From e1d0800f19652879f0e83f1b4a9c3f0d492d8f36 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sun, 17 May 2020 02:25:37 +0900 Subject: [PATCH] shaderir: Bug fix: Wrong implementation of isValidSwizzling --- internal/shaderir/glsl.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/shaderir/glsl.go b/internal/shaderir/glsl.go index 1f63da442..0906523e8 100644 --- a/internal/shaderir/glsl.go +++ b/internal/shaderir/glsl.go @@ -37,18 +37,21 @@ func isValidSwizzling(s string) bool { return false } } + return true case strings.IndexByte(rgba, s[0]) >= 0: for _, c := range s { if strings.IndexRune(rgba, c) == -1 { return false } } + return true case strings.IndexByte(strq, s[0]) >= 0: for _, c := range s { if strings.IndexRune(strq, c) == -1 { return false } } + return true } return false } @@ -225,7 +228,7 @@ func (p *Program) glslBlock(b *Block, level int, localVarIndex int) []string { case BuiltinFuncExpr: return string(e.BuiltinFunc) case SwizzlingExpr: - if isValidSwizzling(e.Swizzling) { + if !isValidSwizzling(e.Swizzling) { return fmt.Sprintf("?(unexpected swizzling: %s)", e.Swizzling) } return e.Swizzling