Closed
Description
Tested versions
- Reproducible in 4.3 and earlier versions
System information
macOS Sonoma - Godot 4.3 stable - Vulkan (Forward+) - Apple M1 Max
Issue description
I'm working on project which needs to modify or create compute shader code. Here I mean not shader parameters, but whole functions (It would be impossible to include all possible combinations, these are affected by the users input).
So, I'm trying to use the RDShaderSource together with the with RenderingDevice::shader_compile_spirv_from_source to compile a compute shader during runtime. But this yields to a RID(0) when I then call RenderingDevice::shader_create_from_spirv
The only thing which works is to load/preload the shader code from the res:// folder.
I also tried to load it from the user:// folder (using ResourceLoader::load), but this also does not work.
Steps to reproduce
var source = """
#[compute]
#version 450
<some shader code>
...
"""
var shader_source = RDShaderSource.new()
shader_source.language = RenderingDevice.SHADER_LANGUAGE_GLSL
shader_source.set_stage_source(RenderingDevice.SHADER_STAGE_COMPUTE, source)
# alternative way, seems to work the same):
# shader_source.source_compute = source
var rd = RenderingServer.create_local_rendering_device()
# returns some RDShaderSPIRV, so seems to work:
var shader_spirv = rd.shader_compile_spirv_from_source(shader_source)
# returns RID(0):
var shader = rd.shader_create_from_spirv(shader_spirv)
# everything else fails because shader seems not be compiled