Skip to content

Commit

Permalink
Fix incorrect aspect in barriers when using emulated Stencil8 textures.
Browse files Browse the repository at this point in the history
  • Loading branch information
cwfitzgerald committed Jun 5, 2023
1 parent ad45f29 commit 8265e25
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
6 changes: 5 additions & 1 deletion wgpu-hal/src/vulkan/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,11 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
vk_barriers.clear();

for bar in barriers {
let range = conv::map_subresource_range(&bar.range, bar.texture.format);
let range = conv::map_subresource_range_combined_aspect(
&bar.range,
bar.texture.format,
&self.device.private_caps,
);
let (src_stage, src_access) = conv::map_texture_usage_to_barrier(bar.usage.start);
let src_layout = conv::derive_image_layout(bar.usage.start, bar.texture.format);
src_stages |= src_stage;
Expand Down
14 changes: 14 additions & 0 deletions wgpu-hal/src/vulkan/conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,20 @@ pub fn map_subresource_range(
}
}

// Special subresource range mapping for dealing with barriers
// so that we account for the "hidden" depth aspect in emulated Stencil8.
pub(super) fn map_subresource_range_combined_aspect(
range: &wgt::ImageSubresourceRange,
format: wgt::TextureFormat,
private_caps: &super::PrivateCapabilities,
) -> vk::ImageSubresourceRange {
let mut range = map_subresource_range(range, format);
if !private_caps.texture_s8 && format == wgt::TextureFormat::Stencil8 {
range.aspect_mask |= vk::ImageAspectFlags::DEPTH;
}
range
}

pub fn map_subresource_layers(
base: &crate::TextureCopyBase,
) -> (vk::ImageSubresourceLayers, vk::Offset3D) {
Expand Down

0 comments on commit 8265e25

Please sign in to comment.