From 2a464a9cc3cc826264ed02e6b27704f70bd2819a Mon Sep 17 00:00:00 2001 From: Carl Woffenden Date: Sat, 21 Mar 2020 12:59:29 +0100 Subject: [PATCH 1/2] Fixes to build since UASTC additions --- contrib/single_file_transcoder/basisu_transcoder-in.cpp | 5 +---- contrib/single_file_transcoder/examples/emscripten.cpp | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/contrib/single_file_transcoder/basisu_transcoder-in.cpp b/contrib/single_file_transcoder/basisu_transcoder-in.cpp index f341644..19d3589 100644 --- a/contrib/single_file_transcoder/basisu_transcoder-in.cpp +++ b/contrib/single_file_transcoder/basisu_transcoder-in.cpp @@ -62,10 +62,7 @@ void _basisu_translib_dummy() { // Unused but only when building with EAC BASISU_NOTE_UNUSED(basist::g_eac_modifier_table); #endif -#if BASISD_SUPPORT_PVRTC1 - // Unused but only when building with PVRTC - BASISU_NOTE_UNUSED(basist::g_pvrtc_bilinear_weights); -#else +#if BASISD_SUPPORT_PVRTC1 == 0 // Unused only when not building with PVRTC BASISU_NOTE_UNUSED(basist::g_etc1_inten_tables16); BASISU_NOTE_UNUSED(basist::g_etc1_inten_tables48); diff --git a/contrib/single_file_transcoder/examples/emscripten.cpp b/contrib/single_file_transcoder/examples/emscripten.cpp index d8c2a60..96ae5a6 100644 --- a/contrib/single_file_transcoder/examples/emscripten.cpp +++ b/contrib/single_file_transcoder/examples/emscripten.cpp @@ -379,7 +379,7 @@ bool upload(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE const ctx, GLuint const name, const decSize = (std::max(8U, (descW + 3) & ~3) * std::max(8U, (descH + 3) & ~3) * 4 + 7) / 8; } else { - decSize = basis_get_bytes_per_block(type) * blocks; + decSize = basis_get_bytes_per_block_or_pixel(type) * blocks; } if (void* decBuf = malloc(decSize)) { if (type >= transcoder_texture_format::cTFTotalTextureFormats) { From a9ee1542330c7e741f03e32322e6d009fe86145a Mon Sep 17 00:00:00 2001 From: Carl Woffenden Date: Sat, 21 Mar 2020 16:13:45 +0100 Subject: [PATCH 2/2] Fixed Emscripten demo when transcoding to uncompressed formats (Also added editor config file) --- contrib/single_file_transcoder/.editorconfig | 4 ++++ .../examples/emscripten.cpp | 17 +++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 contrib/single_file_transcoder/.editorconfig diff --git a/contrib/single_file_transcoder/.editorconfig b/contrib/single_file_transcoder/.editorconfig new file mode 100644 index 0000000..a25dbdf --- /dev/null +++ b/contrib/single_file_transcoder/.editorconfig @@ -0,0 +1,4 @@ +[*] +insert_final_newline = true +indent_style = tab +indent_size = 4 diff --git a/contrib/single_file_transcoder/examples/emscripten.cpp b/contrib/single_file_transcoder/examples/emscripten.cpp index 96ae5a6..740bd26 100644 --- a/contrib/single_file_transcoder/examples/emscripten.cpp +++ b/contrib/single_file_transcoder/examples/emscripten.cpp @@ -379,20 +379,25 @@ bool upload(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE const ctx, GLuint const name, const decSize = (std::max(8U, (descW + 3) & ~3) * std::max(8U, (descH + 3) & ~3) * 4 + 7) / 8; } else { - decSize = basis_get_bytes_per_block_or_pixel(type) * blocks; + decSize = basis_get_bytes_per_block_or_pixel(type); + if (basis_transcoder_format_is_uncompressed(type)) { + decSize *= descW * descH; + } else { + decSize *= blocks; + } } if (void* decBuf = malloc(decSize)) { - if (type >= transcoder_texture_format::cTFTotalTextureFormats) { + if (basis_transcoder_format_is_uncompressed(type)) { // note that blocks becomes total number of pixels for RGB/RGBA blocks = descW * descH; } if (transcoder.transcode_image_level(data, size, 0, level, decBuf, blocks, type)) { - if (type < transcoder_texture_format::cTFTotalTextureFormats) { - glCompressedTexImage2D(GL_TEXTURE_2D, level, - toGlType(type), descW, descH, 0, decSize, decBuf); - } else { + if (basis_transcoder_format_is_uncompressed(type)) { glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, descW, descH, 0, GL_RGBA, toGlType(type), decBuf); + } else { + glCompressedTexImage2D(GL_TEXTURE_2D, level, + toGlType(type), descW, descH, 0, decSize, decBuf); } success = true; }