mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-19 22:11:01 +01:00
Merge #897
897: Improve diagnostics of incompatible attachments r=kvark a=scoopr **Description** Attempt to improve the diagnostics of incompatible attachments Co-authored-by: Mikko Lehtonen <scoopr@iki.fi>
This commit is contained in:
commit
5b67fe71f8
4 files changed
+55
-19
No files matched your search
@@ -719,9 +719,11 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
.use_extend(&*pipeline_guard, pipeline_id, (), ())
|
||||
.unwrap();
|
||||
|
||||
if !bundle_encoder.context.compatible(&pipeline.pass_context) {
|
||||
Err(RenderCommandError::IncompatiblePipeline)?
|
||||
}
|
||||
bundle_encoder
|
||||
.context
|
||||
.check_compatible(&pipeline.pass_context)
|
||||
.map_err(|e| RenderCommandError::IncompatiblePipeline(e))?;
|
||||
|
||||
//TODO: check read-only depth
|
||||
|
||||
let layout = &pipeline_layout_guard[pipeline.layout_id.value];
|
||||
|
||||
@@ -59,8 +59,8 @@ pub enum RenderCommandError {
|
||||
InvalidDynamicOffsetCount { actual: usize, expected: usize },
|
||||
#[error("render pipeline {0:?} is invalid")]
|
||||
InvalidPipeline(id::RenderPipelineId),
|
||||
#[error("render pipeline output formats and sample counts do not match render pass attachment formats")]
|
||||
IncompatiblePipeline,
|
||||
#[error("render pipeline is incompatible, {0}")]
|
||||
IncompatiblePipeline(#[from] crate::device::RenderPassCompatibilityError),
|
||||
#[error("pipeline is not compatible with the depth-stencil read-only render pass")]
|
||||
IncompatibleReadOnlyDepthStencil,
|
||||
#[error("buffer {0:?} is in error {1:?}")]
|
||||
|
||||
@@ -11,8 +11,8 @@ use crate::{
|
||||
},
|
||||
conv,
|
||||
device::{
|
||||
AttachmentData, AttachmentDataVec, FramebufferKey, RenderPassContext, RenderPassKey,
|
||||
MAX_COLOR_TARGETS, MAX_VERTEX_BUFFERS,
|
||||
AttachmentData, AttachmentDataVec, FramebufferKey, RenderPassCompatibilityError,
|
||||
RenderPassContext, RenderPassKey, MAX_COLOR_TARGETS, MAX_VERTEX_BUFFERS,
|
||||
},
|
||||
hub::{GfxBackend, Global, GlobalIdentityHandlerFactory, Token},
|
||||
id,
|
||||
@@ -361,8 +361,8 @@ pub enum RenderPassError {
|
||||
},
|
||||
#[error("cannot pop debug group, because number of pushed debug groups is zero")]
|
||||
InvalidPopDebugGroup,
|
||||
#[error("render bundle output formats do not match render pass attachment formats")]
|
||||
IncompatibleRenderBundle,
|
||||
#[error("render bundle is incompatible, {0}")]
|
||||
IncompatibleRenderBundle(#[from] RenderPassCompatibilityError),
|
||||
#[error(transparent)]
|
||||
RenderCommand(#[from] RenderCommandError),
|
||||
#[error(transparent)]
|
||||
@@ -1016,9 +1016,10 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
.use_extend(&*pipeline_guard, pipeline_id, (), ())
|
||||
.unwrap();
|
||||
|
||||
if !context.compatible(&pipeline.pass_context) {
|
||||
return Err(RenderCommandError::IncompatiblePipeline.into());
|
||||
}
|
||||
context
|
||||
.check_compatible(&pipeline.pass_context)
|
||||
.map_err(|e| RenderCommandError::IncompatiblePipeline(e))?;
|
||||
|
||||
if pipeline.flags.contains(PipelineFlags::WRITES_DEPTH_STENCIL)
|
||||
&& is_ds_read_only
|
||||
{
|
||||
@@ -1512,9 +1513,9 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
.use_extend(&*bundle_guard, bundle_id, (), ())
|
||||
.unwrap();
|
||||
|
||||
if !context.compatible(&bundle.context) {
|
||||
return Err(RenderPassError::IncompatibleRenderBundle);
|
||||
}
|
||||
context
|
||||
.check_compatible(&bundle.context)
|
||||
.map_err(|e| RenderPassError::IncompatibleRenderBundle(e))?;
|
||||
|
||||
unsafe {
|
||||
bundle.execute(
|
||||
|
||||
@@ -106,13 +106,46 @@ pub(crate) struct RenderPassContext {
|
||||
pub attachments: AttachmentData<TextureFormat>,
|
||||
pub sample_count: u8,
|
||||
}
|
||||
#[derive(Clone, Debug, Error)]
|
||||
pub enum RenderPassCompatibilityError {
|
||||
#[error("incompatible color attachment: {0:?} != {1:?}")]
|
||||
IncompatibleColorAttachment(
|
||||
ArrayVec<[TextureFormat; MAX_COLOR_TARGETS]>,
|
||||
ArrayVec<[TextureFormat; MAX_COLOR_TARGETS]>,
|
||||
),
|
||||
#[error("incompatible depth-stencil attachment: {0:?} != {1:?}")]
|
||||
IncompatibleDepthStencilAttachment(Option<TextureFormat>, Option<TextureFormat>),
|
||||
#[error("incompatible sample count: {0:?} != {1:?}")]
|
||||
IncompatibleSampleCount(u8, u8),
|
||||
}
|
||||
|
||||
impl RenderPassContext {
|
||||
// Assumed the renderpass only contains one subpass
|
||||
pub(crate) fn compatible(&self, other: &RenderPassContext) -> bool {
|
||||
self.attachments.colors == other.attachments.colors
|
||||
&& self.attachments.depth_stencil == other.attachments.depth_stencil
|
||||
&& self.sample_count == other.sample_count
|
||||
pub(crate) fn check_compatible(
|
||||
&self,
|
||||
other: &RenderPassContext,
|
||||
) -> Result<(), RenderPassCompatibilityError> {
|
||||
if self.attachments.colors != other.attachments.colors {
|
||||
return Err(RenderPassCompatibilityError::IncompatibleColorAttachment(
|
||||
self.attachments.colors.clone(),
|
||||
other.attachments.colors.clone(),
|
||||
));
|
||||
}
|
||||
if self.attachments.depth_stencil != other.attachments.depth_stencil {
|
||||
return Err(
|
||||
RenderPassCompatibilityError::IncompatibleDepthStencilAttachment(
|
||||
self.attachments.depth_stencil.clone(),
|
||||
other.attachments.depth_stencil.clone(),
|
||||
),
|
||||
);
|
||||
}
|
||||
if self.sample_count != other.sample_count {
|
||||
return Err(RenderPassCompatibilityError::IncompatibleSampleCount(
|
||||
self.sample_count,
|
||||
other.sample_count,
|
||||
));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user