Summary: | GLSL struct causing "Invalid src register file ..." error | ||
---|---|---|---|
Product: | Mesa | Reporter: | Brian Hall <brian.hall> |
Component: | Mesa core | Assignee: | Eric Anholt <eric> |
Status: | RESOLVED FIXED | QA Contact: | |
Severity: | normal | ||
Priority: | medium | CC: | brian.hall |
Version: | 7.6 | ||
Hardware: | x86-64 (AMD64) | ||
OS: | Linux (All) | ||
Whiteboard: | |||
i915 platform: | i915 features: | ||
Bug Depends on: | |||
Bug Blocks: | 29044 |
Description
Brian Hall
2010-03-31 15:56:06 UTC
(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.