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

d3d12: Report other capabilities #200

Merged
merged 1 commit into from
Aug 20, 2024
Merged

d3d12: Report other capabilities #200

merged 1 commit into from
Aug 20, 2024

Conversation

jp7677
Copy link
Owner

@jp7677 jp7677 commented Aug 18, 2024

For Turing+ only.

I'm tempted to report those two also for Turing+.
Since there are no NvAPI_D3D12 equivalents to NvAPI_D3D11_RSSetExclusiveScissorRects or NvAPI_D3D11_RSSetViewportsPixelShadingRates I guess those capabilities refer to D3D12 core functionalities, but should do some research into it first.
Reporting those probably makes no difference in practice.

@Saancreed
Copy link
Collaborator

bVariablePixelRateShadingSupported is simple enough I think, afaict this refers to feature that's accessible using ID3D12GraphicsCommandList5::RSSetShadingRate. Though I'd recommend checking if VK_KHR_fragment_shading_rate extension has been enabled on underlying VkDevice.

bExclusiveScissorRectsSupported looks a bit tougher though. It sounds like something that is exposed by VK_NV_scissor_exclusive extension in Vulkan but vkd3d-proton doesn't use it and I don't see a way to access a feature like this neither in D3D12 core API nor in NVAPI D3D12 extensions. Maybe it would be safer to keep reporting false here.

@jp7677
Copy link
Owner Author

jp7677 commented Aug 19, 2024

bVariablePixelRateShadingSupported is simple enough I think, afaict this refers to feature that's accessible using ID3D12GraphicsCommandList5::RSSetShadingRate. Though I'd recommend checking if VK_KHR_fragment_shading_rate extension has been enabled on underlying VkDevice.

Good suggestion. Did that, which should result in the same.

bExclusiveScissorRectsSupported looks a bit tougher though. It sounds like something that is exposed by VK_NV_scissor_exclusive extension in Vulkan but vkd3d-proton doesn't use it and I don't see a way to access a feature like this neither in D3D12 core API nor in NVAPI D3D12 extensions. Maybe it would be safer to keep reporting false here.

I couldn't find anything related to d3d12 either, this hints in your direction https://developer.nvidia.com/vulkan-turing though. Returning false seems sensible.

@jp7677 jp7677 marked this pull request as ready for review August 19, 2024 17:01
@jp7677 jp7677 requested a review from Saancreed August 19, 2024 20:28
Copy link
Collaborator

@Saancreed Saancreed left a comment

Choose a reason for hiding this comment

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

One warning but it's not necessarily something we need to act on.

@@ -203,6 +207,8 @@ extern "C" {
if (adapter == nullptr || (!adapter->HasNvProprietaryDriver() && !adapter->HasNvkDriver()))
return Ok(str::format(n, " (sm_0)"));

pGraphicsCaps->bVariablePixelRateShadingSupported = adapter->IsVariablePixelRateShadingSupported();
Copy link
Collaborator

Choose a reason for hiding this comment

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

In the incredibly unlikely scenario that we are running this code alongside some ancient version of vkd3d-proton (or usage of the ext is disabled via VKD3D_DISABLE_EXTENSIONS), the safer choice would be to check which extensions were actually enabled on the logical device instead. That would look something like

Com<ID3D12DXVKInteropDevice> device;
if (SUCCEEDED(pDevice->QueryInterface(IID_PPV_ARGS(&device)))) {
    std::vector<const char*> extensions;
    UINT count;
    if (SUCCEEDED(device->GetDeviceExtensions(&count, nullptr))) {
        extensions.resize(count);
        if (SUCCEEDED(device->GetDeviceExtensions(&count, extensions.data())))
            pGraphicsCaps->bVariablePixelRateShadingSupported = std::any_of(extensions.begin(), extensions.end(), [](auto ext) { return ext == std::string_view{VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME}; });
    }
}

but it's fairly disgusting and probably overcomplicated for such a rare corner-case, so if you are fine with this small risk then let's just leave a comment that would explain potential mismatch and ignore the problem for now.

@jp7677 jp7677 merged commit 6b837dc into master Aug 20, 2024
2 checks passed
@jp7677 jp7677 deleted the d3d12-capabilities branch August 20, 2024 16:32
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