mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-25 20:22:30 +01:00
vk: Simplify shadow comparison operations for non-integer formats
- Just use hardware PCF, it makes everyone's life easier.
This commit is contained in:
parent
1d04f14a53
commit
da6760ed98
@ -634,11 +634,6 @@ namespace glsl
|
||||
|
||||
program_common::insert_compare_op(OS, props.low_precision_tests);
|
||||
|
||||
if (props.require_shadow_ops && props.emulate_shadow_compare)
|
||||
{
|
||||
program_common::insert_compare_op_vector(OS);
|
||||
}
|
||||
|
||||
if (props.emulate_coverage_tests)
|
||||
{
|
||||
// Purely stochastic
|
||||
@ -726,26 +721,6 @@ namespace glsl
|
||||
|
||||
if (props.require_texture_ops)
|
||||
{
|
||||
if (props.require_shadow_ops && props.emulate_shadow_compare)
|
||||
{
|
||||
OS <<
|
||||
"vec4 shadowCompare(sampler2D tex, const in vec3 p, const in uint func)\n"
|
||||
"{\n"
|
||||
" vec4 samples = textureGather(tex, p.xy, 0);\n"
|
||||
" float advance_x = dFdx(p).z;\n"
|
||||
" float advance_y = -dFdy(p).z;\n"
|
||||
" vec4 off = vec4(advance_y, (advance_x + advance_y), advance_x, 0.);\n"
|
||||
" vec4 ref = clamp(off + p.z, 0., 1.);\n"
|
||||
" vec4 filtered = vec4(comparison_passes(samples, ref, func));\n"
|
||||
" return dot(filtered, vec4(0.25f)).xxxx;\n"
|
||||
"}\n\n"
|
||||
|
||||
"vec4 shadowCompareProj(sampler2D tex, const in vec4 p, const in uint func)\n"
|
||||
"{\n"
|
||||
" return shadowCompare(tex, p.xyz / p.w, func);\n"
|
||||
"}\n\n";
|
||||
}
|
||||
|
||||
OS <<
|
||||
|
||||
#ifdef __APPLE__
|
||||
@ -855,8 +830,8 @@ namespace glsl
|
||||
if (props.emulate_shadow_compare)
|
||||
{
|
||||
OS <<
|
||||
"#define TEX2D_SHADOW(index, coord3) shadowCompare(TEX_NAME(index), coord3 * vec3(texture_parameters[index].scale, 1.), texture_parameters[index].flags >> 8)\n"
|
||||
"#define TEX2D_SHADOWPROJ(index, coord4) shadowCompareProj(TEX_NAME(index), coord4 * vec4(texture_parameters[index].scale, 1., 1.), texture_parameters[index].flags >> 8)\n";
|
||||
"#define TEX2D_SHADOW(index, coord3) texture(TEX_NAME(index), vec3(coord3.xy * texture_parameters[index].scale, min(coord3.z, 1.)))\n"
|
||||
"#define TEX2D_SHADOWPROJ(index, coord4) textureProj(TEX_NAME(index), vec4(coord4.xy * texture_parameters[index].scale, min(coord4.z, coord4.w), coord4.w))\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -184,21 +184,9 @@ void VKGSRender::load_texture_env()
|
||||
|
||||
if (texture_format >= CELL_GCM_TEXTURE_DEPTH24_D8 && texture_format <= CELL_GCM_TEXTURE_DEPTH16_FLOAT)
|
||||
{
|
||||
if (m_device->get_formats_support().d24_unorm_s8)
|
||||
{
|
||||
// NOTE:
|
||||
// The nvidia-specific format D24S8 has a special way of doing depth comparison that matches the PS3
|
||||
// In case of projected shadow lookup the result of the divide operation has its Z clamped to [0-1] before comparison
|
||||
// Most other wide formats (Z bits > 16) do not behave this way and depth greater than 1 is possible due to the use of floating point as storage
|
||||
// Compare operations for these formats (such as D32_SFLOAT) are therefore emulated for correct results
|
||||
|
||||
// NOTE2:
|
||||
// To improve reusability, DEPTH16 shadow ops are also emulated if D24S8 support is not available
|
||||
|
||||
compare_enabled = VK_TRUE;
|
||||
depth_compare_mode = vk::get_compare_func(rsx::method_registers.fragment_textures[i].zfunc(), true);
|
||||
}
|
||||
}
|
||||
|
||||
const int aniso_override_level = g_cfg.video.anisotropic_level_override;
|
||||
const bool aniso_override = !g_cfg.video.strict_rendering_mode && aniso_override_level > 0;
|
||||
|
@ -130,7 +130,7 @@ void VKFragmentDecompilerThread::insertConstants(std::stringstream & OS)
|
||||
|
||||
const auto mask = (1 << index);
|
||||
|
||||
if (!device_props.emulate_depth_compare && m_prog.shadow_textures & mask)
|
||||
if (m_prog.shadow_textures & mask)
|
||||
{
|
||||
if (m_shadow_sampled_textures & mask)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user