Generator: Improve guid generation and add Dxc support.

This commit is contained in:
Amer Koleci
2022-09-12 11:01:44 +02:00
parent 0d7bc83411
commit c5e06e5215
10 changed files with 5586 additions and 457 deletions

View File

@@ -19,6 +19,7 @@ public static class Program
"Graphics.Direct3D.json", "Graphics.Direct3D.json",
"Graphics.Direct3D11.json", "Graphics.Direct3D11.json",
"Graphics.Direct3D12.json", "Graphics.Direct3D12.json",
"Graphics.Direct3D.Dxc.json",
//"Graphics.Imaging.json", //"Graphics.Imaging.json",
}; };
@@ -53,8 +54,8 @@ public static class Program
{ "Foundation.LPARAM", "IntPtr" }, { "Foundation.LPARAM", "IntPtr" },
{ "Foundation.LRESULT", "IntPtr" }, { "Foundation.LRESULT", "IntPtr" },
{ "Foundation.WPARAM", "UIntPtr" }, { "Foundation.WPARAM", "UIntPtr" },
{ "Foundation.PSTR", "byte*" }, { "Foundation.PSTR", "sbyte*" },
{ "Foundation.PWSTR", "char*" }, { "Foundation.PWSTR", "ushort*" },
{ "Foundation.CHAR", "byte" }, { "Foundation.CHAR", "byte" },
{ "Foundation.LUID", "Luid" }, { "Foundation.LUID", "Luid" },
@@ -64,6 +65,7 @@ public static class Program
{ "System.Com.IUnknown", "IUnknown" }, { "System.Com.IUnknown", "IUnknown" },
{ "System.Com.ISequentialStream", "Com.ISequentialStream" }, { "System.Com.ISequentialStream", "Com.ISequentialStream" },
{ "System.Com.IStream", "Com.IStream" }, { "System.Com.IStream", "Com.IStream" },
{ "System.Com.IMalloc", "Com.IMalloc" },
{ "Graphics.Gdi.HMONITOR", "IntPtr" }, { "Graphics.Gdi.HMONITOR", "IntPtr" },
{ "Graphics.Gdi.HDC", "IntPtr" }, { "Graphics.Gdi.HDC", "IntPtr" },
@@ -82,7 +84,6 @@ public static class Program
{ "Foundation.SIZE", "System.Drawing.Size" }, { "Foundation.SIZE", "System.Drawing.Size" },
}; };
private static readonly Dictionary<string, string> s_partRenames = new() private static readonly Dictionary<string, string> s_partRenames = new()
{ {
{ "NONPREROTATED", "NonPrerotated" }, { "NONPREROTATED", "NonPrerotated" },
@@ -210,6 +211,10 @@ public static class Program
"ExecuteExtensionCommand", "ExecuteExtensionCommand",
"ResolveEncoderOutputMetadata", "ResolveEncoderOutputMetadata",
"ResolveSubresourceRegion", "ResolveSubresourceRegion",
"InPlaceEdit",
"RootSignatureOnly",
"ModuleOnly",
"ValidMask",
}; };
private static readonly HashSet<string> s_preserveCaps = new(StringComparer.OrdinalIgnoreCase) 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_DEVICE_PARAMETER_TYPE", "D3D12_DEBUG_DEVICE_PARAMETER" },
{ "D3D12_DEBUG_COMMAND_LIST_PARAMETER_TYPE", "D3D12_DEBUG_COMMAND_LIST_PARAMETER" }, { "D3D12_DEBUG_COMMAND_LIST_PARAMETER_TYPE", "D3D12_DEBUG_COMMAND_LIST_PARAMETER" },
{ "D3D12_SHADER_VERSION_TYPE", "D3D12_SHVER" }, { "D3D12_SHADER_VERSION_TYPE", "D3D12_SHVER" },
// Dxc
{ "DXC_OUT_KIND", "DXC_OUT" },
}; };
private static readonly Dictionary<string, string> s_knownEnumValueNames = new() private static readonly Dictionary<string, string> s_knownEnumValueNames = new()
@@ -310,6 +318,9 @@ public static class Program
{"DXGI_PRESENT", true }, {"DXGI_PRESENT", true },
{"DXGI_MWA", true }, {"DXGI_MWA", true },
{"DXGI_ENUM_MODES", true }, {"DXGI_ENUM_MODES", true },
{"DXC_HASHFLAG", true },
{"DxcValidatorFlags", true },
{"DxcVersionInfoFlags", true },
}; };
private static readonly HashSet<string> s_ignoredStartParts = new(StringComparer.OrdinalIgnoreCase) private static readonly HashSet<string> s_ignoredStartParts = new(StringComparer.OrdinalIgnoreCase)
@@ -343,6 +354,11 @@ public static class Program
// D2D1 // D2D1
{ "D2D1_2DAFFINETRANSFORM_INTERPOLATION_MODE", "AffineTransform2DInterpolationMode" }, { "D2D1_2DAFFINETRANSFORM_INTERPOLATION_MODE", "AffineTransform2DInterpolationMode" },
// Dxc
{ "DXC_HASHFLAG", "DxcHashFlags" },
{ "DxcValidatorFlags", "DxcValidatorFlags" },
{ "DxcVersionInfoFlags", "DxcVersionInfoFlags" },
}; };
private static readonly Dictionary<string, string> s_structFieldTypeRemap = new() private static readonly Dictionary<string, string> s_structFieldTypeRemap = new()
@@ -382,6 +398,9 @@ public static class Program
// D3D12 // D3D12
{ "D3D12_RENDER_TARGET_BLEND_DESC::RenderTargetWriteMask", "D3D12_COLOR_WRITE_ENABLE" }, { "D3D12_RENDER_TARGET_BLEND_DESC::RenderTargetWriteMask", "D3D12_COLOR_WRITE_ENABLE" },
// Dxc
{ "DxcShaderHash::Flags", "DXC_HASHFLAG" },
}; };
private static readonly Dictionary<string, string> s_mapFunctionParameters = new() private static readonly Dictionary<string, string> s_mapFunctionParameters = new()
@@ -506,7 +525,8 @@ public static class Program
string typeName = GetTypeName(constant.Type); string typeName = GetTypeName(constant.Type);
if (typeName == "Guid") 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") else if (typeName == "HResult")
{ {
@@ -772,12 +792,12 @@ public static class Program
foreach (ApiParameter parameter in function.Params) foreach (ApiParameter parameter in function.Params)
{ {
bool asPointer = false; bool asPointer = false;
string parameterType = default; string parameterType = string.Empty;
if (parameter.Type.Kind == "ApiRef") if (parameter.Type.Kind == "ApiRef")
{ {
if (parameter.Type.TargetKind == "FunctionPointer") 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>"; parameterType = "delegate* unmanaged[Stdcall]<void*, void>";
} }
else else
@@ -966,9 +986,16 @@ public static class Program
csTypeName = structType.Name; csTypeName = structType.Name;
} }
else else
{
if (structType.Name.StartsWith("Dxc"))
{
csTypeName = structType.Name;
}
else
{ {
csTypeName = GetDataTypeName(structType.Name, out structPrefix); csTypeName = GetDataTypeName(structType.Name, out structPrefix);
AddCsMapping(writer.Api, structType.Name, csTypeName); AddCsMapping(writer.Api, structType.Name, csTypeName);
}
writer.WriteLine($"/// <include file='../{writer.DocFileName}.xml' path='doc/member[@name=\"{structType.Name}\"]/*' />"); 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) if (comType.Guid != null)
{ {
// Generate IID // Generate IID
using (writer.PushBlock($"public static ref readonly Guid IID_{csTypeName}")) WriteGuid(writer, comType.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));");
}
}
writer.WriteLine(); writer.WriteLine();
writer.WriteLine($"public static Guid* NativeGuid => (Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in IID_{csTypeName}));"); 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) foreach (ApiParameter parameter in method.Params)
{ {
bool asPointer = false; 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.Kind == "ApiRef")
{ {
if (parameter.Type.TargetKind == "FunctionPointer") 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>"; parameterType = "delegate* unmanaged[Stdcall]<void*, void>";
} }
else else
@@ -1374,11 +1363,6 @@ public static class Program
parameterType = NormalizeTypeName(writer.Api, parameterType); parameterType = NormalizeTypeName(writer.Api, parameterType);
string parameterName = parameter.Name; string parameterName = parameter.Name;
if (method.Name == "RSSetScissorRects" && parameterName == "pRects")
{
}
bool isOptional = parameter.Attrs.Any(item => item is string str && str == "Optional"); bool isOptional = parameter.Attrs.Any(item => item is string str && str == "Optional");
if (parameter.Attrs.Any(item => item is string str && str == "ComOutPtr")) if (parameter.Attrs.Any(item => item is string str && str == "ComOutPtr"))
{ {
@@ -1776,23 +1760,53 @@ public static class Program
return prettyName; 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 _5 = "0x" + guid.Substring(10, 2).ToUpperInvariant();
var b = "0x" + guid.Substring(8, 4); var _6 = "0x" + guid.Substring(8, 2).ToUpperInvariant();
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);
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) private static string GetApiName(ApiDataType dataType)
@@ -1848,12 +1862,21 @@ public static class Program
private static bool IsPrimitive(string typeName) private static bool IsPrimitive(string typeName)
{ {
if (typeName.EndsWith("*"))
{
typeName = typeName.Substring(0, typeName.Length - 1);
}
switch (typeName) switch (typeName)
{ {
case "void": case "void":
case "bool": case "bool":
case "byte":
case "sbyte":
case "int": case "int":
case "uint": case "uint":
case "short":
case "ushort":
case "Bool32": case "Bool32":
return true; return true;
@@ -1878,6 +1901,10 @@ public static class Program
{ {
return IsPrimitive(dataType.Child); return IsPrimitive(dataType.Child);
} }
else if (dataType.Kind == "LPArray")
{
return IsPrimitive(dataType.Child);
}
if (dataType.Kind != "Native") if (dataType.Kind != "Native")
{ {

View 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));
}
}

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<doc />

File diff suppressed because it is too large Load Diff

View File

@@ -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_SAMPLER_DESCRIPTOR_HEAP_INDEXING = 67108864;
public const uint D3D_SHADER_FEATURE_WAVE_MMA = 134217728; public const uint D3D_SHADER_FEATURE_WAVE_MMA = 134217728;
public const uint D3D_SHADER_FEATURE_ATOMIC_INT64_ON_DESCRIPTOR_HEAP_RESOURCE = 268435456; 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 ref readonly Guid WKPDID_D3DDebugObjectName
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); [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static readonly Guid WKPDID_D3D12UniqueObjectId = new Guid(0x1b39de15, 0xec04, 0x4bae, 0xba, 0x4d, 0x8c, 0xef, 0x79, 0xfc, 0x04, 0xc1); 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_X = 1;
public const uint D3D_COMPONENT_MASK_Y = 2; public const uint D3D_COMPONENT_MASK_Y = 2;
public const uint D3D_COMPONENT_MASK_Z = 4; public const uint D3D_COMPONENT_MASK_Z = 4;
public const uint D3D_COMPONENT_MASK_W = 8; 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 ref readonly Guid D3D_TEXTURE_LAYOUT_ROW_MAJOR
public static readonly Guid D3D_TEXTURE_LAYOUT_64KB_STANDARD_SWIZZLE = new Guid(0x4c0f29e3, 0x3f5f, 0x4d35, 0x84, 0xc9, 0xbc, 0x09, 0x83, 0xb6, 0x2c, 0x28); {
[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 #region Enums
@@ -1073,10 +1211,10 @@ public enum ParameterFlags : int
public partial struct ShaderMacro public partial struct ShaderMacro
{ {
/// <include file='../Direct3D.xml' path='doc/member[@name="D3D_SHADER_MACRO::Name"]/*' /> /// <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"]/*' /> /// <include file='../Direct3D.xml' path='doc/member[@name="D3D_SHADER_MACRO::Definition"]/*' />
public unsafe byte* Definition; public unsafe sbyte* Definition;
} }
#endregion Structs #endregion Structs
@@ -1249,9 +1387,9 @@ public unsafe partial struct ID3DInclude
/// <include file='../Direct3D.xml' path='doc/member[@name="ID3DInclude::Open"]/*' /> /// <include file='../Direct3D.xml' path='doc/member[@name="ID3DInclude::Open"]/*' />
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
[VtblIndex(0)] [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"]/*' /> /// <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

View File

@@ -24,10 +24,102 @@ public static partial class Apis
public const uint DXGI_SHARED_RESOURCE_READ = 2147483648; public const uint DXGI_SHARED_RESOURCE_READ = 2147483648;
public const uint DXGI_SHARED_RESOURCE_WRITE = 1; public const uint DXGI_SHARED_RESOURCE_WRITE = 1;
public const uint DXGI_DEBUG_BINARY_VERSION = 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 ref readonly Guid DXGI_DEBUG_ALL
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); [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static readonly Guid DXGI_DEBUG_APP = new Guid(0x06cd6e01, 0x4219, 0x4ebd, 0x87, 0x09, 0x27, 0xed, 0x23, 0x36, 0x0c, 0x62); 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_MESSAGE_ID_STRING_FROM_APPLICATION = 0;
public const uint DXGI_INFO_QUEUE_DEFAULT_MESSAGE_COUNT_LIMIT = 1024; public const uint DXGI_INFO_QUEUE_DEFAULT_MESSAGE_COUNT_LIMIT = 1024;
public const uint DXGI_CREATE_FACTORY_DEBUG = 1; 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"]/*' /> /// <include file='../Dxgi.xml' path='doc/member[@name="IDXGIResource1::CreateSharedHandle"]/*' />
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
[VtblIndex(13)] [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"]/*' /> /// <include file='../Dxgi.xml' path='doc/member[@name="IDXGIInfoQueue::AddMessage"]/*' />
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
[VtblIndex(30)] [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"]/*' /> /// <include file='../Dxgi.xml' path='doc/member[@name="IDXGIInfoQueue::AddApplicationMessage"]/*' />
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
[VtblIndex(31)] [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"]/*' /> /// <include file='../Dxgi.xml' path='doc/member[@name="IDXGIInfoQueue::SetBreakOnCategory"]/*' />

View 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);
}
}

View File

@@ -12,6 +12,8 @@ using MessageId = Win32.Graphics.Direct3D11.MessageId;
using InfoQueueFilter = Win32.Graphics.Direct3D11.InfoQueueFilter; using InfoQueueFilter = Win32.Graphics.Direct3D11.InfoQueueFilter;
using Win32.Graphics.Dxgi.Common; using Win32.Graphics.Dxgi.Common;
using System.Numerics; using System.Numerics;
using Win32.Graphics.Direct3D.Dxc;
using static Win32.Graphics.Direct3D.Dxc.Apis;
namespace ClearScreen; namespace ClearScreen;
@@ -37,8 +39,16 @@ public static unsafe class Program
} }
#endif #endif
private static void TestDxc()
{
using ComPtr<IDxcCompiler3> compiler = default;
DxcCreateInstance(CLSID_DxcCompiler, __uuidof<IDxcCompiler3>(), compiler.GetVoidAddressOf());
}
public static void Main() public static void Main()
{ {
TestDxc();
using ComPtr<IDXGIFactory2> factory = default; using ComPtr<IDXGIFactory2> factory = default;
uint factoryFlags = 0; uint factoryFlags = 0;