From f826bd6ac08a59b48e7ac59a904ad3bb3d5a9559 Mon Sep 17 00:00:00 2001 From: Hans-Kristian Arntzen Date: Mon, 27 Jan 2025 17:35:15 +0100 Subject: [PATCH] vkd3d-shader: Add Rebirth quirk for mesh output robustness. Signed-off-by: Hans-Kristian Arntzen --- include/vkd3d_shader.h | 3 +++ libs/vkd3d-shader/dxil.c | 14 ++++++++++++++ libs/vkd3d/device.c | 7 +++++++ 3 files changed, 24 insertions(+) diff --git a/include/vkd3d_shader.h b/include/vkd3d_shader.h index 081406d3be..a4b10addbb 100644 --- a/include/vkd3d_shader.h +++ b/include/vkd3d_shader.h @@ -473,6 +473,9 @@ enum vkd3d_shader_quirk * This can lead to page faults. Clamps the input index to the private array size * as the simplest possible workaround. */ VKD3D_SHADER_QUIRK_FORCE_ROBUST_PHYSICAL_CBV_LOAD_FORWARDING = (1 << 23), + + /* If SetMeshOutputsEXT will be called out of bounds, exit the meshlet instead. */ + VKD3D_SHADER_QUIRK_MESH_OUTPUT_ROBUSTNESS = (1 << 24), }; struct vkd3d_shader_quirk_hash diff --git a/libs/vkd3d-shader/dxil.c b/libs/vkd3d-shader/dxil.c index 35b0a8b014..2cb2735136 100644 --- a/libs/vkd3d-shader/dxil.c +++ b/libs/vkd3d-shader/dxil.c @@ -1147,6 +1147,20 @@ int vkd3d_shader_compile_dxil(const struct vkd3d_shader_code *dxbc, } } + if (quirks & VKD3D_SHADER_QUIRK_MESH_OUTPUT_ROBUSTNESS) + { + const dxil_spv_option_shader_quirk helper = + { { DXIL_SPV_OPTION_SHADER_QUIRK }, + DXIL_SPV_SHADER_QUIRK_MESH_OUTPUTS_ROBUSTNESS }; + + if (dxil_spv_converter_add_option(converter, &helper.base) != DXIL_SPV_SUCCESS) + { + ERR("dxil-spirv does not support SHADER_QUIRK.\n"); + ret = VKD3D_ERROR_NOT_IMPLEMENTED; + goto end; + } + } + remap_userdata.shader_interface_info = shader_interface_info; remap_userdata.shader_interface_local_info = NULL; remap_userdata.num_root_descriptors = num_root_descriptors; diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c index c1379801ab..b6b4b2b498 100644 --- a/libs/vkd3d/device.c +++ b/libs/vkd3d/device.c @@ -765,6 +765,11 @@ static const struct vkd3d_shader_quirk_info gzw_quirks = { NULL, 0, VKD3D_SHADER_QUIRK_FORCE_ROBUST_PHYSICAL_CBV_LOAD_FORWARDING, }; +/* Apparently some meshlets may try to allocate too many vertices/primitives. */ +static const struct vkd3d_shader_quirk_info rebirth_quirks = { + NULL, 0, VKD3D_SHADER_QUIRK_MESH_OUTPUT_ROBUSTNESS, +}; + static const struct vkd3d_shader_quirk_meta application_shader_quirks[] = { /* F1 2020 (1080110) */ { VKD3D_STRING_COMPARE_EXACT, "F1_2020_dx12.exe", &f1_2019_2020_quirks }, @@ -799,6 +804,8 @@ static const struct vkd3d_shader_quirk_meta application_shader_quirks[] = { { VKD3D_STRING_COMPARE_EXACT, "M1-Win64-Shipping.exe", &tfd_quirks }, /* Gray Zone Warfare (2479810) */ { VKD3D_STRING_COMPARE_EXACT, "GZWClientSteam-Win64-Shipping.exe", &gzw_quirks }, + /* FFVII Rebirth (2909400) */ + { VKD3D_STRING_COMPARE_EXACT, "ff7rebirth_.exe", &rebirth_quirks }, /* Unreal Engine 4 */ { VKD3D_STRING_COMPARE_ENDS_WITH, "-Shipping.exe", &ue4_quirks }, /* MSVC fails to compile empty array. */