]> O.S.I.I.S - jp/vkvg.git/commitdiff
wip, reame path bits, typo
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Fri, 11 Sep 2020 12:54:37 +0000 (14:54 +0200)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Fri, 11 Sep 2020 12:54:37 +0000 (14:54 +0200)
include/vkvg.h
src/vkvg_context.c
src/vkvg_context_internal.c
src/vkvg_context_internal.h
src/vkvg_internal.h
tests/common/test.c

index 8f921c31e1087ce35b0e8dd0a74a5c0f981d4e60..903e59ee6182d29ad32be494f333d0312ed06010 100644 (file)
@@ -968,8 +968,9 @@ void vkvg_clear (VkvgContext ctx);//use vkClearAttachment to speed up clearing s
 vkvg_public
 void vkvg_reset_clip (VkvgContext ctx);
 /**
- * @brief
+ * @brief reset clip
  *
+ * Reset current context clip regions.
  * @param ctx a valid vkvg #context
  */
 vkvg_public
index f2f0988556bb4f7818aad0910eb0622cd66ac0bd..f0ae09e51628f26c5ec1f2e8499b842199a0893d 100644 (file)
@@ -442,7 +442,7 @@ void vkvg_rectangle (VkvgContext ctx, float x, float y, float w, float h){
        _add_point (ctx, x, y);
        _add_point (ctx, x + w, y);
        _add_point (ctx, x + w, y + h);
-       _add_point (ctx, x, y + h);
+       _add_point (ctx, x, y + h);     
 
        vkvg_close_path (ctx);
 }
@@ -539,7 +539,7 @@ void vkvg_fill_preserve (VkvgContext ctx){
        if (ctx->vertCount - ctx->curVertOffset + ctx->pointCount > VKVG_IBO_MAX)
                _emit_draw_cmd_undrawn_vertices(ctx);//limit draw call to addressable vx with choosen index type
 
-       if (ctx->pattern)//if not solid color, source img of gradient has to be bound
+       if (ctx->pattern)//if not solid color, source img or gradient has to be bound
                _ensure_renderpass_is_started(ctx);
        _fill_ec(ctx);
 }
@@ -707,7 +707,7 @@ void vkvg_stroke_preserve (VkvgContext ctx)
                if (_path_has_curves (ctx,ptrPath)) {
                        while (curPathPointIdx < lastPathPointIdx){
 
-                               bool curved = ctx->pathes [ptrPath + ptrSegment] & PATH_IS_CURVE_BIT;
+                               bool curved = ctx->pathes [ptrPath + ptrSegment] & PATH_HAS_CURVES_BIT;
                                if (lastSegmentPointIdx == lastPathPointIdx)//last segment of path, dont draw end point here
                                        lastSegmentPointIdx--;
                                while (curPathPointIdx <= lastSegmentPointIdx)
index d0a53e337af48fd06d37a830a8c35040e38bce09..cfe944c014c1cd88060bc722a56f7462196e1118 100644 (file)
 
 void _resize_vertex_cache (VkvgContext ctx, uint32_t newSize) {
        Vertex* tmp = (Vertex*) realloc (ctx->vertexCache, (size_t)newSize * sizeof(Vertex));
-       LOG(VKVG_LOG_DBG_ARRAYS, "resize VBO: new size: %u size(byte): %zu Ptr: %p -> %p\n", newSize, (size_t)newSize * sizeof(Vertex), ctx->vertexCache, tmp);
+       LOG(VKVG_LOG_DBG_ARRAYS, "resize vertex cache (vx count=%u): old size: %u -> new size: %u size(byte): %zu Ptr: %p -> %p\n",
+               ctx->vertCount, ctx->sizeVertices, newSize, (size_t)newSize * sizeof(Vertex), ctx->vertexCache, tmp);
        if (tmp == NULL){
                ctx->status = VKVG_STATUS_NO_MEMORY;
-               LOG(VKVG_LOG_ERR, "resize VBO failed: vert count: %u byte size: %zu\n", ctx->sizeVertices, ctx->sizeVertices * sizeof(Vertex));
+               LOG(VKVG_LOG_ERR, "resize vertex cache failed: vert count: %u byte size: %zu\n", ctx->sizeVertices, ctx->sizeVertices * sizeof(Vertex));
                return;
        }
        ctx->vertexCache = tmp;
@@ -124,7 +125,7 @@ void _set_curve_start (VkvgContext ctx) {
 //compute segment length and set is curved bit
 void _set_curve_end (VkvgContext ctx) {
        //ctx->pathes [ctx->pathPtr + ctx->segmentPtr] = ctx->pathes [ctx->pathPtr] - ctx->pathes [ctx->pathPtr + ctx->segmentPtr];
-       ctx->pathes [ctx->pathPtr + ctx->segmentPtr] |= PATH_IS_CURVE_BIT;
+       ctx->pathes [ctx->pathPtr + ctx->segmentPtr] |= PATH_HAS_CURVES_BIT;
        ctx->segmentPtr++;
        _check_pathes_array(ctx);
        ctx->pathes [ctx->pathPtr + ctx->segmentPtr] = 0;
@@ -147,7 +148,7 @@ void _finish_path (VkvgContext ctx){
        if (ctx->segmentPtr > 0) {
                ctx->pathes[ctx->pathPtr] |= PATH_HAS_CURVES_BIT;
                //if last segment is not a curve and point count > 0
-               if ((ctx->pathes[ctx->pathPtr+ctx->segmentPtr]&PATH_IS_CURVE_BIT)==0 &&
+               if ((ctx->pathes[ctx->pathPtr+ctx->segmentPtr]&PATH_HAS_CURVES_BIT)==0 &&
                                (ctx->pathes[ctx->pathPtr+ctx->segmentPtr]&PATH_ELT_MASK) > 0)
                        ctx->segmentPtr++;//current segment has to be included
                ctx->pathPtr += ctx->segmentPtr;
@@ -177,7 +178,7 @@ void _remove_last_point (VkvgContext ctx){
                ctx->pathes [ctx->pathPtr + ctx->segmentPtr]--;//decrement last segment point count
                if ((ctx->pathes [ctx->pathPtr + ctx->segmentPtr]&PATH_ELT_MASK) == 0)//if no point left (was only one)
                        ctx->pathes [ctx->pathPtr + ctx->segmentPtr] = 0;//reset current segment
-               else if (ctx->pathes [ctx->pathPtr + ctx->segmentPtr]&PATH_IS_CURVE_BIT)//if segment is a curve
+               else if (ctx->pathes [ctx->pathPtr + ctx->segmentPtr]&PATH_HAS_CURVES_BIT)//if segment is a curve
                        ctx->segmentPtr++;//then segPtr has to be forwarded to new segment
        }
 }
@@ -432,9 +433,10 @@ void _check_vao_size (VkvgContext ctx) {
                        //if cmd is started buffers, are already bound, so no resize is possible
                        //instead we flush, and clear vbo and ibo caches
                        _flush_cmd_until_vx_base (ctx);
-
-               _resize_vbo(ctx, ctx->sizeVertices);
-               _resize_ibo(ctx, ctx->sizeIndices);
+               if (ctx->vertCount > ctx->sizeVBO)              
+                       _resize_vbo(ctx, ctx->sizeVertices);
+               if (ctx->indCount > ctx->sizeIBO)
+                       _resize_ibo(ctx, ctx->sizeIndices);
        }
 }
 
@@ -542,7 +544,6 @@ void _start_cmd_for_render_pass (VkvgContext 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
@@ -1051,8 +1052,9 @@ void _recursive_bezier (VkvgContext ctx,
 }
 #pragma warning(default:4127)
 
+//Even-Odd inside test with stencil buffer implementation.
 void _poly_fill (VkvgContext ctx){
-       //we anticipate the check for vbo buffer size
+       //we anticipate the check for vbo buffer size, ibo is not used in poly_fill
        if (ctx->vertCount + ctx->pointCount > ctx->sizeVBO) {
                if (ctx->cmdStarted) {
                        _end_render_pass(ctx);
@@ -1118,10 +1120,9 @@ void _fill_ec (VkvgContext ctx){
        while (ptrPath < ctx->pathPtr){
                ctx->pathes[ptrPath] |= PATH_CLOSED_BIT;//close path
 
-               uint32_t pathPointCount = ctx->pathes[ptrPath] & PATH_ELT_MASK;
+               uint32_t pathPointCount = ctx->pathes[ptrPath] & PATH_ELT_MASK;         
 
                VKVG_IBO_INDEX_TYPE firstVertIdx = (VKVG_IBO_INDEX_TYPE)(ctx->vertCount - ctx->curVertOffset);
-
                ear_clip_point* ecps = (ear_clip_point*)malloc(pathPointCount*sizeof(ear_clip_point));
                uint32_t ecps_count = pathPointCount;
                VKVG_IBO_INDEX_TYPE i = 0;
@@ -1175,6 +1176,7 @@ void _fill_ec (VkvgContext ctx){
                }
                if (ecps_count == 3)
                        _add_triangle_indices(ctx, ecp_current->next->idx, ecp_current->idx, ecp_current->next->next->idx);
+               free (ecps);
 
                firstPtIdx += pathPointCount;
                if (_path_has_curves (ctx, ptrPath)) {
@@ -1185,7 +1187,6 @@ void _fill_ec (VkvgContext ctx){
                                totPts += (ctx->pathes[ptrPath++] & PATH_ELT_MASK);
                }else
                        ptrPath++;
-               free (ecps);
        }
 }
 
index 95a52ab0f2c8dd0ab5fa0bbb5dc8ced1d0adc77b..e9b45c96b5379dfd9c740d166cff35bfb5dd62bd 100644 (file)
@@ -29,8 +29,8 @@
 #include "vkvg_fonts.h"
 
 #define VKVG_PTS_SIZE                          256
-#define VKVG_VBO_SIZE                          VKVG_PTS_SIZE * 4
-#define VKVG_IBO_SIZE                          VKVG_VBO_SIZE * 6
+#define VKVG_VBO_SIZE                          (VKVG_PTS_SIZE * 4)
+#define VKVG_IBO_SIZE                          (VKVG_VBO_SIZE * 6)
 #define VKVG_PATHES_SIZE                       16
 #define VKVG_ARRAY_THRESHOLD           8
 #define VKVG_IBO_INDEX_TYPE         uint16_t
index ff045951b976ba5735b9d88a8084a82c5db59af7..3fc46477c892e1f9b98d10530d34a97fa5ccaf25 100644 (file)
 #endif
 
 #define PATH_CLOSED_BIT     0x80000000              /* most significant bit of path elmts is closed/open path state */
-#define PATH_HAS_CURVES_BIT 0x40000000              /* 2d most significant bit of path elmts  if curve data are present,
-                                                                                                          stored to avoid emiting joins in curves */
-#define PATH_IS_CURVE_BIT   0x80000000              /* most significant bit of path elmts end mark curves data in path array */
-#define PATH_IS_CONCAVE_BIT 0x40000000              /* 2d most significant bit of path elmts end = true if path is simple concave
-                                                                                                          triangulation for fill may be simplified (not implemented)*/
+#define PATH_HAS_CURVES_BIT 0x40000000              /* 2rd most significant bit of path elmts is curved status
+                                                                                                        * for main path, this indicate that curve datas are present
+                                                                                                        * for segments, this indicate that the segment is curved or not */
 #define PATH_ELT_MASK       0x3FFFFFFF              /* Bit mask for fetching path element value */
 
 #define ROUNDF(f, c) (((float)((int)((f) * (c))) / (c)))
index 349ada80cbf14d587201ddd31ceae0bbbd1f159c..625037b7ed1f6ca45f1cd900fc5f4c04ccc41b96 100644 (file)
@@ -178,7 +178,7 @@ _print_usage_and_exit () {
        printf("\t-q:\t\tQuiet, don't print measures table head row, usefull for batch tests\n");
        printf("\t-p:\t\tPrint test details and exit without performing test, usefull to print details in logs\n");
        printf("\t-vsync:\t\tEnable VSync, disabled by default\n");
-       printf("\t-h:\t\tthis help message.\n");
+       printf("\t-help:\t\tthis help message.\n");
        printf("\n");
        exit(-1);
 }
@@ -247,7 +247,7 @@ void _print_results (const char *testName, int argc, char* argv[], uint32_t i, d
        avg_frames_per_second = (avg_frames_per_second<9999) ? avg_frames_per_second:9999;
 
        if (!quiet && (test_index == 0 || test_index == single_test)) {
-               printf ("______________________________________________________________________________________________________\n");            
+               printf ("__________________________________________________________________________________________________________\n");                
                printf ("| N° | Test File Name  |       Sub Test            | Iter | Size |   FPS   | Average | Median  | Sigma   |\n");
                printf ("|----|-----------------|---------------------------|------|------|---------|---------|---------|---------|\n");
        }