Module: Mesa Branch: staging/20.1 Commit: 304755ad1f3a4d50c4c318ec4c6cd59d6effce8d URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=304755ad1f3a4d50c4c318ec4c6cd59d6effce8d
Author: Bas Nieuwenhuizen <[email protected]> Date: Thu Jul 30 02:49:33 2020 +0200 radv: Override the uniform buffer offset alignment for World War Z. Game does the equivalent of a ALIGN(..., minUniformBufferOffsetAlignment >> 4) which breaks when said alignment is <16 with a SIGFPE. CC: <[email protected]> Reviewed-by: Samuel Pitoiset <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6120> (cherry picked from commit 0067f8992002b44bf75f98fae43886c5a6227075) --- .pick_status.json | 2 +- src/amd/vulkan/radv_device.c | 18 +++++++++++++++++- src/util/00-mesa-defaults.conf | 4 ++++ src/util/xmlpool/t_options.h | 5 +++++ 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 01ba42ddca7..adc9aef6e06 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -94,7 +94,7 @@ "description": "radv: Override the uniform buffer offset alignment for World War Z.", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "master_sha": null, "because_sha": null }, diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c index c01811e3e31..90f810d40f0 100644 --- a/src/amd/vulkan/radv_device.c +++ b/src/amd/vulkan/radv_device.c @@ -582,6 +582,7 @@ DRI_CONF_BEGIN DRI_CONF_VK_X11_STRICT_IMAGE_COUNT("false") DRI_CONF_VK_X11_ENSURE_MIN_IMAGE_COUNT("false") DRI_CONF_RADV_NO_DYNAMIC_BOUNDS("false") + DRI_CONF_RADV_OVERRIDE_UNIFORM_OFFSET_ALIGNMENT(0) DRI_CONF_SECTION_END DRI_CONF_SECTION_DEBUG @@ -1318,6 +1319,21 @@ radv_max_descriptor_set_size() 64 /* storage image */); } +static uint32_t +radv_uniform_buffer_offset_alignment(const struct radv_physical_device *pdevice) +{ + uint32_t uniform_offset_alignment = driQueryOptioni(&pdevice->instance->dri_options, + "radv_override_uniform_offset_alignment"); + if (!util_is_power_of_two_or_zero(uniform_offset_alignment)) { + fprintf(stderr, "ERROR: invalid radv_override_uniform_offset_alignment setting %d:" + "not a power of two\n", uniform_offset_alignment); + uniform_offset_alignment = 0; + } + + /* Take at least the hardware limit. */ + return MAX2(uniform_offset_alignment, 4); +} + void radv_GetPhysicalDeviceProperties( VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties* pProperties) @@ -1400,7 +1416,7 @@ void radv_GetPhysicalDeviceProperties( .viewportSubPixelBits = 8, .minMemoryMapAlignment = 4096, /* A page */ .minTexelBufferOffsetAlignment = 4, - .minUniformBufferOffsetAlignment = 4, + .minUniformBufferOffsetAlignment = radv_uniform_buffer_offset_alignment(pdevice), .minStorageBufferOffsetAlignment = 4, .minTexelOffset = -32, .maxTexelOffset = 31, diff --git a/src/util/00-mesa-defaults.conf b/src/util/00-mesa-defaults.conf index 068d782cbfc..68c6b7425e9 100644 --- a/src/util/00-mesa-defaults.conf +++ b/src/util/00-mesa-defaults.conf @@ -687,5 +687,9 @@ TODO: document the other workarounds. <application name="Path of Exile (32-bit)" executable="PathOfExile.exe"> <option name="radv_no_dynamic_bounds" value="true" /> </application> + + <application name="World War Z" application_name_match="WWZ"> + <option name="radv_override_uniform_offset_alignment" value="16" /> + </application> </device> </driconf> diff --git a/src/util/xmlpool/t_options.h b/src/util/xmlpool/t_options.h index e7462faec08..302c7bd089c 100644 --- a/src/util/xmlpool/t_options.h +++ b/src/util/xmlpool/t_options.h @@ -435,3 +435,8 @@ DRI_CONF_OPT_END DRI_CONF_OPT_BEGIN_B(radv_no_dynamic_bounds, def) \ DRI_CONF_DESC(en,gettext("Disabling bounds checking for dynamic buffer descriptors")) \ DRI_CONF_OPT_END + +#define DRI_CONF_RADV_OVERRIDE_UNIFORM_OFFSET_ALIGNMENT(def) \ +DRI_CONF_OPT_BEGIN_V(radv_override_uniform_offset_alignment, int, def, "0:128") \ + DRI_CONF_DESC(en, gettext("Override the minUniformBufferOffsetAlignment exposed to the application. (0 = default)")) \ +DRI_CONF_OPT_END _______________________________________________ mesa-commit mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-commit
