From 31273c875fc4ba12592d2443bd8776c1149941a8 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Thu, 23 Mar 2023 20:48:39 +0900 Subject: [PATCH] internal/graphics: rename constants --- image_test.go | 6 +++--- internal/graphics/vertex.go | 6 +++--- internal/graphicscommand/command.go | 6 +++--- internal/ui/image.go | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/image_test.go b/image_test.go index 6f4f1e28c..efac6fa77 100644 --- a/image_test.go +++ b/image_test.go @@ -2742,7 +2742,7 @@ func TestIndicesOverflow(t *testing.T) { op := &ebiten.DrawTrianglesOptions{} vs := make([]ebiten.Vertex, 3) - is := make([]uint16, graphics.MaxVertexCount/3*3) + is := make([]uint16, graphics.MaxVerticesCount/3*3) dst.DrawTriangles(vs, is, src, op) // Cause an overflow for indices. @@ -2813,7 +2813,7 @@ func TestVerticesOverflow(t *testing.T) { src.Fill(color.White) op := &ebiten.DrawTrianglesOptions{} - vs := make([]ebiten.Vertex, graphics.MaxVertexCount-1) + vs := make([]ebiten.Vertex, graphics.MaxVerticesCount-1) is := make([]uint16, 3) dst.DrawTriangles(vs, is, src, op) @@ -2885,7 +2885,7 @@ func TestTooManyVertices(t *testing.T) { src.Fill(color.White) op := &ebiten.DrawTrianglesOptions{} - vs := make([]ebiten.Vertex, graphics.MaxVertexCount+1) + vs := make([]ebiten.Vertex, graphics.MaxVerticesCount+1) is := make([]uint16, 3) dst.DrawTriangles(vs, is, src, op) diff --git a/internal/graphics/vertex.go b/internal/graphics/vertex.go index 7fa2cde87..d20c2cac7 100644 --- a/internal/graphics/vertex.go +++ b/internal/graphics/vertex.go @@ -54,12 +54,12 @@ const ( const ( VertexFloatCount = 8 - // MaxVertexCount is the maximum number of vertices for one draw call. + // MaxVerticesCount is the maximum number of vertices for one draw call. // This value is 2^16 - 1 = 65535, as the index type is uint16. // This value cannot be exactly 2^16 == 65536 especially with WebGL 2, as 65536th vertex is not rendered correctly. // See https://registry.khronos.org/webgl/specs/latest/2.0/#5.18 . - MaxVertexCount = math.MaxUint16 - MaxVertexFloatCount = MaxVertexCount * VertexFloatCount + MaxVerticesCount = math.MaxUint16 + MaxVertexFloatsCount = MaxVerticesCount * VertexFloatCount ) var ( diff --git a/internal/graphicscommand/command.go b/internal/graphicscommand/command.go index 75cfa049d..8f9ddcf80 100644 --- a/internal/graphicscommand/command.go +++ b/internal/graphicscommand/command.go @@ -86,14 +86,14 @@ func (q *commandQueue) appendIndices(indices []uint16, offset uint16) { // mustUseDifferentVertexBuffer reports whether a different vertex buffer must be used. func mustUseDifferentVertexBuffer(nextNumVertexFloats int) bool { - return nextNumVertexFloats > graphics.MaxVertexFloatCount + return nextNumVertexFloats > graphics.MaxVertexFloatsCount } // EnqueueDrawTrianglesCommand enqueues a drawing-image command. func (q *commandQueue) EnqueueDrawTrianglesCommand(dst *Image, srcs [graphics.ShaderImageCount]*Image, offsets [graphics.ShaderImageCount - 1][2]float32, vertices []float32, indices []uint16, blend graphicsdriver.Blend, dstRegion, srcRegion graphicsdriver.Region, shader *Shader, uniforms []uint32, evenOdd bool) { - if len(vertices) > graphics.MaxVertexFloatCount { + if len(vertices) > graphics.MaxVertexFloatsCount { // The last part cannot be specified by indices. Just omit them. - vertices = vertices[:graphics.MaxVertexFloatCount] + vertices = vertices[:graphics.MaxVertexFloatsCount] } split := false diff --git a/internal/ui/image.go b/internal/ui/image.go index 9b57b8f59..3f5a53826 100644 --- a/internal/ui/image.go +++ b/internal/ui/image.go @@ -133,7 +133,7 @@ func (i *Image) WritePixels(pix []byte, x, y, width, height int) { i.dotsBuffer[[2]int{x, y}] = clr // One square requires 6 indices (= 2 triangles). - if len(i.dotsBuffer) >= graphics.MaxVertexCount/6 { + if len(i.dotsBuffer) >= graphics.MaxVerticesCount/6 { i.flushDotsBufferIfNeeded() } return