mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-05 20:55:58 +00:00
Add dynamic attribute in bind group layout binding
WebGPU remove dynamic-uniform-buffer and dynamic-storage-buffer but add a new attribute in BindgroupLayoutBinding to record whether a buffer resource is dynamic. Dawn need to align with this change. BUG=dawn:180 Change-Id: I873ad2ec75575e72d184f89a6e3698dff6df50d7 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8520 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
8f93871dff
commit
f697fe3b7d
11
dawn.json
11
dawn.json
@ -55,7 +55,8 @@
|
|||||||
"members": [
|
"members": [
|
||||||
{"name": "binding", "type": "uint32_t"},
|
{"name": "binding", "type": "uint32_t"},
|
||||||
{"name": "visibility", "type": "shader stage bit"},
|
{"name": "visibility", "type": "shader stage bit"},
|
||||||
{"name": "type", "type": "binding type"}
|
{"name": "type", "type": "binding type"},
|
||||||
|
{"name": "dynamic", "type": "bool", "default": "false" }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"bind group layout descriptor": {
|
"bind group layout descriptor": {
|
||||||
@ -70,11 +71,9 @@
|
|||||||
"category": "enum",
|
"category": "enum",
|
||||||
"values": [
|
"values": [
|
||||||
{"value": 0, "name": "uniform buffer"},
|
{"value": 0, "name": "uniform buffer"},
|
||||||
{"value": 1, "name": "sampler"},
|
{"value": 1, "name": "storage buffer"},
|
||||||
{"value": 2, "name": "sampled texture"},
|
{"value": 2, "name": "sampler"},
|
||||||
{"value": 3, "name": "storage buffer"},
|
{"value": 3, "name": "sampled texture"}
|
||||||
{"value": 4, "name": "dynamic uniform buffer"},
|
|
||||||
{"value": 5, "name": "dynamic storage buffer"}
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"blend descriptor": {
|
"blend descriptor": {
|
||||||
|
@ -111,7 +111,7 @@ void init() {
|
|||||||
})");
|
})");
|
||||||
|
|
||||||
dawn::BindGroupLayout bgl = utils::MakeBindGroupLayout(
|
dawn::BindGroupLayout bgl = utils::MakeBindGroupLayout(
|
||||||
device, {{0, dawn::ShaderStageBit::Vertex, dawn::BindingType::DynamicUniformBuffer}});
|
device, {{0, dawn::ShaderStageBit::Vertex, dawn::BindingType::UniformBuffer, true}});
|
||||||
|
|
||||||
utils::ComboRenderPipelineDescriptor descriptor(device);
|
utils::ComboRenderPipelineDescriptor descriptor(device);
|
||||||
descriptor.layout = utils::MakeBasicPipelineLayout(device, &bgl);
|
descriptor.layout = utils::MakeBasicPipelineLayout(device, &bgl);
|
||||||
|
@ -126,18 +126,23 @@ namespace dawn_native {
|
|||||||
// Perform binding-type specific validation.
|
// Perform binding-type specific validation.
|
||||||
switch (layoutInfo.types[bindingIndex]) {
|
switch (layoutInfo.types[bindingIndex]) {
|
||||||
case dawn::BindingType::UniformBuffer:
|
case dawn::BindingType::UniformBuffer:
|
||||||
case dawn::BindingType::DynamicUniformBuffer:
|
|
||||||
DAWN_TRY(ValidateBufferBinding(device, binding, dawn::BufferUsageBit::Uniform));
|
DAWN_TRY(ValidateBufferBinding(device, binding, dawn::BufferUsageBit::Uniform));
|
||||||
break;
|
break;
|
||||||
case dawn::BindingType::StorageBuffer:
|
case dawn::BindingType::StorageBuffer:
|
||||||
case dawn::BindingType::DynamicStorageBuffer:
|
|
||||||
DAWN_TRY(ValidateBufferBinding(device, binding, dawn::BufferUsageBit::Storage));
|
DAWN_TRY(ValidateBufferBinding(device, binding, dawn::BufferUsageBit::Storage));
|
||||||
break;
|
break;
|
||||||
case dawn::BindingType::SampledTexture:
|
case dawn::BindingType::SampledTexture:
|
||||||
|
if (layoutInfo.dynamic[bindingIndex]) {
|
||||||
|
return DAWN_VALIDATION_ERROR(
|
||||||
|
"SampledTextures are expected to be not dynamic");
|
||||||
|
}
|
||||||
DAWN_TRY(
|
DAWN_TRY(
|
||||||
ValidateTextureBinding(device, binding, dawn::TextureUsageBit::Sampled));
|
ValidateTextureBinding(device, binding, dawn::TextureUsageBit::Sampled));
|
||||||
break;
|
break;
|
||||||
case dawn::BindingType::Sampler:
|
case dawn::BindingType::Sampler:
|
||||||
|
if (layoutInfo.dynamic[bindingIndex]) {
|
||||||
|
return DAWN_VALIDATION_ERROR("Samplers are expected to be not dynamic");
|
||||||
|
}
|
||||||
DAWN_TRY(ValidateSamplerBinding(device, binding));
|
DAWN_TRY(ValidateSamplerBinding(device, binding));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -207,10 +212,7 @@ namespace dawn_native {
|
|||||||
ASSERT(binding < kMaxBindingsPerGroup);
|
ASSERT(binding < kMaxBindingsPerGroup);
|
||||||
ASSERT(mLayout->GetBindingInfo().mask[binding]);
|
ASSERT(mLayout->GetBindingInfo().mask[binding]);
|
||||||
ASSERT(mLayout->GetBindingInfo().types[binding] == dawn::BindingType::UniformBuffer ||
|
ASSERT(mLayout->GetBindingInfo().types[binding] == dawn::BindingType::UniformBuffer ||
|
||||||
mLayout->GetBindingInfo().types[binding] == dawn::BindingType::StorageBuffer ||
|
mLayout->GetBindingInfo().types[binding] == dawn::BindingType::StorageBuffer);
|
||||||
mLayout->GetBindingInfo().types[binding] ==
|
|
||||||
dawn::BindingType::DynamicUniformBuffer ||
|
|
||||||
mLayout->GetBindingInfo().types[binding] == dawn::BindingType::DynamicStorageBuffer);
|
|
||||||
BufferBase* buffer = static_cast<BufferBase*>(mBindings[binding].Get());
|
BufferBase* buffer = static_cast<BufferBase*>(mBindings[binding].Get());
|
||||||
return {buffer, mOffsets[binding], mSizes[binding]};
|
return {buffer, mOffsets[binding], mSizes[binding]};
|
||||||
}
|
}
|
||||||
|
@ -87,8 +87,8 @@ namespace dawn_native {
|
|||||||
mBindingInfo.visibilities[index] = binding.visibility;
|
mBindingInfo.visibilities[index] = binding.visibility;
|
||||||
mBindingInfo.types[index] = binding.type;
|
mBindingInfo.types[index] = binding.type;
|
||||||
|
|
||||||
if (binding.type == dawn::BindingType::DynamicUniformBuffer ||
|
if (binding.dynamic) {
|
||||||
binding.type == dawn::BindingType::DynamicStorageBuffer) {
|
mBindingInfo.dynamic.set(index);
|
||||||
mDynamicBufferCount++;
|
mDynamicBufferCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@ namespace dawn_native {
|
|||||||
struct LayoutBindingInfo {
|
struct LayoutBindingInfo {
|
||||||
std::array<dawn::ShaderStageBit, kMaxBindingsPerGroup> visibilities;
|
std::array<dawn::ShaderStageBit, kMaxBindingsPerGroup> visibilities;
|
||||||
std::array<dawn::BindingType, kMaxBindingsPerGroup> types;
|
std::array<dawn::BindingType, kMaxBindingsPerGroup> types;
|
||||||
|
std::bitset<kMaxBindingsPerGroup> dynamic;
|
||||||
std::bitset<kMaxBindingsPerGroup> mask;
|
std::bitset<kMaxBindingsPerGroup> mask;
|
||||||
};
|
};
|
||||||
const LayoutBindingInfo& GetBindingInfo() const;
|
const LayoutBindingInfo& GetBindingInfo() const;
|
||||||
|
@ -588,14 +588,12 @@ namespace dawn_native {
|
|||||||
dawn::BindingType type = layoutInfo.types[i];
|
dawn::BindingType type = layoutInfo.types[i];
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case dawn::BindingType::UniformBuffer:
|
case dawn::BindingType::UniformBuffer: {
|
||||||
case dawn::BindingType::DynamicUniformBuffer: {
|
|
||||||
BufferBase* buffer = group->GetBindingAsBufferBinding(i).buffer;
|
BufferBase* buffer = group->GetBindingAsBufferBinding(i).buffer;
|
||||||
tracker->BufferUsedAs(buffer, dawn::BufferUsageBit::Uniform);
|
tracker->BufferUsedAs(buffer, dawn::BufferUsageBit::Uniform);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case dawn::BindingType::StorageBuffer:
|
case dawn::BindingType::StorageBuffer: {
|
||||||
case dawn::BindingType::DynamicStorageBuffer: {
|
|
||||||
BufferBase* buffer = group->GetBindingAsBufferBinding(i).buffer;
|
BufferBase* buffer = group->GetBindingAsBufferBinding(i).buffer;
|
||||||
tracker->BufferUsedAs(buffer, dawn::BufferUsageBit::Storage);
|
tracker->BufferUsedAs(buffer, dawn::BufferUsageBit::Storage);
|
||||||
} break;
|
} break;
|
||||||
|
@ -66,17 +66,6 @@ namespace dawn_native {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn::BindingType NonDynamicBindingType(dawn::BindingType type) {
|
|
||||||
switch (type) {
|
|
||||||
case dawn::BindingType::DynamicUniformBuffer:
|
|
||||||
return dawn::BindingType::UniformBuffer;
|
|
||||||
case dawn::BindingType::DynamicStorageBuffer:
|
|
||||||
return dawn::BindingType::StorageBuffer;
|
|
||||||
default:
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ShaderModuleBase
|
// ShaderModuleBase
|
||||||
|
|
||||||
ShaderModuleBase::ShaderModuleBase(DeviceBase* device,
|
ShaderModuleBase::ShaderModuleBase(DeviceBase* device,
|
||||||
@ -247,9 +236,7 @@ namespace dawn_native {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// DynamicUniformBuffer and DynamicStorageBuffer are uniform buffer and
|
if (layoutBindingType != moduleInfo.type) {
|
||||||
// storage buffer in shader. Need to translate them.
|
|
||||||
if (NonDynamicBindingType(layoutBindingType) != moduleInfo.type) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,10 +97,6 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
} break;
|
} break;
|
||||||
|
|
||||||
// TODO(shaobo.yan@intel.com): Implement dynamic buffer offset.
|
// TODO(shaobo.yan@intel.com): Implement dynamic buffer offset.
|
||||||
case dawn::BindingType::DynamicUniformBuffer:
|
|
||||||
case dawn::BindingType::DynamicStorageBuffer:
|
|
||||||
UNREACHABLE();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,10 +38,6 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
mBindingOffsets[binding] = mDescriptorCounts[Sampler]++;
|
mBindingOffsets[binding] = mDescriptorCounts[Sampler]++;
|
||||||
break;
|
break;
|
||||||
// TODO(shaobo.yan@intel.com): Implement dynamic buffer offset.
|
// TODO(shaobo.yan@intel.com): Implement dynamic buffer offset.
|
||||||
case dawn::BindingType::DynamicUniformBuffer:
|
|
||||||
case dawn::BindingType::DynamicStorageBuffer:
|
|
||||||
UNREACHABLE();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,10 +97,6 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
mBindingOffsets[binding] += descriptorOffsets[Sampler];
|
mBindingOffsets[binding] += descriptorOffsets[Sampler];
|
||||||
break;
|
break;
|
||||||
// TODO(shaobo.yan@intel.com): Implement dynamic buffer offset.
|
// TODO(shaobo.yan@intel.com): Implement dynamic buffer offset.
|
||||||
case dawn::BindingType::DynamicUniformBuffer:
|
|
||||||
case dawn::BindingType::DynamicStorageBuffer:
|
|
||||||
UNREACHABLE();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -235,7 +235,14 @@ namespace dawn_native { namespace metal {
|
|||||||
case dawn::BindingType::StorageBuffer: {
|
case dawn::BindingType::StorageBuffer: {
|
||||||
BufferBinding binding = group->GetBindingAsBufferBinding(bindingIndex);
|
BufferBinding binding = group->GetBindingAsBufferBinding(bindingIndex);
|
||||||
const id<MTLBuffer> buffer = ToBackend(binding.buffer)->GetMTLBuffer();
|
const id<MTLBuffer> buffer = ToBackend(binding.buffer)->GetMTLBuffer();
|
||||||
const NSUInteger offset = binding.offset;
|
NSUInteger offset = binding.offset;
|
||||||
|
|
||||||
|
// TODO(shaobo.yan@intel.com): Record bound buffer status to use
|
||||||
|
// setBufferOffset to achieve better performance.
|
||||||
|
if (layout.dynamic[bindingIndex]) {
|
||||||
|
offset += dynamicOffsets[currentDynamicBufferIndex];
|
||||||
|
currentDynamicBufferIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
if (hasVertStage) {
|
if (hasVertStage) {
|
||||||
[render setVertexBuffers:&buffer
|
[render setVertexBuffers:&buffer
|
||||||
@ -285,34 +292,6 @@ namespace dawn_native { namespace metal {
|
|||||||
[compute setTexture:textureView->GetMTLTexture() atIndex:computeIndex];
|
[compute setTexture:textureView->GetMTLTexture() atIndex:computeIndex];
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
// TODO(shaobo.yan@intel.com): Record bound buffer status to use setBufferOffset
|
|
||||||
// to achieve better performance.
|
|
||||||
case dawn::BindingType::DynamicUniformBuffer:
|
|
||||||
case dawn::BindingType::DynamicStorageBuffer: {
|
|
||||||
ASSERT(currentDynamicBufferIndex < dynamicOffsetCount);
|
|
||||||
BufferBinding binding = group->GetBindingAsBufferBinding(bindingIndex);
|
|
||||||
const id<MTLBuffer> buffer = ToBackend(binding.buffer)->GetMTLBuffer();
|
|
||||||
NSUInteger offset =
|
|
||||||
binding.offset + dynamicOffsets[currentDynamicBufferIndex];
|
|
||||||
currentDynamicBufferIndex += 1;
|
|
||||||
|
|
||||||
if (hasVertStage) {
|
|
||||||
[render setVertexBuffers:&buffer
|
|
||||||
offsets:&offset
|
|
||||||
withRange:NSMakeRange(vertIndex, 1)];
|
|
||||||
}
|
|
||||||
if (hasFragStage) {
|
|
||||||
[render setFragmentBuffers:&buffer
|
|
||||||
offsets:&offset
|
|
||||||
withRange:NSMakeRange(fragIndex, 1)];
|
|
||||||
}
|
|
||||||
if (hasComputeStage) {
|
|
||||||
[compute setBuffers:&buffer
|
|
||||||
offsets:&offset
|
|
||||||
withRange:NSMakeRange(computeIndex, 1)];
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,8 +42,6 @@ namespace dawn_native { namespace metal {
|
|||||||
switch (groupInfo.types[binding]) {
|
switch (groupInfo.types[binding]) {
|
||||||
case dawn::BindingType::UniformBuffer:
|
case dawn::BindingType::UniformBuffer:
|
||||||
case dawn::BindingType::StorageBuffer:
|
case dawn::BindingType::StorageBuffer:
|
||||||
case dawn::BindingType::DynamicUniformBuffer:
|
|
||||||
case dawn::BindingType::DynamicStorageBuffer:
|
|
||||||
mIndexInfo[stage][group][binding] = bufferIndex;
|
mIndexInfo[stage][group][binding] = bufferIndex;
|
||||||
bufferIndex++;
|
bufferIndex++;
|
||||||
break;
|
break;
|
||||||
|
@ -267,10 +267,6 @@ namespace dawn_native { namespace opengl {
|
|||||||
} break;
|
} break;
|
||||||
|
|
||||||
// TODO(shaobo.yan@intel.com): Implement dynamic buffer offset.
|
// TODO(shaobo.yan@intel.com): Implement dynamic buffer offset.
|
||||||
case dawn::BindingType::DynamicUniformBuffer:
|
|
||||||
case dawn::BindingType::DynamicStorageBuffer:
|
|
||||||
UNREACHABLE();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,10 +136,6 @@ namespace dawn_native { namespace opengl {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
// TODO(shaobo.yan@intel.com): Implement dynamic buffer offset.
|
// TODO(shaobo.yan@intel.com): Implement dynamic buffer offset.
|
||||||
case dawn::BindingType::DynamicUniformBuffer:
|
|
||||||
case dawn::BindingType::DynamicStorageBuffer:
|
|
||||||
UNREACHABLE();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,10 +55,6 @@ namespace dawn_native { namespace opengl {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
// TODO(shaobo.yan@intel.com): Implement dynamic buffer offset
|
// TODO(shaobo.yan@intel.com): Implement dynamic buffer offset
|
||||||
case dawn::BindingType::DynamicUniformBuffer:
|
|
||||||
case dawn::BindingType::DynamicStorageBuffer:
|
|
||||||
UNREACHABLE();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,20 +39,22 @@ namespace dawn_native { namespace vulkan {
|
|||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
VkDescriptorType VulkanDescriptorType(dawn::BindingType type) {
|
VkDescriptorType VulkanDescriptorType(dawn::BindingType type, bool isDynamic) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case dawn::BindingType::UniformBuffer:
|
case dawn::BindingType::UniformBuffer:
|
||||||
|
if (isDynamic) {
|
||||||
|
return VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC;
|
||||||
|
}
|
||||||
return VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
return VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
||||||
case dawn::BindingType::Sampler:
|
case dawn::BindingType::Sampler:
|
||||||
return VK_DESCRIPTOR_TYPE_SAMPLER;
|
return VK_DESCRIPTOR_TYPE_SAMPLER;
|
||||||
case dawn::BindingType::SampledTexture:
|
case dawn::BindingType::SampledTexture:
|
||||||
return VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE;
|
return VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE;
|
||||||
case dawn::BindingType::StorageBuffer:
|
case dawn::BindingType::StorageBuffer:
|
||||||
return VK_DESCRIPTOR_TYPE_STORAGE_BUFFER;
|
if (isDynamic) {
|
||||||
case dawn::BindingType::DynamicUniformBuffer:
|
|
||||||
return VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC;
|
|
||||||
case dawn::BindingType::DynamicStorageBuffer:
|
|
||||||
return VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC;
|
return VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC;
|
||||||
|
}
|
||||||
|
return VK_DESCRIPTOR_TYPE_STORAGE_BUFFER;
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
@ -70,7 +72,8 @@ namespace dawn_native { namespace vulkan {
|
|||||||
for (uint32_t bindingIndex : IterateBitSet(info.mask)) {
|
for (uint32_t bindingIndex : IterateBitSet(info.mask)) {
|
||||||
auto& binding = bindings[numBindings];
|
auto& binding = bindings[numBindings];
|
||||||
binding.binding = bindingIndex;
|
binding.binding = bindingIndex;
|
||||||
binding.descriptorType = VulkanDescriptorType(info.types[bindingIndex]);
|
binding.descriptorType =
|
||||||
|
VulkanDescriptorType(info.types[bindingIndex], info.dynamic[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;
|
||||||
@ -122,14 +125,12 @@ namespace dawn_native { namespace vulkan {
|
|||||||
auto ToDescriptorType = [](dawn::BindingType type) -> DescriptorType {
|
auto ToDescriptorType = [](dawn::BindingType type) -> DescriptorType {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case dawn::BindingType::UniformBuffer:
|
case dawn::BindingType::UniformBuffer:
|
||||||
case dawn::BindingType::DynamicUniformBuffer:
|
|
||||||
return UNIFORM_BUFFER;
|
return UNIFORM_BUFFER;
|
||||||
case dawn::BindingType::Sampler:
|
case dawn::BindingType::Sampler:
|
||||||
return SAMPLER;
|
return SAMPLER;
|
||||||
case dawn::BindingType::SampledTexture:
|
case dawn::BindingType::SampledTexture:
|
||||||
return SAMPLED_IMAGE;
|
return SAMPLED_IMAGE;
|
||||||
case dawn::BindingType::StorageBuffer:
|
case dawn::BindingType::StorageBuffer:
|
||||||
case dawn::BindingType::DynamicStorageBuffer:
|
|
||||||
return STORAGE_BUFFER;
|
return STORAGE_BUFFER;
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
@ -145,7 +146,8 @@ namespace dawn_native { namespace vulkan {
|
|||||||
|
|
||||||
if (descriptorTypeIndex[type] == -1) {
|
if (descriptorTypeIndex[type] == -1) {
|
||||||
descriptorTypeIndex[type] = numSizes;
|
descriptorTypeIndex[type] = numSizes;
|
||||||
result[numSizes].type = VulkanDescriptorType(info.types[bindingIndex]);
|
result[numSizes].type =
|
||||||
|
VulkanDescriptorType(info.types[bindingIndex], info.dynamic[bindingIndex]);
|
||||||
result[numSizes].descriptorCount = 1;
|
result[numSizes].descriptorCount = 1;
|
||||||
numSizes++;
|
numSizes++;
|
||||||
} else {
|
} else {
|
||||||
|
@ -23,7 +23,7 @@ namespace dawn_native { namespace vulkan {
|
|||||||
|
|
||||||
class Device;
|
class Device;
|
||||||
|
|
||||||
VkDescriptorType VulkanDescriptorType(dawn::BindingType type);
|
VkDescriptorType VulkanDescriptorType(dawn::BindingType type, bool isDynamic);
|
||||||
|
|
||||||
class BindGroupLayout : public BindGroupLayoutBase {
|
class BindGroupLayout : public BindGroupLayoutBase {
|
||||||
public:
|
public:
|
||||||
|
@ -77,13 +77,12 @@ namespace dawn_native { namespace vulkan {
|
|||||||
write.dstBinding = bindingIndex;
|
write.dstBinding = bindingIndex;
|
||||||
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]);
|
||||||
|
|
||||||
switch (layoutInfo.types[bindingIndex]) {
|
switch (layoutInfo.types[bindingIndex]) {
|
||||||
case dawn::BindingType::UniformBuffer:
|
case dawn::BindingType::UniformBuffer:
|
||||||
case dawn::BindingType::StorageBuffer:
|
case dawn::BindingType::StorageBuffer: {
|
||||||
case dawn::BindingType::DynamicUniformBuffer:
|
|
||||||
case dawn::BindingType::DynamicStorageBuffer: {
|
|
||||||
BufferBinding binding = GetBindingAsBufferBinding(bindingIndex);
|
BufferBinding binding = GetBindingAsBufferBinding(bindingIndex);
|
||||||
|
|
||||||
writeBufferInfo[numWrites].buffer = ToBackend(binding.buffer)->GetHandle();
|
writeBufferInfo[numWrites].buffer = ToBackend(binding.buffer)->GetHandle();
|
||||||
|
@ -47,9 +47,9 @@ class DynamicBufferOffsetTests : public DawnTest {
|
|||||||
|
|
||||||
mBindGroupLayout = utils::MakeBindGroupLayout(
|
mBindGroupLayout = utils::MakeBindGroupLayout(
|
||||||
device, {{0, dawn::ShaderStageBit::Compute | dawn::ShaderStageBit::Fragment,
|
device, {{0, dawn::ShaderStageBit::Compute | dawn::ShaderStageBit::Fragment,
|
||||||
dawn::BindingType::DynamicUniformBuffer},
|
dawn::BindingType::UniformBuffer, true},
|
||||||
{1, dawn::ShaderStageBit::Compute | dawn::ShaderStageBit::Fragment,
|
{1, dawn::ShaderStageBit::Compute | dawn::ShaderStageBit::Fragment,
|
||||||
dawn::BindingType::DynamicStorageBuffer}});
|
dawn::BindingType::StorageBuffer, true}});
|
||||||
|
|
||||||
mBindGroup = utils::MakeBindGroup(
|
mBindGroup = utils::MakeBindGroup(
|
||||||
device, mBindGroupLayout,
|
device, mBindGroupLayout,
|
||||||
|
@ -456,9 +456,9 @@ class SetBindGroupValidationTest : public ValidationTest {
|
|||||||
void SetUp() override {
|
void SetUp() override {
|
||||||
mBindGroupLayout = utils::MakeBindGroupLayout(
|
mBindGroupLayout = utils::MakeBindGroupLayout(
|
||||||
device, {{0, dawn::ShaderStageBit::Compute | dawn::ShaderStageBit::Fragment,
|
device, {{0, dawn::ShaderStageBit::Compute | dawn::ShaderStageBit::Fragment,
|
||||||
dawn::BindingType::DynamicUniformBuffer},
|
dawn::BindingType::UniformBuffer, true},
|
||||||
{1, dawn::ShaderStageBit::Compute | dawn::ShaderStageBit::Fragment,
|
{1, dawn::ShaderStageBit::Compute | dawn::ShaderStageBit::Fragment,
|
||||||
dawn::BindingType::DynamicStorageBuffer}});
|
dawn::BindingType::StorageBuffer, true}});
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn::Buffer CreateBuffer(uint64_t bufferSize, dawn::BufferUsageBit usage) {
|
dawn::Buffer CreateBuffer(uint64_t bufferSize, dawn::BufferUsageBit usage) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user