Skip to content

Commit

Permalink
Fix some void* (auto)validity
Browse files Browse the repository at this point in the history
- Make implicit validity for optional `void*` mean "nothing" in the
script
- Make `optional` mean non-NULL for `void*` (not implemented)
- Uses of `void*` that point to something should have `noautovalidity`
(adding it)
- Add missing explicit VUs of `void*` parameters
(`vkCmdPushDescriptorSetWithTemplateKHR` and
`vkUpdateDescriptorSetWithTemplateKHR`)
- Also indirectly fixes `vkMapMemory`, `VkAllocationCallbacks`,
`VkDebugReportCallbackCreateInfoEXT`, and Apple and NN surface create
- Remove ugly text hack from script
  • Loading branch information
krOoze committed Oct 12, 2017
1 parent d2d907e commit fc01784
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 14 deletions.
14 changes: 14 additions & 0 deletions doc/specs/vulkan/chapters/descriptorsets.txt
Expand Up @@ -2373,6 +2373,15 @@ include::../api/protos/vkUpdateDescriptorSetWithTemplateKHR.txt[]
of slink:VkDescriptorImageInfo, slink:VkDescriptorBufferInfo, or
slink:VkBufferView used to write the descriptors.

.Valid Usage
****
* pname:pData must: be a pointer to a memory that contains one or more
valid instances of slink:VkDescriptorImageInfo,
slink:VkDescriptorBufferInfo, or slink:VkBufferView in a layout defined
by pname:descriptorUpdateTemplate when it was created with
flink:vkCreateDescriptorUpdateTemplateKHR
****

include::../validity/protos/vkUpdateDescriptorSetWithTemplateKHR.txt[]

.API example
Expand Down Expand Up @@ -2699,6 +2708,11 @@ include::../api/protos/vkCmdPushDescriptorSetWithTemplateKHR.txt[]
The pipelineBindPoint specified during the creation of the descriptor
update template must: be supported by the pname:commandBuffer's parent
sname:VkCommandPool's queue family
* pname:pData must: be a pointer to a memory that contains one or more
valid instances of slink:VkDescriptorImageInfo,
slink:VkDescriptorBufferInfo, or slink:VkBufferView in a layout defined
by pname:descriptorUpdateTemplate when it was created with
flink:vkCreateDescriptorUpdateTemplateKHR
****

include::../validity/protos/vkCmdPushDescriptorSetWithTemplateKHR.txt[]
Expand Down
22 changes: 14 additions & 8 deletions src/spec/validitygenerator.py
Expand Up @@ -406,22 +406,28 @@ def createValidationLineForParameterIntroChunk(self, blockname, param, params, t

elif self.paramIsPointer(param):
# Handle pointers - which are really special case arrays (i.e. they don't have a length)
#TODO should do something here if someone ever uses some intricate comma-separated `optional`
pointercount = paramtype.tail.count('*')

# Treat void* as an int
if paramtype.text == 'void':
pointercount -= 1

# Could be multi-level pointers (e.g. ppData - pointer to a pointer). Handle that.
asciidoc += 'a '
for i in range(0, pointercount):
asciidoc += 'a pointer to '
asciidoc += 'pointer to a '

# Handle void* and pointers to it
if paramtype.text == 'void':
# If there's only one pointer, it's optional, and it doesn't point at anything in particular - we don't need any language.
if pointercount == 1 and param.attrib.get('optional') is not None:
# If there is only void*, it is just optional int - we don't need any language.
if pointercount == 0 and param.attrib.get('optional') is not None:
return '' # early return
else:
# Pointer to nothing in particular - delete the " to " portion
asciidoc = asciidoc[:-4]
else:
# Add an article for English semantic win
asciidoc += 'a '
if param.attrib.get('optional').split(',')[pointercount] is not None:
# The last void* is just optional int (e.g. to be filled by the impl.)
typetext = 'pointer value'


# If a value is "const" that means it won't get modified, so it must be valid going into the function.
if param.text is not None and paramtype.text != 'void':
Expand Down
12 changes: 6 additions & 6 deletions src/spec/vk.xml
Expand Up @@ -1527,7 +1527,7 @@ private version is maintained in the 1.0 branch of the member gitlab server.
<member values="VK_STRUCTURE_TYPE_VI_SURFACE_CREATE_INFO_NN"><type>VkStructureType</type> <name>sType</name></member>
<member>const <type>void</type>* <name>pNext</name></member>
<member optional="true"><type>VkViSurfaceCreateFlagsNN</type> <name>flags</name></member>
<member><type>void</type>* <name>window</name></member>
<member noautovalidity="true"><type>void</type>* <name>window</name></member>
</type>
<type category="struct" name="VkWaylandSurfaceCreateInfoKHR">
<member values="VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR"><type>VkStructureType</type> <name>sType</name></member>
Expand Down Expand Up @@ -2317,13 +2317,13 @@ private version is maintained in the 1.0 branch of the member gitlab server.
<member values="VK_STRUCTURE_TYPE_IOS_SURFACE_CREATE_INFO_MVK"><type>VkStructureType</type> <name>sType</name></member>
<member>const <type>void</type>* <name>pNext</name></member>
<member optional="true"><type>VkIOSSurfaceCreateFlagsMVK</type> <name>flags</name></member>
<member>const <type>void</type>* <name>pView</name></member>
<member noautovalidity="true">const <type>void</type>* <name>pView</name></member>
</type>
<type category="struct" name="VkMacOSSurfaceCreateInfoMVK">
<member values="VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK"><type>VkStructureType</type> <name>sType</name></member>
<member>const <type>void</type>* <name>pNext</name></member>
<member optional="true"><type>VkMacOSSurfaceCreateFlagsMVK</type> <name>flags</name></member>
<member>const <type>void</type>* <name>pView</name></member>
<member noautovalidity="true">const <type>void</type>* <name>pView</name></member>
</type>
<type category="struct" name="VkViewportWScalingNV">
<member><type>float</type> <name>xcoeff</name></member>
Expand Down Expand Up @@ -3796,7 +3796,7 @@ private version is maintained in the 1.0 branch of the member gitlab server.
<param><type>VkDeviceSize</type> <name>offset</name></param>
<param><type>VkDeviceSize</type> <name>size</name></param>
<param optional="true"><type>VkMemoryMapFlags</type> <name>flags</name></param>
<param><type>void</type>** <name>ppData</name></param>
<param optional="false,true"><type>void</type>** <name>ppData</name></param>
</command>
<command>
<proto><type>void</type> <name>vkUnmapMemory</name></proto>
Expand Down Expand Up @@ -5222,15 +5222,15 @@ private version is maintained in the 1.0 branch of the member gitlab server.
<param><type>VkDevice</type> <name>device</name></param>
<param externsync="true"><type>VkDescriptorSet</type> <name>descriptorSet</name></param>
<param><type>VkDescriptorUpdateTemplateKHR</type> <name>descriptorUpdateTemplate</name></param>
<param>const <type>void</type>* <name>pData</name></param>
<param noautovalidity="true">const <type>void</type>* <name>pData</name></param>
</command>
<command queues="graphics,compute" renderpass="both" cmdbufferlevel="primary,secondary">
<proto><type>void</type> <name>vkCmdPushDescriptorSetWithTemplateKHR</name></proto>
<param externsync="true"><type>VkCommandBuffer</type> <name>commandBuffer</name></param>
<param><type>VkDescriptorUpdateTemplateKHR</type> <name>descriptorUpdateTemplate</name></param>
<param><type>VkPipelineLayout</type> <name>layout</name></param>
<param><type>uint32_t</type> <name>set</name></param>
<param>const <type>void</type>* <name>pData</name></param>
<param noautovalidity="true">const <type>void</type>* <name>pData</name></param>
</command>
<command>
<proto><type>void</type> <name>vkSetHdrMetadataEXT</name></proto>
Expand Down

0 comments on commit fc01784

Please sign in to comment.