| 156 | } |
| 157 | |
| 158 | void 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 | |
| 199 | void RenderContext::submit(bool wait) |
| 200 | { |
no test coverage detected