Skip to content

Commit

Permalink
Merge #1280
Browse files Browse the repository at this point in the history
1280: Rename color/depth attachments to match spec r=kvark a=grovesNL

**Description**
- Rename `ColorAttachmentDescriptor` to `RenderPassColorAttachment` (https://gpuweb.github.io/gpuweb/#color-attachments)
- Rename `DepthStencilAttachmentDescriptor` to `RenderPassDepthStencilAttachment` (https://gpuweb.github.io/gpuweb/#depth-stencil-attachments)
- Rename `attachment` fields on both attachments to `view`

**Testing**
None (just `cargo build`) because the renaming downstream should be trivial.

Co-authored-by: Joshua Groves <josh@joshgroves.com>
  • Loading branch information
bors[bot] and grovesNL authored Mar 23, 2021
2 parents fb0288a + a5693ab commit 2bc5526
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion player/tests/data/quad.ron
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
),
target_colors: [
(
attachment: Id(0, 1, Empty),
view: Id(0, 1, Empty),
resolve_target: None,
channel: (
load_op: Clear,
Expand Down
38 changes: 19 additions & 19 deletions wgpu-core/src/command/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ pub struct PassChannel<V> {
#[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<id::TextureViewId>,
/// What operations will be performed on this color attachment.
Expand All @@ -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<f32>,
/// What operations will be performed on the stencil part of the attachment.
pub stencil: PassChannel<u32>,
}

impl DepthStencilAttachmentDescriptor {
impl RenderPassDepthStencilAttachment {
fn is_read_only(&self, aspects: hal::format::Aspects) -> Result<bool, RenderPassErrorInner> {
if aspects.contains(hal::format::Aspects::DEPTH) && !self.depth.read_only {
return Ok(false);
Expand All @@ -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<RenderCommand>,
parent_id: id::CommandEncoderId,
color_targets: ArrayVec<[ColorAttachmentDescriptor; MAX_COLOR_TARGETS]>,
depth_stencil_target: Option<DepthStencilAttachmentDescriptor>,
color_targets: ArrayVec<[RenderPassColorAttachment; MAX_COLOR_TARGETS]>,
depth_stencil_target: Option<RenderPassDepthStencilAttachment>,
}

impl RenderPass {
Expand Down Expand Up @@ -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<B>,
device: &Device<B>,
view_guard: &'a Storage<TextureView<B>, id::TextureViewId>,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -818,15 +818,15 @@ 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()
.filter_map(|at| at.resolve_target)
.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 {
Expand Down Expand Up @@ -1015,8 +1015,8 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
&self,
encoder_id: id::CommandEncoderId,
base: BasePassRef<RenderCommand>,
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);
Expand Down
4 changes: 2 additions & 2 deletions wgpu-core/src/device/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ pub enum Command {
},
RunRenderPass {
base: crate::command::BasePass<crate::command::RenderCommand>,
target_colors: Vec<crate::command::ColorAttachmentDescriptor>,
target_depth_stencil: Option<crate::command::DepthStencilAttachmentDescriptor>,
target_colors: Vec<crate::command::RenderPassColorAttachment>,
target_depth_stencil: Option<crate::command::RenderPassDepthStencilAttachment>,
},
}

Expand Down

0 comments on commit 2bc5526

Please sign in to comment.