[mtl canvas] tmp fix of clear color (revisit one we re-introduce texturing)

This commit is contained in:
Martin Fouilleul 2023-03-29 16:30:16 +02:00
parent 8af4e4eddc
commit eee158ff85
3 changed files with 11 additions and 8 deletions

View File

@ -2977,7 +2977,8 @@ void mg_flush_commands(int primitiveCount, mg_primitive* primitives, mg_path_elt
if(canvas->backend && canvas->backend->render)
{
canvas->backend->render(canvas->backend, primitiveCount, primitives, canvas->path.startIndex + canvas->path.count, pathElements);
int eltCount = canvas->path.startIndex + canvas->path.count;
canvas->backend->render(canvas->backend, canvas->clearColor, primitiveCount, primitives, eltCount, pathElements);
return;
}

View File

@ -205,6 +205,7 @@ typedef struct mg_primitive
} mg_primitive;
typedef void (*mg_canvas_backend_render_proc)(mg_canvas_backend* backend,
mg_color clearColor,
u32 primitiveCount,
mg_primitive* primitives,
u32 eltCount,

View File

@ -62,6 +62,7 @@ static void mg_update_path_extents(vec4* extents, vec2 p)
}
void mg_mtl_canvas_render(mg_canvas_backend* interface,
mg_color clearColor,
u32 primitiveCount,
mg_primitive* primitives,
u32 eltCount,
@ -69,8 +70,7 @@ void mg_mtl_canvas_render(mg_canvas_backend* interface,
{
mg_mtl_canvas_backend* backend = (mg_mtl_canvas_backend*)interface;
//TODO: update rolling buffers
//NOTE: update rolling buffers
dispatch_semaphore_wait(backend->bufferSemaphore, DISPATCH_TIME_FOREVER);
backend->bufferIndex = (backend->bufferIndex + 1) % MG_MTL_INPUT_BUFFERS_COUNT;
@ -264,7 +264,8 @@ void mg_mtl_canvas_render(mg_canvas_backend* interface,
//TODO: clear here?
MTLRenderPassDescriptor* renderPassDescriptor = [MTLRenderPassDescriptor renderPassDescriptor];
renderPassDescriptor.colorAttachments[0].texture = surface->drawable.texture;
renderPassDescriptor.colorAttachments[0].loadAction = MTLLoadActionLoad;
renderPassDescriptor.colorAttachments[0].loadAction = MTLLoadActionClear;
renderPassDescriptor.colorAttachments[0].clearColor = MTLClearColorMake(clearColor.r, clearColor.g, clearColor.b, clearColor.a);
renderPassDescriptor.colorAttachments[0].storeAction = MTLStoreActionStore;
id<MTLRenderCommandEncoder> renderEncoder = [surface->commandBuffer renderCommandEncoderWithDescriptor:renderPassDescriptor];