mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
internal/graphicsdriver: use []uint32 instead of []uint16 for indices
Updates #2612
This commit is contained in:
parent
ba93794a72
commit
f2544a1bd9
13
image.go
13
image.go
@ -488,8 +488,10 @@ func (i *Image) DrawTriangles(vertices []Vertex, indices []uint16, img *Image, o
|
||||
vs[i*graphics.VertexFloatCount+7] = v.ColorA * ca
|
||||
}
|
||||
}
|
||||
is := make([]uint16, len(indices))
|
||||
copy(is, indices)
|
||||
is := make([]uint32, len(indices))
|
||||
for i := range is {
|
||||
is[i] = uint32(indices[i])
|
||||
}
|
||||
|
||||
srcs := [graphics.ShaderImageCount]*ui.Image{img.image}
|
||||
|
||||
@ -635,8 +637,11 @@ func (i *Image) DrawTrianglesShader(vertices []Vertex, indices []uint16, shader
|
||||
vs[i*graphics.VertexFloatCount+6] = v.ColorB
|
||||
vs[i*graphics.VertexFloatCount+7] = v.ColorA
|
||||
}
|
||||
is := make([]uint16, len(indices))
|
||||
copy(is, indices)
|
||||
|
||||
is := make([]uint32, len(indices))
|
||||
for i := range is {
|
||||
is[i] = uint32(indices[i])
|
||||
}
|
||||
|
||||
var imgs [graphics.ShaderImageCount]*ui.Image
|
||||
var imgSize image.Point
|
||||
|
@ -591,7 +591,7 @@ func TestImageEdge(t *testing.T) {
|
||||
ColorA: 1,
|
||||
},
|
||||
}
|
||||
is := graphics.QuadIndices()
|
||||
is := []uint16{0, 1, 2, 1, 2, 3}
|
||||
op.Filter = f
|
||||
img1.DrawTriangles(vs, is, img0, op)
|
||||
}
|
||||
|
@ -313,14 +313,14 @@ func (i *Image) regionWithPadding() image.Rectangle {
|
||||
// 5: Color G
|
||||
// 6: Color B
|
||||
// 7: Color Y
|
||||
func (i *Image) DrawTriangles(srcs [graphics.ShaderImageCount]*Image, vertices []float32, indices []uint16, blend graphicsdriver.Blend, dstRegion image.Rectangle, srcRegions [graphics.ShaderImageCount]image.Rectangle, shader *Shader, uniforms []uint32, evenOdd bool) {
|
||||
func (i *Image) DrawTriangles(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) {
|
||||
backendsM.Lock()
|
||||
defer backendsM.Unlock()
|
||||
|
||||
if !inFrame {
|
||||
vs := make([]float32, len(vertices))
|
||||
copy(vs, vertices)
|
||||
is := make([]uint16, len(indices))
|
||||
is := make([]uint32, len(indices))
|
||||
copy(is, indices)
|
||||
us := make([]uint32, len(uniforms))
|
||||
copy(us, uniforms)
|
||||
@ -334,7 +334,7 @@ func (i *Image) DrawTriangles(srcs [graphics.ShaderImageCount]*Image, vertices [
|
||||
i.drawTriangles(srcs, vertices, indices, blend, dstRegion, srcRegions, shader, uniforms, evenOdd, false)
|
||||
}
|
||||
|
||||
func (i *Image) drawTriangles(srcs [graphics.ShaderImageCount]*Image, vertices []float32, indices []uint16, blend graphicsdriver.Blend, dstRegion image.Rectangle, srcRegions [graphics.ShaderImageCount]image.Rectangle, shader *Shader, uniforms []uint32, evenOdd bool, keepOnAtlas bool) {
|
||||
func (i *Image) drawTriangles(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, keepOnAtlas bool) {
|
||||
backends := make([]*backend, 0, len(srcs))
|
||||
for _, src := range srcs {
|
||||
if src == nil {
|
||||
|
@ -92,7 +92,7 @@ func (i *Image) WritePixels(pix []byte, region image.Rectangle) {
|
||||
// DrawTriangles draws the src image with the given vertices.
|
||||
//
|
||||
// Copying vertices and indices is the caller's responsibility.
|
||||
func (i *Image) DrawTriangles(srcs [graphics.ShaderImageCount]*Image, vertices []float32, indices []uint16, blend graphicsdriver.Blend, dstRegion image.Rectangle, srcRegions [graphics.ShaderImageCount]image.Rectangle, shader *atlas.Shader, uniforms []uint32, evenOdd bool) {
|
||||
func (i *Image) DrawTriangles(srcs [graphics.ShaderImageCount]*Image, vertices []float32, indices []uint32, blend graphicsdriver.Blend, dstRegion image.Rectangle, srcRegions [graphics.ShaderImageCount]image.Rectangle, shader *atlas.Shader, uniforms []uint32, evenOdd bool) {
|
||||
for _, src := range srcs {
|
||||
if i == src {
|
||||
panic("buffered: Image.DrawTriangles: source images must be different from the receiver")
|
||||
|
@ -49,15 +49,17 @@ const (
|
||||
// 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 .
|
||||
//
|
||||
// TODO: Use MaxUint32 and move these values to internal/graphicscommand (#2612)
|
||||
MaxVerticesCount = math.MaxUint16
|
||||
MaxVertexFloatsCount = MaxVerticesCount * VertexFloatCount
|
||||
)
|
||||
|
||||
var (
|
||||
quadIndices = []uint16{0, 1, 2, 1, 2, 3}
|
||||
quadIndices = []uint32{0, 1, 2, 1, 2, 3}
|
||||
)
|
||||
|
||||
func QuadIndices() []uint16 {
|
||||
func QuadIndices() []uint32 {
|
||||
return quadIndices
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ type commandQueue struct {
|
||||
|
||||
// vertices represents a vertices data in OpenGL's array buffer.
|
||||
vertices []float32
|
||||
indices []uint16
|
||||
indices []uint32
|
||||
|
||||
tmpNumVertexFloats int
|
||||
|
||||
@ -71,7 +71,7 @@ func (q *commandQueue) addFinalizer(f func()) {
|
||||
q.finalizers = append(q.finalizers, f)
|
||||
}
|
||||
|
||||
func (q *commandQueue) appendIndices(indices []uint16, offset uint16) {
|
||||
func (q *commandQueue) appendIndices(indices []uint32, offset uint32) {
|
||||
n := len(q.indices)
|
||||
q.indices = append(q.indices, indices...)
|
||||
for i := n; i < len(q.indices); i++ {
|
||||
@ -85,7 +85,7 @@ func mustUseDifferentVertexBuffer(nextNumVertexFloats int) bool {
|
||||
}
|
||||
|
||||
// EnqueueDrawTrianglesCommand enqueues a drawing-image command.
|
||||
func (q *commandQueue) EnqueueDrawTrianglesCommand(dst *Image, srcs [graphics.ShaderImageCount]*Image, vertices []float32, indices []uint16, blend graphicsdriver.Blend, dstRegion image.Rectangle, srcRegions [graphics.ShaderImageCount]image.Rectangle, shader *Shader, uniforms []uint32, evenOdd bool) {
|
||||
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)))
|
||||
}
|
||||
@ -99,7 +99,7 @@ func (q *commandQueue) EnqueueDrawTrianglesCommand(dst *Image, srcs [graphics.Sh
|
||||
// Assume that all the image sizes are same.
|
||||
// Assume that the images are packed from the front in the slice srcs.
|
||||
q.vertices = append(q.vertices, vertices...)
|
||||
q.appendIndices(indices, uint16(q.tmpNumVertexFloats/graphics.VertexFloatCount))
|
||||
q.appendIndices(indices, uint32(q.tmpNumVertexFloats/graphics.VertexFloatCount))
|
||||
q.tmpNumVertexFloats += len(vertices)
|
||||
|
||||
// prependPreservedUniforms not only prepends values to the given slice but also creates a new slice.
|
||||
@ -477,7 +477,7 @@ func (c *commandQueueManager) putCommandQueue(commandQueue *commandQueue) {
|
||||
c.pool.put(commandQueue)
|
||||
}
|
||||
|
||||
func (c *commandQueueManager) enqueueDrawTrianglesCommand(dst *Image, srcs [graphics.ShaderImageCount]*Image, vertices []float32, indices []uint16, blend graphicsdriver.Blend, dstRegion image.Rectangle, srcRegions [graphics.ShaderImageCount]image.Rectangle, shader *Shader, uniforms []uint32, evenOdd bool) {
|
||||
func (c *commandQueueManager) 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 c.current == nil {
|
||||
c.current, _ = c.pool.get()
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ func (i *Image) InternalSize() (int, int) {
|
||||
//
|
||||
// If the source image is not specified, i.e., src is nil and there is no image in the uniform variables, the
|
||||
// elements for the source image are not used.
|
||||
func (i *Image) DrawTriangles(srcs [graphics.ShaderImageCount]*Image, vertices []float32, indices []uint16, blend graphicsdriver.Blend, dstRegion image.Rectangle, srcRegions [graphics.ShaderImageCount]image.Rectangle, shader *Shader, uniforms []uint32, evenOdd bool) {
|
||||
func (i *Image) DrawTriangles(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) {
|
||||
for _, src := range srcs {
|
||||
if src == nil {
|
||||
continue
|
||||
|
@ -48,8 +48,8 @@ const (
|
||||
_DXGI_FORMAT_R32G32B32A32_FLOAT _DXGI_FORMAT = 2
|
||||
_DXGI_FORMAT_R32G32_FLOAT _DXGI_FORMAT = 16
|
||||
_DXGI_FORMAT_R8G8B8A8_UNORM _DXGI_FORMAT = 28
|
||||
_DXGI_FORMAT_R32_UINT _DXGI_FORMAT = 42
|
||||
_DXGI_FORMAT_D24_UNORM_S8_UINT _DXGI_FORMAT = 45
|
||||
_DXGI_FORMAT_R16_UINT _DXGI_FORMAT = 57
|
||||
_DXGI_FORMAT_B8G8R8A8_UNORM _DXGI_FORMAT = 87
|
||||
)
|
||||
|
||||
|
@ -316,7 +316,7 @@ func (g *graphics11) SetTransparent(transparent bool) {
|
||||
// TODO: Implement this?
|
||||
}
|
||||
|
||||
func (g *graphics11) SetVertices(vertices []float32, indices []uint16) error {
|
||||
func (g *graphics11) SetVertices(vertices []float32, indices []uint32) error {
|
||||
if size := pow2(uint32(len(vertices)) * uint32(unsafe.Sizeof(vertices[0]))); g.vertexBufferSizeInBytes < size {
|
||||
if g.vertexBuffer != nil {
|
||||
g.vertexBuffer.Release()
|
||||
@ -352,7 +352,7 @@ func (g *graphics11) SetVertices(vertices []float32, indices []uint16) error {
|
||||
}
|
||||
g.indexBuffer = b
|
||||
g.indexBufferSizeInBytes = size
|
||||
g.deviceContext.IASetIndexBuffer(g.indexBuffer, _DXGI_FORMAT_R16_UINT, 0)
|
||||
g.deviceContext.IASetIndexBuffer(g.indexBuffer, _DXGI_FORMAT_R32_UINT, 0)
|
||||
}
|
||||
|
||||
// Copy the vertices data.
|
||||
@ -371,7 +371,7 @@ func (g *graphics11) SetVertices(vertices []float32, indices []uint16) error {
|
||||
if err := g.deviceContext.Map(unsafe.Pointer(g.indexBuffer), 0, _D3D11_MAP_WRITE_DISCARD, 0, &mapped); err != nil {
|
||||
return err
|
||||
}
|
||||
copy(unsafe.Slice((*uint16)(mapped.pData), len(indices)), indices)
|
||||
copy(unsafe.Slice((*uint32)(mapped.pData), len(indices)), indices)
|
||||
g.deviceContext.Unmap(unsafe.Pointer(g.indexBuffer), 0)
|
||||
}
|
||||
|
||||
|
@ -876,7 +876,7 @@ func (g *graphics12) SetTransparent(transparent bool) {
|
||||
// TODO: Implement this?
|
||||
}
|
||||
|
||||
func (g *graphics12) SetVertices(vertices []float32, indices []uint16) (ferr error) {
|
||||
func (g *graphics12) SetVertices(vertices []float32, indices []uint32) (ferr error) {
|
||||
// Create buffers if necessary.
|
||||
vidx := len(g.vertices[g.frameIndex])
|
||||
if cap(g.vertices[g.frameIndex]) > vidx {
|
||||
@ -946,7 +946,7 @@ func (g *graphics12) SetVertices(vertices []float32, indices []uint16) (ferr err
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
copy(unsafe.Slice((*uint16)(unsafe.Pointer(m)), len(indices)), indices)
|
||||
copy(unsafe.Slice((*uint32)(unsafe.Pointer(m)), len(indices)), indices)
|
||||
g.indices[g.frameIndex][iidx].value.Unmap(0, nil)
|
||||
|
||||
return nil
|
||||
@ -1159,7 +1159,7 @@ func (g *graphics12) DrawTriangles(dstID graphicsdriver.ImageID, srcs [graphics.
|
||||
g.drawCommandList.IASetIndexBuffer(&_D3D12_INDEX_BUFFER_VIEW{
|
||||
BufferLocation: g.indices[g.frameIndex][len(g.indices[g.frameIndex])-1].value.GetGPUVirtualAddress(),
|
||||
SizeInBytes: g.indices[g.frameIndex][len(g.indices[g.frameIndex])-1].sizeInBytes,
|
||||
Format: _DXGI_FORMAT_R16_UINT,
|
||||
Format: _DXGI_FORMAT_R32_UINT,
|
||||
})
|
||||
|
||||
if err := g.pipelineStates.drawTriangles(g.device, g.drawCommandList, g.frameIndex, dst.screen, srcImages, shader, dstRegions, adjustedUniforms, blend, indexOffset, evenOdd); err != nil {
|
||||
|
@ -36,7 +36,7 @@ type Graphics interface {
|
||||
Begin() error
|
||||
End(present bool) error
|
||||
SetTransparent(transparent bool)
|
||||
SetVertices(vertices []float32, indices []uint16) error
|
||||
SetVertices(vertices []float32, indices []uint32) error
|
||||
NewImage(width, height int) (Image, error)
|
||||
NewScreenFramebufferImage(width, height int) (Image, error)
|
||||
SetVsyncEnabled(enabled bool)
|
||||
|
@ -212,7 +212,7 @@ func (g *Graphics) availableBuffer(length uintptr) mtl.Buffer {
|
||||
return newBuf
|
||||
}
|
||||
|
||||
func (g *Graphics) SetVertices(vertices []float32, indices []uint16) error {
|
||||
func (g *Graphics) SetVertices(vertices []float32, indices []uint32) error {
|
||||
vbSize := unsafe.Sizeof(vertices[0]) * uintptr(len(vertices))
|
||||
ibSize := unsafe.Sizeof(indices[0]) * uintptr(len(indices))
|
||||
|
||||
@ -574,15 +574,15 @@ func (g *Graphics) draw(dst *Image, dstRegions []graphicsdriver.DstRegion, srcs
|
||||
if evenOdd {
|
||||
g.rce.SetDepthStencilState(g.dsss[prepareStencil])
|
||||
g.rce.SetRenderPipelineState(prepareStencilRpss)
|
||||
g.rce.DrawIndexedPrimitives(mtl.PrimitiveTypeTriangle, dstRegion.IndexCount, mtl.IndexTypeUInt16, g.ib, indexOffset*2)
|
||||
g.rce.DrawIndexedPrimitives(mtl.PrimitiveTypeTriangle, dstRegion.IndexCount, mtl.IndexTypeUInt32, g.ib, indexOffset*int(unsafe.Sizeof(uint32(0))))
|
||||
|
||||
g.rce.SetDepthStencilState(g.dsss[drawWithStencil])
|
||||
g.rce.SetRenderPipelineState(drawWithStencilRpss)
|
||||
g.rce.DrawIndexedPrimitives(mtl.PrimitiveTypeTriangle, dstRegion.IndexCount, mtl.IndexTypeUInt16, g.ib, indexOffset*2)
|
||||
g.rce.DrawIndexedPrimitives(mtl.PrimitiveTypeTriangle, dstRegion.IndexCount, mtl.IndexTypeUInt32, g.ib, indexOffset*int(unsafe.Sizeof(uint32(0))))
|
||||
} else {
|
||||
g.rce.SetDepthStencilState(g.dsss[noStencil])
|
||||
g.rce.SetRenderPipelineState(noStencilRpss)
|
||||
g.rce.DrawIndexedPrimitives(mtl.PrimitiveTypeTriangle, dstRegion.IndexCount, mtl.IndexTypeUInt16, g.ib, indexOffset*2)
|
||||
g.rce.DrawIndexedPrimitives(mtl.PrimitiveTypeTriangle, dstRegion.IndexCount, mtl.IndexTypeUInt32, g.ib, indexOffset*int(unsafe.Sizeof(uint32(0))))
|
||||
}
|
||||
|
||||
indexOffset += dstRegion.IndexCount
|
||||
|
@ -76,7 +76,7 @@ const (
|
||||
TRUE = 1
|
||||
UNPACK_ALIGNMENT = 0x0CF5
|
||||
UNSIGNED_BYTE = 0x1401
|
||||
UNSIGNED_SHORT = 0x1403
|
||||
UNSIGNED_INT = 0x1405
|
||||
VERTEX_SHADER = 0x8B31
|
||||
WRITE_ONLY = 0x88B9
|
||||
ZERO = 0
|
||||
|
@ -17,6 +17,7 @@ package opengl
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
"unsafe"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/graphics"
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver"
|
||||
@ -164,7 +165,7 @@ func (g *Graphics) Reset() error {
|
||||
return g.state.reset(&g.context)
|
||||
}
|
||||
|
||||
func (g *Graphics) SetVertices(vertices []float32, indices []uint16) error {
|
||||
func (g *Graphics) SetVertices(vertices []float32, indices []uint32) error {
|
||||
g.state.setVertices(&g.context, vertices, indices)
|
||||
return nil
|
||||
}
|
||||
@ -262,13 +263,13 @@ func (g *Graphics) DrawTriangles(dstID graphicsdriver.ImageID, srcIDs [graphics.
|
||||
g.context.ctx.StencilOp(gl.KEEP, gl.KEEP, gl.INVERT)
|
||||
g.context.ctx.ColorMask(false, false, false, false)
|
||||
|
||||
g.context.ctx.DrawElements(gl.TRIANGLES, int32(dstRegion.IndexCount), gl.UNSIGNED_SHORT, indexOffset*2)
|
||||
g.context.ctx.DrawElements(gl.TRIANGLES, int32(dstRegion.IndexCount), gl.UNSIGNED_INT, indexOffset*int(unsafe.Sizeof(uint32(0))))
|
||||
|
||||
g.context.ctx.StencilFunc(gl.NOTEQUAL, 0x00, 0xff)
|
||||
g.context.ctx.StencilOp(gl.KEEP, gl.KEEP, gl.KEEP)
|
||||
g.context.ctx.ColorMask(true, true, true, true)
|
||||
}
|
||||
g.context.ctx.DrawElements(gl.TRIANGLES, int32(dstRegion.IndexCount), gl.UNSIGNED_SHORT, indexOffset*2) // 2 is uint16 size in bytes
|
||||
g.context.ctx.DrawElements(gl.TRIANGLES, int32(dstRegion.IndexCount), gl.UNSIGNED_INT, indexOffset*int(unsafe.Sizeof(uint32(0))))
|
||||
indexOffset += dstRegion.IndexCount
|
||||
}
|
||||
|
||||
|
@ -176,13 +176,13 @@ func pow2(x int) int {
|
||||
return p2
|
||||
}
|
||||
|
||||
func (s *openGLState) setVertices(context *context, vertices []float32, indices []uint16) {
|
||||
func (s *openGLState) setVertices(context *context, vertices []float32, indices []uint32) {
|
||||
if s.vertexArray == 0 {
|
||||
s.vertexArray = context.ctx.CreateVertexArray()
|
||||
}
|
||||
context.ctx.BindVertexArray(s.vertexArray)
|
||||
|
||||
if size := len(vertices) * 4; s.arrayBufferSizeInBytes < size {
|
||||
if size := len(vertices) * int(unsafe.Sizeof(vertices[0])); s.arrayBufferSizeInBytes < size {
|
||||
if s.arrayBuffer != 0 {
|
||||
context.ctx.DeleteBuffer(uint32(s.arrayBuffer))
|
||||
}
|
||||
@ -196,7 +196,7 @@ func (s *openGLState) setVertices(context *context, vertices []float32, indices
|
||||
theArrayBufferLayout.enable(context)
|
||||
}
|
||||
|
||||
if size := len(indices) * 2; s.elementArrayBufferSizeInBytes < size {
|
||||
if size := len(indices) * int(unsafe.Sizeof(indices[0])); s.elementArrayBufferSizeInBytes < size {
|
||||
if s.elementArrayBuffer != 0 {
|
||||
context.ctx.DeleteBuffer(uint32(s.elementArrayBuffer))
|
||||
}
|
||||
@ -208,9 +208,9 @@ func (s *openGLState) setVertices(context *context, vertices []float32, indices
|
||||
}
|
||||
|
||||
// Note that the vertices and the indices passed to BufferSubData is not under GC management in the gl package.
|
||||
vs := unsafe.Slice((*byte)(unsafe.Pointer(&vertices[0])), len(vertices)*4)
|
||||
vs := unsafe.Slice((*byte)(unsafe.Pointer(&vertices[0])), len(vertices)*int(unsafe.Sizeof(vertices[0])))
|
||||
context.ctx.BufferSubData(gl.ARRAY_BUFFER, 0, vs)
|
||||
is := unsafe.Slice((*byte)(unsafe.Pointer(&indices[0])), len(indices)*2)
|
||||
is := unsafe.Slice((*byte)(unsafe.Pointer(&indices[0])), len(indices)*int(unsafe.Sizeof(indices[0])))
|
||||
context.ctx.BufferSubData(gl.ELEMENT_ARRAY_BUFFER, 0, is)
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ func (g *Graphics) End(present bool) error {
|
||||
func (g *Graphics) SetTransparent(transparent bool) {
|
||||
}
|
||||
|
||||
func (g *Graphics) SetVertices(vertices []float32, indices []uint16) error {
|
||||
func (g *Graphics) SetVertices(vertices []float32, indices []uint32) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ func (m *Mipmap) ReadPixels(graphicsDriver graphicsdriver.Graphics, pixels []byt
|
||||
return m.orig.ReadPixels(graphicsDriver, pixels, region)
|
||||
}
|
||||
|
||||
func (m *Mipmap) DrawTriangles(srcs [graphics.ShaderImageCount]*Mipmap, vertices []float32, indices []uint16, blend graphicsdriver.Blend, dstRegion image.Rectangle, srcRegions [graphics.ShaderImageCount]image.Rectangle, shader *atlas.Shader, uniforms []uint32, evenOdd bool, canSkipMipmap bool) {
|
||||
func (m *Mipmap) DrawTriangles(srcs [graphics.ShaderImageCount]*Mipmap, vertices []float32, indices []uint32, blend graphicsdriver.Blend, dstRegion image.Rectangle, srcRegions [graphics.ShaderImageCount]image.Rectangle, shader *atlas.Shader, uniforms []uint32, evenOdd bool, canSkipMipmap bool) {
|
||||
if len(indices) == 0 {
|
||||
return
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ func (p *Pixels) Dispose() {
|
||||
type drawTrianglesHistoryItem struct {
|
||||
images [graphics.ShaderImageCount]*Image
|
||||
vertices []float32
|
||||
indices []uint16
|
||||
indices []uint32
|
||||
blend graphicsdriver.Blend
|
||||
dstRegion image.Rectangle
|
||||
srcRegions [graphics.ShaderImageCount]image.Rectangle
|
||||
@ -322,7 +322,7 @@ func (i *Image) WritePixels(pixels *graphics.ManagedBytes, region image.Rectangl
|
||||
// 5: Color G
|
||||
// 6: Color B
|
||||
// 7: Color Y
|
||||
func (i *Image) DrawTriangles(srcs [graphics.ShaderImageCount]*Image, vertices []float32, indices []uint16, blend graphicsdriver.Blend, dstRegion image.Rectangle, srcRegions [graphics.ShaderImageCount]image.Rectangle, shader *Shader, uniforms []uint32, evenOdd bool) {
|
||||
func (i *Image) DrawTriangles(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) == 0 {
|
||||
return
|
||||
}
|
||||
@ -358,7 +358,7 @@ func (i *Image) DrawTriangles(srcs [graphics.ShaderImageCount]*Image, vertices [
|
||||
}
|
||||
|
||||
// appendDrawTrianglesHistory appends a draw-image history item to the image.
|
||||
func (i *Image) appendDrawTrianglesHistory(srcs [graphics.ShaderImageCount]*Image, vertices []float32, indices []uint16, blend graphicsdriver.Blend, dstRegion image.Rectangle, srcRegions [graphics.ShaderImageCount]image.Rectangle, shader *Shader, uniforms []uint32, evenOdd bool) {
|
||||
func (i *Image) appendDrawTrianglesHistory(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 i.stale || !i.needsRestoring() {
|
||||
panic("restorable: an image must not be stale or need restoring at appendDrawTrianglesHistory")
|
||||
}
|
||||
@ -378,7 +378,7 @@ func (i *Image) appendDrawTrianglesHistory(srcs [graphics.ShaderImageCount]*Imag
|
||||
vs := make([]float32, len(vertices))
|
||||
copy(vs, vertices)
|
||||
|
||||
is := make([]uint16, len(indices))
|
||||
is := make([]uint32, len(indices))
|
||||
copy(is, indices)
|
||||
|
||||
us := make([]uint32, len(uniforms))
|
||||
|
@ -908,7 +908,7 @@ func TestMutateSlices(t *testing.T) {
|
||||
src.WritePixels(bytesToManagedBytes(pix), image.Rect(0, 0, w, h))
|
||||
|
||||
vs := quadVertices(w, h, 0, 0)
|
||||
is := make([]uint16, len(graphics.QuadIndices()))
|
||||
is := make([]uint32, len(graphics.QuadIndices()))
|
||||
copy(is, graphics.QuadIndices())
|
||||
dr := image.Rect(0, 0, w, h)
|
||||
dst.DrawTriangles([graphics.ShaderImageCount]*restorable.Image{src}, vs, is, graphicsdriver.BlendSourceOver, dr, [graphics.ShaderImageCount]image.Rectangle{}, restorable.NearestFilterShader, nil, false)
|
||||
|
@ -80,7 +80,7 @@ func (i *Image) Deallocate() {
|
||||
i.dotsBuffer = nil
|
||||
}
|
||||
|
||||
func (i *Image) DrawTriangles(srcs [graphics.ShaderImageCount]*Image, vertices []float32, indices []uint16, blend graphicsdriver.Blend, dstRegion image.Rectangle, srcRegions [graphics.ShaderImageCount]image.Rectangle, shader *Shader, uniforms []uint32, evenOdd bool, canSkipMipmap bool, antialias bool) {
|
||||
func (i *Image) DrawTriangles(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, canSkipMipmap bool, antialias bool) {
|
||||
if i.modifyCallback != nil {
|
||||
i.modifyCallback()
|
||||
}
|
||||
@ -195,7 +195,7 @@ func (i *Image) flushDotsBufferIfNeeded() {
|
||||
|
||||
l := len(i.dotsBuffer)
|
||||
vs := make([]float32, l*4*graphics.VertexFloatCount)
|
||||
is := make([]uint16, l*6)
|
||||
is := make([]uint32, l*6)
|
||||
sx, sy := float32(1), float32(1)
|
||||
var idx int
|
||||
for p, c := range i.dotsBuffer {
|
||||
@ -239,12 +239,12 @@ func (i *Image) flushDotsBufferIfNeeded() {
|
||||
vs[graphics.VertexFloatCount*4*idx+30] = cbf
|
||||
vs[graphics.VertexFloatCount*4*idx+31] = caf
|
||||
|
||||
is[6*idx] = uint16(4 * idx)
|
||||
is[6*idx+1] = uint16(4*idx + 1)
|
||||
is[6*idx+2] = uint16(4*idx + 2)
|
||||
is[6*idx+3] = uint16(4*idx + 1)
|
||||
is[6*idx+4] = uint16(4*idx + 2)
|
||||
is[6*idx+5] = uint16(4*idx + 3)
|
||||
is[6*idx] = uint32(4 * idx)
|
||||
is[6*idx+1] = uint32(4*idx + 1)
|
||||
is[6*idx+2] = uint32(4*idx + 2)
|
||||
is[6*idx+3] = uint32(4*idx + 1)
|
||||
is[6*idx+4] = uint32(4*idx + 2)
|
||||
is[6*idx+5] = uint32(4*idx + 3)
|
||||
|
||||
idx++
|
||||
}
|
||||
@ -325,7 +325,7 @@ func (i *bigOffscreenImage) deallocate() {
|
||||
i.dirty = false
|
||||
}
|
||||
|
||||
func (i *bigOffscreenImage) drawTriangles(srcs [graphics.ShaderImageCount]*Image, vertices []float32, indices []uint16, blend graphicsdriver.Blend, dstRegion image.Rectangle, srcRegions [graphics.ShaderImageCount]image.Rectangle, shader *Shader, uniforms []uint32, evenOdd bool, canSkipMipmap bool, antialias bool) {
|
||||
func (i *bigOffscreenImage) drawTriangles(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, canSkipMipmap bool, antialias bool) {
|
||||
if i.blend != blend {
|
||||
i.flush()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user