[d3d11] Move query state tracking to immediate context implementation

This commit is contained in:
Philip Rebohle 2019-11-02 13:24:36 +01:00
parent be5dc234c1
commit 0924bb469c
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
4 changed files with 33 additions and 14 deletions

View File

@ -68,6 +68,9 @@ namespace dxvk {
void D3D11CommandList::EmitToCsThread(DxvkCsThread* CsThread) { void D3D11CommandList::EmitToCsThread(DxvkCsThread* CsThread) {
for (const auto& query : m_queries)
query->DoDeferredEnd();
for (const auto& chunk : m_chunks) for (const auto& chunk : m_chunks)
CsThread->dispatchChunk(DxvkCsChunkRef(chunk)); CsThread->dispatchChunk(DxvkCsChunkRef(chunk));

View File

@ -110,7 +110,7 @@ namespace dxvk {
Com<D3D11Query, false> query(static_cast<D3D11Query*>(pAsync)); Com<D3D11Query, false> query(static_cast<D3D11Query*>(pAsync));
if (unlikely(!query->IsScoped())) if (unlikely(!query->DoBegin()))
return; return;
EmitCs([cQuery = std::move(query)] EmitCs([cQuery = std::move(query)]
@ -128,6 +128,9 @@ namespace dxvk {
Com<D3D11Query, false> query(static_cast<D3D11Query*>(pAsync)); Com<D3D11Query, false> query(static_cast<D3D11Query*>(pAsync));
if (unlikely(!query->DoEnd()))
return;
if (unlikely(query->IsEvent())) { if (unlikely(query->IsEvent())) {
query->NotifyEnd(); query->NotifyEnd();
query->IsStalling() query->IsStalling()

View File

@ -182,9 +182,6 @@ namespace dxvk {
void D3D11Query::Begin(DxvkContext* ctx) { void D3D11Query::Begin(DxvkContext* ctx) {
if (unlikely(m_state == D3D11_VK_QUERY_BEGUN))
return;
switch (m_desc.Query) { switch (m_desc.Query) {
case D3D11_QUERY_EVENT: case D3D11_QUERY_EVENT:
case D3D11_QUERY_TIMESTAMP: case D3D11_QUERY_TIMESTAMP:
@ -197,8 +194,6 @@ namespace dxvk {
default: default:
ctx->beginQuery(m_query[0]); ctx->beginQuery(m_query[0]);
} }
m_state = D3D11_VK_QUERY_BEGUN;
} }
@ -214,16 +209,28 @@ namespace dxvk {
break; break;
default: default:
if (unlikely(m_state != D3D11_VK_QUERY_BEGUN))
return;
ctx->endQuery(m_query[0]); ctx->endQuery(m_query[0]);
} }
if (unlikely(m_predicate != nullptr)) if (unlikely(m_predicate != nullptr))
ctx->writePredicate(DxvkBufferSlice(m_predicate), m_query[0]); ctx->writePredicate(DxvkBufferSlice(m_predicate), m_query[0]);
}
bool STDMETHODCALLTYPE D3D11Query::DoBegin() {
if (!IsScoped() || m_state == D3D11_VK_QUERY_BEGUN)
return false;
m_state = D3D11_VK_QUERY_BEGUN;
return true;
}
bool STDMETHODCALLTYPE D3D11Query::DoEnd() {
if (IsScoped() && m_state != D3D11_VK_QUERY_BEGUN)
return false;
m_state = D3D11_VK_QUERY_ENDED; m_state = D3D11_VK_QUERY_ENDED;
return true;
} }
@ -327,9 +334,6 @@ namespace dxvk {
if (unlikely(m_desc.Query != D3D11_QUERY_OCCLUSION_PREDICATE)) if (unlikely(m_desc.Query != D3D11_QUERY_OCCLUSION_PREDICATE))
return DxvkBufferSlice(); return DxvkBufferSlice();
if (unlikely(m_state != D3D11_VK_QUERY_ENDED))
return DxvkBufferSlice();
if (unlikely(m_predicate != nullptr)) { if (unlikely(m_predicate != nullptr)) {
m_predicate = CreatePredicateBuffer(); m_predicate = CreatePredicateBuffer();
ctx->writePredicate(DxvkBufferSlice(m_predicate), m_query[0]); ctx->writePredicate(DxvkBufferSlice(m_predicate), m_query[0]);

View File

@ -43,12 +43,21 @@ namespace dxvk {
void End(DxvkContext* ctx); void End(DxvkContext* ctx);
bool STDMETHODCALLTYPE DoBegin();
bool STDMETHODCALLTYPE DoEnd();
HRESULT STDMETHODCALLTYPE GetData( HRESULT STDMETHODCALLTYPE GetData(
void* pData, void* pData,
UINT GetDataFlags); UINT GetDataFlags);
DxvkBufferSlice GetPredicate(DxvkContext* ctx); DxvkBufferSlice GetPredicate(DxvkContext* ctx);
void DoDeferredEnd() {
m_state = D3D11_VK_QUERY_ENDED;
m_resetCtr += 1;
}
bool IsScoped() const { bool IsScoped() const {
return m_desc.Query != D3D11_QUERY_EVENT return m_desc.Query != D3D11_QUERY_EVENT
&& m_desc.Query != D3D11_QUERY_TIMESTAMP; && m_desc.Query != D3D11_QUERY_TIMESTAMP;