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 com.android.compatibility.common.deviceinfo.DeviceInfo; 20 import com.android.compatibility.common.util.DeviceInfoStore; 21 22 import org.json.JSONArray; 23 import org.json.JSONException; 24 import org.json.JSONObject; 25 26 /** 27 * Vulkan info collector. 28 * 29 * This collector gathers a VkJSONInstance representing the Vulkan capabilities of the Android 30 * device, and translates it into a DeviceInfoStore. The goal is to be as faithful to the original 31 * VkJSON as possible, so that the DeviceInfo can later be turned back into VkJSON without loss, 32 * while still allow complex queries against the DeviceInfo database. 33 * 34 * We inherit some design decisions from VkJSON, and there are a few places were translation isn't 35 * perfect: 36 * 37 * - Most JSON implementations handle JSON Numbers as doubles (64-bit floating point), which can't 38 * faithfully transfer 64-bit integers. So Vulkan uint64_t and VkDeviceSize values are encoded as 39 * Strings containing the hexadecimal representation of the value (with "0x" prefix). 40 * 41 * - Vulkan enum values are represented as Numbers. This is most convenient for processing, though 42 * isn't very human-readable. Pretty-printing these as strings is left for other tools. 43 * 44 * - For implementation convenience, VkJSON represents VkBool32 values as JSON Numbers (0/1). This 45 * collector converts them to JSON Boolean values (false/true). 46 * 47 * - DeviceInfoStore doesn't allow arrays of non-uniform or non-primitive types. VkJSON stores 48 * format capabilities as an array of formats, where each format is an array containing a number 49 * (the format enum value) and an object (the format properties). Since DeviceInfoStore doesn't 50 * allow array-of-array, we instead store formats as an object, with format enum values as keys 51 * and the format property objects as values. This is arguably a more natural and useful 52 * representation anyway. So instead of 53 * [[3, { 54 * "linearTilingFeatures": 0, 55 * "optimalTilingFeatures": 5121, 56 * "bufferFeatures": 0 57 * }]] 58 * the format with enum value "3" will be represented as 59 * "format_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_ALPHA_TO_ONE = "alphaToOne"; 77 private static final String KEY_API_VERSION = "apiVersion"; 78 private static final String KEY_BUFFER_FEATURES = "bufferFeatures"; 79 private static final String KEY_BUFFER_IMAGE_GRANULARITY = "bufferImageGranularity"; 80 private static final String KEY_DEPTH = "depth"; 81 private static final String KEY_DEPTH_BIAS_CLAMP = "depthBiasClamp"; 82 private static final String KEY_DEPTH_BOUNDS = "depthBounds"; 83 private static final String KEY_DEPTH_CLAMP = "depthClamp"; 84 private static final String KEY_DESCRIPTION = "description"; 85 private static final String KEY_DEVICE_ID = "deviceID"; 86 private static final String KEY_DEVICE_NAME = "deviceName"; 87 private static final String KEY_DEVICE_TYPE = "deviceType"; 88 private static final String KEY_DEVICES = "devices"; 89 private static final String KEY_DISCRETE_QUEUE_PRIORITIES = "discreteQueuePriorities"; 90 private static final String KEY_DRAW_INDIRECT_FIRST_INSTANCE = "drawIndirectFirstInstance"; 91 private static final String KEY_DRIVER_VERSION = "driverVersion"; 92 private static final String KEY_DUAL_SRC_BLEND = "dualSrcBlend"; 93 private static final String KEY_EXTENSION_NAME = "extensionName"; 94 private static final String KEY_EXTENSIONS = "extensions"; 95 private static final String KEY_FEATURES = "features"; 96 private static final String KEY_FILL_MODE_NON_SOLID = "fillModeNonSolid"; 97 private static final String KEY_FLAGS = "flags"; 98 private static final String KEY_FORMATS = "formats"; 99 private static final String KEY_FRAGMENT_STORES_AND_ATOMICS = "fragmentStoresAndAtomics"; 100 private static final String KEY_FRAMEBUFFER_COLOR_SAMPLE_COUNTS = "framebufferColorSampleCounts"; 101 private static final String KEY_FRAMEBUFFER_DEPTH_SAMPLE_COUNTS = "framebufferDepthSampleCounts"; 102 private static final String KEY_FRAMEBUFFER_NO_ATTACHMENTS_SAMPLE_COUNTS = "framebufferNoAttachmentsSampleCounts"; 103 private static final String KEY_FRAMEBUFFER_STENCIL_SAMPLE_COUNTS = "framebufferStencilSampleCounts"; 104 private static final String KEY_FULL_DRAW_INDEX_UINT32 = "fullDrawIndexUint32"; 105 private static final String KEY_GEOMETRY_SHADER = "geometryShader"; 106 private static final String KEY_HEAP_INDEX = "heapIndex"; 107 private static final String KEY_HEIGHT = "height"; 108 private static final String KEY_IMAGE_CUBE_ARRAY = "imageCubeArray"; 109 private static final String KEY_IMPLEMENTATION_VERSION = "implementationVersion"; 110 private static final String KEY_INDEPENDENT_BLEND = "independentBlend"; 111 private static final String KEY_INHERITED_QUERIES = "inheritedQueries"; 112 private static final String KEY_LARGE_POINTS = "largePoints"; 113 private static final String KEY_LAYER_NAME = "layerName"; 114 private static final String KEY_LAYERS = "layers"; 115 private static final String KEY_LIMITS = "limits"; 116 private static final String KEY_LINE_WIDTH_GRANULARITY = "lineWidthGranularity"; 117 private static final String KEY_LINE_WIDTH_RANGE = "lineWidthRange"; 118 private static final String KEY_LINEAR_TILING_FEATURES = "linearTilingFeatures"; 119 private static final String KEY_LOGIC_OP = "logicOp"; 120 private static final String KEY_MAX_BOUND_DESCRIPTOR_SETS = "maxBoundDescriptorSets"; 121 private static final String KEY_MAX_CLIP_DISTANCES = "maxClipDistances"; 122 private static final String KEY_MAX_COLOR_ATTACHMENTS = "maxColorAttachments"; 123 private static final String KEY_MAX_COMBINED_CLIP_AND_CULL_DISTANCES = "maxCombinedClipAndCullDistances"; 124 private static final String KEY_MAX_COMPUTE_SHARED_MEMORY_SIZE = "maxComputeSharedMemorySize"; 125 private static final String KEY_MAX_COMPUTE_WORK_GROUP_COUNT = "maxComputeWorkGroupCount"; 126 private static final String KEY_MAX_COMPUTE_WORK_GROUP_INVOCATIONS = "maxComputeWorkGroupInvocations"; 127 private static final String KEY_MAX_COMPUTE_WORK_GROUP_SIZE = "maxComputeWorkGroupSize"; 128 private static final String KEY_MAX_CULL_DISTANCES = "maxCullDistances"; 129 private static final String KEY_MAX_DESCRIPTOR_SET_INPUT_ATTACHMENTS = "maxDescriptorSetInputAttachments"; 130 private static final String KEY_MAX_DESCRIPTOR_SET_SAMPLED_IMAGES = "maxDescriptorSetSampledImages"; 131 private static final String KEY_MAX_DESCRIPTOR_SET_SAMPLERS = "maxDescriptorSetSamplers"; 132 private static final String KEY_MAX_DESCRIPTOR_SET_STORAGE_BUFFERS = "maxDescriptorSetStorageBuffers"; 133 private static final String KEY_MAX_DESCRIPTOR_SET_STORAGE_BUFFERS_DYNAMIC = "maxDescriptorSetStorageBuffersDynamic"; 134 private static final String KEY_MAX_DESCRIPTOR_SET_STORAGE_IMAGES = "maxDescriptorSetStorageImages"; 135 private static final String KEY_MAX_DESCRIPTOR_SET_UNIFORM_BUFFERS = "maxDescriptorSetUniformBuffers"; 136 private static final String KEY_MAX_DESCRIPTOR_SET_UNIFORM_BUFFERS_DYNAMIC = "maxDescriptorSetUniformBuffersDynamic"; 137 private static final String KEY_MAX_DRAW_INDEXED_INDEX_VALUE = "maxDrawIndexedIndexValue"; 138 private static final String KEY_MAX_DRAW_INDIRECT_COUNT = "maxDrawIndirectCount"; 139 private static final String KEY_MAX_FRAGMENT_COMBINED_OUTPUT_RESOURCES = "maxFragmentCombinedOutputResources"; 140 private static final String KEY_MAX_FRAGMENT_DUAL_SRC_ATTACHMENTS = "maxFragmentDualSrcAttachments"; 141 private static final String KEY_MAX_FRAGMENT_INPUT_COMPONENTS = "maxFragmentInputComponents"; 142 private static final String KEY_MAX_FRAGMENT_OUTPUT_ATTACHMENTS = "maxFragmentOutputAttachments"; 143 private static final String KEY_MAX_FRAMEBUFFER_HEIGHT = "maxFramebufferHeight"; 144 private static final String KEY_MAX_FRAMEBUFFER_LAYERS = "maxFramebufferLayers"; 145 private static final String KEY_MAX_FRAMEBUFFER_WIDTH = "maxFramebufferWidth"; 146 private static final String KEY_MAX_GEOMETRY_INPUT_COMPONENTS = "maxGeometryInputComponents"; 147 private static final String KEY_MAX_GEOMETRY_OUTPUT_COMPONENTS = "maxGeometryOutputComponents"; 148 private static final String KEY_MAX_GEOMETRY_OUTPUT_VERTICES = "maxGeometryOutputVertices"; 149 private static final String KEY_MAX_GEOMETRY_SHADER_INVOCATIONS = "maxGeometryShaderInvocations"; 150 private static final String KEY_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS = "maxGeometryTotalOutputComponents"; 151 private static final String KEY_MAX_IMAGE_ARRAY_LAYERS = "maxImageArrayLayers"; 152 private static final String KEY_MAX_IMAGE_DIMENSION_1D = "maxImageDimension1D"; 153 private static final String KEY_MAX_IMAGE_DIMENSION_2D = "maxImageDimension2D"; 154 private static final String KEY_MAX_IMAGE_DIMENSION_3D = "maxImageDimension3D"; 155 private static final String KEY_MAX_IMAGE_DIMENSION_CUBE = "maxImageDimensionCube"; 156 private static final String KEY_MAX_INTERPOLATION_OFFSET = "maxInterpolationOffset"; 157 private static final String KEY_MAX_MEMORY_ALLOCATION_COUNT = "maxMemoryAllocationCount"; 158 private static final String KEY_MAX_PER_STAGE_DESCRIPTOR_INPUT_ATTACHMENTS = "maxPerStageDescriptorInputAttachments"; 159 private static final String KEY_MAX_PER_STAGE_DESCRIPTOR_SAMPLED_IMAGES = "maxPerStageDescriptorSampledImages"; 160 private static final String KEY_MAX_PER_STAGE_DESCRIPTOR_SAMPLERS = "maxPerStageDescriptorSamplers"; 161 private static final String KEY_MAX_PER_STAGE_DESCRIPTOR_STORAGE_BUFFERS = "maxPerStageDescriptorStorageBuffers"; 162 private static final String KEY_MAX_PER_STAGE_DESCRIPTOR_STORAGE_IMAGES = "maxPerStageDescriptorStorageImages"; 163 private static final String KEY_MAX_PER_STAGE_DESCRIPTOR_UNIFORM_BUFFERS = "maxPerStageDescriptorUniformBuffers"; 164 private static final String KEY_MAX_PER_STAGE_RESOURCES = "maxPerStageResources"; 165 private static final String KEY_MAX_PUSH_CONSTANTS_SIZE = "maxPushConstantsSize"; 166 private static final String KEY_MAX_SAMPLE_MASK_WORDS = "maxSampleMaskWords"; 167 private static final String KEY_MAX_SAMPLER_ALLOCATION_COUNT = "maxSamplerAllocationCount"; 168 private static final String KEY_MAX_SAMPLER_ANISOTROPY = "maxSamplerAnisotropy"; 169 private static final String KEY_MAX_SAMPLER_LOD_BIAS = "maxSamplerLodBias"; 170 private static final String KEY_MAX_STORAGE_BUFFER_RANGE = "maxStorageBufferRange"; 171 private static final String KEY_MAX_TESSELLATION_CONTROL_PER_PATCH_OUTPUT_COMPONENTS = "maxTessellationControlPerPatchOutputComponents"; 172 private static final String KEY_MAX_TESSELLATION_CONTROL_PER_VERTEX_INPUT_COMPONENTS = "maxTessellationControlPerVertexInputComponents"; 173 private static final String KEY_MAX_TESSELLATION_CONTROL_PER_VERTEX_OUTPUT_COMPONENTS = "maxTessellationControlPerVertexOutputComponents"; 174 private static final String KEY_MAX_TESSELLATION_CONTROL_TOTAL_OUTPUT_COMPONENTS = "maxTessellationControlTotalOutputComponents"; 175 private static final String KEY_MAX_TESSELLATION_EVALUATION_INPUT_COMPONENTS = "maxTessellationEvaluationInputComponents"; 176 private static final String KEY_MAX_TESSELLATION_EVALUATION_OUTPUT_COMPONENTS = "maxTessellationEvaluationOutputComponents"; 177 private static final String KEY_MAX_TESSELLATION_GENERATION_LEVEL = "maxTessellationGenerationLevel"; 178 private static final String KEY_MAX_TESSELLATION_PATCH_SIZE = "maxTessellationPatchSize"; 179 private static final String KEY_MAX_TEXEL_BUFFER_ELEMENTS = "maxTexelBufferElements"; 180 private static final String KEY_MAX_TEXEL_GATHER_OFFSET = "maxTexelGatherOffset"; 181 private static final String KEY_MAX_TEXEL_OFFSET = "maxTexelOffset"; 182 private static final String KEY_MAX_UNIFORM_BUFFER_RANGE = "maxUniformBufferRange"; 183 private static final String KEY_MAX_VERTEX_INPUT_ATTRIBUTE_OFFSET = "maxVertexInputAttributeOffset"; 184 private static final String KEY_MAX_VERTEX_INPUT_ATTRIBUTES = "maxVertexInputAttributes"; 185 private static final String KEY_MAX_VERTEX_INPUT_BINDING_STRIDE = "maxVertexInputBindingStride"; 186 private static final String KEY_MAX_VERTEX_INPUT_BINDINGS = "maxVertexInputBindings"; 187 private static final String KEY_MAX_VERTEX_OUTPUT_COMPONENTS = "maxVertexOutputComponents"; 188 private static final String KEY_MAX_VIEWPORT_DIMENSIONS = "maxViewportDimensions"; 189 private static final String KEY_MAX_VIEWPORTS = "maxViewports"; 190 private static final String KEY_MEMORY = "memory"; 191 private static final String KEY_MEMORY_HEAP_COUNT = "memoryHeapCount"; 192 private static final String KEY_MEMORY_HEAPS = "memoryHeaps"; 193 private static final String KEY_MEMORY_TYPE_COUNT = "memoryTypeCount"; 194 private static final String KEY_MEMORY_TYPES = "memoryTypes"; 195 private static final String KEY_MIN_IMAGE_TRANSFER_GRANULARITY = "minImageTransferGranularity"; 196 private static final String KEY_MIN_INTERPOLATION_OFFSET = "minInterpolationOffset"; 197 private static final String KEY_MIN_MEMORY_MAP_ALIGNMENT = "minMemoryMapAlignment"; 198 private static final String KEY_MIN_STORAGE_BUFFER_OFFSET_ALIGNMENT = "minStorageBufferOffsetAlignment"; 199 private static final String KEY_MIN_TEXEL_BUFFER_OFFSET_ALIGNMENT = "minTexelBufferOffsetAlignment"; 200 private static final String KEY_MIN_TEXEL_GATHER_OFFSET = "minTexelGatherOffset"; 201 private static final String KEY_MIN_TEXEL_OFFSET = "minTexelOffset"; 202 private static final String KEY_MIN_UNIFORM_BUFFER_OFFSET_ALIGNMENT = "minUniformBufferOffsetAlignment"; 203 private static final String KEY_MIPMAP_PRECISION_BITS = "mipmapPrecisionBits"; 204 private static final String KEY_MULTI_DRAW_INDIRECT = "multiDrawIndirect"; 205 private static final String KEY_MULTI_VIEWPORT = "multiViewport"; 206 private static final String KEY_NON_COHERENT_ATOM_SIZE = "nonCoherentAtomSize"; 207 private static final String KEY_OCCLUSION_QUERY_PRECISE = "occlusionQueryPrecise"; 208 private static final String KEY_OPTIMAL_BUFFER_COPY_OFFSET_ALIGNMENT = "optimalBufferCopyOffsetAlignment"; 209 private static final String KEY_OPTIMAL_BUFFER_COPY_ROW_PITCH_ALIGNMENT = "optimalBufferCopyRowPitchAlignment"; 210 private static final String KEY_OPTIMAL_TILING_FEATURES = "optimalTilingFeatures"; 211 private static final String KEY_PIPELINE_CACHE_UUID = "pipelineCacheUUID"; 212 private static final String KEY_PIPELINE_STATISTICS_QUERY = "pipelineStatisticsQuery"; 213 private static final String KEY_POINT_SIZE_GRANULARITY = "pointSizeGranularity"; 214 private static final String KEY_POINT_SIZE_RANGE = "pointSizeRange"; 215 private static final String KEY_PROPERTIES = "properties"; 216 private static final String KEY_PROPERTY_FLAGS = "propertyFlags"; 217 private static final String KEY_QUEUE_COUNT = "queueCount"; 218 private static final String KEY_QUEUE_FLAGS = "queueFlags"; 219 private static final String KEY_QUEUES = "queues"; 220 private static final String KEY_RESIDENCY_ALIGNED_MIP_SIZE = "residencyAlignedMipSize"; 221 private static final String KEY_RESIDENCY_NON_RESIDENT_STRICT = "residencyNonResidentStrict"; 222 private static final String KEY_RESIDENCY_STANDARD_2D_BLOCK_SHAPE = "residencyStandard2DBlockShape"; 223 private static final String KEY_RESIDENCY_STANDARD_2D_MULTISAMPLE_BLOCK_SHAPE = "residencyStandard2DMultisampleBlockShape"; 224 private static final String KEY_RESIDENCY_STANDARD_3D_BLOCK_SHAPE = "residencyStandard3DBlockShape"; 225 private static final String KEY_ROBUST_BUFFER_ACCESS = "robustBufferAccess"; 226 private static final String KEY_SAMPLE_RATE_SHADING = "sampleRateShading"; 227 private static final String KEY_SAMPLED_IMAGE_COLOR_SAMPLE_COUNTS = "sampledImageColorSampleCounts"; 228 private static final String KEY_SAMPLED_IMAGE_DEPTH_SAMPLE_COUNTS = "sampledImageDepthSampleCounts"; 229 private static final String KEY_SAMPLED_IMAGE_INTEGER_SAMPLE_COUNTS = "sampledImageIntegerSampleCounts"; 230 private static final String KEY_SAMPLED_IMAGE_STENCIL_SAMPLE_COUNTS = "sampledImageStencilSampleCounts"; 231 private static final String KEY_SAMPLER_ANISOTROPY = "samplerAnisotropy"; 232 private static final String KEY_SHADER_CLIP_DISTANCE = "shaderClipDistance"; 233 private static final String KEY_SHADER_CULL_DISTANCE = "shaderCullDistance"; 234 private static final String KEY_SHADER_FLOAT64 = "shaderFloat64"; 235 private static final String KEY_SHADER_IMAGE_GATHER_EXTENDED = "shaderImageGatherExtended"; 236 private static final String KEY_SHADER_INT16 = "shaderInt16"; 237 private static final String KEY_SHADER_INT64 = "shaderInt64"; 238 private static final String KEY_SHADER_RESOURCE_MIN_LOD = "shaderResourceMinLod"; 239 private static final String KEY_SHADER_RESOURCE_RESIDENCY = "shaderResourceResidency"; 240 private static final String KEY_SHADER_SAMPLED_IMAGE_ARRAY_DYNAMIC_INDEXING = "shaderSampledImageArrayDynamicIndexing"; 241 private static final String KEY_SHADER_STORAGE_BUFFER_ARRAY_DYNAMIC_INDEXING = "shaderStorageBufferArrayDynamicIndexing"; 242 private static final String KEY_SHADER_STORAGE_IMAGE_ARRAY_DYNAMIC_INDEXING = "shaderStorageImageArrayDynamicIndexing"; 243 private static final String KEY_SHADER_STORAGE_IMAGE_EXTENDED_FORMATS = "shaderStorageImageExtendedFormats"; 244 private static final String KEY_SHADER_STORAGE_IMAGE_MULTISAMPLE = "shaderStorageImageMultisample"; 245 private static final String KEY_SHADER_STORAGE_IMAGE_READ_WITHOUT_FORMAT = "shaderStorageImageReadWithoutFormat"; 246 private static final String KEY_SHADER_STORAGE_IMAGE_WRITE_WITHOUT_FORMAT = "shaderStorageImageWriteWithoutFormat"; 247 private static final String KEY_SHADER_TESSELLATION_AND_GEOMETRY_POINT_SIZE = "shaderTessellationAndGeometryPointSize"; 248 private static final String KEY_SHADER_UNIFORM_BUFFER_ARRAY_DYNAMIC_INDEXING = "shaderUniformBufferArrayDynamicIndexing"; 249 private static final String KEY_SIZE = "size"; 250 private static final String KEY_SPARSE_ADDRESS_SPACE_SIZE = "sparseAddressSpaceSize"; 251 private static final String KEY_SPARSE_BINDING = "sparseBinding"; 252 private static final String KEY_SPARSE_PROPERTIES = "sparseProperties"; 253 private static final String KEY_SPARSE_RESIDENCY_16_SAMPLES = "sparseResidency16Samples"; 254 private static final String KEY_SPARSE_RESIDENCY_2_SAMPLES = "sparseResidency2Samples"; 255 private static final String KEY_SPARSE_RESIDENCY_4_SAMPLES = "sparseResidency4Samples"; 256 private static final String KEY_SPARSE_RESIDENCY_8_SAMPLES = "sparseResidency8Samples"; 257 private static final String KEY_SPARSE_RESIDENCY_ALIASED = "sparseResidencyAliased"; 258 private static final String KEY_SPARSE_RESIDENCY_BUFFER = "sparseResidencyBuffer"; 259 private static final String KEY_SPARSE_RESIDENCY_IMAGE_2D = "sparseResidencyImage2D"; 260 private static final String KEY_SPARSE_RESIDENCY_IMAGE_3D = "sparseResidencyImage3D"; 261 private static final String KEY_SPEC_VERSION = "specVersion"; 262 private static final String KEY_STANDARD_SAMPLE_LOCATIONS = "standardSampleLocations"; 263 private static final String KEY_STORAGE_IMAGE_SAMPLE_COUNTS = "storageImageSampleCounts"; 264 private static final String KEY_STRICT_LINES = "strictLines"; 265 private static final String KEY_SUB_PIXEL_INTERPOLATION_OFFSET_BITS = "subPixelInterpolationOffsetBits"; 266 private static final String KEY_SUB_PIXEL_PRECISION_BITS = "subPixelPrecisionBits"; 267 private static final String KEY_SUB_TEXEL_PRECISION_BITS = "subTexelPrecisionBits"; 268 private static final String KEY_TESSELLATION_SHADER = "tessellationShader"; 269 private static final String KEY_TEXTURE_COMPRESSION_ASTC_LDR = "textureCompressionASTC_LDR"; 270 private static final String KEY_TEXTURE_COMPRESSION_BC = "textureCompressionBC"; 271 private static final String KEY_TEXTURE_COMPRESSION_ETC2 = "textureCompressionETC2"; 272 private static final String KEY_TIMESTAMP_COMPUTE_AND_GRAPHICS = "timestampComputeAndGraphics"; 273 private static final String KEY_TIMESTAMP_PERIOD = "timestampPeriod"; 274 private static final String KEY_TIMESTAMP_VALID_BITS = "timestampValidBits"; 275 private static final String KEY_VARIABLE_MULTISAMPLE_RATE = "variableMultisampleRate"; 276 private static final String KEY_VENDOR_ID = "vendorID"; 277 private static final String KEY_VERTEX_PIPELINE_STORES_AND_ATOMICS = "vertexPipelineStoresAndAtomics"; 278 private static final String KEY_VIEWPORT_BOUNDS_RANGE = "viewportBoundsRange"; 279 private static final String KEY_VIEWPORT_SUB_PIXEL_BITS = "viewportSubPixelBits"; 280 private static final String KEY_WIDE_LINES = "wideLines"; 281 private static final String KEY_WIDTH = "width"; 282 283 static { 284 System.loadLibrary("ctsdeviceinfo"); 285 } 286 287 @Override collectDeviceInfo(DeviceInfoStore store)288 protected void collectDeviceInfo(DeviceInfoStore store) throws Exception { 289 try { 290 JSONObject instance = new JSONObject(nativeGetVkJSON()); 291 emitLayers(store, instance); 292 emitExtensions(store, instance); 293 emitDevices(store, instance); 294 } catch (JSONException e) { 295 e.printStackTrace(); 296 throw new RuntimeException(e); 297 } 298 } 299 emitDevices(DeviceInfoStore store, JSONObject parent)300 private static void emitDevices(DeviceInfoStore store, JSONObject parent) 301 throws Exception { 302 JSONArray devices = parent.getJSONArray(KEY_DEVICES); 303 store.startArray(convertName(KEY_DEVICES)); 304 for (int deviceIdx = 0; deviceIdx < devices.length(); deviceIdx++) { 305 JSONObject device = devices.getJSONObject(deviceIdx); 306 store.startGroup(); 307 { 308 JSONObject properties = device.getJSONObject(KEY_PROPERTIES); 309 store.startGroup(convertName(KEY_PROPERTIES)); 310 { 311 emitLong(store, properties, KEY_API_VERSION); 312 emitLong(store, properties, KEY_DRIVER_VERSION); 313 emitLong(store, properties, KEY_VENDOR_ID); 314 emitLong(store, properties, KEY_DEVICE_ID); 315 emitLong(store, properties, KEY_DEVICE_TYPE); 316 emitString(store, properties, KEY_DEVICE_NAME); 317 emitLongArray(store, properties, KEY_PIPELINE_CACHE_UUID); 318 319 JSONObject limits = properties.getJSONObject(KEY_LIMITS); 320 store.startGroup(convertName(KEY_LIMITS)); 321 { 322 emitLong(store, limits, KEY_MAX_IMAGE_DIMENSION_1D); 323 emitLong(store, limits, KEY_MAX_IMAGE_DIMENSION_2D); 324 emitLong(store, limits, KEY_MAX_IMAGE_DIMENSION_3D); 325 emitLong(store, limits, KEY_MAX_IMAGE_DIMENSION_CUBE); 326 emitLong(store, limits, KEY_MAX_IMAGE_ARRAY_LAYERS); 327 emitLong(store, limits, KEY_MAX_TEXEL_BUFFER_ELEMENTS); 328 emitLong(store, limits, KEY_MAX_UNIFORM_BUFFER_RANGE); 329 emitLong(store, limits, KEY_MAX_STORAGE_BUFFER_RANGE); 330 emitLong(store, limits, KEY_MAX_PUSH_CONSTANTS_SIZE); 331 emitLong(store, limits, KEY_MAX_MEMORY_ALLOCATION_COUNT); 332 emitLong(store, limits, KEY_MAX_SAMPLER_ALLOCATION_COUNT); 333 emitString(store, limits, KEY_BUFFER_IMAGE_GRANULARITY); 334 emitString(store, limits, KEY_SPARSE_ADDRESS_SPACE_SIZE); 335 emitLong(store, limits, KEY_MAX_BOUND_DESCRIPTOR_SETS); 336 emitLong(store, limits, KEY_MAX_PER_STAGE_DESCRIPTOR_SAMPLERS); 337 emitLong(store, limits, KEY_MAX_PER_STAGE_DESCRIPTOR_UNIFORM_BUFFERS); 338 emitLong(store, limits, KEY_MAX_PER_STAGE_DESCRIPTOR_STORAGE_BUFFERS); 339 emitLong(store, limits, KEY_MAX_PER_STAGE_DESCRIPTOR_SAMPLED_IMAGES); 340 emitLong(store, limits, KEY_MAX_PER_STAGE_DESCRIPTOR_STORAGE_IMAGES); 341 emitLong(store, limits, KEY_MAX_PER_STAGE_DESCRIPTOR_INPUT_ATTACHMENTS); 342 emitLong(store, limits, KEY_MAX_PER_STAGE_RESOURCES); 343 emitLong(store, limits, KEY_MAX_DESCRIPTOR_SET_SAMPLERS); 344 emitLong(store, limits, KEY_MAX_DESCRIPTOR_SET_UNIFORM_BUFFERS); 345 emitLong(store, limits, KEY_MAX_DESCRIPTOR_SET_UNIFORM_BUFFERS_DYNAMIC); 346 emitLong(store, limits, KEY_MAX_DESCRIPTOR_SET_STORAGE_BUFFERS); 347 emitLong(store, limits, KEY_MAX_DESCRIPTOR_SET_STORAGE_BUFFERS_DYNAMIC); 348 emitLong(store, limits, KEY_MAX_DESCRIPTOR_SET_SAMPLED_IMAGES); 349 emitLong(store, limits, KEY_MAX_DESCRIPTOR_SET_STORAGE_IMAGES); 350 emitLong(store, limits, KEY_MAX_DESCRIPTOR_SET_INPUT_ATTACHMENTS); 351 emitLong(store, limits, KEY_MAX_VERTEX_INPUT_ATTRIBUTES); 352 emitLong(store, limits, KEY_MAX_VERTEX_INPUT_BINDINGS); 353 emitLong(store, limits, KEY_MAX_VERTEX_INPUT_ATTRIBUTE_OFFSET); 354 emitLong(store, limits, KEY_MAX_VERTEX_INPUT_BINDING_STRIDE); 355 emitLong(store, limits, KEY_MAX_VERTEX_OUTPUT_COMPONENTS); 356 emitLong(store, limits, KEY_MAX_TESSELLATION_GENERATION_LEVEL); 357 emitLong(store, limits, KEY_MAX_TESSELLATION_PATCH_SIZE); 358 emitLong(store, limits, KEY_MAX_TESSELLATION_CONTROL_PER_VERTEX_INPUT_COMPONENTS); 359 emitLong(store, limits, KEY_MAX_TESSELLATION_CONTROL_PER_VERTEX_OUTPUT_COMPONENTS); 360 emitLong(store, limits, KEY_MAX_TESSELLATION_CONTROL_PER_PATCH_OUTPUT_COMPONENTS); 361 emitLong(store, limits, KEY_MAX_TESSELLATION_CONTROL_TOTAL_OUTPUT_COMPONENTS); 362 emitLong(store, limits, KEY_MAX_TESSELLATION_EVALUATION_INPUT_COMPONENTS); 363 emitLong(store, limits, KEY_MAX_TESSELLATION_EVALUATION_OUTPUT_COMPONENTS); 364 emitLong(store, limits, KEY_MAX_GEOMETRY_SHADER_INVOCATIONS); 365 emitLong(store, limits, KEY_MAX_GEOMETRY_INPUT_COMPONENTS); 366 emitLong(store, limits, KEY_MAX_GEOMETRY_OUTPUT_COMPONENTS); 367 emitLong(store, limits, KEY_MAX_GEOMETRY_OUTPUT_VERTICES); 368 emitLong(store, limits, KEY_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS); 369 emitLong(store, limits, KEY_MAX_FRAGMENT_INPUT_COMPONENTS); 370 emitLong(store, limits, KEY_MAX_FRAGMENT_OUTPUT_ATTACHMENTS); 371 emitLong(store, limits, KEY_MAX_FRAGMENT_DUAL_SRC_ATTACHMENTS); 372 emitLong(store, limits, KEY_MAX_FRAGMENT_COMBINED_OUTPUT_RESOURCES); 373 emitLong(store, limits, KEY_MAX_COMPUTE_SHARED_MEMORY_SIZE); 374 emitLongArray(store, limits, KEY_MAX_COMPUTE_WORK_GROUP_COUNT); 375 emitLong(store, limits, KEY_MAX_COMPUTE_WORK_GROUP_INVOCATIONS); 376 emitLongArray(store, limits, KEY_MAX_COMPUTE_WORK_GROUP_SIZE); 377 emitLong(store, limits, KEY_SUB_PIXEL_PRECISION_BITS); 378 emitLong(store, limits, KEY_SUB_TEXEL_PRECISION_BITS); 379 emitLong(store, limits, KEY_MIPMAP_PRECISION_BITS); 380 emitLong(store, limits, KEY_MAX_DRAW_INDEXED_INDEX_VALUE); 381 emitLong(store, limits, KEY_MAX_DRAW_INDIRECT_COUNT); 382 emitDouble(store, limits, KEY_MAX_SAMPLER_LOD_BIAS); 383 emitDouble(store, limits, KEY_MAX_SAMPLER_ANISOTROPY); 384 emitLong(store, limits, KEY_MAX_VIEWPORTS); 385 emitLongArray(store, limits, KEY_MAX_VIEWPORT_DIMENSIONS); 386 emitDoubleArray(store, limits, KEY_VIEWPORT_BOUNDS_RANGE); 387 emitLong(store, limits, KEY_VIEWPORT_SUB_PIXEL_BITS); 388 emitString(store, limits, KEY_MIN_MEMORY_MAP_ALIGNMENT); 389 emitString(store, limits, KEY_MIN_TEXEL_BUFFER_OFFSET_ALIGNMENT); 390 emitString(store, limits, KEY_MIN_UNIFORM_BUFFER_OFFSET_ALIGNMENT); 391 emitString(store, limits, KEY_MIN_STORAGE_BUFFER_OFFSET_ALIGNMENT); 392 emitLong(store, limits, KEY_MIN_TEXEL_OFFSET); 393 emitLong(store, limits, KEY_MAX_TEXEL_OFFSET); 394 emitLong(store, limits, KEY_MIN_TEXEL_GATHER_OFFSET); 395 emitLong(store, limits, KEY_MAX_TEXEL_GATHER_OFFSET); 396 emitDouble(store, limits, KEY_MIN_INTERPOLATION_OFFSET); 397 emitDouble(store, limits, KEY_MAX_INTERPOLATION_OFFSET); 398 emitLong(store, limits, KEY_SUB_PIXEL_INTERPOLATION_OFFSET_BITS); 399 emitLong(store, limits, KEY_MAX_FRAMEBUFFER_WIDTH); 400 emitLong(store, limits, KEY_MAX_FRAMEBUFFER_HEIGHT); 401 emitLong(store, limits, KEY_MAX_FRAMEBUFFER_LAYERS); 402 emitLong(store, limits, KEY_FRAMEBUFFER_COLOR_SAMPLE_COUNTS); 403 emitLong(store, limits, KEY_FRAMEBUFFER_DEPTH_SAMPLE_COUNTS); 404 emitLong(store, limits, KEY_FRAMEBUFFER_STENCIL_SAMPLE_COUNTS); 405 emitLong(store, limits, KEY_FRAMEBUFFER_NO_ATTACHMENTS_SAMPLE_COUNTS); 406 emitLong(store, limits, KEY_MAX_COLOR_ATTACHMENTS); 407 emitLong(store, limits, KEY_SAMPLED_IMAGE_COLOR_SAMPLE_COUNTS); 408 emitLong(store, limits, KEY_SAMPLED_IMAGE_INTEGER_SAMPLE_COUNTS); 409 emitLong(store, limits, KEY_SAMPLED_IMAGE_DEPTH_SAMPLE_COUNTS); 410 emitLong(store, limits, KEY_SAMPLED_IMAGE_STENCIL_SAMPLE_COUNTS); 411 emitLong(store, limits, KEY_STORAGE_IMAGE_SAMPLE_COUNTS); 412 emitLong(store, limits, KEY_MAX_SAMPLE_MASK_WORDS); 413 emitBoolean(store, limits, KEY_TIMESTAMP_COMPUTE_AND_GRAPHICS); 414 emitDouble(store, limits, KEY_TIMESTAMP_PERIOD); 415 emitLong(store, limits, KEY_MAX_CLIP_DISTANCES); 416 emitLong(store, limits, KEY_MAX_CULL_DISTANCES); 417 emitLong(store, limits, KEY_MAX_COMBINED_CLIP_AND_CULL_DISTANCES); 418 emitLong(store, limits, KEY_DISCRETE_QUEUE_PRIORITIES); 419 emitDoubleArray(store, limits, KEY_POINT_SIZE_RANGE); 420 emitDoubleArray(store, limits, KEY_LINE_WIDTH_RANGE); 421 emitDouble(store, limits, KEY_POINT_SIZE_GRANULARITY); 422 emitDouble(store, limits, KEY_LINE_WIDTH_GRANULARITY); 423 emitBoolean(store, limits, KEY_STRICT_LINES); 424 emitBoolean(store, limits, KEY_STANDARD_SAMPLE_LOCATIONS); 425 emitString(store, limits, KEY_OPTIMAL_BUFFER_COPY_OFFSET_ALIGNMENT); 426 emitString(store, limits, KEY_OPTIMAL_BUFFER_COPY_ROW_PITCH_ALIGNMENT); 427 emitString(store, limits, KEY_NON_COHERENT_ATOM_SIZE); 428 } 429 store.endGroup(); 430 431 JSONObject sparse = properties.getJSONObject(KEY_SPARSE_PROPERTIES); 432 store.startGroup(convertName(KEY_SPARSE_PROPERTIES)); 433 { 434 emitBoolean(store, sparse, KEY_RESIDENCY_STANDARD_2D_BLOCK_SHAPE); 435 emitBoolean(store, sparse, KEY_RESIDENCY_STANDARD_2D_MULTISAMPLE_BLOCK_SHAPE); 436 emitBoolean(store, sparse, KEY_RESIDENCY_STANDARD_3D_BLOCK_SHAPE); 437 emitBoolean(store, sparse, KEY_RESIDENCY_ALIGNED_MIP_SIZE); 438 emitBoolean(store, sparse, KEY_RESIDENCY_NON_RESIDENT_STRICT); 439 } 440 store.endGroup(); 441 } 442 store.endGroup(); 443 444 JSONObject features = device.getJSONObject(KEY_FEATURES); 445 store.startGroup(convertName(KEY_FEATURES)); 446 { 447 emitBoolean(store, features, KEY_ROBUST_BUFFER_ACCESS); 448 emitBoolean(store, features, KEY_FULL_DRAW_INDEX_UINT32); 449 emitBoolean(store, features, KEY_IMAGE_CUBE_ARRAY); 450 emitBoolean(store, features, KEY_INDEPENDENT_BLEND); 451 emitBoolean(store, features, KEY_GEOMETRY_SHADER); 452 emitBoolean(store, features, KEY_TESSELLATION_SHADER); 453 emitBoolean(store, features, KEY_SAMPLE_RATE_SHADING); 454 emitBoolean(store, features, KEY_DUAL_SRC_BLEND); 455 emitBoolean(store, features, KEY_LOGIC_OP); 456 emitBoolean(store, features, KEY_MULTI_DRAW_INDIRECT); 457 emitBoolean(store, features, KEY_DRAW_INDIRECT_FIRST_INSTANCE); 458 emitBoolean(store, features, KEY_DEPTH_CLAMP); 459 emitBoolean(store, features, KEY_DEPTH_BIAS_CLAMP); 460 emitBoolean(store, features, KEY_FILL_MODE_NON_SOLID); 461 emitBoolean(store, features, KEY_DEPTH_BOUNDS); 462 emitBoolean(store, features, KEY_WIDE_LINES); 463 emitBoolean(store, features, KEY_LARGE_POINTS); 464 emitBoolean(store, features, KEY_ALPHA_TO_ONE); 465 emitBoolean(store, features, KEY_MULTI_VIEWPORT); 466 emitBoolean(store, features, KEY_SAMPLER_ANISOTROPY); 467 emitBoolean(store, features, KEY_TEXTURE_COMPRESSION_ETC2); 468 emitBoolean(store, features, KEY_TEXTURE_COMPRESSION_ASTC_LDR); 469 emitBoolean(store, features, KEY_TEXTURE_COMPRESSION_BC); 470 emitBoolean(store, features, KEY_OCCLUSION_QUERY_PRECISE); 471 emitBoolean(store, features, KEY_PIPELINE_STATISTICS_QUERY); 472 emitBoolean(store, features, KEY_VERTEX_PIPELINE_STORES_AND_ATOMICS); 473 emitBoolean(store, features, KEY_FRAGMENT_STORES_AND_ATOMICS); 474 emitBoolean(store, features, KEY_SHADER_TESSELLATION_AND_GEOMETRY_POINT_SIZE); 475 emitBoolean(store, features, KEY_SHADER_IMAGE_GATHER_EXTENDED); 476 emitBoolean(store, features, KEY_SHADER_STORAGE_IMAGE_EXTENDED_FORMATS); 477 emitBoolean(store, features, KEY_SHADER_STORAGE_IMAGE_MULTISAMPLE); 478 emitBoolean(store, features, KEY_SHADER_STORAGE_IMAGE_READ_WITHOUT_FORMAT); 479 emitBoolean(store, features, KEY_SHADER_STORAGE_IMAGE_WRITE_WITHOUT_FORMAT); 480 emitBoolean(store, features, KEY_SHADER_UNIFORM_BUFFER_ARRAY_DYNAMIC_INDEXING); 481 emitBoolean(store, features, KEY_SHADER_SAMPLED_IMAGE_ARRAY_DYNAMIC_INDEXING); 482 emitBoolean(store, features, KEY_SHADER_STORAGE_BUFFER_ARRAY_DYNAMIC_INDEXING); 483 emitBoolean(store, features, KEY_SHADER_STORAGE_IMAGE_ARRAY_DYNAMIC_INDEXING); 484 emitBoolean(store, features, KEY_SHADER_CLIP_DISTANCE); 485 emitBoolean(store, features, KEY_SHADER_CULL_DISTANCE); 486 emitBoolean(store, features, KEY_SHADER_FLOAT64); 487 emitBoolean(store, features, KEY_SHADER_INT64); 488 emitBoolean(store, features, KEY_SHADER_INT16); 489 emitBoolean(store, features, KEY_SHADER_RESOURCE_RESIDENCY); 490 emitBoolean(store, features, KEY_SHADER_RESOURCE_MIN_LOD); 491 emitBoolean(store, features, KEY_SPARSE_BINDING); 492 emitBoolean(store, features, KEY_SPARSE_RESIDENCY_BUFFER); 493 emitBoolean(store, features, KEY_SPARSE_RESIDENCY_IMAGE_2D); 494 emitBoolean(store, features, KEY_SPARSE_RESIDENCY_IMAGE_3D); 495 emitBoolean(store, features, KEY_SPARSE_RESIDENCY_2_SAMPLES); 496 emitBoolean(store, features, KEY_SPARSE_RESIDENCY_4_SAMPLES); 497 emitBoolean(store, features, KEY_SPARSE_RESIDENCY_8_SAMPLES); 498 emitBoolean(store, features, KEY_SPARSE_RESIDENCY_16_SAMPLES); 499 emitBoolean(store, features, KEY_SPARSE_RESIDENCY_ALIASED); 500 emitBoolean(store, features, KEY_VARIABLE_MULTISAMPLE_RATE); 501 emitBoolean(store, features, KEY_INHERITED_QUERIES); 502 } 503 store.endGroup(); 504 505 JSONObject memory = device.getJSONObject(KEY_MEMORY); 506 store.startGroup(convertName(KEY_MEMORY)); 507 { 508 emitLong(store, memory, KEY_MEMORY_TYPE_COUNT); 509 JSONArray memoryTypes = memory.getJSONArray(KEY_MEMORY_TYPES); 510 store.startArray(convertName(KEY_MEMORY_TYPES)); 511 for (int memoryTypeIdx = 0; memoryTypeIdx < memoryTypes.length(); 512 memoryTypeIdx++) { 513 JSONObject memoryType = memoryTypes.getJSONObject(memoryTypeIdx); 514 store.startGroup(); 515 { 516 emitLong(store, memoryType, KEY_PROPERTY_FLAGS); 517 emitLong(store, memoryType, KEY_HEAP_INDEX); 518 } 519 store.endGroup(); 520 } 521 store.endArray(); 522 523 emitLong(store, memory, KEY_MEMORY_HEAP_COUNT); 524 JSONArray memoryHeaps = memory.getJSONArray(KEY_MEMORY_HEAPS); 525 store.startArray(convertName(KEY_MEMORY_HEAPS)); 526 for (int memoryHeapIdx = 0; memoryHeapIdx < memoryHeaps.length(); 527 memoryHeapIdx++) { 528 JSONObject memoryHeap = memoryHeaps.getJSONObject(memoryHeapIdx); 529 store.startGroup(); 530 { 531 emitString(store, memoryHeap, KEY_SIZE); 532 emitLong(store, memoryHeap, KEY_FLAGS); 533 } 534 store.endGroup(); 535 } 536 store.endArray(); 537 } 538 store.endGroup(); 539 540 JSONArray queues = device.getJSONArray(KEY_QUEUES); 541 store.startArray(convertName(KEY_QUEUES)); 542 for (int queueIdx = 0; queueIdx < queues.length(); queueIdx++) { 543 JSONObject queue = queues.getJSONObject(queueIdx); 544 store.startGroup(); 545 { 546 emitLong(store, queue, KEY_QUEUE_FLAGS); 547 emitLong(store, queue, KEY_QUEUE_COUNT); 548 emitLong(store, queue, KEY_TIMESTAMP_VALID_BITS); 549 JSONObject extent = queue.getJSONObject(KEY_MIN_IMAGE_TRANSFER_GRANULARITY); 550 store.startGroup(convertName(KEY_MIN_IMAGE_TRANSFER_GRANULARITY)); 551 { 552 emitLong(store, extent, KEY_WIDTH); 553 emitLong(store, extent, KEY_HEIGHT); 554 emitLong(store, extent, KEY_DEPTH); 555 } 556 store.endGroup(); 557 } 558 store.endGroup(); 559 } 560 store.endArray(); 561 562 // Skip layers for now. VkJSON doesn't yet include device layer extensions, so 563 // this is entirely redundant with the instance extension information. 564 // emitLayers(store, device); 565 store.startArray(convertName(KEY_LAYERS)); 566 store.endArray(); 567 568 emitExtensions(store, device); 569 570 JSONArray formats = device.getJSONArray(KEY_FORMATS); 571 store.startGroup(convertName(KEY_FORMATS)); 572 for (int formatIdx = 0; formatIdx < formats.length(); formatIdx++) { 573 JSONArray formatPair = formats.getJSONArray(formatIdx); 574 JSONObject formatProperties = formatPair.getJSONObject(1); 575 store.startGroup("format_" + formatPair.getInt(0)); 576 { 577 emitLong(store, formatProperties, KEY_LINEAR_TILING_FEATURES); 578 emitLong(store, formatProperties, KEY_OPTIMAL_TILING_FEATURES); 579 emitLong(store, formatProperties, KEY_BUFFER_FEATURES); 580 } 581 store.endGroup(); 582 } 583 store.endGroup(); 584 } 585 store.endGroup(); 586 } 587 store.endArray(); 588 } 589 emitLayers(DeviceInfoStore store, JSONObject parent)590 private static void emitLayers(DeviceInfoStore store, JSONObject parent) 591 throws Exception { 592 JSONArray layers = parent.getJSONArray(KEY_LAYERS); 593 store.startArray(convertName(KEY_LAYERS)); 594 for (int i = 0; i < layers.length(); i++) { 595 JSONObject layer = layers.getJSONObject(i); 596 store.startGroup(); 597 { 598 JSONObject properties = layer.getJSONObject(KEY_PROPERTIES); 599 store.startGroup(convertName(KEY_PROPERTIES)); 600 { 601 emitString(store, properties, KEY_LAYER_NAME); 602 emitLong(store, properties, KEY_SPEC_VERSION); 603 emitLong(store, properties, KEY_IMPLEMENTATION_VERSION); 604 emitString(store, properties, KEY_DESCRIPTION); 605 } 606 store.endGroup(); 607 emitExtensions(store, layer); 608 } 609 store.endGroup(); 610 } 611 store.endArray(); 612 } 613 emitExtensions(DeviceInfoStore store, JSONObject parent)614 private static void emitExtensions(DeviceInfoStore store, JSONObject parent) 615 throws Exception { 616 JSONArray extensions = parent.getJSONArray(KEY_EXTENSIONS); 617 store.startArray(convertName(KEY_EXTENSIONS)); 618 for (int i = 0; i < extensions.length(); i++) { 619 JSONObject extension = extensions.getJSONObject(i); 620 store.startGroup(); 621 { 622 emitString(store, extension, KEY_EXTENSION_NAME); 623 emitLong(store, extension, KEY_SPEC_VERSION); 624 } 625 store.endGroup(); 626 } 627 store.endArray(); 628 } 629 emitBoolean(DeviceInfoStore store, JSONObject parent, String name)630 private static void emitBoolean(DeviceInfoStore store, JSONObject parent, String name) 631 throws Exception { 632 store.addResult(convertName(name), parent.getInt(name) != 0 ? true : false); 633 } 634 emitLong(DeviceInfoStore store, JSONObject parent, String name)635 private static void emitLong(DeviceInfoStore store, JSONObject parent, String name) 636 throws Exception { 637 store.addResult(convertName(name), parent.getLong(name)); 638 } 639 emitDouble(DeviceInfoStore store, JSONObject parent, String name)640 private static void emitDouble(DeviceInfoStore store, JSONObject parent, String name) 641 throws Exception { 642 store.addResult(convertName(name), parent.getDouble(name)); 643 } 644 emitString(DeviceInfoStore store, JSONObject parent, String name)645 private static void emitString(DeviceInfoStore store, JSONObject parent, String name) 646 throws Exception { 647 store.addResult(convertName(name), parent.getString(name)); 648 } 649 emitLongArray(DeviceInfoStore store, JSONObject parent, String name)650 private static void emitLongArray(DeviceInfoStore store, JSONObject parent, String name) 651 throws Exception { 652 JSONArray jsonArray = parent.getJSONArray(name); 653 long[] array = new long[jsonArray.length()]; 654 for (int i = 0; i < jsonArray.length(); i++) { 655 array[i] = jsonArray.getLong(i); 656 } 657 store.addArrayResult(convertName(name), array); 658 } 659 emitDoubleArray(DeviceInfoStore store, JSONObject parent, String name)660 private static void emitDoubleArray(DeviceInfoStore store, JSONObject parent, String name) 661 throws Exception { 662 JSONArray jsonArray = parent.getJSONArray(name); 663 double[] array = new double[jsonArray.length()]; 664 for (int i = 0; i < jsonArray.length(); i++) { 665 array[i] = jsonArray.getDouble(i); 666 } 667 store.addArrayResult(convertName(name), array); 668 } 669 convertName(String name)670 private static String convertName(String name) { 671 // This translation could be done algorithmically, but in this case being able to 672 // code-search for both the original and converted names is more important. 673 switch (name) { 674 case KEY_ALPHA_TO_ONE: return "alpha_to_one"; 675 case KEY_API_VERSION: return "api_version"; 676 case KEY_BUFFER_FEATURES: return "buffer_features"; 677 case KEY_BUFFER_IMAGE_GRANULARITY: return "buffer_image_granularity"; 678 case KEY_DEPTH: return "depth"; 679 case KEY_DEPTH_BIAS_CLAMP: return "depth_bias_clamp"; 680 case KEY_DEPTH_BOUNDS: return "depth_bounds"; 681 case KEY_DEPTH_CLAMP: return "depth_clamp"; 682 case KEY_DESCRIPTION: return "description"; 683 case KEY_DEVICE_ID: return "device_id"; 684 case KEY_DEVICE_NAME: return "device_name"; 685 case KEY_DEVICE_TYPE: return "device_type"; 686 case KEY_DEVICES: return "devices"; 687 case KEY_DISCRETE_QUEUE_PRIORITIES: return "discrete_queue_priorities"; 688 case KEY_DRAW_INDIRECT_FIRST_INSTANCE: return "draw_indirect_first_instance"; 689 case KEY_DRIVER_VERSION: return "driver_version"; 690 case KEY_DUAL_SRC_BLEND: return "dual_src_blend"; 691 case KEY_EXTENSION_NAME: return "extension_name"; 692 case KEY_EXTENSIONS: return "extensions"; 693 case KEY_FEATURES: return "features"; 694 case KEY_FILL_MODE_NON_SOLID: return "fill_mode_non_solid"; 695 case KEY_FLAGS: return "flags"; 696 case KEY_FORMATS: return "formats"; 697 case KEY_FRAGMENT_STORES_AND_ATOMICS: return "fragment_stores_and_atomics"; 698 case KEY_FRAMEBUFFER_COLOR_SAMPLE_COUNTS: return "framebuffer_color_sample_counts"; 699 case KEY_FRAMEBUFFER_DEPTH_SAMPLE_COUNTS: return "framebuffer_depth_sample_counts"; 700 case KEY_FRAMEBUFFER_NO_ATTACHMENTS_SAMPLE_COUNTS: return "framebuffer_no_attachments_sample_counts"; 701 case KEY_FRAMEBUFFER_STENCIL_SAMPLE_COUNTS: return "framebuffer_stencil_sample_counts"; 702 case KEY_FULL_DRAW_INDEX_UINT32: return "full_draw_index_uint32"; 703 case KEY_GEOMETRY_SHADER: return "geometry_shader"; 704 case KEY_HEAP_INDEX: return "heap_index"; 705 case KEY_HEIGHT: return "height"; 706 case KEY_IMAGE_CUBE_ARRAY: return "image_cube_array"; 707 case KEY_IMPLEMENTATION_VERSION: return "implementation_version"; 708 case KEY_INDEPENDENT_BLEND: return "independent_blend"; 709 case KEY_INHERITED_QUERIES: return "inherited_queries"; 710 case KEY_LARGE_POINTS: return "large_points"; 711 case KEY_LAYER_NAME: return "layer_name"; 712 case KEY_LAYERS: return "layers"; 713 case KEY_LIMITS: return "limits"; 714 case KEY_LINE_WIDTH_GRANULARITY: return "line_width_granularity"; 715 case KEY_LINE_WIDTH_RANGE: return "line_width_range"; 716 case KEY_LINEAR_TILING_FEATURES: return "linear_tiling_features"; 717 case KEY_LOGIC_OP: return "logic_op"; 718 case KEY_MAX_BOUND_DESCRIPTOR_SETS: return "max_bound_descriptor_sets"; 719 case KEY_MAX_CLIP_DISTANCES: return "max_clip_distances"; 720 case KEY_MAX_COLOR_ATTACHMENTS: return "max_color_attachments"; 721 case KEY_MAX_COMBINED_CLIP_AND_CULL_DISTANCES: return "max_combined_clip_and_cull_distances"; 722 case KEY_MAX_COMPUTE_SHARED_MEMORY_SIZE: return "max_compute_shared_memory_size"; 723 case KEY_MAX_COMPUTE_WORK_GROUP_COUNT: return "max_compute_work_group_count"; 724 case KEY_MAX_COMPUTE_WORK_GROUP_INVOCATIONS: return "max_compute_work_group_invocations"; 725 case KEY_MAX_COMPUTE_WORK_GROUP_SIZE: return "max_compute_work_group_size"; 726 case KEY_MAX_CULL_DISTANCES: return "max_cull_distances"; 727 case KEY_MAX_DESCRIPTOR_SET_INPUT_ATTACHMENTS: return "max_descriptor_set_input_attachments"; 728 case KEY_MAX_DESCRIPTOR_SET_SAMPLED_IMAGES: return "max_descriptor_set_sampled_images"; 729 case KEY_MAX_DESCRIPTOR_SET_SAMPLERS: return "max_descriptor_set_samplers"; 730 case KEY_MAX_DESCRIPTOR_SET_STORAGE_BUFFERS: return "max_descriptor_set_storage_buffers"; 731 case KEY_MAX_DESCRIPTOR_SET_STORAGE_BUFFERS_DYNAMIC: return "max_descriptor_set_storage_buffers_dynamic"; 732 case KEY_MAX_DESCRIPTOR_SET_STORAGE_IMAGES: return "max_descriptor_set_storage_images"; 733 case KEY_MAX_DESCRIPTOR_SET_UNIFORM_BUFFERS: return "max_descriptor_set_uniform_buffers"; 734 case KEY_MAX_DESCRIPTOR_SET_UNIFORM_BUFFERS_DYNAMIC: return "max_descriptor_set_uniform_buffers_dynamic"; 735 case KEY_MAX_DRAW_INDEXED_INDEX_VALUE: return "max_draw_indexed_index_value"; 736 case KEY_MAX_DRAW_INDIRECT_COUNT: return "max_draw_indirect_count"; 737 case KEY_MAX_FRAGMENT_COMBINED_OUTPUT_RESOURCES: return "max_fragment_combined_output_resources"; 738 case KEY_MAX_FRAGMENT_DUAL_SRC_ATTACHMENTS: return "max_fragment_dual_src_attachments"; 739 case KEY_MAX_FRAGMENT_INPUT_COMPONENTS: return "max_fragment_input_components"; 740 case KEY_MAX_FRAGMENT_OUTPUT_ATTACHMENTS: return "max_fragment_output_attachments"; 741 case KEY_MAX_FRAMEBUFFER_HEIGHT: return "max_framebuffer_height"; 742 case KEY_MAX_FRAMEBUFFER_LAYERS: return "max_framebuffer_layers"; 743 case KEY_MAX_FRAMEBUFFER_WIDTH: return "max_framebuffer_width"; 744 case KEY_MAX_GEOMETRY_INPUT_COMPONENTS: return "max_geometry_input_components"; 745 case KEY_MAX_GEOMETRY_OUTPUT_COMPONENTS: return "max_geometry_output_components"; 746 case KEY_MAX_GEOMETRY_OUTPUT_VERTICES: return "max_geometry_output_vertices"; 747 case KEY_MAX_GEOMETRY_SHADER_INVOCATIONS: return "max_geometry_shader_invocations"; 748 case KEY_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS: return "max_geometry_total_output_components"; 749 case KEY_MAX_IMAGE_ARRAY_LAYERS: return "max_image_array_layers"; 750 case KEY_MAX_IMAGE_DIMENSION_1D: return "max_image_dimension_1d"; 751 case KEY_MAX_IMAGE_DIMENSION_2D: return "max_image_dimension_2d"; 752 case KEY_MAX_IMAGE_DIMENSION_3D: return "max_image_dimension_3d"; 753 case KEY_MAX_IMAGE_DIMENSION_CUBE: return "max_image_dimension_cube"; 754 case KEY_MAX_INTERPOLATION_OFFSET: return "max_interpolation_offset"; 755 case KEY_MAX_MEMORY_ALLOCATION_COUNT: return "max_memory_allocation_count"; 756 case KEY_MAX_PER_STAGE_DESCRIPTOR_INPUT_ATTACHMENTS: return "max_per_stage_descriptor_input_attachments"; 757 case KEY_MAX_PER_STAGE_DESCRIPTOR_SAMPLED_IMAGES: return "max_per_stage_descriptor_sampled_images"; 758 case KEY_MAX_PER_STAGE_DESCRIPTOR_SAMPLERS: return "max_per_stage_descriptor_samplers"; 759 case KEY_MAX_PER_STAGE_DESCRIPTOR_STORAGE_BUFFERS: return "max_per_stage_descriptor_storage_buffers"; 760 case KEY_MAX_PER_STAGE_DESCRIPTOR_STORAGE_IMAGES: return "max_per_stage_descriptor_storage_images"; 761 case KEY_MAX_PER_STAGE_DESCRIPTOR_UNIFORM_BUFFERS: return "max_per_stage_descriptor_uniform_buffers"; 762 case KEY_MAX_PER_STAGE_RESOURCES: return "max_per_stage_resources"; 763 case KEY_MAX_PUSH_CONSTANTS_SIZE: return "max_push_constants_size"; 764 case KEY_MAX_SAMPLE_MASK_WORDS: return "max_sample_mask_words"; 765 case KEY_MAX_SAMPLER_ALLOCATION_COUNT: return "max_sampler_allocation_count"; 766 case KEY_MAX_SAMPLER_ANISOTROPY: return "max_sampler_anisotropy"; 767 case KEY_MAX_SAMPLER_LOD_BIAS: return "max_sampler_lod_bias"; 768 case KEY_MAX_STORAGE_BUFFER_RANGE: return "max_storage_buffer_range"; 769 case KEY_MAX_TESSELLATION_CONTROL_PER_PATCH_OUTPUT_COMPONENTS: return "max_tessellation_control_per_patch_output_components"; 770 case KEY_MAX_TESSELLATION_CONTROL_PER_VERTEX_INPUT_COMPONENTS: return "max_tessellation_control_per_vertex_input_components"; 771 case KEY_MAX_TESSELLATION_CONTROL_PER_VERTEX_OUTPUT_COMPONENTS: return "max_tessellation_control_per_vertex_output_components"; 772 case KEY_MAX_TESSELLATION_CONTROL_TOTAL_OUTPUT_COMPONENTS: return "max_tessellation_control_total_output_components"; 773 case KEY_MAX_TESSELLATION_EVALUATION_INPUT_COMPONENTS: return "max_tessellation_evaluation_input_components"; 774 case KEY_MAX_TESSELLATION_EVALUATION_OUTPUT_COMPONENTS: return "max_tessellation_evaluation_output_components"; 775 case KEY_MAX_TESSELLATION_GENERATION_LEVEL: return "max_tessellation_generation_level"; 776 case KEY_MAX_TESSELLATION_PATCH_SIZE: return "max_tessellation_patch_size"; 777 case KEY_MAX_TEXEL_BUFFER_ELEMENTS: return "max_texel_buffer_elements"; 778 case KEY_MAX_TEXEL_GATHER_OFFSET: return "max_texel_gather_offset"; 779 case KEY_MAX_TEXEL_OFFSET: return "max_texel_offset"; 780 case KEY_MAX_UNIFORM_BUFFER_RANGE: return "max_uniform_buffer_range"; 781 case KEY_MAX_VERTEX_INPUT_ATTRIBUTE_OFFSET: return "max_vertex_input_attribute_offset"; 782 case KEY_MAX_VERTEX_INPUT_ATTRIBUTES: return "max_vertex_input_attributes"; 783 case KEY_MAX_VERTEX_INPUT_BINDING_STRIDE: return "max_vertex_input_binding_stride"; 784 case KEY_MAX_VERTEX_INPUT_BINDINGS: return "max_vertex_input_bindings"; 785 case KEY_MAX_VERTEX_OUTPUT_COMPONENTS: return "max_vertex_output_components"; 786 case KEY_MAX_VIEWPORT_DIMENSIONS: return "max_viewport_dimensions"; 787 case KEY_MAX_VIEWPORTS: return "max_viewports"; 788 case KEY_MEMORY: return "memory"; 789 case KEY_MEMORY_HEAP_COUNT: return "memory_heap_count"; 790 case KEY_MEMORY_HEAPS: return "memory_heaps"; 791 case KEY_MEMORY_TYPE_COUNT: return "memory_type_count"; 792 case KEY_MEMORY_TYPES: return "memory_types"; 793 case KEY_MIN_IMAGE_TRANSFER_GRANULARITY: return "min_image_transfer_granularity"; 794 case KEY_MIN_INTERPOLATION_OFFSET: return "min_interpolation_offset"; 795 case KEY_MIN_MEMORY_MAP_ALIGNMENT: return "min_memory_map_alignment"; 796 case KEY_MIN_STORAGE_BUFFER_OFFSET_ALIGNMENT: return "min_storage_buffer_offset_alignment"; 797 case KEY_MIN_TEXEL_BUFFER_OFFSET_ALIGNMENT: return "min_texel_buffer_offset_alignment"; 798 case KEY_MIN_TEXEL_GATHER_OFFSET: return "min_texel_gather_offset"; 799 case KEY_MIN_TEXEL_OFFSET: return "min_texel_offset"; 800 case KEY_MIN_UNIFORM_BUFFER_OFFSET_ALIGNMENT: return "min_uniform_buffer_offset_alignment"; 801 case KEY_MIPMAP_PRECISION_BITS: return "mipmap_precision_bits"; 802 case KEY_MULTI_DRAW_INDIRECT: return "multi_draw_indirect"; 803 case KEY_MULTI_VIEWPORT: return "multi_viewport"; 804 case KEY_NON_COHERENT_ATOM_SIZE: return "non_coherent_atom_size"; 805 case KEY_OCCLUSION_QUERY_PRECISE: return "occlusion_query_precise"; 806 case KEY_OPTIMAL_BUFFER_COPY_OFFSET_ALIGNMENT: return "optimal_buffer_copy_offset_alignment"; 807 case KEY_OPTIMAL_BUFFER_COPY_ROW_PITCH_ALIGNMENT: return "optimal_buffer_copy_row_pitch_alignment"; 808 case KEY_OPTIMAL_TILING_FEATURES: return "optimal_tiling_features"; 809 case KEY_PIPELINE_CACHE_UUID: return "pipeline_cache_uuid"; 810 case KEY_PIPELINE_STATISTICS_QUERY: return "pipeline_statistics_query"; 811 case KEY_POINT_SIZE_GRANULARITY: return "point_size_granularity"; 812 case KEY_POINT_SIZE_RANGE: return "point_size_range"; 813 case KEY_PROPERTIES: return "properties"; 814 case KEY_PROPERTY_FLAGS: return "property_flags"; 815 case KEY_QUEUE_COUNT: return "queue_count"; 816 case KEY_QUEUE_FLAGS: return "queue_flags"; 817 case KEY_QUEUES: return "queues"; 818 case KEY_RESIDENCY_ALIGNED_MIP_SIZE: return "residency_aligned_mip_size"; 819 case KEY_RESIDENCY_NON_RESIDENT_STRICT: return "residency_non_resident_strict"; 820 case KEY_RESIDENCY_STANDARD_2D_BLOCK_SHAPE: return "residency_standard_2d_block_shape"; 821 case KEY_RESIDENCY_STANDARD_2D_MULTISAMPLE_BLOCK_SHAPE: return "residency_standard_2d_multisample_block_shape"; 822 case KEY_RESIDENCY_STANDARD_3D_BLOCK_SHAPE: return "residency_standard_3d_block_shape"; 823 case KEY_ROBUST_BUFFER_ACCESS: return "robust_buffer_access"; 824 case KEY_SAMPLE_RATE_SHADING: return "sample_rate_shading"; 825 case KEY_SAMPLED_IMAGE_COLOR_SAMPLE_COUNTS: return "sampled_image_color_sample_counts"; 826 case KEY_SAMPLED_IMAGE_DEPTH_SAMPLE_COUNTS: return "sampled_image_depth_sample_counts"; 827 case KEY_SAMPLED_IMAGE_INTEGER_SAMPLE_COUNTS: return "sampled_image_integer_sample_counts"; 828 case KEY_SAMPLED_IMAGE_STENCIL_SAMPLE_COUNTS: return "sampled_image_stencil_sample_counts"; 829 case KEY_SAMPLER_ANISOTROPY: return "sampler_anisotropy"; 830 case KEY_SHADER_CLIP_DISTANCE: return "shader_clip_distance"; 831 case KEY_SHADER_CULL_DISTANCE: return "shader_cull_distance"; 832 case KEY_SHADER_FLOAT64: return "shader_float64"; 833 case KEY_SHADER_IMAGE_GATHER_EXTENDED: return "shader_image_gather_extended"; 834 case KEY_SHADER_INT16: return "shader_int16"; 835 case KEY_SHADER_INT64: return "shader_int64"; 836 case KEY_SHADER_RESOURCE_MIN_LOD: return "shader_resource_min_lod"; 837 case KEY_SHADER_RESOURCE_RESIDENCY: return "shader_resource_residency"; 838 case KEY_SHADER_SAMPLED_IMAGE_ARRAY_DYNAMIC_INDEXING: return "shader_sampled_image_array_dynamic_indexing"; 839 case KEY_SHADER_STORAGE_BUFFER_ARRAY_DYNAMIC_INDEXING: return "shader_storage_buffer_array_dynamic_indexing"; 840 case KEY_SHADER_STORAGE_IMAGE_ARRAY_DYNAMIC_INDEXING: return "shader_storage_image_array_dynamic_indexing"; 841 case KEY_SHADER_STORAGE_IMAGE_EXTENDED_FORMATS: return "shader_storage_image_extended_formats"; 842 case KEY_SHADER_STORAGE_IMAGE_MULTISAMPLE: return "shader_storage_image_multisample"; 843 case KEY_SHADER_STORAGE_IMAGE_READ_WITHOUT_FORMAT: return "shader_storage_image_read_without_format"; 844 case KEY_SHADER_STORAGE_IMAGE_WRITE_WITHOUT_FORMAT: return "shader_storage_image_write_without_format"; 845 case KEY_SHADER_TESSELLATION_AND_GEOMETRY_POINT_SIZE: return "shader_tessellation_and_geometry_point_size"; 846 case KEY_SHADER_UNIFORM_BUFFER_ARRAY_DYNAMIC_INDEXING: return "shader_uniform_buffer_array_dynamic_indexing"; 847 case KEY_SIZE: return "size"; 848 case KEY_SPARSE_ADDRESS_SPACE_SIZE: return "sparse_address_space_size"; 849 case KEY_SPARSE_BINDING: return "sparse_binding"; 850 case KEY_SPARSE_PROPERTIES: return "sparse_properties"; 851 case KEY_SPARSE_RESIDENCY_16_SAMPLES: return "sparse_residency_16_samples"; 852 case KEY_SPARSE_RESIDENCY_2_SAMPLES: return "sparse_residency_2_samples"; 853 case KEY_SPARSE_RESIDENCY_4_SAMPLES: return "sparse_residency_4_samples"; 854 case KEY_SPARSE_RESIDENCY_8_SAMPLES: return "sparse_residency_8_samples"; 855 case KEY_SPARSE_RESIDENCY_ALIASED: return "sparse_residency_aliased"; 856 case KEY_SPARSE_RESIDENCY_BUFFER: return "sparse_residency_buffer"; 857 case KEY_SPARSE_RESIDENCY_IMAGE_2D: return "sparse_residency_image_2d"; 858 case KEY_SPARSE_RESIDENCY_IMAGE_3D: return "sparse_residency_image_3d"; 859 case KEY_SPEC_VERSION: return "spec_version"; 860 case KEY_STANDARD_SAMPLE_LOCATIONS: return "standard_sample_locations"; 861 case KEY_STORAGE_IMAGE_SAMPLE_COUNTS: return "storage_image_sample_counts"; 862 case KEY_STRICT_LINES: return "strict_lines"; 863 case KEY_SUB_PIXEL_INTERPOLATION_OFFSET_BITS: return "sub_pixel_interpolation_offset_bits"; 864 case KEY_SUB_PIXEL_PRECISION_BITS: return "sub_pixel_precision_bits"; 865 case KEY_SUB_TEXEL_PRECISION_BITS: return "sub_texel_precision_bits"; 866 case KEY_TESSELLATION_SHADER: return "tessellation_shader"; 867 case KEY_TEXTURE_COMPRESSION_ASTC_LDR: return "texture_compression_astc_ldr"; 868 case KEY_TEXTURE_COMPRESSION_BC: return "texture_compression_bc"; 869 case KEY_TEXTURE_COMPRESSION_ETC2: return "texture_compression_etc2"; 870 case KEY_TIMESTAMP_COMPUTE_AND_GRAPHICS: return "timestamp_compute_and_graphics"; 871 case KEY_TIMESTAMP_PERIOD: return "timestamp_period"; 872 case KEY_TIMESTAMP_VALID_BITS: return "timestamp_valid_bits"; 873 case KEY_VARIABLE_MULTISAMPLE_RATE: return "variable_multisample_rate"; 874 case KEY_VENDOR_ID: return "vendor_id"; 875 case KEY_VERTEX_PIPELINE_STORES_AND_ATOMICS: return "vertex_pipeline_stores_and_atomics"; 876 case KEY_VIEWPORT_BOUNDS_RANGE: return "viewport_bounds_range"; 877 case KEY_VIEWPORT_SUB_PIXEL_BITS: return "viewport_sub_pixel_bits"; 878 case KEY_WIDE_LINES: return "wide_lines"; 879 case KEY_WIDTH: return "width"; 880 default: throw new RuntimeException("unknown key name: " + name); 881 } 882 } 883 nativeGetVkJSON()884 private static native String nativeGetVkJSON(); 885 886 } 887