[Mesa-dev] r600: Regarding "Failed to build shader (translation from TGSI) #99349

Gert Wollny gw.fossdev at gmail.com
Mon May 29 14:45:46 UTC 2017


Hello all, 


Hardware; Radeon 6850HD, 
Mesa: mesa 17.0.1 and git (sha 531887), 
llvm:
4.0.0

Playing a bit around with the Unreal Editor I was confronted with the
same error message reported in #99349, i.e. "Failed to build shader
(translation from TGSI). 

After some digging though the code I found that the TGSI code [1] of
the offending shader reserves 151 temporaries so that the available 128
GPRs are already allocated right from the start, and when the operation
"MUL TEMP[11], CONST[26], CONST[23]" is translated to byte code,
both constants are read from the cfile region, because 
tgsi_split_constant could not move one constant to a proper GPR.

As one can see in the TGSI dump [1], the shader does not really use 151
temporaries, only 40 are actually also addresses as source, to all the
other temps values are just written once (assuming the the TGSI
notation is OP DEST, SRC0, SRC1 ...). 

My questions are now: 

Does the GSLS-TGSI stage of the compilation do any optimizations?
Specifically, should the unused temporaries be eliminated in that step
and that I get this TGSI-dump is actually a bug in this compilation
stage? (In the Gallium3D wikipedia article [2] it is written that there
is a TGSI optimization stage.) 

As far as I understand there is a optimization pass done after the TGSI
translation, but because of the nature of the problem the shader is
rejected before. Would it make sense to implement a patch that would
work around this problem by reserving some GORs to move constants to
(and the temporary that is now ctx.temp_reg), and then test the number
of allocated registers only after the byte code optimization?  I
partially implemented something like this [3] when I tried to find the
source of the bug, so I could clean that up and propose a patch, so far
the graphical output is clobbered though. 


many thank, 
Gert 





[1]  https://bugs.freedesktop.org/attachment.cgi?id=131567 
(12kb, xz compressed)

[2] https://en.wikipedia.org/wiki/Gallium3D#Tungsten_Graphics_Shader_In
frastructure

[3] https://github.com/gerddie/mesa


More information about the mesa-dev mailing list