ComputeSharp.D2D1 3.1.0-preview1

Prefix Reserved
This is a prerelease version of ComputeSharp.D2D1.
This package has a SemVer 2.0.0 package version: 3.1.0-preview1+57f0a9b583f64f2a22978aab5afac4482fa0f94b.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package ComputeSharp.D2D1 --version 3.1.0-preview1                
NuGet\Install-Package ComputeSharp.D2D1 -Version 3.1.0-preview1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ComputeSharp.D2D1" Version="3.1.0-preview1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ComputeSharp.D2D1 --version 3.1.0-preview1                
#r "nuget: ComputeSharp.D2D1, 3.1.0-preview1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install ComputeSharp.D2D1 as a Cake Addin
#addin nuget:?package=ComputeSharp.D2D1&version=3.1.0-preview1&prerelease

// Install ComputeSharp.D2D1 as a Cake Tool
#tool nuget:?package=ComputeSharp.D2D1&version=3.1.0-preview1&prerelease                

ComputeSharp cover image

Overview 📖

ComputeSharp.D2D1 is a library to write D2D1 pixel shaders entirely with C# code, and to easily register and create ID2D1Effect-s from them. This shares the same base APIs (primitives, intrinsics, etc.) as ComputeSharp, but then adds D2D1 specific support, instead of using DX12 compute shaders like the main package. This means it offers the ability to implement D2D1 pixel shaders, and to then either load them manually, or to register a D2D1 effect using them, optionally with a custom draw transform as well.

Quick start 🚀

Here's a simple D2D1 pixel shader written using ComputeSharp.D2D1:

[D2DInputCount(1)]
[D2DInputSimple(0)]
[D2DShaderProfile(D2D1ShaderProfile.PixelShader50)]
[D2DGeneratedPixelShaderDescriptor]
public readonly partial struct DifferenceEffect(float amount) : ID2D1PixelShader
{
    /// <inheritdoc/>
    public float4 Execute()
    {
        float4 color = D2D.GetInput(0);
        float3 rgb = Hlsl.Saturate(this.amount - color.RGB);

        return new(rgb, 1);
    }
}

This can then be used directly to get the shader bytecode and the buffer, like so:

ReadOnlyMemory<byte> bytecode = D2D1PixelShader.LoadBytecode<DifferenceEffect>();
ReadOnlyMemory<byte> buffer = D2D1PixelShader.GetConstantBuffer(new DifferenceEffect(1));

There are also several other APIs to easily register a pixel shader effect from a shader written using ComputeSharp.D2D1, and to then create an ID2D1Effect instance from it (from the D2D1PixelShaderEffect type), as well as for reflecting into a shader and extract information about it, such as its HLSL source code (from the D2D1ReflectionServices type).

There's more!

For a complete list of all features available in ComputeSharp, check the documentation in the GitHub repo.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on ComputeSharp.D2D1:

Package Downloads
ComputeSharp.D2D1.WinUI

A WinUI 3 library with APIs to leverage D2D1 functionality with D2D1 pixel shaders powered by ComputeSharp.D2D1.

ComputeSharp.D2D1.Uwp

A UWP library with APIs to leverage D2D1 functionality with D2D1 pixel shaders powered by ComputeSharp.D2D1.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.1.0-preview2 96 10/22/2024
3.1.0-preview1 83 9/19/2024
3.0.1 223 6/18/2024
3.0.0 66 6/10/2024
3.0.0-preview2 211 12/17/2023
3.0.0-preview1 112 11/24/2023
2.2.0-preview2 41 10/14/2024
2.2.0-preview1 165 10/10/2023
2.1.0 377 9/27/2023
2.1.0-preview3 121 7/9/2023
2.1.0-preview2 581 5/1/2023
2.1.0-preview1 92 4/27/2023
2.0.3 453 12/24/2022
2.0.2 103 12/9/2022
2.0.0 148 11/29/2022
2.0.0-preview2 121 10/22/2022
2.0.0-preview1 134 10/8/2022
2.0.0-alpha.29 112 9/19/2022
2.0.0-alpha.28 123 9/6/2022
2.0.0-alpha.27 151 8/22/2022
2.0.0-alpha.26 125 8/1/2022
2.0.0-alpha.25 136 6/6/2022
2.0.0-alpha.24 135 5/24/2022
2.0.0-alpha.23 132 5/12/2022
2.0.0-alpha.22 140 4/24/2022
2.0.0-alpha.21 139 4/21/2022