mirror of
https://github.com/narzoul/DDrawCompat
synced 2024-12-30 08:55:36 +01:00
Changed surface alignment to work around performance issues on some drivers
This commit is contained in:
parent
8cc73dc68d
commit
32a67548ae
@ -4,10 +4,7 @@ typedef unsigned long DWORD;
|
||||
|
||||
namespace Config
|
||||
{
|
||||
const int maxUserModeDisplayDrivers = 3;
|
||||
|
||||
const int delayedFlipModeTimeout = 200;
|
||||
const int maxPaletteUpdatesPerMs = 5;
|
||||
const int minExpectedFlipsPerSec = 5;
|
||||
const int virtualScreenBufferExtraRows = 2;
|
||||
const int maxUserModeDisplayDrivers = 3;
|
||||
}
|
||||
|
@ -300,6 +300,7 @@ namespace D3dDdi
|
||||
|
||||
HRESULT Resource::copySubResource(HANDLE dstResource, HANDLE srcResource, UINT subResourceIndex)
|
||||
{
|
||||
LOG_FUNC("Resource::copySubResource", dstResource, srcResource, subResourceIndex);
|
||||
RECT rect = {};
|
||||
rect.right = m_fixedData.pSurfList[subResourceIndex].Width;
|
||||
rect.bottom = m_fixedData.pSurfList[subResourceIndex].Height;
|
||||
@ -317,7 +318,7 @@ namespace D3dDdi
|
||||
{
|
||||
LOG_ONCE("ERROR: Resource::copySubResource failed: " << Compat::hex(result));
|
||||
}
|
||||
return result;
|
||||
return LOG_RESULT(result);
|
||||
}
|
||||
|
||||
void Resource::copyToSysMem(UINT subResourceIndex)
|
||||
@ -358,11 +359,18 @@ namespace D3dDdi
|
||||
auto width = m_fixedData.pSurfList[i].Width;
|
||||
auto height = m_fixedData.pSurfList[i].Height;
|
||||
auto pitch = divCeil(width * m_formatInfo.bytesPerPixel, 8) * 8;
|
||||
m_lockBuffers[i].resize(pitch * height);
|
||||
m_lockBuffers[i].resize(pitch * height + 8);
|
||||
|
||||
surfaceInfo[i].Width = width;
|
||||
surfaceInfo[i].Height = height;
|
||||
surfaceInfo[i].pSysMem = m_lockBuffers[i].data();
|
||||
if (reinterpret_cast<std::uintptr_t>(m_lockBuffers[i].data()) % 16 == 0)
|
||||
{
|
||||
surfaceInfo[i].pSysMem = m_lockBuffers[i].data() + 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
surfaceInfo[i].pSysMem = m_lockBuffers[i].data();
|
||||
}
|
||||
surfaceInfo[i].SysMemPitch = pitch;
|
||||
}
|
||||
|
||||
@ -375,6 +383,7 @@ namespace D3dDdi
|
||||
|
||||
void Resource::createSysMemResource(const std::vector<D3DDDI_SURFACEINFO>& surfaceInfo)
|
||||
{
|
||||
LOG_FUNC("Resource::createSysMemResource", Compat::array(surfaceInfo.data(), surfaceInfo.size()));
|
||||
D3DDDIARG_CREATERESOURCE2 data = {};
|
||||
data.Format = m_fixedData.Format;
|
||||
data.Pool = D3DDDIPOOL_SYSTEMMEM;
|
||||
@ -396,6 +405,7 @@ namespace D3dDdi
|
||||
|
||||
if (FAILED(result))
|
||||
{
|
||||
LOG_RESULT(nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -408,6 +418,7 @@ namespace D3dDdi
|
||||
m_lockData[i].isSysMemUpToDate = false;
|
||||
m_lockData[i].isVidMemUpToDate = true;
|
||||
}
|
||||
LOG_RESULT(m_lockResource);
|
||||
}
|
||||
|
||||
void Resource::copyToVidMem(UINT subResourceIndex)
|
||||
|
@ -66,7 +66,7 @@ namespace
|
||||
}
|
||||
|
||||
void* bits = nullptr;
|
||||
return CreateDIBSection(nullptr, &bmi, DIB_RGB_COLORS, &bits, section, 0);
|
||||
return CreateDIBSection(nullptr, &bmi, DIB_RGB_COLORS, &bits, section, 8);
|
||||
}
|
||||
}
|
||||
|
||||
@ -181,7 +181,7 @@ namespace Gdi
|
||||
desc.ddpfPixelFormat = DDraw::getRgbPixelFormat(g_bpp);
|
||||
desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
|
||||
desc.lPitch = g_pitch;
|
||||
desc.lpSurface = static_cast<unsigned char*>(g_surfaceView) +
|
||||
desc.lpSurface = static_cast<unsigned char*>(g_surfaceView) + 8 +
|
||||
(rect.top - g_bounds.top) * g_pitch +
|
||||
(rect.left - g_bounds.left) * g_bpp / 8;
|
||||
return desc;
|
||||
@ -231,7 +231,7 @@ namespace Gdi
|
||||
}
|
||||
|
||||
g_surfaceFileMapping = CreateFileMapping(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, 0,
|
||||
g_pitch * (g_height + Config::virtualScreenBufferExtraRows), nullptr);
|
||||
g_pitch * g_height + 8, nullptr);
|
||||
g_surfaceView = MapViewOfFile(g_surfaceFileMapping, FILE_MAP_WRITE, 0, 0, 0);
|
||||
|
||||
for (HDC dc : g_dcs)
|
||||
|
Loading…
x
Reference in New Issue
Block a user