Support none visibility binding in bind group

None visibility of shader stage bindings should be supported in
bind group. But Dawn can't support it. The patch fixed this issue.

Bug: dawn:385

Change-Id: I5b747abead24050b56b0fd0a9de561c87df4e36e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/19340
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
This commit is contained in:
Yunchao He 2020-04-13 20:01:22 +00:00 committed by Commit Bot service account
parent 871651d999
commit 582e5284d0
2 changed files with 19 additions and 4 deletions

View File

@ -600,6 +600,24 @@ TEST_F(BindGroupLayoutValidationTest, BindGroupLayoutVisibilityNone) {
device.CreateBindGroupLayout(&descriptor);
}
// This test verifies that binding with none visibility in bind group layout can be supported in
// bind group
TEST_F(BindGroupLayoutValidationTest, BindGroupLayoutVisibilityNoneExpectsBindGroupEntry) {
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {
{0, wgpu::ShaderStage::Vertex, wgpu::BindingType::UniformBuffer},
{1, wgpu::ShaderStage::None, wgpu::BindingType::UniformBuffer},
});
wgpu::BufferDescriptor descriptor;
descriptor.size = 4;
descriptor.usage = wgpu::BufferUsage::Uniform;
wgpu::Buffer buffer = device.CreateBuffer(&descriptor);
utils::MakeBindGroup(device, bgl, {{0, buffer}, {1, buffer}});
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, bgl, {{0, buffer}}));
}
// Check that dynamic buffer numbers exceed maximum value in one bind group layout.
TEST_F(BindGroupLayoutValidationTest, DynamicBufferNumberLimit) {
wgpu::BindGroupLayout bgl[2];

View File

@ -275,13 +275,10 @@ namespace utils {
wgpu::BindGroupLayout MakeBindGroupLayout(
const wgpu::Device& device,
std::initializer_list<wgpu::BindGroupLayoutEntry> bindingsInitializer) {
constexpr wgpu::ShaderStage kNoStages{};
std::vector<wgpu::BindGroupLayoutEntry> bindings;
for (const wgpu::BindGroupLayoutEntry& binding : bindingsInitializer) {
if (binding.visibility != kNoStages) {
bindings.push_back(binding);
}
bindings.push_back(binding);
}
wgpu::BindGroupLayoutDescriptor descriptor;