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

Function clampIfNeeded

Source/Falcor/Utils/Image/ImageIO.cpp:210–230  ·  view source on GitHub ↗

Check if any of base image dimensions need to be clamped to a multiple of 4. This function should only be called if the image is being compressed and mipmaps are being automatically generated.

Source from the content-addressed store, hash-verified

208// Check if any of base image dimensions need to be clamped to a multiple of 4.
209// This function should only be called if the image is being compressed and mipmaps are being automatically generated.
210bool clampIfNeeded(ExportData& image)
211{
212 bool clamped = false;
213 if (image.width > 1u && image.width % 4 != 0)
214 {
215 image.width = std::max(1u, image.width - image.width % 4);
216 clamped = true;
217 }
218 if (image.height > 1u && image.height % 4 != 0)
219 {
220 image.height = std::max(1u, image.height - image.height % 4);
221 clamped = true;
222 }
223 if (image.depth > 1u && image.depth % 4 != 0)
224 {
225 image.depth = std::max(1u, image.depth - image.depth % 4);
226 clamped = true;
227 }
228
229 return clamped;
230}
231
232// Fill the alpha channel with 1's.
233void fillAlphaChannel(nvtt::Surface& image)

Callers 1

saveToDDSMethod · 0.85

Calls 1

maxFunction · 0.50

Tested by

no test coverage detected