Change how depth format is picked
This commit is contained in:
+38
-31
@@ -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())
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user