gpu/internal/convertshaders: batch calls to winepath

Wine tools can be slow to run, so it makes sense to batch their use.
Fortunately, winepath supports resolving multiple paths in one
execution.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2021-04-10 12:54:58 +02:00
parent 3b3d41a7ea
commit 8adcf25049
+10 -5
View File
@@ -117,12 +117,17 @@ func (dxc *DXC) Compile(path, variant string, input []byte, entryPoint string, p
// winepath uses the winepath tool to convert a paths to Windows format. // winepath uses the winepath tool to convert a paths to Windows format.
// The returned path can be used as arguments for Windows command line tools. // The returned path can be used as arguments for Windows command line tools.
func winepath(paths ...*string) error { func winepath(paths ...*string) error {
winepath := exec.Command("winepath", "--windows")
for _, path := range paths { for _, path := range paths {
out, err := exec.Command("winepath", "--windows", *path).Output() winepath.Args = append(winepath.Args, *path)
if err != nil { }
return fmt.Errorf("unable to run `winepath --windows %q`: %w", *path, err) out, err := winepath.Output()
} if err != nil {
*path = strings.TrimSpace(string(out)) return fmt.Errorf("unable to run `winepath --windows`: %w", err)
}
winPaths := strings.Split(strings.TrimSpace(string(out)), "\n")
for i, path := range paths {
*path = winPaths[i]
} }
return nil return nil
} }