Vulkan-Docs/xml/generate-core-block.rb
Jon Leech 26f0bdbf1e Change log for March 5, 2018 Vulkan 1.1.72 spec update:
* Update release number to 72.

Github Issues:

  * Restructure the repository to put the specification `Makefile` and
    associated spec source material at the top level, `vk.xml` and
    associated scripts material in `xml/`, and generated include and source
    files in `include/vulkan/` and `src/ext_loader/`, respectively (public
    issue 436).
  * Add missing bullet point markup to flink:vkCmdCopyImage valid usage
    statement, so it gets a VUID assigned (public issue 627).
  * Fix broken links in a couple of extension appendices (public pull
    request 665).
  * Add the \<platform> tag to the index in section 4.1 of the registry
    schema documentation, and add the protect= attribute of \<extension>
    tags to the comments in `registry.rnc` (public issues 673, 678).
  * Add missing valid usage statements for sparse image interactions to
    flink:VkImageCreateInfo (public pull request 675).
  * Fix improper usage and grammar of "`can: not`" (public pull request
    681).
  * Remove duplicate spec language and NOTE on present layout between the
    flink:vkAcquireNextImageKHR and flink:vkAcquireNextImage2KHR commands
    (public pull request 685).
  * Fix some typos and markup issues (public pull request 689; public issues
    642, 667, 687).
  * Fix typo etext:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_FENCE_FD_BIT ->
    ename:VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT in the
    <<external-semaphore-handle-types-compatibility, External semaphore
    handle types compatibility>> table (public pull request 691).

Internal Issues:

  * Remove the need for the "`noautovalidity`" attribute on extension
    structures in `vk.xml`. It is now implied by the "`structextends`"
    attribute instead (internal issue 942).
  * Replace uses of "`currently bound`" with "`bound`", since "`currently`"
    is redundant and distracting, and add a corresponding rule to the style
    guide (internal issue 993).
  * Fixed subtle issues with the last updates to flink:vkAcquireNextImageKHR
    language that had resulted in ambiguities (internal issue 1178).
  * Make it clear that only one query of a given type is allowed at a time
    by reordering valid usage statements for flink:vkCmdBeginQuery and
    flink:vkCmdEndQuery, and removing redundant ones (internal issue 1213).
  * Swapped OL1 and OL3 in `tessparamUL.svg` to match previous version, and
    fixed where "`(no edge)`" appears (internal issue 1215).

Other Issues:

  * Fixed a minor problem with the valid usage statement extraction script,
    and corresponding markup in the spec source.

New Extensions:

  * `VK_AMD_shader_core_properties`
  * `VK_EXT_descriptor_indexing`
  * `VK_NV_shader_subgroup_partitioned`
2018-04-05 04:24:56 -07:00

122 lines
3.7 KiB
Ruby

require 'nokogiri'
renames = {}
extension_name = ARGV[0]
extension_suffix = /VK_([^_]+)_.+/.match(extension_name)[1]
allowed_dependency_renames = ['']
file = File.open("vk.xml")
Nokogiri::XML(file).xpath('//extension[@name="' + extension_name + '"]').each do | extension |
extension_enum_offset = 1000000000 + ((extension.attribute('number').content.to_i - 1) * 1000)
extension.xpath('require').each do |require|
do_rename = false
if require.attribute('extension')
allowed_dependency_renames.each do |dependency|
if require.attribute('extension').content == dependency
do_rename = true
end
end
else
do_rename = true
end
if do_rename == false
puts "Extension interaction with " + require.attribute('extension').content + " needs addressing!"
else
core_block = "\t"*2 + require.to_s.lines[0].strip + "\n"
alias_block = "\t"*3 + require.to_s.lines[0].strip + "\n"
require.children.each do |element|
if element.node_name != 'text' && element.node_name != 'comment'
# Core Block
if /.+_EXTENSION_NAME/.match(element.attribute('name').content) == nil &&
/.+_SPEC_VERSION/.match(element.attribute('name').content) == nil
case element.node_name
when 'enum'
attributes = element.attributes
if element.attributes['offset']
attributes['value'] = element.attribute('offset').content.to_i + extension_enum_offset
attributes.delete('offset')
end
core_block << "\t"*3 + '<enum'
attributes.each_pair do |key, value|
core_block << ' ' + key + '="' + value.to_s + '"'
end
core_block << '/>' + "\n"
when 'type', 'command'
core_block << "\t"*3 + element.to_s.strip + "\n"
else
core_block << "Warning: Unknown type found!\n" << element.node_name
end
end
# Alias Block + Renames
if /.+_EXTENSION_NAME/.match(element.attribute('name').content) ||
/.+_SPEC_VERSION/.match(element.attribute('name').content)
alias_block << "\t"*4 + element.to_s.strip + "\n"
else
old_name = element.attribute('name').content
new_name = old_name.sub('_' + extension_suffix,'').sub(extension_suffix,'')
alias_block << "\t"*4 + '<alias name="' + old_name + '" value="' + new_name + '"/>' + "\n"
renames[old_name] = new_name
core_block.gsub!(old_name,new_name)
end
end
end
alias_block << "\t"*3 + require.to_s.lines[-1].strip
core_block << "\t"*2 + require.to_s.lines[-1].strip
puts alias_block
puts
puts core_block
puts
renames.each_pair do |old, new|
puts old + ' -> ' + new
end
end
end
end
outdata = File.read('vk.xml')
renames.each_pair do |old, new|
outdata.gsub!(old,new)
end
File.open('vk.xml', 'w') do |out|
out << outdata
end
def rename_text_files(dir, renames, extension_name)
Dir[dir + '/*.txt'].each do |name|
# Skip renaming in the extension appendix, since this should preserve the old names.
if (name != ('../appendices/' + extension_name + '.txt'))
old_file = File.read(name)
new_file = old_file.clone
renames.each_pair do |old, new|
new_file.gsub!(old,new)
end
if (old_file != new_file)
File.write(name, new_file)
end
end
end
Dir[dir + '/*/'].each do |subdir|
rename_text_files(subdir, renames, extension_name)
end
end
rename_text_files('../chapters', renames, extension_name)
rename_text_files('../appendices', renames, extension_name)