diff options
Diffstat (limited to 'modules/basis_universal')
-rw-r--r-- | modules/basis_universal/SCsub | 38 | ||||
-rw-r--r-- | modules/basis_universal/register_types.cpp | 14 | ||||
-rw-r--r-- | modules/basis_universal/register_types.h | 4 | ||||
-rw-r--r-- | modules/basis_universal/texture_basisu.cpp | 23 | ||||
-rw-r--r-- | modules/basis_universal/texture_basisu.h | 10 |
5 files changed, 44 insertions, 45 deletions
diff --git a/modules/basis_universal/SCsub b/modules/basis_universal/SCsub index dc7b176d24..1f9fde966d 100644 --- a/modules/basis_universal/SCsub +++ b/modules/basis_universal/SCsub @@ -6,43 +6,59 @@ Import("env_modules") env_basisu = env_modules.Clone() # Thirdparty source files + +thirdparty_obj = [] + # Not unbundled so far since not widespread as shared library thirdparty_dir = "#thirdparty/basis_universal/" -tool_sources = [ +# Sync list with upstream CMakeLists.txt +encoder_sources = [ + "apg_bmp.c", "basisu_astc_decomp.cpp", "basisu_backend.cpp", "basisu_basis_file.cpp", + "basisu_bc7enc.cpp", "basisu_comp.cpp", "basisu_enc.cpp", "basisu_etc.cpp", "basisu_frontend.cpp", "basisu_global_selector_palette_helpers.cpp", "basisu_gpu_texture.cpp", + "basisu_kernels_sse.cpp", "basisu_pvrtc1_4.cpp", - "basisu_resample_filters.cpp", "basisu_resampler.cpp", + "basisu_resample_filters.cpp", "basisu_ssim.cpp", + "basisu_uastc_enc.cpp", + "jpgd.cpp", "lodepng.cpp", ] -tool_sources = [thirdparty_dir + file for file in tool_sources] +encoder_sources = [thirdparty_dir + "encoder/" + file for file in encoder_sources] transcoder_sources = [thirdparty_dir + "transcoder/basisu_transcoder.cpp"] # Treat Basis headers as system headers to avoid raising warnings. Not supported on MSVC. if not env.msvc: - env_basisu.Append( - CPPFLAGS=["-isystem", Dir(thirdparty_dir).path, "-isystem", Dir(thirdparty_dir + "transcoder").path] - ) + env_basisu.Append(CPPFLAGS=["-isystem", Dir(thirdparty_dir).path]) else: - env_basisu.Prepend(CPPPATH=[thirdparty_dir, thirdparty_dir + "transcoder"]) + env_basisu.Prepend(CPPPATH=[thirdparty_dir]) if env["target"] == "debug": - env_basisu.Append(CPPFLAGS=["-DBASISU_DEVEL_MESSAGES=1", "-DBASISD_ENABLE_DEBUG_FLAGS=1"]) + env_basisu.Append(CPPDEFINES=[("BASISU_DEVEL_MESSAGES", 1), ("BASISD_ENABLE_DEBUG_FLAGS", 1)]) env_thirdparty = env_basisu.Clone() env_thirdparty.disable_warnings() if env["tools"]: - env_thirdparty.add_source_files(env.modules_sources, tool_sources) -env_thirdparty.add_source_files(env.modules_sources, transcoder_sources) + env_thirdparty.Append(CPPDEFINES=["BASISU_NO_IMG_LOADERS"]) + env_thirdparty.add_source_files(thirdparty_obj, encoder_sources) +env_thirdparty.add_source_files(thirdparty_obj, transcoder_sources) +env.modules_sources += thirdparty_obj # Godot source files -env_basisu.add_source_files(env.modules_sources, "*.cpp") + +module_obj = [] + +env_basisu.add_source_files(module_obj, "*.cpp") +env.modules_sources += module_obj + +# Needed to force rebuilding the module files when the thirdparty library is updated. +env.Depends(module_obj, thirdparty_obj) diff --git a/modules/basis_universal/register_types.cpp b/modules/basis_universal/register_types.cpp index 27b299a65d..9a13406900 100644 --- a/modules/basis_universal/register_types.cpp +++ b/modules/basis_universal/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -35,7 +35,7 @@ #include "texture_basisu.h" #ifdef TOOLS_ENABLED -#include <basisu_comp.h> +#include <encoder/basisu_comp.h> #endif #include <transcoder/basisu_transcoder.h> @@ -216,7 +216,7 @@ static Ref<Image> basis_universal_unpacker(const Vector<uint8_t> &p_buffer) { format = basist::transcoder_texture_format::cTFETC2; // get this from renderer imgfmt = Image::FORMAT_ETC2_RGBA8; } else { - //gles2 most likely, bad for normalmaps, nothing to do about this. + //gles2 most likely, bad for normal maps, nothing to do about this. format = basist::transcoder_texture_format::cTFRGBA32; imgfmt = Image::FORMAT_RGBA8; } @@ -233,7 +233,7 @@ static Ref<Image> basis_universal_unpacker(const Vector<uint8_t> &p_buffer) { basist::basisu_image_info info; tr.get_image_info(ptr, size, info, 0); - int block_size = basist::basis_get_bytes_per_block(format); + int block_size = basist::basis_get_bytes_per_block_or_pixel(format); Vector<uint8_t> gpudata; gpudata.resize(info.m_total_blocks * block_size); @@ -260,7 +260,7 @@ static Ref<Image> basis_universal_unpacker(const Vector<uint8_t> &p_buffer) { }; }; - image.instance(); + image.instantiate(); image->create(info.m_width, info.m_height, info.m_total_levels > 1, imgfmt, gpudata); return image; @@ -272,7 +272,7 @@ void register_basis_universal_types() { Image::basis_universal_packer = basis_universal_packer; #endif Image::basis_universal_unpacker = basis_universal_unpacker; - //ClassDB::register_class<TextureBasisU>(); + //GDREGISTER_CLASS(TextureBasisU); } void unregister_basis_universal_types() { diff --git a/modules/basis_universal/register_types.h b/modules/basis_universal/register_types.h index 5053dc27ce..30b465e344 100644 --- a/modules/basis_universal/register_types.h +++ b/modules/basis_universal/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/modules/basis_universal/texture_basisu.cpp b/modules/basis_universal/texture_basisu.cpp index 2ed0340927..9e917420ce 100644 --- a/modules/basis_universal/texture_basisu.cpp +++ b/modules/basis_universal/texture_basisu.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -33,50 +33,42 @@ #include "core/os/os.h" #ifdef TOOLS_ENABLED -#include <basisu_comp.h> +#include <encoder/basisu_comp.h> #endif #include <transcoder/basisu_transcoder.h> void TextureBasisU::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_basisu_data", "data"), &TextureBasisU::set_basisu_data); ClassDB::bind_method(D_METHOD("get_basisu_data"), &TextureBasisU::get_data); ClassDB::bind_method(D_METHOD("import"), &TextureBasisU::import); ADD_PROPERTY(PropertyInfo(Variant::PACKED_BYTE_ARRAY, "basisu_data"), "set_basisu_data", "get_basisu_data"); - }; int TextureBasisU::get_width() const { - return tex_size.x; }; int TextureBasisU::get_height() const { - return tex_size.y; }; RID TextureBasisU::get_rid() const { - return texture; }; bool TextureBasisU::has_alpha() const { - return false; }; void TextureBasisU::set_flags(uint32_t p_flags) { - flags = p_flags; RenderingServer::get_singleton()->texture_set_flags(texture, p_flags); }; uint32_t TextureBasisU::get_flags() const { - return flags; }; @@ -95,12 +87,10 @@ void TextureBasisU::set_basisu_data(const Vector<uint8_t>& p_data) { Image::Format imgfmt; if (OS::get_singleton()->has_feature("s3tc")) { - format = basist::cTFBC3; // get this from renderer imgfmt = Image::FORMAT_DXT5; } else if (OS::get_singleton()->has_feature("etc2")) { - format = basist::cTFETC2; imgfmt = Image::FORMAT_ETC2_RGBA8; }; @@ -126,7 +116,6 @@ void TextureBasisU::set_basisu_data(const Vector<uint8_t>& p_data) { int ofs = 0; tr.start_transcoding(ptr, size); for (int i=0; i<info.m_total_levels; i++) { - basist::basisu_image_level_info level; tr.get_image_level_info(ptr, size, level, 0, i); @@ -141,7 +130,7 @@ void TextureBasisU::set_basisu_data(const Vector<uint8_t>& p_data) { }; Ref<Image> img; - img.instance(); + img.instantiate(); img->create(info.m_width, info.m_height, info.m_total_levels > 1, imgfmt, gpudata); RenderingServer::get_singleton()->texture_allocate(texture, tex_size.x, tex_size.y, 0, img->get_format(), RS::TEXTURE_TYPE_2D, flags); @@ -214,19 +203,15 @@ Error TextureBasisU::import(const Ref<Image>& p_img) { Vector<uint8_t> TextureBasisU::get_basisu_data() const { - return data; }; TextureBasisU::TextureBasisU() { - - flags = FLAGS_DEFAULT; texture = RenderingServer::get_singleton()->texture_create(); }; TextureBasisU::~TextureBasisU() { - RenderingServer::get_singleton()->free(texture); }; diff --git a/modules/basis_universal/texture_basisu.h b/modules/basis_universal/texture_basisu.h index 20ecf15a59..3316035404 100644 --- a/modules/basis_universal/texture_basisu.h +++ b/modules/basis_universal/texture_basisu.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -34,21 +34,20 @@ #include "scene/resources/texture.h" #ifdef TOOLS_ENABLED -#include <basisu_comp.h> +#include <encoder/basisu_comp.h> #endif #include <transcoder/basisu_transcoder.h> #if 0 class TextureBasisU : public Texture { - GDCLASS(TextureBasisU, Texture); RES_BASE_EXTENSION("butex"); RID texture; Size2 tex_size; - uint32_t flags; + uint32_t flags = FLAGS_DEFAULT; Vector<uint8_t> data; @@ -74,7 +73,6 @@ public: TextureBasisU(); ~TextureBasisU(); - }; #endif |