mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
Check whether attachments are of same size or not
This commit is contained in:
parent
f266431f24
commit
a10e5cdb53
@ -316,6 +316,8 @@ pub enum RenderPassError {
|
||||
Encoder(#[from] CommandEncoderError),
|
||||
#[error("attachment texture view {0:?} is invalid")]
|
||||
InvalidAttachment(id::TextureViewId),
|
||||
#[error("attachments have different sizes")]
|
||||
MismatchAttachments,
|
||||
#[error("attachment's sample count {0} is invalid")]
|
||||
InvalidSampleCount(u8),
|
||||
#[error("attachment with resolve target must be multi-sampled")]
|
||||
@ -466,8 +468,9 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
}
|
||||
let mut output_attachments = AttachmentDataVec::<OutputAttachment>::new();
|
||||
|
||||
let mut attachment_width = std::u32::MAX;
|
||||
let mut attachment_height = std::u32::MAX;
|
||||
let mut attachment_width = None;
|
||||
let mut attachment_height = None;
|
||||
let mut valid_attachment = true;
|
||||
|
||||
let context = {
|
||||
use hal::device::Device as _;
|
||||
@ -571,8 +574,10 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
.map_err(|_| RenderPassError::InvalidAttachment(at.attachment))?;
|
||||
add_view(view)?;
|
||||
|
||||
attachment_width = attachment_width.min(view.extent.width);
|
||||
attachment_height = attachment_height.min(view.extent.height);
|
||||
valid_attachment &= *attachment_width.get_or_insert(view.extent.width)
|
||||
== view.extent.width
|
||||
&& *attachment_height.get_or_insert(view.extent.height)
|
||||
== view.extent.height;
|
||||
|
||||
let layouts = match view.inner {
|
||||
TextureViewInner::Native { ref source_id, .. } => {
|
||||
@ -629,6 +634,10 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
colors.push((color_at, hal::image::Layout::ColorAttachmentOptimal));
|
||||
}
|
||||
|
||||
if !valid_attachment {
|
||||
Err(RenderPassError::MismatchAttachments)?
|
||||
}
|
||||
|
||||
for resolve_target in color_attachments.iter().flat_map(|at| at.resolve_target) {
|
||||
let view = trackers
|
||||
.views
|
||||
@ -1266,8 +1275,8 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
use std::{convert::TryFrom, i16};
|
||||
if rect.w == 0
|
||||
|| rect.h == 0
|
||||
|| rect.x + rect.w > attachment_width
|
||||
|| rect.y + rect.h > attachment_height
|
||||
|| rect.x + rect.w > attachment_width.unwrap()
|
||||
|| rect.y + rect.h > attachment_height.unwrap()
|
||||
{
|
||||
Err(RenderCommandError::InvalidScissorRect)?
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ pub enum TransferError {
|
||||
#[error("texture {0:?} is invalid")]
|
||||
InvalidTexture(TextureId),
|
||||
#[error("Source and destination cannot be the same buffer")]
|
||||
AttemptToCopyWithinBuffer,
|
||||
SameSourceDestinationBuffer,
|
||||
#[error("source buffer/texture is missing the `COPY_SRC` usage flag")]
|
||||
MissingCopySrcUsageFlag,
|
||||
#[error("destination buffer/texture is missing the `COPY_DST` usage flag")]
|
||||
@ -305,7 +305,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
span!(_guard, INFO, "CommandEncoder::copy_buffer_to_buffer");
|
||||
|
||||
if source == destination {
|
||||
Err(TransferError::AttemptToCopyWithinBuffer)?
|
||||
Err(TransferError::SameSourceDestinationBuffer)?
|
||||
}
|
||||
let hub = B::hub(self);
|
||||
let mut token = Token::root();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user