mirror of
https://github.com/amerkoleci/Vortice.Win32.git
synced 2026-01-14 16:16:04 +08:00
More generation improvements.
This commit is contained in:
@@ -1,12 +1,7 @@
|
||||
// Copyright © Amer Koleci and Contributors.
|
||||
// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information.
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Xml;
|
||||
using MessagePack;
|
||||
using Microsoft.Windows.SDK.Win32Docs;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Generator;
|
||||
@@ -84,12 +79,43 @@ public static class Program
|
||||
{ "DXGI_HARDWARE_COMPOSITION_SUPPORT_FLAGS", "DXGI_HARDWARE_COMPOSITION_SUPPORT_FLAG" },
|
||||
{ "DXGI_DEBUG_RLO_FLAGS", "DXGI_DEBUG_RLO" },
|
||||
{ "DXGI_OFFER_RESOURCE_FLAGS", "DXGI_OFFER_RESOURCE_FLAG" },
|
||||
|
||||
// D3D
|
||||
{ "D3D_INTERPOLATION_MODE", "D3D_INTERPOLATION" },
|
||||
{ "D3D_PARAMETER_FLAGS", "D3D" },
|
||||
{ "D3D_TESSELLATOR_OUTPUT_PRIMITIVE", "D3D_TESSELLATOR_OUTPUT" },
|
||||
{ "D3D_REGISTER_COMPONENT_TYPE", "D3D_REGISTER_COMPONENT" },
|
||||
{ "D3D_RESOURCE_RETURN_TYPE", "D3D_RETURN_TYPE" },
|
||||
};
|
||||
|
||||
private static readonly Dictionary<string, string> s_partRenames = new()
|
||||
{
|
||||
{ "NONPREROTATED", "NonPrerotated" },
|
||||
{ "POINTLIST", "PointList" },
|
||||
{ "LINELIST", "LineList" },
|
||||
{ "LINESTRIP", "LineStrip" },
|
||||
{ "TRIANGLELIST", "TriangleList" },
|
||||
{ "TRIANGLESTRIP", "TriangleStrip" },
|
||||
{ "PATCHLIST", "PatchList" },
|
||||
|
||||
{ "NOPERSPECTIVE", "NoPerspective" },
|
||||
{ "TEXTURE1D", "Texture1D" },
|
||||
{ "TEXTURE1DARRAY", "Texture1DArray" },
|
||||
{ "TEXTURE2D", "Texture2D" },
|
||||
{ "TEXTURE2DARRAY", "Texture2DArray" },
|
||||
{ "TEXTURE2DMS", "Texture2DMs" },
|
||||
{ "TEXTURE2DMSARRAY", "Texture2DMsArray" },
|
||||
{ "TEXTURE3D", "Texture3D" },
|
||||
{ "TEXTURECUBE", "TextureCube" },
|
||||
{ "TEXTURECUBEARRAY", "TextureCubeArray" },
|
||||
{ "BUFFEREX", "BufferExtended" },
|
||||
};
|
||||
|
||||
private static readonly Dictionary<string, string> s_knownEnumValueNames = new()
|
||||
{
|
||||
{ "DXGI_FORMAT_420_OPAQUE", "Opaque420" },
|
||||
{ "DXGI_OUTDUPL_COMPOSITED_UI_CAPTURE_ONLY", "CompositedUICaptureOnly" },
|
||||
{ "D3D_FEATURE_LEVEL_9_1", "Level_9_1" },
|
||||
};
|
||||
|
||||
private static readonly Dictionary<string, bool> s_generatedEnums = new()
|
||||
@@ -105,7 +131,10 @@ public static class Program
|
||||
private static readonly HashSet<string> s_ignoredParts = new(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
"DXGI",
|
||||
"D3D"
|
||||
"D3D",
|
||||
"D3D10",
|
||||
"D3D11",
|
||||
"PF" // D3D_PF_
|
||||
};
|
||||
|
||||
private static readonly HashSet<string> s_preserveCaps = new(StringComparer.OrdinalIgnoreCase)
|
||||
@@ -399,10 +428,26 @@ public static class Program
|
||||
{
|
||||
if (value.Name.EndsWith("_FORCE_DWORD") ||
|
||||
value.Name.EndsWith("_FORCE_UINT"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Ignore D3D10 and D3D11 in D3D
|
||||
if (enumType.Name.StartsWith("D3D_"))
|
||||
{
|
||||
if (value.Name.StartsWith("D3D10_") ||
|
||||
value.Name.StartsWith("D3D11_"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
string enumValueName = GetPrettyFieldName(value.Name, enumPrefix);
|
||||
|
||||
if (enumType.Name == "D3D_PRIMITIVE_TOPOLOGY")
|
||||
{
|
||||
}
|
||||
|
||||
if (!autoGenerated)
|
||||
{
|
||||
writer.WriteLine($"/// <include file='../{writer.DocFileName}.xml' path='doc/member[@name=\"{enumType.Name}::{value.Name}\"]/*' />");
|
||||
@@ -888,15 +933,36 @@ public static class Program
|
||||
return value;
|
||||
}
|
||||
|
||||
bool isFeatureLevel = enumPrefix == "D3D_FEATURE_LEVEL";
|
||||
bool isDXGIFormat = enumPrefix == "DXGI_FORMAT";
|
||||
|
||||
string[] parts = value[enumPrefix.Length..].Split(new[] { '_' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
var sb = new StringBuilder();
|
||||
StringBuilder sb = new();
|
||||
|
||||
bool appendUnderscore = false;
|
||||
if (isFeatureLevel)
|
||||
{
|
||||
sb.Append("Level").Append('_');
|
||||
appendUnderscore = true;
|
||||
}
|
||||
else if (enumPrefix == "D3D_PRIMITIVE_TOPOLOGY"
|
||||
&& value.EndsWith("_CONTROL_POINT_PATCHLIST"))
|
||||
{
|
||||
sb.Append('P');
|
||||
}
|
||||
else if (enumPrefix == "D3D_PRIMITIVE"
|
||||
&& value.EndsWith("_CONTROL_POINT_PATCH"))
|
||||
{
|
||||
sb.Append('P');
|
||||
}
|
||||
|
||||
int partIndex = 0;
|
||||
foreach (string part in parts)
|
||||
{
|
||||
if (s_ignoredParts.Contains(part))
|
||||
{
|
||||
partIndex++;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -979,9 +1045,9 @@ public static class Program
|
||||
}
|
||||
else
|
||||
{
|
||||
if (part.Equals("NONPREROTATED", StringComparison.OrdinalIgnoreCase))
|
||||
if (s_partRenames.TryGetValue(part, out string? partRemap))
|
||||
{
|
||||
sb.Append("NonPrerotated");
|
||||
sb.Append(partRemap!);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -993,6 +1059,16 @@ public static class Program
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (appendUnderscore)
|
||||
{
|
||||
if (partIndex < parts.Length - 1)
|
||||
{
|
||||
sb.Append('_');
|
||||
}
|
||||
|
||||
partIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
string prettyName = sb.ToString();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user