[PATCH 5/5] wined3d: Avoid using GL_MAX_VARYING_FLOATS_ARB in core profile contexts.

Matteo Bruni mbruni at codeweavers.com
Fri Oct 12 08:39:57 CDT 2018


Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
---
It's deprecated in core profile and removed in forward-compatible
contexts, although the spec suggests that it has a use still:
"Additionally, when linking a program containing only a vertex and
fragment shader, there is a limit on the total number of components
used as vertex shader outputs or fragment shader inputs. This limit is
given by the value of the implementation-dependent constant
MAX_VARYING_COMPONENTS."

Nvidia binary drivers on a GTX 970 report 128 for all the
GL_MAX_*_{INPUT|OUTPUT}_COMPONENTS but only 124 for
GL_MAX_VARYING_FLOATS_ARB. Actually that is correct since
GL_MAX_VARYING_FLOATS_ARB DOESN'T include gl_Position (see the same
area of the spec as above).

Mesa (r600g at least) does return 128 for GL_MAX_VARYING_FLOATS_ARB,
which means glsl_varyings will go down by 1 there. It shouldn't make
any practical difference for us though.

 dlls/wined3d/adapter_gl.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/dlls/wined3d/adapter_gl.c b/dlls/wined3d/adapter_gl.c
index cedfe239bc..99df19cc31 100644
--- a/dlls/wined3d/adapter_gl.c
+++ b/dlls/wined3d/adapter_gl.c
@@ -3079,9 +3079,18 @@ static void wined3d_adapter_init_limits(struct wined3d_gl_info *gl_info, struct
         gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB, &gl_max);
         gl_info->limits.glsl_ps_float_constants = gl_max / 4;
         TRACE("Max ARB_FRAGMENT_SHADER float constants: %u.\n", gl_info->limits.glsl_ps_float_constants);
-        gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VARYING_FLOATS_ARB, &gl_max);
-        gl_info->limits.glsl_varyings = gl_max;
-        TRACE("Max GLSL varyings: %u (%u 4 component varyings).\n", gl_max, gl_max / 4);
+        if (gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
+        {
+            gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_VARYING_FLOATS_ARB, &gl_max);
+            gl_info->limits.glsl_varyings = gl_max;
+        }
+        else
+        {
+            gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_FRAGMENT_INPUT_COMPONENTS, &gl_max);
+            gl_info->limits.glsl_varyings = gl_max - 4;
+        }
+        TRACE("Max GLSL varyings: %u (%u 4 component varyings).\n", gl_info->limits.glsl_varyings,
+                gl_info->limits.glsl_varyings / 4);
 
         if (gl_info->supported[ARB_UNIFORM_BUFFER_OBJECT])
         {
-- 
2.18.1




More information about the wine-devel mailing list