diff --git a/src/Generator/Program.cs b/src/Generator/Program.cs index 24b79b6..e31f7ec 100644 --- a/src/Generator/Program.cs +++ b/src/Generator/Program.cs @@ -20,7 +20,9 @@ public static class Program "Graphics.Direct3D11.json", "Graphics.Direct3D12.json", "Graphics.Direct3D.Dxc.json", + "Graphics.Direct2D.Common.json", //"Graphics.Imaging.json", + //"Graphics.DirectWrite.json", }; private static readonly Dictionary s_csNameMappings = new() @@ -75,6 +77,15 @@ public static class Program { "Graphics.Direct3D.D3DVECTOR", "Vector3" }, { "Graphics.Direct3D.D3DMATRIX", "Matrix4x4" }, + { "Graphics.Direct2D.Common.D2D_MATRIX_3X2_F", "Matrix3x2" }, + { "Graphics.Direct2D.Common.D2D_MATRIX_4X3_F", "Matrix4x3" }, + { "Graphics.Direct2D.Common.D2D_MATRIX_4X4_F", "Matrix4x4" }, + { "Graphics.Direct2D.Common.D2D_MATRIX_5X4_F", "Matrix5x4" }, + { "Graphics.Direct2D.Common.D2D_POINT_2F", "System.Drawing.PointF" }, + { "Graphics.Direct2D.Common.D2D_VECTOR_2F", "Vector2" }, + { "Graphics.Direct2D.Common.D2D_VECTOR_3F", "Vector3" }, + { "Graphics.Direct2D.Common.D2D_VECTOR_4F", "Vector4" }, + { "Graphics.Direct2D.Common.D2D_SIZE_F", "System.Drawing.SizeF" }, // TODO: Understand those -> { "Foundation.RECT", "RawRect" }, @@ -488,6 +499,14 @@ public static class Program "SourceNot2D", "DestinationNot2D", "CreateFence", + "SynchronizedChannel", + "DecoderBeginFrame", + "VideoProcessorGetStreamMirror", + "BackbufferNotSupported", + "DimensionsTooLarge", + "InvalidMipLevel", + "ColorMatrix", + "StencilOp", }; private static readonly HashSet s_preserveCaps = new(StringComparer.OrdinalIgnoreCase) @@ -516,6 +535,9 @@ public static class Program "D3D", "D3D11", "D3D12", + "D2D", + "D2D1", + "DWRITE", }; @@ -610,6 +632,9 @@ public static class Program "D3D10", "D3D11", "D3D12", + "D2D", + "D2D1", + "DWRITE", }; private static readonly HashSet s_ignoredParts = new(StringComparer.OrdinalIgnoreCase) @@ -734,6 +759,7 @@ public static class Program } // Generate docs + //DocGenerator.Generate(new[] { "DWRITE" }, Path.Combine(outputPath, "DirectWrite.xml")); //DocGenerator.Generate(new[] { "D3D" }, Path.Combine(outputPath, "Direct3D.xml")); //DocGenerator.Generate(new[] { "DXGI" }, Path.Combine(outputPath, "Dxgi.xml")); //DocGenerator.Generate(new[] { "D3D11" }, Path.Combine(outputPath, "Direct3D11.xml")); @@ -965,7 +991,8 @@ public static class Program foreach (ApiType structType in api.Types.Where(item => item.Kind.ToLowerInvariant() == "struct")) { if (structType.Name.StartsWith("D3DX11") || - structType.Name.StartsWith("CD3D11")) + structType.Name.StartsWith("CD3D11") || + structType.Name == "D2D_COLOR_F") { continue; } @@ -1298,6 +1325,11 @@ public static class Program writer.WriteLine("[StructLayout(LayoutKind.Explicit)]"); } + if (structType.Name == "D2D_MATRIX_3X2_F") + { + + } + using (writer.PushBlock($"public partial struct {csTypeName}")) { int fieldIndex = 0; @@ -1409,6 +1441,9 @@ public static class Program { writer.WriteLine("[FieldOffset(0)]"); } + + fieldValueName = CleanupName(fieldValueName); + writer.WriteLine($"public {unsafePrefix}{fieldTypeName} {fieldValueName};"); } @@ -1661,6 +1696,8 @@ public static class Program } } + parameterName = CleanupName(parameterName); + argumentBuilder.Append(parameterType).Append(' ').Append(parameterName); //if (isOptional == true) //{ @@ -1761,6 +1798,16 @@ public static class Program return typeName.Replace(api + ".", ""); } + private static string CleanupName(string name) + { + if (name == "string") + { + return "@string"; + } + + return name; + } + private static string GetDataTypeName(string typeName, out string prefix) { prefix = typeName; diff --git a/src/Vortice.Win32/Generated/Graphics/Direct2D.Common.cs b/src/Vortice.Win32/Generated/Graphics/Direct2D.Common.cs new file mode 100644 index 0000000..77b255a --- /dev/null +++ b/src/Vortice.Win32/Generated/Graphics/Direct2D.Common.cs @@ -0,0 +1,485 @@ +// ------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ + +using System; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Diagnostics.CodeAnalysis; + +#if !NET6_0_OR_GREATER +using MemoryMarshal = Win32.MemoryMarshal; +#endif + +namespace Win32.Graphics.Direct2D.Common; + +public static partial class Apis +{ +} + +#region Enums +/// +/// D2D1_ALPHA_MODE +public enum AlphaMode : uint +{ + /// + /// D2D1_ALPHA_MODE_UNKNOWN + Unknown = 0, + /// + /// D2D1_ALPHA_MODE_PREMULTIPLIED + Premultiplied = 1, + /// + /// D2D1_ALPHA_MODE_STRAIGHT + Straight = 2, + /// + /// D2D1_ALPHA_MODE_IGNORE + Ignore = 3, +} + +/// +/// D2D1_FIGURE_BEGIN +public enum FigureBegin : uint +{ + /// + /// D2D1_FIGURE_BEGIN_FILLED + Filled = 0, + /// + /// D2D1_FIGURE_BEGIN_HOLLOW + Hollow = 1, +} + +/// +/// D2D1_FIGURE_END +public enum FigureEnd : uint +{ + /// + /// D2D1_FIGURE_END_OPEN + Open = 0, + /// + /// D2D1_FIGURE_END_CLOSED + Closed = 1, +} + +/// +/// D2D1_PATH_SEGMENT +[Flags] +public enum PathSegment : uint +{ + /// + /// D2D1_PATH_SEGMENT_NONE + None = 0, + /// + /// D2D1_PATH_SEGMENT_FORCE_UNSTROKED + ForceUnstroked = 1, + /// + /// D2D1_PATH_SEGMENT_FORCE_ROUND_LINE_JOIN + ForceRoundLineJoin = 2, +} + +/// +/// D2D1_FILL_MODE +public enum FillMode : uint +{ + /// + /// D2D1_FILL_MODE_ALTERNATE + Alternate = 0, + /// + /// D2D1_FILL_MODE_WINDING + Winding = 1, +} + +/// +/// D2D1_BORDER_MODE +public enum BorderMode : uint +{ + /// + /// D2D1_BORDER_MODE_SOFT + Soft = 0, + /// + /// D2D1_BORDER_MODE_HARD + Hard = 1, +} + +/// +/// D2D1_BLEND_MODE +public enum BlendMode : uint +{ + /// + /// D2D1_BLEND_MODE_MULTIPLY + Multiply = 0, + /// + /// D2D1_BLEND_MODE_SCREEN + Screen = 1, + /// + /// D2D1_BLEND_MODE_DARKEN + Darken = 2, + /// + /// D2D1_BLEND_MODE_LIGHTEN + Lighten = 3, + /// + /// D2D1_BLEND_MODE_DISSOLVE + Dissolve = 4, + /// + /// D2D1_BLEND_MODE_COLOR_BURN + ColorBurn = 5, + /// + /// D2D1_BLEND_MODE_LINEAR_BURN + LinearBurn = 6, + /// + /// D2D1_BLEND_MODE_DARKER_COLOR + DarkerColor = 7, + /// + /// D2D1_BLEND_MODE_LIGHTER_COLOR + LighterColor = 8, + /// + /// D2D1_BLEND_MODE_COLOR_DODGE + ColorDodge = 9, + /// + /// D2D1_BLEND_MODE_LINEAR_DODGE + LinearDodge = 10, + /// + /// D2D1_BLEND_MODE_OVERLAY + Overlay = 11, + /// + /// D2D1_BLEND_MODE_SOFT_LIGHT + SoftLight = 12, + /// + /// D2D1_BLEND_MODE_HARD_LIGHT + HardLight = 13, + /// + /// D2D1_BLEND_MODE_VIVID_LIGHT + VividLight = 14, + /// + /// D2D1_BLEND_MODE_LINEAR_LIGHT + LinearLight = 15, + /// + /// D2D1_BLEND_MODE_PIN_LIGHT + PinLight = 16, + /// + /// D2D1_BLEND_MODE_HARD_MIX + HardMix = 17, + /// + /// D2D1_BLEND_MODE_DIFFERENCE + Difference = 18, + /// + /// D2D1_BLEND_MODE_EXCLUSION + Exclusion = 19, + /// + /// D2D1_BLEND_MODE_HUE + Hue = 20, + /// + /// D2D1_BLEND_MODE_SATURATION + Saturation = 21, + /// + /// D2D1_BLEND_MODE_COLOR + Color = 22, + /// + /// D2D1_BLEND_MODE_LUMINOSITY + Luminosity = 23, + /// + /// D2D1_BLEND_MODE_SUBTRACT + Subtract = 24, + /// + /// D2D1_BLEND_MODE_DIVISION + Division = 25, +} + +/// +/// D2D1_COLORMATRIX_ALPHA_MODE +public enum ColorMatrixAlphaMode : uint +{ + /// + /// D2D1_COLORMATRIX_ALPHA_MODE_PREMULTIPLIED + Premultiplied = 1, + /// + /// D2D1_COLORMATRIX_ALPHA_MODE_STRAIGHT + Straight = 2, +} + +/// +/// D2D1_TURBULENCE_NOISE +public enum TurbulenceNoise : uint +{ + /// + /// D2D1_TURBULENCE_NOISE_FRACTAL_SUM + FractalSum = 0, + /// + /// D2D1_TURBULENCE_NOISE_TURBULENCE + Turbulence = 1, +} + +/// +/// D2D1_COMPOSITE_MODE +public enum CompositeMode : uint +{ + /// + /// D2D1_COMPOSITE_MODE_SOURCE_OVER + SourceOver = 0, + /// + /// D2D1_COMPOSITE_MODE_DESTINATION_OVER + DestinationOver = 1, + /// + /// D2D1_COMPOSITE_MODE_SOURCE_IN + SourceIn = 2, + /// + /// D2D1_COMPOSITE_MODE_DESTINATION_IN + DestinationIn = 3, + /// + /// D2D1_COMPOSITE_MODE_SOURCE_OUT + SourceOut = 4, + /// + /// D2D1_COMPOSITE_MODE_DESTINATION_OUT + DestinationOut = 5, + /// + /// D2D1_COMPOSITE_MODE_SOURCE_ATOP + SourceAtop = 6, + /// + /// D2D1_COMPOSITE_MODE_DESTINATION_ATOP + DestinationAtop = 7, + /// + /// D2D1_COMPOSITE_MODE_XOR + Xor = 8, + /// + /// D2D1_COMPOSITE_MODE_PLUS + Plus = 9, + /// + /// D2D1_COMPOSITE_MODE_SOURCE_COPY + SourceCopy = 10, + /// + /// D2D1_COMPOSITE_MODE_BOUNDED_SOURCE_COPY + BoundedSourceCopy = 11, + /// + /// D2D1_COMPOSITE_MODE_MASK_INVERT + MaskInvert = 12, +} + +#endregion Enums + +#region Structs +/// +/// D2D1_COLOR_F +public partial struct ColorF +{ + /// + public float r; + + /// + public float g; + + /// + public float b; + + /// + public float a; +} + +/// +/// D2D1_PIXEL_FORMAT +public partial struct PixelFormat +{ + /// + public Graphics.Dxgi.Common.Format format; + + /// + public AlphaMode alphaMode; +} + +/// +/// D2D_POINT_2U +public partial struct Point2u +{ + /// + public uint x; + + /// + public uint y; +} + +/// +/// D2D_RECT_F +public partial struct RectF +{ + /// + public float left; + + /// + public float top; + + /// + public float right; + + /// + public float bottom; +} + +/// +/// D2D_RECT_U +public partial struct RectU +{ + /// + public uint left; + + /// + public uint top; + + /// + public uint right; + + /// + public uint bottom; +} + +/// +/// D2D_SIZE_U +public partial struct SizeU +{ + /// + public uint width; + + /// + public uint height; +} + +/// +/// D2D1_BEZIER_SEGMENT +public partial struct BezierSegment +{ + /// + public System.Drawing.PointF point1; + + /// + public System.Drawing.PointF point2; + + /// + public System.Drawing.PointF point3; +} + +#endregion Structs + +#region COM Types +/// +/// ID2D1SimplifiedGeometrySink +[Guid("2cd9069e-12e2-11dc-9fed-001143a055f9")] +[NativeTypeName("struct ID2D1SimplifiedGeometrySink : IUnknown")] +[NativeInheritance("IUnknown")] +public unsafe partial struct ID2D1SimplifiedGeometrySink +{ + public static ref readonly Guid IID_ID2D1SimplifiedGeometrySink + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get + { + ReadOnlySpan data = new byte[] { + 0x9E, 0x06, 0xD9, 0x2C, + 0xE2, 0x12, + 0xDC, 0x11, + 0x9F, + 0xED, + 0x00, + 0x11, + 0x43, + 0xA0, + 0x55, + 0xF9 + }; + + Debug.Assert(data.Length == Unsafe.SizeOf()); + return ref Unsafe.As(ref MemoryMarshal.GetReference(data)); + } + } + + public static Guid* NativeGuid => (Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in IID_ID2D1SimplifiedGeometrySink)); + + public void** lpVtbl; + + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [VtblIndex(0)] + public HResult QueryInterface([NativeTypeName("const IID &")] Guid* riid, void** ppvObject) + { + return ((delegate* unmanaged[Stdcall])(lpVtbl[0]))((IUnknown*)Unsafe.AsPointer(ref this), riid, ppvObject); + } + + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [VtblIndex(1)] + [return: NativeTypeName("ULONG")] + public uint AddRef() + { + return ((delegate* unmanaged[Stdcall])(lpVtbl[1]))((IUnknown*)Unsafe.AsPointer(ref this)); + } + + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [VtblIndex(2)] + [return: NativeTypeName("ULONG")] + public uint Release() + { + return ((delegate* unmanaged[Stdcall])(lpVtbl[2]))((IUnknown*)Unsafe.AsPointer(ref this)); + } + + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [VtblIndex(3)] + public void SetFillMode(FillMode fillMode) + { + ((delegate* unmanaged[Stdcall])(lpVtbl[3]))((ID2D1SimplifiedGeometrySink*)Unsafe.AsPointer(ref this), fillMode); + } + + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [VtblIndex(4)] + public void SetSegmentFlags(PathSegment vertexFlags) + { + ((delegate* unmanaged[Stdcall])(lpVtbl[4]))((ID2D1SimplifiedGeometrySink*)Unsafe.AsPointer(ref this), vertexFlags); + } + + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [VtblIndex(5)] + public void BeginFigure(System.Drawing.PointF* startPoint, FigureBegin figureBegin) + { + ((delegate* unmanaged[Stdcall])(lpVtbl[5]))((ID2D1SimplifiedGeometrySink*)Unsafe.AsPointer(ref this), startPoint, figureBegin); + } + + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [VtblIndex(6)] + public void AddLines(System.Drawing.PointF** points, uint pointsCount) + { + ((delegate* unmanaged[Stdcall])(lpVtbl[6]))((ID2D1SimplifiedGeometrySink*)Unsafe.AsPointer(ref this), points, pointsCount); + } + + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [VtblIndex(7)] + public void AddBeziers(BezierSegment* beziers, uint beziersCount) + { + ((delegate* unmanaged[Stdcall])(lpVtbl[7]))((ID2D1SimplifiedGeometrySink*)Unsafe.AsPointer(ref this), beziers, beziersCount); + } + + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [VtblIndex(8)] + public void EndFigure(FigureEnd figureEnd) + { + ((delegate* unmanaged[Stdcall])(lpVtbl[8]))((ID2D1SimplifiedGeometrySink*)Unsafe.AsPointer(ref this), figureEnd); + } + + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [VtblIndex(9)] + public HResult Close() + { + return ((delegate* unmanaged[Stdcall])(lpVtbl[9]))((ID2D1SimplifiedGeometrySink*)Unsafe.AsPointer(ref this)); + } + +} + +#endregion Com Types + diff --git a/src/Vortice.Win32/Generated/Graphics/Direct3D11.cs b/src/Vortice.Win32/Generated/Graphics/Direct3D11.cs index b73f914..4622a4d 100644 --- a/src/Vortice.Win32/Generated/Graphics/Direct3D11.cs +++ b/src/Vortice.Win32/Generated/Graphics/Direct3D11.cs @@ -6407,10 +6407,10 @@ public enum MessageId : int ReleasedecoderbufferNotlocked = 3145783, /// /// D3D11_MESSAGE_ID_DECODERBEGINFRAME_NULLPARAM - DecoderbeginframeNullParam = 3145784, + DecoderBeginFrameNullParam = 3145784, /// /// D3D11_MESSAGE_ID_DECODERBEGINFRAME_HAZARD - DecoderbeginframeHazard = 3145785, + DecoderBeginFrameHazard = 3145785, /// /// D3D11_MESSAGE_ID_DECODERENDFRAME_NULLPARAM DecoderendframeNullParam = 3145786, @@ -7370,7 +7370,7 @@ public enum MessageId : int Videoprocessorgetstreamcolorspace1NullParam = 3146104, /// /// D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMMIRROR_NULLPARAM - VideoprocessorgetstreammirrorNullParam = 3146105, + VideoProcessorGetStreamMirrorNullParam = 3146105, /// /// D3D11_MESSAGE_ID_RECOMMENDVIDEODECODERDOWNSAMPLING_NULLPARAM RecommendvideodecoderdownsamplingNullParam = 3146106, @@ -7553,7 +7553,7 @@ public enum MessageId : int JpegDecodeNotSupported = 3146169, /// /// D3D11_MESSAGE_ID_JPEGDECODE_DIMENSIONSTOOLARGE - JpegDecodeDimensionstoolarge = 3146170, + JpegDecodeDimensionsTooLarge = 3146170, /// /// D3D11_MESSAGE_ID_JPEGDECODE_INVALIDCOMPONENTS JpegDecodeInvalidComponents = 3146171, @@ -7574,7 +7574,7 @@ public enum MessageId : int JpegDecodeInvalidSubresource = 3146176, /// /// D3D11_MESSAGE_ID_JPEGDECODE_INVALIDMIPLEVEL - JpegDecodeInvalidmiplevel = 3146177, + JpegDecodeInvalidMipLevel = 3146177, /// /// D3D11_MESSAGE_ID_JPEGDECODE_EMPTYDESTBOX JpegDecodeEmptydestbox = 3146178, @@ -7649,7 +7649,7 @@ public enum MessageId : int JpegDecodeUnsupporteddsttextureusage = 3146201, /// /// D3D11_MESSAGE_ID_JPEGDECODE_BACKBUFFERNOTSUPPORTED - JpegDecodeBackbuffernotsupported = 3146202, + JpegDecodeBackbufferNotSupported = 3146202, /// /// D3D11_MESSAGE_ID_JPEGDECODE_UNSUPPRTEDCOPYFLAGS JpegDecodeUnsupprtedcopyflags = 3146203, @@ -7685,10 +7685,10 @@ public enum MessageId : int JpegEncodeInvalidSubresource = 3146213, /// /// D3D11_MESSAGE_ID_JPEGENCODE_INVALIDMIPLEVEL - JpegEncodeInvalidmiplevel = 3146214, + JpegEncodeInvalidMipLevel = 3146214, /// /// D3D11_MESSAGE_ID_JPEGENCODE_DIMENSIONSTOOLARGE - JpegEncodeDimensionstoolarge = 3146215, + JpegEncodeDimensionsTooLarge = 3146215, /// /// D3D11_MESSAGE_ID_JPEGENCODE_HAZARD JpegEncodeHazard = 3146216, @@ -7703,7 +7703,7 @@ public enum MessageId : int JpegEncodeUnsupportedsrctextureusage = 3146219, /// /// D3D11_MESSAGE_ID_JPEGENCODE_BACKBUFFERNOTSUPPORTED - JpegEncodeBackbuffernotsupported = 3146220, + JpegEncodeBackbufferNotSupported = 3146220, /// /// D3D11_MESSAGE_ID_CREATEQUERYORPREDICATE_UNSUPPORTEDCONTEXTTTYPEFORQUERY CreateQueryOrPredicateUnsupportedcontextttypeforquery = 3146221, @@ -7787,7 +7787,7 @@ public enum MessageId : int Videoprocessorgetstreamcolorspace1InvalidStream = 3146247, /// /// D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMMIRROR_INVALIDSTREAM - VideoprocessorgetstreammirrorInvalidStream = 3146248, + VideoProcessorGetStreamMirrorInvalidStream = 3146248, /// /// D3D11_MESSAGE_ID_CREATE_FENCE CreateFence = 3146249, @@ -7799,13 +7799,13 @@ public enum MessageId : int DestroyFence = 3146251, /// /// D3D11_MESSAGE_ID_CREATE_SYNCHRONIZEDCHANNEL - CreateSynchronizedchannel = 3146252, + CreateSynchronizedChannel = 3146252, /// /// D3D11_MESSAGE_ID_LIVE_SYNCHRONIZEDCHANNEL - LiveSynchronizedchannel = 3146253, + LiveSynchronizedChannel = 3146253, /// /// D3D11_MESSAGE_ID_DESTROY_SYNCHRONIZEDCHANNEL - DestroySynchronizedchannel = 3146254, + DestroySynchronizedChannel = 3146254, /// /// D3D11_MESSAGE_ID_CREATEFENCE_INVALIDFLAGS CreateFenceInvalidFlags = 3146255, @@ -7817,22 +7817,22 @@ public enum MessageId : int NegotiatecryptosessionkeyexchangemtNotSupported = 3146259, /// /// D3D11_MESSAGE_ID_DECODERBEGINFRAME_INVALID_HISTOGRAM_COMPONENT_COUNT - DecoderbeginframeInvalidHistogramComponentCount = 3146260, + DecoderBeginFrameInvalidHistogramComponentCount = 3146260, /// /// D3D11_MESSAGE_ID_DECODERBEGINFRAME_INVALID_HISTOGRAM_COMPONENT - DecoderbeginframeInvalidHistogramComponent = 3146261, + DecoderBeginFrameInvalidHistogramComponent = 3146261, /// /// D3D11_MESSAGE_ID_DECODERBEGINFRAME_INVALID_HISTOGRAM_BUFFER_SIZE - DecoderbeginframeInvalidHistogramBufferSize = 3146262, + DecoderBeginFrameInvalidHistogramBufferSize = 3146262, /// /// D3D11_MESSAGE_ID_DECODERBEGINFRAME_INVALID_HISTOGRAM_BUFFER_USAGE - DecoderbeginframeInvalidHistogramBufferUsage = 3146263, + DecoderBeginFrameInvalidHistogramBufferUsage = 3146263, /// /// D3D11_MESSAGE_ID_DECODERBEGINFRAME_INVALID_HISTOGRAM_BUFFER_MISC_FLAGS - DecoderbeginframeInvalidHistogramBufferMiscFlags = 3146264, + DecoderBeginFrameInvalidHistogramBufferMiscFlags = 3146264, /// /// D3D11_MESSAGE_ID_DECODERBEGINFRAME_INVALID_HISTOGRAM_BUFFER_OFFSET - DecoderbeginframeInvalidHistogramBufferOffset = 3146265, + DecoderBeginFrameInvalidHistogramBufferOffset = 3146265, /// /// D3D11_MESSAGE_ID_CREATE_TRACKEDWORKLOAD CreateTrackedworkload = 3146266, @@ -8571,7 +8571,7 @@ public partial struct Box /// /// D3D11_DEPTH_STENCILOP_DESC -public partial struct DepthStencilopDescription +public partial struct DepthStencilOpDescription { /// public StencilOp StencilFailOp; @@ -8609,10 +8609,10 @@ public partial struct DepthStencilDescription public byte StencilWriteMask; /// - public DepthStencilopDescription FrontFace; + public DepthStencilOpDescription FrontFace; /// - public DepthStencilopDescription BackFace; + public DepthStencilOpDescription BackFace; } /// diff --git a/src/Vortice.Win32/Generated/Graphics/Direct3D12.cs b/src/Vortice.Win32/Generated/Graphics/Direct3D12.cs index 45fa796..9e5e54c 100644 --- a/src/Vortice.Win32/Generated/Graphics/Direct3D12.cs +++ b/src/Vortice.Win32/Generated/Graphics/Direct3D12.cs @@ -7043,7 +7043,7 @@ public partial struct Box /// /// D3D12_DEPTH_STENCILOP_DESC -public partial struct DepthStencilopDescription +public partial struct DepthStencilOpDescription { /// public StencilOp StencilFailOp; @@ -7081,10 +7081,10 @@ public partial struct DepthStencilDescription public byte StencilWriteMask; /// - public DepthStencilopDescription FrontFace; + public DepthStencilOpDescription FrontFace; /// - public DepthStencilopDescription BackFace; + public DepthStencilOpDescription BackFace; } /// @@ -7110,10 +7110,10 @@ public partial struct DepthStencilDescription1 public byte StencilWriteMask; /// - public DepthStencilopDescription FrontFace; + public DepthStencilOpDescription FrontFace; /// - public DepthStencilopDescription BackFace; + public DepthStencilOpDescription BackFace; /// public Bool32 DepthBoundsTestEnable; diff --git a/src/Vortice.Win32/Graphics/Direct2D/Matrix4x3.cs b/src/Vortice.Win32/Graphics/Direct2D/Matrix4x3.cs new file mode 100644 index 0000000..7a9ae0b --- /dev/null +++ b/src/Vortice.Win32/Graphics/Direct2D/Matrix4x3.cs @@ -0,0 +1,198 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +using System.Globalization; +using System.Text; + +namespace Win32.Graphics.Direct2D.Common; + +/// +/// Describes a 4-by-3 floating point matrix. +/// +[StructLayout(LayoutKind.Sequential, Pack = 4)] +public readonly struct Matrix4x3 : IEquatable, IFormattable +{ + /// + /// Value at row 1 column 1. + /// + public readonly float M11; + + /// + /// Value at row 1 column 2. + /// + public readonly float M12; + + /// + /// Value at row 1 column 3. + /// + public readonly float M13; + + /// + /// Value at row 2 column 1. + /// + public readonly float M21; + + /// + /// Value at row 2 column 2. + /// + public readonly float M22; + + /// + /// Value at row 2 column 3. + /// + public readonly float M23; + + /// + /// Value at row 3 column 1. + /// + public readonly float M31; + + /// + /// Value at row 3 column 2. + /// + public readonly float M32; + + /// + /// Value at row 3 column 3. + /// + public readonly float M33; + + /// + /// Value at row 4 column 1. + /// + public readonly float M41; + + /// + /// Value at row 4 column 2. + /// + public readonly float M42; + + /// + /// Value at row 4 column 3. + /// + public readonly float M43; + + /// + /// Initializes a new instance of the struct. + /// + /// The value that will be assigned to all components. + public Matrix4x3(float value) + { + M11 = M12 = M13 = + M21 = M22 = M23 = + M31 = M32 = M33 = + M41 = M42 = M43 = value; + } + + /// + /// Initializes a new instance of the struct. + /// + /// The value to assign at row 1 column 1 of the Matrix4x3. + /// The value to assign at row 1 column 2 of the Matrix4x3. + /// The value to assign at row 1 column 3 of the Matrix4x3. + /// The value to assign at row 2 column 1 of the Matrix4x3. + /// The value to assign at row 2 column 2 of the Matrix4x3. + /// The value to assign at row 2 column 3 of the Matrix4x3. + /// The value to assign at row 3 column 1 of the Matrix4x3. + /// The value to assign at row 3 column 2 of the Matrix4x3. + /// The value to assign at row 3 column 3 of the Matrix4x3. + /// The value to assign at row 4 column 1 of the Matrix4x3. + /// The value to assign at row 4 column 2 of the Matrix4x3. + /// The value to assign at row 4 column 3 of the Matrix4x3. + public Matrix4x3( + float m11, float m12, float m13, + float m21, float m22, float m23, + float m31, float m32, float m33, + float m41, float m42, float m43) + { + M11 = m11; M12 = m12; M13 = m13; + M21 = m21; M22 = m22; M23 = m23; + M31 = m31; M32 = m32; M33 = m33; + M41 = m41; M42 = m42; M43 = m43; + } + + /// + /// Compares two objects for equality. + /// + /// The on the left hand of the operand. + /// The on the right hand of the operand. + /// + /// True if the current left is equal to the parameter; otherwise, false. + /// + public static bool operator ==(Matrix4x3 left, Matrix4x3 right) + { + return (left.M11 == right.M11) && (left.M12 == right.M12) && (left.M13 == right.M13) + && (left.M21 == right.M21) && (left.M22 == right.M22) && (left.M23 == right.M23) + && (left.M31 == right.M31) && (left.M32 == right.M32) && (left.M33 == right.M33) + && (left.M41 == right.M41) && (left.M42 == right.M42) && (left.M43 == right.M43); + } + + /// + /// Compares two objects for inequality. + /// + /// The on the left hand of the operand. + /// The on the right hand of the operand. + /// + /// True if the current left is unequal to the parameter; otherwise, false. + /// + public static bool operator !=(Matrix4x3 left, Matrix4x3 right) + { + return (left.M11 != right.M11) || (left.M12 != right.M12) || (left.M13 != right.M13) + || (left.M21 != right.M21) || (left.M22 != right.M22) || (left.M23 != right.M23) + || (left.M31 != right.M31) || (left.M32 != right.M32) || (left.M33 != right.M33) + || (left.M41 != right.M41) || (left.M42 != right.M42) || (left.M43 != right.M43); + } + + /// + public override bool Equals(object? obj) => (obj is Matrix4x3 other) && Equals(other); + + /// + public bool Equals(Matrix4x3 other) => this == other; + + /// + public override int GetHashCode() + { + var hashCode = new HashCode(); + { + hashCode.Add(M11); + hashCode.Add(M12); + hashCode.Add(M13); + hashCode.Add(M21); + hashCode.Add(M22); + hashCode.Add(M23); + hashCode.Add(M31); + hashCode.Add(M32); + hashCode.Add(M33); + hashCode.Add(M41); + hashCode.Add(M42); + hashCode.Add(M43); + } + return hashCode.ToHashCode(); + } + + /// + public override string ToString() => ToString(format: null, formatProvider: null); + + /// + public string ToString(string? format, IFormatProvider? formatProvider) + { + var separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator; + + return new StringBuilder() + .Append('<') + .Append(M11.ToString(format, formatProvider)).Append(separator).Append(' ') + .Append(M12.ToString(format, formatProvider)).Append(separator).Append(' ') + .Append(M13.ToString(format, formatProvider)).Append(separator).Append(' ') + .Append(M21.ToString(format, formatProvider)).Append(separator).Append(' ') + .Append(M22.ToString(format, formatProvider)).Append(separator).Append(' ') + .Append(M23.ToString(format, formatProvider)).Append(separator).Append(' ') + .Append(M31.ToString(format, formatProvider)).Append(separator).Append(' ') + .Append(M32.ToString(format, formatProvider)).Append(separator).Append(' ') + .Append(M33.ToString(format, formatProvider)).Append(separator).Append(' ') + .Append(M41.ToString(format, formatProvider)).Append(separator).Append(' ') + .Append(M42.ToString(format, formatProvider)).Append(separator).Append(' ') + .Append(M43.ToString(format, formatProvider)) + .Append('>') + .ToString(); + } +} diff --git a/src/Vortice.Win32/Graphics/Direct2D/Matrix5x4.cs b/src/Vortice.Win32/Graphics/Direct2D/Matrix5x4.cs new file mode 100644 index 0000000..b27910b --- /dev/null +++ b/src/Vortice.Win32/Graphics/Direct2D/Matrix5x4.cs @@ -0,0 +1,217 @@ +// Copyright © Amer Koleci and Contributors. +// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. + +using System.Globalization; +using System.Text; + +namespace Win32.Graphics.Direct2D.Common; + +/// +/// Describes a 5-by-4 floating point matrix. +/// +[StructLayout(LayoutKind.Sequential, Pack = 4)] +public readonly struct Matrix5x4 : IEquatable, IFormattable +{ + /// + /// Value at row 1 column 1. + /// + public readonly float M11; + + /// + /// Value at row 1 column 2. + /// + public readonly float M12; + + /// + /// Value at row 1 column 3. + /// + public readonly float M13; + + /// + /// Value at row 1 column 4. + /// + public readonly float M14; + + /// + /// Value at row 2 column 1. + /// + public readonly float M21; + + /// + /// Value at row 2 column 2. + /// + public readonly float M22; + + /// + /// Value at row 2 column 3. + /// + public readonly float M23; + + /// + /// Value at row 2 column 4. + /// + public readonly float M24; + + /// + /// Value at row 3 column 1. + /// + public readonly float M31; + + /// + /// Value at row 3 column 2. + /// + public readonly float M32; + + /// + /// Value at row 3 column 3. + /// + public readonly float M33; + + /// + /// Value at row 3 column 4. + /// + public readonly float M34; + + /// + /// Value at row 4 column 1. + /// + public readonly float M41; + + /// + /// Value at row 4 column 2. + /// + public readonly float M42; + + /// + /// Value at row 4 column 3. + /// + public readonly float M43; + + /// + /// Value at row 4 column 4. + /// + public readonly float M44; + + /// + /// Value at row 5 column 1. + /// + public readonly float M51; + + /// + /// Value at row 5 column 2. + /// + public readonly float M52; + + /// + /// Value at row 5 column 3. + /// + public readonly float M53; + + /// + /// Value at row 5 column 4. + /// + public readonly float M54; + + /// + /// Compares two objects for equality. + /// + /// The on the left hand of the operand. + /// The on the right hand of the operand. + /// + /// True if the current left is equal to the parameter; otherwise, false. + /// + public static bool operator ==(Matrix5x4 left, Matrix5x4 right) + { + return (left.M11 == right.M11) && (left.M12 == right.M12) && (left.M13 == right.M13) && (left.M14 == right.M14) + && (left.M21 == right.M21) && (left.M22 == right.M22) && (left.M23 == right.M23) && (left.M24 == right.M24) + && (left.M31 == right.M31) && (left.M32 == right.M32) && (left.M33 == right.M33) && (left.M34 == right.M34) + && (left.M41 == right.M41) && (left.M42 == right.M42) && (left.M43 == right.M43) && (left.M44 == right.M44) + && (left.M51 == right.M51) && (left.M52 == right.M52) && (left.M53 == right.M53) && (left.M54 == right.M54); + } + + /// + /// Compares two objects for inequality. + /// + /// The on the left hand of the operand. + /// The on the right hand of the operand. + /// + /// True if the current left is unequal to the parameter; otherwise, false. + /// + public static bool operator !=(Matrix5x4 left, Matrix5x4 right) + { + return (left.M11 != right.M11) || (left.M12 != right.M12) || (left.M13 != right.M13) || (left.M14 != right.M14) + || (left.M21 != right.M21) || (left.M22 != right.M22) || (left.M23 != right.M23) || (left.M24 != right.M24) + || (left.M31 != right.M31) || (left.M32 != right.M32) || (left.M33 != right.M33) || (left.M34 != right.M34) + || (left.M41 != right.M41) || (left.M42 != right.M42) || (left.M43 != right.M43) || (left.M44 != right.M44) + || (left.M51 != right.M51) || (left.M52 != right.M52) || (left.M53 != right.M53) || (left.M54 != right.M54); + } + + /// + public override bool Equals(object? obj) => (obj is Matrix5x4 other) && Equals(other); + + /// + public bool Equals(Matrix5x4 other) => this == other; + + /// + public override int GetHashCode() + { + var hashCode = new HashCode(); + { + hashCode.Add(M11); + hashCode.Add(M12); + hashCode.Add(M13); + hashCode.Add(M14); + hashCode.Add(M21); + hashCode.Add(M22); + hashCode.Add(M23); + hashCode.Add(M24); + hashCode.Add(M31); + hashCode.Add(M32); + hashCode.Add(M33); + hashCode.Add(M34); + hashCode.Add(M41); + hashCode.Add(M42); + hashCode.Add(M43); + hashCode.Add(M44); + hashCode.Add(M51); + hashCode.Add(M52); + hashCode.Add(M53); + hashCode.Add(M54); + } + return hashCode.ToHashCode(); + } + + /// + public override string ToString() => ToString(format: null, formatProvider: null); + + /// + public string ToString(string? format, IFormatProvider? formatProvider) + { + var separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator; + + return new StringBuilder() + .Append('<') + .Append(M11.ToString(format, formatProvider)).Append(separator).Append(' ') + .Append(M12.ToString(format, formatProvider)).Append(separator).Append(' ') + .Append(M13.ToString(format, formatProvider)).Append(separator).Append(' ') + .Append(M14.ToString(format, formatProvider)).Append(separator).Append(' ') + .Append(M21.ToString(format, formatProvider)).Append(separator).Append(' ') + .Append(M22.ToString(format, formatProvider)).Append(separator).Append(' ') + .Append(M23.ToString(format, formatProvider)).Append(separator).Append(' ') + .Append(M24.ToString(format, formatProvider)).Append(separator).Append(' ') + .Append(M31.ToString(format, formatProvider)).Append(separator).Append(' ') + .Append(M32.ToString(format, formatProvider)).Append(separator).Append(' ') + .Append(M33.ToString(format, formatProvider)).Append(separator).Append(' ') + .Append(M34.ToString(format, formatProvider)).Append(separator).Append(' ') + .Append(M41.ToString(format, formatProvider)).Append(separator).Append(' ') + .Append(M42.ToString(format, formatProvider)).Append(separator).Append(' ') + .Append(M43.ToString(format, formatProvider)).Append(separator).Append(' ') + .Append(M44.ToString(format, formatProvider)).Append(separator).Append(' ') + .Append(M51.ToString(format, formatProvider)).Append(separator).Append(' ') + .Append(M52.ToString(format, formatProvider)).Append(separator).Append(' ') + .Append(M53.ToString(format, formatProvider)).Append(separator).Append(' ') + .Append(M54.ToString(format, formatProvider)) + .Append('>') + .ToString(); + } +} diff --git a/src/Vortice.Win32/Graphics/Direct2D/PixelFormat.cs b/src/Vortice.Win32/Graphics/Direct2D/PixelFormat.cs new file mode 100644 index 0000000..c39184e --- /dev/null +++ b/src/Vortice.Win32/Graphics/Direct2D/PixelFormat.cs @@ -0,0 +1,30 @@ +// 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.Direct2D.Common; + +public partial struct PixelFormat +{ + /// + /// An unkown with to and to . + /// + public static readonly PixelFormat Unknown = new(Format.Unknown, AlphaMode.Unknown); + + /// + /// A Premultiplied with to and to . + /// + public static readonly PixelFormat Premultiplied = new(Format.Unknown, AlphaMode.Premultiplied); + + /// + /// Initializes a new instance of the struct. + /// + /// The to use. + /// A value that specifies whether the alpha channel is using pre-multiplied alpha, straight alpha, whether it should be ignored and considered opaque, or whether it is unknown. + public PixelFormat(Format format, AlphaMode alphaMode) + { + this.format = format; + this.alphaMode = alphaMode; + } +} diff --git a/src/Vortice.Win32/Graphics/Direct3D11/BufferDescription.cs b/src/Vortice.Win32/Graphics/Direct3D11/BufferDescription.cs new file mode 100644 index 0000000..796df76 --- /dev/null +++ b/src/Vortice.Win32/Graphics/Direct3D11/BufferDescription.cs @@ -0,0 +1,31 @@ +// 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 BufferDescription +{ + /// + /// Initializes a new instance of the struct. + /// + /// The size in bytes. + /// The bind flags. + /// The usage. + /// The CPU access flags. + /// The option flags. + /// The structure byte stride. + public BufferDescription(uint byteWidth, + BindFlags bindFlags, + Usage usage = Usage.Default, + CpuAccessFlags cpuAccessFlags = CpuAccessFlags.None, + ResourceMiscFlags miscFlags = ResourceMiscFlags.None, + uint structureByteStride = 0) + { + ByteWidth = byteWidth; + BindFlags = bindFlags; + Usage = usage; + CPUAccessFlags = cpuAccessFlags; + MiscFlags = miscFlags; + StructureByteStride = structureByteStride; + } +} diff --git a/src/Vortice.Win32/Graphics/Direct3D11/DepthStencilDescription.cs b/src/Vortice.Win32/Graphics/Direct3D11/DepthStencilDescription.cs new file mode 100644 index 0000000..5d4b8e5 --- /dev/null +++ b/src/Vortice.Win32/Graphics/Direct3D11/DepthStencilDescription.cs @@ -0,0 +1,101 @@ +// 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 DepthStencilDescription +{ + /// + /// A built-in description with settings for not using a depth stencil buffer. + /// + public static readonly DepthStencilDescription None = new(false, DepthWriteMask.Zero); + + /// + /// A built-in description with default settings for using a depth stencil buffer. + /// + public static readonly DepthStencilDescription Default = new(true, DepthWriteMask.All); + + /// + /// A built-in description with settings for enabling a read-only depth stencil buffer. + /// + public static readonly DepthStencilDescription DepthRead = new(true, DepthWriteMask.Zero); + + /// + /// A built-in description with settings for using a reverse depth stencil buffer. + /// + public static readonly DepthStencilDescription DepthReverseZ = new(true, DepthWriteMask.All, ComparisonFunc.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); + + /// + /// Initializes a new instance of the struct. + /// + /// 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) + { + DepthEnable = depthEnable; + DepthWriteMask = depthWriteMask; + DepthFunc = depthFunc; + StencilEnable = false; + StencilReadMask = (byte)D3D11_DEFAULT_STENCIL_READ_MASK; + StencilWriteMask = (byte)D3D11_DEFAULT_STENCIL_WRITE_MASK; + FrontFace = DepthStencilOpDescription.Default; + BackFace = DepthStencilOpDescription.Default; + } + + /// + /// Initializes a new instance of the struct. + /// + /// Specifies whether to enable depth testing. Set this member to true to enable depth testing. + /// Specifies a value that identifies a portion of the depth-stencil buffer that can be modified by depth data. + /// A value that identifies a function that compares depth data against existing depth data. + /// Specifies whether to enable stencil testing. Set this member to true to enable stencil testing. + /// Identify a portion of the depth-stencil buffer for reading stencil data. + /// Identify a portion of the depth-stencil buffer for writing stencil data. + /// + /// + /// + /// + /// + /// + /// + /// + public DepthStencilDescription( + bool depthEnable, + bool depthWriteEnable, + ComparisonFunc depthFunc, + bool stencilEnable, + byte stencilReadMask, + byte stencilWriteMask, + StencilOp frontStencilFailOp, + StencilOp frontStencilDepthFailOp, + StencilOp frontStencilPassOp, + ComparisonFunc frontStencilFunc, + StencilOp backStencilFailOp, + StencilOp backStencilDepthFailOp, + StencilOp backStencilPassOp, + ComparisonFunc backStencilFunc) + { + DepthEnable = depthEnable; + DepthWriteMask = depthWriteEnable ? DepthWriteMask.All : DepthWriteMask.Zero; + DepthFunc = depthFunc; + StencilEnable = stencilEnable; + StencilReadMask = stencilReadMask; + StencilWriteMask = stencilWriteMask; + FrontFace.StencilFailOp = frontStencilFailOp; + FrontFace.StencilDepthFailOp = frontStencilDepthFailOp; + FrontFace.StencilPassOp = frontStencilPassOp; + FrontFace.StencilFunc = frontStencilFunc; + BackFace.StencilFailOp = backStencilFailOp; + BackFace.StencilDepthFailOp = backStencilDepthFailOp; + BackFace.StencilPassOp = backStencilPassOp; + BackFace.StencilFunc = backStencilFunc; + } +} diff --git a/src/Vortice.Win32/Graphics/Direct3D11/DepthStencilOpDescription.cs b/src/Vortice.Win32/Graphics/Direct3D11/DepthStencilOpDescription.cs new file mode 100644 index 0000000..3ebf254 --- /dev/null +++ b/src/Vortice.Win32/Graphics/Direct3D11/DepthStencilOpDescription.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 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/ShaderResourceViewDescription.cs b/src/Vortice.Win32/Graphics/Direct3D11/ShaderResourceViewDescription.cs new file mode 100644 index 0000000..d6038e5 --- /dev/null +++ b/src/Vortice.Win32/Graphics/Direct3D11/ShaderResourceViewDescription.cs @@ -0,0 +1,266 @@ +// 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; + +namespace Win32.Graphics.Direct3D11; + +public unsafe partial struct ShaderResourceViewDescription +{ + /// + /// Initializes a new instance of the struct. + /// + /// The + /// The to use or . + /// Index of the most detailed mipmap level to use or first element for or . + /// The maximum number of mipmap levels for the view of the texture or num elements for or . + /// The index of the first texture to use in an array of textures or First2DArrayFace for . + /// Number of textures in the array or num cubes for . + /// for . + public ShaderResourceViewDescription( + SrvDimension viewDimension, + Format format = Format.Unknown, + uint mostDetailedMip = 0, + uint mipLevels = unchecked((uint)-1), + uint firstArraySlice = 0, + uint arraySize = unchecked((uint)-1), + BufferExtendedSrvFlags flags = BufferExtendedSrvFlags.None) + { + Format = format; + ViewDimension = viewDimension; + Anonymous = default; + + switch (viewDimension) + { + case SrvDimension.Buffer: + Anonymous.Buffer.FirstElement = mostDetailedMip; + Anonymous.Buffer.NumElements = mipLevels; + break; + case SrvDimension.Texture1D: + Anonymous.Texture1D.MostDetailedMip = mostDetailedMip; + Anonymous.Texture1D.MipLevels = mipLevels; + break; + case SrvDimension.Texture1DArray: + Anonymous.Texture1DArray.MostDetailedMip = mostDetailedMip; + Anonymous.Texture1DArray.MipLevels = mipLevels; + Anonymous.Texture1DArray.FirstArraySlice = firstArraySlice; + Anonymous.Texture1DArray.ArraySize = arraySize; + break; + case SrvDimension.Texture2D: + Anonymous.Texture2D.MostDetailedMip = mostDetailedMip; + Anonymous.Texture2D.MipLevels = mipLevels; + break; + case SrvDimension.Texture2DArray: + Anonymous.Texture2DArray.MostDetailedMip = mostDetailedMip; + Anonymous.Texture2DArray.MipLevels = mipLevels; + Anonymous.Texture2DArray.FirstArraySlice = firstArraySlice; + Anonymous.Texture2DArray.ArraySize = arraySize; + break; + case SrvDimension.Texture2DMs: + break; + case SrvDimension.Texture2DMsArray: + Anonymous.Texture2DMSArray.FirstArraySlice = firstArraySlice; + Anonymous.Texture2DMSArray.ArraySize = arraySize; + break; + case SrvDimension.Texture3D: + Anonymous.Texture3D.MostDetailedMip = mostDetailedMip; + Anonymous.Texture3D.MipLevels = mipLevels; + break; + case SrvDimension.TextureCube: + Anonymous.TextureCube.MostDetailedMip = mostDetailedMip; + Anonymous.TextureCube.MipLevels = mipLevels; + break; + case SrvDimension.TextureCubeArray: + Anonymous.TextureCubeArray.MostDetailedMip = mostDetailedMip; + Anonymous.TextureCubeArray.MipLevels = mipLevels; + Anonymous.TextureCubeArray.First2DArrayFace = firstArraySlice; + Anonymous.TextureCubeArray.NumCubes = arraySize; + break; + case SrvDimension.BufferExtended: + Anonymous.BufferEx.FirstElement = mostDetailedMip; + Anonymous.BufferEx.NumElements = mipLevels; + BufferEx.Flags = flags; + break; + default: + break; + } + } + + /// + /// Initializes a new instance of the struct. + /// + /// Unused + /// + /// + /// + /// + public ShaderResourceViewDescription( + ID3D11Buffer* buffer, + Format format, + uint firstElement, + uint numElements, + BufferExtendedSrvFlags flags = BufferExtendedSrvFlags.None) + { + Format = format; + ViewDimension = SrvDimension.BufferExtended; + + Anonymous = default; + Anonymous.BufferEx.FirstElement = firstElement; + Anonymous.BufferEx.NumElements = numElements; + Anonymous.BufferEx.Flags = flags; + } + + public ShaderResourceViewDescription( + ID3D11Texture1D* texture, + bool isArray, + Format format = Format.Unknown, + uint mostDetailedMip = 0, + uint mipLevels = unchecked((uint)-1), + uint firstArraySlice = 0, + uint arraySize = unchecked((uint)-1)) + { + ViewDimension = isArray ? SrvDimension.Texture1DArray : SrvDimension.Texture1D; + if (format == Format.Unknown + || mipLevels == unchecked((uint)-1) + || (arraySize == unchecked((uint)-1) && SrvDimension.Texture1DArray == ViewDimension)) + { + Texture1DDescription textureDesc; + texture->GetDesc(&textureDesc); + + if (format == Format.Unknown) + format = textureDesc.Format; + if (mipLevels == unchecked((uint)-1)) + mipLevels = textureDesc.MipLevels - mostDetailedMip; + if (arraySize == unchecked((uint)-1)) + arraySize = textureDesc.ArraySize - firstArraySlice; + } + + Format = format; + Anonymous = default; + + switch (ViewDimension) + { + case SrvDimension.Texture1D: + Anonymous.Texture1D.MostDetailedMip = mostDetailedMip; + Anonymous.Texture1D.MipLevels = mipLevels; + break; + case SrvDimension.Texture1DArray: + Anonymous.Texture1DArray.MostDetailedMip = mostDetailedMip; + Anonymous.Texture1DArray.MipLevels = mipLevels; + Anonymous.Texture1DArray.FirstArraySlice = firstArraySlice; + Anonymous.Texture1DArray.ArraySize = arraySize; + break; + default: + break; + } + } + + /// + /// Initializes a new instance of the struct. + /// + /// + /// + /// + /// + /// + /// + /// + public ShaderResourceViewDescription( + ID3D11Texture2D* texture, + SrvDimension viewDimension, + Format format = Format.Unknown, + uint mostDetailedMip = 0, + uint mipLevels = unchecked((uint)-1), + uint firstArraySlice = 0, + uint arraySize = unchecked((uint)-1)) + { + ViewDimension = viewDimension; + if (format == Format.Unknown + || (mipLevels == unchecked((uint)-1) && viewDimension != SrvDimension.Texture2DMs && viewDimension != SrvDimension.Texture2DMsArray) + || (arraySize == unchecked((uint)-1) && (SrvDimension.Texture2DArray == viewDimension || SrvDimension.Texture2DMsArray == viewDimension || SrvDimension.TextureCubeArray == viewDimension))) + { + Texture2DDescription textureDesc; + texture->GetDesc(&textureDesc); + + if (format == Format.Unknown) + format = textureDesc.Format; + if (unchecked((uint)-1) == mipLevels) + mipLevels = textureDesc.MipLevels - mostDetailedMip; + if (unchecked((uint)-1) == arraySize) + { + arraySize = textureDesc.ArraySize - firstArraySlice; + if (viewDimension == SrvDimension.TextureCubeArray) + arraySize /= 6; + } + } + + Format = format; + Anonymous = default; + + switch (viewDimension) + { + case SrvDimension.Texture2D: + Anonymous.Texture2D.MostDetailedMip = mostDetailedMip; + Anonymous.Texture2D.MipLevels = mipLevels; + break; + case SrvDimension.Texture2DArray: + Anonymous.Texture2DArray.MostDetailedMip = mostDetailedMip; + Anonymous.Texture2DArray.MipLevels = mipLevels; + Anonymous.Texture2DArray.FirstArraySlice = firstArraySlice; + Anonymous.Texture2DArray.ArraySize = arraySize; + break; + case SrvDimension.Texture2DMs: + break; + case SrvDimension.Texture2DMsArray: + Anonymous.Texture2DMSArray.FirstArraySlice = firstArraySlice; + Anonymous.Texture2DMSArray.ArraySize = arraySize; + break; + case SrvDimension.TextureCube: + Anonymous.TextureCube.MostDetailedMip = mostDetailedMip; + Anonymous.TextureCube.MipLevels = mipLevels; + break; + case SrvDimension.TextureCubeArray: + Anonymous.TextureCubeArray.MostDetailedMip = mostDetailedMip; + Anonymous.TextureCubeArray.MipLevels = mipLevels; + Anonymous.TextureCubeArray.First2DArrayFace = firstArraySlice; + Anonymous.TextureCubeArray.NumCubes = arraySize; + break; + default: + break; + } + } + + /// + /// Initializes a new instance of the struct. + /// + /// + /// + /// + /// + public ShaderResourceViewDescription( + ID3D11Texture3D* texture, + Format format = Format.Unknown, + uint mostDetailedMip = 0, + uint mipLevels = unchecked((uint)-1)) + { + ViewDimension = SrvDimension.Texture3D; + if (format == Format.Unknown || mipLevels == unchecked((uint)-1)) + { + Texture3DDescription textureDesc; + texture->GetDesc(&textureDesc); + + if (format == Format.Unknown) + format = textureDesc.Format; + if (mipLevels == unchecked((uint)-1)) + mipLevels = textureDesc.MipLevels - mostDetailedMip; + } + + Format = format; + Anonymous = default; + + Anonymous.Texture3D.MostDetailedMip = mostDetailedMip; + Anonymous.Texture3D.MipLevels = mipLevels; + } +} diff --git a/src/Vortice.Win32/Graphics/Direct3D11/UnorderedAccessViewDescription.cs b/src/Vortice.Win32/Graphics/Direct3D11/UnorderedAccessViewDescription.cs new file mode 100644 index 0000000..774278d --- /dev/null +++ b/src/Vortice.Win32/Graphics/Direct3D11/UnorderedAccessViewDescription.cs @@ -0,0 +1,217 @@ +// 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; + +public unsafe partial struct UnorderedAccessViewDescription +{ + /// + /// Initializes a new instance of the struct. + /// + /// The + /// The to use or . + /// The index of the mipmap level to use mip slice or FirstElement for BUFFER. + /// The index of the first texture to use in an array of textures or NumElements for BUFFER or FirstWSlice for TEXTURE3D. + /// Number of textures in the array or WSize for TEXTURE3D. + /// options flags for the resource. + public UnorderedAccessViewDescription( + UavDimension viewDimension, + Format format = Format.Unknown, + uint mipSlice = 0, + uint firstArraySlice = 0, + uint arraySize = unchecked((uint)-1), + BufferUavFlags flags = BufferUavFlags.None) + { + Format = format; + ViewDimension = viewDimension; + Anonymous = default; + + switch (viewDimension) + { + case UavDimension.Buffer: + Anonymous.Buffer.FirstElement = mipSlice; + Anonymous.Buffer.NumElements = firstArraySlice; + Anonymous.Buffer.Flags = flags; + break; + case UavDimension.Texture1D: + Anonymous.Texture1D.MipSlice = mipSlice; + break; + case UavDimension.Texture1DArray: + Anonymous.Texture1DArray.MipSlice = mipSlice; + Anonymous.Texture1DArray.FirstArraySlice = firstArraySlice; + Anonymous.Texture1DArray.ArraySize = arraySize; + break; + case UavDimension.Texture2D: + Anonymous.Texture2D.MipSlice = mipSlice; + break; + case UavDimension.Texture2DArray: + Anonymous.Texture2DArray.MipSlice = mipSlice; + Anonymous.Texture2DArray.FirstArraySlice = firstArraySlice; + Anonymous.Texture2DArray.ArraySize = arraySize; + break; + case UavDimension.Texture3D: + Anonymous.Texture3D.MipSlice = mipSlice; + Anonymous.Texture3D.FirstWSlice = firstArraySlice; + Anonymous.Texture3D.WSize = arraySize; + break; + } + } + + /// + /// Initializes a new instance of the struct. + /// + /// + /// + /// + /// + /// options flags for the resource. + public UnorderedAccessViewDescription( + ID3D11Buffer* buffer, + Format format, + uint firstElement = 0, + uint numElements = 0, + BufferUavFlags flags = BufferUavFlags.None) + { + Format = format; + ViewDimension = UavDimension.Buffer; + Anonymous = default; + Anonymous.Buffer.FirstElement = firstElement; + Anonymous.Buffer.NumElements = numElements; + Anonymous.Buffer.Flags = flags; + } + + /// + /// Initializes a new instance of the struct. + /// + /// + /// + /// + /// + /// + /// + public UnorderedAccessViewDescription( + ID3D11Texture1D* texture, + bool isArray, + Format format = Format.Unknown, + uint mipSlice = 0, + uint firstArraySlice = 0, + uint arraySize = unchecked((uint)-1)) + { + ViewDimension = isArray ? UavDimension.Texture1DArray : UavDimension.Texture1D; + + if (format == Format.Unknown + || (arraySize == unchecked((uint)-1) && (UavDimension.Texture1DArray == ViewDimension))) + { + Texture1DDescription textureDesc; + texture->GetDesc(&textureDesc); + + if (format == Format.Unknown) + format = textureDesc.Format; + if (arraySize == unchecked((uint)-1)) + arraySize = textureDesc.ArraySize - firstArraySlice; + } + + Format = format; + Anonymous = default; + + switch (ViewDimension) + { + case UavDimension.Texture1D: + Anonymous.Texture1D.MipSlice = mipSlice; + break; + case UavDimension.Texture1DArray: + Anonymous.Texture1DArray.MipSlice = mipSlice; + Anonymous.Texture1DArray.FirstArraySlice = firstArraySlice; + Anonymous.Texture1DArray.ArraySize = arraySize; + break; + } + } + + /// + /// Initializes a new instance of the struct. + /// + /// + /// + /// + /// + /// + /// + public UnorderedAccessViewDescription( + ID3D11Texture2D* texture, + UavDimension viewDimension, + Format format = Format.Unknown, + uint mipSlice = 0, + uint firstArraySlice = 0, + uint arraySize = unchecked((uint)-1)) + { + ViewDimension = viewDimension; + + if (format == Format.Unknown + || (arraySize == unchecked((uint)-1) && (viewDimension == UavDimension.Texture2DArray))) + { + Texture2DDescription textureDesc; + texture->GetDesc(&textureDesc); + + if (format == Format.Unknown) + format = textureDesc.Format; + if (arraySize == unchecked((uint)-1)) + arraySize = textureDesc.ArraySize - firstArraySlice; + } + + Format = format; + Anonymous = default; + + switch (viewDimension) + { + case UavDimension.Texture2D: + Anonymous.Texture2D.MipSlice = mipSlice; + break; + case UavDimension.Texture2DArray: + Anonymous.Texture2DArray.MipSlice = mipSlice; + Anonymous.Texture2DArray.FirstArraySlice = firstArraySlice; + Anonymous.Texture2DArray.ArraySize = arraySize; + break; + } + } + + /// + /// Initializes a new instance of the struct. + /// + /// + /// + /// + /// + /// + /// + public UnorderedAccessViewDescription( + ID3D11Texture3D* texture, + UavDimension viewDimension, + Format format = Format.Unknown, + uint mipSlice = 0, + uint firstWSlice = 0, + uint wSize = unchecked((uint)-1)) + { + ViewDimension = viewDimension; + + if (format == Format.Unknown || wSize == unchecked((uint)-1)) + { + Texture3DDescription textureDesc; + texture->GetDesc(&textureDesc); + + if (format == Format.Unknown) + format = textureDesc.Format; + if (wSize == unchecked((uint)-1)) + wSize = textureDesc.Depth - firstWSlice; + } + + Format = format; + Anonymous = default; + + Anonymous.Texture3D.MipSlice = mipSlice; + Anonymous.Texture3D.FirstWSlice = firstWSlice; + Anonymous.Texture3D.WSize = wSize; + } +}