mirror of
https://github.com/EduApps-CDG/OpenDX
synced 2024-12-30 09:45:37 +01:00
[d3d11] Track used queries in deferred contexts and command lists
This commit is contained in:
parent
0671007437
commit
63dbca82e7
@ -49,12 +49,20 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void D3D11CommandList::AddQuery(D3D11Query* pQuery) {
|
||||||
|
m_queries.emplace_back(pQuery);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void D3D11CommandList::EmitToCommandList(ID3D11CommandList* pCommandList) {
|
void D3D11CommandList::EmitToCommandList(ID3D11CommandList* pCommandList) {
|
||||||
auto cmdList = static_cast<D3D11CommandList*>(pCommandList);
|
auto cmdList = static_cast<D3D11CommandList*>(pCommandList);
|
||||||
|
|
||||||
for (const auto& chunk : m_chunks)
|
for (const auto& chunk : m_chunks)
|
||||||
cmdList->m_chunks.push_back(chunk);
|
cmdList->m_chunks.push_back(chunk);
|
||||||
|
|
||||||
|
for (const auto& query : m_queries)
|
||||||
|
cmdList->m_queries.push_back(query);
|
||||||
|
|
||||||
MarkSubmitted();
|
MarkSubmitted();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,9 @@ namespace dxvk {
|
|||||||
|
|
||||||
void AddChunk(
|
void AddChunk(
|
||||||
DxvkCsChunkRef&& Chunk);
|
DxvkCsChunkRef&& Chunk);
|
||||||
|
|
||||||
|
void AddQuery(
|
||||||
|
D3D11Query* pQuery);
|
||||||
|
|
||||||
void EmitToCommandList(
|
void EmitToCommandList(
|
||||||
ID3D11CommandList* pCommandList);
|
ID3D11CommandList* pCommandList);
|
||||||
@ -37,7 +40,8 @@ namespace dxvk {
|
|||||||
D3D11Device* const m_device;
|
D3D11Device* const m_device;
|
||||||
UINT const m_contextFlags;
|
UINT const m_contextFlags;
|
||||||
|
|
||||||
std::vector<DxvkCsChunkRef> m_chunks;
|
std::vector<DxvkCsChunkRef> m_chunks;
|
||||||
|
std::vector<Com<D3D11Query, false>> m_queries;
|
||||||
|
|
||||||
std::atomic<bool> m_submitted = { false };
|
std::atomic<bool> m_submitted = { false };
|
||||||
std::atomic<bool> m_warned = { false };
|
std::atomic<bool> m_warned = { false };
|
||||||
|
@ -34,6 +34,63 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void STDMETHODCALLTYPE D3D11DeferredContext::Begin(
|
||||||
|
ID3D11Asynchronous* pAsync) {
|
||||||
|
D3D10DeviceLock lock = LockContext();
|
||||||
|
|
||||||
|
if (unlikely(!pAsync))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Com<D3D11Query, false> query(static_cast<D3D11Query*>(pAsync));
|
||||||
|
|
||||||
|
if (unlikely(!query->IsScoped()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto entry = std::find(
|
||||||
|
m_queriesBegun.begin(),
|
||||||
|
m_queriesBegun.end(), query);
|
||||||
|
|
||||||
|
if (unlikely(entry != m_queriesBegun.end()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
EmitCs([cQuery = query]
|
||||||
|
(DxvkContext* ctx) {
|
||||||
|
cQuery->Begin(ctx);
|
||||||
|
});
|
||||||
|
|
||||||
|
m_queriesBegun.push_back(std::move(query));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void STDMETHODCALLTYPE D3D11DeferredContext::End(
|
||||||
|
ID3D11Asynchronous* pAsync) {
|
||||||
|
D3D10DeviceLock lock = LockContext();
|
||||||
|
|
||||||
|
if (unlikely(!pAsync))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Com<D3D11Query, false> query(static_cast<D3D11Query*>(pAsync));
|
||||||
|
|
||||||
|
if (query->IsScoped()) {
|
||||||
|
auto entry = std::find(
|
||||||
|
m_queriesBegun.begin(),
|
||||||
|
m_queriesBegun.end(), query);
|
||||||
|
|
||||||
|
if (unlikely(entry == m_queriesBegun.end()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_queriesBegun.erase(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_commandList->AddQuery(query.ptr());
|
||||||
|
|
||||||
|
EmitCs([cQuery = std::move(query)]
|
||||||
|
(DxvkContext* ctx) {
|
||||||
|
cQuery->End(ctx);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void STDMETHODCALLTYPE D3D11DeferredContext::Flush() {
|
void STDMETHODCALLTYPE D3D11DeferredContext::Flush() {
|
||||||
Logger::err("D3D11: Flush called on a deferred context");
|
Logger::err("D3D11: Flush called on a deferred context");
|
||||||
}
|
}
|
||||||
@ -83,6 +140,7 @@ namespace dxvk {
|
|||||||
ID3D11CommandList **ppCommandList) {
|
ID3D11CommandList **ppCommandList) {
|
||||||
D3D10DeviceLock lock = LockContext();
|
D3D10DeviceLock lock = LockContext();
|
||||||
|
|
||||||
|
FinalizeQueries();
|
||||||
FlushCsChunk();
|
FlushCsChunk();
|
||||||
|
|
||||||
if (ppCommandList != nullptr)
|
if (ppCommandList != nullptr)
|
||||||
@ -309,6 +367,20 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void D3D11DeferredContext::FinalizeQueries() {
|
||||||
|
for (auto& query : m_queriesBegun) {
|
||||||
|
m_commandList->AddQuery(query.ptr());
|
||||||
|
|
||||||
|
EmitCs([cQuery = std::move(query)]
|
||||||
|
(DxvkContext* ctx) {
|
||||||
|
cQuery->End(ctx);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
m_queriesBegun.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Com<D3D11CommandList> D3D11DeferredContext::CreateCommandList() {
|
Com<D3D11CommandList> D3D11DeferredContext::CreateCommandList() {
|
||||||
return new D3D11CommandList(m_parent, m_contextFlags);
|
return new D3D11CommandList(m_parent, m_contextFlags);
|
||||||
}
|
}
|
||||||
|
@ -33,11 +33,17 @@ namespace dxvk {
|
|||||||
UINT STDMETHODCALLTYPE GetContextFlags();
|
UINT STDMETHODCALLTYPE GetContextFlags();
|
||||||
|
|
||||||
HRESULT STDMETHODCALLTYPE GetData(
|
HRESULT STDMETHODCALLTYPE GetData(
|
||||||
ID3D11Asynchronous* pAsync,
|
ID3D11Asynchronous* pAsync,
|
||||||
void* pData,
|
void* pData,
|
||||||
UINT DataSize,
|
UINT DataSize,
|
||||||
UINT GetDataFlags);
|
UINT GetDataFlags);
|
||||||
|
|
||||||
|
void STDMETHODCALLTYPE Begin(
|
||||||
|
ID3D11Asynchronous* pAsync);
|
||||||
|
|
||||||
|
void STDMETHODCALLTYPE End(
|
||||||
|
ID3D11Asynchronous* pAsync);
|
||||||
|
|
||||||
void STDMETHODCALLTYPE Flush();
|
void STDMETHODCALLTYPE Flush();
|
||||||
|
|
||||||
void STDMETHODCALLTYPE Flush1(
|
void STDMETHODCALLTYPE Flush1(
|
||||||
@ -87,6 +93,9 @@ namespace dxvk {
|
|||||||
// number of mapped resources per command list.
|
// number of mapped resources per command list.
|
||||||
std::vector<D3D11DeferredContextMapEntry> m_mappedResources;
|
std::vector<D3D11DeferredContextMapEntry> m_mappedResources;
|
||||||
|
|
||||||
|
// Begun and ended queries, will also be stored in command list
|
||||||
|
std::vector<Com<D3D11Query, false>> m_queriesBegun;
|
||||||
|
|
||||||
HRESULT MapBuffer(
|
HRESULT MapBuffer(
|
||||||
ID3D11Resource* pResource,
|
ID3D11Resource* pResource,
|
||||||
D3D11_MAP MapType,
|
D3D11_MAP MapType,
|
||||||
@ -100,6 +109,8 @@ namespace dxvk {
|
|||||||
UINT MapFlags,
|
UINT MapFlags,
|
||||||
D3D11DeferredContextMapEntry* pMapEntry);
|
D3D11DeferredContextMapEntry* pMapEntry);
|
||||||
|
|
||||||
|
void FinalizeQueries();
|
||||||
|
|
||||||
Com<D3D11CommandList> CreateCommandList();
|
Com<D3D11CommandList> CreateCommandList();
|
||||||
|
|
||||||
void EmitCsChunk(DxvkCsChunkRef&& chunk);
|
void EmitCsChunk(DxvkCsChunkRef&& chunk);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user