Skip to content

Commit

Permalink
d3d12: Report other capabilities
Browse files Browse the repository at this point in the history
For Turing+ only.
  • Loading branch information
jp7677 committed Aug 20, 2024
1 parent bda44be commit 6b837dc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
16 changes: 10 additions & 6 deletions src/nvapi_d3d12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,10 @@ extern "C" {

pGraphicsCaps->majorSMVersion = 0;
pGraphicsCaps->minorSMVersion = 0;
// all Vulkan drivers are expected to support ZBC clear without padding
// All Vulkan drivers are expected to support ZBC clear without padding
pGraphicsCaps->bFastUAVClearSupported = true;
pGraphicsCaps->bExclusiveScissorRectsSupported = false;
pGraphicsCaps->bVariablePixelRateShadingSupported = false;

NvapiAdapter* adapter = nullptr;
auto luid = NvapiD3d12Device::GetLuid(pDevice);
Expand All @@ -203,6 +205,13 @@ extern "C" {
if (adapter == nullptr || (!adapter->HasNvProprietaryDriver() && !adapter->HasNvkDriver()))
return Ok(str::format(n, " (sm_0)"));

// Might be related to VK_NV_scissor_exclusive (which isn't used by VKD3D-Proton), but unknown in the context of D3D12
// pGraphicsCaps->bExclusiveScissorRectsSupported = adapter->IsVkDeviceExtensionSupported(VK_NV_SCISSOR_EXCLUSIVE_EXTENSION_NAME);

// Note that adapter->IsVkDeviceExtensionSupported returns the extensions supported by DXVK, not by VKD3D-Proton,
// so we might be wrong here in case of an old VKD3D-Proton version or when VKD3D_DISABLE_EXTENSIONS is in use
pGraphicsCaps->bVariablePixelRateShadingSupported = adapter->IsVkDeviceExtensionSupported(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);

// From https://arnon.dk/matching-sm-architectures-arch-and-gencode-for-various-nvidia-cards/
// Note: One might think that SM here is D3D12 Shader Model, in fact it is the "Streaming Multiprocessor" architecture name
switch (adapter->GetArchitectureId()) {
Expand Down Expand Up @@ -234,11 +243,6 @@ extern "C" {
break;
}

// These fields should be derivable from architecture, but not sure yet what the consequences are
// Currently we do not require these fields, we can implement them later.
// pGraphicsCaps->bExclusiveScissorRectsSupported = ;
// pGraphicsCaps->bVariablePixelRateShadingSupported = ; // Should be supported on Turing and newer

return Ok(str::format(n, " (sm_", pGraphicsCaps->majorSMVersion, pGraphicsCaps->minorSMVersion, ")"));
}

Expand Down
3 changes: 1 addition & 2 deletions src/sysinfo/nvapi_adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ namespace dxvk {
[[nodiscard]] uint32_t GetBoardId() const;
[[nodiscard]] std::optional<LUID> GetLuid() const;
[[nodiscard]] NV_GPU_ARCHITECTURE_ID GetArchitectureId() const;
[[nodiscard]] bool IsVkDeviceExtensionSupported(const std::string& name) const;
[[nodiscard]] const MemoryInfo& GetMemoryInfo() const;
[[nodiscard]] MemoryBudgetInfo GetCurrentMemoryBudgetInfo() const;
[[nodiscard]] bool HasNvml() const;
Expand Down Expand Up @@ -77,8 +78,6 @@ namespace dxvk {

uint32_t m_driverVersionOverride = 0;

[[nodiscard]] bool IsVkDeviceExtensionSupported(const std::string& name) const;

constexpr static auto driverVersionEnvName = "DXVK_NVAPI_DRIVER_VERSION";
constexpr static auto allowOtherDriversEnvName = "DXVK_NVAPI_ALLOW_OTHER_DRIVERS";
constexpr static uint16_t NvidiaPciVendorId = 0x10de;
Expand Down
23 changes: 13 additions & 10 deletions tests/nvapi_d3d12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,17 +232,18 @@ TEST_CASE("D3D12 methods succeed", "[.d3d12]") {
std::string extensionName;
uint16_t expectedMajorSMVersion;
uint16_t expectedMinorSMVersion;
bool variablePixelRateShadingSupported;
};
auto args = GENERATE(
Data{VK_DRIVER_ID_NVIDIA_PROPRIETARY, 0x2600, VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME, 8, 9},
Data{VK_DRIVER_ID_NVIDIA_PROPRIETARY, 0x2000, VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME, 8, 6},
Data{VK_DRIVER_ID_NVIDIA_PROPRIETARY, 0x2000, VK_KHR_FRAGMENT_SHADER_BARYCENTRIC_EXTENSION_NAME, 7, 5},
Data{VK_DRIVER_ID_NVIDIA_PROPRIETARY, 0x2000, VK_NVX_IMAGE_VIEW_HANDLE_EXTENSION_NAME, 7, 0},
Data{VK_DRIVER_ID_NVIDIA_PROPRIETARY, 0x2000, VK_NV_CLIP_SPACE_W_SCALING_EXTENSION_NAME, 6, 0},
Data{VK_DRIVER_ID_NVIDIA_PROPRIETARY, 0x2000, VK_NV_VIEWPORT_ARRAY2_EXTENSION_NAME, 5, 0},
Data{VK_DRIVER_ID_MESA_NVK, 0x2600, VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME, 8, 9},
Data{VK_DRIVER_ID_AMD_OPEN_SOURCE, 0x2000, VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME, 0, 0},
Data{VK_DRIVER_ID_NVIDIA_PROPRIETARY, 0x2000, "ext", 0, 0});
Data{VK_DRIVER_ID_NVIDIA_PROPRIETARY, 0x2600, VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME, 8, 9, true},
Data{VK_DRIVER_ID_NVIDIA_PROPRIETARY, 0x2000, VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME, 8, 6, true},
Data{VK_DRIVER_ID_NVIDIA_PROPRIETARY, 0x2000, VK_KHR_FRAGMENT_SHADER_BARYCENTRIC_EXTENSION_NAME, 7, 5, false},
Data{VK_DRIVER_ID_NVIDIA_PROPRIETARY, 0x2000, VK_NVX_IMAGE_VIEW_HANDLE_EXTENSION_NAME, 7, 0, false},
Data{VK_DRIVER_ID_NVIDIA_PROPRIETARY, 0x2000, VK_NV_CLIP_SPACE_W_SCALING_EXTENSION_NAME, 6, 0, false},
Data{VK_DRIVER_ID_NVIDIA_PROPRIETARY, 0x2000, VK_NV_VIEWPORT_ARRAY2_EXTENSION_NAME, 5, 0, false},
Data{VK_DRIVER_ID_MESA_NVK, 0x2600, VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME, 8, 9, true},
Data{VK_DRIVER_ID_AMD_OPEN_SOURCE, 0x2000, VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME, 0, 0, false},
Data{VK_DRIVER_ID_NVIDIA_PROPRIETARY, 0x2000, "ext", 0, 0, false});

::SetEnvironmentVariableA("DXVK_NVAPI_ALLOW_OTHER_DRIVERS", "1");

Expand All @@ -268,9 +269,11 @@ TEST_CASE("D3D12 methods succeed", "[.d3d12]") {

NV_D3D12_GRAPHICS_CAPS graphicsCaps;
REQUIRE(NvAPI_D3D12_GetGraphicsCapabilities(static_cast<ID3D12Device*>(&device), NV_D3D12_GRAPHICS_CAPS_VER1, &graphicsCaps) == NVAPI_OK);
REQUIRE(graphicsCaps.bFastUAVClearSupported == true);
REQUIRE(graphicsCaps.majorSMVersion == args.expectedMajorSMVersion);
REQUIRE(graphicsCaps.minorSMVersion == args.expectedMinorSMVersion);
REQUIRE(graphicsCaps.bFastUAVClearSupported == true);
REQUIRE(graphicsCaps.bExclusiveScissorRectsSupported == false);
REQUIRE(graphicsCaps.bVariablePixelRateShadingSupported == args.variablePixelRateShadingSupported);
REQUIRE(deviceRefCount == 0);
}

Expand Down

0 comments on commit 6b837dc

Please sign in to comment.