| 249 | } |
| 250 | |
| 251 | void MultiScaler::BuildHiZ(GPUContext* context, GPUTexture* srcDepth, GPUTexture* dstHiZ) |
| 252 | { |
| 253 | PROFILE_GPU_CPU("Build HiZ"); |
| 254 | |
| 255 | int32 dstWidth = dstHiZ->Width(); |
| 256 | int32 dstHeight = dstHiZ->Height(); |
| 257 | |
| 258 | // Copy mip0 |
| 259 | if (srcDepth->Size() == dstHiZ->Size() && srcDepth->Format() == dstHiZ->Format()) |
| 260 | { |
| 261 | context->CopySubresource(dstHiZ, 0, srcDepth, 0); |
| 262 | } |
| 263 | else if (srcDepth->Size() == dstHiZ->Size()) |
| 264 | { |
| 265 | context->Draw(dstHiZ, srcDepth); |
| 266 | } |
| 267 | else |
| 268 | { |
| 269 | context->SetViewportAndScissors((float)dstWidth, (float)dstHeight); |
| 270 | context->SetRenderTarget(dstHiZ->View()); |
| 271 | context->BindSR(0, srcDepth); |
| 272 | context->SetState(_psHalfDepth[2]); |
| 273 | context->DrawFullscreenTriangle(); |
| 274 | } |
| 275 | |
| 276 | // Build mip chain |
| 277 | for (int32 mip = 1; mip < dstHiZ->MipLevels(); mip++) |
| 278 | { |
| 279 | const int32 mipWidth = Math::Max(dstWidth >> mip, 1); |
| 280 | const int32 mipHeight = Math::Max(dstHeight >> mip, 1); |
| 281 | context->ResetRenderTarget(); |
| 282 | |
| 283 | context->SetViewportAndScissors((float)mipWidth, (float)mipHeight); |
| 284 | context->SetRenderTarget(dstHiZ->View(0, mip)); |
| 285 | context->BindSR(0, dstHiZ->View(0, mip - 1)); |
| 286 | context->SetState(_psHalfDepth[2]); |
| 287 | context->DrawFullscreenTriangle(); |
| 288 | } |
| 289 | |
| 290 | context->ResetRenderTarget(); |
| 291 | context->UnBindCB(0); |
| 292 | } |
| 293 | |
| 294 | void MultiScaler::Upscale(GPUContext* context, const Viewport& viewport, GPUTexture* src, GPUTextureView* dst) |
| 295 | { |
no test coverage detected