Revert "internal/graphicscommand: add graphics.MaxVertexFloatCount and use it instead of IndicesCount"

This reverts commit 54e2790a06.

Reason: test failures on browsers:

`GOOS=js GOARCH=wasm go test . -shuffle=1679547510163000000` failed
https://github.com/hajimehoshi/ebiten/actions/runs/4497182906/jobs/7912544699
This commit is contained in:
Hajime Hoshi 2023-03-23 14:07:22 +09:00
parent 54e2790a06
commit c59bcbdb5b
2 changed files with 3 additions and 16 deletions

View File

@ -14,10 +14,6 @@
package graphics package graphics
import (
"math"
)
const ( const (
ShaderImageCount = 4 ShaderImageCount = 4
@ -53,12 +49,7 @@ const (
const ( const (
IndicesCount = (1 << 16) / 3 * 3 // Adjust num for triangles. TODO: Remove this (#2460). IndicesCount = (1 << 16) / 3 * 3 // Adjust num for triangles. TODO: Remove this (#2460).
)
const (
VertexFloatCount = 8 VertexFloatCount = 8
MaxVertexCount = math.MaxUint16 + 1
MaxVertexFloatCount = MaxVertexCount * VertexFloatCount
) )
var ( var (

View File

@ -86,15 +86,11 @@ func (q *commandQueue) appendIndices(indices []uint16, offset uint16) {
// mustUseDifferentVertexBuffer reports whether a different vertex buffer must be used. // mustUseDifferentVertexBuffer reports whether a different vertex buffer must be used.
func mustUseDifferentVertexBuffer(nextNumVertexFloats int) bool { func mustUseDifferentVertexBuffer(nextNumVertexFloats int) bool {
return nextNumVertexFloats > graphics.MaxVertexFloatCount return nextNumVertexFloats > graphics.IndicesCount*graphics.VertexFloatCount
} }
// EnqueueDrawTrianglesCommand enqueues a drawing-image command. // 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) { 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 {
panic(fmt.Sprintf("graphicscommand: len(vertices) must not exceed %d but was %d", graphics.MaxVertexFloatCount, len(vertices)))
}
split := false split := false
if mustUseDifferentVertexBuffer(q.tmpNumVertexFloats + len(vertices)) { if mustUseDifferentVertexBuffer(q.tmpNumVertexFloats + len(vertices)) {
q.tmpNumVertexFloats = 0 q.tmpNumVertexFloats = 0