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

View File

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