| 192 | } |
| 193 | |
| 194 | std::uint32_t Material::GetSortKey() |
| 195 | { |
| 196 | constexpr std::uint32_t Seed = 1697381921; |
| 197 | // Align to 64 bits for `fasthash64()` to properly work on Emscripten without alignment faults |
| 198 | static SortHashData hashData alignas(8); |
| 199 | |
| 200 | for (std::uint32_t i = 0; i < GLTexture::MaxTextureUnits; i++) { |
| 201 | hashData.textures[i] = (textures_[i] != nullptr) ? textures_[i]->GetGLHandle() : 0; |
| 202 | } |
| 203 | hashData.shaderProgram = shaderProgram_->GetGLHandle(); |
| 204 | hashData.srcBlendingFactor = glBlendingFactorToInt(srcBlendingFactor_); |
| 205 | hashData.destBlendingFactor = glBlendingFactorToInt(destBlendingFactor_); |
| 206 | |
| 207 | return (std::uint32_t)xxHash3(reinterpret_cast<const void*>(&hashData), sizeof(SortHashData), Seed); |
| 208 | } |
| 209 | } |
no test coverage detected