mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
Common: Add alignment header
Gets rid of duplicated alignment code.
This commit is contained in:
@ -5,8 +5,8 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#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<u32>(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
|
||||
|
@ -2,6 +2,7 @@
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "Common/Align.h"
|
||||
#include "Common/GL/GLUtil.h"
|
||||
#include "Common/MemoryUtil.h"
|
||||
|
||||
@ -261,11 +262,11 @@ public:
|
||||
PinnedMemory(u32 type, u32 size) : StreamBuffer(type, size)
|
||||
{
|
||||
CreateFences();
|
||||
m_pointer = static_cast<u8*>(
|
||||
Common::AllocateAlignedMemory(ROUND_UP(m_size, ALIGN_PINNED_MEMORY), ALIGN_PINNED_MEMORY));
|
||||
m_pointer = static_cast<u8*>(Common::AllocateAlignedMemory(
|
||||
Common::AlignUp(m_size, ALIGN_PINNED_MEMORY), ALIGN_PINNED_MEMORY));
|
||||
glBindBuffer(GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, m_buffer);
|
||||
glBufferData(GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, ROUND_UP(m_size, ALIGN_PINNED_MEMORY),
|
||||
m_pointer, GL_STREAM_COPY);
|
||||
glBufferData(GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD,
|
||||
Common::AlignUp(m_size, ALIGN_PINNED_MEMORY), m_pointer, GL_STREAM_COPY);
|
||||
glBindBuffer(GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, 0);
|
||||
glBindBuffer(m_buffertype, m_buffer);
|
||||
}
|
||||
|
Reference in New Issue
Block a user