internal/graphics: rename constants

This commit is contained in:
Hajime Hoshi 2023-03-23 20:48:39 +09:00
parent ce9274a29d
commit 31273c875f
4 changed files with 10 additions and 10 deletions

View File

@ -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)

View File

@ -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 (

View File

@ -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

View File

@ -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