Fixed nil dst image checks

This commit is contained in:
Zyko 2024-04-10 18:56:25 +02:00
parent c3a358b44b
commit fc3a6ed373
5 changed files with 18 additions and 0 deletions

View File

@ -809,6 +809,9 @@ func DrawTrianglesShaderMRT(dsts [graphics.ShaderDstImageCount]*Image, vertices
}
for _, dst := range dsts {
if dst == nil {
continue
}
dst.tmpUniforms = dst.tmpUniforms[:0]
dst.tmpUniforms = shader.appendUniforms(dst.tmpUniforms, options.Uniforms)
}

View File

@ -214,6 +214,9 @@ func (i *Image) DrawTriangles(srcs [graphics.ShaderSrcImageCount]*Image, vertice
func DrawTrianglesMRT(dsts [graphics.ShaderDstImageCount]*Image, srcs [graphics.ShaderSrcImageCount]*Image, vertices []float32, indices []uint32, blend graphicsdriver.Blend, dstRegion image.Rectangle, srcRegions [graphics.ShaderSrcImageCount]image.Rectangle, shader *atlas.Shader, uniforms []uint32, fillRule graphicsdriver.FillRule) {
for _, src := range srcs {
for _, dst := range dsts {
if dst == nil {
continue
}
if dst == src {
panic("buffered: DrawTrianglesMRT: source images must be different from the destination")
}
@ -246,6 +249,9 @@ func DrawTrianglesMRT(dsts [graphics.ShaderDstImageCount]*Image, srcs [graphics.
// After rendering, the pixel cache is no longer valid.
for _, dst := range dsts {
if dst == nil {
continue
}
dst.pixels = nil
}
}

View File

@ -177,6 +177,9 @@ func DrawTrianglesMRT(dsts [graphics.ShaderDstImageCount]*Image, srcs [graphics.
src.flushBufferedWritePixels()
}
for _, dst := range dsts {
if dst == nil {
continue
}
dst.flushBufferedWritePixels()
}

View File

@ -195,6 +195,9 @@ func DrawTrianglesMRT(dsts [graphics.ShaderDstImageCount]*Mipmap, srcs [graphics
buffered.DrawTrianglesMRT(dstImgs, srcImgs, vertices, indices, blend, dstRegion, srcRegions, shader, uniforms, fillRule)
for _, dst := range dsts {
if dst == nil {
continue
}
dst.deallocateMipmaps()
}
}

View File

@ -119,6 +119,9 @@ func (i *Image) DrawTriangles(srcs [graphics.ShaderSrcImageCount]*Image, vertice
func DrawTrianglesMRT(dsts [graphics.ShaderDstImageCount]*Image, srcs [graphics.ShaderSrcImageCount]*Image, vertices []float32, indices []uint32, blend graphicsdriver.Blend, dstRegion image.Rectangle, srcRegions [graphics.ShaderSrcImageCount]image.Rectangle, shader *Shader, uniforms []uint32, fillRule graphicsdriver.FillRule, canSkipMipmap bool, antialias bool) {
var dstMipmaps [graphics.ShaderDstImageCount]*mipmap.Mipmap
for i, dst := range dsts {
if dst == nil {
continue
}
if dst.modifyCallback != nil {
dst.modifyCallback()
}