From dd0f4d6991552588839ee4ecbd8f8652f502c309 Mon Sep 17 00:00:00 2001 From: panxinmiao Date: Tue, 18 Nov 2025 15:38:48 +0800 Subject: [PATCH] adds support for configuring the Dx12 presentation system --- ffi/wgpu.h | 8 ++++++++ src/conv.rs | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/ffi/wgpu.h b/ffi/wgpu.h index 272ed23a..b53435d4 100644 --- a/ffi/wgpu.h +++ b/ffi/wgpu.h @@ -137,6 +137,13 @@ typedef enum WGPUGLFenceBehaviour { WGPUGLFenceBehaviour_Force32 = 0x7FFFFFFF } WGPUGLFenceBehaviour; +typedef enum WGPUDx12SwapchainKind { + WGPUDx12SwapchainKind_Undefined = 0x00000000, + WGPUDx12SwapchainKind_DxgiFromHwnd = 0x00000001, + WGPUDx12SwapchainKind_DxgiFromVisual = 0x00000002, + WGPUDx12SwapchainKind_Force32 = 0x7FFFFFFF +} WGPUDx12SwapchainKind; + typedef struct WGPUInstanceExtras { WGPUChainedStruct chain; WGPUInstanceBackend backends; @@ -146,6 +153,7 @@ typedef struct WGPUInstanceExtras { WGPUGLFenceBehaviour glFenceBehaviour; WGPUStringView dxcPath; WGPUDxcMaxShaderModel dxcMaxShaderModel; + WGPUDx12SwapchainKind dx12PresentationSystem; WGPU_NULLABLE const uint8_t* budgetForDeviceCreation; WGPU_NULLABLE const uint8_t* budgetForDeviceLoss; diff --git a/src/conv.rs b/src/conv.rs index 946530d7..1e742d2d 100644 --- a/src/conv.rs +++ b/src/conv.rs @@ -332,6 +332,12 @@ pub unsafe fn map_instance_descriptor( _ => wgt::Dx12Compiler::default(), }; + let dx12_presentation_system = match extras.dx12PresentationSystem { + native::WGPUDx12SwapchainKind_DxgiFromHwnd => wgt::Dx12SwapchainKind::DxgiFromHwnd, + native::WGPUDx12SwapchainKind_DxgiFromVisual => wgt::Dx12SwapchainKind::DxgiFromVisual, + _ => wgt::Dx12SwapchainKind::default(), + }; + let for_resource_creation = unsafe { extras.budgetForDeviceCreation.as_ref() }.copied(); let for_device_loss = unsafe { extras.budgetForDeviceCreation.as_ref() }.copied(); @@ -344,6 +350,7 @@ pub unsafe fn map_instance_descriptor( }, dx12: wgt::Dx12BackendOptions { shader_compiler: dx12_shader_compiler, + presentation_system: dx12_presentation_system, ..Default::default() }, noop: Default::default(),