mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
Allows for depth texture copies
This commit is contained in:
committed by
Dzmitry Malyshau
parent
57b28cb90f
commit
f622c83a19
@@ -95,6 +95,8 @@ pub enum TransferError {
|
||||
CopyFromForbiddenTextureFormat(wgt::TextureFormat),
|
||||
#[error("copying to textures with format {0:?} is forbidden")]
|
||||
CopyToForbiddenTextureFormat(wgt::TextureFormat),
|
||||
#[error("the entire texture must be copied when copiying from depth texture")]
|
||||
InvalidDepthTextureExtent,
|
||||
}
|
||||
|
||||
impl PrettyError for TransferError {
|
||||
@@ -295,6 +297,17 @@ pub(crate) fn validate_texture_copy_range(
|
||||
// physical size can be larger than the virtual
|
||||
let extent = extent_virtual.physical_size(desc.format);
|
||||
|
||||
match desc.format {
|
||||
wgt::TextureFormat::Depth32Float
|
||||
| wgt::TextureFormat::Depth24Plus
|
||||
| wgt::TextureFormat::Depth24PlusStencil8 => {
|
||||
if *copy_size != extent {
|
||||
return Err(TransferError::InvalidDepthTextureExtent);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
let x_copy_max = texture_copy_view.origin.x + copy_size.width;
|
||||
if x_copy_max > extent.width {
|
||||
return Err(TransferError::TextureOverrun {
|
||||
|
||||
@@ -653,19 +653,6 @@ impl<A: HalApi> Device<A> {
|
||||
.describe_format_features(adapter, desc.format)
|
||||
.map_err(|error| resource::CreateTextureError::MissingFeatures(desc.format, error))?;
|
||||
|
||||
// Ensure `D24Plus` textures cannot be copied
|
||||
match desc.format {
|
||||
TextureFormat::Depth24Plus | TextureFormat::Depth24PlusStencil8 => {
|
||||
if desc
|
||||
.usage
|
||||
.intersects(wgt::TextureUsages::COPY_SRC | wgt::TextureUsages::COPY_DST)
|
||||
{
|
||||
return Err(resource::CreateTextureError::CannotCopyD24Plus);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
if desc.usage.is_empty() {
|
||||
return Err(resource::CreateTextureError::EmptyUsage);
|
||||
}
|
||||
|
||||
@@ -255,8 +255,6 @@ pub enum TextureDimensionError {
|
||||
pub enum CreateTextureError {
|
||||
#[error(transparent)]
|
||||
Device(#[from] DeviceError),
|
||||
#[error("D24Plus textures cannot be copied")]
|
||||
CannotCopyD24Plus,
|
||||
#[error("Textures cannot have empty usage flags")]
|
||||
EmptyUsage,
|
||||
#[error(transparent)]
|
||||
|
||||
Reference in New Issue
Block a user