| 3711 | } |
| 3712 | |
| 3713 | void TextureViewer::AutoFitRange() |
| 3714 | { |
| 3715 | // no capture loaded or buffer/empty texture currently being viewed - don't autofit |
| 3716 | if(!m_Ctx.IsCaptureLoaded() || GetCurrentTexture() == NULL || m_Output == NULL) |
| 3717 | return; |
| 3718 | |
| 3719 | m_Ctx.Replay().AsyncInvoke([this](IReplayController *r) { |
| 3720 | ResourceId textureId = m_TexDisplay.resourceId; |
| 3721 | Subresource sub = m_TexDisplay.subresource; |
| 3722 | CompType typeCast = m_TexDisplay.typeCast; |
| 3723 | |
| 3724 | if(m_TexDisplay.customShaderId != ResourceId() && m_Output->GetCustomShaderTexID() != ResourceId()) |
| 3725 | { |
| 3726 | textureId = m_Output->GetCustomShaderTexID(); |
| 3727 | sub.slice = sub.sample = 0; |
| 3728 | typeCast = CompType::Typeless; |
| 3729 | } |
| 3730 | |
| 3731 | PixelValue min, max; |
| 3732 | rdctie(min, max) = r->GetMinMax(textureId, sub, typeCast); |
| 3733 | |
| 3734 | { |
| 3735 | float minval = FLT_MAX; |
| 3736 | float maxval = -FLT_MAX; |
| 3737 | |
| 3738 | bool changeRange = false; |
| 3739 | |
| 3740 | ResourceFormat fmt = GetCurrentTexture()->format; |
| 3741 | |
| 3742 | if(m_TexDisplay.customShaderId != ResourceId()) |
| 3743 | { |
| 3744 | fmt.compType = CompType::Float; |
| 3745 | } |
| 3746 | if(fmt.compType == CompType::Typeless && m_TexDisplay.typeCast == CompType::UInt) |
| 3747 | fmt.compType = CompType::UInt; |
| 3748 | if(fmt.compType == CompType::Typeless && m_TexDisplay.typeCast == CompType::SInt) |
| 3749 | fmt.compType = CompType::SInt; |
| 3750 | |
| 3751 | for(int i = 0; i < 4; i++) |
| 3752 | { |
| 3753 | if(fmt.compType == CompType::UInt) |
| 3754 | { |
| 3755 | min.floatValue[i] = min.uintValue[i]; |
| 3756 | max.floatValue[i] = max.uintValue[i]; |
| 3757 | } |
| 3758 | else if(fmt.compType == CompType::SInt) |
| 3759 | { |
| 3760 | min.floatValue[i] = min.intValue[i]; |
| 3761 | max.floatValue[i] = max.intValue[i]; |
| 3762 | } |
| 3763 | } |
| 3764 | |
| 3765 | if(m_TexDisplay.red) |
| 3766 | { |
| 3767 | minval = qMin(minval, min.floatValue[0]); |
| 3768 | maxval = qMax(maxval, max.floatValue[0]); |
| 3769 | changeRange = true; |
| 3770 | } |
nothing calls this directly
no test coverage detected