[d3d11] Move GetData implementation to D3D11ImmediateContext

It is illegal to call this method on a deferred context, so we should
filter out those calls. This allows the implementation to make use of
features specific to the immediate context.
This commit is contained in:
Philip Rebohle 2018-06-08 12:29:24 +02:00
parent e35cbf833c
commit c716372941
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
6 changed files with 63 additions and 47 deletions

View File

@ -224,47 +224,6 @@ namespace dxvk {
}
HRESULT STDMETHODCALLTYPE D3D11DeviceContext::GetData(
ID3D11Asynchronous* pAsync,
void* pData,
UINT DataSize,
UINT GetDataFlags) {
// 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) {
Logger::err(str::format(
"D3D11: GetData: Data size mismatch",
"\n Expected: ", pAsync->GetDataSize(),
"\n Got: ", DataSize));
return E_INVALIDARG;
}
// Fallout 4 never actually calls this function without
// D3D11_ASYNC_GETDATA_DONOTFLUSH set, which may cause
// the game to freeze in certain situations.
if (m_parent->TestOption(D3D11Option::DisableGetDataFlagDoNotFlush))
GetDataFlags &= ~D3D11_ASYNC_GETDATA_DONOTFLUSH;
// Flush in order to make sure the query commands get dispatched
if ((GetDataFlags & D3D11_ASYNC_GETDATA_DONOTFLUSH) == 0)
Flush();
// This method handles various different but 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))))
return static_cast<D3D11Query*>(query.ptr())->GetData(pData, GetDataFlags);
// The interface is not supported
Logger::err("D3D11: GetData: Unsupported Async type");
return E_INVALIDARG;
}
void STDMETHODCALLTYPE D3D11DeviceContext::SetPredication(
ID3D11Predicate* pPredicate,
BOOL PredicateValue) {

View File

@ -45,12 +45,6 @@ namespace dxvk {
void STDMETHODCALLTYPE End(ID3D11Asynchronous *pAsync) final;
HRESULT STDMETHODCALLTYPE GetData(
ID3D11Asynchronous* pAsync,
void* pData,
UINT DataSize,
UINT GetDataFlags) final;
void STDMETHODCALLTYPE SetPredication(
ID3D11Predicate* pPredicate,
BOOL PredicateValue) final;

View File

@ -23,6 +23,16 @@ namespace dxvk {
}
HRESULT STDMETHODCALLTYPE D3D11DeferredContext::GetData(
ID3D11Asynchronous* pAsync,
void* pData,
UINT DataSize,
UINT GetDataFlags) {
Logger::err("D3D11: GetData called on a deferred context");
return DXGI_ERROR_INVALID_CALL;
}
void STDMETHODCALLTYPE D3D11DeferredContext::Flush() {
Logger::err("D3D11: Flush called on a deferred context");
}

View File

@ -34,6 +34,12 @@ namespace dxvk {
UINT STDMETHODCALLTYPE GetContextFlags() final;
HRESULT STDMETHODCALLTYPE GetData(
ID3D11Asynchronous* pAsync,
void* pData,
UINT DataSize,
UINT GetDataFlags) final;
void STDMETHODCALLTYPE Flush() final;
void STDMETHODCALLTYPE ExecuteCommandList(

View File

@ -45,6 +45,47 @@ namespace dxvk {
}
HRESULT STDMETHODCALLTYPE D3D11ImmediateContext::GetData(
ID3D11Asynchronous* pAsync,
void* pData,
UINT DataSize,
UINT GetDataFlags) {
// 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) {
Logger::err(str::format(
"D3D11: GetData: Data size mismatch",
"\n Expected: ", pAsync->GetDataSize(),
"\n Got: ", DataSize));
return E_INVALIDARG;
}
// Fallout 4 never actually calls this function without
// D3D11_ASYNC_GETDATA_DONOTFLUSH set, which may cause
// the game to freeze in certain situations.
if (m_parent->TestOption(D3D11Option::DisableGetDataFlagDoNotFlush))
GetDataFlags &= ~D3D11_ASYNC_GETDATA_DONOTFLUSH;
// Flush in order to make sure the query commands get dispatched
if ((GetDataFlags & D3D11_ASYNC_GETDATA_DONOTFLUSH) == 0)
Flush();
// This method handles various different but 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))))
return static_cast<D3D11Query*>(query.ptr())->GetData(pData, GetDataFlags);
// The interface is not supported
Logger::err("D3D11: GetData: Unsupported Async type");
return E_INVALIDARG;
}
void STDMETHODCALLTYPE D3D11ImmediateContext::Flush() {
m_parent->FlushInitContext();

View File

@ -27,6 +27,12 @@ namespace dxvk {
UINT STDMETHODCALLTYPE GetContextFlags() final;
HRESULT STDMETHODCALLTYPE GetData(
ID3D11Asynchronous* pAsync,
void* pData,
UINT DataSize,
UINT GetDataFlags) final;
void STDMETHODCALLTYPE Flush() final;
void STDMETHODCALLTYPE ExecuteCommandList(