Commit 93613e11 by Nicolas Capens Committed by Nicolas Capens

Reduce descriptor binding info exposure

Only the descriptor binding type is needed. It's an implementation detail that we currently store the entire original VkDescriptorSetLayoutBinding structures, which might change in the future. This also avoids specializing generated code for things which should not be treated as pipeline immutable state. Bug: b/152227757 Change-Id: I20ca7de53e972e77649dec20fcf623f818d4f53c Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/43972 Presubmit-Ready: Nicolas Capens <nicolascapens@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarBen Clayton <bclayton@google.com>
parent db868c77
......@@ -346,14 +346,14 @@ void SpirvShader::GetImageDimensions(EmitState const *state, Type const &resultT
const DescriptorDecorations &d = descriptorDecorations.at(imageId);
auto setLayout = routine->pipelineLayout->getDescriptorSetLayout(d.DescriptorSet);
auto &bindingLayout = setLayout->getBindingLayout(d.Binding);
auto descriptorType = setLayout->getDescriptorType(d.Binding);
Pointer<Byte> descriptor = state->getPointer(imageId).base;
Pointer<Int> extent;
Int arrayLayers;
switch(bindingLayout.descriptorType)
switch(descriptorType)
{
case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
......@@ -371,7 +371,7 @@ void SpirvShader::GetImageDimensions(EmitState const *state, Type const &resultT
break;
}
default:
UNREACHABLE("Image descriptorType: %d", int(bindingLayout.descriptorType));
UNREACHABLE("Image descriptorType: %d", int(descriptorType));
}
auto dimensions = resultTy.componentCount - (isArrayed ? 1 : 0);
......@@ -410,11 +410,11 @@ SpirvShader::EmitResult SpirvShader::EmitImageQueryLevels(InsnIterator insn, Emi
const DescriptorDecorations &d = descriptorDecorations.at(imageId);
auto setLayout = state->routine->pipelineLayout->getDescriptorSetLayout(d.DescriptorSet);
auto &bindingLayout = setLayout->getBindingLayout(d.Binding);
auto descriptorType = setLayout->getDescriptorType(d.Binding);
Pointer<Byte> descriptor = state->getPointer(imageId).base;
Int mipLevels = 0;
switch(bindingLayout.descriptorType)
switch(descriptorType)
{
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
......@@ -422,7 +422,7 @@ SpirvShader::EmitResult SpirvShader::EmitImageQueryLevels(InsnIterator insn, Emi
mipLevels = *Pointer<Int>(descriptor + OFFSET(vk::SampledImageDescriptor, mipLevels)); // uint32_t
break;
default:
UNREACHABLE("Image descriptorType: %d", int(bindingLayout.descriptorType));
UNREACHABLE("Image descriptorType: %d", int(descriptorType));
}
auto &dst = state->createIntermediate(insn.resultId(), 1);
......@@ -443,11 +443,11 @@ SpirvShader::EmitResult SpirvShader::EmitImageQuerySamples(InsnIterator insn, Em
const DescriptorDecorations &d = descriptorDecorations.at(imageId);
auto setLayout = state->routine->pipelineLayout->getDescriptorSetLayout(d.DescriptorSet);
auto &bindingLayout = setLayout->getBindingLayout(d.Binding);
auto descriptorType = setLayout->getDescriptorType(d.Binding);
Pointer<Byte> descriptor = state->getPointer(imageId).base;
Int sampleCount = 0;
switch(bindingLayout.descriptorType)
switch(descriptorType)
{
case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
sampleCount = *Pointer<Int>(descriptor + OFFSET(vk::StorageImageDescriptor, sampleCount)); // uint32_t
......@@ -458,7 +458,7 @@ SpirvShader::EmitResult SpirvShader::EmitImageQuerySamples(InsnIterator insn, Em
sampleCount = *Pointer<Int>(descriptor + OFFSET(vk::SampledImageDescriptor, sampleCount)); // uint32_t
break;
default:
UNREACHABLE("Image descriptorType: %d", int(bindingLayout.descriptorType));
UNREACHABLE("Image descriptorType: %d", int(descriptorType));
}
auto &dst = state->createIntermediate(insn.resultId(), 1);
......
......@@ -240,10 +240,10 @@ uint32_t DescriptorSetLayout::getDynamicDescriptorOffset(uint32_t binding) const
return index;
}
VkDescriptorSetLayoutBinding const &DescriptorSetLayout::getBindingLayout(uint32_t binding) const
VkDescriptorType DescriptorSetLayout::getDescriptorType(uint32_t binding) const
{
uint32_t index = getBindingIndex(binding);
return bindings[index];
return bindings[index].descriptorType;
}
uint8_t *DescriptorSetLayout::getOffsetPointer(DescriptorSet *descriptorSet, uint32_t binding, uint32_t arrayElement, uint32_t count, size_t *typeSize) const
......
......@@ -124,8 +124,8 @@ public:
// VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC
bool isBindingDynamic(uint32_t binding) const;
// Returns the VkDescriptorSetLayoutBinding for the given binding.
VkDescriptorSetLayoutBinding const &getBindingLayout(uint32_t binding) const;
// Returns the descriptor type for the given binding.
VkDescriptorType getDescriptorType(uint32_t binding) const;
uint8_t *getOffsetPointer(DescriptorSet *descriptorSet, uint32_t binding, uint32_t arrayElement, uint32_t count, size_t *typeSize) const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment