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); 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. // Check that dynamic buffer numbers exceed maximum value in one bind group layout.
TEST_F(BindGroupLayoutValidationTest, DynamicBufferNumberLimit) { TEST_F(BindGroupLayoutValidationTest, DynamicBufferNumberLimit) {
wgpu::BindGroupLayout bgl[2]; wgpu::BindGroupLayout bgl[2];

View File

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