From 47efa26cfc058d87e532f18373008e7eb6c7a02a Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Thu, 16 Jul 2020 14:52:51 +0200 Subject: [PATCH] gpu: limit atlas textures to 8k x 8k Fixes gio#131 Fixes gio#133 Signed-off-by: Elias Naur --- gpu/gpu.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/gpu/gpu.go b/gpu/gpu.go index 5c80d087..c7a418c4 100644 --- a/gpu/gpu.go +++ b/gpu/gpu.go @@ -409,8 +409,16 @@ func newRenderer(ctx backend.Device) *renderer { blitter: newBlitter(ctx), pather: newPather(ctx), } - r.packer.maxDim = ctx.Caps().MaxTextureSize - r.intersections.maxDim = r.packer.maxDim + + maxDim := ctx.Caps().MaxTextureSize + // Large atlas textures cause artifacts due to precision loss in + // shaders. + if cap := 8192; maxDim > cap { + maxDim = cap + } + + r.packer.maxDim = maxDim + r.intersections.maxDim = maxDim return r }