mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
shaderir: Add more tests
This commit is contained in:
parent
3d7c102472
commit
c75a35fd64
@ -99,8 +99,25 @@ func (p *Program) glslFunc(f *Func) []string {
|
||||
argsstr = strings.Join(args, ", ")
|
||||
}
|
||||
|
||||
return []string{
|
||||
fmt.Sprintf(`void %s(%s) {`, f.Name, argsstr),
|
||||
`}`,
|
||||
var lines []string
|
||||
lines = append(lines, fmt.Sprintf("void %s(%s) {", f.Name, argsstr))
|
||||
lines = append(lines, p.glslBlock(&f.Block, f, 0)...)
|
||||
lines = append(lines, "}")
|
||||
|
||||
return lines
|
||||
}
|
||||
|
||||
func (p *Program) glslBlock(b *Block, f *Func, level int) []string {
|
||||
idt := strings.Repeat("\t", level+1)
|
||||
|
||||
var lines []string
|
||||
var idx int
|
||||
if level == 0 {
|
||||
idx = len(f.InParams) + len(f.InOutParams) + len(f.OutParams)
|
||||
}
|
||||
for _, t := range b.LocalVars {
|
||||
lines = append(lines, fmt.Sprintf("%s%s;", idt, p.glslVarDecl(&t, fmt.Sprintf("l%d", idx))))
|
||||
idx++
|
||||
}
|
||||
return lines
|
||||
}
|
||||
|
@ -122,6 +122,35 @@ varying vec3 V0;`,
|
||||
},
|
||||
},
|
||||
Glsl: `void F0(in float l0, in vec2 l1, in vec4 l2, inout mat2 l3, out mat4 l4) {
|
||||
}`,
|
||||
},
|
||||
{
|
||||
Name: "FuncLocals",
|
||||
Program: Program{
|
||||
Funcs: []Func{
|
||||
{
|
||||
Name: "F0",
|
||||
InParams: []Type{
|
||||
{Main: Float},
|
||||
},
|
||||
InOutParams: []Type{
|
||||
{Main: Float},
|
||||
},
|
||||
OutParams: []Type{
|
||||
{Main: Float},
|
||||
},
|
||||
Block: Block{
|
||||
LocalVars: []Type{
|
||||
{Main: Mat4},
|
||||
{Main: Mat4},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Glsl: `void F0(in float l0, inout float l1, out float l2) {
|
||||
mat4 l3;
|
||||
mat4 l4;
|
||||
}`,
|
||||
},
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user