diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2026-10-23 13:56:46 +0200 |
|---|---|---|
| committer | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2026-10-23 15:06:26 +0200 |
| commit | 15fd8e20f23c3fea2c41fa5def986454631c9d9c (patch) | |
| tree | 85d446ee7813a4f41665974faf10f03427688951 | |
| parent | c92b15f3cafb24ae55404b27d67031f0031f1740 (diff) | |
debug imported dev
| -rw-r--r-- | src/vkvg_context.c | 2 | ||||
| -rw-r--r-- | src/vkvg_context_internal.c | 19 | ||||
| -rw-r--r-- | src/vkvg_device.c | 16 | ||||
| -rw-r--r-- | src/vkvg_device_internal.c | 2 | ||||
| -rw-r--r-- | src/vkvg_device_internal.h | 20 | ||||
| -rw-r--r-- | src/vkvg_surface_internal.c | 6 | ||||
| -rw-r--r-- | src/vkvg_surface_internal.h | 3 | ||||
| -rw-r--r-- | tests/fill.c | 2 | ||||
| m--------- | vkh | 0 |
9 files changed, 40 insertions, 30 deletions
diff --git a/src/vkvg_context.c b/src/vkvg_context.c index 09e0718..427dd5a 100644 --- a/src/vkvg_context.c +++ b/src/vkvg_context.c @@ -1434,7 +1434,7 @@ void vkvg_restore(VkvgContext ctx) { uint8_t curSaveBit = 1 << ((ctx->curSavBit - 1) % 6 + 2); - //ctx->renderPassBeginInfo.renderPass = ctx->dev->renderPass_ClearStencil; + ctx->renderPassBeginInfo.renderPass = ctx->pSurf->surfClass->renderPass_ClearStencil; _start_cmd_for_render_pass(ctx); #if defined(DEBUG) && defined(VKVG_DBG_UTILS) diff --git a/src/vkvg_context_internal.c b/src/vkvg_context_internal.c index 92b804c..6b08e35 100644 --- a/src/vkvg_context_internal.c +++ b/src/vkvg_context_internal.c @@ -579,6 +579,7 @@ 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 @@ -633,7 +634,9 @@ void _start_cmd_for_render_pass(VkvgContext ctx) { CmdSetScissor(ctx->cmd, 0, 1, &ctx->bounds); VkDescriptorSet dss[] = {ctx->dev->fontCache->dsFont, ctx->dev->dummySrcSet, ctx->dev->dummyGradSet}; - CmdBindDescriptorSets(ctx->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, ctx->dev->pipelineLayout, 0, 3, dss, 0, NULL); + uint32_t offset = 0; + + 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); @@ -684,9 +687,11 @@ void _update_cur_pattern(VkvgContext ctx, VkvgPattern pat) { case VKVG_PATTERN_TYPE_LINEAR: case VKVG_PATTERN_TYPE_RADIAL: if (newPatternType != VKVG_PATTERN_TYPE_LINEAR && - newPatternType != VKVG_PATTERN_TYPE_RADIAL) + newPatternType != VKVG_PATTERN_TYPE_RADIAL) { + uint32_t offset = 0; CmdBindDescriptorSets(ctx->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, - ctx->dev->pipelineLayout, 2, 1, &ctx->dev->dummyGradSet, 0, NULL); + ctx->dev->pipelineLayout, 2, 1, &ctx->dev->dummyGradSet, 1, &offset); + } break; } } @@ -762,13 +767,15 @@ void _update_cur_pattern(VkvgContext ctx, VkvgPattern pat) { vkvg_matrix_transform_distance(&ctx->pushConsts.mat, &grad->cp[0].z, &grad->cp[0].w); vkvg_matrix_transform_distance(&ctx->pushConsts.mat, &grad->cp[1].z, &grad->cp[0].w); } - - memcpy(vkh_buffer_get_mapped_pointer(&ctx->pSurf->uboGrad), grad, sizeof(vkvg_gradient_t)); + uint32_t offset = ctx->pSurf->gradCount * sizeof(vkvg_gradient_t); + memcpy(vkh_buffer_get_mapped_pointer(&ctx->pSurf->uboGrad) + offset, + grad, sizeof(vkvg_gradient_t)); vkh_buffer_flush(&ctx->pSurf->uboGrad); _ensure_renderpass_is_started(ctx); CmdBindDescriptorSets(ctx->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, ctx->dev->pipelineLayout, - 2, 1, &ctx->pSurf->dsGradient, 0, NULL); + 2, 1, &ctx->pSurf->dsGradient, 1, &offset); + ctx->pSurf->gradCount++; break; } ctx->pushConsts.fsq_patternType = (ctx->pushConsts.fsq_patternType & FULLSCREEN_BIT) + newPatternType; diff --git a/src/vkvg_device.c b/src/vkvg_device.c index 5f780bf..15fd9f2 100644 --- a/src/vkvg_device.c +++ b/src/vkvg_device.c @@ -73,15 +73,14 @@ void _device_init(VkvgDevice dev, const vkvg_device_create_info_t* info) { dev->phyMemProps = phyInfos->memProps; dev->gQueue = vkh_queue_create(dev->vkhDev, info->qFamIdx, info->qIndex); + + VkPhysicalDeviceProperties phyProps = vkh_phyinfo_get_properties(phyInfos); + dev->minUniformBufferOffsetAlignment = phyProps.limits.minUniformBufferOffsetAlignment; + // mtx_init (&dev->gQMutex, mtx_plain); vkh_phyinfo_destroy(phyInfos); -#ifdef VKH_USE_VMA - VmaAllocatorCreateInfo allocatorInfo = {.physicalDevice = info->phy, .device = info->vkdev}; - vmaCreateAllocator(&allocatorInfo, (VmaAllocator*)&dev->allocator); -#endif - dev->cmdPool = vkh_cmd_pool_create(dev->vkhDev, dev->gQueue->familyIndex, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT); dev->cmd = vkh_cmd_buff_create(dev->vkhDev, dev->cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY); dev->fence = vkh_fence_create_signaled(dev->vkhDev); @@ -108,6 +107,7 @@ void _device_init(VkvgDevice dev, const vkvg_device_create_info_t* info) { vkh_device_set_object_name(dev->vkhDev, VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT, (uint64_t)dev->dslSrc, "DSLayout SOURCE"); vkh_device_set_object_name(dev->vkhDev, VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT, (uint64_t)dev->dslFont, "DSLayout FONT"); + vkh_device_set_object_name(dev->vkhDev, VK_OBJECT_TYPE_SAMPLER, (uint64_t)dev->smpFont, "FONT Sampler"); vkh_device_set_object_name(dev->vkhDev, VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT, (uint64_t)dev->dslGrad, "DSLayout GRADIENT"); vkh_device_set_object_name(dev->vkhDev, VK_OBJECT_TYPE_PIPELINE_LAYOUT, (uint64_t)dev->pipelineLayout, "PLLayout dev"); #endif @@ -398,10 +398,6 @@ void vkvg_device_destroy(VkvgDevice dev) { _font_cache_destroy(dev); -#ifdef VKH_USE_VMA - vmaDestroyAllocator(dev->allocator); -#endif - if (dev->threadAware) { mtx_destroy(&dev->mutex); mtx_destroy(&dev->fontCache->mutex); @@ -411,6 +407,8 @@ void vkvg_device_destroy(VkvgDevice dev) { VkhApp app = vkh_device_get_app(dev->vkhDev); vkh_device_destroy(dev->vkhDev); vkh_app_destroy(app); + } else { + vkh_device_destroy(dev->vkhDev); } free(dev); diff --git a/src/vkvg_device_internal.c b/src/vkvg_device_internal.c index 79b94eb..b2064c9 100644 --- a/src/vkvg_device_internal.c +++ b/src/vkvg_device_internal.c @@ -95,7 +95,7 @@ void _device_createDescriptorSetLayout(VkvgDevice dev) { VK_CHECK_RESULT(vkCreateDescriptorSetLayout(dev->vkDev, &dsLayoutCreateInfo, NULL, &dev->dslFont)); dsLayoutBinding[0].pImmutableSamplers = NULL; - dsLayoutBinding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; + dsLayoutBinding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; VK_CHECK_RESULT(vkCreateDescriptorSetLayout(dev->vkDev, &dsLayoutCreateInfo, NULL, &dev->dslGrad)); VkPushConstantRange pushConstantRange[] = { diff --git a/src/vkvg_device_internal.h b/src/vkvg_device_internal.h index f273b8a..e640266 100644 --- a/src/vkvg_device_internal.h +++ b/src/vkvg_device_internal.h @@ -42,25 +42,27 @@ typedef struct _cached_ctx { typedef struct _surface_class* SurfaceClass; +DIAGNOSTIC_DISABLE_UNUSED + CTOR_ARRAY(SurfaceClass) ARRAY_DEL_ELT(SurfaceClass) +DIAGNOSTIC_RESTORE_UNUSED + typedef struct _vkvg_device_t { vkvg_status_t status; /**< Current status of device, affected by last operation */ VkDevice vkDev; /**< Vulkan Logical Device */ VkPhysicalDevice phy; /**< Vulkan Physical device */ VkInstance instance; /**< Vulkan instance */ VkPhysicalDeviceMemoryProperties phyMemProps; /**< Vulkan Physical device memory properties */ -#ifdef VKH_USE_VMA - void* allocator; /**< Vulkan Memory allocator */ -#endif - VkImageTiling supportedTiling; /**< Supported image tiling for surface, 0xFF=no support */ - VkFormat stencilFormat; /**< Supported vulkan image format for stencil */ - VkImageAspectFlags stencilAspectFlag; /**< stencil only or depth stencil, could be solved by - VK_KHR_separate_depth_stencil_layouts*/ - VkFormat pngStagFormat; /**< Supported vulkan image format png write staging img */ - VkImageTiling pngStagTiling; /**< tiling for the blit operation */ + VkDeviceSize minUniformBufferOffsetAlignment; /**< stored for dynamic uniform buffer offsets */ + VkImageTiling supportedTiling; /**< Supported image tiling for surface, 0xFF=no support */ + VkFormat stencilFormat; /**< Supported vulkan image format for stencil */ + VkImageAspectFlags stencilAspectFlag; /**< stencil only or depth stencil, could be solved by + VK_KHR_separate_depth_stencil_layouts*/ + VkFormat pngStagFormat; /**< Supported vulkan image format png write staging img */ + VkImageTiling pngStagTiling; /**< tiling for the blit operation */ mtx_t mutex; /**< protect device access (queue, cahes, ...)from ctxs in separate threads */ bool threadAware; /**< if true, mutex is created and guard device queue and caches access */ diff --git a/src/vkvg_surface_internal.c b/src/vkvg_surface_internal.c index ab37540..3652e33 100644 --- a/src/vkvg_surface_internal.c +++ b/src/vkvg_surface_internal.c @@ -645,7 +645,7 @@ VkvgSurface _create_surface(VkvgDevice dev, VkFormat format, VkSampleCountFlags surf->flushFence = vkh_fence_create(vkhd); #endif - const VkDescriptorPoolSize descriptorPoolSize = {VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1}; + const VkDescriptorPoolSize descriptorPoolSize = {VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 1}; VkDescriptorPoolCreateInfo descriptorPoolCreateInfo = {.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO, .maxSets = 1, .flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, @@ -660,14 +660,14 @@ VkvgSurface _create_surface(VkvgDevice dev, VkFormat format, VkSampleCountFlags VK_CHECK_RESULT(vkAllocateDescriptorSets(dev->vkDev, &descriptorSetAllocateInfo, &surf->dsGradient)); vkh_buffer_init(dev->vkhDev, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, VKH_MEMORY_USAGE_CPU_TO_GPU, - sizeof(vkvg_gradient_t), &surf->uboGrad, true); + MAX_GRAD * sizeof(vkvg_gradient_t), &surf->uboGrad, true); VkDescriptorBufferInfo dbi = {surf->uboGrad.buffer, 0, VK_WHOLE_SIZE}; VkWriteDescriptorSet writeDescriptorSet = {.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, .dstSet = surf->dsGradient, .dstBinding = 0, .descriptorCount = 1, - .descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, + .descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, .pBufferInfo = &dbi}; vkUpdateDescriptorSets(dev->vkDev, 1, &writeDescriptorSet, 0, NULL); diff --git a/src/vkvg_surface_internal.h b/src/vkvg_surface_internal.h index cd5b395..1d98e56 100644 --- a/src/vkvg_surface_internal.h +++ b/src/vkvg_surface_internal.h @@ -9,6 +9,8 @@ #include "vkh.h" #include "vkh_buffer.h" +#define MAX_GRAD 5 + typedef struct _surface_class { atomic_int references; VkvgDevice dev; @@ -50,6 +52,7 @@ typedef struct _vkvg_surface_t { VkDescriptorPool descPool; VkDescriptorSet dsGradient; vkh_buffer_t uboGrad; // uniform buff obj holdings gradient infos + uint32_t gradCount; // recorded grad draws in current command } vkvg_surface; #define LOCK_SURFACE(surf) \ diff --git a/tests/fill.c b/tests/fill.c index 9985424..39e0e78 100644 --- a/tests/fill.c +++ b/tests/fill.c @@ -1,7 +1,7 @@ #include "test.h" void test() { - VkvgContext ctx = _initCtx(surf); + VkvgContext ctx = _initCtx(); vkvg_set_source_rgba(ctx, 0.1f, 0.9f, 0.1f, 1.0f); vkvg_move_to(ctx, 100, 100); diff --git a/vkh b/vkh -Subproject c5b7f0e6000fd61a920a69d4983624ae105a644 +Subproject 0b1ee1525dff764895719adcc283de506183639 |