Skip to content

Commit

Permalink
Merge #2336
Browse files Browse the repository at this point in the history
2336: [mtl] Fix A2BGR10 format mapping r=kvark a=kvark

Fixes Dota2 after #2116 
PR checklist:
- [ ] `make` succeeds (on *nix)
- [ ] `make reftests` succeeds
- [ ] tested examples with the following backends:
- [ ] `rustfmt` run on changed code


Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
  • Loading branch information
bors[bot] and kvark committed Aug 23, 2018
2 parents 174a4ff + d2fc174 commit f87b721
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 25 deletions.
49 changes: 32 additions & 17 deletions src/backend/metal/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3343,11 +3343,16 @@ impl com::RawCommandBuffer<Backend> for CommandBuffer {
retained_textures.last().unwrap()
};

let commands = regions.into_iter().map(|region| {
soft::BlitCommand::CopyImage {
src: AsNative::from(new_src),
dst: AsNative::from(dst.raw.as_ref()),
region: region.borrow().clone(),
let commands = regions.into_iter().filter_map(|region| {
let r = region.borrow();
if r.extent.is_empty() {
None
} else {
Some(soft::BlitCommand::CopyImage {
src: AsNative::from(new_src),
dst: AsNative::from(dst.raw.as_ref()),
region: r.clone(),
})
}
});
sink.as_mut()
Expand All @@ -3366,12 +3371,17 @@ impl com::RawCommandBuffer<Backend> for CommandBuffer {
T::Item: Borrow<com::BufferImageCopy>,
{
// FIXME: layout
let commands = regions.into_iter().map(|region| {
soft::BlitCommand::CopyBufferToImage {
src: AsNative::from(src.raw.as_ref()),
dst: AsNative::from(dst.raw.as_ref()),
dst_desc: dst.format_desc,
region: region.borrow().clone(),
let commands = regions.into_iter().filter_map(|region| {
let r = region.borrow();
if r.image_extent.is_empty() {
None
} else {
Some(soft::BlitCommand::CopyBufferToImage {
src: AsNative::from(src.raw.as_ref()),
dst: AsNative::from(dst.raw.as_ref()),
dst_desc: dst.format_desc,
region: r.clone(),
})
}
});
self.inner
Expand All @@ -3391,12 +3401,17 @@ impl com::RawCommandBuffer<Backend> for CommandBuffer {
T::Item: Borrow<com::BufferImageCopy>,
{
// FIXME: layout
let commands = regions.into_iter().map(|region| {
soft::BlitCommand::CopyImageToBuffer {
src: AsNative::from(src.raw.as_ref()),
src_desc: src.format_desc,
dst: AsNative::from(dst.raw.as_ref()),
region: region.borrow().clone(),
let commands = regions.into_iter().filter_map(|region| {
let r = region.borrow();
if r.image_extent.is_empty() {
None
} else {
Some(soft::BlitCommand::CopyImageToBuffer {
src: AsNative::from(src.raw.as_ref()),
src_desc: src.format_desc,
dst: AsNative::from(dst.raw.as_ref()),
region: r.clone(),
})
}
});
self.inner
Expand Down
19 changes: 11 additions & 8 deletions src/backend/metal/src/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl PrivateCapabilities {
f::Rgba8Srgb if self.format_min_srgb_channels <= 4 => RGBA8Unorm_sRGB,
f::Bgra8Srgb if self.format_min_srgb_channels <= 4 => BGRA8Unorm_sRGB,
f::D24UnormS8Uint if self.format_depth24_stencil8 => Depth24Unorm_Stencil8,
f::D32FloatS8Uint if self.format_depth32_stencil8_filter || self.format_depth32_stencil8_none => Depth32Float_Stencil8,
f::D32FloatS8Uint if self.format_depth32_stencil8_filter => Depth32Float_Stencil8,
f::R8Unorm => R8Unorm,
f::R8Inorm => R8Snorm,
f::R8Uint => R8Uint,
Expand Down Expand Up @@ -46,8 +46,8 @@ impl PrivateCapabilities {
f::Rgba16Uint => RGBA16Uint,
f::Rgba16Int => RGBA16Sint,
f::Rgba16Float => RGBA16Float,
f::A2r10g10b10Unorm => RGB10A2Unorm,
f::A2r10g10b10Uint => RGB10A2Uint,
f::A2r10g10b10Unorm => BGR10A2Unorm,
f::A2b10g10r10Unorm => RGB10A2Unorm,
f::B10g11r11Ufloat => RG11B10Float,
f::E5b9g9r9Ufloat => RGB9E5Float,
f::R32Uint => R32Uint,
Expand Down Expand Up @@ -885,12 +885,14 @@ impl PrivateCapabilities {
..defaults
},
Depth16Unorm if self.format_depth16unorm => Properties {
optimal_tiling: defaults.optimal_tiling
optimal_tiling: defaults.optimal_tiling
| If::DEPTH_STENCIL_ATTACHMENT
| If::SAMPLED_LINEAR,
..defaults
},
Depth32Float if self.format_depth32float_filter => Properties {
optimal_tiling: defaults.optimal_tiling
optimal_tiling: defaults.optimal_tiling
| If::DEPTH_STENCIL_ATTACHMENT
| If::SAMPLED_LINEAR,
..defaults
},
Expand All @@ -903,12 +905,13 @@ impl PrivateCapabilities {
..defaults
},
Depth24Unorm_Stencil8 if self.format_depth24_stencil8 => Properties {
optimal_tiling: defaults.optimal_tiling
| If::SAMPLED_LINEAR,
optimal_tiling: defaults.optimal_tiling
| If::DEPTH_STENCIL_ATTACHMENT,
..defaults
},
Depth32Float_Stencil8 if self.format_depth32_stencil8_filter => Properties {
optimal_tiling: defaults.optimal_tiling
optimal_tiling: defaults.optimal_tiling
| If::DEPTH_STENCIL_ATTACHMENT
| If::SAMPLED_LINEAR,
..defaults
},
Expand Down
4 changes: 4 additions & 0 deletions src/hal/src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ pub struct Extent {
}

impl Extent {
/// Return true if one of the dimensions is zero.
pub fn is_empty(&self) -> bool {
self.width == 0 || self.height == 0 || self.depth == 0
}
/// Get the extent at a particular mipmap level.
pub fn at_level(&self, level: Level) -> Self {
Extent {
Expand Down

0 comments on commit f87b721

Please sign in to comment.