summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2023-04-04 18:00:16 -0400
committerGitHub <noreply@github.com>2023-04-04 18:00:16 -0400
commit68c7d5cda2d6f2eb7bfb3a7e15860eb3ded25424 (patch)
treeac4e8384108e70109b084782b414296d015f92b8 /tools
parent7bb2de1bc40e535fae93940113db97b5ea44a6f2 (diff)
Preliminary support for realtime clock (#2772)
* #include an absolute path didn't work - because paths were taken to always be relative. * Initial support for realtime clock. * Add realtime-clock render feature where seems appropriate. * Fixes to make NVAPI compile properly. Change realtime-clock.slang check to use maths that can't overflow.
Diffstat (limited to 'tools')
-rw-r--r--tools/gfx/cuda/cuda-device.cpp5
-rw-r--r--tools/gfx/d3d11/d3d11-device.cpp5
-rw-r--r--tools/gfx/d3d11/d3d11-scopeNVAPI.cpp2
-rw-r--r--tools/gfx/d3d12/d3d12-device.cpp9
-rw-r--r--tools/gfx/d3d12/d3d12-pipeline-state.cpp2
-rw-r--r--tools/gfx/vulkan/vk-api.h5
-rw-r--r--tools/gfx/vulkan/vk-device.cpp14
7 files changed, 39 insertions, 3 deletions
diff --git a/tools/gfx/cuda/cuda-device.cpp b/tools/gfx/cuda/cuda-device.cpp
index f81bcfe99..4aeecb606 100644
--- a/tools/gfx/cuda/cuda-device.cpp
+++ b/tools/gfx/cuda/cuda-device.cpp
@@ -179,9 +179,12 @@ SLANG_NO_THROW SlangResult SLANG_MCALL DeviceImpl::initialize(const Desc& desc)
SLANG_CUDA_RETURN_WITH_REPORT_ON_FAIL(
cuCtxCreate(&m_context->m_context, 0, m_device), reportType);
- // Not clear how to detect half support on CUDA. For now we'll assume we have it
{
+ // Not clear how to detect half support on CUDA. For now we'll assume we have it
m_features.add("half");
+
+ // CUDA has support for realtime clock
+ m_features.add("realtime-clock");
}
cudaDeviceProp deviceProps;
diff --git a/tools/gfx/d3d11/d3d11-device.cpp b/tools/gfx/d3d11/d3d11-device.cpp
index e32bdf7ed..cc2eda089 100644
--- a/tools/gfx/d3d11/d3d11-device.cpp
+++ b/tools/gfx/d3d11/d3d11-device.cpp
@@ -196,6 +196,11 @@ SlangResult DeviceImpl::initialize(const Desc& desc)
m_features.add("atomic-float");
}
+ // If we have NVAPI well assume we have realtime clock
+ {
+ m_features.add("realtime-clock");
+ }
+
m_nvapi = true;
#endif
}
diff --git a/tools/gfx/d3d11/d3d11-scopeNVAPI.cpp b/tools/gfx/d3d11/d3d11-scopeNVAPI.cpp
index b230623fe..1a662e999 100644
--- a/tools/gfx/d3d11/d3d11-scopeNVAPI.cpp
+++ b/tools/gfx/d3d11/d3d11-scopeNVAPI.cpp
@@ -20,7 +20,7 @@ SlangResult ScopeNVAPI::init(DeviceImpl* device, Index regIndex)
}
#ifdef GFX_NVAPI
- NvAPI_Status nvapiStatus = NvAPI_D3D11_SetNvShaderExtnSlot(renderer->m_device, NvU32(regIndex));
+ NvAPI_Status nvapiStatus = NvAPI_D3D11_SetNvShaderExtnSlot(device->m_device, NvU32(regIndex));
if (nvapiStatus != NVAPI_OK)
{
return SLANG_FAIL;
diff --git a/tools/gfx/d3d12/d3d12-device.cpp b/tools/gfx/d3d12/d3d12-device.cpp
index 8f1a3e366..312c81d75 100644
--- a/tools/gfx/d3d12/d3d12-device.cpp
+++ b/tools/gfx/d3d12/d3d12-device.cpp
@@ -24,6 +24,10 @@
# define ENABLE_DEBUG_LAYER 0
#endif
+#ifdef GFX_NVAPI
+# include "../nvapi/nvapi-include.h"
+#endif
+
namespace gfx
{
namespace d3d12
@@ -597,6 +601,11 @@ Result DeviceImpl::initialize(const Desc& desc)
m_features.add("atomic-float");
}
+ // If we have NVAPI well assume we have realtime clock
+ {
+ m_features.add("realtime-clock");
+ }
+
m_nvapi = true;
#endif
}
diff --git a/tools/gfx/d3d12/d3d12-pipeline-state.cpp b/tools/gfx/d3d12/d3d12-pipeline-state.cpp
index adfdcd518..35313f676 100644
--- a/tools/gfx/d3d12/d3d12-pipeline-state.cpp
+++ b/tools/gfx/d3d12/d3d12-pipeline-state.cpp
@@ -240,7 +240,7 @@ Result PipelineStateImpl::ensureAPIPipelineStateCreated()
SIZE_T(programImpl->m_shaders[0].code.getCount()) };
#ifdef GFX_NVAPI
- if (m_nvapi)
+ if (m_device->m_nvapi)
{
// Also fill the extension structure.
// Use the same UAV slot index and register space that are declared in the shader.
diff --git a/tools/gfx/vulkan/vk-api.h b/tools/gfx/vulkan/vk-api.h
index af2234f55..c34372f45 100644
--- a/tools/gfx/vulkan/vk-api.h
+++ b/tools/gfx/vulkan/vk-api.h
@@ -270,6 +270,11 @@ struct VulkanExtendedFeatureProperties
// Robustness2 features
VkPhysicalDeviceRobustness2FeaturesEXT robustness2Features = {
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ROBUSTNESS_2_FEATURES_EXT};
+
+ // Clock features
+ VkPhysicalDeviceShaderClockFeaturesKHR clockFeatures = {
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_CLOCK_FEATURES_KHR
+ };
};
struct VulkanApi
diff --git a/tools/gfx/vulkan/vk-device.cpp b/tools/gfx/vulkan/vk-device.cpp
index b5eec0b72..488f39be6 100644
--- a/tools/gfx/vulkan/vk-device.cpp
+++ b/tools/gfx/vulkan/vk-device.cpp
@@ -424,6 +424,10 @@ Result DeviceImpl::initVulkanInstanceAndDevice(
extendedFeatures.robustness2Features.pNext = deviceFeatures2.pNext;
deviceFeatures2.pNext = &extendedFeatures.robustness2Features;
+ // clock features
+ extendedFeatures.clockFeatures.pNext = deviceFeatures2.pNext;
+ deviceFeatures2.pNext = &extendedFeatures.clockFeatures;
+
// Atomic Float
// To detect atomic float we need
// https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkPhysicalDeviceShaderAtomicFloatFeaturesEXT.html
@@ -575,6 +579,16 @@ Result DeviceImpl::initVulkanInstanceAndDevice(
m_features.add("robustness2");
}
+ if (extendedFeatures.clockFeatures.shaderDeviceClock)
+ {
+ deviceExtensions.add(VK_KHR_SHADER_CLOCK_EXTENSION_NAME);
+
+ extendedFeatures.clockFeatures.pNext = (void*)deviceCreateInfo.pNext;
+ deviceCreateInfo.pNext = &extendedFeatures.clockFeatures;
+
+ m_features.add("realtime-clock");
+ }
+
VkPhysicalDeviceProperties2 extendedProps = {
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2 };
VkPhysicalDeviceRayTracingPipelinePropertiesKHR rtProps = {