mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-07-21 14:52:04 +00:00
[idd/client/obs] hdr: wire up the SdrWhiteLevel from the capture
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user