| 617 | } |
| 618 | |
| 619 | void basisu_backend::compute_slice_crcs() |
| 620 | { |
| 621 | for (uint32_t slice_index = 0; slice_index < m_slices.size(); slice_index++) |
| 622 | { |
| 623 | //const uint32_t first_block_index = m_slices[slice_index].m_first_block_index; |
| 624 | const uint32_t width = m_slices[slice_index].m_width; |
| 625 | const uint32_t height = m_slices[slice_index].m_height; |
| 626 | const uint32_t num_blocks_x = m_slices[slice_index].m_num_blocks_x; |
| 627 | const uint32_t num_blocks_y = m_slices[slice_index].m_num_blocks_y; |
| 628 | |
| 629 | gpu_image gi; |
| 630 | gi.init(texture_format::cETC1, width, height); |
| 631 | |
| 632 | for (uint32_t block_y = 0; block_y < num_blocks_y; block_y++) |
| 633 | { |
| 634 | for (uint32_t block_x = 0; block_x < num_blocks_x; block_x++) |
| 635 | { |
| 636 | //const uint32_t block_index = first_block_index + block_x + block_y * num_blocks_x; |
| 637 | |
| 638 | encoder_block& m = m_slice_encoder_blocks[slice_index](block_x, block_y); |
| 639 | |
| 640 | { |
| 641 | etc_block& output_block = *(etc_block*)gi.get_block_ptr(block_x, block_y); |
| 642 | |
| 643 | output_block.set_diff_bit(true); |
| 644 | // Setting the flip bit to false to be compatible with the Khronos KDFS. |
| 645 | //output_block.set_flip_bit(true); |
| 646 | output_block.set_flip_bit(false); |
| 647 | |
| 648 | const uint32_t endpoint_index = m.m_endpoint_index; |
| 649 | |
| 650 | output_block.set_block_color5_etc1s(m_endpoint_palette[endpoint_index].m_color5); |
| 651 | output_block.set_inten_tables_etc1s(m_endpoint_palette[endpoint_index].m_inten5); |
| 652 | |
| 653 | const uint32_t selector_idx = m.m_selector_index; |
| 654 | |
| 655 | const etc1_selector_palette_entry& selectors = m_selector_palette[selector_idx]; |
| 656 | for (uint32_t sy = 0; sy < 4; sy++) |
| 657 | for (uint32_t sx = 0; sx < 4; sx++) |
| 658 | output_block.set_selector(sx, sy, selectors(sx, sy)); |
| 659 | } |
| 660 | |
| 661 | } // block_x |
| 662 | } // block_y |
| 663 | |
| 664 | m_output.m_slice_image_crcs[slice_index] = basist::crc16(gi.get_ptr(), gi.get_size_in_bytes(), 0); |
| 665 | |
| 666 | if (m_params.m_debug_images) |
| 667 | { |
| 668 | image gi_unpacked; |
| 669 | gi.unpack(gi_unpacked); |
| 670 | |
| 671 | char buf[256]; |
| 672 | #ifdef _WIN32 |
| 673 | sprintf_s(buf, sizeof(buf), "basisu_backend_slice_%u.png", slice_index); |
| 674 | #else |
| 675 | snprintf(buf, sizeof(buf), "basisu_backend_slice_%u.png", slice_index); |
| 676 | #endif |
nothing calls this directly
no test coverage detected