diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2022-01-26 23:41:15 +0100 |
|---|---|---|
| committer | j-p <jp_bruyere@hotmail.com> | 2022-02-18 21:09:23 +0100 |
| commit | e83e05f4f3c04b441e4844e9db61cd9cc052af80 (patch) | |
| tree | 8b04783ca9c01271da4aff04412029e2c2df6468 /src | |
| parent | 16871cfa90506a3db4a70b5af67a50116362c7d5 (diff) | |
test with only guarded last fence wait and submit
Diffstat (limited to 'src')
| -rw-r--r-- | src/vkvg_context.c | 2 | ||||
| -rw-r--r-- | src/vkvg_context_internal.c | 9 | ||||
| -rw-r--r-- | src/vkvg_context_internal.h | 1 | ||||
| -rw-r--r-- | src/vkvg_device.c | 4 | ||||
| -rw-r--r-- | src/vkvg_device_internal.c | 44 | ||||
| -rw-r--r-- | src/vkvg_device_internal.h | 10 | ||||
| -rw-r--r-- | src/vkvg_fonts.c | 5 |
7 files changed, 55 insertions, 20 deletions
diff --git a/src/vkvg_context.c b/src/vkvg_context.c index 613cf9f..42fc2d3 100644 --- a/src/vkvg_context.c +++ b/src/vkvg_context.c @@ -301,8 +301,8 @@ void vkvg_destroy (VkvgContext ctx) } _clear_context (ctx); + _vkvg_device_destroy_fence (ctx->pSurf->dev, ctx->flushFence); - vkDestroyFence (ctx->dev->vkDev, ctx->flushFence,NULL); vkFreeCommandBuffers(dev, ctx->cmdPool, 2, ctx->cmdBuffers); vkDestroyCommandPool(dev, ctx->cmdPool, NULL); diff --git a/src/vkvg_context_internal.c b/src/vkvg_context_internal.c index 1676f75..c5880da 100644 --- a/src/vkvg_context_internal.c +++ b/src/vkvg_context_internal.c @@ -416,10 +416,6 @@ bool _wait_flush_fence (VkvgContext ctx) { ctx->status = VKVG_STATUS_TIMEOUT; return false; } -void _reset_flush_fence (VkvgContext ctx) { - LOG(VKVG_LOG_INFO, "CTX: _reset_flush_fence\n"); - ResetFences (ctx->dev->vkDev, 1, &ctx->flushFence); -} bool _wait_and_submit_cmd (VkvgContext ctx){ if (!ctx->cmdStarted)//current cmd buff is empty, be aware that wait is also canceled!! return true; @@ -428,9 +424,8 @@ bool _wait_and_submit_cmd (VkvgContext ctx){ if (!_wait_flush_fence (ctx)) return false; - _reset_flush_fence(ctx); - - _submit_cmd (ctx->dev, &ctx->cmd, ctx->flushFence); + _vkvg_device_reset_fence(ctx->pSurf->dev, ctx->flushFence); + _submit_cmd (ctx->pSurf->dev, &ctx->cmd, ctx->flushFence); if (ctx->cmd == ctx->cmdBuffers[0]) ctx->cmd = ctx->cmdBuffers[1]; diff --git a/src/vkvg_context_internal.h b/src/vkvg_context_internal.h index ff10bea..fd219a8 100644 --- a/src/vkvg_context_internal.h +++ b/src/vkvg_context_internal.h @@ -300,7 +300,6 @@ void _flush_cmd_buff (VkvgContext ctx); void _emit_draw_cmd_undrawn_vertices(VkvgContext ctx); void _flush_cmd_until_vx_base (VkvgContext ctx); bool _wait_flush_fence (VkvgContext ctx); -void _reset_flush_fence (VkvgContext ctx); bool _wait_and_submit_cmd (VkvgContext ctx); void _update_push_constants (VkvgContext ctx); void _update_cur_pattern (VkvgContext ctx, VkvgPattern pat); diff --git a/src/vkvg_device.c b/src/vkvg_device.c index bcb5946..a90ea8b 100644 --- a/src/vkvg_device.c +++ b/src/vkvg_device.c @@ -335,8 +335,8 @@ void vkvg_device_get_dpy (VkvgDevice dev, int* hdpy, int* vdpy) { *vdpy = dev->vdpi; } void vkvg_device_set_queue_guards (VkvgDevice dev, vkvg_queue_guard before_submit, vkvg_queue_guard after_submit, void* user_data) { - dev->gQBeforeSubmitGuard = before_submit; - dev->gQAfterSubmitGuard = after_submit; + dev->gQLockGuard = before_submit; + dev->gQUnlockGuard = after_submit; dev->gQGuardUserData = user_data; } #if VKVG_DBG_STATS diff --git a/src/vkvg_device_internal.c b/src/vkvg_device_internal.c index d66df4c..38f6e55 100644 --- a/src/vkvg_device_internal.c +++ b/src/vkvg_device_internal.c @@ -424,15 +424,49 @@ void _wait_idle (VkvgDevice dev) { } void _wait_and_reset_device_fence (VkvgDevice dev) { vkWaitForFences (dev->vkDev, 1, &dev->fence, VK_TRUE, UINT64_MAX); - vkResetFences (dev->vkDev, 1, &dev->fence); + _vkvg_device_reset_fence(dev, dev->fence); +} + +void _vkvg_device_destroy_fence (VkvgDevice dev, VkFence fence) { + if (dev->gQLockGuard) + dev->gQLockGuard (dev->gQGuardUserData); + + if (dev->gQLastFence == fence) + dev->gQLastFence = VK_NULL_HANDLE; + + vkDestroyFence (dev->vkDev, fence, NULL); + + if (dev->gQUnlockGuard) + dev->gQUnlockGuard (dev->gQGuardUserData); +} +void _vkvg_device_reset_fence (VkvgDevice dev, VkFence fence){ + if (dev->gQLockGuard) + dev->gQLockGuard (dev->gQGuardUserData); + + if (dev->gQLastFence == fence) + dev->gQLastFence = VK_NULL_HANDLE; + + ResetFences (dev->vkDev, 1, &fence); + + if (dev->gQUnlockGuard) + dev->gQUnlockGuard (dev->gQGuardUserData); +} +void _vkvg_device_wait_fence (VkvgDevice dev, VkFence fence){ + +} +void _vkvg_device_wait_and_reset_fence (VkvgDevice dev, VkFence fence){ + } void _submit_cmd (VkvgDevice dev, VkCommandBuffer* cmd, VkFence fence) { - if (dev->gQBeforeSubmitGuard) - dev->gQBeforeSubmitGuard (dev->gQGuardUserData); + if (dev->gQLockGuard) + dev->gQLockGuard (dev->gQGuardUserData); + if (dev->gQLastFence != VK_NULL_HANDLE) + WaitForFences (dev->vkDev, 1, &dev->gQLastFence, VK_TRUE, VKVG_FENCE_TIMEOUT); vkh_cmd_submit (dev->gQueue, cmd, fence); - if (dev->gQAfterSubmitGuard) - dev->gQAfterSubmitGuard (dev->gQGuardUserData); + dev->gQLastFence = fence; + if (dev->gQUnlockGuard) + dev->gQUnlockGuard (dev->gQGuardUserData); } bool _init_function_pointers (VkvgDevice dev) { diff --git a/src/vkvg_device_internal.h b/src/vkvg_device_internal.h index 931d582..c702e1c 100644 --- a/src/vkvg_device_internal.h +++ b/src/vkvg_device_internal.h @@ -65,10 +65,11 @@ typedef struct _vkvg_device_t{ VkFormat pngStagFormat; /**< Supported vulkan image format png write staging img */ VkImageTiling pngStagTiling; /**< tiling for the blit operation */ - vkvg_queue_guard gQBeforeSubmitGuard; - vkvg_queue_guard gQAfterSubmitGuard; + vkvg_queue_guard gQLockGuard; + vkvg_queue_guard gQUnlockGuard; void* gQGuardUserData; VkhQueue gQueue; /**< Vulkan Queue with Graphic flag */ + VkFence gQLastFence; VkRenderPass renderPass; /**< Vulkan render pass, common for all surfaces */ VkRenderPass renderPass_ClearStencil;/**< Vulkan render pass for first draw with context, stencil has to be cleared */ @@ -131,4 +132,9 @@ void _flush_all_contexes (VkvgDevice dev); void _wait_idle (VkvgDevice dev); void _wait_and_reset_device_fence (VkvgDevice dev); void _submit_cmd (VkvgDevice dev, VkCommandBuffer* cmd, VkFence fence); + +void _vkvg_device_destroy_fence (VkvgDevice dev, VkFence fence); +void _vkvg_device_reset_fence (VkvgDevice dev, VkFence fence); +void _vkvg_device_wait_fence (VkvgDevice dev, VkFence fence); +void _vkvg_device_wait_and_reset_fence (VkvgDevice dev, VkFence fence); #endif diff --git a/src/vkvg_fonts.c b/src/vkvg_fonts.c index 39e95bc..7d34bee 100644 --- a/src/vkvg_fonts.c +++ b/src/vkvg_fonts.c @@ -104,8 +104,9 @@ void _increase_font_tex_array (VkvgDevice dev){ _font_cache_t* cache = dev->fontCache; vkWaitForFences (dev->vkDev, 1, &cache->uploadFence, VK_TRUE, UINT64_MAX); + _vkvg_device_reset_fence (dev, cache->uploadFence); + vkResetCommandBuffer(cache->cmd, 0); - vkResetFences (dev->vkDev, 1, &cache->uploadFence); uint8_t newSize = cache->texLength + FONT_CACHE_INIT_LAYERS; VkhImage newImg = vkh_tex2d_array_create ((VkhDevice)dev, cache->texFormat, FONT_PAGE_SIZE, FONT_PAGE_SIZE, @@ -241,8 +242,8 @@ void _flush_chars_to_tex (VkvgDevice dev, _vkvg_font_t* f) { LOG(VKVG_LOG_INFO, "_flush_chars_to_tex pen(%d, %d)\n",f->curLine.penX, f->curLine.penY); vkWaitForFences (dev->vkDev,1,&cache->uploadFence,VK_TRUE,UINT64_MAX); + _vkvg_device_reset_fence (dev, cache->uploadFence); vkResetCommandBuffer(cache->cmd,0); - vkResetFences (dev->vkDev,1,&cache->uploadFence); memcpy(cache->buff.allocInfo.pMappedData, cache->hostBuff, (uint64_t)f->curLine.height * FONT_PAGE_SIZE * cache->texPixelSize); |