Skip to content

Commit d86e127

Browse files
committed
Exclude vendors that only have disabled extensions
1 parent d8986f0 commit d86e127

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

sources/SilkTouch/SilkTouch/Mods/MixKhronosData.cs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,12 @@ public async Task InitializeAsync(IModContext ctx, CancellationToken ct = defaul
253253
logger.LogInformation("Reading Khronos XML from \"{}\"...", specPath);
254254
await using var fs = File.OpenRead(specPath);
255255
var xml = await XDocument.LoadAsync(fs, LoadOptions.None, default);
256+
256257
var (apiSets, supportedApiProfiles) = EvaluateProfiles(xml);
258+
job.ApiSets = apiSets;
259+
job.SupportedApiProfiles = supportedApiProfiles;
260+
261+
var profiles = supportedApiProfiles.SelectMany(x => x.Value).Select(x => x.Profile).ToHashSet();
257262
job.Vendors =
258263
[
259264
.. xml.Element("registry")
@@ -264,12 +269,20 @@ .. xml.Element("registry")
264269
.. xml.Element("registry")
265270
?.Element("extensions")
266271
?.Elements("extension")
272+
// Only include vendors who have extensions that match a declared profile
273+
// This is mainly to exclude extensions that are declared as supported="disabled"
274+
.Where(ext => {
275+
var supportedProfiles = ext.Attribute("supported")?.Value.Split("|") ?? [];
276+
return profiles.Intersect(supportedProfiles).Any();
277+
})
267278
.Attributes("name")
268-
.Select(x => x.Value.Split('_')[1].ToUpper()) ?? Enumerable.Empty<string>()
279+
// Extract the second part from the extension name
280+
// Eg: GL_NV_command_list -> NV
281+
.Select(name => name.Value.Split('_')[1].ToUpper()) ?? Enumerable.Empty<string>()
269282
];
270-
job.ApiSets = apiSets;
271-
job.SupportedApiProfiles = supportedApiProfiles;
283+
272284
ReadGroups(xml, job, job.Vendors);
285+
273286
foreach (var typeElement in xml.Elements("registry").Elements("types").Elements("type"))
274287
{
275288
var type = typeElement.Element("name")?.Value;

0 commit comments

Comments
 (0)