mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
Check render bundle encoding for RODS
This commit is contained in:
@@ -46,6 +46,7 @@ use crate::{
|
||||
hub::{GlobalIdentityHandlerFactory, HalApi, Hub, Resource, Storage, Token},
|
||||
id,
|
||||
memory_init_tracker::{MemoryInitKind, MemoryInitTrackerAction},
|
||||
pipeline::PipelineFlags,
|
||||
track::{TrackerSet, UsageConflict},
|
||||
validation::check_buffer_usage,
|
||||
Label, LabelHelpers, LifeGuard, Stored,
|
||||
@@ -66,9 +67,9 @@ pub struct RenderBundleEncoderDescriptor<'a> {
|
||||
/// The formats of the color attachments that this render bundle is capable to rendering to. This
|
||||
/// must match the formats of the color attachments in the renderpass this render bundle is executed in.
|
||||
pub color_formats: Cow<'a, [wgt::TextureFormat]>,
|
||||
/// The formats of the depth attachment that this render bundle is capable to rendering to. This
|
||||
/// must match the formats of the depth attachments in the renderpass this render bundle is executed in.
|
||||
pub depth_stencil_format: Option<wgt::TextureFormat>,
|
||||
/// Information about the depth attachment that this render bundle is capable to rendering to. The format
|
||||
/// must match the format of the depth attachments in the renderpass this render bundle is executed in.
|
||||
pub depth_stencil: Option<wgt::RenderBundleDepthStencil>,
|
||||
/// Sample count this render bundle is capable of rendering to. This must match the pipelines and
|
||||
/// the renderpasses it is used in.
|
||||
pub sample_count: u32,
|
||||
@@ -80,6 +81,7 @@ pub struct RenderBundleEncoder {
|
||||
base: BasePass<RenderCommand>,
|
||||
parent_id: id::DeviceId,
|
||||
pub(crate) context: RenderPassContext,
|
||||
is_ds_read_only: bool,
|
||||
}
|
||||
|
||||
impl RenderBundleEncoder {
|
||||
@@ -95,7 +97,7 @@ impl RenderBundleEncoder {
|
||||
attachments: AttachmentData {
|
||||
colors: desc.color_formats.iter().cloned().collect(),
|
||||
resolves: ArrayVec::new(),
|
||||
depth_stencil: desc.depth_stencil_format,
|
||||
depth_stencil: desc.depth_stencil.map(|ds| ds.format),
|
||||
},
|
||||
sample_count: {
|
||||
let sc = desc.sample_count;
|
||||
@@ -105,6 +107,14 @@ impl RenderBundleEncoder {
|
||||
sc
|
||||
},
|
||||
},
|
||||
is_ds_read_only: match desc.depth_stencil {
|
||||
Some(ds) => {
|
||||
let aspects = hal::FormatAspects::from(ds.format);
|
||||
(!aspects.contains(hal::FormatAspects::DEPTH) || ds.depth_read_only)
|
||||
&& (!aspects.contains(hal::FormatAspects::STENCIL) || ds.stencil_read_only)
|
||||
}
|
||||
None => false,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -120,6 +130,7 @@ impl RenderBundleEncoder {
|
||||
},
|
||||
sample_count: 0,
|
||||
},
|
||||
is_ds_read_only: false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,7 +246,12 @@ impl RenderBundleEncoder {
|
||||
.map_err(RenderCommandError::IncompatiblePipeline)
|
||||
.map_pass_err(scope)?;
|
||||
|
||||
//TODO: check read-only depth
|
||||
if pipeline.flags.contains(PipelineFlags::WRITES_DEPTH_STENCIL)
|
||||
&& self.is_ds_read_only
|
||||
{
|
||||
return Err(RenderCommandError::IncompatibleReadOnlyDepthStencil)
|
||||
.map_pass_err(scope);
|
||||
}
|
||||
|
||||
let layout = &pipeline_layout_guard[pipeline.layout_id.value];
|
||||
pipeline_layout_id = Some(pipeline.layout_id.value);
|
||||
|
||||
@@ -1939,7 +1939,7 @@ impl<A: HalApi> Device<A> {
|
||||
.iter()
|
||||
.any(|ct| ct.write_mask != first.write_mask || ct.blend != first.blend)
|
||||
} {
|
||||
log::error!("Color targets: {:?}", color_targets);
|
||||
log::info!("Color targets: {:?}", color_targets);
|
||||
self.require_downlevel_flags(wgt::DownlevelFlags::INDEPENDENT_BLENDING)?;
|
||||
}
|
||||
|
||||
|
||||
@@ -2746,6 +2746,20 @@ impl<L> CommandBufferDescriptor<L> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Describes the depth/stencil attachment for render bundles.
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "trace", derive(serde::Serialize))]
|
||||
#[cfg_attr(feature = "replay", derive(serde::Deserialize))]
|
||||
pub struct RenderBundleDepthStencil {
|
||||
/// Format of the attachment.
|
||||
pub format: TextureFormat,
|
||||
/// True if the depth aspect is used but not modified.
|
||||
pub depth_read_only: bool,
|
||||
/// True if the stencil aspect is used but not modified.
|
||||
pub stencil_read_only: bool,
|
||||
}
|
||||
|
||||
/// Describes a [`RenderBundle`].
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
|
||||
@@ -77,7 +77,7 @@ impl Example {
|
||||
device.create_render_bundle_encoder(&wgpu::RenderBundleEncoderDescriptor {
|
||||
label: None,
|
||||
color_formats: &[sc_desc.format],
|
||||
depth_stencil_format: None,
|
||||
depth_stencil: None,
|
||||
sample_count,
|
||||
});
|
||||
encoder.set_pipeline(&pipeline);
|
||||
|
||||
@@ -1291,7 +1291,7 @@ impl crate::Context for Context {
|
||||
let descriptor = wgc::command::RenderBundleEncoderDescriptor {
|
||||
label: desc.label.map(Borrowed),
|
||||
color_formats: Borrowed(desc.color_formats),
|
||||
depth_stencil_format: desc.depth_stencil_format,
|
||||
depth_stencil: desc.depth_stencil,
|
||||
sample_count: desc.sample_count,
|
||||
};
|
||||
match wgc::command::RenderBundleEncoder::new(&descriptor, device.id, None) {
|
||||
|
||||
@@ -1324,9 +1324,9 @@ pub struct RenderBundleEncoderDescriptor<'a> {
|
||||
/// The formats of the color attachments that this render bundle is capable to rendering to. This
|
||||
/// must match the formats of the color attachments in the renderpass this render bundle is executed in.
|
||||
pub color_formats: &'a [TextureFormat],
|
||||
/// The formats of the depth attachment that this render bundle is capable to rendering to. This
|
||||
/// must match the formats of the depth attachments in the renderpass this render bundle is executed in.
|
||||
pub depth_stencil_format: Option<TextureFormat>,
|
||||
/// Information about the depth attachment that this render bundle is capable to rendering to. This
|
||||
/// must match the format of the depth attachments in the renderpass this render bundle is executed in.
|
||||
pub depth_stencil: Option<wgt::RenderBundleDepthStencil>,
|
||||
/// Sample count this render bundle is capable of rendering to. This must match the pipelines and
|
||||
/// the renderpasses it is used in.
|
||||
pub sample_count: u32,
|
||||
|
||||
Reference in New Issue
Block a user