Skip to content

Commit

Permalink
Test creating pipeline with a pipeline layout with null bind group la…
Browse files Browse the repository at this point in the history
…yout

This patch adds tests about the compatibility checks between a pipeline
layout with null bind group layout and the binding declarations in shader.

Bug: chromium:377836524, chromium:42241530
Test: dawn_unittests
Change-Id: Ibefce4743e05a05f0e2ff8263523853ec3731f68
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/215094
Reviewed-by: Corentin Wallez <[email protected]>
Reviewed-by: Loko Kung <[email protected]>
Commit-Queue: Jiawei Shao <[email protected]>
  • Loading branch information
Jiawei-Shao authored and Dawn LUCI CQ committed Nov 19, 2024
1 parent 476693a commit 1123688
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/dawn/tests/unittests/validation/BindGroupValidationTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3664,6 +3664,48 @@ TEST_F(PipelineLayoutValidationTest, CreateWithNullBindGroupLayout) {
}
}

// Test the pipeline layout with null bind group layout must match the corresponding binding in
// shader.
TEST_F(PipelineLayoutValidationTest, ShaderMatchesPipelineLayoutWithNullBindGroupLayout) {
for (uint32_t nullBGLIndex = 0; nullBGLIndex < 4; ++nullBGLIndex) {
std::vector<wgpu::BindGroupLayout> bgls(4);
for (uint32_t i = 0; i < 4; ++i) {
if (i == nullBGLIndex) {
continue;
}
bgls[i] = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::Storage}});
}
wgpu::PipelineLayout pipelineLayout = utils::MakePipelineLayout(device, bgls);

for (uint32_t missedGroupIndex = 0; missedGroupIndex < 4; ++missedGroupIndex) {
std::ostringstream stream;
for (uint32_t i = 0; i < 4; ++i) {
if (i != missedGroupIndex) {
stream << "@group(" << i << ") @binding(0) var<storage, read_write> outputData"
<< i << " : u32;\n";
}
}
stream << "@compute @workgroup_size(1, 1) fn main() {\n";
for (uint32_t i = 0; i < 4; ++i) {
if (i != missedGroupIndex) {
stream << "outputData" << i << " = 1u;\n";
}
}
stream << "};";
wgpu::ComputePipelineDescriptor computePipelineDescriptor = {};
computePipelineDescriptor.compute.module =
utils::CreateShaderModule(device, stream.str());
computePipelineDescriptor.layout = pipelineLayout;
if (missedGroupIndex == nullBGLIndex) {
device.CreateComputePipeline(&computePipelineDescriptor);
} else {
ASSERT_DEVICE_ERROR(device.CreateComputePipeline(&computePipelineDescriptor));
}
}
}
}

class PipelineLayoutDontAllowUnsafeAPIValidationTest : public ValidationTest {
protected:
bool AllowUnsafeAPIs() override { return false; }
Expand Down

0 comments on commit 1123688

Please sign in to comment.