Rename GPUBindGroupLayoutBinding dynamic to hasDynamicOffset

Following WebGPU change at  https://github.com/gpuweb/gpuweb/pull/427,
this CL renames GPUBindGroupLayoutBinding dynamic to hasDynamicOffset.

Bug: dawn:22
Change-Id: Ie1c2bf4b1f6764c83be7cfe04f4f1a1d2205f685
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11500
Commit-Queue: François Beaufort <beaufort.francois@gmail.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
François Beaufort 2019-09-24 11:08:17 +00:00 committed by Commit Bot service account
parent 41f8aa550b
commit c3b613296d
11 changed files with 23 additions and 23 deletions

View File

@ -56,7 +56,7 @@
{"name": "binding", "type": "uint32_t"}, {"name": "binding", "type": "uint32_t"},
{"name": "visibility", "type": "shader stage"}, {"name": "visibility", "type": "shader stage"},
{"name": "type", "type": "binding type"}, {"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": "multisampled", "type": "bool", "default": "false"},
{"name": "texture dimension", "type": "texture view dimension", "default": "undefined"}, {"name": "texture dimension", "type": "texture view dimension", "default": "undefined"},
{"name": "texture component type", "type": "texture component type", "default": "float"} {"name": "texture component type", "type": "texture component type", "default": "float"}

View File

@ -55,18 +55,18 @@ namespace dawn_native {
switch (binding.type) { switch (binding.type) {
case dawn::BindingType::UniformBuffer: case dawn::BindingType::UniformBuffer:
if (binding.dynamic) { if (binding.hasDynamicOffset) {
++dynamicUniformBufferCount; ++dynamicUniformBufferCount;
} }
break; break;
case dawn::BindingType::StorageBuffer: case dawn::BindingType::StorageBuffer:
if (binding.dynamic) { if (binding.hasDynamicOffset) {
++dynamicStorageBufferCount; ++dynamicStorageBufferCount;
} }
break; break;
case dawn::BindingType::SampledTexture: case dawn::BindingType::SampledTexture:
case dawn::BindingType::Sampler: case dawn::BindingType::Sampler:
if (binding.dynamic) { if (binding.hasDynamicOffset) {
return DAWN_VALIDATION_ERROR("Samplers and textures cannot be dynamic"); return DAWN_VALIDATION_ERROR("Samplers and textures cannot be dynamic");
} }
break; break;
@ -100,7 +100,7 @@ namespace dawn_native {
namespace { namespace {
size_t HashBindingInfo(const BindGroupLayoutBase::LayoutBindingInfo& info) { size_t HashBindingInfo(const BindGroupLayoutBase::LayoutBindingInfo& info) {
size_t hash = Hash(info.mask); 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)) { for (uint32_t binding : IterateBitSet(info.mask)) {
HashCombine(&hash, info.visibilities[binding], info.types[binding], HashCombine(&hash, info.visibilities[binding], info.types[binding],
@ -112,7 +112,8 @@ namespace dawn_native {
bool operator==(const BindGroupLayoutBase::LayoutBindingInfo& a, bool operator==(const BindGroupLayoutBase::LayoutBindingInfo& a,
const BindGroupLayoutBase::LayoutBindingInfo& b) { 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; return false;
} }
@ -148,9 +149,8 @@ namespace dawn_native {
} else { } else {
mBindingInfo.textureDimensions[index] = binding.textureDimension; mBindingInfo.textureDimensions[index] = binding.textureDimension;
} }
if (binding.hasDynamicOffset) {
if (binding.dynamic) { mBindingInfo.hasDynamicOffset.set(index);
mBindingInfo.dynamic.set(index);
switch (binding.type) { switch (binding.type) {
case dawn::BindingType::UniformBuffer: case dawn::BindingType::UniformBuffer:
++mDynamicUniformBufferCount; ++mDynamicUniformBufferCount;

View File

@ -44,7 +44,7 @@ namespace dawn_native {
std::array<dawn::BindingType, kMaxBindingsPerGroup> types; std::array<dawn::BindingType, kMaxBindingsPerGroup> types;
std::array<dawn::TextureComponentType, kMaxBindingsPerGroup> textureComponentTypes; std::array<dawn::TextureComponentType, kMaxBindingsPerGroup> textureComponentTypes;
std::array<dawn::TextureViewDimension, kMaxBindingsPerGroup> textureDimensions; std::array<dawn::TextureViewDimension, kMaxBindingsPerGroup> textureDimensions;
std::bitset<kMaxBindingsPerGroup> dynamic; std::bitset<kMaxBindingsPerGroup> hasDynamicOffset;
std::bitset<kMaxBindingsPerGroup> multisampled; std::bitset<kMaxBindingsPerGroup> multisampled;
std::bitset<kMaxBindingsPerGroup> mask; std::bitset<kMaxBindingsPerGroup> mask;
}; };

View File

@ -44,7 +44,7 @@ namespace dawn_native { namespace d3d12 {
for (uint32_t bindingIndex : IterateBitSet(layout.mask)) { for (uint32_t bindingIndex : IterateBitSet(layout.mask)) {
// It's not necessary to create descriptors in descriptor heap for dynamic resources. // It's not necessary to create descriptors in descriptor heap for dynamic resources.
// So skip allocating descriptors in descriptor heaps for dynamic buffers. // So skip allocating descriptors in descriptor heaps for dynamic buffers.
if (layout.dynamic[bindingIndex]) { if (layout.hasDynamicOffset[bindingIndex]) {
continue; continue;
} }

View File

@ -27,7 +27,7 @@ namespace dawn_native { namespace d3d12 {
// For dynamic resources, Dawn uses root descriptor in D3D12 backend. // For dynamic resources, Dawn uses root descriptor in D3D12 backend.
// So there is no need to allocate the descriptor from descriptor heap. Skip counting // So there is no need to allocate the descriptor from descriptor heap. Skip counting
// dynamic resources for calculating size of descriptor heap. // dynamic resources for calculating size of descriptor heap.
if (groupInfo.dynamic[binding]) { if (groupInfo.hasDynamicOffset[binding]) {
continue; continue;
} }
@ -94,7 +94,7 @@ namespace dawn_native { namespace d3d12 {
descriptorOffsets[Sampler] = 0; descriptorOffsets[Sampler] = 0;
for (uint32_t binding : IterateBitSet(groupInfo.mask)) { 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. // 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 // Root descriptor needs to set this value to set correct register number in
// generated HLSL shader. // generated HLSL shader.

View File

@ -178,7 +178,7 @@ namespace dawn_native { namespace d3d12 {
group->GetLayout()->GetBindingInfo(); group->GetLayout()->GetBindingInfo();
uint32_t currentDynamicBufferIndex = 0; uint32_t currentDynamicBufferIndex = 0;
for (uint32_t bindingIndex : IterateBitSet(layout.dynamic)) { for (uint32_t bindingIndex : IterateBitSet(layout.hasDynamicOffset)) {
ASSERT(dynamicOffsetCount > 0); ASSERT(dynamicOffsetCount > 0);
uint32_t parameterIndex = uint32_t parameterIndex =
pipelineLayout->GetDynamicRootParameterIndex(index, bindingIndex); pipelineLayout->GetDynamicRootParameterIndex(index, bindingIndex);

View File

@ -117,7 +117,7 @@ namespace dawn_native { namespace d3d12 {
const auto& shaderRegisters = bindGroupLayout->GetBindingOffsets(); const auto& shaderRegisters = bindGroupLayout->GetBindingOffsets();
// Init root descriptors in root signatures. // 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]; D3D12_ROOT_PARAMETER* rootParameter = &rootParameters[parameterIndex];
// Setup root descriptor. // Setup root descriptor.
@ -172,7 +172,7 @@ namespace dawn_native { namespace d3d12 {
uint32_t PipelineLayout::GetDynamicRootParameterIndex(uint32_t group, uint32_t binding) const { uint32_t PipelineLayout::GetDynamicRootParameterIndex(uint32_t group, uint32_t binding) const {
ASSERT(group < kMaxBindGroups); ASSERT(group < kMaxBindGroups);
ASSERT(binding < kMaxBindingsPerGroup); ASSERT(binding < kMaxBindingsPerGroup);
ASSERT(GetBindGroupLayout(group)->GetBindingInfo().dynamic[binding]); ASSERT(GetBindGroupLayout(group)->GetBindingInfo().hasDynamicOffset[binding]);
return mDynamicRootParameterIndices[group][binding]; return mDynamicRootParameterIndices[group][binding];
} }
}} // namespace dawn_native::d3d12 }} // namespace dawn_native::d3d12

View File

@ -460,7 +460,7 @@ namespace dawn_native { namespace metal {
// TODO(shaobo.yan@intel.com): Record bound buffer status to use // TODO(shaobo.yan@intel.com): Record bound buffer status to use
// setBufferOffset to achieve better performance. // setBufferOffset to achieve better performance.
if (layout.dynamic[bindingIndex]) { if (layout.hasDynamicOffset[bindingIndex]) {
offset += dynamicOffsets[currentDynamicBufferIndex]; offset += dynamicOffsets[currentDynamicBufferIndex];
currentDynamicBufferIndex++; currentDynamicBufferIndex++;
} }

View File

@ -254,7 +254,7 @@ namespace dawn_native { namespace opengl {
GLuint uboIndex = indices[bindingIndex]; GLuint uboIndex = indices[bindingIndex];
GLuint offset = binding.offset; GLuint offset = binding.offset;
if (layout.dynamic[bindingIndex]) { if (layout.hasDynamicOffset[bindingIndex]) {
offset += dynamicOffsets[currentDynamicIndex]; offset += dynamicOffsets[currentDynamicIndex];
++currentDynamicIndex; ++currentDynamicIndex;
} }
@ -298,7 +298,7 @@ namespace dawn_native { namespace opengl {
GLuint ssboIndex = indices[bindingIndex]; GLuint ssboIndex = indices[bindingIndex];
GLuint offset = binding.offset; GLuint offset = binding.offset;
if (layout.dynamic[bindingIndex]) { if (layout.hasDynamicOffset[bindingIndex]) {
offset += dynamicOffsets[currentDynamicIndex]; offset += dynamicOffsets[currentDynamicIndex];
++currentDynamicIndex; ++currentDynamicIndex;
} }

View File

@ -73,7 +73,7 @@ namespace dawn_native { namespace vulkan {
auto& binding = bindings[numBindings]; auto& binding = bindings[numBindings];
binding.binding = bindingIndex; binding.binding = bindingIndex;
binding.descriptorType = binding.descriptorType =
VulkanDescriptorType(info.types[bindingIndex], info.dynamic[bindingIndex]); VulkanDescriptorType(info.types[bindingIndex], info.hasDynamicOffset[bindingIndex]);
binding.descriptorCount = 1; binding.descriptorCount = 1;
binding.stageFlags = VulkanShaderStageFlags(info.visibilities[bindingIndex]); binding.stageFlags = VulkanShaderStageFlags(info.visibilities[bindingIndex]);
binding.pImmutableSamplers = nullptr; binding.pImmutableSamplers = nullptr;
@ -146,8 +146,8 @@ namespace dawn_native { namespace vulkan {
if (descriptorTypeIndex[type] == -1) { if (descriptorTypeIndex[type] == -1) {
descriptorTypeIndex[type] = numSizes; descriptorTypeIndex[type] = numSizes;
result[numSizes].type = result[numSizes].type = VulkanDescriptorType(info.types[bindingIndex],
VulkanDescriptorType(info.types[bindingIndex], info.dynamic[bindingIndex]); info.hasDynamicOffset[bindingIndex]);
result[numSizes].descriptorCount = 1; result[numSizes].descriptorCount = 1;
numSizes++; numSizes++;
} else { } else {

View File

@ -78,7 +78,7 @@ namespace dawn_native { namespace vulkan {
write.dstArrayElement = 0; write.dstArrayElement = 0;
write.descriptorCount = 1; write.descriptorCount = 1;
write.descriptorType = VulkanDescriptorType(layoutInfo.types[bindingIndex], write.descriptorType = VulkanDescriptorType(layoutInfo.types[bindingIndex],
layoutInfo.dynamic[bindingIndex]); layoutInfo.hasDynamicOffset[bindingIndex]);
switch (layoutInfo.types[bindingIndex]) { switch (layoutInfo.types[bindingIndex]) {
case dawn::BindingType::UniformBuffer: case dawn::BindingType::UniformBuffer: