mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
gpu/internal/convertshaders: build compute shaders in HLSL cs_5_0 profile
The recent changes to the compute shaders have fixed all errors previously reported by fxc. Switch from dxc to fxc to target shader model 5.0, supported by Direct3D 11. Because we know dxc must be available, always build compute shaders even though the result is not yet used. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -46,6 +46,8 @@ func (fxc *FXC) Compile(path, variant string, input []byte, entryPoint string, p
|
||||
profile = "ps_" + profileVersion
|
||||
case ".vert":
|
||||
profile = "vs_" + profileVersion
|
||||
case ".comp":
|
||||
profile = "cs_" + profileVersion
|
||||
default:
|
||||
return "", fmt.Errorf("unrecognized shader type %s", path)
|
||||
}
|
||||
|
||||
@@ -81,7 +81,6 @@ type Converter struct {
|
||||
glslvalidator *GLSLValidator
|
||||
spirv *SPIRVCross
|
||||
fxc *FXC
|
||||
dxc *DXC
|
||||
}
|
||||
|
||||
func NewConverter(workDir WorkDir, packageName, shadersDir string, directCompute bool) *Converter {
|
||||
@@ -99,18 +98,13 @@ func NewConverter(workDir WorkDir, packageName, shadersDir string, directCompute
|
||||
conv.glslvalidator = NewGLSLValidator()
|
||||
conv.spirv = NewSPIRVCross()
|
||||
conv.fxc = NewFXC()
|
||||
conv.dxc = NewDXC()
|
||||
|
||||
verifyBinaryPath(&conv.glslvalidator.Bin)
|
||||
verifyBinaryPath(&conv.spirv.Bin)
|
||||
if directCompute {
|
||||
verifyBinaryPath(&conv.dxc.Bin)
|
||||
}
|
||||
// We cannot check fxc since it may depend on wine.
|
||||
|
||||
conv.glslvalidator.WorkDir = workDir.Dir("glslvalidator")
|
||||
conv.fxc.WorkDir = workDir.Dir("fxc")
|
||||
conv.dxc.WorkDir = workDir.Dir("dxc")
|
||||
conv.spirv.WorkDir = workDir.Dir("spirv")
|
||||
|
||||
return conv
|
||||
@@ -378,16 +372,17 @@ func (conv *Converter) ComputeShader(shaderPath string) ([]driver.ShaderSources,
|
||||
}
|
||||
sources.GLSL310ES = unixLineEnding(sources.GLSL310ES)
|
||||
|
||||
if conv.directCompute {
|
||||
hlslSource, err := conv.spirv.Convert(shaderPath, "", spirv, "hlsl", "50")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to convert hlsl compute shader %q: %w", shaderPath, err)
|
||||
}
|
||||
hlslSource, err := conv.spirv.Convert(shaderPath, "", spirv, "hlsl", "50")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to convert hlsl compute shader %q: %w", shaderPath, err)
|
||||
}
|
||||
|
||||
sources.HLSL, err = conv.dxc.Compile(shaderPath, "0", []byte(hlslSource), "main", "cs_5_0")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to compile hlsl compute shader %q: %w", shaderPath, err)
|
||||
}
|
||||
dxil, err := conv.fxc.Compile(shaderPath, "0", []byte(hlslSource), "main", "5_0")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to compile hlsl compute shader %q: %w", shaderPath, err)
|
||||
}
|
||||
if conv.directCompute {
|
||||
sources.HLSL = dxil
|
||||
}
|
||||
|
||||
return []driver.ShaderSources{sources}, nil
|
||||
|
||||
Reference in New Issue
Block a user