Skip to content

Commit

Permalink
rsx: Fix depth/color mismatch resolve in texture cache
Browse files Browse the repository at this point in the history
- Sometimes we need a depth texture but only a color texture is available.
  • Loading branch information
kd-11 committed Jun 6, 2021
1 parent 3f80d0b commit ddbe496
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion rpcs3/Emu/RSX/Common/texture_cache_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -529,12 +529,19 @@ namespace rsx
if (const bool gcm_format_is_depth = is_gcm_depth_format(attr2.gcm_format);
gcm_format_is_depth != is_depth)
{
if (force_convert)
if (force_convert || gcm_format_is_depth)
{
// If force_convert is set, we already know there is no simple workaround. Bitcast will be forced to resolve the issue.
// If the existing texture is a color texture but depth readout is requested, force bitcast
// Note that if only reading the depth value was needed from a depth surface, it would have been sampled as color due to Z comparison.
is_depth = gcm_format_is_depth;
force_convert = true;
}
else
{
// Existing texture is a depth texture, but RSX wants a color texture.
// Change the RSX request to a compatible depth texture to give same results in shader.
ensure(is_depth);
attr2.gcm_format = get_compatible_depth_format(attr2.gcm_format);
}

Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/RSX/VK/VKTextureCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,7 @@ namespace vk
case CELL_GCM_TEXTURE_X16:
case CELL_GCM_TEXTURE_DEPTH16:
case CELL_GCM_TEXTURE_DEPTH16_FLOAT:
return (vk_format == VK_FORMAT_D16_UNORM);
return (vk_format == VK_FORMAT_D16_UNORM || vk_format == VK_FORMAT_D32_SFLOAT);
}
}

Expand Down

0 comments on commit ddbe496

Please sign in to comment.