Move D2D1 pixel shaders to shared project

このコミットが含まれているのは:
Sergio Pedri committed 2023-01-21 20:03:25 +01:00
1 親 146d53eafe
コミット 1ec2dad382
17ファイル変更
+113 -46

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

+5
ファイルの表示
@@ -130,6 +130,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{B86A48A7-18B
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputeSharp.D2D1.Uwp", "src\ComputeSharp.D2D1.Uwp\ComputeSharp.D2D1.Uwp.csproj", "{E60A3B1E-FC5D-41AC-ACF0-C2D75B6590D2}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "ComputeSharp.SwapChain.Shaders.D2D1.Shared", "samples\ComputeSharp.SwapChain.Shaders.D2D1.Shared\ComputeSharp.SwapChain.Shaders.D2D1.Shared.shproj", "{F8BF7666-7CCF-4FE4-B055-2EBA4BCD4564}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
@@ -411,6 +413,7 @@ Global
{5DE90C85-ED26-4B5A-A0D7-2FF966A210AC} = {F8EFBB27-4EE2-4463-A75B-7EFDFB55D0F7}
{669A414F-3B46-4B55-B587-061AF63C3067} = {F8EFBB27-4EE2-4463-A75B-7EFDFB55D0F7}
{B86A48A7-18BD-4946-B995-3CE26B092DDF} = {1A9C4108-F61A-4ABE-B5CF-F524521EAE2D}
{F8BF7666-7CCF-4FE4-B055-2EBA4BCD4564} = {0ED8F632-5E17-46BE-8CC3-B14A82D4AEB1}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4664C5E3-0340-4E22-BCFD-98AAEDF5F2DC}
@@ -421,6 +424,7 @@ Global
samples\ComputeSharp.SwapChain.Shaders.Shared\ComputeSharp.SwapChain.Shaders.Shared.projitems*{0800bd51-499d-44c2-9417-fd1f7fdfe9c4}*SharedItemsImports = 13
src\ComputeSharp.UI\ComputeSharp.UI.projitems*{0c82ede1-5b8a-4df3-87da-700b29d5e265}*SharedItemsImports = 13
src\TerraFX.Interop.Windows.Dynamic\TerraFX.Interop.Windows.Dynamic.projitems*{158f984d-cd96-4062-bd02-2268946031a0}*SharedItemsImports = 13
samples\ComputeSharp.SwapChain.Shaders.D2D1.Shared\ComputeSharp.SwapChain.Shaders.D2D1.Shared.projitems*{209c95a3-fa53-431b-b688-3299ca6c29d2}*SharedItemsImports = 5
src\TerraFX.Interop.Windows\TerraFX.Interop.Windows.projitems*{314eb353-e7e3-4146-8111-685cc83ec1de}*SharedItemsImports = 5
src\TerraFX.Interop.Windows.D2D1\TerraFX.Interop.Windows.D2D1.projitems*{4d7d9ba8-a821-4b1c-9ee2-cbcf5849906e}*SharedItemsImports = 5
src\TerraFX.Interop.Windows\TerraFX.Interop.Windows.projitems*{514ff00e-bbf0-4d55-a47c-eeeb6208adce}*SharedItemsImports = 13
@@ -446,6 +450,7 @@ Global
src\ComputeSharp.SourceGeneration\ComputeSharp.SourceGeneration.projitems*{eb52cb67-4162-4722-874b-44ea8da5450e}*SharedItemsImports = 5
src\TerraFX.Interop.Windows.Dynamic\TerraFX.Interop.Windows.Dynamic.projitems*{eb52cb67-4162-4722-874b-44ea8da5450e}*SharedItemsImports = 5
src\TerraFX.Interop.Windows\TerraFX.Interop.Windows.projitems*{eb52cb67-4162-4722-874b-44ea8da5450e}*SharedItemsImports = 5
samples\ComputeSharp.SwapChain.Shaders.D2D1.Shared\ComputeSharp.SwapChain.Shaders.D2D1.Shared.projitems*{f8bf7666-7ccf-4fe4-b055-2eba4bcd4564}*SharedItemsImports = 13
src\ComputeSharp.UI\ComputeSharp.UI.projitems*{fa18ba9f-76bf-4de0-8d24-02fc7657e6cb}*SharedItemsImports = 5
samples\ComputeSharp.SwapChain.Core.Shared\ComputeSharp.SwapChain.Core.Shared.projitems*{fbd388a5-7855-4408-98ff-e689f509db5a}*SharedItemsImports = 4
samples\ComputeSharp.SwapChain.Shaders.Shared\ComputeSharp.SwapChain.Shaders.Shared.projitems*{fbd388a5-7855-4408-98ff-e689f509db5a}*SharedItemsImports = 4
@@ -1,4 +1,6 @@
namespace ComputeSharp.D2D1.Tests.Shaders;
using ComputeSharp.D2D1;
namespace ComputeSharp.SwapChain.Shaders.D2D1;
/// <summary>
/// A shader creating an abstract and colorful animation.
@@ -15,12 +17,12 @@ internal readonly partial struct ColorfulInfinity : ID2D1PixelShader
/// <summary>
/// The current time since the start of the application.
/// </summary>
public readonly float time;
private readonly float time;
/// <summary>
/// The dispatch size for the current output.
/// </summary>
public readonly int2 dispatchSize;
private readonly int2 dispatchSize;
/// <summary>
/// The total number of layers for the final animation.
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects Condition="'$(MSBuildVersion)' == '' Or '$(MSBuildVersion)' &lt; '16.0'">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<HasSharedItems>true</HasSharedItems>
<SharedGUID>f8bf7666-7ccf-4fe4-b055-2eba4bcd4564</SharedGUID>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<Import_RootNamespace>ComputeSharp.SwapChain.Shaders.D2D1.Shared</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)ColorfulInfinity.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ContouredLayers.cs" />
<Compile Include="$(MSBuildThisFileDirectory)FractalTiling.cs" />
<Compile Include="$(MSBuildThisFileDirectory)HelloWorld.cs" />
<Compile Include="$(MSBuildThisFileDirectory)MengerJourney.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Octagrams.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ProteanClouds.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PyramidPattern.cs" />
<Compile Include="$(MSBuildThisFileDirectory)TerracedHills.cs" />
<Compile Include="$(MSBuildThisFileDirectory)TriangleGridContouring.cs" />
<Compile Include="$(MSBuildThisFileDirectory)TwoTiledTruchet.cs" />
</ItemGroup>
</Project>
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>f8bf7666-7ccf-4fe4-b055-2eba4bcd4564</ProjectGuid>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
<PropertyGroup />
<Import Project="ComputeSharp.SwapChain.Shaders.D2D1.Shared.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
</Project>
@@ -1,4 +1,6 @@
namespace ComputeSharp.D2D1.Tests.Shaders;
using ComputeSharp.D2D1;
namespace ComputeSharp.SwapChain.Shaders.D2D1;
/// <summary>
/// Constructing some concise contoured layers, then applying various edge and shading effects to produce some faux depth.
@@ -19,7 +21,7 @@ internal readonly partial struct ContouredLayers : ID2D1PixelShader
/// <summary>
/// The dispatch size for the current output.
/// </summary>
public readonly int2 dispatchSize;
private readonly int2 dispatchSize;
/// <summary>
/// The background texture to sample.
@@ -1,4 +1,6 @@
namespace ComputeSharp.D2D1.Tests.Shaders;
using ComputeSharp.D2D1;
namespace ComputeSharp.SwapChain.Shaders.D2D1;
/// <summary>
/// A shader creating a fractal tiling animation.
@@ -15,12 +17,12 @@ internal readonly partial struct FractalTiling : ID2D1PixelShader
/// <summary>
/// The current time since the start of the application.
/// </summary>
public readonly float time;
private readonly float time;
/// <summary>
/// The dispatch size for the current output.
/// </summary>
public readonly int2 dispatchSize;
private readonly int2 dispatchSize;
/// <inheritdoc/>
public float4 Execute()
@@ -1,4 +1,6 @@
namespace ComputeSharp.D2D1.Tests.Shaders;
using ComputeSharp.D2D1;
namespace ComputeSharp.SwapChain.Shaders.D2D1;
/// <summary>
/// A simple shader to get started with based on shadertoy new shader template.
@@ -13,12 +15,12 @@ internal readonly partial struct HelloWorld : ID2D1PixelShader
/// <summary>
/// The current time since the start of the application.
/// </summary>
public readonly float time;
private readonly float time;
/// <summary>
/// The dispatch size for the current output.
/// </summary>
public readonly int2 dispatchSize;
private readonly int2 dispatchSize;
/// <inheritdoc/>
public float4 Execute()
@@ -1,4 +1,6 @@
namespace ComputeSharp.D2D1.Tests.Shaders;
using ComputeSharp.D2D1;
namespace ComputeSharp.SwapChain.Shaders.D2D1;
/// <summary>
/// A shader creating a flythrough in a Menger system.
@@ -14,12 +16,12 @@ internal readonly partial struct MengerJourney : ID2D1PixelShader
/// <summary>
/// The current time since the start of the application.
/// </summary>
public readonly float time;
private readonly float time;
/// <summary>
/// The dispatch size for the current output.
/// </summary>
public readonly int2 dispatchSize;
private readonly int2 dispatchSize;
private const int MaxSteps = 30;
private const float MinimumDistance = 0.0009f;
@@ -1,4 +1,6 @@
namespace ComputeSharp.D2D1.Tests.Shaders;
using ComputeSharp.D2D1;
namespace ComputeSharp.SwapChain.Shaders.D2D1;
/// <summary>
/// A shader creating an octagram animation, inspired by arabesque.
@@ -14,12 +16,12 @@ internal readonly partial struct Octagrams : ID2D1PixelShader
/// <summary>
/// The current time since the start of the application.
/// </summary>
public readonly float time;
private readonly float time;
/// <summary>
/// The dispatch size for the current output.
/// </summary>
public readonly int2 dispatchSize;
private readonly int2 dispatchSize;
private static float2x2 Rotate(float a)
{
@@ -1,4 +1,6 @@
namespace ComputeSharp.D2D1.Tests.Shaders;
using ComputeSharp.D2D1;
namespace ComputeSharp.SwapChain.Shaders.D2D1;
/// <summary>
/// Fully procedural 3D animated volume with three evaluations per step (for shading).
@@ -15,14 +17,14 @@ internal readonly partial struct ProteanClouds : ID2D1PixelShader
/// <summary>
/// The current time Hlsl.Since the start of the application.
/// </summary>
public readonly float time;
private readonly float time;
/// <summary>
/// The dispatch size for the current output.
/// </summary>
public readonly int2 dispatchSize;
private readonly int2 dispatchSize;
private static readonly float3x3 m3 = new float3x3(0.33338f, 0.56034f, -0.71817f, -0.87887f, 0.32651f, -0.15323f, 0.15162f, 0.69596f, 0.61339f) * 1.93f;
private static readonly float3x3 M3 = new float3x3(0.33338f, 0.56034f, -0.71817f, -0.87887f, 0.32651f, -0.15323f, 0.15162f, 0.69596f, 0.61339f) * 1.93f;
private static float2x2 Rotate(in float a)
{
@@ -65,7 +67,7 @@ internal readonly partial struct ProteanClouds : ID2D1PixelShader
z *= 0.57f;
trk *= 1.4f;
p = Hlsl.Mul(p, m3);
p = Hlsl.Mul(p, M3);
}
d = Hlsl.Abs(d + (prm1 * 3.0f)) + (prm1 * 0.3f) - 2.5f + bsMo.Y;
@@ -1,4 +1,6 @@
namespace ComputeSharp.D2D1.Tests.Shaders;
using ComputeSharp.D2D1;
namespace ComputeSharp.SwapChain.Shaders.D2D1;
/// <summary>
/// An offset grid of square-based pyramids whose tips have been offset according to an underlying directional noise field.
@@ -15,12 +17,12 @@ internal readonly partial struct PyramidPattern : ID2D1PixelShader
/// <summary>
/// The current time Hlsl.Since the start of the application.
/// </summary>
public readonly float time;
private readonly float time;
/// <summary>
/// The dispatch size for the current output.
/// </summary>
public readonly int2 dispatchSize;
private readonly int2 dispatchSize;
// Standard 2D rotation formula.
private static float2x2 Rotate2x2(in float a)
@@ -1,4 +1,6 @@
namespace ComputeSharp.D2D1.Tests.Shaders;
using ComputeSharp.D2D1;
namespace ComputeSharp.SwapChain.Shaders.D2D1;
/// <summary>
/// An abstract representation of some terraced hills. In essence, just a very basic terrain layout with a small code footprint.
@@ -19,7 +21,7 @@ internal readonly partial struct TerracedHills : ID2D1PixelShader
/// <summary>
/// The dispatch size for the current output.
/// </summary>
public readonly int2 dispatchSize;
private readonly int2 dispatchSize;
// 2x2 matrix rotation. Angle vector, courtesy of Fabrice
private static float2x2 Rot2(float th)
@@ -1,4 +1,6 @@
namespace ComputeSharp.D2D1.Tests.Shaders;
using ComputeSharp.D2D1;
namespace ComputeSharp.SwapChain.Shaders.D2D1;
/// <summary>
/// Utilizing a 2D simplex grid to construct the isolines of a noise function.
@@ -14,12 +16,12 @@ internal readonly partial struct TriangleGridContouring : ID2D1PixelShader
/// <summary>
/// The current time Hlsl.Since the start of the application.
/// </summary>
public readonly float time;
private readonly float time;
/// <summary>
/// The dispatch size for the current output.
/// </summary>
public readonly int2 dispatchSize;
private readonly int2 dispatchSize;
// Standard 2D rotation formula.
private static float2x2 Rotate2x2(in float a)
@@ -1,4 +1,6 @@
namespace ComputeSharp.D2D1.Tests.Shaders;
using ComputeSharp.D2D1;
namespace ComputeSharp.SwapChain.Shaders.D2D1;
/// <summary>
/// A shader creating an animated two-tiles Truchet arrangement.
@@ -14,12 +16,12 @@ internal readonly partial struct TwoTiledTruchet : ID2D1PixelShader
/// <summary>
/// The current time since the start of the application.
/// </summary>
public readonly float time;
private readonly float time;
/// <summary>
/// The dispatch size for the current output.
/// </summary>
public readonly int2 dispatchSize;
private readonly int2 dispatchSize;
/// <summary>
/// Calculates the Truchet distance field.
+2
ファイルの表示
@@ -100,4 +100,6 @@
<None Include="..\..\samples\ComputeSharp.SwapChain\Textures\RustyMetal.png" Link="Assets\Textures\RustyMetal.png" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
<Import Project="..\..\samples\ComputeSharp.SwapChain.Shaders.D2D1.Shared\ComputeSharp.SwapChain.Shaders.D2D1.Shared.projitems" Label="Shared" />
</Project>
+1 -1
ファイルの表示
@@ -4,7 +4,7 @@ using System.Reflection;
using System.Runtime.InteropServices;
using ComputeSharp.D2D1.Interop;
using ComputeSharp.D2D1.Tests.Helpers;
using ComputeSharp.D2D1.Tests.Shaders;
using ComputeSharp.SwapChain.Shaders.D2D1;
using ComputeSharp.Tests.Helpers;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Win32;
+13 -12
ファイルの表示
@@ -4,6 +4,7 @@ using System.Reflection;
using System.Runtime.InteropServices;
using ComputeSharp.D2D1.Interop;
using ComputeSharp.D2D1.Tests.Helpers;
using ComputeSharp.SwapChain.Shaders.D2D1;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
@@ -17,25 +18,25 @@ public class ShadersTests
[TestMethod]
public void HelloWorld()
{
RunTest<Shaders.HelloWorld>();
RunTest<HelloWorld>();
}
[TestMethod]
public void ColorfulInfinity()
{
RunTest<Shaders.ColorfulInfinity>();
RunTest<ColorfulInfinity>();
}
[TestMethod]
public void FractalTiling()
{
RunTest<Shaders.FractalTiling>();
RunTest<FractalTiling>();
}
[TestMethod]
public void MengerJourney()
{
RunTest<Shaders.MengerJourney>(0.000011f);
RunTest<MengerJourney>(0.000011f);
}
// This test and the other 3 below are skipped because they do produce valid result,
@@ -46,33 +47,33 @@ public class ShadersTests
[Ignore]
public void TwoTiledTruchet()
{
RunTest<Shaders.TwoTiledTruchet>();
RunTest<TwoTiledTruchet>();
}
[TestMethod]
public void Octagrams()
{
RunTest<Shaders.Octagrams>();
RunTest<Octagrams>();
}
[TestMethod]
public void ProteanClouds()
{
RunTest<Shaders.ProteanClouds>();
RunTest<ProteanClouds>();
}
[TestMethod]
[Ignore]
public void PyramidPattern()
{
RunTest<Shaders.PyramidPattern>();
RunTest<PyramidPattern>();
}
[TestMethod]
[Ignore]
public void TriangleGridContouring()
{
RunTest<Shaders.TriangleGridContouring>();
RunTest<TriangleGridContouring>();
}
[TestMethod]
@@ -101,15 +102,15 @@ public class ShadersTests
strides: stackalloc uint[] { (uint)(texture.Width * sizeof(Rgba32)) });
}
Shaders.ContouredLayers shader = new(0f, new int2(1280, 720));
ContouredLayers shader = new(0f, new int2(1280, 720));
D2D1TestRunner.RunAndCompareShader(in shader, 1280, 720, $"{nameof(Shaders.ContouredLayers)}.png", nameof(Shaders.ContouredLayers), resourceTextures: (0, resourceTextureManager));
D2D1TestRunner.RunAndCompareShader(in shader, 1280, 720, $"{nameof(ContouredLayers)}.png", nameof(ContouredLayers), resourceTextures: (0, resourceTextureManager));
}
[TestMethod]
public void TerracedHills()
{
RunTest<Shaders.TerracedHills>(0.000026f);
RunTest<TerracedHills>(0.000026f);
}
private static void RunTest<T>(float threshold = 0.00001f)