From 5a9d7b66a2eaeddd5577a299e57be5d017ae206a Mon Sep 17 00:00:00 2001 From: Piers Daniell Date: Fri, 30 Jan 2026 16:48:34 -0700 Subject: [PATCH 1/5] Initial support for sType and pNext initialization --- scripts/generator.py | 8 ++++++++ scripts/genvk.py | 1 + xml/Makefile | 2 +- xml/registry.rnc | 3 ++- xml/vk.xml | 12 +++++++++++- 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/scripts/generator.py b/scripts/generator.py index 2ed6fb57f..f4f1f88d7 100644 --- a/scripts/generator.py +++ b/scripts/generator.py @@ -1143,6 +1143,14 @@ def makeCParamDecl(self, param, aligncol): paramdecl += f"{prefix.replace('const ', '') + text} const{tail}" else: paramdecl += prefix + text + tail + + if elem.tag == 'name': + if elem.text == 'sType' and param.attrib.get('values') != None: + paramdecl += ' VK_CPP11_DEFAULT(' + param.attrib['values'] + ')' + elif elem.text == 'pNext': + paramdecl += ' VK_CPP11_DEFAULT(nullptr)' + elif param.attrib.get('default') != None: + paramdecl += ' VK_CPP11_DEFAULT(' + param.attrib['default'] + ')' # Clear prefix for subsequent iterations prefix = '' diff --git a/scripts/genvk.py b/scripts/genvk.py index 432ac31dc..6438e32c3 100755 --- a/scripts/genvk.py +++ b/scripts/genvk.py @@ -449,6 +449,7 @@ def makeGenOpts(args): 'VK_AMDX_dense_geometry_format', 'VK_AMDX_shader_enqueue', 'VK_NV_cuda_kernel_launch', + 'VK_NV_present_metering', ] betaSuppressExtensions = [ diff --git a/xml/Makefile b/xml/Makefile index 45c82f8df..51cb8042f 100644 --- a/xml/Makefile +++ b/xml/Makefile @@ -116,7 +116,7 @@ $(VULKAN)/vk_platform.h: $(STATIC)/vk_platform.h # Python and XML files on which vulkan_core.h depends GENSCRIPT = $(SCRIPTS)/genvk.py VKXML = vk.xml -VKH_DEPENDS = $(VKXML) $(GENSCRIPT) $(SCRIPTS)/reg.py $(SCRIPTS)/generator.py +VKH_DEPENDS = $(VKXML) $(GENSCRIPT) $(SCRIPTS)/reg.py $(SCRIPTS)/generator.py $(SCRIPTS)/cgenerator.py $(HEADERS_H): $(VKH_DEPENDS) $(MKDIR) $(VULKAN) diff --git a/xml/registry.rnc b/xml/registry.rnc index 915c72ff8..41f6a17bc 100644 --- a/xml/registry.rnc +++ b/xml/registry.rnc @@ -321,7 +321,8 @@ TypeStruct = attribute selector { text }?, attribute selection { VkEnumNameList_t }?, NoAutoValidityAttr?, - attribute values { VkEnumNameList_t }?, + attribute values { text }?, + attribute default { text }?, attribute limittype { text }?, attribute objecttype { text }?, attribute deprecated { text }?, diff --git a/xml/vk.xml b/xml/vk.xml index c59a30950..a92ba9806 100755 --- a/xml/vk.xml +++ b/xml/vk.xml @@ -236,6 +236,15 @@ branch of the member gitlab server. #endif #endif + +#ifndef VK_CPP11_DEFAULT + #if (defined(__cplusplus) && (__cplusplus >= 201103L)) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201103L)) + #define VK_CPP11_DEFAULT(VALUE) { VALUE } + #else + #define VK_CPP11_DEFAULT(VALUE) + #endif +#endif + struct ANativeWindow; struct AHardwareBuffer; #ifdef __OBJC__ @@ -1710,7 +1719,7 @@ typedef void* MTLSharedEvent_id; float depthBiasConstantFactor float depthBiasClamp float depthBiasSlopeFactor - float lineWidth + float lineWidth VkStructureType sType @@ -18499,6 +18508,7 @@ endif::VK_KHR_internally_synchronized_queues[] + From 8876bef2ee15cfee05a79cc36bbd66ca33a35057 Mon Sep 17 00:00:00 2001 From: Piers Daniell Date: Fri, 30 Jan 2026 16:50:08 -0700 Subject: [PATCH 2/5] Fix tabs vs spaces --- xml/registry.rnc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xml/registry.rnc b/xml/registry.rnc index 41f6a17bc..697cfb6ab 100644 --- a/xml/registry.rnc +++ b/xml/registry.rnc @@ -322,7 +322,7 @@ TypeStruct = attribute selection { VkEnumNameList_t }?, NoAutoValidityAttr?, attribute values { text }?, - attribute default { text }?, + attribute default { text }?, attribute limittype { text }?, attribute objecttype { text }?, attribute deprecated { text }?, From 976f0219a203da4c07154bf7cd45162d81d24ffd Mon Sep 17 00:00:00 2001 From: Piers Daniell Date: Mon, 2 Feb 2026 17:04:12 -0700 Subject: [PATCH 3/5] Add spec definition for VK_CPP11_DEFAULT --- appendices/boilerplate.adoc | 22 ++++++++++++++++++++++ xml/vk.xml | 4 ++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/appendices/boilerplate.adoc b/appendices/boilerplate.adoc index 0b3d297fd..9ed552bef 100644 --- a/appendices/boilerplate.adoc +++ b/appendices/boilerplate.adoc @@ -310,6 +310,28 @@ current Vulkan headers with their project in this case. endif::VKSC_VERSION_1_0[] -- +==== Vulkan Helper Macros + +[open,refpage='VK_CPP11_DEFAULT',desc='Function macro to allow optional C++11 default member initializers',type='defines'] +-- +dname:VK_CPP11_DEFAULT defines a function macro to allow optional structure default +member initializers when compiling the Vulkan headers with a C++11 capable compiler. + +include::{generated}/api/defines/VK_CPP11_DEFAULT.adoc[] + + * pname:value is the literal default value for the struct member. + +By default the dname:VK_CPP11_DEFAULT will define the default member initializers +when compiling the header with a C++ version of C++11 and above. +The Vulkan headers allow the application to override the default definition of +this macro to either disable the functionality, or modify how it +behaves. + +With default member initializers active applications can avoid assigning the +pname:sType, pname:pNext and some other member values when initializing new +objects of the Vulkan structures. +-- + [[boilerplate-wsi-header]] == Window System-Specific Header Control (Informative) diff --git a/xml/vk.xml b/xml/vk.xml index a92ba9806..1ff0de4c9 100755 --- a/xml/vk.xml +++ b/xml/vk.xml @@ -239,9 +239,9 @@ branch of the member gitlab server. #ifndef VK_CPP11_DEFAULT #if (defined(__cplusplus) && (__cplusplus >= 201103L)) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201103L)) - #define VK_CPP11_DEFAULT(VALUE) { VALUE } + #define VK_CPP11_DEFAULT(value) { value } #else - #define VK_CPP11_DEFAULT(VALUE) + #define VK_CPP11_DEFAULT(value) #endif #endif From 8803a4969661907adac2a17c83b9d9051076d0a6 Mon Sep 17 00:00:00 2001 From: Piers Daniell Date: Mon, 2 Feb 2026 17:12:10 -0700 Subject: [PATCH 4/5] Update build expectations for new macro --- build_tests/expectations/all-1.0.html | 8 ++++---- build_tests/expectations/all.html | 8 ++++---- build_tests/expectations/copy2-1.0.html | 8 ++++---- build_tests/expectations/core.html | 8 ++++---- build_tests/expectations/hic-1.0.html | 8 ++++---- build_tests/expectations/hic.html | 8 ++++---- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/build_tests/expectations/all-1.0.html b/build_tests/expectations/all-1.0.html index da5a60e5f..41b77223d 100644 --- a/build_tests/expectations/all-1.0.html +++ b/build_tests/expectations/all-1.0.html @@ -326,8 +326,8 @@

2.1. Lo
typedef struct VkCopyBufferToImageInfo2 {
-    VkStructureType              sType;
-    const void*                  pNext;
+    VkStructureType              sType VK_CPP11_DEFAULT(VK_STRUCTURE_TYPE_COPY_BUFFER_TO_IMAGE_INFO_2);
+    const void*                  pNext VK_CPP11_DEFAULT(nullptr);
     VkBuffer                     srcBuffer;
     VkImage                      dstImage;
     VkImageLayout                dstImageLayout;
@@ -524,8 +524,8 @@ 

2.1. Lo
typedef struct VkBufferImageCopy2 {
-    VkStructureType             sType;
-    const void*                 pNext;
+    VkStructureType             sType VK_CPP11_DEFAULT(VK_STRUCTURE_TYPE_BUFFER_IMAGE_COPY_2);
+    const void*                 pNext VK_CPP11_DEFAULT(nullptr);
     VkDeviceSize                bufferOffset;
     uint32_t                    bufferRowLength;
     uint32_t                    bufferImageHeight;
diff --git a/build_tests/expectations/all.html b/build_tests/expectations/all.html
index d7504dec5..0330c313d 100644
--- a/build_tests/expectations/all.html
+++ b/build_tests/expectations/all.html
@@ -357,8 +357,8 @@ 

2.1. Lo
// Provided by VK_VERSION_1_3
 typedef struct VkCopyBufferToImageInfo2 {
-    VkStructureType              sType;
-    const void*                  pNext;
+    VkStructureType              sType VK_CPP11_DEFAULT(VK_STRUCTURE_TYPE_COPY_BUFFER_TO_IMAGE_INFO_2);
+    const void*                  pNext VK_CPP11_DEFAULT(nullptr);
     VkBuffer                     srcBuffer;
     VkImage                      dstImage;
     VkImageLayout                dstImageLayout;
@@ -556,8 +556,8 @@ 

2.1. Lo
// Provided by VK_VERSION_1_3
 typedef struct VkBufferImageCopy2 {
-    VkStructureType             sType;
-    const void*                 pNext;
+    VkStructureType             sType VK_CPP11_DEFAULT(VK_STRUCTURE_TYPE_BUFFER_IMAGE_COPY_2);
+    const void*                 pNext VK_CPP11_DEFAULT(nullptr);
     VkDeviceSize                bufferOffset;
     uint32_t                    bufferRowLength;
     uint32_t                    bufferImageHeight;
diff --git a/build_tests/expectations/copy2-1.0.html b/build_tests/expectations/copy2-1.0.html
index cd685d3cf..f6823db3c 100644
--- a/build_tests/expectations/copy2-1.0.html
+++ b/build_tests/expectations/copy2-1.0.html
@@ -305,8 +305,8 @@ 

2.1. Lo
typedef struct VkCopyBufferToImageInfo2 {
-    VkStructureType              sType;
-    const void*                  pNext;
+    VkStructureType              sType VK_CPP11_DEFAULT(VK_STRUCTURE_TYPE_COPY_BUFFER_TO_IMAGE_INFO_2);
+    const void*                  pNext VK_CPP11_DEFAULT(nullptr);
     VkBuffer                     srcBuffer;
     VkImage                      dstImage;
     VkImageLayout                dstImageLayout;
@@ -484,8 +484,8 @@ 

2.1. Lo
typedef struct VkBufferImageCopy2 {
-    VkStructureType             sType;
-    const void*                 pNext;
+    VkStructureType             sType VK_CPP11_DEFAULT(VK_STRUCTURE_TYPE_BUFFER_IMAGE_COPY_2);
+    const void*                 pNext VK_CPP11_DEFAULT(nullptr);
     VkDeviceSize                bufferOffset;
     uint32_t                    bufferRowLength;
     uint32_t                    bufferImageHeight;
diff --git a/build_tests/expectations/core.html b/build_tests/expectations/core.html
index 62d71a7b0..56e453f62 100644
--- a/build_tests/expectations/core.html
+++ b/build_tests/expectations/core.html
@@ -331,8 +331,8 @@ 

2.1. Lo
// Provided by VK_VERSION_1_3
 typedef struct VkCopyBufferToImageInfo2 {
-    VkStructureType              sType;
-    const void*                  pNext;
+    VkStructureType              sType VK_CPP11_DEFAULT(VK_STRUCTURE_TYPE_COPY_BUFFER_TO_IMAGE_INFO_2);
+    const void*                  pNext VK_CPP11_DEFAULT(nullptr);
     VkBuffer                     srcBuffer;
     VkImage                      dstImage;
     VkImageLayout                dstImageLayout;
@@ -505,8 +505,8 @@ 

2.1. Lo
// Provided by VK_VERSION_1_3
 typedef struct VkBufferImageCopy2 {
-    VkStructureType             sType;
-    const void*                 pNext;
+    VkStructureType             sType VK_CPP11_DEFAULT(VK_STRUCTURE_TYPE_BUFFER_IMAGE_COPY_2);
+    const void*                 pNext VK_CPP11_DEFAULT(nullptr);
     VkDeviceSize                bufferOffset;
     uint32_t                    bufferRowLength;
     uint32_t                    bufferImageHeight;
diff --git a/build_tests/expectations/hic-1.0.html b/build_tests/expectations/hic-1.0.html
index 0849b558d..f27ecfe66 100644
--- a/build_tests/expectations/hic-1.0.html
+++ b/build_tests/expectations/hic-1.0.html
@@ -307,8 +307,8 @@ 

2.1. Lo
typedef struct VkCopyBufferToImageInfo2 {
-    VkStructureType              sType;
-    const void*                  pNext;
+    VkStructureType              sType VK_CPP11_DEFAULT(VK_STRUCTURE_TYPE_COPY_BUFFER_TO_IMAGE_INFO_2);
+    const void*                  pNext VK_CPP11_DEFAULT(nullptr);
     VkBuffer                     srcBuffer;
     VkImage                      dstImage;
     VkImageLayout                dstImageLayout;
@@ -486,8 +486,8 @@ 

2.1. Lo
typedef struct VkBufferImageCopy2 {
-    VkStructureType             sType;
-    const void*                 pNext;
+    VkStructureType             sType VK_CPP11_DEFAULT(VK_STRUCTURE_TYPE_BUFFER_IMAGE_COPY_2);
+    const void*                 pNext VK_CPP11_DEFAULT(nullptr);
     VkDeviceSize                bufferOffset;
     uint32_t                    bufferRowLength;
     uint32_t                    bufferImageHeight;
diff --git a/build_tests/expectations/hic.html b/build_tests/expectations/hic.html
index 4be2257d5..2cc8db13e 100644
--- a/build_tests/expectations/hic.html
+++ b/build_tests/expectations/hic.html
@@ -342,8 +342,8 @@ 

2.1. Lo
// Provided by VK_VERSION_1_3
 typedef struct VkCopyBufferToImageInfo2 {
-    VkStructureType              sType;
-    const void*                  pNext;
+    VkStructureType              sType VK_CPP11_DEFAULT(VK_STRUCTURE_TYPE_COPY_BUFFER_TO_IMAGE_INFO_2);
+    const void*                  pNext VK_CPP11_DEFAULT(nullptr);
     VkBuffer                     srcBuffer;
     VkImage                      dstImage;
     VkImageLayout                dstImageLayout;
@@ -523,8 +523,8 @@ 

2.1. Lo
// Provided by VK_VERSION_1_3
 typedef struct VkBufferImageCopy2 {
-    VkStructureType             sType;
-    const void*                 pNext;
+    VkStructureType             sType VK_CPP11_DEFAULT(VK_STRUCTURE_TYPE_BUFFER_IMAGE_COPY_2);
+    const void*                 pNext VK_CPP11_DEFAULT(nullptr);
     VkDeviceSize                bufferOffset;
     uint32_t                    bufferRowLength;
     uint32_t                    bufferImageHeight;

From a76695b70def9d684ad2eb894ce22877babd4311 Mon Sep 17 00:00:00 2001
From: Piers Daniell 
Date: Tue, 3 Feb 2026 13:54:13 -0700
Subject: [PATCH 5/5] A couple more useful defaults

---
 xml/vk.xml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xml/vk.xml b/xml/vk.xml
index 1ff0de4c9..bfddbfa1f 100755
--- a/xml/vk.xml
+++ b/xml/vk.xml
@@ -2449,8 +2449,8 @@ typedef void* MTLSharedEvent_id;
             VkSharingMode                    imageSharingModeSharing mode used for the presentation images
             uint32_t         queueFamilyIndexCountNumber of queue families having access to the images in case of concurrent sharing mode
             const uint32_t*                  pQueueFamilyIndicesArray of queue family indices having access to the images in case of concurrent sharing mode
-            VkSurfaceTransformFlagBitsKHR    preTransformThe transform, relative to the device's natural orientation, applied to the image content prior to presentation
-            VkCompositeAlphaFlagBitsKHR      compositeAlphaThe alpha blending mode used when compositing this surface with other surfaces in the window system
+            VkSurfaceTransformFlagBitsKHR    preTransformThe transform, relative to the device's natural orientation, applied to the image content prior to presentation
+            VkCompositeAlphaFlagBitsKHR      compositeAlphaThe alpha blending mode used when compositing this surface with other surfaces in the window system
             VkPresentModeKHR                 presentModeWhich presentation mode to use for presents on this swap chain
             VkBool32                         clippedSpecifies whether presentable images may be affected by window clip regions
             VkSwapchainKHR       oldSwapchainExisting swap chain to replace, if any