bkaradzic / bgfx

Cross-platform, graphics API agnostic, "Bring Your Own Engine/Framework" style rendering library.
https://bkaradzic.github.io/bgfx/overview.html
BSD 2-Clause "Simplified" License
15.12k stars 1.95k forks source link

[Direct3D12] [Suggested fix] Potentially invalid use of the API in feature support check. #3345

Closed kalmard0 closed 3 months ago

kalmard0 commented 3 months ago

Describe the bug I believe the feature check code for Direct3D12 is mis-using the API.

See the code around https://github.com/bkaradzic/bgfx/blob/0b73e8c7e22a2876a8979a4dd9b77d0686058090/src/renderer_d3d12.cpp#L1125

Starting at Options12 up to Options15, every feature check is using the D3D12_FEATURE_D3D12_OPTIONS12 enum to get the feature results. While I am not very familiar with D3D12 and could not reproduce an actual bug based on this, just looking at the API this seems wrong.

E.g. code that I believe is incorrect: for (D3D12_FEATURE_DATA_D3D12_OPTIONS15 options15; SUCCEEDED(m_device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS12, &options15, sizeof(options15)));)

I think the first argument of CheckFeatureSupport should be D3D12_FEATURE_DATA_D3D12_OPTIONS15 in the snippet above. And the same for the previous few checks.

If you agree this is wrong, I can send a PR to fix these few lines, however I'm not sure how to actually test such a change.

bkaradzic commented 3 months ago

If you agree this is wrong, I can send a PR to fix these few lines, however I'm not sure how to actually test such a change.

Yes. Please send PR.