_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);
}
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);
}
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)
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;
//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;
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;
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
}
}
//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);
}
}
_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
}
#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);
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;
}
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)) {
totPts += (ctx->pathes[ptrPath++] & PATH_ELT_MASK);
}else
ptrPath++;
- free (ecps);
}
}
#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)))
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);
}
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");
}