From f2a3c933bc11a498c622fa18694c84beca8ca031 Mon Sep 17 00:00:00 2001 From: lucy96chen <47800040+lucy96chen@users.noreply.github.com> Date: Thu, 23 Sep 2021 12:19:49 -0700 Subject: 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.) --- tools/gfx/vulkan/render-vk.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'tools/gfx/vulkan/render-vk.cpp') 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(); -- cgit v1.2.3