From 79f4dfcaabda95732b442548c4935728315c98dd Mon Sep 17 00:00:00 2001 From: Wojciech Figat Date: Wed, 14 Dec 2022 16:16:25 +0100 Subject: [PATCH] Add `GetNativePtr` to `GPUAdapter` --- Source/Engine/Graphics/GPUAdapter.h | 5 +++++ Source/Engine/GraphicsDevice/DirectX/GPUAdapterDX.h | 6 ++++-- Source/Engine/GraphicsDevice/Null/GPUAdapterNull.h | 7 ++++--- Source/Engine/GraphicsDevice/Vulkan/GPUAdapterVulkan.h | 4 ++++ 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Source/Engine/Graphics/GPUAdapter.h b/Source/Engine/Graphics/GPUAdapter.h index e385c5836..1afe1127f 100644 --- a/Source/Engine/Graphics/GPUAdapter.h +++ b/Source/Engine/Graphics/GPUAdapter.h @@ -41,6 +41,11 @@ public: /// True if valid, otherwise false. virtual bool IsValid() const = 0; + /// + /// Gets the native pointer to the underlying graphics device adapter. It's a low-level platform-specific handle. + /// + API_PROPERTY() virtual void* GetNativePtr() const = 0; + /// /// Gets the GPU vendor identifier. /// diff --git a/Source/Engine/GraphicsDevice/DirectX/GPUAdapterDX.h b/Source/Engine/GraphicsDevice/DirectX/GPUAdapterDX.h index aea242972..48097b290 100644 --- a/Source/Engine/GraphicsDevice/DirectX/GPUAdapterDX.h +++ b/Source/Engine/GraphicsDevice/DirectX/GPUAdapterDX.h @@ -38,12 +38,14 @@ public: { return Index != INVALID_INDEX && MaxFeatureLevel != static_cast(0); } - + void* GetNativePtr() const override + { + return (void*)(intptr)Index; + } uint32 GetVendorId() const override { return (uint32)Description.VendorId; } - String GetDescription() const override { return Description.Description; diff --git a/Source/Engine/GraphicsDevice/Null/GPUAdapterNull.h b/Source/Engine/GraphicsDevice/Null/GPUAdapterNull.h index 84f05b16f..2fa5f0b27 100644 --- a/Source/Engine/GraphicsDevice/Null/GPUAdapterNull.h +++ b/Source/Engine/GraphicsDevice/Null/GPUAdapterNull.h @@ -12,18 +12,19 @@ class GPUAdapterNull : public GPUAdapter { public: - // [GPUAdapter] bool IsValid() const override { return true; } - + void* GetNativePtr() const override + { + return nullptr; + } uint32 GetVendorId() const override { return 0; } - String GetDescription() const override { return TEXT("Null"); diff --git a/Source/Engine/GraphicsDevice/Vulkan/GPUAdapterVulkan.h b/Source/Engine/GraphicsDevice/Vulkan/GPUAdapterVulkan.h index 781e3e73a..f3ddc5406 100644 --- a/Source/Engine/GraphicsDevice/Vulkan/GPUAdapterVulkan.h +++ b/Source/Engine/GraphicsDevice/Vulkan/GPUAdapterVulkan.h @@ -61,6 +61,10 @@ public: { return Gpu != VK_NULL_HANDLE; } + void* GetNativePtr() const override + { + return (void*)Gpu; + } uint32 GetVendorId() const override { return GpuProps.vendorID;