From 39aaf7fe374ce293f6a228582dd6972f0d35f1e1 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Tue, 14 Mar 2023 13:06:11 +0900 Subject: [PATCH] ebiten: update comments Updates #2601 --- image.go | 4 ++-- internal/graphicscommand/command.go | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/image.go b/image.go index f649b1243..8935987c1 100644 --- a/image.go +++ b/image.go @@ -38,10 +38,10 @@ type Image struct { original *Image bounds image.Rectangle - // tmpVertices must not be reused until the vertices are sent to the graphics command queue. + // tmpVertices must not be reused until ui.Image.Draw* is called. tmpVertices []float32 - // tmpUniforms must not be reused until the vertices are sent to the graphics command queue. + // tmpUniforms must not be reused until ui.Image.Draw* is called. tmpUniforms []uint32 // Do not add a 'buffering' member that are resolved lazily. diff --git a/internal/graphicscommand/command.go b/internal/graphicscommand/command.go index 09dd2fb18..40cf714e7 100644 --- a/internal/graphicscommand/command.go +++ b/internal/graphicscommand/command.go @@ -110,6 +110,9 @@ func (q *commandQueue) EnqueueDrawTrianglesCommand(dst *Image, srcs [graphics.Sh q.tmpNumVertexFloats += len(vertices) q.tmpNumIndices += len(indices) + // prependPreservedUniforms not only prepends values to the given slice but also creates a new slice. + // Allocating a new slice is necessary to make EnqueueDrawTrianglesCommand safe so far. + // TODO: This might cause a performance issue (#2601). uniforms = q.prependPreservedUniforms(uniforms, shader, dst, srcs, offsets, dstRegion, srcRegion) // Remove unused uniform variables so that more commands can be merged.