diff --git a/decompress.cc b/decompress.cc index 163949f..989e081 100644 --- a/decompress.cc +++ b/decompress.cc @@ -213,7 +213,7 @@ std::vector decompressLZW(uint8_t const* data, size_t len, size_t retle printf("Verbatim: %x\n", bits); #endif if (!cur_string.empty()) { - to_dict = cur_string; + to_dict = std::move(cur_string); to_dict.push_back(bits); } cur_string = {static_cast(bits)}; @@ -224,7 +224,7 @@ std::vector decompressLZW(uint8_t const* data, size_t len, size_t retle [](uint8_t const& d) { printf("%.2x ", d); }); printf("\n"); #endif - to_dict = cur_string; + to_dict = std::move(cur_string); to_dict.push_back(dict[bits-DICT_OFS][0]); cur_string = dict[bits-DICT_OFS]; } else { diff --git a/render/Object.cc b/render/Object.cc index 4b3e6e8..d4cb56b 100644 --- a/render/Object.cc +++ b/render/Object.cc @@ -212,6 +212,7 @@ namespace render { unsigned minSize = std::numeric_limits::max(); unsigned accumWidth = 0, maxHeight = 0, maxWidth = 0; unsigned i = 0; + unsigned pixelCount = 0; for (auto& tex : texs) { if (usedTexs.find(i++) == usedTexs.end()) continue; @@ -220,7 +221,7 @@ namespace render { accumWidth += tex.width; maxHeight = std::max(maxHeight, tex.height); maxWidth = std::max(maxWidth, tex.width); - + pixelCount += tex.height*tex.width; } // Set lower bound of minSize to ensure a minimum number of mipmap levels @@ -275,7 +276,9 @@ namespace render { xpos += alignWidth; } unsigned atlasWidth = std::max(xpos, maxWidth), atlasHeight = ypos+lineMaxHeight; - printf("Texture atlas size: %ux%u\n", atlasWidth, atlasHeight); + printf("Texture atlas size: %ux%u, %.1f%% wasted\n", + atlasWidth, atlasHeight, + (atlasWidth*atlasHeight-pixelCount)*100.0/(atlasWidth*atlasHeight)); TextureResource tex = create2DTexture(atlasWidth, atlasHeight, true, minLg+1); @@ -289,9 +292,10 @@ namespace render { info.yofs = (info.y+0.5f)/atlasHeight; info.xscale = (info.tex.width-1.0f)/(atlasWidth*info.tex.width); info.yscale = (info.tex.height-1.0f)/(atlasHeight*info.tex.height); +#ifdef TEXDEBUG printf("Texture coordinate factors: %f, %f; %f, %f\n", info.xofs, info.yofs, info.xscale, info.yscale); - +#endif copyPaletteTexture(info.tex.pixels.data(), info.tex.width, info.tex.height, pixels.data()+info.y*atlasWidth*4+info.x*4, atlasWidth*4, @@ -446,8 +450,9 @@ namespace render { } } - printf("%lu indices, %lu attributes\n", - indices.size(), vertexAttribs.size()); + printf("%lu indices, %lu attributes, %.1f%% attrib reuse\n", + indices.size(), vertexAttribs.size(), + (indices.size()-vertexAttribs.size())*100.0/indices.size()); return std::make_tuple(std::move(vertexAttribs), std::move(indices)); }