mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-16 16:37:08 +00:00
Update BindingInfo to reflect new BindGroupLayoutEntry structure
Changes the internal BindingInfo structure and any references to it. The BindGroupLayoutEntry information is normalized when converting it into the internal representation, but still accepted as either the old or new layout. A "bindingType" member is added to the BindingInfo that's not present in the BindGroupLayoutEntry itself to indicate which of buffer, sampler, texture, or storageTexture is populated. This proves useful for a myriad of switch statements in the various backends. Bug: dawn:527 Change-Id: I6ae65adae61d0005fc50ed6d1bc2ec9b2a1295ad Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/35862 Commit-Queue: Austin Eng <enga@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org> Auto-Submit: Brandon Jones <bajones@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
ec56b90cea
commit
3af532b8a8
@@ -414,13 +414,19 @@ TEST_F(StorageTextureValidationTests, UnsupportedTextureViewDimensionInBindGroup
|
||||
// render and compute pipeline, the binding type in the bind group layout must match the
|
||||
// declaration in the shader.
|
||||
TEST_F(StorageTextureValidationTests, BindGroupLayoutEntryTypeMatchesShaderDeclaration) {
|
||||
constexpr std::array<wgpu::BindingType, 7> kSupportedBindingTypes = {
|
||||
wgpu::BindingType::UniformBuffer, wgpu::BindingType::StorageBuffer,
|
||||
wgpu::BindingType::ReadonlyStorageBuffer, wgpu::BindingType::Sampler,
|
||||
wgpu::BindingType::SampledTexture, wgpu::BindingType::ReadonlyStorageTexture,
|
||||
wgpu::BindingType::WriteonlyStorageTexture};
|
||||
constexpr wgpu::TextureFormat kStorageTextureFormat = wgpu::TextureFormat::R32Float;
|
||||
|
||||
std::initializer_list<utils::BindingLayoutEntryInitializationHelper> kSupportedBindingTypes = {
|
||||
{0, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::Uniform},
|
||||
{0, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::Storage},
|
||||
{0, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::ReadOnlyStorage},
|
||||
{0, wgpu::ShaderStage::Compute, wgpu::SamplerBindingType::Filtering},
|
||||
{0, wgpu::ShaderStage::Compute, wgpu::TextureSampleType::Float},
|
||||
{0, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::ReadOnly,
|
||||
kStorageTextureFormat},
|
||||
{0, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::WriteOnly,
|
||||
kStorageTextureFormat}};
|
||||
|
||||
for (wgpu::StorageTextureAccess bindingTypeInShader : kSupportedStorageTextureAccess) {
|
||||
// Create the compute shader with the given binding type.
|
||||
std::string computeShader =
|
||||
@@ -433,30 +439,20 @@ TEST_F(StorageTextureValidationTests, BindGroupLayoutEntryTypeMatchesShaderDecla
|
||||
defaultComputePipelineDescriptor.computeStage.module = csModule;
|
||||
defaultComputePipelineDescriptor.computeStage.entryPoint = "main";
|
||||
|
||||
// Set common fileds of bind group layout binding.
|
||||
wgpu::BindGroupLayoutEntry defaultBindGroupLayoutEntry;
|
||||
defaultBindGroupLayoutEntry.binding = 0;
|
||||
defaultBindGroupLayoutEntry.visibility = wgpu::ShaderStage::Compute;
|
||||
defaultBindGroupLayoutEntry.storageTextureFormat = kStorageTextureFormat;
|
||||
|
||||
for (wgpu::BindingType bindingTypeInBindgroupLayout : kSupportedBindingTypes) {
|
||||
for (utils::BindingLayoutEntryInitializationHelper bindingLayoutEntry :
|
||||
kSupportedBindingTypes) {
|
||||
wgpu::ComputePipelineDescriptor computePipelineDescriptor =
|
||||
defaultComputePipelineDescriptor;
|
||||
|
||||
// Create bind group layout with different binding types.
|
||||
wgpu::BindGroupLayoutEntry bindGroupLayoutBinding = defaultBindGroupLayoutEntry;
|
||||
bindGroupLayoutBinding.type = bindingTypeInBindgroupLayout;
|
||||
wgpu::BindGroupLayout bindGroupLayout =
|
||||
utils::MakeBindGroupLayout(device, {bindGroupLayoutBinding});
|
||||
utils::MakeBindGroupLayout(device, {bindingLayoutEntry});
|
||||
computePipelineDescriptor.layout =
|
||||
utils::MakeBasicPipelineLayout(device, &bindGroupLayout);
|
||||
|
||||
// The binding type in the bind group layout must the same as the related image object
|
||||
// declared in shader.
|
||||
if ((bindingTypeInBindgroupLayout == wgpu::BindingType::ReadonlyStorageTexture &&
|
||||
bindingTypeInShader == wgpu::StorageTextureAccess::ReadOnly) ||
|
||||
(bindingTypeInBindgroupLayout == wgpu::BindingType::WriteonlyStorageTexture &&
|
||||
bindingTypeInShader == wgpu::StorageTextureAccess::WriteOnly)) {
|
||||
if (bindingLayoutEntry.storageTexture.access == bindingTypeInShader) {
|
||||
device.CreateComputePipeline(&computePipelineDescriptor);
|
||||
} else {
|
||||
ASSERT_DEVICE_ERROR(device.CreateComputePipeline(&computePipelineDescriptor));
|
||||
|
||||
Reference in New Issue
Block a user