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": "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"}

View File

@ -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;

View File

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

View File

@ -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;
}

View File

@ -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.

View File

@ -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);

View File

@ -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

View File

@ -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++;
}

View File

@ -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;
}

View File

@ -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 {

View File

@ -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: