diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2026-10-25 21:07:08 +0100 |
|---|---|---|
| committer | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2026-10-25 21:07:08 +0100 |
| commit | 4c3777527cea4c360b0832a772d6796d81e64c90 (patch) | |
| tree | 17eb9bd704397463a4ca0fcaadfd3d20fbe0f771 | |
| parent | 325b693e0c437a6b0f30bf701f097f4d927f2c17 (diff) | |
_surface_pattern_update_sampler, flush on new pattern only if dyn grad buffer full
| -rw-r--r-- | src/vkvg_context_internal.c | 12 | ||||
| -rw-r--r-- | src/vkvg_pattern.c | 14 | ||||
| -rw-r--r-- | src/vkvg_pattern.h | 1 |
3 files changed, 22 insertions, 5 deletions
diff --git a/src/vkvg_context_internal.c b/src/vkvg_context_internal.c index 255eee6..f569cc2 100644 --- a/src/vkvg_context_internal.c +++ b/src/vkvg_context_internal.c @@ -446,6 +446,7 @@ bool _wait_and_submit_cmd(VkvgContext ctx) { ResetCommandBuffer(ctx->cmd, 0); ctx->cmdStarted = false; + ctx->pSurf->gradCount = 0; return true; } /*void _explicit_ms_resolve (VkvgContext ctx){//should init cmd before calling this (unused, using automatic resolve by @@ -579,7 +580,6 @@ void _flush_cmd_buff(VkvgContext ctx) { vkh_cmd_end(ctx->cmd); _wait_and_submit_cmd(ctx); - ctx->pSurf->gradCount = 0; } // bind correct draw pipeline depending on current OPERATOR @@ -734,6 +734,8 @@ void _update_cur_pattern(VkvgContext ctx, VkvgPattern pat) { // vkvg_matrix_transform_distance(&mat, &ctx->pushConsts.source.width, &ctx->pushConsts.source.height); vkvg_matrix_multiply(&ctx->pushConsts.matInv, &ctx->pushConsts.matInv, &mat); } + if (sp->samplerIsDirty) + _surface_pattern_update_sampler(sp); if (ctx->cmdStarted) CmdBindDescriptorSets(ctx->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, ctx->dev->pipelineLayout, @@ -742,9 +744,11 @@ void _update_cur_pattern(VkvgContext ctx, VkvgPattern pat) { } case VKVG_PATTERN_TYPE_LINEAR: case VKVG_PATTERN_TYPE_RADIAL: - _flush_cmd_buff(ctx); - if (!_wait_ctx_flush_end(ctx)) - return; + if (ctx->pSurf->gradCount >= MAX_GRAD) { + _flush_cmd_buff(ctx); + if (!_wait_ctx_flush_end(ctx)) + return; + } vec4 bounds = {{(float)ctx->pSurf->width}, {(float)ctx->pSurf->height}, diff --git a/src/vkvg_pattern.c b/src/vkvg_pattern.c index 07a72e6..c2b975b 100644 --- a/src/vkvg_pattern.c +++ b/src/vkvg_pattern.c @@ -27,7 +27,6 @@ void _update_descriptor (surface_pattern_t* pat) { }; vkUpdateDescriptorSets(pat->surf->dev->vkDev, 2, writeDescriptorSet, 0, NULL); } - void _surface_pattern_init (VkvgDevice dev, surface_pattern_t* pat) { const VkDescriptorPoolSize descriptorPoolSize[] = { {VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, 1}, @@ -91,6 +90,19 @@ void _create_sampler(surface_pattern_t* pat) { VK_CHECK_RESULT(vkCreateSampler(pat->surf->dev->vkDev, &samplerCreateInfo, NULL, &pat->sampler)); pat->samplerIsDirty = false; } +void _surface_pattern_update_sampler (surface_pattern_t* pat) { + _create_sampler(pat); + VkDescriptorImageInfo diiSampler = {pat->sampler}; + VkWriteDescriptorSet writeDescriptorSet = { + .sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, + .dstSet = pat->dsSource, + .dstBinding = 1, + .descriptorCount = 1, + .descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER, + .pImageInfo = &diiSampler + }; + vkUpdateDescriptorSets(pat->surf->dev->vkDev, 1, &writeDescriptorSet, 0, NULL); +} VkvgPattern vkvg_pattern_create_solid(float r, float g, float b, float a) { VkvgPattern pat = (vkvg_pattern_t*)calloc(1, sizeof(vkvg_pattern_t)); diff --git a/src/vkvg_pattern.h b/src/vkvg_pattern.h index 35e0f0b..d686b58 100644 --- a/src/vkvg_pattern.h +++ b/src/vkvg_pattern.h @@ -43,4 +43,5 @@ typedef struct _vkvg_gradient_pattern_t { vkvg_gradient_t gradient; } vkvg_gradient_pattern_t; +void _surface_pattern_update_sampler (surface_pattern_t* pat); #endif |