From 1f462998702b77abf176821e95957a65ecced12c Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 16 Feb 2019 15:14:48 +0900 Subject: [PATCH] graphicsdriver/opengl: Bug fix: source_size can be optimized out with nearest filter --- internal/graphicsdriver/opengl/program.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/internal/graphicsdriver/opengl/program.go b/internal/graphicsdriver/opengl/program.go index 09c4c1ead..c091959e6 100644 --- a/internal/graphicsdriver/opengl/program.go +++ b/internal/graphicsdriver/opengl/program.go @@ -323,10 +323,15 @@ func (d *Driver) useProgram(mode graphics.CompositeMode, colorM *affine.ColorM, sw := graphics.InternalImageSize(srcW) sh := graphics.InternalImageSize(srcH) - if d.state.lastSourceWidth != sw || d.state.lastSourceHeight != sh { - d.context.uniformFloats(program, "source_size", []float32{float32(sw), float32(sh)}) - d.state.lastSourceWidth = sw - d.state.lastSourceHeight = sh + if filter == graphics.FilterNearest { + d.state.lastSourceWidth = 0 + d.state.lastSourceHeight = 0 + } else { + if d.state.lastSourceWidth != sw || d.state.lastSourceHeight != sh { + d.context.uniformFloats(program, "source_size", []float32{float32(sw), float32(sh)}) + d.state.lastSourceWidth = sw + d.state.lastSourceHeight = sh + } } if filter == graphics.FilterScreen {