mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-25 14:57:20 +00:00
[host] dxgi: fix support for non 24-bit BGR formats
This commit is contained in:
parent
5f613b09d6
commit
561c45bcb9
@ -140,16 +140,15 @@ static void d3d11_free(void)
|
|||||||
this = NULL;
|
this = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int scaleForBGR(int x)
|
static bool d3d11_copyFrame(Texture * tex, ID3D11Texture2D * src)
|
||||||
{
|
|
||||||
return x * 3 / 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void copyFrameFull(Texture * tex, ID3D11Texture2D * src)
|
|
||||||
{
|
{
|
||||||
struct D3D11TexImpl * teximpl = TEXIMPL(*tex);
|
struct D3D11TexImpl * teximpl = TEXIMPL(*tex);
|
||||||
ID3D11Texture2D * dst = *teximpl->cpu;
|
ID3D11Texture2D * dst = *teximpl->cpu;
|
||||||
|
|
||||||
|
INTERLOCKED_SECTION(dxgi->deviceContextLock,
|
||||||
|
{
|
||||||
|
tex->copyTime = microtime();
|
||||||
|
|
||||||
if (tex->texDamageCount < 0)
|
if (tex->texDamageCount < 0)
|
||||||
ID3D11DeviceContext_CopyResource(*dxgi->deviceContext,
|
ID3D11DeviceContext_CopyResource(*dxgi->deviceContext,
|
||||||
(ID3D11Resource *)dst, (ID3D11Resource *)src);
|
(ID3D11Resource *)dst, (ID3D11Resource *)src);
|
||||||
@ -160,26 +159,26 @@ static void copyFrameFull(Texture * tex, ID3D11Texture2D * src)
|
|||||||
FrameDamageRect * rect = tex->texDamageRects + i;
|
FrameDamageRect * rect = tex->texDamageRects + i;
|
||||||
D3D11_BOX box =
|
D3D11_BOX box =
|
||||||
{
|
{
|
||||||
.left = scaleForBGR(rect->x),
|
.left = rect->x,
|
||||||
.top = rect->y,
|
.top = rect->y,
|
||||||
.front = 0,
|
.front = 0,
|
||||||
.back = 1,
|
.back = 1,
|
||||||
.right = scaleForBGR(rect->x + rect->width),
|
.right = rect->x + rect->width,
|
||||||
.bottom = rect->y + rect->height,
|
.bottom = rect->y + rect->height,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (dxgi->outputFormat == CAPTURE_FMT_BGR)
|
||||||
|
{
|
||||||
|
box.left = box.left * 3 / 4;
|
||||||
|
box.right = box.right * 3 / 4;
|
||||||
|
}
|
||||||
|
|
||||||
ID3D11DeviceContext_CopySubresourceRegion(*dxgi->deviceContext,
|
ID3D11DeviceContext_CopySubresourceRegion(*dxgi->deviceContext,
|
||||||
(ID3D11Resource *)dst, 0, box.left, box.top, 0,
|
(ID3D11Resource *)dst, 0, box.left, box.top, 0,
|
||||||
(ID3D11Resource *)src, 0, &box);
|
(ID3D11Resource *)src, 0, &box);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static bool d3d11_copyFrame(Texture * tex, ID3D11Texture2D * src)
|
|
||||||
{
|
|
||||||
INTERLOCKED_SECTION(dxgi->deviceContextLock,
|
|
||||||
{
|
|
||||||
tex->copyTime = microtime();
|
|
||||||
copyFrameFull(tex, src);
|
|
||||||
ID3D11DeviceContext_Flush(*dxgi->deviceContext);
|
ID3D11DeviceContext_Flush(*dxgi->deviceContext);
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
|
@ -1295,11 +1295,6 @@ static CaptureResult dxgi_waitFrame(CaptureFrame * frame, const size_t maxFrameS
|
|||||||
return CAPTURE_RESULT_OK;
|
return CAPTURE_RESULT_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int scaleForBGR(int x)
|
|
||||||
{
|
|
||||||
return x * 3 / 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
static CaptureResult dxgi_getFrame(FrameBuffer * frame, int frameIndex)
|
static CaptureResult dxgi_getFrame(FrameBuffer * frame, int frameIndex)
|
||||||
{
|
{
|
||||||
DEBUG_ASSERT(this);
|
DEBUG_ASSERT(this);
|
||||||
@ -1319,13 +1314,15 @@ static CaptureResult dxgi_getFrame(FrameBuffer * frame, int frameIndex)
|
|||||||
tex->damageRectsCount * sizeof(*tex->damageRects));
|
tex->damageRectsCount * sizeof(*tex->damageRects));
|
||||||
damage->count += tex->damageRectsCount;
|
damage->count += tex->damageRectsCount;
|
||||||
|
|
||||||
|
if (this->outputFormat == CAPTURE_FMT_BGR)
|
||||||
|
{
|
||||||
FrameDamageRect scaledDamageRects[damage->count];
|
FrameDamageRect scaledDamageRects[damage->count];
|
||||||
for (int i = 0; i < ARRAYSIZE(scaledDamageRects); i++) {
|
for (int i = 0; i < ARRAYSIZE(scaledDamageRects); i++) {
|
||||||
FrameDamageRect rect = damage->rects[i];
|
FrameDamageRect rect = damage->rects[i];
|
||||||
int originalX = rect.x;
|
int originalX = rect.x;
|
||||||
int scaledX = scaleForBGR(originalX);
|
int scaledX = originalX * 3 / 4;
|
||||||
rect.x = scaledX;
|
rect.x = scaledX;
|
||||||
rect.width = scaleForBGR(originalX + rect.width) - scaledX;
|
rect.width = ((originalX + rect.width) * 3 / 4) - scaledX;
|
||||||
|
|
||||||
scaledDamageRects[i] = rect;
|
scaledDamageRects[i] = rect;
|
||||||
}
|
}
|
||||||
@ -1333,6 +1330,12 @@ static CaptureResult dxgi_getFrame(FrameBuffer * frame, int frameIndex)
|
|||||||
rectsBufferToFramebuffer(scaledDamageRects, damage->count, this->bpp, frame,
|
rectsBufferToFramebuffer(scaledDamageRects, damage->count, this->bpp, frame,
|
||||||
this->pitch, this->dataHeight, tex->map, this->pitch);
|
this->pitch, this->dataHeight, tex->map, this->pitch);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rectsBufferToFramebuffer(damage->rects, damage->count, this->bpp, frame,
|
||||||
|
this->pitch, this->dataHeight, tex->map, this->pitch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < LGMP_Q_FRAME_LEN; ++i)
|
for (int i = 0; i < LGMP_Q_FRAME_LEN; ++i)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user