mirror of
https://github.com/narzoul/DDrawCompat
synced 2024-12-30 08:55:36 +01:00
Added a primary surface repository
This commit is contained in:
parent
086b7740d9
commit
c344ec3408
@ -496,14 +496,19 @@ namespace D3dDdi
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Adapter::setRepository(LUID luid, CompatWeakPtr<IDirectDraw7> repository)
|
void Adapter::setRepository(LUID luid, CompatWeakPtr<IDirectDraw7> repository, bool isPrimary)
|
||||||
{
|
{
|
||||||
for (auto& adapter : s_adapters)
|
for (auto& adapter : s_adapters)
|
||||||
{
|
{
|
||||||
if (adapter.second.m_luid == luid)
|
if (adapter.second.m_luid == luid)
|
||||||
{
|
{
|
||||||
adapter.second.m_repository = repository;
|
adapter.second.m_repository = repository;
|
||||||
SurfaceRepository::get(adapter.second).setRepository(repository);
|
auto& surfaceRepo = SurfaceRepository::get(adapter.second);
|
||||||
|
surfaceRepo.setRepository(repository);
|
||||||
|
if (isPrimary)
|
||||||
|
{
|
||||||
|
surfaceRepo.setAsPrimary();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ namespace D3dDdi
|
|||||||
|
|
||||||
static void add(const D3DDDIARG_OPENADAPTER& data) { s_adapters.emplace(data.hAdapter, data); }
|
static void add(const D3DDDIARG_OPENADAPTER& data) { s_adapters.emplace(data.hAdapter, data); }
|
||||||
static Adapter& get(HANDLE adapter) { return s_adapters.find(adapter)->second; }
|
static Adapter& get(HANDLE adapter) { return s_adapters.find(adapter)->second; }
|
||||||
static void setRepository(LUID luid, CompatWeakPtr<IDirectDraw7> repository);
|
static void setRepository(LUID luid, CompatWeakPtr<IDirectDraw7> repository, bool isPrimary);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const AdapterInfo& findInfo() const;
|
const AdapterInfo& findInfo() const;
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
std::map<LUID, D3dDdi::SurfaceRepository> g_repositories;
|
std::map<LUID, D3dDdi::SurfaceRepository> g_repositories;
|
||||||
|
D3dDdi::SurfaceRepository* g_primaryRepository = nullptr;
|
||||||
bool g_enableSurfaceCheck = true;
|
bool g_enableSurfaceCheck = true;
|
||||||
|
|
||||||
void initDitherTexture(BYTE* tex, DWORD pitch, DWORD x, DWORD y, DWORD size, DWORD mul, DWORD value)
|
void initDitherTexture(BYTE* tex, DWORD pitch, DWORD x, DWORD y, DWORD size, DWORD mul, DWORD value)
|
||||||
@ -297,6 +298,11 @@ namespace D3dDdi
|
|||||||
return getSurface(m_paletteTexture, 256, 1, D3DDDIFMT_A8R8G8B8, DDSCAPS_TEXTURE | DDSCAPS_VIDEOMEMORY).resource;
|
return getSurface(m_paletteTexture, 256, 1, D3DDDIFMT_A8R8G8B8, DDSCAPS_TEXTURE | DDSCAPS_VIDEOMEMORY).resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SurfaceRepository& SurfaceRepository::getPrimary()
|
||||||
|
{
|
||||||
|
return *g_primaryRepository;
|
||||||
|
}
|
||||||
|
|
||||||
SurfaceRepository::Surface& SurfaceRepository::getSurface(Surface& surface, DWORD width, DWORD height,
|
SurfaceRepository::Surface& SurfaceRepository::getSurface(Surface& surface, DWORD width, DWORD height,
|
||||||
D3DDDIFORMAT format, DWORD caps, UINT surfaceCount, DWORD caps2)
|
D3DDDIFORMAT format, DWORD caps, UINT surfaceCount, DWORD caps2)
|
||||||
{
|
{
|
||||||
@ -386,5 +392,10 @@ namespace D3dDdi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SurfaceRepository::setAsPrimary()
|
||||||
|
{
|
||||||
|
g_primaryRepository = this;
|
||||||
|
}
|
||||||
|
|
||||||
bool SurfaceRepository::s_inCreateSurface = false;
|
bool SurfaceRepository::s_inCreateSurface = false;
|
||||||
}
|
}
|
||||||
|
@ -53,9 +53,11 @@ namespace D3dDdi
|
|||||||
D3DDDIFORMAT format, DWORD caps, UINT surfaceCount = 1);
|
D3DDDIFORMAT format, DWORD caps, UINT surfaceCount = 1);
|
||||||
const Surface& getTempTexture(DWORD width, DWORD height, D3DDDIFORMAT format);
|
const Surface& getTempTexture(DWORD width, DWORD height, D3DDDIFORMAT format);
|
||||||
void release(Surface& surface);
|
void release(Surface& surface);
|
||||||
|
void setAsPrimary();
|
||||||
void setRepository(CompatWeakPtr<IDirectDraw7> dd) { m_dd = dd; }
|
void setRepository(CompatWeakPtr<IDirectDraw7> dd) { m_dd = dd; }
|
||||||
|
|
||||||
static SurfaceRepository& get(const Adapter& adapter);
|
static SurfaceRepository& get(const Adapter& adapter);
|
||||||
|
static SurfaceRepository& getPrimary();
|
||||||
static bool inCreateSurface() { return s_inCreateSurface; }
|
static bool inCreateSurface() { return s_inCreateSurface; }
|
||||||
static void enableSurfaceCheck(bool enable);
|
static void enableSurfaceCheck(bool enable);
|
||||||
|
|
||||||
|
@ -284,9 +284,9 @@ namespace DDraw
|
|||||||
}
|
}
|
||||||
repo.get()->lpVtbl->SetCooperativeLevel(repo, nullptr, DDSCL_NORMAL);
|
repo.get()->lpVtbl->SetCooperativeLevel(repo, nullptr, DDSCL_NORMAL);
|
||||||
it = repositories.insert({ adapterInfo.luid, repo }).first;
|
it = repositories.insert({ adapterInfo.luid, repo }).first;
|
||||||
|
D3dDdi::Adapter::setRepository(adapterInfo.luid, it->second, !guid);
|
||||||
repo.detach();
|
repo.detach();
|
||||||
}
|
}
|
||||||
D3dDdi::Adapter::setRepository(adapterInfo.luid, it->second);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void suppressEmulatedDirectDraw(GUID*& guid)
|
void suppressEmulatedDirectDraw(GUID*& guid)
|
||||||
|
@ -97,6 +97,7 @@ namespace DDraw
|
|||||||
{
|
{
|
||||||
void installHooks(CompatPtr<IDirectDraw7> dd7)
|
void installHooks(CompatPtr<IDirectDraw7> dd7)
|
||||||
{
|
{
|
||||||
|
DDraw::DirectDraw::onCreate(nullptr, *dd7);
|
||||||
RealPrimarySurface::init();
|
RealPrimarySurface::init();
|
||||||
|
|
||||||
g_origInitialize = dd7.get()->lpVtbl->Initialize;
|
g_origInitialize = dd7.get()->lpVtbl->Initialize;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user