Add unit tests for new And and Or intrinsics
このコミットが含まれているのは:
1 親
2d5d229b43
コミット
4f1e3aa946
2ファイル変更
+119
検索条件に一致するファイルはありません
@@ -129,4 +129,54 @@ public partial class ShaderRewriterTests
|
||||
return new(f2x2_r.M11, f2x2_r.M12, f2x2_r.M21, f2x2_r.M22);
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void KnownNamedIntrinsic_AndOr()
|
||||
{
|
||||
D2D1ShaderInfo shaderInfo = D2D1ReflectionServices.GetShaderInfo<KnownNamedIntrinsic_AndOrShader>();
|
||||
|
||||
Assert.AreEqual("""
|
||||
#define D2D_INPUT_COUNT 0
|
||||
|
||||
#include "d2d1effecthelpers.hlsli"
|
||||
|
||||
D2D_PS_ENTRY(Execute)
|
||||
{
|
||||
bool4 mask4_1 = bool4(true, false, true, true);
|
||||
bool4 mask4_2 = bool4(true, false, true, true);
|
||||
bool4 mask4_r_and = (mask4_1 && mask4_2);
|
||||
bool4 mask4_r_or = (mask4_1 || mask4_2);
|
||||
bool2x3 mask2x3_1 = bool2x3((bool)true, (bool)false, (bool)true, (bool)true, (bool)false, (bool)false);
|
||||
bool2x3 mask2x3_2 = bool2x3((bool)true, (bool)false, (bool)true, (bool)true, (bool)true, (bool)true);
|
||||
bool2x3 mask2x3_r_and = (mask2x3_1 && mask2x3_2);
|
||||
bool2x3 mask2x3_r_or = (mask2x3_1 || mask2x3_2);
|
||||
return float4(mask4_r_and.x ? 1 : 0, mask4_r_or.y ? 1 : 0, mask2x3_r_and._m00 ? 1 : 0, mask2x3_r_or._m00 ? 1 : 0);
|
||||
}
|
||||
""", shaderInfo.HlslSource);
|
||||
}
|
||||
|
||||
[D2DInputCount(0)]
|
||||
[D2DShaderProfile(D2D1ShaderProfile.PixelShader50)]
|
||||
[D2DGeneratedPixelShaderDescriptor]
|
||||
internal readonly partial struct KnownNamedIntrinsic_AndOrShader : ID2D1PixelShader
|
||||
{
|
||||
public float4 Execute()
|
||||
{
|
||||
bool4 mask4_1 = new(true, false, true, true);
|
||||
bool4 mask4_2 = new(true, false, true, true);
|
||||
bool4 mask4_r_and = Hlsl.And(mask4_1, mask4_2);
|
||||
bool4 mask4_r_or = Hlsl.Or(mask4_1, mask4_2);
|
||||
|
||||
bool2x3 mask2x3_1 = new(true, false, true, true, false, false);
|
||||
bool2x3 mask2x3_2 = new(true, false, true, true, true, true);
|
||||
bool2x3 mask2x3_r_and = Hlsl.And(mask2x3_1, mask2x3_2);
|
||||
bool2x3 mask2x3_r_or = Hlsl.Or(mask2x3_1, mask2x3_2);
|
||||
|
||||
return new(
|
||||
mask4_r_and.X ? 1 : 0,
|
||||
mask4_r_or.Y ? 1 : 0,
|
||||
mask2x3_r_and.M11 ? 1 : 0,
|
||||
mask2x3_r_or.M11 ? 1 : 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1192,4 +1192,73 @@ public partial class ShaderRewriterTests
|
||||
buffer3[7] = uint2x4_r.M24;
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void KnownNamedIntrinsic_AndOr()
|
||||
{
|
||||
ShaderInfo info = ReflectionServices.GetShaderInfo<KnownNamedIntrinsic_AndOrShader>();
|
||||
|
||||
Assert.AreEqual(
|
||||
"""
|
||||
#define __GroupSize__get_X 64
|
||||
#define __GroupSize__get_Y 1
|
||||
#define __GroupSize__get_Z 1
|
||||
|
||||
cbuffer _ : register(b0)
|
||||
{
|
||||
uint __x;
|
||||
uint __y;
|
||||
uint __z;
|
||||
}
|
||||
|
||||
RWStructuredBuffer<float> __reserved__buffer : register(u0);
|
||||
|
||||
[NumThreads(__GroupSize__get_X, __GroupSize__get_Y, __GroupSize__get_Z)]
|
||||
void Execute(uint3 ThreadIds : SV_DispatchThreadID)
|
||||
{
|
||||
if (ThreadIds.x < __x && ThreadIds.y < __y && ThreadIds.z < __z)
|
||||
{
|
||||
bool4 mask4_1 = bool4(true, false, true, true);
|
||||
bool4 mask4_2 = bool4(true, false, true, true);
|
||||
bool4 mask4_r_and = and(mask4_1, mask4_2);
|
||||
bool4 mask4_r_or = or(mask4_1, mask4_2);
|
||||
bool2x3 mask2x3_1 = bool2x3((bool)true, (bool)false, (bool)true, (bool)true, (bool)false, (bool)false);
|
||||
bool2x3 mask2x3_2 = bool2x3((bool)true, (bool)false, (bool)true, (bool)true, (bool)true, (bool)true);
|
||||
bool2x3 mask2x3_r_and = and(mask2x3_1, mask2x3_2);
|
||||
bool2x3 mask2x3_r_or = or(mask2x3_1, mask2x3_2);
|
||||
__reserved__buffer[0] = mask4_r_and.x ? 1 : 0;
|
||||
__reserved__buffer[1] = mask4_r_or.y ? 1 : 0;
|
||||
__reserved__buffer[2] = mask2x3_r_and._m00 ? 1 : 0;
|
||||
__reserved__buffer[3] = mask2x3_r_or._m00 ? 1 : 0;
|
||||
}
|
||||
}
|
||||
""",
|
||||
info.HlslSource);
|
||||
}
|
||||
|
||||
[AutoConstructor]
|
||||
[ThreadGroupSize(DefaultThreadGroupSizes.X)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct KnownNamedIntrinsic_AndOrShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteBuffer<float> buffer;
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
bool4 mask4_1 = new(true, false, true, true);
|
||||
bool4 mask4_2 = new(true, false, true, true);
|
||||
bool4 mask4_r_and = Hlsl.And(mask4_1, mask4_2);
|
||||
bool4 mask4_r_or = Hlsl.Or(mask4_1, mask4_2);
|
||||
|
||||
bool2x3 mask2x3_1 = new(true, false, true, true, false, false);
|
||||
bool2x3 mask2x3_2 = new(true, false, true, true, true, true);
|
||||
bool2x3 mask2x3_r_and = Hlsl.And(mask2x3_1, mask2x3_2);
|
||||
bool2x3 mask2x3_r_or = Hlsl.Or(mask2x3_1, mask2x3_2);
|
||||
|
||||
buffer[0] = mask4_r_and.X ? 1 : 0;
|
||||
buffer[1] = mask4_r_or.Y ? 1 : 0;
|
||||
buffer[2] = mask2x3_r_and.M11 ? 1 : 0;
|
||||
buffer[3] = mask2x3_r_or.M11 ? 1 : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする