]> O.S.I.I.S - jp/vkvg.git/commitdiff
wip
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 15 Jul 2020 09:20:49 +0000 (11:20 +0200)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 15 Jul 2020 09:20:49 +0000 (11:20 +0200)
16 files changed:
shaders/vkvg_main.vert
src/shaders.h
src/vkvg_context.c
src/vkvg_context_internal.c
src/vkvg_context_internal.h
src/vkvg_device.c
src/vkvg_device_internal.c
src/vkvg_fonts.c
src/vkvg_surface.c
tests/common/test.c
tests/common/vkengine.c
tests/img_surf.c
tests/random_rects.c
tests/rect_fill.c
tests/simple_paint.c
vkh

index 2eb62445f7384d883d96a45cccaac6ef2d5ca877..19899a6108741677b8fe8f4e11fac453aff34c2f 100644 (file)
@@ -25,7 +25,7 @@
 #extension GL_ARB_shading_language_420pack : enable
 
 layout (location = 0) in               vec2 inPos;
-layout (location = 1) in lowp   vec4 inColor;
+layout (location = 1) in               vec4 inColor;
 layout (location = 2) in               vec2 inUV;
 layout (location = 3) in               int      inUVZ;
 
@@ -58,12 +58,11 @@ layout(push_constant) uniform PushConsts {
 void main()
 {
        outPatType      = pc.srcType;
-       outSrc          = inColor;
+       outSrc          = pc.srcType == SOLID ? inColor : pc.source;
        outMat          = pc.matInv;
 
        if (pc.fullScreenQuad != 0) {
                gl_Position = vec4(vec2((gl_VertexIndex << 1) & 2, gl_VertexIndex & 2) * 2.0f + -1.0f, 0.0f, 1.0f);
-               //outUV = vec3((gl_VertexIndex << 1) & 2, gl_VertexIndex & 2, -2);
                outUV = vec3(0,0,-1);
                return;
        }
index eb562a98c04c8a7064982cce538754c8b02c97ca..cd7399480834c060f407c8e090fb426b33eadb11 100644 (file)
@@ -1007,16 +1007,16 @@ unsigned char vkvg_main_frag_spv[] = {
 unsigned int vkvg_main_frag_spv_len = 5780;
 unsigned char vkvg_main_vert_spv[] = {
   0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x0d, 0x00,
-  0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00,
+  0x8d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00,
   0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00,
   0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30,
   0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00,
-  0x08, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
-  0x1a, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00,
-  0x42, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00,
-  0x56, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x02, 0x00, 0x00, 0x00,
+  0x08, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
+  0x28, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00,
+  0x4e, 0x00, 0x00, 0x00, 0x52, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00,
+  0x62, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x02, 0x00, 0x00, 0x00,
   0xc2, 0x01, 0x00, 0x00, 0x04, 0x00, 0x09, 0x00, 0x47, 0x4c, 0x5f, 0x41,
   0x52, 0x42, 0x5f, 0x73, 0x65, 0x70, 0x61, 0x72, 0x61, 0x74, 0x65, 0x5f,
   0x73, 0x68, 0x61, 0x64, 0x65, 0x72, 0x5f, 0x6f, 0x62, 0x6a, 0x65, 0x63,
@@ -1047,21 +1047,21 @@ unsigned char vkvg_main_vert_spv[] = {
   0x6e, 0x76, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x0f, 0x00, 0x00, 0x00,
   0x70, 0x63, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x15, 0x00, 0x00, 0x00,
   0x6f, 0x75, 0x74, 0x53, 0x72, 0x63, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00,
-  0x17, 0x00, 0x00, 0x00, 0x69, 0x6e, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x00,
-  0x05, 0x00, 0x04, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x6f, 0x75, 0x74, 0x4d,
-  0x61, 0x74, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x27, 0x00, 0x00, 0x00,
+  0x20, 0x00, 0x00, 0x00, 0x69, 0x6e, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x00,
+  0x05, 0x00, 0x04, 0x00, 0x28, 0x00, 0x00, 0x00, 0x6f, 0x75, 0x74, 0x4d,
+  0x61, 0x74, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x33, 0x00, 0x00, 0x00,
   0x67, 0x6c, 0x5f, 0x50, 0x65, 0x72, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78,
-  0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, 0x27, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, 0x33, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74,
-  0x69, 0x6f, 0x6e, 0x00, 0x05, 0x00, 0x03, 0x00, 0x29, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x2b, 0x00, 0x00, 0x00,
+  0x69, 0x6f, 0x6e, 0x00, 0x05, 0x00, 0x03, 0x00, 0x35, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x37, 0x00, 0x00, 0x00,
   0x67, 0x6c, 0x5f, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, 0x49, 0x6e, 0x64,
-  0x65, 0x78, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x42, 0x00, 0x00, 0x00,
+  0x65, 0x78, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x4e, 0x00, 0x00, 0x00,
   0x6f, 0x75, 0x74, 0x55, 0x56, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00,
-  0x46, 0x00, 0x00, 0x00, 0x69, 0x6e, 0x55, 0x56, 0x00, 0x00, 0x00, 0x00,
-  0x05, 0x00, 0x04, 0x00, 0x48, 0x00, 0x00, 0x00, 0x69, 0x6e, 0x55, 0x56,
-  0x5a, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x4f, 0x00, 0x00, 0x00,
-  0x70, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x56, 0x00, 0x00, 0x00,
+  0x52, 0x00, 0x00, 0x00, 0x69, 0x6e, 0x55, 0x56, 0x00, 0x00, 0x00, 0x00,
+  0x05, 0x00, 0x04, 0x00, 0x54, 0x00, 0x00, 0x00, 0x69, 0x6e, 0x55, 0x56,
+  0x5a, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x5b, 0x00, 0x00, 0x00,
+  0x70, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x62, 0x00, 0x00, 0x00,
   0x69, 0x6e, 0x50, 0x6f, 0x73, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00,
   0x08, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00,
   0x08, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
@@ -1083,20 +1083,18 @@ unsigned char vkvg_main_vert_spv[] = {
   0x05, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
   0x47, 0x00, 0x03, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
   0x47, 0x00, 0x04, 0x00, 0x15, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00,
-  0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x17, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x17, 0x00, 0x00, 0x00,
-  0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00,
-  0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00,
-  0x1a, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
-  0x48, 0x00, 0x05, 0x00, 0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x20, 0x00, 0x00, 0x00,
+  0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00,
+  0x28, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+  0x48, 0x00, 0x05, 0x00, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00,
-  0x27, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00,
-  0x2b, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00,
-  0x47, 0x00, 0x04, 0x00, 0x42, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x46, 0x00, 0x00, 0x00,
+  0x33, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00,
+  0x37, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00,
+  0x47, 0x00, 0x04, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x52, 0x00, 0x00, 0x00,
   0x1e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00,
-  0x48, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
-  0x47, 0x00, 0x04, 0x00, 0x56, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00,
+  0x54, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+  0x47, 0x00, 0x04, 0x00, 0x62, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00,
   0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
   0x15, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
@@ -1118,186 +1116,207 @@ unsigned char vkvg_main_vert_spv[] = {
   0x11, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
   0x20, 0x00, 0x04, 0x00, 0x14, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
   0x0a, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x14, 0x00, 0x00, 0x00,
-  0x15, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00,
-  0x16, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00,
-  0x3b, 0x00, 0x04, 0x00, 0x16, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
-  0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x19, 0x00, 0x00, 0x00,
-  0x03, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00,
-  0x19, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
-  0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00,
-  0x05, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x1c, 0x00, 0x00, 0x00,
-  0x09, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00,
-  0x06, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
-  0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x02, 0x00, 0x23, 0x00, 0x00, 0x00,
-  0x1e, 0x00, 0x03, 0x00, 0x27, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00,
-  0x20, 0x00, 0x04, 0x00, 0x28, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
-  0x27, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x28, 0x00, 0x00, 0x00,
-  0x29, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00,
-  0x2a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
-  0x3b, 0x00, 0x04, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00,
-  0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00,
-  0x2d, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00,
-  0x09, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40,
-  0x2b, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x80, 0xbf, 0x2b, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00,
-  0x3a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00,
-  0x09, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f,
-  0x17, 0x00, 0x04, 0x00, 0x40, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
-  0x03, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x41, 0x00, 0x00, 0x00,
-  0x03, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00,
-  0x41, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
-  0x2c, 0x00, 0x06, 0x00, 0x40, 0x00, 0x00, 0x00, 0x43, 0x00, 0x00, 0x00,
-  0x3a, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00,
-  0x20, 0x00, 0x04, 0x00, 0x45, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
-  0x0b, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x45, 0x00, 0x00, 0x00,
-  0x46, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00,
-  0x2a, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
-  0x20, 0x00, 0x04, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
-  0x0b, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00,
-  0x50, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00,
-  0x51, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x2b, 0x00, 0x04, 0x00, 0x51, 0x00, 0x00, 0x00, 0x52, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x53, 0x00, 0x00, 0x00,
-  0x09, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00,
-  0x45, 0x00, 0x00, 0x00, 0x56, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
-  0x20, 0x00, 0x04, 0x00, 0x57, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
-  0x09, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x51, 0x00, 0x00, 0x00,
-  0x5d, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x05, 0x00,
-  0x0b, 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00,
-  0x35, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x77, 0x00, 0x00, 0x00,
-  0x09, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x05, 0x00,
-  0x0b, 0x00, 0x00, 0x00, 0x7b, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00,
-  0x3b, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00,
-  0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
-  0xf8, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00,
-  0x4e, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
+  0x15, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00,
+  0x06, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x14, 0x00, 0x02, 0x00, 0x19, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00,
+  0x1b, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00,
+  0x20, 0x00, 0x04, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+  0x0a, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x1f, 0x00, 0x00, 0x00,
+  0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00,
+  0x23, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00,
+  0x20, 0x00, 0x04, 0x00, 0x27, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+  0x0c, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x27, 0x00, 0x00, 0x00,
+  0x28, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00,
+  0x06, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
+  0x20, 0x00, 0x04, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
+  0x0c, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00,
+  0x2d, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00,
+  0x33, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00,
+  0x34, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00,
+  0x3b, 0x00, 0x04, 0x00, 0x34, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00,
+  0x03, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x36, 0x00, 0x00, 0x00,
+  0x01, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00,
+  0x36, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+  0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x39, 0x00, 0x00, 0x00,
+  0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00,
+  0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x2b, 0x00, 0x04, 0x00,
+  0x09, 0x00, 0x00, 0x00, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf,
+  0x2b, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00,
+  0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x17, 0x00, 0x04, 0x00,
+  0x4c, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+  0x20, 0x00, 0x04, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+  0x4c, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x4d, 0x00, 0x00, 0x00,
+  0x4e, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x06, 0x00,
+  0x4c, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00,
+  0x46, 0x00, 0x00, 0x00, 0x43, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00,
+  0x51, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00,
+  0x3b, 0x00, 0x04, 0x00, 0x51, 0x00, 0x00, 0x00, 0x52, 0x00, 0x00, 0x00,
+  0x01, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x36, 0x00, 0x00, 0x00,
+  0x54, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00,
+  0x5a, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00,
+  0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00,
+  0x04, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x5d, 0x00, 0x00, 0x00,
+  0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00,
+  0x5d, 0x00, 0x00, 0x00, 0x5e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x20, 0x00, 0x04, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
+  0x09, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x51, 0x00, 0x00, 0x00,
+  0x62, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00,
+  0x63, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
+  0x2b, 0x00, 0x04, 0x00, 0x5d, 0x00, 0x00, 0x00, 0x69, 0x00, 0x00, 0x00,
+  0x01, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x05, 0x00, 0x0b, 0x00, 0x00, 0x00,
+  0x81, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00,
+  0x20, 0x00, 0x04, 0x00, 0x83, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
+  0x0b, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x05, 0x00, 0x0b, 0x00, 0x00, 0x00,
+  0x87, 0x00, 0x00, 0x00, 0x47, 0x00, 0x00, 0x00, 0x47, 0x00, 0x00, 0x00,
+  0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00,
+  0x05, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x1b, 0x00, 0x00, 0x00,
+  0x1c, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00,
+  0x5a, 0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
   0x41, 0x00, 0x05, 0x00, 0x11, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00,
   0x0f, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00,
   0x06, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00,
   0x3e, 0x00, 0x03, 0x00, 0x08, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00,
-  0x3d, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00,
-  0x17, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x15, 0x00, 0x00, 0x00,
-  0x18, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x1c, 0x00, 0x00, 0x00,
-  0x1d, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00,
-  0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00,
-  0x1d, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x1a, 0x00, 0x00, 0x00,
-  0x1e, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x11, 0x00, 0x00, 0x00,
-  0x20, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00,
-  0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00,
-  0x20, 0x00, 0x00, 0x00, 0xab, 0x00, 0x05, 0x00, 0x23, 0x00, 0x00, 0x00,
-  0x24, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00,
-  0xf7, 0x00, 0x03, 0x00, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0xfa, 0x00, 0x04, 0x00, 0x24, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00,
-  0x26, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x25, 0x00, 0x00, 0x00,
-  0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00,
-  0x2b, 0x00, 0x00, 0x00, 0xc4, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00,
-  0x2e, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x00, 0x00,
-  0xc7, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, 0x00,
-  0x2e, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x6f, 0x00, 0x04, 0x00,
-  0x09, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, 0x00,
-  0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00,
-  0x2b, 0x00, 0x00, 0x00, 0xc7, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00,
-  0x32, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
-  0x6f, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00,
-  0x32, 0x00, 0x00, 0x00, 0x50, 0x00, 0x05, 0x00, 0x0b, 0x00, 0x00, 0x00,
-  0x34, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00,
-  0x8e, 0x00, 0x05, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00,
-  0x34, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x50, 0x00, 0x05, 0x00,
-  0x0b, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00,
-  0x37, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x0b, 0x00, 0x00, 0x00,
-  0x39, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00,
-  0x51, 0x00, 0x05, 0x00, 0x09, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00,
-  0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00,
-  0x09, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x39, 0x00, 0x00, 0x00,
-  0x01, 0x00, 0x00, 0x00, 0x50, 0x00, 0x07, 0x00, 0x0a, 0x00, 0x00, 0x00,
-  0x3e, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x00, 0x00,
-  0x3a, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00,
-  0x14, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00,
-  0x22, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x3f, 0x00, 0x00, 0x00,
-  0x3e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x42, 0x00, 0x00, 0x00,
-  0x43, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0xf8, 0x00, 0x02, 0x00,
-  0x26, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00,
-  0x47, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00,
-  0x06, 0x00, 0x00, 0x00, 0x49, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00,
-  0x6f, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00, 0x00,
-  0x49, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x09, 0x00, 0x00, 0x00,
-  0x4b, 0x00, 0x00, 0x00, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x51, 0x00, 0x05, 0x00, 0x09, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00,
-  0x47, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x50, 0x00, 0x06, 0x00,
-  0x40, 0x00, 0x00, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x4b, 0x00, 0x00, 0x00,
-  0x4c, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00,
-  0x42, 0x00, 0x00, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x41, 0x00, 0x07, 0x00,
-  0x53, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
-  0x50, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x52, 0x00, 0x00, 0x00,
-  0x3d, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00, 0x55, 0x00, 0x00, 0x00,
-  0x54, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x57, 0x00, 0x00, 0x00,
-  0x58, 0x00, 0x00, 0x00, 0x56, 0x00, 0x00, 0x00, 0x52, 0x00, 0x00, 0x00,
-  0x3d, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x00,
-  0x58, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, 0x09, 0x00, 0x00, 0x00,
-  0x5a, 0x00, 0x00, 0x00, 0x55, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x00,
-  0x41, 0x00, 0x07, 0x00, 0x53, 0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00,
-  0x0f, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x00, 0x00,
-  0x52, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00,
-  0x5c, 0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00,
-  0x57, 0x00, 0x00, 0x00, 0x5e, 0x00, 0x00, 0x00, 0x56, 0x00, 0x00, 0x00,
-  0x5d, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00,
-  0x5f, 0x00, 0x00, 0x00, 0x5e, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00,
-  0x09, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00,
-  0x5f, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x09, 0x00, 0x00, 0x00,
-  0x61, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00,
-  0x41, 0x00, 0x07, 0x00, 0x53, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00,
-  0x0f, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
-  0x52, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00,
-  0x63, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00,
-  0x09, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00,
-  0x63, 0x00, 0x00, 0x00, 0x41, 0x00, 0x07, 0x00, 0x53, 0x00, 0x00, 0x00,
-  0x65, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00,
-  0x22, 0x00, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00,
-  0x09, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x00,
-  0x41, 0x00, 0x05, 0x00, 0x57, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x00,
-  0x56, 0x00, 0x00, 0x00, 0x52, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00,
-  0x09, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x00,
-  0x85, 0x00, 0x05, 0x00, 0x09, 0x00, 0x00, 0x00, 0x69, 0x00, 0x00, 0x00,
-  0x66, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x41, 0x00, 0x07, 0x00,
-  0x53, 0x00, 0x00, 0x00, 0x6a, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
-  0x50, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x00,
+  0x41, 0x00, 0x05, 0x00, 0x11, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00,
+  0x0f, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00,
+  0x06, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00,
+  0xaa, 0x00, 0x05, 0x00, 0x19, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00,
+  0x17, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0xf7, 0x00, 0x03, 0x00,
+  0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfa, 0x00, 0x04, 0x00,
+  0x1a, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00,
+  0xf8, 0x00, 0x02, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00,
+  0x0a, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
+  0x3e, 0x00, 0x03, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00,
+  0xf9, 0x00, 0x02, 0x00, 0x1e, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00,
+  0x22, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x23, 0x00, 0x00, 0x00,
+  0x24, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00,
+  0x3d, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00,
+  0x24, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x1c, 0x00, 0x00, 0x00,
+  0x25, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x02, 0x00, 0x1e, 0x00, 0x00, 0x00,
+  0xf8, 0x00, 0x02, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00,
+  0x0a, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00,
+  0x3e, 0x00, 0x03, 0x00, 0x15, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00,
+  0x41, 0x00, 0x05, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00,
+  0x0f, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00,
+  0x0c, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00,
+  0x3e, 0x00, 0x03, 0x00, 0x28, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00,
+  0x41, 0x00, 0x05, 0x00, 0x11, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00,
+  0x0f, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00,
+  0x06, 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00,
+  0xab, 0x00, 0x05, 0x00, 0x19, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00,
+  0x2f, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0xf7, 0x00, 0x03, 0x00,
+  0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfa, 0x00, 0x04, 0x00,
+  0x30, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00,
+  0xf8, 0x00, 0x02, 0x00, 0x31, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00,
+  0x06, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00,
+  0xc4, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00,
+  0x38, 0x00, 0x00, 0x00, 0x39, 0x00, 0x00, 0x00, 0xc7, 0x00, 0x05, 0x00,
+  0x06, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00,
+  0x10, 0x00, 0x00, 0x00, 0x6f, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00,
+  0x3c, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00,
+  0x06, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00,
+  0xc7, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00,
+  0x3d, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x6f, 0x00, 0x04, 0x00,
+  0x09, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00,
+  0x50, 0x00, 0x05, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
+  0x3c, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x05, 0x00,
+  0x0b, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
+  0x41, 0x00, 0x00, 0x00, 0x50, 0x00, 0x05, 0x00, 0x0b, 0x00, 0x00, 0x00,
+  0x44, 0x00, 0x00, 0x00, 0x43, 0x00, 0x00, 0x00, 0x43, 0x00, 0x00, 0x00,
+  0x81, 0x00, 0x05, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00,
+  0x42, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00,
+  0x09, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x09, 0x00, 0x00, 0x00,
+  0x49, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+  0x50, 0x00, 0x07, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00, 0x00,
+  0x48, 0x00, 0x00, 0x00, 0x49, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00,
+  0x47, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x14, 0x00, 0x00, 0x00,
+  0x4b, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00,
+  0x3e, 0x00, 0x03, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00, 0x00,
+  0x3e, 0x00, 0x03, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00,
+  0xfd, 0x00, 0x01, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x32, 0x00, 0x00, 0x00,
+  0x3d, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x53, 0x00, 0x00, 0x00,
+  0x52, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00,
+  0x55, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x6f, 0x00, 0x04, 0x00,
+  0x09, 0x00, 0x00, 0x00, 0x56, 0x00, 0x00, 0x00, 0x55, 0x00, 0x00, 0x00,
+  0x51, 0x00, 0x05, 0x00, 0x09, 0x00, 0x00, 0x00, 0x57, 0x00, 0x00, 0x00,
+  0x53, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00,
+  0x09, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x53, 0x00, 0x00, 0x00,
+  0x01, 0x00, 0x00, 0x00, 0x50, 0x00, 0x06, 0x00, 0x4c, 0x00, 0x00, 0x00,
+  0x59, 0x00, 0x00, 0x00, 0x57, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00,
+  0x56, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x4e, 0x00, 0x00, 0x00,
+  0x59, 0x00, 0x00, 0x00, 0x41, 0x00, 0x07, 0x00, 0x5f, 0x00, 0x00, 0x00,
+  0x60, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00,
+  0x18, 0x00, 0x00, 0x00, 0x5e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00,
+  0x09, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00,
+  0x41, 0x00, 0x05, 0x00, 0x63, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00,
+  0x62, 0x00, 0x00, 0x00, 0x5e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00,
+  0x09, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00,
+  0x85, 0x00, 0x05, 0x00, 0x09, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00,
+  0x61, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x00, 0x41, 0x00, 0x07, 0x00,
+  0x5f, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
+  0x5c, 0x00, 0x00, 0x00, 0x39, 0x00, 0x00, 0x00, 0x5e, 0x00, 0x00, 0x00,
+  0x3d, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00,
+  0x67, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x63, 0x00, 0x00, 0x00,
+  0x6a, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x69, 0x00, 0x00, 0x00,
   0x3d, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, 0x00,
-  0x6a, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x57, 0x00, 0x00, 0x00,
-  0x6c, 0x00, 0x00, 0x00, 0x56, 0x00, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x00,
-  0x3d, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x00,
-  0x6c, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, 0x09, 0x00, 0x00, 0x00,
-  0x6e, 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x00,
-  0x81, 0x00, 0x05, 0x00, 0x09, 0x00, 0x00, 0x00, 0x6f, 0x00, 0x00, 0x00,
-  0x69, 0x00, 0x00, 0x00, 0x6e, 0x00, 0x00, 0x00, 0x41, 0x00, 0x07, 0x00,
-  0x53, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
-  0x50, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x00,
-  0x3d, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00,
-  0x70, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x09, 0x00, 0x00, 0x00,
-  0x72, 0x00, 0x00, 0x00, 0x6f, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00,
-  0x50, 0x00, 0x05, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x73, 0x00, 0x00, 0x00,
-  0x64, 0x00, 0x00, 0x00, 0x72, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00,
-  0x4f, 0x00, 0x00, 0x00, 0x73, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00,
-  0x0b, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00,
-  0x85, 0x00, 0x05, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x76, 0x00, 0x00, 0x00,
-  0x74, 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00,
-  0x77, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
-  0x2d, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00,
-  0x79, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x88, 0x00, 0x05, 0x00,
-  0x0b, 0x00, 0x00, 0x00, 0x7a, 0x00, 0x00, 0x00, 0x76, 0x00, 0x00, 0x00,
-  0x79, 0x00, 0x00, 0x00, 0x83, 0x00, 0x05, 0x00, 0x0b, 0x00, 0x00, 0x00,
-  0x7c, 0x00, 0x00, 0x00, 0x7a, 0x00, 0x00, 0x00, 0x7b, 0x00, 0x00, 0x00,
-  0x51, 0x00, 0x05, 0x00, 0x09, 0x00, 0x00, 0x00, 0x7d, 0x00, 0x00, 0x00,
-  0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00,
-  0x09, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00,
-  0x01, 0x00, 0x00, 0x00, 0x50, 0x00, 0x07, 0x00, 0x0a, 0x00, 0x00, 0x00,
-  0x7f, 0x00, 0x00, 0x00, 0x7d, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00,
-  0x3a, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00,
-  0x14, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00,
-  0x22, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x80, 0x00, 0x00, 0x00,
-  0x7f, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00
+  0x6a, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, 0x09, 0x00, 0x00, 0x00,
+  0x6c, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, 0x00,
+  0x81, 0x00, 0x05, 0x00, 0x09, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x00,
+  0x66, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x41, 0x00, 0x07, 0x00,
+  0x5f, 0x00, 0x00, 0x00, 0x6e, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
+  0x5c, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x5e, 0x00, 0x00, 0x00,
+  0x3d, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00, 0x6f, 0x00, 0x00, 0x00,
+  0x6e, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x09, 0x00, 0x00, 0x00,
+  0x70, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x00, 0x6f, 0x00, 0x00, 0x00,
+  0x41, 0x00, 0x07, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00,
+  0x0f, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00,
+  0x69, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00,
+  0x72, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00,
+  0x63, 0x00, 0x00, 0x00, 0x73, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00,
+  0x5e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00,
+  0x74, 0x00, 0x00, 0x00, 0x73, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00,
+  0x09, 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, 0x72, 0x00, 0x00, 0x00,
+  0x74, 0x00, 0x00, 0x00, 0x41, 0x00, 0x07, 0x00, 0x5f, 0x00, 0x00, 0x00,
+  0x76, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00,
+  0x39, 0x00, 0x00, 0x00, 0x69, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00,
+  0x09, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x76, 0x00, 0x00, 0x00,
+  0x41, 0x00, 0x05, 0x00, 0x63, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00,
+  0x62, 0x00, 0x00, 0x00, 0x69, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00,
+  0x09, 0x00, 0x00, 0x00, 0x79, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00,
+  0x85, 0x00, 0x05, 0x00, 0x09, 0x00, 0x00, 0x00, 0x7a, 0x00, 0x00, 0x00,
+  0x77, 0x00, 0x00, 0x00, 0x79, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00,
+  0x09, 0x00, 0x00, 0x00, 0x7b, 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00,
+  0x7a, 0x00, 0x00, 0x00, 0x41, 0x00, 0x07, 0x00, 0x5f, 0x00, 0x00, 0x00,
+  0x7c, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00,
+  0x10, 0x00, 0x00, 0x00, 0x69, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00,
+  0x09, 0x00, 0x00, 0x00, 0x7d, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00,
+  0x81, 0x00, 0x05, 0x00, 0x09, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00,
+  0x7b, 0x00, 0x00, 0x00, 0x7d, 0x00, 0x00, 0x00, 0x50, 0x00, 0x05, 0x00,
+  0x0b, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
+  0x7e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x5b, 0x00, 0x00, 0x00,
+  0x7f, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00,
+  0x80, 0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00,
+  0x0b, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
+  0x81, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x83, 0x00, 0x00, 0x00,
+  0x84, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x39, 0x00, 0x00, 0x00,
+  0x3d, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00,
+  0x84, 0x00, 0x00, 0x00, 0x88, 0x00, 0x05, 0x00, 0x0b, 0x00, 0x00, 0x00,
+  0x86, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00,
+  0x83, 0x00, 0x05, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00,
+  0x86, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00,
+  0x09, 0x00, 0x00, 0x00, 0x89, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x09, 0x00, 0x00, 0x00,
+  0x8a, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+  0x50, 0x00, 0x07, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x8b, 0x00, 0x00, 0x00,
+  0x89, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00,
+  0x47, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x14, 0x00, 0x00, 0x00,
+  0x8c, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00,
+  0x3e, 0x00, 0x03, 0x00, 0x8c, 0x00, 0x00, 0x00, 0x8b, 0x00, 0x00, 0x00,
+  0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00
 };
-unsigned int vkvg_main_vert_spv_len = 3480;
+unsigned int vkvg_main_vert_spv_len = 3704;
 unsigned char vkvg_main_lcd_frag_spv[] = {
   0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x0d, 0x00,
   0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00,
index 186aaff3dd16ba2972ebc7a55705a65c4842eb64..047ccaa245170dc07d03815fda697f7dfadcd173 100644 (file)
@@ -126,7 +126,10 @@ VkvgContext vkvg_create(VkvgSurface surf)
 
     _create_vertices_buff   (ctx);
     _create_gradient_buff   (ctx);
-    _create_cmd_buff        (ctx);
+
+    vkh_cmd_buffs_create    ((VkhDevice)ctx->pSurf->dev, ctx->cmdPool,
+                             VK_COMMAND_BUFFER_LEVEL_PRIMARY, 2, ctx->cmdBuffers);
+
     if (CmdPushDescriptorSet) {
         _init_push_descriptor_writes(ctx);
     }else{
@@ -145,6 +148,20 @@ VkvgContext vkvg_create(VkvgSurface surf)
 
     LOG(LOG_DBG_ARRAYS, "START\tctx = %lu; pathes:%d pts:%d vch:%d vbo:%d ich:%d ibo:%d\n", ctx, ctx->sizePathes, ctx->sizePoints, ctx->sizeVertices, ctx->sizeVBO, ctx->sizeIndices, ctx->sizeIBO);
 
+#ifdef DEBUG
+    vkh_device_set_object_name((VkhDevice)dev, VK_OBJECT_TYPE_COMMAND_POOL, (uint64_t)ctx->cmdPool, "CTX Cmd Pool");
+    vkh_device_set_object_name((VkhDevice)dev, VK_OBJECT_TYPE_COMMAND_BUFFER, (uint64_t)ctx->cmdBuffers[0], "CTX Cmd Buff A");
+    vkh_device_set_object_name((VkhDevice)dev, VK_OBJECT_TYPE_COMMAND_BUFFER, (uint64_t)ctx->cmdBuffers[1], "CTX Cmd Buff B");
+    vkh_device_set_object_name((VkhDevice)dev, VK_OBJECT_TYPE_FENCE, (uint64_t)ctx->flushFence, "CTX Flush Fence");
+
+    if (!CmdPushDescriptorSet) {
+        vkh_device_set_object_name((VkhDevice)dev, VK_OBJECT_TYPE_DESCRIPTOR_POOL, (uint64_t)ctx->descriptorPool, "CTX Descriptor Pool");
+        vkh_device_set_object_name((VkhDevice)dev, VK_OBJECT_TYPE_DESCRIPTOR_SET, (uint64_t)ctx->dsSrc, "CTX Single DescSet");
+    }
+    vkh_device_set_object_name((VkhDevice)dev, VK_OBJECT_TYPE_BUFFER, (uint64_t)ctx->indices.buffer, "CTX Index Buff");
+    vkh_device_set_object_name((VkhDevice)dev, VK_OBJECT_TYPE_BUFFER, (uint64_t)ctx->vertices.buffer, "CTX Vertex Buff");
+#endif
+
     return ctx;
 }
 /**
@@ -728,7 +745,7 @@ void vkvg_stroke_preserve (VkvgContext ctx)
 }
 void vkvg_paint (VkvgContext ctx){
     _check_cmd_buff_state (ctx);
-    if (ctx->pattern == NULL || ctx->pattern->type == VKVG_PATTERN_TYPE_SOLID){
+    /*if (ctx->pattern == NULL || ctx->pattern->type == VKVG_PATTERN_TYPE_SOLID){
         //add full screen rect untransformed with current color, no need of push constant update -> no flush requested
         _vao_add_rectangle (ctx, 0, 0, ctx->bounds.extent.width, ctx->bounds.extent.height);
         return;
@@ -743,7 +760,8 @@ void vkvg_paint (VkvgContext ctx){
     }else{//if current transformation is not identity, full screen quad has to be untransformed
         //cur transform will be applied in fs for each pixel.
         _vao_add_rectangle (ctx, 0, 0, ctx->bounds.extent.width, ctx->bounds.extent.height);
-    }
+    }*/
+    _vao_add_rectangle (ctx, 0, 0, ctx->bounds.extent.width, ctx->bounds.extent.height);
     //_draw_full_screen_quad (ctx, true);
 }
 inline void vkvg_set_source_rgb (VkvgContext ctx, float r, float g, float b) {
index f832ea37091b8307486036cb54edb2e5b915d2a5..45261fe2581d21906509cd187ef24d362e97349c 100644 (file)
 #include "vkh_queue.h"
 #include "vkh_image.h"
 
+const float LAB_COLOR_RP[4] = {0,0,1,1};
+const float LAB_COLOR_FLUSH[4] = {0,1,1,1};
+
 void _check_vbo_size (VkvgContext ctx) {
-    if (ctx->sizeVertices - ctx->vertCount > VKVG_ARRAY_THRESHOLD)
-        return;
-    ctx->sizeVertices += VKVG_VBO_SIZE;
-    Vertex* tmp = (Vertex*) realloc (ctx->vertexCache, ctx->sizeVertices * sizeof(Vertex));
-    if (tmp == NULL)
-        ctx->status = VKVG_STATUS_NO_MEMORY;
-    else
-        ctx->vertexCache = tmp;
+       if (ctx->sizeVertices - ctx->vertCount > VKVG_ARRAY_THRESHOLD)
+               return;
+       ctx->sizeVertices += VKVG_VBO_SIZE;
+       Vertex* tmp = (Vertex*) realloc (ctx->vertexCache, ctx->sizeVertices * sizeof(Vertex));
+       if (tmp == NULL)
+               ctx->status = VKVG_STATUS_NO_MEMORY;
+       else
+               ctx->vertexCache = tmp;
 }
 void _check_ibo_size (VkvgContext ctx) {
-    if (ctx->sizeIndices - ctx->indCount > VKVG_ARRAY_THRESHOLD)
-        return;
-    ctx->sizeIndices += VKVG_IBO_SIZE;
-    VKVG_IBO_INDEX_TYPE* tmp = (VKVG_IBO_INDEX_TYPE*) realloc (ctx->indexCache, ctx->sizeIndices * sizeof(VKVG_IBO_INDEX_TYPE));
-    if (tmp == NULL)
-        ctx->status = VKVG_STATUS_NO_MEMORY;
-    else
-        ctx->indexCache = tmp;
+       if (ctx->sizeIndices - ctx->indCount > VKVG_ARRAY_THRESHOLD)
+               return;
+       ctx->sizeIndices += VKVG_IBO_SIZE;
+       VKVG_IBO_INDEX_TYPE* tmp = (VKVG_IBO_INDEX_TYPE*) realloc (ctx->indexCache, ctx->sizeIndices * sizeof(VKVG_IBO_INDEX_TYPE));
+       if (tmp == NULL)
+               ctx->status = VKVG_STATUS_NO_MEMORY;
+       else
+               ctx->indexCache = tmp;
 }
 void _check_pathes_array (VkvgContext ctx){
-    if (ctx->sizePathes - ctx->pathPtr - ctx->curvePtr > VKVG_ARRAY_THRESHOLD)
-        return;
-    ctx->sizePathes += VKVG_PATHES_SIZE;
-    uint32_t* tmp = (uint32_t*) realloc (ctx->pathes, ctx->sizePathes * sizeof(uint32_t));
-    if (tmp == NULL){
-        ctx->status = VKVG_STATUS_NO_MEMORY;
-        ctx->pathPtr = 0 + (ctx->pathPtr % 2);
-    }else
-        ctx->pathes = tmp;
+       if (ctx->sizePathes - ctx->pathPtr - ctx->curvePtr > VKVG_ARRAY_THRESHOLD)
+               return;
+       ctx->sizePathes += VKVG_PATHES_SIZE;
+       uint32_t* tmp = (uint32_t*) realloc (ctx->pathes, ctx->sizePathes * sizeof(uint32_t));
+       if (tmp == NULL){
+               ctx->status = VKVG_STATUS_NO_MEMORY;
+               ctx->pathPtr = 0 + (ctx->pathPtr % 2);
+       }else
+               ctx->pathes = tmp;
 }
 void _check_point_array (VkvgContext ctx){
-    if (ctx->sizePoints - ctx->pointCount > VKVG_ARRAY_THRESHOLD)
-        return;
-    ctx->sizePoints += VKVG_PATHES_SIZE;
-    vec2* tmp = (vec2*) realloc (ctx->points, ctx->sizePoints * sizeof(vec2));
-    if (tmp == NULL){
-        ctx->status = VKVG_STATUS_NO_MEMORY;
-        ctx->pointCount = 0;
-    }else
-        ctx->points = tmp;
+       if (ctx->sizePoints - ctx->pointCount > VKVG_ARRAY_THRESHOLD)
+               return;
+       ctx->sizePoints += VKVG_PATHES_SIZE;
+       vec2* tmp = (vec2*) realloc (ctx->points, ctx->sizePoints * sizeof(vec2));
+       if (tmp == NULL){
+               ctx->status = VKVG_STATUS_NO_MEMORY;
+               ctx->pointCount = 0;
+       }else
+               ctx->points = tmp;
 }
 //when empty, ptr is even, else it's odd
 //when empty, no current point is defined.
 inline bool _current_path_is_empty (VkvgContext ctx) {
-    return ctx->pathPtr % 2 == 0;
+       return ctx->pathPtr % 2 == 0;
 }
 //this function expect that current point exists
 inline vec2 _get_current_position (VkvgContext ctx) {
-    return ctx->points[ctx->pointCount-1];
+       return ctx->points[ctx->pointCount-1];
 }
 //set curve start point and set path has curve bit
 inline void _set_curve_start (VkvgContext ctx) {
-    ctx->pathes[ctx->pathPtr+ctx->curvePtr+1] = (ctx->pointCount - 1);
-    ctx->pathes[ctx->pathPtr-1] |= PATH_HAS_CURVES_BIT;
+       ctx->pathes[ctx->pathPtr+ctx->curvePtr+1] = (ctx->pointCount - 1);
+       ctx->pathes[ctx->pathPtr-1] |= PATH_HAS_CURVES_BIT;
 }
 //set curve end point and set path has curve bit
 inline void _set_curve_end (VkvgContext ctx) {
-    ctx->pathes[ctx->pathPtr+ctx->curvePtr+2] = (ctx->pointCount - 1)|PATH_IS_CURVE_BIT;
-    ctx->curvePtr+=2;
-    _check_pathes_array(ctx);
+       ctx->pathes[ctx->pathPtr+ctx->curvePtr+2] = (ctx->pointCount - 1)|PATH_IS_CURVE_BIT;
+       ctx->curvePtr+=2;
+       _check_pathes_array(ctx);
 }
 //path start pointed at ptrPath has curve bit
 inline bool _path_has_curves (VkvgContext ctx, uint ptrPath) {
-    return ctx->pathes[ptrPath] & PATH_HAS_CURVES_BIT;
+       return ctx->pathes[ptrPath] & PATH_HAS_CURVES_BIT;
 }
 //this function expect that current path is empty
 void _start_sub_path (VkvgContext ctx, float x, float y) {
-    //set start to current idx in point array
-    ctx->pathes[ctx->pathPtr] = ctx->pointCount;
-    _add_point(ctx, x, y);
-    _check_pathes_array(ctx);
-    ctx->pathPtr++;
+       //set start to current idx in point array
+       ctx->pathes[ctx->pathPtr] = ctx->pointCount;
+       _add_point(ctx, x, y);
+       _check_pathes_array(ctx);
+       ctx->pathPtr++;
 }
 void _finish_path (VkvgContext ctx){
-    if (_current_path_is_empty(ctx))
-        return;
-    if ((ctx->pathes[ctx->pathPtr-1]&PATH_ELT_MASK) == ctx->pointCount - 1){
-        //only current pos is in path
-        ctx->pathPtr--;
-        return;
-    }
-
-    //set end index of current path to last point in points array
-    ctx->pathes[ctx->pathPtr] = ctx->pointCount - 1;
-    _check_pathes_array(ctx);
-    ctx->pathPtr += ctx->curvePtr + 1;
-    ctx->curvePtr = 0;
+       if (_current_path_is_empty(ctx))
+               return;
+       if ((ctx->pathes[ctx->pathPtr-1]&PATH_ELT_MASK) == ctx->pointCount - 1){
+               //only current pos is in path
+               ctx->pathPtr--;
+               return;
+       }
+
+       //set end index of current path to last point in points array
+       ctx->pathes[ctx->pathPtr] = ctx->pointCount - 1;
+       _check_pathes_array(ctx);
+       ctx->pathPtr += ctx->curvePtr + 1;
+       ctx->curvePtr = 0;
 }
 void _clear_path (VkvgContext ctx){
-    ctx->pathPtr = 0;
-    ctx->pointCount = 0;
-    ctx->curvePtr = 0;
-    _resetMinMax(ctx);
+       ctx->pathPtr = 0;
+       ctx->pointCount = 0;
+       ctx->curvePtr = 0;
+       //_resetMinMax(ctx);
 }
 inline bool _path_is_closed (VkvgContext ctx, uint32_t ptrPath){
-    return ctx->pathes[ptrPath] & PATH_CLOSED_BIT;
-}
-void _resetMinMax (VkvgContext ctx) {
-    ctx->xMin = ctx->yMin = FLT_MAX;
-    ctx->xMax = ctx->yMax = FLT_MIN;
+       return ctx->pathes[ptrPath] & PATH_CLOSED_BIT;
 }
+/*void _resetMinMax (VkvgContext ctx) {
+       ctx->xMin = ctx->yMin = FLT_MAX;
+       ctx->xMax = ctx->yMax = FLT_MIN;
+}*/
 void _add_point (VkvgContext ctx, float x, float y){
-    ctx->points[ctx->pointCount] = (vec2){x,y};
-    ctx->pointCount++;
-
-    _check_point_array(ctx);
-
-    //bounds are computed here to scissor the painting operation
-    //that speed up fill drastically.
-    vkvg_matrix_transform_point (&ctx->pushConsts.mat, &x, &y);
-
-    if (x < ctx->xMin)
-        ctx->xMin = x;
-    if (x > ctx->xMax)
-        ctx->xMax = x;
-    if (y < ctx->yMin)
-        ctx->yMin = y;
-    if (y > ctx->yMax)
-        ctx->yMax = y;
+       ctx->points[ctx->pointCount] = (vec2){x,y};
+       ctx->pointCount++;
+
+       _check_point_array(ctx);
+
+       //bounds are computed here to scissor the painting operation
+       //that speed up fill drastically.
+       /*vkvg_matrix_transform_point (&ctx->pushConsts.mat, &x, &y);
+
+       if (x < ctx->xMin)
+               ctx->xMin = x;
+       if (x > ctx->xMax)
+               ctx->xMax = x;
+       if (y < ctx->yMin)
+               ctx->yMin = y;
+       if (y > ctx->yMax)
+               ctx->yMax = y;*/
 }
 float _normalizeAngle(float a)
 {
-    float res = ROUND_DOWN(fmodf(a,2.0f*M_PIF),100);
-    if (res < 0.0f)
-        return res + 2.0f*M_PIF;
-    else
-        return res;
+       float res = ROUND_DOWN(fmodf(a,2.0f*M_PIF),100);
+       if (res < 0.0f)
+               return res + 2.0f*M_PIF;
+       else
+               return res;
 }
 inline float _get_arc_step (float radius) {
-    return M_PIF/sqrtf(radius)*0.35f;
+       return M_PIF/sqrtf(radius)*0.35f;
 }
 void _create_gradient_buff (VkvgContext ctx){
-    vkvg_buffer_create (ctx->pSurf->dev,
-        VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
-        VMA_MEMORY_USAGE_CPU_TO_GPU,
-        sizeof(vkvg_gradient_t), &ctx->uboGrad);
+       vkvg_buffer_create (ctx->pSurf->dev,
+               VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
+               VMA_MEMORY_USAGE_CPU_TO_GPU,
+               sizeof(vkvg_gradient_t), &ctx->uboGrad);
 }
 void _create_vertices_buff (VkvgContext ctx){
-    vkvg_buffer_create (ctx->pSurf->dev,
-        VK_BUFFER_USAGE_VERTEX_BUFFER_BIT,
-        VMA_MEMORY_USAGE_CPU_TO_GPU,
-        ctx->sizeVBO * sizeof(Vertex), &ctx->vertices);
-    vkvg_buffer_create (ctx->pSurf->dev,
-        VK_BUFFER_USAGE_INDEX_BUFFER_BIT,
-        VMA_MEMORY_USAGE_CPU_TO_GPU,
-        ctx->sizeIBO * sizeof(VKVG_IBO_INDEX_TYPE), &ctx->indices);
+       vkvg_buffer_create (ctx->pSurf->dev,
+               VK_BUFFER_USAGE_VERTEX_BUFFER_BIT,
+               VMA_MEMORY_USAGE_CPU_TO_GPU,
+               ctx->sizeVBO * sizeof(Vertex), &ctx->vertices);
+       vkvg_buffer_create (ctx->pSurf->dev,
+               VK_BUFFER_USAGE_INDEX_BUFFER_BIT,
+               VMA_MEMORY_USAGE_CPU_TO_GPU,
+               ctx->sizeIBO * sizeof(VKVG_IBO_INDEX_TYPE), &ctx->indices);
 }
 void _resize_vbo (VkvgContext ctx, size_t new_size) {
-    _wait_flush_fence (ctx);//wait previous cmd if not completed
-    ctx->sizeVBO = new_size;
-    ctx->sizeVBO += ctx->sizeVBO % VKVG_VBO_SIZE;
-    vkvg_buffer_destroy (&ctx->vertices);
-    vkvg_buffer_create (ctx->pSurf->dev,
-        VK_BUFFER_USAGE_VERTEX_BUFFER_BIT,
-        VMA_MEMORY_USAGE_CPU_TO_GPU,
-        ctx->sizeVBO * sizeof(Vertex), &ctx->vertices);
+       _wait_flush_fence (ctx);//wait previous cmd if not completed
+       ctx->sizeVBO = new_size;
+       ctx->sizeVBO += ctx->sizeVBO % VKVG_VBO_SIZE;
+       vkvg_buffer_destroy (&ctx->vertices);
+       vkvg_buffer_create (ctx->pSurf->dev,
+               VK_BUFFER_USAGE_VERTEX_BUFFER_BIT,
+               VMA_MEMORY_USAGE_CPU_TO_GPU,
+               ctx->sizeVBO * sizeof(Vertex), &ctx->vertices);
 }
 void _resize_ibo (VkvgContext ctx, size_t new_size) {
-    _wait_flush_fence (ctx);//wait previous cmd if not completed
-    ctx->sizeIBO = new_size;
-    ctx->sizeIBO += ctx->sizeIBO % VKVG_IBO_SIZE;
-    vkvg_buffer_destroy (&ctx->indices);
-    vkvg_buffer_create (ctx->pSurf->dev,
-        VK_BUFFER_USAGE_INDEX_BUFFER_BIT,
-        VMA_MEMORY_USAGE_CPU_TO_GPU,
-        ctx->sizeIBO * sizeof(VKVG_IBO_INDEX_TYPE), &ctx->indices);
+       _wait_flush_fence (ctx);//wait previous cmd if not completed
+       ctx->sizeIBO = new_size;
+       ctx->sizeIBO += ctx->sizeIBO % VKVG_IBO_SIZE;
+       vkvg_buffer_destroy (&ctx->indices);
+       vkvg_buffer_create (ctx->pSurf->dev,
+               VK_BUFFER_USAGE_INDEX_BUFFER_BIT,
+               VMA_MEMORY_USAGE_CPU_TO_GPU,
+               ctx->sizeIBO * sizeof(VKVG_IBO_INDEX_TYPE), &ctx->indices);
 }
 void _add_vertexf (VkvgContext ctx, float x, float y){
-    Vertex* pVert = &ctx->vertexCache[ctx->vertCount];
-    pVert->pos.x = x;
-    pVert->pos.y = y;
-    pVert->color = ctx->curColor;
-    pVert->uvZ = -1;
-    ctx->vertCount++;
-
-    _check_vbo_size(ctx);
+       Vertex* pVert = &ctx->vertexCache[ctx->vertCount];
+       pVert->pos.x = x;
+       pVert->pos.y = y;
+       pVert->color = ctx->curColor;
+       pVert->uvZ = -1;
+       ctx->vertCount++;
+
+       _check_vbo_size(ctx);
 }
 void _add_vertex(VkvgContext ctx, Vertex v){
-    ctx->vertexCache[ctx->vertCount] = v;
-    ctx->vertCount++;
+       ctx->vertexCache[ctx->vertCount] = v;
+       ctx->vertCount++;
 
-    _check_vbo_size(ctx);
+       _check_vbo_size(ctx);
 }
 void _set_vertex(VkvgContext ctx, uint32_t idx, Vertex v){
-    ctx->vertexCache[idx] = v;
+       ctx->vertexCache[idx] = v;
 }
 void _add_tri_indices_for_rect (VkvgContext ctx, VKVG_IBO_INDEX_TYPE i){
-    VKVG_IBO_INDEX_TYPE* inds = &ctx->indexCache[ctx->indCount];
-    inds[0] = i;
-    inds[1] = i+2;
-    inds[2] = i+1;
-    inds[3] = i+1;
-    inds[4] = i+2;
-    inds[5] = i+3;
-    ctx->indCount+=6;
-
-    _check_ibo_size(ctx);
+       VKVG_IBO_INDEX_TYPE* inds = &ctx->indexCache[ctx->indCount];
+       inds[0] = i;
+       inds[1] = i+2;
+       inds[2] = i+1;
+       inds[3] = i+1;
+       inds[4] = i+2;
+       inds[5] = i+3;
+       ctx->indCount+=6;
+
+       _check_ibo_size(ctx);
 }
 void _add_triangle_indices(VkvgContext ctx, VKVG_IBO_INDEX_TYPE i0, VKVG_IBO_INDEX_TYPE i1, VKVG_IBO_INDEX_TYPE i2){
-    VKVG_IBO_INDEX_TYPE* inds = &ctx->indexCache[ctx->indCount];
-    inds[0] = i0;
-    inds[1] = i1;
-    inds[2] = i2;
-    ctx->indCount+=3;
+       VKVG_IBO_INDEX_TYPE* inds = &ctx->indexCache[ctx->indCount];
+       inds[0] = i0;
+       inds[1] = i1;
+       inds[2] = i2;
+       ctx->indCount+=3;
 
-    _check_ibo_size(ctx);
+       _check_ibo_size(ctx);
 }
 void _vao_add_rectangle (VkvgContext ctx, float x, float y, float width, float height){
-    Vertex v[4] =
-    {
-        {{x,y},             ctx->curColor, {0,0},-1},
-        {{x,y+height},      ctx->curColor, {0,0},-1},
-        {{x+width,y},       ctx->curColor, {0,0},-1},
-        {{x+width,y+height},ctx->curColor, {0,0},-1}
-    };
-    VKVG_IBO_INDEX_TYPE firstIdx = ctx->vertCount - ctx->curVertOffset;
-    Vertex* pVert = &ctx->vertexCache[ctx->vertCount];
-    memcpy (pVert,v,4*sizeof(Vertex));
-    ctx->vertCount+=4;
-
-    _check_vbo_size(ctx);
-
-    _add_tri_indices_for_rect(ctx, firstIdx);
+       Vertex v[4] =
+       {
+               {{x,y},             ctx->curColor, {0,0},-1},
+               {{x,y+height},      ctx->curColor, {0,0},-1},
+               {{x+width,y},       ctx->curColor, {0,0},-1},
+               {{x+width,y+height},ctx->curColor, {0,0},-1}
+       };
+       VKVG_IBO_INDEX_TYPE firstIdx = ctx->vertCount - ctx->curVertOffset;
+       Vertex* pVert = &ctx->vertexCache[ctx->vertCount];
+       memcpy (pVert,v,4*sizeof(Vertex));
+       ctx->vertCount+=4;
+
+       _check_vbo_size(ctx);
+
+       _add_tri_indices_for_rect(ctx, firstIdx);
 }
 
 void _check_cmd_buff_state (VkvgContext ctx) {
-    if (!ctx->cmdStarted)
-        _start_cmd_for_render_pass(ctx);
-    else if (ctx->pushCstDirty)
-        _update_push_constants(ctx);
-}
-void _create_cmd_buff (VkvgContext ctx){
-    vkh_cmd_buffs_create((VkhDevice)ctx->pSurf->dev, ctx->cmdPool,VK_COMMAND_BUFFER_LEVEL_PRIMARY, 2, ctx->cmdBuffers);
-#if defined(DEBUG) && defined(ENABLE_VALIDATION)
-    vkh_device_set_object_name((VkhDevice)ctx->pSurf->dev, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, (uint64_t)ctx->cmd, "vkvgCtxCmd");
-#endif
+       if (!ctx->cmdStarted)
+               _start_cmd_for_render_pass(ctx);
+       else if (ctx->pushCstDirty)
+               _update_push_constants(ctx);
 }
 void _clear_attachment (VkvgContext ctx) {
 
 }
 inline void _wait_flush_fence (VkvgContext ctx) {
-    vkWaitForFences (ctx->pSurf->dev->vkDev, 1, &ctx->flushFence, VK_TRUE, VKVG_FENCE_TIMEOUT);
+       vkWaitForFences (ctx->pSurf->dev->vkDev, 1, &ctx->flushFence, VK_TRUE, VKVG_FENCE_TIMEOUT);
 }
 inline void _reset_flush_fence (VkvgContext ctx) {
-    vkResetFences (ctx->pSurf->dev->vkDev, 1, &ctx->flushFence);
+       vkResetFences (ctx->pSurf->dev->vkDev, 1, &ctx->flushFence);
 }
 void _wait_and_submit_cmd (VkvgContext ctx){
-    if (!ctx->cmdStarted)
-        return;
+       if (!ctx->cmdStarted)
+               return;
 
-    _wait_flush_fence (ctx);
-    _reset_flush_fence(ctx);
+       _wait_flush_fence (ctx);
+       _reset_flush_fence(ctx);
 
-    _submit_cmd (ctx->pSurf->dev, &ctx->cmd, ctx->flushFence);
+       _submit_cmd (ctx->pSurf->dev, &ctx->cmd, ctx->flushFence);
 
-    if (ctx->cmd == ctx->cmdBuffers[0])
-        ctx->cmd = ctx->cmdBuffers[1];
-    else
-        ctx->cmd = ctx->cmdBuffers[0];
+       if (ctx->cmd == ctx->cmdBuffers[0])
+               ctx->cmd = ctx->cmdBuffers[1];
+       else
+               ctx->cmd = ctx->cmdBuffers[0];
 
-    vkResetCommandBuffer (ctx->cmd, 0);
-    ctx->cmdStarted = false;
+       vkResetCommandBuffer (ctx->cmd, 0);
+       ctx->cmdStarted = false;
 }
 /*void _explicit_ms_resolve (VkvgContext ctx){//should init cmd before calling this (unused, using automatic resolve by renderpass)
-    vkh_image_set_layout (ctx->cmd, ctx->pSurf->imgMS, VK_IMAGE_ASPECT_COLOR_BIT,
-                          VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
-                          VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
-    vkh_image_set_layout (ctx->cmd, ctx->pSurf->img, VK_IMAGE_ASPECT_COLOR_BIT,
-                          VK_IMAGE_LAYOUT_GENERAL, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
-                          VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
-
-    VkImageResolve re = {
-        .extent = {ctx->pSurf->width, ctx->pSurf->height,1},
-        .srcSubresource = {VK_IMAGE_ASPECT_COLOR_BIT,0,0,1},
-        .dstSubresource = {VK_IMAGE_ASPECT_COLOR_BIT,0,0,1}
-    };
-
-    vkCmdResolveImage(ctx->cmd,
-                      vkh_image_get_vkimage (ctx->pSurf->imgMS), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
-                      vkh_image_get_vkimage (ctx->pSurf->img) ,VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
-                      1,&re);
-    vkh_image_set_layout (ctx->cmd, ctx->pSurf->imgMS, VK_IMAGE_ASPECT_COLOR_BIT,
-                          VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL ,
-                          VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
+       vkh_image_set_layout (ctx->cmd, ctx->pSurf->imgMS, VK_IMAGE_ASPECT_COLOR_BIT,
+                                                 VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
+                                                 VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
+       vkh_image_set_layout (ctx->cmd, ctx->pSurf->img, VK_IMAGE_ASPECT_COLOR_BIT,
+                                                 VK_IMAGE_LAYOUT_GENERAL, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
+                                                 VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
+
+       VkImageResolve re = {
+               .extent = {ctx->pSurf->width, ctx->pSurf->height,1},
+               .srcSubresource = {VK_IMAGE_ASPECT_COLOR_BIT,0,0,1},
+               .dstSubresource = {VK_IMAGE_ASPECT_COLOR_BIT,0,0,1}
+       };
+
+       vkCmdResolveImage(ctx->cmd,
+                                         vkh_image_get_vkimage (ctx->pSurf->imgMS), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
+                                         vkh_image_get_vkimage (ctx->pSurf->img) ,VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
+                                         1,&re);
+       vkh_image_set_layout (ctx->cmd, ctx->pSurf->imgMS, VK_IMAGE_ASPECT_COLOR_BIT,
+                                                 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL ,
+                                                 VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
 }*/
 
 //pre flush vertices because of vbo or ibo too small, all vertices except last draw call are flushed
 //this function expects a vertex offset > 0
 void _flush_vertices_caches_until_vertex_base (VkvgContext ctx) {
-    _wait_flush_fence (ctx);
+       _wait_flush_fence (ctx);
 
-    memcpy(ctx->vertices.allocInfo.pMappedData, ctx->vertexCache, ctx->curVertOffset * sizeof (Vertex));
-    memcpy(ctx->indices.allocInfo.pMappedData, ctx->indexCache, ctx->curIndStart * sizeof (VKVG_IBO_INDEX_TYPE));
+       memcpy(ctx->vertices.allocInfo.pMappedData, ctx->vertexCache, ctx->curVertOffset * sizeof (Vertex));
+       memcpy(ctx->indices.allocInfo.pMappedData, ctx->indexCache, ctx->curIndStart * sizeof (VKVG_IBO_INDEX_TYPE));
 
-    //copy remaining vertices and indices to caches starts
-    ctx->vertCount -= ctx->curVertOffset;
-    ctx->indCount -= ctx->curIndStart;
-    memcpy(ctx->vertexCache, &ctx->vertexCache[ctx->curVertOffset], ctx->vertCount * sizeof (Vertex));
-    memcpy(ctx->indexCache, &ctx->indexCache[ctx->curIndStart], ctx->indCount * sizeof (VKVG_IBO_INDEX_TYPE));
+       //copy remaining vertices and indices to caches starts
+       ctx->vertCount -= ctx->curVertOffset;
+       ctx->indCount -= ctx->curIndStart;
+       memcpy(ctx->vertexCache, &ctx->vertexCache[ctx->curVertOffset], ctx->vertCount * sizeof (Vertex));
+       memcpy(ctx->indexCache, &ctx->indexCache[ctx->curIndStart], ctx->indCount * sizeof (VKVG_IBO_INDEX_TYPE));
 
-    ctx->curVertOffset = 0;
-    ctx->curIndStart = 0;
+       ctx->curVertOffset = 0;
+       ctx->curIndStart = 0;
 }
 void _flush_vertices_caches (VkvgContext ctx) {
-    //copy vertex and index caches to the vbo and ibo vkbuffers
-    _wait_flush_fence (ctx);
+       //copy vertex and index caches to the vbo and ibo vkbuffers
+       _wait_flush_fence (ctx);
 
-    memcpy(ctx->vertices.allocInfo.pMappedData, ctx->vertexCache, ctx->vertCount * sizeof (Vertex));
-    memcpy(ctx->indices.allocInfo.pMappedData, ctx->indexCache, ctx->indCount * sizeof (VKVG_IBO_INDEX_TYPE));
+       memcpy(ctx->vertices.allocInfo.pMappedData, ctx->vertexCache, ctx->vertCount * sizeof (Vertex));
+       memcpy(ctx->indices.allocInfo.pMappedData, ctx->indexCache, ctx->indCount * sizeof (VKVG_IBO_INDEX_TYPE));
 
-    ctx->vertCount = ctx->indCount = ctx->curIndStart = ctx->curVertOffset = 0;
+       ctx->vertCount = ctx->indCount = ctx->curIndStart = ctx->curVertOffset = 0;
 }
 //this func expect cmdStarted to be true
 void _end_render_pass (VkvgContext ctx) {
-    LOG(LOG_INFO, "END RENDER PASS: ctx = %lu;\n", ctx);
-    CmdEndRenderPass      (ctx->cmd);
-    ctx->renderPassBeginInfo.renderPass = ctx->pSurf->dev->renderPass;
+       LOG(LOG_INFO, "END RENDER PASS: ctx = %lu;\n", ctx);
+       CmdEndRenderPass      (ctx->cmd);
+#ifdef DEBUG
+       vkh_cmd_label_end (ctx->cmd);
+#endif
+       ctx->renderPassBeginInfo.renderPass = ctx->pSurf->dev->renderPass;
 }
 void _new_flush (VkvgContext ctx){
-    if (ctx->indCount == ctx->curIndStart)
-        return;
-
-    if (ctx->vertCount > ctx->sizeVBO || ctx->indCount > ctx->sizeIBO){
-        //vbo or ibo buffers too small
-        if (ctx->cmdStarted) {
-            //if cmd is started buffers, are already bound, so no resize is possible
-            //instead we flush, and clear vbo and ibo caches
-            _end_render_pass (ctx);
-            _flush_vertices_caches_until_vertex_base (ctx);
-            vkh_cmd_end (ctx->cmd);
-            _wait_and_submit_cmd (ctx);
-            _resize_vbo(ctx, ctx->sizeVertices);
-            _resize_ibo(ctx, ctx->sizeIndices);
-        }else{
-            _resize_vbo(ctx, ctx->sizeVertices);
-            _resize_ibo(ctx, ctx->sizeIndices);
-        }
-    }
-
-    _check_cmd_buff_state(ctx);
-    CmdDrawIndexed(ctx->cmd, ctx->indCount - ctx->curIndStart, 1, ctx->curIndStart, (int32_t)ctx->curVertOffset, 0);
-
-    LOG(LOG_INFO, "RECORD DRAW CMD: ctx = %lu; vertices = %d; indices = %d\n", (ulong)ctx, ctx->vertCount - ctx->indexCache[ctx->curIndStart], ctx->indCount - ctx->curIndStart);
+       if (ctx->indCount == ctx->curIndStart)
+               return;
+
+       if (ctx->vertCount > ctx->sizeVBO || ctx->indCount > ctx->sizeIBO){
+               //vbo or ibo buffers too small
+               if (ctx->cmdStarted) {
+#ifdef DEBUG
+                       vkh_cmd_label_start(ctx->cmd, "ctx flush for resize vao", LAB_COLOR_FLUSH);
+#endif
+                       //if cmd is started buffers, are already bound, so no resize is possible
+                       //instead we flush, and clear vbo and ibo caches
+                       _end_render_pass (ctx);
+                       _flush_vertices_caches_until_vertex_base (ctx);
+                       vkh_cmd_end (ctx->cmd);
+                       _wait_and_submit_cmd (ctx);
+                       _resize_vbo(ctx, ctx->sizeVertices);
+                       _resize_ibo(ctx, ctx->sizeIndices);
+               }else{
+                       _resize_vbo(ctx, ctx->sizeVertices);
+                       _resize_ibo(ctx, ctx->sizeIndices);
+               }
+       }
+
+       _check_cmd_buff_state(ctx);
+       CmdDrawIndexed(ctx->cmd, ctx->indCount - ctx->curIndStart, 1, ctx->curIndStart, (int32_t)ctx->curVertOffset, 0);
+
+       LOG(LOG_INFO, "RECORD DRAW CMD: ctx = %lu; vertices = %d; indices = %d\n", (ulong)ctx, ctx->vertCount - ctx->indexCache[ctx->curIndStart], ctx->indCount - ctx->curIndStart);
 
 #ifdef VKVG_WIRED_DEBUG
-    CmdBindPipeline(ctx->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, ctx->pSurf->dev->pipelineWired);
-    CmdDrawIndexed(ctx->cmd, ctx->indCount - ctx->curIndStart, 1, ctx->curIndStart, (int32_t)ctx->curVertOffset, 0);
-    CmdBindPipeline(ctx->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, ctx->pSurf->dev->pipe_OVER);
+       CmdBindPipeline(ctx->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, ctx->pSurf->dev->pipelineWired);
+       CmdDrawIndexed(ctx->cmd, ctx->indCount - ctx->curIndStart, 1, ctx->curIndStart, (int32_t)ctx->curVertOffset, 0);
+       CmdBindPipeline(ctx->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, ctx->pSurf->dev->pipe_OVER);
 #endif
 
-    ctx->curIndStart = ctx->indCount;
-    ctx->curVertOffset = ctx->vertCount;
+       ctx->curIndStart = ctx->indCount;
+       ctx->curVertOffset = ctx->vertCount;
 
-    _end_render_pass        (ctx);
-    _flush_vertices_caches  (ctx);
-    vkh_cmd_end             (ctx->cmd);
+       _end_render_pass        (ctx);
+       _flush_vertices_caches  (ctx);
+       vkh_cmd_end             (ctx->cmd);
 
-    LOG(LOG_INFO, "FLUSH CTX: ctx = %lu; vertices = %d; indices = %d\n", ctx, ctx->vertCount, ctx->indCount);
-    _wait_and_submit_cmd(ctx);
+       LOG(LOG_INFO, "FLUSH CTX: ctx = %lu; vertices = %d; indices = %d\n", ctx, ctx->vertCount, ctx->indCount);
+       _wait_and_submit_cmd(ctx);
 }
 inline bool _undrawn_vertices (VkvgContext ctx) {
-    return ctx->indCount > ctx->curIndStart;
+       return ctx->indCount > ctx->curIndStart;
 }
 void _record_draw_cmd (VkvgContext ctx){
-    if (ctx->vertCount > ctx->sizeVBO || ctx->indCount > ctx->sizeIBO){
-        //vbo or ibo buffers too small
-        if (ctx->cmdStarted) {
-            //if cmd is started buffers, are already bound, so no resize is possible
-            //instead we flush, and clear vbo and ibo caches
-            _end_render_pass (ctx);
-            _flush_vertices_caches_until_vertex_base (ctx);
-            vkh_cmd_end (ctx->cmd);
-            _wait_and_submit_cmd (ctx);
-            _resize_vbo(ctx, ctx->sizeVertices);
-            _resize_ibo(ctx, ctx->sizeIndices);
-        }else{
-            _resize_vbo(ctx, ctx->sizeVertices);
-            _resize_ibo(ctx, ctx->sizeIndices);
-        }
-    }
-
-    _check_cmd_buff_state(ctx);
-    CmdDrawIndexed(ctx->cmd, ctx->indCount - ctx->curIndStart, 1, ctx->curIndStart, (int32_t)ctx->curVertOffset, 0);
-
-    LOG(LOG_INFO, "RECORD DRAW CMD: ctx = %lu; vertices = %d; indices = %d\n", (ulong)ctx, ctx->vertCount - ctx->indexCache[ctx->curIndStart], ctx->indCount - ctx->curIndStart);
+       if (ctx->vertCount > ctx->sizeVBO || ctx->indCount > ctx->sizeIBO){
+               //vbo or ibo buffers too small
+               if (ctx->cmdStarted) {
+                       //if cmd is started buffers, are already bound, so no resize is possible
+                       //instead we flush, and clear vbo and ibo caches
+                       _end_render_pass (ctx);
+                       _flush_vertices_caches_until_vertex_base (ctx);
+                       vkh_cmd_end (ctx->cmd);
+                       _wait_and_submit_cmd (ctx);
+               }
+               _resize_vbo(ctx, ctx->sizeVertices);
+               _resize_ibo(ctx, ctx->sizeIndices);
+       }
+
+       _check_cmd_buff_state(ctx);
+       CmdDrawIndexed(ctx->cmd, ctx->indCount - ctx->curIndStart, 1, ctx->curIndStart, (int32_t)ctx->curVertOffset, 0);
+
+       LOG(LOG_INFO, "RECORD DRAW CMD: ctx = %lu; vertices = %d; indices = %d\n", (ulong)ctx, ctx->vertCount - ctx->indexCache[ctx->curIndStart], ctx->indCount - ctx->curIndStart);
 
 #ifdef VKVG_WIRED_DEBUG
-    CmdBindPipeline(ctx->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, ctx->pSurf->dev->pipelineWired);
-    CmdDrawIndexed(ctx->cmd, ctx->indCount - ctx->curIndStart, 1, ctx->curIndStart, (int32_t)ctx->curVertOffset, 0);
-    CmdBindPipeline(ctx->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, ctx->pSurf->dev->pipe_OVER);
+       CmdBindPipeline(ctx->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, ctx->pSurf->dev->pipelineWired);
+       CmdDrawIndexed(ctx->cmd, ctx->indCount - ctx->curIndStart, 1, ctx->curIndStart, (int32_t)ctx->curVertOffset, 0);
+       CmdBindPipeline(ctx->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, ctx->pSurf->dev->pipe_OVER);
 #endif
 
-    ctx->curIndStart = ctx->indCount;
-    ctx->curVertOffset = ctx->vertCount;
+       ctx->curIndStart = ctx->indCount;
+       ctx->curVertOffset = ctx->vertCount;
 }
 void _flush_cmd_buff (VkvgContext ctx){
-    if (_undrawn_vertices(ctx))
-        _record_draw_cmd (ctx);
-    else if (!ctx->cmdStarted)
-        return;
-    _end_render_pass        (ctx);
-    _flush_vertices_caches  (ctx);
-    vkh_cmd_end             (ctx->cmd);
-
-    LOG(LOG_INFO, "FLUSH CTX: ctx = %lu; vertices = %d; indices = %d\n", ctx, ctx->vertCount, ctx->indCount);
-    _wait_and_submit_cmd(ctx);
+       if (_undrawn_vertices(ctx))
+               _record_draw_cmd (ctx);
+       else if (!ctx->cmdStarted)
+               return;
+       _end_render_pass        (ctx);
+       _flush_vertices_caches  (ctx);
+       vkh_cmd_end             (ctx->cmd);
+
+       LOG(LOG_INFO, "FLUSH CTX: ctx = %lu; vertices = %d; indices = %d\n", ctx, ctx->vertCount, ctx->indCount);
+       _wait_and_submit_cmd(ctx);
 }
 
 //bind correct draw pipeline depending on current OPERATOR
 void _bind_draw_pipeline (VkvgContext ctx) {
-    switch (ctx->curOperator) {
-    case VKVG_OPERATOR_OVER:
-        CmdBindPipeline(ctx->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, ctx->pSurf->dev->pipe_OVER);
-        break;
-    case VKVG_OPERATOR_CLEAR:
-        vkvg_set_source_rgba(ctx,0,0,0,0);
-        CmdBindPipeline(ctx->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, ctx->pSurf->dev->pipe_CLEAR);
-        break;
-    default:
-        CmdBindPipeline(ctx->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, ctx->pSurf->dev->pipe_OVER);
-        break;
-    }
+       switch (ctx->curOperator) {
+       case VKVG_OPERATOR_OVER:
+               CmdBindPipeline(ctx->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, ctx->pSurf->dev->pipe_OVER);
+               break;
+       case VKVG_OPERATOR_CLEAR:
+               vkvg_set_source_rgba(ctx,0,0,0,0);
+               CmdBindPipeline(ctx->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, ctx->pSurf->dev->pipe_CLEAR);
+               break;
+       default:
+               CmdBindPipeline(ctx->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, ctx->pSurf->dev->pipe_OVER);
+               break;
+       }
 }
 void _init_push_descriptor_writes (VkvgContext ctx) {
-    ctx->descFontTex = vkh_image_get_descriptor (ctx->pSurf->dev->fontCache->texture, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
-    VkWriteDescriptorSet wds = {0};
-    wds.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
-    wds.dstSet = 0;
-    wds.dstBinding = 0;
-    wds.descriptorCount = 1;
-    wds.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
-    wds.pImageInfo = &ctx->descSrcTex;
-    ctx->wds[0] = wds;
-
-    ctx->descSrcTex = vkh_image_get_descriptor (ctx->pSurf->dev->emptyImg, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
-    wds.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
-    wds.dstSet = 0;
-    wds.dstBinding = 1;
-    wds.descriptorCount = 1;
-    wds.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
-    wds.pImageInfo = &ctx->descFontTex;
-    ctx->wds[1] = wds;
-
-    wds.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
-    wds.dstSet = 0;
-    wds.dstBinding = 2;
-    wds.descriptorCount = 1;
-    wds.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
-    wds.pImageInfo = 0;
-    wds.pBufferInfo = &ctx->uboGrad.descriptor;
-    ctx->wds[2] = wds;
+       ctx->descFontTex = vkh_image_get_descriptor (ctx->pSurf->dev->fontCache->texture, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
+       VkWriteDescriptorSet wds = {0};
+       wds.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
+       wds.dstSet = 0;
+       wds.dstBinding = 0;
+       wds.descriptorCount = 1;
+       wds.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
+       wds.pImageInfo = &ctx->descSrcTex;
+       ctx->wds[0] = wds;
+
+       ctx->descSrcTex = vkh_image_get_descriptor (ctx->pSurf->dev->emptyImg, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
+       wds.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
+       wds.dstSet = 0;
+       wds.dstBinding = 1;
+       wds.descriptorCount = 1;
+       wds.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
+       wds.pImageInfo = &ctx->descFontTex;
+       ctx->wds[1] = wds;
+
+       wds.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
+       wds.dstSet = 0;
+       wds.dstBinding = 2;
+       wds.descriptorCount = 1;
+       wds.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
+       wds.pImageInfo = 0;
+       wds.pBufferInfo = &ctx->uboGrad.descriptor;
+       ctx->wds[2] = wds;
 }
+
 void _start_cmd_for_render_pass (VkvgContext ctx) {
-    LOG(LOG_INFO, "START RENDER PASS: ctx = %lu\n", ctx);
-    vkh_cmd_begin (ctx->cmd,VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT);
-
-    if (ctx->pSurf->img->layout == VK_IMAGE_LAYOUT_UNDEFINED){
-        VkhImage imgMs = ctx->pSurf->imgMS;
-        if (imgMs != NULL)
-            vkh_image_set_layout(ctx->cmd, imgMs, VK_IMAGE_ASPECT_COLOR_BIT,
-                                 VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
-                                 VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
-
-        vkh_image_set_layout(ctx->cmd, ctx->pSurf->img, VK_IMAGE_ASPECT_COLOR_BIT,
-                         VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
-                         VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
-    }
-
-    if (ctx->source && ctx->source->layout != VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL)
-        vkh_image_set_layout (ctx->cmd, ctx->source, VK_IMAGE_ASPECT_COLOR_BIT,
-                              VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
-                              VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
-
-    CmdBeginRenderPass (ctx->cmd, &ctx->renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE);
-    VkViewport viewport = {0,0,ctx->pSurf->width,ctx->pSurf->height,0,1};
-    CmdSetViewport(ctx->cmd, 0, 1, &viewport);
-
-    CmdSetScissor(ctx->cmd, 0, 1, &ctx->bounds);
-
-    if (CmdPushDescriptorSet) {
-        CmdPushDescriptorSet(ctx->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, ctx->pSurf->dev->pipelineLayout, 0, 3, &ctx->wds[0]);
-        /*if (ctx->pattern){
-            if (ctx->pattern->type == VKVG_PATTERN_TYPE_SURFACE)
-                CmdPushDescriptorSet(ctx->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, ctx->pSurf->dev->pipelineLayout, 0, 1, &ctx->wds[0]);
-            else if (ctx->pattern->type != VKVG_PATTERN_TYPE_SOLID)
-                CmdPushDescriptorSet(ctx->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, ctx->pSurf->dev->pipelineLayout, 0, 1, &ctx->wds[2]);
-        }*/
-    }else{
-        CmdBindDescriptorSets(ctx->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, ctx->pSurf->dev->pipelineLayout,
-                              0, 1, &ctx->dsSrc, 0, NULL);
-    }
-    VkDeviceSize offsets[1] = { 0 };
-    CmdBindVertexBuffers(ctx->cmd, 0, 1, &ctx->vertices.buffer, offsets);
-    if (sizeof (VKVG_IBO_INDEX_TYPE) == 4)
-        CmdBindIndexBuffer(ctx->cmd, ctx->indices.buffer, 0, VK_INDEX_TYPE_UINT32);
-    else
-        CmdBindIndexBuffer(ctx->cmd, ctx->indices.buffer, 0, VK_INDEX_TYPE_UINT16);
-
-    _update_push_constants  (ctx);
-
-    _bind_draw_pipeline (ctx);
-    CmdSetStencilCompareMask(ctx->cmd, VK_STENCIL_FRONT_AND_BACK, STENCIL_CLIP_BIT);
-
-
-    ctx->cmdStarted = true;
+       LOG(LOG_INFO, "START RENDER PASS: ctx = %lu\n", ctx);
+       vkh_cmd_begin (ctx->cmd,VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT);
+
+       if (ctx->pSurf->img->layout == VK_IMAGE_LAYOUT_UNDEFINED){
+               VkhImage imgMs = ctx->pSurf->imgMS;
+               if (imgMs != NULL)
+                       vkh_image_set_layout(ctx->cmd, imgMs, VK_IMAGE_ASPECT_COLOR_BIT,
+                                                                VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
+                                                                VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
+
+               vkh_image_set_layout(ctx->cmd, ctx->pSurf->img, VK_IMAGE_ASPECT_COLOR_BIT,
+                                                VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
+                                                VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
+       }
+
+       if (ctx->source && ctx->source->layout != VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL)
+               vkh_image_set_layout (ctx->cmd, ctx->source, VK_IMAGE_ASPECT_COLOR_BIT,
+                                                         VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
+                                                         VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
+
+#ifdef DEBUG
+       vkh_cmd_label_start(ctx->cmd, "ctx render pass", LAB_COLOR_RP);
+#endif
+
+       CmdBeginRenderPass (ctx->cmd, &ctx->renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE);
+       VkViewport viewport = {0,0,ctx->pSurf->width,ctx->pSurf->height,0,1};
+       CmdSetViewport(ctx->cmd, 0, 1, &viewport);
+
+       CmdSetScissor(ctx->cmd, 0, 1, &ctx->bounds);
+
+       if (CmdPushDescriptorSet) {
+               CmdPushDescriptorSet(ctx->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, ctx->pSurf->dev->pipelineLayout, 0, 3, &ctx->wds[0]);
+               /*if (ctx->pattern){
+                       if (ctx->pattern->type == VKVG_PATTERN_TYPE_SURFACE)
+                               CmdPushDescriptorSet(ctx->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, ctx->pSurf->dev->pipelineLayout, 0, 1, &ctx->wds[0]);
+                       else if (ctx->pattern->type != VKVG_PATTERN_TYPE_SOLID)
+                               CmdPushDescriptorSet(ctx->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, ctx->pSurf->dev->pipelineLayout, 0, 1, &ctx->wds[2]);
+               }*/
+       }else{
+               CmdBindDescriptorSets(ctx->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, ctx->pSurf->dev->pipelineLayout,
+                                                         0, 1, &ctx->dsSrc, 0, NULL);
+       }
+       VkDeviceSize offsets[1] = { 0 };
+       CmdBindVertexBuffers(ctx->cmd, 0, 1, &ctx->vertices.buffer, offsets);
+       if (sizeof (VKVG_IBO_INDEX_TYPE) == 4)
+               CmdBindIndexBuffer(ctx->cmd, ctx->indices.buffer, 0, VK_INDEX_TYPE_UINT32);
+       else
+               CmdBindIndexBuffer(ctx->cmd, ctx->indices.buffer, 0, VK_INDEX_TYPE_UINT16);
+
+       _update_push_constants  (ctx);
+
+       _bind_draw_pipeline (ctx);
+       CmdSetStencilCompareMask(ctx->cmd, VK_STENCIL_FRONT_AND_BACK, STENCIL_CLIP_BIT);
+
+
+       ctx->cmdStarted = true;
 }
 //compute inverse mat used in shader when context matrix has changed
 //then trigger push constants command
 void _set_mat_inv_and_vkCmdPush (VkvgContext ctx) {
-    if (_undrawn_vertices(ctx))
-        _record_draw_cmd (ctx);//emit draw cmd before push new cst
-    ctx->pushConsts.matInv = ctx->pushConsts.mat;
-    vkvg_matrix_invert (&ctx->pushConsts.matInv);
-    ctx->pushCstDirty = true;
+       if (_undrawn_vertices(ctx))
+               _record_draw_cmd (ctx);//emit draw cmd before push new cst
+       ctx->pushConsts.matInv = ctx->pushConsts.mat;
+       vkvg_matrix_invert (&ctx->pushConsts.matInv);
+       ctx->pushCstDirty = true;
 }
 inline void _update_push_constants (VkvgContext ctx) {
-    CmdPushConstants(ctx->cmd, ctx->pSurf->dev->pipelineLayout,
-                       VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(push_constants),&ctx->pushConsts);
-    ctx->pushCstDirty = false;
+       CmdPushConstants(ctx->cmd, ctx->pSurf->dev->pipelineLayout,
+                                          VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(push_constants),&ctx->pushConsts);
+       ctx->pushCstDirty = false;
 }
 void _update_cur_pattern (VkvgContext ctx, VkvgPattern pat) {
-    VkvgPattern lastPat = ctx->pattern;
-    ctx->pattern = pat;
-
-    switch (pat->type)  {
-    case VKVG_PATTERN_TYPE_SOLID:
-        if (ctx->source)
-            ctx->source = NULL;
-        if (lastPat){
-            if (lastPat->type == VKVG_PATTERN_TYPE_SURFACE){
-                ctx->descSrcTex = vkh_image_get_descriptor (ctx->pSurf->dev->emptyImg, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
-                _flush_cmd_buff(ctx);
-            }
-            if (lastPat->type == pat->type)
-                break;
-            ctx->pushConsts.patternType = pat->type;
-            ctx->pushCstDirty = true;
-        }
-        break;
-    case VKVG_PATTERN_TYPE_SURFACE:
-    {
-        _flush_cmd_buff (ctx);
-
-        VkvgSurface surf = (VkvgSurface)pat->data;
-        ctx->source = surf->img;
-        ctx->pushConsts.source.width = surf->height;
-        ctx->pushConsts.source.height = surf->width;
-        ctx->pushConsts.patternType = pat->type;
-        ctx->pushCstDirty = true;
-
-        if (CmdPushDescriptorSet != VK_NULL_HANDLE) {
-            ctx->descSrcTex = (VkDescriptorImageInfo) {
-                    _get_sampler_for_pattern(ctx->pSurf->dev, pat),
-                    vkh_image_get_view (ctx->source),
-                    VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL};
-
-            if (!ctx->cmdStarted)
-                _start_cmd_for_render_pass(ctx);
-            else{
-                vkh_image_set_layout (ctx->cmd, surf->img, VK_IMAGE_ASPECT_COLOR_BIT,
-                                      VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
-                                      VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
-                CmdPushDescriptorSet(ctx->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, ctx->pSurf->dev->pipelineLayout, 0, 1, &ctx->wds[0]);
-            }
-        }
-        //flush ctx in two steps to add the src transitioning in the cmd buff
-        /*if (ctx->cmdStarted){//transition of img without appropriate dependencies in subpass must be done outside renderpass.
-            _record_draw_cmd (ctx);//ensure all vertices are flushed
-            _end_render_pass (ctx);
-            _flush_vertices_caches (ctx);
-        }else {
-            vkh_cmd_begin (ctx->cmd,VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT);
-            ctx->cmdStarted = true;
-        }
-    */
-        //transition source surface for sampling
-        /*
-        vkh_image_set_layout (ctx->cmd, surf->img, VK_IMAGE_ASPECT_COLOR_BIT,
-                              VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
-                              VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
-
-        vkh_cmd_end (ctx->cmd);
-        _wait_and_submit_cmd (ctx);*/
-
-
-        /*if (vkh_image_get_layout (ctx->source) != VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL){
-            vkh_cmd_begin (ctx->cmd,VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT);
-
-            vkh_image_set_layout (ctx->cmd, ctx->source, VK_IMAGE_ASPECT_COLOR_BIT,
-                                  VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
-                                  VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
-            vkh_cmd_end (ctx->cmd);
-
-            _submit_wait_and_reset_cmd  (ctx);
-        }*/
+       VkvgPattern lastPat = ctx->pattern;
+       ctx->pattern = pat;
+
+       switch (pat->type)  {
+       case VKVG_PATTERN_TYPE_SOLID:
+               if (ctx->source)
+                       ctx->source = NULL;
+               if (lastPat){
+                       if (lastPat->type == VKVG_PATTERN_TYPE_SURFACE){
+                               ctx->descSrcTex = vkh_image_get_descriptor (ctx->pSurf->dev->emptyImg, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
+                               _flush_cmd_buff(ctx);
+                       }
+                       if (lastPat->type == pat->type)
+                               break;
+                       ctx->pushConsts.patternType = pat->type;
+                       ctx->pushCstDirty = true;
+               }
+               break;
+       case VKVG_PATTERN_TYPE_SURFACE:
+       {
+               _flush_cmd_buff (ctx);
+
+               VkvgSurface surf = (VkvgSurface)pat->data;
+               ctx->source = surf->img;
+               ctx->pushConsts.source.width = surf->height;
+               ctx->pushConsts.source.height = surf->width;
+               ctx->pushConsts.patternType = pat->type;
+               ctx->pushCstDirty = true;
+
+               if (CmdPushDescriptorSet != VK_NULL_HANDLE) {
+                       ctx->descSrcTex = (VkDescriptorImageInfo) {
+                                       _get_sampler_for_pattern(ctx->pSurf->dev, pat),
+                                       vkh_image_get_view (ctx->source),
+                                       VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL};
+
+                       if (!ctx->cmdStarted)
+                               _start_cmd_for_render_pass(ctx);
+                       else{
+                               vkh_image_set_layout (ctx->cmd, surf->img, VK_IMAGE_ASPECT_COLOR_BIT,
+                                                                         VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
+                                                                         VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
+                               CmdPushDescriptorSet(ctx->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, ctx->pSurf->dev->pipelineLayout, 0, 1, &ctx->wds[0]);
+                       }
+               }
+               //flush ctx in two steps to add the src transitioning in the cmd buff
+               /*if (ctx->cmdStarted){//transition of img without appropriate dependencies in subpass must be done outside renderpass.
+                       _record_draw_cmd (ctx);//ensure all vertices are flushed
+                       _end_render_pass (ctx);
+                       _flush_vertices_caches (ctx);
+               }else {
+                       vkh_cmd_begin (ctx->cmd,VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT);
+                       ctx->cmdStarted = true;
+               }
+       */
+               //transition source surface for sampling
+               /*
+               vkh_image_set_layout (ctx->cmd, surf->img, VK_IMAGE_ASPECT_COLOR_BIT,
+                                                         VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
+                                                         VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
+
+               vkh_cmd_end (ctx->cmd);
+               _wait_and_submit_cmd (ctx);*/
+
+
+               /*if (vkh_image_get_layout (ctx->source) != VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL){
+                       vkh_cmd_begin (ctx->cmd,VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT);
+
+                       vkh_image_set_layout (ctx->cmd, ctx->source, VK_IMAGE_ASPECT_COLOR_BIT,
+                                                                 VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
+                                                                 VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
+                       vkh_cmd_end (ctx->cmd);
+
+                       _submit_wait_and_reset_cmd  (ctx);
+               }*/
 /*
-        _update_descriptor_set          (ctx, ctx->source, ctx->dsSrc);
+               _update_descriptor_set          (ctx, ctx->source, ctx->dsSrc);
 
 
   */
 
-        //_init_cmd_buff                  (ctx);
-        break;
-    }
-    case VKVG_PATTERN_TYPE_LINEAR:
-        _flush_cmd_buff (ctx);
+               //_init_cmd_buff                  (ctx);
+               break;
+       }
+       case VKVG_PATTERN_TYPE_LINEAR:
+               _flush_cmd_buff (ctx);
 
-        //if (lastPat && lastPat->type == VKVG_PATTERN_TYPE_SURFACE)
-        //    _update_descriptor_set (ctx, ctx->pSurf->dev->emptyImg, ctx->dsSrc,1);
+               //if (lastPat && lastPat->type == VKVG_PATTERN_TYPE_SURFACE)
+               //    _update_descriptor_set (ctx, ctx->pSurf->dev->emptyImg, ctx->dsSrc,1);
 
-        ctx->pushConsts.source = (vec4){ctx->pSurf->width, ctx->pSurf->height, 0, 0};//store img bounds in unused source field
-        ctx->pushConsts.patternType = pat->type;
-        ctx->pushCstDirty = true;
+               ctx->pushConsts.source = (vec4){ctx->pSurf->width, ctx->pSurf->height, 0, 0};//store img bounds in unused source field
+               ctx->pushConsts.patternType = pat->type;
+               ctx->pushCstDirty = true;
 
-        //transform control point with current ctx matrix
-        vkvg_gradient_t grad = {};
-        memcpy(&grad, pat->data, sizeof(vkvg_gradient_t));
+               //transform control point with current ctx matrix
+               vkvg_gradient_t grad = {};
+               memcpy(&grad, pat->data, sizeof(vkvg_gradient_t));
 
-        vkvg_matrix_transform_point(&ctx->pushConsts.mat, &grad.cp[0].x, &grad.cp[0].y);
-        vkvg_matrix_transform_point(&ctx->pushConsts.mat, &grad.cp[1].x, &grad.cp[1].y);
-        //to do, scale radial radiuses in cp[2]
+               vkvg_matrix_transform_point(&ctx->pushConsts.mat, &grad.cp[0].x, &grad.cp[0].y);
+               vkvg_matrix_transform_point(&ctx->pushConsts.mat, &grad.cp[1].x, &grad.cp[1].y);
+               //to do, scale radial radiuses in cp[2]
 
-        memcpy(ctx->uboGrad.allocInfo.pMappedData , &grad, sizeof(vkvg_gradient_t));
+               memcpy(ctx->uboGrad.allocInfo.pMappedData , &grad, sizeof(vkvg_gradient_t));
 
-        if (CmdPushDescriptorSet != VK_NULL_HANDLE && ctx->cmdStarted)
-            CmdPushDescriptorSet(ctx->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, ctx->pSurf->dev->pipelineLayout, 0, 1, &ctx->wds[2]);
-        break;
-    }
+               if (CmdPushDescriptorSet != VK_NULL_HANDLE && ctx->cmdStarted)
+                       CmdPushDescriptorSet(ctx->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, ctx->pSurf->dev->pipelineLayout, 0, 1, &ctx->wds[2]);
+               break;
+       }
 
-    if (lastPat)
-        vkvg_pattern_destroy    (lastPat);
+       if (lastPat)
+               vkvg_pattern_destroy    (lastPat);
 }
 void _update_descriptor_set (VkvgContext ctx, VkhImage img, VkDescriptorSet ds, uint binding){
-    _wait_flush_fence(ctx);//descriptorSet update invalidate cmd buffs
-    VkDescriptorImageInfo descSrcTex = vkh_image_get_descriptor (img, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
-    VkWriteDescriptorSet writeDescriptorSet = {
-            .sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
-            .dstSet = ds,
-            .dstBinding = binding,
-            .descriptorCount = 1,
-            .descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
-            .pImageInfo = &descSrcTex
-    };
-    vkUpdateDescriptorSets(ctx->pSurf->dev->vkDev, 1, &writeDescriptorSet, 0, NULL);
+       _wait_flush_fence(ctx);//descriptorSet update invalidate cmd buffs
+       VkDescriptorImageInfo descSrcTex = vkh_image_get_descriptor (img, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
+       VkWriteDescriptorSet writeDescriptorSet = {
+                       .sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
+                       .dstSet = ds,
+                       .dstBinding = binding,
+                       .descriptorCount = 1,
+                       .descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
+                       .pImageInfo = &descSrcTex
+       };
+       vkUpdateDescriptorSets(ctx->pSurf->dev->vkDev, 1, &writeDescriptorSet, 0, NULL);
 }
 void _update_gradient_desc_set (VkvgContext ctx){
-    VkDescriptorBufferInfo dbi = {ctx->uboGrad.buffer, 0, VK_WHOLE_SIZE};
-    VkWriteDescriptorSet writeDescriptorSet = {
-            .sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
-            .dstSet = ctx->dsSrc,
-            .dstBinding = 2,
-            .descriptorCount = 1,
-            .descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
-            .pBufferInfo = &dbi
-    };
-    vkUpdateDescriptorSets(ctx->pSurf->dev->vkDev, 1, &writeDescriptorSet, 0, NULL);
+       VkDescriptorBufferInfo dbi = {ctx->uboGrad.buffer, 0, VK_WHOLE_SIZE};
+       VkWriteDescriptorSet writeDescriptorSet = {
+                       .sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
+                       .dstSet = ctx->dsSrc,
+                       .dstBinding = 2,
+                       .descriptorCount = 1,
+                       .descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
+                       .pBufferInfo = &dbi
+       };
+       vkUpdateDescriptorSets(ctx->pSurf->dev->vkDev, 1, &writeDescriptorSet, 0, NULL);
 }
 /*
  * Reset currently bound descriptor which image could be destroyed
  */
 /*void _reset_src_descriptor_set (VkvgContext ctx){
-    VkvgDevice dev = ctx->pSurf->dev;
-    //VkDescriptorSet dss[] = {ctx->dsSrc};
-    vkFreeDescriptorSets    (dev->vkDev, ctx->descriptorPool, 1, &ctx->dsSrc);
-
-    VkDescriptorSetAllocateInfo descriptorSetAllocateInfo = { .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
-                                                              .descriptorPool = ctx->descriptorPool,
-                                                              .descriptorSetCount = 1,
-                                                              .pSetLayouts = &dev->dslSrc };
-    VK_CHECK_RESULT(vkAllocateDescriptorSets(dev->vkDev, &descriptorSetAllocateInfo, &ctx->dsSrc));
+       VkvgDevice dev = ctx->pSurf->dev;
+       //VkDescriptorSet dss[] = {ctx->dsSrc};
+       vkFreeDescriptorSets    (dev->vkDev, ctx->descriptorPool, 1, &ctx->dsSrc);
+
+       VkDescriptorSetAllocateInfo descriptorSetAllocateInfo = { .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
+                                                                                                                         .descriptorPool = ctx->descriptorPool,
+                                                                                                                         .descriptorSetCount = 1,
+                                                                                                                         .pSetLayouts = &dev->dslSrc };
+       VK_CHECK_RESULT(vkAllocateDescriptorSets(dev->vkDev, &descriptorSetAllocateInfo, &ctx->dsSrc));
 }*/
 
 void _createDescriptorPool (VkvgContext ctx) {
-    VkvgDevice dev = ctx->pSurf->dev;
-    const VkDescriptorPoolSize descriptorPoolSize[] = {
-        {VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 2 },
-        {VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1 }
-    };
-    VkDescriptorPoolCreateInfo descriptorPoolCreateInfo = { .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
-                                                            .maxSets = 3,
-                                                            .flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT,
-                                                            .poolSizeCount = 2,
-                                                            .pPoolSizes = descriptorPoolSize };
-    VK_CHECK_RESULT(vkCreateDescriptorPool (dev->vkDev, &descriptorPoolCreateInfo, NULL, &ctx->descriptorPool));
+       VkvgDevice dev = ctx->pSurf->dev;
+       const VkDescriptorPoolSize descriptorPoolSize[] = {
+               {VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 2 },
+               {VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1 }
+       };
+       VkDescriptorPoolCreateInfo descriptorPoolCreateInfo = { .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
+                                                                                                                       .maxSets = 3,
+                                                                                                                       .flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT,
+                                                                                                                       .poolSizeCount = 2,
+                                                                                                                       .pPoolSizes = descriptorPoolSize };
+       VK_CHECK_RESULT(vkCreateDescriptorPool (dev->vkDev, &descriptorPoolCreateInfo, NULL, &ctx->descriptorPool));
 }
 void _init_descriptor_sets (VkvgContext ctx){
-    VkvgDevice dev = ctx->pSurf->dev;
-    VkDescriptorSetAllocateInfo descriptorSetAllocateInfo = { .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
-                                                              .descriptorPool = ctx->descriptorPool,
-                                                              .descriptorSetCount = 1,
-                                                              .pSetLayouts = &dev->dslSrc };
-    VK_CHECK_RESULT(vkAllocateDescriptorSets(dev->vkDev, &descriptorSetAllocateInfo, &ctx->dsSrc));
+       VkvgDevice dev = ctx->pSurf->dev;
+       VkDescriptorSetAllocateInfo descriptorSetAllocateInfo = { .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
+                                                                                                                         .descriptorPool = ctx->descriptorPool,
+                                                                                                                         .descriptorSetCount = 1,
+                                                                                                                         .pSetLayouts = &dev->dslSrc };
+       VK_CHECK_RESULT(vkAllocateDescriptorSets(dev->vkDev, &descriptorSetAllocateInfo, &ctx->dsSrc));
 }
 
 void _build_vb_step (vkvg_context* ctx, Vertex v, float hw, uint32_t iL, uint32_t i, uint32_t iR, bool isCurve){
-    //if two of the three points are equal, normal is null
-    vec2 v0n = vec2_line_norm(ctx->points[iL], ctx->points[i]);
-    if (vec2_isnan(v0n))
-        return;
-    vec2 v1n = vec2_line_norm(ctx->points[i], ctx->points[iR]);
-    if (vec2_isnan(v1n))
-        return;
-
-    vec2 bisec = vec2_norm(vec2_add(v0n,v1n));
-
-    float alpha = acosf(v0n.x * v1n.x + v0n.y * v1n.y)/2;
-    float cross = v0n.x * v1n.y - v0n.y * v1n.x;
-
-    if (cross<0)
-        alpha = -alpha;
-
-    float lh = hw / cosf(alpha);
-    bisec = vec2_perp(bisec);
-    bisec = vec2_mult(bisec,lh);
-
-    uint32_t idx = ctx->vertCount - ctx->curVertOffset;
-
-    if (ctx->lineJoin == VKVG_LINE_JOIN_MITER || isCurve){
-        v.pos = vec2_add(ctx->points[i], bisec);
-        _add_vertex(ctx, v);
-        v.pos = vec2_sub(ctx->points[i], bisec);
-        _add_vertex(ctx, v);
-        _add_tri_indices_for_rect(ctx, idx);
-    }else{
-        vec2 vp = vec2_perp(v0n);
-        if (cross<0){
-            v.pos = vec2_add (ctx->points[i], bisec);
-            _add_vertex(ctx, v);
-            v.pos = vec2_sub (ctx->points[i], vec2_mult (vp, hw));
-        }else{
-            v.pos = vec2_add (ctx->points[i], vec2_mult (vp, hw));
-            _add_vertex(ctx, v);
-            v.pos = vec2_sub (ctx->points[i], bisec);
-        }
-        _add_vertex(ctx, v);
-
-        if (ctx->lineJoin == VKVG_LINE_JOIN_BEVEL){
-            if (cross<0){
-                _add_triangle_indices(ctx, idx, idx+2, idx+1);
-                _add_triangle_indices(ctx, idx+2, idx+4, idx+0);
-                _add_triangle_indices(ctx, idx, idx+3, idx+4);
-            }else{
-                _add_triangle_indices(ctx, idx, idx+2, idx+1);
-                _add_triangle_indices(ctx, idx+2, idx+3, idx+1);
-                _add_triangle_indices(ctx, idx+1, idx+3, idx+4);
-            }
-        }else if (ctx->lineJoin == VKVG_LINE_JOIN_ROUND){
-            float step = M_PIF / hw;
-            float a = acosf(vp.x);
-            if (vp.y < 0)
-                a = -a;
-
-            if (cross<0){
-                a+=M_PIF;
-                float a1 = a + alpha*2;
-                a-=step;
-                while (a > a1){
-                    _add_vertexf(ctx, cosf(a) * hw + ctx->points[i].x, sinf(a) * hw + ctx->points[i].y);
-                    a-=step;
-                }
-            }else{
-                float a1 = a + alpha*2;
-                a+=step;
-                while (a < a1){
-                    _add_vertexf(ctx, cosf(a) * hw + ctx->points[i].x, sinf(a) * hw + ctx->points[i].y);
-                    a+=step;
-                }
-            }
-            uint32_t p0Idx = ctx->vertCount - ctx->curVertOffset;
-            _add_triangle_indices(ctx, idx, idx+2, idx+1);
-            if (cross<0){
-                for (uint p = idx+2; p < p0Idx; p++)
-                    _add_triangle_indices(ctx, p, p+1, idx);
-                _add_triangle_indices(ctx, p0Idx, p0Idx+2, idx);
-                _add_triangle_indices(ctx, idx, p0Idx+1, p0Idx+2);
-            }else{
-                for (uint p = idx+2; p < p0Idx; p++)
-                    _add_triangle_indices(ctx, p, p+1, idx+1);
-                _add_triangle_indices(ctx, p0Idx, p0Idx+1, idx+1);
-                _add_triangle_indices(ctx, idx+1, p0Idx+1, p0Idx+2);
-            }
-
-        }
-
-        vp = vec2_mult (vec2_perp(v1n), hw);
-        if (cross<0)
-            v.pos = vec2_sub (ctx->points[i], vp);
-        else
-            v.pos = vec2_add (ctx->points[i], vp);
-        _add_vertex(ctx, v);
-    }
+       //if two of the three points are equal, normal is null
+       vec2 v0n = vec2_line_norm(ctx->points[iL], ctx->points[i]);
+       if (vec2_isnan(v0n))
+               return;
+       vec2 v1n = vec2_line_norm(ctx->points[i], ctx->points[iR]);
+       if (vec2_isnan(v1n))
+               return;
+
+       vec2 bisec = vec2_norm(vec2_add(v0n,v1n));
+
+       float alpha = acosf(v0n.x * v1n.x + v0n.y * v1n.y)/2;
+       float cross = v0n.x * v1n.y - v0n.y * v1n.x;
+
+       if (cross<0)
+               alpha = -alpha;
+
+       float lh = hw / cosf(alpha);
+       bisec = vec2_perp(bisec);
+       bisec = vec2_mult(bisec,lh);
+
+       uint32_t idx = ctx->vertCount - ctx->curVertOffset;
+
+       if (ctx->lineJoin == VKVG_LINE_JOIN_MITER || isCurve){
+               v.pos = vec2_add(ctx->points[i], bisec);
+               _add_vertex(ctx, v);
+               v.pos = vec2_sub(ctx->points[i], bisec);
+               _add_vertex(ctx, v);
+               _add_tri_indices_for_rect(ctx, idx);
+       }else{
+               vec2 vp = vec2_perp(v0n);
+               if (cross<0){
+                       v.pos = vec2_add (ctx->points[i], bisec);
+                       _add_vertex(ctx, v);
+                       v.pos = vec2_sub (ctx->points[i], vec2_mult (vp, hw));
+               }else{
+                       v.pos = vec2_add (ctx->points[i], vec2_mult (vp, hw));
+                       _add_vertex(ctx, v);
+                       v.pos = vec2_sub (ctx->points[i], bisec);
+               }
+               _add_vertex(ctx, v);
+
+               if (ctx->lineJoin == VKVG_LINE_JOIN_BEVEL){
+                       if (cross<0){
+                               _add_triangle_indices(ctx, idx, idx+2, idx+1);
+                               _add_triangle_indices(ctx, idx+2, idx+4, idx+0);
+                               _add_triangle_indices(ctx, idx, idx+3, idx+4);
+                       }else{
+                               _add_triangle_indices(ctx, idx, idx+2, idx+1);
+                               _add_triangle_indices(ctx, idx+2, idx+3, idx+1);
+                               _add_triangle_indices(ctx, idx+1, idx+3, idx+4);
+                       }
+               }else if (ctx->lineJoin == VKVG_LINE_JOIN_ROUND){
+                       float step = M_PIF / hw;
+                       float a = acosf(vp.x);
+                       if (vp.y < 0)
+                               a = -a;
+
+                       if (cross<0){
+                               a+=M_PIF;
+                               float a1 = a + alpha*2;
+                               a-=step;
+                               while (a > a1){
+                                       _add_vertexf(ctx, cosf(a) * hw + ctx->points[i].x, sinf(a) * hw + ctx->points[i].y);
+                                       a-=step;
+                               }
+                       }else{
+                               float a1 = a + alpha*2;
+                               a+=step;
+                               while (a < a1){
+                                       _add_vertexf(ctx, cosf(a) * hw + ctx->points[i].x, sinf(a) * hw + ctx->points[i].y);
+                                       a+=step;
+                               }
+                       }
+                       uint32_t p0Idx = ctx->vertCount - ctx->curVertOffset;
+                       _add_triangle_indices(ctx, idx, idx+2, idx+1);
+                       if (cross<0){
+                               for (uint p = idx+2; p < p0Idx; p++)
+                                       _add_triangle_indices(ctx, p, p+1, idx);
+                               _add_triangle_indices(ctx, p0Idx, p0Idx+2, idx);
+                               _add_triangle_indices(ctx, idx, p0Idx+1, p0Idx+2);
+                       }else{
+                               for (uint p = idx+2; p < p0Idx; p++)
+                                       _add_triangle_indices(ctx, p, p+1, idx+1);
+                               _add_triangle_indices(ctx, p0Idx, p0Idx+1, idx+1);
+                               _add_triangle_indices(ctx, idx+1, p0Idx+1, p0Idx+2);
+                       }
+
+               }
+
+               vp = vec2_mult (vec2_perp(v1n), hw);
+               if (cross<0)
+                       v.pos = vec2_sub (ctx->points[i], vp);
+               else
+                       v.pos = vec2_add (ctx->points[i], vp);
+               _add_vertex(ctx, v);
+       }
 
 /*
 #ifdef DEBUG
 
-    debugLinePoints[dlpCount] = ctx->points[i];
-    debugLinePoints[dlpCount+1] = _v2add(ctx->points[i], _vec2dToVec2(_v2Multd(v0n,10)));
-    dlpCount+=2;
-    debugLinePoints[dlpCount] = ctx->points[i];
-    debugLinePoints[dlpCount+1] = _v2add(ctx->points[i], _vec2dToVec2(_v2Multd(v1n,10)));
-    dlpCount+=2;
-    debugLinePoints[dlpCount] = ctx->points[i];
-    debugLinePoints[dlpCount+1] = ctx->points[iR];
-    dlpCount+=2;
+       debugLinePoints[dlpCount] = ctx->points[i];
+       debugLinePoints[dlpCount+1] = _v2add(ctx->points[i], _vec2dToVec2(_v2Multd(v0n,10)));
+       dlpCount+=2;
+       debugLinePoints[dlpCount] = ctx->points[i];
+       debugLinePoints[dlpCount+1] = _v2add(ctx->points[i], _vec2dToVec2(_v2Multd(v1n,10)));
+       dlpCount+=2;
+       debugLinePoints[dlpCount] = ctx->points[i];
+       debugLinePoints[dlpCount+1] = ctx->points[iR];
+       dlpCount+=2;
 #endif*/
 }
 
 bool ptInTriangle(vec2 p, vec2 p0, vec2 p1, vec2 p2) {
-    float dX = p.x-p2.x;
-    float dY = p.y-p2.y;
-    float dX21 = p2.x-p1.x;
-    float dY12 = p1.y-p2.y;
-    float D = dY12*(p0.x-p2.x) + dX21*(p0.y-p2.y);
-    float s = dY12*dX + dX21*dY;
-    float t = (p2.y-p0.y)*dX + (p0.x-p2.x)*dY;
-    if (D<0)
-        return (s<=0) && (t<=0) && (s+t>=D);
-    return (s>=0) && (t>=0) && (s+t<=D);
+       float dX = p.x-p2.x;
+       float dY = p.y-p2.y;
+       float dX21 = p2.x-p1.x;
+       float dY12 = p1.y-p2.y;
+       float D = dY12*(p0.x-p2.x) + dX21*(p0.y-p2.y);
+       float s = dY12*dX + dX21*dY;
+       float t = (p2.y-p0.y)*dX + (p0.x-p2.x)*dY;
+       if (D<0)
+               return (s<=0) && (t<=0) && (s+t>=D);
+       return (s>=0) && (t>=0) && (s+t<=D);
 }
 
 void _free_ctx_save (vkvg_context_save_t* sav){
-    free(sav->selectedFont.fontFile);
-    free (sav);
+       free(sav->selectedFont.fontFile);
+       free (sav);
 }
 
 
@@ -872,316 +877,316 @@ void _free_ctx_save (vkvg_context_save_t* sav){
 #define curve_angle_tolerance_epsilon 0.001
 
 void _recursive_bezier (VkvgContext ctx,
-                        float x1, float y1, float x2, float y2,
-                        float x3, float y3, float x4, float y4,
-                        unsigned level) {
-    if(level > curve_recursion_limit)
-    {
-        return;
-    }
-
-    // Calculate all the mid-points of the line segments
-    //----------------------
-    float x12   = (x1 + x2) / 2;
-    float y12   = (y1 + y2) / 2;
-    float x23   = (x2 + x3) / 2;
-    float y23   = (y2 + y3) / 2;
-    float x34   = (x3 + x4) / 2;
-    float y34   = (y3 + y4) / 2;
-    float x123  = (x12 + x23) / 2;
-    float y123  = (y12 + y23) / 2;
-    float x234  = (x23 + x34) / 2;
-    float y234  = (y23 + y34) / 2;
-    float x1234 = (x123 + x234) / 2;
-    float y1234 = (y123 + y234) / 2;
-
-    if(level > 0) // Enforce subdivision first time
-    {
-        // Try to approximate the full cubic curve by a single straight line
-        //------------------
-        float dx = x4-x1;
-        float dy = y4-y1;
-
-        float d2 = fabs(((x2 - x4) * dy - (y2 - y4) * dx));
-        float d3 = fabs(((x3 - x4) * dy - (y3 - y4) * dx));
-
-        float da1, da2;
-
-        if(d2 > curve_collinearity_epsilon && d3 > curve_collinearity_epsilon)
-        {
-            // Regular care
-            //-----------------
-            if((d2 + d3)*(d2 + d3) <= m_distance_tolerance * (dx*dx + dy*dy))
-            {
-                // If the curvature doesn't exceed the distance_tolerance value
-                // we tend to finish subdivisions.
-                //----------------------
-                if(m_angle_tolerance < curve_angle_tolerance_epsilon)
-                {
-                    _add_point(ctx, x1234, y1234);
-                    return;
-                }
-
-                // Angle & Cusp Condition
-                //----------------------
-                float a23 = atan2(y3 - y2, x3 - x2);
-                da1 = fabs(a23 - atan2(y2 - y1, x2 - x1));
-                da2 = fabs(atan2(y4 - y3, x4 - x3) - a23);
-                if(da1 >= M_PIF) da1 = M_2_PI - da1;
-                if(da2 >= M_PIF) da2 = M_2_PI - da2;
-
-                if(da1 + da2 < m_angle_tolerance)
-                {
-                    // Finally we can stop the recursion
-                    //----------------------
-                    _add_point(ctx, x1234, y1234);
-                    return;
-                }
-
-                if(m_cusp_limit != 0.0)
-                {
-                    if(da1 > m_cusp_limit)
-                    {
-                        _add_point (ctx, x2, y2);
-                        return;
-                    }
-
-                    if(da2 > m_cusp_limit)
-                    {
-                        _add_point (ctx, x3, y3);
-                        return;
-                    }
-                }
-            }
-        } else {
-            if(d2 > curve_collinearity_epsilon)
-            {
-                // p1,p3,p4 are collinear, p2 is considerable
-                //----------------------
-                if(d2 * d2 <= m_distance_tolerance * (dx*dx + dy*dy))
-                {
-                    if(m_angle_tolerance < curve_angle_tolerance_epsilon)
-                    {
-                        _add_point (ctx, x1234, y1234);
-                        return;
-                    }
-
-                    // Angle Condition
-                    //----------------------
-                    da1 = fabs(atan2(y3 - y2, x3 - x2) - atan2(y2 - y1, x2 - x1));
-                    if(da1 >= M_PIF) da1 = M_2_PI - da1;
-
-                    if(da1 < m_angle_tolerance)
-                    {
-                        _add_point (ctx, x2, y2);
-                        _add_point (ctx, x3, y3);
-                        return;
-                    }
-
-                    if(m_cusp_limit != 0.0)
-                    {
-                        if(da1 > m_cusp_limit)
-                        {
-                            _add_point (ctx, x2, y2);
-                            return;
-                        }
-                    }
-                }
-            } else if(d3 > curve_collinearity_epsilon) {
-                // p1,p2,p4 are collinear, p3 is considerable
-                //----------------------
-                if(d3 * d3 <= m_distance_tolerance * (dx*dx + dy*dy))
-                {
-                    if(m_angle_tolerance < curve_angle_tolerance_epsilon)
-                    {
-                        _add_point (ctx, x1234, y1234);
-                        return;
-                    }
-
-                    // Angle Condition
-                    //----------------------
-                    da1 = fabs(atan2(y4 - y3, x4 - x3) - atan2(y3 - y2, x3 - x2));
-                    if(da1 >= M_PIF) da1 = M_2_PI - da1;
-
-                    if(da1 < m_angle_tolerance)
-                    {
-                        _add_point (ctx, x2, y2);
-                        _add_point (ctx, x3, y3);
-                        return;
-                    }
-
-                    if(m_cusp_limit != 0.0)
-                    {
-                        if(da1 > m_cusp_limit)
-                        {
-                            _add_point (ctx, x3, y3);
-                            return;
-                        }
-                    }
-                }
-            }
-            else
-            {
-                // Collinear case
-                //-----------------
-                dx = x1234 - (x1 + x4) / 2;
-                dy = y1234 - (y1 + y4) / 2;
-                if(dx*dx + dy*dy <= m_distance_tolerance)
-                {
-                    _add_point (ctx, x1234, y1234);
-                    return;
-                }
-            }
-        }
-    }
-
-    // Continue subdivision
-    //----------------------
-    _recursive_bezier (ctx, x1, y1, x12, y12, x123, y123, x1234, y1234, level + 1);
-    _recursive_bezier (ctx, x1234, y1234, x234, y234, x34, y34, x4, y4, level + 1);
+                                               float x1, float y1, float x2, float y2,
+                                               float x3, float y3, float x4, float y4,
+                                               unsigned level) {
+       if(level > curve_recursion_limit)
+       {
+               return;
+       }
+
+       // Calculate all the mid-points of the line segments
+       //----------------------
+       float x12   = (x1 + x2) / 2;
+       float y12   = (y1 + y2) / 2;
+       float x23   = (x2 + x3) / 2;
+       float y23   = (y2 + y3) / 2;
+       float x34   = (x3 + x4) / 2;
+       float y34   = (y3 + y4) / 2;
+       float x123  = (x12 + x23) / 2;
+       float y123  = (y12 + y23) / 2;
+       float x234  = (x23 + x34) / 2;
+       float y234  = (y23 + y34) / 2;
+       float x1234 = (x123 + x234) / 2;
+       float y1234 = (y123 + y234) / 2;
+
+       if(level > 0) // Enforce subdivision first time
+       {
+               // Try to approximate the full cubic curve by a single straight line
+               //------------------
+               float dx = x4-x1;
+               float dy = y4-y1;
+
+               float d2 = fabs(((x2 - x4) * dy - (y2 - y4) * dx));
+               float d3 = fabs(((x3 - x4) * dy - (y3 - y4) * dx));
+
+               float da1, da2;
+
+               if(d2 > curve_collinearity_epsilon && d3 > curve_collinearity_epsilon)
+               {
+                       // Regular care
+                       //-----------------
+                       if((d2 + d3)*(d2 + d3) <= m_distance_tolerance * (dx*dx + dy*dy))
+                       {
+                               // If the curvature doesn't exceed the distance_tolerance value
+                               // we tend to finish subdivisions.
+                               //----------------------
+                               if(m_angle_tolerance < curve_angle_tolerance_epsilon)
+                               {
+                                       _add_point(ctx, x1234, y1234);
+                                       return;
+                               }
+
+                               // Angle & Cusp Condition
+                               //----------------------
+                               float a23 = atan2(y3 - y2, x3 - x2);
+                               da1 = fabs(a23 - atan2(y2 - y1, x2 - x1));
+                               da2 = fabs(atan2(y4 - y3, x4 - x3) - a23);
+                               if(da1 >= M_PIF) da1 = M_2_PI - da1;
+                               if(da2 >= M_PIF) da2 = M_2_PI - da2;
+
+                               if(da1 + da2 < m_angle_tolerance)
+                               {
+                                       // Finally we can stop the recursion
+                                       //----------------------
+                                       _add_point(ctx, x1234, y1234);
+                                       return;
+                               }
+
+                               if(m_cusp_limit != 0.0)
+                               {
+                                       if(da1 > m_cusp_limit)
+                                       {
+                                               _add_point (ctx, x2, y2);
+                                               return;
+                                       }
+
+                                       if(da2 > m_cusp_limit)
+                                       {
+                                               _add_point (ctx, x3, y3);
+                                               return;
+                                       }
+                               }
+                       }
+               } else {
+                       if(d2 > curve_collinearity_epsilon)
+                       {
+                               // p1,p3,p4 are collinear, p2 is considerable
+                               //----------------------
+                               if(d2 * d2 <= m_distance_tolerance * (dx*dx + dy*dy))
+                               {
+                                       if(m_angle_tolerance < curve_angle_tolerance_epsilon)
+                                       {
+                                               _add_point (ctx, x1234, y1234);
+                                               return;
+                                       }
+
+                                       // Angle Condition
+                                       //----------------------
+                                       da1 = fabs(atan2(y3 - y2, x3 - x2) - atan2(y2 - y1, x2 - x1));
+                                       if(da1 >= M_PIF) da1 = M_2_PI - da1;
+
+                                       if(da1 < m_angle_tolerance)
+                                       {
+                                               _add_point (ctx, x2, y2);
+                                               _add_point (ctx, x3, y3);
+                                               return;
+                                       }
+
+                                       if(m_cusp_limit != 0.0)
+                                       {
+                                               if(da1 > m_cusp_limit)
+                                               {
+                                                       _add_point (ctx, x2, y2);
+                                                       return;
+                                               }
+                                       }
+                               }
+                       } else if(d3 > curve_collinearity_epsilon) {
+                               // p1,p2,p4 are collinear, p3 is considerable
+                               //----------------------
+                               if(d3 * d3 <= m_distance_tolerance * (dx*dx + dy*dy))
+                               {
+                                       if(m_angle_tolerance < curve_angle_tolerance_epsilon)
+                                       {
+                                               _add_point (ctx, x1234, y1234);
+                                               return;
+                                       }
+
+                                       // Angle Condition
+                                       //----------------------
+                                       da1 = fabs(atan2(y4 - y3, x4 - x3) - atan2(y3 - y2, x3 - x2));
+                                       if(da1 >= M_PIF) da1 = M_2_PI - da1;
+
+                                       if(da1 < m_angle_tolerance)
+                                       {
+                                               _add_point (ctx, x2, y2);
+                                               _add_point (ctx, x3, y3);
+                                               return;
+                                       }
+
+                                       if(m_cusp_limit != 0.0)
+                                       {
+                                               if(da1 > m_cusp_limit)
+                                               {
+                                                       _add_point (ctx, x3, y3);
+                                                       return;
+                                               }
+                                       }
+                               }
+                       }
+                       else
+                       {
+                               // Collinear case
+                               //-----------------
+                               dx = x1234 - (x1 + x4) / 2;
+                               dy = y1234 - (y1 + y4) / 2;
+                               if(dx*dx + dy*dy <= m_distance_tolerance)
+                               {
+                                       _add_point (ctx, x1234, y1234);
+                                       return;
+                               }
+                       }
+               }
+       }
+
+       // Continue subdivision
+       //----------------------
+       _recursive_bezier (ctx, x1, y1, x12, y12, x123, y123, x1234, y1234, level + 1);
+       _recursive_bezier (ctx, x1234, y1234, x234, y234, x34, y34, x4, y4, level + 1);
 }
 void _poly_fill (VkvgContext ctx){
-    //we anticipate the check for vbo buffer size
-    if (ctx->vertCount + ctx->pointCount > ctx->sizeVBO) {
-        if (ctx->cmdStarted) {
-            _end_render_pass(ctx);
-            _flush_vertices_caches(ctx);
-            vkh_cmd_end(ctx->cmd);
-            _wait_and_submit_cmd(ctx);
-            if (ctx->vertCount + ctx->pointCount > ctx->sizeVBO)
-                _resize_vbo(ctx, ctx->vertCount + ctx->pointCount);
-        }else
-            _resize_vbo(ctx, ctx->vertCount + ctx->pointCount);
-
-        _start_cmd_for_render_pass(ctx);
-    }else
-        _check_cmd_buff_state(ctx);
-
-    CmdBindPipeline (ctx->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, ctx->pSurf->dev->pipelinePolyFill);
-
-    uint32_t ptrPath = 0;
-    Vertex v = {{0},ctx->curColor,{0,0},-1};
-
-    while (ptrPath < ctx->pathPtr){
-        if (ctx->pathes[ptrPath+1]&PATH_IS_CURVE_BIT){
-            ptrPath += 2;
-            continue;
-        }
-        //close path
-        ctx->pathes[ptrPath] |= PATH_CLOSED_BIT;// ctx->pathes[ptrPath];//close path by setting start and end equal
-
-        uint32_t firstPtIdx = ctx->pathes [ptrPath] & PATH_ELT_MASK;
-        uint32_t lastPtIdx  = ctx->pathes [ptrPath+1] & PATH_ELT_MASK;//_get_last_point_of_closed_path (ctx, ptrPath);
-        uint32_t pathPointCount = lastPtIdx - firstPtIdx + 1;
-
-        VKVG_IBO_INDEX_TYPE firstVertIdx = ctx->vertCount;
-
-        for (uint i = 0; i < pathPointCount; i++) {
-            v.pos = ctx->points [i+firstPtIdx];
-            ctx->vertexCache[ctx->vertCount] = v;
-            ctx->vertCount++;
-        }
-
-        LOG(LOG_INFO_PATH, "\tpoly fill: point count = %d; 1st vert = %d; vert count = %d\n", pathPointCount, firstVertIdx, ctx->vertCount - firstVertIdx);
-        CmdDraw (ctx->cmd, pathPointCount, 1, firstVertIdx ,0);
-
-        ptrPath+=2;
-    }
-    ctx->curVertOffset = ctx->vertCount;
+       //we anticipate the check for vbo buffer size
+       if (ctx->vertCount + ctx->pointCount > ctx->sizeVBO) {
+               if (ctx->cmdStarted) {
+                       _end_render_pass(ctx);
+                       _flush_vertices_caches(ctx);
+                       vkh_cmd_end(ctx->cmd);
+                       _wait_and_submit_cmd(ctx);
+                       if (ctx->vertCount + ctx->pointCount > ctx->sizeVBO)
+                               _resize_vbo(ctx, ctx->vertCount + ctx->pointCount);
+               }else
+                       _resize_vbo(ctx, ctx->vertCount + ctx->pointCount);
+
+               _start_cmd_for_render_pass(ctx);
+       }else
+               _check_cmd_buff_state(ctx);
+
+       CmdBindPipeline (ctx->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, ctx->pSurf->dev->pipelinePolyFill);
+
+       uint32_t ptrPath = 0;
+       Vertex v = {{0},ctx->curColor,{0,0},-1};
+
+       while (ptrPath < ctx->pathPtr){
+               if (ctx->pathes[ptrPath+1]&PATH_IS_CURVE_BIT){
+                       ptrPath += 2;
+                       continue;
+               }
+               //close path
+               ctx->pathes[ptrPath] |= PATH_CLOSED_BIT;// ctx->pathes[ptrPath];//close path by setting start and end equal
+
+               uint32_t firstPtIdx = ctx->pathes [ptrPath] & PATH_ELT_MASK;
+               uint32_t lastPtIdx  = ctx->pathes [ptrPath+1] & PATH_ELT_MASK;//_get_last_point_of_closed_path (ctx, ptrPath);
+               uint32_t pathPointCount = lastPtIdx - firstPtIdx + 1;
+
+               VKVG_IBO_INDEX_TYPE firstVertIdx = ctx->vertCount;
+
+               for (uint i = 0; i < pathPointCount; i++) {
+                       v.pos = ctx->points [i+firstPtIdx];
+                       ctx->vertexCache[ctx->vertCount] = v;
+                       ctx->vertCount++;
+               }
+
+               LOG(LOG_INFO_PATH, "\tpoly fill: point count = %d; 1st vert = %d; vert count = %d\n", pathPointCount, firstVertIdx, ctx->vertCount - firstVertIdx);
+               CmdDraw (ctx->cmd, pathPointCount, 1, firstVertIdx ,0);
+
+               ptrPath+=2;
+       }
+       ctx->curVertOffset = ctx->vertCount;
 }
 void _fill_ec (VkvgContext ctx){
-    uint32_t ptrPath = 0;;
-    Vertex v = {{0},ctx->curColor,{0,0},-1};
-
-    while (ptrPath < ctx->pathPtr){
-        if (ctx->pathes[ptrPath+1]&PATH_IS_CURVE_BIT){
-            ptrPath += 2;
-            continue;
-        }
-        ctx->pathes[ptrPath]|=PATH_CLOSED_BIT;//close path
-
-        uint32_t firstPtIdx = ctx->pathes[ptrPath]&PATH_ELT_MASK;
-        uint32_t lastPtIdx = ctx->pathes[ptrPath+1]&PATH_ELT_MASK;
-        uint32_t pathPointCount = lastPtIdx - firstPtIdx + 1;
-        uint32_t firstVertIdx = ctx->vertCount-ctx->curVertOffset;
-
-        ear_clip_point ecps[pathPointCount];        
-        uint32_t ecps_count = 0, i = 0;
-
-        //init points link list
-        while (i < pathPointCount-1){
-            vec2 np = ctx->points[i+firstPtIdx];
-            if (!vec2_equ(np, v.pos)){
-                v.pos = np;
-                ear_clip_point ecp = {v.pos, ecps_count+firstVertIdx, &ecps[ecps_count+1]};
-                ecps[ecps_count] = ecp;
-                _add_vertex(ctx, v);
-                ecps_count++;
-            }
-            i++;
-        }
-
-        v.pos = ctx->points[i+firstPtIdx];
-        ear_clip_point ecp = {v.pos, ecps_count+firstVertIdx, ecps};
-        ecps[ecps_count] = ecp;
-        _add_vertex(ctx, v);
-        ecps_count++;
-
-        ear_clip_point* ecp_current = ecps;
-        uint32_t tries = 0;
-
-        while (ecps_count > 3) {
-            if (tries > ecps_count) {
-                break;
-            }
-            ear_clip_point* v0 = ecp_current->next,
-                    *v1 = ecp_current, *v2 = ecp_current->next->next;
-            if (ecp_zcross (v0, v2, v1)<0){
-                ecp_current = ecp_current->next;
-                tries++;
-                continue;
-            }
-            ear_clip_point* vP = v2->next;
-            bool isEar = true;
-            while (vP!=v1){
-                if (ptInTriangle (vP->pos, v0->pos, v2->pos, v1->pos)){
-                    isEar = false;
-                    break;
-                }
-                vP = vP->next;
-            }
-            if (isEar){
-                _add_triangle_indices (ctx, v0->idx, v1->idx, v2->idx);
-                v1->next = v2;
-                ecps_count --;
-                tries = 0;
-            }else{
-                ecp_current = ecp_current->next;
-                tries++;
-            }
-        }
-        if (ecps_count == 3)
-            _add_triangle_indices(ctx, ecp_current->next->idx, ecp_current->idx, ecp_current->next->next->idx);
-
-        ptrPath+=2;
-    }
-    //_record_draw_cmd(ctx);
+       uint32_t ptrPath = 0;;
+       Vertex v = {{0},ctx->curColor,{0,0},-1};
+
+       while (ptrPath < ctx->pathPtr){
+               if (ctx->pathes[ptrPath+1]&PATH_IS_CURVE_BIT){
+                       ptrPath += 2;
+                       continue;
+               }
+               ctx->pathes[ptrPath]|=PATH_CLOSED_BIT;//close path
+
+               uint32_t firstPtIdx = ctx->pathes[ptrPath]&PATH_ELT_MASK;
+               uint32_t lastPtIdx = ctx->pathes[ptrPath+1]&PATH_ELT_MASK;
+               uint32_t pathPointCount = lastPtIdx - firstPtIdx + 1;
+               uint32_t firstVertIdx = ctx->vertCount-ctx->curVertOffset;
+
+               ear_clip_point ecps[pathPointCount];
+               uint32_t ecps_count = 0, i = 0;
+
+               //init points link list
+               while (i < pathPointCount-1){
+                       vec2 np = ctx->points[i+firstPtIdx];
+                       if (!vec2_equ(np, v.pos)){
+                               v.pos = np;
+                               ear_clip_point ecp = {v.pos, ecps_count+firstVertIdx, &ecps[ecps_count+1]};
+                               ecps[ecps_count] = ecp;
+                               _add_vertex(ctx, v);
+                               ecps_count++;
+                       }
+                       i++;
+               }
+
+               v.pos = ctx->points[i+firstPtIdx];
+               ear_clip_point ecp = {v.pos, ecps_count+firstVertIdx, ecps};
+               ecps[ecps_count] = ecp;
+               _add_vertex(ctx, v);
+               ecps_count++;
+
+               ear_clip_point* ecp_current = ecps;
+               uint32_t tries = 0;
+
+               while (ecps_count > 3) {
+                       if (tries > ecps_count) {
+                               break;
+                       }
+                       ear_clip_point* v0 = ecp_current->next,
+                                       *v1 = ecp_current, *v2 = ecp_current->next->next;
+                       if (ecp_zcross (v0, v2, v1)<0){
+                               ecp_current = ecp_current->next;
+                               tries++;
+                               continue;
+                       }
+                       ear_clip_point* vP = v2->next;
+                       bool isEar = true;
+                       while (vP!=v1){
+                               if (ptInTriangle (vP->pos, v0->pos, v2->pos, v1->pos)){
+                                       isEar = false;
+                                       break;
+                               }
+                               vP = vP->next;
+                       }
+                       if (isEar){
+                               _add_triangle_indices (ctx, v0->idx, v1->idx, v2->idx);
+                               v1->next = v2;
+                               ecps_count --;
+                               tries = 0;
+                       }else{
+                               ecp_current = ecp_current->next;
+                               tries++;
+                       }
+               }
+               if (ecps_count == 3)
+                       _add_triangle_indices(ctx, ecp_current->next->idx, ecp_current->idx, ecp_current->next->next->idx);
+
+               ptrPath+=2;
+       }
+       //_record_draw_cmd(ctx);
 }
 
 static const uint32_t one = 1;
 static const uint32_t zero = 0;
 void _draw_full_screen_quad (VkvgContext ctx, bool useScissor) {
-    if (ctx->xMin < 0 || ctx->yMin < 0)
-        useScissor = false;
-    if (useScissor && ctx->xMin < FLT_MAX) {
-        VkRect2D r = {ctx->xMin, ctx->yMin, ctx->xMax - ctx->xMin, ctx->yMax - ctx->yMin};
-        CmdSetScissor(ctx->cmd, 0, 1, &r);
-    }
-    CmdPushConstants(ctx->cmd, ctx->pSurf->dev->pipelineLayout,
-                       VK_SHADER_STAGE_VERTEX_BIT, 28, 4,&one);
-    CmdDraw (ctx->cmd,3,1,0,0);
-    CmdPushConstants(ctx->cmd, ctx->pSurf->dev->pipelineLayout,
-                       VK_SHADER_STAGE_VERTEX_BIT, 28, 4,&zero);
-    if (useScissor && ctx->xMin < FLT_MAX)
-        CmdSetScissor(ctx->cmd, 0, 1, &ctx->bounds);
+       /*if (ctx->xMin < 0 || ctx->yMin < 0)
+               useScissor = false;
+       if (useScissor && ctx->xMin < FLT_MAX) {
+               VkRect2D r = {ctx->xMin, ctx->yMin, ctx->xMax - ctx->xMin, ctx->yMax - ctx->yMin};
+               CmdSetScissor(ctx->cmd, 0, 1, &r);
+       }*/
+       CmdPushConstants(ctx->cmd, ctx->pSurf->dev->pipelineLayout,
+                                          VK_SHADER_STAGE_VERTEX_BIT, 28, 4,&one);
+       CmdDraw (ctx->cmd,3,1,0,0);
+       CmdPushConstants(ctx->cmd, ctx->pSurf->dev->pipelineLayout,
+                                          VK_SHADER_STAGE_VERTEX_BIT, 28, 4,&zero);
+       /*if (useScissor && ctx->xMin < FLT_MAX)
+               CmdSetScissor(ctx->cmd, 0, 1, &ctx->bounds);*/
 }
index fd793f6b3ae6ffb81112d7f4334d2f58ca520b38..014d2942b81cd6b88ea32f96446a2b663941ce58 100644 (file)
@@ -209,7 +209,6 @@ void _build_vb_step         (vkvg_context* ctx, Vertex v, float hw, uint32_t iL,
 void _vao_add_rectangle     (VkvgContext ctx, float x, float y, float width, float height);
 
 void _bind_draw_pipeline    (VkvgContext ctx);
-void _create_cmd_buff          (VkvgContext ctx);
 void _check_cmd_buff_state  (VkvgContext ctx);
 void _flush_cmd_buff           (VkvgContext ctx);
 
index fbda494bb5328ac37ba35d437e179451fc140996..0869e6c2743701be2a1fa4ad8f299b7710273a19 100644 (file)
@@ -35,7 +35,7 @@
  */
 VkvgDevice vkvg_device_create(VkInstance inst, VkPhysicalDevice phy, VkDevice vkdev, uint32_t qFamIdx, uint32_t qIndex)
 {
-    return vkvg_device_create_multisample (inst,phy,vkdev,qFamIdx,qIndex, VK_SAMPLE_COUNT_1_BIT, false);
+       return vkvg_device_create_multisample (inst,phy,vkdev,qFamIdx,qIndex, VK_SAMPLE_COUNT_1_BIT, false);
 }
 /**
  * @brief Create VkvgDevice with default multisampling configuration
@@ -52,119 +52,143 @@ VkvgDevice vkvg_device_create(VkInstance inst, VkPhysicalDevice phy, VkDevice vk
  */
 VkvgDevice vkvg_device_create_multisample(VkInstance inst, VkPhysicalDevice phy, VkDevice vkdev, uint32_t qFamIdx, uint32_t qIndex, VkSampleCountFlags samples, bool deferredResolve)
 {
-    LOG(LOG_INFO, "CREATE Device: qFam = %d; qIdx = %d\n", qFamIdx, qIndex);
-
-    VkvgDevice dev = (vkvg_device*)malloc(sizeof(vkvg_device));
-
-    dev->instance = inst;
-    dev->hdpi   = 96;
-    dev->vdpi   = 96;
-    dev->samples= samples;
-    dev->deferredResolve = deferredResolve;
-    dev->vkDev  = vkdev;
-    dev->phy    = phy;
-
-    _init_function_pointers (dev);
-
-    VkhPhyInfo phyInfos = vkh_phyinfo_create (dev->phy, NULL);
-
-    dev->phyMemProps = phyInfos->memProps;
-    dev->gQueue = vkh_queue_create ((VkhDevice)dev, qFamIdx, qIndex, phyInfos->queues[qFamIdx].queueFlags);
-    MUTEX_INIT (&dev->gQMutex);
-
-    vkh_phyinfo_destroy (phyInfos);
-
-    VmaAllocatorCreateInfo allocatorInfo = {
-        .physicalDevice = phy,
-        .device = vkdev
-    };
-    vmaCreateAllocator(&allocatorInfo, &dev->allocator);
-
-    dev->lastCtx= NULL;
-
-    dev->cmdPool= vkh_cmd_pool_create       ((VkhDevice)dev, dev->gQueue->familyIndex, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT);
-    dev->cmd    = vkh_cmd_buff_create       ((VkhDevice)dev, dev->cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY);
-    dev->fence  = vkh_fence_create_signaled ((VkhDevice)dev);
-
-    _create_pipeline_cache      (dev);
-    _init_fonts_cache           (dev);
-    if (dev->deferredResolve || dev->samples == VK_SAMPLE_COUNT_1_BIT){
-        dev->renderPass = _createRenderPassNoResolve (dev, VK_ATTACHMENT_LOAD_OP_LOAD, VK_ATTACHMENT_LOAD_OP_LOAD);
-        dev->renderPass_ClearStencil = _createRenderPassNoResolve (dev, VK_ATTACHMENT_LOAD_OP_LOAD, VK_ATTACHMENT_LOAD_OP_CLEAR);
-        dev->renderPass_ClearAll = _createRenderPassNoResolve (dev, VK_ATTACHMENT_LOAD_OP_CLEAR, VK_ATTACHMENT_LOAD_OP_CLEAR);
-    }else{
-        dev->renderPass = _createRenderPassMS (dev, VK_ATTACHMENT_LOAD_OP_LOAD, VK_ATTACHMENT_LOAD_OP_LOAD);
-        dev->renderPass_ClearStencil = _createRenderPassMS (dev, VK_ATTACHMENT_LOAD_OP_LOAD, VK_ATTACHMENT_LOAD_OP_CLEAR);
-        dev->renderPass_ClearAll = _createRenderPassMS (dev, VK_ATTACHMENT_LOAD_OP_CLEAR, VK_ATTACHMENT_LOAD_OP_CLEAR);
-    }
-    _createDescriptorSetLayout  (dev);
-    _setupPipelines             (dev);
-
-    _create_empty_texture       (dev);
-
-    memset(dev->samplers, 0, 10 * sizeof (VkSampler));
-
-    dev->references = 1;
+       LOG(LOG_INFO, "CREATE Device: qFam = %d; qIdx = %d\n", qFamIdx, qIndex);
+
+       VkvgDevice dev = (vkvg_device*)malloc(sizeof(vkvg_device));
+
+       dev->instance = inst;
+       dev->hdpi   = 96;
+       dev->vdpi   = 96;
+       dev->samples= samples;
+       dev->deferredResolve = deferredResolve;
+       dev->vkDev  = vkdev;
+       dev->phy    = phy;
+
+       _init_function_pointers (dev);
+
+       VkhPhyInfo phyInfos = vkh_phyinfo_create (dev->phy, NULL);
+
+       dev->phyMemProps = phyInfos->memProps;
+       dev->gQueue = vkh_queue_create ((VkhDevice)dev, qFamIdx, qIndex);
+       MUTEX_INIT (&dev->gQMutex);
+
+       vkh_phyinfo_destroy (phyInfos);
+
+       VmaAllocatorCreateInfo allocatorInfo = {
+               .physicalDevice = phy,
+               .device = vkdev
+       };
+       vmaCreateAllocator(&allocatorInfo, &dev->allocator);
+
+       dev->lastCtx= NULL;
+
+       dev->cmdPool= vkh_cmd_pool_create       ((VkhDevice)dev, dev->gQueue->familyIndex, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT);
+       dev->cmd    = vkh_cmd_buff_create       ((VkhDevice)dev, dev->cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY);
+       dev->fence  = vkh_fence_create_signaled ((VkhDevice)dev);
+
+       _create_pipeline_cache      (dev);
+       _init_fonts_cache           (dev);
+       if (dev->deferredResolve || dev->samples == VK_SAMPLE_COUNT_1_BIT){
+               dev->renderPass = _createRenderPassNoResolve (dev, VK_ATTACHMENT_LOAD_OP_LOAD, VK_ATTACHMENT_LOAD_OP_LOAD);
+               dev->renderPass_ClearStencil = _createRenderPassNoResolve (dev, VK_ATTACHMENT_LOAD_OP_LOAD, VK_ATTACHMENT_LOAD_OP_CLEAR);
+               dev->renderPass_ClearAll = _createRenderPassNoResolve (dev, VK_ATTACHMENT_LOAD_OP_CLEAR, VK_ATTACHMENT_LOAD_OP_CLEAR);
+       }else{
+               dev->renderPass = _createRenderPassMS (dev, VK_ATTACHMENT_LOAD_OP_LOAD, VK_ATTACHMENT_LOAD_OP_LOAD);
+               dev->renderPass_ClearStencil = _createRenderPassMS (dev, VK_ATTACHMENT_LOAD_OP_LOAD, VK_ATTACHMENT_LOAD_OP_CLEAR);
+               dev->renderPass_ClearAll = _createRenderPassMS (dev, VK_ATTACHMENT_LOAD_OP_CLEAR, VK_ATTACHMENT_LOAD_OP_CLEAR);
+       }
+       _createDescriptorSetLayout  (dev);
+       _setupPipelines             (dev);
+
+       _create_empty_texture       (dev);
+
+       memset(dev->samplers, 0, 10 * sizeof (VkSampler));
+
+       dev->references = 1;
+
+#ifdef DEBUG
+       vkh_device_set_object_name((VkhDevice)dev, VK_OBJECT_TYPE_COMMAND_POOL, (uint64_t)dev->cmdPool, "Device Cmd Pool");
+       vkh_device_set_object_name((VkhDevice)dev, VK_OBJECT_TYPE_COMMAND_BUFFER, (uint64_t)dev->cmd, "Device Cmd Buff");
+       vkh_device_set_object_name((VkhDevice)dev, VK_OBJECT_TYPE_FENCE, (uint64_t)dev->fence, "Device Fence");
+       vkh_device_set_object_name((VkhDevice)dev, VK_OBJECT_TYPE_RENDER_PASS, (uint64_t)dev->renderPass, "RP load img/stencil");
+       vkh_device_set_object_name((VkhDevice)dev, VK_OBJECT_TYPE_RENDER_PASS, (uint64_t)dev->renderPass_ClearStencil, "RP clear stencil");
+       vkh_device_set_object_name((VkhDevice)dev, VK_OBJECT_TYPE_RENDER_PASS, (uint64_t)dev->renderPass_ClearAll, "RP clear all");
+
+       vkh_device_set_object_name((VkhDevice)dev, VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT, (uint64_t)dev->dslSrc, "DSLayout SOURCE");
+       //vkh_device_set_object_name((VkhDevice)dev, VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT, (uint64_t)dev->dslFont, "DSLayout FONT");
+       //vkh_device_set_object_name((VkhDevice)dev, VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT, (uint64_t)dev->dslGrad, "DSLayout GRADIENT");
+       vkh_device_set_object_name((VkhDevice)dev, VK_OBJECT_TYPE_PIPELINE_LAYOUT, (uint64_t)dev->pipelineLayout, "PLLayout dev");
+
+       //vkh_device_set_object_name((VkhDevice)dev, VK_OBJECT_TYPE_PIPELINE, (uint64_t)dev->pipelinePolyFill, "PL Poly fill");
+       //vkh_device_set_object_name((VkhDevice)dev, VK_OBJECT_TYPE_PIPELINE, (uint64_t)dev->pipelineClipping, "PL Clipping");
+       vkh_device_set_object_name((VkhDevice)dev, VK_OBJECT_TYPE_PIPELINE, (uint64_t)dev->pipe_OVER, "PL draw Over");
+       vkh_device_set_object_name((VkhDevice)dev, VK_OBJECT_TYPE_PIPELINE, (uint64_t)dev->pipe_SUB, "PL draw Substract");
+       vkh_device_set_object_name((VkhDevice)dev, VK_OBJECT_TYPE_PIPELINE, (uint64_t)dev->pipe_CLEAR, "PL draw Clear");
+
+       vkh_image_set_name(dev->emptyImg, "empty IMG");
+       vkh_device_set_object_name((VkhDevice)dev, VK_OBJECT_TYPE_IMAGE_VIEW, (uint64_t)vkh_image_get_view(dev->emptyImg), "empty IMG VIEW");
+       //vkh_device_set_object_name((VkhDevice)dev, VK_OBJECT_TYPE_SAMPLER, (uint64_t)vkh_image_get_sampler(dev->emptyImg), "empty IMG SAMPLER");
+#endif
 
-    return dev;
+       return dev;
 }
 
 void vkvg_device_destroy (VkvgDevice dev)
 {
-    dev->references--;
-    if (dev->references > 0)
-        return;
+       dev->references--;
+       if (dev->references > 0)
+               return;
 
-    LOG(LOG_INFO, "DESTROY Device\n");
+       LOG(LOG_INFO, "DESTROY Device\n");
 
-    vkh_image_destroy               (dev->emptyImg);
+       vkh_image_destroy               (dev->emptyImg);
 
-    _destroy_samplers               (dev);
-    //vkDestroyDescriptorSetLayout    (dev->vkDev, dev->dslGrad,NULL);
-    //vkDestroyDescriptorSetLayout    (dev->vkDev, dev->dslFont,NULL);
-    vkDestroyDescriptorSetLayout    (dev->vkDev, dev->dslSrc, NULL);
+       _destroy_samplers               (dev);
+       //vkDestroyDescriptorSetLayout    (dev->vkDev, dev->dslGrad,NULL);
+       //vkDestroyDescriptorSetLayout    (dev->vkDev, dev->dslFont,NULL);
+       vkDestroyDescriptorSetLayout    (dev->vkDev, dev->dslSrc, NULL);
 
-    //vkDestroyPipeline               (dev->vkDev, dev->pipelinePolyFill, NULL);
-    //vkDestroyPipeline               (dev->vkDev, dev->pipelineClipping, NULL);
+       //vkDestroyPipeline               (dev->vkDev, dev->pipelinePolyFill, NULL);
+       //vkDestroyPipeline               (dev->vkDev, dev->pipelineClipping, NULL);
 
-    vkDestroyPipeline               (dev->vkDev, dev->pipe_OVER,    NULL);
-    vkDestroyPipeline               (dev->vkDev, dev->pipe_SUB,     NULL);
-    vkDestroyPipeline               (dev->vkDev, dev->pipe_CLEAR,   NULL);
+       vkDestroyPipeline               (dev->vkDev, dev->pipe_OVER,    NULL);
+       vkDestroyPipeline               (dev->vkDev, dev->pipe_SUB,     NULL);
+       vkDestroyPipeline               (dev->vkDev, dev->pipe_CLEAR,   NULL);
 
 #ifdef VKVG_WIRED_DEBUG
-    vkDestroyPipeline               (dev->vkDev, dev->pipelineWired, NULL);
-    vkDestroyPipeline               (dev->vkDev, dev->pipelineLineList, NULL);
+       vkDestroyPipeline               (dev->vkDev, dev->pipelineWired, NULL);
+       vkDestroyPipeline               (dev->vkDev, dev->pipelineLineList, NULL);
 #endif
 
-    vkDestroyPipelineLayout         (dev->vkDev, dev->pipelineLayout, NULL);
-    vkDestroyPipelineCache          (dev->vkDev, dev->pipelineCache, NULL);
-    vkDestroyRenderPass             (dev->vkDev, dev->renderPass, NULL);
-    vkDestroyRenderPass             (dev->vkDev, dev->renderPass_ClearStencil, NULL);
-    vkDestroyRenderPass             (dev->vkDev, dev->renderPass_ClearAll, NULL);
+       vkDestroyPipelineLayout         (dev->vkDev, dev->pipelineLayout, NULL);
+       vkDestroyPipelineCache          (dev->vkDev, dev->pipelineCache, NULL);
+       vkDestroyRenderPass             (dev->vkDev, dev->renderPass, NULL);
+       vkDestroyRenderPass             (dev->vkDev, dev->renderPass_ClearStencil, NULL);
+       vkDestroyRenderPass             (dev->vkDev, dev->renderPass_ClearAll, NULL);
 
-    vkWaitForFences                 (dev->vkDev, 1, &dev->fence, VK_TRUE, UINT64_MAX);
+       vkWaitForFences                 (dev->vkDev, 1, &dev->fence, VK_TRUE, UINT64_MAX);
 
-    vkDestroyFence                  (dev->vkDev, dev->fence,NULL);
-    vkFreeCommandBuffers            (dev->vkDev, dev->cmdPool, 1, &dev->cmd);
-    vkDestroyCommandPool            (dev->vkDev, dev->cmdPool, NULL);
+       vkDestroyFence                  (dev->vkDev, dev->fence,NULL);
+       vkFreeCommandBuffers            (dev->vkDev, dev->cmdPool, 1, &dev->cmd);
+       vkDestroyCommandPool            (dev->vkDev, dev->cmdPool, NULL);
 
-    _destroy_font_cache             (dev);
+       _destroy_font_cache             (dev);
 
-    vmaDestroyAllocator             (dev->allocator);
+       vmaDestroyAllocator             (dev->allocator);
 
-    MUTEX_DESTROY (&dev->gQMutex);
+       MUTEX_DESTROY (&dev->gQMutex);
 
-    vkh_queue_destroy               (dev->gQueue);
+       vkh_queue_destroy               (dev->gQueue);
 
-    free(dev);
+       free(dev);
 }
 
 VkvgDevice vkvg_device_reference (VkvgDevice dev) {
-    dev->references++;
-    return dev;
+       dev->references++;
+       return dev;
 }
 uint32_t vkvg_device_get_reference_count (VkvgDevice dev) {
-    return dev->references;
+       return dev->references;
 }
 /**
  * @brief set horizontal and vertical resolution of device in dot per inch
@@ -173,10 +197,10 @@ uint32_t vkvg_device_get_reference_count (VkvgDevice dev) {
  * @param vertical device resolution in dot per inch
  */
 void vkvg_device_set_dpy (VkvgDevice dev, int hdpy, int vdpy) {
-    dev->hdpi = hdpy;
-    dev->vdpi = vdpy;
+       dev->hdpi = hdpy;
+       dev->vdpi = vdpy;
 
-    //TODO: reset font cache
+       //TODO: reset font cache
 }
 /**
  * @brief get horizontal and vertical resolution of device in dot per inch
@@ -185,6 +209,6 @@ void vkvg_device_set_dpy (VkvgDevice dev, int hdpy, int vdpy) {
  * @param return vertical device resolution in dot per inch
  */
 void vkvg_device_get_dpy (VkvgDevice dev, int* hdpy, int* vdpy) {
-    *hdpy = dev->hdpi;
-    *vdpy = dev->vdpi;
+       *hdpy = dev->hdpi;
+       *vdpy = dev->vdpi;
 }
index f8f2dd7fce9f166743614d3cc418b07f280cb77e..1755e98219421a9b0374e5752a59d996a5f649e7 100644 (file)
@@ -241,7 +241,7 @@ void _setupPipelines(VkvgDevice dev)
                 .inputRate = VK_VERTEX_INPUT_RATE_VERTEX };
 
     VkVertexInputAttributeDescription vertexInputAttributs[4] = {
-        {0, 0, VK_FORMAT_R32G32_SFLOAT,         0},        
+        {0, 0, VK_FORMAT_R32G32_SFLOAT,         0},
         {1, 0, VK_FORMAT_R8G8B8A8_UNORM,        8},
         {2, 0, VK_FORMAT_R32G32_SFLOAT,        12},
         {3, 0, VK_FORMAT_R8_SINT,              20},
@@ -424,6 +424,7 @@ void _wait_idle (VkvgDevice dev) {
 void _wait_and_reset_device_fence (VkvgDevice dev) {
     vkWaitForFences (dev->vkDev, 1, &dev->fence, VK_TRUE, UINT64_MAX);
     vkResetFences (dev->vkDev, 1, &dev->fence);
+    vkResetCommandBuffer (dev->cmd, 0);
 }
 
 void _submit_cmd (VkvgDevice dev, VkCommandBuffer* cmd, VkFence fence) {
@@ -457,11 +458,16 @@ void _create_empty_texture (VkvgDevice dev) {
     vkh_image_create_descriptor(dev->emptyImg, VK_IMAGE_VIEW_TYPE_2D, VK_IMAGE_ASPECT_COLOR_BIT, VK_FILTER_NEAREST, VK_FILTER_NEAREST, VK_SAMPLER_MIPMAP_MODE_NEAREST,VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE);
 
     _wait_and_reset_device_fence (dev);
-
     vkh_cmd_begin (dev->cmd, VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT);
+#ifdef DEBUG
+    vkh_cmd_label_start(dev->cmd, "create empty texture", (float[]){0.5,0,0,1});
+#endif
     vkh_image_set_layout (dev->cmd, dev->emptyImg, VK_IMAGE_ASPECT_COLOR_BIT,
                           VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
                           VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT);
+#ifdef DEBUG
+    vkh_cmd_label_end(dev->cmd);
+#endif
     vkh_cmd_end (dev->cmd);
     _submit_cmd (dev, &dev->cmd, dev->fence);
 }
index 34d3743cd01037071215fff0a9b506c1f517c069..8263ecff590919e92c04717df0875a95c2add897 100644 (file)
@@ -53,7 +53,7 @@ void _init_fonts_cache (VkvgDevice dev){
     vkh_image_create_descriptor (cache->texture, VK_IMAGE_VIEW_TYPE_2D_ARRAY, VK_IMAGE_ASPECT_COLOR_BIT,
                                  VK_FILTER_NEAREST, VK_FILTER_NEAREST, VK_SAMPLER_MIPMAP_MODE_NEAREST, VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER);
 
-    cache->uploadFence = vkh_fence_create((VkhDevice)dev);
+    cache->uploadFence = dev->fence; //vkh_fence_create((VkhDevice)dev);
 
     uint32_t buffLength = FONT_PAGE_SIZE*FONT_PAGE_SIZE*cache->texPixelSize;
 
@@ -62,7 +62,7 @@ void _init_fonts_cache (VkvgDevice dev){
         VMA_MEMORY_USAGE_CPU_TO_GPU,
         buffLength, &cache->buff);
 
-    cache->cmd = vkh_cmd_buff_create((VkhDevice)dev,dev->cmdPool,VK_COMMAND_BUFFER_LEVEL_PRIMARY);
+    cache->cmd = dev->cmd;// vkh_cmd_buff_create((VkhDevice)dev,dev->cmdPool,VK_COMMAND_BUFFER_LEVEL_PRIMARY);
 
     //Set texture cache initial layout to shaderReadOnly to prevent error msg if cache is not fill
     VkImageSubresourceRange subres      = {VK_IMAGE_ASPECT_COLOR_BIT,0,1,0,cache->texLength};
@@ -71,6 +71,8 @@ void _init_fonts_cache (VkvgDevice dev){
                                 VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
                                 VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
     VK_CHECK_RESULT(vkEndCommandBuffer(cache->cmd));
+    vkWaitForFences (dev->vkDev, 1, &cache->uploadFence, VK_TRUE, UINT64_MAX);
+    vkResetFences   (dev->vkDev, 1, &cache->uploadFence);
     _submit_cmd (dev, &cache->cmd, cache->uploadFence);
 
     cache->hostBuff = (uint8_t*)malloc(buffLength);
@@ -154,7 +156,7 @@ void _init_next_line_in_tex_cache (VkvgDevice dev, _vkvg_font_t* f){
     _init_next_line_in_tex_cache(dev, f);
 }
 void _destroy_font_cache (VkvgDevice dev){
-    _font_cache_t* cache = (_font_cache_t*)dev->fontCache;    
+    _font_cache_t* cache = (_font_cache_t*)dev->fontCache;
 
     free (cache->hostBuff);
 
@@ -180,7 +182,7 @@ void _destroy_font_cache (VkvgDevice dev){
     vkvg_buffer_destroy (&cache->buff);
     vkh_image_destroy   (cache->texture);
     //vkFreeCommandBuffers(dev->vkDev,dev->cmdPool, 1, &cache->cmd);
-    vkDestroyFence      (dev->vkDev,cache->uploadFence,NULL);
+    //vkDestroyFence      (dev->vkDev,cache->uploadFence,NULL);
 
     FT_CHECK_RESULT(FT_Done_FreeType (cache->library));
 
index 3b88763a499326ff2d4bf575bd9161c2c746f833..cb9800959b4865ea25c0664161fbcfe8f04de471 100644 (file)
@@ -115,6 +115,11 @@ void _create_surface_main_image (VkvgSurface surf){
     surf->img = vkh_image_create((VkhDevice)surf->dev,surf->format,surf->width,surf->height,VKVG_TILING,VMA_MEMORY_USAGE_GPU_ONLY,
                                      VK_IMAGE_USAGE_SAMPLED_BIT|VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT|VK_IMAGE_USAGE_TRANSFER_SRC_BIT|VK_IMAGE_USAGE_TRANSFER_DST_BIT);
     vkh_image_create_view(surf->img, VK_IMAGE_VIEW_TYPE_2D, VK_IMAGE_ASPECT_COLOR_BIT);
+#ifdef DEBUG
+    vkh_image_set_name(surf->img, "SURF main color");
+    vkh_device_set_object_name((VkhDevice)surf->dev, VK_OBJECT_TYPE_IMAGE_VIEW, (uint64_t)vkh_image_get_view(surf->img), "SURF main color VIEW");
+    //vkh_device_set_object_name((VkhDevice)surf->dev, VK_OBJECT_TYPE_SAMPLER, (uint64_t)vkh_image_get_sampler(surf->img), "SURF main color SAMPLER");
+#endif
 }
 //create multisample color img if sample count > 1 and the stencil buffer multisampled or not
 void _create_surface_secondary_images (VkvgSurface surf) {
@@ -122,9 +127,19 @@ void _create_surface_secondary_images (VkvgSurface surf) {
         surf->imgMS = vkh_image_ms_create((VkhDevice)surf->dev,surf->format,surf->dev->samples,surf->width,surf->height,VMA_MEMORY_USAGE_GPU_ONLY,
                                           VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT|VK_IMAGE_USAGE_TRANSFER_DST_BIT|VK_IMAGE_USAGE_TRANSFER_SRC_BIT);
         vkh_image_create_view(surf->imgMS, VK_IMAGE_VIEW_TYPE_2D, VK_IMAGE_ASPECT_COLOR_BIT);
+#ifdef DEBUG
+        vkh_image_set_name(surf->imgMS, "SURF MS color IMG");
+        vkh_device_set_object_name((VkhDevice)surf->dev, VK_OBJECT_TYPE_IMAGE_VIEW, (uint64_t)vkh_image_get_view(surf->imgMS), "SURF MS color VIEW");
+        //vkh_device_set_object_name((VkhDevice)surf->dev, VK_OBJECT_TYPE_SAMPLER, (uint64_t)vkh_image_get_sampler(surf->imgMS), "SURF MS color SAMPLER");
+#endif
     }
     surf->stencil = vkh_image_ms_create((VkhDevice)surf->dev,FB_STENCIL_FORMAT,surf->dev->samples,surf->width,surf->height,VMA_MEMORY_USAGE_GPU_ONLY,                                     VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT|VK_IMAGE_USAGE_TRANSFER_DST_BIT|VK_IMAGE_USAGE_TRANSFER_SRC_BIT);
     vkh_image_create_view(surf->stencil, VK_IMAGE_VIEW_TYPE_2D, VK_IMAGE_ASPECT_STENCIL_BIT);
+#ifdef DEBUG
+    vkh_image_set_name(surf->stencil, "SURF stencil");
+    vkh_device_set_object_name((VkhDevice)surf->dev, VK_OBJECT_TYPE_IMAGE_VIEW, (uint64_t)vkh_image_get_view(surf->stencil), "SURF stencil VIEW");
+    //vkh_device_set_object_name((VkhDevice)surf->dev, VK_OBJECT_TYPE_SAMPLER, (uint64_t)vkh_image_get_sampler(surf->stencil), "SURF stencil SAMPLER");
+#endif
 }
 void _create_framebuffer (VkvgSurface surf) {
     VkImageView attachments[] = {
@@ -146,6 +161,9 @@ void _create_framebuffer (VkvgSurface surf) {
         frameBufferCreateInfo.attachmentCount = 2;
     }
     VK_CHECK_RESULT(vkCreateFramebuffer(surf->dev->vkDev, &frameBufferCreateInfo, NULL, &surf->fb));
+#ifdef DEBUG
+    vkh_device_set_object_name((VkhDevice)surf->dev, VK_OBJECT_TYPE_FRAMEBUFFER, (uint64_t)surf->fb, "SURF FB");
+#endif
 }
 void _init_surface (VkvgSurface surf) {
     surf->format = FB_COLOR_FORMAT;//force bgra internally
@@ -155,11 +173,6 @@ void _init_surface (VkvgSurface surf) {
     _create_framebuffer         (surf);
 
     _clear_surface              (surf, VK_IMAGE_ASPECT_STENCIL_BIT);
-#if defined(DEBUG) && defined(ENABLE_VALIDATION)
-    vkh_image_set_name(surf->img, "surfImg");
-    vkh_image_set_name(surf->imgMS, "surfImgMS");
-    vkh_image_set_name(surf->stencil, "surfStencil");
-#endif
 }
 void vkvg_surface_clear (VkvgSurface surf) {
     _clear_surface(surf, VK_IMAGE_ASPECT_STENCIL_BIT|VK_IMAGE_ASPECT_COLOR_BIT);
index 5f137afadb50acb001a939497776e6cc97c0451a..b8de624c0616cec21056baa31d7f7f8106179525 100644 (file)
@@ -11,7 +11,7 @@ VkvgDevice device = NULL;
 VkvgSurface surf = NULL;
 
 uint test_size = 100;  // items drawn in one run, or complexity
-int iterations = 500;   // repeat test n times
+int iterations = 40000;   // repeat test n times
 
 static bool paused = false;
 static VkSampleCountFlags samples = VK_SAMPLE_COUNT_4_BIT;
@@ -103,7 +103,7 @@ double median_run_time (double data[], int n)
 }
 double standard_deviation (const double data[], int n, double mean)
 {
-    double sum_deviation = 0.0;    
+    double sum_deviation = 0.0;
     for (int i = 0; i < n; ++i)
         sum_deviation += (data[i]-mean) * (data[i]-mean);
     return sqrt (sum_deviation / n);
@@ -137,7 +137,7 @@ void run_test_func (void(*testfunc)(void),uint width, uint height) {
 
     int i = 0;
 
-    while (!vkengine_should_close (e)){// && i < iterations) {
+    while (!vkengine_should_close (e) && i < iterations) {
         glfwPollEvents();
 
         start_time = get_tick();
@@ -162,16 +162,16 @@ void run_test_func (void(*testfunc)(void),uint width, uint height) {
             min_run_time = MIN(run_time, min_run_time);
         max_run_time = MAX(run_time, max_run_time);
         run_total += run_time;
-        //i++;
+        i++;
     }
 
-    double avg_run_time = run_total / (double)iterations;
-    double med_run_time = median_run_time (run_time_values, iterations);
-    double standard_dev = standard_deviation (run_time_values, iterations, avg_run_time);
+    double avg_run_time = run_total / (double)i;
+    double med_run_time = median_run_time (run_time_values, i);
+    double standard_dev = standard_deviation (run_time_values, i, avg_run_time);
     double avg_frames_per_second = (1.0 / avg_run_time);
     avg_frames_per_second = (avg_frames_per_second<9999) ? avg_frames_per_second:9999;
 
-    printf ("size:%d iter:%d  avgFps: %f avg: %4.2f%% med: %4.2f%% sd: %4.2f%% \n", test_size, iterations, avg_frames_per_second, avg_run_time, med_run_time, standard_dev);
+    printf ("size:%d iter:%d  avgFps: %f avg: %4.2f%% med: %4.2f%% sd: %4.2f%% \n", test_size, i, avg_frames_per_second, avg_run_time, med_run_time, standard_dev);
 
 }
 void clear_test () {
@@ -274,13 +274,13 @@ void perform_test (void(*testfunc)(void),uint width, uint height) {
         i++;
     }
 
-    double avg_run_time = run_total / (double)iterations;
-    double med_run_time = median_run_time (run_time_values, iterations);
-    double standard_dev = standard_deviation (run_time_values, iterations, avg_run_time);
+    double avg_run_time = run_total / (double)i;
+    double med_run_time = median_run_time (run_time_values, i);
+    double standard_dev = standard_deviation (run_time_values, i, avg_run_time);
     double avg_frames_per_second = (1.0 / avg_run_time);
     avg_frames_per_second = (avg_frames_per_second<9999) ? avg_frames_per_second:9999;
 
-    printf ("size:%d iter:%d  avgFps: %f avg: %4.2f%% med: %4.2f%% sd: %4.2f%% \n", test_size, iterations, avg_frames_per_second, avg_run_time, med_run_time, standard_dev);
+    printf ("size:%d iter:%d  avgFps: %f avg: %4.2f%% med: %4.2f%% sd: %4.2f%% \n", test_size, i, avg_frames_per_second, avg_run_time, med_run_time, standard_dev);
 
     vkDeviceWaitIdle(e->dev->dev);
 
index 4027a2d80fac46ed48901cae9c838de651cda3cd..6e8157ed60a658c598d3c3807be9c3dda14a6f8c 100644 (file)
@@ -93,8 +93,6 @@ void vkengine_dump_available_layers () {
     printf("-----------------\n\n");
 }
 
-//static VkDebugReportCallbackEXT dbgReport;
-
 vk_engine_t* vkengine_create (VkPhysicalDeviceType preferedGPU, VkPresentModeKHR presentMode, uint32_t width, uint32_t height) {
     vk_engine_t* e = (vk_engine_t*)calloc(1,sizeof(vk_engine_t));
 
@@ -104,7 +102,7 @@ vk_engine_t* vkengine_create (VkPhysicalDeviceType preferedGPU, VkPresentModeKHR
     uint32_t enabledExtsCount = 0, phyCount = 0;
     const char** gflwExts = glfwGetRequiredInstanceExtensions (&enabledExtsCount);
 
-    const char* enabledExts [enabledExtsCount+2];
+    const char* enabledExts [enabledExtsCount+1];
 
     for (uint i=0;i<enabledExtsCount;i++)
         enabledExts[i] = gflwExts[i];
@@ -119,14 +117,23 @@ vk_engine_t* vkengine_create (VkPhysicalDeviceType preferedGPU, VkPresentModeKHR
     const char* enabledLayers[] = {NULL};
 #endif
 #ifdef DEBUG
-    //enabledExts[enabledExtsCount] = "VK_EXT_debug_report";
-    //enabledExtsCount++;
-    //enabledExts[enabledExtsCount] = "VK_EXT_debug_utils";
-    //enabledExtsCount++;
+    enabledExts[enabledExtsCount] = "VK_EXT_debug_utils";
+    enabledExtsCount++;
 #endif
 
 
     e->app = vkh_app_create("vkvgTest", enabledLayersCount, enabledLayers, enabledExtsCount, enabledExts);
+#ifdef DEBUG
+    vkh_app_enable_debug_messenger(e->app
+                                   , VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT
+                                   | VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT
+                                   | VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT
+                                   , VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT
+                                   | VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT
+                                   //| VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT
+                                   //| VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT
+                                   , NULL);
+#endif
 
     glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
     glfwWindowHint(GLFW_RESIZABLE,  GLFW_TRUE);
@@ -189,15 +196,8 @@ vk_engine_t* vkengine_create (VkPhysicalDeviceType preferedGPU, VkPresentModeKHR
         }
     }
 
-#if defined(DEBUG) && defined(VKVG_USE_VALIDATION)
-    char const * dex [] = {"VK_KHR_swapchain", "VK_KHR_push_descriptor"};//, "VK_EXT_debug_marker"};
-    enabledExtsCount = 2;
-#else
     char const * dex [] = {"VK_KHR_swapchain", "VK_KHR_push_descriptor"};
     enabledExtsCount = 2;
-#endif
-
-
 
     VkPhysicalDeviceFeatures enabledFeatures = {
         .fillModeNonSolid = true,
@@ -214,16 +214,6 @@ vk_engine_t* vkengine_create (VkPhysicalDeviceType preferedGPU, VkPresentModeKHR
 
     e->dev = vkh_device_create(e->app, pi, &device_info);
 
-#if DEBUG
-    /*dbgReport = vkh_device_create_debug_report (e->dev,
-
-            VK_DEBUG_REPORT_INFORMATION_BIT_EXT|
-            VK_DEBUG_REPORT_ERROR_BIT_EXT|
-            VK_DEBUG_REPORT_WARNING_BIT_EXT|
-            VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT|
-            VK_DEBUG_REPORT_DEBUG_BIT_EXT);*/
-#endif
-
     e->renderer = vkh_presenter_create
             (e->dev, (uint32_t) pi->pQueue, surf, width, height, VK_FORMAT_B8G8R8A8_UNORM, presentMode);
 
@@ -242,10 +232,6 @@ void vkengine_destroy (VkEngine e) {
     vkh_presenter_destroy (e->renderer);
     vkDestroySurfaceKHR (e->app->inst, surf, NULL);
 
-#if DEBUG
-    //vkh_device_destroy_debug_report(e->dev, dbgReport);
-#endif
-
     vkh_device_destroy (e->dev);
 
     glfwDestroyWindow (e->window);
index 1a59e0f4170f751c42a3524d739014c161919a38..319acfbf43c559e826eb92bdf742192859fc712f 100644 (file)
@@ -5,8 +5,8 @@ void test(){
     vkvg_set_fill_rule(ctx,VKVG_FILL_RULE_NON_ZERO);
     VkvgSurface imgSurf = vkvg_surface_create_from_image(device, "data/miroir.jpg");
 
-    vkvg_translate(ctx,20,20);
-    vkvg_rotate(ctx,0.5);
+    //vkvg_translate(ctx,20,20);
+    //vkvg_rotate(ctx,0.5);
 
     vkvg_set_source_rgba(ctx,1,0,0,1);
     //vkvg_rectangle(ctx,100,100,200,200);
index 06f530a3d464af6e9379a2c37a4a9ea6dfb49b29..9a6e965461704197f567da6d84653d9a5b418680 100644 (file)
@@ -10,19 +10,25 @@ void test(){
     vkvg_surface_clear(surf);
 
     VkvgContext ctx = vkvg_create(surf);
-    vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_NON_ZERO);
-    vkvg_set_line_width(ctx,10);
+    vkvg_set_source_rgba(ctx,0,0,0,1);
+    vkvg_paint(ctx);
 
-    for (uint i=0; i<test_size; i++) {
-        randomize_color(ctx);
+    //vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_NON_ZERO);
+    //vkvg_set_line_width(ctx,10);
 
-        float x = truncf(0.5f*w*rand()/RAND_MAX);
-        float y = truncf(0.5f*w*rand()/RAND_MAX);
-        float z = truncf((0.5f*w*rand()/RAND_MAX)+1.f);
-        float v = truncf((0.5f*w*rand()/RAND_MAX)+1.f);
+    for (uint j=0;j<2;j++) {
+        for (uint i=0; i<test_size/2; i++) {
+            randomize_color(ctx);
 
-        vkvg_rectangle(ctx, x, y, z, v);
-        vkvg_fill(ctx);
+            float x = truncf(0.5f*w*rand()/RAND_MAX);
+            float y = truncf(0.5f*w*rand()/RAND_MAX);
+            float z = truncf((0.5f*w*rand()/RAND_MAX)+1.f);
+            float v = truncf((0.5f*w*rand()/RAND_MAX)+1.f);
+
+            vkvg_rectangle(ctx, x, y, z, v);
+            vkvg_fill(ctx);
+        }
+        vkvg_flush(ctx);
     }
     vkvg_destroy(ctx);
 }
index d01ae66863af00380d082c74de775cf7d6fa1931..3aae4c5545ca3149d28175cd9d08a86e32bb8998 100644 (file)
@@ -7,7 +7,7 @@ void test(){
 
     VkvgContext ctx = vkvg_create (surf2);
 
-    vkvg_set_source_rgba(ctx,1.0,0.,0.,0.5f);
+    vkvg_set_source_rgba(ctx,0.0,1.,0.,1.0f);
     vkvg_paint (ctx);
     vkvg_destroy(ctx);
 
@@ -20,7 +20,9 @@ void test(){
 
     */
 
-    vkvg_set_source_surface(ctx, surf2,0,0);
+    vkvg_translate(ctx, -150,-150);
+
+    vkvg_set_source_surface(ctx, surf2, 200,200);
     //vkvg_rectangle(ctx,10,10,300,300);
     //vkvg_fill(ctx);
     vkvg_paint(ctx);
index 6b6dd952f79c7eefb92f94702940d6112eb2b403..4f56a50bbf26aef211aac4f291beac996abfd7d6 100644 (file)
@@ -2,7 +2,7 @@
 
 void test(){
     VkvgContext ctx = vkvg_create(surf);
-    vkvg_set_source_rgba(ctx,0,1,0,1);
+    vkvg_set_source_rgba(ctx,1,0,0,1);
     vkvg_paint(ctx);
 
     /*vkvg_set_line_width(ctx, 5);
@@ -18,7 +18,7 @@ void test(){
     vkvg_destroy(ctx);
 }
 
-int main(int argc, char *argv[]) {    
+int main(int argc, char *argv[]) {
 
     perform_test (test, 1024, 768);
 
diff --git a/vkh b/vkh
index 446b183ec94d72f7d7fb8e82cf6ac1fce48c55b8..908a76fc07ff89457d38ccde1262f760b3f42fe5 160000 (submodule)
--- a/vkh
+++ b/vkh
@@ -1 +1 @@
-Subproject commit 446b183ec94d72f7d7fb8e82cf6ac1fce48c55b8
+Subproject commit 908a76fc07ff89457d38ccde1262f760b3f42fe5