Matteo Bruni : wined3d: Declare gl_Position as invariant.

Alexandre Julliard julliard at winehq.org
Mon Nov 22 16:05:16 CST 2021


Module: wine
Branch: master
Commit: 884b7c50cfd902eff9a41562a103e3bd5747422b
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=884b7c50cfd902eff9a41562a103e3bd5747422b

Author: Matteo Bruni <mbruni at codeweavers.com>
Date:   Fri Nov 19 20:50:30 2021 +0100

wined3d: Declare gl_Position as invariant.

All D3D versions seem to basically guarantee invariance for the vertex
position at the very least. In practice, desktop GL implementations
also do the same.
That's not necessarily the case for tile based renderers, where the
cost of providing invariance might be non negligible. We want this
behavior though, so let's ask for it explicitly.

Based on a patch by Stefan Dösinger.

Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/wined3d/glsl_shader.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index adfbf60e726..4e51402f1cf 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -2184,6 +2184,14 @@ static void shader_generate_glsl_declarations(const struct wined3d_context_gl *c
         if (map & 1) shader_addline(buffer, "void subroutine%u();\n", i);
     }
 
+    if (version->type != WINED3D_SHADER_TYPE_PIXEL && version->type != WINED3D_SHADER_TYPE_COMPUTE)
+    {
+        if (version->type == WINED3D_SHADER_TYPE_HULL)
+            shader_addline(buffer, "out gl_PerVertex { invariant vec4 gl_Position; } gl_out[];\n");
+        else
+            shader_addline(buffer, "invariant gl_Position;\n");
+    }
+
     /* Declare the constants (aka uniforms) */
     if (shader->limits->constant_float > 0)
     {
@@ -7125,6 +7133,8 @@ static GLuint shader_glsl_generate_vs3_rasterizer_input_setup(struct shader_glsl
 
     shader_glsl_add_version_declaration(buffer, gl_info);
 
+    shader_addline(buffer, "invariant gl_Position;\n");
+
     if (per_vertex_point_size)
     {
         shader_addline(buffer, "uniform struct\n{\n");
@@ -8994,6 +9004,8 @@ static GLuint shader_glsl_generate_ffp_vertex_shader(struct shader_glsl_priv *pr
     if (shader_glsl_use_explicit_attrib_location(gl_info))
         shader_addline(buffer, "#extension GL_ARB_explicit_attrib_location : enable\n");
 
+    shader_addline(buffer, "invariant gl_Position;\n");
+
     for (i = 0; i < WINED3D_FFP_ATTRIBS_COUNT; ++i)
     {
         const char *type = i < ARRAY_SIZE(attrib_info) ? attrib_info[i].type : "vec4";




More information about the wine-cvs mailing list