Fix compute pass barriers

This commit is contained in:
Dzmitry Malyshau 2019-05-26 23:55:23 -04:00
parent 17e555b257
commit 4446b81f3e
3 changed files with 18 additions and 13 deletions

View File

@ -686,7 +686,7 @@ void wgpu_compute_pass_push_debug_group(WGPUComputePassId _pass_id, WGPURawStrin
void wgpu_compute_pass_set_bind_group(WGPUComputePassId pass_id, void wgpu_compute_pass_set_bind_group(WGPUComputePassId pass_id,
uint32_t index, uint32_t index,
WGPUBindGroupId bind_group_id, WGPUBindGroupId bind_group_id,
const uint32_t *offsets_ptr, const WGPUBufferAddress *offsets_ptr,
uintptr_t offsets_count); uintptr_t offsets_count);
void wgpu_compute_pass_set_pipeline(WGPUComputePassId pass_id, WGPUComputePipelineId pipeline_id); void wgpu_compute_pass_set_pipeline(WGPUComputePassId pass_id, WGPUComputePipelineId pipeline_id);
@ -810,7 +810,7 @@ void wgpu_render_pass_push_debug_group(WGPURenderPassId _pass_id, WGPURawString
void wgpu_render_pass_set_bind_group(WGPURenderPassId pass_id, void wgpu_render_pass_set_bind_group(WGPURenderPassId pass_id,
uint32_t index, uint32_t index,
WGPUBindGroupId bind_group_id, WGPUBindGroupId bind_group_id,
const uint32_t *offsets_ptr, const WGPUBufferAddress *offsets_ptr,
uintptr_t offsets_count); uintptr_t offsets_count);
void wgpu_render_pass_set_blend_color(WGPURenderPassId pass_id, const WGPUColor *color); void wgpu_render_pass_set_blend_color(WGPURenderPassId pass_id, const WGPUColor *color);
@ -831,7 +831,7 @@ void wgpu_render_pass_set_stencil_reference(WGPURenderPassId pass_id, uint32_t v
void wgpu_render_pass_set_vertex_buffers(WGPURenderPassId pass_id, void wgpu_render_pass_set_vertex_buffers(WGPURenderPassId pass_id,
const WGPUBufferId *buffer_ptr, const WGPUBufferId *buffer_ptr,
const uint32_t *offset_ptr, const WGPUBufferAddress *offset_ptr,
uintptr_t count); uintptr_t count);
void wgpu_render_pass_set_viewport(WGPURenderPassId pass_id, void wgpu_render_pass_set_viewport(WGPURenderPassId pass_id,

View File

@ -24,12 +24,16 @@ pub struct ComputePass<B: hal::Backend> {
} }
impl<B: hal::Backend> ComputePass<B> { impl<B: hal::Backend> ComputePass<B> {
pub(crate) fn new(raw: B::CommandBuffer, cmb_id: Stored<CommandBufferId>) -> Self { pub(crate) fn new(
raw: B::CommandBuffer,
cmb_id: Stored<CommandBufferId>,
trackers: TrackerSet,
) -> Self {
ComputePass { ComputePass {
raw, raw,
cmb_id, cmb_id,
binder: Binder::default(), binder: Binder::default(),
trackers: TrackerSet::new(), trackers,
} }
} }
} }
@ -38,14 +42,14 @@ impl<B: hal::Backend> ComputePass<B> {
#[no_mangle] #[no_mangle]
pub extern "C" fn wgpu_compute_pass_end_pass(pass_id: ComputePassId) -> CommandBufferId { pub extern "C" fn wgpu_compute_pass_end_pass(pass_id: ComputePassId) -> CommandBufferId {
let mut command_buffer_guard = HUB.command_buffers.write(); let mut cmb_guard = HUB.command_buffers.write();
let pass = HUB.compute_passes.unregister(pass_id); let pass = HUB.compute_passes.unregister(pass_id);
let cmb = &mut cmb_guard[pass.cmb_id.value];
//TODO: transitions? // There are no transitions to be made: we've already been inserting barriers
// into the parent command buffer while recording this compute pass.
command_buffer_guard[pass.cmb_id.value] cmb.trackers = pass.trackers;
.raw cmb.raw.push(pass.raw);
.push(pass.raw);
pass.cmb_id.value pass.cmb_id.value
} }

View File

@ -44,7 +44,7 @@ use back::Backend;
use hal::{command::RawCommandBuffer, Device as _}; use hal::{command::RawCommandBuffer, Device as _};
use log::trace; use log::trace;
use std::{collections::hash_map::Entry, iter, slice, thread::ThreadId}; use std::{collections::hash_map::Entry, iter, mem, slice, thread::ThreadId};
#[repr(C)] #[repr(C)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)] #[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
@ -426,12 +426,13 @@ pub fn command_encoder_begin_compute_pass(
let cmb = &mut cmb_guard[command_encoder_id]; let cmb = &mut cmb_guard[command_encoder_id];
let raw = cmb.raw.pop().unwrap(); let raw = cmb.raw.pop().unwrap();
let trackers = mem::replace(&mut cmb.trackers, TrackerSet::new());
let stored = Stored { let stored = Stored {
value: command_encoder_id, value: command_encoder_id,
ref_count: cmb.life_guard.ref_count.clone(), ref_count: cmb.life_guard.ref_count.clone(),
}; };
ComputePass::new(raw, stored) ComputePass::new(raw, stored, trackers)
} }
#[cfg(feature = "local")] #[cfg(feature = "local")]