vulkan: add vk_x11_strict_image_count option
[mesa.git] / src / amd / vulkan / radv_device.c
index ca484fcc0fc28c988077c977ec7cb919f041e584..bdc38a555dedd44fc753211db19532c57c9576d9 100644 (file)
@@ -29,6 +29,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <fcntl.h>
+#include <llvm/Config/llvm-config.h>
 #include "radv_debug.h"
 #include "radv_private.h"
 #include "radv_shader.h"
@@ -354,42 +355,12 @@ radv_physical_device_init(struct radv_physical_device *device,
        radv_get_driver_uuid(&device->driver_uuid);
        radv_get_device_uuid(&device->rad_info, &device->device_uuid);
 
-       if (device->rad_info.family == CHIP_STONEY ||
-           device->rad_info.chip_class >= GFX9) {
-               device->has_rbplus = true;
-               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_RENOIR;
-       }
-
-       device->cpdma_prefetch_writes_memory = device->rad_info.chip_class <= GFX8;
-
-       /* Vega10/Raven need a special workaround for a hardware bug. */
-       device->has_scissor_bug = device->rad_info.family == CHIP_VEGA10 ||
-                                 device->rad_info.family == CHIP_RAVEN;
-
-       device->has_tc_compat_zrange_bug = device->rad_info.chip_class < GFX10;
-
-       /* Out-of-order primitive rasterization. */
-       device->has_out_of_order_rast = device->rad_info.chip_class >= GFX8 &&
-                                       device->rad_info.max_se >= 2;
-       device->out_of_order_rast_allowed = device->has_out_of_order_rast &&
+       device->out_of_order_rast_allowed = device->rad_info.has_out_of_order_rast &&
                                            !(device->instance->debug_flags & RADV_DEBUG_NO_OUT_OF_ORDER);
 
        device->dcc_msaa_allowed =
                (device->instance->perftest_flags & RADV_PERFTEST_DCC_MSAA);
 
-       /* TODO: Figure out how to use LOAD_CONTEXT_REG on GFX6-GFX7. */
-       device->has_load_ctx_reg_pkt = device->rad_info.chip_class >= GFX9 ||
-                                      (device->rad_info.chip_class >= GFX8 &&
-                                       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->rad_info.chip_class >= GFX8 &&
                                    device->instance->perftest_flags & RADV_PERFTEST_SHADER_BALLOT;
 
@@ -561,7 +532,7 @@ radv_handle_per_app_options(struct radv_instance *instance,
                 * load/store memory operations.
                 * See https://reviews.llvm.org/D61313
                 */
-               if (HAVE_LLVM < 0x900)
+               if (LLVM_VERSION_MAJOR < 9)
                        instance->debug_flags |= RADV_DEBUG_NO_LOAD_STORE_OPT;
        } else if (!strcmp(name, "Wolfenstein: Youngblood")) {
                if (!(instance->debug_flags & RADV_DEBUG_NO_SHADER_BALLOT)) {
@@ -585,8 +556,10 @@ static int radv_get_instance_extension_index(const char *name)
 
 static const char radv_dri_options_xml[] =
 DRI_CONF_BEGIN
-       DRI_CONF_SECTION_QUALITY
+       DRI_CONF_SECTION_PERFORMANCE
                DRI_CONF_ADAPTIVE_SYNC("true")
+               DRI_CONF_VK_X11_OVERRIDE_MIN_IMAGE_COUNT(0)
+               DRI_CONF_VK_X11_STRICT_IMAGE_COUNT("false")
        DRI_CONF_SECTION_END
 DRI_CONF_END;
 
@@ -595,7 +568,9 @@ static void  radv_init_dri_options(struct radv_instance *instance)
        driParseOptionInfo(&instance->available_dri_options, radv_dri_options_xml);
        driParseConfigFiles(&instance->dri_options,
                            &instance->available_dri_options,
-                           0, "radv", NULL);
+                           0, "radv", NULL,
+                           instance->engineName,
+                           instance->engineVersion);
 }
 
 VkResult radv_CreateInstance(
@@ -616,6 +591,13 @@ VkResult radv_CreateInstance(
                client_version = VK_API_VERSION_1_0;
        }
 
+       const char *engine_name = NULL;
+       uint32_t engine_version = 0;
+       if (pCreateInfo->pApplicationInfo) {
+               engine_name = pCreateInfo->pApplicationInfo->pEngineName;
+               engine_version = pCreateInfo->pApplicationInfo->engineVersion;
+       }
+
        instance = vk_zalloc2(&default_alloc, pAllocator, sizeof(*instance), 8,
                              VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
        if (!instance)
@@ -659,6 +641,10 @@ VkResult radv_CreateInstance(
                return vk_error(instance, result);
        }
 
+       instance->engineName = vk_strdup(&instance->alloc, engine_name,
+                                        VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
+       instance->engineVersion = engine_version;
+
        _mesa_locale_init();
        glsl_type_singleton_init_or_ref();
 
@@ -685,6 +671,8 @@ void radv_DestroyInstance(
                radv_physical_device_finish(instance->physicalDevices + i);
        }
 
+       vk_free(&instance->alloc, instance->engineName);
+
        VG(VALGRIND_DESTROY_MEMPOOL(instance));
 
        glsl_type_singleton_decref();
@@ -887,7 +875,7 @@ void radv_GetPhysicalDeviceFeatures2(
                        features->storageBuffer16BitAccess = enabled;
                        features->uniformAndStorageBuffer16BitAccess = enabled;
                        features->storagePushConstant16 = enabled;
-                       features->storageInputOutput16 = enabled && HAVE_LLVM >= 0x900;
+                       features->storageInputOutput16 = enabled && LLVM_VERSION_MAJOR >= 9;
                        break;
                }
                case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES: {
@@ -993,8 +981,8 @@ void radv_GetPhysicalDeviceFeatures2(
                case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES_KHR: {
                        VkPhysicalDeviceShaderAtomicInt64FeaturesKHR *features =
                                (VkPhysicalDeviceShaderAtomicInt64FeaturesKHR *)ext;
-                       features->shaderBufferInt64Atomics = HAVE_LLVM >= 0x0900;
-                       features->shaderSharedInt64Atomics = HAVE_LLVM >= 0x0900;
+                       features->shaderBufferInt64Atomics = LLVM_VERSION_MAJOR >= 9;
+                       features->shaderSharedInt64Atomics = LLVM_VERSION_MAJOR >= 9;
                        break;
                }
                case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_FEATURES_EXT: {
@@ -1302,7 +1290,7 @@ void radv_GetPhysicalDeviceProperties2(
 
                        /* SGPR. */
                        properties->sgprsPerSimd =
-                               ac_get_num_physical_sgprs(pdevice->rad_info.chip_class);
+                               ac_get_num_physical_sgprs(&pdevice->rad_info);
                        properties->minSgprAllocation =
                                pdevice->rad_info.chip_class >= GFX8 ? 16 : 8;
                        properties->maxSgprAllocation =
@@ -2005,9 +1993,6 @@ VkResult radv_CreateDevice(
 
        device->tess_offchip_block_dw_size =
                device->physical_device->rad_info.family == CHIP_HAWAII ? 4096 : 8192;
-       device->has_distributed_tess =
-               device->physical_device->rad_info.chip_class >= GFX8 &&
-               device->physical_device->rad_info.max_se >= 2;
 
        if (getenv("RADV_TRACE_FILE")) {
                const char *filename = getenv("RADV_TRACE_FILE");