Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix D3D12Core.dll loading problem for debug build #5315

Conversation

jkwak-work
Copy link
Collaborator

@jkwak-work jkwak-work commented Oct 15, 2024

D3D12Core.dll had been copied to a wrong directory and slang has been using D3D12Core.dll from the system directory, C:\windows\system32.

D3D12Core.dll has to be copied from external/slang-binaries/bin/windows-x64 to build/Release/bin/D3D12 not to build/Release/bin.
The same is true for the debug build and it had to be copied to build/Debug/bin/D3D12 not build/Debug/bin.

It hasn't been a problem for Release build, because the debug-layer is not enabled for Release build and it didn't cause the version mismatching problem with D3D12SDKLayers.dll. The Release build was loaded from either build/Release/bin or from C:\windows\system32, and it didn't matter which one was used.

The Debug build, however, got into a problem where D3D12Core.dll was loaded from the system directory whereas D3D12SDKLayers.dll was loaded from build/Debug/bin and it failed to load D3D12.dll entirely. This caused D3D12 to be "Not supported" for "Windows/Debug" configuration. Note that our CI explicitly excludes DX12 tests for the "Windows/Debug" configuration with a command-line argument "-api all-dx12", and DX12 tests were going to be ignored anyway.

The actual problem was observed when WGPU is implemented. WGPU started printing explicit errors for the load failure of D3D12.dll.

See more detailed explanation:
https://devblogs.microsoft.com/directx/gettingstarted-dx12agility/#d3d12sdkpath-should-not-be-the-same-directory-as-the-application-exe

Closes #5305
Closes #5276

@jkwak-work jkwak-work added the pr: non-breaking PRs without breaking changes label Oct 15, 2024
@jkwak-work jkwak-work self-assigned this Oct 15, 2024
@jkwak-work
Copy link
Collaborator Author

With this PR, the "Windows/Debug" test in CI shows the following,

Compiling stdlib on debug build, this can take a while.
Compiling stdlib took 21.00 seconds.
Supported backends: fxc dxc glslang spirv-dis clang visualstudio gcc genericcpp llvm spirv-opt tint
Check dx12,d3d12: Supported
Check dx11,d3d11: Supported
Check cuda: Not Supported

Note that D3D12 is supported for Debug build.

Without this PR, the previous output shows that D3D12 was not supported for Debug build

Compiling stdlib on debug build, this can take a while.
Compiling stdlib took 21.00 seconds.
Supported backends: fxc dxc glslang spirv-dis clang visualstudio gcc genericcpp llvm spirv-opt tint
Check dx12,d3d12: Not Supported
Check dx11,d3d11: Supported
Check cuda: Not Supported
Warning: D3D12CreateDevice failed
 - While initializing adapter (backend=BackendType::D3D12)
    at InitializeImpl (D:\a\webgpu-dawn-binaries\webgpu-dawn-binaries\build\_deps\dawn-src\src\dawn\native\d3d12\PhysicalDeviceD3D12.cpp:[93](https://github.com/shader-slang/slang/actions/runs/11354984008/job/31583392799#step:5:94))

@jkwak-work jkwak-work changed the title DO NOT REVIEW YET: Fix D3D12Core.dll loading problem Fix D3D12Core.dll loading problem for debug build Oct 15, 2024
@jkwak-work jkwak-work marked this pull request as ready for review October 15, 2024 23:49
@jkwak-work jkwak-work requested a review from aleino-nv October 15, 2024 23:49
Copy link
Collaborator

@aleino-nv aleino-nv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but can the test be disabled instead of commenting out the assert?
The assert seems to be just because of some file extension specific logic, and should otherwise hold.

D3D12Core.dll had been copied to a wrong directory and slang has been using D3D12Core.dll from the system directory, C:\windows\system32.

D3D12Core.dll has to be copied from external/slang-binaries/bin/windows-x64 to build/Release/bin/D3D12 not to build/Release/bin.
The same is true for the debug build and it had to be copied to build/Debug/bin/D3D12 not build/Debug/bin.

It hasn't been a problem for Release build, because the debug-layer is not enabled for Release build and it didn't cause the version mismatching problem with D3D12SDKLayers.dll. The Release build was loaded from either build/Release/bin or from C:\windows\system32, and it didn't matter which one was used.

The Debug build, however, got into a problem where D3D12Core.dll was loaded from the system directory whereas D3D12SDKLayers.dll was loaded from build/Debug/bin and it failed to load D3D12.dll entirely. This caused D3D12 to be "Not supported" for "Windows/Debug" configuration. Note that our CI explicitly excludes DX12 tests for the "Windows/Debug" configuration with a command-line argument "-api all-dx12", and DX12 tests were going to be ignored anyway.

The actual problem was observed when WGPU is implemented. WGPU started printing explicit errors for the load failure of D3D12.dll.

See more detailed explanation:
https://devblogs.microsoft.com/directx/gettingstarted-dx12agility/#d3d12sdkpath-should-not-be-the-same-directory-as-the-application-exe

Closes shader-slang#5305
@jkwak-work jkwak-work force-pushed the fix/relocate_d3d12_dll_to_build_bin_D3D12 branch from a727245 to 4bc48ef Compare October 16, 2024 21:25
@jkwak-work jkwak-work dismissed aleino-nv’s stale review October 16, 2024 21:31

There will be another PR that addresses this problem properly.

@jkwak-work jkwak-work merged commit ee11a45 into shader-slang:master Oct 17, 2024
13 checks passed
@jkwak-work jkwak-work deleted the fix/relocate_d3d12_dll_to_build_bin_D3D12 branch October 17, 2024 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: non-breaking PRs without breaking changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Debug build of Slang fails to load d3d12SDKLayers.dll properly slang-test assert on usePassthru
3 participants