1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-02-20 19:54:19 +01:00

[d3d8] Mimic native token allocations

This commit is contained in:
WinterSnowfall 2024-07-10 00:51:46 +03:00 committed by Philip Rebohle
parent ff137dac9f
commit d731608d5e
2 changed files with 10 additions and 4 deletions

View File

@ -976,11 +976,11 @@ namespace dxvk {
Com<d3d9::IDirect3DStateBlock9> pStateBlock9;
HRESULT res = GetD3D9()->CreateStateBlock(d3d9::D3DSTATEBLOCKTYPE(Type), &pStateBlock9);
m_token++;
m_stateBlocks.emplace(std::piecewise_construct,
std::forward_as_tuple(m_token),
std::forward_as_tuple(this, Type, pStateBlock9.ref()));
*pToken = m_token;
m_token++;
return res;
}
@ -1023,6 +1023,12 @@ namespace dxvk {
m_stateBlocks.erase(stateBlockIter);
// native apparently does drop the token counter in
// situations where the token being removed is the
// last allocated token, which allows some reuse
if (m_token == Token)
m_token--;
return D3D_OK;
}
@ -1030,12 +1036,12 @@ namespace dxvk {
if (unlikely(m_recorder != nullptr))
return D3DERR_INVALIDCALL;
m_token++;
auto stateBlockIterPair = m_stateBlocks.emplace(std::piecewise_construct,
std::forward_as_tuple(m_token),
std::forward_as_tuple(this));
m_recorder = &stateBlockIterPair.first->second;
m_recorderToken = m_token;
m_token++;
return GetD3D9()->BeginStateBlock();
}
@ -1052,7 +1058,7 @@ namespace dxvk {
*pToken = m_recorderToken;
m_recorder = nullptr;
m_recorderToken = -1;
m_recorderToken = 0;
return res;
}

View File

@ -417,7 +417,7 @@ namespace dxvk {
D3DPRESENT_PARAMETERS m_presentParams;
D3D8StateBlock* m_recorder = nullptr;
DWORD m_recorderToken = -1;
DWORD m_recorderToken = 0;
DWORD m_token = 0;
std::unordered_map<DWORD, D3D8StateBlock> m_stateBlocks;
D3D8Batcher* m_batcher = nullptr;