shaderir: Add bool/int/float conversion

Updates #1289
This commit is contained in:
Hajime Hoshi 2020-08-11 23:04:49 +09:00
parent 8bc1c8bbd8
commit f71346da6c
2 changed files with 13 additions and 1 deletions

View File

@ -82,6 +82,12 @@ func basicTypeString(t shaderir.BasicType, packed bool) string {
func builtinFuncString(f shaderir.BuiltinFunc) string {
switch f {
case shaderir.BoolF:
return "static_cast<bool>"
case shaderir.IntF:
return "static_cast<int>"
case shaderir.FloatF:
return "static_cast<float>"
case shaderir.Vec2F:
return "float2"
case shaderir.Vec3F:

View File

@ -198,6 +198,9 @@ func OpFromToken(t token.Token) (Op, bool) {
type BuiltinFunc string
const (
BoolF BuiltinFunc = "bool"
IntF BuiltinFunc = "int"
FloatF BuiltinFunc = "float"
Vec2F BuiltinFunc = "vec2"
Vec3F BuiltinFunc = "vec3"
Vec4F BuiltinFunc = "vec4"
@ -247,7 +250,10 @@ const (
func ParseBuiltinFunc(str string) (BuiltinFunc, bool) {
switch BuiltinFunc(str) {
case Vec2F,
case BoolF,
IntF,
FloatF,
Vec2F,
Vec3F,
Vec4F,
Mat2F,