From 72bb238d08ef44e7c641fbf6197cc665fde9a872 Mon Sep 17 00:00:00 2001 From: martinfouilleul Date: Sun, 13 Aug 2023 14:51:27 +0200 Subject: [PATCH] [canvas] fix canvas max tile queue count. Off-by-one was causing some paths to be culled in segment setup shader's bounds check --- milepost/src/gl_canvas.c | 10 ++++++++-- milepost/src/mtl_renderer.m | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/milepost/src/gl_canvas.c b/milepost/src/gl_canvas.c index 50a81df..2c43bee 100644 --- a/milepost/src/gl_canvas.c +++ b/milepost/src/gl_canvas.c @@ -373,8 +373,14 @@ void mg_gl_canvas_encode_path(mg_gl_canvas_backend* backend, mg_primitive* primi path->textureID = -1; } - int nTilesX = ((path->box.z - path->box.x)*scale - 1) / MG_GL_TILE_SIZE + 1; - int nTilesY = ((path->box.w - path->box.y)*scale - 1) / MG_GL_TILE_SIZE + 1; + int firstTileX = path->box.x*scale / MG_GL_TILE_SIZE; + int firstTileY = path->box.y*scale / MG_GL_TILE_SIZE; + int lastTileX = path->box.z*scale / MG_GL_TILE_SIZE; + int lastTileY = path->box.w*scale / MG_GL_TILE_SIZE; + + int nTilesX = lastTileX - firstTileX + 1; + int nTilesY = lastTileY - firstTileY + 1; + backend->maxTileQueueCount += (nTilesX * nTilesY); } diff --git a/milepost/src/mtl_renderer.m b/milepost/src/mtl_renderer.m index 61de9db..11497cd 100644 --- a/milepost/src/mtl_renderer.m +++ b/milepost/src/mtl_renderer.m @@ -255,8 +255,14 @@ void mg_mtl_encode_path(mg_mtl_canvas_backend* backend, mg_primitive* primitive, } path->texture = backend->currentImageIndex; - int nTilesX = ((path->box.z - path->box.x)*scale - 1) / MG_MTL_TILE_SIZE + 1; - int nTilesY = ((path->box.w - path->box.y)*scale - 1) / MG_MTL_TILE_SIZE + 1; + int firstTileX = path->box.x*scale / MG_MTL_TILE_SIZE; + int firstTileY = path->box.y*scale / MG_MTL_TILE_SIZE; + int lastTileX = path->box.z*scale / MG_MTL_TILE_SIZE; + int lastTileY = path->box.w*scale / MG_MTL_TILE_SIZE; + + int nTilesX = lastTileX - firstTileX + 1; + int nTilesY = lastTileY - firstTileY + 1; + backend->maxTileQueueCount += (nTilesX * nTilesY); }