Clean up storage image descriptor access
We already have the pointer available; no need to recompute it from the decorations.
This is groundwork for being able to index into arrays of storage image
descriptors correctly.
Bug: b/131082089
Change-Id: I574968b6ab8d205d5e4e3fcb4df5d08d2b88dcfa
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/29568
Tested-by: Chris Forbes <chrisforbes@google.com>
Presubmit-Ready: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Pipeline/SpirvShader.cpp b/src/Pipeline/SpirvShader.cpp
index 43af987..3d71c51 100644
--- a/src/Pipeline/SpirvShader.cpp
+++ b/src/Pipeline/SpirvShader.cpp
@@ -4394,13 +4394,10 @@
bool isCubeMap = imageType.definition.word(3) == spv::DimCube;
const DescriptorDecorations &d = descriptorDecorations.at(imageId);
- uint32_t arrayIndex = 0; // TODO(b/129523279)
auto setLayout = state->routine->pipelineLayout->getDescriptorSetLayout(d.DescriptorSet);
- size_t bindingOffset = setLayout->getBindingOffset(d.Binding, arrayIndex);
auto &bindingLayout = setLayout->getBindingLayout(d.Binding);
- Pointer<Byte> set = state->routine->descriptorSets[d.DescriptorSet]; // DescriptorSet*
- Pointer<Byte> binding = Pointer<Byte>(set + bindingOffset);
+ Pointer<Byte> binding = state->routine->getPointer(imageId).base;
auto &dst = state->routine->createIntermediate(resultId, resultType.sizeInComponents);
@@ -4470,15 +4467,9 @@
ASSERT(imageType.definition.opcode() == spv::OpTypeImage);
- const DescriptorDecorations &d = descriptorDecorations.at(imageId);
- uint32_t arrayIndex = 0; // TODO(b/129523279)
- auto setLayout = state->routine->pipelineLayout->getDescriptorSetLayout(d.DescriptorSet);
- size_t bindingOffset = setLayout->getBindingOffset(d.Binding, arrayIndex);
-
auto coordinate = GenericValue(this, state->routine, insn.word(4));
- Pointer<Byte> set = state->routine->descriptorSets[d.DescriptorSet]; // DescriptorSet*
- Pointer<Byte> binding = Pointer<Byte>(set + bindingOffset);
+ Pointer<Byte> binding = state->routine->getPointer(imageId).base;
Pointer<Byte> imageBase = *Pointer<Pointer<Byte>>(binding + OFFSET(vk::StorageImageDescriptor, ptr));
auto &dst = state->routine->createIntermediate(resultId, resultType.sizeInComponents);
@@ -4627,16 +4618,10 @@
// Not handling any image operands yet.
ASSERT(insn.wordCount() == 4);
- const DescriptorDecorations &d = descriptorDecorations.at(imageId);
- uint32_t arrayIndex = 0; // TODO(b/129523279)
- auto setLayout = state->routine->pipelineLayout->getDescriptorSetLayout(d.DescriptorSet);
- size_t bindingOffset = setLayout->getBindingOffset(d.Binding, arrayIndex);
-
auto coordinate = GenericValue(this, state->routine, insn.word(2));
auto texel = GenericValue(this, state->routine, insn.word(3));
- Pointer<Byte> set = state->routine->descriptorSets[d.DescriptorSet]; // DescriptorSet*
- Pointer<Byte> binding = Pointer<Byte>(set + bindingOffset); // StorageImageDescriptor*
+ Pointer<Byte> binding = state->routine->getPointer(imageId).base;
Pointer<Byte> imageBase = *Pointer<Pointer<Byte>>(binding + OFFSET(vk::StorageImageDescriptor, ptr));
SIMD::Int packed[4];
@@ -4740,15 +4725,9 @@
ASSERT(resultType.storageClass == spv::StorageClassImage);
ASSERT(getType(resultType.element).opcode() == spv::OpTypeInt);
- const DescriptorDecorations &d = descriptorDecorations.at(imageId);
- uint32_t arrayIndex = 0; // TODO(b/129523279)
- auto setLayout = state->routine->pipelineLayout->getDescriptorSetLayout(d.DescriptorSet);
- size_t bindingOffset = setLayout->getBindingOffset(d.Binding, arrayIndex);
-
auto coordinate = GenericValue(this, state->routine, insn.word(4));
- Pointer<Byte> set = state->routine->descriptorSets[d.DescriptorSet]; // DescriptorSet*
- Pointer<Byte> binding = Pointer<Byte>(set + bindingOffset);
+ Pointer<Byte> binding = state->routine->getPointer(imageId).base;
Pointer<Byte> imageBase = *Pointer<Pointer<Byte>>(binding + OFFSET(vk::StorageImageDescriptor, ptr));
SIMD::Int texelOffset = GetTexelOffset(coordinate, imageType, binding, sizeof(uint32_t));