shader-slang/slang

Slang crashes during link when attempting to call a kernel function from another function

Opened this issue · 0 comments

When attempting to call a function tagging as a compute shader from another function, slang crashes during link.

Expected behaviour: Slang should either allow this, or report a compile error.

The module in the following SGL test case reproduces the crash in the call to link_program. Debugging c++, the crash was inside IDevice::createProgram

`
def test_call_kernel_function(test_id: str, device_type: sgl.DeviceType):
device = helpers.get_device(type=device_type)

# Loading a valid module must succeed
module = device.load_module_from_source(
    module_name=f"test_call_kernel_function_{test_id}",
    source="""
    [shader("compute")]
    [numthreads(1, 1, 1)]
    void foo_kernel(uint3 tid: SV_DispatchThreadID, uniform int x) { }

    [shader("compute")]
    [numthreads(1, 1, 1)]
    void main_kernel(uint3 tid: SV_DispatchThreadID, uniform int x)
    {
        foo_kernel(tid, x);
    }

""",
)
assert len(module.entry_points) == 2
main = module.entry_point("main_kernel")
assert main.name == "main_kernel"
device.link_program([module], [main])

`