Add D3D12 native dependency project (Vortice.D3D12MA.Native) and C# bindings.

This commit is contained in:
Amer Koleci
2025-02-04 12:14:27 +01:00
parent 4699c15c51
commit 30277d58c6
44 changed files with 842 additions and 261 deletions

View File

@@ -20,7 +20,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET 8 SDK
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
global-json-file: ./global.json

View File

@@ -11,13 +11,13 @@
<!-- Version -->
<PropertyGroup>
<VersionPrefix>2.2.6</VersionPrefix>
<VersionPrefix>2.2.7</VersionPrefix>
<VersionSuffix Condition="'$(VersionSuffix)' == ''"></VersionSuffix>
</PropertyGroup>
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
<LangVersion>13.0</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UseArtifactsOutput>true</UseArtifactsOutput>

View File

@@ -7,12 +7,12 @@
<ItemGroup>
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageVersion Include="NUnit" Version="4.1.0" />
<PackageVersion Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageVersion Include="NUnit" Version="4.3.2" />
<PackageVersion Include="NUnit3TestAdapter" Version="4.6.0" />
<!-- Generator -->
<PackageVersion Include="MessagePack" Version="3.0.54-alpha" />
<PackageVersion Include="MessagePack" Version="3.1.3" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<PackageVersion Include="Microsoft.Windows.SDK.Win32Docs" Version="0.1.42-alpha" />
</ItemGroup>

View File

@@ -4,7 +4,7 @@
[![Build status](https://github.com/amerkoleci/Vortice.Win32/workflows/Build/badge.svg)](https://github.com/amerkoleci/Vortice.Win32/actions)
[![NuGet](https://img.shields.io/nuget/v/Vortice.Win32.svg)](https://www.nuget.org/packages/Vortice.Win32)
**Vortice.Win32** is **.net8.0** low-level bindings for Win32, generation is based on json files from [win32json](https://github.com/marlersoft/win32json), follows naming conventions of Vortice.Windows but small GC allocation and using unsafe struct for COM objects.
**Vortice.Win32** is **.net8.0** and **.net9.0** low-level bindings for Win32, generation is based on json files from [win32json](https://github.com/marlersoft/win32json), follows naming conventions of Vortice.Windows but small GC allocation and using unsafe struct for COM objects.
## Sponsors
To further help development of these bindings library or other projects, please consider [SPONSOR](https://github.com/sponsors/amerkoleci) my profile in order to allow faster issue triaging and new features to be implemented.

View File

@@ -11,7 +11,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{08F6
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "01-ClearScreen", "samples\01-ClearScreen\01-ClearScreen.csproj", "{5A10816D-90A4-4AEA-B06E-6A463DA4A891}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{065268A8-16E6-4CFF-8F67-3FD99155877F}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".root", ".root", "{065268A8-16E6-4CFF-8F67-3FD99155877F}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.gitignore = .gitignore
@@ -50,6 +50,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vortice.Dxc.Native", "src\V
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vortice.Pix.Native", "src\Vortice.Pix.Native\Vortice.Pix.Native.csproj", "{E75BA02B-0788-4065-8534-BC3FCF06CC9D}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Native", "Native", "{2B88F597-01D2-4843-BE1E-858855688A4A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vortice.D3D12MA.Native", "src\Vortice.D3D12MA.Native\Vortice.D3D12MA.Native.csproj", "{28E78497-FD58-4C79-A3A2-9FA9509B55F2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vortice.Win32.Graphics.D3D12MemoryAllocator", "src\Vortice.Win32.Graphics.D3D12MemoryAllocator\Vortice.Win32.Graphics.D3D12MemoryAllocator.csproj", "{AC2594D8-0538-4E3B-AC7E-3F40CC07623C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -120,12 +126,23 @@ Global
{E75BA02B-0788-4065-8534-BC3FCF06CC9D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E75BA02B-0788-4065-8534-BC3FCF06CC9D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E75BA02B-0788-4065-8534-BC3FCF06CC9D}.Release|Any CPU.Build.0 = Release|Any CPU
{28E78497-FD58-4C79-A3A2-9FA9509B55F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{28E78497-FD58-4C79-A3A2-9FA9509B55F2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{28E78497-FD58-4C79-A3A2-9FA9509B55F2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{28E78497-FD58-4C79-A3A2-9FA9509B55F2}.Release|Any CPU.Build.0 = Release|Any CPU
{AC2594D8-0538-4E3B-AC7E-3F40CC07623C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AC2594D8-0538-4E3B-AC7E-3F40CC07623C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AC2594D8-0538-4E3B-AC7E-3F40CC07623C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AC2594D8-0538-4E3B-AC7E-3F40CC07623C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{5A10816D-90A4-4AEA-B06E-6A463DA4A891} = {08F6AF96-809B-45C5-BE6C-5BAB7D9AFB60}
{3C579D3B-8239-4707-B906-253181EF52B4} = {2B88F597-01D2-4843-BE1E-858855688A4A}
{E75BA02B-0788-4065-8534-BC3FCF06CC9D} = {2B88F597-01D2-4843-BE1E-858855688A4A}
{28E78497-FD58-4C79-A3A2-9FA9509B55F2} = {2B88F597-01D2-4843-BE1E-858855688A4A}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DF0375B3-E304-4A53-8E5F-FC9D23743647}

View File

@@ -1,6 +1,6 @@
{
"sdk": {
"version": "8.0.100",
"version": "9.0.100",
"rollForward": "latestFeature",
"allowPrerelease": false
}

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net8.0</TargetFrameworks>
<TargetFrameworks>net9.0</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IsPackable>false</IsPackable>
<RootNamespace>ClearScreen</RootNamespace>
@@ -9,6 +9,7 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Vortice.Win32.Graphics.D3D12MemoryAllocator\Vortice.Win32.Graphics.D3D12MemoryAllocator.csproj" />
<ProjectReference Include="..\..\src\Vortice.Win32.Graphics.Direct3D11\Vortice.Win32.Graphics.Direct3D11.csproj" />
<ProjectReference Include="..\..\src\Vortice.Win32.Graphics.Direct3D12\Vortice.Win32.Graphics.Direct3D12.csproj" />
<ProjectReference Include="..\..\src\Vortice.Win32.Graphics.Direct3D11on12\Vortice.Win32.Graphics.Direct3D11on12.csproj" />
@@ -24,12 +25,14 @@
<ItemGroup>
<None Include="..\..\src\Vortice.Dxc.Native\runtimes\win-x64\native\dxil.dll" Link="dxil.dll" Visible="False" CopyToOutputDirectory="PreserveNewest" />
<None Include="..\..\src\Vortice.Dxc.Native\runtimes\win-x64\native\dxcompiler.dll" Link="dxil.dll" Visible="False" CopyToOutputDirectory="PreserveNewest" />
<None Include="..\..\src\Vortice.D3D12MA.Native\runtimes\win-x64\native\D3D12MA.dll" Link="D3D12MA.dll" Visible="False" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
</When>
<When Condition="($([MSBuild]::IsOsPlatform('windows')) and '$(RuntimeIdentifier)'=='') or '$(RuntimeIdentifier)'=='win-arm64'">
<ItemGroup>
<None Include="..\..\src\Vortice.Dxc.Native\runtimes\win-arm64\native\dxil.dll" Link="dxil.dll" Visible="False" CopyToOutputDirectory="PreserveNewest" />
<None Include="..\..\src\Vortice.Dxc.Native\runtimes\win-arm64\native\dxcompiler.dll" Link="dxil.dll" Visible="False" CopyToOutputDirectory="PreserveNewest" />
<None Include="..\..\src\Vortice.D3D12MA.Native\runtimes\win-arm64\native\D3D12MA.dll" Link="D3D12MA.dll" Visible="False" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
</When>
</Choose>

View File

@@ -16,17 +16,22 @@ using Win32.Media.Audio.XAudio2;
using static Win32.Apis;
using static Win32.Graphics.Direct2D.Apis;
using static Win32.Graphics.Direct3D.Dxc.Apis;
using static Win32.Graphics.Direct3D12.Apis;
using static Win32.Graphics.Direct3D11.Apis;
using static Win32.Graphics.DirectWrite.Apis;
using static Win32.Graphics.Dxgi.Apis;
using static Win32.Graphics.Imaging.D2D.Apis;
using static Win32.Media.Audio.XAudio2.Apis;
using static Win32.Graphics.D3D12MemoryAllocator.Apis;
using DWriteFactoryType = Win32.Graphics.DirectWrite.FactoryType;
using FactoryType = Win32.Graphics.Direct2D.FactoryType;
using FeatureLevel = Win32.Graphics.Direct3D.FeatureLevel;
using InfoQueueFilter = Win32.Graphics.Direct3D11.InfoQueueFilter;
using MessageId = Win32.Graphics.Direct3D11.MessageId;
using D3D11MessageSeverity = Win32.Graphics.Direct3D11.MessageSeverity;
using Win32.Graphics.Direct3D12;
using Win32.Graphics.D3D12MemoryAllocator;
namespace ClearScreen;
@@ -147,6 +152,7 @@ public static unsafe class Program
}
using ComPtr<IDXGIAdapter1> adapter = default;
bool supportD3D12 = false;
using ComPtr<IDXGIFactory6> factory6 = default;
if (factory.CopyTo(&factory6).Success)
@@ -165,6 +171,13 @@ public static unsafe class Program
if ((desc.Flags & AdapterFlags.Software) != AdapterFlags.None)
continue;
// Check to see if the adapter supports Direct3D 12, but don't create the actual device yet.
if (D3D12CreateDevice((IUnknown*)adapter.Get(), FeatureLevel.Level_11_0, __uuidof<ID3D12Device>(), null).Success)
{
supportD3D12 = true;
break;
}
break;
//string name = desc.DescriptionStr;
}
@@ -182,15 +195,58 @@ public static unsafe class Program
if ((desc.Flags & AdapterFlags.Software) != AdapterFlags.None)
continue;
// Check to see if the adapter supports Direct3D 12, but don't create the actual device yet.
if (D3D12CreateDevice((IUnknown*)adapter.Get(), FeatureLevel.Level_11_0, __uuidof<ID3D12Device>(), null).Success)
{
supportD3D12 = true;
break;
}
//string name = desc.DescriptionStr;
break;
}
}
ReadOnlySpan<FeatureLevel> featureLevels = stackalloc FeatureLevel[1]
if (supportD3D12)
{
FeatureLevel.Level_11_0
using ComPtr<ID3D12Device> device = default;
// Create the DX12 API device object.
hr = D3D12CreateDevice(
(IUnknown*)adapter.Get(),
FeatureLevel.Level_11_0,
__uuidof<ID3D12Device>(),
device.GetVoidAddressOf()
);
ThrowIfFailed(hr);
AllocatorDesc allocatorDesc = new()
{
pDevice = device.Get(),
pAdapter = (IDXGIAdapter*)adapter.Get()
};
hr = CreateAllocator(in allocatorDesc, out Allocator allocator);
AllocationDesc allocationDesc = new();
allocationDesc.HeapType = HeapType.Default;
using ComPtr<ID3D12Resource> buffer = default;
ResourceDescription bufferDesc = ResourceDescription.Buffer(256u);
Allocation allocation = default;
hr = allocator.CreateResource<ID3D12Resource>(&allocationDesc, in bufferDesc, ResourceStates.Common,
null, &allocation, buffer.GetAddressOf());
//var test = allocator.IsUMA;
ThrowIfFailed(hr);
uint cnt = allocation.Release();
}
else
{
ReadOnlySpan<FeatureLevel> featureLevels =
[
FeatureLevel.Level_11_0
];
CreateDeviceFlags creationFlags = CreateDeviceFlags.BgraSupport;
#if DEBUG
@@ -221,8 +277,8 @@ public static unsafe class Program
using ComPtr<ID3D11InfoQueue> d3dInfoQueue = default;
if (d3dDebug.CopyTo(&d3dInfoQueue).Success)
{
d3dInfoQueue.Get()->SetBreakOnSeverity(MessageSeverity.Corruption, true);
d3dInfoQueue.Get()->SetBreakOnSeverity(MessageSeverity.Error, true);
d3dInfoQueue.Get()->SetBreakOnSeverity(D3D11MessageSeverity.Corruption, true);
d3dInfoQueue.Get()->SetBreakOnSeverity(D3D11MessageSeverity.Error, true);
MessageId* hide = stackalloc MessageId[1]
{
@@ -263,4 +319,5 @@ public static unsafe class Program
ThrowIfFailed(tempDevice.Get()->CreateDepthStencilView(
(ID3D11Resource*)depthStencilTexture.Get(), null, depthStencilTextureView.GetAddressOf()));
}
}
}

View File

@@ -21,8 +21,8 @@ public static class DocGenerator
public static void Generate(string repoRoot, string[] prefixes, string outputPath)
{
using FileStream docsStream = File.OpenRead(Path.Combine(repoRoot, "docs", "apidocs.msgpack"));
var data = MessagePackSerializer.Deserialize<Dictionary<string, ApiDetails>>(docsStream);
var documentationData = new Dictionary<string, ApiDetails>();
Dictionary<string, ApiDetails> data = MessagePackSerializer.Deserialize<Dictionary<string, ApiDetails>>(docsStream);
Dictionary<string, ApiDetails> documentationData = new();
foreach (string key in data.Keys)
{

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<OutputType>Exe</OutputType>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IsPackable>false</IsPackable>

View File

@@ -351,7 +351,7 @@
,"Attrs":[]
,"Params":[
{"Name":"riid","Type":{"Kind":"PointerTo","Child":{"Kind":"Native","Name":"Guid"}},"Attrs":["In","Const"]}
,{"Name":"fence","Type":{"Kind":"PointerTo","Child":{"Kind":"PointerTo","Child":{"Kind":"Native","Name":"Void"}}},"Attrs":["Out","RetVal"]}
,{"Name":"fence","Type":{"Kind":"PointerTo","Child":{"Kind":"PointerTo","Child":{"Kind":"Native","Name":"Void"}}},"Attrs":["Out","RetVal","ComOutPtr"]}
]
}
,{
@@ -667,7 +667,7 @@
,"Params":[
{"Name":"d3dDevice","Type":{"Kind":"ApiRef","Name":"IUnknown","TargetKind":"Com","Api":"System.Com","Parents":[]},"Attrs":["In"]}
,{"Name":"riid","Type":{"Kind":"PointerTo","Child":{"Kind":"Native","Name":"Guid"}},"Attrs":["In","Const"]}
,{"Name":"presentationFactory","Type":{"Kind":"PointerTo","Child":{"Kind":"PointerTo","Child":{"Kind":"Native","Name":"Void"}}},"Attrs":["Out"]}
,{"Name":"presentationFactory","Type":{"Kind":"PointerTo","Child":{"Kind":"PointerTo","Child":{"Kind":"Native","Name":"Void"}}},"Attrs":["Out","ComOutPtr"]}
]
}
]

View File

@@ -9103,7 +9103,7 @@
,{"Name":"Depth","Type":{"Kind":"Native","Name":"Single"},"Attrs":["In"]}
,{"Name":"Stencil","Type":{"Kind":"Native","Name":"Byte"},"Attrs":["In"]}
,{"Name":"NumRects","Type":{"Kind":"Native","Name":"UInt32"},"Attrs":["In"]}
,{"Name":"pRects","Type":{"Kind":"LPArray","NullNullTerm":false,"CountConst":-1,"CountParamIndex":4,"Child":{"Kind":"ApiRef","Name":"RECT","TargetKind":"Default","Api":"Foundation","Parents":[]}},"Attrs":["In","Const"]}
,{"Name":"pRects","Type":{"Kind":"LPArray","NullNullTerm":false,"CountConst":-1,"CountParamIndex":4,"Child":{"Kind":"ApiRef","Name":"RECT","TargetKind":"Default","Api":"Foundation","Parents":[]}},"Attrs":["In","Optional","Const"]}
]
}
,{

View File

@@ -349,7 +349,7 @@
,"Platform":null
,"Attrs":[]
,"Params":[
{"Name":"statistics","Type":{"Kind":"PointerTo","Child":{"Kind":"ApiRef","Name":"DCOMPOSITION_FRAME_STATISTICS","TargetKind":"Default","Api":"Graphics.DirectComposition","Parents":[]}},"Attrs":["Out"]}
{"Name":"statistics","Type":{"Kind":"PointerTo","Child":{"Kind":"ApiRef","Name":"DCOMPOSITION_FRAME_STATISTICS","TargetKind":"Default","Api":"Graphics.DirectComposition","Parents":[]}},"Attrs":["Out","RetVal"]}
]
}
,{
@@ -2257,7 +2257,7 @@
,"Platform":null
,"Attrs":[]
,"Params":[
{"Name":"statistics","Type":{"Kind":"PointerTo","Child":{"Kind":"ApiRef","Name":"DCOMPOSITION_FRAME_STATISTICS","TargetKind":"Default","Api":"Graphics.DirectComposition","Parents":[]}},"Attrs":["Out"]}
{"Name":"statistics","Type":{"Kind":"PointerTo","Child":{"Kind":"ApiRef","Name":"DCOMPOSITION_FRAME_STATISTICS","TargetKind":"Default","Api":"Graphics.DirectComposition","Parents":[]}},"Attrs":["Out","RetVal"]}
]
}
,{
@@ -4484,7 +4484,7 @@
,"Params":[
{"Name":"fenceValue","Type":{"Kind":"PointerTo","Child":{"Kind":"Native","Name":"UInt64"}},"Attrs":["Out"]}
,{"Name":"iid","Type":{"Kind":"PointerTo","Child":{"Kind":"Native","Name":"Guid"}},"Attrs":["In","Const"]}
,{"Name":"availableFence","Type":{"Kind":"PointerTo","Child":{"Kind":"PointerTo","Child":{"Kind":"Native","Name":"Void"}}},"Attrs":["Out"]}
,{"Name":"availableFence","Type":{"Kind":"PointerTo","Child":{"Kind":"PointerTo","Child":{"Kind":"Native","Name":"Void"}}},"Attrs":["Out","ComOutPtr"]}
]
}
]
@@ -4645,7 +4645,7 @@
{"Name":"frameId","Type":{"Kind":"Native","Name":"UInt64"},"Attrs":["In"]}
,{"Name":"frameStats","Type":{"Kind":"PointerTo","Child":{"Kind":"ApiRef","Name":"COMPOSITION_FRAME_STATS","TargetKind":"Default","Api":"Graphics.DirectComposition","Parents":[]}},"Attrs":["Out"]}
,{"Name":"targetIdCount","Type":{"Kind":"Native","Name":"UInt32"},"Attrs":["In"]}
,{"Name":"targetIds","Type":{"Kind":"PointerTo","Child":{"Kind":"ApiRef","Name":"COMPOSITION_TARGET_ID","TargetKind":"Default","Api":"Graphics.DirectComposition","Parents":[]}},"Attrs":["Out","Optional"]}
,{"Name":"targetIds","Type":{"Kind":"LPArray","NullNullTerm":false,"CountConst":-1,"CountParamIndex":-1,"Child":{"Kind":"ApiRef","Name":"COMPOSITION_TARGET_ID","TargetKind":"Default","Api":"Graphics.DirectComposition","Parents":[]}},"Attrs":["Out","Optional"]}
,{"Name":"actualTargetIdCount","Type":{"Kind":"PointerTo","Child":{"Kind":"Native","Name":"UInt32"}},"Attrs":["Out","Optional"]}
]
}
@@ -4661,7 +4661,7 @@
,"Params":[
{"Name":"frameId","Type":{"Kind":"Native","Name":"UInt64"},"Attrs":["In"]}
,{"Name":"targetId","Type":{"Kind":"PointerTo","Child":{"Kind":"ApiRef","Name":"COMPOSITION_TARGET_ID","TargetKind":"Default","Api":"Graphics.DirectComposition","Parents":[]}},"Attrs":["In","Const"]}
,{"Name":"targetStats","Type":{"Kind":"PointerTo","Child":{"Kind":"ApiRef","Name":"COMPOSITION_TARGET_STATS","TargetKind":"Default","Api":"Graphics.DirectComposition","Parents":[]}},"Attrs":["Out"]}
,{"Name":"targetStats","Type":{"Kind":"PointerTo","Child":{"Kind":"ApiRef","Name":"COMPOSITION_TARGET_STATS","TargetKind":"Default","Api":"Graphics.DirectComposition","Parents":[]}},"Attrs":["Out","RetVal"]}
]
}
,{

View File

@@ -3578,111 +3578,6 @@
,"Value":256
,"Attrs":[]
}
,{
"Name":"DISPLAY_DEVICE_ATTACHED_TO_DESKTOP"
,"Type":{"Kind":"Native","Name":"UInt32"}
,"ValueType":"UInt32"
,"Value":1
,"Attrs":[]
}
,{
"Name":"DISPLAY_DEVICE_MULTI_DRIVER"
,"Type":{"Kind":"Native","Name":"UInt32"}
,"ValueType":"UInt32"
,"Value":2
,"Attrs":[]
}
,{
"Name":"DISPLAY_DEVICE_PRIMARY_DEVICE"
,"Type":{"Kind":"Native","Name":"UInt32"}
,"ValueType":"UInt32"
,"Value":4
,"Attrs":[]
}
,{
"Name":"DISPLAY_DEVICE_MIRRORING_DRIVER"
,"Type":{"Kind":"Native","Name":"UInt32"}
,"ValueType":"UInt32"
,"Value":8
,"Attrs":[]
}
,{
"Name":"DISPLAY_DEVICE_VGA_COMPATIBLE"
,"Type":{"Kind":"Native","Name":"UInt32"}
,"ValueType":"UInt32"
,"Value":16
,"Attrs":[]
}
,{
"Name":"DISPLAY_DEVICE_REMOVABLE"
,"Type":{"Kind":"Native","Name":"UInt32"}
,"ValueType":"UInt32"
,"Value":32
,"Attrs":[]
}
,{
"Name":"DISPLAY_DEVICE_ACC_DRIVER"
,"Type":{"Kind":"Native","Name":"UInt32"}
,"ValueType":"UInt32"
,"Value":64
,"Attrs":[]
}
,{
"Name":"DISPLAY_DEVICE_MODESPRUNED"
,"Type":{"Kind":"Native","Name":"UInt32"}
,"ValueType":"UInt32"
,"Value":134217728
,"Attrs":[]
}
,{
"Name":"DISPLAY_DEVICE_RDPUDD"
,"Type":{"Kind":"Native","Name":"UInt32"}
,"ValueType":"UInt32"
,"Value":16777216
,"Attrs":[]
}
,{
"Name":"DISPLAY_DEVICE_REMOTE"
,"Type":{"Kind":"Native","Name":"UInt32"}
,"ValueType":"UInt32"
,"Value":67108864
,"Attrs":[]
}
,{
"Name":"DISPLAY_DEVICE_DISCONNECT"
,"Type":{"Kind":"Native","Name":"UInt32"}
,"ValueType":"UInt32"
,"Value":33554432
,"Attrs":[]
}
,{
"Name":"DISPLAY_DEVICE_TS_COMPATIBLE"
,"Type":{"Kind":"Native","Name":"UInt32"}
,"ValueType":"UInt32"
,"Value":2097152
,"Attrs":[]
}
,{
"Name":"DISPLAY_DEVICE_UNSAFE_MODES_ON"
,"Type":{"Kind":"Native","Name":"UInt32"}
,"ValueType":"UInt32"
,"Value":524288
,"Attrs":[]
}
,{
"Name":"DISPLAY_DEVICE_ACTIVE"
,"Type":{"Kind":"Native","Name":"UInt32"}
,"ValueType":"UInt32"
,"Value":1
,"Attrs":[]
}
,{
"Name":"DISPLAY_DEVICE_ATTACHED"
,"Type":{"Kind":"Native","Name":"UInt32"}
,"ValueType":"UInt32"
,"Value":2
,"Attrs":[]
}
,{
"Name":"DISPLAYCONFIG_MAXPATH"
,"Type":{"Kind":"Native","Name":"UInt32"}
@@ -7585,6 +7480,32 @@
]
,"IntegerBase":"UInt32"
}
,{
"Name":"DISPLAY_DEVICE_STATE_FLAGS"
,"Architectures":[]
,"Platform":null
,"Kind":"Enum"
,"Flags":true
,"Scoped":false
,"Values":[
{"Name":"DISPLAY_DEVICE_ATTACHED_TO_DESKTOP","Value":1}
,{"Name":"DISPLAY_DEVICE_MULTI_DRIVER","Value":2}
,{"Name":"DISPLAY_DEVICE_PRIMARY_DEVICE","Value":4}
,{"Name":"DISPLAY_DEVICE_MIRRORING_DRIVER","Value":8}
,{"Name":"DISPLAY_DEVICE_VGA_COMPATIBLE","Value":16}
,{"Name":"DISPLAY_DEVICE_REMOVABLE","Value":32}
,{"Name":"DISPLAY_DEVICE_ACC_DRIVER","Value":64}
,{"Name":"DISPLAY_DEVICE_MODESPRUNED","Value":134217728}
,{"Name":"DISPLAY_DEVICE_RDPUDD","Value":16777216}
,{"Name":"DISPLAY_DEVICE_REMOTE","Value":67108864}
,{"Name":"DISPLAY_DEVICE_DISCONNECT","Value":33554432}
,{"Name":"DISPLAY_DEVICE_TS_COMPATIBLE","Value":2097152}
,{"Name":"DISPLAY_DEVICE_UNSAFE_MODES_ON","Value":524288}
,{"Name":"DISPLAY_DEVICE_ACTIVE","Value":1}
,{"Name":"DISPLAY_DEVICE_ATTACHED","Value":2}
]
,"IntegerBase":"UInt32"
}
,{
"Name":"HBITMAP"
,"Architectures":[]
@@ -8740,7 +8661,7 @@
{"Name":"cb","Type":{"Kind":"Native","Name":"UInt32"},"Attrs":[]}
,{"Name":"DeviceName","Type":{"Kind":"Array","Shape":{"Size":32},"Child":{"Kind":"ApiRef","Name":"CHAR","TargetKind":"Default","Api":"Foundation","Parents":[]}},"Attrs":[]}
,{"Name":"DeviceString","Type":{"Kind":"Array","Shape":{"Size":128},"Child":{"Kind":"ApiRef","Name":"CHAR","TargetKind":"Default","Api":"Foundation","Parents":[]}},"Attrs":[]}
,{"Name":"StateFlags","Type":{"Kind":"Native","Name":"UInt32"},"Attrs":[]}
,{"Name":"StateFlags","Type":{"Kind":"ApiRef","Name":"DISPLAY_DEVICE_STATE_FLAGS","TargetKind":"Default","Api":"Graphics.Gdi","Parents":[]},"Attrs":[]}
,{"Name":"DeviceID","Type":{"Kind":"Array","Shape":{"Size":128},"Child":{"Kind":"ApiRef","Name":"CHAR","TargetKind":"Default","Api":"Foundation","Parents":[]}},"Attrs":[]}
,{"Name":"DeviceKey","Type":{"Kind":"Array","Shape":{"Size":128},"Child":{"Kind":"ApiRef","Name":"CHAR","TargetKind":"Default","Api":"Foundation","Parents":[]}},"Attrs":[]}
]
@@ -8759,7 +8680,7 @@
{"Name":"cb","Type":{"Kind":"Native","Name":"UInt32"},"Attrs":[]}
,{"Name":"DeviceName","Type":{"Kind":"Array","Shape":{"Size":32},"Child":{"Kind":"Native","Name":"Char"}},"Attrs":[]}
,{"Name":"DeviceString","Type":{"Kind":"Array","Shape":{"Size":128},"Child":{"Kind":"Native","Name":"Char"}},"Attrs":[]}
,{"Name":"StateFlags","Type":{"Kind":"Native","Name":"UInt32"},"Attrs":[]}
,{"Name":"StateFlags","Type":{"Kind":"ApiRef","Name":"DISPLAY_DEVICE_STATE_FLAGS","TargetKind":"Default","Api":"Graphics.Gdi","Parents":[]},"Attrs":[]}
,{"Name":"DeviceID","Type":{"Kind":"Array","Shape":{"Size":128},"Child":{"Kind":"Native","Name":"Char"}},"Attrs":[]}
,{"Name":"DeviceKey","Type":{"Kind":"Array","Shape":{"Size":128},"Child":{"Kind":"Native","Name":"Char"}},"Attrs":[]}
]
@@ -11477,10 +11398,10 @@
,{"Name":"bItalic","Type":{"Kind":"Native","Name":"UInt32"},"Attrs":["In"]}
,{"Name":"bUnderline","Type":{"Kind":"Native","Name":"UInt32"},"Attrs":["In"]}
,{"Name":"bStrikeOut","Type":{"Kind":"Native","Name":"UInt32"},"Attrs":["In"]}
,{"Name":"iCharSet","Type":{"Kind":"Native","Name":"UInt32"},"Attrs":["In"]}
,{"Name":"iOutPrecision","Type":{"Kind":"Native","Name":"UInt32"},"Attrs":["In"]}
,{"Name":"iClipPrecision","Type":{"Kind":"Native","Name":"UInt32"},"Attrs":["In"]}
,{"Name":"iQuality","Type":{"Kind":"Native","Name":"UInt32"},"Attrs":["In"]}
,{"Name":"iCharSet","Type":{"Kind":"Native","Name":"UInt32"},"Attrs":["In",{"Kind":"AssociatedEnum","Enum":"FONT_CHARSET"}]}
,{"Name":"iOutPrecision","Type":{"Kind":"Native","Name":"UInt32"},"Attrs":["In",{"Kind":"AssociatedEnum","Enum":"FONT_OUTPUT_PRECISION"}]}
,{"Name":"iClipPrecision","Type":{"Kind":"Native","Name":"UInt32"},"Attrs":["In",{"Kind":"AssociatedEnum","Enum":"FONT_CLIP_PRECISION"}]}
,{"Name":"iQuality","Type":{"Kind":"Native","Name":"UInt32"},"Attrs":["In",{"Kind":"AssociatedEnum","Enum":"FONT_QUALITY"}]}
,{"Name":"iPitchAndFamily","Type":{"Kind":"Native","Name":"UInt32"},"Attrs":["In"]}
,{"Name":"pszFaceName","Type":{"Kind":"ApiRef","Name":"PSTR","TargetKind":"Default","Api":"Foundation","Parents":[]},"Attrs":["In","Optional","Const"]}
]
@@ -11503,10 +11424,10 @@
,{"Name":"bItalic","Type":{"Kind":"Native","Name":"UInt32"},"Attrs":["In"]}
,{"Name":"bUnderline","Type":{"Kind":"Native","Name":"UInt32"},"Attrs":["In"]}
,{"Name":"bStrikeOut","Type":{"Kind":"Native","Name":"UInt32"},"Attrs":["In"]}
,{"Name":"iCharSet","Type":{"Kind":"Native","Name":"UInt32"},"Attrs":["In"]}
,{"Name":"iOutPrecision","Type":{"Kind":"Native","Name":"UInt32"},"Attrs":["In"]}
,{"Name":"iClipPrecision","Type":{"Kind":"Native","Name":"UInt32"},"Attrs":["In"]}
,{"Name":"iQuality","Type":{"Kind":"Native","Name":"UInt32"},"Attrs":["In"]}
,{"Name":"iCharSet","Type":{"Kind":"Native","Name":"UInt32"},"Attrs":["In",{"Kind":"AssociatedEnum","Enum":"FONT_CHARSET"}]}
,{"Name":"iOutPrecision","Type":{"Kind":"Native","Name":"UInt32"},"Attrs":["In",{"Kind":"AssociatedEnum","Enum":"FONT_OUTPUT_PRECISION"}]}
,{"Name":"iClipPrecision","Type":{"Kind":"Native","Name":"UInt32"},"Attrs":["In",{"Kind":"AssociatedEnum","Enum":"FONT_CLIP_PRECISION"}]}
,{"Name":"iQuality","Type":{"Kind":"Native","Name":"UInt32"},"Attrs":["In",{"Kind":"AssociatedEnum","Enum":"FONT_QUALITY"}]}
,{"Name":"iPitchAndFamily","Type":{"Kind":"Native","Name":"UInt32"},"Attrs":["In"]}
,{"Name":"pszFaceName","Type":{"Kind":"ApiRef","Name":"PWSTR","TargetKind":"Default","Api":"Foundation","Parents":[]},"Attrs":["In","Optional","Const"]}
]

View File

@@ -0,0 +1,19 @@
Copyright (c) 2019-2024 Advanced Micro Devices, Inc. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net4.6.1;net8.0;net9.0</TargetFrameworks>
<Description>D3D12MemoryAllocator native libraries with C bindings</Description>
<PackageVersion>1.0.0</PackageVersion>
<IncludeBuildOutput>false</IncludeBuildOutput>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageLicenseExpression></PackageLicenseExpression>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
<RepositoryUrl>https://github.com/GPUOpen-LibrariesAndSDKs/D3D12MemoryAllocator</RepositoryUrl>
<PackageReadmeFile>README.md</PackageReadmeFile>
<IncludeSymbols>false</IncludeSymbols>
</PropertyGroup>
<ItemGroup>
<None Include="$(RepoRootDirectory)/README.md" Pack="true" PackagePath="\" />
<Content Include="LICENSE.txt" PackagePath="" />
</ItemGroup>
<ItemGroup>
<Content Include="build\**" PackagePath="build/%(RecursiveDir)%(Filename)%(Extension)" />
<Content Include="runtimes\**" PackagePath="runtimes/%(RecursiveDir)%(Filename)%(Extension)" />
<Content Include="$(MSBuildThisFileDirectory)_._" PackagePath="lib/net9.0" />
<Content Include="$(MSBuildThisFileDirectory)_._" PackagePath="lib/net8.0" />
<Content Include="$(MSBuildThisFileDirectory)_._" PackagePath="lib/net461" />
<Content Include="$(MSBuildThisFileDirectory)_._" PackagePath="lib/netstandard2.0" />
</ItemGroup>
</Project>

View File

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<_Vortice_D3DMA_Native_IsWindows Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">true</_Vortice_D3DMA_Native_IsWindows>
<_Vortice_D3DMA_Native_NativeRuntime Condition=" '$(_Vortice_D3DMA_Native_IsWindows)' == '' And '$(_Vortice_D3DMA_Native_IsWindows)' == 'true' And ('$(Prefer32Bit)' == 'false' Or '$(PlatformTarget)' == 'x64')">win-x64</_Vortice_D3DMA_Native_NativeRuntime>
<_Vortice_D3DMA_Native_NativeRuntime Condition=" '$(_Vortice_D3DMA_Native_IsWindows)' == '' And '$(_Vortice_D3DMA_Native_IsWindows)' == 'true' And '$(PlatformTarget)' == 'ARM64'">win-arm64</_Vortice_D3DMA_Native_NativeRuntime>
</PropertyGroup>
<ItemGroup>
<Content Condition="'$(_Vortice_D3DMA_Native_NativeRuntime)' != ''" Include="$(MSBuildThisFileDirectory)..\..\runtimes\$(_Vortice_D3DMA_Native_NativeRuntime)\native\D3D12MA.dll">
<Link>%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Visible>False</Visible>
</Content>
</ItemGroup>
</Project>

View File

@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net4.6.1;net8.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net4.6.1;net8.0;net9.0</TargetFrameworks>
<Description>Dxc native libraries</Description>
<PackageVersion>1.0.2</PackageVersion>
<PackageVersion>1.0.3</PackageVersion>
<IncludeBuildOutput>false</IncludeBuildOutput>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageLicenseExpression></PackageLicenseExpression>
@@ -23,6 +23,7 @@
<ItemGroup>
<Content Include="build\**" PackagePath="build/%(RecursiveDir)%(Filename)%(Extension)" />
<Content Include="runtimes\**" PackagePath="runtimes/%(RecursiveDir)%(Filename)%(Extension)" />
<Content Include="$(MSBuildThisFileDirectory)_._" PackagePath="lib/net9.0" />
<Content Include="$(MSBuildThisFileDirectory)_._" PackagePath="lib/net8.0" />
<Content Include="$(MSBuildThisFileDirectory)_._" PackagePath="lib/net461" />
<Content Include="$(MSBuildThisFileDirectory)_._" PackagePath="lib/netstandard2.0" />

View File

@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net4.6.1;net8.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net4.6.1;net8.0;net9.0</TargetFrameworks>
<Description>WinPixEventRuntime native libraries</Description>
<PackageVersion>1.0.0</PackageVersion>
<PackageVersion>1.0.1</PackageVersion>
<IncludeBuildOutput>false</IncludeBuildOutput>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageLicenseExpression></PackageLicenseExpression>
@@ -22,6 +22,7 @@
<ItemGroup>
<Content Include="build\**" PackagePath="build/%(RecursiveDir)%(Filename)%(Extension)" />
<Content Include="runtimes\**" PackagePath="runtimes/%(RecursiveDir)%(Filename)%(Extension)" />
<Content Include="$(MSBuildThisFileDirectory)_._" PackagePath="lib/net9.0" />
<Content Include="$(MSBuildThisFileDirectory)_._" PackagePath="lib/net8.0" />
<Content Include="$(MSBuildThisFileDirectory)_._" PackagePath="lib/net461" />
<Content Include="$(MSBuildThisFileDirectory)_._" PackagePath="lib/netstandard2.0" />

View File

@@ -0,0 +1,43 @@
// Copyright © Amer Koleci and Contributors.
// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information.
using Win32.Graphics.Direct3D12;
using static Win32.Apis;
using static Win32.Graphics.D3D12MemoryAllocator.Apis;
namespace Win32.Graphics.D3D12MemoryAllocator;
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public readonly partial struct Allocation : IEquatable<Allocation>
{
public Allocation(nint handle) { Handle = handle; }
public nint Handle { get; }
public bool IsNull => Handle == 0;
public bool IsNotNull => Handle != 0;
public static Allocation Null => new(0);
public static implicit operator Allocation(nint handle) => new(handle);
public static implicit operator nint(Allocation handle) => handle.Handle;
public static bool operator ==(Allocation left, Allocation right) => left.Handle == right.Handle;
public static bool operator !=(Allocation left, Allocation right) => left.Handle != right.Handle;
public static bool operator ==(Allocation left, nint right) => left.Handle == right;
public static bool operator !=(Allocation left, nint right) => left.Handle != right;
public bool Equals(Allocation other) => Handle == other.Handle;
/// <inheritdoc/>
public override bool Equals(object? obj) => obj is Allocation handle && Equals(handle);
/// <inheritdoc/>
public override int GetHashCode() => Handle.GetHashCode();
private string DebuggerDisplay => $"{nameof(Allocation)} [0x{Handle:X}]";
public uint AddRef() => D3D12MA_Allocation_AddRef(Handle);
public uint Release() => D3D12MA_Allocation_Release(Handle);
public ulong Offset => D3D12MA_Allocation_GetOffset(Handle);
public ulong Alignment => D3D12MA_Allocation_GetAlignment(Handle);
public ulong Size => D3D12MA_Allocation_GetSize(Handle);
public unsafe ID3D12Resource* Resource
{
get => D3D12MA_Allocation_GetResource(Handle);
set => D3D12MA_Allocation_SetResource(Handle, value);
}
public unsafe ID3D12Heap* Heap => D3D12MA_Allocation_GetHeap(Handle);
}

View File

@@ -0,0 +1,93 @@
// Copyright © Amer Koleci and Contributors.
// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information.
using Win32.Graphics.Direct3D12;
using Win32.Graphics.Dxgi.Common;
using static Win32.Apis;
using static Win32.Graphics.D3D12MemoryAllocator.Apis;
namespace Win32.Graphics.D3D12MemoryAllocator;
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public readonly unsafe partial struct Allocator : IEquatable<Allocator>
{
public Allocator(nint handle) { Handle = handle; }
public nint Handle { get; }
public bool IsNull => Handle == 0;
public bool IsNotNull => Handle != 0;
public static Allocator Null => new(0);
public static implicit operator Allocator(nint handle) => new(handle);
public static implicit operator nint(Allocator handle) => handle.Handle;
public static bool operator ==(Allocator left, Allocator right) => left.Handle == right.Handle;
public static bool operator !=(Allocator left, Allocator right) => left.Handle != right.Handle;
public static bool operator ==(Allocator left, nint right) => left.Handle == right;
public static bool operator !=(Allocator left, nint right) => left.Handle != right;
public bool Equals(Allocator other) => Handle == other.Handle;
/// <inheritdoc/>
public override bool Equals(object? obj) => obj is Allocator handle && Equals(handle);
/// <inheritdoc/>
public override int GetHashCode() => Handle.GetHashCode();
private string DebuggerDisplay => $"{nameof(Allocator)} [0x{Handle:X}]";
public uint AddRef() => D3D12MA_Allocator_AddRef(Handle);
public uint Release() => D3D12MA_Allocator_Release(Handle);
public bool IsUMA => D3D12MA_Allocator_IsUMA(Handle);
public bool IsCacheCoherentUMA => D3D12MA_Allocator_IsCacheCoherentUMA(Handle);
public bool IsGPUUploadHeapSupported => D3D12MA_Allocator_IsGPUUploadHeapSupported(Handle);
public ulong GetMemoryCapacity(uint memorySegmentGroup) => D3D12MA_Allocator_GetMemoryCapacity(Handle, memorySegmentGroup);
public HResult CreateResource(AllocationDesc* pAllocDesc,
in ResourceDescription resourceDesc,
ResourceStates initialResourceState,
ClearValue* pOptimizedClearValue,
Allocation* allocation, Guid* riidResource, void** ppvResource)
{
fixed (ResourceDescription* pResourceDesc = &resourceDesc)
{
return D3D12MA_Allocator_CreateResource(Handle, pAllocDesc, pResourceDesc, initialResourceState, pOptimizedClearValue, allocation, riidResource, ppvResource);
}
}
public HResult CreateResource<TResource>(AllocationDesc* pAllocDesc,
in ResourceDescription resourceDesc,
ResourceStates initialResourceState,
ClearValue* pOptimizedClearValue,
Allocation* allocation, TResource** ppvResource)
where TResource : unmanaged, ID3D12Resource.Interface
{
fixed (ResourceDescription* pResourceDesc = &resourceDesc)
{
return D3D12MA_Allocator_CreateResource(Handle,
pAllocDesc,
pResourceDesc,
initialResourceState,
pOptimizedClearValue,
allocation,
__uuidof<TResource>(), (void**)ppvResource);
}
}
public HResult CreateResource2(AllocationDesc* pAllocDesc,
ResourceDescription1* pResourceDesc,
ResourceStates initialResourceState,
ClearValue* pOptimizedClearValue,
Allocation* allocation, Guid* riidResource, void** ppvResource)
{
return D3D12MA_Allocator_CreateResource2(Handle, pAllocDesc, pResourceDesc, initialResourceState, pOptimizedClearValue, allocation, riidResource, ppvResource);
}
public HResult CreateResource3(AllocationDesc* pAllocDesc,
ResourceDescription1* pResourceDesc,
BarrierLayout initialLayout,
ClearValue* pOptimizedClearValue,
uint numCastableFormats, Format* pCastableFormats,
Allocation* allocation, Guid* riidResource, void** ppvResource)
{
return D3D12MA_Allocator_CreateResource3(Handle, pAllocDesc, pResourceDesc, initialLayout,
pOptimizedClearValue,
numCastableFormats, pCastableFormats,
allocation, riidResource, ppvResource);
}
}

View File

@@ -0,0 +1,96 @@
// Copyright © Amer Koleci and Contributors.
// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information.
using Win32.Graphics.Direct3D12;
using Win32.Graphics.Dxgi.Common;
namespace Win32.Graphics.D3D12MemoryAllocator;
public static unsafe partial class Apis
{
private const string LibraryName = "D3D12MA";
[LibraryImport(LibraryName, EntryPoint = "D3D12MA_CreateAllocator")]
public static partial HResult CreateAllocator(in AllocatorDesc desc, out Allocator allocator);
[LibraryImport(LibraryName, EntryPoint = "D3D12MA_CreateVirtualBlock")]
public static partial HResult CreateVirtualBlock(in VirtualBlockDesc desc, out VirtualBlock virtualBlock);
[LibraryImport(LibraryName)]
internal static partial uint D3D12MA_Allocator_AddRef(nint pSelf);
[LibraryImport(LibraryName)]
internal static partial uint D3D12MA_Allocator_Release(nint pSelf);
[LibraryImport(LibraryName)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static partial bool D3D12MA_Allocator_IsUMA(nint pSelf);
[LibraryImport(LibraryName)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static partial bool D3D12MA_Allocator_IsCacheCoherentUMA(nint pSelf);
[LibraryImport(LibraryName)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static partial bool D3D12MA_Allocator_IsGPUUploadHeapSupported(nint pSelf);
[LibraryImport(LibraryName)]
internal static partial ulong D3D12MA_Allocator_GetMemoryCapacity(nint pSelf, uint memorySegmentGroup);
[LibraryImport(LibraryName)]
internal static partial HResult D3D12MA_Allocator_CreateResource(nint pSelf, AllocationDesc* allocationDesc, ResourceDescription* resourceDesc, ResourceStates initialResourceState, ClearValue* pOptimizedClearValue, Allocation* allocation, Guid* riidResource, void** ppvResource);
[LibraryImport(LibraryName)]
internal static partial HResult D3D12MA_Allocator_CreateResource2(nint pSelf, AllocationDesc* allocationDesc, ResourceDescription1* pResourceDesc, ResourceStates initialResourceState, ClearValue* pOptimizedClearValue, Allocation* ppAllocation, Guid* riidResource, void** ppvResource);
[LibraryImport(LibraryName)]
internal static partial HResult D3D12MA_Allocator_CreateResource3(nint pSelf, AllocationDesc* allocationDesc, ResourceDescription1* pResourceDesc, BarrierLayout InitialLayout, ClearValue* pOptimizedClearValue, uint NumCastableFormats, Format* pCastableFormats, Allocation* ppAllocation, Guid* riidResource, void** ppvResource);
[LibraryImport(LibraryName)]
internal static partial HResult D3D12MA_Allocator_AllocateMemory(nint pSelf, AllocationDesc* pAllocDesc, ResourceAllocationInfo* pAllocInfo, Allocation* ppAllocation);
[LibraryImport(LibraryName)]
internal static partial HResult D3D12MA_Allocator_CreateAliasingResource(nint pSelf, Allocation* pAllocation, ulong AllocationLocalOffset, ResourceDescription* pResourceDesc, ResourceStates InitialResourceState, ClearValue* pOptimizedClearValue, Guid* riidResource, void** ppvResource);
[LibraryImport(LibraryName)]
internal static partial HResult D3D12MA_Allocator_CreateAliasingResource1(nint pSelf, Allocation* pAllocation, ulong AllocationLocalOffset, ResourceDescription* pResourceDesc, ResourceStates InitialResourceState, ClearValue* pOptimizedClearValue, Guid* riidResource, void** ppvResource);
[LibraryImport(LibraryName)]
internal static partial HResult D3D12MA_Allocator_CreateAliasingResource2(nint pSelf, Allocation* pAllocation, ulong AllocationLocalOffset, ResourceDescription* pResourceDesc, BarrierLayout InitialLayout, ClearValue* pOptimizedClearValue, uint NumCastableFormats, Format* pCastableFormats, Guid* riidResource, void** ppvResource);
[LibraryImport(LibraryName)]
internal static partial HResult D3D12MA_Allocator_CreatePool(nint pSelf, PoolDesc* pPoolDesc, Pool* ppPool);
[LibraryImport(LibraryName)]
internal static partial void D3D12MA_Allocator_SetCurrentFrameIndex(nint pSelf, uint frameIndex);
//[LibraryImport(LibraryName)]
//internal static partial void D3D12MA_Allocator_GetBudget(nint pSelf, D3D12MABudget* pLocalBudget, D3D12MABudget* pNonLocalBudget);
//[LibraryImport(LibraryName)]
//internal static partial void D3D12MA_Allocator_CalculateStatistics(nint pSelf, D3D12MATotalStatistics* pStats);
[LibraryImport(LibraryName)]
internal static partial void D3D12MA_Allocator_BuildStatsString(nint pSelf, char** ppStatsString, Bool32 DetailedMap);
[LibraryImport(LibraryName)]
internal static partial void D3D12MA_Allocator_FreeStatsString(nint pSelf, char* pStatsString);
//[LibraryImport(LibraryName)]
//internal static partial void D3D12MA_Allocator_BeginDefragmentation(void* pSelf, const D3D12MA_DEFRAGMENTATION_DESC* pDesc, D3D12MA_DefragmentationContext** ppContext);
#region Allocation
[LibraryImport(LibraryName)]
internal static partial uint D3D12MA_Allocation_AddRef(nint pSelf);
[LibraryImport(LibraryName)]
internal static partial uint D3D12MA_Allocation_Release(nint pSelf);
[LibraryImport(LibraryName)]
internal static partial ulong D3D12MA_Allocation_GetOffset(nint pSelf);
[LibraryImport(LibraryName)]
internal static partial ulong D3D12MA_Allocation_GetAlignment(nint pSelf);
[LibraryImport(LibraryName)]
internal static partial ulong D3D12MA_Allocation_GetSize(nint pSelf);
[LibraryImport(LibraryName)]
internal static partial ID3D12Resource* D3D12MA_Allocation_GetResource(nint pSelf);
[LibraryImport(LibraryName)]
internal static partial void D3D12MA_Allocation_SetResource(nint pSelf, ID3D12Resource* pResource);
[LibraryImport(LibraryName)]
internal static partial ID3D12Heap* D3D12MA_Allocation_GetHeap(nint pSelf);
[LibraryImport(LibraryName)]
internal static partial void D3D12MA_Allocation_SetPrivateData(nint pSelf, void* pPrivateData);
[LibraryImport(LibraryName)]
internal static partial void* D3D12MA_Allocation_GetPrivateData(nint pSelf);
[LibraryImport(LibraryName)]
internal static partial void D3D12MA_Allocation_SetName(nint pSelf, char* Name);
[LibraryImport(LibraryName)]
internal static partial char* D3D12MA_Allocation_GetName(nint pSelf);
#endregion
}

View File

@@ -0,0 +1,121 @@
// Copyright © Amer Koleci and Contributors.
// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information.
namespace Win32.Graphics.D3D12MemoryAllocator;
/// <unmanaged>D3D12MA_ALLOCATOR_FLAGS</unmanaged>
[Flags]
public enum AllocatorFlags
{
/// <unmanaged>D3D12MA_ALLOCATOR_FLAG_NONE</unmanaged>
None = 0x00,
/// <unmanaged>D3D12MA_ALLOCATOR_FLAG_SINGLETHREADED</unmanaged>
SingleThreaded = 0x01,
/// <unmanaged>D3D12MA_ALLOCATOR_FLAG_ALWAYS_COMMITTED</unmanaged>
AlwaysCommitted = 0x02,
/// <unmanaged>D3D12MA_ALLOCATOR_FLAG_DEFAULT_POOLS_NOT_ZEROED</unmanaged>
DefaultPoolsNotZeroed = 0x04,
/// <unmanaged>D3D12MA_ALLOCATOR_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED</unmanaged>
MSAATexturesAlwaysCommitted = 0x08,
/// <unmanaged>D3D12MA_ALLOCATOR_FLAG_DONT_PREFER_SMALL_BUFFERS_COMMITTED</unmanaged>
DontPreferSmallBuffersCommitted = 0x10
}
/// <unmanaged>D3D12MA_POOL_FLAGS</unmanaged>
[Flags]
public enum PoolFlags
{
/// <unmanaged>D3D12MA_POOL_FLAG_NONE</unmanaged>
None = 0x0,
/// <unmanaged>D3D12MA_POOL_FLAG_ALGORITHM_LINEAR</unmanaged>
AlgorithmLinear = 0x1,
/// <unmanaged>D3D12MA_POOL_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED</unmanaged>
MSAATexturesAlwaysCommitted = 0x2,
/// <unmanaged>D3D12MA_POOL_FLAG_ALGORITHM_MASK</unmanaged>
AlgorithmMask = AlgorithmLinear,
}
/// <unmanaged>D3D12MA_ALLOCATION_FLAGS</unmanaged>
[Flags]
public enum AllocationFlags
{
/// <unmanaged>D3D12MA_ALLOCATION_FLAG_NONE</unmanaged>
None = 0x00000000,
/// <unmanaged>D3D12MA_ALLOCATION_FLAG_COMMITTED</unmanaged>
Committed = 0x00000001,
/// <unmanaged>D3D12MA_ALLOCATION_FLAG_NEVER_ALLOCATE</unmanaged>
NeverAllocate = 0x00000002,
/// <unmanaged>D3D12MA_ALLOCATION_FLAG_WITHIN_BUDGET</unmanaged>
WithinBudget = 0x00000004,
/// <unmanaged>D3D12MA_ALLOCATION_FLAG_UPPER_ADDRESS</unmanaged>
UpperAddress = 0x00000008,
/// <unmanaged>D3D12MA_ALLOCATION_FLAG_CAN_ALIAS</unmanaged>
CanAlias = 0x00000010,
/// <unmanaged>D3D12MA_ALLOCATION_FLAG_STRATEGY_MIN_MEMORY</unmanaged>
StrategyMinMemory = 0x00010000,
/// <unmanaged>D3D12MA_ALLOCATION_FLAG_STRATEGY_MIN_TIME</unmanaged>
StrategyMinTime = 0x00020000,
/// <unmanaged>D3D12MA_ALLOCATION_FLAG_STRATEGY_MIN_OFFSET</unmanaged>
StrategyMinOffset = 0x0004000,
/// <unmanaged>D3D12MA_ALLOCATION_FLAG_STRATEGY_BEST_FIT</unmanaged>
StrategyBestFit = StrategyMinMemory,
/// <unmanaged>D3D12MA_ALLOCATION_FLAG_STRATEGY_FIRST_FIT</unmanaged>
StrategyFirstFit = StrategyMinTime,
/// <unmanaged>D3D12MA_ALLOCATION_FLAG_STRATEGY_MASK</unmanaged>
StrategyMask = StrategyMinMemory | StrategyMinTime | StrategyMinOffset
}
/// <unmanaged>D3D12MA_ALLOCATION_FLAGS</unmanaged>
[Flags]
public enum VirtualBlockFlags
{
/// <unmanaged>D3D12MA_VIRTUAL_BLOCK_FLAG_NONE</unmanaged>
None = 0,
/// <unmanaged>D3D12MA_VIRTUAL_BLOCK_FLAG_ALGORITHM_LINEAR</unmanaged>
AlgorithmLinear = PoolFlags.AlgorithmLinear,
/// <unmanaged>D3D12MA_VIRTUAL_BLOCK_FLAG_ALGORITHM_MASK</unmanaged>
AlgorithmMask = PoolFlags.AlgorithmMask,
}
/// <unmanaged>D3D12MA_DEFRAGMENTATION_FLAGS</unmanaged>
[Flags]
public enum DefragmentationFlags
{
/// <unmanaged>D3D12MA_DEFRAGMENTATION_FLAG_ALGORITHM_FAST</unmanaged>
AlgorithmFast = 0x1,
/// <unmanaged>D3D12MA_DEFRAGMENTATION_FLAG_ALGORITHM_BALANCED</unmanaged>
AlgorithmBalanced = 0x2,
/// <unmanaged>D3D12MA_DEFRAGMENTATION_FLAG_ALGORITHM_FULL</unmanaged>
AlgorithmFull = 0x4,
/// <unmanaged>D3D12MA_DEFRAGMENTATION_FLAG_ALGORITHM_MASK</unmanaged>
AlgorithmMask = AlgorithmFast | AlgorithmBalanced | AlgorithmFull,
}
/// <unmanaged>D3D12MA_DEFRAGMENTATION_MOVE_OPERATION</unmanaged>
public enum DefragmentationMoveOperation
{
/// <unmanaged>D3D12MA_DEFRAGMENTATION_MOVE_OPERATION_COPY</unmanaged>
Copy = 0,
/// <unmanaged>D3D12MA_DEFRAGMENTATION_MOVE_OPERATION_IGNORE</unmanaged>
Ignore = 1,
/// <unmanaged>D3D12MA_DEFRAGMENTATION_MOVE_OPERATION_DESTROY</unmanaged>
Destroy = 2,
}
/// <unmanaged>D3D12MA_VIRTUAL_ALLOCATION_FLAGS</unmanaged>
[Flags]
public enum VirtualAllocationFlags
{
/// <unmanaged>D3D12MA_VIRTUAL_ALLOCATION_FLAG_NONE</unmanaged>
None = 0,
/// <unmanaged>D3D12MA_VIRTUAL_ALLOCATION_FLAG_UPPER_ADDRESS</unmanaged>
UpperAddress = AllocationFlags.UpperAddress,
/// <unmanaged>D3D12MA_VIRTUAL_ALLOCATION_FLAG_STRATEGY_MIN_MEMORY</unmanaged>
StrategyMinMemory = AllocationFlags.StrategyMinMemory,
/// <unmanaged>D3D12MA_VIRTUAL_ALLOCATION_FLAG_STRATEGY_MIN_TIME</unmanaged>
StrategyMinTime = AllocationFlags.StrategyMinTime,
/// <unmanaged>D3D12MA_VIRTUAL_ALLOCATION_FLAG_STRATEGY_MIN_OFFSET</unmanaged>
StrategyMinOffset = AllocationFlags.StrategyMinOffset,
/// <unmanaged>D3D12MA_ALLOCATION_FLAG_STRATEGY_MASK</unmanaged>
StrategyMask = AllocationFlags.StrategyMask,
}

View File

@@ -0,0 +1,70 @@
// Copyright © Amer Koleci and Contributors.
// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information.
namespace Win32.Graphics.D3D12MemoryAllocator;
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public readonly partial struct Pool : IEquatable<Pool>
{
public Pool(nint handle) { Handle = handle; }
public nint Handle { get; }
public bool IsNull => Handle == 0;
public bool IsNotNull => Handle != 0;
public static Pool Null => new(0);
public static implicit operator Pool(nint handle) => new(handle);
public static implicit operator nint(Pool handle) => handle.Handle;
public static bool operator ==(Pool left, Pool right) => left.Handle == right.Handle;
public static bool operator !=(Pool left, Pool right) => left.Handle != right.Handle;
public static bool operator ==(Pool left, nint right) => left.Handle == right;
public static bool operator !=(Pool left, nint right) => left.Handle != right;
public bool Equals(Pool other) => Handle == other.Handle;
/// <inheritdoc/>
public override bool Equals(object? obj) => obj is Pool handle && Equals(handle);
/// <inheritdoc/>
public override int GetHashCode() => Handle.GetHashCode();
private string DebuggerDisplay => $"{nameof(Pool)} [0x{Handle:X}]";
}
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public readonly partial struct VirtualBlock : IEquatable<VirtualBlock>
{
public VirtualBlock(nint handle) { Handle = handle; }
public nint Handle { get; }
public bool IsNull => Handle == 0;
public bool IsNotNull => Handle != 0;
public static VirtualBlock Null => new(0);
public static implicit operator VirtualBlock(nint handle) => new(handle);
public static implicit operator nint(VirtualBlock handle) => handle.Handle;
public static bool operator ==(VirtualBlock left, VirtualBlock right) => left.Handle == right.Handle;
public static bool operator !=(VirtualBlock left, VirtualBlock right) => left.Handle != right.Handle;
public static bool operator ==(VirtualBlock left, nint right) => left.Handle == right;
public static bool operator !=(VirtualBlock left, nint right) => left.Handle != right;
public bool Equals(VirtualBlock other) => Handle == other.Handle;
/// <inheritdoc/>
public override bool Equals(object? obj) => obj is VirtualBlock handle && Equals(handle);
/// <inheritdoc/>
public override int GetHashCode() => Handle.GetHashCode();
private string DebuggerDisplay => $"{nameof(VirtualBlock)} [0x{Handle:X}]";
}
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public readonly partial struct DefragmentationContext : IEquatable<DefragmentationContext>
{
public DefragmentationContext(nint handle) { Handle = handle; }
public nint Handle { get; }
public bool IsNull => Handle == 0;
public bool IsNotNull => Handle != 0;
public static DefragmentationContext Null => new(0);
public static implicit operator DefragmentationContext(nint handle) => new(handle);
public static implicit operator nint(DefragmentationContext handle) => handle.Handle;
public static bool operator ==(DefragmentationContext left, DefragmentationContext right) => left.Handle == right.Handle;
public static bool operator !=(DefragmentationContext left, DefragmentationContext right) => left.Handle != right.Handle;
public static bool operator ==(DefragmentationContext left, nint right) => left.Handle == right;
public static bool operator !=(DefragmentationContext left, nint right) => left.Handle != right;
public bool Equals(DefragmentationContext other) => Handle == other.Handle;
/// <inheritdoc/>
public override bool Equals(object? obj) => obj is DefragmentationContext handle && Equals(handle);
/// <inheritdoc/>
public override int GetHashCode() => Handle.GetHashCode();
private string DebuggerDisplay => $"{nameof(DefragmentationContext)} [0x{Handle:X}]";
}

View File

@@ -0,0 +1,11 @@
// Copyright © Amer Koleci and Contributors.
// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information.
using static Win32.Apis;
using static Win32.Graphics.D3D12MemoryAllocator.Apis;
namespace Win32.Graphics.D3D12MemoryAllocator;
partial struct Pool
{
}

View File

@@ -0,0 +1,80 @@
// Copyright © Amer Koleci and Contributors.
// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information.
using Win32.Graphics.Direct3D12;
using Win32.Graphics.Dxgi;
namespace Win32.Graphics.D3D12MemoryAllocator;
/// <unmanaged>D3D12MA_ALLOCATION_CALLBACKS</unmanaged>
public unsafe partial struct AllocationCallbacks
{
/// <summary>Allocation function.</summary>
/// <unmanaged>D3D12MA_AllocateFunctionType</unmanaged>
public delegate* unmanaged<nuint, nuint, void*, void*> pAllocate;
/// <summary>Dellocation function.</summary>
/// <unmanaged>D3D12MA_FreeFunctionType</unmanaged>
public delegate* unmanaged<void*, void*, void> pFree;
/// <summary>Custom data that will be passed to allocation and deallocation functions as <c>pUserData</c> parameter.</summary>
public void* pPrivateData;
}
/// <unmanaged>D3D12MA_ALLOCATOR_DESC</unmanaged>
public unsafe partial struct AllocatorDesc
{
public AllocatorFlags Flags;
public ID3D12Device* pDevice;
public ulong PreferredBlockSize;
public AllocationCallbacks* pAllocationCallbacks;
public IDXGIAdapter* pAdapter;
}
/// <unmanaged>D3D12MA_POOL_DESC</unmanaged>
public unsafe partial struct PoolDesc
{
public PoolFlags Flags;
public HeapProperties HeapProperties;
public HeapFlags HeapFlags;
public ulong BlockSize;
public uint MinBlockCount;
public uint MaxBlockCount;
public ulong MinAllocationAlignment;
public ID3D12ProtectedResourceSession* pProtectedSession;
public ResidencyPriority ResidencyPriority;
}
/// <unmanaged>D3D12MA_VIRTUAL_BLOCK_DESC</unmanaged>
public unsafe partial struct VirtualBlockDesc
{
public VirtualBlockFlags Flags;
public ulong Size;
public AllocationCallbacks* pAllocationCallbacks;
}
/// <unmanaged>D3D12MA_ALLOCATION_DESC</unmanaged>
public unsafe partial struct AllocationDesc
{
public AllocationFlags Flags;
public HeapType HeapType;
public HeapFlags ExtraHeapFlags;
public Pool* CustomPool;
public void* pPrivateData;
}
/// <unmanaged>D3D12MA_VIRTUAL_ALLOCATION_DESC</unmanaged>
public unsafe partial struct D3D12MA_VIRTUAL_ALLOCATION_DESC
{
public VirtualAllocationFlags Flags;
public ulong Size;
public ulong Alignment;
public void* pPrivateData;
}
public unsafe partial struct D3D12MA_VIRTUAL_ALLOCATION_INFO
{
public ulong Offset;
public ulong Size;
public void* pPrivateData;
}

View File

@@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<Description>D3D12MemoryAllocator bindings</Description>
<NoWarn>$(NoWarn);CS0419;IDE0017</NoWarn>
</PropertyGroup>
<ItemGroup>
<Using Include="System.Numerics" />
<Using Include="System.Diagnostics" />
<Using Include="System.Runtime.CompilerServices" />
<Using Include="System.Runtime.InteropServices" />
<Using Include="System.Diagnostics.CodeAnalysis" />
<Using Include="Win32.Numerics" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Vortice.D3D12MA.Native\Vortice.D3D12MA.Native.csproj" />
<ProjectReference Include="..\Vortice.Win32.Graphics.Direct3D12\Vortice.Win32.Graphics.Direct3D12.csproj" />
<ProjectReference Include="..\Vortice.Win32.Graphics.Dxgi\Vortice.Win32.Graphics.Dxgi.csproj" />
</ItemGroup>
</Project>

View File

@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0</TargetFrameworks>
<Description>Direct2D1 bindings.</Description>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<Description>Direct2D1 bindings</Description>
<NoWarn>$(NoWarn);CS0419;IDE0017</NoWarn>
</PropertyGroup>

View File

@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0</TargetFrameworks>
<Description>DXC (DirectXShaderCompiler) bindings.</Description>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<Description>DXC (DirectXShaderCompiler) bindings</Description>
<NoWarn>$(NoWarn);CS0419;IDE0017</NoWarn>
</PropertyGroup>

View File

@@ -1,9 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0</TargetFrameworks>
<Description>FXC bindings.</Description>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<Description>FXC bindings</Description>
<NoWarn>$(NoWarn);CS0419;IDE0017</NoWarn>
</PropertyGroup>

View File

@@ -1,9 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0</TargetFrameworks>
<Description>Direct3D11 bindings.</Description>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<Description>Direct3D11 bindings</Description>
<NoWarn>$(NoWarn);CS0419;IDE0017</NoWarn>
</PropertyGroup>

View File

@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0</TargetFrameworks>
<Description>Direct3D11on12 bindings.</Description>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<Description>Direct3D11on12 bindings</Description>
<NoWarn>$(NoWarn);CS0419;IDE0017</NoWarn>
</PropertyGroup>

View File

@@ -1,9 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0</TargetFrameworks>
<Description>Direct3D12 bindings.</Description>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<Description>Direct3D12 bindings</Description>
<NoWarn>$(NoWarn);CS0419;IDE0017</NoWarn>
</PropertyGroup>

View File

@@ -1,9 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0</TargetFrameworks>
<Description>DirectComposition bindings.</Description>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<Description>DirectComposition bindings</Description>
<NoWarn>$(NoWarn);CS0419;IDE0017</NoWarn>
</PropertyGroup>

View File

@@ -1,9 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0</TargetFrameworks>
<Description>DirectWrite bindings.</Description>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<Description>DirectWrite bindings</Description>
<NoWarn>$(NoWarn);CS0419;IDE0017</NoWarn>
</PropertyGroup>

View File

@@ -1,9 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0</TargetFrameworks>
<Description>Dxgi bindings.</Description>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<Description>DXGI bindings</Description>
<NoWarn>$(NoWarn);CS0419;IDE0017</NoWarn>
</PropertyGroup>

View File

@@ -1,9 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0</TargetFrameworks>
<Description>WIC bindings.</Description>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<Description>WIC bindings</Description>
<NoWarn>$(NoWarn);CS0419;IDE0017</NoWarn>
</PropertyGroup>

View File

@@ -1,9 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0</TargetFrameworks>
<Description>XAudio2 and X3DAudio bindings.</Description>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<Description>XAudio2 and X3DAudio bindings</Description>
<NoWarn>$(NoWarn);CS0419;IDE0017</NoWarn>
</PropertyGroup>

View File

@@ -13,7 +13,7 @@ namespace Win32;
/// <typeparam name="T">The type to wrap in the current <see cref="ComPtr{T}"/> instance.</typeparam>
/// <remarks>While this type is not marked as <see langword="ref"/> so that it can also be used in fields, make sure to keep the reference counts properly tracked if you do store <see cref="ComPtr{T}"/> instances on the heap.</remarks>
public unsafe struct ComPtr<T> : IDisposable
where T : unmanaged
where T : unmanaged, IUnknown.Interface
{
/// <summary>The raw pointer to a COM object, if existing.</summary>
private T* ptr_;
@@ -38,7 +38,7 @@ public unsafe struct ComPtr<T> : IDisposable
/// <param name="other">The raw pointer to wrap.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator ComPtr<T>(T* other)
=> new ComPtr<T>(other);
=> new(other);
/// <summary>Unwraps a <see cref="ComPtr{T}"/> instance and returns the internal raw pointer.</summary>
/// <param name="other">The <see cref="ComPtr{T}"/> instance to unwrap.</param>
@@ -52,9 +52,9 @@ public unsafe struct ComPtr<T> : IDisposable
/// <returns>The result of <see cref="IUnknown.QueryInterface"/> for the target type <typeparamref name="U"/>.</returns>
/// <remarks>This method will automatically release the target COM object pointed to by <paramref name="p"/>, if any.</remarks>
public readonly HResult As<U>(ComPtr<U>* p)
where U : unmanaged, INativeGuid
where U : unmanaged, IUnknown.Interface
{
return ((IUnknown*)ptr_)->QueryInterface(__uuidof<U>(), (void**)p->ReleaseAndGetAddressOf());
return ptr_->QueryInterface(__uuidof<U>(), (void**)p->ReleaseAndGetAddressOf());
}
/// <summary>Converts the current object reference to type <typeparamref name="U"/> and assigns that to a target <see cref="ComPtr{T}"/> value.</summary>
@@ -63,10 +63,10 @@ public unsafe struct ComPtr<T> : IDisposable
/// <returns>The result of <see cref="IUnknown.QueryInterface"/> for the target type <typeparamref name="U"/>.</returns>
/// <remarks>This method will automatically release the target COM object pointed to by <paramref name="other"/>, if any.</remarks>
public readonly HResult As<U>(ref ComPtr<U> other)
where U : unmanaged, INativeGuid
where U : unmanaged, IUnknown.Interface
{
U* ptr;
HResult result = ((IUnknown*)ptr_)->QueryInterface(__uuidof<U>(), (void**)&ptr);
HResult result = ptr_->QueryInterface(__uuidof<U>(), (void**)&ptr);
other.Attach(ptr);
return result;
@@ -79,7 +79,7 @@ public unsafe struct ComPtr<T> : IDisposable
/// <remarks>This method will automatically release the target COM object pointed to by <paramref name="other"/>, if any.</remarks>
public readonly HResult AsIID(Guid* riid, ComPtr<IUnknown>* other)
{
return ((IUnknown*)ptr_)->QueryInterface(riid, (void**)other->ReleaseAndGetAddressOf());
return ptr_->QueryInterface(riid, (void**)other->ReleaseAndGetAddressOf());
}
/// <summary>Converts the current object reference to a type indicated by the given IID and assigns that to a target <see cref="ComPtr{T}"/> value.</summary>
@@ -90,7 +90,7 @@ public unsafe struct ComPtr<T> : IDisposable
public readonly HResult AsIID(Guid* riid, ref ComPtr<IUnknown> other)
{
IUnknown* ptr;
HResult result = ((IUnknown*)ptr_)->QueryInterface(riid, (void**)&ptr);
HResult result = ptr_->QueryInterface(riid, (void**)&ptr);
other.Attach(ptr);
return result;
@@ -103,7 +103,7 @@ public unsafe struct ComPtr<T> : IDisposable
{
if (ptr_ != null)
{
var @ref = ((IUnknown*)ptr_)->Release();
var @ref = ptr_->Release();
Debug.Assert((@ref != 0) || (ptr_ != other));
}
ptr_ = other;
@@ -153,28 +153,28 @@ public unsafe struct ComPtr<T> : IDisposable
/// <param name="ptr">The target raw pointer to copy the address of the current COM object to.</param>
/// <returns>The result of <see cref="IUnknown.QueryInterface"/> for the target type <typeparamref name="U"/>.</returns>
public readonly HResult CopyTo<U>(U** ptr)
where U : unmanaged, INativeGuid
where U : unmanaged, IUnknown.Interface
{
return ((IUnknown*)ptr_)->QueryInterface(__uuidof<U>(), (void**)ptr);
return ptr_->QueryInterface(__uuidof<U>(), (void**)ptr);
}
/// <summary>Converts the current COM object reference to a given interface type and assigns that to a target <see cref="ComPtr{T}"/>.</summary>
/// <param name="p">The target raw pointer to copy the address of the current COM object to.</param>
/// <returns>The result of <see cref="IUnknown.QueryInterface"/> for the target type <typeparamref name="U"/>.</returns>
public readonly HResult CopyTo<U>(ComPtr<U>* p)
where U : unmanaged, INativeGuid
where U : unmanaged, IUnknown.Interface
{
return ((IUnknown*)ptr_)->QueryInterface(__uuidof<U>(), (void**)p->ReleaseAndGetAddressOf());
return ptr_->QueryInterface(__uuidof<U>(), (void**)p->ReleaseAndGetAddressOf());
}
/// <summary>Converts the current COM object reference to a given interface type and assigns that to a target <see cref="ComPtr{T}"/>.</summary>
/// <param name="other">The target reference to copy the address of the current COM object to.</param>
/// <returns>The result of <see cref="IUnknown.QueryInterface"/> for the target type <typeparamref name="U"/>.</returns>
public readonly HResult CopyTo<U>(ref ComPtr<U> other)
where U : unmanaged, INativeGuid
where U : unmanaged, IUnknown.Interface
{
U* ptr;
HResult result = ((IUnknown*)ptr_)->QueryInterface(__uuidof<U>(), (void**)&ptr);
HResult result = ptr_->QueryInterface(__uuidof<U>(), (void**)&ptr);
other.Attach(ptr);
return result;
@@ -186,7 +186,7 @@ public unsafe struct ComPtr<T> : IDisposable
/// <returns>The result of <see cref="IUnknown.QueryInterface"/> for the target IID.</returns>
public readonly HResult CopyTo(Guid* riid, void** ptr)
{
return ((IUnknown*)ptr_)->QueryInterface(riid, ptr);
return ptr_->QueryInterface(riid, ptr);
}
/// <summary>Converts the current object reference to a type indicated by the given IID and assigns that to a target <see cref="ComPtr{T}"/> value.</summary>
@@ -195,7 +195,7 @@ public unsafe struct ComPtr<T> : IDisposable
/// <returns>The result of <see cref="IUnknown.QueryInterface"/> for the target IID.</returns>
public readonly HResult CopyTo(Guid* riid, ComPtr<IUnknown>* p)
{
return ((IUnknown*)ptr_)->QueryInterface(riid, (void**)p->ReleaseAndGetAddressOf());
return ptr_->QueryInterface(riid, (void**)p->ReleaseAndGetAddressOf());
}
/// <summary>Converts the current object reference to a type indicated by the given IID and assigns that to a target <see cref="ComPtr{T}"/> value.</summary>
@@ -205,7 +205,7 @@ public unsafe struct ComPtr<T> : IDisposable
public readonly HResult CopyTo(Guid* riid, ref ComPtr<IUnknown> other)
{
IUnknown* ptr;
HResult result = ((IUnknown*)ptr_)->QueryInterface(riid, (void**)&ptr);
HResult result = ptr_->QueryInterface(riid, (void**)&ptr);
other.Attach(ptr);
return result;
@@ -220,7 +220,7 @@ public unsafe struct ComPtr<T> : IDisposable
if (pointer != null)
{
ptr_ = null;
_ = ((IUnknown*)pointer)->Release();
_ = pointer->Release();
}
}
@@ -254,17 +254,6 @@ public unsafe struct ComPtr<T> : IDisposable
return (void**)Unsafe.AsPointer(ref Unsafe.AsRef(in this));
}
/// <summary>
/// Gets the address of the current <see cref="ComPtr{T}"/> instance as a raw <see cref="IUnknown"/> double pointer.
/// This method is only valid when the current <see cref="ComPtr{T}"/> instance is on the stack or pinned.
/// </summary>
/// <returns>The raw pointer to the current <see cref="ComPtr{T}"/> instance.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly IUnknown** GetIUnknownAddressOf()
{
return (IUnknown**)Unsafe.AsPointer(ref Unsafe.AsRef(in this));
}
/// <summary>Gets the address of the current <see cref="ComPtr{T}"/> instance as a raw <typeparamref name="T"/> double pointer.</summary>
/// <returns>The raw pointer to the current <see cref="ComPtr{T}"/> instance.</returns>
[EditorBrowsable(EditorBrowsableState.Never)]
@@ -309,10 +298,7 @@ public unsafe struct ComPtr<T> : IDisposable
/// <summary>Resets the current instance by decrementing the reference count for the target COM object and setting the internal raw pointer to <see langword="null"/>.</summary>
/// <returns>The updated reference count for the COM object that was in use, if any.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public uint Reset()
{
return InternalRelease();
}
public uint Reset() => InternalRelease();
/// <summary>Swaps the current COM object reference with that of a given <see cref="ComPtr{T}"/> instance.</summary>
/// <param name="r">The target <see cref="ComPtr{T}"/> instance to swap with the current one.</param>
@@ -341,7 +327,7 @@ public unsafe struct ComPtr<T> : IDisposable
if (temp != null)
{
_ = ((IUnknown*)temp)->AddRef();
_ = temp->AddRef();
}
}
@@ -354,7 +340,7 @@ public unsafe struct ComPtr<T> : IDisposable
if (temp != null)
{
ptr_ = null;
@ref = ((IUnknown*)temp)->Release();
@ref = temp->Release();
}
return @ref;

View File

@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0</TargetFrameworks>
<Description>Windows API low level bindings.</Description>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<Description>Windows API low level bindings</Description>
</PropertyGroup>
<ItemGroup>

View File

@@ -10,7 +10,7 @@ public static unsafe partial class Apis
[DoesNotReturn]
public static void ThrowExternalException(string methodName, int errorCode)
{
var message = string.Format("'{0}' failed with an error code of '{1}'", methodName, errorCode);
string message = string.Format("'{0}' failed with an error code of '{1}'", methodName, errorCode);
throw new ExternalException(message, errorCode);
}