diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2026-10-25 18:54:43 +0100 |
|---|---|---|
| committer | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2026-10-25 18:54:43 +0100 |
| commit | d66b32c0b9c2bd635924a3a219aba1d82a1faa0a (patch) | |
| tree | f3142ec581e3d2f8e081b3497770a02107940600 | |
| parent | f3b3eea40acd2a266e8a329ae7e7586fe0eae883 (diff) | |
save_stencil_if_required, emit draw cmd before pattern change, apple bug
| -rw-r--r-- | src/cross_os.h | 2 | ||||
| -rw-r--r-- | src/vkvg_context.c | 38 | ||||
| -rw-r--r-- | src/vkvg_context_internal.c | 6 |
3 files changed, 26 insertions, 20 deletions
diff --git a/src/cross_os.h b/src/cross_os.h index 8752870..c35dffc 100644 --- a/src/cross_os.h +++ b/src/cross_os.h @@ -77,7 +77,7 @@ __pragma(warning(disable : 4505)) // 1. Check if we are in a POSIX environment that supports strncasecmp #if defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200112L) #include <strings.h> /* Provides the native strncasecmp */ -#else +#elif !defined(__APPLE__) /* 2. Fallback: Implement our own C11-compliant version */ #include <ctype.h> diff --git a/src/vkvg_context.c b/src/vkvg_context.c index e1edfe3..368d255 100644 --- a/src/vkvg_context.c +++ b/src/vkvg_context.c @@ -296,6 +296,7 @@ void vkvg_set_opacity(VkvgContext ctx, float opacity) { return; _emit_draw_cmd_undrawn_vertices(ctx); + ctx->pushConsts.opacity = opacity; ctx->pushCstDirty = true; } @@ -728,12 +729,7 @@ vkvg_clip_state_t _get_previous_clip_state(VkvgContext ctx) { static const VkClearAttachment clearStencil = {VK_IMAGE_ASPECT_STENCIL_BIT, 1, {{{0}}}}; static const VkClearAttachment clearColorAttach = {VK_IMAGE_ASPECT_COLOR_BIT, 0, {{{0}}}}; -void _reset_clip(VkvgContext ctx) { - if (ctx->curClipRef == 0) - return; //nothing to do - - _emit_draw_cmd_undrawn_vertices(ctx); - +void _save_stencil_if_required (VkvgContext ctx) { if (ctx->ctxSaveCount > 0) { vkvg_context_save_t* sav = &ctx->pSavedCtxs[ctx->ctxSaveCount - 1]; if (sav->curClipRef > 0) { @@ -776,6 +772,14 @@ void _reset_clip(VkvgContext ctx) { _wait_and_submit_cmd(ctx); } } +} +void _reset_clip(VkvgContext ctx) { + if (ctx->curClipRef == 0) + return; //nothing to do + + _emit_draw_cmd_undrawn_vertices(ctx); + + _save_stencil_if_required(ctx); ctx->curClipRef = 0; @@ -812,20 +816,20 @@ void vkvg_clear(VkvgContext ctx) { RECORD(ctx, VKVG_CMD_CLEAR); - if (_get_previous_clip_state(ctx) == vkvg_clip_state_clear) - ctx->curClipState = vkvg_clip_state_none; - else - ctx->curClipState = vkvg_clip_state_clear; - _emit_draw_cmd_undrawn_vertices(ctx); + + _save_stencil_if_required(ctx); + ctx->curClipRef = 0; - if (!ctx->cmdStarted) { + + if (ctx->cmdStarted) { + VkClearAttachment ca[2] = {clearColorAttach, clearStencil}; + vkCmdClearAttachments(ctx->cmd, 2, ca, 1, &ctx->clearRect); + CmdSetStencilReference(ctx->cmd, VK_STENCIL_FRONT_AND_BACK, ctx->curClipRef); + } else { ctx->renderPassBeginInfo.renderPass = ctx->pSurf->surfClass->renderPass_ClearAll; _start_cmd_for_render_pass(ctx); - return; } - VkClearAttachment ca[2] = {clearColorAttach, clearStencil}; - vkCmdClearAttachments(ctx->cmd, 2, ca, 1, &ctx->clearRect); } void _clip_preserve(VkvgContext ctx) { _finish_path(ctx); @@ -880,7 +884,7 @@ void _fill_preserve(VkvgContext ctx) { if (ctx->vertCount - ctx->curVertOffset + ctx->pointCount > VKVG_IBO_MAX) _emit_draw_cmd_undrawn_vertices(ctx); // limit draw call to addressable vx with choosen index type - if (ctx->pattern) // if not solid color, source img or gradient has to be bound + if (ctx->pattern) _ensure_renderpass_is_started(ctx); _fill_non_zero(ctx); } @@ -1064,6 +1068,7 @@ void vkvg_paint(VkvgContext ctx) { } _ensure_renderpass_is_started(ctx); + _draw_full_screen_quad(ctx, NULL); } void vkvg_set_source_color(VkvgContext ctx, uint32_t c) { @@ -1078,7 +1083,6 @@ void vkvg_set_source_rgb(VkvgContext ctx, float r, float g, float b) { return; RECORD(ctx, VKVG_CMD_SET_SOURCE_RGB, r, g, b); ctx->curColor = CreateRgbaf(r, g, b, 1); - _emit_draw_cmd_undrawn_vertices(ctx); _update_cur_pattern(ctx, NULL); } void vkvg_set_source_rgba(VkvgContext ctx, float r, float g, float b, float a) { diff --git a/src/vkvg_context_internal.c b/src/vkvg_context_internal.c index bcbc609..aca970a 100644 --- a/src/vkvg_context_internal.c +++ b/src/vkvg_context_internal.c @@ -638,8 +638,8 @@ void _start_cmd_for_render_pass(VkvgContext ctx) { CmdBindDescriptorSets(ctx->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, ctx->dev->pipelineLayout, 0, 3, dss, 1, &offset); - VkDeviceSize offsets[1] = {0}; - CmdBindVertexBuffers(ctx->cmd, 0, 1, &ctx->vertices.buffer, offsets); + VkDeviceSize offsets = 0; + CmdBindVertexBuffers(ctx->cmd, 0, 1, &ctx->vertices.buffer, &offsets); CmdBindIndexBuffer(ctx->cmd, ctx->indices.buffer, 0, VKVG_VK_INDEX_TYPE); _update_push_constants(ctx); @@ -674,6 +674,8 @@ void _update_cur_pattern(VkvgContext ctx, VkvgPattern pat) { } else newPatternType = pat->type; + _emit_draw_cmd_undrawn_vertices(ctx); + if (lastPat) { if (ctx->cmdStarted) { switch (lastPat->type) { |