Slang bindings

Started by codex, January 22, 2026, 00:51:06

Previous topic - Next topic

codex

Are there any plans to add bindings for slang? If not, how can I get started on making these bindings for lwjgl myself?

spasi

Hey codex,

There are two options now:

1. Building "offline" bindings as a new LWJGL module. You could start by examining the shaderc bindings and doing something similar for slang. This involves using the LWJGL Kotlin-based bindings generator. A great starting point is the commit that first added the shaderc bindings, it should include everything necessary to get started.

2. Building runtime-generated bindings using LWJGL 3.4.0. If you're able to upgrade to 3.4.0 and JDK 25, then you can use the new FFM-based runtime bindings generator in the org.lwjgl.system.ffm package. With this generator you write simple Java interfaces to describe a C API (downcalls, upcalls, structs/unions) and you get instances of those interfaces generated at runtime by LWJGL. Assuming you have access to prebuilt slang binaries, you should be able to start using it immediately, without building a custom LWJGL or waiting for a fresh snapshot.

codex

Thanks for the guidance. I'm attempting option 1, but slang already seems a lot more complex than shaderc, so I have some questions.

struct ISession : public ISlangUnknown {
    virtual IGlobalSession* getGlobalSession() = 0;
    virtual IModule* loadModule(const char* moduleName, IBlob** outDiagnostics = nullptr) = 0;
}

How do I properly represent ISession? I've tried using both StructType and NativeClass for this, but neither seems to cover all the bases.