OSDN Git Service

i915: Fix texcoord vs. varying collision in fragment programs
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Wed, 2 Jul 2014 14:28:23 +0000 (17:28 +0300)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Thu, 16 Jul 2015 13:48:41 +0000 (21:48 +0800)
commit048ceab6a0e71cd1866b011f197d6be36fe4d1a8
treef039a4edb9db5d9fa2598fcd473c83dac22ff812
parent1cd32687c231fec941c8500c4457966606cb0ed3
i915: Fix texcoord vs. varying collision in fragment programs

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;
 }

This was tested on a PNV.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
src/mesa/drivers/dri/i915/i915_context.h
src/mesa/drivers/dri/i915/i915_fragprog.c