remove dyn render & compute pass

This commit is contained in:
Andreas Reich 2024-08-06 23:29:21 +02:00
parent 0287eaf022
commit 0fb772b5df
9 changed files with 312 additions and 898 deletions

View File

@ -211,7 +211,7 @@ pub fn op_webgpu_command_encoder_begin_render_pass(
}; };
let (render_pass, error) = let (render_pass, error) =
instance.command_encoder_create_render_pass_dyn(*command_encoder, &descriptor); instance.command_encoder_create_render_pass(*command_encoder, &descriptor);
let rid = state let rid = state
.resource_table .resource_table
.add(super::render_pass::WebGpuRenderPass(RefCell::new( .add(super::render_pass::WebGpuRenderPass(RefCell::new(
@ -264,7 +264,7 @@ pub fn op_webgpu_command_encoder_begin_compute_pass(
}; };
let (compute_pass, error) = let (compute_pass, error) =
instance.command_encoder_create_compute_pass_dyn(*command_encoder, &descriptor); instance.command_encoder_create_compute_pass(*command_encoder, &descriptor);
let rid = state let rid = state
.resource_table .resource_table
.add(super::compute_pass::WebGpuComputePass(RefCell::new( .add(super::compute_pass::WebGpuComputePass(RefCell::new(

View File

@ -10,9 +10,7 @@ use std::cell::RefCell;
use super::error::WebGpuResult; use super::error::WebGpuResult;
pub(crate) struct WebGpuComputePass( pub(crate) struct WebGpuComputePass(pub(crate) RefCell<wgpu_core::command::ComputePass>);
pub(crate) RefCell<Box<dyn wgpu_core::command::DynComputePass>>,
);
impl Resource for WebGpuComputePass { impl Resource for WebGpuComputePass {
fn name(&self) -> Cow<str> { fn name(&self) -> Cow<str> {
"webGPUComputePass".into() "webGPUComputePass".into()
@ -33,10 +31,12 @@ pub fn op_webgpu_compute_pass_set_pipeline(
.resource_table .resource_table
.get::<WebGpuComputePass>(compute_pass_rid)?; .get::<WebGpuComputePass>(compute_pass_rid)?;
compute_pass_resource state
.0 .borrow::<wgpu_core::global::Global>()
.borrow_mut() .compute_pass_set_pipeline(
.set_pipeline(state.borrow(), compute_pipeline_resource.1)?; &mut compute_pass_resource.0.borrow_mut(),
compute_pipeline_resource.1,
)?;
Ok(WebGpuResult::empty()) Ok(WebGpuResult::empty())
} }
@ -54,10 +54,9 @@ pub fn op_webgpu_compute_pass_dispatch_workgroups(
.resource_table .resource_table
.get::<WebGpuComputePass>(compute_pass_rid)?; .get::<WebGpuComputePass>(compute_pass_rid)?;
compute_pass_resource state
.0 .borrow::<wgpu_core::global::Global>()
.borrow_mut() .compute_pass_dispatch_workgroups(&mut compute_pass_resource.0.borrow_mut(), x, y, z)?;
.dispatch_workgroups(state.borrow(), x, y, z)?;
Ok(WebGpuResult::empty()) Ok(WebGpuResult::empty())
} }
@ -77,10 +76,13 @@ pub fn op_webgpu_compute_pass_dispatch_workgroups_indirect(
.resource_table .resource_table
.get::<WebGpuComputePass>(compute_pass_rid)?; .get::<WebGpuComputePass>(compute_pass_rid)?;
compute_pass_resource state
.0 .borrow::<wgpu_core::global::Global>()
.borrow_mut() .compute_pass_dispatch_workgroups_indirect(
.dispatch_workgroups_indirect(state.borrow(), buffer_resource.1, indirect_offset)?; &mut compute_pass_resource.0.borrow_mut(),
buffer_resource.1,
indirect_offset,
)?;
Ok(WebGpuResult::empty()) Ok(WebGpuResult::empty())
} }
@ -95,7 +97,9 @@ pub fn op_webgpu_compute_pass_end(
.resource_table .resource_table
.take::<WebGpuComputePass>(compute_pass_rid)?; .take::<WebGpuComputePass>(compute_pass_rid)?;
compute_pass_resource.0.borrow_mut().end(state.borrow())?; state
.borrow::<wgpu_core::global::Global>()
.compute_pass_end(&mut compute_pass_resource.0.borrow_mut())?;
Ok(WebGpuResult::empty()) Ok(WebGpuResult::empty())
} }
@ -127,8 +131,10 @@ pub fn op_webgpu_compute_pass_set_bind_group(
let dynamic_offsets_data: &[u32] = &dynamic_offsets_data[start..start + len]; let dynamic_offsets_data: &[u32] = &dynamic_offsets_data[start..start + len];
compute_pass_resource.0.borrow_mut().set_bind_group( state
state.borrow(), .borrow::<wgpu_core::global::Global>()
.compute_pass_set_bind_group(
&mut compute_pass_resource.0.borrow_mut(),
index, index,
bind_group_resource.1, bind_group_resource.1,
dynamic_offsets_data, dynamic_offsets_data,
@ -148,8 +154,10 @@ pub fn op_webgpu_compute_pass_push_debug_group(
.resource_table .resource_table
.get::<WebGpuComputePass>(compute_pass_rid)?; .get::<WebGpuComputePass>(compute_pass_rid)?;
compute_pass_resource.0.borrow_mut().push_debug_group( state
state.borrow(), .borrow::<wgpu_core::global::Global>()
.compute_pass_push_debug_group(
&mut compute_pass_resource.0.borrow_mut(),
group_label, group_label,
0, // wgpu#975 0, // wgpu#975
)?; )?;
@ -167,10 +175,9 @@ pub fn op_webgpu_compute_pass_pop_debug_group(
.resource_table .resource_table
.get::<WebGpuComputePass>(compute_pass_rid)?; .get::<WebGpuComputePass>(compute_pass_rid)?;
compute_pass_resource state
.0 .borrow::<wgpu_core::global::Global>()
.borrow_mut() .compute_pass_pop_debug_group(&mut compute_pass_resource.0.borrow_mut())?;
.pop_debug_group(state.borrow())?;
Ok(WebGpuResult::empty()) Ok(WebGpuResult::empty())
} }
@ -186,8 +193,10 @@ pub fn op_webgpu_compute_pass_insert_debug_marker(
.resource_table .resource_table
.get::<WebGpuComputePass>(compute_pass_rid)?; .get::<WebGpuComputePass>(compute_pass_rid)?;
compute_pass_resource.0.borrow_mut().insert_debug_marker( state
state.borrow(), .borrow::<wgpu_core::global::Global>()
.compute_pass_insert_debug_marker(
&mut compute_pass_resource.0.borrow_mut(),
marker_label, marker_label,
0, // wgpu#975 0, // wgpu#975
)?; )?;

View File

@ -12,7 +12,7 @@ use std::cell::RefCell;
use super::error::WebGpuResult; use super::error::WebGpuResult;
pub(crate) struct WebGpuRenderPass(pub(crate) RefCell<Box<dyn wgpu_core::command::DynRenderPass>>); pub(crate) struct WebGpuRenderPass(pub(crate) RefCell<wgpu_core::command::RenderPass>);
impl Resource for WebGpuRenderPass { impl Resource for WebGpuRenderPass {
fn name(&self) -> Cow<str> { fn name(&self) -> Cow<str> {
"webGPURenderPass".into() "webGPURenderPass".into()
@ -41,8 +41,10 @@ pub fn op_webgpu_render_pass_set_viewport(
.resource_table .resource_table
.get::<WebGpuRenderPass>(args.render_pass_rid)?; .get::<WebGpuRenderPass>(args.render_pass_rid)?;
render_pass_resource.0.borrow_mut().set_viewport( state
state.borrow(), .borrow::<wgpu_core::global::Global>()
.render_pass_set_viewport(
&mut render_pass_resource.0.borrow_mut(),
args.x, args.x,
args.y, args.y,
args.width, args.width,
@ -68,10 +70,15 @@ pub fn op_webgpu_render_pass_set_scissor_rect(
.resource_table .resource_table
.get::<WebGpuRenderPass>(render_pass_rid)?; .get::<WebGpuRenderPass>(render_pass_rid)?;
render_pass_resource state
.0 .borrow::<wgpu_core::global::Global>()
.borrow_mut() .render_pass_set_scissor_rect(
.set_scissor_rect(state.borrow(), x, y, width, height)?; &mut render_pass_resource.0.borrow_mut(),
x,
y,
width,
height,
)?;
Ok(WebGpuResult::empty()) Ok(WebGpuResult::empty())
} }
@ -87,10 +94,9 @@ pub fn op_webgpu_render_pass_set_blend_constant(
.resource_table .resource_table
.get::<WebGpuRenderPass>(render_pass_rid)?; .get::<WebGpuRenderPass>(render_pass_rid)?;
render_pass_resource state
.0 .borrow::<wgpu_core::global::Global>()
.borrow_mut() .render_pass_set_blend_constant(&mut render_pass_resource.0.borrow_mut(), color)?;
.set_blend_constant(state.borrow(), color)?;
Ok(WebGpuResult::empty()) Ok(WebGpuResult::empty())
} }
@ -106,10 +112,9 @@ pub fn op_webgpu_render_pass_set_stencil_reference(
.resource_table .resource_table
.get::<WebGpuRenderPass>(render_pass_rid)?; .get::<WebGpuRenderPass>(render_pass_rid)?;
render_pass_resource state
.0 .borrow::<wgpu_core::global::Global>()
.borrow_mut() .render_pass_set_stencil_reference(&mut render_pass_resource.0.borrow_mut(), reference)?;
.set_stencil_reference(state.borrow(), reference)?;
Ok(WebGpuResult::empty()) Ok(WebGpuResult::empty())
} }
@ -125,10 +130,9 @@ pub fn op_webgpu_render_pass_begin_occlusion_query(
.resource_table .resource_table
.get::<WebGpuRenderPass>(render_pass_rid)?; .get::<WebGpuRenderPass>(render_pass_rid)?;
render_pass_resource state
.0 .borrow::<wgpu_core::global::Global>()
.borrow_mut() .render_pass_begin_occlusion_query(&mut render_pass_resource.0.borrow_mut(), query_index)?;
.begin_occlusion_query(state.borrow(), query_index)?;
Ok(WebGpuResult::empty()) Ok(WebGpuResult::empty())
} }
@ -143,10 +147,9 @@ pub fn op_webgpu_render_pass_end_occlusion_query(
.resource_table .resource_table
.get::<WebGpuRenderPass>(render_pass_rid)?; .get::<WebGpuRenderPass>(render_pass_rid)?;
render_pass_resource state
.0 .borrow::<wgpu_core::global::Global>()
.borrow_mut() .render_pass_end_occlusion_query(&mut render_pass_resource.0.borrow_mut())?;
.end_occlusion_query(state.borrow())?;
Ok(WebGpuResult::empty()) Ok(WebGpuResult::empty())
} }
@ -172,10 +175,9 @@ pub fn op_webgpu_render_pass_execute_bundles(
.resource_table .resource_table
.get::<WebGpuRenderPass>(render_pass_rid)?; .get::<WebGpuRenderPass>(render_pass_rid)?;
render_pass_resource state
.0 .borrow::<wgpu_core::global::Global>()
.borrow_mut() .render_pass_execute_bundles(&mut render_pass_resource.0.borrow_mut(), &bundles)?;
.execute_bundles(state.borrow(), &bundles)?;
Ok(WebGpuResult::empty()) Ok(WebGpuResult::empty())
} }
@ -190,7 +192,9 @@ pub fn op_webgpu_render_pass_end(
.resource_table .resource_table
.take::<WebGpuRenderPass>(render_pass_rid)?; .take::<WebGpuRenderPass>(render_pass_rid)?;
render_pass_resource.0.borrow_mut().end(state.borrow())?; state
.borrow::<wgpu_core::global::Global>()
.render_pass_end(&mut render_pass_resource.0.borrow_mut())?;
Ok(WebGpuResult::empty()) Ok(WebGpuResult::empty())
} }
@ -222,8 +226,10 @@ pub fn op_webgpu_render_pass_set_bind_group(
let dynamic_offsets_data: &[u32] = &dynamic_offsets_data[start..start + len]; let dynamic_offsets_data: &[u32] = &dynamic_offsets_data[start..start + len];
render_pass_resource.0.borrow_mut().set_bind_group( state
state.borrow(), .borrow::<wgpu_core::global::Global>()
.render_pass_set_bind_group(
&mut render_pass_resource.0.borrow_mut(),
index, index,
bind_group_resource.1, bind_group_resource.1,
dynamic_offsets_data, dynamic_offsets_data,
@ -243,8 +249,10 @@ pub fn op_webgpu_render_pass_push_debug_group(
.resource_table .resource_table
.get::<WebGpuRenderPass>(render_pass_rid)?; .get::<WebGpuRenderPass>(render_pass_rid)?;
render_pass_resource.0.borrow_mut().push_debug_group( state
state.borrow(), .borrow::<wgpu_core::global::Global>()
.render_pass_push_debug_group(
&mut render_pass_resource.0.borrow_mut(),
group_label, group_label,
0, // wgpu#975 0, // wgpu#975
)?; )?;
@ -262,10 +270,9 @@ pub fn op_webgpu_render_pass_pop_debug_group(
.resource_table .resource_table
.get::<WebGpuRenderPass>(render_pass_rid)?; .get::<WebGpuRenderPass>(render_pass_rid)?;
render_pass_resource state
.0 .borrow::<wgpu_core::global::Global>()
.borrow_mut() .render_pass_pop_debug_group(&mut render_pass_resource.0.borrow_mut())?;
.pop_debug_group(state.borrow())?;
Ok(WebGpuResult::empty()) Ok(WebGpuResult::empty())
} }
@ -281,8 +288,10 @@ pub fn op_webgpu_render_pass_insert_debug_marker(
.resource_table .resource_table
.get::<WebGpuRenderPass>(render_pass_rid)?; .get::<WebGpuRenderPass>(render_pass_rid)?;
render_pass_resource.0.borrow_mut().insert_debug_marker( state
state.borrow(), .borrow::<wgpu_core::global::Global>()
.render_pass_insert_debug_marker(
&mut render_pass_resource.0.borrow_mut(),
marker_label, marker_label,
0, // wgpu#975 0, // wgpu#975
)?; )?;
@ -304,10 +313,12 @@ pub fn op_webgpu_render_pass_set_pipeline(
.resource_table .resource_table
.get::<WebGpuRenderPass>(render_pass_rid)?; .get::<WebGpuRenderPass>(render_pass_rid)?;
render_pass_resource state
.0 .borrow::<wgpu_core::global::Global>()
.borrow_mut() .render_pass_set_pipeline(
.set_pipeline(state.borrow(), render_pipeline_resource.1)?; &mut render_pass_resource.0.borrow_mut(),
render_pipeline_resource.1,
)?;
Ok(WebGpuResult::empty()) Ok(WebGpuResult::empty())
} }
@ -338,8 +349,10 @@ pub fn op_webgpu_render_pass_set_index_buffer(
None None
}; };
render_pass_resource.0.borrow_mut().set_index_buffer( state
state.borrow(), .borrow::<wgpu_core::global::Global>()
.render_pass_set_index_buffer(
&mut render_pass_resource.0.borrow_mut(),
buffer_resource.1, buffer_resource.1,
index_format, index_format,
offset, offset,
@ -375,8 +388,10 @@ pub fn op_webgpu_render_pass_set_vertex_buffer(
None None
}; };
render_pass_resource.0.borrow_mut().set_vertex_buffer( state
state.borrow(), .borrow::<wgpu_core::global::Global>()
.render_pass_set_vertex_buffer(
&mut render_pass_resource.0.borrow_mut(),
slot, slot,
buffer_resource.1, buffer_resource.1,
offset, offset,
@ -400,8 +415,10 @@ pub fn op_webgpu_render_pass_draw(
.resource_table .resource_table
.get::<WebGpuRenderPass>(render_pass_rid)?; .get::<WebGpuRenderPass>(render_pass_rid)?;
render_pass_resource.0.borrow_mut().draw( state
state.borrow(), .borrow::<wgpu_core::global::Global>()
.render_pass_draw(
&mut render_pass_resource.0.borrow_mut(),
vertex_count, vertex_count,
instance_count, instance_count,
first_vertex, first_vertex,
@ -426,8 +443,10 @@ pub fn op_webgpu_render_pass_draw_indexed(
.resource_table .resource_table
.get::<WebGpuRenderPass>(render_pass_rid)?; .get::<WebGpuRenderPass>(render_pass_rid)?;
render_pass_resource.0.borrow_mut().draw_indexed( state
state.borrow(), .borrow::<wgpu_core::global::Global>()
.render_pass_draw_indexed(
&mut render_pass_resource.0.borrow_mut(),
index_count, index_count,
instance_count, instance_count,
first_index, first_index,
@ -453,8 +472,10 @@ pub fn op_webgpu_render_pass_draw_indirect(
.resource_table .resource_table
.get::<WebGpuRenderPass>(render_pass_rid)?; .get::<WebGpuRenderPass>(render_pass_rid)?;
render_pass_resource.0.borrow_mut().draw_indirect( state
state.borrow(), .borrow::<wgpu_core::global::Global>()
.render_pass_draw_indirect(
&mut render_pass_resource.0.borrow_mut(),
buffer_resource.1, buffer_resource.1,
indirect_offset, indirect_offset,
)?; )?;
@ -477,8 +498,10 @@ pub fn op_webgpu_render_pass_draw_indexed_indirect(
.resource_table .resource_table
.get::<WebGpuRenderPass>(render_pass_rid)?; .get::<WebGpuRenderPass>(render_pass_rid)?;
render_pass_resource.0.borrow_mut().draw_indexed_indirect( state
state.borrow(), .borrow::<wgpu_core::global::Global>()
.render_pass_draw_indexed_indirect(
&mut render_pass_resource.0.borrow_mut(),
buffer_resource.1, buffer_resource.1,
indirect_offset, indirect_offset,
)?; )?;

View File

@ -31,7 +31,7 @@ use wgt::{BufferAddress, DynamicOffset};
use std::sync::Arc; use std::sync::Arc;
use std::{fmt, mem, str}; use std::{fmt, mem, str};
use super::{bind::BinderError, memory_init::CommandBufferTextureMemoryActions, DynComputePass}; use super::{bind::BinderError, memory_init::CommandBufferTextureMemoryActions};
pub struct ComputePass { pub struct ComputePass {
/// All pass data & records is stored here. /// All pass data & records is stored here.
@ -328,19 +328,6 @@ impl Global {
(ComputePass::new(Some(cmd_buf), arc_desc), None) (ComputePass::new(Some(cmd_buf), arc_desc), None)
} }
/// Creates a type erased compute pass.
///
/// If creation fails, an invalid pass is returned.
/// Any operation on an invalid pass will return an error.
pub fn command_encoder_create_compute_pass_dyn(
&self,
encoder_id: id::CommandEncoderId,
desc: &ComputePassDescriptor,
) -> (Box<dyn DynComputePass>, Option<CommandEncoderError>) {
let (pass, err) = self.command_encoder_create_compute_pass(encoder_id, desc);
(Box::new(pass), err)
}
pub fn compute_pass_end(&self, pass: &mut ComputePass) -> Result<(), ComputePassError> { pub fn compute_pass_end(&self, pass: &mut ComputePass) -> Result<(), ComputePassError> {
let scope = PassErrorScope::Pass; let scope = PassErrorScope::Pass;

View File

@ -1,178 +0,0 @@
use wgt::WasmNotSendSync;
use crate::{global, id};
use super::{ComputePass, ComputePassError};
/// Trait for type erasing ComputePass.
// TODO(#5124): wgpu-core's ComputePass trait should not be hal type dependent.
// Practically speaking this allows us merge gfx_select with type erasure:
// The alternative would be to introduce ComputePassId which then first needs to be looked up and then dispatch via gfx_select.
pub trait DynComputePass: std::fmt::Debug + WasmNotSendSync {
fn set_bind_group(
&mut self,
context: &global::Global,
index: u32,
bind_group_id: id::BindGroupId,
offsets: &[wgt::DynamicOffset],
) -> Result<(), ComputePassError>;
fn set_pipeline(
&mut self,
context: &global::Global,
pipeline_id: id::ComputePipelineId,
) -> Result<(), ComputePassError>;
fn set_push_constants(
&mut self,
context: &global::Global,
offset: u32,
data: &[u8],
) -> Result<(), ComputePassError>;
fn dispatch_workgroups(
&mut self,
context: &global::Global,
groups_x: u32,
groups_y: u32,
groups_z: u32,
) -> Result<(), ComputePassError>;
fn dispatch_workgroups_indirect(
&mut self,
context: &global::Global,
buffer_id: id::BufferId,
offset: wgt::BufferAddress,
) -> Result<(), ComputePassError>;
fn push_debug_group(
&mut self,
context: &global::Global,
label: &str,
color: u32,
) -> Result<(), ComputePassError>;
fn pop_debug_group(&mut self, context: &global::Global) -> Result<(), ComputePassError>;
fn insert_debug_marker(
&mut self,
context: &global::Global,
label: &str,
color: u32,
) -> Result<(), ComputePassError>;
fn write_timestamp(
&mut self,
context: &global::Global,
query_set_id: id::QuerySetId,
query_index: u32,
) -> Result<(), ComputePassError>;
fn begin_pipeline_statistics_query(
&mut self,
context: &global::Global,
query_set_id: id::QuerySetId,
query_index: u32,
) -> Result<(), ComputePassError>;
fn end_pipeline_statistics_query(
&mut self,
context: &global::Global,
) -> Result<(), ComputePassError>;
fn end(&mut self, context: &global::Global) -> Result<(), ComputePassError>;
fn label(&self) -> Option<&str>;
}
impl DynComputePass for ComputePass {
fn set_bind_group(
&mut self,
context: &global::Global,
index: u32,
bind_group_id: id::BindGroupId,
offsets: &[wgt::DynamicOffset],
) -> Result<(), ComputePassError> {
context.compute_pass_set_bind_group(self, index, bind_group_id, offsets)
}
fn set_pipeline(
&mut self,
context: &global::Global,
pipeline_id: id::ComputePipelineId,
) -> Result<(), ComputePassError> {
context.compute_pass_set_pipeline(self, pipeline_id)
}
fn set_push_constants(
&mut self,
context: &global::Global,
offset: u32,
data: &[u8],
) -> Result<(), ComputePassError> {
context.compute_pass_set_push_constants(self, offset, data)
}
fn dispatch_workgroups(
&mut self,
context: &global::Global,
groups_x: u32,
groups_y: u32,
groups_z: u32,
) -> Result<(), ComputePassError> {
context.compute_pass_dispatch_workgroups(self, groups_x, groups_y, groups_z)
}
fn dispatch_workgroups_indirect(
&mut self,
context: &global::Global,
buffer_id: id::BufferId,
offset: wgt::BufferAddress,
) -> Result<(), ComputePassError> {
context.compute_pass_dispatch_workgroups_indirect(self, buffer_id, offset)
}
fn push_debug_group(
&mut self,
context: &global::Global,
label: &str,
color: u32,
) -> Result<(), ComputePassError> {
context.compute_pass_push_debug_group(self, label, color)
}
fn pop_debug_group(&mut self, context: &global::Global) -> Result<(), ComputePassError> {
context.compute_pass_pop_debug_group(self)
}
fn insert_debug_marker(
&mut self,
context: &global::Global,
label: &str,
color: u32,
) -> Result<(), ComputePassError> {
context.compute_pass_insert_debug_marker(self, label, color)
}
fn write_timestamp(
&mut self,
context: &global::Global,
query_set_id: id::QuerySetId,
query_index: u32,
) -> Result<(), ComputePassError> {
context.compute_pass_write_timestamp(self, query_set_id, query_index)
}
fn begin_pipeline_statistics_query(
&mut self,
context: &global::Global,
query_set_id: id::QuerySetId,
query_index: u32,
) -> Result<(), ComputePassError> {
context.compute_pass_begin_pipeline_statistics_query(self, query_set_id, query_index)
}
fn end_pipeline_statistics_query(
&mut self,
context: &global::Global,
) -> Result<(), ComputePassError> {
context.compute_pass_end_pipeline_statistics_query(self)
}
fn end(&mut self, context: &global::Global) -> Result<(), ComputePassError> {
context.compute_pass_end(self)
}
fn label(&self) -> Option<&str> {
self.label()
}
}

View File

@ -1,458 +0,0 @@
use wgt::WasmNotSendSync;
use crate::{global, id};
use super::{RenderPass, RenderPassError};
/// Trait for type erasing RenderPass.
// TODO(#5124): wgpu-core's RenderPass trait should not be hal type dependent.
// Practically speaking this allows us merge gfx_select with type erasure:
// The alternative would be to introduce RenderPassId which then first needs to be looked up and then dispatch via gfx_select.
pub trait DynRenderPass: std::fmt::Debug + WasmNotSendSync {
fn set_bind_group(
&mut self,
context: &global::Global,
index: u32,
bind_group_id: id::BindGroupId,
offsets: &[wgt::DynamicOffset],
) -> Result<(), RenderPassError>;
fn set_index_buffer(
&mut self,
context: &global::Global,
buffer_id: id::BufferId,
index_format: wgt::IndexFormat,
offset: wgt::BufferAddress,
size: Option<wgt::BufferSize>,
) -> Result<(), RenderPassError>;
fn set_vertex_buffer(
&mut self,
context: &global::Global,
slot: u32,
buffer_id: id::BufferId,
offset: wgt::BufferAddress,
size: Option<wgt::BufferSize>,
) -> Result<(), RenderPassError>;
fn set_pipeline(
&mut self,
context: &global::Global,
pipeline_id: id::RenderPipelineId,
) -> Result<(), RenderPassError>;
fn set_push_constants(
&mut self,
context: &global::Global,
stages: wgt::ShaderStages,
offset: u32,
data: &[u8],
) -> Result<(), RenderPassError>;
fn draw(
&mut self,
context: &global::Global,
vertex_count: u32,
instance_count: u32,
first_vertex: u32,
first_instance: u32,
) -> Result<(), RenderPassError>;
fn draw_indexed(
&mut self,
context: &global::Global,
index_count: u32,
instance_count: u32,
first_index: u32,
base_vertex: i32,
first_instance: u32,
) -> Result<(), RenderPassError>;
fn draw_indirect(
&mut self,
context: &global::Global,
buffer_id: id::BufferId,
offset: wgt::BufferAddress,
) -> Result<(), RenderPassError>;
fn draw_indexed_indirect(
&mut self,
context: &global::Global,
buffer_id: id::BufferId,
offset: wgt::BufferAddress,
) -> Result<(), RenderPassError>;
fn multi_draw_indirect(
&mut self,
context: &global::Global,
buffer_id: id::BufferId,
offset: wgt::BufferAddress,
count: u32,
) -> Result<(), RenderPassError>;
fn multi_draw_indexed_indirect(
&mut self,
context: &global::Global,
buffer_id: id::BufferId,
offset: wgt::BufferAddress,
count: u32,
) -> Result<(), RenderPassError>;
fn multi_draw_indirect_count(
&mut self,
context: &global::Global,
buffer_id: id::BufferId,
offset: wgt::BufferAddress,
count_buffer_id: id::BufferId,
count_buffer_offset: wgt::BufferAddress,
max_count: u32,
) -> Result<(), RenderPassError>;
fn multi_draw_indexed_indirect_count(
&mut self,
context: &global::Global,
buffer_id: id::BufferId,
offset: wgt::BufferAddress,
count_buffer_id: id::BufferId,
count_buffer_offset: wgt::BufferAddress,
max_count: u32,
) -> Result<(), RenderPassError>;
fn set_blend_constant(
&mut self,
context: &global::Global,
color: wgt::Color,
) -> Result<(), RenderPassError>;
fn set_scissor_rect(
&mut self,
context: &global::Global,
x: u32,
y: u32,
width: u32,
height: u32,
) -> Result<(), RenderPassError>;
fn set_viewport(
&mut self,
context: &global::Global,
x: f32,
y: f32,
width: f32,
height: f32,
min_depth: f32,
max_depth: f32,
) -> Result<(), RenderPassError>;
fn set_stencil_reference(
&mut self,
context: &global::Global,
reference: u32,
) -> Result<(), RenderPassError>;
fn push_debug_group(
&mut self,
context: &global::Global,
label: &str,
color: u32,
) -> Result<(), RenderPassError>;
fn pop_debug_group(&mut self, context: &global::Global) -> Result<(), RenderPassError>;
fn insert_debug_marker(
&mut self,
context: &global::Global,
label: &str,
color: u32,
) -> Result<(), RenderPassError>;
fn write_timestamp(
&mut self,
context: &global::Global,
query_set_id: id::QuerySetId,
query_index: u32,
) -> Result<(), RenderPassError>;
fn begin_occlusion_query(
&mut self,
context: &global::Global,
query_index: u32,
) -> Result<(), RenderPassError>;
fn end_occlusion_query(&mut self, context: &global::Global) -> Result<(), RenderPassError>;
fn begin_pipeline_statistics_query(
&mut self,
context: &global::Global,
query_set_id: id::QuerySetId,
query_index: u32,
) -> Result<(), RenderPassError>;
fn end_pipeline_statistics_query(
&mut self,
context: &global::Global,
) -> Result<(), RenderPassError>;
fn execute_bundles(
&mut self,
context: &global::Global,
bundles: &[id::RenderBundleId],
) -> Result<(), RenderPassError>;
fn end(&mut self, context: &global::Global) -> Result<(), RenderPassError>;
fn label(&self) -> Option<&str>;
}
impl DynRenderPass for RenderPass {
fn set_index_buffer(
&mut self,
context: &global::Global,
buffer_id: id::BufferId,
index_format: wgt::IndexFormat,
offset: wgt::BufferAddress,
size: Option<wgt::BufferSize>,
) -> Result<(), RenderPassError> {
context.render_pass_set_index_buffer(self, buffer_id, index_format, offset, size)
}
fn set_vertex_buffer(
&mut self,
context: &global::Global,
slot: u32,
buffer_id: id::BufferId,
offset: wgt::BufferAddress,
size: Option<wgt::BufferSize>,
) -> Result<(), RenderPassError> {
context.render_pass_set_vertex_buffer(self, slot, buffer_id, offset, size)
}
fn set_bind_group(
&mut self,
context: &global::Global,
index: u32,
bind_group_id: id::BindGroupId,
offsets: &[wgt::DynamicOffset],
) -> Result<(), RenderPassError> {
context.render_pass_set_bind_group(self, index, bind_group_id, offsets)
}
fn set_pipeline(
&mut self,
context: &global::Global,
pipeline_id: id::RenderPipelineId,
) -> Result<(), RenderPassError> {
context.render_pass_set_pipeline(self, pipeline_id)
}
fn set_push_constants(
&mut self,
context: &global::Global,
stages: wgt::ShaderStages,
offset: u32,
data: &[u8],
) -> Result<(), RenderPassError> {
context.render_pass_set_push_constants(self, stages, offset, data)
}
fn draw(
&mut self,
context: &global::Global,
vertex_count: u32,
instance_count: u32,
first_vertex: u32,
first_instance: u32,
) -> Result<(), RenderPassError> {
context.render_pass_draw(
self,
vertex_count,
instance_count,
first_vertex,
first_instance,
)
}
fn draw_indexed(
&mut self,
context: &global::Global,
index_count: u32,
instance_count: u32,
first_index: u32,
base_vertex: i32,
first_instance: u32,
) -> Result<(), RenderPassError> {
context.render_pass_draw_indexed(
self,
index_count,
instance_count,
first_index,
base_vertex,
first_instance,
)
}
fn draw_indirect(
&mut self,
context: &global::Global,
buffer_id: id::BufferId,
offset: wgt::BufferAddress,
) -> Result<(), RenderPassError> {
context.render_pass_draw_indirect(self, buffer_id, offset)
}
fn draw_indexed_indirect(
&mut self,
context: &global::Global,
buffer_id: id::BufferId,
offset: wgt::BufferAddress,
) -> Result<(), RenderPassError> {
context.render_pass_draw_indexed_indirect(self, buffer_id, offset)
}
fn multi_draw_indirect(
&mut self,
context: &global::Global,
buffer_id: id::BufferId,
offset: wgt::BufferAddress,
count: u32,
) -> Result<(), RenderPassError> {
context.render_pass_multi_draw_indirect(self, buffer_id, offset, count)
}
fn multi_draw_indexed_indirect(
&mut self,
context: &global::Global,
buffer_id: id::BufferId,
offset: wgt::BufferAddress,
count: u32,
) -> Result<(), RenderPassError> {
context.render_pass_multi_draw_indexed_indirect(self, buffer_id, offset, count)
}
fn multi_draw_indirect_count(
&mut self,
context: &global::Global,
buffer_id: id::BufferId,
offset: wgt::BufferAddress,
count_buffer_id: id::BufferId,
count_buffer_offset: wgt::BufferAddress,
max_count: u32,
) -> Result<(), RenderPassError> {
context.render_pass_multi_draw_indirect_count(
self,
buffer_id,
offset,
count_buffer_id,
count_buffer_offset,
max_count,
)
}
fn multi_draw_indexed_indirect_count(
&mut self,
context: &global::Global,
buffer_id: id::BufferId,
offset: wgt::BufferAddress,
count_buffer_id: id::BufferId,
count_buffer_offset: wgt::BufferAddress,
max_count: u32,
) -> Result<(), RenderPassError> {
context.render_pass_multi_draw_indexed_indirect_count(
self,
buffer_id,
offset,
count_buffer_id,
count_buffer_offset,
max_count,
)
}
fn set_blend_constant(
&mut self,
context: &global::Global,
color: wgt::Color,
) -> Result<(), RenderPassError> {
context.render_pass_set_blend_constant(self, color)
}
fn set_scissor_rect(
&mut self,
context: &global::Global,
x: u32,
y: u32,
width: u32,
height: u32,
) -> Result<(), RenderPassError> {
context.render_pass_set_scissor_rect(self, x, y, width, height)
}
fn set_viewport(
&mut self,
context: &global::Global,
x: f32,
y: f32,
width: f32,
height: f32,
min_depth: f32,
max_depth: f32,
) -> Result<(), RenderPassError> {
context.render_pass_set_viewport(self, x, y, width, height, min_depth, max_depth)
}
fn set_stencil_reference(
&mut self,
context: &global::Global,
reference: u32,
) -> Result<(), RenderPassError> {
context.render_pass_set_stencil_reference(self, reference)
}
fn push_debug_group(
&mut self,
context: &global::Global,
label: &str,
color: u32,
) -> Result<(), RenderPassError> {
context.render_pass_push_debug_group(self, label, color)
}
fn pop_debug_group(&mut self, context: &global::Global) -> Result<(), RenderPassError> {
context.render_pass_pop_debug_group(self)
}
fn insert_debug_marker(
&mut self,
context: &global::Global,
label: &str,
color: u32,
) -> Result<(), RenderPassError> {
context.render_pass_insert_debug_marker(self, label, color)
}
fn write_timestamp(
&mut self,
context: &global::Global,
query_set_id: id::QuerySetId,
query_index: u32,
) -> Result<(), RenderPassError> {
context.render_pass_write_timestamp(self, query_set_id, query_index)
}
fn begin_occlusion_query(
&mut self,
context: &global::Global,
query_index: u32,
) -> Result<(), RenderPassError> {
context.render_pass_begin_occlusion_query(self, query_index)
}
fn end_occlusion_query(&mut self, context: &global::Global) -> Result<(), RenderPassError> {
context.render_pass_end_occlusion_query(self)
}
fn begin_pipeline_statistics_query(
&mut self,
context: &global::Global,
query_set_id: id::QuerySetId,
query_index: u32,
) -> Result<(), RenderPassError> {
context.render_pass_begin_pipeline_statistics_query(self, query_set_id, query_index)
}
fn end_pipeline_statistics_query(
&mut self,
context: &global::Global,
) -> Result<(), RenderPassError> {
context.render_pass_end_pipeline_statistics_query(self)
}
fn execute_bundles(
&mut self,
context: &global::Global,
bundles: &[id::RenderBundleId],
) -> Result<(), RenderPassError> {
context.render_pass_execute_bundles(self, bundles)
}
fn end(&mut self, context: &global::Global) -> Result<(), RenderPassError> {
context.render_pass_end(self)
}
fn label(&self) -> Option<&str> {
self.label()
}
}

View File

@ -5,8 +5,6 @@ mod clear;
mod compute; mod compute;
mod compute_command; mod compute_command;
mod draw; mod draw;
mod dyn_compute_pass;
mod dyn_render_pass;
mod memory_init; mod memory_init;
mod query; mod query;
mod render; mod render;
@ -18,9 +16,8 @@ use std::sync::Arc;
pub(crate) use self::clear::clear_texture; pub(crate) use self::clear::clear_texture;
pub use self::{ pub use self::{
bundle::*, clear::ClearError, compute::*, compute_command::ComputeCommand, draw::*, bundle::*, clear::ClearError, compute::*, compute_command::ComputeCommand, draw::*, query::*,
dyn_compute_pass::DynComputePass, dyn_render_pass::DynRenderPass, query::*, render::*, render::*, render_command::RenderCommand, transfer::*,
render_command::RenderCommand, transfer::*,
}; };
pub(crate) use allocator::CommandAllocator; pub(crate) use allocator::CommandAllocator;

View File

@ -52,7 +52,7 @@ use super::{
memory_init::TextureSurfaceDiscard, CommandBufferTextureMemoryActions, CommandEncoder, memory_init::TextureSurfaceDiscard, CommandBufferTextureMemoryActions, CommandEncoder,
QueryResetMap, QueryResetMap,
}; };
use super::{DrawKind, DynRenderPass, Rect}; use super::{DrawKind, Rect};
/// Operation to perform to the output attachment at the start of a renderpass. /// Operation to perform to the output attachment at the start of a renderpass.
#[repr(C)] #[repr(C)]
@ -1461,19 +1461,6 @@ impl Global {
(RenderPass::new(Some(cmd_buf), arc_desc), err) (RenderPass::new(Some(cmd_buf), arc_desc), err)
} }
/// Creates a type erased render pass.
///
/// If creation fails, an invalid pass is returned.
/// Any operation on an invalid pass will return an error.
pub fn command_encoder_create_render_pass_dyn(
&self,
encoder_id: id::CommandEncoderId,
desc: &RenderPassDescriptor<'_>,
) -> (Box<dyn DynRenderPass>, Option<CommandEncoderError>) {
let (pass, err) = self.command_encoder_create_render_pass(encoder_id, desc);
(Box::new(pass), err)
}
#[doc(hidden)] #[doc(hidden)]
#[cfg(any(feature = "serde", feature = "replay"))] #[cfg(any(feature = "serde", feature = "replay"))]
pub fn render_pass_end_with_unresolved_commands( pub fn render_pass_end_with_unresolved_commands(

View File

@ -489,13 +489,13 @@ impl Queue {
#[derive(Debug)] #[derive(Debug)]
pub struct ComputePass { pub struct ComputePass {
pass: Box<dyn wgc::command::DynComputePass>, pass: wgc::command::ComputePass,
error_sink: ErrorSink, error_sink: ErrorSink,
} }
#[derive(Debug)] #[derive(Debug)]
pub struct RenderPass { pub struct RenderPass {
pass: Box<dyn wgc::command::DynRenderPass>, pass: wgc::command::RenderPass,
error_sink: ErrorSink, error_sink: ErrorSink,
} }
@ -1866,7 +1866,7 @@ impl crate::Context for ContextWgpuCore {
end_of_pass_write_index: tw.end_of_pass_write_index, end_of_pass_write_index: tw.end_of_pass_write_index,
}); });
let (pass, err) = self.0.command_encoder_create_compute_pass_dyn( let (pass, err) = self.0.command_encoder_create_compute_pass(
*encoder, *encoder,
&wgc::command::ComputePassDescriptor { &wgc::command::ComputePassDescriptor {
label: desc.label.map(Borrowed), label: desc.label.map(Borrowed),
@ -1928,7 +1928,7 @@ impl crate::Context for ContextWgpuCore {
end_of_pass_write_index: tw.end_of_pass_write_index, end_of_pass_write_index: tw.end_of_pass_write_index,
}); });
let (pass, err) = self.0.command_encoder_create_render_pass_dyn( let (pass, err) = self.0.command_encoder_create_render_pass(
*encoder, *encoder,
&wgc::command::RenderPassDescriptor { &wgc::command::RenderPassDescriptor {
label: desc.label.map(Borrowed), label: desc.label.map(Borrowed),
@ -2341,7 +2341,10 @@ impl crate::Context for ContextWgpuCore {
pipeline: &Self::ComputePipelineId, pipeline: &Self::ComputePipelineId,
_pipeline_data: &Self::ComputePipelineData, _pipeline_data: &Self::ComputePipelineData,
) { ) {
if let Err(cause) = pass_data.pass.set_pipeline(&self.0, *pipeline) { if let Err(cause) = self
.0
.compute_pass_set_pipeline(&mut pass_data.pass, *pipeline)
{
self.handle_error( self.handle_error(
&pass_data.error_sink, &pass_data.error_sink,
cause, cause,
@ -2360,9 +2363,9 @@ impl crate::Context for ContextWgpuCore {
_bind_group_data: &Self::BindGroupData, _bind_group_data: &Self::BindGroupData,
offsets: &[wgt::DynamicOffset], offsets: &[wgt::DynamicOffset],
) { ) {
if let Err(cause) = pass_data if let Err(cause) =
.pass self.0
.set_bind_group(&self.0, index, *bind_group, offsets) .compute_pass_set_bind_group(&mut pass_data.pass, index, *bind_group, offsets)
{ {
self.handle_error( self.handle_error(
&pass_data.error_sink, &pass_data.error_sink,
@ -2380,7 +2383,10 @@ impl crate::Context for ContextWgpuCore {
offset: u32, offset: u32,
data: &[u8], data: &[u8],
) { ) {
if let Err(cause) = pass_data.pass.set_push_constants(&self.0, offset, data) { if let Err(cause) =
self.0
.compute_pass_set_push_constants(&mut pass_data.pass, offset, data)
{
self.handle_error( self.handle_error(
&pass_data.error_sink, &pass_data.error_sink,
cause, cause,
@ -2396,7 +2402,10 @@ impl crate::Context for ContextWgpuCore {
pass_data: &mut Self::ComputePassData, pass_data: &mut Self::ComputePassData,
label: &str, label: &str,
) { ) {
if let Err(cause) = pass_data.pass.insert_debug_marker(&self.0, label, 0) { if let Err(cause) = self
.0
.compute_pass_insert_debug_marker(&mut pass_data.pass, label, 0)
{
self.handle_error( self.handle_error(
&pass_data.error_sink, &pass_data.error_sink,
cause, cause,
@ -2412,7 +2421,10 @@ impl crate::Context for ContextWgpuCore {
pass_data: &mut Self::ComputePassData, pass_data: &mut Self::ComputePassData,
group_label: &str, group_label: &str,
) { ) {
if let Err(cause) = pass_data.pass.push_debug_group(&self.0, group_label, 0) { if let Err(cause) =
self.0
.compute_pass_push_debug_group(&mut pass_data.pass, group_label, 0)
{
self.handle_error( self.handle_error(
&pass_data.error_sink, &pass_data.error_sink,
cause, cause,
@ -2427,7 +2439,7 @@ impl crate::Context for ContextWgpuCore {
_pass: &mut Self::ComputePassId, _pass: &mut Self::ComputePassId,
pass_data: &mut Self::ComputePassData, pass_data: &mut Self::ComputePassData,
) { ) {
if let Err(cause) = pass_data.pass.pop_debug_group(&self.0) { if let Err(cause) = self.0.compute_pass_pop_debug_group(&mut pass_data.pass) {
self.handle_error( self.handle_error(
&pass_data.error_sink, &pass_data.error_sink,
cause, cause,
@ -2445,9 +2457,9 @@ impl crate::Context for ContextWgpuCore {
_query_set_data: &Self::QuerySetData, _query_set_data: &Self::QuerySetData,
query_index: u32, query_index: u32,
) { ) {
if let Err(cause) = pass_data if let Err(cause) =
.pass self.0
.write_timestamp(&self.0, *query_set, query_index) .compute_pass_write_timestamp(&mut pass_data.pass, *query_set, query_index)
{ {
self.handle_error( self.handle_error(
&pass_data.error_sink, &pass_data.error_sink,
@ -2466,11 +2478,11 @@ impl crate::Context for ContextWgpuCore {
_query_set_data: &Self::QuerySetData, _query_set_data: &Self::QuerySetData,
query_index: u32, query_index: u32,
) { ) {
if let Err(cause) = if let Err(cause) = self.0.compute_pass_begin_pipeline_statistics_query(
pass_data &mut pass_data.pass,
.pass *query_set,
.begin_pipeline_statistics_query(&self.0, *query_set, query_index) query_index,
{ ) {
self.handle_error( self.handle_error(
&pass_data.error_sink, &pass_data.error_sink,
cause, cause,
@ -2485,7 +2497,10 @@ impl crate::Context for ContextWgpuCore {
_pass: &mut Self::ComputePassId, _pass: &mut Self::ComputePassId,
pass_data: &mut Self::ComputePassData, pass_data: &mut Self::ComputePassData,
) { ) {
if let Err(cause) = pass_data.pass.end_pipeline_statistics_query(&self.0) { if let Err(cause) = self
.0
.compute_pass_end_pipeline_statistics_query(&mut pass_data.pass)
{
self.handle_error( self.handle_error(
&pass_data.error_sink, &pass_data.error_sink,
cause, cause,
@ -2503,7 +2518,10 @@ impl crate::Context for ContextWgpuCore {
y: u32, y: u32,
z: u32, z: u32,
) { ) {
if let Err(cause) = pass_data.pass.dispatch_workgroups(&self.0, x, y, z) { if let Err(cause) = self
.0
.compute_pass_dispatch_workgroups(&mut pass_data.pass, x, y, z)
{
self.handle_error( self.handle_error(
&pass_data.error_sink, &pass_data.error_sink,
cause, cause,
@ -2521,11 +2539,11 @@ impl crate::Context for ContextWgpuCore {
_indirect_buffer_data: &Self::BufferData, _indirect_buffer_data: &Self::BufferData,
indirect_offset: wgt::BufferAddress, indirect_offset: wgt::BufferAddress,
) { ) {
if let Err(cause) = if let Err(cause) = self.0.compute_pass_dispatch_workgroups_indirect(
pass_data &mut pass_data.pass,
.pass *indirect_buffer,
.dispatch_workgroups_indirect(&self.0, *indirect_buffer, indirect_offset) indirect_offset,
{ ) {
self.handle_error( self.handle_error(
&pass_data.error_sink, &pass_data.error_sink,
cause, cause,
@ -2540,7 +2558,7 @@ impl crate::Context for ContextWgpuCore {
_pass: &mut Self::ComputePassId, _pass: &mut Self::ComputePassId,
pass_data: &mut Self::ComputePassData, pass_data: &mut Self::ComputePassData,
) { ) {
if let Err(cause) = pass_data.pass.end(&self.0) { if let Err(cause) = self.0.compute_pass_end(&mut pass_data.pass) {
self.handle_error( self.handle_error(
&pass_data.error_sink, &pass_data.error_sink,
cause, cause,
@ -2742,7 +2760,10 @@ impl crate::Context for ContextWgpuCore {
pipeline: &Self::RenderPipelineId, pipeline: &Self::RenderPipelineId,
_pipeline_data: &Self::RenderPipelineData, _pipeline_data: &Self::RenderPipelineData,
) { ) {
if let Err(cause) = pass_data.pass.set_pipeline(&self.0, *pipeline) { if let Err(cause) = self
.0
.render_pass_set_pipeline(&mut pass_data.pass, *pipeline)
{
self.handle_error( self.handle_error(
&pass_data.error_sink, &pass_data.error_sink,
cause, cause,
@ -2761,9 +2782,9 @@ impl crate::Context for ContextWgpuCore {
_bind_group_data: &Self::BindGroupData, _bind_group_data: &Self::BindGroupData,
offsets: &[wgt::DynamicOffset], offsets: &[wgt::DynamicOffset],
) { ) {
if let Err(cause) = pass_data if let Err(cause) =
.pass self.0
.set_bind_group(&self.0, index, *bind_group, offsets) .render_pass_set_bind_group(&mut pass_data.pass, index, *bind_group, offsets)
{ {
self.handle_error( self.handle_error(
&pass_data.error_sink, &pass_data.error_sink,
@ -2784,11 +2805,13 @@ impl crate::Context for ContextWgpuCore {
offset: wgt::BufferAddress, offset: wgt::BufferAddress,
size: Option<wgt::BufferSize>, size: Option<wgt::BufferSize>,
) { ) {
if let Err(cause) = if let Err(cause) = self.0.render_pass_set_index_buffer(
pass_data &mut pass_data.pass,
.pass *buffer,
.set_index_buffer(&self.0, *buffer, index_format, offset, size) index_format,
{ offset,
size,
) {
self.handle_error( self.handle_error(
&pass_data.error_sink, &pass_data.error_sink,
cause, cause,
@ -2808,9 +2831,9 @@ impl crate::Context for ContextWgpuCore {
offset: wgt::BufferAddress, offset: wgt::BufferAddress,
size: Option<wgt::BufferSize>, size: Option<wgt::BufferSize>,
) { ) {
if let Err(cause) = pass_data if let Err(cause) =
.pass self.0
.set_vertex_buffer(&self.0, slot, *buffer, offset, size) .render_pass_set_vertex_buffer(&mut pass_data.pass, slot, *buffer, offset, size)
{ {
self.handle_error( self.handle_error(
&pass_data.error_sink, &pass_data.error_sink,
@ -2829,9 +2852,9 @@ impl crate::Context for ContextWgpuCore {
offset: u32, offset: u32,
data: &[u8], data: &[u8],
) { ) {
if let Err(cause) = pass_data if let Err(cause) =
.pass self.0
.set_push_constants(&self.0, stages, offset, data) .render_pass_set_push_constants(&mut pass_data.pass, stages, offset, data)
{ {
self.handle_error( self.handle_error(
&pass_data.error_sink, &pass_data.error_sink,
@ -2849,8 +2872,8 @@ impl crate::Context for ContextWgpuCore {
vertices: Range<u32>, vertices: Range<u32>,
instances: Range<u32>, instances: Range<u32>,
) { ) {
if let Err(cause) = pass_data.pass.draw( if let Err(cause) = self.0.render_pass_draw(
&self.0, &mut pass_data.pass,
vertices.end - vertices.start, vertices.end - vertices.start,
instances.end - instances.start, instances.end - instances.start,
vertices.start, vertices.start,
@ -2873,8 +2896,8 @@ impl crate::Context for ContextWgpuCore {
base_vertex: i32, base_vertex: i32,
instances: Range<u32>, instances: Range<u32>,
) { ) {
if let Err(cause) = pass_data.pass.draw_indexed( if let Err(cause) = self.0.render_pass_draw_indexed(
&self.0, &mut pass_data.pass,
indices.end - indices.start, indices.end - indices.start,
instances.end - instances.start, instances.end - instances.start,
indices.start, indices.start,
@ -2898,9 +2921,9 @@ impl crate::Context for ContextWgpuCore {
_indirect_buffer_data: &Self::BufferData, _indirect_buffer_data: &Self::BufferData,
indirect_offset: wgt::BufferAddress, indirect_offset: wgt::BufferAddress,
) { ) {
if let Err(cause) = pass_data if let Err(cause) =
.pass self.0
.draw_indirect(&self.0, *indirect_buffer, indirect_offset) .render_pass_draw_indirect(&mut pass_data.pass, *indirect_buffer, indirect_offset)
{ {
self.handle_error( self.handle_error(
&pass_data.error_sink, &pass_data.error_sink,
@ -2919,11 +2942,11 @@ impl crate::Context for ContextWgpuCore {
_indirect_buffer_data: &Self::BufferData, _indirect_buffer_data: &Self::BufferData,
indirect_offset: wgt::BufferAddress, indirect_offset: wgt::BufferAddress,
) { ) {
if let Err(cause) = if let Err(cause) = self.0.render_pass_draw_indexed_indirect(
pass_data &mut pass_data.pass,
.pass *indirect_buffer,
.draw_indexed_indirect(&self.0, *indirect_buffer, indirect_offset) indirect_offset,
{ ) {
self.handle_error( self.handle_error(
&pass_data.error_sink, &pass_data.error_sink,
cause, cause,
@ -2942,11 +2965,12 @@ impl crate::Context for ContextWgpuCore {
indirect_offset: wgt::BufferAddress, indirect_offset: wgt::BufferAddress,
count: u32, count: u32,
) { ) {
if let Err(cause) = if let Err(cause) = self.0.render_pass_multi_draw_indirect(
pass_data &mut pass_data.pass,
.pass *indirect_buffer,
.multi_draw_indirect(&self.0, *indirect_buffer, indirect_offset, count) indirect_offset,
{ count,
) {
self.handle_error( self.handle_error(
&pass_data.error_sink, &pass_data.error_sink,
cause, cause,
@ -2965,8 +2989,8 @@ impl crate::Context for ContextWgpuCore {
indirect_offset: wgt::BufferAddress, indirect_offset: wgt::BufferAddress,
count: u32, count: u32,
) { ) {
if let Err(cause) = pass_data.pass.multi_draw_indexed_indirect( if let Err(cause) = self.0.render_pass_multi_draw_indexed_indirect(
&self.0, &mut pass_data.pass,
*indirect_buffer, *indirect_buffer,
indirect_offset, indirect_offset,
count, count,
@ -2992,8 +3016,8 @@ impl crate::Context for ContextWgpuCore {
count_buffer_offset: wgt::BufferAddress, count_buffer_offset: wgt::BufferAddress,
max_count: u32, max_count: u32,
) { ) {
if let Err(cause) = pass_data.pass.multi_draw_indirect_count( if let Err(cause) = self.0.render_pass_multi_draw_indirect_count(
&self.0, &mut pass_data.pass,
*indirect_buffer, *indirect_buffer,
indirect_offset, indirect_offset,
*count_buffer, *count_buffer,
@ -3021,8 +3045,8 @@ impl crate::Context for ContextWgpuCore {
count_buffer_offset: wgt::BufferAddress, count_buffer_offset: wgt::BufferAddress,
max_count: u32, max_count: u32,
) { ) {
if let Err(cause) = pass_data.pass.multi_draw_indexed_indirect_count( if let Err(cause) = self.0.render_pass_multi_draw_indexed_indirect_count(
&self.0, &mut pass_data.pass,
*indirect_buffer, *indirect_buffer,
indirect_offset, indirect_offset,
*count_buffer, *count_buffer,
@ -3044,7 +3068,10 @@ impl crate::Context for ContextWgpuCore {
pass_data: &mut Self::RenderPassData, pass_data: &mut Self::RenderPassData,
color: wgt::Color, color: wgt::Color,
) { ) {
if let Err(cause) = pass_data.pass.set_blend_constant(&self.0, color) { if let Err(cause) = self
.0
.render_pass_set_blend_constant(&mut pass_data.pass, color)
{
self.handle_error( self.handle_error(
&pass_data.error_sink, &pass_data.error_sink,
cause, cause,
@ -3063,9 +3090,9 @@ impl crate::Context for ContextWgpuCore {
width: u32, width: u32,
height: u32, height: u32,
) { ) {
if let Err(cause) = pass_data if let Err(cause) =
.pass self.0
.set_scissor_rect(&self.0, x, y, width, height) .render_pass_set_scissor_rect(&mut pass_data.pass, x, y, width, height)
{ {
self.handle_error( self.handle_error(
&pass_data.error_sink, &pass_data.error_sink,
@ -3087,10 +3114,15 @@ impl crate::Context for ContextWgpuCore {
min_depth: f32, min_depth: f32,
max_depth: f32, max_depth: f32,
) { ) {
if let Err(cause) = pass_data if let Err(cause) = self.0.render_pass_set_viewport(
.pass &mut pass_data.pass,
.set_viewport(&self.0, x, y, width, height, min_depth, max_depth) x,
{ y,
width,
height,
min_depth,
max_depth,
) {
self.handle_error( self.handle_error(
&pass_data.error_sink, &pass_data.error_sink,
cause, cause,
@ -3106,7 +3138,10 @@ impl crate::Context for ContextWgpuCore {
pass_data: &mut Self::RenderPassData, pass_data: &mut Self::RenderPassData,
reference: u32, reference: u32,
) { ) {
if let Err(cause) = pass_data.pass.set_stencil_reference(&self.0, reference) { if let Err(cause) = self
.0
.render_pass_set_stencil_reference(&mut pass_data.pass, reference)
{
self.handle_error( self.handle_error(
&pass_data.error_sink, &pass_data.error_sink,
cause, cause,
@ -3122,7 +3157,10 @@ impl crate::Context for ContextWgpuCore {
pass_data: &mut Self::RenderPassData, pass_data: &mut Self::RenderPassData,
label: &str, label: &str,
) { ) {
if let Err(cause) = pass_data.pass.insert_debug_marker(&self.0, label, 0) { if let Err(cause) = self
.0
.render_pass_insert_debug_marker(&mut pass_data.pass, label, 0)
{
self.handle_error( self.handle_error(
&pass_data.error_sink, &pass_data.error_sink,
cause, cause,
@ -3138,7 +3176,10 @@ impl crate::Context for ContextWgpuCore {
pass_data: &mut Self::RenderPassData, pass_data: &mut Self::RenderPassData,
group_label: &str, group_label: &str,
) { ) {
if let Err(cause) = pass_data.pass.push_debug_group(&self.0, group_label, 0) { if let Err(cause) = self
.0
.render_pass_push_debug_group(&mut pass_data.pass, group_label, 0)
{
self.handle_error( self.handle_error(
&pass_data.error_sink, &pass_data.error_sink,
cause, cause,
@ -3153,7 +3194,7 @@ impl crate::Context for ContextWgpuCore {
_pass: &mut Self::RenderPassId, _pass: &mut Self::RenderPassId,
pass_data: &mut Self::RenderPassData, pass_data: &mut Self::RenderPassData,
) { ) {
if let Err(cause) = pass_data.pass.pop_debug_group(&self.0) { if let Err(cause) = self.0.render_pass_pop_debug_group(&mut pass_data.pass) {
self.handle_error( self.handle_error(
&pass_data.error_sink, &pass_data.error_sink,
cause, cause,
@ -3171,9 +3212,9 @@ impl crate::Context for ContextWgpuCore {
_query_set_data: &Self::QuerySetData, _query_set_data: &Self::QuerySetData,
query_index: u32, query_index: u32,
) { ) {
if let Err(cause) = pass_data if let Err(cause) =
.pass self.0
.write_timestamp(&self.0, *query_set, query_index) .render_pass_write_timestamp(&mut pass_data.pass, *query_set, query_index)
{ {
self.handle_error( self.handle_error(
&pass_data.error_sink, &pass_data.error_sink,
@ -3190,7 +3231,10 @@ impl crate::Context for ContextWgpuCore {
pass_data: &mut Self::RenderPassData, pass_data: &mut Self::RenderPassData,
query_index: u32, query_index: u32,
) { ) {
if let Err(cause) = pass_data.pass.begin_occlusion_query(&self.0, query_index) { if let Err(cause) = self
.0
.render_pass_begin_occlusion_query(&mut pass_data.pass, query_index)
{
self.handle_error( self.handle_error(
&pass_data.error_sink, &pass_data.error_sink,
cause, cause,
@ -3205,7 +3249,7 @@ impl crate::Context for ContextWgpuCore {
_pass: &mut Self::RenderPassId, _pass: &mut Self::RenderPassId,
pass_data: &mut Self::RenderPassData, pass_data: &mut Self::RenderPassData,
) { ) {
if let Err(cause) = pass_data.pass.end_occlusion_query(&self.0) { if let Err(cause) = self.0.render_pass_end_occlusion_query(&mut pass_data.pass) {
self.handle_error( self.handle_error(
&pass_data.error_sink, &pass_data.error_sink,
cause, cause,
@ -3223,11 +3267,11 @@ impl crate::Context for ContextWgpuCore {
_query_set_data: &Self::QuerySetData, _query_set_data: &Self::QuerySetData,
query_index: u32, query_index: u32,
) { ) {
if let Err(cause) = if let Err(cause) = self.0.render_pass_begin_pipeline_statistics_query(
pass_data &mut pass_data.pass,
.pass *query_set,
.begin_pipeline_statistics_query(&self.0, *query_set, query_index) query_index,
{ ) {
self.handle_error( self.handle_error(
&pass_data.error_sink, &pass_data.error_sink,
cause, cause,
@ -3242,7 +3286,10 @@ impl crate::Context for ContextWgpuCore {
_pass: &mut Self::RenderPassId, _pass: &mut Self::RenderPassId,
pass_data: &mut Self::RenderPassData, pass_data: &mut Self::RenderPassData,
) { ) {
if let Err(cause) = pass_data.pass.end_pipeline_statistics_query(&self.0) { if let Err(cause) = self
.0
.render_pass_end_pipeline_statistics_query(&mut pass_data.pass)
{
self.handle_error( self.handle_error(
&pass_data.error_sink, &pass_data.error_sink,
cause, cause,
@ -3259,9 +3306,9 @@ impl crate::Context for ContextWgpuCore {
render_bundles: &mut dyn Iterator<Item = (Self::RenderBundleId, &Self::RenderBundleData)>, render_bundles: &mut dyn Iterator<Item = (Self::RenderBundleId, &Self::RenderBundleData)>,
) { ) {
let temp_render_bundles = render_bundles.map(|(i, _)| i).collect::<SmallVec<[_; 4]>>(); let temp_render_bundles = render_bundles.map(|(i, _)| i).collect::<SmallVec<[_; 4]>>();
if let Err(cause) = pass_data if let Err(cause) = self
.pass .0
.execute_bundles(&self.0, &temp_render_bundles) .render_pass_execute_bundles(&mut pass_data.pass, &temp_render_bundles)
{ {
self.handle_error( self.handle_error(
&pass_data.error_sink, &pass_data.error_sink,
@ -3277,7 +3324,7 @@ impl crate::Context for ContextWgpuCore {
_pass: &mut Self::RenderPassId, _pass: &mut Self::RenderPassId,
pass_data: &mut Self::RenderPassData, pass_data: &mut Self::RenderPassData,
) { ) {
if let Err(cause) = pass_data.pass.end(&self.0) { if let Err(cause) = self.0.render_pass_end(&mut pass_data.pass) {
self.handle_error( self.handle_error(
&pass_data.error_sink, &pass_data.error_sink,
cause, cause,