Adding -pvrtc_clamp command line flag, so we can see what PVRTC1 textures look like when transcoded and unpacked with clamp addressing

This commit is contained in:
richgel999
2019-09-29 18:41:57 -07:00
parent dad34eac9e
commit 9be4e210ff

View File

@@ -88,6 +88,7 @@ static void print_usage()
" -etc1_only: Only unpack to ETC1, skipping the other texture formats during -unpack\n"
" -disable_hierarchical_endpoint_codebooks: Disable hierarchical endpoint codebook usage, slower but higher quality on some compression levels\n"
" -compare_ssim: Compute and display SSIM of image comparison (slow)\n"
" -pvrtc_clamp: Use clamp addressing when transcoding and unpacking PVRTC1 textures\n"
"\n"
"Mipmap generation options:\n"
" -mipmap: Generate mipmaps for each source image\n"
@@ -216,6 +217,8 @@ static bool load_listing_file(const std::string &f, std::vector<std::string> &fi
class command_line_params
{
BASISU_NO_EQUALS_OR_COPY_CONSTRUCT(command_line_params);
public:
command_line_params() :
m_mode(cDefault),
@@ -225,7 +228,8 @@ public:
m_no_ktx(false),
m_etc1_only(false),
m_fuzz_testing(false),
m_compare_ssim(false)
m_compare_ssim(false),
m_pvrtc_clamp(false)
{
}
@@ -250,6 +254,8 @@ public:
m_mode = cValidate;
else if (strcasecmp(pArg, "-compare_ssim") == 0)
m_compare_ssim = true;
else if (strcasecmp(pArg, "-pvrtc_clamp") == 0)
m_pvrtc_clamp = true;
else if (strcasecmp(pArg, "-file") == 0)
{
REMAINING_ARGS_CHECK(1);
@@ -578,6 +584,7 @@ public:
bool m_etc1_only;
bool m_fuzz_testing;
bool m_compare_ssim;
bool m_pvrtc_clamp;
};
static bool expand_multifile(command_line_params &opts)
@@ -1009,9 +1016,11 @@ static bool unpack_and_validate_mode(command_line_params &opts, bool validate_fl
// Fill the buffer with psuedo-random bytes, to help more visibly detect cases where the transcoder fails to write to part of the output.
fill_buffer_with_random_bytes(gi.get_ptr(), gi.get_size_in_bytes());
uint32_t decode_flags = (opts.m_pvrtc_clamp ? 0 : basist::basisu_transcoder::cDecodeFlagsPVRTCWrapAddressing);
tm.start();
if (!dec.transcode_image_level(&basis_data[0], (uint32_t)basis_data.size(), image_index, level_index, gi.get_ptr(), gi.get_total_blocks(), transcoder_tex_fmt, 0))
if (!dec.transcode_image_level(&basis_data[0], (uint32_t)basis_data.size(), image_index, level_index, gi.get_ptr(), gi.get_total_blocks(), transcoder_tex_fmt, decode_flags))
{
error_printf("Failed transcoding image level (%u %u %u)!\n", image_index, level_index, format_iter);
return false;
@@ -1094,7 +1103,8 @@ static bool unpack_and_validate_mode(command_line_params &opts, bool validate_fl
}
image u;
if (!gi[level_index].unpack(u))
const bool pvrtc_wrap_addressing = !opts.m_pvrtc_clamp;
if (!gi[level_index].unpack(u, pvrtc_wrap_addressing))
{
printf("Warning: Failed unpacking GPU texture data (%u %u %u). Unpacking as much as possible.\n", format_iter, image_index, level_index);
total_unpack_warnings++;