diff --git a/src/ComputeSharp/Shaders/Interop/ReflectionServices.cs b/src/ComputeSharp/Shaders/Interop/ReflectionServices.cs
index c0a04789..3a83b4f0 100644
--- a/src/ComputeSharp/Shaders/Interop/ReflectionServices.cs
+++ b/src/ComputeSharp/Shaders/Interop/ReflectionServices.cs
@@ -14,13 +14,13 @@ namespace ComputeSharp.Interop
public static class ReflectionServices
{
///
- /// Gets the shader info associated with a given shader.
+ /// Gets the shader info associated with a given compute shader.
///
- /// This overload can be used for simplicity when the shader being inspected does not rely on captured
+ /// This overload can be used for simplicity when the compute shader being inspected does not rely on captured
/// objects to be processed correctly. This is the case when it does not contain any -s.
///
///
- /// The type of shader to retrieve info for.
+ /// The type of compute shader to retrieve info for.
/// The resulting instance.
///
/// The thread group sizes will always be set to (1, 1, 1) in the returned shader. This is done to
@@ -30,14 +30,14 @@ namespace ComputeSharp.Interop
public static void GetShaderInfo(out ShaderInfo shaderInfo)
where T : struct, IComputeShader
{
- GetShaderInfo(default(T), out shaderInfo);
+ GetNonGenericShaderInfo(default(T), out shaderInfo);
}
///
- /// Gets the shader info associated with a given shader.
+ /// Gets the shader info associated with a given compute shader.
///
- /// The type of shader to retrieve info for.
- /// The input shader to retrieve info for.
+ /// The type of compute shader to retrieve info for.
+ /// The input compute shader to retrieve info for.
/// The resulting instance.
///
/// The thread group sizes will always be set to (1, 1, 1) in the returned shader. This is done to
@@ -46,6 +46,59 @@ namespace ComputeSharp.Interop
///
public static unsafe void GetShaderInfo(in T shader, out ShaderInfo shaderInfo)
where T : struct, IComputeShader
+ {
+ GetNonGenericShaderInfo(in shader, out shaderInfo);
+ }
+
+ ///
+ /// Gets the shader info associated with a given pixel shader.
+ ///
+ /// This overload can be used for simplicity when the pixel shader being inspected does not rely on captured
+ /// objects to be processed correctly. This is the case when it does not contain any -s.
+ ///
+ ///
+ /// The type of pixel shader to retrieve info for.
+ /// The type of pixels being processed by the shader.
+ /// The resulting instance.
+ ///
+ /// The thread group sizes will always be set to (1, 1, 1) in the returned shader. This is done to
+ /// avoid having to compiler multiple shaders just to get reflection info for them. When using any of
+ /// the APIs to dispatch a shader, the thread sizes would actually be set to a proper value insead.
+ ///
+ public static void GetShaderInfo(out ShaderInfo shaderInfo)
+ where T : struct, IPixelShader
+ where TPixel : unmanaged
+ {
+ GetNonGenericShaderInfo(default(T), out shaderInfo);
+ }
+
+ ///
+ /// Gets the shader info associated with a given pixel shader.
+ ///
+ /// The type of pixel shader to retrieve info for.
+ /// The type of pixels being processed by the shader.
+ /// The input pixel shader to retrieve info for.
+ /// The resulting instance.
+ ///
+ /// The thread group sizes will always be set to (1, 1, 1) in the returned shader. This is done to
+ /// avoid having to compiler multiple shaders just to get reflection info for them. When using any of
+ /// the APIs to dispatch a shader, the thread sizes would actually be set to a proper value insead.
+ ///
+ public static unsafe void GetShaderInfo(in T shader, out ShaderInfo shaderInfo)
+ where T : struct, IPixelShader
+ where TPixel : unmanaged
+ {
+ GetNonGenericShaderInfo(in shader, out shaderInfo);
+ }
+
+ ///
+ /// Gets the shader info associated with a given shader of any type.
+ ///
+ /// The type of shader to retrieve info for.
+ /// The input shader to retrieve info for.
+ /// The resulting instance.
+ private static unsafe void GetNonGenericShaderInfo(in T shader, out ShaderInfo shaderInfo)
+ where T : struct
{
ShaderLoader shaderLoader = ShaderLoader.Load(in shader);
diff --git a/tests/ComputeSharp.Tests/ShaderCompilerTests.cs b/tests/ComputeSharp.Tests/ShaderCompilerTests.cs
index 0bdfd0b4..50e72d30 100644
--- a/tests/ComputeSharp.Tests/ShaderCompilerTests.cs
+++ b/tests/ComputeSharp.Tests/ShaderCompilerTests.cs
@@ -122,7 +122,7 @@ namespace ComputeSharp.Tests
}
[TestMethod]
- public void OutOfOrderMethods_Ok()
+ public void OutOfOrderMethods()
{
ReflectionServices.GetShaderInfo(out var info);
}
@@ -153,5 +153,23 @@ namespace ComputeSharp.Tests
buffer[ThreadIds.X] = ExternalStructType.Sum(type);
}
}
+
+ [TestMethod]
+ public void PixelShader()
+ {
+ ReflectionServices.GetShaderInfo(out var info);
+
+ Assert.AreEqual(info.TextureStoreInstructionCount, 1u);
+ Assert.AreEqual(info.BoundResourceCount, 2u);
+ }
+
+ public readonly partial struct StatelessPixelShader : IPixelShader
+ {
+ ///
+ public Float4 Execute()
+ {
+ return new(1, 1, 1, 1);
+ }
+ }
}
}