mirror of
https://github.com/KhronosGroup/KTX-Software.git
synced 2026-01-18 17:41:19 +01:00
Create libktx project (#1071)
Move the libktx build from the root CMakeLists.txt to its own in the `lib` directory. Although still within KTX-Software, the new libktx project `CMakeLists.txt` can be used as either a sub-project of KTX-Software or as a standalone project to build just libktx. This has been done due to both direct requests, such as https://github.com/KhronosGroup/KTX-Software/discussions/995 and indirect requests such as complaints that the root CMakeLists is too complicated. The effort has led to some useful cleanup and better modularization. The following FEATURE options have been moved to the libktx project and consequently renamed with a `LIBKTX` prefix: - LIBKTX_FEATURE_KTX1 - LIBKTX_FEATURE_KTX2 - LIBKTX_FEATURE_VK_UPLOAD - LIBKTX_FEATURE_GL_UPLOAD - LIBKTX_FEATURE_ETC_UNPACK These options have been duplicated in the libktx project so they can be set when it is the top-level project: - LIBKTX_EMBED_BITCODE - LIBKTX_WERROR When libktx is used as a sub-project, they are set from the similarly named KTX-Software options. Add a workflow to test configuring and building a standalone libktx. Along the way, fixed a bug, that caused configurations in the linux.yml workflow that were supposed to incorporate OpenCL to not do so. However it is not possible to run the tests on those configurations as the Actions runners report the cpu type as "generic" so Portable OpenCL (POCL) can't figure out what to do. Also along the way, update the ignore lists in all the workflow files to include newer workflows files.
This commit is contained in:
6
.github/workflows/android.yml
vendored
6
.github/workflows/android.yml
vendored
@@ -19,11 +19,17 @@ on:
|
||||
- 'v[0-9]+.[0-9]+.[0-9]+-*'
|
||||
paths-ignore:
|
||||
- .appveyor.yml
|
||||
- .github/workflows/check-libktx-only.yml
|
||||
- .github/workflows/check-mkvk.yml
|
||||
- .github/workflows/check-reuse.yml
|
||||
- .github/workflows/docs.yml
|
||||
- .github/workflows/formatting.yml
|
||||
- .github/workflows/macos.yml
|
||||
- .github/workflows/linux.yml
|
||||
- .github/workflows/mingw.yml
|
||||
- .github/workflows/publish-pyktx.yml
|
||||
- .github/workflows/manual.yml
|
||||
- .github/workflows/web.yml
|
||||
- .github/workflows/windows.yml
|
||||
- .travis.yml
|
||||
- README.md
|
||||
|
||||
42
.github/workflows/check-libktx-only.yml
vendored
42
.github/workflows/check-libktx-only.yml
vendored
@@ -2,6 +2,11 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
name: Check config and build of just libktx
|
||||
|
||||
# The purpose of this is to smoke test building just libktx using its
|
||||
# CMakeLists.txt as the top-level project. Testing of various build
|
||||
# options and running of tests on the library is left to the various
|
||||
# KTX-Software project workflows.
|
||||
|
||||
# Seems no way to avoid duplicating this on logic in each .yml file.
|
||||
# See https://github.com/actions/starter-workflows/issues/245.
|
||||
on:
|
||||
@@ -45,17 +50,31 @@ on:
|
||||
|
||||
# Allow manual trigger
|
||||
workflow_dispatch:
|
||||
workflow_call:
|
||||
|
||||
jobs:
|
||||
check-mkvk:
|
||||
check-libktx-only:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ macos-latest, ubuntu-latest, windows-latest ]
|
||||
config: [ Release ]
|
||||
generator: [ 'Ninja Multi-Config' ]
|
||||
exclude:
|
||||
- os: windows-latest
|
||||
generator: 'Ninja Multi-Config'
|
||||
include:
|
||||
# The NMC generator defaults to using GCC and GCC names dlls with
|
||||
# a "lib" prefix and the import files with both the prefix and a
|
||||
# ".dll.a" extension. I have neither the time nor energy to find out
|
||||
# how to change the behaviour. Use VS.
|
||||
- os: windows-latest
|
||||
generator: 'Visual Studio 17 2022'
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
env:
|
||||
GIT_LFS_SKIP_SMUDGE: 1
|
||||
BUILD_DIR: "build"
|
||||
SOURCE_DIR: "lib"
|
||||
WERROR: ON
|
||||
|
||||
steps:
|
||||
@@ -66,19 +85,28 @@ jobs:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Configure CMake build
|
||||
run: cmake -B ${{ env.BUILD_DIR }} -DLIBKTX_WERROR=${{ env.WERROR }}
|
||||
run: cmake -S ${{ env.SOURCE_DIR }} -B ${{ env.BUILD_DIR }} -G "${{ matrix.generator }}" -DLIBKTX_WERROR=${{ env.WERROR }}
|
||||
- name: Build libktx
|
||||
run: cmake --build ${{ env.BUILD_DIR }} --config=Release
|
||||
|
||||
- name: Prepare version for artifact
|
||||
id: ktx-version
|
||||
- name: Prepare version number and architecture for artifact
|
||||
id: libktx-version
|
||||
shell: bash
|
||||
# Arch set up is to match arch to names used in releases and platforms.
|
||||
# N.B. If `>> ${{ github.env }} is used here variables are not seen in
|
||||
# following step on Windows runners. Linux and macOS have no problem.
|
||||
run: |
|
||||
KTX_VERSION=`cat $BUILD_DIR/ktx.version`
|
||||
echo KTX_VERSION=$(cat ${{ env.BUILD_DIR }}) >> ${{ env.GITHUB_ENV }}
|
||||
echo KTX_VERSION=$(grep -A 1 -m 1 "Code version" lib/src/version.h | tail -n 1) >> $GITHUB_ENV
|
||||
arch=$(echo ${{ runner.arch }} | tr '[:upper:]' '[:lower:]')
|
||||
if [ "$arch" = "x64" ]; then arch=x86_64; fi
|
||||
echo ARCH=$arch >> $GITHUB_ENV
|
||||
|
||||
- name: Check output directory content
|
||||
run: scripts/check_lib_build_output.sh ${{ env.BUILD_DIR }}/${{ matrix.config }}
|
||||
|
||||
- name: Upload artifact libktx
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: libktx-${{ env.KTX_VERSION }}
|
||||
name: libktx-${{ env.KTX_VERSION }}-${{ runner.os }}-${{ env.ARCH }}
|
||||
path: ${{env.BUILD_DIR}}/Release/*ktx*
|
||||
|
||||
|
||||
7
.github/workflows/check-mkvk.yml
vendored
7
.github/workflows/check-mkvk.yml
vendored
@@ -19,10 +19,17 @@ on:
|
||||
- 'v[0-9]+.[0-9]+.[0-9]+-*'
|
||||
paths-ignore:
|
||||
- .appveyor.yml
|
||||
- .github/workflows/android.yml
|
||||
- .github/workflows/check-libktx-only.yml
|
||||
- .github/workflows/check-reuse.yml
|
||||
- .github/workflows/docs.yml
|
||||
- .github/workflows/formatting.yml
|
||||
- .github/workflows/macos.yml
|
||||
- .github/workflows/linux.yml
|
||||
- .github/workflows/mingw.yml
|
||||
- .github/workflows/publish-pyktx.yml
|
||||
- .github/workflows/manual.yml
|
||||
- .github/workflows/web.yml
|
||||
- .github/workflows/windows.yml
|
||||
- .travis.yml
|
||||
- README.md
|
||||
|
||||
6
.github/workflows/docs.yml
vendored
6
.github/workflows/docs.yml
vendored
@@ -33,10 +33,16 @@ on:
|
||||
paths-ignore:
|
||||
- .appveyor.yml
|
||||
- .github/workflows/android.yml
|
||||
- .github/workflows/check-libktx-only.yml
|
||||
- .github/workflows/check-mkvk.yml
|
||||
- .github/workflows/check-reuse.yml
|
||||
- .github/workflows/formatting.yml
|
||||
- .github/workflows/linux.yml
|
||||
- .github/workflows/macos.yml
|
||||
- .github/workflows/mingw.yml
|
||||
- .github/workflows/publish-pyktx.yml
|
||||
- .github/workflows/manual.yml
|
||||
- .github/workflows/web.yml
|
||||
- .github/workflows/windows.yml
|
||||
- .travis.yml
|
||||
- README.md
|
||||
|
||||
20
.github/workflows/linux.yml
vendored
20
.github/workflows/linux.yml
vendored
@@ -20,10 +20,15 @@ on:
|
||||
paths-ignore:
|
||||
- .appveyor.yml
|
||||
- .github/workflows/android.yml
|
||||
- .github/workflows/check-libktx-only.yml
|
||||
- .github/workflows/check-mkvk.yml
|
||||
- .github/workflows/docs.yml
|
||||
- .github/workflows/formatting.yml
|
||||
- .github/workflows/mingw.yml
|
||||
- .github/workflows/macos.yml
|
||||
- .github/workflows/publish-pyktx.yml
|
||||
- .github/workflows/manual.yml
|
||||
- .github/workflows/web.yml
|
||||
- .github/workflows/windows.yml
|
||||
- .travis.yml
|
||||
- README.md
|
||||
@@ -96,6 +101,9 @@ jobs:
|
||||
doc: ON, jni: ON, loadtests: OpenGL, py: ON, tools: ON, tools_cts: ON,
|
||||
package: YES, sse: OFF, opencl: OFF
|
||||
}
|
||||
# Can't run OpenCL on Actions because the runner CPU reports as
|
||||
# "generic" so POCL (the only OpenCL CPU driver) can't figure out
|
||||
# which code to use. Disable tests, just check building.
|
||||
- name: OpenCL,SSE
|
||||
os: ubuntu-22.04
|
||||
generator: Ninja
|
||||
@@ -104,8 +112,8 @@ jobs:
|
||||
vk_sdk_ver: '1.4.313'
|
||||
options: {
|
||||
config: Release,
|
||||
doc: OFF, jni: OFF, loadtests: OFF, py: OFF, tools: OFF, tools_cts: OFF,
|
||||
sse: ON, opencl: ON
|
||||
doc: OFF, jni: OFF, loadtests: OFF, py: OFF, tests: OFF, tools: OFF,
|
||||
tools_cts: OFF, sse: ON, opencl: ON
|
||||
}
|
||||
- name: OpenCL
|
||||
os: ubuntu-22.04
|
||||
@@ -115,8 +123,8 @@ jobs:
|
||||
vk_sdk_ver: '1.4.313'
|
||||
options: {
|
||||
config: Release,
|
||||
doc: OFF, jni: OFF, loadtests: OFF, py: OFF, tools: OFF, tools_cts: OFF,
|
||||
sse: OFF, opencl: ON
|
||||
doc: OFF, jni: OFF, loadtests: OFF, py: OFF, tests: OFF, tools: OFF,
|
||||
tools_cts: OFF, sse: OFF, opencl: ON
|
||||
}
|
||||
- name: All OFF
|
||||
os: ubuntu-22.04
|
||||
@@ -155,8 +163,8 @@ jobs:
|
||||
FEATURE_TOOLS: ${{ matrix.options.tools }}
|
||||
FEATURE_TOOLS_CTS: ${{ matrix.options.tools_cts }}
|
||||
PACKAGE: ${{ matrix.options.package && matrix.options.package || 'NO' }}
|
||||
SUPPORT_OPENCL: ${{ matrix.options.opencl }}
|
||||
SUPPORT_SSE: ${{ matrix.options.sse }}
|
||||
SUPPORT_OPENCL: ${{ matrix.options.opencl && matrix.options.opencl || 'OFF' }}
|
||||
SUPPORT_SSE: ${{ matrix.options.sse && matrix.options.sse || 'OFF' }}
|
||||
PY_USE_VENV: ${{ matrix.options.py.use_venv && matrix.options.py_use_venv || 'OFF' }}
|
||||
WERROR: ${{ matrix.options.werror && matrix.options.werror || 'ON' }}
|
||||
# CC Handled by job step
|
||||
|
||||
6
.github/workflows/macos.yml
vendored
6
.github/workflows/macos.yml
vendored
@@ -20,10 +20,16 @@ on:
|
||||
paths-ignore:
|
||||
- .appveyor.yml
|
||||
- .github/workflows/android.yml
|
||||
- .github/workflows/check-libktx-only.yml
|
||||
- .github/workflows/check-mkvk.yml
|
||||
- .github/workflows/check-reuse.yml
|
||||
- .github/workflows/docs.yml
|
||||
- .github/workflows/formatting.yml
|
||||
- .github/workflows/linux.yml
|
||||
- .github/workflows/mingw.yml
|
||||
- .github/workflows/publish-pyktx.yml
|
||||
- .github/workflows/manual.yml
|
||||
- .github/workflows/web.yml
|
||||
- .github/workflows/windows.yml
|
||||
- .travis.yml
|
||||
- README.md
|
||||
|
||||
6
.github/workflows/manual.yml
vendored
6
.github/workflows/manual.yml
vendored
@@ -8,6 +8,8 @@ on:
|
||||
jobs:
|
||||
android:
|
||||
uses: ./.github/workflows/android.yml
|
||||
libktx-only:
|
||||
uses: ./.github/workflows/check-libktx-only.yml
|
||||
linux:
|
||||
uses: ./.github/workflows/linux.yml
|
||||
macos:
|
||||
@@ -20,7 +22,7 @@ jobs:
|
||||
uses: ./.github/workflows/windows.yml
|
||||
|
||||
all:
|
||||
needs: [android, linux, macos, mingw, web, windows]
|
||||
needs: [android, libktx-only, linux, macos, mingw, web, windows]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- run: exit 0
|
||||
- run: exit 0
|
||||
|
||||
5
.github/workflows/mingw.yml
vendored
5
.github/workflows/mingw.yml
vendored
@@ -20,10 +20,15 @@ on:
|
||||
paths-ignore:
|
||||
- .appveyor.yml
|
||||
- .github/workflows/android.yml
|
||||
- .github/workflows/check-libktx-only.yml
|
||||
- .github/workflows/check-mkvk.yml
|
||||
- .github/workflows/docs.yml
|
||||
- .github/workflows/formatting.yml
|
||||
- .github/workflows/linux.yml
|
||||
- .github/workflows/macos.yml
|
||||
- .github/workflows/publish-pyktx.yml
|
||||
- .github/workflows/manual.yml
|
||||
- .github/workflows/web.yml
|
||||
- .github/workflows/windows.yml
|
||||
- .travis.yml
|
||||
- README.md
|
||||
|
||||
6
.github/workflows/web.yml
vendored
6
.github/workflows/web.yml
vendored
@@ -20,10 +20,16 @@ on:
|
||||
paths-ignore:
|
||||
- .appveyor.yml
|
||||
- .github/workflows/android.yml
|
||||
- .github/workflows/check-libktx-only.yml
|
||||
- .github/workflows/check-mkvk.yml
|
||||
- .github/workflows/check-reuse.yml
|
||||
- .github/workflows/docs.yml
|
||||
- .github/workflows/formatting.yml
|
||||
- .github/workflows/macos.yml
|
||||
- .github/workflows/linux.yml
|
||||
- .github/workflows/mingw.yml
|
||||
- .github/workflows/publish-pyktx.yml
|
||||
- .github/workflows/manual.yml
|
||||
- .github/workflows/windows.yml
|
||||
- .travis.yml
|
||||
- README.md
|
||||
|
||||
7
.github/workflows/windows.yml
vendored
7
.github/workflows/windows.yml
vendored
@@ -20,10 +20,17 @@ on:
|
||||
paths-ignore:
|
||||
- .appveyor.yml
|
||||
- .github/workflows/android.yml
|
||||
- .github/workflows/check-libktx-only.yml
|
||||
- .github/workflows/check-mkvk.yml
|
||||
- .github/workflows/check-reuse.yml
|
||||
- .github/workflows/docs.yml
|
||||
- .github/workflows/formatting.yml
|
||||
- .github/workflows/macos.yml
|
||||
- .github/workflows/linux.yml
|
||||
- .github/workflows/mingw.yml
|
||||
- .github/workflows/publish-pyktx.yml
|
||||
- .github/workflows/manual.yml
|
||||
- .github/workflows/web.yml
|
||||
- .travis.yml
|
||||
- README.md
|
||||
- CODE_OF_CONDUCT.md
|
||||
|
||||
9
.gitignore
vendored
9
.gitignore
vendored
@@ -6,16 +6,13 @@
|
||||
*~
|
||||
*.bak
|
||||
|
||||
/CMakeUserPresets.json
|
||||
/build*/
|
||||
/install*/
|
||||
CMakeUserPresets.json
|
||||
build*/
|
||||
install*/
|
||||
|
||||
# /include/
|
||||
/include/imdebug.h
|
||||
|
||||
# /lib/
|
||||
/lib/src
|
||||
|
||||
# /external/
|
||||
/external/astc-encoder/.gitmodules
|
||||
/external/astc-encoder/Source/GoogleTest
|
||||
|
||||
113
BUILDING.md
113
BUILDING.md
@@ -23,7 +23,61 @@ Supported platforms (please see their specific requirements first)
|
||||
- [Windows](#windows)
|
||||
- [Android](#android)
|
||||
|
||||
The minimal way to a build is to clone this repository and run the following in a terminal
|
||||
The minimal way to a build is to clone this repository and follow the instructions for your desired build below.
|
||||
|
||||
_libktx_ only
|
||||
-------------
|
||||
To build only _libktx_ and nothing else, run the following in a terminal
|
||||
|
||||
```bash
|
||||
# Navigate to the `lib` directory of your KTX-Software clone (replace with
|
||||
# your actual path)
|
||||
cd /path/to/KTX-Software/lib
|
||||
|
||||
# This generates build/project files in the clone's `lib/build` subfolder
|
||||
cmake . -B build
|
||||
|
||||
# Compile the project
|
||||
cmake --build build
|
||||
```
|
||||
|
||||
If you need the library to be static, add `-D BUILD_SHARED_LIBS=OFF` to the CMake configure command (always disabled on iOS and Emscripten).
|
||||
|
||||
> **Note:**
|
||||
>
|
||||
> When linking to the static library, make sure to
|
||||
> define `KHRONOS_STATIC` before including KTX header files.
|
||||
> This is especially important on Windows.
|
||||
|
||||
If you want the Basis Universal encoders in `libktx` to use OpenCL
|
||||
add `-D BASISU_SUPPORT_OPENCL=ON` to the CMake configure command. In this case
|
||||
you must have an OpenCL development environment installed on the build machine
|
||||
and a driver on the run-time machine.
|
||||
|
||||
> **Note:**
|
||||
>
|
||||
> There is very little advantage to using OpenCL in the context
|
||||
> of `libktx`. It is disabled in the default build configuration.
|
||||
|
||||
> **Note:**
|
||||
>
|
||||
> When building from a source `tar.gz` and not from the git repository directly,
|
||||
> it is recommended to set the variable `KTX_GIT_VERSION_FULL` to the
|
||||
> associated git tag (e.g `v4.3.2`)
|
||||
>
|
||||
> ```bash
|
||||
> cmake . -G Ninja -B build -DKTX_GIT_VERSION_FULL=v4.3.2
|
||||
> ```
|
||||
> Use with caution.
|
||||
|
||||
The information below about signing on iOS, macOS and Windows applies to library only and complete builds.
|
||||
|
||||
The only dependencies beyond the build tools are for the build machine to have a
|
||||
[bash](#bash) shell and, if using OpenCL, the mentioned OpenCL development
|
||||
environment.
|
||||
|
||||
The complete project
|
||||
--------------------
|
||||
|
||||
```bash
|
||||
# Navigate to the root of your KTX-Software clone (replace with
|
||||
@@ -43,39 +97,15 @@ This creates the `libktx` library and the command line tools. To create the comp
|
||||
cmake . -B build -D KTX_FEATURE_LOADTEST_APPS=ON -D KTX_FEATURE_DOC=ON
|
||||
```
|
||||
|
||||
If you need the library to be static, add `-D BUILD_SHARED_LIBS=OFF` to the CMake configure command (always disabled on iOS and Emscripten).
|
||||
|
||||
> **Note:**
|
||||
>
|
||||
> When linking to the static library, make sure to
|
||||
> define `KHRONOS_STATIC` before including KTX header files.
|
||||
> This is especially important on Windows.
|
||||
The library build notes and the note about `KTX_GIT_VERSION_FULL` above apply
|
||||
here too.
|
||||
|
||||
If you want to run the CTS tests (recommended only during KTX development)
|
||||
add `-D KTX_FEATURE_TOOLS_CTS=ON` to the CMake configure command and fetch
|
||||
the CTS submodule. For more information see [Conformance Test Suite](#conformance-test-suite).
|
||||
|
||||
If you want the Basis Universal encoders in `libktx` to use OpenCL
|
||||
add `-D BASISU_SUPPORT_OPENCL=ON` to the CMake configure command.
|
||||
|
||||
> **Note:**
|
||||
>
|
||||
> There is very little advantage to using OpenCL in the context
|
||||
> of `libktx`. It is disabled in the default build configuration.
|
||||
|
||||
> **Note:**
|
||||
>
|
||||
> When building from a source `tar.gz` and not from the git repository directly,
|
||||
> it is recommended to set the variable `KTX_GIT_VERSION_FULL` to the
|
||||
> associated git tag (e.g `v4.3.2`)
|
||||
>
|
||||
> ```bash
|
||||
> cmake . -G Ninja -B build -DKTX_GIT_VERSION_FULL=v4.3.2
|
||||
> ```
|
||||
> Use with caution.
|
||||
|
||||
Building
|
||||
--------
|
||||
Detailed Build and Dependency Notes
|
||||
-----------------------------------
|
||||
|
||||
### GNU/Linux
|
||||
|
||||
@@ -95,10 +125,10 @@ OpenCL you need
|
||||
On Ubuntu and Debian these can be installed via
|
||||
|
||||
```bash
|
||||
sudo apt install build-essential cmake libzstd-dev ninja-build doxygen graphviz opencl-c-headers mesa-opencl-icd
|
||||
sudo apt install build-essential cmake libzstd-dev ninja-build doxygen graphviz opencl-c-headers ocl-icd-opencl-dev mesa-opencl-icd
|
||||
```
|
||||
|
||||
`mesa-opencl-icd` should be replaced by the appropriate package for your GPU.
|
||||
`mesa-opencl-icd` should be replaced by the appropriate package for your GPU or with the Portable OpenCL: `pocl-opencl-icd libpocl-dev`.
|
||||
|
||||
On Fedora and RedHat these can be installed via
|
||||
|
||||
@@ -539,23 +569,24 @@ All but a few project developers can ignore this section. The files discussed he
|
||||
|
||||
The following files related to the the VkFormat enum are generated from `vulkan_core.h`:
|
||||
|
||||
- lib/vkformat_check.c
|
||||
- lib/vkformat_enum.h
|
||||
- lib/vkformat_list.inl
|
||||
- lib/vkformat_str.c
|
||||
- lib/vkformat_typesize.c
|
||||
- lib/dfd/dfd2vk.inl
|
||||
- lib/dfd/vk2dfd.inl
|
||||
- lib/src/vkformat_check.c
|
||||
- lib/src/vkformat_enum.h
|
||||
- lib/src/vkformat_list.inl
|
||||
- lib/src/vkformat_str.c
|
||||
- lib/src/vkformat_typesize.c
|
||||
- external/dfdutils/dfd2vk.inl
|
||||
- external/dfdutils/vk2dfd.inl
|
||||
- interface/java\_binding/src/main/java/org/khronos/ktxVkFormat.java
|
||||
- interface/python\_binding/pyktx/vk\_format.py
|
||||
- interface/js\_binding/vk\_format.inl
|
||||
- tests/unittests/vkformat\_list.inl
|
||||
|
||||
|
||||
The following files are generated from the mapping database in the KTX-Specification repo by `generate_format_switches.rb`:
|
||||
|
||||
- lib/vkFormat2glFormat.inl
|
||||
- lib/vkFormat2glInternalFormat.inl
|
||||
- lib/vkFormat2glType.inl
|
||||
- lib/src/vkFormat2glFormat.inl
|
||||
- lib/src/vkFormat2glInternalFormat.inl
|
||||
- lib/src/vkFormat2glType.inl
|
||||
|
||||
All are generated by the `mkvk` target which is only configured if `KTX_GENERATE_VK_FILES` is set to `ON` at the time of CMake configuration. Since this setting is labelled *Advanced* it will not be visible in the CMake GUI unless `Advanced` is set.
|
||||
|
||||
|
||||
1079
CMakeLists.txt
1079
CMakeLists.txt
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,85 @@
|
||||
# Copyright 2020 Andreas Atteneder
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# Config options for code signing
|
||||
|
||||
if(APPLE)
|
||||
# Signing
|
||||
set(XCODE_CODE_SIGN_IDENTITY "Development" CACHE STRING "Xcode code sign ID")
|
||||
set(XCODE_DEVELOPMENT_TEAM "" CACHE STRING "Xcode development team ID")
|
||||
set(PRODUCTBUILD_IDENTITY_NAME "" CACHE STRING "productbuild identity name")
|
||||
set(PRODUCTBUILD_KEYCHAIN_PATH "" CACHE FILEPATH "pkgbuild keychain file")
|
||||
if(APPLE_LOCKED_OS)
|
||||
set(XCODE_PROVISIONING_PROFILE_SPECIFIER "" CACHE STRING "Xcode provisioning profile specifier")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.18.0")
|
||||
include(KtxDependentVariable)
|
||||
# Signing
|
||||
set(CODE_SIGN_KEY_VAULT "" CACHE STRING "Name of the vault to search for signing certificate. Enables related code signing variables when set.")
|
||||
set_property(CACHE CODE_SIGN_KEY_VAULT
|
||||
PROPERTY STRINGS "" Azure Machine User)
|
||||
|
||||
# Common signing variables
|
||||
KTX_DEPENDENT_VARIABLE( CODE_SIGN_TIMESTAMP_URL STRING
|
||||
"URL of timestamp server for code signing. Signed code should be timestamped so the signature will remain valid even after the certificate expires."
|
||||
""
|
||||
"CODE_SIGN_KEY_VAULT"
|
||||
""
|
||||
)
|
||||
# Variables for signing with local certificate.
|
||||
KTX_DEPENDENT_VARIABLE( LOCAL_KEY_VAULT_SIGNING_IDENTITY STRING
|
||||
"Subject Name of Windows code signing certificate. Displayed in 'Issued To' field of cert{lm,mgr}. Overriden by LOCAL_KEY_VAULT_CERTIFICATE_THUMBPRINT."
|
||||
""
|
||||
"CODE_SIGN_KEY_VAULT;${CODE_SIGN_KEY_VAULT} MATCHES Machine OR ${CODE_SIGN_KEY_VAULT} MATCHES User"
|
||||
""
|
||||
)
|
||||
KTX_DEPENDENT_VARIABLE( LOCAL_KEY_VAULT_CERTIFICATE_THUMBPRINT STRING
|
||||
"Thumbprint of the certificate to use. Use this instead of LOCAL_KEY_VAULT_SIGNING_IDENTITY when you have multiple certificates with the same identity. Overrides LOCAL_KEY_VAULT_SIGNING_IDENTITY."
|
||||
""
|
||||
"CODE_SIGN_KEY_VAULT;${CODE_SIGN_KEY_VAULT} MATCHES Machine OR ${CODE_SIGN_KEY_VAULT} MATCHES User"
|
||||
""
|
||||
)
|
||||
|
||||
# Variables for signing with certificate from Azure
|
||||
KTX_DEPENDENT_VARIABLE( AZURE_KEY_VAULT_URL STRING
|
||||
"The URL of your Azure key vault."
|
||||
""
|
||||
"CODE_SIGN_KEY_VAULT;${CODE_SIGN_KEY_VAULT} MATCHES Azure"
|
||||
""
|
||||
)
|
||||
KTX_DEPENDENT_VARIABLE( AZURE_KEY_VAULT_CERTIFICATE STRING
|
||||
"The name of the certificate in Azure Key Vault."
|
||||
""
|
||||
"CODE_SIGN_KEY_VAULT;${CODE_SIGN_KEY_VAULT} MATCHES Azure"
|
||||
""
|
||||
)
|
||||
KTX_DEPENDENT_VARIABLE( AZURE_KEY_VAULT_CLIENT_ID STRING
|
||||
"The id of an application (Client) registered with Azure that has permission to access the certificate."
|
||||
""
|
||||
"CODE_SIGN_KEY_VAULT;${CODE_SIGN_KEY_VAULT} MATCHES Azure"
|
||||
""
|
||||
)
|
||||
KTX_DEPENDENT_VARIABLE( AZURE_KEY_VAULT_TENANT_ID STRING
|
||||
"The id of the Azure Active Directory (Tenant) holding the Client."
|
||||
""
|
||||
"CODE_SIGN_KEY_VAULT;${CODE_SIGN_KEY_VAULT} MATCHES Azure"
|
||||
""
|
||||
)
|
||||
KTX_DEPENDENT_VARIABLE( AZURE_KEY_VAULT_CLIENT_SECRET STRING
|
||||
"The secret to authenticate access to the Client."
|
||||
""
|
||||
"CODE_SIGN_KEY_VAULT;${CODE_SIGN_KEY_VAULT} MATCHES Azure"
|
||||
""
|
||||
)
|
||||
else()
|
||||
# KTX_DEPENDENT_VARIABLE won't work. Force disable signing.
|
||||
unset(CODE_SIGN_KEY_VAULT CACHE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Macro for setting up code signing on targets
|
||||
macro (set_code_sign target)
|
||||
if(APPLE)
|
||||
|
||||
@@ -80,7 +80,7 @@ function( CreateDocLibKTX )
|
||||
set( DOXYGEN_TYPEDEF_HIDES_STRUCT NO )
|
||||
set( DOXYGEN_EXCLUDE lib/uthash.h )
|
||||
set( DOXYGEN_EXCLUDE_PATTERNS ktxint.h )
|
||||
set( DOXYGEN_EXAMPLE_PATH examples lib )
|
||||
set( DOXYGEN_EXAMPLE_PATH examples lib/src )
|
||||
# This does not hide the scope (class) names in the Modules list
|
||||
# in the ToC. See https://github.com/doxygen/doxygen/issues/9921.
|
||||
set( DOXYGEN_HIDE_SCOPE_NAMES YES )
|
||||
@@ -126,23 +126,23 @@ function( CreateDocLibKTX )
|
||||
doxygen_add_docs(
|
||||
libktx.doc
|
||||
lib/libktx_mainpage.md
|
||||
include
|
||||
lib/astc_codec.cpp
|
||||
lib/basis_encode.cpp
|
||||
lib/basis_transcode.cpp
|
||||
lib/miniz_wrapper.cpp
|
||||
lib/strings.c
|
||||
lib/gl_funcs.c
|
||||
lib/glloader.c
|
||||
lib/hashlist.c
|
||||
lib/filestream.c
|
||||
lib/memstream.c
|
||||
lib/texture.c
|
||||
lib/texture1.c
|
||||
lib/texture2.c
|
||||
lib/vkloader.c
|
||||
lib/writer1.c
|
||||
lib/writer2.c
|
||||
lib/include
|
||||
lib/src/astc_codec.cpp
|
||||
lib/src/basis_encode.cpp
|
||||
lib/src/basis_transcode.cpp
|
||||
lib/src/miniz_wrapper.cpp
|
||||
lib/src/strings.c
|
||||
lib/src/gl_funcs.c
|
||||
lib/src/glloader.c
|
||||
lib/src/hashlist.c
|
||||
lib/src/filestream.c
|
||||
lib/src/memstream.c
|
||||
lib/src/texture.c
|
||||
lib/src/texture1.c
|
||||
lib/src/texture2.c
|
||||
lib/src/vkloader.c
|
||||
lib/src/writer1.c
|
||||
lib/src/writer2.c
|
||||
)
|
||||
add_docs_cmake_plus( libktx.doc pkgdoc/libktxDoxyLayout.xml )
|
||||
endfunction()
|
||||
@@ -220,7 +220,7 @@ function( CreateDocKTX )
|
||||
set( DOXYGEN_LAYOUT_FILE pkgdoc/packageDoxyLayout.xml )
|
||||
set( DOXYGEN_EXCLUDE lib/uthash.h )
|
||||
set( DOXYGEN_EXCLUDE_PATTERNS ktxint.h )
|
||||
set( DOXYGEN_EXAMPLE_PATH lib )
|
||||
set( DOXYGEN_EXAMPLE_PATH lib/src )
|
||||
set( DOXYGEN_GENERATE_TAGFILE ${docdest}/ktxpkg.tag )
|
||||
set( DOXYGEN_HTML_HEADER pkgdoc/header.html )
|
||||
set( DOXYGEN_HTML_OUTPUT . )
|
||||
|
||||
@@ -16,6 +16,14 @@
|
||||
# this. Since only project developers need to use these targets, and
|
||||
# only occasionally, this misfeature can be tolerated.
|
||||
|
||||
set(dfdutils "${PROJECT_SOURCE_DIR}/external/dfdutils")
|
||||
set(java_binding "${PROJECT_SOURCE_DIR}/interface/java_binding")
|
||||
set(js_binding "${PROJECT_SOURCE_DIR}/interface/js_binding")
|
||||
set(lib_src "${PROJECT_SOURCE_DIR}/lib/src")
|
||||
set(python_binding "${PROJECT_SOURCE_DIR}/interface/python_binding")
|
||||
set(scripts "${PROJECT_SOURCE_DIR}/scripts")
|
||||
set(unittests "${PROJECT_SOURCE_DIR}/tests/unittests")
|
||||
|
||||
if (NOT IOS AND NOT ANDROID)
|
||||
# Not needed as local custom vulkan_core.h is used. Keeping
|
||||
# in case we go back to the standard one.
|
||||
@@ -26,7 +34,7 @@ if (NOT IOS AND NOT ANDROID)
|
||||
# This cmake file is included from its parent so has the same scope as
|
||||
# the including file. If we change Vulkan_INCLUDE_DIR, other parts will
|
||||
# be affected.
|
||||
set(mkvk_vulkan_include_dir external/dfdutils)
|
||||
set(mkvk_vulkan_include_dir "${dfdutils}")
|
||||
else()
|
||||
# Skip mkvk. There is no need to use iOS or Android to regenerate
|
||||
# the files.
|
||||
@@ -78,16 +86,16 @@ endif()
|
||||
|
||||
list(APPEND mkvkformatfiles_input
|
||||
${vulkan_header}
|
||||
scripts/mkvkformatfiles)
|
||||
${scripts}/mkvkformatfiles)
|
||||
list(APPEND mkvkformatfiles_output
|
||||
"${PROJECT_SOURCE_DIR}/interface/java_binding/src/main/java/org/khronos/ktx/VkFormat.java"
|
||||
"${PROJECT_SOURCE_DIR}/interface/js_binding/vk_format.inl"
|
||||
"${PROJECT_SOURCE_DIR}/interface/python_binding/pyktx/vk_format.py"
|
||||
"${PROJECT_SOURCE_DIR}/lib/vkformat_enum.h"
|
||||
"${PROJECT_SOURCE_DIR}/lib/vkformat_typesize.c"
|
||||
"${PROJECT_SOURCE_DIR}/lib/vkformat_check.c"
|
||||
"${PROJECT_SOURCE_DIR}/lib/vkformat_str.c"
|
||||
"${PROJECT_SOURCE_DIR}tests/unittests/vkformat_list.inl")
|
||||
"${java_binding}/src/main/java/org/khronos/ktx/VkFormat.java"
|
||||
"${js_binding}/vk_format.inl"
|
||||
"${python_binding}/pyktx/vk_format.py"
|
||||
"${lib_src}/vkformat_enum.h"
|
||||
"${lib_src}/vkformat_typesize.c"
|
||||
"${lib_src}/vkformat_check.c"
|
||||
"${lib_src}/src/vkformat_str.c"
|
||||
"${unittests}/vkformat_list.inl")
|
||||
|
||||
# CAUTION: When a COMMAND contains VAR="Value" CMake messes up the escaping
|
||||
# for Bash. With or without VERBATIM, if Value has no spaces CMake changes it
|
||||
@@ -104,7 +112,7 @@ list(APPEND mkvkformatfiles_output
|
||||
# parses successfully.
|
||||
|
||||
list(APPEND mvffc_as_list
|
||||
scripts/mkvkformatfiles ./ ${vulkan_header})
|
||||
${scripts}/mkvkformatfiles ./ ${vulkan_header})
|
||||
list(JOIN mvffc_as_list " " mvffc_as_string)
|
||||
set(mkvkformatfiles_command "${BASH_EXECUTABLE}" -c "${mvffc_as_string}")
|
||||
|
||||
@@ -124,12 +132,11 @@ add_custom_target(mkvkformatfiles
|
||||
list(APPEND makevk2dfd_input
|
||||
${vulkan_header}
|
||||
external/dfdutils/makevk2dfd.pl)
|
||||
set(makevk2dfd_output
|
||||
"${PROJECT_SOURCE_DIR}/external/dfdutils/vk2dfd.inl")
|
||||
set(makevk2dfd_output "${dfdutils}/vk2dfd.inl")
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${makevk2dfd_output}
|
||||
COMMAND "${PERL_EXECUTABLE}" external/dfdutils/makevk2dfd.pl ${vulkan_header} external/dfdutils/vk2dfd.inl
|
||||
COMMAND "${PERL_EXECUTABLE}" ${dfdutils}/makevk2dfd.pl ${vulkan_header} ${dfdutils}/vk2dfd.inl
|
||||
DEPENDS ${makevk2dfd_input}
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
COMMENT "Generating VkFormat/DFD switch body"
|
||||
@@ -144,14 +151,14 @@ add_custom_target(makevk2dfd
|
||||
|
||||
list(APPEND makedfd2vk_input
|
||||
${vulkan_header}
|
||||
external/dfdutils/makedfd2vk.pl)
|
||||
${dfdutils}/makedfd2vk.pl)
|
||||
list(APPEND makedfd2vk_output
|
||||
"${PROJECT_SOURCE_DIR}/external/dfdutils/dfd2vk.inl")
|
||||
"${dfdutils}/dfd2vk.inl")
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${makedfd2vk_output}
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory external/dfdutils
|
||||
COMMAND "${PERL_EXECUTABLE}" external/dfdutils/makedfd2vk.pl ${vulkan_header} external/dfdutils/dfd2vk.inl
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${dfdutils}
|
||||
COMMAND "${PERL_EXECUTABLE}" ${dfdutils}/makedfd2vk.pl ${vulkan_header} ${dfdutils}/dfd2vk.inl
|
||||
DEPENDS ${makedfd2vk_input}
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
COMMENT "Generating DFD/VkFormat switch body"
|
||||
@@ -167,19 +174,19 @@ list(APPEND makevk2gl_input
|
||||
${KTX_SPECIFICATION}/generate_format_switches.rb
|
||||
${KTX_SPECIFICATION}/formats.json)
|
||||
list(APPEND makevk2gl_output
|
||||
"${PROJECT_SOURCE_DIR}/lib/vkFormat2glFormat.inl"
|
||||
"${PROJECT_SOURCE_DIR}/lib/vkFormat2glInternalFormat.inl"
|
||||
"${PROJECT_SOURCE_DIR}/lib/vkFormat2glType.inl")
|
||||
"${lib_src}/vkFormat2glFormat.inl"
|
||||
"${lib_src}/vkFormat2glInternalFormat.inl"
|
||||
"${lib_src}/vkFormat2glType.inl")
|
||||
# Until we have D3D or Metal loaders these outputs of
|
||||
# generate_format_switches.rb are unneeded.
|
||||
list(APPEND makevk2gl_extraneous_files
|
||||
"${PROJECT_SOURCE_DIR}/lib/vkFormat2dxgiFormat.inl"
|
||||
"${PROJECT_SOURCE_DIR}/lib/vkFormat2mtlFormat.inl"
|
||||
"${lib_src}/vkFormat2dxgiFormat.inl"
|
||||
"${lib_src}/vkFormat2mtlFormat.inl"
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${makevk2gl_output}
|
||||
COMMAND "${RUBY_EXECUTABLE}" ${KTX_SPECIFICATION}/generate_format_switches.rb ${PROJECT_SOURCE_DIR}/lib
|
||||
COMMAND "${RUBY_EXECUTABLE}" ${KTX_SPECIFICATION}/generate_format_switches.rb ${lib_src}
|
||||
COMMAND ${CMAKE_COMMAND} -E rm -f ${makevk2gl_extraneous_files}
|
||||
DEPENDS ${makevk2gl_input}
|
||||
WORKING_DIRECTORY ${KTX_SPECIFICATION}
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
#
|
||||
|
||||
include(GetGitRevisionDescription)
|
||||
include(CMakePrintHelpers)
|
||||
|
||||
find_package(Bash REQUIRED)
|
||||
|
||||
function(git_update_index)
|
||||
if(NOT GIT_FOUND)
|
||||
@@ -171,17 +174,20 @@ endif()
|
||||
set(KTX_VERSION ${KTX_VERSION_MAJOR}.${KTX_VERSION_MINOR}.${KTX_VERSION_PATCH})
|
||||
set(KTX_VERSION_FULL ${KTX_VERSION}${KTX_VERSION_TWEAK})
|
||||
|
||||
#message("KTX version: ${KTX_VERSION} major:${KTX_VERSION_MAJOR} minor:${KTX_VERSION_MINOR} patch:${KTX_VERSION_PATCH} tweak:${KTX_VERSION_TWEAK}")
|
||||
#cmake_print_variables(KTX_VERSION KTX_VERSION_FULL)
|
||||
#cmake_print_variables(KTX_VERSION_MAJOR KTX_VERSION_MINOR KTX_VERSION_PATCH KTX_VERSION_TWEAK)
|
||||
|
||||
function( create_version_header dest_path target )
|
||||
|
||||
# N.B. cmake_print_variables(CMAKE_CURRENT_FUNCTION_LIST_DIR) will
|
||||
# print the location of the cmake_print_variables function.
|
||||
set( mkversion "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../scripts/mkversion" )
|
||||
set( version_h_output ${PROJECT_SOURCE_DIR}/${dest_path}/version.h)
|
||||
|
||||
if(CMAKE_HOST_WIN32)
|
||||
add_custom_command(
|
||||
OUTPUT ${version_h_output}
|
||||
# On Windows this command has to be invoked by a shell in order to work
|
||||
COMMAND ${BASH_EXECUTABLE} -c "\"scripts/mkversion\" ${MKV_VERSION_OPT} \"-o\" \"version.h\" \"${dest_path}\""
|
||||
COMMAND ${BASH_EXECUTABLE} -c "\"${mkversion}\" ${MKV_VERSION_OPT} \"-o\" \"version.h\" \"${dest_path}\""
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
COMMENT "Generate ${version_h_output}"
|
||||
VERBATIM
|
||||
@@ -189,7 +195,7 @@ function( create_version_header dest_path target )
|
||||
else()
|
||||
add_custom_command(
|
||||
OUTPUT ${version_h_output}
|
||||
COMMAND scripts/mkversion ${MKV_VERSION_OPT} -o version.h ${dest_path}
|
||||
COMMAND ${mkversion} ${MKV_VERSION_OPT} -o version.h ${dest_path}
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
COMMENT "Generate ${version_h_output}"
|
||||
VERBATIM
|
||||
|
||||
@@ -213,8 +213,10 @@ namespace basist
|
||||
}
|
||||
|
||||
static inline int32_t clampi(int32_t value, int32_t low, int32_t high) { if (value < low) value = low; else if (value > high) value = high; return value; }
|
||||
#if BASISD_SUPPORT_PVRTC2
|
||||
static inline float clampf(float value, float low, float high) { if (value < low) value = low; else if (value > high) value = high; return value; }
|
||||
static inline float saturate(float value) { return clampf(value, 0, 1.0f); }
|
||||
#endif
|
||||
|
||||
static inline uint8_t mul_8(uint32_t v, uint32_t q) { v = v * q + 128; return (uint8_t)((v + (v >> 8)) >> 8); }
|
||||
|
||||
@@ -12954,7 +12956,7 @@ namespace basist
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t best_pbits[2];
|
||||
uint32_t best_pbits[2] = {}; // Initialization here is to stop gcc warning
|
||||
color_quad_u8 bestMinColor, bestMaxColor;
|
||||
determine_unique_pbits((total_comps == 2) ? 4 : total_comps, 7, xl, xh, bestMinColor, bestMaxColor, best_pbits);
|
||||
|
||||
|
||||
2
external/dfdutils/dfd.h
vendored
2
external/dfdutils/dfd.h
vendored
@@ -65,7 +65,7 @@ typedef unsigned int uint32_t;
|
||||
#if !defined(LIBKTX)
|
||||
#include <vulkan/vulkan_core.h>
|
||||
#else
|
||||
#include "../../lib/vkformat_enum.h"
|
||||
#include "../../lib/src/vkformat_enum.h"
|
||||
#endif
|
||||
|
||||
uint32_t* vk2dfd(enum VkFormat format);
|
||||
|
||||
@@ -25,9 +25,9 @@ target_include_directories(
|
||||
obj_basisu_cbind
|
||||
PUBLIC
|
||||
inc
|
||||
${KTX_BASISU_INCLUDE_DIRS}
|
||||
${PROJECT_SOURCE_DIR}/external/basisu/transcoder
|
||||
PRIVATE
|
||||
$<TARGET_PROPERTY:ktx,INCLUDE_DIRECTORIES>
|
||||
$<TARGET_PROPERTY:ktx_read,INCLUDE_DIRECTORIES>
|
||||
${PROJECT_SOURCE_DIR}/utils
|
||||
)
|
||||
|
||||
@@ -36,7 +36,7 @@ target_compile_definitions(
|
||||
PUBLIC
|
||||
KTX_BASISU_C_BINDINGS
|
||||
PRIVATE
|
||||
$<TARGET_PROPERTY:ktx,INTERFACE_COMPILE_DEFINITIONS>
|
||||
$<TARGET_PROPERTY:ktx_read,INTERFACE_COMPILE_DEFINITIONS>
|
||||
# We're only using this to read .basis files.
|
||||
BASISD_SUPPORT_KTX2_ZSTD=0
|
||||
BASISD_SUPPORT_KTX2=0
|
||||
|
||||
@@ -40,7 +40,6 @@ target_include_directories(ktx-jni SYSTEM PRIVATE
|
||||
)
|
||||
|
||||
set_target_properties(ktx-jni PROPERTIES
|
||||
LIBRARY_OUTPUT_DIRECTORY ${KTX_BUILD_DIR}/$<CONFIG>
|
||||
VERSION ${PROJECT_VERSION}
|
||||
SOVERSION ${PROJECT_VERSION_MAJOR}
|
||||
XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME "YES"
|
||||
|
||||
@@ -2,15 +2,16 @@
|
||||
# Copyright 2023 Shukant Pal
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
cmake_minimum_required(VERSION 3.27) # 3.27 for genex TARGET_IMPORT_FILE artifacts.
|
||||
|
||||
option( KTX_PY_USE_VENV
|
||||
"Use a Python virtual environment. Needed for externally managed python installations."
|
||||
OFF
|
||||
)
|
||||
|
||||
find_package (Python3 COMPONENTS Interpreter)
|
||||
set(SOURCE_DIR ${CMAKE_SOURCE_DIR}/interface/python_binding)
|
||||
file(GLOB pyktx_py_src ${SOURCE_DIR}/pyktx/*.py)
|
||||
list(TRANSFORM pyktx_py_src REPLACE "${SOURCE_DIR}/pyktx/" "${KTX_BUILD_DIR}/interface/python_binding/docs/pyktx." OUTPUT_VARIABLE pyktx_py_rst_filenames)
|
||||
file(GLOB pyktx_py_src ${CMAKE_CURRENT_SOURCE_DIR}/pyktx/*.py)
|
||||
list(TRANSFORM pyktx_py_src REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/pyktx/" "${KTX_BUILD_DIR}/interface/python_binding/docs/pyktx." OUTPUT_VARIABLE pyktx_py_rst_filenames)
|
||||
list(TRANSFORM pyktx_py_rst_filenames REPLACE ".py$" ".rst" OUTPUT_VARIABLE pyktx_py_rst)
|
||||
|
||||
set(PYTHON_EXECUTABLE_SYSTEM ${Python3_EXECUTABLE})
|
||||
@@ -33,7 +34,12 @@ endif()
|
||||
# Convert Windows path to CMake path
|
||||
cmake_path(SET PYTHON_PATH ${PYTHON_EXECUTABLE})
|
||||
|
||||
set(LIBKTX_LIB_DIR ${KTX_BUILD_DIR}/$<CONFIG>)
|
||||
set(libktx_include_dir $<TARGET_PROPERTY:ktx,INTERFACE_INCLUDE_DIRECTORIES>)
|
||||
# IMPORT_FILE_DIR is typically only set when building a Windows DLL and
|
||||
# points to the directory with the .lib import file.
|
||||
set(libktx_import_dir $<IF:$<BOOL:$<TARGET_IMPORT_FILE_DIR:ktx>>,$<TARGET_IMPORT_FILE_DIR:ktx>,$<TARGET_FILE_DIR:ktx>>)
|
||||
set(libktx_lib_dir $<TARGET_FILE_DIR:ktx>)
|
||||
add_custom_target(debug_libktx_dirs COMMAND ${CMAKE_COMMAND} -E echo "libktx_include_dir = ${libktx_include_dir}, libktx_import_dir = ${libktx_import_dir}, libktx_lib_dir = ${libktx_lib_dir}")
|
||||
|
||||
if(KTX_PY_USE_VENV)
|
||||
add_custom_target( py-venv ALL
|
||||
@@ -61,7 +67,7 @@ add_custom_command(
|
||||
TARGET pyktx-deps
|
||||
PRE_BUILD
|
||||
COMMAND
|
||||
${PYTHON_EXECUTABLE} -m pip install --no-warn-script-location -r ${SOURCE_DIR}/requirements.txt
|
||||
${PYTHON_EXECUTABLE} -m pip install --no-warn-script-location -r ${CMAKE_CURRENT_SOURCE_DIR}/requirements.txt
|
||||
COMMENT
|
||||
"Install dependencies for pyktx build"
|
||||
)
|
||||
@@ -77,7 +83,7 @@ add_custom_target( pyktx ALL
|
||||
pyktx/ktx_texture1.c
|
||||
pyktx/ktx_texture2.c
|
||||
WORKING_DIRECTORY
|
||||
${SOURCE_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMENT
|
||||
"Python distributions"
|
||||
)
|
||||
@@ -91,7 +97,7 @@ add_custom_command(
|
||||
COMMENT
|
||||
"Clean up pyktx build artifacts"
|
||||
WORKING_DIRECTORY
|
||||
${SOURCE_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
# Normalize version number as the python toolchain does. Tweaks are reduced
|
||||
@@ -108,6 +114,7 @@ normalize_version(KTX_VERSION_NORMALIZED ${KTX_VERSION_FULL})
|
||||
set(DIST_DIR ${KTX_BUILD_DIR}/interface/python_binding/dist)
|
||||
set(SOURCE_ARCHIVE_BASENAME ${DIST_DIR}/pyktx-${KTX_VERSION_NORMALIZED})
|
||||
|
||||
cmake_print_variables(BASH_EXECUTABLE)
|
||||
add_custom_command(
|
||||
TARGET pyktx
|
||||
POST_BUILD
|
||||
@@ -116,8 +123,9 @@ add_custom_command(
|
||||
${SOURCE_ARCHIVE_BASENAME}.zip
|
||||
COMMAND
|
||||
${CMAKE_COMMAND} -E env
|
||||
LIBKTX_INCLUDE_DIR=${CMAKE_SOURCE_DIR}/include
|
||||
LIBKTX_LIB_DIR=${LIBKTX_LIB_DIR}
|
||||
LIBKTX_INCLUDE_DIR=${libktx_include_dir}
|
||||
LIBKTX_IMPORT_DIR=${libktx_import_dir}
|
||||
LIBKTX_LIB_DIR=${libktx_lib_dir}
|
||||
LIBKTX_VERSION=${KTX_VERSION_NORMALIZED}
|
||||
# The build module by default builds in an isolated environment, i.e. it
|
||||
# requires a virtual env. I have not found a way via find_package to
|
||||
@@ -127,7 +135,7 @@ add_custom_command(
|
||||
COMMENT
|
||||
"Build pyktx source package"
|
||||
WORKING_DIRECTORY
|
||||
${SOURCE_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
@@ -135,35 +143,37 @@ add_custom_command(
|
||||
POST_BUILD
|
||||
COMMAND
|
||||
${CMAKE_COMMAND} -E env
|
||||
LIBKTX_INCLUDE_DIR=${CMAKE_SOURCE_DIR}/include
|
||||
LIBKTX_LIB_DIR=${LIBKTX_LIB_DIR}
|
||||
LIBKTX_INCLUDE_DIR=${libktx_include_dir}
|
||||
LIBKTX_IMPORT_DIR=${libktx_import_dir}
|
||||
LIBKTX_LIB_DIR=${libktx_lib_dir}
|
||||
LIBKTX_VERSION=${KTX_VERSION_NORMALIZED}
|
||||
# Ditto with sdist isolated environment comment.
|
||||
${PYTHON_EXECUTABLE} -m build --wheel --outdir ${DIST_DIR}
|
||||
COMMENT
|
||||
"Build pyktx wheel"
|
||||
WORKING_DIRECTORY
|
||||
${SOURCE_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
set(pyktx_egg_info
|
||||
${SOURCE_DIR}/pyktx.egg-info/dependency_links.txt
|
||||
${SOURCE_DIR}/pyktx.egg-info/PKG-INFO
|
||||
${SOURCE_DIR}/pyktx.egg-info/requires.txt
|
||||
${SOURCE_DIR}/pyktx.egg-info/SOURCES.txt
|
||||
${SOURCE_DIR}/pyktx.egg-info/top_level.txt)
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/pyktx.egg-info/dependency_links.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/pyktx.egg-info/PKG-INFO
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/pyktx.egg-info/requires.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/pyktx.egg-info/SOURCES.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/pyktx.egg-info/top_level.txt)
|
||||
|
||||
add_test(NAME pyktx
|
||||
COMMAND
|
||||
${CMAKE_COMMAND} -E env
|
||||
LIBKTX_INCLUDE_DIR=${CMAKE_SOURCE_DIR}/include
|
||||
LIBKTX_LIB_DIR=${LIBKTX_LIB_DIR}
|
||||
LIBKTX_INCLUDE_DIR=${libktx_include_dir}
|
||||
LIBKTX_IMPORT_DIR=${libktx_import_dir}
|
||||
LIBKTX_LIB_DIR=${libktx_lib_dir}
|
||||
KTX_RUN_TESTS=ON
|
||||
DYLD_LIBRARY_PATH=${LIBKTX_LIB_DIR}:$ENV{DYLD_LIBRARY_PATH}
|
||||
LD_LIBRARY_PATH=${LIBKTX_LIB_DIR}:$ENV{LD_LIBRARY_PATH}
|
||||
DYLD_LIBRARY_PATH=${libktx_lib_dir}:$ENV{DYLD_LIBRARY_PATH}
|
||||
LD_LIBRARY_PATH=${libktx_lib_dir}:$ENV{LD_LIBRARY_PATH}
|
||||
${PYTHON_EXECUTABLE} buildscript.py
|
||||
WORKING_DIRECTORY
|
||||
${SOURCE_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
if(KTX_FEATURE_DOC)
|
||||
@@ -191,10 +201,11 @@ if(KTX_FEATURE_DOC)
|
||||
# prints warnings and fails to include any content in the documentation
|
||||
# for the native interfaces in the HTML files it creates.
|
||||
${CMAKE_COMMAND} -E env
|
||||
LIBKTX_INCLUDE_DIR=${CMAKE_SOURCE_DIR}/include
|
||||
LIBKTX_LIB_DIR=${LIBKTX_LIB_DIR}
|
||||
DYLD_LIBRARY_PATH=${LIBKTX_LIB_DIR}:$ENV{DYLD_LIBRARY_PATH}
|
||||
LD_LIBRARY_PATH=${LIBKTX_LIB_DIR}:$ENV{LD_LIBRARY_PATH}
|
||||
LIBKTX_INCLUDE_DIR=${libktx_include_dir}
|
||||
LIBKTX_IMPORT_DIR=${libktx_import_dir}
|
||||
LIBKTX_LIB_DIR=${libktx_lib_dir}
|
||||
DYLD_LIBRARY_PATH=${libktx_lib_dir}:$ENV{DYLD_LIBRARY_PATH}
|
||||
LD_LIBRARY_PATH=${libktx_lib_dir}:$ENV{LD_LIBRARY_PATH}
|
||||
${PYTHON_EXECUTABLE} buildscript.py
|
||||
COMMAND
|
||||
${CMAKE_COMMAND} -E copy
|
||||
@@ -213,8 +224,8 @@ if(KTX_FEATURE_DOC)
|
||||
# in the docs directory of the python_binding section of the build directory.
|
||||
# `--separate` says to put the documentation for each module on its own page.
|
||||
${CMAKE_COMMAND} -E env
|
||||
LIBKTX_INCLUDE_DIR=${CMAKE_SOURCE_DIR}/include
|
||||
LIBKTX_LIB_DIR=${LIBKTX_LIB_DIR}
|
||||
LIBKTX_INCLUDE_DIR=${libktx_include_dir}
|
||||
LIBKTX_LIB_DIR=${libktx_lib_dir}
|
||||
${PYTHON_EXECUTABLE} -m sphinx.ext.apidoc -o ${KTX_BUILD_DIR}/interface/python_binding/docs ./pyktx --separate
|
||||
COMMAND
|
||||
# Sphinx uses autodoc to generate html files from the .rst files generated above.
|
||||
@@ -226,17 +237,17 @@ if(KTX_FEATURE_DOC)
|
||||
# there by one of the COMMANDs above). `conf.py` adds the python binding
|
||||
# section of the build directory to Python's `sys.path` so Autodoc can find the
|
||||
# modules. However they aren't there. The `pyktx` module is the directory
|
||||
# ${SOURCE_DIR}/pyktx and the .o files from compiling the native parts are
|
||||
# built there by buildscript.py when invoked above. ${SOURCE_DIR} appears in
|
||||
# Python's sys.path so autodoc finds them. There is nothing explicit in `conf.py`
|
||||
# to do this. It appears that Sphinx or autodoc itself adds its working directory
|
||||
# to `sys.path`.
|
||||
# ${CMAKE_CURRENT_SOURCE_DIR}/pyktx and the .o files from compiling the native
|
||||
# parts are built there by buildscript.py when invoked above.
|
||||
# ${CMAKE_CURRENT_SOURCE_DIR} appears in Python's sys.path so autodoc finds them.
|
||||
# There is nothing explicit in `conf.py` to do this. It appears that Sphinx or
|
||||
# autodoc itself adds its working directory to `sys.path`.
|
||||
${CMAKE_COMMAND} -E env
|
||||
LIBKTX_INCLUDE_DIR=${CMAKE_SOURCE_DIR}/include
|
||||
LIBKTX_LIB_DIR=${LIBKTX_LIB_DIR}
|
||||
LIBKTX_INCLUDE_DIR=$<TARGET_PROPERTY:ktx,INTERFACE_INCLUDE_DIRECTORIES>
|
||||
LIBKTX_LIB_DIR=${libktx_lib_dir}
|
||||
SPHINXBUILD=${PYTHON_PATH}\ -m\ sphinx
|
||||
make SOURCEDIR="${KTX_BUILD_DIR}/interface/python_binding" BUILDDIR="${KTX_BUILD_DIR}/interface/python_binding/docs/html/pyktx" html
|
||||
WORKING_DIRECTORY
|
||||
${SOURCE_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -5,11 +5,13 @@ Made with love by [Shukant Pal](https://www.shukantpal.com/about) on his way to
|
||||
|
||||
# pyktx
|
||||
|
||||
This Python package provides a Pythonic interface to libktx. It uses CFFI to generate the C bindings.
|
||||
This Python package provides a Pythonic interface to _libktx_. It uses CFFI to generate the C bindings.
|
||||
|
||||
## Usage
|
||||
|
||||
**You must have libktx installed on your system to use pyktx ordinarily. You can configure where libktx is installed using the `LIBKTX_INCLUDE_DIR` and `LIBKTX_LIB_DIR` environment variables too.**
|
||||
**You must have _libktx_ installed on your system to use pyktx ordinarily. If not
|
||||
installed in the default location, you can configure where _libktx_ is installed
|
||||
using the `LIBKTX_INCLUDE_DIR` and `LIBKTX_LIB_DIR` environment variables.**
|
||||
|
||||
To install libktx, download and run the appropriate installer from [our releases](https://github.com/KhronosGroup/KTX-Software/releases).
|
||||
|
||||
@@ -17,15 +19,49 @@ To install libktx, download and run the appropriate installer from [our releases
|
||||
|
||||
To build and test pyktx,
|
||||
|
||||
Note: the following examples assume the environment variable PROJECT_DIR contains
|
||||
the full path to your KTX project. The self-built examples further assume that your
|
||||
build is in the `build` subdirectory of the project.
|
||||
|
||||
Set `LIBKTX_INSTALL_DIR` to point to your `libktx` installation. If you've
|
||||
installed `libktx` at the default location there is no need to set this.
|
||||
|
||||
```bash
|
||||
# Set LIBKTX_INSTALL_DIR if you've installed libktx at the default system location.
|
||||
# Otherwise set LIBKTX_INCLUDE_DIR, LIBKTX_LIB_DIR to wherever you've built libktx.
|
||||
cd ${PROJECT_DIR}/interface/python_binding
|
||||
cd $PROJECT_DIR/interface/python_binding
|
||||
KTX_RUN_TESTS=ON python3 buildscript.py
|
||||
# or
|
||||
LIBKTX_INSTALL_DIR=<path_to_your_installation> KTX_RUN_TESTS=ON python3 buildscript.py
|
||||
```
|
||||
|
||||
If you are on a POSIX system (macOS or Linux), make sure libktx is on your `DYLD_LIBRARY_PATH` and `LD_LIBRARY_PATH`.
|
||||
On Windows.
|
||||
|
||||
```powershell
|
||||
cd $env:PROJECT_DIR/interface/python_binding
|
||||
pwsh -Command { $env:LIBKTX_INSTALL_DIR='<path to installation>'; python buildscript.py }
|
||||
# or
|
||||
pwsh -Command { $env:LIBKTX_INSTALL_DIR='<path to installation>'; $env:KTX_RUN_TESTS='ON'; python buildscript.py }
|
||||
```
|
||||
|
||||
If you want to test with a self-built libktx, set `LIBKTX_INCLUDE_DIR` and
|
||||
`LIBKTX_LIB_DIR` to wherever your build is located. E.g.
|
||||
|
||||
```bash
|
||||
cd $PROJECT_DIR/interface/python_binding
|
||||
LIBKTX_INCLUDE_DIR=../../lib/include LIBKTX_LIB_DIR=../../build/Debug KTX_RUN_TESTS=ON python3 buildscript.py
|
||||
```
|
||||
|
||||
On Windows, you must also set `LIBKTX_IMPORT_DIR`. It must be the path to the
|
||||
directory where `ktx.lib` can be found. `LIBKTX_LIB_DIR` is the path to
|
||||
the directory where `ktx.dll` can be found.
|
||||
|
||||
```powershell
|
||||
cd $env:PROJECT_DIR/interface/python_binding
|
||||
pwsh -Command { $env:LIBKTX_INCLUDE_DIR='../../lib/include'; $env:LIBKTX_IMPORT_DIR='../../build/lib/Debug'; $env:LIBKTX_LIB_DIR = '../../build/Debug>'; python buildscript.py }
|
||||
# or
|
||||
pwsh -Command { $env:LIBKTX_INCLUDE_DIR='../../lib/include'; $env:LIBKTX_IMPORT_DIR='../../build/lib/Debug'; $env:LIBKTX_LIB_DIR = '../../build/Debug>'; $env:KTX_RUN_TESTS='ON'; python buildscript.py }
|
||||
```
|
||||
|
||||
### Note
|
||||
> When building on macOS against a universal CPython binary, such as that installed with the Xcode command-line tools (/usr/bin/python3), ld will issue a warning
|
||||
>
|
||||
> ```
|
||||
|
||||
@@ -9,6 +9,7 @@ import unittest
|
||||
|
||||
LIBKTX_INSTALL_DIR = os.getenv("LIBKTX_INSTALL_DIR")
|
||||
LIBKTX_INCLUDE_DIR = os.getenv("LIBKTX_INCLUDE_DIR")
|
||||
LIBKTX_IMPORT_DIR = os.getenv("LIBKTX_IMPORT_DIR")
|
||||
LIBKTX_LIB_DIR = os.getenv("LIBKTX_LIB_DIR")
|
||||
|
||||
if os.name == 'nt':
|
||||
@@ -27,7 +28,9 @@ elif os.name == 'posix':
|
||||
if LIBKTX_INCLUDE_DIR is None:
|
||||
LIBKTX_INCLUDE_DIR = '/usr/include'
|
||||
if LIBKTX_LIB_DIR is None:
|
||||
LIBKTX_LIB_DIR = '/usr/lib'
|
||||
LIBKTX_LIB_DIR = '/usr/local/lib'
|
||||
|
||||
library_dirs = ([LIBKTX_IMPORT_DIR] if LIBKTX_IMPORT_DIR is not None else [LIBKTX_LIB_DIR] if LIBKTX_LIB_DIR is not None else [])
|
||||
|
||||
ffibuilder = FFI()
|
||||
|
||||
@@ -186,11 +189,19 @@ ffibuilder.set_source(
|
||||
#include "ktx_texture1.h"
|
||||
#include "ktx_texture2.h"
|
||||
""",
|
||||
# The following distutil keywords are documented
|
||||
# at https://docs.python.org/3.11/distutils/apiref.html
|
||||
#
|
||||
# List of directories to search for C/C++ header files
|
||||
include_dirs=['pyktx']
|
||||
+ ([LIBKTX_INCLUDE_DIR] if LIBKTX_INCLUDE_DIR is not None else []),
|
||||
# List of source filenames, relative to the the setup script
|
||||
sources=['pyktx/ktx_texture.c', 'pyktx/ktx_texture1.c', 'pyktx/ktx_texture2.c'],
|
||||
# List of library names (not filenames or paths) to link against
|
||||
libraries=['ktx'],
|
||||
library_dirs=([LIBKTX_LIB_DIR] if LIBKTX_LIB_DIR is not None else []),
|
||||
# List of directories to search for C/C++ libraries at link time
|
||||
library_dirs=library_dirs,
|
||||
# List of directories to search for C/C++ libraries at run time.
|
||||
runtime_library_dirs=(([LIBKTX_LIB_DIR] if LIBKTX_LIB_DIR is not None else []) if os.name != 'nt' else None))
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -11,6 +11,10 @@ if os.name == 'nt':
|
||||
LIBKTX_INSTALL_DIR = 'C:\\Program Files\\KTX-Software'
|
||||
if LIBKTX_LIB_DIR is None:
|
||||
LIBKTX_LIB_DIR = LIBKTX_INSTALL_DIR + '\\bin'
|
||||
else:
|
||||
# add_dll_directory requires full path.
|
||||
LIBKTX_LIB_DIR = os.path.abspath(LIBKTX_LIB_DIR);
|
||||
|
||||
os.add_dll_directory(os.path.normpath(LIBKTX_LIB_DIR))
|
||||
|
||||
from .gl_internalformat import *
|
||||
|
||||
1024
lib/CMakeLists.txt
Normal file
1024
lib/CMakeLists.txt
Normal file
File diff suppressed because it is too large
Load Diff
@@ -540,7 +540,9 @@ compressedTexImage2DCallback(int miplevel, int face,
|
||||
{
|
||||
ktx_cbdata* cbData = (ktx_cbdata*)userdata;
|
||||
GLenum glerror;
|
||||
#if SUPPORT_SOFTWARE_ETC_UNPACK
|
||||
KTX_error_code result;
|
||||
#endif
|
||||
UNUSED(depth);
|
||||
|
||||
if (faceLodSize > UINT32_MAX)
|
||||
@@ -104,15 +104,17 @@ cmake_args+=(\
|
||||
"-D" "KTX_FEATURE_TESTS=$FEATURE_TESTS" \
|
||||
"-D" "KTX_FEATURE_TOOLS=$FEATURE_TOOLS" \
|
||||
"-D" "KTX_FEATURE_TOOLS_CTS=$FEATURE_TOOLS_CTS" \
|
||||
"-D" "KTX_FEATURE_GL_UPLOAD=$FEATURE_GL_UPLOAD" \
|
||||
"-D" "KTX_FEATURE_VK_UPLOAD=$FEATURE_VK_UPLOAD" \
|
||||
"-D" "LIBKTX_FEATURE_GL_UPLOAD=$FEATURE_GL_UPLOAD" \
|
||||
"-D" "LIBKTX_FEATURE_VK_UPLOAD=$FEATURE_VK_UPLOAD" \
|
||||
"-D" "BASISU_SUPPORT_OPENCL=$SUPPORT_OPENCL" \
|
||||
"-D" "BASISU_SUPPORT_SSE=$SUPPORT_SSE" \
|
||||
"-D" "KTX_PY_USE_VENV=$PY_USE_VENV" \
|
||||
"-D" "KTX_WERROR=$WERROR"
|
||||
)
|
||||
if [ "$FEATURE_PY" = "ON" ]; then
|
||||
cmake_args+=("-D" "KTX_PY_USE_VENV=$PY_USE_VENV")
|
||||
fi
|
||||
if [ "$ARCH" != $(uname -m) ]; then
|
||||
cmake_args+=("--toolchain", "cmake/linux-$ARCH-toolchain.cmake")
|
||||
cmake_args+=("--toolchain" "cmake/linux-$ARCH-toolchain.cmake")
|
||||
fi
|
||||
config_display="Configure KTX-Software (Linux on $ARCH): "
|
||||
for arg in "${cmake_args[@]}"; do
|
||||
|
||||
52
scripts/check_lib_build_output.sh
Executable file
52
scripts/check_lib_build_output.sh
Executable file
@@ -0,0 +1,52 @@
|
||||
#! /usr/bin/env bash
|
||||
|
||||
# Copyright 2025 The Khronos Group Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# Used only for checking in workflows that the output directory of a
|
||||
# libktx-only build has only the expected output files.
|
||||
|
||||
function usage() {
|
||||
echo "$0 <directory> where <directory> is the directory to check."
|
||||
}
|
||||
|
||||
cd $1
|
||||
# Expect to be in the output of a build created by a multi-config generator.
|
||||
version=$(cat ../ktx.version)
|
||||
if [[ -z "$version" ]]; then
|
||||
# No file. Perhaps a single config generator was used.
|
||||
version=$(cat ktx.version)
|
||||
fi
|
||||
if [[ -z "$version" ]]; then
|
||||
echo "ktx.version file is missing from $1/.. and $1."
|
||||
fi
|
||||
declare -a expected
|
||||
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
||||
expected=(libktx.so.$version libktx.so.4 libktx.so libktx_read.so.$version libktx_read.so.4 libktx_read.so)
|
||||
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
expected=(libktx.$version.dylib libktx.4.dylib libktx.dylib libktx_read.$version.dylib libktx_read.4.dylib libktx_read.dylib)
|
||||
elif [[ "$OSTYPE" == "win32" ]]; then
|
||||
expected=(ktx.dll ktx.lib ktx_read.dll ktx_read.lib)
|
||||
fi
|
||||
for e in ${expected[@]}; do
|
||||
if [[ ! -e $e ]]; then
|
||||
echo "Expected file $e does not exist"
|
||||
ls
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
for f in *; do
|
||||
expectedFile=0
|
||||
for e in ${expected[@]}; do
|
||||
if [[ "$e" = "$f" ]] ; then
|
||||
expectedFile=1
|
||||
fi
|
||||
done
|
||||
if [[ ! expectedFile -eq 1 ]]; then
|
||||
echo "Unexpected file $f found in output directory"
|
||||
ls
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -56,7 +56,7 @@ fi
|
||||
# Make sure we're in the KTX root directory
|
||||
cd $(dirname $0)/$depth
|
||||
if [ -n "$match" ]; then
|
||||
find . -path './build*' -prune -o -path tests/cts -prune -o -path './.git' -prune -o -path './external' -prune -o -type f -name "$filepattern" -exec grep -H "$match" {} \;
|
||||
find . -path './build*' -prune -o -path ./lib/build* -prune -o -path tests/cts -prune -o -path './.git' -prune -o -path './external' -prune -o -type f -name "$filepattern" -exec grep -H "$match" {} \;
|
||||
else
|
||||
find . -path './build*' -prune -o -path tests/cts -prune -o -path './.git' -prune -o -path './external' -prune -o -type f -name "$filepattern" -print
|
||||
find . -path './build*' -prune -o -path ./lib/build* -prune -o -path tests/cts -prune -o -path './.git' -prune -o -path './external' -prune -o -type f -name "$filepattern" -print
|
||||
fi
|
||||
|
||||
@@ -64,8 +64,14 @@ else
|
||||
# Try this where `arch` is x86-64 or arm64.
|
||||
sudo apt-get -qq install gcc-$gcc_pkg_arch-linux-gnu:native g++-$gcc_pkg_arch-linux-gnu:native binutils-$gcc_pkg_arch-linux-gnu:native
|
||||
fi
|
||||
sudo apt-get -qq install opencl-c-headers:$dpkg_arch
|
||||
sudo apt-get -qq install mesa-opencl-icd:$dpkg_arch
|
||||
if [[ "$SUPPORT_OPENCL" = "ON" ]]; then
|
||||
sudo apt-get -qq install pocl-opencl-icd:$dpkg_arch libpocl-dev:$dpkg_arch
|
||||
# This is still needed as only it provides libOpenCL.so.
|
||||
sudo apt-get -qq install ocl-icd-opencl-dev:$dpkg_arch
|
||||
# In case we need to check the OpenCL installation.
|
||||
#sudo apt-get -qq install clinfo:$dkpg_arch
|
||||
#clinfo
|
||||
fi
|
||||
if [[ "$FEATURE_GL_UPLOAD" = "ON" || "$FEATURE_LOADTESTS" =~ "OpenGL" ]]; then
|
||||
sudo apt-get -qq install libgl1:$dpkg_arch libgl1-mesa-dev:$dpkg_arch
|
||||
fi
|
||||
|
||||
@@ -14,8 +14,13 @@ DEF_VER=v4.0
|
||||
LF='
|
||||
'
|
||||
|
||||
# Change directory the root of the Git repo.
|
||||
# git describe has to be run in the Git repo root.
|
||||
# Before changing the directory to the repo root capture
|
||||
# the working directory to support <object> values that are
|
||||
# relative paths. This is particularly helpful for CMake
|
||||
# sub-projects in subdirectories of the repo.
|
||||
depth=..
|
||||
workdir=$(pwd)
|
||||
cd $(dirname $0)/$depth
|
||||
|
||||
# `man 7 gitrevisions` for the meaning of the output from git describe.
|
||||
@@ -63,8 +68,11 @@ function setfile() {
|
||||
local VC
|
||||
local verstring=$1_VERSION
|
||||
if [ $dry_run -eq 1 ]; then
|
||||
echo $verstring $VN
|
||||
return
|
||||
echo $verstring $VN
|
||||
if [ -n $VF ]; then
|
||||
echo "will be written to $2"
|
||||
fi
|
||||
return
|
||||
fi
|
||||
if [ -r $2 ]; then
|
||||
VC=$(grep $verstring $2 | sed -e "s/^#define $verstring //")
|
||||
@@ -100,9 +108,13 @@ function writeversion() {
|
||||
else
|
||||
vfp=$1/$VF
|
||||
fi
|
||||
if [ "$1" = "lib" ]; then
|
||||
if [[ $1 =~ .*lib$ || $1 =~ .*lib/src$ ]]; then
|
||||
ON=LIBKTX
|
||||
setfile $ON $1/$VF
|
||||
elif [ "$OBJ" == "." ]; then
|
||||
# Will only get "." if in repo root.
|
||||
ON=KTX-Software
|
||||
setfile $ON $1
|
||||
else
|
||||
ON=$(basename $1)
|
||||
ON=$(echo $ON | tr [:lower:] [:upper:])
|
||||
@@ -148,7 +160,21 @@ if [ $write_all -eq 1 ]; then
|
||||
fi
|
||||
done
|
||||
else
|
||||
if [[ $workdir =~ $(pwd)(/(.*$)?)? ]]; then
|
||||
# Trailing part of workdir gives object location in repo.
|
||||
if [ -n "${BASH_REMATCH[2]}" ]; then
|
||||
if [ "$OBJ" == "." ]; then
|
||||
OBJ=${BASH_REMATCH[2]}
|
||||
else
|
||||
OBJ=${BASH_REMATCH[2]}/$OBJ
|
||||
fi
|
||||
# else We are in the repo root
|
||||
fi
|
||||
else
|
||||
>&2 echo "$0: Working directory is not in KTX-Software repo."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
writeversion $OBJ
|
||||
fi
|
||||
|
||||
# vim:ai:ts=4:sts=4:sw=2:expandtab:textwidth=70
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
|
||||
# Usage: mkvkformatfiles [output-dir path/to/vulkan_core]
|
||||
#
|
||||
# This is expected to be run in the repo's root directory which is set
|
||||
# as the working directory by the cmake commands that run this script.
|
||||
#
|
||||
# output_dir defaults to the current directory.
|
||||
# path/to/vulkan_core defaults to ENVIRON["Vulkan_INCLUDE_DIR"]. If not
|
||||
# set, default is external/dfdutils/vulkan/vulkan_core.h.
|
||||
@@ -13,16 +16,16 @@
|
||||
|
||||
# This script creates 6 files from vulkan/vulkan_core.h:
|
||||
#
|
||||
# - lib/vkformat_enum.h: the VkFormat enum declaration for those who don't
|
||||
# - lib/src/vkformat_enum.h: the VkFormat enum declaration for those who don't
|
||||
# want to include vulkan_core.h. extension token names for
|
||||
# extensions that have been moved to core are omitted.
|
||||
#
|
||||
# - lib/vkformat_str.c: a switch statement for converting VkFormat enums to
|
||||
# - lib/src/vkformat_str.c: a switch statement for converting VkFormat enums to
|
||||
# to strings corresponding to the format names.
|
||||
# - lib/vkformat_typesize.c, function to return the type-size for each
|
||||
# format.
|
||||
#
|
||||
# - lib/vkformat_check.c: 3 functions: 1 to check if a format is prohibited in
|
||||
# - lib/src/vkformat_check.c: 3 functions: 1 to check if a format is prohibited in
|
||||
# KTX2, one to see if a format is a valid Vulkan format and one to see
|
||||
# if it is an sRGB format.
|
||||
#
|
||||
@@ -65,11 +68,11 @@ BEGIN {
|
||||
|
||||
# Hard-coded paths are somewhat unfortunate but major changes in
|
||||
# the source code organization are unlikely.
|
||||
format_hdr = output_dir "lib/vkformat_enum.h"
|
||||
format_typesize = output_dir "lib/vkformat_typesize.c"
|
||||
format_hdr = output_dir "lib/src/vkformat_enum.h"
|
||||
format_typesize = output_dir "lib/src/vkformat_typesize.c"
|
||||
format_inl = output_dir "tests/unittests/vkformat_list.inl"
|
||||
format_strings = output_dir "lib/vkformat_str.c"
|
||||
format_check = output_dir "lib/vkformat_check.c"
|
||||
format_strings = output_dir "lib/src/vkformat_str.c"
|
||||
format_check = output_dir "lib/src/vkformat_check.c"
|
||||
format_java = output_dir "interface/java_binding/src/main/java/org/khronos/ktx/VkFormat.java"
|
||||
format_js = output_dir "interface/js_binding/vk_format.inl"
|
||||
format_python = output_dir "interface/python_binding/pyktx/vk_format.py"
|
||||
|
||||
@@ -25,7 +25,7 @@ target_include_directories(
|
||||
SYSTEM
|
||||
PRIVATE
|
||||
$<TARGET_PROPERTY:objUtil,INTERFACE_INCLUDE_DIRECTORIES>
|
||||
${PROJECT_SOURCE_DIR}/lib
|
||||
${PROJECT_SOURCE_DIR}/lib/src
|
||||
${PROJECT_SOURCE_DIR}/other_include
|
||||
)
|
||||
|
||||
|
||||
@@ -176,7 +176,7 @@ target_include_directories(vkloadtests
|
||||
PRIVATE
|
||||
SDL3::Headers
|
||||
$<TARGET_PROPERTY:appfwSDL,INTERFACE_INCLUDE_DIRECTORIES>
|
||||
$<TARGET_PROPERTY:ktx,INCLUDE_DIRECTORIES>
|
||||
$<TARGET_PROPERTY:ktx,INTERFACE_INCLUDE_DIRECTORIES>
|
||||
$<TARGET_PROPERTY:objUtil,INTERFACE_INCLUDE_DIRECTORIES>
|
||||
appfwSDL/VulkanAppSDL
|
||||
vkloadtests
|
||||
|
||||
@@ -19,7 +19,7 @@ target_include_directories(
|
||||
PRIVATE
|
||||
$<TARGET_PROPERTY:ktx,INCLUDE_DIRECTORIES>
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../other_include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../lib # Just for gl_format.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../lib/src # Just for gl_format.h
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
|
||||
@@ -53,7 +53,7 @@ target_include_directories(
|
||||
unittests
|
||||
PRIVATE
|
||||
$<TARGET_PROPERTY:ktx,INCLUDE_DIRECTORIES>
|
||||
${PROJECT_SOURCE_DIR}/lib
|
||||
${PROJECT_SOURCE_DIR}/lib/src
|
||||
${PROJECT_SOURCE_DIR}/tools
|
||||
${PROJECT_SOURCE_DIR}/tools/imageio
|
||||
loadtests/common
|
||||
@@ -97,7 +97,7 @@ target_include_directories(
|
||||
PRIVATE
|
||||
$<TARGET_PROPERTY:ktx,INCLUDE_DIRECTORIES>
|
||||
${PROJECT_SOURCE_DIR}/other_include
|
||||
${PROJECT_SOURCE_DIR}/lib
|
||||
${PROJECT_SOURCE_DIR}/lib/src
|
||||
unittests
|
||||
)
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ set_code_sign(transcodetests)
|
||||
target_include_directories(
|
||||
transcodetests
|
||||
PRIVATE
|
||||
${PROJECT_SOURCE_DIR}/lib
|
||||
${PROJECT_SOURCE_DIR}/lib/src
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
@@ -44,17 +44,31 @@ if(WIN32)
|
||||
$<$<STREQUAL:"${BASISU_CBIND_LIBTYPE}","STATIC">:KHRONOS_STATIC>
|
||||
)
|
||||
|
||||
# Retrieve and set warning settings for the 2 files from the ktx target.
|
||||
# See comment in ../../CMakeLists.txt around line 625.
|
||||
# Retrieve and set warning settings for the 2 files from the ktx_read
|
||||
# target.
|
||||
# TODO: After BasisU update check if this is still necessary to compile
|
||||
# without warnings
|
||||
get_source_file_property(
|
||||
transcoder_options
|
||||
"${PROJECT_SOURCE_DIR}/external/basisu/transcoder/basisu_transcoder.cpp"
|
||||
TARGET_DIRECTORY ktx_read
|
||||
COMPILE_OPTIONS
|
||||
)
|
||||
if (transcoder_options)
|
||||
set_source_files_properties(
|
||||
"${PROJECT_SOURCE_DIR}/external/basisu/transcoder/basisu_transcoder.cpp"
|
||||
PROPERTIES COMPILE_OPTIONS "${transcoder_options}"
|
||||
"${PROJECT_SOURCE_DIR}/external/basisu/transcoder/basisu_transcoder.cpp"
|
||||
PROPERTIES COMPILE_OPTIONS "${transcoder_options}"
|
||||
)
|
||||
endif()
|
||||
get_source_file_property(
|
||||
zstd_options
|
||||
"${PROJECT_SOURCE_DIR}/external/basisu/zstd/zstd.c"
|
||||
TARGET_DIRECTORY ktx_read
|
||||
COMPILE_OPTIONS
|
||||
)
|
||||
if (zstd_options)
|
||||
set_source_files_properties(
|
||||
"${PROJECT_SOURCE_DIR}/external/basisu/zstd/zstd.c"
|
||||
${PROJECT_SOURCE_DIR}/external/basisu/zstd/zstd.c
|
||||
PROPERTIES COMPILE_OPTIONS "${zstd_options}"
|
||||
)
|
||||
endif()
|
||||
@@ -68,6 +82,9 @@ if(WIN32)
|
||||
obj_tmp_basisu
|
||||
PUBLIC # only for basisu_c_binding.
|
||||
BASISU_NO_ITERATOR_DEBUG_LEVEL
|
||||
# We're only using this to read .basis files.
|
||||
BASISD_SUPPORT_KTX2_ZSTD=0
|
||||
BASISD_SUPPORT_KTX2=0
|
||||
)
|
||||
target_link_libraries(transcodetests obj_tmp_basisu)
|
||||
endif()
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
# Copyright 2017-2020 The Khronos Group Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
if(NOT KTX_FEATURE_KTX1)
|
||||
message(WARNING "KTX_FEATURE_KTX1 is not set -> disabling tools")
|
||||
if(NOT LIBKTX_FEATURE_KTX1)
|
||||
message(WARNING "LIBKTX_FEATURE_KTX1 is not set -> disabling tools")
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(NOT KTX_FEATURE_KTX2)
|
||||
message(WARNING "KTX_FEATURE_KTX2 is not set -> disabling tools")
|
||||
if(NOT LIBKTX_FEATURE_KTX2)
|
||||
message(WARNING "LIBKTX_FEATURE_KTX2 is not set -> disabling tools")
|
||||
return()
|
||||
endif()
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ target_include_directories(
|
||||
ktxtools
|
||||
SYSTEM
|
||||
PRIVATE
|
||||
${PROJECT_SOURCE_DIR}/lib
|
||||
${PROJECT_SOURCE_DIR}/lib/src
|
||||
${PROJECT_SOURCE_DIR}/other_include
|
||||
)
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ PRIVATE
|
||||
.
|
||||
$<TARGET_PROPERTY:ktx,INCLUDE_DIRECTORIES>
|
||||
$<TARGET_PROPERTY:objUtil,INTERFACE_INCLUDE_DIRECTORIES>
|
||||
${PROJECT_SOURCE_DIR}/lib
|
||||
${PROJECT_SOURCE_DIR}/lib/src
|
||||
${PROJECT_SOURCE_DIR}/other_include
|
||||
)
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ PRIVATE
|
||||
.
|
||||
$<TARGET_PROPERTY:ktx,INCLUDE_DIRECTORIES>
|
||||
$<TARGET_PROPERTY:objUtil,INTERFACE_INCLUDE_DIRECTORIES>
|
||||
${PROJECT_SOURCE_DIR}/lib
|
||||
${PROJECT_SOURCE_DIR}/lib/src
|
||||
${PROJECT_SOURCE_DIR}/other_include
|
||||
)
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ PRIVATE
|
||||
.
|
||||
$<TARGET_PROPERTY:ktx,INCLUDE_DIRECTORIES>
|
||||
$<TARGET_PROPERTY:objUtil,INTERFACE_INCLUDE_DIRECTORIES>
|
||||
${PROJECT_SOURCE_DIR}/lib
|
||||
${PROJECT_SOURCE_DIR}/lib/src
|
||||
${PROJECT_SOURCE_DIR}/other_include
|
||||
)
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ target_include_directories(
|
||||
SYSTEM
|
||||
PRIVATE
|
||||
$<TARGET_PROPERTY:imageio,INTERFACE_SYSTEM_INCLUDE_DIRECTORIES>
|
||||
"${PROJECT_SOURCE_DIR}/lib"
|
||||
"${PROJECT_SOURCE_DIR}/lib/src"
|
||||
"${PROJECT_SOURCE_DIR}/external/dfdutils"
|
||||
)
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
#include "GL/glcorearb.h"
|
||||
#include "ktx.h"
|
||||
#include "../../lib/vkformat_enum.h"
|
||||
#include "../../lib/src/vkformat_enum.h"
|
||||
#include "argparser.h"
|
||||
#include "version.h"
|
||||
#include "image.hpp"
|
||||
|
||||
Reference in New Issue
Block a user