Use correct uniform buffer alignment instead of hardcoded 256

This commit is contained in:
baldurk
2015-10-28 23:13:12 +01:00
parent c54b17284c
commit 63e0cc3f39
4 changed files with 17 additions and 5 deletions
+3
View File
@@ -175,6 +175,7 @@ private:
uint32_t GPULocalMemIndex;
VkPhysicalDeviceFeatures features;
VkPhysicalDeviceProperties props;
VkPhysicalDeviceMemoryProperties memProps;
};
@@ -216,6 +217,8 @@ private:
const VkPhysicalDeviceFeatures &GetDeviceFeatures()
{ return m_PhysicalDeviceData.features; }
const VkPhysicalDeviceProperties &GetDeviceProps()
{ return m_PhysicalDeviceData.props; }
uint32_t GetReadbackMemoryIndex(uint32_t resourceRequiredBitmask);
uint32_t GetUploadMemoryIndex(uint32_t resourceRequiredBitmask);
+6 -4
View File
@@ -94,10 +94,12 @@ void VulkanDebugManager::GPUBuffer::Create(WrappedVulkan *driver, VkDevice dev,
m_ResourceManager = driver->GetResourceManager();
align = (VkDeviceSize)driver->GetDeviceProps().limits.minUniformBufferOffsetAlignment;
sz = size;
// offset must be 256-aligned, so ensure we have at least ringSize
// offset must be aligned, so ensure we have at least ringSize
// copies accounting for that
totalsize = ringSize == 1 ? size : AlignUp(size, (VkDeviceSize)256ULL)*ringSize;
totalsize = ringSize == 1 ? size : AlignUp(size, align)*ringSize;
curoffset = 0;
VkBufferCreateInfo bufInfo = {
@@ -175,8 +177,8 @@ void *VulkanDebugManager::GPUBuffer::Map(const VkLayerDispatchTable *vt, VkDevic
offset = 0;
RDCASSERT(offset + size <= totalsize);
// offset must be 256-aligned
curoffset = AlignUp(offset+size, (VkDeviceSize)256ULL);
// offset must be aligned
curoffset = AlignUp(offset+size, align);
if(bindoffset) *bindoffset = (uint32_t)offset;
+3
View File
@@ -71,6 +71,9 @@ class VulkanDebugManager
VkBuffer buf;
VkDeviceMemory mem;
// uniform buffer alignment requirement
VkDeviceSize align;
// for handling ring allocations
VkDeviceSize totalsize;
VkDeviceSize curoffset;
@@ -438,7 +438,9 @@ bool WrappedVulkan::Serialise_vkCreateDevice(
GetResourceManager()->WrapResource(Unwrap(device), m_InternalCmds.m_CmdPool);
}
ObjDisp(physicalDevice)->GetPhysicalDeviceProperties(Unwrap(physicalDevice), &m_PhysicalDeviceData.props);
ObjDisp(physicalDevice)->GetPhysicalDeviceMemoryProperties(Unwrap(physicalDevice), &m_PhysicalDeviceData.memProps);
ObjDisp(physicalDevice)->GetPhysicalDeviceFeatures(Unwrap(physicalDevice), &m_PhysicalDeviceData.features);
@@ -573,6 +575,8 @@ VkResult WrappedVulkan::vkCreateDevice(
GetResourceManager()->WrapResource(Unwrap(device), m_InternalCmds.m_CmdPool);
}
ObjDisp(physicalDevice)->GetPhysicalDeviceProperties(Unwrap(physicalDevice), &m_PhysicalDeviceData.props);
ObjDisp(physicalDevice)->GetPhysicalDeviceMemoryProperties(Unwrap(physicalDevice), &m_PhysicalDeviceData.memProps);
ObjDisp(physicalDevice)->GetPhysicalDeviceFeatures(Unwrap(physicalDevice), &m_PhysicalDeviceData.features);