MCPcopy Create free account
hub / github.com/ARM-software/astc-encoder / load_image_block

Function load_image_block

Source/astcenc_image.cpp:162–275  ·  view source on GitHub ↗

See header for documentation. */

Source from the content-addressed store, hash-verified

160
161/* See header for documentation. */
162void load_image_block(
163 astcenc_profile decode_mode,
164 const astcenc_image& img,
165 image_block& blk,
166 const block_size_descriptor& bsd,
167 size_t pos_x,
168 size_t pos_y,
169 size_t pos_z,
170 const astcenc_swizzle& swz
171) {
172 size_t size_x = img.dim_x;
173 size_t size_y = img.dim_y;
174 size_t size_z = img.dim_z;
175
176 blk.pos_x = pos_x;
177 blk.pos_y = pos_y;
178 blk.pos_z = pos_z;
179
180 // True if any non-identity swizzle
181 bool needs_swz = (swz.r != ASTCENC_SWZ_R) || (swz.g != ASTCENC_SWZ_G) ||
182 (swz.b != ASTCENC_SWZ_B) || (swz.a != ASTCENC_SWZ_A);
183
184 vfloat4 data_min(1e38f);
185 vfloat4 data_mean(0.0f);
186 vfloat4 data_mean_scale(1.0f / static_cast<float>(bsd.texel_count));
187 vfloat4 data_max(-1e38f);
188 vmask4 grayscalev(true);
189 size_t idx = 0;
190
191 // This works because we impose the same choice everywhere during encode
192 uint8_t rgb_lns = (decode_mode == ASTCENC_PRF_HDR) ||
193 (decode_mode == ASTCENC_PRF_HDR_RGB_LDR_A) ? 1 : 0;
194 uint8_t a_lns = decode_mode == ASTCENC_PRF_HDR ? 1 : 0;
195 vint4 use_lns(rgb_lns, rgb_lns, rgb_lns, a_lns);
196 vmask4 lns_mask = use_lns != vint4::zero();
197
198 // Set up the function pointers for loading pipeline as needed
199 pixel_loader loader = load_texel_u8;
200 if (img.data_type == ASTCENC_TYPE_F16)
201 {
202 loader = load_texel_f16;
203 }
204 else if (img.data_type == ASTCENC_TYPE_F32)
205 {
206 loader = load_texel_f32;
207 }
208
209 pixel_swizzler swizzler = swz_texel_skip;
210 if (needs_swz)
211 {
212 swizzler = swz_texel;
213 }
214
215 pixel_converter converter = encode_texel_unorm;
216 if (any(lns_mask))
217 {
218 converter = encode_texel_lns;
219 }

Callers

nothing calls this directly

Calls 9

lns_to_sf16Function · 0.85
texelMethod · 0.80
anyFunction · 0.70
minFunction · 0.70
maxFunction · 0.70
float16_to_floatFunction · 0.70
float_to_intFunction · 0.70
selectFunction · 0.70
allFunction · 0.70

Tested by

no test coverage detected