From c349031c27b7f66151f07d785625c585e10a92c2 Mon Sep 17 00:00:00 2001 From: Ville Syrjälä Date: Mon, 23 Mar 2015 14:47:36 +0200 Subject: i915: Fix texcoord vs. varying collision in fragment programs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit i915 fragment programs utilize the texture coordinate registers for both texture coordinates and varyings. Unfortunately the code doesn't check if the same index might be in use for both. It just naively uses the index to pick a texture unit, which could lead to collisions. Add an extra mapping step to allocate non conflicting texture units for both uses. The issue can be reproduced with a pair of simple shaders like these: attribute vec4 in_mod; varying vec4 mod; void main() { mod = in_mod; gl_TexCoord[0] = gl_MultiTexCoord0; gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; } varying vec4 mod; uniform sampler2D tex; void main() { gl_FragColor = texture2D(tex, vec2(gl_TexCoord[0])) * mod; } Fixes many piglit tests on i915: glsl-link-varyings-2 glsl-orangebook-ch06-bump interpolation-none-gl_frontcolor-smooth-fixed interpolation-none-gl_frontcolor-smooth-none interpolation-none-gl_frontcolor-smooth-vertex interpolation-none-gl_frontsecondarycolor-smooth-fixed interpolation-none-gl_frontsecondarycolor-smooth-vertex interpolation-none-gl_frontsecondarycolor-smooth-none interpolation-none-other-flat-fixed interpolation-none-other-flat-none interpolation-none-other-flat-vertex interpolation-none-other-smooth-fixed interpolation-none-other-smooth-none interpolation-none-other-smooth-vertex v2 [idr]: Minor formatting tweaks. Signed-off-by: Ville Syrjälä Reviewed-by: Ian Romanick Cc: "11.0" --- src/mesa/drivers/dri/i915/i915_context.h | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'src/mesa/drivers/dri/i915/i915_context.h') diff --git a/src/mesa/drivers/dri/i915/i915_context.h b/src/mesa/drivers/dri/i915/i915_context.h index fa58ecb8165..d8f592bcb9f 100644 --- a/src/mesa/drivers/dri/i915/i915_context.h +++ b/src/mesa/drivers/dri/i915/i915_context.h @@ -115,6 +115,8 @@ enum { I915_RASTER_RULES_SETUP_SIZE, }; +#define I915_TEX_UNITS 8 + #define I915_MAX_CONSTANT 32 #define I915_CONSTANT_SIZE (2+(4*I915_MAX_CONSTANT)) @@ -194,7 +196,8 @@ struct i915_fragment_program /* Helpers for i915_fragprog.c: */ - GLuint wpos_tex; + uint8_t texcoord_mapping[I915_TEX_UNITS]; + uint8_t wpos_tex; bool depth_written; struct @@ -205,15 +208,6 @@ struct i915_fragment_program GLuint nr_params; }; - - - - - - -#define I915_TEX_UNITS 8 - - struct i915_hw_state { GLuint Ctx[I915_CTX_SETUP_SIZE]; -- cgit v1.2.3