Use single timeline semaphore for compress

This commit is contained in:
mittorn 2024-11-11 21:03:37 +03:00
parent bc6080f4e0
commit 75894cc9ed

View file

@ -119,6 +119,7 @@ struct ComputeApplication {
ComputeApplicationPipeline computePipeline;
TextureCompressionPipeline compressPipeline;
VulkanBuffer compressionConstantBuffer;
VkSemaphore compressSemaphore;
struct UBO{
float frameNum;
@ -133,7 +134,7 @@ struct ComputeApplication {
VkCommandBuffer compressCommandBuffer;
VkFence decomposeFence;
//VkFence compressFence;
VkSemaphore compressSemaphore;
bool running = false;
uint8_t *pReconstructionData;
@ -252,7 +253,6 @@ struct ComputeApplication {
vkCmdDispatch(chain[chidx].compressCommandBuffer, (uint32_t)ceil(WIDTH/2 / float(WORKGROUP_SIZE)), (uint32_t)ceil(HEIGHT/2 / float(WORKGROUP_SIZE)), 1);
VK_CHECK_RESULT(vkEndCommandBuffer(chain[chidx].compressCommandBuffer)); // end recording commands.
//VK_CHECK_RESULT(vkCreateFence(dev.device, &fenceCreateInfo, NULL, &chain[chidx].compressFence));
CallWith($Sc(VkSemaphoreCreateInfo{VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO}, $M(VkSemaphoreTypeCreateInfoKHR{VK_STRUCTURE_TYPE_SEMAPHORE_TYPE_CREATE_INFO_KHR},$(semaphoreType) = VK_SEMAPHORE_TYPE_TIMELINE_KHR)), vkCreateSemaphore(dev.device, &ref, NULL, &chain[chidx].compressSemaphore));
}
void waitFence(int chidx)
{
@ -271,7 +271,7 @@ struct ComputeApplication {
//$M(VkTimelineSemaphoreSubmitInfoKHR{VK_STRUCTURE_TYPE_TIMELINE_SEMAPHORE_SUBMIT_INFO_KHR}, $(signalSemaphoreValueCount), $(pSignalSemaphoreValues) &= (uint64_t)frameNum);
CallWith($Sc(
SubmitInfo(chain[chidx].compressCommandBuffer, $(signalSemaphoreCount),
$(pSignalSemaphores) = &chain[chidx].compressSemaphore),
$(pSignalSemaphores) = &compressSemaphore),
$M(VkTimelineSemaphoreSubmitInfoKHR{VK_STRUCTURE_TYPE_TIMELINE_SEMAPHORE_SUBMIT_INFO_KHR}, $(signalSemaphoreValueCount),
$(pSignalSemaphoreValues) &= (uint64_t)frameNum)
)
@ -290,7 +290,7 @@ struct ComputeApplication {
{
int chidx = frameNum & 3;
//VK_CHECK_RESULT(vkWaitForFences(dev.device, 1, &chain[chidx].compressFence, VK_TRUE, 100000000000));
CallWith($M(VkSemaphoreWaitInfoKHR{VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO_KHR}, $(pSemaphores) = &chain[chidx].compressSemaphore, $(semaphoreCount), $(pValues) &= (uint64_t)frameNum ),
CallWith($M(VkSemaphoreWaitInfoKHR{VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO_KHR}, $(pSemaphores) = &compressSemaphore, $(semaphoreCount), $(pValues) &= (uint64_t)frameNum ),
pvkWaitSemaphoresKHR(dev.device,&ref, 100000000000));
#if 1
@ -409,6 +409,7 @@ struct ComputeApplication {
dev.FlushCommandBuffer(b, dev.defaultQueue);
enc.Setup(drm_fd, WIDTH/2, HEIGHT/2, filename, fd, &mod, &size, &offset, &pitch1, &pitch2, modifiers, count, p010);
CallWith($Sc(VkSemaphoreCreateInfo{VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO}, $M(VkSemaphoreTypeCreateInfoKHR{VK_STRUCTURE_TYPE_SEMAPHORE_TYPE_CREATE_INFO_KHR},$(semaphoreType) = VK_SEMAPHORE_TYPE_TIMELINE_KHR)), vkCreateSemaphore(dev.device, &ref, NULL, &compressSemaphore));
for(int i = 0; i < CHAIN_SIZE; i++)
{
dev.CreateAndMap(chain[i].uboBuf, sizeof(UBO));