-
struct Uniforms { resolution: vec2f, time: f32 };
@binding(0) @group(0) var<uniform> U : Uniforms;
@binding(1) @group(0) var mySampler: sampler;
@binding(2) @group(0) var myTexture: texture_2d<f32>;
struct out{
position: vec4f,
color: vec3f
}
@fragment
fn main(@builtin(position) fragCoord : vec4f,
@location(0) color: vec3f) -> @location(0) vec4<f32>
{
var uv = fragCoord.xy/U.resolution ;//* 2. -1.;
//uv*= vec2f(1, -1);
var col:vec4f = textureSample(myTexture,mySampler,uv);
return vec4<f32>(color,1.);
}Everything works fine until I comment this line var col:vec4f = textureSample(myTexture,mySampler,uv);I receive this error I'm getting an error for not using these bindings, am I forced to use them? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
|
I'll point out that this issue list is for problems with the specs, not questions about using the API. That being said, this is intended WGSL behavior. The workaround is to use a phony assignment to indicate to WGSL that the variable is still "in use". @fragment
fn main(@builtin(position) fragCoord : vec4f,
@location(0) color: vec3f) -> @location(0) vec4<f32>
{
var uv = fragCoord.xy/U.resolution ;//* 2. -1.;
//uv*= vec2f(1, -1);
// Do a phony assignment to ensure that these variables are not removed from the autogenerated bind group layout.
_ = myTexture;
_ = mySampler;
//var col:vec4f = textureSample(myTexture,mySampler,uv);
return vec4<f32>(color,1.);
}The other way to work around this is to stop using |
Beta Was this translation helpful? Give feedback.
I'll point out that this issue list is for problems with the specs, not questions about using the API.
That being said, this is intended WGSL behavior. The workaround is to use a phony assignment to indicate to WGSL that the variable is still "in use".