mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-30 01:54:31 +01:00
Add missing maxColorAttachmentBytesPerSample validation for render passes (#8697)
This commit is contained in:
1 parent
f558612470
commit
422d539731
5 files changed
+31
-20
No files matched your search
@@ -195,6 +195,7 @@ By @cwfitzgerald in [#8609](https://github.com/gfx-rs/wgpu/pull/8609).
|
||||
- Corrected documentation of the minimum alignment of the _end_ of a mapped range of a buffer (it is 4, not 8). By @kpreid in [#8450](https://github.com/gfx-rs/wgpu/pull/8450).
|
||||
- `util::StagingBelt` now takes a `Device` when it is created instead of when it is used. By @kpreid in [#8462](https://github.com/gfx-rs/wgpu/pull/8462).
|
||||
- `wgpu_hal::vulkan::Texture` API changes to handle externally-created textures and memory more flexibly. By @s-ol in [#8512](https://github.com/gfx-rs/wgpu/pull/8512), [#8521](https://github.com/gfx-rs/wgpu/pull/8521).
|
||||
- Render passes are now validated against the `maxColorAttachmentBytesPerSample` limit. By @andyleiserson in [#8697](https://github.com/gfx-rs/wgpu/pull/8697).
|
||||
|
||||
#### Metal
|
||||
|
||||
|
||||
+1
-1
@@ -129,7 +129,7 @@ webgpu:api,validation,queue,buffer_mapped:copyTextureToBuffer:*
|
||||
webgpu:api,validation,queue,buffer_mapped:map_command_recording_order:*
|
||||
webgpu:api,validation,queue,submit:command_buffer,*
|
||||
webgpu:api,validation,render_pass,render_pass_descriptor:attachments,*
|
||||
webgpu:api,validation,render_pass,render_pass_descriptor:color_attachments,depthSlice,*
|
||||
webgpu:api,validation,render_pass,render_pass_descriptor:color_attachments,*
|
||||
webgpu:api,validation,render_pass,render_pass_descriptor:resolveTarget,*
|
||||
webgpu:api,validation,render_pass,resolve:resolve_attachment:*
|
||||
webgpu:api,validation,resource_usages,buffer,in_pass_encoder:*
|
||||
|
||||
@@ -44,7 +44,7 @@ use crate::{
|
||||
ParentDevice, QuerySet, Texture, TextureView, TextureViewNotRenderableReason,
|
||||
},
|
||||
track::{ResourceUsageCompatibilityError, Tracker, UsageScope},
|
||||
Label,
|
||||
validation, Label,
|
||||
};
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
@@ -1277,6 +1277,15 @@ impl RenderPassInfo {
|
||||
));
|
||||
}
|
||||
|
||||
validation::validate_color_attachment_bytes_per_sample(
|
||||
color_attachments
|
||||
.iter()
|
||||
.flatten()
|
||||
.map(|at| at.view.desc.format),
|
||||
device.limits.max_color_attachment_bytes_per_sample,
|
||||
)
|
||||
.map_err(RenderPassErrorInner::ColorAttachment)?;
|
||||
|
||||
fn check_attachment_overlap(
|
||||
attachment_set: &mut crate::FastHashSet<(crate::track::TrackerIndex, u32, u32)>,
|
||||
view: &TextureView,
|
||||
|
||||
@@ -52,7 +52,7 @@ use crate::{
|
||||
snatch::{SnatchGuard, SnatchLock, Snatchable},
|
||||
timestamp_normalization::TIMESTAMP_NORMALIZATION_BUFFER_USES,
|
||||
track::{BindGroupStates, DeviceTracker, TrackerIndexAllocators, UsageScope, UsageScopePool},
|
||||
validation::{self, validate_color_attachment_bytes_per_sample},
|
||||
validation,
|
||||
weak_vec::WeakVec,
|
||||
FastHashMap, LabelHelpers, OnceCellOrLock,
|
||||
};
|
||||
@@ -4134,15 +4134,11 @@ impl Device {
|
||||
}
|
||||
}
|
||||
|
||||
let limit = self.limits.max_color_attachment_bytes_per_sample;
|
||||
let formats = color_targets
|
||||
.iter()
|
||||
.map(|cs| cs.as_ref().map(|cs| cs.format));
|
||||
if let Err(total) = validate_color_attachment_bytes_per_sample(formats, limit) {
|
||||
return Err(pipeline::CreateRenderPipelineError::ColorAttachment(
|
||||
command::ColorAttachmentError::TooManyBytesPerSample { total, limit },
|
||||
));
|
||||
}
|
||||
validation::validate_color_attachment_bytes_per_sample(
|
||||
color_targets.iter().flatten().map(|cs| cs.format),
|
||||
self.limits.max_color_attachment_bytes_per_sample,
|
||||
)
|
||||
.map_err(pipeline::CreateRenderPipelineError::ColorAttachment)?;
|
||||
|
||||
if let Some(ds) = depth_stencil_state {
|
||||
target_specified = true;
|
||||
|
||||
@@ -1411,17 +1411,17 @@ impl Interface {
|
||||
}
|
||||
}
|
||||
|
||||
// https://gpuweb.github.io/gpuweb/#abstract-opdef-calculating-color-attachment-bytes-per-sample
|
||||
/// Validate a list of color attachment formats against `maxColorAttachmentBytesPerSample`.
|
||||
///
|
||||
/// The color attachments can be from a render pass descriptor or a pipeline descriptor.
|
||||
///
|
||||
/// Implements <https://gpuweb.github.io/gpuweb/#abstract-opdef-calculating-color-attachment-bytes-per-sample>.
|
||||
pub fn validate_color_attachment_bytes_per_sample(
|
||||
attachment_formats: impl Iterator<Item = Option<wgt::TextureFormat>>,
|
||||
attachment_formats: impl IntoIterator<Item = wgt::TextureFormat>,
|
||||
limit: u32,
|
||||
) -> Result<(), u32> {
|
||||
) -> Result<(), crate::command::ColorAttachmentError> {
|
||||
let mut total_bytes_per_sample: u32 = 0;
|
||||
for format in attachment_formats {
|
||||
let Some(format) = format else {
|
||||
continue;
|
||||
};
|
||||
|
||||
let byte_cost = format.target_pixel_byte_cost().unwrap();
|
||||
let alignment = format.target_component_alignment().unwrap();
|
||||
|
||||
@@ -1430,7 +1430,12 @@ pub fn validate_color_attachment_bytes_per_sample(
|
||||
}
|
||||
|
||||
if total_bytes_per_sample > limit {
|
||||
return Err(total_bytes_per_sample);
|
||||
return Err(
|
||||
crate::command::ColorAttachmentError::TooManyBytesPerSample {
|
||||
total: total_bytes_per_sample,
|
||||
limit,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in new issue
Block a user