More std::move in decompress; Show efficiency stats in render::Object

This commit is contained in:
2015-06-08 22:48:14 +02:00
parent ed32a1290e
commit 70439a10c8
2 changed files with 12 additions and 7 deletions

View File

@@ -213,7 +213,7 @@ std::vector<uint8_t> 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<uint8_t>(bits)};
@@ -224,7 +224,7 @@ std::vector<uint8_t> 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 {

View File

@@ -212,6 +212,7 @@ namespace render {
unsigned minSize = std::numeric_limits<unsigned>::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<unsigned>(maxHeight, tex.height);
maxWidth = std::max<unsigned>(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));
}