From: Jean-Philippe Bruyère Date: Wed, 25 Apr 2018 19:23:03 +0000 (+0200) Subject: code clean X-Git-Tag: v0.1-alpha~133^2 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=refs%2Fpull%2F12%2Fhead;p=jp%2Fvkvg.git code clean --- diff --git a/src/vkvg_context.c b/src/vkvg_context.c index a4707da..5f09c29 100644 --- a/src/vkvg_context.c +++ b/src/vkvg_context.c @@ -301,7 +301,6 @@ void vkvg_rectangle (VkvgContext ctx, float x, float y, float w, float h){ void vkvg_reset_clip (VkvgContext ctx){ _flush_cmd_buff(ctx); _clear_stencil(ctx->pSurf); - //ctx->stencilRef=0; _init_cmd_buff(ctx); } void vkvg_clip (VkvgContext ctx){ @@ -356,12 +355,10 @@ void vkvg_clip_preserve (VkvgContext ctx){ vkCmdBindPipeline(ctx->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, ctx->pSurf->dev->pipelineClipping); vkCmdDrawIndexed (ctx->cmd,6,1,0,0,0); - //vkvg_flush(ctx); + //should test current operator to bind correct pipeline - //ctx->stencilRef++; vkCmdBindPipeline(ctx->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, ctx->pSurf->dev->pipeline); vkCmdSetStencilCompareMask(ctx->cmd, VK_STENCIL_FRONT_AND_BACK, STENCIL_CLIP_BIT); - //vkCmdSetStencilReference(ctx->cmd,VK_STENCIL_FRONT_AND_BACK, ctx->stencilRef); } void vkvg_fill_preserve (VkvgContext ctx){ if (ctx->pathPtr == 0) //nothing to fill @@ -375,10 +372,8 @@ void vkvg_fill_preserve (VkvgContext ctx){ vkCmdBindPipeline(ctx->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, ctx->pSurf->dev->pipeline); vkCmdSetStencilCompareMask(ctx->cmd, VK_STENCIL_FRONT_AND_BACK, STENCIL_FILL_BIT); - //vkCmdSetStencilReference(ctx->cmd,VK_STENCIL_FRONT_AND_BACK, 0xff); vkCmdDrawIndexed (ctx->cmd,6,1,0,0,0); vkCmdSetStencilCompareMask(ctx->cmd, VK_STENCIL_FRONT_AND_BACK, STENCIL_CLIP_BIT); - //vkCmdSetStencilReference(ctx->cmd,VK_STENCIL_FRONT_AND_BACK, 0x0); } void vkvg_stroke_preserve (VkvgContext ctx) { @@ -519,9 +514,6 @@ void _vkvg_fill_rectangle (VkvgContext ctx, float x, float y, float width, float _add_tri_indices_for_rect(ctx, firstIdx); } void vkvg_paint (VkvgContext ctx){ -// _vkvg_fill_rectangle (ctx, 0, 0, ctx->pSurf->width, ctx->pSurf->height); -// _record_draw_cmd(ctx); - //vkCmdSetStencilCompareMask(ctx->cmd, VK_STENCIL_FRONT_AND_BACK, 0x2); vkCmdDrawIndexed (ctx->cmd,6,1,0,0,0); } @@ -665,7 +657,6 @@ void vkvg_save (VkvgContext ctx){ VK_CHECK_RESULT(vkEndCommandBuffer(ctx->cmd)); _submit_ctx_cmd(ctx); - //sav->stencilRef = ctx->stencilRef; sav->sizePoints = ctx->sizePoints; sav->pointCount = ctx->pointCount; @@ -728,7 +719,6 @@ void vkvg_restore (VkvgContext ctx){ VK_CHECK_RESULT(vkEndCommandBuffer(ctx->cmd)); _submit_ctx_cmd(ctx); - //ctx->stencilRef = sav->stencilRef; ctx->sizePoints = sav->sizePoints; ctx->pointCount = sav->pointCount; diff --git a/src/vkvg_context_internal.c b/src/vkvg_context_internal.c index ed1bb27..c2fee69 100644 --- a/src/vkvg_context_internal.c +++ b/src/vkvg_context_internal.c @@ -245,7 +245,6 @@ void _init_cmd_buff (VkvgContext ctx){ vkCmdBindIndexBuffer(ctx->cmd, ctx->indices.buffer, 0, VK_INDEX_TYPE_UINT32); vkCmdBindPipeline(ctx->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, ctx->pSurf->dev->pipeline); vkCmdSetStencilCompareMask(ctx->cmd, VK_STENCIL_FRONT_AND_BACK, 0); - //vkCmdSetStencilReference(ctx->cmd,VK_STENCIL_FRONT_AND_BACK, ctx->stencilRef); _update_push_constants (ctx); } diff --git a/src/vkvg_context_internal.h b/src/vkvg_context_internal.h index 7d02728..a660993 100644 --- a/src/vkvg_context_internal.h +++ b/src/vkvg_context_internal.h @@ -47,8 +47,6 @@ typedef struct { uint32_t patternType; uint32_t pad; vkvg_matrix_t mat; - //uint32_t pad2; - //uint32_t pad3; vkvg_matrix_t matInv; }push_constants; @@ -89,7 +87,6 @@ typedef struct _vkvg_context_t { VkvgSurface pSurf; VkFence flushFence; - //uint32_t stencilRef; VkhImage source; VkCommandPool cmdPool; diff --git a/src/vkvg_device_internal.c b/src/vkvg_device_internal.c index 84021a9..5c0df70 100644 --- a/src/vkvg_device_internal.c +++ b/src/vkvg_device_internal.c @@ -158,10 +158,6 @@ void _setupPipelines(VkvgDevice dev) .pAttachments = &blendAttachmentState }; /*failOp,passOp,depthFailOp,compareOp, compareMask, writeMask, reference;*/ - /*VkStencilOpState polyFillOpState ={VK_STENCIL_OP_KEEP,VK_STENCIL_OP_INVERT,VK_STENCIL_OP_KEEP,VK_COMPARE_OP_EQUAL,0x0,0xf,0}; - VkStencilOpState clipingOpState = {VK_STENCIL_OP_REPLACE,VK_STENCIL_OP_ZERO,VK_STENCIL_OP_KEEP,VK_COMPARE_OP_EQUAL,STENCIL_FILL_BIT,STENCIL_ALL_BIT,0x2}; - VkStencilOpState stencilOpState = {VK_STENCIL_OP_KEEP,VK_STENCIL_OP_ZERO,VK_STENCIL_OP_KEEP,VK_COMPARE_OP_EQUAL,0xf,0xf,0xf};*/ - VkStencilOpState polyFillOpState ={VK_STENCIL_OP_KEEP,VK_STENCIL_OP_INVERT,VK_STENCIL_OP_KEEP,VK_COMPARE_OP_EQUAL,STENCIL_CLIP_BIT,STENCIL_FILL_BIT,0}; VkStencilOpState clipingOpState = {VK_STENCIL_OP_REPLACE,VK_STENCIL_OP_ZERO,VK_STENCIL_OP_KEEP,VK_COMPARE_OP_NOT_EQUAL,STENCIL_FILL_BIT,STENCIL_ALL_BIT,0x2}; VkStencilOpState stencilOpState = {VK_STENCIL_OP_KEEP,VK_STENCIL_OP_ZERO,VK_STENCIL_OP_KEEP,VK_COMPARE_OP_EQUAL,STENCIL_FILL_BIT,STENCIL_FILL_BIT,0x1}; @@ -265,7 +261,6 @@ void _setupPipelines(VkvgDevice dev) dsStateCreateInfo.back = dsStateCreateInfo.front = clipingOpState; VK_CHECK_RESULT(vkCreateGraphicsPipelines(dev->vkDev, dev->pipelineCache, 1, &pipelineCreateInfo, NULL, &dev->pipelineClipping)); - //dsStateCreateInfo.back.writeMask = dsStateCreateInfo.front.writeMask = 0; dsStateCreateInfo.back = dsStateCreateInfo.front = stencilOpState; blendAttachmentState.colorWriteMask=0xf; dynamicState.dynamicStateCount = 3; diff --git a/src/vkvg_surface.c b/src/vkvg_surface.c index 89035c6..35a22dc 100644 --- a/src/vkvg_surface.c +++ b/src/vkvg_surface.c @@ -60,9 +60,9 @@ void _init_surface (VkvgSurface surf) { surf->stencilMS = vkh_image_ms_create(surf->dev,VK_FORMAT_S8_UINT,VKVG_SAMPLES,surf->width,surf->height,VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, 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_BORDER); - vkh_image_create_descriptor(surf->imgMS, 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); - vkh_image_create_descriptor(surf->stencilMS, VK_IMAGE_VIEW_TYPE_2D, VK_IMAGE_ASPECT_STENCIL_BIT, VK_FILTER_NEAREST, VK_FILTER_NEAREST, VK_SAMPLER_MIPMAP_MODE_NEAREST,VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER); + 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); + vkh_image_create_descriptor(surf->imgMS, 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); + vkh_image_create_descriptor(surf->stencilMS, VK_IMAGE_VIEW_TYPE_2D, VK_IMAGE_ASPECT_STENCIL_BIT, VK_FILTER_NEAREST, VK_FILTER_NEAREST, VK_SAMPLER_MIPMAP_MODE_NEAREST,VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE); VkImageView attachments[] = { vkh_image_get_view (surf->imgMS), diff --git a/tests/test1.c b/tests/test1.c index 8ef3f54..ad19a0c 100644 --- a/tests/test1.c +++ b/tests/test1.c @@ -551,16 +551,15 @@ void cairo_test_fill_rule (VkvgContext cr){ void cairo_test_clip (VkvgContext cr){ vkvg_arc (cr, 128.0, 128.0, 76.8, 0, 2 * M_PI); vkvg_clip (cr); - //vkvg_new_path (cr); /* current path is not // consumed by vkvg_clip() */ vkvg_set_source_rgba(cr, 0, 0, 0, 1); vkvg_rectangle (cr, 0, 0, 256, 256); vkvg_fill (cr); vkvg_set_source_rgba (cr, 0, 1, 0, 1); - vkvg_move_to (cr, 0, 0); + vkvg_move_to (cr, -100, -100); vkvg_line_to (cr, 256, 256); - vkvg_move_to (cr, 256, 0); + vkvg_move_to (cr, 356, -100); vkvg_line_to (cr, 0, 256); vkvg_set_line_width (cr, 10.0); vkvg_stroke (cr); @@ -721,6 +720,25 @@ void cairo_tests () { vkvg_set_source_rgba(ctx,0.7,0.7,0.7,1); vkvg_paint(ctx); + /*vkvg_set_source_rgba(ctx,0,1,0,1); + vkvg_rectangle(ctx,100,100,200,200); + //vkvg_fill(ctx); + vkvg_clip(ctx); + + vkvg_set_source_rgba(ctx,1,0,0,1); + vkvg_paint(ctx); + //vkvg_rectangle(ctx,00,00,1024,800); + //vkvg_fill(ctx); + + vkvg_reset_clip(ctx); + vkvg_set_source_rgba(ctx,0,0,1,1); + vkvg_set_line_width(ctx,20); + vkvg_move_to(ctx,0,0); + vkvg_rel_line_to(ctx,800,800); + vkvg_stroke(ctx);*/ + + //cairo_test_clip(ctx); + cairo_print_arc(ctx); vkvg_translate(ctx,200,0); @@ -738,12 +756,6 @@ void cairo_tests () { vkvg_translate(ctx,250,0); cairo_print_arc_neg(ctx); - /*vkvg_translate(ctx,250,0); - cairo_test_clip(ctx); - - vkvg_translate(ctx,250,0); - vkvg_test_fill_and_stroke(ctx);*/ - vkvg_destroy(ctx); }