Fix D3D12 debug crash due to validation layers SDK bug (#3222)

* Fix D3D12 debug crash due to validation layers SDK bug

* Change LONG to FARPROC to be technically correct

* Make requested changes:
Move windows version checking to function in bgfx.cpp
Change windowsVersionIs to also use this technique
Use bgfx code style
Specify dwOSVersionInfoSize prior to calling rtlGetVersion

* Merge both functions into one
Use bx::dlsym instead of GetProcAddress directly
Fix major & minor comparison logic

* Fix win10 version comment

* Revert rendererCreate check back to Win 0x0602

* Clean up logic as per suggestion
This commit is contained in:
Raziel Alphadios
2023-12-14 05:20:07 +02:00
committed by GitHub
parent e2631c1a56
commit f4a9bfc4bc
3 changed files with 42 additions and 21 deletions

View File

@@ -844,13 +844,20 @@ namespace bgfx { namespace d3d12
if (SUCCEEDED(hr))
{
// debug1->SetEnableGPUBasedValidation(true);
// https://discordapp.com/channels/590611987420020747/593519198995742733/703642988345032804
// D3D12 Bug Number: 26131261
// There is a bug in the D3D12 validation that causes example-21 to fail when using UAV
// Setting this function below to false avoids the bug
debug1->SetEnableSynchronizedCommandQueueValidation(false);
// Setting SetEnableSynchronizedCommandQueueValidation below to false avoids the bug
// It was fixed in (probably) the first windows 11 sdk, 22000
// However, the fix causes any dx12 context with validation to break if this is set to false, so we can't do that anymore
if (windowsVersionIs(Condition::GreaterEqual, 0x0A00, 22000))
{
debug1->SetEnableGPUBasedValidation(true);
}
else
{
debug1->SetEnableSynchronizedCommandQueueValidation(false);
}
}
DX_RELEASE(debug1, 1);