~mmach/netext73/mesa-ryzen

« back to all changes in this revision

Viewing changes to src/panfrost/vulkan/panvk_device.c

  • Committer: mmach
  • Date: 2023-11-02 21:31:35 UTC
  • Revision ID: netbit73@gmail.com-20231102213135-18d4tzh7tj0uz752
2023-11-02 22:11:57

Show diffs side-by-side

added added

removed removed

Lines of Context:
162
162
   };
163
163
}
164
164
 
 
165
static void
 
166
panvk_get_features(const struct panvk_physical_device *device,
 
167
                   struct vk_features *features)
 
168
{
 
169
   *features = (struct vk_features){
 
170
      /* Vulkan 1.0 */
 
171
      .robustBufferAccess = true,
 
172
      .fullDrawIndexUint32 = true,
 
173
      .independentBlend = true,
 
174
      .logicOp = true,
 
175
      .wideLines = true,
 
176
      .largePoints = true,
 
177
      .textureCompressionETC2 = true,
 
178
      .textureCompressionASTC_LDR = true,
 
179
      .shaderUniformBufferArrayDynamicIndexing = true,
 
180
      .shaderSampledImageArrayDynamicIndexing = true,
 
181
      .shaderStorageBufferArrayDynamicIndexing = true,
 
182
      .shaderStorageImageArrayDynamicIndexing = true,
 
183
 
 
184
      /* Vulkan 1.1 */
 
185
      .storageBuffer16BitAccess = false,
 
186
      .uniformAndStorageBuffer16BitAccess = false,
 
187
      .storagePushConstant16 = false,
 
188
      .storageInputOutput16 = false,
 
189
      .multiview = false,
 
190
      .multiviewGeometryShader = false,
 
191
      .multiviewTessellationShader = false,
 
192
      .variablePointersStorageBuffer = true,
 
193
      .variablePointers = true,
 
194
      .protectedMemory = false,
 
195
      .samplerYcbcrConversion = false,
 
196
      .shaderDrawParameters = false,
 
197
 
 
198
      /* Vulkan 1.2 */
 
199
      .samplerMirrorClampToEdge = false,
 
200
      .drawIndirectCount = false,
 
201
      .storageBuffer8BitAccess = false,
 
202
      .uniformAndStorageBuffer8BitAccess = false,
 
203
      .storagePushConstant8 = false,
 
204
      .shaderBufferInt64Atomics = false,
 
205
      .shaderSharedInt64Atomics = false,
 
206
      .shaderFloat16 = false,
 
207
      .shaderInt8 = false,
 
208
 
 
209
      .descriptorIndexing = false,
 
210
      .shaderInputAttachmentArrayDynamicIndexing = false,
 
211
      .shaderUniformTexelBufferArrayDynamicIndexing = false,
 
212
      .shaderStorageTexelBufferArrayDynamicIndexing = false,
 
213
      .shaderUniformBufferArrayNonUniformIndexing = false,
 
214
      .shaderSampledImageArrayNonUniformIndexing = false,
 
215
      .shaderStorageBufferArrayNonUniformIndexing = false,
 
216
      .shaderStorageImageArrayNonUniformIndexing = false,
 
217
      .shaderInputAttachmentArrayNonUniformIndexing = false,
 
218
      .shaderUniformTexelBufferArrayNonUniformIndexing = false,
 
219
      .shaderStorageTexelBufferArrayNonUniformIndexing = false,
 
220
      .descriptorBindingUniformBufferUpdateAfterBind = false,
 
221
      .descriptorBindingSampledImageUpdateAfterBind = false,
 
222
      .descriptorBindingStorageImageUpdateAfterBind = false,
 
223
      .descriptorBindingStorageBufferUpdateAfterBind = false,
 
224
      .descriptorBindingUniformTexelBufferUpdateAfterBind = false,
 
225
      .descriptorBindingStorageTexelBufferUpdateAfterBind = false,
 
226
      .descriptorBindingUpdateUnusedWhilePending = false,
 
227
      .descriptorBindingPartiallyBound = false,
 
228
      .descriptorBindingVariableDescriptorCount = false,
 
229
      .runtimeDescriptorArray = false,
 
230
 
 
231
      .samplerFilterMinmax = false,
 
232
      .scalarBlockLayout = false,
 
233
      .imagelessFramebuffer = false,
 
234
      .uniformBufferStandardLayout = false,
 
235
      .shaderSubgroupExtendedTypes = false,
 
236
      .separateDepthStencilLayouts = false,
 
237
      .hostQueryReset = false,
 
238
      .timelineSemaphore = false,
 
239
      .bufferDeviceAddress = false,
 
240
      .bufferDeviceAddressCaptureReplay = false,
 
241
      .bufferDeviceAddressMultiDevice = false,
 
242
      .vulkanMemoryModel = false,
 
243
      .vulkanMemoryModelDeviceScope = false,
 
244
      .vulkanMemoryModelAvailabilityVisibilityChains = false,
 
245
      .shaderOutputViewportIndex = false,
 
246
      .shaderOutputLayer = false,
 
247
      .subgroupBroadcastDynamicId = false,
 
248
 
 
249
      /* Vulkan 1.3 */
 
250
      .robustImageAccess = false,
 
251
      .inlineUniformBlock = false,
 
252
      .descriptorBindingInlineUniformBlockUpdateAfterBind = false,
 
253
      .pipelineCreationCacheControl = false,
 
254
      .privateData = true,
 
255
      .shaderDemoteToHelperInvocation = false,
 
256
      .shaderTerminateInvocation = false,
 
257
      .subgroupSizeControl = false,
 
258
      .computeFullSubgroups = false,
 
259
      .synchronization2 = true,
 
260
      .textureCompressionASTC_HDR = false,
 
261
      .shaderZeroInitializeWorkgroupMemory = false,
 
262
      .dynamicRendering = false,
 
263
      .shaderIntegerDotProduct = false,
 
264
      .maintenance4 = false,
 
265
 
 
266
      /* VK_EXT_index_type_uint8 */
 
267
      .indexTypeUint8 = true,
 
268
 
 
269
      /* VK_EXT_vertex_attribute_divisor */
 
270
      .vertexAttributeInstanceRateDivisor = true,
 
271
      .vertexAttributeInstanceRateZeroDivisor = true,
 
272
 
 
273
      /* VK_EXT_depth_clip_enable */
 
274
      .depthClipEnable = true,
 
275
 
 
276
      /* VK_EXT_4444_formats */
 
277
      .formatA4R4G4B4 = true,
 
278
      .formatA4B4G4R4 = true,
 
279
 
 
280
      /* VK_EXT_custom_border_color */
 
281
      .customBorderColors = true,
 
282
      .customBorderColorWithoutFormat = true,
 
283
   };
 
284
}
 
285
 
165
286
VkResult panvk_physical_device_try_create(struct vk_instance *vk_instance,
166
287
                                          struct _drmDevice *drm_device,
167
288
                                          struct vk_physical_device **out);
223
344
      parse_debug_string(getenv("PANVK_DEBUG"), panvk_debug_options);
224
345
 
225
346
   if (instance->debug_flags & PANVK_DEBUG_STARTUP)
226
 
      panvk_logi("Created an instance");
 
347
      vk_logi(VK_LOG_NO_OBJS(instance), "Created an instance");
227
348
 
228
349
   VG(VALGRIND_CREATE_MEMPOOL(instance, 0, false));
229
350
 
288
409
   drmFreeVersion(version);
289
410
 
290
411
   if (instance->debug_flags & PANVK_DEBUG_STARTUP)
291
 
      panvk_logi("Found compatible device '%s'.", path);
 
412
      vk_logi(VK_LOG_NO_OBJS(instance), "Found compatible device '%s'.", path);
292
413
 
293
414
   struct vk_device_extension_table supported_extensions;
294
415
   panvk_get_device_extensions(device, &supported_extensions);
295
416
 
 
417
   struct vk_features supported_features;
 
418
   panvk_get_features(device, &supported_features);
 
419
 
296
420
   struct vk_physical_device_dispatch_table dispatch_table;
297
421
   vk_physical_device_dispatch_table_from_entrypoints(
298
422
      &dispatch_table, &panvk_physical_device_entrypoints, true);
299
423
   vk_physical_device_dispatch_table_from_entrypoints(
300
424
      &dispatch_table, &wsi_physical_device_entrypoints, false);
301
425
 
302
 
   result = vk_physical_device_init(&device->vk, &instance->vk,
303
 
                                    &supported_extensions, &dispatch_table);
 
426
   result =
 
427
      vk_physical_device_init(&device->vk, &instance->vk, &supported_extensions,
 
428
                              &supported_features, &dispatch_table);
304
429
 
305
430
   if (result != VK_SUCCESS) {
306
431
      vk_error(instance, result);
308
433
   }
309
434
 
310
435
   device->instance = instance;
311
 
   assert(strlen(path) < ARRAY_SIZE(device->path));
312
 
   strncpy(device->path, path, ARRAY_SIZE(device->path));
313
436
 
314
437
   if (instance->vk.enabled_extensions.KHR_display) {
315
438
      master_fd = open(drm_device->nodes[DRM_NODE_PRIMARY], O_RDWR | O_CLOEXEC);
406
529
}
407
530
 
408
531
void
409
 
panvk_GetPhysicalDeviceFeatures2(VkPhysicalDevice physicalDevice,
410
 
                                 VkPhysicalDeviceFeatures2 *pFeatures)
411
 
{
412
 
   struct vk_features features = {
413
 
      /* Vulkan 1.0 */
414
 
      .robustBufferAccess = true,
415
 
      .fullDrawIndexUint32 = true,
416
 
      .independentBlend = true,
417
 
      .logicOp = true,
418
 
      .wideLines = true,
419
 
      .largePoints = true,
420
 
      .textureCompressionETC2 = true,
421
 
      .textureCompressionASTC_LDR = true,
422
 
      .shaderUniformBufferArrayDynamicIndexing = true,
423
 
      .shaderSampledImageArrayDynamicIndexing = true,
424
 
      .shaderStorageBufferArrayDynamicIndexing = true,
425
 
      .shaderStorageImageArrayDynamicIndexing = true,
426
 
 
427
 
      /* Vulkan 1.1 */
428
 
      .storageBuffer16BitAccess = false,
429
 
      .uniformAndStorageBuffer16BitAccess = false,
430
 
      .storagePushConstant16 = false,
431
 
      .storageInputOutput16 = false,
432
 
      .multiview = false,
433
 
      .multiviewGeometryShader = false,
434
 
      .multiviewTessellationShader = false,
435
 
      .variablePointersStorageBuffer = true,
436
 
      .variablePointers = true,
437
 
      .protectedMemory = false,
438
 
      .samplerYcbcrConversion = false,
439
 
      .shaderDrawParameters = false,
440
 
 
441
 
      /* Vulkan 1.2 */
442
 
      .samplerMirrorClampToEdge = false,
443
 
      .drawIndirectCount = false,
444
 
      .storageBuffer8BitAccess = false,
445
 
      .uniformAndStorageBuffer8BitAccess = false,
446
 
      .storagePushConstant8 = false,
447
 
      .shaderBufferInt64Atomics = false,
448
 
      .shaderSharedInt64Atomics = false,
449
 
      .shaderFloat16 = false,
450
 
      .shaderInt8 = false,
451
 
 
452
 
      .descriptorIndexing = false,
453
 
      .shaderInputAttachmentArrayDynamicIndexing = false,
454
 
      .shaderUniformTexelBufferArrayDynamicIndexing = false,
455
 
      .shaderStorageTexelBufferArrayDynamicIndexing = false,
456
 
      .shaderUniformBufferArrayNonUniformIndexing = false,
457
 
      .shaderSampledImageArrayNonUniformIndexing = false,
458
 
      .shaderStorageBufferArrayNonUniformIndexing = false,
459
 
      .shaderStorageImageArrayNonUniformIndexing = false,
460
 
      .shaderInputAttachmentArrayNonUniformIndexing = false,
461
 
      .shaderUniformTexelBufferArrayNonUniformIndexing = false,
462
 
      .shaderStorageTexelBufferArrayNonUniformIndexing = false,
463
 
      .descriptorBindingUniformBufferUpdateAfterBind = false,
464
 
      .descriptorBindingSampledImageUpdateAfterBind = false,
465
 
      .descriptorBindingStorageImageUpdateAfterBind = false,
466
 
      .descriptorBindingStorageBufferUpdateAfterBind = false,
467
 
      .descriptorBindingUniformTexelBufferUpdateAfterBind = false,
468
 
      .descriptorBindingStorageTexelBufferUpdateAfterBind = false,
469
 
      .descriptorBindingUpdateUnusedWhilePending = false,
470
 
      .descriptorBindingPartiallyBound = false,
471
 
      .descriptorBindingVariableDescriptorCount = false,
472
 
      .runtimeDescriptorArray = false,
473
 
 
474
 
      .samplerFilterMinmax = false,
475
 
      .scalarBlockLayout = false,
476
 
      .imagelessFramebuffer = false,
477
 
      .uniformBufferStandardLayout = false,
478
 
      .shaderSubgroupExtendedTypes = false,
479
 
      .separateDepthStencilLayouts = false,
480
 
      .hostQueryReset = false,
481
 
      .timelineSemaphore = false,
482
 
      .bufferDeviceAddress = false,
483
 
      .bufferDeviceAddressCaptureReplay = false,
484
 
      .bufferDeviceAddressMultiDevice = false,
485
 
      .vulkanMemoryModel = false,
486
 
      .vulkanMemoryModelDeviceScope = false,
487
 
      .vulkanMemoryModelAvailabilityVisibilityChains = false,
488
 
      .shaderOutputViewportIndex = false,
489
 
      .shaderOutputLayer = false,
490
 
      .subgroupBroadcastDynamicId = false,
491
 
 
492
 
      /* Vulkan 1.3 */
493
 
      .robustImageAccess = false,
494
 
      .inlineUniformBlock = false,
495
 
      .descriptorBindingInlineUniformBlockUpdateAfterBind = false,
496
 
      .pipelineCreationCacheControl = false,
497
 
      .privateData = true,
498
 
      .shaderDemoteToHelperInvocation = false,
499
 
      .shaderTerminateInvocation = false,
500
 
      .subgroupSizeControl = false,
501
 
      .computeFullSubgroups = false,
502
 
      .synchronization2 = true,
503
 
      .textureCompressionASTC_HDR = false,
504
 
      .shaderZeroInitializeWorkgroupMemory = false,
505
 
      .dynamicRendering = false,
506
 
      .shaderIntegerDotProduct = false,
507
 
      .maintenance4 = false,
508
 
 
509
 
      /* VK_EXT_index_type_uint8 */
510
 
      .indexTypeUint8 = true,
511
 
 
512
 
      /* VK_EXT_vertex_attribute_divisor */
513
 
      .vertexAttributeInstanceRateDivisor = true,
514
 
      .vertexAttributeInstanceRateZeroDivisor = true,
515
 
 
516
 
      /* VK_EXT_depth_clip_enable */
517
 
      .depthClipEnable = true,
518
 
 
519
 
      /* VK_EXT_4444_formats */
520
 
      .formatA4R4G4B4 = true,
521
 
      .formatA4B4G4R4 = true,
522
 
 
523
 
      /* VK_EXT_custom_border_color */
524
 
      .customBorderColors = true,
525
 
      .customBorderColorWithoutFormat = true,
526
 
   };
527
 
 
528
 
   vk_get_physical_device_features(pFeatures, &features);
529
 
}
530
 
 
531
 
void
532
532
panvk_GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice,
533
533
                                   VkPhysicalDeviceProperties2 *pProperties)
534
534
{
698
698
      .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_PROPERTIES,
699
699
   };
700
700
 
701
 
   vk_foreach_struct(ext, pProperties->pNext)
702
 
   {
 
701
   vk_foreach_struct(ext, pProperties->pNext) {
703
702
      if (vk_get_physical_device_core_1_1_property_ext(ext, &core_1_1))
704
703
         continue;
705
704
      if (vk_get_physical_device_core_1_2_property_ext(ext, &core_1_2))