Skip to content
Discussion options

You must be logged in to vote

The answer seems to be that you need to put an "export" on both declaration and implementation, and then it seems to generate the expected function declaration and calling syntax. (even if I compiles the shaders in the order where "later.slang" compiles after "shader.slang").

const char* shortestShader =
"RWStructuredBuffer<float> result;"
"export float computeSomething(uint3 threadId);  // FORWARD DECLARATION"
""
"[shader(\"compute\")]"
"[numthreads(1,1,1)]"
"void computeMain(uint3 threadId : SV_DispatchThreadID)"
"{"
"    result[threadId.x] = computeSomething(threadId);"
"}";

const char* laterShader =
"export float computeSomething(uint3 threadId) // IMPLEMENTATION"
"{"
"    return sin…

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@joelongson
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by joelongson
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant