From 70f76411938923f659f72e7c3fcbf653237d873a Mon Sep 17 00:00:00 2001 From: Andreas Reich Date: Sun, 21 Jul 2024 12:04:44 +0200 Subject: [PATCH] impl DynSurfaceTexture for all surface textures --- wgpu-hal/src/dx12/mod.rs | 1 + wgpu-hal/src/dynamic/mod.rs | 1 + wgpu-hal/src/empty.rs | 1 + wgpu-hal/src/gles/mod.rs | 1 + wgpu-hal/src/lib.rs | 4 ++-- wgpu-hal/src/metal/mod.rs | 3 +++ wgpu-hal/src/vulkan/mod.rs | 3 +++ 7 files changed, 12 insertions(+), 2 deletions(-) diff --git a/wgpu-hal/src/dx12/mod.rs b/wgpu-hal/src/dx12/mod.rs index 8267f7f4b..44a56a244 100644 --- a/wgpu-hal/src/dx12/mod.rs +++ b/wgpu-hal/src/dx12/mod.rs @@ -456,6 +456,7 @@ pub struct Texture { } impl crate::DynTexture for Texture {} +impl crate::DynSurfaceTexture for Texture {} unsafe impl Send for Texture {} unsafe impl Sync for Texture {} diff --git a/wgpu-hal/src/dynamic/mod.rs b/wgpu-hal/src/dynamic/mod.rs index 0262d4fbb..a7e343ad4 100644 --- a/wgpu-hal/src/dynamic/mod.rs +++ b/wgpu-hal/src/dynamic/mod.rs @@ -101,6 +101,7 @@ pub trait DynQuerySet: DynResource + std::fmt::Debug {} pub trait DynRenderPipeline: DynResource + std::fmt::Debug {} pub trait DynSampler: DynResource + std::fmt::Debug {} pub trait DynShaderModule: DynResource + std::fmt::Debug {} +pub trait DynSurfaceTexture: DynResource + std::fmt::Debug {} pub trait DynTexture: DynResource + std::fmt::Debug {} pub trait DynTextureView: DynResource + std::fmt::Debug {} diff --git a/wgpu-hal/src/empty.rs b/wgpu-hal/src/empty.rs index 0e7f43073..37723326b 100644 --- a/wgpu-hal/src/empty.rs +++ b/wgpu-hal/src/empty.rs @@ -51,6 +51,7 @@ impl crate::DynPipelineLayout for Resource {} impl crate::DynQuerySet for Resource {} impl crate::DynRenderPipeline for Resource {} impl crate::DynShaderModule for Resource {} +impl crate::DynSurfaceTexture for Resource {} impl crate::DynTexture for Resource {} impl crate::DynTextureView for Resource {} diff --git a/wgpu-hal/src/gles/mod.rs b/wgpu-hal/src/gles/mod.rs index 412424a85..2e76871b1 100644 --- a/wgpu-hal/src/gles/mod.rs +++ b/wgpu-hal/src/gles/mod.rs @@ -375,6 +375,7 @@ pub struct Texture { } impl crate::DynTexture for Texture {} +impl crate::DynSurfaceTexture for Texture {} impl Texture { pub fn default_framebuffer(format: wgt::TextureFormat) -> Self { diff --git a/wgpu-hal/src/lib.rs b/wgpu-hal/src/lib.rs index 6ae5d6bdc..9a80eea6c 100644 --- a/wgpu-hal/src/lib.rs +++ b/wgpu-hal/src/lib.rs @@ -269,7 +269,7 @@ pub use dynamic::{ DynAccelerationStructure, DynBindGroup, DynBindGroupLayout, DynBuffer, DynCommandBuffer, DynCommandEncoder, DynComputePipeline, DynDevice, DynFence, DynPipelineCache, DynPipelineLayout, DynQuerySet, DynRenderPipeline, DynResource, DynSampler, DynShaderModule, - DynTexture, DynTextureView, + DynSurfaceTexture, DynTexture, DynTextureView, }; use std::{ @@ -411,7 +411,7 @@ pub trait Api: Clone + fmt::Debug + Sized { type Buffer: DynBuffer; type Texture: DynTexture; - type SurfaceTexture: fmt::Debug + WasmNotSendSync + Borrow; + type SurfaceTexture: DynSurfaceTexture + fmt::Debug + Borrow; 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 fdcf6550b..35a4d8159 100644 --- a/wgpu-hal/src/metal/mod.rs +++ b/wgpu-hal/src/metal/mod.rs @@ -86,6 +86,7 @@ crate::impl_dyn_resource!( Sampler, ShaderModule, Surface, + SurfaceTexture, Texture, TextureView ); @@ -381,6 +382,8 @@ pub struct SurfaceTexture { present_with_transaction: bool, } +impl crate::DynSurfaceTexture for SurfaceTexture {} + impl std::borrow::Borrow for SurfaceTexture { fn borrow(&self) -> &Texture { &self.texture diff --git a/wgpu-hal/src/vulkan/mod.rs b/wgpu-hal/src/vulkan/mod.rs index 360abdfee..f0fb84f15 100644 --- a/wgpu-hal/src/vulkan/mod.rs +++ b/wgpu-hal/src/vulkan/mod.rs @@ -94,6 +94,7 @@ crate::impl_dyn_resource!( Sampler, ShaderModule, Surface, + SurfaceTexture, Texture, TextureView ); @@ -377,6 +378,8 @@ pub struct SurfaceTexture { surface_semaphores: Arc>, } +impl crate::DynSurfaceTexture for SurfaceTexture {} + impl Borrow for SurfaceTexture { fn borrow(&self) -> &Texture { &self.texture