Skip to content

Commit

Permalink
feat: webgpu.33
Browse files Browse the repository at this point in the history
  • Loading branch information
triniwiz committed Oct 14, 2024
1 parent d6a5cbd commit 3d85c04
Show file tree
Hide file tree
Showing 30 changed files with 164 additions and 250 deletions.
3 changes: 3 additions & 0 deletions apps/demo/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ Helpers.initialize();
require('@nativescript/canvas-polyfill');
*/
import '@nativescript/canvas-polyfill';
import { Canvas } from '@nativescript/canvas';
// require('@nativescript/canvas-polyfill');
// import { Svg } from '@nativescript/canvas-svg';
// import { ImageAsset } from '@nativescript/canvas';
declare const jp, GDPerformanceMonitor, android, java, UIColor;
let monitor;
import { Application, path as filePath, knownFolders, Utils, path as nsPath, ImageSource, Trace, Screen } from '@nativescript/core';

// Canvas.useSurface = true;
Canvas.forceGL = false;
Application.on('discardedError', (args) => {
console.log('discardedError', args.error, args);
});
Expand Down
4 changes: 2 additions & 2 deletions crates/canvas-2d/src/context/surface_vulkan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl Context {
image.unwrap() as gpu::vk::Image,
alloc,
gpu::vk::ImageTiling::OPTIMAL,
gpu::vk::ImageLayout::COLOR_ATTACHMENT_OPTIMAL,
gpu::vk::ImageLayout::UNDEFINED,
gpu::vk::Format::R8G8B8A8_UNORM,
1,
None,
Expand Down Expand Up @@ -186,7 +186,7 @@ impl Context {
image.unwrap() as gpu::vk::Image,
alloc,
gpu::vk::ImageTiling::OPTIMAL,
gpu::vk::ImageLayout::COLOR_ATTACHMENT_OPTIMAL,
gpu::vk::ImageLayout::UNDEFINED,
gpu::vk::Format::R8G8B8A8_UNORM,
1,
None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ pub extern "system" fn nativeUpdate2DSurface(
env: JNIEnv,
_: JClass,
surface: jobject,
width: jint,
height: jint,
context: jlong,
) {
if context == 0 {
Expand All @@ -282,8 +284,8 @@ pub extern "system" fn nativeUpdate2DSurface(

unsafe {
if let Some(window) = NativeWindow::from_surface(env.get_native_interface(), surface) {
let width = window.width() as f32;
let height = window.height() as f32;
let width = width as f32;
let height = height as f32;

#[cfg(feature = "gl")]{
let context = context.get_context_mut();
Expand Down
4 changes: 2 additions & 2 deletions crates/canvas-android/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub extern "system" fn JNI_OnLoad(vm: JavaVM, _reserved: *const c_void) -> jint
"(IIZZZZIZZZZZI)J",
"(Landroid/view/Surface;ZFIFI)J",
"(Landroid/view/Surface;J)V",
"(Landroid/view/Surface;J)V",
"(Landroid/view/Surface;IIJ)V",
"(IIJ)V",
"(IIJ)V",
"(J)V",
Expand Down Expand Up @@ -129,7 +129,7 @@ pub extern "system" fn JNI_OnLoad(vm: JavaVM, _reserved: *const c_void) -> jint
"!(IIZZZZIZZZZZI)J",
"!(Landroid/view/Surface;ZFIFI)J",
"!(Landroid/view/Surface;J)V",
"!(Landroid/view/Surface;J)V",
"!(Landroid/view/Surface;IIJ)V",
"!(IIJ)V",
"!(IIJ)V",
"!(J)V",
Expand Down
8 changes: 1 addition & 7 deletions crates/canvas-c/src/c2d/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,9 @@ impl CanvasRenderingContext2D {
context.swap_buffers();
}

#[cfg(feature = "vulkan")]
if let Some(vulkan) = self.context.vulkan_context.as_mut() {
vulkan.record_command_buffer();
}

#[cfg(feature = "vulkan")]
if self.engine == Engine::Vulkan {
self.context.
submit();
self.context.flush()
}

#[cfg(feature = "vulkan")]
Expand Down
Loading

0 comments on commit 3d85c04

Please sign in to comment.