diff --git a/src/Generator/Generator.csproj b/src/Generator/Generator.csproj index 9fab0c8..4896e6a 100644 --- a/src/Generator/Generator.csproj +++ b/src/Generator/Generator.csproj @@ -19,4 +19,6 @@ + + diff --git a/src/Generator/Program.cs b/src/Generator/Program.cs index cd087e4..b4f03ac 100644 --- a/src/Generator/Program.cs +++ b/src/Generator/Program.cs @@ -4,6 +4,8 @@ using System; using System.Collections.Generic; using System.Globalization; +using System.Reflection.Metadata; +using System.Reflection; using System.Text; using Newtonsoft.Json; @@ -124,7 +126,6 @@ public static class Program private static readonly Dictionary s_partRenames = new() { - { "CBUFFER", "CBuffer" }, { "TBUFFER", "TBuffer" }, { "NOPERSPECTIVE", "NoPerspective" }, @@ -844,9 +845,21 @@ public static class Program { "D3D11_RLDO_FLAGS", "ReportLiveDeviceObjectFlags" }, { "D3D11_1_CREATE_DEVICE_CONTEXT_STATE_FLAG", "CreateDeviceContextStateFlags" }, { "D3D11_QUERY", "QueryType" }, + { "D3D11_COMPARISON_FUNC", "ComparisonFunction" }, + { "D3D11_STENCIL_OP", "StencilOperation" }, + { "D3D11_BLEND_OP", "BlendOperation" }, + { "D3D11_LOGIC_OP", "LogicOperation" }, + { "D3D11_DEPTH_STENCILOP_DESC", "DepthStencilOperationDescription" }, // D3D12 { "D3D12_RLDO_FLAGS", "ReportLiveDeviceObjectFlags" }, + { "D3D12_COMPARISON_FUNC", "ComparisonFunction" }, + { "D3D12_STENCIL_OP", "StencilOperation" }, + { "D3D12_BLEND_OP", "BlendOperation" }, + { "D3D12_LOGIC_OP", "LogicOperation" }, + { "D3D12_PREDICATION_OP", "PredicationOperation" }, + { "D3D12_AUTO_BREADCRUMB_OP", "AutoBreadcrumbOperation" }, + { "D3D12_DEPTH_STENCILOP_DESC", "DepthStencilOperationDescription" }, // D2D1 { "D2D1_2DAFFINETRANSFORM_INTERPOLATION_MODE", "AffineTransform2DInterpolationMode" }, @@ -1369,7 +1382,7 @@ public static class Program continue; } - WriteFunction(writer, api, function, string.Empty, false); + WriteFunction(writer, api, function, string.Empty, false, false, true); writer.WriteLine(); } } @@ -1377,15 +1390,18 @@ public static class Program writer.WriteLine($"#endregion Functions"); } - private static void WriteFunction( + private static string WriteFunction( CodeWriter writer, ApiData api, ApiType function, string functionName, - bool asCallback) + bool asCallback, + bool asParameter = false, + bool skipUnsafe = false) { string returnType = GetTypeName(function.ReturnType); string functionSuffix = string.Empty; + StringBuilder functionSignature = new(); if (string.IsNullOrEmpty(function.DllImport) == false) { @@ -1399,41 +1415,10 @@ public static class Program int parameterIndex = 0; foreach (ApiParameter parameter in function.Params) { - bool asPointer = false; - string parameterType = string.Empty; - if (parameter.Type.Kind == "ApiRef") - { - if (parameter.Type.TargetKind == "FunctionPointer") - { - ApiType functionType = api.Types.First(item => item.Name == parameter.Type.Name && item.Kind == "FunctionPointer"); - parameterType = "delegate* unmanaged[Stdcall]"; - } - else - { - string fullTypeName = $"{parameter.Type.Api}.{parameter.Type.Name}"; - if (!IsPrimitive(parameter.Type) && !IsEnum(fullTypeName)) - { - asPointer = true; - } - } - } - - if (string.IsNullOrEmpty(parameterType)) - { - parameterType = GetTypeName(parameter.Type, asPointer); - } - - parameterType = NormalizeTypeName(writer.Api, parameterType); - string parameterName = parameter.Name; - - bool isOptional = parameter.Attrs.Any(item => item is string str && str == "Optional"); - if (parameter.Attrs.Any(item => item is string str && str == "ComOutPtr")) - { - if (!IsPrimitive(parameter.Type)) - { - parameterType += "*"; - } - } + GetParameterSignature(api, writer, parameter, + string.Empty, + out string parameterType, + out string parameterName); argumentBuilder.Append(parameterType); @@ -1442,11 +1427,6 @@ public static class Program argumentBuilder.Append(' ').Append(parameterName); } - if (isOptional == true) - { - //argumentBuilder.Append(" = default"); - } - argumentsTypesBuilder.Append(parameterType); argumentsNameBuilder.Append(parameterName); @@ -1466,17 +1446,43 @@ public static class Program functionName = function.Name; } - writer.Write("public "); + if (!asParameter) + { + writer.Write("public "); + functionSignature.Append("public "); + } + + string signature = string.Empty; + if (!skipUnsafe) + { + if (!asParameter || asCallback) + { + signature = "unsafe "; + } + } + if (asCallback) { - writer.Write($"unsafe delegate* unmanaged[Stdcall]<{argumentsString}, {returnType}> {functionName}"); + signature += $"delegate* unmanaged[Stdcall]<{argumentsString}, {returnType}>"; + + if (!asParameter) + { + signature += $" {functionName}"; + } } else { - writer.Write($"{functionSuffix}{returnType} {functionName}({argumentsString})"); + signature += $"{functionSuffix}{returnType} {functionName}({argumentsString})"; } - writer.WriteLine(";"); + functionSignature.Append(signature); + if (!asParameter) + { + writer.Write(signature); + writer.WriteLine(";"); + } + + return functionSignature.ToString(); } private static void GenerateEnum(CodeWriter writer, ApiType enumType, bool autoGenerated) @@ -1784,7 +1790,7 @@ public static class Program if (field.Type.TargetKind == "FunctionPointer") { ApiType functionType = api.Types.First(item => item.Name == field.Type.Name && item.Kind == "FunctionPointer"); - WriteFunction(writer, api, functionType, field.Name, true); + WriteFunction(writer, api, functionType, field.Name, true, false, false); } else { @@ -2003,14 +2009,6 @@ public static class Program StringBuilder argumentsNameBuilder = new(); int parameterIndex = 0; - bool allOptional = false; - - if (method.Name == "EndDraw") - { - allOptional = - method.Params.All(item => item.Attrs.Any(attr => attr is string str && str == "Optional")); - } - bool useReturnAsParameter = false; if (returnType != "void" && method.ReturnType.TargetKind != "Com" && @@ -2044,88 +2042,17 @@ public static class Program foreach (ApiParameter parameter in method.Params) { - bool asPointer = false; - string parameterType = string.Empty; + GetParameterSignature(api, writer, parameter, + $"{comType.Name}::{method.Name}", + out string parameterType, + out string parameterName); - if (parameter.Type.Kind == "ApiRef") - { - if (parameter.Type.TargetKind == "FunctionPointer") - { - ApiType functionType = api.Types.First(item => item.Name == parameter.Type.Name && item.Kind == "FunctionPointer"); - parameterType = "delegate* unmanaged[Stdcall]"; - } - else - { - string fullTypeName = $"{parameter.Type.Api}.{parameter.Type.Name}"; - if (!IsPrimitive(parameter.Type) && !IsEnum(fullTypeName)) - { - asPointer = true; - } - } - } + argumentBuilder + .Append(parameterType) + .Append(' ') + .Append(parameterName); - if (string.IsNullOrEmpty(parameterType)) - { - string parameterNameLookup = $"{comType.Name}::{method.Name}::{parameter.Name}"; - if (s_mapFunctionParameters.TryGetValue(parameterNameLookup, out string? remapType)) - { - parameterType = GetTypeName($"{writer.Api}.{remapType}"); - if (parameter.Attrs.Any(item => item is string str && str == "Out")) - { - parameterType += "*"; - } - } - else - { - parameterType = GetTypeName(parameter.Type, asPointer); - } - } - - parameterType = NormalizeTypeName(writer.Api, parameterType); - string parameterName = parameter.Name; - - bool isOptional = parameter.Attrs.Any(item => item is string str && str == "Optional"); - if (parameter.Attrs.Any(item => item is string str && str == "ComOutPtr")) - { - if (!IsPrimitive(parameter.Type)) - { - parameterType += "*"; - } - } - else if (parameterType.EndsWith("**") == false && - parameter.Attrs.Any(item => item is string str && (str == "RetVal" || str == "Out"))) - { - if (parameter.Type.Child == null) - { - //if (!IsPrimitive(parameter.Type)) - //{ - // parameterType += "*"; - //} - } - else if (parameter.Type.Child.Kind != "ApiRef") - { - if (!IsPrimitive(parameter.Type)) - { - parameterType += "*"; - } - } - else - { - string apiName = GetApiName(parameter.Type.Child); - string fullTypeName = $"{apiName}.{parameter.Type.Child.Name}"; - - if (!IsPrimitive(parameter.Type) && !IsStruct(fullTypeName) && !IsEnum(fullTypeName)) - { - parameterType += "*"; - } - } - } - - parameterName = CleanupName(parameterName); - parameterType = NormalizeTypeName(writer.Api, parameterType); - - argumentBuilder.Append(parameterType).Append(' ').Append(parameterName); - if (allOptional == true && isOptional == true) + if (method.Name == "EndDraw") { argumentBuilder.Append(" = null"); } @@ -2215,6 +2142,102 @@ public static class Program s_visitedComTypes.Add($"{writer.Api}.{comType.Name}", methodsToGenerate); } + private static void GetParameterSignature( + ApiData api, + CodeWriter writer, + ApiParameter parameter, + string memberLookup, + out string parameterType, + out string parameterName) + { + bool asPointer = false; + parameterType = string.Empty; + + if (parameter.Type.Kind == "ApiRef") + { + if (parameter.Type.TargetKind == "FunctionPointer") + { + ApiType functionType = api.Types.First(item => item.Name == parameter.Type.Name && item.Kind == "FunctionPointer"); + parameterType = WriteFunction(writer, api, functionType, parameter.Name, true, true, true); + } + else + { + string fullTypeName = $"{parameter.Type.Api}.{parameter.Type.Name}"; + if (!IsPrimitive(parameter.Type) && !IsEnum(fullTypeName)) + { + asPointer = true; + } + } + } + + if (string.IsNullOrEmpty(parameterType)) + { + if (string.IsNullOrEmpty(memberLookup) == false) + { + string parameterNameLookup = $"{memberLookup}::{parameter.Name}"; + if (s_mapFunctionParameters.TryGetValue(parameterNameLookup, out string? remapType)) + { + parameterType = GetTypeName($"{writer.Api}.{remapType}"); + if (parameter.Attrs.Any(item => item is string str && str == "Out")) + { + parameterType += "*"; + } + } + else + { + parameterType = GetTypeName(parameter.Type, asPointer); + } + } + else + { + parameterType = GetTypeName(parameter.Type, asPointer); + } + } + + parameterType = NormalizeTypeName(writer.Api, parameterType); + + bool isOptional = parameter.Attrs.Any(item => item is string str && str == "Optional"); + if (parameter.Attrs.Any(item => item is string str && str == "ComOutPtr")) + { + if (!IsPrimitive(parameter.Type)) + { + parameterType += "*"; + } + } + else if (parameterType.EndsWith("**") == false && + parameter.Attrs.Any(item => item is string str && (str == "RetVal" || str == "Out"))) + { + if (parameter.Type.Child == null) + { + //if (!IsPrimitive(parameter.Type)) + //{ + // parameterType += "*"; + //} + } + else if (parameter.Type.Child.Kind != "ApiRef") + { + if (!IsPrimitive(parameter.Type)) + { + parameterType += "*"; + } + } + else + { + string apiName = GetApiName(parameter.Type.Child); + string fullTypeName = $"{apiName}.{parameter.Type.Child.Name}"; + + if (!IsPrimitive(parameter.Type) && !IsStruct(fullTypeName) && !IsEnum(fullTypeName)) + { + parameterType += "*"; + } + } + } + + parameterType = NormalizeTypeName(writer.Api, parameterType); + parameterName = parameter.Name; + parameterName = CleanupName(parameterName); + } + private static bool ShouldSkipConstant(ApiDataConstant constant) { if (constant.Name == "_FACDXGI" || diff --git a/src/Vortice.Win32/Generated/Graphics/Direct2D.cs b/src/Vortice.Win32/Generated/Graphics/Direct2D.cs index 46f1fc8..da65e46 100644 --- a/src/Vortice.Win32/Generated/Graphics/Direct2D.cs +++ b/src/Vortice.Win32/Generated/Graphics/Direct2D.cs @@ -5500,10 +5500,10 @@ public static unsafe partial class Apis public static extern Bool32 D2D1InvertMatrix(Matrix3x2* matrix); [DllImport("d2d1", ExactSpelling = true)] - public static extern HResult D2D1CreateDevice(Graphics.Dxgi.IDXGIDevice* dxgiDevice, CreationProperties* creationProperties, ID2D1Device* d2dDevice); + public static extern HResult D2D1CreateDevice(Graphics.Dxgi.IDXGIDevice* dxgiDevice, CreationProperties* creationProperties, ID2D1Device** d2dDevice); [DllImport("d2d1", ExactSpelling = true)] - public static extern HResult D2D1CreateDeviceContext(Graphics.Dxgi.IDXGISurface* dxgiSurface, CreationProperties* creationProperties, ID2D1DeviceContext* d2dDeviceContext); + public static extern HResult D2D1CreateDeviceContext(Graphics.Dxgi.IDXGISurface* dxgiSurface, CreationProperties* creationProperties, ID2D1DeviceContext** d2dDeviceContext); [DllImport("d2d1", ExactSpelling = true)] public static extern Color4 D2D1ConvertColorSpace(ColorSpace sourceColorSpace, ColorSpace destinationColorSpace, Color4* color); diff --git a/src/Vortice.Win32/Generated/Graphics/Direct2D/ID2D1Factory1.cs b/src/Vortice.Win32/Generated/Graphics/Direct2D/ID2D1Factory1.cs index e6d0538..0e3cd09 100644 --- a/src/Vortice.Win32/Generated/Graphics/Direct2D/ID2D1Factory1.cs +++ b/src/Vortice.Win32/Generated/Graphics/Direct2D/ID2D1Factory1.cs @@ -230,17 +230,17 @@ public unsafe partial struct ID2D1Factory1 /// [MethodImpl(MethodImplOptions.AggressiveInlining)] [VtblIndex(22)] - public HResult RegisterEffectFromStream(Guid* classId, Com.IStream* propertyXml, PropertyBinding* bindings, uint bindingsCount, delegate* unmanaged[Stdcall] effectFactory) + public HResult RegisterEffectFromStream(Guid* classId, Com.IStream* propertyXml, PropertyBinding* bindings, uint bindingsCount, delegate* unmanaged[Stdcall] effectFactory) { - return ((delegate* unmanaged[Stdcall], int>)(lpVtbl[22]))((ID2D1Factory1*)Unsafe.AsPointer(ref this), classId, propertyXml, bindings, bindingsCount, effectFactory); + return ((delegate* unmanaged[Stdcall], int>)(lpVtbl[22]))((ID2D1Factory1*)Unsafe.AsPointer(ref this), classId, propertyXml, bindings, bindingsCount, effectFactory); } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] [VtblIndex(23)] - public HResult RegisterEffectFromString(Guid* classId, ushort* propertyXml, PropertyBinding* bindings, uint bindingsCount, delegate* unmanaged[Stdcall] effectFactory) + public HResult RegisterEffectFromString(Guid* classId, ushort* propertyXml, PropertyBinding* bindings, uint bindingsCount, delegate* unmanaged[Stdcall] effectFactory) { - return ((delegate* unmanaged[Stdcall], int>)(lpVtbl[23]))((ID2D1Factory1*)Unsafe.AsPointer(ref this), classId, propertyXml, bindings, bindingsCount, effectFactory); + return ((delegate* unmanaged[Stdcall], int>)(lpVtbl[23]))((ID2D1Factory1*)Unsafe.AsPointer(ref this), classId, propertyXml, bindings, bindingsCount, effectFactory); } /// diff --git a/src/Vortice.Win32/Generated/Graphics/Direct2D/ID2D1Factory2.cs b/src/Vortice.Win32/Generated/Graphics/Direct2D/ID2D1Factory2.cs index 0a50540..20d83fe 100644 --- a/src/Vortice.Win32/Generated/Graphics/Direct2D/ID2D1Factory2.cs +++ b/src/Vortice.Win32/Generated/Graphics/Direct2D/ID2D1Factory2.cs @@ -230,17 +230,17 @@ public unsafe partial struct ID2D1Factory2 /// [MethodImpl(MethodImplOptions.AggressiveInlining)] [VtblIndex(22)] - public HResult RegisterEffectFromStream(Guid* classId, Com.IStream* propertyXml, PropertyBinding* bindings, uint bindingsCount, delegate* unmanaged[Stdcall] effectFactory) + public HResult RegisterEffectFromStream(Guid* classId, Com.IStream* propertyXml, PropertyBinding* bindings, uint bindingsCount, delegate* unmanaged[Stdcall] effectFactory) { - return ((delegate* unmanaged[Stdcall], int>)(lpVtbl[22]))((ID2D1Factory2*)Unsafe.AsPointer(ref this), classId, propertyXml, bindings, bindingsCount, effectFactory); + return ((delegate* unmanaged[Stdcall], int>)(lpVtbl[22]))((ID2D1Factory2*)Unsafe.AsPointer(ref this), classId, propertyXml, bindings, bindingsCount, effectFactory); } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] [VtblIndex(23)] - public HResult RegisterEffectFromString(Guid* classId, ushort* propertyXml, PropertyBinding* bindings, uint bindingsCount, delegate* unmanaged[Stdcall] effectFactory) + public HResult RegisterEffectFromString(Guid* classId, ushort* propertyXml, PropertyBinding* bindings, uint bindingsCount, delegate* unmanaged[Stdcall] effectFactory) { - return ((delegate* unmanaged[Stdcall], int>)(lpVtbl[23]))((ID2D1Factory2*)Unsafe.AsPointer(ref this), classId, propertyXml, bindings, bindingsCount, effectFactory); + return ((delegate* unmanaged[Stdcall], int>)(lpVtbl[23]))((ID2D1Factory2*)Unsafe.AsPointer(ref this), classId, propertyXml, bindings, bindingsCount, effectFactory); } /// diff --git a/src/Vortice.Win32/Generated/Graphics/Direct2D/ID2D1Factory3.cs b/src/Vortice.Win32/Generated/Graphics/Direct2D/ID2D1Factory3.cs index 533b716..0bfc4cf 100644 --- a/src/Vortice.Win32/Generated/Graphics/Direct2D/ID2D1Factory3.cs +++ b/src/Vortice.Win32/Generated/Graphics/Direct2D/ID2D1Factory3.cs @@ -230,17 +230,17 @@ public unsafe partial struct ID2D1Factory3 /// [MethodImpl(MethodImplOptions.AggressiveInlining)] [VtblIndex(22)] - public HResult RegisterEffectFromStream(Guid* classId, Com.IStream* propertyXml, PropertyBinding* bindings, uint bindingsCount, delegate* unmanaged[Stdcall] effectFactory) + public HResult RegisterEffectFromStream(Guid* classId, Com.IStream* propertyXml, PropertyBinding* bindings, uint bindingsCount, delegate* unmanaged[Stdcall] effectFactory) { - return ((delegate* unmanaged[Stdcall], int>)(lpVtbl[22]))((ID2D1Factory3*)Unsafe.AsPointer(ref this), classId, propertyXml, bindings, bindingsCount, effectFactory); + return ((delegate* unmanaged[Stdcall], int>)(lpVtbl[22]))((ID2D1Factory3*)Unsafe.AsPointer(ref this), classId, propertyXml, bindings, bindingsCount, effectFactory); } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] [VtblIndex(23)] - public HResult RegisterEffectFromString(Guid* classId, ushort* propertyXml, PropertyBinding* bindings, uint bindingsCount, delegate* unmanaged[Stdcall] effectFactory) + public HResult RegisterEffectFromString(Guid* classId, ushort* propertyXml, PropertyBinding* bindings, uint bindingsCount, delegate* unmanaged[Stdcall] effectFactory) { - return ((delegate* unmanaged[Stdcall], int>)(lpVtbl[23]))((ID2D1Factory3*)Unsafe.AsPointer(ref this), classId, propertyXml, bindings, bindingsCount, effectFactory); + return ((delegate* unmanaged[Stdcall], int>)(lpVtbl[23]))((ID2D1Factory3*)Unsafe.AsPointer(ref this), classId, propertyXml, bindings, bindingsCount, effectFactory); } /// diff --git a/src/Vortice.Win32/Generated/Graphics/Direct2D/ID2D1Factory4.cs b/src/Vortice.Win32/Generated/Graphics/Direct2D/ID2D1Factory4.cs index 8689420..f2609ea 100644 --- a/src/Vortice.Win32/Generated/Graphics/Direct2D/ID2D1Factory4.cs +++ b/src/Vortice.Win32/Generated/Graphics/Direct2D/ID2D1Factory4.cs @@ -230,17 +230,17 @@ public unsafe partial struct ID2D1Factory4 /// [MethodImpl(MethodImplOptions.AggressiveInlining)] [VtblIndex(22)] - public HResult RegisterEffectFromStream(Guid* classId, Com.IStream* propertyXml, PropertyBinding* bindings, uint bindingsCount, delegate* unmanaged[Stdcall] effectFactory) + public HResult RegisterEffectFromStream(Guid* classId, Com.IStream* propertyXml, PropertyBinding* bindings, uint bindingsCount, delegate* unmanaged[Stdcall] effectFactory) { - return ((delegate* unmanaged[Stdcall], int>)(lpVtbl[22]))((ID2D1Factory4*)Unsafe.AsPointer(ref this), classId, propertyXml, bindings, bindingsCount, effectFactory); + return ((delegate* unmanaged[Stdcall], int>)(lpVtbl[22]))((ID2D1Factory4*)Unsafe.AsPointer(ref this), classId, propertyXml, bindings, bindingsCount, effectFactory); } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] [VtblIndex(23)] - public HResult RegisterEffectFromString(Guid* classId, ushort* propertyXml, PropertyBinding* bindings, uint bindingsCount, delegate* unmanaged[Stdcall] effectFactory) + public HResult RegisterEffectFromString(Guid* classId, ushort* propertyXml, PropertyBinding* bindings, uint bindingsCount, delegate* unmanaged[Stdcall] effectFactory) { - return ((delegate* unmanaged[Stdcall], int>)(lpVtbl[23]))((ID2D1Factory4*)Unsafe.AsPointer(ref this), classId, propertyXml, bindings, bindingsCount, effectFactory); + return ((delegate* unmanaged[Stdcall], int>)(lpVtbl[23]))((ID2D1Factory4*)Unsafe.AsPointer(ref this), classId, propertyXml, bindings, bindingsCount, effectFactory); } /// diff --git a/src/Vortice.Win32/Generated/Graphics/Direct2D/ID2D1Factory5.cs b/src/Vortice.Win32/Generated/Graphics/Direct2D/ID2D1Factory5.cs index 9dac4a5..9de7dab 100644 --- a/src/Vortice.Win32/Generated/Graphics/Direct2D/ID2D1Factory5.cs +++ b/src/Vortice.Win32/Generated/Graphics/Direct2D/ID2D1Factory5.cs @@ -230,17 +230,17 @@ public unsafe partial struct ID2D1Factory5 /// [MethodImpl(MethodImplOptions.AggressiveInlining)] [VtblIndex(22)] - public HResult RegisterEffectFromStream(Guid* classId, Com.IStream* propertyXml, PropertyBinding* bindings, uint bindingsCount, delegate* unmanaged[Stdcall] effectFactory) + public HResult RegisterEffectFromStream(Guid* classId, Com.IStream* propertyXml, PropertyBinding* bindings, uint bindingsCount, delegate* unmanaged[Stdcall] effectFactory) { - return ((delegate* unmanaged[Stdcall], int>)(lpVtbl[22]))((ID2D1Factory5*)Unsafe.AsPointer(ref this), classId, propertyXml, bindings, bindingsCount, effectFactory); + return ((delegate* unmanaged[Stdcall], int>)(lpVtbl[22]))((ID2D1Factory5*)Unsafe.AsPointer(ref this), classId, propertyXml, bindings, bindingsCount, effectFactory); } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] [VtblIndex(23)] - public HResult RegisterEffectFromString(Guid* classId, ushort* propertyXml, PropertyBinding* bindings, uint bindingsCount, delegate* unmanaged[Stdcall] effectFactory) + public HResult RegisterEffectFromString(Guid* classId, ushort* propertyXml, PropertyBinding* bindings, uint bindingsCount, delegate* unmanaged[Stdcall] effectFactory) { - return ((delegate* unmanaged[Stdcall], int>)(lpVtbl[23]))((ID2D1Factory5*)Unsafe.AsPointer(ref this), classId, propertyXml, bindings, bindingsCount, effectFactory); + return ((delegate* unmanaged[Stdcall], int>)(lpVtbl[23]))((ID2D1Factory5*)Unsafe.AsPointer(ref this), classId, propertyXml, bindings, bindingsCount, effectFactory); } /// diff --git a/src/Vortice.Win32/Generated/Graphics/Direct2D/ID2D1Factory6.cs b/src/Vortice.Win32/Generated/Graphics/Direct2D/ID2D1Factory6.cs index 5818e8d..99bedfc 100644 --- a/src/Vortice.Win32/Generated/Graphics/Direct2D/ID2D1Factory6.cs +++ b/src/Vortice.Win32/Generated/Graphics/Direct2D/ID2D1Factory6.cs @@ -230,17 +230,17 @@ public unsafe partial struct ID2D1Factory6 /// [MethodImpl(MethodImplOptions.AggressiveInlining)] [VtblIndex(22)] - public HResult RegisterEffectFromStream(Guid* classId, Com.IStream* propertyXml, PropertyBinding* bindings, uint bindingsCount, delegate* unmanaged[Stdcall] effectFactory) + public HResult RegisterEffectFromStream(Guid* classId, Com.IStream* propertyXml, PropertyBinding* bindings, uint bindingsCount, delegate* unmanaged[Stdcall] effectFactory) { - return ((delegate* unmanaged[Stdcall], int>)(lpVtbl[22]))((ID2D1Factory6*)Unsafe.AsPointer(ref this), classId, propertyXml, bindings, bindingsCount, effectFactory); + return ((delegate* unmanaged[Stdcall], int>)(lpVtbl[22]))((ID2D1Factory6*)Unsafe.AsPointer(ref this), classId, propertyXml, bindings, bindingsCount, effectFactory); } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] [VtblIndex(23)] - public HResult RegisterEffectFromString(Guid* classId, ushort* propertyXml, PropertyBinding* bindings, uint bindingsCount, delegate* unmanaged[Stdcall] effectFactory) + public HResult RegisterEffectFromString(Guid* classId, ushort* propertyXml, PropertyBinding* bindings, uint bindingsCount, delegate* unmanaged[Stdcall] effectFactory) { - return ((delegate* unmanaged[Stdcall], int>)(lpVtbl[23]))((ID2D1Factory6*)Unsafe.AsPointer(ref this), classId, propertyXml, bindings, bindingsCount, effectFactory); + return ((delegate* unmanaged[Stdcall], int>)(lpVtbl[23]))((ID2D1Factory6*)Unsafe.AsPointer(ref this), classId, propertyXml, bindings, bindingsCount, effectFactory); } /// diff --git a/src/Vortice.Win32/Generated/Graphics/Direct2D/ID2D1Factory7.cs b/src/Vortice.Win32/Generated/Graphics/Direct2D/ID2D1Factory7.cs index 67817d7..9a2d4bd 100644 --- a/src/Vortice.Win32/Generated/Graphics/Direct2D/ID2D1Factory7.cs +++ b/src/Vortice.Win32/Generated/Graphics/Direct2D/ID2D1Factory7.cs @@ -230,17 +230,17 @@ public unsafe partial struct ID2D1Factory7 /// [MethodImpl(MethodImplOptions.AggressiveInlining)] [VtblIndex(22)] - public HResult RegisterEffectFromStream(Guid* classId, Com.IStream* propertyXml, PropertyBinding* bindings, uint bindingsCount, delegate* unmanaged[Stdcall] effectFactory) + public HResult RegisterEffectFromStream(Guid* classId, Com.IStream* propertyXml, PropertyBinding* bindings, uint bindingsCount, delegate* unmanaged[Stdcall] effectFactory) { - return ((delegate* unmanaged[Stdcall], int>)(lpVtbl[22]))((ID2D1Factory7*)Unsafe.AsPointer(ref this), classId, propertyXml, bindings, bindingsCount, effectFactory); + return ((delegate* unmanaged[Stdcall], int>)(lpVtbl[22]))((ID2D1Factory7*)Unsafe.AsPointer(ref this), classId, propertyXml, bindings, bindingsCount, effectFactory); } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] [VtblIndex(23)] - public HResult RegisterEffectFromString(Guid* classId, ushort* propertyXml, PropertyBinding* bindings, uint bindingsCount, delegate* unmanaged[Stdcall] effectFactory) + public HResult RegisterEffectFromString(Guid* classId, ushort* propertyXml, PropertyBinding* bindings, uint bindingsCount, delegate* unmanaged[Stdcall] effectFactory) { - return ((delegate* unmanaged[Stdcall], int>)(lpVtbl[23]))((ID2D1Factory7*)Unsafe.AsPointer(ref this), classId, propertyXml, bindings, bindingsCount, effectFactory); + return ((delegate* unmanaged[Stdcall], int>)(lpVtbl[23]))((ID2D1Factory7*)Unsafe.AsPointer(ref this), classId, propertyXml, bindings, bindingsCount, effectFactory); } /// diff --git a/src/Vortice.Win32/Generated/Graphics/Direct3D11.cs b/src/Vortice.Win32/Generated/Graphics/Direct3D11.cs index ed25cc1..16c2fd6 100644 --- a/src/Vortice.Win32/Generated/Graphics/Direct3D11.cs +++ b/src/Vortice.Win32/Generated/Graphics/Direct3D11.cs @@ -2289,7 +2289,7 @@ public enum ClearFlags : int /// /// D3D11_COMPARISON_FUNC -public enum ComparisonFunc : int +public enum ComparisonFunction : int { /// /// D3D11_COMPARISON_NEVER @@ -2331,7 +2331,7 @@ public enum DepthWriteMask : int /// /// D3D11_STENCIL_OP -public enum StencilOp : int +public enum StencilOperation : int { /// /// D3D11_STENCIL_OP_KEEP @@ -2418,7 +2418,7 @@ public enum Blend : int /// /// D3D11_BLEND_OP -public enum BlendOp : int +public enum BlendOperation : int { /// /// D3D11_BLEND_OP_ADD @@ -7898,7 +7898,7 @@ public enum CopyFlags : int /// /// D3D11_LOGIC_OP -public enum LogicOp : int +public enum LogicOperation : int { /// /// D3D11_LOGIC_OP_CLEAR @@ -8544,19 +8544,19 @@ public partial struct Box /// /// D3D11_DEPTH_STENCILOP_DESC -public partial struct DepthStencilOpDescription +public partial struct DepthStencilOperationDescription { /// - public StencilOp StencilFailOp; + public StencilOperation StencilFailOp; /// - public StencilOp StencilDepthFailOp; + public StencilOperation StencilDepthFailOp; /// - public StencilOp StencilPassOp; + public StencilOperation StencilPassOp; /// - public ComparisonFunc StencilFunc; + public ComparisonFunction StencilFunc; } /// @@ -8570,7 +8570,7 @@ public partial struct DepthStencilDescription public DepthWriteMask DepthWriteMask; /// - public ComparisonFunc DepthFunc; + public ComparisonFunction DepthFunc; /// public Bool32 StencilEnable; @@ -8582,10 +8582,10 @@ public partial struct DepthStencilDescription public byte StencilWriteMask; /// - public DepthStencilOpDescription FrontFace; + public DepthStencilOperationDescription FrontFace; /// - public DepthStencilOpDescription BackFace; + public DepthStencilOperationDescription BackFace; } /// @@ -8602,7 +8602,7 @@ public partial struct RenderTargetBlendDescription public Blend DestBlend; /// - public BlendOp BlendOp; + public BlendOperation BlendOp; /// public Blend SrcBlendAlpha; @@ -8611,7 +8611,7 @@ public partial struct RenderTargetBlendDescription public Blend DestBlendAlpha; /// - public BlendOp BlendOpAlpha; + public BlendOperation BlendOpAlpha; /// public ColorWriteEnable RenderTargetWriteMask; @@ -10026,7 +10026,7 @@ public partial struct SamplerDescription public uint MaxAnisotropy; /// - public ComparisonFunc ComparisonFunc; + public ComparisonFunction ComparisonFunc; /// public unsafe fixed float BorderColor[4]; @@ -11481,7 +11481,7 @@ public partial struct RenderTargetBlendDescription1 public Blend DestBlend; /// - public BlendOp BlendOp; + public BlendOperation BlendOp; /// public Blend SrcBlendAlpha; @@ -11490,10 +11490,10 @@ public partial struct RenderTargetBlendDescription1 public Blend DestBlendAlpha; /// - public BlendOp BlendOpAlpha; + public BlendOperation BlendOpAlpha; /// - public LogicOp LogicOp; + public LogicOperation LogicOp; /// public ColorWriteEnable RenderTargetWriteMask; diff --git a/src/Vortice.Win32/Generated/Graphics/Direct3D12.cs b/src/Vortice.Win32/Generated/Graphics/Direct3D12.cs index 6539977..7f5ecb9 100644 --- a/src/Vortice.Win32/Generated/Graphics/Direct3D12.cs +++ b/src/Vortice.Win32/Generated/Graphics/Direct3D12.cs @@ -831,7 +831,7 @@ public enum CullMode : int /// /// D3D12_COMPARISON_FUNC -public enum ComparisonFunc : int +public enum ComparisonFunction : int { /// /// D3D12_COMPARISON_FUNC_NEVER @@ -873,7 +873,7 @@ public enum DepthWriteMask : int /// /// D3D12_STENCIL_OP -public enum StencilOp : int +public enum StencilOperation : int { /// /// D3D12_STENCIL_OP_KEEP @@ -960,7 +960,7 @@ public enum Blend : int /// /// D3D12_BLEND_OP -public enum BlendOp : int +public enum BlendOperation : int { /// /// D3D12_BLEND_OP_ADD @@ -1004,7 +1004,7 @@ public enum ColorWriteEnable : byte /// /// D3D12_LOGIC_OP -public enum LogicOp : int +public enum LogicOperation : int { /// /// D3D12_LOGIC_OP_CLEAR @@ -2854,7 +2854,7 @@ public enum QueryType : int /// /// D3D12_PREDICATION_OP -public enum PredicationOp : int +public enum PredicationOperation : int { /// /// D3D12_PREDICATION_OP_EQUAL_ZERO @@ -3495,7 +3495,7 @@ public enum HitKind : int /// /// D3D12_AUTO_BREADCRUMB_OP -public enum AutoBreadcrumbOp : int +public enum AutoBreadcrumbOperation : int { /// /// D3D12_AUTO_BREADCRUMB_OP_SETMARKER @@ -7016,19 +7016,19 @@ public partial struct Box /// /// D3D12_DEPTH_STENCILOP_DESC -public partial struct DepthStencilOpDescription +public partial struct DepthStencilOperationDescription { /// - public StencilOp StencilFailOp; + public StencilOperation StencilFailOp; /// - public StencilOp StencilDepthFailOp; + public StencilOperation StencilDepthFailOp; /// - public StencilOp StencilPassOp; + public StencilOperation StencilPassOp; /// - public ComparisonFunc StencilFunc; + public ComparisonFunction StencilFunc; } /// @@ -7042,7 +7042,7 @@ public partial struct DepthStencilDescription public DepthWriteMask DepthWriteMask; /// - public ComparisonFunc DepthFunc; + public ComparisonFunction DepthFunc; /// public Bool32 StencilEnable; @@ -7054,10 +7054,10 @@ public partial struct DepthStencilDescription public byte StencilWriteMask; /// - public DepthStencilOpDescription FrontFace; + public DepthStencilOperationDescription FrontFace; /// - public DepthStencilOpDescription BackFace; + public DepthStencilOperationDescription BackFace; } /// @@ -7071,7 +7071,7 @@ public partial struct DepthStencilDescription1 public DepthWriteMask DepthWriteMask; /// - public ComparisonFunc DepthFunc; + public ComparisonFunction DepthFunc; /// public Bool32 StencilEnable; @@ -7083,10 +7083,10 @@ public partial struct DepthStencilDescription1 public byte StencilWriteMask; /// - public DepthStencilOpDescription FrontFace; + public DepthStencilOperationDescription FrontFace; /// - public DepthStencilOpDescription BackFace; + public DepthStencilOperationDescription BackFace; /// public Bool32 DepthBoundsTestEnable; @@ -7109,7 +7109,7 @@ public partial struct RenderTargetBlendDescription public Blend DestBlend; /// - public BlendOp BlendOp; + public BlendOperation BlendOp; /// public Blend SrcBlendAlpha; @@ -7118,10 +7118,10 @@ public partial struct RenderTargetBlendDescription public Blend DestBlendAlpha; /// - public BlendOp BlendOpAlpha; + public BlendOperation BlendOpAlpha; /// - public LogicOp LogicOp; + public LogicOperation LogicOp; /// public ColorWriteEnable RenderTargetWriteMask; @@ -8839,7 +8839,7 @@ public partial struct SamplerDescription public uint MaxAnisotropy; /// - public ComparisonFunc ComparisonFunc; + public ComparisonFunction ComparisonFunc; /// public unsafe fixed float BorderColor[4]; @@ -9681,7 +9681,7 @@ public partial struct StaticSamplerDescription public uint MaxAnisotropy; /// - public ComparisonFunc ComparisonFunc; + public ComparisonFunction ComparisonFunc; /// public StaticBorderColor BorderColor; @@ -10950,7 +10950,7 @@ public partial struct AutoBreadcrumbNode public unsafe uint* pLastBreadcrumbValue; /// - public unsafe AutoBreadcrumbOp* pCommandHistory; + public unsafe AutoBreadcrumbOperation* pCommandHistory; /// public unsafe AutoBreadcrumbNode* pNext; @@ -10996,7 +10996,7 @@ public partial struct AutoBreadcrumbNode1 public unsafe uint* pLastBreadcrumbValue; /// - public unsafe AutoBreadcrumbOp* pCommandHistory; + public unsafe AutoBreadcrumbOperation* pCommandHistory; /// public unsafe AutoBreadcrumbNode1* pNext; @@ -12058,13 +12058,13 @@ public partial struct ParameterDescription public static unsafe partial class Apis { [DllImport("d3d12", ExactSpelling = true)] - public static extern HResult D3D12SerializeRootSignature(RootSignatureDescription* pRootSignature, RootSignatureVersion Version, Graphics.Direct3D.ID3DBlob* ppBlob, Graphics.Direct3D.ID3DBlob* ppErrorBlob); + public static extern HResult D3D12SerializeRootSignature(RootSignatureDescription* pRootSignature, RootSignatureVersion Version, Graphics.Direct3D.ID3DBlob** ppBlob, Graphics.Direct3D.ID3DBlob** ppErrorBlob); [DllImport("d3d12", ExactSpelling = true)] public static extern HResult D3D12CreateRootSignatureDeserializer(void* pSrcData, nuint SrcDataSizeInBytes, Guid* pRootSignatureDeserializerInterface, void** ppRootSignatureDeserializer); [DllImport("d3d12", ExactSpelling = true)] - public static extern HResult D3D12SerializeVersionedRootSignature(VersionedRootSignatureDescription* pRootSignature, Graphics.Direct3D.ID3DBlob* ppBlob, Graphics.Direct3D.ID3DBlob* ppErrorBlob); + public static extern HResult D3D12SerializeVersionedRootSignature(VersionedRootSignatureDescription* pRootSignature, Graphics.Direct3D.ID3DBlob** ppBlob, Graphics.Direct3D.ID3DBlob** ppErrorBlob); [DllImport("d3d12", ExactSpelling = true)] public static extern HResult D3D12CreateVersionedRootSignatureDeserializer(void* pSrcData, nuint SrcDataSizeInBytes, Guid* pRootSignatureDeserializerInterface, void** ppRootSignatureDeserializer); diff --git a/src/Vortice.Win32/Generated/Graphics/Direct3D12/ID3D12GraphicsCommandList.cs b/src/Vortice.Win32/Generated/Graphics/Direct3D12/ID3D12GraphicsCommandList.cs index bf3d083..8f996a7 100644 --- a/src/Vortice.Win32/Generated/Graphics/Direct3D12/ID3D12GraphicsCommandList.cs +++ b/src/Vortice.Win32/Generated/Graphics/Direct3D12/ID3D12GraphicsCommandList.cs @@ -494,9 +494,9 @@ public unsafe partial struct ID3D12GraphicsCommandList /// [MethodImpl(MethodImplOptions.AggressiveInlining)] [VtblIndex(55)] - public void SetPredication(ID3D12Resource* pBuffer, ulong AlignedBufferOffset, PredicationOp Operation) + public void SetPredication(ID3D12Resource* pBuffer, ulong AlignedBufferOffset, PredicationOperation Operation) { - ((delegate* unmanaged[Stdcall])(lpVtbl[55]))((ID3D12GraphicsCommandList*)Unsafe.AsPointer(ref this), pBuffer, AlignedBufferOffset, Operation); + ((delegate* unmanaged[Stdcall])(lpVtbl[55]))((ID3D12GraphicsCommandList*)Unsafe.AsPointer(ref this), pBuffer, AlignedBufferOffset, Operation); } /// diff --git a/src/Vortice.Win32/Generated/Graphics/Direct3D12/ID3D12GraphicsCommandList1.cs b/src/Vortice.Win32/Generated/Graphics/Direct3D12/ID3D12GraphicsCommandList1.cs index 2bb4409..b0ba7c6 100644 --- a/src/Vortice.Win32/Generated/Graphics/Direct3D12/ID3D12GraphicsCommandList1.cs +++ b/src/Vortice.Win32/Generated/Graphics/Direct3D12/ID3D12GraphicsCommandList1.cs @@ -494,9 +494,9 @@ public unsafe partial struct ID3D12GraphicsCommandList1 /// [MethodImpl(MethodImplOptions.AggressiveInlining)] [VtblIndex(55)] - public void SetPredication(ID3D12Resource* pBuffer, ulong AlignedBufferOffset, PredicationOp Operation) + public void SetPredication(ID3D12Resource* pBuffer, ulong AlignedBufferOffset, PredicationOperation Operation) { - ((delegate* unmanaged[Stdcall])(lpVtbl[55]))((ID3D12GraphicsCommandList1*)Unsafe.AsPointer(ref this), pBuffer, AlignedBufferOffset, Operation); + ((delegate* unmanaged[Stdcall])(lpVtbl[55]))((ID3D12GraphicsCommandList1*)Unsafe.AsPointer(ref this), pBuffer, AlignedBufferOffset, Operation); } /// diff --git a/src/Vortice.Win32/Generated/Graphics/Direct3D12/ID3D12GraphicsCommandList2.cs b/src/Vortice.Win32/Generated/Graphics/Direct3D12/ID3D12GraphicsCommandList2.cs index fd3e769..04ae706 100644 --- a/src/Vortice.Win32/Generated/Graphics/Direct3D12/ID3D12GraphicsCommandList2.cs +++ b/src/Vortice.Win32/Generated/Graphics/Direct3D12/ID3D12GraphicsCommandList2.cs @@ -494,9 +494,9 @@ public unsafe partial struct ID3D12GraphicsCommandList2 /// [MethodImpl(MethodImplOptions.AggressiveInlining)] [VtblIndex(55)] - public void SetPredication(ID3D12Resource* pBuffer, ulong AlignedBufferOffset, PredicationOp Operation) + public void SetPredication(ID3D12Resource* pBuffer, ulong AlignedBufferOffset, PredicationOperation Operation) { - ((delegate* unmanaged[Stdcall])(lpVtbl[55]))((ID3D12GraphicsCommandList2*)Unsafe.AsPointer(ref this), pBuffer, AlignedBufferOffset, Operation); + ((delegate* unmanaged[Stdcall])(lpVtbl[55]))((ID3D12GraphicsCommandList2*)Unsafe.AsPointer(ref this), pBuffer, AlignedBufferOffset, Operation); } /// diff --git a/src/Vortice.Win32/Generated/Graphics/Direct3D12/ID3D12GraphicsCommandList3.cs b/src/Vortice.Win32/Generated/Graphics/Direct3D12/ID3D12GraphicsCommandList3.cs index 9775c28..ee2eac2 100644 --- a/src/Vortice.Win32/Generated/Graphics/Direct3D12/ID3D12GraphicsCommandList3.cs +++ b/src/Vortice.Win32/Generated/Graphics/Direct3D12/ID3D12GraphicsCommandList3.cs @@ -494,9 +494,9 @@ public unsafe partial struct ID3D12GraphicsCommandList3 /// [MethodImpl(MethodImplOptions.AggressiveInlining)] [VtblIndex(55)] - public void SetPredication(ID3D12Resource* pBuffer, ulong AlignedBufferOffset, PredicationOp Operation) + public void SetPredication(ID3D12Resource* pBuffer, ulong AlignedBufferOffset, PredicationOperation Operation) { - ((delegate* unmanaged[Stdcall])(lpVtbl[55]))((ID3D12GraphicsCommandList3*)Unsafe.AsPointer(ref this), pBuffer, AlignedBufferOffset, Operation); + ((delegate* unmanaged[Stdcall])(lpVtbl[55]))((ID3D12GraphicsCommandList3*)Unsafe.AsPointer(ref this), pBuffer, AlignedBufferOffset, Operation); } /// diff --git a/src/Vortice.Win32/Generated/Graphics/Direct3D12/ID3D12GraphicsCommandList4.cs b/src/Vortice.Win32/Generated/Graphics/Direct3D12/ID3D12GraphicsCommandList4.cs index 505ee64..c266bba 100644 --- a/src/Vortice.Win32/Generated/Graphics/Direct3D12/ID3D12GraphicsCommandList4.cs +++ b/src/Vortice.Win32/Generated/Graphics/Direct3D12/ID3D12GraphicsCommandList4.cs @@ -494,9 +494,9 @@ public unsafe partial struct ID3D12GraphicsCommandList4 /// [MethodImpl(MethodImplOptions.AggressiveInlining)] [VtblIndex(55)] - public void SetPredication(ID3D12Resource* pBuffer, ulong AlignedBufferOffset, PredicationOp Operation) + public void SetPredication(ID3D12Resource* pBuffer, ulong AlignedBufferOffset, PredicationOperation Operation) { - ((delegate* unmanaged[Stdcall])(lpVtbl[55]))((ID3D12GraphicsCommandList4*)Unsafe.AsPointer(ref this), pBuffer, AlignedBufferOffset, Operation); + ((delegate* unmanaged[Stdcall])(lpVtbl[55]))((ID3D12GraphicsCommandList4*)Unsafe.AsPointer(ref this), pBuffer, AlignedBufferOffset, Operation); } /// diff --git a/src/Vortice.Win32/Generated/Graphics/Direct3D12/ID3D12GraphicsCommandList5.cs b/src/Vortice.Win32/Generated/Graphics/Direct3D12/ID3D12GraphicsCommandList5.cs index 01c2870..3e4ac4b 100644 --- a/src/Vortice.Win32/Generated/Graphics/Direct3D12/ID3D12GraphicsCommandList5.cs +++ b/src/Vortice.Win32/Generated/Graphics/Direct3D12/ID3D12GraphicsCommandList5.cs @@ -494,9 +494,9 @@ public unsafe partial struct ID3D12GraphicsCommandList5 /// [MethodImpl(MethodImplOptions.AggressiveInlining)] [VtblIndex(55)] - public void SetPredication(ID3D12Resource* pBuffer, ulong AlignedBufferOffset, PredicationOp Operation) + public void SetPredication(ID3D12Resource* pBuffer, ulong AlignedBufferOffset, PredicationOperation Operation) { - ((delegate* unmanaged[Stdcall])(lpVtbl[55]))((ID3D12GraphicsCommandList5*)Unsafe.AsPointer(ref this), pBuffer, AlignedBufferOffset, Operation); + ((delegate* unmanaged[Stdcall])(lpVtbl[55]))((ID3D12GraphicsCommandList5*)Unsafe.AsPointer(ref this), pBuffer, AlignedBufferOffset, Operation); } /// diff --git a/src/Vortice.Win32/Generated/Graphics/Direct3D12/ID3D12GraphicsCommandList6.cs b/src/Vortice.Win32/Generated/Graphics/Direct3D12/ID3D12GraphicsCommandList6.cs index 2a56ae7..6a538de 100644 --- a/src/Vortice.Win32/Generated/Graphics/Direct3D12/ID3D12GraphicsCommandList6.cs +++ b/src/Vortice.Win32/Generated/Graphics/Direct3D12/ID3D12GraphicsCommandList6.cs @@ -494,9 +494,9 @@ public unsafe partial struct ID3D12GraphicsCommandList6 /// [MethodImpl(MethodImplOptions.AggressiveInlining)] [VtblIndex(55)] - public void SetPredication(ID3D12Resource* pBuffer, ulong AlignedBufferOffset, PredicationOp Operation) + public void SetPredication(ID3D12Resource* pBuffer, ulong AlignedBufferOffset, PredicationOperation Operation) { - ((delegate* unmanaged[Stdcall])(lpVtbl[55]))((ID3D12GraphicsCommandList6*)Unsafe.AsPointer(ref this), pBuffer, AlignedBufferOffset, Operation); + ((delegate* unmanaged[Stdcall])(lpVtbl[55]))((ID3D12GraphicsCommandList6*)Unsafe.AsPointer(ref this), pBuffer, AlignedBufferOffset, Operation); } /// diff --git a/src/Vortice.Win32/Generated/Graphics/Direct3D12/ID3D12InfoQueue1.cs b/src/Vortice.Win32/Generated/Graphics/Direct3D12/ID3D12InfoQueue1.cs index ffaf710..60c6fb6 100644 --- a/src/Vortice.Win32/Generated/Graphics/Direct3D12/ID3D12InfoQueue1.cs +++ b/src/Vortice.Win32/Generated/Graphics/Direct3D12/ID3D12InfoQueue1.cs @@ -358,9 +358,9 @@ public unsafe partial struct ID3D12InfoQueue1 /// [MethodImpl(MethodImplOptions.AggressiveInlining)] [VtblIndex(38)] - public HResult RegisterMessageCallback(delegate* unmanaged[Stdcall] CallbackFunc, MessageCallbackFlags CallbackFilterFlags, void* pContext, uint* pCallbackCookie) + public HResult RegisterMessageCallback(delegate* unmanaged[Stdcall] CallbackFunc, MessageCallbackFlags CallbackFilterFlags, void* pContext, uint* pCallbackCookie) { - return ((delegate* unmanaged[Stdcall], MessageCallbackFlags, void*, uint*, int>)(lpVtbl[38]))((ID3D12InfoQueue1*)Unsafe.AsPointer(ref this), CallbackFunc, CallbackFilterFlags, pContext, pCallbackCookie); + return ((delegate* unmanaged[Stdcall], MessageCallbackFlags, void*, uint*, int>)(lpVtbl[38]))((ID3D12InfoQueue1*)Unsafe.AsPointer(ref this), CallbackFunc, CallbackFilterFlags, pContext, pCallbackCookie); } /// diff --git a/src/Vortice.Win32/Generated/Graphics/Imaging.cs b/src/Vortice.Win32/Generated/Graphics/Imaging.cs index 0f6b01b..8c73ca3 100644 --- a/src/Vortice.Win32/Generated/Graphics/Imaging.cs +++ b/src/Vortice.Win32/Generated/Graphics/Imaging.cs @@ -7788,13 +7788,13 @@ public partial struct WICMetadataHeader public static unsafe partial class Apis { [DllImport("WindowsCodecs", ExactSpelling = true)] - public static extern HResult WICConvertBitmapSource(Guid* dstFormat, IWICBitmapSource* pISrc, IWICBitmapSource* ppIDst); + public static extern HResult WICConvertBitmapSource(Guid* dstFormat, IWICBitmapSource* pISrc, IWICBitmapSource** ppIDst); [DllImport("WindowsCodecs", ExactSpelling = true)] - public static extern HResult WICCreateBitmapFromSection(uint width, uint height, Guid* pixelFormat, Handle hSection, uint stride, uint offset, IWICBitmap* ppIBitmap); + public static extern HResult WICCreateBitmapFromSection(uint width, uint height, Guid* pixelFormat, Handle hSection, uint stride, uint offset, IWICBitmap** ppIBitmap); [DllImport("WindowsCodecs", ExactSpelling = true)] - public static extern HResult WICCreateBitmapFromSectionEx(uint width, uint height, Guid* pixelFormat, Handle hSection, uint stride, uint offset, WICSectionAccessLevel desiredAccessLevel, IWICBitmap* ppIBitmap); + public static extern HResult WICCreateBitmapFromSectionEx(uint width, uint height, Guid* pixelFormat, Handle hSection, uint stride, uint offset, WICSectionAccessLevel desiredAccessLevel, IWICBitmap** ppIBitmap); [DllImport("WindowsCodecs", ExactSpelling = true)] public static extern HResult WICMapGuidToShortName(Guid* guid, uint cchName, ushort* wzName, uint* pcchActual); diff --git a/src/Vortice.Win32/Generated/Graphics/Imaging/IWICBitmapCodecProgressNotification.cs b/src/Vortice.Win32/Generated/Graphics/Imaging/IWICBitmapCodecProgressNotification.cs index 029263a..f28158b 100644 --- a/src/Vortice.Win32/Generated/Graphics/Imaging/IWICBitmapCodecProgressNotification.cs +++ b/src/Vortice.Win32/Generated/Graphics/Imaging/IWICBitmapCodecProgressNotification.cs @@ -78,9 +78,9 @@ public unsafe partial struct IWICBitmapCodecProgressNotification /// [MethodImpl(MethodImplOptions.AggressiveInlining)] [VtblIndex(3)] - public HResult RegisterProgressNotification(delegate* unmanaged[Stdcall] pfnProgressNotification, void* pvData, uint dwProgressFlags) + public HResult RegisterProgressNotification(delegate* unmanaged[Stdcall] pfnProgressNotification, void* pvData, uint dwProgressFlags) { - return ((delegate* unmanaged[Stdcall], void*, uint, int>)(lpVtbl[3]))((IWICBitmapCodecProgressNotification*)Unsafe.AsPointer(ref this), pfnProgressNotification, pvData, dwProgressFlags); + return ((delegate* unmanaged[Stdcall], void*, uint, int>)(lpVtbl[3]))((IWICBitmapCodecProgressNotification*)Unsafe.AsPointer(ref this), pfnProgressNotification, pvData, dwProgressFlags); } } diff --git a/src/Vortice.Win32/Graphics/Direct3D11/BlendDescription.cs b/src/Vortice.Win32/Graphics/Direct3D11/BlendDescription.cs index 8d85062..7e8f37c 100644 --- a/src/Vortice.Win32/Graphics/Direct3D11/BlendDescription.cs +++ b/src/Vortice.Win32/Graphics/Direct3D11/BlendDescription.cs @@ -54,10 +54,10 @@ public unsafe partial struct BlendDescription { RenderTarget[i].SrcBlend = sourceBlend; RenderTarget[i].DestBlend = destinationBlend; - RenderTarget[i].BlendOp = BlendOp.Add; + RenderTarget[i].BlendOp = BlendOperation.Add; RenderTarget[i].SrcBlendAlpha = srcBlendAlpha; RenderTarget[i].DestBlendAlpha = destBlendAlpha; - RenderTarget[i].BlendOpAlpha = BlendOp.Add; + RenderTarget[i].BlendOpAlpha = BlendOperation.Add; RenderTarget[i].RenderTargetWriteMask = ColorWriteEnable.All; RenderTarget[i].BlendEnable = IsBlendEnabled(ref RenderTarget[i]); } @@ -65,10 +65,10 @@ public unsafe partial struct BlendDescription private static bool IsBlendEnabled(ref RenderTargetBlendDescription renderTarget) { - return renderTarget.BlendOp != BlendOp.Add + return renderTarget.BlendOp != BlendOperation.Add || renderTarget.SrcBlend != Blend.One || renderTarget.DestBlendAlpha != Blend.Zero - || renderTarget.BlendOp != BlendOp.Add + || renderTarget.BlendOp != BlendOperation.Add || renderTarget.SrcBlend != Blend.One || renderTarget.DestBlend != Blend.Zero; } diff --git a/src/Vortice.Win32/Graphics/Direct3D11/BlendDescription1.cs b/src/Vortice.Win32/Graphics/Direct3D11/BlendDescription1.cs index 73e0fb7..6273585 100644 --- a/src/Vortice.Win32/Graphics/Direct3D11/BlendDescription1.cs +++ b/src/Vortice.Win32/Graphics/Direct3D11/BlendDescription1.cs @@ -25,7 +25,7 @@ public unsafe partial struct BlendDescription1 /// /// A built-in description with settings for blending with non-premultipled alpha, that is blending source and destination data using alpha while assuming the color data contains no alpha information. /// - public static readonly BlendDescription NonPremultiplied = new(Blend.SrcAlpha, Blend.InvSrcAlpha); + public static readonly BlendDescription1 NonPremultiplied = new(Blend.SrcAlpha, Blend.InvSrcAlpha); /// /// Initializes a new instance of the struct. @@ -54,11 +54,11 @@ public unsafe partial struct BlendDescription1 { RenderTarget[i].SrcBlend = sourceBlend; RenderTarget[i].DestBlend = destinationBlend; - RenderTarget[i].BlendOp = BlendOp.Add; + RenderTarget[i].BlendOp = BlendOperation.Add; RenderTarget[i].SrcBlendAlpha = srcBlendAlpha; RenderTarget[i].DestBlendAlpha = destBlendAlpha; - RenderTarget[i].BlendOpAlpha = BlendOp.Add; - RenderTarget[i].LogicOp = LogicOp.Noop; + RenderTarget[i].BlendOpAlpha = BlendOperation.Add; + RenderTarget[i].LogicOp = LogicOperation.Noop; RenderTarget[i].RenderTargetWriteMask = ColorWriteEnable.All; RenderTarget[i].BlendEnable = IsBlendEnabled(ref RenderTarget[i]); } @@ -66,10 +66,10 @@ public unsafe partial struct BlendDescription1 private static bool IsBlendEnabled(ref RenderTargetBlendDescription1 renderTarget) { - return renderTarget.BlendOp != BlendOp.Add + return renderTarget.BlendOp != BlendOperation.Add || renderTarget.SrcBlend != Blend.One || renderTarget.DestBlendAlpha != Blend.Zero - || renderTarget.BlendOp != BlendOp.Add + || renderTarget.BlendOp != BlendOperation.Add || renderTarget.SrcBlend != Blend.One || renderTarget.DestBlend != Blend.Zero; } diff --git a/src/Vortice.Win32/Graphics/Direct3D11/DepthStencilDescription.cs b/src/Vortice.Win32/Graphics/Direct3D11/DepthStencilDescription.cs index 5d4b8e5..163896d 100644 --- a/src/Vortice.Win32/Graphics/Direct3D11/DepthStencilDescription.cs +++ b/src/Vortice.Win32/Graphics/Direct3D11/DepthStencilDescription.cs @@ -25,12 +25,12 @@ public unsafe partial struct DepthStencilDescription /// /// A built-in description with settings for using a reverse depth stencil buffer. /// - public static readonly DepthStencilDescription DepthReverseZ = new(true, DepthWriteMask.All, ComparisonFunc.GreaterEqual); + public static readonly DepthStencilDescription DepthReverseZ = new(true, DepthWriteMask.All, ComparisonFunction.GreaterEqual); /// /// A built-in description with settings for enabling a read-only reverse depth stencil buffer. /// - public static readonly DepthStencilDescription DepthReadReverseZ = new(true, DepthWriteMask.Zero, ComparisonFunc.GreaterEqual); + public static readonly DepthStencilDescription DepthReadReverseZ = new(true, DepthWriteMask.Zero, ComparisonFunction.GreaterEqual); /// /// Initializes a new instance of the struct. @@ -38,7 +38,10 @@ public unsafe partial struct DepthStencilDescription /// Enable depth testing. /// Identify a portion of the depth-stencil buffer that can be modified by depth data. /// A function that compares depth data against existing depth data. - public DepthStencilDescription(bool depthEnable, DepthWriteMask depthWriteMask, ComparisonFunc depthFunc = ComparisonFunc.LessEqual) + public DepthStencilDescription( + bool depthEnable, + DepthWriteMask depthWriteMask, + ComparisonFunction depthFunc = ComparisonFunction.LessEqual) { DepthEnable = depthEnable; DepthWriteMask = depthWriteMask; @@ -46,8 +49,8 @@ public unsafe partial struct DepthStencilDescription StencilEnable = false; StencilReadMask = (byte)D3D11_DEFAULT_STENCIL_READ_MASK; StencilWriteMask = (byte)D3D11_DEFAULT_STENCIL_WRITE_MASK; - FrontFace = DepthStencilOpDescription.Default; - BackFace = DepthStencilOpDescription.Default; + FrontFace = DepthStencilOperationDescription.Default; + BackFace = DepthStencilOperationDescription.Default; } /// @@ -70,18 +73,18 @@ public unsafe partial struct DepthStencilDescription public DepthStencilDescription( bool depthEnable, bool depthWriteEnable, - ComparisonFunc depthFunc, + ComparisonFunction depthFunc, bool stencilEnable, byte stencilReadMask, byte stencilWriteMask, - StencilOp frontStencilFailOp, - StencilOp frontStencilDepthFailOp, - StencilOp frontStencilPassOp, - ComparisonFunc frontStencilFunc, - StencilOp backStencilFailOp, - StencilOp backStencilDepthFailOp, - StencilOp backStencilPassOp, - ComparisonFunc backStencilFunc) + StencilOperation frontStencilFailOp, + StencilOperation frontStencilDepthFailOp, + StencilOperation frontStencilPassOp, + ComparisonFunction frontStencilFunc, + StencilOperation backStencilFailOp, + StencilOperation backStencilDepthFailOp, + StencilOperation backStencilPassOp, + ComparisonFunction backStencilFunc) { DepthEnable = depthEnable; DepthWriteMask = depthWriteEnable ? DepthWriteMask.All : DepthWriteMask.Zero; diff --git a/src/Vortice.Win32/Graphics/Direct3D11/DepthStencilOpDescription.cs b/src/Vortice.Win32/Graphics/Direct3D11/DepthStencilOpDescription.cs deleted file mode 100644 index 3ebf254..0000000 --- a/src/Vortice.Win32/Graphics/Direct3D11/DepthStencilOpDescription.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright © Amer Koleci and Contributors. -// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. - -namespace Win32.Graphics.Direct3D11; - -public unsafe partial struct DepthStencilOpDescription -{ - /// - /// A built-in description with default values. - /// - public static readonly DepthStencilOpDescription Default = new(StencilOp.Keep, StencilOp.Keep, StencilOp.Keep, ComparisonFunc.Always); - - /// - /// Initializes a new instance of the struct. - /// - /// A value that identifies the stencil operation to perform when stencil testing fails. - /// A value that identifies the stencil operation to perform when stencil testing passes and depth testing fails. - /// A value that identifies the stencil operation to perform when stencil testing and depth testing both pass. - /// A value that identifies the function that compares stencil data against existing stencil data. - public DepthStencilOpDescription(StencilOp stencilFailOp, StencilOp stencilDepthFailOp, StencilOp stencilPassOp, ComparisonFunc stencilFunc) - { - StencilFailOp = stencilFailOp; - StencilDepthFailOp = stencilDepthFailOp; - StencilPassOp = stencilPassOp; - StencilFunc = stencilFunc; - } -} diff --git a/src/Vortice.Win32/Graphics/Direct3D11/DepthStencilOperationDescription.cs b/src/Vortice.Win32/Graphics/Direct3D11/DepthStencilOperationDescription.cs new file mode 100644 index 0000000..248deb7 --- /dev/null +++ b/src/Vortice.Win32/Graphics/Direct3D11/DepthStencilOperationDescription.cs @@ -0,0 +1,27 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +namespace Win32.Graphics.Direct3D11; + +public unsafe partial struct DepthStencilOperationDescription +{ + /// + /// A built-in description with default values. + /// + public static readonly DepthStencilOperationDescription Default = new(StencilOperation.Keep, StencilOperation.Keep, StencilOperation.Keep, ComparisonFunction.Always); + + /// + /// Initializes a new instance of the struct. + /// + /// A value that identifies the stencil operation to perform when stencil testing fails. + /// A value that identifies the stencil operation to perform when stencil testing passes and depth testing fails. + /// A value that identifies the stencil operation to perform when stencil testing and depth testing both pass. + /// A value that identifies the function that compares stencil data against existing stencil data. + public DepthStencilOperationDescription(StencilOperation stencilFailOp, StencilOperation stencilDepthFailOp, StencilOperation stencilPassOp, ComparisonFunction stencilFunc) + { + StencilFailOp = stencilFailOp; + StencilDepthFailOp = stencilDepthFailOp; + StencilPassOp = stencilPassOp; + StencilFunc = stencilFunc; + } +} diff --git a/src/Vortice.Win32/Graphics/Direct3D11/RenderTargetViewDescription.cs b/src/Vortice.Win32/Graphics/Direct3D11/RenderTargetViewDescription.cs index f989a34..9ee3ccb 100644 --- a/src/Vortice.Win32/Graphics/Direct3D11/RenderTargetViewDescription.cs +++ b/src/Vortice.Win32/Graphics/Direct3D11/RenderTargetViewDescription.cs @@ -1,7 +1,6 @@ // Copyright © Amer Koleci and Contributors. // Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. -using System.Xml.Serialization; using Win32.Graphics.Dxgi.Common; namespace Win32.Graphics.Direct3D11; diff --git a/src/Vortice.Win32/Graphics/Direct3D11/SamplerDescription.cs b/src/Vortice.Win32/Graphics/Direct3D11/SamplerDescription.cs index a82fd6e..8ebc307 100644 --- a/src/Vortice.Win32/Graphics/Direct3D11/SamplerDescription.cs +++ b/src/Vortice.Win32/Graphics/Direct3D11/SamplerDescription.cs @@ -1,9 +1,9 @@ // Copyright © Amer Koleci and Contributors. // Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. -using static Win32.Graphics.Direct3D11.Apis; +using static Win32.Graphics.Direct3D12.Apis; -namespace Win32.Graphics.Direct3D11; +namespace Win32.Graphics.Direct3D12; public unsafe partial struct SamplerDescription { @@ -13,8 +13,8 @@ public unsafe partial struct SamplerDescription public static readonly SamplerDescription LinearWrap = new(Filter.MinMagMipLinear, TextureAddressMode.Wrap); public static readonly SamplerDescription LinearClamp = new(Filter.MinMagMipLinear, TextureAddressMode.Clamp); - public static readonly SamplerDescription AnisotropicWrap = new(Filter.Anisotropic, TextureAddressMode.Wrap, 0.0f, D3D11_MAX_MAXANISOTROPY); - public static readonly SamplerDescription AnisotropicClamp = new(Filter.Anisotropic, TextureAddressMode.Clamp, 0.0f, D3D11_MAX_MAXANISOTROPY); + public static readonly SamplerDescription AnisotropicWrap = new(Filter.Anisotropic, TextureAddressMode.Wrap, 0.0f, D3D12_MAX_MAXANISOTROPY); + public static readonly SamplerDescription AnisotropicClamp = new(Filter.Anisotropic, TextureAddressMode.Clamp, 0.0f, D3D12_MAX_MAXANISOTROPY); /// /// Initializes a new instance of the struct. @@ -36,7 +36,7 @@ public unsafe partial struct SamplerDescription TextureAddressMode addressW, float mipLODBias, uint maxAnisotropy, - ComparisonFunc comparisonFunction, + ComparisonFunction comparisonFunction, Color4 borderColor, float minLOD, float maxLOD) @@ -75,7 +75,7 @@ public unsafe partial struct SamplerDescription TextureAddressMode addressW, float mipLODBias = 0.0f, uint maxAnisotropy = 1, - ComparisonFunc comparisonFunction = ComparisonFunc.Never, + ComparisonFunction comparisonFunction = ComparisonFunction.Never, float minLOD = float.MinValue, float maxLOD = float.MaxValue) { @@ -109,7 +109,7 @@ public unsafe partial struct SamplerDescription TextureAddressMode address, float mipLODBias = 0.0f, uint maxAnisotropy = 1, - ComparisonFunc comparisonFunction = ComparisonFunc.Never, + ComparisonFunction comparisonFunction = ComparisonFunction.Never, float minLOD = float.MinValue, float maxLOD = float.MaxValue) { diff --git a/src/Vortice.Win32/Graphics/Direct3D11/ShaderResourceViewDescription.cs b/src/Vortice.Win32/Graphics/Direct3D11/ShaderResourceViewDescription.cs index d6038e5..b2210a1 100644 --- a/src/Vortice.Win32/Graphics/Direct3D11/ShaderResourceViewDescription.cs +++ b/src/Vortice.Win32/Graphics/Direct3D11/ShaderResourceViewDescription.cs @@ -1,7 +1,6 @@ // Copyright © Amer Koleci and Contributors. // Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. -using System.Xml.Serialization; using Win32.Graphics.Direct3D; using Win32.Graphics.Dxgi.Common; diff --git a/src/Vortice.Win32/Graphics/Direct3D11/UnorderedAccessViewDescription.cs b/src/Vortice.Win32/Graphics/Direct3D11/UnorderedAccessViewDescription.cs index 56e4f18..83b2fcf 100644 --- a/src/Vortice.Win32/Graphics/Direct3D11/UnorderedAccessViewDescription.cs +++ b/src/Vortice.Win32/Graphics/Direct3D11/UnorderedAccessViewDescription.cs @@ -1,7 +1,6 @@ // Copyright © Amer Koleci and Contributors. // Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. -using System.Xml.Serialization; using Win32.Graphics.Dxgi.Common; namespace Win32.Graphics.Direct3D11; diff --git a/src/Vortice.Win32/Graphics/Direct3D12/Apis.cs b/src/Vortice.Win32/Graphics/Direct3D12/Apis.cs index 0194c1c..c1f18ed 100644 --- a/src/Vortice.Win32/Graphics/Direct3D12/Apis.cs +++ b/src/Vortice.Win32/Graphics/Direct3D12/Apis.cs @@ -5,6 +5,7 @@ // Copyright © Amer Koleci and Contributors. // Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. +using Win32.Graphics.Direct3D; using Win32.Graphics.Dxgi.Common; using static Win32.Apis; @@ -381,4 +382,133 @@ public static unsafe partial class Apis return UpdateSubresources(pCmdList, pDestinationResource, pIntermediate, FirstSubresource, NumSubresources, RequiredSize, Layouts, NumRows, RowSizesInBytes, pResourceData, pSrcData); } + + public static ID3D12CommandList** CommandListCast([NativeTypeName("ID3D12GraphicsCommandList * const *")] ID3D12GraphicsCommandList** pp) + { + return (ID3D12CommandList**)pp; + } + + public static HResult D3D12SerializeVersionedRootSignature( + VersionedRootSignatureDescription* pRootSignatureDesc, + RootSignatureVersion MaxVersion, + ID3DBlob** ppBlob, + ID3DBlob** ppErrorBlob) + { + if (ppErrorBlob != null) + { + *ppErrorBlob = null; + } + + switch (MaxVersion) + { + case RootSignatureVersion.V1_0: + switch (pRootSignatureDesc->Version) + { + case RootSignatureVersion.V1_0: + return D3D12SerializeRootSignature(&pRootSignatureDesc->Anonymous.Desc_1_0, RootSignatureVersion.V1_0, ppBlob, ppErrorBlob); + + case RootSignatureVersion.V1_1: + { + HResult hr = HResult.Ok; + ref readonly RootSignatureDescription1 desc_1_1 = ref pRootSignatureDesc->Anonymous.Desc_1_1; + + nuint ParametersSize = (uint)sizeof(RootParameter) * desc_1_1.NumParameters; + void* pParameters = ((ulong)ParametersSize > 0) ? HeapAlloc(GetProcessHeap(), 0, ParametersSize) : null; + + if ((ulong)ParametersSize > 0 && pParameters == null) + { + hr = HResult.OutOfMemory; + } + + var pParameters_1_0 = (RootParameter*)pParameters; + + if (hr.Success) + { + for (uint n = 0; n < desc_1_1.NumParameters; n++) + { + Debug.Assert((long)ParametersSize == (sizeof(RootParameter) * desc_1_1.NumParameters)); + + pParameters_1_0[n].ParameterType = desc_1_1.pParameters[n].ParameterType; + pParameters_1_0[n].ShaderVisibility = desc_1_1.pParameters[n].ShaderVisibility; + + switch (desc_1_1.pParameters[n].ParameterType) + { + case RootParameterType.T32BitConstants: + pParameters_1_0[n].Anonymous.Constants.Num32BitValues = desc_1_1.pParameters[n].Anonymous.Constants.Num32BitValues; + pParameters_1_0[n].Anonymous.Constants.RegisterSpace = desc_1_1.pParameters[n].Anonymous.Constants.RegisterSpace; + pParameters_1_0[n].Anonymous.Constants.ShaderRegister = desc_1_1.pParameters[n].Anonymous.Constants.ShaderRegister; + break; + + case RootParameterType.Cbv: + case RootParameterType.Srv: + case RootParameterType.Uav: + pParameters_1_0[n].Anonymous.Descriptor.RegisterSpace = desc_1_1.pParameters[n].Anonymous.Descriptor.RegisterSpace; + pParameters_1_0[n].Anonymous.Descriptor.ShaderRegister = desc_1_1.pParameters[n].Anonymous.Descriptor.ShaderRegister; + break; + + case RootParameterType.DescriptorTable: + ref readonly RootDescriptorTable1 table_1_1 = ref desc_1_1.pParameters[n].Anonymous.DescriptorTable; + + nuint DescriptorRangesSize = (uint)sizeof(DescriptorRange) * table_1_1.NumDescriptorRanges; + void* pDescriptorRanges = ((ulong)DescriptorRangesSize > 0 && hr.Success) ? HeapAlloc(GetProcessHeap(), 0, DescriptorRangesSize) : null; + + if ((ulong)DescriptorRangesSize > 0 && pDescriptorRanges == null) + { + hr = HResult.OutOfMemory; + } + + var pDescriptorRanges_1_0 = (DescriptorRange*)pDescriptorRanges; + + if (hr.Success) + { + for (uint x = 0; x < table_1_1.NumDescriptorRanges; x++) + { + Debug.Assert((long)DescriptorRangesSize == (sizeof(DescriptorRange) * table_1_1.NumDescriptorRanges)); + + pDescriptorRanges_1_0[x].BaseShaderRegister = table_1_1.pDescriptorRanges[x].BaseShaderRegister; + pDescriptorRanges_1_0[x].NumDescriptors = table_1_1.pDescriptorRanges[x].NumDescriptors; + pDescriptorRanges_1_0[x].OffsetInDescriptorsFromTableStart = table_1_1.pDescriptorRanges[x].OffsetInDescriptorsFromTableStart; + pDescriptorRanges_1_0[x].RangeType = table_1_1.pDescriptorRanges[x].RangeType; + pDescriptorRanges_1_0[x].RegisterSpace = table_1_1.pDescriptorRanges[x].RegisterSpace; + } + } + + ref RootDescriptorTable table_1_0 = ref pParameters_1_0[n].Anonymous.DescriptorTable; + table_1_0.NumDescriptorRanges = table_1_1.NumDescriptorRanges; + table_1_0.pDescriptorRanges = pDescriptorRanges_1_0; + break; + } + } + } + + if (hr.Success) + { + RootSignatureDescription desc_1_0 = new RootSignatureDescription(desc_1_1.NumParameters, pParameters_1_0, desc_1_1.NumStaticSamplers, desc_1_1.pStaticSamplers, desc_1_1.Flags); + hr = D3D12SerializeRootSignature(&desc_1_0, RootSignatureVersion.V1_0 , ppBlob, ppErrorBlob); + } + + if (pParameters != null) + { + for (uint n = 0; n < desc_1_1.NumParameters; n++) + { + if (desc_1_1.pParameters[n].ParameterType == RootParameterType.DescriptorTable) + { + _ = HeapFree(GetProcessHeap(), 0, (void*)pParameters_1_0[n].Anonymous.DescriptorTable.pDescriptorRanges); + } + } + + _ = HeapFree(GetProcessHeap(), 0, pParameters); + } + + return hr; + } + } + break; + + case RootSignatureVersion.V1_1: + return D3D12SerializeVersionedRootSignature(pRootSignatureDesc, ppBlob, ppErrorBlob); + } + + return HResult.InvalidArg; + } } diff --git a/src/Vortice.Win32/Graphics/Direct3D12/BlendDescription.cs b/src/Vortice.Win32/Graphics/Direct3D12/BlendDescription.cs new file mode 100644 index 0000000..c240557 --- /dev/null +++ b/src/Vortice.Win32/Graphics/Direct3D12/BlendDescription.cs @@ -0,0 +1,54 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +using static Win32.Graphics.Direct3D12.Apis; + +namespace Win32.Graphics.Direct3D12; + +public unsafe partial struct BlendDescription +{ + /// + /// A built-in description with settings for opaque blend, that is overwriting the source with the destination data. + /// + public static readonly BlendDescription Opaque = new(Blend.One, Blend.Zero); + + /// + /// A built-in description with settings for alpha blend, that is blending the source and destination data using alpha. + /// + public static readonly BlendDescription AlphaBlend = new(Blend.One, Blend.InvSrcAlpha); + + /// + /// A built-in description with settings for additive blend, that is adding the destination data to the source data without using alpha. + /// + public static readonly BlendDescription Additive = new(Blend.SrcAlpha, Blend.One); + + /// + /// A built-in description with settings for blending with non-premultipled alpha, that is blending source and destination data using alpha while assuming the color data contains no alpha information. + /// + public static readonly BlendDescription NonPremultiplied = new(Blend.SrcAlpha, Blend.InvSrcAlpha); + + /// + /// Initializes a new instance of the struct. + /// + /// The source blend. + /// The destination blend. + public BlendDescription(Blend srcBlend, Blend destBlend) + : this() + { + AlphaToCoverageEnable = false; + IndependentBlendEnable = false; + + for (int i = 0; i < D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT; i++) + { + RenderTarget[i].BlendEnable = srcBlend != Blend.One || destBlend != Blend.Zero; + RenderTarget[i].LogicOp = LogicOperation.Noop; + RenderTarget[i].SrcBlend = srcBlend; + RenderTarget[i].DestBlend = destBlend; + RenderTarget[i].BlendOp = BlendOperation.Add; + RenderTarget[i].SrcBlendAlpha = srcBlend; + RenderTarget[i].DestBlendAlpha = destBlend; + RenderTarget[i].BlendOpAlpha = BlendOperation.Add; + RenderTarget[i].RenderTargetWriteMask = ColorWriteEnable.All; + } + } +} diff --git a/src/Vortice.Win32/Graphics/Direct3D12/CpuDescriptorHandle.cs b/src/Vortice.Win32/Graphics/Direct3D12/CpuDescriptorHandle.cs new file mode 100644 index 0000000..0895a5f --- /dev/null +++ b/src/Vortice.Win32/Graphics/Direct3D12/CpuDescriptorHandle.cs @@ -0,0 +1,63 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +namespace Win32.Graphics.Direct3D12; + +public unsafe partial struct CpuDescriptorHandle : IEquatable +{ + public static CpuDescriptorHandle Default => default; + + public CpuDescriptorHandle(in CpuDescriptorHandle other, int offsetScaledByIncrementSize) + { + InitOffsetted(out this, other, offsetScaledByIncrementSize); + } + + public CpuDescriptorHandle(in CpuDescriptorHandle other, int offsetInDescriptors, uint descriptorIncrementSize) + { + InitOffsetted(out this, other, offsetInDescriptors, descriptorIncrementSize); + } + + public CpuDescriptorHandle Offset(int offsetInDescriptors, uint descriptorIncrementSize) + { + ptr = unchecked((nuint)((long)ptr + ((long)offsetInDescriptors * (long)descriptorIncrementSize))); + return this; + } + + public CpuDescriptorHandle Offset(int offsetScaledByIncrementSize) + { + ptr = unchecked((nuint)((long)ptr + (long)offsetScaledByIncrementSize)); + return this; + } + + public static bool operator ==(in CpuDescriptorHandle left, in CpuDescriptorHandle right) + => (left.ptr == right.ptr); + + public static bool operator !=(in CpuDescriptorHandle left, in CpuDescriptorHandle right) + => (left.ptr != right.ptr); + + public void InitOffsetted(in CpuDescriptorHandle @base, int offsetScaledByIncrementSize) + { + InitOffsetted(out this, @base, offsetScaledByIncrementSize); + } + + public void InitOffsetted(in CpuDescriptorHandle @base, int offsetInDescriptors, uint descriptorIncrementSize) + { + InitOffsetted(out this, @base, offsetInDescriptors, descriptorIncrementSize); + } + + public static void InitOffsetted(out CpuDescriptorHandle handle, in CpuDescriptorHandle @base, int offsetScaledByIncrementSize) + { + handle.ptr = (nuint)((long)@base.ptr + (long)offsetScaledByIncrementSize); + } + + public static void InitOffsetted(out CpuDescriptorHandle handle, in CpuDescriptorHandle @base, int offsetInDescriptors, uint descriptorIncrementSize) + { + handle.ptr = (nuint)((long)@base.ptr + ((long)offsetInDescriptors * (long)descriptorIncrementSize)); + } + + public override bool Equals(object? obj) => (obj is CpuDescriptorHandle other) && Equals(other); + + public bool Equals(CpuDescriptorHandle other) => this == other; + + public override int GetHashCode() => ptr.GetHashCode(); +} diff --git a/src/Vortice.Win32/Graphics/Direct3D12/DepthStencilDescription.cs b/src/Vortice.Win32/Graphics/Direct3D12/DepthStencilDescription.cs new file mode 100644 index 0000000..e8af6b2 --- /dev/null +++ b/src/Vortice.Win32/Graphics/Direct3D12/DepthStencilDescription.cs @@ -0,0 +1,63 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +using static Win32.Graphics.Direct3D12.Apis; + +namespace Win32.Graphics.Direct3D12; + +public unsafe partial struct DepthStencilDescription +{ + /// + /// A built-in description with settings for not using a depth stencil buffer. + /// + public static readonly DepthStencilDescription None = new(false, false, ComparisonFunction.LessEqual); + + /// + /// A built-in description with default settings for using a depth stencil buffer. + /// + public static readonly DepthStencilDescription Default = new(true, true, ComparisonFunction.LessEqual); + + /// + /// A built-in description with settings for enabling a read-only depth stencil buffer. + /// + public static readonly DepthStencilDescription Read = new(true, false, ComparisonFunction.LessEqual); + + /// + /// A built-in description with default settings for using a reverse depth stencil buffer. + /// + public static readonly DepthStencilDescription ReverseZ = new(true, true, ComparisonFunction.GreaterEqual); + + /// + /// A built-in description with default settings for using a reverse read-only depth stencil buffer. + /// + public static readonly DepthStencilDescription ReadReverseZ = new(true, false, ComparisonFunction.GreaterEqual); + + /// + /// Initializes a new instance of the struct. + /// + public DepthStencilDescription( + bool depthEnable, + bool depthWriteEnable, + ComparisonFunction depthFunc, + bool stencilEnable = false, + byte stencilReadMask = (byte)D3D12_DEFAULT_STENCIL_READ_MASK, + byte stencilWriteMask = (byte)D3D12_DEFAULT_STENCIL_WRITE_MASK, + StencilOperation frontStencilFailOp = StencilOperation.Keep, + StencilOperation frontStencilDepthFailOp = StencilOperation.Keep, + StencilOperation frontStencilPassOp = StencilOperation.Keep, + ComparisonFunction frontStencilFunc = ComparisonFunction.Always, + StencilOperation backStencilFailOp = StencilOperation.Keep, + StencilOperation backStencilDepthFailOp = StencilOperation.Keep, + StencilOperation backStencilPassOp = StencilOperation.Keep, + ComparisonFunction backStencilFunc = ComparisonFunction.Always) + { + DepthEnable = depthEnable; + DepthWriteMask = depthWriteEnable ? DepthWriteMask.All : DepthWriteMask.Zero; + DepthFunc = depthFunc; + StencilEnable = stencilEnable; + StencilReadMask = stencilReadMask; + StencilWriteMask = stencilWriteMask; + FrontFace = new(frontStencilFailOp, frontStencilDepthFailOp, frontStencilPassOp, frontStencilFunc); + BackFace = new(backStencilFailOp, backStencilDepthFailOp, backStencilPassOp, backStencilFunc); + } +} diff --git a/src/Vortice.Win32/Graphics/Direct3D12/DepthStencilDescription1.cs b/src/Vortice.Win32/Graphics/Direct3D12/DepthStencilDescription1.cs new file mode 100644 index 0000000..682411a --- /dev/null +++ b/src/Vortice.Win32/Graphics/Direct3D12/DepthStencilDescription1.cs @@ -0,0 +1,65 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +using static Win32.Graphics.Direct3D12.Apis; + +namespace Win32.Graphics.Direct3D12; + +public unsafe partial struct DepthStencilDescription1 +{ + /// + /// A built-in description with settings for not using a depth stencil buffer. + /// + public static readonly DepthStencilDescription1 None = new(false, false, ComparisonFunction.LessEqual); + + /// + /// A built-in description with default settings for using a depth stencil buffer. + /// + public static readonly DepthStencilDescription1 Default = new(true, true, ComparisonFunction.LessEqual); + + /// + /// A built-in description with settings for enabling a read-only depth stencil buffer. + /// + public static readonly DepthStencilDescription1 Read = new(true, false, ComparisonFunction.LessEqual); + + /// + /// A built-in description with default settings for using a reverse depth stencil buffer. + /// + public static readonly DepthStencilDescription1 ReverseZ = new(true, true, ComparisonFunction.GreaterEqual); + + /// + /// A built-in description with default settings for using a reverse read-only depth stencil buffer. + /// + public static readonly DepthStencilDescription1 ReadReverseZ = new(true, false, ComparisonFunction.GreaterEqual); + + /// + /// Initializes a new instance of the struct. + /// + public DepthStencilDescription1( + bool depthEnable, + bool depthWriteEnable, + ComparisonFunction depthFunc, + bool stencilEnable = false, + byte stencilReadMask = (byte)D3D12_DEFAULT_STENCIL_READ_MASK, + byte stencilWriteMask = (byte)D3D12_DEFAULT_STENCIL_WRITE_MASK, + StencilOperation frontStencilFailOp = StencilOperation.Keep, + StencilOperation frontStencilDepthFailOp = StencilOperation.Keep, + StencilOperation frontStencilPassOp = StencilOperation.Keep, + ComparisonFunction frontStencilFunc = ComparisonFunction.Always, + StencilOperation backStencilFailOp = StencilOperation.Keep, + StencilOperation backStencilDepthFailOp = StencilOperation.Keep, + StencilOperation backStencilPassOp = StencilOperation.Keep, + ComparisonFunction backStencilFunc = ComparisonFunction.Always, + bool depthBoundsTestEnable = false) + { + DepthEnable = depthEnable; + DepthWriteMask = depthWriteEnable ? DepthWriteMask.All : DepthWriteMask.Zero; + DepthFunc = depthFunc; + StencilEnable = stencilEnable; + StencilReadMask = stencilReadMask; + StencilWriteMask = stencilWriteMask; + FrontFace = new(frontStencilFailOp, frontStencilDepthFailOp, frontStencilPassOp, frontStencilFunc); + BackFace = new(backStencilFailOp, backStencilDepthFailOp, backStencilPassOp, backStencilFunc); + DepthBoundsTestEnable = depthBoundsTestEnable; + } +} diff --git a/src/Vortice.Win32/Graphics/Direct3D12/DepthStencilOperationDescription.cs b/src/Vortice.Win32/Graphics/Direct3D12/DepthStencilOperationDescription.cs new file mode 100644 index 0000000..4b08390 --- /dev/null +++ b/src/Vortice.Win32/Graphics/Direct3D12/DepthStencilOperationDescription.cs @@ -0,0 +1,27 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +namespace Win32.Graphics.Direct3D12; + +public unsafe partial struct DepthStencilOperationDescription +{ + /// + /// A built-in description with default values. + /// + public static readonly DepthStencilOperationDescription Default = new(StencilOperation.Keep, StencilOperation.Keep, StencilOperation.Keep, ComparisonFunction.Always); + + /// + /// Initializes a new instance of the struct. + /// + /// A value that identifies the stencil operation to perform when stencil testing fails. + /// A value that identifies the stencil operation to perform when stencil testing passes and depth testing fails. + /// A value that identifies the stencil operation to perform when stencil testing and depth testing both pass. + /// A value that identifies the function that compares stencil data against existing stencil data. + public DepthStencilOperationDescription(StencilOperation stencilFailOp, StencilOperation stencilDepthFailOp, StencilOperation stencilPassOp, ComparisonFunction stencilFunc) + { + StencilFailOp = stencilFailOp; + StencilDepthFailOp = stencilDepthFailOp; + StencilPassOp = stencilPassOp; + StencilFunc = stencilFunc; + } +} diff --git a/src/Vortice.Win32/Graphics/Direct3D12/DepthStencilViewDescription.cs b/src/Vortice.Win32/Graphics/Direct3D12/DepthStencilViewDescription.cs new file mode 100644 index 0000000..7a448ed --- /dev/null +++ b/src/Vortice.Win32/Graphics/Direct3D12/DepthStencilViewDescription.cs @@ -0,0 +1,148 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +using Win32.Graphics.Dxgi.Common; + +namespace Win32.Graphics.Direct3D12; + +public unsafe partial struct DepthStencilViewDescription +{ + /// + /// Initializes a new instance of the struct. + /// + /// The + /// The to use or . + /// The index of the mipmap level to use mip slice. or first element for . + /// The index of the first texture to use in an array of textures or NumElements for , FirstWSlice for . + /// Number of textures in the array or WSize for . + /// + public DepthStencilViewDescription( + DsvDimension viewDimension, + Format format = Format.Unknown, + uint mipSlice = 0, + uint firstArraySlice = 0, + uint arraySize = unchecked((uint)-1), + DsvFlags flags = DsvFlags.None) + { + Format = format; + ViewDimension = viewDimension; + Anonymous = default; + Flags = flags; + + switch (viewDimension) + { + case DsvDimension.Texture1D: + Texture1D.MipSlice = mipSlice; + break; + case DsvDimension.Texture1DArray: + Texture1DArray.MipSlice = mipSlice; + Texture1DArray.FirstArraySlice = firstArraySlice; + Texture1DArray.ArraySize = arraySize; + break; + case DsvDimension.Texture2D: + Texture2D.MipSlice = mipSlice; + break; + case DsvDimension.Texture2DArray: + Texture2DArray.MipSlice = mipSlice; + Texture2DArray.FirstArraySlice = firstArraySlice; + Texture2DArray.ArraySize = arraySize; + break; + case DsvDimension.Texture2DMs: + break; + case DsvDimension.Texture2DMsArray: + Texture2DMSArray.FirstArraySlice = firstArraySlice; + Texture2DMSArray.ArraySize = arraySize; + break; + default: + break; + } + } + + /// + /// Initializes a new instance of the struct. + /// + public DepthStencilViewDescription( + ID3D12Resource* texture, + DsvDimension viewDimension = DsvDimension.Unknown, + Format format = Format.Unknown, + uint mipSlice = 0, + uint firstArraySlice = 0, + uint arraySize = unchecked((uint)-1), + DsvFlags flags = DsvFlags.None) + { + ViewDimension = viewDimension; + if (viewDimension == DsvDimension.Unknown || + format == Format.Unknown || + arraySize == unchecked((uint)-1)) + { + ResourceDescription resourceDesc = texture->GetDesc(); + + if (viewDimension == DsvDimension.Unknown) + { + switch (resourceDesc.Dimension) + { + case ResourceDimension.Texture1D: + viewDimension = resourceDesc.DepthOrArraySize > 1 ? DsvDimension.Texture1DArray : DsvDimension.Texture1D; + break; + case ResourceDimension.Texture2D: + if (resourceDesc.SampleDesc.Count > 1) + { + viewDimension = resourceDesc.DepthOrArraySize > 1 ? DsvDimension.Texture2DMsArray : DsvDimension.Texture2DMs; + } + else + { + viewDimension = resourceDesc.DepthOrArraySize > 1 ? DsvDimension.Texture2DArray : DsvDimension.Texture2D; + } + break; + } + } + + if (format == Format.Unknown) + { + format = resourceDesc.Format; + } + + bool isArray = + viewDimension == DsvDimension.Texture2DArray || + viewDimension == DsvDimension.Texture2DMsArray; + + if (arraySize == unchecked((uint)-1) && + isArray) + { + arraySize = resourceDesc.ArraySize - firstArraySlice; + } + } + + Format = format; + Flags = flags; + Anonymous = default; + + switch (viewDimension) + { + case DsvDimension.Texture1D: + Anonymous.Texture1D.MipSlice = mipSlice; + break; + case DsvDimension.Texture1DArray: + Anonymous.Texture1DArray.MipSlice = mipSlice; + Anonymous.Texture1DArray.FirstArraySlice = firstArraySlice; + Anonymous.Texture1DArray.ArraySize = arraySize; + break; + case DsvDimension.Texture2D: + Anonymous.Texture2D.MipSlice = mipSlice; + break; + case DsvDimension.Texture2DArray: + Anonymous.Texture2DArray.MipSlice = mipSlice; + Anonymous.Texture2DArray.FirstArraySlice = firstArraySlice; + Anonymous.Texture2DArray.ArraySize = arraySize; + break; + case DsvDimension.Texture2DMs: + break; + case DsvDimension.Texture2DMsArray: + Anonymous.Texture2DMSArray.FirstArraySlice = firstArraySlice; + Anonymous.Texture2DMSArray.ArraySize = arraySize; + break; + default: + break; + } + } +} diff --git a/src/Vortice.Win32/Graphics/Direct3D12/GpuDescriptorHandle.cs b/src/Vortice.Win32/Graphics/Direct3D12/GpuDescriptorHandle.cs new file mode 100644 index 0000000..a7e0410 --- /dev/null +++ b/src/Vortice.Win32/Graphics/Direct3D12/GpuDescriptorHandle.cs @@ -0,0 +1,64 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +namespace Win32.Graphics.Direct3D12; + +public unsafe partial struct GpuDescriptorHandle : IEquatable +{ + public static GpuDescriptorHandle Default => default; + + public GpuDescriptorHandle(in GpuDescriptorHandle other, int offsetScaledByIncrementSize) + { + InitOffsetted(out this, other, offsetScaledByIncrementSize); + } + + public GpuDescriptorHandle(in GpuDescriptorHandle other, int offsetInDescriptors, uint descriptorIncrementSize) + { + InitOffsetted(out this, other, offsetInDescriptors, descriptorIncrementSize); + } + + public GpuDescriptorHandle Offset(int offsetInDescriptors, uint descriptorIncrementSize) + { + ptr = (ulong)((long)ptr + ((long)offsetInDescriptors * (long)descriptorIncrementSize)); + return this; + } + + public GpuDescriptorHandle Offset(int offsetScaledByIncrementSize) + { + ptr = (ulong)((long)ptr + (long)offsetScaledByIncrementSize); + return this; + } + + + public static bool operator ==(in GpuDescriptorHandle left, in GpuDescriptorHandle right) + => (left.ptr == right.ptr); + + public static bool operator !=(in GpuDescriptorHandle left, in GpuDescriptorHandle right) + => (left.ptr != right.ptr); + + public void InitOffsetted(in GpuDescriptorHandle @base, int offsetScaledByIncrementSize) + { + InitOffsetted(out this, @base, offsetScaledByIncrementSize); + } + + public void InitOffsetted(in GpuDescriptorHandle @base, int offsetInDescriptors, uint descriptorIncrementSize) + { + InitOffsetted(out this, @base, offsetInDescriptors, descriptorIncrementSize); + } + + public static void InitOffsetted(out GpuDescriptorHandle handle, in GpuDescriptorHandle @base, int offsetScaledByIncrementSize) + { + handle.ptr = (ulong)((long)@base.ptr + (long)offsetScaledByIncrementSize); + } + + public static void InitOffsetted(out GpuDescriptorHandle handle, in GpuDescriptorHandle @base, int offsetInDescriptors, uint descriptorIncrementSize) + { + handle.ptr = (ulong)((long)@base.ptr + ((long)offsetInDescriptors * (long)descriptorIncrementSize)); + } + + public override bool Equals(object? obj) => (obj is GpuDescriptorHandle other) && Equals(other); + + public bool Equals(GpuDescriptorHandle other) => this == other; + + public override int GetHashCode() => ptr.GetHashCode(); +} diff --git a/src/Vortice.Win32/Graphics/Direct3D12/HeapDescription.cs b/src/Vortice.Win32/Graphics/Direct3D12/HeapDescription.cs new file mode 100644 index 0000000..3cf62b9 --- /dev/null +++ b/src/Vortice.Win32/Graphics/Direct3D12/HeapDescription.cs @@ -0,0 +1,91 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +namespace Win32.Graphics.Direct3D12; + +public unsafe partial struct HeapDescription : IEquatable +{ + public HeapDescription(ulong size, + HeapProperties properties, + ulong alignment = 0, + HeapFlags flags = HeapFlags.None) + { + SizeInBytes = size; + Properties = properties; + Alignment = alignment; + Flags = flags; + } + + public HeapDescription(ulong size, + HeapType type, + ulong alignment = 0, + HeapFlags flags = HeapFlags.None) + { + SizeInBytes = size; + Properties = new HeapProperties(type); + Alignment = alignment; + Flags = flags; + } + + public HeapDescription(ulong size, + CpuPageProperty cpuPageProperty, + MemoryPool memoryPoolPreference, + ulong alignment = 0, + HeapFlags flags = HeapFlags.None) + { + SizeInBytes = size; + Properties = new HeapProperties(cpuPageProperty, memoryPoolPreference); + Alignment = alignment; + Flags = flags; + } + + public HeapDescription(in ResourceAllocationInfo resourceAllocInfo, + HeapProperties properties, + HeapFlags flags = HeapFlags.None) + { + SizeInBytes = resourceAllocInfo.SizeInBytes; + Properties = properties; + Alignment = resourceAllocInfo.Alignment; + Flags = flags; + } + + public HeapDescription(in ResourceAllocationInfo resourceAllocInfo, + HeapType type, + HeapFlags flags = HeapFlags.None) + { + SizeInBytes = resourceAllocInfo.SizeInBytes; + Properties = new HeapProperties(type); + Alignment = resourceAllocInfo.Alignment; + Flags = flags; + } + + public HeapDescription(in ResourceAllocationInfo resAllocInfo, + CpuPageProperty cpuPageProperty, + MemoryPool memoryPoolPreference, + HeapFlags flags = HeapFlags.None) + { + SizeInBytes = resAllocInfo.SizeInBytes; + Properties = new HeapProperties(cpuPageProperty, memoryPoolPreference); + Alignment = resAllocInfo.Alignment; + Flags = flags; + } + + public bool IsCPUAccessible => Properties.IsCPUAccessible; + + public static bool operator ==(in HeapDescription left, in HeapDescription right) + { + return (left.SizeInBytes == right.SizeInBytes) + && (left.Properties == right.Properties) + && (left.Alignment == right.Alignment) + && (left.Flags == right.Flags); + } + + public static bool operator !=(in HeapDescription left, in HeapDescription right) + => !(left == right); + + public override bool Equals(object? obj) => (obj is HeapDescription other) && Equals(other); + + public bool Equals(HeapDescription other) => this == other; + + public override int GetHashCode() => HashCode.Combine(SizeInBytes, Properties, Alignment, Flags); +} diff --git a/src/Vortice.Win32/Graphics/Direct3D12/HeapProperties.cs b/src/Vortice.Win32/Graphics/Direct3D12/HeapProperties.cs new file mode 100644 index 0000000..aeeecfb --- /dev/null +++ b/src/Vortice.Win32/Graphics/Direct3D12/HeapProperties.cs @@ -0,0 +1,56 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +namespace Win32.Graphics.Direct3D12; + +public partial struct HeapProperties : IEquatable +{ + public HeapProperties(CpuPageProperty cpuPageProperty, + MemoryPool memoryPoolPreference, + uint creationNodeMask = 1, + uint nodeMask = 1) + { + Type = HeapType.Custom; + CPUPageProperty = cpuPageProperty; + MemoryPoolPreference = memoryPoolPreference; + CreationNodeMask = creationNodeMask; + VisibleNodeMask = nodeMask; + } + + public HeapProperties(HeapType type, uint creationNodeMask = 1, uint nodeMask = 1) + { + Type = type; + CPUPageProperty = CpuPageProperty.Unknown; + MemoryPoolPreference = MemoryPool.Unknown; + CreationNodeMask = creationNodeMask; + VisibleNodeMask = nodeMask; + } + + public bool IsCPUAccessible + { + get + { + return (Type == HeapType.Upload) + || (Type == HeapType.Readback) + || ((Type == HeapType.Custom) && ((CPUPageProperty == CpuPageProperty.WriteCombine) || (CPUPageProperty == CpuPageProperty.WriteBack))); + } + } + + public static bool operator ==(in HeapProperties left, in HeapProperties right) + { + return (left.Type == right.Type) + && (left.CPUPageProperty == right.CPUPageProperty) + && (left.MemoryPoolPreference == right.MemoryPoolPreference) + && (left.CreationNodeMask == right.CreationNodeMask) + && (left.VisibleNodeMask == right.VisibleNodeMask); + } + + public static bool operator !=(in HeapProperties left, in HeapProperties right) + => !(left == right); + + public override bool Equals(object? obj) => (obj is HeapProperties other) && Equals(other); + + public bool Equals(HeapProperties other) => this == other; + + public override int GetHashCode() => HashCode.Combine(Type, CPUPageProperty, MemoryPoolPreference, CreationNodeMask, VisibleNodeMask); +} diff --git a/src/Vortice.Win32/Graphics/Direct3D12/IndexBufferView.cs b/src/Vortice.Win32/Graphics/Direct3D12/IndexBufferView.cs new file mode 100644 index 0000000..b844fbd --- /dev/null +++ b/src/Vortice.Win32/Graphics/Direct3D12/IndexBufferView.cs @@ -0,0 +1,33 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +using Win32.Graphics.Dxgi.Common; + +namespace Win32.Graphics.Direct3D12; + +public unsafe partial struct IndexBufferView +{ + /// + /// Initializes a new instance of the struct. + /// + /// Specifies a gpu virtual address that identifies the address of the buffer. + /// Specifies the size in bytes of the index buffer. + /// Specifies the for the index-buffer format. + public IndexBufferView(ulong bufferLocation, uint sizeInBytes, Format format) + { + BufferLocation = bufferLocation; + SizeInBytes = sizeInBytes; + Format = format; + } + + /// + /// Initializes a new instance of the struct. + /// + /// Specifies a gpu virtual address that identifies the address of the buffer. + /// Specifies the size in bytes of the index buffer. + /// Specifies if index buffer is 32 bit or 16 bit sized. + public IndexBufferView(ulong bufferLocation, uint sizeInBytes, bool is32Bit = false) + : this(bufferLocation, sizeInBytes, is32Bit ? Format.R32Uint : Format.R16Uint) + { + } +} diff --git a/src/Vortice.Win32/Graphics/Direct3D12/MeshShaderPipelineStateDescription.cs b/src/Vortice.Win32/Graphics/Direct3D12/MeshShaderPipelineStateDescription.cs new file mode 100644 index 0000000..e3d1bdb --- /dev/null +++ b/src/Vortice.Win32/Graphics/Direct3D12/MeshShaderPipelineStateDescription.cs @@ -0,0 +1,68 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +using Win32.Graphics.Dxgi.Common; + +namespace Win32.Graphics.Direct3D12; + +/// D3DX12_MESH_SHADER_PIPELINE_STATE_DESC +public unsafe partial struct MeshShaderPipelineStateDescription +{ + public ID3D12RootSignature* pRootSignature; + + public ShaderBytecode AS; + + public ShaderBytecode MS; + + public ShaderBytecode PS; + + public BlendDescription BlendState; + + public uint SampleMask; + + public RasterizerDescription RasterizerState; + + public DepthStencilDescription1 DepthStencilState; + + public PrimitiveTopologyType PrimitiveTopologyType; + + public uint NumRenderTargets; + + public _RTVFormats_e__FixedBuffer RTVFormats; + + public Format DSVFormat; + + public SamplerDescription SampleDesc; + + public uint NodeMask; + + public CachedPipelineState CachedPSO; + + public PipelineStateFlags Flags; + + public partial struct _RTVFormats_e__FixedBuffer + { + public Format e0; + public Format e1; + public Format e2; + public Format e3; + public Format e4; + public Format e5; + public Format e6; + public Format e7; + + [UnscopedRef] + public ref Format this[int index] + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get + { + return ref AsSpan()[index]; + } + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [UnscopedRef] + public Span AsSpan() => MemoryMarshal.CreateSpan(ref e0, 8); + } +} diff --git a/src/Vortice.Win32/Graphics/Direct3D12/MipRegion.cs b/src/Vortice.Win32/Graphics/Direct3D12/MipRegion.cs new file mode 100644 index 0000000..4ee9b08 --- /dev/null +++ b/src/Vortice.Win32/Graphics/Direct3D12/MipRegion.cs @@ -0,0 +1,36 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +using Win32.Graphics.Dxgi.Common; + +namespace Win32.Graphics.Direct3D12; + +public unsafe partial struct MipRegion : IEquatable +{ + public MipRegion(uint width, uint height, uint depth) + { + Width = width; + Height = height; + Depth = depth; + } + + public static bool operator ==(in MipRegion left, in MipRegion right) + { + return + left.Width == right.Width && + left.Height == right.Height && + left.Depth == right.Depth; + } + + public static bool operator !=(in MipRegion left, in MipRegion right) + => !(left == right); + + public override bool Equals(object? obj) => (obj is MipRegion other) && Equals(other); + + public bool Equals(MipRegion other) => this == other; + + public override int GetHashCode() + { + return HashCode.Combine(Width, Height, Depth); + } +} diff --git a/src/Vortice.Win32/Graphics/Direct3D12/Range.cs b/src/Vortice.Win32/Graphics/Direct3D12/Range.cs new file mode 100644 index 0000000..7644dcf --- /dev/null +++ b/src/Vortice.Win32/Graphics/Direct3D12/Range.cs @@ -0,0 +1,15 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +using Win32.Graphics.Dxgi.Common; + +namespace Win32.Graphics.Direct3D12; + +public partial struct Range +{ + public Range(nuint begin, nuint end) + { + Begin = begin; + End = end; + } +} diff --git a/src/Vortice.Win32/Graphics/Direct3D12/RasterizerDescription.cs b/src/Vortice.Win32/Graphics/Direct3D12/RasterizerDescription.cs new file mode 100644 index 0000000..9c4c0b0 --- /dev/null +++ b/src/Vortice.Win32/Graphics/Direct3D12/RasterizerDescription.cs @@ -0,0 +1,58 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +using static Win32.Graphics.Direct3D12.Apis; + +namespace Win32.Graphics.Direct3D12; + +public partial struct RasterizerDescription +{ + /// + /// A built-in description with settings with settings for not culling any primitives. + /// + public static readonly RasterizerDescription CullNone = new(FillMode.Solid, CullMode.None); + + /// + /// A built-in description with settings for culling primitives with clockwise winding order. + /// + public static readonly RasterizerDescription CullClockwise = new(FillMode.Solid, CullMode.Front); + + /// + /// A built-in description with settings for culling primitives with counter-clockwise winding order. + /// + public static readonly RasterizerDescription CullCounterClockwise = new(FillMode.Solid, CullMode.Back); + + /// + /// A built-in description with settings for not culling any primitives and wireframe fill mode. + /// + public static readonly RasterizerDescription Wireframe = new(FillMode.Wireframe, CullMode.Back); + + /// + /// Initializes a new instance of the class. + /// + public RasterizerDescription( + FillMode fillMode, + CullMode cullMode, + bool frontCounterClockwise = false, + int depthBias = D3D12_DEFAULT_DEPTH_BIAS, + float depthBiasClamp = D3D12_DEFAULT_DEPTH_BIAS_CLAMP, + float slopeScaledDepthBias = D3D12_DEFAULT_SLOPE_SCALED_DEPTH_BIAS, + bool depthClipEnable = true, + bool multisampleEnable = true, + bool antialiasedLineEnable = false, + uint forcedSampleCount = 0, + ConservativeRasterizationMode conservativeRaster = ConservativeRasterizationMode.Off) + { + CullMode = cullMode; + FillMode = fillMode; + FrontCounterClockwise = false; + DepthBias = depthBias; + DepthBiasClamp = depthBiasClamp; + SlopeScaledDepthBias = slopeScaledDepthBias; + DepthClipEnable = depthClipEnable; + MultisampleEnable = multisampleEnable; + AntialiasedLineEnable = antialiasedLineEnable; + ForcedSampleCount = forcedSampleCount; + ConservativeRaster = conservativeRaster; + } +} diff --git a/src/Vortice.Win32/Graphics/Direct3D12/RenderTargetViewDescription.cs b/src/Vortice.Win32/Graphics/Direct3D12/RenderTargetViewDescription.cs new file mode 100644 index 0000000..f49f8ac --- /dev/null +++ b/src/Vortice.Win32/Graphics/Direct3D12/RenderTargetViewDescription.cs @@ -0,0 +1,169 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +using Win32.Graphics.Dxgi.Common; + +namespace Win32.Graphics.Direct3D12; + +public unsafe partial struct RenderTargetViewDescription +{ + /// + /// Initializes a new instance of the struct. + /// + /// The + /// The to use or . + /// The index of the mipmap level to use mip slice. or first element for . + /// The index of the first texture to use in an array of textures or NumElements for , FirstWSlice for . + /// Number of textures in the array or WSize for . + public RenderTargetViewDescription( + RtvDimension viewDimension, + Format format = Format.Unknown, + uint mipSlice = 0, + uint firstArraySlice = 0, + uint arraySize = unchecked((uint)-1)) + { + Format = format; + ViewDimension = viewDimension; + Anonymous = default; + + switch (viewDimension) + { + case RtvDimension.Buffer: + Buffer.FirstElement = mipSlice; + Buffer.NumElements = firstArraySlice; + break; + case RtvDimension.Texture1D: + Texture1D.MipSlice = mipSlice; + break; + case RtvDimension.Texture1DArray: + Texture1DArray.MipSlice = mipSlice; + Texture1DArray.FirstArraySlice = firstArraySlice; + Texture1DArray.ArraySize = arraySize; + break; + case RtvDimension.Texture2D: + Texture2D.MipSlice = mipSlice; + break; + case RtvDimension.Texture2DArray: + Texture2DArray.MipSlice = mipSlice; + Texture2DArray.FirstArraySlice = firstArraySlice; + Texture2DArray.ArraySize = arraySize; + break; + case RtvDimension.Texture2DMs: + break; + case RtvDimension.Texture2DMsArray: + Texture2DMSArray.FirstArraySlice = firstArraySlice; + Texture2DMSArray.ArraySize = arraySize; + break; + case RtvDimension.Texture3D: + Texture3D.MipSlice = mipSlice; + Texture3D.FirstWSlice = firstArraySlice; + Texture3D.WSize = arraySize; + break; + default: + break; + } + } + + /// + /// Initializes a new instance of the struct. + /// + public RenderTargetViewDescription( + ID3D12Resource* texture, + RtvDimension viewDimension = RtvDimension.Unknown, + Format format = Format.Unknown, + uint mipSlice = 0, + uint firstArraySlice = 0, + uint arraySize = unchecked((uint)-1), + uint planeSlice = 0) + { + ViewDimension = viewDimension; + if (viewDimension == RtvDimension.Unknown || + format == Format.Unknown || + arraySize == unchecked((uint)-1)) + { + ResourceDescription resourceDesc = texture->GetDesc(); + + if (viewDimension == RtvDimension.Unknown) + { + switch (resourceDesc.Dimension) + { + case ResourceDimension.Buffer: + viewDimension = RtvDimension.Buffer; + break; + case ResourceDimension.Texture1D: + viewDimension = resourceDesc.DepthOrArraySize > 1 ? RtvDimension.Texture1DArray : RtvDimension.Texture1D; + break; + case ResourceDimension.Texture2D: + if (resourceDesc.SampleDesc.Count > 1) + { + viewDimension = resourceDesc.DepthOrArraySize > 1 ? RtvDimension.Texture2DMsArray : RtvDimension.Texture2DMs; + } + else + { + viewDimension = resourceDesc.DepthOrArraySize > 1 ? RtvDimension.Texture2DArray : RtvDimension.Texture2D; + } + break; + case ResourceDimension.Texture3D: + viewDimension = RtvDimension.Texture3D; + break; + } + } + + if (format == Format.Unknown) + { + format = resourceDesc.Format; + } + + bool isArray = + viewDimension == RtvDimension.Texture2DArray || + viewDimension == RtvDimension.Texture2DMsArray; + + if (arraySize == unchecked((uint)-1) && + isArray) + { + arraySize = resourceDesc.ArraySize - firstArraySlice; + } + } + + Format = format; + Anonymous = default; + switch (viewDimension) + { + case RtvDimension.Buffer: + Anonymous.Buffer.FirstElement = firstArraySlice; + Anonymous.Buffer.NumElements = arraySize; + break; + case RtvDimension.Texture1D: + Anonymous.Texture1D.MipSlice = mipSlice; + break; + case RtvDimension.Texture1DArray: + Anonymous.Texture1DArray.MipSlice = mipSlice; + Anonymous.Texture1DArray.FirstArraySlice = firstArraySlice; + Anonymous.Texture1DArray.ArraySize = arraySize; + break; + case RtvDimension.Texture2D: + Anonymous.Texture2D.MipSlice = mipSlice; + Anonymous.Texture2D.PlaneSlice = planeSlice; + break; + case RtvDimension.Texture2DArray: + Anonymous.Texture2DArray.MipSlice = mipSlice; + Anonymous.Texture2DArray.FirstArraySlice = firstArraySlice; + Anonymous.Texture2DArray.ArraySize = arraySize; + Anonymous.Texture2DArray.PlaneSlice = planeSlice; + break; + case RtvDimension.Texture2DMs: + break; + case RtvDimension.Texture2DMsArray: + Anonymous.Texture2DMSArray.FirstArraySlice = firstArraySlice; + Anonymous.Texture2DMSArray.ArraySize = arraySize; + break; + case RtvDimension.Texture3D: + Anonymous.Texture3D.MipSlice = mipSlice; + Anonymous.Texture3D.FirstWSlice = firstArraySlice; + Anonymous.Texture3D.WSize = arraySize; + break; + default: + break; + } + } +} diff --git a/src/Vortice.Win32/Graphics/Direct3D12/ResourceDescription.cs b/src/Vortice.Win32/Graphics/Direct3D12/ResourceDescription.cs index a0fb902..77eab01 100644 --- a/src/Vortice.Win32/Graphics/Direct3D12/ResourceDescription.cs +++ b/src/Vortice.Win32/Graphics/Direct3D12/ResourceDescription.cs @@ -156,8 +156,10 @@ public unsafe partial struct ResourceDescription : IEquatable !(l == r); + public static bool operator !=(in ResourceDescription left, in ResourceDescription right) + { + return !(left == right); + } public override bool Equals(object? obj) => (obj is ResourceDescription other) && Equals(other); diff --git a/src/Vortice.Win32/Graphics/Direct3D12/ResourceDescription1.cs b/src/Vortice.Win32/Graphics/Direct3D12/ResourceDescription1.cs new file mode 100644 index 0000000..ee1bb84 --- /dev/null +++ b/src/Vortice.Win32/Graphics/Direct3D12/ResourceDescription1.cs @@ -0,0 +1,199 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +using Win32.Graphics.Dxgi.Common; +using static Win32.Graphics.Direct3D12.Apis; + +namespace Win32.Graphics.Direct3D12; + +public unsafe partial struct ResourceDescription1 : IEquatable +{ + /// + /// Initializes a new instance of the struct. + /// + public ResourceDescription1( + ResourceDimension dimension, + ulong alignment, + ulong width, + uint height, + ushort depthOrArraySize, + ushort mipLevels, + Format format, + uint sampleCount, + uint sampleQuality, + TextureLayout layout, + ResourceFlags flags, + uint samplerFeedbackMipRegionWidth = 0, + uint samplerFeedbackMipRegionHeight = 0, + uint samplerFeedbackMipRegionDepth = 0) + { + Dimension = dimension; + Alignment = alignment; + Width = width; + Height = height; + DepthOrArraySize = depthOrArraySize; + MipLevels = mipLevels; + Format = format; + SampleDesc = new(sampleCount, sampleQuality); + Layout = layout; + Flags = flags; + SamplerFeedbackMipRegion = new( + samplerFeedbackMipRegionWidth, + samplerFeedbackMipRegionHeight, + samplerFeedbackMipRegionDepth); + } + + public static ResourceDescription1 Buffer(in ResourceAllocationInfo resourceAllocInfo, ResourceFlags flags = ResourceFlags.None) + { + return new ResourceDescription1( + ResourceDimension.Buffer, + resourceAllocInfo.Alignment, + resourceAllocInfo.SizeInBytes, + 1, 1, 1, Format.Unknown, 1, 0, TextureLayout.RowMajor, + flags, + 0, 0, 0); + } + + public static ResourceDescription1 Buffer( + ulong sizeInBytes, + ResourceFlags flags = ResourceFlags.None, + ulong alignment = 0) + { + return new ResourceDescription1( + ResourceDimension.Buffer, + alignment, + sizeInBytes, + 1, 1, 1, + Format.Unknown, 1, 0, TextureLayout.RowMajor, + flags, + 0, 0, 0); + } + + public static ResourceDescription Tex1D(Format format, + ulong width, + ushort arraySize = 1, + ushort mipLevels = 0, + ResourceFlags flags = ResourceFlags.None, + TextureLayout layout = TextureLayout.Unknown, + ulong alignment = 0) + { + return new ResourceDescription(ResourceDimension.Texture1D, alignment, width, 1, arraySize, mipLevels, format, 1, 0, layout, flags); + } + + public static ResourceDescription1 Tex2D(Format format, + ulong width, + uint height, + ushort arraySize = 1, + ushort mipLevels = 0, + uint sampleCount = 1, + uint sampleQuality = 0, + ResourceFlags flags = ResourceFlags.None, + TextureLayout layout = TextureLayout.Unknown, + ulong alignment = 0, + uint samplerFeedbackMipRegionWidth = 0, + uint samplerFeedbackMipRegionHeight = 0, + uint samplerFeedbackMipRegionDepth = 0) + { + return new ResourceDescription1(ResourceDimension.Texture2D, + alignment, + width, + height, + arraySize, + mipLevels, + format, + sampleCount, + sampleQuality, + layout, + flags, + samplerFeedbackMipRegionWidth, + samplerFeedbackMipRegionHeight, + samplerFeedbackMipRegionDepth); + } + + public static ResourceDescription1 Texture3D(Format format, + ulong width, + uint height, + ushort depth, + ushort mipLevels = 0, + ResourceFlags flags = ResourceFlags.None, + TextureLayout layout = TextureLayout.Unknown, + ulong alignment = 0) + { + return new ResourceDescription1( + ResourceDimension.Texture3D, + alignment, + width, + height, + depth, + mipLevels, + format, + 1, + 0, + layout, + flags, + 0, 0, 0); + } + + public ushort Depth => ((Dimension == ResourceDimension.Texture3D) ? DepthOrArraySize : (ushort)(1)); + + public ushort ArraySize => ((Dimension != ResourceDimension.Texture3D) ? DepthOrArraySize : (ushort)(1)); + + public byte GetPlaneCount(ID3D12Device* pDevice) + { + return D3D12GetFormatPlaneCount(pDevice, Format); + } + + public uint GetSubresources(ID3D12Device* pDevice) + { + return MipLevels * (uint)ArraySize * GetPlaneCount(pDevice); + } + + public uint CalcSubresource(uint MipSlice, uint ArraySlice, uint PlaneSlice) + { + return D3D12CalcSubresource(MipSlice, ArraySlice, PlaneSlice, MipLevels, ArraySize); + } + + public static bool operator ==(in ResourceDescription1 left, in ResourceDescription1 right) + { + return (left.Dimension == right.Dimension) + && (left.Alignment == right.Alignment) + && (left.Width == right.Width) + && (left.Height == right.Height) + && (left.DepthOrArraySize == right.DepthOrArraySize) + && (left.MipLevels == right.MipLevels) + && (left.Format == right.Format) + && (left.SampleDesc.Count == right.SampleDesc.Count) + && (left.SampleDesc.Quality == right.SampleDesc.Quality) + && (left.Layout == right.Layout) + && (left.Flags == right.Flags) + && (left.SamplerFeedbackMipRegion == right.SamplerFeedbackMipRegion); + } + + public static bool operator !=(in ResourceDescription1 left, in ResourceDescription1 right) + { + return !(left == right); + } + + public override bool Equals(object? obj) => (obj is ResourceDescription1 other) && Equals(other); + + public bool Equals(ResourceDescription1 other) => this == other; + + public override int GetHashCode() + { + var hashCode = new HashCode(); + { + hashCode.Add(Dimension); + hashCode.Add(Alignment); + hashCode.Add(Width); + hashCode.Add(Height); + hashCode.Add(DepthOrArraySize); + hashCode.Add(MipLevels); + hashCode.Add(Format); + hashCode.Add(SampleDesc); + hashCode.Add(Layout); + hashCode.Add(Flags); + hashCode.Add(SamplerFeedbackMipRegion); + } + return hashCode.ToHashCode(); + } +} diff --git a/src/Vortice.Win32/Graphics/Direct3D12/RootConstants.cs b/src/Vortice.Win32/Graphics/Direct3D12/RootConstants.cs new file mode 100644 index 0000000..c301f2c --- /dev/null +++ b/src/Vortice.Win32/Graphics/Direct3D12/RootConstants.cs @@ -0,0 +1,28 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +namespace Win32.Graphics.Direct3D12; + +public unsafe partial struct RootConstants +{ + public RootConstants(uint num32BitValues, uint shaderRegister, uint registerSpace = 0) + { + Init(out this, num32BitValues, shaderRegister, registerSpace); + } + + public void Init(uint num32BitValues, uint shaderRegister, uint registerSpace = 0) + { + Init(out this, num32BitValues, shaderRegister, registerSpace); + } + + public static void Init( + out RootConstants rootConstants, + uint num32BitValues, + uint shaderRegister, + uint registerSpace = 0) + { + rootConstants.Num32BitValues = num32BitValues; + rootConstants.ShaderRegister = shaderRegister; + rootConstants.RegisterSpace = registerSpace; + } +} diff --git a/src/Vortice.Win32/Graphics/Direct3D12/RootDescriptor.cs b/src/Vortice.Win32/Graphics/Direct3D12/RootDescriptor.cs new file mode 100644 index 0000000..f075038 --- /dev/null +++ b/src/Vortice.Win32/Graphics/Direct3D12/RootDescriptor.cs @@ -0,0 +1,23 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +namespace Win32.Graphics.Direct3D12; + +public unsafe partial struct RootDescriptor +{ + public RootDescriptor(uint shaderRegister, uint registerSpace = 0) + { + Init(out this, shaderRegister, registerSpace); + } + + public void Init(uint shaderRegister, uint registerSpace = 0) + { + Init(out this, shaderRegister, registerSpace); + } + + public static void Init(out RootDescriptor table, uint shaderRegister, uint registerSpace = 0) + { + table.ShaderRegister = shaderRegister; + table.RegisterSpace = registerSpace; + } +} diff --git a/src/Vortice.Win32/Graphics/Direct3D12/RootDescriptor1.cs b/src/Vortice.Win32/Graphics/Direct3D12/RootDescriptor1.cs new file mode 100644 index 0000000..f437d2e --- /dev/null +++ b/src/Vortice.Win32/Graphics/Direct3D12/RootDescriptor1.cs @@ -0,0 +1,27 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +namespace Win32.Graphics.Direct3D12; + +public unsafe partial struct RootDescriptor1 +{ + public RootDescriptor1(uint shaderRegister, uint registerSpace = 0, RootDescriptorFlags flags = RootDescriptorFlags.None) + { + Init(out this, shaderRegister, registerSpace, flags); + } + + public void Init(uint shaderRegister, uint registerSpace = 0, RootDescriptorFlags flags = RootDescriptorFlags.None) + { + Init(out this, shaderRegister, registerSpace, flags); + } + + public static void Init(out RootDescriptor1 table, + uint shaderRegister, + uint registerSpace = 0, + RootDescriptorFlags flags = RootDescriptorFlags.None) + { + table.ShaderRegister = shaderRegister; + table.RegisterSpace = registerSpace; + table.Flags = flags; + } +} diff --git a/src/Vortice.Win32/Graphics/Direct3D12/RootDescriptorTable.cs b/src/Vortice.Win32/Graphics/Direct3D12/RootDescriptorTable.cs new file mode 100644 index 0000000..af7d44a --- /dev/null +++ b/src/Vortice.Win32/Graphics/Direct3D12/RootDescriptorTable.cs @@ -0,0 +1,24 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +namespace Win32.Graphics.Direct3D12; + +public unsafe partial struct RootDescriptorTable +{ + public RootDescriptorTable(uint numDescriptorRanges, DescriptorRange* descriptorRanges) + { + Init(out this, numDescriptorRanges, descriptorRanges); + } + + public void Init(uint numDescriptorRanges, DescriptorRange* descriptorRanges) + { + Init(out this, numDescriptorRanges, descriptorRanges); + } + + public static void Init(out RootDescriptorTable rootDescriptorTable, + uint numDescriptorRanges, DescriptorRange* descriptorRanges) + { + rootDescriptorTable.NumDescriptorRanges = numDescriptorRanges; + rootDescriptorTable.pDescriptorRanges = descriptorRanges; + } +} diff --git a/src/Vortice.Win32/Graphics/Direct3D12/RootDescriptorTable1.cs b/src/Vortice.Win32/Graphics/Direct3D12/RootDescriptorTable1.cs new file mode 100644 index 0000000..c257dd8 --- /dev/null +++ b/src/Vortice.Win32/Graphics/Direct3D12/RootDescriptorTable1.cs @@ -0,0 +1,24 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +namespace Win32.Graphics.Direct3D12; + +public unsafe partial struct RootDescriptorTable1 +{ + public RootDescriptorTable1(uint numDescriptorRanges, DescriptorRange1* descriptorRanges) + { + Init(out this, numDescriptorRanges, descriptorRanges); + } + + public void Init(uint numDescriptorRanges, DescriptorRange1* descriptorRanges) + { + Init(out this, numDescriptorRanges, descriptorRanges); + } + + public static void Init(out RootDescriptorTable1 rootDescriptorTable, + uint numDescriptorRanges, DescriptorRange1* descriptorRanges) + { + rootDescriptorTable.NumDescriptorRanges = numDescriptorRanges; + rootDescriptorTable.pDescriptorRanges = descriptorRanges; + } +} diff --git a/src/Vortice.Win32/Graphics/Direct3D12/RootParameter1.cs b/src/Vortice.Win32/Graphics/Direct3D12/RootParameter1.cs new file mode 100644 index 0000000..a175900 --- /dev/null +++ b/src/Vortice.Win32/Graphics/Direct3D12/RootParameter1.cs @@ -0,0 +1,114 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +namespace Win32.Graphics.Direct3D12; + +public unsafe partial struct RootParameter1 +{ + public static void InitAsDescriptorTable( + out RootParameter1 rootParam, + uint numDescriptorRanges, + DescriptorRange1* pDescriptorRanges, + ShaderVisibility visibility = ShaderVisibility.All) + { + rootParam = default; + + rootParam.ParameterType = RootParameterType.DescriptorTable; + rootParam.ShaderVisibility = visibility; + RootDescriptorTable1.Init(out rootParam.Anonymous.DescriptorTable, numDescriptorRanges, pDescriptorRanges); + } + + public static void InitAsConstants( + out RootParameter1 rootParam, + uint num32BitValues, + uint shaderRegister, + uint registerSpace = 0, + ShaderVisibility visibility = ShaderVisibility.All) + { + rootParam = default; + + rootParam.ParameterType = RootParameterType.T32BitConstants; + rootParam.ShaderVisibility = visibility; + RootConstants.Init(out rootParam.Anonymous.Constants, num32BitValues, shaderRegister, registerSpace); + } + + public static void InitAsConstantBufferView( + out RootParameter1 rootParam, + uint shaderRegister, + uint registerSpace = 0, + ShaderVisibility visibility = ShaderVisibility.All) + { + rootParam = default; + + rootParam.ParameterType = RootParameterType.Cbv; + rootParam.ShaderVisibility = visibility; + RootDescriptor1.Init(out rootParam.Anonymous.Descriptor, shaderRegister, registerSpace); + } + + public static void InitAsShaderResourceView( + out RootParameter1 rootParam, + uint shaderRegister, + uint registerSpace = 0, + ShaderVisibility visibility = ShaderVisibility.All) + { + rootParam = default; + + rootParam.ParameterType = RootParameterType.Srv; + rootParam.ShaderVisibility = visibility; + RootDescriptor1.Init(out rootParam.Anonymous.Descriptor, shaderRegister, registerSpace); + } + + public static void InitAsUnorderedAccessView( + out RootParameter1 rootParam, + uint shaderRegister, + uint registerSpace = 0, + ShaderVisibility visibility = ShaderVisibility.All) + { + rootParam = default; + + rootParam.ParameterType = RootParameterType.Uav; + rootParam.ShaderVisibility = visibility; + RootDescriptor1.Init(out rootParam.Anonymous.Descriptor, shaderRegister, registerSpace); + } + + public void InitAsDescriptorTable( + uint numDescriptorRanges, + DescriptorRange1* pDescriptorRanges, + ShaderVisibility visibility = ShaderVisibility.All) + { + InitAsDescriptorTable(out this, numDescriptorRanges, pDescriptorRanges, visibility); + } + + public void InitAsConstants( + uint num32BitValues, + uint shaderRegister, + uint registerSpace = 0, + ShaderVisibility visibility = ShaderVisibility.All) + { + InitAsConstants(out this, num32BitValues, shaderRegister, registerSpace, visibility); + } + + public void InitAsConstantBufferView( + uint shaderRegister, + uint registerSpace = 0, + ShaderVisibility visibility = ShaderVisibility.All) + { + InitAsConstantBufferView(out this, shaderRegister, registerSpace, visibility); + } + + public void InitAsShaderResourceView( + uint shaderRegister, + uint registerSpace = 0, + ShaderVisibility visibility = ShaderVisibility.All) + { + InitAsShaderResourceView(out this, shaderRegister, registerSpace, visibility); + } + + public void InitAsUnorderedAccessView( + uint shaderRegister, + uint registerSpace = 0, + ShaderVisibility visibility = ShaderVisibility.All) + { + InitAsUnorderedAccessView(out this, shaderRegister, registerSpace, visibility); + } +} diff --git a/src/Vortice.Win32/Graphics/Direct3D12/RootSignatureDescription.cs b/src/Vortice.Win32/Graphics/Direct3D12/RootSignatureDescription.cs new file mode 100644 index 0000000..6375b02 --- /dev/null +++ b/src/Vortice.Win32/Graphics/Direct3D12/RootSignatureDescription.cs @@ -0,0 +1,36 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +namespace Win32.Graphics.Direct3D12; + +public unsafe partial struct RootSignatureDescription +{ + public RootSignatureDescription( + uint numParameters, RootParameter* parameters, + uint numStaticSamplers = 0, StaticSamplerDescription* staticSamplers = null, + RootSignatureFlags flags = RootSignatureFlags.None) + { + Init(out this, numParameters, parameters, numStaticSamplers, staticSamplers, flags); + } + + public void Init( + uint numParameters, RootParameter* parameters, + uint numStaticSamplers = 0, StaticSamplerDescription* staticSamplers = null, + RootSignatureFlags flags = RootSignatureFlags.None) + { + Init(out this, numParameters, parameters, numStaticSamplers, staticSamplers, flags); + } + + public static void Init( + out RootSignatureDescription desc, + uint numParameters, RootParameter* parameters, + uint numStaticSamplers = 0, StaticSamplerDescription* staticSamplers = null, + RootSignatureFlags flags = RootSignatureFlags.None) + { + desc.NumParameters = numParameters; + desc.pParameters = parameters; + desc.NumStaticSamplers = numStaticSamplers; + desc.pStaticSamplers = staticSamplers; + desc.Flags = flags; + } +} diff --git a/src/Vortice.Win32/Graphics/Direct3D12/RootSignatureDescription1.cs b/src/Vortice.Win32/Graphics/Direct3D12/RootSignatureDescription1.cs new file mode 100644 index 0000000..e61fafc --- /dev/null +++ b/src/Vortice.Win32/Graphics/Direct3D12/RootSignatureDescription1.cs @@ -0,0 +1,36 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +namespace Win32.Graphics.Direct3D12; + +public unsafe partial struct RootSignatureDescription1 +{ + public RootSignatureDescription1( + uint numParameters, RootParameter1* parameters, + uint numStaticSamplers = 0, StaticSamplerDescription* staticSamplers = null, + RootSignatureFlags flags = RootSignatureFlags.None) + { + Init(out this, numParameters, parameters, numStaticSamplers, staticSamplers, flags); + } + + public void Init( + uint numParameters, RootParameter1* parameters, + uint numStaticSamplers = 0, StaticSamplerDescription* staticSamplers = null, + RootSignatureFlags flags = RootSignatureFlags.None) + { + Init(out this, numParameters, parameters, numStaticSamplers, staticSamplers, flags); + } + + public static void Init( + out RootSignatureDescription1 desc, + uint numParameters, RootParameter1* parameters, + uint numStaticSamplers = 0, StaticSamplerDescription* staticSamplers = null, + RootSignatureFlags flags = RootSignatureFlags.None) + { + desc.NumParameters = numParameters; + desc.pParameters = parameters; + desc.NumStaticSamplers = numStaticSamplers; + desc.pStaticSamplers = staticSamplers; + desc.Flags = flags; + } +} diff --git a/src/Vortice.Win32/Graphics/Direct3D12/SamplerDescription.cs b/src/Vortice.Win32/Graphics/Direct3D12/SamplerDescription.cs new file mode 100644 index 0000000..4a2fc4e --- /dev/null +++ b/src/Vortice.Win32/Graphics/Direct3D12/SamplerDescription.cs @@ -0,0 +1,130 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +using static Win32.Graphics.Direct3D11.Apis; + +namespace Win32.Graphics.Direct3D11; + +public unsafe partial struct SamplerDescription +{ + public static readonly SamplerDescription PointWrap = new(Filter.MinMagMipPoint, TextureAddressMode.Wrap); + public static readonly SamplerDescription PointClamp = new(Filter.MinMagMipPoint, TextureAddressMode.Clamp); + + public static readonly SamplerDescription LinearWrap = new(Filter.MinMagMipLinear, TextureAddressMode.Wrap); + public static readonly SamplerDescription LinearClamp = new(Filter.MinMagMipLinear, TextureAddressMode.Clamp); + + public static readonly SamplerDescription AnisotropicWrap = new(Filter.Anisotropic, TextureAddressMode.Wrap, 0.0f, D3D11_MAX_MAXANISOTROPY); + public static readonly SamplerDescription AnisotropicClamp = new(Filter.Anisotropic, TextureAddressMode.Clamp, 0.0f, D3D11_MAX_MAXANISOTROPY); + + /// + /// Initializes a new instance of the struct. + /// + /// Filtering method to use when sampling a texture. + /// Method to use for resolving a u texture coordinate that is outside the 0 to 1 range. + /// Method to use for resolving a v texture coordinate that is outside the 0 to 1 range. + /// Method to use for resolving a w texture coordinate that is outside the 0 to 1 range. + /// Offset from the calculated mipmap level. + /// Clamping value used if or is specified in Filter. Valid values are between 1 and 16. + /// A function that compares sampled data against existing sampled data. + /// Border color to use if is specified for AddressU, AddressV, or AddressW. + /// Lower end of the mipmap range to clamp access to, where 0 is the largest and most detailed mipmap level and any level higher than that is less detailed. + /// Upper end of the mipmap range to clamp access to, where 0 is the largest and most detailed mipmap level and any level higher than that is less detailed. This value must be greater than or equal to MinLOD. + public SamplerDescription( + Filter filter, + TextureAddressMode addressU, + TextureAddressMode addressV, + TextureAddressMode addressW, + float mipLODBias, + uint maxAnisotropy, + ComparisonFunction comparisonFunction, + Color4 borderColor, + float minLOD, + float maxLOD) + { + Filter = filter; + AddressU = addressU; + AddressV = addressV; + AddressW = addressW; + MipLODBias = mipLODBias; + MaxAnisotropy = maxAnisotropy; + ComparisonFunc = comparisonFunction; + BorderColor[0] = borderColor.R; + BorderColor[1] = borderColor.G; + BorderColor[2] = borderColor.B; + BorderColor[3] = borderColor.A; + MinLOD = minLOD; + MaxLOD = maxLOD; + } + + /// + /// Initializes a new instance of the struct. + /// + /// Filtering method to use when sampling a texture. + /// Method to use for resolving a u texture coordinate that is outside the 0 to 1 range. + /// Method to use for resolving a v texture coordinate that is outside the 0 to 1 range. + /// Method to use for resolving a w texture coordinate that is outside the 0 to 1 range. + /// Offset from the calculated mipmap level. + /// Clamping value used if or is specified in Filter. Valid values are between 1 and 16. + /// A function that compares sampled data against existing sampled data. + /// Lower end of the mipmap range to clamp access to, where 0 is the largest and most detailed mipmap level and any level higher than that is less detailed. + /// Upper end of the mipmap range to clamp access to, where 0 is the largest and most detailed mipmap level and any level higher than that is less detailed. This value must be greater than or equal to MinLOD. + public SamplerDescription( + Filter filter, + TextureAddressMode addressU, + TextureAddressMode addressV, + TextureAddressMode addressW, + float mipLODBias = 0.0f, + uint maxAnisotropy = 1, + ComparisonFunction comparisonFunction = ComparisonFunction.Never, + float minLOD = float.MinValue, + float maxLOD = float.MaxValue) + { + Filter = filter; + AddressU = addressU; + AddressV = addressV; + AddressW = addressW; + MipLODBias = mipLODBias; + MaxAnisotropy = maxAnisotropy; + ComparisonFunc = comparisonFunction; + BorderColor[0] = 1.0f; + BorderColor[1] = 1.0f; + BorderColor[2] = 1.0f; + BorderColor[3] = 1.0f; + MinLOD = minLOD; + MaxLOD = maxLOD; + } + + /// + /// Initializes a new instance of the struct. + /// + /// Filtering method to use when sampling a texture. + /// Method to use for resolving a u, v e w texture coordinate that is outside the 0 to 1 range. + /// Offset from the calculated mipmap level. + /// Clamping value used if or is specified in Filter. Valid values are between 1 and 16. + /// A function that compares sampled data against existing sampled data. + /// Lower end of the mipmap range to clamp access to, where 0 is the largest and most detailed mipmap level and any level higher than that is less detailed. + /// Upper end of the mipmap range to clamp access to, where 0 is the largest and most detailed mipmap level and any level higher than that is less detailed. This value must be greater than or equal to MinLOD. + public SamplerDescription( + Filter filter, + TextureAddressMode address, + float mipLODBias = 0.0f, + uint maxAnisotropy = 1, + ComparisonFunction comparisonFunction = ComparisonFunction.Never, + float minLOD = float.MinValue, + float maxLOD = float.MaxValue) + { + Filter = filter; + AddressU = address; + AddressV = address; + AddressW = address; + MipLODBias = mipLODBias; + MaxAnisotropy = maxAnisotropy; + ComparisonFunc = comparisonFunction; + BorderColor[0] = 1.0f; + BorderColor[1] = 1.0f; + BorderColor[2] = 1.0f; + BorderColor[3] = 1.0f; + MinLOD = minLOD; + MaxLOD = maxLOD; + } +} diff --git a/src/Vortice.Win32/Graphics/Direct3D12/ShaderBytecode.cs b/src/Vortice.Win32/Graphics/Direct3D12/ShaderBytecode.cs new file mode 100644 index 0000000..eff5e37 --- /dev/null +++ b/src/Vortice.Win32/Graphics/Direct3D12/ShaderBytecode.cs @@ -0,0 +1,22 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +using Win32.Graphics.Direct3D; +using Win32.Graphics.Dxgi.Common; + +namespace Win32.Graphics.Direct3D12; + +public unsafe partial struct ShaderBytecode +{ + public ShaderBytecode(ID3DBlob* shaderBlob) + { + pShaderBytecode = shaderBlob->GetBufferPointer(); + BytecodeLength = shaderBlob->GetBufferSize(); + } + + public ShaderBytecode(void* shaderBytecode, nuint bytecodeLength) + { + pShaderBytecode = shaderBytecode; + BytecodeLength = bytecodeLength; + } +} diff --git a/src/Vortice.Win32/Graphics/Direct3D12/StaticSamplerDescription.cs b/src/Vortice.Win32/Graphics/Direct3D12/StaticSamplerDescription.cs new file mode 100644 index 0000000..ea9e426 --- /dev/null +++ b/src/Vortice.Win32/Graphics/Direct3D12/StaticSamplerDescription.cs @@ -0,0 +1,65 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +using static Win32.Graphics.Direct3D12.Apis; + +namespace Win32.Graphics.Direct3D12; + +public unsafe partial struct StaticSamplerDescription +{ + /// + /// Initializes a new instance of the struct. + /// + /// The shader visibility. + /// The shader register. + /// The register space. + public StaticSamplerDescription( + ShaderVisibility shaderVisibility, + uint shaderRegister, + uint registerSpace) + { + Filter = Filter.MinMagMipLinear; + AddressU = TextureAddressMode.Clamp; + AddressV = TextureAddressMode.Clamp; + AddressW = TextureAddressMode.Clamp; + MipLODBias = 0.0f; + MaxAnisotropy = 1; + ComparisonFunc = ComparisonFunction.Never; + BorderColor = StaticBorderColor.TransparentBlack; + MinLOD = float.MinValue; + MaxLOD = float.MaxValue; + + ShaderRegister = shaderRegister; + RegisterSpace = registerSpace; + ShaderVisibility = shaderVisibility; + } + + /// + /// Initializes a new instance of the struct. + /// + /// Sampler description + /// The shader visibility. + /// The shader register. + /// The register space. + public StaticSamplerDescription( + in SamplerDescription samplerDescription, + ShaderVisibility shaderVisibility, + uint shaderRegister, + uint registerSpace, + StaticBorderColor borderColor = StaticBorderColor.OpaqueWhite) : this() + { + ShaderVisibility = shaderVisibility; + ShaderRegister = shaderRegister; + RegisterSpace = registerSpace; + BorderColor = borderColor; + Filter = samplerDescription.Filter; + AddressU = samplerDescription.AddressU; + AddressV = samplerDescription.AddressV; + AddressW = samplerDescription.AddressW; + MinLOD = samplerDescription.MinLOD; + MaxLOD = samplerDescription.MaxLOD; + MipLODBias = samplerDescription.MipLODBias; + MaxAnisotropy = samplerDescription.MaxAnisotropy; + ComparisonFunc = samplerDescription.ComparisonFunc; + } +} diff --git a/src/Vortice.Win32/Graphics/Direct3D12/VertexBufferView.cs b/src/Vortice.Win32/Graphics/Direct3D12/VertexBufferView.cs new file mode 100644 index 0000000..2f47ae9 --- /dev/null +++ b/src/Vortice.Win32/Graphics/Direct3D12/VertexBufferView.cs @@ -0,0 +1,20 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +namespace Win32.Graphics.Direct3D12; + +public unsafe partial struct VertexBufferView +{ + /// + /// Initializes a new instance of the struct. + /// + /// Specifies a gpu virtual address that identifies the address of the buffer. + /// Specifies the size in bytes of the buffer. + /// Specifies the size in bytes of each vertex entry. + public VertexBufferView(ulong bufferLocation, uint sizeInBytes, uint strideInBytes) + { + BufferLocation = bufferLocation; + SizeInBytes = sizeInBytes; + StrideInBytes = strideInBytes; + } +} diff --git a/src/Vortice.Win32/Vortice.Win32.csproj b/src/Vortice.Win32/Vortice.Win32.csproj index 36e7d8d..e24e0bb 100644 --- a/src/Vortice.Win32/Vortice.Win32.csproj +++ b/src/Vortice.Win32/Vortice.Win32.csproj @@ -3,7 +3,7 @@ netstandard2.0;net6.0; Windows API low level bindings. - 1.5.5 + 1.6.0 true