Reduce size of SampledImageDescriptor

We no longer need the full vk::Sampler information in SampledImageDescriptor, since we now only use the id, so it was replaced with a single uint32_t member called samplerId. Bug: b/129523279 Change-Id: I61808054fb5b1327c60e0f34894f9fbd42d36b33 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/54109 Presubmit-Ready: Alexis Hétu <sugoi@google.com> Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Commit-Queue: Alexis Hétu <sugoi@google.com>
parent e260190e
...@@ -157,8 +157,8 @@ void SpirvShader::EmitImageSampleUnconditional(Array<SIMD::Float> &out, ImageIns ...@@ -157,8 +157,8 @@ void SpirvShader::EmitImageSampleUnconditional(Array<SIMD::Float> &out, ImageIns
auto coordinate = Operand(this, state, coordinateId); auto coordinate = Operand(this, state, coordinateId);
rr::Int samplerId = *Pointer<rr::Int>(samplerDescriptor + OFFSET(vk::SampledImageDescriptor, sampler) + OFFSET(vk::Sampler, id)); // vk::Sampler::id rr::Int samplerId = *Pointer<rr::Int>(samplerDescriptor + OFFSET(vk::SampledImageDescriptor, samplerId)); // vk::Sampler::id
Pointer<Byte> texture = imageDescriptor + OFFSET(vk::SampledImageDescriptor, texture); // sw::Texture* Pointer<Byte> texture = imageDescriptor + OFFSET(vk::SampledImageDescriptor, texture); // sw::Texture*
// Above we assumed that if the SampledImage operand is not the result of an OpSampledImage, // Above we assumed that if the SampledImage operand is not the result of an OpSampledImage,
// it must be a combined image sampler loaded straight from the descriptor set. For OpImageFetch // it must be a combined image sampler loaded straight from the descriptor set. For OpImageFetch
......
...@@ -175,7 +175,7 @@ void DescriptorSetLayout::initialize(DescriptorSet *descriptorSet) ...@@ -175,7 +175,7 @@ void DescriptorSetLayout::initialize(DescriptorSet *descriptorSet)
for(uint32_t j = 0; j < bindings[i].descriptorCount; j++) for(uint32_t j = 0; j < bindings[i].descriptorCount; j++)
{ {
SampledImageDescriptor *imageSamplerDescriptor = reinterpret_cast<SampledImageDescriptor *>(mem); SampledImageDescriptor *imageSamplerDescriptor = reinterpret_cast<SampledImageDescriptor *>(mem);
imageSamplerDescriptor->updateSampler(bindings[i].immutableSamplers[j]); imageSamplerDescriptor->samplerId = bindings[i].immutableSamplers[j]->id;
mem += descriptorSize; mem += descriptorSize;
} }
} }
...@@ -245,11 +245,6 @@ uint8_t *DescriptorSetLayout::getDescriptorPointer(DescriptorSet *descriptorSet, ...@@ -245,11 +245,6 @@ uint8_t *DescriptorSetLayout::getDescriptorPointer(DescriptorSet *descriptorSet,
return &descriptorSet->data[byteOffset]; return &descriptorSet->data[byteOffset];
} }
void SampledImageDescriptor::updateSampler(const vk::Sampler *newSampler)
{
memcpy(reinterpret_cast<void *>(&sampler), newSampler, sizeof(sampler));
}
void DescriptorSetLayout::WriteDescriptorSet(Device *device, DescriptorSet *dstSet, VkDescriptorUpdateTemplateEntry const &entry, char const *src) void DescriptorSetLayout::WriteDescriptorSet(Device *device, DescriptorSet *dstSet, VkDescriptorUpdateTemplateEntry const &entry, char const *src)
{ {
DescriptorSetLayout *dstLayout = dstSet->header.layout; DescriptorSetLayout *dstLayout = dstSet->header.layout;
...@@ -273,7 +268,7 @@ void DescriptorSetLayout::WriteDescriptorSet(Device *device, DescriptorSet *dstS ...@@ -273,7 +268,7 @@ void DescriptorSetLayout::WriteDescriptorSet(Device *device, DescriptorSet *dstS
// descriptorCount of zero, must all either use immutable samplers or must all not use immutable samplers." // descriptorCount of zero, must all either use immutable samplers or must all not use immutable samplers."
if(!binding.immutableSamplers) if(!binding.immutableSamplers)
{ {
sampledImage[i].updateSampler(vk::Cast(update->sampler)); sampledImage[i].samplerId = vk::Cast(update->sampler)->id;
} }
sampledImage[i].device = device; sampledImage[i].device = device;
} }
...@@ -332,7 +327,7 @@ void DescriptorSetLayout::WriteDescriptorSet(Device *device, DescriptorSet *dstS ...@@ -332,7 +327,7 @@ void DescriptorSetLayout::WriteDescriptorSet(Device *device, DescriptorSet *dstS
// descriptorCount of zero, must all either use immutable samplers or must all not use immutable samplers." // descriptorCount of zero, must all either use immutable samplers or must all not use immutable samplers."
if(!binding.immutableSamplers) if(!binding.immutableSamplers)
{ {
sampledImage[i].updateSampler(vk::Cast(update->sampler)); sampledImage[i].samplerId = vk::Cast(update->sampler)->id;
} }
} }
......
...@@ -33,13 +33,9 @@ struct alignas(16) SampledImageDescriptor ...@@ -33,13 +33,9 @@ struct alignas(16) SampledImageDescriptor
{ {
~SampledImageDescriptor() = delete; ~SampledImageDescriptor() = delete;
void updateSampler(const vk::Sampler *sampler); uint32_t samplerId;
// TODO(b/129523279): Minimize to the data actually needed.
vk::Sampler sampler;
vk::Device *device;
uint32_t imageViewId; uint32_t imageViewId;
alignas(16) sw::Texture texture; alignas(16) sw::Texture texture;
int width; // Of base mip-level. int width; // Of base mip-level.
int height; int height;
...@@ -47,6 +43,7 @@ struct alignas(16) SampledImageDescriptor ...@@ -47,6 +43,7 @@ struct alignas(16) SampledImageDescriptor
int mipLevels; int mipLevels;
int sampleCount; int sampleCount;
Device *device;
ImageView *memoryOwner; // Pointer to the view which owns the memory used by the descriptor set ImageView *memoryOwner; // Pointer to the view which owns the memory used by the descriptor set
}; };
......
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