shaderir: Add (*Type).serialize again

This commit is contained in:
Hajime Hoshi 2020-06-20 21:08:08 +09:00
parent 255da0367f
commit 28948a9976
2 changed files with 6 additions and 2 deletions

View File

@ -60,7 +60,7 @@ func (p *Program) structName(t *Type) string {
if t.Main != Struct { if t.Main != Struct {
panic("shaderir: the given type at structName must be a struct") panic("shaderir: the given type at structName must be a struct")
} }
s := t.String() s := t.serialize()
if n, ok := p.structNames[s]; ok { if n, ok := p.structNames[s]; ok {
return n return n
} }

View File

@ -66,7 +66,7 @@ func (t *Type) String() string {
case Mat4: case Mat4:
return "mat4" return "mat4"
case Texture2D: case Texture2D:
return "sampler2D" return "texture2D"
case Array: case Array:
return fmt.Sprintf("%s[%d]", t.Sub[0].String(), t.Length) return fmt.Sprintf("%s[%d]", t.Sub[0].String(), t.Length)
case Struct: case Struct:
@ -83,6 +83,10 @@ func (t *Type) String() string {
} }
} }
func (t *Type) serialize() string {
return t.String()
}
type BasicType int 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 // For a texture, a name Texture2D is used instead of Sampler2D. A sampler is a combination of a texture and how to