diff options
| author | lucy96chen <47800040+lucy96chen@users.noreply.github.com> | 2021-09-23 12:19:49 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-09-23 12:19:49 -0700 |
| commit | f2a3c933bc11a498c622fa18694c84beca8ca031 (patch) | |
| tree | 8420310733f50c9d8d4765c6dd3022b7be08eae3 /tools | |
| parent | b9b398d038b524f15a86ff27cd6888d54e8754e0 (diff) | |
Add method to retrieve native handles (#1944)
* Added a getNativeHandle() method that retrieves the natively created handles; Modified RendererBase, VKDevice, D3D12Device, and DebugDevice to implement this new method
* Moved ExistingDeviceHandles out of Desc directly inside IDevice and renamed to NativeHandles; Modified calls accessing the struct accordingly in RendererBase, DebugDevice, VKDevice, and D3D12Device
* Minor cleanup changes (renames, etc.)
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/gfx/d3d12/render-d3d12.cpp | 8 | ||||
| -rw-r--r-- | tools/gfx/debug-layer.cpp | 5 | ||||
| -rw-r--r-- | tools/gfx/debug-layer.h | 1 | ||||
| -rw-r--r-- | tools/gfx/renderer-shared.cpp | 6 | ||||
| -rw-r--r-- | tools/gfx/renderer-shared.h | 1 | ||||
| -rw-r--r-- | tools/gfx/vulkan/render-vk.cpp | 12 |
6 files changed, 31 insertions, 2 deletions
diff --git a/tools/gfx/d3d12/render-d3d12.cpp b/tools/gfx/d3d12/render-d3d12.cpp index 22f846ded..b9419c0f1 100644 --- a/tools/gfx/d3d12/render-d3d12.cpp +++ b/tools/gfx/d3d12/render-d3d12.cpp @@ -146,6 +146,8 @@ public: return m_info; } + virtual SLANG_NO_THROW Result SLANG_MCALL getNativeHandle(NativeHandle* outHandle) override; + ~D3D12Device(); #if SLANG_GFX_HAS_DXR_SUPPORT @@ -4115,6 +4117,12 @@ Result D3D12Device::captureTextureToSurface( // !!!!!!!!!!!!!!!!!!!!!!!!!!!! Renderer interface !!!!!!!!!!!!!!!!!!!!!!!!!! +Result D3D12Device::getNativeHandle(NativeHandle* outHandle) +{ + *outHandle = NativeHandle::fromD3D12Handle(m_device); + return SLANG_OK; +} + Result D3D12Device::_createDevice(DeviceCheckFlags deviceCheckFlags, const UnownedStringSlice& nameMatch, D3D_FEATURE_LEVEL featureLevel, DeviceInfo& outDeviceInfo) { outDeviceInfo.clear(); diff --git a/tools/gfx/debug-layer.cpp b/tools/gfx/debug-layer.cpp index 50cacc6c2..91757a501 100644 --- a/tools/gfx/debug-layer.cpp +++ b/tools/gfx/debug-layer.cpp @@ -285,6 +285,11 @@ void validateAccelerationStructureBuildInputs( } } +Result DebugDevice::getNativeHandle(NativeHandle* outHandle) +{ + return baseObject->getNativeHandle(outHandle); +} + Result DebugDevice::getFeatures(const char** outFeatures, UInt bufferSize, UInt* outFeatureCount) { SLANG_GFX_API_FUNC; diff --git a/tools/gfx/debug-layer.h b/tools/gfx/debug-layer.h index c7de48149..1494fec58 100644 --- a/tools/gfx/debug-layer.h +++ b/tools/gfx/debug-layer.h @@ -40,6 +40,7 @@ public: public: DebugDevice(); IDevice* getInterface(const Slang::Guid& guid); + virtual SLANG_NO_THROW Result SLANG_MCALL getNativeHandle(NativeHandle* outHandle) override; virtual SLANG_NO_THROW bool SLANG_MCALL hasFeature(const char* feature) override; virtual SLANG_NO_THROW Result SLANG_MCALL getFeatures(const char** outFeatures, UInt bufferSize, UInt* outFeatureCount) override; diff --git a/tools/gfx/renderer-shared.cpp b/tools/gfx/renderer-shared.cpp index bb80c4f53..18f99ad1b 100644 --- a/tools/gfx/renderer-shared.cpp +++ b/tools/gfx/renderer-shared.cpp @@ -248,6 +248,12 @@ SLANG_NO_THROW Result SLANG_MCALL RendererBase::initialize(const Desc& desc) return SLANG_OK; } +SLANG_NO_THROW Result SLANG_MCALL RendererBase::getNativeHandle(NativeHandle* outHandle) +{ + *outHandle = {}; + return SLANG_OK; +} + SLANG_NO_THROW Result SLANG_MCALL RendererBase::getFeatures( const char** outFeatures, UInt bufferSize, UInt* outFeatureCount) { diff --git a/tools/gfx/renderer-shared.h b/tools/gfx/renderer-shared.h index 31a7566a2..5710bc74e 100644 --- a/tools/gfx/renderer-shared.h +++ b/tools/gfx/renderer-shared.h @@ -1079,6 +1079,7 @@ class RendererBase : public IDevice, public Slang::ComObject public: SLANG_COM_OBJECT_IUNKNOWN_ALL + virtual SLANG_NO_THROW Result SLANG_MCALL getNativeHandle(NativeHandle* outHandle) SLANG_OVERRIDE; virtual SLANG_NO_THROW Result SLANG_MCALL getFeatures( const char** outFeatures, UInt bufferSize, UInt* outFeatureCount) SLANG_OVERRIDE; virtual SLANG_NO_THROW bool SLANG_MCALL hasFeature(const char* featureName) SLANG_OVERRIDE; diff --git a/tools/gfx/vulkan/render-vk.cpp b/tools/gfx/vulkan/render-vk.cpp index e67f86217..70eb8de03 100644 --- a/tools/gfx/vulkan/render-vk.cpp +++ b/tools/gfx/vulkan/render-vk.cpp @@ -53,7 +53,7 @@ public: kMaxDescriptorSets = 8, }; // Renderer implementation - Result initVulkanInstanceAndDevice(Desc::ExistingDeviceHandles handles, bool useValidationLayer); + Result initVulkanInstanceAndDevice(NativeHandle handles, bool useValidationLayer); virtual SLANG_NO_THROW Result SLANG_MCALL initialize(const Desc& desc) override; virtual SLANG_NO_THROW Result SLANG_MCALL createTransientResourceHeap( const ITransientResourceHeap::Desc& desc, @@ -134,6 +134,8 @@ public: { return m_info; } + + virtual SLANG_NO_THROW Result SLANG_MCALL getNativeHandle(NativeHandle* outHandle) override; /// Dtor ~VKDevice(); @@ -5222,7 +5224,13 @@ VkPipelineShaderStageCreateInfo VKDevice::compileEntryPoint( // !!!!!!!!!!!!!!!!!!!!!!!!!!!! Renderer interface !!!!!!!!!!!!!!!!!!!!!!!!!! -Result VKDevice::initVulkanInstanceAndDevice(const Desc::ExistingDeviceHandles handles, bool useValidationLayer) +Result VKDevice::getNativeHandle(NativeHandle* outHandle) +{ + *outHandle = NativeHandle::fromVulkanHandles((uint64_t)m_api.m_instance, (uint64_t)m_api.m_physicalDevice, (uint64_t)m_api.m_device); + return SLANG_OK; +} + +Result VKDevice::initVulkanInstanceAndDevice(const NativeHandle handles, bool useValidationLayer) { m_features.clear(); |
