radv: add a new debug option called RADV_DEBUG=noshaderballot
[mesa.git] / src / amd / vulkan / radv_device.c
index fc961040b6e047c6661cc7a5a6df4717f6745b8d..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}
 };
 
@@ -973,11 +977,8 @@ void radv_GetPhysicalDeviceFeatures2(
                case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES_KHR: {
                        VkPhysicalDeviceShaderAtomicInt64FeaturesKHR *features =
                                (VkPhysicalDeviceShaderAtomicInt64FeaturesKHR *)ext;
-                       /* TODO: Enable this once the driver supports 64-bit
-                        * compare&swap atomic operations.
-                        */
-                       features->shaderBufferInt64Atomics = false;
-                       features->shaderSharedInt64Atomics = false;
+                       features->shaderBufferInt64Atomics = HAVE_LLVM >= 0x0900;
+                       features->shaderSharedInt64Atomics = HAVE_LLVM >= 0x0900;
                        break;
                }
                case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_FEATURES_EXT: {
@@ -1013,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;
                }
@@ -1889,6 +1902,9 @@ VkResult radv_CreateDevice(
                device->enabled_extensions.EXT_descriptor_indexing ||
                device->enabled_extensions.EXT_buffer_device_address;
 
+       device->robust_buffer_access = pCreateInfo->pEnabledFeatures &&
+                                      pCreateInfo->pEnabledFeatures->robustBufferAccess;
+
        mtx_init(&device->shader_slab_mutex, mtx_plain);
        list_inithead(&device->shader_slabs);
 
@@ -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));
@@ -4352,7 +4371,7 @@ radv_init_dcc_control_reg(struct radv_device *device,
               S_028C78_INDEPENDENT_128B_BLOCKS(independent_128b_blocks);
 }
 
-static void
+void
 radv_initialise_color_surface(struct radv_device *device,
                              struct radv_color_buffer_info *cb,
                              struct radv_image_view *iview)
@@ -4411,15 +4430,15 @@ radv_initialise_color_surface(struct radv_device *device,
 
                cb->cb_color_pitch = S_028C64_TILE_MAX(pitch_tile_max);
                cb->cb_color_slice = S_028C68_TILE_MAX(slice_tile_max);
-               cb->cb_color_cmask_slice = iview->image->cmask.slice_tile_max;
+               cb->cb_color_cmask_slice = surf->u.legacy.cmask_slice_tile_max;
 
                cb->cb_color_attrib |= S_028C74_TILE_MODE_INDEX(tile_mode_index);
 
                if (radv_image_has_fmask(iview->image)) {
                        if (device->physical_device->rad_info.chip_class >= GFX7)
-                               cb->cb_color_pitch |= S_028C64_FMASK_TILE_MAX(iview->image->fmask.pitch_in_pixels / 8 - 1);
-                       cb->cb_color_attrib |= S_028C74_FMASK_TILE_MODE_INDEX(iview->image->fmask.tile_mode_index);
-                       cb->cb_color_fmask_slice = S_028C88_TILE_MAX(iview->image->fmask.slice_tile_max);
+                               cb->cb_color_pitch |= S_028C64_FMASK_TILE_MAX(surf->u.legacy.fmask.pitch_in_pixels / 8 - 1);
+                       cb->cb_color_attrib |= S_028C74_FMASK_TILE_MODE_INDEX(surf->u.legacy.fmask.tiling_index);
+                       cb->cb_color_fmask_slice = S_028C88_TILE_MAX(surf->u.legacy.fmask.slice_tile_max);
                } else {
                        /* This must be set for fast clear to work without FMASK. */
                        if (device->physical_device->rad_info.chip_class >= GFX7)
@@ -4431,7 +4450,7 @@ radv_initialise_color_surface(struct radv_device *device,
 
        /* CMASK variables */
        va = radv_buffer_get_va(iview->bo) + iview->image->offset;
-       va += iview->image->cmask.offset;
+       va += iview->image->cmask_offset;
        cb->cb_color_cmask = va >> 8;
 
        va = radv_buffer_get_va(iview->bo) + iview->image->offset;
@@ -4460,9 +4479,9 @@ radv_initialise_color_surface(struct radv_device *device,
        }
 
        if (radv_image_has_fmask(iview->image)) {
-               va = radv_buffer_get_va(iview->bo) + iview->image->offset + iview->image->fmask.offset;
+               va = radv_buffer_get_va(iview->bo) + iview->image->offset + iview->image->fmask_offset;
                cb->cb_color_fmask = va >> 8;
-               cb->cb_color_fmask |= iview->image->fmask.tile_swizzle;
+               cb->cb_color_fmask |= surf->fmask_tile_swizzle;
        } else {
                cb->cb_color_fmask = cb->cb_color_base;
        }
@@ -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 */
@@ -4512,7 +4531,7 @@ radv_initialise_color_surface(struct radv_device *device,
        if (radv_image_has_fmask(iview->image)) {
                cb->cb_color_info |= S_028C70_COMPRESSION(1);
                if (device->physical_device->rad_info.chip_class == GFX6) {
-                       unsigned fmask_bankh = util_logbase2(iview->image->fmask.bank_height);
+                       unsigned fmask_bankh = util_logbase2(surf->u.legacy.fmask.bankh);
                        cb->cb_color_attrib |= S_028C74_FMASK_BANK_HEIGHT(fmask_bankh);
                }
 
@@ -4612,7 +4631,7 @@ radv_calc_decompress_on_z_planes(struct radv_device *device,
        return max_zplanes;
 }
 
-static void
+void
 radv_initialise_ds_surface(struct radv_device *device,
                           struct radv_ds_buffer_info *ds,
                           struct radv_image_view *iview)
@@ -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_attachment_info) * 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,18 +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].attachment = iview;
-               if (iview->aspect_mask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) {
-                       radv_initialise_ds_surface(device, &framebuffer->attachments[i].ds, iview);
-               } else {
-                       radv_initialise_color_surface(device, &framebuffer->attachments[i].cb, 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));
                }
-               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);