rt(d3d12): replace let_chains with stable alternatives

This commit is contained in:
chyyran 2024-09-14 01:33:36 -04:00 committed by Ronny Chan
parent ab9ab6fe68
commit b432a1e02d
4 changed files with 41 additions and 30 deletions

View file

@ -535,7 +535,12 @@ impl FilterChainD3D12 {
.into(); .into();
// incredibly cursed. // incredibly cursed.
let (reflection, graphics_pipeline) = let (reflection, graphics_pipeline) = 'pipeline: {
'dxil: {
if force_hlsl {
break 'dxil;
}
if let Ok(graphics_pipeline) = D3D12GraphicsPipeline::new_from_dxil( if let Ok(graphics_pipeline) = D3D12GraphicsPipeline::new_from_dxil(
device, device,
library, library,
@ -544,10 +549,11 @@ impl FilterChainD3D12 {
root_signature, root_signature,
render_format, render_format,
disable_cache, disable_cache,
) && !force_hlsl ) {
{ break 'pipeline (dxil_reflection, graphics_pipeline);
(dxil_reflection, graphics_pipeline) }
} else { }
let hlsl_reflection = hlsl.reflect(index, semantics)?; let hlsl_reflection = hlsl.reflect(index, semantics)?;
let hlsl = hlsl.compile(Some( let hlsl = hlsl.compile(Some(
librashader_reflect::back::hlsl::HlslShaderModel::ShaderModel6_0, librashader_reflect::back::hlsl::HlslShaderModel::ShaderModel6_0,

View file

@ -160,14 +160,20 @@ impl FilterPass {
source, source,
); );
if let Some(ubo) = &self.reflection.ubo if self
&& ubo.size != 0 .reflection
.ubo
.as_ref()
.is_some_and(|ubo| ubo.size != 0)
{ {
self.uniform_storage.inner_ubo().bind_cbv(2, cmd); self.uniform_storage.inner_ubo().bind_cbv(2, cmd);
} }
if let Some(push) = &self.reflection.push_constant if self
&& push.size != 0 .reflection
.push_constant
.as_ref()
.is_some_and(|push| push.size != 0)
{ {
self.uniform_storage.inner_push().bind_cbv(3, cmd); self.uniform_storage.inner_push().bind_cbv(3, cmd);
} }

View file

@ -1,6 +1,5 @@
#![cfg(target_os = "windows")] #![cfg(target_os = "windows")]
#![deny(unsafe_op_in_unsafe_fn)] #![deny(unsafe_op_in_unsafe_fn)]
#![feature(let_chains)]
#![feature(type_alias_impl_trait)] #![feature(type_alias_impl_trait)]
mod buffer; mod buffer;

View file

@ -5,14 +5,14 @@ use crate::hello_triangle::{DXSample, SampleCommandLine};
#[test] #[test]
fn triangle_d3d12() { fn triangle_d3d12() {
let sample = hello_triangle::d3d12_hello_triangle::Sample::new( let sample = hello_triangle::d3d12_hello_triangle::Sample::new(
// "../test/shaders_slang/bezel/Mega_Bezel/Presets/MBZ__0__SMOOTH-ADV.slangp", "../test/shaders_slang/bezel/Mega_Bezel/Presets/MBZ__0__SMOOTH-ADV.slangp",
// "../test/shaders_slang/crt/crt-lottes.slangp", // "../test/shaders_slang/crt/crt-lottes.slangp",
// "../test/basic.slangp", // "../test/basic.slangp",
// "../test/shaders_slang/handheld/console-border/gbc-lcd-grid-v2.slangp", // "../test/shaders_slang/handheld/console-border/gbc-lcd-grid-v2.slangp",
// "../test/Mega_Bezel_Packs/Duimon-Mega-Bezel/Presets/Advanced/Nintendo_GBA_SP/GBA_SP-[ADV]-[LCD-GRID]-[Night].slangp", // "../test/Mega_Bezel_Packs/Duimon-Mega-Bezel/Presets/Advanced/Nintendo_GBA_SP/GBA_SP-[ADV]-[LCD-GRID]-[Night].slangp",
// "../test/shaders_slang/test/feedback.slangp", // "../test/shaders_slang/test/feedback.slangp",
// "../test/shaders_slang/test/history.slangp", // "../test/shaders_slang/test/history.slangp",
"../test/shaders_slang/crt/crt-geom-deluxe.slangp", // "../test/shaders_slang/crt/crt-geom-deluxe.slangp",
// "../test/slang-shaders/vhs/VHSPro.slangp", // "../test/slang-shaders/vhs/VHSPro.slangp",
&SampleCommandLine { &SampleCommandLine {
use_warp_device: false, use_warp_device: false,