diff --git a/wgpu-hal/src/dx12/mod.rs b/wgpu-hal/src/dx12/mod.rs index c9ca02f97..3dbb58abb 100644 --- a/wgpu-hal/src/dx12/mod.rs +++ b/wgpu-hal/src/dx12/mod.rs @@ -452,6 +452,8 @@ pub struct Texture { allocation: Option, } +impl crate::DynTexture for Texture {} + unsafe impl Send for Texture {} unsafe impl Sync for Texture {} @@ -491,6 +493,8 @@ pub struct TextureView { handle_dsv_rw: Option, } +impl crate::DynTextureView for TextureView {} + unsafe impl Send for TextureView {} unsafe impl Sync for TextureView {} diff --git a/wgpu-hal/src/dynamic/mod.rs b/wgpu-hal/src/dynamic/mod.rs index be342c42e..10cea187c 100644 --- a/wgpu-hal/src/dynamic/mod.rs +++ b/wgpu-hal/src/dynamic/mod.rs @@ -88,10 +88,12 @@ impl DynResourceExt for R { pub trait DynBindGroup: DynResource + std::fmt::Debug {} pub trait DynBuffer: DynResource + std::fmt::Debug {} +pub trait DynComputePipeline: DynResource + std::fmt::Debug {} pub trait DynPipelineLayout: DynResource + std::fmt::Debug {} pub trait DynQuerySet: DynResource + std::fmt::Debug {} pub trait DynRenderPipeline: DynResource + std::fmt::Debug {} -pub trait DynComputePipeline: DynResource + std::fmt::Debug {} +pub trait DynTexture: DynResource + std::fmt::Debug {} +pub trait DynTextureView: DynResource + std::fmt::Debug {} impl<'a> BufferBinding<'a, dyn DynBuffer> { pub fn expect_downcast(self) -> BufferBinding<'a, B> { diff --git a/wgpu-hal/src/empty.rs b/wgpu-hal/src/empty.rs index 06325e9a9..f63df91e9 100644 --- a/wgpu-hal/src/empty.rs +++ b/wgpu-hal/src/empty.rs @@ -44,10 +44,12 @@ crate::impl_dyn_resource!(Context, Encoder, Resource); impl crate::DynBindGroup for Resource {} impl crate::DynBuffer for Resource {} +impl crate::DynComputePipeline for Resource {} impl crate::DynPipelineLayout for Resource {} impl crate::DynQuerySet for Resource {} impl crate::DynRenderPipeline for Resource {} -impl crate::DynComputePipeline for Resource {} +impl crate::DynTexture for Resource {} +impl crate::DynTextureView for Resource {} impl crate::Instance for Context { type A = Api; diff --git a/wgpu-hal/src/gles/mod.rs b/wgpu-hal/src/gles/mod.rs index 940a8e679..570973520 100644 --- a/wgpu-hal/src/gles/mod.rs +++ b/wgpu-hal/src/gles/mod.rs @@ -373,6 +373,8 @@ pub struct Texture { pub copy_size: CopyExtent, } +impl crate::DynTexture for Texture {} + impl Texture { pub fn default_framebuffer(format: wgt::TextureFormat) -> Self { Self { @@ -460,6 +462,8 @@ pub struct TextureView { format: wgt::TextureFormat, } +impl crate::DynTextureView for TextureView {} + #[derive(Debug)] pub struct Sampler { raw: glow::Sampler, diff --git a/wgpu-hal/src/lib.rs b/wgpu-hal/src/lib.rs index 07ce7c7e8..ab119fc35 100644 --- a/wgpu-hal/src/lib.rs +++ b/wgpu-hal/src/lib.rs @@ -267,7 +267,7 @@ mod dynamic; pub(crate) use dynamic::{impl_dyn_resource, DynResource}; pub use dynamic::{ DynBindGroup, DynBuffer, DynCommandEncoder, DynComputePipeline, DynPipelineLayout, DynQuerySet, - DynRenderPipeline, + DynRenderPipeline, DynTexture, DynTextureView, }; use std::{ @@ -408,9 +408,9 @@ pub trait Api: Clone + fmt::Debug + Sized { type CommandBuffer: WasmNotSendSync + fmt::Debug; type Buffer: DynBuffer; - type Texture: fmt::Debug + WasmNotSendSync + 'static; + type Texture: DynTexture; type SurfaceTexture: fmt::Debug + WasmNotSendSync + Borrow; - type TextureView: fmt::Debug + WasmNotSendSync; + type TextureView: DynTextureView; type Sampler: fmt::Debug + WasmNotSendSync; type QuerySet: DynQuerySet; diff --git a/wgpu-hal/src/metal/mod.rs b/wgpu-hal/src/metal/mod.rs index be4b7c23b..a7282ca4c 100644 --- a/wgpu-hal/src/metal/mod.rs +++ b/wgpu-hal/src/metal/mod.rs @@ -505,6 +505,8 @@ pub struct Texture { copy_size: crate::CopyExtent, } +impl crate::DynTexture for Texture {} + unsafe impl Send for Texture {} unsafe impl Sync for Texture {} @@ -514,6 +516,8 @@ pub struct TextureView { aspects: crate::FormatAspects, } +impl crate::DynTextureView for TextureView {} + unsafe impl Send for TextureView {} unsafe impl Sync for TextureView {} diff --git a/wgpu-hal/src/vulkan/mod.rs b/wgpu-hal/src/vulkan/mod.rs index b8b669057..2d4a97173 100644 --- a/wgpu-hal/src/vulkan/mod.rs +++ b/wgpu-hal/src/vulkan/mod.rs @@ -671,6 +671,8 @@ pub struct Texture { view_formats: Vec, } +impl crate::DynTexture for Texture {} + impl Texture { /// # Safety /// @@ -687,6 +689,8 @@ pub struct TextureView { attachment: FramebufferAttachment, } +impl crate::DynTextureView for TextureView {} + impl TextureView { /// # Safety ///