shaderir: Change the param order

This commit is contained in:
Hajime Hoshi 2020-06-03 00:46:52 +09:00
parent 3118657fff
commit fa5b2ed730
4 changed files with 15 additions and 15 deletions

View File

@ -249,10 +249,10 @@ func (p *Program) glslBlock(b *Block, level int, localVarIndex int) []string {
switch { switch {
case idx < na: case idx < na:
return fmt.Sprintf("A%d", idx) return fmt.Sprintf("A%d", idx)
case idx < na+nv: case idx == na:
return fmt.Sprintf("V%d", idx-na)
case idx == na+nv:
return "gl_Position" return "gl_Position"
case idx < na+nv+1:
return fmt.Sprintf("V%d", idx-na-1)
default: default:
return fmt.Sprintf("l%d", idx-(na+nv+1)) return fmt.Sprintf("l%d", idx-(na+nv+1))
} }

View File

@ -646,15 +646,15 @@ varying vec3 V0;`,
Block: block( Block: block(
nil, nil,
assignStmt( assignStmt(
localVariableExpr(5), localVariableExpr(3),
localVariableExpr(0), localVariableExpr(0),
), ),
assignStmt( assignStmt(
localVariableExpr(3), localVariableExpr(4),
localVariableExpr(1), localVariableExpr(1),
), ),
assignStmt( assignStmt(
localVariableExpr(4), localVariableExpr(5),
localVariableExpr(2), localVariableExpr(2),
), ),
), ),
@ -695,15 +695,15 @@ varying vec2 V1;`,
Block: block( Block: block(
nil, nil,
assignStmt( assignStmt(
localVariableExpr(5), localVariableExpr(3),
localVariableExpr(0), localVariableExpr(0),
), ),
assignStmt( assignStmt(
localVariableExpr(3), localVariableExpr(4),
localVariableExpr(1), localVariableExpr(1),
), ),
assignStmt( assignStmt(
localVariableExpr(4), localVariableExpr(5),
localVariableExpr(2), localVariableExpr(2),
), ),
), ),

View File

@ -37,10 +37,10 @@ type Func struct {
} }
// VertexFunc takes pseudo params, and the number if len(attributes) + len(varyings) + 1. // VertexFunc takes pseudo params, and the number if len(attributes) + len(varyings) + 1.
// If 0 <= index < len(attributes), the params are in-params and treated as attribute variables. // If 0 <= index < len(attributes), the params are in-params and represent attribute variables.
// If len(attributes) <= index < len(attributes) + len(varyings), the params are out-params and treated as varying // If index == len(attributes), the param is an out-param and repesents the position in vec4 (gl_Position in GLSL)
// variables. // If len(attributes) + 1 <= index < len(attributes) + len(varyings) + 1, the params are out-params and represent
// The last param represents the position in vec4 (gl_Position in GLSL). // varying variables.
type VertexFunc struct { type VertexFunc struct {
Block Block Block Block
} }

View File

@ -159,7 +159,7 @@ var (
Exprs: []shaderir.Expr{ Exprs: []shaderir.Expr{
{ {
Type: shaderir.LocalVariable, Type: shaderir.LocalVariable,
Index: 4, // the varying variable Index: 5, // the varying variable
}, },
{ {
Type: shaderir.LocalVariable, Type: shaderir.LocalVariable,
@ -172,7 +172,7 @@ var (
Exprs: []shaderir.Expr{ Exprs: []shaderir.Expr{
{ {
Type: shaderir.LocalVariable, Type: shaderir.LocalVariable,
Index: 5, // gl_Position in GLSL Index: 4, // gl_Position in GLSL
}, },
{ {
Type: shaderir.Binary, Type: shaderir.Binary,