setDepthClipMode: and setTriangleFillMode: refused every value but Metal's defaults
(DrawKind::DepthClamp, DrawKind::FillMode). Vulkan 1.3 bakes both in
VkPipelineRasterizationStateCreateInfo, and only VK_EXT_extended_dynamic_state3 makes them
dynamic. The floor cannot require that extension: the UHD 630's Windows driver lists no EDS3, and
KosmicKrisp reports extendedDynamicState3PolygonMode false. So both are now first-use pipeline
variants, the accepted form. The encoder keeps a Raster (clamp, lines) and each draw takes
RenderCompiled::pipeline(topology, raster). The content keeps its primary VkPipeline (the triangle
or patch class at the default state) and a bounded list of the others, by class list topology and
raster state: at most 7 (three more states of the triangle or patch class, two of each other
class). The line and point classes take the clip mode alone, since Metal and Vulkan apply the fill
mode to triangles only. A triangle's edges under Lines chain Bresenham's rule, as the line class
does ("the effective rasterization input topology is in the line topology class"). The first draw
under a state makes its pipeline and waits for it: a first-use wait of a new site,
FirstUse::Raster (Metrics::first_use_raster_waits, _nanos, _max_nanos). The line and point
classes' first draws at the default state count where they did.
Floor:
- depthClamp joins REQUIRED, and the translator is told (=> DepthClamp), so the encoder maps the
mode through metal::state::depth_clamp_enable. Vulkan 1.4 and Roadmap 2022 require it. The venue
dumps report it true on every venue: m3-max-48727, 48728, 48729, 48730, 48731, 48736, 48737 and
61508. tests/floor.rs, the README floor table, RUNTIME_FLOOR and profiles/runtime-floor.json
add it.
- fillModeNonSolid is enabled where reported (FILL_MODES, told to the translator), and the setter
maps Lines through metal::state::polygon_mode. KosmicKrisp on the M3 Max reports it false
(m3-max-48737); every other dumped venue reports it true. There Lines stays DrawKind::FillMode,
and so does the raw value 2, which no SDK header declares.
DrawKind::DepthClamp is deleted. The consumer's checkout names it nowhere (git grep in
reims-vgpu: 0 hits). Its only call sites are set_triangle_fill_mode and set_depth_clip_mode at
crates/reims-vgpu-vulkan/src/rt_platform/render.rs:371 and :374, whose signatures are unchanged.
The translator's raster-state test reads runtime-floor, which now states depthClamp. Clamp maps
there, and the refusal is asserted on runtime-floor without it, as ab8277a560 did for
depthBiasClamp. Other translator tests that read runtime-floor were grepped for DepthClamp and
FillModeNonSolid, and none reads the floor as lacking them.
Known gaps (README): a content's first draw under Clamp or Lines makes a VkPipeline, which Metal
does not. Under Clamp the depth a fragment function writes is the device's clamp's: Metal stores a
negative NaN as 0 below a range above 0, and the translator's depth_clamp_range variant is not
drawn.
Conformance: render-state-depth-clip and render-state-facing leave known-gaps-rt.tsv;
CONFORMANCE-COVERAGE.md regenerated. Docs: README (encoder, first-use waits, floor and fill-mode
tables, known gaps), REFUSALS.md, the api_signatures table (3 Metrics fields, 1 variant gone).
Tests:
- tests/raster.rs: a triangle in front of the near plane draws nothing under Clip and every
texel under Clamp (twice: one pipeline made). Under Lines, through a viewport half a pixel
right of and above the corner, the triangle draws its two edges inside the target, column 0
and row 7, and nothing inside. Without fillModeNonSolid it is FillMode and fills. Pipelines
made, raster first-use waits and first-use waits are each 1 + fillModeNonSolid.
- draw.rs: setting both modes makes no pipeline when no draw follows.
- floor.rs: depthClamp's missing case, and the fill-mode feature enabled where reported.
- first_use_sites.rs: the raster site.
1815 lines
89 KiB
Python
Executable File
1815 lines
89 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Regenerate `crates/metal2vulkan-validation/profiles/*.json` from pinned public sources.
|
|
|
|
Every committed device profile is a Khronos profiles-schema document with exactly one profile,
|
|
named `VP_M2V_<file stem>`, plus a top-level `provenance` object. Sources are pinned by URL and
|
|
SHA-256; nothing is invented. A field the source does not report is absent from the output, and a
|
|
source field this converter cannot represent is listed under `provenance.unmapped` instead of
|
|
being guessed.
|
|
|
|
Source kinds:
|
|
|
|
* `gpuinfo`: a raw vulkan.gpuinfo.org report (`api/v2/getreport.php`), converted to the profiles
|
|
schema with the pinned Vulkan-Headers `vk.xml` for member types, enum names, and flag bits.
|
|
* `khronos`: one profile and the capability blocks it references, extracted verbatim from a pinned
|
|
KhronosGroup/Vulkan-Profiles file. A profile that states no formats of its own defers to its
|
|
core version's Required Format Support tables, so it gets the same format blocks as `derived`
|
|
(Vulkan-Profiles does not encode those tables); one that states formats is kept as is.
|
|
* `derived`: a floor built from a LunarG minimum-requirements profile (`vk12-floor` from the 1.2
|
|
one, `runtime-floor` from the 1.3 one), with features reduced to the unconditional
|
|
`VK_VERSION_1_0..1_N` requirements of `vk.xml`, plus the Vulkan 1.2 specification's Required
|
|
Format Support tables (`required_formats.py`) and the weakest permitted value of each property
|
|
the product reads, and VK_LAYER_KHRONOS_profiles sets, that the base profile leaves without a
|
|
requirement (`UNREQUIRED_PROPERTIES`). `runtime-floor` adds the block `m2v_runtime_floor`
|
|
(`RUNTIME_FLOOR`): the device extensions, features and limits `metal2vulkan-runtime`'s floor
|
|
requires (`crates/metal2vulkan-runtime/src/floor.rs`, which a runtime test holds it equal to).
|
|
* `vulkaninfo`: a local `vulkaninfo --json` capture. The capture opens a device, so it is never
|
|
taken by this script; pass it with `--capture NAME=PATH`. `vulkaninfo --json` never writes
|
|
`VkFormatProperties3`, so a source that declares `formats` also takes that device's
|
|
`corpus-vulkan --capture-formats` supplement (`--formats NAME=PATH`): the
|
|
conversion checks that both files describe one device and that each format's low 32 bits are
|
|
the capture's `VkFormatProperties`, then writes every format's `VkFormatProperties3`. Without a
|
|
capture the committed conversion is kept.
|
|
|
|
Whatever the kind, the last step withholds the members that identify the reporting host or
|
|
driver build (`HOST_IDENTITY`: UUIDs, LUIDs, PCI address, DRM nodes) and names them in
|
|
`provenance.withheld`. A document states no deviation from the specifications: the product
|
|
takes a driver's measured deviations from its release
|
|
(`crates/metal2vulkan/src/device/driver_facts.rs`).
|
|
|
|
Downloads are cached under `.cache/device-profiles/` (gitignored) and verified before use.
|
|
"""
|
|
import argparse
|
|
import copy
|
|
import hashlib
|
|
import json
|
|
import re
|
|
import sys
|
|
import urllib.request
|
|
import xml.etree.ElementTree as ET
|
|
from pathlib import Path
|
|
|
|
import required_formats
|
|
|
|
REPO = Path(__file__).resolve().parents[2]
|
|
OUT_DIR = REPO / "crates" / "metal2vulkan-validation" / "profiles"
|
|
# Where a source marked `below_floor` goes, under the output directory: a description
|
|
# `Device::from_queries` refuses, apart from the committed profiles every test and census reads.
|
|
# Its one reader is the translator's floor refusal test.
|
|
BELOW_FLOOR_DIR = "below-floor"
|
|
CACHE_DIR = REPO / ".cache" / "device-profiles"
|
|
SCHEMA = "https://schema.khronos.org/vulkan/profiles-0.8-latest.json#"
|
|
CONVERTER = "scripts/regen-device-profiles/regen_device_profiles.py"
|
|
# Date recorded in generated profile history. Bump it when regenerated content changes, so that
|
|
# rerunning the script over unchanged sources is byte-identical.
|
|
GENERATED = "2026-09-29"
|
|
|
|
RAW = "https://raw.githubusercontent.com/KhronosGroup/"
|
|
REGISTRY = {
|
|
"url": RAW + "Vulkan-Headers/v1.4.364/registry/vk.xml",
|
|
"sha256": "4cfe3c137f3a95c15275b1cfda0aee407dbf131de2005a3552aa41c49f895c89",
|
|
}
|
|
PROFILES_TAG = RAW + "Vulkan-Profiles/vulkan-sdk-1.4.357.0/profiles/"
|
|
MINIMUM_REQUIREMENTS = {
|
|
"url": PROFILES_TAG + "LunarG/VP_LUNARG_minimum_requirements.json",
|
|
"sha256": "0feaf3db72f398717f1de96d138896b6756934ef8d178d934147de0cd6691e72",
|
|
"profile": "VP_LUNARG_minimum_requirements_1_2",
|
|
}
|
|
GPUINFO_REPORT = "https://vulkan.gpuinfo.org/api/v2/getreport.php?id={}"
|
|
GPUINFO_DISPLAY = "https://vulkan.gpuinfo.org/displayreport.php?id={}"
|
|
|
|
# Properties the product reads at Vulkan 1.2 that the base profile leaves unstated because the
|
|
# specification sets no requirement on them, at the weakest value it permits: the value the
|
|
# product's reader takes for an absent member. A derived profile states them so that
|
|
# VK_LAYER_KHRONOS_profiles, which keeps the device's own value for a member a profile omits,
|
|
# reports the profile as the product reads it. The float-controls independence
|
|
# members are not among them: vk.xml gives them `limittype="exact"`, so the layer never sets them
|
|
# and keeps the device's value whatever a profile states.
|
|
UNREQUIRED_PROPERTIES_BLOCK = "m2v_unrequired_properties"
|
|
UNREQUIRED_PROPERTIES = {
|
|
"VkPhysicalDeviceProperties": {"limits": {"strictLines": False}},
|
|
"VkPhysicalDeviceVulkan11Properties": {"subgroupQuadOperationsInAllStages": False},
|
|
}
|
|
|
|
# The block `runtime-floor` adds to its Vulkan 1.3 base: what metal2vulkan-runtime's floor
|
|
# requires of every device (`crates/metal2vulkan-runtime/src/floor.rs`: `DEVICE_EXTENSIONS`,
|
|
# `REQUIRED` and `limits()`), each limit at the value the floor needs. A runtime test
|
|
# (`the_floor_profile_states_exactly_the_floor`) holds the committed block equal to floor.rs. The
|
|
# floor's queue family, timestamp bits, memory types and time domains have no profiles-schema form
|
|
# and are not stated.
|
|
RUNTIME_FLOOR_BLOCK = "m2v_runtime_floor"
|
|
# The block a `complete_required` derived profile states the core features its version requires
|
|
# and its base profile omits in.
|
|
REQUIRED_FEATURES_BLOCK = "m2v_required_features"
|
|
RUNTIME_FLOOR = {
|
|
"extensions": {
|
|
"VK_KHR_swapchain": 1,
|
|
"VK_EXT_robustness2": 1,
|
|
"VK_EXT_calibrated_timestamps": 1,
|
|
"VK_EXT_line_rasterization": 1,
|
|
},
|
|
"features": {
|
|
"VkPhysicalDeviceFeatures": {member: True for member in (
|
|
"shaderInt64", "shaderSampledImageArrayDynamicIndexing",
|
|
"shaderStorageImageArrayDynamicIndexing", "shaderStorageImageWriteWithoutFormat",
|
|
"shaderStorageImageExtendedFormats", "samplerAnisotropy",
|
|
"shaderImageGatherExtended", "shaderInt16", "independentBlend",
|
|
"fragmentStoresAndAtomics", "alphaToOne", "logicOp", "fullDrawIndexUint32",
|
|
"depthBiasClamp", "drawIndirectFirstInstance", "depthClamp", "shaderClipDistance",
|
|
"tessellationShader", "shaderTessellationAndGeometryPointSize", "largePoints",
|
|
"dualSrcBlend", "sampleRateShading", "vertexPipelineStoresAndAtomics")},
|
|
"VkPhysicalDeviceVulkan11Features": {member: True for member in (
|
|
"storageBuffer16BitAccess", "multiview", "shaderDrawParameters")},
|
|
"VkPhysicalDeviceVulkan12Features": {member: True for member in (
|
|
"bufferDeviceAddress", "runtimeDescriptorArray", "descriptorBindingPartiallyBound",
|
|
"descriptorBindingUpdateUnusedWhilePending",
|
|
"descriptorBindingSampledImageUpdateAfterBind",
|
|
"descriptorBindingStorageImageUpdateAfterBind",
|
|
"shaderSampledImageArrayNonUniformIndexing",
|
|
"shaderStorageImageArrayNonUniformIndexing", "samplerMirrorClampToEdge",
|
|
"shaderInt8", "storageBuffer8BitAccess", "scalarBlockLayout",
|
|
"uniformBufferStandardLayout", "vulkanMemoryModel", "vulkanMemoryModelDeviceScope",
|
|
"shaderSubgroupExtendedTypes", "timelineSemaphore", "hostQueryReset",
|
|
"shaderOutputLayer")},
|
|
"VkPhysicalDeviceVulkan13Features": {member: True for member in (
|
|
"subgroupSizeControl", "computeFullSubgroups", "robustImageAccess",
|
|
"shaderDemoteToHelperInvocation", "shaderTerminateInvocation",
|
|
"shaderZeroInitializeWorkgroupMemory", "synchronization2", "dynamicRendering")},
|
|
"VkPhysicalDeviceRobustness2FeaturesEXT": {"nullDescriptor": True,
|
|
"robustImageAccess2": True},
|
|
"VkPhysicalDeviceLineRasterizationFeaturesEXT": {"bresenhamLines": True},
|
|
},
|
|
"properties": {
|
|
"VkPhysicalDeviceProperties": {"limits": {
|
|
"maxSamplerAllocationCount": 4000,
|
|
"maxPushConstantsSize": 256,
|
|
"maxComputeWorkGroupInvocations": 1024,
|
|
"maxComputeWorkGroupSize": [1024, 1024, 64],
|
|
"timestampComputeAndGraphics": True,
|
|
"standardSampleLocations": True,
|
|
"maxColorAttachments": 8,
|
|
"maxFragmentOutputAttachments": 8,
|
|
}},
|
|
"VkPhysicalDeviceVulkan12Properties": {
|
|
"maxPerStageDescriptorUpdateAfterBindSampledImages": 65536,
|
|
"maxDescriptorSetUpdateAfterBindSampledImages": 65536,
|
|
"maxPerStageDescriptorUpdateAfterBindStorageImages": 65536,
|
|
"maxDescriptorSetUpdateAfterBindStorageImages": 65536,
|
|
"maxPerStageDescriptorUpdateAfterBindSamplers": 12000,
|
|
"maxDescriptorSetUpdateAfterBindSamplers": 12000,
|
|
"maxPerStageUpdateAfterBindResources": 131080,
|
|
"maxUpdateAfterBindDescriptorsInAllPools": 143072,
|
|
},
|
|
},
|
|
}
|
|
|
|
# The block that completes a requirements document (`khronos`) for VK_LAYER_KHRONOS_profiles.
|
|
# A Vulkan-Profiles requirements profile states only what it requires. The product's
|
|
# reader takes a member it omits as its version's guarantee, or as none, and a feature its version
|
|
# requires as present; the layer, restricting a device to it, reports the device's own value for an
|
|
# omitted member of a structure the context queries, and an omitted feature as absent. So a run
|
|
# restricted to the profile would find the device's values, on every device. The block states
|
|
# those members at the values the product reads, so the layer reports the profile as the product
|
|
# reads it, and the product's reading does not change. A source opts in with `layer_presentation`;
|
|
# a requirements document without the block is one validation refuses to restrict a device to.
|
|
LAYER_PRESENTATION_BLOCK = "m2v_layer_presentation"
|
|
|
|
# The members the product reads (src/device/khronos.rs) of the core device-property structures, by
|
|
# vk.xml structure, with the minor version that made each core, at the value its reader takes for
|
|
# an absent member: the version's guarantee (`required_limits`: Vulkan's Required Limits as
|
|
# VP_LUNARG_minimum_requirements_1_2 transcribes them, and maxBufferSize from Vulkan 1.3), else
|
|
# none (0, false, an empty list). A context at a profile's version queries each structure of that
|
|
# version or earlier, so a completed requirements document states each one it omits. Not the
|
|
# device's identity (`noauto`) nor denormBehaviorIndependence and roundingModeIndependence
|
|
# (`exact`): the layer keeps the device's value of each, and validation bounds them.
|
|
# VkPhysicalDeviceVulkan14Properties is not modelled: completing a Vulkan 1.4 document fails.
|
|
FOUR_SAMPLES = ["VK_SAMPLE_COUNT_1_BIT", "VK_SAMPLE_COUNT_4_BIT"]
|
|
FLOAT_CONTROLS = [f"{kind}Float{bits}" for kind in (
|
|
"shaderSignedZeroInfNanPreserve", "shaderDenormPreserve", "shaderDenormFlushToZero",
|
|
"shaderRoundingModeRTE", "shaderRoundingModeRTZ") for bits in (16, 32, 64)]
|
|
CORE_PROPERTIES = {
|
|
"VkPhysicalDeviceProperties": (0, {"limits": {
|
|
"maxImageDimension1D": 4096,
|
|
"maxImageDimension2D": 4096,
|
|
"maxImageDimension3D": 256,
|
|
"maxImageDimensionCube": 4096,
|
|
"maxImageArrayLayers": 256,
|
|
"maxTexelBufferElements": 65536,
|
|
"maxUniformBufferRange": 16384,
|
|
"maxStorageBufferRange": 134217728,
|
|
"maxPushConstantsSize": 128,
|
|
"maxBoundDescriptorSets": 4,
|
|
"maxPerStageDescriptorSamplers": 16,
|
|
"maxPerStageDescriptorUniformBuffers": 12,
|
|
"maxPerStageDescriptorStorageBuffers": 4,
|
|
"maxPerStageDescriptorSampledImages": 16,
|
|
"maxPerStageDescriptorStorageImages": 4,
|
|
"maxPerStageDescriptorInputAttachments": 4,
|
|
"maxPerStageResources": 128,
|
|
"maxDescriptorSetSamplers": 96,
|
|
"maxDescriptorSetUniformBuffers": 72,
|
|
"maxDescriptorSetStorageBuffers": 24,
|
|
"maxDescriptorSetSampledImages": 96,
|
|
"maxDescriptorSetStorageImages": 24,
|
|
"maxDescriptorSetInputAttachments": 4,
|
|
"maxVertexInputAttributes": 16,
|
|
"maxVertexInputBindings": 16,
|
|
"maxVertexInputAttributeOffset": 2047,
|
|
"maxVertexInputBindingStride": 2048,
|
|
"maxVertexOutputComponents": 64,
|
|
"maxTessellationGenerationLevel": 0,
|
|
"maxTessellationEvaluationOutputComponents": 0,
|
|
# 0 without `geometryShader`, which no core version requires.
|
|
"maxGeometryInputComponents": 0,
|
|
"maxGeometryOutputComponents": 0,
|
|
"maxGeometryTotalOutputComponents": 0,
|
|
"maxFragmentInputComponents": 64,
|
|
"maxFragmentOutputAttachments": 4,
|
|
"maxFragmentDualSrcAttachments": 0,
|
|
"maxFragmentCombinedOutputResources": 4,
|
|
"maxComputeSharedMemorySize": 16384,
|
|
"maxComputeWorkGroupCount": [65535, 65535, 65535],
|
|
"maxComputeWorkGroupInvocations": 128,
|
|
"maxComputeWorkGroupSize": [128, 128, 64],
|
|
"maxSamplerLodBias": 2.0,
|
|
"maxSamplerAnisotropy": 1.0,
|
|
"minTexelBufferOffsetAlignment": 256,
|
|
"minUniformBufferOffsetAlignment": 256,
|
|
"minStorageBufferOffsetAlignment": 256,
|
|
"minTexelOffset": -8,
|
|
"maxTexelOffset": 7,
|
|
"minTexelGatherOffset": -8,
|
|
"maxTexelGatherOffset": 7,
|
|
"minInterpolationOffset": 0.0,
|
|
"maxInterpolationOffset": 0.0,
|
|
"framebufferColorSampleCounts": FOUR_SAMPLES,
|
|
"framebufferDepthSampleCounts": FOUR_SAMPLES,
|
|
"framebufferStencilSampleCounts": FOUR_SAMPLES,
|
|
"framebufferNoAttachmentsSampleCounts": FOUR_SAMPLES,
|
|
"maxColorAttachments": 4,
|
|
"storageImageSampleCounts": ["VK_SAMPLE_COUNT_1_BIT"],
|
|
"maxClipDistances": 0,
|
|
"maxCullDistances": 0,
|
|
"maxCombinedClipAndCullDistances": 0,
|
|
"maxFramebufferWidth": 4096,
|
|
"maxFramebufferHeight": 4096,
|
|
"maxFramebufferLayers": 256,
|
|
# 2^32 - 1 where the profile states fullDrawIndexUint32 (FEATURE_EXACT_PROPERTIES).
|
|
"maxDrawIndexedIndexValue": 16777215,
|
|
"maxTessellationPatchSize": 0,
|
|
# Without `largePoints` a device's points are 1.0 (`pointSizeRange` (1.0, 1.0)), the
|
|
# bound the reader takes for an absent range.
|
|
"pointSizeRange": [1.0, 1.0],
|
|
# Without `wideLines` a device's lines are 1.0 (`lineWidthRange` (1.0, 1.0),
|
|
# `lineWidthGranularity` 0.0); subPixelPrecisionBits' guarantee is 4; strictLines none.
|
|
"subPixelPrecisionBits": 4,
|
|
"lineWidthRange": [1.0, 1.0],
|
|
"lineWidthGranularity": 0.0,
|
|
"strictLines": False,
|
|
}}),
|
|
"VkPhysicalDeviceVulkan11Properties": (1, {
|
|
"subgroupSize": 1,
|
|
"subgroupSupportedStages": ["VK_SHADER_STAGE_COMPUTE_BIT"],
|
|
"subgroupSupportedOperations": ["VK_SUBGROUP_FEATURE_BASIC_BIT"],
|
|
"subgroupQuadOperationsInAllStages": False,
|
|
"maxMultiviewViewCount": 0,
|
|
"maxMultiviewInstanceIndex": 0,
|
|
"maxMemoryAllocationSize": 1073741824,
|
|
}),
|
|
"VkPhysicalDeviceVulkan12Properties": (2, {
|
|
**{member: False for member in FLOAT_CONTROLS},
|
|
"maxPerStageDescriptorUpdateAfterBindSamplers": 0,
|
|
"maxPerStageDescriptorUpdateAfterBindSampledImages": 0,
|
|
"maxPerStageDescriptorUpdateAfterBindStorageImages": 0,
|
|
"maxPerStageUpdateAfterBindResources": 0,
|
|
"maxDescriptorSetUpdateAfterBindSamplers": 0,
|
|
"maxDescriptorSetUpdateAfterBindStorageBuffers": 0,
|
|
"maxDescriptorSetUpdateAfterBindSampledImages": 0,
|
|
"maxDescriptorSetUpdateAfterBindStorageImages": 0,
|
|
"robustBufferAccessUpdateAfterBind": False,
|
|
"filterMinmaxSingleComponentFormats": False,
|
|
"framebufferIntegerColorSampleCounts": ["VK_SAMPLE_COUNT_1_BIT"],
|
|
# VkPhysicalDeviceDepthStencilResolveProperties: "VK_RESOLVE_MODE_SAMPLE_ZERO_BIT must be
|
|
# included in the set" of each.
|
|
"supportedDepthResolveModes": ["VK_RESOLVE_MODE_SAMPLE_ZERO_BIT"],
|
|
"supportedStencilResolveModes": ["VK_RESOLVE_MODE_SAMPLE_ZERO_BIT"],
|
|
"independentResolveNone": False,
|
|
"independentResolve": False,
|
|
}),
|
|
"VkPhysicalDeviceVulkan13Properties": (3, {
|
|
"minSubgroupSize": 0,
|
|
"maxSubgroupSize": 0,
|
|
"maxComputeWorkgroupSubgroups": 0,
|
|
"requiredSubgroupSizeStages": [],
|
|
"maxBufferSize": 1073741824,
|
|
}),
|
|
}
|
|
|
|
# The members the product reads (src/device/khronos.rs `PROPERTY_STRUCTS`) of the extension
|
|
# device-property structures beyond core Vulkan 1.2, by vk.xml name, at the value its reader takes
|
|
# for an absent member. A completed requirements document that lists the extension states each one
|
|
# it omits.
|
|
EXTENSION_PROPERTIES = {
|
|
"VkPhysicalDeviceSubgroupSizeControlProperties": {
|
|
"minSubgroupSize": 0,
|
|
"maxSubgroupSize": 0,
|
|
"maxComputeWorkgroupSubgroups": 0,
|
|
"requiredSubgroupSizeStages": [],
|
|
},
|
|
"VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT": {"maxVertexAttribDivisor": 0},
|
|
"VkPhysicalDeviceMaintenance5Properties": {"nonStrictWideLinesUseParallelogram": False},
|
|
"VkPhysicalDeviceSampleLocationsPropertiesEXT": {
|
|
"sampleLocationSampleCounts": [],
|
|
"variableSampleLocations": False,
|
|
},
|
|
}
|
|
|
|
# Core device-property members whose value a feature the profile states makes exact, by vk.xml
|
|
# structure and member, with the feature and that value. Where the profile states the feature
|
|
# true and omits the member, its presentation states this value, as the product's reader takes it
|
|
# (src/device/khronos.rs `Merged::describe`), in place of CORE_PROPERTIES' guarantee.
|
|
# "If this feature is supported, maxDrawIndexedIndexValue must be 2^32-1" (fullDrawIndexUint32).
|
|
FEATURE_EXACT_PROPERTIES = {
|
|
("VkPhysicalDeviceProperties", "maxDrawIndexedIndexValue"):
|
|
("fullDrawIndexUint32", 4294967295),
|
|
}
|
|
|
|
# The limits a feature conditions (the specification's "Required Limits" table: a limit's
|
|
# requirement where the device has the feature), by vk.xml structure and member, with the feature
|
|
# and the value the table requires of a device with it: a derived profile whose block requires the
|
|
# feature states that value where its base states the value for a device without it. pointSizeRange
|
|
# is (1.0, 64.0 - ULP) at a pointSizeGranularity of 1.0; maxInterpolationOffset 0.5 - 1 ULP at 4
|
|
# subpixel interpolation offset bits. maxCombinedClipAndCullDistances is conditioned on
|
|
# shaderCullDistance, which no derived profile requires.
|
|
FEATURE_LIMITS = {
|
|
**{("VkPhysicalDeviceProperties", member): ("tessellationShader", value)
|
|
for member, value in (
|
|
("maxTessellationGenerationLevel", 64),
|
|
("maxTessellationPatchSize", 32),
|
|
("maxTessellationControlPerVertexInputComponents", 64),
|
|
("maxTessellationControlPerVertexOutputComponents", 64),
|
|
("maxTessellationControlPerPatchOutputComponents", 120),
|
|
("maxTessellationControlTotalOutputComponents", 2048),
|
|
("maxTessellationEvaluationInputComponents", 64),
|
|
("maxTessellationEvaluationOutputComponents", 64))},
|
|
("VkPhysicalDeviceProperties", "maxFragmentDualSrcAttachments"): ("dualSrcBlend", 1),
|
|
("VkPhysicalDeviceProperties", "maxSamplerAnisotropy"): ("samplerAnisotropy", 16),
|
|
("VkPhysicalDeviceProperties", "minTexelGatherOffset"): ("shaderImageGatherExtended", -8),
|
|
("VkPhysicalDeviceProperties", "maxTexelGatherOffset"): ("shaderImageGatherExtended", 7),
|
|
("VkPhysicalDeviceProperties", "minInterpolationOffset"): ("sampleRateShading", -0.5),
|
|
("VkPhysicalDeviceProperties", "maxInterpolationOffset"): ("sampleRateShading", 0.4375),
|
|
("VkPhysicalDeviceProperties", "subPixelInterpolationOffsetBits"): ("sampleRateShading", 4),
|
|
("VkPhysicalDeviceProperties", "maxClipDistances"): ("shaderClipDistance", 8),
|
|
("VkPhysicalDeviceProperties", "pointSizeRange"): ("largePoints", [1.0, 63.0]),
|
|
("VkPhysicalDeviceProperties", "pointSizeGranularity"): ("largePoints", 1.0),
|
|
}
|
|
|
|
# Members a derived profile's base (VP_LUNARG_minimum_requirements_1_2) states at a value the
|
|
# Vulkan 1.2 specification contradicts, by vk.xml structure and member, with the base's value and
|
|
# the specification's. The derivation states the specification's value in the base's place and
|
|
# names each correction in its provenance; a base value other than the one listed fails the
|
|
# regeneration, so an upstream fix is noticed.
|
|
# - VkPhysicalDeviceDepthStencilResolveProperties: "VK_RESOLVE_MODE_SAMPLE_ZERO_BIT must be
|
|
# included in the set" of supported depth and of supported stencil resolve modes.
|
|
# - The Required Limits table: maxDrawIndexedIndexValue is at least 2^24 - 1, where the base
|
|
# states 2^24.
|
|
SPEC_CORRECTIONS = {
|
|
("VkPhysicalDeviceVulkan12Properties", "supportedDepthResolveModes"):
|
|
([], ["VK_RESOLVE_MODE_SAMPLE_ZERO_BIT"]),
|
|
("VkPhysicalDeviceVulkan12Properties", "supportedStencilResolveModes"):
|
|
([], ["VK_RESOLVE_MODE_SAMPLE_ZERO_BIT"]),
|
|
("VkPhysicalDeviceProperties", "maxDrawIndexedIndexValue"): (16777216, 16777215),
|
|
}
|
|
|
|
# The other extension device-property structures the product reads (src/device/khronos.rs
|
|
# `PROPERTY_STRUCTS`), by vk.xml name: completing a requirements document that lists the extension
|
|
# of one and omits a member fails, until EXTENSION_PROPERTIES states the values the reader takes.
|
|
# `VkPhysicalDeviceMaintenance10PropertiesKHR` is not among them: vk.xml gives its member
|
|
# `limittype="exact"`, which the layer never sets, and validation bounds it.
|
|
UNMODELLED_PROPERTY_STRUCTS = {
|
|
"VkPhysicalDeviceVertexAttributeDivisorProperties",
|
|
"VkPhysicalDeviceMaintenance4Properties",
|
|
"VkPhysicalDevicePushDescriptorProperties",
|
|
"VkPhysicalDevicePortabilitySubsetPropertiesKHR",
|
|
"VkPhysicalDeviceAccelerationStructurePropertiesKHR",
|
|
"VkPhysicalDeviceDeviceGeneratedCommandsPropertiesEXT",
|
|
}
|
|
|
|
# Capability blocks holding the Vulkan 1.2 Required Format Support tables: every unconditional
|
|
# entry, and the entries a feature the profile requires makes unconditional (one block per
|
|
# feature, named by the prefix plus the feature).
|
|
REQUIRED_FORMATS_BLOCK = "m2v_vulkan12_required_formats"
|
|
|
|
# Device-property members no committed profile carries, whatever its source kind:
|
|
# they identify the host or the driver build a report came from instead of describing what the
|
|
# device can do. Nothing in translation reads them, and a profile simulated on another machine
|
|
# (VK_LAYER_KHRONOS_profiles) would report them as that machine's. Two kinds:
|
|
# - opaque identifiers: every `VK_UUID_SIZE` or `VK_LUID_SIZE` byte array that a device property
|
|
# struct of the pinned vk.xml declares (`Registry.identifier_members`; regeneration fails when
|
|
# the registry declares one this set lacks);
|
|
# - where the device sits on the host: its PCI address and its DRM node numbers.
|
|
HOST_IDENTITY = {
|
|
"deviceLUID", "deviceUUID", "driverUUID", "optimalTilingLayoutUUID", "pipelineCacheUUID",
|
|
"shaderBinaryUUID", "shaderModuleIdentifierAlgorithmUUID",
|
|
"pciBus", "pciDevice", "pciDomain", "pciFunction",
|
|
"primaryMajor", "primaryMinor", "renderMajor", "renderMinor",
|
|
}
|
|
|
|
# Each color attachment format's sample counts, which no profiles-schema structure holds
|
|
# (`VkImageFormatProperties`, Vulkan-Profiles issue 341): a `vulkaninfo` profile's top-level
|
|
# `SAMPLE_COUNTS_KEY` object, keyed by profile name, maps each format whose optimal tiling has
|
|
# `COLOR_ATTACHMENT` to the `VkSampleCountFlagBits` of a 2D, optimal-tiling image of it with
|
|
# `COLOR_ATTACHMENT` usage, from its `corpus-vulkan --capture-formats` supplement.
|
|
SAMPLE_COUNTS_KEY = "m2v_color_attachment_sample_counts"
|
|
SAMPLE_COUNTS_MEMBER = "colorAttachmentSampleCounts"
|
|
|
|
SOURCES = [
|
|
{
|
|
"name": "vk12-floor",
|
|
"kind": "derived",
|
|
"label": "Vulkan 1.2 required features and minimum limits only",
|
|
"below_floor": True,
|
|
},
|
|
{
|
|
"name": "runtime-floor",
|
|
"kind": "derived",
|
|
"label": ("the runtime's floor: Vulkan 1.3 required features and minimum limits, and "
|
|
"what metal2vulkan-runtime requires of every device"),
|
|
"base_profile": "VP_LUNARG_minimum_requirements_1_3",
|
|
"minor": 3,
|
|
"complete_required": True,
|
|
"runtime_floor": True,
|
|
},
|
|
{
|
|
"name": "nvidia-rtx50-linux",
|
|
"kind": "gpuinfo",
|
|
"report": 51770,
|
|
"sha256": "9cfb004ba47300329269d78f6e4bc2ea39b1a35d48c93ef5fb361f071247827d",
|
|
},
|
|
{
|
|
"name": "nvidia-pascal-linux",
|
|
"kind": "gpuinfo",
|
|
"report": 52074,
|
|
"sha256": "36cdb075156f5255ec0ece4e91eaf8fe2ae8c1dfa1f7013aca196a27f387d73b",
|
|
},
|
|
{
|
|
"name": "amd-rdna3-radv",
|
|
"kind": "gpuinfo",
|
|
"report": 51898,
|
|
"sha256": "d930ad92ca5da4f19b1c44ccf71a3fa34998e1e3f6834b06da1fb0661abbdd3a",
|
|
},
|
|
{
|
|
"name": "amd-rdna2-apu-radv",
|
|
"kind": "gpuinfo",
|
|
"report": 51886,
|
|
"sha256": "27b8aa8d78d26dace85f0c9360a77dd1f4603f58ad47c9f280f89d532b7787f0",
|
|
},
|
|
{
|
|
"name": "intel-arl-anv",
|
|
"kind": "gpuinfo",
|
|
"report": 52029,
|
|
"sha256": "962998684be1ebdd2163b7810cf8a3aaea6b8ec01585282cb84a79e3f82d80f4",
|
|
},
|
|
{
|
|
"name": "intel-irisxe-anv",
|
|
"kind": "gpuinfo",
|
|
"report": 51836,
|
|
"sha256": "fb74c05355f2b8c75766949550bf5b970a7e8486f14edb11ad75766f1f9cf9fd",
|
|
},
|
|
{
|
|
"name": "moltenvk-m3",
|
|
"kind": "vulkaninfo",
|
|
"sha256": "7e5c9fee5dc7d9fec91af17d782176781f2f02726394774de8e97e004105b9ed",
|
|
"profile": "VP_VULKANINFO_Apple_M3_Max_0_2_2210_portability_subset",
|
|
"command": "vulkaninfo --json",
|
|
"host": ("Apple M3 Max, macOS 27.0.1 (26A434), Homebrew molten-vk 1.4.2, "
|
|
"vulkan-tools 1.4.363.0"),
|
|
"formats": {
|
|
"command": "corpus-vulkan --capture-formats OUT --device-type gpu",
|
|
"sha256": "5c51e94668daac9f1310de8bac90bdc2b2b22a053efd8c0508277b93eac0bdc4",
|
|
},
|
|
},
|
|
{
|
|
"name": "lavapipe",
|
|
"kind": "gpuinfo",
|
|
"report": 51983,
|
|
"sha256": "be9cbc3518501d272eb2d8e20383674095a8a0c125be424cd328e7dea761f29c",
|
|
},
|
|
{
|
|
# The Linux gate's lavapipe: the committed `lavapipe` above is an x86
|
|
# 256-bit llvmpipe with 8-lane subgroups; the gate image's is arm64, 128-bit, 4 lanes.
|
|
"name": "gate-lavapipe",
|
|
"kind": "vulkaninfo",
|
|
"sha256": "66e849c60423e37387a34ffdee8b10cc0068f82e273451ac91dfebe2ef9c0fa9",
|
|
"profile": "VP_VULKANINFO_llvmpipe_(LLVM_21_1_8,_128_bits)_26_0_8",
|
|
"command": "vulkaninfo --json",
|
|
"host": ("scripts/linux-gate --icd lavapipe, image m2v-linux-gate:c07668da48ca42af-arm64 "
|
|
"(Ubuntu 26.04, arm64): mesa-vulkan-drivers 26.0.8-1ubuntu0.3, libvulkan1 and "
|
|
"vulkan-tools 1.4.341.0"),
|
|
"formats": {
|
|
"command": "corpus-vulkan --capture-formats OUT --device-type cpu",
|
|
"sha256": "9c109ad771f374d605e1bd5668d41254017fb6f5763fb42817a80bf5ad61c782",
|
|
},
|
|
},
|
|
{
|
|
"name": "gate-lavapipe-x86_64",
|
|
"kind": "vulkaninfo",
|
|
"sha256": "30066e1ab691eff34251fe41e575014f0da21f6092d4eb4f7fa7b10e8aa47a92",
|
|
"profile": "VP_VULKANINFO_llvmpipe_(LLVM_21_1_8,_256_bits)_26_0_8",
|
|
"command": "vulkaninfo --json",
|
|
"host": ("scripts/linux-gate --icd lavapipe, image m2v-linux-gate:c07668da48ca42af-amd64 "
|
|
"(Ubuntu 26.04, x86_64): mesa-vulkan-drivers 26.0.8-1ubuntu0.3, libvulkan1 and "
|
|
"vulkan-tools 1.4.341.0"),
|
|
"formats": {
|
|
"command": "corpus-vulkan --capture-formats OUT --device-type cpu",
|
|
"sha256": "a6becd36af52862861931fd072856fb3572be7bb23d9cb8d670831fb0b306c5d",
|
|
},
|
|
},
|
|
{
|
|
"name": "amd-780m-radv",
|
|
"kind": "vulkaninfo",
|
|
"sha256": "f109b309ae26d97339bb5b26f4ed5d6aa60c16dd8affeec6c5719bcda4d90601",
|
|
"profile": "VP_VULKANINFO_AMD_Radeon_780M_Graphics_(RADV_PHOENIX)_26_2_6",
|
|
"command": "vulkaninfo --json",
|
|
"host": ("AMD Radeon 780M (Phoenix), CachyOS: mesa and vulkan-radeon 26.2.6, "
|
|
"vulkan-icd-loader and vulkan-tools 1.4.363.0"),
|
|
"formats": {
|
|
"command": "corpus-vulkan --capture-formats OUT --device-type gpu",
|
|
"sha256": "987f79dcaea1d8ac4e1f7565377e81d656e15af810dee851a4b14d8515969387",
|
|
},
|
|
},
|
|
{
|
|
# The Radeon 780M of Hawk Point, the GPU of `amd-780m-radv` under another deviceID
|
|
# (0x1900), whose measured driver facts it shares; no venue names it. Its capture, under
|
|
# the same RADV build, differs from `amd-780m-radv`'s only in the deviceID.
|
|
"name": "amd-780m-hawkpoint-radv",
|
|
"kind": "vulkaninfo",
|
|
"sha256": "bafbfbfad3ee3d4cdac62485d73e45291cd7dcf4e0a145534ebe6d0bacc4deb5",
|
|
"profile": "VP_VULKANINFO_AMD_Radeon_780M_Graphics_(RADV_PHOENIX)_26_2_6",
|
|
"command": "vulkaninfo --json",
|
|
"host": ("AMD Radeon 780M (Hawk Point, Ryzen 7 8845HS), CachyOS: mesa and vulkan-radeon "
|
|
"26.2.6, vulkan-icd-loader and vulkan-tools 1.4.363.0"),
|
|
"formats": {
|
|
"command": "corpus-vulkan --capture-formats OUT --device-type gpu",
|
|
"sha256": "8bc7553ce483f8d294d1e4dcf336086f56f338791958f99f3b68c240a4daa5e6",
|
|
},
|
|
},
|
|
{
|
|
"name": "intel-irisxe-rplp-anv",
|
|
"kind": "vulkaninfo",
|
|
"sha256": "270ab1aa612b3430b1bf041fe6c41ec140921cc3c4b8b16f29f51d192163ad38",
|
|
"profile": "VP_VULKANINFO_Intel(R)_Iris(R)_Xe_Graphics_(RPL-P)_26_2_6",
|
|
"command": "vulkaninfo --json",
|
|
"host": ("Intel Iris Xe Graphics (Raptor Lake-P), CachyOS: mesa and vulkan-intel "
|
|
"26.2.6, vulkan-icd-loader and vulkan-tools 1.4.363.0"),
|
|
"formats": {
|
|
"command": "corpus-vulkan --capture-formats OUT --device-type gpu",
|
|
"sha256": "81e40f063157bc2bb874574b38aeeeb7084505a08963d9158e34a1403020c1ec",
|
|
},
|
|
},
|
|
{
|
|
# An i9-13900's UHD Graphics 770 (Raptor Lake-S), captured under ANV 26.2.4 (the
|
|
# intel-irisxe-rplp-anv venue's Iris Xe (RPL-P) is captured under 26.2.6). Its capture
|
|
# differs from the venue's in maxMemoryAllocationSize, and that venue does not allow it.
|
|
"name": "intel-uhd770-rpls-anv",
|
|
"kind": "vulkaninfo",
|
|
"sha256": "c4088e885bf46fc414e55a56fdb0f5b946ae6a34af61e2667891cab6089f8ca2",
|
|
"profile": "VP_VULKANINFO_Intel(R)_Graphics_(RPL-S)_26_2_4",
|
|
"command": "vulkaninfo --json",
|
|
"host": ("Intel UHD Graphics 770 (Raptor Lake-S, i9-13900), CachyOS: mesa and "
|
|
"vulkan-intel 26.2.4, vulkan-icd-loader and vulkan-tools 1.4.357.0"),
|
|
"formats": {
|
|
"command": "corpus-vulkan --capture-formats OUT --device-type gpu",
|
|
"sha256": "e1ed48d542902316c8bf2f4f0cbde7a3387b3aecac2a9c4dfc763acecd97a8d2",
|
|
},
|
|
},
|
|
{
|
|
"name": "nvidia-rtx5080-laptop",
|
|
"kind": "vulkaninfo",
|
|
"sha256": "94b71e5bd1f1bc61e06921f173bb12459f525ff6c49a1bf26dd933f914253469",
|
|
"profile": "VP_VULKANINFO_NVIDIA_GeForce_RTX_5080_Laptop_GPU_615_71_9_0",
|
|
"command": "vulkaninfo --json",
|
|
"host": ("NVIDIA GeForce RTX 5080 Laptop GPU, CachyOS: nvidia-utils 615.71.09 "
|
|
"(nvidia-open kernel module), vulkan-icd-loader and vulkan-tools 1.4.357.0"),
|
|
"formats": {
|
|
"command": "corpus-vulkan --capture-formats OUT --device-type gpu",
|
|
"sha256": "86bc23122d165c02808b913be956569b1a35ef976e150aea410a5248cad4c003",
|
|
},
|
|
},
|
|
]
|
|
|
|
|
|
|
|
|
|
def profile_name(stem):
|
|
return "VP_M2V_" + stem.replace("-", "_")
|
|
|
|
|
|
def sha256(data):
|
|
return hashlib.sha256(data).hexdigest()
|
|
|
|
|
|
def fetch(url, pinned, offline):
|
|
"""Returns the pinned bytes of `url`, from the cache or the network."""
|
|
CACHE_DIR.mkdir(parents=True, exist_ok=True)
|
|
cached = CACHE_DIR / pinned
|
|
if cached.exists():
|
|
data = cached.read_bytes()
|
|
elif offline:
|
|
raise SystemExit(f"offline and not cached: {url}")
|
|
else:
|
|
request = urllib.request.Request(url, headers={"User-Agent": "metal2vulkan-profiles"})
|
|
with urllib.request.urlopen(request, timeout=120) as response:
|
|
data = response.read()
|
|
actual = sha256(data)
|
|
if actual != pinned:
|
|
raise SystemExit(f"{url}: sha256 {actual} does not match pin {pinned}")
|
|
cached.write_bytes(data)
|
|
return data
|
|
|
|
|
|
def supported(element):
|
|
api = element.get("api")
|
|
return api is None or "vulkan" in api.split(",")
|
|
|
|
|
|
class Member:
|
|
def __init__(self, element):
|
|
self.name = element.find("name").text
|
|
self.type = element.find("type").text
|
|
parts = [element.text or ""]
|
|
for child in element:
|
|
if child.tag != "comment":
|
|
parts.append(child.text or "")
|
|
parts.append(child.tail or "")
|
|
tail = "".join(parts)
|
|
self.pointer = "*" in tail
|
|
# Array bounds are literal numbers or API constants (`<enum>` children, whose text
|
|
# `itertext` includes between the brackets).
|
|
self.dims = [dim.strip() for dim in re.findall(r"\[([^\]]*)\]", tail)]
|
|
if any(not dim for dim in self.dims):
|
|
raise ValueError(f"member {self.name}: empty array bound")
|
|
|
|
|
|
class Registry:
|
|
"""The subset of `vk.xml` the conversion needs: structs, enums, bitmasks, extensions."""
|
|
|
|
def __init__(self, data):
|
|
root = ET.fromstring(data)
|
|
self.constants = {}
|
|
self.structs = {}
|
|
self.aliases = {}
|
|
self.categories = {}
|
|
self.bitmask_bits = {}
|
|
self.enum_values = {}
|
|
for element in root.find("types"):
|
|
if element.tag != "type" or not supported(element):
|
|
continue
|
|
name = element.get("name") or element.findtext("name")
|
|
category = element.get("category")
|
|
if element.get("alias"):
|
|
self.aliases[name] = element.get("alias")
|
|
self.categories[name] = category
|
|
continue
|
|
self.categories[name] = category
|
|
if category in ("struct", "union"):
|
|
self.structs[name] = {
|
|
"members": [Member(m) for m in element.findall("member") if supported(m)],
|
|
"extends": set(filter(None, (element.get("structextends") or "").split(","))),
|
|
}
|
|
elif category == "bitmask":
|
|
bits = element.get("requires") or element.get("bitvalues")
|
|
if bits:
|
|
self.bitmask_bits[name] = bits
|
|
for enums in root.findall("enums"):
|
|
name = enums.get("name")
|
|
if name == "API Constants":
|
|
for constant in enums.findall("enum"):
|
|
if constant.get("value"):
|
|
self.constants[constant.get("name")] = constant.get("value")
|
|
continue
|
|
values = self.enum_values.setdefault(name, {})
|
|
for enum in enums.findall("enum"):
|
|
if supported(enum):
|
|
self._add_enum(values, enum, None)
|
|
self.extension_types = {}
|
|
for feature in root.findall("feature"):
|
|
if supported(feature):
|
|
for require in feature.findall("require"):
|
|
for enum in require.findall("enum"):
|
|
if enum.get("extends") and supported(enum):
|
|
self._add_enum(self.enum_values.setdefault(enum.get("extends"), {}), enum, None)
|
|
for extension in root.find("extensions"):
|
|
number = int(extension.get("number"))
|
|
types = []
|
|
for require in extension.findall("require"):
|
|
if not supported(require):
|
|
continue
|
|
types.extend(t.get("name") for t in require.findall("type"))
|
|
for enum in require.findall("enum"):
|
|
if enum.get("extends") and supported(enum):
|
|
values = self.enum_values.setdefault(enum.get("extends"), {})
|
|
self._add_enum(values, enum, number)
|
|
self.extension_types[extension.get("name")] = types
|
|
self.required_by_version = self._required_by_version(root)
|
|
self.required_features = self.required_through(2)
|
|
|
|
def required_through(self, minor):
|
|
"""The members `vk.xml` requires without a condition of every version from 1.0 through
|
|
1.`minor`."""
|
|
return {member for version in range(minor + 1)
|
|
for _, member in self.required_by_version.get(f"VK_VERSION_1_{version}", [])}
|
|
|
|
@staticmethod
|
|
def _add_enum(values, enum, extension_number):
|
|
if enum.get("alias"):
|
|
return
|
|
name = enum.get("name")
|
|
if enum.get("bitpos") is not None:
|
|
value = 1 << int(enum.get("bitpos"))
|
|
elif enum.get("offset") is not None:
|
|
number = int(enum.get("extnumber") or extension_number)
|
|
value = 1000000000 + (number - 1) * 1000 + int(enum.get("offset"))
|
|
if enum.get("dir") == "-":
|
|
value = -value
|
|
elif enum.get("value") is not None:
|
|
text = enum.get("value")
|
|
try:
|
|
value = int(text, 0)
|
|
except ValueError:
|
|
return
|
|
else:
|
|
return
|
|
# The first non-alias name for a value wins, which is the core spelling.
|
|
values.setdefault(value, name)
|
|
|
|
@staticmethod
|
|
def _required_by_version(root):
|
|
"""Each core version's feature requirements without a condition, as (structure, member)
|
|
pairs, by version name (`VK_VERSION_1_2`)."""
|
|
out = {}
|
|
for feature in root.findall("feature"):
|
|
if not supported(feature):
|
|
continue
|
|
pairs = out.setdefault(feature.get("name"), [])
|
|
for require in feature.findall("require"):
|
|
if require.get("depends"):
|
|
continue
|
|
pairs.extend((f.get("struct"), f.get("name")) for f in require.findall("feature"))
|
|
return out
|
|
|
|
def identifier_members(self):
|
|
"""Names of the opaque identifiers among device properties: every `VK_UUID_SIZE` or
|
|
`VK_LUID_SIZE` byte array of `VkPhysicalDeviceProperties` or of a struct extending
|
|
`VkPhysicalDeviceProperties2`."""
|
|
names = set()
|
|
for name, struct in self.structs.items():
|
|
if (name != "VkPhysicalDeviceProperties"
|
|
and "VkPhysicalDeviceProperties2" not in struct["extends"]):
|
|
continue
|
|
for member in struct["members"]:
|
|
if member.dims in (["VK_UUID_SIZE"], ["VK_LUID_SIZE"]):
|
|
names.add(member.name)
|
|
return names
|
|
|
|
def resolve(self, name):
|
|
seen = set()
|
|
while name in self.aliases:
|
|
if name in seen:
|
|
raise ValueError(f"alias cycle at {name}")
|
|
seen.add(name)
|
|
name = self.aliases[name]
|
|
return name
|
|
|
|
def struct(self, name):
|
|
return self.structs[self.resolve(name)]
|
|
|
|
def member(self, struct, name):
|
|
for member in self.struct(struct)["members"]:
|
|
if member.name == name:
|
|
return member
|
|
return None
|
|
|
|
def extension_structs(self, extension, chain):
|
|
"""Structs an extension adds to `chain` (e.g. `VkPhysicalDeviceFeatures2`), as spelled by
|
|
the extension."""
|
|
result = []
|
|
for name in self.extension_types.get(extension, []):
|
|
resolved = self.resolve(name)
|
|
if resolved in self.structs and chain in self.structs[resolved]["extends"]:
|
|
result.append(name)
|
|
return result
|
|
|
|
|
|
class Unmapped(Exception):
|
|
pass
|
|
|
|
|
|
def parse_int(raw):
|
|
if isinstance(raw, bool):
|
|
return int(raw)
|
|
if isinstance(raw, int):
|
|
return raw
|
|
if isinstance(raw, float) and raw.is_integer():
|
|
return int(raw)
|
|
if isinstance(raw, str):
|
|
return int(raw, 0)
|
|
raise Unmapped(f"not an integer: {raw!r}")
|
|
|
|
|
|
INTEGER_TYPES = {
|
|
"uint8_t", "uint16_t", "uint32_t", "uint64_t", "int8_t", "int16_t", "int32_t", "int64_t",
|
|
"size_t", "VkDeviceSize", "VkDeviceAddress", "VkSampleMask",
|
|
}
|
|
|
|
|
|
class Converter:
|
|
def __init__(self, registry):
|
|
self.registry = registry
|
|
|
|
def enum_name(self, type_name, raw):
|
|
value = parse_int(raw)
|
|
values = self.registry.enum_values.get(self.registry.resolve(type_name), {})
|
|
if value not in values:
|
|
raise Unmapped(f"{type_name} value {value}")
|
|
return values[value]
|
|
|
|
def flag_names(self, type_name, raw):
|
|
bits_type = self.registry.bitmask_bits.get(self.registry.resolve(type_name))
|
|
value = parse_int(raw)
|
|
if bits_type is None:
|
|
if value == 0:
|
|
return []
|
|
raise Unmapped(f"{type_name} has no bits but value {value}")
|
|
values = self.registry.enum_values.get(bits_type, {})
|
|
names = []
|
|
for bit in range(64):
|
|
mask = 1 << bit
|
|
if value & mask:
|
|
if mask not in values:
|
|
raise Unmapped(f"{type_name} bit {bit}")
|
|
names.append(values[mask])
|
|
return names
|
|
|
|
def scalar(self, type_name, raw):
|
|
category = self.registry.categories.get(type_name)
|
|
if type_name == "VkBool32":
|
|
if raw in ("true", "false"):
|
|
return raw == "true"
|
|
value = parse_int(raw)
|
|
if value not in (0, 1):
|
|
raise Unmapped(f"VkBool32 value {value}")
|
|
return value == 1
|
|
if type_name in INTEGER_TYPES:
|
|
return parse_int(raw)
|
|
if type_name in ("float", "double"):
|
|
return float(raw)
|
|
if category == "enum":
|
|
return self.enum_name(type_name, raw)
|
|
if category == "bitmask":
|
|
return self.flag_names(type_name, raw)
|
|
if category == "struct":
|
|
return self.struct_value(type_name, raw)
|
|
raise Unmapped(f"unsupported member type {type_name}")
|
|
|
|
def value(self, member, raw):
|
|
if member.type == "char" and member.dims:
|
|
if not isinstance(raw, str):
|
|
raise Unmapped(f"{member.name}: expected a string")
|
|
return raw
|
|
if not member.dims:
|
|
return self.scalar(member.type, raw)
|
|
if not isinstance(raw, list):
|
|
raise Unmapped(f"{member.name}: expected an array")
|
|
return [self.scalar(member.type, item) for item in raw]
|
|
|
|
def struct_value(self, type_name, raw):
|
|
if self.registry.resolve(type_name) == "VkConformanceVersion" and isinstance(raw, str):
|
|
parts = raw.split(".")
|
|
if len(parts) != 4:
|
|
raise Unmapped(f"conformance version {raw!r}")
|
|
raw = dict(zip(["major", "minor", "subminor", "patch"], parts))
|
|
if isinstance(raw, list):
|
|
# gpuinfo spells small all-scalar structs such as VkExtent2D as positional arrays.
|
|
members = self.registry.struct(type_name)["members"]
|
|
if len(raw) != len(members) or any(m.dims or m.pointer for m in members):
|
|
raise Unmapped(f"{type_name}: positional value {raw!r}")
|
|
raw = {member.name: item for member, item in zip(members, raw)}
|
|
if not isinstance(raw, dict):
|
|
raise Unmapped(f"{type_name}: expected an object")
|
|
result, unmapped = self.fill(type_name, raw, type_name)
|
|
if unmapped:
|
|
raise Unmapped(f"{type_name}: {', '.join(unmapped)}")
|
|
return result
|
|
|
|
def fill(self, struct, raw, where):
|
|
"""Converts the members of `raw` that `struct` declares, in declaration order. Returns the
|
|
object and the list of source fields that could not be represented."""
|
|
result = {}
|
|
unmapped = []
|
|
known = set()
|
|
for member in self.registry.struct(struct)["members"]:
|
|
known.add(member.name)
|
|
if member.name in ("sType", "pNext") or member.pointer or member.name not in raw:
|
|
continue
|
|
try:
|
|
result[member.name] = self.value(member, raw[member.name])
|
|
except (Unmapped, ValueError, TypeError) as error:
|
|
unmapped.append(f"{where}.{member.name} ({error})")
|
|
for name in raw:
|
|
if name not in known:
|
|
unmapped.append(f"{where}.{name} (not a member)")
|
|
elif self.registry.member(struct, name).pointer:
|
|
unmapped.append(f"{where}.{name} (pointer member)")
|
|
return result, unmapped
|
|
|
|
|
|
def group_extended(registry, rows, chain, output, unmapped, converter):
|
|
"""Folds gpuinfo's flat `{extension, name, value}` rows into the extension's structs."""
|
|
by_extension = {}
|
|
for row in rows:
|
|
by_extension.setdefault(row["extension"], []).append(row)
|
|
for extension in sorted(by_extension):
|
|
structs = registry.extension_structs(extension, chain)
|
|
values = {}
|
|
for row in by_extension[extension]:
|
|
raw = row["supported"] if "supported" in row else row["value"]
|
|
owner = next((s for s in structs if registry.member(s, row["name"])), None)
|
|
if owner is None:
|
|
unmapped.append(f"{extension}.{row['name']} (no {chain} struct declares it)")
|
|
continue
|
|
values.setdefault(owner, {})[row["name"]] = raw
|
|
for owner in structs:
|
|
if owner in values:
|
|
result, missing = converter.fill(owner, values[owner], owner)
|
|
unmapped.extend(missing)
|
|
if result:
|
|
output[owner] = result
|
|
|
|
|
|
def convert_gpuinfo(registry, report, source):
|
|
converter = Converter(registry)
|
|
unmapped = []
|
|
properties = report["properties"]
|
|
features = {}
|
|
if "features" in report:
|
|
result, missing = converter.fill("VkPhysicalDeviceFeatures", report["features"], "features")
|
|
features["VkPhysicalDeviceFeatures"] = result
|
|
unmapped.extend(missing)
|
|
for version in ("11", "12", "13", "14"):
|
|
core = report.get(f"core{version}") or {}
|
|
if core.get("features"):
|
|
name = f"VkPhysicalDeviceVulkan{version}Features"
|
|
result, missing = converter.fill(name, core["features"], f"core{version}.features")
|
|
features[name] = result
|
|
unmapped.extend(missing)
|
|
extended = report.get("extended") or {}
|
|
group_extended(registry, extended.get("devicefeatures2") or [], "VkPhysicalDeviceFeatures2",
|
|
features, unmapped, converter)
|
|
|
|
props = {}
|
|
core10 = {k: properties[k] for k in properties if registry.member("VkPhysicalDeviceProperties", k)}
|
|
result, missing = converter.fill("VkPhysicalDeviceProperties", core10, "properties")
|
|
props["VkPhysicalDeviceProperties"] = result
|
|
unmapped.extend(missing)
|
|
ignored = {"apiVersionText", "deviceTypeText", "driverVersionText", "headerversion",
|
|
"hasFormatFeatureFlags2", "subgroupProperties", "productModel", "productManufacturer"}
|
|
for key in properties:
|
|
if key not in core10 and key not in ignored:
|
|
unmapped.append(f"properties.{key} (not a member)")
|
|
if properties.get("subgroupProperties"):
|
|
result, missing = converter.fill("VkPhysicalDeviceSubgroupProperties",
|
|
properties["subgroupProperties"], "subgroupProperties")
|
|
props["VkPhysicalDeviceSubgroupProperties"] = result
|
|
unmapped.extend(missing)
|
|
for version in ("11", "12", "13", "14"):
|
|
core = report.get(f"core{version}") or {}
|
|
if core.get("properties"):
|
|
name = f"VkPhysicalDeviceVulkan{version}Properties"
|
|
result, missing = converter.fill(name, core["properties"], f"core{version}.properties")
|
|
props[name] = result
|
|
unmapped.extend(missing)
|
|
group_extended(registry, extended.get("deviceproperties2") or [], "VkPhysicalDeviceProperties2",
|
|
props, unmapped, converter)
|
|
|
|
extensions = {}
|
|
for extension in report.get("extensions") or []:
|
|
name = extension["extensionName"]
|
|
if name not in registry.extension_types:
|
|
unmapped.append(f"extensions.{name} (not in the registry)")
|
|
continue
|
|
extensions[name] = parse_int(extension["specVersion"])
|
|
|
|
formats = {}
|
|
flags2 = bool(properties.get("hasFormatFeatureFlags2"))
|
|
for format_id, entry in report.get("formats") or []:
|
|
if not entry.get("supported"):
|
|
continue
|
|
try:
|
|
name = converter.enum_name("VkFormat", format_id)
|
|
legacy = {}
|
|
extended_props = {}
|
|
for field in ("linearTilingFeatures", "optimalTilingFeatures", "bufferFeatures"):
|
|
value = parse_int(entry[field])
|
|
legacy_bits = registry.enum_values["VkFormatFeatureFlagBits"]
|
|
legacy[field] = [legacy_bits[1 << b] for b in range(32)
|
|
if value & (1 << b) and (1 << b) in legacy_bits]
|
|
if flags2:
|
|
extended_props[field] = converter.flag_names("VkFormatFeatureFlags2", value)
|
|
elif any(value & (1 << b) and (1 << b) not in legacy_bits for b in range(64)):
|
|
raise Unmapped(f"{field} has bits outside VkFormatFeatureFlagBits")
|
|
formats[name] = {"VkFormatProperties": legacy}
|
|
if flags2:
|
|
formats[name]["VkFormatProperties3"] = extended_props
|
|
except Unmapped as error:
|
|
unmapped.append(f"formats[{format_id}] ({error})")
|
|
|
|
queues = []
|
|
for queue in report.get("queues") or []:
|
|
raw = {k: v for k, v in queue.items() if k != "supportsPresent"}
|
|
result, missing = converter.fill("VkQueueFamilyProperties", raw, "queues")
|
|
unmapped.extend(missing)
|
|
queues.append({"VkQueueFamilyProperties": result})
|
|
|
|
device = {
|
|
"extensions": dict(sorted(extensions.items())),
|
|
"features": dict(sorted(features.items())),
|
|
"properties": dict(sorted(props.items())),
|
|
"formats": dict(sorted(formats.items())),
|
|
"queueFamiliesProperties": queues,
|
|
}
|
|
environment = report.get("environment") or {}
|
|
core12 = (report.get("core12") or {}).get("properties") or {}
|
|
api_version = properties["apiVersionText"]
|
|
report_id = source["report"]
|
|
osname = f"{environment.get('name', '')} {environment.get('version', '')}".strip()
|
|
osname = osname.replace("'", "")
|
|
label = (f"{properties['deviceName']} driver {properties['driverVersionText']} "
|
|
f"on {osname}")
|
|
provenance = {
|
|
"source": "gpuinfo",
|
|
"report_id": report_id,
|
|
"url": GPUINFO_DISPLAY.format(report_id),
|
|
"raw_url": GPUINFO_REPORT.format(report_id),
|
|
"sha256": source["sha256"],
|
|
"device_name": properties["deviceName"],
|
|
"vendor_id": properties.get("vendorID"),
|
|
"device_id": properties.get("deviceID"),
|
|
"driver_name": core12.get("driverName"),
|
|
"driver_info": core12.get("driverInfo"),
|
|
"driver_version": properties["driverVersionText"],
|
|
"api_version": api_version,
|
|
"os": osname,
|
|
"report_version": environment.get("reportversion"),
|
|
"converter": CONVERTER,
|
|
"registry": REGISTRY,
|
|
"unmapped": sorted(unmapped),
|
|
}
|
|
return document(source["name"], api_version, label,
|
|
f"Converted from vulkan.gpuinfo.org report {report_id} "
|
|
f"({GPUINFO_DISPLAY.format(report_id)}).",
|
|
{"device": device}, ["device"], [], provenance)
|
|
|
|
|
|
def document(stem, api_version, label, description, capabilities, required, optionals,
|
|
provenance):
|
|
api = re.match(r"^(\d+)\.(\d+)\.(\d+)", api_version)
|
|
if not api:
|
|
raise SystemExit(f"{stem}: bad api version {api_version}")
|
|
profile = {
|
|
"version": 1,
|
|
"api-version": api.group(0),
|
|
"label": label,
|
|
"description": description,
|
|
"contributors": {},
|
|
"history": [{
|
|
"revision": 1,
|
|
"date": GENERATED,
|
|
"author": "metal2vulkan",
|
|
"comment": f"Generated by {CONVERTER}; see provenance.",
|
|
}],
|
|
"capabilities": required,
|
|
}
|
|
if optionals:
|
|
profile["optionals"] = optionals
|
|
return {
|
|
"$schema": SCHEMA,
|
|
"provenance": provenance,
|
|
"capabilities": capabilities,
|
|
"profiles": {profile_name(stem): profile},
|
|
}
|
|
|
|
|
|
def referenced(entries):
|
|
names = []
|
|
for entry in entries:
|
|
for name in entry if isinstance(entry, list) else [entry]:
|
|
if name not in names:
|
|
names.append(name)
|
|
return names
|
|
|
|
|
|
def required_features(capabilities, entries):
|
|
"""The feature members a profile's capability list requires: those a required block sets, and
|
|
those every alternative of a one-of entry sets (one alternative alone guarantees nothing)."""
|
|
def enabled(name):
|
|
return {member for members in capabilities[name].get("features", {}).values()
|
|
for member, value in members.items() if value is True}
|
|
|
|
result = set()
|
|
for entry in entries:
|
|
if isinstance(entry, list):
|
|
result |= set.intersection(*(enabled(name) for name in entry)) if entry else set()
|
|
else:
|
|
result |= enabled(entry)
|
|
return result
|
|
|
|
|
|
def required_format_blocks(capabilities, required, provenance, formats):
|
|
"""Adds the Required Format Support blocks a requirements profile implies: every
|
|
unconditional entry, and one block per feature the profile requires that makes conditional
|
|
entries unconditional. The provenance names the pinned source and lists every conditional
|
|
requirement, including the choices between formats or tables a profile cannot state."""
|
|
features = required_features(capabilities, required)
|
|
|
|
def block(table):
|
|
return {"formats": {name: {"VkFormatProperties": props}
|
|
for name, props in table.items()}}
|
|
|
|
capabilities[REQUIRED_FORMATS_BLOCK] = block(formats["unconditional"])
|
|
required.append(REQUIRED_FORMATS_BLOCK)
|
|
by_feature = {}
|
|
for requirement in formats["conditional"]:
|
|
feature = requirement.get("if_feature")
|
|
if feature in features:
|
|
[table] = requirement["any_of"]
|
|
by_feature.setdefault(feature, {}).update(copy.deepcopy(table))
|
|
for feature, table in sorted(by_feature.items()):
|
|
name = f"{REQUIRED_FORMATS_BLOCK}_if_{feature}"
|
|
capabilities[name] = block(dict(sorted(table.items())))
|
|
required.append(name)
|
|
provenance["required_formats"] = {
|
|
"url": required_formats.SPEC["url"],
|
|
"sha256": required_formats.SPEC["sha256"],
|
|
"tag": required_formats.SPEC["tag"],
|
|
"attributes": required_formats.VERSION_1_2,
|
|
"tables": formats["tables"],
|
|
"rule": (f"the Required Format Support tables of the Vulkan 1.2 specification, read by "
|
|
f"scripts/regen-device-profiles/required_formats.py: {REQUIRED_FORMATS_BLOCK} "
|
|
f"holds every unconditional entry and {REQUIRED_FORMATS_BLOCK}_if_<feature> "
|
|
f"the entries a feature this profile requires makes unconditional; "
|
|
f"`conditional` lists every conditional requirement (at least one table of "
|
|
f"`any_of` holds in full, on a device supporting `if_feature` when present)"),
|
|
"conditional": formats["conditional"],
|
|
"not_represented": formats["not_represented"],
|
|
}
|
|
|
|
|
|
def stated_members(capabilities, section):
|
|
"""The member names `capabilities` state in `section` (`features` or `properties`), of any
|
|
structure, as the product's reader reads them (flattened, `limits` included)."""
|
|
names = set()
|
|
for block in capabilities.values():
|
|
for members in block.get(section, {}).values():
|
|
for member, value in members.items():
|
|
if member == "limits" and isinstance(value, dict):
|
|
names.update(value)
|
|
else:
|
|
names.add(member)
|
|
return names
|
|
|
|
|
|
def presented_formats(capabilities, stem):
|
|
"""Each format several of `capabilities` (in the profile's order) state, at the union of their
|
|
flags, where it differs from the last block's entry. `VK_LAYER_KHRONOS_profiles` keeps one
|
|
block's entry of a format, the last that states it, while the product's reader takes the
|
|
union of every block's flags (`roadmap-2022`'s Required Format Support blocks
|
|
state 23 formats twice, and the layer reported the conditional block's storage bit alone)."""
|
|
entries = {}
|
|
for block in capabilities.values():
|
|
for name, props in block.get("formats", {}).items():
|
|
entries.setdefault(name, []).append(props)
|
|
formats = {}
|
|
for name, stated in sorted(entries.items()):
|
|
if len(stated) < 2:
|
|
continue
|
|
union = {}
|
|
for props in stated:
|
|
for struct, fields in props.items():
|
|
target = union.setdefault(struct, {})
|
|
for field, flags in fields.items():
|
|
if not isinstance(flags, list):
|
|
raise SystemExit(
|
|
f"{stem}: {name}'s {struct}.{field} is stated by several blocks and "
|
|
"is not a list of flags: its union is not modelled")
|
|
have = target.setdefault(field, [])
|
|
have.extend(flag for flag in flags if flag not in have)
|
|
|
|
def sets(props):
|
|
return {(struct, field): set(flags) for struct, fields in props.items()
|
|
for field, flags in fields.items() if flags}
|
|
|
|
if sets(union) != sets(stated[-1]):
|
|
formats[name] = union
|
|
return formats
|
|
|
|
|
|
def layer_presentation(registry, capabilities, api_version, stem):
|
|
"""The `LAYER_PRESENTATION_BLOCK` of a requirements document: each feature its core version
|
|
requires without a condition, each member the product reads of the core device-property
|
|
structures of its version (`CORE_PROPERTIES`), and each member the product reads of the
|
|
device-property structures of the extensions it lists (`EXTENSION_PROPERTIES`), that
|
|
`capabilities` omit, at the value the product reads; and each format several blocks state, at
|
|
the union the product reads ([`presented_formats`]). The block is the profile's last, so the
|
|
layer keeps its entry of each such format. Returns the block and the stated members' names."""
|
|
major, minor = (int(part) for part in api_version.split(".")[:2])
|
|
modelled = max(core for core, _ in CORE_PROPERTIES.values())
|
|
if major != 1 or minor > modelled:
|
|
raise SystemExit(
|
|
f"{stem}: Vulkan {major}.{minor}'s device-property structures are not modelled "
|
|
f"(CORE_PROPERTIES reaches 1.{modelled})")
|
|
features_stated = stated_members(capabilities, "features")
|
|
properties_stated = stated_members(capabilities, "properties")
|
|
features = {}
|
|
for version in range(minor + 1):
|
|
# vk.xml may name a requirement in the core structure and in the extension structure
|
|
# it absorbed: stated once, in the core one (the `VkPhysicalDeviceVulkan1x` or 1.0
|
|
# structure), as profile documents do.
|
|
pairs = sorted(registry.required_by_version.get(f"VK_VERSION_1_{version}", []),
|
|
key=lambda pair: not pair[0].startswith(("VkPhysicalDeviceVulkan1",
|
|
"VkPhysicalDeviceFeatures")))
|
|
for struct, member in pairs:
|
|
if member not in features_stated:
|
|
features.setdefault(struct, {})[member] = True
|
|
features_stated.add(member)
|
|
features_true = {member for block in list(capabilities.values()) + [{"features": features}]
|
|
for members in block.get("features", {}).values()
|
|
for member, value in members.items() if value is True}
|
|
properties = {}
|
|
for struct, (core, members) in CORE_PROPERTIES.items():
|
|
if core > minor:
|
|
continue
|
|
nested = members.get("limits") if struct == "VkPhysicalDeviceProperties" else None
|
|
for member, value in (nested if nested is not None else members).items():
|
|
if member not in properties_stated:
|
|
exact = FEATURE_EXACT_PROPERTIES.get((struct, member))
|
|
if exact is not None and exact[0] in features_true:
|
|
value = exact[1]
|
|
target = properties.setdefault(struct, {})
|
|
if nested is not None:
|
|
target = target.setdefault("limits", {})
|
|
target[member] = copy.deepcopy(value)
|
|
extensions = sorted({name for block in capabilities.values()
|
|
for name in block.get("extensions", {})})
|
|
for extension in extensions:
|
|
for struct in registry.extension_structs(extension, "VkPhysicalDeviceProperties2"):
|
|
resolved = registry.resolve(struct)
|
|
if resolved in EXTENSION_PROPERTIES:
|
|
for member, value in EXTENSION_PROPERTIES[resolved].items():
|
|
if member not in properties_stated:
|
|
properties.setdefault(struct, {})[member] = copy.deepcopy(value)
|
|
elif resolved in UNMODELLED_PROPERTY_STRUCTS:
|
|
omitted = sorted(member.name for member in registry.struct(struct)["members"]
|
|
if member.name not in ("sType", "pNext")
|
|
and member.name not in properties_stated)
|
|
if omitted:
|
|
raise SystemExit(
|
|
f"{stem}: {extension}'s {struct} is read by the product, and the profile "
|
|
f"omits {omitted}: state the values its reader takes in "
|
|
"EXTENSION_PROPERTIES")
|
|
block = {}
|
|
if features:
|
|
block["features"] = features
|
|
if properties:
|
|
block["properties"] = properties
|
|
formats = presented_formats(capabilities, stem)
|
|
if formats:
|
|
block["formats"] = formats
|
|
|
|
def names(prefix, members):
|
|
for member, value in members.items():
|
|
if member == "limits" and isinstance(value, dict):
|
|
yield from names(f"{prefix}.limits", value)
|
|
else:
|
|
yield f"{prefix}.{member}"
|
|
|
|
named = sorted([name for section in ("features", "properties")
|
|
for struct, members in block.get(section, {}).items()
|
|
for name in names(struct, members)]
|
|
+ [f"formats.{name}" for name in formats])
|
|
return block, named
|
|
|
|
|
|
def extract(data, source, formats, registry=None):
|
|
"""One profile plus the capability blocks it references, verbatim. A profile whose blocks
|
|
state no formats gets the Required Format Support blocks (`required_format_blocks`); a source
|
|
with `layer_presentation` gets the `LAYER_PRESENTATION_BLOCK` (`layer_presentation`, which
|
|
reads the pinned `registry`)."""
|
|
doc = json.loads(data)
|
|
profile = copy.deepcopy(doc["profiles"][source["profile"]])
|
|
if profile.get("profiles"):
|
|
raise SystemExit(f"{source['profile']} requires other profiles; not supported")
|
|
names = referenced(profile.get("capabilities", []) + profile.get("optionals", []))
|
|
capabilities = {name: doc["capabilities"][name] for name in names}
|
|
provenance = {
|
|
"source": "khronos",
|
|
"url": source["url"],
|
|
"sha256": source["sha256"],
|
|
"source_profile": source["profile"],
|
|
"source_profile_version": profile["version"],
|
|
}
|
|
if not any("formats" in capabilities[name] for name in names):
|
|
required_format_blocks(capabilities, profile["capabilities"], provenance, formats)
|
|
if source.get("layer_presentation"):
|
|
# What the profile states is its capabilities' (the reader and the layer read no
|
|
# optionals).
|
|
required = {name: capabilities[name] for name in referenced(profile["capabilities"])}
|
|
block, named = layer_presentation(registry, required, profile["api-version"],
|
|
source["name"])
|
|
if block:
|
|
capabilities[LAYER_PRESENTATION_BLOCK] = block
|
|
profile["capabilities"].append(LAYER_PRESENTATION_BLOCK)
|
|
provenance["layer_presentation"] = {
|
|
"registry": REGISTRY,
|
|
"rule": (f"the {LAYER_PRESENTATION_BLOCK} block states each feature the profile's "
|
|
"core version requires without a condition, and each member the product "
|
|
"reads of the core device-property structures of its version and of the "
|
|
"device-property structures of the extensions it lists, that the profile "
|
|
"omits, at the value the product reads, "
|
|
+ ("and each format several of its blocks state at the union of their "
|
|
"flags, which the product reads (the layer keeps the last block's entry "
|
|
"of a format), " if "formats" in block else "")
|
|
+ "so that VK_LAYER_KHRONOS_profiles reports the profile as the product "
|
|
"reads it"),
|
|
"stated": named,
|
|
}
|
|
out = {
|
|
"$schema": SCHEMA,
|
|
"provenance": provenance,
|
|
"capabilities": capabilities,
|
|
"profiles": {profile_name(source["name"]): profile},
|
|
}
|
|
profile["description"] = (f"{source['profile']} extracted verbatim from "
|
|
f"{source['url']}. {profile['description']}")
|
|
return out
|
|
|
|
|
|
def derive(registry, data, source, formats):
|
|
doc = json.loads(data)
|
|
base_profile = source.get("base_profile", MINIMUM_REQUIREMENTS["profile"])
|
|
minor = source.get("minor", 2)
|
|
required_by = registry.required_through(minor)
|
|
base = doc["profiles"][base_profile]
|
|
names = referenced(base["capabilities"])
|
|
capabilities = {}
|
|
dropped = []
|
|
corrected = []
|
|
for name in names:
|
|
block = copy.deepcopy(doc["capabilities"][name])
|
|
for struct, members in block.get("features", {}).items():
|
|
for member in list(members):
|
|
if member not in required_by:
|
|
dropped.append(f"{struct}.{member}")
|
|
del members[member]
|
|
block["features"] = {s: m for s, m in block.get("features", {}).items() if m}
|
|
if not block["features"]:
|
|
del block["features"]
|
|
for struct, members in block.get("properties", {}).items():
|
|
nested = members.get("limits") if struct == "VkPhysicalDeviceProperties" else None
|
|
target = nested if nested is not None else members
|
|
for member in list(target):
|
|
correction = SPEC_CORRECTIONS.get((struct, member))
|
|
if correction is None:
|
|
continue
|
|
stated, specified = correction
|
|
if target[member] != stated:
|
|
raise SystemExit(f"{source['name']}: the base profile states {struct}."
|
|
f"{member} = {json.dumps(target[member])}, not "
|
|
f"{json.dumps(stated)}: review SPEC_CORRECTIONS")
|
|
target[member] = copy.deepcopy(specified)
|
|
corrected.append(f"{struct}.{member}: {json.dumps(stated)} -> "
|
|
f"{json.dumps(specified)}")
|
|
capabilities[name] = block
|
|
missing = sorted(required_by - {
|
|
member for block in capabilities.values()
|
|
for members in block.get("features", {}).values() for member in members})
|
|
completed = {}
|
|
if missing and source.get("complete_required"):
|
|
# A required feature the base omits (VP_LUNARG_minimum_requirements_1_3 lists no
|
|
# `privateData`): stated in a block of its own, at true, and named in the provenance.
|
|
# vk.xml names a promoted feature by both its core and its extension structure: the core
|
|
# version's structure states it.
|
|
chosen = {}
|
|
for version in range(minor + 1):
|
|
for struct, member in registry.required_by_version.get(f"VK_VERSION_1_{version}", []):
|
|
if member in missing and (member not in chosen
|
|
or struct.startswith("VkPhysicalDeviceVulkan1")):
|
|
chosen[member] = struct
|
|
for member, struct in sorted(chosen.items()):
|
|
completed.setdefault(struct, {})[member] = True
|
|
missing = sorted(set(missing) - {m for members in completed.values() for m in members})
|
|
if missing:
|
|
raise SystemExit(f"{source['name']}: base profile lacks required features {missing}")
|
|
uncorrected = sorted(f"{struct}.{member}" for struct, member in SPEC_CORRECTIONS
|
|
if not any(f"{struct}.{member}:" in line for line in corrected))
|
|
if uncorrected:
|
|
raise SystemExit(f"{source['name']}: the base profile no longer states {uncorrected}: "
|
|
"review SPEC_CORRECTIONS")
|
|
required = list(names)
|
|
if completed:
|
|
capabilities[REQUIRED_FEATURES_BLOCK] = {"features": completed}
|
|
required.append(REQUIRED_FEATURES_BLOCK)
|
|
provenance = {
|
|
"source": "derived",
|
|
"base_url": MINIMUM_REQUIREMENTS["url"],
|
|
"base_sha256": MINIMUM_REQUIREMENTS["sha256"],
|
|
"base_profile": base_profile,
|
|
"registry": REGISTRY,
|
|
"rule": (f"features reduced to the unconditional VK_VERSION_1_0..1_{minor} feature "
|
|
"requirements of vk.xml; limits and properties are the base profile's "
|
|
"minimums, but where the Vulkan 1.2 specification states another "
|
|
"(spec_corrections)"),
|
|
"dropped_features": sorted(dropped),
|
|
"spec_corrections": sorted(corrected),
|
|
}
|
|
if completed:
|
|
provenance["added_features"] = sorted(f"{struct}.{member}"
|
|
for struct, members in completed.items()
|
|
for member in members)
|
|
provenance["rule"] += (f"; plus the {REQUIRED_FEATURES_BLOCK} block: each such "
|
|
"requirement the base profile omits (added_features)")
|
|
def flattened(struct, members):
|
|
nested = members.get("limits") if struct == "VkPhysicalDeviceProperties" else None
|
|
return nested if nested is not None else members
|
|
|
|
stated = {(struct, member) for block in capabilities.values()
|
|
for struct, members in block.get("properties", {}).items()
|
|
for member in flattened(struct, members)}
|
|
restated = sorted(f"{struct}.{member}" for struct, members in UNREQUIRED_PROPERTIES.items()
|
|
for member in flattened(struct, members) if (struct, member) in stated)
|
|
if restated:
|
|
raise SystemExit(f"{source['name']}: the base profile now states {restated}")
|
|
capabilities[UNREQUIRED_PROPERTIES_BLOCK] = {
|
|
"properties": copy.deepcopy(UNREQUIRED_PROPERTIES),
|
|
}
|
|
required.append(UNREQUIRED_PROPERTIES_BLOCK)
|
|
provenance["rule"] += (f"; plus the {UNREQUIRED_PROPERTIES_BLOCK} block: the weakest value "
|
|
"the specification permits for each property the product reads, and "
|
|
"the profiles layer sets, that the base profile leaves without a "
|
|
"requirement")
|
|
if source.get("runtime_floor"):
|
|
capabilities[RUNTIME_FLOOR_BLOCK] = copy.deepcopy(RUNTIME_FLOOR)
|
|
required.append(RUNTIME_FLOOR_BLOCK)
|
|
provenance["rule"] += (f"; plus the {RUNTIME_FLOOR_BLOCK} block: the device extensions, "
|
|
"features and limits metal2vulkan-runtime's floor requires "
|
|
"(crates/metal2vulkan-runtime/src/floor.rs), each limit at the "
|
|
"value the floor needs; its queue family, timestamp bits, memory "
|
|
"types and time domains have no profiles-schema form")
|
|
# A feature a block requires that fixes a property (FEATURE_EXACT_PROPERTIES) or conditions a
|
|
# limit (FEATURE_LIMITS) states its value where a block states the value without the feature.
|
|
required_true = {member for block in capabilities.values()
|
|
for members in block.get("features", {}).values()
|
|
for member, value in members.items() if value is True}
|
|
exact = []
|
|
conditioned = {**FEATURE_EXACT_PROPERTIES, **FEATURE_LIMITS}
|
|
for (struct, member), (feature, value) in sorted(conditioned.items()):
|
|
if feature not in required_true:
|
|
continue
|
|
for block in capabilities.values():
|
|
members = block.get("properties", {}).get(struct)
|
|
target = flattened(struct, members) if members is not None else {}
|
|
if member in target and target[member] != value:
|
|
exact.append(f"{struct}.{member}: {json.dumps(target[member])} -> "
|
|
f"{json.dumps(value)} ({feature})")
|
|
target[member] = value
|
|
if exact:
|
|
provenance["feature_limits"] = exact
|
|
provenance["rule"] += ("; where a feature a block requires fixes or conditions a "
|
|
"property, the specification's value for a device with the "
|
|
"feature (feature_limits)")
|
|
# After the floor's block, so the formats a feature it requires makes unconditional are stated.
|
|
required_format_blocks(capabilities, required, provenance, formats)
|
|
return document(source["name"], base["api-version"], source["label"],
|
|
f"Derived by {CONVERTER} from {base_profile}; see provenance.",
|
|
capabilities, required, [], provenance)
|
|
|
|
|
|
def import_capture(data, source, supplement=None, registry=None):
|
|
"""The profile `source` names in the `vulkaninfo --json` capture `data`, with its capability
|
|
blocks; with `supplement` (the device's `corpus-vulkan --capture-formats` document, parsed)
|
|
and the pinned `registry`, every format also states its `VkFormatProperties3`, and each color
|
|
attachment format its sample counts under `SAMPLE_COUNTS_KEY` ([`merge_formats`])."""
|
|
doc = json.loads(data)
|
|
profile = copy.deepcopy(doc["profiles"][source["profile"]])
|
|
names = referenced(profile["capabilities"] + profile.get("optionals", []))
|
|
capabilities = {name: doc["capabilities"][name] for name in names}
|
|
device = capabilities["device"]["properties"]
|
|
driver = (device.get("VkPhysicalDeviceVulkan12Properties")
|
|
or device.get("VkPhysicalDeviceDriverProperties") or {})
|
|
core = device["VkPhysicalDeviceProperties"]
|
|
transforms = []
|
|
# The profiles schema requires unique queue-family entries; MoltenVK reports several
|
|
# identical families. Keep the first of each and say so.
|
|
for block in capabilities.values():
|
|
families = block.get("queueFamiliesProperties")
|
|
if families:
|
|
unique = []
|
|
for family in families:
|
|
if family not in unique:
|
|
unique.append(family)
|
|
if len(unique) != len(families):
|
|
transforms.append(f"queueFamiliesProperties: dropped {len(families) - len(unique)} "
|
|
"entries identical to an earlier family (schema uniqueItems)")
|
|
block["queueFamiliesProperties"] = unique
|
|
provenance = {
|
|
"source": "vulkaninfo",
|
|
"command": source["command"],
|
|
"sha256": source["sha256"],
|
|
"source_profile": source["profile"],
|
|
"device_name": core["deviceName"],
|
|
"vendor_id": core["vendorID"],
|
|
"device_id": core["deviceID"],
|
|
"driver_name": driver.get("driverName"),
|
|
"driver_info": driver.get("driverInfo"),
|
|
"driver_version": str(core["driverVersion"]),
|
|
"api_version": profile["api-version"],
|
|
"host": source["host"],
|
|
"captured": profile["history"][0]["date"],
|
|
"transforms": transforms,
|
|
}
|
|
if registry is not None:
|
|
unmapped = conform_capture(capabilities, registry)
|
|
if unmapped:
|
|
provenance["unmapped"] = unmapped
|
|
if source.get("formats") is not None:
|
|
if supplement is None or registry is None:
|
|
raise SystemExit(f"{source['name']}: the source declares a formats supplement; pass "
|
|
f"--formats {source['name']}=PATH")
|
|
provenance["formats"], counts = merge_formats(capabilities, core, driver, supplement,
|
|
registry, source)
|
|
else:
|
|
counts = {}
|
|
profile["description"] = (f"Local capture of {source['profile']}; see provenance. "
|
|
f"{profile['description']}")
|
|
doc = {
|
|
"$schema": SCHEMA,
|
|
"provenance": provenance,
|
|
"capabilities": capabilities,
|
|
"profiles": {profile_name(source["name"]): profile},
|
|
}
|
|
if counts:
|
|
doc[SAMPLE_COUNTS_KEY] = {profile_name(source["name"]): counts}
|
|
return doc
|
|
|
|
|
|
def conform_capture(capabilities, registry):
|
|
"""Removes what a `vulkaninfo --json` capture states that the profiles schema of the pinned
|
|
registry cannot hold, and returns it as `provenance.unmapped` entries: an extension the
|
|
registry does not define (a driver's unpublished one), and a pointer member vulkaninfo did not
|
|
follow, which it writes as the string `NULL` where the schema types the array it points to.
|
|
Every other member is kept verbatim, a pointer member written as its array included."""
|
|
unmapped = []
|
|
for block_name, block in sorted(capabilities.items()):
|
|
extensions = block.get("extensions") or {}
|
|
for name in sorted(extensions):
|
|
if name not in registry.extension_types:
|
|
del extensions[name]
|
|
unmapped.append(f"{block_name}.extensions.{name} (not in the pinned registry)")
|
|
for section in ("features", "properties"):
|
|
for struct, members in sorted((block.get(section) or {}).items()):
|
|
if not isinstance(members, dict) or registry.resolve(struct) not in registry.structs:
|
|
continue
|
|
for name in sorted(members):
|
|
member = registry.member(registry.resolve(struct), name)
|
|
if member is not None and member.pointer and members[name] == "NULL":
|
|
del members[name]
|
|
unmapped.append(f"{block_name}.{section}.{struct}.{name} "
|
|
"(pointer member written as NULL)")
|
|
return unmapped
|
|
|
|
|
|
FORMAT_MEMBERS = ("linearTilingFeatures", "optimalTilingFeatures", "bufferFeatures")
|
|
|
|
|
|
def enum_value(registry, type_name, name):
|
|
"""The value `type_name`'s enumerant `name` has in the pinned registry."""
|
|
for value, known in registry.enum_values.get(registry.resolve(type_name), {}).items():
|
|
if known == name:
|
|
return value
|
|
raise SystemExit(f"{type_name} has no enumerant {name} in the pinned registry")
|
|
|
|
|
|
def flag_bits(registry, type_name, names):
|
|
"""The mask the flag `names` of bitmask `type_name` spell in the pinned registry."""
|
|
bits = registry.bitmask_bits[registry.resolve(type_name)]
|
|
mask = 0
|
|
for name in names:
|
|
mask |= enum_value(registry, bits, name)
|
|
return mask
|
|
|
|
|
|
def merge_formats(capabilities, core, driver, supplement, registry, source):
|
|
"""Writes `VkFormatProperties3` beside the `VkFormatProperties` of every format the capture's
|
|
capability blocks state, from `supplement`, the same device's `corpus-vulkan
|
|
--capture-formats` document, and returns its provenance record with the color
|
|
attachment sample counts of each stated format that has them, by name. Fails
|
|
unless both describe one device (name, vendor, device, driver ID, driver version, driver info,
|
|
API version, device type), each stated format is in the supplement with the capture's low 32
|
|
bits and its color attachment sample counts, those counts belong to a format whose optimal
|
|
tiling has `COLOR_ATTACHMENT`, and every format the supplement reports with a feature is one
|
|
the capture states."""
|
|
formats = source["formats"]
|
|
device = supplement.get("device") or {}
|
|
expected = {
|
|
"device": core["deviceName"],
|
|
"vendor_id": core["vendorID"],
|
|
"device_id": core["deviceID"],
|
|
"device_type": enum_value(registry, "VkPhysicalDeviceType", core["deviceType"]),
|
|
"api_version": core["apiVersion"],
|
|
"driver_id": enum_value(registry, "VkDriverId", driver["driverID"]),
|
|
"driver_version": core["driverVersion"],
|
|
"driver_info": driver["driverInfo"],
|
|
}
|
|
differ = [f"{key} {device.get(key)!r} (capture {value!r})" for key, value in expected.items()
|
|
if device.get(key) != value]
|
|
if differ:
|
|
raise SystemExit(f"{source['name']}: the formats supplement is of another device: "
|
|
+ "; ".join(differ))
|
|
reported = supplement.get("formats") or {}
|
|
# `VkFormatFeatureFlags2` shares its low bits with `VkFormatFeatureFlags`, but 32-bit
|
|
# `VkFormatProperties` can hold only the bits `VkFormatFeatureFlagBits` defines (bit 31, the
|
|
# storage read without a format, is 64-bit only).
|
|
legacy_bits = 0
|
|
for value in registry.enum_values.get(registry.bitmask_bits["VkFormatFeatureFlags"], {}):
|
|
legacy_bits |= value
|
|
color_attachment = flag_bits(registry, "VkFormatFeatureFlags2",
|
|
["VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BIT"])
|
|
stated = set()
|
|
counts = {}
|
|
for block in capabilities.values():
|
|
for name, entry in (block.get("formats") or {}).items():
|
|
if name not in reported:
|
|
raise SystemExit(f"{source['name']}: the formats supplement lacks {name}, "
|
|
"which the capture states")
|
|
masks = reported[name]
|
|
legacy = entry.get("VkFormatProperties") or {}
|
|
for member in FORMAT_MEMBERS:
|
|
low = flag_bits(registry, "VkFormatFeatureFlags", legacy.get(member, []))
|
|
if masks[member] & legacy_bits != low:
|
|
raise SystemExit(f"{source['name']}: {name}.{member}: the supplement's "
|
|
f"32-bit features {masks[member] & legacy_bits:#x} are not "
|
|
f"the capture's VkFormatProperties {low:#x}")
|
|
converter = Converter(registry)
|
|
try:
|
|
entry["VkFormatProperties3"] = {
|
|
member: converter.flag_names("VkFormatFeatureFlags2", masks[member])
|
|
for member in FORMAT_MEMBERS}
|
|
except Unmapped as error:
|
|
raise SystemExit(f"{source['name']}: {name}: {error} is outside the pinned "
|
|
"registry") from None
|
|
samples = masks.get(SAMPLE_COUNTS_MEMBER)
|
|
if samples is None:
|
|
raise SystemExit(f"{source['name']}: the formats supplement states no "
|
|
f"{SAMPLE_COUNTS_MEMBER} for {name}: recapture it")
|
|
if samples and not masks["optimalTilingFeatures"] & color_attachment:
|
|
raise SystemExit(f"{source['name']}: {name}: the supplement's color attachment "
|
|
f"sample counts {samples:#x} are of a format whose optimal "
|
|
"tiling has no COLOR_ATTACHMENT")
|
|
if samples:
|
|
try:
|
|
counts[name] = converter.flag_names("VkSampleCountFlags", samples)
|
|
except Unmapped as error:
|
|
raise SystemExit(f"{source['name']}: {name}: {error} is outside the pinned "
|
|
"registry") from None
|
|
stated.add(name)
|
|
unstated = sorted(name for name, masks in reported.items()
|
|
if name not in stated and any(masks[m] for m in FORMAT_MEMBERS))
|
|
if unstated:
|
|
raise SystemExit(f"{source['name']}: the formats supplement reports features of "
|
|
f"{', '.join(unstated)}, which the capture does not state")
|
|
return {
|
|
"command": formats["command"],
|
|
"sha256": formats["sha256"],
|
|
"queried": len(reported),
|
|
"stated": len(stated),
|
|
"color_attachment_sample_counts": len(counts),
|
|
}, dict(sorted(counts.items()))
|
|
|
|
|
|
def unlisted_identifiers(registry):
|
|
"""The registry's opaque identifier members that `HOST_IDENTITY` does not withhold."""
|
|
return sorted(registry.identifier_members() - HOST_IDENTITY)
|
|
|
|
|
|
def withhold_host_identity(doc):
|
|
"""The last step of every conversion: removes each `HOST_IDENTITY` member from the document's
|
|
property structs (a struct or section left empty goes too) and lists what it removed, as
|
|
`Struct.member`, in `provenance.withheld`. Returns `doc`, changed in place."""
|
|
withheld = set()
|
|
for block in doc["capabilities"].values():
|
|
properties = block.get("properties")
|
|
if properties is None:
|
|
continue
|
|
for struct in list(properties):
|
|
members = properties[struct]
|
|
for member in [name for name in members if name in HOST_IDENTITY]:
|
|
del members[member]
|
|
withheld.add(f"{struct}.{member}")
|
|
if not members:
|
|
del properties[struct]
|
|
if not properties:
|
|
del block["properties"]
|
|
if withheld:
|
|
doc["provenance"]["withheld"] = sorted(withheld)
|
|
return doc
|
|
|
|
|
|
def target_of(out, source):
|
|
"""Where `source`'s file goes under the output directory `out`."""
|
|
directory = out / BELOW_FLOOR_DIR if source.get("below_floor") else out
|
|
return directory / f"{source['name']}.json"
|
|
|
|
|
|
def render(doc):
|
|
return json.dumps(doc, indent=2, ensure_ascii=False) + "\n"
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
|
|
parser.add_argument("--out", type=Path, default=OUT_DIR)
|
|
parser.add_argument("--offline", action="store_true", help="use only the download cache")
|
|
parser.add_argument("--only", action="append", default=[], help="regenerate one profile")
|
|
parser.add_argument("--capture", action="append", default=[], metavar="NAME=PATH",
|
|
help="a vulkaninfo --json capture for a vulkaninfo-kind profile")
|
|
parser.add_argument("--formats", action="append", default=[], metavar="NAME=PATH",
|
|
help="a corpus-vulkan --capture-formats supplement for that capture")
|
|
args = parser.parse_args()
|
|
captures = dict(item.split("=", 1) for item in args.capture)
|
|
supplements = dict(item.split("=", 1) for item in args.formats)
|
|
registry = None
|
|
formats = None
|
|
args.out.mkdir(parents=True, exist_ok=True)
|
|
for source in SOURCES:
|
|
if args.only and source["name"] not in args.only:
|
|
continue
|
|
target = target_of(args.out, source)
|
|
target.parent.mkdir(parents=True, exist_ok=True)
|
|
kind = source["kind"]
|
|
recaptured = kind == "vulkaninfo" and source["name"] in captures
|
|
presented = source.get("layer_presentation", False)
|
|
if (kind in ("gpuinfo", "derived") or recaptured or presented) and registry is None:
|
|
registry = Registry(fetch(REGISTRY["url"], REGISTRY["sha256"], args.offline))
|
|
unlisted = unlisted_identifiers(registry)
|
|
if unlisted:
|
|
raise SystemExit(f"vk.xml declares device identifiers HOST_IDENTITY does not "
|
|
f"withhold: {', '.join(unlisted)}")
|
|
if kind in ("khronos", "derived") and formats is None:
|
|
spec = required_formats.SPEC
|
|
text = fetch(spec["url"], spec["sha256"], args.offline).decode("utf-8")
|
|
formats = required_formats.required_formats(text, required_formats.VERSION_1_2)
|
|
if kind == "gpuinfo":
|
|
data = fetch(GPUINFO_REPORT.format(source["report"]), source["sha256"], args.offline)
|
|
doc = convert_gpuinfo(registry, json.loads(data), source)
|
|
elif kind == "khronos":
|
|
doc = extract(fetch(source["url"], source["sha256"], args.offline), source, formats,
|
|
registry)
|
|
elif kind == "derived":
|
|
data = fetch(MINIMUM_REQUIREMENTS["url"], MINIMUM_REQUIREMENTS["sha256"], args.offline)
|
|
doc = derive(registry, data, source, formats)
|
|
elif kind == "vulkaninfo":
|
|
path = captures.get(source["name"])
|
|
if path is None:
|
|
# The committed conversion stands.
|
|
print(f"kept the capture in {target.name}: no --capture {source['name']}=PATH "
|
|
"(needs a device)")
|
|
doc = json.loads(target.read_text())
|
|
else:
|
|
data = Path(path).read_bytes()
|
|
if sha256(data) != source["sha256"]:
|
|
raise SystemExit(f"{path}: sha256 {sha256(data)} does not match pin")
|
|
supplement = None
|
|
if source.get("formats") is not None:
|
|
formats_path = supplements.get(source["name"])
|
|
if formats_path is None:
|
|
raise SystemExit(f"{source['name']}: pass --formats "
|
|
f"{source['name']}=PATH with the capture")
|
|
formats_data = Path(formats_path).read_bytes()
|
|
if sha256(formats_data) != source["formats"]["sha256"]:
|
|
raise SystemExit(f"{formats_path}: sha256 {sha256(formats_data)} does "
|
|
"not match pin")
|
|
supplement = json.loads(formats_data)
|
|
doc = import_capture(data, source, supplement, registry)
|
|
else:
|
|
raise SystemExit(f"unknown source kind {kind}")
|
|
text = render(withhold_host_identity(doc))
|
|
if not target.exists() or target.read_text() != text:
|
|
target.write_text(text)
|
|
print(f"wrote {target.relative_to(REPO) if target.is_relative_to(REPO) else target}")
|
|
else:
|
|
print(f"unchanged {target.name}")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|