MCPcopy Create free account
hub / github.com/defold/defold / validate_output

Method validate_output

engine/dlib/src/basis/encoder/basisu_frontend.cpp:3358–3414  ·  view source on GitHub ↗

This is very slow and only intended for debugging/development. It's enabled using the "-validate_etc1s" command line option.

Source from the content-addressed store, hash-verified

3356
3357 // This is very slow and only intended for debugging/development. It's enabled using the "-validate_etc1s" command line option.
3358 bool basisu_frontend::validate_output() const
3359 {
3360 debug_printf("validate_output\n");
3361
3362 if (!check_etc1s_constraints())
3363 return false;
3364
3365 for (uint32_t block_index = 0; block_index < m_total_blocks; block_index++)
3366 {
3367//#define CHECK(x) do { if (!(x)) { DebugBreak(); return false; } } while(0)
3368#define CHECK(x) BASISU_FRONTEND_VERIFY(x);
3369
3370 CHECK(get_output_block(block_index).get_flip_bit() == true);
3371
3372 const bool diff_flag = get_diff_flag(block_index);
3373 CHECK(diff_flag == true);
3374
3375 etc_block blk;
3376 memset(&blk, 0, sizeof(blk));
3377 blk.set_flip_bit(true);
3378 blk.set_diff_bit(true);
3379
3380 const uint32_t endpoint_cluster0_index = get_subblock_endpoint_cluster_index(block_index, 0);
3381 const uint32_t endpoint_cluster1_index = get_subblock_endpoint_cluster_index(block_index, 1);
3382
3383 // basisu only supports ETC1S, so these must be equal.
3384 CHECK(endpoint_cluster0_index == endpoint_cluster1_index);
3385
3386 CHECK(blk.set_block_color5_check(get_endpoint_cluster_unscaled_color(endpoint_cluster0_index, false), get_endpoint_cluster_unscaled_color(endpoint_cluster1_index, false)));
3387
3388 CHECK(get_endpoint_cluster_color_is_used(endpoint_cluster0_index, false));
3389
3390 blk.set_inten_table(0, get_endpoint_cluster_inten_table(endpoint_cluster0_index, false));
3391 blk.set_inten_table(1, get_endpoint_cluster_inten_table(endpoint_cluster1_index, false));
3392
3393 const uint32_t selector_cluster_index = get_block_selector_cluster_index(block_index);
3394 CHECK(selector_cluster_index < get_total_selector_clusters());
3395
3396 CHECK(vector_find(get_selector_cluster_block_indices(selector_cluster_index), block_index) != -1);
3397
3398 blk.set_raw_selector_bits(get_selector_cluster_selector_bits(selector_cluster_index).get_raw_selector_bits());
3399
3400 const etc_block &rdo_output_block = get_output_block(block_index);
3401
3402 CHECK(rdo_output_block.get_flip_bit() == blk.get_flip_bit());
3403 CHECK(rdo_output_block.get_diff_bit() == blk.get_diff_bit());
3404 CHECK(rdo_output_block.get_inten_table(0) == blk.get_inten_table(0));
3405 CHECK(rdo_output_block.get_inten_table(1) == blk.get_inten_table(1));
3406 CHECK(rdo_output_block.get_base5_color() == blk.get_base5_color());
3407 CHECK(rdo_output_block.get_delta3_color() == blk.get_delta3_color());
3408 CHECK(rdo_output_block.get_raw_selector_bits() == blk.get_raw_selector_bits());
3409
3410#undef CHECK
3411 }
3412
3413 return true;
3414 }
3415

Callers

nothing calls this directly

Calls 13

debug_printfFunction · 0.85
vector_findFunction · 0.85
get_flip_bitMethod · 0.45
set_flip_bitMethod · 0.45
set_diff_bitMethod · 0.45
set_inten_tableMethod · 0.45
set_raw_selector_bitsMethod · 0.45
get_raw_selector_bitsMethod · 0.45
get_diff_bitMethod · 0.45
get_inten_tableMethod · 0.45
get_base5_colorMethod · 0.45

Tested by

no test coverage detected