mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-04 08:55:35 +00:00
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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user