From 720c23161ff6543d7d42e5c61b01da296e67b2f0 Mon Sep 17 00:00:00 2001 From: Yaekai <21324379+Yaekai@users.noreply.github.com> Date: Tue, 24 Nov 2026 00:59:49 +0100 Subject: [PATCH] GPU: emit null buffer SRV/UAV when descriptor names a buffer with null resource When a title creates a null buffer view (resource == 0, ViewDimension == BUFFER), buffer_bytes(0) returns None, so null_for() fell through to null_like() / null_view() (or a 2D texture UAV) and emitted a 2D texture descriptor into a slot where a shader expects a buffer. Check desc[1] == 1 (D3D12_SRV_DIMENSION_BUFFER / D3D12_UAV_DIMENSION_BUFFER) in null_for() for both View::Shader and View::Unordered so null buffer views get a matching null buffer descriptor. --- crates/victory-gpu/src/descriptor/host.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/victory-gpu/src/descriptor/host.rs b/crates/victory-gpu/src/descriptor/host.rs index ccc295f..f652c4a 100644 --- a/crates/victory-gpu/src/descriptor/host.rs +++ b/crates/victory-gpu/src/descriptor/host.rs @@ -735,13 +735,15 @@ fn null_for(view: &View, at: D3D12_CPU_DESCRIPTOR_HANDLE) { let Some(host) = host() else { return }; let is_buffer = |r: &usize| crate::resource::buffer_bytes(*r as crate::object::This).is_some(); let buffer = match view { - View::Unordered(r, _, _) => is_buffer(r), + View::Unordered(r, _, desc) => is_buffer(r) || desc.is_some_and(|d| d[1] == 1), View::Placed(true, resource, _) => resource[0] == 1, // Shader views of buffers read nothing through a null buffer view: // a null 2D view where the shader expects a buffer is a mismatch // the hardware does not survive in general (GPU-based validation // reports it). - View::Shader(r, _) if is_buffer(r) => return null_buffer_view(at), + View::Shader(r, desc) if is_buffer(r) || desc.is_some_and(|d| d[1] == 1) => { + return null_buffer_view(at); + } View::Placed(false, resource, _) if resource[0] == 1 => return null_buffer_view(at), // Textures: a null view of the title's dimension (1D, arrays, 3D, // cubes), not always 2D.