diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2026-10-26 10:15:48 +0100 |
|---|---|---|
| committer | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2026-10-26 10:15:48 +0100 |
| commit | b51886c9fe9b591ff7f373c0719fbc51cf0a29e6 (patch) | |
| tree | 7a079af70d6042d32ff09740542f625da313a46c | |
| parent | 61887b0627a0777058bfb72836cf3081b6db062b (diff) | |
remove samples and deffered resolve from device create struct
| -rw-r--r-- | gunit_tests/drawTestBase.cpp | 1 | ||||
| -rw-r--r-- | include/vkvg.h | 31 | ||||
| -rw-r--r-- | samples/VkvgTest.cpp | 16 | ||||
| -rw-r--r-- | src/svg/svg-parse.c | 2 | ||||
| -rw-r--r-- | src/vkvg_device.c | 12 | ||||
| -rw-r--r-- | src/vkvg_device_internal.c | 1 | ||||
| -rw-r--r-- | src/vkvg_device_internal.h | 3 | ||||
| -rw-r--r-- | src/vkvg_surface_internal.c | 6 | ||||
| -rw-r--r-- | src/vkvg_surface_internal.h | 2 | ||||
| -rw-r--r-- | tests/bezier.c | 10 | ||||
| -rw-r--r-- | tests/common/test.c | 3 | ||||
| -rw-r--r-- | tests/fonts/allfont.c | 10 | ||||
| -rw-r--r-- | tests/fonts/fontquery.c | 10 | ||||
| -rw-r--r-- | tests/gradient2.c | 10 | ||||
| -rw-r--r-- | tests/inverse_colinear.c | 10 | ||||
| -rw-r--r-- | tests/offscreen.c | 2 | ||||
| -rw-r--r-- | tests/path_extents.c | 10 | ||||
| -rw-r--r-- | tests/vkvg-svg/svg-viewer-old.c | 14 | ||||
| -rw-r--r-- | tests/vkvg-svg/svg-viewer.c | 16 |
19 files changed, 71 insertions, 98 deletions
diff --git a/gunit_tests/drawTestBase.cpp b/gunit_tests/drawTestBase.cpp index 472a814..13faab2 100644 --- a/gunit_tests/drawTestBase.cpp +++ b/gunit_tests/drawTestBase.cpp @@ -22,7 +22,6 @@ DrawTestBase::DrawTestBase() { fs::create_directories(diffDir); vkvg_device_create_info_t info{}; - info.samples = VK_SAMPLE_COUNT_4_BIT; fs::path fontDir = fs::path(GTEST_DATA_ROOT) / fs::path("fonts"); info.fontsDirectories = fontDir.string().c_str(); dev = vkvg_device_create(&info); diff --git a/include/vkvg.h b/include/vkvg.h index bd6a465..48fca2d 100644 --- a/include/vkvg.h +++ b/include/vkvg.h @@ -571,16 +571,6 @@ vkvg_public void vkvg_matrix_get_scale(const vkvg_matrix_t* matrix, flo * #VkvgDevice is the starting point of a vkvg rendering infrastructure. It connects an * existing vulkan context with vkvg, or may create a new one. * - * Most of the vulkan rendering component (pipelines, renderpass, ..) are part of the VkvgDevice, - * their are shared among drawing contexts. - * - * Antialiasing level is configured when creating the device by selecting the sample count. - * @ref vkvg_device_create will create a non-antialiased dev by selecting VK_SAMPLE_COUNT_1_BIT as sample count. - * To create antialiased rendering device, call @ref vkvg_device_create_multisample with VkSampleCountFlags - * greater than one. - * - * vkvg use a single frame buffer format for now: VK_FORMAT_B8G8R8A8_UNORM. - * * Device holds the font cache so that each time a context draws text, the same cache is used. * * @{ */ @@ -592,24 +582,13 @@ vkvg_public void vkvg_matrix_get_scale(const vkvg_matrix_t* matrix, flo * @code * @endcode * - * @samples: sample count. - * @inst: vulkan instance used to create device, may be null to create a new instance. - * @phy: vulkan physical device to create vkvg device for, may be null. - * @vkdev: vulkan logical device, may be null to create a new one. - * @qFamIdx: graphic queue family index, ignored if vkdev is NULL. - * @qIndex: queue index, ignored if vkdev is NULL. - * @deferredResolve: If true, the final simple sampled image of the surface will only be resolved on demand - * when calling @ref vkvg_surface_get_vk_image or by explicitly calling @ref vkvg_multisample_surface_resolve. - * If false, multisampled image is resolved on each draw operation. */ typedef struct { - VkSampleCountFlags samples; - bool deferredResolve; - VkInstance inst; - VkPhysicalDevice phy; - VkDevice vkdev; - uint32_t qFamIdx; - uint32_t qIndex; + VkInstance inst; /**< vulkan instance used to create device, may be null to create a new instance.*/ + VkPhysicalDevice phy; /**< vulkan physical device to create vkvg device for, may be null.*/ + VkDevice vkdev; /**< vulkan logical device, may be null to create a new one.*/ + uint32_t qFamIdx; /**< graphic queue family index, ignored if vkdev is NULL.*/ + uint32_t qIndex; /**< queue index, ignored if vkdev is NULL.*/ bool threadAware; /**< if true, mutex is created and guard device queue and caches access */ const char* fontsDirectories; /**< Coma sepparated list of font directories to scan. With font-config, leave empty for default system configuration. diff --git a/samples/VkvgTest.cpp b/samples/VkvgTest.cpp index 24285d8..b67eba3 100644 --- a/samples/VkvgTest.cpp +++ b/samples/VkvgTest.cpp @@ -35,14 +35,14 @@ VkvgTest::VkvgTest(VkvgTestFunc testFunc, std::string _name) { void VkvgTest::initTest(SampleApp* app) { this->app = app; - vkvg_device_create_info_t info = {app->samples, - false, - vkh_app_get_inst(app->app), - vkh_device_get_phy(app->vkhDev), - vkh_device_get_vkdev(app->vkhDev), - app->presentQIndex, - 0, - false}; + vkvg_device_create_info_t info = { + vkh_app_get_inst(app->app), + vkh_device_get_phy(app->vkhDev), + vkh_device_get_vkdev(app->vkhDev), + app->presentQIndex, + 0, + false + }; device = vkvg_device_create(&info); surf = vkvg_surface_create(device, app->width, app->height); diff --git a/src/svg/svg-parse.c b/src/svg/svg-parse.c index 3a56e5d..6500fe4 100644 --- a/src/svg/svg-parse.c +++ b/src/svg/svg-parse.c @@ -1646,7 +1646,7 @@ void process_svg(svg_context *const svg) { return; } if (!svg->ctx) { - svg->surf = vkvg_surface_create(svg->dev, surfW, surfH); + svg->surf = vkvg_surface_create_ms(svg->dev, surfW, surfH, VK_SAMPLE_COUNT_4_BIT); svg->ctx = vkvg_create(svg->surf); vkvg_clear (svg->ctx); svg->ownContext = true; diff --git a/src/vkvg_device.c b/src/vkvg_device.c index 15fd9f2..2a1535a 100644 --- a/src/vkvg_device.c +++ b/src/vkvg_device.c @@ -76,6 +76,7 @@ void _device_init(VkvgDevice dev, const vkvg_device_create_info_t* info) { VkPhysicalDeviceProperties phyProps = vkh_phyinfo_get_properties(phyInfos); dev->minUniformBufferOffsetAlignment = phyProps.limits.minUniformBufferOffsetAlignment; + dev->framebufferColorSampleCounts = phyProps.limits.framebufferColorSampleCounts; // mtx_init (&dev->gQMutex, mtx_plain); @@ -288,17 +289,6 @@ VkvgDevice vkvg_device_create(vkvg_device_create_info_t* info) { if (!_device_try_get_phyinfo(phys, phyCount, VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU, &pi)) pi = phys[0]; - if (!info->samples) // if not set, default to 1 sample - info->samples = VK_SAMPLE_COUNT_1_BIT; - - if (!(pi->properties.limits.framebufferColorSampleCounts & info->samples)) { - LOGE("CREATE Device failed: sample count not supported: %d\n", info->samples); - dev->status = VKVG_STATUS_DEVICE_ERROR; - vkh_app_free_phyinfos(phyCount, phys); - vkh_app_destroy(app); - return dev; - } - uint32_t qCount = 0; float qPriorities[] = {0.0}; VkDeviceQueueCreateInfo pQueueInfos[] = {{0}, {0}, {0}}; diff --git a/src/vkvg_device_internal.c b/src/vkvg_device_internal.c index 2c79c2c..0697f95 100644 --- a/src/vkvg_device_internal.c +++ b/src/vkvg_device_internal.c @@ -103,7 +103,6 @@ void _device_createDescriptorSetLayout(VkvgDevice dev) { //{VK_SHADER_STAGE_FRAGMENT_BIT,0,sizeof(push_constants)} }; VkDescriptorSetLayout dsls[] = {dev->dslFont, dev->dslSrc, dev->dslGrad}; - VkPipelineLayoutCreateInfo pipelineLayoutCreateInfo = { .sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, .pushConstantRangeCount = 1, diff --git a/src/vkvg_device_internal.h b/src/vkvg_device_internal.h index 37cb29f..9851ff5 100644 --- a/src/vkvg_device_internal.h +++ b/src/vkvg_device_internal.h @@ -55,6 +55,7 @@ typedef struct _vkvg_device_t { VkPhysicalDeviceMemoryProperties phyMemProps; /**< Vulkan Physical device memory properties */ VkDeviceSize minUniformBufferOffsetAlignment; /**< stored for dynamic uniform buffer offsets */ + VkSampleCountFlags framebufferColorSampleCounts; 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 @@ -69,7 +70,7 @@ typedef struct _vkvg_device_t { atomic_int references; /**< Reference count, prevent destroying device if still in use */ VkCommandPool cmdPool; /**< Global command pool for processing on surfaces without context */ VkCommandBuffer cmd; /**< Global command buffer */ - VkFence fence; /**< this fence is kept signaled when idle, wait and reset are called before each recording. */ + VkFence fence; /**< this fence is kept signaled when idle, wait and reset are called before each recording. */ VkPipelineCache pipelineCache; /**< speed up startup by caching configured pipelines on disk */ diff --git a/src/vkvg_surface_internal.c b/src/vkvg_surface_internal.c index 9862672..87a464c 100644 --- a/src/vkvg_surface_internal.c +++ b/src/vkvg_surface_internal.c @@ -624,6 +624,12 @@ VkvgSurface _create_surface(VkvgDevice dev, VkFormat format, VkSampleCountFlags return (VkvgSurface)&_vkvg_status_no_memory; } + if (!(dev->framebufferColorSampleCounts & samples)) { + LOGE("CREATE Surface failed, sample count not supported: %d\n", samples); + surf->status = VKVG_STATUS_INVALID_SURFACE; + return surf; + } + surf->dev = dev; surf->hdpi = 72; surf->vdpi = 72; diff --git a/src/vkvg_surface_internal.h b/src/vkvg_surface_internal.h index 1d98e56..be0a636 100644 --- a/src/vkvg_surface_internal.h +++ b/src/vkvg_surface_internal.h @@ -15,7 +15,7 @@ typedef struct _surface_class { atomic_int references; VkvgDevice dev; VkFormat format; - VkSampleCountFlags samples; /**< samples count */ + VkSampleCountFlags samples; /**< samples count */ VkRenderPass renderPass; /**< Vulkan render pass, common for all surfaces */ VkRenderPass renderPass_ClearStencil; /**< Vulkan render pass for first draw with context, stencil has to be cleared */ VkRenderPass renderPass_ClearAll; /**< Vulkan render pass for new surface, clear all attacments*/ diff --git a/tests/bezier.c b/tests/bezier.c index 19c1cb7..c5178e0 100644 --- a/tests/bezier.c +++ b/tests/bezier.c @@ -201,11 +201,11 @@ int main(int argc, char* argv[]) { vkengine_set_scroll_callback(e, scroll_callback); vkvg_device_create_info_t info = { - samples, false, - vkh_app_get_inst(e->app), - vkh_device_get_phy(e->dev), - vkh_device_get_vkdev(e->dev), - e->gQFamIdx, 0}; + vkh_app_get_inst(e->app), + vkh_device_get_phy(e->dev), + vkh_device_get_vkdev(e->dev), + e->gQFamIdx, 0 + }; device = vkvg_device_create(&info); surf = vkvg_surface_create(device, test_width, test_height); diff --git a/tests/common/test.c b/tests/common/test.c index fde3317..6902698 100644 --- a/tests/common/test.c +++ b/tests/common/test.c @@ -154,7 +154,6 @@ void init_test(uint32_t width, uint32_t height) { vkengine_set_scroll_callback(e, scroll_callback); vkvg_device_create_info_t info = { - samples, false, vkh_app_get_inst(e->app), vkh_device_get_phy(e->dev), vkh_device_get_vkdev(e->dev), @@ -472,7 +471,7 @@ void perform_test(void (*testfunc)(void), const char* testName, int argc, char* void perform_test_offscreen(void (*testfunc)(void), const char* testName, int argc, char* argv[]) { - vkvg_device_create_info_t info = { samples }; + vkvg_device_create_info_t info = {0}; device = vkvg_device_create(&info); // vkvg_device_set_dpy(device, 96, 96); surf = vkvg_surface_create(device, test_width, test_height); diff --git a/tests/fonts/allfont.c b/tests/fonts/allfont.c index 36e8952..dc7d20c 100644 --- a/tests/fonts/allfont.c +++ b/tests/fonts/allfont.c @@ -333,11 +333,11 @@ int main(int argc, char* argv[]) { vkengine_set_scroll_callback(e, scroll_callback); vkvg_device_create_info_t info = { - 1, false, - vkh_app_get_inst(e->app), - vkh_device_get_phy(e->dev), - vkh_device_get_vkdev(e->dev), - e->gQFamIdx, 0, false };//, TESTS_DATA_ROOT "/fonts"}; + vkh_app_get_inst(e->app), + vkh_device_get_phy(e->dev), + vkh_device_get_vkdev(e->dev), + e->gQFamIdx, 0, false + };//, TESTS_DATA_ROOT "/fonts"}; device = vkvg_device_create(&info); surf = vkvg_surface_create(device, test_width, test_height); diff --git a/tests/fonts/fontquery.c b/tests/fonts/fontquery.c index 3cab712..3296752 100644 --- a/tests/fonts/fontquery.c +++ b/tests/fonts/fontquery.c @@ -499,11 +499,11 @@ int main(int argc, char* argv[]) { vkengine_set_char_callback(e, char_callback); vkvg_device_create_info_t info = { - 1, false, - vkh_app_get_inst(e->app), - vkh_device_get_phy(e->dev), - vkh_device_get_vkdev(e->dev), - e->gQFamIdx, 0, false};//, TESTS_DATA_ROOT "/fonts"}; + vkh_app_get_inst(e->app), + vkh_device_get_phy(e->dev), + vkh_device_get_vkdev(e->dev), + e->gQFamIdx, 0, false + };//, TESTS_DATA_ROOT "/fonts"}; device = vkvg_device_create(&info); surf = vkvg_surface_create(device, test_width, test_height); diff --git a/tests/gradient2.c b/tests/gradient2.c index 37dfae1..2036074 100644 --- a/tests/gradient2.c +++ b/tests/gradient2.c @@ -136,11 +136,11 @@ int main(int argc, char* argv[]) { vkengine_set_scroll_callback(e, scroll_callback); vkvg_device_create_info_t info = { - samples, false, - vkh_app_get_inst(e->app), - vkh_device_get_phy(e->dev), - vkh_device_get_vkdev(e->dev), - e->gQFamIdx, 0}; + vkh_app_get_inst(e->app), + vkh_device_get_phy(e->dev), + vkh_device_get_vkdev(e->dev), + e->gQFamIdx, 0 + }; device = vkvg_device_create(&info); surf = vkvg_surface_create(device, test_width, test_height); diff --git a/tests/inverse_colinear.c b/tests/inverse_colinear.c index 9075ea3..bd3f62e 100644 --- a/tests/inverse_colinear.c +++ b/tests/inverse_colinear.c @@ -178,11 +178,11 @@ int main(int argc, char* argv[]) { vkengine_set_scroll_callback(e, scroll_callback); vkvg_device_create_info_t info = { - samples, false, - vkh_app_get_inst(e->app), - vkh_device_get_phy(e->dev), - vkh_device_get_vkdev(e->dev), - e->gQFamIdx, 0}; + vkh_app_get_inst(e->app), + vkh_device_get_phy(e->dev), + vkh_device_get_vkdev(e->dev), + e->gQFamIdx, 0 + }; device = vkvg_device_create(&info); diff --git a/tests/offscreen.c b/tests/offscreen.c index d6644d6..86140bd 100644 --- a/tests/offscreen.c +++ b/tests/offscreen.c @@ -1,7 +1,7 @@ #include "vkvg.h" int main(int argc, char* argv[]) { - vkvg_device_create_info_t info = {VK_SAMPLE_COUNT_1_BIT, false}; + vkvg_device_create_info_t info = {0}; VkvgDevice dev = vkvg_device_create(&info); VkvgSurface surf = vkvg_surface_create(dev, 512, 512); VkvgContext ctx = vkvg_create(surf); diff --git a/tests/path_extents.c b/tests/path_extents.c index 302c722..4fd3ae1 100644 --- a/tests/path_extents.c +++ b/tests/path_extents.c @@ -148,11 +148,11 @@ int main(int argc, char* argv[]) { vkengine_set_scroll_callback(e, scroll_callback); vkvg_device_create_info_t info = { - samples, false, - vkh_app_get_inst(e->app), - vkh_device_get_phy(e->dev), - vkh_device_get_vkdev(e->dev), - e->gQFamIdx, 0}; + vkh_app_get_inst(e->app), + vkh_device_get_phy(e->dev), + vkh_device_get_vkdev(e->dev), + e->gQFamIdx, 0 + }; device = vkvg_device_create(&info); surf = vkvg_surface_create(device, test_width, test_height); diff --git a/tests/vkvg-svg/svg-viewer-old.c b/tests/vkvg-svg/svg-viewer-old.c index 890aa9a..018aa13 100644 --- a/tests/vkvg-svg/svg-viewer-old.c +++ b/tests/vkvg-svg/svg-viewer-old.c @@ -315,13 +315,13 @@ int main(int argc, char* argv[]) { VkEngine e = vkengine_create(VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, VK_PRESENT_MODE_FIFO_KHR, width, height); vkengine_set_key_callback(e, key_callback); vkengine_set_scroll_callback(e, scroll_callback); - vkvg_device_create_info_t info = {samples, - false, - vkh_app_get_inst(e->app), - vkengine_get_physical_device(e), - vkengine_get_device(e), - vkengine_get_queue_fam_idx(e), - 0}; + vkvg_device_create_info_t info = { + vkh_app_get_inst(e->app), + vkengine_get_physical_device(e), + vkengine_get_device(e), + vkengine_get_queue_fam_idx(e), + 0 + }; dev = vkvg_device_create(&info); surf = vkvg_surface_create(dev, width, height); vkh_presenter_build_blit_cmd(e->renderer, vkvg_surface_get_vk_image(surf), width, height); diff --git a/tests/vkvg-svg/svg-viewer.c b/tests/vkvg-svg/svg-viewer.c index 1316abe..8bd46db 100644 --- a/tests/vkvg-svg/svg-viewer.c +++ b/tests/vkvg-svg/svg-viewer.c @@ -281,14 +281,14 @@ int main(int argc, char* argv[]) { VkEngine e = vkengine_create(VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, VK_PRESENT_MODE_FIFO_KHR, width, height); vkengine_set_key_callback(e, key_callback); vkengine_set_scroll_callback(e, scroll_callback); - vkvg_device_create_info_t info = {samples, - false, - vkh_app_get_inst(e->app), - vkengine_get_physical_device(e), - vkengine_get_device(e), - vkengine_get_queue_fam_idx(e), - 0}; - dev = vkvg_device_create(&info); + vkvg_device_create_info_t info = { + vkh_app_get_inst(e->app), + vkengine_get_physical_device(e), + vkengine_get_device(e), + vkengine_get_queue_fam_idx(e), + 0 + }; + dev = vkvg_device_create(&info); mainSurf = vkvg_surface_create(dev, width, height); vkh_presenter_build_blit_cmd(e->renderer, vkvg_surface_get_vk_image(mainSurf), width, height); |