Skip to content

Commit

Permalink
Cleanups in webgpu/api/operation/command_buffer (gpuweb#369)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kangz authored Nov 20, 2020
1 parent 84b7ab1 commit f33917f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 30 deletions.
26 changes: 9 additions & 17 deletions src/webgpu/api/operation/command_buffer/compute/basic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,6 @@ g.test('memcpy').fn(async t => {
usage: GPUBufferUsage.COPY_SRC | GPUBufferUsage.STORAGE,
});

const bgl = t.device.createBindGroupLayout({
entries: [
{ binding: 0, visibility: 4, type: 'storage-buffer' },
{ binding: 1, visibility: 4, type: 'storage-buffer' },
],
});
const bg = t.device.createBindGroup({
entries: [
{ binding: 0, resource: { buffer: src, offset: 0, size: 4 } },
{ binding: 1, resource: { buffer: dst, offset: 0, size: 4 } },
],
layout: bgl,
});

const pl = t.device.createPipelineLayout({ bindGroupLayouts: [bgl] });
const pipeline = t.device.createComputePipeline({
computeStage: {
module: t.device.createShaderModule({
Expand All @@ -57,14 +42,21 @@ g.test('memcpy').fn(async t => {
}),
entryPoint: 'main',
},
layout: pl,
});

const bg = t.device.createBindGroup({
entries: [
{ binding: 0, resource: { buffer: src, offset: 0, size: 4 } },
{ binding: 1, resource: { buffer: dst, offset: 0, size: 4 } },
],
layout: pipeline.getBindGroupLayout(0),
});

const encoder = t.device.createCommandEncoder();
const pass = encoder.beginComputePass();
pass.setPipeline(pipeline);
pass.setBindGroup(0, bg);
pass.dispatch(1, 1, 1);
pass.dispatch(1);
pass.endPass();
t.device.defaultQueue.submit([encoder.finish()]);

Expand Down
13 changes: 2 additions & 11 deletions src/webgpu/api/operation/command_buffer/render/rendering.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ g.test('fullscreen_quad').fn(async t => {
});
const colorAttachmentView = colorAttachment.createView();

const pl = t.device.createPipelineLayout({ bindGroupLayouts: [] });
const pipeline = t.device.createRenderPipeline({
vertexStage: {
module: t.device.createShaderModule({
Expand Down Expand Up @@ -50,16 +49,8 @@ g.test('fullscreen_quad').fn(async t => {
}),
entryPoint: 'main',
},
layout: pl,
primitiveTopology: 'triangle-list',
rasterizationState: {
frontFace: 'ccw',
},
colorStates: [{ format: 'rgba8unorm', alphaBlend: {}, colorBlend: {} }],
vertexState: {
indexFormat: 'uint16',
vertexBuffers: [],
},
colorStates: [{ format: 'rgba8unorm' }],
});

const encoder = t.device.createCommandEncoder();
Expand All @@ -73,7 +64,7 @@ g.test('fullscreen_quad').fn(async t => {
],
});
pass.setPipeline(pipeline);
pass.draw(3, 1, 0, 0);
pass.draw(3);
pass.endPass();
encoder.copyTextureToBuffer(
{ texture: colorAttachment, mipLevel: 0, origin: { x: 0, y: 0, z: 0 } },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ g.test('storeOp_controls_whether_1x1_drawn_quad_is_stored')
}),
entryPoint: 'main',
},
layout: t.device.createPipelineLayout({ bindGroupLayouts: [] }),
primitiveTopology: 'triangle-list',
colorStates: [{ format: 'r8unorm' }],
});
Expand All @@ -67,7 +66,7 @@ g.test('storeOp_controls_whether_1x1_drawn_quad_is_stored')
],
});
pass.setPipeline(renderPipeline);
pass.draw(3, 1, 0, 0);
pass.draw(3);
pass.endPass();
t.device.defaultQueue.submit([encoder.finish()]);

Expand Down

0 comments on commit f33917f

Please sign in to comment.