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