shader-slang / slang

Making it easier to work with shaders
http://shader-slang.com
Other
3.16k stars 214 forks source link

Support for Custom GLSL Code in Slang #5687

Open Calonca opened 5 days ago

Calonca commented 5 days ago

Description

I am using Slang to create compute shaders for use in Godot. In Godot, the shader source code must include the #[compute] directive at the top of the file.

I attempted to achieve this by adding the following line to the computeMain function.

__requirePrelude(R"(#[compute])");

However, compilation to GLSL fails with the following error:

internal error 99999: unimplemented feature in Slang compiler: unexpected IR opcode during code emit
    __requirePrelude(R"(#[compute])");

Question

Is it possible to support the addition of custom GLSL code (e.g., directives like #[compute]) in Slang shaders? If not, are there any alternative approaches or workarounds for embedding such directives in the generated GLSL code for compatibility with Godot?

Steps to Reproduce

  1. Use Slang to create a compute shader.
  2. Add __requirePrelude(R"(#[compute])"); inside the compute function.
  3. Compile the shader to GLSL using the Slang compiler.

Expected Behavior

The #[compute] directive should be successfully added to the GLSL output for compatibility with Godot.

Actual Behavior

The compilation fails with an internal error.

jkwak-work commented 4 days ago

This question was initially brought up on Discord. Yong agreed to support it.