C
C#2y ago
Garf

❔ Using ComputeSharp with Veldrid?

Want to use ComputeSharp (turns C# into GPU shader code, basically) with Veldrid (a low level graphics API for C#) but I'm not sure how. ComputeSharp can create precompiled shaders which I hope I can then use with Veldrid to simplify making shaders but I just have no idea how. This is how you usually define shaders in Veldrid
ShaderDescription vertexShaderDesc = new ShaderDescription(
ShaderStages.Vertex,
Encoding.UTF8.GetBytes(VertexCode),
"main");
ShaderDescription fragmentShaderDesc = new ShaderDescription(
ShaderStages.Fragment,
Encoding.UTF8.GetBytes(FragmentCode),
"main");
ShaderDescription vertexShaderDesc = new ShaderDescription(
ShaderStages.Vertex,
Encoding.UTF8.GetBytes(VertexCode),
"main");
ShaderDescription fragmentShaderDesc = new ShaderDescription(
ShaderStages.Fragment,
Encoding.UTF8.GetBytes(FragmentCode),
"main");
and ComputeSharp 'shaders' look something like this
using ComputeSharp;
[AutoConstructor]
[EmbeddedBytecode(8, 8, 1)]
public readonly partial struct TestShader : IPixelShader<float4>
{
public float4 Execute()
{
float2 uv = ThreadIds.Normalized.XY;
float3 col = 0.5f + 0.5f * Hlsl.Cos(new float3(uv, uv.X) + new float3(0, 2, 4));

return new(col, 1f);
}
}
using ComputeSharp;
[AutoConstructor]
[EmbeddedBytecode(8, 8, 1)]
public readonly partial struct TestShader : IPixelShader<float4>
{
public float4 Execute()
{
float2 uv = ThreadIds.Normalized.XY;
float3 col = 0.5f + 0.5f * Hlsl.Cos(new float3(uv, uv.X) + new float3(0, 2, 4));

return new(col, 1f);
}
}
Does anyone know if this is possible?
1 Reply
Accord
Accord2y ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.

Did you find this page helpful?