Add slang shaders for headless samples

This commit is contained in:
Sascha Willems 2025-05-15 19:04:04 +02:00
parent a442bdd683
commit 04ab171247
4 changed files with 104 additions and 9 deletions

View file

@ -0,0 +1,34 @@
/* Copyright (c) 2025, Sascha Willems
*
* SPDX-License-Identifier: MIT
*
*/
RWStructuredBuffer<uint> values;
[[SpecializationConstant]] const uint BUFFER_ELEMENTS = 32;
uint fibonacci(uint n) {
if(n <= 1){
return n;
}
uint curr = 1;
uint prev = 1;
for(uint i = 2; i < n; ++i) {
uint temp = curr;
curr += prev;
prev = temp;
}
return curr;
}
[numthreads(1, 1, 1)]
[shader("compute")]
void computeMain(uint3 GlobalInvocationID : SV_DispatchThreadID)
{
uint index = GlobalInvocationID.x;
if (index >= BUFFER_ELEMENTS)
return;
values[index] = fibonacci(values[index]);
}

View file

@ -0,0 +1,32 @@
/* Copyright (c) 2025, Sascha Willems
*
* SPDX-License-Identifier: MIT
*
*/
struct VSInput
{
float3 Pos;
float3 Color;
};
struct VSOutput
{
float4 Pos : SV_POSITION;
float3 Color;
};
[shader("vertex")]
VSOutput vertexMain(VSInput input, uniform float4x4 mvp)
{
VSOutput output;
output.Color = input.Color;
output.Pos = mul(mvp, float4(input.Pos.xyz, 1.0));
return output;
}
[shader("fragment")]
float4 fragmentMain(VSOutput input)
{
return float4(input.Color, 1.0);
}