ComputeSharp.D2D1 3.0.0-preview2

Prefix Reserved
This is a prerelease version of ComputeSharp.D2D1.
This package has a SemVer 2.0.0 package version: 3.0.0-preview2+2f6ab50b9ef0bd2d24c4370165d4144793a68c62.
There is a newer version of this package available.
See the version list below for details.
dotnet add package ComputeSharp.D2D1 --version 3.0.0-preview2                
NuGet\Install-Package ComputeSharp.D2D1 -Version 3.0.0-preview2                
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.0.0-preview2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ComputeSharp.D2D1 --version 3.0.0-preview2                
#r "nuget: ComputeSharp.D2D1, 3.0.0-preview2"                
#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.0.0-preview2&prerelease

// Install ComputeSharp.D2D1 as a Cake Tool
#tool nuget:?package=ComputeSharp.D2D1&version=3.0.0-preview2&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.Uwp

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

ComputeSharp.D2D1.WinUI

A WinUI 3 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.0.1 57 6/18/2024
3.0.0 53 6/10/2024
3.0.0-preview2 195 12/17/2023
3.0.0-preview1 96 11/24/2023
2.2.0-preview1 146 10/10/2023
2.1.0 307 9/27/2023
2.1.0-preview3 108 7/9/2023
2.1.0-preview2 567 5/1/2023
2.1.0-preview1 76 4/27/2023
2.0.3 434 12/24/2022
2.0.2 84 12/9/2022
2.0.0 130 11/29/2022
2.0.0-preview2 105 10/22/2022
2.0.0-preview1 117 10/8/2022
2.0.0-alpha.29 95 9/19/2022
2.0.0-alpha.28 105 9/6/2022
2.0.0-alpha.27 135 8/22/2022
2.0.0-alpha.26 111 8/1/2022
2.0.0-alpha.25 121 6/6/2022
2.0.0-alpha.24 122 5/24/2022
2.0.0-alpha.23 118 5/12/2022
2.0.0-alpha.22 125 4/24/2022
2.0.0-alpha.21 125 4/21/2022