Skip to content

Commit d73aade

Browse files
committed
Remove constants that are marked as deprecated aliases
These only seem to exist for Vulkan currently. For Vulkan: These represent misnamed constants that have now been renamed to be consistent with the rest of the Vulkan spec. For Silk: These misnamed constants and their corrected variants cause name collisions when names are prettified (thus leading to compile errors) and cause common prefix determination for enum member names to be more pessimistic (thus leading to longer names). For users: Removing these aliases can induce more API breaks, but because these are aliases and always have an alternative, API breaks are simple to fix. Removing these aliases also makes it clearer which variant is the correct variant to use.
1 parent bdfd3c8 commit d73aade

16 files changed

+123
-222
lines changed

.silktouch/ac001027d53000e0.stout

0 Bytes
Binary file not shown.

.silktouch/bdd42329798b2360.stout

1.83 MB
Binary file not shown.

eng/silktouch/vulkan/vulkan/generate.rsp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,6 @@
22
@../remap.rsp
33
--exclude
44
VK_NULL_HANDLE
5-
VK_GOOGLE_HLSL_FUNCTIONALITY1_EXTENSION_NAME
6-
VK_GOOGLE_HLSL_FUNCTIONALITY1_SPEC_VERSION
7-
VK_KHR_MAINTENANCE1_EXTENSION_NAME
8-
VK_KHR_MAINTENANCE1_SPEC_VERSION
9-
VK_KHR_MAINTENANCE2_EXTENSION_NAME
10-
VK_KHR_MAINTENANCE2_SPEC_VERSION
11-
VK_KHR_MAINTENANCE3_EXTENSION_NAME
12-
VK_KHR_MAINTENANCE3_SPEC_VERSION
13-
VK_NV_VIEWPORT_ARRAY2_EXTENSION_NAME
14-
VK_NV_VIEWPORT_ARRAY2_SPEC_VERSION
15-
VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES2_EXT
165
--file
176
vulkan-vulkan.h
187
--methodClassName

sources/SilkTouch/SilkTouch/Mods/MixKhronosData.cs

Lines changed: 63 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,18 @@ public Dictionary<
121121
/// modifying the original configuration object. It is used in the same way.
122122
/// </summary>
123123
public Dictionary<string, string> TypeMap { get; init; } = [];
124+
125+
/// <summary>
126+
/// This tracks a set of enum members marked with the deprecated="aliased" attribute.
127+
/// These are removed from the generated bindings.
128+
/// </summary>
129+
/// <remarks>
130+
/// At the time this was added, only Vulkan seems to use the deprecated="aliased" attribute.
131+
/// These names tend to cause name collisions after names are prettified so removing these
132+
/// prevents these issues. This can cause API breakages, but because these are aliases,
133+
/// these are easily solvable breakages.
134+
/// </remarks>
135+
public HashSet<string> DeprecatedAliases = [];
124136
}
125137

126138
/// <summary>
@@ -259,6 +271,7 @@ public async Task InitializeAsync(IModContext ctx, CancellationToken ct = defaul
259271
job.SupportedApiProfiles = supportedApiProfiles;
260272

261273
var profiles = supportedApiProfiles.SelectMany(x => x.Value).Select(x => x.Profile).ToHashSet();
274+
262275
job.Vendors =
263276
[
264277
.. xml.Element("registry")
@@ -281,6 +294,10 @@ .. xml.Element("registry")
281294
.Select(name => name.Value.Split('_')[1].ToUpper()) ?? Enumerable.Empty<string>()
282295
];
283296

297+
job.DeprecatedAliases = xml.Descendants()
298+
.Where(x => x.Attribute("deprecated")?.Value == "aliased" && x.Attribute("name") != null)
299+
.Select(x => x.Attribute("name")!.Value).ToHashSet();
300+
284301
ReadGroups(xml, job, job.Vendors);
285302

286303
foreach (var typeElement in xml.Elements("registry").Elements("types").Elements("type"))
@@ -303,7 +320,7 @@ public async Task ExecuteAsync(IModContext ctx, CancellationToken ct = default)
303320
var proj = ctx.SourceProject;
304321

305322
// Rewrite phase 1
306-
var rewriter1 = new EnumRewriterPhase1(jobData, logger);
323+
var rewriter1 = new RewriterPhase1(jobData, logger);
307324
foreach (var docId in proj?.DocumentIds ?? [])
308325
{
309326
var doc = proj!.GetDocument(docId) ?? throw new InvalidOperationException("Document missing");
@@ -326,7 +343,7 @@ public async Task ExecuteAsync(IModContext ctx, CancellationToken ct = default)
326343
}
327344

328345
// Rewrite phase 2
329-
var rewriter2 = new EnumRewriterPhase2(jobData, rewriter1);
346+
var rewriter2 = new RewriterPhase2(jobData, rewriter1);
330347
foreach (var docId in proj?.DocumentIds ?? [])
331348
{
332349
var doc = proj!.GetDocument(docId) ?? throw new InvalidOperationException("Document missing");
@@ -1694,14 +1711,16 @@ jobKey is null
16941711
private static partial Regex EndingsNotToTrim();
16951712

16961713
/// <summary>
1714+
/// This rewriter focuses on adding missing enums.
1715+
/// <para/>
16971716
/// Extracts enum constants that are defined as fields and moves them to their actual enum types.
16981717
/// Begins renaming FlagBits enums to Flags.
16991718
/// </summary>
17001719
/// <remarks>
17011720
/// This rewriter is split into two phases because NamespaceFromSyntaxNode breaks due to
17021721
/// the FieldDeclarationSyntax being modified.
17031722
/// </remarks>
1704-
private class EnumRewriterPhase1(JobData job, ILogger logger) : CSharpSyntaxRewriter
1723+
private class RewriterPhase1(JobData job, ILogger logger) : CSharpSyntaxRewriter
17051724
{
17061725
/// <summary>
17071726
/// Tracks enum groups that already exist in the project, prior to the generation of missing enums.
@@ -1927,15 +1946,24 @@ private class EnumRewriterPhase1(JobData job, ILogger logger) : CSharpSyntaxRewr
19271946
/// Finishes renaming FlagBits enums to Flags.
19281947
/// Marks bitmask enums with the [Flags] attribute.
19291948
/// Replaces uint/ulong with the actual enum type for FlagBits/Flags types.
1949+
/// Removes deprecated aliases.
19301950
/// </summary>
1931-
private class EnumRewriterPhase2(JobData job, EnumRewriterPhase1 phase1) : CSharpSyntaxRewriter(true)
1951+
private class RewriterPhase2(JobData job, RewriterPhase1 phase1) : CSharpSyntaxRewriter(true)
19321952
{
19331953
public override SyntaxNode? VisitIdentifierName(IdentifierNameSyntax node) => IdentifierName(node.Identifier.ToString().Replace("FlagBits", "Flags"));
19341954

19351955
public override SyntaxNode? VisitEnumDeclaration(EnumDeclarationSyntax node)
19361956
{
19371957
var identifier = node.Identifier.ToString();
19381958

1959+
if (node.Members.Any(m => job.DeprecatedAliases.Contains(m.Identifier.ValueText)))
1960+
{
1961+
// Remove deprecated aliases
1962+
node = node.WithMembers([
1963+
..node.Members.Where(m => !job.DeprecatedAliases.Contains(m.Identifier.ValueText))
1964+
]);
1965+
}
1966+
19391967
if (job.Groups.TryGetValue(identifier, out var group) && group.KnownBitmask)
19401968
{
19411969
// Add [Flags] attribute
@@ -1951,22 +1979,47 @@ private class EnumRewriterPhase2(JobData job, EnumRewriterPhase1 phase1) : CShar
19511979

19521980
public override SyntaxNode? VisitFieldDeclaration(FieldDeclarationSyntax node)
19531981
{
1954-
if (!TryGetManagedEnumType(node.AttributeLists, out var managedName))
1982+
if (node.Declaration.Variables.Any(v => job.DeprecatedAliases.Contains(v.Identifier.ValueText)))
19551983
{
1956-
return base.VisitFieldDeclaration(node);
1984+
// Remove deprecated aliases
1985+
node = node.WithDeclaration(node.Declaration.WithVariables([
1986+
..node.Declaration.Variables.Where(v => !job.DeprecatedAliases.Contains(v.Identifier.ValueText))
1987+
]));
1988+
1989+
if (node.Declaration.Variables.Count == 0)
1990+
{
1991+
return null;
1992+
}
1993+
}
1994+
1995+
if (TryGetManagedEnumType(node.AttributeLists, out var managedName))
1996+
{
1997+
node = node.WithDeclaration(node.Declaration.WithType(ParseTypeName(managedName)));
1998+
}
1999+
2000+
return base.VisitFieldDeclaration(node);
2001+
2002+
}
2003+
2004+
public override SyntaxNode? VisitPropertyDeclaration(PropertyDeclarationSyntax node)
2005+
{
2006+
if (job.DeprecatedAliases.Contains(node.Identifier.ValueText))
2007+
{
2008+
return null;
19572009
}
19582010

1959-
return base.VisitFieldDeclaration(node.WithDeclaration(node.Declaration.WithType(ParseTypeName(managedName))));
2011+
return base.VisitPropertyDeclaration(node);
19602012
}
19612013

19622014
public override SyntaxNode? VisitParameter(ParameterSyntax node)
19632015
{
1964-
if (!TryGetManagedEnumType(node.AttributeLists, out var managedName))
2016+
if (TryGetManagedEnumType(node.AttributeLists, out var managedName))
19652017
{
1966-
return base.VisitParameter(node);
2018+
node = node.WithType(ParseTypeName(managedName));
19672019
}
19682020

1969-
return base.VisitParameter(node.WithType(ParseTypeName(managedName)));
2021+
return base.VisitParameter(node);
2022+
19702023
}
19712024

19722025
/// <summary>

sources/Vulkan/Vulkan/Enums/PipelineStageFlags2.gen.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ public enum PipelineStageFlags2 : ulong
8383
TaskShaderBitEXT = unchecked((ulong)0x00080000UL),
8484
MeshShaderBitEXT = unchecked((ulong)0x00100000UL),
8585
SubpassShaderBitHuawei = unchecked((ulong)0x8000000000UL),
86-
SubpassShadingBitHuawei = unchecked((ulong)0x8000000000UL),
8786
InvocationMaskBitHuawei = unchecked((ulong)0x10000000000UL),
8887
AccelerationStructureCopyBitKHR = unchecked((ulong)0x10000000UL),
8988
MicromapBuildBitEXT = unchecked((ulong)0x40000000UL),

sources/Vulkan/Vulkan/Vulkan/ColorSpaceKHR.gen.cs

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,105 +14,105 @@ namespace Silk.NET.Vulkan;
1414
public enum ColorSpaceKHR : uint
1515
{
1616
[SupportedApiProfile("vulkan", ["VK_KHR_surface"])]
17-
ColorSpaceSrgbNonlinearKHR = 0,
17+
SrgbNonlinearKHR = 0,
1818

1919
[SupportedApiProfile(
2020
"vulkan",
2121
["VK_EXT_swapchain_colorspace"],
2222
ImpliesSets = ["VK_KHR_surface"]
2323
)]
24-
ColorSpaceDisplayP3NonlinearEXT = 1000104001,
24+
DisplayP3NonlinearEXT = 1000104001,
2525

2626
[SupportedApiProfile(
2727
"vulkan",
2828
["VK_EXT_swapchain_colorspace"],
2929
ImpliesSets = ["VK_KHR_surface"]
3030
)]
31-
ColorSpaceExtendedSrgbLinearEXT = 1000104002,
31+
ExtendedSrgbLinearEXT = 1000104002,
3232

3333
[SupportedApiProfile(
3434
"vulkan",
3535
["VK_EXT_swapchain_colorspace"],
3636
ImpliesSets = ["VK_KHR_surface"]
3737
)]
38-
ColorSpaceDisplayP3LinearEXT = 1000104003,
38+
DisplayP3LinearEXT = 1000104003,
3939

4040
[SupportedApiProfile(
4141
"vulkan",
4242
["VK_EXT_swapchain_colorspace"],
4343
ImpliesSets = ["VK_KHR_surface"]
4444
)]
45-
ColorSpaceDciP3NonlinearEXT = 1000104004,
45+
DciP3NonlinearEXT = 1000104004,
4646

4747
[SupportedApiProfile(
4848
"vulkan",
4949
["VK_EXT_swapchain_colorspace"],
5050
ImpliesSets = ["VK_KHR_surface"]
5151
)]
52-
ColorSpaceBt709LinearEXT = 1000104005,
52+
Bt709LinearEXT = 1000104005,
5353

5454
[SupportedApiProfile(
5555
"vulkan",
5656
["VK_EXT_swapchain_colorspace"],
5757
ImpliesSets = ["VK_KHR_surface"]
5858
)]
59-
ColorSpaceBt709NonlinearEXT = 1000104006,
59+
Bt709NonlinearEXT = 1000104006,
6060

6161
[SupportedApiProfile(
6262
"vulkan",
6363
["VK_EXT_swapchain_colorspace"],
6464
ImpliesSets = ["VK_KHR_surface"]
6565
)]
66-
ColorSpaceBt2020LinearEXT = 1000104007,
66+
Bt2020LinearEXT = 1000104007,
6767

6868
[SupportedApiProfile(
6969
"vulkan",
7070
["VK_EXT_swapchain_colorspace"],
7171
ImpliesSets = ["VK_KHR_surface"]
7272
)]
73-
ColorSpaceHdr10St2084EXT = 1000104008,
73+
Hdr10St2084EXT = 1000104008,
7474

7575
[SupportedApiProfile(
7676
"vulkan",
7777
["VK_EXT_swapchain_colorspace"],
7878
ImpliesSets = ["VK_KHR_surface"]
7979
)]
80-
ColorSpaceDolbyvisionEXT = 1000104009,
80+
DolbyvisionEXT = 1000104009,
8181

8282
[SupportedApiProfile(
8383
"vulkan",
8484
["VK_EXT_swapchain_colorspace"],
8585
ImpliesSets = ["VK_KHR_surface"]
8686
)]
87-
ColorSpaceHdr10HlgEXT = 1000104010,
87+
Hdr10HlgEXT = 1000104010,
8888

8989
[SupportedApiProfile(
9090
"vulkan",
9191
["VK_EXT_swapchain_colorspace"],
9292
ImpliesSets = ["VK_KHR_surface"]
9393
)]
94-
ColorSpaceAdobergbLinearEXT = 1000104011,
94+
AdobergbLinearEXT = 1000104011,
9595

9696
[SupportedApiProfile(
9797
"vulkan",
9898
["VK_EXT_swapchain_colorspace"],
9999
ImpliesSets = ["VK_KHR_surface"]
100100
)]
101-
ColorSpaceAdobergbNonlinearEXT = 1000104012,
101+
AdobergbNonlinearEXT = 1000104012,
102102

103103
[SupportedApiProfile(
104104
"vulkan",
105105
["VK_EXT_swapchain_colorspace"],
106106
ImpliesSets = ["VK_KHR_surface"]
107107
)]
108-
ColorSpacePassThroughEXT = 1000104013,
108+
PassThroughEXT = 1000104013,
109109

110110
[SupportedApiProfile(
111111
"vulkan",
112112
["VK_EXT_swapchain_colorspace"],
113113
ImpliesSets = ["VK_KHR_surface"]
114114
)]
115-
ColorSpaceExtendedSrgbNonlinearEXT = 1000104014,
115+
ExtendedSrgbNonlinearEXT = 1000104014,
116116

117117
[SupportedApiProfile(
118118
"vulkan",
@@ -122,15 +122,5 @@ public enum ColorSpaceKHR : uint
122122
"VK_KHR_get_surface_capabilities2+VK_KHR_swapchain+VK_VERSION_1_1",
123123
]
124124
)]
125-
ColorSpaceDisplayNativeAMD = 1000213000,
126-
127-
[SupportedApiProfile("vulkan", ["VK_KHR_surface"])]
128-
ColorspaceSrgbNonlinearKHR = ColorSpaceSrgbNonlinearKHR,
129-
130-
[SupportedApiProfile(
131-
"vulkan",
132-
["VK_EXT_swapchain_colorspace"],
133-
ImpliesSets = ["VK_KHR_surface"]
134-
)]
135-
ColorSpaceDciP3LinearEXT = ColorSpaceDisplayP3LinearEXT,
125+
DisplayNativeAMD = 1000213000,
136126
}

sources/Vulkan/Vulkan/Vulkan/DebugReportObjectTypeEXT.gen.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,6 @@ public enum DebugReportObjectTypeEXT : uint
176176
)]
177177
BufferCollectionFuchsiaEXT = 1000366000,
178178

179-
[SupportedApiProfile("vulkan", ["VK_EXT_debug_report"])]
180-
DebugReportEXT = DebugReportCallbackExtEXT,
181-
182-
[SupportedApiProfile("vulkan", ["VK_EXT_debug_report"])]
183-
ValidationCacheEXT = ValidationCacheExtEXT,
184-
185179
[SupportedApiProfile(
186180
"vulkan",
187181
["VK_EXT_debug_report", "VK_KHR_descriptor_update_template"],

sources/Vulkan/Vulkan/Vulkan/Format.gen.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2292,17 +2292,6 @@ public enum Format : uint
22922292
)]
22932293
A4B4G4R4UnormPack16EXT = A4B4G4R4UnormPack16,
22942294

2295-
[SupportedApiProfile(
2296-
"vulkan",
2297-
["VK_NV_optical_flow"],
2298-
ImpliesSets = [
2299-
"VK_KHR_format_feature_flags2+VK_KHR_synchronization2+VK_KHR_get_physical_device_properties2",
2300-
"VK_KHR_format_feature_flags2+VK_KHR_synchronization2+VK_VERSION_1_1",
2301-
"VK_VERSION_1_3",
2302-
]
2303-
)]
2304-
R16G16S10X5NV = R16G16Sfixed5NV,
2305-
23062295
[SupportedApiProfile(
23072296
"vulkan",
23082297
["VK_KHR_maintenance5"],

0 commit comments

Comments
 (0)