mirror of https://github.com/godotengine/godot
astcenc: Allow runtime decompression of ASTC formats
This commit is contained in:
parent
bdf625bd54
commit
e8e62d0cdd
|
|
@ -41,6 +41,13 @@ env_astcenc.Prepend(CPPPATH=[thirdparty_dir])
|
||||||
|
|
||||||
env_thirdparty = env_astcenc.Clone()
|
env_thirdparty = env_astcenc.Clone()
|
||||||
env_thirdparty.disable_warnings()
|
env_thirdparty.disable_warnings()
|
||||||
|
|
||||||
|
# Build the encoder only for editor builds
|
||||||
|
astc_encoder = env.editor_build
|
||||||
|
|
||||||
|
if not astc_encoder:
|
||||||
|
env_thirdparty.Append(CPPDEFINES=[("ASTCENC_DECOMPRESS_ONLY")])
|
||||||
|
|
||||||
env_thirdparty.add_source_files(thirdparty_obj, thirdparty_sources)
|
env_thirdparty.add_source_files(thirdparty_obj, thirdparty_sources)
|
||||||
env.modules_sources += thirdparty_obj
|
env.modules_sources += thirdparty_obj
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
def can_build(env, platform):
|
def can_build(env, platform):
|
||||||
# Godot only uses it in the editor, but ANGLE depends on it and we had
|
return True
|
||||||
# to remove the copy from prebuilt ANGLE libs to solve symbol clashes.
|
|
||||||
return env.editor_build or env.get("angle_libs")
|
|
||||||
|
|
||||||
|
|
||||||
def configure(env):
|
def configure(env):
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@
|
||||||
|
|
||||||
#include <astcenc.h>
|
#include <astcenc.h>
|
||||||
|
|
||||||
|
#ifdef TOOLS_ENABLED
|
||||||
void _compress_astc(Image *r_img, Image::ASTCFormat p_format) {
|
void _compress_astc(Image *r_img, Image::ASTCFormat p_format) {
|
||||||
const uint64_t start_time = OS::get_singleton()->get_ticks_msec();
|
const uint64_t start_time = OS::get_singleton()->get_ticks_msec();
|
||||||
|
|
||||||
|
|
@ -171,6 +172,7 @@ void _compress_astc(Image *r_img, Image::ASTCFormat p_format) {
|
||||||
|
|
||||||
print_verbose(vformat("astcenc: Encoding took %d ms.", OS::get_singleton()->get_ticks_msec() - start_time));
|
print_verbose(vformat("astcenc: Encoding took %d ms.", OS::get_singleton()->get_ticks_msec() - start_time));
|
||||||
}
|
}
|
||||||
|
#endif // TOOLS_ENABLED
|
||||||
|
|
||||||
void _decompress_astc(Image *r_img) {
|
void _decompress_astc(Image *r_img) {
|
||||||
const uint64_t start_time = OS::get_singleton()->get_ticks_msec();
|
const uint64_t start_time = OS::get_singleton()->get_ticks_msec();
|
||||||
|
|
@ -213,8 +215,9 @@ void _decompress_astc(Image *r_img) {
|
||||||
|
|
||||||
astcenc_config config;
|
astcenc_config config;
|
||||||
const float quality = ASTCENC_PRE_MEDIUM;
|
const float quality = ASTCENC_PRE_MEDIUM;
|
||||||
|
const uint32_t flags = ASTCENC_FLG_DECOMPRESS_ONLY;
|
||||||
|
|
||||||
astcenc_error status = astcenc_config_init(profile, block_x, block_y, 1, quality, 0, &config);
|
astcenc_error status = astcenc_config_init(profile, block_x, block_y, 1, quality, flags, &config);
|
||||||
ERR_FAIL_COND_MSG(status != ASTCENC_SUCCESS,
|
ERR_FAIL_COND_MSG(status != ASTCENC_SUCCESS,
|
||||||
vformat("astcenc: Configuration initialization failed: %s.", astcenc_get_error_string(status)));
|
vformat("astcenc: Configuration initialization failed: %s.", astcenc_get_error_string(status)));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,10 @@
|
||||||
|
|
||||||
#include "core/io/image.h"
|
#include "core/io/image.h"
|
||||||
|
|
||||||
|
#ifdef TOOLS_ENABLED
|
||||||
void _compress_astc(Image *r_img, Image::ASTCFormat p_format);
|
void _compress_astc(Image *r_img, Image::ASTCFormat p_format);
|
||||||
|
#endif
|
||||||
|
|
||||||
void _decompress_astc(Image *r_img);
|
void _decompress_astc(Image *r_img);
|
||||||
|
|
||||||
#endif // IMAGE_COMPRESS_ASTCENC_H
|
#endif // IMAGE_COMPRESS_ASTCENC_H
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,10 @@ void initialize_astcenc_module(ModuleInitializationLevel p_level) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef TOOLS_ENABLED
|
||||||
Image::_image_compress_astc_func = _compress_astc;
|
Image::_image_compress_astc_func = _compress_astc;
|
||||||
|
#endif
|
||||||
|
|
||||||
Image::_image_decompress_astc = _decompress_astc;
|
Image::_image_decompress_astc = _decompress_astc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue