[host] dxgi: fix HDR damage aware copy

This commit is contained in:
Geoffrey McRae 2023-10-22 03:15:12 +11:00
parent 3ed71a09f4
commit 742e41c2c3
3 changed files with 12 additions and 12 deletions
common
include/common
src
host/platform/Windows/capture/DXGI/src

@ -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, FrameBuffer * frame, int dstStride, int height,
const uint8_t * src, int srcStride); 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, uint8_t * dst, int dstStride, int height,
const FrameBuffer * frame, int srcStride); const FrameBuffer * frame, int srcStride);

@ -83,7 +83,7 @@ static int cornerCompare(const void * a_, const void * b_)
return 0; 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, uint8_t * dst, int dstStride, int height,
const uint8_t * src, int srcStride, void * opaque, const uint8_t * src, int srcStride, void * opaque,
void (*rowCopyStart)(int y, void * opaque), void (*rowCopyStart)(int y, void * opaque),
@ -148,8 +148,8 @@ inline static void rectsBufferCopy(FrameDamageRect * rects, int count,
x1 = active[i].x; x1 = active[i].x;
in_rect += active[i].delta; in_rect += active[i].delta;
if (!in_rect) if (!in_rect)
rectCopyUnaligned(dst, src, prev_y, y, x1 * 4, dstStride, srcStride, rectCopyUnaligned(dst, src, prev_y, y, x1 * bpp, dstStride, srcStride,
(active[i].x - x1) * 4); (active[i].x - x1) * bpp);
} }
if (re >= cornerCount || y == height) 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); 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, FrameBuffer * frame, int dstStride, int height,
const uint8_t * src, int srcStride) const uint8_t * src, int srcStride)
{ {
struct ToFramebufferData data = { .frame = frame, .stride = dstStride }; struct ToFramebufferData data = { .frame = frame, .stride = dstStride };
rectsBufferCopy(rects, count, framebuffer_get_data(frame), dstStride, height, rectsBufferCopy(rects, count, bpp, framebuffer_get_data(frame), dstStride,
src, srcStride, &data, NULL, fbRowFinish); height, src, srcStride, &data, NULL, fbRowFinish);
framebuffer_set_write_ptr(frame, height * dstStride); 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); 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, uint8_t * dst, int dstStride, int height,
const FrameBuffer * frame, int srcStride) const FrameBuffer * frame, int srcStride)
{ {
struct FromFramebufferData data = { .frame = frame, .stride = 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); framebuffer_get_buffer(frame), srcStride, &data, fbRowStart, NULL);
} }

@ -1177,8 +1177,8 @@ static CaptureResult dxgi_getFrame(FrameBuffer * frame,
memcpy(damage->rects + damage->count, tex->damageRects, memcpy(damage->rects + damage->count, tex->damageRects,
tex->damageRectsCount * sizeof(*tex->damageRects)); tex->damageRectsCount * sizeof(*tex->damageRects));
damage->count += tex->damageRectsCount; damage->count += tex->damageRectsCount;
rectsBufferToFramebuffer(damage->rects, damage->count, frame, this->pitch, rectsBufferToFramebuffer(damage->rects, damage->count, this->bpp, frame,
height, tex->map, this->pitch); this->pitch, height, tex->map, this->pitch);
} }
for (int i = 0; i < LGMP_Q_FRAME_LEN; ++i) for (int i = 0; i < LGMP_Q_FRAME_LEN; ++i)