MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / clearTexture

Method clearTexture

Source/Falcor/Core/API/RenderContext.cpp:158–197  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

156}
157
158void RenderContext::clearTexture(Texture* pTexture, const float4& clearColor)
159{
160 FALCOR_ASSERT(pTexture);
161
162 // Check that the format is either Unorm, Snorm or float
163 auto format = pTexture->getFormat();
164 auto fType = getFormatType(format);
165 if (fType == FormatType::Sint || fType == FormatType::Uint || fType == FormatType::Unknown)
166 {
167 logWarning(
168 "RenderContext::clearTexture() - Unsupported texture format {}. The texture format must be a normalized or floating-point "
169 "format.",
170 to_string(format)
171 );
172 return;
173 }
174
175 auto bindFlags = pTexture->getBindFlags();
176 // Select the right clear based on the texture's binding flags
177 if (is_set(bindFlags, ResourceBindFlags::RenderTarget))
178 clearRtv(pTexture->getRTV().get(), clearColor);
179 else if (is_set(bindFlags, ResourceBindFlags::UnorderedAccess))
180 clearUAV(pTexture->getUAV().get(), clearColor);
181 else if (is_set(bindFlags, ResourceBindFlags::DepthStencil))
182 {
183 if (isStencilFormat(format) && (clearColor.y != 0))
184 {
185 logWarning(
186 "RenderContext::clearTexture() - when clearing a depth-stencil texture the stencil value(clearColor.y) must be 0. Received "
187 "{}. Forcing stencil to 0.",
188 clearColor.y
189 );
190 }
191 clearDsv(pTexture->getDSV().get(), clearColor.r, 0);
192 }
193 else
194 {
195 logWarning("Texture::clear() - The texture does not have a bind flag that allows us to clear!");
196 }
197}
198
199void RenderContext::submit(bool wait)
200{

Callers 4

clearBuffersMethod · 0.80
executeMethod · 0.80
executeMethod · 0.80

Calls 9

getFormatTypeFunction · 0.85
isStencilFormatFunction · 0.85
getFormatMethod · 0.80
getRTVMethod · 0.80
getDSVMethod · 0.80
to_stringFunction · 0.70
logWarningFunction · 0.50
getMethod · 0.45
getUAVMethod · 0.45

Tested by

no test coverage detected