1
0
mirror of https://github.com/narzoul/DDrawCompat synced 2024-12-30 08:55:36 +01:00

Use convolution for bilinear resolution downscale

This commit is contained in:
narzoul 2023-04-14 16:23:36 +02:00
parent c39dc0b334
commit 549c4190fa
2 changed files with 9 additions and 37 deletions

View File

@ -666,27 +666,6 @@ namespace D3dDdi
m_isClampable = false;
}
void Resource::downscale(Resource*& rt, LONG& srcWidth, LONG& srcHeight, LONG dstWidth, LONG dstHeight)
{
auto& repo = m_device.getRepo();
while (srcWidth > 2 * dstWidth || srcHeight > 2 * dstHeight)
{
const LONG newSrcWidth = std::max(dstWidth, (srcWidth + 1) / 2);
const LONG newSrcHeight = std::max(dstHeight, (srcHeight + 1) / 2);
auto& nextRt = repo.getNextRenderTarget(newSrcWidth, newSrcHeight, rt);
if (!nextRt.resource)
{
return;
}
m_device.getShaderBlitter().textureBlt(*nextRt.resource, 0, { 0, 0, newSrcWidth, newSrcHeight },
*rt, 0, { 0, 0, srcWidth, srcHeight }, D3DTEXF_LINEAR | D3DTEXF_SRGB);
rt = nextRt.resource;
srcWidth = newSrcWidth;
srcHeight = newSrcHeight;
}
}
void Resource::enableConfig(bool enable)
{
g_enableConfig = enable;
@ -1285,10 +1264,6 @@ namespace D3dDdi
return LOG_RESULT(S_OK);
}
const LONG dstWidth = data.DstRect.right - data.DstRect.left;
const LONG dstHeight = data.DstRect.bottom - data.DstRect.top;
downscale(rt, data.SrcRect.right, data.SrcRect.bottom, dstWidth, dstHeight);
m_device.getShaderBlitter().displayBlt(*this, data.DstSubResourceIndex, data.DstRect, *rt, 0, data.SrcRect);
clearRectExterior(data.DstSubResourceIndex, data.DstRect);
@ -1517,15 +1492,6 @@ namespace D3dDdi
}
}
if (filter & D3DTEXF_SRGB)
{
downscale(srcRes, srcRect.right, srcRect.bottom, dstRect.right, dstRect.bottom);
if (Rect::isEqualSize(srcRect, dstRect))
{
filter = D3DTEXF_POINT;
}
}
if (!dstResource.m_fixedData.Flags.RenderTarget && !dstResource.m_fixedData.Flags.ZBuffer ||
(filter & D3DTEXF_SRGB) && !(dstResource.m_formatOp.Operations & FORMATOP_SRGBWRITE))
{
@ -1576,8 +1542,15 @@ namespace D3dDdi
}
else
{
m_device.getShaderBlitter().textureBlt(*dstRes, dstIndex, dstRect, *srcRes, srcIndex, srcRect,
filter, data.Flags.SrcColorKey ? &ck : nullptr);
if ((D3DTEXF_LINEAR | D3DTEXF_SRGB) == filter)
{
m_device.getShaderBlitter().bilinearBlt(*dstRes, dstIndex, dstRect, *srcRes, srcIndex, srcRect, 0);
}
else
{
m_device.getShaderBlitter().textureBlt(*dstRes, dstIndex, dstRect, *srcRes, srcIndex, srcRect,
filter, data.Flags.SrcColorKey ? &ck : nullptr);
}
}
if (*dstRes != data.hDstResource)

View File

@ -110,7 +110,6 @@ namespace D3dDdi
void createGdiLockResource();
void createLockResource();
void createSysMemResource(const std::vector<D3DDDI_SURFACEINFO>& surfaceInfo);
void downscale(Resource*& rt, LONG& srcWidth, LONG& srcHeight, LONG dstWidth, LONG dstHeight);
void fixResourceData();
D3DDDIFORMAT getFormatConfig();
std::pair<D3DDDIMULTISAMPLE_TYPE, UINT> getMultisampleConfig();