A downloadable tool for Windows and Linux

Download NowName your own price

Godot <3 Vulkan Compute

Run Vulkan Compute shaders in Godot 3!

[TODO :) ]


Post-Submission Changelog

Clearly I didn't quite get this project to where I hoped to. :D

What does the demo do?

When you click the "Run" button the demo executes a Vulkan Compute shader from within a Godot 3 application.

Note: The *3* is not a typo.

The code of the compute shader looks like this (the Itch editor widget does not like code formatting :/ ):

#version 450
#extension GL_EXT_debug_printf : enable

layout (local_size_x = 256) in;

void main() {
   int some_value = 41 + 1;
   debugPrintfEXT("Hello Godot <3 from a Vulkan & SPIR-V Compute shader!");
   debugPrintfEXT("This value DOES Compute: %d", some_value);
}


(I should note that while I got the functionality running I didn't manage to repackage it into an actual plugin yet.)

Does the Compute Shader do anything cool?

Well, it runs, (I think :) ) isn't that enough? :D

In theory, it performs an addition & has some debug print output but I've never seen the output because *reasons*. But (aside from validation errors) there's no Vulkan errors along the way.

Could the Computer Shader do anything cool?

In theory! :)

When I started this project I wasn't even sure if a Vulkan Compute Shader would even run in this scenario. Having established that it can, it seems likedly that--at a minimum--if I bind an input & output buffer the shader could run in the background & manipulate data of some sort (GPU AI/simulation perhaps?).

But using buffers in that scenario may be slow due to CPU<-->GPU data transfer. However while developing this project I discovered Vulkan has the concept of "foreign" or "external" memories which might offer a way to bypass this.

But why?

Mainly I just wanted to show off what I thought was a kinda cool hack & maybe encourage some people to check out the Foreigner project which I think is extremely powerful. (And I'd really like FFI functionality to be built into the engine because it enables much easier cross-platform interaction with pre-built libraries and, like, Visual Basic had the same functionality years ago. :D )

(I've made similar proof-of-concept demos wrapping the VLC & XCB libraries and it's also the mechanism behind my Epic Online Services for Godot addon.)

Future plans/roadmap?

Currently in the near term:

  • Would like to at least get as far as having [Update #2] the debug print work. :D
  • Would like to support input/output buffers.
  • Enable use of [Update #3] arbitrary Compute shaders in the demo.
  • And actually package this as an addon.

Stay tuned... :D

Changelog

This is what has changed since original submission:

  • Update #1:
    • Created this "Post-Submission Changelog".
    • Added "What does the demo do?" & other sections.
  • Update #2:
    • Finally confirmed the debug print from the compute shader is actually executed after adding support for Renderdoc's API capture support. (By a very convoluted path!)
    • Added some screenshots from the `qrenderdoc` tool showing the debug output & some other details.
  • Update #3:
    • Uploaded v0.1.1 for Linux & Windows.
    • Run your own Vulkan Compute shaders!
    • Renderdoc API support on Linux.
    • More details & pictures in the Devlog for Update #3.

The source (with my pre-existing changes) for the pre-existing Foreigner FFI (Foreign Function Interface) addon & associated demo project (which I used for developing this project) is here:

If you want to use GDScript to wrap a library with a C ABI I encourage you to check out Foreigner!

Download

Download NowName your own price

Click download now to get access to the following files:

Godot-Three-Vulkan-Compute-Addon-Demo-Linux-debug-v0.1.1.tar.gz 16 MB
Godot-Three-Vulkan-Compute-Addon-Demo-Win64-debug-v0.1.1.zip 15 MB
godot-three-vulkan-compute-addon-demo--linux--v0.1.0a.tar.gz 16 MB
godot-three-vulkan-compute-addon-demo--win64--v0.1.0.zip 14 MB

Development log

Leave a comment

Log in with itch.io to leave a comment.