mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-02-18 22:54:15 +01:00
[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:
parent
e35cbf833c
commit
c716372941
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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");
|
||||
}
|
||||
|
@ -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(
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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(
|
||||
|
Loading…
x
Reference in New Issue
Block a user