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

Method RequestHalfResDepth

Source/Engine/Graphics/RenderBuffers.cpp:82–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80}
81
82GPUTexture* 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
117GPUTexture* RenderBuffers::RequestHiZ(GPUContext* context, bool fullRes, int32 mipLevels)
118{

Callers 3

RenderMotionVectorsMethod · 0.80
RenderMethod · 0.80
RenderMethod · 0.80

Calls 9

GetResolutionFunction · 0.85
New2DFunction · 0.85
ReleaseFunction · 0.85
FormatMethod · 0.80
DownscaleDepthMethod · 0.80
InstanceClass · 0.50
GetFunction · 0.50
IsReadyMethod · 0.45
ViewMethod · 0.45

Tested by

no test coverage detected