Skip to content

Commit

Permalink
[host] dxgi: fix HDR damage aware copy
Browse files Browse the repository at this point in the history
  • Loading branch information
gnif committed Oct 21, 2023
1 parent 3ed71a0 commit 742e41c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions common/include/common/rects.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
16 changes: 8 additions & 8 deletions common/src/rects.c
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions host/platform/Windows/capture/DXGI/src/dxgi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 742e41c

Please sign in to comment.