if (dev->cachedContextCount) {
VkvgContext ctx = dev->cachedContext[--dev->cachedContextCount];
ctx->pSurf = surf;
+
+ if (!surf || surf->status) {
+ ctx->status = VKVG_STATUS_INVALID_SURFACE;
+ return ctx;
+ }
+
_init_ctx (ctx);
_update_descriptor_set (ctx, surf->dev->emptyImg, ctx->dsSrc);
_clear_path (ctx);
dev->status = VKVG_STATUS_NO_MEMORY;
return NULL;
}
+
+ ctx->pSurf = surf;
+
if (!surf || surf->status) {
ctx->status = VKVG_STATUS_INVALID_SURFACE;
return ctx;
ctx->sizePathes = VKVG_PATHES_SIZE;
ctx->renderPassBeginInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
- ctx->pSurf = surf;
ctx->dev = surf->dev;
_init_ctx (ctx);
#endif
- if (ctx->dev->cachedContextCount < VKVG_MAX_CACHED_CONTEXT_COUNT) {
+ if (!ctx->status && ctx->dev->cachedContextCount < VKVG_MAX_CACHED_CONTEXT_COUNT) {
ctx->dev->cachedContext[ctx->dev->cachedContextCount++] = ctx;
_clear_context (ctx);
ctx->references++;