From bb174715b37615304974b74f61abd35175467947 Mon Sep 17 00:00:00 2001 From: Matthew Albrecht Date: Thu, 23 May 2019 17:39:19 -0500 Subject: [PATCH] CMake rework, CIs added. --- .appveyor.yml | 46 ++++ .gitignore | 3 + .travis.yml | 76 +++++++ CMakeLists.txt | 94 ++------- README.md | 41 ++-- basisu.sln | 31 --- basisu.vcxproj | 197 ------------------ basisu.vcxproj.filters | 67 ------ basisu/CMakeLists.txt | 81 +++++++ .../basisu_backend.cpp | 0 basisu_backend.h => basisu/basisu_backend.h | 0 .../basisu_basis_file.cpp | 0 .../basisu_basis_file.h | 0 basisu_comp.cpp => basisu/basisu_comp.cpp | 0 basisu_comp.h => basisu/basisu_comp.h | 0 basisu_enc.cpp => basisu/basisu_enc.cpp | 0 basisu_enc.h => basisu/basisu_enc.h | 0 basisu_etc.cpp => basisu/basisu_etc.cpp | 0 basisu_etc.h => basisu/basisu_etc.h | 0 basisu/basisu_export.h | 42 ++++ .../basisu_frontend.cpp | 0 basisu_frontend.h => basisu/basisu_frontend.h | 0 ...basisu_global_selector_palette_helpers.cpp | 0 .../basisu_global_selector_palette_helpers.h | 0 .../basisu_gpu_texture.cpp | 0 .../basisu_gpu_texture.h | 0 .../basisu_pvrtc1_4.cpp | 0 basisu_pvrtc1_4.h => basisu/basisu_pvrtc1_4.h | 0 .../basisu_resample_filters.cpp | 0 .../basisu_resampler.cpp | 0 .../basisu_resampler.h | 0 .../basisu_resampler_filters.h | 0 basisu_ssim.cpp => basisu/basisu_ssim.cpp | 0 basisu_ssim.h => basisu/basisu_ssim.h | 0 lodepng.cpp => basisu/lodepng.cpp | 0 lodepng.h => basisu/lodepng.h | 0 {transcoder => basisu/transcoder}/basisu.h | 0 .../transcoder}/basisu_file_headers.h | 0 .../transcoder}/basisu_global_selector_cb.h | 0 .../basisu_global_selector_palette.h | 6 +- .../transcoder}/basisu_transcoder.cpp | 0 .../transcoder}/basisu_transcoder.h | 0 .../transcoder}/basisu_transcoder_internal.h | 0 .../basisu_transcoder_tables_bc7_m6.inc | 0 .../basisu_transcoder_tables_dxt1_5.inc | 0 .../basisu_transcoder_tables_dxt1_6.inc | 0 bin/readme.txt | 1 - build_clang.sh | 1 - tool/CMakeLists.txt | 27 +++ basisu_tool.cpp => tool/basisu_tool.cpp | 22 +- webgl/transcoder/CMakeLists.txt | 28 +-- 51 files changed, 341 insertions(+), 422 deletions(-) create mode 100644 .appveyor.yml create mode 100644 .gitignore create mode 100644 .travis.yml delete mode 100644 basisu.sln delete mode 100644 basisu.vcxproj delete mode 100644 basisu.vcxproj.filters create mode 100644 basisu/CMakeLists.txt rename basisu_backend.cpp => basisu/basisu_backend.cpp (100%) rename basisu_backend.h => basisu/basisu_backend.h (100%) rename basisu_basis_file.cpp => basisu/basisu_basis_file.cpp (100%) rename basisu_basis_file.h => basisu/basisu_basis_file.h (100%) rename basisu_comp.cpp => basisu/basisu_comp.cpp (100%) rename basisu_comp.h => basisu/basisu_comp.h (100%) rename basisu_enc.cpp => basisu/basisu_enc.cpp (100%) rename basisu_enc.h => basisu/basisu_enc.h (100%) rename basisu_etc.cpp => basisu/basisu_etc.cpp (100%) rename basisu_etc.h => basisu/basisu_etc.h (100%) create mode 100644 basisu/basisu_export.h rename basisu_frontend.cpp => basisu/basisu_frontend.cpp (100%) rename basisu_frontend.h => basisu/basisu_frontend.h (100%) rename basisu_global_selector_palette_helpers.cpp => basisu/basisu_global_selector_palette_helpers.cpp (100%) rename basisu_global_selector_palette_helpers.h => basisu/basisu_global_selector_palette_helpers.h (100%) rename basisu_gpu_texture.cpp => basisu/basisu_gpu_texture.cpp (100%) rename basisu_gpu_texture.h => basisu/basisu_gpu_texture.h (100%) rename basisu_pvrtc1_4.cpp => basisu/basisu_pvrtc1_4.cpp (100%) rename basisu_pvrtc1_4.h => basisu/basisu_pvrtc1_4.h (100%) rename basisu_resample_filters.cpp => basisu/basisu_resample_filters.cpp (100%) rename basisu_resampler.cpp => basisu/basisu_resampler.cpp (100%) rename basisu_resampler.h => basisu/basisu_resampler.h (100%) rename basisu_resampler_filters.h => basisu/basisu_resampler_filters.h (100%) rename basisu_ssim.cpp => basisu/basisu_ssim.cpp (100%) rename basisu_ssim.h => basisu/basisu_ssim.h (100%) rename lodepng.cpp => basisu/lodepng.cpp (100%) rename lodepng.h => basisu/lodepng.h (100%) rename {transcoder => basisu/transcoder}/basisu.h (100%) rename {transcoder => basisu/transcoder}/basisu_file_headers.h (100%) rename {transcoder => basisu/transcoder}/basisu_global_selector_cb.h (100%) rename {transcoder => basisu/transcoder}/basisu_global_selector_palette.h (98%) rename {transcoder => basisu/transcoder}/basisu_transcoder.cpp (100%) rename {transcoder => basisu/transcoder}/basisu_transcoder.h (100%) rename {transcoder => basisu/transcoder}/basisu_transcoder_internal.h (100%) rename {transcoder => basisu/transcoder}/basisu_transcoder_tables_bc7_m6.inc (100%) rename {transcoder => basisu/transcoder}/basisu_transcoder_tables_dxt1_5.inc (100%) rename {transcoder => basisu/transcoder}/basisu_transcoder_tables_dxt1_6.inc (100%) delete mode 100644 bin/readme.txt delete mode 100644 build_clang.sh create mode 100644 tool/CMakeLists.txt rename basisu_tool.cpp => tool/basisu_tool.cpp (99%) diff --git a/.appveyor.yml b/.appveyor.yml new file mode 100644 index 00000000..c98da4b7 --- /dev/null +++ b/.appveyor.yml @@ -0,0 +1,46 @@ +version: 1.0.5{build} + +clone_depth: 5 + +build: + parallel: true + verbosity: minimal + +environment: + matrix: + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + ARCHITECTURE: x64 + GEN: "Visual Studio 15 2017 Win64" + CFG: Debug + BUILD_OUT: "x64-Debug" + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + ARCHITECTURE: x64 + GEN: "Visual Studio 15 2017 Win64" + CFG: Release + BUILD_OUT: "x64-Release" + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + ARCHITECTURE: x86 + GEN: "Visual Studio 15 2017" + CFG: Debug + BUILD_OUT: "x86-Debug" + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + ARCHITECTURE: x86 + GEN: "Visual Studio 15 2017" + CFG: Release + BUILD_OUT: "x86-Release" + NINJA_URL: https://github.com/ninja-build/ninja/releases/download/v1.9.0/ninja-win.zip + MSVC_HOME: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community" + +install: + - git submodule update --init --recursive + # Get Ninja + - appveyor DownloadFile %NINJA_URL% -FileName ninja.zip + - 7z x ninja.zip -oC:\ninja > nul + - set PATH=C:\ninja;%PATH% + - ninja --version + +build_script: + - call "%MSVC_HOME%\VC\Auxiliary\Build\vcvarsall.bat" %ARCHITECTURE% + - mkdir bin\%BUILD_OUT% && cd bin\%BUILD_OUT% + - cmake -DCMAKE_BUILD_TYPE=%CFG% -GNinja ../../ + - ninja diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..6a6464c9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.vs/* +out/* +.DS_Store \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..cd98460b --- /dev/null +++ b/.travis.yml @@ -0,0 +1,76 @@ +matrix: + include: + # GCC 7 + - os: linux + dist: xenial + sudo: required + addons: &gcc7 + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - pkg-config + - cmake + - g++-7 + language: cpp + compiler: gcc + env: + - COMPILER=g++-7 + - GSL_CXX_STANDARD=17 + - BUILD_TYPE=Release + before_install: + - sudo apt-get update -qq + - sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 90 + # Clang 6.0 + - os: linux + dist: xenial + sudo: required + addons: &clang60 + apt: + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-xenial-6.0 + - sourceline: 'deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-6.0 main' + key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key' + packages: + - pkg-config + - cmake + - clang-6.0 + - g++-7 + language: cpp + compiler: clang + env: + - COMPILER=clang++-6.0 + - GSL_CXX_STANDARD=17 + - BUILD_TYPE=Release + before_install: + - sudo apt-get update -qq + - sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-6.0 1000 + - sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-6.0 1000 + - clang --version + # XCode 10.2 + - os: osx + osx_image: xcode10.2 + sudo: required + language: cpp + compiler: clang + env: + - COMPILER=clang++ + - GSL_CXX_STANDARD=17 + - BUILD_TYPE=Release + before_install: + - brew update + - brew install pkg-config + +script: +- git submodule update --init --recursive +- mkdir bin && cd bin +- | + if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then + cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=$BUILD_TYPE + make all -j$(nproc) + else + cmake .. -G "Xcode" -DCMAKE_BUILD_TYPE=$BUILD_TYPE + xcodebuild -quiet -parallelizeTargets -jobs $(sysctl -n hw.physicalcpu) -target basisu -configuration $BUILD_TYPE + fi +- cd ../ diff --git a/CMakeLists.txt b/CMakeLists.txt index 62d4a411..3746c847 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,87 +1,21 @@ -project(basisu) +cmake_minimum_required(VERSION 3.0 FATAL_ERROR) +project(basisu VERSION 1.0.5 LANGUAGES C CXX) -cmake_minimum_required(VERSION 3.0) -option(BUILD_X64 "build 64-bit" TRUE) -option(STATIC "static linking" FALSE) +option(BUILD_SHARED_LIBS "Build Shared Libraries" ON) +option(BASISU_BUILD_TOOL "Build the tool" ON) +option(BASISU_INSTALL "Installs basis universal" ON) +option(BASISU_INSTALL_TOOL "Installs the tool" ON) -message("Initial BUILD_X64=${BUILD_X64}") -message("Initial CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}") +# GNU filesystem conventions +include(GNUInstallDirs) -if( NOT CMAKE_BUILD_TYPE ) - set( CMAKE_BUILD_TYPE Release ) -endif( NOT CMAKE_BUILD_TYPE ) +# Windows build shared libraries +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) -message( ${PROJECT_NAME} " build type: " ${CMAKE_BUILD_TYPE} ) +find_package(Threads REQUIRED) -if (BUILD_X64) - message("Building 64-bit") -else() - message("Building 32-bit") -endif(BUILD_X64) +add_subdirectory(basisu) -set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g") -set(CMAKE_C_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g") - -set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") -set(CMAKE_C_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") - -set(CMAKE_CXX_FLAGS -std=c++11) -set(GCC_COMPILE_FLAGS "-fvisibility=hidden -fvisibility-inlines-hidden -fPIC -fopenmp -fno-strict-aliasing -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64 -Wall -Wextra -Wno-unused-local-typedefs -Wno-unused-value -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-unused-variable -Wno-reorder") - -if (NOT BUILD_X64) - set(GCC_COMPILE_FLAGS "${GCC_COMPILE_FLAGS} -m32") +if(BASISU_BUILD_TOOL) + add_subdirectory(tool) endif() - -if (STATIC) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_LINK_FLAGS} -static-libgcc -static-libstdc++ -static") -else() - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_LINK_FLAGS} -Wl,-rpath .") -endif(STATIC) - -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GCC_COMPILE_FLAGS}") -set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${GCC_COMPILE_FLAGS}") -set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${GCC_COMPILE_FLAGS} -D_DEBUG") - -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COMPILE_FLAGS}") -set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${GCC_COMPILE_FLAGS}") -set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${GCC_COMPILE_FLAGS} -D_DEBUG") - -set(BASISU_SRC_LIST ${COMMON_SRC_LIST} - basisu_backend.cpp - basisu_basis_file.cpp - basisu_comp.cpp - basisu_enc.cpp - basisu_etc.cpp - basisu_frontend.cpp - basisu_global_selector_palette_helpers.cpp - basisu_gpu_texture.cpp - basisu_pvrtc1_4.cpp - basisu_resampler.cpp - basisu_resample_filters.cpp - basisu_ssim.cpp - basisu_tool.cpp - lodepng.cpp - transcoder/basisu_transcoder.cpp - ) - -if (APPLE) - set(BIN_DIRECTORY "bin_osx") -else() - set(BIN_DIRECTORY "bin") -endif() - -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/${BIN_DIRECTORY}) - -add_executable(basisu ${BASISU_SRC_LIST}) -target_link_libraries(basisu m pthread) - -install(TARGETS basisu DESTINATION bin) - -if (CMAKE_BUILD_TYPE STREQUAL Release) - if (APPLE) - add_custom_command(TARGET basisu POST_BUILD COMMAND strip -X -x ${CMAKE_SOURCE_DIR}/${BIN_DIRECTORY}/basisu) - else() - add_custom_command(TARGET basisu POST_BUILD COMMAND strip -g -X -x ${CMAKE_SOURCE_DIR}/${BIN_DIRECTORY}/basisu) - endif() -endif() - diff --git a/README.md b/README.md index ad038943..7fdfa759 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,8 @@ # basis_universal + +[![Build status](https://ci.appveyor.com/api/projects/status/vj7gnik7fo6indw7?svg=true)](https://ci.appveyor.com/project/Mattparks/basis_universal) +[![Build Status](https://travis-ci.org/mattparks/basis_universal.svg?branch=master)](https://travis-ci.org/mattparks/basis_universal) + Basis Universal GPU Texture and Texture Video Compression Reference Codec Basis Universal is a ["supercompressed"](http://gamma.cs.unc.edu/GST/gst.pdf) GPU texture and texture video compression system that outputs a highly compressed intermediate file format (.basis) that can be quickly transcoded to a wide variety of GPU texture compression formats: PVRTC1 4bpp RGB, BC7 mode 6 RGB, BC1-5, ETC1, and ETC2. We will be adding ASTC RGB or RGBA, BC7 mode 4/5 RGBA, and PVRTC1 4bpp RGBA next. Basis files support non-uniform texture arrays, so cubemaps, volume textures, texture arrays, mipmap levels, video sequences, or arbitrary texture "tiles" can be stored in a single file. The compressor is able to exploit color and pattern correlations across the entire file, so multiple images with mipmaps can be stored very efficiently in a single file. @@ -21,12 +25,13 @@ The encoder uses [lodepng](https://lodev.org/lodepng/) for loading and saving PN ### Command Line Compression Tool -The command line tool used to create, validate, and transcode/unpack .basis files is named "basisu". Run basisu without any parameters for help. Note this tool uses the reference encoder. +The command line tool used to create, validate, and transcode/unpack .basis files is named "basisuTool". Run basisuTool without any parameters for help. Note this tool uses the reference encoder. To build basisu: ``` -cmake CMakeLists.txt +mkdir bin && cd bin +cmake .. make ``` @@ -42,23 +47,23 @@ make To compress a sRGB image to .basis: -`basisu x.png` +`basisuTool x.png` Note that basisu defaults to sRGB colorspace metrics. If the input is a normal map, or some other type of non-sRGB (non-photographic) texture content, be sure to use -linear to avoid extra unnecessary artifacts. To add automatically generated mipmaps to the .basis file, at a higher than default quality level (which ranges from [1,255]): -`basisu -mipmap -mip_srgb -q 190 x.png` +`basisuTool -mipmap -mip_srgb -q 190 x.png` There are several mipmap options that allow you to change the filter kernel, the smallest mipmap dimension, etc. The tool also supports generating cubemap files, 2D/cubemap texture arrays, etc. To create a higher quality .basis file (one with better codebooks): -`basisu -slower x.png` +`basisuTool -slower x.png` To unpack a .basis file to multiple .png/.ktx files: -`basisu x.basis` +`basisuTool x.basis` The mipmapped .KTX files will be in a variety of compressed GPU texture formats (PVRTC1 4bpp, ETC1-2, BC1-5, BC7), and to my knowledge there is no single .KTX viewer tool that correctly and reliably supports every GPU texture format that we support. BC1-5 and BC7 files are viewable using AMD's Compressonator, ETC1/2 using Mali's Texture Compression Tool, and PVRTC1 using Imagination Tech's PVRTexTool. Links: @@ -74,13 +79,13 @@ For best quality, you must supply basisu with original uncompressed source image For the maximum possible achievable quality with the current format and encoder, use: -`basisu x.png -slower -max_endpoints 16128 -max_selectors 16128 -no_selector_rdo -no_endpoint_rdo` +`basisuTool x.png -slower -max_endpoints 16128 -max_selectors 16128 -no_selector_rdo -no_endpoint_rdo` Note that "-no_selector_rdo -no_endpoint_rdo" are optional. Using them hurts rate distortion performance, but increases quality. An alternative is to use -selector_rdo_thresh X and -endpoint_rdo_thresh, with X ranging from [1,2] (higher=lower quality/better compression - see the tool's help text). To compress small video sequences, say using tools like ffmpeg and VirtualDub: -'basisu -slower -tex_type video -stats -debug -multifile_printf "pic%04u.png" -multifile_num 200 -multifile_first 1 -max_selectors 16128 -max_endpoints 16128' +'basisuTool -slower -tex_type video -stats -debug -multifile_printf "pic%04u.png" -multifile_num 200 -multifile_first 1 -max_selectors 16128 -max_endpoints 16128' The reference encoder will take a LONG time and a lot of CPU to encode video, especially with -slower. The more cores your machine has, the better. Basis is intended for smaller videos of a few dozen seconds or so. If you are very patient and have a Threadripper or Xeon workstation, you should be able to encode up to a few thousand 720P frames. @@ -92,34 +97,34 @@ If you are doing rate distortion comparisons vs. other similar systems, be sure ### More detailed examples -`basisu x.png`\ +`basisuTool x.png`\ Compress sRGB image x.png to x.basis using default settings (multiple filenames OK) -`basisu x.basis`\ +`basisuTool x.basis`\ Unpack x.basis to PNG/KTX files (multiple filenames OK) -`basisu -file x.png -mipmap -mip_srgb -y_flip`\ +`basisuTool -file x.png -mipmap -mip_srgb -y_flip`\ Compress a mipmapped x.basis file from an sRGB image named x.png, Y flip each source image -`basisu -validate -file x.basis`\ +`basisuTool -validate -file x.basis`\ Validate x.basis (check header, check file CRC's, attempt to transcode all slices) -`basisu -unpack -file x.basis`\ +`basisuTool -unpack -file x.basis`\ Validates, transcodes and unpacks x.basis to mipmapped .KTX and RGB/A .PNG files (transcodes to all supported GPU texture formats) -`basisu -q 255 -file x.png -mipmap -mip_srgb -debug -stats`\ +`basisuTool -q 255 -file x.png -mipmap -mip_srgb -debug -stats`\ Compress sRGB x.png to x.basis at quality level 255 with compressor debug output/statistics -`basisu -linear -max_endpoints 16128 -max_selectors 16128 -file x.png`\ +`basisuTool -linear -max_endpoints 16128 -max_selectors 16128 -file x.png`\ Compress non-sRGB x.png to x.basis using the largest supported manually specified codebook sizes -`basisu -linear -global_sel_pal -no_hybrid_sel_cb -file x.png`\ +`basisuTool -linear -global_sel_pal -no_hybrid_sel_cb -file x.png`\ Compress a non-sRGB image, use virtual selector codebooks for improved compression (but slower encoding) -`basisu -linear -global_sel_pal -file x.png`\ +`basisuTool -linear -global_sel_pal -file x.png`\ Compress a non-sRGB image, use hybrid selector codebooks for slightly improved compression (but slower encoding) -`basisu -tex_type video -framerate 20 -multifile_printf "x%02u.png" -multifile_first 1 -multifile_count 20`\ +`basisuTool -tex_type video -framerate 20 -multifile_printf "x%02u.png" -multifile_first 1 -multifile_count 20`\ Compress a 20 sRGB source image video sequence (x01.png, x02.png, x03.png, etc.) to x01.basis diff --git a/basisu.sln b/basisu.sln deleted file mode 100644 index dda6ffbb..00000000 --- a/basisu.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.28803.202 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "basisu", "basisu.vcxproj", "{59586A07-8E7E-411D-BC3D-387E039AA423}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {59586A07-8E7E-411D-BC3D-387E039AA423}.Debug|x64.ActiveCfg = Debug|x64 - {59586A07-8E7E-411D-BC3D-387E039AA423}.Debug|x64.Build.0 = Debug|x64 - {59586A07-8E7E-411D-BC3D-387E039AA423}.Debug|x86.ActiveCfg = Debug|Win32 - {59586A07-8E7E-411D-BC3D-387E039AA423}.Debug|x86.Build.0 = Debug|Win32 - {59586A07-8E7E-411D-BC3D-387E039AA423}.Release|x64.ActiveCfg = Release|x64 - {59586A07-8E7E-411D-BC3D-387E039AA423}.Release|x64.Build.0 = Release|x64 - {59586A07-8E7E-411D-BC3D-387E039AA423}.Release|x86.ActiveCfg = Release|Win32 - {59586A07-8E7E-411D-BC3D-387E039AA423}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {5E583429-7830-4B3A-9DDE-F01B115CE0D8} - EndGlobalSection -EndGlobal diff --git a/basisu.vcxproj b/basisu.vcxproj deleted file mode 100644 index 332ae13a..00000000 --- a/basisu.vcxproj +++ /dev/null @@ -1,197 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - {59586A07-8E7E-411D-BC3D-387E039AA423} - basisu - 10.0 - - - - Application - true - v142 - MultiByte - - - Application - false - v142 - true - MultiByte - - - Application - true - v142 - MultiByte - - - Application - false - v142 - true - MultiByte - - - - - - - - - - - - - - - - - - - - - $(SolutionDir)\bin - - - $(SolutionDir)\bin - - - $(SolutionDir)\bin - - - $(SolutionDir)\bin - - - - Level4 - Disabled - true - true - - - - - Console - - - - - Level4 - Disabled - true - true - - - true - - - Console - - - - - Level4 - MaxSpeed - true - true - true - true - - - NDEBUG;_MBCS;%(PreprocessorDefinitions) - false - AnySuitable - - - true - true - Console - - - - - Level4 - MaxSpeed - true - true - true - true - - - NDEBUG;_MBCS;%(PreprocessorDefinitions) - false - true - AnySuitable - - - true - true - Console - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/basisu.vcxproj.filters b/basisu.vcxproj.filters deleted file mode 100644 index 896699e5..00000000 --- a/basisu.vcxproj.filters +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - - - - - - - - - - - transcoder - - - - - - - - - - - - - - - - - - - - transcoder - - - transcoder - - - transcoder - - - transcoder - - - - - - transcoder - - - transcoder - - - transcoder - - - - - {7a54aaad-1d10-4bdf-b8e9-c14ed2263ed8} - - - \ No newline at end of file diff --git a/basisu/CMakeLists.txt b/basisu/CMakeLists.txt new file mode 100644 index 00000000..5c627b5c --- /dev/null +++ b/basisu/CMakeLists.txt @@ -0,0 +1,81 @@ +set(BASISU_HEADER_FILES + transcoder/basisu.h + transcoder/basisu_file_headers.h + transcoder/basisu_global_selector_cb.h + transcoder/basisu_global_selector_palette.h + transcoder/basisu_transcoder.h + transcoder/basisu_transcoder_internal.h + basisu_backend.h + basisu_basis_file.h + basisu_comp.h + basisu_enc.h + basisu_etc.h + basisu_frontend.h + basisu_global_selector_palette_helpers.h + basisu_gpu_texture.h + basisu_pvrtc1_4.h + basisu_resampler.h + basisu_ssim.h + #lodepng.h + ) +set(BASISU_SOURCE_FILES + transcoder/basisu_transcoder.cpp + basisu_backend.cpp + basisu_basis_file.cpp + basisu_comp.cpp + basisu_enc.cpp + basisu_etc.cpp + basisu_frontend.cpp + basisu_global_selector_palette_helpers.cpp + basisu_gpu_texture.cpp + basisu_pvrtc1_4.cpp + basisu_resampler.cpp + basisu_resample_filters.cpp + basisu_ssim.cpp + lodepng.cpp + ) +set(BASISU_SOURCES + ${BASISU_HEADER_FILES} + ${BASISU_SOURCE_FILES} + ) + +add_library(basisu ${BASISU_SOURCES}) + +target_compile_features(basisu PUBLIC cxx_std_11) +set_target_properties(basisu PROPERTIES + POSITION_INDEPENDENT_CODE ON + FOLDER "basisu" + ) + +target_include_directories(basisu + PUBLIC + # Helps the includes find what they need at build-time + $ + # Helps the includes find what they need at runtime + $ + ) + +target_link_libraries(basisu + PRIVATE + Threads::Threads + ) + +include(GenerateExportHeader) +generate_export_header(basisu EXPORT_FILE_NAME "${CMAKE_CURRENT_SOURCE_DIR}/basisu_export.h") + +if(BASISU_INSTALL) + install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/" + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}" + FILES_MATCHING + PATTERN "*.h" + PATTERN "*.hpp" + ) + install(TARGETS basisu + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + ) + #install(FILES + # ${CMAKE_CURRENT_BINARY_DIR}/basisu_export.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}" + # ) +endif() diff --git a/basisu_backend.cpp b/basisu/basisu_backend.cpp similarity index 100% rename from basisu_backend.cpp rename to basisu/basisu_backend.cpp diff --git a/basisu_backend.h b/basisu/basisu_backend.h similarity index 100% rename from basisu_backend.h rename to basisu/basisu_backend.h diff --git a/basisu_basis_file.cpp b/basisu/basisu_basis_file.cpp similarity index 100% rename from basisu_basis_file.cpp rename to basisu/basisu_basis_file.cpp diff --git a/basisu_basis_file.h b/basisu/basisu_basis_file.h similarity index 100% rename from basisu_basis_file.h rename to basisu/basisu_basis_file.h diff --git a/basisu_comp.cpp b/basisu/basisu_comp.cpp similarity index 100% rename from basisu_comp.cpp rename to basisu/basisu_comp.cpp diff --git a/basisu_comp.h b/basisu/basisu_comp.h similarity index 100% rename from basisu_comp.h rename to basisu/basisu_comp.h diff --git a/basisu_enc.cpp b/basisu/basisu_enc.cpp similarity index 100% rename from basisu_enc.cpp rename to basisu/basisu_enc.cpp diff --git a/basisu_enc.h b/basisu/basisu_enc.h similarity index 100% rename from basisu_enc.h rename to basisu/basisu_enc.h diff --git a/basisu_etc.cpp b/basisu/basisu_etc.cpp similarity index 100% rename from basisu_etc.cpp rename to basisu/basisu_etc.cpp diff --git a/basisu_etc.h b/basisu/basisu_etc.h similarity index 100% rename from basisu_etc.h rename to basisu/basisu_etc.h diff --git a/basisu/basisu_export.h b/basisu/basisu_export.h new file mode 100644 index 00000000..9659808a --- /dev/null +++ b/basisu/basisu_export.h @@ -0,0 +1,42 @@ + +#ifndef BASISU_EXPORT_H +#define BASISU_EXPORT_H + +#ifdef BASISU_STATIC_DEFINE +# define BASISU_EXPORT +# define BASISU_NO_EXPORT +#else +# ifndef BASISU_EXPORT +# ifdef basisu_EXPORTS + /* We are building this library */ +# define BASISU_EXPORT __declspec(dllexport) +# else + /* We are using this library */ +# define BASISU_EXPORT __declspec(dllimport) +# endif +# endif + +# ifndef BASISU_NO_EXPORT +# define BASISU_NO_EXPORT +# endif +#endif + +#ifndef BASISU_DEPRECATED +# define BASISU_DEPRECATED __declspec(deprecated) +#endif + +#ifndef BASISU_DEPRECATED_EXPORT +# define BASISU_DEPRECATED_EXPORT BASISU_EXPORT BASISU_DEPRECATED +#endif + +#ifndef BASISU_DEPRECATED_NO_EXPORT +# define BASISU_DEPRECATED_NO_EXPORT BASISU_NO_EXPORT BASISU_DEPRECATED +#endif + +#if 0 /* DEFINE_NO_DEPRECATED */ +# ifndef BASISU_NO_DEPRECATED +# define BASISU_NO_DEPRECATED +# endif +#endif + +#endif /* BASISU_EXPORT_H */ diff --git a/basisu_frontend.cpp b/basisu/basisu_frontend.cpp similarity index 100% rename from basisu_frontend.cpp rename to basisu/basisu_frontend.cpp diff --git a/basisu_frontend.h b/basisu/basisu_frontend.h similarity index 100% rename from basisu_frontend.h rename to basisu/basisu_frontend.h diff --git a/basisu_global_selector_palette_helpers.cpp b/basisu/basisu_global_selector_palette_helpers.cpp similarity index 100% rename from basisu_global_selector_palette_helpers.cpp rename to basisu/basisu_global_selector_palette_helpers.cpp diff --git a/basisu_global_selector_palette_helpers.h b/basisu/basisu_global_selector_palette_helpers.h similarity index 100% rename from basisu_global_selector_palette_helpers.h rename to basisu/basisu_global_selector_palette_helpers.h diff --git a/basisu_gpu_texture.cpp b/basisu/basisu_gpu_texture.cpp similarity index 100% rename from basisu_gpu_texture.cpp rename to basisu/basisu_gpu_texture.cpp diff --git a/basisu_gpu_texture.h b/basisu/basisu_gpu_texture.h similarity index 100% rename from basisu_gpu_texture.h rename to basisu/basisu_gpu_texture.h diff --git a/basisu_pvrtc1_4.cpp b/basisu/basisu_pvrtc1_4.cpp similarity index 100% rename from basisu_pvrtc1_4.cpp rename to basisu/basisu_pvrtc1_4.cpp diff --git a/basisu_pvrtc1_4.h b/basisu/basisu_pvrtc1_4.h similarity index 100% rename from basisu_pvrtc1_4.h rename to basisu/basisu_pvrtc1_4.h diff --git a/basisu_resample_filters.cpp b/basisu/basisu_resample_filters.cpp similarity index 100% rename from basisu_resample_filters.cpp rename to basisu/basisu_resample_filters.cpp diff --git a/basisu_resampler.cpp b/basisu/basisu_resampler.cpp similarity index 100% rename from basisu_resampler.cpp rename to basisu/basisu_resampler.cpp diff --git a/basisu_resampler.h b/basisu/basisu_resampler.h similarity index 100% rename from basisu_resampler.h rename to basisu/basisu_resampler.h diff --git a/basisu_resampler_filters.h b/basisu/basisu_resampler_filters.h similarity index 100% rename from basisu_resampler_filters.h rename to basisu/basisu_resampler_filters.h diff --git a/basisu_ssim.cpp b/basisu/basisu_ssim.cpp similarity index 100% rename from basisu_ssim.cpp rename to basisu/basisu_ssim.cpp diff --git a/basisu_ssim.h b/basisu/basisu_ssim.h similarity index 100% rename from basisu_ssim.h rename to basisu/basisu_ssim.h diff --git a/lodepng.cpp b/basisu/lodepng.cpp similarity index 100% rename from lodepng.cpp rename to basisu/lodepng.cpp diff --git a/lodepng.h b/basisu/lodepng.h similarity index 100% rename from lodepng.h rename to basisu/lodepng.h diff --git a/transcoder/basisu.h b/basisu/transcoder/basisu.h similarity index 100% rename from transcoder/basisu.h rename to basisu/transcoder/basisu.h diff --git a/transcoder/basisu_file_headers.h b/basisu/transcoder/basisu_file_headers.h similarity index 100% rename from transcoder/basisu_file_headers.h rename to basisu/transcoder/basisu_file_headers.h diff --git a/transcoder/basisu_global_selector_cb.h b/basisu/transcoder/basisu_global_selector_cb.h similarity index 100% rename from transcoder/basisu_global_selector_cb.h rename to basisu/transcoder/basisu_global_selector_cb.h diff --git a/transcoder/basisu_global_selector_palette.h b/basisu/transcoder/basisu_global_selector_palette.h similarity index 98% rename from transcoder/basisu_global_selector_palette.h rename to basisu/transcoder/basisu_global_selector_palette.h index 70c663a9..68559478 100644 --- a/transcoder/basisu_global_selector_palette.h +++ b/basisu/transcoder/basisu_global_selector_palette.h @@ -13,6 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. #pragma once + +#include "basisu_export.h" #include "basisu_transcoder_internal.h" #include @@ -611,8 +613,8 @@ namespace basist typedef std::vector etc1_selector_palette_entry_vec; - extern const uint32_t g_global_selector_cb[]; - extern const uint32_t g_global_selector_cb_size; + BASISU_EXPORT extern const uint32_t g_global_selector_cb[]; + BASISU_EXPORT extern const uint32_t g_global_selector_cb_size; #define ETC1_GLOBAL_SELECTOR_CODEBOOK_MAX_PAL_BITS (12) diff --git a/transcoder/basisu_transcoder.cpp b/basisu/transcoder/basisu_transcoder.cpp similarity index 100% rename from transcoder/basisu_transcoder.cpp rename to basisu/transcoder/basisu_transcoder.cpp diff --git a/transcoder/basisu_transcoder.h b/basisu/transcoder/basisu_transcoder.h similarity index 100% rename from transcoder/basisu_transcoder.h rename to basisu/transcoder/basisu_transcoder.h diff --git a/transcoder/basisu_transcoder_internal.h b/basisu/transcoder/basisu_transcoder_internal.h similarity index 100% rename from transcoder/basisu_transcoder_internal.h rename to basisu/transcoder/basisu_transcoder_internal.h diff --git a/transcoder/basisu_transcoder_tables_bc7_m6.inc b/basisu/transcoder/basisu_transcoder_tables_bc7_m6.inc similarity index 100% rename from transcoder/basisu_transcoder_tables_bc7_m6.inc rename to basisu/transcoder/basisu_transcoder_tables_bc7_m6.inc diff --git a/transcoder/basisu_transcoder_tables_dxt1_5.inc b/basisu/transcoder/basisu_transcoder_tables_dxt1_5.inc similarity index 100% rename from transcoder/basisu_transcoder_tables_dxt1_5.inc rename to basisu/transcoder/basisu_transcoder_tables_dxt1_5.inc diff --git a/transcoder/basisu_transcoder_tables_dxt1_6.inc b/basisu/transcoder/basisu_transcoder_tables_dxt1_6.inc similarity index 100% rename from transcoder/basisu_transcoder_tables_dxt1_6.inc rename to basisu/transcoder/basisu_transcoder_tables_dxt1_6.inc diff --git a/bin/readme.txt b/bin/readme.txt deleted file mode 100644 index c33ed9f4..00000000 --- a/bin/readme.txt +++ /dev/null @@ -1 +0,0 @@ -executable files go here diff --git a/build_clang.sh b/build_clang.sh deleted file mode 100644 index 91e8a792..00000000 --- a/build_clang.sh +++ /dev/null @@ -1 +0,0 @@ -cmake -D CMAKE_C_COMPILER=/usr/bin/clang -D CMAKE_CXX_COMPILER=/usr/bin/clang++ . diff --git a/tool/CMakeLists.txt b/tool/CMakeLists.txt new file mode 100644 index 00000000..eedbdf29 --- /dev/null +++ b/tool/CMakeLists.txt @@ -0,0 +1,27 @@ +set(BASISU_TOOL_HEADER_FILES + ) +set(BASISU_TOOL_SOURCE_FILES + basisu_tool.cpp + ) +set(BASISU_TOOL_SOURCES + ${BASISU_TOOL_HEADER_FILES} + ${BASISU_TOOL_SOURCE_FILES} + ) + +add_executable(basisuTool ${BASISU_TOOL_SOURCES}) +add_dependencies(basisuTool basisu) + +target_compile_features(basisuTool PUBLIC cxx_std_11) +set_target_properties(basisuTool PROPERTIES + POSITION_INDEPENDENT_CODE ON + FOLDER "basisu" + ) + +target_link_libraries(basisuTool PRIVATE basisu) + +if(BASISU_INSTALL_TOOL) + install(TARGETS basisuTool + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ) +endif() \ No newline at end of file diff --git a/basisu_tool.cpp b/tool/basisu_tool.cpp similarity index 99% rename from basisu_tool.cpp rename to tool/basisu_tool.cpp index 57b68ff9..3e279918 100644 --- a/basisu_tool.cpp +++ b/tool/basisu_tool.cpp @@ -11,17 +11,17 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -#include "transcoder/basisu.h" -#include "transcoder/basisu_transcoder_internal.h" -#include "basisu_enc.h" -#include "basisu_etc.h" -#include "basisu_gpu_texture.h" -#include "basisu_frontend.h" -#include "basisu_backend.h" -#include "transcoder/basisu_global_selector_palette.h" -#include "basisu_comp.h" -#include "transcoder/basisu_transcoder.h" -#include "basisu_ssim.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #if defined(_OPENMP) #include #endif diff --git a/webgl/transcoder/CMakeLists.txt b/webgl/transcoder/CMakeLists.txt index 5e338c62..d189bd2a 100644 --- a/webgl/transcoder/CMakeLists.txt +++ b/webgl/transcoder/CMakeLists.txt @@ -1,19 +1,19 @@ cmake_minimum_required(VERSION 3.0) - project(basisu_transcoder_js) if (EMSCRIPTEN) - set(CMAKE_CXX_STANDARD 11) - - add_executable(basis_transcoder.js - ../../transcoder/basisu_transcoder.cpp - basis_wrappers.cpp - ) - - target_include_directories(basis_transcoder.js PRIVATE ../../transcoder) - - 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 -s MALLOC=emmalloc -DNDEBUG -DBASISD_SUPPORT_BC7=0") + set(CMAKE_CXX_STANDARD 11) + + add_executable(basis_transcoder.js + ../../basisu/transcoder/basisu_transcoder.cpp + basis_wrappers.cpp + ) + + target_include_directories(basis_transcoder.js PRIVATE ../../basisu/transcoder) + + 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 -s MALLOC=emmalloc -DNDEBUG -DBASISD_SUPPORT_BC7=0" + ) endif()