diff --git a/Cargo.lock b/Cargo.lock index 826c140a7..65a8cbaa6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2360,6 +2360,22 @@ version = "0.1.4+2024.11.22-df583a3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e3cd67e8ea2ba061339150970542cf1c60ba44c6d17e31279cbc133a4b018f8" +[[package]] +name = "macro_rules_attribute" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65049d7923698040cd0b1ddcced9b0eb14dd22c5f86ae59c3740eab64a676520" +dependencies = [ + "macro_rules_attribute-proc_macro", + "paste", +] + +[[package]] +name = "macro_rules_attribute-proc_macro" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "670fdfda89751bc4a84ac13eaa63e205cf0fd22b4c9a5fbfa085b63c1f1d3a30" + [[package]] name = "malloc_buf" version = "0.0.6" @@ -4817,6 +4833,7 @@ dependencies = [ "hashbrown 0.16.0", "indexmap", "log", + "macro_rules_attribute", "naga", "once_cell", "parking_lot", diff --git a/Cargo.toml b/Cargo.toml index 12f94bfed..335dddaa6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -142,6 +142,7 @@ libloading = "0.8" libm = { version = "0.2.6", default-features = false } libtest-mimic = "0.8" log = "0.4.21" +macro_rules_attribute = "0.2" nanoserde = "0.2" nanorand = { version = "0.8", default-features = false, features = ["wyrand"] } noise = "0.9" diff --git a/player/src/bin/play.rs b/player/src/bin/play.rs index dfce80b8a..5f7f93c8c 100644 --- a/player/src/bin/play.rs +++ b/player/src/bin/play.rs @@ -7,7 +7,7 @@ fn main() { use player::GlobalPlay as _; use wgc::device::trace; - use wgpu_core::identity::IdentityManager; + use wgpu_core::{command::IdReferences, identity::IdentityManager}; use std::{ fs, @@ -52,7 +52,7 @@ fn main() { log::info!("Loading trace '{trace:?}'"); let file = fs::File::open(trace).unwrap(); - let mut actions: Vec = ron::de::from_reader(file).unwrap(); + let mut actions: Vec> = ron::de::from_reader(file).unwrap(); actions.reverse(); // allows us to pop from the top log::info!("Found {} actions", actions.len()); diff --git a/player/src/lib.rs b/player/src/lib.rs index 437f51b14..e160d9e04 100644 --- a/player/src/lib.rs +++ b/player/src/lib.rs @@ -6,7 +6,11 @@ extern crate wgpu_core as wgc; extern crate wgpu_types as wgt; -use wgc::{command::Command, device::trace, identity::IdentityManager}; +use wgc::{ + command::{Command, IdReferences}, + device::trace, + identity::IdentityManager, +}; use std::{borrow::Cow, fs, path::Path}; @@ -21,7 +25,7 @@ pub trait GlobalPlay { &self, device: wgc::id::DeviceId, queue: wgc::id::QueueId, - action: trace::Action, + action: trace::Action, dir: &Path, command_encoder_id_manager: &mut IdentityManager, command_buffer_id_manager: &mut IdentityManager, @@ -143,7 +147,7 @@ impl GlobalPlay for wgc::global::Global { } }; wgc::ray_tracing::BlasBuildEntry { - blas_id: x.blas_id, + blas_id: x.blas, geometries, } }); @@ -153,14 +157,14 @@ impl GlobalPlay for wgc::global::Global { instance .as_ref() .map(|instance| wgc::ray_tracing::TlasInstance { - blas_id: instance.blas_id, + blas_id: instance.blas, transform: &instance.transform, custom_data: instance.custom_data, mask: instance.mask, }) }); wgc::ray_tracing::TlasPackage { - tlas_id: x.tlas_id, + tlas_id: x.tlas, instances: Box::new(instances), lowest_unmodified: x.lowest_unmodified, } @@ -188,7 +192,7 @@ impl GlobalPlay for wgc::global::Global { &self, device: wgc::id::DeviceId, queue: wgc::id::QueueId, - action: trace::Action, + action: trace::Action, dir: &Path, command_encoder_id_manager: &mut IdentityManager, command_buffer_id_manager: &mut IdentityManager, diff --git a/player/tests/player/main.rs b/player/tests/player/main.rs index 700a67390..f1296e635 100644 --- a/player/tests/player/main.rs +++ b/player/tests/player/main.rs @@ -20,7 +20,7 @@ use std::{ path::{Path, PathBuf}, slice, }; -use wgc::identity::IdentityManager; +use wgc::{command::IdReferences, identity::IdentityManager}; #[derive(serde::Deserialize)] struct RawId { @@ -57,7 +57,7 @@ struct Expectation { struct Test<'a> { features: wgt::Features, expectations: Vec, - actions: Vec>, + actions: Vec>, } fn map_callback(status: Result<(), wgc::resource::BufferAccessError>) { diff --git a/wgpu-core/Cargo.toml b/wgpu-core/Cargo.toml index 170d0f749..520cbd466 100644 --- a/wgpu-core/Cargo.toml +++ b/wgpu-core/Cargo.toml @@ -178,6 +178,7 @@ document-features.workspace = true hashbrown.workspace = true indexmap.workspace = true log.workspace = true +macro_rules_attribute.workspace = true once_cell = { workspace = true, features = ["std"] } parking_lot.workspace = true profiling = { workspace = true, default-features = false } diff --git a/wgpu-core/src/command/encoder_command.rs b/wgpu-core/src/command/encoder_command.rs index 092228099..eaf118701 100644 --- a/wgpu-core/src/command/encoder_command.rs +++ b/wgpu-core/src/command/encoder_command.rs @@ -1,12 +1,77 @@ use core::convert::Infallible; use alloc::{string::String, sync::Arc, vec::Vec}; +#[cfg(feature = "serde")] +use macro_rules_attribute::attribute_alias; use crate::{ id, resource::{Buffer, QuerySet, Texture}, }; +pub trait ReferenceType { + type Buffer: Clone + core::fmt::Debug; + type Texture: Clone + core::fmt::Debug; + type TextureView: Clone + core::fmt::Debug; + type QuerySet: Clone + core::fmt::Debug; + type BindGroup: Clone + core::fmt::Debug; + type RenderPipeline: Clone + core::fmt::Debug; + type RenderBundle: Clone + core::fmt::Debug; + type ComputePipeline: Clone + core::fmt::Debug; + type Blas: Clone + core::fmt::Debug; + type Tlas: Clone + core::fmt::Debug; +} + +#[derive(Clone, Debug)] +pub struct IdReferences; + +#[derive(Clone, Debug)] +pub struct ArcReferences; + +impl ReferenceType for IdReferences { + type Buffer = id::BufferId; + type Texture = id::TextureId; + type TextureView = id::TextureViewId; + type QuerySet = id::QuerySetId; + type BindGroup = id::BindGroupId; + type RenderPipeline = id::RenderPipelineId; + type RenderBundle = id::RenderBundleId; + type ComputePipeline = id::ComputePipelineId; + type Blas = id::BlasId; + type Tlas = id::TlasId; +} + +impl ReferenceType for ArcReferences { + type Buffer = Arc; + type Texture = Arc; + type TextureView = Arc; + type QuerySet = Arc; + type BindGroup = Arc; + type RenderPipeline = Arc; + type RenderBundle = Arc; + type ComputePipeline = Arc; + type Blas = Arc; + type Tlas = Arc; +} + +#[cfg(feature = "serde")] +attribute_alias! { + #[apply(serde_object_reference_struct)] = + #[derive(serde::Serialize, serde::Deserialize)] + #[serde(bound = + "R::Buffer: serde::Serialize + for<'d> serde::Deserialize<'d>,\ + R::Texture: serde::Serialize + for<'d> serde::Deserialize<'d>,\ + R::TextureView: serde::Serialize + for<'d> serde::Deserialize<'d>,\ + R::QuerySet: serde::Serialize + for<'d> serde::Deserialize<'d>,\ + R::BindGroup: serde::Serialize + for<'d> serde::Deserialize<'d>,\ + R::RenderPipeline: serde::Serialize + for<'d> serde::Deserialize<'d>,\ + R::RenderBundle: serde::Serialize + for<'d> serde::Deserialize<'d>,\ + R::ComputePipeline: serde::Serialize + for<'d> serde::Deserialize<'d>,\ + R::Blas: serde::Serialize + for<'d> serde::Deserialize<'d>,\ + R::Tlas: serde::Serialize + for<'d> serde::Deserialize<'d>" + )]; +} + #[derive(Clone, Debug)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum Command { diff --git a/wgpu-core/src/command/mod.rs b/wgpu-core/src/command/mod.rs index 77848a312..56ed8097c 100644 --- a/wgpu-core/src/command/mod.rs +++ b/wgpu-core/src/command/mod.rs @@ -34,13 +34,15 @@ use core::mem::{self, ManuallyDrop}; use core::ops; pub(crate) use self::clear::clear_texture; +#[cfg(feature = "serde")] +pub(crate) use self::encoder_command::serde_object_reference_struct; pub use self::{ bundle::*, clear::ClearError, compute::*, compute_command::{ArcComputeCommand, ComputeCommand}, draw::*, - encoder_command::{ArcCommand, Command}, + encoder_command::{ArcCommand, ArcReferences, Command, IdReferences, ReferenceType}, query::*, render::*, render_command::{ArcRenderCommand, RenderCommand}, diff --git a/wgpu-core/src/command/ray_tracing.rs b/wgpu-core/src/command/ray_tracing.rs index ac4547ff2..58001cad7 100644 --- a/wgpu-core/src/command/ray_tracing.rs +++ b/wgpu-core/src/command/ray_tracing.rs @@ -8,32 +8,29 @@ use core::{ use wgt::{math::align_to, BufferUsages, BufferUses, Features}; use crate::{ - command::CommandBufferMutable, + command::encoder::EncodingState, + ray_tracing::{AsAction, AsBuild, BlasTriangleGeometryInfo, TlasBuild, ValidateAsActionsError}, + resource::InvalidResourceError, + track::Tracker, +}; +use crate::{command::EncoderStateError, device::resource::CommandIndices}; +use crate::{ + command::{ArcCommand, ArcReferences, CommandBufferMutable}, device::queue::TempResource, global::Global, id::CommandEncoderId, init_tracker::MemoryInitKind, ray_tracing::{ - BlasBuildEntry, BlasGeometries, BuildAccelerationStructureError, TlasPackage, - TraceBlasBuildEntry, TraceBlasGeometries, TraceBlasTriangleGeometry, TraceTlasInstance, - TraceTlasPackage, + ArcBlasBuildEntry, ArcBlasGeometries, ArcBlasTriangleGeometry, ArcTlasInstance, + ArcTlasPackage, BlasBuildEntry, BlasGeometries, BuildAccelerationStructureError, + OwnedBlasBuildEntry, OwnedTlasPackage, TlasPackage, TraceBlasBuildEntry, + TraceBlasGeometries, TraceBlasTriangleGeometry, TraceTlasInstance, TraceTlasPackage, }, resource::{Blas, BlasCompactState, Buffer, Labeled, StagingBuffer, Tlas}, scratch::ScratchBuffer, snatch::SnatchGuard, track::PendingTransition, }; -use crate::{command::EncoderStateError, device::resource::CommandIndices}; -use crate::{ - command::{encoder::EncodingState, ArcCommand}, - ray_tracing::{ - ArcBlasBuildEntry, ArcBlasGeometries, ArcBlasTriangleGeometry, ArcTlasInstance, - ArcTlasPackage, AsAction, AsBuild, BlasTriangleGeometryInfo, TlasBuild, - ValidateAsActionsError, - }, - resource::InvalidResourceError, - track::Tracker, -}; use crate::{lock::RwLockWriteGuard, resource::RawResourceAccess}; use crate::id::{BlasId, TlasId}; @@ -147,7 +144,7 @@ impl Global { } }; TraceBlasBuildEntry { - blas_id: blas_entry.blas_id, + blas: blas_entry.blas_id, geometries, } }) @@ -159,7 +156,7 @@ impl Global { .instances .map(|instance| { instance.map(|instance| TraceTlasInstance { - blas_id: instance.blas_id, + blas: instance.blas_id, transform: *instance.transform, custom_data: instance.custom_data, mask: instance.mask, @@ -167,7 +164,7 @@ impl Global { }) .collect(); TraceTlasPackage { - tlas_id: package.tlas_id, + tlas: package.tlas_id, instances, lowest_unmodified: package.lowest_unmodified, } @@ -215,7 +212,7 @@ impl Global { } }; Ok(ArcBlasBuildEntry { - blas: self.resolve_blas_id(blas_entry.blas_id)?, + blas: self.resolve_blas_id(blas_entry.blas)?, geometries, }) }) @@ -232,7 +229,7 @@ impl Global { .as_ref() .map(|instance| { Ok(ArcTlasInstance { - blas: self.resolve_blas_id(instance.blas_id)?, + blas: self.resolve_blas_id(instance.blas)?, transform: instance.transform, custom_data: instance.custom_data, mask: instance.mask, @@ -242,7 +239,7 @@ impl Global { }) .collect::>()?; Ok(ArcTlasPackage { - tlas: self.resolve_tlas_id(tlas_package.tlas_id)?, + tlas: self.resolve_tlas_id(tlas_package.tlas)?, instances, lowest_unmodified: tlas_package.lowest_unmodified, }) @@ -256,8 +253,8 @@ impl Global { pub(crate) fn build_acceleration_structures( state: &mut EncodingState, - blas: Vec, - tlas: Vec, + blas: Vec>, + tlas: Vec>, ) -> Result<(), BuildAccelerationStructureError> { state .device @@ -282,7 +279,7 @@ pub(crate) fn build_acceleration_structures( &mut scratch_buffer_blas_size, &mut blas_storage, )?; - let mut tlas_lock_store = Vec::<(Option, Arc)>::new(); + let mut tlas_lock_store = Vec::<(Option>, Arc)>::new(); for package in tlas.into_iter() { let tlas = package.tlas.clone(); @@ -615,7 +612,7 @@ impl CommandBufferMutable { ///iterates over the blas iterator, and it's geometry, pushing the buffers into a storage vector (and also some validation). fn iter_blas( - blas_iter: impl Iterator, + blas_iter: impl Iterator>, tracker: &mut Tracker, build_command: &mut AsBuild, buf_storage: &mut Vec, diff --git a/wgpu-core/src/device/trace.rs b/wgpu-core/src/device/trace.rs index fcb3f5891..6142802a8 100644 --- a/wgpu-core/src/device/trace.rs +++ b/wgpu-core/src/device/trace.rs @@ -1,12 +1,17 @@ -use alloc::{string::String, vec::Vec}; use core::{convert::Infallible, ops::Range}; +use alloc::{string::String, vec::Vec}; +use macro_rules_attribute::apply; + #[cfg(feature = "trace")] use {alloc::borrow::Cow, std::io::Write as _}; -use crate::{command::Command, id}; - -//TODO: consider a readable Id that doesn't include the backend +#[cfg(feature = "trace")] +use crate::command::IdReferences; +use crate::{ + command::{serde_object_reference_struct, BasePass, Command, ReferenceType, RenderCommand}, + id, +}; type FileName = String; @@ -36,8 +41,8 @@ pub(crate) fn new_render_bundle_encoder_descriptor<'a>( #[allow(clippy::large_enum_variant)] #[derive(Debug)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum Action<'a> { +#[apply(serde_object_reference_struct)] +pub enum Action<'a, R: ReferenceType> { Init { desc: crate::device::DeviceDescriptor<'a>, backend: wgt::Backend, @@ -46,18 +51,18 @@ pub enum Action<'a> { id::SurfaceId, wgt::SurfaceConfiguration>, ), - CreateBuffer(id::BufferId, crate::resource::BufferDescriptor<'a>), - FreeBuffer(id::BufferId), - DestroyBuffer(id::BufferId), - CreateTexture(id::TextureId, crate::resource::TextureDescriptor<'a>), - FreeTexture(id::TextureId), - DestroyTexture(id::TextureId), + CreateBuffer(R::Buffer, crate::resource::BufferDescriptor<'a>), + FreeBuffer(R::Buffer), + DestroyBuffer(R::Buffer), + CreateTexture(R::Texture, crate::resource::TextureDescriptor<'a>), + FreeTexture(R::Texture), + DestroyTexture(R::Texture), CreateTextureView { - id: id::TextureViewId, - parent_id: id::TextureId, + id: R::TextureView, + parent_id: R::Texture, desc: crate::resource::TextureViewDescriptor<'a>, }, - DestroyTextureView(id::TextureViewId), + DestroyTextureView(R::TextureView), CreateExternalTexture { id: id::ExternalTextureId, desc: crate::resource::ExternalTextureDescriptor<'a>, @@ -68,7 +73,7 @@ pub enum Action<'a> { CreateSampler(id::SamplerId, crate::resource::SamplerDescriptor<'a>), DestroySampler(id::SamplerId), GetSurfaceTexture { - id: id::TextureId, + id: R::Texture, parent_id: id::SurfaceId, }, Present(id::SurfaceId), @@ -125,7 +130,7 @@ pub enum Action<'a> { CreateRenderBundle { id: id::RenderBundleId, desc: crate::command::RenderBundleEncoderDescriptor<'a>, - base: crate::command::BasePass, + base: BasePass, }, DestroyRenderBundle(id::RenderBundleId), CreateQuerySet { @@ -134,13 +139,13 @@ pub enum Action<'a> { }, DestroyQuerySet(id::QuerySetId), WriteBuffer { - id: id::BufferId, + id: R::Buffer, data: FileName, range: Range, queued: bool, }, WriteTexture { - to: wgt::TexelCopyTextureInfo, + to: wgt::TexelCopyTextureInfo, data: FileName, layout: wgt::TexelCopyBufferLayout, size: wgt::Extent3d, @@ -189,7 +194,10 @@ impl Trace { name } - pub(crate) fn add(&mut self, action: Action) { + pub(crate) fn add(&mut self, action: Action<'_, IdReferences>) + where + for<'a> Action<'a, IdReferences>: serde::Serialize, + { match ron::ser::to_string_pretty(&action, self.config.clone()) { Ok(string) => { let _ = writeln!(self.file, "{string},"); diff --git a/wgpu-core/src/ray_tracing.rs b/wgpu-core/src/ray_tracing.rs index 291656678..0dd645129 100644 --- a/wgpu-core/src/ray_tracing.rs +++ b/wgpu-core/src/ray_tracing.rs @@ -10,18 +10,21 @@ use alloc::{boxed::Box, sync::Arc, vec::Vec}; +use macro_rules_attribute::apply; use thiserror::Error; use wgt::{ error::{ErrorType, WebGpuError}, AccelerationStructureGeometryFlags, BufferAddress, IndexFormat, VertexFormat, }; +#[cfg(feature = "serde")] +use crate::command::serde_object_reference_struct; use crate::{ - command::EncoderStateError, + command::{ArcReferences, EncoderStateError, IdReferences, ReferenceType}, device::{DeviceError, MissingFeatures}, id::{BlasId, BufferId, TlasId}, resource::{ - Blas, BlasCompactCallback, BlasPrepareCompactResult, Buffer, DestroyedResourceError, + Blas, BlasCompactCallback, BlasPrepareCompactResult, DestroyedResourceError, InvalidResourceError, MissingBufferUsageError, ResourceErrorIdent, Tlas, }, }; @@ -306,60 +309,62 @@ pub(crate) enum AsAction { /// Like [`BlasTriangleGeometry`], but with owned data. #[derive(Debug, Clone)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct TraceBlasTriangleGeometry { +#[cfg_attr(feature = "serde", apply(serde_object_reference_struct))] +pub struct OwnedBlasTriangleGeometry { pub size: wgt::BlasTriangleGeometrySizeDescriptor, - pub vertex_buffer: BufferId, - pub index_buffer: Option, - pub transform_buffer: Option, + pub vertex_buffer: R::Buffer, + pub index_buffer: Option, + pub transform_buffer: Option, pub first_vertex: u32, pub vertex_stride: BufferAddress, pub first_index: Option, pub transform_buffer_offset: Option, } -#[derive(Debug, Clone)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum TraceBlasGeometries { - TriangleGeometries(Vec), -} +pub type ArcBlasTriangleGeometry = OwnedBlasTriangleGeometry; +pub type TraceBlasTriangleGeometry = OwnedBlasTriangleGeometry; #[derive(Debug, Clone)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct TraceBlasBuildEntry { - pub blas_id: BlasId, - pub geometries: TraceBlasGeometries, +#[cfg_attr(feature = "serde", apply(serde_object_reference_struct))] +pub enum OwnedBlasGeometries { + TriangleGeometries(Vec>), } +pub type ArcBlasGeometries = OwnedBlasGeometries; +pub type TraceBlasGeometries = OwnedBlasGeometries; + #[derive(Debug, Clone)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct TraceTlasInstance { - pub blas_id: BlasId, +#[cfg_attr(feature = "serde", apply(serde_object_reference_struct))] +pub struct OwnedBlasBuildEntry { + pub blas: R::Blas, + pub geometries: OwnedBlasGeometries, // TODO +} + +pub type ArcBlasBuildEntry = OwnedBlasBuildEntry; +pub type TraceBlasBuildEntry = OwnedBlasBuildEntry; + +#[derive(Debug, Clone)] +#[cfg_attr(feature = "serde", apply(serde_object_reference_struct))] +pub struct OwnedTlasInstance { + pub blas: R::Blas, pub transform: [f32; 12], pub custom_data: u32, pub mask: u8, } +pub type ArcTlasInstance = OwnedTlasInstance; +pub type TraceTlasInstance = OwnedTlasInstance; + #[derive(Debug, Clone)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct TraceTlasPackage { - pub tlas_id: TlasId, - pub instances: Vec>, +#[cfg_attr(feature = "serde", apply(serde_object_reference_struct))] +pub struct OwnedTlasPackage { + pub tlas: R::Tlas, + pub instances: Vec>>, pub lowest_unmodified: u32, } -/// Like [`BlasTriangleGeometry`], but with `Arc`s. -#[derive(Debug, Clone)] -pub struct ArcBlasTriangleGeometry { - pub size: wgt::BlasTriangleGeometrySizeDescriptor, - pub vertex_buffer: Arc, - pub index_buffer: Option>, - pub transform_buffer: Option>, - pub first_vertex: u32, - pub vertex_stride: BufferAddress, - pub first_index: Option, - pub transform_buffer_offset: Option, -} +pub type TraceTlasPackage = OwnedTlasPackage; +pub type ArcTlasPackage = OwnedTlasPackage; /// [`BlasTriangleGeometry`], without the resources. #[derive(Debug, Clone)] @@ -371,32 +376,6 @@ pub struct BlasTriangleGeometryInfo { pub transform_buffer_offset: Option, } -#[derive(Debug, Clone)] -pub enum ArcBlasGeometries { - TriangleGeometries(Vec), -} - -#[derive(Debug, Clone)] -pub struct ArcBlasBuildEntry { - pub blas: Arc, - pub geometries: ArcBlasGeometries, -} - -#[derive(Debug, Clone)] -pub struct ArcTlasInstance { - pub blas: Arc, - pub transform: [f32; 12], - pub custom_data: u32, - pub mask: u8, -} - -#[derive(Debug, Clone)] -pub struct ArcTlasPackage { - pub tlas: Arc, - pub instances: Vec>, - pub lowest_unmodified: u32, -} - #[derive(Clone, Debug, Error)] pub enum BlasPrepareCompactError { #[error(transparent)] diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index 9ea2a5d22..08de1f5ae 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -5357,6 +5357,8 @@ bitflags::bitflags! { bitflags::bitflags! { /// Similar to `BufferUsages`, but used only for `CommandEncoder::transition_resources`. + #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] + #[cfg_attr(feature = "serde", serde(transparent))] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct BufferUses: u16 { /// The argument to a read-only mapping. @@ -5408,6 +5410,7 @@ bitflags::bitflags! { /// A buffer transition for use with `CommandEncoder::transition_resources`. #[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct BufferTransition { /// The buffer to transition. pub buffer: T, @@ -5669,6 +5672,8 @@ bitflags::bitflags! { bitflags::bitflags! { /// Similar to `TextureUsages`, but used only for `CommandEncoder::transition_resources`. #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] + #[cfg_attr(feature = "serde", serde(transparent))] pub struct TextureUses: u16 { /// The texture is in unknown state. const UNINITIALIZED = 1 << 0; @@ -5724,6 +5729,7 @@ bitflags::bitflags! { /// A texture transition for use with `CommandEncoder::transition_resources`. #[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct TextureTransition { /// The texture to transition. pub texture: T, @@ -5737,6 +5743,7 @@ pub struct TextureTransition { /// Specifies a particular set of subresources in a texture. #[derive(Clone, Debug, PartialEq, Eq)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct TextureSelector { /// Range of mips to use. pub mips: Range,