mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-25 00:03:29 +00:00
Handle TooManyAttachments in wgpu-core (#6076)
This commit is contained in:
parent
9619a43849
commit
de960ccbba
@ -595,6 +595,8 @@ pub enum CommandEncoderError {
|
||||
InvalidTimestampWritesQuerySetId(id::QuerySetId),
|
||||
#[error("Attachment TextureViewId {0:?} is invalid")]
|
||||
InvalidAttachmentId(id::TextureViewId),
|
||||
#[error(transparent)]
|
||||
InvalidColorAttachment(#[from] ColorAttachmentError),
|
||||
#[error("Resolve attachment TextureViewId {0:?} is invalid")]
|
||||
InvalidResolveTargetId(id::TextureViewId),
|
||||
#[error("Depth stencil attachment TextureViewId {0:?} is invalid")]
|
||||
|
@ -1342,10 +1342,21 @@ impl Global {
|
||||
hub: &crate::hub::Hub<A>,
|
||||
desc: &RenderPassDescriptor<'_>,
|
||||
arc_desc: &mut ArcRenderPassDescriptor<A>,
|
||||
device: &Device<A>,
|
||||
) -> Result<(), CommandEncoderError> {
|
||||
let query_sets = hub.query_sets.read();
|
||||
let texture_views = hub.texture_views.read();
|
||||
|
||||
let max_color_attachments = device.limits.max_color_attachments as usize;
|
||||
if desc.color_attachments.len() > max_color_attachments {
|
||||
return Err(CommandEncoderError::InvalidColorAttachment(
|
||||
ColorAttachmentError::TooMany {
|
||||
given: desc.color_attachments.len(),
|
||||
limit: max_color_attachments,
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
for color_attachment in desc.color_attachments.iter() {
|
||||
if let Some(RenderPassColorAttachment {
|
||||
view: view_id,
|
||||
@ -1447,7 +1458,7 @@ impl Global {
|
||||
Err(e) => return make_err(e, arc_desc),
|
||||
};
|
||||
|
||||
let err = fill_arc_desc(hub, desc, &mut arc_desc).err();
|
||||
let err = fill_arc_desc(hub, desc, &mut arc_desc, &cmd_buf.device).err();
|
||||
|
||||
(RenderPass::new(Some(cmd_buf), arc_desc), err)
|
||||
}
|
||||
|
@ -1923,15 +1923,6 @@ impl crate::Context for ContextWgpuCore {
|
||||
encoder_data: &Self::CommandEncoderData,
|
||||
desc: &crate::RenderPassDescriptor<'_>,
|
||||
) -> (Self::RenderPassId, Self::RenderPassData) {
|
||||
if desc.color_attachments.len() > wgc::MAX_COLOR_ATTACHMENTS {
|
||||
self.handle_error_fatal(
|
||||
wgc::command::ColorAttachmentError::TooMany {
|
||||
given: desc.color_attachments.len(),
|
||||
limit: wgc::MAX_COLOR_ATTACHMENTS,
|
||||
},
|
||||
"CommandEncoder::begin_render_pass",
|
||||
);
|
||||
}
|
||||
let colors = desc
|
||||
.color_attachments
|
||||
.iter()
|
||||
@ -1943,7 +1934,7 @@ impl crate::Context for ContextWgpuCore {
|
||||
channel: map_pass_channel(Some(&at.ops)),
|
||||
})
|
||||
})
|
||||
.collect::<ArrayVec<_, { wgc::MAX_COLOR_ATTACHMENTS }>>();
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let depth_stencil = desc.depth_stencil_attachment.as_ref().map(|dsa| {
|
||||
wgc::command::RenderPassDepthStencilAttachment {
|
||||
|
Loading…
Reference in New Issue
Block a user