From eec78223d1233217740d682f830d0c0b493fdc0c Mon Sep 17 00:00:00 2001 From: Inkeliz Date: Tue, 15 Mar 2022 12:37:26 +0000 Subject: [PATCH] gpu: prevent texture to be larger than MaxTextureSize Change eeb2febfea01cda47bd46e76f08b3f80347fce46 added extra space to FBO sizes to avoid re-creating them often. However, the size could end up higher than the GPU supports. This change caps the size. Fixes: https://todo.sr.ht/~eliasnaur/gio/380 Signed-off-by: Inkeliz --- gpu/path.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gpu/path.go b/gpu/path.go index c56ce159..c14d5928 100644 --- a/gpu/path.go +++ b/gpu/path.go @@ -261,6 +261,13 @@ func (s *fboSet) resize(ctx driver.Device, sizes []image.Point) { } // Add 5% extra space in each dimension to minimize resizing. sz = sz.Mul(105).Div(100) + max := ctx.Caps().MaxTextureSize + if sz.Y > max { + sz.Y = max + } + if sz.X > max { + sz.X = max + } tex, err := ctx.NewTexture(driver.TextureFormatFloat, sz.X, sz.Y, driver.FilterNearest, driver.FilterNearest, driver.BufferBindingTexture|driver.BufferBindingFramebuffer) if err != nil {