Skip to content

Commit

Permalink
Remove trailing space characters with the formatting script
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronfranke committed Dec 5, 2024
1 parent e4f0721 commit 7ab6e00
Show file tree
Hide file tree
Showing 105 changed files with 3,026 additions and 3,069 deletions.
36 changes: 18 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
# For MSVC builds default to SSE enabled, and determine if it's a 64-bit (-A x64) vs. 32-bit (-A Win32) build.
if (MSVC)
option(SSE "SSE 4.1 support" TRUE)
if ( CMAKE_GENERATOR_PLATFORM STREQUAL Win32 )
if ( CMAKE_GENERATOR_PLATFORM STREQUAL Win32 )
set(BUILD_X64 0)
else()
set(BUILD_X64 1)
Expand Down Expand Up @@ -68,26 +68,26 @@ endif()
if (NOT MSVC)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g")

set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")

if (SAN)
message("Enabling SAN")

set(SANITIZE_FLAGS "-fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined -fno-sanitize=alignment")

set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${SANITIZE_FLAGS}")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${SANITIZE_FLAGS}")

set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${SANITIZE_FLAGS}")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${SANITIZE_FLAGS}")
endif()

set(CMAKE_CXX_FLAGS -std=c++11)
set(GCC_COMPILE_FLAGS "-fvisibility=hidden -fPIC -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-variable -Wno-misleading-indentation -Wno-maybe-uninitialized -Wno-unused-function -Wno-stringop-overflow -Wno-unknown-warning-option")
set(GCC_CXX_COMPILE_FLAGS "-fvisibility=hidden -fPIC -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-variable -Wno-reorder -Wno-misleading-indentation -Wno-class-memaccess -Wno-deprecated-copy -Wno-maybe-uninitialized -Wno-unused-function -Wno-stringop-overflow -Wno-unknown-warning-option")

if (NOT BUILD_X64)
set(GCC_COMPILE_FLAGS "${GCC_COMPILE_FLAGS} -m32")
set(GCC_CXX_COMPILE_FLAGS "${GCC_CXX_COMPILE_FLAGS} -m32")
Expand All @@ -106,7 +106,7 @@ if (NOT MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBASISU_SUPPORT_SSE=0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBASISU_SUPPORT_SSE=0")
endif()

set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_LINK_FLAGS} -static-libgcc -static-libstdc++ -static")
else()
if (SSE)
Expand All @@ -116,7 +116,7 @@ if (NOT MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBASISU_SUPPORT_SSE=0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBASISU_SUPPORT_SSE=0")
endif()

set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_LINK_FLAGS} -Wl,-rpath .")
endif()

Expand Down Expand Up @@ -189,8 +189,8 @@ if (NOT MSVC)
# For Non-Windows builds, let cmake try and find the system OpenCL headers/libs for us.
if (OPENCL AND OPENCL_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBASISU_SUPPORT_OPENCL=1")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBASISU_SUPPORT_OPENCL=1")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBASISU_SUPPORT_OPENCL=1")

target_include_directories(basisu PRIVATE ${OpenCL_INCLUDE_DIRS})
target_include_directories(examples PRIVATE ${OpenCL_INCLUDE_DIRS})
target_include_directories(basisu_encoder PRIVATE ${OpenCL_INCLUDE_DIRS})
Expand All @@ -200,8 +200,8 @@ else()
# For Windows builds, we use our local copies of the OpenCL import lib and Khronos headers.
if (OPENCL)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBASISU_SUPPORT_OPENCL=1")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBASISU_SUPPORT_OPENCL=1")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBASISU_SUPPORT_OPENCL=1")

target_include_directories(basisu PRIVATE "OpenCL")
target_include_directories(examples PRIVATE "OpenCL")
target_include_directories(basisu_encoder PRIVATE "OpenCL")
Expand All @@ -214,7 +214,7 @@ else()
target_link_libraries(examples PRIVATE "${CMAKE_SOURCE_DIR}/OpenCL/lib/OpenCL.lib")
endif()
endif()
endif()
endif()

if (NOT MSVC)
target_link_libraries(basisu PRIVATE m pthread ${BASISU_EXTRA_LIBS})
Expand All @@ -236,19 +236,19 @@ if (NOT EMSCRIPTEN)
endif()

if (MSVC)
set_target_properties(basisu PROPERTIES
set_target_properties(basisu PROPERTIES
RUNTIME_OUTPUT_NAME "basisu"
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
)
set_target_properties(examples PROPERTIES
)

set_target_properties(examples PROPERTIES
RUNTIME_OUTPUT_NAME "examples"
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
)
)
endif()
2 changes: 1 addition & 1 deletion CppProperties.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
"intelliSenseMode": "windows-msvc-x64"
}
]
}
}
20 changes: 10 additions & 10 deletions LICENSES/Apache-2.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ AND DISTRIBUTION

1. Definitions.



"License" shall mean the terms and conditions for use, reproduction, and distribution
as defined by Sections 1 through 9 of this document.



"Licensor" shall mean the copyright owner or entity authorized by the copyright
owner that is granting the License.



"Legal Entity" shall mean the union of the acting entity and all other entities
that control, are controlled by, or are under common control with that entity.
Expand All @@ -26,31 +26,31 @@ or indirect, to cause the direction or management of such entity, whether
by contract or otherwise, or (ii) ownership of fifty percent (50%) or more
of the outstanding shares, or (iii) beneficial ownership of such entity.



"You" (or "Your") shall mean an individual or Legal Entity exercising permissions
granted by this License.



"Source" form shall mean the preferred form for making modifications, including
but not limited to software source code, documentation source, and configuration
files.



"Object" form shall mean any form resulting from mechanical transformation
or translation of a Source form, including but not limited to compiled object
code, generated documentation, and conversions to other media types.



"Work" shall mean the work of authorship, whether in Source or Object form,
made available under the License, as indicated by a copyright notice that
is included in or attached to the work (an example is provided in the Appendix
below).



"Derivative Works" shall mean any work, whether in Source or Object form,
that is based on (or derived from) the Work and for which the editorial revisions,
Expand All @@ -59,7 +59,7 @@ original work of authorship. For the purposes of this License, Derivative
Works shall not include works that remain separable from, or merely link (or
bind by name) to the interfaces of, the Work and Derivative Works thereof.



"Contribution" shall mean any work of authorship, including the original version
of the Work and any modifications or additions to that Work or Derivative
Expand All @@ -74,7 +74,7 @@ for the purpose of discussing and improving the Work, but excluding communicatio
that is conspicuously marked or otherwise designated in writing by the copyright
owner as "Not a Contribution."



"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
of whom a Contribution has been received by Licensor and subsequently incorporated
Expand Down
1 change: 0 additions & 1 deletion OpenCL/CL/cl_d3d10.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,3 @@ typedef cl_int (CL_API_CALL *clEnqueueReleaseD3D10ObjectsKHR_fn)(
#endif

#endif /* __OPENCL_CL_D3D10_H */

1 change: 0 additions & 1 deletion OpenCL/CL/cl_d3d11.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,3 @@ typedef cl_int (CL_API_CALL *clEnqueueReleaseD3D11ObjectsKHR_fn)(
#endif

#endif /* __OPENCL_CL_D3D11_H */

5 changes: 2 additions & 3 deletions OpenCL/CL/cl_dx9_media_sharing.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ extern "C" {

typedef cl_uint cl_dx9_media_adapter_type_khr;
typedef cl_uint cl_dx9_media_adapter_set_khr;

#if defined(_WIN32)
#include <d3d9.h>
typedef struct _cl_dx9_surface_info_khr
Expand Down Expand Up @@ -91,7 +91,7 @@ typedef cl_mem (CL_API_CALL *clCreateFromDX9MediaSurfaceKHR_fn)(
cl_mem_flags flags,
cl_dx9_media_adapter_type_khr adapter_type,
void * surface_info,
cl_uint plane,
cl_uint plane,
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2;

typedef cl_int (CL_API_CALL *clEnqueueAcquireDX9MediaSurfacesKHR_fn)(
Expand Down Expand Up @@ -226,4 +226,3 @@ typedef cl_int (CL_API_CALL *clEnqueueReleaseDX9ObjectsINTEL_fn)(
#endif

#endif /* __OPENCL_CL_DX9_MEDIA_SHARING_H */

2 changes: 1 addition & 1 deletion OpenCL/CL/cl_ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ clEnqueueGenerateMipmapIMG(cl_command_queue command_queue,
cl_uint num_events_in_wait_list,
const cl_event *event_wait_list,
cl_event *event) CL_API_SUFFIX__VERSION_1_2;

/******************************************
* cl_img_mem_properties extension *
******************************************/
Expand Down
2 changes: 1 addition & 1 deletion OpenCL/CL/cl_gl.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ typedef cl_int (CL_API_CALL *clGetGLContextInfoKHR_fn)(
void * param_value,
size_t * param_value_size_ret);

/*
/*
* cl_khr_gl_event extension
*/
#define CL_COMMAND_GL_FENCE_SYNC_OBJECT_KHR 0x200D
Expand Down
1 change: 0 additions & 1 deletion OpenCL/CL/cl_va_api_media_sharing_intel.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,3 @@ typedef cl_int (CL_API_CALL *clEnqueueReleaseVA_APIMediaSurfacesINTEL_fn)(
#endif

#endif /* __OPENCL_CL_VA_API_MEDIA_SHARING_INTEL_H */

3 changes: 1 addition & 2 deletions OpenCL/license.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
These optional files (which are only needed when compiling with OpenCL support enabled in the encoder) are from the
These optional files (which are only needed when compiling with OpenCL support enabled in the encoder) are from the
Khronos Group OpenCL headers github repo. They are Copyright (c) 2008-2020 The Khronos Group Inc.
https://github.com/KhronosGroup/OpenCL-Headers

24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ An LDR/HDR portable GPU compressed texture transcoding system.
Intro
-----

Basis Universal is an open source [supercompressed](http://gamma.cs.unc.edu/GST/gst.pdf) LDR/HDR GPU compressed texture interchange system from Binomial LLC that supports two intermediate file formats: the [.KTX2 open standard from the Khronos Group](https://registry.khronos.org/KTX/specs/2.0/ktxspec.v2.html), and our own ".basis" file format. These file formats support rapid transcoding to virtually any compressed [GPU texture format](https://en.wikipedia.org/wiki/Texture_compression) released in the past ~25 years.
Basis Universal is an open source [supercompressed](http://gamma.cs.unc.edu/GST/gst.pdf) LDR/HDR GPU compressed texture interchange system from Binomial LLC that supports two intermediate file formats: the [.KTX2 open standard from the Khronos Group](https://registry.khronos.org/KTX/specs/2.0/ktxspec.v2.html), and our own ".basis" file format. These file formats support rapid transcoding to virtually any compressed [GPU texture format](https://en.wikipedia.org/wiki/Texture_compression) released in the past ~25 years.

Our overall goal with this project is to simplify the encoding and efficient distribution of *portable* LDR and HDR GPU texture, image, and texture video content in a way that is compatible with any GPU or rendering/graphics API.

Expand All @@ -19,7 +19,7 @@ Links

- [Release Notes](https://github.com/BinomialLLC/basis_universal/wiki/Release-Notes)

- [Live Encoder/Transcoder WebGL Examples](https://subquantumtech.com/uastchdr2/)
- [Live Encoder/Transcoder WebGL Examples](https://subquantumtech.com/uastchdr2/)

- [Javascript API/WASM/WebGL info](https://github.com/BinomialLLC/basis_universal/tree/master/webgl)

Expand Down Expand Up @@ -133,21 +133,21 @@ Compressing and Unpacking .KTX2/.basis Files

Note the .EXR reader we're using is [TinyEXR's](https://github.com/syoyo/tinyexr), which doesn't support all possible .EXR compression modes. Tools like [ImageMagick](https://imagemagick.org/) can be used to create .EXR files that TinyEXR can read.

Alternatively, LDR images (such as .PNG) can be compressed to UASTC HDR by specifying `-hdr`. By default, LDR images, when compressed to UASTC HDR, are first converted from sRGB to linear light before compression. This conversion step can be disabled by specifying `-hdr_ldr_no_srgb_to_linear`.
Alternatively, LDR images (such as .PNG) can be compressed to UASTC HDR by specifying `-hdr`. By default, LDR images, when compressed to UASTC HDR, are first converted from sRGB to linear light before compression. This conversion step can be disabled by specifying `-hdr_ldr_no_srgb_to_linear`.

Importantly, for best quality, you should **supply basisu with original uncompressed source images**. Any other type of lossy compression applied before basisu (including ETC1/BC1-5, BC7, JPEG, etc.) will cause multi-generational artifacts to appear in the final output textures.
Importantly, for best quality, you should **supply basisu with original uncompressed source images**. Any other type of lossy compression applied before basisu (including ETC1/BC1-5, BC7, JPEG, etc.) will cause multi-generational artifacts to appear in the final output textures.

### Some Useful Command Line Options

- `-fastest` (which is equivalent to `-uastc_level 0`) puts the UASTC LDR/HDR encoders in their fastest (but lower quality) modes.
- `-fastest` (which is equivalent to `-uastc_level 0`) puts the UASTC LDR/HDR encoders in their fastest (but lower quality) modes.

- `-slower` puts the UASTC LDR/HDR encoders in higher quality but slower modes (equivalent to `-uastc_level 3`). The default level is 1, and the highest is 4 (which is quite slow).

- `-q X`, where X ranges from [1,255], controls the ETC1S mode's quality vs. file size tradeoff level. 255 is the highest quality, and the default is 128.

- `-debug` causes the encoder to print internal and developer-oriented verbose debug information.

- `-stats` to see various quality (PSNR) statistics.
- `-stats` to see various quality (PSNR) statistics.

- `-linear`: ETC1S defaults to sRGB colorspace metrics, UASTC LDR currently always uses linear metrics, and UASTC HDR defaults to weighted RGB metrics (with 2,3,1 weights). 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. (Angular normal map metrics for UASTC LDR/HDR are definitely doable and on our TODO list.)

Expand All @@ -174,7 +174,7 @@ There are several mipmap options to change the filter kernel, the filter colorsp

`basisu -comp_level 2 x.png`

On some rare images (ones with blue sky gradients come to bind), you may need to increase the ETC1S `-comp_level` setting, which ranges from 1,6. This controls the amount of overall effort the encoder uses to optimize the ETC1S codebooks and the compressed data stream. Higher comp_level's are *significantly* slower.
On some rare images (ones with blue sky gradients come to bind), you may need to increase the ETC1S `-comp_level` setting, which ranges from 1,6. This controls the amount of overall effort the encoder uses to optimize the ETC1S codebooks and the compressed data stream. Higher comp_level's are *significantly* slower.

- To manually set the ETC1S codebook sizes (instead of using -q), with a higher codebook generation level (this is useful with texture video):

Expand All @@ -201,11 +201,11 @@ You can either use the command line tool or [call the transcoder directly](https

`basisu x.ktx2`

Use the `-no_ktx` and `-etc1_only`/`-format_only` options to unpack to less files.
Use the `-no_ktx` and `-etc1_only`/`-format_only` options to unpack to less files.

`-info` and `-validate` will just display file information and not output any files.
`-info` and `-validate` will just display file information and not output any files.

The written mipmapped, cubemap, or texture array .KTX/.DDS files will be in a wide variety of compressed GPU texture formats (PVRTC1 4bpp, ETC1-2, BC1-5, BC7, etc.), and to our knowledge there is unfortunately (as of 2024) still no single .KTX or .DDS 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. [RenderDoc](https://renderdoc.org/) has a useful texture file viewer for many formats. The Mac OSX Finder supports previewing .EXR and .KTX files in various GPU formats. The Windows 11 Explorer can preview .DDS files. The [online OpenHDR Viewer](https://viewer.openhdr.org/) is useful for viewing .EXR/.HDR image files.
The written mipmapped, cubemap, or texture array .KTX/.DDS files will be in a wide variety of compressed GPU texture formats (PVRTC1 4bpp, ETC1-2, BC1-5, BC7, etc.), and to our knowledge there is unfortunately (as of 2024) still no single .KTX or .DDS 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. [RenderDoc](https://renderdoc.org/) has a useful texture file viewer for many formats. The Mac OSX Finder supports previewing .EXR and .KTX files in various GPU formats. The Windows 11 Explorer can preview .DDS files. The [online OpenHDR Viewer](https://viewer.openhdr.org/) is useful for viewing .EXR/.HDR image files.

WebGL Examples
--------------
Expand All @@ -216,10 +216,10 @@ The 'WebGL' directory contains four simple WebGL demos that use the transcoder a
![Screenshot of 'gltf' example running in a browser.](webgl/gltf/preview.png)
![Screenshot of 'encode_test' example running in a browser.](webgl/ktx2_encode_test/preview.png)

Building the WASM Modules with [Emscripten](https://emscripten.org/)
Building the WASM Modules with [Emscripten](https://emscripten.org/)
--------------------------------------------------------------------

Both the transcoder and encoder may be compiled using emscripten to WebAssembly and used on the web. A set of JavaScript wrappers to the codec, written in C++ with emscripten extensions, is located in `webgl/transcoding/basis_wrappers.cpp`. The JavaScript wrapper supports nearly all features and modes, including texture video. See the README.md and CMakeLists.txt files in `webgl/transcoder` and `webgl/encoder`.
Both the transcoder and encoder may be compiled using emscripten to WebAssembly and used on the web. A set of JavaScript wrappers to the codec, written in C++ with emscripten extensions, is located in `webgl/transcoding/basis_wrappers.cpp`. The JavaScript wrapper supports nearly all features and modes, including texture video. See the README.md and CMakeLists.txt files in `webgl/transcoder` and `webgl/encoder`.

To build the WASM transcoder, after installing emscripten:

Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---

image:
image:
- macos
- Ubuntu2004
- Visual Studio 2019
Expand Down
1 change: 0 additions & 1 deletion basisu.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@
</windowsSettings>
</application>
</assembly>

4 changes: 2 additions & 2 deletions basisu.vcxproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
Expand Down Expand Up @@ -187,4 +187,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
Loading

0 comments on commit 7ab6e00

Please sign in to comment.