godot/thirdparty/basis_universal/encoder/basisu_comp.cpp

// basisu_comp.cpp
// Copyright (C) 2019-2024 Binomial LLC. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "basisu_comp.h"
#include "basisu_enc.h"
#include <unordered_set>
#include <atomic>
#include <map>

//#define UASTC_HDR_DEBUG_SAVE_CATEGORIZED_BLOCKS

// basisu_transcoder.cpp is where basisu_miniz lives now, we just need the declarations here.
#define MINIZ_NO_ZLIB_COMPATIBLE_NAMES
#include "basisu_miniz.h"

#include "basisu_opencl.h"

#include "../transcoder/basisu_astc_hdr_core.h"

#if !BASISD_SUPPORT_KTX2
#error BASISD_SUPPORT_KTX2 must be enabled (set to 1).
#endif

#if BASISD_SUPPORT_KTX2_ZSTD
#include <zstd.h>
#endif

// Set to 1 to disable the mipPadding alignment workaround (which only seems to be needed when no key-values are written at all)
#define BASISU_DISABLE_KTX2_ALIGNMENT_WORKAROUND

// Set to 1 to disable writing all KTX2 key values, triggering an early validator bug.
#define BASISU_DISABLE_KTX2_KEY_VALUES

usingnamespacebuminiz;

#define BASISU_USE_STB_IMAGE_RESIZE_FOR_MIPMAP_GEN
#define DEBUG_CROP_TEXTURE_TO_64x64
#define DEBUG_RESIZE_TEXTURE
#define DEBUG_EXTRACT_SINGLE_BLOCK

namespace basisu
{
	basis_compressor::basis_compressor() :{}

	basis_compressor::~basis_compressor()
	{}

	void basis_compressor::check_for_hdr_inputs()
	{}

	bool basis_compressor::sanity_check_input_params()
	{}

	bool basis_compressor::init(const basis_compressor_params &params)
	{}
		
	basis_compressor::error_code basis_compressor::process()
	{}

	basis_compressor::error_code basis_compressor::encode_slices_to_uastc_hdr()
	{}

	basis_compressor::error_code basis_compressor::encode_slices_to_uastc()
	{}

	bool basis_compressor::generate_mipmaps(const imagef& img, basisu::vector<imagef>& mips, bool has_alpha)
	{}

	bool basis_compressor::generate_mipmaps(const image &img, basisu::vector<image> &mips, bool has_alpha)
	{}

	void basis_compressor::clean_hdr_image(imagef& src_img)
	{}

	bool basis_compressor::read_dds_source_images()
	{}

	bool basis_compressor::read_source_images()
	{}

	// Do some basic validation for 2D arrays, cubemaps, video, and volumes.
	bool basis_compressor::validate_texture_type_constraints() 
	{}

	bool basis_compressor::extract_source_blocks()
	{}

	bool basis_compressor::process_frontend()
	{}

	bool basis_compressor::extract_frontend_texture_data()
	{}

	bool basis_compressor::process_backend()
	{}

	bool basis_compressor::create_basis_file_and_transcode()
	{}

	bool basis_compressor::write_hdr_debug_images(const char* pBasename, const imagef& orig_hdr_img, uint32_t width, uint32_t height)
	{}

	bool basis_compressor::write_output_files_and_compute_stats()
	{}
	
	// Make sure all the mip 0's have the same dimensions and number of mipmap levels, or we can't encode the KTX2 file.
	bool basis_compressor::validate_ktx2_constraints()
	{}

	static uint8_t g_ktx2_etc1s_nonalpha_dfd[44] =;
	static uint8_t g_ktx2_etc1s_alpha_dfd[60]    =;
	
	static uint8_t g_ktx2_uastc_nonalpha_dfd[44] =;
	static uint8_t g_ktx2_uastc_alpha_dfd[44]    =;

	// HDR TODO - what is the best Khronos DFD to use for UASTC HDR?
	static uint8_t g_ktx2_uastc_hdr_nonalpha_dfd[44] =;
			
	void basis_compressor::get_dfd(uint8_vec &dfd, const basist::ktx2_header &header)
	{}

	bool basis_compressor::create_ktx2_file()
	{}

	bool basis_parallel_compress(
		uint32_t total_threads,
		const basisu::vector<basis_compressor_params>& params_vec,
		basisu::vector< parallel_results >& results_vec)
	{}

	static void* basis_compress(
		const basisu::vector<image> *pSource_images,
		const basisu::vector<imagef> *pSource_images_hdr,
		uint32_t flags_and_quality, float uastc_rdo_quality,
		size_t* pSize,
		image_stats* pStats)
	{}

	void* basis_compress(
		const basisu::vector<image>& source_images,
		uint32_t flags_and_quality, float uastc_rdo_quality,
		size_t* pSize,
		image_stats* pStats)
	{}

	void* basis_compress(
		const basisu::vector<imagef>& source_images_hdr,
		uint32_t flags_and_quality,
		size_t* pSize,
		image_stats* pStats)
	{}

	void* basis_compress(
		const uint8_t* pImageRGBA, uint32_t width, uint32_t height, uint32_t pitch_in_pixels,
		uint32_t flags_and_quality, float uastc_rdo_quality,
		size_t* pSize,
		image_stats* pStats)
	{}

	void basis_free_data(void* p)
	{}

	bool basis_benchmark_etc1s_opencl(bool* pOpenCL_failed)
	{}

} // namespace basisu