Compare commits

..

2 Commits

Author SHA1 Message Date
molive 5afecc2c08 Change how depth format is picked 2025-12-01 19:45:53 +00:00
molive 5da5edf8aa Add build.rs 2025-12-01 19:45:36 +00:00
3 changed files with 67 additions and 31 deletions
+2
View File
@@ -1,3 +1,5 @@
#!/bin/bash
glslangValidator --spirv-val --spirv-dis -g0 -S frag --target-env vulkan1.3 --quiet src/trace.frag.glsl > src/trace.spv-dis
sed -i '/%11 =/,/OpFunctionEnd/d' src/trace.spv-dis
sed -i 's/%11\b/%1000/g' src/trace.spv-dis
+27
View File
@@ -0,0 +1,27 @@
use std::{fs::read_dir, io::Write, process::Command};
fn main() {
//let mut output = std::fs::File::create("output.txt").unwrap();
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=Cargo.lock");
let paths = read_dir("src").unwrap();
for path in paths {
if let Ok(path) = path {
if path
.path()
.extension()
.map(|ext| ext == "glsl")
.unwrap_or(false)
{
println!("cargo::rerun-if-changed={}", path.path().display());
//writeln!(output, "cargo::rerun-if-changed={}",
// path.path().display()).unwrap();
}
}
}
Command::new("bash")
.arg("assemble_trace.sh")
.status()
.expect("Failed to assemble header shaders");
}
+38 -31
View File
@@ -5,6 +5,7 @@
const DUMP_SPV_TO_FILE: bool = true;
const PIPELINE_CACHING: bool = false;
const IGNORE_STENCIL: bool = true;
const BYTECODE_IMITATES_GLSL: bool = false;
@@ -333,37 +334,37 @@ impl App {
physical_device.properties().device_type,
);
let depth_format = if physical_device
.format_properties(Format::D24_UNORM_S8_UINT)
.unwrap()
.optimal_tiling_features
.contains(FormatFeatures::DEPTH_STENCIL_ATTACHMENT)
{
Format::D24_UNORM_S8_UINT
} else if physical_device
.format_properties(Format::X8_D24_UNORM_PACK32)
.unwrap()
.optimal_tiling_features
.contains(FormatFeatures::DEPTH_STENCIL_ATTACHMENT)
{
Format::X8_D24_UNORM_PACK32
} else if physical_device
.format_properties(Format::D32_SFLOAT_S8_UINT)
.unwrap()
.optimal_tiling_features
.contains(FormatFeatures::DEPTH_STENCIL_ATTACHMENT)
{
Format::D32_SFLOAT_S8_UINT
} else if physical_device
.format_properties(Format::D16_UNORM_S8_UINT)
.unwrap()
.optimal_tiling_features
.contains(FormatFeatures::DEPTH_STENCIL_ATTACHMENT)
{
Format::D16_UNORM_S8_UINT
const DEPTH_FORMAT_ORDERING: [Format; 4] = [
Format::D24_UNORM_S8_UINT,
Format::X8_D24_UNORM_PACK32,
Format::D32_SFLOAT_S8_UINT,
Format::D16_UNORM_S8_UINT,
];
const DEPTH_FORMAT_ORDERING_IGNORE_STENCIL: [Format; 6] = [
Format::D32_SFLOAT,
Format::D24_UNORM_S8_UINT,
Format::X8_D24_UNORM_PACK32,
Format::D32_SFLOAT_S8_UINT,
Format::D16_UNORM,
Format::D16_UNORM_S8_UINT,
];
let depth_format = (if IGNORE_STENCIL {
DEPTH_FORMAT_ORDERING_IGNORE_STENCIL.iter()
} else {
panic!("Could not find suitable depth format!");
};
DEPTH_FORMAT_ORDERING.iter()
})
.filter(|format| {
physical_device
.format_properties(**format)
.unwrap()
.optimal_tiling_features
.contains(FormatFeatures::DEPTH_STENCIL_ATTACHMENT)
})
.next()
.expect("Could not find suitable depth format!")
.clone();
info!("Using depth format {:?}", depth_format);
@@ -1583,6 +1584,12 @@ impl App {
)
.unwrap();
let depth_clear = if self.depth_format.numeric_format_stencil().is_some() {
Some((0.0, 0).into())
} else {
Some((0.0).into())
};
builder
.begin_render_pass(
RenderPassBeginInfo {
@@ -1592,7 +1599,7 @@ impl App {
Some([0.12, 0.1, 0.1, 1.0].into()),
Some([0.0, 0.0, 0.0, 1.0].into()),
Some([0.0, 0.0, 0.0, 1.0].into()),
Some((0.0, 0).into()),
depth_clear,
],
..RenderPassBeginInfo::framebuffer(rcx.framebuffers[image_index].clone())
},