Skip to content

Commit

Permalink
test(d3d12): Add D3D12 render test
Browse files Browse the repository at this point in the history
  • Loading branch information
chyyran committed Sep 26, 2024
1 parent 379941c commit 445b0ad
Show file tree
Hide file tree
Showing 5 changed files with 676 additions and 6 deletions.
2 changes: 1 addition & 1 deletion librashader-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ opengl = ["librashader/runtime-gl", "dep:glow", "dep:glfw"]
wgpu = ["librashader/runtime-wgpu", "dep:wgpu", "dep:wgpu-types"]

d3d11 = ["librashader/runtime-d3d11", "dep:windows"]
d3d12 = ["librashader/runtime-d3d12", "dep:windows"]
d3d12 = ["librashader/runtime-d3d12", "dep:windows", "dep:d3d12-descriptor-heap"]
d3d9 = ["librashader/runtime-d3d9", "dep:windows"]

metal = ["librashader/runtime-metal", "dep:objc2", "dep:objc2-metal"]
Expand Down
35 changes: 35 additions & 0 deletions librashader-test/src/render/d3d12/descriptor_heap.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use d3d12_descriptor_heap::D3D12DescriptorHeapType;
use windows::Win32::Graphics::Direct3D12::{
D3D12_DESCRIPTOR_HEAP_DESC, D3D12_DESCRIPTOR_HEAP_FLAG_NONE,
D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, D3D12_DESCRIPTOR_HEAP_TYPE_RTV,
};

#[derive(Clone)]
pub struct CpuStagingHeap;

#[derive(Clone)]
pub struct RenderTargetHeap;

impl D3D12DescriptorHeapType for RenderTargetHeap {
// Lut texture heaps are CPU only and get bound to the descriptor heap of the shader.
fn create_desc(size: usize) -> D3D12_DESCRIPTOR_HEAP_DESC {
D3D12_DESCRIPTOR_HEAP_DESC {
Type: D3D12_DESCRIPTOR_HEAP_TYPE_RTV,
NumDescriptors: size as u32,
Flags: D3D12_DESCRIPTOR_HEAP_FLAG_NONE,
NodeMask: 0,
}
}
}

impl D3D12DescriptorHeapType for CpuStagingHeap {
// Lut texture heaps are CPU only and get bound to the descriptor heap of the shader.
fn create_desc(size: usize) -> D3D12_DESCRIPTOR_HEAP_DESC {
D3D12_DESCRIPTOR_HEAP_DESC {
Type: D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV,
NumDescriptors: size as u32,
Flags: D3D12_DESCRIPTOR_HEAP_FLAG_NONE,
NodeMask: 0,
}
}
}
Loading

0 comments on commit 445b0ad

Please sign in to comment.