From: Jean-Philippe Bruyère Date: Fri, 11 Sep 2020 12:54:37 +0000 (+0200) Subject: wip, reame path bits, typo X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=8e2f1aee629c051331994ff056a212461eac13ab;p=jp%2Fvkvg.git wip, reame path bits, typo --- diff --git a/include/vkvg.h b/include/vkvg.h index 8f921c3..903e59e 100644 --- a/include/vkvg.h +++ b/include/vkvg.h @@ -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 diff --git a/src/vkvg_context.c b/src/vkvg_context.c index f2f0988..f0ae09e 100644 --- a/src/vkvg_context.c +++ b/src/vkvg_context.c @@ -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) diff --git a/src/vkvg_context_internal.c b/src/vkvg_context_internal.c index d0a53e3..cfe944c 100644 --- a/src/vkvg_context_internal.c +++ b/src/vkvg_context_internal.c @@ -38,10 +38,11 @@ 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); } } diff --git a/src/vkvg_context_internal.h b/src/vkvg_context_internal.h index 95a52ab..e9b45c9 100644 --- a/src/vkvg_context_internal.h +++ b/src/vkvg_context_internal.h @@ -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 diff --git a/src/vkvg_internal.h b/src/vkvg_internal.h index ff04595..3fc4647 100644 --- a/src/vkvg_internal.h +++ b/src/vkvg_internal.h @@ -49,11 +49,9 @@ #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))) diff --git a/tests/common/test.c b/tests/common/test.c index 349ada8..625037b 100644 --- a/tests/common/test.c +++ b/tests/common/test.c @@ -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"); }