all: rename arguments in Kage

Closes #2767
This commit is contained in:
Hajime Hoshi 2023-09-24 15:59:58 +09:00
parent 915ed48f7a
commit b95228a8a6
10 changed files with 286 additions and 286 deletions

View File

@ -730,11 +730,11 @@ var _ [len(DrawRectShaderOptions{}.Images)]struct{} = [graphics.ShaderImageCount
// //
// If a specified uniform variable's length or type doesn't match with an expected one, DrawRectShader panics. // If a specified uniform variable's length or type doesn't match with an expected one, DrawRectShader panics.
// //
// In a shader, texCoord in Fragment represents a position in a source image. // In a shader, srcPos in Fragment represents a position in a source image.
// If no source images are specified, texCoord represents the position from (0, 0) to (width, height) in pixels. // If no source images are specified, srcPos represents the position from (0, 0) to (width, height) in pixels.
// If the unit is pixels by a compiler directive `//kage:unit pixelss`, texCoord values are valid. // If the unit is pixels by a compiler directive `//kage:unit pixelss`, srcPos values are valid.
// If the unit is texels (default), texCoord values still take from (0, 0) to (width, height), // If the unit is texels (default), srcPos values still take from (0, 0) to (width, height),
// but these are invalid since texCoord is expected to be in texels in the texel-unit mode. // but these are invalid since srcPos is expected to be in texels in the texel-unit mode.
// This behavior is preserved for backward compatibility. It is recommended to use the pixel-unit mode to avoid confusion. // This behavior is preserved for backward compatibility. It is recommended to use the pixel-unit mode to avoid confusion.
// //
// If no source images are specified, imageSrc0Size returns a valid size only when the unit is pixels, // If no source images are specified, imageSrc0Size returns a valid size only when the unit is pixels,

View File

@ -2197,7 +2197,7 @@ func TestImageDrawTrianglesShaderInterpolatesValues(t *testing.T) {
is := []uint16{0, 1, 2, 1, 2, 3} is := []uint16{0, 1, 2, 1, 2, 3}
shader, err := ebiten.NewShader([]byte(` shader, err := ebiten.NewShader([]byte(`
package main package main
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
return color return color
} }
`)) `))
@ -4152,7 +4152,7 @@ func TestImageDrawTrianglesShaderWithGreaterIndexThanVerticesCount(t *testing.T)
is := []uint16{0, 1, 2, 1, 2, 4} is := []uint16{0, 1, 2, 1, 2, 4}
shader, err := ebiten.NewShader([]byte(` shader, err := ebiten.NewShader([]byte(`
package main package main
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
return color return color
} }
`)) `))
@ -4194,7 +4194,7 @@ func TestImageDrawTrianglesShaderWithTooBigIndex(t *testing.T) {
is := []uint16{0, 1, 2, 1, 2, ebiten.MaxVerticesCount} is := []uint16{0, 1, 2, 1, 2, ebiten.MaxVerticesCount}
shader, err := ebiten.NewShader([]byte(` shader, err := ebiten.NewShader([]byte(`
package main package main
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
return color return color
} }
`)) `))
@ -4218,7 +4218,7 @@ func TestImageGeoMAfterDraw(t *testing.T) {
package main package main
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
return vec4(1) return vec4(1)
} }
`)) `))

View File

@ -37,7 +37,7 @@ func (g *Game) Update() error {
var Color vec4 var Color vec4
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
return Color return Color
}`)) }`))
if err != nil { if err != nil {
@ -69,7 +69,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
var Dummy float var Dummy float
var A, B, G, R float var A, B, G, R float
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
return vec4(R, G, B, A) return vec4(R, G, B, A)
}`)) }`))
if err != nil { if err != nil {

View File

@ -26,7 +26,7 @@ func (g *Game) Update() error {
const shaderData = ` const shaderData = `
package main package main
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
return vec4(1) return vec4(1)
} }
` `

View File

@ -22,7 +22,7 @@ func init() {
s, err := ebiten.NewShader([]byte(` s, err := ebiten.NewShader([]byte(`
package main package main
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
return vec4(1) return vec4(1)
}`)) }`))
if err != nil { if err != nil {

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,13 @@
package main package main
func Vertex(position vec2, texCoord vec2, color vec4) (position vec4, texCoord vec2, color vec4) { func Vertex(dstPos vec2, srcPos vec2, color vec4) (dstPos vec4, srcPos vec2, color vec4) {
projectionMatrix := mat4( projectionMatrix := mat4(
2/ScreenSize.x, 0, 0, 0, 2/ScreenSize.x, 0, 0, 0,
0, 2/ScreenSize.y, 0, 0, 0, 2/ScreenSize.y, 0, 0,
0, 0, 1, 0, 0, 0, 1, 0,
-1, -1, 0, 1, -1, -1, 0, 1,
) )
return projectionMatrix * vec4(position, 0, 1), texCoord, color return projectionMatrix * vec4(dstPos, 0, 1), srcPos, color
} }
var ScreenSize vec2 var ScreenSize vec2

View File

@ -1,17 +1,17 @@
package main package main
func Vertex(position vec2, texCoord vec2, color vec4) (position vec4, texCoord vec2, color vec4) { func Vertex(dstPos vec2, srcPos vec2, color vec4) (dstPos vec4, srcPos vec2, color vec4) {
projectionMatrix := mat4( projectionMatrix := mat4(
2/ScreenSize.x, 0, 0, 0, 2/ScreenSize.x, 0, 0, 0,
0, 2/ScreenSize.y, 0, 0, 0, 2/ScreenSize.y, 0, 0,
0, 0, 1, 0, 0, 0, 1, 0,
-1, -1, 0, 1, -1, -1, 0, 1,
) )
return projectionMatrix * vec4(position, 0, 1), texCoord, color return projectionMatrix * vec4(dstPos, 0, 1), srcPos, color
} }
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
return vec4(position.x, texCoord.y, color.z, 1) return vec4(dstPos.x, srcPos.y, color.z, 1)
} }
var ScreenSize vec2 var ScreenSize vec2

View File

@ -28,7 +28,7 @@ func ShaderProgramFill(r, g, b, a byte) *shaderir.Program {
package main package main
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
return vec4(%0.9f, %0.9f, %0.9f, %0.9f) return vec4(%0.9f, %0.9f, %0.9f, %0.9f)
} }
`, float64(r)/0xff, float64(g)/0xff, float64(b)/0xff, float64(a)/0xff))) `, float64(r)/0xff, float64(g)/0xff, float64(b)/0xff, float64(a)/0xff)))
@ -46,14 +46,14 @@ func ShaderProgramImages(numImages int) *shaderir.Program {
var exprs []string var exprs []string
for i := 0; i < numImages; i++ { for i := 0; i < numImages; i++ {
exprs = append(exprs, fmt.Sprintf("imageSrc%dUnsafeAt(texCoord)", i)) exprs = append(exprs, fmt.Sprintf("imageSrc%dUnsafeAt(srcPos)", i))
} }
ir, err := graphics.CompileShader([]byte(fmt.Sprintf(`//kage:unit pixels ir, err := graphics.CompileShader([]byte(fmt.Sprintf(`//kage:unit pixels
package main package main
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
return %s return %s
} }
`, strings.Join(exprs, " + ")))) `, strings.Join(exprs, " + "))))

View File

@ -32,7 +32,7 @@ func TestShaderFill(t *testing.T) {
package main package main
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
return vec4(1, 0, 0, 1) return vec4(1, 0, 0, 1)
} }
`)) `))
@ -64,7 +64,7 @@ func TestShaderFillWithDrawImage(t *testing.T) {
package main package main
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
return vec4(1, 0, 0, 1) return vec4(1, 0, 0, 1)
} }
`)) `))
@ -101,8 +101,8 @@ func TestShaderWithDrawImageDoesNotWreckTextureUnits(t *testing.T) {
package main package main
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
return imageSrc0At(texCoord) return imageSrc0At(srcPos)
} }
`)) `))
if err != nil { if err != nil {
@ -171,7 +171,7 @@ func TestShaderFillWithDrawTriangles(t *testing.T) {
package main package main
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
return vec4(1, 0, 0, 1) return vec4(1, 0, 0, 1)
} }
`)) `))
@ -252,7 +252,7 @@ func clr(red float) (float, float, float, float) {
return red, 0, 0, 1 return red, 0, 0, 1
} }
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
return vec4(clr(1)) return vec4(clr(1))
} }
`)) `))
@ -283,7 +283,7 @@ package main
var U vec4 var U vec4
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
return U return U
} }
`)) `))
@ -312,7 +312,7 @@ func TestShaderMatrix(t *testing.T) {
package main package main
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
var a, b mat4 var a, b mat4
a[0] = vec4(0.125, 0.0625, 0.0625, 0.0625) a[0] = vec4(0.125, 0.0625, 0.0625, 0.0625)
a[1] = vec4(0.25, 0.25, 0.0625, 0.1875) a[1] = vec4(0.25, 0.25, 0.0625, 0.1875)
@ -352,9 +352,9 @@ func TestShaderSubImage(t *testing.T) {
package main package main
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
r := imageSrc0At(texCoord).r r := imageSrc0At(srcPos).r
g := imageSrc1At(texCoord).g g := imageSrc1At(srcPos).g
return vec4(r, g, 0, 1) return vec4(r, g, 0, 1)
} }
`)) `))
@ -480,8 +480,8 @@ func TestShaderDerivatives(t *testing.T) {
package main package main
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
p := imageSrc0At(texCoord) p := imageSrc0At(srcPos)
return vec4(abs(dfdx(p.r)), abs(dfdy(p.g)), 0, 1) return vec4(abs(dfdx(p.r)), abs(dfdy(p.g)), 0, 1)
} }
`)) `))
@ -542,8 +542,8 @@ func Foo(p vec4) vec4 {
return vec4(abs(dfdx(p.r)), abs(dfdy(p.g)), 0, 1) return vec4(abs(dfdx(p.r)), abs(dfdy(p.g)), 0, 1)
} }
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
p := imageSrc0At(texCoord) p := imageSrc0At(srcPos)
return Foo(p) return Foo(p)
} }
`)) `))
@ -604,7 +604,7 @@ package main
var C [2]float var C [2]float
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
return vec4(C[0], 1, 1, 1) return vec4(C[0], 1, 1, 1)
}`, }`,
Uniforms: map[string]any{ Uniforms: map[string]any{
@ -619,7 +619,7 @@ package main
var C [1]float var C [1]float
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
return vec4(C[0], 1, 1, 1) return vec4(C[0], 1, 1, 1)
}`, }`,
Uniforms: map[string]any{ Uniforms: map[string]any{
@ -634,7 +634,7 @@ package main
var C [2]mat2 var C [2]mat2
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
return vec4(C[0][0][0], 1, 1, 1) return vec4(C[0][0][0], 1, 1, 1)
}`, }`,
Uniforms: map[string]any{ Uniforms: map[string]any{
@ -676,7 +676,7 @@ func TestShaderFuncMod(t *testing.T) {
package main package main
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
r := mod(-0.25, 1.0) r := mod(-0.25, 1.0)
return vec4(r, 0, 0, 1) return vec4(r, 0, 0, 1)
} }
@ -712,8 +712,8 @@ func TestShaderMatrixInitialize(t *testing.T) {
package main package main
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
return mat4(2) * imageSrc0At(texCoord); return mat4(2) * imageSrc0At(srcPos);
} }
`)) `))
if err != nil { if err != nil {
@ -744,7 +744,7 @@ func TestShaderModVectorAndFloat(t *testing.T) {
package main package main
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
r := mod(vec3(0.25, 0.5, 0.75), 0.5) r := mod(vec3(0.25, 0.5, 0.75), 0.5)
return vec4(r, 1) return vec4(r, 1)
} }
@ -781,8 +781,8 @@ func textureAt(uv vec2) vec4 {
return imageSrc0UnsafeAt(uv) return imageSrc0UnsafeAt(uv)
} }
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
return textureAt(texCoord) return textureAt(srcPos)
} }
`)) `))
if err != nil { if err != nil {
@ -815,7 +815,7 @@ func TestShaderAtan2(t *testing.T) {
package main package main
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
y := vec4(1, 1, 1, 1) y := vec4(1, 1, 1, 1)
x := vec4(1, 1, 1, 1) x := vec4(1, 1, 1, 1)
return atan2(y, x) return atan2(y, x)
@ -852,7 +852,7 @@ package main
var Mat2 mat2 var Mat2 mat2
var F float var F float
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
return vec4(F * Mat2 * vec2(1), 1, 1) return vec4(F * Mat2 * vec2(1), 1, 1)
} }
`)) `))
@ -892,7 +892,7 @@ package main
var Mat2 [2]mat2 var Mat2 [2]mat2
var F float var F float
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
return vec4(F * Mat2[0] * Mat2[1] * vec2(1), 1, 1) return vec4(F * Mat2[0] * Mat2[1] * vec2(1), 1, 1)
} }
`)) `))
@ -934,7 +934,7 @@ package main
var Mat3 mat3 var Mat3 mat3
var F float var F float
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
return vec4(F * Mat3 * vec3(1), 1) return vec4(F * Mat3 * vec3(1), 1)
} }
`)) `))
@ -975,7 +975,7 @@ package main
var Mat3 [2]mat3 var Mat3 [2]mat3
var F float var F float
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
return vec4(F * Mat3[0] * Mat3[1] * vec3(1), 1) return vec4(F * Mat3[0] * Mat3[1] * vec3(1), 1)
} }
`)) `))
@ -1019,7 +1019,7 @@ package main
var Mat4 mat4 var Mat4 mat4
var F float var F float
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
return F * Mat4 * vec4(1) return F * Mat4 * vec4(1)
} }
`)) `))
@ -1061,7 +1061,7 @@ package main
var Mat4 [2]mat4 var Mat4 [2]mat4
var F float var F float
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
return F * Mat4[0] * Mat4[1] * vec4(1) return F * Mat4[0] * Mat4[1] * vec4(1)
} }
`)) `))
@ -1103,9 +1103,9 @@ func TestShaderOptionsNegativeBounds(t *testing.T) {
package main package main
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
r := imageSrc0At(texCoord).r r := imageSrc0At(srcPos).r
g := imageSrc1At(texCoord).g g := imageSrc1At(srcPos).g
return vec4(r, g, 0, 1) return vec4(r, g, 0, 1)
} }
`)) `))
@ -1233,7 +1233,7 @@ func TestShaderVectorEqual(t *testing.T) {
package main package main
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
a := vec3(1) a := vec3(1)
b := vec3(1) b := vec3(1)
if a == b { if a == b {
@ -1283,8 +1283,8 @@ func TestShaderDiscard(t *testing.T) {
package main package main
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
p := imageSrc0At(texCoord) p := imageSrc0At(srcPos)
if p.a == 0 { if p.a == 0 {
discard() discard()
} else { } else {
@ -1330,11 +1330,11 @@ func TestShaderDrawRect(t *testing.T) {
package main package main
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
// Adjust texCoord into [0, 1]. // Adjust srcPos into [0, 1].
texCoord -= imageSrc0Origin() srcPos -= imageSrc0Origin()
texCoord /= imageSrc0Size() srcPos /= imageSrc0Size()
if texCoord.x >= 0.5 && texCoord.y >= 0.5 { if srcPos.x >= 0.5 && srcPos.y >= 0.5 {
return vec4(1, 0, 0, 1) return vec4(1, 0, 0, 1)
} }
return vec4(0, 1, 0, 1) return vec4(0, 1, 0, 1)
@ -1378,7 +1378,7 @@ func TestShaderDrawRectColorScale(t *testing.T) {
package main package main
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
return color return color
} }
`)) `))
@ -1415,7 +1415,7 @@ var U1 int
var U2 int var U2 int
var U3 int var U3 int
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
return vec4(float(U0)/255.0, float(U1)/255.0, float(U2)/255.0, float(U3)/255.0) return vec4(float(U0)/255.0, float(U1)/255.0, float(U2)/255.0, float(U3)/255.0)
} }
` `
@ -1426,7 +1426,7 @@ package main
var U [4]int var U [4]int
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
return vec4(float(U[0])/255.0, float(U[1])/255.0, float(U[2])/255.0, float(U[3])/255.0) return vec4(float(U[0])/255.0, float(U[1])/255.0, float(U[2])/255.0, float(U[3])/255.0)
} }
` `
@ -1438,7 +1438,7 @@ package main
var U0 ivec4 var U0 ivec4
var U1 [2]ivec3 var U1 [2]ivec3
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
return vec4(float(U0.x)/255.0, float(U0.y)/255.0, float(U1[0].z)/255.0, float(U1[1].x)/255.0) return vec4(float(U0.x)/255.0, float(U0.y)/255.0, float(U1[0].z)/255.0, float(U1[1].x)/255.0)
} }
` `
@ -1614,7 +1614,7 @@ package main
var U [4]vec3 var U [4]vec3
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
return vec4(U[0].x/255.0, U[1].y/255.0, U[2].z/255.0, U[3].x/255.0) return vec4(U[0].x/255.0, U[1].y/255.0, U[2].z/255.0, U[3].x/255.0)
} }
` `
@ -1685,7 +1685,7 @@ return vec4(b)/255`,
package main package main
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
%s %s
} }
`, tc.source) `, tc.source)
@ -1719,8 +1719,8 @@ func TestShaderTexelAndPixel(t *testing.T) {
package main package main
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
pos := (texCoord - imageSrc0Origin()) / imageSrc0Size() pos := (srcPos - imageSrc0Origin()) / imageSrc0Size()
pos *= vec2(%d, %d) pos *= vec2(%d, %d)
pos /= 255 pos /= 255
return vec4(pos.x, pos.y, 0, 1) return vec4(pos.x, pos.y, 0, 1)
@ -1733,8 +1733,8 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
package main package main
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
pos := texCoord - imageSrc0Origin() pos := srcPos - imageSrc0Origin()
pos /= 255 pos /= 255
return vec4(pos.x, pos.y, 0, 1) return vec4(pos.x, pos.y, 0, 1)
} }
@ -1780,8 +1780,8 @@ func TestShaderDifferentTextureSizes(t *testing.T) {
package main package main
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
return imageSrc0At(texCoord) + imageSrc1At(texCoord) return imageSrc0At(srcPos) + imageSrc1At(srcPos)
} }
`, unit))) `, unit)))
if err != nil { if err != nil {
@ -1831,7 +1831,7 @@ func TestShaderIVec(t *testing.T) {
package main package main
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
pos := ivec2(3, 4) pos := ivec2(3, 4)
return imageSrc0At(vec2(pos) + imageSrc0Origin()) return imageSrc0At(vec2(pos) + imageSrc0Origin())
} }
@ -1862,7 +1862,7 @@ package main
var U vec4 var U vec4
var V [3]float var V [3]float
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
return vec4(0) return vec4(0)
} }
`)) `))
@ -1968,7 +1968,7 @@ package main
var U vec4 var U vec4
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
return U return U
} }
`)) `))
@ -2025,8 +2025,8 @@ func TestShaderDrawRectWithoutSource(t *testing.T) {
package main package main
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
t := texCoord t := srcPos
size := imageSrc0Size() size := imageSrc0Size()
@ -2039,7 +2039,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
return vec4(0, 1, 1, 1) return vec4(0, 1, 1, 1)
} }
// Adjust texCoord into [0, 1]. // Adjust srcPos into [0, 1].
t -= imageSrc0Origin() t -= imageSrc0Origin()
if size != vec2(0) { if size != vec2(0) {
t /= size t /= size
@ -2109,9 +2109,9 @@ func TestShaderMatrixDivFloat(t *testing.T) {
package main package main
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
var x = 2.0 var x = 2.0
return mat4(3) / x * imageSrc0At(texCoord); return mat4(3) / x * imageSrc0At(srcPos);
} }
`)) `))
if err != nil { if err != nil {
@ -2161,8 +2161,8 @@ func TestShaderDifferentSourceSizes(t *testing.T) {
package main package main
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
return imageSrc0At(texCoord) + imageSrc1At(texCoord) return imageSrc0At(srcPos) + imageSrc1At(srcPos)
} }
`, unit))) `, unit)))
if err != nil { if err != nil {
@ -2272,8 +2272,8 @@ func TestShaderBitwiseOperator(t *testing.T) {
package main package main
func Fragment(position vec4, texCoord vec2, color vec4) vec4 { func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
v := ivec4(imageSrc0At(texCoord) * 0xff) v := ivec4(imageSrc0At(srcPos) * 0xff)
%s %s
return vec4(v) / 0xff; return vec4(v) / 0xff;
} }