[Mesa-dev] Mesa (master): tgsi: collect texture sampler target info in tgsi_scan_shader()

Michel Dänzer michel at daenzer.net
Wed Mar 30 08:06:45 UTC 2016


Hi Brian,


On 30.03.2016 09:16, Brian Paul wrote:
> Module: Mesa
> Branch: master
> Commit: 86e1768c13d67945f4a9549820e711b70ff2aba7
> URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=86e1768c13d67945f4a9549820e711b70ff2aba7
> 
> Author: Brian Paul <brianp at vmware.com>
> Date:   Sat Mar 26 11:46:53 2016 -0600
> 
> tgsi: collect texture sampler target info in tgsi_scan_shader()
> 
> Texture sample instructions specify a sampler unit and texture target
> such as "1D", "2D", "CUBE", etc.  Sampler view declarations also specify
> the sampler unit and texture target.
> 
> This patch checks that the texture instructions agree with the declarations
> and collects the texture target type for each sampler unit.
> 
> v2: only compare instruction's texture target to the sampler view declaration
> target if the instruction is a TEX instruction, not a SAMPLE instruction.
> 
> Reviewed-by: José Fonseca <jfonseca at vmware.com>
> Reviewed-by: Roland Scheidegger <sroland at vmware.com>

[...]

> @@ -431,6 +453,16 @@ scan_declaration(struct tgsi_shader_info *info,
>           }
>        } else if (file == TGSI_FILE_SAMPLER) {
>           info->samplers_declared |= 1 << reg;
> +      } else if (file == TGSI_FILE_SAMPLER_VIEW) {
> +         unsigned target = fulldecl->SamplerView.Resource;
> +         assert(target < TGSI_TEXTURE_UNKNOWN);
> +         if (info->sampler_targets[reg] == TGSI_TEXTURE_UNKNOWN) {
> +            /* Save sampler target for this sampler index */
> +            info->sampler_targets[reg] = target;
> +         } else {
> +            /* if previously declared, make sure targets agree */
> +            assert(info->sampler_targets[reg] == target);
> +         }

This broke a bunch of arb_gpu_shader5 piglit tests for me, e.g.
spec at arb_gpu_shader5@texturegather at fs-r-none-shadow-2d:

textureGather: ../../../../src/gallium/auxiliary/tgsi/tgsi_scan.c:206:
scan_instruction: Assertion `info->sampler_targets[index] == target' failed.

This is the TGSI:

FRAG
PROPERTY FS_COLOR0_WRITES_ALL_CBUFS 1
DCL SV[0], POSITION
DCL OUT[0], COLOR
DCL SAMP[0]
DCL SVIEW[0], SHADOW2D, FLOAT
DCL CONST[1]
DCL TEMP[0]
DCL TEMP[1..2], LOCAL
IMM[0] INT32 {0, 0, 0, 0}
IMM[1] FLT32 {    0.5000,     0.0000,     0.0000,     0.0000}
  0: MOV TEMP[0], SV[0]
  1: MAD TEMP[0].y, SV[0], CONST[1].xxxx, CONST[1].yyyy
  2: TXQ TEMP[1].xy, IMM[0].xxxx, SAMP[0], 2D
  3: I2F TEMP[1].xy, TEMP[1].xyyy
  4: RCP TEMP[2].x, TEMP[1].xxxx
  5: RCP TEMP[2].y, TEMP[1].yyyy
  6: MUL TEMP[1].xy, TEMP[0].xyyy, TEMP[2].xyyy
  7: MOV TEMP[1].xy, TEMP[1].xyyy
  8: MOV TEMP[1].z, IMM[1].xxxx
  9: TG4 TEMP[1], TEMP[1], IMM[0].xxxx, SAMP[0], SHADOW2D
 10: MOV OUT[0], TEMP[1]
 11: END


The problem is that the TXQ instruction (generated from GLSL
textureSize) uses 2D as the target, but the sampler view is declared as
SHADOW2D.

I'm not sure if this is a bug in glsl_to_tgsi or the GLSL compiler, or
if scan_declaration needs to be relaxed.


-- 
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer


More information about the mesa-dev mailing list