From a5693ab2a346988ad11bd6a1d4f1633da6a40bd5 Mon Sep 17 00:00:00 2001 From: Joshua Groves Date: Tue, 23 Mar 2021 09:31:59 -0230 Subject: [PATCH] Rename color/depth attachments to match spec - Rename `ColorAttachmentDescriptor` to `RenderPassColorAttachment` - Rename `DepthStencilAttachmentDescriptor` to `RenderPassDepthStencilAttachment` - Rename `attachment` fields on both attachments to `view` --- player/tests/data/quad.ron | 2 +- wgpu-core/src/command/render.rs | 38 ++++++++++++++++----------------- wgpu-core/src/device/trace.rs | 4 ++-- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/player/tests/data/quad.ron b/player/tests/data/quad.ron index 69e9e47353..2a72c61b18 100644 --- a/player/tests/data/quad.ron +++ b/player/tests/data/quad.ron @@ -96,7 +96,7 @@ ), target_colors: [ ( - attachment: Id(0, 1, Empty), + view: Id(0, 1, Empty), resolve_target: None, channel: ( load_op: Clear, diff --git a/wgpu-core/src/command/render.rs b/wgpu-core/src/command/render.rs index e1ca59f069..f30954ade5 100644 --- a/wgpu-core/src/command/render.rs +++ b/wgpu-core/src/command/render.rs @@ -97,9 +97,9 @@ pub struct PassChannel { #[derive(Clone, Debug, PartialEq)] #[cfg_attr(any(feature = "serial-pass", feature = "trace"), derive(Serialize))] #[cfg_attr(any(feature = "serial-pass", feature = "replay"), derive(Deserialize))] -pub struct ColorAttachmentDescriptor { +pub struct RenderPassColorAttachment { /// The view to use as an attachment. - pub attachment: id::TextureViewId, + pub view: id::TextureViewId, /// The view that will receive the resolved output if multisampling is used. pub resolve_target: Option, /// What operations will be performed on this color attachment. @@ -111,16 +111,16 @@ pub struct ColorAttachmentDescriptor { #[derive(Clone, Debug, PartialEq)] #[cfg_attr(any(feature = "serial-pass", feature = "trace"), derive(Serialize))] #[cfg_attr(any(feature = "serial-pass", feature = "replay"), derive(Deserialize))] -pub struct DepthStencilAttachmentDescriptor { +pub struct RenderPassDepthStencilAttachment { /// The view to use as an attachment. - pub attachment: id::TextureViewId, + pub view: id::TextureViewId, /// What operations will be performed on the depth part of the attachment. pub depth: PassChannel, /// What operations will be performed on the stencil part of the attachment. pub stencil: PassChannel, } -impl DepthStencilAttachmentDescriptor { +impl RenderPassDepthStencilAttachment { fn is_read_only(&self, aspects: hal::format::Aspects) -> Result { if aspects.contains(hal::format::Aspects::DEPTH) && !self.depth.read_only { return Ok(false); @@ -143,17 +143,17 @@ impl DepthStencilAttachmentDescriptor { pub struct RenderPassDescriptor<'a> { pub label: Label<'a>, /// The color attachments of the render pass. - pub color_attachments: Cow<'a, [ColorAttachmentDescriptor]>, + pub color_attachments: Cow<'a, [RenderPassColorAttachment]>, /// The depth and stencil attachment of the render pass, if any. - pub depth_stencil_attachment: Option<&'a DepthStencilAttachmentDescriptor>, + pub depth_stencil_attachment: Option<&'a RenderPassDepthStencilAttachment>, } #[cfg_attr(feature = "serial-pass", derive(Deserialize, Serialize))] pub struct RenderPass { base: BasePass, parent_id: id::CommandEncoderId, - color_targets: ArrayVec<[ColorAttachmentDescriptor; MAX_COLOR_TARGETS]>, - depth_stencil_target: Option, + color_targets: ArrayVec<[RenderPassColorAttachment; MAX_COLOR_TARGETS]>, + depth_stencil_target: Option, } impl RenderPass { @@ -512,8 +512,8 @@ struct RenderPassInfo<'a, B: hal::Backend> { impl<'a, B: GfxBackend> RenderPassInfo<'a, B> { fn start( raw: &mut B::CommandBuffer, - color_attachments: &[ColorAttachmentDescriptor], - depth_stencil_attachment: Option<&DepthStencilAttachmentDescriptor>, + color_attachments: &[RenderPassColorAttachment], + depth_stencil_attachment: Option<&RenderPassDepthStencilAttachment>, cmd_buf: &CommandBuffer, device: &Device, view_guard: &'a Storage, id::TextureViewId>, @@ -562,8 +562,8 @@ impl<'a, B: GfxBackend> RenderPassInfo<'a, B> { Some(at) => { let view = trackers .views - .use_extend(&*view_guard, at.attachment, (), ()) - .map_err(|_| RenderPassErrorInner::InvalidAttachment(at.attachment))?; + .use_extend(&*view_guard, at.view, (), ()) + .map_err(|_| RenderPassErrorInner::InvalidAttachment(at.view))?; add_view(view, "depth")?; depth_stencil_aspects = view.aspects; @@ -620,8 +620,8 @@ impl<'a, B: GfxBackend> RenderPassInfo<'a, B> { for at in color_attachments { let view = trackers .views - .use_extend(&*view_guard, at.attachment, (), ()) - .map_err(|_| RenderPassErrorInner::InvalidAttachment(at.attachment))?; + .use_extend(&*view_guard, at.view, (), ()) + .map_err(|_| RenderPassErrorInner::InvalidAttachment(at.view))?; add_view(view, "color")?; let layouts = match view.inner { @@ -818,7 +818,7 @@ impl<'a, B: GfxBackend> RenderPassInfo<'a, B> { let view_data = AttachmentData { colors: color_attachments .iter() - .map(|at| view_guard.get(at.attachment).unwrap()) + .map(|at| view_guard.get(at.view).unwrap()) .collect(), resolves: color_attachments .iter() @@ -826,7 +826,7 @@ impl<'a, B: GfxBackend> RenderPassInfo<'a, B> { .map(|attachment| view_guard.get(attachment).unwrap()) .collect(), depth_stencil: depth_stencil_attachment - .map(|at| view_guard.get(at.attachment).unwrap()), + .map(|at| view_guard.get(at.view).unwrap()), }; let extent = extent.ok_or(RenderPassErrorInner::MissingAttachments)?; let fb_key = FramebufferKey { @@ -1015,8 +1015,8 @@ impl Global { &self, encoder_id: id::CommandEncoderId, base: BasePassRef, - color_attachments: &[ColorAttachmentDescriptor], - depth_stencil_attachment: Option<&DepthStencilAttachmentDescriptor>, + color_attachments: &[RenderPassColorAttachment], + depth_stencil_attachment: Option<&RenderPassDepthStencilAttachment>, ) -> Result<(), RenderPassError> { profiling::scope!("CommandEncoder::run_render_pass"); let scope = PassErrorScope::Pass(encoder_id); diff --git a/wgpu-core/src/device/trace.rs b/wgpu-core/src/device/trace.rs index af38f8f41e..d921e1b013 100644 --- a/wgpu-core/src/device/trace.rs +++ b/wgpu-core/src/device/trace.rs @@ -158,8 +158,8 @@ pub enum Command { }, RunRenderPass { base: crate::command::BasePass, - target_colors: Vec, - target_depth_stencil: Option, + target_colors: Vec, + target_depth_stencil: Option, }, }