Use raw multiline string literals in D2D1 tests, add UTF8 test
このコミットが含まれているのは:
1 親
a34d70d280
コミット
f3bb5a5daa
1ファイル変更
+47
-16
@@ -12,18 +12,19 @@ public partial class D2D1ShaderCompilerTests
|
||||
[TestMethod]
|
||||
public unsafe void CompileInvertEffectWithDefaultOptions()
|
||||
{
|
||||
const string source = @"
|
||||
const string source = """
|
||||
#define D2D_INPUT_COUNT 1
|
||||
#define D2D_INPUT0_SIMPLE
|
||||
|
||||
#include ""d2d1effecthelpers.hlsli""
|
||||
#include "d2d1effecthelpers.hlsli"
|
||||
|
||||
D2D_PS_ENTRY(PSMain)
|
||||
{
|
||||
float4 color = D2DGetInput(0);
|
||||
float3 rgb = saturate(1.0 - color.rgb);
|
||||
return float4(rgb, 1);
|
||||
}";
|
||||
}
|
||||
""";
|
||||
|
||||
ReadOnlyMemory<byte> bytecode = D2D1ShaderCompiler.Compile(
|
||||
source,
|
||||
@@ -35,20 +36,47 @@ public partial class D2D1ShaderCompilerTests
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public unsafe void CompileInvertEffectWithDefaultOptionsAndLinking()
|
||||
public unsafe void CompileInvertEffectWithDefaultOptions_Utf8()
|
||||
{
|
||||
const string source = @"
|
||||
ReadOnlySpan<byte> sourceUtf8 = """
|
||||
#define D2D_INPUT_COUNT 1
|
||||
#define D2D_INPUT0_SIMPLE
|
||||
|
||||
#include ""d2d1effecthelpers.hlsli""
|
||||
#include "d2d1effecthelpers.hlsli"
|
||||
|
||||
D2D_PS_ENTRY(PSMain)
|
||||
{
|
||||
float4 color = D2DGetInput(0);
|
||||
float3 rgb = saturate(1.0 - color.rgb);
|
||||
return float4(rgb, 1);
|
||||
}";
|
||||
}
|
||||
"""u8;
|
||||
|
||||
ReadOnlyMemory<byte> bytecode = D2D1ShaderCompiler.Compile(
|
||||
sourceUtf8,
|
||||
"PSMain"u8,
|
||||
D2D1ShaderProfile.PixelShader40Level93,
|
||||
D2D1CompileOptions.Default);
|
||||
|
||||
Assert.IsTrue(bytecode.Length > 0);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public unsafe void CompileInvertEffectWithDefaultOptionsAndLinking()
|
||||
{
|
||||
const string source = """
|
||||
#define D2D_INPUT_COUNT 1
|
||||
#define D2D_INPUT0_SIMPLE
|
||||
|
||||
#include "d2d1effecthelpers.hlsli"
|
||||
|
||||
D2D_PS_ENTRY(PSMain)
|
||||
{
|
||||
float4 color = D2DGetInput(0);
|
||||
float3 rgb = saturate(1.0 - color.rgb);
|
||||
return float4(rgb, 1);
|
||||
}
|
||||
""";
|
||||
|
||||
ReadOnlyMemory<byte> bytecode = D2D1ShaderCompiler.Compile(
|
||||
source,
|
||||
@@ -63,18 +91,19 @@ public partial class D2D1ShaderCompilerTests
|
||||
[ExpectedException(typeof(FxcCompilationException))]
|
||||
public unsafe void CompileInvertEffectWithInvalidEntryPoint()
|
||||
{
|
||||
const string source = @"
|
||||
const string source = """
|
||||
#define D2D_INPUT_COUNT 1
|
||||
#define D2D_INPUT0_SIMPLE
|
||||
|
||||
#include ""d2d1effecthelpers.hlsli""
|
||||
#include "d2d1effecthelpers.hlsli"
|
||||
|
||||
D2D_PS_ENTRY(PSMain)
|
||||
{
|
||||
float4 color = D2DGetInput(0);
|
||||
float3 rgb = saturate(1.0 - color.rgb);
|
||||
return float4(rgb, 1);
|
||||
}";
|
||||
}
|
||||
""";
|
||||
|
||||
ReadOnlyMemory<byte> bytecode = D2D1ShaderCompiler.Compile(
|
||||
source,
|
||||
@@ -89,18 +118,19 @@ public partial class D2D1ShaderCompilerTests
|
||||
[ExpectedException(typeof(FxcCompilationException))]
|
||||
public unsafe void CompileInvertEffectWithErrors()
|
||||
{
|
||||
const string source = @"
|
||||
const string source = """
|
||||
#define D2D_INPUT_COUNT 1
|
||||
#define D2D_INPUT0_SIMPLE
|
||||
|
||||
#include ""d2d1effecthelpers.hlsli""
|
||||
#include "d2d1effecthelpers.hlsli"
|
||||
|
||||
D2D_PS_ENTRY(PSMain)
|
||||
{
|
||||
float4 color = D2DGetInput(99);
|
||||
float3 rgb2 = saturate(1.0 - color.rgb);
|
||||
return float4(rgb, 1, 4.0);
|
||||
}";
|
||||
}
|
||||
""";
|
||||
|
||||
ReadOnlyMemory<byte> bytecode = D2D1ShaderCompiler.Compile(
|
||||
source,
|
||||
@@ -114,12 +144,12 @@ public partial class D2D1ShaderCompilerTests
|
||||
[TestMethod]
|
||||
public unsafe void CompilePixelateEffectWithDefaultOptions()
|
||||
{
|
||||
const string source = @"
|
||||
const string source = """
|
||||
#define D2D_INPUT_COUNT 1
|
||||
#define D2D_INPUT0_COMPLEX
|
||||
#define D2D_REQUIRES_SCENE_POSITION
|
||||
|
||||
#include ""d2d1effecthelpers.hlsli""
|
||||
#include "d2d1effecthelpers.hlsli"
|
||||
|
||||
struct ComputeSharp_D2D1_Tests_Effects_PixelateEffect_Shader_Constants
|
||||
{
|
||||
@@ -147,7 +177,8 @@ public partial class D2D1ShaderCompilerTests
|
||||
float4 sample3 = D2DSampleInputAtPosition(0, int2(x1, y1));
|
||||
float4 color = (sample0 + sample1 + sample2 + sample3) / 4;
|
||||
return color;
|
||||
}";
|
||||
}
|
||||
""";
|
||||
|
||||
ReadOnlyMemory<byte> bytecode = D2D1ShaderCompiler.Compile(
|
||||
source,
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする