Allow Bind Group Layout Binding visibility to be None
According to https://github.com/gpuweb/gpuweb/issues/405, None is a valid value for GPUBindGroupLayoutBinding visibility to be passed in. Bug: dawn:22 Change-Id: I7b30b7ab8ed6824718573fa25fad5d509846db55 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11980 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: François Beaufort <beaufort.francois@gmail.com>
This commit is contained in:
parent
91b2142ee4
commit
bed0fdf7ad
|
@ -49,10 +49,6 @@ namespace dawn_native {
|
||||||
return DAWN_VALIDATION_ERROR("some binding index was specified more than once");
|
return DAWN_VALIDATION_ERROR("some binding index was specified more than once");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (binding.visibility == dawn::ShaderStage::None) {
|
|
||||||
return DAWN_VALIDATION_ERROR("Visibility of bindings can't be None");
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (binding.type) {
|
switch (binding.type) {
|
||||||
case dawn::BindingType::UniformBuffer:
|
case dawn::BindingType::UniformBuffer:
|
||||||
if (binding.hasDynamicOffset) {
|
if (binding.hasDynamicOffset) {
|
||||||
|
|
|
@ -776,4 +776,35 @@ TEST_P(BindGroupTests, DrawThenChangePipelineAndBindGroup) {
|
||||||
EXPECT_PIXEL_RGBA8_EQ(notFilled, renderPass.color, max, max);
|
EXPECT_PIXEL_RGBA8_EQ(notFilled, renderPass.color, max, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test that visibility of bindings in BindGroupLayout can be none
|
||||||
|
// This test passes by not asserting or crashing.
|
||||||
|
TEST_P(BindGroupTests, BindGroupLayoutVisibilityCanBeNone) {
|
||||||
|
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
|
||||||
|
|
||||||
|
dawn::BindGroupLayoutBinding binding = {0, dawn::ShaderStage::None,
|
||||||
|
dawn::BindingType::UniformBuffer};
|
||||||
|
dawn::BindGroupLayoutDescriptor descriptor;
|
||||||
|
descriptor.bindingCount = 1;
|
||||||
|
descriptor.bindings = &binding;
|
||||||
|
dawn::BindGroupLayout layout = device.CreateBindGroupLayout(&descriptor);
|
||||||
|
|
||||||
|
dawn::RenderPipeline pipeline = MakeTestPipeline(renderPass, {}, {layout});
|
||||||
|
|
||||||
|
std::array<float, 4> color = {1, 0, 0, 1};
|
||||||
|
dawn::Buffer uniformBuffer =
|
||||||
|
utils::CreateBufferFromData(device, &color, sizeof(color), dawn::BufferUsage::Uniform);
|
||||||
|
dawn::BindGroup bindGroup =
|
||||||
|
utils::MakeBindGroup(device, layout, {{0, uniformBuffer, 0, sizeof(color)}});
|
||||||
|
|
||||||
|
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||||
|
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
|
||||||
|
pass.SetPipeline(pipeline);
|
||||||
|
pass.SetBindGroup(0, bindGroup);
|
||||||
|
pass.Draw(3, 1, 0, 0);
|
||||||
|
pass.EndPass();
|
||||||
|
|
||||||
|
dawn::CommandBuffer commands = encoder.Finish();
|
||||||
|
queue.Submit(1, &commands);
|
||||||
|
}
|
||||||
|
|
||||||
DAWN_INSTANTIATE_TEST(BindGroupTests, D3D12Backend, MetalBackend, OpenGLBackend, VulkanBackend);
|
DAWN_INSTANTIATE_TEST(BindGroupTests, D3D12Backend, MetalBackend, OpenGLBackend, VulkanBackend);
|
||||||
|
|
|
@ -526,7 +526,7 @@ TEST_F(BindGroupLayoutValidationTest, DynamicAndTypeCompatibility) {
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
// This test verifies that visibility of bindings in BindGroupLayout can't be none
|
// This test verifies that visibility of bindings in BindGroupLayout can be none
|
||||||
TEST_F(BindGroupLayoutValidationTest, BindGroupLayoutVisibilityNone) {
|
TEST_F(BindGroupLayoutValidationTest, BindGroupLayoutVisibilityNone) {
|
||||||
utils::MakeBindGroupLayout(device,
|
utils::MakeBindGroupLayout(device,
|
||||||
{
|
{
|
||||||
|
@ -538,7 +538,7 @@ TEST_F(BindGroupLayoutValidationTest, BindGroupLayoutVisibilityNone) {
|
||||||
dawn::BindGroupLayoutDescriptor descriptor;
|
dawn::BindGroupLayoutDescriptor descriptor;
|
||||||
descriptor.bindingCount = 1;
|
descriptor.bindingCount = 1;
|
||||||
descriptor.bindings = &binding;
|
descriptor.bindings = &binding;
|
||||||
ASSERT_DEVICE_ERROR(device.CreateBindGroupLayout(&descriptor));
|
device.CreateBindGroupLayout(&descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that dynamic buffer numbers exceed maximum value in one bind group layout.
|
// Check that dynamic buffer numbers exceed maximum value in one bind group layout.
|
||||||
|
|
Loading…
Reference in New Issue