Skip to content

Commit

Permalink
Merge pull request #7 from zeux/wasmopt
Browse files Browse the repository at this point in the history
Make basis_transcoder.{js,wasm} substantially smaller
  • Loading branch information
richgel999 authored May 23, 2019
2 parents 5f5c579 + c2430c3 commit 0319b50
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 17 deletions.
7 changes: 0 additions & 7 deletions transcoder/basisu.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,6 @@
#include <assert.h>
#include <random>

#if defined(__EMSCRIPTEN__) && !defined(_DEBUG) && !defined(DEBUG)
// HUGE HACK: I've been unable to disable assertions using emcc -O2 -s ASSERTIONS=0, no idea why.
// We definitely don't want them enabled in release.
#undef assert
#define assert(x) ((void)0)
#endif

#ifdef max
#undef max
#endif
Expand Down
24 changes: 19 additions & 5 deletions transcoder/basisu_transcoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,25 @@
// Set to 1 for fuzz testing. This will disable all CRC16 checks on headers and compressed data.
#define BASISU_NO_HEADER_OR_DATA_CRC16_CHECKS 0

#define BASISD_SUPPORT_DXT1 1
#define BASISD_SUPPORT_DXT5A 1
#define BASISD_SUPPORT_BC7 1
#define BASISD_SUPPORT_PVRTC1 1
#define BASISD_SUPPORT_ETC2_EAC_A8 1
#ifndef BASISD_SUPPORT_DXT1
#define BASISD_SUPPORT_DXT1 1
#endif

#ifndef BASISD_SUPPORT_DXT5A
#define BASISD_SUPPORT_DXT5A 1
#endif

#ifndef BASISD_SUPPORT_BC7
#define BASISD_SUPPORT_BC7 1
#endif

#ifndef BASISD_SUPPORT_PVRTC1
#define BASISD_SUPPORT_PVRTC1 1
#endif

#ifndef BASISD_SUPPORT_ETC2_EAC_A8
#define BASISD_SUPPORT_ETC2_EAC_A8 1
#endif

#define BASISD_WRITE_NEW_BC7_TABLES 0
#define BASISD_WRITE_NEW_DXT1_TABLES 0
Expand Down
2 changes: 1 addition & 1 deletion webgl/transcoder/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ if (EMSCRIPTEN)
set_target_properties(basis_transcoder.js PROPERTIES
OUTPUT_NAME "basis_transcoder"
SUFFIX ".js"
LINK_FLAGS "--bind -s ALLOW_MEMORY_GROWTH=1 -O3 -s ASSERTIONS=0")
LINK_FLAGS "--bind -s ALLOW_MEMORY_GROWTH=1 -O3 -s ASSERTIONS=0 -s MALLOC=emmalloc -DNDEBUG -DBASISD_SUPPORT_BC7=0")
endif()
3 changes: 0 additions & 3 deletions webgl/transcoder/basis_wrappers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
#include "basisu_transcoder.h"
#include <emscripten/bind.h>

#include <iostream>

using namespace emscripten;
using namespace basist;

Expand Down Expand Up @@ -39,7 +37,6 @@ struct basis_file

if (!m_transcoder.validate_header(m_file.data(), m_file.size())) {
m_file.clear();
std::cerr << "Invalid Basis header" << std::endl;
}

// Initialized after validation
Expand Down
2 changes: 1 addition & 1 deletion webgl/transcoder/build/basis_transcoder.js

Large diffs are not rendered by default.

Binary file modified webgl/transcoder/build/basis_transcoder.wasm
Binary file not shown.

0 comments on commit 0319b50

Please sign in to comment.