Skip to content

Commit

Permalink
drop cmdbuffer handles in wgpuQueueSubmitForIndex (#245)
Browse files Browse the repository at this point in the history
  • Loading branch information
rajveermalviya authored Feb 27, 2023
1 parent e1b1591 commit 1adb557
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,7 @@ pub fn map_swapchain_descriptor(
native::WGPUCompositeAlphaMode_Inherit => wgt::CompositeAlphaMode::Inherit,
_ => panic!("invalid alpha mode for swapchain descriptor"),
},
unsafe { make_slice(extras.viewFormats, extras.viewFormatCount as usize) }
unsafe { make_slice(extras.viewFormats, extras.viewFormatCount) }
.iter()
.map(|f| {
map_texture_format(*f).expect("invalid view format for swapchain descriptor")
Expand Down
14 changes: 9 additions & 5 deletions src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -695,11 +695,11 @@ pub unsafe extern "C" fn wgpuQueueSubmit(

let mut command_buffers = Vec::new();
for command_buffer in make_slice(commands, command_count as usize) {
let ptr = (*command_buffer) as native::WGPUCommandBuffer;
// NOTE: Automaticaly drop the command buffer
let ptr = *command_buffer;
if ptr.is_null() {
panic!("invalid command buffer");
}
// NOTE: Automaticaly drop the command buffer
let buffer_id = Box::from_raw(ptr).id;
command_buffers.push(buffer_id)
}
Expand All @@ -718,9 +718,13 @@ pub unsafe extern "C" fn wgpuQueueSubmitForIndex(

let mut command_buffers = Vec::new();
for command_buffer in make_slice(commands, command_count as usize) {
let ptr = (*command_buffer) as native::WGPUCommandBuffer;
let (id, _) = ptr.unwrap_handle();
command_buffers.push(id)
let ptr = *command_buffer;
if ptr.is_null() {
panic!("invalid command buffer");
}
// NOTE: Automaticaly drop the command buffer
let buffer_id = Box::from_raw(ptr).id;
command_buffers.push(buffer_id)
}

let submission_index = gfx_select!(queue => context.queue_submit(queue, &command_buffers))
Expand Down

0 comments on commit 1adb557

Please sign in to comment.