From 5ec2f66524664ddaaa936a6c6ed093013ec195cc Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Thu, 4 Jul 2019 01:55:55 +0900 Subject: [PATCH] shareable: Bug fix: Updated maxSize wrongly Updates #892 --- internal/shareable/shareable.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/internal/shareable/shareable.go b/internal/shareable/shareable.go index affb3dc04..4348d656c 100644 --- a/internal/shareable/shareable.go +++ b/internal/shareable/shareable.go @@ -39,6 +39,13 @@ var ( maxSize = 0 ) +func min(a, b int) int { + if a < b { + return a + } + return b +} + func init() { var once sync.Once hooks.AppendHookOnBeforeUpdate(func() error { @@ -52,10 +59,7 @@ func init() { minSize = 1024 // Use 4096 as a maximum size whatever size the graphics driver accepts. There are // not enough evidences that bigger textures works correctly. - maxSize = 4096 - if m := graphicsDriver.MaxImageSize(); maxSize < m { - maxSize = m - } + maxSize = min(4096, graphicsDriver.MaxImageSize()) } else { minSize = 512 maxSize = 512