Commit 34ae0df0 authored by Joshua Ashton's avatar Joshua Ashton 🐸

[d3d9] Handle query sizes of 0 and query checking.

parent 5d302339
Pipeline #52 passed with stage
in 1 minute and 36 seconds
......@@ -83,11 +83,13 @@ namespace dxup {
HRESULT STDMETHODCALLTYPE Direct3DQuery9::GetData(void* pData, DWORD dwSize, DWORD dwGetDataFlags) {
CriticalSection cs(m_device);
if (pData == nullptr)
return log::d3derr(D3DERR_INVALIDCALL, "GetData: pData was nullptr.");
if (pData != nullptr && dwSize != 0) {
if (pData == nullptr)
return log::d3derr(D3DERR_INVALIDCALL, "GetData: pData was nullptr.");
if (dwSize < GetDataSize())
return log::d3derr(D3DERR_INVALIDCALL, "GetData: dwSize was less than the required data size.");
if (dwSize < GetDataSize())
return log::d3derr(D3DERR_INVALIDCALL, "GetData: dwSize was less than the required data size.");
}
bool flush = dwGetDataFlags & D3DGETDATA_FLUSH;
......@@ -97,8 +99,12 @@ namespace dxup {
HRESULT result = m_device->GetContext()->GetData(m_query.ptr(), &queryData, GetD3D11DataSize(), flush ? 0 : D3D11_ASYNC_GETDATA_DONOTFLUSH);
std::memcpy(pData, &queryData, std::min((size_t)GetD3D11DataSize(), (size_t)dwSize));
if (FAILED(result))
return S_FALSE;
if (FAILED(result)) {
if (flush)
return D3DERR_INVALIDCALL;
else
return S_FALSE;
}
else
return D3D_OK;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment