ctx->sizeIBO * sizeof(VKVG_IBO_INDEX_TYPE), &ctx->indices);
}
void _resize_vbo (VkvgContext ctx, uint32_t new_size) {
- if (!_wait_flush_fence (ctx))//wait previous cmd if not completed
+ if (!_wait_ctx_flush_end (ctx))//wait previous cmd if not completed
return;
LOG(VKVG_LOG_DBG_ARRAYS, "resize VBO: %d -> ", ctx->sizeVBO);
ctx->sizeVBO = new_size;
ctx->sizeVBO * sizeof(Vertex), &ctx->vertices);
}
void _resize_ibo (VkvgContext ctx, size_t new_size) {
- if (!_wait_flush_fence (ctx))//wait previous cmd if not completed
+ if (!_wait_ctx_flush_end (ctx))//wait previous cmd if not completed
return;
ctx->sizeIBO = new_size;
uint32_t mod = ctx->sizeIBO % VKVG_IBO_SIZE;
}
-bool _wait_flush_fence (VkvgContext ctx) {
+bool _wait_ctx_flush_end (VkvgContext ctx) {
LOG(VKVG_LOG_INFO, "CTX: _wait_flush_fence\n");
#ifdef VKVG_ENABLE_VK_TIMELINE_SEMAPHORE
if (vkh_timeline_wait ((VkhDevice)ctx->dev, ctx->pSurf->timeline, ctx->timelineStep) == VK_SUCCESS)
VkvgSurface surf = ctx->pSurf;
VkvgDevice dev = surf->dev;
//vkh_timeline_wait ((VkhDevice)dev, surf->timeline, ct->timelineStep);
- LOCK_SURFACE(surf)
- LOCK_DEVICE
- vkh_cmd_submit_timelined (dev->gQueue, &ctx->cmd, surf->timeline, surf->timelineStep, surf->timelineStep+1);
- surf->timelineStep++;
- ctx->timelineStep = surf->timelineStep;
- UNLOCK_DEVICE
- UNLOCK_SURFACE(surf)
+ if (ctx->pattern && ctx->pattern->type == VKVG_PATTERN_TYPE_SURFACE) {
+ //add source surface timeline sync.
+ VkvgSurface source = (VkvgSurface)ctx->pattern->data;
+ LOCK_SURFACE(surf)
+ LOCK_SURFACE(source)
+ LOCK_DEVICE
+ vkh_cmd_submit_timelined2 (dev->gQueue, &ctx->cmd,
+ (VkSemaphore[2]){surf->timeline,source->timeline},
+ (uint64_t[2]){surf->timelineStep,source->timelineStep},
+ (uint64_t[2]){surf->timelineStep+1,source->timelineStep+1});
+ surf->timelineStep++;
+ source->timelineStep++;
+ ctx->timelineStep = surf->timelineStep;
+ UNLOCK_DEVICE
+ UNLOCK_SURFACE(source)
+ UNLOCK_SURFACE(surf)
+ } else {
+ LOCK_SURFACE(surf)
+ LOCK_DEVICE
+ vkh_cmd_submit_timelined (dev->gQueue, &ctx->cmd, surf->timeline, surf->timelineStep, surf->timelineStep+1);
+ surf->timelineStep++;
+ ctx->timelineStep = surf->timelineStep;
+ UNLOCK_DEVICE
+ UNLOCK_SURFACE(surf)
+ }
#else
- if (!_wait_flush_fence (ctx))
+ if (!_wait_ctx_flush_end (ctx))
return false;
ResetFences (ctx->dev->vkDev, 1, &ctx->flushFence);
_device_submit_cmd (ctx->dev, &ctx->cmd, ctx->flushFence);
//pre flush vertices because of vbo or ibo too small, all vertices except last draw call are flushed
//this function expects a vertex offset > 0
void _flush_vertices_caches_until_vertex_base (VkvgContext ctx) {
- _wait_flush_fence (ctx);
+ _wait_ctx_flush_end (ctx);
memcpy(ctx->vertices.allocInfo.pMappedData, ctx->vertexCache, ctx->curVertOffset * sizeof (Vertex));
memcpy(ctx->indices.allocInfo.pMappedData, ctx->indexCache, ctx->curIndStart * sizeof (VKVG_IBO_INDEX_TYPE));
//copy vertex and index caches to the vbo and ibo vkbuffers used by gpu for drawing
//current running cmd has to be completed to free usage of those
void _flush_vertices_caches (VkvgContext ctx) {
- if (!_wait_flush_fence (ctx))
+ if (!_wait_ctx_flush_end (ctx))
return;
memcpy(ctx->vertices.allocInfo.pMappedData, ctx->vertexCache, ctx->vertCount * sizeof (Vertex));
switch (newPatternType) {
case VKVG_PATTERN_TYPE_SOLID:
_flush_cmd_buff (ctx);
- if (!_wait_flush_fence (ctx))
+ if (!_wait_ctx_flush_end (ctx))
return;
if (lastPat->type == VKVG_PATTERN_TYPE_SURFACE)//unbind current source surface by replacing it with empty texture
_update_descriptor_set (ctx, ctx->dev->emptyImg, ctx->dsSrc);
vkh_cmd_end (ctx->cmd);
_wait_and_submit_cmd (ctx);
- if (!_wait_flush_fence (ctx))
+ if (!_wait_ctx_flush_end (ctx))
return;
ctx->source = surf->img;
case VKVG_PATTERN_TYPE_LINEAR:
case VKVG_PATTERN_TYPE_RADIAL:
_flush_cmd_buff (ctx);
- if (!_wait_flush_fence (ctx))
+ if (!_wait_ctx_flush_end (ctx))
return;
if (lastPat && lastPat->type == VKVG_PATTERN_TYPE_SURFACE)
_flush_vertices_caches (ctx);
vkh_cmd_end (ctx->cmd);
_wait_and_submit_cmd (ctx);
- _wait_flush_fence (ctx);
+ _wait_ctx_flush_end (ctx);
if (ctx->sizeVBO - VKVG_ARRAY_THRESHOLD < ctx->pointCount){
_resize_vbo (ctx, ctx->pointCount + VKVG_ARRAY_THRESHOLD);
_resize_vertex_cache (ctx, ctx->sizeVBO);