Add texture_from_raw method for metal/dx12 device

This commit is contained in:
xiaopengli89
2021-10-28 15:36:48 +08:00
committed by Dzmitry Malyshau
parent 8568188558
commit cd9498d447
2 changed files with 36 additions and 0 deletions

View File

@@ -280,6 +280,24 @@ impl super::Device {
);
result
}
pub unsafe fn texture_from_raw(
resource: native::Resource,
format: wgt::TextureFormat,
dimension: wgt::TextureDimension,
size: wgt::Extent3d,
mip_level_count: u32,
sample_count: u32,
) -> super::Texture {
super::Texture {
resource,
format,
dimension,
size,
mip_level_count,
sample_count,
}
}
}
impl crate::Device<super::Api> for super::Device {

View File

@@ -174,6 +174,24 @@ impl super::Device {
.set_mutability(mtl::MTLMutability::Immutable);
}
}
pub unsafe fn texture_from_raw(
raw: mtl::Texture,
raw_format: mtl::MTLPixelFormat,
raw_type: mtl::MTLTextureType,
array_layers: u32,
mip_levels: u32,
copy_size: crate::CopyExtent,
) -> super::Texture {
super::Texture {
raw,
raw_format,
raw_type,
array_layers,
mip_levels,
copy_size,
}
}
}
impl crate::Device<super::Api> for super::Device {