mirror of
https://github.com/narzoul/DDrawCompat
synced 2024-12-30 08:55:36 +01:00
Added BltFilter setting
This commit is contained in:
parent
516ed1f7da
commit
22c61dc115
@ -5,6 +5,7 @@ namespace Config
|
||||
Settings::AlternatePixelCenter alternatePixelCenter;
|
||||
Settings::AltTabFix altTabFix;
|
||||
Settings::Antialiasing antialiasing;
|
||||
Settings::BltFilter bltFilter;
|
||||
Settings::ConfigHotKey configHotKey;
|
||||
Settings::CpuAffinity cpuAffinity;
|
||||
Settings::DesktopColorDepth desktopColorDepth;
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <Config/Settings/AlternatePixelCenter.h>
|
||||
#include <Config/Settings/AltTabFix.h>
|
||||
#include <Config/Settings/Antialiasing.h>
|
||||
#include <Config/Settings/BltFilter.h>
|
||||
#include <Config/Settings/ConfigHotKey.h>
|
||||
#include <Config/Settings/CpuAffinity.h>
|
||||
#include <Config/Settings/DesktopColorDepth.h>
|
||||
@ -28,6 +29,7 @@ namespace Config
|
||||
extern Settings::AlternatePixelCenter alternatePixelCenter;
|
||||
extern Settings::AltTabFix altTabFix;
|
||||
extern Settings::Antialiasing antialiasing;
|
||||
extern Settings::BltFilter bltFilter;
|
||||
extern Settings::ConfigHotKey configHotKey;
|
||||
extern Settings::CpuAffinity cpuAffinity;
|
||||
extern Settings::DesktopColorDepth desktopColorDepth;
|
||||
|
22
DDrawCompat/Config/Settings/BltFilter.h
Normal file
22
DDrawCompat/Config/Settings/BltFilter.h
Normal file
@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include <Config/MappedSetting.h>
|
||||
|
||||
namespace Config
|
||||
{
|
||||
namespace Settings
|
||||
{
|
||||
class BltFilter : public MappedSetting<UINT>
|
||||
{
|
||||
public:
|
||||
static const UINT NATIVE = 0;
|
||||
static const UINT POINT = 1;
|
||||
static const UINT BILINEAR = 2;
|
||||
|
||||
BltFilter::BltFilter()
|
||||
: MappedSetting("BltFilter", "point", { {"native", NATIVE}, {"point", POINT}, {"bilinear", BILINEAR}})
|
||||
{
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
@ -220,7 +220,13 @@ namespace D3dDdi
|
||||
return presentationBlt(data, srcResource);
|
||||
}
|
||||
|
||||
return sysMemPreferredBlt(data, *srcResource);
|
||||
HRESULT result = bltViaCpu(data, *srcResource);
|
||||
if (S_FALSE != result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
return bltViaGpu(data, *srcResource);
|
||||
}
|
||||
|
||||
prepareForBltDst(data);
|
||||
@ -255,6 +261,138 @@ namespace D3dDdi
|
||||
return LOG_RESULT(S_OK);
|
||||
}
|
||||
|
||||
HRESULT Resource::bltViaCpu(D3DDDIARG_BLT data, Resource& srcResource)
|
||||
{
|
||||
if (m_fixedData.Format != srcResource.m_fixedData.Format ||
|
||||
0 == m_formatInfo.bytesPerPixel ||
|
||||
D3DDDIFMT_P8 != m_fixedData.Format && !m_isOversized && !srcResource.m_isOversized)
|
||||
{
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
D3DDDIARG_LOCK srcLock = {};
|
||||
srcLock.hResource = data.hSrcResource;
|
||||
srcLock.SubResourceIndex = data.SrcSubResourceIndex;
|
||||
if (D3DDDIPOOL_SYSTEMMEM == srcResource.m_fixedData.Pool)
|
||||
{
|
||||
srcLock.Flags.NotifyOnly = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
srcLock.Area = data.SrcRect;
|
||||
srcLock.Flags.AreaValid = 1;
|
||||
srcLock.Flags.ReadOnly = 1;
|
||||
}
|
||||
|
||||
HRESULT result = srcResource.lock(srcLock);
|
||||
if (FAILED(result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
D3DDDIARG_LOCK dstLock = {};
|
||||
dstLock.hResource = data.hDstResource;
|
||||
dstLock.SubResourceIndex = data.DstSubResourceIndex;
|
||||
if (D3DDDIPOOL_SYSTEMMEM == m_fixedData.Pool)
|
||||
{
|
||||
dstLock.Flags.NotifyOnly = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dstLock.Area = data.DstRect;
|
||||
dstLock.Flags.AreaValid = 1;
|
||||
}
|
||||
|
||||
result = lock(dstLock);
|
||||
if (SUCCEEDED(result))
|
||||
{
|
||||
if (D3DDDIPOOL_SYSTEMMEM == srcResource.m_fixedData.Pool)
|
||||
{
|
||||
auto& lockData = srcResource.m_lockData[data.SrcSubResourceIndex];
|
||||
srcLock.pSurfData = static_cast<BYTE*>(lockData.data) + data.SrcRect.top * lockData.pitch +
|
||||
data.SrcRect.left * m_formatInfo.bytesPerPixel;
|
||||
srcLock.Pitch = lockData.pitch;
|
||||
}
|
||||
|
||||
if (D3DDDIPOOL_SYSTEMMEM == m_fixedData.Pool)
|
||||
{
|
||||
auto& lockData = m_lockData[data.DstSubResourceIndex];
|
||||
dstLock.pSurfData = static_cast<BYTE*>(lockData.data) + data.DstRect.top * lockData.pitch +
|
||||
data.DstRect.left * m_formatInfo.bytesPerPixel;
|
||||
dstLock.Pitch = lockData.pitch;
|
||||
}
|
||||
|
||||
DDraw::Blitter::blt(
|
||||
dstLock.pSurfData,
|
||||
dstLock.Pitch,
|
||||
data.DstRect.right - data.DstRect.left,
|
||||
data.DstRect.bottom - data.DstRect.top,
|
||||
srcLock.pSurfData,
|
||||
srcLock.Pitch,
|
||||
(1 - 2 * data.Flags.MirrorLeftRight) * (data.SrcRect.right - data.SrcRect.left),
|
||||
(1 - 2 * data.Flags.MirrorUpDown) * (data.SrcRect.bottom - data.SrcRect.top),
|
||||
m_formatInfo.bytesPerPixel,
|
||||
data.Flags.DstColorKey ? reinterpret_cast<const DWORD*>(&data.ColorKey) : nullptr,
|
||||
data.Flags.SrcColorKey ? reinterpret_cast<const DWORD*>(&data.ColorKey) : nullptr);
|
||||
|
||||
D3DDDIARG_UNLOCK dstUnlock = {};
|
||||
dstUnlock.hResource = dstLock.hResource;
|
||||
dstUnlock.SubResourceIndex = dstLock.SubResourceIndex;
|
||||
dstUnlock.Flags.NotifyOnly = dstLock.Flags.NotifyOnly;
|
||||
unlock(dstUnlock);
|
||||
}
|
||||
|
||||
D3DDDIARG_UNLOCK srcUnlock = {};
|
||||
srcUnlock.hResource = srcLock.hResource;
|
||||
srcUnlock.SubResourceIndex = srcLock.SubResourceIndex;
|
||||
srcUnlock.Flags.NotifyOnly = srcLock.Flags.NotifyOnly;
|
||||
srcResource.unlock(srcUnlock);
|
||||
return result;
|
||||
}
|
||||
|
||||
HRESULT Resource::bltViaGpu(D3DDDIARG_BLT data, Resource& srcResource)
|
||||
{
|
||||
if (D3DDDIPOOL_SYSTEMMEM != m_fixedData.Pool &&
|
||||
(m_fixedData.Flags.RenderTarget || data.Flags.SrcColorKey || data.Flags.MirrorLeftRight || data.Flags.MirrorUpDown))
|
||||
{
|
||||
if (SUCCEEDED(shaderBlt(data, srcResource)))
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
srcResource.prepareForBltSrc(data);
|
||||
prepareForBltDst(data);
|
||||
}
|
||||
|
||||
auto bltFilter = Config::bltFilter.get();
|
||||
if (Config::Settings::BltFilter::NATIVE != bltFilter &&
|
||||
D3DDDIPOOL_SYSTEMMEM != m_fixedData.Pool &&
|
||||
D3DDDIPOOL_SYSTEMMEM != srcResource.m_fixedData.Pool)
|
||||
{
|
||||
if (Config::Settings::BltFilter::POINT == bltFilter)
|
||||
{
|
||||
data.Flags.Point = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
data.Flags.Linear = 1;
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT result = m_device.getOrigVtable().pfnBlt(m_device, &data);
|
||||
if (D3DDDIPOOL_SYSTEMMEM == m_fixedData.Pool)
|
||||
{
|
||||
notifyLock(data.DstSubResourceIndex);
|
||||
}
|
||||
else if (D3DDDIPOOL_SYSTEMMEM == srcResource.m_fixedData.Pool)
|
||||
{
|
||||
srcResource.notifyLock(data.SrcSubResourceIndex);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void Resource::clearUpToDateFlags(UINT subResourceIndex)
|
||||
{
|
||||
m_lockData[subResourceIndex].isMsaaUpToDate = false;
|
||||
@ -1096,118 +1234,6 @@ namespace D3dDdi
|
||||
return LOG_RESULT(S_OK);
|
||||
}
|
||||
|
||||
HRESULT Resource::sysMemPreferredBlt(D3DDDIARG_BLT& data, Resource& srcResource)
|
||||
{
|
||||
if (m_fixedData.Format == srcResource.m_fixedData.Format &&
|
||||
0 != m_formatInfo.bytesPerPixel &&
|
||||
(D3DDDIFMT_P8 == m_fixedData.Format || m_isOversized || srcResource.m_isOversized))
|
||||
{
|
||||
D3DDDIARG_LOCK srcLock = {};
|
||||
srcLock.hResource = data.hSrcResource;
|
||||
srcLock.SubResourceIndex = data.SrcSubResourceIndex;
|
||||
if (D3DDDIPOOL_SYSTEMMEM == srcResource.m_fixedData.Pool)
|
||||
{
|
||||
srcLock.Flags.NotifyOnly = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
srcLock.Area = data.SrcRect;
|
||||
srcLock.Flags.AreaValid = 1;
|
||||
srcLock.Flags.ReadOnly = 1;
|
||||
}
|
||||
|
||||
HRESULT result = srcResource.lock(srcLock);
|
||||
if (FAILED(result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
D3DDDIARG_LOCK dstLock = {};
|
||||
dstLock.hResource = data.hDstResource;
|
||||
dstLock.SubResourceIndex = data.DstSubResourceIndex;
|
||||
if (D3DDDIPOOL_SYSTEMMEM == m_fixedData.Pool)
|
||||
{
|
||||
dstLock.Flags.NotifyOnly = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dstLock.Area = data.DstRect;
|
||||
dstLock.Flags.AreaValid = 1;
|
||||
}
|
||||
|
||||
result = lock(dstLock);
|
||||
if (SUCCEEDED(result))
|
||||
{
|
||||
if (D3DDDIPOOL_SYSTEMMEM == srcResource.m_fixedData.Pool)
|
||||
{
|
||||
auto& lockData = srcResource.m_lockData[data.SrcSubResourceIndex];
|
||||
srcLock.pSurfData = static_cast<BYTE*>(lockData.data) + data.SrcRect.top * lockData.pitch +
|
||||
data.SrcRect.left * m_formatInfo.bytesPerPixel;
|
||||
srcLock.Pitch = lockData.pitch;
|
||||
}
|
||||
|
||||
if (D3DDDIPOOL_SYSTEMMEM == m_fixedData.Pool)
|
||||
{
|
||||
auto& lockData = m_lockData[data.DstSubResourceIndex];
|
||||
dstLock.pSurfData = static_cast<BYTE*>(lockData.data) + data.DstRect.top * lockData.pitch +
|
||||
data.DstRect.left * m_formatInfo.bytesPerPixel;
|
||||
dstLock.Pitch = lockData.pitch;
|
||||
}
|
||||
|
||||
DDraw::Blitter::blt(
|
||||
dstLock.pSurfData,
|
||||
dstLock.Pitch,
|
||||
data.DstRect.right - data.DstRect.left,
|
||||
data.DstRect.bottom - data.DstRect.top,
|
||||
srcLock.pSurfData,
|
||||
srcLock.Pitch,
|
||||
(1 - 2 * data.Flags.MirrorLeftRight) * (data.SrcRect.right - data.SrcRect.left),
|
||||
(1 - 2 * data.Flags.MirrorUpDown) * (data.SrcRect.bottom - data.SrcRect.top),
|
||||
m_formatInfo.bytesPerPixel,
|
||||
data.Flags.DstColorKey ? reinterpret_cast<const DWORD*>(&data.ColorKey) : nullptr,
|
||||
data.Flags.SrcColorKey ? reinterpret_cast<const DWORD*>(&data.ColorKey) : nullptr);
|
||||
|
||||
D3DDDIARG_UNLOCK dstUnlock = {};
|
||||
dstUnlock.hResource = dstLock.hResource;
|
||||
dstUnlock.SubResourceIndex = dstLock.SubResourceIndex;
|
||||
dstUnlock.Flags.NotifyOnly = dstLock.Flags.NotifyOnly;
|
||||
unlock(dstUnlock);
|
||||
}
|
||||
|
||||
D3DDDIARG_UNLOCK srcUnlock = {};
|
||||
srcUnlock.hResource = srcLock.hResource;
|
||||
srcUnlock.SubResourceIndex = srcLock.SubResourceIndex;
|
||||
srcUnlock.Flags.NotifyOnly = srcLock.Flags.NotifyOnly;
|
||||
srcResource.unlock(srcUnlock);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (D3DDDIPOOL_SYSTEMMEM != m_fixedData.Pool &&
|
||||
(m_fixedData.Flags.RenderTarget || data.Flags.SrcColorKey || data.Flags.MirrorLeftRight || data.Flags.MirrorUpDown))
|
||||
{
|
||||
if (SUCCEEDED(shaderBlt(data, srcResource)))
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
srcResource.prepareForBltSrc(data);
|
||||
prepareForBltDst(data);
|
||||
}
|
||||
|
||||
HRESULT result = m_device.getOrigVtable().pfnBlt(m_device, &data);
|
||||
if (D3DDDIPOOL_SYSTEMMEM == m_fixedData.Pool)
|
||||
{
|
||||
notifyLock(data.DstSubResourceIndex);
|
||||
}
|
||||
else if (D3DDDIPOOL_SYSTEMMEM == srcResource.m_fixedData.Pool)
|
||||
{
|
||||
srcResource.notifyLock(data.SrcSubResourceIndex);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
HRESULT Resource::unlock(const D3DDDIARG_UNLOCK& data)
|
||||
{
|
||||
return (m_lockResource || m_isOversized) ? S_OK : m_device.getOrigVtable().pfnUnlock(m_device, &data);
|
||||
|
@ -77,6 +77,8 @@ namespace D3dDdi
|
||||
};
|
||||
|
||||
HRESULT bltLock(D3DDDIARG_LOCK& data);
|
||||
HRESULT bltViaCpu(D3DDDIARG_BLT data, Resource& srcResource);
|
||||
HRESULT bltViaGpu(D3DDDIARG_BLT data, Resource& srcResource);
|
||||
void clearUpToDateFlags(UINT subResourceIndex);
|
||||
void clipRect(UINT subResourceIndex, RECT& rect);
|
||||
HRESULT copySubResource(Resource& dstResource, Resource& srcResource, UINT subResourceIndex);
|
||||
@ -102,7 +104,6 @@ namespace D3dDdi
|
||||
HRESULT presentationBlt(D3DDDIARG_BLT data, Resource* srcResource);
|
||||
void presentLayeredWindows(Resource& dst, UINT dstSubResourceIndex, const RECT& dstRect);
|
||||
HRESULT shaderBlt(D3DDDIARG_BLT& data, Resource& srcResource);
|
||||
HRESULT sysMemPreferredBlt(D3DDDIARG_BLT& data, Resource& srcResource);
|
||||
|
||||
Device& m_device;
|
||||
HANDLE m_handle;
|
||||
|
@ -220,6 +220,7 @@
|
||||
<ClInclude Include="Config\Settings\AlternatePixelCenter.h" />
|
||||
<ClInclude Include="Config\Settings\AltTabFix.h" />
|
||||
<ClInclude Include="Config\Settings\Antialiasing.h" />
|
||||
<ClInclude Include="Config\Settings\BltFilter.h" />
|
||||
<ClInclude Include="Config\Settings\ConfigHotKey.h" />
|
||||
<ClInclude Include="Config\Settings\CpuAffinity.h" />
|
||||
<ClInclude Include="Config\Settings\DesktopColorDepth.h" />
|
||||
|
@ -561,6 +561,9 @@
|
||||
<ClInclude Include="Win32\Version.h">
|
||||
<Filter>Header Files\Win32</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Config\Settings\BltFilter.h">
|
||||
<Filter>Header Files\Config\Settings</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Gdi\Gdi.cpp">
|
||||
|
@ -12,6 +12,7 @@ namespace Overlay
|
||||
, m_focus(nullptr)
|
||||
{
|
||||
addControl(Config::alternatePixelCenter);
|
||||
addControl(Config::bltFilter);
|
||||
addControl(Config::antialiasing);
|
||||
addControl(Config::displayFilter);
|
||||
addControl(Config::renderColorDepth);
|
||||
|
Loading…
x
Reference in New Issue
Block a user