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

Method BuildHiZ

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

Source from the content-addressed store, hash-verified

249}
250
251void 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
294void MultiScaler::Upscale(GPUContext* context, const Viewport& viewport, GPUTexture* src, GPUTextureView* dst)
295{

Callers 1

RequestHiZMethod · 0.80

Calls 11

FormatMethod · 0.80
MaxFunction · 0.50
SizeMethod · 0.45
CopySubresourceMethod · 0.45
DrawMethod · 0.45
SetRenderTargetMethod · 0.45
ViewMethod · 0.45
BindSRMethod · 0.45
SetStateMethod · 0.45
ResetRenderTargetMethod · 0.45

Tested by

no test coverage detected