mirror of
https://github.com/RPCS3/rpcs3.git
synced 2026-03-05 04:54:32 +01:00
vk: Fix shader compiler issues caused by broken preprocessor macro expansion
This commit is contained in:
parent
87677cfc85
commit
51e1ff4976
|
|
@ -553,7 +553,7 @@ void main()
|
|||
ur1 = (1u << ur1); // address mask
|
||||
uvr0.x = (ur0 >> 7u); // address to uvec4 row (each row has 32x4 bits)
|
||||
#ifdef VULKAN
|
||||
uvr0.x += fs_stipple_pattern_array_offset; // Address base offset. Only applies to vulkan.
|
||||
uvr0.x += _fs_stipple_pattern_array_offset; // Address base offset. Only applies to vulkan.
|
||||
#endif
|
||||
ur0 = (ur0 >> 5u) & 3u; // address to uvec4 word (address / 32) % 4
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ R"(
|
|||
const uint bit_offset = (address & 31u);
|
||||
#ifdef VULKAN
|
||||
// In vulkan we have a unified array with a dynamic offset
|
||||
const uint word_index = _get_bits(address, 7, 3) + fs_stipple_pattern_array_offset;
|
||||
const uint word_index = _get_bits(address, 7, 3) + _fs_stipple_pattern_array_offset;
|
||||
#else
|
||||
const uint word_index = _get_bits(address, 7, 3);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -251,11 +251,12 @@ void VKFragmentDecompilerThread::insertConstants(std::stringstream & OS)
|
|||
" draw_parameters_t draw_parameters[];\n"
|
||||
"};\n\n"
|
||||
|
||||
"#define get_draw_params() draw_parameters[draw_parameters_offset]\n"
|
||||
"#define fs_constants_offset get_draw_params().fs_constants_offset\n"
|
||||
"#define fs_context_offset get_draw_params().fs_context_offset\n"
|
||||
"#define fs_texture_base_index get_draw_params().fs_texture_base_index\n"
|
||||
"#define fs_stipple_pattern_array_offset get_draw_params().fs_stipple_pattern_offset\n\n";
|
||||
"draw_parameters_t get_draw_params() { return draw_parameters[draw_parameters_offset]; }\n\n"
|
||||
|
||||
"#define _fs_constants_offset get_draw_params().fs_constants_offset\n"
|
||||
"#define _fs_context_offset get_draw_params().fs_context_offset\n"
|
||||
"#define _fs_texture_base_index get_draw_params().fs_texture_base_index\n"
|
||||
"#define _fs_stipple_pattern_array_offset get_draw_params().fs_stipple_pattern_offset\n\n";
|
||||
|
||||
if (!properties.constant_offsets.empty())
|
||||
{
|
||||
|
|
@ -263,7 +264,7 @@ void VKFragmentDecompilerThread::insertConstants(std::stringstream & OS)
|
|||
OS << "{\n";
|
||||
OS << " vec4 fc[];\n";
|
||||
OS << "};\n";
|
||||
OS << "#define _fetch_constant(x) fc[x + fs_constants_offset]\n\n";
|
||||
OS << "#define _fetch_constant(x) fc[x + _fs_constants_offset]\n\n";
|
||||
}
|
||||
|
||||
OS <<
|
||||
|
|
@ -341,19 +342,20 @@ void VKFragmentDecompilerThread::insertGlobalFunctions(std::stringstream &OS)
|
|||
if (m_shader_props.require_fog_read)
|
||||
{
|
||||
OS <<
|
||||
"#define fog_param0 fs_contexts[fs_context_offset].fog_param0\n"
|
||||
"#define fog_param1 fs_contexts[fs_context_offset].fog_param1\n"
|
||||
"#define fog_mode fs_contexts[fs_context_offset].fog_mode\n\n";
|
||||
"#define fog_param0 fs_contexts[_fs_context_offset].fog_param0\n"
|
||||
"#define fog_param1 fs_contexts[_fs_context_offset].fog_param1\n"
|
||||
"#define fog_mode fs_contexts[_fs_context_offset].fog_mode\n\n";
|
||||
}
|
||||
|
||||
if (m_shader_props.require_wpos)
|
||||
{
|
||||
OS <<
|
||||
"#define wpos_scale fs_contexts[fs_context_offset].wpos_scale\n"
|
||||
"#define wpos_bias fs_contexts[fs_context_offset].wpos_bias\n\n";
|
||||
"#define wpos_scale fs_contexts[_fs_context_offset].wpos_scale\n"
|
||||
"#define wpos_bias fs_contexts[_fs_context_offset].wpos_bias\n\n";
|
||||
}
|
||||
|
||||
OS << "#define texture_base_index fs_texture_base_index\n\n";
|
||||
OS <<
|
||||
"#define texture_base_index _fs_texture_base_index\n\n";
|
||||
|
||||
glsl::insert_glsl_legacy_function(OS, m_shader_props);
|
||||
}
|
||||
|
|
@ -448,9 +450,10 @@ void VKFragmentDecompilerThread::insertMainEnd(std::stringstream & OS)
|
|||
OS << "void main()\n";
|
||||
OS << "{\n";
|
||||
|
||||
// FIXME: Workaround
|
||||
OS <<
|
||||
" const uint rop_control = fs_contexts[fs_context_offset].rop_control;\n"
|
||||
" const float alpha_ref = fs_contexts[fs_context_offset].alpha_ref;\n\n";
|
||||
" const uint rop_control = fs_contexts[_fs_context_offset].rop_control;\n"
|
||||
" const float alpha_ref = fs_contexts[_fs_context_offset].alpha_ref;\n\n";
|
||||
|
||||
::glsl::insert_rop_init(OS);
|
||||
|
||||
|
|
|
|||
|
|
@ -178,11 +178,11 @@ namespace vk
|
|||
comp.insertConstants(builder);
|
||||
|
||||
builder <<
|
||||
"#define fog_param0 fs_contexts[fs_context_offset].fog_param0\n"
|
||||
"#define fog_param1 fs_contexts[fs_context_offset].fog_param1\n"
|
||||
"#define fog_mode fs_contexts[fs_context_offset].fog_mode\n"
|
||||
"#define wpos_scale fs_contexts[fs_context_offset].wpos_scale\n"
|
||||
"#define wpos_bias fs_contexts[fs_context_offset].wpos_bias\n\n";
|
||||
"#define fog_param0 fs_contexts[_fs_context_offset].fog_param0\n"
|
||||
"#define fog_param1 fs_contexts[_fs_context_offset].fog_param1\n"
|
||||
"#define fog_mode fs_contexts[_fs_context_offset].fog_mode\n"
|
||||
"#define wpos_scale fs_contexts[_fs_context_offset].wpos_scale\n"
|
||||
"#define wpos_bias fs_contexts[_fs_context_offset].wpos_bias\n\n";
|
||||
|
||||
if (compiler_options & program_common::interpreter::COMPILER_OPT_ENABLE_ALPHA_TEST_GE)
|
||||
{
|
||||
|
|
@ -260,7 +260,7 @@ namespace vk
|
|||
"#define SAMPLER2D(index) sampler2D_array[index]\n"
|
||||
"#define SAMPLER3D(index) sampler3D_array[index]\n"
|
||||
"#define SAMPLERCUBE(index) samplerCube_array[index]\n"
|
||||
"#define texture_base_index fs_texture_base_index\n\n";
|
||||
"#define texture_base_index _fs_texture_base_index\n\n";
|
||||
}
|
||||
|
||||
builder <<
|
||||
|
|
@ -273,6 +273,10 @@ namespace vk
|
|||
" uvec4 fp_instructions[];\n"
|
||||
"};\n\n";
|
||||
|
||||
builder <<
|
||||
" uint rop_control = fs_contexts[_fs_context_offset].rop_control;\n"
|
||||
" float alpha_ref = fs_contexts[_fs_context_offset].alpha_ref;\n\n";
|
||||
|
||||
builder << program_common::interpreter::get_fragment_interpreter();
|
||||
const std::string s = builder.str();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue