introduce DynTexture & DynTextureView

This commit is contained in:
Andreas Reich 2024-07-17 09:39:29 +02:00
parent bea9a10f90
commit bdf6710d58
7 changed files with 25 additions and 5 deletions

View File

@ -452,6 +452,8 @@ pub struct Texture {
allocation: Option<suballocation::AllocationWrapper>,
}
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<descriptor::Handle>,
}
impl crate::DynTextureView for TextureView {}
unsafe impl Send for TextureView {}
unsafe impl Sync for TextureView {}

View File

@ -88,10 +88,12 @@ impl<R: DynResource + ?Sized> 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<B: DynBuffer>(self) -> BufferBinding<'a, B> {

View File

@ -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;

View File

@ -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,

View File

@ -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<Self::Texture>;
type TextureView: fmt::Debug + WasmNotSendSync;
type TextureView: DynTextureView;
type Sampler: fmt::Debug + WasmNotSendSync;
type QuerySet: DynQuerySet;

View File

@ -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 {}

View File

@ -671,6 +671,8 @@ pub struct Texture {
view_formats: Vec<wgt::TextureFormat>,
}
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
///