1 /*
2  * Copyright 2016 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.cts.deviceinfo;
18 
19 import java.util.HashMap;
20 import com.android.compatibility.common.deviceinfo.DeviceInfo;
21 import com.android.compatibility.common.util.DeviceInfoStore;
22 
23 import org.json.JSONArray;
24 import org.json.JSONException;
25 import org.json.JSONObject;
26 
27 /**
28  * Vulkan info collector.
29  *
30  * This collector gathers a VkJSONInstance representing the Vulkan capabilities of the Android
31  * device, and translates it into a DeviceInfoStore. The goal is to be as faithful to the original
32  * VkJSON as possible, so that the DeviceInfo can later be turned back into VkJSON without loss,
33  * while still allow complex queries against the DeviceInfo database.
34  *
35  * We inherit some design decisions from VkJSON, and there are a few places were translation isn't
36  * perfect:
37  *
38  * - Most JSON implementations handle JSON Numbers as doubles (64-bit floating point), which can't
39  *   faithfully transfer 64-bit integers. So Vulkan uint64_t and VkDeviceSize values are encoded as
40  *   Strings containing the hexadecimal representation of the value (with "0x" prefix).
41  *
42  * - Vulkan enum values are represented as Numbers. This is most convenient for processing, though
43  *   isn't very human-readable. Pretty-printing these as strings is left for other tools.
44  *
45  * - For implementation convenience, VkJSON represents VkBool32 values as JSON Numbers (0/1). This
46  *   collector converts them to JSON Boolean values (false/true).
47  *
48  * - DeviceInfoStore doesn't allow arrays of non-uniform or non-primitive types. VkJSON stores
49  *   format capabilities as an array of formats, where each format is an array containing a number
50  *   (the format enum value) and an object (the format properties). Since DeviceInfoStore doesn't
51  *   allow array-of-array, we instead store formats as an array of uniform structs, So instead of
52  *       [[3, {
53  *           "linearTilingFeatures": 0,
54  *           "optimalTilingFeatures": 5121,
55  *           "bufferFeatures": 0
56  *       }]]
57  *   the format with enum value "3" will be represented as
58  *       {
59  *           "id": 3,
60  *           "linear_tiling_features": 0,
61  *           "optimal_tiling_features": 5121,
62  *           "buffer_features": 0
63  *       }
64  *
65  * - Device layers are deprecated, but instance layers can still add device extensions. VkJSON
66  *   doesn't yet include device extensions provided by layers, though. So VulkanDeviceInfo omits
67  *   device layers altogether. Eventually VkJSON and VulkanDeviceInfo should report device layers
68  *   and their extensions the same way instance layers and their extensions are reported.
69  *
70  * - VkJSON uses the original Vulkan field names, while VulkanDeviceInfo follows the DeviceInfo
71  *   naming convention. So VkJSON fields named like "sparseProperties" will be converted to names
72  *   like "sparse_properties".
73  */
74 public final class VulkanDeviceInfo extends DeviceInfo {
75 
76     private static final String KEY_16BIT_STORAGE_FEATURES = "16bitStorageFeatures";
77     private static final String KEY_ALPHA_TO_ONE = "alphaToOne";
78     private static final String KEY_API_VERSION = "apiVersion";
79     private static final String KEY_BUFFER_FEATURES = "bufferFeatures";
80     private static final String KEY_BUFFER_IMAGE_GRANULARITY = "bufferImageGranularity";
81     private static final String KEY_COMPATIBLE_HANDLE_TYPES = "compatibleHandleTypes";
82     private static final String KEY_DEPTH = "depth";
83     private static final String KEY_DEPTH_BIAS_CLAMP = "depthBiasClamp";
84     private static final String KEY_DEPTH_BOUNDS = "depthBounds";
85     private static final String KEY_DEPTH_CLAMP = "depthClamp";
86     private static final String KEY_DESCRIPTION = "description";
87     private static final String KEY_DEVICE_GROUPS = "deviceGroups";
88     private static final String KEY_DEVICE_ID = "deviceID";
89     private static final String KEY_DEVICE_LUID = "deviceLUID";
90     private static final String KEY_DEVICE_LUID_VALID = "deviceLUIDValid";
91     private static final String KEY_DEVICE_NAME = "deviceName";
92     private static final String KEY_DEVICE_NODE_MASK = "deviceNodeMask";
93     private static final String KEY_DEVICE_TYPE = "deviceType";
94     private static final String KEY_DEVICE_UUID = "deviceUUID";
95     private static final String KEY_DEVICES = "devices";
96     private static final String KEY_DISCRETE_QUEUE_PRIORITIES = "discreteQueuePriorities";
97     private static final String KEY_DRAW_INDIRECT_FIRST_INSTANCE = "drawIndirectFirstInstance";
98     private static final String KEY_DRIVER_VERSION = "driverVersion";
99     private static final String KEY_DRIVER_UUID = "driverUUID";
100     private static final String KEY_DUAL_SRC_BLEND = "dualSrcBlend";
101     private static final String KEY_EXPORT_FROM_IMPORTED_HANDLE_TYPES = "exportFromImportedHandleTypes";
102     private static final String KEY_EXTENSION_NAME = "extensionName";
103     private static final String KEY_EXTENSIONS = "extensions";
104     private static final String KEY_EXTERNAL_FENCE_FEATURES = "externalFenceFeatures";
105     private static final String KEY_EXTERNAL_FENCE_PROPERTIES = "externalFenceProperties";
106     private static final String KEY_EXTERNAL_SEMAPHORE_FEATURES = "externalSemaphoreFeatures";
107     private static final String KEY_EXTERNAL_SEMAPHORE_PROPERTIES = "externalSemaphoreProperties";
108     private static final String KEY_FEATURES = "features";
109     private static final String KEY_FILL_MODE_NON_SOLID = "fillModeNonSolid";
110     private static final String KEY_FLAGS = "flags";
111     private static final String KEY_FORMATS = "formats";
112     private static final String KEY_FRAGMENT_STORES_AND_ATOMICS = "fragmentStoresAndAtomics";
113     private static final String KEY_FRAMEBUFFER_COLOR_SAMPLE_COUNTS = "framebufferColorSampleCounts";
114     private static final String KEY_FRAMEBUFFER_DEPTH_SAMPLE_COUNTS = "framebufferDepthSampleCounts";
115     private static final String KEY_FRAMEBUFFER_NO_ATTACHMENTS_SAMPLE_COUNTS = "framebufferNoAttachmentsSampleCounts";
116     private static final String KEY_FRAMEBUFFER_STENCIL_SAMPLE_COUNTS = "framebufferStencilSampleCounts";
117     private static final String KEY_FULL_DRAW_INDEX_UINT32 = "fullDrawIndexUint32";
118     private static final String KEY_GEOMETRY_SHADER = "geometryShader";
119     private static final String KEY_HEAP_INDEX = "heapIndex";
120     private static final String KEY_HEIGHT = "height";
121     private static final String KEY_ID_PROPERTIES = "idProperties";
122     private static final String KEY_IMAGE_CUBE_ARRAY = "imageCubeArray";
123     private static final String KEY_IMPLEMENTATION_VERSION = "implementationVersion";
124     private static final String KEY_INDEPENDENT_BLEND = "independentBlend";
125     private static final String KEY_INHERITED_QUERIES = "inheritedQueries";
126     private static final String KEY_LARGE_POINTS = "largePoints";
127     private static final String KEY_LAYER_NAME = "layerName";
128     private static final String KEY_LAYERS = "layers";
129     private static final String KEY_LIMITS = "limits";
130     private static final String KEY_LINE_WIDTH_GRANULARITY = "lineWidthGranularity";
131     private static final String KEY_LINE_WIDTH_RANGE = "lineWidthRange";
132     private static final String KEY_LINEAR_TILING_FEATURES = "linearTilingFeatures";
133     private static final String KEY_LOGIC_OP = "logicOp";
134     private static final String KEY_MAINTENANCE_3_PROPERTIES = "maintenance3Properties";
135     private static final String KEY_MAX_BOUND_DESCRIPTOR_SETS = "maxBoundDescriptorSets";
136     private static final String KEY_MAX_CLIP_DISTANCES = "maxClipDistances";
137     private static final String KEY_MAX_COLOR_ATTACHMENTS = "maxColorAttachments";
138     private static final String KEY_MAX_COMBINED_CLIP_AND_CULL_DISTANCES = "maxCombinedClipAndCullDistances";
139     private static final String KEY_MAX_COMPUTE_SHARED_MEMORY_SIZE = "maxComputeSharedMemorySize";
140     private static final String KEY_MAX_COMPUTE_WORK_GROUP_COUNT = "maxComputeWorkGroupCount";
141     private static final String KEY_MAX_COMPUTE_WORK_GROUP_INVOCATIONS = "maxComputeWorkGroupInvocations";
142     private static final String KEY_MAX_COMPUTE_WORK_GROUP_SIZE = "maxComputeWorkGroupSize";
143     private static final String KEY_MAX_CULL_DISTANCES = "maxCullDistances";
144     private static final String KEY_MAX_DESCRIPTOR_SET_INPUT_ATTACHMENTS = "maxDescriptorSetInputAttachments";
145     private static final String KEY_MAX_DESCRIPTOR_SET_SAMPLED_IMAGES = "maxDescriptorSetSampledImages";
146     private static final String KEY_MAX_DESCRIPTOR_SET_SAMPLERS = "maxDescriptorSetSamplers";
147     private static final String KEY_MAX_DESCRIPTOR_SET_STORAGE_BUFFERS = "maxDescriptorSetStorageBuffers";
148     private static final String KEY_MAX_DESCRIPTOR_SET_STORAGE_BUFFERS_DYNAMIC = "maxDescriptorSetStorageBuffersDynamic";
149     private static final String KEY_MAX_DESCRIPTOR_SET_STORAGE_IMAGES = "maxDescriptorSetStorageImages";
150     private static final String KEY_MAX_DESCRIPTOR_SET_UNIFORM_BUFFERS = "maxDescriptorSetUniformBuffers";
151     private static final String KEY_MAX_DESCRIPTOR_SET_UNIFORM_BUFFERS_DYNAMIC = "maxDescriptorSetUniformBuffersDynamic";
152     private static final String KEY_MAX_DRAW_INDEXED_INDEX_VALUE = "maxDrawIndexedIndexValue";
153     private static final String KEY_MAX_DRAW_INDIRECT_COUNT = "maxDrawIndirectCount";
154     private static final String KEY_MAX_FRAGMENT_COMBINED_OUTPUT_RESOURCES = "maxFragmentCombinedOutputResources";
155     private static final String KEY_MAX_FRAGMENT_DUAL_SRC_ATTACHMENTS = "maxFragmentDualSrcAttachments";
156     private static final String KEY_MAX_FRAGMENT_INPUT_COMPONENTS = "maxFragmentInputComponents";
157     private static final String KEY_MAX_FRAGMENT_OUTPUT_ATTACHMENTS = "maxFragmentOutputAttachments";
158     private static final String KEY_MAX_FRAMEBUFFER_HEIGHT = "maxFramebufferHeight";
159     private static final String KEY_MAX_FRAMEBUFFER_LAYERS = "maxFramebufferLayers";
160     private static final String KEY_MAX_FRAMEBUFFER_WIDTH = "maxFramebufferWidth";
161     private static final String KEY_MAX_GEOMETRY_INPUT_COMPONENTS = "maxGeometryInputComponents";
162     private static final String KEY_MAX_GEOMETRY_OUTPUT_COMPONENTS = "maxGeometryOutputComponents";
163     private static final String KEY_MAX_GEOMETRY_OUTPUT_VERTICES = "maxGeometryOutputVertices";
164     private static final String KEY_MAX_GEOMETRY_SHADER_INVOCATIONS = "maxGeometryShaderInvocations";
165     private static final String KEY_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS = "maxGeometryTotalOutputComponents";
166     private static final String KEY_MAX_IMAGE_ARRAY_LAYERS = "maxImageArrayLayers";
167     private static final String KEY_MAX_IMAGE_DIMENSION_1D = "maxImageDimension1D";
168     private static final String KEY_MAX_IMAGE_DIMENSION_2D = "maxImageDimension2D";
169     private static final String KEY_MAX_IMAGE_DIMENSION_3D = "maxImageDimension3D";
170     private static final String KEY_MAX_IMAGE_DIMENSION_CUBE = "maxImageDimensionCube";
171     private static final String KEY_MAX_INTERPOLATION_OFFSET = "maxInterpolationOffset";
172     private static final String KEY_MAX_MEMORY_ALLOCATION_COUNT = "maxMemoryAllocationCount";
173     private static final String KEY_MAX_MEMORY_ALLOCATION_SIZE = "maxMemoryAllocationSize";
174     private static final String KEY_MAX_MULTIVIEW_INSTANCE_INDEX = "maxMultiviewInstanceIndex";
175     private static final String KEY_MAX_MULTIVIEW_VIEW_COUNT = "maxMultiviewViewCount";
176     private static final String KEY_MAX_PER_SET_DESCRIPTORS = "maxPerSetDescriptors";
177     private static final String KEY_MAX_PER_STAGE_DESCRIPTOR_INPUT_ATTACHMENTS = "maxPerStageDescriptorInputAttachments";
178     private static final String KEY_MAX_PER_STAGE_DESCRIPTOR_SAMPLED_IMAGES = "maxPerStageDescriptorSampledImages";
179     private static final String KEY_MAX_PER_STAGE_DESCRIPTOR_SAMPLERS = "maxPerStageDescriptorSamplers";
180     private static final String KEY_MAX_PER_STAGE_DESCRIPTOR_STORAGE_BUFFERS = "maxPerStageDescriptorStorageBuffers";
181     private static final String KEY_MAX_PER_STAGE_DESCRIPTOR_STORAGE_IMAGES = "maxPerStageDescriptorStorageImages";
182     private static final String KEY_MAX_PER_STAGE_DESCRIPTOR_UNIFORM_BUFFERS = "maxPerStageDescriptorUniformBuffers";
183     private static final String KEY_MAX_PER_STAGE_RESOURCES = "maxPerStageResources";
184     private static final String KEY_MAX_PUSH_CONSTANTS_SIZE = "maxPushConstantsSize";
185     private static final String KEY_MAX_SAMPLE_MASK_WORDS = "maxSampleMaskWords";
186     private static final String KEY_MAX_SAMPLER_ALLOCATION_COUNT = "maxSamplerAllocationCount";
187     private static final String KEY_MAX_SAMPLER_ANISOTROPY = "maxSamplerAnisotropy";
188     private static final String KEY_MAX_SAMPLER_LOD_BIAS = "maxSamplerLodBias";
189     private static final String KEY_MAX_STORAGE_BUFFER_RANGE = "maxStorageBufferRange";
190     private static final String KEY_MAX_TESSELLATION_CONTROL_PER_PATCH_OUTPUT_COMPONENTS = "maxTessellationControlPerPatchOutputComponents";
191     private static final String KEY_MAX_TESSELLATION_CONTROL_PER_VERTEX_INPUT_COMPONENTS = "maxTessellationControlPerVertexInputComponents";
192     private static final String KEY_MAX_TESSELLATION_CONTROL_PER_VERTEX_OUTPUT_COMPONENTS = "maxTessellationControlPerVertexOutputComponents";
193     private static final String KEY_MAX_TESSELLATION_CONTROL_TOTAL_OUTPUT_COMPONENTS = "maxTessellationControlTotalOutputComponents";
194     private static final String KEY_MAX_TESSELLATION_EVALUATION_INPUT_COMPONENTS = "maxTessellationEvaluationInputComponents";
195     private static final String KEY_MAX_TESSELLATION_EVALUATION_OUTPUT_COMPONENTS = "maxTessellationEvaluationOutputComponents";
196     private static final String KEY_MAX_TESSELLATION_GENERATION_LEVEL = "maxTessellationGenerationLevel";
197     private static final String KEY_MAX_TESSELLATION_PATCH_SIZE = "maxTessellationPatchSize";
198     private static final String KEY_MAX_TEXEL_BUFFER_ELEMENTS = "maxTexelBufferElements";
199     private static final String KEY_MAX_TEXEL_GATHER_OFFSET = "maxTexelGatherOffset";
200     private static final String KEY_MAX_TEXEL_OFFSET = "maxTexelOffset";
201     private static final String KEY_MAX_UNIFORM_BUFFER_RANGE = "maxUniformBufferRange";
202     private static final String KEY_MAX_VERTEX_INPUT_ATTRIBUTE_OFFSET = "maxVertexInputAttributeOffset";
203     private static final String KEY_MAX_VERTEX_INPUT_ATTRIBUTES = "maxVertexInputAttributes";
204     private static final String KEY_MAX_VERTEX_INPUT_BINDING_STRIDE = "maxVertexInputBindingStride";
205     private static final String KEY_MAX_VERTEX_INPUT_BINDINGS = "maxVertexInputBindings";
206     private static final String KEY_MAX_VERTEX_OUTPUT_COMPONENTS = "maxVertexOutputComponents";
207     private static final String KEY_MAX_VIEWPORT_DIMENSIONS = "maxViewportDimensions";
208     private static final String KEY_MAX_VIEWPORTS = "maxViewports";
209     private static final String KEY_MEMORY = "memory";
210     private static final String KEY_MEMORY_HEAP_COUNT = "memoryHeapCount";
211     private static final String KEY_MEMORY_HEAPS = "memoryHeaps";
212     private static final String KEY_MEMORY_TYPE_COUNT = "memoryTypeCount";
213     private static final String KEY_MEMORY_TYPES = "memoryTypes";
214     private static final String KEY_MIN_IMAGE_TRANSFER_GRANULARITY = "minImageTransferGranularity";
215     private static final String KEY_MIN_INTERPOLATION_OFFSET = "minInterpolationOffset";
216     private static final String KEY_MIN_MEMORY_MAP_ALIGNMENT = "minMemoryMapAlignment";
217     private static final String KEY_MIN_STORAGE_BUFFER_OFFSET_ALIGNMENT = "minStorageBufferOffsetAlignment";
218     private static final String KEY_MIN_TEXEL_BUFFER_OFFSET_ALIGNMENT = "minTexelBufferOffsetAlignment";
219     private static final String KEY_MIN_TEXEL_GATHER_OFFSET = "minTexelGatherOffset";
220     private static final String KEY_MIN_TEXEL_OFFSET = "minTexelOffset";
221     private static final String KEY_MIN_UNIFORM_BUFFER_OFFSET_ALIGNMENT = "minUniformBufferOffsetAlignment";
222     private static final String KEY_MIPMAP_PRECISION_BITS = "mipmapPrecisionBits";
223     private static final String KEY_MULTI_DRAW_INDIRECT = "multiDrawIndirect";
224     private static final String KEY_MULTI_VIEWPORT = "multiViewport";
225     private static final String KEY_MULTIVIEW = "multiview";
226     private static final String KEY_MULTIVIEW_FEATURES = "multiviewFeatures";
227     private static final String KEY_MULTIVIEW_GEOMETRY_SHADER = "multiviewGeometryShader";
228     private static final String KEY_MULTIVIEW_PROPERTIES = "multiviewProperties";
229     private static final String KEY_MULTIVIEW_TESSELLATION_SHADER = "multiviewTessellationShader";
230     private static final String KEY_NON_COHERENT_ATOM_SIZE = "nonCoherentAtomSize";
231     private static final String KEY_OCCLUSION_QUERY_PRECISE = "occlusionQueryPrecise";
232     private static final String KEY_OPTIMAL_BUFFER_COPY_OFFSET_ALIGNMENT = "optimalBufferCopyOffsetAlignment";
233     private static final String KEY_OPTIMAL_BUFFER_COPY_ROW_PITCH_ALIGNMENT = "optimalBufferCopyRowPitchAlignment";
234     private static final String KEY_OPTIMAL_TILING_FEATURES = "optimalTilingFeatures";
235     private static final String KEY_PIPELINE_CACHE_UUID = "pipelineCacheUUID";
236     private static final String KEY_PIPELINE_STATISTICS_QUERY = "pipelineStatisticsQuery";
237     private static final String KEY_POINT_CLIPPING_BEHAVIOR = "pointClippingBehavior";
238     private static final String KEY_POINT_CLIPPING_PROPERTIES = "pointClippingProperties";
239     private static final String KEY_POINT_SIZE_GRANULARITY = "pointSizeGranularity";
240     private static final String KEY_POINT_SIZE_RANGE = "pointSizeRange";
241     private static final String KEY_PROPERTIES = "properties";
242     private static final String KEY_PROPERTY_FLAGS = "propertyFlags";
243     private static final String KEY_PROTECTED_MEMORY = "protectedMemory";
244     private static final String KEY_PROTECTED_MEMORY_FEATURES = "protectedMemoryFeatures";
245     private static final String KEY_QUAD_OPERATIONS_IN_ALL_STAGES = "quadOperationsInAllStages";
246     private static final String KEY_QUEUE_COUNT = "queueCount";
247     private static final String KEY_QUEUE_FLAGS = "queueFlags";
248     private static final String KEY_QUEUES = "queues";
249     private static final String KEY_RESIDENCY_ALIGNED_MIP_SIZE = "residencyAlignedMipSize";
250     private static final String KEY_RESIDENCY_NON_RESIDENT_STRICT = "residencyNonResidentStrict";
251     private static final String KEY_RESIDENCY_STANDARD_2D_BLOCK_SHAPE = "residencyStandard2DBlockShape";
252     private static final String KEY_RESIDENCY_STANDARD_2D_MULTISAMPLE_BLOCK_SHAPE = "residencyStandard2DMultisampleBlockShape";
253     private static final String KEY_RESIDENCY_STANDARD_3D_BLOCK_SHAPE = "residencyStandard3DBlockShape";
254     private static final String KEY_ROBUST_BUFFER_ACCESS = "robustBufferAccess";
255     private static final String KEY_SAMPLE_RATE_SHADING = "sampleRateShading";
256     private static final String KEY_SAMPLED_IMAGE_COLOR_SAMPLE_COUNTS = "sampledImageColorSampleCounts";
257     private static final String KEY_SAMPLED_IMAGE_DEPTH_SAMPLE_COUNTS = "sampledImageDepthSampleCounts";
258     private static final String KEY_SAMPLED_IMAGE_INTEGER_SAMPLE_COUNTS = "sampledImageIntegerSampleCounts";
259     private static final String KEY_SAMPLED_IMAGE_STENCIL_SAMPLE_COUNTS = "sampledImageStencilSampleCounts";
260     private static final String KEY_SAMPLER_ANISOTROPY = "samplerAnisotropy";
261     private static final String KEY_SAMPLER_YCBCR_CONVERSION = "samplerYcbcrConversion";
262     private static final String KEY_SAMPLER_YCBCR_CONVERSION_FEATURES = "samplerYcbcrConversionFeatures";
263     private static final String KEY_SHADER_CLIP_DISTANCE = "shaderClipDistance";
264     private static final String KEY_SHADER_CULL_DISTANCE = "shaderCullDistance";
265     private static final String KEY_SHADER_DRAW_PARAMETER_FEATURES = "shaderDrawParameterFeatures";
266     private static final String KEY_SHADER_DRAW_PARAMETERS = "shaderDrawParameters";
267     private static final String KEY_SHADER_FLOAT64 = "shaderFloat64";
268     private static final String KEY_SHADER_IMAGE_GATHER_EXTENDED = "shaderImageGatherExtended";
269     private static final String KEY_SHADER_INT16 = "shaderInt16";
270     private static final String KEY_SHADER_INT64 = "shaderInt64";
271     private static final String KEY_SHADER_RESOURCE_MIN_LOD = "shaderResourceMinLod";
272     private static final String KEY_SHADER_RESOURCE_RESIDENCY = "shaderResourceResidency";
273     private static final String KEY_SHADER_SAMPLED_IMAGE_ARRAY_DYNAMIC_INDEXING = "shaderSampledImageArrayDynamicIndexing";
274     private static final String KEY_SHADER_STORAGE_BUFFER_ARRAY_DYNAMIC_INDEXING = "shaderStorageBufferArrayDynamicIndexing";
275     private static final String KEY_SHADER_STORAGE_IMAGE_ARRAY_DYNAMIC_INDEXING = "shaderStorageImageArrayDynamicIndexing";
276     private static final String KEY_SHADER_STORAGE_IMAGE_EXTENDED_FORMATS = "shaderStorageImageExtendedFormats";
277     private static final String KEY_SHADER_STORAGE_IMAGE_MULTISAMPLE = "shaderStorageImageMultisample";
278     private static final String KEY_SHADER_STORAGE_IMAGE_READ_WITHOUT_FORMAT = "shaderStorageImageReadWithoutFormat";
279     private static final String KEY_SHADER_STORAGE_IMAGE_WRITE_WITHOUT_FORMAT = "shaderStorageImageWriteWithoutFormat";
280     private static final String KEY_SHADER_TESSELLATION_AND_GEOMETRY_POINT_SIZE = "shaderTessellationAndGeometryPointSize";
281     private static final String KEY_SHADER_UNIFORM_BUFFER_ARRAY_DYNAMIC_INDEXING = "shaderUniformBufferArrayDynamicIndexing";
282     private static final String KEY_SIZE = "size";
283     private static final String KEY_SPARSE_ADDRESS_SPACE_SIZE = "sparseAddressSpaceSize";
284     private static final String KEY_SPARSE_BINDING = "sparseBinding";
285     private static final String KEY_SPARSE_PROPERTIES = "sparseProperties";
286     private static final String KEY_SPARSE_RESIDENCY_16_SAMPLES = "sparseResidency16Samples";
287     private static final String KEY_SPARSE_RESIDENCY_2_SAMPLES = "sparseResidency2Samples";
288     private static final String KEY_SPARSE_RESIDENCY_4_SAMPLES = "sparseResidency4Samples";
289     private static final String KEY_SPARSE_RESIDENCY_8_SAMPLES = "sparseResidency8Samples";
290     private static final String KEY_SPARSE_RESIDENCY_ALIASED = "sparseResidencyAliased";
291     private static final String KEY_SPARSE_RESIDENCY_BUFFER = "sparseResidencyBuffer";
292     private static final String KEY_SPARSE_RESIDENCY_IMAGE_2D = "sparseResidencyImage2D";
293     private static final String KEY_SPARSE_RESIDENCY_IMAGE_3D = "sparseResidencyImage3D";
294     private static final String KEY_SPEC_VERSION = "specVersion";
295     private static final String KEY_STANDARD_SAMPLE_LOCATIONS = "standardSampleLocations";
296     private static final String KEY_STORAGE_BUFFER_16BIT_ACCESS = "storageBuffer16BitAccess";
297     private static final String KEY_STORAGE_IMAGE_SAMPLE_COUNTS = "storageImageSampleCounts";
298     private static final String KEY_STORAGE_INPUT_OUTPUT_16 = "storageInputOutput16";
299     private static final String KEY_STORAGE_PUSH_CONSTANT_16 = "storagePushConstant16";
300     private static final String KEY_STRICT_LINES = "strictLines";
301     private static final String KEY_SUB_PIXEL_INTERPOLATION_OFFSET_BITS = "subPixelInterpolationOffsetBits";
302     private static final String KEY_SUB_PIXEL_PRECISION_BITS = "subPixelPrecisionBits";
303     private static final String KEY_SUB_TEXEL_PRECISION_BITS = "subTexelPrecisionBits";
304     private static final String KEY_SUBGROUP_PROPERTIES = "subgroupProperties";
305     private static final String KEY_SUBGROUP_SIZE = "subgroupSize";
306     private static final String KEY_SUBSET_ALLOCATION = "subsetAllocation";
307     private static final String KEY_SUPPORTED_OPERATIONS = "supportedOperations";
308     private static final String KEY_SUPPORTED_STAGES = "supportedStages";
309     private static final String KEY_TESSELLATION_SHADER = "tessellationShader";
310     private static final String KEY_TEXTURE_COMPRESSION_ASTC_LDR = "textureCompressionASTC_LDR";
311     private static final String KEY_TEXTURE_COMPRESSION_BC = "textureCompressionBC";
312     private static final String KEY_TEXTURE_COMPRESSION_ETC2 = "textureCompressionETC2";
313     private static final String KEY_TIMESTAMP_COMPUTE_AND_GRAPHICS = "timestampComputeAndGraphics";
314     private static final String KEY_TIMESTAMP_PERIOD = "timestampPeriod";
315     private static final String KEY_TIMESTAMP_VALID_BITS = "timestampValidBits";
316     private static final String KEY_UNIFORM_AND_STORAGE_BUFFER_16BIT_ACCESS = "uniformAndStorageBuffer16BitAccess";
317     private static final String KEY_VARIABLE_MULTISAMPLE_RATE = "variableMultisampleRate";
318     private static final String KEY_VARIABLE_POINTER_FEATURES = "variablePointerFeatures";
319     private static final String KEY_VARIABLE_POINTER_FEATURES_KHR = "variablePointerFeaturesKHR";
320     private static final String KEY_VARIABLE_POINTERS = "variablePointers";
321     private static final String KEY_VARIABLE_POINTERS_STORAGE_BUFFER = "variablePointersStorageBuffer";
322     private static final String KEY_VENDOR_ID = "vendorID";
323     private static final String KEY_VERTEX_PIPELINE_STORES_AND_ATOMICS = "vertexPipelineStoresAndAtomics";
324     private static final String KEY_VIEWPORT_BOUNDS_RANGE = "viewportBoundsRange";
325     private static final String KEY_VIEWPORT_SUB_PIXEL_BITS = "viewportSubPixelBits";
326     private static final String KEY_VK_KHR_VARIABLE_POINTERS = "VK_KHR_variable_pointers";
327     private static final String KEY_WIDE_LINES = "wideLines";
328     private static final String KEY_WIDTH = "width";
329 
330     private static final int VK_API_VERSION_1_1 = 4198400;
331     private static final int ENUM_VK_KHR_VARIABLE_POINTERS = 0;
332 
333     private static HashMap<String, Integer> extensionNameToEnum;
334 
335     static {
336         System.loadLibrary("ctsdeviceinfo");
337         extensionNameToEnum = new HashMap<>();
extensionNameToEnum.put(KEY_VK_KHR_VARIABLE_POINTERS, ENUM_VK_KHR_VARIABLE_POINTERS)338         extensionNameToEnum.put(KEY_VK_KHR_VARIABLE_POINTERS, ENUM_VK_KHR_VARIABLE_POINTERS);
339     }
340 
341     @Override
collectDeviceInfo(DeviceInfoStore store)342     protected void collectDeviceInfo(DeviceInfoStore store) throws Exception {
343         try {
344             JSONObject instance = new JSONObject(nativeGetVkJSON());
345             emitDeviceGroups(store, instance);
346             emitLayers(store, instance);
347             emitExtensions(store, instance);
348             emitDevices(store, instance);
349         } catch (JSONException e) {
350             e.printStackTrace();
351             throw new RuntimeException(e);
352         }
353     }
354 
emitDeviceGroups(DeviceInfoStore store, JSONObject parent)355     private static void emitDeviceGroups(DeviceInfoStore store, JSONObject parent)
356             throws Exception {
357         JSONArray deviceGroups = parent.getJSONArray(KEY_DEVICE_GROUPS);
358         store.startArray(convertName(KEY_DEVICE_GROUPS));
359         for (int deviceGroupIdx = 0; deviceGroupIdx < deviceGroups.length(); deviceGroupIdx++) {
360             JSONObject deviceGroup = deviceGroups.getJSONObject(deviceGroupIdx);
361             store.startGroup();
362             {
363                 emitLongArray(store, deviceGroup, KEY_DEVICES);
364                 emitBoolean(store, deviceGroup, KEY_SUBSET_ALLOCATION);
365             }
366             store.endGroup();
367         }
368         store.endArray();
369     }
370 
emitDevices(DeviceInfoStore store, JSONObject parent)371     private static void emitDevices(DeviceInfoStore store, JSONObject parent)
372             throws Exception {
373         JSONArray devices = parent.getJSONArray(KEY_DEVICES);
374         store.startArray(convertName(KEY_DEVICES));
375         for (int deviceIdx = 0; deviceIdx < devices.length(); deviceIdx++) {
376             JSONObject device = devices.getJSONObject(deviceIdx);
377             store.startGroup();
378             {
379                 JSONObject properties = device.getJSONObject(KEY_PROPERTIES);
380                 store.startGroup(convertName(KEY_PROPERTIES));
381                 {
382                     emitLong(store, properties, KEY_API_VERSION);
383                     emitLong(store, properties, KEY_DRIVER_VERSION);
384                     emitLong(store, properties, KEY_VENDOR_ID);
385                     emitLong(store, properties, KEY_DEVICE_ID);
386                     emitLong(store, properties, KEY_DEVICE_TYPE);
387                     emitString(store, properties, KEY_DEVICE_NAME);
388                     emitLongArray(store, properties, KEY_PIPELINE_CACHE_UUID);
389 
390                     JSONObject limits = properties.getJSONObject(KEY_LIMITS);
391                     store.startGroup(convertName(KEY_LIMITS));
392                     {
393                         emitLong(store, limits, KEY_MAX_IMAGE_DIMENSION_1D);
394                         emitLong(store, limits, KEY_MAX_IMAGE_DIMENSION_2D);
395                         emitLong(store, limits, KEY_MAX_IMAGE_DIMENSION_3D);
396                         emitLong(store, limits, KEY_MAX_IMAGE_DIMENSION_CUBE);
397                         emitLong(store, limits, KEY_MAX_IMAGE_ARRAY_LAYERS);
398                         emitLong(store, limits, KEY_MAX_TEXEL_BUFFER_ELEMENTS);
399                         emitLong(store, limits, KEY_MAX_UNIFORM_BUFFER_RANGE);
400                         emitLong(store, limits, KEY_MAX_STORAGE_BUFFER_RANGE);
401                         emitLong(store, limits, KEY_MAX_PUSH_CONSTANTS_SIZE);
402                         emitLong(store, limits, KEY_MAX_MEMORY_ALLOCATION_COUNT);
403                         emitLong(store, limits, KEY_MAX_SAMPLER_ALLOCATION_COUNT);
404                         emitString(store, limits, KEY_BUFFER_IMAGE_GRANULARITY);
405                         emitString(store, limits, KEY_SPARSE_ADDRESS_SPACE_SIZE);
406                         emitLong(store, limits, KEY_MAX_BOUND_DESCRIPTOR_SETS);
407                         emitLong(store, limits, KEY_MAX_PER_STAGE_DESCRIPTOR_SAMPLERS);
408                         emitLong(store, limits, KEY_MAX_PER_STAGE_DESCRIPTOR_UNIFORM_BUFFERS);
409                         emitLong(store, limits, KEY_MAX_PER_STAGE_DESCRIPTOR_STORAGE_BUFFERS);
410                         emitLong(store, limits, KEY_MAX_PER_STAGE_DESCRIPTOR_SAMPLED_IMAGES);
411                         emitLong(store, limits, KEY_MAX_PER_STAGE_DESCRIPTOR_STORAGE_IMAGES);
412                         emitLong(store, limits, KEY_MAX_PER_STAGE_DESCRIPTOR_INPUT_ATTACHMENTS);
413                         emitLong(store, limits, KEY_MAX_PER_STAGE_RESOURCES);
414                         emitLong(store, limits, KEY_MAX_DESCRIPTOR_SET_SAMPLERS);
415                         emitLong(store, limits, KEY_MAX_DESCRIPTOR_SET_UNIFORM_BUFFERS);
416                         emitLong(store, limits, KEY_MAX_DESCRIPTOR_SET_UNIFORM_BUFFERS_DYNAMIC);
417                         emitLong(store, limits, KEY_MAX_DESCRIPTOR_SET_STORAGE_BUFFERS);
418                         emitLong(store, limits, KEY_MAX_DESCRIPTOR_SET_STORAGE_BUFFERS_DYNAMIC);
419                         emitLong(store, limits, KEY_MAX_DESCRIPTOR_SET_SAMPLED_IMAGES);
420                         emitLong(store, limits, KEY_MAX_DESCRIPTOR_SET_STORAGE_IMAGES);
421                         emitLong(store, limits, KEY_MAX_DESCRIPTOR_SET_INPUT_ATTACHMENTS);
422                         emitLong(store, limits, KEY_MAX_VERTEX_INPUT_ATTRIBUTES);
423                         emitLong(store, limits, KEY_MAX_VERTEX_INPUT_BINDINGS);
424                         emitLong(store, limits, KEY_MAX_VERTEX_INPUT_ATTRIBUTE_OFFSET);
425                         emitLong(store, limits, KEY_MAX_VERTEX_INPUT_BINDING_STRIDE);
426                         emitLong(store, limits, KEY_MAX_VERTEX_OUTPUT_COMPONENTS);
427                         emitLong(store, limits, KEY_MAX_TESSELLATION_GENERATION_LEVEL);
428                         emitLong(store, limits, KEY_MAX_TESSELLATION_PATCH_SIZE);
429                         emitLong(store, limits, KEY_MAX_TESSELLATION_CONTROL_PER_VERTEX_INPUT_COMPONENTS);
430                         emitLong(store, limits, KEY_MAX_TESSELLATION_CONTROL_PER_VERTEX_OUTPUT_COMPONENTS);
431                         emitLong(store, limits, KEY_MAX_TESSELLATION_CONTROL_PER_PATCH_OUTPUT_COMPONENTS);
432                         emitLong(store, limits, KEY_MAX_TESSELLATION_CONTROL_TOTAL_OUTPUT_COMPONENTS);
433                         emitLong(store, limits, KEY_MAX_TESSELLATION_EVALUATION_INPUT_COMPONENTS);
434                         emitLong(store, limits, KEY_MAX_TESSELLATION_EVALUATION_OUTPUT_COMPONENTS);
435                         emitLong(store, limits, KEY_MAX_GEOMETRY_SHADER_INVOCATIONS);
436                         emitLong(store, limits, KEY_MAX_GEOMETRY_INPUT_COMPONENTS);
437                         emitLong(store, limits, KEY_MAX_GEOMETRY_OUTPUT_COMPONENTS);
438                         emitLong(store, limits, KEY_MAX_GEOMETRY_OUTPUT_VERTICES);
439                         emitLong(store, limits, KEY_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS);
440                         emitLong(store, limits, KEY_MAX_FRAGMENT_INPUT_COMPONENTS);
441                         emitLong(store, limits, KEY_MAX_FRAGMENT_OUTPUT_ATTACHMENTS);
442                         emitLong(store, limits, KEY_MAX_FRAGMENT_DUAL_SRC_ATTACHMENTS);
443                         emitLong(store, limits, KEY_MAX_FRAGMENT_COMBINED_OUTPUT_RESOURCES);
444                         emitLong(store, limits, KEY_MAX_COMPUTE_SHARED_MEMORY_SIZE);
445                         emitLongArray(store, limits, KEY_MAX_COMPUTE_WORK_GROUP_COUNT);
446                         emitLong(store, limits, KEY_MAX_COMPUTE_WORK_GROUP_INVOCATIONS);
447                         emitLongArray(store, limits, KEY_MAX_COMPUTE_WORK_GROUP_SIZE);
448                         emitLong(store, limits, KEY_SUB_PIXEL_PRECISION_BITS);
449                         emitLong(store, limits, KEY_SUB_TEXEL_PRECISION_BITS);
450                         emitLong(store, limits, KEY_MIPMAP_PRECISION_BITS);
451                         emitLong(store, limits, KEY_MAX_DRAW_INDEXED_INDEX_VALUE);
452                         emitLong(store, limits, KEY_MAX_DRAW_INDIRECT_COUNT);
453                         emitDouble(store, limits, KEY_MAX_SAMPLER_LOD_BIAS);
454                         emitDouble(store, limits, KEY_MAX_SAMPLER_ANISOTROPY);
455                         emitLong(store, limits, KEY_MAX_VIEWPORTS);
456                         emitLongArray(store, limits, KEY_MAX_VIEWPORT_DIMENSIONS);
457                         emitDoubleArray(store, limits, KEY_VIEWPORT_BOUNDS_RANGE);
458                         emitLong(store, limits, KEY_VIEWPORT_SUB_PIXEL_BITS);
459                         emitString(store, limits, KEY_MIN_MEMORY_MAP_ALIGNMENT);
460                         emitString(store, limits, KEY_MIN_TEXEL_BUFFER_OFFSET_ALIGNMENT);
461                         emitString(store, limits, KEY_MIN_UNIFORM_BUFFER_OFFSET_ALIGNMENT);
462                         emitString(store, limits, KEY_MIN_STORAGE_BUFFER_OFFSET_ALIGNMENT);
463                         emitLong(store, limits, KEY_MIN_TEXEL_OFFSET);
464                         emitLong(store, limits, KEY_MAX_TEXEL_OFFSET);
465                         emitLong(store, limits, KEY_MIN_TEXEL_GATHER_OFFSET);
466                         emitLong(store, limits, KEY_MAX_TEXEL_GATHER_OFFSET);
467                         emitDouble(store, limits, KEY_MIN_INTERPOLATION_OFFSET);
468                         emitDouble(store, limits, KEY_MAX_INTERPOLATION_OFFSET);
469                         emitLong(store, limits, KEY_SUB_PIXEL_INTERPOLATION_OFFSET_BITS);
470                         emitLong(store, limits, KEY_MAX_FRAMEBUFFER_WIDTH);
471                         emitLong(store, limits, KEY_MAX_FRAMEBUFFER_HEIGHT);
472                         emitLong(store, limits, KEY_MAX_FRAMEBUFFER_LAYERS);
473                         emitLong(store, limits, KEY_FRAMEBUFFER_COLOR_SAMPLE_COUNTS);
474                         emitLong(store, limits, KEY_FRAMEBUFFER_DEPTH_SAMPLE_COUNTS);
475                         emitLong(store, limits, KEY_FRAMEBUFFER_STENCIL_SAMPLE_COUNTS);
476                         emitLong(store, limits, KEY_FRAMEBUFFER_NO_ATTACHMENTS_SAMPLE_COUNTS);
477                         emitLong(store, limits, KEY_MAX_COLOR_ATTACHMENTS);
478                         emitLong(store, limits, KEY_SAMPLED_IMAGE_COLOR_SAMPLE_COUNTS);
479                         emitLong(store, limits, KEY_SAMPLED_IMAGE_INTEGER_SAMPLE_COUNTS);
480                         emitLong(store, limits, KEY_SAMPLED_IMAGE_DEPTH_SAMPLE_COUNTS);
481                         emitLong(store, limits, KEY_SAMPLED_IMAGE_STENCIL_SAMPLE_COUNTS);
482                         emitLong(store, limits, KEY_STORAGE_IMAGE_SAMPLE_COUNTS);
483                         emitLong(store, limits, KEY_MAX_SAMPLE_MASK_WORDS);
484                         emitBoolean(store, limits, KEY_TIMESTAMP_COMPUTE_AND_GRAPHICS);
485                         emitDouble(store, limits, KEY_TIMESTAMP_PERIOD);
486                         emitLong(store, limits, KEY_MAX_CLIP_DISTANCES);
487                         emitLong(store, limits, KEY_MAX_CULL_DISTANCES);
488                         emitLong(store, limits, KEY_MAX_COMBINED_CLIP_AND_CULL_DISTANCES);
489                         emitLong(store, limits, KEY_DISCRETE_QUEUE_PRIORITIES);
490                         emitDoubleArray(store, limits, KEY_POINT_SIZE_RANGE);
491                         emitDoubleArray(store, limits, KEY_LINE_WIDTH_RANGE);
492                         emitDouble(store, limits, KEY_POINT_SIZE_GRANULARITY);
493                         emitDouble(store, limits, KEY_LINE_WIDTH_GRANULARITY);
494                         emitBoolean(store, limits, KEY_STRICT_LINES);
495                         emitBoolean(store, limits, KEY_STANDARD_SAMPLE_LOCATIONS);
496                         emitString(store, limits, KEY_OPTIMAL_BUFFER_COPY_OFFSET_ALIGNMENT);
497                         emitString(store, limits, KEY_OPTIMAL_BUFFER_COPY_ROW_PITCH_ALIGNMENT);
498                         emitString(store, limits, KEY_NON_COHERENT_ATOM_SIZE);
499                     }
500                     store.endGroup();
501 
502                     JSONObject sparse = properties.getJSONObject(KEY_SPARSE_PROPERTIES);
503                     store.startGroup(convertName(KEY_SPARSE_PROPERTIES));
504                     {
505                         emitBoolean(store, sparse, KEY_RESIDENCY_STANDARD_2D_BLOCK_SHAPE);
506                         emitBoolean(store, sparse, KEY_RESIDENCY_STANDARD_2D_MULTISAMPLE_BLOCK_SHAPE);
507                         emitBoolean(store, sparse, KEY_RESIDENCY_STANDARD_3D_BLOCK_SHAPE);
508                         emitBoolean(store, sparse, KEY_RESIDENCY_ALIGNED_MIP_SIZE);
509                         emitBoolean(store, sparse, KEY_RESIDENCY_NON_RESIDENT_STRICT);
510                     }
511                     store.endGroup();
512                 }
513                 store.endGroup();
514 
515                 JSONObject features = device.getJSONObject(KEY_FEATURES);
516                 store.startGroup(convertName(KEY_FEATURES));
517                 {
518                     emitBoolean(store, features, KEY_ROBUST_BUFFER_ACCESS);
519                     emitBoolean(store, features, KEY_FULL_DRAW_INDEX_UINT32);
520                     emitBoolean(store, features, KEY_IMAGE_CUBE_ARRAY);
521                     emitBoolean(store, features, KEY_INDEPENDENT_BLEND);
522                     emitBoolean(store, features, KEY_GEOMETRY_SHADER);
523                     emitBoolean(store, features, KEY_TESSELLATION_SHADER);
524                     emitBoolean(store, features, KEY_SAMPLE_RATE_SHADING);
525                     emitBoolean(store, features, KEY_DUAL_SRC_BLEND);
526                     emitBoolean(store, features, KEY_LOGIC_OP);
527                     emitBoolean(store, features, KEY_MULTI_DRAW_INDIRECT);
528                     emitBoolean(store, features, KEY_DRAW_INDIRECT_FIRST_INSTANCE);
529                     emitBoolean(store, features, KEY_DEPTH_CLAMP);
530                     emitBoolean(store, features, KEY_DEPTH_BIAS_CLAMP);
531                     emitBoolean(store, features, KEY_FILL_MODE_NON_SOLID);
532                     emitBoolean(store, features, KEY_DEPTH_BOUNDS);
533                     emitBoolean(store, features, KEY_WIDE_LINES);
534                     emitBoolean(store, features, KEY_LARGE_POINTS);
535                     emitBoolean(store, features, KEY_ALPHA_TO_ONE);
536                     emitBoolean(store, features, KEY_MULTI_VIEWPORT);
537                     emitBoolean(store, features, KEY_SAMPLER_ANISOTROPY);
538                     emitBoolean(store, features, KEY_TEXTURE_COMPRESSION_ETC2);
539                     emitBoolean(store, features, KEY_TEXTURE_COMPRESSION_ASTC_LDR);
540                     emitBoolean(store, features, KEY_TEXTURE_COMPRESSION_BC);
541                     emitBoolean(store, features, KEY_OCCLUSION_QUERY_PRECISE);
542                     emitBoolean(store, features, KEY_PIPELINE_STATISTICS_QUERY);
543                     emitBoolean(store, features, KEY_VERTEX_PIPELINE_STORES_AND_ATOMICS);
544                     emitBoolean(store, features, KEY_FRAGMENT_STORES_AND_ATOMICS);
545                     emitBoolean(store, features, KEY_SHADER_TESSELLATION_AND_GEOMETRY_POINT_SIZE);
546                     emitBoolean(store, features, KEY_SHADER_IMAGE_GATHER_EXTENDED);
547                     emitBoolean(store, features, KEY_SHADER_STORAGE_IMAGE_EXTENDED_FORMATS);
548                     emitBoolean(store, features, KEY_SHADER_STORAGE_IMAGE_MULTISAMPLE);
549                     emitBoolean(store, features, KEY_SHADER_STORAGE_IMAGE_READ_WITHOUT_FORMAT);
550                     emitBoolean(store, features, KEY_SHADER_STORAGE_IMAGE_WRITE_WITHOUT_FORMAT);
551                     emitBoolean(store, features, KEY_SHADER_UNIFORM_BUFFER_ARRAY_DYNAMIC_INDEXING);
552                     emitBoolean(store, features, KEY_SHADER_SAMPLED_IMAGE_ARRAY_DYNAMIC_INDEXING);
553                     emitBoolean(store, features, KEY_SHADER_STORAGE_BUFFER_ARRAY_DYNAMIC_INDEXING);
554                     emitBoolean(store, features, KEY_SHADER_STORAGE_IMAGE_ARRAY_DYNAMIC_INDEXING);
555                     emitBoolean(store, features, KEY_SHADER_CLIP_DISTANCE);
556                     emitBoolean(store, features, KEY_SHADER_CULL_DISTANCE);
557                     emitBoolean(store, features, KEY_SHADER_FLOAT64);
558                     emitBoolean(store, features, KEY_SHADER_INT64);
559                     emitBoolean(store, features, KEY_SHADER_INT16);
560                     emitBoolean(store, features, KEY_SHADER_RESOURCE_RESIDENCY);
561                     emitBoolean(store, features, KEY_SHADER_RESOURCE_MIN_LOD);
562                     emitBoolean(store, features, KEY_SPARSE_BINDING);
563                     emitBoolean(store, features, KEY_SPARSE_RESIDENCY_BUFFER);
564                     emitBoolean(store, features, KEY_SPARSE_RESIDENCY_IMAGE_2D);
565                     emitBoolean(store, features, KEY_SPARSE_RESIDENCY_IMAGE_3D);
566                     emitBoolean(store, features, KEY_SPARSE_RESIDENCY_2_SAMPLES);
567                     emitBoolean(store, features, KEY_SPARSE_RESIDENCY_4_SAMPLES);
568                     emitBoolean(store, features, KEY_SPARSE_RESIDENCY_8_SAMPLES);
569                     emitBoolean(store, features, KEY_SPARSE_RESIDENCY_16_SAMPLES);
570                     emitBoolean(store, features, KEY_SPARSE_RESIDENCY_ALIASED);
571                     emitBoolean(store, features, KEY_VARIABLE_MULTISAMPLE_RATE);
572                     emitBoolean(store, features, KEY_INHERITED_QUERIES);
573                 }
574                 store.endGroup();
575 
576                 JSONObject memory = device.getJSONObject(KEY_MEMORY);
577                 store.startGroup(convertName(KEY_MEMORY));
578                 {
579                     emitLong(store, memory, KEY_MEMORY_TYPE_COUNT);
580                     JSONArray memoryTypes = memory.getJSONArray(KEY_MEMORY_TYPES);
581                     store.startArray(convertName(KEY_MEMORY_TYPES));
582                     for (int memoryTypeIdx = 0; memoryTypeIdx < memoryTypes.length();
583                             memoryTypeIdx++) {
584                         JSONObject memoryType = memoryTypes.getJSONObject(memoryTypeIdx);
585                         store.startGroup();
586                         {
587                             emitLong(store, memoryType, KEY_PROPERTY_FLAGS);
588                             emitLong(store, memoryType, KEY_HEAP_INDEX);
589                         }
590                         store.endGroup();
591                     }
592                     store.endArray();
593 
594                     emitLong(store, memory, KEY_MEMORY_HEAP_COUNT);
595                     JSONArray memoryHeaps = memory.getJSONArray(KEY_MEMORY_HEAPS);
596                     store.startArray(convertName(KEY_MEMORY_HEAPS));
597                     for (int memoryHeapIdx = 0; memoryHeapIdx < memoryHeaps.length();
598                             memoryHeapIdx++) {
599                         JSONObject memoryHeap = memoryHeaps.getJSONObject(memoryHeapIdx);
600                         store.startGroup();
601                         {
602                             emitString(store, memoryHeap, KEY_SIZE);
603                             emitLong(store, memoryHeap, KEY_FLAGS);
604                         }
605                         store.endGroup();
606                     }
607                     store.endArray();
608                 }
609                 store.endGroup();
610 
611                 JSONArray queues = device.getJSONArray(KEY_QUEUES);
612                 store.startArray(convertName(KEY_QUEUES));
613                 for (int queueIdx = 0; queueIdx < queues.length(); queueIdx++) {
614                     JSONObject queue = queues.getJSONObject(queueIdx);
615                     store.startGroup();
616                     {
617                         emitLong(store, queue, KEY_QUEUE_FLAGS);
618                         emitLong(store, queue, KEY_QUEUE_COUNT);
619                         emitLong(store, queue, KEY_TIMESTAMP_VALID_BITS);
620                         JSONObject extent = queue.getJSONObject(KEY_MIN_IMAGE_TRANSFER_GRANULARITY);
621                         store.startGroup(convertName(KEY_MIN_IMAGE_TRANSFER_GRANULARITY));
622                         {
623                             emitLong(store, extent, KEY_WIDTH);
624                             emitLong(store, extent, KEY_HEIGHT);
625                             emitLong(store, extent, KEY_DEPTH);
626                         }
627                         store.endGroup();
628                     }
629                     store.endGroup();
630                 }
631                 store.endArray();
632 
633                 // Skip layers for now. VkJSON doesn't yet include device layer extensions, so
634                 // this is entirely redundant with the instance extension information.
635                 // emitLayers(store, device);
636                 store.startArray(convertName(KEY_LAYERS));
637                 store.endArray();
638 
639                 emitExtensions(store, device);
640 
641                 JSONArray formats = device.getJSONArray(KEY_FORMATS);
642                 // Note: Earlier code used field named 'formats' with different data structure.
643                 // In order to have the mix of old and new data, we cannot reuse that name.
644                 store.startArray("supported_formats");
645                 for (int formatIdx = 0; formatIdx < formats.length(); formatIdx++) {
646                     JSONArray formatPair = formats.getJSONArray(formatIdx);
647                     JSONObject formatProperties = formatPair.getJSONObject(1);
648                     store.startGroup();
649                     {
650                         store.addResult("format", (long)formatPair.getInt(0));
651                         emitLong(store, formatProperties, KEY_LINEAR_TILING_FEATURES);
652                         emitLong(store, formatProperties, KEY_OPTIMAL_TILING_FEATURES);
653                         emitLong(store, formatProperties, KEY_BUFFER_FEATURES);
654                     }
655                     store.endGroup();
656                 }
657                 store.endArray();
658 
659                 if (properties.getLong(KEY_API_VERSION) >= VK_API_VERSION_1_1) {
660                     JSONObject subgroupProperties = device.getJSONObject(KEY_SUBGROUP_PROPERTIES);
661                     store.startGroup(convertName(KEY_SUBGROUP_PROPERTIES));
662                     {
663                         emitLong(store, subgroupProperties, KEY_SUBGROUP_SIZE);
664                         emitLong(store, subgroupProperties, KEY_SUPPORTED_STAGES);
665                         emitLong(store, subgroupProperties, KEY_SUPPORTED_OPERATIONS);
666                         emitBoolean(store, subgroupProperties, KEY_QUAD_OPERATIONS_IN_ALL_STAGES);
667                     }
668                     store.endGroup();
669 
670                     JSONObject pointClippingProperties = device.getJSONObject(KEY_POINT_CLIPPING_PROPERTIES);
671                     store.startGroup(convertName(KEY_POINT_CLIPPING_PROPERTIES));
672                     {
673                         emitLong(store, pointClippingProperties, KEY_POINT_CLIPPING_BEHAVIOR);
674                     }
675                     store.endGroup();
676 
677                     JSONObject multiviewProperties = device.getJSONObject(KEY_MULTIVIEW_PROPERTIES);
678                     store.startGroup(convertName(KEY_MULTIVIEW_PROPERTIES));
679                     {
680                         emitLong(store, multiviewProperties, KEY_MAX_MULTIVIEW_VIEW_COUNT);
681                         emitLong(store, multiviewProperties, KEY_MAX_MULTIVIEW_INSTANCE_INDEX);
682                     }
683                     store.endGroup();
684 
685                     JSONObject idProperties = device.getJSONObject(KEY_ID_PROPERTIES);
686                     store.startGroup(convertName(KEY_ID_PROPERTIES));
687                     {
688                         emitLongArray(store, idProperties, KEY_DEVICE_UUID);
689                         emitLongArray(store, idProperties, KEY_DRIVER_UUID);
690                         emitLongArray(store, idProperties, KEY_DEVICE_LUID);
691                         emitLong(store, idProperties, KEY_DEVICE_NODE_MASK);
692                         emitBoolean(store, idProperties, KEY_DEVICE_LUID_VALID);
693                     }
694                     store.endGroup();
695 
696                     JSONObject maintenance3Properties = device.getJSONObject(KEY_MAINTENANCE_3_PROPERTIES);
697                     store.startGroup(convertName(KEY_MAINTENANCE_3_PROPERTIES));
698                     {
699                         emitLong(store, maintenance3Properties, KEY_MAX_PER_SET_DESCRIPTORS);
700                         emitString(store, maintenance3Properties, KEY_MAX_MEMORY_ALLOCATION_SIZE);
701                     }
702                     store.endGroup();
703 
704                     JSONObject bit16StorageFeatures = device.getJSONObject(KEY_16BIT_STORAGE_FEATURES);
705                     store.startGroup(convertName(KEY_16BIT_STORAGE_FEATURES));
706                     {
707                         emitBoolean(store, bit16StorageFeatures, KEY_STORAGE_BUFFER_16BIT_ACCESS);
708                         emitBoolean(store, bit16StorageFeatures, KEY_UNIFORM_AND_STORAGE_BUFFER_16BIT_ACCESS);
709                         emitBoolean(store, bit16StorageFeatures, KEY_STORAGE_PUSH_CONSTANT_16);
710                         emitBoolean(store, bit16StorageFeatures, KEY_STORAGE_INPUT_OUTPUT_16);
711                     }
712                     store.endGroup();
713 
714                     JSONObject multiviewFeatures = device.getJSONObject(KEY_MULTIVIEW_FEATURES);
715                     store.startGroup(convertName(KEY_MULTIVIEW_FEATURES));
716                     {
717                         emitBoolean(store, multiviewFeatures, KEY_MULTIVIEW);
718                         emitBoolean(store, multiviewFeatures, KEY_MULTIVIEW_GEOMETRY_SHADER);
719                         emitBoolean(store, multiviewFeatures, KEY_MULTIVIEW_TESSELLATION_SHADER);
720                     }
721                     store.endGroup();
722 
723                     JSONObject variablePointerFeatures = device.getJSONObject(KEY_VARIABLE_POINTER_FEATURES);
724                     store.startGroup(convertName(KEY_VARIABLE_POINTER_FEATURES));
725                     {
726                         emitBoolean(store, variablePointerFeatures, KEY_VARIABLE_POINTERS_STORAGE_BUFFER);
727                         emitBoolean(store, variablePointerFeatures, KEY_VARIABLE_POINTERS);
728                     }
729                     store.endGroup();
730 
731                     JSONObject protectedMemoryFeatures = device.getJSONObject(KEY_PROTECTED_MEMORY_FEATURES);
732                     store.startGroup(convertName(KEY_PROTECTED_MEMORY_FEATURES));
733                     {
734                         emitBoolean(store, protectedMemoryFeatures, KEY_PROTECTED_MEMORY);
735                     }
736                     store.endGroup();
737 
738                     JSONObject samplerYcbcrConversionFeatures = device.getJSONObject(KEY_SAMPLER_YCBCR_CONVERSION_FEATURES);
739                     store.startGroup(convertName(KEY_SAMPLER_YCBCR_CONVERSION_FEATURES));
740                     {
741                         emitBoolean(store, samplerYcbcrConversionFeatures, KEY_SAMPLER_YCBCR_CONVERSION);
742                     }
743                     store.endGroup();
744 
745                     JSONObject shaderDrawParameterFeatures = device.getJSONObject(KEY_SHADER_DRAW_PARAMETER_FEATURES);
746                     store.startGroup(convertName(KEY_SHADER_DRAW_PARAMETER_FEATURES));
747                     {
748                         emitBoolean(store, shaderDrawParameterFeatures, KEY_SHADER_DRAW_PARAMETERS);
749                     }
750                     store.endGroup();
751 
752                     JSONArray externalFences = device.getJSONArray(KEY_EXTERNAL_FENCE_PROPERTIES);
753                     store.startArray(convertName(KEY_EXTERNAL_FENCE_PROPERTIES));
754                     for (int idx = 0; idx < externalFences.length(); ++idx) {
755                         JSONArray externalFencePair = externalFences.getJSONArray(idx);
756                         JSONObject externalFenceProperties = externalFencePair.getJSONObject(1);
757                         store.startGroup();
758                         {
759                             store.addResult("handle_type", externalFencePair.getLong(0));
760                             emitLong(store, externalFenceProperties, KEY_EXPORT_FROM_IMPORTED_HANDLE_TYPES);
761                             emitLong(store, externalFenceProperties, KEY_COMPATIBLE_HANDLE_TYPES);
762                             emitLong(store, externalFenceProperties, KEY_EXTERNAL_FENCE_FEATURES);
763                         }
764                         store.endGroup();
765                     }
766                     store.endArray();
767 
768                     JSONArray externalSemaphores = device.getJSONArray(KEY_EXTERNAL_SEMAPHORE_PROPERTIES);
769                     store.startArray(convertName(KEY_EXTERNAL_SEMAPHORE_PROPERTIES));
770                     for (int idx = 0; idx < externalSemaphores.length(); ++idx) {
771                         JSONArray externalSemaphorePair = externalSemaphores.getJSONArray(idx);
772                         JSONObject externalSemaphoreProperties = externalSemaphorePair.getJSONObject(1);
773                         store.startGroup();
774                         {
775                             store.addResult("handle_type", externalSemaphorePair.getLong(0));
776                             emitLong(store, externalSemaphoreProperties, KEY_EXPORT_FROM_IMPORTED_HANDLE_TYPES);
777                             emitLong(store, externalSemaphoreProperties, KEY_COMPATIBLE_HANDLE_TYPES);
778                             emitLong(store, externalSemaphoreProperties, KEY_EXTERNAL_SEMAPHORE_FEATURES);
779                         }
780                         store.endGroup();
781                     }
782                     store.endArray();
783                 }
784             }
785             store.endGroup();
786         }
787         store.endArray();
788     }
789 
emitLayers(DeviceInfoStore store, JSONObject parent)790     private static void emitLayers(DeviceInfoStore store, JSONObject parent)
791             throws Exception {
792         JSONArray layers = parent.getJSONArray(KEY_LAYERS);
793         store.startArray(convertName(KEY_LAYERS));
794         for (int i = 0; i < layers.length(); i++) {
795             JSONObject layer = layers.getJSONObject(i);
796             store.startGroup();
797             {
798                 JSONObject properties = layer.getJSONObject(KEY_PROPERTIES);
799                 store.startGroup(convertName(KEY_PROPERTIES));
800                 {
801                     emitString(store, properties, KEY_LAYER_NAME);
802                     emitLong(store, properties, KEY_SPEC_VERSION);
803                     emitLong(store, properties, KEY_IMPLEMENTATION_VERSION);
804                     emitString(store, properties, KEY_DESCRIPTION);
805                 }
806                 store.endGroup();
807                 emitExtensions(store, layer);
808             }
809             store.endGroup();
810         }
811         store.endArray();
812     }
813 
emitVariablePointerFeaturesKHR(DeviceInfoStore store, JSONObject parent)814     private static void emitVariablePointerFeaturesKHR(DeviceInfoStore store, JSONObject parent)
815             throws Exception {
816         try {
817             JSONObject extVariablePointerFeatures = parent.getJSONObject(KEY_VK_KHR_VARIABLE_POINTERS);
818             try {
819                 store.startGroup(convertName(KEY_VK_KHR_VARIABLE_POINTERS));
820                 {
821                     JSONObject variablePointerFeaturesKHR = extVariablePointerFeatures.getJSONObject(KEY_VARIABLE_POINTER_FEATURES_KHR);
822                     store.startGroup(convertName(KEY_VARIABLE_POINTER_FEATURES_KHR));
823                     {
824                         emitBoolean(store, variablePointerFeaturesKHR, KEY_VARIABLE_POINTERS_STORAGE_BUFFER);
825                         emitBoolean(store, variablePointerFeaturesKHR, KEY_VARIABLE_POINTERS);
826                     }
827                     store.endGroup();
828                 }
829                 store.endGroup();
830             } catch (JSONException e) {
831                 e.printStackTrace();
832                 throw new RuntimeException(e);
833             }
834         } catch (JSONException ignored) {
835         }
836     }
837 
emitExtension(String key, DeviceInfoStore store, JSONObject parent)838     private static void emitExtension(String key, DeviceInfoStore store, JSONObject parent)
839             throws Exception {
840         if (!extensionNameToEnum.containsKey(key)) return;
841         switch (extensionNameToEnum.get(key)) {
842             case ENUM_VK_KHR_VARIABLE_POINTERS:
843               emitVariablePointerFeaturesKHR(store, parent);
844               break;
845         }
846     }
847 
emitExtensions(DeviceInfoStore store, JSONObject parent)848     private static void emitExtensions(DeviceInfoStore store, JSONObject parent)
849             throws Exception {
850         JSONArray extensions = parent.getJSONArray(KEY_EXTENSIONS);
851         store.startArray(convertName(KEY_EXTENSIONS));
852         for (int i = 0; i < extensions.length(); i++) {
853             JSONObject extension = extensions.getJSONObject(i);
854             store.startGroup();
855             {
856                 emitString(store, extension, KEY_EXTENSION_NAME);
857                 emitLong(store, extension, KEY_SPEC_VERSION);
858             }
859             store.endGroup();
860         }
861         store.endArray();
862 
863         for (int i = 0; i < extensions.length(); i++) {
864             JSONObject extension = extensions.getJSONObject(i);
865             String key = extension.getString(KEY_EXTENSION_NAME);
866             emitExtension(key, store, parent);
867         }
868     }
869 
emitBoolean(DeviceInfoStore store, JSONObject parent, String name)870     private static void emitBoolean(DeviceInfoStore store, JSONObject parent, String name)
871             throws Exception {
872         store.addResult(convertName(name), parent.getInt(name) != 0 ? true : false);
873     }
874 
emitLong(DeviceInfoStore store, JSONObject parent, String name)875     private static void emitLong(DeviceInfoStore store, JSONObject parent, String name)
876             throws Exception {
877         store.addResult(convertName(name), parent.getLong(name));
878     }
879 
emitDouble(DeviceInfoStore store, JSONObject parent, String name)880     private static void emitDouble(DeviceInfoStore store, JSONObject parent, String name)
881             throws Exception {
882         store.addResult(convertName(name), parent.getDouble(name));
883     }
884 
emitString(DeviceInfoStore store, JSONObject parent, String name)885     private static void emitString(DeviceInfoStore store, JSONObject parent, String name)
886             throws Exception {
887         store.addResult(convertName(name), parent.getString(name));
888     }
889 
emitLongArray(DeviceInfoStore store, JSONObject parent, String name)890     private static void emitLongArray(DeviceInfoStore store, JSONObject parent, String name)
891             throws Exception {
892         JSONArray jsonArray = parent.getJSONArray(name);
893         long[] array = new long[jsonArray.length()];
894         for (int i = 0; i < jsonArray.length(); i++) {
895             array[i] = jsonArray.getLong(i);
896         }
897         store.addArrayResult(convertName(name), array);
898     }
899 
emitDoubleArray(DeviceInfoStore store, JSONObject parent, String name)900     private static void emitDoubleArray(DeviceInfoStore store, JSONObject parent, String name)
901             throws Exception {
902         JSONArray jsonArray = parent.getJSONArray(name);
903         double[] array = new double[jsonArray.length()];
904         for (int i = 0; i < jsonArray.length(); i++) {
905             array[i] = jsonArray.getDouble(i);
906         }
907         store.addArrayResult(convertName(name), array);
908     }
909 
convertName(String name)910     private static String convertName(String name) {
911         // This translation could be done algorithmically, but in this case being able to
912         // code-search for both the original and converted names is more important.
913         switch (name) {
914             case KEY_16BIT_STORAGE_FEATURES: return "bit16_storage_features";
915             case KEY_ALPHA_TO_ONE: return "alpha_to_one";
916             case KEY_API_VERSION: return "api_version";
917             case KEY_BUFFER_FEATURES: return "buffer_features";
918             case KEY_BUFFER_IMAGE_GRANULARITY: return "buffer_image_granularity";
919             case KEY_COMPATIBLE_HANDLE_TYPES: return "compatible_handle_types";
920             case KEY_DEPTH: return "depth";
921             case KEY_DEPTH_BIAS_CLAMP: return "depth_bias_clamp";
922             case KEY_DEPTH_BOUNDS: return "depth_bounds";
923             case KEY_DEPTH_CLAMP: return "depth_clamp";
924             case KEY_DESCRIPTION: return "description";
925             case KEY_DEVICE_GROUPS: return "device_groups";
926             case KEY_DEVICE_ID: return "device_id";
927             case KEY_DEVICE_LUID: return "device_luid";
928             case KEY_DEVICE_LUID_VALID: return "device_luid_valid";
929             case KEY_DEVICE_NODE_MASK: return "device_node_mask";
930             case KEY_DEVICE_NAME: return "device_name";
931             case KEY_DEVICE_TYPE: return "device_type";
932             case KEY_DEVICE_UUID: return "device_uuid";
933             case KEY_DEVICES: return "devices";
934             case KEY_DISCRETE_QUEUE_PRIORITIES: return "discrete_queue_priorities";
935             case KEY_DRAW_INDIRECT_FIRST_INSTANCE: return "draw_indirect_first_instance";
936             case KEY_DRIVER_VERSION: return "driver_version";
937             case KEY_DRIVER_UUID: return "driver_uuid";
938             case KEY_DUAL_SRC_BLEND: return "dual_src_blend";
939             case KEY_EXPORT_FROM_IMPORTED_HANDLE_TYPES: return "export_from_imported_handle_types";
940             case KEY_EXTENSION_NAME: return "extension_name";
941             case KEY_EXTENSIONS: return "extensions";
942             case KEY_EXTERNAL_FENCE_FEATURES: return "external_fence_features";
943             case KEY_EXTERNAL_FENCE_PROPERTIES: return "external_fence_properties";
944             case KEY_EXTERNAL_SEMAPHORE_FEATURES: return "external_semaphore_features";
945             case KEY_EXTERNAL_SEMAPHORE_PROPERTIES: return "external_semaphore_properties";
946             case KEY_FEATURES: return "features";
947             case KEY_FILL_MODE_NON_SOLID: return "fill_mode_non_solid";
948             case KEY_FLAGS: return "flags";
949             case KEY_FORMATS: return "formats";
950             case KEY_FRAGMENT_STORES_AND_ATOMICS: return "fragment_stores_and_atomics";
951             case KEY_FRAMEBUFFER_COLOR_SAMPLE_COUNTS: return "framebuffer_color_sample_counts";
952             case KEY_FRAMEBUFFER_DEPTH_SAMPLE_COUNTS: return "framebuffer_depth_sample_counts";
953             case KEY_FRAMEBUFFER_NO_ATTACHMENTS_SAMPLE_COUNTS: return "framebuffer_no_attachments_sample_counts";
954             case KEY_FRAMEBUFFER_STENCIL_SAMPLE_COUNTS: return "framebuffer_stencil_sample_counts";
955             case KEY_FULL_DRAW_INDEX_UINT32: return "full_draw_index_uint32";
956             case KEY_GEOMETRY_SHADER: return "geometry_shader";
957             case KEY_HEAP_INDEX: return "heap_index";
958             case KEY_HEIGHT: return "height";
959             case KEY_ID_PROPERTIES: return "id_properties";
960             case KEY_IMAGE_CUBE_ARRAY: return "image_cube_array";
961             case KEY_IMPLEMENTATION_VERSION: return "implementation_version";
962             case KEY_INDEPENDENT_BLEND: return "independent_blend";
963             case KEY_INHERITED_QUERIES: return "inherited_queries";
964             case KEY_LARGE_POINTS: return "large_points";
965             case KEY_LAYER_NAME: return "layer_name";
966             case KEY_LAYERS: return "layers";
967             case KEY_LIMITS: return "limits";
968             case KEY_LINE_WIDTH_GRANULARITY: return "line_width_granularity";
969             case KEY_LINE_WIDTH_RANGE: return "line_width_range";
970             case KEY_LINEAR_TILING_FEATURES: return "linear_tiling_features";
971             case KEY_LOGIC_OP: return "logic_op";
972             case KEY_MAINTENANCE_3_PROPERTIES: return "maintenance_3_properties";
973             case KEY_MAX_BOUND_DESCRIPTOR_SETS: return "max_bound_descriptor_sets";
974             case KEY_MAX_CLIP_DISTANCES: return "max_clip_distances";
975             case KEY_MAX_COLOR_ATTACHMENTS: return "max_color_attachments";
976             case KEY_MAX_COMBINED_CLIP_AND_CULL_DISTANCES: return "max_combined_clip_and_cull_distances";
977             case KEY_MAX_COMPUTE_SHARED_MEMORY_SIZE: return "max_compute_shared_memory_size";
978             case KEY_MAX_COMPUTE_WORK_GROUP_COUNT: return "max_compute_work_group_count";
979             case KEY_MAX_COMPUTE_WORK_GROUP_INVOCATIONS: return "max_compute_work_group_invocations";
980             case KEY_MAX_COMPUTE_WORK_GROUP_SIZE: return "max_compute_work_group_size";
981             case KEY_MAX_CULL_DISTANCES: return "max_cull_distances";
982             case KEY_MAX_DESCRIPTOR_SET_INPUT_ATTACHMENTS: return "max_descriptor_set_input_attachments";
983             case KEY_MAX_DESCRIPTOR_SET_SAMPLED_IMAGES: return "max_descriptor_set_sampled_images";
984             case KEY_MAX_DESCRIPTOR_SET_SAMPLERS: return "max_descriptor_set_samplers";
985             case KEY_MAX_DESCRIPTOR_SET_STORAGE_BUFFERS: return "max_descriptor_set_storage_buffers";
986             case KEY_MAX_DESCRIPTOR_SET_STORAGE_BUFFERS_DYNAMIC: return "max_descriptor_set_storage_buffers_dynamic";
987             case KEY_MAX_DESCRIPTOR_SET_STORAGE_IMAGES: return "max_descriptor_set_storage_images";
988             case KEY_MAX_DESCRIPTOR_SET_UNIFORM_BUFFERS: return "max_descriptor_set_uniform_buffers";
989             case KEY_MAX_DESCRIPTOR_SET_UNIFORM_BUFFERS_DYNAMIC: return "max_descriptor_set_uniform_buffers_dynamic";
990             case KEY_MAX_DRAW_INDEXED_INDEX_VALUE: return "max_draw_indexed_index_value";
991             case KEY_MAX_DRAW_INDIRECT_COUNT: return "max_draw_indirect_count";
992             case KEY_MAX_FRAGMENT_COMBINED_OUTPUT_RESOURCES: return "max_fragment_combined_output_resources";
993             case KEY_MAX_FRAGMENT_DUAL_SRC_ATTACHMENTS: return "max_fragment_dual_src_attachments";
994             case KEY_MAX_FRAGMENT_INPUT_COMPONENTS: return "max_fragment_input_components";
995             case KEY_MAX_FRAGMENT_OUTPUT_ATTACHMENTS: return "max_fragment_output_attachments";
996             case KEY_MAX_FRAMEBUFFER_HEIGHT: return "max_framebuffer_height";
997             case KEY_MAX_FRAMEBUFFER_LAYERS: return "max_framebuffer_layers";
998             case KEY_MAX_FRAMEBUFFER_WIDTH: return "max_framebuffer_width";
999             case KEY_MAX_GEOMETRY_INPUT_COMPONENTS: return "max_geometry_input_components";
1000             case KEY_MAX_GEOMETRY_OUTPUT_COMPONENTS: return "max_geometry_output_components";
1001             case KEY_MAX_GEOMETRY_OUTPUT_VERTICES: return "max_geometry_output_vertices";
1002             case KEY_MAX_GEOMETRY_SHADER_INVOCATIONS: return "max_geometry_shader_invocations";
1003             case KEY_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS: return "max_geometry_total_output_components";
1004             case KEY_MAX_IMAGE_ARRAY_LAYERS: return "max_image_array_layers";
1005             case KEY_MAX_IMAGE_DIMENSION_1D: return "max_image_dimension_1d";
1006             case KEY_MAX_IMAGE_DIMENSION_2D: return "max_image_dimension_2d";
1007             case KEY_MAX_IMAGE_DIMENSION_3D: return "max_image_dimension_3d";
1008             case KEY_MAX_IMAGE_DIMENSION_CUBE: return "max_image_dimension_cube";
1009             case KEY_MAX_INTERPOLATION_OFFSET: return "max_interpolation_offset";
1010             case KEY_MAX_MEMORY_ALLOCATION_COUNT: return "max_memory_allocation_count";
1011             case KEY_MAX_MEMORY_ALLOCATION_SIZE: return "max_memory_allocation_size";
1012             case KEY_MAX_MULTIVIEW_VIEW_COUNT: return "max_multiview_view_count";
1013             case KEY_MAX_MULTIVIEW_INSTANCE_INDEX: return "max_multiview_instance_index";
1014             case KEY_MAX_PER_SET_DESCRIPTORS: return "max_per_set_descriptors";
1015             case KEY_MAX_PER_STAGE_DESCRIPTOR_INPUT_ATTACHMENTS: return "max_per_stage_descriptor_input_attachments";
1016             case KEY_MAX_PER_STAGE_DESCRIPTOR_SAMPLED_IMAGES: return "max_per_stage_descriptor_sampled_images";
1017             case KEY_MAX_PER_STAGE_DESCRIPTOR_SAMPLERS: return "max_per_stage_descriptor_samplers";
1018             case KEY_MAX_PER_STAGE_DESCRIPTOR_STORAGE_BUFFERS: return "max_per_stage_descriptor_storage_buffers";
1019             case KEY_MAX_PER_STAGE_DESCRIPTOR_STORAGE_IMAGES: return "max_per_stage_descriptor_storage_images";
1020             case KEY_MAX_PER_STAGE_DESCRIPTOR_UNIFORM_BUFFERS: return "max_per_stage_descriptor_uniform_buffers";
1021             case KEY_MAX_PER_STAGE_RESOURCES: return "max_per_stage_resources";
1022             case KEY_MAX_PUSH_CONSTANTS_SIZE: return "max_push_constants_size";
1023             case KEY_MAX_SAMPLE_MASK_WORDS: return "max_sample_mask_words";
1024             case KEY_MAX_SAMPLER_ALLOCATION_COUNT: return "max_sampler_allocation_count";
1025             case KEY_MAX_SAMPLER_ANISOTROPY: return "max_sampler_anisotropy";
1026             case KEY_MAX_SAMPLER_LOD_BIAS: return "max_sampler_lod_bias";
1027             case KEY_MAX_STORAGE_BUFFER_RANGE: return "max_storage_buffer_range";
1028             case KEY_MAX_TESSELLATION_CONTROL_PER_PATCH_OUTPUT_COMPONENTS: return "max_tessellation_control_per_patch_output_components";
1029             case KEY_MAX_TESSELLATION_CONTROL_PER_VERTEX_INPUT_COMPONENTS: return "max_tessellation_control_per_vertex_input_components";
1030             case KEY_MAX_TESSELLATION_CONTROL_PER_VERTEX_OUTPUT_COMPONENTS: return "max_tessellation_control_per_vertex_output_components";
1031             case KEY_MAX_TESSELLATION_CONTROL_TOTAL_OUTPUT_COMPONENTS: return "max_tessellation_control_total_output_components";
1032             case KEY_MAX_TESSELLATION_EVALUATION_INPUT_COMPONENTS: return "max_tessellation_evaluation_input_components";
1033             case KEY_MAX_TESSELLATION_EVALUATION_OUTPUT_COMPONENTS: return "max_tessellation_evaluation_output_components";
1034             case KEY_MAX_TESSELLATION_GENERATION_LEVEL: return "max_tessellation_generation_level";
1035             case KEY_MAX_TESSELLATION_PATCH_SIZE: return "max_tessellation_patch_size";
1036             case KEY_MAX_TEXEL_BUFFER_ELEMENTS: return "max_texel_buffer_elements";
1037             case KEY_MAX_TEXEL_GATHER_OFFSET: return "max_texel_gather_offset";
1038             case KEY_MAX_TEXEL_OFFSET: return "max_texel_offset";
1039             case KEY_MAX_UNIFORM_BUFFER_RANGE: return "max_uniform_buffer_range";
1040             case KEY_MAX_VERTEX_INPUT_ATTRIBUTE_OFFSET: return "max_vertex_input_attribute_offset";
1041             case KEY_MAX_VERTEX_INPUT_ATTRIBUTES: return "max_vertex_input_attributes";
1042             case KEY_MAX_VERTEX_INPUT_BINDING_STRIDE: return "max_vertex_input_binding_stride";
1043             case KEY_MAX_VERTEX_INPUT_BINDINGS: return "max_vertex_input_bindings";
1044             case KEY_MAX_VERTEX_OUTPUT_COMPONENTS: return "max_vertex_output_components";
1045             case KEY_MAX_VIEWPORT_DIMENSIONS: return "max_viewport_dimensions";
1046             case KEY_MAX_VIEWPORTS: return "max_viewports";
1047             case KEY_MEMORY: return "memory";
1048             case KEY_MEMORY_HEAP_COUNT: return "memory_heap_count";
1049             case KEY_MEMORY_HEAPS: return "memory_heaps";
1050             case KEY_MEMORY_TYPE_COUNT: return "memory_type_count";
1051             case KEY_MEMORY_TYPES: return "memory_types";
1052             case KEY_MIN_IMAGE_TRANSFER_GRANULARITY: return "min_image_transfer_granularity";
1053             case KEY_MIN_INTERPOLATION_OFFSET: return "min_interpolation_offset";
1054             case KEY_MIN_MEMORY_MAP_ALIGNMENT: return "min_memory_map_alignment";
1055             case KEY_MIN_STORAGE_BUFFER_OFFSET_ALIGNMENT: return "min_storage_buffer_offset_alignment";
1056             case KEY_MIN_TEXEL_BUFFER_OFFSET_ALIGNMENT: return "min_texel_buffer_offset_alignment";
1057             case KEY_MIN_TEXEL_GATHER_OFFSET: return "min_texel_gather_offset";
1058             case KEY_MIN_TEXEL_OFFSET: return "min_texel_offset";
1059             case KEY_MIN_UNIFORM_BUFFER_OFFSET_ALIGNMENT: return "min_uniform_buffer_offset_alignment";
1060             case KEY_MIPMAP_PRECISION_BITS: return "mipmap_precision_bits";
1061             case KEY_MULTI_DRAW_INDIRECT: return "multi_draw_indirect";
1062             case KEY_MULTI_VIEWPORT: return "multi_viewport";
1063             case KEY_MULTIVIEW: return "multiview";
1064             case KEY_MULTIVIEW_FEATURES: return "multiview_features";
1065             case KEY_MULTIVIEW_GEOMETRY_SHADER: return "multiview_geometry_shader";
1066             case KEY_MULTIVIEW_PROPERTIES: return "multiview_properties";
1067             case KEY_MULTIVIEW_TESSELLATION_SHADER: return "multiview_tessellation_shader";
1068             case KEY_NON_COHERENT_ATOM_SIZE: return "non_coherent_atom_size";
1069             case KEY_OCCLUSION_QUERY_PRECISE: return "occlusion_query_precise";
1070             case KEY_OPTIMAL_BUFFER_COPY_OFFSET_ALIGNMENT: return "optimal_buffer_copy_offset_alignment";
1071             case KEY_OPTIMAL_BUFFER_COPY_ROW_PITCH_ALIGNMENT: return "optimal_buffer_copy_row_pitch_alignment";
1072             case KEY_OPTIMAL_TILING_FEATURES: return "optimal_tiling_features";
1073             case KEY_PIPELINE_CACHE_UUID: return "pipeline_cache_uuid";
1074             case KEY_PIPELINE_STATISTICS_QUERY: return "pipeline_statistics_query";
1075             case KEY_POINT_CLIPPING_BEHAVIOR: return "point_clipping_behavior";
1076             case KEY_POINT_CLIPPING_PROPERTIES: return "point_clipping_properties";
1077             case KEY_POINT_SIZE_GRANULARITY: return "point_size_granularity";
1078             case KEY_POINT_SIZE_RANGE: return "point_size_range";
1079             case KEY_PROPERTIES: return "properties";
1080             case KEY_PROPERTY_FLAGS: return "property_flags";
1081             case KEY_PROTECTED_MEMORY: return "protected_memory";
1082             case KEY_PROTECTED_MEMORY_FEATURES: return "protected_memory_features";
1083             case KEY_QUAD_OPERATIONS_IN_ALL_STAGES: return "quad_operations_in_all_stages";
1084             case KEY_QUEUE_COUNT: return "queue_count";
1085             case KEY_QUEUE_FLAGS: return "queue_flags";
1086             case KEY_QUEUES: return "queues";
1087             case KEY_RESIDENCY_ALIGNED_MIP_SIZE: return "residency_aligned_mip_size";
1088             case KEY_RESIDENCY_NON_RESIDENT_STRICT: return "residency_non_resident_strict";
1089             case KEY_RESIDENCY_STANDARD_2D_BLOCK_SHAPE: return "residency_standard_2d_block_shape";
1090             case KEY_RESIDENCY_STANDARD_2D_MULTISAMPLE_BLOCK_SHAPE: return "residency_standard_2d_multisample_block_shape";
1091             case KEY_RESIDENCY_STANDARD_3D_BLOCK_SHAPE: return "residency_standard_3d_block_shape";
1092             case KEY_ROBUST_BUFFER_ACCESS: return "robust_buffer_access";
1093             case KEY_SAMPLE_RATE_SHADING: return "sample_rate_shading";
1094             case KEY_SAMPLED_IMAGE_COLOR_SAMPLE_COUNTS: return "sampled_image_color_sample_counts";
1095             case KEY_SAMPLED_IMAGE_DEPTH_SAMPLE_COUNTS: return "sampled_image_depth_sample_counts";
1096             case KEY_SAMPLED_IMAGE_INTEGER_SAMPLE_COUNTS: return "sampled_image_integer_sample_counts";
1097             case KEY_SAMPLED_IMAGE_STENCIL_SAMPLE_COUNTS: return "sampled_image_stencil_sample_counts";
1098             case KEY_SAMPLER_ANISOTROPY: return "sampler_anisotropy";
1099             case KEY_SAMPLER_YCBCR_CONVERSION: return "sampler_ycbcr_conversion";
1100             case KEY_SAMPLER_YCBCR_CONVERSION_FEATURES: return "sampler_ycbcr_conversion_features";
1101             case KEY_SHADER_CLIP_DISTANCE: return "shader_clip_distance";
1102             case KEY_SHADER_CULL_DISTANCE: return "shader_cull_distance";
1103             case KEY_SHADER_DRAW_PARAMETER_FEATURES: return "shader_draw_parameter_features";
1104             case KEY_SHADER_DRAW_PARAMETERS: return "shader_draw_parameters";
1105             case KEY_SHADER_FLOAT64: return "shader_float64";
1106             case KEY_SHADER_IMAGE_GATHER_EXTENDED: return "shader_image_gather_extended";
1107             case KEY_SHADER_INT16: return "shader_int16";
1108             case KEY_SHADER_INT64: return "shader_int64";
1109             case KEY_SHADER_RESOURCE_MIN_LOD: return "shader_resource_min_lod";
1110             case KEY_SHADER_RESOURCE_RESIDENCY: return "shader_resource_residency";
1111             case KEY_SHADER_SAMPLED_IMAGE_ARRAY_DYNAMIC_INDEXING: return "shader_sampled_image_array_dynamic_indexing";
1112             case KEY_SHADER_STORAGE_BUFFER_ARRAY_DYNAMIC_INDEXING: return "shader_storage_buffer_array_dynamic_indexing";
1113             case KEY_SHADER_STORAGE_IMAGE_ARRAY_DYNAMIC_INDEXING: return "shader_storage_image_array_dynamic_indexing";
1114             case KEY_SHADER_STORAGE_IMAGE_EXTENDED_FORMATS: return "shader_storage_image_extended_formats";
1115             case KEY_SHADER_STORAGE_IMAGE_MULTISAMPLE: return "shader_storage_image_multisample";
1116             case KEY_SHADER_STORAGE_IMAGE_READ_WITHOUT_FORMAT: return "shader_storage_image_read_without_format";
1117             case KEY_SHADER_STORAGE_IMAGE_WRITE_WITHOUT_FORMAT: return "shader_storage_image_write_without_format";
1118             case KEY_SHADER_TESSELLATION_AND_GEOMETRY_POINT_SIZE: return "shader_tessellation_and_geometry_point_size";
1119             case KEY_SHADER_UNIFORM_BUFFER_ARRAY_DYNAMIC_INDEXING: return "shader_uniform_buffer_array_dynamic_indexing";
1120             case KEY_SIZE: return "size";
1121             case KEY_SPARSE_ADDRESS_SPACE_SIZE: return "sparse_address_space_size";
1122             case KEY_SPARSE_BINDING: return "sparse_binding";
1123             case KEY_SPARSE_PROPERTIES: return "sparse_properties";
1124             case KEY_SPARSE_RESIDENCY_16_SAMPLES: return "sparse_residency_16_samples";
1125             case KEY_SPARSE_RESIDENCY_2_SAMPLES: return "sparse_residency_2_samples";
1126             case KEY_SPARSE_RESIDENCY_4_SAMPLES: return "sparse_residency_4_samples";
1127             case KEY_SPARSE_RESIDENCY_8_SAMPLES: return "sparse_residency_8_samples";
1128             case KEY_SPARSE_RESIDENCY_ALIASED: return "sparse_residency_aliased";
1129             case KEY_SPARSE_RESIDENCY_BUFFER: return "sparse_residency_buffer";
1130             case KEY_SPARSE_RESIDENCY_IMAGE_2D: return "sparse_residency_image_2d";
1131             case KEY_SPARSE_RESIDENCY_IMAGE_3D: return "sparse_residency_image_3d";
1132             case KEY_SPEC_VERSION: return "spec_version";
1133             case KEY_STANDARD_SAMPLE_LOCATIONS: return "standard_sample_locations";
1134             case KEY_STORAGE_BUFFER_16BIT_ACCESS: return "storage_buffer_16bit_access";
1135             case KEY_STORAGE_IMAGE_SAMPLE_COUNTS: return "storage_image_sample_counts";
1136             case KEY_STORAGE_INPUT_OUTPUT_16: return "storage_input_output_16";
1137             case KEY_STORAGE_PUSH_CONSTANT_16: return "storage_push_constant_16";
1138             case KEY_STRICT_LINES: return "strict_lines";
1139             case KEY_SUB_PIXEL_INTERPOLATION_OFFSET_BITS: return "sub_pixel_interpolation_offset_bits";
1140             case KEY_SUB_PIXEL_PRECISION_BITS: return "sub_pixel_precision_bits";
1141             case KEY_SUB_TEXEL_PRECISION_BITS: return "sub_texel_precision_bits";
1142             case KEY_SUBGROUP_PROPERTIES: return "subgroup_properties";
1143             case KEY_SUBGROUP_SIZE: return "subgroup_size";
1144             case KEY_SUBSET_ALLOCATION: return "subset_allocation";
1145             case KEY_SUPPORTED_OPERATIONS: return "supported_operations";
1146             case KEY_SUPPORTED_STAGES: return "supported_stages";
1147             case KEY_TESSELLATION_SHADER: return "tessellation_shader";
1148             case KEY_TEXTURE_COMPRESSION_ASTC_LDR: return "texture_compression_astc_ldr";
1149             case KEY_TEXTURE_COMPRESSION_BC: return "texture_compression_bc";
1150             case KEY_TEXTURE_COMPRESSION_ETC2: return "texture_compression_etc2";
1151             case KEY_TIMESTAMP_COMPUTE_AND_GRAPHICS: return "timestamp_compute_and_graphics";
1152             case KEY_TIMESTAMP_PERIOD: return "timestamp_period";
1153             case KEY_TIMESTAMP_VALID_BITS: return "timestamp_valid_bits";
1154             case KEY_UNIFORM_AND_STORAGE_BUFFER_16BIT_ACCESS: return "uniform_and_storage_buffer_16bit_access";
1155             case KEY_VARIABLE_MULTISAMPLE_RATE: return "variable_multisample_rate";
1156             case KEY_VARIABLE_POINTER_FEATURES: return "variable_pointer_features";
1157             case KEY_VARIABLE_POINTER_FEATURES_KHR: return "variable_pointer_features_khr";
1158             case KEY_VARIABLE_POINTERS: return "variable_pointers";
1159             case KEY_VARIABLE_POINTERS_STORAGE_BUFFER: return "variable_pointers_storage_buffer";
1160             case KEY_VENDOR_ID: return "vendor_id";
1161             case KEY_VERTEX_PIPELINE_STORES_AND_ATOMICS: return "vertex_pipeline_stores_and_atomics";
1162             case KEY_VIEWPORT_BOUNDS_RANGE: return "viewport_bounds_range";
1163             case KEY_VIEWPORT_SUB_PIXEL_BITS: return "viewport_sub_pixel_bits";
1164             case KEY_VK_KHR_VARIABLE_POINTERS: return "vk_khr_variable_pointers";
1165             case KEY_WIDE_LINES: return "wide_lines";
1166             case KEY_WIDTH: return "width";
1167             default: throw new RuntimeException("unknown key name: " + name);
1168         }
1169     }
1170 
nativeGetVkJSON()1171     private static native String nativeGetVkJSON();
1172 
1173 }
1174