// SPDX-License-Identifier: Apache-2.0 // ---------------------------------------------------------------------------- // Copyright 2011-2024 Arm Limited // // 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. // ---------------------------------------------------------------------------- /** * @brief Functions for creating in-memory ASTC image structures. */ #include <cassert> #include <cstring> #include "astcenc_internal.h" /** * @brief Loader pipeline function type for data fetch from memory. */ pixel_loader; /** * @brief Loader pipeline function type for swizzling data in a vector. */ pixel_swizzler; /** * @brief Loader pipeline function type for converting data in a vector to LNS. */ pixel_converter; /** * @brief Load a 8-bit UNORM texel from a data array. * * @param data The data pointer. * @param base_offset The index offset to the start of the pixel. */ static vfloat4 load_texel_u8( const void* data, int base_offset ) { … } /** * @brief Load a 16-bit fp16 texel from a data array. * * @param data The data pointer. * @param base_offset The index offset to the start of the pixel. */ static vfloat4 load_texel_f16( const void* data, int base_offset ) { … } /** * @brief Load a 32-bit float texel from a data array. * * @param data The data pointer. * @param base_offset The index offset to the start of the pixel. */ static vfloat4 load_texel_f32( const void* data, int base_offset ) { … } /** * @brief Dummy no-op swizzle function. * * @param data The source RGBA vector to swizzle. * @param swz The swizzle to use. */ static vfloat4 swz_texel_skip( vfloat4 data, const astcenc_swizzle& swz ) { … } /** * @brief Swizzle a texel into a new arrangement. * * @param data The source RGBA vector to swizzle. * @param swz The swizzle to use. */ static vfloat4 swz_texel( vfloat4 data, const astcenc_swizzle& swz ) { … } /** * @brief Encode a texel that is entirely LDR linear. * * @param data The RGBA data to encode. * @param lns_mask The mask for the HDR channels than need LNS encoding. */ static vfloat4 encode_texel_unorm( vfloat4 data, vmask4 lns_mask ) { … } /** * @brief Encode a texel that includes at least some HDR LNS texels. * * @param data The RGBA data to encode. * @param lns_mask The mask for the HDR channels than need LNS encoding. */ static vfloat4 encode_texel_lns( vfloat4 data, vmask4 lns_mask ) { … } /* See header for documentation. */ void load_image_block( astcenc_profile decode_mode, const astcenc_image& img, image_block& blk, const block_size_descriptor& bsd, unsigned int xpos, unsigned int ypos, unsigned int zpos, const astcenc_swizzle& swz ) { … } /* See header for documentation. */ void load_image_block_fast_ldr( astcenc_profile decode_mode, const astcenc_image& img, image_block& blk, const block_size_descriptor& bsd, unsigned int xpos, unsigned int ypos, unsigned int zpos, const astcenc_swizzle& swz ) { … } /* See header for documentation. */ void store_image_block( astcenc_image& img, const image_block& blk, const block_size_descriptor& bsd, unsigned int xpos, unsigned int ypos, unsigned int zpos, const astcenc_swizzle& swz ) { … }