isl: don't assert(num_elements > (1ull << 27))

Some games such as Marvel's Spider-Man Remastered and Assassin's
Creed: Valhalla don't work in debug mode because they hit this
assertion. In Release mode, they appear to work (although in some
platforms there may be visual corruption or GPU hangs). There's
nothing we can do about this error (see below), so in this patch we
replace the assertion with an error message, because it allows us to
(i) test the rest of the game in debug mode so we may catch other
issues; and (ii) warn users of release mode that the issue is
happening.

The unsupported num_elements comes from vkGetDescriptorEXT() and
appears to be violating VUID-VkDescriptorGetInfoEXT-type-09427. This
function cannot return errors, but we can disable
VK_EXT_descriptor_buffer.

If we do disable the extension, then vkCreateBufferView() will start
triggering the assertion, and we can see that
VkBufferViewCreateInfo-range-00930 is being violated. If we change Anv
to return errors on these vkCreateBufferView() cases, then the games
won't work at all.

I reported this to vkd3d-proton, but according to the vkd3d-proton
developer Philip Rebohle:

 "There's also the problematic case of games using typed descriptors
  but passing non-typed buffer descriptors, which is an extremely
  common app bug that works on all D3D12 drivers that we need to work
  around by creating typed views. If that's what's happening here then
  the best we can do is to just not create the typed view and have the
  game be broken entirely, or create a smaller view and most likely
  still completely break the game, but at least that way it wouldn't
  trigger Vulkan validation. Emulating larger views via multiple
  smaller views is not possible for us."

 "Confirmed that it's the app itself creating these views."

 "D3D12 does not have runtime validation for this or any sort of query
  for the app, so we really can't do much here."

Link: https://gitlab.freedesktop.org/mesa/mesa/-/issues/9963
Link: https://github.com/HansKristian-Work/vkd3d-proton/issues/2071
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30775>
This commit is contained in:
Paulo Zanoni 2024-08-20 16:28:00 -07:00 committed by Marge Bot
parent b78a691ce2
commit f3c7e14f09

View file

@ -22,6 +22,7 @@
*/
#include <stdint.h>
#include <inttypes.h>
#define __gen_address_type uint64_t
#define __gen_user_data void
@ -36,6 +37,7 @@ __gen_combine_address(__attribute__((unused)) void *data,
#include "genxml/gen_macros.h"
#include "genxml/genX_pack.h"
#include "util/log.h"
#include "isl_priv.h"
#include "isl_genX_helpers.h"
@ -973,8 +975,25 @@ isl_genX(buffer_fill_state_s)(const struct isl_device *dev, void *state,
*
* For typed buffer and structured buffer surfaces, the number
* of entries in the buffer ranges from 1 to 2^27.
*
* We could assert(num_elements <= (1 << 27)) here, but some DX12 games
* misbehave and there's nothing either vkd3d or Anv can do about it.
* Therefore we just allow those cases to happen in order to avoid
* crashing or further breaking the applications.
*
* Applications causing this issue generally ignore
* PhysicalDevice::maxTexelBufferElements, leading them to disrespect
* restrictions such as:
* VUID-VkDescriptorGetInfoEXT-type-09427
* VUID-VkDescriptorGetInfoEXT-type-09428
* VUID-VkBufferViewCreateInfo-range-00930
* VUID-VkBufferViewCreateInfo-range-04059
*/
assert(num_elements <= (1ull << 27));
if (num_elements > (1 << 27)) {
mesa_logw("%s: num_elements is too big: %u (buffer size: %"PRIu64")\n",
__func__, num_elements, buffer_size);
num_elements = 1 << 27;
}
}
struct GENX(RENDER_SURFACE_STATE) s = { 0, };