diff --git a/c-host/Makefile b/c-host/Makefile index cf0669b0..e5f940d7 100644 --- a/c-host/Makefile +++ b/c-host/Makefile @@ -5,7 +5,7 @@ OUTPUT = looking-glass-host EXT = CFLAGS = -std=gnu99 -Wall -Werror -CFLAGS += -g -O0 +CFLAGS += -g -O3 CFLAGS += -I. CFLAGS += -I../common diff --git a/c-host/windows/capture/dxgi.c b/c-host/windows/capture/dxgi.c index 0636ba59..41cdf98f 100644 --- a/c-host/windows/capture/dxgi.c +++ b/c-host/windows/capture/dxgi.c @@ -40,7 +40,7 @@ struct iface D3D_FEATURE_LEVEL featureLevel; IDXGIOutputDuplication * dup; ID3D11Texture2D * texture; - bool hasFrame; + bool needsRelease; unsigned int width; unsigned int height; @@ -424,7 +424,7 @@ static CaptureResult dxgi_capture(bool * hasFrameUpdate, bool * hasPointerUpdate switch(status) { case S_OK: - this->hasFrame = true; + this->needsRelease = true; break; case DXGI_ERROR_WAIT_TIMEOUT: @@ -447,17 +447,20 @@ static CaptureResult dxgi_capture(bool * hasFrameUpdate, bool * hasPointerUpdate return CAPTURE_RESULT_ERROR; } - ID3D11DeviceContext_CopyResource(this->deviceContext, - (ID3D11Resource *)this->texture, (ID3D11Resource *)src); + if (frameInfo.LastPresentTime.QuadPart != 0) + { + ID3D11DeviceContext_CopyResource(this->deviceContext, + (ID3D11Resource *)this->texture, (ID3D11Resource *)src); - ID3D11Texture2D_Release(src); - IDXGIResource_Release(res); - - *hasFrameUpdate = true; + ID3D11Texture2D_Release(src); + *hasFrameUpdate = true; + } if (frameInfo.PointerShapeBufferSize > 0) *hasPointerUpdate = true; + IDXGIResource_Release(res); + return CAPTURE_RESULT_OK; } @@ -490,7 +493,7 @@ static bool dxgi_getFrame(CaptureFrame * frame) static CaptureResult dxgi_releaseFrame() { assert(this); - if (!this->hasFrame) + if (!this->needsRelease) return CAPTURE_RESULT_OK; HRESULT status = IDXGIOutputDuplication_ReleaseFrame(this->dup); @@ -506,7 +509,7 @@ static CaptureResult dxgi_releaseFrame() case WAIT_ABANDONED: case DXGI_ERROR_ACCESS_LOST: { - this->hasFrame = false; + this->needsRelease = false; return CAPTURE_RESULT_REINIT; } @@ -515,7 +518,7 @@ static CaptureResult dxgi_releaseFrame() return CAPTURE_RESULT_ERROR; } - this->hasFrame = false; + this->needsRelease = false; return CAPTURE_RESULT_OK; }