Skip to content

Commit

Permalink
Merge #17
Browse files Browse the repository at this point in the history
17: Update for wgpu-core r=kvark a=kvark

Depends on gfx-rs/wgpu#619

Co-authored-by: Dzmitry Malyshau <[email protected]>
  • Loading branch information
bors[bot] and kvark authored May 1, 2020
2 parents e5b4a60 + fdf8d47 commit 33859ff
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 139 deletions.
49 changes: 46 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 3 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,16 @@ crate-type = ["lib", "cdylib", "staticlib"]
[features]
default = []
#metal-auto-capture = ["gfx-backend-metal/auto-capture"]
vulkan-portability = ["core/gfx-backend-vulkan"]
vulkan-portability = ["wgc/gfx-backend-vulkan"]

[dependencies.core]
[dependencies.wgc]
package = "wgpu-core"
#path = "../wgpu-core"
git = "https://github.com/gfx-rs/wgpu"
version = "0.5"
features = ["raw-window-handle", "trace"]

[dependencies.wgt]
package = "wgpu-types"
#path = "../wgpu-types"
git = "https://github.com/gfx-rs/wgpu"
version = "0.5"

Expand All @@ -39,6 +38,3 @@ lazy_static = "1.1"
parking_lot = "0.10"
raw-window-handle = "0.3"
libc = {version="0.2", features=[]}

[target.'cfg(target_os = "macos")'.dependencies]
objc = "0.2.7"
6 changes: 6 additions & 0 deletions cbindgen.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ language = "C"
prefix = "WGPU"
exclude = ["Option_AdapterId", "Option_SurfaceId", "Option_TextureViewId"]

[export.rename]
"BufferDescriptor_Label" = "BufferDescriptor"
"TextureDescriptor_Label" = "TextureDescriptor"
"TextureViewDescriptor_Label" = "TextureViewDescriptor"
"SamplerDescriptor_Label" = "SamplerDescriptor"

[parse]
parse_deps = true
include = ["wgpu-core", "wgpu-types"]
Expand Down
8 changes: 6 additions & 2 deletions ffi/wgpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,8 @@ typedef struct {
uintptr_t entries_length;
} WGPUBindGroupLayoutDescriptor;

typedef const char *WGPULabel;

typedef uint32_t WGPUBufferUsage;
#define WGPUBufferUsage_MAP_READ 1
#define WGPUBufferUsage_MAP_WRITE 2
Expand All @@ -533,7 +535,7 @@ typedef uint32_t WGPUBufferUsage;
#define WGPUBufferUsage_INDIRECT 256

typedef struct {
const char *label;
WGPULabel label;
WGPUBufferAddress size;
WGPUBufferUsage usage;
} WGPUBufferDescriptor;
Expand Down Expand Up @@ -652,6 +654,7 @@ typedef struct {
} WGPURenderPipelineDescriptor;

typedef struct {
WGPULabel label;
WGPUAddressMode address_mode_u;
WGPUAddressMode address_mode_v;
WGPUAddressMode address_mode_w;
Expand Down Expand Up @@ -692,7 +695,7 @@ typedef struct {
} WGPUSwapChainDescriptor;

typedef struct {
const char *label;
WGPULabel label;
WGPUExtent3d size;
uint32_t mip_level_count;
uint32_t sample_count;
Expand Down Expand Up @@ -725,6 +728,7 @@ typedef struct {
} WGPUSwapChainOutput;

typedef struct {
WGPULabel label;
WGPUTextureFormat format;
WGPUTextureViewDimension dimension;
WGPUTextureAspect aspect;
Expand Down
32 changes: 16 additions & 16 deletions src/command.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::GLOBAL;

pub use core::command::{compute_ffi::*, render_ffi::*};
pub use wgc::command::{compute_ffi::*, render_ffi::*};

use core::{gfx_select, id};
use wgc::{gfx_select, id};

#[no_mangle]
pub extern "C" fn wgpu_command_encoder_finish(
Expand Down Expand Up @@ -33,8 +33,8 @@ pub extern "C" fn wgpu_command_encoder_copy_buffer_to_buffer(
#[no_mangle]
pub extern "C" fn wgpu_command_encoder_copy_buffer_to_texture(
command_encoder_id: id::CommandEncoderId,
source: &core::command::BufferCopyView,
destination: &core::command::TextureCopyView,
source: &wgc::command::BufferCopyView,
destination: &wgc::command::TextureCopyView,
copy_size: wgt::Extent3d,
) {
gfx_select!(command_encoder_id => GLOBAL.command_encoder_copy_buffer_to_texture(
Expand All @@ -47,8 +47,8 @@ pub extern "C" fn wgpu_command_encoder_copy_buffer_to_texture(
#[no_mangle]
pub extern "C" fn wgpu_command_encoder_copy_texture_to_buffer(
command_encoder_id: id::CommandEncoderId,
source: &core::command::TextureCopyView,
destination: &core::command::BufferCopyView,
source: &wgc::command::TextureCopyView,
destination: &wgc::command::BufferCopyView,
copy_size: wgt::Extent3d,
) {
gfx_select!(command_encoder_id => GLOBAL.command_encoder_copy_texture_to_buffer(
Expand All @@ -61,8 +61,8 @@ pub extern "C" fn wgpu_command_encoder_copy_texture_to_buffer(
#[no_mangle]
pub extern "C" fn wgpu_command_encoder_copy_texture_to_texture(
command_encoder_id: id::CommandEncoderId,
source: &core::command::TextureCopyView,
destination: &core::command::TextureCopyView,
source: &wgc::command::TextureCopyView,
destination: &wgc::command::TextureCopyView,
copy_size: wgt::Extent3d,
) {
gfx_select!(command_encoder_id => GLOBAL.command_encoder_copy_texture_to_texture(
Expand All @@ -80,9 +80,9 @@ pub extern "C" fn wgpu_command_encoder_copy_texture_to_texture(
#[no_mangle]
pub unsafe extern "C" fn wgpu_command_encoder_begin_render_pass(
encoder_id: id::CommandEncoderId,
desc: &core::command::RenderPassDescriptor,
) -> *mut core::command::RawPass {
let pass = core::command::RawPass::new_render(encoder_id, desc);
desc: &wgc::command::RenderPassDescriptor,
) -> *mut wgc::command::RawPass {
let pass = wgc::command::RawPass::new_render(encoder_id, desc);
Box::into_raw(Box::new(pass))
}

Expand All @@ -98,7 +98,7 @@ pub unsafe extern "C" fn wgpu_render_pass_end_pass(pass_id: id::RenderPassId) {
}

#[no_mangle]
pub unsafe extern "C" fn wgpu_render_pass_destroy(pass: *mut core::command::RawPass) {
pub unsafe extern "C" fn wgpu_render_pass_destroy(pass: *mut wgc::command::RawPass) {
let _ = Box::from_raw(pass).into_vec();
}

Expand All @@ -110,9 +110,9 @@ pub unsafe extern "C" fn wgpu_render_pass_destroy(pass: *mut core::command::RawP
#[no_mangle]
pub unsafe extern "C" fn wgpu_command_encoder_begin_compute_pass(
encoder_id: id::CommandEncoderId,
_desc: Option<&core::command::ComputePassDescriptor>,
) -> *mut core::command::RawPass {
let pass = core::command::RawPass::new_compute(encoder_id);
_desc: Option<&wgc::command::ComputePassDescriptor>,
) -> *mut wgc::command::RawPass {
let pass = wgc::command::RawPass::new_compute(encoder_id);
Box::into_raw(Box::new(pass))
}

Expand All @@ -123,6 +123,6 @@ pub unsafe extern "C" fn wgpu_compute_pass_end_pass(pass_id: id::ComputePassId)
}

#[no_mangle]
pub unsafe extern "C" fn wgpu_compute_pass_destroy(pass: *mut core::command::RawPass) {
pub unsafe extern "C" fn wgpu_compute_pass_destroy(pass: *mut wgc::command::RawPass) {
let _ = Box::from_raw(pass).into_vec();
}
Loading

0 comments on commit 33859ff

Please sign in to comment.