Bug 31810 - r600g: Sampling from an alpha texture in a fragment shader
Summary: r600g: Sampling from an alpha texture in a fragment shader
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Drivers/Gallium/r600 (show other bugs)
Version: git
Hardware: Other All
: medium normal
Assignee: Default DRI bug account
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-21 04:47 UTC by Owen Taylor
Modified: 2010-11-21 22:05 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
piglit patch described (4.47 KB, application/octet-stream)
2010-11-21 04:47 UTC, Owen Taylor
Details
Slightly simpler version of Piglit test (4.38 KB, patch)
2010-11-21 06:53 UTC, Owen Taylor
Details | Splinter Review

Description Owen Taylor 2010-11-21 04:47:04 UTC
Created attachment 40447 [details]
piglit patch described

The attach piglit addition works on g600c and softpipe fails on r600g.

(The test is close to minimal, but not having diagnosed the bug
I don't know if "sampling from an alpha texture" is the fundamental
thing that needs to be tested or not... or there could even be failing
piglit tests elsewhere that are showing the same problem.)

The TGSI looks right:

DCL IN[0], COLOR, LINEAR
DCL IN[1], GENERIC[0], PERSPECTIVE
DCL OUT[0], COLOR
DCL SAMP[0]
DCL TEMP[0]
  0: TEX TEMP[0], IN[1], SAMP[0], 2D
  1: MUL OUT[0], IN[0], TEMP[0].wwww
  2: END
VERT

Despite spending a lot of time fooling around this yesterday and checking
what I thought were the obvious things I really have no idea what is going
on; hopefully it will be obvious for someone more familiar with the R700
shader code.
Comment 1 Owen Taylor 2010-11-21 06:53:37 UTC
Created attachment 40449 [details] [review]
Slightly simpler version of Piglit test

Here's a slightly simpler version of the test (gets rid of multiplying by a color)

I'm a little reluctant to provide any of the results of my experiments trying to understand this, since I'm still confused and maybe will just confuse anybody following on, but in the SQ_TEX_WORD1 generated from:

 0: TEX TEMP[0], IN[0], SAMP[0], 2D

If I manually tweak the DST_SEL_X/DEST_SEL_Y/DEST_SEL_Z/DEST_SEL_W I see the
following results for the loaded stored into the temporary:

 Sel  Result
 xyzw xyzw
 ---------
 1000 1000
 0100 0100
 0010 0010
 0001 0001

 0w00 0000
 0w01 0001

 100w 1001
 1w00 1100 (example A)

 w000 w000
 w001 w001
 ww01 ww01 (example B)
 w100 w100
 w00w w00w

So, in the marked example A above, if I set DST_SEL_X to SQ_SEL_1 and DST_SEL_Y to SQ_SEL_W and DST_SEL_Z and DST_SEL_W to SQ_SEL_0, then I end up with a value that has 1's for x and y, and 0's for z and w.

Possibly wrong interpretation: In all the cases above what you an observe is that the value of a component is the same as if you first replaced w with the value selected by DST_SEL_X and then applied the actual selector.

So, DST_SEL_Y=SQ_SEL_W in example A gave us 1 because DST_SEL_X=SQ_SEL_1, but in example B it gave us w because DST_SEL_X=SQ_SEL_1.

This might have something to do with the interaction with the swizzle inherent to the A8 texture format that sets X,Y,Z=0 and W=X. That would match up with this only occurring for A8 textures and not for RGBA textures.  but I don't understand why a swizzle at texture load time would cause the selectors from INST_TEX to have a double effect. Anyways, I'm still confused. I don't really have time to work on this more, but if it isn't obvious, then one possible approach would be to compare the bytecode and texture setup of the classic driver (which works for this) to what the gallium driver is doing.

Oh, and I should mention that I did my testing on an RV710, in case it's a r6xx/r7xx difference.
Comment 2 Dave Airlie 2010-11-21 21:56:01 UTC
just FYI for anyone else looking at this:

its something to do with the staged texture upload code. disabling it makes it all a lot happier
Comment 3 Dave Airlie 2010-11-21 22:05:49 UTC
should be fixed by
d5aadf0d80e8c973ef5cf9d82e97f23f0e3c032b in mesa master.

Thanks Owen for the test program made it a lot easier to track down.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.