rsx: Do not use VTC tiling on NPOT textures

- Seems to be ignored for 'normal' textures. Mostly verified through games.
This commit is contained in:
kd-11 2021-07-31 02:50:22 +03:00 committed by kd-11
parent 8af694da2e
commit 0ec526c5f1
2 changed files with 15 additions and 2 deletions

View file

@ -689,7 +689,10 @@ namespace rsx
case CELL_GCM_TEXTURE_COMPRESSED_DXT1:
{
if (depth > 1 && !caps.supports_vtc_decoding)
if (depth > 1 &&
utils::is_power_of_2(src_layout.width_in_texel) &&
utils::is_power_of_2(src_layout.height_in_texel) &&
!caps.supports_vtc_decoding)
{
// PS3 uses the Nvidia VTC memory layout for compressed 3D textures.
// This is only supported using Nvidia OpenGL.
@ -711,7 +714,10 @@ namespace rsx
case CELL_GCM_TEXTURE_COMPRESSED_DXT23:
case CELL_GCM_TEXTURE_COMPRESSED_DXT45:
{
if (depth > 1 && !caps.supports_vtc_decoding)
if (depth > 1 &&
utils::is_power_of_2(src_layout.width_in_texel) &&
utils::is_power_of_2(src_layout.height_in_texel) &&
!caps.supports_vtc_decoding)
{
// PS3 uses the Nvidia VTC memory layout for compressed 3D textures.
// This is only supported using Nvidia OpenGL.

View file

@ -385,6 +385,13 @@ namespace utils
return static_cast<T>(value / align + (value > 0 ? T{(value % align) > (align / 2)} : 0 - T{(value % align) < (align / 2)}));
}
// Returns true if input is an unsigned integer with a power of 2
template <typename T> requires(std::is_integral_v<T> && std::is_unsigned_v<T>)
constexpr T is_power_of_2(T value)
{
return !(value & (value - 1));
}
// Hack. Pointer cast util to workaround UB. Use with extreme care.
template <typename T, typename U>
[[nodiscard]] T* bless(U* ptr)