mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-07-21 23:02:05 +00:00
[idd/client/obs] hdr: wire up the SdrWhiteLevel from the capture
This commit is contained in:
@@ -92,6 +92,7 @@ typedef struct LG_RendererFormat
|
||||
uint32_t hdrMinDisplayLuminance;
|
||||
uint32_t hdrMaxContentLightLevel;
|
||||
uint32_t hdrMaxFrameAverageLightLevel;
|
||||
uint32_t sdrWhiteLevel;
|
||||
}
|
||||
LG_RendererFormat;
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ struct CursorTex
|
||||
GLuint uRotate;
|
||||
GLuint uCBMode;
|
||||
GLint uMapSDRtoPQ;
|
||||
GLint uSDRWhiteLevel;
|
||||
};
|
||||
|
||||
struct CursorPos
|
||||
@@ -79,6 +80,7 @@ struct EGL_Cursor
|
||||
_Atomic(struct CursorSize) size;
|
||||
_Atomic(float) scale;
|
||||
_Atomic(bool) mapSDRtoPQ;
|
||||
_Atomic(float) sdrWhiteLevel;
|
||||
|
||||
struct CursorTex norm;
|
||||
struct CursorTex mono;
|
||||
@@ -108,11 +110,12 @@ static bool cursorTexInit(struct CursorTex * t,
|
||||
return false;
|
||||
}
|
||||
|
||||
t->uMousePos = egl_shaderGetUniform(t->shader, "mouse" );
|
||||
t->uScale = egl_shaderGetUniform(t->shader, "scale" );
|
||||
t->uRotate = egl_shaderGetUniform(t->shader, "rotate" );
|
||||
t->uCBMode = egl_shaderGetUniform(t->shader, "cbMode" );
|
||||
t->uMapSDRtoPQ = egl_shaderGetUniform(t->shader, "mapSDRtoPQ");
|
||||
t->uMousePos = egl_shaderGetUniform(t->shader, "mouse" );
|
||||
t->uScale = egl_shaderGetUniform(t->shader, "scale" );
|
||||
t->uRotate = egl_shaderGetUniform(t->shader, "rotate" );
|
||||
t->uCBMode = egl_shaderGetUniform(t->shader, "cbMode" );
|
||||
t->uMapSDRtoPQ = egl_shaderGetUniform(t->shader, "mapSDRtoPQ" );
|
||||
t->uSDRWhiteLevel = egl_shaderGetUniform(t->shader, "sdrWhiteLevel");
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -121,11 +124,12 @@ static inline void setCursorTexUniforms(EGL_Cursor * cursor,
|
||||
struct CursorTex * t, bool mono, float x, float y,
|
||||
float w, float h, float scale)
|
||||
{
|
||||
glUniform4f(t->uMousePos , x, y, w, mono ? h / 2 : h);
|
||||
glUniform1f(t->uScale , scale);
|
||||
glUniform1i(t->uRotate , cursor->rotate);
|
||||
glUniform1i(t->uCBMode , cursor->cbMode);
|
||||
glUniform1i(t->uMapSDRtoPQ, !mono && atomic_load(&cursor->mapSDRtoPQ));
|
||||
glUniform4f(t->uMousePos , x, y, w, mono ? h / 2 : h);
|
||||
glUniform1f(t->uScale , scale);
|
||||
glUniform1i(t->uRotate , cursor->rotate);
|
||||
glUniform1i(t->uCBMode , cursor->cbMode);
|
||||
glUniform1i(t->uMapSDRtoPQ , !mono && atomic_load(&cursor->mapSDRtoPQ));
|
||||
glUniform1f(t->uSDRWhiteLevel, atomic_load(&cursor->sdrWhiteLevel));
|
||||
}
|
||||
|
||||
static void cursorTexFree(struct CursorTex * t)
|
||||
@@ -174,6 +178,8 @@ bool egl_cursorInit(EGL_Cursor ** cursor)
|
||||
atomic_init(&(*cursor)->size , size );
|
||||
atomic_init(&(*cursor)->scale , 1.0f );
|
||||
atomic_init(&(*cursor)->mapSDRtoPQ, false);
|
||||
atomic_init(&(*cursor)->sdrWhiteLevel,
|
||||
(float)KVMFR_SDR_WHITE_LEVEL_DEFAULT);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -435,7 +441,10 @@ struct CursorState egl_cursorRender(EGL_Cursor * cursor,
|
||||
return state;
|
||||
}
|
||||
|
||||
void egl_cursorSetHDRState(EGL_Cursor * cursor, bool hdrActive, bool hdrPQ)
|
||||
void egl_cursorSetHDRState(EGL_Cursor * cursor, bool hdrActive, bool hdrPQ,
|
||||
float sdrWhiteLevel)
|
||||
{
|
||||
atomic_store(&cursor->sdrWhiteLevel, sdrWhiteLevel > 0.0f ?
|
||||
sdrWhiteLevel : (float)KVMFR_SDR_WHITE_LEVEL_DEFAULT);
|
||||
atomic_store(&cursor->mapSDRtoPQ, hdrActive && hdrPQ);
|
||||
}
|
||||
|
||||
@@ -53,4 +53,5 @@ void egl_cursorSetState(EGL_Cursor * cursor, const bool visible,
|
||||
struct CursorState egl_cursorRender(EGL_Cursor * cursor,
|
||||
LG_RendererRotate rotate, int width, int height);
|
||||
|
||||
void egl_cursorSetHDRState(EGL_Cursor * cursor, bool hdrActive, bool hdrPQ);
|
||||
void egl_cursorSetHDRState(EGL_Cursor * cursor, bool hdrActive, bool hdrPQ,
|
||||
float sdrWhiteLevel);
|
||||
|
||||
@@ -631,7 +631,8 @@ static bool egl_onFrameFormat(LG_Renderer * renderer, const LG_RendererFormat fo
|
||||
egl_desktopSetNativeHDR(this->desktop, useNativeHDR);
|
||||
|
||||
// Tell the cursor shader whether to map SDR cursor colors into PQ
|
||||
egl_cursorSetHDRState(this->cursor, useNativeHDR, format.hdrPQ);
|
||||
egl_cursorSetHDRState(this->cursor, useNativeHDR, format.hdrPQ,
|
||||
format.sdrWhiteLevel);
|
||||
|
||||
egl_update_scale_type(this);
|
||||
egl_damageSetup(this->damage, format.frameWidth, format.frameHeight);
|
||||
|
||||
@@ -10,6 +10,7 @@ out vec4 color;
|
||||
uniform sampler2D sampler1;
|
||||
uniform float scale;
|
||||
uniform bool mapSDRtoPQ;
|
||||
uniform float sdrWhiteLevel;
|
||||
|
||||
void main()
|
||||
{
|
||||
@@ -32,7 +33,7 @@ void main()
|
||||
if (mapSDRtoPQ)
|
||||
{
|
||||
vec3 linear = bt709to2020(srgb2lin(tmp.rgb));
|
||||
tmp.rgb = lin2pq(linear * (203.0 / 10000.0));
|
||||
tmp.rgb = lin2pq(linear * (sdrWhiteLevel / 10000.0));
|
||||
}
|
||||
|
||||
color = tmp;
|
||||
|
||||
@@ -12,6 +12,7 @@ uniform sampler2D sampler1;
|
||||
uniform float scale;
|
||||
uniform int cbMode;
|
||||
uniform bool mapSDRtoPQ;
|
||||
uniform float sdrWhiteLevel;
|
||||
|
||||
void main()
|
||||
{
|
||||
@@ -38,7 +39,7 @@ void main()
|
||||
// then premultiply again so the blend operation remains valid.
|
||||
vec3 srgb = clamp(color.rgb / color.a, 0.0, 1.0);
|
||||
vec3 linear = bt709to2020(srgb2lin(srgb));
|
||||
color.rgb = lin2pq(linear * (203.0 / 10000.0)) * color.a;
|
||||
color.rgb = lin2pq(linear * (sdrWhiteLevel / 10000.0)) * color.a;
|
||||
}
|
||||
else
|
||||
color.rgb = vec3(0.0);
|
||||
|
||||
@@ -629,17 +629,19 @@ int main_frameThread(void * unused)
|
||||
if (!g_state.formatValid || frame->formatVer != formatVer)
|
||||
{
|
||||
// setup the renderer format with the frame format details
|
||||
lgrFormat.type = frame->type;
|
||||
lgrFormat.screenWidth = frame->screenWidth;
|
||||
lgrFormat.screenHeight = frame->screenHeight;
|
||||
lgrFormat.dataWidth = frame->dataWidth;
|
||||
lgrFormat.dataHeight = frame->dataHeight;
|
||||
lgrFormat.frameWidth = frame->frameWidth;
|
||||
lgrFormat.frameHeight = frame->frameHeight;
|
||||
lgrFormat.stride = frame->stride;
|
||||
lgrFormat.pitch = frame->pitch;
|
||||
lgrFormat.hdr = frame->flags & FRAME_FLAG_HDR;
|
||||
lgrFormat.hdrPQ = frame->flags & FRAME_FLAG_HDR_PQ;
|
||||
lgrFormat.type = frame->type;
|
||||
lgrFormat.screenWidth = frame->screenWidth;
|
||||
lgrFormat.screenHeight = frame->screenHeight;
|
||||
lgrFormat.dataWidth = frame->dataWidth;
|
||||
lgrFormat.dataHeight = frame->dataHeight;
|
||||
lgrFormat.frameWidth = frame->frameWidth;
|
||||
lgrFormat.frameHeight = frame->frameHeight;
|
||||
lgrFormat.stride = frame->stride;
|
||||
lgrFormat.pitch = frame->pitch;
|
||||
lgrFormat.hdr = frame->flags & FRAME_FLAG_HDR;
|
||||
lgrFormat.hdrPQ = frame->flags & FRAME_FLAG_HDR_PQ;
|
||||
lgrFormat.sdrWhiteLevel = frame->sdrWhiteLevel ?
|
||||
frame->sdrWhiteLevel : KVMFR_SDR_WHITE_LEVEL_DEFAULT;
|
||||
|
||||
if (lgrFormat.hdr)
|
||||
{
|
||||
@@ -728,14 +730,15 @@ int main_frameThread(void * unused)
|
||||
g_state.formatValid = true;
|
||||
formatVer = frame->formatVer;
|
||||
|
||||
DEBUG_INFO("Format: %s %ux%u (%ux%u) stride:%u pitch:%u rotation:%d hdr:%d pq:%d",
|
||||
DEBUG_INFO("Format: %s %ux%u (%ux%u) stride:%u pitch:%u rotation:%d hdr:%d pq:%d sdrWhite:%u nits",
|
||||
FrameTypeStr[frame->type],
|
||||
frame->frameWidth, frame->frameHeight,
|
||||
frame->dataWidth , frame->dataHeight ,
|
||||
frame->stride, frame->pitch,
|
||||
frame->rotation,
|
||||
frame->flags & FRAME_FLAG_HDR ? 1 : 0,
|
||||
frame->flags & FRAME_FLAG_HDR_PQ ? 1 : 0);
|
||||
frame->flags & FRAME_FLAG_HDR_PQ ? 1 : 0,
|
||||
lgrFormat.sdrWhiteLevel);
|
||||
|
||||
LG_LOCK(g_state.lgrLock);
|
||||
if (!RENDERER(onFrameFormat, lgrFormat))
|
||||
@@ -1533,7 +1536,7 @@ restart:
|
||||
if (waitCount == 30)
|
||||
{
|
||||
DEBUG_BREAK();
|
||||
if (!g_params.disableWaitingMessage)
|
||||
if (!g_params.disableWaitingMessage)
|
||||
{
|
||||
msgs[msgsCount++] = app_msgBox(
|
||||
"Host Application Not Running",
|
||||
|
||||
Reference in New Issue
Block a user