remove old CaptureFrame() api
This commit is contained in:
parent
e0e56026cb
commit
51af8d2f14
3 changed files with 6 additions and 75 deletions
|
@ -13,7 +13,6 @@ namespace hazelnut {
|
||||||
|
|
||||||
// Framebuffer information
|
// Framebuffer information
|
||||||
struct FramebufferInformation {
|
struct FramebufferInformation {
|
||||||
u32* pFramebuffer;
|
|
||||||
u32 width;
|
u32 width;
|
||||||
u32 height;
|
u32 height;
|
||||||
};
|
};
|
||||||
|
@ -31,12 +30,8 @@ namespace hazelnut {
|
||||||
|
|
||||||
virtual bool Initialize() = 0;
|
virtual bool Initialize() = 0;
|
||||||
|
|
||||||
/// New CaptureFrame() API; now capture is copied directly to output buffer
|
/// Captures frame to provided output buffer directly.
|
||||||
/// instead of copy->copy.
|
virtual DisplayCaptureResult CaptureFrame(u32* pOut) = 0;
|
||||||
virtual DisplayCaptureResult CaptureFrameTemp(u32* pOut) = 0;
|
|
||||||
|
|
||||||
/// Performs the capture. THIS VERSION IS DEPRECATED AND WILL BE REMOVED
|
|
||||||
virtual DisplayCaptureResult CaptureFrame() = 0;
|
|
||||||
|
|
||||||
/// Get framebuffer information.
|
/// Get framebuffer information.
|
||||||
virtual FramebufferInformation GetFramebufferInformation() = 0;
|
virtual FramebufferInformation GetFramebufferInformation() = 0;
|
||||||
|
|
|
@ -68,8 +68,6 @@ namespace hazelnut {
|
||||||
u32 height;
|
u32 height;
|
||||||
|
|
||||||
u32* pRawFramebuffer;
|
u32* pRawFramebuffer;
|
||||||
unique_buffer<u32> convertedFramebuffer;
|
|
||||||
|
|
||||||
u8* pDiffMap;
|
u8* pDiffMap;
|
||||||
|
|
||||||
u32 diffmapWidth;
|
u32 diffmapWidth;
|
||||||
|
@ -224,7 +222,7 @@ namespace hazelnut {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DisplayCaptureResult CaptureFrameTemp(u32* pOut) override {
|
DisplayCaptureResult CaptureFrame(u32* pOut) override {
|
||||||
auto nvStatus = nvfbc->NvFBCToSysGrabFrame(&this->fbcSysGrabParams);
|
auto nvStatus = nvfbc->NvFBCToSysGrabFrame(&this->fbcSysGrabParams);
|
||||||
|
|
||||||
switch(nvStatus) {
|
switch(nvStatus) {
|
||||||
|
@ -237,7 +235,7 @@ namespace hazelnut {
|
||||||
|
|
||||||
// Recurse. This looks naughty, but will allow us to directly retry
|
// 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)
|
// the capture. (Plus if this causes issues whatever has happened is probably beyond saving)
|
||||||
return CaptureFrame();
|
return CaptureFrame(pOut);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
default: return DisplayCaptureResult::Fail;
|
default: return DisplayCaptureResult::Fail;
|
||||||
|
@ -272,62 +270,7 @@ namespace hazelnut {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
DisplayCaptureResult CaptureFrame() override {
|
FramebufferInformation GetFramebufferInformation() override { return FramebufferInformation { width, height }; }
|
||||||
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 }; }
|
|
||||||
|
|
||||||
DiffInformation GetDiffInformation() override {
|
DiffInformation GetDiffInformation() override {
|
||||||
// diffmapWidth = (u32)ceil((f32)width / 32);
|
// diffmapWidth = (u32)ceil((f32)width / 32);
|
||||||
|
|
|
@ -51,14 +51,7 @@ int main(int argc, char** argv) {
|
||||||
while(true) {
|
while(true) {
|
||||||
{
|
{
|
||||||
auto guard = pHeader->lock.lock();
|
auto guard = pHeader->lock.lock();
|
||||||
|
auto result = pCaptureInterface->CaptureFrame(pFrameHeader->bits());
|
||||||
|
|
||||||
|
|
||||||
auto result = pCaptureInterface->CaptureFrameTemp(pFrameHeader->bits(
|
|
||||||
pFrameHeader->serial.load() % hazelnut::kNrFramesQueued,
|
|
||||||
framebuffer.width,
|
|
||||||
framebuffer.height
|
|
||||||
));
|
|
||||||
|
|
||||||
switch(result) {
|
switch(result) {
|
||||||
case hazelnut::DisplayCaptureResult::Ok:
|
case hazelnut::DisplayCaptureResult::Ok:
|
||||||
|
|
Loading…
Reference in a new issue