mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-02-19 18:33:30 +00:00
Cleanup exports
This commit is contained in:
parent
407cf69a8e
commit
3908d2b5a1
@ -16,9 +16,8 @@
|
||||
#define BINDINGS_LENGTH (1)
|
||||
#define BIND_GROUP_LAYOUTS_LENGTH (1)
|
||||
|
||||
void request_adapter_callback(WGPUAdapterId const *received, void *userdata) {
|
||||
WGPUAdapterId *id = (WGPUAdapterId*) userdata;
|
||||
*id = *received;
|
||||
void request_adapter_callback(WGPUAdapterId received, void *userdata) {
|
||||
*(WGPUAdapterId*)userdata = received;
|
||||
}
|
||||
|
||||
void read_buffer_map(
|
||||
|
@ -36,9 +36,8 @@
|
||||
#define RENDER_PASS_ATTACHMENTS_LENGTH (1)
|
||||
#define BIND_GROUP_LAYOUTS_LENGTH (1)
|
||||
|
||||
void request_adapter_callback(WGPUAdapterId const *received, void *userdata) {
|
||||
WGPUAdapterId *id = (WGPUAdapterId*) userdata;
|
||||
*id = *received;
|
||||
void request_adapter_callback(WGPUAdapterId received, void *userdata) {
|
||||
*(WGPUAdapterId*)userdata = received;
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
@ -649,7 +649,7 @@ typedef struct {
|
||||
|
||||
typedef uint32_t WGPUBackendBit;
|
||||
|
||||
typedef void (*WGPURequestAdapterCallback)(const WGPUAdapterId *adapter, void *userdata);
|
||||
typedef void (*WGPURequestAdapterCallback)(WGPUAdapterId id, void *userdata);
|
||||
|
||||
typedef struct {
|
||||
WGPUTextureViewId view_id;
|
||||
|
@ -600,11 +600,11 @@ impl<B: GfxBackend> Device<B> {
|
||||
}
|
||||
};
|
||||
match operation {
|
||||
resource::BufferMapOperation::Read(_, on_read, userdata) => {
|
||||
on_read(status, ptr, userdata)
|
||||
resource::BufferMapOperation::Read(_, on_read) => {
|
||||
on_read(status, ptr)
|
||||
}
|
||||
resource::BufferMapOperation::Write(_, on_write, userdata) => {
|
||||
on_write(status, ptr, userdata)
|
||||
resource::BufferMapOperation::Write(_, on_write) => {
|
||||
on_write(status, ptr)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2000,11 +2000,6 @@ impl<F: AllIdentityFilter + IdentityFilter<DeviceId>> Global<F> {
|
||||
}
|
||||
}
|
||||
|
||||
pub type BufferMapReadCallback =
|
||||
extern "C" fn(status: resource::BufferMapAsyncStatus, data: *const u8, userdata: *mut u8);
|
||||
pub type BufferMapWriteCallback =
|
||||
extern "C" fn(status: resource::BufferMapAsyncStatus, data: *mut u8, userdata: *mut u8);
|
||||
|
||||
impl<F> Global<F> {
|
||||
pub fn buffer_map_async<B: GfxBackend>(
|
||||
&self,
|
||||
|
@ -17,7 +17,6 @@ use serde::{Deserialize, Serialize};
|
||||
pub use hal::adapter::AdapterInfo;
|
||||
use hal::{self, adapter::PhysicalDevice as _, queue::QueueFamily as _, Instance as _};
|
||||
|
||||
use std::ffi::c_void;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Instance {
|
||||
@ -153,8 +152,6 @@ pub struct DeviceDescriptor {
|
||||
pub limits: Limits,
|
||||
}
|
||||
|
||||
pub type RequestAdapterCallback = extern "C" fn(adapter: *const AdapterId, userdata: *mut c_void);
|
||||
|
||||
bitflags::bitflags! {
|
||||
#[repr(transparent)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
|
@ -3,7 +3,6 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use crate::{
|
||||
device::{BufferMapReadCallback, BufferMapWriteCallback},
|
||||
id::{DeviceId, SwapChainId, TextureId},
|
||||
track::DUMMY_SELECTOR,
|
||||
BufferAddress,
|
||||
@ -17,7 +16,7 @@ use hal;
|
||||
use rendy_memory::MemoryBlock;
|
||||
use smallvec::SmallVec;
|
||||
|
||||
use std::borrow::Borrow;
|
||||
use std::{borrow::Borrow, fmt};
|
||||
|
||||
bitflags::bitflags! {
|
||||
#[repr(transparent)]
|
||||
@ -62,25 +61,35 @@ pub enum BufferMapAsyncStatus {
|
||||
ContextLost,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum BufferMapOperation {
|
||||
Read(std::ops::Range<u64>, BufferMapReadCallback, *mut u8),
|
||||
Write(std::ops::Range<u64>, BufferMapWriteCallback, *mut u8),
|
||||
Read(std::ops::Range<u64>, Box<dyn FnOnce(BufferMapAsyncStatus, *const u8)>),
|
||||
Write(std::ops::Range<u64>, Box<dyn FnOnce(BufferMapAsyncStatus, *mut u8)>),
|
||||
}
|
||||
|
||||
//TODO: clarify if/why this is needed here
|
||||
unsafe impl Send for BufferMapOperation {}
|
||||
unsafe impl Sync for BufferMapOperation {}
|
||||
|
||||
impl fmt::Debug for BufferMapOperation {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
let (op, range) = match *self {
|
||||
BufferMapOperation::Read(ref range, _) => ("read", range),
|
||||
BufferMapOperation::Write(ref range, _) => ("write", range),
|
||||
};
|
||||
write!(fmt, "BufferMapOperation <{}> of range {:?}", op, range)
|
||||
}
|
||||
}
|
||||
|
||||
impl BufferMapOperation {
|
||||
pub(crate) fn call_error(self) {
|
||||
match self {
|
||||
BufferMapOperation::Read(_, callback, userdata) => {
|
||||
BufferMapOperation::Read(_, callback) => {
|
||||
log::error!("wgpu_buffer_map_read_async failed: buffer mapping is pending");
|
||||
callback(BufferMapAsyncStatus::Error, std::ptr::null_mut(), userdata);
|
||||
callback(BufferMapAsyncStatus::Error, std::ptr::null());
|
||||
}
|
||||
BufferMapOperation::Write(_, callback, userdata) => {
|
||||
BufferMapOperation::Write(_, callback) => {
|
||||
log::error!("wgpu_buffer_map_write_async failed: buffer mapping is pending");
|
||||
callback(BufferMapAsyncStatus::Error, std::ptr::null_mut(), userdata);
|
||||
callback(BufferMapAsyncStatus::Error, std::ptr::null_mut());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,12 @@ use core::{gfx_select, hub::Token, id};
|
||||
|
||||
use std::{marker::PhantomData, slice};
|
||||
|
||||
pub type RequestAdapterCallback =
|
||||
unsafe extern "C" fn(id: id::AdapterId, userdata: *mut std::ffi::c_void);
|
||||
pub type BufferMapReadCallback =
|
||||
unsafe extern "C" fn(status: core::resource::BufferMapAsyncStatus, data: *const u8, userdata: *mut u8);
|
||||
pub type BufferMapWriteCallback =
|
||||
unsafe extern "C" fn(status: core::resource::BufferMapAsyncStatus, data: *mut u8, userdata: *mut u8);
|
||||
|
||||
pub fn wgpu_create_surface(raw_handle: raw_window_handle::RawWindowHandle) -> id::SurfaceId {
|
||||
use raw_window_handle::RawWindowHandle as Rwh;
|
||||
@ -116,17 +122,19 @@ pub extern "C" fn wgpu_create_surface_from_windows_hwnd(
|
||||
pub extern "C" fn wgpu_request_adapter_async(
|
||||
desc: Option<&core::instance::RequestAdapterOptions>,
|
||||
mask: core::instance::BackendBit,
|
||||
callback: core::instance::RequestAdapterCallback,
|
||||
callback: RequestAdapterCallback,
|
||||
userdata: *mut std::ffi::c_void,
|
||||
) {
|
||||
let id = GLOBAL.pick_adapter(
|
||||
&desc.cloned().unwrap_or_default(),
|
||||
core::instance::AdapterInputs::Mask(mask, || PhantomData),
|
||||
);
|
||||
callback(
|
||||
id.as_ref().map_or(&id::AdapterId::ERROR, |x| x as *const _),
|
||||
userdata,
|
||||
);
|
||||
unsafe {
|
||||
callback(
|
||||
id.unwrap_or(id::AdapterId::ERROR),
|
||||
userdata,
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
@ -313,11 +321,15 @@ pub extern "C" fn wgpu_buffer_map_read_async(
|
||||
buffer_id: id::BufferId,
|
||||
start: core::BufferAddress,
|
||||
size: core::BufferAddress,
|
||||
callback: core::device::BufferMapReadCallback,
|
||||
callback: BufferMapReadCallback,
|
||||
userdata: *mut u8,
|
||||
) {
|
||||
let operation =
|
||||
core::resource::BufferMapOperation::Read(start .. start + size, callback, userdata);
|
||||
let operation = core::resource::BufferMapOperation::Read(
|
||||
start .. start + size,
|
||||
Box::new(move |status, data| unsafe {
|
||||
callback(status, data, userdata)
|
||||
}),
|
||||
);
|
||||
gfx_select!(buffer_id => GLOBAL.buffer_map_async(buffer_id, core::resource::BufferUsage::MAP_READ, operation))
|
||||
}
|
||||
|
||||
@ -326,11 +338,15 @@ pub extern "C" fn wgpu_buffer_map_write_async(
|
||||
buffer_id: id::BufferId,
|
||||
start: core::BufferAddress,
|
||||
size: core::BufferAddress,
|
||||
callback: core::device::BufferMapWriteCallback,
|
||||
callback: BufferMapWriteCallback,
|
||||
userdata: *mut u8,
|
||||
) {
|
||||
let operation =
|
||||
core::resource::BufferMapOperation::Write(start .. start + size, callback, userdata);
|
||||
let operation = core::resource::BufferMapOperation::Write(
|
||||
start .. start + size,
|
||||
Box::new(move |status, data| unsafe {
|
||||
callback(status, data, userdata)
|
||||
}),
|
||||
);
|
||||
gfx_select!(buffer_id => GLOBAL.buffer_map_async(buffer_id, core::resource::BufferUsage::MAP_WRITE, operation))
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,10 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
pub mod command;
|
||||
pub mod device;
|
||||
mod command;
|
||||
mod device;
|
||||
|
||||
pub use self::command::*;
|
||||
pub use self::device::*;
|
||||
|
||||
type Global = core::hub::Global<parking_lot::Mutex<core::hub::IdentityManager>>;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user