internal/graphics: rename constants

Closes #2828
This commit is contained in:
Hajime Hoshi 2023-11-04 16:05:26 +09:00
parent 1f95c98969
commit d862a75fb3
3 changed files with 21 additions and 16 deletions

View File

@ -394,7 +394,12 @@ const MaxIndicesCount = (1 << 16) / 3 * 3
const MaxIndicesNum = MaxIndicesCount
// MaxVerticesCount is the maximum number of vertices for DrawTriangles and DrawTrianglesShader.
const MaxVerticesCount = graphics.MaxVerticesCount
//
// Deprecated: as of v2.7. Use MaxVertexCount instead.
const MaxVerticesCount = graphics.MaxVertexCount
// MaxVertexCount is the maximum number of vertices for DrawTriangles and DrawTrianglesShader.
const MaxVertexCount = graphics.MaxVertexCount
// DrawTriangles draws triangles with the specified vertices and their indices.
//
@ -406,11 +411,11 @@ const MaxVerticesCount = graphics.MaxVerticesCount
// Vertex contains color values, which are interpreted as straight-alpha colors by default.
// This depends on the option's ColorScaleMode.
//
// If len(vertices) is more than MaxVerticesCount, the exceeding part is ignored.
// If len(vertices) is more than MaxVertexCount, the exceeding part is ignored.
//
// If len(indices) is not multiple of 3, DrawTriangles panics.
//
// If a value in indices is out of range of vertices, or not less than MaxVerticesCount, DrawTriangles panics.
// If a value in indices is out of range of vertices, or not less than MaxVertexCount, DrawTriangles panics.
//
// The rule in which DrawTriangles works effectively is same as DrawImage's.
//
@ -427,9 +432,9 @@ func (i *Image) DrawTriangles(vertices []Vertex, indices []uint16, img *Image, o
return
}
if len(vertices) > graphics.MaxVerticesCount {
if len(vertices) > graphics.MaxVertexCount {
// The last part cannot be specified by indices. Just omit them.
vertices = vertices[:graphics.MaxVerticesCount]
vertices = vertices[:graphics.MaxVertexCount]
}
if len(indices)%3 != 0 {
panic("ebiten: len(indices) % 3 must be 0")
@ -567,11 +572,11 @@ var _ [len(DrawTrianglesShaderOptions{}.Images) - graphics.ShaderImageCount]stru
// DrawTrianglesShader panics.
// If one of the specified image is non-nil and is disposed, DrawTrianglesShader panics.
//
// If len(vertices) is more than MaxVerticesCount, the exceeding part is ignored.
// If len(vertices) is more than MaxVertexCount, the exceeding part is ignored.
//
// If len(indices) is not multiple of 3, DrawTrianglesShader panics.
//
// If a value in indices is out of range of vertices, or not less than MaxVerticesCount, DrawTrianglesShader panics.
// If a value in indices is out of range of vertices, or not less than MaxVertexCount, DrawTrianglesShader panics.
//
// When a specified image is non-nil and is disposed, DrawTrianglesShader panics.
//
@ -589,9 +594,9 @@ func (i *Image) DrawTrianglesShader(vertices []Vertex, indices []uint16, shader
panic("ebiten: the given shader to DrawTrianglesShader must not be disposed")
}
if len(vertices) > graphics.MaxVerticesCount {
if len(vertices) > graphics.MaxVertexCount {
// The last part cannot be specified by indices. Just omit them.
vertices = vertices[:graphics.MaxVerticesCount]
vertices = vertices[:graphics.MaxVertexCount]
}
if len(indices)%3 != 0 {
panic("ebiten: len(indices) % 3 must be 0")

View File

@ -48,16 +48,16 @@ const (
is32bit = 1 >> (^uint(0) >> 63)
is64bit = 1 - is32bit
// MaxVerticesCount is the maximum number of vertices for one draw call.
// MaxVertexCount is the maximum number of vertices for one draw call.
//
// On 64bit architectures, this value is 2^32-1, as the index type is uint32.
// This value cannot be exactly 2^32 especially with WebGL 2, as 2^32th vertex is not rendered correctly.
// See https://registry.khronos.org/webgl/specs/latest/2.0/#5.18 .
//
// On 32bit architectures, this value is an adjusted number so that MaxVertexFloatsCount doesn't overflow int.
MaxVerticesCount = is64bit*math.MaxUint32 + is32bit*(math.MaxInt32/VertexFloatCount)
// On 32bit architectures, this value is an adjusted number so that MaxVertexFloatCount doesn't overflow int.
MaxVertexCount = is64bit*math.MaxUint32 + is32bit*(math.MaxInt32/VertexFloatCount)
MaxVertexFloatsCount = MaxVerticesCount * VertexFloatCount
MaxVertexFloatCount = MaxVertexCount * VertexFloatCount
)
var (

View File

@ -81,13 +81,13 @@ func (q *commandQueue) appendIndices(indices []uint32, offset uint32) {
// mustUseDifferentVertexBuffer reports whether a different vertex buffer must be used.
func mustUseDifferentVertexBuffer(nextNumVertexFloats int) bool {
return nextNumVertexFloats > graphics.MaxVertexFloatsCount
return nextNumVertexFloats > graphics.MaxVertexFloatCount
}
// EnqueueDrawTrianglesCommand enqueues a drawing-image command.
func (q *commandQueue) EnqueueDrawTrianglesCommand(dst *Image, srcs [graphics.ShaderImageCount]*Image, vertices []float32, indices []uint32, blend graphicsdriver.Blend, dstRegion image.Rectangle, srcRegions [graphics.ShaderImageCount]image.Rectangle, shader *Shader, uniforms []uint32, evenOdd bool) {
if len(vertices) > graphics.MaxVertexFloatsCount {
panic(fmt.Sprintf("graphicscommand: len(vertices) must equal to or less than %d but was %d", graphics.MaxVertexFloatsCount, len(vertices)))
if len(vertices) > graphics.MaxVertexFloatCount {
panic(fmt.Sprintf("graphicscommand: len(vertices) must equal to or less than %d but was %d", graphics.MaxVertexFloatCount, len(vertices)))
}
split := false