"before all" hook for "setPipeline" ‣
TypeError: Cannot read properties of undefined (reading 'createShaderModule')
at Context.<anonymous> (https://greggman.github.io/webgpu-avoid-redundant-state-setting/test/tests/webgpu-avoid-redundant-state-setting-tests.js:90:31)
at callFn (https://greggman.github.io/webgpu-avoid-redundant-state-setting/test/mocha.js:13124:23)
at Runnable$3.run (https://greggman.github.io/webgpu-avoid-redundant-state-setting/test/mocha.js:13112:7)
at next (https://greggman.github.io/webgpu-avoid-redundant-state-setting/test/mocha.js:14489:12)
at https://greggman.github.io/webgpu-avoid-redundant-state-setting/test/mocha.js:14550:7
at timeslice (https://greggman.github.io/webgpu-avoid-redundant-state-setting/test/mocha.js:20501:29)
const shaderSrc = `
@group(0) @binding(0) var<storage, read_write> data0: array<f32>;
@group(0) @binding(2) var<storage, read_write> data1: array<f32>;
@compute @workgroup_size(1) fn computeSomething(
@builtin(global_invocation_id) id: vec3<u32>
) {
_ = &data0;
_ = &data1;
}
`;
const module = device.createShaderModule({code: shaderSrc});
const pipelineDesc = {
layout: 'auto',
compute: {
module,
entryPoint: 'computeSomething',
},
};
pipeline0 = device.createComputePipeline(pipelineDesc);
pipeline1 = device.createComputePipeline(pipelineDesc);
const storageBuffer0 = device.createBuffer({
size: 1024,
usage: GPUBufferUsage.STORAGE,
});
const storageBuffer1 = device.createBuffer({
size: 1024,
usage: GPUBufferUsage.STORAGE,
});
bindGroup0 = device.createBindGroup({
label: 'group0',
layout: pipeline0.getBindGroupLayout(0),
entries: [
{ binding: 0, resource: { buffer: storageBuffer0 } },
{ binding: 2, resource: { buffer: storageBuffer1 } },
],
});
bindGroup1 = device.createBindGroup({
label: 'group1',
layout: pipeline0.getBindGroupLayout(0),
entries: [
{ binding: 0, resource: { buffer: storageBuffer0 } },
{ binding: 2, resource: { buffer: storageBuffer1 } },
],
});
const bindGroupLayout = device.createBindGroupLayout({
entries: [
{ binding: 0, visibility: GPUShaderStage.COMPUTE, buffer: { type: "read-only-storage", hasDynamicOffset: true } },
{ binding: 2, visibility: GPUShaderStage.COMPUTE, buffer: { type: "read-only-storage", hasDynamicOffset: true } },
],
});
dynamicBindGroup0 = device.createBindGroup({
label: 'dynamicGroup0',
layout: bindGroupLayout,
entries: [
{ binding: 0, resource: { buffer: storageBuffer0, size: 512 } },
{ binding: 2, resource: { buffer: storageBuffer1, size: 512 } },
],
});
dynamicBindGroup0 = device.createBindGroup({
label: 'dynamicGroup1',
layout: bindGroupLayout,
entries: [
{ binding: 0, resource: { buffer: storageBuffer0, size: 512 } },
{ binding: 2, resource: { buffer: storageBuffer1, size: 512 } },
],
});
pass = encoder.beginComputePass();