a bug regarding the usage of omm::Cpu::BakeInputDesc.formats
Hey guys! I'm trying to use formats array to override the global format when I'm testing cpu minimal sample, but the baking result is wrong. The key problem is that when going to file bake_cpu_impl.cpp, the func still use global format, but not consider formats override, that causes wrong result state of microTriangles, ommArrayData resize, ommArrayDataOffset and so on; Here is the correction code that could be referenced. It should be tested carefully before merged, while only my cases run well. And I didn't test GPU bake, maybe there has the same bug. By the way, I didn't see new feature of "index offset" of CPU bake, but only GPU bake.
bake_cpu_impl.cpp: static ommResult Serialize(... , line 1763 to line 1772 change to:
const uint32_t omm2stateBitCount = omm::bird::GetBitCount(ommFormat_OC1_2_State);
const uint32_t omm4stateBitCount = omm::bird::GetBitCount(ommFormat_OC1_4_State);
uint32_t ommDescArrayCount = 0;
size_t ommArrayDataSize = 0;
for (uint32_t i = 0; i < kMaxNumSubdivLevels; ++i) {
const uint32_t ommCount = ommArrayHistogram.GetOmmCount(ommFormat_OC1_2_State, i);
ommDescArrayCount += ommCount;
const size_t numOmmForSubDivLvl = (size_t)omm::bird::GetNumMicroTriangles(i) * omm2stateBitCount;
ommArrayDataSize += size_t(ommCount) * std::max<size_t>(numOmmForSubDivLvl >> 3ull, 1ull);
}
for (uint32_t i = 0; i < kMaxNumSubdivLevels; ++i) {
const uint32_t ommCount = ommArrayHistogram.GetOmmCount(ommFormat_OC1_4_State, i);
ommDescArrayCount += ommCount;
const size_t numOmmForSubDivLvl = (size_t)omm::bird::GetNumMicroTriangles(i) * omm4stateBitCount;
ommArrayDataSize += size_t(ommCount) * std::max<size_t>(numOmmForSubDivLvl >> 3ull, 1ull);
}
line 1819 change to:
ommArrayDataOffset += std::max((numMicroTriangles * (is2State? omm2stateBitCount : omm4stateBitCount)) >> 3u, 1u);
and in this file all code like:
const ommOpacityState state = GetStateFromCoverage(desc.format ...
should be changed to:
const ommOpacityState state = GetStateFromCoverage(workItem.vmFormat ...
And also I found another bug. In file serialize_impl.cpp:line 134 and line 147, if inputDesc.formats is valid, numFormats and numSubdivLvls should be inputDesc.indexCount / 3, not inputDesc.indexCount, for every 3 indices forms a particular triangle which owns its format and level, not every index has its format and level
Thank you for reporting these issues! The use of the non-global formats is indeed lacking in our testing and it's quite likely that you're right. Will take a look at these as soon as possible