diff --git a/DDrawCompat/Config/Config.cpp b/DDrawCompat/Config/Config.cpp index ccd4431..22cf810 100644 --- a/DDrawCompat/Config/Config.cpp +++ b/DDrawCompat/Config/Config.cpp @@ -50,6 +50,7 @@ #include #include #include +#include #include #include @@ -107,6 +108,7 @@ namespace Config Settings::ThreadPriorityBoost threadPriorityBoost; Settings::VertexBufferMemoryType vertexBufferMemoryType; Settings::VertexFixup vertexFixup; + Settings::ViewportEdgeFix viewportEdgeFix; Settings::VSync vSync; Settings::WinVersionLie winVersionLie; } diff --git a/DDrawCompat/Config/Settings/ViewportEdgeFix.h b/DDrawCompat/Config/Settings/ViewportEdgeFix.h new file mode 100644 index 0000000..3f963fc --- /dev/null +++ b/DDrawCompat/Config/Settings/ViewportEdgeFix.h @@ -0,0 +1,32 @@ +#pragma once + +#include + +namespace Config +{ + namespace Settings + { + class ViewportEdgeFix : public EnumSetting + { + public: + enum Values { OFF, SCALE }; + + ViewportEdgeFix() + : EnumSetting("ViewportEdgeFix", "off", { "off", "scale" }) + { + } + + virtual ParamInfo getParamInfo() const override + { + switch (m_value) + { + case SCALE: + return { "Gap", 1, 100, 50 }; + } + return {}; + } + }; + } + + extern Settings::ViewportEdgeFix viewportEdgeFix; +} diff --git a/DDrawCompat/D3dDdi/DeviceState.cpp b/DDrawCompat/D3dDdi/DeviceState.cpp index 4000542..2971c3b 100644 --- a/DDrawCompat/D3dDdi/DeviceState.cpp +++ b/DDrawCompat/D3dDdi/DeviceState.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #define LOG_DS LOG_DEBUG << "DeviceState::" << __func__ << ": " @@ -901,7 +902,7 @@ namespace D3dDdi if (spriteMode != m_spriteMode) { m_spriteMode = spriteMode; - m_changedStates |= CS_RENDER_STATE | CS_TEXTURE_STAGE; + m_changedStates |= CS_RENDER_STATE | CS_RENDER_TARGET | CS_TEXTURE_STAGE; m_changedRenderStates.set(D3DDDIRS_MULTISAMPLEANTIALIAS); if (Config::Settings::SpriteTexCoord::ROUND == Config::spriteTexCoord.get()) { @@ -1353,17 +1354,21 @@ namespace D3dDdi const float apc = Config::alternatePixelCenter.get(); const auto& zr = m_current.zRange; + const float viewportEdgeGap = m_spriteMode ? 0 : (Config::viewportEdgeFix.getParam() / 100.0f); + const float w = width - viewportEdgeGap; + const float h = height - viewportEdgeGap; + m_vertexFixupData.texCoordAdj[2] = stc; m_vertexFixupData.texCoordAdj[3] = stc; if (Config::Settings::VertexFixup::GPU == m_vertexFixupConfig) { - m_vertexFixupData.offset[0] = 0.5f + apc - 0.5f / sx - width / 2; - m_vertexFixupData.offset[1] = 0.5f + apc - 0.5f / sy - height / 2; + m_vertexFixupData.offset[0] = 0.5f + apc - 0.5f / sx - w / 2; + m_vertexFixupData.offset[1] = 0.5f + apc - 0.5f / sy - h / 2; m_vertexFixupData.offset[2] = -zr.MinZ; - m_vertexFixupData.multiplier[0] = 2.0f / width; - m_vertexFixupData.multiplier[1] = -2.0f / height; + m_vertexFixupData.multiplier[0] = 2.0f / w; + m_vertexFixupData.multiplier[1] = -2.0f / h; m_vertexFixupData.multiplier[2] = 1.0f / (zr.MaxZ - zr.MinZ); } else @@ -1371,8 +1376,8 @@ namespace D3dDdi m_vertexFixupData.offset[0] = 0.5f + apc - 0.5f / sx; m_vertexFixupData.offset[1] = 0.5f + apc - 0.5f / sy; - m_vertexFixupData.multiplier[0] = sx; - m_vertexFixupData.multiplier[1] = sy; + m_vertexFixupData.multiplier[0] = sx * width / w; + m_vertexFixupData.multiplier[1] = sy * height / h; } m_changedStates |= CS_VERTEX_FIXUP; diff --git a/DDrawCompat/DDrawCompat.vcxproj b/DDrawCompat/DDrawCompat.vcxproj index 6a21872..9bb8e5e 100644 --- a/DDrawCompat/DDrawCompat.vcxproj +++ b/DDrawCompat/DDrawCompat.vcxproj @@ -216,6 +216,7 @@ + diff --git a/DDrawCompat/DDrawCompat.vcxproj.filters b/DDrawCompat/DDrawCompat.vcxproj.filters index 32aa36f..a22060a 100644 --- a/DDrawCompat/DDrawCompat.vcxproj.filters +++ b/DDrawCompat/DDrawCompat.vcxproj.filters @@ -723,6 +723,9 @@ Header Files\Config\Settings + + Header Files\Config\Settings + diff --git a/DDrawCompat/Overlay/ConfigWindow.cpp b/DDrawCompat/Overlay/ConfigWindow.cpp index b5e3141..0551950 100644 --- a/DDrawCompat/Overlay/ConfigWindow.cpp +++ b/DDrawCompat/Overlay/ConfigWindow.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -71,6 +72,7 @@ namespace { &Config::statsTransparency, [&]() { Gdi::GuiThread::getStatsWindow()->setAlpha(Config::statsTransparency.get()); }}, { &Config::textureFilter, &D3dDdi::Device::updateAllConfig }, { &Config::vertexFixup, &D3dDdi::Device::updateAllConfig }, + { &Config::viewportEdgeFix }, { &Config::vSync } }; } diff --git a/DDrawCompat/Win32/Registry.cpp b/DDrawCompat/Win32/Registry.cpp index 9607365..449bb0b 100644 --- a/DDrawCompat/Win32/Registry.cpp +++ b/DDrawCompat/Win32/Registry.cpp @@ -318,7 +318,7 @@ namespace LSTATUS WINAPI regEnumValueW(HKEY hKey, DWORD dwIndex, LPWSTR lpValueName, LPDWORD lpcchValueName, LPDWORD lpReserved, LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData) { - LOG_FUNC("RegEnumValueW", hKey, dwIndex, lpValueName, lpcchValueName, lpReserved, lpType, lpData, lpcbData); + LOG_FUNC("RegEnumValueW", hKey, dwIndex, Compat::out(lpValueName), lpcchValueName, lpReserved, lpType, lpData, lpcbData); if (lpValueName && lpcchValueName && !lpReserved && !lpType && !lpData && !lpcbData) { auto keyName(getKeyName(hKey));