]> O.S.I.I.S - jp/vkvg.git/commitdiff
clear new surface with first renderpass
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 1 May 2019 15:57:01 +0000 (17:57 +0200)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 1 May 2019 15:57:01 +0000 (17:57 +0200)
14 files changed:
include/vkvg.h
src/cross_os.c [new file with mode: 0644]
src/cross_os.h [new file with mode: 0644]
src/vkvg_context.c
src/vkvg_context_internal.c
src/vkvg_device.c
src/vkvg_device_internal.c
src/vkvg_device_internal.h
src/vkvg_surface.c
src/vkvg_surface_internal.h
template.c [new file with mode: 0644]
tests/common/test.c
tests/common/test.h
tests/painting.c

index 618fe7f8b1e057c522cbf8941f20922aa9c0402e..ec3050405cd8e00e51f64e1a29893ca233d42252 100644 (file)
@@ -43,7 +43,7 @@ extern "C" {
 #define LOG_FULL               0xff
 
 #ifdef DEBUG
-static uint8_t log_level       = LOG_ERR;// LOG_INFO | LOG_DEBUG;
+static uint8_t log_level       = LOG_ERR;// LOG_INFO | LOG_DEBUG;
 #define LOG(level,...) (log_level & level) ? fprintf (stdout, __VA_ARGS__):true;
 #else
 #define LOG
diff --git a/src/cross_os.c b/src/cross_os.c
new file mode 100644 (file)
index 0000000..ba53b6a
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2018 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
+ * Software, and to permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+#include "cross_os.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+
+int directoryExists (const char* path) {
+#ifdef _WIN32
+    return getenv("HOME");
+#elif __APPLE__
+#elif __unix__
+    struct stat st = {0};
+    return stat(path, &st)+1;
+#endif
+    return -1;
+}
+const char* getUserDir () {
+#ifdef _WIN32
+    return getenv("HOME");
+#elif __APPLE__
+#elif __unix__
+    struct passwd *pw = getpwuid(getuid());
+    return pw->pw_dir;
+#endif
+    return -1;
+}
diff --git a/src/cross_os.h b/src/cross_os.h
new file mode 100644 (file)
index 0000000..f9932b1
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2018 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
+ * Software, and to permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+#ifndef CROSS_OS_H
+#define CROSS_OS_H
+
+//cross platform os helpers
+#ifdef _WIN32
+#include "windows.h"
+#elif __APPLE__
+#elif __unix__
+#include <unistd.h>
+#include <sys/types.h>
+#include <pwd.h>
+#endif
+
+const char* getUserDir ();
+
+#endif // CROSS_OS_H
index 2a5db0cd3595056a3b28ff1fdd86a32d546f4090..894ea50b4097c171dc5d0298adc866daedfb0fd5 100644 (file)
@@ -32,9 +32,9 @@ static uint32_t dlpCount = 0;
 #endif
 
 static VkClearValue clearValues[3] = {
-    { {{0.0f, 0.0f, 0.0f, 1.0f}} },
-    { {{1.0f, 0}} },
-    { {{0.0f, 0.0f, 0.0f, 1.0f}} }
+    { 0.0f, 0.0f, 0.0f, 0.0f },
+    { 1.0f, 0 },
+    { 0.0f, 0.0f, 0.0f, 0.0f }
 };
 
 /**
@@ -44,11 +44,11 @@ static VkClearValue clearValues[3] = {
  */
 VkvgContext vkvg_create(VkvgSurface surf)
 {
-    LOG(LOG_INFO, "CREATE Context: surf = %lu\n", (ulong)surf);
-
     VkvgDevice dev = surf->dev;
     VkvgContext ctx = (vkvg_context*)calloc(1, sizeof(vkvg_context));
 
+    LOG(LOG_INFO, "CREATE Context: ctx = %lu; surf = %lu\n", (ulong)ctx, (ulong)surf);
+
     if (ctx==NULL) {
         dev->status = VKVG_STATUS_NO_MEMORY;
         return NULL;
@@ -80,7 +80,14 @@ VkvgContext vkvg_create(VkvgSurface surf)
     ctx->renderPassBeginInfo.renderArea.extent.width = ctx->pSurf->width;
     ctx->renderPassBeginInfo.renderArea.extent.height = ctx->pSurf->height;
     ctx->renderPassBeginInfo.pClearValues = clearValues;
-    ctx->renderPassBeginInfo.renderPass = ctx->pSurf->dev->renderPass_ClearStencil;
+
+    if (ctx->pSurf->new)
+        ctx->renderPassBeginInfo.renderPass = ctx->pSurf->dev->renderPass_ClearAll;
+    else
+        ctx->renderPassBeginInfo.renderPass = ctx->pSurf->dev->renderPass_ClearStencil;
+
+    ctx->pSurf->new = false;
+
     ctx->renderPassBeginInfo.clearValueCount = 3;
 
     ctx->pPrev          = surf->dev->lastCtx;
@@ -160,6 +167,8 @@ void vkvg_destroy (VkvgContext ctx)
 
     _flush_cmd_buff(ctx);
 
+    LOG(LOG_INFO, "DESTROY Context: ctx = %lu; surf = %lu\n", (ulong)ctx, (ulong)ctx->pSurf);
+
     if (ctx->pattern)
         vkvg_pattern_destroy (ctx->pattern);
 
@@ -456,6 +465,8 @@ void vkvg_clip_preserve (VkvgContext ctx){
         return;
     _finish_path(ctx);
 
+    LOG(LOG_INFO, "CLIP: ctx = %lu; path cpt = %d;\n", ctx, ctx->pathPtr / 2);
+
     if (ctx->pointCount * 4 > ctx->sizeIndices - ctx->indCount)//flush if vk buff is full
         vkvg_flush(ctx);
 
index 58eaac5274d41292b5cd6cbefec919c458d6f316..2a76b0e59564b649756e6b549c23a8a756a07ba0 100644 (file)
@@ -235,7 +235,7 @@ inline void _submit_wait_and_reset_cmd (VkvgContext ctx){
 }*/
 
 void _end_render_pass (VkvgContext ctx) {
-    LOG(LOG_INFO, "FLUSH Context: ctx = %lu; vert cpt = %d; ind cpt = %d\n", ctx, ctx->vertCount -4, ctx->indCount - 6);
+    LOG(LOG_INFO, "END RENDER PASS: ctx = %lu; vert cpt = %d; ind cpt = %d\n", ctx, ctx->vertCount -4, ctx->indCount - 6);
     _record_draw_cmd        (ctx);
     CmdEndRenderPass      (ctx->cmd);
     ctx->renderPassBeginInfo.renderPass = ctx->pSurf->dev->renderPass;
index e7e9f32de62778c9ed5197154451f58a1e064b97..53af110e18d7ea3c017585ddb4cdcd56efdfe753 100644 (file)
@@ -89,11 +89,13 @@ VkvgDevice vkvg_device_create_multisample(VkInstance inst, VkPhysicalDevice phy,
     _create_pipeline_cache      (dev);
     _init_fonts_cache           (dev);
     if (dev->deferredResolve || dev->samples == VK_SAMPLE_COUNT_1_BIT){
-        dev->renderPass = _setupRenderPassNoResolve (dev, VK_ATTACHMENT_LOAD_OP_LOAD, VK_ATTACHMENT_LOAD_OP_LOAD);
-        dev->renderPass_ClearStencil = _setupRenderPassNoResolve (dev, VK_ATTACHMENT_LOAD_OP_LOAD, VK_ATTACHMENT_LOAD_OP_CLEAR);
+        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);
@@ -135,6 +137,7 @@ void vkvg_device_destroy (VkvgDevice dev)
     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);
 
index d8ab85dba48e8c92bbc6d091ffed1978bd681cf2..9e92efba04e02ec58c4c2cf7a05565c3fd0fcf68 100644 (file)
@@ -47,7 +47,7 @@ void _create_pipeline_cache(VkvgDevice dev){
     VK_CHECK_RESULT(vkCreatePipelineCache(dev->vkDev, &pipelineCacheCreateInfo, NULL, &dev->pipelineCache));
 }
 
-VkRenderPass _setupRenderPassNoResolve(VkvgDevice dev, VkAttachmentLoadOp loadOp, VkAttachmentLoadOp stencilLoadOp)
+VkRenderPass _createRenderPassNoResolve(VkvgDevice dev, VkAttachmentLoadOp loadOp, VkAttachmentLoadOp stencilLoadOp)
 {
     VkAttachmentDescription attColor = {
                     .format = FB_COLOR_FORMAT,
@@ -115,8 +115,8 @@ VkRenderPass _createRenderPassMS(VkvgDevice dev, VkAttachmentLoadOp loadOp, VkAt
     VkAttachmentDescription attColorResolve = {
                     .format = FB_COLOR_FORMAT,
                     .samples = VK_SAMPLE_COUNT_1_BIT,
-                    .loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE,
-                    .storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE,
+                    .loadOp = loadOp,
+                    .storeOp = VK_ATTACHMENT_STORE_OP_STORE,
                     .stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE,
                     .stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE,
                     .initialLayout = VK_IMAGE_LAYOUT_UNDEFINED,
index 8bcca38821bd804e319a7ca9a081576e1afbd500..e26dcf59f33c4de47d239a40c788d14b472cacd0 100644 (file)
@@ -61,6 +61,7 @@ typedef struct _vkvg_device_t{
     MUTEX                   gQMutex;                /**< queue submission has to be externally syncronized */
     VkRenderPass                       renderPass;             /**< Vulkan render pass, common for all surfaces */
     VkRenderPass                       renderPass_ClearStencil;/**< Vulkan render pass for first draw with context, stencil has to be cleared */
+    VkRenderPass                       renderPass_ClearAll;    /**< Vulkan render pass for new surface, clear all attacments*/
 
     uint32_t                references;             /**< Reference count, prevent destroying device if still in use */
     VkCommandPool                      cmdPool;                /**< Global command pool for processing on surfaces without context */
@@ -102,7 +103,7 @@ void _create_empty_texture      (VkvgDevice dev);
 void _check_image_format_properties (VkvgDevice dev);
 void _create_pipeline_cache     (VkvgDevice dev);
 VkRenderPass _createRenderPassMS(VkvgDevice dev, VkAttachmentLoadOp loadOp, VkAttachmentLoadOp stencilLoadOp);
-VkRenderPass _setupRenderPassNoResolve(VkvgDevice dev, VkAttachmentLoadOp loadOp, VkAttachmentLoadOp stencilLoadOp);
+VkRenderPass _createRenderPassNoResolve(VkvgDevice dev, VkAttachmentLoadOp loadOp, VkAttachmentLoadOp stencilLoadOp);
 void _setupPipelines            (VkvgDevice dev);
 void _createDescriptorSetLayout (VkvgDevice dev);
 void _flush_all_contexes        (VkvgDevice dev);
index f3958e08a1bccb6ae3350f247221c9afcda30ee7..df9ac8dd4c2a5bc2b62c2e7c52afffc0d7c7d4bf 100644 (file)
@@ -170,6 +170,7 @@ VkvgSurface vkvg_surface_create(VkvgDevice dev, uint32_t width, uint32_t height)
     surf->dev = dev;
     surf->width = width;
     surf->height = height;
+    surf->new = true;//used to clear all attacments on first render pass
 
     _init_surface (surf);
 
index 11e4408f2098545ddc3bfc3ccf00d4d882dee44c..983b285ecc0893e83b874d48c6e1bd5baa62692f 100644 (file)
@@ -36,6 +36,7 @@ typedef struct _vkvg_surface_t {
     VkhImage   imgMS;
     VkhImage   stencil;
     uint32_t    references;
+    bool        new;
 }vkvg_surface;
 
 void _clear_surface (VkvgSurface surf, VkImageAspectFlags aspect);
diff --git a/template.c b/template.c
new file mode 100644 (file)
index 0000000..3cb99af
--- /dev/null
@@ -0,0 +1,14 @@
+#include "test.h"
+
+void test(){
+       VkvgContext ctx = vkvg_create(surf);
+
+       vkvg_destroy(ctx);
+}
+
+int main(int argc, char *argv[]) {
+
+       perform_test (test, 600, 800);
+
+       return 0;
+}
index 285b25374196686764a5d07ce255c9dff5c7f113..edd7ac9b9f2d93e7ca19218ca38b0101239712fe 100644 (file)
@@ -63,11 +63,70 @@ void randomize_color (VkvgContext ctx) {
         (float)rand()/RAND_MAX
     );
 }
+static vk_engine_t* e;
+
+void init_test (uint width, uint height){
+    e = vkengine_create (VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, VK_PRESENT_MODE_MAILBOX_KHR, width, height);
+    VkhPresenter r = e->renderer;
+    vkengine_set_key_callback (e, key_callback);
+    vkengine_set_mouse_but_callback(e, mouse_button_callback);
+    vkengine_set_cursor_pos_callback(e, mouse_move_callback);
+    vkengine_set_scroll_callback(e, scroll_callback);
+
+    bool deferredResolve = false;
+
+    device  = vkvg_device_create_multisample(vkh_app_get_inst(e->app), r->dev->phy, r->dev->dev, r->qFam, 0, VK_SAMPLE_COUNT_1_BIT, deferredResolve);
+
+    vkvg_device_set_dpy(device, 96, 96);
+
+    surf    = vkvg_surface_create(device, width, height);
+
+    vkh_presenter_build_blit_cmd (r, vkvg_surface_get_vk_image(surf), width, height);
+}
+void run_test_func (void(*testfunc)(void),uint width, uint height) {
+    bool deferredResolve = false;
+    VkhPresenter r = e->renderer;
+
+    struct timeval before , after;
+    double frameTime = 0, frameTimeAccum = 0, frameCount = 0;
+
+    while (!vkengine_should_close (e)) {
+        glfwPollEvents();
+
+        gettimeofday(&before , NULL);
+
+        testfunc();
+
+        if (deferredResolve)
+            vkvg_multisample_surface_resolve(surf);
+        if (!vkh_presenter_draw (r))
+            vkh_presenter_build_blit_cmd (r, vkvg_surface_get_vk_image(surf), width, height);
+
+        vkDeviceWaitIdle(e->dev->dev);
+
+        gettimeofday(&after , NULL);
+
+        frameTimeAccum += time_diff(before , after);
+        frameCount++;
+    }
+
+    frameTime = frameTimeAccum / frameCount;
+    printf ("frame (µs): %.0lf\nfps: %lf\n", frameTime, floor(1000000 / frameTime));
+
+}
+void clear_test () {
+    vkDeviceWaitIdle(e->dev->dev);
+
+    vkvg_surface_destroy    (surf);
+    vkvg_device_destroy     (device);
+
+    vkengine_destroy (e);
+}
 
 void perform_test (void(*testfunc)(void),uint width, uint height) {
     //dumpLayerExts();
 
-    vk_engine_t* e = vkengine_create (VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, VK_PRESENT_MODE_MAILBOX_KHR, width, height);
+    e = vkengine_create (VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, VK_PRESENT_MODE_MAILBOX_KHR, width, height);
     VkhPresenter r = e->renderer;
     vkengine_set_key_callback (e, key_callback);
     vkengine_set_mouse_but_callback(e, mouse_button_callback);
index dc83464b3bb079f139f60ec406a700f9e441d117..4841767bf115f088e79eb10e83801a6fc14ca511 100644 (file)
@@ -73,5 +73,11 @@ extern bool mouseDown;
 extern VkvgDevice device;
 extern VkvgSurface surf;
 
+//run test in one step
 void perform_test (void(*testfunc)(void),uint width, uint height);
 void randomize_color (VkvgContext ctx);
+
+//run test in 3 step: init, run, clear.
+void init_test (uint width, uint height);
+void run_test_func (void(*testfunc)(void),uint width, uint height);
+void clear_test ();
index 39eb09d675e54c0b3cd12d24afd40cea965f177e..f8ac37084b7cb179c19188698c37bd520b27776f 100644 (file)
@@ -1,38 +1,80 @@
 #include "test.h"
 
+static VkvgSurface surf2;
+
 void test(){
 
-    VkvgSurface surf2 = vkvg_surface_create (device,400,400);;
-    VkvgContext ctx = vkvg_create (surf2);
+    VkvgContext ctx  = vkvg_create (surf);
 
-    vkvg_set_source_rgba(ctx,1.0,0.,0.,1.0);
+    vkvg_set_source_surface(ctx,surf2,0,0);
     vkvg_paint (ctx);
-
     vkvg_destroy (ctx);
-    ctx = vkvg_create (surf);
 
-    vkvg_set_source_rgba(ctx,0.1,0.1,0.3,1.0);
-    vkvg_paint (ctx);
+    return;
+
+    //vkvg_set_source_rgba(ctx,0.1,0.1,0.3,1.0);
+    //vkvg_paint (ctx);
 
-    //vkvg_set_source_surface(ctx,surf2,0,0);
+    for (int i=0; i<10; i++) {
+        vkvg_translate(ctx,50,50);
+
+        /*vkvg_save(ctx);
+
+        vkvg_rectangle(ctx,0,0,200,200);
+        vkvg_clip_preserve(ctx);
+        vkvg_set_operator(ctx,VKVG_OPERATOR_CLEAR);
+        vkvg_fill(ctx);
+        vkvg_set_operator(ctx,VKVG_OPERATOR_OVER);*/
+
+        vkvg_set_source_rgba(ctx,0.0,0.0,0.0,0.3f);
+        vkvg_move_to(ctx,0,0);
+        vkvg_line_to(ctx,0,200);
+        vkvg_set_line_width(ctx,10);
+        vkvg_stroke(ctx);
+        vkvg_set_source_surface(ctx,surf2,0,0);
+        vkvg_paint (ctx);
+
+        //vkvg_restore(ctx);
+    }
 
     //VkvgPattern pat = vkvg_get_source (ctx);
-    VkvgPattern pat = vkvg_pattern_create_for_surface(surf2);
+    /*VkvgPattern pat = vkvg_pattern_create_for_surface(surf2);
     vkvg_pattern_set_extend (pat,VKVG_EXTEND_REFLECT);
-    vkvg_set_source(ctx,pat);
-    //vkvg_paint (ctx);
+    vkvg_set_source(ctx,pat);*/
     //vkvg_set_source_rgba(ctx,0,1,0,1.0);
-    vkvg_rectangle(ctx,100,100,200,200);
-    vkvg_fill(ctx);
+    //vkvg_rectangle(ctx,100,100,200,200);
+    //vkvg_fill(ctx);
 
     vkvg_destroy (ctx);
-    vkvg_surface_destroy (surf2);
-    vkvg_pattern_destroy (pat);
+
+    //vkvg_pattern_destroy (pat);
 }
 
 int main(int argc, char *argv[]) {
 
-    perform_test (test, 1024, 768);
+    init_test(1024, 768);
+
+    surf2 = vkvg_surface_create (device,400,400);
+
+    VkvgContext ctx = vkvg_create (surf2);
+
+    vkvg_set_source_rgba(ctx,1.0,0.,0.,0.2f);
+    vkvg_paint (ctx);
+    vkvg_set_source_rgba(ctx,1.0,1.0,0.,0.5f);
+    vkvg_move_to(ctx,10,10);
+    vkvg_line_to(ctx,200,200);
+    vkvg_set_line_width(ctx,10);
+    vkvg_stroke(ctx);
+    vkvg_set_source_rgba(ctx,1.0,1.0,1.0,0.6f);
+    vkvg_rectangle(ctx,0,0,400,400);
+    vkvg_stroke(ctx);
+
+    vkvg_destroy (ctx);
+
+    run_test_func(test, 1024, 768);
+
+    vkvg_surface_destroy (surf2);
 
+    clear_test();
     return 0;
 }