Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect aspects in barriers for depth+stencil images #2108

Merged
merged 2 commits into from
Dec 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions vulkano/src/command_buffer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ pub(crate) struct CommandBufferBufferUsage {

#[derive(Clone, Debug, PartialEq, Eq)]
pub(crate) struct CommandBufferBufferRangeUsage {
pub(crate) first_use: ResourceUseRef,
pub(crate) first_use: Option<ResourceUseRef>,
pub(crate) mutable: bool,
}

Expand All @@ -546,7 +546,7 @@ pub(crate) struct CommandBufferImageUsage {

#[derive(Clone, Debug, PartialEq, Eq)]
pub(crate) struct CommandBufferImageRangeUsage {
pub(crate) first_use: ResourceUseRef,
pub(crate) first_use: Option<ResourceUseRef>,
pub(crate) mutable: bool,
pub(crate) expected_layout: ImageLayout,
pub(crate) final_layout: ImageLayout,
Expand Down
19 changes: 16 additions & 3 deletions vulkano/src/command_buffer/synced/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use crate::{
},
descriptor_set::{DescriptorSetResources, DescriptorSetWithOffsets},
device::{Device, DeviceOwned},
image::{sys::Image, ImageAccess, ImageLayout, ImageSubresourceRange},
image::{sys::Image, ImageAccess, ImageAspects, ImageLayout, ImageSubresourceRange},
pipeline::{
graphics::{
color_blend::LogicOp,
Expand Down Expand Up @@ -539,6 +539,19 @@ impl SyncCommandBufferBuilder {
subresource_range.mip_levels.start += inner.first_mipmap_level;
subresource_range.mip_levels.end += inner.first_mipmap_level;

// VUID-VkImageMemoryBarrier2-image-03320
if !self
.device()
.enabled_features()
.separate_depth_stencil_layouts
&& image
.format()
.aspects()
.contains(ImageAspects::DEPTH | ImageAspects::STENCIL)
{
subresource_range.aspects = ImageAspects::DEPTH | ImageAspects::STENCIL;
}

let range_map = self.images2.entry(inner.image.clone()).or_insert_with(|| {
[(
0..inner.image.range_size(),
Expand Down Expand Up @@ -816,7 +829,7 @@ impl SyncCommandBufferBuilder {
.into_iter()
.filter(|(_range, state)| !state.resource_uses.is_empty())
.map(|(range, state)| {
let first_use = state.resource_uses.into_iter().next().unwrap();
let first_use = state.resource_uses.into_iter().next();
(
range,
CommandBufferBufferRangeUsage {
Expand Down Expand Up @@ -845,7 +858,7 @@ impl SyncCommandBufferBuilder {
state.current_layout = state.final_layout;
}

let first_use = state.resource_uses.into_iter().next().unwrap();
let first_use = state.resource_uses.into_iter().next();
(
range,
CommandBufferImageRangeUsage {
Expand Down
2 changes: 1 addition & 1 deletion vulkano/src/sync/future/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ pub enum FlushError {
/// Access to a resource has been denied.
ResourceAccessError {
error: AccessError,
use_ref: ResourceUseRef,
use_ref: Option<ResourceUseRef>,
},

/// The command buffer or one of the secondary command buffers it executes was created with the
Expand Down