67: Dropping textures and buffers r=kvark a=kvark



Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
This commit is contained in:
bors[bot]
2019-02-21 17:56:15 +00:00
12 changed files with 204 additions and 151 deletions

12
Cargo.lock generated
View File

@@ -413,7 +413,7 @@ dependencies = [
[[package]]
name = "gfx-backend-metal"
version = "0.1.0"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -423,7 +423,7 @@ dependencies = [
"foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx-hal 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"metal 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
"metal 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
"objc 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
"range-alloc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -571,7 +571,7 @@ dependencies = [
[[package]]
name = "metal"
version = "0.13.1"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1277,7 +1277,7 @@ dependencies = [
"gfx-backend-dx11 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx-backend-dx12 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx-backend-empty 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx-backend-metal 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx-backend-metal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx-backend-vulkan 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx-hal 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1438,7 +1438,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum gfx-backend-dx11 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7751e630a3472d96b1a0ce9cd6742f2e17c0f71a6e833f822b914a11f89bd7db"
"checksum gfx-backend-dx12 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "635f526eb3110f47ab64145efce8510bb042df7eba147254ecd8a5d732700c11"
"checksum gfx-backend-empty 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "590c15369f88b88e4ea748da52b27a521a758a947b4aee995539c9f0cc1beb4c"
"checksum gfx-backend-metal 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "68fa011e32280f7566bddbb736734291b685c812087c99bc848d6ac7ae3e0b7f"
"checksum gfx-backend-metal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "66a0fa897619ea7f05e8841fe6214cf1b4e3f52d6a88ed51c2fbc6635a2d5517"
"checksum gfx-backend-vulkan 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "982c618fd9ddeea7e68b2d872b9b6cf13024fc7d4033ba90f0e54ac0d33c798f"
"checksum gfx-hal 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "84c470bce77fcaaea6854858682a99026ff796b880b0ca30511593a6b2bc77c0"
"checksum glsl-to-spirv 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "28caebc98746d507603a2d3df66dcbe04e41d4febad0320f3eec1ef72b6bbef1"
@@ -1454,7 +1454,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum malloc_buf 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb"
"checksum memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e1dd4eaac298c32ce07eb6ed9242eda7d82955b9170b7d6db59b2e02cc63fcb8"
"checksum memmap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b"
"checksum metal 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7de9c2b83c946ab01c9942928388f911d93486b97636d9927541345905fea65d"
"checksum metal 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cd3f21d259068945192293b7a98b1c6844af9eb7602e393c405198b229efc157"
"checksum nix 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "921f61dc817b379d0834e45d5ec45beaacfae97082090a49c2cf30dcbc30206f"
"checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945"
"checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1"

View File

@@ -30,7 +30,7 @@ else
endif
.PHONY: all check test doc clear lib-native lib-rust examples-native examples-rust
.PHONY: all check test doc clear lib-native lib-rust examples-native examples-rust gfx-cube
all: examples-native examples-rust examples-gfx
@@ -64,3 +64,6 @@ examples-rust: lib-rust examples/Cargo.toml $(wildcard wgpu-native/**/*.rs)
examples-gfx: lib-rust gfx-examples/Cargo.toml $(wildcard gfx-examples/*.rs)
cargo build --manifest-path gfx-examples/Cargo.toml --features $(FEATURE_RUST)
gfx-cube:
cargo run --manifest-path gfx-examples/Cargo.toml --bin cube --features $(FEATURE_RUST)

View File

@@ -92,7 +92,6 @@ fn main() {
cpass.set_pipeline(&compute_pipeline);
cpass.set_bind_group(0, &bind_group);
cpass.dispatch(numbers.len() as u32, 1, 1);
cpass.end_pass();
}
encoder.copy_buffer_tobuffer(&storage_buffer, 0, &staging_buffer, 0, size);

View File

@@ -108,7 +108,6 @@ fn main() {
});
rpass.set_pipeline(&render_pipeline);
rpass.draw(0..3, 0..1);
rpass.end_pass();
}
device

View File

@@ -318,7 +318,6 @@ impl framework::Example for Cube {
rpass.set_index_buffer(&self.index_buf, 0);
rpass.set_vertex_buffers(&[(&self.vertex_buf, 0)]);
rpass.draw_indexed(0 .. self.index_count as u32, 0, 0..1);
rpass.end_pass();
}
device

View File

@@ -27,7 +27,9 @@ pub fn load_glsl(name: &str, stage: ShaderStage) -> Vec<u8> {
ShaderStage::Fragment => glsl_to_spirv::ShaderType::Fragment,
ShaderStage::Compute => glsl_to_spirv::ShaderType::Compute,
};
let path = PathBuf::from("data").join(name);
let path = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("data")
.join(name);
let code = read_to_string(path).unwrap();
let mut output = glsl_to_spirv::compile(&code, ty).unwrap();
let mut spv = Vec::new();

View File

@@ -696,4 +696,4 @@ WGPUTextureViewId wgpu_texture_create_view(WGPUTextureId texture_id,
void wgpu_texture_destroy(WGPUTextureId texture_id);
void wgpu_texture_view_destroy(WGPUTextureViewId _texture_view_id);
void wgpu_texture_view_destroy(WGPUTextureViewId texture_view_id);

View File

@@ -34,9 +34,7 @@ impl<B: hal::Backend> ComputePass<B> {
#[no_mangle]
pub extern "C" fn wgpu_compute_pass_end_pass(pass_id: ComputePassId) -> CommandBufferId {
#[cfg(feature = "local")]
HUB.compute_passes.unregister(pass_id);
let pass = HUB.compute_passes.write().take(pass_id);
let pass = HUB.compute_passes.unregister(pass_id);
HUB.command_buffers
.write()

View File

@@ -34,9 +34,7 @@ impl<B: hal::Backend> RenderPass<B> {
#[no_mangle]
pub extern "C" fn wgpu_render_pass_end_pass(pass_id: RenderPassId) -> CommandBufferId {
#[cfg(feature = "local")]
HUB.render_passes.unregister(pass_id);
let mut pass = HUB.render_passes.write().take(pass_id);
let mut pass = HUB.render_passes.unregister(pass_id);
unsafe {
pass.raw.end_render_pass();
}

View File

@@ -1,5 +1,5 @@
use crate::{binding_model, command, conv, pipeline, resource, swap_chain};
use crate::hub::{HUB, Storage};
use crate::hub::HUB;
use crate::track::{BufferTracker, TextureTracker, TrackPermit};
use crate::{
LifeGuard, RefCount, Stored, SubmissionIndex, WeaklyStored,
@@ -67,11 +67,13 @@ impl Eq for FramebufferKey {}
enum ResourceId {
Buffer(BufferId),
Texture(TextureId),
TextureView(TextureViewId),
}
enum Resource<B: hal::Backend> {
Buffer(resource::Buffer<B>),
Texture(resource::Texture<B>),
TextureView(resource::TextureView<B>),
}
struct ActiveSubmission<B: hal::Backend> {
@@ -101,45 +103,6 @@ impl<B: hal::Backend> DestroyedResources<B> {
.push((resource_id, life_guard.ref_count.clone()));
}
fn triage_referenced(
&mut self,
buffer_guard: &mut Storage<resource::Buffer<B>>,
texture_guard: &mut Storage<resource::Texture<B>>,
) {
for i in (0..self.referenced.len()).rev() {
// one in resource itself, and one here in this list
let num_refs = self.referenced[i].1.load();
if num_refs <= 2 {
assert_eq!(num_refs, 2);
let resource_id = self.referenced.swap_remove(i).0;
let (submit_index, resource) = match resource_id {
ResourceId::Buffer(id) => {
#[cfg(feature = "local")]
HUB.buffers.unregister(id);
let buf = buffer_guard.take(id);
let si = buf.life_guard.submission_index.load(Ordering::Acquire);
(si, Resource::Buffer(buf))
}
ResourceId::Texture(id) => {
#[cfg(feature = "local")]
HUB.textures.unregister(id);
let tex = texture_guard.take(id);
let si = tex.life_guard.submission_index.load(Ordering::Acquire);
(si, Resource::Texture(tex))
}
};
match self
.active
.iter_mut()
.find(|a| a.index == submit_index)
{
Some(a) => a.resources.push(resource),
None => self.free.push(resource),
}
}
}
}
/// Returns the last submission index that is done.
fn cleanup(&mut self, raw: &B::Device) -> SubmissionIndex {
let mut last_done = 0;
@@ -159,12 +122,15 @@ impl<B: hal::Backend> DestroyedResources<B> {
for resource in self.free.drain(..) {
match resource {
Resource::Buffer(buf) => {
unsafe { raw.destroy_buffer(buf.raw) };
}
Resource::Texture(tex) => {
unsafe { raw.destroy_image(tex.raw) };
}
Resource::Buffer(buf) => unsafe {
raw.destroy_buffer(buf.raw)
},
Resource::Texture(tex) => unsafe {
raw.destroy_image(tex.raw)
},
Resource::TextureView(view) => unsafe {
raw.destroy_image_view(view.raw)
},
}
}
@@ -172,6 +138,44 @@ impl<B: hal::Backend> DestroyedResources<B> {
}
}
impl DestroyedResources<back::Backend> {
fn triage_referenced(&mut self) {
for i in (0..self.referenced.len()).rev() {
// one in resource itself, and one here in this list
let num_refs = self.referenced[i].1.load();
if num_refs <= 2 {
assert_eq!(num_refs, 2);
let resource_id = self.referenced.swap_remove(i).0;
let (submit_index, resource) = match resource_id {
ResourceId::Buffer(id) => {
let buf = HUB.buffers.unregister(id);
let si = buf.life_guard.submission_index.load(Ordering::Acquire);
(si, Resource::Buffer(buf))
}
ResourceId::Texture(id) => {
let tex = HUB.textures.unregister(id);
let si = tex.life_guard.submission_index.load(Ordering::Acquire);
(si, Resource::Texture(tex))
}
ResourceId::TextureView(id) => {
let view = HUB.texture_views.unregister(id);
let si = view.life_guard.submission_index.load(Ordering::Acquire);
(si, Resource::TextureView(view))
}
};
match self
.active
.iter_mut()
.find(|a| a.index == submit_index)
{
Some(a) => a.resources.push(resource),
None => self.free.push(resource),
}
}
}
}
}
pub struct Device<B: hal::Backend> {
pub(crate) raw: B::Device,
@@ -579,8 +583,19 @@ pub extern "C" fn wgpu_texture_destroy(texture_id: TextureId) {
}
#[no_mangle]
pub extern "C" fn wgpu_texture_view_destroy(_texture_view_id: TextureViewId) {
unimplemented!()
pub extern "C" fn wgpu_texture_view_destroy(texture_view_id: TextureViewId) {
let texture_view_guard = HUB.texture_views.read();
let view = texture_view_guard.get(texture_view_id);
let device_id = HUB.textures
.read()
.get(view.texture_id.value)
.device_id.value;
HUB.devices
.read()
.get(device_id)
.destroyed
.lock()
.add(ResourceId::TextureView(texture_view_id), &view.life_guard);
}
@@ -878,77 +893,80 @@ pub extern "C" fn wgpu_queue_submit(
) {
let mut device_guard = HUB.devices.write();
let device = device_guard.get_mut(queue_id);
let mut buffer_tracker = device.buffer_tracker.lock();
let mut texture_tracker = device.texture_tracker.lock();
let mut command_buffer_guard = HUB.command_buffers.write();
let mut swap_chain_links = Vec::new();
let command_buffer_ids =
unsafe { slice::from_raw_parts(command_buffer_ptr, command_buffer_count) };
let mut buffer_guard = HUB.buffers.write();
let mut texture_guard = HUB.textures.write();
let old_submit_index = device
.life_guard
.submission_index
.fetch_add(1, Ordering::Relaxed);
let mut swap_chain_links = Vec::new();
//TODO: if multiple command buffers are submitted, we can re-use the last
// native command buffer of the previous chain instead of always creating
// a temporary one, since the chains are not finished.
{
let mut command_buffer_guard = HUB.command_buffers.write();
let buffer_guard = HUB.buffers.read();
let texture_guard = HUB.textures.read();
let mut buffer_tracker = device.buffer_tracker.lock();
let mut texture_tracker = device.texture_tracker.lock();
// finish all the command buffers first
for &cmb_id in command_buffer_ids {
let comb = command_buffer_guard.get_mut(cmb_id);
swap_chain_links.extend(comb.swap_chain_links.drain(..));
// update submission IDs
comb.life_guard.submission_index
.store(old_submit_index, Ordering::Release);
for id in comb.buffer_tracker.used() {
buffer_guard
.get(id)
.life_guard
.submission_index
// finish all the command buffers first
for &cmb_id in command_buffer_ids {
let comb = command_buffer_guard.get_mut(cmb_id);
swap_chain_links.extend(comb.swap_chain_links.drain(..));
// update submission IDs
comb.life_guard.submission_index
.store(old_submit_index, Ordering::Release);
}
for id in comb.texture_tracker.used() {
texture_guard
.get(id)
.life_guard
.submission_index
.store(old_submit_index, Ordering::Release);
}
for id in comb.buffer_tracker.used() {
buffer_guard
.get(id)
.life_guard
.submission_index
.store(old_submit_index, Ordering::Release);
}
for id in comb.texture_tracker.used() {
texture_guard
.get(id)
.life_guard
.submission_index
.store(old_submit_index, Ordering::Release);
}
// execute resource transitions
let mut transit = device.com_allocator.extend(comb);
unsafe {
transit.begin(
hal::command::CommandBufferFlags::ONE_TIME_SUBMIT,
hal::command::CommandBufferInheritanceInfo::default(),
// execute resource transitions
let mut transit = device.com_allocator.extend(comb);
unsafe {
transit.begin(
hal::command::CommandBufferFlags::ONE_TIME_SUBMIT,
hal::command::CommandBufferInheritanceInfo::default(),
);
}
//TODO: fix the consume
command::CommandBuffer::insert_barriers(
&mut transit,
buffer_tracker.consume_by_replace(&comb.buffer_tracker),
texture_tracker.consume_by_replace(&comb.texture_tracker),
&*buffer_guard,
&*texture_guard,
);
}
//TODO: fix the consume
command::CommandBuffer::insert_barriers(
&mut transit,
buffer_tracker.consume_by_replace(&comb.buffer_tracker),
texture_tracker.consume_by_replace(&comb.texture_tracker),
&*buffer_guard,
&*texture_guard,
);
unsafe {
transit.finish();
}
comb.raw.insert(0, transit);
unsafe {
comb.raw.last_mut().unwrap().finish();
unsafe {
transit.finish();
}
comb.raw.insert(0, transit);
unsafe {
comb.raw.last_mut().unwrap().finish();
}
}
}
// now prepare the GPU submission
let fence = device.raw.create_fence(false).unwrap();
{
let command_buffer_guard = HUB.command_buffers.read();
let swap_chain_guard = HUB.swap_chains.read();
let wait_semaphores = swap_chain_links
.into_iter()
.map(|link| {
@@ -959,6 +977,7 @@ pub extern "C" fn wgpu_queue_submit(
.sem_available;
(sem, hal::pso::PipelineStage::COLOR_ATTACHMENT_OUTPUT)
});
let submission =
hal::queue::Submission::<_, _, &[<back::Backend as hal::Backend>::Semaphore]> {
//TODO: may `OneShot` be enough?
@@ -968,6 +987,7 @@ pub extern "C" fn wgpu_queue_submit(
wait_semaphores,
signal_semaphores: &[], //TODO: signal `sem_present`?
};
unsafe {
device.queue_group.queues[0]
.as_raw_mut()
@@ -977,7 +997,7 @@ pub extern "C" fn wgpu_queue_submit(
let last_done = {
let mut destroyed = device.destroyed.lock();
destroyed.triage_referenced(&mut *buffer_guard, &mut *texture_guard);
destroyed.triage_referenced();
let last_done = destroyed.cleanup(&device.raw);
destroyed.active.push(ActiveSubmission {
@@ -995,9 +1015,7 @@ pub extern "C" fn wgpu_queue_submit(
// finally, return the command buffers to the allocator
for &cmb_id in command_buffer_ids {
#[cfg(feature = "local")]
HUB.command_buffers.unregister(cmb_id);
let cmd_buf = command_buffer_guard.take(cmb_id);
let cmd_buf = HUB.command_buffers.unregister(cmb_id);
device.com_allocator.after_submit(cmd_buf);
}
}

View File

@@ -58,9 +58,6 @@ impl<T> Storage<T> {
pub fn get_mut(&mut self, id: Id) -> &mut T {
self.map.get_mut(&id).unwrap()
}
pub fn take(&mut self, id: Id) -> T {
self.map.remove(&id).unwrap()
}
}
pub struct Registry<T> {
@@ -94,16 +91,19 @@ impl<T> ops::DerefMut for Registry<T> {
}
}
#[cfg(feature = "local")]
impl<T> Registry<T> {
#[cfg(feature = "local")]
pub fn register(&self, value: T) -> Id {
let id = self.identity.lock().alloc();
let old = self.data.write().map.insert(id, value);
assert!(old.is_none());
id
}
pub fn unregister(&self, id: Id) {
pub fn unregister(&self, id: Id) -> T {
#[cfg(feature = "local")]
self.identity.lock().free(id);
self.data.write().map.remove(&id).unwrap()
}
}

View File

@@ -4,7 +4,6 @@ extern crate wgpu_native as wgn;
use arrayvec::ArrayVec;
use std::ffi::CString;
use std::marker::PhantomData;
use std::ops::Range;
use std::ptr;
@@ -26,7 +25,14 @@ pub use wgn::{
};
//Note: we need some better guidelines on which structures receive by value, and which by pointer.
//TODO: avoid heap allocating vectors during resource creation.
#[derive(Default)]
struct Temp {
//bind_group_descriptors: Vec<wgn::BindGroupDescriptor>,
//vertex_buffers: Vec<wgn::VertexBufferDescriptor>,
command_buffers: Vec<wgn::CommandBufferId>,
}
pub struct Instance {
id: wgn::InstanceId,
@@ -38,6 +44,7 @@ pub struct Adapter {
pub struct Device {
id: wgn::DeviceId,
temp: Temp,
}
pub struct Buffer {
@@ -64,20 +71,6 @@ pub struct SwapChain {
id: wgn::SwapChainId,
}
pub enum BindingResource<'a> {
Buffer {
buffer: &'a Buffer,
range: Range<u32>,
},
Sampler(&'a Sampler),
TextureView(&'a TextureView),
}
pub struct Binding<'a> {
pub binding: u32,
pub resource: BindingResource<'a>,
}
pub struct BindGroupLayout {
id: wgn::BindGroupLayoutId,
}
@@ -103,7 +96,7 @@ pub struct ComputePipeline {
}
pub struct CommandBuffer {
_id: wgn::CommandBufferId,
id: wgn::CommandBufferId,
}
pub struct CommandEncoder {
@@ -122,7 +115,22 @@ pub struct ComputePass<'a> {
pub struct Queue<'a> {
id: wgn::QueueId,
_marker: PhantomData<&'a Self>,
temp: &'a mut Temp,
}
pub enum BindingResource<'a> {
Buffer {
buffer: &'a Buffer,
range: Range<u32>,
},
Sampler(&'a Sampler),
TextureView(&'a TextureView),
}
pub struct Binding<'a> {
pub binding: u32,
pub resource: BindingResource<'a>,
}
pub struct BindGroupLayoutDescriptor<'a> {
@@ -215,6 +223,7 @@ impl<'a> TextureCopyView<'a> {
}
}
impl Instance {
pub fn new() -> Self {
Instance {
@@ -239,6 +248,7 @@ impl Adapter {
pub fn create_device(&self, desc: &DeviceDescriptor) -> Device {
Device {
id: wgn::wgpu_adapter_create_device(self.id, desc),
temp: Temp::default(),
}
}
}
@@ -259,7 +269,7 @@ impl Device {
pub fn get_queue(&mut self) -> Queue {
Queue {
id: wgn::wgpu_device_get_queue(self.id),
_marker: PhantomData,
temp: &mut self.temp,
}
}
@@ -430,6 +440,12 @@ impl Buffer {
}
}
impl Drop for Buffer {
fn drop(&mut self) {
wgn::wgpu_buffer_destroy(self.id);
}
}
impl Texture {
pub fn create_view(&self, desc: &TextureViewDescriptor) -> TextureView {
TextureView {
@@ -444,10 +460,22 @@ impl Texture {
}
}
impl Drop for Texture {
fn drop(&mut self) {
wgn::wgpu_texture_destroy(self.id);
}
}
impl Drop for TextureView {
fn drop(&mut self) {
wgn::wgpu_texture_view_destroy(self.id);
}
}
impl CommandEncoder {
pub fn finish(self) -> CommandBuffer {
CommandBuffer {
_id: wgn::wgpu_command_encoder_finish(self.id),
id: wgn::wgpu_command_encoder_finish(self.id),
}
}
@@ -560,10 +588,6 @@ impl CommandEncoder {
}
impl<'a> RenderPass<'a> {
pub fn end_pass(self) {
wgn::wgpu_render_pass_end_pass(self.id);
}
pub fn set_bind_group(&mut self, index: u32, bind_group: &BindGroup) {
wgn::wgpu_render_pass_set_bind_group(self.id, index, bind_group.id);
}
@@ -613,11 +637,13 @@ impl<'a> RenderPass<'a> {
}
}
impl<'a> ComputePass<'a> {
pub fn end_pass(self) {
wgn::wgpu_compute_pass_end_pass(self.id);
impl<'a> Drop for RenderPass<'a> {
fn drop(&mut self) {
wgn::wgpu_render_pass_end_pass(self.id);
}
}
impl<'a> ComputePass<'a> {
pub fn set_bind_group(&mut self, index: u32, bind_group: &BindGroup) {
wgn::wgpu_compute_pass_set_bind_group(self.id, index, bind_group.id);
}
@@ -631,11 +657,22 @@ impl<'a> ComputePass<'a> {
}
}
impl<'a> Drop for ComputePass<'a> {
fn drop(&mut self) {
wgn::wgpu_compute_pass_end_pass(self.id);
}
}
impl<'a> Queue<'a> {
pub fn submit(&mut self, command_buffers: &[CommandBuffer]) {
self.temp.command_buffers.clear();
self.temp.command_buffers.extend(
command_buffers.iter().map(|cb| cb.id)
);
wgn::wgpu_queue_submit(
self.id,
command_buffers.as_ptr() as *const _,
self.temp.command_buffers.as_ptr(),
command_buffers.len(),
);
}