diff --git a/dawn.json b/dawn.json index c4178d9c9c..a71e9d62ce 100644 --- a/dawn.json +++ b/dawn.json @@ -56,7 +56,7 @@ {"name": "binding", "type": "uint32_t"}, {"name": "visibility", "type": "shader stage"}, {"name": "type", "type": "binding type"}, - {"name": "dynamic", "type": "bool", "default": "false"}, + {"name": "has dynamic offset", "type": "bool", "default": "false"}, {"name": "multisampled", "type": "bool", "default": "false"}, {"name": "texture dimension", "type": "texture view dimension", "default": "undefined"}, {"name": "texture component type", "type": "texture component type", "default": "float"} diff --git a/src/dawn_native/BindGroupLayout.cpp b/src/dawn_native/BindGroupLayout.cpp index ae602095c9..29aec85cef 100644 --- a/src/dawn_native/BindGroupLayout.cpp +++ b/src/dawn_native/BindGroupLayout.cpp @@ -55,18 +55,18 @@ namespace dawn_native { switch (binding.type) { case dawn::BindingType::UniformBuffer: - if (binding.dynamic) { + if (binding.hasDynamicOffset) { ++dynamicUniformBufferCount; } break; case dawn::BindingType::StorageBuffer: - if (binding.dynamic) { + if (binding.hasDynamicOffset) { ++dynamicStorageBufferCount; } break; case dawn::BindingType::SampledTexture: case dawn::BindingType::Sampler: - if (binding.dynamic) { + if (binding.hasDynamicOffset) { return DAWN_VALIDATION_ERROR("Samplers and textures cannot be dynamic"); } break; @@ -100,7 +100,7 @@ namespace dawn_native { namespace { size_t HashBindingInfo(const BindGroupLayoutBase::LayoutBindingInfo& info) { size_t hash = Hash(info.mask); - HashCombine(&hash, info.dynamic, info.multisampled); + HashCombine(&hash, info.hasDynamicOffset, info.multisampled); for (uint32_t binding : IterateBitSet(info.mask)) { HashCombine(&hash, info.visibilities[binding], info.types[binding], @@ -112,7 +112,8 @@ namespace dawn_native { bool operator==(const BindGroupLayoutBase::LayoutBindingInfo& a, const BindGroupLayoutBase::LayoutBindingInfo& b) { - if (a.mask != b.mask || a.dynamic != b.dynamic || a.multisampled != b.multisampled) { + if (a.mask != b.mask || a.hasDynamicOffset != b.hasDynamicOffset || + a.multisampled != b.multisampled) { return false; } @@ -148,9 +149,8 @@ namespace dawn_native { } else { mBindingInfo.textureDimensions[index] = binding.textureDimension; } - - if (binding.dynamic) { - mBindingInfo.dynamic.set(index); + if (binding.hasDynamicOffset) { + mBindingInfo.hasDynamicOffset.set(index); switch (binding.type) { case dawn::BindingType::UniformBuffer: ++mDynamicUniformBufferCount; diff --git a/src/dawn_native/BindGroupLayout.h b/src/dawn_native/BindGroupLayout.h index e06459b5b9..c241cabb25 100644 --- a/src/dawn_native/BindGroupLayout.h +++ b/src/dawn_native/BindGroupLayout.h @@ -44,7 +44,7 @@ namespace dawn_native { std::array types; std::array textureComponentTypes; std::array textureDimensions; - std::bitset dynamic; + std::bitset hasDynamicOffset; std::bitset multisampled; std::bitset mask; }; diff --git a/src/dawn_native/d3d12/BindGroupD3D12.cpp b/src/dawn_native/d3d12/BindGroupD3D12.cpp index 275f1ce3fa..0d9292b3bc 100644 --- a/src/dawn_native/d3d12/BindGroupD3D12.cpp +++ b/src/dawn_native/d3d12/BindGroupD3D12.cpp @@ -44,7 +44,7 @@ namespace dawn_native { namespace d3d12 { for (uint32_t bindingIndex : IterateBitSet(layout.mask)) { // It's not necessary to create descriptors in descriptor heap for dynamic resources. // So skip allocating descriptors in descriptor heaps for dynamic buffers. - if (layout.dynamic[bindingIndex]) { + if (layout.hasDynamicOffset[bindingIndex]) { continue; } diff --git a/src/dawn_native/d3d12/BindGroupLayoutD3D12.cpp b/src/dawn_native/d3d12/BindGroupLayoutD3D12.cpp index ec81ad6d0c..e0627b4be3 100644 --- a/src/dawn_native/d3d12/BindGroupLayoutD3D12.cpp +++ b/src/dawn_native/d3d12/BindGroupLayoutD3D12.cpp @@ -27,7 +27,7 @@ namespace dawn_native { namespace d3d12 { // For dynamic resources, Dawn uses root descriptor in D3D12 backend. // So there is no need to allocate the descriptor from descriptor heap. Skip counting // dynamic resources for calculating size of descriptor heap. - if (groupInfo.dynamic[binding]) { + if (groupInfo.hasDynamicOffset[binding]) { continue; } @@ -94,7 +94,7 @@ namespace dawn_native { namespace d3d12 { descriptorOffsets[Sampler] = 0; for (uint32_t binding : IterateBitSet(groupInfo.mask)) { - if (groupInfo.dynamic[binding]) { + if (groupInfo.hasDynamicOffset[binding]) { // Dawn is using values in mBindingOffsets to decide register number in HLSL. // Root descriptor needs to set this value to set correct register number in // generated HLSL shader. diff --git a/src/dawn_native/d3d12/CommandBufferD3D12.cpp b/src/dawn_native/d3d12/CommandBufferD3D12.cpp index 5fbb778968..f4aa363a5f 100644 --- a/src/dawn_native/d3d12/CommandBufferD3D12.cpp +++ b/src/dawn_native/d3d12/CommandBufferD3D12.cpp @@ -178,7 +178,7 @@ namespace dawn_native { namespace d3d12 { group->GetLayout()->GetBindingInfo(); uint32_t currentDynamicBufferIndex = 0; - for (uint32_t bindingIndex : IterateBitSet(layout.dynamic)) { + for (uint32_t bindingIndex : IterateBitSet(layout.hasDynamicOffset)) { ASSERT(dynamicOffsetCount > 0); uint32_t parameterIndex = pipelineLayout->GetDynamicRootParameterIndex(index, bindingIndex); diff --git a/src/dawn_native/d3d12/PipelineLayoutD3D12.cpp b/src/dawn_native/d3d12/PipelineLayoutD3D12.cpp index 08b0e257c8..1b8a219e0f 100644 --- a/src/dawn_native/d3d12/PipelineLayoutD3D12.cpp +++ b/src/dawn_native/d3d12/PipelineLayoutD3D12.cpp @@ -117,7 +117,7 @@ namespace dawn_native { namespace d3d12 { const auto& shaderRegisters = bindGroupLayout->GetBindingOffsets(); // Init root descriptors in root signatures. - for (uint32_t dynamicBinding : IterateBitSet(groupInfo.dynamic)) { + for (uint32_t dynamicBinding : IterateBitSet(groupInfo.hasDynamicOffset)) { D3D12_ROOT_PARAMETER* rootParameter = &rootParameters[parameterIndex]; // Setup root descriptor. @@ -172,7 +172,7 @@ namespace dawn_native { namespace d3d12 { uint32_t PipelineLayout::GetDynamicRootParameterIndex(uint32_t group, uint32_t binding) const { ASSERT(group < kMaxBindGroups); ASSERT(binding < kMaxBindingsPerGroup); - ASSERT(GetBindGroupLayout(group)->GetBindingInfo().dynamic[binding]); + ASSERT(GetBindGroupLayout(group)->GetBindingInfo().hasDynamicOffset[binding]); return mDynamicRootParameterIndices[group][binding]; } }} // namespace dawn_native::d3d12 diff --git a/src/dawn_native/metal/CommandBufferMTL.mm b/src/dawn_native/metal/CommandBufferMTL.mm index 0ea8feb54c..bc7bd7d28c 100644 --- a/src/dawn_native/metal/CommandBufferMTL.mm +++ b/src/dawn_native/metal/CommandBufferMTL.mm @@ -460,7 +460,7 @@ namespace dawn_native { namespace metal { // TODO(shaobo.yan@intel.com): Record bound buffer status to use // setBufferOffset to achieve better performance. - if (layout.dynamic[bindingIndex]) { + if (layout.hasDynamicOffset[bindingIndex]) { offset += dynamicOffsets[currentDynamicBufferIndex]; currentDynamicBufferIndex++; } diff --git a/src/dawn_native/opengl/CommandBufferGL.cpp b/src/dawn_native/opengl/CommandBufferGL.cpp index 5943a8df95..b45103962a 100644 --- a/src/dawn_native/opengl/CommandBufferGL.cpp +++ b/src/dawn_native/opengl/CommandBufferGL.cpp @@ -254,7 +254,7 @@ namespace dawn_native { namespace opengl { GLuint uboIndex = indices[bindingIndex]; GLuint offset = binding.offset; - if (layout.dynamic[bindingIndex]) { + if (layout.hasDynamicOffset[bindingIndex]) { offset += dynamicOffsets[currentDynamicIndex]; ++currentDynamicIndex; } @@ -298,7 +298,7 @@ namespace dawn_native { namespace opengl { GLuint ssboIndex = indices[bindingIndex]; GLuint offset = binding.offset; - if (layout.dynamic[bindingIndex]) { + if (layout.hasDynamicOffset[bindingIndex]) { offset += dynamicOffsets[currentDynamicIndex]; ++currentDynamicIndex; } diff --git a/src/dawn_native/vulkan/BindGroupLayoutVk.cpp b/src/dawn_native/vulkan/BindGroupLayoutVk.cpp index e2d36ae179..31c3575225 100644 --- a/src/dawn_native/vulkan/BindGroupLayoutVk.cpp +++ b/src/dawn_native/vulkan/BindGroupLayoutVk.cpp @@ -73,7 +73,7 @@ namespace dawn_native { namespace vulkan { auto& binding = bindings[numBindings]; binding.binding = bindingIndex; binding.descriptorType = - VulkanDescriptorType(info.types[bindingIndex], info.dynamic[bindingIndex]); + VulkanDescriptorType(info.types[bindingIndex], info.hasDynamicOffset[bindingIndex]); binding.descriptorCount = 1; binding.stageFlags = VulkanShaderStageFlags(info.visibilities[bindingIndex]); binding.pImmutableSamplers = nullptr; @@ -146,8 +146,8 @@ namespace dawn_native { namespace vulkan { if (descriptorTypeIndex[type] == -1) { descriptorTypeIndex[type] = numSizes; - result[numSizes].type = - VulkanDescriptorType(info.types[bindingIndex], info.dynamic[bindingIndex]); + result[numSizes].type = VulkanDescriptorType(info.types[bindingIndex], + info.hasDynamicOffset[bindingIndex]); result[numSizes].descriptorCount = 1; numSizes++; } else { diff --git a/src/dawn_native/vulkan/BindGroupVk.cpp b/src/dawn_native/vulkan/BindGroupVk.cpp index f321c686da..cc7ddd4881 100644 --- a/src/dawn_native/vulkan/BindGroupVk.cpp +++ b/src/dawn_native/vulkan/BindGroupVk.cpp @@ -78,7 +78,7 @@ namespace dawn_native { namespace vulkan { write.dstArrayElement = 0; write.descriptorCount = 1; write.descriptorType = VulkanDescriptorType(layoutInfo.types[bindingIndex], - layoutInfo.dynamic[bindingIndex]); + layoutInfo.hasDynamicOffset[bindingIndex]); switch (layoutInfo.types[bindingIndex]) { case dawn::BindingType::UniformBuffer: