]> O.S.I.I.S - jp/vkvg.git/commitdiff
use VulkanMemoryAllocator for mem allocs
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Tue, 8 May 2018 08:26:39 +0000 (10:26 +0200)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Tue, 8 May 2018 08:26:39 +0000 (10:26 +0200)
13 files changed:
include/vkvg.h
src/vkvg_buff.c
src/vkvg_buff.h
src/vkvg_context.c
src/vkvg_context_internal.c
src/vkvg_context_internal.h
src/vkvg_device.c
src/vkvg_device_internal.h
src/vkvg_fonts.c
src/vkvg_surface.c
tests/test1.c
tests/vkengine.c
vkh

index 110077e0af6ceed650ab8025f0e8f0ea7b0df2fe..cef9ba4fbd003c606ff4a41863d9fa92b3b07d62 100644 (file)
@@ -129,6 +129,8 @@ uint32_t    vkvg_surface_get_reference_count(VkvgSurface surf);
 
 void           vkvg_surface_destroy            (VkvgSurface surf);
 VkImage                vkvg_surface_get_vk_image       (VkvgSurface surf);
+uint32_t       vkvg_surface_get_width      (VkvgSurface surf);
+uint32_t       vkvg_surface_get_height     (VkvgSurface surf);
 VkImage                vkvg_surface_get_vkh_image      (VkvgSurface surf);
 void        vkvg_surface_write_to_png   (VkvgSurface surf, const char* path);
 
index 25bcca3866b3f514a3380b440491c24c6ec90099..7e516965b1ecc77221bf36607cbae6363e579737 100644 (file)
 #include "vkvg_buff.h"
 #include "vkvg_device_internal.h"
 
-void _set_size_and_map(VkvgDevice pDev, VkBufferUsageFlags usage, VkMemoryPropertyFlags memoryPropertyFlags, VkDeviceSize size, vkvg_buff *buff){
-    VkMemoryRequirements memReq;
-    vkGetBufferMemoryRequirements(pDev->vkDev, buff->buffer, &memReq);
-    VkMemoryAllocateInfo memAllocInfo = { .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
-                                          .allocationSize = memReq.size };
-    assert(memory_type_from_properties(&pDev->phyMemProps, memReq.memoryTypeBits,memoryPropertyFlags, &memAllocInfo.memoryTypeIndex));
-    VK_CHECK_RESULT(vkAllocateMemory(pDev->vkDev, &memAllocInfo, NULL, &buff->memory));
-
-    buff->alignment = memReq.alignment;
-    buff->size = memAllocInfo.allocationSize;
-    buff->usageFlags = usage;
-    buff->memoryPropertyFlags = memoryPropertyFlags;
-
-    VK_CHECK_RESULT(vkBindBufferMemory(buff->pDev->vkDev, buff->buffer, buff->memory, 0));
-    VK_CHECK_RESULT(vkMapMemory(buff->pDev->vkDev, buff->memory, 0, VK_WHOLE_SIZE, 0, &buff->mapped));
-}
-
-void vkvg_buffer_create(VkvgDevice pDev, VkBufferUsageFlags usage, VkMemoryPropertyFlags memoryPropertyFlags, VkDeviceSize size, vkvg_buff *buff){
+void vkvg_buffer_create(VkvgDevice pDev, VkBufferUsageFlags usage, VmaMemoryUsage memoryPropertyFlags, VkDeviceSize size, vkvg_buff *buff){
     buff->pDev = pDev;
     VkBufferCreateInfo bufCreateInfo = {
         .sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
         .usage = usage, .size = size, .sharingMode = VK_SHARING_MODE_EXCLUSIVE};
-    VK_CHECK_RESULT(vkCreateBuffer(pDev->vkDev, &bufCreateInfo, NULL, &buff->buffer));
+    VmaAllocationCreateInfo allocInfo = { .usage = memoryPropertyFlags, .flags = VMA_ALLOCATION_CREATE_MAPPED_BIT };
 
-    _set_size_and_map(pDev,usage,memoryPropertyFlags,size,buff);
+    VK_CHECK_RESULT(vmaCreateBuffer (pDev->allocator, &bufCreateInfo, &allocInfo, &buff->buffer, &buff->alloc, &buff->allocInfo));
 }
 
 void vkvg_buffer_destroy(vkvg_buff *buff){
-    vkUnmapMemory   (buff->pDev->vkDev, buff->memory);
-    vkDestroyBuffer (buff->pDev->vkDev, buff->buffer, NULL);
-    vkFreeMemory    (buff->pDev->vkDev, buff->memory, NULL);
+    vmaDestroyBuffer (buff->pDev->allocator, buff->buffer, buff->alloc);
 }
 
-
-void vkvg_buffer_increase_size(vkvg_buff *buff, uint32_t sizeAdded){
-    size_t oldBSize = buff->size;
-    void* pSave = (void*)malloc (oldBSize);
-    memcpy (pSave, buff->mapped, oldBSize);
-
-    vkvg_buffer_destroy(buff);
-    vkvg_buffer_create(buff->pDev, buff->usageFlags, buff->memoryPropertyFlags, oldBSize + sizeAdded, buff);
-    memcpy (buff->mapped, pSave, oldBSize);
-    free(pSave);
-}
index 40dd6ad2d7c0d66c7b4fa58e839d4e4875042baf..eaba746ad0d7b3aa29ed5f6d3ded7f13e835953a 100644 (file)
 
 #include <vulkan/vulkan.h>
 #include "vkvg.h"
+#include "vk_mem_alloc.h"
 
 typedef struct vkvg_buff_t {
-    VkvgDevice      pDev;
-    VkBuffer        buffer;
-    VkDeviceMemory  memory;
+    VkvgDevice          pDev;
+    VkBuffer            buffer;
+    VmaAllocation       alloc;
+    VmaAllocationInfo   allocInfo;
     VkDescriptorBufferInfo descriptor;
-    VkDeviceSize    size;
-    VkDeviceSize    alignment;
-
-    VkBufferUsageFlags usageFlags;
-    VkMemoryPropertyFlags memoryPropertyFlags;
-
-    void* mapped;
 }vkvg_buff;
 
 void vkvg_buffer_create         (VkvgDevice pDev, VkBufferUsageFlags usage,
-                                    VkMemoryPropertyFlags memoryPropertyFlags, VkDeviceSize size, vkvg_buff* buff);
+                                    VmaMemoryUsage memoryPropertyFlags, VkDeviceSize size, vkvg_buff *buff);
 void vkvg_buffer_destroy        (vkvg_buff* buff);
-void vkvg_buffer_increase_size  (vkvg_buff *buff, uint32_t sizeAdded);
 #endif
index 03b0aeebe591637db95c4680dc160419f7adefd5..d5c3eb5347c0ad551ea3b3b93a914b913b659d60 100644 (file)
@@ -89,7 +89,7 @@ VkvgContext vkvg_create(VkvgSurface surf)
 void vkvg_flush (VkvgContext ctx){
     _flush_cmd_buff(ctx);
     _init_cmd_buff(ctx);
-
+/*
 #ifdef DEBUG
 
     vec4 red = {0,0,1,1};
@@ -110,7 +110,7 @@ void vkvg_flush (VkvgContext ctx){
     vkCmdDrawIndexed(ctx->cmd, ctx->indCount-ctx->curIndStart, 1, ctx->curIndStart, 0, 1);
     _flush_cmd_buff(ctx);
 #endif
-
+*/
 }
 
 void vkvg_destroy (VkvgContext ctx)
@@ -510,7 +510,7 @@ void vkvg_stroke_preserve (VkvgContext ctx)
             iR = ctx->pathes[ptrPath];
             _build_vb_step(ctx,v,hw,iL,i,iR);
 
-            uint32_t* inds = (uint32_t*)(ctx->indices.mapped + ((ctx->indCount-6) * sizeof(uint32_t)));
+            uint32_t* inds = (uint32_t*)(ctx->indices.allocInfo.pMappedData + ((ctx->indCount-6) * sizeof(uint32_t)));
             uint32_t ii = firstIdx;
             inds[1] = ii;
             inds[4] = ii;
@@ -534,6 +534,9 @@ void vkvg_set_source_rgba (VkvgContext ctx, float r, float g, float b, float a)
 }
 void vkvg_set_source_surface(VkvgContext ctx, VkvgSurface surf, float x, float y){
     _update_cur_pattern (ctx, vkvg_pattern_create_for_surface(surf));
+    ctx->pushConsts.source.x = x;
+    ctx->pushConsts.source.y = y;
+    _update_push_constants (ctx);
 }
 void vkvg_set_source (VkvgContext ctx, VkvgPattern pat){
     _update_cur_pattern (ctx, pat);
index 5b6e5e7bab8e3c55802b38b16c1d9c93a26ded12..7d0446567cd969e58fcb073f8de02681b90edf16 100644 (file)
@@ -104,38 +104,38 @@ float _normalizeAngle(float a)
 void _create_gradient_buff (VkvgContext ctx){
     vkvg_buffer_create (ctx->pSurf->dev,
         VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
-        VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_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,
-        VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
+        VMA_MEMORY_USAGE_CPU_TO_GPU,
         ctx->sizeVertices * sizeof(Vertex), &ctx->vertices);
     vkvg_buffer_create (ctx->pSurf->dev,
         VK_BUFFER_USAGE_INDEX_BUFFER_BIT,
-        VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
+        VMA_MEMORY_USAGE_CPU_TO_GPU,
         ctx->sizeIndices * sizeof(uint32_t), &ctx->indices);
 }
 const vec3 blankuv = {};
 void _add_vertexf (VkvgContext ctx, float x, float y){
-    Vertex* pVert = (Vertex*)(ctx->vertices.mapped + ctx->vertCount * sizeof(Vertex));
+    Vertex* pVert = (Vertex*)(ctx->vertices.allocInfo.pMappedData + ctx->vertCount * sizeof(Vertex));
     pVert->pos.x = x;
     pVert->pos.y = y;
     pVert->uv = blankuv;
     ctx->vertCount++;
 }
 void _add_vertex(VkvgContext ctx, Vertex v){
-    Vertex* pVert = (Vertex*)(ctx->vertices.mapped + ctx->vertCount * sizeof(Vertex));
+    Vertex* pVert = (Vertex*)(ctx->vertices.allocInfo.pMappedData + ctx->vertCount * sizeof(Vertex));
     *pVert = v;
     ctx->vertCount++;
 }
 void _set_vertex(VkvgContext ctx, uint32_t idx, Vertex v){
-    Vertex* pVert = (Vertex*)(ctx->vertices.mapped + idx * sizeof(Vertex));
+    Vertex* pVert = (Vertex*)(ctx->vertices.allocInfo.pMappedData + idx * sizeof(Vertex));
     *pVert = v;
 }
 void _add_tri_indices_for_rect (VkvgContext ctx, uint32_t i){
-    uint32_t* inds = (uint32_t*)(ctx->indices.mapped + (ctx->indCount * sizeof(uint32_t)));
+    uint32_t* inds = (uint32_t*)(ctx->indices.allocInfo.pMappedData + (ctx->indCount * sizeof(uint32_t)));
     inds[0] = i;
     inds[1] = i+2;
     inds[2] = i+1;
@@ -145,7 +145,7 @@ void _add_tri_indices_for_rect (VkvgContext ctx, uint32_t i){
     ctx->indCount+=6;
 }
 void _add_triangle_indices(VkvgContext ctx, uint32_t i0, uint32_t i1, uint32_t i2){
-    uint32_t* inds = (uint32_t*)(ctx->indices.mapped + (ctx->indCount * sizeof(uint32_t)));
+    uint32_t* inds = (uint32_t*)(ctx->indices.allocInfo.pMappedData + (ctx->indCount * sizeof(uint32_t)));
     inds[0] = i0;
     inds[1] = i1;
     inds[2] = i2;
@@ -160,7 +160,7 @@ void _vao_add_rectangle (VkvgContext ctx, float x, float y, float width, float h
         {{x+width,y+height},{0,0,-1}}
     };
     uint32_t firstIdx = ctx->vertCount;
-    Vertex* pVert = (Vertex*)(ctx->vertices.mapped + ctx->vertCount * sizeof(Vertex));
+    Vertex* pVert = (Vertex*)(ctx->vertices.allocInfo.pMappedData + ctx->vertCount * sizeof(Vertex));
     memcpy (pVert,v,4*sizeof(Vertex));
     ctx->vertCount+=4;
     _add_tri_indices_for_rect(ctx, firstIdx);
@@ -373,7 +373,7 @@ void _update_cur_pattern (VkvgContext ctx, VkvgPattern pat) {
         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.mapped, &grad, sizeof(vkvg_gradient_t));
+        memcpy(ctx->uboGrad.allocInfo.pMappedData , &grad, sizeof(vkvg_gradient_t));
 
         _init_cmd_buff (ctx);
         break;
@@ -451,7 +451,7 @@ void add_line(vkvg_context* ctx, vec2 p1, vec2 p2, vec4 col){
     _add_vertex(ctx, v);
     v.pos = p2;
     _add_vertex(ctx, v);
-    uint32_t* inds = (uint32_t*)(ctx->indices.mapped + (ctx->indCount * sizeof(uint32_t)));
+    uint32_t* inds = (uint32_t*)(ctx->indices.allocInfo.pMappedData  + (ctx->indCount * sizeof(uint32_t)));
     inds[0] = ctx->vertCount - 2;
     inds[1] = ctx->vertCount - 1;
     ctx->indCount+=2;
index 84c7afe339a6b4dedb72c742af9c7493d4e93c34..00d512e61aa19b0ad23be9d7eefec85ed67b237d 100644 (file)
@@ -42,12 +42,12 @@ typedef struct{
 }Vertex;
 
 typedef struct {
-    vec4     source;
-    vec2     size;
-    uint32_t patternType;
-    uint32_t pad;
-    vkvg_matrix_t mat;
-    vkvg_matrix_t matInv;
+    vec4            source;
+    vec2            size;
+    uint32_t        patternType;
+    uint32_t        pad;
+    vkvg_matrix_t   mat;
+    vkvg_matrix_t   matInv;
 }push_constants;
 
 typedef struct _vkvg_context_save_t{
index 1edb6e474d8034d0ed98102ffe80efa41e8b0f3b..a494aa7f7b1367e9089cd64986b9187daf0c843a 100644 (file)
 #include "vkvg_device_internal.h"
 #include "vkh_queue.h"
 #include "vkh_phyinfo.h"
+#include "vk_mem_alloc.h"
 
 VkvgDevice vkvg_device_create(VkPhysicalDevice phy, VkDevice vkdev, uint32_t qFamIdx, uint32_t qIndex)
 {
     VkvgDevice dev = (vkvg_device*)malloc(sizeof(vkvg_device));
 
-    dev->hdpi   = 96;
-    dev->vdpi   = 96;
+    dev->hdpi   = 72;
+    dev->vdpi   = 72;
     dev->vkDev  = vkdev;
     dev->phy    = phy;
 
@@ -40,6 +41,12 @@ VkvgDevice vkvg_device_create(VkPhysicalDevice phy, VkDevice vkdev, uint32_t qFa
 
     vkh_phyinfo_destroy (phyInfos);
 
+    VmaAllocatorCreateInfo allocatorInfo = {
+        .physicalDevice = phy,
+        .device = vkdev
+    };
+    vmaCreateAllocator(&allocatorInfo, &dev->allocator);
+
     dev->lastCtx= NULL;
 
     dev->cmdPool= vkh_cmd_pool_create       (dev, dev->gQueue->familyIndex, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT);
@@ -88,6 +95,9 @@ void vkvg_device_destroy (VkvgDevice dev)
     vkDestroyCommandPool            (dev->vkDev, dev->cmdPool, NULL);
 
     _destroy_font_cache(dev);
+
+    vmaDestroyAllocator (dev->allocator);
+
     free(dev);
 }
 
index 9d19c3c87725b78b5d90329947d01a3ab064dc58..85131063569b2a5e5a4b149c917c63534a79fd4e 100644 (file)
@@ -34,6 +34,7 @@ typedef struct _vkvg_device_t{
     VkDevice                           vkDev;
     VkPhysicalDeviceMemoryProperties phyMemProps;
     VkPhysicalDevice        phy;
+    VmaAllocator            allocator;
 
     VkhQueue                gQueue;
     VkRenderPass                       renderPass;
index 0aced480bd226c1a67b43b929a758360090734b3..0b5802f856c3323e6d1d82ebcba4ce4c0812db1b 100644 (file)
@@ -354,7 +354,7 @@ void _font_extents (VkvgContext ctx, vkvg_font_extents_t *extents) {
     FT_BBox* bbox = &ctx->currentFont->face->bbox;
     FT_Size_Metrics* metrics = &ctx->currentFont->face->size->metrics;
     extents->ascent = metrics->ascender >> 6;
-    extents->descent= metrics->descender >> 6;
+    extents->descent= -(metrics->descender >> 6);
     extents->height = metrics->height >> 6;
     extents->max_x_advance = bbox->xMax >> 6;
     extents->max_y_advance = bbox->yMax >> 6;
index 3bb202044f4af6651f1636a387dede23f39a7a0f..9e01e485e797a6e9dcafde7e96c8409d78b93adf 100644 (file)
@@ -55,11 +55,11 @@ void _clear_stencil (VkvgSurface surf)
 
 void _init_surface (VkvgSurface surf) {
     surf->format = FB_COLOR_FORMAT;//force bgra internally
-    surf->img = vkh_image_create(surf->dev,surf->format,surf->width,surf->height,VK_IMAGE_TILING_LINEAR,VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
+    surf->img = vkh_image_create(surf->dev,surf->format,surf->width,surf->height,VK_IMAGE_TILING_LINEAR,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);
-    surf->imgMS = vkh_image_ms_create(surf->dev,surf->format,VKVG_SAMPLES,surf->width,surf->height,VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
+    surf->imgMS = vkh_image_ms_create(surf->dev,surf->format,VKVG_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);
-    surf->stencilMS = vkh_image_ms_create(surf->dev,VK_FORMAT_S8_UINT,VKVG_SAMPLES,surf->width,surf->height,VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
+    surf->stencilMS = vkh_image_ms_create(surf->dev,VK_FORMAT_S8_UINT,VKVG_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_descriptor(surf->img, 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);
@@ -113,11 +113,11 @@ VkvgSurface vkvg_surface_create_from_bitmap (VkvgDevice dev, unsigned char* img,
     VkImageSubresourceLayers imgSubResLayers = {VK_IMAGE_ASPECT_COLOR_BIT,0,0,1};
     //original format image
     VkhImage stagImg= vkh_image_create (surf->dev,VK_FORMAT_R8G8B8A8_UNORM,surf->width,surf->height,VK_IMAGE_TILING_LINEAR,
-                                         VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
+                                         VMA_MEMORY_USAGE_GPU_ONLY,
                                          VK_IMAGE_USAGE_TRANSFER_SRC_BIT|VK_IMAGE_USAGE_TRANSFER_DST_BIT);
     //bgra bliting target
     VkhImage tmpImg = vkh_image_create (surf->dev,surf->format,surf->width,surf->height,VK_IMAGE_TILING_LINEAR,
-                                         VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
+                                         VMA_MEMORY_USAGE_GPU_ONLY,
                                          VK_IMAGE_USAGE_SAMPLED_BIT|VK_IMAGE_USAGE_TRANSFER_DST_BIT);
     vkh_image_create_descriptor (tmpImg, 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_BORDER);
@@ -239,6 +239,12 @@ VkImage vkvg_surface_get_vk_image(VkvgSurface surf)
 {
     return vkh_image_get_vkimage (surf->img);
 }
+uint32_t vkvg_surface_get_width (VkvgSurface surf) {
+    return surf->width;
+}
+uint32_t vkvg_surface_get_height (VkvgSurface surf) {
+    return surf->height;
+}
 
 void vkvg_surface_write_to_png (VkvgSurface surf, const char* path){
     uint32_t stride = surf->width * 4;
@@ -247,7 +253,7 @@ void vkvg_surface_write_to_png (VkvgSurface surf, const char* path){
 
     //RGBA to blit to, surf img is bgra
     VkhImage stagImg= vkh_image_create (surf->dev,VK_FORMAT_R8G8B8A8_UNORM,surf->width,surf->height,VK_IMAGE_TILING_LINEAR,
-                                         VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
+                                         VMA_MEMORY_USAGE_GPU_TO_CPU,
                                          VK_IMAGE_USAGE_TRANSFER_SRC_BIT|VK_IMAGE_USAGE_TRANSFER_DST_BIT);
 
     VkCommandBuffer cmd = dev->cmd;
index 0b837d36af296edf7d601fa8a05bdf06bc8b5a22..deec038f3c95838f846d556e9e1bf3b983623fef 100644 (file)
@@ -523,7 +523,7 @@ void multi_test1 () {
 //    vkvg_fill(ctx);
 
     VkvgPattern pat = vkvg_pattern_create_for_surface(surf2);
-    vkvg_pattern_set_extend(pat, VKVG_EXTEND_NONE);
+    vkvg_pattern_set_extend(pat, VKVG_EXTEND_REFLECT);
     vkvg_pattern_set_filter(pat, VKVG_FILTER_BILINEAR);
     vkvg_set_source (ctx, pat);
     //vkvg_rectangle(ctx,100,100,400,400);
@@ -989,7 +989,38 @@ void test_svg () {
 
     vkvg_destroy(ctx);
 }
+void test_1 () {
+    const char* text = "This is a petit test {}";
 
+    VkvgContext ctx = vkvg_create (surf);
+
+    vkvg_set_source_rgba(ctx,0,0,0,1.0);
+    vkvg_paint (ctx);
+    vkvg_set_source_rgba(ctx,1,1,1,1.0);
+
+    vkvg_select_font_face(ctx, "mono");
+    vkvg_set_font_size(ctx, 12);
+
+    vkvg_font_extents_t f = {};
+    vkvg_font_extents(ctx, &f);
+
+    vkvg_text_extents_t t = {};
+    vkvg_text_extents(ctx, text, &t);
+
+    vkvg_move_to(ctx,100,100);
+    vkvg_show_text(ctx, text);
+
+    vkvg_move_to(ctx,100,100.5 - f.ascent);
+    vkvg_line_to(ctx,100+t.width,100.5 - f.ascent);
+
+    vkvg_move_to(ctx,100,100.5 - f.descent);
+    vkvg_line_to(ctx,100+t.width,100.5 - f.descent);
+
+    vkvg_stroke(ctx);
+
+    vkvg_flush(ctx);
+    vkvg_destroy (ctx);
+}
 void test_painting () {
     VkvgSurface surf2 = vkvg_surface_create (device,400,400);;
     VkvgContext ctx = vkvg_create (surf2);
@@ -1031,7 +1062,7 @@ int main(int argc, char *argv[]) {
     surf    = vkvg_surface_create(device, 1024, 800);
 
     //test_svg();
-
+    //test_img_surface();
     //
 
     //test_grad_transforms();
@@ -1042,6 +1073,7 @@ int main(int argc, char *argv[]) {
 
     while (!vkengine_should_close (e)) {
         glfwPollEvents();
+        //test_1();
         cairo_tests();
         //multi_test1();
         //test_painting();
index f115b3e6bee3f590bd88868c22e6db73f944c565..4a9daf6c1d0574c6636ae9e066a72e62f00b9003 100644 (file)
@@ -20,8 +20,8 @@
  * THE SOFTWARE.
  */
 
-#include "vkengine.h"
 #include "vkh.h"
+#include "vkengine.h"
 #include "vkh_app.h"
 #include "vkh_phyinfo.h"
 #include "vkh_presenter.h"
diff --git a/vkh b/vkh
index 3c56e7f095f2eb60e5f3ada2e6805383ec430508..6362a530a88166df5b52376bd2107e7a531b2411 160000 (submodule)
--- a/vkh
+++ b/vkh
@@ -1 +1 @@
-Subproject commit 3c56e7f095f2eb60e5f3ada2e6805383ec430508
+Subproject commit 6362a530a88166df5b52376bd2107e7a531b2411