mirror of
https://github.com/amerkoleci/Vortice.Win32.git
synced 2026-01-14 16:16:04 +08:00
Generator: Improve guid generation and add Dxc support.
This commit is contained in:
@@ -19,6 +19,7 @@ public static class Program
|
||||
"Graphics.Direct3D.json",
|
||||
"Graphics.Direct3D11.json",
|
||||
"Graphics.Direct3D12.json",
|
||||
"Graphics.Direct3D.Dxc.json",
|
||||
//"Graphics.Imaging.json",
|
||||
};
|
||||
|
||||
@@ -53,8 +54,8 @@ public static class Program
|
||||
{ "Foundation.LPARAM", "IntPtr" },
|
||||
{ "Foundation.LRESULT", "IntPtr" },
|
||||
{ "Foundation.WPARAM", "UIntPtr" },
|
||||
{ "Foundation.PSTR", "byte*" },
|
||||
{ "Foundation.PWSTR", "char*" },
|
||||
{ "Foundation.PSTR", "sbyte*" },
|
||||
{ "Foundation.PWSTR", "ushort*" },
|
||||
{ "Foundation.CHAR", "byte" },
|
||||
|
||||
{ "Foundation.LUID", "Luid" },
|
||||
@@ -64,6 +65,7 @@ public static class Program
|
||||
{ "System.Com.IUnknown", "IUnknown" },
|
||||
{ "System.Com.ISequentialStream", "Com.ISequentialStream" },
|
||||
{ "System.Com.IStream", "Com.IStream" },
|
||||
{ "System.Com.IMalloc", "Com.IMalloc" },
|
||||
|
||||
{ "Graphics.Gdi.HMONITOR", "IntPtr" },
|
||||
{ "Graphics.Gdi.HDC", "IntPtr" },
|
||||
@@ -82,7 +84,6 @@ public static class Program
|
||||
{ "Foundation.SIZE", "System.Drawing.Size" },
|
||||
};
|
||||
|
||||
|
||||
private static readonly Dictionary<string, string> s_partRenames = new()
|
||||
{
|
||||
{ "NONPREROTATED", "NonPrerotated" },
|
||||
@@ -210,6 +211,10 @@ public static class Program
|
||||
"ExecuteExtensionCommand",
|
||||
"ResolveEncoderOutputMetadata",
|
||||
"ResolveSubresourceRegion",
|
||||
"InPlaceEdit",
|
||||
"RootSignatureOnly",
|
||||
"ModuleOnly",
|
||||
"ValidMask",
|
||||
};
|
||||
|
||||
private static readonly HashSet<string> s_preserveCaps = new(StringComparer.OrdinalIgnoreCase)
|
||||
@@ -276,6 +281,9 @@ public static class Program
|
||||
{ "D3D12_DEBUG_DEVICE_PARAMETER_TYPE", "D3D12_DEBUG_DEVICE_PARAMETER" },
|
||||
{ "D3D12_DEBUG_COMMAND_LIST_PARAMETER_TYPE", "D3D12_DEBUG_COMMAND_LIST_PARAMETER" },
|
||||
{ "D3D12_SHADER_VERSION_TYPE", "D3D12_SHVER" },
|
||||
|
||||
// Dxc
|
||||
{ "DXC_OUT_KIND", "DXC_OUT" },
|
||||
};
|
||||
|
||||
private static readonly Dictionary<string, string> s_knownEnumValueNames = new()
|
||||
@@ -310,6 +318,9 @@ public static class Program
|
||||
{"DXGI_PRESENT", true },
|
||||
{"DXGI_MWA", true },
|
||||
{"DXGI_ENUM_MODES", true },
|
||||
{"DXC_HASHFLAG", true },
|
||||
{"DxcValidatorFlags", true },
|
||||
{"DxcVersionInfoFlags", true },
|
||||
};
|
||||
|
||||
private static readonly HashSet<string> s_ignoredStartParts = new(StringComparer.OrdinalIgnoreCase)
|
||||
@@ -343,6 +354,11 @@ public static class Program
|
||||
|
||||
// D2D1
|
||||
{ "D2D1_2DAFFINETRANSFORM_INTERPOLATION_MODE", "AffineTransform2DInterpolationMode" },
|
||||
|
||||
// Dxc
|
||||
{ "DXC_HASHFLAG", "DxcHashFlags" },
|
||||
{ "DxcValidatorFlags", "DxcValidatorFlags" },
|
||||
{ "DxcVersionInfoFlags", "DxcVersionInfoFlags" },
|
||||
};
|
||||
|
||||
private static readonly Dictionary<string, string> s_structFieldTypeRemap = new()
|
||||
@@ -382,6 +398,9 @@ public static class Program
|
||||
|
||||
// D3D12
|
||||
{ "D3D12_RENDER_TARGET_BLEND_DESC::RenderTargetWriteMask", "D3D12_COLOR_WRITE_ENABLE" },
|
||||
|
||||
// Dxc
|
||||
{ "DxcShaderHash::Flags", "DXC_HASHFLAG" },
|
||||
};
|
||||
|
||||
private static readonly Dictionary<string, string> s_mapFunctionParameters = new()
|
||||
@@ -506,7 +525,8 @@ public static class Program
|
||||
string typeName = GetTypeName(constant.Type);
|
||||
if (typeName == "Guid")
|
||||
{
|
||||
writer.WriteLine($"public static readonly Guid {constant.Name} = {FormatGuid(constant.Value.ToString())};");
|
||||
WriteGuid(writer, constant.Value.ToString(), constant.Name);
|
||||
writer.WriteLine();
|
||||
}
|
||||
else if (typeName == "HResult")
|
||||
{
|
||||
@@ -772,12 +792,12 @@ public static class Program
|
||||
foreach (ApiParameter parameter in function.Params)
|
||||
{
|
||||
bool asPointer = false;
|
||||
string parameterType = default;
|
||||
string parameterType = string.Empty;
|
||||
if (parameter.Type.Kind == "ApiRef")
|
||||
{
|
||||
if (parameter.Type.TargetKind == "FunctionPointer")
|
||||
{
|
||||
var functionType = api.Types.First(item => item.Name == parameter.Type.Name && item.Kind == "FunctionPointer");
|
||||
ApiType functionType = api.Types.First(item => item.Name == parameter.Type.Name && item.Kind == "FunctionPointer");
|
||||
parameterType = "delegate* unmanaged[Stdcall]<void*, void>";
|
||||
}
|
||||
else
|
||||
@@ -967,8 +987,15 @@ public static class Program
|
||||
}
|
||||
else
|
||||
{
|
||||
csTypeName = GetDataTypeName(structType.Name, out structPrefix);
|
||||
AddCsMapping(writer.Api, structType.Name, csTypeName);
|
||||
if (structType.Name.StartsWith("Dxc"))
|
||||
{
|
||||
csTypeName = structType.Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
csTypeName = GetDataTypeName(structType.Name, out structPrefix);
|
||||
AddCsMapping(writer.Api, structType.Name, csTypeName);
|
||||
}
|
||||
|
||||
writer.WriteLine($"/// <include file='../{writer.DocFileName}.xml' path='doc/member[@name=\"{structType.Name}\"]/*' />");
|
||||
|
||||
@@ -1219,51 +1246,7 @@ public static class Program
|
||||
if (comType.Guid != null)
|
||||
{
|
||||
// Generate IID
|
||||
using (writer.PushBlock($"public static ref readonly Guid IID_{csTypeName}"))
|
||||
{
|
||||
writer.WriteLine("[MethodImpl(MethodImplOptions.AggressiveInlining)]");
|
||||
using (writer.PushBlock("get"))
|
||||
{
|
||||
var guid = Guid.Parse(comType.Guid).ToString("N");
|
||||
var _1 = "0x" + guid.Substring(6, 2).ToUpperInvariant();
|
||||
var _2 = "0x" + guid.Substring(4, 2).ToUpperInvariant();
|
||||
var _3 = "0x" + guid.Substring(2, 2).ToUpperInvariant();
|
||||
var _4 = "0x" + guid.Substring(0, 2).ToUpperInvariant();
|
||||
|
||||
var _5 = "0x" + guid.Substring(10, 2).ToUpperInvariant();
|
||||
var _6 = "0x" + guid.Substring(8, 2).ToUpperInvariant();
|
||||
|
||||
var _7 = "0x" + guid.Substring(14, 2).ToUpperInvariant();
|
||||
var _8 = "0x" + guid.Substring(12, 2).ToUpperInvariant();
|
||||
|
||||
var d = "0x" + guid.Substring(16, 2).ToUpperInvariant();
|
||||
var e = "0x" + guid.Substring(18, 2).ToUpperInvariant();
|
||||
var f = "0x" + guid.Substring(20, 2).ToUpperInvariant();
|
||||
var g = "0x" + guid.Substring(22, 2).ToUpperInvariant();
|
||||
var h = "0x" + guid.Substring(24, 2).ToUpperInvariant();
|
||||
var i = "0x" + guid.Substring(26, 2).ToUpperInvariant();
|
||||
var j = "0x" + guid.Substring(28, 2).ToUpperInvariant();
|
||||
var k = "0x" + guid.Substring(30, 2).ToUpperInvariant();
|
||||
|
||||
writer.WriteLine("ReadOnlySpan<byte> data = new byte[] {");
|
||||
writer.WriteLine($"{'\t'}{_1}, {_2}, {_3}, {_4},");
|
||||
writer.WriteLine($"{'\t'}{_5}, {_6},");
|
||||
writer.WriteLine($"{'\t'}{_7}, {_8},");
|
||||
writer.WriteLine($"{'\t'}{d},");
|
||||
writer.WriteLine($"{'\t'}{e},");
|
||||
writer.WriteLine($"{'\t'}{f},");
|
||||
writer.WriteLine($"{'\t'}{g},");
|
||||
writer.WriteLine($"{'\t'}{h},");
|
||||
writer.WriteLine($"{'\t'}{i},");
|
||||
writer.WriteLine($"{'\t'}{j},");
|
||||
writer.WriteLine($"{'\t'}{k}");
|
||||
writer.WriteLine("};");
|
||||
writer.WriteLine();
|
||||
|
||||
writer.WriteLine("Debug.Assert(data.Length == Unsafe.SizeOf<Guid>());");
|
||||
writer.WriteLine("return ref Unsafe.As<byte, Guid>(ref MemoryMarshal.GetReference(data));");
|
||||
}
|
||||
}
|
||||
WriteGuid(writer, comType.Guid, $"IID_{csTypeName}");
|
||||
writer.WriteLine();
|
||||
|
||||
writer.WriteLine($"public static Guid* NativeGuid => (Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in IID_{csTypeName}));");
|
||||
@@ -1338,12 +1321,18 @@ public static class Program
|
||||
foreach (ApiParameter parameter in method.Params)
|
||||
{
|
||||
bool asPointer = false;
|
||||
string parameterType = default;
|
||||
string parameterType = string.Empty;
|
||||
|
||||
|
||||
if (method.Name == "Compile" && parameter.Name == "pArguments")
|
||||
{
|
||||
}
|
||||
|
||||
if (parameter.Type.Kind == "ApiRef")
|
||||
{
|
||||
if (parameter.Type.TargetKind == "FunctionPointer")
|
||||
{
|
||||
var functionType = api.Types.First(item => item.Name == parameter.Type.Name && item.Kind == "FunctionPointer");
|
||||
ApiType functionType = api.Types.First(item => item.Name == parameter.Type.Name && item.Kind == "FunctionPointer");
|
||||
parameterType = "delegate* unmanaged[Stdcall]<void*, void>";
|
||||
}
|
||||
else
|
||||
@@ -1374,11 +1363,6 @@ public static class Program
|
||||
parameterType = NormalizeTypeName(writer.Api, parameterType);
|
||||
string parameterName = parameter.Name;
|
||||
|
||||
if (method.Name == "RSSetScissorRects" && parameterName == "pRects")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool isOptional = parameter.Attrs.Any(item => item is string str && str == "Optional");
|
||||
if (parameter.Attrs.Any(item => item is string str && str == "ComOutPtr"))
|
||||
{
|
||||
@@ -1776,23 +1760,53 @@ public static class Program
|
||||
return prettyName;
|
||||
}
|
||||
|
||||
private static string FormatGuid(string value)
|
||||
private static void WriteGuid(CodeWriter writer, string guidValue, string guidName)
|
||||
{
|
||||
var guid = Guid.Parse(value).ToString("N");
|
||||
using (writer.PushBlock($"public static ref readonly Guid {guidName}"))
|
||||
{
|
||||
writer.WriteLine("[MethodImpl(MethodImplOptions.AggressiveInlining)]");
|
||||
using (writer.PushBlock("get"))
|
||||
{
|
||||
var guid = Guid.Parse(guidValue).ToString("N");
|
||||
var _1 = "0x" + guid.Substring(6, 2).ToUpperInvariant();
|
||||
var _2 = "0x" + guid.Substring(4, 2).ToUpperInvariant();
|
||||
var _3 = "0x" + guid.Substring(2, 2).ToUpperInvariant();
|
||||
var _4 = "0x" + guid.Substring(0, 2).ToUpperInvariant();
|
||||
|
||||
var a = "0x" + guid.Substring(0, 8);
|
||||
var b = "0x" + guid.Substring(8, 4);
|
||||
var c = "0x" + guid.Substring(12, 4);
|
||||
var d = "0x" + guid.Substring(16, 2);
|
||||
var e = "0x" + guid.Substring(18, 2);
|
||||
var f = "0x" + guid.Substring(20, 2);
|
||||
var g = "0x" + guid.Substring(22, 2);
|
||||
var h = "0x" + guid.Substring(24, 2);
|
||||
var i = "0x" + guid.Substring(26, 2);
|
||||
var j = "0x" + guid.Substring(28, 2);
|
||||
var k = "0x" + guid.Substring(30, 2);
|
||||
var _5 = "0x" + guid.Substring(10, 2).ToUpperInvariant();
|
||||
var _6 = "0x" + guid.Substring(8, 2).ToUpperInvariant();
|
||||
|
||||
return $"new Guid({a}, {b}, {c}, {d}, {e}, {f}, {g}, {h}, {i}, {j}, {k})";
|
||||
var _7 = "0x" + guid.Substring(14, 2).ToUpperInvariant();
|
||||
var _8 = "0x" + guid.Substring(12, 2).ToUpperInvariant();
|
||||
|
||||
var d = "0x" + guid.Substring(16, 2).ToUpperInvariant();
|
||||
var e = "0x" + guid.Substring(18, 2).ToUpperInvariant();
|
||||
var f = "0x" + guid.Substring(20, 2).ToUpperInvariant();
|
||||
var g = "0x" + guid.Substring(22, 2).ToUpperInvariant();
|
||||
var h = "0x" + guid.Substring(24, 2).ToUpperInvariant();
|
||||
var i = "0x" + guid.Substring(26, 2).ToUpperInvariant();
|
||||
var j = "0x" + guid.Substring(28, 2).ToUpperInvariant();
|
||||
var k = "0x" + guid.Substring(30, 2).ToUpperInvariant();
|
||||
|
||||
writer.WriteLine("ReadOnlySpan<byte> data = new byte[] {");
|
||||
writer.WriteLine($"{'\t'}{_1}, {_2}, {_3}, {_4},");
|
||||
writer.WriteLine($"{'\t'}{_5}, {_6},");
|
||||
writer.WriteLine($"{'\t'}{_7}, {_8},");
|
||||
writer.WriteLine($"{'\t'}{d},");
|
||||
writer.WriteLine($"{'\t'}{e},");
|
||||
writer.WriteLine($"{'\t'}{f},");
|
||||
writer.WriteLine($"{'\t'}{g},");
|
||||
writer.WriteLine($"{'\t'}{h},");
|
||||
writer.WriteLine($"{'\t'}{i},");
|
||||
writer.WriteLine($"{'\t'}{j},");
|
||||
writer.WriteLine($"{'\t'}{k}");
|
||||
writer.WriteLine("};");
|
||||
writer.WriteLine();
|
||||
|
||||
writer.WriteLine("Debug.Assert(data.Length == Unsafe.SizeOf<Guid>());");
|
||||
writer.WriteLine("return ref Unsafe.As<byte, Guid>(ref MemoryMarshal.GetReference(data));");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetApiName(ApiDataType dataType)
|
||||
@@ -1848,12 +1862,21 @@ public static class Program
|
||||
|
||||
private static bool IsPrimitive(string typeName)
|
||||
{
|
||||
if (typeName.EndsWith("*"))
|
||||
{
|
||||
typeName = typeName.Substring(0, typeName.Length - 1);
|
||||
}
|
||||
|
||||
switch (typeName)
|
||||
{
|
||||
case "void":
|
||||
case "bool":
|
||||
case "byte":
|
||||
case "sbyte":
|
||||
case "int":
|
||||
case "uint":
|
||||
case "short":
|
||||
case "ushort":
|
||||
case "Bool32":
|
||||
return true;
|
||||
|
||||
@@ -1878,6 +1901,10 @@ public static class Program
|
||||
{
|
||||
return IsPrimitive(dataType.Child);
|
||||
}
|
||||
else if (dataType.Kind == "LPArray")
|
||||
{
|
||||
return IsPrimitive(dataType.Child);
|
||||
}
|
||||
|
||||
if (dataType.Kind != "Native")
|
||||
{
|
||||
|
||||
110
src/Vortice.Win32/Com/IMalloc.cs
Normal file
110
src/Vortice.Win32/Com/IMalloc.cs
Normal file
@@ -0,0 +1,110 @@
|
||||
// Copyright © Amer Koleci and Contributors.
|
||||
// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information.
|
||||
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Win32.Com;
|
||||
|
||||
[Guid("00000002-0000-0000-C000-000000000046")]
|
||||
[NativeTypeName("struct IMalloc : IUnknown")]
|
||||
[NativeInheritance("IUnknown")]
|
||||
public unsafe partial struct IMalloc
|
||||
{
|
||||
public static ref readonly Guid IID_IMalloc
|
||||
{
|
||||
get
|
||||
{
|
||||
ReadOnlySpan<byte> data = new byte[] {
|
||||
0x02, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00,
|
||||
0x00, 0x00,
|
||||
0xC0,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x46
|
||||
};
|
||||
|
||||
Debug.Assert(data.Length == Unsafe.SizeOf<Guid>());
|
||||
return ref Unsafe.As<byte, Guid>(ref MemoryMarshal.GetReference(data));
|
||||
}
|
||||
}
|
||||
|
||||
public static Guid* NativeGuid => (Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in IID_IMalloc));
|
||||
|
||||
public void** lpVtbl;
|
||||
|
||||
/// <inheritdoc cref="IUnknown.QueryInterface" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(0)]
|
||||
public HResult QueryInterface([NativeTypeName("const IID &")] Guid* riid, void** ppvObject)
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<ISequentialStream*, Guid*, void**, int>)(lpVtbl[0]))((ISequentialStream*)Unsafe.AsPointer(ref this), riid, ppvObject);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IUnknown.AddRef" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(1)]
|
||||
[return: NativeTypeName("ULONG")]
|
||||
public uint AddRef()
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<ISequentialStream*, uint>)(lpVtbl[1]))((ISequentialStream*)Unsafe.AsPointer(ref this));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IUnknown.Release" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(2)]
|
||||
[return: NativeTypeName("ULONG")]
|
||||
public uint Release()
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<ISequentialStream*, uint>)(lpVtbl[2]))((ISequentialStream*)Unsafe.AsPointer(ref this));
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(3)]
|
||||
public void* Alloc([NativeTypeName("SIZE_T")] nuint cb)
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<IMalloc*, nuint, void*>)(lpVtbl[3]))((IMalloc*)Unsafe.AsPointer(ref this), cb);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(4)]
|
||||
public void* Realloc(void* pv, [NativeTypeName("SIZE_T")] nuint cb)
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<IMalloc*, void*, nuint, void*>)(lpVtbl[4]))((IMalloc*)Unsafe.AsPointer(ref this), pv, cb);
|
||||
}
|
||||
|
||||
/// <include file='IMalloc.xml' path='doc/member[@name="IMalloc.Free"]/*' />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(5)]
|
||||
public void Free(void* pv)
|
||||
{
|
||||
((delegate* unmanaged[Stdcall]<IMalloc*, void*, void>)(lpVtbl[5]))((IMalloc*)Unsafe.AsPointer(ref this), pv);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(6)]
|
||||
[return: NativeTypeName("SIZE_T")]
|
||||
public nuint GetSize(void* pv)
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<IMalloc*, void*, nuint>)(lpVtbl[6]))((IMalloc*)Unsafe.AsPointer(ref this), pv);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(7)]
|
||||
public int DidAlloc(void* pv)
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<IMalloc*, void*, int>)(lpVtbl[7]))((IMalloc*)Unsafe.AsPointer(ref this), pv);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(8)]
|
||||
public void HeapMinimize()
|
||||
{
|
||||
((delegate* unmanaged[Stdcall]<IMalloc*, void>)(lpVtbl[8]))((IMalloc*)Unsafe.AsPointer(ref this));
|
||||
}
|
||||
}
|
||||
2
src/Vortice.Win32/Generated/Dxc.xml
Normal file
2
src/Vortice.Win32/Generated/Dxc.xml
Normal file
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<doc />
|
||||
3045
src/Vortice.Win32/Generated/Graphics/Direct3D.Dxc.cs
Normal file
3045
src/Vortice.Win32/Generated/Graphics/Direct3D.Dxc.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -64,16 +64,154 @@ public static partial class Apis
|
||||
public const uint D3D_SHADER_FEATURE_SAMPLER_DESCRIPTOR_HEAP_INDEXING = 67108864;
|
||||
public const uint D3D_SHADER_FEATURE_WAVE_MMA = 134217728;
|
||||
public const uint D3D_SHADER_FEATURE_ATOMIC_INT64_ON_DESCRIPTOR_HEAP_RESOURCE = 268435456;
|
||||
public static readonly Guid WKPDID_D3DDebugObjectName = new Guid(0x429b8c22, 0x9188, 0x4b0c, 0x87, 0x42, 0xac, 0xb0, 0xbf, 0x85, 0xc2, 0x00);
|
||||
public static readonly Guid WKPDID_D3DDebugObjectNameW = new Guid(0x4cca5fd8, 0x921f, 0x42c8, 0x85, 0x66, 0x70, 0xca, 0xf2, 0xa9, 0xb7, 0x41);
|
||||
public static readonly Guid WKPDID_CommentStringW = new Guid(0xd0149dc0, 0x90e8, 0x4ec8, 0x81, 0x44, 0xe9, 0x00, 0xad, 0x26, 0x6b, 0xb2);
|
||||
public static readonly Guid WKPDID_D3D12UniqueObjectId = new Guid(0x1b39de15, 0xec04, 0x4bae, 0xba, 0x4d, 0x8c, 0xef, 0x79, 0xfc, 0x04, 0xc1);
|
||||
public static ref readonly Guid WKPDID_D3DDebugObjectName
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get
|
||||
{
|
||||
ReadOnlySpan<byte> data = new byte[] {
|
||||
0x22, 0x8C, 0x9B, 0x42,
|
||||
0x88, 0x91,
|
||||
0x0C, 0x4B,
|
||||
0x87,
|
||||
0x42,
|
||||
0xAC,
|
||||
0xB0,
|
||||
0xBF,
|
||||
0x85,
|
||||
0xC2,
|
||||
0x00
|
||||
};
|
||||
|
||||
Debug.Assert(data.Length == Unsafe.SizeOf<Guid>());
|
||||
return ref Unsafe.As<byte, Guid>(ref MemoryMarshal.GetReference(data));
|
||||
}
|
||||
}
|
||||
|
||||
public static ref readonly Guid WKPDID_D3DDebugObjectNameW
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get
|
||||
{
|
||||
ReadOnlySpan<byte> data = new byte[] {
|
||||
0xD8, 0x5F, 0xCA, 0x4C,
|
||||
0x1F, 0x92,
|
||||
0xC8, 0x42,
|
||||
0x85,
|
||||
0x66,
|
||||
0x70,
|
||||
0xCA,
|
||||
0xF2,
|
||||
0xA9,
|
||||
0xB7,
|
||||
0x41
|
||||
};
|
||||
|
||||
Debug.Assert(data.Length == Unsafe.SizeOf<Guid>());
|
||||
return ref Unsafe.As<byte, Guid>(ref MemoryMarshal.GetReference(data));
|
||||
}
|
||||
}
|
||||
|
||||
public static ref readonly Guid WKPDID_CommentStringW
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get
|
||||
{
|
||||
ReadOnlySpan<byte> data = new byte[] {
|
||||
0xC0, 0x9D, 0x14, 0xD0,
|
||||
0xE8, 0x90,
|
||||
0xC8, 0x4E,
|
||||
0x81,
|
||||
0x44,
|
||||
0xE9,
|
||||
0x00,
|
||||
0xAD,
|
||||
0x26,
|
||||
0x6B,
|
||||
0xB2
|
||||
};
|
||||
|
||||
Debug.Assert(data.Length == Unsafe.SizeOf<Guid>());
|
||||
return ref Unsafe.As<byte, Guid>(ref MemoryMarshal.GetReference(data));
|
||||
}
|
||||
}
|
||||
|
||||
public static ref readonly Guid WKPDID_D3D12UniqueObjectId
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get
|
||||
{
|
||||
ReadOnlySpan<byte> data = new byte[] {
|
||||
0x15, 0xDE, 0x39, 0x1B,
|
||||
0x04, 0xEC,
|
||||
0xAE, 0x4B,
|
||||
0xBA,
|
||||
0x4D,
|
||||
0x8C,
|
||||
0xEF,
|
||||
0x79,
|
||||
0xFC,
|
||||
0x04,
|
||||
0xC1
|
||||
};
|
||||
|
||||
Debug.Assert(data.Length == Unsafe.SizeOf<Guid>());
|
||||
return ref Unsafe.As<byte, Guid>(ref MemoryMarshal.GetReference(data));
|
||||
}
|
||||
}
|
||||
|
||||
public const uint D3D_COMPONENT_MASK_X = 1;
|
||||
public const uint D3D_COMPONENT_MASK_Y = 2;
|
||||
public const uint D3D_COMPONENT_MASK_Z = 4;
|
||||
public const uint D3D_COMPONENT_MASK_W = 8;
|
||||
public static readonly Guid D3D_TEXTURE_LAYOUT_ROW_MAJOR = new Guid(0xb5dc234f, 0x72bb, 0x4bec, 0x97, 0x05, 0x8c, 0xf2, 0x58, 0xdf, 0x6b, 0x6c);
|
||||
public static readonly Guid D3D_TEXTURE_LAYOUT_64KB_STANDARD_SWIZZLE = new Guid(0x4c0f29e3, 0x3f5f, 0x4d35, 0x84, 0xc9, 0xbc, 0x09, 0x83, 0xb6, 0x2c, 0x28);
|
||||
public static ref readonly Guid D3D_TEXTURE_LAYOUT_ROW_MAJOR
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get
|
||||
{
|
||||
ReadOnlySpan<byte> data = new byte[] {
|
||||
0x4F, 0x23, 0xDC, 0xB5,
|
||||
0xBB, 0x72,
|
||||
0xEC, 0x4B,
|
||||
0x97,
|
||||
0x05,
|
||||
0x8C,
|
||||
0xF2,
|
||||
0x58,
|
||||
0xDF,
|
||||
0x6B,
|
||||
0x6C
|
||||
};
|
||||
|
||||
Debug.Assert(data.Length == Unsafe.SizeOf<Guid>());
|
||||
return ref Unsafe.As<byte, Guid>(ref MemoryMarshal.GetReference(data));
|
||||
}
|
||||
}
|
||||
|
||||
public static ref readonly Guid D3D_TEXTURE_LAYOUT_64KB_STANDARD_SWIZZLE
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get
|
||||
{
|
||||
ReadOnlySpan<byte> data = new byte[] {
|
||||
0xE3, 0x29, 0x0F, 0x4C,
|
||||
0x5F, 0x3F,
|
||||
0x35, 0x4D,
|
||||
0x84,
|
||||
0xC9,
|
||||
0xBC,
|
||||
0x09,
|
||||
0x83,
|
||||
0xB6,
|
||||
0x2C,
|
||||
0x28
|
||||
};
|
||||
|
||||
Debug.Assert(data.Length == Unsafe.SizeOf<Guid>());
|
||||
return ref Unsafe.As<byte, Guid>(ref MemoryMarshal.GetReference(data));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#region Enums
|
||||
@@ -1073,10 +1211,10 @@ public enum ParameterFlags : int
|
||||
public partial struct ShaderMacro
|
||||
{
|
||||
/// <include file='../Direct3D.xml' path='doc/member[@name="D3D_SHADER_MACRO::Name"]/*' />
|
||||
public unsafe byte* Name;
|
||||
public unsafe sbyte* Name;
|
||||
|
||||
/// <include file='../Direct3D.xml' path='doc/member[@name="D3D_SHADER_MACRO::Definition"]/*' />
|
||||
public unsafe byte* Definition;
|
||||
public unsafe sbyte* Definition;
|
||||
}
|
||||
|
||||
#endregion Structs
|
||||
@@ -1249,9 +1387,9 @@ public unsafe partial struct ID3DInclude
|
||||
/// <include file='../Direct3D.xml' path='doc/member[@name="ID3DInclude::Open"]/*' />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(0)]
|
||||
public HResult Open(IncludeType IncludeType, byte** pFileName, void* pParentData, void** ppData, uint* pBytes)
|
||||
public HResult Open(IncludeType IncludeType, sbyte* pFileName, void* pParentData, void** ppData, uint* pBytes)
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<ID3DInclude*, IncludeType, byte**, void*, void**, uint*, int>)(lpVtbl[0]))((ID3DInclude*)Unsafe.AsPointer(ref this), IncludeType, pFileName, pParentData, ppData, pBytes);
|
||||
return ((delegate* unmanaged[Stdcall]<ID3DInclude*, IncludeType, sbyte*, void*, void**, uint*, int>)(lpVtbl[0]))((ID3DInclude*)Unsafe.AsPointer(ref this), IncludeType, pFileName, pParentData, ppData, pBytes);
|
||||
}
|
||||
|
||||
/// <include file='../Direct3D.xml' path='doc/member[@name="ID3DInclude::Close"]/*' />
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -24,10 +24,102 @@ public static partial class Apis
|
||||
public const uint DXGI_SHARED_RESOURCE_READ = 2147483648;
|
||||
public const uint DXGI_SHARED_RESOURCE_WRITE = 1;
|
||||
public const uint DXGI_DEBUG_BINARY_VERSION = 1;
|
||||
public static readonly Guid DXGI_DEBUG_ALL = new Guid(0xe48ae283, 0xda80, 0x490b, 0x87, 0xe6, 0x43, 0xe9, 0xa9, 0xcf, 0xda, 0x08);
|
||||
public static readonly Guid DXGI_DEBUG_DX = new Guid(0x35cdd7fc, 0x13b2, 0x421d, 0xa5, 0xd7, 0x7e, 0x44, 0x51, 0x28, 0x7d, 0x64);
|
||||
public static readonly Guid DXGI_DEBUG_DXGI = new Guid(0x25cddaa4, 0xb1c6, 0x47e1, 0xac, 0x3e, 0x98, 0x87, 0x5b, 0x5a, 0x2e, 0x2a);
|
||||
public static readonly Guid DXGI_DEBUG_APP = new Guid(0x06cd6e01, 0x4219, 0x4ebd, 0x87, 0x09, 0x27, 0xed, 0x23, 0x36, 0x0c, 0x62);
|
||||
public static ref readonly Guid DXGI_DEBUG_ALL
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get
|
||||
{
|
||||
ReadOnlySpan<byte> data = new byte[] {
|
||||
0x83, 0xE2, 0x8A, 0xE4,
|
||||
0x80, 0xDA,
|
||||
0x0B, 0x49,
|
||||
0x87,
|
||||
0xE6,
|
||||
0x43,
|
||||
0xE9,
|
||||
0xA9,
|
||||
0xCF,
|
||||
0xDA,
|
||||
0x08
|
||||
};
|
||||
|
||||
Debug.Assert(data.Length == Unsafe.SizeOf<Guid>());
|
||||
return ref Unsafe.As<byte, Guid>(ref MemoryMarshal.GetReference(data));
|
||||
}
|
||||
}
|
||||
|
||||
public static ref readonly Guid DXGI_DEBUG_DX
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get
|
||||
{
|
||||
ReadOnlySpan<byte> data = new byte[] {
|
||||
0xFC, 0xD7, 0xCD, 0x35,
|
||||
0xB2, 0x13,
|
||||
0x1D, 0x42,
|
||||
0xA5,
|
||||
0xD7,
|
||||
0x7E,
|
||||
0x44,
|
||||
0x51,
|
||||
0x28,
|
||||
0x7D,
|
||||
0x64
|
||||
};
|
||||
|
||||
Debug.Assert(data.Length == Unsafe.SizeOf<Guid>());
|
||||
return ref Unsafe.As<byte, Guid>(ref MemoryMarshal.GetReference(data));
|
||||
}
|
||||
}
|
||||
|
||||
public static ref readonly Guid DXGI_DEBUG_DXGI
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get
|
||||
{
|
||||
ReadOnlySpan<byte> data = new byte[] {
|
||||
0xA4, 0xDA, 0xCD, 0x25,
|
||||
0xC6, 0xB1,
|
||||
0xE1, 0x47,
|
||||
0xAC,
|
||||
0x3E,
|
||||
0x98,
|
||||
0x87,
|
||||
0x5B,
|
||||
0x5A,
|
||||
0x2E,
|
||||
0x2A
|
||||
};
|
||||
|
||||
Debug.Assert(data.Length == Unsafe.SizeOf<Guid>());
|
||||
return ref Unsafe.As<byte, Guid>(ref MemoryMarshal.GetReference(data));
|
||||
}
|
||||
}
|
||||
|
||||
public static ref readonly Guid DXGI_DEBUG_APP
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get
|
||||
{
|
||||
ReadOnlySpan<byte> data = new byte[] {
|
||||
0x01, 0x6E, 0xCD, 0x06,
|
||||
0x19, 0x42,
|
||||
0xBD, 0x4E,
|
||||
0x87,
|
||||
0x09,
|
||||
0x27,
|
||||
0xED,
|
||||
0x23,
|
||||
0x36,
|
||||
0x0C,
|
||||
0x62
|
||||
};
|
||||
|
||||
Debug.Assert(data.Length == Unsafe.SizeOf<Guid>());
|
||||
return ref Unsafe.As<byte, Guid>(ref MemoryMarshal.GetReference(data));
|
||||
}
|
||||
}
|
||||
|
||||
public const uint DXGI_INFO_QUEUE_MESSAGE_ID_STRING_FROM_APPLICATION = 0;
|
||||
public const uint DXGI_INFO_QUEUE_DEFAULT_MESSAGE_COUNT_LIMIT = 1024;
|
||||
public const uint DXGI_CREATE_FACTORY_DEBUG = 1;
|
||||
@@ -4781,9 +4873,9 @@ public unsafe partial struct IDXGIResource1
|
||||
/// <include file='../Dxgi.xml' path='doc/member[@name="IDXGIResource1::CreateSharedHandle"]/*' />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(13)]
|
||||
public HResult CreateSharedHandle(Security.SECURITY_ATTRIBUTES* pAttributes, uint dwAccess, char** lpName, IntPtr* pHandle)
|
||||
public HResult CreateSharedHandle(Security.SECURITY_ATTRIBUTES* pAttributes, uint dwAccess, ushort* lpName, IntPtr* pHandle)
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<IDXGIResource1*, Security.SECURITY_ATTRIBUTES*, uint, char**, IntPtr*, int>)(lpVtbl[13]))((IDXGIResource1*)Unsafe.AsPointer(ref this), pAttributes, dwAccess, lpName, pHandle);
|
||||
return ((delegate* unmanaged[Stdcall]<IDXGIResource1*, Security.SECURITY_ATTRIBUTES*, uint, ushort*, IntPtr*, int>)(lpVtbl[13]))((IDXGIResource1*)Unsafe.AsPointer(ref this), pAttributes, dwAccess, lpName, pHandle);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10819,17 +10911,17 @@ public unsafe partial struct IDXGIInfoQueue
|
||||
/// <include file='../Dxgi.xml' path='doc/member[@name="IDXGIInfoQueue::AddMessage"]/*' />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(30)]
|
||||
public HResult AddMessage(Guid Producer, InfoQueueMessageCategory Category, InfoQueueMessageSeverity Severity, int ID, byte** pDescription)
|
||||
public HResult AddMessage(Guid Producer, InfoQueueMessageCategory Category, InfoQueueMessageSeverity Severity, int ID, sbyte* pDescription)
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<IDXGIInfoQueue*, Guid, InfoQueueMessageCategory, InfoQueueMessageSeverity, int, byte**, int>)(lpVtbl[30]))((IDXGIInfoQueue*)Unsafe.AsPointer(ref this), Producer, Category, Severity, ID, pDescription);
|
||||
return ((delegate* unmanaged[Stdcall]<IDXGIInfoQueue*, Guid, InfoQueueMessageCategory, InfoQueueMessageSeverity, int, sbyte*, int>)(lpVtbl[30]))((IDXGIInfoQueue*)Unsafe.AsPointer(ref this), Producer, Category, Severity, ID, pDescription);
|
||||
}
|
||||
|
||||
/// <include file='../Dxgi.xml' path='doc/member[@name="IDXGIInfoQueue::AddApplicationMessage"]/*' />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(31)]
|
||||
public HResult AddApplicationMessage(InfoQueueMessageSeverity Severity, byte** pDescription)
|
||||
public HResult AddApplicationMessage(InfoQueueMessageSeverity Severity, sbyte* pDescription)
|
||||
{
|
||||
return ((delegate* unmanaged[Stdcall]<IDXGIInfoQueue*, InfoQueueMessageSeverity, byte**, int>)(lpVtbl[31]))((IDXGIInfoQueue*)Unsafe.AsPointer(ref this), Severity, pDescription);
|
||||
return ((delegate* unmanaged[Stdcall]<IDXGIInfoQueue*, InfoQueueMessageSeverity, sbyte*, int>)(lpVtbl[31]))((IDXGIInfoQueue*)Unsafe.AsPointer(ref this), Severity, pDescription);
|
||||
}
|
||||
|
||||
/// <include file='../Dxgi.xml' path='doc/member[@name="IDXGIInfoQueue::SetBreakOnCategory"]/*' />
|
||||
|
||||
26
src/Vortice.Win32/Graphics/Dxc.Manual.cs
Normal file
26
src/Vortice.Win32/Graphics/Dxc.Manual.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
// Copyright © Amer Koleci and Contributors.
|
||||
// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information.
|
||||
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Win32.Graphics.Direct3D.Dxc;
|
||||
|
||||
public static unsafe partial class Apis
|
||||
{
|
||||
public static HResult DxcCreateInstance(in Guid rclsid, Guid* riid, void** ppv)
|
||||
{
|
||||
return DxcCreateInstance(
|
||||
(Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in rclsid)),
|
||||
riid,
|
||||
ppv);
|
||||
}
|
||||
|
||||
public static HResult DxcCreateInstance2(Com.IMalloc* pMalloc, in Guid rclsid, Guid* riid, void** ppv)
|
||||
{
|
||||
return DxcCreateInstance2(
|
||||
pMalloc,
|
||||
(Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in rclsid)),
|
||||
riid,
|
||||
ppv);
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,8 @@ using MessageId = Win32.Graphics.Direct3D11.MessageId;
|
||||
using InfoQueueFilter = Win32.Graphics.Direct3D11.InfoQueueFilter;
|
||||
using Win32.Graphics.Dxgi.Common;
|
||||
using System.Numerics;
|
||||
using Win32.Graphics.Direct3D.Dxc;
|
||||
using static Win32.Graphics.Direct3D.Dxc.Apis;
|
||||
|
||||
namespace ClearScreen;
|
||||
|
||||
@@ -37,8 +39,16 @@ public static unsafe class Program
|
||||
}
|
||||
#endif
|
||||
|
||||
private static void TestDxc()
|
||||
{
|
||||
using ComPtr<IDxcCompiler3> compiler = default;
|
||||
DxcCreateInstance(CLSID_DxcCompiler, __uuidof<IDxcCompiler3>(), compiler.GetVoidAddressOf());
|
||||
}
|
||||
|
||||
public static void Main()
|
||||
{
|
||||
TestDxc();
|
||||
|
||||
using ComPtr<IDXGIFactory2> factory = default;
|
||||
uint factoryFlags = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user