You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+78-2Lines changed: 78 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,14 +4,89 @@ GLSL as a scripting language? Say no more!
4
4
5
5
Crash is a super not production-ready asynchronous IO runtime and module system for Vulkan compute shaders.
6
6
7
+
## What does it look like?
8
+
9
+
```glsl
10
+
#include <file.glsl>
11
+
#include <parallel.glsl>
12
+
13
+
void main() {
14
+
if (ThreadId == 0) {
15
+
println("Hello from crash!");
16
+
println(`We are running on ${ThreadLocalCount * ThreadGroupCount} threads across ${ThreadGroupCount} thread groups. Let me introduce the first four thread groups.`);
* Malloc that works by bumping a heap pointer and a FREE() macro to free all memory allocated inside it `FREE(alloc_t ptr = malloc(4));`
81
+
* A second heap for IO to make life complicated: `FREE(alloc_t buf = malloc(1024); FREE_IO(readSync("myfile.txt", buf)); println(buf));`
82
+
* And a macro to free both heaps at the same time: `FREE_ALL(alloc_t buf = malloc(1024); readSync("myfile.txt", buf); println(buf));`
83
+
* Set warp width and warp count from GLSL: `ThreadLocalCount = 64; ThreadGroupCount = 256;`
84
+
* By default, crash programs run across 16384 threads. A naive hello world will fill your screen with hellos. Use ThreadId to limit it to a single thread `if (ThreadId == 0) println("Hello, World!");`
85
+
* Set heap size per thread, per thread group and total program heap `HeapSize = 4096; GroupHeapSize = HeapSize * ThreadLocalCount; TotalHeapSize = GroupHeapSize * ThreadGroupCount;`
86
+
* An `#include <file.glsl>` system powered by the C preprocessor.
87
+
* That also loads things over HTTPS with SHA256 integrity verification `#include <https://raw.githubusercontent.com/kig/spirv-wasm/12f2554994f5b733da65e6705099e2afd160649c/spirv-io/lib/dlopen.glsl> @ 4b43671ba494238b3855c2990c2cd844573a91d15464ed8b77d2a5b98d0eb2e1`
88
+
89
+
## Examples
15
90
16
91
The example scripts in [examples/](examples/) show you how to do various things, such as:
17
92
@@ -84,6 +159,7 @@ The GPU spins and waits for the request status flag to be set to completed. Afte
84
159
buffer, sets the request status flag to handled, and goes on its merry way.
85
160
86
161
So far, so good. What if you couldn't trust the order of the writes and reads above? What if cache lines in your memory buffer were getting transported over UDP.
162
+
What if the driver killed your compute shaders after 10 seconds. Since clearly it has hung, right? Who would wait for user input in a shader? Crash, that's who!
println(`We are running on ${ThreadLocalCount * ThreadGroupCount} threads across ${ThreadGroupCount} thread groups. Let me introduce the first four thread groups.`);
8
+
}
9
+
globalBarrier();
10
+
if (ThreadGroupId <4&& ThreadLocalId %16==0) {
11
+
println(`Thread ${ThreadId} from thread group ${ThreadGroupId}[${ThreadLocalId}] checking in.`);
12
+
}
13
+
globalBarrier();
14
+
if (ThreadId ==0) {
15
+
println("What's your name?");
16
+
string name = awaitIO(readLine(stdin, malloc(256)));
0 commit comments