Initial commit - some engine bugs stopping compiling
This commit is contained in:
BIN
third-party/.DS_Store
vendored
Normal file
BIN
third-party/.DS_Store
vendored
Normal file
Binary file not shown.
BIN
third-party/glad/.DS_Store
vendored
Normal file
BIN
third-party/glad/.DS_Store
vendored
Normal file
Binary file not shown.
36
third-party/glad/.github/workflows/glad2.yaml
vendored
Normal file
36
third-party/glad/.github/workflows/glad2.yaml
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
on: [push, pull_request]
|
||||
|
||||
name: glad2
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Test
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.x'
|
||||
- name: Install Python dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -r requirements.txt
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install gcc g++ gcc-mingw-w64 g++-mingw-w64 rustc libglfw3-dev wine winetricks xvfb libxxf86vm-dev libxi-dev libxcursor-dev libxinerama-dev
|
||||
- name: Setup environment
|
||||
run: |
|
||||
mkdir .wine
|
||||
export WINEPREFIX="$(pwd)/.wine"
|
||||
export WINEDLLOVERRIDES="mscoree,mshtml="
|
||||
|
||||
winetricks nocrashdialog
|
||||
- name: Run Tests
|
||||
run: PRINT_MESSAGE=1 xvfb-run --auto-servernum ./utility/test.sh
|
||||
- name: Publish Test Results
|
||||
uses: EnricoMi/publish-unit-test-result-action@v2
|
||||
if: always()
|
||||
with:
|
||||
files: test-report.xml
|
||||
comment_mode: off
|
||||
22
third-party/glad/.gitignore
vendored
Normal file
22
third-party/glad/.gitignore
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
*.pyc
|
||||
/*.xml
|
||||
*.kdev4
|
||||
build/
|
||||
*.o
|
||||
*.a
|
||||
a.out
|
||||
*.kdev_include_paths
|
||||
main.c
|
||||
*.diff
|
||||
*.swp
|
||||
.idea
|
||||
dist/
|
||||
*.egg-info
|
||||
/khrplatform.h
|
||||
/eglplatform.h
|
||||
/vk_platform.h
|
||||
/glad-rs/
|
||||
/rust/
|
||||
target/
|
||||
Cargo.lock
|
||||
.vscode/
|
||||
63
third-party/glad/LICENSE
vendored
Normal file
63
third-party/glad/LICENSE
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
The glad source code:
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013-2022 David Herberth
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
The Khronos Specifications:
|
||||
|
||||
Copyright (c) 2013-2020 The Khronos Group Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
|
||||
The EGL Specification and various headers:
|
||||
|
||||
Copyright (c) 2007-2016 The Khronos Group Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and/or associated documentation files (the
|
||||
"Materials"), to deal in the Materials without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Materials, and to
|
||||
permit persons to whom the Materials are furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Materials.
|
||||
|
||||
THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
||||
1
third-party/glad/MANIFEST.in
vendored
Normal file
1
third-party/glad/MANIFEST.in
vendored
Normal file
@@ -0,0 +1 @@
|
||||
recursive-include glad *.c *.h *.d *.volt *.rs *.toml *.xml
|
||||
83
third-party/glad/README.md
vendored
Normal file
83
third-party/glad/README.md
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
glad
|
||||
====
|
||||
|
||||
Vulkan/GL/GLES/EGL/GLX/WGL Loader-Generator based on the official specifications
|
||||
for multiple languages.
|
||||
|
||||
Check out the [webservice for glad2](https://glad.sh) to generate the files you need!
|
||||
|
||||
|
||||
**NOTE:** This is the 2.0 branch, which adds more functionality but changes the API.
|
||||
|
||||
Some languages are only available in the [glad1 generator](https://glad.dav1d.de).
|
||||
|
||||
## Examples
|
||||
|
||||
```c
|
||||
#include <glad/gl.h>
|
||||
// GLFW (include after glad)
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
|
||||
int main() {
|
||||
// -- snip --
|
||||
|
||||
GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, "LearnOpenGL", NULL, NULL);
|
||||
glfwMakeContextCurrent(window);
|
||||
|
||||
int version = gladLoadGL(glfwGetProcAddress);
|
||||
if (version == 0) {
|
||||
printf("Failed to initialize OpenGL context\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Successfully loaded OpenGL
|
||||
printf("Loaded OpenGL %d.%d\n", GLAD_VERSION_MAJOR(version), GLAD_VERSION_MINOR(version));
|
||||
|
||||
// -- snip --
|
||||
}
|
||||
```
|
||||
|
||||
The full code: [hellowindow2.cpp](example/c++/hellowindow2.cpp)
|
||||
|
||||
More examples in the [examples directory](example/) of this repository.
|
||||
|
||||
## Plugins
|
||||
|
||||
Glad [plugins](https://github.com/Dav1dde/glad/wiki/Extending-Glad)
|
||||
maintained by the community to add support for more languages:
|
||||
|
||||
- [Fortran](https://github.com/AarnoldGad/glad-fortran).
|
||||
|
||||
## Documentation
|
||||
|
||||
The documentation can be found in the [wiki](https://github.com/Dav1dde/glad/wiki).
|
||||
|
||||
|
||||
Examples can be found [in the example directory](/example). Some examples:
|
||||
|
||||
* C/C++
|
||||
* [GL GLFW](example/c/gl_glfw.c)
|
||||
* [GL GLFW On-Demand loading](example/c/gl_glfw_on_demand.c)
|
||||
* [GL GLFW Multiple Windows/Contexts](example/c++/multiwin_mx/)
|
||||
* [GL SDL2](example/c/gl_sdl2.c)
|
||||
* [Vulkan GLFW](example/c/vulkan_tri_glfw/)
|
||||
* [GLX](example/c/glx.c)
|
||||
* [GLX Modern](example/c/glx_modern.c)
|
||||
* [WGL](example/c/wgl.c)
|
||||
* [EGL X11](example/c/egl_x11/)
|
||||
* Rust
|
||||
* [GL GLFW](example/rust/gl-glfw/)
|
||||
* [GL GLFW Multiple Windows/Contexts](example/rust/gl-glfw-mx/)
|
||||
|
||||
|
||||
|
||||
## License
|
||||
|
||||
For the source code and various Khronos files see [LICENSE](/LICENSE).
|
||||
|
||||
The generated code from glad is any of Public Domain, WTFPL or CC0.
|
||||
Now Khronos has some of their specifications under Apache Version 2.0
|
||||
license which may have an impact on the generated code,
|
||||
[see this clarifying comment](https://github.com/KhronosGroup/OpenGL-Registry/issues/376#issuecomment-596187053)
|
||||
on the Khronos / OpenGL-Specification issue tracker.
|
||||
21
third-party/glad/cmake/CMakeLists.txt
vendored
Normal file
21
third-party/glad/cmake/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
# configuration variables:
|
||||
# GLAD_SOURCES_DIR: path to the sources of glad (=python module)
|
||||
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
project(glad C)
|
||||
|
||||
set(
|
||||
GLAD_CMAKE_DIR
|
||||
"${CMAKE_CURRENT_LIST_DIR}"
|
||||
CACHE STRING
|
||||
"Directory containing glad generator CMakeLists.txt. Must be absolute."
|
||||
)
|
||||
set(
|
||||
GLAD_SOURCES_DIR
|
||||
"${GLAD_CMAKE_DIR}/../"
|
||||
CACHE STRING
|
||||
"Directory containing glad sources (python modules), used as working directory. Must be absolute."
|
||||
)
|
||||
mark_as_advanced(GLAD_CMAKE_DIR)
|
||||
|
||||
include(${GLAD_CMAKE_DIR}/GladConfig.cmake)
|
||||
295
third-party/glad/cmake/GladConfig.cmake
vendored
Normal file
295
third-party/glad/cmake/GladConfig.cmake
vendored
Normal file
@@ -0,0 +1,295 @@
|
||||
# This project defines a `glad_add_library` function that will create a glad library.
|
||||
# The created library will automatically generate the glad sources.
|
||||
# Consumers can link to the the library.
|
||||
#
|
||||
# glad_add_library(<TARGET> [SHARED|STATIC|MODULE|INTERFACE] [EXCLUDE_FROM_ALL] [MERGE] [QUIET] [LOCATION <PATH>]
|
||||
# [LANGUAGE <LANG>] [API <API1> [<API2> ...]] [EXTENSIONS [<EXT1> [<EXT2> ...]]])
|
||||
# - <TARGET>
|
||||
# Name of the TARGET
|
||||
# - SHARED|STATIC|MODULE|INTERFACE
|
||||
# Type of the library, if none is specified, default BUILD_SHARED_LIBS behavior is honored
|
||||
# - EXCLUDE_FROM_ALL
|
||||
# Exclude building the library from the all target
|
||||
# - MERGE
|
||||
# Merge multiple APIs of the same specitifation into one file.
|
||||
# - REPRODUCIBLE
|
||||
# Makes the build reproducible by not fetching the latest specification from Khronos.
|
||||
# - QUIET
|
||||
# Disable logging
|
||||
# - LOCATION <PATH>
|
||||
# Set the location where the generated glad should be saved.
|
||||
# - LANGUAGE <LANG>
|
||||
# Language of the generated glad sources.
|
||||
# - API <API1> [<API2> ...]]
|
||||
# Apis to include in the generated glad library.
|
||||
# - EXTENSIONS [<EXT1> [<EXT2> ...]]
|
||||
# Extensions to include in the generated glad library. Pass NONE to add no extensions whatsoever.
|
||||
#
|
||||
# examples:
|
||||
# - create a shared glad library of the core profile of opengl 3.3, having all extensions:
|
||||
# ```
|
||||
# glad_add_library(glad_gl_core_33 SHARED API gl:core=3.3)
|
||||
# ```
|
||||
# - create a module glad library of the compatibility profile of opengl 1.0, having only the GL_EXT_COMPRESSION_s3tc extensionsion
|
||||
# ```
|
||||
# glad_add_library(glad_gl_compat_10 MODULE API gl:compatibility=1.0 EXTENSIONS GL_EXT_COMPRESSION_s3tc)
|
||||
# ```
|
||||
# - create a static glad library with the vulkan=1.1
|
||||
# ```
|
||||
# glad_add_library(glad_vulkan_11 STATIC API vulkan=1.1)
|
||||
# ```
|
||||
|
||||
# Extract specification, profile and version from a string
|
||||
# examples:
|
||||
# gl:core=3.3 => SPEC=gl PROFILE=core VERSION=3.3
|
||||
# gl:compatibility=4.0 => SPEC=gl PROFILE=compatibility VERSION=4.0
|
||||
# vulkan=1.1 => SPEC=vulkan PROFILE="" VERSION=1.1
|
||||
function(__glad_extract_spec_profile_version SPEC PROFILE VERSION STRING)
|
||||
string(REPLACE "=" ";" SPEC_PROFILE_VERSION_LIST "${STRING}")
|
||||
list(LENGTH SPEC_PROFILE_VERSION_LIST SPV_LENGTH)
|
||||
if(SPV_LENGTH LESS 2)
|
||||
message(FATAL_ERROR "${SPEC} is an invalid SPEC")
|
||||
endif()
|
||||
list(GET SPEC_PROFILE_VERSION_LIST 0 SPEC_PROFILE_STR)
|
||||
list(GET SPEC_PROFILE_VERSION_LIST 1 VERSION_STR)
|
||||
|
||||
string(REPLACE ":" ";" SPEC_PROFILE_LIST "${SPEC_PROFILE_STR}")
|
||||
list(LENGTH SPEC_PROFILE_LIST SP_LENGTH)
|
||||
if(SP_LENGTH LESS 2)
|
||||
list(GET SPEC_PROFILE_LIST 0 SPEC_STR)
|
||||
set(PROFILE_STR "")
|
||||
else()
|
||||
list(GET SPEC_PROFILE_LIST 0 SPEC_STR)
|
||||
list(GET SPEC_PROFILE_LIST 1 PROFILE_STR)
|
||||
endif()
|
||||
|
||||
set("${SPEC}" "${SPEC_STR}" PARENT_SCOPE)
|
||||
set("${PROFILE}" "${PROFILE_STR}" PARENT_SCOPE)
|
||||
set("${VERSION}" "${VERSION_STR}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Calculate the argument and generated files for the "c" subparser for glad
|
||||
function(__glad_c_library CARGS CFILES)
|
||||
cmake_parse_arguments(GGC "ALIAS;DEBUG;HEADERONLY;LOADER;MX;MXGLOBAL;ON_DEMAND" "" "API" ${ARGN})
|
||||
|
||||
if(NOT GGC_API)
|
||||
message(FATAL_ERROR "Need API")
|
||||
endif()
|
||||
|
||||
set(GGC_FILES "")
|
||||
foreach(API ${GGC_API})
|
||||
__glad_extract_spec_profile_version(SPEC PROFILE VERSION "${API}")
|
||||
if(SPEC STREQUAL "egl")
|
||||
list(APPEND GGC_FILES
|
||||
"${GLAD_DIR}/include/EGL/eglplatform.h"
|
||||
"${GLAD_DIR}/include/KHR/khrplatform.h"
|
||||
"${GLAD_DIR}/include/glad/egl.h"
|
||||
)
|
||||
if(NOT GGC_HEADERONLY)
|
||||
list(APPEND GGC_FILES "${GLAD_DIR}/src/egl.c")
|
||||
endif()
|
||||
elseif(SPEC STREQUAL "vulkan")
|
||||
list(APPEND GGC_FILES
|
||||
"${GLAD_DIR}/include/vk_platform.h"
|
||||
"${GLAD_DIR}/include/glad/vulkan.h"
|
||||
)
|
||||
if(NOT GGC_HEADERONLY)
|
||||
list(APPEND GGC_FILES "${GLAD_DIR}/src/vulkan.c")
|
||||
endif()
|
||||
elseif(SPEC STREQUAL "gl")
|
||||
list(APPEND GGC_FILES
|
||||
"${GLAD_DIR}/include/KHR/khrplatform.h"
|
||||
"${GLAD_DIR}/include/glad/gl.h"
|
||||
)
|
||||
if(NOT GGC_HEADERONLY)
|
||||
list(APPEND GGC_FILES "${GLAD_DIR}/src/gl.c")
|
||||
endif()
|
||||
elseif(SPEC STREQUAL "gles1")
|
||||
list(APPEND GGC_FILES
|
||||
"${GLAD_DIR}/include/KHR/khrplatform.h"
|
||||
"${GLAD_DIR}/include/glad/gles1.h"
|
||||
)
|
||||
if(NOT GGC_HEADERONLY)
|
||||
list(APPEND GGC_FILES "${GLAD_DIR}/src/gles1.c")
|
||||
endif()
|
||||
elseif(SPEC STREQUAL "gles2")
|
||||
list(APPEND GGC_FILES
|
||||
"${GLAD_DIR}/include/KHR/khrplatform.h"
|
||||
"${GLAD_DIR}/include/glad/gles2.h"
|
||||
)
|
||||
if(NOT GGC_HEADERONLY)
|
||||
list(APPEND GGC_FILES "${GLAD_DIR}/src/gles2.c")
|
||||
endif()
|
||||
elseif(SPEC STREQUAL "glsc2")
|
||||
list(APPEND GGC_FILES
|
||||
"${GLAD_DIR}/include/KHR/khrplatform.h"
|
||||
"${GLAD_DIR}/include/glad/glsc2.h"
|
||||
)
|
||||
if(NOT GGC_HEADERONLY)
|
||||
list(APPEND GGC_FILES "${GLAD_DIR}/src/glsc2.c")
|
||||
endif()
|
||||
elseif(SPEC STREQUAL "wgl")
|
||||
list(APPEND GGC_FILES "${GLAD_DIR}/include/glad/wgl.h")
|
||||
if(NOT GGC_HEADERONLY)
|
||||
list(APPEND GGC_FILES "${GLAD_DIR}/src/wgl.c")
|
||||
endif()
|
||||
elseif(SPEC STREQUAL "glx")
|
||||
list(APPEND GGC_FILES "${GLAD_DIR}/include/glad/glx.h")
|
||||
if(NOT GGC_HEADERONLY)
|
||||
list(APPEND GGC_FILES "${GLAD_DIR}/src/glx.c")
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "Unknown SPEC: '${SPEC}'")
|
||||
endif()
|
||||
endforeach()
|
||||
list(REMOVE_DUPLICATES GGC_FILES)
|
||||
|
||||
set(GGC_ARGS "")
|
||||
if(GGC_ALIAS)
|
||||
list(APPEND GGC_ARGS "--alias")
|
||||
endif()
|
||||
|
||||
if(GGC_DEBUG)
|
||||
list(APPEND GGC_ARGS "--debug")
|
||||
endif()
|
||||
|
||||
if(GGC_HEADERONLY)
|
||||
list(APPEND GGC_ARGS "--header-only")
|
||||
endif()
|
||||
|
||||
if(GGC_LOADER)
|
||||
list(APPEND GGC_ARGS "--loader")
|
||||
endif()
|
||||
|
||||
if(GGC_MX)
|
||||
list(APPEND GGC_ARGS "--mx")
|
||||
endif()
|
||||
|
||||
if(GGC_MXGLOBAL)
|
||||
list(APPEND GGC_ARGS "--mx-global")
|
||||
endif()
|
||||
|
||||
if(GGC_ON_DEMAND)
|
||||
list(APPEND GGC_ARGS "--on-demand")
|
||||
endif()
|
||||
|
||||
set("${CARGS}" "${GGC_ARGS}" PARENT_SCOPE)
|
||||
set("${CFILES}" "${GGC_FILES}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Create a glad library named "${TARGET}"
|
||||
function(glad_add_library TARGET)
|
||||
message(STATUS "Glad Library \'${TARGET}\'")
|
||||
|
||||
find_package(Python COMPONENTS Interpreter REQUIRED)
|
||||
|
||||
cmake_parse_arguments(GG "MERGE;QUIET;REPRODUCIBLE;STATIC;SHARED;MODULE;INTERFACE;EXCLUDE_FROM_ALL" "LOCATION;LANGUAGE" "API;EXTENSIONS" ${ARGN})
|
||||
|
||||
if(NOT GG_LOCATION)
|
||||
set(GG_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/gladsources/${TARGET}")
|
||||
endif()
|
||||
if(BUILD_SHARED_LIBS)
|
||||
set(GG_SHARED TRUE)
|
||||
endif()
|
||||
set(GLAD_DIR "${GG_LOCATION}")
|
||||
if(NOT IS_DIRECTORY "${GLAD_DIR}")
|
||||
file(MAKE_DIRECTORY "${GLAD_DIR}")
|
||||
endif()
|
||||
set(GLAD_ARGS --out-path "${GLAD_DIR}")
|
||||
|
||||
if(NOT GG_API)
|
||||
message(FATAL_ERROR "Need API")
|
||||
endif()
|
||||
string(REPLACE ";" "," GLAD_API "${GG_API}")
|
||||
list(APPEND GLAD_ARGS --api "${GLAD_API}")
|
||||
|
||||
if(GG_EXTENSIONS)
|
||||
list(FIND GG_EXTENSIONS NONE GG_EXT_NONE)
|
||||
if(GG_EXT_NONE GREATER -1)
|
||||
set(GLAD_EXTENSIONS " ")
|
||||
else()
|
||||
list(REMOVE_DUPLICATES GG_EXTENSIONS)
|
||||
list(JOIN GG_EXTENSIONS "," GLAD_EXTENSIONS)
|
||||
endif()
|
||||
list(APPEND GLAD_ARGS --extensions "${GLAD_EXTENSIONS}")
|
||||
endif()
|
||||
|
||||
if(GG_QUIET)
|
||||
list(APPEND GLAD_ARGS --quiet)
|
||||
endif()
|
||||
|
||||
if(GG_MERGE)
|
||||
list(APPEND GLAD_ARGS --merge)
|
||||
endif()
|
||||
|
||||
if(GG_REPRODUCIBLE)
|
||||
list(APPEND GLAD_ARGS --reproducible)
|
||||
endif()
|
||||
|
||||
set(GLAD_LANGUAGE "c")
|
||||
if(GG_LANGUAGE)
|
||||
string(TOLOWER "${GG_LANGUAGE}" "${GLAD_LANGUAGE}")
|
||||
endif()
|
||||
|
||||
if(GLAD_LANGUAGE STREQUAL "c")
|
||||
__glad_c_library(LANG_ARGS GLAD_FILES ${GG_UNPARSED_ARGUMENTS} API ${GG_API})
|
||||
else()
|
||||
message(FATAL_ERROR "Unknown LANGUAGE")
|
||||
endif()
|
||||
list(APPEND GLAD_ARGS ${GLAD_LANGUAGE} ${LANG_ARGS})
|
||||
|
||||
string(REPLACE "${GLAD_DIR}" GLAD_DIRECTORY GLAD_ARGS_UNIVERSAL "${GLAD_ARGS}")
|
||||
set(GLAD_ARGS_PATH "${GLAD_DIR}/args.txt")
|
||||
|
||||
# add make custom target
|
||||
add_custom_command(
|
||||
OUTPUT ${GLAD_FILES} ${GLAD_ARGS_PATH}
|
||||
COMMAND echo Cleaning ${GLAD_DIR}
|
||||
COMMAND ${CMAKE_COMMAND} -E remove_directory ${GLAD_DIR}
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${GLAD_DIR}
|
||||
COMMAND echo Generating with args ${GLAD_ARGS}
|
||||
COMMAND ${Python_EXECUTABLE} -m glad ${GLAD_ARGS}
|
||||
COMMAND echo Writing ${GLAD_ARGS_PATH}
|
||||
COMMAND echo ${GLAD_ARGS} > ${GLAD_ARGS_PATH}
|
||||
WORKING_DIRECTORY $<$<BOOL:${GLAD_SOURCES_DIR}>:${GLAD_SOURCES_DIR}>
|
||||
COMMENT "${TARGET}-generate"
|
||||
USES_TERMINAL
|
||||
)
|
||||
|
||||
set(GLAD_ADD_LIBRARY_ARGS "")
|
||||
if(GG_SHARED)
|
||||
list(APPEND GLAD_ADD_LIBRARY_ARGS SHARED)
|
||||
elseif(GG_STATIC)
|
||||
list(APPEND GLAD_ADD_LIBRARY_ARGS STATIC)
|
||||
elseif(GG_MODULE)
|
||||
list(APPEND GLAD_ADD_LIBRARY_ARGS MODULE)
|
||||
elseif(GG_INTERFACE)
|
||||
list(APPEND GLAD_ADD_LIBRARY_ARGS INTERFACE)
|
||||
endif()
|
||||
|
||||
if(GG_EXCLUDE_FROM_ALL)
|
||||
list(APPEND GLAD_ADD_LIBRARY_ARGS EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
|
||||
add_library("${TARGET}" ${GLAD_ADD_LIBRARY_ARGS}
|
||||
${GLAD_FILES}
|
||||
)
|
||||
|
||||
target_include_directories("${TARGET}"
|
||||
PUBLIC
|
||||
"${GLAD_DIR}/include"
|
||||
)
|
||||
|
||||
target_link_libraries("${TARGET}"
|
||||
PUBLIC
|
||||
${CMAKE_DL_LIBS}
|
||||
)
|
||||
|
||||
if(GG_SHARED)
|
||||
target_compile_definitions("${TARGET}" PUBLIC GLAD_API_CALL_EXPORT)
|
||||
set_target_properties("${TARGET}"
|
||||
PROPERTIES
|
||||
DEFINE_SYMBOL "GLAD_API_CALL_EXPORT_BUILD"
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
||||
89
third-party/glad/example/c++/hellowindow2.cpp
vendored
Normal file
89
third-party/glad/example/c++/hellowindow2.cpp
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
#include <iostream>
|
||||
|
||||
// GLAD
|
||||
#include <glad/gl.h>
|
||||
|
||||
// GLFW (include after glad)
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
|
||||
// This example is taken from http://learnopengl.com/
|
||||
// http://learnopengl.com/code_viewer.php?code=getting-started/hellowindow2
|
||||
// The code originally used GLEW, I replaced it with Glad
|
||||
|
||||
// Compile:
|
||||
// g++ example/c++/hellowindow2.cpp -Ibuild/include build/src/gl.c -lglfw -ldl
|
||||
|
||||
|
||||
// Function prototypes
|
||||
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode);
|
||||
|
||||
// Window dimensions
|
||||
const GLuint WIDTH = 800, HEIGHT = 600;
|
||||
|
||||
|
||||
// The MAIN function, from here we start the application and run the game loop
|
||||
int main()
|
||||
{
|
||||
std::cout << "Starting GLFW context, OpenGL 3.3" << std::endl;
|
||||
// Init GLFW
|
||||
glfwInit();
|
||||
// Set all the required options for GLFW
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
|
||||
|
||||
// Create a GLFWwindow object that we can use for GLFW's functions
|
||||
GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, "LearnOpenGL", NULL, NULL);
|
||||
glfwMakeContextCurrent(window);
|
||||
if (window == NULL)
|
||||
{
|
||||
std::cout << "Failed to create GLFW window" << std::endl;
|
||||
glfwTerminate();
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Set the required callback functions
|
||||
glfwSetKeyCallback(window, key_callback);
|
||||
|
||||
// Load OpenGL functions, gladLoadGL returns the loaded version, 0 on error.
|
||||
int version = gladLoadGL(glfwGetProcAddress);
|
||||
if (version == 0)
|
||||
{
|
||||
std::cout << "Failed to initialize OpenGL context" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Successfully loaded OpenGL
|
||||
std::cout << "Loaded OpenGL " << GLAD_VERSION_MAJOR(version) << "." << GLAD_VERSION_MINOR(version) << std::endl;
|
||||
|
||||
// Define the viewport dimensions
|
||||
glViewport(0, 0, WIDTH, HEIGHT);
|
||||
|
||||
// Game loop
|
||||
while (!glfwWindowShouldClose(window))
|
||||
{
|
||||
// Check if any events have been activated (key pressed, mouse moved etc.) and call corresponding response functions
|
||||
glfwPollEvents();
|
||||
|
||||
// Render
|
||||
// Clear the colorbuffer
|
||||
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
// Swap the screen buffers
|
||||
glfwSwapBuffers(window);
|
||||
}
|
||||
|
||||
// Terminates GLFW, clearing any resources allocated by GLFW.
|
||||
glfwTerminate();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Is called whenever a key is pressed/released via GLFW
|
||||
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode)
|
||||
{
|
||||
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
|
||||
glfwSetWindowShouldClose(window, GL_TRUE);
|
||||
}
|
||||
130
third-party/glad/example/c++/hellowindow2_macro.cpp
vendored
Normal file
130
third-party/glad/example/c++/hellowindow2_macro.cpp
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
#include <iostream>
|
||||
|
||||
// GLAD
|
||||
#define GLAD_GL_IMPLEMENTATION
|
||||
#include <glad/gl.h>
|
||||
|
||||
// GLFW
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
|
||||
// This example is taken from http://learnopengl.com/
|
||||
// http://learnopengl.com/code_viewer.php?code=getting-started/hellowindow2
|
||||
// The code originally used GLEW, I replaced it with Glad
|
||||
|
||||
// Compile:
|
||||
// g++ example/c++/hellowindow2.cpp -Ibuild/include build/src/glad.c -lglfw -ldl
|
||||
|
||||
|
||||
// Function prototypes
|
||||
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode);
|
||||
|
||||
// Window dimensions
|
||||
const GLuint WIDTH = 800, HEIGHT = 600;
|
||||
|
||||
|
||||
#ifdef GLAD_OPTION_GL_DEBUG
|
||||
// Define a custom callback for demonstration purposes
|
||||
void pre_gl_call(const char *name, void *funcptr, int len_args, ...) {
|
||||
#ifdef GLAD_OPTION_GL_MX
|
||||
printf("Current GL Context: %p -> ", gladGetGLContext());
|
||||
#endif
|
||||
printf("Calling: %s at %p (%d arguments)\n", name, funcptr, len_args);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// The MAIN function, from here we start the application and run the game loop
|
||||
int main()
|
||||
{
|
||||
std::cout << "Starting GLFW context, OpenGL 3.3" << std::endl;
|
||||
// Init GLFW
|
||||
glfwInit();
|
||||
// Set all the required options for GLFW
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
|
||||
|
||||
// Create a GLFWwindow object that we can use for GLFW's functions
|
||||
GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, "LearnOpenGL", NULL, NULL);
|
||||
glfwMakeContextCurrent(window);
|
||||
if (window == NULL)
|
||||
{
|
||||
std::cout << "Failed to create GLFW window" << std::endl;
|
||||
glfwTerminate();
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Set the required callback functions
|
||||
glfwSetKeyCallback(window, key_callback);
|
||||
|
||||
#ifdef GLAD_OPTION_GL_LOADER
|
||||
printf("Using internal loader.\n");
|
||||
#endif
|
||||
|
||||
#ifdef GLAD_OPTION_GL_MX
|
||||
GladGLContext context = {};
|
||||
#ifdef GLAD_OPTION_GL_LOADER
|
||||
int version = gladLoaderLoadGLContext(&context);
|
||||
#else
|
||||
int version = gladLoadGLContext(&context, glfwGetProcAddress);
|
||||
#endif
|
||||
#else
|
||||
#ifdef GLAD_OPTION_GL_LOADER
|
||||
int version = gladLoaderLoadGL();
|
||||
#else
|
||||
int version = gladLoadGL(glfwGetProcAddress);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (version == 0)
|
||||
{
|
||||
std::cout << "Failed to initialize OpenGL context" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::cout << "Loaded OpenGL " << GLAD_VERSION_MAJOR(version) << "." << GLAD_VERSION_MINOR(version) << std::endl;
|
||||
|
||||
#ifdef GLAD_OPTION_GL_DEBUG
|
||||
// before every opengl call call pre_gl_call
|
||||
glad_set_gl_pre_callback(pre_gl_call);
|
||||
// don't use the callbacks for glClear and glClearColor
|
||||
#ifdef GLAD_OPTION_GL_MX_GLOBAL
|
||||
glad_debug_glClear = gladGetGLContext()->Clear;
|
||||
glad_debug_glClearColor = gladGetGLContext()->ClearColor;
|
||||
#else
|
||||
glad_debug_glClear = glad_glClear;
|
||||
glad_debug_glClearColor = glad_glClearColor;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Define the viewport dimensions
|
||||
glViewport(0, 0, WIDTH, HEIGHT);
|
||||
|
||||
// Game loop
|
||||
while (!glfwWindowShouldClose(window))
|
||||
{
|
||||
// Check if any events have been activated (key pressed, mouse moved etc.) and call corresponding response functions
|
||||
glfwPollEvents();
|
||||
|
||||
// Render
|
||||
// Clear the colorbuffer
|
||||
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
// Swap the screen buffers
|
||||
glfwSwapBuffers(window);
|
||||
}
|
||||
|
||||
// Terminates GLFW, clearing any resources allocated by GLFW.
|
||||
glfwTerminate();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Is called whenever a key is pressed/released via GLFW
|
||||
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode)
|
||||
{
|
||||
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
|
||||
glfwSetWindowShouldClose(window, GL_TRUE);
|
||||
}
|
||||
92
third-party/glad/example/c++/hellowindow2_mx.cpp
vendored
Normal file
92
third-party/glad/example/c++/hellowindow2_mx.cpp
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
#include <iostream>
|
||||
|
||||
// GLAD
|
||||
#include <glad/gl.h>
|
||||
|
||||
// GLFW
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
|
||||
// This example is taken from http://learnopengl.com/
|
||||
// http://learnopengl.com/code_viewer.php?code=getting-started/hellowindow2
|
||||
// The code originally used GLEW, I replaced it with Glad
|
||||
|
||||
// Compile:
|
||||
// g++ example/c++/hellowindow2.cpp -Ibuild/include build/src/glad.c -lglfw -ldl
|
||||
|
||||
|
||||
// Function prototypes
|
||||
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode);
|
||||
void draw(GLFWwindow *window, GladGLContext *context);
|
||||
|
||||
// Window dimensions
|
||||
const GLuint WIDTH = 800, HEIGHT = 600;
|
||||
|
||||
|
||||
// The MAIN function, from here we start the application and run the game loop
|
||||
int main()
|
||||
{
|
||||
std::cout << "Starting GLFW context, OpenGL 3.3" << std::endl;
|
||||
// Init GLFW
|
||||
glfwInit();
|
||||
// Set all the required options for GLFW
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
|
||||
|
||||
// Create a GLFWwindow object that we can use for GLFW's functions
|
||||
GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, "LearnOpenGL", NULL, NULL);
|
||||
glfwMakeContextCurrent(window);
|
||||
if (window == NULL)
|
||||
{
|
||||
std::cout << "Failed to create GLFW window" << std::endl;
|
||||
glfwTerminate();
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Set the required callback functions
|
||||
glfwSetKeyCallback(window, key_callback);
|
||||
|
||||
GladGLContext context = {};
|
||||
int version = gladLoadGLContext(&context, glfwGetProcAddress);
|
||||
if (version == 0)
|
||||
{
|
||||
std::cout << "Failed to initialize OpenGL context" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
draw(window, &context);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void draw(GLFWwindow *window, GladGLContext *gl) {
|
||||
// Define the viewport dimensions
|
||||
gl->Viewport(0, 0, WIDTH, HEIGHT);
|
||||
|
||||
// Game loop
|
||||
while (!glfwWindowShouldClose(window))
|
||||
{
|
||||
// Check if any events have been activated (key pressed, mouse moved etc.) and call corresponding response functions
|
||||
glfwPollEvents();
|
||||
|
||||
// Render
|
||||
// Clear the colorbuffer
|
||||
gl->ClearColor(0.2f, 0.3f, 0.3f, 1.0f);
|
||||
gl->Clear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
// Swap the screen buffers
|
||||
glfwSwapBuffers(window);
|
||||
}
|
||||
|
||||
// Terminates GLFW, clearing any resources allocated by GLFW.
|
||||
glfwTerminate();
|
||||
}
|
||||
|
||||
// Is called whenever a key is pressed/released via GLFW
|
||||
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode)
|
||||
{
|
||||
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
|
||||
glfwSetWindowShouldClose(window, GL_TRUE);
|
||||
}
|
||||
18
third-party/glad/example/c++/multiwin_mx/CMakeLists.txt
vendored
Normal file
18
third-party/glad/example/c++/multiwin_mx/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
project(glad_examples_c_multiwin_mx C CXX)
|
||||
|
||||
find_package(glfw3 REQUIRED)
|
||||
|
||||
set(GLAD_SOURCES_DIR "${PROJECT_SOURCE_DIR}/../../..")
|
||||
add_subdirectory("${GLAD_SOURCES_DIR}/cmake" glad_cmake)
|
||||
|
||||
glad_add_library(glad_gl_core_mx_33 REPRODUCIBLE MX API gl:core=3.3)
|
||||
|
||||
add_executable(multiwin_mx
|
||||
multiwin_mx.cpp
|
||||
)
|
||||
target_link_libraries(multiwin_mx
|
||||
PUBLIC
|
||||
glad_gl_core_mx_33
|
||||
glfw
|
||||
)
|
||||
109
third-party/glad/example/c++/multiwin_mx/multiwin_mx.cpp
vendored
Normal file
109
third-party/glad/example/c++/multiwin_mx/multiwin_mx.cpp
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
#include <iostream>
|
||||
|
||||
#include <glad/gl.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
|
||||
// Function prototypes
|
||||
GLFWwindow* create_window(const char *name, int major, int minor);
|
||||
GladGLContext* create_context(GLFWwindow *window);
|
||||
void free_context(GladGLContext *context);
|
||||
void draw(GLFWwindow *window, GladGLContext *context, float r, float g, float b);
|
||||
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode);
|
||||
|
||||
// Window dimensions
|
||||
const GLuint WIDTH = 400, HEIGHT = 300;
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
glfwInit();
|
||||
|
||||
GLFWwindow *window1 = create_window("Window 1", 3, 3);
|
||||
GLFWwindow *window2 = create_window("Window 2", 3, 2);
|
||||
|
||||
if (!window1 || !window2) {
|
||||
std::cout << "Failed to create GLFW window" << std::endl;
|
||||
glfwTerminate();
|
||||
return -1;
|
||||
}
|
||||
|
||||
glfwSetKeyCallback(window1, key_callback);
|
||||
glfwSetKeyCallback(window2, key_callback);
|
||||
|
||||
GladGLContext *context1 = create_context(window1);
|
||||
GladGLContext *context2 = create_context(window2);
|
||||
|
||||
if (!context1 || !context2) {
|
||||
std::cout << "Failed to initialize GL contexts" << std::endl;
|
||||
free_context(context1);
|
||||
free_context(context2);
|
||||
}
|
||||
|
||||
glfwMakeContextCurrent(window1);
|
||||
context1->Viewport(0, 0, WIDTH, HEIGHT);
|
||||
|
||||
glfwMakeContextCurrent(window2);
|
||||
context2->Viewport(0, 0, WIDTH, HEIGHT);
|
||||
|
||||
|
||||
while (!glfwWindowShouldClose(window1) && !glfwWindowShouldClose(window2))
|
||||
{
|
||||
glfwPollEvents();
|
||||
|
||||
draw(window1, context1, 0.5, 0.2, 0.6);
|
||||
draw(window2, context2, 0.0, 0.1, 0.8);
|
||||
}
|
||||
|
||||
free_context(context1);
|
||||
free_context(context2);
|
||||
|
||||
glfwTerminate();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLFWwindow* create_window(const char *name, int major, int minor) {
|
||||
std::cout << "Creating Window, OpenGL " << major << "." << minor << ": " << name << std::endl;
|
||||
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, major);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, minor);
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
|
||||
|
||||
GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, name, NULL, NULL);
|
||||
return window;
|
||||
}
|
||||
|
||||
GladGLContext* create_context(GLFWwindow *window) {
|
||||
glfwMakeContextCurrent(window);
|
||||
|
||||
GladGLContext* context = (GladGLContext*) calloc(1, sizeof(GladGLContext));
|
||||
if (!context) return NULL;
|
||||
|
||||
int version = gladLoadGLContext(context, glfwGetProcAddress);
|
||||
std::cout << "Loaded OpenGL " << GLAD_VERSION_MAJOR(version) << "." << GLAD_VERSION_MINOR(version) << std::endl;
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
void free_context(GladGLContext *context) {
|
||||
free(context);
|
||||
}
|
||||
|
||||
|
||||
void draw(GLFWwindow *window, GladGLContext *gl, float r, float g, float b) {
|
||||
glfwMakeContextCurrent(window);
|
||||
|
||||
gl->ClearColor(r, g, b, 1.0f);
|
||||
gl->Clear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glfwSwapBuffers(window);
|
||||
}
|
||||
|
||||
// Is called whenever a key is pressed/released via GLFW
|
||||
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode)
|
||||
{
|
||||
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
|
||||
glfwSetWindowShouldClose(window, GL_TRUE);
|
||||
}
|
||||
76
third-party/glad/example/c/egl_gles2_glfw_emscripten.c
vendored
Normal file
76
third-party/glad/example/c/egl_gles2_glfw_emscripten.c
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <glad/egl.h>
|
||||
#include <glad/gles2.h>
|
||||
|
||||
#define GLFW_INCLUDE_NONE 1
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten/emscripten.h>
|
||||
#else
|
||||
#define GLFW_EXPOSE_NATIVE_EGL 1
|
||||
#include <GLFW/glfw3native.h>
|
||||
#endif
|
||||
|
||||
const GLuint WIDTH = 800, HEIGHT = 600;
|
||||
|
||||
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode) {
|
||||
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
|
||||
glfwSetWindowShouldClose(window, GL_TRUE);
|
||||
}
|
||||
|
||||
void render_frame(GLFWwindow *window) {
|
||||
glfwPollEvents();
|
||||
|
||||
glClearColor(0.7f, 0.9f, 0.1f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glfwSwapBuffers(window);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
glfwInit();
|
||||
srand(time(NULL));
|
||||
|
||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
|
||||
glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API);
|
||||
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
|
||||
|
||||
GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, "[glad] EGL with GLFW", NULL, NULL);
|
||||
glfwMakeContextCurrent(window);
|
||||
|
||||
glfwSetKeyCallback(window, key_callback);
|
||||
|
||||
#ifndef __EMSCRIPTEN__
|
||||
/* Load EGL */
|
||||
EGLDisplay display = glfwGetEGLDisplay();
|
||||
int egl_version = gladLoaderLoadEGL(display);
|
||||
printf("EGL %d.%d\n", GLAD_VERSION_MAJOR(egl_version), GLAD_VERSION_MINOR(egl_version));
|
||||
#endif
|
||||
|
||||
/* Load GLES */
|
||||
int gles_version = 0;
|
||||
if (rand() % 100 < 50) {
|
||||
printf("-> using GLFW to load GLES2\n");
|
||||
gles_version = gladLoadGLES2(glfwGetProcAddress);
|
||||
} else {
|
||||
printf("-> using GLAD loader to load GLES2\n");
|
||||
gles_version = gladLoaderLoadGLES2();
|
||||
}
|
||||
printf("GLES %d.%d\n", GLAD_VERSION_MAJOR(gles_version), GLAD_VERSION_MINOR(gles_version));
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
emscripten_set_main_loop_arg((em_arg_callback_func) render_frame, window, 60, 1);
|
||||
#else
|
||||
while (!glfwWindowShouldClose(window)) { render_frame(window); }
|
||||
#endif
|
||||
|
||||
glfwTerminate();
|
||||
|
||||
return 0;
|
||||
}
|
||||
21
third-party/glad/example/c/egl_x11/CMakeLists.txt
vendored
Normal file
21
third-party/glad/example/c/egl_x11/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
project(glad_examples_c_egl_x11 C)
|
||||
|
||||
find_package(X11 REQUIRED)
|
||||
|
||||
set(GLAD_SOURCES_DIR "${PROJECT_SOURCE_DIR}/../../..")
|
||||
add_subdirectory("${GLAD_SOURCES_DIR}/cmake" glad_cmake)
|
||||
|
||||
glad_add_library(glad_egl_15_gles2_20 REPRODUCIBLE LOADER API egl=1.5 gles2=2.0)
|
||||
add_executable(egl_x11
|
||||
egl_x11.c
|
||||
)
|
||||
target_include_directories(egl_x11
|
||||
PUBLIC
|
||||
${X11_INCLUDE_DIR}
|
||||
)
|
||||
target_link_libraries(egl_x11
|
||||
PUBLIC
|
||||
glad_egl_15_gles2_20
|
||||
${X11_LIBRARIES}
|
||||
)
|
||||
163
third-party/glad/example/c/egl_x11/egl_x11.c
vendored
Normal file
163
third-party/glad/example/c/egl_x11/egl_x11.c
vendored
Normal file
@@ -0,0 +1,163 @@
|
||||
// gcc example/c/egl_x11.c -Ibuild/include build/src/*.c -ldl -lX11
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
#include <glad/egl.h>
|
||||
#include <glad/gles2.h>
|
||||
|
||||
|
||||
const int window_width = 800, window_height = 480;
|
||||
|
||||
|
||||
int main(void) {
|
||||
Display *display = XOpenDisplay(NULL);
|
||||
if (display == NULL) {
|
||||
printf("cannot connect to X server\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int screen = DefaultScreen(display);
|
||||
Window root = RootWindow(display, screen);
|
||||
Visual *visual = DefaultVisual(display, screen);
|
||||
|
||||
Colormap colormap = XCreateColormap(display, root, visual, AllocNone);
|
||||
|
||||
XSetWindowAttributes attributes;
|
||||
attributes.colormap = colormap;
|
||||
attributes.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask;
|
||||
|
||||
Window window =
|
||||
XCreateWindow(display, root, 0, 0, window_width, window_height, 0,
|
||||
DefaultDepth(display, screen), InputOutput, visual,
|
||||
CWColormap | CWEventMask, &attributes);
|
||||
|
||||
XFreeColormap(display, colormap);
|
||||
|
||||
XMapWindow(display, window);
|
||||
XStoreName(display, window, "[glad] EGL with X11");
|
||||
|
||||
if (!window) {
|
||||
printf("Unable to create window.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int egl_version = gladLoaderLoadEGL(NULL);
|
||||
if (!egl_version) {
|
||||
printf("Unable to load EGL.\n");
|
||||
return 1;
|
||||
}
|
||||
printf("Loaded EGL %d.%d on first load.\n",
|
||||
GLAD_VERSION_MAJOR(egl_version), GLAD_VERSION_MINOR(egl_version));
|
||||
|
||||
EGLDisplay egl_display = eglGetDisplay((EGLNativeDisplayType) display);
|
||||
if (egl_display == EGL_NO_DISPLAY) {
|
||||
printf("Got no EGL display.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!eglInitialize(egl_display, NULL, NULL)) {
|
||||
printf("Unable to initialize EGL\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
egl_version = gladLoaderLoadEGL(egl_display);
|
||||
if (!egl_version) {
|
||||
printf("Unable to reload EGL.\n");
|
||||
return 1;
|
||||
}
|
||||
printf("Loaded EGL %d.%d after reload.\n",
|
||||
GLAD_VERSION_MAJOR(egl_version), GLAD_VERSION_MINOR(egl_version));
|
||||
|
||||
EGLint attr[] = {
|
||||
EGL_BUFFER_SIZE, 16,
|
||||
EGL_RENDERABLE_TYPE,
|
||||
EGL_OPENGL_ES2_BIT,
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
EGLConfig egl_config;
|
||||
EGLint num_config;
|
||||
if (!eglChooseConfig(egl_display, attr, &egl_config, 1, &num_config)) {
|
||||
printf("Failed to choose config (eglError: %d)\n", eglGetError());
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (num_config != 1) {
|
||||
printf("Didn't get exactly one config, but %d\n", num_config);
|
||||
return 1;
|
||||
}
|
||||
|
||||
EGLSurface egl_surface =
|
||||
eglCreateWindowSurface(egl_display, egl_config, window, NULL);
|
||||
if (egl_surface == EGL_NO_SURFACE) {
|
||||
printf("Unable to create EGL surface (eglError: %d)\n",
|
||||
eglGetError());
|
||||
return 1;
|
||||
}
|
||||
|
||||
EGLint ctxattr[] = {
|
||||
EGL_CONTEXT_CLIENT_VERSION, 2,
|
||||
EGL_NONE
|
||||
};
|
||||
EGLContext egl_context =
|
||||
eglCreateContext(egl_display, egl_config, EGL_NO_CONTEXT, ctxattr);
|
||||
if (egl_context == EGL_NO_CONTEXT) {
|
||||
printf("Unable to create EGL context (eglError: %d)\n",
|
||||
eglGetError());
|
||||
return 1;
|
||||
}
|
||||
|
||||
// activate context before loading GL functions using glad
|
||||
eglMakeCurrent(egl_display, egl_surface, egl_surface, egl_context);
|
||||
|
||||
int gles_version = gladLoaderLoadGLES2();
|
||||
if (!gles_version) {
|
||||
printf("Unable to load GLES.\n");
|
||||
return 1;
|
||||
}
|
||||
printf("Loaded GLES %d.%d.\n",
|
||||
GLAD_VERSION_MAJOR(gles_version), GLAD_VERSION_MINOR(gles_version));
|
||||
|
||||
XWindowAttributes gwa;
|
||||
XGetWindowAttributes(display, window, &gwa);
|
||||
glViewport(0, 0, gwa.width, gwa.height);
|
||||
|
||||
bool quit = false;
|
||||
while (!quit) {
|
||||
while (XPending(display)) {
|
||||
XEvent xev;
|
||||
XNextEvent(display, &xev);
|
||||
|
||||
if (xev.type == KeyPress) {
|
||||
quit = true;
|
||||
}
|
||||
}
|
||||
|
||||
glClearColor(0.8, 0.6, 0.7, 1.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
eglSwapBuffers(egl_display, egl_surface);
|
||||
|
||||
usleep(1000 * 10);
|
||||
}
|
||||
|
||||
gladLoaderUnloadGLES2();
|
||||
|
||||
eglDestroyContext(egl_display, egl_context);
|
||||
eglDestroySurface(egl_display, egl_surface);
|
||||
eglTerminate(egl_display);
|
||||
|
||||
gladLoaderUnloadEGL();
|
||||
|
||||
XDestroyWindow(display, window);
|
||||
XCloseDisplay(display);
|
||||
|
||||
return 0;
|
||||
}
|
||||
44
third-party/glad/example/c/gl_glfw.c
vendored
Normal file
44
third-party/glad/example/c/gl_glfw.c
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define GLAD_GL_IMPLEMENTATION // Necessary for headeronly version.
|
||||
#include <glad/gl.h>
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
|
||||
const GLuint WIDTH = 800, HEIGHT = 600;
|
||||
|
||||
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode) {
|
||||
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
|
||||
glfwSetWindowShouldClose(window, GL_TRUE);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
glfwInit();
|
||||
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
|
||||
GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, "[glad] GL with GLFW", NULL, NULL);
|
||||
glfwMakeContextCurrent(window);
|
||||
|
||||
glfwSetKeyCallback(window, key_callback);
|
||||
|
||||
int version = gladLoadGL(glfwGetProcAddress);
|
||||
printf("GL %d.%d\n", GLAD_VERSION_MAJOR(version), GLAD_VERSION_MINOR(version));
|
||||
|
||||
while (!glfwWindowShouldClose(window)) {
|
||||
glfwPollEvents();
|
||||
|
||||
glClearColor(0.7f, 0.9f, 0.1f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glfwSwapBuffers(window);
|
||||
}
|
||||
|
||||
glfwTerminate();
|
||||
|
||||
return 0;
|
||||
}
|
||||
73
third-party/glad/example/c/gl_glfw_on_demand.c
vendored
Normal file
73
third-party/glad/example/c/gl_glfw_on_demand.c
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
// This example requires you to generate glad with the --on-demand option and optionally --loader and --debug.
|
||||
// gcc -o gl_glfw_on_demand example/c/gl_glfw_on_demand.c build/src/gl.c -Ibuild/include -ldl -lglfw
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <glad/gl.h>
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
|
||||
const GLuint WIDTH = 800, HEIGHT = 600;
|
||||
|
||||
|
||||
static void pre_call_gl_callback(const char *name, GLADapiproc apiproc, int len_args, ...) {
|
||||
printf("about to call gl func: %s\n", name);
|
||||
}
|
||||
|
||||
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode) {
|
||||
if (action != GLFW_PRESS) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (key == GLFW_KEY_ESCAPE) {
|
||||
glfwSetWindowShouldClose(window, GL_TRUE);
|
||||
#ifdef GLAD_OPTION_GL_DEBUG
|
||||
} else if (key == GLFW_KEY_H) {
|
||||
printf("Installing glad debug function pointers\n");
|
||||
gladInstallGLDebug();
|
||||
} else if (key == GLFW_KEY_J) {
|
||||
printf("Uninstalling glad debug function pointers\n");
|
||||
gladUninstallGLDebug();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
glfwInit();
|
||||
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
|
||||
GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, "[glad] GL with GLFW", NULL, NULL);
|
||||
glfwMakeContextCurrent(window);
|
||||
|
||||
glfwSetKeyCallback(window, key_callback);
|
||||
|
||||
// If glad is generated with the --loader and --on-demand option
|
||||
// you don't have to call any glad function.
|
||||
// It is recommended to use the loader provided by your context creation library
|
||||
// instead of the glad loader.
|
||||
#ifndef GLAD_GL_LOADER
|
||||
gladSetGLOnDemandLoader(glfwGetProcAddress);
|
||||
#endif
|
||||
|
||||
#ifdef GLAD_OPTION_GL_DEBUG
|
||||
gladUninstallGLDebug();
|
||||
gladSetGLPreCallback(pre_call_gl_callback);
|
||||
#endif
|
||||
|
||||
while (!glfwWindowShouldClose(window)) {
|
||||
glfwPollEvents();
|
||||
|
||||
glClearColor(0.7f, 0.9f, 0.1f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glfwSwapBuffers(window);
|
||||
}
|
||||
|
||||
glfwTerminate();
|
||||
|
||||
return 0;
|
||||
}
|
||||
64
third-party/glad/example/c/gl_sdl2.c
vendored
Normal file
64
third-party/glad/example/c/gl_sdl2.c
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
// gcc example/c/gl_sdl2.c build/src/gl.c -Ibuild/include `sdl2-config --libs --cflags` -ldl
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <glad/gl.h>
|
||||
#include <SDL.h>
|
||||
#include <SDL_opengl.h>
|
||||
|
||||
|
||||
const GLuint WIDTH = 800, HEIGHT = 600;
|
||||
|
||||
int main(void) {
|
||||
// code without checking for errors
|
||||
SDL_Init(SDL_INIT_VIDEO);
|
||||
|
||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
|
||||
|
||||
SDL_Window *window = SDL_CreateWindow(
|
||||
"[glad] GL with SDL",
|
||||
SDL_WINDOWPOS_CENTERED,
|
||||
SDL_WINDOWPOS_CENTERED,
|
||||
WIDTH, HEIGHT,
|
||||
SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN
|
||||
);
|
||||
|
||||
SDL_GLContext context = SDL_GL_CreateContext(window);
|
||||
|
||||
int version = gladLoadGL((GLADloadfunc) SDL_GL_GetProcAddress);
|
||||
printf("GL %d.%d\n", GLAD_VERSION_MAJOR(version), GLAD_VERSION_MINOR(version));
|
||||
|
||||
int exit = 0;
|
||||
while(!exit) {
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event)) {
|
||||
switch(event.type) {
|
||||
case SDL_QUIT:
|
||||
exit = 1;
|
||||
break;
|
||||
case SDL_KEYUP:
|
||||
if (event.key.keysym.sym == SDLK_ESCAPE) {
|
||||
exit = 1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
glClearColor(0.7f, 0.9f, 0.1f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
SDL_GL_SwapWindow(window);
|
||||
SDL_Delay(1);
|
||||
}
|
||||
|
||||
SDL_GL_DeleteContext(context);
|
||||
SDL_DestroyWindow(window);
|
||||
SDL_Quit();
|
||||
|
||||
return 0;
|
||||
}
|
||||
55
third-party/glad/example/c/gles2_glfw_emscripten.c
vendored
Normal file
55
third-party/glad/example/c/gles2_glfw_emscripten.c
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <glad/gles2.h>
|
||||
|
||||
#define GLFW_INCLUDE_NONE 1
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten/emscripten.h>
|
||||
#endif
|
||||
|
||||
|
||||
const GLuint WIDTH = 800, HEIGHT = 600;
|
||||
|
||||
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode) {
|
||||
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
|
||||
glfwSetWindowShouldClose(window, GL_TRUE);
|
||||
}
|
||||
|
||||
void render_frame(GLFWwindow *window) {
|
||||
glfwPollEvents();
|
||||
|
||||
glClearColor(0.7f, 0.9f, 0.1f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glfwSwapBuffers(window);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
glfwInit();
|
||||
|
||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
|
||||
glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API);
|
||||
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
|
||||
|
||||
GLFWwindow *window = glfwCreateWindow(WIDTH, HEIGHT, "[glad] GLES2 with GLFW", NULL, NULL);
|
||||
glfwMakeContextCurrent(window);
|
||||
|
||||
glfwSetKeyCallback(window, key_callback);
|
||||
|
||||
/* Load GLES */
|
||||
int gles_version = gladLoadGLES2(glfwGetProcAddress);
|
||||
printf("GLES %d.%d\n", GLAD_VERSION_MAJOR(gles_version), GLAD_VERSION_MINOR(gles_version));
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
emscripten_set_main_loop_arg((em_arg_callback_func) render_frame, window, 60, 1);
|
||||
#else
|
||||
while (!glfwWindowShouldClose(window)) { render_frame(window); }
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
78
third-party/glad/example/c/glut.c
vendored
Normal file
78
third-party/glad/example/c/glut.c
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <glad/gl.h>
|
||||
#ifdef __APPLE__
|
||||
#include <GLUT/glut.h>
|
||||
#else
|
||||
#include <GL/glut.h>
|
||||
#endif
|
||||
|
||||
// This file is a modified version of gl3w's test.c
|
||||
// https://github.com/skaslev/gl3w/blob/master/src/test.c
|
||||
|
||||
// Compile:
|
||||
// gcc example/c/simple.c -Ibuild/include build/src/glad.c -lglut -ldl
|
||||
|
||||
|
||||
static int width = 600, height = 600;
|
||||
|
||||
static void display(void)
|
||||
{
|
||||
glClearColor(1.0f, 0.2f, 0.7f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glutSwapBuffers();
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void reshape(int w, int h)
|
||||
{
|
||||
width = w > 1 ? w : 1;
|
||||
height = h > 1 ? h : 1;
|
||||
glViewport(0, 0, width, height);
|
||||
glClearDepth(1.0);
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
static void keyboard(unsigned char key, int x, int y)
|
||||
{
|
||||
switch (key) {
|
||||
case 27: // Escape key
|
||||
glutDestroyWindow(1);
|
||||
return;
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
glutInit(&argc, argv);
|
||||
glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE);
|
||||
glutInitWindowSize(width, height);
|
||||
glutCreateWindow("cookie");
|
||||
|
||||
glutReshapeFunc(reshape);
|
||||
glutDisplayFunc(display);
|
||||
glutKeyboardFunc(keyboard);
|
||||
|
||||
// initialize glad after creating a context
|
||||
int version = gladLoaderLoadGL();
|
||||
if(version == 0) {
|
||||
printf("Something went wrong!\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
printf("OpenGL %d.%d\n", GLAD_VERSION_MAJOR(version), GLAD_VERSION_MINOR(version));
|
||||
if (!GLAD_GL_VERSION_2_0) {
|
||||
printf("Your system doesn't support OpenGL >= 2!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("OpenGL %s, GLSL %s\n",
|
||||
glGetString(GL_VERSION),
|
||||
glGetString(GL_SHADING_LANGUAGE_VERSION));
|
||||
|
||||
glutMainLoop();
|
||||
|
||||
return 0;
|
||||
}
|
||||
98
third-party/glad/example/c/glx.c
vendored
Normal file
98
third-party/glad/example/c/glx.c
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
// gcc example/c/glx.c -o build/glx -Ibuild/include build/src/*.c -ldl -lX11
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
#include <glad/gl.h>
|
||||
#include <glad/glx.h>
|
||||
|
||||
|
||||
const int window_width = 800, window_height = 480;
|
||||
|
||||
|
||||
int main(void) {
|
||||
Display *display = XOpenDisplay(NULL);
|
||||
if (display == NULL) {
|
||||
printf("cannot connect to X server\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int screen = DefaultScreen(display);
|
||||
|
||||
int glx_version = gladLoaderLoadGLX(display, screen);
|
||||
if (!glx_version) {
|
||||
printf("Unable to load GLX.\n");
|
||||
return 1;
|
||||
}
|
||||
printf("Loaded GLX %d.%d\n", GLAD_VERSION_MAJOR(glx_version), GLAD_VERSION_MINOR(glx_version));
|
||||
|
||||
Window root = RootWindow(display, screen);
|
||||
|
||||
GLint visual_attributes[] = { GLX_RGBA, GLX_DOUBLEBUFFER, None };
|
||||
XVisualInfo *visual_info = glXChooseVisual(display, screen, visual_attributes);
|
||||
|
||||
Colormap colormap = XCreateColormap(display, root, visual_info->visual, AllocNone);
|
||||
|
||||
XSetWindowAttributes attributes;
|
||||
attributes.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask;
|
||||
attributes.colormap = colormap;
|
||||
|
||||
Window window =
|
||||
XCreateWindow(display, root, 0, 0, window_width, window_height, 0,
|
||||
visual_info->depth, InputOutput, visual_info->visual,
|
||||
CWColormap | CWEventMask, &attributes);
|
||||
|
||||
XMapWindow(display, window);
|
||||
XStoreName(display, window, "[glad] GLX with X11");
|
||||
|
||||
if (!window) {
|
||||
printf("Unable to create window.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
GLXContext context = glXCreateContext(display, visual_info, NULL, GL_TRUE);
|
||||
glXMakeCurrent(display, window, context);
|
||||
|
||||
int gl_version = gladLoaderLoadGL();
|
||||
if (!gl_version) {
|
||||
printf("Unable to load GL.\n");
|
||||
return 1;
|
||||
}
|
||||
printf("Loaded GL %d.%d\n", GLAD_VERSION_MAJOR(gl_version), GLAD_VERSION_MINOR(gl_version));
|
||||
|
||||
XWindowAttributes gwa;
|
||||
XGetWindowAttributes(display, window, &gwa);
|
||||
glViewport(0, 0, gwa.width, gwa.height);
|
||||
|
||||
bool quit = false;
|
||||
while (!quit) {
|
||||
while (XPending(display)) {
|
||||
XEvent xev;
|
||||
XNextEvent(display, &xev);
|
||||
|
||||
if (xev.type == KeyPress) {
|
||||
quit = true;
|
||||
}
|
||||
}
|
||||
|
||||
glClearColor(0.8, 0.6, 0.7, 1.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glXSwapBuffers(display, window);
|
||||
|
||||
usleep(1000 * 10);
|
||||
}
|
||||
|
||||
glXMakeCurrent(display, 0, 0);
|
||||
glXDestroyContext(display, context);
|
||||
|
||||
XDestroyWindow(display, window);
|
||||
XFreeColormap(display, colormap);
|
||||
XCloseDisplay(display);
|
||||
|
||||
gladLoaderUnloadGLX();
|
||||
}
|
||||
117
third-party/glad/example/c/glx_modern.c
vendored
Normal file
117
third-party/glad/example/c/glx_modern.c
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
// gcc example/c/glx.c -o build/glx -Ibuild/include build/src/*.c -ldl -lX11
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
#include <glad/gl.h>
|
||||
#include <glad/glx.h>
|
||||
|
||||
|
||||
const int window_width = 800, window_height = 480;
|
||||
|
||||
|
||||
int main(void) {
|
||||
Display *display = XOpenDisplay(NULL);
|
||||
if (display == NULL) {
|
||||
printf("cannot connect to X server\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int screen = DefaultScreen(display);
|
||||
Window root = RootWindow(display, screen);
|
||||
Visual *visual = DefaultVisual(display, screen);
|
||||
|
||||
Colormap colormap = XCreateColormap(display, root, visual, AllocNone);
|
||||
|
||||
XSetWindowAttributes attributes;
|
||||
attributes.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask;
|
||||
attributes.colormap = colormap;
|
||||
|
||||
Window window =
|
||||
XCreateWindow(display, root, 0, 0, window_width, window_height, 0,
|
||||
DefaultDepth(display, screen), InputOutput, visual,
|
||||
CWColormap | CWEventMask, &attributes);
|
||||
|
||||
XMapWindow(display, window);
|
||||
XStoreName(display, window, "[glad] Modern GLX with X11");
|
||||
|
||||
if (!window) {
|
||||
printf("Unable to create window.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int glx_version = gladLoaderLoadGLX(display, screen);
|
||||
if (!glx_version) {
|
||||
printf("Unable to load GLX.\n");
|
||||
return 1;
|
||||
}
|
||||
printf("Loaded GLX %d.%d\n", GLAD_VERSION_MAJOR(glx_version), GLAD_VERSION_MINOR(glx_version));
|
||||
|
||||
GLint visual_attributes[] = {
|
||||
GLX_RENDER_TYPE, GLX_RGBA_BIT,
|
||||
GLX_DOUBLEBUFFER, 1,
|
||||
None
|
||||
};
|
||||
|
||||
int num_fbc = 0;
|
||||
GLXFBConfig *fbc = glXChooseFBConfig(display, screen, visual_attributes, &num_fbc);
|
||||
|
||||
GLint context_attributes[] = {
|
||||
GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
|
||||
GLX_CONTEXT_MINOR_VERSION_ARB, 3,
|
||||
GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
|
||||
None
|
||||
};
|
||||
|
||||
GLXContext context =
|
||||
glXCreateContextAttribsARB(display, fbc[0], NULL, 1, context_attributes);
|
||||
if (!context) {
|
||||
printf("Unable to create OpenGL context.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
glXMakeCurrent(display, window, context);
|
||||
|
||||
int gl_version = gladLoaderLoadGL();
|
||||
if (!gl_version) {
|
||||
printf("Unable to load GL.\n");
|
||||
return 1;
|
||||
}
|
||||
printf("Loaded GL %d.%d\n", GLAD_VERSION_MAJOR(gl_version), GLAD_VERSION_MINOR(gl_version));
|
||||
|
||||
XWindowAttributes gwa;
|
||||
XGetWindowAttributes(display, window, &gwa);
|
||||
glViewport(0, 0, gwa.width, gwa.height);
|
||||
|
||||
bool quit = false;
|
||||
while (!quit) {
|
||||
while (XPending(display)) {
|
||||
XEvent xev;
|
||||
XNextEvent(display, &xev);
|
||||
|
||||
if (xev.type == KeyPress) {
|
||||
quit = true;
|
||||
}
|
||||
}
|
||||
|
||||
glClearColor(0.8, 0.6, 0.7, 1.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glXSwapBuffers(display, window);
|
||||
|
||||
usleep(1000 * 10);
|
||||
}
|
||||
|
||||
glXMakeCurrent(display, 0, 0);
|
||||
glXDestroyContext(display, context);
|
||||
|
||||
XDestroyWindow(display, window);
|
||||
XFreeColormap(display, colormap);
|
||||
XCloseDisplay(display);
|
||||
|
||||
gladLoaderUnloadGLX();
|
||||
}
|
||||
17
third-party/glad/example/c/vulkan_tri_glfw/CMakeLists.txt
vendored
Normal file
17
third-party/glad/example/c/vulkan_tri_glfw/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
project(glad_examples_c_vulkan_tri_glfw C)
|
||||
|
||||
set(GLAD_SOURCES_DIR "${PROJECT_SOURCE_DIR}/../../..")
|
||||
add_subdirectory("${GLAD_SOURCES_DIR}/cmake" glad_cmake)
|
||||
|
||||
find_package(glfw3 REQUIRED)
|
||||
|
||||
glad_add_library(glad_vulkan_12 REPRODUCIBLE LOADER API vulkan=1.2)
|
||||
add_executable(vulkan_tri_glfw
|
||||
vulkan_tri_glfw.c
|
||||
)
|
||||
target_link_libraries(vulkan_tri_glfw
|
||||
PUBLIC
|
||||
glad_vulkan_12
|
||||
glfw
|
||||
)
|
||||
2244
third-party/glad/example/c/vulkan_tri_glfw/vulkan_tri_glfw.c
vendored
Normal file
2244
third-party/glad/example/c/vulkan_tri_glfw/vulkan_tri_glfw.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
172
third-party/glad/example/c/wgl.c
vendored
Normal file
172
third-party/glad/example/c/wgl.c
vendored
Normal file
@@ -0,0 +1,172 @@
|
||||
/**
|
||||
* Thanks to Xeek for the code!
|
||||
*
|
||||
* Building and running under Linux:
|
||||
* i686-w64-mingw32-gcc example/c/wgl.c build/src/wgl.c build/src/gl.c -Ibuild/include -lgdi32 -lopengl32
|
||||
* wine a.exe
|
||||
*/
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <glad/wgl.h>
|
||||
#include <glad/gl.h>
|
||||
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
|
||||
static const TCHAR window_classname[] = _T("SampleWndClass");
|
||||
static const TCHAR window_title[] = _T("[glad] WGL");
|
||||
static const POINT window_location = { CW_USEDEFAULT, 0 };
|
||||
static const SIZE window_size = { 1024, 768 };
|
||||
static const GLfloat clear_color[] = { 0.0f, 0.0f, 1.0f, 1.0f };
|
||||
|
||||
|
||||
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
|
||||
UNREFERENCED_PARAMETER(hPrevInstance);
|
||||
UNREFERENCED_PARAMETER(lpCmdLine);
|
||||
|
||||
WNDCLASSEX wcex = { };
|
||||
wcex.cbSize = sizeof(WNDCLASSEX);
|
||||
wcex.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wcex.lpfnWndProc = WndProc;
|
||||
wcex.hInstance = hInstance;
|
||||
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wcex.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
|
||||
wcex.lpszClassName = window_classname;
|
||||
|
||||
ATOM wndclass = RegisterClassEx(&wcex);
|
||||
|
||||
HWND hWnd = CreateWindow(MAKEINTATOM(wndclass), window_title,
|
||||
WS_OVERLAPPEDWINDOW,
|
||||
window_location.x, window_location.y,
|
||||
window_size.cx, window_size.cy,
|
||||
NULL, NULL, hInstance, NULL);
|
||||
|
||||
if (!hWnd) {
|
||||
MessageBox(NULL, _T("Failed to create window!"), window_title, MB_ICONERROR);
|
||||
return -1;
|
||||
}
|
||||
// Configure & Initialize OpenGL:
|
||||
|
||||
// Get a device context so I can set the pixel format later:
|
||||
HDC hdc = GetDC(hWnd);
|
||||
if (hdc == NULL) {
|
||||
DestroyWindow(hWnd);
|
||||
MessageBox(NULL, _T("Failed to get Window's device context!"), window_title, MB_ICONERROR);
|
||||
return -1;
|
||||
}
|
||||
// Set the pixel format for the device context:
|
||||
PIXELFORMATDESCRIPTOR pfd = { };
|
||||
pfd.nSize = sizeof(pfd);
|
||||
pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR); // Set the size of the PFD to the size of the class
|
||||
pfd.dwFlags = PFD_DOUBLEBUFFER | PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW; // Enable double buffering, opengl support and drawing to a window
|
||||
pfd.iPixelType = PFD_TYPE_RGBA; // Set our application to use RGBA pixels
|
||||
pfd.cColorBits = 32; // Give us 32 bits of color information (the higher, the more colors)
|
||||
pfd.cDepthBits = 32; // Give us 32 bits of depth information (the higher, the more depth levels)
|
||||
pfd.iLayerType = PFD_MAIN_PLANE; // Set the layer of the PFD
|
||||
int format = ChoosePixelFormat(hdc, &pfd);
|
||||
if (format == 0 || SetPixelFormat(hdc, format, &pfd) == FALSE) {
|
||||
ReleaseDC(hWnd, hdc);
|
||||
DestroyWindow(hWnd);
|
||||
MessageBox(NULL, _T("Failed to set a compatible pixel format!"), window_title, MB_ICONERROR);
|
||||
return -1;
|
||||
}
|
||||
// Create and enable a temporary (helper) opengl context:
|
||||
HGLRC temp_context = NULL;
|
||||
if (NULL == (temp_context = wglCreateContext(hdc))) {
|
||||
ReleaseDC(hWnd, hdc);
|
||||
DestroyWindow(hWnd);
|
||||
MessageBox(NULL, _T("Failed to create the initial rendering context!"), window_title, MB_ICONERROR);
|
||||
return -1;
|
||||
}
|
||||
wglMakeCurrent(hdc, temp_context);
|
||||
|
||||
// Load WGL Extensions:
|
||||
gladLoaderLoadWGL(hdc);
|
||||
|
||||
// Set the desired OpenGL version:
|
||||
int attributes[] = {
|
||||
WGL_CONTEXT_MAJOR_VERSION_ARB, 3, // Set the MAJOR version of OpenGL to 3
|
||||
WGL_CONTEXT_MINOR_VERSION_ARB, 2, // Set the MINOR version of OpenGL to 2
|
||||
WGL_CONTEXT_FLAGS_ARB,
|
||||
WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB, // Set our OpenGL context to be forward compatible
|
||||
0
|
||||
};
|
||||
|
||||
// Create the final opengl context and get rid of the temporary one:
|
||||
HGLRC opengl_context = NULL;
|
||||
if (NULL == (opengl_context = wglCreateContextAttribsARB(hdc, NULL, attributes))) {
|
||||
wglDeleteContext(temp_context);
|
||||
ReleaseDC(hWnd, hdc);
|
||||
DestroyWindow(hWnd);
|
||||
MessageBox(NULL, _T("Failed to create the final rendering context!"), window_title, MB_ICONERROR);
|
||||
return -1;
|
||||
}
|
||||
wglMakeCurrent(NULL, NULL); // Remove the temporary context from being active
|
||||
wglDeleteContext(temp_context); // Delete the temporary OpenGL context
|
||||
wglMakeCurrent(hdc, opengl_context); // Make our OpenGL 3.2 context current
|
||||
|
||||
// Glad Loader!
|
||||
if (!gladLoaderLoadGL()) {
|
||||
wglMakeCurrent(NULL, NULL);
|
||||
wglDeleteContext(opengl_context);
|
||||
ReleaseDC(hWnd, hdc);
|
||||
DestroyWindow(hWnd);
|
||||
MessageBox(NULL, _T("Glad Loader failed!"), window_title, MB_ICONERROR);
|
||||
return -1;
|
||||
}
|
||||
// Show & Update the main window:
|
||||
ShowWindow(hWnd, nCmdShow);
|
||||
UpdateWindow(hWnd);
|
||||
|
||||
// A typical native Windows game loop:
|
||||
bool should_quit = false;
|
||||
MSG msg = { };
|
||||
while (!should_quit) {
|
||||
// Generally you'll want to empty out the message queue before each rendering
|
||||
// frame or messages will build up in the queue possibly causing input
|
||||
// delay. Multiple messages and input events occur before each frame.
|
||||
while (PeekMessage(&msg, hWnd, 0, 0, PM_REMOVE)) {
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
|
||||
if (msg.message == WM_QUIT || (msg.message == WM_KEYDOWN && msg.wParam == VK_ESCAPE))
|
||||
should_quit = true;
|
||||
}
|
||||
|
||||
glClearColor(clear_color[0], clear_color[1], clear_color[2], clear_color[3]);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
SwapBuffers(hdc);
|
||||
}
|
||||
|
||||
// Clean-up:
|
||||
if (opengl_context)
|
||||
wglDeleteContext(opengl_context);
|
||||
if (hdc)
|
||||
ReleaseDC(hWnd, hdc);
|
||||
if (hWnd)
|
||||
DestroyWindow(hWnd);
|
||||
|
||||
return (int) msg.wParam;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
||||
switch (uMsg) {
|
||||
case WM_QUIT:
|
||||
case WM_CLOSE:
|
||||
DestroyWindow(hWnd);
|
||||
break;
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
default:
|
||||
return DefWindowProc(hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
8
third-party/glad/example/rust/gl-glfw-mx/Cargo.toml
vendored
Normal file
8
third-party/glad/example/rust/gl-glfw-mx/Cargo.toml
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "gl-glfw"
|
||||
version = "0.1.0"
|
||||
|
||||
[dependencies]
|
||||
glfw = "0.37.0"
|
||||
glad-gl = { path = "./build/glad-gl" }
|
||||
|
||||
34
third-party/glad/example/rust/gl-glfw-mx/README.md
vendored
Normal file
34
third-party/glad/example/rust/gl-glfw-mx/README.md
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
Example: gl-glfw-mx
|
||||
================
|
||||
|
||||
|
||||
This is basic example showcasing `glad-gl` in combination with
|
||||
[`glfw`](https://crates.io/crates/glfw). And multiple OpenGL contexts
|
||||
in different windows.
|
||||
|
||||
To run the example use the following command:
|
||||
|
||||
```sh
|
||||
./init.sh && cargo run
|
||||
```
|
||||
|
||||
The `init.sh` script is just a small utility used to generate
|
||||
the `glad-gl` crate into the `build/` directory. The `Cargo.toml`
|
||||
references the dependency using:
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
glad-gl = { path = "./build/glad-gl" }
|
||||
```
|
||||
|
||||
This example is the basic example of the
|
||||
[glfw crate](https://crates.io/crates/glfw) with some
|
||||
OpenGL instructions added and just one additional line
|
||||
to initialize `glad`:
|
||||
|
||||
```rust
|
||||
gl::load(|e| glfw.get_proc_address_raw(e) as *const std::os::raw::c_void);
|
||||
```
|
||||
|
||||
That's all that is needed to initialize and use OpenGL using `glad`!
|
||||
|
||||
9
third-party/glad/example/rust/gl-glfw-mx/init.sh
vendored
Executable file
9
third-party/glad/example/rust/gl-glfw-mx/init.sh
vendored
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
BASE_PATH="$(dirname $(realpath $0))"
|
||||
|
||||
|
||||
cd "${BASE_PATH}/../../../"
|
||||
|
||||
python -m glad --out-path "${BASE_PATH}/build" --extensions="" --api="gl:core=3.3" rust --mx
|
||||
|
||||
63
third-party/glad/example/rust/gl-glfw-mx/src/main.rs
vendored
Normal file
63
third-party/glad/example/rust/gl-glfw-mx/src/main.rs
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
extern crate glfw;
|
||||
extern crate glad_gl;
|
||||
use std::sync::mpsc::Receiver;
|
||||
use glfw::{Action, Context, Key};
|
||||
use glad_gl::gl;
|
||||
|
||||
|
||||
struct Window {
|
||||
source: glfw::Window,
|
||||
events: Receiver<(f64, glfw::WindowEvent)>,
|
||||
gl: gl::Gl
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();
|
||||
|
||||
let mut w1 = create_window(&mut glfw);
|
||||
let mut w2 = create_window(&mut glfw);
|
||||
|
||||
while !w1.source.should_close() && !w2.source.should_close() {
|
||||
glfw.poll_events();
|
||||
|
||||
draw(&mut w1);
|
||||
draw(&mut w2);
|
||||
}
|
||||
}
|
||||
|
||||
fn create_window(glfw: &mut glfw::Glfw) -> Window {
|
||||
let (mut window, events) = glfw
|
||||
.create_window(300, 300, "[glad] Rust - OpenGL with GLFW", glfw::WindowMode::Windowed)
|
||||
.expect("Failed to create GLFW window.");
|
||||
|
||||
window.set_key_polling(true);
|
||||
window.make_current();
|
||||
|
||||
let gl = gl::load(|e| glfw.get_proc_address_raw(e) as *const std::os::raw::c_void);
|
||||
|
||||
Window {
|
||||
source: window, events, gl
|
||||
}
|
||||
}
|
||||
|
||||
fn draw(window: &mut Window) {
|
||||
for (_, event) in glfw::flush_messages(&window.events) {
|
||||
handle_window_event(&mut window.source, event);
|
||||
}
|
||||
|
||||
window.source.make_current();
|
||||
unsafe {
|
||||
window.gl.ClearColor(0.7, 0.9, 0.1, 1.0);
|
||||
window.gl.Clear(gl::COLOR_BUFFER_BIT);
|
||||
}
|
||||
window.source.swap_buffers();
|
||||
}
|
||||
|
||||
fn handle_window_event(window: &mut glfw::Window, event: glfw::WindowEvent) {
|
||||
match event {
|
||||
glfw::WindowEvent::Key(Key::Escape, _, Action::Press, _) => {
|
||||
window.set_should_close(true)
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
8
third-party/glad/example/rust/gl-glfw/Cargo.toml
vendored
Normal file
8
third-party/glad/example/rust/gl-glfw/Cargo.toml
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "gl-glfw"
|
||||
version = "0.1.0"
|
||||
|
||||
[dependencies]
|
||||
glfw = "0.37.0"
|
||||
glad-gl = { path = "./build/glad-gl" }
|
||||
|
||||
33
third-party/glad/example/rust/gl-glfw/README.md
vendored
Normal file
33
third-party/glad/example/rust/gl-glfw/README.md
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
Example: gl-glfw
|
||||
================
|
||||
|
||||
|
||||
This is basic example showcasing `glad-gl` in combination with
|
||||
[`glfw`](https://crates.io/crates/glfw).
|
||||
|
||||
To run the example use the following command:
|
||||
|
||||
```sh
|
||||
./init.sh && cargo run
|
||||
```
|
||||
|
||||
The `init.sh` script is just a small utility used to generate
|
||||
the `glad-gl` crate into the `build/` directory. The `Cargo.toml`
|
||||
references the dependency using:
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
glad-gl = { path = "./build/glad-gl" }
|
||||
```
|
||||
|
||||
This example is the basic example of the
|
||||
[glfw crate](https://crates.io/crates/glfw) with some
|
||||
OpenGL instructions added and just one additional line
|
||||
to initialize `glad`:
|
||||
|
||||
```rust
|
||||
gl::load(|e| glfw.get_proc_address_raw(e) as *const std::os::raw::c_void);
|
||||
```
|
||||
|
||||
That's all that is needed to initialize and use OpenGL using `glad`!
|
||||
|
||||
9
third-party/glad/example/rust/gl-glfw/init.sh
vendored
Executable file
9
third-party/glad/example/rust/gl-glfw/init.sh
vendored
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
BASE_PATH="$(dirname $(realpath $0))"
|
||||
|
||||
|
||||
cd "${BASE_PATH}/../../../"
|
||||
|
||||
python -m glad --out-path "${BASE_PATH}/build" --extensions="" --api="gl:core=3.3" rust
|
||||
|
||||
40
third-party/glad/example/rust/gl-glfw/src/main.rs
vendored
Normal file
40
third-party/glad/example/rust/gl-glfw/src/main.rs
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
extern crate glfw;
|
||||
extern crate glad_gl;
|
||||
use glfw::{Action, Context, Key};
|
||||
use glad_gl::gl;
|
||||
|
||||
|
||||
fn main() {
|
||||
let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();
|
||||
|
||||
let (mut window, events) = glfw.create_window(300, 300, "[glad] Rust - OpenGL with GLFW", glfw::WindowMode::Windowed)
|
||||
.expect("Failed to create GLFW window.");
|
||||
|
||||
window.set_key_polling(true);
|
||||
window.make_current();
|
||||
|
||||
gl::load(|e| glfw.get_proc_address_raw(e) as *const std::os::raw::c_void);
|
||||
|
||||
while !window.should_close() {
|
||||
glfw.poll_events();
|
||||
for (_, event) in glfw::flush_messages(&events) {
|
||||
handle_window_event(&mut window, event);
|
||||
}
|
||||
|
||||
unsafe {
|
||||
gl::ClearColor(0.7, 0.9, 0.1, 1.0);
|
||||
gl::Clear(gl::COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
window.swap_buffers();
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_window_event(window: &mut glfw::Window, event: glfw::WindowEvent) {
|
||||
match event {
|
||||
glfw::WindowEvent::Key(Key::Escape, _, Action::Press, _) => {
|
||||
window.set_should_close(true)
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
3
third-party/glad/glad/__init__.py
vendored
Normal file
3
third-party/glad/glad/__init__.py
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
__version__ = '2.0.8'
|
||||
|
||||
197
third-party/glad/glad/__main__.py
vendored
Normal file
197
third-party/glad/glad/__main__.py
vendored
Normal file
@@ -0,0 +1,197 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
Uses the official Khronos-XML specs to generate a
|
||||
Vulkan/GL/GLES/EGL/GLX/WGL Loader made for your needs.
|
||||
|
||||
|
||||
Subcommands have additional help information, query with: `{subcommand} --help`
|
||||
"""
|
||||
from itertools import groupby
|
||||
|
||||
import logging
|
||||
import os
|
||||
|
||||
import glad.files
|
||||
from glad import __version__
|
||||
from glad.config import Config, ConfigOption
|
||||
from glad.generator import GenerationInfo
|
||||
from glad.sink import LoggingSink
|
||||
from glad.opener import URLOpener
|
||||
from glad.parse import FeatureSet
|
||||
from glad.plugin import find_specifications, find_generators
|
||||
from glad.util import parse_apis
|
||||
|
||||
|
||||
logger = logging.getLogger('glad')
|
||||
|
||||
|
||||
def parse_extensions(value):
|
||||
if os.path.isfile(value):
|
||||
# it's an extensions file
|
||||
with open(value) as f:
|
||||
value = f.read()
|
||||
|
||||
value = value.replace(',', ' ')
|
||||
return list(filter(None, value.split()))
|
||||
|
||||
|
||||
class GlobalConfig(Config):
|
||||
OUT_PATH = ConfigOption(
|
||||
required=True,
|
||||
description='Output directory for the generated files'
|
||||
)
|
||||
API = ConfigOption(
|
||||
required=True,
|
||||
converter=parse_apis,
|
||||
description='Comma separated list of APIs in `name:profile=version` pairs '
|
||||
'optionally including a specification `name:profile/spec=version`. '
|
||||
'No version means latest, a profile is only required if the API requires a profile. '
|
||||
'E.g. `gl:core=3.3,gles1/gl=2,gles2'
|
||||
)
|
||||
EXTENSIONS = ConfigOption(
|
||||
converter=parse_extensions,
|
||||
default=None,
|
||||
description='Path to a file containing a list of extensions or '
|
||||
'a comma separated list of extensions, if missing '
|
||||
'all possible extensions are included.'
|
||||
)
|
||||
MERGE = ConfigOption(
|
||||
converter=bool,
|
||||
default=False,
|
||||
description='Merge multiple APIs of the same specification into one file.'
|
||||
)
|
||||
QUIET = ConfigOption(
|
||||
converter=bool,
|
||||
description='Disable logging.'
|
||||
)
|
||||
REPRODUCIBLE = ConfigOption(
|
||||
converter=bool,
|
||||
default=False,
|
||||
description='Makes the build reproducible by not fetching the latest '
|
||||
'specification from Khronos.'
|
||||
)
|
||||
|
||||
|
||||
def load_specifications(specification_names, opener, specification_classes=None):
|
||||
specifications = dict()
|
||||
|
||||
if specification_classes is None:
|
||||
specification_classes = find_specifications()
|
||||
|
||||
for name in set(specification_names):
|
||||
Specification = specification_classes[name]
|
||||
xml_name = name + '.xml'
|
||||
|
||||
if os.path.isfile(xml_name):
|
||||
logger.info('using local specification: %s', xml_name)
|
||||
specification = Specification.from_file(xml_name, opener=opener)
|
||||
else:
|
||||
logger.info('getting %r specification from remote location', name)
|
||||
specification = Specification.from_remote(opener=opener)
|
||||
|
||||
specifications[name] = specification
|
||||
|
||||
return specifications
|
||||
|
||||
|
||||
def apis_by_specification(api_info, specifications):
|
||||
return groupby(api_info.items(),
|
||||
key=lambda api_info: specifications[api_info[1].specification])
|
||||
|
||||
|
||||
def main(args=None):
|
||||
from argparse import ArgumentParser
|
||||
import sys
|
||||
|
||||
# Initialize logging as early as possible
|
||||
if not '--quiet' in (args or sys.argv):
|
||||
logging.basicConfig(
|
||||
format='[%(asctime)s][%(levelname)s\t][%(name)-7s\t]: %(message)s',
|
||||
datefmt='%d.%m.%Y %H:%M:%S', level=logging.DEBUG
|
||||
)
|
||||
|
||||
logging_sink = LoggingSink(logger=logger)
|
||||
|
||||
description = __doc__
|
||||
parser = ArgumentParser(description=description)
|
||||
|
||||
parser.add_argument('--version', action='version', version=__version__)
|
||||
|
||||
global_config = GlobalConfig()
|
||||
global_config.init_parser(parser)
|
||||
|
||||
subparsers = parser.add_subparsers(
|
||||
dest='subparser_name',
|
||||
description='Generator to use'
|
||||
)
|
||||
subparsers.default = 'c'
|
||||
|
||||
configs = dict()
|
||||
generators = find_generators()
|
||||
for lang, Generator in generators.items():
|
||||
config = Generator.Config()
|
||||
subparser = subparsers.add_parser(lang)
|
||||
config.init_parser(subparser)
|
||||
|
||||
configs[lang] = config
|
||||
|
||||
ns = parser.parse_args(args=args)
|
||||
|
||||
global_config.update_from_object(ns, convert=False, ignore_additional=True)
|
||||
config = configs[ns.subparser_name]
|
||||
config.update_from_object(ns, convert=False, ignore_additional=True)
|
||||
|
||||
# This should never throw if Config.init_parser is working correctly
|
||||
global_config.validate() # Done before, but doesn't hurt
|
||||
config.validate()
|
||||
|
||||
if global_config['REPRODUCIBLE']:
|
||||
opener = glad.files.StaticFileOpener()
|
||||
gen_info_factory = lambda *a, **kw: GenerationInfo.create(when='-', *a, **kw)
|
||||
else:
|
||||
opener = URLOpener()
|
||||
gen_info_factory = GenerationInfo.create
|
||||
|
||||
specifications = load_specifications(
|
||||
[value[0] for value in global_config['API'].values()], opener=opener
|
||||
)
|
||||
|
||||
generator = generators[ns.subparser_name](
|
||||
global_config['OUT_PATH'], opener=opener, gen_info_factory=gen_info_factory
|
||||
)
|
||||
|
||||
invalid_extensions = set(global_config['EXTENSIONS'] or [])
|
||||
for specification, apis in apis_by_specification(global_config['API'], specifications):
|
||||
for api in apis:
|
||||
invalid_extensions = invalid_extensions.difference(specification.extensions[api[0]])
|
||||
|
||||
if not len(invalid_extensions) == 0:
|
||||
message = 'invalid extensions or extensions not present in one of the selected APIs: {}\n' \
|
||||
.format(', '.join(invalid_extensions))
|
||||
parser.exit(11, message)
|
||||
|
||||
def select(specification, api, info):
|
||||
logging_sink.info('generating {}:{}/{}={}'.format(api, info.profile, info.specification, info.version))
|
||||
|
||||
extensions = global_config['EXTENSIONS']
|
||||
if extensions:
|
||||
extensions = [ext for ext in extensions if specification.is_extension(api, ext)]
|
||||
|
||||
return generator.select(specification, api, info.version, info.profile, extensions, config, sink=logging_sink)
|
||||
|
||||
for specification, apis in apis_by_specification(global_config['API'], specifications):
|
||||
feature_sets = list(select(specification, api, info) for api, info in apis)
|
||||
|
||||
if global_config['MERGE']:
|
||||
logging_sink.info('merging {}'.format(feature_sets))
|
||||
feature_sets = [FeatureSet.merge(feature_sets, sink=logging_sink)]
|
||||
logging_sink.info('merged into {}'.format(feature_sets[0]))
|
||||
|
||||
for feature_set in feature_sets:
|
||||
logging_sink.info('generating feature set {}'.format(feature_set))
|
||||
generator.generate(specification, feature_set, config, sink=logging_sink)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
307
third-party/glad/glad/config.py
vendored
Normal file
307
third-party/glad/glad/config.py
vendored
Normal file
@@ -0,0 +1,307 @@
|
||||
class ConfigException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class InvalidConfig(ConfigException):
|
||||
pass
|
||||
|
||||
|
||||
class OptionRequired(InvalidConfig):
|
||||
def __init__(self, name, option):
|
||||
ConfigException.__init__(self, 'Required option {!r} not set'.format(name))
|
||||
|
||||
self.name = name
|
||||
self.option = option
|
||||
|
||||
|
||||
class ConstraintException(InvalidConfig):
|
||||
def __init__(self, message, constraint):
|
||||
InvalidConfig.__init__(self, message)
|
||||
|
||||
self.constraint = constraint
|
||||
|
||||
|
||||
class RequirementNotSatisfied(ConstraintException):
|
||||
pass
|
||||
|
||||
|
||||
class UnsupportedConfiguration(ConstraintException):
|
||||
pass
|
||||
|
||||
|
||||
class InvalidOption(ConfigException):
|
||||
def __init__(self, name):
|
||||
ConfigException.__init__(self, 'Invalid option {!r}'.format(name))
|
||||
|
||||
self.name = name
|
||||
|
||||
|
||||
def identity(x):
|
||||
return x
|
||||
|
||||
|
||||
def one_of(choices):
|
||||
def validator(x):
|
||||
if x not in choices:
|
||||
raise ValueError('invalid choice {!r}, expected one of {!r}', x, choices)
|
||||
|
||||
validator.__config__doc__ = 'One of: {!r}'.format(choices)
|
||||
return validator
|
||||
|
||||
|
||||
class ConfigOption(object):
|
||||
def __init__(self, description, converter=None, default=None, required=False, help=None):
|
||||
self.converter = converter
|
||||
if self.converter is None:
|
||||
self.converter = identity
|
||||
|
||||
self.description = description
|
||||
self.default = default
|
||||
self.required = required
|
||||
self.help = help
|
||||
|
||||
try:
|
||||
self.description = '{}. {}'.format(
|
||||
self.description.rstrip('. '),
|
||||
self.converter.__config_doc__
|
||||
)
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
if self.default and self.required:
|
||||
raise ValueError(
|
||||
'ConfigOption cannot have a default and be required at the same time.'
|
||||
)
|
||||
|
||||
def to_parser_arguments(self):
|
||||
args = dict(
|
||||
type=self.converter,
|
||||
help=self.description,
|
||||
)
|
||||
|
||||
if self.required:
|
||||
args['required'] = True
|
||||
else:
|
||||
if self.converter is bool:
|
||||
args['action'] = 'store_false' if self.default else 'store_true'
|
||||
args.pop('type')
|
||||
else:
|
||||
args['default'] = self.default
|
||||
|
||||
return args
|
||||
|
||||
|
||||
class Constraint(object):
|
||||
def validate(self, config):
|
||||
pass
|
||||
|
||||
|
||||
class RequirementConstraint(Constraint):
|
||||
"""
|
||||
Specifies a simple requirement constraint.
|
||||
If a list of options are given (True), the requirement needs to be True as well.
|
||||
This only checks for the variables boolean values.
|
||||
"""
|
||||
def __init__(self, options, require, error_formatter=None):
|
||||
self.options = options
|
||||
self.require = require
|
||||
|
||||
if len(self.options) == 0:
|
||||
raise ValueError('At least one option required')
|
||||
|
||||
self.error_formatter = error_formatter
|
||||
if self.error_formatter is None:
|
||||
self.error_formatter = self._format_error
|
||||
|
||||
def validate(self, config):
|
||||
if all(config[option] for option in self.options) and not config[self.require]:
|
||||
raise RequirementNotSatisfied(self.error_formatter(self, config), self)
|
||||
|
||||
@staticmethod
|
||||
def _format_error(constraint, config):
|
||||
plural = len(constraint.options) > 1
|
||||
options = ', '.join(constraint.options[:-1])
|
||||
if options:
|
||||
options = '{} and {}'.format(options, constraint.options[-1])
|
||||
else:
|
||||
options = constraint.options[0]
|
||||
|
||||
return 'option{s} {options} require{not_s} option {require}'.format(
|
||||
options=options,
|
||||
require=constraint.require,
|
||||
s='s' if plural else '',
|
||||
not_s='' if plural else 's'
|
||||
)
|
||||
|
||||
|
||||
class UnsupportedConstraint(Constraint):
|
||||
"""
|
||||
Specifies a unsupported constraint, that can either be a single option
|
||||
or a combination of options. Checks only for the boolean value of the options.
|
||||
"""
|
||||
def __init__(self, given, not_allowed, error_formatter=None):
|
||||
self.given = given
|
||||
self.not_allowed = not_allowed
|
||||
|
||||
if len(self.given) == 0:
|
||||
raise ValueError('At least one \'given\' option required')
|
||||
|
||||
self.error_formatter = error_formatter
|
||||
if self.error_formatter is None:
|
||||
self.error_formatter = self._format_error
|
||||
|
||||
def validate(self, config):
|
||||
if all(config[option] for option in self.given) and config[self.not_allowed]:
|
||||
raise UnsupportedConfiguration(self.error_formatter(self, config), self)
|
||||
|
||||
@staticmethod
|
||||
def _format_error(constraint, config):
|
||||
plural = len(constraint.given) > 1
|
||||
given = ', '.join(constraint.given[:-1])
|
||||
if given:
|
||||
given = '{} and {}'.format(given, constraint.given[-1])
|
||||
else:
|
||||
given = constraint.given[-1]
|
||||
|
||||
return 'option{s} {given} can not be used together with {not_allowed}'.format(
|
||||
given=given,
|
||||
not_allowed=constraint.not_allowed,
|
||||
s='s' if plural else ''
|
||||
)
|
||||
|
||||
|
||||
class Config(object):
|
||||
"""
|
||||
Base for all glad configurations. The class with initiliaze the options
|
||||
with it iself. Every uppercase name will be assumed to be a configuration option
|
||||
and should be of type ConfigOption:
|
||||
|
||||
class MyAwesomeConfig(Config):
|
||||
DEBUG = ConfigOption(
|
||||
converter=bool,
|
||||
default=False
|
||||
description='Enables debug output'
|
||||
)
|
||||
ITERATIONS = ConfigOption(
|
||||
converter=int,
|
||||
required=True
|
||||
description='Number of iterations'
|
||||
)
|
||||
|
||||
config = MyAwesomeConfig()
|
||||
config['DEBUG'] = True
|
||||
|
||||
# update config from file
|
||||
# ...
|
||||
# now make sure every required option has been set
|
||||
config.validate()
|
||||
|
||||
if config['DEBUG']:
|
||||
print 'debug information'
|
||||
|
||||
Special Constraints can be specified in the __constraints__ variable.
|
||||
|
||||
class MyConstraintConfig(MyAwesomeConfig):
|
||||
__constraints__ = [
|
||||
RequirementConstraint(['DEBUG'], 'iterations')
|
||||
]
|
||||
|
||||
The constraints will be checked when calling `.valid` or `.validate()`
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self._options = dict()
|
||||
self._values = dict()
|
||||
|
||||
# initialize options, every uppercase name without leading underscore = option
|
||||
for name in dir(self):
|
||||
if name.isupper() and not name.startswith('_'):
|
||||
option = self._options[name] = getattr(self, name)
|
||||
|
||||
if not option.required:
|
||||
self._values[name] = option.default
|
||||
|
||||
def set(self, name, value, convert=True):
|
||||
try:
|
||||
option = self._options[name]
|
||||
except KeyError:
|
||||
raise InvalidOption(name)
|
||||
|
||||
if convert:
|
||||
value = option.converter(value)
|
||||
self._values[name] = value
|
||||
|
||||
def get(self, item, default=None):
|
||||
try:
|
||||
return self[item]
|
||||
except KeyError:
|
||||
return default
|
||||
|
||||
def __getitem__(self, item):
|
||||
return self._values[item]
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
self.set(key, value, convert=True)
|
||||
|
||||
def items(self):
|
||||
return list(self._options.items())
|
||||
|
||||
@property
|
||||
def valid(self):
|
||||
"""
|
||||
Checks if every required option has been set.
|
||||
|
||||
:return: True if everything has been set otherwise False
|
||||
"""
|
||||
try:
|
||||
self.validate()
|
||||
except InvalidConfig:
|
||||
return False
|
||||
return True
|
||||
|
||||
def validate(self):
|
||||
"""
|
||||
Checks if every required option has been set.
|
||||
Throws InvalidConfig if a required option is missing.
|
||||
This also checks all specified constraints.
|
||||
|
||||
Should be overwritten by subclasses if necessary.
|
||||
"""
|
||||
for name, option in self._options.items():
|
||||
if option.required:
|
||||
if not name in self._values:
|
||||
raise OptionRequired(name, option)
|
||||
|
||||
constraints = getattr(self, '__constraints__', [])
|
||||
for constraint in constraints:
|
||||
constraint.validate(self)
|
||||
|
||||
def update_from_object(self, obj, convert=True, ignore_additional=False):
|
||||
for name in dir(obj):
|
||||
if not name.startswith('_'):
|
||||
try:
|
||||
self.set(name, getattr(obj, name), convert=convert)
|
||||
except InvalidOption:
|
||||
if not ignore_additional:
|
||||
raise
|
||||
|
||||
def init_parser(self, parser):
|
||||
for name, option in self._options.items():
|
||||
parser_name = '--' + name.lower().replace('_', '-')
|
||||
|
||||
parser.add_argument(
|
||||
parser_name,
|
||||
dest=name,
|
||||
**option.to_parser_arguments()
|
||||
)
|
||||
|
||||
def to_dict(self, transform=None):
|
||||
if transform is None:
|
||||
transform = identity
|
||||
|
||||
result = dict()
|
||||
|
||||
for name, value in self._values.items():
|
||||
result[transform(name)] = value
|
||||
|
||||
return result
|
||||
63
third-party/glad/glad/files/__init__.py
vendored
Normal file
63
third-party/glad/glad/files/__init__.py
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
import os.path
|
||||
import logging
|
||||
import shutil
|
||||
|
||||
try:
|
||||
from urlparse import urlparse
|
||||
except ImportError:
|
||||
from urllib.parse import urlparse
|
||||
|
||||
try:
|
||||
from importlib.resources import files
|
||||
|
||||
def resource_open(package, name, *args, **kwargs):
|
||||
return files(package).joinpath(name).open(*args, **kwargs)
|
||||
except ImportError:
|
||||
try:
|
||||
from pkg_resources import resource_stream
|
||||
|
||||
def resource_open(package, name, *args, **kwargs):
|
||||
return resource_stream(package, name)
|
||||
except ImportError:
|
||||
def resource_open(package, name, *args, **kwargs):
|
||||
raise FileNotFoundError
|
||||
|
||||
|
||||
BASE_PATH = os.path.abspath(os.path.dirname(__file__))
|
||||
|
||||
logger = logging.getLogger('glad.files')
|
||||
|
||||
|
||||
class GladFileException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
def open_local(name, *args, **kwargs):
|
||||
# use pkg_resources when available, makes it work in zipped modules
|
||||
# or other environments
|
||||
try:
|
||||
return resource_open(__name__, name, *args, **kwargs)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
# fallback to filesystem
|
||||
logger.info('falling back to packaged path: %r', name)
|
||||
local_path = os.path.normpath(os.path.join(BASE_PATH, os.path.join(name)))
|
||||
if not local_path.startswith(BASE_PATH):
|
||||
raise GladFileException('unsafe file path, won\'t open {!r}'.format(local_path))
|
||||
return open(local_path, *args, **kwargs)
|
||||
|
||||
|
||||
class StaticFileOpener(object):
|
||||
def urlopen(self, url, data=None, *args, **kwargs):
|
||||
logger.debug('intercepted attempt to retrieve resource: %r', url)
|
||||
if data is not None:
|
||||
raise GladFileException('can not resolve requests with payload')
|
||||
|
||||
filename = urlparse(url).path.rsplit('/', 1)[-1]
|
||||
return open_local(filename, 'rb')
|
||||
|
||||
def urlretrieve(self, url, filename, *args, **kwargs):
|
||||
with self.urlopen(url) as src:
|
||||
with open(filename, 'wb') as dst:
|
||||
shutil.copyfileobj(src, dst)
|
||||
3595
third-party/glad/glad/files/egl.xml
vendored
Normal file
3595
third-party/glad/glad/files/egl.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
175
third-party/glad/glad/files/eglplatform.h
vendored
Normal file
175
third-party/glad/glad/files/eglplatform.h
vendored
Normal file
@@ -0,0 +1,175 @@
|
||||
#ifndef __eglplatform_h_
|
||||
#define __eglplatform_h_
|
||||
|
||||
/*
|
||||
** Copyright 2007-2020 The Khronos Group Inc.
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/* Platform-specific types and definitions for egl.h
|
||||
*
|
||||
* Adopters may modify khrplatform.h and this file to suit their platform.
|
||||
* You are encouraged to submit all modifications to the Khronos group so that
|
||||
* they can be included in future versions of this file. Please submit changes
|
||||
* by filing an issue or pull request on the public Khronos EGL Registry, at
|
||||
* https://www.github.com/KhronosGroup/EGL-Registry/
|
||||
*/
|
||||
|
||||
#include <KHR/khrplatform.h>
|
||||
|
||||
/* Macros used in EGL function prototype declarations.
|
||||
*
|
||||
* EGL functions should be prototyped as:
|
||||
*
|
||||
* EGLAPI return-type EGLAPIENTRY eglFunction(arguments);
|
||||
* typedef return-type (EXPAPIENTRYP PFNEGLFUNCTIONPROC) (arguments);
|
||||
*
|
||||
* KHRONOS_APICALL and KHRONOS_APIENTRY are defined in KHR/khrplatform.h
|
||||
*/
|
||||
|
||||
#ifndef EGLAPI
|
||||
#define EGLAPI KHRONOS_APICALL
|
||||
#endif
|
||||
|
||||
#ifndef EGLAPIENTRY
|
||||
#define EGLAPIENTRY KHRONOS_APIENTRY
|
||||
#endif
|
||||
#define EGLAPIENTRYP EGLAPIENTRY*
|
||||
|
||||
/* The types NativeDisplayType, NativeWindowType, and NativePixmapType
|
||||
* are aliases of window-system-dependent types, such as X Display * or
|
||||
* Windows Device Context. They must be defined in platform-specific
|
||||
* code below. The EGL-prefixed versions of Native*Type are the same
|
||||
* types, renamed in EGL 1.3 so all types in the API start with "EGL".
|
||||
*
|
||||
* Khronos STRONGLY RECOMMENDS that you use the default definitions
|
||||
* provided below, since these changes affect both binary and source
|
||||
* portability of applications using EGL running on different EGL
|
||||
* implementations.
|
||||
*/
|
||||
|
||||
#if defined(EGL_NO_PLATFORM_SPECIFIC_TYPES)
|
||||
|
||||
typedef void *EGLNativeDisplayType;
|
||||
typedef void *EGLNativePixmapType;
|
||||
typedef void *EGLNativeWindowType;
|
||||
|
||||
#elif defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) /* Win32 and WinCE */
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
#endif
|
||||
#include <windows.h>
|
||||
|
||||
typedef HDC EGLNativeDisplayType;
|
||||
typedef HBITMAP EGLNativePixmapType;
|
||||
typedef HWND EGLNativeWindowType;
|
||||
|
||||
#elif defined(__QNX__)
|
||||
|
||||
typedef khronos_uintptr_t EGLNativeDisplayType;
|
||||
typedef struct _screen_pixmap* EGLNativePixmapType; /* screen_pixmap_t */
|
||||
typedef struct _screen_window* EGLNativeWindowType; /* screen_window_t */
|
||||
|
||||
#elif defined(__EMSCRIPTEN__)
|
||||
|
||||
typedef int EGLNativeDisplayType;
|
||||
typedef int EGLNativePixmapType;
|
||||
typedef int EGLNativeWindowType;
|
||||
|
||||
#elif defined(__WINSCW__) || defined(__SYMBIAN32__) /* Symbian */
|
||||
|
||||
typedef int EGLNativeDisplayType;
|
||||
typedef void *EGLNativePixmapType;
|
||||
typedef void *EGLNativeWindowType;
|
||||
|
||||
#elif defined(WL_EGL_PLATFORM)
|
||||
|
||||
typedef struct wl_display *EGLNativeDisplayType;
|
||||
typedef struct wl_egl_pixmap *EGLNativePixmapType;
|
||||
typedef struct wl_egl_window *EGLNativeWindowType;
|
||||
|
||||
#elif defined(__GBM__)
|
||||
|
||||
typedef struct gbm_device *EGLNativeDisplayType;
|
||||
typedef struct gbm_bo *EGLNativePixmapType;
|
||||
typedef void *EGLNativeWindowType;
|
||||
|
||||
#elif defined(__ANDROID__) || defined(ANDROID)
|
||||
|
||||
struct ANativeWindow;
|
||||
struct egl_native_pixmap_t;
|
||||
|
||||
typedef void* EGLNativeDisplayType;
|
||||
typedef struct egl_native_pixmap_t* EGLNativePixmapType;
|
||||
typedef struct ANativeWindow* EGLNativeWindowType;
|
||||
|
||||
#elif defined(USE_OZONE)
|
||||
|
||||
typedef intptr_t EGLNativeDisplayType;
|
||||
typedef intptr_t EGLNativePixmapType;
|
||||
typedef intptr_t EGLNativeWindowType;
|
||||
|
||||
#elif defined(USE_X11)
|
||||
|
||||
/* X11 (tentative) */
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
typedef Display *EGLNativeDisplayType;
|
||||
typedef Pixmap EGLNativePixmapType;
|
||||
typedef Window EGLNativeWindowType;
|
||||
|
||||
#elif defined(__unix__)
|
||||
|
||||
typedef void *EGLNativeDisplayType;
|
||||
typedef khronos_uintptr_t EGLNativePixmapType;
|
||||
typedef khronos_uintptr_t EGLNativeWindowType;
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
|
||||
typedef int EGLNativeDisplayType;
|
||||
typedef void *EGLNativePixmapType;
|
||||
typedef void *EGLNativeWindowType;
|
||||
|
||||
#elif defined(__HAIKU__)
|
||||
|
||||
#include <kernel/image.h>
|
||||
|
||||
typedef void *EGLNativeDisplayType;
|
||||
typedef khronos_uintptr_t EGLNativePixmapType;
|
||||
typedef khronos_uintptr_t EGLNativeWindowType;
|
||||
|
||||
#elif defined(__Fuchsia__)
|
||||
|
||||
typedef void *EGLNativeDisplayType;
|
||||
typedef khronos_uintptr_t EGLNativePixmapType;
|
||||
typedef khronos_uintptr_t EGLNativeWindowType;
|
||||
|
||||
#else
|
||||
#error "Platform not recognized"
|
||||
#endif
|
||||
|
||||
/* EGL 1.2 types, renamed for consistency in EGL 1.3 */
|
||||
typedef EGLNativeDisplayType NativeDisplayType;
|
||||
typedef EGLNativePixmapType NativePixmapType;
|
||||
typedef EGLNativeWindowType NativeWindowType;
|
||||
|
||||
|
||||
/* Define EGLint. This must be a signed integral type large enough to contain
|
||||
* all legal attribute names and values passed into and out of EGL, whether
|
||||
* their type is boolean, bitmask, enumerant (symbolic constant), integer,
|
||||
* handle, or other. While in general a 32-bit integer will suffice, if
|
||||
* handles are 64 bit types, then EGLint should be defined as a signed 64-bit
|
||||
* integer type.
|
||||
*/
|
||||
typedef khronos_int32_t EGLint;
|
||||
|
||||
|
||||
/* C++ / C typecast macros for special EGL handle values */
|
||||
#if defined(__cplusplus)
|
||||
#define EGL_CAST(type, value) (static_cast<type>(value))
|
||||
#else
|
||||
#define EGL_CAST(type, value) ((type) (value))
|
||||
#endif
|
||||
|
||||
#endif /* __eglplatform_h */
|
||||
47519
third-party/glad/glad/files/gl.xml
vendored
Normal file
47519
third-party/glad/glad/files/gl.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2208
third-party/glad/glad/files/glx.xml
vendored
Normal file
2208
third-party/glad/glad/files/glx.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
311
third-party/glad/glad/files/khrplatform.h
vendored
Normal file
311
third-party/glad/glad/files/khrplatform.h
vendored
Normal file
@@ -0,0 +1,311 @@
|
||||
#ifndef __khrplatform_h_
|
||||
#define __khrplatform_h_
|
||||
|
||||
/*
|
||||
** Copyright (c) 2008-2018 The Khronos Group Inc.
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining a
|
||||
** copy of this software and/or associated documentation files (the
|
||||
** "Materials"), to deal in the Materials without restriction, including
|
||||
** without limitation the rights to use, copy, modify, merge, publish,
|
||||
** distribute, sublicense, and/or sell copies of the Materials, and to
|
||||
** permit persons to whom the Materials are furnished to do so, subject to
|
||||
** the following conditions:
|
||||
**
|
||||
** The above copyright notice and this permission notice shall be included
|
||||
** in all copies or substantial portions of the Materials.
|
||||
**
|
||||
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
||||
*/
|
||||
|
||||
/* Khronos platform-specific types and definitions.
|
||||
*
|
||||
* The master copy of khrplatform.h is maintained in the Khronos EGL
|
||||
* Registry repository at https://github.com/KhronosGroup/EGL-Registry
|
||||
* The last semantic modification to khrplatform.h was at commit ID:
|
||||
* 67a3e0864c2d75ea5287b9f3d2eb74a745936692
|
||||
*
|
||||
* Adopters may modify this file to suit their platform. Adopters are
|
||||
* encouraged to submit platform specific modifications to the Khronos
|
||||
* group so that they can be included in future versions of this file.
|
||||
* Please submit changes by filing pull requests or issues on
|
||||
* the EGL Registry repository linked above.
|
||||
*
|
||||
*
|
||||
* See the Implementer's Guidelines for information about where this file
|
||||
* should be located on your system and for more details of its use:
|
||||
* http://www.khronos.org/registry/implementers_guide.pdf
|
||||
*
|
||||
* This file should be included as
|
||||
* #include <KHR/khrplatform.h>
|
||||
* by Khronos client API header files that use its types and defines.
|
||||
*
|
||||
* The types in khrplatform.h should only be used to define API-specific types.
|
||||
*
|
||||
* Types defined in khrplatform.h:
|
||||
* khronos_int8_t signed 8 bit
|
||||
* khronos_uint8_t unsigned 8 bit
|
||||
* khronos_int16_t signed 16 bit
|
||||
* khronos_uint16_t unsigned 16 bit
|
||||
* khronos_int32_t signed 32 bit
|
||||
* khronos_uint32_t unsigned 32 bit
|
||||
* khronos_int64_t signed 64 bit
|
||||
* khronos_uint64_t unsigned 64 bit
|
||||
* khronos_intptr_t signed same number of bits as a pointer
|
||||
* khronos_uintptr_t unsigned same number of bits as a pointer
|
||||
* khronos_ssize_t signed size
|
||||
* khronos_usize_t unsigned size
|
||||
* khronos_float_t signed 32 bit floating point
|
||||
* khronos_time_ns_t unsigned 64 bit time in nanoseconds
|
||||
* khronos_utime_nanoseconds_t unsigned time interval or absolute time in
|
||||
* nanoseconds
|
||||
* khronos_stime_nanoseconds_t signed time interval in nanoseconds
|
||||
* khronos_boolean_enum_t enumerated boolean type. This should
|
||||
* only be used as a base type when a client API's boolean type is
|
||||
* an enum. Client APIs which use an integer or other type for
|
||||
* booleans cannot use this as the base type for their boolean.
|
||||
*
|
||||
* Tokens defined in khrplatform.h:
|
||||
*
|
||||
* KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
|
||||
*
|
||||
* KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
|
||||
* KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
|
||||
*
|
||||
* Calling convention macros defined in this file:
|
||||
* KHRONOS_APICALL
|
||||
* KHRONOS_APIENTRY
|
||||
* KHRONOS_APIATTRIBUTES
|
||||
*
|
||||
* These may be used in function prototypes as:
|
||||
*
|
||||
* KHRONOS_APICALL void KHRONOS_APIENTRY funcname(
|
||||
* int arg1,
|
||||
* int arg2) KHRONOS_APIATTRIBUTES;
|
||||
*/
|
||||
|
||||
#if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC)
|
||||
# define KHRONOS_STATIC 1
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Definition of KHRONOS_APICALL
|
||||
*-------------------------------------------------------------------------
|
||||
* This precedes the return type of the function in the function prototype.
|
||||
*/
|
||||
#if defined(KHRONOS_STATIC)
|
||||
/* If the preprocessor constant KHRONOS_STATIC is defined, make the
|
||||
* header compatible with static linking. */
|
||||
# define KHRONOS_APICALL
|
||||
#elif defined(_WIN32)
|
||||
# define KHRONOS_APICALL __declspec(dllimport)
|
||||
#elif defined (__SYMBIAN32__)
|
||||
# define KHRONOS_APICALL IMPORT_C
|
||||
#elif defined(__ANDROID__)
|
||||
# define KHRONOS_APICALL __attribute__((visibility("default")))
|
||||
#else
|
||||
# define KHRONOS_APICALL
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Definition of KHRONOS_APIENTRY
|
||||
*-------------------------------------------------------------------------
|
||||
* This follows the return type of the function and precedes the function
|
||||
* name in the function prototype.
|
||||
*/
|
||||
#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
|
||||
/* Win32 but not WinCE */
|
||||
# define KHRONOS_APIENTRY __stdcall
|
||||
#else
|
||||
# define KHRONOS_APIENTRY
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Definition of KHRONOS_APIATTRIBUTES
|
||||
*-------------------------------------------------------------------------
|
||||
* This follows the closing parenthesis of the function prototype arguments.
|
||||
*/
|
||||
#if defined (__ARMCC_2__)
|
||||
#define KHRONOS_APIATTRIBUTES __softfp
|
||||
#else
|
||||
#define KHRONOS_APIATTRIBUTES
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* basic type definitions
|
||||
*-----------------------------------------------------------------------*/
|
||||
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
|
||||
|
||||
|
||||
/*
|
||||
* Using <stdint.h>
|
||||
*/
|
||||
#include <stdint.h>
|
||||
typedef int32_t khronos_int32_t;
|
||||
typedef uint32_t khronos_uint32_t;
|
||||
typedef int64_t khronos_int64_t;
|
||||
typedef uint64_t khronos_uint64_t;
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
/*
|
||||
* To support platform where unsigned long cannot be used interchangeably with
|
||||
* inptr_t (e.g. CHERI-extended ISAs), we can use the stdint.h intptr_t.
|
||||
* Ideally, we could just use (u)intptr_t everywhere, but this could result in
|
||||
* ABI breakage if khronos_uintptr_t is changed from unsigned long to
|
||||
* unsigned long long or similar (this results in different C++ name mangling).
|
||||
* To avoid changes for existing platforms, we restrict usage of intptr_t to
|
||||
* platforms where the size of a pointer is larger than the size of long.
|
||||
*/
|
||||
#if defined(__SIZEOF_LONG__) && defined(__SIZEOF_POINTER__)
|
||||
#if __SIZEOF_POINTER__ > __SIZEOF_LONG__
|
||||
#define KHRONOS_USE_INTPTR_T
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#elif defined(__VMS ) || defined(__sgi)
|
||||
|
||||
/*
|
||||
* Using <inttypes.h>
|
||||
*/
|
||||
#include <inttypes.h>
|
||||
typedef int32_t khronos_int32_t;
|
||||
typedef uint32_t khronos_uint32_t;
|
||||
typedef int64_t khronos_int64_t;
|
||||
typedef uint64_t khronos_uint64_t;
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
|
||||
#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
|
||||
|
||||
/*
|
||||
* Win32
|
||||
*/
|
||||
typedef __int32 khronos_int32_t;
|
||||
typedef unsigned __int32 khronos_uint32_t;
|
||||
typedef __int64 khronos_int64_t;
|
||||
typedef unsigned __int64 khronos_uint64_t;
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
|
||||
#elif defined(__sun__) || defined(__digital__)
|
||||
|
||||
/*
|
||||
* Sun or Digital
|
||||
*/
|
||||
typedef int khronos_int32_t;
|
||||
typedef unsigned int khronos_uint32_t;
|
||||
#if defined(__arch64__) || defined(_LP64)
|
||||
typedef long int khronos_int64_t;
|
||||
typedef unsigned long int khronos_uint64_t;
|
||||
#else
|
||||
typedef long long int khronos_int64_t;
|
||||
typedef unsigned long long int khronos_uint64_t;
|
||||
#endif /* __arch64__ */
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
|
||||
#elif 0
|
||||
|
||||
/*
|
||||
* Hypothetical platform with no float or int64 support
|
||||
*/
|
||||
typedef int khronos_int32_t;
|
||||
typedef unsigned int khronos_uint32_t;
|
||||
#define KHRONOS_SUPPORT_INT64 0
|
||||
#define KHRONOS_SUPPORT_FLOAT 0
|
||||
|
||||
#else
|
||||
|
||||
/*
|
||||
* Generic fallback
|
||||
*/
|
||||
#include <stdint.h>
|
||||
typedef int32_t khronos_int32_t;
|
||||
typedef uint32_t khronos_uint32_t;
|
||||
typedef int64_t khronos_int64_t;
|
||||
typedef uint64_t khronos_uint64_t;
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Types that are (so far) the same on all platforms
|
||||
*/
|
||||
typedef signed char khronos_int8_t;
|
||||
typedef unsigned char khronos_uint8_t;
|
||||
typedef signed short int khronos_int16_t;
|
||||
typedef unsigned short int khronos_uint16_t;
|
||||
|
||||
/*
|
||||
* Types that differ between LLP64 and LP64 architectures - in LLP64,
|
||||
* pointers are 64 bits, but 'long' is still 32 bits. Win64 appears
|
||||
* to be the only LLP64 architecture in current use.
|
||||
*/
|
||||
#ifdef KHRONOS_USE_INTPTR_T
|
||||
typedef intptr_t khronos_intptr_t;
|
||||
typedef uintptr_t khronos_uintptr_t;
|
||||
#elif defined(_WIN64)
|
||||
typedef signed long long int khronos_intptr_t;
|
||||
typedef unsigned long long int khronos_uintptr_t;
|
||||
#else
|
||||
typedef signed long int khronos_intptr_t;
|
||||
typedef unsigned long int khronos_uintptr_t;
|
||||
#endif
|
||||
|
||||
#if defined(_WIN64)
|
||||
typedef signed long long int khronos_ssize_t;
|
||||
typedef unsigned long long int khronos_usize_t;
|
||||
#else
|
||||
typedef signed long int khronos_ssize_t;
|
||||
typedef unsigned long int khronos_usize_t;
|
||||
#endif
|
||||
|
||||
#if KHRONOS_SUPPORT_FLOAT
|
||||
/*
|
||||
* Float type
|
||||
*/
|
||||
typedef float khronos_float_t;
|
||||
#endif
|
||||
|
||||
#if KHRONOS_SUPPORT_INT64
|
||||
/* Time types
|
||||
*
|
||||
* These types can be used to represent a time interval in nanoseconds or
|
||||
* an absolute Unadjusted System Time. Unadjusted System Time is the number
|
||||
* of nanoseconds since some arbitrary system event (e.g. since the last
|
||||
* time the system booted). The Unadjusted System Time is an unsigned
|
||||
* 64 bit value that wraps back to 0 every 584 years. Time intervals
|
||||
* may be either signed or unsigned.
|
||||
*/
|
||||
typedef khronos_uint64_t khronos_utime_nanoseconds_t;
|
||||
typedef khronos_int64_t khronos_stime_nanoseconds_t;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Dummy value used to pad enum types to 32 bits.
|
||||
*/
|
||||
#ifndef KHRONOS_MAX_ENUM
|
||||
#define KHRONOS_MAX_ENUM 0x7FFFFFFF
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Enumerated boolean type
|
||||
*
|
||||
* Values other than zero should be considered to be true. Therefore
|
||||
* comparisons should not be made against KHRONOS_TRUE.
|
||||
*/
|
||||
typedef enum {
|
||||
KHRONOS_FALSE = 0,
|
||||
KHRONOS_TRUE = 1,
|
||||
KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
|
||||
} khronos_boolean_enum_t;
|
||||
|
||||
#endif /* __khrplatform_h_ */
|
||||
28023
third-party/glad/glad/files/vk.xml
vendored
Normal file
28023
third-party/glad/glad/files/vk.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
84
third-party/glad/glad/files/vk_platform.h
vendored
Normal file
84
third-party/glad/glad/files/vk_platform.h
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
//
|
||||
// File: vk_platform.h
|
||||
//
|
||||
/*
|
||||
** Copyright 2014-2024 The Khronos Group Inc.
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
|
||||
#ifndef VK_PLATFORM_H_
|
||||
#define VK_PLATFORM_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif // __cplusplus
|
||||
|
||||
/*
|
||||
***************************************************************************************************
|
||||
* Platform-specific directives and type declarations
|
||||
***************************************************************************************************
|
||||
*/
|
||||
|
||||
/* Platform-specific calling convention macros.
|
||||
*
|
||||
* Platforms should define these so that Vulkan clients call Vulkan commands
|
||||
* with the same calling conventions that the Vulkan implementation expects.
|
||||
*
|
||||
* VKAPI_ATTR - Placed before the return type in function declarations.
|
||||
* Useful for C++11 and GCC/Clang-style function attribute syntax.
|
||||
* VKAPI_CALL - Placed after the return type in function declarations.
|
||||
* Useful for MSVC-style calling convention syntax.
|
||||
* VKAPI_PTR - Placed between the '(' and '*' in function pointer types.
|
||||
*
|
||||
* Function declaration: VKAPI_ATTR void VKAPI_CALL vkCommand(void);
|
||||
* Function pointer type: typedef void (VKAPI_PTR *PFN_vkCommand)(void);
|
||||
*/
|
||||
#if defined(_WIN32)
|
||||
// On Windows, Vulkan commands use the stdcall convention
|
||||
#define VKAPI_ATTR
|
||||
#define VKAPI_CALL __stdcall
|
||||
#define VKAPI_PTR VKAPI_CALL
|
||||
#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH < 7
|
||||
#error "Vulkan is not supported for the 'armeabi' NDK ABI"
|
||||
#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7 && defined(__ARM_32BIT_STATE)
|
||||
// On Android 32-bit ARM targets, Vulkan functions use the "hardfloat"
|
||||
// calling convention, i.e. float parameters are passed in registers. This
|
||||
// is true even if the rest of the application passes floats on the stack,
|
||||
// as it does by default when compiling for the armeabi-v7a NDK ABI.
|
||||
#define VKAPI_ATTR __attribute__((pcs("aapcs-vfp")))
|
||||
#define VKAPI_CALL
|
||||
#define VKAPI_PTR VKAPI_ATTR
|
||||
#else
|
||||
// On other platforms, use the default calling convention
|
||||
#define VKAPI_ATTR
|
||||
#define VKAPI_CALL
|
||||
#define VKAPI_PTR
|
||||
#endif
|
||||
|
||||
#if !defined(VK_NO_STDDEF_H)
|
||||
#include <stddef.h>
|
||||
#endif // !defined(VK_NO_STDDEF_H)
|
||||
|
||||
#if !defined(VK_NO_STDINT_H)
|
||||
#if defined(_MSC_VER) && (_MSC_VER < 1600)
|
||||
typedef signed __int8 int8_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef signed __int16 int16_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef signed __int32 int32_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef signed __int64 int64_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#endif // !defined(VK_NO_STDINT_H)
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif
|
||||
392
third-party/glad/glad/files/vulkan_video_codec_av1std.h
vendored
Normal file
392
third-party/glad/glad/files/vulkan_video_codec_av1std.h
vendored
Normal file
@@ -0,0 +1,392 @@
|
||||
#ifndef VULKAN_VIDEO_CODEC_AV1STD_H_
|
||||
#define VULKAN_VIDEO_CODEC_AV1STD_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright 2015-2024 The Khronos Group Inc.
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is generated from the Khronos Vulkan XML API Registry.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// vulkan_video_codec_av1std is a preprocessor guard. Do not pass it to API calls.
|
||||
#define vulkan_video_codec_av1std 1
|
||||
#include "vulkan_video_codecs_common.h"
|
||||
#define STD_VIDEO_AV1_NUM_REF_FRAMES 8
|
||||
#define STD_VIDEO_AV1_REFS_PER_FRAME 7
|
||||
#define STD_VIDEO_AV1_TOTAL_REFS_PER_FRAME 8
|
||||
#define STD_VIDEO_AV1_MAX_TILE_COLS 64
|
||||
#define STD_VIDEO_AV1_MAX_TILE_ROWS 64
|
||||
#define STD_VIDEO_AV1_MAX_SEGMENTS 8
|
||||
#define STD_VIDEO_AV1_SEG_LVL_MAX 8
|
||||
#define STD_VIDEO_AV1_PRIMARY_REF_NONE 7
|
||||
#define STD_VIDEO_AV1_SELECT_INTEGER_MV 2
|
||||
#define STD_VIDEO_AV1_SELECT_SCREEN_CONTENT_TOOLS 2
|
||||
#define STD_VIDEO_AV1_SKIP_MODE_FRAMES 2
|
||||
#define STD_VIDEO_AV1_MAX_LOOP_FILTER_STRENGTHS 4
|
||||
#define STD_VIDEO_AV1_LOOP_FILTER_ADJUSTMENTS 2
|
||||
#define STD_VIDEO_AV1_MAX_CDEF_FILTER_STRENGTHS 8
|
||||
#define STD_VIDEO_AV1_MAX_NUM_PLANES 3
|
||||
#define STD_VIDEO_AV1_GLOBAL_MOTION_PARAMS 6
|
||||
#define STD_VIDEO_AV1_MAX_NUM_Y_POINTS 14
|
||||
#define STD_VIDEO_AV1_MAX_NUM_CB_POINTS 10
|
||||
#define STD_VIDEO_AV1_MAX_NUM_CR_POINTS 10
|
||||
#define STD_VIDEO_AV1_MAX_NUM_POS_LUMA 24
|
||||
#define STD_VIDEO_AV1_MAX_NUM_POS_CHROMA 25
|
||||
|
||||
typedef enum StdVideoAV1Profile {
|
||||
STD_VIDEO_AV1_PROFILE_MAIN = 0,
|
||||
STD_VIDEO_AV1_PROFILE_HIGH = 1,
|
||||
STD_VIDEO_AV1_PROFILE_PROFESSIONAL = 2,
|
||||
STD_VIDEO_AV1_PROFILE_INVALID = 0x7FFFFFFF,
|
||||
STD_VIDEO_AV1_PROFILE_MAX_ENUM = 0x7FFFFFFF
|
||||
} StdVideoAV1Profile;
|
||||
|
||||
typedef enum StdVideoAV1Level {
|
||||
STD_VIDEO_AV1_LEVEL_2_0 = 0,
|
||||
STD_VIDEO_AV1_LEVEL_2_1 = 1,
|
||||
STD_VIDEO_AV1_LEVEL_2_2 = 2,
|
||||
STD_VIDEO_AV1_LEVEL_2_3 = 3,
|
||||
STD_VIDEO_AV1_LEVEL_3_0 = 4,
|
||||
STD_VIDEO_AV1_LEVEL_3_1 = 5,
|
||||
STD_VIDEO_AV1_LEVEL_3_2 = 6,
|
||||
STD_VIDEO_AV1_LEVEL_3_3 = 7,
|
||||
STD_VIDEO_AV1_LEVEL_4_0 = 8,
|
||||
STD_VIDEO_AV1_LEVEL_4_1 = 9,
|
||||
STD_VIDEO_AV1_LEVEL_4_2 = 10,
|
||||
STD_VIDEO_AV1_LEVEL_4_3 = 11,
|
||||
STD_VIDEO_AV1_LEVEL_5_0 = 12,
|
||||
STD_VIDEO_AV1_LEVEL_5_1 = 13,
|
||||
STD_VIDEO_AV1_LEVEL_5_2 = 14,
|
||||
STD_VIDEO_AV1_LEVEL_5_3 = 15,
|
||||
STD_VIDEO_AV1_LEVEL_6_0 = 16,
|
||||
STD_VIDEO_AV1_LEVEL_6_1 = 17,
|
||||
STD_VIDEO_AV1_LEVEL_6_2 = 18,
|
||||
STD_VIDEO_AV1_LEVEL_6_3 = 19,
|
||||
STD_VIDEO_AV1_LEVEL_7_0 = 20,
|
||||
STD_VIDEO_AV1_LEVEL_7_1 = 21,
|
||||
STD_VIDEO_AV1_LEVEL_7_2 = 22,
|
||||
STD_VIDEO_AV1_LEVEL_7_3 = 23,
|
||||
STD_VIDEO_AV1_LEVEL_INVALID = 0x7FFFFFFF,
|
||||
STD_VIDEO_AV1_LEVEL_MAX_ENUM = 0x7FFFFFFF
|
||||
} StdVideoAV1Level;
|
||||
|
||||
typedef enum StdVideoAV1FrameType {
|
||||
STD_VIDEO_AV1_FRAME_TYPE_KEY = 0,
|
||||
STD_VIDEO_AV1_FRAME_TYPE_INTER = 1,
|
||||
STD_VIDEO_AV1_FRAME_TYPE_INTRA_ONLY = 2,
|
||||
STD_VIDEO_AV1_FRAME_TYPE_SWITCH = 3,
|
||||
STD_VIDEO_AV1_FRAME_TYPE_INVALID = 0x7FFFFFFF,
|
||||
STD_VIDEO_AV1_FRAME_TYPE_MAX_ENUM = 0x7FFFFFFF
|
||||
} StdVideoAV1FrameType;
|
||||
|
||||
typedef enum StdVideoAV1ReferenceName {
|
||||
STD_VIDEO_AV1_REFERENCE_NAME_INTRA_FRAME = 0,
|
||||
STD_VIDEO_AV1_REFERENCE_NAME_LAST_FRAME = 1,
|
||||
STD_VIDEO_AV1_REFERENCE_NAME_LAST2_FRAME = 2,
|
||||
STD_VIDEO_AV1_REFERENCE_NAME_LAST3_FRAME = 3,
|
||||
STD_VIDEO_AV1_REFERENCE_NAME_GOLDEN_FRAME = 4,
|
||||
STD_VIDEO_AV1_REFERENCE_NAME_BWDREF_FRAME = 5,
|
||||
STD_VIDEO_AV1_REFERENCE_NAME_ALTREF2_FRAME = 6,
|
||||
STD_VIDEO_AV1_REFERENCE_NAME_ALTREF_FRAME = 7,
|
||||
STD_VIDEO_AV1_REFERENCE_NAME_INVALID = 0x7FFFFFFF,
|
||||
STD_VIDEO_AV1_REFERENCE_NAME_MAX_ENUM = 0x7FFFFFFF
|
||||
} StdVideoAV1ReferenceName;
|
||||
|
||||
typedef enum StdVideoAV1InterpolationFilter {
|
||||
STD_VIDEO_AV1_INTERPOLATION_FILTER_EIGHTTAP = 0,
|
||||
STD_VIDEO_AV1_INTERPOLATION_FILTER_EIGHTTAP_SMOOTH = 1,
|
||||
STD_VIDEO_AV1_INTERPOLATION_FILTER_EIGHTTAP_SHARP = 2,
|
||||
STD_VIDEO_AV1_INTERPOLATION_FILTER_BILINEAR = 3,
|
||||
STD_VIDEO_AV1_INTERPOLATION_FILTER_SWITCHABLE = 4,
|
||||
STD_VIDEO_AV1_INTERPOLATION_FILTER_INVALID = 0x7FFFFFFF,
|
||||
STD_VIDEO_AV1_INTERPOLATION_FILTER_MAX_ENUM = 0x7FFFFFFF
|
||||
} StdVideoAV1InterpolationFilter;
|
||||
|
||||
typedef enum StdVideoAV1TxMode {
|
||||
STD_VIDEO_AV1_TX_MODE_ONLY_4X4 = 0,
|
||||
STD_VIDEO_AV1_TX_MODE_LARGEST = 1,
|
||||
STD_VIDEO_AV1_TX_MODE_SELECT = 2,
|
||||
STD_VIDEO_AV1_TX_MODE_INVALID = 0x7FFFFFFF,
|
||||
STD_VIDEO_AV1_TX_MODE_MAX_ENUM = 0x7FFFFFFF
|
||||
} StdVideoAV1TxMode;
|
||||
|
||||
typedef enum StdVideoAV1FrameRestorationType {
|
||||
STD_VIDEO_AV1_FRAME_RESTORATION_TYPE_NONE = 0,
|
||||
STD_VIDEO_AV1_FRAME_RESTORATION_TYPE_WIENER = 1,
|
||||
STD_VIDEO_AV1_FRAME_RESTORATION_TYPE_SGRPROJ = 2,
|
||||
STD_VIDEO_AV1_FRAME_RESTORATION_TYPE_SWITCHABLE = 3,
|
||||
STD_VIDEO_AV1_FRAME_RESTORATION_TYPE_INVALID = 0x7FFFFFFF,
|
||||
STD_VIDEO_AV1_FRAME_RESTORATION_TYPE_MAX_ENUM = 0x7FFFFFFF
|
||||
} StdVideoAV1FrameRestorationType;
|
||||
|
||||
typedef enum StdVideoAV1ColorPrimaries {
|
||||
STD_VIDEO_AV1_COLOR_PRIMARIES_BT_709 = 1,
|
||||
STD_VIDEO_AV1_COLOR_PRIMARIES_BT_UNSPECIFIED = 2,
|
||||
STD_VIDEO_AV1_COLOR_PRIMARIES_BT_470_M = 4,
|
||||
STD_VIDEO_AV1_COLOR_PRIMARIES_BT_470_B_G = 5,
|
||||
STD_VIDEO_AV1_COLOR_PRIMARIES_BT_601 = 6,
|
||||
STD_VIDEO_AV1_COLOR_PRIMARIES_SMPTE_240 = 7,
|
||||
STD_VIDEO_AV1_COLOR_PRIMARIES_GENERIC_FILM = 8,
|
||||
STD_VIDEO_AV1_COLOR_PRIMARIES_BT_2020 = 9,
|
||||
STD_VIDEO_AV1_COLOR_PRIMARIES_XYZ = 10,
|
||||
STD_VIDEO_AV1_COLOR_PRIMARIES_SMPTE_431 = 11,
|
||||
STD_VIDEO_AV1_COLOR_PRIMARIES_SMPTE_432 = 12,
|
||||
STD_VIDEO_AV1_COLOR_PRIMARIES_EBU_3213 = 22,
|
||||
STD_VIDEO_AV1_COLOR_PRIMARIES_INVALID = 0x7FFFFFFF,
|
||||
STD_VIDEO_AV1_COLOR_PRIMARIES_MAX_ENUM = 0x7FFFFFFF
|
||||
} StdVideoAV1ColorPrimaries;
|
||||
|
||||
typedef enum StdVideoAV1TransferCharacteristics {
|
||||
STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_RESERVED_0 = 0,
|
||||
STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_BT_709 = 1,
|
||||
STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_UNSPECIFIED = 2,
|
||||
STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_RESERVED_3 = 3,
|
||||
STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_BT_470_M = 4,
|
||||
STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_BT_470_B_G = 5,
|
||||
STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_BT_601 = 6,
|
||||
STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_SMPTE_240 = 7,
|
||||
STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_LINEAR = 8,
|
||||
STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_LOG_100 = 9,
|
||||
STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_LOG_100_SQRT10 = 10,
|
||||
STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_IEC_61966 = 11,
|
||||
STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_BT_1361 = 12,
|
||||
STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_SRGB = 13,
|
||||
STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_BT_2020_10_BIT = 14,
|
||||
STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_BT_2020_12_BIT = 15,
|
||||
STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_SMPTE_2084 = 16,
|
||||
STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_SMPTE_428 = 17,
|
||||
STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_HLG = 18,
|
||||
STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_INVALID = 0x7FFFFFFF,
|
||||
STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_MAX_ENUM = 0x7FFFFFFF
|
||||
} StdVideoAV1TransferCharacteristics;
|
||||
|
||||
typedef enum StdVideoAV1MatrixCoefficients {
|
||||
STD_VIDEO_AV1_MATRIX_COEFFICIENTS_IDENTITY = 0,
|
||||
STD_VIDEO_AV1_MATRIX_COEFFICIENTS_BT_709 = 1,
|
||||
STD_VIDEO_AV1_MATRIX_COEFFICIENTS_UNSPECIFIED = 2,
|
||||
STD_VIDEO_AV1_MATRIX_COEFFICIENTS_RESERVED_3 = 3,
|
||||
STD_VIDEO_AV1_MATRIX_COEFFICIENTS_FCC = 4,
|
||||
STD_VIDEO_AV1_MATRIX_COEFFICIENTS_BT_470_B_G = 5,
|
||||
STD_VIDEO_AV1_MATRIX_COEFFICIENTS_BT_601 = 6,
|
||||
STD_VIDEO_AV1_MATRIX_COEFFICIENTS_SMPTE_240 = 7,
|
||||
STD_VIDEO_AV1_MATRIX_COEFFICIENTS_SMPTE_YCGCO = 8,
|
||||
STD_VIDEO_AV1_MATRIX_COEFFICIENTS_BT_2020_NCL = 9,
|
||||
STD_VIDEO_AV1_MATRIX_COEFFICIENTS_BT_2020_CL = 10,
|
||||
STD_VIDEO_AV1_MATRIX_COEFFICIENTS_SMPTE_2085 = 11,
|
||||
STD_VIDEO_AV1_MATRIX_COEFFICIENTS_CHROMAT_NCL = 12,
|
||||
STD_VIDEO_AV1_MATRIX_COEFFICIENTS_CHROMAT_CL = 13,
|
||||
STD_VIDEO_AV1_MATRIX_COEFFICIENTS_ICTCP = 14,
|
||||
STD_VIDEO_AV1_MATRIX_COEFFICIENTS_INVALID = 0x7FFFFFFF,
|
||||
STD_VIDEO_AV1_MATRIX_COEFFICIENTS_MAX_ENUM = 0x7FFFFFFF
|
||||
} StdVideoAV1MatrixCoefficients;
|
||||
|
||||
typedef enum StdVideoAV1ChromaSamplePosition {
|
||||
STD_VIDEO_AV1_CHROMA_SAMPLE_POSITION_UNKNOWN = 0,
|
||||
STD_VIDEO_AV1_CHROMA_SAMPLE_POSITION_VERTICAL = 1,
|
||||
STD_VIDEO_AV1_CHROMA_SAMPLE_POSITION_COLOCATED = 2,
|
||||
STD_VIDEO_AV1_CHROMA_SAMPLE_POSITION_RESERVED = 3,
|
||||
STD_VIDEO_AV1_CHROMA_SAMPLE_POSITION_INVALID = 0x7FFFFFFF,
|
||||
STD_VIDEO_AV1_CHROMA_SAMPLE_POSITION_MAX_ENUM = 0x7FFFFFFF
|
||||
} StdVideoAV1ChromaSamplePosition;
|
||||
typedef struct StdVideoAV1ColorConfigFlags {
|
||||
uint32_t mono_chrome : 1;
|
||||
uint32_t color_range : 1;
|
||||
uint32_t separate_uv_delta_q : 1;
|
||||
uint32_t color_description_present_flag : 1;
|
||||
uint32_t reserved : 28;
|
||||
} StdVideoAV1ColorConfigFlags;
|
||||
|
||||
typedef struct StdVideoAV1ColorConfig {
|
||||
StdVideoAV1ColorConfigFlags flags;
|
||||
uint8_t BitDepth;
|
||||
uint8_t subsampling_x;
|
||||
uint8_t subsampling_y;
|
||||
uint8_t reserved1;
|
||||
StdVideoAV1ColorPrimaries color_primaries;
|
||||
StdVideoAV1TransferCharacteristics transfer_characteristics;
|
||||
StdVideoAV1MatrixCoefficients matrix_coefficients;
|
||||
StdVideoAV1ChromaSamplePosition chroma_sample_position;
|
||||
} StdVideoAV1ColorConfig;
|
||||
|
||||
typedef struct StdVideoAV1TimingInfoFlags {
|
||||
uint32_t equal_picture_interval : 1;
|
||||
uint32_t reserved : 31;
|
||||
} StdVideoAV1TimingInfoFlags;
|
||||
|
||||
typedef struct StdVideoAV1TimingInfo {
|
||||
StdVideoAV1TimingInfoFlags flags;
|
||||
uint32_t num_units_in_display_tick;
|
||||
uint32_t time_scale;
|
||||
uint32_t num_ticks_per_picture_minus_1;
|
||||
} StdVideoAV1TimingInfo;
|
||||
|
||||
typedef struct StdVideoAV1LoopFilterFlags {
|
||||
uint32_t loop_filter_delta_enabled : 1;
|
||||
uint32_t loop_filter_delta_update : 1;
|
||||
uint32_t reserved : 30;
|
||||
} StdVideoAV1LoopFilterFlags;
|
||||
|
||||
typedef struct StdVideoAV1LoopFilter {
|
||||
StdVideoAV1LoopFilterFlags flags;
|
||||
uint8_t loop_filter_level[STD_VIDEO_AV1_MAX_LOOP_FILTER_STRENGTHS];
|
||||
uint8_t loop_filter_sharpness;
|
||||
uint8_t update_ref_delta;
|
||||
int8_t loop_filter_ref_deltas[STD_VIDEO_AV1_TOTAL_REFS_PER_FRAME];
|
||||
uint8_t update_mode_delta;
|
||||
int8_t loop_filter_mode_deltas[STD_VIDEO_AV1_LOOP_FILTER_ADJUSTMENTS];
|
||||
} StdVideoAV1LoopFilter;
|
||||
|
||||
typedef struct StdVideoAV1QuantizationFlags {
|
||||
uint32_t using_qmatrix : 1;
|
||||
uint32_t diff_uv_delta : 1;
|
||||
uint32_t reserved : 30;
|
||||
} StdVideoAV1QuantizationFlags;
|
||||
|
||||
typedef struct StdVideoAV1Quantization {
|
||||
StdVideoAV1QuantizationFlags flags;
|
||||
uint8_t base_q_idx;
|
||||
int8_t DeltaQYDc;
|
||||
int8_t DeltaQUDc;
|
||||
int8_t DeltaQUAc;
|
||||
int8_t DeltaQVDc;
|
||||
int8_t DeltaQVAc;
|
||||
uint8_t qm_y;
|
||||
uint8_t qm_u;
|
||||
uint8_t qm_v;
|
||||
} StdVideoAV1Quantization;
|
||||
|
||||
typedef struct StdVideoAV1Segmentation {
|
||||
uint8_t FeatureEnabled[STD_VIDEO_AV1_MAX_SEGMENTS];
|
||||
int16_t FeatureData[STD_VIDEO_AV1_MAX_SEGMENTS][STD_VIDEO_AV1_SEG_LVL_MAX];
|
||||
} StdVideoAV1Segmentation;
|
||||
|
||||
typedef struct StdVideoAV1TileInfoFlags {
|
||||
uint32_t uniform_tile_spacing_flag : 1;
|
||||
uint32_t reserved : 31;
|
||||
} StdVideoAV1TileInfoFlags;
|
||||
|
||||
typedef struct StdVideoAV1TileInfo {
|
||||
StdVideoAV1TileInfoFlags flags;
|
||||
uint8_t TileCols;
|
||||
uint8_t TileRows;
|
||||
uint16_t context_update_tile_id;
|
||||
uint8_t tile_size_bytes_minus_1;
|
||||
uint8_t reserved1[7];
|
||||
const uint16_t* pMiColStarts;
|
||||
const uint16_t* pMiRowStarts;
|
||||
const uint16_t* pWidthInSbsMinus1;
|
||||
const uint16_t* pHeightInSbsMinus1;
|
||||
} StdVideoAV1TileInfo;
|
||||
|
||||
typedef struct StdVideoAV1CDEF {
|
||||
uint8_t cdef_damping_minus_3;
|
||||
uint8_t cdef_bits;
|
||||
uint8_t cdef_y_pri_strength[STD_VIDEO_AV1_MAX_CDEF_FILTER_STRENGTHS];
|
||||
uint8_t cdef_y_sec_strength[STD_VIDEO_AV1_MAX_CDEF_FILTER_STRENGTHS];
|
||||
uint8_t cdef_uv_pri_strength[STD_VIDEO_AV1_MAX_CDEF_FILTER_STRENGTHS];
|
||||
uint8_t cdef_uv_sec_strength[STD_VIDEO_AV1_MAX_CDEF_FILTER_STRENGTHS];
|
||||
} StdVideoAV1CDEF;
|
||||
|
||||
typedef struct StdVideoAV1LoopRestoration {
|
||||
StdVideoAV1FrameRestorationType FrameRestorationType[STD_VIDEO_AV1_MAX_NUM_PLANES];
|
||||
uint16_t LoopRestorationSize[STD_VIDEO_AV1_MAX_NUM_PLANES];
|
||||
} StdVideoAV1LoopRestoration;
|
||||
|
||||
typedef struct StdVideoAV1GlobalMotion {
|
||||
uint8_t GmType[STD_VIDEO_AV1_NUM_REF_FRAMES];
|
||||
int32_t gm_params[STD_VIDEO_AV1_NUM_REF_FRAMES][STD_VIDEO_AV1_GLOBAL_MOTION_PARAMS];
|
||||
} StdVideoAV1GlobalMotion;
|
||||
|
||||
typedef struct StdVideoAV1FilmGrainFlags {
|
||||
uint32_t chroma_scaling_from_luma : 1;
|
||||
uint32_t overlap_flag : 1;
|
||||
uint32_t clip_to_restricted_range : 1;
|
||||
uint32_t update_grain : 1;
|
||||
uint32_t reserved : 28;
|
||||
} StdVideoAV1FilmGrainFlags;
|
||||
|
||||
typedef struct StdVideoAV1FilmGrain {
|
||||
StdVideoAV1FilmGrainFlags flags;
|
||||
uint8_t grain_scaling_minus_8;
|
||||
uint8_t ar_coeff_lag;
|
||||
uint8_t ar_coeff_shift_minus_6;
|
||||
uint8_t grain_scale_shift;
|
||||
uint16_t grain_seed;
|
||||
uint8_t film_grain_params_ref_idx;
|
||||
uint8_t num_y_points;
|
||||
uint8_t point_y_value[STD_VIDEO_AV1_MAX_NUM_Y_POINTS];
|
||||
uint8_t point_y_scaling[STD_VIDEO_AV1_MAX_NUM_Y_POINTS];
|
||||
uint8_t num_cb_points;
|
||||
uint8_t point_cb_value[STD_VIDEO_AV1_MAX_NUM_CB_POINTS];
|
||||
uint8_t point_cb_scaling[STD_VIDEO_AV1_MAX_NUM_CB_POINTS];
|
||||
uint8_t num_cr_points;
|
||||
uint8_t point_cr_value[STD_VIDEO_AV1_MAX_NUM_CR_POINTS];
|
||||
uint8_t point_cr_scaling[STD_VIDEO_AV1_MAX_NUM_CR_POINTS];
|
||||
int8_t ar_coeffs_y_plus_128[STD_VIDEO_AV1_MAX_NUM_POS_LUMA];
|
||||
int8_t ar_coeffs_cb_plus_128[STD_VIDEO_AV1_MAX_NUM_POS_CHROMA];
|
||||
int8_t ar_coeffs_cr_plus_128[STD_VIDEO_AV1_MAX_NUM_POS_CHROMA];
|
||||
uint8_t cb_mult;
|
||||
uint8_t cb_luma_mult;
|
||||
uint16_t cb_offset;
|
||||
uint8_t cr_mult;
|
||||
uint8_t cr_luma_mult;
|
||||
uint16_t cr_offset;
|
||||
} StdVideoAV1FilmGrain;
|
||||
|
||||
typedef struct StdVideoAV1SequenceHeaderFlags {
|
||||
uint32_t still_picture : 1;
|
||||
uint32_t reduced_still_picture_header : 1;
|
||||
uint32_t use_128x128_superblock : 1;
|
||||
uint32_t enable_filter_intra : 1;
|
||||
uint32_t enable_intra_edge_filter : 1;
|
||||
uint32_t enable_interintra_compound : 1;
|
||||
uint32_t enable_masked_compound : 1;
|
||||
uint32_t enable_warped_motion : 1;
|
||||
uint32_t enable_dual_filter : 1;
|
||||
uint32_t enable_order_hint : 1;
|
||||
uint32_t enable_jnt_comp : 1;
|
||||
uint32_t enable_ref_frame_mvs : 1;
|
||||
uint32_t frame_id_numbers_present_flag : 1;
|
||||
uint32_t enable_superres : 1;
|
||||
uint32_t enable_cdef : 1;
|
||||
uint32_t enable_restoration : 1;
|
||||
uint32_t film_grain_params_present : 1;
|
||||
uint32_t timing_info_present_flag : 1;
|
||||
uint32_t initial_display_delay_present_flag : 1;
|
||||
uint32_t reserved : 13;
|
||||
} StdVideoAV1SequenceHeaderFlags;
|
||||
|
||||
typedef struct StdVideoAV1SequenceHeader {
|
||||
StdVideoAV1SequenceHeaderFlags flags;
|
||||
StdVideoAV1Profile seq_profile;
|
||||
uint8_t frame_width_bits_minus_1;
|
||||
uint8_t frame_height_bits_minus_1;
|
||||
uint16_t max_frame_width_minus_1;
|
||||
uint16_t max_frame_height_minus_1;
|
||||
uint8_t delta_frame_id_length_minus_2;
|
||||
uint8_t additional_frame_id_length_minus_1;
|
||||
uint8_t order_hint_bits_minus_1;
|
||||
uint8_t seq_force_integer_mv;
|
||||
uint8_t seq_force_screen_content_tools;
|
||||
uint8_t reserved1[5];
|
||||
const StdVideoAV1ColorConfig* pColorConfig;
|
||||
const StdVideoAV1TimingInfo* pTimingInfo;
|
||||
} StdVideoAV1SequenceHeader;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
109
third-party/glad/glad/files/vulkan_video_codec_av1std_decode.h
vendored
Normal file
109
third-party/glad/glad/files/vulkan_video_codec_av1std_decode.h
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
#ifndef VULKAN_VIDEO_CODEC_AV1STD_DECODE_H_
|
||||
#define VULKAN_VIDEO_CODEC_AV1STD_DECODE_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright 2015-2024 The Khronos Group Inc.
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is generated from the Khronos Vulkan XML API Registry.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// vulkan_video_codec_av1std_decode is a preprocessor guard. Do not pass it to API calls.
|
||||
#define vulkan_video_codec_av1std_decode 1
|
||||
#include "vulkan_video_codec_av1std.h"
|
||||
|
||||
#define VK_STD_VULKAN_VIDEO_CODEC_AV1_DECODE_API_VERSION_1_0_0 VK_MAKE_VIDEO_STD_VERSION(1, 0, 0)
|
||||
|
||||
#define VK_STD_VULKAN_VIDEO_CODEC_AV1_DECODE_SPEC_VERSION VK_STD_VULKAN_VIDEO_CODEC_AV1_DECODE_API_VERSION_1_0_0
|
||||
#define VK_STD_VULKAN_VIDEO_CODEC_AV1_DECODE_EXTENSION_NAME "VK_STD_vulkan_video_codec_av1_decode"
|
||||
typedef struct StdVideoDecodeAV1PictureInfoFlags {
|
||||
uint32_t error_resilient_mode : 1;
|
||||
uint32_t disable_cdf_update : 1;
|
||||
uint32_t use_superres : 1;
|
||||
uint32_t render_and_frame_size_different : 1;
|
||||
uint32_t allow_screen_content_tools : 1;
|
||||
uint32_t is_filter_switchable : 1;
|
||||
uint32_t force_integer_mv : 1;
|
||||
uint32_t frame_size_override_flag : 1;
|
||||
uint32_t buffer_removal_time_present_flag : 1;
|
||||
uint32_t allow_intrabc : 1;
|
||||
uint32_t frame_refs_short_signaling : 1;
|
||||
uint32_t allow_high_precision_mv : 1;
|
||||
uint32_t is_motion_mode_switchable : 1;
|
||||
uint32_t use_ref_frame_mvs : 1;
|
||||
uint32_t disable_frame_end_update_cdf : 1;
|
||||
uint32_t allow_warped_motion : 1;
|
||||
uint32_t reduced_tx_set : 1;
|
||||
uint32_t reference_select : 1;
|
||||
uint32_t skip_mode_present : 1;
|
||||
uint32_t delta_q_present : 1;
|
||||
uint32_t delta_lf_present : 1;
|
||||
uint32_t delta_lf_multi : 1;
|
||||
uint32_t segmentation_enabled : 1;
|
||||
uint32_t segmentation_update_map : 1;
|
||||
uint32_t segmentation_temporal_update : 1;
|
||||
uint32_t segmentation_update_data : 1;
|
||||
uint32_t UsesLr : 1;
|
||||
uint32_t usesChromaLr : 1;
|
||||
uint32_t apply_grain : 1;
|
||||
uint32_t reserved : 3;
|
||||
} StdVideoDecodeAV1PictureInfoFlags;
|
||||
|
||||
typedef struct StdVideoDecodeAV1PictureInfo {
|
||||
StdVideoDecodeAV1PictureInfoFlags flags;
|
||||
StdVideoAV1FrameType frame_type;
|
||||
uint32_t current_frame_id;
|
||||
uint8_t OrderHint;
|
||||
uint8_t primary_ref_frame;
|
||||
uint8_t refresh_frame_flags;
|
||||
uint8_t reserved1;
|
||||
StdVideoAV1InterpolationFilter interpolation_filter;
|
||||
StdVideoAV1TxMode TxMode;
|
||||
uint8_t delta_q_res;
|
||||
uint8_t delta_lf_res;
|
||||
uint8_t SkipModeFrame[STD_VIDEO_AV1_SKIP_MODE_FRAMES];
|
||||
uint8_t coded_denom;
|
||||
uint8_t reserved2[3];
|
||||
uint8_t OrderHints[STD_VIDEO_AV1_NUM_REF_FRAMES];
|
||||
uint32_t expectedFrameId[STD_VIDEO_AV1_NUM_REF_FRAMES];
|
||||
const StdVideoAV1TileInfo* pTileInfo;
|
||||
const StdVideoAV1Quantization* pQuantization;
|
||||
const StdVideoAV1Segmentation* pSegmentation;
|
||||
const StdVideoAV1LoopFilter* pLoopFilter;
|
||||
const StdVideoAV1CDEF* pCDEF;
|
||||
const StdVideoAV1LoopRestoration* pLoopRestoration;
|
||||
const StdVideoAV1GlobalMotion* pGlobalMotion;
|
||||
const StdVideoAV1FilmGrain* pFilmGrain;
|
||||
} StdVideoDecodeAV1PictureInfo;
|
||||
|
||||
typedef struct StdVideoDecodeAV1ReferenceInfoFlags {
|
||||
uint32_t disable_frame_end_update_cdf : 1;
|
||||
uint32_t segmentation_enabled : 1;
|
||||
uint32_t reserved : 30;
|
||||
} StdVideoDecodeAV1ReferenceInfoFlags;
|
||||
|
||||
typedef struct StdVideoDecodeAV1ReferenceInfo {
|
||||
StdVideoDecodeAV1ReferenceInfoFlags flags;
|
||||
uint8_t frame_type;
|
||||
uint8_t RefFrameSignBias;
|
||||
uint8_t OrderHint;
|
||||
uint8_t SavedOrderHints[STD_VIDEO_AV1_NUM_REF_FRAMES];
|
||||
} StdVideoDecodeAV1ReferenceInfo;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
312
third-party/glad/glad/files/vulkan_video_codec_h264std.h
vendored
Normal file
312
third-party/glad/glad/files/vulkan_video_codec_h264std.h
vendored
Normal file
@@ -0,0 +1,312 @@
|
||||
#ifndef VULKAN_VIDEO_CODEC_H264STD_H_
|
||||
#define VULKAN_VIDEO_CODEC_H264STD_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright 2015-2024 The Khronos Group Inc.
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is generated from the Khronos Vulkan XML API Registry.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// vulkan_video_codec_h264std is a preprocessor guard. Do not pass it to API calls.
|
||||
#define vulkan_video_codec_h264std 1
|
||||
#include "vulkan_video_codecs_common.h"
|
||||
#define STD_VIDEO_H264_CPB_CNT_LIST_SIZE 32
|
||||
#define STD_VIDEO_H264_SCALING_LIST_4X4_NUM_LISTS 6
|
||||
#define STD_VIDEO_H264_SCALING_LIST_4X4_NUM_ELEMENTS 16
|
||||
#define STD_VIDEO_H264_SCALING_LIST_8X8_NUM_LISTS 6
|
||||
#define STD_VIDEO_H264_SCALING_LIST_8X8_NUM_ELEMENTS 64
|
||||
#define STD_VIDEO_H264_MAX_NUM_LIST_REF 32
|
||||
#define STD_VIDEO_H264_MAX_CHROMA_PLANES 2
|
||||
#define STD_VIDEO_H264_NO_REFERENCE_PICTURE 0xFF
|
||||
|
||||
typedef enum StdVideoH264ChromaFormatIdc {
|
||||
STD_VIDEO_H264_CHROMA_FORMAT_IDC_MONOCHROME = 0,
|
||||
STD_VIDEO_H264_CHROMA_FORMAT_IDC_420 = 1,
|
||||
STD_VIDEO_H264_CHROMA_FORMAT_IDC_422 = 2,
|
||||
STD_VIDEO_H264_CHROMA_FORMAT_IDC_444 = 3,
|
||||
STD_VIDEO_H264_CHROMA_FORMAT_IDC_INVALID = 0x7FFFFFFF,
|
||||
STD_VIDEO_H264_CHROMA_FORMAT_IDC_MAX_ENUM = 0x7FFFFFFF
|
||||
} StdVideoH264ChromaFormatIdc;
|
||||
|
||||
typedef enum StdVideoH264ProfileIdc {
|
||||
STD_VIDEO_H264_PROFILE_IDC_BASELINE = 66,
|
||||
STD_VIDEO_H264_PROFILE_IDC_MAIN = 77,
|
||||
STD_VIDEO_H264_PROFILE_IDC_HIGH = 100,
|
||||
STD_VIDEO_H264_PROFILE_IDC_HIGH_444_PREDICTIVE = 244,
|
||||
STD_VIDEO_H264_PROFILE_IDC_INVALID = 0x7FFFFFFF,
|
||||
STD_VIDEO_H264_PROFILE_IDC_MAX_ENUM = 0x7FFFFFFF
|
||||
} StdVideoH264ProfileIdc;
|
||||
|
||||
typedef enum StdVideoH264LevelIdc {
|
||||
STD_VIDEO_H264_LEVEL_IDC_1_0 = 0,
|
||||
STD_VIDEO_H264_LEVEL_IDC_1_1 = 1,
|
||||
STD_VIDEO_H264_LEVEL_IDC_1_2 = 2,
|
||||
STD_VIDEO_H264_LEVEL_IDC_1_3 = 3,
|
||||
STD_VIDEO_H264_LEVEL_IDC_2_0 = 4,
|
||||
STD_VIDEO_H264_LEVEL_IDC_2_1 = 5,
|
||||
STD_VIDEO_H264_LEVEL_IDC_2_2 = 6,
|
||||
STD_VIDEO_H264_LEVEL_IDC_3_0 = 7,
|
||||
STD_VIDEO_H264_LEVEL_IDC_3_1 = 8,
|
||||
STD_VIDEO_H264_LEVEL_IDC_3_2 = 9,
|
||||
STD_VIDEO_H264_LEVEL_IDC_4_0 = 10,
|
||||
STD_VIDEO_H264_LEVEL_IDC_4_1 = 11,
|
||||
STD_VIDEO_H264_LEVEL_IDC_4_2 = 12,
|
||||
STD_VIDEO_H264_LEVEL_IDC_5_0 = 13,
|
||||
STD_VIDEO_H264_LEVEL_IDC_5_1 = 14,
|
||||
STD_VIDEO_H264_LEVEL_IDC_5_2 = 15,
|
||||
STD_VIDEO_H264_LEVEL_IDC_6_0 = 16,
|
||||
STD_VIDEO_H264_LEVEL_IDC_6_1 = 17,
|
||||
STD_VIDEO_H264_LEVEL_IDC_6_2 = 18,
|
||||
STD_VIDEO_H264_LEVEL_IDC_INVALID = 0x7FFFFFFF,
|
||||
STD_VIDEO_H264_LEVEL_IDC_MAX_ENUM = 0x7FFFFFFF
|
||||
} StdVideoH264LevelIdc;
|
||||
|
||||
typedef enum StdVideoH264PocType {
|
||||
STD_VIDEO_H264_POC_TYPE_0 = 0,
|
||||
STD_VIDEO_H264_POC_TYPE_1 = 1,
|
||||
STD_VIDEO_H264_POC_TYPE_2 = 2,
|
||||
STD_VIDEO_H264_POC_TYPE_INVALID = 0x7FFFFFFF,
|
||||
STD_VIDEO_H264_POC_TYPE_MAX_ENUM = 0x7FFFFFFF
|
||||
} StdVideoH264PocType;
|
||||
|
||||
typedef enum StdVideoH264AspectRatioIdc {
|
||||
STD_VIDEO_H264_ASPECT_RATIO_IDC_UNSPECIFIED = 0,
|
||||
STD_VIDEO_H264_ASPECT_RATIO_IDC_SQUARE = 1,
|
||||
STD_VIDEO_H264_ASPECT_RATIO_IDC_12_11 = 2,
|
||||
STD_VIDEO_H264_ASPECT_RATIO_IDC_10_11 = 3,
|
||||
STD_VIDEO_H264_ASPECT_RATIO_IDC_16_11 = 4,
|
||||
STD_VIDEO_H264_ASPECT_RATIO_IDC_40_33 = 5,
|
||||
STD_VIDEO_H264_ASPECT_RATIO_IDC_24_11 = 6,
|
||||
STD_VIDEO_H264_ASPECT_RATIO_IDC_20_11 = 7,
|
||||
STD_VIDEO_H264_ASPECT_RATIO_IDC_32_11 = 8,
|
||||
STD_VIDEO_H264_ASPECT_RATIO_IDC_80_33 = 9,
|
||||
STD_VIDEO_H264_ASPECT_RATIO_IDC_18_11 = 10,
|
||||
STD_VIDEO_H264_ASPECT_RATIO_IDC_15_11 = 11,
|
||||
STD_VIDEO_H264_ASPECT_RATIO_IDC_64_33 = 12,
|
||||
STD_VIDEO_H264_ASPECT_RATIO_IDC_160_99 = 13,
|
||||
STD_VIDEO_H264_ASPECT_RATIO_IDC_4_3 = 14,
|
||||
STD_VIDEO_H264_ASPECT_RATIO_IDC_3_2 = 15,
|
||||
STD_VIDEO_H264_ASPECT_RATIO_IDC_2_1 = 16,
|
||||
STD_VIDEO_H264_ASPECT_RATIO_IDC_EXTENDED_SAR = 255,
|
||||
STD_VIDEO_H264_ASPECT_RATIO_IDC_INVALID = 0x7FFFFFFF,
|
||||
STD_VIDEO_H264_ASPECT_RATIO_IDC_MAX_ENUM = 0x7FFFFFFF
|
||||
} StdVideoH264AspectRatioIdc;
|
||||
|
||||
typedef enum StdVideoH264WeightedBipredIdc {
|
||||
STD_VIDEO_H264_WEIGHTED_BIPRED_IDC_DEFAULT = 0,
|
||||
STD_VIDEO_H264_WEIGHTED_BIPRED_IDC_EXPLICIT = 1,
|
||||
STD_VIDEO_H264_WEIGHTED_BIPRED_IDC_IMPLICIT = 2,
|
||||
STD_VIDEO_H264_WEIGHTED_BIPRED_IDC_INVALID = 0x7FFFFFFF,
|
||||
STD_VIDEO_H264_WEIGHTED_BIPRED_IDC_MAX_ENUM = 0x7FFFFFFF
|
||||
} StdVideoH264WeightedBipredIdc;
|
||||
|
||||
typedef enum StdVideoH264ModificationOfPicNumsIdc {
|
||||
STD_VIDEO_H264_MODIFICATION_OF_PIC_NUMS_IDC_SHORT_TERM_SUBTRACT = 0,
|
||||
STD_VIDEO_H264_MODIFICATION_OF_PIC_NUMS_IDC_SHORT_TERM_ADD = 1,
|
||||
STD_VIDEO_H264_MODIFICATION_OF_PIC_NUMS_IDC_LONG_TERM = 2,
|
||||
STD_VIDEO_H264_MODIFICATION_OF_PIC_NUMS_IDC_END = 3,
|
||||
STD_VIDEO_H264_MODIFICATION_OF_PIC_NUMS_IDC_INVALID = 0x7FFFFFFF,
|
||||
STD_VIDEO_H264_MODIFICATION_OF_PIC_NUMS_IDC_MAX_ENUM = 0x7FFFFFFF
|
||||
} StdVideoH264ModificationOfPicNumsIdc;
|
||||
|
||||
typedef enum StdVideoH264MemMgmtControlOp {
|
||||
STD_VIDEO_H264_MEM_MGMT_CONTROL_OP_END = 0,
|
||||
STD_VIDEO_H264_MEM_MGMT_CONTROL_OP_UNMARK_SHORT_TERM = 1,
|
||||
STD_VIDEO_H264_MEM_MGMT_CONTROL_OP_UNMARK_LONG_TERM = 2,
|
||||
STD_VIDEO_H264_MEM_MGMT_CONTROL_OP_MARK_LONG_TERM = 3,
|
||||
STD_VIDEO_H264_MEM_MGMT_CONTROL_OP_SET_MAX_LONG_TERM_INDEX = 4,
|
||||
STD_VIDEO_H264_MEM_MGMT_CONTROL_OP_UNMARK_ALL = 5,
|
||||
STD_VIDEO_H264_MEM_MGMT_CONTROL_OP_MARK_CURRENT_AS_LONG_TERM = 6,
|
||||
STD_VIDEO_H264_MEM_MGMT_CONTROL_OP_INVALID = 0x7FFFFFFF,
|
||||
STD_VIDEO_H264_MEM_MGMT_CONTROL_OP_MAX_ENUM = 0x7FFFFFFF
|
||||
} StdVideoH264MemMgmtControlOp;
|
||||
|
||||
typedef enum StdVideoH264CabacInitIdc {
|
||||
STD_VIDEO_H264_CABAC_INIT_IDC_0 = 0,
|
||||
STD_VIDEO_H264_CABAC_INIT_IDC_1 = 1,
|
||||
STD_VIDEO_H264_CABAC_INIT_IDC_2 = 2,
|
||||
STD_VIDEO_H264_CABAC_INIT_IDC_INVALID = 0x7FFFFFFF,
|
||||
STD_VIDEO_H264_CABAC_INIT_IDC_MAX_ENUM = 0x7FFFFFFF
|
||||
} StdVideoH264CabacInitIdc;
|
||||
|
||||
typedef enum StdVideoH264DisableDeblockingFilterIdc {
|
||||
STD_VIDEO_H264_DISABLE_DEBLOCKING_FILTER_IDC_DISABLED = 0,
|
||||
STD_VIDEO_H264_DISABLE_DEBLOCKING_FILTER_IDC_ENABLED = 1,
|
||||
STD_VIDEO_H264_DISABLE_DEBLOCKING_FILTER_IDC_PARTIAL = 2,
|
||||
STD_VIDEO_H264_DISABLE_DEBLOCKING_FILTER_IDC_INVALID = 0x7FFFFFFF,
|
||||
STD_VIDEO_H264_DISABLE_DEBLOCKING_FILTER_IDC_MAX_ENUM = 0x7FFFFFFF
|
||||
} StdVideoH264DisableDeblockingFilterIdc;
|
||||
|
||||
typedef enum StdVideoH264SliceType {
|
||||
STD_VIDEO_H264_SLICE_TYPE_P = 0,
|
||||
STD_VIDEO_H264_SLICE_TYPE_B = 1,
|
||||
STD_VIDEO_H264_SLICE_TYPE_I = 2,
|
||||
STD_VIDEO_H264_SLICE_TYPE_INVALID = 0x7FFFFFFF,
|
||||
STD_VIDEO_H264_SLICE_TYPE_MAX_ENUM = 0x7FFFFFFF
|
||||
} StdVideoH264SliceType;
|
||||
|
||||
typedef enum StdVideoH264PictureType {
|
||||
STD_VIDEO_H264_PICTURE_TYPE_P = 0,
|
||||
STD_VIDEO_H264_PICTURE_TYPE_B = 1,
|
||||
STD_VIDEO_H264_PICTURE_TYPE_I = 2,
|
||||
STD_VIDEO_H264_PICTURE_TYPE_IDR = 5,
|
||||
STD_VIDEO_H264_PICTURE_TYPE_INVALID = 0x7FFFFFFF,
|
||||
STD_VIDEO_H264_PICTURE_TYPE_MAX_ENUM = 0x7FFFFFFF
|
||||
} StdVideoH264PictureType;
|
||||
|
||||
typedef enum StdVideoH264NonVclNaluType {
|
||||
STD_VIDEO_H264_NON_VCL_NALU_TYPE_SPS = 0,
|
||||
STD_VIDEO_H264_NON_VCL_NALU_TYPE_PPS = 1,
|
||||
STD_VIDEO_H264_NON_VCL_NALU_TYPE_AUD = 2,
|
||||
STD_VIDEO_H264_NON_VCL_NALU_TYPE_PREFIX = 3,
|
||||
STD_VIDEO_H264_NON_VCL_NALU_TYPE_END_OF_SEQUENCE = 4,
|
||||
STD_VIDEO_H264_NON_VCL_NALU_TYPE_END_OF_STREAM = 5,
|
||||
STD_VIDEO_H264_NON_VCL_NALU_TYPE_PRECODED = 6,
|
||||
STD_VIDEO_H264_NON_VCL_NALU_TYPE_INVALID = 0x7FFFFFFF,
|
||||
STD_VIDEO_H264_NON_VCL_NALU_TYPE_MAX_ENUM = 0x7FFFFFFF
|
||||
} StdVideoH264NonVclNaluType;
|
||||
typedef struct StdVideoH264SpsVuiFlags {
|
||||
uint32_t aspect_ratio_info_present_flag : 1;
|
||||
uint32_t overscan_info_present_flag : 1;
|
||||
uint32_t overscan_appropriate_flag : 1;
|
||||
uint32_t video_signal_type_present_flag : 1;
|
||||
uint32_t video_full_range_flag : 1;
|
||||
uint32_t color_description_present_flag : 1;
|
||||
uint32_t chroma_loc_info_present_flag : 1;
|
||||
uint32_t timing_info_present_flag : 1;
|
||||
uint32_t fixed_frame_rate_flag : 1;
|
||||
uint32_t bitstream_restriction_flag : 1;
|
||||
uint32_t nal_hrd_parameters_present_flag : 1;
|
||||
uint32_t vcl_hrd_parameters_present_flag : 1;
|
||||
} StdVideoH264SpsVuiFlags;
|
||||
|
||||
typedef struct StdVideoH264HrdParameters {
|
||||
uint8_t cpb_cnt_minus1;
|
||||
uint8_t bit_rate_scale;
|
||||
uint8_t cpb_size_scale;
|
||||
uint8_t reserved1;
|
||||
uint32_t bit_rate_value_minus1[STD_VIDEO_H264_CPB_CNT_LIST_SIZE];
|
||||
uint32_t cpb_size_value_minus1[STD_VIDEO_H264_CPB_CNT_LIST_SIZE];
|
||||
uint8_t cbr_flag[STD_VIDEO_H264_CPB_CNT_LIST_SIZE];
|
||||
uint32_t initial_cpb_removal_delay_length_minus1;
|
||||
uint32_t cpb_removal_delay_length_minus1;
|
||||
uint32_t dpb_output_delay_length_minus1;
|
||||
uint32_t time_offset_length;
|
||||
} StdVideoH264HrdParameters;
|
||||
|
||||
typedef struct StdVideoH264SequenceParameterSetVui {
|
||||
StdVideoH264SpsVuiFlags flags;
|
||||
StdVideoH264AspectRatioIdc aspect_ratio_idc;
|
||||
uint16_t sar_width;
|
||||
uint16_t sar_height;
|
||||
uint8_t video_format;
|
||||
uint8_t colour_primaries;
|
||||
uint8_t transfer_characteristics;
|
||||
uint8_t matrix_coefficients;
|
||||
uint32_t num_units_in_tick;
|
||||
uint32_t time_scale;
|
||||
uint8_t max_num_reorder_frames;
|
||||
uint8_t max_dec_frame_buffering;
|
||||
uint8_t chroma_sample_loc_type_top_field;
|
||||
uint8_t chroma_sample_loc_type_bottom_field;
|
||||
uint32_t reserved1;
|
||||
const StdVideoH264HrdParameters* pHrdParameters;
|
||||
} StdVideoH264SequenceParameterSetVui;
|
||||
|
||||
typedef struct StdVideoH264SpsFlags {
|
||||
uint32_t constraint_set0_flag : 1;
|
||||
uint32_t constraint_set1_flag : 1;
|
||||
uint32_t constraint_set2_flag : 1;
|
||||
uint32_t constraint_set3_flag : 1;
|
||||
uint32_t constraint_set4_flag : 1;
|
||||
uint32_t constraint_set5_flag : 1;
|
||||
uint32_t direct_8x8_inference_flag : 1;
|
||||
uint32_t mb_adaptive_frame_field_flag : 1;
|
||||
uint32_t frame_mbs_only_flag : 1;
|
||||
uint32_t delta_pic_order_always_zero_flag : 1;
|
||||
uint32_t separate_colour_plane_flag : 1;
|
||||
uint32_t gaps_in_frame_num_value_allowed_flag : 1;
|
||||
uint32_t qpprime_y_zero_transform_bypass_flag : 1;
|
||||
uint32_t frame_cropping_flag : 1;
|
||||
uint32_t seq_scaling_matrix_present_flag : 1;
|
||||
uint32_t vui_parameters_present_flag : 1;
|
||||
} StdVideoH264SpsFlags;
|
||||
|
||||
typedef struct StdVideoH264ScalingLists {
|
||||
uint16_t scaling_list_present_mask;
|
||||
uint16_t use_default_scaling_matrix_mask;
|
||||
uint8_t ScalingList4x4[STD_VIDEO_H264_SCALING_LIST_4X4_NUM_LISTS][STD_VIDEO_H264_SCALING_LIST_4X4_NUM_ELEMENTS];
|
||||
uint8_t ScalingList8x8[STD_VIDEO_H264_SCALING_LIST_8X8_NUM_LISTS][STD_VIDEO_H264_SCALING_LIST_8X8_NUM_ELEMENTS];
|
||||
} StdVideoH264ScalingLists;
|
||||
|
||||
typedef struct StdVideoH264SequenceParameterSet {
|
||||
StdVideoH264SpsFlags flags;
|
||||
StdVideoH264ProfileIdc profile_idc;
|
||||
StdVideoH264LevelIdc level_idc;
|
||||
StdVideoH264ChromaFormatIdc chroma_format_idc;
|
||||
uint8_t seq_parameter_set_id;
|
||||
uint8_t bit_depth_luma_minus8;
|
||||
uint8_t bit_depth_chroma_minus8;
|
||||
uint8_t log2_max_frame_num_minus4;
|
||||
StdVideoH264PocType pic_order_cnt_type;
|
||||
int32_t offset_for_non_ref_pic;
|
||||
int32_t offset_for_top_to_bottom_field;
|
||||
uint8_t log2_max_pic_order_cnt_lsb_minus4;
|
||||
uint8_t num_ref_frames_in_pic_order_cnt_cycle;
|
||||
uint8_t max_num_ref_frames;
|
||||
uint8_t reserved1;
|
||||
uint32_t pic_width_in_mbs_minus1;
|
||||
uint32_t pic_height_in_map_units_minus1;
|
||||
uint32_t frame_crop_left_offset;
|
||||
uint32_t frame_crop_right_offset;
|
||||
uint32_t frame_crop_top_offset;
|
||||
uint32_t frame_crop_bottom_offset;
|
||||
uint32_t reserved2;
|
||||
const int32_t* pOffsetForRefFrame;
|
||||
const StdVideoH264ScalingLists* pScalingLists;
|
||||
const StdVideoH264SequenceParameterSetVui* pSequenceParameterSetVui;
|
||||
} StdVideoH264SequenceParameterSet;
|
||||
|
||||
typedef struct StdVideoH264PpsFlags {
|
||||
uint32_t transform_8x8_mode_flag : 1;
|
||||
uint32_t redundant_pic_cnt_present_flag : 1;
|
||||
uint32_t constrained_intra_pred_flag : 1;
|
||||
uint32_t deblocking_filter_control_present_flag : 1;
|
||||
uint32_t weighted_pred_flag : 1;
|
||||
uint32_t bottom_field_pic_order_in_frame_present_flag : 1;
|
||||
uint32_t entropy_coding_mode_flag : 1;
|
||||
uint32_t pic_scaling_matrix_present_flag : 1;
|
||||
} StdVideoH264PpsFlags;
|
||||
|
||||
typedef struct StdVideoH264PictureParameterSet {
|
||||
StdVideoH264PpsFlags flags;
|
||||
uint8_t seq_parameter_set_id;
|
||||
uint8_t pic_parameter_set_id;
|
||||
uint8_t num_ref_idx_l0_default_active_minus1;
|
||||
uint8_t num_ref_idx_l1_default_active_minus1;
|
||||
StdVideoH264WeightedBipredIdc weighted_bipred_idc;
|
||||
int8_t pic_init_qp_minus26;
|
||||
int8_t pic_init_qs_minus26;
|
||||
int8_t chroma_qp_index_offset;
|
||||
int8_t second_chroma_qp_index_offset;
|
||||
const StdVideoH264ScalingLists* pScalingLists;
|
||||
} StdVideoH264PictureParameterSet;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
77
third-party/glad/glad/files/vulkan_video_codec_h264std_decode.h
vendored
Normal file
77
third-party/glad/glad/files/vulkan_video_codec_h264std_decode.h
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
#ifndef VULKAN_VIDEO_CODEC_H264STD_DECODE_H_
|
||||
#define VULKAN_VIDEO_CODEC_H264STD_DECODE_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright 2015-2024 The Khronos Group Inc.
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is generated from the Khronos Vulkan XML API Registry.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// vulkan_video_codec_h264std_decode is a preprocessor guard. Do not pass it to API calls.
|
||||
#define vulkan_video_codec_h264std_decode 1
|
||||
#include "vulkan_video_codec_h264std.h"
|
||||
|
||||
#define VK_STD_VULKAN_VIDEO_CODEC_H264_DECODE_API_VERSION_1_0_0 VK_MAKE_VIDEO_STD_VERSION(1, 0, 0)
|
||||
|
||||
#define VK_STD_VULKAN_VIDEO_CODEC_H264_DECODE_SPEC_VERSION VK_STD_VULKAN_VIDEO_CODEC_H264_DECODE_API_VERSION_1_0_0
|
||||
#define VK_STD_VULKAN_VIDEO_CODEC_H264_DECODE_EXTENSION_NAME "VK_STD_vulkan_video_codec_h264_decode"
|
||||
#define STD_VIDEO_DECODE_H264_FIELD_ORDER_COUNT_LIST_SIZE 2
|
||||
|
||||
typedef enum StdVideoDecodeH264FieldOrderCount {
|
||||
STD_VIDEO_DECODE_H264_FIELD_ORDER_COUNT_TOP = 0,
|
||||
STD_VIDEO_DECODE_H264_FIELD_ORDER_COUNT_BOTTOM = 1,
|
||||
STD_VIDEO_DECODE_H264_FIELD_ORDER_COUNT_INVALID = 0x7FFFFFFF,
|
||||
STD_VIDEO_DECODE_H264_FIELD_ORDER_COUNT_MAX_ENUM = 0x7FFFFFFF
|
||||
} StdVideoDecodeH264FieldOrderCount;
|
||||
typedef struct StdVideoDecodeH264PictureInfoFlags {
|
||||
uint32_t field_pic_flag : 1;
|
||||
uint32_t is_intra : 1;
|
||||
uint32_t IdrPicFlag : 1;
|
||||
uint32_t bottom_field_flag : 1;
|
||||
uint32_t is_reference : 1;
|
||||
uint32_t complementary_field_pair : 1;
|
||||
} StdVideoDecodeH264PictureInfoFlags;
|
||||
|
||||
typedef struct StdVideoDecodeH264PictureInfo {
|
||||
StdVideoDecodeH264PictureInfoFlags flags;
|
||||
uint8_t seq_parameter_set_id;
|
||||
uint8_t pic_parameter_set_id;
|
||||
uint8_t reserved1;
|
||||
uint8_t reserved2;
|
||||
uint16_t frame_num;
|
||||
uint16_t idr_pic_id;
|
||||
int32_t PicOrderCnt[STD_VIDEO_DECODE_H264_FIELD_ORDER_COUNT_LIST_SIZE];
|
||||
} StdVideoDecodeH264PictureInfo;
|
||||
|
||||
typedef struct StdVideoDecodeH264ReferenceInfoFlags {
|
||||
uint32_t top_field_flag : 1;
|
||||
uint32_t bottom_field_flag : 1;
|
||||
uint32_t used_for_long_term_reference : 1;
|
||||
uint32_t is_non_existing : 1;
|
||||
} StdVideoDecodeH264ReferenceInfoFlags;
|
||||
|
||||
typedef struct StdVideoDecodeH264ReferenceInfo {
|
||||
StdVideoDecodeH264ReferenceInfoFlags flags;
|
||||
uint16_t FrameNum;
|
||||
uint16_t reserved;
|
||||
int32_t PicOrderCnt[STD_VIDEO_DECODE_H264_FIELD_ORDER_COUNT_LIST_SIZE];
|
||||
} StdVideoDecodeH264ReferenceInfo;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
147
third-party/glad/glad/files/vulkan_video_codec_h264std_encode.h
vendored
Normal file
147
third-party/glad/glad/files/vulkan_video_codec_h264std_encode.h
vendored
Normal file
@@ -0,0 +1,147 @@
|
||||
#ifndef VULKAN_VIDEO_CODEC_H264STD_ENCODE_H_
|
||||
#define VULKAN_VIDEO_CODEC_H264STD_ENCODE_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright 2015-2024 The Khronos Group Inc.
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is generated from the Khronos Vulkan XML API Registry.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// vulkan_video_codec_h264std_encode is a preprocessor guard. Do not pass it to API calls.
|
||||
#define vulkan_video_codec_h264std_encode 1
|
||||
#include "vulkan_video_codec_h264std.h"
|
||||
|
||||
#define VK_STD_VULKAN_VIDEO_CODEC_H264_ENCODE_API_VERSION_1_0_0 VK_MAKE_VIDEO_STD_VERSION(1, 0, 0)
|
||||
|
||||
#define VK_STD_VULKAN_VIDEO_CODEC_H264_ENCODE_SPEC_VERSION VK_STD_VULKAN_VIDEO_CODEC_H264_ENCODE_API_VERSION_1_0_0
|
||||
#define VK_STD_VULKAN_VIDEO_CODEC_H264_ENCODE_EXTENSION_NAME "VK_STD_vulkan_video_codec_h264_encode"
|
||||
typedef struct StdVideoEncodeH264WeightTableFlags {
|
||||
uint32_t luma_weight_l0_flag;
|
||||
uint32_t chroma_weight_l0_flag;
|
||||
uint32_t luma_weight_l1_flag;
|
||||
uint32_t chroma_weight_l1_flag;
|
||||
} StdVideoEncodeH264WeightTableFlags;
|
||||
|
||||
typedef struct StdVideoEncodeH264WeightTable {
|
||||
StdVideoEncodeH264WeightTableFlags flags;
|
||||
uint8_t luma_log2_weight_denom;
|
||||
uint8_t chroma_log2_weight_denom;
|
||||
int8_t luma_weight_l0[STD_VIDEO_H264_MAX_NUM_LIST_REF];
|
||||
int8_t luma_offset_l0[STD_VIDEO_H264_MAX_NUM_LIST_REF];
|
||||
int8_t chroma_weight_l0[STD_VIDEO_H264_MAX_NUM_LIST_REF][STD_VIDEO_H264_MAX_CHROMA_PLANES];
|
||||
int8_t chroma_offset_l0[STD_VIDEO_H264_MAX_NUM_LIST_REF][STD_VIDEO_H264_MAX_CHROMA_PLANES];
|
||||
int8_t luma_weight_l1[STD_VIDEO_H264_MAX_NUM_LIST_REF];
|
||||
int8_t luma_offset_l1[STD_VIDEO_H264_MAX_NUM_LIST_REF];
|
||||
int8_t chroma_weight_l1[STD_VIDEO_H264_MAX_NUM_LIST_REF][STD_VIDEO_H264_MAX_CHROMA_PLANES];
|
||||
int8_t chroma_offset_l1[STD_VIDEO_H264_MAX_NUM_LIST_REF][STD_VIDEO_H264_MAX_CHROMA_PLANES];
|
||||
} StdVideoEncodeH264WeightTable;
|
||||
|
||||
typedef struct StdVideoEncodeH264SliceHeaderFlags {
|
||||
uint32_t direct_spatial_mv_pred_flag : 1;
|
||||
uint32_t num_ref_idx_active_override_flag : 1;
|
||||
uint32_t reserved : 30;
|
||||
} StdVideoEncodeH264SliceHeaderFlags;
|
||||
|
||||
typedef struct StdVideoEncodeH264PictureInfoFlags {
|
||||
uint32_t IdrPicFlag : 1;
|
||||
uint32_t is_reference : 1;
|
||||
uint32_t no_output_of_prior_pics_flag : 1;
|
||||
uint32_t long_term_reference_flag : 1;
|
||||
uint32_t adaptive_ref_pic_marking_mode_flag : 1;
|
||||
uint32_t reserved : 27;
|
||||
} StdVideoEncodeH264PictureInfoFlags;
|
||||
|
||||
typedef struct StdVideoEncodeH264ReferenceInfoFlags {
|
||||
uint32_t used_for_long_term_reference : 1;
|
||||
uint32_t reserved : 31;
|
||||
} StdVideoEncodeH264ReferenceInfoFlags;
|
||||
|
||||
typedef struct StdVideoEncodeH264ReferenceListsInfoFlags {
|
||||
uint32_t ref_pic_list_modification_flag_l0 : 1;
|
||||
uint32_t ref_pic_list_modification_flag_l1 : 1;
|
||||
uint32_t reserved : 30;
|
||||
} StdVideoEncodeH264ReferenceListsInfoFlags;
|
||||
|
||||
typedef struct StdVideoEncodeH264RefListModEntry {
|
||||
StdVideoH264ModificationOfPicNumsIdc modification_of_pic_nums_idc;
|
||||
uint16_t abs_diff_pic_num_minus1;
|
||||
uint16_t long_term_pic_num;
|
||||
} StdVideoEncodeH264RefListModEntry;
|
||||
|
||||
typedef struct StdVideoEncodeH264RefPicMarkingEntry {
|
||||
StdVideoH264MemMgmtControlOp memory_management_control_operation;
|
||||
uint16_t difference_of_pic_nums_minus1;
|
||||
uint16_t long_term_pic_num;
|
||||
uint16_t long_term_frame_idx;
|
||||
uint16_t max_long_term_frame_idx_plus1;
|
||||
} StdVideoEncodeH264RefPicMarkingEntry;
|
||||
|
||||
typedef struct StdVideoEncodeH264ReferenceListsInfo {
|
||||
StdVideoEncodeH264ReferenceListsInfoFlags flags;
|
||||
uint8_t num_ref_idx_l0_active_minus1;
|
||||
uint8_t num_ref_idx_l1_active_minus1;
|
||||
uint8_t RefPicList0[STD_VIDEO_H264_MAX_NUM_LIST_REF];
|
||||
uint8_t RefPicList1[STD_VIDEO_H264_MAX_NUM_LIST_REF];
|
||||
uint8_t refList0ModOpCount;
|
||||
uint8_t refList1ModOpCount;
|
||||
uint8_t refPicMarkingOpCount;
|
||||
uint8_t reserved1[7];
|
||||
const StdVideoEncodeH264RefListModEntry* pRefList0ModOperations;
|
||||
const StdVideoEncodeH264RefListModEntry* pRefList1ModOperations;
|
||||
const StdVideoEncodeH264RefPicMarkingEntry* pRefPicMarkingOperations;
|
||||
} StdVideoEncodeH264ReferenceListsInfo;
|
||||
|
||||
typedef struct StdVideoEncodeH264PictureInfo {
|
||||
StdVideoEncodeH264PictureInfoFlags flags;
|
||||
uint8_t seq_parameter_set_id;
|
||||
uint8_t pic_parameter_set_id;
|
||||
uint16_t idr_pic_id;
|
||||
StdVideoH264PictureType primary_pic_type;
|
||||
uint32_t frame_num;
|
||||
int32_t PicOrderCnt;
|
||||
uint8_t temporal_id;
|
||||
uint8_t reserved1[3];
|
||||
const StdVideoEncodeH264ReferenceListsInfo* pRefLists;
|
||||
} StdVideoEncodeH264PictureInfo;
|
||||
|
||||
typedef struct StdVideoEncodeH264ReferenceInfo {
|
||||
StdVideoEncodeH264ReferenceInfoFlags flags;
|
||||
StdVideoH264PictureType primary_pic_type;
|
||||
uint32_t FrameNum;
|
||||
int32_t PicOrderCnt;
|
||||
uint16_t long_term_pic_num;
|
||||
uint16_t long_term_frame_idx;
|
||||
uint8_t temporal_id;
|
||||
} StdVideoEncodeH264ReferenceInfo;
|
||||
|
||||
typedef struct StdVideoEncodeH264SliceHeader {
|
||||
StdVideoEncodeH264SliceHeaderFlags flags;
|
||||
uint32_t first_mb_in_slice;
|
||||
StdVideoH264SliceType slice_type;
|
||||
int8_t slice_alpha_c0_offset_div2;
|
||||
int8_t slice_beta_offset_div2;
|
||||
int8_t slice_qp_delta;
|
||||
uint8_t reserved1;
|
||||
StdVideoH264CabacInitIdc cabac_init_idc;
|
||||
StdVideoH264DisableDeblockingFilterIdc disable_deblocking_filter_idc;
|
||||
const StdVideoEncodeH264WeightTable* pWeightTable;
|
||||
} StdVideoEncodeH264SliceHeader;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
446
third-party/glad/glad/files/vulkan_video_codec_h265std.h
vendored
Normal file
446
third-party/glad/glad/files/vulkan_video_codec_h265std.h
vendored
Normal file
@@ -0,0 +1,446 @@
|
||||
#ifndef VULKAN_VIDEO_CODEC_H265STD_H_
|
||||
#define VULKAN_VIDEO_CODEC_H265STD_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright 2015-2024 The Khronos Group Inc.
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is generated from the Khronos Vulkan XML API Registry.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// vulkan_video_codec_h265std is a preprocessor guard. Do not pass it to API calls.
|
||||
#define vulkan_video_codec_h265std 1
|
||||
#include "vulkan_video_codecs_common.h"
|
||||
#define STD_VIDEO_H265_CPB_CNT_LIST_SIZE 32
|
||||
#define STD_VIDEO_H265_SUBLAYERS_LIST_SIZE 7
|
||||
#define STD_VIDEO_H265_SCALING_LIST_4X4_NUM_LISTS 6
|
||||
#define STD_VIDEO_H265_SCALING_LIST_4X4_NUM_ELEMENTS 16
|
||||
#define STD_VIDEO_H265_SCALING_LIST_8X8_NUM_LISTS 6
|
||||
#define STD_VIDEO_H265_SCALING_LIST_8X8_NUM_ELEMENTS 64
|
||||
#define STD_VIDEO_H265_SCALING_LIST_16X16_NUM_LISTS 6
|
||||
#define STD_VIDEO_H265_SCALING_LIST_16X16_NUM_ELEMENTS 64
|
||||
#define STD_VIDEO_H265_SCALING_LIST_32X32_NUM_LISTS 2
|
||||
#define STD_VIDEO_H265_SCALING_LIST_32X32_NUM_ELEMENTS 64
|
||||
#define STD_VIDEO_H265_CHROMA_QP_OFFSET_LIST_SIZE 6
|
||||
#define STD_VIDEO_H265_CHROMA_QP_OFFSET_TILE_COLS_LIST_SIZE 19
|
||||
#define STD_VIDEO_H265_CHROMA_QP_OFFSET_TILE_ROWS_LIST_SIZE 21
|
||||
#define STD_VIDEO_H265_PREDICTOR_PALETTE_COMPONENTS_LIST_SIZE 3
|
||||
#define STD_VIDEO_H265_PREDICTOR_PALETTE_COMP_ENTRIES_LIST_SIZE 128
|
||||
#define STD_VIDEO_H265_MAX_NUM_LIST_REF 15
|
||||
#define STD_VIDEO_H265_MAX_CHROMA_PLANES 2
|
||||
#define STD_VIDEO_H265_MAX_SHORT_TERM_REF_PIC_SETS 64
|
||||
#define STD_VIDEO_H265_MAX_DPB_SIZE 16
|
||||
#define STD_VIDEO_H265_MAX_LONG_TERM_REF_PICS_SPS 32
|
||||
#define STD_VIDEO_H265_MAX_LONG_TERM_PICS 16
|
||||
#define STD_VIDEO_H265_MAX_DELTA_POC 48
|
||||
#define STD_VIDEO_H265_NO_REFERENCE_PICTURE 0xFF
|
||||
|
||||
typedef enum StdVideoH265ChromaFormatIdc {
|
||||
STD_VIDEO_H265_CHROMA_FORMAT_IDC_MONOCHROME = 0,
|
||||
STD_VIDEO_H265_CHROMA_FORMAT_IDC_420 = 1,
|
||||
STD_VIDEO_H265_CHROMA_FORMAT_IDC_422 = 2,
|
||||
STD_VIDEO_H265_CHROMA_FORMAT_IDC_444 = 3,
|
||||
STD_VIDEO_H265_CHROMA_FORMAT_IDC_INVALID = 0x7FFFFFFF,
|
||||
STD_VIDEO_H265_CHROMA_FORMAT_IDC_MAX_ENUM = 0x7FFFFFFF
|
||||
} StdVideoH265ChromaFormatIdc;
|
||||
|
||||
typedef enum StdVideoH265ProfileIdc {
|
||||
STD_VIDEO_H265_PROFILE_IDC_MAIN = 1,
|
||||
STD_VIDEO_H265_PROFILE_IDC_MAIN_10 = 2,
|
||||
STD_VIDEO_H265_PROFILE_IDC_MAIN_STILL_PICTURE = 3,
|
||||
STD_VIDEO_H265_PROFILE_IDC_FORMAT_RANGE_EXTENSIONS = 4,
|
||||
STD_VIDEO_H265_PROFILE_IDC_SCC_EXTENSIONS = 9,
|
||||
STD_VIDEO_H265_PROFILE_IDC_INVALID = 0x7FFFFFFF,
|
||||
STD_VIDEO_H265_PROFILE_IDC_MAX_ENUM = 0x7FFFFFFF
|
||||
} StdVideoH265ProfileIdc;
|
||||
|
||||
typedef enum StdVideoH265LevelIdc {
|
||||
STD_VIDEO_H265_LEVEL_IDC_1_0 = 0,
|
||||
STD_VIDEO_H265_LEVEL_IDC_2_0 = 1,
|
||||
STD_VIDEO_H265_LEVEL_IDC_2_1 = 2,
|
||||
STD_VIDEO_H265_LEVEL_IDC_3_0 = 3,
|
||||
STD_VIDEO_H265_LEVEL_IDC_3_1 = 4,
|
||||
STD_VIDEO_H265_LEVEL_IDC_4_0 = 5,
|
||||
STD_VIDEO_H265_LEVEL_IDC_4_1 = 6,
|
||||
STD_VIDEO_H265_LEVEL_IDC_5_0 = 7,
|
||||
STD_VIDEO_H265_LEVEL_IDC_5_1 = 8,
|
||||
STD_VIDEO_H265_LEVEL_IDC_5_2 = 9,
|
||||
STD_VIDEO_H265_LEVEL_IDC_6_0 = 10,
|
||||
STD_VIDEO_H265_LEVEL_IDC_6_1 = 11,
|
||||
STD_VIDEO_H265_LEVEL_IDC_6_2 = 12,
|
||||
STD_VIDEO_H265_LEVEL_IDC_INVALID = 0x7FFFFFFF,
|
||||
STD_VIDEO_H265_LEVEL_IDC_MAX_ENUM = 0x7FFFFFFF
|
||||
} StdVideoH265LevelIdc;
|
||||
|
||||
typedef enum StdVideoH265SliceType {
|
||||
STD_VIDEO_H265_SLICE_TYPE_B = 0,
|
||||
STD_VIDEO_H265_SLICE_TYPE_P = 1,
|
||||
STD_VIDEO_H265_SLICE_TYPE_I = 2,
|
||||
STD_VIDEO_H265_SLICE_TYPE_INVALID = 0x7FFFFFFF,
|
||||
STD_VIDEO_H265_SLICE_TYPE_MAX_ENUM = 0x7FFFFFFF
|
||||
} StdVideoH265SliceType;
|
||||
|
||||
typedef enum StdVideoH265PictureType {
|
||||
STD_VIDEO_H265_PICTURE_TYPE_P = 0,
|
||||
STD_VIDEO_H265_PICTURE_TYPE_B = 1,
|
||||
STD_VIDEO_H265_PICTURE_TYPE_I = 2,
|
||||
STD_VIDEO_H265_PICTURE_TYPE_IDR = 3,
|
||||
STD_VIDEO_H265_PICTURE_TYPE_INVALID = 0x7FFFFFFF,
|
||||
STD_VIDEO_H265_PICTURE_TYPE_MAX_ENUM = 0x7FFFFFFF
|
||||
} StdVideoH265PictureType;
|
||||
|
||||
typedef enum StdVideoH265AspectRatioIdc {
|
||||
STD_VIDEO_H265_ASPECT_RATIO_IDC_UNSPECIFIED = 0,
|
||||
STD_VIDEO_H265_ASPECT_RATIO_IDC_SQUARE = 1,
|
||||
STD_VIDEO_H265_ASPECT_RATIO_IDC_12_11 = 2,
|
||||
STD_VIDEO_H265_ASPECT_RATIO_IDC_10_11 = 3,
|
||||
STD_VIDEO_H265_ASPECT_RATIO_IDC_16_11 = 4,
|
||||
STD_VIDEO_H265_ASPECT_RATIO_IDC_40_33 = 5,
|
||||
STD_VIDEO_H265_ASPECT_RATIO_IDC_24_11 = 6,
|
||||
STD_VIDEO_H265_ASPECT_RATIO_IDC_20_11 = 7,
|
||||
STD_VIDEO_H265_ASPECT_RATIO_IDC_32_11 = 8,
|
||||
STD_VIDEO_H265_ASPECT_RATIO_IDC_80_33 = 9,
|
||||
STD_VIDEO_H265_ASPECT_RATIO_IDC_18_11 = 10,
|
||||
STD_VIDEO_H265_ASPECT_RATIO_IDC_15_11 = 11,
|
||||
STD_VIDEO_H265_ASPECT_RATIO_IDC_64_33 = 12,
|
||||
STD_VIDEO_H265_ASPECT_RATIO_IDC_160_99 = 13,
|
||||
STD_VIDEO_H265_ASPECT_RATIO_IDC_4_3 = 14,
|
||||
STD_VIDEO_H265_ASPECT_RATIO_IDC_3_2 = 15,
|
||||
STD_VIDEO_H265_ASPECT_RATIO_IDC_2_1 = 16,
|
||||
STD_VIDEO_H265_ASPECT_RATIO_IDC_EXTENDED_SAR = 255,
|
||||
STD_VIDEO_H265_ASPECT_RATIO_IDC_INVALID = 0x7FFFFFFF,
|
||||
STD_VIDEO_H265_ASPECT_RATIO_IDC_MAX_ENUM = 0x7FFFFFFF
|
||||
} StdVideoH265AspectRatioIdc;
|
||||
typedef struct StdVideoH265DecPicBufMgr {
|
||||
uint32_t max_latency_increase_plus1[STD_VIDEO_H265_SUBLAYERS_LIST_SIZE];
|
||||
uint8_t max_dec_pic_buffering_minus1[STD_VIDEO_H265_SUBLAYERS_LIST_SIZE];
|
||||
uint8_t max_num_reorder_pics[STD_VIDEO_H265_SUBLAYERS_LIST_SIZE];
|
||||
} StdVideoH265DecPicBufMgr;
|
||||
|
||||
typedef struct StdVideoH265SubLayerHrdParameters {
|
||||
uint32_t bit_rate_value_minus1[STD_VIDEO_H265_CPB_CNT_LIST_SIZE];
|
||||
uint32_t cpb_size_value_minus1[STD_VIDEO_H265_CPB_CNT_LIST_SIZE];
|
||||
uint32_t cpb_size_du_value_minus1[STD_VIDEO_H265_CPB_CNT_LIST_SIZE];
|
||||
uint32_t bit_rate_du_value_minus1[STD_VIDEO_H265_CPB_CNT_LIST_SIZE];
|
||||
uint32_t cbr_flag;
|
||||
} StdVideoH265SubLayerHrdParameters;
|
||||
|
||||
typedef struct StdVideoH265HrdFlags {
|
||||
uint32_t nal_hrd_parameters_present_flag : 1;
|
||||
uint32_t vcl_hrd_parameters_present_flag : 1;
|
||||
uint32_t sub_pic_hrd_params_present_flag : 1;
|
||||
uint32_t sub_pic_cpb_params_in_pic_timing_sei_flag : 1;
|
||||
uint32_t fixed_pic_rate_general_flag : 8;
|
||||
uint32_t fixed_pic_rate_within_cvs_flag : 8;
|
||||
uint32_t low_delay_hrd_flag : 8;
|
||||
} StdVideoH265HrdFlags;
|
||||
|
||||
typedef struct StdVideoH265HrdParameters {
|
||||
StdVideoH265HrdFlags flags;
|
||||
uint8_t tick_divisor_minus2;
|
||||
uint8_t du_cpb_removal_delay_increment_length_minus1;
|
||||
uint8_t dpb_output_delay_du_length_minus1;
|
||||
uint8_t bit_rate_scale;
|
||||
uint8_t cpb_size_scale;
|
||||
uint8_t cpb_size_du_scale;
|
||||
uint8_t initial_cpb_removal_delay_length_minus1;
|
||||
uint8_t au_cpb_removal_delay_length_minus1;
|
||||
uint8_t dpb_output_delay_length_minus1;
|
||||
uint8_t cpb_cnt_minus1[STD_VIDEO_H265_SUBLAYERS_LIST_SIZE];
|
||||
uint16_t elemental_duration_in_tc_minus1[STD_VIDEO_H265_SUBLAYERS_LIST_SIZE];
|
||||
uint16_t reserved[3];
|
||||
const StdVideoH265SubLayerHrdParameters* pSubLayerHrdParametersNal;
|
||||
const StdVideoH265SubLayerHrdParameters* pSubLayerHrdParametersVcl;
|
||||
} StdVideoH265HrdParameters;
|
||||
|
||||
typedef struct StdVideoH265VpsFlags {
|
||||
uint32_t vps_temporal_id_nesting_flag : 1;
|
||||
uint32_t vps_sub_layer_ordering_info_present_flag : 1;
|
||||
uint32_t vps_timing_info_present_flag : 1;
|
||||
uint32_t vps_poc_proportional_to_timing_flag : 1;
|
||||
} StdVideoH265VpsFlags;
|
||||
|
||||
typedef struct StdVideoH265ProfileTierLevelFlags {
|
||||
uint32_t general_tier_flag : 1;
|
||||
uint32_t general_progressive_source_flag : 1;
|
||||
uint32_t general_interlaced_source_flag : 1;
|
||||
uint32_t general_non_packed_constraint_flag : 1;
|
||||
uint32_t general_frame_only_constraint_flag : 1;
|
||||
} StdVideoH265ProfileTierLevelFlags;
|
||||
|
||||
typedef struct StdVideoH265ProfileTierLevel {
|
||||
StdVideoH265ProfileTierLevelFlags flags;
|
||||
StdVideoH265ProfileIdc general_profile_idc;
|
||||
StdVideoH265LevelIdc general_level_idc;
|
||||
} StdVideoH265ProfileTierLevel;
|
||||
|
||||
typedef struct StdVideoH265VideoParameterSet {
|
||||
StdVideoH265VpsFlags flags;
|
||||
uint8_t vps_video_parameter_set_id;
|
||||
uint8_t vps_max_sub_layers_minus1;
|
||||
uint8_t reserved1;
|
||||
uint8_t reserved2;
|
||||
uint32_t vps_num_units_in_tick;
|
||||
uint32_t vps_time_scale;
|
||||
uint32_t vps_num_ticks_poc_diff_one_minus1;
|
||||
uint32_t reserved3;
|
||||
const StdVideoH265DecPicBufMgr* pDecPicBufMgr;
|
||||
const StdVideoH265HrdParameters* pHrdParameters;
|
||||
const StdVideoH265ProfileTierLevel* pProfileTierLevel;
|
||||
} StdVideoH265VideoParameterSet;
|
||||
|
||||
typedef struct StdVideoH265ScalingLists {
|
||||
uint8_t ScalingList4x4[STD_VIDEO_H265_SCALING_LIST_4X4_NUM_LISTS][STD_VIDEO_H265_SCALING_LIST_4X4_NUM_ELEMENTS];
|
||||
uint8_t ScalingList8x8[STD_VIDEO_H265_SCALING_LIST_8X8_NUM_LISTS][STD_VIDEO_H265_SCALING_LIST_8X8_NUM_ELEMENTS];
|
||||
uint8_t ScalingList16x16[STD_VIDEO_H265_SCALING_LIST_16X16_NUM_LISTS][STD_VIDEO_H265_SCALING_LIST_16X16_NUM_ELEMENTS];
|
||||
uint8_t ScalingList32x32[STD_VIDEO_H265_SCALING_LIST_32X32_NUM_LISTS][STD_VIDEO_H265_SCALING_LIST_32X32_NUM_ELEMENTS];
|
||||
uint8_t ScalingListDCCoef16x16[STD_VIDEO_H265_SCALING_LIST_16X16_NUM_LISTS];
|
||||
uint8_t ScalingListDCCoef32x32[STD_VIDEO_H265_SCALING_LIST_32X32_NUM_LISTS];
|
||||
} StdVideoH265ScalingLists;
|
||||
|
||||
typedef struct StdVideoH265SpsVuiFlags {
|
||||
uint32_t aspect_ratio_info_present_flag : 1;
|
||||
uint32_t overscan_info_present_flag : 1;
|
||||
uint32_t overscan_appropriate_flag : 1;
|
||||
uint32_t video_signal_type_present_flag : 1;
|
||||
uint32_t video_full_range_flag : 1;
|
||||
uint32_t colour_description_present_flag : 1;
|
||||
uint32_t chroma_loc_info_present_flag : 1;
|
||||
uint32_t neutral_chroma_indication_flag : 1;
|
||||
uint32_t field_seq_flag : 1;
|
||||
uint32_t frame_field_info_present_flag : 1;
|
||||
uint32_t default_display_window_flag : 1;
|
||||
uint32_t vui_timing_info_present_flag : 1;
|
||||
uint32_t vui_poc_proportional_to_timing_flag : 1;
|
||||
uint32_t vui_hrd_parameters_present_flag : 1;
|
||||
uint32_t bitstream_restriction_flag : 1;
|
||||
uint32_t tiles_fixed_structure_flag : 1;
|
||||
uint32_t motion_vectors_over_pic_boundaries_flag : 1;
|
||||
uint32_t restricted_ref_pic_lists_flag : 1;
|
||||
} StdVideoH265SpsVuiFlags;
|
||||
|
||||
typedef struct StdVideoH265SequenceParameterSetVui {
|
||||
StdVideoH265SpsVuiFlags flags;
|
||||
StdVideoH265AspectRatioIdc aspect_ratio_idc;
|
||||
uint16_t sar_width;
|
||||
uint16_t sar_height;
|
||||
uint8_t video_format;
|
||||
uint8_t colour_primaries;
|
||||
uint8_t transfer_characteristics;
|
||||
uint8_t matrix_coeffs;
|
||||
uint8_t chroma_sample_loc_type_top_field;
|
||||
uint8_t chroma_sample_loc_type_bottom_field;
|
||||
uint8_t reserved1;
|
||||
uint8_t reserved2;
|
||||
uint16_t def_disp_win_left_offset;
|
||||
uint16_t def_disp_win_right_offset;
|
||||
uint16_t def_disp_win_top_offset;
|
||||
uint16_t def_disp_win_bottom_offset;
|
||||
uint32_t vui_num_units_in_tick;
|
||||
uint32_t vui_time_scale;
|
||||
uint32_t vui_num_ticks_poc_diff_one_minus1;
|
||||
uint16_t min_spatial_segmentation_idc;
|
||||
uint16_t reserved3;
|
||||
uint8_t max_bytes_per_pic_denom;
|
||||
uint8_t max_bits_per_min_cu_denom;
|
||||
uint8_t log2_max_mv_length_horizontal;
|
||||
uint8_t log2_max_mv_length_vertical;
|
||||
const StdVideoH265HrdParameters* pHrdParameters;
|
||||
} StdVideoH265SequenceParameterSetVui;
|
||||
|
||||
typedef struct StdVideoH265PredictorPaletteEntries {
|
||||
uint16_t PredictorPaletteEntries[STD_VIDEO_H265_PREDICTOR_PALETTE_COMPONENTS_LIST_SIZE][STD_VIDEO_H265_PREDICTOR_PALETTE_COMP_ENTRIES_LIST_SIZE];
|
||||
} StdVideoH265PredictorPaletteEntries;
|
||||
|
||||
typedef struct StdVideoH265SpsFlags {
|
||||
uint32_t sps_temporal_id_nesting_flag : 1;
|
||||
uint32_t separate_colour_plane_flag : 1;
|
||||
uint32_t conformance_window_flag : 1;
|
||||
uint32_t sps_sub_layer_ordering_info_present_flag : 1;
|
||||
uint32_t scaling_list_enabled_flag : 1;
|
||||
uint32_t sps_scaling_list_data_present_flag : 1;
|
||||
uint32_t amp_enabled_flag : 1;
|
||||
uint32_t sample_adaptive_offset_enabled_flag : 1;
|
||||
uint32_t pcm_enabled_flag : 1;
|
||||
uint32_t pcm_loop_filter_disabled_flag : 1;
|
||||
uint32_t long_term_ref_pics_present_flag : 1;
|
||||
uint32_t sps_temporal_mvp_enabled_flag : 1;
|
||||
uint32_t strong_intra_smoothing_enabled_flag : 1;
|
||||
uint32_t vui_parameters_present_flag : 1;
|
||||
uint32_t sps_extension_present_flag : 1;
|
||||
uint32_t sps_range_extension_flag : 1;
|
||||
uint32_t transform_skip_rotation_enabled_flag : 1;
|
||||
uint32_t transform_skip_context_enabled_flag : 1;
|
||||
uint32_t implicit_rdpcm_enabled_flag : 1;
|
||||
uint32_t explicit_rdpcm_enabled_flag : 1;
|
||||
uint32_t extended_precision_processing_flag : 1;
|
||||
uint32_t intra_smoothing_disabled_flag : 1;
|
||||
uint32_t high_precision_offsets_enabled_flag : 1;
|
||||
uint32_t persistent_rice_adaptation_enabled_flag : 1;
|
||||
uint32_t cabac_bypass_alignment_enabled_flag : 1;
|
||||
uint32_t sps_scc_extension_flag : 1;
|
||||
uint32_t sps_curr_pic_ref_enabled_flag : 1;
|
||||
uint32_t palette_mode_enabled_flag : 1;
|
||||
uint32_t sps_palette_predictor_initializers_present_flag : 1;
|
||||
uint32_t intra_boundary_filtering_disabled_flag : 1;
|
||||
} StdVideoH265SpsFlags;
|
||||
|
||||
typedef struct StdVideoH265ShortTermRefPicSetFlags {
|
||||
uint32_t inter_ref_pic_set_prediction_flag : 1;
|
||||
uint32_t delta_rps_sign : 1;
|
||||
} StdVideoH265ShortTermRefPicSetFlags;
|
||||
|
||||
typedef struct StdVideoH265ShortTermRefPicSet {
|
||||
StdVideoH265ShortTermRefPicSetFlags flags;
|
||||
uint32_t delta_idx_minus1;
|
||||
uint16_t use_delta_flag;
|
||||
uint16_t abs_delta_rps_minus1;
|
||||
uint16_t used_by_curr_pic_flag;
|
||||
uint16_t used_by_curr_pic_s0_flag;
|
||||
uint16_t used_by_curr_pic_s1_flag;
|
||||
uint16_t reserved1;
|
||||
uint8_t reserved2;
|
||||
uint8_t reserved3;
|
||||
uint8_t num_negative_pics;
|
||||
uint8_t num_positive_pics;
|
||||
uint16_t delta_poc_s0_minus1[STD_VIDEO_H265_MAX_DPB_SIZE];
|
||||
uint16_t delta_poc_s1_minus1[STD_VIDEO_H265_MAX_DPB_SIZE];
|
||||
} StdVideoH265ShortTermRefPicSet;
|
||||
|
||||
typedef struct StdVideoH265LongTermRefPicsSps {
|
||||
uint32_t used_by_curr_pic_lt_sps_flag;
|
||||
uint32_t lt_ref_pic_poc_lsb_sps[STD_VIDEO_H265_MAX_LONG_TERM_REF_PICS_SPS];
|
||||
} StdVideoH265LongTermRefPicsSps;
|
||||
|
||||
typedef struct StdVideoH265SequenceParameterSet {
|
||||
StdVideoH265SpsFlags flags;
|
||||
StdVideoH265ChromaFormatIdc chroma_format_idc;
|
||||
uint32_t pic_width_in_luma_samples;
|
||||
uint32_t pic_height_in_luma_samples;
|
||||
uint8_t sps_video_parameter_set_id;
|
||||
uint8_t sps_max_sub_layers_minus1;
|
||||
uint8_t sps_seq_parameter_set_id;
|
||||
uint8_t bit_depth_luma_minus8;
|
||||
uint8_t bit_depth_chroma_minus8;
|
||||
uint8_t log2_max_pic_order_cnt_lsb_minus4;
|
||||
uint8_t log2_min_luma_coding_block_size_minus3;
|
||||
uint8_t log2_diff_max_min_luma_coding_block_size;
|
||||
uint8_t log2_min_luma_transform_block_size_minus2;
|
||||
uint8_t log2_diff_max_min_luma_transform_block_size;
|
||||
uint8_t max_transform_hierarchy_depth_inter;
|
||||
uint8_t max_transform_hierarchy_depth_intra;
|
||||
uint8_t num_short_term_ref_pic_sets;
|
||||
uint8_t num_long_term_ref_pics_sps;
|
||||
uint8_t pcm_sample_bit_depth_luma_minus1;
|
||||
uint8_t pcm_sample_bit_depth_chroma_minus1;
|
||||
uint8_t log2_min_pcm_luma_coding_block_size_minus3;
|
||||
uint8_t log2_diff_max_min_pcm_luma_coding_block_size;
|
||||
uint8_t reserved1;
|
||||
uint8_t reserved2;
|
||||
uint8_t palette_max_size;
|
||||
uint8_t delta_palette_max_predictor_size;
|
||||
uint8_t motion_vector_resolution_control_idc;
|
||||
uint8_t sps_num_palette_predictor_initializers_minus1;
|
||||
uint32_t conf_win_left_offset;
|
||||
uint32_t conf_win_right_offset;
|
||||
uint32_t conf_win_top_offset;
|
||||
uint32_t conf_win_bottom_offset;
|
||||
const StdVideoH265ProfileTierLevel* pProfileTierLevel;
|
||||
const StdVideoH265DecPicBufMgr* pDecPicBufMgr;
|
||||
const StdVideoH265ScalingLists* pScalingLists;
|
||||
const StdVideoH265ShortTermRefPicSet* pShortTermRefPicSet;
|
||||
const StdVideoH265LongTermRefPicsSps* pLongTermRefPicsSps;
|
||||
const StdVideoH265SequenceParameterSetVui* pSequenceParameterSetVui;
|
||||
const StdVideoH265PredictorPaletteEntries* pPredictorPaletteEntries;
|
||||
} StdVideoH265SequenceParameterSet;
|
||||
|
||||
typedef struct StdVideoH265PpsFlags {
|
||||
uint32_t dependent_slice_segments_enabled_flag : 1;
|
||||
uint32_t output_flag_present_flag : 1;
|
||||
uint32_t sign_data_hiding_enabled_flag : 1;
|
||||
uint32_t cabac_init_present_flag : 1;
|
||||
uint32_t constrained_intra_pred_flag : 1;
|
||||
uint32_t transform_skip_enabled_flag : 1;
|
||||
uint32_t cu_qp_delta_enabled_flag : 1;
|
||||
uint32_t pps_slice_chroma_qp_offsets_present_flag : 1;
|
||||
uint32_t weighted_pred_flag : 1;
|
||||
uint32_t weighted_bipred_flag : 1;
|
||||
uint32_t transquant_bypass_enabled_flag : 1;
|
||||
uint32_t tiles_enabled_flag : 1;
|
||||
uint32_t entropy_coding_sync_enabled_flag : 1;
|
||||
uint32_t uniform_spacing_flag : 1;
|
||||
uint32_t loop_filter_across_tiles_enabled_flag : 1;
|
||||
uint32_t pps_loop_filter_across_slices_enabled_flag : 1;
|
||||
uint32_t deblocking_filter_control_present_flag : 1;
|
||||
uint32_t deblocking_filter_override_enabled_flag : 1;
|
||||
uint32_t pps_deblocking_filter_disabled_flag : 1;
|
||||
uint32_t pps_scaling_list_data_present_flag : 1;
|
||||
uint32_t lists_modification_present_flag : 1;
|
||||
uint32_t slice_segment_header_extension_present_flag : 1;
|
||||
uint32_t pps_extension_present_flag : 1;
|
||||
uint32_t cross_component_prediction_enabled_flag : 1;
|
||||
uint32_t chroma_qp_offset_list_enabled_flag : 1;
|
||||
uint32_t pps_curr_pic_ref_enabled_flag : 1;
|
||||
uint32_t residual_adaptive_colour_transform_enabled_flag : 1;
|
||||
uint32_t pps_slice_act_qp_offsets_present_flag : 1;
|
||||
uint32_t pps_palette_predictor_initializers_present_flag : 1;
|
||||
uint32_t monochrome_palette_flag : 1;
|
||||
uint32_t pps_range_extension_flag : 1;
|
||||
} StdVideoH265PpsFlags;
|
||||
|
||||
typedef struct StdVideoH265PictureParameterSet {
|
||||
StdVideoH265PpsFlags flags;
|
||||
uint8_t pps_pic_parameter_set_id;
|
||||
uint8_t pps_seq_parameter_set_id;
|
||||
uint8_t sps_video_parameter_set_id;
|
||||
uint8_t num_extra_slice_header_bits;
|
||||
uint8_t num_ref_idx_l0_default_active_minus1;
|
||||
uint8_t num_ref_idx_l1_default_active_minus1;
|
||||
int8_t init_qp_minus26;
|
||||
uint8_t diff_cu_qp_delta_depth;
|
||||
int8_t pps_cb_qp_offset;
|
||||
int8_t pps_cr_qp_offset;
|
||||
int8_t pps_beta_offset_div2;
|
||||
int8_t pps_tc_offset_div2;
|
||||
uint8_t log2_parallel_merge_level_minus2;
|
||||
uint8_t log2_max_transform_skip_block_size_minus2;
|
||||
uint8_t diff_cu_chroma_qp_offset_depth;
|
||||
uint8_t chroma_qp_offset_list_len_minus1;
|
||||
int8_t cb_qp_offset_list[STD_VIDEO_H265_CHROMA_QP_OFFSET_LIST_SIZE];
|
||||
int8_t cr_qp_offset_list[STD_VIDEO_H265_CHROMA_QP_OFFSET_LIST_SIZE];
|
||||
uint8_t log2_sao_offset_scale_luma;
|
||||
uint8_t log2_sao_offset_scale_chroma;
|
||||
int8_t pps_act_y_qp_offset_plus5;
|
||||
int8_t pps_act_cb_qp_offset_plus5;
|
||||
int8_t pps_act_cr_qp_offset_plus3;
|
||||
uint8_t pps_num_palette_predictor_initializers;
|
||||
uint8_t luma_bit_depth_entry_minus8;
|
||||
uint8_t chroma_bit_depth_entry_minus8;
|
||||
uint8_t num_tile_columns_minus1;
|
||||
uint8_t num_tile_rows_minus1;
|
||||
uint8_t reserved1;
|
||||
uint8_t reserved2;
|
||||
uint16_t column_width_minus1[STD_VIDEO_H265_CHROMA_QP_OFFSET_TILE_COLS_LIST_SIZE];
|
||||
uint16_t row_height_minus1[STD_VIDEO_H265_CHROMA_QP_OFFSET_TILE_ROWS_LIST_SIZE];
|
||||
uint32_t reserved3;
|
||||
const StdVideoH265ScalingLists* pScalingLists;
|
||||
const StdVideoH265PredictorPaletteEntries* pPredictorPaletteEntries;
|
||||
} StdVideoH265PictureParameterSet;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
67
third-party/glad/glad/files/vulkan_video_codec_h265std_decode.h
vendored
Normal file
67
third-party/glad/glad/files/vulkan_video_codec_h265std_decode.h
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
#ifndef VULKAN_VIDEO_CODEC_H265STD_DECODE_H_
|
||||
#define VULKAN_VIDEO_CODEC_H265STD_DECODE_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright 2015-2024 The Khronos Group Inc.
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is generated from the Khronos Vulkan XML API Registry.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// vulkan_video_codec_h265std_decode is a preprocessor guard. Do not pass it to API calls.
|
||||
#define vulkan_video_codec_h265std_decode 1
|
||||
#include "vulkan_video_codec_h265std.h"
|
||||
|
||||
#define VK_STD_VULKAN_VIDEO_CODEC_H265_DECODE_API_VERSION_1_0_0 VK_MAKE_VIDEO_STD_VERSION(1, 0, 0)
|
||||
|
||||
#define VK_STD_VULKAN_VIDEO_CODEC_H265_DECODE_SPEC_VERSION VK_STD_VULKAN_VIDEO_CODEC_H265_DECODE_API_VERSION_1_0_0
|
||||
#define VK_STD_VULKAN_VIDEO_CODEC_H265_DECODE_EXTENSION_NAME "VK_STD_vulkan_video_codec_h265_decode"
|
||||
#define STD_VIDEO_DECODE_H265_REF_PIC_SET_LIST_SIZE 8
|
||||
typedef struct StdVideoDecodeH265PictureInfoFlags {
|
||||
uint32_t IrapPicFlag : 1;
|
||||
uint32_t IdrPicFlag : 1;
|
||||
uint32_t IsReference : 1;
|
||||
uint32_t short_term_ref_pic_set_sps_flag : 1;
|
||||
} StdVideoDecodeH265PictureInfoFlags;
|
||||
|
||||
typedef struct StdVideoDecodeH265PictureInfo {
|
||||
StdVideoDecodeH265PictureInfoFlags flags;
|
||||
uint8_t sps_video_parameter_set_id;
|
||||
uint8_t pps_seq_parameter_set_id;
|
||||
uint8_t pps_pic_parameter_set_id;
|
||||
uint8_t NumDeltaPocsOfRefRpsIdx;
|
||||
int32_t PicOrderCntVal;
|
||||
uint16_t NumBitsForSTRefPicSetInSlice;
|
||||
uint16_t reserved;
|
||||
uint8_t RefPicSetStCurrBefore[STD_VIDEO_DECODE_H265_REF_PIC_SET_LIST_SIZE];
|
||||
uint8_t RefPicSetStCurrAfter[STD_VIDEO_DECODE_H265_REF_PIC_SET_LIST_SIZE];
|
||||
uint8_t RefPicSetLtCurr[STD_VIDEO_DECODE_H265_REF_PIC_SET_LIST_SIZE];
|
||||
} StdVideoDecodeH265PictureInfo;
|
||||
|
||||
typedef struct StdVideoDecodeH265ReferenceInfoFlags {
|
||||
uint32_t used_for_long_term_reference : 1;
|
||||
uint32_t unused_for_reference : 1;
|
||||
} StdVideoDecodeH265ReferenceInfoFlags;
|
||||
|
||||
typedef struct StdVideoDecodeH265ReferenceInfo {
|
||||
StdVideoDecodeH265ReferenceInfoFlags flags;
|
||||
int32_t PicOrderCntVal;
|
||||
} StdVideoDecodeH265ReferenceInfo;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
157
third-party/glad/glad/files/vulkan_video_codec_h265std_encode.h
vendored
Normal file
157
third-party/glad/glad/files/vulkan_video_codec_h265std_encode.h
vendored
Normal file
@@ -0,0 +1,157 @@
|
||||
#ifndef VULKAN_VIDEO_CODEC_H265STD_ENCODE_H_
|
||||
#define VULKAN_VIDEO_CODEC_H265STD_ENCODE_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright 2015-2024 The Khronos Group Inc.
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is generated from the Khronos Vulkan XML API Registry.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// vulkan_video_codec_h265std_encode is a preprocessor guard. Do not pass it to API calls.
|
||||
#define vulkan_video_codec_h265std_encode 1
|
||||
#include "vulkan_video_codec_h265std.h"
|
||||
|
||||
#define VK_STD_VULKAN_VIDEO_CODEC_H265_ENCODE_API_VERSION_1_0_0 VK_MAKE_VIDEO_STD_VERSION(1, 0, 0)
|
||||
|
||||
#define VK_STD_VULKAN_VIDEO_CODEC_H265_ENCODE_SPEC_VERSION VK_STD_VULKAN_VIDEO_CODEC_H265_ENCODE_API_VERSION_1_0_0
|
||||
#define VK_STD_VULKAN_VIDEO_CODEC_H265_ENCODE_EXTENSION_NAME "VK_STD_vulkan_video_codec_h265_encode"
|
||||
typedef struct StdVideoEncodeH265WeightTableFlags {
|
||||
uint16_t luma_weight_l0_flag;
|
||||
uint16_t chroma_weight_l0_flag;
|
||||
uint16_t luma_weight_l1_flag;
|
||||
uint16_t chroma_weight_l1_flag;
|
||||
} StdVideoEncodeH265WeightTableFlags;
|
||||
|
||||
typedef struct StdVideoEncodeH265WeightTable {
|
||||
StdVideoEncodeH265WeightTableFlags flags;
|
||||
uint8_t luma_log2_weight_denom;
|
||||
int8_t delta_chroma_log2_weight_denom;
|
||||
int8_t delta_luma_weight_l0[STD_VIDEO_H265_MAX_NUM_LIST_REF];
|
||||
int8_t luma_offset_l0[STD_VIDEO_H265_MAX_NUM_LIST_REF];
|
||||
int8_t delta_chroma_weight_l0[STD_VIDEO_H265_MAX_NUM_LIST_REF][STD_VIDEO_H265_MAX_CHROMA_PLANES];
|
||||
int8_t delta_chroma_offset_l0[STD_VIDEO_H265_MAX_NUM_LIST_REF][STD_VIDEO_H265_MAX_CHROMA_PLANES];
|
||||
int8_t delta_luma_weight_l1[STD_VIDEO_H265_MAX_NUM_LIST_REF];
|
||||
int8_t luma_offset_l1[STD_VIDEO_H265_MAX_NUM_LIST_REF];
|
||||
int8_t delta_chroma_weight_l1[STD_VIDEO_H265_MAX_NUM_LIST_REF][STD_VIDEO_H265_MAX_CHROMA_PLANES];
|
||||
int8_t delta_chroma_offset_l1[STD_VIDEO_H265_MAX_NUM_LIST_REF][STD_VIDEO_H265_MAX_CHROMA_PLANES];
|
||||
} StdVideoEncodeH265WeightTable;
|
||||
|
||||
typedef struct StdVideoEncodeH265SliceSegmentHeaderFlags {
|
||||
uint32_t first_slice_segment_in_pic_flag : 1;
|
||||
uint32_t dependent_slice_segment_flag : 1;
|
||||
uint32_t slice_sao_luma_flag : 1;
|
||||
uint32_t slice_sao_chroma_flag : 1;
|
||||
uint32_t num_ref_idx_active_override_flag : 1;
|
||||
uint32_t mvd_l1_zero_flag : 1;
|
||||
uint32_t cabac_init_flag : 1;
|
||||
uint32_t cu_chroma_qp_offset_enabled_flag : 1;
|
||||
uint32_t deblocking_filter_override_flag : 1;
|
||||
uint32_t slice_deblocking_filter_disabled_flag : 1;
|
||||
uint32_t collocated_from_l0_flag : 1;
|
||||
uint32_t slice_loop_filter_across_slices_enabled_flag : 1;
|
||||
uint32_t reserved : 20;
|
||||
} StdVideoEncodeH265SliceSegmentHeaderFlags;
|
||||
|
||||
typedef struct StdVideoEncodeH265SliceSegmentHeader {
|
||||
StdVideoEncodeH265SliceSegmentHeaderFlags flags;
|
||||
StdVideoH265SliceType slice_type;
|
||||
uint32_t slice_segment_address;
|
||||
uint8_t collocated_ref_idx;
|
||||
uint8_t MaxNumMergeCand;
|
||||
int8_t slice_cb_qp_offset;
|
||||
int8_t slice_cr_qp_offset;
|
||||
int8_t slice_beta_offset_div2;
|
||||
int8_t slice_tc_offset_div2;
|
||||
int8_t slice_act_y_qp_offset;
|
||||
int8_t slice_act_cb_qp_offset;
|
||||
int8_t slice_act_cr_qp_offset;
|
||||
int8_t slice_qp_delta;
|
||||
uint16_t reserved1;
|
||||
const StdVideoEncodeH265WeightTable* pWeightTable;
|
||||
} StdVideoEncodeH265SliceSegmentHeader;
|
||||
|
||||
typedef struct StdVideoEncodeH265ReferenceListsInfoFlags {
|
||||
uint32_t ref_pic_list_modification_flag_l0 : 1;
|
||||
uint32_t ref_pic_list_modification_flag_l1 : 1;
|
||||
uint32_t reserved : 30;
|
||||
} StdVideoEncodeH265ReferenceListsInfoFlags;
|
||||
|
||||
typedef struct StdVideoEncodeH265ReferenceListsInfo {
|
||||
StdVideoEncodeH265ReferenceListsInfoFlags flags;
|
||||
uint8_t num_ref_idx_l0_active_minus1;
|
||||
uint8_t num_ref_idx_l1_active_minus1;
|
||||
uint8_t RefPicList0[STD_VIDEO_H265_MAX_NUM_LIST_REF];
|
||||
uint8_t RefPicList1[STD_VIDEO_H265_MAX_NUM_LIST_REF];
|
||||
uint8_t list_entry_l0[STD_VIDEO_H265_MAX_NUM_LIST_REF];
|
||||
uint8_t list_entry_l1[STD_VIDEO_H265_MAX_NUM_LIST_REF];
|
||||
} StdVideoEncodeH265ReferenceListsInfo;
|
||||
|
||||
typedef struct StdVideoEncodeH265PictureInfoFlags {
|
||||
uint32_t is_reference : 1;
|
||||
uint32_t IrapPicFlag : 1;
|
||||
uint32_t used_for_long_term_reference : 1;
|
||||
uint32_t discardable_flag : 1;
|
||||
uint32_t cross_layer_bla_flag : 1;
|
||||
uint32_t pic_output_flag : 1;
|
||||
uint32_t no_output_of_prior_pics_flag : 1;
|
||||
uint32_t short_term_ref_pic_set_sps_flag : 1;
|
||||
uint32_t slice_temporal_mvp_enabled_flag : 1;
|
||||
uint32_t reserved : 23;
|
||||
} StdVideoEncodeH265PictureInfoFlags;
|
||||
|
||||
typedef struct StdVideoEncodeH265LongTermRefPics {
|
||||
uint8_t num_long_term_sps;
|
||||
uint8_t num_long_term_pics;
|
||||
uint8_t lt_idx_sps[STD_VIDEO_H265_MAX_LONG_TERM_REF_PICS_SPS];
|
||||
uint8_t poc_lsb_lt[STD_VIDEO_H265_MAX_LONG_TERM_PICS];
|
||||
uint16_t used_by_curr_pic_lt_flag;
|
||||
uint8_t delta_poc_msb_present_flag[STD_VIDEO_H265_MAX_DELTA_POC];
|
||||
uint8_t delta_poc_msb_cycle_lt[STD_VIDEO_H265_MAX_DELTA_POC];
|
||||
} StdVideoEncodeH265LongTermRefPics;
|
||||
|
||||
typedef struct StdVideoEncodeH265PictureInfo {
|
||||
StdVideoEncodeH265PictureInfoFlags flags;
|
||||
StdVideoH265PictureType pic_type;
|
||||
uint8_t sps_video_parameter_set_id;
|
||||
uint8_t pps_seq_parameter_set_id;
|
||||
uint8_t pps_pic_parameter_set_id;
|
||||
uint8_t short_term_ref_pic_set_idx;
|
||||
int32_t PicOrderCntVal;
|
||||
uint8_t TemporalId;
|
||||
uint8_t reserved1[7];
|
||||
const StdVideoEncodeH265ReferenceListsInfo* pRefLists;
|
||||
const StdVideoH265ShortTermRefPicSet* pShortTermRefPicSet;
|
||||
const StdVideoEncodeH265LongTermRefPics* pLongTermRefPics;
|
||||
} StdVideoEncodeH265PictureInfo;
|
||||
|
||||
typedef struct StdVideoEncodeH265ReferenceInfoFlags {
|
||||
uint32_t used_for_long_term_reference : 1;
|
||||
uint32_t unused_for_reference : 1;
|
||||
uint32_t reserved : 30;
|
||||
} StdVideoEncodeH265ReferenceInfoFlags;
|
||||
|
||||
typedef struct StdVideoEncodeH265ReferenceInfo {
|
||||
StdVideoEncodeH265ReferenceInfoFlags flags;
|
||||
StdVideoH265PictureType pic_type;
|
||||
int32_t PicOrderCntVal;
|
||||
uint8_t TemporalId;
|
||||
} StdVideoEncodeH265ReferenceInfo;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
36
third-party/glad/glad/files/vulkan_video_codecs_common.h
vendored
Normal file
36
third-party/glad/glad/files/vulkan_video_codecs_common.h
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
#ifndef VULKAN_VIDEO_CODECS_COMMON_H_
|
||||
#define VULKAN_VIDEO_CODECS_COMMON_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright 2015-2024 The Khronos Group Inc.
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is generated from the Khronos Vulkan XML API Registry.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// vulkan_video_codecs_common is a preprocessor guard. Do not pass it to API calls.
|
||||
#define vulkan_video_codecs_common 1
|
||||
#if !defined(VK_NO_STDINT_H)
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#define VK_MAKE_VIDEO_STD_VERSION(major, minor, patch) \
|
||||
((((uint32_t)(major)) << 22) | (((uint32_t)(minor)) << 12) | ((uint32_t)(patch)))
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
1988
third-party/glad/glad/files/wgl.xml
vendored
Normal file
1988
third-party/glad/glad/files/wgl.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
340
third-party/glad/glad/generator/__init__.py
vendored
Normal file
340
third-party/glad/glad/generator/__init__.py
vendored
Normal file
@@ -0,0 +1,340 @@
|
||||
from datetime import datetime
|
||||
|
||||
import sys
|
||||
|
||||
import collections
|
||||
import os.path
|
||||
from jinja2 import Environment, ChoiceLoader, PackageLoader
|
||||
|
||||
import glad
|
||||
from glad.config import Config
|
||||
from glad.sink import LoggingSink
|
||||
from glad.opener import URLOpener
|
||||
from glad.util import makefiledir
|
||||
|
||||
if sys.version_info >= (3, 0):
|
||||
from urllib.parse import urlencode
|
||||
else:
|
||||
from urllib import urlencode
|
||||
|
||||
|
||||
class NullConfig(Config):
|
||||
pass
|
||||
|
||||
|
||||
class BaseGenerator(object):
|
||||
DISPLAY_NAME = None
|
||||
Config = NullConfig
|
||||
|
||||
def __init__(self, path, opener=None, gen_info_factory=None):
|
||||
self.path = os.path.abspath(path)
|
||||
|
||||
self.opener = opener
|
||||
if self.opener is None:
|
||||
self.opener = URLOpener.default()
|
||||
|
||||
self.gen_info_factory = gen_info_factory or GenerationInfo.create
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return self.DISPLAY_NAME
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
raise NotImplementedError
|
||||
|
||||
def select(self, spec, api, version, profile, extensions, config, sink=LoggingSink(__name__)):
|
||||
"""
|
||||
Basically equivalent to `Specification.select` but gives the generator
|
||||
a chance to add additionally required extension, modify the result, etc.
|
||||
|
||||
:param spec: Specification to use
|
||||
:param api: API name
|
||||
:param version: API version, None means latest
|
||||
:param profile: desired profile
|
||||
:param extensions: a list of desired extension names, None means all
|
||||
:param config: instance of of config specified in `CONFIG`
|
||||
:param sink: sink used to collect non fatal errors and information
|
||||
:return: FeatureSet with the required types, enums, commands/functions
|
||||
"""
|
||||
return spec.select(api, version, profile, extensions, sink=sink)
|
||||
|
||||
def generate(self, spec, feature_set, config, sink=LoggingSink(__name__)):
|
||||
"""
|
||||
Generates a feature set with the generator.
|
||||
|
||||
:param spec: specification of `feature_set`
|
||||
:param feature_set: feature set to generate
|
||||
:param config: instance of config specified in `CONFIG`
|
||||
:param sink: sink used to collect non fatal errors and information
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
def _api_filter(api):
|
||||
if len(api) > 5:
|
||||
return api.capitalize()
|
||||
return api.upper()
|
||||
|
||||
|
||||
class JinjaGenerator(BaseGenerator):
|
||||
TEMPLATES = None
|
||||
|
||||
def __init__(self, path, opener=None, gen_info_factory=None):
|
||||
BaseGenerator.__init__(self, path, opener=opener, gen_info_factory=gen_info_factory)
|
||||
|
||||
assert self.TEMPLATES is not None
|
||||
self.environment = Environment(
|
||||
loader=ChoiceLoader(list(map(PackageLoader, self.TEMPLATES))),
|
||||
extensions=['jinja2.ext.do'],
|
||||
trim_blocks=True,
|
||||
lstrip_blocks=True,
|
||||
keep_trailing_newline=True,
|
||||
autoescape=False
|
||||
)
|
||||
|
||||
self.environment.globals.update(
|
||||
set_=set,
|
||||
zip=zip
|
||||
)
|
||||
|
||||
self.environment.tests.update(
|
||||
existsin=lambda value, other: value in other
|
||||
)
|
||||
|
||||
self.environment.filters.update(
|
||||
api=_api_filter
|
||||
)
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
raise NotImplementedError
|
||||
|
||||
def get_templates(self, spec, feature_set, config):
|
||||
"""
|
||||
Return a list of destination and template tuples for the
|
||||
desired feature set and configuration.
|
||||
|
||||
:param spec: specification
|
||||
:param feature_set: feature set
|
||||
:param config: configuration
|
||||
:return: [(destination, name)]
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def modify_feature_set(self, spec, feature_set, config):
|
||||
"""
|
||||
Called before `get_templates` and for every `generate` call.
|
||||
Mainly useful to update definitions in order to make the
|
||||
template interpret types correctly.
|
||||
|
||||
Even though it is possible to return a new feature set,
|
||||
such modifications should rather be done in `select`.
|
||||
|
||||
Default implementation does nothing.
|
||||
|
||||
:param feature_set: feature set to modify (the one passed to `get_templates`)
|
||||
:return: modified feature set
|
||||
"""
|
||||
return feature_set
|
||||
|
||||
def get_template_arguments(self, spec, feature_set, config):
|
||||
return dict(
|
||||
spec=spec,
|
||||
feature_set=feature_set,
|
||||
options=config.to_dict(transform=lambda x: x.lower()),
|
||||
gen_info=self.gen_info_factory(self, spec, feature_set, config)
|
||||
)
|
||||
|
||||
def generate(self, spec, feature_set, config, sink=LoggingSink(__name__)):
|
||||
feature_set = self.modify_feature_set(spec, feature_set, config)
|
||||
for template, output_path in self.get_templates(spec, feature_set, config):
|
||||
#try:
|
||||
template = self.environment.get_template(template)
|
||||
#except TemplateNotFound:
|
||||
# # TODO better error, maybe let get_templates throw
|
||||
# raise ValueError('Unsupported specification/configuration')
|
||||
|
||||
result = template.render(
|
||||
**self.get_template_arguments(spec, feature_set, config)
|
||||
)
|
||||
|
||||
output_path = os.path.join(self.path, output_path)
|
||||
makefiledir(output_path)
|
||||
with open(output_path, 'w') as f:
|
||||
f.write(result)
|
||||
|
||||
self.post_generate(spec, feature_set, config)
|
||||
|
||||
def post_generate(self, spec, feature_set, config):
|
||||
pass
|
||||
|
||||
|
||||
class GenerationInfo(object):
|
||||
def __init__(self, generator_name, generator_id, spec, info, options, extensions,
|
||||
when=None, commandline=None, online=None):
|
||||
"""
|
||||
Collection of information used to describe a single "generation".
|
||||
All held information should either be a string or be "stringifyable".
|
||||
|
||||
:param generator_name: the generator name
|
||||
:param generator_id: the generator id (as it was registered with glad.plugin)
|
||||
:param spec: the specification name
|
||||
:param info: feature set information, usually glad.parse.FeatureSetInfo
|
||||
:param options: dictionary containing all enabled options and their value
|
||||
:param when: datetime when the code was generated, defaults to now
|
||||
:param commandline: callable used to build commandline parameters (will be pased this instance)
|
||||
:param online: callable used to build online parameters (will be passed this instance)
|
||||
"""
|
||||
self.generator_name = generator_name
|
||||
self.generator_id = generator_id
|
||||
self.specification = spec
|
||||
self.info = info
|
||||
self.options = options
|
||||
self.extensions = extensions
|
||||
self.when = when or datetime.now().strftime('%c')
|
||||
|
||||
self._commandline = commandline or Commandline()
|
||||
self._online = online or Online()
|
||||
|
||||
@classmethod
|
||||
def create(cls, generator, spec, feature_set, config, **kwargs):
|
||||
return cls(
|
||||
generator.name,
|
||||
generator.id,
|
||||
spec.name,
|
||||
feature_set.info,
|
||||
config.to_dict(),
|
||||
[ext.name for ext in feature_set.extensions],
|
||||
**kwargs
|
||||
)
|
||||
|
||||
@property
|
||||
def version(self):
|
||||
return glad.__version__
|
||||
|
||||
@property
|
||||
def commandline(self):
|
||||
return self._commandline.build(self)
|
||||
|
||||
@property
|
||||
def online(self):
|
||||
return self._online.build(self)
|
||||
|
||||
|
||||
class ParameterBuilder(object):
|
||||
def build(self, gen_info):
|
||||
raise NotImplementedError
|
||||
|
||||
def __call__(self, gen_info):
|
||||
return self.build(gen_info)
|
||||
|
||||
|
||||
class NullParameterBuilder(ParameterBuilder):
|
||||
def build(self, gen_info):
|
||||
return ''
|
||||
|
||||
|
||||
class Commandline(ParameterBuilder):
|
||||
def __init__(self):
|
||||
"""
|
||||
Parameter builder which serializes a GeneratorInfo
|
||||
into commandline arguments.
|
||||
"""
|
||||
pass
|
||||
|
||||
def format_argument(self, name, value):
|
||||
name = name.lower().replace('_', '-')
|
||||
|
||||
if isinstance(value, bool):
|
||||
return '--{name}'.format(name=name) if value else None
|
||||
|
||||
if isinstance(value, (list, tuple)):
|
||||
value = ','.join(str(element) for element in value)
|
||||
|
||||
return '--{name}=\'{value}\''.format(name=name, value=value)
|
||||
|
||||
def build(self, gen_info):
|
||||
args = []
|
||||
|
||||
def push(name, value):
|
||||
formatted = self.format_argument(name, value)
|
||||
if formatted is not None:
|
||||
args.append(formatted)
|
||||
|
||||
# general options
|
||||
push('merge', gen_info.info.merged)
|
||||
push('api', list(gen_info.info))
|
||||
push('extensions', gen_info.extensions)
|
||||
|
||||
# generator options
|
||||
args.append(gen_info.generator_id)
|
||||
for name, value in gen_info.options.items():
|
||||
push(name, value)
|
||||
|
||||
return ' '.join(args)
|
||||
|
||||
|
||||
class Online(ParameterBuilder):
|
||||
def __init__(self, base_url='http://glad.sh'):
|
||||
"""
|
||||
Parameter builder which serializes a GeneratorInfo
|
||||
into commandline arguments.
|
||||
|
||||
:param base_url: base url of the web generator.
|
||||
"""
|
||||
self.base_url = base_url
|
||||
|
||||
self._max_len_threshold = 2000
|
||||
|
||||
def format_argument(self, name, value):
|
||||
name = name.lower().replace('-', '_')
|
||||
|
||||
if isinstance(value, bool):
|
||||
return name, 'on' if value else 'off'
|
||||
|
||||
if isinstance(value, (list, tuple)):
|
||||
result = list()
|
||||
for element in value:
|
||||
if isinstance(element, (list, tuple)) and len(element) == 2:
|
||||
if isinstance(element[1], bool):
|
||||
if element[1]:
|
||||
result.append(element[0].upper())
|
||||
else:
|
||||
result.append('{0}={1}'.format(*element))
|
||||
else:
|
||||
result.append(str(element))
|
||||
value = ','.join(result)
|
||||
|
||||
return name, value
|
||||
|
||||
def build(self, gen_info):
|
||||
args = collections.OrderedDict()
|
||||
|
||||
def push(name, value):
|
||||
name, value = self.format_argument(name, value)
|
||||
args[name] = value
|
||||
|
||||
# general options
|
||||
push('api', list(gen_info.info))
|
||||
push('extensions', gen_info.extensions)
|
||||
|
||||
# generator options
|
||||
push('generator', gen_info.generator_id)
|
||||
|
||||
options = [('merge', gen_info.info.merged)]
|
||||
options.extend(gen_info.options.items())
|
||||
push('options', options)
|
||||
|
||||
def build_url():
|
||||
return '{base_url}/#{data}'.format(
|
||||
base_url=self.base_url.rstrip('/'),
|
||||
data=urlencode(args)
|
||||
)
|
||||
|
||||
url = build_url()
|
||||
if self._max_len_threshold and len(url) > self._max_len_threshold:
|
||||
args.pop('extensions')
|
||||
url = build_url()
|
||||
|
||||
return url
|
||||
553
third-party/glad/glad/generator/c/__init__.py
vendored
Normal file
553
third-party/glad/glad/generator/c/__init__.py
vendored
Normal file
@@ -0,0 +1,553 @@
|
||||
import copy
|
||||
import itertools
|
||||
|
||||
import os.path
|
||||
import re
|
||||
from collections import namedtuple
|
||||
from contextlib import closing
|
||||
|
||||
from glad.config import Config, ConfigOption, UnsupportedConstraint
|
||||
from glad.sink import LoggingSink
|
||||
from glad.generator import JinjaGenerator
|
||||
from glad.generator.util import (
|
||||
is_device_command,
|
||||
strip_specification_prefix,
|
||||
collect_alias_information,
|
||||
find_extensions_with_aliases,
|
||||
jinja2_contextfunction,
|
||||
jinja2_contextfilter
|
||||
)
|
||||
from glad.parse import Type, EnumType
|
||||
from glad.specification import VK, GL, WGL
|
||||
import glad.util
|
||||
|
||||
_ARRAY_RE = re.compile(r'\[[\d\w]*\]')
|
||||
|
||||
DebugArguments = namedtuple('_DebugParams', ['impl', 'function', 'pre_callback', 'post_callback', 'ret'])
|
||||
DebugReturn = namedtuple('_DebugReturn', ['declaration', 'assignment', 'ret'])
|
||||
|
||||
|
||||
class Header(object):
|
||||
def __init__(self, name, include, url, requires=None):
|
||||
self.name = name
|
||||
self.include = include
|
||||
self.url = url
|
||||
self.requires = requires
|
||||
|
||||
|
||||
def type_to_c(parsed_type):
|
||||
result = ''
|
||||
|
||||
for text in glad.util.itertext(parsed_type._element, ignore=('comment',)):
|
||||
if text == parsed_type.name:
|
||||
# yup * is sometimes part of the name
|
||||
result += '*' * text.count('*')
|
||||
else:
|
||||
result += text
|
||||
result = _ARRAY_RE.sub('*', result)
|
||||
return result.strip()
|
||||
|
||||
|
||||
def params_to_c(params):
|
||||
result = ', '.join(param.type._raw for param in params) if params else 'void'
|
||||
result = ' '.join(result.split())
|
||||
return result
|
||||
|
||||
|
||||
def param_names(params):
|
||||
return ', '.join(param.name for param in params)
|
||||
|
||||
|
||||
@jinja2_contextfunction
|
||||
def loadable(context, extensions=None, api=None):
|
||||
spec = context['spec']
|
||||
feature_set = context['feature_set']
|
||||
|
||||
if extensions is None:
|
||||
extensions = (feature_set.features, feature_set.extensions)
|
||||
elif len(extensions) > 0:
|
||||
# allow loadable(feature_set.features), nicer syntax in templates
|
||||
try:
|
||||
iter(extensions[0])
|
||||
except TypeError:
|
||||
extensions = [extensions]
|
||||
|
||||
for extension in itertools.chain.from_iterable(extensions):
|
||||
if api is None or extension.supports(api):
|
||||
commands = extension.get_requirements(spec, feature_set=feature_set).commands
|
||||
if commands:
|
||||
yield extension, commands
|
||||
|
||||
|
||||
def is_void(t):
|
||||
# lower because of win API having VOID
|
||||
return type_to_c(t).lower() == 'void'
|
||||
|
||||
|
||||
def get_debug_impl(command, command_code_name=None):
|
||||
command_code_name = command_code_name or command.name
|
||||
|
||||
impl = params_to_c(command.params)
|
||||
func = param_names(command.params)
|
||||
|
||||
pre_callback = ', '.join(filter(None, [
|
||||
'"{}"'.format(command.name),
|
||||
'(GLADapiproc) {}'.format(command_code_name),
|
||||
str(len(command.params)),
|
||||
func
|
||||
]))
|
||||
|
||||
is_void_ret = is_void(command.proto.ret)
|
||||
|
||||
post_callback = ('NULL, ' if is_void_ret else '(void*) &ret, ') + pre_callback
|
||||
|
||||
ret = DebugReturn('', '', '')
|
||||
if not is_void_ret:
|
||||
ret = DebugReturn(
|
||||
'{} ret;\n '.format(type_to_c(command.proto.ret)),
|
||||
'ret = ',
|
||||
'return ret;'
|
||||
)
|
||||
|
||||
return DebugArguments(impl, func, pre_callback, post_callback, ret)
|
||||
|
||||
|
||||
@jinja2_contextfilter
|
||||
def ctx(jinja_context, name, context='context', raw=False, name_only=False, member=False):
|
||||
options = jinja_context['options']
|
||||
|
||||
prefix = 'glad_'
|
||||
if options['mx']:
|
||||
prefix = context + '->'
|
||||
if name.startswith('GLAD_'):
|
||||
name = name[5:]
|
||||
|
||||
if not raw:
|
||||
name = strip_specification_prefix(name, jinja_context['spec'])
|
||||
|
||||
# it's a mx struct member
|
||||
if member:
|
||||
return name
|
||||
|
||||
# you won't the name, only when we're not mx
|
||||
if name_only and not options['mx']:
|
||||
return name
|
||||
|
||||
return prefix + name
|
||||
|
||||
|
||||
@jinja2_contextfilter
|
||||
def pfn(context, value):
|
||||
spec = context['spec']
|
||||
if spec.name in (VK.NAME,):
|
||||
return 'PFN_' + value
|
||||
return 'PFN' + value.upper() + 'PROC'
|
||||
|
||||
|
||||
@jinja2_contextfilter
|
||||
def c_commands(context, commands):
|
||||
"""
|
||||
The c in c_commands refers to the c file.
|
||||
|
||||
This function filters a list of commands for the generated .c file.
|
||||
WGL core functions are not dynamically loaded but need to be linked,
|
||||
this functions filters out wgl core functions for the .c file.
|
||||
|
||||
:param context: jinja context
|
||||
:param commands: list of commands
|
||||
:return: commands filtered
|
||||
"""
|
||||
spec = context['spec']
|
||||
if not spec.name == WGL.NAME:
|
||||
return commands
|
||||
|
||||
feature_set = context['feature_set']
|
||||
core = feature_set.features[0].get_requirements(spec, feature_set=feature_set)
|
||||
|
||||
return [command for command in commands if not command in core]
|
||||
|
||||
|
||||
@jinja2_contextfunction
|
||||
def enum_member(context, type_, member, require_value=False):
|
||||
if member.alias is None:
|
||||
return member.value
|
||||
|
||||
feature_set = context['feature_set']
|
||||
enums_of_type = type_.enums_for(feature_set)
|
||||
|
||||
def is_enum_before(target, before):
|
||||
for enum in enums_of_type:
|
||||
if enum.name == target:
|
||||
return True
|
||||
if enum.name == before:
|
||||
return False
|
||||
|
||||
if not require_value:
|
||||
if is_enum_before(member.alias, member.name):
|
||||
return member.alias
|
||||
|
||||
# This is the part where the spec is annoying again
|
||||
# an enum that has been moved into core in a later version
|
||||
# loses its _KHR postfix, but in an earlier version this still requires an extension...
|
||||
# Luckily glad automatically adds the necessary enum to the feature set,
|
||||
# but it doesn't get generated, because it is not actually part of the selected feature set.
|
||||
# Just have to get the actual value now
|
||||
def resolve(target):
|
||||
target = feature_set.find_enum(target)
|
||||
if target.alias is None:
|
||||
return target.value
|
||||
return resolve(target.alias)
|
||||
|
||||
return resolve(member.alias)
|
||||
|
||||
|
||||
_CPP_STYLE_COMMENT_RE = re.compile(r'(^|\s|\))//(?P<comment>[^\r^\n]*)', flags=re.MULTILINE)
|
||||
|
||||
|
||||
def replace_cpp_style_comments(inp):
|
||||
return _CPP_STYLE_COMMENT_RE.sub(r'\1/*\2 */', inp)
|
||||
|
||||
|
||||
class CConfig(Config):
|
||||
DEBUG = ConfigOption(
|
||||
converter=bool,
|
||||
default=False,
|
||||
description='Enables generation of a debug build'
|
||||
)
|
||||
ALIAS = ConfigOption(
|
||||
converter=bool,
|
||||
default=False,
|
||||
description='Enables function pointer aliasing'
|
||||
)
|
||||
MX = ConfigOption(
|
||||
converter=bool,
|
||||
default=False,
|
||||
description='Enables support for multiple GL contexts'
|
||||
)
|
||||
# MX_GLOBAL = ConfigOption(
|
||||
# converter=bool,
|
||||
# default=False,
|
||||
# description='Mimic global GL functions with context switching'
|
||||
# )
|
||||
HEADER_ONLY = ConfigOption(
|
||||
converter=bool,
|
||||
default=False,
|
||||
description='Generate a header only version of glad'
|
||||
)
|
||||
LOADER = ConfigOption(
|
||||
converter=bool,
|
||||
default=False,
|
||||
description='Include internal loaders for APIs'
|
||||
)
|
||||
ON_DEMAND = ConfigOption(
|
||||
converter=bool,
|
||||
default=False,
|
||||
description='On-demand function pointer loading, initialize on use (experimental)'
|
||||
)
|
||||
|
||||
__constraints__ = [
|
||||
# RequirementConstraint(['MX_GLOBAL'], 'MX'),
|
||||
UnsupportedConstraint(['MX'], 'DEBUG'),
|
||||
# RequirementConstraint(['MX', 'DEBUG'], 'MX_GLOBAL')
|
||||
UnsupportedConstraint(['MX'], 'ON_DEMAND')
|
||||
]
|
||||
|
||||
|
||||
class CGenerator(JinjaGenerator):
|
||||
DISPLAY_NAME = 'C/C++'
|
||||
|
||||
TEMPLATES = ['glad.generator.c']
|
||||
Config = CConfig
|
||||
|
||||
ADDITIONAL_HEADERS = [
|
||||
Header(
|
||||
'khrplatform',
|
||||
'KHR/khrplatform.h',
|
||||
'https://raw.githubusercontent.com/KhronosGroup/EGL-Registry/main/api/KHR/khrplatform.h'
|
||||
),
|
||||
Header(
|
||||
'eglplatform',
|
||||
'EGL/eglplatform.h',
|
||||
'https://raw.githubusercontent.com/KhronosGroup/EGL-Registry/main/api/EGL/eglplatform.h'
|
||||
),
|
||||
Header(
|
||||
'vk_platform',
|
||||
'vk_platform.h',
|
||||
'https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/main/include/vulkan/vk_platform.h'
|
||||
),
|
||||
Header(
|
||||
'vk_video/vulkan_video_codecs_common.h',
|
||||
'vk_video/vulkan_video_codecs_common.h',
|
||||
'https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/main/include/vk_video/vulkan_video_codecs_common.h'
|
||||
),
|
||||
Header(
|
||||
'vk_video/vulkan_video_codec_h264std.h',
|
||||
'vk_video/vulkan_video_codec_h264std.h',
|
||||
'https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/main/include/vk_video/vulkan_video_codec_h264std.h',
|
||||
requires=['vk_video/vulkan_video_codecs_common.h']
|
||||
),
|
||||
Header(
|
||||
'vk_video/vulkan_video_codec_h264std_decode.h',
|
||||
'vk_video/vulkan_video_codec_h264std_decode.h',
|
||||
'https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/main/include/vk_video/vulkan_video_codec_h264std_decode.h',
|
||||
requires=['vk_video/vulkan_video_codecs_common.h']
|
||||
),
|
||||
Header(
|
||||
'vk_video/vulkan_video_codec_h264std_encode.h',
|
||||
'vk_video/vulkan_video_codec_h264std_encode.h',
|
||||
'https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/main/include/vk_video/vulkan_video_codec_h264std_encode.h',
|
||||
requires=['vk_video/vulkan_video_codecs_common.h']
|
||||
),
|
||||
Header(
|
||||
'vk_video/vulkan_video_codec_h265std.h',
|
||||
'vk_video/vulkan_video_codec_h265std.h',
|
||||
'https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/main/include/vk_video/vulkan_video_codec_h265std.h',
|
||||
requires=['vk_video/vulkan_video_codecs_common.h']
|
||||
),
|
||||
Header(
|
||||
'vk_video/vulkan_video_codec_h265std_decode.h',
|
||||
'vk_video/vulkan_video_codec_h265std_decode.h',
|
||||
'https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/main/include/vk_video/vulkan_video_codec_h265std_decode.h',
|
||||
requires=['vk_video/vulkan_video_codecs_common.h']
|
||||
),
|
||||
Header(
|
||||
'vk_video/vulkan_video_codec_h265std_encode.h',
|
||||
'vk_video/vulkan_video_codec_h265std_encode.h',
|
||||
'https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/main/include/vk_video/vulkan_video_codec_h265std_encode.h',
|
||||
requires=['vk_video/vulkan_video_codecs_common.h']
|
||||
),
|
||||
Header(
|
||||
'vk_video/vulkan_video_codec_av1std.h',
|
||||
'vk_video/vulkan_video_codec_av1std.h',
|
||||
'https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/main/include/vk_video/vulkan_video_codec_av1std.h',
|
||||
requires=['vk_video/vulkan_video_codecs_common.h']
|
||||
),
|
||||
Header(
|
||||
'vk_video/vulkan_video_codec_av1std_decode.h',
|
||||
'vk_video/vulkan_video_codec_av1std_decode.h',
|
||||
'https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/main/include/vk_video/vulkan_video_codec_av1std_decode.h',
|
||||
requires=['vk_video/vulkan_video_codecs_common.h']
|
||||
),
|
||||
]
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
JinjaGenerator.__init__(self, *args, **kwargs)
|
||||
|
||||
self._headers = dict()
|
||||
|
||||
self.environment.globals.update(
|
||||
get_debug_impl=get_debug_impl,
|
||||
loadable=loadable,
|
||||
enum_member=enum_member,
|
||||
chain=itertools.chain
|
||||
)
|
||||
|
||||
self.environment.filters.update(
|
||||
defined=lambda x: 'defined({})'.format(x),
|
||||
type_to_c=type_to_c,
|
||||
params_to_c=params_to_c,
|
||||
param_names=param_names,
|
||||
pfn=pfn,
|
||||
ctx=ctx,
|
||||
no_prefix=jinja2_contextfilter(lambda ctx, value: strip_specification_prefix(value, ctx['spec'])),
|
||||
c_commands=c_commands
|
||||
)
|
||||
|
||||
self.environment.tests.update(
|
||||
supports=lambda x, arg: x.supports(arg),
|
||||
void=is_void,
|
||||
)
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
return 'c'
|
||||
|
||||
def select(self, spec, api, version, profile, extensions, config, sink=LoggingSink(__name__)):
|
||||
if extensions is not None:
|
||||
extensions = set(extensions)
|
||||
|
||||
if api == 'wgl':
|
||||
# See issue #40: https://github.com/Dav1dde/glad/issues/40
|
||||
# > Currently if you generate a loader without these extensions
|
||||
# > (WGL_ARB_extensions_string and WGL_EXT_extensions_string) it won't compile.
|
||||
# Adds these 2 extensions if they are missing.
|
||||
extensions.update(('WGL_ARB_extensions_string', 'WGL_EXT_extensions_string'))
|
||||
|
||||
if config['ALIAS']:
|
||||
extensions.update(find_extensions_with_aliases(spec, api, version, profile, extensions))
|
||||
|
||||
return JinjaGenerator.select(self, spec, api, version, profile, extensions, config, sink=sink)
|
||||
|
||||
def get_template_arguments(self, spec, feature_set, config):
|
||||
args = JinjaGenerator.get_template_arguments(self, spec, feature_set, config)
|
||||
|
||||
# TODO allow MX for every specification/api
|
||||
if spec.name not in (VK.NAME, GL.NAME):
|
||||
args['options']['mx'] = False
|
||||
args['options']['mx_global'] = False
|
||||
|
||||
args.update(
|
||||
aliases=collect_alias_information(feature_set.commands),
|
||||
# required for vulkan loader:
|
||||
device_commands=list(filter(is_device_command, feature_set.commands))
|
||||
)
|
||||
|
||||
return args
|
||||
|
||||
def get_templates(self, spec, feature_set, config):
|
||||
header = 'include/glad/{}.h'.format(feature_set.name)
|
||||
source = 'src/{}.c'.format(feature_set.name)
|
||||
|
||||
templates = list()
|
||||
|
||||
if config['HEADER_ONLY']:
|
||||
templates.extend([
|
||||
('header_only.h', header)
|
||||
])
|
||||
else:
|
||||
templates.extend([
|
||||
('{}.h'.format(spec.name), header),
|
||||
('{}.c'.format(spec.name), source)
|
||||
])
|
||||
|
||||
return templates
|
||||
|
||||
def post_generate(self, spec, feature_set, config):
|
||||
self._add_additional_headers(feature_set, config)
|
||||
|
||||
def modify_feature_set(self, spec, feature_set, config):
|
||||
# TODO this takes rather long (~30%), maybe drop it?
|
||||
feature_set = copy.deepcopy(feature_set)
|
||||
|
||||
self._fix_issue_70(feature_set)
|
||||
self._fix_cpp_style_comments(feature_set)
|
||||
self._fixup_enums(feature_set)
|
||||
self._add_header_requirements(feature_set)
|
||||
self._replace_included_headers(feature_set, config)
|
||||
|
||||
return feature_set
|
||||
|
||||
def _fix_issue_70(self, feature_set):
|
||||
"""
|
||||
See issue #70: https://github.com/Dav1dde/glad/issues/70
|
||||
> it seems OSX already includes GLsizeiptr and a few others.
|
||||
> The same problem happens with glad.h as well.
|
||||
> The workaround appears to be to use long instead of ptrdiff_t.
|
||||
"""
|
||||
for type_name in ('GLsizeiptr', 'GLintptr', 'GLsizeiptrARB', 'GLintptrARB'):
|
||||
if type_name in feature_set.types:
|
||||
index = feature_set.types.index(type_name)
|
||||
type_ = copy.deepcopy(feature_set.types[index])
|
||||
type_._raw = \
|
||||
'#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) ' + \
|
||||
'&& (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)\n' + \
|
||||
type_._raw.replace('ptrdiff_t', 'long') + '\n#else\n' + type_._raw + '\n#endif'
|
||||
feature_set.types[index] = type_
|
||||
|
||||
def _fix_cpp_style_comments(self, feature_set):
|
||||
"""
|
||||
Turns CPP-Style comments `//` into C90 compatible comments `/**/`
|
||||
|
||||
Currently the only "workaround" needed to make Vulkan compile with -ansi.
|
||||
See also: https://github.com/KhronosGroup/Vulkan-Docs/pull/700
|
||||
"""
|
||||
for i, type_ in enumerate(feature_set.types):
|
||||
if '//' in type_._raw:
|
||||
new_type = copy.deepcopy(type_)
|
||||
new_type._raw = replace_cpp_style_comments(new_type._raw)
|
||||
feature_set.types[i] = new_type
|
||||
|
||||
def _fixup_enums(self, feature_set):
|
||||
"""
|
||||
There are some enums which are simply empty:
|
||||
https://github.com/KhronosGroup/Vulkan-Docs/issues/1754
|
||||
they need to be removed, we need to also remove any type which is an alias to that empty enum.
|
||||
|
||||
Additionally we need to extend type information for enum alias types,
|
||||
if the alias points to an enum with bitwidth 64 copy over the
|
||||
bitwidth information so we can later produce the correct typedef.
|
||||
"""
|
||||
bitwidth_64 = set()
|
||||
to_remove = set()
|
||||
|
||||
for typ in (t for t in feature_set.types if isinstance(t, EnumType)):
|
||||
if typ.bitwidth == '64':
|
||||
bitwidth_64.add(typ.name)
|
||||
if typ.alias is None and not typ.enums_for(feature_set):
|
||||
to_remove.add(typ.name)
|
||||
|
||||
new_types = []
|
||||
for typ in feature_set.types:
|
||||
if typ.alias:
|
||||
if typ.alias in bitwidth_64:
|
||||
typ.bitwidth = '64'
|
||||
|
||||
if typ.name not in to_remove and typ.alias not in to_remove:
|
||||
new_types.append(typ)
|
||||
|
||||
feature_set.types = new_types
|
||||
|
||||
def _replace_included_headers(self, feature_set, config):
|
||||
if not config['HEADER_ONLY']:
|
||||
return feature_set
|
||||
|
||||
types = feature_set.types
|
||||
for header in self.ADDITIONAL_HEADERS:
|
||||
try:
|
||||
type_index = types.index(header.name)
|
||||
except ValueError:
|
||||
continue
|
||||
|
||||
content = self._read_header(header.url)
|
||||
for pheader in self.ADDITIONAL_HEADERS:
|
||||
name = pheader.name.rsplit('/', 1)[-1]
|
||||
content = re.sub(
|
||||
'^(#include\\s*["<]({}|{})(\\.h)?[>"])'.format(name, pheader.include), r'/* \1 */',
|
||||
content,
|
||||
flags=re.MULTILINE
|
||||
)
|
||||
|
||||
types[type_index] = Type(header.name, raw=content)
|
||||
|
||||
def _add_header_requirements(self, feature_set):
|
||||
added = set()
|
||||
|
||||
for header in self.ADDITIONAL_HEADERS:
|
||||
if header.name not in feature_set.types:
|
||||
continue
|
||||
|
||||
for require in (header.requires or []):
|
||||
if require not in added:
|
||||
t = Type(require, raw="#include \"{}\"".format(require))
|
||||
feature_set.types.insert(0, t)
|
||||
added.add(require)
|
||||
|
||||
def _add_additional_headers(self, feature_set, config):
|
||||
if config['HEADER_ONLY']:
|
||||
return
|
||||
|
||||
for header in self.ADDITIONAL_HEADERS:
|
||||
if header.name not in feature_set.types:
|
||||
continue
|
||||
|
||||
path = os.path.join(self.path, 'include/{}'.format(header.include))
|
||||
|
||||
directory_path = os.path.split(path)[0]
|
||||
if not os.path.exists(directory_path):
|
||||
os.makedirs(directory_path)
|
||||
|
||||
if not os.path.exists(path):
|
||||
content = self._read_header(header.url)
|
||||
with open(path, 'wb') as dest:
|
||||
dest.write(content.encode('utf-8'))
|
||||
|
||||
def _read_header(self, url):
|
||||
if url not in self._headers:
|
||||
with closing(self.opener.urlopen(url)) as src:
|
||||
header = src.read().decode('utf-8')
|
||||
|
||||
header = replace_cpp_style_comments(header)
|
||||
self._headers[url] = header
|
||||
|
||||
return self._headers[url]
|
||||
|
||||
195
third-party/glad/glad/generator/c/templates/base_template.c
vendored
Normal file
195
third-party/glad/glad/generator/c/templates/base_template.c
vendored
Normal file
@@ -0,0 +1,195 @@
|
||||
{% import 'template_utils.h' as template_utils with context %}
|
||||
/**
|
||||
* SPDX-License-Identifier: (WTFPL OR CC0-1.0) AND Apache-2.0
|
||||
*/
|
||||
{% block includes %}
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
{% if not options.header_only %}
|
||||
{% block glad_include %}
|
||||
#include <glad/{{ feature_set.name }}.h>
|
||||
{% endblock %}
|
||||
{% endif %}
|
||||
|
||||
{% include 'impl_util.c' %}
|
||||
{% endblock %}
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
{% set global_context = 'glad_' + feature_set.name + '_context' -%}
|
||||
|
||||
{% block variables %}
|
||||
{% if options.mx_global %}
|
||||
{% call template_utils.zero_initialized() %}Glad{{ feature_set.name|api }}Context {{ global_context }}_static{% endcall %}
|
||||
Glad{{ feature_set.name|api }}Context* {{ global_context }} = &{{ global_context }}_static;
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block extensions %}
|
||||
{% if not options.mx and not options.on_demand %}
|
||||
{% for extension in chain(feature_set.features, feature_set.extensions) %}
|
||||
{% call template_utils.protect(extension) %}
|
||||
int GLAD_{{ extension.name }} = 0;
|
||||
{% endcall %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block on_demand %}
|
||||
{% if options.on_demand %}
|
||||
{% for api in feature_set.info.apis %}
|
||||
{% if options.loader %}
|
||||
static GLADapiproc glad_{{ api }}_internal_loader_get_proc(const char *name);
|
||||
static GLADloadfunc glad_global_on_demand_{{ api }}_loader_func = glad_{{ api }}_internal_loader_get_proc;
|
||||
{% else %}
|
||||
static GLADloadfunc glad_global_on_demand_{{ api }}_loader_func = NULL;
|
||||
{% endif %}
|
||||
|
||||
void gladSet{{ api|api }}OnDemandLoader(GLADloadfunc loader) {
|
||||
glad_global_on_demand_{{ api }}_loader_func = loader;
|
||||
}
|
||||
{% endfor %}
|
||||
|
||||
static GLADapiproc glad_{{ spec.name }}_on_demand_loader(const char *name) {
|
||||
GLADapiproc result = NULL;
|
||||
{% for api in feature_set.info.apis %}
|
||||
if (result == NULL && glad_global_on_demand_{{ api }}_loader_func != NULL) {
|
||||
result = glad_global_on_demand_{{ api }}_loader_func(name);
|
||||
}
|
||||
{% endfor %}
|
||||
/* this provokes a segmentation fault if there was no loader or no loader returned something useful */
|
||||
return result;
|
||||
}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block debug %}
|
||||
{% if options.debug %}
|
||||
{% block debug_default_pre %}
|
||||
static void _pre_call_{{ feature_set.name }}_callback_default(const char *name, GLADapiproc apiproc, int len_args, ...) {
|
||||
GLAD_UNUSED(name);
|
||||
GLAD_UNUSED(apiproc);
|
||||
GLAD_UNUSED(len_args);
|
||||
}
|
||||
{% endblock %}
|
||||
{% block debug_default_post %}
|
||||
static void _post_call_{{ feature_set.name }}_callback_default(void *ret, const char *name, GLADapiproc apiproc, int len_args, ...) {
|
||||
GLAD_UNUSED(ret);
|
||||
GLAD_UNUSED(name);
|
||||
GLAD_UNUSED(apiproc);
|
||||
GLAD_UNUSED(len_args);
|
||||
}
|
||||
{% endblock %}
|
||||
|
||||
static GLADprecallback _pre_call_{{ feature_set.name }}_callback = _pre_call_{{ feature_set.name }}_callback_default;
|
||||
void gladSet{{ feature_set.name|api }}PreCallback(GLADprecallback cb) {
|
||||
_pre_call_{{ feature_set.name }}_callback = cb;
|
||||
}
|
||||
static GLADpostcallback _post_call_{{ feature_set.name }}_callback = _post_call_{{ feature_set.name }}_callback_default;
|
||||
void gladSet{{ feature_set.name|api }}PostCallback(GLADpostcallback cb) {
|
||||
_post_call_{{ feature_set.name }}_callback = cb;
|
||||
}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% if not options.mx %}
|
||||
{% block commands %}
|
||||
{% for command in feature_set.commands|c_commands %}
|
||||
{% call template_utils.protect(command) %}
|
||||
{% if options.on_demand %}
|
||||
static {{ command.proto.ret|type_to_c }} GLAD_API_PTR glad_on_demand_impl_{{ command.name }}({{ command.params|params_to_c }}) {
|
||||
glad_{{ command.name }} = ({{ command.name|pfn }}) glad_{{ spec.name }}_on_demand_loader("{{ command.name }}");
|
||||
{% if command.proto.ret is void %}
|
||||
glad_{{ command.name }}({{ command.params|param_names }});
|
||||
{% else %}
|
||||
return glad_{{ command.name }}({{ command.params|param_names }});
|
||||
{% endif %}
|
||||
}
|
||||
{{ command.name|pfn }} glad_{{ command.name }} = glad_on_demand_impl_{{ command.name }};
|
||||
{% else %}
|
||||
{{ command.name|pfn }} glad_{{ command.name }} = NULL;
|
||||
{% endif %}
|
||||
{% if options.debug %}
|
||||
{% set impl = get_debug_impl(command, command.name|ctx(context=global_context)) %}
|
||||
static {{ command.proto.ret|type_to_c }} GLAD_API_PTR glad_debug_impl_{{ command.name }}({{ impl.impl }}) {
|
||||
{{ impl.ret.declaration }}_pre_call_{{ feature_set.name }}_callback({{ impl.pre_callback }});
|
||||
{{ impl.ret.assignment }}{{ command.name|ctx(context=global_context) }}({{ impl.function }});
|
||||
_post_call_{{ feature_set.name }}_callback({{ impl.post_callback }});
|
||||
{{ impl.ret.ret }}
|
||||
}
|
||||
{{ command.name|pfn }} glad_debug_{{ command.name }} = glad_debug_impl_{{ command.name }};
|
||||
{% endif %}
|
||||
{% endcall %}
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% if not options.on_demand %}
|
||||
{% block extension_loaders %}
|
||||
{% for extension, commands in loadable() %}
|
||||
{% call template_utils.protect(extension) %}
|
||||
static void glad_{{ spec.name }}_load_{{ extension.name }}({{ template_utils.context_arg(',') }} GLADuserptrloadfunc load, void* userptr) {
|
||||
if(!{{ ('GLAD_' + extension.name)|ctx(name_only=True) }}) return;
|
||||
{% for command in commands %}
|
||||
{{ command.name|ctx }} = ({{ command.name|pfn }}) load(userptr, "{{ command.name }}");
|
||||
{% endfor %}
|
||||
}
|
||||
{% endcall %}
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block aliasing %}
|
||||
{% if options.alias %}
|
||||
static void glad_{{ spec.name }}_resolve_aliases({{ template_utils.context_arg(def='void') }}) {
|
||||
{% for command in feature_set.commands|sort(attribute='name') %}
|
||||
{% call template_utils.protect(command) %}
|
||||
{% for alias in aliases.get(command.name, [])|reject('equalto', command.name) %}
|
||||
{% call template_utils.protect(alias) %}
|
||||
if ({{ command.name|ctx }} == NULL && {{ alias|ctx }} != NULL) {{ command.name|ctx }} = ({{ command.name|pfn }}){{ alias|ctx }};
|
||||
{% endcall %}
|
||||
{% endfor %}
|
||||
{% endcall %}
|
||||
{% endfor %}
|
||||
}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block loader %}
|
||||
{% endblock %}
|
||||
{% endif %} {# options.on_demand #}
|
||||
|
||||
{% if options.debug %}
|
||||
void gladInstall{{ feature_set.name|api }}Debug(void) {
|
||||
{% for command in feature_set.commands|c_commands %}
|
||||
{% call template_utils.protect(command) %}
|
||||
glad_debug_{{ command.name }} = glad_debug_impl_{{ command.name }};
|
||||
{% endcall %}
|
||||
{% endfor %}
|
||||
}
|
||||
|
||||
void gladUninstall{{ feature_set.name|api }}Debug(void) {
|
||||
{% for command in feature_set.commands|c_commands %}
|
||||
{% call template_utils.protect(command) %}
|
||||
glad_debug_{{ command.name }} = glad_{{ command.name }};
|
||||
{% endcall %}
|
||||
{% endfor %}
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
{% if options.loader %}
|
||||
{% block loader_impl %}
|
||||
{% for api in feature_set.info.apis %}
|
||||
{% include 'loader/' + api + '.c' %}
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
{% endif %}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
139
third-party/glad/glad/generator/c/templates/base_template.h
vendored
Normal file
139
third-party/glad/glad/generator/c/templates/base_template.h
vendored
Normal file
@@ -0,0 +1,139 @@
|
||||
{% import "template_utils.h" as template_utils with context %}
|
||||
{% block TODO %}
|
||||
/**
|
||||
* Loader generated by glad {{ gen_info.version }} on {{ gen_info.when }}
|
||||
*
|
||||
* SPDX-License-Identifier: (WTFPL OR CC0-1.0) AND Apache-2.0
|
||||
*
|
||||
* Generator: {{ gen_info.generator_name }}
|
||||
* Specification: {{ gen_info.specification }}
|
||||
* Extensions: {{ gen_info.extensions|length }}
|
||||
*
|
||||
* APIs:
|
||||
{% for info in gen_info.info %}
|
||||
* - {{ info }}
|
||||
{% endfor %}
|
||||
*
|
||||
* Options:
|
||||
{% for name, value in gen_info.options.items() %}
|
||||
* - {{ name }} = {{ value }}
|
||||
{% endfor %}
|
||||
*
|
||||
* Commandline:
|
||||
* {{ gen_info.commandline }}
|
||||
*
|
||||
* Online:
|
||||
* {{ gen_info.online }}
|
||||
*
|
||||
*/
|
||||
{% endblock %}
|
||||
|
||||
#ifndef GLAD_{{ feature_set.name|upper }}_H_
|
||||
#define GLAD_{{ feature_set.name|upper }}_H_
|
||||
|
||||
{% block header %}
|
||||
{% endblock %}
|
||||
|
||||
#define GLAD_{{ feature_set.name|upper }}
|
||||
{% for option in options %}
|
||||
{% if options[option] %}
|
||||
#define GLAD_OPTION_{{ feature_set.name|upper }}_{{ option|upper }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
{% block platform %}
|
||||
{% include 'platform.h' %}
|
||||
{% endblock %}
|
||||
|
||||
{% block enums %}
|
||||
{{ template_utils.write_enumerations(feature_set.enums) }}
|
||||
{% endblock %}
|
||||
|
||||
{% block types %}
|
||||
{{ template_utils.write_types(feature_set.types) }}
|
||||
{% endblock %}
|
||||
|
||||
{% block feature_information %}
|
||||
{{ template_utils.write_feature_information(chain(feature_set.features, feature_set.extensions), with_runtime=not options.mx and not options.on_demand) }}
|
||||
{% endblock %}
|
||||
|
||||
{% block commands %}
|
||||
{{ template_utils.write_function_typedefs(feature_set.commands) }}
|
||||
{% if not options.mx %}
|
||||
{{ template_utils.write_function_declarations(feature_set.commands, debug=options.debug) }}
|
||||
{% else %}
|
||||
typedef struct Glad{{ feature_set.name|api }}Context {
|
||||
void* userptr;
|
||||
|
||||
{% for extension in chain(feature_set.features, feature_set.extensions) %}
|
||||
int {{ extension.name|ctx(member=True) }};
|
||||
{% endfor %}
|
||||
|
||||
{% for command in feature_set.commands %}
|
||||
{% call template_utils.protect(command) %}
|
||||
{{ command.name|pfn }} {{ command.name|ctx(member=True) }};
|
||||
{% endcall %}
|
||||
{% endfor %}
|
||||
|
||||
{% if options.loader %}
|
||||
void* glad_loader_handle;
|
||||
{% endif %}
|
||||
} Glad{{ feature_set.name|api }}Context;
|
||||
|
||||
{% if options.mx_global %}
|
||||
GLAD_API_CALL Glad{{ feature_set.name|api }}Context* glad_{{ feature_set.name }}_context;
|
||||
|
||||
{% for extension in chain(feature_set.features, feature_set.extensions) %}
|
||||
#define GLAD_{{ extension.name }} (glad_{{ feature_set.name }}_context->{{ extension.name|no_prefix }})
|
||||
{% endfor %}
|
||||
|
||||
{% for command in feature_set.commands %}
|
||||
#define {{ command.name }} (glad_{{ feature_set.name }}_context->{{ command.name|no_prefix }})
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block declarations %}
|
||||
{% if options.on_demand %}
|
||||
{% for api in feature_set.info.apis %}
|
||||
GLAD_API_CALL void gladSet{{ api|api }}OnDemandLoader(GLADloadfunc loader);
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{% if options.mx_global %}
|
||||
Glad{{ feature_set.name|api }}Context* gladGet{{ feature_set.name|api }}Context(void);
|
||||
GLAD_API_CALL void gladSet{{ feature_set.name|api }}Context(Glad{{ feature_set.name|api }}Context *context);
|
||||
{% endif %}
|
||||
|
||||
{% if options.debug %}
|
||||
GLAD_API_CALL void gladSet{{ feature_set.name|api }}PreCallback(GLADprecallback cb);
|
||||
GLAD_API_CALL void gladSet{{ feature_set.name|api }}PostCallback(GLADpostcallback cb);
|
||||
|
||||
GLAD_API_CALL void gladInstall{{ feature_set.name|api }}Debug(void);
|
||||
GLAD_API_CALL void gladUninstall{{ feature_set.name|api }}Debug(void);
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% if not options.on_demand %}
|
||||
{% block custom_declarations %}
|
||||
{% endblock %}
|
||||
{% endif %}
|
||||
|
||||
{% if options.loader %}
|
||||
{% block loader_impl %}
|
||||
{% for api in feature_set.info.apis %}
|
||||
{% include 'loader/' + api + '.h' %}
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
{% endif %}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
117
third-party/glad/glad/generator/c/templates/egl.c
vendored
Normal file
117
third-party/glad/glad/generator/c/templates/egl.c
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
{% extends 'base_template.c' %}
|
||||
|
||||
{% block loader %}
|
||||
static int glad_egl_get_extensions(EGLDisplay display, const char **extensions) {
|
||||
*extensions = eglQueryString(display, EGL_EXTENSIONS);
|
||||
|
||||
return extensions != NULL;
|
||||
}
|
||||
|
||||
static int glad_egl_has_extension(const char *extensions, const char *ext) {
|
||||
const char *loc;
|
||||
const char *terminator;
|
||||
if(extensions == NULL) {
|
||||
return 0;
|
||||
}
|
||||
while(1) {
|
||||
loc = strstr(extensions, ext);
|
||||
if(loc == NULL) {
|
||||
return 0;
|
||||
}
|
||||
terminator = loc + strlen(ext);
|
||||
if((loc == extensions || *(loc - 1) == ' ') &&
|
||||
(*terminator == ' ' || *terminator == '\0')) {
|
||||
return 1;
|
||||
}
|
||||
extensions = terminator;
|
||||
}
|
||||
}
|
||||
|
||||
static GLADapiproc glad_egl_get_proc_from_userptr(void *userptr, const char *name) {
|
||||
return (GLAD_GNUC_EXTENSION (GLADapiproc (*)(const char *name)) userptr)(name);
|
||||
}
|
||||
|
||||
{% for api in feature_set.info.apis %}
|
||||
static int glad_egl_find_extensions_{{ api|lower }}(EGLDisplay display) {
|
||||
const char *extensions;
|
||||
if (!glad_egl_get_extensions(display, &extensions)) return 0;
|
||||
|
||||
{% for extension in feature_set.extensions %}
|
||||
GLAD_{{ extension.name }} = glad_egl_has_extension(extensions, "{{ extension.name }}");
|
||||
{% else %}
|
||||
GLAD_UNUSED(&glad_egl_has_extension);
|
||||
{% endfor %}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int glad_egl_find_core_{{ api|lower }}(EGLDisplay display) {
|
||||
int major, minor;
|
||||
const char *version;
|
||||
|
||||
if (display == NULL) {
|
||||
display = EGL_NO_DISPLAY; /* this is usually NULL, better safe than sorry */
|
||||
}
|
||||
if (display == EGL_NO_DISPLAY) {
|
||||
display = eglGetCurrentDisplay();
|
||||
}
|
||||
#ifdef EGL_VERSION_1_4
|
||||
if (display == EGL_NO_DISPLAY) {
|
||||
display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
}
|
||||
#endif
|
||||
#ifndef EGL_VERSION_1_5
|
||||
if (display == EGL_NO_DISPLAY) {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
version = eglQueryString(display, EGL_VERSION);
|
||||
(void) eglGetError();
|
||||
|
||||
if (version == NULL) {
|
||||
major = 1;
|
||||
minor = 0;
|
||||
} else {
|
||||
GLAD_IMPL_UTIL_SSCANF(version, "%d.%d", &major, &minor);
|
||||
}
|
||||
|
||||
{% for feature in feature_set.features %}
|
||||
GLAD_{{ feature.name }} = (major == {{ feature.version.major }} && minor >= {{ feature.version.minor }}) || major > {{ feature.version.major }};
|
||||
{% endfor %}
|
||||
|
||||
return GLAD_MAKE_VERSION(major, minor);
|
||||
}
|
||||
|
||||
int gladLoad{{ api|api }}UserPtr(EGLDisplay display, GLADuserptrloadfunc load, void* userptr) {
|
||||
int version;
|
||||
eglGetDisplay = (PFNEGLGETDISPLAYPROC) load(userptr, "eglGetDisplay");
|
||||
eglGetCurrentDisplay = (PFNEGLGETCURRENTDISPLAYPROC) load(userptr, "eglGetCurrentDisplay");
|
||||
eglQueryString = (PFNEGLQUERYSTRINGPROC) load(userptr, "eglQueryString");
|
||||
eglGetError = (PFNEGLGETERRORPROC) load(userptr, "eglGetError");
|
||||
if (eglGetDisplay == NULL || eglGetCurrentDisplay == NULL || eglQueryString == NULL || eglGetError == NULL) return 0;
|
||||
|
||||
version = glad_egl_find_core_{{ api|lower }}(display);
|
||||
if (!version) return 0;
|
||||
{% for feature, _ in loadable(feature_set.features) %}
|
||||
glad_egl_load_{{ feature.name }}(load, userptr);
|
||||
{% endfor %}
|
||||
|
||||
if (!glad_egl_find_extensions_{{ api|lower }}(display)) return 0;
|
||||
{% for extension, _ in loadable(feature_set.extensions) %}
|
||||
glad_egl_load_{{ extension.name }}(load, userptr);
|
||||
{% endfor %}
|
||||
|
||||
{% if options.alias %}
|
||||
glad_egl_resolve_aliases();
|
||||
{% endif %}
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
int gladLoad{{ api|api }}(EGLDisplay display, GLADloadfunc load) {
|
||||
return gladLoad{{ api|api }}UserPtr(display, glad_egl_get_proc_from_userptr, GLAD_GNUC_EXTENSION (void*) load);
|
||||
}
|
||||
{% endfor %}
|
||||
|
||||
{% endblock %}
|
||||
8
third-party/glad/glad/generator/c/templates/egl.h
vendored
Normal file
8
third-party/glad/glad/generator/c/templates/egl.h
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
{% extends 'base_template.h' %}
|
||||
|
||||
{% block custom_declarations %}
|
||||
{% for api in feature_set.info.apis %}
|
||||
GLAD_API_CALL int gladLoad{{ api|api }}UserPtr(EGLDisplay display, GLADuserptrloadfunc load, void *userptr);
|
||||
GLAD_API_CALL int gladLoad{{ api|api }}(EGLDisplay display, GLADloadfunc load);
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
228
third-party/glad/glad/generator/c/templates/gl.c
vendored
Normal file
228
third-party/glad/glad/generator/c/templates/gl.c
vendored
Normal file
@@ -0,0 +1,228 @@
|
||||
{% extends 'base_template.c' %}
|
||||
|
||||
|
||||
{% block debug_default_pre %}
|
||||
static void _pre_call_{{ feature_set.name }}_callback_default(const char *name, GLADapiproc apiproc, int len_args, ...) {
|
||||
GLAD_UNUSED(len_args);
|
||||
|
||||
if (apiproc == NULL) {
|
||||
fprintf(stderr, "GLAD: ERROR %s is NULL!\n", name);
|
||||
return;
|
||||
}
|
||||
if (glad_glGetError == NULL) {
|
||||
fprintf(stderr, "GLAD: ERROR glGetError is NULL!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
(void) glad_glGetError();
|
||||
}
|
||||
{% endblock %}
|
||||
|
||||
{% block debug_default_post %}
|
||||
static void _post_call_{{ feature_set.name }}_callback_default(void *ret, const char *name, GLADapiproc apiproc, int len_args, ...) {
|
||||
GLenum error_code;
|
||||
|
||||
GLAD_UNUSED(ret);
|
||||
GLAD_UNUSED(apiproc);
|
||||
GLAD_UNUSED(len_args);
|
||||
|
||||
error_code = glad_glGetError();
|
||||
|
||||
if (error_code != GL_NO_ERROR) {
|
||||
fprintf(stderr, "GLAD: ERROR %d in %s!\n", error_code, name);
|
||||
}
|
||||
}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block loader %}
|
||||
static void glad_gl_free_extensions(char **exts_i) {
|
||||
if (exts_i != NULL) {
|
||||
unsigned int index;
|
||||
for(index = 0; exts_i[index]; index++) {
|
||||
free((void *) (exts_i[index]));
|
||||
}
|
||||
free((void *)exts_i);
|
||||
exts_i = NULL;
|
||||
}
|
||||
}
|
||||
static int glad_gl_get_extensions({{ template_utils.context_arg(',') }} const char **out_exts, char ***out_exts_i) {
|
||||
#if defined(GL_ES_VERSION_3_0) || defined(GL_VERSION_3_0)
|
||||
if ({{ 'glGetStringi'|ctx }} != NULL && {{ 'glGetIntegerv'|ctx }} != NULL) {
|
||||
unsigned int index = 0;
|
||||
unsigned int num_exts_i = 0;
|
||||
char **exts_i = NULL;
|
||||
{{ 'glGetIntegerv'|ctx }}(GL_NUM_EXTENSIONS, (int*) &num_exts_i);
|
||||
exts_i = (char **) malloc((num_exts_i + 1) * (sizeof *exts_i));
|
||||
if (exts_i == NULL) {
|
||||
return 0;
|
||||
}
|
||||
for(index = 0; index < num_exts_i; index++) {
|
||||
const char *gl_str_tmp = (const char*) {{ 'glGetStringi'|ctx }}(GL_EXTENSIONS, index);
|
||||
size_t len = strlen(gl_str_tmp) + 1;
|
||||
|
||||
char *local_str = (char*) malloc(len * sizeof(char));
|
||||
if(local_str == NULL) {
|
||||
exts_i[index] = NULL;
|
||||
glad_gl_free_extensions(exts_i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
memcpy(local_str, gl_str_tmp, len * sizeof(char));
|
||||
exts_i[index] = local_str;
|
||||
}
|
||||
exts_i[index] = NULL;
|
||||
|
||||
*out_exts_i = exts_i;
|
||||
|
||||
return 1;
|
||||
}
|
||||
#else
|
||||
GLAD_UNUSED(out_exts_i);
|
||||
#endif
|
||||
if ({{ 'glGetString'|ctx }} == NULL) {
|
||||
return 0;
|
||||
}
|
||||
*out_exts = (const char *){{ 'glGetString'|ctx }}(GL_EXTENSIONS);
|
||||
return 1;
|
||||
}
|
||||
static int glad_gl_has_extension(const char *exts, char **exts_i, const char *ext) {
|
||||
if(exts_i) {
|
||||
unsigned int index;
|
||||
for(index = 0; exts_i[index]; index++) {
|
||||
const char *e = exts_i[index];
|
||||
if(strcmp(e, ext) == 0) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const char *extensions;
|
||||
const char *loc;
|
||||
const char *terminator;
|
||||
extensions = exts;
|
||||
if(extensions == NULL || ext == NULL) {
|
||||
return 0;
|
||||
}
|
||||
while(1) {
|
||||
loc = strstr(extensions, ext);
|
||||
if(loc == NULL) {
|
||||
return 0;
|
||||
}
|
||||
terminator = loc + strlen(ext);
|
||||
if((loc == extensions || *(loc - 1) == ' ') &&
|
||||
(*terminator == ' ' || *terminator == '\0')) {
|
||||
return 1;
|
||||
}
|
||||
extensions = terminator;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static GLADapiproc glad_gl_get_proc_from_userptr(void *userptr, const char* name) {
|
||||
return (GLAD_GNUC_EXTENSION (GLADapiproc (*)(const char *name)) userptr)(name);
|
||||
}
|
||||
|
||||
{% for api in feature_set.info.apis %}
|
||||
static int glad_gl_find_extensions_{{ api|lower }}({{ template_utils.context_arg(def='void') }}) {
|
||||
const char *exts = NULL;
|
||||
char **exts_i = NULL;
|
||||
if (!glad_gl_get_extensions({{ 'context, ' if options.mx }}&exts, &exts_i)) return 0;
|
||||
|
||||
{% for extension in feature_set.extensions|select('supports', api) %}
|
||||
{{ ('GLAD_' + extension.name)|ctx(name_only=True) }} = glad_gl_has_extension(exts, exts_i, "{{ extension.name }}");
|
||||
{% else %}
|
||||
GLAD_UNUSED(&glad_gl_has_extension);
|
||||
{% endfor %}
|
||||
|
||||
glad_gl_free_extensions(exts_i);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int glad_gl_find_core_{{ api|lower }}({{ template_utils.context_arg(def='void') }}) {
|
||||
int i;
|
||||
const char* version;
|
||||
const char* prefixes[] = {
|
||||
"OpenGL ES-CM ",
|
||||
"OpenGL ES-CL ",
|
||||
"OpenGL ES ",
|
||||
"OpenGL SC ",
|
||||
NULL
|
||||
};
|
||||
int major = 0;
|
||||
int minor = 0;
|
||||
version = (const char*) {{ 'glGetString'|ctx }}(GL_VERSION);
|
||||
if (!version) return 0;
|
||||
for (i = 0; prefixes[i]; i++) {
|
||||
const size_t length = strlen(prefixes[i]);
|
||||
if (strncmp(version, prefixes[i], length) == 0) {
|
||||
version += length;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
GLAD_IMPL_UTIL_SSCANF(version, "%d.%d", &major, &minor);
|
||||
|
||||
{% for feature in feature_set.features|select('supports', api) %}
|
||||
{{ ('GLAD_' + feature.name)|ctx(name_only=True) }} = (major == {{ feature.version.major }} && minor >= {{ feature.version.minor }}) || major > {{ feature.version.major }};
|
||||
{% endfor %}
|
||||
|
||||
return GLAD_MAKE_VERSION(major, minor);
|
||||
}
|
||||
|
||||
int gladLoad{{ api|api }}{{ 'Context' if options.mx }}UserPtr({{ template_utils.context_arg(',') }} GLADuserptrloadfunc load, void *userptr) {
|
||||
int version;
|
||||
|
||||
{{ 'glGetString'|ctx }} = (PFNGLGETSTRINGPROC) load(userptr, "glGetString");
|
||||
if({{ 'glGetString'|ctx }} == NULL) return 0;
|
||||
version = glad_gl_find_core_{{ api|lower }}({{ 'context' if options.mx }});
|
||||
|
||||
{% for feature, _ in loadable(feature_set.features, api=api) %}
|
||||
glad_gl_load_{{ feature.name }}({{'context, ' if options.mx }}load, userptr);
|
||||
{% endfor %}
|
||||
|
||||
if (!glad_gl_find_extensions_{{ api|lower }}({{ 'context' if options.mx }})) return 0;
|
||||
{% for extension, _ in loadable(feature_set.extensions, api=api) %}
|
||||
glad_gl_load_{{ extension.name }}({{'context, ' if options.mx }}load, userptr);
|
||||
{% endfor %}
|
||||
|
||||
{% if options.mx_global %}
|
||||
gladSet{{ feature_set.name|api }}Context(context);
|
||||
{% endif %}
|
||||
|
||||
{% if options.alias %}
|
||||
glad_gl_resolve_aliases({{ 'context' if options.mx }});
|
||||
{% endif %}
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
{% if options.mx_global %}
|
||||
int gladLoad{{ api|api }}UserPtr(GLADuserptrloadfunc load, void *userptr) {
|
||||
return gladLoad{{ api|api }}ContextUserPtr(gladGet{{ feature_set.name|api }}Context(), load, userptr);
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
int gladLoad{{ api|api }}{{ 'Context' if options.mx }}({{ template_utils.context_arg(',') }} GLADloadfunc load) {
|
||||
return gladLoad{{ api|api }}{{ 'Context' if options.mx }}UserPtr({{'context,' if options.mx }} glad_gl_get_proc_from_userptr, GLAD_GNUC_EXTENSION (void*) load);
|
||||
}
|
||||
|
||||
{% if options.mx_global %}
|
||||
int gladLoad{{ api|api }}(GLADloadfunc load) {
|
||||
return gladLoad{{ api|api }}Context(gladGet{{ feature_set.name|api }}Context(), load);
|
||||
}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% if options.mx_global %}
|
||||
Glad{{ feature_set.name|api }}Context* gladGet{{ feature_set.name|api }}Context() {
|
||||
return {{ global_context }};
|
||||
}
|
||||
|
||||
void gladSet{{ feature_set.name|api }}Context(Glad{{ feature_set.name|api }}Context *context) {
|
||||
{{ global_context }} = context;
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
38
third-party/glad/glad/generator/c/templates/gl.h
vendored
Normal file
38
third-party/glad/glad/generator/c/templates/gl.h
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
{% extends 'base_template.h' %}
|
||||
|
||||
{% block header %}
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wreserved-id-macro"
|
||||
#endif
|
||||
{% set header_data = [
|
||||
('gl', '__gl_h_', 'OpenGL (gl.h)'), ('gl', '__gl3_h_', 'OpenGL (gl3.h)'),
|
||||
('gl', '__glext_h_', 'OpenGL (glext.h)'), ('gl', '__gl3ext_h_', 'OpenGL (gl3ext.h)'),
|
||||
('gles1', '__gl_h_', 'OpenGL ES 1'), ('gles1', '__gles1_gl_h_', 'OpenGL ES 1'),
|
||||
('gles2', '__gl2_h_', 'OpenGL ES 2'), ('gles2', '__gles2_gl2_h_', 'OpenGL ES 2'),
|
||||
('gles2', '__gl3_h_', 'OpenGL ES 3'), ('gles2', '__gles2_gl3_h_', 'OpenGL ES 3'),
|
||||
] %}
|
||||
{% set written = [] %}
|
||||
{% for api, header_name, name in header_data %}
|
||||
{% if api in feature_set.info.apis and header_name not in written -%}
|
||||
{{ template_utils.header_error(api, header_name, name) }}
|
||||
{%- do written.append(header_name) -%}
|
||||
{%- endif -%}
|
||||
{%- endfor -%}
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block custom_declarations %}
|
||||
{% for api in feature_set.info.apis %}
|
||||
GLAD_API_CALL int gladLoad{{ api|api }}{{ 'Context' if options.mx }}UserPtr({{ template_utils.context_arg(',') }} GLADuserptrloadfunc load, void *userptr);
|
||||
GLAD_API_CALL int gladLoad{{ api|api }}{{ 'Context' if options.mx }}({{ template_utils.context_arg(',') }} GLADloadfunc load);
|
||||
|
||||
{% if options.mx_global %}
|
||||
GLAD_API_CALL int gladLoad{{ api|api }}UserPtr(GLADuserptrloadfunc load, void *userptr);
|
||||
GLAD_API_CALL int gladLoad{{ api|api }}(GLADloadfunc load);
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
103
third-party/glad/glad/generator/c/templates/glx.c
vendored
Normal file
103
third-party/glad/glad/generator/c/templates/glx.c
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
{% extends 'base_template.c' %}
|
||||
|
||||
{% block loader %}
|
||||
static int glad_glx_has_extension(Display *display, int screen, const char *ext) {
|
||||
#ifndef GLX_VERSION_1_1
|
||||
GLAD_UNUSED(display);
|
||||
GLAD_UNUSED(screen);
|
||||
GLAD_UNUSED(ext);
|
||||
#else
|
||||
const char *terminator;
|
||||
const char *loc;
|
||||
const char *extensions;
|
||||
|
||||
if (glXQueryExtensionsString == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
extensions = glXQueryExtensionsString(display, screen);
|
||||
|
||||
if(extensions == NULL || ext == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
while(1) {
|
||||
loc = strstr(extensions, ext);
|
||||
if(loc == NULL)
|
||||
break;
|
||||
|
||||
terminator = loc + strlen(ext);
|
||||
if((loc == extensions || *(loc - 1) == ' ') &&
|
||||
(*terminator == ' ' || *terminator == '\0')) {
|
||||
return 1;
|
||||
}
|
||||
extensions = terminator;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static GLADapiproc glad_glx_get_proc_from_userptr(void *userptr, const char* name) {
|
||||
return (GLAD_GNUC_EXTENSION (GLADapiproc (*)(const char *name)) userptr)(name);
|
||||
}
|
||||
|
||||
{% for api in feature_set.info.apis %}
|
||||
static int glad_glx_find_extensions(Display *display, int screen) {
|
||||
{% for extension in feature_set.extensions %}
|
||||
GLAD_{{ extension.name }} = glad_glx_has_extension(display, screen, "{{ extension.name }}");
|
||||
{% else %}
|
||||
GLAD_UNUSED(&glad_glx_has_extension);
|
||||
{% endfor %}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int glad_glx_find_core_{{ api|lower }}(Display **display, int *screen) {
|
||||
int major = 0, minor = 0;
|
||||
if(*display == NULL) {
|
||||
#ifdef GLAD_GLX_NO_X11
|
||||
GLAD_UNUSED(screen);
|
||||
return 0;
|
||||
#else
|
||||
*display = XOpenDisplay(0);
|
||||
if (*display == NULL) {
|
||||
return 0;
|
||||
}
|
||||
*screen = XScreenNumberOfScreen(XDefaultScreenOfDisplay(*display));
|
||||
#endif
|
||||
}
|
||||
glXQueryVersion(*display, &major, &minor);
|
||||
{% for feature in feature_set.features %}
|
||||
GLAD_{{ feature.name }} = (major == {{ feature.version.major }} && minor >= {{ feature.version.minor }}) || major > {{ feature.version.major }};
|
||||
{% endfor %}
|
||||
return GLAD_MAKE_VERSION(major, minor);
|
||||
}
|
||||
|
||||
int gladLoad{{ api|api }}UserPtr(Display *display, int screen, GLADuserptrloadfunc load, void *userptr) {
|
||||
int version;
|
||||
glXQueryVersion = (PFNGLXQUERYVERSIONPROC) load(userptr, "glXQueryVersion");
|
||||
if(glXQueryVersion == NULL) return 0;
|
||||
version = glad_glx_find_core_{{ api|lower }}(&display, &screen);
|
||||
|
||||
{% for feature, _ in loadable(feature_set.features) %}
|
||||
glad_glx_load_{{ feature.name }}(load, userptr);
|
||||
{% endfor %}
|
||||
|
||||
if (!glad_glx_find_extensions(display, screen)) return 0;
|
||||
{% for extension, _ in loadable(feature_set.extensions) %}
|
||||
glad_glx_load_{{ extension.name }}(load, userptr);
|
||||
{% endfor %}
|
||||
|
||||
{% if options.alias %}
|
||||
glad_glx_resolve_aliases();
|
||||
{% endif %}
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
int gladLoad{{ api|api }}(Display *display, int screen, GLADloadfunc load) {
|
||||
return gladLoad{{ api|api }}UserPtr(display, screen, glad_glx_get_proc_from_userptr, GLAD_GNUC_EXTENSION (void*) load);
|
||||
}
|
||||
{% endfor %}
|
||||
|
||||
{% endblock %}
|
||||
19
third-party/glad/glad/generator/c/templates/glx.h
vendored
Normal file
19
third-party/glad/glad/generator/c/templates/glx.h
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
{% extends 'base_template.h' %}
|
||||
|
||||
{% block header %}
|
||||
{{ template_utils.header_error(feature_set.name, feature_set.name|upper + '_H', feature_set.name|api) }}
|
||||
|
||||
#include <X11/X.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
#include <glad/gl.h>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block custom_declarations %}
|
||||
{% for api in feature_set.info.apis %}
|
||||
GLAD_API_CALL int gladLoad{{ api|api }}UserPtr(Display *display, int screen, GLADuserptrloadfunc load, void *userptr);
|
||||
GLAD_API_CALL int gladLoad{{ api|api }}(Display *display, int screen, GLADloadfunc load);
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
8
third-party/glad/glad/generator/c/templates/header_only.h
vendored
Normal file
8
third-party/glad/glad/generator/c/templates/header_only.h
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
{% include spec.name + '.h' %}
|
||||
|
||||
/* Source */
|
||||
#ifdef GLAD_{{ feature_set.name|upper }}_IMPLEMENTATION
|
||||
{% include spec.name + '.c' %}
|
||||
|
||||
#endif /* GLAD_{{ feature_set.name|upper }}_IMPLEMENTATION */
|
||||
|
||||
10
third-party/glad/glad/generator/c/templates/impl_util.c
vendored
Normal file
10
third-party/glad/glad/generator/c/templates/impl_util.c
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef GLAD_IMPL_UTIL_C_
|
||||
#define GLAD_IMPL_UTIL_C_
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define GLAD_IMPL_UTIL_SSCANF sscanf_s
|
||||
#else
|
||||
#define GLAD_IMPL_UTIL_SSCANF sscanf
|
||||
#endif
|
||||
|
||||
#endif /* GLAD_IMPL_UTIL_C_ */
|
||||
94
third-party/glad/glad/generator/c/templates/loader/egl.c
vendored
Normal file
94
third-party/glad/glad/generator/c/templates/loader/egl.c
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
{% import "template_utils.h" as template_utils with context %}
|
||||
#ifdef GLAD_EGL
|
||||
|
||||
{% include 'loader/library.c' %}
|
||||
|
||||
struct _glad_egl_userptr {
|
||||
void *handle;
|
||||
PFNEGLGETPROCADDRESSPROC get_proc_address_ptr;
|
||||
};
|
||||
|
||||
static GLADapiproc glad_egl_get_proc(void *vuserptr, const char* name) {
|
||||
struct _glad_egl_userptr userptr = *(struct _glad_egl_userptr*) vuserptr;
|
||||
GLADapiproc result = NULL;
|
||||
|
||||
result = glad_dlsym_handle(userptr.handle, name);
|
||||
if (result == NULL) {
|
||||
result = GLAD_GNUC_EXTENSION (GLADapiproc) userptr.get_proc_address_ptr(name);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void* _egl_handle = NULL;
|
||||
|
||||
static void* glad_egl_dlopen_handle(void) {
|
||||
#if GLAD_PLATFORM_APPLE
|
||||
static const char *NAMES[] = {"libEGL.dylib"};
|
||||
#elif GLAD_PLATFORM_WIN32
|
||||
static const char *NAMES[] = {"libEGL.dll", "EGL.dll"};
|
||||
#else
|
||||
static const char *NAMES[] = {"libEGL.so.1", "libEGL.so"};
|
||||
#endif
|
||||
|
||||
if (_egl_handle == NULL) {
|
||||
_egl_handle = glad_get_dlopen_handle(NAMES, sizeof(NAMES) / sizeof(NAMES[0]));
|
||||
}
|
||||
|
||||
return _egl_handle;
|
||||
}
|
||||
|
||||
static struct _glad_egl_userptr glad_egl_build_userptr(void *handle) {
|
||||
struct _glad_egl_userptr userptr;
|
||||
userptr.handle = handle;
|
||||
userptr.get_proc_address_ptr = (PFNEGLGETPROCADDRESSPROC) glad_dlsym_handle(handle, "eglGetProcAddress");
|
||||
return userptr;
|
||||
}
|
||||
|
||||
{% if not options.on_demand %}
|
||||
int gladLoaderLoadEGL(EGLDisplay display) {
|
||||
int version = 0;
|
||||
void *handle = NULL;
|
||||
int did_load = 0;
|
||||
struct _glad_egl_userptr userptr;
|
||||
|
||||
did_load = _egl_handle == NULL;
|
||||
handle = glad_egl_dlopen_handle();
|
||||
if (handle != NULL) {
|
||||
userptr = glad_egl_build_userptr(handle);
|
||||
|
||||
if (userptr.get_proc_address_ptr != NULL) {
|
||||
version = gladLoadEGLUserPtr(display, glad_egl_get_proc, &userptr);
|
||||
}
|
||||
|
||||
if (!version && did_load) {
|
||||
gladLoaderUnloadEGL();
|
||||
}
|
||||
}
|
||||
|
||||
return version;
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
{% if options.on_demand %}
|
||||
{% call template_utils.zero_initialized() %}static struct _glad_egl_userptr glad_egl_internal_loader_global_userptr{% endcall %}
|
||||
static GLADapiproc glad_egl_internal_loader_get_proc(const char *name) {
|
||||
if (glad_egl_internal_loader_global_userptr.handle == NULL) {
|
||||
glad_egl_internal_loader_global_userptr = glad_egl_build_userptr(glad_egl_dlopen_handle());
|
||||
}
|
||||
|
||||
return glad_egl_get_proc((void *) &glad_egl_internal_loader_global_userptr, name);
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
void gladLoaderUnloadEGL(void) {
|
||||
if (_egl_handle != NULL) {
|
||||
glad_close_dlopen_handle(_egl_handle);
|
||||
_egl_handle = NULL;
|
||||
{% if options.on_demand %}
|
||||
glad_egl_internal_loader_global_userptr.handle = NULL;
|
||||
{% endif %}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* GLAD_EGL */
|
||||
9
third-party/glad/glad/generator/c/templates/loader/egl.h
vendored
Normal file
9
third-party/glad/glad/generator/c/templates/loader/egl.h
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifdef GLAD_EGL
|
||||
|
||||
{% if not options.on_demand %}
|
||||
GLAD_API_CALL int gladLoaderLoadEGL(EGLDisplay display);
|
||||
{% endif %}
|
||||
|
||||
GLAD_API_CALL void gladLoaderUnloadEGL(void);
|
||||
|
||||
#endif
|
||||
125
third-party/glad/glad/generator/c/templates/loader/gl.c
vendored
Normal file
125
third-party/glad/glad/generator/c/templates/loader/gl.c
vendored
Normal file
@@ -0,0 +1,125 @@
|
||||
{% import "template_utils.h" as template_utils with context %}
|
||||
#ifdef GLAD_GL
|
||||
|
||||
{% set loader_handle = template_utils.handle('gl') %}
|
||||
{% include 'loader/library.c' %}
|
||||
|
||||
typedef void* (GLAD_API_PTR *GLADglprocaddrfunc)(const char*);
|
||||
struct _glad_gl_userptr {
|
||||
void *handle;
|
||||
GLADglprocaddrfunc gl_get_proc_address_ptr;
|
||||
};
|
||||
|
||||
static GLADapiproc glad_gl_get_proc(void *vuserptr, const char *name) {
|
||||
struct _glad_gl_userptr userptr = *(struct _glad_gl_userptr*) vuserptr;
|
||||
GLADapiproc result = NULL;
|
||||
|
||||
if(userptr.gl_get_proc_address_ptr != NULL) {
|
||||
result = GLAD_GNUC_EXTENSION (GLADapiproc) userptr.gl_get_proc_address_ptr(name);
|
||||
}
|
||||
if(result == NULL) {
|
||||
result = glad_dlsym_handle(userptr.handle, name);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
{% if not options.mx %}
|
||||
static void* {{ loader_handle }} = NULL;
|
||||
{% endif %}
|
||||
|
||||
static void* glad_gl_dlopen_handle({{ template_utils.context_arg(def='void') }}) {
|
||||
#if GLAD_PLATFORM_APPLE
|
||||
static const char *NAMES[] = {
|
||||
"../Frameworks/OpenGL.framework/OpenGL",
|
||||
"/Library/Frameworks/OpenGL.framework/OpenGL",
|
||||
"/System/Library/Frameworks/OpenGL.framework/OpenGL",
|
||||
"/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL"
|
||||
};
|
||||
#elif GLAD_PLATFORM_WIN32
|
||||
static const char *NAMES[] = {"opengl32.dll"};
|
||||
#else
|
||||
static const char *NAMES[] = {
|
||||
#if defined(__CYGWIN__)
|
||||
"libGL-1.so",
|
||||
#endif
|
||||
"libGL.so.1",
|
||||
"libGL.so"
|
||||
};
|
||||
#endif
|
||||
|
||||
if ({{ loader_handle }} == NULL) {
|
||||
{{ loader_handle }} = glad_get_dlopen_handle(NAMES, sizeof(NAMES) / sizeof(NAMES[0]));
|
||||
}
|
||||
|
||||
return {{ loader_handle }};
|
||||
}
|
||||
|
||||
static struct _glad_gl_userptr glad_gl_build_userptr(void *handle) {
|
||||
struct _glad_gl_userptr userptr;
|
||||
|
||||
userptr.handle = handle;
|
||||
#if GLAD_PLATFORM_APPLE || defined(__HAIKU__)
|
||||
userptr.gl_get_proc_address_ptr = NULL;
|
||||
#elif GLAD_PLATFORM_WIN32
|
||||
userptr.gl_get_proc_address_ptr =
|
||||
(GLADglprocaddrfunc) glad_dlsym_handle(handle, "wglGetProcAddress");
|
||||
#else
|
||||
userptr.gl_get_proc_address_ptr =
|
||||
(GLADglprocaddrfunc) glad_dlsym_handle(handle, "glXGetProcAddressARB");
|
||||
#endif
|
||||
|
||||
return userptr;
|
||||
}
|
||||
|
||||
{% if not options.on_demand %}
|
||||
int gladLoaderLoadGL{{ 'Context' if options.mx }}({{ template_utils.context_arg(def='void') }}) {
|
||||
int version = 0;
|
||||
void *handle;
|
||||
int did_load = 0;
|
||||
struct _glad_gl_userptr userptr;
|
||||
|
||||
did_load = {{ loader_handle }} == NULL;
|
||||
handle = glad_gl_dlopen_handle({{ 'context' if options.mx }});
|
||||
if (handle) {
|
||||
userptr = glad_gl_build_userptr(handle);
|
||||
|
||||
version = gladLoadGL{{ 'Context' if options.mx }}UserPtr({{ 'context,' if options.mx }}glad_gl_get_proc, &userptr);
|
||||
|
||||
if (did_load) {
|
||||
gladLoaderUnloadGL{{ 'Context' if options.mx }}({{ 'context' if options.mx }});
|
||||
}
|
||||
}
|
||||
|
||||
return version;
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
{% if options.on_demand %}
|
||||
{% call template_utils.zero_initialized() %}static struct _glad_gl_userptr glad_gl_internal_loader_global_userptr{% endcall %}
|
||||
static GLADapiproc glad_gl_internal_loader_get_proc(const char *name) {
|
||||
if (glad_gl_internal_loader_global_userptr.handle == NULL) {
|
||||
glad_gl_internal_loader_global_userptr = glad_gl_build_userptr(glad_gl_dlopen_handle());
|
||||
}
|
||||
|
||||
return glad_gl_get_proc((void *) &glad_gl_internal_loader_global_userptr, name);
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
{% if options.mx_global %}
|
||||
int gladLoaderLoadGL(void) {
|
||||
return gladLoaderLoadGLContext(gladGet{{ feature_set.name|api }}Context());
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
void gladLoaderUnloadGL{{ 'Context' if options.mx }}({{ template_utils.context_arg(def='void') }}) {
|
||||
if ({{ loader_handle }} != NULL) {
|
||||
glad_close_dlopen_handle({{ loader_handle }});
|
||||
{{ loader_handle }} = NULL;
|
||||
{% if options.on_demand %}
|
||||
glad_gl_internal_loader_global_userptr.handle = NULL;
|
||||
{% endif %}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* GLAD_GL */
|
||||
12
third-party/glad/glad/generator/c/templates/loader/gl.h
vendored
Normal file
12
third-party/glad/glad/generator/c/templates/loader/gl.h
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
{% import "template_utils.h" as template_utils with context %}
|
||||
#ifdef GLAD_GL
|
||||
|
||||
{% if not options.on_demand %}
|
||||
GLAD_API_CALL int gladLoaderLoadGL{{ 'Context' if options.mx }}({{ template_utils.context_arg(def='void') }});
|
||||
{% endif %}
|
||||
{% if options.mx_global %}
|
||||
GLAD_API_CALL int gladLoaderLoadGL(void);
|
||||
{% endif %}
|
||||
GLAD_API_CALL void gladLoaderUnloadGL{{ 'Context' if options.mx }}({{ template_utils.context_arg(def='void') }});
|
||||
|
||||
#endif
|
||||
109
third-party/glad/glad/generator/c/templates/loader/gles1.c
vendored
Normal file
109
third-party/glad/glad/generator/c/templates/loader/gles1.c
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
{% import "template_utils.h" as template_utils with context %}
|
||||
#ifdef GLAD_GLES1
|
||||
|
||||
{% set loader_handle = template_utils.handle('gles1') %}
|
||||
{% include 'loader/library.c' %}
|
||||
|
||||
#include <glad/egl.h>
|
||||
|
||||
struct _glad_gles1_userptr {
|
||||
void *handle;
|
||||
PFNEGLGETPROCADDRESSPROC get_proc_address_ptr;
|
||||
};
|
||||
|
||||
|
||||
static GLADapiproc glad_gles1_get_proc(void *vuserptr, const char* name) {
|
||||
struct _glad_gles1_userptr userptr = *(struct _glad_gles1_userptr*) vuserptr;
|
||||
GLADapiproc result = NULL;
|
||||
|
||||
{# /* dlsym first, since some implementations don't return function pointers for core functions */ #}
|
||||
result = glad_dlsym_handle(userptr.handle, name);
|
||||
if (result == NULL) {
|
||||
result = userptr.get_proc_address_ptr(name);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
{% if not options.mx %}
|
||||
static void* {{ loader_handle }} = NULL;
|
||||
{% endif %}
|
||||
|
||||
static void* glad_gles1_dlopen_handle({{ template_utils.context_arg(def='void') }}) {
|
||||
#if GLAD_PLATFORM_APPLE
|
||||
static const char *NAMES[] = {"libGLESv1_CM.dylib"};
|
||||
#elif GLAD_PLATFORM_WIN32
|
||||
static const char *NAMES[] = {"GLESv1_CM.dll", "libGLESv1_CM", "libGLES_CM.dll"};
|
||||
#else
|
||||
static const char *NAMES[] = {"libGLESv1_CM.so.1", "libGLESv1_CM.so", "libGLES_CM.so.1"};
|
||||
#endif
|
||||
|
||||
if ({{ loader_handle }} == NULL) {
|
||||
{{ loader_handle }} = glad_get_dlopen_handle(NAMES, sizeof(NAMES) / sizeof(NAMES[0]));
|
||||
}
|
||||
|
||||
return {{ loader_handle }};
|
||||
}
|
||||
|
||||
static struct _glad_gles1_userptr glad_gles1_build_userptr(void *handle) {
|
||||
struct _glad_gles1_userptr userptr;
|
||||
userptr.handle = handle;
|
||||
userptr.get_proc_address_ptr = eglGetProcAddress;
|
||||
return userptr;
|
||||
}
|
||||
|
||||
{% if not options.on_demand %}
|
||||
int gladLoaderLoadGLES1{{ 'Context' if options.mx }}({{ template_utils.context_arg(def='void') }}) {
|
||||
int version = 0;
|
||||
void *handle = NULL;
|
||||
int did_load = 0;
|
||||
struct _glad_gles1_userptr userptr;
|
||||
|
||||
if (eglGetProcAddress == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
did_load = {{ loader_handle }} == NULL;
|
||||
handle = glad_gles1_dlopen_handle({{ 'context' if options.mx }});
|
||||
if (handle != NULL) {
|
||||
userptr = glad_gles1_build_userptr(handle);
|
||||
|
||||
version = gladLoadGLES1{{ 'Context' if options.mx }}UserPtr({{ 'context, ' if options.mx }}glad_gles1_get_proc, &userptr);
|
||||
|
||||
if (!version && did_load) {
|
||||
gladLoaderUnloadGLES1{{ 'Context' if options.mx }}({{ 'context' if options.mx }});
|
||||
}
|
||||
}
|
||||
|
||||
return version;
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
{% if options.on_demand %}
|
||||
{% call template_utils.zero_initialized() %}static struct _glad_gles1_userptr glad_gles1_internal_loader_global_userptr{% endcall %}
|
||||
static GLADapiproc glad_gles1_internal_loader_get_proc(const char *name) {
|
||||
if (glad_gles1_internal_loader_global_userptr.handle == NULL) {
|
||||
glad_gles1_internal_loader_global_userptr = glad_gles1_build_userptr(glad_gles1_dlopen_handle());
|
||||
}
|
||||
|
||||
return glad_gles1_get_proc((void *) &glad_gles1_internal_loader_global_userptr, name);
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
{% if options.mx_global %}
|
||||
int gladLoaderLoadGLES1(void) {
|
||||
return gladLoaderLoadGLES1Context(gladGet{{ feature_set.name|api }}Context());
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
void gladLoaderUnloadGLES1{{ 'Context' if options.mx }}({{ template_utils.context_arg(def='void') }}) {
|
||||
if ({{ loader_handle }} != NULL) {
|
||||
glad_close_dlopen_handle({{ loader_handle }});
|
||||
{{ loader_handle }} = NULL;
|
||||
{% if options.on_demand %}
|
||||
glad_gles1_internal_loader_global_userptr.handle = NULL;
|
||||
{% endif %}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* GLAD_GLES1 */
|
||||
17
third-party/glad/glad/generator/c/templates/loader/gles1.h
vendored
Normal file
17
third-party/glad/glad/generator/c/templates/loader/gles1.h
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
{% import "template_utils.h" as template_utils with context %}
|
||||
#ifdef GLAD_GLES1
|
||||
{#
|
||||
#ifndef __egl_h_
|
||||
#error "gles1 loader requires egl.h, include egl.h (<glad/egl.h>) before including the loader."
|
||||
#endif
|
||||
#}
|
||||
|
||||
{% if not options.on_demand %}
|
||||
GLAD_API_CALL int gladLoaderLoadGLES1{{ 'Context' if options.mx }}({{ template_utils.context_arg(def='void') }});
|
||||
{% endif %}
|
||||
{% if options.mx_global %}
|
||||
GLAD_API_CALL int gladLoaderLoadGLES1(void);
|
||||
{% endif %}
|
||||
GLAD_API_CALL void gladLoaderUnloadGLES1{{ 'Context' if options.mx }}({{ template_utils.context_arg(def='void') }});
|
||||
|
||||
#endif /* GLAD_GLES1 */
|
||||
146
third-party/glad/glad/generator/c/templates/loader/gles2.c
vendored
Normal file
146
third-party/glad/glad/generator/c/templates/loader/gles2.c
vendored
Normal file
@@ -0,0 +1,146 @@
|
||||
{% import "template_utils.h" as template_utils with context %}
|
||||
#ifdef GLAD_GLES2
|
||||
|
||||
{% set loader_handle = template_utils.handle('gles2') %}
|
||||
{% include 'loader/library.c' %}
|
||||
|
||||
#if GLAD_PLATFORM_EMSCRIPTEN
|
||||
#ifndef GLAD_EGL_H_
|
||||
typedef void (*__eglMustCastToProperFunctionPointerType)(void);
|
||||
typedef __eglMustCastToProperFunctionPointerType (GLAD_API_PTR *PFNEGLGETPROCADDRESSPROC)(const char *name);
|
||||
#endif
|
||||
extern __eglMustCastToProperFunctionPointerType emscripten_GetProcAddress(const char *name);
|
||||
#elif defined(GLAD_GLES2_USE_SYSTEM_EGL)
|
||||
#include <EGL/egl.h>
|
||||
typedef __eglMustCastToProperFunctionPointerType (GLAD_API_PTR *PFNEGLGETPROCADDRESSPROC)(const char *name);
|
||||
#else
|
||||
#include <glad/egl.h>
|
||||
#endif
|
||||
|
||||
|
||||
struct _glad_gles2_userptr {
|
||||
void *handle;
|
||||
PFNEGLGETPROCADDRESSPROC get_proc_address_ptr;
|
||||
};
|
||||
|
||||
|
||||
static GLADapiproc glad_gles2_get_proc(void *vuserptr, const char* name) {
|
||||
struct _glad_gles2_userptr userptr = *(struct _glad_gles2_userptr*) vuserptr;
|
||||
GLADapiproc result = NULL;
|
||||
|
||||
#if GLAD_PLATFORM_EMSCRIPTEN
|
||||
GLAD_UNUSED(&glad_dlsym_handle);
|
||||
#else
|
||||
{# /* dlsym first, since some implementations don't return function pointers for core functions */ #}
|
||||
result = glad_dlsym_handle(userptr.handle, name);
|
||||
#endif
|
||||
if (result == NULL) {
|
||||
result = userptr.get_proc_address_ptr(name);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
{% if not options.mx %}
|
||||
static void* {{ loader_handle }} = NULL;
|
||||
{% endif %}
|
||||
|
||||
static void* glad_gles2_dlopen_handle({{ template_utils.context_arg(def='void') }}) {
|
||||
#if GLAD_PLATFORM_EMSCRIPTEN
|
||||
#elif GLAD_PLATFORM_APPLE
|
||||
static const char *NAMES[] = {"libGLESv2.dylib"};
|
||||
#elif GLAD_PLATFORM_WIN32
|
||||
static const char *NAMES[] = {"GLESv2.dll", "libGLESv2.dll"};
|
||||
#else
|
||||
static const char *NAMES[] = {"libGLESv2.so.2", "libGLESv2.so"};
|
||||
#endif
|
||||
|
||||
#if GLAD_PLATFORM_EMSCRIPTEN
|
||||
GLAD_UNUSED(&glad_get_dlopen_handle);
|
||||
return NULL;
|
||||
#else
|
||||
if ({{ loader_handle }} == NULL) {
|
||||
{{ loader_handle }} = glad_get_dlopen_handle(NAMES, sizeof(NAMES) / sizeof(NAMES[0]));
|
||||
}
|
||||
|
||||
return {{ loader_handle }};
|
||||
#endif
|
||||
}
|
||||
|
||||
static struct _glad_gles2_userptr glad_gles2_build_userptr(void *handle) {
|
||||
struct _glad_gles2_userptr userptr;
|
||||
#if GLAD_PLATFORM_EMSCRIPTEN
|
||||
GLAD_UNUSED(handle);
|
||||
userptr.get_proc_address_ptr = emscripten_GetProcAddress;
|
||||
#else
|
||||
userptr.handle = handle;
|
||||
userptr.get_proc_address_ptr = eglGetProcAddress;
|
||||
#endif
|
||||
return userptr;
|
||||
}
|
||||
|
||||
{% if not options.on_demand %}
|
||||
int gladLoaderLoadGLES2{{ 'Context' if options.mx }}({{ template_utils.context_arg(def='void') }}) {
|
||||
int version = 0;
|
||||
void *handle = NULL;
|
||||
int did_load = 0;
|
||||
struct _glad_gles2_userptr userptr;
|
||||
|
||||
#if GLAD_PLATFORM_EMSCRIPTEN
|
||||
GLAD_UNUSED(handle);
|
||||
GLAD_UNUSED(did_load);
|
||||
GLAD_UNUSED(&glad_gles2_dlopen_handle);
|
||||
GLAD_UNUSED(&glad_gles2_build_userptr);
|
||||
userptr.get_proc_address_ptr = emscripten_GetProcAddress;
|
||||
version = gladLoadGLES2{{ 'Context' if options.mx }}UserPtr({{ 'context, ' if options.mx }}glad_gles2_get_proc, &userptr);
|
||||
#else
|
||||
#ifndef GLAD_GLES2_USE_SYSTEM_EGL
|
||||
if (eglGetProcAddress == NULL) {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
did_load = {{ loader_handle }} == NULL;
|
||||
handle = glad_gles2_dlopen_handle({{ 'context' if options.mx }});
|
||||
if (handle != NULL) {
|
||||
userptr = glad_gles2_build_userptr(handle);
|
||||
|
||||
version = gladLoadGLES2{{ 'Context' if options.mx }}UserPtr({{ 'context, ' if options.mx }}glad_gles2_get_proc, &userptr);
|
||||
|
||||
if (!version && did_load) {
|
||||
gladLoaderUnloadGLES2{{ 'Context' if options.mx }}({{ 'context' if options.mx }});
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return version;
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
{% if options.on_demand %}
|
||||
{% call template_utils.zero_initialized() %}static struct _glad_gles2_userptr glad_gles2_internal_loader_global_userptr{% endcall %}
|
||||
static GLADapiproc glad_gles2_internal_loader_get_proc(const char *name) {
|
||||
if (glad_gles2_internal_loader_global_userptr.get_proc_address_ptr == NULL) {
|
||||
glad_gles2_internal_loader_global_userptr = glad_gles2_build_userptr(glad_gles2_dlopen_handle());
|
||||
}
|
||||
|
||||
return glad_gles2_get_proc((void *) &glad_gles2_internal_loader_global_userptr, name);
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
{% if options.mx_global %}
|
||||
int gladLoaderLoadGLES2(void) {
|
||||
return gladLoaderLoadGLES2Context(gladGet{{ feature_set.name|api }}Context());
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
void gladLoaderUnloadGLES2{{ 'Context' if options.mx }}({{ template_utils.context_arg(def='void') }}) {
|
||||
if ({{ loader_handle }} != NULL) {
|
||||
glad_close_dlopen_handle({{ loader_handle }});
|
||||
{{ loader_handle }} = NULL;
|
||||
{% if options.on_demand %}
|
||||
glad_gles2_internal_loader_global_userptr.get_proc_address_ptr = NULL;
|
||||
{% endif %}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* GLAD_GLES2 */
|
||||
18
third-party/glad/glad/generator/c/templates/loader/gles2.h
vendored
Normal file
18
third-party/glad/glad/generator/c/templates/loader/gles2.h
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
{% import "template_utils.h" as template_utils with context %}
|
||||
#ifdef GLAD_GLES2
|
||||
{#
|
||||
#ifndef __egl_h_
|
||||
#error "gles2 loader requires egl.h, include egl.h (<glad/egl.h>) before including the loader."
|
||||
#endif
|
||||
#}
|
||||
|
||||
{% if not options.on_demand %}
|
||||
GLAD_API_CALL int gladLoaderLoadGLES2{{ 'Context' if options.mx }}({{ template_utils.context_arg(def='void') }});
|
||||
{% endif %}
|
||||
{% if options.mx_global %}
|
||||
GLAD_API_CALL int gladLoaderLoadGLES2(void);
|
||||
{% endif %}
|
||||
GLAD_API_CALL void gladLoaderUnloadGLES2{{ 'Context' if options.mx }}({{ template_utils.context_arg(def='void') }});
|
||||
|
||||
#endif /* GLAD_GLES2 */
|
||||
|
||||
0
third-party/glad/glad/generator/c/templates/loader/glsc2.c
vendored
Normal file
0
third-party/glad/glad/generator/c/templates/loader/glsc2.c
vendored
Normal file
0
third-party/glad/glad/generator/c/templates/loader/glsc2.h
vendored
Normal file
0
third-party/glad/glad/generator/c/templates/loader/glsc2.h
vendored
Normal file
74
third-party/glad/glad/generator/c/templates/loader/glx.c
vendored
Normal file
74
third-party/glad/glad/generator/c/templates/loader/glx.c
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
#ifdef GLAD_GLX
|
||||
|
||||
{% include 'loader/library.c' %}
|
||||
|
||||
typedef void* (GLAD_API_PTR *GLADglxprocaddrfunc)(const char*);
|
||||
|
||||
static GLADapiproc glad_glx_get_proc(void *userptr, const char *name) {
|
||||
return GLAD_GNUC_EXTENSION ((GLADapiproc (*)(const char *name)) userptr)(name);
|
||||
}
|
||||
|
||||
static void* _glx_handle;
|
||||
|
||||
static void* glad_glx_dlopen_handle(void) {
|
||||
static const char *NAMES[] = {
|
||||
#if defined __CYGWIN__
|
||||
"libGL-1.so",
|
||||
#endif
|
||||
"libGL.so.1",
|
||||
"libGL.so"
|
||||
};
|
||||
|
||||
if (_glx_handle == NULL) {
|
||||
_glx_handle = glad_get_dlopen_handle(NAMES, sizeof(NAMES) / sizeof(NAMES[0]));
|
||||
}
|
||||
|
||||
return _glx_handle;
|
||||
}
|
||||
|
||||
{% if not options.on_demand %}
|
||||
int gladLoaderLoadGLX(Display *display, int screen) {
|
||||
int version = 0;
|
||||
void *handle = NULL;
|
||||
int did_load = 0;
|
||||
GLADglxprocaddrfunc loader;
|
||||
|
||||
did_load = _glx_handle == NULL;
|
||||
handle = glad_glx_dlopen_handle();
|
||||
if (handle != NULL) {
|
||||
loader = (GLADglxprocaddrfunc) glad_dlsym_handle(handle, "glXGetProcAddressARB");
|
||||
if (loader != NULL) {
|
||||
version = gladLoadGLXUserPtr(display, screen, glad_glx_get_proc, GLAD_GNUC_EXTENSION (void*) loader);
|
||||
}
|
||||
|
||||
if (!version && did_load) {
|
||||
gladLoaderUnloadGLX();
|
||||
}
|
||||
}
|
||||
|
||||
return version;
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
{% if options.on_demand %}
|
||||
static GLADglxprocaddrfunc glad_glx_internal_loader_global_userptr = NULL;
|
||||
static GLADapiproc glad_glx_internal_loader_get_proc(const char *name) {
|
||||
if (glad_glx_internal_loader_global_userptr == NULL) {
|
||||
glad_glx_internal_loader_global_userptr = (GLADglxprocaddrfunc) glad_dlsym_handle(glad_glx_dlopen_handle(), "glXGetProcAddressARB");
|
||||
}
|
||||
|
||||
return glad_glx_get_proc(GLAD_GNUC_EXTENSION (void *) glad_glx_internal_loader_global_userptr, name);
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
void gladLoaderUnloadGLX() {
|
||||
if (_glx_handle != NULL) {
|
||||
glad_close_dlopen_handle(_glx_handle);
|
||||
_glx_handle = NULL;
|
||||
{% if options.on_demand %}
|
||||
glad_glx_internal_loader_global_userptr = NULL;
|
||||
{% endif %}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* GLAD_GLX */
|
||||
9
third-party/glad/glad/generator/c/templates/loader/glx.h
vendored
Normal file
9
third-party/glad/glad/generator/c/templates/loader/glx.h
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifdef GLAD_GLX
|
||||
|
||||
{% if not options.on_demand %}
|
||||
GLAD_API_CALL int gladLoaderLoadGLX(Display *display, int screen);
|
||||
{% endif %}
|
||||
|
||||
GLAD_API_CALL void gladLoaderUnloadGLX(void);
|
||||
|
||||
#endif
|
||||
66
third-party/glad/glad/generator/c/templates/loader/library.c
vendored
Normal file
66
third-party/glad/glad/generator/c/templates/loader/library.c
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
#ifndef GLAD_LOADER_LIBRARY_C_
|
||||
#define GLAD_LOADER_LIBRARY_C_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if GLAD_PLATFORM_WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
|
||||
static void* glad_get_dlopen_handle(const char *lib_names[], int length) {
|
||||
void *handle = NULL;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < length; ++i) {
|
||||
#if GLAD_PLATFORM_WIN32
|
||||
#if GLAD_PLATFORM_UWP
|
||||
size_t buffer_size = (strlen(lib_names[i]) + 1) * sizeof(WCHAR);
|
||||
LPWSTR buffer = (LPWSTR) malloc(buffer_size);
|
||||
if (buffer != NULL) {
|
||||
int ret = MultiByteToWideChar(CP_ACP, 0, lib_names[i], -1, buffer, buffer_size);
|
||||
if (ret != 0) {
|
||||
handle = (void*) LoadPackagedLibrary(buffer, 0);
|
||||
}
|
||||
free((void*) buffer);
|
||||
}
|
||||
#else
|
||||
handle = (void*) LoadLibraryA(lib_names[i]);
|
||||
#endif
|
||||
#else
|
||||
handle = dlopen(lib_names[i], RTLD_LAZY | RTLD_LOCAL);
|
||||
#endif
|
||||
if (handle != NULL) {
|
||||
return handle;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void glad_close_dlopen_handle(void* handle) {
|
||||
if (handle != NULL) {
|
||||
#if GLAD_PLATFORM_WIN32
|
||||
FreeLibrary((HMODULE) handle);
|
||||
#else
|
||||
dlclose(handle);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static GLADapiproc glad_dlsym_handle(void* handle, const char *name) {
|
||||
if (handle == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if GLAD_PLATFORM_WIN32
|
||||
return (GLADapiproc) GetProcAddress((HMODULE) handle, name);
|
||||
#else
|
||||
return GLAD_GNUC_EXTENSION (GLADapiproc) dlsym(handle, name);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* GLAD_LOADER_LIBRARY_C_ */
|
||||
155
third-party/glad/glad/generator/c/templates/loader/vulkan.c
vendored
Normal file
155
third-party/glad/glad/generator/c/templates/loader/vulkan.c
vendored
Normal file
@@ -0,0 +1,155 @@
|
||||
{% import "template_utils.h" as template_utils with context %}
|
||||
#ifdef GLAD_VULKAN
|
||||
|
||||
{% set loader_handle = template_utils.handle('vulkan') %}
|
||||
{% include 'loader/library.c' %}
|
||||
|
||||
|
||||
static const char* DEVICE_FUNCTIONS[] = {
|
||||
{% for command in device_commands %}
|
||||
"{{ command.name }}",
|
||||
{% endfor %}
|
||||
};
|
||||
|
||||
static int glad_vulkan_is_device_function(const char *name) {
|
||||
/* Exists as a workaround for:
|
||||
* https://github.com/KhronosGroup/Vulkan-LoaderAndValidationLayers/issues/2323
|
||||
*
|
||||
* `vkGetDeviceProcAddr` does not return NULL for non-device functions.
|
||||
*/
|
||||
int i;
|
||||
int length = sizeof(DEVICE_FUNCTIONS) / sizeof(DEVICE_FUNCTIONS[0]);
|
||||
|
||||
for (i=0; i < length; ++i) {
|
||||
if (strcmp(DEVICE_FUNCTIONS[i], name) == 0) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct _glad_vulkan_userptr {
|
||||
void *vk_handle;
|
||||
VkInstance vk_instance;
|
||||
VkDevice vk_device;
|
||||
PFN_vkGetInstanceProcAddr get_instance_proc_addr;
|
||||
PFN_vkGetDeviceProcAddr get_device_proc_addr;
|
||||
};
|
||||
|
||||
static GLADapiproc glad_vulkan_get_proc(void *vuserptr, const char *name) {
|
||||
struct _glad_vulkan_userptr userptr = *(struct _glad_vulkan_userptr*) vuserptr;
|
||||
PFN_vkVoidFunction result = NULL;
|
||||
|
||||
if (userptr.vk_device != NULL && glad_vulkan_is_device_function(name)) {
|
||||
result = userptr.get_device_proc_addr(userptr.vk_device, name);
|
||||
}
|
||||
|
||||
if (result == NULL && userptr.vk_instance != NULL) {
|
||||
result = userptr.get_instance_proc_addr(userptr.vk_instance, name);
|
||||
}
|
||||
|
||||
if(result == NULL) {
|
||||
result = (PFN_vkVoidFunction) glad_dlsym_handle(userptr.vk_handle, name);
|
||||
}
|
||||
|
||||
return (GLADapiproc) result;
|
||||
}
|
||||
|
||||
|
||||
{% if not options.mx %}
|
||||
static void* {{ loader_handle }} = NULL;
|
||||
{% endif %}
|
||||
|
||||
static void* glad_vulkan_dlopen_handle({{ template_utils.context_arg(def='void') }}) {
|
||||
static const char *NAMES[] = {
|
||||
#if GLAD_PLATFORM_APPLE
|
||||
"libvulkan.1.dylib",
|
||||
#elif GLAD_PLATFORM_WIN32
|
||||
"vulkan-1.dll",
|
||||
"vulkan.dll",
|
||||
#else
|
||||
"libvulkan.so.1",
|
||||
"libvulkan.so",
|
||||
#endif
|
||||
};
|
||||
|
||||
if ({{ loader_handle }} == NULL) {
|
||||
{{ loader_handle }} = glad_get_dlopen_handle(NAMES, sizeof(NAMES) / sizeof(NAMES[0]));
|
||||
}
|
||||
|
||||
return {{ loader_handle }};
|
||||
}
|
||||
|
||||
static struct _glad_vulkan_userptr glad_vulkan_build_userptr(void *handle, VkInstance instance, VkDevice device) {
|
||||
struct _glad_vulkan_userptr userptr;
|
||||
userptr.vk_handle = handle;
|
||||
userptr.vk_instance = instance;
|
||||
userptr.vk_device = device;
|
||||
userptr.get_instance_proc_addr = (PFN_vkGetInstanceProcAddr) glad_dlsym_handle(handle, "vkGetInstanceProcAddr");
|
||||
userptr.get_device_proc_addr = (PFN_vkGetDeviceProcAddr) glad_dlsym_handle(handle, "vkGetDeviceProcAddr");
|
||||
return userptr;
|
||||
}
|
||||
|
||||
{% if not options.on_demand %}
|
||||
int gladLoaderLoadVulkan{{ 'Context' if options.mx }}({{ template_utils.context_arg(',') }} VkInstance instance, VkPhysicalDevice physical_device, VkDevice device) {
|
||||
int version = 0;
|
||||
void *handle = NULL;
|
||||
int did_load = 0;
|
||||
struct _glad_vulkan_userptr userptr;
|
||||
|
||||
did_load = {{ loader_handle }} == NULL;
|
||||
handle = glad_vulkan_dlopen_handle({{ 'context' if options.mx }});
|
||||
if (handle != NULL) {
|
||||
userptr = glad_vulkan_build_userptr(handle, instance, device);
|
||||
|
||||
if (userptr.get_instance_proc_addr != NULL && userptr.get_device_proc_addr != NULL) {
|
||||
version = gladLoadVulkan{{ 'Context' if options.mx }}UserPtr({{ 'context,' if options.mx }} physical_device, glad_vulkan_get_proc, &userptr);
|
||||
}
|
||||
|
||||
if (!version && did_load) {
|
||||
gladLoaderUnloadVulkan{{ 'Context' if options.mx }}({{ 'context' if options.mx }});
|
||||
}
|
||||
}
|
||||
|
||||
return version;
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
{% if options.on_demand %}
|
||||
{% call template_utils.zero_initialized() %}static struct _glad_vulkan_userptr glad_vulkan_internal_loader_global_userptr{% endcall %}
|
||||
|
||||
void gladLoaderSetVulkanInstance(VkInstance instance) {
|
||||
glad_vulkan_internal_loader_global_userptr.vk_instance = instance;
|
||||
}
|
||||
|
||||
void gladLoaderSetVulkanDevice(VkDevice device) {
|
||||
glad_vulkan_internal_loader_global_userptr.vk_device = device;
|
||||
}
|
||||
|
||||
static GLADapiproc glad_vulkan_internal_loader_get_proc(const char *name) {
|
||||
if (glad_vulkan_internal_loader_global_userptr.vk_handle == NULL) {
|
||||
glad_vulkan_internal_loader_global_userptr = glad_vulkan_build_userptr(glad_vulkan_dlopen_handle(), NULL, NULL);
|
||||
}
|
||||
|
||||
return glad_vulkan_get_proc((void *) &glad_vulkan_internal_loader_global_userptr, name);
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
{% if options.mx_global %}
|
||||
int gladLoaderLoadVulkan(VkInstance instance, VkPhysicalDevice physical_device, VkDevice device) {
|
||||
return gladLoaderLoadVulkanContext(gladGetVulkanContext(), instance, physical_device, device);
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
void gladLoaderUnloadVulkan{{ 'Context' if options.mx }}({{ template_utils.context_arg(def='void') }}) {
|
||||
if ({{ loader_handle }} != NULL) {
|
||||
glad_close_dlopen_handle({{ loader_handle }});
|
||||
{{ loader_handle }} = NULL;
|
||||
{% if options.on_demand %}
|
||||
glad_vulkan_internal_loader_global_userptr.vk_handle = NULL;
|
||||
{% endif %}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* GLAD_VULKAN */
|
||||
18
third-party/glad/glad/generator/c/templates/loader/vulkan.h
vendored
Normal file
18
third-party/glad/glad/generator/c/templates/loader/vulkan.h
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
{% import "template_utils.h" as template_utils with context %}
|
||||
#ifdef GLAD_VULKAN
|
||||
|
||||
{% if not options.on_demand %}
|
||||
GLAD_API_CALL int gladLoaderLoadVulkan{{ 'Context' if options.mx }}({{ template_utils.context_arg(',') }} VkInstance instance, VkPhysicalDevice physical_device, VkDevice device);
|
||||
{% endif %}
|
||||
{% if options.mx_global %}
|
||||
GLAD_API_CALL int gladLoaderLoadVulkan(VkInstance instance, VkPhysicalDevice physical_device, VkDevice device);
|
||||
{% endif %}
|
||||
GLAD_API_CALL void gladLoaderUnloadVulkan{{ 'Context' if options.mx }}({{ template_utils.context_arg(def='void') }});
|
||||
|
||||
{% if options.on_demand %}
|
||||
GLAD_API_CALL void gladLoaderSetVulkanInstance(VkInstance instance);
|
||||
GLAD_API_CALL void gladLoaderSetVulkanDevice(VkDevice device);
|
||||
{% endif %}
|
||||
|
||||
|
||||
#endif
|
||||
20
third-party/glad/glad/generator/c/templates/loader/wgl.c
vendored
Normal file
20
third-party/glad/glad/generator/c/templates/loader/wgl.c
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifdef GLAD_WGL
|
||||
|
||||
{% if not options.on_demand %}
|
||||
static GLADapiproc glad_wgl_get_proc(void *vuserptr, const char* name) {
|
||||
GLAD_UNUSED(vuserptr);
|
||||
return GLAD_GNUC_EXTENSION (GLADapiproc) wglGetProcAddress(name);
|
||||
}
|
||||
|
||||
int gladLoaderLoadWGL(HDC hdc) {
|
||||
return gladLoadWGLUserPtr(hdc, glad_wgl_get_proc, NULL);
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
{% if options.on_demand %}
|
||||
static GLADapiproc glad_wgl_internal_loader_get_proc(const char *name) {
|
||||
return GLAD_GNUC_EXTENSION (GLADapiproc) wglGetProcAddress(name);
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
#endif /* GLAD_WGL */
|
||||
7
third-party/glad/glad/generator/c/templates/loader/wgl.h
vendored
Normal file
7
third-party/glad/glad/generator/c/templates/loader/wgl.h
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
#ifdef GLAD_WGL
|
||||
|
||||
{% if not options.on_demand %}
|
||||
GLAD_API_CALL int gladLoaderLoadWGL(HDC hdc);
|
||||
{% endif %}
|
||||
|
||||
#endif
|
||||
115
third-party/glad/glad/generator/c/templates/platform.h
vendored
Normal file
115
third-party/glad/glad/generator/c/templates/platform.h
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
#ifndef GLAD_PLATFORM_H_
|
||||
#define GLAD_PLATFORM_H_
|
||||
|
||||
#ifndef GLAD_PLATFORM_WIN32
|
||||
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__MINGW32__)
|
||||
#define GLAD_PLATFORM_WIN32 1
|
||||
#else
|
||||
#define GLAD_PLATFORM_WIN32 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef GLAD_PLATFORM_APPLE
|
||||
#ifdef __APPLE__
|
||||
#define GLAD_PLATFORM_APPLE 1
|
||||
#else
|
||||
#define GLAD_PLATFORM_APPLE 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef GLAD_PLATFORM_EMSCRIPTEN
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#define GLAD_PLATFORM_EMSCRIPTEN 1
|
||||
#else
|
||||
#define GLAD_PLATFORM_EMSCRIPTEN 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef GLAD_PLATFORM_UWP
|
||||
#if defined(_MSC_VER) && !defined(GLAD_INTERNAL_HAVE_WINAPIFAMILY)
|
||||
#ifdef __has_include
|
||||
#if __has_include(<winapifamily.h>)
|
||||
#define GLAD_INTERNAL_HAVE_WINAPIFAMILY 1
|
||||
#endif
|
||||
#elif _MSC_VER >= 1700 && !_USING_V110_SDK71_
|
||||
#define GLAD_INTERNAL_HAVE_WINAPIFAMILY 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef GLAD_INTERNAL_HAVE_WINAPIFAMILY
|
||||
#include <winapifamily.h>
|
||||
#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
|
||||
#define GLAD_PLATFORM_UWP 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef GLAD_PLATFORM_UWP
|
||||
#define GLAD_PLATFORM_UWP 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define GLAD_GNUC_EXTENSION __extension__
|
||||
#else
|
||||
#define GLAD_GNUC_EXTENSION
|
||||
#endif
|
||||
|
||||
#define GLAD_UNUSED(x) (void)(x)
|
||||
|
||||
#ifndef GLAD_API_CALL
|
||||
#if defined(GLAD_API_CALL_EXPORT)
|
||||
#if GLAD_PLATFORM_WIN32 || defined(__CYGWIN__)
|
||||
#if defined(GLAD_API_CALL_EXPORT_BUILD)
|
||||
#if defined(__GNUC__)
|
||||
#define GLAD_API_CALL __attribute__ ((dllexport)) extern
|
||||
#else
|
||||
#define GLAD_API_CALL __declspec(dllexport) extern
|
||||
#endif
|
||||
#else
|
||||
#if defined(__GNUC__)
|
||||
#define GLAD_API_CALL __attribute__ ((dllimport)) extern
|
||||
#else
|
||||
#define GLAD_API_CALL __declspec(dllimport) extern
|
||||
#endif
|
||||
#endif
|
||||
#elif defined(__GNUC__) && defined(GLAD_API_CALL_EXPORT_BUILD)
|
||||
#define GLAD_API_CALL __attribute__ ((visibility ("default"))) extern
|
||||
#else
|
||||
#define GLAD_API_CALL extern
|
||||
#endif
|
||||
#else
|
||||
#define GLAD_API_CALL extern
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef APIENTRY
|
||||
#define GLAD_API_PTR APIENTRY
|
||||
#elif GLAD_PLATFORM_WIN32
|
||||
#define GLAD_API_PTR __stdcall
|
||||
#else
|
||||
#define GLAD_API_PTR
|
||||
#endif
|
||||
|
||||
#ifndef GLAPI
|
||||
#define GLAPI GLAD_API_CALL
|
||||
#endif
|
||||
|
||||
#ifndef GLAPIENTRY
|
||||
#define GLAPIENTRY GLAD_API_PTR
|
||||
#endif
|
||||
|
||||
#define GLAD_MAKE_VERSION(major, minor) (major * 10000 + minor)
|
||||
#define GLAD_VERSION_MAJOR(version) (version / 10000)
|
||||
#define GLAD_VERSION_MINOR(version) (version % 10000)
|
||||
|
||||
#define GLAD_GENERATOR_VERSION "{{ gen_info.version }}"
|
||||
|
||||
typedef void (*GLADapiproc)(void);
|
||||
|
||||
typedef GLADapiproc (*GLADloadfunc)(const char *name);
|
||||
typedef GLADapiproc (*GLADuserptrloadfunc)(void *userptr, const char *name);
|
||||
|
||||
typedef void (*GLADprecallback)(const char *name, GLADapiproc apiproc, int len_args, ...);
|
||||
typedef void (*GLADpostcallback)(void *ret, const char *name, GLADapiproc apiproc, int len_args, ...);
|
||||
|
||||
#endif /* GLAD_PLATFORM_H_ */
|
||||
133
third-party/glad/glad/generator/c/templates/template_utils.h
vendored
Normal file
133
third-party/glad/glad/generator/c/templates/template_utils.h
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
{% macro header_error(api, header_name, name) %}
|
||||
#ifdef {{ header_name }}
|
||||
#error {{ name }} header already included (API: {{ api }}), remove previous include!
|
||||
#endif
|
||||
#define {{ header_name }} 1
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
{% macro context_arg(suffix='', def='') -%}
|
||||
{{ 'Glad' + feature_set.name|api + 'Context *context' + suffix if options.mx else def }}
|
||||
{%- endmacro %}
|
||||
|
||||
{% macro handle(api_name) -%}
|
||||
{{ 'context->glad' if options.mx else '_glad_' + api_name|api }}_loader_handle
|
||||
{%- endmacro %}
|
||||
|
||||
|
||||
{% macro protect(symbol) %}
|
||||
{% set protections = spec.protections(symbol, feature_set=feature_set) %}
|
||||
{% if protections %}
|
||||
#if {{ protections|map('defined')|join(' || ') }}
|
||||
{% endif %}
|
||||
{{ caller() }}
|
||||
{%- if protections %}
|
||||
|
||||
#endif
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro write_feature_information(extensions, with_runtime=True) %}
|
||||
{% for extension in extensions %}
|
||||
{% call protect(extension) %}
|
||||
#define {{ extension.name }} 1
|
||||
{% if with_runtime %}
|
||||
GLAD_API_CALL int GLAD_{{ extension.name }};
|
||||
{% endif %}
|
||||
{% endcall %}
|
||||
{% endfor %}
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
{% macro write_types(types) %}
|
||||
{# we assume the types are sorted correctly #}
|
||||
{% for type in types %}
|
||||
{{ write_type(type) }}
|
||||
{% endfor %}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro write_type(type) %}
|
||||
{% call protect(type) %}
|
||||
{% if type.category == 'enum' -%}
|
||||
{% if type.alias -%}
|
||||
{% if type.bitwidth == '64' -%}
|
||||
typedef {{ type.alias }} {{ type.name }};
|
||||
{% else -%}
|
||||
typedef enum {{ type.alias }} {{ type.name }};
|
||||
{% endif %}
|
||||
{% elif type.bitwidth == '64' %}
|
||||
typedef uint64_t {{ type.name }};
|
||||
{% for member in type.enums_for(feature_set) %}
|
||||
static const {{ member.parent_type }} {{ member.name }} = {{ enum_member(type, member, require_value=True) }};
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
{%- if type.enums_for(feature_set) -%}
|
||||
typedef enum {{ type.name }} {
|
||||
{% for member in type.enums_for(feature_set) %}
|
||||
{{ member.name }} = {{ enum_member(type, member) }},
|
||||
{% endfor %}
|
||||
{{ '{}_MAX_ENUM{}'.format(*type.expanded_name) }} = 0x7FFFFFFF
|
||||
} {{ type.name }};
|
||||
{%- endif -%}
|
||||
{% endif -%}
|
||||
{% elif type.category in ('struct', 'union') -%}
|
||||
typedef {{ type.category }} {% if type.alias %}{{ type.alias }}{% else %}{{ type.name }}{% endif %} {% if type.members %}{
|
||||
{% for member in type.members %}
|
||||
{{ member.type._raw }};
|
||||
{% endfor %}
|
||||
}{% endif %} {{ type.name }};
|
||||
{% elif type.alias %}
|
||||
#define {{ type.name }} {{ type.alias }}
|
||||
{%- elif type._raw|trim -%}
|
||||
{{ type._raw|trim|replace('APIENTRY', 'GLAD_API_PTR') }}
|
||||
{%- elif type.category == 'include' %}
|
||||
#include <{{ type.name }}>
|
||||
{%- endif -%}
|
||||
{% endcall %}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro write_enumerations(enumerations) %}
|
||||
{% for enum in enumerations %}
|
||||
{% call protect(enum) %}
|
||||
#define {{ enum.name }} {{ feature_set.find_enum(enum.alias, enum).value }}
|
||||
{% endcall %}
|
||||
{% endfor %}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro write_function_definitions(commands) %}
|
||||
{% for command in commands %}
|
||||
{% call protect(command) %}
|
||||
{{ command.proto.ret|type_to_c }} {{ command.name }}({{ command.params|params_to_c }});
|
||||
{% endcall %}
|
||||
{% endfor %}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro write_function_typedefs(commands) %}
|
||||
{% for command in commands %}
|
||||
{% call protect(command) %}
|
||||
typedef {{ command.proto.ret|type_to_c }} (GLAD_API_PTR *{{ command.name|pfn }})({{ command.params|params_to_c }});
|
||||
{% endcall %}
|
||||
{% endfor %}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro write_function_declarations(commands, debug=False) %}
|
||||
{% for command in commands %}
|
||||
{% call protect(command) %}
|
||||
GLAD_API_CALL {{ command.name|pfn }} glad_{{ command.name }};
|
||||
{% if debug %}
|
||||
GLAD_API_CALL {{ command.name|pfn }} glad_debug_{{ command.name }};
|
||||
#define {{ command.name }} glad_debug_{{ command.name }}
|
||||
{% else %}
|
||||
#define {{ command.name }} glad_{{ command.name }}
|
||||
{% endif %}
|
||||
{% endcall %}
|
||||
{% endfor %}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro zero_initialized(s) %}
|
||||
#ifdef __cplusplus
|
||||
{{ caller() }} = {};
|
||||
#else
|
||||
{{ caller() }} = { 0 };
|
||||
#endif
|
||||
{% endmacro %}
|
||||
239
third-party/glad/glad/generator/c/templates/vk.c
vendored
Normal file
239
third-party/glad/glad/generator/c/templates/vk.c
vendored
Normal file
@@ -0,0 +1,239 @@
|
||||
{% extends 'base_template.c' %}
|
||||
|
||||
|
||||
{% block loader %}
|
||||
static int glad_vk_get_extensions({{ template_utils.context_arg(',') }} VkPhysicalDevice physical_device, uint32_t *out_extension_count, char ***out_extensions) {
|
||||
uint32_t i;
|
||||
uint32_t instance_extension_count = 0;
|
||||
uint32_t device_extension_count = 0;
|
||||
uint32_t max_extension_count = 0;
|
||||
uint32_t total_extension_count = 0;
|
||||
char **extensions = NULL;
|
||||
VkExtensionProperties *ext_properties = NULL;
|
||||
VkResult result;
|
||||
|
||||
if ({{ 'vkEnumerateInstanceExtensionProperties'|ctx }} == NULL || (physical_device != NULL && {{ 'vkEnumerateDeviceExtensionProperties'|ctx }} == NULL)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
result = {{ 'vkEnumerateInstanceExtensionProperties'|ctx }}(NULL, &instance_extension_count, NULL);
|
||||
if (result != VK_SUCCESS) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (physical_device != NULL) {
|
||||
result = {{ 'vkEnumerateDeviceExtensionProperties'|ctx }}(physical_device, NULL, &device_extension_count, NULL);
|
||||
if (result != VK_SUCCESS) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
total_extension_count = instance_extension_count + device_extension_count;
|
||||
if (total_extension_count <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
max_extension_count = instance_extension_count > device_extension_count
|
||||
? instance_extension_count : device_extension_count;
|
||||
|
||||
ext_properties = (VkExtensionProperties*) malloc(max_extension_count * sizeof(VkExtensionProperties));
|
||||
if (ext_properties == NULL) {
|
||||
goto glad_vk_get_extensions_error;
|
||||
}
|
||||
|
||||
result = {{ 'vkEnumerateInstanceExtensionProperties'|ctx }}(NULL, &instance_extension_count, ext_properties);
|
||||
if (result != VK_SUCCESS) {
|
||||
goto glad_vk_get_extensions_error;
|
||||
}
|
||||
|
||||
extensions = (char**) calloc(total_extension_count, sizeof(char*));
|
||||
if (extensions == NULL) {
|
||||
goto glad_vk_get_extensions_error;
|
||||
}
|
||||
|
||||
for (i = 0; i < instance_extension_count; ++i) {
|
||||
VkExtensionProperties ext = ext_properties[i];
|
||||
|
||||
size_t extension_name_length = strlen(ext.extensionName) + 1;
|
||||
extensions[i] = (char*) malloc(extension_name_length * sizeof(char));
|
||||
if (extensions[i] == NULL) {
|
||||
goto glad_vk_get_extensions_error;
|
||||
}
|
||||
memcpy(extensions[i], ext.extensionName, extension_name_length * sizeof(char));
|
||||
}
|
||||
|
||||
if (physical_device != NULL) {
|
||||
result = {{ 'vkEnumerateDeviceExtensionProperties'|ctx }}(physical_device, NULL, &device_extension_count, ext_properties);
|
||||
if (result != VK_SUCCESS) {
|
||||
goto glad_vk_get_extensions_error;
|
||||
}
|
||||
|
||||
for (i = 0; i < device_extension_count; ++i) {
|
||||
VkExtensionProperties ext = ext_properties[i];
|
||||
|
||||
size_t extension_name_length = strlen(ext.extensionName) + 1;
|
||||
extensions[instance_extension_count + i] = (char*) malloc(extension_name_length * sizeof(char));
|
||||
if (extensions[instance_extension_count + i] == NULL) {
|
||||
goto glad_vk_get_extensions_error;
|
||||
}
|
||||
memcpy(extensions[instance_extension_count + i], ext.extensionName, extension_name_length * sizeof(char));
|
||||
}
|
||||
}
|
||||
|
||||
free((void*) ext_properties);
|
||||
|
||||
*out_extension_count = total_extension_count;
|
||||
*out_extensions = extensions;
|
||||
|
||||
return 1;
|
||||
|
||||
glad_vk_get_extensions_error:
|
||||
free((void*) ext_properties);
|
||||
if (extensions != NULL) {
|
||||
for (i = 0; i < total_extension_count; ++i) {
|
||||
free((void*) extensions[i]);
|
||||
}
|
||||
free(extensions);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void glad_vk_free_extensions(uint32_t extension_count, char **extensions) {
|
||||
uint32_t i;
|
||||
|
||||
for(i = 0; i < extension_count ; ++i) {
|
||||
free((void*) (extensions[i]));
|
||||
}
|
||||
|
||||
free((void*) extensions);
|
||||
}
|
||||
|
||||
static int glad_vk_has_extension(const char *name, uint32_t extension_count, char **extensions) {
|
||||
uint32_t i;
|
||||
|
||||
for (i = 0; i < extension_count; ++i) {
|
||||
if(extensions[i] != NULL && strcmp(name, extensions[i]) == 0) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static GLADapiproc glad_vk_get_proc_from_userptr(void *userptr, const char* name) {
|
||||
return (GLAD_GNUC_EXTENSION (GLADapiproc (*)(const char *name)) userptr)(name);
|
||||
}
|
||||
|
||||
{% for api in feature_set.info.apis %}
|
||||
static int glad_vk_find_extensions_{{ api|lower }}({{ template_utils.context_arg(',') }} VkPhysicalDevice physical_device) {
|
||||
uint32_t extension_count = 0;
|
||||
char **extensions = NULL;
|
||||
if (!glad_vk_get_extensions({{'context, ' if options.mx }}physical_device, &extension_count, &extensions)) return 0;
|
||||
|
||||
{% for extension in feature_set.extensions %}
|
||||
{% call template_utils.protect(extension) %}
|
||||
{{ ('GLAD_' + extension.name)|ctx(name_only=True) }} = glad_vk_has_extension("{{ extension.name }}", extension_count, extensions);
|
||||
{% endcall %}
|
||||
{% endfor %}
|
||||
|
||||
{# Special case: only one extension which is protected -> unused at compile time only on some platforms #}
|
||||
GLAD_UNUSED(&glad_vk_has_extension);
|
||||
|
||||
glad_vk_free_extensions(extension_count, extensions);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int glad_vk_find_core_{{ api|lower }}({{ template_utils.context_arg(',') }} VkPhysicalDevice physical_device) {
|
||||
int major = 1;
|
||||
int minor = 0;
|
||||
|
||||
#ifdef VK_VERSION_1_1
|
||||
if ({{ 'vkEnumerateInstanceVersion'|ctx }} != NULL) {
|
||||
uint32_t version;
|
||||
VkResult result;
|
||||
|
||||
result = {{ 'vkEnumerateInstanceVersion'|ctx }}(&version);
|
||||
if (result == VK_SUCCESS) {
|
||||
major = (int) VK_VERSION_MAJOR(version);
|
||||
minor = (int) VK_VERSION_MINOR(version);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (physical_device != NULL && {{ 'vkGetPhysicalDeviceProperties'|ctx }} != NULL) {
|
||||
VkPhysicalDeviceProperties properties;
|
||||
{{ 'vkGetPhysicalDeviceProperties'|ctx }}(physical_device, &properties);
|
||||
|
||||
major = (int) VK_VERSION_MAJOR(properties.apiVersion);
|
||||
minor = (int) VK_VERSION_MINOR(properties.apiVersion);
|
||||
}
|
||||
|
||||
{% for feature in feature_set.features %}
|
||||
{{ ('GLAD_' + feature.name)|ctx(name_only=True) }} = (major == {{ feature.version.major }} && minor >= {{ feature.version.minor }}) || major > {{ feature.version.major }};
|
||||
{% endfor %}
|
||||
|
||||
return GLAD_MAKE_VERSION(major, minor);
|
||||
}
|
||||
|
||||
int gladLoad{{ api|api }}{{ 'Context' if options.mx }}UserPtr({{ template_utils.context_arg(',') }} VkPhysicalDevice physical_device, GLADuserptrloadfunc load, void *userptr) {
|
||||
int version;
|
||||
|
||||
#ifdef VK_VERSION_1_1
|
||||
{{ 'vkEnumerateInstanceVersion '|ctx }} = (PFN_vkEnumerateInstanceVersion) load(userptr, "vkEnumerateInstanceVersion");
|
||||
#endif
|
||||
version = glad_vk_find_core_{{ api|lower }}({{ 'context,' if options.mx }} physical_device);
|
||||
if (!version) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
{% for feature, _ in loadable(feature_set.features) %}
|
||||
glad_vk_load_{{ feature.name }}({{'context, ' if options.mx }}load, userptr);
|
||||
{% endfor %}
|
||||
|
||||
if (!glad_vk_find_extensions_{{ api|lower }}({{ 'context,' if options.mx }} physical_device)) return 0;
|
||||
{% for extension, _ in loadable(feature_set.extensions) %}
|
||||
{% call template_utils.protect(extension) %}
|
||||
glad_vk_load_{{ extension.name }}({{'context, ' if options.mx }}load, userptr);
|
||||
{% endcall %}
|
||||
{% endfor %}
|
||||
|
||||
{% if options.mx_global %}
|
||||
gladSet{{ api|api }}Context(context);
|
||||
{% endif %}
|
||||
|
||||
{%- if options.alias %}
|
||||
glad_vk_resolve_aliases({{ 'context' if options.mx }});
|
||||
{% endif %}
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
{% if options.mx_global %}
|
||||
int gladLoad{{ api|api }}UserPtr(VkPhysicalDevice physical_device, GLADuserptrloadfunc load, void *userptr) {
|
||||
return gladLoad{{ api|api }}ContextUserPtr(gladGet{{ api|api }}Context(), physical_device, load, userptr);
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
int gladLoad{{ api|api }}{{ 'Context' if options.mx }}({{ template_utils.context_arg(',') }} VkPhysicalDevice physical_device, GLADloadfunc load) {
|
||||
return gladLoad{{ api|api }}{{ 'Context' if options.mx }}UserPtr({{'context,' if options.mx }} physical_device, glad_vk_get_proc_from_userptr, GLAD_GNUC_EXTENSION (void*) load);
|
||||
}
|
||||
|
||||
{% if options.mx_global %}
|
||||
int gladLoad{{ api|api }}(VkPhysicalDevice physical_device, GLADloadfunc load) {
|
||||
return gladLoad{{ api|api }}Context(gladGet{{ api|api }}Context(), physical_device, load);
|
||||
}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% if options.mx_global %}
|
||||
Glad{{ feature_set.name|api }}Context* gladGet{{ feature_set.name|api }}Context() {
|
||||
return {{ global_context }};
|
||||
}
|
||||
|
||||
void gladSet{{ feature_set.name|api }}Context(Glad{{ feature_set.name|api }}Context *context) {
|
||||
{{ global_context }} = context;
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
20
third-party/glad/glad/generator/c/templates/vk.h
vendored
Normal file
20
third-party/glad/glad/generator/c/templates/vk.h
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
{% extends 'base_template.h' %}
|
||||
|
||||
|
||||
{% block header %}
|
||||
{{ template_utils.header_error(feature_set.name, feature_set.name.upper() + '_H_', name) }}
|
||||
{{ template_utils.header_error(feature_set.name, feature_set.name.upper() + '_CORE_H_', name) }}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block custom_declarations %}
|
||||
{% for api in feature_set.info.apis %}
|
||||
GLAD_API_CALL int gladLoad{{ api|api }}{{ 'Context' if options.mx }}UserPtr({{ template_utils.context_arg(',') }} VkPhysicalDevice physical_device, GLADuserptrloadfunc load, void *userptr);
|
||||
GLAD_API_CALL int gladLoad{{ api|api }}{{ 'Context' if options.mx }}({{ template_utils.context_arg(',') }} VkPhysicalDevice physical_device, GLADloadfunc load);
|
||||
{% endfor %}
|
||||
|
||||
{% if options.mx_global %}
|
||||
GLAD_API_CALL int gladLoad{{ feature_set.name|api }}UserPtr(VkPhysicalDevice physical_device, GLADuserptrloadfunc load, void *userptr);
|
||||
GLAD_API_CALL int gladLoad{{ feature_set.name|api }}(VkPhysicalDevice physical_device, GLADloadfunc load);
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
98
third-party/glad/glad/generator/c/templates/wgl.c
vendored
Normal file
98
third-party/glad/glad/generator/c/templates/wgl.c
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
{% extends 'base_template.c' %}
|
||||
|
||||
{% block extension_loaders %}
|
||||
{% for extension, commands in loadable((feature_set.features[1:], feature_set.extensions)) %}
|
||||
static void glad_wgl_load_{{ extension.name }}(GLADuserptrloadfunc load, void *userptr) {
|
||||
if(!GLAD_{{ extension.name }}) return;
|
||||
{% for command in commands %}
|
||||
glad_{{ command.name }} = ({{ command.name|pfn }}) load(userptr, "{{ command.name }}");
|
||||
{% endfor %}
|
||||
}
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
|
||||
{% block loader %}
|
||||
static int glad_wgl_has_extension(HDC hdc, const char *ext) {
|
||||
const char *terminator;
|
||||
const char *loc;
|
||||
const char *extensions;
|
||||
|
||||
if(wglGetExtensionsStringEXT == NULL && wglGetExtensionsStringARB == NULL)
|
||||
return 0;
|
||||
|
||||
if(wglGetExtensionsStringARB == NULL || hdc == INVALID_HANDLE_VALUE)
|
||||
extensions = wglGetExtensionsStringEXT();
|
||||
else
|
||||
extensions = wglGetExtensionsStringARB(hdc);
|
||||
|
||||
if(extensions == NULL || ext == NULL)
|
||||
return 0;
|
||||
|
||||
while(1) {
|
||||
loc = strstr(extensions, ext);
|
||||
if(loc == NULL)
|
||||
break;
|
||||
|
||||
terminator = loc + strlen(ext);
|
||||
if((loc == extensions || *(loc - 1) == ' ') &&
|
||||
(*terminator == ' ' || *terminator == '\0'))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
extensions = terminator;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static GLADapiproc glad_wgl_get_proc_from_userptr(void *userptr, const char* name) {
|
||||
return (GLAD_GNUC_EXTENSION (GLADapiproc (*)(const char *name)) userptr)(name);
|
||||
}
|
||||
|
||||
{% for api in feature_set.info.apis %}
|
||||
static int glad_wgl_find_extensions_{{ api|lower }}(HDC hdc) {
|
||||
{% for extension in feature_set.extensions %}
|
||||
GLAD_{{ extension.name }} = glad_wgl_has_extension(hdc, "{{ extension.name }}");
|
||||
{% else %}
|
||||
GLAD_UNUSED(&glad_wgl_has_extension);
|
||||
{% endfor %}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int glad_wgl_find_core_{{ api|lower }}(void) {
|
||||
{% set hv = feature_set.features|select('supports', api)|list|last %}
|
||||
int major = {{ hv.version.major }}, minor = {{ hv.version.minor }};
|
||||
{% for feature in feature_set.features|select('supports', api) %}
|
||||
GLAD_{{ feature.name }} = (major == {{ feature.version.major }} && minor >= {{ feature.version.minor }}) || major > {{ feature.version.major }};
|
||||
{% endfor %}
|
||||
return GLAD_MAKE_VERSION(major, minor);
|
||||
}
|
||||
|
||||
int gladLoad{{ api|api }}UserPtr(HDC hdc, GLADuserptrloadfunc load, void *userptr) {
|
||||
int version;
|
||||
wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC) load(userptr, "wglGetExtensionsStringARB");
|
||||
wglGetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC) load(userptr, "wglGetExtensionsStringEXT");
|
||||
if(wglGetExtensionsStringARB == NULL && wglGetExtensionsStringEXT == NULL) return 0;
|
||||
version = glad_wgl_find_core_{{ api|lower }}();
|
||||
|
||||
{% for feature, _ in loadable(feature_set.features[1:], api=api) %}
|
||||
glad_wgl_load_{{ feature.name }}(load, userptr);
|
||||
{% endfor %}
|
||||
|
||||
if (!glad_wgl_find_extensions_{{ api|lower }}(hdc)) return 0;
|
||||
{% for extension, _ in loadable(feature_set.extensions, api=api) %}
|
||||
glad_wgl_load_{{ extension.name }}(load, userptr);
|
||||
{% endfor %}
|
||||
|
||||
{% if options.alias %}
|
||||
glad_wgl_resolve_aliases();
|
||||
{% endif %}
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
int gladLoad{{ api|api }}(HDC hdc, GLADloadfunc load) {
|
||||
return gladLoad{{ api|api }}UserPtr(hdc, glad_wgl_get_proc_from_userptr, GLAD_GNUC_EXTENSION (void*) load);
|
||||
}
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
22
third-party/glad/glad/generator/c/templates/wgl.h
vendored
Normal file
22
third-party/glad/glad/generator/c/templates/wgl.h
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
{% extends 'base_template.h' %}
|
||||
|
||||
{% block header %}
|
||||
#include <windows.h>
|
||||
#include <glad/gl.h>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block commands %}
|
||||
{{ template_utils.write_function_typedefs(feature_set.commands) }}
|
||||
{# these are already defined in windows.h #}
|
||||
{% set blacklist = feature_set.features[0].get_requirements(spec, feature_set=feature_set).commands %}
|
||||
{{ template_utils.write_function_declarations(feature_set.commands|reject('existsin', blacklist)) }}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block custom_declarations %}
|
||||
{% for api in feature_set.info.apis %}
|
||||
GLAD_API_CALL int gladLoad{{ api|api }}UserPtr(HDC hdc, GLADuserptrloadfunc load, void *userptr);
|
||||
GLAD_API_CALL int gladLoad{{ api|api }}(HDC hdc, GLADloadfunc load);
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
245
third-party/glad/glad/generator/rust/__init__.py
vendored
Normal file
245
third-party/glad/glad/generator/rust/__init__.py
vendored
Normal file
@@ -0,0 +1,245 @@
|
||||
import jinja2
|
||||
|
||||
import glad
|
||||
from glad.config import Config, ConfigOption
|
||||
from glad.generator import JinjaGenerator
|
||||
from glad.generator.util import (
|
||||
strip_specification_prefix,
|
||||
collect_alias_information,
|
||||
find_extensions_with_aliases,
|
||||
jinja2_contextfilter
|
||||
)
|
||||
from glad.parse import ParsedType, EnumType
|
||||
from glad.sink import LoggingSink
|
||||
|
||||
|
||||
_RUST_TYPE_MAPPING = {
|
||||
'void': 'c_void',
|
||||
'char': 'c_char',
|
||||
'uchar': 'c_uchar',
|
||||
'float': 'c_float',
|
||||
'double': 'c_double',
|
||||
'int': 'c_int',
|
||||
'long': 'c_long',
|
||||
'int8_t': 'i8',
|
||||
'uint8_t': 'u8',
|
||||
'int16_t': 'i16',
|
||||
'uint16_t': 'u16',
|
||||
'int32_t': 'i32',
|
||||
'int64_t': 'i32',
|
||||
'uint32_t': 'u32',
|
||||
'uint64_t': 'u64',
|
||||
'size_t': 'usize',
|
||||
'ull': 'u64',
|
||||
}
|
||||
|
||||
|
||||
def enum_type(enum, feature_set):
|
||||
if enum.alias and enum.value is None:
|
||||
aliased = feature_set.find_enum(enum.alias)
|
||||
if aliased is None:
|
||||
raise ValueError('unable to resolve enum alias {} of enum {}'.format(enum.alias, enum))
|
||||
enum = aliased
|
||||
|
||||
# if the value links to another enum, resolve the enum right now
|
||||
if enum.value is not None:
|
||||
# enum = feature_set.find_enum(enum.value, default=enum)
|
||||
referenced = feature_set.find_enum(enum.value)
|
||||
# TODO currently every enum with a parent type is u32
|
||||
if referenced is not None and referenced.parent_type is not None:
|
||||
return 'u32'
|
||||
|
||||
# we could return GLenum and friends here
|
||||
# but thanks to type aliasing we don't have to
|
||||
# this makes handling types for different specifications
|
||||
# easier, since we don't have to swap types. GLenum -> XXenum.
|
||||
if enum.type:
|
||||
_RUST_TYPE_MAPPING.get(enum.type, 'c_uint')
|
||||
|
||||
if enum.value.startswith('0x'):
|
||||
return 'u64' if len(enum.value[2:]) > 8 else 'c_uint'
|
||||
|
||||
if enum.name in ('GL_TRUE', 'GL_FALSE'):
|
||||
return 'c_uchar'
|
||||
|
||||
if enum.value.startswith('-'):
|
||||
return 'c_int'
|
||||
|
||||
if enum.value.endswith('f') or enum.value.endswith('F'):
|
||||
return 'c_float'
|
||||
|
||||
if enum.value.startswith('"'):
|
||||
# TODO figure out correct type
|
||||
return '&str'
|
||||
|
||||
if enum.value.startswith('(('):
|
||||
# Casts: '((Type)value)' -> 'Type'
|
||||
raise NotImplementedError
|
||||
|
||||
if enum.value.startswith('EGL_CAST'):
|
||||
# EGL_CAST(type,value) -> type
|
||||
return enum.value.split('(', 1)[1].split(',')[0]
|
||||
|
||||
return 'c_uint'
|
||||
|
||||
|
||||
def enum_value(enum, feature_set):
|
||||
if enum.alias and enum.value is None:
|
||||
enum = feature_set.find_enum(enum.alias)
|
||||
|
||||
# basically an alias to another enum (value contains another enum)
|
||||
# resolve it here and adjust value accordingly.
|
||||
referenced = feature_set.find_enum(enum.value)
|
||||
if referenced is None:
|
||||
pass
|
||||
elif referenced.parent_type is not None:
|
||||
# global value is a reference to a enum type value
|
||||
return '{}::{} as u32'.format(referenced.parent_type, enum.value)
|
||||
else:
|
||||
enum = referenced
|
||||
|
||||
value = enum.value
|
||||
if value.endswith('"'):
|
||||
value = value[:-1] + r'\0"'
|
||||
return value
|
||||
|
||||
if enum.value.startswith('EGL_CAST'):
|
||||
# EGL_CAST(type,value) -> value as type
|
||||
type_, value = enum.value.split('(', 1)[1].rsplit(')', 1)[0].split(',')
|
||||
return '{} as {}'.format(value, type_)
|
||||
|
||||
if enum.type == 'float' and value.endswith('F'):
|
||||
value = value[:-1]
|
||||
|
||||
for old, new in (('(', ''), (')', ''), ('f', ''),
|
||||
('U', ''), ('L', ''), ('~', '!')):
|
||||
value = value.replace(old, new)
|
||||
|
||||
return value
|
||||
|
||||
|
||||
def to_rust_type(type_):
|
||||
if type_ is None:
|
||||
return 'std::os::raw::c_void'
|
||||
|
||||
parsed_type = type_ if isinstance(type_, ParsedType) else ParsedType.from_string(type_)
|
||||
|
||||
if not parsed_type.is_pointer and parsed_type.type == 'void':
|
||||
return '()'
|
||||
|
||||
prefix = ''
|
||||
if parsed_type.is_pointer > 0:
|
||||
if parsed_type.is_const:
|
||||
prefix = '*const ' * parsed_type.is_pointer
|
||||
else:
|
||||
prefix = '*mut ' * parsed_type.is_pointer
|
||||
|
||||
type_ = _RUST_TYPE_MAPPING.get(parsed_type.type, parsed_type.type)
|
||||
|
||||
if parsed_type.is_array > 0:
|
||||
type_ = '[{};{}]'.format(type_, parsed_type.is_array)
|
||||
|
||||
return ' '.join(e.strip() for e in (prefix, type_)).strip()
|
||||
|
||||
|
||||
def to_rust_params(command, mode='full'):
|
||||
if mode == 'names':
|
||||
return ', '.join(identifier(param.name) for param in command.params)
|
||||
elif mode == 'types':
|
||||
return ', '.join(to_rust_type(param.type) for param in command.params)
|
||||
elif mode == 'full':
|
||||
return ', '.join(
|
||||
'{name}: {type}'.format(name=identifier(param.name), type=to_rust_type(param.type))
|
||||
for param in command.params
|
||||
)
|
||||
|
||||
raise ValueError('invalid mode: ' + mode)
|
||||
|
||||
|
||||
def identifier(name):
|
||||
if name in ('type', 'ref', 'box', 'in'):
|
||||
return name + '_'
|
||||
return name
|
||||
|
||||
|
||||
class RustConfig(Config):
|
||||
ALIAS = ConfigOption(
|
||||
converter=bool,
|
||||
default=False,
|
||||
description='Automatically adds all extensions that ' +
|
||||
'provide aliases for the current feature set.'
|
||||
)
|
||||
MX = ConfigOption(
|
||||
converter=bool,
|
||||
default=False,
|
||||
description='Enables support for multiple GL contexts'
|
||||
)
|
||||
|
||||
|
||||
class RustGenerator(JinjaGenerator):
|
||||
DISPLAY_NAME = 'Rust'
|
||||
|
||||
TEMPLATES = ['glad.generator.rust']
|
||||
Config = RustConfig
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
JinjaGenerator.__init__(self, *args, **kwargs)
|
||||
|
||||
self.environment.filters.update(
|
||||
feature=lambda x: 'feature = "{}"'.format(x),
|
||||
enum_type=jinja2_contextfilter(lambda ctx, enum: enum_type(enum, ctx['feature_set'])),
|
||||
enum_value=jinja2_contextfilter(lambda ctx, enum: enum_value(enum, ctx['feature_set'])),
|
||||
type=to_rust_type,
|
||||
params=to_rust_params,
|
||||
identifier=identifier,
|
||||
no_prefix=jinja2_contextfilter(lambda ctx, value: strip_specification_prefix(value, ctx['spec']))
|
||||
)
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
return 'rust'
|
||||
|
||||
def select(self, spec, api, version, profile, extensions, config, sink=LoggingSink(__name__)):
|
||||
if extensions is not None:
|
||||
extensions = set(extensions)
|
||||
|
||||
if config['ALIAS']:
|
||||
extensions.update(find_extensions_with_aliases(spec, api, version, profile, extensions))
|
||||
|
||||
return JinjaGenerator.select(self, spec, api, version, profile, extensions, config, sink=sink)
|
||||
|
||||
def get_template_arguments(self, spec, feature_set, config):
|
||||
args = JinjaGenerator.get_template_arguments(self, spec, feature_set, config)
|
||||
|
||||
args.update(
|
||||
version=glad.__version__,
|
||||
aliases=collect_alias_information(feature_set.commands)
|
||||
)
|
||||
|
||||
return args
|
||||
|
||||
def get_templates(self, spec, feature_set, config):
|
||||
return [
|
||||
('Cargo.toml', 'glad-{}/Cargo.toml'.format(feature_set.name)),
|
||||
('lib.rs', 'glad-{}/src/lib.rs'.format(feature_set.name)),
|
||||
('impl.rs', 'glad-{}/src/{}.rs'.format(feature_set.name, spec.name))
|
||||
]
|
||||
|
||||
def modify_feature_set(self, spec, feature_set, config):
|
||||
self._remove_empty_enums(feature_set)
|
||||
|
||||
return feature_set
|
||||
|
||||
def _remove_empty_enums(self, feature_set):
|
||||
"""
|
||||
There are some enums which are simply empty:
|
||||
https://github.com/KhronosGroup/Vulkan-Docs/issues/1754
|
||||
they need to be removed, we need to also remove any type which is an alias to that empty enum.
|
||||
"""
|
||||
to_remove = set()
|
||||
|
||||
for typ in (t for t in feature_set.types if isinstance(t, EnumType)):
|
||||
if typ.alias is None and not typ.enums_for(feature_set):
|
||||
to_remove.add(typ.name)
|
||||
|
||||
feature_set.types = [t for t in feature_set.types if t.name not in to_remove and t.alias not in to_remove]
|
||||
11
third-party/glad/glad/generator/rust/templates/Cargo.toml
vendored
Normal file
11
third-party/glad/glad/generator/rust/templates/Cargo.toml
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
[package]
|
||||
name = "glad-{{ feature_set.name }}"
|
||||
version = "{{ version }}"
|
||||
authors = ["David Herberth <github@dav1d.de>"]
|
||||
license = "(WTFPL OR CC0-1.0) AND Apache-2.0"
|
||||
|
||||
[features]
|
||||
{% for platform in spec.platforms.values() %}
|
||||
{{ platform.protect }} = []
|
||||
{{ platform.name }} = ["{{ platform.protect }}"]
|
||||
{% endfor %}
|
||||
148
third-party/glad/glad/generator/rust/templates/impl.rs
vendored
Normal file
148
third-party/glad/glad/generator/rust/templates/impl.rs
vendored
Normal file
@@ -0,0 +1,148 @@
|
||||
{% import 'template_utils.rs' as template_utils with context %}
|
||||
pub use self::types::*;
|
||||
pub use self::enumerations::*;
|
||||
pub use self::functions::*;
|
||||
|
||||
use std::os::raw::c_void;
|
||||
|
||||
{% set ctx_name = feature_set.name | capitalize %}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
struct FnPtr {
|
||||
ptr: *const c_void,
|
||||
is_loaded: bool
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl FnPtr {
|
||||
fn new(ptr: *const c_void) -> FnPtr {
|
||||
if !ptr.is_null() {
|
||||
FnPtr { ptr, is_loaded: true }
|
||||
} else {
|
||||
FnPtr { ptr: FnPtr::not_initialized as *const c_void, is_loaded: false }
|
||||
}
|
||||
}
|
||||
|
||||
fn set_ptr(&mut self, ptr: *const c_void) {
|
||||
*self = Self::new(ptr);
|
||||
}
|
||||
|
||||
fn aliased(&mut self, other: *const FnPtr) {
|
||||
unsafe {
|
||||
if !self.is_loaded && (*other).is_loaded {
|
||||
*self = *other;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[inline(never)]
|
||||
fn not_initialized() -> ! { panic!("{{ feature_set.name }}: function not initialized") }
|
||||
}
|
||||
|
||||
unsafe impl Sync for FnPtr {}
|
||||
unsafe impl Send for FnPtr {}
|
||||
|
||||
pub mod types {
|
||||
{% include 'types/' + spec.name + '.rs' ignore missing with context %}
|
||||
}
|
||||
|
||||
pub mod enumerations {
|
||||
#![allow(dead_code, non_upper_case_globals, unused_imports)]
|
||||
|
||||
use std::os::raw::*;
|
||||
use super::types::*;
|
||||
|
||||
{% for enum in feature_set.enums %}
|
||||
pub const {{ enum.name|no_prefix }}: {{ enum|enum_type }} = {{ enum|enum_value }};
|
||||
{% endfor %}
|
||||
}
|
||||
|
||||
pub mod functions {
|
||||
#![allow(non_snake_case, unused_variables, dead_code, unused_imports)]
|
||||
|
||||
use std::mem::transmute;
|
||||
use std::os::raw::*;
|
||||
use super::*;
|
||||
use super::types::*;
|
||||
|
||||
macro_rules! func {
|
||||
($fun:ident, $ret:ty, $($name:ident: $typ:ty),*) => {
|
||||
#[inline] pub unsafe fn $fun({{ '&self, ' if options.mx }}$($name: $typ),*) -> $ret {
|
||||
transmute::<_, extern "system" fn($($typ),*) -> $ret>({{ 'self.' if options.mx else 'storage::' }}$fun.ptr)($($name),*)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{% if options.mx %}
|
||||
pub struct {{ ctx_name }} {
|
||||
{% for command in feature_set.commands %}
|
||||
{{ template_utils.protect(command) }} pub(super) {{ command.name|no_prefix }}: FnPtr,
|
||||
{% endfor %}
|
||||
}
|
||||
|
||||
{% if not spec.name | capitalize == ctx_name %}
|
||||
pub type {{ spec.name | capitalize }} = {{ ctx_name }};
|
||||
{% endif %}
|
||||
|
||||
impl {{ ctx_name }} {
|
||||
{% endif %}
|
||||
|
||||
{% for command in feature_set.commands %}
|
||||
{{ template_utils.protect(command) }} func!({{ command.name|no_prefix }}, {{ command.proto.ret|type }}, {{ command|params }});
|
||||
{% endfor %}
|
||||
|
||||
{{ '}' if options.mx }}
|
||||
}
|
||||
|
||||
{% if not options.mx %}
|
||||
mod storage {
|
||||
#![allow(non_snake_case, non_upper_case_globals)]
|
||||
|
||||
use super::FnPtr;
|
||||
use std::os::raw::*;
|
||||
|
||||
macro_rules! store {
|
||||
($name:ident) => {
|
||||
pub(super) static mut $name: FnPtr = FnPtr { ptr: FnPtr::not_initialized as *const c_void, is_loaded: false };
|
||||
}
|
||||
}
|
||||
|
||||
{% for command in feature_set.commands %}
|
||||
{{ template_utils.protect(command) }} store!({{ command.name|no_prefix }});
|
||||
{% endfor %}
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
{% if options.mx %}
|
||||
pub fn load<F>(mut loadfn: F) -> functions::{{ ctx_name }} where F: FnMut(&'static str) -> *const c_void {
|
||||
#[allow(unused_mut)]
|
||||
let mut ctx = {{ ctx_name }} {
|
||||
{% for command in feature_set.commands %}
|
||||
{{ template_utils.protect(command.name) }} {{ command.name|no_prefix }}: FnPtr::new(loadfn("{{ command.name }}")),
|
||||
{% endfor %}
|
||||
};
|
||||
|
||||
{% for command, caliases in aliases|dictsort %}
|
||||
{% for alias in caliases|reject('equalto', command) %}
|
||||
{{ template_utils.protect(command) }} ctx.{{ command|no_prefix }}.aliased(std::ptr::addr_of!(ctx.{{ alias|no_prefix }}));
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
|
||||
ctx
|
||||
}
|
||||
{% else %}
|
||||
pub fn load<F>(mut loadfn: F) where F: FnMut(&'static str) -> *const c_void {
|
||||
unsafe {
|
||||
{% for command in feature_set.commands %}
|
||||
{{ template_utils.protect(command) }} storage::{{ command.name | no_prefix }}.set_ptr(loadfn("{{ command.name }}"));
|
||||
{% endfor %}
|
||||
|
||||
{% for command, caliases in aliases|dictsort %}
|
||||
{% for alias in caliases|reject('equalto', command) %}
|
||||
{{ template_utils.protect(command) }}{{ template_utils.protect(alias) }} storage::{{ command|no_prefix }}.aliased(std::ptr::addr_of!(storage::{{ alias|no_prefix }}));
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
}
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
2
third-party/glad/glad/generator/rust/templates/lib.rs
vendored
Normal file
2
third-party/glad/glad/generator/rust/templates/lib.rs
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
#[allow(clippy::all)]
|
||||
pub mod {{ spec.name }};
|
||||
6
third-party/glad/glad/generator/rust/templates/template_utils.rs
vendored
Normal file
6
third-party/glad/glad/generator/rust/templates/template_utils.rs
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
{% macro protect(symbol) %}
|
||||
{% set protections = spec.protections(symbol, feature_set=feature_set) %}
|
||||
{% if protections -%}
|
||||
#[cfg(any({{ protections|map('feature')|join(',') }}))]
|
||||
{%- endif -%}
|
||||
{%- endmacro %}
|
||||
82
third-party/glad/glad/generator/rust/templates/types/egl.rs
vendored
Normal file
82
third-party/glad/glad/generator/rust/templates/types/egl.rs
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
#![allow(dead_code, non_camel_case_types, non_snake_case)]
|
||||
{% include 'types/khrplatform.rs' %}
|
||||
|
||||
pub type EGLint = khronos_int32_t;
|
||||
|
||||
// TODO replace based on platform, see eglplatform.h
|
||||
#[cfg(target_os = "macos")] pub type EGLNativeDisplayType = i32;
|
||||
#[cfg(not(target_os = "macos"))] pub type EGLNativeDisplayType = *mut std::os::raw::c_void;
|
||||
pub type EGLNativeWindowType = *mut std::os::raw::c_void;
|
||||
pub type EGLNativePixmapType = *mut std::os::raw::c_void;
|
||||
|
||||
// EGL types
|
||||
pub type EGLBoolean = std::os::raw::c_uint;
|
||||
pub type EGLenum = std::os::raw::c_uint;
|
||||
|
||||
pub type EGLClientBuffer = *mut std::os::raw::c_void;
|
||||
pub type EGLConfig = *mut std::os::raw::c_void;
|
||||
pub type EGLContext = *mut std::os::raw::c_void;
|
||||
pub type EGLDeviceEXT = *mut std::os::raw::c_void;
|
||||
pub type EGLDisplay = *mut std::os::raw::c_void;
|
||||
pub type EGLImage = *mut std::os::raw::c_void;
|
||||
pub type EGLImageKHR = *mut std::os::raw::c_void;
|
||||
pub type EGLLabelKHR = *mut std::os::raw::c_void;
|
||||
pub type EGLObjectKHR = *mut std::os::raw::c_void;
|
||||
pub type EGLOutputLayerEXT = *mut std::os::raw::c_void;
|
||||
pub type EGLOutputPortEXT = *mut std::os::raw::c_void;
|
||||
pub type EGLStreamKHR = *mut std::os::raw::c_void;
|
||||
pub type EGLSurface = *mut std::os::raw::c_void;
|
||||
pub type EGLSync = *mut std::os::raw::c_void;
|
||||
pub type EGLSyncKHR = *mut std::os::raw::c_void;
|
||||
pub type EGLSyncNV = *mut std::os::raw::c_void;
|
||||
|
||||
pub type EGLAttrib = isize;
|
||||
pub type EGLAttribKHR = isize;
|
||||
pub enum __eglMustCastToProperFunctionPointerType_fn {}
|
||||
pub type __eglMustCastToProperFunctionPointerType = *mut __eglMustCastToProperFunctionPointerType_fn;
|
||||
pub type EGLNativeFileDescriptorKHR = std::os::raw::c_int;
|
||||
pub type EGLnsecsANDROID = khronos_stime_nanoseconds_t;
|
||||
pub type EGLsizeiANDROID = khronos_ssize_t;
|
||||
pub type EGLTimeKHR = khronos_utime_nanoseconds_t;
|
||||
pub type EGLTime = khronos_utime_nanoseconds_t;
|
||||
pub type EGLTimeNV = khronos_utime_nanoseconds_t;
|
||||
pub type EGLuint64KHR = khronos_uint64_t;
|
||||
pub type EGLuint64NV = khronos_utime_nanoseconds_t;
|
||||
pub struct AHardwareBuffer;
|
||||
|
||||
pub type EGLSetBlobFuncANDROID = extern "system" fn (
|
||||
*const std::os::raw::c_void,
|
||||
EGLsizeiANDROID,
|
||||
*const std::os::raw::c_void,
|
||||
EGLsizeiANDROID
|
||||
) -> ();
|
||||
pub type EGLGetBlobFuncANDROID = extern "system" fn (
|
||||
*const std::os::raw::c_void,
|
||||
EGLsizeiANDROID,
|
||||
*mut std::os::raw::c_void,
|
||||
EGLsizeiANDROID
|
||||
) -> EGLsizeiANDROID;
|
||||
pub type EGLDEBUGPROCKHR = extern "system" fn (
|
||||
error: EGLenum,
|
||||
command: *mut std::os::raw::c_char,
|
||||
messageType: EGLint,
|
||||
threadLabel: EGLLabelKHR,
|
||||
objectLabel: EGLLabelKHR,
|
||||
message: *mut std::os::raw::c_char
|
||||
) -> ();
|
||||
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct EGLClientPixmapHI {
|
||||
pData: *const std::os::raw::c_void,
|
||||
iWidth: EGLint,
|
||||
iHeight: EGLint,
|
||||
iStride: EGLint,
|
||||
}
|
||||
|
||||
pub type wl_display = std::os::raw::c_void;
|
||||
pub type wl_surface = std::os::raw::c_void;
|
||||
pub type wl_buffer = std::os::raw::c_void;
|
||||
pub type wl_resource = std::os::raw::c_void;
|
||||
|
||||
97
third-party/glad/glad/generator/rust/templates/types/gl.rs
vendored
Normal file
97
third-party/glad/glad/generator/rust/templates/types/gl.rs
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
#![allow(dead_code, non_snake_case, non_camel_case_types)]
|
||||
|
||||
use std::os::raw;
|
||||
|
||||
pub type GLvoid = raw::c_void;
|
||||
|
||||
pub type GLbyte = raw::c_char;
|
||||
pub type GLubyte = raw::c_uchar;
|
||||
pub type GLchar = raw::c_char;
|
||||
pub type GLboolean = raw::c_uchar;
|
||||
|
||||
pub type GLshort = raw::c_short;
|
||||
pub type GLushort = raw::c_ushort;
|
||||
|
||||
pub type GLint = raw::c_int;
|
||||
pub type GLuint = raw::c_uint;
|
||||
pub type GLint64 = i64;
|
||||
pub type GLuint64 = u64;
|
||||
|
||||
pub type GLintptr = isize;
|
||||
pub type GLsizeiptr = isize;
|
||||
pub type GLintptrARB = isize;
|
||||
pub type GLsizeiptrARB = isize;
|
||||
pub type GLint64EXT = i64;
|
||||
pub type GLuint64EXT = u64;
|
||||
|
||||
pub type GLsizei = GLint;
|
||||
pub type GLclampx = raw::c_int;
|
||||
pub type GLfixed = GLint;
|
||||
pub type GLhalf = raw::c_ushort;
|
||||
pub type GLhalfNV = raw::c_ushort;
|
||||
pub type GLhalfARB = raw::c_ushort;
|
||||
|
||||
pub type GLenum = raw::c_uint;
|
||||
pub type GLbitfield = raw::c_uint;
|
||||
|
||||
pub type GLfloat = raw::c_float;
|
||||
pub type GLdouble = raw::c_double;
|
||||
pub type GLclampf = raw::c_float;
|
||||
pub type GLclampd = raw::c_double;
|
||||
|
||||
pub type GLcharARB = raw::c_char;
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
pub type GLhandleARB = *const raw::c_void;
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
pub type GLhandleARB = raw::c_uint;
|
||||
|
||||
pub enum __GLsync {}
|
||||
|
||||
pub type GLsync = *const __GLsync;
|
||||
|
||||
pub enum _cl_context {}
|
||||
|
||||
pub enum _cl_event {}
|
||||
|
||||
pub type GLvdpauSurfaceNV = GLintptr;
|
||||
pub type GLeglClientBufferEXT = *const raw::c_void;
|
||||
pub type GLeglImageOES = *const raw::c_void;
|
||||
|
||||
|
||||
pub type GLDEBUGPROC = extern "system" fn (
|
||||
source: GLenum,
|
||||
type_: GLenum,
|
||||
id: GLuint,
|
||||
severity: GLenum,
|
||||
length: GLsizei,
|
||||
message: *const GLchar,
|
||||
userParam: *mut raw::c_void,
|
||||
);
|
||||
pub type GLDEBUGPROCARB = extern "system" fn (
|
||||
source: GLenum,
|
||||
type_: GLenum,
|
||||
id: GLuint,
|
||||
severity: GLenum,
|
||||
length: GLsizei,
|
||||
message: *const GLchar,
|
||||
userParam: *mut raw::c_void,
|
||||
);
|
||||
pub type GLDEBUGPROCKHR = extern "system" fn (
|
||||
source: GLenum,
|
||||
type_: GLenum,
|
||||
id: GLuint,
|
||||
severity: GLenum,
|
||||
length: GLsizei,
|
||||
message: *const GLchar,
|
||||
userParam: *mut GLvoid,
|
||||
);
|
||||
pub type GLDEBUGPROCAMD = extern "system" fn (
|
||||
id: GLuint,
|
||||
category: GLenum,
|
||||
severity: GLenum,
|
||||
length: GLsizei,
|
||||
message: *const GLchar,
|
||||
userParam: *mut GLvoid,
|
||||
);
|
||||
pub type GLVULKANPROCNV = extern "system" fn ();
|
||||
137
third-party/glad/glad/generator/rust/templates/types/glx.rs
vendored
Normal file
137
third-party/glad/glad/generator/rust/templates/types/glx.rs
vendored
Normal file
@@ -0,0 +1,137 @@
|
||||
#![allow(dead_code, non_camel_case_types, non_snake_case)]
|
||||
{% include 'types/gl.rs' %}
|
||||
|
||||
use std;
|
||||
|
||||
pub type XID = std::os::raw::c_ulong;
|
||||
pub type Bool = std::os::raw::c_int;
|
||||
pub enum Display {}
|
||||
|
||||
pub type Font = XID;
|
||||
pub type Pixmap = XID;
|
||||
pub type Colormap = XID;
|
||||
pub type Status = XID;
|
||||
pub enum Visual {}
|
||||
pub type VisualID = std::os::raw::c_ulong;
|
||||
pub type Window = XID;
|
||||
pub type GLXFBConfigID = XID;
|
||||
pub type GLXFBConfig = *const std::os::raw::c_void;
|
||||
pub type GLXContextID = XID;
|
||||
pub type GLXContext = *const std::os::raw::c_void;
|
||||
pub type GLXPixmap = XID;
|
||||
pub type GLXDrawable = XID;
|
||||
pub type GLXWindow = XID;
|
||||
pub type GLXPbuffer = XID;
|
||||
pub enum __GLXextFuncPtr_fn {}
|
||||
pub type __GLXextFuncPtr = *mut __GLXextFuncPtr_fn;
|
||||
pub type GLXVideoCaptureDeviceNV = XID;
|
||||
pub type GLXVideoDeviceNV = std::os::raw::c_int;
|
||||
pub type GLXVideoSourceSGIX = XID;
|
||||
pub type GLXFBConfigIDSGIX = XID;
|
||||
pub type GLXFBConfigSGIX = *const std::os::raw::c_void;
|
||||
pub type GLXPbufferSGIX = XID;
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct XVisualInfo {
|
||||
pub visual: *mut Visual,
|
||||
pub visualid: VisualID,
|
||||
pub screen: std::os::raw::c_int,
|
||||
pub depth: std::os::raw::c_int,
|
||||
pub class: std::os::raw::c_int,
|
||||
pub red_mask: std::os::raw::c_ulong,
|
||||
pub green_mask: std::os::raw::c_ulong,
|
||||
pub blue_mask: std::os::raw::c_ulong,
|
||||
pub colormap_size: std::os::raw::c_int,
|
||||
pub bits_per_rgb: std::os::raw::c_int,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct GLXPbufferClobberEvent {
|
||||
pub event_type: std::os::raw::c_int,
|
||||
pub draw_type: std::os::raw::c_int,
|
||||
pub serial: std::os::raw::c_ulong,
|
||||
pub send_event: Bool,
|
||||
pub display: *const Display,
|
||||
pub drawable: GLXDrawable,
|
||||
pub buffer_mask: std::os::raw::c_uint,
|
||||
pub aux_buffer: std::os::raw::c_uint,
|
||||
pub x: std::os::raw::c_int,
|
||||
pub y: std::os::raw::c_int,
|
||||
pub width: std::os::raw::c_int,
|
||||
pub height: std::os::raw::c_int,
|
||||
pub count: std::os::raw::c_int,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct GLXBufferSwapComplete {
|
||||
pub type_: std::os::raw::c_int,
|
||||
pub serial: std::os::raw::c_ulong,
|
||||
pub send_event: Bool,
|
||||
pub display: *const Display,
|
||||
pub drawable: GLXDrawable,
|
||||
pub event_type: std::os::raw::c_int,
|
||||
pub ust: i64,
|
||||
pub msc: i64,
|
||||
pub sbc: i64,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct GLXBufferClobberEventSGIX {
|
||||
pub type_: std::os::raw::c_int,
|
||||
pub serial: std::os::raw::c_ulong,
|
||||
pub send_event: Bool,
|
||||
pub display: *const Display,
|
||||
pub drawable: GLXDrawable,
|
||||
pub event_type: std::os::raw::c_int,
|
||||
pub draw_type: std::os::raw::c_int,
|
||||
pub mask: std::os::raw::c_uint,
|
||||
pub x: std::os::raw::c_int,
|
||||
pub y: std::os::raw::c_int,
|
||||
pub width: std::os::raw::c_int,
|
||||
pub height: std::os::raw::c_int,
|
||||
pub count: std::os::raw::c_int,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct GLXHyperpipeNetworkSGIX {
|
||||
pub pipeName: [std::os::raw::c_char; super::enumerations::HYPERPIPE_PIPE_NAME_LENGTH_SGIX as usize],
|
||||
pub networkId: std::os::raw::c_int,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct GLXHyperpipeConfigSGIX {
|
||||
pub pipeName: [std::os::raw::c_char; super::enumerations::HYPERPIPE_PIPE_NAME_LENGTH_SGIX as usize],
|
||||
pub channel: std::os::raw::c_int,
|
||||
pub participationType: std::os::raw::c_uint,
|
||||
pub timeSlice: std::os::raw::c_int,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct GLXPipeRect {
|
||||
pub pipeName: [std::os::raw::c_char; super::enumerations::HYPERPIPE_PIPE_NAME_LENGTH_SGIX as usize],
|
||||
pub srcXOrigin: std::os::raw::c_int,
|
||||
pub srcYOrigin: std::os::raw::c_int,
|
||||
pub srcWidth: std::os::raw::c_int,
|
||||
pub srcHeight: std::os::raw::c_int,
|
||||
pub destXOrigin: std::os::raw::c_int,
|
||||
pub destYOrigin: std::os::raw::c_int,
|
||||
pub destWidth: std::os::raw::c_int,
|
||||
pub destHeight: std::os::raw::c_int,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct GLXPipeRectLimits {
|
||||
pub pipeName: [std::os::raw::c_char; super::enumerations::HYPERPIPE_PIPE_NAME_LENGTH_SGIX as usize],
|
||||
pub XOrigin: std::os::raw::c_int,
|
||||
pub YOrigin: std::os::raw::c_int,
|
||||
pub maxHeight: std::os::raw::c_int,
|
||||
pub maxWidth: std::os::raw::c_int,
|
||||
}
|
||||
21
third-party/glad/glad/generator/rust/templates/types/khrplatform.rs
vendored
Normal file
21
third-party/glad/glad/generator/rust/templates/types/khrplatform.rs
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
#![allow(non_camel_case_types)]
|
||||
|
||||
use std;
|
||||
|
||||
// see khrplatform.h for these types
|
||||
pub type khronos_int8_t = i8;
|
||||
pub type khronos_uint8_t = u8;
|
||||
pub type khronos_int16_t = i16;
|
||||
pub type khronos_uint16_t = u16;
|
||||
pub type khronos_int32_t = i32;
|
||||
pub type khronos_uint32_t = u32;
|
||||
pub type khronos_int64_t = i64;
|
||||
pub type khronos_uint64_t = u64;
|
||||
pub type khronos_intptr_t = isize;
|
||||
pub type khronos_uintptr_t = usize;
|
||||
pub type khronos_ssize_t = isize;
|
||||
pub type khronos_usize_t = usize;
|
||||
pub type khronos_float_t = std::os::raw::c_float;
|
||||
pub type khronos_time_ns_t = u64;
|
||||
pub type khronos_stime_nanoseconds_t = i64;
|
||||
pub type khronos_utime_nanoseconds_t = u64;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user