From 1f7e7de82b76ebbf301720c542564b73bec9ccd6 Mon Sep 17 00:00:00 2001 From: Bryce Hutchings Date: Tue, 14 Oct 2025 15:07:42 -0700 Subject: [PATCH] Fix D3D12 driver returning internal types to RenderingDevice's texture_get_native_handle/get_driver_resource --- doc/classes/RenderingDevice.xml | 2 ++ drivers/d3d12/rendering_device_driver_d3d12.cpp | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/doc/classes/RenderingDevice.xml b/doc/classes/RenderingDevice.xml index f325733998c..7b4fb65ac93 100644 --- a/doc/classes/RenderingDevice.xml +++ b/doc/classes/RenderingDevice.xml @@ -1163,6 +1163,7 @@ The main graphics-compute command queue ([code]rid[/code] parameter is ignored). - Vulkan: [code]VkQueue[/code]. + - D3D12: [code]ID3D12CommandQueue[/code]. - Metal: [code]MTLCommandQueue[/code]. @@ -1171,6 +1172,7 @@ - Vulkan: [code]VkImage[/code]. + - D3D12: [code]ID3D12Resource[/code]. The view of an owned or shared texture. diff --git a/drivers/d3d12/rendering_device_driver_d3d12.cpp b/drivers/d3d12/rendering_device_driver_d3d12.cpp index de9b8522ad9..179adf4ceab 100644 --- a/drivers/d3d12/rendering_device_driver_d3d12.cpp +++ b/drivers/d3d12/rendering_device_driver_d3d12.cpp @@ -5679,14 +5679,18 @@ uint64_t RenderingDeviceDriverD3D12::get_resource_native_handle(DriverResource p return 0; } case DRIVER_RESOURCE_COMMAND_QUEUE: { - return (uint64_t)p_driver_id.id; + const CommandQueueInfo *cmd_queue_info = (const CommandQueueInfo *)p_driver_id.id; + return (uint64_t)cmd_queue_info->d3d_queue.Get(); } case DRIVER_RESOURCE_QUEUE_FAMILY: { return 0; } case DRIVER_RESOURCE_TEXTURE: { const TextureInfo *tex_info = (const TextureInfo *)p_driver_id.id; - return (uint64_t)tex_info->main_texture; + if (tex_info->main_texture) { + tex_info = tex_info->main_texture; + } + return (uint64_t)tex_info->resource; } break; case DRIVER_RESOURCE_TEXTURE_VIEW: { const TextureInfo *tex_info = (const TextureInfo *)p_driver_id.id;