forked from shader-slang/slang
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Precompiled SPIR-V import support (shader-slang#5048)
* Precompiled SPIR-V import support Adds appropriate linkage and function declaration syntax for SPIR-V functions that are declared, to be imported from another SPIR-V module. Unlike DXIL, stripping the Slang IR for a function down to a declaration requires retaining a block of parameters, as the function declaration must be emitted to SPIR-V with the same parameters as a definition. Because that thwarts the logic in Slang to tell the difference between a declaration and definition, and explicit decoration is introduced to explicitly mark functions which need to be treated as declarations during emit phase. Fixes shader-slang#4992 Co-authored-by: Yong He <[email protected]>
- Loading branch information
Showing
9 changed files
with
146 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
//TEST_IGNORE_FILE: | ||
|
||
// module-library-pointer-param.slang | ||
|
||
module "module-library-pointer-param"; | ||
|
||
public int ptrFunc(int* a) | ||
{ | ||
return *a; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// precompiled-spirv-pointer-param.slang | ||
|
||
// A test that uses slang-modules with embedded precompiled SPIRV and a library containing | ||
// a function with a pointer parameter. | ||
// The test compiles a library slang (module-library-pointer-param.slang) with -embed-downstream-ir then links the | ||
// library to entrypoint slang (this file). | ||
// The test passes if there is no errror thrown. | ||
// TODO: Check if final linkage used only the precompiled spirv. | ||
|
||
//TEST:COMPILE: tests/library/module-library-pointer-param.slang -o tests/library/module-library-pointer-param.slang-module -target spirv -embed-downstream-ir -incomplete-library | ||
//TEST:COMPILE: tests/library/precompiled-spirv-pointer-param.slang -target spirv -stage anyhit -entry anyhit -o tests/library/linked.spirv | ||
|
||
import "module-library-pointer-param"; | ||
|
||
struct Payload | ||
{ | ||
int val; | ||
} | ||
|
||
struct Attributes | ||
{ | ||
float2 bary; | ||
} | ||
|
||
[vk::push_constant] int* g_int; | ||
|
||
[shader("anyhit")] | ||
void anyhit(inout Payload payload, Attributes attrib) | ||
{ | ||
payload.val = ptrFunc(g_int); | ||
} |