From cd9498d44738ef6f8e057ece6a42a6434175d8e3 Mon Sep 17 00:00:00 2001 From: xiaopengli89 Date: Thu, 28 Oct 2021 15:36:48 +0800 Subject: [PATCH] Add texture_from_raw method for metal/dx12 device --- wgpu-hal/src/dx12/device.rs | 18 ++++++++++++++++++ wgpu-hal/src/metal/device.rs | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/wgpu-hal/src/dx12/device.rs b/wgpu-hal/src/dx12/device.rs index 49be25e906..95eccb3b9b 100644 --- a/wgpu-hal/src/dx12/device.rs +++ b/wgpu-hal/src/dx12/device.rs @@ -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 for super::Device { diff --git a/wgpu-hal/src/metal/device.rs b/wgpu-hal/src/metal/device.rs index 91aa0a5e0c..da3a73ed10 100644 --- a/wgpu-hal/src/metal/device.rs +++ b/wgpu-hal/src/metal/device.rs @@ -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 for super::Device {