1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-31 05:52:11 +01:00

[d3d11] Do not use QueryInterface to get query pointers

We're not going to implement counters anyway, so this is
unnecessary overhead.
This commit is contained in:
Philip Rebohle 2018-10-17 17:19:07 +02:00
parent 5ab6f691ae
commit 5ecfbd8425
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 22 additions and 40 deletions

View File

@ -226,18 +226,13 @@ namespace dxvk {
if (!pAsync) if (!pAsync)
return; return;
Com<ID3D11Query> query; Com<D3D11Query> queryPtr = static_cast<D3D11Query*>(pAsync);
if (SUCCEEDED(pAsync->QueryInterface(__uuidof(ID3D11Query), reinterpret_cast<void**>(&query)))) {
Com<D3D11Query> queryPtr = static_cast<D3D11Query*>(query.ptr());
if (queryPtr->HasBeginEnabled()) { if (queryPtr->HasBeginEnabled()) {
const uint32_t revision = queryPtr->Reset(); uint32_t revision = queryPtr->Reset();
EmitCs([revision, queryPtr] (DxvkContext* ctx) {
EmitCs([revision, queryPtr] (DxvkContext* ctx) { queryPtr->Begin(ctx, revision);
queryPtr->Begin(ctx, revision); });
});
}
} }
} }
@ -246,22 +241,17 @@ namespace dxvk {
if (!pAsync) if (!pAsync)
return; return;
Com<ID3D11Query> query; Com<D3D11Query> queryPtr = static_cast<D3D11Query*>(pAsync);
if (SUCCEEDED(pAsync->QueryInterface(__uuidof(ID3D11Query), reinterpret_cast<void**>(&query)))) { if (queryPtr->HasBeginEnabled()) {
Com<D3D11Query> queryPtr = static_cast<D3D11Query*>(query.ptr()); EmitCs([queryPtr] (DxvkContext* ctx) {
queryPtr->End(ctx);
if (queryPtr->HasBeginEnabled()) { });
EmitCs([queryPtr] (DxvkContext* ctx) { } else {
queryPtr->End(ctx); uint32_t revision = queryPtr->Reset();
}); EmitCs([revision, queryPtr] (DxvkContext* ctx) {
} else { queryPtr->Signal(ctx, revision);
const uint32_t revision = queryPtr->Reset(); });
EmitCs([revision, queryPtr] (DxvkContext* ctx) {
queryPtr->Signal(ctx, revision);
});
}
} }
} }

View File

@ -53,12 +53,15 @@ namespace dxvk {
void* pData, void* pData,
UINT DataSize, UINT DataSize,
UINT GetDataFlags) { UINT GetDataFlags) {
if (!pAsync)
return E_INVALIDARG;
// Make sure that we can safely write to the memory // Make sure that we can safely write to the memory
// location pointed to by pData if it is specified. // location pointed to by pData if it is specified.
if (DataSize == 0) if (DataSize == 0)
pData = nullptr; pData = nullptr;
if (pData != nullptr && pAsync->GetDataSize() != DataSize) { if (pData && pAsync->GetDataSize() != DataSize) {
Logger::err(str::format( Logger::err(str::format(
"D3D11: GetData: Data size mismatch", "D3D11: GetData: Data size mismatch",
"\n Expected: ", pAsync->GetDataSize(), "\n Expected: ", pAsync->GetDataSize(),
@ -66,25 +69,14 @@ namespace dxvk {
return E_INVALIDARG; return E_INVALIDARG;
} }
// Default error return for unsupported interfaces // Get query status directly from the query object
HRESULT hr = E_INVALIDARG; HRESULT hr = static_cast<D3D11Query*>(pAsync)->GetData(pData, GetDataFlags);
// This method can handle various incompatible interfaces,
// so we have to find out what we are actually dealing with
Com<ID3D11Query> query;
if (SUCCEEDED(pAsync->QueryInterface(__uuidof(ID3D11Query), reinterpret_cast<void**>(&query))))
hr = static_cast<D3D11Query*>(query.ptr())->GetData(pData, GetDataFlags);
// If we're likely going to spin on the asynchronous object, // If we're likely going to spin on the asynchronous object,
// flush the context so that we're keeping the GPU busy // flush the context so that we're keeping the GPU busy
if (hr == S_FALSE) if (hr == S_FALSE)
FlushImplicit(); FlushImplicit();
// The requested interface is not supported
if (FAILED(hr))
Logger::err("D3D11: GetData: Unsupported Async type");
return hr; return hr;
} }