Closed SuperIceCN closed 11 hours ago
By default Dawn bounces all C API calls through a vtable which acts as a swappable interface implementation for e.g. testing.
To initialize the interface, there must be a call to dawnProcSetProcs
setting it to the return value of dawn::native::GetProcs()
. Otherwise, you can directly call the result of function pointers dawn::native::GetProcs()
returns and skip the vtable entirely - which is what Mach does: https://sourcegraph.com/search?q=context:global+repo:%5Egithub%5C.com/hexops/mach%24+machDawnGetProcTable&patternType=keyword&sm=0
There is some more info on it here: https://machengine.org/pkg/mach-gpu-dawn/#important-building-webgpu-api-symbols
However, I must warn you that the Mach project is moving away from Dawn/WebGPU in favor of our own graphics abstraction sysgpu. As a result, the mach-gpu-dawn
project is likely to be removed soon.
My advice would be one of two options:
Hope that helps!
First of all, thank you for your help!
I just tried calling directly and it didn't crashed the JVM though the status of the response is not success while in an executable file it works. Anyway, I am considering switching to using sysgpu, which I guess that it will be much more easier to debug. My only concern is if sysgpu can achieve a relatively stable state in the coming months, at least in the parts related to compute shaders? (According to the commit records, there has been no progress for four months.) If so, I'm willing to make at least sysgpu accessible to Java&Kotlin applications, since JVM and Android community is in short of a gpu interface that is modern and easy to deploy for a long time.
Thank you for taking the time out of your busy schedule to answer my question.
sysgpu is definitely not stable, it is extremely experimental and likely to change a lot in the coming months. I expect its API and shading language to change dramatically.
Considering the following scenario: If you wish to use webgpu via zig in a Java program, it would be natural to use JNI to call the zig function with
callconv(.C)
. However, I've tested mach-gpu on my two PC and the following code makes JVM crashed. (Btw, the dawn binding by zig-gamedev works well).Native.java:
Native.zig:
root.zig:
Here the jni library is SuperIceCN/zig-jni.
Build and run Native.java and then the JVM crashed.
Console log:
JVM crash report:
I have been spending a long time on this issue, but I still cannot find a clue. I am grateful for any help.