| 80 | } |
| 81 | |
| 82 | GPUTexture* RenderBuffers::RequestHalfResDepth(GPUContext* context) |
| 83 | { |
| 84 | // Skip if already done in the current frame |
| 85 | const auto currentFrame = Engine::FrameCount; |
| 86 | if (LastFrameHalfResDepth == currentFrame) |
| 87 | return HalfResDepth; |
| 88 | if (!MultiScaler::Instance()->IsReady()) |
| 89 | return DepthBuffer; |
| 90 | |
| 91 | auto format = DepthBuffer->Format(); |
| 92 | auto width = RenderTools::GetResolution(_width, ResolutionMode::Half); |
| 93 | auto height = RenderTools::GetResolution(_height, ResolutionMode::Half); |
| 94 | auto tempDesc = GPUTextureDescription::New2D(width, height, format, DepthBuffer->Flags()); |
| 95 | |
| 96 | LastFrameHalfResDepth = currentFrame; |
| 97 | if (HalfResDepth == nullptr) |
| 98 | { |
| 99 | // Missing buffer |
| 100 | HalfResDepth = RenderTargetPool::Get(tempDesc); |
| 101 | RENDER_TARGET_POOL_SET_NAME(HalfResDepth, "HalfResDepth"); |
| 102 | } |
| 103 | else if (HalfResDepth->Width() != width || HalfResDepth->Height() != height || HalfResDepth->Format() != format) |
| 104 | { |
| 105 | // Wrong size buffer |
| 106 | RenderTargetPool::Release(HalfResDepth); |
| 107 | HalfResDepth = RenderTargetPool::Get(tempDesc); |
| 108 | RENDER_TARGET_POOL_SET_NAME(HalfResDepth, "HalfResDepth"); |
| 109 | } |
| 110 | |
| 111 | // Generate depth |
| 112 | MultiScaler::Instance()->DownscaleDepth(context, width, height, DepthBuffer, HalfResDepth->View()); |
| 113 | |
| 114 | return HalfResDepth; |
| 115 | } |
| 116 | |
| 117 | GPUTexture* RenderBuffers::RequestHiZ(GPUContext* context, bool fullRes, int32 mipLevels) |
| 118 | { |
no test coverage detected