internal/graphicsdriver/directx: check the DLL availability at NewGraphics

Updates #2613
Updates #2618
This commit is contained in:
Hajime Hoshi 2023-03-30 01:45:22 +09:00
parent 3e477d0bbb
commit 0cd832f096
2 changed files with 9 additions and 1 deletions

View File

@ -95,8 +95,12 @@ func init() {
procD3DCompile = d3dcompiler.NewProc("D3DCompile")
}
func isD3DCompilerDLLAvailable() bool {
return procD3DCompile != nil
}
func _D3DCompile(srcData []byte, sourceName string, pDefines []_D3D_SHADER_MACRO, pInclude unsafe.Pointer, entryPoint string, target string, flags1 uint32, flags2 uint32) (*_ID3DBlob, error) {
if procD3DCompile == nil {
if !isD3DCompilerDLLAvailable() {
return nil, fmt.Errorf("directx: d3dcompiler_*.dll is missing in this environment")
}

View File

@ -73,6 +73,10 @@ func parseFeatureLevel(str string) (_D3D_FEATURE_LEVEL, bool) {
// NewGraphics creates an implementation of graphicsdriver.Graphics for DirectX.
// The returned graphics value is nil iff the error is not nil.
func NewGraphics() (graphicsdriver.Graphics, error) {
if !isD3DCompilerDLLAvailable() {
return nil, fmt.Errorf("directx: d3dcompiler_*.dll is missing in this environment")
}
var useWARP bool
var useDebugLayer bool
version := 11