Mesa (main): radv: report APUs as discrete GPUs for Red Dead Redemption 2

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jul 16 07:31:47 UTC 2021


Module: Mesa
Branch: main
Commit: cadf2d63b736b610728d508ed507551dd74ba16a
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=cadf2d63b736b610728d508ed507551dd74ba16a

Author: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Date:   Wed Jul 14 11:40:15 2021 +0200

radv: report APUs as discrete GPUs for Red Dead Redemption 2

On APUs, we fake heaps to simulate a dGPU setup because it seems to
have the maximum compatibility. Though, some applications like RDR2
still only looks at GTT if the driver reports an iGPU which means it
will only use 1/3rd of total memory available.

This is currently behind a drirc option because it might have
implications for other apps but we might want to extend this later
if everything is fine.

Cc: 21.2 mesa-stable
Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11891>

---

 src/amd/vulkan/radv_device.c   | 15 +++++++++++++--
 src/amd/vulkan/radv_private.h  |  1 +
 src/util/00-mesa-defaults.conf |  4 ++++
 src/util/driconf.h             |  4 ++++
 4 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index 738f68db9b1..ecddf358738 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -863,6 +863,7 @@ static const driOptionDescription radv_dri_options[] = {
       DRI_CONF_RADV_INVARIANT_GEOM(false)
       DRI_CONF_RADV_DISABLE_TC_COMPAT_HTILE_GENERAL(false)
       DRI_CONF_RADV_DISABLE_DCC(false)
+      DRI_CONF_RADV_REPORT_APU_AS_DGPU(false)
    DRI_CONF_SECTION_END
 };
 // clang-format on
@@ -902,6 +903,9 @@ radv_init_dri_options(struct radv_instance *instance)
 
    if (driQueryOptionb(&instance->dri_options, "radv_disable_dcc"))
       instance->debug_flags |= RADV_DEBUG_NO_DCC;
+
+   instance->report_apu_as_dgpu =
+      driQueryOptionb(&instance->dri_options, "radv_report_apu_as_dgpu");
 }
 
 VkResult
@@ -1826,13 +1830,20 @@ radv_GetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice,
       .nonCoherentAtomSize = 64,
    };
 
+   VkPhysicalDeviceType device_type;
+
+   if (pdevice->rad_info.has_dedicated_vram || pdevice->instance->report_apu_as_dgpu) {
+      device_type = VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU;
+   } else {
+      device_type = VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU;
+   }
+
    *pProperties = (VkPhysicalDeviceProperties){
       .apiVersion = RADV_API_VERSION,
       .driverVersion = vk_get_driver_version(),
       .vendorID = ATI_VENDOR_ID,
       .deviceID = pdevice->rad_info.pci_id,
-      .deviceType = pdevice->rad_info.has_dedicated_vram ? VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU
-                                                         : VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU,
+      .deviceType = device_type,
       .limits = limits,
       .sparseProperties =
          {
diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h
index 045af48628f..b98b5cc2abd 100644
--- a/src/amd/vulkan/radv_private.h
+++ b/src/amd/vulkan/radv_private.h
@@ -333,6 +333,7 @@ struct radv_instance {
    bool disable_tc_compat_htile_in_general;
    bool disable_shrink_image_store;
    bool absolute_depth_bias;
+   bool report_apu_as_dgpu;
 };
 
 VkResult radv_init_wsi(struct radv_physical_device *physical_device);
diff --git a/src/util/00-mesa-defaults.conf b/src/util/00-mesa-defaults.conf
index c899793ec4a..a1cbe28110b 100644
--- a/src/util/00-mesa-defaults.conf
+++ b/src/util/00-mesa-defaults.conf
@@ -843,5 +843,9 @@ TODO: document the other workarounds.
         <application name="Wolfenstein II" application_name_match="Wolfenstein II The New Colossus">
             <option name="radv_disable_dcc" value="true" />
         </application>
+
+        <application name="RDR2" application_name_match="Red Dead Redemption 2">
+            <option name="radv_report_apu_as_dgpu" value="true" />
+        </application>
     </device>
 </driconf>
diff --git a/src/util/driconf.h b/src/util/driconf.h
index 44e1d5bdd8b..3a90832faff 100644
--- a/src/util/driconf.h
+++ b/src/util/driconf.h
@@ -513,4 +513,8 @@
    DRI_CONF_OPT_B(radv_disable_dcc, def, \
                   "Disable DCC for color images")
 
+#define DRI_CONF_RADV_REPORT_APU_AS_DGPU(def) \
+   DRI_CONF_OPT_B(radv_report_apu_as_dgpu, def, \
+                  "Report APUs as discrete GPUs instead of integrated GPUs")
+
 #endif



More information about the mesa-commit mailing list