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

Author: Felix DeGrood <[email protected]>
Date:   Mon May 15 22:44:45 2023 +0000

anv: override vendorID for Cyberpunk 2077

A recent update to Cyberpunk 2077 enables XeSS code for Intel GPUs
which is causing the game to crash in the XeSS libraries.  As a
temporary work around, stop identifying as Intel for Cyberpunk so
XeSS falls back to the cross-vendor path.

References: https://gitlab.freedesktop.org/mesa/mesa/-/issues/8860
Reviewed-by: Kenneth Graunke <[email protected]>
Reviewed-by: Lionel Landwerlin <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23271>

---

 src/intel/vulkan/anv_device.c  | 5 +++++
 src/intel/vulkan/anv_private.h | 1 +
 src/util/00-mesa-defaults.conf | 3 +++
 src/util/driconf.h             | 3 +++
 4 files changed, 12 insertions(+)

diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index 44a591531c0..da9e05b9ced 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -85,6 +85,7 @@ static const driOptionDescription anv_dri_options[] = {
       DRI_CONF_VK_WSI_FORCE_BGRA8_UNORM_FIRST(false)
       DRI_CONF_LIMIT_TRIG_INPUT_RANGE(false)
       DRI_CONF_ANV_MESH_CONV_PRIM_ATTRS_TO_VERT_ATTRS(-2)
+      DRI_CONF_FORCE_VK_VENDOR(0)
    DRI_CONF_SECTION_END
 
    DRI_CONF_SECTION_QUALITY
@@ -1500,6 +1501,8 @@ anv_init_dri_options(struct anv_instance *instance)
             driQueryOptioni(&instance->dri_options, 
"generated_indirect_threshold");
     instance->query_clear_with_blorp_threshold =
        driQueryOptioni(&instance->dri_options, 
"query_clear_with_blorp_threshold");
+    instance->force_vk_vendor =
+       driQueryOptioni(&instance->dri_options, "force_vk_vendor");
 }
 
 VkResult anv_CreateInstance(
@@ -1749,6 +1752,8 @@ void anv_GetPhysicalDeviceProperties(
       .sparseProperties = {0}, /* Broadwell doesn't do sparse. */
    };
 
+   if (unlikely(pdevice->instance->force_vk_vendor))
+      pProperties->vendorID = pdevice->instance->force_vk_vendor;
    snprintf(pProperties->deviceName, sizeof(pProperties->deviceName),
             "%s", pdevice->info.name);
    memcpy(pProperties->pipelineCacheUUID,
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 8c4099e3b7b..b6401c44782 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -1037,6 +1037,7 @@ struct anv_instance {
     float                                       lower_depth_range_rate;
     unsigned                                    generated_indirect_threshold;
     unsigned                                    
query_clear_with_blorp_threshold;
+    unsigned                                    force_vk_vendor;
 
     /* HW workarounds */
     bool                                        no_16bit;
diff --git a/src/util/00-mesa-defaults.conf b/src/util/00-mesa-defaults.conf
index b5f8b233a7d..a58831bc304 100644
--- a/src/util/00-mesa-defaults.conf
+++ b/src/util/00-mesa-defaults.conf
@@ -1056,6 +1056,9 @@ TODO: document the other workarounds.
         <application name="NieR:Automata" executable="NieRAutomata.exe">
             <option name="limit_trig_input_range" value="true" />
         </application>
+        <application name="Cyberpunk 2077" executable="Cyberpunk2077.exe">
+            <option name="force_vk_vendor" value="-1" />
+        </application>
         <!--
         Disable 16-bit feature on zink and angle so that GLES mediump doesn't
         lower to our inefficent 16-bit shader support.  No need to do so for
diff --git a/src/util/driconf.h b/src/util/driconf.h
index ac51622830d..108cc017c43 100644
--- a/src/util/driconf.h
+++ b/src/util/driconf.h
@@ -310,6 +310,9 @@
    DRI_CONF_OPT_B(ignore_discard_framebuffer, def, \
                   "Ignore glDiscardFramebuffer/glInvalidateFramebuffer, 
workaround for games that use it incorrectly")
 
+#define DRI_CONF_FORCE_VK_VENDOR(def) \
+   DRI_CONF_OPT_I(force_vk_vendor, 0, -1, 2147483647, "Override GPU vendor id")
+
 /**
  * \brief Image quality-related options
  */

Reply via email to