| 173 | } |
| 174 | |
| 175 | void SimplePostFX::execute(RenderContext* pRenderContext, const RenderData& renderData) |
| 176 | { |
| 177 | auto pSrc = renderData.getTexture(kSrc); |
| 178 | auto pDst = renderData.getTexture(kDst); |
| 179 | FALCOR_ASSERT(pSrc && pDst); |
| 180 | |
| 181 | // Issue error and disable pass if I/O size doesn't match. The user can hit continue and fix the config or abort. |
| 182 | if (getEnabled() && (pSrc->getWidth() != pDst->getWidth() || pSrc->getHeight() != pDst->getHeight())) |
| 183 | { |
| 184 | logError("SimplePostFX I/O sizes don't match. The pass will be disabled."); |
| 185 | mEnabled = false; |
| 186 | } |
| 187 | const uint2 resolution = uint2(pSrc->getWidth(), pSrc->getHeight()); |
| 188 | |
| 189 | // if we have 'identity' settings, we can just copy input to output |
| 190 | // clang-format off |
| 191 | if (getEnabled() == false || getWipe() >= 1.f || ( |
| 192 | getBloomAmount() == 0.f && |
| 193 | getChromaticAberrationAmount() == 0.f && |
| 194 | getBarrelDistortAmount() == 0.f && |
| 195 | all(getSaturationCurve() == float3(1.f)) && |
| 196 | all(getColorOffset() == float3(0.5f)) && |
| 197 | all(getColorScale() == float3(0.5f)) && |
| 198 | all(getColorPower() == float3(0.5f)) && |
| 199 | getColorOffsetScalar() == 0.f && |
| 200 | getColorScaleScalar() == 0.f && |
| 201 | getColorPowerScalar() == 0.f |
| 202 | )) |
| 203 | { |
| 204 | // wipe is all the way across, which corresponds to no effect |
| 205 | pRenderContext->blit(pSrc->getSRV(), pDst->getRTV()); |
| 206 | return; |
| 207 | } |
| 208 | // clang-format on |
| 209 | |
| 210 | preparePostFX(pRenderContext, resolution.x, resolution.y); |
| 211 | if (getBloomAmount() > 0.f) |
| 212 | { |
| 213 | // Downsampling |
| 214 | { |
| 215 | auto var = mpDownsamplePass->getRootVar(); |
| 216 | var["gLinearSampler"] = mpLinearSampler; |
| 217 | for (int level = 0; level < kNumLevels; ++level) |
| 218 | { |
| 219 | uint2 res = {std::max(1u, resolution.x >> (level + 1)), std::max(1u, resolution.y >> (level + 1))}; |
| 220 | float2 invres = float2(1.f / res.x, 1.f / res.y); |
| 221 | var["PerFrameCB"]["gResolution"] = res; |
| 222 | var["PerFrameCB"]["gInvRes"] = invres; |
| 223 | var["gSrc"] = level ? mpPyramid[level] : pSrc; |
| 224 | var["gDst"] = mpPyramid[level + 1]; |
| 225 | mpDownsamplePass->execute(pRenderContext, uint3(res, 1)); |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | // Upsampling |
| 230 | { |
| 231 | auto var = mpUpsamplePass->getRootVar(); |
| 232 | var["gLinearSampler"] = mpLinearSampler; |
nothing calls this directly
no test coverage detected