Commit 3e6a9717 by Chris Forbes

Set up uniform texel buffers as SampledImageDescriptor

Bug: b/132336537 Test: dEQP-VK.binding_model.* Change-Id: I75014c0db6a331bdcf8a4ec3ded4c1e8225dccb8 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/30930Tested-by: 's avatarChris Forbes <chrisforbes@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 3e6f60b3
......@@ -35,6 +35,7 @@ public:
void *getPointer() const;
uint32_t getElementCount() const { return range / Format(format).bytes(); }
uint32_t getRangeInBytes() const { return range; }
VkFormat getFormat() const { return format; }
private:
VkBuffer buffer;
......
......@@ -299,7 +299,36 @@ void DescriptorSetLayout::WriteDescriptorSet(DescriptorSet *dstSet, VkDescriptor
}
else if (entry.descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER)
{
UNIMPLEMENTED("VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER");
SampledImageDescriptor *imageSampler = reinterpret_cast<SampledImageDescriptor*>(memToWrite);
for (uint32_t i = 0; i < entry.descriptorCount; i++)
{
auto update = reinterpret_cast<VkBufferView const *>(src + entry.offset + entry.stride * i);
auto bufferView = Cast(*update);
imageSampler[i].type = VK_IMAGE_VIEW_TYPE_1D;
imageSampler[i].imageViewId = 1; // FIXME: BufferViews need IDs in the same space as ImageViews
imageSampler[i].swizzle = { VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_A };
imageSampler[i].format = bufferView->getFormat();
auto numElements = bufferView->getElementCount();
imageSampler[i].extent = { numElements, 1, 1 };
imageSampler[i].arrayLayers = 1;
imageSampler[i].texture.widthWidthHeightHeight = sw::vector(numElements, numElements, 1, 1);
imageSampler[i].texture.width = sw::replicate(numElements);
imageSampler[i].texture.height = sw::replicate(1);
imageSampler[i].texture.depth = sw::replicate(1);
sw::Mipmap &mipmap = imageSampler[i].texture.mipmap[0];
mipmap.buffer[0] = bufferView->getPointer();
mipmap.width[0] = mipmap.width[1] = mipmap.width[2] = mipmap.width[3] = static_cast<short>(numElements);
mipmap.height[0] = mipmap.height[1] = mipmap.height[2] = mipmap.height[3] = 1;
mipmap.depth[0] = mipmap.depth[1] = mipmap.depth[2] = mipmap.depth[3] = 1;
mipmap.pitchP.x = mipmap.pitchP.y = mipmap.pitchP.z = mipmap.pitchP.w = numElements;
mipmap.sliceP.x = mipmap.sliceP.y = mipmap.sliceP.z = mipmap.sliceP.w = 0;
mipmap.onePitchP[0] = mipmap.onePitchP[2] = 1;
mipmap.onePitchP[1] = mipmap.onePitchP[3] = static_cast<short>(numElements);
}
}
else if (entry.descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER ||
entry.descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE)
......
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