From 09bf6ccf1941a5a5f7a5164756e09a27bd6c8ae4 Mon Sep 17 00:00:00 2001 From: sagudev <16504129+sagudev@users.noreply.github.com> Date: Fri, 7 Aug 2026 07:39:56 +0200 Subject: [PATCH] [core] Do not use IDs as default types in `RenderPassColorAttachment` Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --- wgpu-core/src/command/mod.rs | 10 +++++----- wgpu-core/src/command/render.rs | 17 +++++++---------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/wgpu-core/src/command/mod.rs b/wgpu-core/src/command/mod.rs index 869b59814..e791a45d7 100644 --- a/wgpu-core/src/command/mod.rs +++ b/wgpu-core/src/command/mod.rs @@ -57,11 +57,11 @@ pub use self::{ encoder_command::{ArcCommand, ArcReferences, Command, IdReferences, ReferenceType}, query::{QueryError, QueryUseError, ResolveError, SimplifiedQueryType}, render::{ - ArcRenderPassColorAttachment, AttachmentError, AttachmentErrorLocation, - ColorAttachmentError, ColorAttachments, LoadOp, PassChannel, RenderBasePass, RenderPass, - RenderPassColorAttachment, RenderPassDepthStencilAttachment, RenderPassDescriptor, - RenderPassError, RenderPassErrorInner, ResolvedPassChannel, - ResolvedRenderPassDepthStencilAttachment, ResolvedRenderPassDescriptor, StoreOp, + AttachmentError, AttachmentErrorLocation, ColorAttachmentError, ColorAttachments, LoadOp, + PassChannel, RenderBasePass, RenderPass, RenderPassColorAttachment, + RenderPassDepthStencilAttachment, RenderPassDescriptor, RenderPassError, + RenderPassErrorInner, ResolvedPassChannel, ResolvedRenderPassDepthStencilAttachment, + ResolvedRenderPassDescriptor, StoreOp, }, render_command::ArcRenderCommand, transfer::{CopySide, TransferError}, diff --git a/wgpu-core/src/command/render.rs b/wgpu-core/src/command/render.rs index 5cc3cd6f1..0df52d9cb 100644 --- a/wgpu-core/src/command/render.rs +++ b/wgpu-core/src/command/render.rs @@ -190,7 +190,7 @@ impl ResolvedPassChannel { #[repr(C)] #[derive(Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -pub struct RenderPassColorAttachment { +pub struct RenderPassColorAttachment> { /// The view to use as an attachment. pub view: TV, /// The depth slice index of a 3D view. It must not be provided if the view is not 3D. @@ -207,14 +207,12 @@ pub struct RenderPassColorAttachment { pub store_op: StoreOp, } -pub type ArcRenderPassColorAttachment = RenderPassColorAttachment>; - // Avoid allocation in the common case that there is only one color attachment, // but don't bloat `ArcCommand::RunRenderPass` excessively. pub type ColorAttachments> = SmallVec<[Option>; 1]>; -impl ArcRenderPassColorAttachment { +impl RenderPassColorAttachment { fn hal_ops(&self) -> hal::AttachmentOps { load_hal_ops(self.load_op) | store_hal_ops(self.store_op) } @@ -262,7 +260,7 @@ pub struct ResolvedRenderPassDepthStencilAttachment { pub struct RenderPassDescriptor<'a> { pub label: Label<'a>, /// The color attachments of the render pass. - pub color_attachments: Cow<'a, [Option]>, + pub color_attachments: Cow<'a, [Option>]>, /// The depth and stencil attachment of the render pass, if any. pub depth_stencil_attachment: Option>, /// Defines where and when timestamp values will be written for this pass. @@ -294,7 +292,7 @@ struct ArcRenderPassDescriptor<'a> { pub label: &'a Label<'a>, /// The color attachments of the render pass. pub color_attachments: - ArrayVec, { hal::MAX_COLOR_ATTACHMENTS }>, + ArrayVec, { hal::MAX_COLOR_ATTACHMENTS }>, /// The depth and stencil attachment of the render pass, if any. pub depth_stencil_attachment: Option>>, @@ -326,8 +324,7 @@ pub struct RenderPass { /// See parent: Option>, - color_attachments: - ArrayVec, { hal::MAX_COLOR_ATTACHMENTS }>, + color_attachments: ArrayVec, { hal::MAX_COLOR_ATTACHMENTS }>, depth_stencil_attachment: Option>>, timestamp_writes: Option, occlusion_query_set: Option>, @@ -1189,7 +1186,7 @@ impl RenderPassInfo { fn start( device: &Arc, hal_label: Option<&str>, - color_attachments: &[Option], + color_attachments: &[Option], mut depth_stencil_attachment: Option< ResolvedRenderPassDepthStencilAttachment>, >, @@ -1894,7 +1891,7 @@ impl CommandEncoder { arc_desc .color_attachments - .push(Some(ArcRenderPassColorAttachment { + .push(Some(RenderPassColorAttachment { view: Arc::clone(view), depth_slice: *depth_slice, resolve_target: resolve_target.map(Arc::clone),