- wait for space if the stream buffers are exhausted

This commit is contained in:
Magnus Norddahl 2019-06-16 13:05:12 +02:00
parent 240a32f4c8
commit d31dbf14e4
2 changed files with 19 additions and 5 deletions

View file

@ -327,6 +327,9 @@ void VkRenderState::ApplyStreamData()
{
mDataIndex = 0;
mStreamDataOffset += sizeof(StreamUBO);
if (mStreamDataOffset + sizeof(StreamUBO) >= fb->StreamUBO->Size())
WaitForStreamBuffers();
}
uint8_t *ptr = (uint8_t*)fb->StreamUBO->Memory();
memcpy(ptr + mStreamDataOffset + sizeof(StreamData) * mDataIndex, &mStreamData, sizeof(StreamData));
@ -420,11 +423,11 @@ void VkRenderState::ApplyMatrices()
{
auto fb = GetVulkanFrameBuffer();
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));
}
if (mMatricesOffset + (fb->UniformBufferAlignedSize<MatricesUBO>() << 1) >= fb->MatricesUBO->Size())
WaitForStreamBuffers();
mMatricesOffset += fb->UniformBufferAlignedSize<MatricesUBO>();
memcpy(static_cast<uint8_t*>(fb->MatricesUBO->Memory()) + mMatricesOffset, &mMatrices, sizeof(MatricesUBO));
}
}
@ -481,6 +484,16 @@ void VkRenderState::ApplyDynamicSet()
}
}
void VkRenderState::WaitForStreamBuffers()
{
EndRenderPass();
GetVulkanFrameBuffer()->WaitForCommands(false);
mApplyCount = 0;
mStreamDataOffset = 0;
mDataIndex = 0;
mMatricesOffset = 0;
}
void VkRenderState::Bind(int bindingpoint, uint32_t offset)
{
if (bindingpoint == VIEWPOINT_BINDINGPOINT)

View file

@ -63,6 +63,7 @@ protected:
void ApplyVertexBuffers();
void ApplyMaterial();
void WaitForStreamBuffers();
void BeginRenderPass(VulkanCommandBuffer *cmdbuffer);
bool mDepthClamp = true;