summaryrefslogtreecommitdiffstats
path: root/gfx/wgpu_bindings/src/client.rs
diff options
context:
space:
mode:
Diffstat (limited to 'gfx/wgpu_bindings/src/client.rs')
-rw-r--r--gfx/wgpu_bindings/src/client.rs108
1 files changed, 39 insertions, 69 deletions
diff --git a/gfx/wgpu_bindings/src/client.rs b/gfx/wgpu_bindings/src/client.rs
index ae1a5ef5ea..15c41a2264 100644
--- a/gfx/wgpu_bindings/src/client.rs
+++ b/gfx/wgpu_bindings/src/client.rs
@@ -13,7 +13,6 @@ use crate::SwapChainId;
use wgc::{id, identity::IdentityManager};
use wgt::{Backend, TextureFormat};
-pub use wgc::command::{compute_ffi::*, render_ffi::*};
use wgc::id::markers;
use parking_lot::Mutex;
@@ -38,16 +37,38 @@ fn make_byte_buf<T: serde::Serialize>(data: &T) -> ByteBuf {
}
#[repr(C)]
+pub struct ConstantEntry {
+ key: RawString,
+ value: f64,
+}
+
+#[repr(C)]
pub struct ProgrammableStageDescriptor {
module: id::ShaderModuleId,
entry_point: RawString,
+ constants: *const ConstantEntry,
+ constants_length: usize,
}
impl ProgrammableStageDescriptor {
fn to_wgpu(&self) -> wgc::pipeline::ProgrammableStageDescriptor {
+ let constants = make_slice(self.constants, self.constants_length)
+ .iter()
+ .map(|ce| {
+ (
+ unsafe { std::ffi::CStr::from_ptr(ce.key) }
+ .to_str()
+ .unwrap()
+ .to_string(),
+ ce.value,
+ )
+ })
+ .collect();
wgc::pipeline::ProgrammableStageDescriptor {
module: self.module,
entry_point: cow_label(&self.entry_point),
+ constants: Cow::Owned(constants),
+ zero_initialize_workgroup_memory: true,
}
}
}
@@ -525,17 +546,9 @@ pub extern "C" fn wgpu_client_make_buffer_id(
}
#[no_mangle]
-pub extern "C" fn wgpu_client_free_buffer_id(
- client: &Client,
- id: id::BufferId,
-) {
+pub extern "C" fn wgpu_client_free_buffer_id(client: &Client, id: id::BufferId) {
let backend = id.backend();
- client
- .identities
- .lock()
- .select(backend)
- .buffers
- .free(id)
+ client.identities.lock().select(backend).buffers.free(id)
}
#[no_mangle]
@@ -569,20 +582,11 @@ pub extern "C" fn wgpu_client_create_texture(
}
#[no_mangle]
-pub extern "C" fn wgpu_client_free_texture_id(
- client: &Client,
- id: id::TextureId,
-) {
+pub extern "C" fn wgpu_client_free_texture_id(client: &Client, id: id::TextureId) {
let backend = id.backend();
- client
- .identities
- .lock()
- .select(backend)
- .textures
- .free(id)
+ client.identities.lock().select(backend).textures.free(id)
}
-
#[no_mangle]
pub extern "C" fn wgpu_client_create_texture_view(
client: &Client,
@@ -619,10 +623,7 @@ pub extern "C" fn wgpu_client_create_texture_view(
}
#[no_mangle]
-pub extern "C" fn wgpu_client_free_texture_view_id(
- client: &Client,
- id: id::TextureViewId,
-) {
+pub extern "C" fn wgpu_client_free_texture_view_id(client: &Client, id: id::TextureViewId) {
let backend = id.backend();
client
.identities
@@ -667,17 +668,9 @@ pub extern "C" fn wgpu_client_create_sampler(
}
#[no_mangle]
-pub extern "C" fn wgpu_client_free_sampler_id(
- client: &Client,
- id: id::SamplerId,
-) {
+pub extern "C" fn wgpu_client_free_sampler_id(client: &Client, id: id::SamplerId) {
let backend = id.backend();
- client
- .identities
- .lock()
- .select(backend)
- .samplers
- .free(id)
+ client.identities.lock().select(backend).samplers.free(id)
}
#[no_mangle]
@@ -692,24 +685,20 @@ pub extern "C" fn wgpu_client_make_encoder_id(
.select(backend)
.command_buffers
.process(backend)
- .transmute()
+ .into_command_encoder_id()
}
#[no_mangle]
-pub extern "C" fn wgpu_client_free_command_encoder_id(
- client: &Client,
- id: id::CommandEncoderId,
-) {
+pub extern "C" fn wgpu_client_free_command_encoder_id(client: &Client, id: id::CommandEncoderId) {
let backend = id.backend();
client
.identities
.lock()
.select(backend)
.command_buffers
- .free(id.transmute())
+ .free(id.into_command_buffer_id())
}
-
#[no_mangle]
pub extern "C" fn wgpu_client_create_command_encoder(
client: &Client,
@@ -726,7 +715,7 @@ pub extern "C" fn wgpu_client_create_command_encoder(
.select(backend)
.command_buffers
.process(backend)
- .transmute();
+ .into_command_encoder_id();
let action = DeviceAction::CreateCommandEncoder(id, desc.map_label(|_| label));
*bb = make_byte_buf(&action);
@@ -772,7 +761,6 @@ pub extern "C" fn wgpu_device_create_render_bundle_encoder(
}
}
-
#[no_mangle]
pub unsafe extern "C" fn wgpu_render_bundle_encoder_destroy(
pass: *mut wgc::command::RenderBundleEncoder,
@@ -829,10 +817,7 @@ pub unsafe extern "C" fn wgpu_client_create_render_bundle_error(
}
#[no_mangle]
-pub extern "C" fn wgpu_client_free_render_bundle_id(
- client: &Client,
- id: id::RenderBundleId,
-) {
+pub extern "C" fn wgpu_client_free_render_bundle_id(client: &Client, id: id::RenderBundleId) {
let backend = id.backend();
client
.identities
@@ -1160,10 +1145,7 @@ pub unsafe extern "C" fn wgpu_client_create_pipeline_layout(
}
#[no_mangle]
-pub extern "C" fn wgpu_client_free_pipeline_layout_id(
- client: &Client,
- id: id::PipelineLayoutId,
-) {
+pub extern "C" fn wgpu_client_free_pipeline_layout_id(client: &Client, id: id::PipelineLayoutId) {
let backend = id.backend();
client
.identities
@@ -1221,10 +1203,7 @@ pub unsafe extern "C" fn wgpu_client_create_bind_group(
}
#[no_mangle]
-pub extern "C" fn wgpu_client_free_bind_group_id(
- client: &Client,
- id: id::BindGroupId,
-) {
+pub extern "C" fn wgpu_client_free_bind_group_id(client: &Client, id: id::BindGroupId) {
let backend = id.backend();
client
.identities
@@ -1249,10 +1228,7 @@ pub extern "C" fn wgpu_client_make_shader_module_id(
}
#[no_mangle]
-pub extern "C" fn wgpu_client_free_shader_module_id(
- client: &Client,
- id: id::ShaderModuleId,
-) {
+pub extern "C" fn wgpu_client_free_shader_module_id(client: &Client, id: id::ShaderModuleId) {
let backend = id.backend();
client
.identities
@@ -1304,10 +1280,7 @@ pub unsafe extern "C" fn wgpu_client_create_compute_pipeline(
}
#[no_mangle]
-pub extern "C" fn wgpu_client_free_compute_pipeline_id(
- client: &Client,
- id: id::ComputePipelineId,
-) {
+pub extern "C" fn wgpu_client_free_compute_pipeline_id(client: &Client, id: id::ComputePipelineId) {
let backend = id.backend();
client
.identities
@@ -1361,10 +1334,7 @@ pub unsafe extern "C" fn wgpu_client_create_render_pipeline(
}
#[no_mangle]
-pub extern "C" fn wgpu_client_free_render_pipeline_id(
- client: &Client,
- id: id::RenderPipelineId,
-) {
+pub extern "C" fn wgpu_client_free_render_pipeline_id(client: &Client, id: id::RenderPipelineId) {
let backend = id.backend();
client
.identities