diff --git a/agent/src/capture.hpp b/agent/src/capture.hpp index 102d37f..8e5161b 100644 --- a/agent/src/capture.hpp +++ b/agent/src/capture.hpp @@ -13,7 +13,6 @@ namespace hazelnut { // Framebuffer information struct FramebufferInformation { - u32* pFramebuffer; u32 width; u32 height; }; @@ -31,12 +30,8 @@ namespace hazelnut { virtual bool Initialize() = 0; - /// New CaptureFrame() API; now capture is copied directly to output buffer - /// instead of copy->copy. - virtual DisplayCaptureResult CaptureFrameTemp(u32* pOut) = 0; - - /// Performs the capture. THIS VERSION IS DEPRECATED AND WILL BE REMOVED - virtual DisplayCaptureResult CaptureFrame() = 0; + /// Captures frame to provided output buffer directly. + virtual DisplayCaptureResult CaptureFrame(u32* pOut) = 0; /// Get framebuffer information. virtual FramebufferInformation GetFramebufferInformation() = 0; diff --git a/agent/src/capture_nvfbc.cpp b/agent/src/capture_nvfbc.cpp index 21af8ca..b286c55 100644 --- a/agent/src/capture_nvfbc.cpp +++ b/agent/src/capture_nvfbc.cpp @@ -68,8 +68,6 @@ namespace hazelnut { u32 height; u32* pRawFramebuffer; - unique_buffer convertedFramebuffer; - u8* pDiffMap; u32 diffmapWidth; @@ -224,7 +222,7 @@ namespace hazelnut { } } - DisplayCaptureResult CaptureFrameTemp(u32* pOut) override { + DisplayCaptureResult CaptureFrame(u32* pOut) override { auto nvStatus = nvfbc->NvFBCToSysGrabFrame(&this->fbcSysGrabParams); switch(nvStatus) { @@ -237,7 +235,7 @@ namespace hazelnut { // Recurse. This looks naughty, but will allow us to directly retry // the capture. (Plus if this causes issues whatever has happened is probably beyond saving) - return CaptureFrame(); + return CaptureFrame(pOut); } break; default: return DisplayCaptureResult::Fail; @@ -272,62 +270,7 @@ namespace hazelnut { return result; } - DisplayCaptureResult CaptureFrame() override { - auto nvStatus = nvfbc->NvFBCToSysGrabFrame(&this->fbcSysGrabParams); - - switch(nvStatus) { - case NVFBC_SUCCESS: break; - - // Need to recreate the session. If it fails then we fail too. - case NVFBC_ERROR_INVALIDATED_SESSION: { - if(!NvfbcInitSession()) - return DisplayCaptureResult::Fail; - - // Recurse. This looks naughty, but will allow us to directly retry - // the capture. (Plus if this causes issues whatever has happened is probably beyond saving) - return CaptureFrame(); - } break; - - default: return DisplayCaptureResult::Fail; - } - - if(width != grabInfo.dwWidth || height != grabInfo.dwHeight) { - width = grabInfo.dwWidth; - height = grabInfo.dwHeight; - - convertedFramebuffer.resize(width * height); - - return DisplayCaptureResult::OkButResized; - } - - // Splat to the converted framebuffer. It doesn't have padding on it. - auto* pBufferData = (u8*)convertedFramebuffer.data(); - auto* pSrcData = (u8*)&pRawFramebuffer[0]; - - for(u32 y = 0; y < grabInfo.dwHeight; ++y) { - // Convert to BGRA - // FIXME: Make this SIMD. I can't into this very well -#if 0 - usize srcStart = (y * grabInfo.dwBufferWidth) * 4; - usize dstStart = (y * width) * 4; - for(u32 x = 0; x < grabInfo.dwWidth * 4; x += 4) { - pBufferData[(dstStart + x) + 0] = pSrcData[(srcStart + x) + 2]; // B - pBufferData[(dstStart + x) + 1] = pSrcData[(srcStart + x) + 1]; // G - pBufferData[(dstStart + x) + 2] = pSrcData[(srcStart + x) + 0]; // R - pBufferData[(dstStart + x) + 3] = 0xff; // A - } -#endif - - memcpy(&pBufferData[(y * width) * 4], &pRawFramebuffer[(y * grabInfo.dwBufferWidth)], grabInfo.dwWidth * 4); - } - - // sleep - // nvfbc->NvFBCToSysGPUBasedCPUSleep(16000); - - return DisplayCaptureResult::Ok; - } - - FramebufferInformation GetFramebufferInformation() override { return FramebufferInformation { convertedFramebuffer.data(), width, height }; } + FramebufferInformation GetFramebufferInformation() override { return FramebufferInformation { width, height }; } DiffInformation GetDiffInformation() override { // diffmapWidth = (u32)ceil((f32)width / 32); diff --git a/agent/src/main.cpp b/agent/src/main.cpp index 5091d49..2adcdc2 100755 --- a/agent/src/main.cpp +++ b/agent/src/main.cpp @@ -51,14 +51,7 @@ int main(int argc, char** argv) { while(true) { { auto guard = pHeader->lock.lock(); - - - - auto result = pCaptureInterface->CaptureFrameTemp(pFrameHeader->bits( - pFrameHeader->serial.load() % hazelnut::kNrFramesQueued, - framebuffer.width, - framebuffer.height - )); + auto result = pCaptureInterface->CaptureFrame(pFrameHeader->bits()); switch(result) { case hazelnut::DisplayCaptureResult::Ok: