Skip to content

Commit

Permalink
chore: webgpu.4
Browse files Browse the repository at this point in the history
  • Loading branch information
triniwiz committed Aug 6, 2024
1 parent 791e26c commit fbf68b0
Show file tree
Hide file tree
Showing 203 changed files with 4,307 additions and 3,736 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,14 @@ on:
pull_request:
workflow_dispatch:

env:
CARGO_TERM_COLOR: always

env:
NPM_TAG: "pr"
EMULATOR_NAME: "runtime-emu"
NDK_VERSION: r23c
ANDROID_API: 29
ANDROID_ABI: x86_64
NDK_ARCH: linux

CARGO_TERM_COLOR: always

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ GENERATE_HEADERS:
# PHONY keyword on make means this is not a file, just an identifier for a target
.PHONY: $(ARCHS_IOS)
$(ARCHS_IOS): %:
RUSTFLAGS="-Zlocation-detail=none -C panic=abort" cargo +nightly build -Z build-std='std,panic_abort' -Z build-std-features=panic_immediate_abort --target $@ --release -p canvas-svg
RUSTFLAGS="-Zlocation-detail=none -C panic=abort" cargo +nightly build -Z build-std='std,panic_abort' -Z build-std-features=panic_immediate_abort --target $@ --release -p canvas-ios

$(XCFRAMEWORK): $(ARCHS_IOS)

Expand Down
8 changes: 7 additions & 1 deletion crates/canvas-android/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::path::Path;
const DEFAULT_CLANG_VERSION: &str = "12.0.9";
fn main() {
setup_aarch64_android_workaround();
// setup_x86_64_android_workaround();
setup_x86_64_android_workaround();
println!("cargo:rerun-if-changed=src/lib.rs");
println!("cargo:rerun-if-changed=src/jni_compat/mod.rs");
println!("cargo:rerun-if-changed=src/jni_compat/org_nativescript_canvas_NSCCanvas.rs");
Expand All @@ -21,6 +21,8 @@ fn setup_x86_64_android_workaround() {
let target_os = env::var("CARGO_CFG_TARGET_OS").expect("CARGO_CFG_TARGET_OS not set");
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").expect("CARGO_CFG_TARGET_ARCH not set");
if target_arch == "x86_64" && target_os == "android" {
println!("cargo:rustc-link-arg=-Wl,-z,max-page-size=16384");
/*
let android_ndk_home = if let Ok(android_ndk_home) = env::var("ANDROID_NDK") {
android_ndk_home
} else {
Expand Down Expand Up @@ -59,6 +61,8 @@ fn setup_x86_64_android_workaround() {
} else {
panic!("Path {linkpath} not exists");
}
*/
}
}

Expand Down Expand Up @@ -111,6 +115,8 @@ fn setup_aarch64_android_workaround() {
"toolchains/llvm/prebuilt/{build_os}-x86_64/lib/clang/{clang_version}/lib/linux/"
);

println!("cargo:rustc-link-arg=-Wl,-z,max-page-size=16384");

let linkpath_other = format!("{android_ndk_home}/{linux_aarch64_lib_dir_other}");
if Path::new(&linkpath).exists() {
println!("cargo:rustc-link-search={android_ndk_home}/{linux_aarch64_lib_dir}");
Expand Down
2 changes: 1 addition & 1 deletion crates/canvas-c/src/c2d/custom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ pub extern "C" fn canvas_native_image_filter_release(value: *const ImageFilter)
if value.is_null() {
return;
}
let _ = unsafe { Arc::increment_strong_count(value) };
let _ = unsafe { Arc::decrement_strong_count(value) };
}
10 changes: 6 additions & 4 deletions crates/canvas-c/src/webgpu/gpu_command_encoder.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
use std::sync::Arc;
use std::{ffi::CStr, os::raw::c_char};
use std::sync::Arc;

use crate::webgpu::error::handle_error;
use crate::webgpu::prelude::ptr_into_label;
use crate::webgpu::structs::{CanvasLoadOp, CanvasStoreOp};

//use wgpu_core::gfx_select;
use super::{
enums::CanvasTextureAspect,
Expand All @@ -15,9 +20,6 @@ use super::{
CanvasRenderPassDepthStencilAttachment,
},
};
use crate::webgpu::error::handle_error;
use crate::webgpu::prelude::ptr_into_label;
use crate::webgpu::structs::{CanvasLoadOp, CanvasStoreOp};

pub struct CanvasGPUCommandEncoder {
pub(crate) instance: Arc<CanvasWebGPUInstance>,
Expand Down
12 changes: 12 additions & 0 deletions crates/canvas-c/src/webgpu/gpu_compute_pipeline.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::sync::Arc;

//use wgpu_core::gfx_select;
use crate::webgpu::error::handle_error;
use crate::webgpu::gpu::CanvasWebGPUInstance;
Expand All @@ -10,13 +11,24 @@ pub struct CanvasGPUComputePipeline {
pub(crate) error_sink: super::gpu_device::ErrorSink,
}

impl Drop for CanvasGPUComputePipeline {
fn drop(&mut self) {
if !std::thread::panicking() {
let global = self.instance.global();
gfx_select!(id => global.compute_pipeline_drop(self.pipeline));
}
}
}


#[no_mangle]
pub unsafe extern "C" fn canvas_native_webgpu_compute_pipeline_reference(
pipeline: *const CanvasGPUComputePipeline,
) {
if pipeline.is_null() {
return;
}

Arc::increment_strong_count(pipeline);
}

Expand Down
9 changes: 9 additions & 0 deletions crates/canvas-c/src/webgpu/gpu_pipeline_layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ pub struct CanvasGPUPipelineLayout {
pub(crate) layout: wgpu_core::id::PipelineLayoutId,
}

impl Drop for CanvasGPUPipelineLayout {
fn drop(&mut self) {
if !std::thread::panicking() {
let global = self.instance.global();
gfx_select!(layout => global.pipeline_layout_drop(self.layout));
}
}
}

#[no_mangle]
pub unsafe extern "C" fn canvas_native_webgpu_pipeline_layout_reference(
pipeline_layout: *const CanvasGPUPipelineLayout,
Expand Down
5 changes: 5 additions & 0 deletions crates/canvas-c/src/webgpu/gpu_queue.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::os::raw::{c_char, c_void};
use std::sync::Arc;

//use wgpu_core::gfx_select;
use crate::webgpu::error::{handle_error, handle_error_fatal};

Expand Down Expand Up @@ -217,6 +218,10 @@ pub unsafe extern "C" fn canvas_native_webgpu_queue_submit(
{
handle_error_fatal(global, cause, "canvas_native_webgpu_queue_submit");
}

for id in command_buffer_ids.into_iter() {
gfx_select!(id => global.command_buffer_drop(id));
}
}

#[no_mangle]
Expand Down
2 changes: 1 addition & 1 deletion crates/playground/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ fn test(state: &mut WebGLState, gl_state: &mut WebGLState, ctx_2d: &mut CanvasRe
// state.remove_if_current();
gl_state.make_current();
let mut ctx = ctx_2d.get_context_mut();;
let mut ctx = ctx_2d.get_context_mut();
ctx.set_font("30px Arial");
Expand Down
10 changes: 2 additions & 8 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,11 @@
"inputs": ["production", "^production"],
"cache": true
},
"lint": {
"inputs": ["default", "{workspaceRoot}/.eslintrc.json"],
"cache": true
},
"build.all": {
"cache": true
},
"test": {
"cache": true
},
"e2e": {
"@nx/eslint:lint": {
"inputs": ["default", "{workspaceRoot}/.eslintrc.json"],
"cache": true
}
},
Expand Down
2 changes: 1 addition & 1 deletion packages/canvas-babylon/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/canvas-babylon",
"version": "2.0.0-webgpu.2",
"version": "2.0.0-webgpu.4",
"description": "",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/canvas-media/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/canvas-media",
"version": "2.0.0-webgpu.2",
"version": "2.0.0-webgpu.4",
"description": "Canvas media",
"main": "index",
"typings": "index.d.ts",
Expand Down
Binary file modified packages/canvas-media/platforms/android/canvas_media.aar
Binary file not shown.
2 changes: 1 addition & 1 deletion packages/canvas-phaser-ce/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/canvas-phaser-ce",
"version": "2.0.0-webgpu.2",
"version": "2.0.0-webgpu.4",
"description": "Tools for using Phaser-ce to build native 2D games in NativeScript 👾",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/canvas-phaser/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/canvas-phaser",
"version": "2.0.0-webgpu.2",
"version": "2.0.0-webgpu.4",
"description": "Build awesome 2D games with Phaser.js and NativeScript",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/canvas-pixi/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/canvas-pixi",
"version": "2.0.0-webgpu.2",
"version": "2.0.0-webgpu.4",
"description": "Plugin for using pixi.js in NativeScript",
"main": "index",
"typings": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/canvas-polyfill/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/canvas-polyfill",
"version": "2.0.0-webgpu.2",
"version": "2.0.0-webgpu.4",
"description": "Polyfill for making NativeScript compatible with web libs like pixi.js, three.js, phaser.js, babylon.js, etc....",
"main": "index",
"typings": "index.d.ts",
Expand Down
Binary file modified packages/canvas-polyfill/platforms/android/async-release.aar
Binary file not shown.
Binary file modified packages/canvas-polyfill/platforms/android/canvas_polyfill.aar
Binary file not shown.
2 changes: 1 addition & 1 deletion packages/canvas-svg/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/canvas-svg",
"version": "2.0.0-webgpu.2",
"version": "2.0.0-webgpu.4",
"description": "Add a plugin description",
"main": "index",
"typings": "index.d.ts",
Expand Down
Loading

0 comments on commit fbf68b0

Please sign in to comment.