rendervulkan: Add passthru colorspace
This commit is contained in:
parent
50190f63c8
commit
6b362ac5ff
8 changed files with 26 additions and 13 deletions
|
|
@ -2187,6 +2187,7 @@ static inline drm_valve1_transfer_function colorspace_to_plane_degamma_tf(Gamesc
|
|||
default: // Linear in this sense is SRGB. Linear = sRGB image view doing automatic sRGB -> Linear which doesn't happen on DRM side.
|
||||
case GAMESCOPE_APP_TEXTURE_COLORSPACE_SRGB:
|
||||
return DRM_VALVE1_TRANSFER_FUNCTION_SRGB;
|
||||
case GAMESCOPE_APP_TEXTURE_COLORSPACE_PASSTHRU:
|
||||
case GAMESCOPE_APP_TEXTURE_COLORSPACE_SCRGB:
|
||||
// Use LINEAR TF for scRGB float format as 80 nit = 1.0 in scRGB, which matches
|
||||
// what PQ TF decodes to/encodes from.
|
||||
|
|
@ -2208,6 +2209,8 @@ static inline drm_valve1_transfer_function colorspace_to_plane_shaper_tf(Gamesco
|
|||
case GAMESCOPE_APP_TEXTURE_COLORSPACE_SCRGB: // scRGB Linear -> PQ for shaper + 3D LUT
|
||||
case GAMESCOPE_APP_TEXTURE_COLORSPACE_HDR10_PQ:
|
||||
return DRM_VALVE1_TRANSFER_FUNCTION_PQ;
|
||||
case GAMESCOPE_APP_TEXTURE_COLORSPACE_PASSTHRU:
|
||||
return DRM_VALVE1_TRANSFER_FUNCTION_DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,8 +41,9 @@ enum GamescopeAppTextureColorspace {
|
|||
GAMESCOPE_APP_TEXTURE_COLORSPACE_SRGB,
|
||||
GAMESCOPE_APP_TEXTURE_COLORSPACE_SCRGB,
|
||||
GAMESCOPE_APP_TEXTURE_COLORSPACE_HDR10_PQ,
|
||||
GAMESCOPE_APP_TEXTURE_COLORSPACE_PASSTHRU,
|
||||
};
|
||||
const uint32_t GamescopeAppTextureColorspace_Bits = 2;
|
||||
const uint32_t GamescopeAppTextureColorspace_Bits = 3;
|
||||
|
||||
inline bool ColorspaceIsHDR( GamescopeAppTextureColorspace colorspace )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -305,7 +305,8 @@ struct FrameInfo_t
|
|||
|
||||
bool viewConvertsToLinearAutomatically() const {
|
||||
return colorspace == GAMESCOPE_APP_TEXTURE_COLORSPACE_LINEAR ||
|
||||
colorspace == GAMESCOPE_APP_TEXTURE_COLORSPACE_SCRGB;
|
||||
colorspace == GAMESCOPE_APP_TEXTURE_COLORSPACE_SCRGB ||
|
||||
colorspace == GAMESCOPE_APP_TEXTURE_COLORSPACE_PASSTHRU;
|
||||
}
|
||||
|
||||
uint32_t integerWidth() const { return tex->width() / scale.x; }
|
||||
|
|
@ -340,7 +341,7 @@ struct FrameInfo_t
|
|||
uint32_t result = 0;
|
||||
for (int i = 0; i < layerCount; i++)
|
||||
{
|
||||
result |= layers[ i ].colorspace << i * GamescopeAppTextureColorspace_Bits;
|
||||
result |= layers[ i ].colorspace << (i * GamescopeAppTextureColorspace_Bits);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -502,7 +502,7 @@ vec4 gaussian_blur(sampler2D layerSampler, uint layerIdx, vec2 pos, uint radius,
|
|||
|
||||
if (vertical)
|
||||
{
|
||||
color.rgb = apply_layer_color_mgmt(color.rgb, colorspace);
|
||||
color.rgb = apply_layer_color_mgmt(color.rgb, layerIdx, colorspace);
|
||||
}
|
||||
|
||||
return color;
|
||||
|
|
|
|||
|
|
@ -312,6 +312,7 @@ vec3 colorspace_plane_degamma_tf(vec3 color, uint colorspace) {
|
|||
switch (colorspace) {
|
||||
default: return vec3(1, 1, 0); // should never happen
|
||||
|
||||
case colorspace_passthru:
|
||||
case colorspace_linear: // Using sRGB image view. Unlike DRM which doesn't get that liberty for scanout.
|
||||
case colorspace_scRGB:
|
||||
return color;
|
||||
|
|
@ -326,6 +327,7 @@ vec3 colorspace_plane_regamma_tf(vec3 color, uint colorspace) {
|
|||
switch (colorspace) {
|
||||
default: return vec3(1, 1, 0); // should never happen
|
||||
|
||||
case colorspace_passthru:
|
||||
case colorspace_scRGB:
|
||||
return color;
|
||||
case colorspace_linear: // Using sRGB image view. Unlike DRM which doesn't get that liberty for scanout.
|
||||
|
|
@ -354,7 +356,8 @@ vec3 colorspace_plane_shaper_tf(vec3 color, uint colorspace) {
|
|||
// pre-blend doing display EOTF -> display linearized
|
||||
vec3 colorspace_blend_tf(vec3 color, uint eotf) {
|
||||
switch (eotf) {
|
||||
default: return vec3(1, 0, 0); // should never happen
|
||||
default:
|
||||
return color;
|
||||
|
||||
// Note from Josh:
|
||||
//
|
||||
|
|
@ -376,7 +379,8 @@ vec3 colorspace_blend_tf(vec3 color, uint eotf) {
|
|||
// post blend doing display linearized -> display EOTF
|
||||
vec3 colorspace_output_tf(vec3 color, uint eotf) {
|
||||
switch (eotf) {
|
||||
default: return vec3(0, 1, 0); // should never happen
|
||||
default:
|
||||
return color;
|
||||
|
||||
// see comment in colorspace_blend_tf
|
||||
case EOTF_Gamma22:
|
||||
|
|
|
|||
|
|
@ -72,14 +72,17 @@ void compositing_debug(uvec2 coord) {
|
|||
//
|
||||
// ie. call colorspace_plane_degamma_tf(color.rgb, colorspace) before
|
||||
// input to this function.
|
||||
vec3 apply_layer_color_mgmt(vec3 color, uint colorspace) {
|
||||
vec3 apply_layer_color_mgmt(vec3 color, uint layer, uint colorspace) {
|
||||
if (colorspace == colorspace_passthru)
|
||||
return color;
|
||||
|
||||
if (c_itm_enable)
|
||||
{
|
||||
color = bt2446a_inverse_tonemapping(color, u_itmSdrNits, u_itmTargetNits);
|
||||
colorspace = colorspace_pq;
|
||||
}
|
||||
|
||||
if (checkDebugFlag(compositedebug_Heatmap))
|
||||
if (layer == 0 && checkDebugFlag(compositedebug_Heatmap))
|
||||
{
|
||||
// Debug HDR heatmap.
|
||||
color = hdr_heatmap(color, colorspace);
|
||||
|
|
@ -90,7 +93,6 @@ vec3 apply_layer_color_mgmt(vec3 color, uint colorspace) {
|
|||
|
||||
uint plane_eotf = colorspace_to_eotf(colorspace);
|
||||
|
||||
color = colorspace_plane_shaper_tf(color, colorspace);
|
||||
// The shaper TF is basically just a regamma to get into something the shaper LUT can handle.
|
||||
//
|
||||
// Despite naming, degamma + shaper TF are NOT necessarily the inverse of each other. ^^^
|
||||
|
|
@ -102,10 +104,11 @@ vec3 apply_layer_color_mgmt(vec3 color, uint colorspace) {
|
|||
bool lut3d_enabled = textureQueryLevels(s_shaperLut[plane_eotf]) != 0;
|
||||
if (lut3d_enabled)
|
||||
{
|
||||
color = colorspace_plane_shaper_tf(color, colorspace);
|
||||
color = perform_1dlut(color, s_shaperLut[plane_eotf]);
|
||||
color = perform_3dlut(color, s_lut3D[plane_eotf]);
|
||||
}
|
||||
color = colorspace_blend_tf(color, c_output_eotf);
|
||||
//color = colorspace_blend_tf(color, c_output_eotf);
|
||||
}
|
||||
|
||||
return color;
|
||||
|
|
@ -173,6 +176,7 @@ vec4 sampleLayerEx(sampler2D layerSampler, uint offsetLayerIdx, uint colorspaceL
|
|||
}
|
||||
// JoshA: AMDGPU applies 3x4 CTM like this, where A is 1.0, but it only affects .rgb.
|
||||
color.rgb = vec4(color.rgb, 1.0f) * u_ctm[offsetLayerIdx];
|
||||
color.rgb = apply_layer_color_mgmt(color.rgb, offsetLayerIdx, colorspace);
|
||||
|
||||
return color;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ void rcasComposite(uvec2 pos)
|
|||
|
||||
outputValue.rgb = colorspace_plane_degamma_tf(outputValue.rgb, colorspace);
|
||||
outputValue.rgb = (vec4(outputValue.rgb, 1.0f) * u_ctm[0]).rgb;
|
||||
outputValue.rgb = apply_layer_color_mgmt(outputValue.rgb, colorspace);
|
||||
outputValue.rgb = apply_layer_color_mgmt(outputValue.rgb, 0, colorspace);
|
||||
outputValue *= u_opacity[0];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ const int colorspace_linear = 0;
|
|||
const int colorspace_sRGB = 1;
|
||||
const int colorspace_scRGB = 2;
|
||||
const int colorspace_pq = 3;
|
||||
const int colorspace_reserved = 3;
|
||||
const int colorspace_max_bits = 2;
|
||||
const int colorspace_passthru = 4;
|
||||
const int colorspace_max_bits = 3;
|
||||
|
||||
const int filter_linear_emulated = 0;
|
||||
const int filter_nearest = 1;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue