Rename MAX_COLOR_TARGETS to MAX_COLOR_ATTACHMENTS to match spec

This commit is contained in:
Jinlei Li 2022-06-17 10:36:45 +08:00 committed by Jim Blandy
parent f2c3d42818
commit f4c01052ef
12 changed files with 22 additions and 22 deletions

View File

@ -168,7 +168,7 @@ impl RenderBundleEncoder {
parent_id,
context: RenderPassContext {
attachments: AttachmentData {
colors: if desc.color_formats.len() > hal::MAX_COLOR_TARGETS {
colors: if desc.color_formats.len() > hal::MAX_COLOR_ATTACHMENTS {
return Err(CreateRenderBundleError::TooManyColorAttachments);
} else {
desc.color_formats.iter().cloned().collect()

View File

@ -182,7 +182,7 @@ pub struct RenderPassDescriptor<'a> {
pub struct RenderPass {
base: BasePass<RenderCommand>,
parent_id: id::CommandEncoderId,
color_targets: ArrayVec<RenderPassColorAttachment, { hal::MAX_COLOR_TARGETS }>,
color_targets: ArrayVec<RenderPassColorAttachment, { hal::MAX_COLOR_ATTACHMENTS }>,
depth_stencil_target: Option<RenderPassDepthStencilAttachment>,
// Resource binding dedupe state.
@ -589,7 +589,7 @@ impl<A: hal::Api> TextureView<A> {
}
}
const MAX_TOTAL_ATTACHMENTS: usize = hal::MAX_COLOR_TARGETS + hal::MAX_COLOR_TARGETS + 1;
const MAX_TOTAL_ATTACHMENTS: usize = hal::MAX_COLOR_ATTACHMENTS + hal::MAX_COLOR_ATTACHMENTS + 1;
type AttachmentDataVec<T> = ArrayVec<T, MAX_TOTAL_ATTACHMENTS>;
struct RenderPassInfo<'a, A: HalApi> {
@ -726,7 +726,7 @@ impl<'a, A: HalApi> RenderPassInfo<'a, A> {
Ok(())
};
let mut colors = ArrayVec::<hal::ColorAttachment<A>, { hal::MAX_COLOR_TARGETS }>::new();
let mut colors = ArrayVec::<hal::ColorAttachment<A>, { hal::MAX_COLOR_ATTACHMENTS }>::new();
let mut depth_stencil = None;
if let Some(at) = depth_stencil_attachment {

View File

@ -52,8 +52,8 @@ pub enum HostMap {
#[derive(Clone, Debug, Hash, PartialEq)]
#[cfg_attr(feature = "serial-pass", derive(serde::Deserialize, serde::Serialize))]
pub(crate) struct AttachmentData<T> {
pub colors: ArrayVec<T, { hal::MAX_COLOR_TARGETS }>,
pub resolves: ArrayVec<T, { hal::MAX_COLOR_TARGETS }>,
pub colors: ArrayVec<T, { hal::MAX_COLOR_ATTACHMENTS }>,
pub resolves: ArrayVec<T, { hal::MAX_COLOR_ATTACHMENTS }>,
pub depth_stencil: Option<T>,
}
impl<T: PartialEq> Eq for AttachmentData<T> {}
@ -78,8 +78,8 @@ pub(crate) struct RenderPassContext {
pub enum RenderPassCompatibilityError {
#[error("Incompatible color attachment: the renderpass expected {0:?} but was given {1:?}")]
IncompatibleColorAttachment(
ArrayVec<TextureFormat, { hal::MAX_COLOR_TARGETS }>,
ArrayVec<TextureFormat, { hal::MAX_COLOR_TARGETS }>,
ArrayVec<TextureFormat, { hal::MAX_COLOR_ATTACHMENTS }>,
ArrayVec<TextureFormat, { hal::MAX_COLOR_ATTACHMENTS }>,
),
#[error(
"Incompatible depth-stencil attachment: the renderpass expected {0:?} but was given {1:?}"

View File

@ -48,7 +48,7 @@ pub mod resource;
mod track;
mod validation;
pub use hal::{api, MAX_BIND_GROUPS, MAX_COLOR_TARGETS, MAX_VERTEX_BUFFERS};
pub use hal::{api, MAX_BIND_GROUPS, MAX_COLOR_ATTACHMENTS, MAX_VERTEX_BUFFERS};
use atomic::{AtomicUsize, Ordering};

View File

@ -580,7 +580,7 @@ impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
unsafe fn begin_render_pass(&mut self, desc: &crate::RenderPassDescriptor<super::Api>) {
self.begin_pass(super::PassKind::Render, desc.label);
let mut color_views = [native::CpuDescriptor { ptr: 0 }; crate::MAX_COLOR_TARGETS];
let mut color_views = [native::CpuDescriptor { ptr: 0 }; crate::MAX_COLOR_ATTACHMENTS];
for (rtv, cat) in color_views.iter_mut().zip(desc.color_attachments.iter()) {
*rtv = cat.target.view.handle_rtv.unwrap().raw;
}

View File

@ -287,7 +287,7 @@ enum PassKind {
struct PassState {
has_label: bool,
resolves: ArrayVec<PassResolve, { crate::MAX_COLOR_TARGETS }>,
resolves: ArrayVec<PassResolve, { crate::MAX_COLOR_ATTACHMENTS }>,
layout: PipelineLayoutShared,
root_elements: [RootElement; MAX_ROOT_ELEMENTS],
dirty_root_elements: u64,

View File

@ -17,14 +17,14 @@ pub(super) struct State {
vertex_buffers:
[(super::VertexBufferDesc, Option<super::BufferBinding>); crate::MAX_VERTEX_BUFFERS],
vertex_attributes: ArrayVec<super::AttributeDesc, { super::MAX_VERTEX_ATTRIBUTES }>,
color_targets: ArrayVec<super::ColorTargetDesc, { crate::MAX_COLOR_TARGETS }>,
color_targets: ArrayVec<super::ColorTargetDesc, { crate::MAX_COLOR_ATTACHMENTS }>,
stencil: super::StencilState,
depth_bias: wgt::DepthBiasState,
samplers: [Option<glow::Sampler>; super::MAX_SAMPLERS],
texture_slots: [TextureSlotDesc; super::MAX_TEXTURE_SLOTS],
render_size: wgt::Extent3d,
resolve_attachments: ArrayVec<(u32, super::TextureView), { crate::MAX_COLOR_TARGETS }>,
invalidate_attachments: ArrayVec<u32, { crate::MAX_COLOR_TARGETS + 2 }>,
resolve_attachments: ArrayVec<(u32, super::TextureView), { crate::MAX_COLOR_ATTACHMENTS }>,
invalidate_attachments: ArrayVec<u32, { crate::MAX_COLOR_ATTACHMENTS + 2 }>,
has_pass_label: bool,
instance_vbuf_mask: usize,
dirty_vbuf_mask: usize,

View File

@ -567,7 +567,7 @@ struct PrimitiveState {
unclipped_depth: bool,
}
type InvalidatedAttachments = ArrayVec<u32, { crate::MAX_COLOR_TARGETS + 2 }>;
type InvalidatedAttachments = ArrayVec<u32, { crate::MAX_COLOR_ATTACHMENTS + 2 }>;
#[derive(Debug)]
enum Command {

View File

@ -50,7 +50,7 @@ impl super::Queue {
// Reset the draw buffers to what they were before the clear
let indices = (0..self.draw_buffer_count as u32)
.map(|i| glow::COLOR_ATTACHMENT0 + i)
.collect::<ArrayVec<_, { crate::MAX_COLOR_TARGETS }>>();
.collect::<ArrayVec<_, { crate::MAX_COLOR_ATTACHMENTS }>>();
gl.draw_buffers(&indices);
}
#[cfg(not(target_arch = "wasm32"))]
@ -693,7 +693,7 @@ impl super::Queue {
None,
0,
);
for i in 0..crate::MAX_COLOR_TARGETS {
for i in 0..crate::MAX_COLOR_ATTACHMENTS {
let target = glow::COLOR_ATTACHMENT0 + i as u32;
gl.framebuffer_texture_2d(
glow::DRAW_FRAMEBUFFER,
@ -748,7 +748,7 @@ impl super::Queue {
self.draw_buffer_count = count;
let indices = (0..count as u32)
.map(|i| glow::COLOR_ATTACHMENT0 + i)
.collect::<ArrayVec<_, { crate::MAX_COLOR_TARGETS }>>();
.collect::<ArrayVec<_, { crate::MAX_COLOR_ATTACHMENTS }>>();
gl.draw_buffers(&indices);
if self

View File

@ -97,7 +97,7 @@ use thiserror::Error;
pub const MAX_ANISOTROPY: u8 = 16;
pub const MAX_BIND_GROUPS: usize = 8;
pub const MAX_VERTEX_BUFFERS: usize = 16;
pub const MAX_COLOR_TARGETS: usize = 8;
pub const MAX_COLOR_ATTACHMENTS: usize = 8;
pub const MAX_MIP_LEVELS: u32 = 16;
/// Size of a single occlusion/timestamp query, when copied into a buffer, in bytes.
pub const QUERY_SIZE: wgt::BufferAddress = 8;

View File

@ -41,7 +41,7 @@ use ash::{
use parking_lot::Mutex;
const MILLIS_TO_NANOS: u64 = 1_000_000;
const MAX_TOTAL_ATTACHMENTS: usize = crate::MAX_COLOR_TARGETS * 2 + 1;
const MAX_TOTAL_ATTACHMENTS: usize = crate::MAX_COLOR_ATTACHMENTS * 2 + 1;
pub type DropGuard = Box<dyn std::any::Any + Send + Sync>;
@ -212,7 +212,7 @@ struct DepthStencilAttachmentKey {
#[derive(Clone, Eq, Default, Hash, PartialEq)]
struct RenderPassKey {
colors: ArrayVec<ColorAttachmentKey, { crate::MAX_COLOR_TARGETS }>,
colors: ArrayVec<ColorAttachmentKey, { crate::MAX_COLOR_ATTACHMENTS }>,
depth_stencil: Option<DepthStencilAttachmentKey>,
sample_count: u32,
multiview: Option<NonZeroU32>,

View File

@ -2027,7 +2027,7 @@ impl crate::Context for Context {
resolve_target: ca.resolve_target.map(|rt| rt.id),
channel: map_pass_channel(Some(&ca.ops)),
})
.collect::<ArrayVec<_, { wgc::MAX_COLOR_TARGETS }>>();
.collect::<ArrayVec<_, { wgc::MAX_COLOR_ATTACHMENTS }>>();
let depth_stencil = desc.depth_stencil_attachment.as_ref().map(|dsa| {
wgc::command::RenderPassDepthStencilAttachment {