mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
internal/shader: use plural forms for Kage compiler directives
This change renames ``` //kage:unit texel //kage:unit pixel ``` to ``` //kage:unit texels //kage:unit pixels ``` . Closes #2717
This commit is contained in:
parent
a0ffd8dd25
commit
63df6168d9
@ -14,7 +14,7 @@
|
||||
|
||||
//go:build ignore
|
||||
|
||||
//kage:unit pixel
|
||||
//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
//go:build ignore
|
||||
|
||||
//kage:unit pixel
|
||||
//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
//go:build ignore
|
||||
|
||||
//kage:unit pixel
|
||||
//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
//go:build ignore
|
||||
|
||||
//kage:unit pixel
|
||||
//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
//go:build ignore
|
||||
|
||||
//kage:unit pixel
|
||||
//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
//go:build ignore
|
||||
|
||||
//kage:unit pixel
|
||||
//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
//go:build ignore
|
||||
|
||||
//kage:unit pixel
|
||||
//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
|
@ -24,7 +24,7 @@ import (
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/ui"
|
||||
)
|
||||
|
||||
const screenShaderSrc = `//kage:unit pixel
|
||||
const screenShaderSrc = `//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
|
4
image.go
4
image.go
@ -740,7 +740,7 @@ var _ [len(DrawRectShaderOptions{}.Images)]struct{} = [graphics.ShaderImageCount
|
||||
//
|
||||
// In a shader, texCoord 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 the unit is pixels by a compiler directive `//kage:unit pixels`, texCoord values are valid.
|
||||
// If the unit is pixels by a compiler directive `//kage:unit pixelss`, texCoord values are valid.
|
||||
// If the unit is texels (default), texCoord 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.
|
||||
// This behavior is preserved for backward compatibility. It is recommended to use the pixel-unit mode to avoid confusion.
|
||||
@ -787,7 +787,7 @@ func (i *Image) DrawRectShader(width, height int, shader *Shader, options *DrawR
|
||||
b := img.Bounds()
|
||||
sx, sy = img.adjustPosition(b.Min.X, b.Min.Y)
|
||||
sr = img.adjustedRegion()
|
||||
} else if shader.unit == shaderir.Pixel {
|
||||
} else if shader.unit == shaderir.Pixels {
|
||||
// Give the source size as pixels only when the unit is pixels so that users can get the source size via imageSrcRegionOnTexture (#2166).
|
||||
// With the texel mode, the imageSrcRegionOnTexture values should be in texels so the source position in pixels would not match.
|
||||
sr = graphicsdriver.Region{
|
||||
|
@ -412,7 +412,7 @@ func (i *Image) drawTriangles(srcs [graphics.ShaderImageCount]*Image, vertices [
|
||||
vertices[i+2] += oxf
|
||||
vertices[i+3] += oyf
|
||||
}
|
||||
if shader.unit() == shaderir.Texel {
|
||||
if shader.unit() == shaderir.Texels {
|
||||
sw, sh := srcs[0].backend.restorable.InternalSize()
|
||||
swf, shf := float32(sw), float32(sh)
|
||||
for i := 0; i < n; i += graphics.VertexFloatCount {
|
||||
|
@ -52,7 +52,7 @@ var (
|
||||
shadersM sync.Mutex
|
||||
)
|
||||
|
||||
var tmpl = template.Must(template.New("tmpl").Parse(`//kage:unit pixel
|
||||
var tmpl = template.Must(template.New("tmpl").Parse(`//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
|
@ -79,9 +79,9 @@ func imageSrcRegionOnTexture() (vec2, vec2) {
|
||||
if i >= 1 {
|
||||
// Convert the position in texture0's positions to the target texture positions.
|
||||
switch unit {
|
||||
case shaderir.Pixel:
|
||||
case shaderir.Pixels:
|
||||
pos = fmt.Sprintf("pos + __textureSourceOffsets[%d]", i-1)
|
||||
case shaderir.Texel:
|
||||
case shaderir.Texels:
|
||||
pos = fmt.Sprintf("(pos * __textureSizes[0] + __textureSourceOffsets[%d]) / __textureSizes[%d]", i-1, i)
|
||||
default:
|
||||
return "", fmt.Errorf("graphics: unexpected unit: %d", unit)
|
||||
|
@ -694,7 +694,7 @@ func (q *commandQueue) prependPreservedUniforms(uniforms []uint32, shader *Shade
|
||||
uniforms[9] = math.Float32bits(float32(h))
|
||||
}
|
||||
|
||||
if shader.unit() == shaderir.Texel {
|
||||
if shader.unit() == shaderir.Texels {
|
||||
dstRegion.X /= float32(dw)
|
||||
dstRegion.Y /= float32(dh)
|
||||
dstRegion.Width /= float32(dw)
|
||||
@ -707,7 +707,7 @@ func (q *commandQueue) prependPreservedUniforms(uniforms []uint32, shader *Shade
|
||||
uniforms[12] = math.Float32bits(dstRegion.Width)
|
||||
uniforms[13] = math.Float32bits(dstRegion.Height)
|
||||
|
||||
if shader.unit() == shaderir.Texel && srcs[0] != nil {
|
||||
if shader.unit() == shaderir.Texels && srcs[0] != nil {
|
||||
w, h := srcs[0].InternalSize()
|
||||
srcRegion.X /= float32(w)
|
||||
srcRegion.Y /= float32(h)
|
||||
|
@ -80,7 +80,7 @@ func init() {
|
||||
return nil
|
||||
})
|
||||
wg.Go(func() error {
|
||||
ir, err := graphics.CompileShader([]byte(`//kage:unit pixel
|
||||
ir, err := graphics.CompileShader([]byte(`//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
|
@ -220,7 +220,7 @@ func Compile(src []byte, vertexEntry, fragmentEntry string, textureCount int) (*
|
||||
|
||||
func ParseCompilerDirectives(src []byte) (shaderir.Unit, error) {
|
||||
// TODO: Change the unit to pixels in v3 (#2645).
|
||||
unit := shaderir.Texel
|
||||
unit := shaderir.Texels
|
||||
|
||||
reUnit := regexp.MustCompile(`^//kage:unit\s+(.+)$`)
|
||||
var unitParsed bool
|
||||
@ -236,10 +236,10 @@ func ParseCompilerDirectives(src []byte) (shaderir.Unit, error) {
|
||||
return 0, fmt.Errorf("shader: at most one //kage:unit can exist in a shader")
|
||||
}
|
||||
switch m[1] {
|
||||
case "pixel":
|
||||
unit = shaderir.Pixel
|
||||
case "texel":
|
||||
unit = shaderir.Texel
|
||||
case "pixels":
|
||||
unit = shaderir.Pixels
|
||||
case "texels":
|
||||
unit = shaderir.Texels
|
||||
default:
|
||||
return 0, fmt.Errorf("shader: invalid value for //kage:unit: %s", m[1])
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ func hlslNormalize(str string) string {
|
||||
}
|
||||
|
||||
func metalNormalize(str string) string {
|
||||
prelude := msl.Prelude(shaderir.Texel)
|
||||
prelude := msl.Prelude(shaderir.Texels)
|
||||
if strings.HasPrefix(str, prelude) {
|
||||
str = str[len(prelude):]
|
||||
}
|
||||
|
@ -3137,29 +3137,29 @@ func TestCompilerDirective(t *testing.T) {
|
||||
func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
||||
return position
|
||||
}`,
|
||||
unit: shaderir.Texel,
|
||||
unit: shaderir.Texels,
|
||||
err: false,
|
||||
},
|
||||
{
|
||||
src: `//kage:unit texel
|
||||
src: `//kage:unit texels
|
||||
|
||||
package main
|
||||
|
||||
func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
||||
return position
|
||||
}`,
|
||||
unit: shaderir.Texel,
|
||||
unit: shaderir.Texels,
|
||||
err: false,
|
||||
},
|
||||
{
|
||||
src: `//kage:unit pixel
|
||||
src: `//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
||||
return position
|
||||
}`,
|
||||
unit: shaderir.Pixel,
|
||||
unit: shaderir.Pixels,
|
||||
err: false,
|
||||
},
|
||||
{
|
||||
@ -3173,8 +3173,8 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
||||
err: true,
|
||||
},
|
||||
{
|
||||
src: `//kage:unit pixel
|
||||
//kage:unit pixel
|
||||
src: `//kage:unit pixels
|
||||
//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
@ -3184,8 +3184,8 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
||||
err: true,
|
||||
},
|
||||
{
|
||||
src: `//kage:unit pixel
|
||||
//kage:unit texel
|
||||
src: `//kage:unit pixels
|
||||
//kage:unit texels
|
||||
|
||||
package main
|
||||
|
||||
|
@ -122,7 +122,7 @@ func (c *compileContext) builtinFuncString(f shaderir.BuiltinFunc) string {
|
||||
case shaderir.Dfdy:
|
||||
return "dFdy"
|
||||
case shaderir.TexelAt:
|
||||
if c.unit == shaderir.Pixel {
|
||||
if c.unit == shaderir.Pixels {
|
||||
return "texelFetch"
|
||||
}
|
||||
return "texture"
|
||||
|
@ -121,7 +121,7 @@ func Compile(p *shaderir.Program) (vertexShader, pixelShader string, offsets []i
|
||||
for i := 0; i < p.TextureCount; i++ {
|
||||
lines = append(lines, fmt.Sprintf("Texture2D T%[1]d : register(t%[1]d);", i))
|
||||
}
|
||||
if c.unit == shaderir.Texel {
|
||||
if c.unit == shaderir.Texels {
|
||||
lines = append(lines, "SamplerState samp : register(s0);")
|
||||
}
|
||||
}
|
||||
@ -471,9 +471,9 @@ func (c *compileContext) block(p *shaderir.Program, topBlock, block *shaderir.Bl
|
||||
}
|
||||
case shaderir.TexelAt:
|
||||
switch c.unit {
|
||||
case shaderir.Pixel:
|
||||
case shaderir.Pixels:
|
||||
return fmt.Sprintf("%s.Load(int3(%s, 0))", args[0], strings.Join(args[1:], ", "))
|
||||
case shaderir.Texel:
|
||||
case shaderir.Texels:
|
||||
return fmt.Sprintf("%s.Sample(samp, %s)", args[0], strings.Join(args[1:], ", "))
|
||||
default:
|
||||
panic(fmt.Sprintf("hlsl: unexpected unit: %d", p.Unit))
|
||||
|
@ -181,7 +181,7 @@ func TestOutput(t *testing.T) {
|
||||
{
|
||||
Name: "Empty",
|
||||
Program: shaderir.Program{
|
||||
Unit: shaderir.Pixel,
|
||||
Unit: shaderir.Pixels,
|
||||
},
|
||||
GlslVS: glsl.VertexPrelude(glsl.GLSLVersionDefault),
|
||||
GlslFS: glsl.FragmentPrelude(glsl.GLSLVersionDefault),
|
||||
@ -189,7 +189,7 @@ func TestOutput(t *testing.T) {
|
||||
{
|
||||
Name: "Uniform",
|
||||
Program: shaderir.Program{
|
||||
Unit: shaderir.Pixel,
|
||||
Unit: shaderir.Pixels,
|
||||
Uniforms: []shaderir.Type{
|
||||
{Main: shaderir.Float},
|
||||
},
|
||||
@ -202,7 +202,7 @@ uniform float U0;`,
|
||||
{
|
||||
Name: "UniformStruct",
|
||||
Program: shaderir.Program{
|
||||
Unit: shaderir.Pixel,
|
||||
Unit: shaderir.Pixels,
|
||||
Uniforms: []shaderir.Type{
|
||||
{
|
||||
Main: shaderir.Struct,
|
||||
@ -228,7 +228,7 @@ uniform S0 U0;`,
|
||||
{
|
||||
Name: "Vars",
|
||||
Program: shaderir.Program{
|
||||
Unit: shaderir.Pixel,
|
||||
Unit: shaderir.Pixels,
|
||||
Uniforms: []shaderir.Type{
|
||||
{Main: shaderir.Float},
|
||||
},
|
||||
@ -250,7 +250,7 @@ in vec3 V0;`,
|
||||
{
|
||||
Name: "Func",
|
||||
Program: shaderir.Program{
|
||||
Unit: shaderir.Pixel,
|
||||
Unit: shaderir.Pixels,
|
||||
Funcs: []shaderir.Func{
|
||||
{
|
||||
Index: 0,
|
||||
@ -271,7 +271,7 @@ void F0(void) {
|
||||
{
|
||||
Name: "FuncParams",
|
||||
Program: shaderir.Program{
|
||||
Unit: shaderir.Pixel,
|
||||
Unit: shaderir.Pixels,
|
||||
Funcs: []shaderir.Func{
|
||||
{
|
||||
Index: 0,
|
||||
@ -300,7 +300,7 @@ void F0(in float l0, in vec2 l1, in vec4 l2, out mat4 l3) {
|
||||
{
|
||||
Name: "FuncReturn",
|
||||
Program: shaderir.Program{
|
||||
Unit: shaderir.Pixel,
|
||||
Unit: shaderir.Pixels,
|
||||
Funcs: []shaderir.Func{
|
||||
{
|
||||
Index: 0,
|
||||
@ -334,7 +334,7 @@ float F0(in float l0) {
|
||||
{
|
||||
Name: "FuncLocals",
|
||||
Program: shaderir.Program{
|
||||
Unit: shaderir.Pixel,
|
||||
Unit: shaderir.Pixels,
|
||||
Funcs: []shaderir.Func{
|
||||
{
|
||||
Index: 0,
|
||||
@ -369,7 +369,7 @@ void F0(in float l0, out float l1) {
|
||||
{
|
||||
Name: "FuncBlocks",
|
||||
Program: shaderir.Program{
|
||||
Unit: shaderir.Pixel,
|
||||
Unit: shaderir.Pixels,
|
||||
Funcs: []shaderir.Func{
|
||||
{
|
||||
Index: 0,
|
||||
@ -424,7 +424,7 @@ void F0(in float l0, out float l1) {
|
||||
{
|
||||
Name: "Add",
|
||||
Program: shaderir.Program{
|
||||
Unit: shaderir.Pixel,
|
||||
Unit: shaderir.Pixels,
|
||||
Funcs: []shaderir.Func{
|
||||
{
|
||||
Index: 0,
|
||||
@ -466,7 +466,7 @@ void F0(in float l0, in float l1, out float l2) {
|
||||
{
|
||||
Name: "Selection",
|
||||
Program: shaderir.Program{
|
||||
Unit: shaderir.Pixel,
|
||||
Unit: shaderir.Pixels,
|
||||
Funcs: []shaderir.Func{
|
||||
{
|
||||
Index: 0,
|
||||
@ -509,7 +509,7 @@ void F0(in bool l0, in float l1, in float l2, out float l3) {
|
||||
{
|
||||
Name: "Call",
|
||||
Program: shaderir.Program{
|
||||
Unit: shaderir.Pixel,
|
||||
Unit: shaderir.Pixels,
|
||||
Funcs: []shaderir.Func{
|
||||
{
|
||||
Index: 0,
|
||||
@ -558,7 +558,7 @@ void F0(in float l0, in float l1, out vec2 l2) {
|
||||
{
|
||||
Name: "BuiltinFunc",
|
||||
Program: shaderir.Program{
|
||||
Unit: shaderir.Pixel,
|
||||
Unit: shaderir.Pixels,
|
||||
Funcs: []shaderir.Func{
|
||||
{
|
||||
Index: 0,
|
||||
@ -600,7 +600,7 @@ void F0(in float l0, in float l1, out float l2) {
|
||||
{
|
||||
Name: "FieldSelector",
|
||||
Program: shaderir.Program{
|
||||
Unit: shaderir.Pixel,
|
||||
Unit: shaderir.Pixels,
|
||||
Funcs: []shaderir.Func{
|
||||
{
|
||||
Index: 0,
|
||||
@ -640,7 +640,7 @@ void F0(in vec4 l0, out vec2 l1) {
|
||||
{
|
||||
Name: "If",
|
||||
Program: shaderir.Program{
|
||||
Unit: shaderir.Pixel,
|
||||
Unit: shaderir.Pixels,
|
||||
Funcs: []shaderir.Func{
|
||||
{
|
||||
Index: 0,
|
||||
@ -705,7 +705,7 @@ void F0(in float l0, in float l1, out float l2) {
|
||||
{
|
||||
Name: "For",
|
||||
Program: shaderir.Program{
|
||||
Unit: shaderir.Pixel,
|
||||
Unit: shaderir.Pixels,
|
||||
Funcs: []shaderir.Func{
|
||||
{
|
||||
Index: 0,
|
||||
@ -761,7 +761,7 @@ void F0(in float l0, in float l1, out float l2) {
|
||||
{
|
||||
Name: "For2",
|
||||
Program: shaderir.Program{
|
||||
Unit: shaderir.Pixel,
|
||||
Unit: shaderir.Pixels,
|
||||
Funcs: []shaderir.Func{
|
||||
{
|
||||
Index: 0,
|
||||
@ -817,7 +817,7 @@ void F0(in float l0, in float l1, out float l2) {
|
||||
l2 = l4;
|
||||
}
|
||||
}`,
|
||||
Metal: msl.Prelude(shaderir.Pixel) + `
|
||||
Metal: msl.Prelude(shaderir.Pixels) + `
|
||||
|
||||
void F0(float l0, float l1, thread float& l2);
|
||||
|
||||
@ -831,7 +831,7 @@ void F0(float l0, float l1, thread float& l2) {
|
||||
{
|
||||
Name: "For3",
|
||||
Program: shaderir.Program{
|
||||
Unit: shaderir.Pixel,
|
||||
Unit: shaderir.Pixels,
|
||||
Funcs: []shaderir.Func{
|
||||
{
|
||||
Index: 0,
|
||||
@ -914,7 +914,7 @@ void F0(in float l0, in float l1, out float l2) {
|
||||
l2 = l5;
|
||||
}
|
||||
}`,
|
||||
Metal: msl.Prelude(shaderir.Pixel) + `
|
||||
Metal: msl.Prelude(shaderir.Pixels) + `
|
||||
|
||||
void F0(float l0, float l1, thread float& l2);
|
||||
|
||||
@ -932,7 +932,7 @@ void F0(float l0, float l1, thread float& l2) {
|
||||
{
|
||||
Name: "VertexFunc",
|
||||
Program: shaderir.Program{
|
||||
Unit: shaderir.Pixel,
|
||||
Unit: shaderir.Pixels,
|
||||
Uniforms: []shaderir.Type{
|
||||
{Main: shaderir.Float},
|
||||
},
|
||||
@ -985,7 +985,7 @@ in vec2 V1;`,
|
||||
{
|
||||
Name: "FragmentFunc",
|
||||
Program: shaderir.Program{
|
||||
Unit: shaderir.Pixel,
|
||||
Unit: shaderir.Pixels,
|
||||
Uniforms: []shaderir.Type{
|
||||
{Main: shaderir.Float},
|
||||
},
|
||||
|
@ -57,7 +57,7 @@ template<typename T, typename U>
|
||||
T mod(T x, U y) {
|
||||
return x - y * floor(x/y);
|
||||
}`
|
||||
if unit == shaderir.Texel {
|
||||
if unit == shaderir.Texels {
|
||||
str += `
|
||||
|
||||
constexpr sampler texture_sampler{filter::nearest};`
|
||||
@ -396,9 +396,9 @@ func (c *compileContext) block(p *shaderir.Program, topBlock, block *shaderir.Bl
|
||||
}
|
||||
if callee.Type == shaderir.BuiltinFuncExpr && callee.BuiltinFunc == shaderir.TexelAt {
|
||||
switch p.Unit {
|
||||
case shaderir.Texel:
|
||||
case shaderir.Texels:
|
||||
return fmt.Sprintf("%s.sample(texture_sampler, %s)", args[0], strings.Join(args[1:], ", "))
|
||||
case shaderir.Pixel:
|
||||
case shaderir.Pixels:
|
||||
return fmt.Sprintf("%s.read(static_cast<uint2>(%s))", args[0], strings.Join(args[1:], ", "))
|
||||
default:
|
||||
panic(fmt.Sprintf("msl: unexpected unit: %d", p.Unit))
|
||||
|
@ -25,8 +25,8 @@ import (
|
||||
type Unit int
|
||||
|
||||
const (
|
||||
Texel Unit = iota
|
||||
Pixel
|
||||
Texels Unit = iota
|
||||
Pixels
|
||||
)
|
||||
|
||||
type Program struct {
|
||||
|
@ -24,7 +24,7 @@ import (
|
||||
|
||||
// ShaderProgramFill returns a shader source to fill the frambuffer.
|
||||
func ShaderProgramFill(r, g, b, a byte) *shaderir.Program {
|
||||
ir, err := graphics.CompileShader([]byte(fmt.Sprintf(`//kage:unit pixel
|
||||
ir, err := graphics.CompileShader([]byte(fmt.Sprintf(`//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
@ -49,7 +49,7 @@ func ShaderProgramImages(numImages int) *shaderir.Program {
|
||||
exprs = append(exprs, fmt.Sprintf("imageSrc%dUnsafeAt(texCoord)", i))
|
||||
}
|
||||
|
||||
ir, err := graphics.CompileShader([]byte(fmt.Sprintf(`//kage:unit pixel
|
||||
ir, err := graphics.CompileShader([]byte(fmt.Sprintf(`//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
|
@ -28,7 +28,7 @@ func TestShaderFill(t *testing.T) {
|
||||
const w, h = 16, 16
|
||||
|
||||
dst := ebiten.NewImage(w, h)
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixel
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
@ -60,7 +60,7 @@ func TestShaderFillWithDrawImage(t *testing.T) {
|
||||
const w, h = 16, 16
|
||||
|
||||
dst := ebiten.NewImage(w, h)
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixel
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
@ -97,7 +97,7 @@ func TestShaderWithDrawImageDoesNotWreckTextureUnits(t *testing.T) {
|
||||
rect := image.Rectangle{Max: image.Point{X: w, Y: h}}
|
||||
|
||||
dst := ebiten.NewImageWithOptions(rect, &ebiten.NewImageOptions{Unmanaged: true})
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixel
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
@ -167,7 +167,7 @@ func TestShaderFillWithDrawTriangles(t *testing.T) {
|
||||
const w, h = 16, 16
|
||||
|
||||
dst := ebiten.NewImage(w, h)
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixel
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
@ -244,7 +244,7 @@ func TestShaderFunction(t *testing.T) {
|
||||
const w, h = 16, 16
|
||||
|
||||
dst := ebiten.NewImage(w, h)
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixel
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
@ -277,7 +277,7 @@ func TestShaderUninitializedUniformVariables(t *testing.T) {
|
||||
const w, h = 16, 16
|
||||
|
||||
dst := ebiten.NewImage(w, h)
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixel
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
@ -308,7 +308,7 @@ func TestShaderMatrix(t *testing.T) {
|
||||
const w, h = 16, 16
|
||||
|
||||
dst := ebiten.NewImage(w, h)
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixel
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
@ -348,7 +348,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
||||
func TestShaderSubImage(t *testing.T) {
|
||||
const w, h = 16, 16
|
||||
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixel
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
@ -476,7 +476,7 @@ func TestShaderDerivatives(t *testing.T) {
|
||||
|
||||
const w, h = 16, 16
|
||||
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixel
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
@ -533,7 +533,7 @@ func TestShaderDerivatives2(t *testing.T) {
|
||||
|
||||
const w, h = 16, 16
|
||||
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixel
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
@ -598,7 +598,7 @@ func TestShaderUniformFirstElement(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
Name: "float array",
|
||||
Shader: `//kage:unit pixel
|
||||
Shader: `//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
@ -613,7 +613,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
||||
},
|
||||
{
|
||||
Name: "float one-element array",
|
||||
Shader: `//kage:unit pixel
|
||||
Shader: `//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
@ -628,7 +628,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
||||
},
|
||||
{
|
||||
Name: "matrix array",
|
||||
Shader: `//kage:unit pixel
|
||||
Shader: `//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
@ -672,7 +672,7 @@ func TestShaderFuncMod(t *testing.T) {
|
||||
const w, h = 16, 16
|
||||
|
||||
dst := ebiten.NewImage(w, h)
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixel
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
@ -708,7 +708,7 @@ func TestShaderMatrixInitialize(t *testing.T) {
|
||||
src.Fill(color.RGBA{R: 0x10, G: 0x20, B: 0x30, A: 0xff})
|
||||
|
||||
dst := ebiten.NewImage(w, h)
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixel
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
@ -740,7 +740,7 @@ func TestShaderModVectorAndFloat(t *testing.T) {
|
||||
const w, h = 16, 16
|
||||
|
||||
dst := ebiten.NewImage(w, h)
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixel
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
@ -773,7 +773,7 @@ func TestShaderTextureAt(t *testing.T) {
|
||||
src.Fill(color.RGBA{R: 0x10, G: 0x20, B: 0x30, A: 0xff})
|
||||
|
||||
dst := ebiten.NewImage(w, h)
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixel
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
@ -811,7 +811,7 @@ func TestShaderAtan2(t *testing.T) {
|
||||
src.Fill(color.RGBA{R: 0x10, G: 0x20, B: 0x30, A: 0xff})
|
||||
|
||||
dst := ebiten.NewImage(w, h)
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixel
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
@ -845,7 +845,7 @@ func TestShaderUniformMatrix2(t *testing.T) {
|
||||
const w, h = 16, 16
|
||||
|
||||
dst := ebiten.NewImage(w, h)
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixel
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
@ -885,7 +885,7 @@ func TestShaderUniformMatrix2Array(t *testing.T) {
|
||||
const w, h = 16, 16
|
||||
|
||||
dst := ebiten.NewImage(w, h)
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixel
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
@ -927,7 +927,7 @@ func TestShaderUniformMatrix3(t *testing.T) {
|
||||
const w, h = 16, 16
|
||||
|
||||
dst := ebiten.NewImage(w, h)
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixel
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
@ -968,7 +968,7 @@ func TestShaderUniformMatrix3Array(t *testing.T) {
|
||||
const w, h = 16, 16
|
||||
|
||||
dst := ebiten.NewImage(w, h)
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixel
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
@ -1012,7 +1012,7 @@ func TestShaderUniformMatrix4(t *testing.T) {
|
||||
const w, h = 16, 16
|
||||
|
||||
dst := ebiten.NewImage(w, h)
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixel
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
@ -1054,7 +1054,7 @@ func TestShaderUniformMatrix4Array(t *testing.T) {
|
||||
const w, h = 16, 16
|
||||
|
||||
dst := ebiten.NewImage(w, h)
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixel
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
@ -1099,7 +1099,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
||||
func TestShaderOptionsNegativeBounds(t *testing.T) {
|
||||
const w, h = 16, 16
|
||||
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixel
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
@ -1229,7 +1229,7 @@ func TestShaderVectorEqual(t *testing.T) {
|
||||
const w, h = 16, 16
|
||||
|
||||
dst := ebiten.NewImage(w, h)
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixel
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
@ -1279,7 +1279,7 @@ func TestShaderDiscard(t *testing.T) {
|
||||
}
|
||||
src.WritePixels(pix)
|
||||
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixel
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
@ -1326,7 +1326,7 @@ func TestShaderDrawRect(t *testing.T) {
|
||||
dst := ebiten.NewImage(dstW, dstH)
|
||||
src := ebiten.NewImage(srcW, srcH)
|
||||
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixel
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
@ -1375,7 +1375,7 @@ func TestShaderDrawRectColorScale(t *testing.T) {
|
||||
const w, h = 16, 16
|
||||
|
||||
dst := ebiten.NewImage(w, h)
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixel
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
@ -1407,7 +1407,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
||||
}
|
||||
|
||||
func TestShaderUniformInt(t *testing.T) {
|
||||
const ints = `//kage:unit pixel
|
||||
const ints = `//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
@ -1421,7 +1421,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
||||
}
|
||||
`
|
||||
|
||||
const intArray = `//kage:unit pixel
|
||||
const intArray = `//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
@ -1432,7 +1432,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
||||
}
|
||||
`
|
||||
|
||||
const intVec = `//kage:unit pixel
|
||||
const intVec = `//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
@ -1609,7 +1609,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
||||
|
||||
// Issue #2463
|
||||
func TestShaderUniformVec3Array(t *testing.T) {
|
||||
const shader = `//kage:unit pixel
|
||||
const shader = `//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
@ -1682,7 +1682,7 @@ return vec4(b)/255`,
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
shader := fmt.Sprintf(`//kage:unit pixel
|
||||
shader := fmt.Sprintf(`//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
@ -1716,7 +1716,7 @@ func TestShaderTexelAndPixel(t *testing.T) {
|
||||
dstPixel := ebiten.NewImage(dstW, dstH)
|
||||
src := ebiten.NewImage(srcW, srcH)
|
||||
|
||||
shaderTexel, err := ebiten.NewShader([]byte(fmt.Sprintf(`//kage:unit texel
|
||||
shaderTexel, err := ebiten.NewShader([]byte(fmt.Sprintf(`//kage:unit texels
|
||||
|
||||
package main
|
||||
|
||||
@ -1731,7 +1731,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
shaderPixel, err := ebiten.NewShader([]byte(`//kage:unit pixel
|
||||
shaderPixel, err := ebiten.NewShader([]byte(`//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
@ -1776,7 +1776,7 @@ func TestShaderDifferentTextureSizes(t *testing.T) {
|
||||
src0.Fill(color.RGBA{0x10, 0x20, 0x30, 0xff})
|
||||
src1.Fill(color.RGBA{0x30, 0x20, 0x10, 0xff})
|
||||
|
||||
for _, unit := range []string{"texel", "pixel"} {
|
||||
for _, unit := range []string{"texels", "pixels"} {
|
||||
unit := unit
|
||||
t.Run(fmt.Sprintf("unit %s", unit), func(t *testing.T) {
|
||||
shader, err := ebiten.NewShader([]byte(fmt.Sprintf(`//kage:unit %s
|
||||
@ -1830,7 +1830,7 @@ func TestShaderIVec(t *testing.T) {
|
||||
|
||||
// Test that ivec2 can take any float values that can be casted to integers.
|
||||
// This seems the common behavior in shading languages like GLSL, Metal, and HLSL.
|
||||
shader, err := ebiten.NewShader([]byte(`//kage:unit pixel
|
||||
shader, err := ebiten.NewShader([]byte(`//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
@ -1859,7 +1859,7 @@ func TestShaderUniformSizes(t *testing.T) {
|
||||
const w, h = 16, 16
|
||||
|
||||
dst := ebiten.NewImage(w, h)
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixel
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
@ -1978,7 +1978,7 @@ func TestShaderUniformDefaultValue(t *testing.T) {
|
||||
const w, h = 16, 16
|
||||
|
||||
dst := ebiten.NewImage(w, h)
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixel
|
||||
s, err := ebiten.NewShader([]byte(`//kage:unit pixels
|
||||
|
||||
package main
|
||||
|
||||
@ -2036,7 +2036,7 @@ func TestShaderDrawRectWithoutSource(t *testing.T) {
|
||||
|
||||
src := ebiten.NewImage(srcW, srcH)
|
||||
|
||||
for _, unit := range []string{"pixel", "texel"} {
|
||||
for _, unit := range []string{"pixels", "texels"} {
|
||||
s, err := ebiten.NewShader([]byte(fmt.Sprintf(`//kage:unit %s
|
||||
|
||||
package main
|
||||
@ -2094,7 +2094,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
||||
var want color.RGBA
|
||||
if offsetX <= i && i < offsetX+srcW && offsetY <= j && j < offsetY+srcH {
|
||||
var blue byte
|
||||
if !withSrc && unit == "texel" {
|
||||
if !withSrc && unit == "texels" {
|
||||
blue = 0xff
|
||||
}
|
||||
if offsetX+srcW/2 <= i && offsetY+srcH/2 <= j {
|
||||
|
Loading…
Reference in New Issue
Block a user