GS/HW: Use CreateCompatible() in texture cache to propagate correct formats.

Co-authored-by: TellowKrinkle
This commit is contained in:
TJnotJT
2026-06-21 00:54:19 -05:00
committed by Ty
parent 896e0b82c2
commit c7042e1877
2 changed files with 7 additions and 7 deletions
+3 -3
View File
@@ -1135,9 +1135,9 @@ bool GSHwHack::OI_SonicUnleashed(GSRendererHW& r, GSTexture* rt, GSTexture* ds,
rt_again->m_valid.y /= 2;
rt_again->m_valid.w /= 2;
rt_again->m_TEX0.PSM = PSMCT32;
GSTexture* tex = g_gs_device->CreateRenderTarget(
rt_again->m_unscaled_size.x * rt_again->m_scale, rt_again->m_unscaled_size.y * rt_again->m_scale,
GSTexture::Format::Color, false);
GSTexture* tex = g_gs_device->CreateCompatible(rt_again->m_texture,
static_cast<int>(rt_again->m_unscaled_size.x * rt_again->m_scale),
static_cast<int>(rt_again->m_unscaled_size.y * rt_again->m_scale), false);
if (!tex)
return false;
+4 -4
View File
@@ -4142,7 +4142,7 @@ void GSTextureCache::Target::ScaleRTAlpha()
const GSVector4i valid_rect = GSVector4i(GSVector4(m_valid) * GSVector4(m_scale));
GL_PUSH("TC: ScaleRTAlpha(valid=(%dx%d %d,%d=>%d,%d))", m_valid.width(), m_valid.height(), m_valid.x, m_valid.y, m_valid.z, m_valid.w);
if (GSTexture* temp_rt = g_gs_device->CreateRenderTarget(rtsize, GSTexture::Format::Color, !GSVector4i::loadh(rtsize).eq(valid_rect)))
if (GSTexture* temp_rt = g_gs_device->CreateCompatible(m_texture, rtsize, !GSVector4i::loadh(rtsize).eq(valid_rect)))
{
// Only copy up the valid area, since there's no point in "correcting" nothing.
const GSVector4 dRect(m_texture->GetRect().rintersect(valid_rect));
@@ -4167,7 +4167,7 @@ void GSTextureCache::Target::UnscaleRTAlpha()
const GSVector4i valid_rect = GSVector4i(GSVector4(m_valid) * GSVector4(m_scale));
GL_PUSH("TC: UnscaleRTAlpha(valid=(%dx%d %d,%d=>%d,%d))", valid_rect.width(), valid_rect.height(), valid_rect.x, valid_rect.y, valid_rect.z, valid_rect.w);
if (GSTexture* temp_rt = g_gs_device->CreateRenderTarget(rtsize, GSTexture::Format::Color, !GSVector4i::loadh(rtsize).eq(valid_rect)))
if (GSTexture* temp_rt = g_gs_device->CreateCompatible(m_texture, rtsize, !GSVector4i::loadh(rtsize).eq(valid_rect)))
{
// Only copy up the valid area, since there's no point in "correcting" nothing.
const GSVector4 dRect(m_texture->GetRect().rintersect(valid_rect));
@@ -4220,7 +4220,7 @@ void GSTextureCache::ScaleTargetForDisplay(Target* t, const GIFRegTEX0& dispfb,
const int new_width = std::max(t->m_unscaled_size.x, needed_width);
const int scaled_new_height = static_cast<int>(std::ceil(static_cast<float>(new_height) * scale));
const int scaled_new_width = static_cast<int>(std::ceil(static_cast<float>(new_width) * scale));
GSTexture* new_texture = g_gs_device->CreateRenderTarget(scaled_new_width, scaled_new_height, GSTexture::Format::Color, false);
GSTexture* new_texture = g_gs_device->CreateCompatible(old_texture, scaled_new_width, scaled_new_height, false);
if (!new_texture)
{
// Memory allocation failure, do our best to hobble along.
@@ -4329,7 +4329,7 @@ bool GSTextureCache::CopyRGBFromDepthToColor(Target* dst, Target* depth_src)
GSTexture* tex = dst->m_texture;
if (needs_new_tex)
{
tex = g_gs_device->CreateRenderTarget(new_scaled_size, GSTexture::Format::Color,
tex = g_gs_device->CreateCompatible(dst->m_texture, new_scaled_size,
new_size != dst->m_unscaled_size || new_size != depth_src->m_unscaled_size);
if (!tex)
return false;