Skip to content

Commit 5ac099b

Browse files
committed
rt(d3d12): clear rtv before rendering
1 parent 518325a commit 5ac099b

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

librashader-runtime-d3d12/src/filter_pass.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,12 @@ impl FilterPass {
202202
},
203203
}];
204204

205+
cmd.ClearRenderTargetView(
206+
*output.output.descriptor.as_ref(),
207+
&[0.0, 0.0, 0.0, 0.0],
208+
None,
209+
);
210+
205211
cmd.BeginRenderPass(Some(&pass), None, D3D12_RENDER_PASS_FLAG_NONE)
206212
}
207213

librashader-runtime-d3d12/src/framebuffer.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use std::mem::ManuallyDrop;
1818
use std::sync::Arc;
1919
use windows::core::Interface;
2020
use windows::Win32::Graphics::Direct3D12::{
21-
ID3D12Device, ID3D12GraphicsCommandList, ID3D12Resource, D3D12_BOX,
21+
ID3D12Device, ID3D12GraphicsCommandList, ID3D12Resource, D3D12_BOX, D3D12_CLEAR_VALUE,
2222
D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING, D3D12_FEATURE_DATA_FORMAT_SUPPORT,
2323
D3D12_FORMAT_SUPPORT1_MIP, D3D12_FORMAT_SUPPORT1_RENDER_TARGET,
2424
D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE, D3D12_FORMAT_SUPPORT1_TEXTURE2D,
@@ -121,7 +121,11 @@ impl OwnedImage {
121121
resource_category: ResourceCategory::RtvDsvTexture,
122122
resource_desc: &desc,
123123
castable_formats: &[],
124-
clear_value: None,
124+
clear_value: Some(&D3D12_CLEAR_VALUE {
125+
Format: desc.Format,
126+
// Default is fine since its just zeroes.
127+
Anonymous: Default::default(),
128+
}),
125129
initial_state_or_layout: ResourceStateOrBarrierLayout::ResourceState(
126130
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE,
127131
),

librashader-runtime-d3d12/tests/triangle.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use crate::hello_triangle::{DXSample, SampleCommandLine};
55
#[test]
66
fn triangle_d3d12() {
77
let sample = hello_triangle::d3d12_hello_triangle::Sample::new(
8-
"../test/shaders_slang/sonkun/slot-mask/flat-screen/1080p/test.slangp",
9-
// "../test/shaders_slang/crt/crt-royale.slangp",
8+
// "../test/shaders_slang/sonkun/slot-mask/flat-screen/1080p/test.slangp",
9+
"../test/shaders_slang/crt/crt-royale.slangp",
1010
// "../test/basic.slangp",
1111
// "../test/shaders_slang/handheld/console-border/gbc-lcd-grid-v2.slangp",
1212
// "../test/Mega_Bezel_Packs/Duimon-Mega-Bezel/Presets/Advanced/Nintendo_GBA_SP/GBA_SP-[ADV]-[LCD-GRID]-[Night].slangp",

0 commit comments

Comments
 (0)