Skip to content

Commit

Permalink
[Platform/Shared] Expose submit method for DirectContex class (requir…
Browse files Browse the repository at this point in the history
…ed for dx12 integration)
  • Loading branch information
EgorOrachyov authored and tonsky committed Jul 29, 2021
1 parent e8a4734 commit 8b21114
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions platform/cc/DirectContext.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<GrDirectContext*>(static_cast<uintptr_t>(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<GrDirectContext*>(static_cast<uintptr_t>(ptr));
Expand Down
13 changes: 13 additions & 0 deletions shared/java/DirectContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ public DirectContext resetGL(GLBackendState... states) {
return this;
}

/**
* <p>Submit outstanding work to the gpu from all previously un-submitted flushes.</p>
* <p>If the syncCpu flag is true this function will return once the gpu has finished with all submitted work.</p>
* <p>For more information refer to skia GrDirectContext::submit(bool syncCpu) method.</p>
*
* @param syncCpu flag to sync cpu and gpu work submission
*/
public void submit(boolean syncCpu) {
Stats.onNativeCall();
_nSubmit(_ptr, syncCpu);
}

/**
* <p>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,
Expand Down Expand Up @@ -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);
}

0 comments on commit 8b21114

Please sign in to comment.