add RenderPassColorAttachment::depth_slice

This commit is contained in:
teoxoy 2025-04-17 17:58:48 +02:00 committed by Teodor Tanasoaia
parent 6058dd4296
commit 5ecc48d494
56 changed files with 76 additions and 2 deletions

View File

@ -360,6 +360,7 @@ impl RenderpassState {
label: None,
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view: &self.render_target,
depth_slice: None,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::BLACK),
@ -406,6 +407,7 @@ impl RenderpassState {
label: None,
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view: &self.render_target,
depth_slice: None,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::BLACK),

View File

@ -63,6 +63,7 @@ impl GPUCommandEncoder {
attachment.into_option().map(|attachment| {
wgpu_core::command::RenderPassColorAttachment {
view: attachment.view.id,
depth_slice: attachment.depth_slice,
resolve_target: attachment.resolve_target.map(|target| target.id),
load_op: attachment
.load_op

View File

@ -402,8 +402,8 @@ pub(crate) struct GPURenderPassDescriptor {
#[webidl(dictionary)]
pub(crate) struct GPURenderPassColorAttachment {
pub view: Ptr<GPUTextureView>,
/*#[options(enforce_range = true)]
pub depth_slice: Option<u32>,*/
#[options(enforce_range = true)]
pub depth_slice: Option<u32>,
pub resolve_target: Option<Ptr<GPUTextureView>>,
pub clear_value: Option<GPUColor>,
pub load_op: GPULoadOp,

View File

@ -263,6 +263,7 @@ impl crate::framework::Example for Example {
// create render pass descriptor and its color attachments
let color_attachments = [Some(wgpu::RenderPassColorAttachment {
view,
depth_slice: None,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::BLACK),

View File

@ -112,6 +112,7 @@ impl Example {
label: None,
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view,
depth_slice: None,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(clear_color),

View File

@ -263,6 +263,7 @@ impl crate::framework::Example for Example {
label: Some("low resolution"),
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view: &self.low_res_target,
depth_slice: None,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::BLACK),
@ -284,6 +285,7 @@ impl crate::framework::Example for Example {
label: Some("full resolution"),
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view,
depth_slice: None,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::BLACK),

View File

@ -341,6 +341,7 @@ impl crate::framework::Example for Example {
label: None,
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view,
depth_slice: None,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color {

View File

@ -118,6 +118,7 @@ async fn run(event_loop: EventLoop<()>, window: Window) {
label: None,
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view: &view,
depth_slice: None,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::GREEN),

View File

@ -119,6 +119,7 @@ async fn run(event_loop: EventLoop<()>, viewports: Vec<(Arc<Window>, wgpu::Color
color_attachments: &[Some(
wgpu::RenderPassColorAttachment {
view: &view,
depth_slice: None,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(

View File

@ -160,6 +160,7 @@ impl Example {
label: None,
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view: &views[target_mip],
depth_slice: None,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::WHITE),
@ -481,6 +482,7 @@ impl crate::framework::Example for Example {
label: None,
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view,
depth_slice: None,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(clear_color),

View File

@ -279,6 +279,7 @@ impl crate::framework::Example for Example {
let rpass_color_attachment = if self.sample_count == 1 {
wgpu::RenderPassColorAttachment {
view,
depth_slice: None,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::BLACK),
@ -288,6 +289,7 @@ impl crate::framework::Example for Example {
} else {
wgpu::RenderPassColorAttachment {
view: &self.multisampled_framebuffer,
depth_slice: None,
resolve_target: Some(view),
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::BLACK),

View File

@ -329,6 +329,7 @@ impl TargetRenderer {
label: None,
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view: surface_view,
depth_slice: None,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::GREEN),
@ -508,11 +509,13 @@ impl crate::framework::Example for Example {
&[
Some(wgpu::RenderPassColorAttachment {
view: &self.texture_targets.red_view,
depth_slice: None,
resolve_target: None,
ops: Default::default(),
}),
Some(wgpu::RenderPassColorAttachment {
view: &self.texture_targets.green_view,
depth_slice: None,
resolve_target: None,
ops: Default::default(),
}),

View File

@ -462,6 +462,7 @@ impl crate::framework::Example for Example {
label: None,
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view,
depth_slice: None,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::GREEN),

View File

@ -349,6 +349,7 @@ impl crate::framework::Example for Example {
label: None,
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view,
depth_slice: None,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::GREEN),

View File

@ -450,6 +450,7 @@ impl crate::framework::Example for Example {
label: None,
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view,
depth_slice: None,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::GREEN),

View File

@ -529,6 +529,7 @@ impl crate::framework::Example for Example {
label: None,
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view,
depth_slice: None,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::GREEN),

View File

@ -335,6 +335,7 @@ impl crate::framework::Example for Example {
label: None,
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view,
depth_slice: None,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color {

View File

@ -406,6 +406,7 @@ impl crate::framework::Example for Example {
label: None,
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view,
depth_slice: None,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::GREEN),

View File

@ -84,6 +84,7 @@ async fn run(_path: Option<String>) {
label: None,
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view: &texture_view,
depth_slice: None,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::GREEN),

View File

@ -794,6 +794,7 @@ impl crate::framework::Example for Example {
label: None,
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view,
depth_slice: None,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color {

View File

@ -426,6 +426,7 @@ impl crate::framework::Example for Example {
label: None,
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view,
depth_slice: None,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color {

View File

@ -181,6 +181,7 @@ impl<const SRGB: bool> crate::framework::Example for Example<SRGB> {
label: None,
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view,
depth_slice: None,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color {

View File

@ -200,6 +200,7 @@ impl crate::framework::Example for Example {
label: None,
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view,
depth_slice: None,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color {

View File

@ -392,6 +392,7 @@ impl crate::framework::Example for Example {
label: None,
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view,
depth_slice: None,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::BLACK),

View File

@ -380,6 +380,7 @@ fn render_pass(
label: None,
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view: &render_target_view,
depth_slice: None,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::GREEN),

View File

@ -307,6 +307,7 @@ async fn run(event_loop: EventLoop<()>, window: Arc<Window>) {
color_attachments: &[Some(
wgpu::RenderPassColorAttachment {
view: &view,
depth_slice: None,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::GREEN),

View File

@ -731,6 +731,7 @@ impl crate::framework::Example for Example {
label: None,
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view: &self.reflect_view,
depth_slice: None,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(back_color),
@ -760,6 +761,7 @@ impl crate::framework::Example for Example {
label: None,
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view,
depth_slice: None,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(back_color),
@ -789,6 +791,7 @@ impl crate::framework::Example for Example {
label: None,
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view,
depth_slice: None,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Load,

View File

@ -97,6 +97,7 @@ impl State {
label: None,
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view: &texture_view,
depth_slice: None,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::GREEN),

View File

@ -210,6 +210,7 @@ async fn binding_array_sampled_textures(ctx: TestingContext, partially_bound: bo
label: Some("Render Pass"),
color_attachments: &[Some(RenderPassColorAttachment {
view: &output_view,
depth_slice: None,
resolve_target: None,
ops: Operations {
load: LoadOp::Clear(Color::BLACK),

View File

@ -369,6 +369,7 @@ static DEVICE_DESTROY_THEN_MORE: GpuTestConfiguration = GpuTestConfiguration::ne
ops: wgpu::Operations::default(),
resolve_target: None,
view: &target_view,
depth_slice: None,
})],
depth_stencil_attachment: None,
timestamp_writes: None,

View File

@ -241,6 +241,7 @@ async fn run_test(ctx: TestingContext, test_data: TestData, expect_noop: bool) {
ops: wgpu::Operations::default(),
resolve_target: None,
view: &out_texture_view,
depth_slice: None,
})],
depth_stencil_attachment: None,
timestamp_writes: None,
@ -707,6 +708,7 @@ async fn indirect_buffer_offsets(ctx: TestingContext) {
ops: wgpu::Operations::default(),
resolve_target: None,
view: &out_texture_view,
depth_slice: None,
})],
depth_stencil_attachment: None,
timestamp_writes: None,

View File

@ -55,6 +55,7 @@ static DROP_ENCODER_AFTER_ERROR: GpuTestConfiguration = GpuTestConfiguration::ne
ops: wgpu::Operations::default(),
resolve_target: None,
view: &target_view,
depth_slice: None,
})],
depth_stencil_attachment: None,
timestamp_writes: None,
@ -285,6 +286,7 @@ fn encoder_operations_fail_while_pass_alive(ctx: TestingContext) {
.begin_render_pass(&wgpu::RenderPassDescriptor {
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view: &color_attachment_view,
depth_slice: None,
resolve_target: None,
ops: wgpu::Operations::default(),
})],

View File

@ -187,6 +187,7 @@ async fn draw_test_with_reports(
ops: wgpu::Operations::default(),
resolve_target: None,
view: &texture_view,
depth_slice: None,
})],
depth_stencil_attachment: None,
timestamp_writes: None,

View File

@ -109,6 +109,7 @@ static NV12_TEXTURE_CREATION_SAMPLING: GpuTestConfiguration = GpuTestConfigurati
ops: wgpu::Operations::default(),
resolve_target: None,
view: &target_view,
depth_slice: None,
})],
depth_stencil_attachment: None,
timestamp_writes: None,

View File

@ -301,6 +301,7 @@ async fn render_pass_test(ctx: &TestingContext, use_render_bundle: bool) {
label: Some("Render Pass"),
color_attachments: &[Some(RenderPassColorAttachment {
view: &output_texture_view,
depth_slice: None,
resolve_target: None,
ops: Operations {
load: LoadOp::Clear(Color::default()),

View File

@ -151,6 +151,7 @@ async fn multi_stage_data_binding_test(ctx: TestingContext) {
label: Some("rpass"),
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view: &view,
depth_slice: None,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::BLACK),

View File

@ -141,6 +141,7 @@ static PASS_RESET_VERTEX_BUFFER: GpuTestConfiguration =
label: Some("double renderpass"),
color_attachments: &[Some(RenderPassColorAttachment {
view: &view,
depth_slice: None,
resolve_target: None,
ops: Operations {
load: LoadOp::Clear(Color::BLACK),
@ -176,6 +177,7 @@ static PASS_RESET_VERTEX_BUFFER: GpuTestConfiguration =
label: Some("single renderpass"),
color_attachments: &[Some(RenderPassColorAttachment {
view: &view,
depth_slice: None,
resolve_target: None,
ops: Operations {
load: LoadOp::Clear(Color::BLACK),

View File

@ -76,6 +76,7 @@ async fn test_impl(ctx: &TestingContext) {
label: Some("Renderpass"),
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view: &texture_view,
depth_slice: None,
resolve_target: None,
ops: wgpu::Operations {
// Important: this isn't the color expected below

View File

@ -76,6 +76,7 @@ async fn test_impl(ctx: &TestingContext) {
label: Some("Renderpass"),
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view: &texture_view,
depth_slice: None,
resolve_target: None,
ops: wgpu::Operations {
// Important: this isn't the color expected below

View File

@ -66,6 +66,7 @@ async fn render_pass_resource_ownership(ctx: TestingContext) {
label: Some("render_pass"),
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view: &color_attachment_view,
depth_slice: None,
resolve_target: Some(&color_attachment_resolve_view),
ops: wgpu::Operations::default(),
})],
@ -147,6 +148,7 @@ async fn render_pass_query_set_ownership_pipeline_statistics(ctx: TestingContext
let mut rpass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view: &color_attachment_view,
depth_slice: None,
resolve_target: None,
ops: wgpu::Operations::default(),
})],
@ -217,6 +219,7 @@ async fn render_pass_query_set_ownership_timestamps(ctx: TestingContext) {
let mut rpass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view: &color_attachment_view,
depth_slice: None,
resolve_target: None,
ops: wgpu::Operations::default(),
})],
@ -274,6 +277,7 @@ async fn render_pass_keep_encoder_alive(ctx: TestingContext) {
let rpass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view: &color_attachment_view,
depth_slice: None,
resolve_target: None,
ops: wgpu::Operations::default(),
})],

View File

@ -177,6 +177,7 @@ async fn run_test(
label: None,
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view: ms_texture_view.as_ref().unwrap_or(&out_texture_view),
depth_slice: None,
resolve_target: multisample.then_some(&out_texture_view),
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::BLACK),

View File

@ -74,6 +74,7 @@ async fn scissor_test_impl(
label: Some("Renderpass"),
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view: &texture_view,
depth_slice: None,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color {

View File

@ -184,6 +184,7 @@ async fn pulling_common(
},
resolve_target: None,
view: &color_view,
depth_slice: None,
})],
depth_stencil_attachment: None,
timestamp_writes: None,

View File

@ -142,6 +142,7 @@ async fn reinterpret(
ops: wgpu::Operations::default(),
resolve_target: None,
view: &target_view,
depth_slice: None,
})],
depth_stencil_attachment: None,
timestamp_writes: None,

View File

@ -351,6 +351,7 @@ async fn vertex_formats_common(ctx: TestingContext, tests: &[Test<'_>]) {
ops: wgpu::Operations::default(),
resolve_target: None,
view: &dummy,
depth_slice: None,
})],
depth_stencil_attachment: None,
timestamp_writes: None,

View File

@ -357,6 +357,7 @@ async fn vertex_index_common(ctx: TestingContext) {
ops: wgpu::Operations::default(),
resolve_target: None,
view: &dummy,
depth_slice: None,
})],
depth_stencil_attachment: None,
timestamp_writes: None,

View File

@ -227,6 +227,7 @@ impl<'ctx> TestCase<'ctx> {
color_attachments: &[self.format.has_color_aspect().then_some(
RenderPassColorAttachment {
view: &self.texture.create_view(&TextureViewDescriptor::default()),
depth_slice: None,
resolve_target: None,
ops: Operations {
load: LoadOp::Load,

View File

@ -461,6 +461,7 @@ fn clear_texture_via_render_passes(
),
usage: wgt::TextureUses::COLOR_TARGET,
},
depth_slice: None,
resolve_target: None,
ops: hal::AttachmentOps::STORE,
clear_value: wgt::Color::TRANSPARENT,

View File

@ -162,6 +162,8 @@ impl<V: Copy + Default> ResolvedPassChannel<V> {
pub struct RenderPassColorAttachment<TV = id::TextureViewId> {
/// The view to use as an attachment.
pub view: TV,
/// The depth slice index of a 3D view. It must not be provided if the view is not 3D.
pub depth_slice: Option<u32>,
/// The view that will receive the resolved output if multisampling is used.
pub resolve_target: Option<TV>,
/// Operation to perform to the output attachment at the start of a
@ -1201,6 +1203,7 @@ impl<'d> RenderPassInfo<'d> {
view: color_view.try_raw(snatch_guard)?,
usage: wgt::TextureUses::COLOR_TARGET,
},
depth_slice: at.depth_slice,
resolve_target: hal_resolve_target,
ops: at.hal_ops(),
clear_value: at.clear_value(),
@ -1417,6 +1420,7 @@ impl Global {
for color_attachment in desc.color_attachments.iter() {
if let Some(RenderPassColorAttachment {
view: view_id,
depth_slice,
resolve_target,
load_op,
store_op,
@ -1438,6 +1442,7 @@ impl Global {
.color_attachments
.push(Some(ArcRenderPassColorAttachment {
view,
depth_slice: *depth_slice,
resolve_target,
load_op: *load_op,
store_op: *store_op,

View File

@ -708,6 +708,7 @@ impl<A: hal::Api> Example<A> {
view: &surface_tex_view,
usage: wgpu_types::TextureUses::COLOR_TARGET,
},
depth_slice: None,
resolve_target: None,
ops: hal::AttachmentOps::STORE,
clear_value: wgpu_types::Color {

View File

@ -323,6 +323,7 @@ fn fill_screen(exposed: &hal::ExposedAdapter<hal::api::Gles>, width: u32, height
view: &view,
usage: wgpu_types::TextureUses::COLOR_TARGET,
},
depth_slice: None,
resolve_target: None,
ops: hal::AttachmentOps::STORE,
clear_value: wgpu_types::Color::BLUE,

View File

@ -730,6 +730,7 @@ impl<'a> ColorAttachment<'a, dyn DynTextureView> {
pub fn expect_downcast<B: DynTextureView>(&self) -> ColorAttachment<'a, B> {
ColorAttachment {
target: self.target.expect_downcast(),
depth_slice: self.depth_slice,
resolve_target: self.resolve_target.as_ref().map(|rt| rt.expect_downcast()),
ops: self.ops,
clear_value: self.clear_value,

View File

@ -2336,6 +2336,7 @@ pub struct Attachment<'a, T: DynTextureView + ?Sized> {
#[derive(Clone, Debug)]
pub struct ColorAttachment<'a, T: DynTextureView + ?Sized> {
pub target: Attachment<'a, T>,
pub depth_slice: Option<u32>,
pub resolve_target: Option<Attachment<'a, T>>,
pub ops: AttachmentOps,
pub clear_value: wgt::Color,

View File

@ -522,6 +522,8 @@ static_assertions::assert_impl_all!(RenderPassTimestampWrites<'_>: Send, Sync);
pub struct RenderPassColorAttachment<'tex> {
/// The view to use as an attachment.
pub view: &'tex TextureView,
/// The depth slice index of a 3D view. It must not be provided if the view is not 3D.
pub depth_slice: Option<u32>,
/// The view that will receive the resolved output if multisampling is used.
///
/// If set, it is always written to, regardless of how [`Self::ops`] is configured.

View File

@ -2348,6 +2348,7 @@ impl dispatch::CommandEncoderInterface for CoreCommandEncoder {
ca.as_ref()
.map(|at| wgc::command::RenderPassColorAttachment {
view: at.view.inner.as_core().id,
depth_slice: at.depth_slice,
resolve_target: at.resolve_target.map(|view| view.inner.as_core().id),
load_op: at.ops.load,
store_op: at.ops.store,

View File

@ -199,6 +199,7 @@ impl TextureBlitter {
label: Some("wgpu::util::TextureBlitter::pass"),
color_attachments: &[Some(crate::RenderPassColorAttachment {
view: target,
depth_slice: None,
resolve_target: None,
ops: wgt::Operations {
load: LoadOp::Load,