From 31ccfffd386cdf7bfafdccda240a179431ecc98c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Sun, 27 Nov 2016 11:56:22 +0100 Subject: Common: Add alignment header Gets rid of duplicated alignment code. --- Source/Core/VideoBackends/Vulkan/StateTracker.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'Source/Core/VideoBackends/Vulkan/StateTracker.cpp') diff --git a/Source/Core/VideoBackends/Vulkan/StateTracker.cpp b/Source/Core/VideoBackends/Vulkan/StateTracker.cpp index 34ea98f41b..e9bbb980b0 100644 --- a/Source/Core/VideoBackends/Vulkan/StateTracker.cpp +++ b/Source/Core/VideoBackends/Vulkan/StateTracker.cpp @@ -6,6 +6,7 @@ #include +#include "Common/Align.h" #include "Common/Assert.h" #include "VideoBackends/Vulkan/CommandBufferManager.h" @@ -101,11 +102,11 @@ bool StateTracker::Initialize() // To work around this we reserve the maximum buffer size at all times, but only commit // as many bytes as we use. m_uniform_buffer_reserve_size = sizeof(PixelShaderConstants); - m_uniform_buffer_reserve_size = Util::AlignValue(m_uniform_buffer_reserve_size, - g_vulkan_context->GetUniformBufferAlignment()) + + m_uniform_buffer_reserve_size = Common::AlignUp(m_uniform_buffer_reserve_size, + g_vulkan_context->GetUniformBufferAlignment()) + sizeof(VertexShaderConstants); - m_uniform_buffer_reserve_size = Util::AlignValue(m_uniform_buffer_reserve_size, - g_vulkan_context->GetUniformBufferAlignment()) + + m_uniform_buffer_reserve_size = Common::AlignUp(m_uniform_buffer_reserve_size, + g_vulkan_context->GetUniformBufferAlignment()) + sizeof(GeometryShaderConstants); // Default dirty flags include all descriptors @@ -461,9 +462,9 @@ void StateTracker::UploadAllConstants() size_t ub_alignment = g_vulkan_context->GetUniformBufferAlignment(); size_t pixel_constants_offset = 0; size_t vertex_constants_offset = - Util::AlignValue(pixel_constants_offset + sizeof(PixelShaderConstants), ub_alignment); + Common::AlignUp(pixel_constants_offset + sizeof(PixelShaderConstants), ub_alignment); size_t geometry_constants_offset = - Util::AlignValue(vertex_constants_offset + sizeof(VertexShaderConstants), ub_alignment); + Common::AlignUp(vertex_constants_offset + sizeof(VertexShaderConstants), ub_alignment); size_t allocation_size = geometry_constants_offset + sizeof(GeometryShaderConstants); // Allocate everything at once. -- cgit v1.2.3