Add D2D1PixelShader.GetResourceTextureCount<T>() and tests

このコミットが含まれているのは:
Sergio Pedri committed 2023-09-30 14:12:49 +02:00
1 親 ba732ac96a
コミット a873fafdd4
2ファイル変更
+50

検索条件に一致するファイルはありません

+13
ファイルの表示
@@ -295,6 +295,19 @@ public static class D2D1PixelShader
return shader.InputCount;
}
/// <summary>
/// Gets the number of resource textures for a D2D1 pixel shader.
/// </summary>
/// <typeparam name="T">The type of D2D1 pixel shader to get the resource texture count for.</typeparam>
/// <returns>The number of resource texture for the D2D1 pixel shader of type <typeparamref name="T"/>.</returns>
public static int GetResourceTextureCount<T>()
where T : unmanaged, ID2D1PixelShader
{
Unsafe.SkipInit(out T shader);
return shader.ResourceTextureCount;
}
/// <summary>
/// Gets the input types for a D2D1 pixel shader.
/// </summary>
+37
ファイルの表示
@@ -235,6 +235,43 @@ public partial class D2D1PixelShaderTests
Assert.AreEqual(span[3].Dimensions, 2);
}
[TestMethod]
public unsafe void GetResourceTextureCount_IsCorrect()
{
Assert.AreEqual(0, D2D1PixelShader.GetResourceTextureCount<ShaderWithoutResourceTextures>());
Assert.AreEqual(1, D2D1PixelShader.GetResourceTextureCount<ShaderWithJustOneResourceTextures>());
Assert.AreEqual(4, D2D1PixelShader.GetResourceTextureCount<ShaderWithResourceTextures>());
}
[D2DInputCount(4)]
[D2DInputSimple(0)]
[D2DInputSimple(2)]
[D2DInputComplex(1)]
[D2DInputComplex(3)]
[D2DShaderProfile(D2D1ShaderProfile.PixelShader50)]
[AutoConstructor]
partial struct ShaderWithoutResourceTextures : ID2D1PixelShader
{
public Float4 Execute()
{
return 0;
}
}
[D2DInputCount(0)]
[D2DShaderProfile(D2D1ShaderProfile.PixelShader50)]
[AutoConstructor]
partial struct ShaderWithJustOneResourceTextures : ID2D1PixelShader
{
[D2DResourceTextureIndex(0)]
D2D1ResourceTexture1D<float> myTexture;
public Float4 Execute()
{
return this.myTexture.Sample(0);
}
}
[D2DInputCount(4)]
[D2DInputSimple(0)]
[D2DInputSimple(2)]