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 {
case idx < na:
return fmt.Sprintf("A%d", idx)
case idx < na+nv:
return fmt.Sprintf("V%d", idx-na)
case idx == na+nv:
case idx == na:
return "gl_Position"
case idx < na+nv+1:
return fmt.Sprintf("V%d", idx-na-1)
default:
return fmt.Sprintf("l%d", idx-(na+nv+1))
}

View File

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

View File

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

View File

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