ComputeSharp.D2D1 3.1.0

Prefix Reserved
This package has a SemVer 2.0.0 package version: 3.1.0+120aff270539996ef9fc52fe46561d12da0b89d4.
dotnet add package ComputeSharp.D2D1 --version 3.1.0                
NuGet\Install-Package ComputeSharp.D2D1 -Version 3.1.0                
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" />                
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                
#r "nuget: ComputeSharp.D2D1, 3.1.0"                
#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

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

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 51 12/24/2024
3.1.0-preview2 148 10/22/2024
3.1.0-preview1 94 9/19/2024
3.0.1 260 6/18/2024
3.0.0 73 6/10/2024
3.0.0-preview2 216 12/17/2023
3.0.0-preview1 117 11/24/2023
2.2.0-preview2 50 10/14/2024
2.2.0-preview1 171 10/10/2023
2.1.0 399 9/27/2023
2.1.0-preview3 124 7/9/2023
2.1.0-preview2 588 5/1/2023
2.1.0-preview1 95 4/27/2023
2.0.3 458 12/24/2022
2.0.2 108 12/9/2022
2.0.0 155 11/29/2022
2.0.0-preview2 124 10/22/2022
2.0.0-preview1 137 10/8/2022
2.0.0-alpha.29 115 9/19/2022
2.0.0-alpha.28 126 9/6/2022
2.0.0-alpha.27 155 8/22/2022
2.0.0-alpha.26 128 8/1/2022
2.0.0-alpha.25 139 6/6/2022
2.0.0-alpha.24 138 5/24/2022
2.0.0-alpha.23 135 5/12/2022
2.0.0-alpha.22 143 4/24/2022
2.0.0-alpha.21 142 4/21/2022