### Compile Slang to target platforms Source: https://shader-slang.org/docs/first-slang-shader Command-line instructions for compiling Slang shaders into Vulkan SPIR-V or GLSL formats. ```bash .\slangc.exe hello-world.slang -profile glsl_450 -target spirv -o hello-world.spv -entry computeMain ``` ```bash .\slangc.exe hello-world.slang -profile glsl_450 -target glsl -o hello-world.glsl -entry computeMain ``` -------------------------------- ### Define a basic compute shader Source: https://shader-slang.org/docs/first-slang-shader A simple compute shader that adds values from two input buffers and stores the result in an output buffer. ```slang // hello-world.slang StructuredBuffer buffer0; StructuredBuffer buffer1; RWStructuredBuffer result; [shader("compute")] [numthreads(1,1,1)] void computeMain(uint3 threadId : SV_DispatchThreadID) { uint index = threadId.x; result[index] = buffer0[index] + buffer1[index]; } ``` -------------------------------- ### Generated GLSL output Source: https://shader-slang.org/docs/first-slang-shader The resulting GLSL code after compiling the initial Slang shader, showing how Slang handles binding layouts. ```glsl // hello-world.glsl (generated by slangc) #version 450 layout(row_major) uniform; layout(row_major) buffer; #line 2 0 layout(std430, binding = 0) readonly buffer _S1 { float _data[]; } buffer0_0; #line 3 layout(std430, binding = 1) readonly buffer _S2 { float _data[]; } buffer1_0; #line 4 layout(std430, binding = 2) buffer _S3 { float _data[]; } result_0; layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { #line 10 uint index_0 = gl_GlobalInvocationID.x; float _S4 = ((buffer0_0)._data[(index_0)]); #line 11 float _S5 = ((buffer1_0)._data[(index_0)]); #line 11 float _S6 = _S4 + _S5; #line 11 ((result_0)._data[(index_0)]) = _S6; #line 8 return; } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.