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 ...@@ -43,7 +43,22 @@ size_t Buffer::ComputeRequiredAllocationSize(const VkBufferCreateInfo* pCreateIn
const VkMemoryRequirements Buffer::getMemoryRequirements() const const VkMemoryRequirements Buffer::getMemoryRequirements() const
{ {
VkMemoryRequirements memoryRequirements = {}; 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.memoryTypeBits = vk::MEMORY_TYPE_GENERIC_BIT;
memoryRequirements.size = size; // TODO: also reserve space for a header containing memoryRequirements.size = size; // TODO: also reserve space for a header containing
// the size of the buffer (for robust buffer access) // the size of the buffer (for robust buffer access)
......
...@@ -38,6 +38,9 @@ enum ...@@ -38,6 +38,9 @@ enum
enum enum
{ {
REQUIRED_MEMORY_ALIGNMENT = 8, // For 64 bit formats on ARM64 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. MEMORY_TYPE_GENERIC_BIT = 0x1, // Generic system memory.
}; };
......
...@@ -204,9 +204,9 @@ const VkPhysicalDeviceLimits& PhysicalDevice::getLimits() const ...@@ -204,9 +204,9 @@ const VkPhysicalDeviceLimits& PhysicalDevice::getLimits() const
{ -8192, 8191 }, // viewportBoundsRange[2] { -8192, 8191 }, // viewportBoundsRange[2]
0, // viewportSubPixelBits 0, // viewportSubPixelBits
64, // minMemoryMapAlignment 64, // minMemoryMapAlignment
256, // minTexelBufferOffsetAlignment vk::MIN_TEXEL_BUFFER_OFFSET_ALIGNMENT, // minTexelBufferOffsetAlignment
256, // minUniformBufferOffsetAlignment vk::MIN_UNIFORM_BUFFER_OFFSET_ALIGNMENT, // minUniformBufferOffsetAlignment
256, // minStorageBufferOffsetAlignment vk::MIN_STORAGE_BUFFER_OFFSET_ALIGNMENT, // minStorageBufferOffsetAlignment
-8, // minTexelOffset -8, // minTexelOffset
7, // maxTexelOffset 7, // maxTexelOffset
-8, // minTexelGatherOffset -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