| 129 | } |
| 130 | |
| 131 | void ErrorMeasurePass::execute(RenderContext* pRenderContext, const RenderData& renderData) |
| 132 | { |
| 133 | ref<Texture> pSourceImageTexture = renderData.getTexture(kInputChannelSourceImage); |
| 134 | ref<Texture> pOutputImageTexture = renderData.getTexture(kOutputChannelImage); |
| 135 | |
| 136 | // Create the texture for the difference image if this is our first |
| 137 | // time through or if the source image resolution has changed. |
| 138 | const uint32_t width = pSourceImageTexture->getWidth(), height = pSourceImageTexture->getHeight(); |
| 139 | if (!mpDifferenceTexture || mpDifferenceTexture->getWidth() != width || mpDifferenceTexture->getHeight() != height) |
| 140 | { |
| 141 | mpDifferenceTexture = mpDevice->createTexture2D( |
| 142 | width, |
| 143 | height, |
| 144 | ResourceFormat::RGBA32Float, |
| 145 | 1, |
| 146 | 1, |
| 147 | nullptr, |
| 148 | ResourceBindFlags::ShaderResource | ResourceBindFlags::UnorderedAccess |
| 149 | ); |
| 150 | FALCOR_ASSERT(mpDifferenceTexture); |
| 151 | } |
| 152 | |
| 153 | mMeasurements.valid = false; |
| 154 | |
| 155 | ref<Texture> pReference = getReference(renderData); |
| 156 | if (!pReference) |
| 157 | { |
| 158 | // We don't have a reference image, so just copy the source image to the output. |
| 159 | pRenderContext->blit(pSourceImageTexture->getSRV(), pOutputImageTexture->getRTV()); |
| 160 | return; |
| 161 | } |
| 162 | |
| 163 | runDifferencePass(pRenderContext, renderData); |
| 164 | runReductionPasses(pRenderContext, renderData); |
| 165 | |
| 166 | switch (mSelectedOutputId) |
| 167 | { |
| 168 | case OutputId::Source: |
| 169 | pRenderContext->blit(pSourceImageTexture->getSRV(), pOutputImageTexture->getRTV()); |
| 170 | break; |
| 171 | case OutputId::Reference: |
| 172 | pRenderContext->blit(pReference->getSRV(), pOutputImageTexture->getRTV()); |
| 173 | break; |
| 174 | case OutputId::Difference: |
| 175 | pRenderContext->blit(mpDifferenceTexture->getSRV(), pOutputImageTexture->getRTV()); |
| 176 | break; |
| 177 | default: |
| 178 | FALCOR_THROW("ErrorMeasurePass: Unhandled OutputId case"); |
| 179 | } |
| 180 | |
| 181 | saveMeasurementsToFile(); |
| 182 | } |
| 183 | |
| 184 | void ErrorMeasurePass::runDifferencePass(RenderContext* pRenderContext, const RenderData& renderData) |
| 185 | { |
no test coverage detected