mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-12 12:08:58 +01:00
shaderir: Remove Ident
This commit is contained in:
parent
dbbe4ee09c
commit
094d845edd
@ -166,7 +166,7 @@ func (p *Program) glslFunc(f *Func) []string {
|
||||
}
|
||||
|
||||
var lines []string
|
||||
lines = append(lines, fmt.Sprintf("%s %s(%s) {", p.glslType(&f.Return), f.Name, argsstr))
|
||||
lines = append(lines, fmt.Sprintf("%s F%d(%s) {", p.glslType(&f.Return), f.Index, argsstr))
|
||||
lines = append(lines, p.glslBlock(&f.Block, 0, idx)...)
|
||||
lines = append(lines, "}")
|
||||
|
||||
@ -230,12 +230,12 @@ func (p *Program) glslBlock(b *Block, level int, localVarIndex int) []string {
|
||||
case BuiltinFuncExpr:
|
||||
return string(e.BuiltinFunc)
|
||||
case SwizzlingExpr:
|
||||
if !isValidSwizzling(e.Ident) {
|
||||
return fmt.Sprintf("?(unexpected swizzling: %s)", e.Ident)
|
||||
if !isValidSwizzling(e.Swizzling) {
|
||||
return fmt.Sprintf("?(unexpected swizzling: %s)", e.Swizzling)
|
||||
}
|
||||
return e.Ident
|
||||
case Ident:
|
||||
return e.Ident
|
||||
return e.Swizzling
|
||||
case FunctionExpr:
|
||||
return fmt.Sprintf("F%d", e.Index)
|
||||
case Unary:
|
||||
var op string
|
||||
switch e.Op {
|
||||
|
@ -100,15 +100,15 @@ func builtinFuncExpr(f BuiltinFunc) Expr {
|
||||
|
||||
func swizzlingExpr(swizzling string) Expr {
|
||||
return Expr{
|
||||
Type: SwizzlingExpr,
|
||||
Ident: swizzling,
|
||||
Type: SwizzlingExpr,
|
||||
Swizzling: swizzling,
|
||||
}
|
||||
}
|
||||
|
||||
func identExpr(ident string) Expr {
|
||||
func functionExpr(index int) Expr {
|
||||
return Expr{
|
||||
Type: Ident,
|
||||
Ident: ident,
|
||||
Type: FunctionExpr,
|
||||
Index: index,
|
||||
}
|
||||
}
|
||||
|
||||
@ -200,7 +200,7 @@ varying vec3 V0;`,
|
||||
Program: Program{
|
||||
Funcs: []Func{
|
||||
{
|
||||
Name: "F0",
|
||||
Index: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -212,7 +212,7 @@ varying vec3 V0;`,
|
||||
Program: Program{
|
||||
Funcs: []Func{
|
||||
{
|
||||
Name: "F0",
|
||||
Index: 0,
|
||||
InParams: []Type{
|
||||
{Main: Float},
|
||||
{Main: Vec2},
|
||||
@ -235,7 +235,7 @@ varying vec3 V0;`,
|
||||
Program: Program{
|
||||
Funcs: []Func{
|
||||
{
|
||||
Name: "F0",
|
||||
Index: 0,
|
||||
InParams: []Type{
|
||||
{Main: Float},
|
||||
},
|
||||
@ -258,7 +258,7 @@ varying vec3 V0;`,
|
||||
Program: Program{
|
||||
Funcs: []Func{
|
||||
{
|
||||
Name: "F0",
|
||||
Index: 0,
|
||||
InParams: []Type{
|
||||
{Main: Float},
|
||||
},
|
||||
@ -285,7 +285,7 @@ varying vec3 V0;`,
|
||||
Program: Program{
|
||||
Funcs: []Func{
|
||||
{
|
||||
Name: "F0",
|
||||
Index: 0,
|
||||
InParams: []Type{
|
||||
{Main: Float},
|
||||
},
|
||||
@ -326,7 +326,7 @@ varying vec3 V0;`,
|
||||
Program: Program{
|
||||
Funcs: []Func{
|
||||
{
|
||||
Name: "F0",
|
||||
Index: 0,
|
||||
InParams: []Type{
|
||||
{Main: Float},
|
||||
{Main: Float},
|
||||
@ -357,7 +357,7 @@ varying vec3 V0;`,
|
||||
Program: Program{
|
||||
Funcs: []Func{
|
||||
{
|
||||
Name: "F0",
|
||||
Index: 0,
|
||||
InParams: []Type{
|
||||
{Main: Bool},
|
||||
{Main: Float},
|
||||
@ -389,7 +389,7 @@ varying vec3 V0;`,
|
||||
Program: Program{
|
||||
Funcs: []Func{
|
||||
{
|
||||
Name: "F0",
|
||||
Index: 0,
|
||||
InParams: []Type{
|
||||
{Main: Float},
|
||||
{Main: Float},
|
||||
@ -401,13 +401,13 @@ varying vec3 V0;`,
|
||||
nil,
|
||||
exprStmt(
|
||||
callExpr(
|
||||
identExpr("F1"),
|
||||
functionExpr(1),
|
||||
),
|
||||
),
|
||||
assignStmt(
|
||||
varNameExpr(Local, 2),
|
||||
callExpr(
|
||||
identExpr("F2"),
|
||||
functionExpr(2),
|
||||
varNameExpr(Local, 0),
|
||||
varNameExpr(Local, 1),
|
||||
),
|
||||
@ -426,7 +426,7 @@ varying vec3 V0;`,
|
||||
Program: Program{
|
||||
Funcs: []Func{
|
||||
{
|
||||
Name: "F0",
|
||||
Index: 0,
|
||||
InParams: []Type{
|
||||
{Main: Float},
|
||||
{Main: Float},
|
||||
@ -457,7 +457,7 @@ varying vec3 V0;`,
|
||||
Program: Program{
|
||||
Funcs: []Func{
|
||||
{
|
||||
Name: "F0",
|
||||
Index: 0,
|
||||
InParams: []Type{
|
||||
{Main: Vec4},
|
||||
},
|
||||
@ -486,7 +486,7 @@ varying vec3 V0;`,
|
||||
Program: Program{
|
||||
Funcs: []Func{
|
||||
{
|
||||
Name: "F0",
|
||||
Index: 0,
|
||||
InParams: []Type{
|
||||
{Main: Float},
|
||||
{Main: Float},
|
||||
@ -534,7 +534,7 @@ varying vec3 V0;`,
|
||||
Program: Program{
|
||||
Funcs: []Func{
|
||||
{
|
||||
Name: "F0",
|
||||
Index: 0,
|
||||
InParams: []Type{
|
||||
{Main: Float},
|
||||
{Main: Float},
|
||||
|
@ -27,10 +27,8 @@ type Program struct {
|
||||
structTypes []Type
|
||||
}
|
||||
|
||||
// TODO: How to avoid the name with existing functions?
|
||||
|
||||
type Func struct {
|
||||
Name string
|
||||
Index int
|
||||
InParams []Type
|
||||
InOutParams []Type
|
||||
OutParams []Type
|
||||
@ -89,7 +87,8 @@ type Expr struct {
|
||||
Int int32
|
||||
Float float32
|
||||
BuiltinFunc BuiltinFunc
|
||||
Ident string
|
||||
Swizzling string
|
||||
Index int
|
||||
Op Op
|
||||
}
|
||||
|
||||
@ -101,7 +100,7 @@ const (
|
||||
VarName
|
||||
BuiltinFuncExpr
|
||||
SwizzlingExpr
|
||||
Ident
|
||||
FunctionExpr
|
||||
Unary
|
||||
Binary
|
||||
Selection
|
||||
|
Loading…
Reference in New Issue
Block a user