mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-10 00:28:20 +00:00
[client] egl: prepare for DXGI HDR10 support
This commit is contained in:
parent
200b7b732c
commit
2f36aaff5c
@ -73,6 +73,7 @@ typedef struct LG_RendererFormat
|
||||
{
|
||||
FrameType type; // frame type
|
||||
bool hdr; // if the frame is HDR or not
|
||||
bool hdrPQ; // if the HDR content is PQ mapped
|
||||
unsigned int screenWidth; // actual width of the host
|
||||
unsigned int screenHeight; // actual height of the host
|
||||
unsigned int frameWidth; // width of frame transmitted
|
||||
|
@ -53,6 +53,7 @@ struct DesktopShader
|
||||
GLint uIsHDR;
|
||||
GLint uMapHDRtoSDR;
|
||||
GLint uMapHDRGain;
|
||||
GLint uMapHDRPQ;
|
||||
};
|
||||
|
||||
struct EGL_Desktop
|
||||
@ -68,6 +69,7 @@ struct EGL_Desktop
|
||||
// internals
|
||||
int width, height;
|
||||
bool hdr;
|
||||
bool hdrPQ;
|
||||
LG_RendererRotate rotate;
|
||||
|
||||
bool useSpice;
|
||||
@ -125,6 +127,7 @@ static bool egl_initDesktopShader(
|
||||
shader->uIsHDR = egl_shaderGetUniform(shader->shader, "isHDR" );
|
||||
shader->uMapHDRtoSDR = egl_shaderGetUniform(shader->shader, "mapHDRtoSDR" );
|
||||
shader->uMapHDRGain = egl_shaderGetUniform(shader->shader, "mapHDRGain" );
|
||||
shader->uMapHDRPQ = egl_shaderGetUniform(shader->shader, "mapHDRPQ" );
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -342,6 +345,7 @@ bool egl_desktopSetup(EGL_Desktop * desktop, const LG_RendererFormat format)
|
||||
desktop->width = format.frameWidth;
|
||||
desktop->height = format.frameHeight;
|
||||
desktop->hdr = format.hdr;
|
||||
desktop->hdrPQ = format.hdrPQ;
|
||||
|
||||
if (!egl_textureSetup(
|
||||
desktop->texture,
|
||||
@ -538,6 +542,11 @@ bool egl_desktopRender(EGL_Desktop * desktop, unsigned int outputWidth,
|
||||
.type = EGL_UNIFORM_TYPE_1F,
|
||||
.location = shader->uMapHDRGain,
|
||||
.f = { mapHDRGain }
|
||||
},
|
||||
{
|
||||
.type = EGL_UNIFORM_TYPE_1I,
|
||||
.location = shader->uMapHDRPQ,
|
||||
.f = { desktop->hdrPQ }
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -23,6 +23,7 @@ uniform int cbMode;
|
||||
uniform bool isHDR;
|
||||
uniform bool mapHDRtoSDR;
|
||||
uniform float mapHDRGain;
|
||||
uniform bool mapHDRPQ;
|
||||
|
||||
void main()
|
||||
{
|
||||
@ -43,7 +44,7 @@ void main()
|
||||
}
|
||||
|
||||
if (isHDR && mapHDRtoSDR)
|
||||
color.rgb = mapToSDR(color.rgb, mapHDRGain);
|
||||
color.rgb = mapToSDR(color.rgb, mapHDRGain, mapHDRPQ);
|
||||
|
||||
if (cbMode > 0)
|
||||
color = cbTransform(color, cbMode);
|
||||
|
@ -40,7 +40,7 @@ float midGain(vec3 pixel)
|
||||
min(pixel.r, pixel.g)); // min = b
|
||||
}
|
||||
|
||||
vec3 compress(vec3 pixel, float gain)
|
||||
vec3 compress(vec3 pixel)
|
||||
{
|
||||
float maxGain = maxGain(pixel);
|
||||
return pixel * (maxGain < knee ? maxGain :
|
||||
@ -99,8 +99,10 @@ vec3 bt2020to709(vec3 bt2020)
|
||||
bt2020.r * -0.0182 + bt2020.g * -0.1006 + bt2020.b * 1.1187);
|
||||
}
|
||||
|
||||
vec3 mapToSDR(vec3 color, float gain)
|
||||
vec3 mapToSDR(vec3 color, float gain, bool pq)
|
||||
{
|
||||
vec3 lin = bt2020to709(pq2lin(color.rgb, gain));
|
||||
return lin2srgb(compress(lin, gain));
|
||||
if (pq)
|
||||
color = pq2lin(color.rgb, gain);
|
||||
color = bt2020to709(color);
|
||||
return lin2srgb(compress(color));
|
||||
}
|
||||
|
@ -630,6 +630,7 @@ int main_frameThread(void * unused)
|
||||
lgrFormat.stride = frame->stride;
|
||||
lgrFormat.pitch = frame->pitch;
|
||||
lgrFormat.hdr = frame->flags & FRAME_FLAG_HDR;
|
||||
lgrFormat.hdrPQ = frame->flags & FRAME_FLAG_HDR_PQ;
|
||||
|
||||
if (frame->flags & FRAME_FLAG_TRUNCATED)
|
||||
{
|
||||
|
@ -133,10 +133,11 @@ KVMFRCursor;
|
||||
|
||||
enum
|
||||
{
|
||||
FRAME_FLAG_BLOCK_SCREENSAVER = 0x1,
|
||||
FRAME_FLAG_REQUEST_ACTIVATION = 0x2,
|
||||
FRAME_FLAG_TRUNCATED = 0x4, // ivshmem was too small for the frame
|
||||
FRAME_FLAG_HDR = 0x8 // RGBA10 may not be HDR
|
||||
FRAME_FLAG_BLOCK_SCREENSAVER = 0x1 ,
|
||||
FRAME_FLAG_REQUEST_ACTIVATION = 0x2 ,
|
||||
FRAME_FLAG_TRUNCATED = 0x4 , // ivshmem was too small for the frame
|
||||
FRAME_FLAG_HDR = 0x8 , // RGBA10 may not be HDR
|
||||
FRAME_FLAG_HDR_PQ = 0x10 // HDR PQ has been applied to the frame
|
||||
};
|
||||
|
||||
typedef uint32_t KVMFRFrameFlags;
|
||||
|
Loading…
Reference in New Issue
Block a user