From 8b2111460148cf6f190e5a1db24cf8ebfb069dcd Mon Sep 17 00:00:00 2001 From: Egor Orachev Date: Tue, 27 Jul 2021 19:34:11 +0300 Subject: [PATCH] [Platform/Shared] Expose submit method for DirectContex class (required for dx12 integration) --- platform/cc/DirectContext.cc | 6 ++++++ shared/java/DirectContext.java | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/platform/cc/DirectContext.cc b/platform/cc/DirectContext.cc index 91703c07..0aa158f8 100644 --- a/platform/cc/DirectContext.cc +++ b/platform/cc/DirectContext.cc @@ -45,6 +45,12 @@ extern "C" JNIEXPORT void JNICALL Java_org_jetbrains_skija_DirectContext__1nFlus context->flush(GrFlushInfo()); } +extern "C" JNIEXPORT void JNICALL Java_org_jetbrains_skija_DirectContext__1nSubmit + (JNIEnv* env, jclass jclass, jlong ptr, jboolean syncCpu) { + GrDirectContext* context = reinterpret_cast(static_cast(ptr)); + context->submit(syncCpu); +} + extern "C" JNIEXPORT void JNICALL Java_org_jetbrains_skija_DirectContext__1nReset (JNIEnv* env, jclass jclass, jlong ptr, jint flags) { GrDirectContext* context = reinterpret_cast(static_cast(ptr)); diff --git a/shared/java/DirectContext.java b/shared/java/DirectContext.java index 00301e0a..a248a103 100644 --- a/shared/java/DirectContext.java +++ b/shared/java/DirectContext.java @@ -67,6 +67,18 @@ public DirectContext resetGL(GLBackendState... states) { return this; } + /** + *

Submit outstanding work to the gpu from all previously un-submitted flushes.

+ *

If the syncCpu flag is true this function will return once the gpu has finished with all submitted work.

+ *

For more information refer to skia GrDirectContext::submit(bool syncCpu) method.

+ * + * @param syncCpu flag to sync cpu and gpu work submission + */ + public void submit(boolean syncCpu) { + Stats.onNativeCall(); + _nSubmit(_ptr, syncCpu); + } + /** *

Abandons all GPU resources and assumes the underlying backend 3D API context is no longer * usable. Call this if you have lost the associated GPU context, and thus internal texture, @@ -102,6 +114,7 @@ public DirectContext(long ptr) { @ApiStatus.Internal public static native long _nMakeMetal(long devicePtr, long queuePtr); @ApiStatus.Internal public static native long _nMakeDirect3D(long adapterPtr, long devicePtr, long queuePtr); @ApiStatus.Internal public static native long _nFlush(long ptr); + @ApiStatus.Internal public static native long _nSubmit(long ptr, boolean syncCpu); @ApiStatus.Internal public static native void _nReset(long ptr, int flags); @ApiStatus.Internal public static native void _nAbandon(long ptr); } \ No newline at end of file