From b3dfe383c6d31ff3dbd76dcfb32de8d536382f3e Mon Sep 17 00:00:00 2001 From: lucy96chen <47800040+lucy96chen@users.noreply.github.com> Date: Mon, 4 Oct 2021 09:46:33 -0700 Subject: Get native handles for TextureResource and BufferResource (#1960) * Added getNativeHandle() to TextureResource and BufferResource; Implemented getNativeHandle() in Vulkan and D3D12; Added new unit test files for the aforementioned implementation * Added missing getNativeHandle() implementations to renderer-shared.cpp and CUDA * Finished new getNativeHandle() unit tests for ITextureResource and IBufferResource; Modified ICommandQueue and ICommandBuffer unit tests to call QueryInterface to convert to IUnknown then back and compare resulting pointers for equality * Unit tests updated and pass locally * Cast m_buffer.m_buffer and m_image to uint64_t --- tools/gfx/vulkan/render-vk.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (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 7af7d086f..d2cbd6790 100644 --- a/tools/gfx/vulkan/render-vk.cpp +++ b/tools/gfx/vulkan/render-vk.cpp @@ -203,6 +203,12 @@ public: return (DeviceAddress)m_buffer.m_api->vkGetBufferDeviceAddress( m_buffer.m_api->m_device, &info); } + + virtual SLANG_NO_THROW Result SLANG_MCALL getNativeHandle(NativeHandle* outHandle) override + { + *outHandle = (uint64_t)m_buffer.m_buffer; + return SLANG_OK; + } }; class TextureResourceImpl : public TextureResource @@ -229,6 +235,12 @@ public: VkDeviceMemory m_imageMemory = VK_NULL_HANDLE; bool m_isWeakImageReference = false; RefPtr m_device; + + virtual SLANG_NO_THROW Result SLANG_MCALL getNativeHandle(NativeHandle* outHandle) override + { + *outHandle = (uint64_t)m_image; + return SLANG_OK; + } }; class SamplerStateImpl : public ISamplerState, public ComObject -- cgit v1.2.3