diff --git a/internal/affine/colorm.go b/internal/affine/colorm.go index a10e86b1a..16e5e3ffe 100644 --- a/internal/affine/colorm.go +++ b/internal/affine/colorm.go @@ -173,15 +173,15 @@ func (c *colorMImplBodyTranslate) Apply(clr color.Color) color.Color { } } -func (c *ColorM) UnsafeElements() ([]float32, []float32) { +func (c *ColorM) UnsafeElements() (*[16]float32, *[4]float32) { if c.isIdentity() { - return colorMIdentityBody[:], colorMIdentityTranslate[:] + return &colorMIdentityBody, &colorMIdentityTranslate } return c.impl.UnsafeElements() } -func (c *colorMImplBodyTranslate) UnsafeElements() ([]float32, []float32) { - return c.body[:], c.translate[:] +func (c *colorMImplBodyTranslate) UnsafeElements() (*[16]float32, *[4]float32) { + return &c.body, &c.translate } func (c *ColorM) det() float32 { diff --git a/internal/graphicsdriver/metal/graphics.go b/internal/graphicsdriver/metal/graphics.go index 3c3d2a8d3..6472a7242 100644 --- a/internal/graphicsdriver/metal/graphics.go +++ b/internal/graphicsdriver/metal/graphics.go @@ -917,8 +917,8 @@ func (g *Graphics) DrawTriangles(dstID driver.ImageID, srcIDs [graphics.ShaderIm uniformVars = []interface{}{ []float32{float32(w), float32(h)}, sourceSize, - esBody, - esTranslate, + esBody[:], + esTranslate[:], scale, []float32{ srcRegion.X, diff --git a/internal/graphicsdriver/opengl/graphics.go b/internal/graphicsdriver/opengl/graphics.go index 6b8e4986b..739519387 100644 --- a/internal/graphicsdriver/opengl/graphics.go +++ b/internal/graphicsdriver/opengl/graphics.go @@ -192,11 +192,11 @@ func (g *Graphics) DrawTriangles(dstID driver.ImageID, srcIDs [graphics.ShaderIm esBody, esTranslate := colorM.UnsafeElements() uniformVars = append(uniformVars, uniformVariable{ name: "color_matrix_body", - value: esBody, + value: esBody[:], typ: shaderir.Type{Main: shaderir.Mat4}, }, uniformVariable{ name: "color_matrix_translation", - value: esTranslate, + value: esTranslate[:], typ: shaderir.Type{Main: shaderir.Vec4}, }) }