From 742e41c2c3093806e4d0d5c5cb370d4d6545cf2f Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Sun, 22 Oct 2023 03:15:12 +1100 Subject: [PATCH] [host] dxgi: fix HDR damage aware copy --- common/include/common/rects.h | 4 ++-- common/src/rects.c | 16 ++++++++-------- host/platform/Windows/capture/DXGI/src/dxgi.c | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/common/include/common/rects.h b/common/include/common/rects.h index 66872a6b1..0a325cfe3 100644 --- a/common/include/common/rects.h +++ b/common/include/common/rects.h @@ -38,11 +38,11 @@ inline static void rectCopyUnaligned(uint8_t * dest, const uint8_t * src, } } -void rectsBufferToFramebuffer(FrameDamageRect * rects, int count, +void rectsBufferToFramebuffer(FrameDamageRect * rects, int count, int bpp, FrameBuffer * frame, int dstStride, int height, const uint8_t * src, int srcStride); -void rectsFramebufferToBuffer(FrameDamageRect * rects, int count, +void rectsFramebufferToBuffer(FrameDamageRect * rects, int count, int bpp, uint8_t * dst, int dstStride, int height, const FrameBuffer * frame, int srcStride); diff --git a/common/src/rects.c b/common/src/rects.c index dd948903e..f2ad7836a 100644 --- a/common/src/rects.c +++ b/common/src/rects.c @@ -83,7 +83,7 @@ static int cornerCompare(const void * a_, const void * b_) return 0; } -inline static void rectsBufferCopy(FrameDamageRect * rects, int count, +inline static void rectsBufferCopy(FrameDamageRect * rects, int count, int bpp, uint8_t * dst, int dstStride, int height, const uint8_t * src, int srcStride, void * opaque, void (*rowCopyStart)(int y, void * opaque), @@ -148,8 +148,8 @@ inline static void rectsBufferCopy(FrameDamageRect * rects, int count, x1 = active[i].x; in_rect += active[i].delta; if (!in_rect) - rectCopyUnaligned(dst, src, prev_y, y, x1 * 4, dstStride, srcStride, - (active[i].x - x1) * 4); + rectCopyUnaligned(dst, src, prev_y, y, x1 * bpp, dstStride, srcStride, + (active[i].x - x1) * bpp); } if (re >= cornerCount || y == height) @@ -203,13 +203,13 @@ static void fbRowFinish(int y, void * opaque) framebuffer_set_write_ptr(data->frame, y * data->stride); } -void rectsBufferToFramebuffer(FrameDamageRect * rects, int count, +void rectsBufferToFramebuffer(FrameDamageRect * rects, int count, int bpp, FrameBuffer * frame, int dstStride, int height, const uint8_t * src, int srcStride) { struct ToFramebufferData data = { .frame = frame, .stride = dstStride }; - rectsBufferCopy(rects, count, framebuffer_get_data(frame), dstStride, height, - src, srcStride, &data, NULL, fbRowFinish); + rectsBufferCopy(rects, count, bpp, framebuffer_get_data(frame), dstStride, + height, src, srcStride, &data, NULL, fbRowFinish); framebuffer_set_write_ptr(frame, height * dstStride); } @@ -225,12 +225,12 @@ static void fbRowStart(int y, void * opaque) framebuffer_wait(data->frame, y * data->stride); } -void rectsFramebufferToBuffer(FrameDamageRect * rects, int count, +void rectsFramebufferToBuffer(FrameDamageRect * rects, int count, int bpp, uint8_t * dst, int dstStride, int height, const FrameBuffer * frame, int srcStride) { struct FromFramebufferData data = { .frame = frame, .stride = srcStride }; - rectsBufferCopy(rects, count, dst, dstStride, height, + rectsBufferCopy(rects, count, bpp, dst, dstStride, height, framebuffer_get_buffer(frame), srcStride, &data, fbRowStart, NULL); } diff --git a/host/platform/Windows/capture/DXGI/src/dxgi.c b/host/platform/Windows/capture/DXGI/src/dxgi.c index b9f426fad..22669ebca 100644 --- a/host/platform/Windows/capture/DXGI/src/dxgi.c +++ b/host/platform/Windows/capture/DXGI/src/dxgi.c @@ -1177,8 +1177,8 @@ static CaptureResult dxgi_getFrame(FrameBuffer * frame, memcpy(damage->rects + damage->count, tex->damageRects, tex->damageRectsCount * sizeof(*tex->damageRects)); damage->count += tex->damageRectsCount; - rectsBufferToFramebuffer(damage->rects, damage->count, frame, this->pitch, - height, tex->map, this->pitch); + rectsBufferToFramebuffer(damage->rects, damage->count, this->bpp, frame, + this->pitch, height, tex->map, this->pitch); } for (int i = 0; i < LGMP_Q_FRAME_LEN; ++i)