Commit 61234552 by Alexis Hetu Committed by Alexis Hétu

Support for usage in memory requirements

Buffer usage was ignored in memory requirements. Usage support was added for the purpose of computing the proper required alignment. Fixes: dEQP-VK.memory.requirements.core.buffer.regular Bug b/118383648 Change-Id: Ib66e8d85f1b468765e24edba598fa06f4b5888c9 Reviewed-on: https://swiftshader-review.googlesource.com/c/23928 Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarChris Forbes <chrisforbes@google.com>
parent 1c658230
......@@ -43,7 +43,22 @@ size_t Buffer::ComputeRequiredAllocationSize(const VkBufferCreateInfo* pCreateIn
const VkMemoryRequirements Buffer::getMemoryRequirements() const
{
VkMemoryRequirements memoryRequirements = {};
memoryRequirements.alignment = vk::REQUIRED_MEMORY_ALIGNMENT;
if(usage & (VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT | VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT))
{
memoryRequirements.alignment = vk::MIN_TEXEL_BUFFER_OFFSET_ALIGNMENT;
}
else if(usage & VK_BUFFER_USAGE_STORAGE_BUFFER_BIT)
{
memoryRequirements.alignment = vk::MIN_STORAGE_BUFFER_OFFSET_ALIGNMENT;
}
else if(usage & VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT)
{
memoryRequirements.alignment = vk::MIN_UNIFORM_BUFFER_OFFSET_ALIGNMENT;
}
else
{
memoryRequirements.alignment = REQUIRED_MEMORY_ALIGNMENT;
}
memoryRequirements.memoryTypeBits = vk::MEMORY_TYPE_GENERIC_BIT;
memoryRequirements.size = size; // TODO: also reserve space for a header containing
// the size of the buffer (for robust buffer access)
......
......@@ -38,6 +38,9 @@ enum
enum
{
REQUIRED_MEMORY_ALIGNMENT = 8, // For 64 bit formats on ARM64
MIN_TEXEL_BUFFER_OFFSET_ALIGNMENT = 256,
MIN_UNIFORM_BUFFER_OFFSET_ALIGNMENT = 256,
MIN_STORAGE_BUFFER_OFFSET_ALIGNMENT = 256,
MEMORY_TYPE_GENERIC_BIT = 0x1, // Generic system memory.
};
......
......@@ -204,9 +204,9 @@ const VkPhysicalDeviceLimits& PhysicalDevice::getLimits() const
{ -8192, 8191 }, // viewportBoundsRange[2]
0, // viewportSubPixelBits
64, // minMemoryMapAlignment
256, // minTexelBufferOffsetAlignment
256, // minUniformBufferOffsetAlignment
256, // minStorageBufferOffsetAlignment
vk::MIN_TEXEL_BUFFER_OFFSET_ALIGNMENT, // minTexelBufferOffsetAlignment
vk::MIN_UNIFORM_BUFFER_OFFSET_ALIGNMENT, // minUniformBufferOffsetAlignment
vk::MIN_STORAGE_BUFFER_OFFSET_ALIGNMENT, // minStorageBufferOffsetAlignment
-8, // minTexelOffset
7, // maxTexelOffset
-8, // minTexelGatherOffset
......
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