Skip to content

Commit e707326

Browse files
vkprofiles: Remove 'UNIQUE', replaced by PULL_ALIASES and STRIP_DUPLICATION
- Also add tests for pull and strip - Fix striping for the same block
1 parent 4741db6 commit e707326

12 files changed

Lines changed: 1040 additions & 789 deletions

profiles/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ add_custom_target(VpGenerate-Libraries
131131
--api ${API_TYPE}
132132
--registry ${VULKAN_HEADERS_INSTALL_DIR}/${CMAKE_INSTALL_DATADIR}/vulkan/registry/vk.xml
133133
--input ${CMAKE_CURRENT_LIST_DIR}
134+
--mode schema
134135
COMMAND ${VKPROFILES_EXE} library
135136
--api ${API_TYPE}
136137
--registry ${VULKAN_HEADERS_INSTALL_DIR}/${CMAKE_INSTALL_DATADIR}/vulkan/registry/vk.xml

scripts/README.md

Lines changed: 16 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
```bash
66
vkprofiles <command> [options]
7-
87
```
98

109
---
@@ -17,56 +16,40 @@ Converts implicit profile JSON files to explicit profile JSON files by pulling V
1716

1817
```bash
1918
vkprofiles convert --registry vk.xml --input path/to/input_dir --output path/to/output_dir [options]
20-
2119
```
2220

2321
* `--input`, `-i`: *(Required)* Path to input profile JSON file or directory.
24-
25-
2622
* `--output`, `-o`: *(Required)* Path to output directory or file.
27-
28-
2923
* `--registry`, `-r`: Path to `vk.xml`.
30-
31-
3224
* `--api`: Target API variant (`vulkan`). Default: `vulkan`.
33-
34-
3525
* `--format`: Output formatting style (`flatten` or `tree`). Default: `flatten`.
36-
37-
3826
* `--mode`: Space-separated list of conversion capabilities to apply. Default: all flags.
39-
40-
4127
* `--validate`, `-v`: Validate profile files against schema prior to conversion.
4228

43-
44-
4529
#### Conversion Mode Flags (`--mode`)
4630

31+
Conversion flags are processed in a deterministic internal pipeline order regardless of the order specified on the command line. This multi-phase sequence ensures that all extension dependencies and core promotions are populated first, structural feature/property/format aliases are subsequently expanded across all required structures, redundant inherited definitions are stripped, and capability blocks are consolidated as the final step.
32+
4733
| Mode Value | Description |
4834
| --- | --- |
49-
| `strip-duplication` | Recursively removes duplicate extension requirements, features, properties, and format flags that are already satisfied by parent profiles in the inheritance chain.
50-
51-
|
5235
| `pull-dependences` | Queries `vk.xml` to automatically pull in and append all dependent extensions required by any extensions listed in the capability blocks.
5336

54-
|
55-
| `pull-aliases` | Automatically expands structural capability aliases (features, properties, and format flags) across core version bundle structures and extension structs (e.g., mapping `VkPhysicalDevice16BitStorageFeatures` to `VkPhysicalDeviceVulkan11Features`).
56-
5737
|
5838
| `pull-promoted-extensions` | Adds version-specific `vulkan1Xpulledrequirements` capability blocks containing all extensions that were promoted into the target Vulkan core version.
5939

6040
|
61-
| `ignore-extension-versions` | Forces all required extension spec versions to `1`, ignoring specific extension version numbers.
41+
| `pull-aliases` | Automatically expands structural capability aliases (features, properties, and format flags) across core version bundle structures and extension structs (e.g., mapping `VkPhysicalDevice16BitStorageFeatures` to `VkPhysicalDeviceVulkan11Features`).
6242

6343
|
64-
| `unique` | Strips duplicate capability members from lower-priority structures (e.g. extension structs or split core structs) if a higher-priority structure (e.g. `VkPhysicalDeviceVulkan1XFeatures`) already defines them with identical values.
44+
| `strip-duplication` | Recursively removes duplicate extension requirements, features, properties, and format flags that are already satisfied by parent profiles in the inheritance chain.
6545

6646
|
6747
| `consolidate` | Combines all mandatory capability blocks across a profile into a single consolidated requirement block (`<profile_name>_requirements`).
6848

6949
|
50+
| `ignore-extension-versions` | Modifier flag: Forces all required extension spec versions to `1`, ignoring specific extension version numbers during extension pulling.
51+
52+
|
7053

7154
**Example:**
7255

@@ -75,9 +58,8 @@ vkprofiles convert \
7558
--registry vk.xml \
7659
--input profiles/LunarG \
7760
--output profiles/generated \
78-
--mode unique pull-dependences \
61+
--mode pull-dependences pull-aliases strip-duplication \
7962
--validate
80-
8163
```
8264

8365
---
@@ -88,30 +70,20 @@ Validates one or more profile JSON files against the Vulkan Profiles JSON schema
8870

8971
```bash
9072
vkprofiles validate --registry vk.xml --input path/to/profiles [options]
91-
9273
```
9374

9475
* `--input`, `-i`: *(Required)* Path to profile JSON file or directory to validate.
95-
96-
9776
* `--registry`, `-r`: Path to `vk.xml` (used to generate a schema if `--schema` is omitted).
98-
99-
10077
* `--schema`, `-s`: Path to an explicit JSON schema file (`profiles-*.json`).
101-
102-
10378
* `--api`: Target API variant (`vulkan`). Default: `vulkan`.
10479

105-
106-
10780
**Example:**
10881

10982
```bash
11083
vkprofiles validate \
11184
--api vulkan \
11285
--registry vk.xml \
11386
--input profiles/LunarG
114-
11587
```
11688

11789
---
@@ -122,27 +94,19 @@ Generates a Vulkan Profiles JSON schema file from `vk.xml`.
12294

12395
```bash
12496
vkprofiles schema --registry vk.xml --output path/to/schema.json [options]
125-
12697
```
12798

12899
* `--output`, `-o`: *(Required)* Output path for generated JSON schema file.
129-
130-
131100
* `--registry`, `-r`: Path to `vk.xml`.
132-
133-
134101
* `--api`: Target API variant (`vulkan`). Default: `vulkan`.
135102

136-
137-
138103
**Example:**
139104

140105
```bash
141106
vkprofiles schema \
142107
--api vulkan \
143108
--registry vk.xml \
144109
--output schema/profiles-0.8-latest.json
145-
146110
```
147111

148112
---
@@ -153,52 +117,23 @@ Combines multiple profile JSON files into a single merged profile JSON file via
153117

154118
```bash
155119
vkprofiles merge --registry vk.xml --input path/to/profiles --output path/to/merged.json [options]
156-
157120
```
158121

159122
* `--registry`, `-r`: *(Required)* Path to `vk.xml`.
160-
161-
162123
* `--output`, `-o`: *(Required)* Output JSON file path.
163-
164-
165124
* `--input`, `-i`: Directory path containing profiles to merge.
166-
167-
168125
* `--config`, `-c`: Path to JSON merge config file.
169-
170-
171126
* `--mode`, `-m`: Combination mode (`intersection` or `union`). Default: `intersection`.
172-
173-
174127
* `--format`: Output formatting style (`flatten` or `pretty`). Default: `pretty`.
175-
176-
177128
* `--profile-name`: Override output profile name.
178-
179-
180129
* `--profile-version`: Set profile version number. Default: `1`.
181-
182-
183130
* `--profile-label`: Set profile label string.
184-
185-
186131
* `--profile-desc`: Set profile description string.
187-
188-
189132
* `--profile-date`: Set profile release date (`YYYY-MM-DD`).
190-
191-
192133
* `--profile-api-version`: Set target Vulkan API version (e.g., `1.3.280`).
193-
194-
195134
* `--profile-stage`: Set development stage (`ALPHA`, `BETA`, `STABLE`). Default: `STABLE`.
196-
197-
198135
* `--strip-duplicate-structs`: Strip duplicate structure entries.
199136

200-
201-
202137
**Example (Creating `VP_LUNARG_desktop_baseline.json`):**
203138
In the repository build process, `VP_LUNARG_desktop_baseline.json` is constructed by calculating the intersection of historical desktop baseline profiles listed in `VP_LUNARG_desktop_baseline_config.json`:
204139

@@ -208,7 +143,6 @@ vkprofiles merge \
208143
--config profiles/LunarG/VP_LUNARG_desktop_baseline_config.json \
209144
--output profiles/LunarG/VP_LUNARG_desktop_baseline.json \
210145
--strip-duplicate-structs
211-
212146
```
213147

214148
**Example (Merging Directory to Single Profile):**
@@ -223,7 +157,6 @@ vkprofiles merge \
223157
--profile-date 2026-06-22 \
224158
--profile-stage BETA \
225159
--profile-api-version 1.4.353
226-
227160
```
228161

229162
---
@@ -232,52 +165,30 @@ vkprofiles merge \
232165

233166
Generates C/C++ Vulkan Profiles API library headers (`vulkan_profiles.h`, `vulkan_profiles.hpp`) and source file (`vulkan_profiles.cpp`).
234167

168+
> [!IMPORTANT]
169+
> **Device Creation Requirements**
170+
> Generating a Vulkan Profiles API library suitable for creating a `VkDevice` instance requires that the input profile JSON files contain no duplicate Vulkan feature structures. The Vulkan specification prohibits passing superseded or duplicate feature structures simultaneously in the `pNext` chain during device creation.
171+
> If the source profile JSON files contain redundant or unexpanded feature structures, developers can use the `--convert` flag with `pull-aliases` and `strip-duplication` modes during library generation to automatically sanitize, expand, and deduplicate feature structures before C/C++ code generation.
172+
235173
```bash
236174
vkprofiles library --registry vk.xml --input path/to/profiles --output path/to/include [options]
237-
238175
```
239176

240177
* `--registry`, `-r`: *(Required)* Path to `vk.xml`.
241-
242-
243178
* `--input`, `-i`: *(Required)* Directory containing input profile JSON files.
244-
245-
246179
* `--input-filenames`: Comma-separated list of profile filenames.
247-
248-
249180
* `--output`, `-o`, `--output-inc`: Target header output directory.
250-
251-
252181
* `--output-src`: Target source output directory. If omitted in `header+source` mode, defaults to `--output`.
253-
254-
255182
* `--output-filename`: Base filename for generated files. Default: `vulkan_profiles`.
256-
257-
258183
* `--mode`: Library generation mode (`header-only`, `header+source`). Default: `header-only` and `header+source`.
259-
260-
261184
* `--output-schema`: Output file path for generated JSON schema.
262-
263-
264-
* `--convert`: Apply profiles data conversion (e.g., `unique`, `pull-aliases`) prior to generation.
265-
266-
185+
* `--convert`: Apply profiles data conversion (e.g., `pull-aliases`, `strip-duplication`, `pull-dependences`) prior to generation.
267186
* `--intermediate`: Directory path for intermediate converted JSON files (used with `--convert`).
268-
269-
270187
* `--validate`, `-v`: Validate profiles against schema during generation.
271-
272-
273188
* `--debug`, `-d`: Generate debug variant of library code.
274-
275-
276189
* `--config`, `-c`: Build configuration (`release` or `debug`).
277190

278-
279-
280-
**Example (Header + Source):**
191+
**Example (Header + Source with Automatic Conversion):**
281192

282193
```bash
283194
vkprofiles library \
@@ -289,8 +200,8 @@ vkprofiles library \
289200
--output-src library/source \
290201
--output-filename vulkan_profiles \
291202
--mode header+source \
203+
--convert pull-aliases strip-duplication \
292204
--config release
293-
294205
```
295206

296207
**Example (Header-Only):**
@@ -302,7 +213,6 @@ vkprofiles library \
302213
--input profiles \
303214
--output library/include/vulkan \
304215
--mode header-only
305-
306216
```
307217

308218
---
@@ -313,25 +223,14 @@ Generates Markdown documentation from profile JSON files.
313223

314224
```bash
315225
vkprofiles doc --registry vk.xml --input path/to/profiles --output PROFILES.md [options]
316-
317226
```
318227

319228
* `--registry`, `-r`: *(Required)* Path to `vk.xml`.
320-
321-
322229
* `--input`, `-i`: *(Required)* Directory containing profile JSON files.
323-
324-
325230
* `--output`, `-o`: *(Required)* Output Markdown file path.
326-
327-
328231
* `--input-filenames`: Comma-separated list of profile filenames.
329-
330-
331232
* `--validate`, `-v`: Validate profile JSON files before generating documentation.
332233

333-
334-
335234
**Example:**
336235

337236
```bash
@@ -341,7 +240,6 @@ vkprofiles doc \
341240
--input profiles \
342241
--input-filenames "VP_KHR_roadmap.json,VP_LUNARG_minimum_requirements.json" \
343242
--output PROFILES.md
344-
345243
```
346244

347245
---
@@ -362,25 +260,17 @@ Generates `profiles_generated.cpp` for the Vulkan Profiles layer (`VkLayer_khron
362260
vkprofiles layer --registry vk.xml --output layer/profiles_generated.cpp
363261

364262
```
365-
366263
* `--registry`, `-r`: Path to `vk.xml`.
367-
368-
369264
* `--output`, `-o`: Output path for generated layer source file.
370-
371-
372265
* `--api`: Target API variant (`vulkan`).
373266

374-
375-
376267
**Example:**
377268

378269
```bash
379270
vkprofiles layer \
380271
--api vulkan \
381272
--registry vk.xml \
382273
--output layer/profiles_generated.cpp
383-
384274
```
385275

386276
---
@@ -391,22 +281,13 @@ Generates synthetic test profile JSON (`VP_LUNARG_test_api_generated.json`) and
391281

392282
```bash
393283
vkprofiles tests --registry vk.xml --output-profile path/to/test.json --output-cpp path/to/tests.cpp
394-
395284
```
396285

397286
* `--registry`, `-r`: *(Required)* Path to `vk.xml`.
398-
399-
400287
* `--output-profile`: *(Required)* Output path for synthetic test profile JSON.
401-
402-
403288
* `--output-cpp`: Output path for C++ test source file.
404-
405-
406289
* `--api`: Target API variant (`vulkan`).
407290

408-
409-
410291
**Example:**
411292

412293
```bash

scripts/profiles.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def main(argv):
6262
validate_parser.add_argument('--registry', '-r', action='store', help='Use a specific Vulkan registry file (vk.xml).')
6363
validate_parser.add_argument('--schema', '-s', action='store', help='Use a profile schema (profiles-*.json). By default, generate a profile schema vk.xml.')
6464
validate_parser.add_argument('--input', '-i', action='store', required=True, help='Path to the input profiles files.')
65-
validate_parser.add_argument('--mode', '-m', nargs='*', action='store', choices=['schema', 'analysis'], default=['schema', 'analysis'], help="Validation mode(s) to execute (default: schema analysis).")
65+
validate_parser.add_argument('--mode', '-m', nargs='*', action='store', choices=['schema', 'analysis'], default=['schema'], help="Validation mode(s) to execute (default: schema analysis).")
6666

6767
schema_parser = subparsers.add_parser('schema', help='Generate a profile json schema file.')
6868
schema_parser.add_argument('--registry', '-r', action='store', help='Use a specific Vulkan registry file (vk.xml).')

0 commit comments

Comments
 (0)