From b41840b0106908f1dca1d689cf5a41cc185f7827 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Fri, 27 Oct 2023 01:11:57 +1100 Subject: [PATCH] [host] all: tell the client if HDR PQ is in use or not --- host/include/interface/capture.h | 11 ++++++----- host/platform/Windows/capture/DXGI/src/dxgi.c | 4 +++- host/platform/Windows/capture/NVFBC/src/nvfbc.c | 6 ++++-- host/src/app.c | 11 ++++------- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/host/include/interface/capture.h b/host/include/interface/capture.h index 069d5b6c..cffd760d 100644 --- a/host/include/interface/capture.h +++ b/host/include/interface/capture.h @@ -44,11 +44,10 @@ CaptureResult; typedef enum CaptureFormat { // frame formats - CAPTURE_FMT_BGRA , - CAPTURE_FMT_RGBA , - CAPTURE_FMT_RGBA10_SDR, - CAPTURE_FMT_RGBA10_HDR, - CAPTURE_FMT_RGBA16F , + CAPTURE_FMT_BGRA , + CAPTURE_FMT_RGBA , + CAPTURE_FMT_RGBA10 , + CAPTURE_FMT_RGBA16F, // pointer formats CAPTURE_FMT_COLOR , @@ -79,6 +78,8 @@ typedef struct CaptureFrame unsigned int pitch; unsigned int stride; CaptureFormat format; + bool hdr; + bool hdrPQ; CaptureRotation rotation; uint32_t damageRectsCount; FrameDamageRect damageRects[KVMFR_MAX_DAMAGE_RECTS]; diff --git a/host/platform/Windows/capture/DXGI/src/dxgi.c b/host/platform/Windows/capture/DXGI/src/dxgi.c index 18e2deda..5bce58c9 100644 --- a/host/platform/Windows/capture/DXGI/src/dxgi.c +++ b/host/platform/Windows/capture/DXGI/src/dxgi.c @@ -802,7 +802,7 @@ next_output: // we convert to HDR10 to save bandwidth case DXGI_FORMAT_R16G16B16A16_FLOAT: this->dxgiFormat = DXGI_FORMAT_R10G10B10A2_UNORM; - this->format = CAPTURE_FMT_RGBA10_HDR; + this->format = CAPTURE_FMT_RGBA10; break; default: @@ -1607,6 +1607,8 @@ static CaptureResult dxgi_waitFrame(CaptureFrame * frame, const size_t maxFrameS frame->pitch = this->pitch; frame->stride = this->stride; frame->format = this->format; + frame->hdr = this->hdr; + frame->hdrPQ = false; frame->rotation = this->rotation; frame->damageRectsCount = tex->damageRectsCount; diff --git a/host/platform/Windows/capture/NVFBC/src/nvfbc.c b/host/platform/Windows/capture/NVFBC/src/nvfbc.c index 78349601..006e9db0 100644 --- a/host/platform/Windows/capture/NVFBC/src/nvfbc.c +++ b/host/platform/Windows/capture/NVFBC/src/nvfbc.c @@ -757,8 +757,10 @@ static CaptureResult nvfbc_waitFrame(CaptureFrame * frame, updateDamageRects(frame); - frame->format = this->grabInfo.bIsHDR ? - CAPTURE_FMT_RGBA10_HDR : CAPTURE_FMT_RGBA10_SDR; + frame->format = CAPTURE_FMT_RGBA10; + frame->hdr = this->grabInfo.bIsHDR; + frame->hdrPQ = true; + return CAPTURE_RESULT_OK; } diff --git a/host/src/app.c b/host/src/app.c index 5bb75f1b..cd6f51dc 100644 --- a/host/src/app.c +++ b/host/src/app.c @@ -244,22 +244,19 @@ static bool sendFrame(void) app.frameIndex = 0; KVMFRFrame * fi = lgmpHostMemPtr(app.frameMemory[app.frameIndex]); - KVMFRFrameFlags flags = 0; + KVMFRFrameFlags flags = + (frame.hdr ? FRAME_FLAG_HDR : 0) | + (frame.hdrPQ ? FRAME_FLAG_HDR_PQ : 0); switch(frame.format) { case CAPTURE_FMT_BGRA : fi->type = FRAME_TYPE_BGRA ; break; case CAPTURE_FMT_RGBA : fi->type = FRAME_TYPE_RGBA ; break; - case CAPTURE_FMT_RGBA10_SDR: + case CAPTURE_FMT_RGBA10: fi->type = FRAME_TYPE_RGBA10; break; - case CAPTURE_FMT_RGBA10_HDR: - fi->type = FRAME_TYPE_RGBA10; - flags |= FRAME_FLAG_HDR; - break; - case CAPTURE_FMT_RGBA16F: fi->type = FRAME_TYPE_RGBA16F; flags |= FRAME_FLAG_HDR;