Descriptor Pool alignment checks
Make sure all allocations within the pool are 16 bytes aligned
Bug b/137554711
Change-Id: I7e9531b720ae07390e0089768f92fd95c62d6afb
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/33250
Tested-by: Alexis Hétu <sugoi@google.com>
Presubmit-Ready: Alexis Hétu <sugoi@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Vulkan/VkDescriptorPool.cpp b/src/Vulkan/VkDescriptorPool.cpp
index e888018..79b46cc 100644
--- a/src/Vulkan/VkDescriptorPool.cpp
+++ b/src/Vulkan/VkDescriptorPool.cpp
@@ -51,12 +51,12 @@
size_t DescriptorPool::ComputeRequiredAllocationSize(const VkDescriptorPoolCreateInfo* pCreateInfo)
{
- size_t size = pCreateInfo->maxSets * sizeof(DescriptorSetHeader);
+ size_t size = pCreateInfo->maxSets * sw::align(sizeof(DescriptorSetHeader), 16);
for(uint32_t i = 0; i < pCreateInfo->poolSizeCount; i++)
{
size += pCreateInfo->pPoolSizes[i].descriptorCount *
- DescriptorSetLayout::GetDescriptorSize(pCreateInfo->pPoolSizes[i].type);
+ sw::align(DescriptorSetLayout::GetDescriptorSize(pCreateInfo->pPoolSizes[i].type), 16);
}
return size;
diff --git a/src/Vulkan/VkDescriptorSet.hpp b/src/Vulkan/VkDescriptorSet.hpp
index a733a5b..fc50148 100644
--- a/src/Vulkan/VkDescriptorSet.hpp
+++ b/src/Vulkan/VkDescriptorSet.hpp
@@ -29,7 +29,7 @@
DescriptorSetLayout* layout;
};
- class DescriptorSet
+ class alignas(16) DescriptorSet
{
public:
static inline DescriptorSet* Cast(VkDescriptorSet object)