Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
d223dbf
Implement BCn to ETC2 transcode
Shivansps Sep 16, 2026
b2b35a0
improve text cache size option display and usability
Shivansps Oct 12, 2026
8fd3ece
Merge remote-tracking branch 'upstream/master' into etc2-transcoding
Shivansps Nov 1, 2026
127ec0c
Merge remote-tracking branch 'upstream/master' into etc2-transcoding
Shivansps Nov 3, 2026
8a36e4f
requested changes
Shivansps Nov 3, 2026
6f09296
Unify vulkan texture support probe
Shivansps Nov 3, 2026
7c4b472
correct cache version tag
Shivansps Nov 3, 2026
d61c97c
fix clang-tidy issue
Shivansps Nov 3, 2026
865a9bc
Merge remote-tracking branch 'upstream/master' into etc2-transcoding
Shivansps Nov 5, 2026
f12fe5a
set loc ids
Shivansps Nov 5, 2026
6cc2c1f
delete newline
Shivansps Nov 5, 2026
679e80c
Cache hit modifies mtime and min textures sizes consideration in tran…
Shivansps Nov 7, 2026
fb1a8a2
remove test change
Shivansps Nov 7, 2026
5671115
adjust test
Shivansps Nov 7, 2026
c6f7b66
Update test_ddsutils.cpp
Shivansps Nov 8, 2026
2707a9a
Update test_ddsutils.cpp
Shivansps Nov 8, 2026
e872f02
Properly deal with cockpit gauges on resized textures
Shivansps Nov 10, 2026
db90095
fix clang-tidy issues
Shivansps Nov 10, 2026
1e34fe3
Merge remote-tracking branch 'upstream/master' into etc2-transcoding
Shivansps Nov 11, 2026
c670df3
Merge remote-tracking branch 'upstream/master' into etc2-transcoding
Shivansps Nov 11, 2026
6ea30f6
update localization ids
Shivansps Nov 11, 2026
b43218e
requested changes
Shivansps Nov 13, 2026
6a7165c
Merge remote-tracking branch 'upstream/master' into etc2-transcoding
Shivansps Nov 17, 2026
d1368f2
Merge remote-tracking branch 'upstream/master' into etc2-transcoding
Shivansps Nov 17, 2026
b2e8003
Fix streaming of compressed DDS frames in EFF animations
Shivansps Nov 17, 2026
0f5d911
Fix texture cache recovery and pruning
Shivansps Nov 17, 2026
0a60253
Fix ddsutils test
Shivansps Nov 17, 2026
323e69f
Unify location_flags type, set file_list_info.size; tinfo.size
Shivansps Nov 17, 2026
50bf6a3
bm_reload() now set the original width and height
Shivansps Nov 17, 2026
5a3d9be
Preserve original DDS dimensions in 2D rendering and Lua
Shivansps Nov 17, 2026
c998d2c
clang tidy change
Shivansps Nov 17, 2026
5e613fc
fix compile error
Shivansps Nov 17, 2026
80ef877
rename variable
Shivansps Nov 17, 2026
9290bdd
Use allow to use original_size in gr_aabitmap()
Shivansps Nov 17, 2026
07c12ad
Merge remote-tracking branch 'upstream/master' into etc2-transcoding
Shivansps Nov 19, 2026
61985de
update localize ids
Shivansps Nov 19, 2026
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
2 changes: 2 additions & 0 deletions code/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ TARGET_LINK_LIBRARIES(code PUBLIC compiler)

target_link_libraries(code PUBLIC md5)

target_link_libraries(code PUBLIC etcpak)

if (FSO_BUILD_WITH_DISCORD)
target_link_libraries(code PUBLIC discord-rpc)
add_definitions(-DWITH_DISCORD)
Expand Down
4 changes: 4 additions & 0 deletions code/bmpman/bm_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ struct bitmap_entry {
uint used_flags; //!< What flags it was accessed thru
int load_count;

// File dimensions before texture conversion; zero uses the current bitmap dimensions.
int original_width;
int original_height;

bitmap bm; //!< Bitmap info

bm_extra_info info; //!< Data for animations and user bitmaps
Expand Down
45 changes: 40 additions & 5 deletions code/bmpman/bmpman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,23 @@ int bm_get_info(int handle, int *w, int * h, uint* flags, int *nframes, int *fps
}
}

int bm_get_original_size(int handle, int* w, int* h)
{
const int result = bm_get_info(handle, w, h);
if (result < 0) {
return result;
}

const auto* entry = bm_get_entry(handle);
if (w && entry->original_width > 0) {
*w = entry->original_width;
}
if (h && entry->original_height > 0) {
*h = entry->original_height;
}
return result;
}

int bm_get_depth(int handle, int* depth) {
bitmap* bmp;

Expand Down Expand Up @@ -1147,12 +1164,13 @@ int bm_is_valid(int handle) {
// c_type = output for an updated BM_TYPE_*
// mm_lvl = number of mipmap levels for the image
// size = size of the data contained in the image
static int bm_load_info(BM_TYPE type, const char *filename, CFILE *img_cfp, int *w, int *h, int *bpp, BM_TYPE *c_type, int *mm_lvl, size_t *size)
static int bm_load_info(BM_TYPE type, const char *filename, CFILE *img_cfp, int *w, int *h, int *bpp, BM_TYPE *c_type, int *mm_lvl, size_t *size,
int *original_width = nullptr, int *original_height = nullptr)
{
int dds_ct;

if (type == BM_TYPE_DDS) {
int dds_error = dds_read_header(filename, img_cfp, w, h, bpp, &dds_ct, mm_lvl, size);
int dds_error = dds_read_header(filename, img_cfp, w, h, bpp, &dds_ct, mm_lvl, size, original_width, original_height);

if (dds_error != DDS_ERROR_NONE) {
mprintf(("DDS ERROR: Couldn't open '%s' -- %s\n", filename, dds_error_string(dds_error)));
Expand All @@ -1176,6 +1194,14 @@ static int bm_load_info(BM_TYPE type, const char *filename, CFILE *img_cfp, int
*c_type = BM_TYPE_BC7;
break;

case DDS_ETC2_RGBA8:
*c_type = BM_TYPE_ETC2_RGBA_EAC;
break;

case DDS_ETC2_RGB:
*c_type = BM_TYPE_ETC2_RGB;
break;

case DDS_UNCOMPRESSED:
*c_type = BM_TYPE_DDS;
break;
Expand Down Expand Up @@ -1255,6 +1281,7 @@ static int bm_load_info(BM_TYPE type, const char *filename, CFILE *img_cfp, int
int bm_load(const char *real_filename, int dir_type) {
int free_slot = -1;
int w, h, bpp = 8;
int original_width = 0, original_height = 0;
int rc = 0;
size_t bm_size = 0;
int mm_lvl = 0;
Expand Down Expand Up @@ -1322,7 +1349,8 @@ int bm_load(const char *real_filename, int dir_type) {
return -1;
}

rc = bm_load_info(type, filename, img_cfp, &w, &h, &bpp, &c_type, &mm_lvl, &bm_size);
rc = bm_load_info(type, filename, img_cfp, &w, &h, &bpp, &c_type, &mm_lvl, &bm_size,
&original_width, &original_height);

if (rc != 0) {
if (img_cfp != nullptr)
Expand All @@ -1347,6 +1375,8 @@ int bm_load(const char *real_filename, int dir_type) {
entry->type = type;
entry->comp_type = c_type;
entry->signature = Bm_next_signature++;
entry->original_width = original_width;
entry->original_height = original_height;
entry->bm.w = (short)w;
entry->bm.rowsize = (short)w;
entry->bm.h = (short)h;
Expand Down Expand Up @@ -1809,7 +1839,8 @@ int bm_load_animation(const char *real_filename, int *nframes, int *fps, int *ke

// bm_load_info() returns non-0 on failure
if (bm_load_info(eff_type, entry->info.ani.eff.filename,
nullptr, &anim_width, &anim_height, &bpp, &c_type, &mm_lvl, &img_size)) {
nullptr, &anim_width, &anim_height, &bpp, &c_type, &mm_lvl, &img_size,
&entry->original_width, &entry->original_height)) {
// if we didn't get anything then bail out now
if (i == 0) {
Warning(LOCATION, "EFF: No frame images were found. EFF, %s, is invalid.\n", filename);
Expand Down Expand Up @@ -3113,9 +3144,11 @@ int bm_reload(int bitmap_handle, const char* filename) {
}

int w = 0, h = 0, bpp = 0, mm_lvl = 0;
int original_width = 0, original_height = 0;
BM_TYPE c_type = BM_TYPE_NONE;
size_t size = 0;
const int rc = bm_load_info(entry->type, full_name, img_cfp, &w, &h, &bpp, &c_type, &mm_lvl, &size);
const int rc = bm_load_info(entry->type, full_name, img_cfp, &w, &h, &bpp, &c_type, &mm_lvl, &size,
&original_width, &original_height);
cfclose(img_cfp);
if (rc != 0) {
return -1;
Expand All @@ -3133,6 +3166,8 @@ int bm_reload(int bitmap_handle, const char* filename) {
bm_free_data(bm_get_slot(bitmap_handle));
strcpy_s(entry->filename, filename);
}
entry->original_width = original_width;
entry->original_height = original_height;
return bitmap_handle;
}

Expand Down
7 changes: 7 additions & 0 deletions code/bmpman/bmpman.h
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,13 @@ int bm_is_valid(int handle);
*/
int bm_get_info(int handle, int *w = nullptr, int * h = nullptr, uint* flags = nullptr, int *nframes = nullptr, int *fps = nullptr);

/**
* @brief Gets the dimensions before DDS conversion drops mip levels.
* Falls back to the current dimensions for bitmaps without source-size metadata.
* @returns The same handle (or first animation frame) as bm_get_info(), or -1 on failure.
*/
int bm_get_original_size(int handle, int* w = nullptr, int* h = nullptr);

/**
* @brief Gets 3D info on the bitmap indexed by handle.
*
Expand Down
6 changes: 3 additions & 3 deletions code/camera/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ subtitle::subtitle(int in_x_pos, int in_y_pos, const char* in_text, const char*
//Get image size
if(image_id != -1)
{
bm_get_info(image_id, &w, &h);
bm_get_original_size(image_id, &w, &h);
if (in_width > 0)
w = in_width;
if (in_height > 0)
Expand Down Expand Up @@ -870,7 +870,7 @@ subtitle::subtitle(int in_x_pos, int in_y_pos, const char* in_text, const char*
image_pos.h = in_height;

if(image_id != -1)
text_pos.x = image_pos.x + w; //Still set from bm_get_info call
text_pos.x = image_pos.x + w;
else
text_pos.x = image_pos.x;
text_pos.y = image_pos.y;
Expand Down Expand Up @@ -954,7 +954,7 @@ void subtitle::do_frame(float frametime)
int orig_w, orig_h;
vec3d scale;

bm_get_info(image_id, &orig_w, &orig_h);
bm_get_original_size(image_id, &orig_w, &orig_h);
scale.xyz.x = (image_pos.w > 0) ? (image_pos.w / (float) orig_w) : 1.0f;
scale.xyz.y = (image_pos.h > 0) ? (image_pos.h / (float) orig_h) : 1.0f;
scale.xyz.z = 1.0f;
Expand Down
20 changes: 9 additions & 11 deletions code/cfile/cfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -544,31 +544,29 @@ void cf_attrib(const char *filename, int set, int clear, int dir_type)
}
#endif

int cf_rename(const char *old_name, const char *name, int dir_type)
int cf_rename(const char* old_name, const char* name, int dir_type, uint32_t location_flags)
{
Assert( CF_TYPE_SPECIFIED(dir_type) );
Assert(CF_TYPE_SPECIFIED(dir_type));

int ret_code;
SCP_string old_longname;
SCP_string new_longname;
cf_create_default_path_string(old_longname, dir_type, old_name);
cf_create_default_path_string(new_longname, dir_type, name);

cf_create_default_path_string(old_longname, dir_type, old_name, location_flags);
cf_create_default_path_string(new_longname, dir_type, name, location_flags);

ret_code = rename(old_longname.c_str(), new_longname.c_str());
if(ret_code != 0){
switch(errno){
case EACCES :
if (ret_code != 0) {
switch (errno) {
case EACCES:
return CF_RENAME_FAIL_ACCESS;
case ENOENT :
case ENOENT:
default:
return CF_RENAME_FAIL_EXIST;
}
}

return CF_RENAME_SUCCESS;


}


Expand Down
3 changes: 2 additions & 1 deletion code/cfile/cfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ struct CFILE;
// extra info that can be returned when getting a file listing
typedef struct {
time_t write_time;
size_t size;
} file_list_info;


Expand Down Expand Up @@ -288,7 +289,7 @@ uint cf_add_chksum_long(uint seed, ubyte *buffer, size_t size);
#define CF_RENAME_SUCCESS 0 // successfully renamed the file
#define CF_RENAME_FAIL_ACCESS 1 // new name could not be created
#define CF_RENAME_FAIL_EXIST 2 // old name does not exist
int cf_rename(const char *old_name, const char *name, int type = CF_TYPE_ANY );
int cf_rename(const char *old_name, const char *name, int type = CF_TYPE_ANY, uint32_t location_flags = CF_LOCATION_ALL);

// Creates the directory path if it doesn't exist. Even creates all its
// parent paths.
Expand Down
3 changes: 3 additions & 0 deletions code/cfile/cfilesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1800,6 +1800,7 @@ int cf_get_file_list(SCP_vector<SCP_string>& list, int pathtype, const char* _fi

if (info) {
tinfo.write_time = file.m_time;
tinfo.size = file.size;
info->push_back(tinfo);
}
}
Expand Down Expand Up @@ -1873,6 +1874,7 @@ int cf_get_file_list(SCP_vector<SCP_string>& list, int pathtype, const char* _fi

if (info) {
tinfo.write_time = file.m_time;
tinfo.size = file.size;
info->push_back(tinfo);
}
}
Expand Down Expand Up @@ -1944,6 +1946,7 @@ int cf_get_file_list(SCP_vector<SCP_string>& list, int pathtype, const char* _fi

if (info) {
tinfo.write_time = f->write_time;
tinfo.size = f->size;
info->push_back( tinfo );
}
}
Expand Down
8 changes: 8 additions & 0 deletions code/cmdline/cmdline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ Flag exe_params[] =
{ "-log_multi_packet", "Log multi packet types ", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-log_multi_packet",},
{ "-no_bsp_align", "Disable pof BSP data alignment", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_bsp_align", },
{ "-no_large_shaders", "Split large shader into smaller shaders", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_large_shaders", },
{ "-no_transcode_cache","Disables the texture transcode cache", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_transcode_cache", },

#ifdef WIN32
{ "-fix_registry", "Use a different registry path", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-fix_registry", },
Expand Down Expand Up @@ -474,6 +475,7 @@ cmdline_parm no_large_shaders("-no_large_shaders", NULL, AT_NONE);
#ifdef WIN32
cmdline_parm fix_registry("-fix_registry", NULL, AT_NONE);
#endif
cmdline_parm no_transcode_cache_arg("-no_transcode_cache", nullptr, AT_NONE);

int Cmdline_load_all_weapons = 0;
int Cmdline_nomovies = 0;
Expand All @@ -498,6 +500,7 @@ bool Cmdline_no_large_shaders = false;
#ifdef WIN32
bool Cmdline_alternate_registry_path = false;
#endif
bool Cmdline_no_transcode_cache = false;
uint Cmdline_rng_seed = 0;
bool Cmdline_reuse_rng_seed = false;

Expand Down Expand Up @@ -2240,6 +2243,11 @@ bool SetCmdlineParams()
if (no_large_shaders.found()) {
Cmdline_no_large_shaders = true;
}

if (no_transcode_cache_arg.found())
{
Cmdline_no_transcode_cache = true;
}

#ifdef WIN32
if (fix_registry.found()) {
Expand Down
1 change: 1 addition & 0 deletions code/cmdline/cmdline.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ extern bool Cmdline_no_large_shaders;
#ifdef WIN32
extern bool Cmdline_alternate_registry_path;
#endif
extern bool Cmdline_no_transcode_cache;

// Developer/Testing related
extern char *Cmdline_start_mission;
Expand Down
Loading
Loading