Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,21 @@ Fork of seedee/SDHLT focused on compile performance and map FPS for Counter-Stri
- CI ran `ctest` with no registered tests and always failed that step

### Added
- CSG: `-mergeentities` folds equivalent static brush entities into one, so a
- CSG: `-texchart` reports what each texture costs the bsp. On a map compiled
with `-nowadtextures` the texture lump is most of the file - measured at
82.8% on `zm_azteca` and 69.9% on `zm_eichen`, against 8.7% and 15.4% for
lighting - and `-chart` stops at a single `texdata` total, which is where the
question starts. The report lists textures by bytes, flags any whose pixels
are byte for byte identical, and crosses each one against the surface area it
actually paints: the texture axes carry the texels-per-unit scale, so the
pixels a texture ever displays is a number, not a guess. Anything with 4x
more pixels than it displays can lose half its resolution in each axis and
still have a pixel per pixel on screen. That distinction matters - a naive
"halve everything 256px and up" projection claimed 70% off `zm_azteca`, and
the real answer there is that nothing is oversampled at all, because those
textures tile across very large surfaces. On `zm_eichen` it finds 3 textures
worth halving (6.1%) and one duplicated pair. Off by default and it only
reads back the lump CSG has already written
field of 200 identical `func_illusionary` bushes costs one BSP model instead
of 200. Models are the scarce resource here: the engine precache table they
live in is shared with studio models and sprites. Entities are only folded
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ set(CSG_SOURCES
${CSG_DIR}/mergeents.cpp
${CSG_DIR}/properties.cpp
${CSG_DIR}/qcsg.cpp
${CSG_DIR}/texreport.cpp
${CSG_DIR}/textures.cpp
${CSG_DIR}/wadcfg.cpp
${CSG_DIR}/wadpath.cpp
Expand Down
1 change: 1 addition & 0 deletions src/sdhlt/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ HLCSG_CPPFILES = \
sdHLCSG/mergeents.cpp \
sdHLCSG/properties.cpp \
sdHLCSG/qcsg.cpp \
sdHLCSG/texreport.cpp \
sdHLCSG/textures.cpp \
sdHLCSG/wadcfg.cpp \
sdHLCSG/wadpath.cpp \
Expand Down
8 changes: 8 additions & 0 deletions src/sdhlt/sdHLCSG/csg.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
#define DEFAULT_NOUTF8 false
#endif
#define DEFAULT_NULLIFYTRIGGER true
#define DEFAULT_TEXREPORT false
#define DEFAULT_MERGE_ENTITIES false
#define DEFAULT_MERGE_MAXSIZE 1024.0 // longest side a merged group may reach, 0 = no limit
#define DEFAULT_MERGE_BLEND false
Expand Down Expand Up @@ -247,6 +248,13 @@ extern vec_t g_merge_maxsize;
extern bool g_merge_blend;
extern void MergeStaticEntities();

//=============================================================================
// texreport.cpp

extern bool g_texreport;
extern void AccumulateTextureArea(int texinfo, vec_t area);
extern void TextureCostReport();

//=============================================================================
// textures.cpp

Expand Down
18 changes: 18 additions & 0 deletions src/sdhlt/sdHLCSG/qcsg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,12 @@ void WriteFace(const int hull, const bface_t* const f
// .p0 format
w = f->w;

// hull 0 is the visible geometry, which is the only thing a texture paints
if (!hull)
{
AccumulateTextureArea(f->texinfo, w->getArea());
}

// plane summary
fprintf (out[hull], "%i %i %i %i %u\n", detaillevel, f->planenum, f->texinfo, f->contents, w->m_NumPoints);

Expand Down Expand Up @@ -1236,6 +1242,10 @@ void WriteBSP(const char* const name)
if (g_onlyents)
LoadWadValue ();

// after WriteMiptex, because that is what fills the lump and turns each
// texinfo's miptex field into a real index into it
TextureCostReport();

UnparseEntities();
ConvertHintToEmpty(); // this is ridiculous. --vluzacn
if (g_chart)
Expand Down Expand Up @@ -1582,6 +1592,9 @@ static void Usage()
Log(" -mergesize # : max size of a merged group, 0 for no limit\n");
Log(" -mergeblend : also merge blended render modes (may reorder them)\n");

Log(" -texchart : report what each texture costs the bsp and whether\n");
Log(" its resolution is doing any work\n");


Log(" -nolightopt : don't optimize engine light entities\n");

Expand Down Expand Up @@ -1689,6 +1702,7 @@ static void Settings()
Log("wad.cfg config name [ %7s ] [ %7s ]\n", g_wadconfigname? g_wadconfigname: "None", "None");
Log("nullfile [ %7s ] [ %7s ]\n", g_nullfile ? g_nullfile : "None", "None");
Log("nullify trigger [ %7s ] [ %7s ]\n", g_nullifytrigger? "on": "off", DEFAULT_NULLIFYTRIGGER? "on": "off");
Log("texture cost report [ %7s ] [ %7s ]\n", g_texreport? "on": "off", DEFAULT_TEXREPORT? "on": "off");
Log("merge static entities [ %7s ] [ %7s ]\n", g_merge_entities? "on": "off", DEFAULT_MERGE_ENTITIES? "on": "off");
{
char merge_size[10];
Expand Down Expand Up @@ -2101,6 +2115,10 @@ int main(const int argc, char** argv)
{
g_nullifytrigger = false;
}
else if (!strcasecmp (argv[i], "-texchart"))
{
g_texreport = true;
}
else if (!strcasecmp (argv[i], "-mergeentities"))
{
g_merge_entities = true;
Expand Down
4 changes: 4 additions & 0 deletions src/sdhlt/sdHLCSG/sdHLCSG.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,10 @@
RelativePath=".\mergeents.cpp"
>
</File>
<File
RelativePath=".\texreport.cpp"
>
</File>
<File
RelativePath=".\properties.cpp"
>
Expand Down
1 change: 1 addition & 0 deletions src/sdhlt/sdHLCSG/sdHLCSG.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@
<ClCompile Include="hullfile.cpp" />
<ClCompile Include="map.cpp" />
<ClCompile Include="mergeents.cpp" />
<ClCompile Include="texreport.cpp" />
<ClCompile Include="properties.cpp" />
<ClCompile Include="qcsg.cpp" />
<ClCompile Include="textures.cpp" />
Expand Down
3 changes: 3 additions & 0 deletions src/sdhlt/sdHLCSG/sdHLCSG.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@
<ClCompile Include="mergeents.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="texreport.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="properties.cpp">
<Filter>Source Files</Filter>
</ClCompile>
Expand Down
Loading
Loading