mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-08-05 18:24:08 +00:00
[host] kvmfr: allow the frame size to exceed the available memory
This change allows the host to still transmit a frame that is truncated if the IVSHMEM size is too small to allow for a full frame.
This commit is contained in:
@@ -714,14 +714,6 @@ static void dxgi_free(void)
|
||||
this = NULL;
|
||||
}
|
||||
|
||||
static unsigned int dxgi_getMaxFrameSize(void)
|
||||
{
|
||||
assert(this);
|
||||
assert(this->initialized);
|
||||
|
||||
return this->height * this->pitch;
|
||||
}
|
||||
|
||||
static unsigned int dxgi_getMouseScale(void)
|
||||
{
|
||||
assert(this);
|
||||
@@ -928,7 +920,7 @@ static CaptureResult dxgi_capture(void)
|
||||
return CAPTURE_RESULT_OK;
|
||||
}
|
||||
|
||||
static CaptureResult dxgi_waitFrame(CaptureFrame * frame)
|
||||
static CaptureResult dxgi_waitFrame(CaptureFrame * frame, const size_t maxFrameSize)
|
||||
{
|
||||
assert(this);
|
||||
assert(this->initialized);
|
||||
@@ -980,26 +972,30 @@ static CaptureResult dxgi_waitFrame(CaptureFrame * frame)
|
||||
|
||||
tex->state = TEXTURE_STATE_MAPPED;
|
||||
|
||||
frame->formatVer = tex->formatVer;
|
||||
frame->width = this->width;
|
||||
frame->height = this->height;
|
||||
frame->pitch = this->pitch;
|
||||
frame->stride = this->stride;
|
||||
frame->format = this->format;
|
||||
frame->rotation = this->rotation;
|
||||
const unsigned int maxHeight = maxFrameSize / this->pitch;
|
||||
|
||||
frame->formatVer = tex->formatVer;
|
||||
frame->width = this->width;
|
||||
frame->height = maxHeight > this->height ? this->height : maxHeight;
|
||||
frame->realHeight = this->height;
|
||||
frame->pitch = this->pitch;
|
||||
frame->stride = this->stride;
|
||||
frame->format = this->format;
|
||||
frame->rotation = this->rotation;
|
||||
|
||||
atomic_fetch_sub_explicit(&this->texReady, 1, memory_order_release);
|
||||
return CAPTURE_RESULT_OK;
|
||||
}
|
||||
|
||||
static CaptureResult dxgi_getFrame(FrameBuffer * frame)
|
||||
static CaptureResult dxgi_getFrame(FrameBuffer * frame,
|
||||
const unsigned int height)
|
||||
{
|
||||
assert(this);
|
||||
assert(this->initialized);
|
||||
|
||||
Texture * tex = &this->texture[this->texRIndex];
|
||||
|
||||
framebuffer_write(frame, tex->map.pData, this->pitch * this->height);
|
||||
framebuffer_write(frame, tex->map.pData, this->pitch * height);
|
||||
LOCKED({ID3D11DeviceContext_Unmap(this->deviceContext, (ID3D11Resource*)tex->tex, 0);});
|
||||
tex->state = TEXTURE_STATE_UNUSED;
|
||||
|
||||
@@ -1052,7 +1048,6 @@ struct CaptureInterface Capture_DXGI =
|
||||
.stop = dxgi_stop,
|
||||
.deinit = dxgi_deinit,
|
||||
.free = dxgi_free,
|
||||
.getMaxFrameSize = dxgi_getMaxFrameSize,
|
||||
.getMouseScale = dxgi_getMouseScale,
|
||||
.capture = dxgi_capture,
|
||||
.waitFrame = dxgi_waitFrame,
|
||||
|
@@ -275,11 +275,6 @@ static void nvfbc_free(void)
|
||||
NvFBCFree();
|
||||
}
|
||||
|
||||
static unsigned int nvfbc_getMaxFrameSize(void)
|
||||
{
|
||||
return this->maxWidth * this->maxHeight * 4;
|
||||
}
|
||||
|
||||
static unsigned int nvfbc_getMouseScale(void)
|
||||
{
|
||||
return this->dpi * 100 / DPI_100_PERCENT;
|
||||
@@ -320,7 +315,8 @@ static CaptureResult nvfbc_capture(void)
|
||||
return CAPTURE_RESULT_OK;
|
||||
}
|
||||
|
||||
static CaptureResult nvfbc_waitFrame(CaptureFrame * frame)
|
||||
static CaptureResult nvfbc_waitFrame(CaptureFrame * frame,
|
||||
const size_t maxFrameSize)
|
||||
{
|
||||
if (!lgWaitEvent(this->frameEvent, 1000))
|
||||
return CAPTURE_RESULT_TIMEOUT;
|
||||
@@ -339,12 +335,15 @@ static CaptureResult nvfbc_waitFrame(CaptureFrame * frame)
|
||||
++this->formatVer;
|
||||
}
|
||||
|
||||
frame->formatVer = this->formatVer;
|
||||
frame->width = this->grabWidth;
|
||||
frame->height = this->grabHeight;
|
||||
frame->pitch = this->grabStride * 4;
|
||||
frame->stride = this->grabStride;
|
||||
frame->rotation = CAPTURE_ROT_0;
|
||||
const unsigned int maxHeight = maxFrameSize / (this->grabStride * 4);
|
||||
|
||||
frame->formatVer = this->formatVer;
|
||||
frame->width = this->grabWidth;
|
||||
frame->height = maxHeight > this->grabHeight ? this->grabHeight : maxHeight;
|
||||
frame->realHeight = this->grabHeight;
|
||||
frame->pitch = this->grabStride * 4;
|
||||
frame->stride = this->grabStride;
|
||||
frame->rotation = CAPTURE_ROT_0;
|
||||
|
||||
#if 0
|
||||
//NvFBC never sets bIsHDR so instead we check for any data in the alpha channel
|
||||
@@ -366,12 +365,13 @@ static CaptureResult nvfbc_waitFrame(CaptureFrame * frame)
|
||||
return CAPTURE_RESULT_OK;
|
||||
}
|
||||
|
||||
static CaptureResult nvfbc_getFrame(FrameBuffer * frame)
|
||||
static CaptureResult nvfbc_getFrame(FrameBuffer * frame,
|
||||
const unsigned int height)
|
||||
{
|
||||
framebuffer_write(
|
||||
frame,
|
||||
this->frameBuffer,
|
||||
this->grabInfo.dwHeight * this->grabInfo.dwBufferWidth * 4
|
||||
height * this->grabInfo.dwBufferWidth * 4
|
||||
);
|
||||
return CAPTURE_RESULT_OK;
|
||||
}
|
||||
@@ -442,7 +442,6 @@ struct CaptureInterface Capture_NVFBC =
|
||||
.stop = nvfbc_stop,
|
||||
.deinit = nvfbc_deinit,
|
||||
.free = nvfbc_free,
|
||||
.getMaxFrameSize = nvfbc_getMaxFrameSize,
|
||||
.getMouseScale = nvfbc_getMouseScale,
|
||||
.capture = nvfbc_capture,
|
||||
.waitFrame = nvfbc_waitFrame,
|
||||
|
Reference in New Issue
Block a user