2016-07-11 01:13:41 +00:00
|
|
|
#!/usr/bin/python3 -i
|
|
|
|
#
|
|
|
|
# Copyright (c) 2013-2016 The Khronos Group Inc.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
|
|
|
import os,re,sys
|
|
|
|
from generator import *
|
|
|
|
|
|
|
|
# HostSynchronizationOutputGenerator - subclass of OutputGenerator.
|
|
|
|
# Generates AsciiDoc includes of the externsync parameter table for the
|
|
|
|
# fundamentals chapter of the Vulkan specification. Similar to
|
|
|
|
# DocOutputGenerator.
|
|
|
|
#
|
|
|
|
# ---- methods ----
|
|
|
|
# HostSynchronizationOutputGenerator(errFile, warnFile, diagFile) - args as for
|
|
|
|
# OutputGenerator. Defines additional internal state.
|
|
|
|
# ---- methods overriding base class ----
|
|
|
|
# genCmd(cmdinfo)
|
|
|
|
class HostSynchronizationOutputGenerator(OutputGenerator):
|
|
|
|
# Generate Host Synchronized Parameters in a table at the top of the spec
|
|
|
|
def __init__(self,
|
|
|
|
errFile = sys.stderr,
|
|
|
|
warnFile = sys.stderr,
|
|
|
|
diagFile = sys.stdout):
|
|
|
|
OutputGenerator.__init__(self, errFile, warnFile, diagFile)
|
|
|
|
|
|
|
|
threadsafety = {'parameters': '', 'parameterlists': '', 'implicit': ''}
|
|
|
|
|
|
|
|
def makeParameterName(self, name):
|
|
|
|
return 'pname:' + name
|
|
|
|
|
|
|
|
def makeFLink(self, name):
|
|
|
|
return 'flink:' + name
|
|
|
|
|
|
|
|
#
|
|
|
|
# Generate an include file
|
|
|
|
#
|
|
|
|
# directory - subdirectory to put file in
|
|
|
|
# basename - base name of the file
|
|
|
|
# contents - contents of the file (Asciidoc boilerplate aside)
|
|
|
|
def writeInclude(self):
|
|
|
|
|
|
|
|
if self.threadsafety['parameters'] is not None:
|
|
|
|
# Create file
|
Change log for July 22, 2016 Vulkan 1.0.22 spec update:
* Bump API patch number and header version number to 22 for this update.
Github Issues:
* Translate the subpass self-dependency language into concrete
validity statements, and added a validity statement about the
restrictions on layout parameters (public issue 267).
* Add validity requirement that
slink:VkAttachmentDescription::pname:finalLayout and
slink:VkAttachmentReference::pname:layout must not be
ename:VK_IMAGE_LAYOUT_UNDEFINED or
ename:VK_IMAGE_LAYOUT_PREINITIALIZED (public issue 268).
* Clarify that slink:VkSubpassDescription::pname:pResolveAttachments
layouts are used. Make language consistent with other attachment
arrays (public issue 270).
* Changed 64-bit definition for
dname:VK_DEFINE_NON_DISPATCHABLE_HANDLE to work for x32 platform in
+vk.xml+ and the resulting +vulkan.h+ (public issue 282).
* Add missing error return code for
flink:vkEnumerateInstanceExtensionProperties and
flink:vkEnumerateDeviceExtensionProperties (public issue 285)
* Fix several cases of stext::VkStructName.memberName markup to
stext::VkStructName::pname:memberName, to match other usage in the
spec, and describe this markup in the style guide (public issue
286).
* Modified validity language generation script to avoid redundant
common ancestor language if covered by generic parent language, and
used `Both' instead of `Each' when appropriate (public issue 288).
Internal Issues:
* Add language about behavior of flink:vkAllocateDescriptorSets when
allocation fails due to fragmentation, a new error
ename:VK_ERROR_FRAGMENTED_POOL, and a Note explaining the situation
(internal issue 309).
* For the features of code:PointSize, code:ClipDistance, and
code:CullDistance, the SPIR-V capability is required to be declared
on use (read or write) rather than on decoration (internal issue
359).
* Have desktop versions of GLSL respect precision qualification
(code:mediump and code:lowp) when compiling for Vulkan. These will
get translated to SPIR-V's code:RelaxedPrecision decoration as they
do with OpenGL ES versions of GLSL (ESSL). The default precision of
all types is code:highp when using a desktop version (internal issue
360).
* Add validity statement for slink:VkImageCreateInfo specifying that
multisampled images must be two-dimensional, optimally tiled, and
with a single mipmap level (internal issue 369).
* Add validity statements to slink:VkImageViewCreateInfo disallowing
creation of images or image views with no supported features. Made
some slink:VkImageViewCreateInfo validity statements more precise
and consistent. Added a Note to the <<features,features>> chapter
about formats with no features (internal issue 371).
* Remove +manpages+ from default build targets. Nroff outputs
containing imbedded latexmath will not render properly. Fixing this
is a lot of work for limited use cases (internal issue 401).
Other Commits:
* Fix flink:vkRenderPassBeginInfo::pname:clearValueCount validity
statement to be based on attachment indices rather than the number
of cleared attachments
(Vulkan-LoaderAndValidationLayers/issues/601).
* Convert registry documentation from LaTeX to asciidoc source and
rename from +src/spec/readme.tex+ to +src/spec/registry.txt+.
* Fix lack of Oxford commas in validity language.
* Lots of cleanup of generator scripts and Makefiles to move extension
list for generator into the script arguments instead of the body of
genvk.py, and express better dependencies between XML, scripts, and
generated files.
2016-07-23 10:15:48 +00:00
|
|
|
filename = self.genOpts.directory + '/' + 'parameters.txt'
|
2016-07-11 01:13:41 +00:00
|
|
|
self.logMsg('diag', '# Generating include file:', filename)
|
|
|
|
fp = open(filename, 'w')
|
|
|
|
|
|
|
|
# Host Synchronization
|
|
|
|
write('// WARNING: DO NOT MODIFY! This file is automatically generated from the vk.xml registry', file=fp)
|
|
|
|
write('.Externally Synchronized Parameters', file=fp)
|
|
|
|
write('*' * 80, file=fp)
|
|
|
|
write(self.threadsafety['parameters'], file=fp, end='')
|
|
|
|
write('*' * 80, file=fp)
|
|
|
|
write('', file=fp)
|
|
|
|
|
|
|
|
if self.threadsafety['parameterlists'] is not None:
|
|
|
|
# Create file
|
Change log for July 22, 2016 Vulkan 1.0.22 spec update:
* Bump API patch number and header version number to 22 for this update.
Github Issues:
* Translate the subpass self-dependency language into concrete
validity statements, and added a validity statement about the
restrictions on layout parameters (public issue 267).
* Add validity requirement that
slink:VkAttachmentDescription::pname:finalLayout and
slink:VkAttachmentReference::pname:layout must not be
ename:VK_IMAGE_LAYOUT_UNDEFINED or
ename:VK_IMAGE_LAYOUT_PREINITIALIZED (public issue 268).
* Clarify that slink:VkSubpassDescription::pname:pResolveAttachments
layouts are used. Make language consistent with other attachment
arrays (public issue 270).
* Changed 64-bit definition for
dname:VK_DEFINE_NON_DISPATCHABLE_HANDLE to work for x32 platform in
+vk.xml+ and the resulting +vulkan.h+ (public issue 282).
* Add missing error return code for
flink:vkEnumerateInstanceExtensionProperties and
flink:vkEnumerateDeviceExtensionProperties (public issue 285)
* Fix several cases of stext::VkStructName.memberName markup to
stext::VkStructName::pname:memberName, to match other usage in the
spec, and describe this markup in the style guide (public issue
286).
* Modified validity language generation script to avoid redundant
common ancestor language if covered by generic parent language, and
used `Both' instead of `Each' when appropriate (public issue 288).
Internal Issues:
* Add language about behavior of flink:vkAllocateDescriptorSets when
allocation fails due to fragmentation, a new error
ename:VK_ERROR_FRAGMENTED_POOL, and a Note explaining the situation
(internal issue 309).
* For the features of code:PointSize, code:ClipDistance, and
code:CullDistance, the SPIR-V capability is required to be declared
on use (read or write) rather than on decoration (internal issue
359).
* Have desktop versions of GLSL respect precision qualification
(code:mediump and code:lowp) when compiling for Vulkan. These will
get translated to SPIR-V's code:RelaxedPrecision decoration as they
do with OpenGL ES versions of GLSL (ESSL). The default precision of
all types is code:highp when using a desktop version (internal issue
360).
* Add validity statement for slink:VkImageCreateInfo specifying that
multisampled images must be two-dimensional, optimally tiled, and
with a single mipmap level (internal issue 369).
* Add validity statements to slink:VkImageViewCreateInfo disallowing
creation of images or image views with no supported features. Made
some slink:VkImageViewCreateInfo validity statements more precise
and consistent. Added a Note to the <<features,features>> chapter
about formats with no features (internal issue 371).
* Remove +manpages+ from default build targets. Nroff outputs
containing imbedded latexmath will not render properly. Fixing this
is a lot of work for limited use cases (internal issue 401).
Other Commits:
* Fix flink:vkRenderPassBeginInfo::pname:clearValueCount validity
statement to be based on attachment indices rather than the number
of cleared attachments
(Vulkan-LoaderAndValidationLayers/issues/601).
* Convert registry documentation from LaTeX to asciidoc source and
rename from +src/spec/readme.tex+ to +src/spec/registry.txt+.
* Fix lack of Oxford commas in validity language.
* Lots of cleanup of generator scripts and Makefiles to move extension
list for generator into the script arguments instead of the body of
genvk.py, and express better dependencies between XML, scripts, and
generated files.
2016-07-23 10:15:48 +00:00
|
|
|
filename = self.genOpts.directory + '/' + '/parameterlists.txt'
|
2016-07-11 01:13:41 +00:00
|
|
|
self.logMsg('diag', '# Generating include file:', filename)
|
|
|
|
fp = open(filename, 'w')
|
|
|
|
|
|
|
|
# Host Synchronization
|
|
|
|
write('// WARNING: DO NOT MODIFY! This file is automatically generated from the vk.xml registry', file=fp)
|
|
|
|
write('.Externally Synchronized Parameter Lists', file=fp)
|
|
|
|
write('*' * 80, file=fp)
|
|
|
|
write(self.threadsafety['parameterlists'], file=fp, end='')
|
|
|
|
write('*' * 80, file=fp)
|
|
|
|
write('', file=fp)
|
|
|
|
|
|
|
|
if self.threadsafety['implicit'] is not None:
|
|
|
|
# Create file
|
Change log for July 22, 2016 Vulkan 1.0.22 spec update:
* Bump API patch number and header version number to 22 for this update.
Github Issues:
* Translate the subpass self-dependency language into concrete
validity statements, and added a validity statement about the
restrictions on layout parameters (public issue 267).
* Add validity requirement that
slink:VkAttachmentDescription::pname:finalLayout and
slink:VkAttachmentReference::pname:layout must not be
ename:VK_IMAGE_LAYOUT_UNDEFINED or
ename:VK_IMAGE_LAYOUT_PREINITIALIZED (public issue 268).
* Clarify that slink:VkSubpassDescription::pname:pResolveAttachments
layouts are used. Make language consistent with other attachment
arrays (public issue 270).
* Changed 64-bit definition for
dname:VK_DEFINE_NON_DISPATCHABLE_HANDLE to work for x32 platform in
+vk.xml+ and the resulting +vulkan.h+ (public issue 282).
* Add missing error return code for
flink:vkEnumerateInstanceExtensionProperties and
flink:vkEnumerateDeviceExtensionProperties (public issue 285)
* Fix several cases of stext::VkStructName.memberName markup to
stext::VkStructName::pname:memberName, to match other usage in the
spec, and describe this markup in the style guide (public issue
286).
* Modified validity language generation script to avoid redundant
common ancestor language if covered by generic parent language, and
used `Both' instead of `Each' when appropriate (public issue 288).
Internal Issues:
* Add language about behavior of flink:vkAllocateDescriptorSets when
allocation fails due to fragmentation, a new error
ename:VK_ERROR_FRAGMENTED_POOL, and a Note explaining the situation
(internal issue 309).
* For the features of code:PointSize, code:ClipDistance, and
code:CullDistance, the SPIR-V capability is required to be declared
on use (read or write) rather than on decoration (internal issue
359).
* Have desktop versions of GLSL respect precision qualification
(code:mediump and code:lowp) when compiling for Vulkan. These will
get translated to SPIR-V's code:RelaxedPrecision decoration as they
do with OpenGL ES versions of GLSL (ESSL). The default precision of
all types is code:highp when using a desktop version (internal issue
360).
* Add validity statement for slink:VkImageCreateInfo specifying that
multisampled images must be two-dimensional, optimally tiled, and
with a single mipmap level (internal issue 369).
* Add validity statements to slink:VkImageViewCreateInfo disallowing
creation of images or image views with no supported features. Made
some slink:VkImageViewCreateInfo validity statements more precise
and consistent. Added a Note to the <<features,features>> chapter
about formats with no features (internal issue 371).
* Remove +manpages+ from default build targets. Nroff outputs
containing imbedded latexmath will not render properly. Fixing this
is a lot of work for limited use cases (internal issue 401).
Other Commits:
* Fix flink:vkRenderPassBeginInfo::pname:clearValueCount validity
statement to be based on attachment indices rather than the number
of cleared attachments
(Vulkan-LoaderAndValidationLayers/issues/601).
* Convert registry documentation from LaTeX to asciidoc source and
rename from +src/spec/readme.tex+ to +src/spec/registry.txt+.
* Fix lack of Oxford commas in validity language.
* Lots of cleanup of generator scripts and Makefiles to move extension
list for generator into the script arguments instead of the body of
genvk.py, and express better dependencies between XML, scripts, and
generated files.
2016-07-23 10:15:48 +00:00
|
|
|
filename = self.genOpts.directory + '/' + '/implicit.txt'
|
2016-07-11 01:13:41 +00:00
|
|
|
self.logMsg('diag', '# Generating include file:', filename)
|
|
|
|
fp = open(filename, 'w')
|
|
|
|
|
|
|
|
# Host Synchronization
|
|
|
|
write('// WARNING: DO NOT MODIFY! This file is automatically generated from the vk.xml registry', file=fp)
|
|
|
|
write('.Implicit Externally Synchronized Parameters', file=fp)
|
|
|
|
write('*' * 80, file=fp)
|
|
|
|
write(self.threadsafety['implicit'], file=fp, end='')
|
|
|
|
write('*' * 80, file=fp)
|
|
|
|
write('', file=fp)
|
|
|
|
|
|
|
|
fp.close()
|
|
|
|
|
|
|
|
#
|
|
|
|
# Check if the parameter passed in is a pointer to an array
|
|
|
|
def paramIsArray(self, param):
|
|
|
|
return param.attrib.get('len') is not None
|
|
|
|
|
|
|
|
# Check if the parameter passed in is a pointer
|
|
|
|
def paramIsPointer(self, param):
|
|
|
|
ispointer = False
|
|
|
|
paramtype = param.find('type')
|
|
|
|
if paramtype.tail is not None and '*' in paramtype.tail:
|
|
|
|
ispointer = True
|
|
|
|
|
|
|
|
return ispointer
|
|
|
|
|
|
|
|
# Turn the "name[].member[]" notation into plain English.
|
|
|
|
def makeThreadDereferenceHumanReadable(self, dereference):
|
|
|
|
matches = re.findall(r"[\w]+[^\w]*",dereference)
|
|
|
|
stringval = ''
|
|
|
|
for match in reversed(matches):
|
|
|
|
if '->' in match or '.' in match:
|
|
|
|
stringval += 'member of '
|
|
|
|
if '[]' in match:
|
|
|
|
stringval += 'each element of '
|
|
|
|
|
|
|
|
stringval += 'the '
|
|
|
|
stringval += self.makeParameterName(re.findall(r"[\w]+",match)[0])
|
|
|
|
stringval += ' '
|
|
|
|
|
|
|
|
stringval += 'parameter'
|
|
|
|
|
|
|
|
return stringval[0].upper() + stringval[1:]
|
|
|
|
|
|
|
|
def makeThreadSafetyBlocks(self, cmd, paramtext):
|
|
|
|
protoname = cmd.find('proto/name').text
|
|
|
|
|
|
|
|
# Find and add any parameters that are thread unsafe
|
|
|
|
explicitexternsyncparams = cmd.findall(paramtext + "[@externsync]")
|
|
|
|
if (explicitexternsyncparams is not None):
|
|
|
|
for param in explicitexternsyncparams:
|
|
|
|
externsyncattribs = param.attrib.get('externsync')
|
|
|
|
paramname = param.find('name')
|
|
|
|
for externsyncattrib in externsyncattribs.split(','):
|
|
|
|
|
|
|
|
tempstring = '* '
|
|
|
|
if externsyncattrib == 'true':
|
|
|
|
if self.paramIsArray(param):
|
|
|
|
tempstring += 'Each element of the '
|
|
|
|
elif self.paramIsPointer(param):
|
|
|
|
tempstring += 'The object referenced by the '
|
|
|
|
else:
|
|
|
|
tempstring += 'The '
|
|
|
|
|
|
|
|
tempstring += self.makeParameterName(paramname.text)
|
|
|
|
tempstring += ' parameter'
|
|
|
|
|
|
|
|
else:
|
|
|
|
tempstring += self.makeThreadDereferenceHumanReadable(externsyncattrib)
|
|
|
|
|
|
|
|
tempstring += ' in '
|
|
|
|
tempstring += self.makeFLink(protoname)
|
|
|
|
tempstring += '\n'
|
|
|
|
|
|
|
|
|
|
|
|
if ' element of ' in tempstring:
|
|
|
|
self.threadsafety['parameterlists'] += tempstring
|
|
|
|
else:
|
|
|
|
self.threadsafety['parameters'] += tempstring
|
|
|
|
|
|
|
|
|
|
|
|
# Find and add any "implicit" parameters that are thread unsafe
|
|
|
|
implicitexternsyncparams = cmd.find('implicitexternsyncparams')
|
|
|
|
if (implicitexternsyncparams is not None):
|
|
|
|
for elem in implicitexternsyncparams:
|
|
|
|
self.threadsafety['implicit'] += '* '
|
|
|
|
self.threadsafety['implicit'] += elem.text[0].upper()
|
|
|
|
self.threadsafety['implicit'] += elem.text[1:]
|
|
|
|
self.threadsafety['implicit'] += ' in '
|
|
|
|
self.threadsafety['implicit'] += self.makeFLink(protoname)
|
|
|
|
self.threadsafety['implicit'] += '\n'
|
|
|
|
|
|
|
|
|
|
|
|
# For any vkCmd* functions, the commandBuffer parameter must be being recorded
|
|
|
|
if protoname is not None and 'vkCmd' in protoname:
|
|
|
|
self.threadsafety['implicit'] += '* '
|
|
|
|
self.threadsafety['implicit'] += 'The sname:VkCommandPool that pname:commandBuffer was allocated from, in '
|
|
|
|
self.threadsafety['implicit'] += self.makeFLink(protoname)
|
|
|
|
|
|
|
|
self.threadsafety['implicit'] += '\n'
|
|
|
|
|
|
|
|
#
|
|
|
|
# Command generation
|
|
|
|
def genCmd(self, cmdinfo, name):
|
|
|
|
OutputGenerator.genCmd(self, cmdinfo, name)
|
|
|
|
#
|
|
|
|
# Get all thh parameters
|
|
|
|
params = cmdinfo.elem.findall('param')
|
|
|
|
usages = cmdinfo.elem.findall('validity/usage')
|
|
|
|
|
|
|
|
self.makeThreadSafetyBlocks(cmdinfo.elem, 'param')
|
|
|
|
|
|
|
|
self.writeInclude()
|