shaderir: Rename Sampler2D -> Texture2D

This commit is contained in:
Hajime Hoshi 2020-05-30 17:48:56 +09:00
parent c0cd7ec59c
commit 1042eb71e0
3 changed files with 13 additions and 9 deletions

View File

@ -190,5 +190,5 @@ const (
Any BuiltinFunc = "any"
All BuiltinFunc = "all"
Not BuiltinFunc = "not"
Texture2D BuiltinFunc = "texture2D"
Texture2DF BuiltinFunc = "texture2D"
)

View File

@ -47,7 +47,7 @@ func (t *Type) serialize() string {
return "mat3"
case Mat4:
return "mat4"
case Sampler2D:
case Texture2D:
return "sampler2D"
case Array:
return fmt.Sprintf("%s[%d]", t.Sub[0].serialize(), t.Length)
@ -67,6 +67,10 @@ func (t *Type) serialize() string {
type BasicType int
// For a texture, a name Texture2D is used instead of Sampler2D. A sampler is a combination of a texture and how to
// get its texel (a fitlter or an address), while a texture is just a 2D byte array. In Ebiten, a sampler in GLSL
// always uses the same filter (nearest) and address (clamp-to-zero), then the name Texture2D is adopted.
const (
None BasicType = iota
Bool
@ -78,7 +82,7 @@ const (
Mat2
Mat3
Mat4
Sampler2D
Texture2D
Array
Struct
)
@ -105,7 +109,7 @@ func (t BasicType) Glsl() string {
return "mat3"
case Mat4:
return "mat4"
case Sampler2D:
case Texture2D:
return "sampler2D"
case Array:
// First-class array is not available on GLSL ES 2.

View File

@ -265,8 +265,8 @@ func ShaderProgramFill(r, g, b, a byte) shaderir.Program {
// Uniform variables's indices and their values are:
//
// 0: the framebuffer size (Vec2)
// 1: the first images (Sampler2D)
// 2n: the n-th image (Sampler2D)
// 1: the first images (Texture2D)
// 2n: the n-th image (Texture2D)
// 2n+1: the n-th image's region (Vec4)
//
// The first image's size and region are represented in attribute variables.
@ -280,7 +280,7 @@ func ShaderProgramImages(imageNum int) shaderir.Program {
p := defaultProgram()
for i := 0; i < imageNum; i++ {
p.Uniforms = append(p.Uniforms, shaderir.Type{Main: shaderir.Sampler2D})
p.Uniforms = append(p.Uniforms, shaderir.Type{Main: shaderir.Texture2D})
if i > 0 {
p.Uniforms = append(p.Uniforms, shaderir.Type{Main: shaderir.Vec4})
}
@ -315,7 +315,7 @@ func ShaderProgramImages(imageNum int) shaderir.Program {
Exprs: []shaderir.Expr{
{
Type: shaderir.BuiltinFuncExpr,
BuiltinFunc: shaderir.Texture2D,
BuiltinFunc: shaderir.Texture2DF,
},
{
Type: shaderir.UniformVariable,
@ -335,7 +335,7 @@ func ShaderProgramImages(imageNum int) shaderir.Program {
Exprs: []shaderir.Expr{
{
Type: shaderir.BuiltinFuncExpr,
BuiltinFunc: shaderir.Texture2D,
BuiltinFunc: shaderir.Texture2DF,
},
{
Type: shaderir.UniformVariable,