mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 01:15:35 +00:00
gpu: fix clip intersection with the D3D backend
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -17,6 +17,23 @@ vec3[2] fboTextureTransform() {
|
||||
return t;
|
||||
}
|
||||
|
||||
// fboTransform returns a transformation
|
||||
// that cancels the implied transformation between
|
||||
// the clip space and the framebuffer.
|
||||
// Only two rows are returned. The last is implied
|
||||
// to be [0, 0, 1].
|
||||
vec3[2] fboTransform() {
|
||||
vec3[2] t;
|
||||
#ifdef HLSL
|
||||
t[0] = vec3(1.0, 0.0, 0.0);
|
||||
t[1] = vec3(0.0, 1.0, 0.0);
|
||||
#else
|
||||
t[0] = vec3(1.0, 0.0, 0.0);
|
||||
t[1] = vec3(0.0, -1.0, 0.0);
|
||||
#endif
|
||||
return t;
|
||||
}
|
||||
|
||||
// toClipSpace converts an OpenGL gl_Position value to a
|
||||
// native GPU position.
|
||||
vec4 toClipSpace(vec4 pos) {
|
||||
|
||||
@@ -4,18 +4,25 @@
|
||||
|
||||
precision highp float;
|
||||
|
||||
#include <common.inc>
|
||||
|
||||
layout(location = 0) in vec2 pos;
|
||||
layout(location = 1) in vec2 uv;
|
||||
|
||||
layout(binding = 0) uniform Block {
|
||||
vec4 uvTransform;
|
||||
vec4 subUVTransform;
|
||||
};
|
||||
|
||||
layout(location = 0) out vec2 vUV;
|
||||
|
||||
void main() {
|
||||
vec2 p = pos;
|
||||
p.y = -p.y;
|
||||
gl_Position = vec4(p, 0, 1);
|
||||
vUV = uv*uvTransform.xy + uvTransform.zw;
|
||||
vec3[2] fboTrans = fboTransform();
|
||||
vec3 p = transform3x2(fboTrans, vec3(pos, 1.0));
|
||||
gl_Position = vec4(p, 1);
|
||||
vec3[2] fboTexTrans = fboTextureTransform();
|
||||
vec3 uv3 = transform3x2(fboTexTrans, vec3(uv, 1.0));
|
||||
vUV = uv3.xy*subUVTransform.xy + subUVTransform.zw;
|
||||
vUV = transform3x2(fboTexTrans, vec3(vUV, 1.0)).xy;
|
||||
vUV = vUV*uvTransform.xy + uvTransform.zw;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user