mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
internal/graphicscommand: add graphics.MaxVertexFloatCount and use it instead of IndicesCount
Updates #2460
This commit is contained in:
parent
3f2ac129d2
commit
54e2790a06
@ -14,6 +14,10 @@
|
||||
|
||||
package graphics
|
||||
|
||||
import (
|
||||
"math"
|
||||
)
|
||||
|
||||
const (
|
||||
ShaderImageCount = 4
|
||||
|
||||
@ -48,8 +52,13 @@ const (
|
||||
)
|
||||
|
||||
const (
|
||||
IndicesCount = (1 << 16) / 3 * 3 // Adjust num for triangles. TODO: Remove this (#2460).
|
||||
VertexFloatCount = 8
|
||||
IndicesCount = (1 << 16) / 3 * 3 // Adjust num for triangles. TODO: Remove this (#2460).
|
||||
)
|
||||
|
||||
const (
|
||||
VertexFloatCount = 8
|
||||
MaxVertexCount = math.MaxUint16 + 1
|
||||
MaxVertexFloatCount = MaxVertexCount * VertexFloatCount
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -86,11 +86,15 @@ 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.IndicesCount*graphics.VertexFloatCount
|
||||
return nextNumVertexFloats > graphics.MaxVertexFloatCount
|
||||
}
|
||||
|
||||
// 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 {
|
||||
panic(fmt.Sprintf("graphicscommand: len(vertices) must not exceed %d but was %d", graphics.MaxVertexFloatCount, len(vertices)))
|
||||
}
|
||||
|
||||
split := false
|
||||
if mustUseDifferentVertexBuffer(q.tmpNumVertexFloats + len(vertices)) {
|
||||
q.tmpNumVertexFloats = 0
|
||||
|
Loading…
Reference in New Issue
Block a user