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. --- .../Core/VideoBackends/OGL/ProgramShaderCache.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp') diff --git a/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp b/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp index 66952ed976..44bf063a8a 100644 --- a/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp +++ b/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp @@ -5,8 +5,8 @@ #include #include +#include "Common/Align.h" #include "Common/Common.h" -#include "Common/MathUtil.h" #include "Common/StringUtil.h" #include "Core/ConfigManager.h" @@ -148,22 +148,22 @@ void ProgramShaderCache::UploadConstants() memcpy(buffer.first, &PixelShaderManager::constants, sizeof(PixelShaderConstants)); - memcpy(buffer.first + ROUND_UP(sizeof(PixelShaderConstants), s_ubo_align), + memcpy(buffer.first + Common::AlignUp(sizeof(PixelShaderConstants), s_ubo_align), &VertexShaderManager::constants, sizeof(VertexShaderConstants)); - memcpy(buffer.first + ROUND_UP(sizeof(PixelShaderConstants), s_ubo_align) + - ROUND_UP(sizeof(VertexShaderConstants), s_ubo_align), + memcpy(buffer.first + Common::AlignUp(sizeof(PixelShaderConstants), s_ubo_align) + + Common::AlignUp(sizeof(VertexShaderConstants), s_ubo_align), &GeometryShaderManager::constants, sizeof(GeometryShaderConstants)); s_buffer->Unmap(s_ubo_buffer_size); glBindBufferRange(GL_UNIFORM_BUFFER, 1, s_buffer->m_buffer, buffer.second, sizeof(PixelShaderConstants)); glBindBufferRange(GL_UNIFORM_BUFFER, 2, s_buffer->m_buffer, - buffer.second + ROUND_UP(sizeof(PixelShaderConstants), s_ubo_align), + buffer.second + Common::AlignUp(sizeof(PixelShaderConstants), s_ubo_align), sizeof(VertexShaderConstants)); glBindBufferRange(GL_UNIFORM_BUFFER, 3, s_buffer->m_buffer, - buffer.second + ROUND_UP(sizeof(PixelShaderConstants), s_ubo_align) + - ROUND_UP(sizeof(VertexShaderConstants), s_ubo_align), + buffer.second + Common::AlignUp(sizeof(PixelShaderConstants), s_ubo_align) + + Common::AlignUp(sizeof(VertexShaderConstants), s_ubo_align), sizeof(GeometryShaderConstants)); PixelShaderManager::dirty = false; @@ -407,9 +407,10 @@ void ProgramShaderCache::Init() // then the UBO will fail. glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &s_ubo_align); - s_ubo_buffer_size = ROUND_UP(sizeof(PixelShaderConstants), s_ubo_align) + - ROUND_UP(sizeof(VertexShaderConstants), s_ubo_align) + - ROUND_UP(sizeof(GeometryShaderConstants), s_ubo_align); + s_ubo_buffer_size = + static_cast(Common::AlignUp(sizeof(PixelShaderConstants), s_ubo_align) + + Common::AlignUp(sizeof(VertexShaderConstants), s_ubo_align) + + Common::AlignUp(sizeof(GeometryShaderConstants), s_ubo_align)); // We multiply by *4*4 because we need to get down to basic machine units. // So multiply by four to get how many floats we have from vec4s -- cgit v1.2.3