| 1386 | } |
| 1387 | |
| 1388 | void GlobalSurfaceAtlasPass::RenderDebug(RenderContext& renderContext, GPUContext* context, GPUTexture* output) |
| 1389 | { |
| 1390 | // Render all dependant effects before |
| 1391 | if (EnumHasAnyFlags(renderContext.View.Flags, ViewFlags::GI)) |
| 1392 | { |
| 1393 | switch (renderContext.List->Settings.GlobalIllumination.Mode) |
| 1394 | { |
| 1395 | case GlobalIlluminationMode::DDGI: |
| 1396 | DynamicDiffuseGlobalIlluminationPass::Instance()->Render(renderContext, context, nullptr); |
| 1397 | break; |
| 1398 | } |
| 1399 | } |
| 1400 | GlobalSignDistanceFieldPass::BindingData bindingDataSDF; |
| 1401 | BindingData bindingData; |
| 1402 | if (GlobalSignDistanceFieldPass::Instance()->Render(renderContext, context, bindingDataSDF) || Render(renderContext, context, bindingData)) |
| 1403 | { |
| 1404 | context->Draw(output, renderContext.Buffers->GBuffer0); |
| 1405 | return; |
| 1406 | } |
| 1407 | GPUTextureView* skybox = GBufferPass::Instance()->RenderSkybox(renderContext, context); |
| 1408 | |
| 1409 | PROFILE_GPU_CPU("Global Surface Atlas Debug"); |
| 1410 | const Float2 outputSize(output->Size()); |
| 1411 | Data0 data; |
| 1412 | { |
| 1413 | data.ViewWorldPos = renderContext.View.Position; |
| 1414 | data.ViewNearPlane = renderContext.View.Near; |
| 1415 | data.ViewFarPlane = renderContext.View.Far; |
| 1416 | for (int32 i = 0; i < 4; i++) |
| 1417 | data.ViewFrustumWorldRays[i] = Float4(renderContext.List->FrustumCornersWs[i + 4], 0); |
| 1418 | data.GlobalSDF = bindingDataSDF.Constants; |
| 1419 | data.GlobalSurfaceAtlas = bindingData.Constants; |
| 1420 | data.SkyboxIntensity = 1.0f; |
| 1421 | context->UpdateCB(_cb0, &data); |
| 1422 | context->BindCB(0, _cb0); |
| 1423 | } |
| 1424 | context->BindSR(0, bindingDataSDF.Texture ? bindingDataSDF.Texture->ViewVolume() : nullptr); |
| 1425 | context->BindSR(1, bindingDataSDF.TextureMip ? bindingDataSDF.TextureMip->ViewVolume() : nullptr); |
| 1426 | context->BindSR(2, bindingData.Chunks ? bindingData.Chunks->View() : nullptr); |
| 1427 | context->BindSR(3, bindingData.CulledObjects ? bindingData.CulledObjects->View() : nullptr); |
| 1428 | context->BindSR(4, bindingData.Objects ? bindingData.Objects->View() : nullptr); |
| 1429 | context->BindSR(6, bindingData.AtlasDepth->View()); |
| 1430 | context->BindSR(7, skybox); |
| 1431 | context->SetState(_psDebug0); |
| 1432 | { |
| 1433 | Float2 outputSizeThird = outputSize * 0.333f; |
| 1434 | Float2 outputSizeTwoThird = outputSize * 0.666f; |
| 1435 | |
| 1436 | auto tempBuffer = RenderTargetPool::Get(output->GetDescription()); |
| 1437 | RENDER_TARGET_POOL_SET_NAME(tempBuffer, "GlobalSurfaceAtlas.TempBuffer"); |
| 1438 | context->Clear(tempBuffer->View(), Color::Black); |
| 1439 | context->SetRenderTarget(tempBuffer->View()); |
| 1440 | |
| 1441 | // Full screen - direct light |
| 1442 | context->BindSR(5, bindingData.AtlasLighting->View()); |
| 1443 | context->SetViewport(outputSize.X, outputSize.Y); |
| 1444 | context->SetScissor(Rectangle(0, 0, outputSize.X, outputSize.Y)); |
| 1445 | context->DrawFullscreenTriangle(); |
nothing calls this directly
no test coverage detected