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

Don't enable D3D12 debug layers as part of device creation #147

Merged
merged 1 commit into from
Jan 31, 2025

Conversation

aleino-nv
Copy link
Contributor

@aleino-nv aleino-nv commented Jan 30, 2025

As [1] shows, creating a D3D12 device and then enabling debug layers causes future device creation to fail.
That means enabling debug layers is a process-wide decision that should be done at startup, and not just before creating an individual device.

This helps to address shader-slang/slang#6172. In the case of the mentioned failure, the WebGPU backend happened to create a D3D12 device before Slang-RHI got to create a device and enable debug layers.

A new interface is added which lets the API user enable debug layers separately, before creating any devices.

After this, the fix for slang-test debug issue is shader-slang/slang#6226.

[1] shader-slang/slang#6172 (comment)

As [1] shows, creating a D3D12 device and then enabling debug layers causes future device
creation to fail.
That means enabling debug layers is a process-wide decision that should be done at
startup, and not just before creating an individual device.

This helps to address shader-slang/slang#6172.
In the case of the mentioned failure, the WebGPU backend happened to create a D3D12 device
before Slang-RHI got to create a device and enable debug layers.

A new interface is added which lets the API user enable debug layers separately, before
creating any devices.

[1] shader-slang/slang#6172 (comment)
@aleino-nv aleino-nv force-pushed the aleino/d3d12-debug-layer-fix branch from f559e32 to a4e3c7c Compare January 30, 2025 13:12
@skallweitNV
Copy link
Collaborator

I don't really like how this plays with the enableBackendValidation option in the DeviceDesc.
Maybe we should remove that option from DeviceDesc and have users enable backend debug layers using the new API.
For D3D12 we basically do what is in this PR. For Vulkan we'd have to store a global flag and check that on device creation.

@aleino-nv
Copy link
Contributor Author

I don't really like how this plays with the enableBackendValidation option in the DeviceDesc. Maybe we should remove that option from DeviceDesc and have users enable backend debug layers using the new API. For D3D12 we basically do what is in this PR. For Vulkan we'd have to store a global flag and check that on device creation.

Could we make enableBackendValidation a parameter to getRHI, so that you have to decide when you create the instance?

@skallweitNV
Copy link
Collaborator

getRHI just returns a singleton, so adding a parameter there makes no sense IMO.

@aleino-nv
Copy link
Contributor Author

getRHI just returns a singleton, so adding a parameter there makes no sense IMO.

I meant that getRHI should get the initial instance using this parameter as well.

@skallweitNV
Copy link
Collaborator

I think the current enableDebugLayers method is fine. We could add checks to fail if a D3D12 has already been created. But we can also merge the PR as is, I can remove enableBackendValidation later.

@aleino-nv aleino-nv merged commit df69e28 into main Jan 31, 2025
15 checks passed
@aleino-nv aleino-nv deleted the aleino/d3d12-debug-layer-fix branch January 31, 2025 08:45
@aleino-nv
Copy link
Contributor Author

I think the current enableDebugLayers method is fine. We could add checks to fail if a D3D12 has already been created. But we can also merge the PR as is, I can remove enableBackendValidation later.

Ok, I filed #151 for the removal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants