- use the uniform buffer alignment as returned by the vulkan device
This commit is contained in:
parent
95116e8580
commit
e06f8f172d
4 changed files with 13 additions and 16 deletions
|
|
@ -479,16 +479,6 @@ void VkRenderState::ApplyPushConstants()
|
|||
mCommandBuffer->pushConstants(passManager->PipelineLayout.get(), VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, 0, (uint32_t)sizeof(PushConstants), &mPushConstants);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static void CopyToBuffer(uint32_t &offset, const T &data, VKDataBuffer *buffer)
|
||||
{
|
||||
if (offset + (UniformBufferAlignment<T>() << 1) < buffer->Size())
|
||||
{
|
||||
offset += UniformBufferAlignment<T>();
|
||||
memcpy(static_cast<uint8_t*>(buffer->Memory()) + offset, &data, sizeof(T));
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static void BufferedSet(bool &modified, T &dst, const T &src)
|
||||
{
|
||||
|
|
@ -533,7 +523,12 @@ void VkRenderState::ApplyMatrices()
|
|||
if (modified)
|
||||
{
|
||||
auto fb = GetVulkanFrameBuffer();
|
||||
CopyToBuffer(mMatricesOffset, mMatrices, fb->MatricesUBO);
|
||||
|
||||
if (mMatricesOffset + (fb->UniformBufferAlignedSize<MatricesUBO>() << 1) < fb->MatricesUBO->Size())
|
||||
{
|
||||
mMatricesOffset += fb->UniformBufferAlignedSize<MatricesUBO>();
|
||||
memcpy(static_cast<uint8_t*>(fb->MatricesUBO->Memory()) + mMatricesOffset, &mMatrices, sizeof(MatricesUBO));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue