jpbruyere / vkvg Goto Github PK
View Code? Open in Web Editor NEWVulkan 2D graphics library
Home Page: https://jpbruyere.github.io/vkvg
License: MIT License
Vulkan 2D graphics library
Home Page: https://jpbruyere.github.io/vkvg
License: MIT License
Context has dedicated command pool and dedicated descriptor pool.
There is a single graphic queue instantiated in the device.
All commands (from device, surfaces and contexts) are submitted to that queue from their respective threads.
Validation layer complaints when submitting commands from other threads.
I have to find the correct way to build command buffers in different threads and submitting them to the main graphic queue.
glfwCreateWindowSurface returns 0 => presentation queue not found => sigsev.
In Debug mode glfwCreateWindowSurface returns correct pointer for surface...
After following the installations instructions precisely I get the following errors on my Fedora 32 system:
-*- mode: compilation; default-directory: "/space/pub-repos/vkvg/build/" -*-
Compilation started at Wed Aug 12 23:18:59
make
[ 10%] Built target vkh_static
[ 23%] Built target vkvg_static
[ 25%] Built target tests_common
[ 26%] Linking CXX executable test_compositing
/usr/bin/ld: libtests_common.a(test.c.o):/space/pub-repos/vkvg/vkh/src/vkh_device.h:32: multiple definition of `CreateDebugReportCallback'; CMakeFiles/test_compositing.dir/tests/compositing.c.o:/space/pub-repos/vkvg/vkh/src/vkh_device.h:32: first defined here
/usr/bin/ld: libtests_common.a(test.c.o):/space/pub-repos/vkvg/vkh/src/vkh_device.h:33: multiple definition of `DestroyDebugReportCallback'; CMakeFiles/test_compositing.dir/tests/compositing.c.o:/space/pub-repos/vkvg/vkh/src/vkh_device.h:33: first defined here
/usr/bin/ld: libtests_common.a(test.c.o):/space/pub-repos/vkvg/vkh/src/vkh_device.h:34: multiple definition of `dbgBreakCallback'; CMakeFiles/test_compositing.dir/tests/compositing.c.o:/space/pub-repos/vkvg/vkh/src/vkh_device.h:34: first defined here
/usr/bin/ld: libtests_common.a(vkengine.c.o):/space/pub-repos/vkvg/vkh/src/vkh_device.h:32: multiple definition of `CreateDebugReportCallback'; CMakeFiles/test_compositing.dir/tests/compositing.c.o:/space/pub-repos/vkvg/vkh/src/vkh_device.h:32: first defined here
/usr/bin/ld: libtests_common.a(vkengine.c.o):/space/pub-repos/vkvg/vkh/src/vkh_device.h:33: multiple definition of `DestroyDebugReportCallback'; CMakeFiles/test_compositing.dir/tests/compositing.c.o:/space/pub-repos/vkvg/vkh/src/vkh_device.h:33: first defined here
:
I pulled the recent changes from this repository and tried to build it, but the linkage failed:
[ 49%] Linking CXX executable arcs
/usr/bin/ld: CMakeFiles/tests_common.dir/common/vkengine.c.o: in function `vkengine_create':
[many undefined references]
/usr/bin/ld: ../libvkvg.a(vkvg_device.c.o): in function `vkvg_device_create':
[many undefined references]
collect2: error: ld returned 1 exit status
make[2]: *** [tests/CMakeFiles/arcs.dir/build.make:112: tests/arcs] Error 1
make[1]: *** [CMakeFiles/Makefile2:485: tests/CMakeFiles/arcs.dir/all] Error 2
make: *** [Makefile:156: all] Error 2
I see some missing function definitions are related to vkh_layer*
and vkh_extension*
, have you perhaps forgotten to push changes to vkhelpers
?
patterns data's are stored in context push constant, and ubo, the full pattern struct should be stored in ctx to allow save and restore. struct lifetime sync between context and pattern should be handled.
When offset is greater than 0, first dashes until total dash length are not drawn.
In closed path with offset > 0, inked dash on the closing corner must be handled with continuous line where possible.
Hi, I'm here just to tell you I made a PKGBUILD for Arch Linux and released it on the Arch User Repository here: https://aur.archlinux.org/packages/vkvg. You can add it in your README if you like it.
Triangle fans are used to fill polygons with the Even/Odd technic, it's not supported by moltenVK.
A quick fix has be apply to disable Even/Odd on macOS.
The workaround is to bind the IBO in the _poly_fill() method and produce triangle list indices as the fan would output with the contour.
This add several convenient methods to create a vulkan context that meets vkvg requirements
#93
Current implementation uses basic ear clipping.
Hi, could you please create backend renderer for nanovg?
Question: In the samples you define the graphics and the presentation queue as the same queue. Is it possible that this becomes a bottleneck for the measurements?
When a curve segment has a very tight angle, currently the join is extended or converted to miter join. Ideally, under a certain angle, the segment join should be converted to curved join to render a perfect curve.
Provide a lightweight single font system that can compile without freetype, fontconfig and harfbuzz.
Pattern are implemented in the main shader, so for now I can't reuse the texture extend properties which would make things a lot easier.
My side is win10 vs 2019
VKVG_ FILL_ RULE_ NON_ ZERO and VKVG_ FILL_ RULE_ EVEN_ ODD, The effect is the same
It would be good if there was a .deb package for Debian or Ubuntu.
I guess in the Ubuntu version, it makes it possible to have a PPA which makes it much easier to try out vkvg.
especially for vkvg_arc, current point presence should be tested, a boolean could be added when it is set.
Output repets last error several times:
WRN: [ UNASSIGNED-CoreValidation-DrawState-InvalidRenderpass ] Object: VK_NULL_HANDLE (Type = 0) | Render pass has an attachment with loadOp == V
K_ATTACHMENT_LOAD_OP_LOAD and initialLayout == VK_IMAGE_LAYOUT_UNDEFINED. This is probably not what you intended. Consider using VK_ATTACHMENT_L
OAD_OP_DONT_CARE instead if the image truely is undefined at the start of the render pass.
WRN: [ UNASSIGNED-CoreValidation-DrawState-InvalidRenderpass ] Object: VK_NULL_HANDLE (Type = 0) | Render pass has an attachment with stencilLoad
Op == VK_ATTACHMENT_LOAD_OP_LOAD and initialLayout == VK_IMAGE_LAYOUT_UNDEFINED. This is probably not what you intended. Consider using VK_ATTAC
HMENT_LOAD_OP_DONT_CARE instead if the image truely is undefined at the start of the render pass.
WRN: [ UNASSIGNED-CoreValidation-DrawState-InvalidRenderpass ] Object: VK_NULL_HANDLE (Type = 0) | Render pass has an attachment with loadOp == V
K_ATTACHMENT_LOAD_OP_LOAD and initialLayout == VK_IMAGE_LAYOUT_UNDEFINED. This is probably not what you intended. Consider using VK_ATTACHMENT_L
OAD_OP_DONT_CARE instead if the image truely is undefined at the start of the render pass.
DBG: While debugging through RenderDoc, debug output through validation layers is suppressed.
To show debug output look at the 'DebugOutputMute' capture option in RenderDoc's API, but be aware of false positives from the validation layers.
ERR: [ VUID-vkAcquireNextImageKHR-semaphore-01780 ] Object: 0x557f21c34aa0 (Type = 3) | vkAcquireNextImageKHR: Semaphore and fence cannot both be
VK_NULL_HANDLE. There would be no way to determine the completion of this operation. The Vulkan spec states: semaphore and fence must not both be
equal to VK_NULL_HANDLE (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-vkAcquireNextImageKHR-semaphore-01780
)
ERR: [ VUID-VkPresentInfoKHR-pImageIndices-01296 ] Object: 0x557f21c9cac0 (Type = 4) | Images passed to present must be in layout VK_IMAGE_LAYOUT
_PRESENT_SRC_KHR or VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR but is in VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL. The Vulkan spec states: Each element of
pImageIndices must be the index of a presentable image acquired from the swapchain specified by the corresponding element of the pSwapchains arra
y, and the presented image subresource must be in the VK_IMAGE_LAYOUT_PRESENT_SRC_KHR layout at the time the operation is executed on a VkDevice (
https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-VkPresentInfoKHR-pImageIndices-01296)
ERR: [ VUID-vkAcquireNextImageKHR-semaphore-01780 ] Object: 0x557f21c34aa0 (Type = 3) | vkAcquireNextImageKHR: Semaphore and fence cannot both be
VK_NULL_HANDLE. There would be no way to determine the completion of this operation. The Vulkan spec states: semaphore and fence must not both be
equal to VK_NULL_HANDLE (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-vkAcquireNextImageKHR-semaphore-01780
)
ERR: [ VUID-VkPresentInfoKHR-pImageIndices-01296 ] Object: 0x557f21c9cac0 (Type = 4) | Images passed to present must be in layout VK_IMAGE_LAYOUT
_PRESENT_SRC_KHR or VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR but is in VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL. The Vulkan spec states: Each element of
pImageIndices must be the index of a presentable image acquired from the swapchain specified by the corresponding element of the pSwapchains arra
y, and the presented image subresource must be in the VK_IMAGE_LAYOUT_PRESENT_SRC_KHR layout at the time the operation is executed on a VkDevice (
https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-VkPresentInfoKHR-pImageIndices-01296)
ERR: [ VUID-vkAcquireNextImageKHR-semaphore-01780 ] Object: 0x557f21c34aa0 (Type = 3) | vkAcquireNextImageKHR: Semaphore and fence cannot both be
VK_NULL_HANDLE. There would be no way to determine the completion of this operation. The Vulkan spec states: semaphore and fence must not both be
equal to VK_NULL_HANDLE (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-vkAcquireNextImageKHR-semaphore-01780
)
possibly missing triangle in the start cap (direction:BottomLeft to TopRight), but it maybe a driver stack bug (rasteriser)
IMAGE(ERROR / SPEC): object: 0x0 type: 0 msgNum: 165676968 - vkCreateImage: usage bit VK_IMAGE_USAGE_COLOR_ATTACHMENT is not supported for format VK_FORMAT_B8G8R8A8_UNORM with tiling VK_IMAGE_TILING_LINEAR. The spec valid usage text states 'If tiling is VK_IMAGE_TILING_LINEAR, and VkFormatProperties::linearTilingFeatures (as returned by vkGetPhysicalDeviceFormatProperties with the same value of format) does not include VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT, usage must not contain VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkImageCreateInfo-tiling-00980)
IMAGE(ERROR): object: 0x0 type: 0 location: 677 msg_code: 165676968: Object: 0x0 | vkCreateImage: usage bit VK_IMAGE_USAGE_COLOR_ATTACHMENT is not supported for format VK_FORMAT_B8G8R8A8_UNORM with tiling VK_IMAGE_TILING_LINEAR. The spec valid usage text states 'If tiling is VK_IMAGE_TILING_LINEAR, and VkFormatProperties::linearTilingFeatures (as returned by vkGetPhysicalDeviceFormatProperties with the same value of format) does not include VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT, usage must not contain VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkImageCreateInfo-tiling-00980)
IMAGE(ERROR / SPEC): object: 0x0 type: 0 msgNum: 165676888 - vkCreateImage: The combination of format, type, tiling, usage and flags supplied in the VkImageCreateInfo struct is reported by vkGetPhysicalDeviceImageFormatProperties() as unsupported. The spec valid usage text states 'The combination of format, imageType, tiling, usage, and flags must be supported, as indicated by a VK_SUCCESS return value from vkGetPhysicalDeviceImageFormatProperties invoked with the same values passed to the corresponding parameters.' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkImageCreateInfo-format-00940)
IMAGE(ERROR): object: 0x0 type: 0 location: 708 msg_code: 165676888: Object: 0x0 | vkCreateImage: The combination of format, type, tiling, usage and flags supplied in the VkImageCreateInfo struct is reported by vkGetPhysicalDeviceImageFormatProperties() as unsupported. The spec valid usage text states 'The combination of format, imageType, tiling, usage, and flags must be supported, as indicated by a VK_SUCCESS return value from vkGetPhysicalDeviceImageFormatProperties invoked with the same values passed to the corresponding parameters.' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkImageCreateInfo-format-00940)
vkvg_test: vkh_image.c:57: _vkh_image_create: Assertion `res == VK_SUCCESS' failed.
If I change VK_IMAGE_TILING_LINEAR->VK_IMAGE_TILING_OPTIMAL then vkvg_test runs, but still with validation errors:
DS(ERROR / SPEC): object: 0x1f00 type: 23 msgNum: 61 - Descriptor set 0x1f00 encountered the following validation error at vkCmdDrawIndexed() time: Descriptor in bindi
ng #0 at global descriptor index 0 is being used in draw but has not been updated.
Would you like to be able to use Pango in concert with Vkvg, as you can do with Cairo in pangocairo
? I could work on it.
SIMD instructions target minimum 128 bits registers for floats, so for 2 dimensions vectors, the minimal alignment is 128bits, this makes use of SIMD only possible for 2*64bit float component vectors. So I'm planning to test and maybe move the vkvg api to double float instead of single float to be able to use SIMD.
The first tests with vgperf against skia's vulkan backend and cairo gles show that solid colored rectangles and circles output of vkvg is 4 to 10 times slower due to the solid color handling: vkvg use push constants to set colors, resulting in too small triangles count submitted to gpu (cmdDrawIndexed vertices count too small). other libraries use color vertex attribute, which is by far the most efficient way to output lots of solid colored simple shape when vertex count/mesh is small.
Actual vertex attributes:
A possible plan for vertex attribute is:
And use another dedicated vertex buffer for font texture coordinate, this imply to create a separate pipeline for text rendering. For now, I use a single pipeline for all pattern types and texts.
After using a lot of hours, I still can't get vkvg to work nicely with cpp.
Right now i'm stuck at creating the device with vkvg_device_create_multisample, where I get a segmentation fault.
The segmentation fault occurs around the VkvgDevice variable created inside the function
I'm using the same approach as the examples
`void InitEngine(uint32_t Width, uint32_t Height) {
Inst = VkEngineCreate(VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, VK_PRESENT_MODE_FIFO_KHR, TWidth, THeight);
VkhPresenter Render = Inst->Renderer;
bool DeferredResolve = false;
Dev = vkvg_device_create_multisample(vkh_app_get_inst(Inst->App), Render->dev->phy, Render->dev->dev, Render->qFam, 0, Samples, DeferredResolve);
vkvg_device_set_dpy(Dev, 96, 96);
Surface = vkvg_surface_create(Dev, Width, Height);
vkh_presenter_build_blit_cmd(Render, vkvg_surface_get_vk_image(Surface), TWidth, THeight);
}`
You can make Cairo-gl Wayland-native thanks to its EGL backend, as shown here: https://jan.newmarch.name/Wayland/Cairo. Can you do the same with vkvg?
For now, there is no way to know that a point in a path is part of a curve or a line, the idea is maybe to use a vec3 for the path points and store type in third field.
Harfbuzz is designed to handle complex text shaping and text direction.
It has to be implemented in VkvgText
.
I keep getting this message.
CMake Error at C:/Program Files/CMake/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find Freetype (missing: FREETYPE_LIBRARY FREETYPE_INCLUDE_DIRS)
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files/CMake/share/cmake-3.13/Modules/FindFreetype.cmake:156 (find_package_handle_standard_args)
CMakeLists.txt:74 (FIND_PACKAGE)
I've tried installing FreeType two different ways. Once via the detailed Windows Instructions and directly from the FreeType download.
I'm building for x64.
I've tried manually doing
set FREETYPE_INCLUDE_DIRS="\Program Files (x86)\GnuWin32\include"
set FREETYPE_LIBRARY="\Program Files (x86)\GnuWin32\lib"
This had no effect.
Context caching is a new feature that allow caching of created context that dramatically increase context creation time. Maximum cached context count is controlled by the macro VKVG_MAX_CACHED_CONTEXT_COUNT.
Several vulkan objects are reused that cause error when manipulated by different threads.
So for now on master, max_cached_context_count is set to 0. To resolve this issue the following tasks are required:
I would say that 99% of these warnings are false alarms, possibly all of them.
But their presence makes it nearly impossible to spot new and dangerous ones as they are added.
I cleaned up about 3,000+ of these at my last employer and uncovered 50 attempts to write out of bounds. The writes only passed because they were writing less than 4 bytes to memory allocated on 4 byte boundaries. It worked but was a ticking bomb.
One I found was
#include "vk_mem_alloc.h".h
Just a dangling '.h' which the compiler let pass with a warning.
Stuff like this doesn't engender a lot of confidence in the package.
I expect to be using this package as a foundation for some upcoming work and I'm open to doing some cleanup work if requested.
Bob Tipton
Dark Sky Innovative Solutions.
This is useful for GUIs and drop shadows. NanoVG shader implements box, linear, and radial using the shader below, but obviously it only supports two color stops.
https://github.com/memononen/nanovg/blob/master/src/nanovg_gl.h#L638
I am interested in understanding the library. I would like to dedicate some of my time to help in the documentation department, if that would be helpful to you.
Would you like to add more error handling for return values from functions like the following?
Clipping is done with the stencil buffer. Once clipped, the clipped regions are not transformed by new matrices.
I see that the project uses cmake to build itself. I find the syntax a bit challenging to understand, and I think meson is a bit more readable. I would be happy to add meson support to vkvg. I would just need a bit of guidance in translating cmake to meson.
When I run the test surface
in release mode, it always segfaults, sometimes with malloc_consolidate(): unaligned fastbin chunk detected
, or free(): double free detected in tcache 2
. While in debug mode I also get corrupted double-linked list
, munmap_chunk(): invalid pointer
, free(): invalid pointer
, double free or corruption (!prev)
or malloc(): unsorted double linked list corrupted
.
Have you thought about using a code formatter like astyle or uncrustify? It's good to have a consistent style.
for build vkvg need install stb, on fedora
sudo dnf install stbi-devel
and edit CMakeLists.txt on line 7
SET(CMAKE_EXE_LINKER_FLAGS "-lm -lstbi")
The font cache is a global cache at the device level, contexts have one descriptor pointing on a common texture array. If this texture array has to be expanded, all contexts are flushed thanks to a double linked list of contexts in the device.
This pattern has to be simplified and reorganized, only contexts updating and using new chars should have an up to date descriptor to the last font cache texture array. Other contexts should keep old cache texture as long as their don't upload new chars.
#define isnanf __isnanf
to #define isnanf isnan
.va_arg
, but does not include stdlib.h
.ctx
is a null pointer in _find_or_create_font_size
when trying to load the mono
font.[ 84%] Building C object tests/CMakeFiles/gradient2.dir/gradient2.c.o
In file included from /home/bill/vkvg/tests/../src/vkvg_context_internal.h:29,
from /home/bill/vkvg/tests/getarcstep.c:3:
/home/bill/vkvg/tests/../src/vkvg_fonts.h:29:11: fatal error: ft2build.h: No such file or directory
29 | #include <ft2build.h>
| ^~~~~~~~~~~~
compilation terminated.
VKVG is Vectors in Vulkan, right?
So why not have the icon be a volcano, with beziér curve handles on a line and it's pulling at a line as it's expanding like you're making it erupt.
I feel like that could be an awesome logo ngl.
This part of the message I posted on the issue #57 made me wonder:
Fatal : VkResult is -2 in /run/media/Volume/Marco/Nextcloud/Sviluppo/aur-vkvg/src/vkvg-0.2.1/vkh/src/vkh_image.c at line 57
Segmentation fault (core dumped)
The path of my build directory ended up in the binaries, that's why makepkg
tells:
==> WARNING: Package contains reference to $srcdir
usr/lib/libvkh.so.0.1.0
usr/lib/libvkvg.so.0.2
So it seems the issue is here https://github.com/jpbruyere/vkhelpers/blob/41daf55f834aede1698aaa1afae02e2faf22530a/src/vkh_image.c#L57 with VK_CHECK_RESULT
. Looking for some CMAKE variables, I found this https://cmake.org/cmake/help/latest/prop_tgt/BUILD_RPATH_USE_ORIGIN.html but even after raising the minimum CMake version to 3.14 and adding SET(BUILD_RPATH_USE_ORIGIN TRUE)
I still get the warning.
How can we make this library reproducible?
Coming from nanovg, these are some features I miss:
Android currently does not build because Vulkan 1.2 is not supported. I'm not particularly familiar with Vulkan, but I think these steps are needed.
VK_MAKE_API_VERSION
is not present, so just fallback to VK_MAKE_VERSION
if VK_MAKE_API_VERSION
is not defined (vkh_app.c).VkPhysicalDeviceVulkan12Features
scalarBlockLayout
in VkPhysicalDeviceVulkan12Features
VK_EXT_scalar_block_layout
is detected set scalarBlockLayout
in VkPhysicalDeviceScalarBlockLayoutFeaturesEXT
and point pNext
to this struct.It seems the alpha channel in gradients is ignored. For example, if I create a linear gradient with two identical color stops (r=1, g=0, b=0, a=0.5), I would expect the behavior to be the same as set_source_rgba(1,0,0,0.5), but instead I get solid red with no blending.
As far as I can tell, this is a pure C library. Would be nice to see the c++ dependency dropped.
I get the following error message when trying to run one of the examples:
Fatal : VkResult is -6 in /home/porky11/build/vkvg/vkh/src/vkh_app.c at line 83
test_colinear: /home/porky11/build/vkvg/vkh/src/vkh_app.c:83: vkh_app_create: Assertion `res == VK_SUCCESS' failed.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.