├── .clang-format
├── .gitignore
├── .gitmodules
├── CMakeLists.txt
├── LICENSE
├── README.md
├── build.sh
├── doc
└── images
│ ├── WebGPU_API.png
│ ├── depth_coordinates.png
│ ├── linuxlogo.png
│ ├── render_coordinates.png
│ ├── texture_coordinates.png
│ ├── webgpu-logo.png
│ ├── webgpu-logo.svg
│ └── webgpu_logo.png
├── docker
└── Dockerfile
├── external
├── basisu
│ ├── README.md
│ ├── basisu_transcoder.cpp
│ ├── wgpu_basisu.cpp
│ └── wgpu_basisu.h
├── dawn
│ └── download_dawn.sh
├── ktx
│ ├── LICENSE.md
│ ├── NOTICE.md
│ ├── README.md
│ ├── include
│ │ ├── ktx.h
│ │ └── ktxvulkan.h
│ ├── lib
│ │ ├── checkheader.c
│ │ ├── errstr.c
│ │ ├── etcdec.cxx
│ │ ├── etcunpack.cxx
│ │ ├── filestream.c
│ │ ├── filestream.h
│ │ ├── gl_format.h
│ │ ├── gl_funcptrs.h
│ │ ├── gles1_funcptrs.h
│ │ ├── gles2_funcptrs.h
│ │ ├── gles3_funcptrs.h
│ │ ├── glloader.c
│ │ ├── hashlist.c
│ │ ├── hashtable.c
│ │ ├── ktxgl.h
│ │ ├── ktxint.h
│ │ ├── libktx.gypi
│ │ ├── mainpage.md
│ │ ├── memstream.c
│ │ ├── memstream.h
│ │ ├── stream.h
│ │ ├── swap.c
│ │ ├── texture.c
│ │ ├── uthash.h
│ │ ├── vk_format.h
│ │ ├── vk_funclist.inl
│ │ ├── vk_funcs.c
│ │ ├── vk_funcs.h
│ │ ├── vkloader.c
│ │ ├── writer.c
│ │ └── writer_v1.c
│ └── other_include
│ │ └── KHR
│ │ └── khrplatform.h
├── par
│ └── par_shapes.h
├── rply
│ ├── LICENSE
│ ├── etc
│ │ ├── convert.c
│ │ ├── dump.c
│ │ ├── input.ply
│ │ └── sconvert.c
│ ├── manual
│ │ ├── manual.html
│ │ ├── reference.css
│ │ └── rply.png
│ ├── rply.c
│ ├── rply.h
│ └── rplyfile.h
├── sc
│ ├── sc_array.h
│ └── sc_queue.h
└── stb
│ ├── stb_font_consolas_24_latin1.h
│ ├── stb_image.h
│ ├── stb_image_resize.h
│ └── stb_image_write.h
├── lib
└── wgpu_native
│ ├── wgpu_native.cpp
│ └── wgpu_native.h
├── screenshots
├── animometer.jpg
├── compute_boids.jpg
├── compute_n_body.jpg
├── compute_particles.jpg
├── compute_ray_tracing.jpg
├── cube_reflection.jpg
├── demo_selection_1.jpg
├── gears.jpg
├── gltf_loading.jpg
├── image_blur.jpg
├── imgui_overlay.jpg
├── instanced_cube.jpg
├── msaa_line.jpg
├── shadertoy.jpg
├── shadow_mapping.jpg
├── skybox.jpg
├── textured_cube.jpg
├── textured_quad.jpg
├── triangle.jpg
├── two_cubes.jpg
└── video_uploading.jpg
└── src
├── core
├── api.h
├── argparse.c
├── argparse.h
├── camera.c
├── camera.h
├── file.c
├── file.h
├── frustum.c
├── frustum.h
├── hashmap.c
├── hashmap.h
├── input.h
├── log.c
├── log.h
├── macro.h
├── math.c
├── math.h
├── platform.h
├── utils.c
├── utils.h
├── video_decode.c
├── video_decode.h
├── window.c
└── window.h
├── examples
├── a_buffer.c
├── animometer.c
├── aquarium.c
├── basisu.c
├── bind_groups.c
├── blinn_phong_lighting.c
├── bloom.c
├── cameras.c
├── clear_screen.c
├── common_shaders.h
├── compute_boids.c
├── compute_metaballs.c
├── compute_particles.c
├── compute_particles_easing.c
├── compute_particles_webgpu_logo.c
├── compute_ray_tracing.c
├── compute_shader.c
├── conservative_raster.c
├── conway.c
├── conway_paletted_blurring.c
├── coordinate_system.c
├── cornell_box.c
├── cube_reflection.c
├── cubemap.c
├── deferred_rendering.c
├── dynamic_uniform_buffer.c
├── equirectangular_image.c
├── example_base.c
├── example_base.h
├── examples.c
├── examples.h
├── fluid_simulation.c
├── game_of_life.c
├── gears.c
├── gerstner_waves.c
├── gltf_loading.c
├── gltf_scene_rendering.c
├── gltf_skinning.c
├── hdr.c
├── image_blur.c
├── imgui_overlay.c
├── immersive_video.c
├── instanced_cube.c
├── meshes.c
├── meshes.h
├── minimal.c
├── msaa_line.c
├── multi_sampling.c
├── n_body_simulation.c
├── normal_map.c
├── normal_mapping.c
├── occlusion_query.c
├── offscreen_rendering.c
├── out_of_bounds_viewport.c
├── parallax_mapping.c
├── pbr_basic.c
├── pbr_ibl.c
├── pbr_texture.c
├── points.c
├── post_processing.c
├── pristine_grid.c
├── prng.c
├── procedural_mesh.c
├── radial_blur.c
├── render_bundles.c
├── reversed_z.c
├── sampler_parameters.c
├── screenshot.c
├── shadertoy.c
├── shadow_mapping.c
├── square.c
├── stencil_buffer.c
├── terrain_mesh.c
├── text_overlay.c
├── texture_3d.c
├── texture_cubemap.c
├── texture_mipmap_gen.c
├── textured_cube.c
├── textured_quad.c
├── tile_map.c
├── triangle.c
├── two_cubes.c
├── vertex_buffer.c
├── video_uploading.c
├── volume_rendering_texture_3d.c
└── wireframe_vertex_pulling.c
├── main.c
├── platforms
└── linux.c
└── webgpu
├── api.h
├── buffer.c
├── buffer.h
├── context.c
├── context.h
├── gltf_model.c
├── gltf_model.h
├── imgui_overlay.c
├── imgui_overlay.h
├── pbr.c
├── pbr.h
├── shader.c
├── shader.h
├── text_overlay.c
├── text_overlay.h
├── texture.c
└── texture.h
/.clang-format:
--------------------------------------------------------------------------------
1 | BasedOnStyle: LLVM
2 | AccessModifierOffset: -2
3 | AlignConsecutiveAssignments: true
4 | AlignEscapedNewlinesLeft: false
5 | AlignTrailingComments: true
6 | AllowAllParametersOfDeclarationOnNextLine: false
7 | AllowShortBlocksOnASingleLine: false
8 | AllowShortCaseLabelsOnASingleLine: false
9 | AllowShortFunctionsOnASingleLine: None
10 | AllowShortIfStatementsOnASingleLine: false
11 | AllowShortLoopsOnASingleLine: false
12 | AlwaysBreakBeforeMultilineStrings: true
13 | AlwaysBreakTemplateDeclarations: true
14 | BinPackParameters: true
15 | BreakBeforeBinaryOperators: true
16 | BreakBeforeBraces: Stroustrup
17 | BreakBeforeTernaryOperators: false
18 | BreakConstructorInitializersBeforeComma: true
19 | ColumnLimit: 80
20 | ConstructorInitializerAllOnOneLineOrOnePerLine: true
21 | ConstructorInitializerIndentWidth: 4
22 | ContinuationIndentWidth: 2
23 | Cpp11BracedListStyle: true
24 | IndentCaseLabels: true
25 | IndentFunctionDeclarationAfterType: false
26 | IndentWidth: 2
27 | Language: Cpp
28 | MaxEmptyLinesToKeep: 1
29 | NamespaceIndentation: None
30 | PointerBindsToType: true
31 | SpaceBeforeAssignmentOperators: true
32 | SpaceInEmptyParentheses: false
33 | SpacesBeforeTrailingComments: 1
34 | SpacesInAngles: false
35 | SpacesInCStyleCastParentheses: false
36 | SpacesInParentheses: false
37 | SpacesInSquareBrackets: false
38 | Standard: Cpp11
39 | UseTab: Never
40 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled Object files
2 | *.slo
3 | *.lo
4 | *.o
5 | *.obj
6 |
7 | # Qt cache
8 | CMakeLists.txt.user
9 | CMakeLists.txt.user.*
10 |
11 | # IDE project files
12 | *.sublime-project
13 | *.sublime-workspace
14 |
15 | # Local config unix
16 | .localconfig
17 |
18 | # Precompiled Headers
19 | *.gch
20 | *.pch
21 |
22 | # Compiled Dynamic libraries
23 | *.so
24 | *.dylib
25 | *.dll
26 |
27 | # Fortran module files
28 | *.mod
29 | *.smod
30 |
31 | # Compiled Static libraries
32 | *.lai
33 | *.la
34 | *.a
35 | *.lib
36 |
37 | # Build dir
38 | build
39 | debug_build
40 | release_build
41 | /bin
42 | /install
43 | /external/dawn/dawn
44 | /external/dawn/depot_tools
45 | /external/dawn/include
46 | /external/dawn/lib
47 |
48 | # Executables
49 | *.exe
50 | *.out
51 | *.app
52 |
53 | # Dolphin files
54 | .directory
55 |
56 | # vscode
57 | .vscode/
58 |
59 | # Python cache
60 | __pycache__
61 |
62 | # Backup example files
63 | /src/examples/*.bak
64 |
65 | # Docker related files
66 | .Xauthority
67 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "assets"]
2 | path = assets
3 | url = https://github.com/samdauwe/webgpu-native-assets
4 | [submodule "external/cglm"]
5 | path = external/cglm
6 | url = https://github.com/recp/cglm
7 | [submodule "external/cgltf"]
8 | path = external/cgltf
9 | url = https://github.com/jkuhlmann/cgltf
10 | [submodule "external/cimgui"]
11 | path = external/cimgui
12 | url = https://github.com/cimgui/cimgui
13 | [submodule "external/cJSON"]
14 | path = external/cJSON
15 | url = https://github.com/DaveGamble/cJSON.git
16 |
--------------------------------------------------------------------------------
/build.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -e
4 |
5 | EXTERNAL_DIR="$PWD/external"
6 | DAWN_DIR="$EXTERNAL_DIR/dawn"
7 | BUILD_DIR="$PWD/build"
8 |
9 | DOCKER_DIR="$PWD/docker"
10 | DOCKER_NAME="docker-webgpu-native-examples:latest"
11 |
12 | update_dawn() {
13 | WORKING_DIR=`pwd`
14 |
15 | echo "---------- Updating Dawn code ----------"
16 | cd "$DAWN_DIR"
17 | /bin/bash download_dawn.sh
18 |
19 | cd "$WORKING_DIR"
20 | }
21 |
22 | webgpu_native_examples() {
23 | WORKING_DIR=`pwd`
24 |
25 | echo "---------- Building WebGPU Native Examples ----------"
26 | mkdir -p "$BUILD_DIR"
27 | cd "$BUILD_DIR"
28 | cmake .. -DCMAKE_BUILD_TYPE=Release
29 | make all -j8
30 |
31 | cd "$WORKING_DIR"
32 | }
33 |
34 | docker_build() {
35 | WORKING_DIR=`pwd`
36 |
37 | echo "---------- Building Docker image ----------"
38 | cd "$DOCKER_DIR"
39 | docker build --network host -t $DOCKER_NAME -f Dockerfile .
40 |
41 | cd "$WORKING_DIR"
42 | }
43 |
44 | docker_run() {
45 | echo "---------- Running Docker container ----------"
46 | xhost + && \
47 | docker run -it --rm --privileged \
48 | --env="DISPLAY" \
49 | --env="QT_X11_NO_MITSHM=1" \
50 | --network=host \
51 | --ipc=host \
52 | -v "$PWD":/webgpu-native-examples:rw \
53 | -v /tmp/.X11-unix:/tmp/.X11-unix:rw \
54 | -v "$HOME/.Xauthority":/webgpu-native-examples/.Xauthority:rw \
55 | -v /dev/video0:/dev/video0 \
56 | -v /dev/video1:/dev/video1 \
57 | -v /dev/video2:/dev/video2 \
58 | -v /dev/snd:/dev/snd \
59 | -w /webgpu-native-examples \
60 | $DOCKER_NAME /bin/bash && \
61 | xhost -
62 | }
63 |
64 | while [[ $# -gt 0 ]]; do case "$1" in
65 | -update_dawn)
66 | shift
67 | update_dawn
68 | ;;
69 | -webgpu_native_examples)
70 | shift
71 | webgpu_native_examples
72 | ;;
73 | -docker_build)
74 | shift
75 | docker_build
76 | ;;
77 | -docker_run)
78 | shift
79 | docker_run
80 | ;;
81 | -h|-help|--help)
82 | cat << EOF
83 | usage: $0 [options]
84 | options:
85 | -update_dawn Update to the latest version of "depot_tools" and "Dawn"
86 | -webgpu_native_examples Build WebGPU native examples
87 | -docker_build Build Docker image for running the examples
88 | -docker_run Run the Docker container with the examples
89 | -help Show help on stdout and exit
90 | EOF
91 | exit 0 ;;
92 | *) _err "Unexpected argument $1" ;;
93 | esac; done
94 |
--------------------------------------------------------------------------------
/doc/images/WebGPU_API.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/samdauwe/webgpu-native-examples/4e2f520208abd7b5c74c419440eb87b37709e28e/doc/images/WebGPU_API.png
--------------------------------------------------------------------------------
/doc/images/depth_coordinates.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/samdauwe/webgpu-native-examples/4e2f520208abd7b5c74c419440eb87b37709e28e/doc/images/depth_coordinates.png
--------------------------------------------------------------------------------
/doc/images/linuxlogo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/samdauwe/webgpu-native-examples/4e2f520208abd7b5c74c419440eb87b37709e28e/doc/images/linuxlogo.png
--------------------------------------------------------------------------------
/doc/images/render_coordinates.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/samdauwe/webgpu-native-examples/4e2f520208abd7b5c74c419440eb87b37709e28e/doc/images/render_coordinates.png
--------------------------------------------------------------------------------
/doc/images/texture_coordinates.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/samdauwe/webgpu-native-examples/4e2f520208abd7b5c74c419440eb87b37709e28e/doc/images/texture_coordinates.png
--------------------------------------------------------------------------------
/doc/images/webgpu-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/samdauwe/webgpu-native-examples/4e2f520208abd7b5c74c419440eb87b37709e28e/doc/images/webgpu-logo.png
--------------------------------------------------------------------------------
/doc/images/webgpu-logo.svg:
--------------------------------------------------------------------------------
1 |
36 |
--------------------------------------------------------------------------------
/doc/images/webgpu_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/samdauwe/webgpu-native-examples/4e2f520208abd7b5c74c419440eb87b37709e28e/doc/images/webgpu_logo.png
--------------------------------------------------------------------------------
/docker/Dockerfile:
--------------------------------------------------------------------------------
1 | # Ubuntu 20.04 (Focal Fossa)
2 | FROM ubuntu:20.04
3 |
4 | # reference : https://www.softwarepronto.com/2022/09/dockerubuntu-installing-latest-cmake-on.html
5 | RUN apt-get update \
6 | && apt-get -y install build-essential \
7 | && apt-get install -y wget \
8 | && rm -rf /var/lib/apt/lists/* \
9 | && wget https://github.com/Kitware/CMake/releases/download/v3.24.1/cmake-3.24.1-Linux-x86_64.sh \
10 | -q -O /tmp/cmake-install.sh \
11 | && chmod u+x /tmp/cmake-install.sh \
12 | && mkdir /opt/cmake-3.24.1 \
13 | && /tmp/cmake-install.sh --skip-license --prefix=/opt/cmake-3.24.1 \
14 | && rm /tmp/cmake-install.sh \
15 | && ln -s /opt/cmake-3.24.1/bin/* /usr/local/bin
16 |
17 | # Install dependencies
18 | RUN apt-get update && \
19 | DEBIAN_FRONTEND=noninteractive apt-get install -yq \
20 | sudo \
21 | wget \
22 | git ca-certificates openssl \
23 | # Dev
24 | pkg-config build-essential python3 \
25 | # X11 / XCB
26 | libxi-dev libxcursor-dev libxinerama-dev libxrandr-dev mesa-common-dev \
27 | xcb libxcb-xkb-dev x11-xkb-utils libx11-xcb-dev libxkbcommon-x11-dev \
28 | # Libav
29 | libavdevice-dev \
30 | # Vulkan
31 | libvulkan1 libvulkan-dev mesa-vulkan-drivers vulkan-utils
32 |
33 | # Remove sudoer password
34 | RUN echo "${USER} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
35 |
--------------------------------------------------------------------------------
/external/basisu/README.md:
--------------------------------------------------------------------------------
1 | see: https://github.com/BinomialLLC/basis_universal
2 |
3 | NOTE: the basisu_transcoder.cpp file has been created with basis_universal/contrib/single_file_transcoder/combine.sh:
4 |
5 | ./combine.sh -r ../../transcoder -x basisu_transcoder_tables_bc7_m6.inc -o basisu_transcoder.cpp basisu_transcoder-in.cpp
6 |
--------------------------------------------------------------------------------
/external/basisu/basisu_transcoder.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/samdauwe/webgpu-native-examples/4e2f520208abd7b5c74c419440eb87b37709e28e/external/basisu/basisu_transcoder.cpp
--------------------------------------------------------------------------------
/external/basisu/wgpu_basisu.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | /*
3 | * wgpu_basisu.h -- C-API wrapper glue code for Basis Universal
4 | */
5 | #include
6 | #include
7 |
8 | #include
9 |
10 | #if defined(__cplusplus)
11 | extern "C" {
12 | #endif
13 |
14 | /* Various compile-time constants */
15 | enum {
16 | // Basis transcode result
17 | BASIS_TRANSCODE_RESULT_SUCCESS = 0u,
18 | BASIS_TRANSCODE_RESULT_INVALID_BASIS_HEADER = 1u,
19 | BASIS_TRANSCODE_RESULT_INVALID_BASIS_DATA = 2u,
20 | BASIS_TRANSCODE_RESULT_TRANSCODE_FAILURE = 3u,
21 | BASIS_TRANSCODE_RESULT_UNSUPPORTED_TRANSCODE_FORMAT = 4u,
22 | // Upper limit(s)
23 | BASISU_MAX_MIPMAPS = 16u,
24 | };
25 |
26 | /*
27 | * basisu_data_t is a pointer-size-pair struct used to pass memory blobs.
28 | */
29 | typedef struct basisu_data_t {
30 | const void* ptr;
31 | size_t size;
32 | } basisu_data_t;
33 |
34 | typedef struct basisu_image_desc_t {
35 | WGPUTextureFormat format;
36 | uint32_t width;
37 | uint32_t height;
38 | uint32_t level_count; // Number of mipmaps
39 | basisu_data_t levels[BASISU_MAX_MIPMAPS];
40 | } basisu_image_desc_t;
41 |
42 | typedef struct basisu_transcode_result_t {
43 | uint32_t result_code;
44 | basisu_image_desc_t image_desc;
45 | } basisu_transcode_result_t;
46 |
47 | /* Basis Universal Setup/Shudown */
48 | void basisu_setup(void);
49 | void basisu_shutdown(void);
50 | bool basisu_is_initialized(void);
51 |
52 | /* Basis Universal transcoding */
53 | basisu_transcode_result_t
54 | basisu_transcode(basisu_data_t basisu_data,
55 | WGPUTextureFormat (*supported_formats)[12],
56 | uint32_t supported_format_count, bool mipmaps);
57 | void basisu_free(const basisu_image_desc_t* desc);
58 |
59 | #if defined(__cplusplus)
60 | } // extern "C"
61 | #endif
62 |
--------------------------------------------------------------------------------
/external/dawn/download_dawn.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 |
4 | ## ---------------------------------------------------------------------------------------------- #
5 | # Build script for Dawn, a WebGPU implementation.
6 | #
7 | # Uses the Chromium build system and dependency management to build Dawn from source.
8 | #
9 | # NOTE: Only works on GNU/Linux
10 | #
11 | # Ref:
12 | # https://dawn.googlesource.com/dawn
13 | # https://dawn.googlesource.com/dawn/+/HEAD/docs/building.md
14 | # ---------------------------------------------------------------------------------------------- #/
15 |
16 | GIT_DEPOT_TOOLS_URL="https://chromium.googlesource.com/chromium/tools/depot_tools.git"
17 | DAWN_URL="https://dawn.googlesource.com/dawn"
18 | DAWN_BRANCH="chromium/6370"
19 |
20 | # Get location of the script itself
21 | SOURCE="${BASH_SOURCE[0]}"
22 | while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
23 | DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
24 | SOURCE="$(readlink "$SOURCE")"
25 | [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
26 | done
27 | PROJECT_ROOT="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
28 |
29 | # Set paths
30 | DEPOT_TOOLS="$PROJECT_ROOT/depot_tools"
31 | PATH="$PATH:$DEPOT_TOOLS"
32 | DAWN_ROOT="$PROJECT_ROOT/dawn"
33 |
34 | # Utility method for creating a directory
35 | create_directory_if_not_found() {
36 | # if we cannot find the directory
37 | if [ ! -d "$1" ];
38 | then
39 | echo "$1 directory not found, creating..."
40 | mkdir -p "$1"
41 | echo "directory created at $1"
42 | fi
43 | }
44 |
45 | # Execute Ninja build
46 | exec_ninja() {
47 | echo "Running ninja"
48 | ninja -C $1 # $DAWN_TARGET
49 | }
50 |
51 | # Update/Get/Ensure the Gclient Depot Tools
52 | # Ref: http://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html#_setting_up
53 | pull_depot_tools() {
54 | WORKING_DIR=`pwd`
55 |
56 | # Either clone or get latest depot tools
57 | if [ ! -d "$DEPOT_TOOLS" ]
58 | then
59 | echo 'Make directory for gclient called Depot Tools'
60 | mkdir -p "$DEPOT_TOOLS"
61 |
62 | echo "Pull the depo tools project from chromium source into the depot tools directory"
63 | git clone $GIT_DEPOT_TOOLS_URL $DEPOT_TOOLS
64 | else
65 | echo "Change directory into the depot tools"
66 | cd "$DEPOT_TOOLS"
67 |
68 | echo "Pull the depot tools down to the latest"
69 | git pull origin main
70 | fi
71 |
72 | # Navigate back
73 | cd "$WORKING_DIR"
74 | }
75 |
76 | # Update/Get the dawn code base
77 | pull_dawn() {
78 | WORKING_DIR=`pwd`
79 |
80 | # Either clone or get latest dawn code
81 | if [ ! -d "$DAWN_ROOT" ]
82 | then
83 | echo "Make dawn directory"
84 | mkdir -p "$DAWN_ROOT"
85 |
86 | echo "Pull the latest dawn code"
87 | git clone -b $DAWN_BRANCH $DAWN_URL $DAWN_ROOT
88 | else
89 | echo "Change directory into dawn"
90 | cd "$DAWN_ROOT"
91 |
92 | echo "Pull the latest dawn code"
93 | git pull
94 | fi
95 |
96 | # Bootstrap the gclient configuration
97 | echo Bootstrap the gclient configuration
98 | cd "$DAWN_ROOT"
99 | cp scripts/standalone.gclient .gclient
100 |
101 | # Fetch external dependencies and toolchains with gclient
102 | echo "Fetch external dependencies and toolchains with gclient"
103 | echo "this can take a while..."
104 | if [ -z $1 ]
105 | then
106 | echo "gclient sync with newest"
107 | gclient sync
108 | else
109 | echo "gclient sync with $1"
110 | gclient sync -r $1
111 | fi
112 |
113 | # Navigate back
114 | cd "$WORKING_DIR"
115 | }
116 |
117 | pull_depot_tools
118 | pull_dawn
119 |
--------------------------------------------------------------------------------
/external/ktx/NOTICE.md:
--------------------------------------------------------------------------------
1 | LICENSE.md
--------------------------------------------------------------------------------
/external/ktx/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | The Official Khronos KTX Software Repository
4 | ---
5 |
6 | | GNU/Linux, iOS & OSX | Windows | Documentation |
7 | |----------------------| :------: | :-----------: |
8 | | [](https://travis-ci.org/KhronosGroup/KTX-Software) | [](https://ci.appveyor.com/project/msc-/ktx/branch/master) | [](https://codedocs.xyz/KhronosGroup/KTX-Software/) |
9 |
10 | This is the official home of the source code
11 | for the Khronos KTX library and tools. KTX is a lightweight file format
12 | for OpenGL textures, designed around how textures are loaded in OpenGL.
13 |
14 | See the Doxygen generated live documentation for
15 | [`master`](https://github.khronos.org/KTX-Software/)
16 | for API usage information.
17 |
18 | See [CONTRIBUTING](CONTRIBUTING.md) for information about contributing.
19 |
20 | See [LICENSE](LICENSE.md) for information about licensing.
21 |
22 | See [BUILDING](BUILDING.md) for information about building the code.
23 |
24 | More information about KTX and links to tools that support it can be
25 | found on the
26 | [KTX page](http://www.khronos.org/opengles/sdk/tools/KTX/) of
27 | the [OpenGL ES SDK](http://www.khronos.org/opengles/sdk) on
28 | [khronos.org](http://www.khronos.org).
29 |
30 | If you need help with using the KTX library or KTX tools, please use the
31 | [KTX forum](https://forums.khronos.org/forumdisplay.php/103-KTX-file-format-for-OpenGL-OpenGL-ES-and-WebGL-textures).
32 | To report problems use GitHub [issues](https://github.com/KhronosGroup/KTX/issues).
33 |
34 | **IMPORTANT:** you **must** install the [Git LFS](https://github.com/github/git-lfs)
35 | command line extension in order to fully checkout this repository after cloning. You
36 | need at least version 1.1.
37 |
38 | A few files have `$Date$` keywords. If you care about having the proper
39 | dates shown or will be generating the documentation or preparing
40 | distribution archives, you **must** follow the instructions below.
41 |
42 | #### $Date$ keyword expansion
43 |
44 | $Date$ keywords are expanded via a smudge & clean filter. To install
45 | the filter, issue the following commands in the root of your clone.
46 |
47 | On Unix (Linux, Mac OS X, etc.) platforms and Windows using Git for Windows'
48 | Git Bash or Cygwin's bash terminal:
49 |
50 | ```bash
51 | ./install-gitconfig.sh
52 | rm TODO.md include/ktx.h tools/toktx/toktx.cpp
53 | git checkout TODO.md include/ktx.h tools/toktx/toktx.cpp
54 | ```
55 |
56 | On Windows with the Command Prompt (requires `git.exe` in a directory
57 | on your %PATH%):
58 |
59 | ```cmd
60 | install-gitconfig.bat
61 | del TODO.md include/ktx.h tools/toktx/toktx.cpp
62 | git checkout TODO.md include/ktx.h tools/toktx/toktx.cpp
63 | ```
64 |
65 | The first command adds an [include] of the repo's `.gitconfig` to the
66 | local git config file `.git/config`, i.e. the one in your clone of the repo.
67 | `.gitconfig` contains the config of the "keyworder" filter. The remaining
68 | commands force a new checkout of the affected files to smudge them with the
69 | date. These two are unnecessary if you plan to edit these files.
70 |
71 |
--------------------------------------------------------------------------------
/external/ktx/include/ktxvulkan.h:
--------------------------------------------------------------------------------
1 | /* -*- tab-width: 4; -*- */
2 | /* vi: set sw=2 ts=4 expandtab: */
3 |
4 | #ifndef KTX_H_C54B42AEE39611E68E1E4FF8C51D1C66
5 | #define KTX_H_C54B42AEE39611E68E1E4FF8C51D1C66
6 |
7 | /*
8 | * ©2017 Mark Callow.
9 | *
10 | * Licensed under the Apache License, Version 2.0 (the "License");
11 | * you may not use this file except in compliance with the License.
12 | * You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing, software
17 | * distributed under the License is distributed on an "AS IS" BASIS,
18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 | * See the License for the specific language governing permissions and
20 | * limitations under the License.
21 | */
22 |
23 | /**
24 | * @internal
25 | * @file
26 | * @~English
27 | *
28 | * @brief Declares the public functions and structures of the
29 | * KTX Vulkan texture loading API.
30 | *
31 | * A separate header file is used to avoid extra dependencies for those not
32 | * using Vulkan. The nature of the Vulkan API, rampant structures and enums,
33 | * means that vulkan.h must be included. The alternative is duplicating
34 | * unattractively large parts of it.
35 | *
36 | * @author Mark Callow, Edgewise Consulting
37 | *
38 | * $Date$
39 | */
40 |
41 | #include
42 | #include
43 |
44 | #if 0
45 | /* Avoid Vulkan include file */
46 | #define VK_DEFINE_HANDLE(object) typedef struct object##_T* object;
47 |
48 | #if defined(__LP64__) || defined(_WIN64) || defined(__x86_64__) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__)
49 | #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef struct object##_T *object;
50 | #else
51 | #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef uint64_t object;
52 | #endif
53 |
54 | VK_DEFINE_HANDLE(VkPhysicalDevice)
55 | VK_DEFINE_HANDLE(VkDevice)
56 | VK_DEFINE_HANDLE(VkQueue)
57 | VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkCommandPool)
58 | VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDeviceMemory)
59 | VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkImage)
60 | VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkImageView)
61 | VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSampler)
62 | #endif
63 |
64 | #ifdef __cplusplus
65 | extern "C" {
66 | #endif
67 |
68 | /**
69 | * @class ktxVulkanTexture
70 | * @brief Struct for returning information about the Vulkan texture image
71 | * created by the ktxTexture_VkUpload* functions.
72 | *
73 | * Creation of these objects is internal to the upload functions.
74 | */
75 | typedef struct ktxVulkanTexture
76 | {
77 | VkImage image; /*!< Handle to the Vulkan image created by the loader. */
78 | VkFormat imageFormat; /*!< Format of the image data. */
79 | VkImageLayout imageLayout; /*!< Layout of the created image. Has the same
80 | value as @p layout parameter passed to the
81 | loader. */
82 | VkDeviceMemory deviceMemory; /*!< The memory allocated for the image on
83 | the Vulkan device. */
84 | VkImageViewType viewType; /*!< ViewType corresponding to @p image. Reflects
85 | the dimensionality, cubeness and arrayness
86 | of the image. */
87 | uint32_t width; /*!< The width of the image. */
88 | uint32_t height; /*!< The height of the image. */
89 | uint32_t depth; /*!< The depth of the image. */
90 | uint32_t levelCount; /*!< The number of MIP levels in the image. */
91 | uint32_t layerCount; /*!< The number of array layers in the image. */
92 | } ktxVulkanTexture;
93 |
94 | void
95 | ktxVulkanTexture_Destruct(ktxVulkanTexture* This, VkDevice device,
96 | const VkAllocationCallbacks* pAllocator);
97 |
98 | /**
99 | * @class ktxVulkanDeviceInfo
100 | * @brief Struct for passing information about the Vulkan device on which
101 | * to create images to the texture image loading functions.
102 | *
103 | * Avoids passing a large number of parameters to each loading function.
104 | * Use of ktxVulkanDeviceInfo_create() or ktxVulkanDeviceInfo_construct() to
105 | * populate this structure is highly recommended.
106 | *
107 | * @code
108 | ktxVulkanDeviceInfo vdi;
109 | ktxVulkanTexture texture;
110 |
111 | vdi = ktxVulkanDeviceInfo_create(physicalDevice,
112 | device,
113 | queue,
114 | cmdPool,
115 | &allocator);
116 | ktxLoadVkTextureN("texture_1.ktx", vdi, &texture, NULL, NULL);
117 | // ...
118 | ktxLoadVkTextureN("texture_n.ktx", vdi, &texture, NULL, NULL);
119 | ktxVulkanDeviceInfo_destroy(vdi);
120 | * @endcode
121 | */
122 | typedef struct ktxVulkanDeviceInfo {
123 | VkPhysicalDevice physicalDevice; /*!< Handle of the physical device. */
124 | VkDevice device; /*!< Handle of the logical device. */
125 | VkQueue queue; /*!< Handle to the queue to which to submit commands. */
126 | VkCommandBuffer cmdBuffer; /*!< Handle of the cmdBuffer to use. */
127 | /** Handle of the command pool from which to allocate the command buffer. */
128 | VkCommandPool cmdPool;
129 | /** Pointer to the allocator to use for the command buffer and created
130 | * images.
131 | */
132 | const VkAllocationCallbacks* pAllocator;
133 | /** Memory properties of the Vulkan physical device. */
134 | VkPhysicalDeviceMemoryProperties deviceMemoryProperties;
135 | } ktxVulkanDeviceInfo;
136 |
137 | ktxVulkanDeviceInfo*
138 | ktxVulkanDeviceInfo_Create(VkPhysicalDevice physicalDevice, VkDevice device,
139 | VkQueue queue, VkCommandPool cmdPool,
140 | const VkAllocationCallbacks* pAllocator);
141 | KTX_error_code
142 | ktxVulkanDeviceInfo_Construct(ktxVulkanDeviceInfo* This,
143 | VkPhysicalDevice physicalDevice, VkDevice device,
144 | VkQueue queue, VkCommandPool cmdPool,
145 | const VkAllocationCallbacks* pAllocator);
146 | void
147 | ktxVulkanDeviceInfo_Destruct(ktxVulkanDeviceInfo* This);
148 | void
149 | ktxVulkanDeviceInfo_Destroy(ktxVulkanDeviceInfo* This);
150 |
151 |
152 | KTX_error_code
153 | ktxTexture_VkUploadEx(ktxTexture* This, ktxVulkanDeviceInfo* vdi,
154 | ktxVulkanTexture* vkTexture,
155 | VkImageTiling tiling,
156 | VkImageUsageFlags usageFlags,
157 | VkImageLayout layout);
158 |
159 | KTX_error_code
160 | ktxTexture_VkUpload(ktxTexture* This, ktxVulkanDeviceInfo* vdi,
161 | ktxVulkanTexture *vkTexture);
162 |
163 | VkFormat
164 | ktxTexture_GetVkFormat(ktxTexture* This);
165 |
166 | #ifdef __cplusplus
167 | }
168 | #endif
169 |
170 | #endif /* KTX_H_A55A6F00956F42F3A137C11929827FE1 */
171 |
--------------------------------------------------------------------------------
/external/ktx/lib/checkheader.c:
--------------------------------------------------------------------------------
1 | /* -*- tab-width: 4; -*- */
2 | /* vi: set sw=2 ts=4 expandtab: */
3 |
4 | /* $Id: df002b39ae6b9b3b995e7633ff96acf0d285edcc $ */
5 |
6 | /*
7 | * ©2010-2018 The khronos Group, Inc.
8 | *
9 | * Licensed under the Apache License, Version 2.0 (the "License");
10 | * you may not use this file except in compliance with the License.
11 | * You may obtain a copy of the License at
12 | *
13 | * http://www.apache.org/licenses/LICENSE-2.0
14 | *
15 | * Unless required by applicable law or agreed to in writing, software
16 | * distributed under the License is distributed on an "AS IS" BASIS,
17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | * See the License for the specific language governing permissions and
19 | * limitations under the License.
20 | */
21 |
22 | /**
23 | * @internal
24 | * @file checkheader.c
25 | * @~English
26 | *
27 | * @brief Function to verify a KTX file header
28 | *
29 | * @author Mark Callow, HI Corporation
30 | */
31 |
32 | /*
33 | * Author: Georg Kolling, Imagination Technology with modifications
34 | * by Mark Callow, HI Corporation.
35 | */
36 | #include
37 | #include
38 |
39 | #include "ktx.h"
40 | #include "ktxint.h"
41 |
42 | /**
43 | * @internal
44 | * @~English
45 | * @brief Check a KTX file header.
46 | *
47 | * As well as checking that the header identifies a KTX file, the function
48 | * sanity checks the values and returns information about the texture in a
49 | * struct KTX_supplementary_info.
50 | *
51 | * @param pHeader pointer to the KTX header to check
52 | * @param pSuppInfo pointer to a KTX_supplementary_info structure in which to
53 | * return information about the texture.
54 | *
55 | * @author Georg Kolling, Imagination Technology
56 | * @author Mark Callow, HI Corporation
57 | */
58 | KTX_error_code _ktxCheckHeader(KTX_header* pHeader,
59 | KTX_supplemental_info* pSuppInfo)
60 | {
61 | ktx_uint8_t identifier_reference[12] = KTX_IDENTIFIER_REF;
62 | ktx_uint32_t max_dim;
63 |
64 | assert(pHeader != NULL && pSuppInfo != NULL);
65 |
66 | /* Compare identifier, is this a KTX file? */
67 | if (memcmp(pHeader->identifier, identifier_reference, 12) != 0)
68 | {
69 | return KTX_UNKNOWN_FILE_FORMAT;
70 | }
71 |
72 | if (pHeader->endianness == KTX_ENDIAN_REF_REV)
73 | {
74 | /* Convert endianness of pHeader fields. */
75 | _ktxSwapEndian32(&pHeader->glType, 12);
76 |
77 | if (pHeader->glTypeSize != 1 &&
78 | pHeader->glTypeSize != 2 &&
79 | pHeader->glTypeSize != 4)
80 | {
81 | /* Only 8-, 16-, and 32-bit types supported so far. */
82 | return KTX_FILE_DATA_ERROR;
83 | }
84 | }
85 | else if (pHeader->endianness != KTX_ENDIAN_REF)
86 | {
87 | return KTX_FILE_DATA_ERROR;
88 | }
89 |
90 | /* Check glType and glFormat */
91 | pSuppInfo->compressed = 0;
92 | if (pHeader->glType == 0 || pHeader->glFormat == 0)
93 | {
94 | if (pHeader->glType + pHeader->glFormat != 0)
95 | {
96 | /* either both or none of glType, glFormat must be zero */
97 | return KTX_FILE_DATA_ERROR;
98 | }
99 | pSuppInfo->compressed = 1;
100 | }
101 |
102 | if (pHeader->glFormat == pHeader->glInternalformat) {
103 | // glInternalFormat is either unsized (which is no longer and should
104 | // never have been supported by libktx) or glFormat is sized.
105 | return KTX_FILE_DATA_ERROR;
106 | }
107 |
108 | /* Check texture dimensions. KTX files can store 8 types of textures:
109 | 1D, 2D, 3D, cube, and array variants of these. There is currently
110 | no GL extension for 3D array textures. */
111 | if ((pHeader->pixelWidth == 0) ||
112 | (pHeader->pixelDepth > 0 && pHeader->pixelHeight == 0))
113 | {
114 | /* texture must have width */
115 | /* texture must have height if it has depth */
116 | return KTX_FILE_DATA_ERROR;
117 | }
118 |
119 |
120 | if (pHeader->pixelDepth > 0)
121 | {
122 | if (pHeader->numberOfArrayElements > 0)
123 | {
124 | /* No 3D array textures yet. */
125 | return KTX_UNSUPPORTED_TEXTURE_TYPE;
126 | }
127 | pSuppInfo->textureDimension = 3;
128 | }
129 | else if (pHeader->pixelHeight > 0)
130 | {
131 | pSuppInfo->textureDimension = 2;
132 | }
133 | else
134 | {
135 | pSuppInfo->textureDimension = 1;
136 | }
137 |
138 | if (pHeader->numberOfFaces == 6)
139 | {
140 | if (pSuppInfo->textureDimension != 2)
141 | {
142 | /* cube map needs 2D faces */
143 | return KTX_FILE_DATA_ERROR;
144 | }
145 | }
146 | else if (pHeader->numberOfFaces != 1)
147 | {
148 | /* numberOfFaces must be either 1 or 6 */
149 | return KTX_FILE_DATA_ERROR;
150 | }
151 |
152 | /* Check number of mipmap levels */
153 | if (pHeader->numberOfMipmapLevels == 0)
154 | {
155 | pSuppInfo->generateMipmaps = 1;
156 | pHeader->numberOfMipmapLevels = 1;
157 | }
158 | else
159 | {
160 | pSuppInfo->generateMipmaps = 0;
161 | }
162 |
163 | /* This test works for arrays too because height or depth will be 0. */
164 | max_dim = MAX(MAX(pHeader->pixelWidth, pHeader->pixelHeight), pHeader->pixelDepth);
165 | if (max_dim < ((ktx_uint32_t)1 << (pHeader->numberOfMipmapLevels - 1)))
166 | {
167 | /* Can't have more mip levels than 1 + log2(max(width, height, depth)) */
168 | return KTX_FILE_DATA_ERROR;
169 | }
170 |
171 | return KTX_SUCCESS;
172 | }
173 |
--------------------------------------------------------------------------------
/external/ktx/lib/errstr.c:
--------------------------------------------------------------------------------
1 | /* -*- tab-width: 4; -*- */
2 | /* vi: set sw=2 ts=4 expandtab: */
3 |
4 | /* $Id: 11f526c2587823b49cde3b437746e95b57e3200e $ */
5 |
6 | /*
7 | * ©2010-2018 The khronos Group, Inc.
8 | *
9 | * Licensed under the Apache License, Version 2.0 (the "License");
10 | * you may not use this file except in compliance with the License.
11 | * You may obtain a copy of the License at
12 | *
13 | * http://www.apache.org/licenses/LICENSE-2.0
14 | *
15 | * Unless required by applicable law or agreed to in writing, software
16 | * distributed under the License is distributed on an "AS IS" BASIS,
17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | * See the License for the specific language governing permissions and
19 | * limitations under the License.
20 | */
21 |
22 | /**
23 | * @file errstr.c
24 | * @~English
25 | *
26 | * @brief Function to return a string corresponding to a KTX error code.
27 | *
28 | * @author Mark Callow, HI Corporation
29 | */
30 |
31 | #include "ktx.h"
32 |
33 | static const char* const errorStrings[] = {
34 | "Operation succeeded", /* KTX_SUCCESS */
35 | "File data is inconsistent with KTX spec.", /* KTX_FILE_DATA_ERROR */
36 | "File open failed", /* KTX_FILE_OPEN_FAILED */
37 | "Operation would exceed the max file size", /* KTX_FILE_OVERFLOW */
38 | "File read error", /* KTX_FILE_READ_ERROR */
39 | "File seek error", /* KTX_FILE_SEEK_ERROR */
40 | "File does not have enough data for request", /* KTX_FILE_UNEXPECTED_EOF */
41 | "File write error", /* KTX_FILE_WRITE_ERROR */
42 | "GL error occurred", /* KTX_GL_ERROR */
43 | "Operation not allowed in the current state", /* KTX_INVALID_OPERATION */
44 | "Invalid parameter value", /* KTX_INVALID_VALUE */
45 | "Key not found", /* KTX_NOT_FOUND */
46 | "Out of memory", /* KTX_OUT_OF_MEMORY */
47 | "Not a KTX file", /* KTX_UNKNOWN_FILE_FORMAT */
48 | "Texture type not supported by GL context" /* KTX_UNSUPPORTED_TEXTURE_TYPE */
49 | };
50 | static const int lastErrorCode = (sizeof(errorStrings) / sizeof(char*)) - 1;
51 |
52 |
53 | /**
54 | * @~English
55 | * @brief Return a string corresponding to a KTX error code.
56 | *
57 | * @param error the error code for which to return a string
58 | *
59 | * @return pointer to the message string.
60 | *
61 | * @internal Use UTF-8 for translated message strings.
62 | *
63 | * @author Mark Callow, HI Corporation
64 | */
65 | const char* const ktxErrorString(KTX_error_code error)
66 | {
67 | if (error > lastErrorCode)
68 | return "Unrecognized error code";
69 | return errorStrings[error];
70 | }
71 |
--------------------------------------------------------------------------------
/external/ktx/lib/filestream.h:
--------------------------------------------------------------------------------
1 | /* -*- tab-width: 4; -*- */
2 | /* vi: set sw=2 ts=4 expandtab: */
3 |
4 | /*
5 | * ©2010-2018 The khronos Group, Inc.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 |
20 | /*
21 | * Author: Maksim Kolesin from original code
22 | * by Mark Callow and Georg Kolling
23 | */
24 |
25 | #ifndef FILESTREAM_H
26 | #define FILESTREAM_H
27 |
28 | #include "ktx.h"
29 | #include "stream.h"
30 |
31 | /*
32 | * ktxFileInit: Initialize a ktxStream to a ktxFileStream with a FILE object
33 | */
34 | KTX_error_code ktxFileStream_construct(ktxStream* str, FILE* file,
35 | ktx_bool_t closeFileOnDestruct);
36 |
37 | void ktxFileStream_destruct(ktxStream* str);
38 |
39 | #endif /* FILESTREAM_H */
40 |
--------------------------------------------------------------------------------
/external/ktx/lib/gl_funcptrs.h:
--------------------------------------------------------------------------------
1 | /* -*- tab-width: 4; -*- */
2 | /* vi: set sw=2 ts=4 expandtab: */
3 |
4 | /* $Id: c29f4818e74655d62754e26efdab99cb2d2ca638 $ */
5 |
6 | /*
7 | * ©2010-2017 The khronos Group, Inc.
8 | *
9 | * Licensed under the Apache License, Version 2.0 (the "License");
10 | * you may not use this file except in compliance with the License.
11 | * You may obtain a copy of the License at
12 | *
13 | * http://www.apache.org/licenses/LICENSE-2.0
14 | *
15 | * Unless required by applicable law or agreed to in writing, software
16 | * distributed under the License is distributed on an "AS IS" BASIS,
17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | * See the License for the specific language governing permissions and
19 | * limitations under the License.
20 | */
21 |
22 | /*
23 | * Author: Mark Callow based on code from Georg Kolling
24 | */
25 |
26 | #ifndef GL_FUNCPTRS_H
27 | #define GL_FUNCPTRS_H
28 |
29 | #ifdef __cplusplus
30 | extern "C" {
31 | #endif
32 |
33 | #if KTX_USE_GETPROC
34 | // Not defined in glew.h.
35 | typedef void (GL_APIENTRY* PFNGLTEXIMAGE1DPROC) (
36 | GLenum target, GLint level, GLint internalformat,
37 | GLsizei width, GLint border, GLenum format, GLenum type,
38 | const GLvoid *pixels
39 | );
40 | #endif
41 |
42 | extern PFNGLTEXIMAGE1DPROC pfGlTexImage1D;
43 | extern PFNGLTEXIMAGE3DPROC pfGlTexImage3D;
44 | extern PFNGLCOMPRESSEDTEXIMAGE1DPROC pfGlCompressedTexImage1D;
45 | extern PFNGLCOMPRESSEDTEXIMAGE3DPROC pfGlCompressedTexImage3D;
46 | extern PFNGLGENERATEMIPMAPPROC pfGlGenerateMipmap;
47 | extern PFNGLGETSTRINGIPROC pfGlGetStringi;
48 |
49 | #define DECLARE_GL_FUNCPTRS \
50 | PFNGLTEXIMAGE1DPROC pfGlTexImage1D; \
51 | PFNGLTEXIMAGE3DPROC pfGlTexImage3D; \
52 | PFNGLCOMPRESSEDTEXIMAGE1DPROC pfGlCompressedTexImage1D; \
53 | PFNGLCOMPRESSEDTEXIMAGE3DPROC pfGlCompressedTexImage3D; \
54 | PFNGLGENERATEMIPMAPPROC pfGlGenerateMipmap; \
55 | PFNGLGETSTRINGIPROC pfGlGetStringi;
56 |
57 | #define INITIALIZE_GL_FUNCPTRS \
58 | pfGlTexImage1D = glTexImage1D; \
59 | pfGlTexImage3D = glTexImage3D; \
60 | pfGlCompressedTexImage1D = glCompressedTexImage1D; \
61 | pfGlCompressedTexImage3D = glCompressedTexImage3D; \
62 | pfGlGenerateMipmap = glGenerateMipmap; \
63 | pfGlGetStringi = glGetStringi;
64 |
65 | #ifdef __cplusplus
66 | }
67 | #endif
68 |
69 | #endif /* GL_FUNCPTRS_H */
70 |
--------------------------------------------------------------------------------
/external/ktx/lib/gles1_funcptrs.h:
--------------------------------------------------------------------------------
1 | /* -*- tab-width: 4; -*- */
2 | /* vi: set sw=2 ts=4 expandtab: */
3 |
4 | /* $Id: a9dea3dfe7b8266c56bd790f15e03e8e7e1baa8e $ */
5 |
6 | /*
7 | * ©2010-2017 The khronos Group, Inc.
8 | *
9 | * Licensed under the Apache License, Version 2.0 (the "License");
10 | * you may not use this file except in compliance with the License.
11 | * You may obtain a copy of the License at
12 | *
13 | * http://www.apache.org/licenses/LICENSE-2.0
14 | *
15 | * Unless required by applicable law or agreed to in writing, software
16 | * distributed under the License is distributed on an "AS IS" BASIS,
17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | * See the License for the specific language governing permissions and
19 | * limitations under the License.
20 | */
21 |
22 | /*
23 | * Author: Mark Callow based on code from Georg Kolling
24 | */
25 |
26 | #ifndef GLES1_FUNCPTRS_H
27 | #define GLES1_FUNCPTRS_H
28 |
29 | #ifdef __cplusplus
30 | extern "C" {
31 | #endif
32 |
33 | /* remove these where already defined as typedefs (GCC 4 complains of duplicate definitions) */
34 | typedef void (GL_APIENTRY* PFNGLTEXIMAGE1DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
35 | typedef void (GL_APIENTRY* PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
36 | typedef void (GL_APIENTRY* PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data);
37 | typedef void (GL_APIENTRY* PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);
38 | typedef void (GL_APIENTRY* PFNGLGENERATEMIPMAPPROC) (GLenum target);
39 | typedef const GLubyte* (GL_APIENTRY* PFNGLGETSTRINGIPROC) (GLenum name, GLint index);
40 |
41 | extern PFNGLTEXIMAGE1DPROC pfGlTexImage1D;
42 | extern PFNGLTEXIMAGE3DPROC pfGlTexImage3D;
43 | extern PFNGLCOMPRESSEDTEXIMAGE1DPROC pfGlCompressedTexImage1D;
44 | extern PFNGLCOMPRESSEDTEXIMAGE3DPROC pfGlCompressedTexImage3D;
45 | extern PFNGLGENERATEMIPMAPPROC pfGlGenerateMipmap;
46 | extern PFNGLGETSTRINGIPROC pfGlGetStringi;
47 |
48 | #define DECLARE_GL_FUNCPTRS \
49 | PFNGLTEXIMAGE1DPROC pfGlTexImage1D; \
50 | PFNGLTEXIMAGE3DPROC pfGlTexImage3D; \
51 | PFNGLCOMPRESSEDTEXIMAGE1DPROC pfGlCompressedTexImage1D; \
52 | PFNGLCOMPRESSEDTEXIMAGE3DPROC pfGlCompressedTexImage3D; \
53 | PFNGLGENERATEMIPMAPPROC pfGlGenerateMipmap; \
54 | PFNGLGETSTRINGIPROC pfGlGetStringi;
55 |
56 | #define INITIALIZE_GL_FUNCPTRS \
57 | pfGlTexImage1D = 0; \
58 | pfGlTexImage3D = 0; \
59 | pfGlCompressedTexImage1D = 0; \
60 | pfGlCompressedTexImage3D = 0; \
61 | pfGlGenerateMipmap = 0; \
62 | pfGlGetStringi = 0;
63 |
64 | #ifdef __cplusplus
65 | }
66 | #endif
67 |
68 | #endif /* GLES1_FUNCPTRS_H */
69 |
--------------------------------------------------------------------------------
/external/ktx/lib/gles2_funcptrs.h:
--------------------------------------------------------------------------------
1 | /* -*- tab-width: 4; -*- */
2 | /* vi: set sw=2 ts=4 expandtab: */
3 |
4 | /* $Id: f780b88290b1aa6df0104020b75e21904e53ff1c $ */
5 |
6 | /*
7 | * ©2010-2017 The khronos Group, Inc.
8 | *
9 | * Licensed under the Apache License, Version 2.0 (the "License");
10 | * you may not use this file except in compliance with the License.
11 | * You may obtain a copy of the License at
12 | *
13 | * http://www.apache.org/licenses/LICENSE-2.0
14 | *
15 | * Unless required by applicable law or agreed to in writing, software
16 | * distributed under the License is distributed on an "AS IS" BASIS,
17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | * See the License for the specific language governing permissions and
19 | * limitations under the License.
20 | */
21 |
22 | /*
23 | * Author: Mark Callow based on code from Georg Kolling
24 | */
25 |
26 | #ifndef GLES2_FUNCPTRS_H
27 | #define GLES2_FUNCPTRS_H
28 |
29 | #ifdef __cplusplus
30 | extern "C" {
31 | #endif
32 |
33 | /* remove these where already defined as typedefs (GCC 4 complains of duplicate definitions) */
34 | typedef void (GL_APIENTRY* PFNGLTEXIMAGE1DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
35 | typedef void (GL_APIENTRY* PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
36 | typedef void (GL_APIENTRY* PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data);
37 | typedef void (GL_APIENTRY* PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);
38 | typedef const GLubyte* (GL_APIENTRY* PFNGLGETSTRINGIPROC) (GLenum name, GLuint index);
39 |
40 | extern PFNGLTEXIMAGE1DPROC pfGlTexImage1D;
41 | extern PFNGLTEXIMAGE3DPROC pfGlTexImage3D;
42 | extern PFNGLCOMPRESSEDTEXIMAGE1DPROC pfGlCompressedTexImage1D;
43 | extern PFNGLCOMPRESSEDTEXIMAGE3DPROC pfGlCompressedTexImage3D;
44 | extern PFNGLGENERATEMIPMAPPROC pfGlGenerateMipmap;
45 | extern PFNGLGETSTRINGIPROC pfGlGetStringi;
46 |
47 | #define DECLARE_GL_FUNCPTRS \
48 | PFNGLTEXIMAGE1DPROC pfGlTexImage1D; \
49 | PFNGLTEXIMAGE3DPROC pfGlTexImage3D; \
50 | PFNGLCOMPRESSEDTEXIMAGE1DPROC pfGlCompressedTexImage1D; \
51 | PFNGLCOMPRESSEDTEXIMAGE3DPROC pfGlCompressedTexImage3D; \
52 | PFNGLGENERATEMIPMAPPROC pfGlGenerateMipmap; \
53 | PFNGLGETSTRINGIPROC pfGlGetStringi;
54 |
55 | #define INITIALIZE_GL_FUNCPTRS \
56 | pfGlTexImage1D = 0; \
57 | pfGlTexImage3D = 0; \
58 | pfGlCompressedTexImage1D = 0; \
59 | pfGlCompressedTexImage3D = 0; \
60 | pfGlGenerateMipmap = glGenerateMipmap; \
61 | pfGlGetStringi = 0;
62 |
63 | #ifdef __cplusplus
64 | }
65 | #endif
66 |
67 | #endif /* GLES2_FUNCPTRS_H */
68 |
--------------------------------------------------------------------------------
/external/ktx/lib/gles3_funcptrs.h:
--------------------------------------------------------------------------------
1 | /* -*- tab-width: 4; -*- */
2 | /* vi: set sw=2 ts=4 expandtab: */
3 |
4 | /* $Id: 81315679d0a7bf28f92251adeb0cfea199e013fe $ */
5 |
6 | /*
7 | * ©2010-2017 The khronos Group, Inc.
8 | *
9 | * Licensed under the Apache License, Version 2.0 (the "License");
10 | * you may not use this file except in compliance with the License.
11 | * You may obtain a copy of the License at
12 | *
13 | * http://www.apache.org/licenses/LICENSE-2.0
14 | *
15 | * Unless required by applicable law or agreed to in writing, software
16 | * distributed under the License is distributed on an "AS IS" BASIS,
17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | * See the License for the specific language governing permissions and
19 | * limitations under the License.
20 | */
21 |
22 | /*
23 | * Author: Mark Callow based on code from Georg Kolling
24 | */
25 |
26 | #ifndef GLES3_FUNCPTRS_H
27 | #define GLES3_FUNCPTRS_H
28 |
29 | #ifdef __cplusplus
30 | extern "C" {
31 | #endif
32 |
33 | /* remove these where already defined as typedefs */
34 | typedef void (GL_APIENTRY* PFNGLTEXIMAGE1DPROC) (
35 | GLenum target, GLint level, GLint internalformat,
36 | GLsizei width, GLint border, GLenum format,
37 | GLenum type, const GLvoid *pixels
38 | );
39 | typedef void (GL_APIENTRY* PFNGLCOMPRESSEDTEXIMAGE1DPROC) (
40 | GLenum target, GLint level, GLenum internalformat,
41 | GLsizei width, GLint border, GLsizei imageSize,
42 | const GLvoid *data
43 | );
44 |
45 | extern PFNGLTEXIMAGE1DPROC pfGlTexImage1D;
46 | extern PFNGLTEXIMAGE3DPROC pfGlTexImage3D;
47 | extern PFNGLCOMPRESSEDTEXIMAGE1DPROC pfGlCompressedTexImage1D;
48 | extern PFNGLCOMPRESSEDTEXIMAGE3DPROC pfGlCompressedTexImage3D;
49 | extern PFNGLGENERATEMIPMAPPROC pfGlGenerateMipmap;
50 | extern PFNGLGETSTRINGIPROC pfGlGetStringi;
51 |
52 | #define DECLARE_GL_FUNCPTRS \
53 | PFNGLTEXIMAGE1DPROC pfGlTexImage1D; \
54 | PFNGLTEXIMAGE3DPROC pfGlTexImage3D; \
55 | PFNGLCOMPRESSEDTEXIMAGE1DPROC pfGlCompressedTexImage1D; \
56 | PFNGLCOMPRESSEDTEXIMAGE3DPROC pfGlCompressedTexImage3D; \
57 | PFNGLGENERATEMIPMAPPROC pfGlGenerateMipmap; \
58 | PFNGLGETSTRINGIPROC pfGlGetStringi;
59 |
60 | #define INITIALIZE_GL_FUNCPTRS \
61 | pfGlTexImage1D = 0; \
62 | pfGlTexImage3D = glTexImage3D; \
63 | pfGlCompressedTexImage1D = 0; \
64 | pfGlCompressedTexImage3D = glCompressedTexImage3D; \
65 | pfGlGenerateMipmap = glGenerateMipmap; \
66 | pfGlGetStringi = glGetStringi;
67 |
68 | #ifdef __cplusplus
69 | }
70 | #endif
71 |
72 | #endif /* GLES3_FUNCPTRS_H */
73 |
--------------------------------------------------------------------------------
/external/ktx/lib/hashtable.c:
--------------------------------------------------------------------------------
1 | /* -*- tab-width: 4; -*- */
2 | /* vi: set sw=2 ts=4 expandtab: */
3 |
4 | /**
5 | * @internal
6 | * @file hashtable.c
7 | * @~English
8 | *
9 | * @brief Functions for backward compatibility with libktx v1
10 | * hashtable API.
11 | *
12 | * @author Mark Callow, www.edgewise-consulting.com
13 | */
14 |
15 | /*
16 | * ©2018 Mark Callow.
17 | *
18 | * Licensed under the Apache License, Version 2.0 (the "License");
19 | * you may not use this file except in compliance with the License.
20 | * You may obtain a copy of the License at
21 | *
22 | * http://www.apache.org/licenses/LICENSE-2.0
23 | *
24 | * Unless required by applicable law or agreed to in writing, software
25 | * distributed under the License is distributed on an "AS IS" BASIS,
26 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
27 | * See the License for the specific language governing permissions and
28 | * limitations under the License.
29 | */
30 |
31 |
32 | #include "ktx.h"
33 |
34 | /**
35 | * @memberof KTX_hash_table
36 | * @~English
37 | * @deprecated Use ktxHashList_Create().
38 | */
39 | KTX_hash_table
40 | ktxHashTable_Create(void) {
41 | ktxHashList* hl;
42 | (void)ktxHashList_Create(&hl);
43 | return hl;
44 | }
45 |
46 | /**
47 | * @memberof KTX_hash_table
48 | * @~English
49 | * @deprecated Use ktxHashList_Serialize().
50 | * @brief Serializes the hash table to a block of memory suitable for
51 | * writing to a KTX file.
52 | */
53 | KTX_error_code
54 | ktxHashTable_Serialize(KTX_hash_table This,
55 | unsigned int* kvdLen, unsigned char** kvd)
56 | {
57 | return ktxHashList_Serialize(This, kvdLen, kvd);
58 | }
59 |
60 | /**
61 | * @memberof KTX_hash_table
62 | * @deprecated Use ktxHashList_Deserialize().
63 | * @~English
64 | * @brief Create a new hash table from a block of serialized key-value
65 | * data read from a file.
66 | *
67 | * The caller is responsible for freeing the returned hash table.
68 | *
69 | * @note The bytes of the 32-bit key-value lengths within the serialized data
70 | * are expected to be in native endianness.
71 | *
72 | * @param[in] kvdLen the length of the serialized key-value data.
73 | * @param[in] pKvd pointer to the serialized key-value data.
74 | * @param[in,out] pHt @p *pHt is set to point to the created hash
75 | * table.
76 | *
77 | * @return KTX_SUCCESS or one of the following error codes.
78 | *
79 | * @exception KTX_INVALID_VALUE if @p pKvd or @p pHt is NULL or kvdLen == 0.
80 | * @exception KTX_OUT_OF_MEMORY there was not enough memory to create the hash
81 | * table.
82 | */
83 | KTX_error_code
84 | ktxHashTable_Deserialize(unsigned int kvdLen, void* pKvd, KTX_hash_table* pHt)
85 | {
86 | ktxHashList* pHl;
87 | KTX_error_code result;
88 | result = ktxHashList_Create(&pHl);
89 | if (result != KTX_SUCCESS)
90 | return result;
91 |
92 | result = ktxHashList_Deserialize(pHl, kvdLen, pKvd);
93 | if (result == KTX_SUCCESS)
94 | *pHt = pHl;
95 | return result;
96 | }
97 |
98 |
--------------------------------------------------------------------------------
/external/ktx/lib/ktxgl.h:
--------------------------------------------------------------------------------
1 | /* -*- tab-width: 4; -*- */
2 | /* vi: set sw=2 ts=4 expandtab: */
3 |
4 | /* $Id: 94277b50a14992fc9e5a6e011ef5f9cdf28f0d89 $ */
5 |
6 | /*
7 | * Copyright (c) 2010-2018 The Khronos Group Inc.
8 | *
9 | * Licensed under the Apache License, Version 2.0 (the "License");
10 | * you may not use this file except in compliance with the License.
11 | * You may obtain a copy of the License at
12 | *
13 | * http://www.apache.org/licenses/LICENSE-2.0
14 | *
15 | * Unless required by applicable law or agreed to in writing, software
16 | * distributed under the License is distributed on an "AS IS" BASIS,
17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | * See the License for the specific language governing permissions and
19 | * limitations under the License.
20 | */
21 |
22 |
23 | /*
24 | * Author: Mark Callow from original code by Georg Kolling
25 | */
26 |
27 | #ifndef KTXGL_H
28 | #define KTXGL_H
29 |
30 | #ifndef SUPPORT_LEGACY_FORMAT_CONVERSION
31 | #if KTX_OPENGL
32 | #define SUPPORT_LEGACY_FORMAT_CONVERSION 1
33 | #elif KTX_OPENGL_ES1
34 | /* ES1, ES2 & ES3 support the legacy formats */
35 | #define SUPPORT_LEGACY_FORMAT_CONVERSION 0
36 | #endif
37 | #endif
38 |
39 | #ifdef __cplusplus
40 | extern "C" {
41 | #endif
42 |
43 | /*
44 | * These defines are needed to compile the KTX library. When
45 | * these things are not available in the GL header in use at
46 | * compile time, the library provides its own support, handles
47 | * the expected run-time errors or just needs the token value.
48 | */
49 | #ifndef GL_LUMINANCE
50 | #define GL_ALPHA 0x1906
51 | #define GL_LUMINANCE 0x1909
52 | #define GL_LUMINANCE_ALPHA 0x190A
53 | #endif
54 | #ifndef GL_INTENSITY
55 | #define GL_INTENSITY 0x8049
56 | #endif
57 | #if SUPPORT_LEGACY_FORMAT_CONVERSION
58 | /* For loading legacy KTX files. */
59 | #ifndef GL_LUMINANCE4
60 | #define GL_ALPHA4 0x803B
61 | #define GL_ALPHA8 0x803C
62 | #define GL_ALPHA12 0x803D
63 | #define GL_ALPHA16 0x803E
64 | #define GL_LUMINANCE4 0x803F
65 | #define GL_LUMINANCE8 0x8040
66 | #define GL_LUMINANCE12 0x8041
67 | #define GL_LUMINANCE16 0x8042
68 | #define GL_LUMINANCE4_ALPHA4 0x8043
69 | #define GL_LUMINANCE6_ALPHA2 0x8044
70 | #define GL_LUMINANCE8_ALPHA8 0x8045
71 | #define GL_LUMINANCE12_ALPHA4 0x8046
72 | #define GL_LUMINANCE12_ALPHA12 0x8047
73 | #define GL_LUMINANCE16_ALPHA16 0x8048
74 | #endif
75 | #ifndef GL_INTENSITY4
76 | #define GL_INTENSITY4 0x804A
77 | #define GL_INTENSITY8 0x804B
78 | #define GL_INTENSITY12 0x804C
79 | #define GL_INTENSITY16 0x804D
80 | #endif
81 | #ifndef GL_SLUMINANCE
82 | #define GL_SLUMINANCE_ALPHA 0x8C44
83 | #define GL_SLUMINANCE8_ALPHA8 0x8C45
84 | #define GL_SLUMINANCE 0x8C46
85 | #define GL_SLUMINANCE8 0x8C47
86 | #endif
87 | #endif /* SUPPORT_LEGACY_FORMAT_CONVERSION */
88 | #ifndef GL_TEXTURE_1D
89 | #define GL_TEXTURE_1D 0x0DE0
90 | #endif
91 | #ifndef GL_TEXTURE_3D
92 | #define GL_TEXTURE_3D 0x806F
93 | #endif
94 | #ifndef GL_TEXTURE_CUBE_MAP
95 | #define GL_TEXTURE_CUBE_MAP 0x8513
96 | #define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515
97 | #endif
98 | #ifndef GL_TEXTURE_CUBE_MAP_ARRAY
99 | #define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009
100 | #endif
101 | /* from GL_EXT_texture_array */
102 | #ifndef GL_TEXTURE_1D_ARRAY_EXT
103 | #define GL_TEXTURE_1D_ARRAY_EXT 0x8C18
104 | #define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A
105 | #endif
106 | #ifndef GL_GENERATE_MIPMAP
107 | #define GL_GENERATE_MIPMAP 0x8191
108 | #endif
109 |
110 | /* For writer.c */
111 | #if !defined(GL_BGR)
112 | #define GL_BGR 0x80E0
113 | #define GL_BGRA 0x80E1
114 | #endif
115 | #if !defined(GL_RED_INTEGER)
116 | #define GL_RED_INTEGER 0x8D94
117 | #define GL_RGB_INTEGER 0x8D98
118 | #define GL_RGBA_INTEGER 0x8D99
119 | #endif
120 | #if !defined(GL_GREEN_INTEGER)
121 | #define GL_GREEN_INTEGER 0x8D95
122 | #define GL_BLUE_INTEGER 0x8D96
123 | #endif
124 | #if !defined(GL_ALPHA_INTEGER)
125 | #define GL_ALPHA_INTEGER 0x8D97
126 | #endif
127 | #if !defined (GL_BGR_INTEGER)
128 | #define GL_BGR_INTEGER 0x8D9A
129 | #define GL_BGRA_INTEGER 0x8D9B
130 | #endif
131 | #if !defined(GL_INT)
132 | #define GL_INT 0x1404
133 | #define GL_UNSIGNED_INT 0x1405
134 | #endif
135 | #if !defined(GL_HALF_FLOAT)
136 | typedef unsigned short GLhalf;
137 | #define GL_HALF_FLOAT 0x140B
138 | #endif
139 | #if !defined(GL_UNSIGNED_BYTE_3_3_2)
140 | #define GL_UNSIGNED_BYTE_3_3_2 0x8032
141 | #define GL_UNSIGNED_INT_8_8_8_8 0x8035
142 | #define GL_UNSIGNED_INT_10_10_10_2 0x8036
143 | #endif
144 | #if !defined(GL_UNSIGNED_BYTE_2_3_3_REV)
145 | #define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362
146 | #define GL_UNSIGNED_SHORT_5_6_5 0x8363
147 | #define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364
148 | #define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365
149 | #define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366
150 | #define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367
151 | #define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368
152 | #endif
153 | #if !defined(GL_UNSIGNED_INT_24_8)
154 | #define GL_DEPTH_STENCIL 0x84F9
155 | #define GL_UNSIGNED_INT_24_8 0x84FA
156 | #endif
157 | #if !defined(GL_UNSIGNED_INT_5_9_9_9_REV)
158 | #define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E
159 | #endif
160 | #if !defined(GL_UNSIGNED_INT_10F_11F_11F_REV)
161 | #define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B
162 | #endif
163 | #if !defined (GL_FLOAT_32_UNSIGNED_INT_24_8_REV)
164 | #define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD
165 | #endif
166 |
167 | #ifndef GL_ETC1_RGB8_OES
168 | #define GL_ETC1_RGB8_OES 0x8D64
169 | #endif
170 |
171 | #if SUPPORT_SOFTWARE_ETC_UNPACK
172 | #ifndef GL_COMPRESSED_R11_EAC
173 | #define GL_COMPRESSED_R11_EAC 0x9270
174 | #define GL_COMPRESSED_SIGNED_R11_EAC 0x9271
175 | #define GL_COMPRESSED_RG11_EAC 0x9272
176 | #define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273
177 | #define GL_COMPRESSED_RGB8_ETC2 0x9274
178 | #define GL_COMPRESSED_SRGB8_ETC2 0x9275
179 | #define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276
180 | #define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277
181 | #define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278
182 | #define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279
183 | #endif
184 | #ifndef GL_R16_SNORM
185 | #define GL_R16_SNORM 0x8F98
186 | #define GL_RG16_SNORM 0x8F99
187 | #endif
188 | #ifndef GL_RED
189 | #define GL_RED 0x1903
190 | #define GL_GREEN 0x1904
191 | #define GL_BLUE 0x1905
192 | #define GL_RG 0x8227
193 | #define GL_RG_INTEGER 0x8228
194 | #endif
195 | #ifndef GL_R16
196 | #define GL_R16 0x822A
197 | #define GL_RG16 0x822C
198 | #endif
199 | #ifndef GL_RGB8
200 | #define GL_RGB8 0x8051
201 | #define GL_RGBA8 0x8058
202 | #endif
203 | #ifndef GL_SRGB8
204 | #define GL_SRGB8 0x8C41
205 | #define GL_SRGB8_ALPHA8 0x8C43
206 | #endif
207 | #endif
208 |
209 | #ifndef GL_MAJOR_VERSION
210 | #define GL_MAJOR_VERSION 0x821B
211 | #define GL_MINOR_VERSION 0x821C
212 | #endif
213 |
214 | #ifndef GL_CONTEXT_PROFILE_MASK
215 | #define GL_CONTEXT_PROFILE_MASK 0x9126
216 | #define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001
217 | #define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002
218 | #endif
219 |
220 | #ifndef GL_NUM_EXTENSIONS
221 | #define GL_NUM_EXTENSIONS 0x821D
222 | #endif
223 |
224 | #ifdef __cplusplus
225 | }
226 | #endif
227 |
228 | #endif /* KTXGL_H */
229 |
--------------------------------------------------------------------------------
/external/ktx/lib/ktxint.h:
--------------------------------------------------------------------------------
1 | /* -*- tab-width: 4; -*- */
2 | /* vi: set sw=2 ts=4 expandtab: */
3 |
4 | /* $Id: 3dd768b381113d67ca7e4bde10e6252900bff845 $ */
5 |
6 | /*
7 | * Copyright (c) 2010-2018 The Khronos Group Inc.
8 | *
9 | * Licensed under the Apache License, Version 2.0 (the "License");
10 | * you may not use this file except in compliance with the License.
11 | * You may obtain a copy of the License at
12 | *
13 | * http://www.apache.org/licenses/LICENSE-2.0
14 | *
15 | * Unless required by applicable law or agreed to in writing, software
16 | * distributed under the License is distributed on an "AS IS" BASIS,
17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | * See the License for the specific language governing permissions and
19 | * limitations under the License.
20 | */
21 |
22 |
23 | /*
24 | * Author: Mark Callow from original code by Georg Kolling
25 | */
26 |
27 | #ifndef KTXINT_H
28 | #define KTXINT_H
29 |
30 | /* Define this to include the ETC unpack software in the library. */
31 | #ifndef SUPPORT_SOFTWARE_ETC_UNPACK
32 | /* Include for all GL versions because have seen OpenGL ES 3
33 | * implementaions that do not support ETC1 (ARM Mali emulator v1.0)!
34 | */
35 | #define SUPPORT_SOFTWARE_ETC_UNPACK 1
36 | #endif
37 |
38 | #ifndef MAX
39 | #define MAX(x, y) (((x) > (y)) ? (x) : (y))
40 | #endif
41 |
42 | #define KTX2_IDENTIFIER_REF { 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x32, 0x30, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A }
43 | #define KTX2_HEADER_SIZE (64)
44 |
45 | #ifdef __cplusplus
46 | extern "C" {
47 | #endif
48 |
49 | /**
50 | * @internal
51 | * @brief used to pass GL context capabilites to subroutines.
52 | */
53 | #define _KTX_NO_R16_FORMATS 0x0
54 | #define _KTX_R16_FORMATS_NORM 0x1
55 | #define _KTX_R16_FORMATS_SNORM 0x2
56 | #define _KTX_ALL_R16_FORMATS (_KTX_R16_FORMATS_NORM | _KTX_R16_FORMATS_SNORM)
57 | extern GLint _ktxR16Formats;
58 | extern GLboolean _ktxSupportsSRGB;
59 |
60 | /**
61 | * @internal
62 | * @~English
63 | * @brief KTX file header
64 | *
65 | * See the KTX specification for descriptions
66 | */
67 | typedef struct KTX_header {
68 | ktx_uint8_t identifier[12];
69 | ktx_uint32_t endianness;
70 | ktx_uint32_t glType;
71 | ktx_uint32_t glTypeSize;
72 | ktx_uint32_t glFormat;
73 | ktx_uint32_t glInternalformat;
74 | ktx_uint32_t glBaseInternalformat;
75 | ktx_uint32_t pixelWidth;
76 | ktx_uint32_t pixelHeight;
77 | ktx_uint32_t pixelDepth;
78 | ktx_uint32_t numberOfArrayElements;
79 | ktx_uint32_t numberOfFaces;
80 | ktx_uint32_t numberOfMipmapLevels;
81 | ktx_uint32_t bytesOfKeyValueData;
82 | } KTX_header;
83 |
84 | /* This will cause compilation to fail if the struct size doesn't match */
85 | typedef int KTX_header_SIZE_ASSERT [sizeof(KTX_header) == KTX_HEADER_SIZE];
86 |
87 | /**
88 | * @internal
89 | * @~English
90 | * @brief Structure for supplemental information about the texture.
91 | *
92 | * _ktxCheckHeader returns supplemental information about the texture in this
93 | * structure that is derived during checking of the file header.
94 | */
95 | typedef struct KTX_supplemental_info
96 | {
97 | ktx_uint8_t compressed;
98 | ktx_uint8_t generateMipmaps;
99 | ktx_uint16_t textureDimension;
100 | } KTX_supplemental_info;
101 | /**
102 | * @internal
103 | * @var ktx_uint8_t KTX_supplemental_info::compressed
104 | * @~English
105 | * @brief KTX_TRUE, if this a compressed texture, KTX_FALSE otherwise?
106 | */
107 | /**
108 | * @internal
109 | * @var ktx_uint8_t KTX_supplemental_info::generateMipmaps
110 | * @~English
111 | * @brief KTX_TRUE, if mipmap generation is required, KTX_FALSE otherwise.
112 | */
113 | /**
114 | * @internal
115 | * @var ktx_uint16_t KTX_supplemental_info::textureDimension
116 | * @~English
117 | * @brief The number of dimensions, 1, 2 or 3, of data in the texture image.
118 | */
119 |
120 | /*
121 | * @internal
122 | * CheckHeader
123 | *
124 | * Reads the KTX file header and performs some sanity checking on the values
125 | */
126 | KTX_error_code _ktxCheckHeader(KTX_header* pHeader,
127 | KTX_supplemental_info* pSuppInfo);
128 |
129 | /*
130 | * SwapEndian16: Swaps endianness in an array of 16-bit values
131 | */
132 | void _ktxSwapEndian16(ktx_uint16_t* pData16, int count);
133 |
134 | /*
135 | * SwapEndian32: Swaps endianness in an array of 32-bit values
136 | */
137 | void _ktxSwapEndian32(ktx_uint32_t* pData32, int count);
138 |
139 | /*
140 | * UnpackETC: uncompresses an ETC compressed texture image
141 | */
142 | KTX_error_code _ktxUnpackETC(const GLubyte* srcETC, const GLenum srcFormat,
143 | ktx_uint32_t active_width, ktx_uint32_t active_height,
144 | GLubyte** dstImage,
145 | GLenum* format, GLenum* internalFormat, GLenum* type,
146 | GLint R16Formats, GLboolean supportsSRGB);
147 |
148 | /*
149 | * Pad nbytes to next multiple of n
150 | */
151 | /* Equivalent to n * ceil(nbytes / n) */
152 | #define _KTX_PADN(n, nbytes) (nbytes + (n-1) & ~(ktx_uint32_t)(n-1))
153 | /*
154 | * Calculate bytes of of padding needed to reach next multiple of n.
155 | */
156 | /* Equivalent to (n * ceil(nbytes / n)) - nbytes */
157 | #define _KTX_PADN_LEN(n, nbytes) ((n-1) - (nbytes + (n-1) & (n-1)))
158 |
159 | /*
160 | * Pad nbytes to next multiple of 4
161 | */
162 | #define _KTX_PAD4(nbytes) _KTX_PADN(4, nbytes)
163 | /*
164 | * Calculate bytes of of padding needed to reach next multiple of 4.
165 | */
166 | #define _KTX_PAD4_LEN(nbytes) _KTX_PADN_LEN(4, nbytes)
167 |
168 | /*
169 | * Pad nbytes to KTX_GL_UNPACK_ALIGNMENT
170 | */
171 | #define _KTX_PAD_UNPACK_ALIGN(nbytes) \
172 | _KTX_PADN(KTX_GL_UNPACK_ALIGNMENT, nbytes)
173 | /*
174 | * Calculate bytes of of padding needed to reach KTX_GL_UNPACK_ALIGNMENT.
175 | */
176 | #define _KTX_PAD_UNPACK_ALIGN_LEN(nbytes) \
177 | _KTX_PADN_LEN(KTX_GL_UNPACK_ALIGNMENT, nbytes)
178 |
179 | /*
180 | ======================================
181 | Internal ktxTexture functions
182 | ======================================
183 | */
184 |
185 | KTX_error_code
186 | ktxTexture_iterateLoadedImages(ktxTexture* This, PFNKTXITERCB iterCb,
187 | void* userdata);
188 | KTX_error_code
189 | ktxTexture_iterateSourceImages(ktxTexture* This, PFNKTXITERCB iterCb,
190 | void* userdata);
191 |
192 | ktx_uint32_t ktxTexture_glTypeSize(ktxTexture* This);
193 | ktx_size_t ktxTexture_imageSize(ktxTexture* This, ktx_uint32_t level);
194 | ktx_bool_t ktxTexture_isActiveStream(ktxTexture* This);
195 | ktx_size_t ktxTexture_levelSize(ktxTexture* This, ktx_uint32_t level);
196 | ktx_size_t ktxTexture_faceLodSize(ktxTexture* This, ktx_uint32_t level);
197 | void ktxTexture_rowInfo(ktxTexture* This, ktx_uint32_t level,
198 | ktx_uint32_t* numRows, ktx_uint32_t* rowBytes,
199 | ktx_uint32_t* rowPadding);
200 |
201 | #ifdef __cplusplus
202 | }
203 | #endif
204 |
205 | #endif /* KTXINT_H */
206 |
--------------------------------------------------------------------------------
/external/ktx/lib/mainpage.md:
--------------------------------------------------------------------------------
1 | Introduction {#mainpage}
2 | =========
3 |
4 | libktx is a small library of functions for creating and reading KTX (Khronos
5 | TeXture) files and instantiating OpenGL® and OpenGL® ES
6 | textures and Vulkan images from them.
7 |
8 | For information about the KTX format see the
9 |
10 | formal specification.
11 |
12 | The library is open source software. Source code is available at
13 | GitHub. Most of the source
14 | code and the documentation is licensed under the Apache 2.0 license. See @ref license
15 | for details. When distributing the library, whether in source or binary form, this
16 | documentation must be included in the distribution or otherwise made available to
17 | recipients.
18 |
19 | See @ref libktx_history for the list of changes.
20 |
21 | See @ref todo for the current To Do list.
22 |
23 | @authors
24 | Mark Callow, Edgewise Consulting,
25 | formerly at HI Corporation\n
26 | Georg Kolling, Imagination Technology\n
27 | Jacob Ström, Ericsson AB
28 |
29 | @version 3.0.0
30 |
31 | $Date$
32 |
33 | # Usage Overview {#overview}
34 |
35 | ## Reading a KTX file for non-GL and non-Vulkan Use {#readktx}
36 |
37 | ~~~~~~~~~~~~~~~~{.c}
38 | #include
39 |
40 | ktxTexture* texture;
41 | KTX_error_code result;
42 | ktx_size_t offset;
43 | ktx_uint8_t* image;
44 | ktx_uint32_t level, layer, faceSlice;
45 |
46 | result = ktxTexture_CreateFromNamedFile("mytex3d.ktx",
47 | KTX_TEXTURE_CREATE_LOAD_IMAGE_DATA_BIT,
48 | &texture);
49 |
50 | // Retrieve information about the texture from fields in the ktxTexture
51 | // such as:
52 | ktx_uint32 numLevels = texture->numLevels;
53 | ktx_uint32 baseWidth = texture->baseWidth;
54 | ktx_bool_t isArray = texture->isArray;
55 |
56 | // Retrieve a pointer to the image for a specific mip level, array layer
57 | // & face or depth slice.
58 | level = 1; layer = 0; faceSlice = 3;
59 | result = ktxTexture_GetImageOffset(texture, level, layer, faceSlice, &offset);
60 | image = ktxTexture_GetData(texture) + offset;
61 | // ...
62 | // Do something with the texture image.
63 | // ...
64 | ktxTexture_Destroy(texture);
65 | ~~~~~~~~~~~~~~~~
66 |
67 | ## Creating a GL texture object from a KTX file. {#createGL}
68 |
69 | ~~~~~~~~~~~~~~~~{.c}
70 | #include
71 |
72 | ktxTexture* kTexture;
73 | KTX_error_code result;
74 | ktx_size_t offset;
75 | ktx_uint8_t* image;
76 | ktx_uint32_t level, layer, faceSlice;
77 | GLuint texture = 0;
78 | GLenum target, glerror;
79 |
80 | result = ktxTexture_CreateFromNamedFile("mytex3d.ktx",
81 | KTX_TEXTURE_CREATE_NO_FLAGS,
82 | &kTexture);
83 | glGenTextures(1, &texture); // Optional. GLUpload can generate a texture.
84 | result = ktxtexture_GLUpload(kTexture, &texture, &target, &glerror);
85 | ktxTexture_Destroy(texture);
86 | // ...
87 | // GL rendering using the texture
88 | // ...
89 | ~~~~~~~~~~~~~~~~
90 |
91 | ## Creating a Vulkan image object from a KTX file. {#createVulkan}
92 |
93 | ~~~~~~~~~~~~~~~~{.c}
94 | #include
95 |
96 | ktxTexture* kTexture;
97 | KTX_error_code result;
98 | ktx_size_t offset;
99 | ktx_uint8_t* image;
100 | ktx_uint32_t level, layer, faceSlice;
101 | ktxVulkanDeviceInfo vdi;
102 | ktxVulkanTexture texture;
103 |
104 | // Set up Vulkan physical device (gpu), logical device (device), queue
105 | // and command pool. Save the handles to these in a struct called vkctx.
106 | // ktx VulkanDeviceInfo is used to pass these with the expectation that
107 | // apps are likely to upload a large number of textures.
108 | ktxVulkanDeviceInfo_Construct(&vdi, vkctx.gpu, vkctx.device,
109 | vkctx.queue, vkctx.commandPool, nullptr);
110 |
111 | ktxresult = ktxTexture_CreateFromNamedFile("mytex3d.ktx",
112 | KTX_TEXTURE_CREATE_NO_FLAGS,
113 | &kTexture);
114 |
115 | ktxresult = ktxTexture_VkUploadEx(kTexture, &vdi, &texture,
116 | VK_IMAGE_TILING_OPTIMAL,
117 | VK_IMAGE_USAGE_SAMPLED_BIT,
118 | VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
119 |
120 | ktxTexture_Destroy(kTexture);
121 | ktxVulkanDeviceInfo_Destruct(&vdi);
122 | // ...
123 | // Vulkan rendering using the texture
124 | // ...
125 | // When done using the image in Vulkan...
126 | ktxVulkanTexture_Destruct(&texture, vkctx.device, nullptr);
127 | ~~~~~~~~~~~~~~~~
128 |
129 | ## Extracting Metadata {#subsection}
130 |
131 | Once a ktxTexture object has been created, metadata can be easily found
132 | and extracted. The following can be added to any of the above.
133 |
134 | ~~~~~~~~~~~~~~~~{.c}
135 | char* pValue;
136 | uint32_t valueLen;
137 | if (KTX_SUCCESS == ktxHashList_FindValue(&kTexture->kvDataHead,
138 | KTX_ORIENTATION_KEY,
139 | &valueLen, (void**)&pValue))
140 | {
141 | char s, t;
142 |
143 | if (sscanf(pValue, KTX_ORIENTATION2_FMT, &s, &t) == 2) {
144 | ...
145 | }
146 | }
147 | ~~~~~~~~~~~~~~~~
148 |
149 | ## Writing a KTX file {#writektx}
150 |
151 | ~~~~~~~~~~~~~~~~{.c}
152 | #include
153 |
154 | ktxTexture* texture;
155 | ktxTextureCreateInfo createInfo;
156 | KTX_error_code result;
157 | ktx_uint32_t level, layer, faceSlice;
158 | FILE* src;
159 | ktx_size_t srcSize;
160 |
161 | createInfo.glInternalformat = GL_RGB8;
162 | createInfo.baseWidth = 2048;
163 | createInfo.baseHeight = 1024;
164 | createInfo.baseDepth = 16;
165 | createInfo.numDimensions = 3.
166 | // Note: it is not necessary to provide a full mipmap pyramid.
167 | createInfo.numLevels = log2(createInfo.baseWidth) + 1
168 | createInfo.numLayers = 1;
169 | createInfo.numFaces = 1;
170 | createInfo.isArray = KTX_FALSE;
171 | createInfo.generateMipmaps = KTX_FALSE;
172 |
173 | result = ktxTexture_Create(createInfo,
174 | KTX_TEXTURE_CREATE_ALLOC_STORAGE,
175 | &texture);
176 |
177 | src = // Open a stdio FILE* on the baseLevel image, slice 0.
178 | srcSize = // Query size of the file.
179 | level = 0;
180 | layer = 0;
181 | faceSlice = 0;
182 | result = ktxTexture_SetImageFromMemory(texture, level, layer, faceSlice,
183 | src, srcSize);
184 | // Repeat for the other 15 slices of the base level and all other levels
185 | // up to createInfo.numLevels.
186 |
187 | ktxTexture_WriteToNamedFile(texture, "mytex3d.ktx");
188 | ktxTexture_Destroy(texture);
189 | ~~~~~~~~~~~~~~~~
190 |
191 | ## Modifying a KTX file {#modifyktx}
192 |
193 | ~~~~~~~~~~~~~~~~{.c}
194 | #include
195 |
196 | ktxTexture* texture;
197 | KTX_error_code result;
198 | ktx_size_t offset;
199 | ktx_uint8_t* image;
200 | ktx_uint32_t level, layer, faceSlice;
201 |
202 | result = ktxTexture_CreateFromNamedFile("mytex3d.ktx",
203 | KTX_TEXTURE_CREATE_LOAD_IMAGE_DATA_BIT,
204 | &texture);
205 | // The file is closed after all the data has been read.
206 |
207 | // It is the responsibilty of the application to make sure its
208 | // modifications are valid.
209 | texture->generateMipmaps = KTX_TRUE;
210 |
211 | ktxTexture_WriteToNamedFile(texture, "mytex3d.ktx");
212 | ktxTexture_Destroy(texture);
213 | ~~~~~~~~~~~~~~~~
214 |
215 |
--------------------------------------------------------------------------------
/external/ktx/lib/memstream.h:
--------------------------------------------------------------------------------
1 | /* -*- tab-width: 4; -*- */
2 | /* vi: set sw=2 ts=4 expandtab: */
3 |
4 | /*
5 | * Copyright (c) 2010-2018 The Khronos Group Inc.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 |
20 | /**
21 | * @internal
22 | * @file
23 | * @~English
24 | *
25 | * @brief Interface of ktxStream for memory.
26 | *
27 | * @author Maksim Kolesin
28 | * @author Georg Kolling, Imagination Technology
29 | * @author Mark Callow, HI Corporation
30 | */
31 |
32 | #ifndef MEMSTREAM_H
33 | #define MEMSTREAM_H
34 |
35 | #include "ktx.h"
36 | #include "stream.h"
37 |
38 | /*
39 | * Initialize a ktxStream to a ktxMemStream with internally
40 | * allocated memory. Can be read or written.
41 | */
42 | KTX_error_code ktxMemStream_construct(ktxStream* str,
43 | ktx_bool_t freeOnDestruct);
44 | /*
45 | * Initialize a ktxStream to a read-only ktxMemStream reading
46 | * from an array of bytes.
47 | */
48 | KTX_error_code ktxMemStream_construct_ro(ktxStream* str,
49 | const ktx_uint8_t* pBytes,
50 | const ktx_size_t size);
51 | void ktxMemStream_destruct(ktxStream* str);
52 |
53 | KTX_error_code ktxMemStream_getdata(ktxStream* str, ktx_uint8_t** ppBytes);
54 |
55 | #endif /* MEMSTREAM_H */
56 |
--------------------------------------------------------------------------------
/external/ktx/lib/stream.h:
--------------------------------------------------------------------------------
1 | /* -*- tab-width: 4; -*- */
2 | /* vi: set sw=2 ts=4 expandtab: */
3 |
4 | /*
5 | * Copyright (c) 2010-2018 The Khronos Group Inc.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 |
20 | /**
21 | * @internal
22 | * @file
23 | * @~English
24 | *
25 | * @brief Interface of ktxStream.
26 | *
27 | * @author Maksim Kolesin
28 | * @author Georg Kolling, Imagination Technology
29 | * @author Mark Callow, HI Corporation
30 | */
31 |
32 | #ifndef KTXSTREAM_H
33 | #define KTXSTREAM_H
34 |
35 | #include
36 | #include "ktx.h"
37 |
38 | /*
39 | * This is unsigned to allow ktxmemstreams to use the
40 | * full amount of memory available. Platforms will
41 | * limit the size of ktxfilestreams to, e.g, MAX_LONG
42 | * on 32-bit and ktxfilestreams raises errors if
43 | * offset values exceed the limits. This choice may
44 | * need to be revisited if we ever start needing -ve
45 | * offsets.
46 | *
47 | * Should the 2GB file size handling limit on 32-bit
48 | * platforms become a problem, ktxfilestream will have
49 | * to be changed to explicitly handle large files by
50 | * using the 64-bit stream functions.
51 | */
52 | #if defined(_MSC_VER) && defined(_WIN64)
53 | typedef unsigned __int64 ktx_off_t;
54 | #else
55 | typedef size_t ktx_off_t;
56 | #endif
57 | typedef struct ktxMem ktxMem;
58 | typedef struct ktxStream ktxStream;
59 |
60 | enum streamType { eStreamTypeFile = 1, eStreamTypeMemory = 2 };
61 |
62 | /**
63 | * @internal
64 | * @~English
65 | * @brief type for a pointer to a stream reading function
66 | */
67 | typedef KTX_error_code (*ktxStream_read)(ktxStream* str, void* dst,
68 | const ktx_size_t count);
69 | /**
70 | * @internal
71 | * @~English
72 | * @brief type for a pointer to a stream skipping function
73 | */
74 | typedef KTX_error_code (*ktxStream_skip)(ktxStream* str,
75 | const ktx_size_t count);
76 |
77 | /**
78 | * @internal
79 | * @~English
80 | * @brief type for a pointer to a stream reading function
81 | */
82 | typedef KTX_error_code (*ktxStream_write)(ktxStream* str, const void *src,
83 | const ktx_size_t size,
84 | const ktx_size_t count);
85 |
86 | /**
87 | * @internal
88 | * @~English
89 | * @brief type for a pointer to a stream position query function
90 | */
91 | typedef KTX_error_code (*ktxStream_getpos)(ktxStream* str, ktx_off_t* const offset);
92 |
93 | /**
94 | * @internal
95 | * @~English
96 | * @brief type for a pointer to a stream position query function
97 | */
98 | typedef KTX_error_code (*ktxStream_setpos)(ktxStream* str, const ktx_off_t offset);
99 |
100 | /**
101 | * @internal
102 | * @~English
103 | * @brief type for a pointer to a stream size query function
104 | */
105 | typedef KTX_error_code (*ktxStream_getsize)(ktxStream* str, ktx_size_t* const size);
106 |
107 | /**
108 | * @internal
109 | * @~English
110 | * @brief Destruct a stream
111 | */
112 | typedef void (*ktxStream_destruct)(ktxStream* str);
113 |
114 | /**
115 | * @internal
116 | * @~English
117 | * @brief KTX stream class
118 | */
119 | struct ktxStream
120 | {
121 | ktxStream_read read; /*!< @internal pointer to function for reading bytes. */
122 | ktxStream_skip skip; /*!< @internal pointer to function for skipping bytes. */
123 | ktxStream_write write; /*!< @internal pointer to function for writing bytes. */
124 | ktxStream_getpos getpos; /*!< @internal pointer to function for getting current position in stream. */
125 | ktxStream_setpos setpos; /*!< @internal pointer to function for setting current position in stream. */
126 | ktxStream_getsize getsize; /*!< @internal pointer to function for querying size. */
127 | ktxStream_destruct destruct; /*!< @internal destruct the stream. */
128 |
129 | enum streamType type;
130 | union {
131 | FILE* file;
132 | ktxMem* mem;
133 | } data; /**< @internal pointer to the stream data. */
134 | ktx_bool_t closeOnDestruct; /**< @internal Close FILE* or dispose of memory on destruct. */
135 | };
136 |
137 | #endif /* KTXSTREAM_H */
138 |
--------------------------------------------------------------------------------
/external/ktx/lib/swap.c:
--------------------------------------------------------------------------------
1 | /* -*- tab-width: 4; -*- */
2 | /* vi: set sw=2 ts=4 expandtab: */
3 |
4 | /* $Id: d858975c68f39438233f78cbf217f70fc5ddd316 $ */
5 |
6 | /*
7 | * Copyright (c) 2010 The Khronos Group Inc.
8 | *
9 | * Licensed under the Apache License, Version 2.0 (the "License");
10 | * you may not use this file except in compliance with the License.
11 | * You may obtain a copy of the License at
12 | *
13 | * http://www.apache.org/licenses/LICENSE-2.0
14 | *
15 | * Unless required by applicable law or agreed to in writing, software
16 | * distributed under the License is distributed on an "AS IS" BASIS,
17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | * See the License for the specific language governing permissions and
19 | * limitations under the License.
20 | */
21 |
22 | #include "KHR/khrplatform.h"
23 |
24 | /*
25 | * SwapEndian16: Swaps endianness in an array of 16-bit values
26 | */
27 | void
28 | _ktxSwapEndian16(khronos_uint16_t* pData16, int count)
29 | {
30 | int i;
31 | for (i = 0; i < count; ++i)
32 | {
33 | khronos_uint16_t x = *pData16;
34 | *pData16++ = (x << 8) | (x >> 8);
35 | }
36 | }
37 |
38 | /*
39 | * SwapEndian32: Swaps endianness in an array of 32-bit values
40 | */
41 | void
42 | _ktxSwapEndian32(khronos_uint32_t* pData32, int count)
43 | {
44 | int i;
45 | for (i = 0; i < count; ++i)
46 | {
47 | khronos_uint32_t x = *pData32;
48 | *pData32++ = (x << 24) | ((x & 0xFF00) << 8) | ((x & 0xFF0000) >> 8) | (x >> 24);
49 | }
50 | }
51 |
52 |
53 |
--------------------------------------------------------------------------------
/external/ktx/lib/vk_funclist.inl:
--------------------------------------------------------------------------------
1 | /* -*- tab-width: 4; -*- */
2 | /* vi: set sw=2 ts=4 expandtab textwidth=70: */
3 |
4 | /*
5 | * ©2017 Mark Callow.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 |
20 | /**
21 | * @internal
22 | * @file vk_funclist.h
23 | * @~English
24 | *
25 | * @brief List of Vulkan functions used by libktx.
26 | */
27 |
28 | VK_FUNCTION(vkAllocateCommandBuffers)
29 | VK_FUNCTION(vkAllocateMemory)
30 | VK_FUNCTION(vkBeginCommandBuffer)
31 | VK_FUNCTION(vkBindBufferMemory)
32 | VK_FUNCTION(vkBindImageMemory)
33 | VK_FUNCTION(vkCmdBlitImage)
34 | VK_FUNCTION(vkCmdCopyBufferToImage)
35 | VK_FUNCTION(vkCmdPipelineBarrier)
36 | VK_FUNCTION(vkCreateBuffer)
37 | VK_FUNCTION(vkCreateFence)
38 | VK_FUNCTION(vkCreateImage)
39 | VK_FUNCTION(vkDestroyBuffer)
40 | VK_FUNCTION(vkDestroyFence)
41 | VK_FUNCTION(vkDestroyImage)
42 | VK_FUNCTION(vkEndCommandBuffer)
43 | VK_FUNCTION(vkFreeCommandBuffers)
44 | VK_FUNCTION(vkFreeMemory)
45 | VK_FUNCTION(vkGetBufferMemoryRequirements)
46 | VK_FUNCTION(vkGetImageMemoryRequirements)
47 | VK_FUNCTION(vkGetImageSubresourceLayout)
48 | VK_FUNCTION(vkGetPhysicalDeviceImageFormatProperties)
49 | VK_FUNCTION(vkGetPhysicalDeviceFormatProperties)
50 | VK_FUNCTION(vkGetPhysicalDeviceMemoryProperties)
51 | VK_FUNCTION(vkMapMemory)
52 | VK_FUNCTION(vkQueueSubmit)
53 | VK_FUNCTION(vkQueueWaitIdle)
54 | VK_FUNCTION(vkUnmapMemory)
55 | VK_FUNCTION(vkWaitForFences)
56 |
--------------------------------------------------------------------------------
/external/ktx/lib/vk_funcs.c:
--------------------------------------------------------------------------------
1 | /* -*- tab-width: 4; -*- */
2 | /* vi: set sw=2 ts=4 expandtab textwidth=70: */
3 |
4 | /*
5 | * ©2017 Mark Callow.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 |
20 | /**
21 | * @internal
22 | * @file vk_funcs.c
23 | * @~English
24 | *
25 | * @brief Retrieve Vulkan function pointers needed by libktx
26 | */
27 |
28 | #if defined(KTX_USE_FUNCPTRS_FOR_VULKAN)
29 |
30 | #define UNIX 0
31 | #define MACOS 0
32 | #define WINDOWS 0
33 |
34 | #if defined(_WIN32)
35 | #undef WINDOWS
36 | #define WINDOWS 1
37 | #endif
38 | #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__)
39 | #undef UNIX
40 | #define UNIX 1
41 | #endif
42 | #if defined(linux) || defined(__linux) || defined(__linux__)
43 | #undef UNIX
44 | #define UNIX 1
45 | #endif
46 | #if defined(__APPLE__) && defined(__x86_64__)
47 | #undef MACOS
48 | #define MACOS 1
49 | #endif
50 |
51 | #if (IOS + MACOS + UNIX + WINDOWS) > 1
52 | #error "Multiple OS\'s defined"
53 | #endif
54 |
55 | #if WINDOWS
56 | #define WINDOWS_LEAN_AND_MEAN
57 | #include
58 | #else
59 | #include
60 | #endif
61 | #include "ktx.h"
62 | #include "vk_funcs.h"
63 |
64 | #if WINDOWS
65 | HMODULE ktxVulkanLibary;
66 | #define LoadLibrary LoadLibrary
67 | #define LoadProcAddr GetProcAddress
68 | #elif MACOS || UNIX
69 | #define LoadLibrary dlopen
70 | #define LoadProcAddr dlsym
71 | void* ktxVulkanLibrary;
72 | #else
73 | #error "Don\'t know how to load symbols on this OS."
74 | #endif
75 |
76 | #if WINDOWS
77 | #define VULKANLIB "vulkan-1.dll"
78 | #elif MACOS
79 | #define VULKANLIB "vulkan.framework/vulkan"
80 | #elif UNIX
81 | #define VULKANLIB "libvulkan.so"
82 | #endif
83 |
84 | static PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr;
85 |
86 | /* Define pointers for functions libktx is using. */
87 | #define VK_FUNCTION(fun) PFN_##fun ktx_##fun;
88 |
89 | #include "vk_funclist.inl"
90 |
91 | #undef VK_FUNCTION
92 |
93 | #if 0
94 | // The Vulkan spec. recommends using vkGetInstanceProcAddr over dlsym
95 | // (or whatever). Doing so would require a backward incompatible
96 | // change to the libktx API to provide the VkInstance. We have no
97 | // choice but dlsym. We can't use vkGetDeviceProcAddr because libktx
98 | // also uses none-device-level functions.
99 | #define VK_FUNCTION(fun) \
100 | if ( !(ktx_##fun = (PFN_##fun)vkGetInstanceProcAddr(instance, #fun )) ) { \
101 | fprintf(stderr, "Could not load Vulkan command: %s!\n", #fun); \
102 | return KTX_FALSE; \
103 | }
104 | #else
105 | #if defined(__GNUC__)
106 | // This strange casting is because dlsym returns a void* thus is not
107 | // compatible with ISO C which forbids conversion of object pointers
108 | // to function pointers. The cast masks the conversion from the
109 | // compiler thus no warning even though -pedantic is set. Since the
110 | // platform supports dlsym, conversion to function pointers must
111 | // work, despite the mandated ISO C warning.
112 | #define VK_FUNCTION(fun) \
113 | if ( !(*(void **)(&ktx_##fun) = LoadProcAddr(ktxVulkanLibrary, #fun)) ) {\
114 | fprintf(stderr, "Could not load Vulkan command: %s!\n", #fun); \
115 | return KTX_FALSE; \
116 | }
117 | #else
118 | #define VK_FUNCTION(fun) \
119 | if ( !(ktx_##fun = (PFN_##fun)LoadProcAddr(ktxVulkanLibrary, #fun)) ) { \
120 | fprintf(stderr, "Could not load Vulkan command: %s!\n", #fun); \
121 | return KTX_FALSE; \
122 | }
123 | #endif
124 | #endif
125 |
126 | ktx_bool_t
127 | ktxVulkanLoadLibrary(void)
128 | {
129 | if (ktxVulkanLibrary)
130 | return KTX_TRUE;
131 |
132 | ktxVulkanLibrary = LoadLibrary(VULKANLIB, RTLD_LAZY);
133 | if (ktxVulkanLibrary == NULL) {
134 | fprintf(stderr, "Could not load Vulkan library.\n");
135 | return(KTX_FALSE);
136 | }
137 |
138 | #if 0
139 | vkGetInstanceProcAddr =
140 | (PFN_vkGetInstanceProcAddr)LoadProcAddr(ktxVulkanLibrary,
141 | "vkGetInstanceProcAddr");
142 | if (!vkGetInstanceProcAddr) {
143 | fprintf(stderr, "Could not load Vulkan command: %s!\n",
144 | "vkGetInstanceProcAddr");
145 | return(KTX_FALSE);
146 | }
147 | #endif
148 |
149 | #include "vk_funclist.inl"
150 |
151 | return KTX_TRUE;
152 | }
153 |
154 | #undef VK_FUNCTION
155 |
156 | #else
157 |
158 | extern
159 | #if defined(__GNUC__)
160 | __attribute__((unused))
161 | #endif
162 | int keepISOCompilersHappy;
163 |
164 | #endif /* KTX_USE_FUNCPTRS_FOR_VULKAN */
165 |
--------------------------------------------------------------------------------
/external/ktx/lib/vk_funcs.h:
--------------------------------------------------------------------------------
1 | /* -*- tab-width: 4; -*- */
2 | /* vi: set sw=2 ts=4 expandtab textwidth=70: */
3 |
4 | /*
5 | * ©2017 Mark Callow.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 |
20 | /**
21 | * @internal
22 | * @file vk_funcs.h
23 | * @~English
24 | *
25 | * @brief Declare pointers for Vulkan functions.
26 | *
27 | * Dynamically retrieving pointers avoids apps having to make sure a
28 | * Vulkan library is availablei when using a shared libktx, even if
29 | * not using libktx's Vulkan loader.
30 | */
31 |
32 | #ifndef _VK_FUNCS_H_
33 | #define _VK_FUNCS_H_
34 |
35 | #if defined(KTX_USE_FUNCPTRS_FOR_VULKAN)
36 | #define VK_NO_PROTOTYPES
37 | #endif
38 |
39 | #include
40 | #include "ktx.h"
41 |
42 | #if defined(KTX_USE_FUNCPTRS_FOR_VULKAN)
43 |
44 | #if defined(_WIN32)
45 | extern HMODULE ktxVulkanLibary;
46 | #else
47 | extern void* ktxVulkanLibrary;
48 | #endif
49 |
50 | extern ktx_bool_t ktxVulkanLoadLibrary(void);
51 |
52 | /* Declare pointers for functions libktx is using. */
53 | #define VK_FUNCTION(fun) extern PFN_##fun ktx_##fun;
54 |
55 | #include "vk_funclist.inl"
56 |
57 | #undef VK_FUNCTION
58 |
59 | /*
60 | * Define prefixed names to prevent collisions with other libraries or apps
61 | * finding our pointers when searching the module for function addresses.
62 | */
63 | #define vkAllocateCommandBuffers ktx_vkAllocateCommandBuffers
64 | #define vkAllocateMemory ktx_vkAllocateMemory
65 | #define vkBeginCommandBuffer ktx_vkBeginCommandBuffer
66 | #define vkBindBufferMemory ktx_vkBindBufferMemory
67 | #define vkBindImageMemory ktx_vkBindImageMemory
68 | #define vkCmdBlitImage ktx_vkCmdBlitImage
69 | #define vkCmdCopyBufferToImage ktx_vkCmdCopyBufferToImage
70 | #define vkCmdPipelineBarrier ktx_vkCmdPipelineBarrier
71 | #define vkCreateBuffer ktx_vkCreateBuffer
72 | #define vkCreateFence ktx_vkCreateFence
73 | #define vkCreateImage ktx_vkCreateImage
74 | #define vkDestroyBuffer ktx_vkDestroyBuffer
75 | #define vkDestroyFence ktx_vkDestroyFence
76 | #define vkDestroyImage ktx_vkDestroyImage
77 | #define vkEndCommandBuffer ktx_vkEndCommandBuffer
78 | #define vkFreeCommandBuffers ktx_vkFreeCommandBuffers
79 | #define vkFreeMemory ktx_vkFreeMemory
80 | #define vkGetBufferMemoryRequirements ktx_vkGetBufferMemoryRequirements
81 | #define vkGetImageMemoryRequirements ktx_vkGetImageMemoryRequirements
82 | #define vkGetImageSubresourceLayout ktx_vkGetImageSubresourceLayout
83 | #define vkGetPhysicalDeviceImageFormatProperties ktx_vkGetPhysicalDeviceImageFormatProperties
84 | #define vkGetPhysicalDeviceFormatProperties ktx_vkGetPhysicalDeviceFormatProperties
85 | #define vkGetPhysicalDeviceMemoryProperties ktx_vkGetPhysicalDeviceMemoryProperties
86 | #define vkMapMemory ktx_vkMapMemory
87 | #define vkQueueSubmit ktx_vkQueueSubmit
88 | #define vkQueueWaitIdle ktx_vkQueueWaitIdle
89 | #define vkUnmapMemory ktx_vkUnmapMemory
90 | #define vkWaitForFences ktx_vkWaitForFences
91 |
92 | #undef VK_FUNCTION
93 |
94 | #endif /* KTX_USE_FUNCPTRS_FOR_VULKAN */
95 |
96 | #endif /* _VK_FUNCS_H_ */
97 |
98 |
--------------------------------------------------------------------------------
/external/rply/LICENSE:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/samdauwe/webgpu-native-examples/4e2f520208abd7b5c74c419440eb87b37709e28e/external/rply/LICENSE
--------------------------------------------------------------------------------
/external/rply/etc/convert.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include "rply.h"
6 |
7 | /* internal function prototypes */
8 | static void error(const char *fmt, ...);
9 | static void help(void);
10 | static void parse_arguments(int argc, char **argv,
11 | e_ply_storage_mode *storage_mode,
12 | const char **iname, const char **oname);
13 | static void setup_callbacks(p_ply iply, p_ply oply);
14 |
15 | /* given a format mode, an input file name and an output file name,
16 | * convert input file to output in given format mode */
17 | int main(int argc, char **argv) {
18 | const char *value = NULL;
19 | e_ply_storage_mode storage_mode = PLY_LITTLE_ENDIAN;
20 | const char *iname = NULL, *oname = NULL;
21 | p_ply iply = NULL, oply = NULL;
22 | /* parse command line arguments */
23 | parse_arguments(argc, argv, &storage_mode, &iname, &oname);
24 | /* open input file and make sure we parsed its header */
25 | iply = ply_open(iname, NULL, 0, NULL);
26 | if (!iply) error("Unable to open file '%s'", iname);
27 | if (!ply_read_header(iply)) error("Failed reading '%s' header", iname);
28 | /* create output file */
29 | oply = ply_create(oname, storage_mode, NULL, 0, NULL);
30 | if (!oply) error("Unable to create file '%s'", oname);
31 | /* create elements and properties in output file and
32 | * setup callbacks for them in input file */
33 | setup_callbacks(iply, oply);
34 | /* pass comments and obj_infos from input to output */
35 | value = NULL;
36 | while ((value = ply_get_next_comment(iply, value)))
37 | if (!ply_add_comment(oply, value))
38 | error("Failed adding comments");
39 | value = NULL;
40 | while ((value = ply_get_next_obj_info(iply, value)))
41 | if (!ply_add_obj_info(oply, value))
42 | error("Failed adding comments");
43 | /* write output header */
44 | if (!ply_write_header(oply)) error("Failed writing '%s' header", oname);
45 | /* read input file generating callbacks that pass data to output file */
46 | if (!ply_read(iply)) error("Conversion failed");
47 | /* close up, we are done */
48 | if (!ply_close(iply)) error("Error closing file '%s'", iname);
49 | if (!ply_close(oply)) error("Error closing file '%s'", oname);
50 | return 0;
51 | }
52 |
53 | /* prints an error message and exits */
54 | static void error(const char *fmt, ...) {
55 | va_list ap;
56 | va_start(ap, fmt);
57 | vfprintf(stderr, fmt, ap);
58 | va_end(ap);
59 | fprintf(stderr, "\n");
60 | exit(1);
61 | }
62 |
63 | /* prints the help message and exits */
64 | static void help(void) {
65 | error("Usage:\n"
66 | " convert