mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-24 00:11:11 +01:00
Explicit Global hubs
This commit is contained in:
1 parent
ae5a78f828
commit
f67894c310
11 files changed
+369
-177
No files matched your search
+85
-1
@@ -244,6 +244,8 @@ typedef enum {
|
||||
WGPUVertexFormat_Int4 = 48,
|
||||
} WGPUVertexFormat;
|
||||
|
||||
typedef struct WGPUGlobal WGPUGlobal;
|
||||
|
||||
typedef uint64_t WGPUId_Device_Dummy;
|
||||
|
||||
typedef WGPUId_Device_Dummy WGPUDeviceId;
|
||||
@@ -670,23 +672,33 @@ WGPUDeviceId wgpu_adapter_request_device(WGPUAdapterId adapter_id,
|
||||
const WGPUDeviceDescriptor *desc);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
void wgpu_bind_group_destroy(WGPUBindGroupId bind_group_id);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
void wgpu_buffer_destroy(WGPUBufferId buffer_id);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
void wgpu_buffer_map_read_async(WGPUBufferId buffer_id,
|
||||
WGPUBufferAddress start,
|
||||
WGPUBufferAddress size,
|
||||
WGPUBufferMapReadCallback callback,
|
||||
uint8_t *userdata);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
void wgpu_buffer_map_write_async(WGPUBufferId buffer_id,
|
||||
WGPUBufferAddress start,
|
||||
WGPUBufferAddress size,
|
||||
WGPUBufferMapWriteCallback callback,
|
||||
uint8_t *userdata);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
void wgpu_buffer_unmap(WGPUBufferId buffer_id);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
WGPUComputePassId wgpu_command_encoder_begin_compute_pass(WGPUCommandEncoderId encoder_id,
|
||||
@@ -698,38 +710,54 @@ WGPURenderPassId wgpu_command_encoder_begin_render_pass(WGPUCommandEncoderId enc
|
||||
const WGPURenderPassDescriptor *desc);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
void wgpu_command_encoder_copy_buffer_to_buffer(WGPUCommandEncoderId command_encoder_id,
|
||||
WGPUBufferId source,
|
||||
WGPUBufferAddress source_offset,
|
||||
WGPUBufferId destination,
|
||||
WGPUBufferAddress destination_offset,
|
||||
WGPUBufferAddress size);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
void wgpu_command_encoder_copy_buffer_to_texture(WGPUCommandEncoderId command_encoder_id,
|
||||
const WGPUBufferCopyView *source,
|
||||
const WGPUTextureCopyView *destination,
|
||||
WGPUExtent3d copy_size);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
void wgpu_command_encoder_copy_texture_to_buffer(WGPUCommandEncoderId command_encoder_id,
|
||||
const WGPUTextureCopyView *source,
|
||||
const WGPUBufferCopyView *destination,
|
||||
WGPUExtent3d copy_size);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
void wgpu_command_encoder_copy_texture_to_texture(WGPUCommandEncoderId command_encoder_id,
|
||||
const WGPUTextureCopyView *source,
|
||||
const WGPUTextureCopyView *destination,
|
||||
WGPUExtent3d copy_size);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
WGPUCommandBufferId wgpu_command_encoder_finish(WGPUCommandEncoderId encoder_id,
|
||||
const WGPUCommandBufferDescriptor *desc);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
void wgpu_compute_pass_dispatch(WGPUComputePassId pass_id, uint32_t x, uint32_t y, uint32_t z);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
void wgpu_compute_pass_dispatch_indirect(WGPUComputePassId pass_id,
|
||||
WGPUBufferId indirect_buffer_id,
|
||||
WGPUBufferAddress indirect_offset);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
void wgpu_compute_pass_end_pass(WGPUComputePassId pass_id);
|
||||
#endif
|
||||
|
||||
void wgpu_compute_pass_insert_debug_marker(WGPUComputePassId _pass_id, WGPURawString _label);
|
||||
|
||||
@@ -737,13 +765,17 @@ void wgpu_compute_pass_pop_debug_group(WGPUComputePassId _pass_id);
|
||||
|
||||
void wgpu_compute_pass_push_debug_group(WGPUComputePassId _pass_id, WGPURawString _label);
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
void wgpu_compute_pass_set_bind_group(WGPUComputePassId pass_id,
|
||||
uint32_t index,
|
||||
WGPUBindGroupId bind_group_id,
|
||||
const WGPUBufferAddress *offsets,
|
||||
uintptr_t offsets_length);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
void wgpu_compute_pass_set_pipeline(WGPUComputePassId pass_id, WGPUComputePipelineId pipeline_id);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
WGPUSurfaceId wgpu_create_surface_from_metal_layer(void *layer);
|
||||
@@ -816,81 +848,124 @@ WGPUSwapChainId wgpu_device_create_swap_chain(WGPUDeviceId device_id,
|
||||
WGPUTextureId wgpu_device_create_texture(WGPUDeviceId device_id, const WGPUTextureDescriptor *desc);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
void wgpu_device_destroy(WGPUDeviceId device_id);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
void wgpu_device_get_limits(WGPUDeviceId _device_id, WGPULimits *limits);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
WGPUQueueId wgpu_device_get_queue(WGPUDeviceId device_id);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
void wgpu_device_poll(WGPUDeviceId device_id, bool force_wait);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
void wgpu_queue_submit(WGPUQueueId queue_id,
|
||||
const WGPUCommandBufferId *command_buffers,
|
||||
uintptr_t command_buffers_length);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
void wgpu_render_pass_draw(WGPURenderPassId pass_id,
|
||||
uint32_t vertex_count,
|
||||
uint32_t instance_count,
|
||||
uint32_t first_vertex,
|
||||
uint32_t first_instance);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
void wgpu_render_pass_draw_indexed(WGPURenderPassId pass_id,
|
||||
uint32_t index_count,
|
||||
uint32_t instance_count,
|
||||
uint32_t first_index,
|
||||
int32_t base_vertex,
|
||||
uint32_t first_instance);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
void wgpu_render_pass_draw_indexed_indirect(WGPURenderPassId pass_id,
|
||||
WGPUBufferId indirect_buffer_id,
|
||||
WGPUBufferAddress indirect_offset);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
void wgpu_render_pass_draw_indirect(WGPURenderPassId pass_id,
|
||||
WGPUBufferId indirect_buffer_id,
|
||||
WGPUBufferAddress indirect_offset);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
void wgpu_render_pass_end_pass(WGPURenderPassId pass_id);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
void wgpu_render_pass_execute_bundles(WGPURenderPassId _pass_id,
|
||||
const WGPURenderBundleId *_bundles,
|
||||
uintptr_t _bundles_length);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
void wgpu_render_pass_insert_debug_marker(WGPURenderPassId _pass_id, WGPURawString _label);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
void wgpu_render_pass_pop_debug_group(WGPURenderPassId _pass_id);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
void wgpu_render_pass_push_debug_group(WGPURenderPassId _pass_id, WGPURawString _label);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
void wgpu_render_pass_set_bind_group(WGPURenderPassId pass_id,
|
||||
uint32_t index,
|
||||
WGPUBindGroupId bind_group_id,
|
||||
const WGPUBufferAddress *offsets,
|
||||
uintptr_t offsets_length);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
void wgpu_render_pass_set_blend_color(WGPURenderPassId pass_id, const WGPUColor *color);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
void wgpu_render_pass_set_index_buffer(WGPURenderPassId pass_id,
|
||||
WGPUBufferId buffer_id,
|
||||
WGPUBufferAddress offset);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
void wgpu_render_pass_set_pipeline(WGPURenderPassId pass_id, WGPURenderPipelineId pipeline_id);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
void wgpu_render_pass_set_scissor_rect(WGPURenderPassId pass_id,
|
||||
uint32_t x,
|
||||
uint32_t y,
|
||||
uint32_t w,
|
||||
uint32_t h);
|
||||
#endif
|
||||
|
||||
void wgpu_render_pass_set_stencil_reference(WGPURenderPassId pass_id, uint32_t value);
|
||||
#if !defined(WGPU_REMOTE)
|
||||
void wgpu_render_pass_set_stencil_reference(const WGPUGlobal *global,
|
||||
WGPURenderPassId pass_id,
|
||||
uint32_t value);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
void wgpu_render_pass_set_vertex_buffers(WGPURenderPassId pass_id,
|
||||
uint32_t start_slot,
|
||||
const WGPUBufferId *buffers,
|
||||
const WGPUBufferAddress *offsets,
|
||||
uintptr_t length);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
void wgpu_render_pass_set_viewport(WGPURenderPassId pass_id,
|
||||
float x,
|
||||
float y,
|
||||
@@ -898,24 +973,33 @@ void wgpu_render_pass_set_viewport(WGPURenderPassId pass_id,
|
||||
float h,
|
||||
float min_depth,
|
||||
float max_depth);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
WGPUAdapterId wgpu_request_adapter(const WGPURequestAdapterOptions *desc);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
void wgpu_sampler_destroy(WGPUSamplerId sampler_id);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
WGPUSwapChainOutput wgpu_swap_chain_get_next_texture(WGPUSwapChainId swap_chain_id);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
void wgpu_swap_chain_present(WGPUSwapChainId swap_chain_id);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
WGPUTextureViewId wgpu_texture_create_view(WGPUTextureId texture_id,
|
||||
const WGPUTextureViewDescriptor *desc);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
void wgpu_texture_destroy(WGPUTextureId texture_id);
|
||||
#endif
|
||||
|
||||
#if !defined(WGPU_REMOTE)
|
||||
void wgpu_texture_view_destroy(WGPUTextureViewId texture_view_id);
|
||||
#endif
|
||||
@@ -26,7 +26,7 @@ metal-auto-capture = ["gfx-backend-metal/auto-capture"]
|
||||
arrayvec = "0.5"
|
||||
bitflags = "1.0"
|
||||
copyless = "0.1"
|
||||
lazy_static = "1.1.0"
|
||||
lazy_static = "1.1.0" #TODO: local only
|
||||
log = "0.4"
|
||||
hal = { package = "gfx-hal", git = "https://github.com/gfx-rs/gfx", rev = "3d5db15661127c8cad8d85522a68ec36c82f6e69" }
|
||||
gfx-backend-empty = { git = "https://github.com/gfx-rs/gfx", rev = "3d5db15661127c8cad8d85522a68ec36c82f6e69" }
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
use crate::{
|
||||
command::bind::{Binder, LayoutChange},
|
||||
device::all_buffer_stages,
|
||||
gfx_select,
|
||||
hub::{GfxBackend, Token},
|
||||
hub::{GfxBackend, Global, Token},
|
||||
track::{Stitch, TrackerSet},
|
||||
BindGroupId,
|
||||
BufferAddress,
|
||||
@@ -20,11 +19,15 @@ use crate::{
|
||||
Stored,
|
||||
BIND_BUFFER_ALIGNMENT,
|
||||
};
|
||||
#[cfg(not(feature = "remote"))]
|
||||
use crate::{gfx_select, hub::GLOBAL};
|
||||
|
||||
use hal::{self, command::CommandBuffer as _};
|
||||
use log::trace;
|
||||
|
||||
use std::{iter, slice};
|
||||
use std::iter;
|
||||
#[cfg(not(feature = "remote"))]
|
||||
use std::slice;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct ComputePass<B: hal::Backend> {
|
||||
@@ -52,9 +55,9 @@ impl<B: hal::Backend> ComputePass<B> {
|
||||
|
||||
// Common routines between render/compute
|
||||
|
||||
pub fn compute_pass_end_pass<B: GfxBackend>(pass_id: ComputePassId) {
|
||||
pub fn compute_pass_end_pass<B: GfxBackend>(global: &Global, pass_id: ComputePassId) {
|
||||
let mut token = Token::root();
|
||||
let hub = B::hub();
|
||||
let hub = B::hub(global);
|
||||
let (mut cmb_guard, mut token) = hub.command_buffers.write(&mut token);
|
||||
let (pass, _) = hub.compute_passes.unregister(pass_id, &mut token);
|
||||
let cmb = &mut cmb_guard[pass.cmb_id.value];
|
||||
@@ -65,18 +68,20 @@ pub fn compute_pass_end_pass<B: GfxBackend>(pass_id: ComputePassId) {
|
||||
cmb.raw.push(pass.raw);
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "remote"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_compute_pass_end_pass(pass_id: ComputePassId) {
|
||||
gfx_select!(pass_id => compute_pass_end_pass(pass_id))
|
||||
gfx_select!(pass_id => compute_pass_end_pass(&*GLOBAL, pass_id))
|
||||
}
|
||||
|
||||
pub fn compute_pass_set_bind_group<B: GfxBackend>(
|
||||
global: &Global,
|
||||
pass_id: ComputePassId,
|
||||
index: u32,
|
||||
bind_group_id: BindGroupId,
|
||||
offsets: &[BufferAddress],
|
||||
) {
|
||||
let hub = B::hub();
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
|
||||
let (pipeline_layout_guard, mut token) = hub.pipeline_layouts.read(&mut token);
|
||||
@@ -143,6 +148,7 @@ pub fn compute_pass_set_bind_group<B: GfxBackend>(
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "remote"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_compute_pass_set_bind_group(
|
||||
pass_id: ComputePassId,
|
||||
@@ -156,7 +162,7 @@ pub extern "C" fn wgpu_compute_pass_set_bind_group(
|
||||
} else {
|
||||
&[]
|
||||
};
|
||||
gfx_select!(pass_id => compute_pass_set_bind_group(pass_id, index, bind_group_id, offsets))
|
||||
gfx_select!(pass_id => compute_pass_set_bind_group(&*GLOBAL, pass_id, index, bind_group_id, offsets))
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
@@ -179,8 +185,8 @@ pub extern "C" fn wgpu_compute_pass_insert_debug_marker(
|
||||
|
||||
// Compute-specific routines
|
||||
|
||||
pub fn compute_pass_dispatch<B: GfxBackend>(pass_id: ComputePassId, x: u32, y: u32, z: u32) {
|
||||
let hub = B::hub();
|
||||
pub fn compute_pass_dispatch<B: GfxBackend>(global: &Global, pass_id: ComputePassId, x: u32, y: u32, z: u32) {
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
let (mut pass_guard, _) = hub.compute_passes.write(&mut token);
|
||||
unsafe {
|
||||
@@ -188,17 +194,19 @@ pub fn compute_pass_dispatch<B: GfxBackend>(pass_id: ComputePassId, x: u32, y: u
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "remote"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_compute_pass_dispatch(pass_id: ComputePassId, x: u32, y: u32, z: u32) {
|
||||
gfx_select!(pass_id => compute_pass_dispatch(pass_id, x, y, z))
|
||||
gfx_select!(pass_id => compute_pass_dispatch(&*GLOBAL, pass_id, x, y, z))
|
||||
}
|
||||
|
||||
pub fn compute_pass_dispatch_indirect<B: GfxBackend>(
|
||||
global: &Global,
|
||||
pass_id: ComputePassId,
|
||||
indirect_buffer_id: BufferId,
|
||||
indirect_offset: BufferAddress,
|
||||
) {
|
||||
let hub = B::hub();
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
let (buffer_guard, _) = hub.buffers.read(&mut token);
|
||||
let (mut pass_guard, _) = hub.compute_passes.write(&mut token);
|
||||
@@ -229,20 +237,22 @@ pub fn compute_pass_dispatch_indirect<B: GfxBackend>(
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "remote"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_compute_pass_dispatch_indirect(
|
||||
pass_id: ComputePassId,
|
||||
indirect_buffer_id: BufferId,
|
||||
indirect_offset: BufferAddress,
|
||||
) {
|
||||
gfx_select!(pass_id => compute_pass_dispatch_indirect(pass_id, indirect_buffer_id, indirect_offset))
|
||||
gfx_select!(pass_id => compute_pass_dispatch_indirect(&*GLOBAL, pass_id, indirect_buffer_id, indirect_offset))
|
||||
}
|
||||
|
||||
pub fn compute_pass_set_pipeline<B: GfxBackend>(
|
||||
global: &Global,
|
||||
pass_id: ComputePassId,
|
||||
pipeline_id: ComputePipelineId,
|
||||
) {
|
||||
let hub = B::hub();
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
let (pipeline_layout_guard, mut token) = hub.pipeline_layouts.read(&mut token);
|
||||
let (bind_group_guard, mut token) = hub.bind_groups.read(&mut token);
|
||||
@@ -292,10 +302,11 @@ pub fn compute_pass_set_pipeline<B: GfxBackend>(
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "remote"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_compute_pass_set_pipeline(
|
||||
pass_id: ComputePassId,
|
||||
pipeline_id: ComputePipelineId,
|
||||
) {
|
||||
gfx_select!(pass_id => compute_pass_set_pipeline(pass_id, pipeline_id))
|
||||
gfx_select!(pass_id => compute_pass_set_pipeline(&*GLOBAL, pass_id, pipeline_id))
|
||||
}
|
||||
@@ -22,8 +22,7 @@ use crate::{
|
||||
RenderPassContext,
|
||||
RenderPassKey,
|
||||
},
|
||||
gfx_select,
|
||||
hub::{GfxBackend, Storage, Token},
|
||||
hub::{GfxBackend, Global, Storage, Token},
|
||||
id::{Input, Output},
|
||||
resource::TextureViewInner,
|
||||
track::{Stitch, TrackerSet},
|
||||
@@ -43,6 +42,8 @@ use crate::{
|
||||
TextureUsage,
|
||||
TextureViewId,
|
||||
};
|
||||
#[cfg(not(feature = "remote"))]
|
||||
use crate::{gfx_select, hub::GLOBAL};
|
||||
|
||||
use arrayvec::ArrayVec;
|
||||
use hal::{adapter::PhysicalDevice as _, command::CommandBuffer as _, device::Device as _};
|
||||
@@ -194,10 +195,11 @@ pub struct CommandBufferDescriptor {
|
||||
}
|
||||
|
||||
pub fn command_encoder_finish<B: GfxBackend>(
|
||||
global: &Global,
|
||||
encoder_id: CommandEncoderId,
|
||||
_desc: &CommandBufferDescriptor,
|
||||
) -> CommandBufferId {
|
||||
let hub = B::hub();
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
//TODO: actually close the last recorded command buffer
|
||||
let (mut comb_guard, _) = hub.command_buffers.write(&mut token);
|
||||
@@ -211,21 +213,23 @@ pub fn command_encoder_finish<B: GfxBackend>(
|
||||
encoder_id
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "remote"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_command_encoder_finish(
|
||||
encoder_id: CommandEncoderId,
|
||||
desc: Option<&CommandBufferDescriptor>,
|
||||
) -> CommandBufferId {
|
||||
let desc = &desc.cloned().unwrap_or_default();
|
||||
gfx_select!(encoder_id => command_encoder_finish(encoder_id, desc))
|
||||
gfx_select!(encoder_id => command_encoder_finish(&*GLOBAL, encoder_id, desc))
|
||||
}
|
||||
|
||||
pub fn command_encoder_begin_render_pass<B: GfxBackend>(
|
||||
global: &Global,
|
||||
encoder_id: CommandEncoderId,
|
||||
desc: &RenderPassDescriptor,
|
||||
id_in: Input<RenderPassId>,
|
||||
) -> Output<RenderPassId> {
|
||||
let hub = B::hub();
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
|
||||
let (adapter_guard, mut token) = hub.adapters.read(&mut token);
|
||||
@@ -724,15 +728,16 @@ pub extern "C" fn wgpu_command_encoder_begin_render_pass(
|
||||
encoder_id: CommandEncoderId,
|
||||
desc: &RenderPassDescriptor,
|
||||
) -> RenderPassId {
|
||||
gfx_select!(encoder_id => command_encoder_begin_render_pass(encoder_id, desc, PhantomData))
|
||||
gfx_select!(encoder_id => command_encoder_begin_render_pass(&*GLOBAL, encoder_id, desc, PhantomData))
|
||||
}
|
||||
|
||||
pub fn command_encoder_begin_compute_pass<B: GfxBackend>(
|
||||
global: &Global,
|
||||
encoder_id: CommandEncoderId,
|
||||
_desc: &ComputePassDescriptor,
|
||||
id_in: Input<ComputePassId>,
|
||||
) -> Output<ComputePassId> {
|
||||
let hub = B::hub();
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
|
||||
let (mut cmb_guard, mut token) = hub.command_buffers.write(&mut token);
|
||||
@@ -757,5 +762,5 @@ pub extern "C" fn wgpu_command_encoder_begin_compute_pass(
|
||||
desc: Option<&ComputePassDescriptor>,
|
||||
) -> ComputePassId {
|
||||
let desc = &desc.cloned().unwrap_or_default();
|
||||
gfx_select!(encoder_id => command_encoder_begin_compute_pass(encoder_id, desc, PhantomData))
|
||||
gfx_select!(encoder_id => command_encoder_begin_compute_pass(&*GLOBAL, encoder_id, desc, PhantomData))
|
||||
}
|
||||
@@ -6,8 +6,7 @@ use crate::{
|
||||
command::bind::{Binder, LayoutChange},
|
||||
conv,
|
||||
device::{RenderPassContext, BIND_BUFFER_ALIGNMENT, MAX_VERTEX_BUFFERS},
|
||||
gfx_select,
|
||||
hub::{GfxBackend, Token},
|
||||
hub::{GfxBackend, Global, Token},
|
||||
pipeline::{IndexFormat, InputStepMode, PipelineFlags},
|
||||
resource::BufferUsage,
|
||||
track::{Stitch, TrackerSet},
|
||||
@@ -17,17 +16,19 @@ use crate::{
|
||||
Color,
|
||||
CommandBuffer,
|
||||
CommandBufferId,
|
||||
RawString,
|
||||
RenderBundleId,
|
||||
RenderPassId,
|
||||
RenderPipelineId,
|
||||
Stored,
|
||||
};
|
||||
#[cfg(not(feature = "remote"))]
|
||||
use crate::{gfx_select, RawString, RenderBundleId, hub::GLOBAL};
|
||||
|
||||
use hal::command::CommandBuffer as _;
|
||||
use log::trace;
|
||||
|
||||
use std::{iter, ops::Range, slice};
|
||||
use std::{iter, ops::Range};
|
||||
#[cfg(not(feature = "remote"))]
|
||||
use std::slice;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
enum OptionalState {
|
||||
@@ -181,8 +182,8 @@ impl<B: GfxBackend> RenderPass<B> {
|
||||
|
||||
// Common routines between render/compute
|
||||
|
||||
pub fn render_pass_end_pass<B: GfxBackend>(pass_id: RenderPassId) {
|
||||
let hub = B::hub();
|
||||
pub fn render_pass_end_pass<B: GfxBackend>(global: &Global, pass_id: RenderPassId) {
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
let (mut cmb_guard, mut token) = hub.command_buffers.write(&mut token);
|
||||
let (mut pass, mut token) = hub.render_passes.unregister(pass_id, &mut token);
|
||||
@@ -215,18 +216,20 @@ pub fn render_pass_end_pass<B: GfxBackend>(pass_id: RenderPassId) {
|
||||
cmb.raw.push(pass.raw);
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "remote"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_render_pass_end_pass(pass_id: RenderPassId) {
|
||||
gfx_select!(pass_id => render_pass_end_pass(pass_id))
|
||||
gfx_select!(pass_id => render_pass_end_pass(&*GLOBAL, pass_id))
|
||||
}
|
||||
|
||||
pub fn render_pass_set_bind_group<B: GfxBackend>(
|
||||
global: &Global,
|
||||
pass_id: RenderPassId,
|
||||
index: u32,
|
||||
bind_group_id: BindGroupId,
|
||||
offsets: &[BufferAddress],
|
||||
) {
|
||||
let hub = B::hub();
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
let (pipeline_layout_guard, mut token) = hub.pipeline_layouts.read(&mut token);
|
||||
let (bind_group_guard, mut token) = hub.bind_groups.read(&mut token);
|
||||
@@ -276,6 +279,7 @@ pub fn render_pass_set_bind_group<B: GfxBackend>(
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "remote"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_render_pass_set_bind_group(
|
||||
pass_id: RenderPassId,
|
||||
@@ -289,19 +293,22 @@ pub extern "C" fn wgpu_render_pass_set_bind_group(
|
||||
} else {
|
||||
&[]
|
||||
};
|
||||
gfx_select!(pass_id => render_pass_set_bind_group(pass_id, index, bind_group_id, offsets))
|
||||
gfx_select!(pass_id => render_pass_set_bind_group(&*GLOBAL, pass_id, index, bind_group_id, offsets))
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "remote"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_render_pass_push_debug_group(_pass_id: RenderPassId, _label: RawString) {
|
||||
//TODO
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "remote"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_render_pass_pop_debug_group(_pass_id: RenderPassId) {
|
||||
//TODO
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "remote"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_render_pass_insert_debug_marker(_pass_id: RenderPassId, _label: RawString) {
|
||||
//TODO
|
||||
@@ -310,11 +317,12 @@ pub extern "C" fn wgpu_render_pass_insert_debug_marker(_pass_id: RenderPassId, _
|
||||
// Render-specific routines
|
||||
|
||||
pub fn render_pass_set_index_buffer<B: GfxBackend>(
|
||||
global: &Global,
|
||||
pass_id: RenderPassId,
|
||||
buffer_id: BufferId,
|
||||
offset: BufferAddress,
|
||||
) {
|
||||
let hub = B::hub();
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
let (mut pass_guard, mut token) = hub.render_passes.write(&mut token);
|
||||
let (buffer_guard, _) = hub.buffers.read(&mut token);
|
||||
@@ -342,22 +350,24 @@ pub fn render_pass_set_index_buffer<B: GfxBackend>(
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "remote"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_render_pass_set_index_buffer(
|
||||
pass_id: RenderPassId,
|
||||
buffer_id: BufferId,
|
||||
offset: BufferAddress,
|
||||
) {
|
||||
gfx_select!(pass_id => render_pass_set_index_buffer(pass_id, buffer_id, offset))
|
||||
gfx_select!(pass_id => render_pass_set_index_buffer(&*GLOBAL, pass_id, buffer_id, offset))
|
||||
}
|
||||
|
||||
pub fn render_pass_set_vertex_buffers<B: GfxBackend>(
|
||||
global: &Global,
|
||||
pass_id: RenderPassId,
|
||||
start_slot: u32,
|
||||
buffers: &[BufferId],
|
||||
offsets: &[BufferAddress],
|
||||
) {
|
||||
let hub = B::hub();
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
assert_eq!(buffers.len(), offsets.len());
|
||||
|
||||
@@ -391,6 +401,7 @@ pub fn render_pass_set_vertex_buffers<B: GfxBackend>(
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "remote"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_render_pass_set_vertex_buffers(
|
||||
pass_id: RenderPassId,
|
||||
@@ -401,17 +412,18 @@ pub extern "C" fn wgpu_render_pass_set_vertex_buffers(
|
||||
) {
|
||||
let buffers = unsafe { slice::from_raw_parts(buffers, length) };
|
||||
let offsets = unsafe { slice::from_raw_parts(offsets, length) };
|
||||
gfx_select!(pass_id => render_pass_set_vertex_buffers(pass_id, start_slot, buffers, offsets))
|
||||
gfx_select!(pass_id => render_pass_set_vertex_buffers(&*GLOBAL, pass_id, start_slot, buffers, offsets))
|
||||
}
|
||||
|
||||
pub fn render_pass_draw<B: GfxBackend>(
|
||||
global: &Global,
|
||||
pass_id: RenderPassId,
|
||||
vertex_count: u32,
|
||||
instance_count: u32,
|
||||
first_vertex: u32,
|
||||
first_instance: u32,
|
||||
) {
|
||||
let hub = B::hub();
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
let (mut pass_guard, _) = hub.render_passes.write(&mut token);
|
||||
let pass = &mut pass_guard[pass_id];
|
||||
@@ -434,6 +446,7 @@ pub fn render_pass_draw<B: GfxBackend>(
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "remote"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_render_pass_draw(
|
||||
pass_id: RenderPassId,
|
||||
@@ -442,15 +455,16 @@ pub extern "C" fn wgpu_render_pass_draw(
|
||||
first_vertex: u32,
|
||||
first_instance: u32,
|
||||
) {
|
||||
gfx_select!(pass_id => render_pass_draw(pass_id, vertex_count, instance_count, first_vertex, first_instance))
|
||||
gfx_select!(pass_id => render_pass_draw(&*GLOBAL, pass_id, vertex_count, instance_count, first_vertex, first_instance))
|
||||
}
|
||||
|
||||
pub fn render_pass_draw_indirect<B: GfxBackend>(
|
||||
global: &Global,
|
||||
pass_id: RenderPassId,
|
||||
indirect_buffer_id: BufferId,
|
||||
indirect_offset: BufferAddress,
|
||||
) {
|
||||
let hub = B::hub();
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
let (mut pass_guard, _) = hub.render_passes.write(&mut token);
|
||||
let (buffer_guard, _) = hub.buffers.read(&mut token);
|
||||
@@ -474,16 +488,18 @@ pub fn render_pass_draw_indirect<B: GfxBackend>(
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "remote"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_render_pass_draw_indirect(
|
||||
pass_id: RenderPassId,
|
||||
indirect_buffer_id: BufferId,
|
||||
indirect_offset: BufferAddress,
|
||||
) {
|
||||
gfx_select!(pass_id => render_pass_draw_indirect(pass_id, indirect_buffer_id, indirect_offset))
|
||||
gfx_select!(pass_id => render_pass_draw_indirect(&*GLOBAL, pass_id, indirect_buffer_id, indirect_offset))
|
||||
}
|
||||
|
||||
pub fn render_pass_draw_indexed<B: GfxBackend>(
|
||||
global: &Global,
|
||||
pass_id: RenderPassId,
|
||||
index_count: u32,
|
||||
instance_count: u32,
|
||||
@@ -491,7 +507,7 @@ pub fn render_pass_draw_indexed<B: GfxBackend>(
|
||||
base_vertex: i32,
|
||||
first_instance: u32,
|
||||
) {
|
||||
let hub = B::hub();
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
let (mut pass_guard, _) = hub.render_passes.write(&mut token);
|
||||
let pass = &mut pass_guard[pass_id];
|
||||
@@ -516,6 +532,7 @@ pub fn render_pass_draw_indexed<B: GfxBackend>(
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "remote"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_render_pass_draw_indexed(
|
||||
pass_id: RenderPassId,
|
||||
@@ -525,15 +542,16 @@ pub extern "C" fn wgpu_render_pass_draw_indexed(
|
||||
base_vertex: i32,
|
||||
first_instance: u32,
|
||||
) {
|
||||
gfx_select!(pass_id => render_pass_draw_indexed(pass_id, index_count, instance_count, first_index, base_vertex, first_instance))
|
||||
gfx_select!(pass_id => render_pass_draw_indexed(&*GLOBAL, pass_id, index_count, instance_count, first_index, base_vertex, first_instance))
|
||||
}
|
||||
|
||||
pub fn render_pass_draw_indexed_indirect<B: GfxBackend>(
|
||||
global: &Global,
|
||||
pass_id: RenderPassId,
|
||||
indirect_buffer_id: BufferId,
|
||||
indirect_offset: BufferAddress,
|
||||
) {
|
||||
let hub = B::hub();
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
let (mut pass_guard, _) = hub.render_passes.write(&mut token);
|
||||
let (buffer_guard, _) = hub.buffers.read(&mut token);
|
||||
@@ -558,20 +576,22 @@ pub fn render_pass_draw_indexed_indirect<B: GfxBackend>(
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "remote"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_render_pass_draw_indexed_indirect(
|
||||
pass_id: RenderPassId,
|
||||
indirect_buffer_id: BufferId,
|
||||
indirect_offset: BufferAddress,
|
||||
) {
|
||||
gfx_select!(pass_id => render_pass_draw_indexed_indirect(pass_id, indirect_buffer_id, indirect_offset))
|
||||
gfx_select!(pass_id => render_pass_draw_indexed_indirect(&*GLOBAL, pass_id, indirect_buffer_id, indirect_offset))
|
||||
}
|
||||
|
||||
pub fn render_pass_set_pipeline<B: GfxBackend>(
|
||||
global: &Global,
|
||||
pass_id: RenderPassId,
|
||||
pipeline_id: RenderPipelineId,
|
||||
) {
|
||||
let hub = B::hub();
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
let (pipeline_layout_guard, mut token) = hub.pipeline_layouts.read(&mut token);
|
||||
let (bind_group_guard, mut token) = hub.bind_groups.read(&mut token);
|
||||
@@ -675,16 +695,19 @@ pub fn render_pass_set_pipeline<B: GfxBackend>(
|
||||
pass.vertex_state.update_limits();
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "remote"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_render_pass_set_pipeline(
|
||||
pass_id: RenderPassId,
|
||||
pipeline_id: RenderPipelineId,
|
||||
) {
|
||||
gfx_select!(pass_id => render_pass_set_pipeline(pass_id, pipeline_id))
|
||||
gfx_select!(pass_id => render_pass_set_pipeline(&*GLOBAL, pass_id, pipeline_id))
|
||||
}
|
||||
|
||||
pub fn render_pass_set_blend_color<B: GfxBackend>(pass_id: RenderPassId, color: &Color) {
|
||||
let hub = B::hub();
|
||||
pub fn render_pass_set_blend_color<B: GfxBackend>(
|
||||
global: &Global, pass_id: RenderPassId, color: &Color
|
||||
) {
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
let (mut pass_guard, _) = hub.render_passes.write(&mut token);
|
||||
let pass = &mut pass_guard[pass_id];
|
||||
@@ -696,13 +719,16 @@ pub fn render_pass_set_blend_color<B: GfxBackend>(pass_id: RenderPassId, color:
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "remote"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_render_pass_set_blend_color(pass_id: RenderPassId, color: &Color) {
|
||||
gfx_select!(pass_id => render_pass_set_blend_color(pass_id, color))
|
||||
gfx_select!(pass_id => render_pass_set_blend_color(&*GLOBAL, pass_id, color))
|
||||
}
|
||||
|
||||
pub fn render_pass_set_stencil_reference<B: GfxBackend>(pass_id: RenderPassId, value: u32) {
|
||||
let hub = B::hub();
|
||||
pub fn render_pass_set_stencil_reference<B: GfxBackend>(
|
||||
global: &Global, pass_id: RenderPassId, value: u32
|
||||
) {
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
let (mut pass_guard, _) = hub.render_passes.write(&mut token);
|
||||
let pass = &mut pass_guard[pass_id];
|
||||
@@ -714,12 +740,16 @@ pub fn render_pass_set_stencil_reference<B: GfxBackend>(pass_id: RenderPassId, v
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "remote"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_render_pass_set_stencil_reference(pass_id: RenderPassId, value: u32) {
|
||||
gfx_select!(pass_id => render_pass_set_stencil_reference(pass_id, value))
|
||||
pub extern "C" fn wgpu_render_pass_set_stencil_reference(
|
||||
pass_id: RenderPassId, value: u32
|
||||
) {
|
||||
gfx_select!(pass_id => render_pass_set_stencil_reference(&*GLOBAL, pass_id, value))
|
||||
}
|
||||
|
||||
pub fn render_pass_set_viewport<B: GfxBackend>(
|
||||
global: &Global,
|
||||
pass_id: RenderPassId,
|
||||
x: f32,
|
||||
y: f32,
|
||||
@@ -728,7 +758,7 @@ pub fn render_pass_set_viewport<B: GfxBackend>(
|
||||
min_depth: f32,
|
||||
max_depth: f32,
|
||||
) {
|
||||
let hub = B::hub();
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
let (mut pass_guard, _) = hub.render_passes.write(&mut token);
|
||||
let pass = &mut pass_guard[pass_id];
|
||||
@@ -752,6 +782,7 @@ pub fn render_pass_set_viewport<B: GfxBackend>(
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "remote"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_render_pass_set_viewport(
|
||||
pass_id: RenderPassId,
|
||||
@@ -762,17 +793,18 @@ pub extern "C" fn wgpu_render_pass_set_viewport(
|
||||
min_depth: f32,
|
||||
max_depth: f32,
|
||||
) {
|
||||
gfx_select!(pass_id => render_pass_set_viewport(pass_id, x, y, w, h, min_depth, max_depth))
|
||||
gfx_select!(pass_id => render_pass_set_viewport(&*GLOBAL, pass_id, x, y, w, h, min_depth, max_depth))
|
||||
}
|
||||
|
||||
pub fn render_pass_set_scissor_rect<B: GfxBackend>(
|
||||
global: &Global,
|
||||
pass_id: RenderPassId,
|
||||
x: u32,
|
||||
y: u32,
|
||||
w: u32,
|
||||
h: u32,
|
||||
) {
|
||||
let hub = B::hub();
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
let (mut pass_guard, _) = hub.render_passes.write(&mut token);
|
||||
let pass = &mut pass_guard[pass_id];
|
||||
@@ -793,6 +825,7 @@ pub fn render_pass_set_scissor_rect<B: GfxBackend>(
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "remote"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_render_pass_set_scissor_rect(
|
||||
pass_id: RenderPassId,
|
||||
@@ -801,9 +834,10 @@ pub extern "C" fn wgpu_render_pass_set_scissor_rect(
|
||||
w: u32,
|
||||
h: u32,
|
||||
) {
|
||||
gfx_select!(pass_id => render_pass_set_scissor_rect(pass_id, x, y, w, h))
|
||||
gfx_select!(pass_id => render_pass_set_scissor_rect(&*GLOBAL, pass_id, x, y, w, h))
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "remote"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_render_pass_execute_bundles(
|
||||
_pass_id: RenderPassId,
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
use crate::{
|
||||
conv,
|
||||
device::{all_buffer_stages, all_image_stages},
|
||||
gfx_select,
|
||||
hub::{GfxBackend, Token},
|
||||
hub::{GfxBackend, Global, Token},
|
||||
BufferAddress,
|
||||
BufferId,
|
||||
BufferUsage,
|
||||
@@ -16,6 +15,8 @@ use crate::{
|
||||
TextureId,
|
||||
TextureUsage,
|
||||
};
|
||||
#[cfg(not(feature = "remote"))]
|
||||
use crate::{gfx_select, hub::GLOBAL};
|
||||
|
||||
use hal::command::CommandBuffer as _;
|
||||
|
||||
@@ -65,6 +66,7 @@ impl TextureCopyView {
|
||||
}
|
||||
|
||||
pub fn command_encoder_copy_buffer_to_buffer<B: GfxBackend>(
|
||||
global: &Global,
|
||||
command_encoder_id: CommandEncoderId,
|
||||
source: BufferId,
|
||||
source_offset: BufferAddress,
|
||||
@@ -72,7 +74,7 @@ pub fn command_encoder_copy_buffer_to_buffer<B: GfxBackend>(
|
||||
destination_offset: BufferAddress,
|
||||
size: BufferAddress,
|
||||
) {
|
||||
let hub = B::hub();
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
|
||||
let (mut cmb_guard, mut token) = hub.command_buffers.write(&mut token);
|
||||
@@ -124,6 +126,7 @@ pub fn command_encoder_copy_buffer_to_buffer<B: GfxBackend>(
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "remote"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_command_encoder_copy_buffer_to_buffer(
|
||||
command_encoder_id: CommandEncoderId,
|
||||
@@ -134,6 +137,7 @@ pub extern "C" fn wgpu_command_encoder_copy_buffer_to_buffer(
|
||||
size: BufferAddress,
|
||||
) {
|
||||
gfx_select!(command_encoder_id => command_encoder_copy_buffer_to_buffer(
|
||||
&*GLOBAL,
|
||||
command_encoder_id,
|
||||
source, source_offset,
|
||||
destination,
|
||||
@@ -142,12 +146,13 @@ pub extern "C" fn wgpu_command_encoder_copy_buffer_to_buffer(
|
||||
}
|
||||
|
||||
pub fn command_encoder_copy_buffer_to_texture<B: GfxBackend>(
|
||||
global: &Global,
|
||||
command_encoder_id: CommandEncoderId,
|
||||
source: &BufferCopyView,
|
||||
destination: &TextureCopyView,
|
||||
copy_size: Extent3d,
|
||||
) {
|
||||
let hub = B::hub();
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
let (mut cmb_guard, mut token) = hub.command_buffers.write(&mut token);
|
||||
let cmb = &mut cmb_guard[command_encoder_id];
|
||||
@@ -215,6 +220,7 @@ pub fn command_encoder_copy_buffer_to_texture<B: GfxBackend>(
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "remote"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_command_encoder_copy_buffer_to_texture(
|
||||
command_encoder_id: CommandEncoderId,
|
||||
@@ -223,6 +229,7 @@ pub extern "C" fn wgpu_command_encoder_copy_buffer_to_texture(
|
||||
copy_size: Extent3d,
|
||||
) {
|
||||
gfx_select!(command_encoder_id => command_encoder_copy_buffer_to_texture(
|
||||
&*GLOBAL,
|
||||
command_encoder_id,
|
||||
source,
|
||||
destination,
|
||||
@@ -230,12 +237,13 @@ pub extern "C" fn wgpu_command_encoder_copy_buffer_to_texture(
|
||||
}
|
||||
|
||||
pub fn command_encoder_copy_texture_to_buffer<B: GfxBackend>(
|
||||
global: &Global,
|
||||
command_encoder_id: CommandEncoderId,
|
||||
source: &TextureCopyView,
|
||||
destination: &BufferCopyView,
|
||||
copy_size: Extent3d,
|
||||
) {
|
||||
let hub = B::hub();
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
let (mut cmb_guard, mut token) = hub.command_buffers.write(&mut token);
|
||||
let cmb = &mut cmb_guard[command_encoder_id];
|
||||
@@ -305,6 +313,7 @@ pub fn command_encoder_copy_texture_to_buffer<B: GfxBackend>(
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "remote"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_command_encoder_copy_texture_to_buffer(
|
||||
command_encoder_id: CommandEncoderId,
|
||||
@@ -313,6 +322,7 @@ pub extern "C" fn wgpu_command_encoder_copy_texture_to_buffer(
|
||||
copy_size: Extent3d,
|
||||
) {
|
||||
gfx_select!(command_encoder_id => command_encoder_copy_texture_to_buffer(
|
||||
&*GLOBAL,
|
||||
command_encoder_id,
|
||||
source,
|
||||
destination,
|
||||
@@ -320,12 +330,13 @@ pub extern "C" fn wgpu_command_encoder_copy_texture_to_buffer(
|
||||
}
|
||||
|
||||
pub fn command_encoder_copy_texture_to_texture<B: GfxBackend>(
|
||||
global: &Global,
|
||||
command_encoder_id: CommandEncoderId,
|
||||
source: &TextureCopyView,
|
||||
destination: &TextureCopyView,
|
||||
copy_size: Extent3d,
|
||||
) {
|
||||
let hub = B::hub();
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
|
||||
let (mut cmb_guard, mut token) = hub.command_buffers.write(&mut token);
|
||||
@@ -393,6 +404,7 @@ pub fn command_encoder_copy_texture_to_texture<B: GfxBackend>(
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "remote"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_command_encoder_copy_texture_to_texture(
|
||||
command_encoder_id: CommandEncoderId,
|
||||
@@ -401,6 +413,7 @@ pub extern "C" fn wgpu_command_encoder_copy_texture_to_texture(
|
||||
copy_size: Extent3d,
|
||||
) {
|
||||
gfx_select!(command_encoder_id => command_encoder_copy_texture_to_texture(
|
||||
&*GLOBAL,
|
||||
command_encoder_id,
|
||||
source,
|
||||
destination,
|
||||
|
||||
+110
-73
@@ -10,8 +10,7 @@ use crate::{
|
||||
binding_model,
|
||||
command,
|
||||
conv,
|
||||
gfx_select,
|
||||
hub::{GfxBackend, Token, GLOBAL},
|
||||
hub::{GfxBackend, Global, Token},
|
||||
id::{Input, Output},
|
||||
pipeline,
|
||||
resource,
|
||||
@@ -46,6 +45,8 @@ use crate::{
|
||||
TextureUsage,
|
||||
TextureViewId,
|
||||
};
|
||||
#[cfg(not(feature = "remote"))]
|
||||
use crate::{gfx_select, hub::GLOBAL};
|
||||
|
||||
use arrayvec::ArrayVec;
|
||||
use copyless::VecHelper as _;
|
||||
@@ -275,7 +276,9 @@ impl<B: GfxBackend> PendingResources<B> {
|
||||
last_done
|
||||
}
|
||||
|
||||
fn triage_referenced(&mut self, trackers: &mut TrackerSet, mut token: &mut Token<Device<B>>) {
|
||||
fn triage_referenced(
|
||||
&mut self, global: &Global, trackers: &mut TrackerSet, mut token: &mut Token<Device<B>>
|
||||
) {
|
||||
// Before destruction, a resource is expected to have the following strong refs:
|
||||
// - in resource itself
|
||||
// - in the device tracker
|
||||
@@ -286,7 +289,7 @@ impl<B: GfxBackend> PendingResources<B> {
|
||||
return;
|
||||
}
|
||||
|
||||
let hub = B::hub();
|
||||
let hub = B::hub(global);
|
||||
//TODO: lock less, if possible
|
||||
let (mut bind_group_guard, mut token) = hub.bind_groups.write(&mut token);
|
||||
let (mut buffer_guard, mut token) = hub.buffers.write(&mut token);
|
||||
@@ -362,11 +365,11 @@ impl<B: GfxBackend> PendingResources<B> {
|
||||
}
|
||||
}
|
||||
|
||||
fn triage_mapped(&mut self, token: &mut Token<Device<B>>) {
|
||||
fn triage_mapped(&mut self, global: &Global, token: &mut Token<Device<B>>) {
|
||||
if self.mapped.is_empty() {
|
||||
return;
|
||||
}
|
||||
let (buffer_guard, _) = B::hub().buffers.read(token);
|
||||
let (buffer_guard, _) = B::hub(global).buffers.read(token);
|
||||
|
||||
for stored in self.mapped.drain(..) {
|
||||
let resource_id = stored.value;
|
||||
@@ -390,10 +393,11 @@ impl<B: GfxBackend> PendingResources<B> {
|
||||
|
||||
fn triage_framebuffers(
|
||||
&mut self,
|
||||
global: &Global,
|
||||
framebuffers: &mut FastHashMap<FramebufferKey, B::Framebuffer>,
|
||||
token: &mut Token<Device<B>>,
|
||||
) {
|
||||
let (texture_view_guard, _) = B::hub().texture_views.read(token);
|
||||
let (texture_view_guard, _) = B::hub(global).texture_views.read(token);
|
||||
let remove_list = framebuffers
|
||||
.keys()
|
||||
.filter_map(|key| {
|
||||
@@ -428,13 +432,14 @@ impl<B: GfxBackend> PendingResources<B> {
|
||||
|
||||
fn handle_mapping(
|
||||
&mut self,
|
||||
global: &Global,
|
||||
raw: &B::Device,
|
||||
token: &mut Token<Device<B>>,
|
||||
) -> Vec<BufferMapPendingCallback> {
|
||||
if self.ready_to_map.is_empty() {
|
||||
return Vec::new();
|
||||
}
|
||||
let (mut buffer_guard, _) = B::hub().buffers.write(token);
|
||||
let (mut buffer_guard, _) = B::hub(global).buffers.write(token);
|
||||
self.ready_to_map
|
||||
.drain(..)
|
||||
.map(|buffer_id| {
|
||||
@@ -566,20 +571,20 @@ impl<B: GfxBackend> Device<B> {
|
||||
}
|
||||
}
|
||||
|
||||
fn maintain(&self, force_wait: bool, token: &mut Token<Self>) -> Vec<BufferMapPendingCallback> {
|
||||
fn maintain(&self, global: &Global, force_wait: bool, token: &mut Token<Self>) -> Vec<BufferMapPendingCallback> {
|
||||
let mut pending = self.pending.lock();
|
||||
let mut trackers = self.trackers.lock();
|
||||
|
||||
pending.triage_referenced(&mut *trackers, token);
|
||||
pending.triage_mapped(token);
|
||||
pending.triage_framebuffers(&mut *self.framebuffers.lock(), token);
|
||||
pending.triage_referenced(global, &mut *trackers, token);
|
||||
pending.triage_mapped(global, token);
|
||||
pending.triage_framebuffers(global, &mut *self.framebuffers.lock(), token);
|
||||
let last_done = pending.cleanup(
|
||||
&self.raw,
|
||||
&self.mem_allocator,
|
||||
&self.desc_allocator,
|
||||
force_wait,
|
||||
);
|
||||
let callbacks = pending.handle_mapping(&self.raw, token);
|
||||
let callbacks = pending.handle_mapping(global, &self.raw, token);
|
||||
|
||||
unsafe {
|
||||
self.desc_allocator.lock().cleanup(&self.raw);
|
||||
@@ -767,11 +772,12 @@ pub struct ShaderModule<B: hal::Backend> {
|
||||
}
|
||||
|
||||
pub fn device_create_buffer<B: GfxBackend>(
|
||||
global: &Global,
|
||||
device_id: DeviceId,
|
||||
desc: &resource::BufferDescriptor,
|
||||
id_in: Input<BufferId>,
|
||||
) -> Output<BufferId> {
|
||||
let hub = B::hub();
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
|
||||
let (device_guard, _) = hub.devices.read(&mut token);
|
||||
@@ -797,16 +803,17 @@ pub extern "C" fn wgpu_device_create_buffer(
|
||||
device_id: DeviceId,
|
||||
desc: &resource::BufferDescriptor,
|
||||
) -> BufferId {
|
||||
gfx_select!(device_id => device_create_buffer(device_id, desc, PhantomData))
|
||||
gfx_select!(device_id => device_create_buffer(&*GLOBAL, device_id, desc, PhantomData))
|
||||
}
|
||||
|
||||
pub fn device_create_buffer_mapped<B: GfxBackend>(
|
||||
global: &Global,
|
||||
device_id: DeviceId,
|
||||
desc: &resource::BufferDescriptor,
|
||||
mapped_ptr_out: *mut *mut u8,
|
||||
id_in: Input<BufferId>,
|
||||
) -> Output<BufferId> {
|
||||
let hub = B::hub();
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
let mut desc = desc.clone();
|
||||
desc.usage |= resource::BufferUsage::MAP_WRITE;
|
||||
@@ -847,11 +854,11 @@ pub extern "C" fn wgpu_device_create_buffer_mapped(
|
||||
desc: &resource::BufferDescriptor,
|
||||
mapped_ptr_out: *mut *mut u8,
|
||||
) -> BufferId {
|
||||
gfx_select!(device_id => device_create_buffer_mapped(device_id, desc, mapped_ptr_out, PhantomData))
|
||||
gfx_select!(device_id => device_create_buffer_mapped(&*GLOBAL, device_id, desc, mapped_ptr_out, PhantomData))
|
||||
}
|
||||
|
||||
pub fn buffer_destroy<B: GfxBackend>(buffer_id: BufferId) {
|
||||
let hub = B::hub();
|
||||
pub fn buffer_destroy<B: GfxBackend>(global: &Global, buffer_id: BufferId) {
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
let (device_guard, mut token) = hub.devices.read(&mut token);
|
||||
let (buffer_guard, _) = hub.buffers.read(&mut token);
|
||||
@@ -862,17 +869,19 @@ pub fn buffer_destroy<B: GfxBackend>(buffer_id: BufferId) {
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "remote"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_buffer_destroy(buffer_id: BufferId) {
|
||||
gfx_select!(buffer_id => buffer_destroy(buffer_id))
|
||||
gfx_select!(buffer_id => buffer_destroy(&*GLOBAL, buffer_id))
|
||||
}
|
||||
|
||||
pub fn device_create_texture<B: GfxBackend>(
|
||||
global: &Global,
|
||||
device_id: DeviceId,
|
||||
desc: &resource::TextureDescriptor,
|
||||
id_in: Input<TextureId>,
|
||||
) -> Output<TextureId> {
|
||||
let hub = B::hub();
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
|
||||
let (device_guard, _) = hub.devices.read(&mut token);
|
||||
@@ -898,15 +907,16 @@ pub extern "C" fn wgpu_device_create_texture(
|
||||
device_id: DeviceId,
|
||||
desc: &resource::TextureDescriptor,
|
||||
) -> TextureId {
|
||||
gfx_select!(device_id => device_create_texture(device_id, desc, PhantomData))
|
||||
gfx_select!(device_id => device_create_texture(&*GLOBAL, device_id, desc, PhantomData))
|
||||
}
|
||||
|
||||
pub fn texture_create_view<B: GfxBackend>(
|
||||
global: &Global,
|
||||
texture_id: TextureId,
|
||||
desc: Option<&resource::TextureViewDescriptor>,
|
||||
id_in: Input<TextureViewId>,
|
||||
) -> Output<TextureViewId> {
|
||||
let hub = B::hub();
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
|
||||
let (device_guard, mut token) = hub.devices.read(&mut token);
|
||||
@@ -996,11 +1006,11 @@ pub extern "C" fn wgpu_texture_create_view(
|
||||
texture_id: TextureId,
|
||||
desc: Option<&resource::TextureViewDescriptor>,
|
||||
) -> TextureViewId {
|
||||
gfx_select!(texture_id => texture_create_view(texture_id, desc, PhantomData))
|
||||
gfx_select!(texture_id => texture_create_view(&*GLOBAL, texture_id, desc, PhantomData))
|
||||
}
|
||||
|
||||
pub fn texture_destroy<B: GfxBackend>(texture_id: TextureId) {
|
||||
let hub = B::hub();
|
||||
pub fn texture_destroy<B: GfxBackend>(global: &Global, texture_id: TextureId) {
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
|
||||
let (device_guard, mut token) = hub.devices.read(&mut token);
|
||||
@@ -1015,13 +1025,16 @@ pub fn texture_destroy<B: GfxBackend>(texture_id: TextureId) {
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "remote"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_texture_destroy(texture_id: TextureId) {
|
||||
gfx_select!(texture_id => texture_destroy(texture_id))
|
||||
gfx_select!(texture_id => texture_destroy(&*GLOBAL, texture_id))
|
||||
}
|
||||
|
||||
pub fn texture_view_destroy<B: GfxBackend>(texture_view_id: TextureViewId) {
|
||||
let hub = B::hub();
|
||||
pub fn texture_view_destroy<B: GfxBackend>(
|
||||
global: &Global, texture_view_id: TextureViewId
|
||||
) {
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
let (device_guard, mut token) = hub.devices.read(&mut token);
|
||||
let (texture_guard, mut token) = hub.textures.read(&mut token);
|
||||
@@ -1039,17 +1052,19 @@ pub fn texture_view_destroy<B: GfxBackend>(texture_view_id: TextureViewId) {
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "remote"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_texture_view_destroy(texture_view_id: TextureViewId) {
|
||||
gfx_select!(texture_view_id => texture_view_destroy(texture_view_id))
|
||||
gfx_select!(texture_view_id => texture_view_destroy(&*GLOBAL, texture_view_id))
|
||||
}
|
||||
|
||||
pub fn device_create_sampler<B: GfxBackend>(
|
||||
global: &Global,
|
||||
device_id: DeviceId,
|
||||
desc: &resource::SamplerDescriptor,
|
||||
id_in: Input<SamplerId>,
|
||||
) -> Output<SamplerId> {
|
||||
let hub = B::hub();
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
let (device_guard, mut token) = hub.devices.read(&mut token);
|
||||
let device = &device_guard[device_id];
|
||||
@@ -1092,11 +1107,11 @@ pub extern "C" fn wgpu_device_create_sampler(
|
||||
device_id: DeviceId,
|
||||
desc: &resource::SamplerDescriptor,
|
||||
) -> SamplerId {
|
||||
gfx_select!(device_id => device_create_sampler(device_id, desc, PhantomData))
|
||||
gfx_select!(device_id => device_create_sampler(&*GLOBAL, device_id, desc, PhantomData))
|
||||
}
|
||||
|
||||
pub fn sampler_destroy<B: GfxBackend>(sampler_id: SamplerId) {
|
||||
let hub = B::hub();
|
||||
pub fn sampler_destroy<B: GfxBackend>(global: &Global, sampler_id: SamplerId) {
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
let (device_guard, mut token) = hub.devices.read(&mut token);
|
||||
let (sampler_guard, _) = hub.samplers.read(&mut token);
|
||||
@@ -1110,18 +1125,20 @@ pub fn sampler_destroy<B: GfxBackend>(sampler_id: SamplerId) {
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "remote"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_sampler_destroy(sampler_id: SamplerId) {
|
||||
gfx_select!(sampler_id => sampler_destroy(sampler_id))
|
||||
gfx_select!(sampler_id => sampler_destroy(&*GLOBAL, sampler_id))
|
||||
}
|
||||
|
||||
pub fn device_create_bind_group_layout<B: GfxBackend>(
|
||||
global: &Global,
|
||||
device_id: DeviceId,
|
||||
desc: &binding_model::BindGroupLayoutDescriptor,
|
||||
id_in: Input<BindGroupLayoutId>,
|
||||
) -> Output<BindGroupLayoutId> {
|
||||
let mut token = Token::root();
|
||||
let hub = B::hub();
|
||||
let hub = B::hub(global);
|
||||
let bindings = unsafe { slice::from_raw_parts(desc.bindings, desc.bindings_length) };
|
||||
|
||||
let raw_bindings = bindings
|
||||
@@ -1160,15 +1177,16 @@ pub extern "C" fn wgpu_device_create_bind_group_layout(
|
||||
device_id: DeviceId,
|
||||
desc: &binding_model::BindGroupLayoutDescriptor,
|
||||
) -> BindGroupLayoutId {
|
||||
gfx_select!(device_id => device_create_bind_group_layout(device_id, desc, PhantomData))
|
||||
gfx_select!(device_id => device_create_bind_group_layout(&*GLOBAL, device_id, desc, PhantomData))
|
||||
}
|
||||
|
||||
pub fn device_create_pipeline_layout<B: GfxBackend>(
|
||||
global: &Global,
|
||||
device_id: DeviceId,
|
||||
desc: &binding_model::PipelineLayoutDescriptor,
|
||||
id_in: Input<PipelineLayoutId>,
|
||||
) -> Output<PipelineLayoutId> {
|
||||
let hub = B::hub();
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
|
||||
let (device_guard, mut token) = hub.devices.read(&mut token);
|
||||
@@ -1203,15 +1221,16 @@ pub extern "C" fn wgpu_device_create_pipeline_layout(
|
||||
device_id: DeviceId,
|
||||
desc: &binding_model::PipelineLayoutDescriptor,
|
||||
) -> PipelineLayoutId {
|
||||
gfx_select!(device_id => device_create_pipeline_layout(device_id, desc, PhantomData))
|
||||
gfx_select!(device_id => device_create_pipeline_layout(&*GLOBAL, device_id, desc, PhantomData))
|
||||
}
|
||||
|
||||
pub fn device_create_bind_group<B: GfxBackend>(
|
||||
global: &Global,
|
||||
device_id: DeviceId,
|
||||
desc: &binding_model::BindGroupDescriptor,
|
||||
id_in: Input<BindGroupId>,
|
||||
) -> Output<BindGroupId> {
|
||||
let hub = B::hub();
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
|
||||
let (device_guard, mut token) = hub.devices.read(&mut token);
|
||||
@@ -1377,11 +1396,11 @@ pub extern "C" fn wgpu_device_create_bind_group(
|
||||
device_id: DeviceId,
|
||||
desc: &binding_model::BindGroupDescriptor,
|
||||
) -> BindGroupId {
|
||||
gfx_select!(device_id => device_create_bind_group(device_id, desc, PhantomData))
|
||||
gfx_select!(device_id => device_create_bind_group(&*GLOBAL, device_id, desc, PhantomData))
|
||||
}
|
||||
|
||||
pub fn bind_group_destroy<B: GfxBackend>(bind_group_id: BindGroupId) {
|
||||
let hub = B::hub();
|
||||
pub fn bind_group_destroy<B: GfxBackend>(global: &Global, bind_group_id: BindGroupId) {
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
let (device_guard, mut token) = hub.devices.read(&mut token);
|
||||
let (bind_group_guard, _) = hub.bind_groups.read(&mut token);
|
||||
@@ -1395,17 +1414,19 @@ pub fn bind_group_destroy<B: GfxBackend>(bind_group_id: BindGroupId) {
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "remote"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_bind_group_destroy(bind_group_id: BindGroupId) {
|
||||
gfx_select!(bind_group_id => bind_group_destroy(bind_group_id))
|
||||
gfx_select!(bind_group_id => bind_group_destroy(&*GLOBAL, bind_group_id))
|
||||
}
|
||||
|
||||
pub fn device_create_shader_module<B: GfxBackend>(
|
||||
global: &Global,
|
||||
device_id: DeviceId,
|
||||
desc: &pipeline::ShaderModuleDescriptor,
|
||||
id_in: Input<ShaderModuleId>,
|
||||
) -> Output<ShaderModuleId> {
|
||||
let hub = B::hub();
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
|
||||
let spv = unsafe { slice::from_raw_parts(desc.code.bytes, desc.code.length) };
|
||||
@@ -1430,15 +1451,16 @@ pub extern "C" fn wgpu_device_create_shader_module(
|
||||
device_id: DeviceId,
|
||||
desc: &pipeline::ShaderModuleDescriptor,
|
||||
) -> ShaderModuleId {
|
||||
gfx_select!(device_id => device_create_shader_module(device_id, desc, PhantomData))
|
||||
gfx_select!(device_id => device_create_shader_module(&*GLOBAL, device_id, desc, PhantomData))
|
||||
}
|
||||
|
||||
pub fn device_create_command_encoder<B: GfxBackend>(
|
||||
global: &Global,
|
||||
device_id: DeviceId,
|
||||
_desc: &command::CommandEncoderDescriptor,
|
||||
id_in: Input<CommandEncoderId>,
|
||||
) -> Output<CommandEncoderId> {
|
||||
let hub = B::hub();
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
|
||||
let (device_guard, mut token) = hub.devices.read(&mut token);
|
||||
@@ -1467,16 +1489,21 @@ pub extern "C" fn wgpu_device_create_command_encoder(
|
||||
desc: Option<&command::CommandEncoderDescriptor>,
|
||||
) -> CommandEncoderId {
|
||||
let desc = &desc.cloned().unwrap_or_default();
|
||||
gfx_select!(device_id => device_create_command_encoder(device_id, desc, PhantomData))
|
||||
gfx_select!(device_id => device_create_command_encoder(&*GLOBAL, device_id, desc, PhantomData))
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "remote"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_device_get_queue(device_id: DeviceId) -> QueueId {
|
||||
device_id
|
||||
}
|
||||
|
||||
pub fn queue_submit<B: GfxBackend>(queue_id: QueueId, command_buffer_ids: &[CommandBufferId]) {
|
||||
let hub = B::hub();
|
||||
pub fn queue_submit<B: GfxBackend>(
|
||||
global: &Global,
|
||||
queue_id: QueueId,
|
||||
command_buffer_ids: &[CommandBufferId],
|
||||
) {
|
||||
let hub = B::hub(global);
|
||||
|
||||
let (submit_index, fence) = {
|
||||
let mut token = Token::root();
|
||||
@@ -1607,7 +1634,7 @@ pub fn queue_submit<B: GfxBackend>(queue_id: QueueId, command_buffer_ids: &[Comm
|
||||
let (device_guard, mut token) = hub.devices.read(&mut token);
|
||||
let device = &device_guard[queue_id];
|
||||
|
||||
let callbacks = device.maintain(false, &mut token);
|
||||
let callbacks = device.maintain(global, false, &mut token);
|
||||
device.pending.lock().active.alloc().init(ActiveSubmission {
|
||||
index: submit_index,
|
||||
fence,
|
||||
@@ -1627,6 +1654,7 @@ pub fn queue_submit<B: GfxBackend>(queue_id: QueueId, command_buffer_ids: &[Comm
|
||||
Device::<B>::fire_map_callbacks(callbacks);
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "remote"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_queue_submit(
|
||||
queue_id: QueueId,
|
||||
@@ -1635,15 +1663,16 @@ pub extern "C" fn wgpu_queue_submit(
|
||||
) {
|
||||
let command_buffer_ids =
|
||||
unsafe { slice::from_raw_parts(command_buffers, command_buffers_length) };
|
||||
gfx_select!(queue_id => queue_submit(queue_id, command_buffer_ids))
|
||||
gfx_select!(queue_id => queue_submit(&*GLOBAL, queue_id, command_buffer_ids))
|
||||
}
|
||||
|
||||
pub fn device_create_render_pipeline<B: GfxBackend>(
|
||||
global: &Global,
|
||||
device_id: DeviceId,
|
||||
desc: &pipeline::RenderPipelineDescriptor,
|
||||
id_in: Input<RenderPipelineId>,
|
||||
) -> Output<RenderPipelineId> {
|
||||
let hub = B::hub();
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
|
||||
let sc = desc.sample_count;
|
||||
@@ -1904,15 +1933,16 @@ pub extern "C" fn wgpu_device_create_render_pipeline(
|
||||
device_id: DeviceId,
|
||||
desc: &pipeline::RenderPipelineDescriptor,
|
||||
) -> RenderPipelineId {
|
||||
gfx_select!(device_id => device_create_render_pipeline(device_id, desc, PhantomData))
|
||||
gfx_select!(device_id => device_create_render_pipeline(&*GLOBAL, device_id, desc, PhantomData))
|
||||
}
|
||||
|
||||
pub fn device_create_compute_pipeline<B: GfxBackend>(
|
||||
global: &Global,
|
||||
device_id: DeviceId,
|
||||
desc: &pipeline::ComputePipelineDescriptor,
|
||||
id_in: Input<ComputePipelineId>,
|
||||
) -> Output<ComputePipelineId> {
|
||||
let hub = B::hub();
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
|
||||
let raw_pipeline = {
|
||||
@@ -1965,19 +1995,20 @@ pub extern "C" fn wgpu_device_create_compute_pipeline(
|
||||
device_id: DeviceId,
|
||||
desc: &pipeline::ComputePipelineDescriptor,
|
||||
) -> ComputePipelineId {
|
||||
gfx_select!(device_id => device_create_compute_pipeline(device_id, desc, PhantomData))
|
||||
gfx_select!(device_id => device_create_compute_pipeline(&*GLOBAL, device_id, desc, PhantomData))
|
||||
}
|
||||
|
||||
pub fn device_create_swap_chain<B: GfxBackend>(
|
||||
global: &Global,
|
||||
device_id: DeviceId,
|
||||
surface_id: SurfaceId,
|
||||
desc: &swap_chain::SwapChainDescriptor,
|
||||
) -> SwapChainId {
|
||||
log::info!("creating swap chain {:?}", desc);
|
||||
let hub = B::hub();
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
|
||||
let (mut surface_guard, mut token) = GLOBAL.surfaces.write(&mut token);
|
||||
let (mut surface_guard, mut token) = global.surfaces.write(&mut token);
|
||||
let (adapter_guard, mut token) = hub.adapters.read(&mut token);
|
||||
let (device_guard, mut token) = hub.devices.read(&mut token);
|
||||
let (mut swap_chain_guard, _) = hub.swap_chains.write(&mut token);
|
||||
@@ -2046,33 +2077,35 @@ pub extern "C" fn wgpu_device_create_swap_chain(
|
||||
surface_id: SurfaceId,
|
||||
desc: &swap_chain::SwapChainDescriptor,
|
||||
) -> SwapChainId {
|
||||
gfx_select!(device_id => device_create_swap_chain(device_id, surface_id, desc))
|
||||
gfx_select!(device_id => device_create_swap_chain(&*GLOBAL, device_id, surface_id, desc))
|
||||
}
|
||||
|
||||
pub fn device_poll<B: GfxBackend>(device_id: DeviceId, force_wait: bool) {
|
||||
let hub = B::hub();
|
||||
pub fn device_poll<B: GfxBackend>(global: &Global, device_id: DeviceId, force_wait: bool) {
|
||||
let hub = B::hub(global);
|
||||
let callbacks = {
|
||||
let (device_guard, mut token) = hub.devices.read(&mut Token::root());
|
||||
device_guard[device_id].maintain(force_wait, &mut token)
|
||||
device_guard[device_id].maintain(global, force_wait, &mut token)
|
||||
};
|
||||
Device::<B>::fire_map_callbacks(callbacks);
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "remote"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_device_poll(device_id: DeviceId, force_wait: bool) {
|
||||
gfx_select!(device_id => device_poll(device_id, force_wait))
|
||||
gfx_select!(device_id => device_poll(&*GLOBAL, device_id, force_wait))
|
||||
}
|
||||
|
||||
pub fn device_destroy<B: GfxBackend>(device_id: DeviceId) {
|
||||
let hub = B::hub();
|
||||
pub fn device_destroy<B: GfxBackend>(global: &Global, device_id: DeviceId) {
|
||||
let hub = B::hub(global);
|
||||
let (device, mut token) = hub.devices.unregister(device_id, &mut Token::root());
|
||||
device.maintain(true, &mut token);
|
||||
device.maintain(global, true, &mut token);
|
||||
device.com_allocator.destroy(&device.raw);
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "remote"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_device_destroy(device_id: DeviceId) {
|
||||
gfx_select!(device_id => device_destroy(device_id))
|
||||
gfx_select!(device_id => device_destroy(&*GLOBAL, device_id))
|
||||
}
|
||||
|
||||
pub type BufferMapReadCallback =
|
||||
@@ -2081,11 +2114,12 @@ pub type BufferMapWriteCallback =
|
||||
extern "C" fn(status: BufferMapAsyncStatus, data: *mut u8, userdata: *mut u8);
|
||||
|
||||
pub fn buffer_map_async<B: GfxBackend>(
|
||||
global: &Global,
|
||||
buffer_id: BufferId,
|
||||
usage: resource::BufferUsage,
|
||||
operation: BufferMapOperation,
|
||||
) {
|
||||
let hub = B::hub();
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
let (device_guard, mut token) = hub.devices.read(&mut token);
|
||||
|
||||
@@ -2121,6 +2155,7 @@ pub fn buffer_map_async<B: GfxBackend>(
|
||||
device.pending.lock().map(buffer_id, ref_count);
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "remote"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_buffer_map_read_async(
|
||||
buffer_id: BufferId,
|
||||
@@ -2130,9 +2165,10 @@ pub extern "C" fn wgpu_buffer_map_read_async(
|
||||
userdata: *mut u8,
|
||||
) {
|
||||
let operation = BufferMapOperation::Read(start .. start + size, callback, userdata);
|
||||
gfx_select!(buffer_id => buffer_map_async(buffer_id, resource::BufferUsage::MAP_READ, operation))
|
||||
gfx_select!(buffer_id => buffer_map_async(&*GLOBAL, buffer_id, resource::BufferUsage::MAP_READ, operation))
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "remote"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_buffer_map_write_async(
|
||||
buffer_id: BufferId,
|
||||
@@ -2142,11 +2178,11 @@ pub extern "C" fn wgpu_buffer_map_write_async(
|
||||
userdata: *mut u8,
|
||||
) {
|
||||
let operation = BufferMapOperation::Write(start .. start + size, callback, userdata);
|
||||
gfx_select!(buffer_id => buffer_map_async(buffer_id, resource::BufferUsage::MAP_WRITE, operation))
|
||||
gfx_select!(buffer_id => buffer_map_async(&*GLOBAL, buffer_id, resource::BufferUsage::MAP_WRITE, operation))
|
||||
}
|
||||
|
||||
pub fn buffer_unmap<B: GfxBackend>(buffer_id: BufferId) {
|
||||
let hub = B::hub();
|
||||
pub fn buffer_unmap<B: GfxBackend>(global: &Global, buffer_id: BufferId) {
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
|
||||
let (device_guard, mut token) = hub.devices.read(&mut token);
|
||||
@@ -2172,7 +2208,8 @@ pub fn buffer_unmap<B: GfxBackend>(buffer_id: BufferId) {
|
||||
buffer.memory.unmap(device_raw);
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "remote"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_buffer_unmap(buffer_id: BufferId) {
|
||||
gfx_select!(buffer_id => buffer_unmap(buffer_id))
|
||||
gfx_select!(buffer_id => buffer_unmap(&*GLOBAL, buffer_id))
|
||||
}
|
||||
+15
-13
@@ -46,15 +46,16 @@ use crate::{
|
||||
TypedId,
|
||||
};
|
||||
|
||||
use lazy_static::lazy_static;
|
||||
#[cfg(not(feature = "remote"))]
|
||||
use parking_lot::Mutex;
|
||||
use parking_lot::{RwLock, RwLockReadGuard, RwLockWriteGuard};
|
||||
use vec_map::VecMap;
|
||||
|
||||
#[allow(unused)]
|
||||
#[cfg(debug_assertions)]
|
||||
use std::cell::Cell;
|
||||
use std::{marker::PhantomData, ops, sync::Arc};
|
||||
#[cfg(not(feature = "remote"))]
|
||||
use std::sync::Arc;
|
||||
use std::{marker::PhantomData, ops};
|
||||
|
||||
|
||||
/// A simple structure to manage identities of objects.
|
||||
@@ -406,7 +407,8 @@ pub struct Global {
|
||||
hubs: Hubs,
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
#[cfg(not(feature = "remote"))]
|
||||
lazy_static::lazy_static! {
|
||||
pub static ref GLOBAL: Arc<Global> = Arc::new(Global {
|
||||
instance: Instance::new("wgpu", 1),
|
||||
surfaces: Registry::new(Backend::Empty),
|
||||
@@ -416,15 +418,15 @@ lazy_static! {
|
||||
|
||||
pub trait GfxBackend: hal::Backend {
|
||||
const VARIANT: Backend;
|
||||
fn hub() -> &'static Hub<Self>;
|
||||
fn hub(global: &Global) -> &Hub<Self>;
|
||||
fn get_surface_mut(surface: &mut Surface) -> &mut Self::Surface;
|
||||
}
|
||||
|
||||
#[cfg(any(not(any(target_os = "ios", target_os = "macos")), feature = "gfx-backend-vulkan"))]
|
||||
impl GfxBackend for backend::Vulkan {
|
||||
const VARIANT: Backend = Backend::Vulkan;
|
||||
fn hub() -> &'static Hub<Self> {
|
||||
&GLOBAL.hubs.vulkan
|
||||
fn hub(global: &Global) -> &Hub<Self> {
|
||||
&global.hubs.vulkan
|
||||
}
|
||||
fn get_surface_mut(surface: &mut Surface) -> &mut Self::Surface {
|
||||
surface.vulkan.as_mut().unwrap()
|
||||
@@ -434,8 +436,8 @@ impl GfxBackend for backend::Vulkan {
|
||||
#[cfg(any(target_os = "ios", target_os = "macos"))]
|
||||
impl GfxBackend for backend::Metal {
|
||||
const VARIANT: Backend = Backend::Metal;
|
||||
fn hub() -> &'static Hub<Self> {
|
||||
&GLOBAL.hubs.metal
|
||||
fn hub(global: &Global) -> &Hub<Self> {
|
||||
&global.hubs.metal
|
||||
}
|
||||
fn get_surface_mut(surface: &mut Surface) -> &mut Self::Surface {
|
||||
&mut surface.metal
|
||||
@@ -445,8 +447,8 @@ impl GfxBackend for backend::Metal {
|
||||
#[cfg(windows)]
|
||||
impl GfxBackend for backend::Dx12 {
|
||||
const VARIANT: Backend = Backend::Dx12;
|
||||
fn hub() -> &'static Hub<Self> {
|
||||
&GLOBAL.hubs.dx12
|
||||
fn hub(global: &Global) -> &Hub<Self> {
|
||||
&global.hubs.dx12
|
||||
}
|
||||
fn get_surface_mut(surface: &mut Surface) -> &mut Self::Surface {
|
||||
surface.dx12.as_mut().unwrap()
|
||||
@@ -456,8 +458,8 @@ impl GfxBackend for backend::Dx12 {
|
||||
#[cfg(windows)]
|
||||
impl GfxBackend for backend::Dx11 {
|
||||
const VARIANT: Backend = Backend::Dx11;
|
||||
fn hub() -> &'static Hub<Self> {
|
||||
&GLOBAL.hubs.dx11
|
||||
fn hub(global: &Global) -> &Hub<Self> {
|
||||
&global.hubs.dx11
|
||||
}
|
||||
fn get_surface_mut(surface: &mut Surface) -> &mut Self::Surface {
|
||||
&mut surface.dx11
|
||||
|
||||
+16
-14
@@ -6,7 +6,7 @@ use crate::{
|
||||
backend,
|
||||
binding_model::MAX_BIND_GROUPS,
|
||||
device::BIND_BUFFER_ALIGNMENT,
|
||||
hub::{GfxBackend, Token, GLOBAL},
|
||||
hub::{GfxBackend, Global, Token},
|
||||
id::{Input, Output},
|
||||
AdapterId,
|
||||
AdapterInfo,
|
||||
@@ -15,7 +15,7 @@ use crate::{
|
||||
DeviceId,
|
||||
};
|
||||
#[cfg(not(feature = "remote"))]
|
||||
use crate::{gfx_select, SurfaceId};
|
||||
use crate::{gfx_select, SurfaceId, hub::GLOBAL};
|
||||
|
||||
#[cfg(not(feature = "remote"))]
|
||||
use bitflags::bitflags;
|
||||
@@ -46,7 +46,7 @@ pub struct Instance {
|
||||
}
|
||||
|
||||
impl Instance {
|
||||
pub(crate) fn new(name: &str, version: u32) -> Self {
|
||||
pub fn new(name: &str, version: u32) -> Self {
|
||||
Instance {
|
||||
#[cfg(any(not(any(target_os = "ios", target_os = "macos")), feature = "gfx-backend-vulkan"))]
|
||||
vulkan: gfx_backend_vulkan::Instance::create(name, version).ok(),
|
||||
@@ -267,10 +267,11 @@ pub extern "C" fn wgpu_create_surface_from_windows_hwnd(
|
||||
}
|
||||
|
||||
pub fn request_adapter(
|
||||
global: &Global,
|
||||
desc: &RequestAdapterOptions,
|
||||
input_ids: &[Input<AdapterId>],
|
||||
) -> Option<AdapterId> {
|
||||
let instance = &GLOBAL.instance;
|
||||
let instance = &global.instance;
|
||||
let mut device_types = Vec::new();
|
||||
|
||||
#[cfg(feature = "remote")]
|
||||
@@ -367,7 +368,7 @@ pub fn request_adapter(
|
||||
raw: adapters_vk.swap_remove(selected),
|
||||
};
|
||||
info!("Adapter Vulkan {:?}", adapter.raw.info);
|
||||
let id_out = backend::Vulkan::hub().adapters.register_identity(
|
||||
let id_out = backend::Vulkan::hub(global).adapters.register_identity(
|
||||
id_vulkan.unwrap(),
|
||||
adapter,
|
||||
&mut token,
|
||||
@@ -383,7 +384,7 @@ pub fn request_adapter(
|
||||
raw: adapters_mtl.swap_remove(selected),
|
||||
};
|
||||
info!("Adapter Metal {:?}", adapter.raw.info);
|
||||
let id_out = backend::Metal::hub().adapters.register_identity(
|
||||
let id_out = backend::Metal::hub(global).adapters.register_identity(
|
||||
id_metal.unwrap(),
|
||||
adapter,
|
||||
&mut token,
|
||||
@@ -399,7 +400,7 @@ pub fn request_adapter(
|
||||
raw: adapters_dx12.swap_remove(selected),
|
||||
};
|
||||
info!("Adapter Dx12 {:?}", adapter.raw.info);
|
||||
let id_out = backend::Dx12::hub().adapters.register_identity(
|
||||
let id_out = backend::Dx12::hub(global).adapters.register_identity(
|
||||
id_dx12.unwrap(),
|
||||
adapter,
|
||||
&mut token,
|
||||
@@ -412,7 +413,7 @@ pub fn request_adapter(
|
||||
raw: adapters_dx11.swap_remove(selected),
|
||||
};
|
||||
info!("Adapter Dx11 {:?}", adapter.raw.info);
|
||||
let id_out = backend::Dx11::hub().adapters.register_identity(
|
||||
let id_out = backend::Dx11::hub(global).adapters.register_identity(
|
||||
id_dx11.unwrap(),
|
||||
adapter,
|
||||
&mut token,
|
||||
@@ -428,15 +429,16 @@ pub fn request_adapter(
|
||||
#[cfg(not(feature = "remote"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_request_adapter(desc: Option<&RequestAdapterOptions>) -> AdapterId {
|
||||
request_adapter(&desc.cloned().unwrap_or_default(), &[]).unwrap()
|
||||
request_adapter(&*GLOBAL, &desc.cloned().unwrap_or_default(), &[]).unwrap()
|
||||
}
|
||||
|
||||
pub fn adapter_request_device<B: GfxBackend>(
|
||||
global: &Global,
|
||||
adapter_id: AdapterId,
|
||||
desc: &DeviceDescriptor,
|
||||
id_in: Input<DeviceId>,
|
||||
) -> Output<DeviceId> {
|
||||
let hub = B::hub();
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
let device = {
|
||||
let (adapter_guard, _) = hub.adapters.read(&mut token);
|
||||
@@ -503,11 +505,11 @@ pub extern "C" fn wgpu_adapter_request_device(
|
||||
desc: Option<&DeviceDescriptor>,
|
||||
) -> DeviceId {
|
||||
let desc = &desc.cloned().unwrap_or_default();
|
||||
gfx_select!(adapter_id => adapter_request_device(adapter_id, desc, PhantomData))
|
||||
gfx_select!(adapter_id => adapter_request_device(&*GLOBAL, adapter_id, desc, PhantomData))
|
||||
}
|
||||
|
||||
pub fn adapter_get_info<B: GfxBackend>(adapter_id: AdapterId) -> AdapterInfo {
|
||||
let hub = B::hub();
|
||||
pub fn adapter_get_info<B: GfxBackend>(global: &Global, adapter_id: AdapterId) -> AdapterInfo {
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
let (adapter_guard, _) = hub.adapters.read(&mut token);
|
||||
let adapter = &adapter_guard[adapter_id];
|
||||
@@ -518,5 +520,5 @@ pub fn adapter_get_info<B: GfxBackend>(adapter_id: AdapterId) -> AdapterInfo {
|
||||
pub fn wgpu_adapter_get_info(
|
||||
adapter_id: AdapterId
|
||||
) -> AdapterInfo {
|
||||
gfx_select!(adapter_id => adapter_get_info(adapter_id))
|
||||
gfx_select!(adapter_id => adapter_get_info(&*GLOBAL, adapter_id))
|
||||
}
|
||||
@@ -34,8 +34,7 @@
|
||||
|
||||
use crate::{
|
||||
conv,
|
||||
gfx_select,
|
||||
hub::{GLOBAL, GfxBackend, Token},
|
||||
hub::{GfxBackend, Global, Token},
|
||||
resource,
|
||||
DeviceId,
|
||||
Extent3d,
|
||||
@@ -46,6 +45,8 @@ use crate::{
|
||||
SwapChainId,
|
||||
TextureViewId,
|
||||
};
|
||||
#[cfg(not(feature = "remote"))]
|
||||
use crate::{gfx_select, hub::GLOBAL};
|
||||
|
||||
use hal::{
|
||||
self,
|
||||
@@ -129,13 +130,14 @@ pub struct SwapChainOutput {
|
||||
}
|
||||
|
||||
pub fn swap_chain_get_next_texture<B: GfxBackend>(
|
||||
global: &Global,
|
||||
swap_chain_id: SwapChainId,
|
||||
view_id_in: Input<TextureViewId>,
|
||||
) -> SwapChainOutput {
|
||||
let hub = B::hub();
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
|
||||
let (mut surface_guard, mut token) = GLOBAL.surfaces.write(&mut token);
|
||||
let (mut surface_guard, mut token) = global.surfaces.write(&mut token);
|
||||
let surface = &mut surface_guard[swap_chain_id.to_surface_id()];
|
||||
let (device_guard, mut token) = hub.devices.read(&mut token);
|
||||
let (mut swap_chain_guard, mut token) = hub.swap_chains.write(&mut token);
|
||||
@@ -205,14 +207,14 @@ pub fn swap_chain_get_next_texture<B: GfxBackend>(
|
||||
#[cfg(not(feature = "remote"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_swap_chain_get_next_texture(swap_chain_id: SwapChainId) -> SwapChainOutput {
|
||||
gfx_select!(swap_chain_id => swap_chain_get_next_texture(swap_chain_id, PhantomData))
|
||||
gfx_select!(swap_chain_id => swap_chain_get_next_texture(&*GLOBAL, swap_chain_id, PhantomData))
|
||||
}
|
||||
|
||||
pub fn swap_chain_present<B: GfxBackend>(swap_chain_id: SwapChainId) {
|
||||
let hub = B::hub();
|
||||
pub fn swap_chain_present<B: GfxBackend>(global: &Global, swap_chain_id: SwapChainId) {
|
||||
let hub = B::hub(global);
|
||||
let mut token = Token::root();
|
||||
|
||||
let (mut surface_guard, mut token) = GLOBAL.surfaces.write(&mut token);
|
||||
let (mut surface_guard, mut token) = global.surfaces.write(&mut token);
|
||||
let surface = &mut surface_guard[swap_chain_id.to_surface_id()];
|
||||
let (mut device_guard, mut token) = hub.devices.write(&mut token);
|
||||
let (mut swap_chain_guard, mut token) = hub.swap_chains.write(&mut token);
|
||||
@@ -247,7 +249,8 @@ pub fn swap_chain_present<B: GfxBackend>(swap_chain_id: SwapChainId) {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "remote"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_swap_chain_present(swap_chain_id: SwapChainId) {
|
||||
gfx_select!(swap_chain_id => swap_chain_present(swap_chain_id))
|
||||
gfx_select!(swap_chain_id => swap_chain_present(&*GLOBAL, swap_chain_id))
|
||||
}
|
||||
@@ -23,7 +23,8 @@ enum ControlFlow {
|
||||
Terminate,
|
||||
}
|
||||
|
||||
fn process(message: GlobalMessage) -> ControlFlow {
|
||||
fn process(_message: GlobalMessage) -> ControlFlow {
|
||||
/*
|
||||
match message {
|
||||
GlobalMessage::RequestAdapter(ref desc, ref ids) => {
|
||||
wgn::request_adapter(desc, ids);
|
||||
@@ -33,7 +34,7 @@ fn process(message: GlobalMessage) -> ControlFlow {
|
||||
wgn::gfx_select!(adapter_id => fun(adapter_id, desc, id));
|
||||
}
|
||||
GlobalMessage::Terminate => return ControlFlow::Terminate,
|
||||
}
|
||||
}*/
|
||||
|
||||
ControlFlow::Continue
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user