Fixed problem with synchronization of uniform data updates.
This commit is contained in:
parent
bfb4b7607a
commit
4a1e77a3d0
1 changed files with 22 additions and 6 deletions
|
|
@ -283,6 +283,22 @@ public:
|
||||||
|
|
||||||
VK_CHECK_RESULT(vkBeginCommandBuffer(compute.commandBuffer, &cmdBufInfo));
|
VK_CHECK_RESULT(vkBeginCommandBuffer(compute.commandBuffer, &cmdBufInfo));
|
||||||
|
|
||||||
|
VkBufferMemoryBarrier bufferMemoryBarrier = {};
|
||||||
|
bufferMemoryBarrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER;
|
||||||
|
bufferMemoryBarrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT;
|
||||||
|
bufferMemoryBarrier.dstAccessMask = VK_ACCESS_UNIFORM_READ_BIT;
|
||||||
|
bufferMemoryBarrier.buffer = compute.uniformBuffer.buffer;
|
||||||
|
bufferMemoryBarrier.offset = 0;
|
||||||
|
bufferMemoryBarrier.size = VK_WHOLE_SIZE;
|
||||||
|
vkCmdPipelineBarrier(
|
||||||
|
compute.commandBuffer,
|
||||||
|
VK_PIPELINE_STAGE_HOST_BIT,
|
||||||
|
VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||||
|
VK_FLAGS_NONE,
|
||||||
|
0, nullptr,
|
||||||
|
1, &bufferMemoryBarrier,
|
||||||
|
0, nullptr );
|
||||||
|
|
||||||
vkCmdBindPipeline(compute.commandBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, compute.pipeline);
|
vkCmdBindPipeline(compute.commandBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, compute.pipeline);
|
||||||
vkCmdBindDescriptorSets(compute.commandBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, compute.pipelineLayout, 0, 1, &compute.descriptorSet, 0, 0);
|
vkCmdBindDescriptorSets(compute.commandBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, compute.pipelineLayout, 0, 1, &compute.descriptorSet, 0, 0);
|
||||||
|
|
||||||
|
|
@ -685,6 +701,12 @@ public:
|
||||||
|
|
||||||
void draw()
|
void draw()
|
||||||
{
|
{
|
||||||
|
VkSubmitInfo computeSubmitInfo = vks::initializers::submitInfo();
|
||||||
|
computeSubmitInfo.commandBufferCount = 1;
|
||||||
|
computeSubmitInfo.pCommandBuffers = &compute.commandBuffer;
|
||||||
|
|
||||||
|
VK_CHECK_RESULT( vkQueueSubmit( compute.queue, 1, &computeSubmitInfo, compute.fence ) );
|
||||||
|
|
||||||
VulkanExampleBase::prepareFrame();
|
VulkanExampleBase::prepareFrame();
|
||||||
|
|
||||||
// Command buffer to be sumitted to the queue
|
// Command buffer to be sumitted to the queue
|
||||||
|
|
@ -698,12 +720,6 @@ public:
|
||||||
// Use a fence to ensure that compute command buffer has finished executing before using it again
|
// Use a fence to ensure that compute command buffer has finished executing before using it again
|
||||||
vkWaitForFences(device, 1, &compute.fence, VK_TRUE, UINT64_MAX);
|
vkWaitForFences(device, 1, &compute.fence, VK_TRUE, UINT64_MAX);
|
||||||
vkResetFences(device, 1, &compute.fence);
|
vkResetFences(device, 1, &compute.fence);
|
||||||
|
|
||||||
VkSubmitInfo computeSubmitInfo = vks::initializers::submitInfo();
|
|
||||||
computeSubmitInfo.commandBufferCount = 1;
|
|
||||||
computeSubmitInfo.pCommandBuffers = &compute.commandBuffer;
|
|
||||||
|
|
||||||
VK_CHECK_RESULT(vkQueueSubmit(compute.queue, 1, &computeSubmitInfo, compute.fence));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void prepare()
|
void prepare()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue