Skip to content

Commit

Permalink
Merge #85
Browse files Browse the repository at this point in the history
85: Start migration from cbindgen to bindgen r=kvark a=DevOrc

Fix for #78 - has rust types generated by the header instead of vice-versa. Currently still needs a lot of work (most of the original codebase is deleted 😞 ) but I am slowly reimplementing everything with the generated types. Currently the triangle and compute examples _should_ work on Windows and Linux. Anyways, thought I would post this here to get initial thoughts before I finished adding everything. 

## Big changes
- all of the header types are generated at build time and inserted into the `crate::native` module
- enums are mapped from their c types to wgt using a macro (map_enum!)
- two c headers (`ffi/webgpu.h` for things in the [webgpu-native](https://github.com/webgpu-native/webgpu-headers) headers, and `ffi/wgpu.h` for stuff unique to wgpu-native)

## Small Notes
- auto-generated bindings are modified at build time to change all of the *Impl to Ids (`BindGroupImpl` -> `wgc::id::BindGroupId`)
- libclang now required to build (required by bindgen)
- enum constants are i32 on windows and are u32 on macos/linux
- example shaders are now written in WGSL
- Had to change some of the makefiles for windows c development (if anyone has a better way to write makefiles please let me know :smile:)

## Stuff that still needs to be added
- [x] MacOS Surfaces
- [ ] Wayland Surfaces
- [x]  most commands
- [x] undelete / update the capture example
- [x] logging
- [x] Textures
- [x] Fix IOS
- [ ] Include webgpu.h in release CI

Co-authored-by: Noah Charlton <ncharlton002@gmail.com>
  • Loading branch information
bors[bot] and ncharlton02 authored Apr 2, 2021
2 parents ce7a761 + fc8e9b5 commit e66901e
Show file tree
Hide file tree
Showing 29 changed files with 2,160 additions and 5,170 deletions.
18 changes: 14 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,16 @@ jobs:
channel: stable
build_command: rustup default stable-msvc; cargo clippy
make_command: make package
install_deps_command: |
# choco exit with code 1 after successful install
choco install -y --force llvm | exit 0
- os: windows-2019
name: Windows Nightly
channel: nightly
build_command: rustup default nightly-msvc; cargo check
install_deps_command: |
# choco exit with code 1 after successful install ¯\_(ツ)_/¯
choco install -y --force cmake make | exit 0
choco install -y --force cmake make llvm | exit 0
curl -sL -o glfw.zip https://github.com/glfw/glfw/archive/3.3.zip
unzip -qq glfw.zip -d $GITHUB_WORKSPACE
cd $GITHUB_WORKSPACE/glfw-3.3/
Expand All @@ -75,8 +78,11 @@ jobs:
cmake . -DCMAKE_INSTALL_PREFIX=$GLFW3_INSTALL_DIR -DCMAKE_GENERATOR_PLATFORM=x64
cmake --build . --target install
make_command: CMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/glfw-3.3/install make VERBOSE=1
make_shell: cmd
steps:
- uses: actions/checkout@v2
with:
submodules: 'true'
- if: matrix.channel == 'nightly'
name: Install latest nightly
uses: actions-rs/toolchain@v1
Expand All @@ -93,8 +99,6 @@ jobs:
- if: contains(matrix.build_command, 'clippy')
name: cargo clippy
run: ${{ matrix.build_command }}
- if: matrix.channel == 'nightly'
run: cargo +nightly install cbindgen
- run: ${{ matrix.make_command }}
shell: bash

Expand Down Expand Up @@ -194,6 +198,8 @@ jobs:
runs-on: macos-10.15
steps:
- uses: actions/checkout@v2
with:
submodules: 'true'
- run: rustup component add clippy
- run: rustup target add aarch64-apple-ios
- run: cargo clippy --target aarch64-apple-ios
Expand All @@ -205,11 +211,13 @@ jobs:
PKG_CONFIG_ALLOW_CROSS: 1
steps:
- uses: actions/checkout@v2
with:
submodules: 'true'
- run: rustup component add clippy
- name: Install dependencies
run: |
sudo apt-get update -y -qq
sudo apt-get install -y -qq libegl1-mesa-dev
sudo apt-get install -y -qq libegl1-mesa-dev libc6-dev-i386
echo "$ANDROID_HOME/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin" >> $GITHUB_PATH
- run: rustup target add aarch64-linux-android
- run: cargo clippy --target aarch64-linux-android
Expand All @@ -219,6 +227,8 @@ jobs:
runs-on: macos-10.15
steps:
- uses: actions/checkout@v2
with:
submodules: 'true'
- run: rustup component add clippy
- run: cargo clippy --features vulkan-portability

Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "ffi/webgpu-headers"]
path = ffi/webgpu-headers
url = https://github.com/webgpu-native/webgpu-headers
Loading

0 comments on commit e66901e

Please sign in to comment.