MCPcopy Create free account
hub / github.com/deathkiller/jazz2-native / GetSortKey

Method GetSortKey

Sources/nCine/Graphics/Material.cpp:194–208  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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}

Callers 1

Calls 2

glBlendingFactorToIntFunction · 0.85
GetGLHandleMethod · 0.45

Tested by

no test coverage detected