-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from kaizhangNV/main
Support shader-printf and remove write-only texture WAR
- Loading branch information
Showing
8 changed files
with
371 additions
and
54 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,84 @@ | ||
|
||
const playgroundSource = ` | ||
internal uniform float time; | ||
// Return the current time in milliseconds | ||
public float getTime() | ||
{ | ||
return time; | ||
} | ||
// type field: 1 for string, 2 for integer, 3 for float, 4 for double | ||
struct FormatedStruct | ||
{ | ||
uint32_t type = 0xFFFFFFFF; | ||
uint32_t low = 0; | ||
uint32_t high = 0; | ||
}; | ||
internal RWStructuredBuffer<FormatedStruct> g_printedBuffer; | ||
interface IPrintf | ||
{ | ||
uint32_t typeFlag(); | ||
uint32_t writePrintfWords(); | ||
}; | ||
extension uint : IPrintf | ||
{ | ||
uint32_t typeFlag() { return 2;} | ||
uint32_t writePrintfWords() { return (uint32_t)this; } | ||
} | ||
extension int : IPrintf | ||
{ | ||
uint32_t typeFlag() { return 2;} | ||
uint32_t writePrintfWords() { return (uint32_t)this; } | ||
} | ||
// extension int64_t : IPrintf | ||
// { | ||
// uint64_t writePrintfWords() { return (uint64_t)this; } | ||
// } | ||
// extension uint64_t : IPrintf | ||
// { | ||
// uint64_t writePrintfWords() { return (uint64_t)this; } | ||
// } | ||
extension float : IPrintf | ||
{ | ||
uint32_t typeFlag() { return 3;} | ||
uint32_t writePrintfWords() { return bit_cast<uint32_t>(this); } | ||
} | ||
// extension double : IPrintf | ||
// { | ||
// uint64_t writePrintfWords() { return bit_cast<uint64_t>(this); } | ||
// } | ||
extension String : IPrintf | ||
{ | ||
uint32_t typeFlag() { return 1;} | ||
uint32_t writePrintfWords() { return getStringHash(this); } | ||
} | ||
void handleEach<T>(T value, int index) where T : IPrintf | ||
{ | ||
g_printedBuffer[index].type = value.typeFlag(); | ||
g_printedBuffer[index].low = value.writePrintfWords(); | ||
} | ||
public void print<each T>(String format, expand each T values) where T : IPrintf | ||
{ | ||
//if (format.length != 0) | ||
{ | ||
g_printedBuffer[0].type = 1; | ||
g_printedBuffer[0].low = getStringHash(format); | ||
int index = 1; | ||
expand(handleEach(each values, index++)); | ||
g_printedBuffer[index] = {}; | ||
} | ||
} | ||
`; |
Oops, something went wrong.