ggerganov/imgui-ws

Is compressor enable ?

Eragon-Brisingr opened this issue · 5 comments

I find compressor diff funtion cost large time, but it seem not use.

Can you clarify?

The compression is used here: https://github.com/ggerganov/imgui-ws/blob/master/src/imgui-ws.cpp#L343-L351

But dataRead.drawListsDiff can not find any read reference. And i cancel calculate diff imgui-ws seem render right.

// calculate diff
m_drawListsDiff.clear();
m_drawListsDiff.resize(nCmdLists);
for (uint32_t iList = 0; iList < nCmdLists; ++iList) {
auto & bufferCur = m_drawListsCur[iList];
auto & bufferDiff = m_drawListsDiff[iList];
bufferDiff.clear();
int32_t type = 1; // Run-Length Encoding
if (iList >= m_drawListsPrev.size() || m_drawListsPrev[iList].size() != bufferCur.size()) {
type = 0; // Full update
}
std::copy((char *)(&type), (char *)(&type) + sizeof(type), std::back_inserter(bufferDiff));
if (type == 0) {
std::copy(bufferCur.begin(), bufferCur.end(), std::back_inserter(bufferDiff));
} else if (type == 1) {
auto & bufferPrev = m_drawListsPrev[iList];
uint32_t a = 0;
uint32_t b = 0;
uint32_t c = 0;
uint32_t n = 0;
for (int i = 0; i < (int) bufferCur.size(); i += 4) {
std::memcpy((char *)(&a), bufferPrev.data() + i, sizeof(uint32_t));
std::memcpy((char *)(&b), bufferCur.data() + i, sizeof(uint32_t));
a = a ^ b;
if (a == c) {
++n;
} else {
if (n > 0) {
std::copy((char *)(&n), (char *)(&n) + sizeof(uint32_t), std::back_inserter(bufferDiff));
std::copy((char *)(&c), (char *)(&c) + sizeof(uint32_t), std::back_inserter(bufferDiff));
}
n = 1;
c = a;
}
}
if (bufferCur.size() % 4 != 0) {
a = 0;
b = 0;
uint32_t i = (bufferCur.size()/4)*4;
uint32_t k = bufferCur.size() - i;
std::memcpy((char *)(&a), bufferPrev.data() + i, k);
std::memcpy((char *)(&b), bufferCur.data() + i, k);
a = a ^ b;
if (a == c) {
++n;
} else {
std::copy((char *)(&n), (char *)(&n) + sizeof(uint32_t), std::back_inserter(bufferDiff));
std::copy((char *)(&c), (char *)(&c) + sizeof(uint32_t), std::back_inserter(bufferDiff));
n = 1;
c = a;
}
}
std::copy((char *)(&n), (char *)(&n) + sizeof(uint32_t), std::back_inserter(bufferDiff));
std::copy((char *)(&c), (char *)(&c) + sizeof(uint32_t), std::back_inserter(bufferDiff));
}
}
return true;

image

when draw many shape, Incppect::update cost too much time.

Probably, the compression is not efficient for your scene.

If it is possible, you can try to record your session and we can analyze the data to see what is the problem. To record a session, check the record-sdl2 tool. Basically, you need to grab the Session class from here and use it to save your frames to a file. The file will be probably big, but if you could send it to me somehow, I can try to improve the compression algorithm to perform better in your case. You can also run the compressor-benchmark tool to get some information about the compression rate and performance for you scene.

ImGui_WS性能
Maybe is stl debug too slow, I try unreal engine development settings, the performance is can accept.