mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-02-05 15:34:28 +01:00
Update glsl
This commit is contained in:
parent
577664c1cb
commit
280cc1a732
@ -823,10 +823,12 @@ func (cs *compileState) parseFunc(block *block, d *ast.FuncDecl) (function, bool
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The first out-param is treated as gl_FragColor in GLSL.
|
// The first out-param is treated as gl_FragColor in GLSL.
|
||||||
if outParams[0].typ.Main != shaderir.Vec4 {
|
for i := range outParams {
|
||||||
cs.addError(d.Pos(), "fragment entry point must have at least one returning vec4 value for a color")
|
if outParams[i].typ.Main != shaderir.Vec4 {
|
||||||
|
cs.addError(d.Pos(), "fragment entry point must only have vec4 return values for colors")
|
||||||
return function{}, false
|
return function{}, false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Adjust the number of textures to write to
|
// Adjust the number of textures to write to
|
||||||
cs.ir.ColorsOutCount = len(outParams)
|
cs.ir.ColorsOutCount = len(outParams)
|
||||||
|
|
||||||
|
@ -334,7 +334,8 @@ func (cs *compileState) parseStmt(block *block, fname string, stmt ast.Stmt, inP
|
|||||||
|
|
||||||
case *ast.ReturnStmt:
|
case *ast.ReturnStmt:
|
||||||
if len(stmt.Results) != len(outParams) && len(stmt.Results) != 1 {
|
if len(stmt.Results) != len(outParams) && len(stmt.Results) != 1 {
|
||||||
if !(len(stmt.Results) == 0 && len(outParams) > 0 && outParams[0].name != "") {
|
// Fragment function does not have to return a value due to discard
|
||||||
|
if fname != cs.fragmentEntry && !(len(stmt.Results) == 0 && len(outParams) > 0 && outParams[0].name != "") {
|
||||||
// TODO: Check variable shadowings.
|
// TODO: Check variable shadowings.
|
||||||
// https://go.dev/ref/spec#Return_statements
|
// https://go.dev/ref/spec#Return_statements
|
||||||
cs.addError(stmt.Pos(), fmt.Sprintf("the number of returning variables must be %d but %d", len(outParams), len(stmt.Results)))
|
cs.addError(stmt.Pos(), fmt.Sprintf("the number of returning variables must be %d but %d", len(outParams), len(stmt.Results)))
|
||||||
|
@ -603,7 +603,7 @@ func (c *compileContext) block(p *shaderir.Program, topBlock, block *shaderir.Bl
|
|||||||
}
|
}
|
||||||
case shaderir.Discard:
|
case shaderir.Discard:
|
||||||
// 'discard' is invoked only in the fragment shader entry point.
|
// 'discard' is invoked only in the fragment shader entry point.
|
||||||
lines = append(lines, idt+"discard;", idt+"return vec4(0.0);")
|
lines = append(lines, idt+"discard;") //, idt+"return vec4(0.0);")
|
||||||
default:
|
default:
|
||||||
lines = append(lines, fmt.Sprintf("%s?(unexpected stmt: %d)", idt, s.Type))
|
lines = append(lines, fmt.Sprintf("%s?(unexpected stmt: %d)", idt, s.Type))
|
||||||
}
|
}
|
||||||
@ -651,7 +651,7 @@ func adjustProgram(p *shaderir.Program) *shaderir.Program {
|
|||||||
Main: shaderir.Vec4,
|
Main: shaderir.Vec4,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newP.FragmentFunc.Block.LocalVarIndexOffset += (p.ColorsOutCount-1)
|
newP.FragmentFunc.Block.LocalVarIndexOffset += (p.ColorsOutCount - 1)
|
||||||
|
|
||||||
newP.Funcs = append(newP.Funcs, shaderir.Func{
|
newP.Funcs = append(newP.Funcs, shaderir.Func{
|
||||||
Index: funcIdx,
|
Index: funcIdx,
|
||||||
|
Loading…
Reference in New Issue
Block a user