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
Remove imageMain and printMain in favor of render and print imports (#168)
* Remove `imageMain` and `printMain` in favor of render and print imports
Fixes#167
* Fix compilation of non playground shaders
* Cleanup imports, better handle lack of webgpu support
* Allow displaying both image and print output at the same time
* Update documentation
* Fix compilation target and entrypoint selection
Copy file name to clipboardExpand all lines: engine/slang-compilation-engine/media/playgroundDocumentation.md
+34-15Lines changed: 34 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ No data is sent to any server.
5
5
6
6
## Compiling Shaders (the "Compile" button)
7
7
8
-
You can compile shaders to many targets supported by Slang here, including SPIR-V, HLSL, GLSL, Metal, and
8
+
You can compile shaders to many targets supported by Slang here, including SPIR-V, HLSL, GLSL, Metal, CUDA, and
9
9
WGSL.
10
10
Generating DXIL requires DXC, which doesn't run in the browser so it's not supported here. You will have the opportunuty to select entrypoints for targets that don't support multiple entrypoints.
11
11
You can compile shaders with either the button in the top right of the editor, or the command `Slang Compile`.
@@ -14,13 +14,36 @@ You can compile shaders with either the button in the top right of the editor, o
14
14
15
15
In addition to compiling shaders, this playground extension can also run simple shaders via WebGPU.
16
16
You can run shaders with either the button in the top right of the editor, or the command `Run Playground`.
17
-
The playground supports running two types of shaders:
17
+
The playground supports running compute shaders that produce an image, text output, or both. All runnable shaders must be compute shaders marked with the `[shader("compute")]` attribute. You can use `import rendering` or `import printing` to display shader results.
18
18
19
-
***Image Compute Shader**: This is a compute shader that returns a pixel value at a given image
20
-
coordinate, similar to ShaderToys.
21
-
An image compute shader must define a `float4 imageMain(uint2 dispatchThreadID, int2 screenSize)` function.
22
-
***Print Shader**: This is a shader that prints text to the output pane.
23
-
A print shader must define a `void printMain()` function.
19
+
### Rendering
20
+
21
+
The `rendering` module provides the following function:
This will render to the output at the provided location based on the result of the provided function. The provided function takes in the screen size as an `int2`. It also creates an `outputTexture` texture, so you can create an entrypoint that executes for every pixel like so:
0 commit comments