vkvg_buffer_destroy (&ctx->indices);
vkvg_buffer_destroy (&ctx->vertices);
+ free(ctx->vertexCache);
+ free(ctx->indexCache);
+
//vkh_image_destroy (ctx->source);
free(ctx->selectedFont.fontFile);
iR = ctx->pathes[ptrPath]&PATH_ELT_MASK;
_build_vb_step(ctx,v,hw,iL,i,iR, false);
- uint32_t* inds = (uint32_t*)(ctx->indices.allocInfo.pMappedData + ((ctx->indCount-6) * sizeof(uint32_t)));
+ uint32_t* inds = &ctx->indexCache [ctx->indCount-6];
uint32_t ii = firstIdx;
inds[1] = ii;
inds[4] = ii;
sizeof(vkvg_gradient_t), &ctx->uboGrad);
}
void _create_vertices_buff (VkvgContext ctx){
+
+ ctx->vertexCache = (Vertex*)malloc(ctx->sizeVertices * sizeof(Vertex));
+ ctx->indexCache = (uint32_t*)malloc(ctx->sizeVertices * sizeof(uint32_t));
+
vkvg_buffer_create (ctx->pSurf->dev,
VK_BUFFER_USAGE_VERTEX_BUFFER_BIT,
VMA_MEMORY_USAGE_CPU_TO_GPU,
}
const vec3 blankuv = {};
void _add_vertexf (VkvgContext ctx, float x, float y){
- Vertex* pVert = (Vertex*)(ctx->vertices.allocInfo.pMappedData + ctx->vertCount * sizeof(Vertex));
+ Vertex* pVert = &ctx->vertexCache[ctx->vertCount];
pVert->pos.x = x;
pVert->pos.y = y;
pVert->uv = blankuv;
ctx->vertCount++;
}
void _add_vertex(VkvgContext ctx, Vertex v){
- Vertex* pVert = (Vertex*)(ctx->vertices.allocInfo.pMappedData + ctx->vertCount * sizeof(Vertex));
- *pVert = v;
+ ctx->vertexCache[ctx->vertCount] = v;
ctx->vertCount++;
}
void _set_vertex(VkvgContext ctx, uint32_t idx, Vertex v){
- Vertex* pVert = (Vertex*)(ctx->vertices.allocInfo.pMappedData + idx * sizeof(Vertex));
- *pVert = v;
+ ctx->vertexCache[idx] = v;
}
void _add_tri_indices_for_rect (VkvgContext ctx, uint32_t i){
- uint32_t* inds = (uint32_t*)(ctx->indices.allocInfo.pMappedData + (ctx->indCount * sizeof(uint32_t)));
+ uint32_t* inds = &ctx->indexCache[ctx->indCount];
inds[0] = i;
inds[1] = i+2;
inds[2] = i+1;
ctx->indCount+=6;
}
void _add_triangle_indices(VkvgContext ctx, uint32_t i0, uint32_t i1, uint32_t i2){
- uint32_t* inds = (uint32_t*)(ctx->indices.allocInfo.pMappedData + (ctx->indCount * sizeof(uint32_t)));
+ uint32_t* inds = &ctx->indexCache[ctx->indCount];
inds[0] = i0;
inds[1] = i1;
inds[2] = i2;
{{x+width,y+height},{0,0,-1}}
};
uint32_t firstIdx = ctx->vertCount;
- Vertex* pVert = (Vertex*)(ctx->vertices.allocInfo.pMappedData + ctx->vertCount * sizeof(Vertex));
+ Vertex* pVert = &ctx->vertexCache[ctx->vertCount];
memcpy (pVert,v,4*sizeof(Vertex));
ctx->vertCount+=4;
_add_tri_indices_for_rect(ctx, firstIdx);
ctx->renderPassBeginInfo.renderPass = ctx->pSurf->dev->renderPass;
}
void _flush_cmd_buff (VkvgContext ctx){
+
+ memcpy(ctx->vertices.allocInfo.pMappedData, ctx->vertexCache, ctx->vertCount * sizeof (Vertex));
+ memcpy(ctx->indices.allocInfo.pMappedData, ctx->indexCache, ctx->indCount * sizeof (uint32_t));
+
if (!ctx->cmdStarted)
return;
_end_render_pass (ctx);
_add_vertex(ctx, v);
v.pos = p2;
_add_vertex(ctx, v);
- uint32_t* inds = (uint32_t*)(ctx->indices.allocInfo.pMappedData + (ctx->indCount * sizeof(uint32_t)));
+ uint32_t* inds = &ctx->indexCache [ctx->indCount];
inds[0] = ctx->vertCount - 2;
inds[1] = ctx->vertCount - 1;
ctx->indCount+=2;
VK_CHECK_RESULT(vkCreatePipelineLayout(dev->vkDev, &pipelineLayoutCreateInfo, NULL, &dev->pipelineLayout));
}
+void _wait_idle (VkvgDevice dev) {
+ vkDeviceWaitIdle (dev->vkDev);
+}
void _wait_and_reset_device_fence (VkvgDevice dev) {
vkWaitForFences (dev->vkDev, 1, &dev->fence, VK_TRUE, UINT64_MAX);
vkResetFences (dev->vkDev, 1, &dev->fence);