From 9c6bd888fde708a00838a8c957e7fcc501213d30 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Sun, 11 Oct 2020 19:22:31 +1100 Subject: [PATCH] [host/client] added experimental RGBA16 float support (EGL only) --- client/renderers/EGL/desktop.c | 5 +++++ client/renderers/EGL/texture.c | 13 +++++++++++++ client/renderers/EGL/texture.h | 1 + client/src/main.c | 5 +++++ common/include/common/KVMFR.h | 3 ++- host/include/interface/capture.h | 9 +++++---- host/platform/Windows/capture/DXGI/src/dxgi.c | 15 +++++++++++---- host/src/app.c | 9 +++++---- 8 files changed, 47 insertions(+), 13 deletions(-) diff --git a/client/renderers/EGL/desktop.c b/client/renderers/EGL/desktop.c index 37c9fbfe..78de4776 100644 --- a/client/renderers/EGL/desktop.c +++ b/client/renderers/EGL/desktop.c @@ -197,6 +197,11 @@ bool egl_desktop_update(EGL_Desktop * desktop, const bool sourceChanged, const L desktop->shader = &desktop->shader_generic; break; + case FRAME_TYPE_RGBA16F: + pixFmt = EGL_PF_RGBA16F; + desktop->shader = &desktop->shader_generic; + break; + case FRAME_TYPE_YUV420: pixFmt = EGL_PF_YUV420; desktop->shader = &desktop->shader_yuv; diff --git a/client/renderers/EGL/texture.c b/client/renderers/EGL/texture.c index f6306c6c..f26a9e54 100644 --- a/client/renderers/EGL/texture.c +++ b/client/renderers/EGL/texture.c @@ -219,6 +219,19 @@ bool egl_texture_setup(EGL_Texture * texture, enum EGL_PixelFormat pixFmt, size_ texture->pboBufferSize = height * stride; break; + case EGL_PF_RGBA16F: + planeCount = 1; + texture->bpp = 8; + texture->format = GL_RGBA; + texture->planes[0][0] = width; + texture->planes[0][1] = height; + texture->planes[0][2] = stride / 8; + texture->offsets[0] = 0; + texture->intFormat = GL_RGB16; + texture->dataType = GL_FLOAT; + texture->pboBufferSize = height * stride; + break; + case EGL_PF_YUV420: planeCount = 3; texture->bpp = 4; diff --git a/client/renderers/EGL/texture.h b/client/renderers/EGL/texture.h index faaa5e46..3d0da041 100644 --- a/client/renderers/EGL/texture.h +++ b/client/renderers/EGL/texture.h @@ -32,6 +32,7 @@ enum EGL_PixelFormat EGL_PF_RGBA, EGL_PF_BGRA, EGL_PF_RGBA10, + EGL_PF_RGBA16F, EGL_PF_YUV420 }; diff --git a/client/src/main.c b/client/src/main.c index e0da904c..09c354d7 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -440,6 +440,11 @@ static int frameThread(void * unused) lgrFormat.bpp = 32; break; + case FRAME_TYPE_RGBA16F: + dataSize = lgrFormat.height * lgrFormat.pitch; + lgrFormat.bpp = 64; + break; + case FRAME_TYPE_YUV420: dataSize = lgrFormat.height * lgrFormat.width; dataSize += (dataSize / 4) * 2; diff --git a/common/include/common/KVMFR.h b/common/include/common/KVMFR.h index 48c10716..374a6693 100644 --- a/common/include/common/KVMFR.h +++ b/common/include/common/KVMFR.h @@ -29,6 +29,7 @@ typedef enum FrameType FRAME_TYPE_BGRA , // BGRA interleaved: B,G,R,A 32bpp FRAME_TYPE_RGBA , // RGBA interleaved: R,G,B,A 32bpp FRAME_TYPE_RGBA10 , // RGBA interleaved: R,G,B,A 10,10,10,2 bpp + FRAME_TYPE_RGBA16F , // RGBA interleaved: R,G,B,A 16,16,16,16 bpp float FRAME_TYPE_YUV420 , // YUV420 FRAME_TYPE_MAX , // sentinel value } @@ -51,7 +52,7 @@ typedef enum CursorType CursorType; #define KVMFR_MAGIC "KVMFR---" -#define KVMFR_VERSION 3 +#define KVMFR_VERSION 4 typedef struct KVMFR { diff --git a/host/include/interface/capture.h b/host/include/interface/capture.h index f72ceb4c..03595203 100644 --- a/host/include/interface/capture.h +++ b/host/include/interface/capture.h @@ -35,10 +35,11 @@ CaptureResult; typedef enum CaptureFormat { // frame formats - CAPTURE_FMT_BGRA , - CAPTURE_FMT_RGBA , - CAPTURE_FMT_RGBA10, - CAPTURE_FMT_YUV420, + CAPTURE_FMT_BGRA , + CAPTURE_FMT_RGBA , + CAPTURE_FMT_RGBA10 , + CAPTURE_FMT_RGBA16F, + CAPTURE_FMT_YUV420 , // pointer formats CAPTURE_FMT_COLOR , diff --git a/host/platform/Windows/capture/DXGI/src/dxgi.c b/host/platform/Windows/capture/DXGI/src/dxgi.c index e36c7938..a539c2aa 100644 --- a/host/platform/Windows/capture/DXGI/src/dxgi.c +++ b/host/platform/Windows/capture/DXGI/src/dxgi.c @@ -519,11 +519,18 @@ static bool dxgi_init() IDXGIOutputDuplication_GetDesc(this->dup, &dupDesc); DEBUG_INFO("Source Format : %s", GetDXGIFormatStr(dupDesc.ModeDesc.Format)); + uint8_t bpp = 8; switch(dupDesc.ModeDesc.Format) { - case DXGI_FORMAT_B8G8R8A8_UNORM : this->format = CAPTURE_FMT_BGRA ; break; - case DXGI_FORMAT_R8G8B8A8_UNORM : this->format = CAPTURE_FMT_RGBA ; break; - case DXGI_FORMAT_R10G10B10A2_UNORM: this->format = CAPTURE_FMT_RGBA10; break; + case DXGI_FORMAT_B8G8R8A8_UNORM : this->format = CAPTURE_FMT_BGRA ; break; + case DXGI_FORMAT_R8G8B8A8_UNORM : this->format = CAPTURE_FMT_RGBA ; break; + case DXGI_FORMAT_R10G10B10A2_UNORM : this->format = CAPTURE_FMT_RGBA10 ; break; + + case DXGI_FORMAT_R16G16B16A16_FLOAT: + this->format = CAPTURE_FMT_RGBA16F; + bpp = 16; + break; + default: DEBUG_ERROR("Unsupported source format"); goto fail; @@ -562,7 +569,7 @@ static bool dxgi_init() goto fail; } this->pitch = mapping.RowPitch; - this->stride = mapping.RowPitch / 4; + this->stride = mapping.RowPitch / bpp; ID3D11DeviceContext_Unmap(this->deviceContext, (ID3D11Resource *)this->texture[0].tex, 0); QueryPerformanceFrequency(&this->perfFreq) ; diff --git a/host/src/app.c b/host/src/app.c index f91a8384..19890aed 100644 --- a/host/src/app.c +++ b/host/src/app.c @@ -178,10 +178,11 @@ static int frameThread(void * opaque) KVMFRFrame * fi = lgmpHostMemPtr(app.frameMemory[app.frameIndex]); 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: fi->type = FRAME_TYPE_RGBA10; break; - case CAPTURE_FMT_YUV420: fi->type = FRAME_TYPE_YUV420; break; + case CAPTURE_FMT_BGRA : fi->type = FRAME_TYPE_BGRA ; break; + case CAPTURE_FMT_RGBA : fi->type = FRAME_TYPE_RGBA ; break; + case CAPTURE_FMT_RGBA10 : fi->type = FRAME_TYPE_RGBA10 ; break; + case CAPTURE_FMT_RGBA16F: fi->type = FRAME_TYPE_RGBA16F; break; + case CAPTURE_FMT_YUV420 : fi->type = FRAME_TYPE_YUV420 ; break; default: DEBUG_ERROR("Unsupported frame format %d, skipping frame", frame.format); continue;