-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support shader-printf and remove write-only texture WAR #26
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we pass the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yea, good point, but now we can not add g_printBuffer into the function parameter. Looks like wgsl doesn't support it and we need some legalization path like glsl to make this happen. |
||
}; | ||
|
||
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] = {}; | ||
} | ||
} | ||
`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public interface IPrintable
.