MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / DownscaleDepth

Method DownscaleDepth

Source/Engine/Renderer/Utils/MultiScaler.cpp:215–249  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

213}
214
215void MultiScaler::DownscaleDepth(GPUContext* context, int32 dstWidth, int32 dstHeight, GPUTexture* src, GPUTextureView* dst)
216{
217 PROFILE_GPU_CPU("Downscale Depth");
218 bool outputDepth = ((GPUTexture*)dst->GetParent())->IsDepthStencil();
219 if (checkIfSkipPass())
220 {
221 if (outputDepth)
222 context->ClearDepth(dst);
223 else
224 context->Clear(dst, Color::Transparent);
225 return;
226 }
227
228 // Prepare
229 Data data;
230 data.TexelSize.X = 1.0f / (float)src->Width();
231 data.TexelSize.Y = 1.0f / (float)src->Height();
232 auto cb = _shader->GetShader()->GetCB(0);
233 context->UpdateCB(cb, &data);
234 context->BindCB(0, cb);
235
236 // Draw
237 context->SetViewportAndScissors((float)dstWidth, (float)dstHeight);
238 if (outputDepth)
239 context->SetRenderTarget(dst, (GPUTextureView*)nullptr);
240 else
241 context->SetRenderTarget(dst);
242 context->BindSR(0, src);
243 context->SetState(_psHalfDepth[outputDepth ? 1 : 0]);
244 context->DrawFullscreenTriangle();
245
246 // Cleanup
247 context->ResetRenderTarget();
248 context->UnBindCB(0);
249}
250
251void MultiScaler::BuildHiZ(GPUContext* context, GPUTexture* srcDepth, GPUTexture* dstHiZ)
252{

Callers 1

RequestHalfResDepthMethod · 0.80

Calls 12

IsDepthStencilMethod · 0.80
GetParentMethod · 0.45
ClearDepthMethod · 0.45
ClearMethod · 0.45
GetShaderMethod · 0.45
UpdateCBMethod · 0.45
BindCBMethod · 0.45
SetRenderTargetMethod · 0.45
BindSRMethod · 0.45
SetStateMethod · 0.45
ResetRenderTargetMethod · 0.45

Tested by

no test coverage detected