gpu/internal/convertshaders,gpu: represent converted shaders with raw literals

Raw strings with linebreaks are easier to read and produce smaller
diffs.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2021-04-12 12:04:53 +02:00
parent 495c690187
commit fbee13a07d
13 changed files with 7086 additions and 474 deletions
+11 -7
View File
@@ -18,18 +18,22 @@ type GLSLValidator struct {
func NewGLSLValidator() *GLSLValidator { return &GLSLValidator{Bin: "glslangValidator"} }
// ConvertCompute converts glsl compute shader to spirv.
func (glsl *GLSLValidator) ConvertCompute(path string, input []byte) ([]byte, error) {
base := glsl.WorkDir.Path(filepath.Base(path))
// Convert converts a glsl shader to spirv.
func (glsl *GLSLValidator) Convert(path, variant string, hlsl bool, input []byte) ([]byte, error) {
base := glsl.WorkDir.Path(filepath.Base(path), variant)
pathout := base + ".out"
cmd := exec.Command(glsl.Bin,
"-G100", // OpenGL ES 3.1.
"-w", // Suppress warnings.
"-S", "comp",
"--stdin",
"-I"+filepath.Dir(path),
"-V", // OpenGL ES 3.1.
"-w", // Suppress warnings.
"-S", filepath.Ext(path)[1:],
"-o", pathout,
path,
)
if hlsl {
cmd.Args = append(cmd.Args, "-DHLSL")
}
cmd.Stdin = bytes.NewBuffer(input)
out, err := cmd.Output()