| 238 | } |
| 239 | |
| 240 | TempRenderTarget* PostProcessor::DOF(ID3D11ShaderResourceView* input, ID3D11ShaderResourceView* depthBuffer, |
| 241 | TempRenderTarget*& nearMask) |
| 242 | { |
| 243 | uint32 dofResX = inputWidth / 2; |
| 244 | uint32 dofResY = inputHeight / 2; |
| 245 | |
| 246 | TempRenderTarget* nearTarget = GetTempRenderTarget(dofResX, dofResY, DXGI_FORMAT_R16G16B16A16_FLOAT); |
| 247 | TempRenderTarget* farTarget = GetTempRenderTarget(dofResX, dofResY, DXGI_FORMAT_R16G16B16A16_FLOAT); |
| 248 | |
| 249 | inputs.push_back(input); |
| 250 | inputs.push_back(depthBuffer); |
| 251 | outputs.push_back(nearTarget->RTView); |
| 252 | outputs.push_back(farTarget->RTView); |
| 253 | |
| 254 | if(AppSettings::MSAAMode == MSAAModes::MSAANone) |
| 255 | PostProcess(dofDownscale[0], L"DOF Downscale"); |
| 256 | else |
| 257 | PostProcess(dofDownscale[1], L"DOF Downscale"); |
| 258 | |
| 259 | const uint32 tileSize = 32; |
| 260 | const uint32 numTilesX = (inputWidth + (tileSize - 1)) / tileSize; |
| 261 | const uint32 numTilesY = (inputHeight + (tileSize - 1)) / tileSize; |
| 262 | TempRenderTarget* nearMaskInitial = GetTempRenderTarget(numTilesX, numTilesY, DXGI_FORMAT_R16_UNORM, 1, 0, 1, false, true); |
| 263 | |
| 264 | ID3D11RenderTargetView* rtvs[2] = { nullptr, nullptr }; |
| 265 | context->OMSetRenderTargets(2, rtvs, nullptr); |
| 266 | SetCSInputs(context, nearTarget->SRView); |
| 267 | SetCSOutputs(context, nearMaskInitial->UAView); |
| 268 | SetCSShader(context, computeNearMask16); |
| 269 | |
| 270 | context->Dispatch(numTilesX, numTilesY, 1); |
| 271 | |
| 272 | ClearCSInputs(context); |
| 273 | ClearCSOutputs(context); |
| 274 | |
| 275 | nearMask = GetTempRenderTarget(numTilesX, numTilesY, DXGI_FORMAT_R16_UNORM, 1, 0, 1, false, false); |
| 276 | PostProcess(nearMaskInitial->SRView, nearMask->RTView, dilateNearMask, L"Dilate Near Mask"); |
| 277 | |
| 278 | nearMaskInitial->InUse = false; |
| 279 | |
| 280 | const uint32 numIterations = 1; |
| 281 | for(uint32 i = 0; i < numIterations; ++i) |
| 282 | { |
| 283 | TempRenderTarget* nearMaskTemp = GetTempRenderTarget(numTilesX, numTilesY, nearMask->Format); |
| 284 | PostProcess(nearMask->SRView, nearMaskTemp->RTView, nearMaskBlurH, L"Near Mask Blur H"); |
| 285 | |
| 286 | PostProcess(nearMaskTemp->SRView, nearMask->RTView, nearMaskBlurV, L"Near Mask Blur V"); |
| 287 | nearMaskTemp->InUse = false; |
| 288 | } |
| 289 | |
| 290 | TempRenderTarget* nearResult = GetTempRenderTarget(dofResX, dofResY, DXGI_FORMAT_R16G16B16A16_FLOAT); |
| 291 | TempRenderTarget* farResult = GetTempRenderTarget(dofResX, dofResY, DXGI_FORMAT_R16G16B16A16_FLOAT); |
| 292 | |
| 293 | inputs.push_back(nearTarget->SRView); |
| 294 | inputs.push_back(farTarget->SRView); |
| 295 | inputs.push_back(nearMask->SRView); |
| 296 | outputs.push_back(nearResult->RTView); |
| 297 | outputs.push_back(farResult->RTView); |
nothing calls this directly
no test coverage detected