From 2d8c09d9cb10a4fbcd8c67ddd2b4f7f0fb158424 Mon Sep 17 00:00:00 2001 From: bmjask <> Date: Wed, 25 Nov 2026 22:57:14 -0800 Subject: [PATCH] D3D12.X: match texture downloads to writer queues Carry the source writer queue type in immutable texture download plans. Record and submit on the same DIRECT or COMPUTE type, while rejecting COPY queues and type/device mismatches before ownership transfer or execution. This remains a non-activated preparation for ordered pre-Signal downloads. Assisted-by: Codex (GPT-5.6-sol) --- crates/xcl/src/hle/d3d12x/title_textures.rs | 26 +++++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/crates/xcl/src/hle/d3d12x/title_textures.rs b/crates/xcl/src/hle/d3d12x/title_textures.rs index 99ba2e91bf..ddef51322f 100644 --- a/crates/xcl/src/hle/d3d12x/title_textures.rs +++ b/crates/xcl/src/hle/d3d12x/title_textures.rs @@ -2034,6 +2034,7 @@ struct DownloadObjects { #[allow(dead_code)] pub(super) struct TextureDownloadPlan { device: ID3D12Device, + queue_type: D3D12_COMMAND_LIST_TYPE, tex: Arc, source: ID3D12Resource, readback: ID3D12Resource, @@ -2118,10 +2119,10 @@ impl TextureDownloadPlan { pub unsafe fn submit(self, queue: &ID3D12CommandQueue) -> Result { let mut queue_device: Option = None; queue.GetDevice(&mut queue_device).map_err(|e| e.to_string())?; - if queue.GetDesc().Type != D3D12_COMMAND_LIST_TYPE_DIRECT + if queue.GetDesc().Type != self.queue_type || queue_device.as_ref().is_none_or(|d| d.as_raw() != self.device.as_raw()) { - return Err("texture download requires a direct queue from its source device".into()); + return Err("texture download queue type or source device differs from its plan".into()); } let mut pending = PendingDownload { tex: self.tex, @@ -2148,15 +2149,23 @@ impl TextureDownloadPlan { } } +fn download_queue_type_supported(ty: D3D12_COMMAND_LIST_TYPE) -> bool { + matches!(ty, D3D12_COMMAND_LIST_TYPE_DIRECT | D3D12_COMMAND_LIST_TYPE_COMPUTE) +} + /// Build but do not submit a download. Preparation performs no global lookup or queue operation. #[allow(dead_code)] pub(super) unsafe fn prepare_texture_download( dev: &ID3D12Device, source: &ID3D12Resource, + queue_type: D3D12_COMMAND_LIST_TYPE, tex: Arc, format: u32, selected: &[(u32, D3D12_RESOURCE_STATES)], ) -> Result { + if !download_queue_type_supported(queue_type) { + return Err("texture download requires a direct or compute queue".into()); + } let mut source_device: Option = None; source.GetDevice(&mut source_device).map_err(|e| e.to_string())?; if source_device.as_ref().is_none_or(|d| d.as_raw() != dev.as_raw()) { @@ -2180,8 +2189,8 @@ pub(super) unsafe fn prepare_texture_download( .ok_or("driver footprint overflow")?; } let (footprints, bytes) = validate_download_layout(&tex, &desc, format, selected, &queried)?; - let allocator = dev.CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT).map_err(|e| e.to_string())?; - let graphics: ID3D12GraphicsCommandList = dev.CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, &allocator, None).map_err(|e| e.to_string())?; + let allocator = dev.CreateCommandAllocator(queue_type).map_err(|e| e.to_string())?; + let graphics: ID3D12GraphicsCommandList = dev.CreateCommandList(0, queue_type, &allocator, None).map_err(|e| e.to_string())?; let mut readback = None; dev.CreateCommittedResource( &D3D12_HEAP_PROPERTIES { Type: D3D12_HEAP_TYPE_READBACK, ..Default::default() }, @@ -2225,7 +2234,7 @@ pub(super) unsafe fn prepare_texture_download( graphics.Close().map_err(|e| e.to_string())?; let list: ID3D12CommandList = graphics.cast().map_err(|e| e.to_string())?; let fence = dev.CreateFence(0, D3D12_FENCE_FLAG_NONE).map_err(|e| e.to_string())?; - Ok(TextureDownloadPlan { device: dev.clone(), tex, source: source.clone(), readback, allocator, list, fence, footprints, bytes }) + Ok(TextureDownloadPlan { device: dev.clone(), queue_type, tex, source: source.clone(), readback, allocator, list, fence, footprints, bytes }) } @@ -3034,6 +3043,13 @@ mod tests { .collect() } + #[test] + fn download_plans_use_writer_capable_queue_types() { + assert!(download_queue_type_supported(D3D12_COMMAND_LIST_TYPE_DIRECT)); + assert!(download_queue_type_supported(D3D12_COMMAND_LIST_TYPE_COMPUTE)); + assert!(!download_queue_type_supported(D3D12_COMMAND_LIST_TYPE_COPY)); + } + #[test] fn download_layout_preserves_explicit_states_and_bounds_array_and_volume_footprints() { let array_desc = console_desc(3, 17, 9, 2, 3, 28, 0x105);