From c3c6694d8f0f57f1df49ffd4a63d7083b1d81c85 Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Tue, 7 Apr 2020 07:11:12 +0000 Subject: [PATCH] Rename BG[L]Binding to BG[L]Entry This is to match the WebGPU API change. The only manual changes are in dawn.json and templates. The rest was created with the following commands: git grep -l BindGroupLayoutBinding | xargs sed -i "" -e "s/BindGroupLayoutBinding/BindGroupLayoutEntry/g" git grep -l BindGroupBinding | xargs sed -i "" -e "s/BindGroupBinding/BindGroupEntry/g" git cl format Bug: dawn:22 Change-Id: I1377eef9ea9816578441c91d167909dedc7f8e96 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/18863 Reviewed-by: Austin Eng Reviewed-by: Kai Ninomiya Commit-Queue: Corentin Wallez --- dawn.json | 8 +- generator/templates/webgpu.h | 4 + generator/templates/webgpu_cpp.h | 4 + src/dawn_native/BindGroup.cpp | 11 ++- src/dawn_native/BindGroupLayout.cpp | 10 +-- src/dawn_native/PipelineLayout.cpp | 6 +- src/tests/end2end/BindGroupTests.cpp | 4 +- src/tests/end2end/DeviceLostTests.cpp | 6 +- src/tests/end2end/StorageTextureTests.cpp | 8 +- .../validation/BindGroupValidationTests.cpp | 32 ++++---- .../GetBindGroupLayoutValidationTests.cpp | 16 ++-- .../StorageTextureValidationTests.cpp | 76 +++++++++---------- .../unittests/wire/WireArgumentTests.cpp | 2 +- .../unittests/wire/WireOptionalTests.cpp | 2 +- src/utils/WGPUHelpers.cpp | 12 +-- src/utils/WGPUHelpers.h | 4 +- 16 files changed, 106 insertions(+), 99 deletions(-) diff --git a/dawn.json b/dawn.json index 7aff7b1db2..f3dd908fcf 100644 --- a/dawn.json +++ b/dawn.json @@ -59,7 +59,7 @@ "bind group": { "category": "object" }, - "bind group binding": { + "bind group entry": { "category": "structure", "extensible": false, "members": [ @@ -78,13 +78,13 @@ {"name": "label", "type": "char", "annotation": "const*", "length": "strlen", "optional": true}, {"name": "layout", "type": "bind group layout"}, {"name": "binding count", "type": "uint32_t"}, - {"name": "bindings", "type": "bind group binding", "annotation": "const*", "length": "binding count"} + {"name": "bindings", "type": "bind group entry", "annotation": "const*", "length": "binding count"} ] }, "bind group layout": { "category": "object" }, - "bind group layout binding": { + "bind group layout entry": { "category": "structure", "extensible": false, "members": [ @@ -104,7 +104,7 @@ "members": [ {"name": "label", "type": "char", "annotation": "const*", "length": "strlen", "optional": true}, {"name": "binding count", "type": "uint32_t"}, - {"name": "bindings", "type": "bind group layout binding", "annotation": "const*", "length": "binding count"} + {"name": "bindings", "type": "bind group layout entry", "annotation": "const*", "length": "binding count"} ] }, "binding type": { diff --git a/generator/templates/webgpu.h b/generator/templates/webgpu.h index bae0a53e60..892830e5a9 100644 --- a/generator/templates/webgpu.h +++ b/generator/templates/webgpu.h @@ -114,6 +114,10 @@ typedef struct WGPUChainedStruct { {% endfor %} +// TODO(dawn:22): Remove this once users use the "Entry" version. +typedef WGPUBindGroupEntry WGPUBindGroupBinding; +typedef WGPUBindGroupLayoutEntry WGPUBindGroupLayoutBinding; + #ifdef __cplusplus extern "C" { #endif diff --git a/generator/templates/webgpu_cpp.h b/generator/templates/webgpu_cpp.h index 3dde1e803e..b53f83e295 100644 --- a/generator/templates/webgpu_cpp.h +++ b/generator/templates/webgpu_cpp.h @@ -216,6 +216,10 @@ namespace wgpu { {% endfor %} + // TODO(dawn:22): Remove this once users use the "Entry" version. + using BindGroupBinding = BindGroupEntry; + using BindGroupLayoutBinding = BindGroupLayoutEntry; + } // namespace wgpu #endif // WEBGPU_CPP_H_ diff --git a/src/dawn_native/BindGroup.cpp b/src/dawn_native/BindGroup.cpp index 8949aa2470..46336981cb 100644 --- a/src/dawn_native/BindGroup.cpp +++ b/src/dawn_native/BindGroup.cpp @@ -29,7 +29,7 @@ namespace dawn_native { // Helper functions to perform binding-type specific validation MaybeError ValidateBufferBinding(const DeviceBase* device, - const BindGroupBinding& binding, + const BindGroupEntry& binding, wgpu::BufferUsage requiredUsage) { if (binding.buffer == nullptr || binding.sampler != nullptr || binding.textureView != nullptr) { @@ -66,7 +66,7 @@ namespace dawn_native { } MaybeError ValidateTextureBinding(const DeviceBase* device, - const BindGroupBinding& binding, + const BindGroupEntry& binding, wgpu::TextureUsage requiredUsage, const BindingInfo& bindingInfo) { if (binding.textureView == nullptr || binding.sampler != nullptr || @@ -110,8 +110,7 @@ namespace dawn_native { return {}; } - MaybeError ValidateSamplerBinding(const DeviceBase* device, - const BindGroupBinding& binding) { + MaybeError ValidateSamplerBinding(const DeviceBase* device, const BindGroupEntry& binding) { if (binding.sampler == nullptr || binding.textureView != nullptr || binding.buffer != nullptr) { return DAWN_VALIDATION_ERROR("expected sampler binding"); @@ -138,7 +137,7 @@ namespace dawn_native { std::bitset bindingsSet; for (uint32_t i = 0; i < descriptor->bindingCount; ++i) { - const BindGroupBinding& binding = descriptor->bindings[i]; + const BindGroupEntry& binding = descriptor->bindings[i]; const auto& it = bindingMap.find(BindingNumber(binding.binding)); if (it == bindingMap.end()) { @@ -208,7 +207,7 @@ namespace dawn_native { } for (uint32_t i = 0; i < descriptor->bindingCount; ++i) { - const BindGroupBinding& binding = descriptor->bindings[i]; + const BindGroupEntry& binding = descriptor->bindings[i]; BindingIndex bindingIndex = descriptor->layout->GetBindingIndex(BindingNumber(binding.binding)); diff --git a/src/dawn_native/BindGroupLayout.cpp b/src/dawn_native/BindGroupLayout.cpp index b65f469204..6b481e8b51 100644 --- a/src/dawn_native/BindGroupLayout.cpp +++ b/src/dawn_native/BindGroupLayout.cpp @@ -102,7 +102,7 @@ namespace dawn_native { uint32_t dynamicUniformBufferCount = 0; uint32_t dynamicStorageBufferCount = 0; for (BindingIndex i = 0; i < descriptor->bindingCount; ++i) { - const BindGroupLayoutBinding& binding = descriptor->bindings[i]; + const BindGroupLayoutEntry& binding = descriptor->bindings[i]; BindingNumber bindingNumber = BindingNumber(binding.binding); DAWN_TRY(ValidateShaderStage(binding.visibility)); @@ -149,7 +149,7 @@ namespace dawn_native { if (binding.multisampled) { return DAWN_VALIDATION_ERROR( - "BindGroupLayoutBinding::multisampled must be false (for now)"); + "BindGroupLayoutEntry::multisampled must be false (for now)"); } bindingsSet.insert(bindingNumber); @@ -190,7 +190,7 @@ namespace dawn_native { a.storageTextureFormat != b.storageTextureFormat; } - bool SortBindingsCompare(const BindGroupLayoutBinding& a, const BindGroupLayoutBinding& b) { + bool SortBindingsCompare(const BindGroupLayoutEntry& a, const BindGroupLayoutEntry& b) { if (a.hasDynamicOffset != b.hasDynamicOffset) { // Buffers with dynamic offsets should come before those without. // This makes it easy to iterate over the dynamic buffer bindings @@ -258,13 +258,13 @@ namespace dawn_native { BindGroupLayoutBase::BindGroupLayoutBase(DeviceBase* device, const BindGroupLayoutDescriptor* descriptor) : CachedObject(device), mBindingCount(descriptor->bindingCount) { - std::vector sortedBindings( + std::vector sortedBindings( descriptor->bindings, descriptor->bindings + descriptor->bindingCount); std::sort(sortedBindings.begin(), sortedBindings.end(), SortBindingsCompare); for (BindingIndex i = 0; i < mBindingCount; ++i) { - const BindGroupLayoutBinding& binding = sortedBindings[i]; + const BindGroupLayoutEntry& binding = sortedBindings[i]; mBindingInfo[i].type = binding.type; mBindingInfo[i].visibility = binding.visibility; mBindingInfo[i].textureComponentType = diff --git a/src/dawn_native/PipelineLayout.cpp b/src/dawn_native/PipelineLayout.cpp index 46a132b365..eda841625e 100644 --- a/src/dawn_native/PipelineLayout.cpp +++ b/src/dawn_native/PipelineLayout.cpp @@ -25,7 +25,7 @@ namespace dawn_native { namespace { - bool operator==(const BindGroupLayoutBinding& lhs, const BindGroupLayoutBinding& rhs) { + bool operator==(const BindGroupLayoutEntry& lhs, const BindGroupLayoutEntry& rhs) { return lhs.binding == rhs.binding && lhs.visibility == rhs.visibility && lhs.type == rhs.type && lhs.hasDynamicOffset == rhs.hasDynamicOffset && lhs.multisampled == rhs.multisampled && @@ -127,7 +127,7 @@ namespace dawn_native { ASSERT(count > 0); // Data which BindGroupLayoutDescriptor will point to for creation - std::array, kMaxBindGroups> + std::array, kMaxBindGroups> bindingData = {}; // A map of bindings to the index in |bindingData| @@ -150,7 +150,7 @@ namespace dawn_native { return DAWN_VALIDATION_ERROR("Multisampled textures not supported (yet)"); } - BindGroupLayoutBinding bindingSlot; + BindGroupLayoutEntry bindingSlot; bindingSlot.binding = bindingNumber; DAWN_TRY(ValidateBindingTypeWithShaderStageVisibility( diff --git a/src/tests/end2end/BindGroupTests.cpp b/src/tests/end2end/BindGroupTests.cpp index 9d89cee04a..ee8eb052f7 100644 --- a/src/tests/end2end/BindGroupTests.cpp +++ b/src/tests/end2end/BindGroupTests.cpp @@ -754,8 +754,8 @@ TEST_P(BindGroupTests, DrawThenChangePipelineAndBindGroup) { TEST_P(BindGroupTests, BindGroupLayoutVisibilityCanBeNone) { utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); - wgpu::BindGroupLayoutBinding binding = {0, wgpu::ShaderStage::None, - wgpu::BindingType::UniformBuffer}; + wgpu::BindGroupLayoutEntry binding = {0, wgpu::ShaderStage::None, + wgpu::BindingType::UniformBuffer}; wgpu::BindGroupLayoutDescriptor descriptor; descriptor.bindingCount = 1; descriptor.bindings = &binding; diff --git a/src/tests/end2end/DeviceLostTests.cpp b/src/tests/end2end/DeviceLostTests.cpp index 410a5c6990..7934de41fa 100644 --- a/src/tests/end2end/DeviceLostTests.cpp +++ b/src/tests/end2end/DeviceLostTests.cpp @@ -105,8 +105,8 @@ TEST_P(DeviceLostTest, SubmitFails) { TEST_P(DeviceLostTest, CreateBindGroupLayoutFails) { SetCallbackAndLoseForTesting(); - wgpu::BindGroupLayoutBinding binding = {0, wgpu::ShaderStage::None, - wgpu::BindingType::UniformBuffer}; + wgpu::BindGroupLayoutEntry binding = {0, wgpu::ShaderStage::None, + wgpu::BindingType::UniformBuffer}; wgpu::BindGroupLayoutDescriptor descriptor; descriptor.bindingCount = 1; descriptor.bindings = &binding; @@ -139,7 +139,7 @@ TEST_P(DeviceLostTest, GetBindGroupLayoutFails) { TEST_P(DeviceLostTest, CreateBindGroupFails) { SetCallbackAndLoseForTesting(); - wgpu::BindGroupBinding binding; + wgpu::BindGroupEntry binding; binding.binding = 0; binding.sampler = nullptr; binding.textureView = nullptr; diff --git a/src/tests/end2end/StorageTextureTests.cpp b/src/tests/end2end/StorageTextureTests.cpp index b351db7d54..e09e79aba8 100644 --- a/src/tests/end2end/StorageTextureTests.cpp +++ b/src/tests/end2end/StorageTextureTests.cpp @@ -23,8 +23,8 @@ TEST_P(StorageTextureTests, BindGroupLayoutWithStorageTextureBindingType) { // wgpu::BindingType::ReadonlyStorageTexture is a valid binding type to create a bind group // layout. { - wgpu::BindGroupLayoutBinding binding = {0, wgpu::ShaderStage::Compute, - wgpu::BindingType::ReadonlyStorageTexture}; + wgpu::BindGroupLayoutEntry binding = {0, wgpu::ShaderStage::Compute, + wgpu::BindingType::ReadonlyStorageTexture}; binding.storageTextureFormat = wgpu::TextureFormat::R32Float; wgpu::BindGroupLayoutDescriptor descriptor; descriptor.bindingCount = 1; @@ -35,8 +35,8 @@ TEST_P(StorageTextureTests, BindGroupLayoutWithStorageTextureBindingType) { // wgpu::BindingType::WriteonlyStorageTexture is a valid binding type to create a bind group // layout. { - wgpu::BindGroupLayoutBinding binding = {0, wgpu::ShaderStage::Compute, - wgpu::BindingType::WriteonlyStorageTexture}; + wgpu::BindGroupLayoutEntry binding = {0, wgpu::ShaderStage::Compute, + wgpu::BindingType::WriteonlyStorageTexture}; binding.storageTextureFormat = wgpu::TextureFormat::R32Float; wgpu::BindGroupLayoutDescriptor descriptor; descriptor.bindingCount = 1; diff --git a/src/tests/unittests/validation/BindGroupValidationTests.cpp b/src/tests/unittests/validation/BindGroupValidationTests.cpp index 9e7ad9ee46..226e121441 100644 --- a/src/tests/unittests/validation/BindGroupValidationTests.cpp +++ b/src/tests/unittests/validation/BindGroupValidationTests.cpp @@ -92,7 +92,7 @@ TEST_F(BindGroupValidationTest, bindingCountMismatch) { ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {})); } -// Check constraints on BindGroupBinding::binding +// Check constraints on BindGroupEntry::binding TEST_F(BindGroupValidationTest, WrongBindings) { wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout( device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::Sampler}}); @@ -131,7 +131,7 @@ TEST_F(BindGroupValidationTest, SamplerBindingType) { wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout( device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::Sampler}}); - wgpu::BindGroupBinding binding; + wgpu::BindGroupEntry binding; binding.binding = 0; binding.sampler = nullptr; binding.textureView = nullptr; @@ -180,7 +180,7 @@ TEST_F(BindGroupValidationTest, TextureBindingType) { wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout( device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture}}); - wgpu::BindGroupBinding binding; + wgpu::BindGroupEntry binding; binding.binding = 0; binding.sampler = nullptr; binding.textureView = nullptr; @@ -234,7 +234,7 @@ TEST_F(BindGroupValidationTest, BufferBindingType) { wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout( device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::UniformBuffer}}); - wgpu::BindGroupBinding binding; + wgpu::BindGroupEntry binding; binding.binding = 0; binding.sampler = nullptr; binding.textureView = nullptr; @@ -467,7 +467,7 @@ TEST_F(BindGroupValidationTest, ErrorLayout) { class BindGroupLayoutValidationTest : public ValidationTest { public: - void TestCreateBindGroupLayout(wgpu::BindGroupLayoutBinding* binding, + void TestCreateBindGroupLayout(wgpu::BindGroupLayoutEntry* binding, uint32_t count, bool expected) { wgpu::BindGroupLayoutDescriptor descriptor; @@ -513,7 +513,7 @@ TEST_F(BindGroupLayoutValidationTest, BindGroupLayoutStorageBindingsInVertexShad } // Tests setting that bind group layout bindings numbers may be >= kMaxBindingsPerGroup. -TEST_F(BindGroupLayoutValidationTest, BindGroupLayoutBindingUnbounded) { +TEST_F(BindGroupLayoutValidationTest, BindGroupLayoutEntryUnbounded) { // Checks that kMaxBindingsPerGroup is valid. utils::MakeBindGroupLayout(device, {{kMaxBindingsPerGroup, wgpu::ShaderStage::Vertex, wgpu::BindingType::UniformBuffer}}); @@ -525,7 +525,7 @@ TEST_F(BindGroupLayoutValidationTest, BindGroupLayoutBindingUnbounded) { // Test that there can't be more than kMaxBindingPerGroup bindings per group TEST_F(BindGroupLayoutValidationTest, BindGroupLayoutMaxBindings) { - wgpu::BindGroupLayoutBinding bindings[kMaxBindingsPerGroup + 1]; + wgpu::BindGroupLayoutEntry bindings[kMaxBindingsPerGroup + 1]; for (uint32_t i = 0; i < kMaxBindingsPerGroup + 1; i++) { bindings[i].type = wgpu::BindingType::UniformBuffer; @@ -547,7 +547,7 @@ TEST_F(BindGroupLayoutValidationTest, BindGroupLayoutMaxBindings) { // This test verifies that the BindGroupLayout bindings are correctly validated, even if the // binding ids are out-of-order. -TEST_F(BindGroupLayoutValidationTest, BindGroupBinding) { +TEST_F(BindGroupLayoutValidationTest, BindGroupEntry) { utils::MakeBindGroupLayout(device, { {1, wgpu::ShaderStage::Vertex, wgpu::BindingType::UniformBuffer}, @@ -590,8 +590,8 @@ TEST_F(BindGroupLayoutValidationTest, BindGroupLayoutVisibilityNone) { {0, wgpu::ShaderStage::Vertex, wgpu::BindingType::UniformBuffer}, }); - wgpu::BindGroupLayoutBinding binding = {0, wgpu::ShaderStage::None, - wgpu::BindingType::UniformBuffer}; + wgpu::BindGroupLayoutEntry binding = {0, wgpu::ShaderStage::None, + wgpu::BindingType::UniformBuffer}; wgpu::BindGroupLayoutDescriptor descriptor; descriptor.bindingCount = 1; descriptor.bindings = &binding; @@ -601,9 +601,9 @@ TEST_F(BindGroupLayoutValidationTest, BindGroupLayoutVisibilityNone) { // Check that dynamic buffer numbers exceed maximum value in one bind group layout. TEST_F(BindGroupLayoutValidationTest, DynamicBufferNumberLimit) { wgpu::BindGroupLayout bgl[2]; - std::vector maxUniformDB; - std::vector maxStorageDB; - std::vector maxReadonlyStorageDB; + std::vector maxUniformDB; + std::vector maxStorageDB; + std::vector maxReadonlyStorageDB; for (uint32_t i = 0; i < kMaxDynamicUniformBufferCount; ++i) { maxUniformDB.push_back( @@ -620,7 +620,7 @@ TEST_F(BindGroupLayoutValidationTest, DynamicBufferNumberLimit) { {i, wgpu::ShaderStage::Compute, wgpu::BindingType::ReadonlyStorageBuffer, true}); } - auto MakeBindGroupLayout = [&](wgpu::BindGroupLayoutBinding* binding, + auto MakeBindGroupLayout = [&](wgpu::BindGroupLayoutEntry* binding, uint32_t count) -> wgpu::BindGroupLayout { wgpu::BindGroupLayoutDescriptor descriptor; descriptor.bindingCount = count; @@ -1027,9 +1027,9 @@ class SetBindGroupPersistenceValidationTest : public ValidationTest { // Iterate through the desired bind group layouts. for (uint32_t l = 0; l < layouts.size(); ++l) { const auto& layout = layouts[l]; - std::vector bindings(layout.size()); + std::vector bindings(layout.size()); - // Iterate through binding types and populate a list of BindGroupLayoutBindings. + // Iterate through binding types and populate a list of BindGroupLayoutEntrys. for (uint32_t b = 0; b < layout.size(); ++b) { bindings[b] = {b, wgpu::ShaderStage::Fragment, layout[b], false}; } diff --git a/src/tests/unittests/validation/GetBindGroupLayoutValidationTests.cpp b/src/tests/unittests/validation/GetBindGroupLayoutValidationTests.cpp index 6b2f0daacc..efcbfac34a 100644 --- a/src/tests/unittests/validation/GetBindGroupLayoutValidationTests.cpp +++ b/src/tests/unittests/validation/GetBindGroupLayoutValidationTests.cpp @@ -102,7 +102,7 @@ TEST_F(GetBindGroupLayoutTests, DefaultShaderStageAndDynamicOffsets) { void main() { })"); - wgpu::BindGroupLayoutBinding binding = {}; + wgpu::BindGroupLayoutEntry binding = {}; binding.binding = 0; binding.type = wgpu::BindingType::UniformBuffer; binding.multisampled = false; @@ -150,7 +150,7 @@ TEST_F(GetBindGroupLayoutTests, ComputePipeline) { wgpu::ComputePipeline pipeline = device.CreateComputePipeline(&descriptor); - wgpu::BindGroupLayoutBinding binding = {}; + wgpu::BindGroupLayoutEntry binding = {}; binding.binding = 0; binding.type = wgpu::BindingType::UniformBuffer; binding.visibility = kVisibilityAll; @@ -165,7 +165,7 @@ TEST_F(GetBindGroupLayoutTests, ComputePipeline) { // Test that the binding type matches the shader. TEST_F(GetBindGroupLayoutTests, BindingType) { - wgpu::BindGroupLayoutBinding binding = {}; + wgpu::BindGroupLayoutEntry binding = {}; binding.binding = 0; binding.hasDynamicOffset = false; binding.multisampled = false; @@ -236,7 +236,7 @@ TEST_F(GetBindGroupLayoutTests, BindingType) { // Test that multisampling matches the shader. TEST_F(GetBindGroupLayoutTests, Multisampled) { - wgpu::BindGroupLayoutBinding binding = {}; + wgpu::BindGroupLayoutEntry binding = {}; binding.binding = 0; binding.type = wgpu::BindingType::SampledTexture; binding.visibility = kVisibilityAll; @@ -273,7 +273,7 @@ TEST_F(GetBindGroupLayoutTests, Multisampled) { // Test that texture view dimension matches the shader. TEST_F(GetBindGroupLayoutTests, TextureDimension) { - wgpu::BindGroupLayoutBinding binding = {}; + wgpu::BindGroupLayoutEntry binding = {}; binding.binding = 0; binding.type = wgpu::BindingType::SampledTexture; binding.visibility = kVisibilityAll; @@ -347,7 +347,7 @@ TEST_F(GetBindGroupLayoutTests, TextureDimension) { // Test that texture component type matches the shader. TEST_F(GetBindGroupLayoutTests, TextureComponentType) { - wgpu::BindGroupLayoutBinding binding = {}; + wgpu::BindGroupLayoutEntry binding = {}; binding.binding = 0; binding.type = wgpu::BindingType::SampledTexture; binding.visibility = kVisibilityAll; @@ -391,7 +391,7 @@ TEST_F(GetBindGroupLayoutTests, TextureComponentType) { // Test that binding= indices match. TEST_F(GetBindGroupLayoutTests, BindingIndices) { - wgpu::BindGroupLayoutBinding binding = {}; + wgpu::BindGroupLayoutEntry binding = {}; binding.type = wgpu::BindingType::UniformBuffer; binding.visibility = kVisibilityAll; binding.hasDynamicOffset = false; @@ -619,7 +619,7 @@ TEST_F(GetBindGroupLayoutTests, UnusedIndex) { // Test that after explicitly creating a pipeline with a pipeline layout, calling // GetBindGroupLayout reflects the same bind group layouts. TEST_F(GetBindGroupLayoutTests, Reflection) { - wgpu::BindGroupLayoutBinding binding = {}; + wgpu::BindGroupLayoutEntry binding = {}; binding.binding = 0; binding.type = wgpu::BindingType::UniformBuffer; binding.visibility = wgpu::ShaderStage::Vertex; diff --git a/src/tests/unittests/validation/StorageTextureValidationTests.cpp b/src/tests/unittests/validation/StorageTextureValidationTests.cpp index 46cc28015b..776466b643 100644 --- a/src/tests/unittests/validation/StorageTextureValidationTests.cpp +++ b/src/tests/unittests/validation/StorageTextureValidationTests.cpp @@ -381,7 +381,7 @@ TEST_F(StorageTextureValidationTests, BindGroupLayoutWithStorageTextureBindingTy {wgpu::ShaderStage::Compute, wgpu::BindingType::StorageTexture, false}}}; for (const auto& testSpec : kTestSpecs) { - wgpu::BindGroupLayoutBinding binding = {0, testSpec.stage, testSpec.type}; + wgpu::BindGroupLayoutEntry binding = {0, testSpec.stage, testSpec.type}; binding.storageTextureFormat = wgpu::TextureFormat::R32Uint; wgpu::BindGroupLayoutDescriptor descriptor; descriptor.bindingCount = 1; @@ -462,7 +462,7 @@ TEST_F(StorageTextureValidationTests, UnsupportedSPIRVStorageTextureFormat) { // Verify when we create and use a bind group layout with storage textures in the creation of // render and compute pipeline, the binding type in the bind group layout must match the // declaration in the shader. -TEST_F(StorageTextureValidationTests, BindGroupLayoutBindingTypeMatchesShaderDeclaration) { +TEST_F(StorageTextureValidationTests, BindGroupLayoutEntryTypeMatchesShaderDeclaration) { constexpr std::array kSupportedBindingTypes = { wgpu::BindingType::UniformBuffer, wgpu::BindingType::StorageBuffer, wgpu::BindingType::ReadonlyStorageBuffer, wgpu::BindingType::Sampler, @@ -483,17 +483,17 @@ TEST_F(StorageTextureValidationTests, BindGroupLayoutBindingTypeMatchesShaderDec defaultComputePipelineDescriptor.computeStage.entryPoint = "main"; // Set common fileds of bind group layout binding. - wgpu::BindGroupLayoutBinding defaultBindGroupLayoutBinding; - defaultBindGroupLayoutBinding.binding = 0; - defaultBindGroupLayoutBinding.visibility = wgpu::ShaderStage::Compute; - defaultBindGroupLayoutBinding.storageTextureFormat = kStorageTextureFormat; + wgpu::BindGroupLayoutEntry defaultBindGroupLayoutEntry; + defaultBindGroupLayoutEntry.binding = 0; + defaultBindGroupLayoutEntry.visibility = wgpu::ShaderStage::Compute; + defaultBindGroupLayoutEntry.storageTextureFormat = kStorageTextureFormat; for (wgpu::BindingType bindingTypeInBindgroupLayout : kSupportedBindingTypes) { wgpu::ComputePipelineDescriptor computePipelineDescriptor = defaultComputePipelineDescriptor; // Create bind group layout with different binding types. - wgpu::BindGroupLayoutBinding bindGroupLayoutBinding = defaultBindGroupLayoutBinding; + wgpu::BindGroupLayoutEntry bindGroupLayoutBinding = defaultBindGroupLayoutEntry; bindGroupLayoutBinding.type = bindingTypeInBindgroupLayout; wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout(device, {bindGroupLayoutBinding}); @@ -514,27 +514,27 @@ TEST_F(StorageTextureValidationTests, BindGroupLayoutBindingTypeMatchesShaderDec // Verify it is invalid not to set a valid texture format in a bind group layout when the binding // type is read-only or write-only storage texture. TEST_F(StorageTextureValidationTests, UndefinedStorageTextureFormatInBindGroupLayout) { - wgpu::BindGroupLayoutBinding errorBindGroupLayoutBinding; - errorBindGroupLayoutBinding.binding = 0; - errorBindGroupLayoutBinding.visibility = wgpu::ShaderStage::Compute; - errorBindGroupLayoutBinding.storageTextureFormat = wgpu::TextureFormat::Undefined; + wgpu::BindGroupLayoutEntry errorBindGroupLayoutEntry; + errorBindGroupLayoutEntry.binding = 0; + errorBindGroupLayoutEntry.visibility = wgpu::ShaderStage::Compute; + errorBindGroupLayoutEntry.storageTextureFormat = wgpu::TextureFormat::Undefined; for (wgpu::BindingType bindingType : kSupportedStorageTextureBindingTypes) { - errorBindGroupLayoutBinding.type = bindingType; - ASSERT_DEVICE_ERROR(utils::MakeBindGroupLayout(device, {errorBindGroupLayoutBinding})); + errorBindGroupLayoutEntry.type = bindingType; + ASSERT_DEVICE_ERROR(utils::MakeBindGroupLayout(device, {errorBindGroupLayoutEntry})); } } // Verify it is invalid to create a bind group layout with storage textures and an unsupported // storage texture format. TEST_F(StorageTextureValidationTests, StorageTextureFormatInBindGroupLayout) { - wgpu::BindGroupLayoutBinding defaultBindGroupLayoutBinding; - defaultBindGroupLayoutBinding.binding = 0; - defaultBindGroupLayoutBinding.visibility = wgpu::ShaderStage::Compute; + wgpu::BindGroupLayoutEntry defaultBindGroupLayoutEntry; + defaultBindGroupLayoutEntry.binding = 0; + defaultBindGroupLayoutEntry.visibility = wgpu::ShaderStage::Compute; for (wgpu::BindingType bindingType : kSupportedStorageTextureBindingTypes) { for (wgpu::TextureFormat textureFormat : utils::kAllTextureFormats) { - wgpu::BindGroupLayoutBinding bindGroupLayoutBinding = defaultBindGroupLayoutBinding; + wgpu::BindGroupLayoutEntry bindGroupLayoutBinding = defaultBindGroupLayoutEntry; bindGroupLayoutBinding.type = bindingType; bindGroupLayoutBinding.storageTextureFormat = textureFormat; if (utils::TextureFormatSupportsStorageTexture(textureFormat)) { @@ -567,8 +567,8 @@ TEST_F(StorageTextureValidationTests, BindGroupLayoutStorageTextureFormatMatches defaultComputePipelineDescriptor.computeStage.entryPoint = "main"; // Set common fileds of bind group layout binding. - wgpu::BindGroupLayoutBinding defaultBindGroupLayoutBinding = { - 0, wgpu::ShaderStage::Compute, bindingType}; + wgpu::BindGroupLayoutEntry defaultBindGroupLayoutEntry = {0, wgpu::ShaderStage::Compute, + bindingType}; for (wgpu::TextureFormat storageTextureFormatInBindGroupLayout : utils::kAllTextureFormats) { @@ -578,7 +578,7 @@ TEST_F(StorageTextureValidationTests, BindGroupLayoutStorageTextureFormatMatches } // Create the bind group layout with the given storage texture format. - wgpu::BindGroupLayoutBinding bindGroupLayoutBinding = defaultBindGroupLayoutBinding; + wgpu::BindGroupLayoutEntry bindGroupLayoutBinding = defaultBindGroupLayoutEntry; bindGroupLayoutBinding.storageTextureFormat = storageTextureFormatInBindGroupLayout; wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout(device, {bindGroupLayoutBinding}); @@ -624,13 +624,13 @@ TEST_F(StorageTextureValidationTests, BindGroupLayoutTextureDimensionMatchesShad defaultComputePipelineDescriptor.computeStage.entryPoint = "main"; // Set common fileds of bind group layout binding. - wgpu::BindGroupLayoutBinding defaultBindGroupLayoutBinding = { - 0, wgpu::ShaderStage::Compute, bindingType}; - defaultBindGroupLayoutBinding.storageTextureFormat = kStorageTextureFormat; + wgpu::BindGroupLayoutEntry defaultBindGroupLayoutEntry = {0, wgpu::ShaderStage::Compute, + bindingType}; + defaultBindGroupLayoutEntry.storageTextureFormat = kStorageTextureFormat; for (wgpu::TextureViewDimension dimensionInBindGroupLayout : kAllDimensions) { // Create the bind group layout with the given texture view dimension. - wgpu::BindGroupLayoutBinding bindGroupLayoutBinding = defaultBindGroupLayoutBinding; + wgpu::BindGroupLayoutEntry bindGroupLayoutBinding = defaultBindGroupLayoutEntry; bindGroupLayoutBinding.textureDimension = dimensionInBindGroupLayout; wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout(device, {bindGroupLayoutBinding}); @@ -657,7 +657,7 @@ TEST_F(StorageTextureValidationTests, BindGroupLayoutTextureDimensionMatchesShad // are allowed to have dynamic offsets. TEST_F(StorageTextureValidationTests, StorageTextureCannotHaveDynamicOffsets) { for (wgpu::BindingType storageBindingType : kSupportedStorageTextureBindingTypes) { - wgpu::BindGroupLayoutBinding bindGroupLayoutBinding; + wgpu::BindGroupLayoutEntry bindGroupLayoutBinding; bindGroupLayoutBinding.binding = 0; bindGroupLayoutBinding.visibility = wgpu::ShaderStage::Compute; bindGroupLayoutBinding.type = storageBindingType; @@ -674,7 +674,7 @@ TEST_F(StorageTextureValidationTests, StorageTextureBindingTypeInBindGroup) { constexpr wgpu::TextureFormat kStorageTextureFormat = wgpu::TextureFormat::R32Float; for (wgpu::BindingType storageBindingType : kSupportedStorageTextureBindingTypes) { // Create a bind group layout. - wgpu::BindGroupLayoutBinding bindGroupLayoutBinding; + wgpu::BindGroupLayoutEntry bindGroupLayoutBinding; bindGroupLayoutBinding.binding = 0; bindGroupLayoutBinding.visibility = wgpu::ShaderStage::Compute; bindGroupLayoutBinding.type = storageBindingType; @@ -718,7 +718,7 @@ TEST_F(StorageTextureValidationTests, StorageTextureUsageInBindGroup) { for (wgpu::BindingType storageBindingType : kSupportedStorageTextureBindingTypes) { // Create a bind group layout. - wgpu::BindGroupLayoutBinding bindGroupLayoutBinding; + wgpu::BindGroupLayoutEntry bindGroupLayoutBinding; bindGroupLayoutBinding.binding = 0; bindGroupLayoutBinding.visibility = wgpu::ShaderStage::Compute; bindGroupLayoutBinding.type = storageBindingType; @@ -747,10 +747,10 @@ TEST_F(StorageTextureValidationTests, StorageTextureUsageInBindGroup) { // group must match the corresponding bind group binding. TEST_F(StorageTextureValidationTests, StorageTextureFormatInBindGroup) { for (wgpu::BindingType storageBindingType : kSupportedStorageTextureBindingTypes) { - wgpu::BindGroupLayoutBinding defaultBindGroupLayoutBinding; - defaultBindGroupLayoutBinding.binding = 0; - defaultBindGroupLayoutBinding.visibility = wgpu::ShaderStage::Compute; - defaultBindGroupLayoutBinding.type = storageBindingType; + wgpu::BindGroupLayoutEntry defaultBindGroupLayoutEntry; + defaultBindGroupLayoutEntry.binding = 0; + defaultBindGroupLayoutEntry.visibility = wgpu::ShaderStage::Compute; + defaultBindGroupLayoutEntry.type = storageBindingType; for (wgpu::TextureFormat formatInBindGroupLayout : utils::kAllTextureFormats) { if (!utils::TextureFormatSupportsStorageTexture(formatInBindGroupLayout)) { @@ -758,7 +758,7 @@ TEST_F(StorageTextureValidationTests, StorageTextureFormatInBindGroup) { } // Create a bind group layout with given storage texture format. - wgpu::BindGroupLayoutBinding bindGroupLayoutBinding = defaultBindGroupLayoutBinding; + wgpu::BindGroupLayoutEntry bindGroupLayoutBinding = defaultBindGroupLayoutEntry; bindGroupLayoutBinding.storageTextureFormat = formatInBindGroupLayout; wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout(device, {bindGroupLayoutBinding}); @@ -808,15 +808,15 @@ TEST_F(StorageTextureValidationTests, StorageTextureViewDimensionInBindGroup) { kDefaultTextureViewDescriptor.baseArrayLayer = 0; for (wgpu::BindingType storageBindingType : kSupportedStorageTextureBindingTypes) { - wgpu::BindGroupLayoutBinding defaultBindGroupLayoutBinding; - defaultBindGroupLayoutBinding.binding = 0; - defaultBindGroupLayoutBinding.visibility = wgpu::ShaderStage::Compute; - defaultBindGroupLayoutBinding.type = storageBindingType; - defaultBindGroupLayoutBinding.storageTextureFormat = kStorageTextureFormat; + wgpu::BindGroupLayoutEntry defaultBindGroupLayoutEntry; + defaultBindGroupLayoutEntry.binding = 0; + defaultBindGroupLayoutEntry.visibility = wgpu::ShaderStage::Compute; + defaultBindGroupLayoutEntry.type = storageBindingType; + defaultBindGroupLayoutEntry.storageTextureFormat = kStorageTextureFormat; for (wgpu::TextureViewDimension dimensionInBindGroupLayout : kSupportedDimensions) { // Create a bind group layout with given texture view dimension. - wgpu::BindGroupLayoutBinding bindGroupLayoutBinding = defaultBindGroupLayoutBinding; + wgpu::BindGroupLayoutEntry bindGroupLayoutBinding = defaultBindGroupLayoutEntry; bindGroupLayoutBinding.textureDimension = dimensionInBindGroupLayout; wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout(device, {bindGroupLayoutBinding}); diff --git a/src/tests/unittests/wire/WireArgumentTests.cpp b/src/tests/unittests/wire/WireArgumentTests.cpp index 21d5aaf80a..1275bf4698 100644 --- a/src/tests/unittests/wire/WireArgumentTests.cpp +++ b/src/tests/unittests/wire/WireArgumentTests.cpp @@ -313,7 +313,7 @@ TEST_F(WireArgumentTests, StructureOfObjectArrayArgument) { // Test that the wire is able to send structures that contain objects TEST_F(WireArgumentTests, StructureOfStructureArrayArgument) { static constexpr int NUM_BINDINGS = 3; - WGPUBindGroupLayoutBinding bindings[NUM_BINDINGS]{ + WGPUBindGroupLayoutEntry bindings[NUM_BINDINGS]{ {0, WGPUShaderStage_Vertex, WGPUBindingType_Sampler, false, false, WGPUTextureViewDimension_2D, WGPUTextureComponentType_Float}, {1, WGPUShaderStage_Vertex, WGPUBindingType_SampledTexture, false, false, diff --git a/src/tests/unittests/wire/WireOptionalTests.cpp b/src/tests/unittests/wire/WireOptionalTests.cpp index 20d2435d7f..5695dc5547 100644 --- a/src/tests/unittests/wire/WireOptionalTests.cpp +++ b/src/tests/unittests/wire/WireOptionalTests.cpp @@ -35,7 +35,7 @@ TEST_F(WireOptionalTests, OptionalObjectValue) { .WillOnce(Return(apiBindGroupLayout)); // The `sampler`, `textureView` and `buffer` members of a binding are optional. - WGPUBindGroupBinding binding; + WGPUBindGroupEntry binding; binding.binding = 0; binding.sampler = nullptr; binding.textureView = nullptr; diff --git a/src/utils/WGPUHelpers.cpp b/src/utils/WGPUHelpers.cpp index e56ef1b80c..0aa8828d0f 100644 --- a/src/utils/WGPUHelpers.cpp +++ b/src/utils/WGPUHelpers.cpp @@ -274,11 +274,11 @@ namespace utils { wgpu::BindGroupLayout MakeBindGroupLayout( const wgpu::Device& device, - std::initializer_list bindingsInitializer) { + std::initializer_list bindingsInitializer) { constexpr wgpu::ShaderStage kNoStages{}; - std::vector bindings; - for (const wgpu::BindGroupLayoutBinding& binding : bindingsInitializer) { + std::vector bindings; + for (const wgpu::BindGroupLayoutEntry& binding : bindingsInitializer) { if (binding.visibility != kNoStages) { bindings.push_back(binding); } @@ -307,8 +307,8 @@ namespace utils { : binding(binding), buffer(buffer), offset(offset), size(size) { } - wgpu::BindGroupBinding BindingInitializationHelper::GetAsBinding() const { - wgpu::BindGroupBinding result; + wgpu::BindGroupEntry BindingInitializationHelper::GetAsBinding() const { + wgpu::BindGroupEntry result; result.binding = binding; result.sampler = sampler; @@ -324,7 +324,7 @@ namespace utils { const wgpu::Device& device, const wgpu::BindGroupLayout& layout, std::initializer_list bindingsInitializer) { - std::vector bindings; + std::vector bindings; for (const BindingInitializationHelper& helper : bindingsInitializer) { bindings.push_back(helper.GetAsBinding()); } diff --git a/src/utils/WGPUHelpers.h b/src/utils/WGPUHelpers.h index c930d6a65a..3fdeb6d25a 100644 --- a/src/utils/WGPUHelpers.h +++ b/src/utils/WGPUHelpers.h @@ -91,7 +91,7 @@ namespace utils { const wgpu::BindGroupLayout* bindGroupLayout); wgpu::BindGroupLayout MakeBindGroupLayout( const wgpu::Device& device, - std::initializer_list bindingsInitializer); + std::initializer_list bindingsInitializer); // Helpers to make creating bind groups look nicer: // @@ -111,7 +111,7 @@ namespace utils { uint64_t offset = 0, uint64_t size = wgpu::kWholeSize); - wgpu::BindGroupBinding GetAsBinding() const; + wgpu::BindGroupEntry GetAsBinding() const; uint32_t binding; wgpu::Sampler sampler;