Commit a94ca189 by Nicolas Capens Committed by Nicolas Capens

Fix update of immutable samplers

Use a common method for updating mutable and immutable sampler descriptors. Bug: b/129523279 Test: dEQP-VK.texture.filtering.2d.formats.r8g8b8a8_unorm.* Change-Id: I1ef82c8fe2cbb2e92f3dadce794346be525648b8 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/29848 Presubmit-Ready: Nicolas Capens <nicolascapens@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarChris Forbes <chrisforbes@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
parent 821feba5
...@@ -160,7 +160,7 @@ void DescriptorSetLayout::initialize(VkDescriptorSet vkDescriptorSet) ...@@ -160,7 +160,7 @@ void DescriptorSetLayout::initialize(VkDescriptorSet vkDescriptorSet)
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->sampler = vk::Cast(bindings[i].pImmutableSamplers[j]); imageSamplerDescriptor->updateSampler(vk::Cast(bindings[i].pImmutableSamplers[j]));
mem += typeSize; mem += typeSize;
} }
} }
...@@ -245,6 +245,14 @@ uint8_t* DescriptorSetLayout::getOffsetPointer(DescriptorSet *descriptorSet, uin ...@@ -245,6 +245,14 @@ uint8_t* DescriptorSetLayout::getOffsetPointer(DescriptorSet *descriptorSet, uin
return &descriptorSet->data[byteOffset]; return &descriptorSet->data[byteOffset];
} }
void SampledImageDescriptor::updateSampler(const vk::Sampler *sampler)
{
this->sampler = sampler;
texture.minLod = sw::clamp(sampler->minLod, 0.0f, (float)(sw::MAX_TEXTURE_LOD));
texture.maxLod = sw::clamp(sampler->maxLod, 0.0f, (float)(sw::MAX_TEXTURE_LOD));
}
void DescriptorSetLayout::WriteDescriptorSet(DescriptorSet *dstSet, VkDescriptorUpdateTemplateEntry const &entry, char const *src) void DescriptorSetLayout::WriteDescriptorSet(DescriptorSet *dstSet, VkDescriptorUpdateTemplateEntry const &entry, char const *src)
{ {
DescriptorSetLayout* dstLayout = dstSet->layout; DescriptorSetLayout* dstLayout = dstSet->layout;
...@@ -269,16 +277,9 @@ void DescriptorSetLayout::WriteDescriptorSet(DescriptorSet *dstSet, VkDescriptor ...@@ -269,16 +277,9 @@ void DescriptorSetLayout::WriteDescriptorSet(DescriptorSet *dstSet, VkDescriptor
// 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.pImmutableSamplers) if(!binding.pImmutableSamplers)
{ {
vk::Sampler *sampler = vk::Cast(update->sampler); imageSampler[i].updateSampler(vk::Cast(update->sampler));
imageSampler[i].sampler = sampler;
texture->minLod = sw::clamp(sampler->minLod, 0.0f, (float)(sw::MAX_TEXTURE_LOD));
texture->maxLod = sw::clamp(sampler->maxLod, 0.0f, (float)(sw::MAX_TEXTURE_LOD));
} }
memset(texture, 0, sizeof(sw::Texture)); // TODO(b/129523279): eliminate
imageSampler[i].imageView = imageView; imageSampler[i].imageView = imageView;
auto &subresourceRange = imageView->getSubresourceRange(); auto &subresourceRange = imageView->getSubresourceRange();
......
...@@ -29,9 +29,11 @@ class DescriptorSet; ...@@ -29,9 +29,11 @@ class DescriptorSet;
// TODO(b/129523279): Move to the Device or Pipeline layer. // TODO(b/129523279): Move to the Device or Pipeline layer.
struct SampledImageDescriptor struct SampledImageDescriptor
{ {
void updateSampler(const vk::Sampler *sampler);
// TODO(b/129523279): Minimize to the data actually needed. // TODO(b/129523279): Minimize to the data actually needed.
vk::Sampler *sampler; const vk::Sampler *sampler;
vk::ImageView *imageView; const vk::ImageView *imageView;
sw::Texture texture; sw::Texture texture;
}; };
......
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