radv: add a new debug option called RADV_DEBUG=noshaderballot
[mesa.git] / src / amd / vulkan / radv_device.c
index 0d4b25c6969f4aa51369b31a6bda7d3230af2b17..f77430d55be3d7bbac85ea2f575c1c41389f217f 100644 (file)
@@ -348,7 +348,8 @@ radv_physical_device_init(struct radv_physical_device *device,
                device->rbplus_allowed = device->rad_info.family == CHIP_STONEY ||
                                         device->rad_info.family == CHIP_VEGA12 ||
                                         device->rad_info.family == CHIP_RAVEN ||
-                                        device->rad_info.family == CHIP_RAVEN2;
+                                        device->rad_info.family == CHIP_RAVEN2 ||
+                                        device->rad_info.family == CHIP_RENOIR;
        }
 
        /* The mere presence of CLEAR_STATE in the IB causes random GPU hangs
@@ -379,9 +380,11 @@ radv_physical_device_init(struct radv_physical_device *device,
                                        device->rad_info.me_fw_feature >= 41);
 
        device->has_dcc_constant_encode = device->rad_info.family == CHIP_RAVEN2 ||
+                                         device->rad_info.family == CHIP_RENOIR ||
                                          device->rad_info.chip_class >= GFX10;
 
-       device->use_shader_ballot = device->instance->perftest_flags & RADV_PERFTEST_SHADER_BALLOT;
+       device->use_shader_ballot = device->rad_info.chip_class >= GFX8 &&
+                                   device->instance->perftest_flags & RADV_PERFTEST_SHADER_BALLOT;
 
        /* Determine the number of threads per wave for all stages. */
        device->cs_wave_size = 64;
@@ -493,6 +496,7 @@ static const struct debug_control radv_debug_options[] = {
        {"nobinning", RADV_DEBUG_NOBINNING},
        {"noloadstoreopt", RADV_DEBUG_NO_LOAD_STORE_OPT},
        {"nongg", RADV_DEBUG_NO_NGG},
+       {"noshaderballot", RADV_DEBUG_NO_SHADER_BALLOT},
        {NULL, 0}
 };
 
@@ -1010,6 +1014,18 @@ void radv_GetPhysicalDeviceFeatures2(
                        features->indexTypeUint8 = pdevice->rad_info.chip_class >= GFX8;
                        break;
                }
+               case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES_KHR: {
+                       VkPhysicalDeviceImagelessFramebufferFeaturesKHR *features =
+                               (VkPhysicalDeviceImagelessFramebufferFeaturesKHR *)ext;
+                       features->imagelessFramebuffer = true;
+                       break;
+               }
+               case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_EXECUTABLE_PROPERTIES_FEATURES_KHR: {
+                       VkPhysicalDevicePipelineExecutablePropertiesFeaturesKHR *features =
+                               (VkPhysicalDevicePipelineExecutablePropertiesFeaturesKHR *)ext;
+                       features->pipelineExecutableInfo = true;
+                       break;
+               }
                default:
                        break;
                }
@@ -1925,10 +1941,10 @@ VkResult radv_CreateDevice(
        device->pbb_allowed = device->physical_device->rad_info.chip_class >= GFX9 &&
                              !(device->instance->debug_flags & RADV_DEBUG_NOBINNING);
 
-       /* Disabled and not implemented for now. */
        device->dfsm_allowed = device->pbb_allowed &&
                               (device->physical_device->rad_info.family == CHIP_RAVEN ||
-                               device->physical_device->rad_info.family == CHIP_RAVEN2);
+                               device->physical_device->rad_info.family == CHIP_RAVEN2 ||
+                               device->physical_device->rad_info.family == CHIP_RENOIR);
 
 #ifdef ANDROID
        device->always_use_syncobj = device->physical_device->rad_info.has_syncobj_wait_for_submit;
@@ -1996,9 +2012,12 @@ VkResult radv_CreateDevice(
                device->empty_cs[family] = device->ws->cs_create(device->ws, family);
                switch (family) {
                case RADV_QUEUE_GENERAL:
-                       radeon_emit(device->empty_cs[family], PKT3(PKT3_CONTEXT_CONTROL, 1, 0));
-                       radeon_emit(device->empty_cs[family], CONTEXT_CONTROL_LOAD_ENABLE(1));
-                       radeon_emit(device->empty_cs[family], CONTEXT_CONTROL_SHADOW_ENABLE(1));
+                     /* Since amdgpu version 3.6.0, CONTEXT_CONTROL is emitted by the kernel */
+                       if (device->physical_device->rad_info.drm_minor < 6) {
+                               radeon_emit(device->empty_cs[family], PKT3(PKT3_CONTEXT_CONTROL, 1, 0));
+                               radeon_emit(device->empty_cs[family], CONTEXT_CONTROL_LOAD_ENABLE(1));
+                               radeon_emit(device->empty_cs[family], CONTEXT_CONTROL_SHADOW_ENABLE(1));
+                       }
                        break;
                case RADV_QUEUE_COMPUTE:
                        radeon_emit(device->empty_cs[family], PKT3(PKT3_NOP, 0, 0));
@@ -4473,7 +4492,7 @@ radv_initialise_color_surface(struct radv_device *device,
        format = radv_translate_colorformat(iview->vk_format);
        if (format == V_028C70_COLOR_INVALID || ntype == ~0u)
                radv_finishme("Illegal color\n");
-       swap = radv_translate_colorswap(iview->vk_format, FALSE);
+       swap = radv_translate_colorswap(iview->vk_format, false);
        endian = radv_colorformat_endian_swap(format);
 
        /* blend clamp should be set for all NORM/SRGB types */
@@ -4806,11 +4825,15 @@ VkResult radv_CreateFramebuffer(
 {
        RADV_FROM_HANDLE(radv_device, device, _device);
        struct radv_framebuffer *framebuffer;
+       const VkFramebufferAttachmentsCreateInfoKHR *imageless_create_info =
+               vk_find_struct_const(pCreateInfo->pNext,
+                       FRAMEBUFFER_ATTACHMENTS_CREATE_INFO_KHR);
 
        assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO);
 
-       size_t size = sizeof(*framebuffer) +
-               sizeof(struct radv_image_view*) * pCreateInfo->attachmentCount;
+       size_t size = sizeof(*framebuffer);
+       if (!imageless_create_info)
+               size += sizeof(struct radv_image_view*) * pCreateInfo->attachmentCount;
        framebuffer = vk_alloc2(&device->alloc, pAllocator, size, 8,
                                  VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
        if (framebuffer == NULL)
@@ -4820,13 +4843,23 @@ VkResult radv_CreateFramebuffer(
        framebuffer->width = pCreateInfo->width;
        framebuffer->height = pCreateInfo->height;
        framebuffer->layers = pCreateInfo->layers;
-       for (uint32_t i = 0; i < pCreateInfo->attachmentCount; i++) {
-               VkImageView _iview = pCreateInfo->pAttachments[i];
-               struct radv_image_view *iview = radv_image_view_from_handle(_iview);
-               framebuffer->attachments[i] = iview;
-               framebuffer->width = MIN2(framebuffer->width, iview->extent.width);
-               framebuffer->height = MIN2(framebuffer->height, iview->extent.height);
-               framebuffer->layers = MIN2(framebuffer->layers, radv_surface_max_layer_count(iview));
+       if (imageless_create_info) {
+               for (unsigned i = 0; i < imageless_create_info->attachmentImageInfoCount; ++i) {
+                       const VkFramebufferAttachmentImageInfoKHR *attachment =
+                               imageless_create_info->pAttachmentImageInfos + i;
+                       framebuffer->width = MIN2(framebuffer->width, attachment->width);
+                       framebuffer->height = MIN2(framebuffer->height, attachment->height);
+                       framebuffer->layers = MIN2(framebuffer->layers, attachment->layerCount);
+               }
+       } else {
+               for (uint32_t i = 0; i < pCreateInfo->attachmentCount; i++) {
+                       VkImageView _iview = pCreateInfo->pAttachments[i];
+                       struct radv_image_view *iview = radv_image_view_from_handle(_iview);
+                       framebuffer->attachments[i] = iview;
+                       framebuffer->width = MIN2(framebuffer->width, iview->extent.width);
+                       framebuffer->height = MIN2(framebuffer->height, iview->extent.height);
+                       framebuffer->layers = MIN2(framebuffer->layers, radv_surface_max_layer_count(iview));
+               }
        }
 
        *pFramebuffer = radv_framebuffer_to_handle(framebuffer);