bkaradzic/bgfx

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

kalmard0 opened this issue · 1 comments

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

See the code around

for (D3D12_FEATURE_DATA_D3D12_OPTIONS15 options15; SUCCEEDED(m_device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS12, &options15, sizeof(options15)));)

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.

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.