Skip to content

Commit

Permalink
move same device checks in render_pass_end
Browse files Browse the repository at this point in the history
  • Loading branch information
teoxoy authored and ErichDonGubler committed Jul 18, 2024
1 parent 911d28f commit 7761b57
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions wgpu-core/src/command/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ impl<'d, A: HalApi> RenderPassInfo<'d, A> {
}

fn start(
device: &'d Device<A>,
device: &'d Arc<Device<A>>,
hal_label: Option<&str>,
color_attachments: ArrayVec<
Option<ArcRenderPassColorAttachment<A>>,
Expand Down Expand Up @@ -919,6 +919,7 @@ impl<'d, A: HalApi> RenderPassInfo<'d, A> {

if let Some(at) = depth_stencil_attachment.as_ref() {
let view = &at.view;
view.same_device(device)?;
check_multiview(view)?;
add_view(view, AttachmentErrorLocation::Depth)?;

Expand Down Expand Up @@ -1049,6 +1050,7 @@ impl<'d, A: HalApi> RenderPassInfo<'d, A> {
continue;
};
let color_view: &TextureView<A> = &at.view;
color_view.same_device(device)?;
check_multiview(color_view)?;
add_view(
color_view,
Expand Down Expand Up @@ -1079,6 +1081,7 @@ impl<'d, A: HalApi> RenderPassInfo<'d, A> {

let mut hal_resolve_target = None;
if let Some(resolve_view) = &at.resolve_target {
resolve_view.same_device(device)?;
check_multiview(resolve_view)?;

let resolve_location = AttachmentErrorLocation::Color {
Expand Down Expand Up @@ -1178,8 +1181,9 @@ impl<'d, A: HalApi> RenderPassInfo<'d, A> {
multiview,
};

let timestamp_writes_hal = timestamp_writes.as_ref().map(|tw| {
let timestamp_writes_hal = if let Some(tw) = timestamp_writes.as_ref() {
let query_set = &tw.query_set;
query_set.same_device(device)?;

if let Some(index) = tw.beginning_of_pass_write_index {
pending_query_resets.use_query_set(query_set, index);
Expand All @@ -1188,16 +1192,21 @@ impl<'d, A: HalApi> RenderPassInfo<'d, A> {
pending_query_resets.use_query_set(query_set, index);
}

hal::RenderPassTimestampWrites {
Some(hal::RenderPassTimestampWrites {
query_set: query_set.raw.as_ref().unwrap(),
beginning_of_pass_write_index: tw.beginning_of_pass_write_index,
end_of_pass_write_index: tw.end_of_pass_write_index,
}
});
})
} else {
None
};

let occlusion_query_set_hal = occlusion_query_set
.as_ref()
.map(|query_set| query_set.raw.as_ref().unwrap());
let occlusion_query_set_hal = if let Some(query_set) = occlusion_query_set.as_ref() {
query_set.same_device(device)?;
Some(query_set.raw.as_ref().unwrap())
} else {
None
};

let hal_desc = hal::RenderPassDescriptor {
label: hal_label,
Expand Down Expand Up @@ -1331,7 +1340,6 @@ impl Global {
) -> (RenderPass<A>, Option<CommandEncoderError>) {
fn fill_arc_desc<A: HalApi>(
hub: &crate::hub::Hub<A>,
device: &Arc<Device<A>>,
desc: &RenderPassDescriptor<'_>,
arc_desc: &mut ArcRenderPassDescriptor<A>,
) -> Result<(), CommandEncoderError> {
Expand All @@ -1348,13 +1356,11 @@ impl Global {
let view = texture_views
.get_owned(*view_id)
.map_err(|_| CommandEncoderError::InvalidAttachmentId(*view_id))?;
view.same_device(device)?;

let resolve_target = if let Some(resolve_target_id) = resolve_target {
let rt_arc = texture_views.get_owned(*resolve_target_id).map_err(|_| {
CommandEncoderError::InvalidResolveTargetId(*resolve_target_id)
})?;
rt_arc.same_device(device)?;

Some(rt_arc)
} else {
Expand Down Expand Up @@ -1382,7 +1388,6 @@ impl Global {
depth_stencil_attachment.view,
)
})?;
view.same_device(device)?;

Some(ArcRenderPassDepthStencilAttachment {
view,
Expand All @@ -1397,7 +1402,6 @@ impl Global {
let query_set = query_sets.get_owned(tw.query_set).map_err(|_| {
CommandEncoderError::InvalidTimestampWritesQuerySetId(tw.query_set)
})?;
query_set.same_device(device)?;

Some(ArcPassTimestampWrites {
query_set,
Expand All @@ -1413,7 +1417,6 @@ impl Global {
let query_set = query_sets.get_owned(occlusion_query_set).map_err(|_| {
CommandEncoderError::InvalidOcclusionQuerySetId(occlusion_query_set)
})?;
query_set.same_device(device)?;

Some(query_set)
} else {
Expand Down Expand Up @@ -1444,7 +1447,7 @@ impl Global {
Err(e) => return make_err(e, arc_desc),
};

let err = fill_arc_desc(hub, &cmd_buf.device, desc, &mut arc_desc).err();
let err = fill_arc_desc(hub, desc, &mut arc_desc).err();

(RenderPass::new(Some(cmd_buf), arc_desc), err)
}
Expand Down

0 comments on commit 7761b57

Please sign in to comment.