GLSL fragment shader is producing this error: Mesa 7.7.1 implementation error: Invalid src register file 12 in get_src_register_pointer() Please report at bugzilla.freedesktop.org I've reduced the code down as much as I could while still reproducing the bug: --- shader.frag -------------- uniform sampler3D volShadSampler0; struct VolShad { sampler3D texture; int samples; int channels; mat4 worldToScreen; }; vec3 testfunc(VolShad vs, vec3 p) { return vec3(1.0, 1.0, 1.0); } void main() { // (Initializing the VolShad struct this way also causes the error) //VolShad volShad0 = VolShad(volShadSampler0, 8, 3, mat4(0.987538, 0.911446, 0.626908, 0.626908, 0, 2.20361, -0.496881, -0.49688, 1.03169, -0.872442, -0.600081, -0.600081, -47.4917, 35.4831, 75.2649, 75.3648)); VolShad volShad0; volShad0.texture = volShadSampler0; volShad0.texture = 8; volShad0.channels = 3; volShad0.worldToScreen = mat4(0.987538, 0.911446, 0.626908, 0.626908, 0, 2.20361, -0.496881, -0.49688, 1.03169, -0.872442, -0.600081, -0.600081, -47.4917, 35.4831, 75.2649, 75.3648); vec3 outputColor = testfunc(volShad0, vec3(1, 1, 1)); gl_FragColor = vec4(1, 1, 1, 1); }
(In reply to comment #0) > uniform sampler3D volShadSampler0; > > struct VolShad > { > sampler3D texture; > int samples; > int channels; > mat4 worldToScreen; > }; [snip] > VolShad volShad0; > volShad0.texture = volShadSampler0; > volShad0.texture = 8; This shouldn't compile. It is invalid to assign 8 to a sampler3D.
Oops, I'm sorry. That's a typo as I was cleaning it up for submission. It should read: VolShad volShad0; volShad0.texture = volShadSampler0; volShad0.samples = 8; It seems that having the sampler3D as a member of the struct is causing the problem. I was able to workaround it for now by removing the "texture" field from the struct and carrying it along as a separate argument to my function.
There is a piglit testcase for this now: glsl-fs-uniform-sampler-struct
(In reply to comment #2) > Oops, I'm sorry. That's a typo as I was cleaning it up for submission. It > should read: > > VolShad volShad0; > volShad0.texture = volShadSampler0; > volShad0.samples = 8; Which is still invalid. From page 17 (page 23 of the PDF) of the GLSL 1.20 spec: "Samplers cannot be treated as l-values; hence cannot be used as out or inout function parameters, nor can they be assigned into." I notice that Nvidia's driver accepts this shader, but their compiler is clearly wrong here. I'm leaving the bug open because: 1. glsl-fs-uniform-sampler-struct tests legal behavior and fails. 2. The glsl2 compiler accepts this invalid shader. I've added two tests to piglit, sampler-01.frag and sampler-02.frag, for this issue.
commit c735d85395f8f0c0a71b04ebc728390970271fe2 Author: Eric Anholt <eric@anholt.net> Date: Wed Aug 25 23:27:56 2010 -0700 glsl: Don't consider things with a type containing a sampler as an lvalue. We had ad-hoc handled some common cases by flagging sampler-typed variables as read_only, and rejected initializers of samplers. However, people could sneak them in in all sorts of surprising ways, like using whole-array or structure assignment. Fixes: glslparsertest/glsl2/sampler-01.frag glslparsertest/glsl2/sampler-03.frag glslparsertest/glsl2/sampler-04.frag glslparsertest/glsl2/sampler-06.frag Bug #27403.
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.