summaryrefslogtreecommitdiff
path: root/tools/gfx/d3d12
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2020-08-24 14:26:27 -0400
committerGitHub <noreply@github.com>2020-08-24 11:26:27 -0700
commit67ca54997d445e15891965b8d77561b9d10bb18c (patch)
tree8719fb2ff6a42f24daef5ca77d046a55b56d5b98 /tools/gfx/d3d12
parentfcac02e405661de311b5ceebbd6d3e2c78bf8aea (diff)
NVAPI improvements (#1512)
* First pass at incorporating nvapi into test harness. * D3d12 Atomic Float Add via NVAPI working * Dx12 atomic float appears to work. * Atomic float add on Dx12. * Added atomic64 feature addition to vk. Fix correct output for atomic-float-byte-address.slang * Disable atomic float failing tests. * Upgraded VK headers. * Detect atomic float availability on VK. * Try to get test working for in64 atomic. * Made HLSL prelude controlled via the render-test requirements. * Added -enable-nvapi to premake. * Fix D3D12Renderer when NVAPI is not available. * Small improvements to VKRenderer. * Improve atomic documentation in target-compatibility.md. * Fixed NVAPI working on D3D12. * Test for specific NVAPI features. * Remove requiredFeatures from Renderer::Desc as was ignored. Tried to document more around nvapiExtnSlot. * Readded requiredFeatures to Renderer::Desc * Improve comments in the tests.
Diffstat (limited to 'tools/gfx/d3d12')
-rw-r--r--tools/gfx/d3d12/render-d3d12.cpp57
1 files changed, 39 insertions, 18 deletions
diff --git a/tools/gfx/d3d12/render-d3d12.cpp b/tools/gfx/d3d12/render-d3d12.cpp
index ca44aa04d..0f23d8dd4 100644
--- a/tools/gfx/d3d12/render-d3d12.cpp
+++ b/tools/gfx/d3d12/render-d3d12.cpp
@@ -1523,6 +1523,19 @@ Result D3D12Renderer::_createDevice(DeviceCheckFlags deviceCheckFlags, const Uno
return SLANG_OK;
}
+static bool _isSupportedNVAPIOp(ID3D12Device* dev, uint32_t op)
+{
+#ifdef GFX_NVAPI
+ {
+ bool isSupported;
+ NvAPI_Status status = NvAPI_D3D12_IsNvShaderExtnOpCodeSupported(dev, NvU32(op), &isSupported);
+ return status == NVAPI_OK && isSupported;
+ }
+#else
+ return false;
+#endif
+}
+
Result D3D12Renderer::initialize(const Desc& desc, void* inWindowHandle)
{
m_hwnd = (HWND)inWindowHandle;
@@ -1602,32 +1615,40 @@ Result D3D12Renderer::initialize(const Desc& desc, void* inWindowHandle)
return SLANG_FAIL;
}
+ // Set the device
+ m_device = m_deviceInfo.m_device;
+
// NVAPI
+ if (desc.nvapiExtnSlot >= 0)
{
- const char* features[] = { "nvapi", "atomic-float", "atomic-int64" };
- bool needsNvapi = false;
- for (Index i = 0; i < SLANG_COUNT_OF(features); ++i)
+ if (SLANG_FAILED(NVAPIUtil::initialize()))
{
- if (desc.requiredFeatures.indexOf(features[i]) >= 0)
- {
- needsNvapi = true;
- break;
- }
+ return SLANG_E_NOT_AVAILABLE;
}
- if (needsNvapi && SLANG_SUCCEEDED(NVAPIUtil::initialize()))
+#ifdef GFX_NVAPI
+ // From DOCS: Applications are expected to bind null UAV to this slot.
+ // NOTE! We don't currently do this, but doesn't seem to be a problem.
+
+ const NvAPI_Status status = NvAPI_D3D12_SetNvShaderExtnSlotSpace(m_device, NvU32(desc.nvapiExtnSlot), NvU32(0));
+
+ if (status != NVAPI_OK)
{
- // TODO(JS): We should test for specific features here.
- for (Index i = 0; i < SLANG_COUNT_OF(features); ++i)
- {
- m_features.add(features[i]);
- }
- m_nvapi = true;
+ return SLANG_E_NOT_AVAILABLE;
}
- }
- // Set the device
- m_device = m_deviceInfo.m_device;
+ if (_isSupportedNVAPIOp(m_device, NV_EXTN_OP_UINT64_ATOMIC))
+ {
+ m_features.add("atomic-int64");
+ }
+ if (_isSupportedNVAPIOp(m_device, NV_EXTN_OP_FP32_ATOMIC))
+ {
+ m_features.add("atomic-float");
+ }
+
+ m_nvapi = true;
+#endif
+ }
// Find what features are supported
{