Commit 621a7bd0 by Chris Forbes

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/+/29568Tested-by: 's avatarChris Forbes <chrisforbes@google.com> Presubmit-Ready: Chris Forbes <chrisforbes@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 652edcc3
...@@ -4394,13 +4394,10 @@ namespace sw ...@@ -4394,13 +4394,10 @@ namespace sw
bool isCubeMap = imageType.definition.word(3) == spv::DimCube; bool isCubeMap = imageType.definition.word(3) == spv::DimCube;
const DescriptorDecorations &d = descriptorDecorations.at(imageId); const DescriptorDecorations &d = descriptorDecorations.at(imageId);
uint32_t arrayIndex = 0; // TODO(b/129523279)
auto setLayout = state->routine->pipelineLayout->getDescriptorSetLayout(d.DescriptorSet); auto setLayout = state->routine->pipelineLayout->getDescriptorSetLayout(d.DescriptorSet);
size_t bindingOffset = setLayout->getBindingOffset(d.Binding, arrayIndex);
auto &bindingLayout = setLayout->getBindingLayout(d.Binding); auto &bindingLayout = setLayout->getBindingLayout(d.Binding);
Pointer<Byte> set = state->routine->descriptorSets[d.DescriptorSet]; // DescriptorSet* Pointer<Byte> binding = state->routine->getPointer(imageId).base;
Pointer<Byte> binding = Pointer<Byte>(set + bindingOffset);
auto &dst = state->routine->createIntermediate(resultId, resultType.sizeInComponents); auto &dst = state->routine->createIntermediate(resultId, resultType.sizeInComponents);
...@@ -4470,15 +4467,9 @@ namespace sw ...@@ -4470,15 +4467,9 @@ namespace sw
ASSERT(imageType.definition.opcode() == spv::OpTypeImage); 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)); auto coordinate = GenericValue(this, state->routine, insn.word(4));
Pointer<Byte> set = state->routine->descriptorSets[d.DescriptorSet]; // DescriptorSet* Pointer<Byte> binding = state->routine->getPointer(imageId).base;
Pointer<Byte> binding = Pointer<Byte>(set + bindingOffset);
Pointer<Byte> imageBase = *Pointer<Pointer<Byte>>(binding + OFFSET(vk::StorageImageDescriptor, ptr)); Pointer<Byte> imageBase = *Pointer<Pointer<Byte>>(binding + OFFSET(vk::StorageImageDescriptor, ptr));
auto &dst = state->routine->createIntermediate(resultId, resultType.sizeInComponents); auto &dst = state->routine->createIntermediate(resultId, resultType.sizeInComponents);
...@@ -4627,16 +4618,10 @@ namespace sw ...@@ -4627,16 +4618,10 @@ namespace sw
// Not handling any image operands yet. // Not handling any image operands yet.
ASSERT(insn.wordCount() == 4); 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 coordinate = GenericValue(this, state->routine, insn.word(2));
auto texel = GenericValue(this, state->routine, insn.word(3)); auto texel = GenericValue(this, state->routine, insn.word(3));
Pointer<Byte> set = state->routine->descriptorSets[d.DescriptorSet]; // DescriptorSet* Pointer<Byte> binding = state->routine->getPointer(imageId).base;
Pointer<Byte> binding = Pointer<Byte>(set + bindingOffset); // StorageImageDescriptor*
Pointer<Byte> imageBase = *Pointer<Pointer<Byte>>(binding + OFFSET(vk::StorageImageDescriptor, ptr)); Pointer<Byte> imageBase = *Pointer<Pointer<Byte>>(binding + OFFSET(vk::StorageImageDescriptor, ptr));
SIMD::Int packed[4]; SIMD::Int packed[4];
...@@ -4740,15 +4725,9 @@ namespace sw ...@@ -4740,15 +4725,9 @@ namespace sw
ASSERT(resultType.storageClass == spv::StorageClassImage); ASSERT(resultType.storageClass == spv::StorageClassImage);
ASSERT(getType(resultType.element).opcode() == spv::OpTypeInt); 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)); auto coordinate = GenericValue(this, state->routine, insn.word(4));
Pointer<Byte> set = state->routine->descriptorSets[d.DescriptorSet]; // DescriptorSet* Pointer<Byte> binding = state->routine->getPointer(imageId).base;
Pointer<Byte> binding = Pointer<Byte>(set + bindingOffset);
Pointer<Byte> imageBase = *Pointer<Pointer<Byte>>(binding + OFFSET(vk::StorageImageDescriptor, ptr)); Pointer<Byte> imageBase = *Pointer<Pointer<Byte>>(binding + OFFSET(vk::StorageImageDescriptor, ptr));
SIMD::Int texelOffset = GetTexelOffset(coordinate, imageType, binding, sizeof(uint32_t)); SIMD::Int texelOffset = GetTexelOffset(coordinate, imageType, binding, sizeof(uint32_t));
......
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