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/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;
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..697cfb6ab 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..bfddbfa1f 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
@@ -2440,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
@@ -18499,6 +18508,7 @@ endif::VK_KHR_internally_synchronized_queues[]
             
             
             
+