mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-22 23:04:07 +00:00
Fix missing transitions before the render pass
This commit is contained in:
parent
f798f7c631
commit
92441c38a2
@ -297,9 +297,15 @@ impl<F> Global<F> {
|
|||||||
let (adapter_guard, mut token) = hub.adapters.read(&mut token);
|
let (adapter_guard, mut token) = hub.adapters.read(&mut token);
|
||||||
let (device_guard, mut token) = hub.devices.read(&mut token);
|
let (device_guard, mut token) = hub.devices.read(&mut token);
|
||||||
let (mut cmb_guard, mut token) = hub.command_buffers.write(&mut token);
|
let (mut cmb_guard, mut token) = hub.command_buffers.write(&mut token);
|
||||||
let cmb = &mut cmb_guard[encoder_id];
|
|
||||||
let raw = cmb.raw.last_mut().unwrap();
|
|
||||||
let mut trackers = TrackerSet::new(B::VARIANT);
|
let mut trackers = TrackerSet::new(B::VARIANT);
|
||||||
|
let cmb = &mut cmb_guard[encoder_id];
|
||||||
|
let device = &device_guard[cmb.device_id.value];
|
||||||
|
let mut raw = device.com_allocator.extend(cmb);
|
||||||
|
|
||||||
|
unsafe {
|
||||||
|
raw.begin_primary(hal::command::CommandBufferFlags::ONE_TIME_SUBMIT);
|
||||||
|
}
|
||||||
|
|
||||||
let (pipeline_layout_guard, mut token) = hub.pipeline_layouts.read(&mut token);
|
let (pipeline_layout_guard, mut token) = hub.pipeline_layouts.read(&mut token);
|
||||||
let (bind_group_guard, mut token) = hub.bind_groups.read(&mut token);
|
let (bind_group_guard, mut token) = hub.bind_groups.read(&mut token);
|
||||||
@ -311,13 +317,12 @@ impl<F> Global<F> {
|
|||||||
let (context, sample_count) = {
|
let (context, sample_count) = {
|
||||||
use hal::{adapter::PhysicalDevice as _, device::Device as _};
|
use hal::{adapter::PhysicalDevice as _, device::Device as _};
|
||||||
|
|
||||||
let device = &device_guard[cmb.device_id.value];
|
|
||||||
|
|
||||||
let limits = adapter_guard[device.adapter_id]
|
let limits = adapter_guard[device.adapter_id]
|
||||||
.raw
|
.raw
|
||||||
.physical_device
|
.physical_device
|
||||||
.limits();
|
.limits();
|
||||||
let samples_count_limit = limits.framebuffer_color_sample_counts;
|
let samples_count_limit = limits.framebuffer_color_sample_counts;
|
||||||
|
let base_trackers = &cmb.trackers;
|
||||||
|
|
||||||
let mut extent = None;
|
let mut extent = None;
|
||||||
let mut used_swap_chain_image = None::<Stored<id::TextureViewId>>;
|
let mut used_swap_chain_image = None::<Stored<id::TextureViewId>>;
|
||||||
@ -346,7 +351,7 @@ impl<F> Global<F> {
|
|||||||
let rp_key = {
|
let rp_key = {
|
||||||
let depth_stencil = match depth_stencil_attachment {
|
let depth_stencil = match depth_stencil_attachment {
|
||||||
Some(at) => {
|
Some(at) => {
|
||||||
let view = cmb.trackers
|
let view = trackers
|
||||||
.views
|
.views
|
||||||
.use_extend(&*view_guard, at.attachment, (), ())
|
.use_extend(&*view_guard, at.attachment, (), ())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@ -363,7 +368,7 @@ impl<F> Global<F> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Using render pass for transition.
|
// Using render pass for transition.
|
||||||
let consistent_usage = cmb.trackers.textures.query(
|
let consistent_usage = base_trackers.textures.query(
|
||||||
source_id.value,
|
source_id.value,
|
||||||
view.range.clone(),
|
view.range.clone(),
|
||||||
);
|
);
|
||||||
@ -405,7 +410,7 @@ impl<F> Global<F> {
|
|||||||
view.samples, sample_count,
|
view.samples, sample_count,
|
||||||
"All attachments must have the same sample_count"
|
"All attachments must have the same sample_count"
|
||||||
);
|
);
|
||||||
let first_use = cmb.trackers.views.init(
|
let first_use = trackers.views.init(
|
||||||
at.attachment,
|
at.attachment,
|
||||||
view.life_guard.add_ref(),
|
view.life_guard.add_ref(),
|
||||||
PhantomData,
|
PhantomData,
|
||||||
@ -413,7 +418,7 @@ impl<F> Global<F> {
|
|||||||
|
|
||||||
let layouts = match view.inner {
|
let layouts = match view.inner {
|
||||||
TextureViewInner::Native { ref source_id, .. } => {
|
TextureViewInner::Native { ref source_id, .. } => {
|
||||||
let consistent_usage = cmb.trackers.textures.query(
|
let consistent_usage = base_trackers.textures.query(
|
||||||
source_id.value,
|
source_id.value,
|
||||||
view.range.clone(),
|
view.range.clone(),
|
||||||
);
|
);
|
||||||
@ -465,7 +470,7 @@ impl<F> Global<F> {
|
|||||||
view.samples, 1,
|
view.samples, 1,
|
||||||
"All resolve_targets must have a sample_count of 1"
|
"All resolve_targets must have a sample_count of 1"
|
||||||
);
|
);
|
||||||
let first_use = cmb.trackers.views.init(
|
let first_use = trackers.views.init(
|
||||||
resolve_target,
|
resolve_target,
|
||||||
view.life_guard.add_ref(),
|
view.life_guard.add_ref(),
|
||||||
PhantomData,
|
PhantomData,
|
||||||
@ -473,7 +478,7 @@ impl<F> Global<F> {
|
|||||||
|
|
||||||
let layouts = match view.inner {
|
let layouts = match view.inner {
|
||||||
TextureViewInner::Native { ref source_id, .. } => {
|
TextureViewInner::Native { ref source_id, .. } => {
|
||||||
let consistent_usage = cmb.trackers.textures.query(
|
let consistent_usage = base_trackers.textures.query(
|
||||||
source_id.value,
|
source_id.value,
|
||||||
view.range.clone(),
|
view.range.clone(),
|
||||||
);
|
);
|
||||||
@ -1093,6 +1098,19 @@ impl<F> Global<F> {
|
|||||||
RenderCommand::End => break,
|
RenderCommand::End => break,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
super::CommandBuffer::insert_barriers(
|
||||||
|
cmb.raw.last_mut().unwrap(),
|
||||||
|
&mut cmb.trackers,
|
||||||
|
&trackers,
|
||||||
|
&*buffer_guard,
|
||||||
|
&*texture_guard,
|
||||||
|
);
|
||||||
|
unsafe {
|
||||||
|
cmb.raw.last_mut().unwrap().finish();
|
||||||
|
raw.end_render_pass();
|
||||||
|
}
|
||||||
|
cmb.raw.push(raw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1216,9 +1216,8 @@ impl<F: IdentityFilter<id::CommandEncoderId>> Global<F> {
|
|||||||
.com_allocator
|
.com_allocator
|
||||||
.allocate(dev_stored, &device.raw, device.features, lowest_active_index);
|
.allocate(dev_stored, &device.raw, device.features, lowest_active_index);
|
||||||
unsafe {
|
unsafe {
|
||||||
comb.raw.last_mut().unwrap().begin(
|
comb.raw.last_mut().unwrap().begin_primary(
|
||||||
hal::command::CommandBufferFlags::ONE_TIME_SUBMIT,
|
hal::command::CommandBufferFlags::ONE_TIME_SUBMIT,
|
||||||
hal::command::CommandBufferInheritanceInfo::default(),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1381,9 +1380,8 @@ impl<F: AllIdentityFilter + IdentityFilter<id::CommandBufferId>> Global<F> {
|
|||||||
// execute resource transitions
|
// execute resource transitions
|
||||||
let mut transit = device.com_allocator.extend(comb);
|
let mut transit = device.com_allocator.extend(comb);
|
||||||
unsafe {
|
unsafe {
|
||||||
transit.begin(
|
transit.begin_primary(
|
||||||
hal::command::CommandBufferFlags::ONE_TIME_SUBMIT,
|
hal::command::CommandBufferFlags::ONE_TIME_SUBMIT,
|
||||||
hal::command::CommandBufferInheritanceInfo::default(),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
log::trace!("Stitching command buffer {:?} before submission", cmb_id);
|
log::trace!("Stitching command buffer {:?} before submission", cmb_id);
|
||||||
|
@ -280,7 +280,7 @@ impl<S: ResourceState> ResourceTracker<S> {
|
|||||||
///
|
///
|
||||||
/// Returns `Some(Usage)` only if this usage is consistent
|
/// Returns `Some(Usage)` only if this usage is consistent
|
||||||
/// across the given selector.
|
/// across the given selector.
|
||||||
pub fn query(&mut self, id: S::Id, selector: S::Selector) -> Option<S::Usage> {
|
pub fn query(&self, id: S::Id, selector: S::Selector) -> Option<S::Usage> {
|
||||||
let (index, epoch, backend) = id.unzip();
|
let (index, epoch, backend) = id.unzip();
|
||||||
debug_assert_eq!(backend, self.backend);
|
debug_assert_eq!(backend, self.backend);
|
||||||
let res = self.map.get(&index)?;
|
let res = self.map.get(&index)?;
|
||||||
|
Loading…
Reference in New Issue
Block a user