diff --git a/DDrawCompat/D3dDdi/Resource.cpp b/DDrawCompat/D3dDdi/Resource.cpp index 873cc45..42ed674 100644 --- a/DDrawCompat/D3dDdi/Resource.cpp +++ b/DDrawCompat/D3dDdi/Resource.cpp @@ -135,6 +135,7 @@ namespace D3dDdi , m_isSurfaceRepoResource(SurfaceRepository::inCreateSurface() || !g_enableConfig) , m_isClampable(true) , m_isPrimary(false) + , m_isPrimaryScalingNeeded(false) , m_isPalettizedTextureUpToDate(false) , m_isColorKeyedSurfaceUpToDate(false) { @@ -380,6 +381,12 @@ namespace D3dDdi srcResource.loadFromLockRefResource(data.SrcSubResourceIndex); } + if (m_isPrimary && !m_isPrimaryScalingNeeded && srcResource.isScaled(data.SrcSubResourceIndex)) + { + m_isPrimaryScalingNeeded = true; + updateConfig(); + } + Resource* srcRes = &srcResource; if (m_msaaResolvedSurface.resource && srcResource.m_msaaResolvedSurface.resource && (srcResource.m_lockData[data.SrcSubResourceIndex].isMsaaResolvedUpToDate || @@ -821,13 +828,25 @@ namespace D3dDdi SIZE Resource::getScaledSize() { SIZE size = { static_cast(m_fixedData.pSurfList[0].Width), static_cast(m_fixedData.pSurfList[0].Height) }; - if (m_origData.Flags.RenderTarget || m_fixedData.Flags.ZBuffer) + if (m_isPrimary && m_isPrimaryScalingNeeded || m_origData.Flags.RenderTarget || m_fixedData.Flags.ZBuffer) { return m_device.getAdapter().getScaledSize(size); } return size; } + bool Resource::isScaled(UINT subResourceIndex) + { + if (!m_msaaResolvedSurface.resource) + { + return false; + } + + auto& si = m_fixedData.pSurfList[subResourceIndex]; + auto& scaledSi = m_msaaResolvedSurface.resource->getFixedDesc().pSurfList[subResourceIndex]; + return si.Width != scaledSi.Width || si.Height != scaledSi.Height; + } + bool Resource::isValidRect(UINT subResourceIndex, const RECT& rect) { return rect.left >= 0 && rect.top >= 0 && rect.left < rect.right && rect.top < rect.bottom && diff --git a/DDrawCompat/D3dDdi/Resource.h b/DDrawCompat/D3dDdi/Resource.h index 010a31d..2d8a229 100644 --- a/DDrawCompat/D3dDdi/Resource.h +++ b/DDrawCompat/D3dDdi/Resource.h @@ -117,6 +117,7 @@ namespace D3dDdi D3DDDIFORMAT getFormatConfig(); std::pair getMultisampleConfig(); SIZE getScaledSize(); + bool isScaled(UINT subResourceIndex); bool isValidRect(UINT subResourceIndex, const RECT& rect); void loadFromLockRefResource(UINT subResourceIndex); void loadMsaaResource(UINT subResourceIndex); @@ -155,6 +156,7 @@ namespace D3dDdi bool m_isSurfaceRepoResource; bool m_isClampable; bool m_isPrimary; + bool m_isPrimaryScalingNeeded; bool m_isPalettizedTextureUpToDate; bool m_isColorKeyedSurfaceUpToDate; };