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