Skip to content

Commit

Permalink
nvapi-d3d12: Add GB200 SM numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
jp7677 committed Jan 10, 2025
1 parent 1ee5320 commit d719941
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
6 changes: 5 additions & 1 deletion src/nvapi_d3d12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,13 @@ extern "C" {
// 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/
// From https://arnon.dk/matching-sm-architectures-arch-and-gencode-for-various-nvidia-cards/ and https://en.wikipedia.org/wiki/CUDA#GPUs_supported
// Note: One might think that SM here is D3D12 Shader Model, in fact it is the "Streaming Multiprocessor" architecture name
switch (adapter->GetArchitectureId()) {
case NV_GPU_ARCHITECTURE_GB200:
pGraphicsCaps->majorSMVersion = 10;
pGraphicsCaps->minorSMVersion = 0; // Still unknown
break;
case NV_GPU_ARCHITECTURE_AD100:
pGraphicsCaps->majorSMVersion = 8;
pGraphicsCaps->minorSMVersion = 9;
Expand Down
30 changes: 18 additions & 12 deletions tests/nvapi_d3d12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,30 +229,34 @@ TEST_CASE("D3D12 methods succeed", "[.d3d12]") {
struct Data {
VkDriverId driverId;
uint32_t deviceId;
std::string extensionName;
std::set<std::string> extensionNames;
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, 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, 2, false},
Data{VK_DRIVER_ID_NVIDIA_PROPRIETARY, 0x2000, VK_EXT_SHADER_IMAGE_ATOMIC_INT64_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});
Data{VK_DRIVER_ID_NVIDIA_PROPRIETARY, 0x2600, {VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME, VK_KHR_COMPUTE_SHADER_DERIVATIVES_EXTENSION_NAME}, 10, 0, true},
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, 2, false},
Data{VK_DRIVER_ID_NVIDIA_PROPRIETARY, 0x2000, {VK_EXT_SHADER_IMAGE_ATOMIC_INT64_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");

auto extensionNames = std::set<std::string>{VK_KHR_DRIVER_PROPERTIES_EXTENSION_NAME};
extensionNames.insert(args.extensionNames.begin(), args.extensionNames.end());

luid.HighPart = 0x00000002;
luid.LowPart = 0x00000001;

ALLOW_CALL(*vk, GetDeviceExtensions(_, _))
.RETURN(std::set<std::string>{VK_KHR_DRIVER_PROPERTIES_EXTENSION_NAME, args.extensionName});
.RETURN(extensionNames);
ALLOW_CALL(*vk, GetPhysicalDeviceProperties2(_, _, _))
.SIDE_EFFECT(
ConfigureGetPhysicalDeviceProperties2(_3,
Expand All @@ -263,6 +267,8 @@ TEST_CASE("D3D12 methods succeed", "[.d3d12]") {
vkProps.props->deviceID = args.deviceId;
if (args.extensionNames.contains(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME))
vkProps.fragmentShadingRateProps->primitiveFragmentShadingRateWithMultipleViewports = VK_TRUE;
if (args.extensionNames.contains(VK_KHR_COMPUTE_SHADER_DERIVATIVES_EXTENSION_NAME))
vkProps.computeShaderDerivativesProps->meshAndTaskShaderDerivatives = VK_TRUE;
}));

SetupResourceFactory(std::move(dxgiFactory), std::move(vk), std::move(nvml), std::move(lfx));
Expand Down

0 comments on commit d719941

Please sign in to comment.