Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force precise vertex shaders in Hunt: Showdown #2171

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion include/vkd3d_shader.h
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,11 @@ enum vkd3d_shader_quirk
VKD3D_SHADER_QUIRK_FORCE_GRAPHICS_BARRIER = (1 << 18),

/* VK_PIPELINE_CREATE_DISABLE_OPTIMIZATIONS. For driver workarounds where optimizations break stuff. */
VKD3D_SHADER_QUIRK_DISABLE_OPTIMIZATIONS = (1 << 19)
VKD3D_SHADER_QUIRK_DISABLE_OPTIMIZATIONS = (1 << 19),

/* Forces NoContract on every expression that can take it (only applies to VS).
* Useful as a global quirk when games are shipping broken code. */
VKD3D_SHADER_QUIRK_FORCE_NOCONTRACT_MATH_VS = (1 << 20)
};

struct vkd3d_shader_quirk_hash
Expand Down
8 changes: 7 additions & 1 deletion libs/vkd3d-shader/dxil.c
Original file line number Diff line number Diff line change
Expand Up @@ -796,10 +796,16 @@ int vkd3d_shader_compile_dxil(const struct vkd3d_shader_code *dxbc,
}

{
bool force_nocontract =
(quirks & VKD3D_SHADER_QUIRK_FORCE_NOCONTRACT_MATH) ||
((quirks & VKD3D_SHADER_QUIRK_FORCE_NOCONTRACT_MATH_VS) &&
shader_interface_info->stage == VK_SHADER_STAGE_VERTEX_BIT);

const struct dxil_spv_option_precise_control helper =
{ { DXIL_SPV_OPTION_PRECISE_CONTROL },
(quirks & VKD3D_SHADER_QUIRK_FORCE_NOCONTRACT_MATH) ? DXIL_SPV_TRUE : DXIL_SPV_FALSE,
force_nocontract ? DXIL_SPV_TRUE : DXIL_SPV_FALSE,
DXIL_SPV_FALSE };

if (dxil_spv_converter_add_option(converter, &helper.base) != DXIL_SPV_SUCCESS)
{
WARN("dxil-spirv does not support PRECISE_CONTROL.\n");
Expand Down
6 changes: 6 additions & 0 deletions libs/vkd3d-shader/spirv.c
Original file line number Diff line number Diff line change
Expand Up @@ -2424,6 +2424,12 @@ struct vkd3d_dxbc_compiler *vkd3d_dxbc_compiler_create(const struct vkd3d_shader

compiler->shader_version = *shader_version;
compiler->quirks = vkd3d_shader_compile_arguments_select_quirks(compile_args, shader_hash);

/* Easier to normalize the quirk here than refactor all the checks. */
if ((compiler->quirks & VKD3D_SHADER_QUIRK_FORCE_NOCONTRACT_MATH_VS) &&
shader_interface->stage == VK_SHADER_STAGE_VERTEX_BIT)
compiler->quirks |= VKD3D_SHADER_QUIRK_FORCE_NOCONTRACT_MATH;

#ifdef VKD3D_ENABLE_DESCRIPTOR_QA
compiler->descriptor_qa_shader_hash = shader_hash;
#endif
Expand Down
7 changes: 7 additions & 0 deletions libs/vkd3d/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,11 @@ static const struct vkd3d_shader_quirk_info ffxvi_quirks = {
ffxvi_hashes, ARRAY_SIZE(ffxvi_hashes),
};

/* Some shaders use precise, some don't, leading to invariance issues. */
static const struct vkd3d_shader_quirk_info hunt_quirks = {
NULL, 0, VKD3D_SHADER_QUIRK_FORCE_NOCONTRACT_MATH_VS,
};

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 },
Expand All @@ -766,6 +771,8 @@ static const struct vkd3d_shader_quirk_meta application_shader_quirks[] = {
{ VKD3D_STRING_COMPARE_EXACT, "ACMirage_plus.exe", &ac_mirage_quirks },
/* FF XVI. */
{ VKD3D_STRING_COMPARE_STARTS_WITH, "ffxvi", &ffxvi_quirks },
/* Hunt: Showdown 1896 (594650) */
{ VKD3D_STRING_COMPARE_EXACT, "HuntGame.exe", &hunt_quirks },
/* Unreal Engine 4 */
{ VKD3D_STRING_COMPARE_ENDS_WITH, "-Shipping.exe", &ue4_quirks },
/* MSVC fails to compile empty array. */
Expand Down