* Converts an image of the given format to an RGBA float image. */
| 161 | * Converts an image of the given format to an RGBA float image. |
| 162 | */ |
| 163 | static std::vector<float> convertToRGBA32Float(ResourceFormat format, uint32_t width, uint32_t height, const void* pData) |
| 164 | { |
| 165 | FALCOR_ASSERT(isConvertibleToRGBA32Float(format)); |
| 166 | |
| 167 | FormatType type = getFormatType(format); |
| 168 | uint32_t channelCount = getFormatChannelCount(format); |
| 169 | uint32_t channelBits = getNumChannelBits(format, 0); |
| 170 | |
| 171 | std::vector<float> floatData; |
| 172 | |
| 173 | if (type == FormatType::Float && channelBits == 16) |
| 174 | { |
| 175 | floatData = convertHalfToRGBA32Float(width, height, channelCount, pData); |
| 176 | } |
| 177 | else if (type == FormatType::Uint && channelBits == 16) |
| 178 | { |
| 179 | floatData = convertIntToRGBA32Float<uint16_t>(width, height, channelCount, pData); |
| 180 | } |
| 181 | else if (type == FormatType::Uint && channelBits == 32) |
| 182 | { |
| 183 | floatData = convertIntToRGBA32Float<uint32_t>(width, height, channelCount, pData); |
| 184 | } |
| 185 | else if (type == FormatType::Sint && channelBits == 16) |
| 186 | { |
| 187 | floatData = convertIntToRGBA32Float<int16_t>(width, height, channelCount, pData); |
| 188 | } |
| 189 | else if (type == FormatType::Sint && channelBits == 32) |
| 190 | { |
| 191 | floatData = convertIntToRGBA32Float<int32_t>(width, height, channelCount, pData); |
| 192 | } |
| 193 | else |
| 194 | { |
| 195 | FALCOR_UNREACHABLE(); |
| 196 | } |
| 197 | |
| 198 | // Default alpha channel to 1. |
| 199 | if (channelCount < 4) |
| 200 | { |
| 201 | for (uint32_t i = 0; i < width * height; ++i) |
| 202 | floatData[i * 4 + 3] = 1.f; |
| 203 | } |
| 204 | |
| 205 | return floatData; |
| 206 | } |
| 207 | |
| 208 | /** |
| 209 | * Converts 96bpp to 128bpp RGBA without clamping. |
no test coverage detected