Get replay to display textures in gamma-correct fashion

This commit is contained in:
baldurk
2015-10-15 13:05:04 +02:00
parent 64be44bf8b
commit 4ebbf09364
5 changed files with 71 additions and 3 deletions
+1 -1
View File
@@ -42,9 +42,9 @@ On replay:
* Only 2D non-array non-integer textures can currently be displayed.
* Pixel values aren't fetched.
* Thumbnail images aren't rendered (causes crashes/halts on nvidia's driver).
* Auto texture range-fit or histogram display is not implemented.
* Debug overlays aren't implemented.
* The display pipeline is not yet gamma correct.
* Saving textures is not supported.
* Queue-level API events are not properly listed. API calls between draw-type vkCmd... are listed.
* Meshes are not rendered as a preview.
+5
View File
@@ -102,6 +102,11 @@ void main(void)
col = vec4(dot(col.rgb, 1.0f.xxx).xxx, 1.0f);
}
}
if(texdisplay.OutputDisplayFormat > 0)
{
col.rgb = pow(clamp(col.rgb, 0.0f.xxx, 1.0f.xxx), 2.2f.xxx);
}
color_out = (texdisplay.RawOutput != 0 ? rawcol : col);
}
+24 -2
View File
@@ -193,9 +193,26 @@ void VulkanReplay::OutputWindow::Create(WrappedVulkan *driver, VkDevice device,
}
else
{
// since we don't care, if the driver has a preference just pick the first
imformat = formats[0].format;
// try and find a format with SRGB correction
imformat = VK_FORMAT_UNDEFINED;
imcolspace = formats[0].colorSpace;
for(uint32_t i=0; i < numFormats; i++)
{
if(IsSRGBFormat(formats[i].format))
{
imformat = formats[i].format;
imcolspace = formats[i].colorSpace;
RDCASSERT(imcolspace == VK_COLORSPACE_SRGB_NONLINEAR_KHR);
break;
}
}
if(imformat == VK_FORMAT_UNDEFINED)
{
RDCWARN("Couldn't find SRGB correcting output swapchain format");
imformat = formats[0].format;
}
}
SAFE_DELETE_ARRAY(formats);
@@ -748,6 +765,11 @@ bool VulkanReplay::RenderTexture(TextureDisplay cfg)
// VKTODOMED handle different texture types/displays
data->OutputDisplayFormat = 0;
if(!IsSRGBFormat(iminfo.format) && cfg.linearDisplayAsGamma)
{
data->OutputDisplayFormat |= 1; // VKTODOMED constants TEXDISPLAY_GAMMA_CURVE;
}
data->RawOutput = cfg.rawoutput ? 1 : 0;
GetDebugManager()->m_TexDisplayUBO.Unmap(vt, dev);
+40
View File
@@ -178,3 +178,43 @@ bool IsDepthStencilFormat(VkFormat f)
return false;
}
bool IsSRGBFormat(VkFormat f)
{
switch(f)
{
case VK_FORMAT_R8_SRGB:
case VK_FORMAT_R8G8_SRGB:
case VK_FORMAT_R8G8B8_SRGB:
case VK_FORMAT_R8G8B8A8_SRGB:
case VK_FORMAT_BC1_RGB_SRGB:
case VK_FORMAT_BC1_RGBA_SRGB:
case VK_FORMAT_BC2_SRGB:
case VK_FORMAT_BC3_SRGB:
case VK_FORMAT_BC7_SRGB:
case VK_FORMAT_ETC2_R8G8B8_SRGB:
case VK_FORMAT_ETC2_R8G8B8A1_SRGB:
case VK_FORMAT_ETC2_R8G8B8A8_SRGB:
case VK_FORMAT_ASTC_4x4_SRGB:
case VK_FORMAT_ASTC_5x4_SRGB:
case VK_FORMAT_ASTC_5x5_SRGB:
case VK_FORMAT_ASTC_6x5_SRGB:
case VK_FORMAT_ASTC_6x6_SRGB:
case VK_FORMAT_ASTC_8x5_SRGB:
case VK_FORMAT_ASTC_8x6_SRGB:
case VK_FORMAT_ASTC_8x8_SRGB:
case VK_FORMAT_ASTC_10x5_SRGB:
case VK_FORMAT_ASTC_10x6_SRGB:
case VK_FORMAT_ASTC_10x8_SRGB:
case VK_FORMAT_ASTC_10x10_SRGB:
case VK_FORMAT_ASTC_12x10_SRGB:
case VK_FORMAT_ASTC_12x12_SRGB:
case VK_FORMAT_B8G8R8_SRGB:
case VK_FORMAT_B8G8R8A8_SRGB:
return true;
default:
break;
}
return false;
}
+1
View File
@@ -698,3 +698,4 @@ struct ImgState
bool IsBlockFormat(VkFormat f);
bool IsDepthStencilFormat(VkFormat f);
bool IsSRGBFormat(VkFormat f);