@@ -27,7 +27,7 @@ async function main() {
2727 worldViewProjection: mat4x4f,
2828 worldInverseTranspose: mat4x4f,
2929 };
30- @group(0 ) @binding(0) var<uniform> vsUniforms: VSUniforms;
30+ @group(2 ) @binding(0) var<uniform> vsUniforms: VSUniforms;
3131
3232 struct MyVSInput {
3333 @location(0) position: vec4f,
@@ -54,9 +54,9 @@ async function main() {
5454 lightDirection: vec3f,
5555 };
5656
57- @group(0) @binding(1 ) var<uniform> fsUniforms: FSUniforms;
58- @group(0) @binding(2 ) var diffuseSampler: sampler;
59- @group(0) @binding(3 ) var diffuseTexture: texture_2d<f32>;
57+ @group(0) @binding(0 ) var<uniform> fsUniforms: FSUniforms;
58+ @group(0) @binding(1 ) var diffuseSampler: sampler;
59+ @group(0) @binding(2 ) var diffuseTexture: texture_2d<f32>;
6060
6161 @fragment
6262 fn myFSMain(v: MyVSOutput) -> @location(0) vec4f {
@@ -147,13 +147,19 @@ async function main() {
147147 usage : GPUBufferUsage . UNIFORM | GPUBufferUsage . COPY_DST ,
148148 } ) ;
149149
150- const bindGroup = device . createBindGroup ( {
151- layout : pipeline . getBindGroupLayout ( 0 ) ,
150+ const bindGroup0 = device . createBindGroup ( {
151+ layout : bindGroupLayouts [ 0 ] ,
152+ entries : [
153+ { binding : 0 , resource : { buffer : fsUniformBuffer } } ,
154+ { binding : 1 , resource : sampler } ,
155+ { binding : 2 , resource : texture . createView ( ) } ,
156+ ] ,
157+ } ) ;
158+
159+ const bindGroup2 = device . createBindGroup ( {
160+ layout : bindGroupLayouts [ 2 ] ,
152161 entries : [
153162 { binding : 0 , resource : { buffer : vsUniformBuffer } } ,
154- { binding : 1 , resource : { buffer : fsUniformBuffer } } ,
155- { binding : 2 , resource : sampler } ,
156- { binding : 3 , resource : texture . createView ( ) } ,
157163 ] ,
158164 } ) ;
159165
@@ -219,7 +225,8 @@ async function main() {
219225 const commandEncoder = device . createCommandEncoder ( ) ;
220226 const passEncoder = commandEncoder . beginRenderPass ( renderPassDescriptor ) ;
221227 passEncoder . setPipeline ( pipeline ) ;
222- passEncoder . setBindGroup ( 0 , bindGroup ) ;
228+ passEncoder . setBindGroup ( 0 , bindGroup0 ) ;
229+ passEncoder . setBindGroup ( 2 , bindGroup2 ) ;
223230 passEncoder . setVertexBuffer ( 0 , buffers [ 0 ] ) ;
224231 passEncoder . setIndexBuffer ( indexBuffer , indexFormat ) ;
225232 passEncoder . drawIndexed ( numElements ) ;
0 commit comments