mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-13 22:47:26 +01:00
internal/shader: bug fix: spaces around a compiler directive should be allowed
Closes #2771
This commit is contained in:
parent
a3ff5f283b
commit
0e27a8a30b
@ -222,7 +222,9 @@ func ParseCompilerDirectives(src []byte) (shaderir.Unit, error) {
|
|||||||
// TODO: Change the unit to pixels in v3 (#2645).
|
// TODO: Change the unit to pixels in v3 (#2645).
|
||||||
unit := shaderir.Texels
|
unit := shaderir.Texels
|
||||||
|
|
||||||
reUnit := regexp.MustCompile(`^//kage:unit\s+(.+)$`)
|
// Go's whitespace is U+0020 (SP), U+0009 (\t), U+000d (\r), and U+000A (\n).
|
||||||
|
// See https://go.dev/ref/spec#Tokens
|
||||||
|
reUnit := regexp.MustCompile(`^[ \t\r\n]*//kage:unit\s+([^ \t\r\n]+)[ \t\r\n]*$`)
|
||||||
var unitParsed bool
|
var unitParsed bool
|
||||||
|
|
||||||
buf := bytes.NewBuffer(src)
|
buf := bytes.NewBuffer(src)
|
||||||
|
@ -3311,6 +3311,16 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
}`,
|
}`,
|
||||||
err: true,
|
err: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
src: "\t " + `//kage:unit pixels` + " \t\r" + `
|
||||||
|
package main
|
||||||
|
|
||||||
|
func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
||||||
|
return position
|
||||||
|
}`,
|
||||||
|
unit: shaderir.Pixels,
|
||||||
|
err: false,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for _, c := range cases {
|
for _, c := range cases {
|
||||||
ir, err := compileToIR([]byte(c.src))
|
ir, err := compileToIR([]byte(c.src))
|
||||||
|
Loading…
Reference in New Issue
Block a user