mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-12-23 14:03:40 +00:00
[host] dxgi: populate damage rectangles
Co-Authored-By: Quantum <quantum2048@gmail.com>
This commit is contained in:
parent
80ab4b5393
commit
d7f9afb3ba
@ -27,6 +27,7 @@
|
||||
#include "common/event.h"
|
||||
#include "common/dpi.h"
|
||||
#include "common/runningavg.h"
|
||||
#include "common/KVMFR.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdatomic.h>
|
||||
@ -53,6 +54,8 @@ typedef struct Texture
|
||||
ID3D11Texture2D * tex;
|
||||
D3D11_MAPPED_SUBRESOURCE map;
|
||||
uint64_t copyTime;
|
||||
uint8_t damageRectsCount;
|
||||
RECT damageRects[KVMFR_MAX_DAMAGE_RECTS];
|
||||
}
|
||||
Texture;
|
||||
|
||||
@ -782,6 +785,15 @@ static CaptureResult dxgi_capture(void)
|
||||
tex->copyTime = microtime();
|
||||
ID3D11DeviceContext_CopyResource(this->deviceContext,
|
||||
(ID3D11Resource *)tex->tex, (ID3D11Resource *)src);
|
||||
|
||||
UINT damageRectsBufferSizeRequired;
|
||||
if (IDXGIOutputDuplication_GetFrameDirtyRects(this->dup, KVMFR_MAX_DAMAGE_RECTS,
|
||||
tex->damageRects, &damageRectsBufferSizeRequired) == S_OK)
|
||||
tex->damageRectsCount = damageRectsBufferSizeRequired / sizeof(*tex->damageRects);
|
||||
else
|
||||
// Either received too many damage regions or hit another error;
|
||||
// damage the full frame instead.
|
||||
tex->damageRectsCount = 0;
|
||||
}
|
||||
|
||||
if (copyPointer)
|
||||
@ -930,14 +942,26 @@ static CaptureResult dxgi_waitFrame(CaptureFrame * frame, const size_t maxFrameS
|
||||
|
||||
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;
|
||||
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;
|
||||
|
||||
frame->damageRectsCount = tex->damageRectsCount;
|
||||
for (int i = 0; i < tex->damageRectsCount; i++)
|
||||
{
|
||||
RECT damageRect = tex->damageRects[i];
|
||||
frame->damageRects[i] = (FrameDamageRect) {
|
||||
.x = damageRect.left,
|
||||
.y = damageRect.top,
|
||||
.width = damageRect.right - damageRect.left,
|
||||
.height = damageRect.bottom - damageRect.top
|
||||
};
|
||||
}
|
||||
|
||||
atomic_fetch_sub_explicit(&this->texReady, 1, memory_order_release);
|
||||
return CAPTURE_RESULT_OK;
|
||||
|
Loading…
Reference in New Issue
Block a user