From a5f67252f220e261a98aac85f73361966d78c6c2 Mon Sep 17 00:00:00 2001 From: RblSb Date: Fri, 11 Sep 2026 17:43:17 +0300 Subject: [PATCH] Fix early buffer flush in image painter --- Sources/kha/graphics4/Graphics2.hx | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/Sources/kha/graphics4/Graphics2.hx b/Sources/kha/graphics4/Graphics2.hx index ce0afb8c0..a7ba1dfe3 100644 --- a/Sources/kha/graphics4/Graphics2.hx +++ b/Sources/kha/graphics4/Graphics2.hx @@ -262,7 +262,7 @@ class ImageShaderPainter { g.setTexture(pipeline.textureLocation, null); - if (end || (bufferStart + bufferIndex + 1) * 4 >= bufferSize) { + if (end || bufferIndex + 1 >= bufferSize) { bufferStart = 0; bufferIndex = 0; rectVertices = rectVertexBuffer.lock(0); @@ -288,7 +288,7 @@ class ImageShaderPainter { public inline function drawImage(img: kha.Image, bottomleftx: FastFloat, bottomlefty: FastFloat, topleftx: FastFloat, toplefty: FastFloat, toprightx: FastFloat, toprighty: FastFloat, bottomrightx: FastFloat, bottomrighty: FastFloat, opacity: FastFloat, color: Color): Void { var tex = img; - if (bufferStart + bufferIndex + 1 >= bufferSize || (lastTexture != null && tex != lastTexture)) + if (bufferIndex + 1 >= bufferSize || (lastTexture != null && tex != lastTexture)) drawBuffer(false); setRectColor(color.R, color.G, color.B, color.A * opacity); @@ -303,7 +303,7 @@ class ImageShaderPainter { bottomlefty: FastFloat, topleftx: FastFloat, toplefty: FastFloat, toprightx: FastFloat, toprighty: FastFloat, bottomrightx: FastFloat, bottomrighty: FastFloat, opacity: FastFloat, color: Color): Void { var tex = img; - if (bufferStart + bufferIndex + 1 >= bufferSize || (lastTexture != null && tex != lastTexture)) + if (bufferIndex + 1 >= bufferSize || (lastTexture != null && tex != lastTexture)) drawBuffer(false); setRectTexCoords(sx / tex.realWidth, sy / tex.realHeight, (sx + sw) / tex.realWidth, (sy + sh) / tex.realHeight); @@ -314,20 +314,6 @@ class ImageShaderPainter { lastTexture = tex; } - public inline function drawImageScale(img: kha.Image, sx: FastFloat, sy: FastFloat, sw: FastFloat, sh: FastFloat, left: FastFloat, top: FastFloat, - right: FastFloat, bottom: FastFloat, opacity: FastFloat, color: Color): Void { - var tex = img; - if (bufferStart + bufferIndex + 1 >= bufferSize || (lastTexture != null && tex != lastTexture)) - drawBuffer(false); - - setRectTexCoords(sx / tex.realWidth, sy / tex.realHeight, (sx + sw) / tex.realWidth, (sy + sh) / tex.realHeight); - setRectColor(color.R, color.G, color.B, opacity); - setRectVertices(left, bottom, left, top, right, top, right, bottom); - - ++bufferIndex; - lastTexture = tex; - } - public function end(): Void { if (bufferIndex > 0) { drawBuffer(true);