mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-09-23 06:05:45 +00:00
Fix precision loss when downcasting to HDR/EXR identified by @iOrange
* When outputting to a format supporting more than 8-bit data, we don't want to lose precision by downcasting e.g. D32S8 to RGBA8, instead use RGBA32.
This commit is contained in:
@@ -748,9 +748,21 @@ bool ReplayController::SaveTexture(const TextureSave &saveData, const char *path
|
||||
|
||||
if(downcast)
|
||||
{
|
||||
// if the source and destination are more than 1 byte per component, remap to RGBA32
|
||||
if(td.format.compByteWidth > 1 && (sd.destType == FileType::DDS ||
|
||||
sd.destType == FileType::HDR || sd.destType == FileType::EXR))
|
||||
const bool destHDR = (sd.destType == FileType::DDS || sd.destType == FileType::HDR ||
|
||||
sd.destType == FileType::EXR);
|
||||
|
||||
const bool sourceHDR =
|
||||
td.format.compByteWidth > 1 || td.format.type == ResourceFormatType::D16S8 ||
|
||||
td.format.type == ResourceFormatType::D24S8 || td.format.type == ResourceFormatType::D32S8 ||
|
||||
td.format.type == ResourceFormatType::R11G11B10 ||
|
||||
td.format.type == ResourceFormatType::R10G10B10A2 ||
|
||||
td.format.type == ResourceFormatType::R9G9B9E5 || td.format.type == ResourceFormatType::BC6 ||
|
||||
td.format.type == ResourceFormatType::BC7 || td.format.type == ResourceFormatType::YUV10 ||
|
||||
td.format.type == ResourceFormatType::YUV12 || td.format.type == ResourceFormatType::YUV16;
|
||||
|
||||
// if the source and destination have more than 1 byte per component, remap to RGBA32 to avoid
|
||||
// precision loss
|
||||
if(sourceHDR && destHDR)
|
||||
{
|
||||
remap = RemapTexture::RGBA32;
|
||||
td.format.compByteWidth = 4;
|
||||
|
||||
Reference in New Issue
Block a user