1/** 2 * Copyright 2018 The ANGLE Project Authors. All rights reserved. 3 * Use of this source code is governed by a BSD-style license that can be 4 * found in the LICENSE file. 5 * This script is meant to be executed agaisnt the vulkan spec 31.3.3 tables. 6 * Instructions: Copy all the tables from the HTML source to a plain document 7 * and add a textarea at the bottom with ID='result'. Execute this JS on load 8 * of the document and you should have a JSON string in the textarea with the 9 * mandatory specs included. If the spec changes format / CSS in any way, the 10 * selectors will need to be modified. 11 **/ 12var indexToFeatureMap = []; 13var index = 12; 14 15var outputJson = {}; 16 17// Map all features to indexes of squares. 18$("#features-formats-mandatory-features-subbyte td").each(function() { 19 $this = $(this); 20 $this.find("code").each(function() { 21 if ($(this).text().startsWith("VK_FORMAT_FEATURE")) { 22 indexToFeatureMap[index--] = $(this).text(); 23 } 24 }); 25}); 26 27var allTableIds = 28 ["features-formats-mandatory-features-subbyte", 29 "features-formats-mandatory-features-2byte", 30 "features-formats-mandatory-features-4byte", 31 "features-formats-mandatory-features-10bit", 32 "features-formats-mandatory-features-16bit", 33 "features-formats-mandatory-features-32bit", 34 "features-formats-mandatory-features-64bit", 35 "features-formats-mandatory-features-depth-stencil", 36 "features-formats-mandatory-features-features-bcn", 37 "features-formats-mandatory-features-features-etc", 38 "features-formats-mandatory-features-features-astc"]; 39 40for (var i = 0; i < allTableIds.length; i++) { 41 $("#" + allTableIds[i] + " td").each(function() { 42 $this = $(this); 43 44 $this.find("code").each(function() { 45 if (!$(this).text().startsWith("VK_FORMAT_FEATURE") && 46 $(this).text().startsWith("VK_FORMAT")) { 47 // Found one vkFormat to features line. 48 var vkFormat = $(this).text(); 49 var squareIndex = 0; 50 var features = []; 51 var skipEntry = false; 52 53 $(this).closest("tr").find("td.halign-center").each(function() { 54 // Find all squares with features. 55 if ($(this).text() === "✓") { 56 features.push(indexToFeatureMap[squareIndex]); 57 } 58 if ($(this).text() === "†") { 59 skipEntry = true; 60 return false; // Break; 61 } 62 squareIndex++; 63 }); 64 if (!skipEntry && 65 (features.length > 0)) { 66 Object.defineProperty(outputJson, vkFormat, { 67 value: features, 68 enumerable: true, 69 readable: true, 70 writable: false 71 }); 72 } 73 } 74 }); 75 }); 76} 77$("#result").text(JSON.stringify(outputJson)); 78