mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-26 07:17:23 +00:00
[host] dxgi: wait for sync before trying to read the memory map
This commit is contained in:
parent
e298f9169c
commit
0d1d49b00e
@ -196,12 +196,25 @@ bool DXGI::Initialize(CaptureOptions * options)
|
|||||||
}
|
}
|
||||||
m_surfaceMapped = true;
|
m_surfaceMapped = true;
|
||||||
|
|
||||||
|
D3D11_QUERY_DESC qd;
|
||||||
|
qd.MiscFlags = 0;
|
||||||
|
qd.Query = D3D11_QUERY_EVENT;
|
||||||
|
if (FAILED(m_device->CreateQuery(&qd, &this->m_eventQuery)))
|
||||||
|
{
|
||||||
|
DEBUG_ERROR("Failed to create event query");
|
||||||
|
DeInitialize();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
m_initialized = true;
|
m_initialized = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DXGI::DeInitialize()
|
void DXGI::DeInitialize()
|
||||||
{
|
{
|
||||||
|
if (m_eventQuery)
|
||||||
|
m_eventQuery.Release();
|
||||||
|
|
||||||
if (m_releaseFrame)
|
if (m_releaseFrame)
|
||||||
{
|
{
|
||||||
m_releaseFrame = false;
|
m_releaseFrame = false;
|
||||||
@ -434,6 +447,7 @@ GrabStatus DXGI::GrabFrame(FrameInfo & frame)
|
|||||||
|
|
||||||
src->GetDesc(&m_desc);
|
src->GetDesc(&m_desc);
|
||||||
m_deviceContext->CopyResource(m_texture, src);
|
m_deviceContext->CopyResource(m_texture, src);
|
||||||
|
m_deviceContext->End(m_eventQuery);
|
||||||
src.Release();
|
src.Release();
|
||||||
|
|
||||||
m_width = m_desc.Width;
|
m_width = m_desc.Width;
|
||||||
@ -443,8 +457,10 @@ GrabStatus DXGI::GrabFrame(FrameInfo & frame)
|
|||||||
frame.height = m_desc.Height;
|
frame.height = m_desc.Height;
|
||||||
frame.pitch = m_mapping.RowPitch;
|
frame.pitch = m_mapping.RowPitch;
|
||||||
frame.stride = m_mapping.RowPitch / 4;
|
frame.stride = m_mapping.RowPitch / 4;
|
||||||
|
|
||||||
unsigned int size = m_height * m_mapping.RowPitch;
|
unsigned int size = m_height * m_mapping.RowPitch;
|
||||||
|
|
||||||
|
// wait for the copy to complete before trying to perform the copy
|
||||||
|
while(S_FALSE == m_deviceContext->GetData(m_eventQuery, NULL, 0, 0)) {}
|
||||||
memcpySSE(frame.buffer, m_mapping.pData, size < frame.bufferSize ? size : frame.bufferSize);
|
memcpySSE(frame.buffer, m_mapping.pData, size < frame.bufferSize ? size : frame.bufferSize);
|
||||||
|
|
||||||
return GRAB_STATUS_OK;
|
return GRAB_STATUS_OK;
|
||||||
|
@ -32,6 +32,7 @@ _COM_SMARTPTR_TYPEDEF(IDXGIFactory1 , __uuidof(IDXGIFactory1 ));
|
|||||||
_COM_SMARTPTR_TYPEDEF(ID3D11Device , __uuidof(ID3D11Device ));
|
_COM_SMARTPTR_TYPEDEF(ID3D11Device , __uuidof(ID3D11Device ));
|
||||||
_COM_SMARTPTR_TYPEDEF(ID3D11DeviceContext , __uuidof(ID3D11DeviceContext ));
|
_COM_SMARTPTR_TYPEDEF(ID3D11DeviceContext , __uuidof(ID3D11DeviceContext ));
|
||||||
_COM_SMARTPTR_TYPEDEF(IDXGIDevice , __uuidof(IDXGIDevice ));
|
_COM_SMARTPTR_TYPEDEF(IDXGIDevice , __uuidof(IDXGIDevice ));
|
||||||
|
_COM_SMARTPTR_TYPEDEF(ID3D11Query , __uuidof(ID3D11Query ));
|
||||||
_COM_SMARTPTR_TYPEDEF(IDXGIOutput1 , __uuidof(IDXGIOutput1 ));
|
_COM_SMARTPTR_TYPEDEF(IDXGIOutput1 , __uuidof(IDXGIOutput1 ));
|
||||||
_COM_SMARTPTR_TYPEDEF(IDXGIOutput , __uuidof(IDXGIOutput ));
|
_COM_SMARTPTR_TYPEDEF(IDXGIOutput , __uuidof(IDXGIOutput ));
|
||||||
_COM_SMARTPTR_TYPEDEF(IDXGIAdapter1 , __uuidof(IDXGIAdapter1 ));
|
_COM_SMARTPTR_TYPEDEF(IDXGIAdapter1 , __uuidof(IDXGIAdapter1 ));
|
||||||
@ -84,6 +85,7 @@ namespace Capture
|
|||||||
bool m_releaseFrame;
|
bool m_releaseFrame;
|
||||||
ID3D11Texture2DPtr m_texture;
|
ID3D11Texture2DPtr m_texture;
|
||||||
D3D11_TEXTURE2D_DESC m_desc;
|
D3D11_TEXTURE2D_DESC m_desc;
|
||||||
|
ID3D11QueryPtr m_eventQuery;
|
||||||
D3D11_MAPPED_SUBRESOURCE m_mapping;
|
D3D11_MAPPED_SUBRESOURCE m_mapping;
|
||||||
bool m_surfaceMapped;
|
bool m_surfaceMapped;
|
||||||
BYTE * m_pointer;
|
BYTE * m_pointer;
|
||||||
|
Loading…
Reference in New Issue
Block a user