GPU: Experimental WebGPU SDLGPU Backend (#16020)

This commit is contained in:
The Stickmahn
2026-11-28 09:43:19 -08:00
committed by GitHub
parent 50ce1ed250
commit 01b2a215ba
58 changed files with 16165 additions and 11 deletions
+87
View File
@@ -0,0 +1,87 @@
name: 'Setup Google Dawn'
description: 'Download Dawn GitHub release archive'
inputs:
platform:
description: 'Platform (macos-latest, ubuntu-latest, windows-latest)'
required: true
shell:
description: 'Shell'
required: true
dawn-release-name:
description: 'git tag of the Google Dawn release'
default: 'v20260819.212523'
dawn-git-tag:
description: 'git hash of dawn release (depends on dawn-release-name)'
default: 'e463578aa391834c1cf889ef0024e9978057f39a'
runs:
using: 'composite'
steps:
- name: 'Calculate variables'
id: calc
shell: sh
run: |
case "${{ inputs.platform }}" in
"macos-latest" | "ubuntu-latest" | "windows-latest")
# https://github.com/google/dawn/releases/download/v20260819.212523/Dawn-e463578aa391834c1cf889ef0024e9978057f39a-macos-latest-Release.tar.gz
# https://github.com/google/dawn/releases/download/v20260819.212523/Dawn-e463578aa391834c1cf889ef0024e9978057f39a-ubuntu-latest-Release.tar.gz
# https://github.com/google/dawn/releases/download/v20260819.212523/Dawn-e463578aa391834c1cf889ef0024e9978057f39a-windows-latest-Release.tar.gz
dirname="Dawn-${{ inputs.dawn-git-tag }}-${{ inputs.platform }}-Release"
archive="${dirname}.tar.gz"
url="https://github.com/google/dawn/releases/download/${{ inputs.dawn-release-name }}/$archive"
;;
*)
echo "Unsupported ${{ runner.os }}-${{ runner.inputs.platform }}"
exit 1;
;;
esac
extract_dir="$(echo '${{ runner.temp }}' | sed -E 's#\\#/#g')"
extract_dir_unix="${extract_dir}"
if [ x${{ runner.os }} = xWindows ]; then
extract_dir_unix="$(cygpath -u "$extract_dir")"
fi
echo "extract-dir=${extract_dir}" >> ${GITHUB_OUTPUT}
echo "extract-dir-unix=${extract_dir_unix}" >> ${GITHUB_OUTPUT}
echo "archive=${archive}" >> ${GITHUB_OUTPUT}
echo "dirname=${dirname}" >> ${GITHUB_OUTPUT}
echo "url=${url}" >> ${GITHUB_OUTPUT}
echo "cache-key=${archive}-${{ inputs.platform }}" >> ${GITHUB_OUTPUT}
- name: 'Restore cached ${{ steps.calc.outputs.archive }}'
id: cache-restore
uses: actions/cache/restore@v5
with:
path: '${{ steps.calc.outputs.extract-dir }}/${{ steps.calc.outputs.archive }}'
key: ${{ steps.calc.outputs.cache-key }}
- name: 'Download Dawn ${{ inputs.dawn-release-name }} for ${{ inputs.platform }}'
if: ${{ !steps.cache-restore.outputs.cache-hit || steps.cache-restore.outputs.cache-hit == 'false' }}
shell: pwsh
run: |
Invoke-WebRequest "${{ steps.calc.outputs.url }}" -OutFile "${{ steps.calc.outputs.extract-dir }}/${{ steps.calc.outputs.archive }}"
- name: 'Cache ${{ steps.calc.outputs.archive }}'
if: ${{ !steps.cache-restore.outputs.cache-hit || steps.cache-restore.outputs.cache-hit == 'false' }}
uses: actions/cache/save@v5
with:
path: '${{ steps.calc.outputs.extract-dir }}/${{ steps.calc.outputs.archive }}'
key: ${{ steps.calc.outputs.cache-key }}
- name: 'Extract Dawn'
shell: sh
run: |
cd "${{ steps.calc.outputs.extract-dir-unix }}"
tar xf "${{ steps.calc.outputs.extract-dir-unix }}/${{ steps.calc.outputs.archive }}"
if [ ! -d "${{ steps.calc.outputs.extract-dir-unix }}/${{ steps.calc.outputs.dirname }}" ]; then
echo "Extraction failes: ${{ steps.calc.outputs.extract-dir }}/${{ steps.calc.outputs.dirname }} directory does not exist"
exit 1
fi
- name: 'Set output variables'
id: final
shell: ${{ inputs.shell }}
run: |
dawn_prefix="${{ steps.calc.outputs.extract-dir }}/${{ steps.calc.outputs.dirname }}"
if [ -f "${dawn_prefix}/cmake/DawnConfig.cmake" ]; then
echo "Dawn_DIR=${dawn_prefix}/cmake" >> ${GITHUB_ENV}
elif [ -d "${dawn_prefix}/lib/cmake" ]; then
echo "Dawn_DIR=${dawn_prefix}/lib/cmake" >> ${GITHUB_ENV}
elif [ -d "${dawn_prefix}/lib64/cmake" ]; then
echo "Dawn_DIR=${dawn_prefix}/lib64/cmake" >> ${GITHUB_ENV}
fi
echo "Dawn_ROOT=${dawn_prefix}" >> ${GITHUB_ENV}
+10 -1
View File
@@ -133,6 +133,7 @@ class JobSpec:
gdk: bool = False
vita_gles: Optional[VitaGLES] = None
more_hard_deps: bool = False
dawn_webgpu: bool = False
allow_failure: bool = False
@@ -149,7 +150,7 @@ JOB_SPECS = {
"msvc-clang-x86": JobSpec(name="Windows (MSVC, clang-cl x86)", priority=False, os=JobOs.WindowsLatest, platform=SdlPlatform.Msvc, artifact="SDL-clang-cl-x86", msvc_arch=MsvcArch.X86, clang_cl=True, ),
"msvc-gdk-x64": JobSpec(name="GDK (MSVC, x64)", priority=False, os=JobOs.Windows2022, platform=SdlPlatform.Msvc, artifact="SDL-VC-GDK", msvc_arch=MsvcArch.X64, msvc_project="VisualC-GDK/SDL.sln", gdk=True, no_cmake=True, ),
"ubuntu-22.04": JobSpec(name="Ubuntu 22.04", priority=False, os=JobOs.Ubuntu22_04, platform=SdlPlatform.Linux, artifact="SDL-ubuntu22.04", ),
"ubuntu-latest": JobSpec(name="Ubuntu (latest)", priority=False, os=JobOs.UbuntuLatest, platform=SdlPlatform.Linux, artifact="SDL-ubuntu-latest", ),
"ubuntu-latest": JobSpec(name="Ubuntu (latest)", priority=False, os=JobOs.UbuntuLatest, platform=SdlPlatform.Linux, artifact="SDL-ubuntu-latest", dawn_webgpu=True, ),
"ubuntu-24.04-arm64": JobSpec(name="Ubuntu 24.04 (ARM64)", priority=False, os=JobOs.Ubuntu24_04_arm, platform=SdlPlatform.Linux, artifact="SDL-ubuntu24.04-arm64", ),
"steamrt3": JobSpec(name="Steam Linux Runtime 3.0 (x86_64)", priority=False, os=JobOs.UbuntuLatest, platform=SdlPlatform.Linux, artifact="SDL-steamrt3", container="registry.gitlab.steamos.cloud/steamrt/sniper/sdk:latest" ),
"steamrt4": JobSpec(name="Steam Linux Runtime 4.0 (x86_64)", priority=True, os=JobOs.UbuntuLatest, platform=SdlPlatform.Linux, artifact="SDL-steamrt4", container="registry.gitlab.steamos.cloud/steamrt/steamrt4/sdk:latest", more_hard_deps = True, ),
@@ -274,6 +275,7 @@ class JobDetails:
setup_gage_sdk_path: str = ""
binutils_strings: str = "strings"
ctest_args: str = ""
dawn_platform: bool = False
allow_failure: bool = False
def to_workflow(self, enable_artifacts: bool) -> dict[str, str|bool]:
@@ -348,6 +350,7 @@ class JobDetails:
"setup-ngage-sdk-path": self.setup_gage_sdk_path,
"binutils-strings": self.binutils_strings,
"ctest-args": self.ctest_args,
"dawn-platform": self.dawn_platform,
"allow-failure": self.allow_failure,
}
return {k: v for k, v in data.items() if v != ""}
@@ -544,6 +547,9 @@ def spec_to_job(spec: JobSpec, key: str, trackmem_symbol_names: bool, ctest_args
job.apt_packages.extend((
"libunwind-dev", # For SDL_test memory tracking
))
if spec.dawn_webgpu:
job.cmake_arguments.append("-DDawn_DIR=${Dawn_DIR}")
job.dawn_platform = "ubuntu-latest"
job.ccache = True
if trackmem_symbol_names:
# older libunwind is slow
@@ -830,6 +836,9 @@ def spec_to_job(spec: JobSpec, key: str, trackmem_symbol_names: bool, ctest_args
job.msys2_packages.append(f"{msys2_env}-ffmpeg")
if job.ccache:
job.msys2_packages.append(f"{msys2_env}-ccache")
if spec.dawn_webgpu:
job.cmake_arguments.append("-DDawn_DIR=${Dawn_DIR}")
job.dawn_platform = "windows-latest"
case SdlPlatform.Cygwin:
job.ccache = False # Missing evict-older-than option
job.clang_tidy = False # error finding files [clang-diagnostic-error] cause might be space in command path
+7 -1
View File
@@ -55,7 +55,7 @@ jobs:
- uses: mymindstorm/setup-emsdk@v15
if: ${{ matrix.platform.platform == 'emscripten' }}
with:
version: 3.1.35
version: 4.0.10
- uses: browser-actions/setup-chrome@v2
id: setup-chrome
if: ${{ matrix.platform.platform == 'emscripten' && matrix.platform.run-tests }}
@@ -94,6 +94,12 @@ jobs:
with:
arch: ${{ matrix.platform.msvc-vcvars-arch }}
sdk: ${{ matrix.platform.msvc-vcvars-sdk }}
- name: 'Set up Google Dawn SDK'
uses: ./.github/actions/setup-dawn
if: ${{ matrix.platform.dawn-platform != '' }}
with:
platform: ${{ matrix.platform.dawn-platform }}
shell: ${{ matrix.platform.shell }}
- name: 'Set up Nokia N-Gage SDK'
uses: ./.github/actions/setup-ngage-sdk
if: ${{ matrix.platform.setup-ngage-sdk-path != '' }}
+18
View File
@@ -288,6 +288,8 @@ endif()
set(SDL_VULKAN_DEFAULT ON)
set(SDL_WGPU_DEFAULT ON)
set(SDL_X11_XRANDR_DEFAULT ON)
if(SOLARIS)
set(SDL_VULKAN_DEFAULT OFF)
@@ -381,6 +383,8 @@ dep_option(SDL_RENDER_METAL "Enable the Metal render driver" ON "SDL_REND
dep_option(SDL_RENDER_GPU "Enable the SDL_GPU render driver" ON "SDL_RENDER;SDL_GPU" OFF)
dep_option(SDL_VIVANTE "Use Vivante EGL video driver" ON "${UNIX_SYS};SDL_CPU_ARM32" OFF)
dep_option(SDL_VULKAN "Enable Vulkan support" "${SDL_VULKAN_DEFAULT}" "SDL_VIDEO;ANDROID OR APPLE OR LINUX OR FREEBSD OR OPENBSD OR WINDOWS OR CYGWIN OR OHOS" OFF)
dep_option(SDL_WEBGPU "Enable experimental WebGPU support" "${SDL_WGPU_DEFAULT}" "SDL_GPU;WINDOWS OR UNIX OR EMSCRIPTEN;NOT APPLE" OFF)
dep_option(SDL_WEBGPU_EMSCRIPTEN "Allow SDL to automatically link with Emscripten's WebGPU implementation" "TRUE" "SDL_WEBGPU;EMSCRIPTEN" OFF)
dep_option(SDL_RENDER_VULKAN "Enable the Vulkan render driver" ON "SDL_RENDER;SDL_VULKAN" OFF)
dep_option(SDL_METAL "Enable Metal support" ON "APPLE" OFF)
set_option(SDL_OPENVR "Use OpenVR video driver" OFF)
@@ -1891,6 +1895,7 @@ elseif(EMSCRIPTEN)
# project. Uncomment at will for verbose cross-compiling -I/../ path info.
sdl_compile_options(PRIVATE "-Wno-warn-absolute-paths")
CheckWebGPU()
if(NOT SDL_EMSCRIPTEN_PERSISTENT_PATH STREQUAL "")
set(SDL_EMSCRIPTEN_PERSISTENT_PATH_STRING "${SDL_EMSCRIPTEN_PERSISTENT_PATH}")
sdl_link_dependency(idbfs LIBS idbfs.js)
@@ -2088,6 +2093,7 @@ elseif(UNIX AND NOT (APPLE OR RISCOS OR HAIKU OR CYGWIN))
CheckVivante()
CheckVulkan()
CheckQNXScreen()
CheckWebGPU()
endif()
if(SDL_TRAY)
@@ -2691,6 +2697,10 @@ elseif(WINDOWS OR CYGWIN)
set(HAVE_RENDER_VULKAN TRUE)
endif()
endif()
if(SDL_WEBGPU)
CheckWebGPU()
endif()
endif()
if(SDL_TRAY)
@@ -3874,6 +3884,14 @@ if(SDL_GPU)
set(SDL_GPU_VULKAN 1)
set(HAVE_SDL_GPU TRUE)
endif()
if(SDL_VIDEO_WEBGPU)
sdl_glob_sources(
"${SDL3_SOURCE_DIR}/src/gpu/webgpu/*.c"
"${SDL3_SOURCE_DIR}/src/gpu/webgpu/*.h"
)
set(SDL_GPU_WEBGPU 1)
set(HAVE_SDL_GPU TRUE)
endif()
if(SDL_VIDEO_METAL)
sdl_glob_sources(
"${SDL3_SOURCE_DIR}/src/gpu/metal/*.m"
+59 -5
View File
@@ -620,24 +620,24 @@ macro(CheckLibThai)
endmacro()
macro(WaylandProtocolGen _SCANNER _CODE_MODE _XML _PROTL)
set(_WAYLAND_PROT_C_CODE "${CMAKE_CURRENT_BINARY_DIR}/wayland-generated-protocols/${_PROTL}-protocol.c")
set(_WAYLAND_PROT_H_CODE "${CMAKE_CURRENT_BINARY_DIR}/wayland-generated-protocols/${_PROTL}-client-protocol.h")
set(_WAYLAND_PROT_C_CODE "${CMAKE_CURRENT_BINARY_DIR}/wayland-generated-protocols/${_PROTL}-protocol.c")
set(_WAYLAND_PROT_H_CODE "${CMAKE_CURRENT_BINARY_DIR}/wayland-generated-protocols/${_PROTL}-client-protocol.h")
add_custom_command(
add_custom_command(
OUTPUT "${_WAYLAND_PROT_H_CODE}"
DEPENDS "${_XML}"
COMMAND "${_SCANNER}"
ARGS client-header "${_XML}" "${_WAYLAND_PROT_H_CODE}"
)
add_custom_command(
add_custom_command(
OUTPUT "${_WAYLAND_PROT_C_CODE}"
DEPENDS "${_WAYLAND_PROT_H_CODE}"
COMMAND "${_SCANNER}"
ARGS "${_CODE_MODE}" "${_XML}" "${_WAYLAND_PROT_C_CODE}"
)
sdl_sources("${_WAYLAND_PROT_C_CODE}")
sdl_sources("${_WAYLAND_PROT_C_CODE}")
endmacro()
# Requires:
@@ -949,6 +949,60 @@ macro(CheckVulkan)
endif()
endmacro()
macro(CheckWebGPU)
set(HAVE_WEBGPU FALSE)
if(SDL_WEBGPU)
if(SDL_WEBGPU_EMSCRIPTEN)
message(STATUS "Using Emdawnwebgpu (remote) as WebGPU implementation")
# NOTE: Since the Emdawnwebgpu port is the official Emscripten provided
# way to link WebGPU, I thought it would be okay to just have SDL do it.
# There's an option to disable this, and since the port is just a python script
# we could use our own if supply-chain attacks are an issue.
# (Although, if somebody's breached the Emscripten repo there's probably bigger issues.)
# https://github.com/emscripten-core/emscripten/blob/main/tools/ports/emdawnwebgpu.py
sdl_compile_options(PRIVATE "--use-port=emdawnwebgpu")
sdl_link_dependency(sdlgpu-emdawnwebgpu LINK_OPTIONS "--use-port=emdawnwebgpu")
set(HAVE_WEBGPU_EMSCRIPTEN TRUE)
set(HAVE_WEBGPU TRUE)
else()
check_language(CXX)
find_package(Dawn QUIET)
if(CMAKE_CXX_COMPILER AND Dawn_FOUND)
find_package(Threads)
set(HAVE_WEBGPU TRUE)
sdl_link_dependency(sdlgpu-dawn-threads CMAKE_MODULE Threads)
sdl_link_dependency(sdlgpu-dawn LIBS dawn::webgpu_dawn CMAKE_MODULE Dawn)
message("-- Using Dawn as WebGPU implementation")
endif()
endif()
if(HAVE_WEBGPU)
set(SDL_VIDEO_WEBGPU 1)
# Dawn's a C++ library, so we'll have to enable C++
enable_language(CXX)
# Dawn includes
if(HAVE_WAYLAND)
sdl_sources("${SDL3_SOURCE_DIR}/src/video/wayland/SDL_waylandwgpu_dawn.cpp")
endif()
if(HAVE_X11)
sdl_sources("${SDL3_SOURCE_DIR}/src/video/x11/SDL_x11wgpu_dawn.cpp")
endif()
if(WINDOWS)
sdl_sources("${SDL3_SOURCE_DIR}/src/video/windows/SDL_windowswgpu_dawn.cpp")
endif()
if(EMSCRIPTEN)
sdl_sources("${SDL3_SOURCE_DIR}/src/video/emscripten/SDL_emscriptenwgpu_dawn.cpp")
endif()
set(WEBGPU_STATIC 1)
endif()
endif()
endmacro()
# Requires:
# - EGL
macro(CheckQNXScreen)
+2 -1
View File
@@ -103,7 +103,7 @@ macro(add_sdl_example_executable TARGET)
endif()
elseif(EMSCRIPTEN)
set_property(TARGET ${TARGET} PROPERTY SUFFIX ".html")
target_link_options(${TARGET} PRIVATE -sALLOW_MEMORY_GROWTH=1)
target_link_options(${TARGET} PRIVATE -sALLOW_MEMORY_GROWTH=1 -sASYNCIFY=1) # The WebGPU SDLGPU backend requires Asyncify.
elseif(N3DS)
set(ROMFS_DIR "${CMAKE_CURRENT_BINARY_DIR}/romfs/${TARGET}")
file(MAKE_DIRECTORY "${ROMFS_DIR}")
@@ -165,6 +165,7 @@ add_sdl_example_executable(demo-snake SOURCES demo/01-snake/snake.c)
add_sdl_example_executable(demo-woodeneye-008 SOURCES demo/02-woodeneye-008/woodeneye-008.c)
add_sdl_example_executable(demo-infinite-monkeys SOURCES demo/03-infinite-monkeys/infinite-monkeys.c)
add_sdl_example_executable(demo-bytepusher SOURCES demo/04-bytepusher/bytepusher.c)
add_sdl_example_executable(gpu-orbital-simulation SOURCES gpu/01-orbital-simulation/orbit.c gpu/01-orbital-simulation/math.c)
# When you add an example, remember to add the Visual Studio project as well:
# - Add a new example in examples/
@@ -0,0 +1,4 @@
This is a small SDLGPU application which simulates asteroids orbiting around Earth.
It uses compute shaders to calculate each asteroid's position and velocity, and instancing to render them.
Press left/right to decrease/increase timestep, and up/down to increase/decrease the asteroid count.
+210
View File
@@ -0,0 +1,210 @@
#include "math.h"
// Matrix Math
Matrix4x4 Matrix4x4_Multiply(Matrix4x4 matrix1, Matrix4x4 matrix2) {
Matrix4x4 result;
result.m11 = ((matrix1.m11 * matrix2.m11) + (matrix1.m12 * matrix2.m21) +
(matrix1.m13 * matrix2.m31) + (matrix1.m14 * matrix2.m41));
result.m12 = ((matrix1.m11 * matrix2.m12) + (matrix1.m12 * matrix2.m22) +
(matrix1.m13 * matrix2.m32) + (matrix1.m14 * matrix2.m42));
result.m13 = ((matrix1.m11 * matrix2.m13) + (matrix1.m12 * matrix2.m23) +
(matrix1.m13 * matrix2.m33) + (matrix1.m14 * matrix2.m43));
result.m14 = ((matrix1.m11 * matrix2.m14) + (matrix1.m12 * matrix2.m24) +
(matrix1.m13 * matrix2.m34) + (matrix1.m14 * matrix2.m44));
result.m21 = ((matrix1.m21 * matrix2.m11) + (matrix1.m22 * matrix2.m21) +
(matrix1.m23 * matrix2.m31) + (matrix1.m24 * matrix2.m41));
result.m22 = ((matrix1.m21 * matrix2.m12) + (matrix1.m22 * matrix2.m22) +
(matrix1.m23 * matrix2.m32) + (matrix1.m24 * matrix2.m42));
result.m23 = ((matrix1.m21 * matrix2.m13) + (matrix1.m22 * matrix2.m23) +
(matrix1.m23 * matrix2.m33) + (matrix1.m24 * matrix2.m43));
result.m24 = ((matrix1.m21 * matrix2.m14) + (matrix1.m22 * matrix2.m24) +
(matrix1.m23 * matrix2.m34) + (matrix1.m24 * matrix2.m44));
result.m31 = ((matrix1.m31 * matrix2.m11) + (matrix1.m32 * matrix2.m21) +
(matrix1.m33 * matrix2.m31) + (matrix1.m34 * matrix2.m41));
result.m32 = ((matrix1.m31 * matrix2.m12) + (matrix1.m32 * matrix2.m22) +
(matrix1.m33 * matrix2.m32) + (matrix1.m34 * matrix2.m42));
result.m33 = ((matrix1.m31 * matrix2.m13) + (matrix1.m32 * matrix2.m23) +
(matrix1.m33 * matrix2.m33) + (matrix1.m34 * matrix2.m43));
result.m34 = ((matrix1.m31 * matrix2.m14) + (matrix1.m32 * matrix2.m24) +
(matrix1.m33 * matrix2.m34) + (matrix1.m34 * matrix2.m44));
result.m41 = ((matrix1.m41 * matrix2.m11) + (matrix1.m42 * matrix2.m21) +
(matrix1.m43 * matrix2.m31) + (matrix1.m44 * matrix2.m41));
result.m42 = ((matrix1.m41 * matrix2.m12) + (matrix1.m42 * matrix2.m22) +
(matrix1.m43 * matrix2.m32) + (matrix1.m44 * matrix2.m42));
result.m43 = ((matrix1.m41 * matrix2.m13) + (matrix1.m42 * matrix2.m23) +
(matrix1.m43 * matrix2.m33) + (matrix1.m44 * matrix2.m43));
result.m44 = ((matrix1.m41 * matrix2.m14) + (matrix1.m42 * matrix2.m24) +
(matrix1.m43 * matrix2.m34) + (matrix1.m44 * matrix2.m44));
return result;
}
Matrix4x4 Matrix4x4_TransposeToColumnMajor(Matrix4x4 rowMajorMat) {
Matrix4x4 newMatrix = rowMajorMat;
newMatrix.m12 = rowMajorMat.m21;
newMatrix.m13 = rowMajorMat.m31;
newMatrix.m14 = rowMajorMat.m41;
newMatrix.m21 = rowMajorMat.m12;
newMatrix.m23 = rowMajorMat.m32;
newMatrix.m24 = rowMajorMat.m42;
newMatrix.m31 = rowMajorMat.m13;
newMatrix.m32 = rowMajorMat.m23;
newMatrix.m34 = rowMajorMat.m43;
newMatrix.m41 = rowMajorMat.m14;
newMatrix.m42 = rowMajorMat.m24;
newMatrix.m43 = rowMajorMat.m34;
return newMatrix;
}
Matrix4x4 Matrix4x4_CreateRotationZ(float radians) {
return Matrix4x4_TransposeToColumnMajor((Matrix4x4){
SDL_cosf(radians), SDL_sinf(radians), 0, 0, -SDL_sinf(radians),
SDL_cosf(radians), 0, 0, 0, 0, 1, 0, 0, 0, 0, 1});
}
Matrix4x4 Matrix4x4_CreateTranslation(float x, float y, float z) {
return Matrix4x4_TransposeToColumnMajor(
(Matrix4x4){1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, x, y, z, 1});
}
Matrix4x4 Matrix4x4_CreateOrthographicOffCenter(float left, float right,
float bottom, float top,
float zNearPlane,
float zFarPlane) {
return Matrix4x4_TransposeToColumnMajor((Matrix4x4){
2.0f / (right - left), 0, 0, 0, 0, 2.0f / (top - bottom), 0, 0, 0, 0,
1.0f / (zNearPlane - zFarPlane), 0, (left + right) / (left - right),
(top + bottom) / (bottom - top), zNearPlane / (zNearPlane - zFarPlane),
1});
}
Matrix4x4 Matrix4x4_CreatePerspectiveFieldOfView(float fieldOfView,
float aspectRatio,
float nearPlaneDistance,
float farPlaneDistance) {
float num = 1.0f / (SDL_tanf(fieldOfView * 0.5f));
return Matrix4x4_TransposeToColumnMajor((Matrix4x4){
num / aspectRatio, 0, 0, 0, 0, num, 0, 0, 0, 0,
farPlaneDistance / (nearPlaneDistance - farPlaneDistance), -1, 0, 0,
(nearPlaneDistance * farPlaneDistance) /
(nearPlaneDistance - farPlaneDistance),
0});
}
Matrix4x4 Matrix4x4_CreateLookAt(Vector3 cameraPosition, Vector3 cameraTarget,
Vector3 cameraUpVector) {
Vector3 targetToPosition = {
cameraPosition.x - cameraTarget.x,
cameraPosition.y - cameraTarget.y,
cameraPosition.z - cameraTarget.z
};
Vector3 vectorA = Vector3_Normalize(targetToPosition);
Vector3 vectorB = Vector3_Normalize(Vector3_Cross(cameraUpVector, vectorA));
Vector3 vectorC = Vector3_Cross(vectorA, vectorB);
return Matrix4x4_TransposeToColumnMajor((Matrix4x4) {
vectorB.x, vectorC.x, vectorA.x, 0,
vectorB.y, vectorC.y, vectorA.y, 0,
vectorB.z, vectorC.z, vectorA.z, 0,
-Vector3_Dot(vectorB, cameraPosition), -Vector3_Dot(vectorC, cameraPosition), -Vector3_Dot(vectorA, cameraPosition), 1
});
}
Matrix4x4 Matrix4x4_Inverse(Matrix4x4 mat) {
float inv[16];
const float a[16] = {mat.m11, mat.m21, mat.m31, mat.m41, mat.m12, mat.m22,
mat.m32, mat.m42, mat.m13, mat.m23, mat.m33, mat.m43,
mat.m14, mat.m24, mat.m34, mat.m44};
inv[0] = a[5] * a[10] * a[15] - a[5] * a[11] * a[14] - a[9] * a[6] * a[15] +
a[9] * a[7] * a[14] + a[13] * a[6] * a[11] - a[13] * a[7] * a[10];
inv[4] = -a[4] * a[10] * a[15] + a[4] * a[11] * a[14] + a[8] * a[6] * a[15] -
a[8] * a[7] * a[14] - a[12] * a[6] * a[11] + a[12] * a[7] * a[10];
inv[8] = a[4] * a[9] * a[15] - a[4] * a[11] * a[13] - a[8] * a[5] * a[15] +
a[8] * a[7] * a[13] + a[12] * a[5] * a[11] - a[12] * a[7] * a[9];
inv[12] = -a[4] * a[9] * a[14] + a[4] * a[10] * a[13] + a[8] * a[5] * a[14] -
a[8] * a[6] * a[13] - a[12] * a[5] * a[10] + a[12] * a[6] * a[9];
inv[1] = -a[1] * a[10] * a[15] + a[1] * a[11] * a[14] + a[9] * a[2] * a[15] -
a[9] * a[3] * a[14] - a[13] * a[2] * a[11] + a[13] * a[3] * a[10];
inv[5] = a[0] * a[10] * a[15] - a[0] * a[11] * a[14] - a[8] * a[2] * a[15] +
a[8] * a[3] * a[14] + a[12] * a[2] * a[11] - a[12] * a[3] * a[10];
inv[9] = -a[0] * a[9] * a[15] + a[0] * a[11] * a[13] + a[8] * a[1] * a[15] -
a[8] * a[3] * a[13] - a[12] * a[1] * a[11] + a[12] * a[3] * a[9];
inv[13] = a[0] * a[9] * a[14] - a[0] * a[10] * a[13] - a[8] * a[1] * a[14] +
a[8] * a[2] * a[13] + a[12] * a[1] * a[10] - a[12] * a[2] * a[9];
inv[2] = a[1] * a[6] * a[15] - a[1] * a[7] * a[14] - a[5] * a[2] * a[15] +
a[5] * a[3] * a[14] + a[13] * a[2] * a[7] - a[13] * a[3] * a[6];
inv[6] = -a[0] * a[6] * a[15] + a[0] * a[7] * a[14] + a[4] * a[2] * a[15] -
a[4] * a[3] * a[14] - a[12] * a[2] * a[7] + a[12] * a[3] * a[6];
inv[10] = a[0] * a[5] * a[15] - a[0] * a[7] * a[13] - a[4] * a[1] * a[15] +
a[4] * a[3] * a[13] + a[12] * a[1] * a[7] - a[12] * a[3] * a[5];
inv[14] = -a[0] * a[5] * a[14] + a[0] * a[6] * a[13] + a[4] * a[1] * a[14] -
a[4] * a[2] * a[13] - a[12] * a[1] * a[6] + a[12] * a[2] * a[5];
inv[3] = -a[1] * a[6] * a[11] + a[1] * a[7] * a[10] + a[5] * a[2] * a[11] -
a[5] * a[3] * a[10] - a[9] * a[2] * a[7] + a[9] * a[3] * a[6];
inv[7] = a[0] * a[6] * a[11] - a[0] * a[7] * a[10] - a[4] * a[2] * a[11] +
a[4] * a[3] * a[10] + a[8] * a[2] * a[7] - a[8] * a[3] * a[6];
inv[11] = -a[0] * a[5] * a[11] + a[0] * a[7] * a[9] + a[4] * a[1] * a[11] -
a[4] * a[3] * a[9] - a[8] * a[1] * a[7] + a[8] * a[3] * a[5];
inv[15] = a[0] * a[5] * a[10] - a[0] * a[6] * a[9] - a[4] * a[1] * a[10] +
a[4] * a[2] * a[9] + a[8] * a[1] * a[6] - a[8] * a[2] * a[5];
float det = a[0] * inv[0] + a[1] * inv[4] + a[2] * inv[8] + a[3] * inv[12];
det = 1.0f / det;
return (Matrix4x4){
.m11 = inv[0] * det,
.m12 = inv[1] * det,
.m13 = inv[2] * det,
.m14 = inv[3] * det,
.m21 = inv[4] * det,
.m22 = inv[5] * det,
.m23 = inv[6] * det,
.m24 = inv[7] * det,
.m31 = inv[8] * det,
.m32 = inv[9] * det,
.m33 = inv[10] * det,
.m34 = inv[11] * det,
.m41 = inv[12] * det,
.m42 = inv[13] * det,
.m43 = inv[14] * det,
.m44 = inv[15] * det,
};
}
Vector3 Vector3_Normalize(Vector3 vec) {
float magnitude =
SDL_sqrtf((vec.x * vec.x) + (vec.y * vec.y) + (vec.z * vec.z));
return (Vector3){vec.x / magnitude, vec.y / magnitude, vec.z / magnitude};
}
float Vector3_Dot(Vector3 vecA, Vector3 vecB) {
return (vecA.x * vecB.x) + (vecA.y * vecB.y) + (vecA.z * vecB.z);
}
Vector3 Vector3_Cross(Vector3 vecA, Vector3 vecB) {
return (Vector3){vecA.y * vecB.z - vecB.y * vecA.z,
-(vecA.x * vecB.z - vecB.x * vecA.z),
vecA.x * vecB.y - vecB.x * vecA.y};
}
+37
View File
@@ -0,0 +1,37 @@
// I stole this math library from TheSpydog's SDLGPU examples:
// https://github.com/TheSpydog/SDL_gpu_examples/blob/main/Examples/Common.c
// Sorry!
// TODO: Get more of the gpu_examples stuff into mainline SDL
#include <SDL3/SDL_stdinc.h>
// Matrix Math
typedef struct Matrix4x4 {
float m11, m12, m13, m14;
float m21, m22, m23, m24;
float m31, m32, m33, m34;
float m41, m42, m43, m44;
} Matrix4x4;
typedef struct Vector3 {
float x, y, z;
} Vector3;
Matrix4x4 Matrix4x4_Multiply(Matrix4x4 matrix1, Matrix4x4 matrix2);
Matrix4x4 Matrix4x4_CreateRotationZ(float radians);
Matrix4x4 Matrix4x4_CreateTranslation(float x, float y, float z);
Matrix4x4 Matrix4x4_CreateOrthographicOffCenter(float left, float right,
float bottom, float top,
float zNearPlane,
float zFarPlane);
Matrix4x4 Matrix4x4_CreatePerspectiveFieldOfView(float fieldOfView,
float aspectRatio,
float nearPlaneDistance,
float farPlaneDistance);
Matrix4x4 Matrix4x4_CreateLookAt(Vector3 cameraPosition, Vector3 cameraTarget,
Vector3 cameraUpVector);
Matrix4x4 Matrix4x4_Inverse(Matrix4x4 mat);
Vector3 Vector3_Normalize(Vector3 vec);
float Vector3_Dot(Vector3 vecA, Vector3 vecB);
Vector3 Vector3_Cross(Vector3 vecA, Vector3 vecB);
Binary file not shown.

After

Width:  |  Height:  |  Size: 139 KiB

+572
View File
@@ -0,0 +1,572 @@
#include <SDL3/SDL.h>
#define SDL_MAIN_USE_CALLBACKS
#include <SDL3/SDL_main.h>
#include "math.h"
#include "shaders.h"
typedef struct Asteroid
{
Vector3 pos;
float padding1;
Vector3 vel;
float padding2;
} Asteroid;
typedef struct UniformDataCompute
{
float timescale;
float numAsteroids;
float deltaTime;
} UniformDataCompute;
typedef struct Vertex
{
float x, y, z;
} Vertex;
typedef struct AppState
{
bool shouldRecreateAsteroids;
bool leftClickDown;
Uint32 numAsteroids;
Uint32 minDistance;
Uint32 maxDistance;
Uint32 cameraDistance; // KM
float cameraRotation;
float cameraRotationVelocity;
float deltaTime;
float timescale;
int timescaleIndex;
Uint64 timeLastIter;
SDL_Window *window;
SDL_GPUDevice *device;
SDL_GPUShader *vs, *fs;
SDL_GPUGraphicsPipeline *graphicsPipeline;
SDL_GPUComputePipeline *computePipeline;
SDL_GPUBuffer *vtxBuffer, *idxBuffer;
SDL_GPUBuffer *asteroidBuf;
} AppState;
static AppState app = { 0 };
#define ASTEROID_SIZE 15000.0f
#define MAX_ASTEROIDS 4000000.0f
#define EARTH_RADIUS 6371000.0f
#define RESOLUTION_X 800.0f
#define RESOLUTION_Y 600.0f
// By pressing left or right arrow on your keyboard you can decrease/increase the time scale (how fast time goes)
const float timescales[6] = { 1.0f, 10.0f, 100.0f, 1000.0f, 2500.0f, 5000.0f };
void InitPipelines(void)
{
app.vs =
SDL_CreateGPUShader(app.device, &(SDL_GPUShaderCreateInfo){
.code = (const Uint8 *)vtxShader,
.code_size = SDL_strlen(vtxShader),
.entrypoint = "main",
.format = SDL_GPU_SHADERFORMAT_WGSL,
.num_samplers = 0,
.num_storage_buffers = 0,
.num_storage_textures = 0,
.num_uniform_buffers = 1,
.stage = SDL_GPU_SHADERSTAGE_VERTEX,
});
app.fs =
SDL_CreateGPUShader(app.device, &(SDL_GPUShaderCreateInfo){
.code = (const Uint8 *)frgShader,
.code_size = SDL_strlen(frgShader),
.entrypoint = "main",
.format = SDL_GPU_SHADERFORMAT_WGSL,
.num_samplers = 0,
.num_storage_buffers = 0,
.num_storage_textures = 0,
.num_uniform_buffers = 0,
.stage = SDL_GPU_SHADERSTAGE_FRAGMENT,
});
app.graphicsPipeline = SDL_CreateGPUGraphicsPipeline(
app.device,
&(SDL_GPUGraphicsPipelineCreateInfo){
.target_info = {
.num_color_targets = 1,
.color_target_descriptions =
(SDL_GPUColorTargetDescription[]){
{
.format = SDL_GetGPUSwapchainTextureFormat(
app.device, app.window),
},
}, // Note: I couldn't be bothered to do depth testing. Sorry!
},
.vertex_input_state = (SDL_GPUVertexInputState){
.num_vertex_buffers = 1,
.vertex_buffer_descriptions = (SDL_GPUVertexBufferDescription[]){
{
.slot = 0,
.input_rate = SDL_GPU_VERTEXINPUTRATE_VERTEX,
.instance_step_rate = 0,
.pitch = sizeof(Vertex),
},
},
.num_vertex_attributes = 1,
.vertex_attributes = (SDL_GPUVertexAttribute[]){
{
.buffer_slot = 0,
.format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT3,
.location = 0,
.offset = 0,
},
},
},
.rasterizer_state = {
// We'll enable backface culling here.
// I'm not nearly good enough of a graphics programmer
// to explain what backface culling in a simple manner,
// but TLDR it's pretty much a free performance boost.
.cull_mode = SDL_GPU_CULLMODE_BACK,
.front_face = SDL_GPU_FRONTFACE_COUNTER_CLOCKWISE,
},
.primitive_type = SDL_GPU_PRIMITIVETYPE_TRIANGLELIST,
.vertex_shader = app.vs,
.fragment_shader = app.fs,
});
app.computePipeline = SDL_CreateGPUComputePipeline(app.device, &(SDL_GPUComputePipelineCreateInfo){
.code = (const Uint8 *)cmpShader,
.code_size = SDL_strlen(cmpShader),
.entrypoint = "main",
.format = SDL_GPU_SHADERFORMAT_WGSL,
.num_samplers = 0,
.num_readonly_storage_buffers = 0,
.num_readonly_storage_textures = 0,
.num_readwrite_storage_buffers = 1,
.num_readwrite_storage_textures = 0,
.num_uniform_buffers = 1,
.threadcount_x = 64,
.threadcount_y = 1,
.threadcount_z = 1,
});
}
void CreateAsteroids(SDL_GPUCopyPass *copyPass)
{
Uint32 i;
if (app.asteroidBuf != NULL) {
// If we're recreating the asteroids, we'll have to release the previous asteroid buffer
// since otherwise we'd waste a TON of GPU memory and eventually crash.
SDL_ReleaseGPUBuffer(app.device, app.asteroidBuf);
}
// We'll create a storage buffer which'll store each asteroid's position and velocity.
// This will be written to in the compute shader, and then read from in the vertex shader.
app.asteroidBuf = SDL_CreateGPUBuffer(app.device, &(SDL_GPUBufferCreateInfo){
.size = sizeof(Asteroid) * app.numAsteroids,
.usage = SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_READ |
SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_WRITE |
SDL_GPU_BUFFERUSAGE_GRAPHICS_STORAGE_READ,
});
SDL_GPUTransferBuffer *asteroidTransferBuffer = SDL_CreateGPUTransferBuffer(app.device, &(SDL_GPUTransferBufferCreateInfo){
.size = sizeof(Asteroid) * app.numAsteroids,
.usage = SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD,
});
Asteroid *asteroidData = SDL_MapGPUTransferBuffer(app.device, asteroidTransferBuffer, false);
// This loop will create all the asteroids and randomly spread them out in Earth's orbit.
for (i = 0; i < app.numAsteroids; i++) {
Uint32 distance = SDL_max(SDL_rand(app.maxDistance), (Sint32)app.minDistance);
float theta = (2.0f * SDL_PI_F * i) / app.numAsteroids;
float finalDist = EARTH_RADIUS + distance;
asteroidData[i].pos.x = finalDist * SDL_sinf(theta);
asteroidData[i].pos.z = finalDist * SDL_cosf(theta);
asteroidData[i].vel.x = (7700 * SDL_cosf(theta)) * (1 + SDL_randf() / 5);
asteroidData[i].vel.z = (7700 * -SDL_sinf(theta)) * (1 + SDL_randf() / 5);
// We give some initial random velocity to the Y axis to spread the asteroids out a little.
asteroidData[i].vel.y = 1500 * SDL_randf();
}
SDL_UnmapGPUTransferBuffer(app.device, asteroidTransferBuffer);
// We'll upload the transfer buffer's data to the storage buffer with this SDL_UploadToGPUBuffer call.
SDL_UploadToGPUBuffer(
copyPass,
&(SDL_GPUTransferBufferLocation){
.transfer_buffer = asteroidTransferBuffer,
.offset = 0,
},
&(SDL_GPUBufferRegion){
.buffer = app.asteroidBuf,
.offset = 0,
.size = sizeof(Asteroid) * app.numAsteroids,
},
false);
// We don't need this transfer buffer any more, so we'll release it to free up GPU memory.
SDL_ReleaseGPUTransferBuffer(app.device, asteroidTransferBuffer);
}
void InitBuffers(void)
{
// We'll create our vertex & index buffers here.
// Since we're using instancing, we only need one cube mesh for all asteroids.
app.vtxBuffer =
SDL_CreateGPUBuffer(app.device, &(SDL_GPUBufferCreateInfo){
.size = sizeof(Vertex) * 24,
.usage = SDL_GPU_BUFFERUSAGE_VERTEX,
});
app.idxBuffer =
SDL_CreateGPUBuffer(app.device, &(SDL_GPUBufferCreateInfo){
.size = sizeof(Uint16) * 36,
.usage = SDL_GPU_BUFFERUSAGE_INDEX,
});
// We'll have to create a transfer buffer to upload our mesh data.
// We'll be smart here and use the same buffer for both uploads, so we'll make it large enough to fit both the vertex & index data.
SDL_GPUTransferBuffer *meshTransferBuffer = SDL_CreateGPUTransferBuffer(app.device, &(SDL_GPUTransferBufferCreateInfo){
.size = (sizeof(Uint16) * 36) + (sizeof(Vertex) * 24),
.usage = SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD,
});
// We'll map the transfer buffer so we can upload our cube mesh to the GPU.
Vertex *transferData = SDL_MapGPUTransferBuffer(app.device, meshTransferBuffer, false);
Uint16 *indexData = (Uint16 *)&transferData[24];
// This is just a cube's raw data.
transferData[0] = (Vertex){ -ASTEROID_SIZE, -ASTEROID_SIZE, -ASTEROID_SIZE };
transferData[1] = (Vertex){ ASTEROID_SIZE, -ASTEROID_SIZE, -ASTEROID_SIZE };
transferData[2] = (Vertex){ ASTEROID_SIZE, ASTEROID_SIZE, -ASTEROID_SIZE };
transferData[3] = (Vertex){ -ASTEROID_SIZE, ASTEROID_SIZE, -ASTEROID_SIZE };
transferData[4] = (Vertex){ -ASTEROID_SIZE, -ASTEROID_SIZE, ASTEROID_SIZE };
transferData[5] = (Vertex){ ASTEROID_SIZE, -ASTEROID_SIZE, ASTEROID_SIZE };
transferData[6] = (Vertex){ ASTEROID_SIZE, ASTEROID_SIZE, ASTEROID_SIZE };
transferData[7] = (Vertex){ -ASTEROID_SIZE, ASTEROID_SIZE, ASTEROID_SIZE };
transferData[8] = (Vertex){ -ASTEROID_SIZE, -ASTEROID_SIZE, -ASTEROID_SIZE };
transferData[9] = (Vertex){ -ASTEROID_SIZE, ASTEROID_SIZE, -ASTEROID_SIZE };
transferData[10] = (Vertex){ -ASTEROID_SIZE, ASTEROID_SIZE, ASTEROID_SIZE };
transferData[11] = (Vertex){ -ASTEROID_SIZE, -ASTEROID_SIZE, ASTEROID_SIZE };
transferData[12] = (Vertex){ ASTEROID_SIZE, -ASTEROID_SIZE, -ASTEROID_SIZE };
transferData[13] = (Vertex){ ASTEROID_SIZE, ASTEROID_SIZE, -ASTEROID_SIZE };
transferData[14] = (Vertex){ ASTEROID_SIZE, ASTEROID_SIZE, ASTEROID_SIZE };
transferData[15] = (Vertex){ ASTEROID_SIZE, -ASTEROID_SIZE, ASTEROID_SIZE };
transferData[16] = (Vertex){ -ASTEROID_SIZE, -ASTEROID_SIZE, -ASTEROID_SIZE };
transferData[17] = (Vertex){ -ASTEROID_SIZE, -ASTEROID_SIZE, ASTEROID_SIZE };
transferData[18] = (Vertex){ ASTEROID_SIZE, -ASTEROID_SIZE, ASTEROID_SIZE };
transferData[19] = (Vertex){ ASTEROID_SIZE, -ASTEROID_SIZE, -ASTEROID_SIZE };
transferData[20] = (Vertex){ -ASTEROID_SIZE, ASTEROID_SIZE, -ASTEROID_SIZE };
transferData[21] = (Vertex){ -ASTEROID_SIZE, ASTEROID_SIZE, ASTEROID_SIZE };
transferData[22] = (Vertex){ ASTEROID_SIZE, ASTEROID_SIZE, ASTEROID_SIZE };
transferData[23] = (Vertex){ ASTEROID_SIZE, ASTEROID_SIZE, -ASTEROID_SIZE };
Uint16 indices[] = { 0, 1, 2, 0, 2, 3, 6, 5, 4, 7, 6, 4,
8, 9, 10, 8, 10, 11, 14, 13, 12, 15, 14, 12,
16, 17, 18, 16, 18, 19, 22, 21, 20, 23, 22, 20 };
SDL_memcpy(indexData, indices, sizeof(indices));
// Now that we're done copying the cube mesh data to the transfer buffer,
// we'll unmap the transfer buffer so we can upload to the vertex & index buffers from it.
SDL_UnmapGPUTransferBuffer(app.device, meshTransferBuffer);
// We'll acquire a command buffer and begin a copy pass.
// In order to upload anything to the GPU in SDLGPU, you must first begin a "copy pass".
// Within this copy pass, you can... copy data. Once you're finished with the copy pass,
// you call SDL_EndGPUCopyPass and then continue on with whatever else you need to do.
SDL_GPUCommandBuffer *cmdBuf = SDL_AcquireGPUCommandBuffer(app.device);
SDL_GPUCopyPass *copyPass = SDL_BeginGPUCopyPass(cmdBuf);
// While we're here, we'll also upload our initial asteroid data.
CreateAsteroids(copyPass);
SDL_UploadToGPUBuffer(copyPass,
&(SDL_GPUTransferBufferLocation){
.transfer_buffer = meshTransferBuffer,
.offset = 0,
},
&(SDL_GPUBufferRegion){
.buffer = app.vtxBuffer,
.offset = 0,
.size = sizeof(Vertex) * 24,
},
false);
SDL_UploadToGPUBuffer(
copyPass,
&(SDL_GPUTransferBufferLocation){
.transfer_buffer = meshTransferBuffer,
// Remember that we're using the same transfer buffer here,
// so we'll add the vertex data size to the offset.
.offset = sizeof(Vertex) * 24,
},
&(SDL_GPUBufferRegion){
.buffer = app.idxBuffer,
.offset = 0,
.size = sizeof(Uint16) * 36,
},
false);
SDL_EndGPUCopyPass(copyPass);
SDL_SubmitGPUCommandBuffer(cmdBuf);
SDL_ReleaseGPUTransferBuffer(app.device, meshTransferBuffer);
}
// We're using the SDL callbacks here, since they generally play nicer with Emscripten.
// You can also run a traditional main loop if you want to, but you'll have to do a bit of screwing around to get it working with Emscripten.
SDL_AppResult SDL_AppInit(void **appstate, int argc, char **argv)
{
if (!SDL_Init(SDL_INIT_VIDEO)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init failed (%s)", SDL_GetError());
return SDL_APP_FAILURE;
}
app.window =
SDL_CreateWindow("Orbit Simulation", (int)RESOLUTION_X, (int)RESOLUTION_Y, 0);
if (app.window == NULL) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_CreateWindow failed (%s)", SDL_GetError());
return SDL_APP_FAILURE;
}
// We'll create the SDL_GPUDevice here. This device will be used to interface with the GPU.
// This function takes in three arguments: The shader format(s) you support, whether or not debug mode is enabled, and additional properties.
//
// The shader format(s) argument allows you to say "Hey, I can give shaders in these formats!".
// This lets you support Vulkan, DX12, Metal, and WebGPU while still using the same SDLGPU code.
//
// However, in this example we are only supporting WGSL, which is WebGPU's shading language.
// (Quite frankly, I just didn't wanna rewrite the shader code in HLSL.)
app.device = SDL_CreateGPUDevice(SDL_GPU_SHADERFORMAT_WGSL, true, NULL);
if (app.device == NULL) {
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "This example only supports SDL_GPU through webgpu");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_CreateGPUDevice failed (%s)", SDL_GetError());
return SDL_APP_FAILURE;
}
app.numAsteroids = 100000;
app.minDistance = 75000;
app.maxDistance = 78000;
app.cameraDistance = 10000; // cameraDistance is in kilometers
app.timescale = timescales[3];
app.timescaleIndex = 3;
// In order to render an image to the SDL window with SDLGPU, you must call SDL_ClaimWindowForGPUDevice.
// This creates the "swapchain", allowing you to later call SDL_(WaitAnd)AcquireGPUSwapchainTexture.
SDL_ClaimWindowForGPUDevice(app.device, app.window);
InitPipelines();
InitBuffers();
// We have to set this here, since this is part of the delta time calculations and dividing by 0 is not good.
app.timeLastIter = SDL_GetTicksNS();
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Press left or right to change timescale.");
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Press up or down to increase/decrease asteroid count.");
// We'll return SDL_APP_CONTINUE, which tells SDL that the app initialization succeeded, and that the app should continue running.
return SDL_APP_CONTINUE;
}
// This function runs once per frame, and therefore we'll put our GPU rendering code here.
SDL_AppResult SDL_AppIterate(void *appstate)
{
Uint64 timeLastIter = app.timeLastIter;
app.timeLastIter = SDL_GetTicksNS();
app.deltaTime = (app.timeLastIter - timeLastIter) / (float)1e9;
// This code changes the camera rotation by cameraRotationVelocity. It then also divides the velocity by 1.15f to apply some drag.
app.cameraRotation += app.cameraRotationVelocity;
app.cameraRotationVelocity /= 1.15f;
// We'll acquire a command buffer here.
// In order to run anything on the GPU, you must first acquire a GPU command buffer.
// After you've acquired the buffer, you proceed to fill it with GPU commands. (e.g: draw this, upload that, clear this, etc...)
// Once you've filled the command buffer with all your GPU commands, you "submit" it.
// This sends the commands to the GPU where they'll be run.
SDL_GPUCommandBuffer *cmdBuf = SDL_AcquireGPUCommandBuffer(app.device);
// If the asteroid count's changed we'll have to upload the new asteroids.
if (app.shouldRecreateAsteroids) {
// Important note with the WebGPU backend: There's an edge case in WebGPU which makes it so that any swapchain texture you've
// previously acquired will instantly be destroyed if you map a transfer buffer. I have no idea why it does that, but it does.
// Keep that in mind!
SDL_GPUCopyPass *copyPass = SDL_BeginGPUCopyPass(cmdBuf);
CreateAsteroids(copyPass);
SDL_EndGPUCopyPass(copyPass);
app.shouldRecreateAsteroids = false;
}
// This code starts a "compute pass". A compute pass is a pass in which you execute compute shaders.
// This is unlike a copy pass, which copies data, and a render pass, which renders triangles.
//
// A compute shader is a special kind of shader which allows you to run non-graphics related code on a GPU.
// This example makes use of compute shaders to simulate each asteroid's orbit direcly on the GPU, without any input from the CPU.
// This not only simplifies the code, but this also runs much better than if we were to run the simulation on the CPU.
// Using this compute shader, I can simulate 4 million asteroids in less than a millisecond on my 6700XT, without ever uploading any data from the CPU.
//
// (Note that we're binding the asteroid buffer here, since SDLGPU requires R/W compute storage buffers to be bound in SDL_BeginGPUComputePass.)
SDL_GPUComputePass *computePass = SDL_BeginGPUComputePass(cmdBuf, NULL, 0, &(SDL_GPUStorageBufferReadWriteBinding){ .buffer = app.asteroidBuf, .cycle = false }, 1);
// We'll bind our compute pipeline here.
SDL_BindGPUComputePipeline(computePass, app.computePipeline);
// We'll push our uniform data here. This doesn't include all that much, just the deltaTime, amount of asteroids, and the timescale.
SDL_PushGPUComputeUniformData(cmdBuf, 0, &(UniformDataCompute){
.deltaTime = app.deltaTime,
.numAsteroids = (float)app.numAsteroids,
.timescale = app.timescale,
},
sizeof(UniformDataCompute));
// Finally, we'll dispatch our compute. This tells the GPU "hey, run this compute code please".
// Since we've previously set our X thread size to 64, we'll have to divide the asteroid count by 64 to get our thread dispatch size.
SDL_DispatchGPUCompute(computePass, app.numAsteroids / 64, 1, 1);
// Compute is finished, let's move on to the rendering!
SDL_EndGPUComputePass(computePass);
SDL_GPUTexture *swapchainTexture = NULL;
// As written about in the asteroid upload code above, WebGPU has a weird edge case where mapping a buffer will destroy any currently acquired swapchain textures.
// So, the swapchain acquisition is done as late as possible here, to prevent shenanigans.
SDL_WaitAndAcquireGPUSwapchainTexture(cmdBuf, app.window, &swapchainTexture, NULL, NULL); // We don't care about the texture's size since we already know it
// If the swapchain texture's NULL, we won't bother doing anything.
// A NULL swapchain texture means that we can't render to the swapchain right now, for some reason.
// This is normal behaviour (for example: if the window's not visible this'll be NULL), so we'll just skip over the rendering code if that's the case.
if (swapchainTexture != NULL) {
// This is some basic matrix math that creates perspective and also allows us to move the camera around.
Matrix4x4 proj = Matrix4x4_CreatePerspectiveFieldOfView(75.0f * SDL_PI_F / 180.0f, RESOLUTION_X / RESOLUTION_Y, 0.001f, 200.0f);
Matrix4x4 view = Matrix4x4_CreateLookAt(
(Vector3){
((float)app.cameraDistance * 1000) * SDL_sinf(app.cameraRotation),
((float)app.cameraDistance * 1000),
((float)app.cameraDistance * 1000) * SDL_cosf(app.cameraRotation),
},
(Vector3){ 0, 0, 0 },
(Vector3){ 0, 1, 0 });
Matrix4x4 viewproj = Matrix4x4_Multiply(proj, view);
// In order to start a render pass in SDLGPU you have to provide your color targets.
// In this example there's only one color target (the swapchain), so that's all we care about.
SDL_GPUColorTargetInfo colorTargetInfo = { 0 };
colorTargetInfo.texture = swapchainTexture;
colorTargetInfo.clear_color = (SDL_FColor){ 0.0f, 0.0f, 0.0f, 1.0f };
colorTargetInfo.load_op = SDL_GPU_LOADOP_CLEAR; // We'll tell the GPU to clear the color target to pure black here.
colorTargetInfo.store_op = SDL_GPU_STOREOP_STORE; // We'll want to keep the finished image so that we can display it to the user.
// Finally, we'll begin our render pass.
SDL_GPURenderPass *renderPass =
SDL_BeginGPURenderPass(cmdBuf, &colorTargetInfo, 1, NULL);
// We'll first bind our pipeline, vertex & index buffers.
SDL_BindGPUGraphicsPipeline(renderPass, app.graphicsPipeline);
SDL_BindGPUVertexBuffers(renderPass, 0, &(SDL_GPUBufferBinding){ .buffer = app.vtxBuffer, .offset = 0 }, 1);
SDL_BindGPUIndexBuffer(renderPass, &(SDL_GPUBufferBinding){ .buffer = app.idxBuffer, .offset = 0 }, SDL_GPU_INDEXELEMENTSIZE_16BIT);
// We'll bind our asteroid storage buffer here (which was previously updated by the compute pass) so that the vertex shader can access the asteroid position.
SDL_BindGPUVertexStorageBuffers(renderPass, 0, &app.asteroidBuf, 1);
// We'll push our combined view + projection matrix to the GPU here.
SDL_PushGPUVertexUniformData(cmdBuf, 0, &viewproj, sizeof(Matrix4x4));
// Time to draw all of the asteroids. I wasn't very fancy with it, so the "asteroids" are in reality just cubes.
// This example is mostly a showcase of WebGPU's compute abilities.
// You can see here that we pass in app.numAsteroids here as our instance count.
// This tells the GPU "hey, you'll be rendering the exact same thing a billion times, no need for multiple draw calls."
// This greatly speeds up rendering since there's only one draw call for the GPU.
SDL_DrawGPUIndexedPrimitives(renderPass, 36, app.numAsteroids, 0, 0, 0);
// We're done with our render pass, so we'll end it here.
SDL_EndGPURenderPass(renderPass);
}
// Finally, it's time to submit our command buffer.
// SDLGPU handles all of the swapchain stuff for you, so we don't need to bother with presentation and such.
SDL_SubmitGPUCommandBuffer(cmdBuf);
return SDL_APP_CONTINUE;
}
// This callback gets run whenever an event occurs (e.g keyboard input)
SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event)
{
if (event->type == SDL_EVENT_QUIT) {
// If the "quit" event's happened we'll return SDL_APP_SUCCESS, which tells SDL that we're done with our app.
return SDL_APP_SUCCESS;
}
if (event->type == SDL_EVENT_KEY_DOWN) {
if (event->key.scancode == SDL_SCANCODE_LEFT) {
if (app.timescaleIndex > 0) {
app.timescaleIndex -= 1;
app.timescale = timescales[app.timescaleIndex];
}
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Timescale: %.3f", app.timescale);
} else if (event->key.scancode == SDL_SCANCODE_RIGHT) {
if (app.timescaleIndex < 5) {
app.timescaleIndex += 1;
app.timescale = timescales[app.timescaleIndex];
}
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Timescale: %.3f", app.timescale);
} else if (event->key.scancode == SDL_SCANCODE_UP && (app.numAsteroids + 100000) <= MAX_ASTEROIDS) {
app.numAsteroids += 100000;
app.shouldRecreateAsteroids = true;
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Asteroid count: %i", (int)app.numAsteroids);
} else if (event->key.scancode == SDL_SCANCODE_DOWN && ((int)app.numAsteroids - 100000) >= 10000) {
app.numAsteroids -= 100000;
app.shouldRecreateAsteroids = true;
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Asteroid count: %i", (int)app.numAsteroids);
}
}
if (event->type == SDL_EVENT_MOUSE_WHEEL) {
app.cameraDistance -= event->wheel.integer_y * 500;
}
// If left click is pressed down on the mouse, we'll hide it and allow the user to rotate the camera view.
if (event->type == SDL_EVENT_MOUSE_BUTTON_DOWN || event->type == SDL_EVENT_MOUSE_BUTTON_UP) {
if (event->button.button == 1) {
app.leftClickDown = event->button.down;
SDL_SetWindowRelativeMouseMode(app.window, app.leftClickDown);
}
}
if (event->type == SDL_EVENT_MOUSE_MOTION) {
if (app.leftClickDown) {
app.cameraRotationVelocity += event->motion.xrel / 2000.0f;
}
}
return SDL_APP_CONTINUE;
}
// This callback is called when the app is shutting down.
// We'll free our GPU resources here.
void SDL_AppQuit(void *appstate, SDL_AppResult result)
{
SDL_ReleaseGPUBuffer(app.device, app.vtxBuffer);
SDL_ReleaseGPUBuffer(app.device, app.idxBuffer);
SDL_ReleaseGPUBuffer(app.device, app.asteroidBuf);
SDL_ReleaseGPUGraphicsPipeline(app.device, app.graphicsPipeline);
SDL_ReleaseGPUShader(app.device, app.fs);
SDL_ReleaseGPUShader(app.device, app.vs);
SDL_ReleaseWindowFromGPUDevice(app.device, app.window);
SDL_DestroyGPUDevice(app.device);
SDL_DestroyWindow(app.window);
SDL_Quit();
}
@@ -0,0 +1,82 @@
// These shaders are all in textual WGSL.
// This is for two reasons:
// - 1: This SDL3 example is only ever meant to run on the WebGPU backend, on the SDL website.
// - 2: I didn't want to rewrite these shaders.
// They're also formatted a little grossly since Clang & MSVC don't support R"" strings.
/**
* This is the vertex shader for each asteroid.
* It reads the asteroid storage buffer (previously used in the compute shader), and displaces each asteroid by the buffer entry's "pos" field.
*/
const char *vtxShader = "\n\
struct Asteroid {\n\
pos: vec3<f32>,\n\
vel: vec3<f32>,\n\
};\n\
@group(0u) @binding(0u) var<storage, read> posBuf: array<Asteroid>;\n\
@group(1u) @binding(0u) var<uniform> camMatrix: mat4x4<f32>;\n\
\n\
@vertex\n\
fn main(@location(0u) pos: vec3<f32>, @builtin(instance_index) index: u32) -> @builtin(position) vec4<f32> {\n\
return vec4<f32>(pos + posBuf[index].pos, 1.0f) * camMatrix;\n\
}";
/**
* This is the asteroid fragment shader.
* Very simple, this just returns an almost-pure white.
*/
const char *frgShader = "\n\
@fragment\n\
fn main() -> @location(0) vec4<f32> {\n\
return vec4<f32>(0.9f, 0.9f, 0.9f, 1.0f);\n\
}";
/**
* This is the compute shader for the asteroids.
* It uses a simplified version of Newton's law of universal gravitation
* to calculate the force applied to each asteroid.
* F = GM / r²
*/
const char *cmpShader = "\n\
// This is the struct which stores each asteroid's data.\n\
struct Asteroid {\n\
pos: vec3<f32>,\n\
vel: vec3<f32>,\n\
};\n\
\n\
// This is the uniform data that's pushed to the compute shader.\n\
// You don't *have* to organize your uniform data into a struct, but that's how I like to do it.\n\
struct UniformData {\n\
timescale: f32,\n\
numAsteroids: f32,\n\
deltaTime: f32,\n\
};\n\
\n\
// G & M are merged into one since floating point numbers are a little weird at large sizes.\n\
const GM = 3.986004418e+14;\n\
\n\
@group(1u) @binding(0u) var<storage, read_write> buf: array<Asteroid>;\n\
@group(2u) @binding(0u) var<uniform> uniformData: UniformData;\n\
\n\
fn accel(pos: vec3<f32>) -> vec3<f32>{\n\
// We don't bother calculating the force exerted upon the Earth by each asteroid since it's miniscule.\n\
// This isn't meant to be a 100% accurate physics simulation, it's meant to run in your browser :P\n\
\n\
// r is the distance between the asteroid and the Earth.\n\
// Since the earth's center of mass is at (0, 0, 0), we don't have to add anything to the asteroid's position.\n\
let r2: f32 = pow(pos.x, 2) + pow(pos.y, 2) + pow(pos.z, 2);\n\
let r: f32 = sqrt(r2);\n\
\n\
// Finally we'll calculate the force exerted upon the asteroid.\n\
return pos * -(GM / (r2 * r));\n\
}\n\
\n\
@compute @workgroup_size(64, 1, 1)\n\
fn main(@builtin(global_invocation_id) id: vec3<u32>){\n\
var ast: Asteroid = buf[id.x];\n\
// We'll first calculate the updated velocity, and then the position.\n\
ast.vel += (accel(ast.pos) * (uniformData.deltaTime)) * uniformData.timescale;\n\
ast.pos += (ast.vel * uniformData.deltaTime) * uniformData.timescale;\n\
\n\
buf[id.x] = ast;\n\
}";
Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

+154 -2
View File
@@ -269,6 +269,41 @@
* - iOS/tvOS requires an A9 GPU or newer
* - iOS Simulator and tvOS Simulator are unsupported
*
* ### WebGPU
*
* SDL driver name: "webgpu"
*
* WebGPU support is complicated and rapidly updating, so there's no exact list.
* Generally speaking, if you're using a modern browser you can use WebGPU.
*
* The backend requires these WebGPU features to run:
* - `BGRA8UnormStorage`
* - `CoreFeaturesAndLimits`
* - `Depth32FloatStencil8`
* - `DepthClipControl`
* - `Float32Filterable`
* - `IndirectFirstInstance`
* - `RG11B10UfloatRenderable`
*
* The backend also optionally supports some features. These features are not required
* for the backend to run, but they are required for specific SDLGPU functionality:
* - `Float32Blendable`
* Required for blending Float32 textures. The backend will safely disable blending
* if this is unsupported.
* - `TextureCompressionASTC`
* - `TextureCompressionASTCSliced3D`
* Required for ASTC texture format support.
* - `TextureCompressionBC`
* - `TextureCompressionBCSliced3D`
* Required for BC texture format support
* - `TextureFormatsTier1`
* - `TextureFormatsTier2`
* Required for a lot of stuff, mostly related to texture sampling & access. It's
* too much to list here.
*
* Both all required and optional features will be requested automatically during
* device creation. If debug mode is enabled, any unsupported features will be logged.
*
* ## Coordinate System
*
* The GPU API uses a left-handed coordinate system, following the convention
@@ -371,6 +406,7 @@
* Debug Executable..., select your application, set "GPU Frame Capture" to
* "Metal" in scheme "Options" window, run your app, and click the small
* Metal icon on the bottom to capture a frame)
* * For WebGPU, check your browser's developer console.
*
* Aside from that, you may want to enable additional debug layers to receive
* more detailed error messages, based on your GPU backend:
@@ -383,6 +419,9 @@
* that should be installed.
* * For Metal, it should be enough just to run the application from XCode to
* receive detailed errors or warnings in the output.
* * For WebGPU, you usually don't need to do anything, as the browser will
* report detailed errors. However, some browsers may only provide error
* messages in beta / preview builds, so keep that in mind.
*
* Don't hesitate to use tools as RenderDoc when encountering runtime issues
* or unexpected output on screen, quick GPU frame inspection can usually help
@@ -906,6 +945,9 @@ typedef enum SDL_GPUTextureFormat
* within a compute pass. Note that SIMULTANEOUS usage is only supported by a
* limited number of texture formats.
*
* Note that WebGPU does not distinguish between READ | WRITE and SIMULTANEOUS
* read-write.
*
* \since This datatype is available since SDL 3.2.0.
*
* \sa SDL_CreateGPUTexture
@@ -1049,6 +1091,7 @@ typedef Uint32 SDL_GPUShaderFormat;
#define SDL_GPU_SHADERFORMAT_DXIL (1u << 3) /**< DXIL SM6_0 shaders for D3D12. */
#define SDL_GPU_SHADERFORMAT_MSL (1u << 4) /**< MSL shaders for Metal. */
#define SDL_GPU_SHADERFORMAT_METALLIB (1u << 5) /**< Precompiled metallib shaders for Metal. */
#define SDL_GPU_SHADERFORMAT_WGSL (1u << 6) /**< WGSL shaders for WebGPU. */
/**
* Specifies the format of a vertex attribute.
@@ -2259,6 +2302,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GPUSupportsProperties(
* - "vulkan": [Vulkan](CategoryGPU#vulkan)
* - "direct3d12": [D3D12](CategoryGPU#d3d12)
* - "metal": [Metal](CategoryGPU#metal)
* - "webgpu": [WebGPU](CategoryGPU#webgpu)
* - NULL: let SDL pick the optimal driver
*
* \param format_flags a bitflag indicating which shader formats the app is
@@ -2411,6 +2455,7 @@ extern SDL_DECLSPEC SDL_GPUDevice * SDLCALL SDL_CreateGPUDeviceWithProperties(
#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_DXIL_BOOLEAN "SDL.gpu.device.create.shaders.dxil"
#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_MSL_BOOLEAN "SDL.gpu.device.create.shaders.msl"
#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_METALLIB_BOOLEAN "SDL.gpu.device.create.shaders.metallib"
#define SDL_PROP_GPU_DEVICE_CREATE_SHADERS_WGSL_BOOLEAN "SDL.gpu.device.create.shaders.wgsl"
#define SDL_PROP_GPU_DEVICE_CREATE_D3D12_ALLOW_FEWER_RESOURCE_SLOTS_BOOLEAN "SDL.gpu.device.create.d3d12.allowtier1resourcebinding"
#define SDL_PROP_GPU_DEVICE_CREATE_D3D12_SEMANTIC_NAME_STRING "SDL.gpu.device.create.d3d12.semantic"
#define SDL_PROP_GPU_DEVICE_CREATE_D3D12_AGILITY_SDK_VERSION_NUMBER "SDL.gpu.device.create.d3d12.agility_sdk_version"
@@ -2490,8 +2535,8 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetNumGPUDrivers(void);
* checked during initialization.
*
* The names of drivers are all simple, low-ASCII identifiers, like "vulkan",
* "metal" or "direct3d12". These never have Unicode characters, and are not
* meant to be proper names.
* "metal", "direct3d12", or "webgpu". These never have Unicode characters,
* and are not meant to be proper names.
*
* \param index the index of a GPU driver.
* \returns the name of the GPU driver with the given **index** or NULL when
@@ -2833,6 +2878,50 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetGPUDeviceProperties(SDL_GPUD
*
* ---
*
* **WGSL (WebGPU Shading Language)**
*
* For WGSL, use the following order:
* - 0: Sampled textures, followed by read-only storage textures, followed by
* read-only storage buffers
* - 1: Read-write storage textures, followed by read-write storage buffers
* - 2: Uniform buffers
*
* Note that WebGPU does not differentiate between simultaneous read-write and non-simultaneous
* read-write. This means that any storage bind with both READ & WRITE accesses will be treated
* as if it were simultaneous. If simultaneous RW is unsupported, the backend will fall back
* to write-only.
*
* **Example**
*
* For a compute shader binding 2 of each resource type, the binds should look
* like this:
*
* ```wgsl
* // Sampled textures come first, followed by the sampler, in SDL slot order.
* \@group(0) \@binding(0) var sampledTextureBoundToSlot0: ...
* \@group(0) \@binding(1) var samplerBoundToSlot0: sampler
* \@group(0) \@binding(2) var sampledTextureBoundToSlot1: ...
* \@group(0) \@binding(3) var samplerBoundToSlot1: sampler
* // Any read-only storage textures come next, in SDL slot order.
* \@group(0) \@binding(4) var readOnlyStorageTextureBoundToSlot0: ...
* \@group(0) \@binding(5) var readOnlyStorageTextureBoundToSlot1: ...
* // Any read-only storage buffers come next, in SDL slot order.
* \@group(0) \@binding(6) var<storage, ...> readOnlyStorageBufferBoundToSlot0: ...
* \@group(0) \@binding(7) var<storage, ...> readOnlyStorageBufferBoundToSlot1: ...
* // Read-write storage textures and buffers have their own bind group.
* // Read-write storage textures go first, in SDL slot order.
* \@group(1) \@binding(0) var readWriteStorageTextureBoundToSlot0: ...
* \@group(1) \@binding(1) var readWriteStorageTextureBoundToSlot1: ...
* // Any read-write storage textures come next, in SDL slot order.
* \@group(1) \@binding(2) var<storage, ...> readWriteStorageBufferBoundToSlot0: ...
* \@group(1) \@binding(3) var<storage, ...> readWriteStorageBufferBoundToSlot1: ...
* // Any uniform buffers are in their own set, in SDL slot order.
* \@group(2) \@binding(0) var<uniform> uniformBufferBoundToSlot0: ...
* \@group(2) \@binding(1) var<uniform> uniformBufferBoundToSlot1: ...
* ```
*
* ---
*
* There are optional properties that can be provided through `props`. These
* are the supported properties:
*
@@ -3073,6 +3162,55 @@ extern SDL_DECLSPEC SDL_GPUSampler * SDLCALL SDL_CreateGPUSampler(
*
* ---
*
* **WGSL (WebGPU Shading Language)**
*
* For vertex shaders, use: - Group 0 for samplers, storage textures, and
* storage buffers - Group 1 for uniform data
*
* For fragment shaders, use: - Group 2 for samplers, storage textures, and
* storage buffers - Group 3 for uniform data
*
* The first resource in a given set must have a `binding` of 0. Additional
* resources must appear at consecutive bindings (1, 2, etc), leaving no gaps
* in the set.
*
* All sampled textures must come first in the binding order, followed by their
* associated sampler, in order of how they are bound via `SDL_BindGPU*Samplers()`.
*
* All storage textures must come after all samplers and sampled textures
* in the binding order, in order of how they are bound via `SDL_Bind*StorageTextures()`.
*
* All storage buffers must come after all storage textures in the binding
* order, in order of how they are bound via `SDL_Bind*StorageBuffers()`.
*
* Note that WebGPU has... odd alignment rules. All types must be aligned to a power of
* two, but can be any size.
* Consult the [WebGPU spec](https://www.w3.org/TR/WGSL/#alignment-and-size) for more.
*
* **Example**
*
* If a vertex shader binds 2 samplers, 2 storage textures, 2 storage buffers,
* and 2 uniform buffers, its binding layout should look like this:
*
* ```wgsl
* // Sampled textures come first, followed by the sampler, in SDL slot order.
* \@group(0) \@binding(0) var sampledTextureBoundToSlot0: ...
* \@group(0) \@binding(1) var samplerBoundToSlot0: sampler
* \@group(0) \@binding(2) var sampledTextureBoundToSlot1: ...
* \@group(0) \@binding(3) var samplerBoundToSlot1: sampler
* // Any storage textures come next, in SDL slot order.
* \@group(0) \@binding(4) var storageTextureBoundToSlot0: ...
* \@group(0) \@binding(5) var storageTextureBoundToSlot1: ...
* // Any storage buffers come next, in SDL slot order.
* \@group(0) \@binding(6) var<storage, ...> storageBufferBoundToSlot0: ...
* \@group(0) \@binding(7) var<storage, ...> storageBufferBoundToSlot1: ...
* // Any uniform buffers are in their own set, in SDL slot order.
* \@group(1) \@binding(0) var<uniform> uniformBufferBoundToSlot0: ...
* \@group(1) \@binding(1) var<uniform> uniformBufferBoundToSlot1: ...
* ```
*
* ---
*
* Shader semantics other than system-value semantics do not matter in D3D12.
* For ease of use, the SDL implementation assumes that non system-value
* semantics will all be `TEXCOORD`. If you are using HLSL as the shader
@@ -4217,6 +4355,10 @@ extern SDL_DECLSPEC void SDLCALL SDL_EndGPUComputePass(
* SDL_UnmapGPUTransferBuffer. The memory is owned by the graphics driver - do
* NOT call SDL_free() on the returned pointer.
*
* Note that for the WebGPU backend, mapping download buffers is a very expensive
* procedure. Mapping download buffers with the WebGPU backend is strongly
* discouraged.
*
* \param device a GPU context.
* \param transfer_buffer a transfer buffer.
* \param cycle if true, cycles the transfer buffer if it is already bound.
@@ -4276,6 +4418,8 @@ extern SDL_DECLSPEC SDL_GPUCopyPass * SDLCALL SDL_BeginGPUCopyPass(
* is properly aligned, but this adds overhead to the transfer process. Apps
* can avoid this by aligning their data appropriately, or using a different
* GPU backend than Direct3D 12.
* Note that the WebGPU backend inherits Direct3D's 256-byte BPR alignment
* rules, and therefore also presents the same behaviour.
*
* \param copy_pass a copy pass handle.
* \param source the source transfer buffer with image layout information.
@@ -4627,6 +4771,10 @@ extern SDL_DECLSPEC SDL_GPUTextureFormat SDLCALL SDL_GetGPUSwapchainTextureForma
* freed by the user. You MUST NOT call this function from any thread other
* than the one that created the window.
*
* **WARNING**: WebGPU has an edge case in which mapping a transfer buffer
* destroys any currently acquired swapchain textures! Always remember to
* acquire your swapchain texture AFTER you've mapped your transfer buffers!
*
* \param command_buffer a command buffer.
* \param window a window that has been claimed.
* \param swapchain_texture a pointer filled in with a swapchain texture
@@ -4703,6 +4851,10 @@ extern SDL_DECLSPEC bool SDLCALL SDL_WaitForGPUSwapchain(
* The swapchain texture is write-only and cannot be used as a sampler or for
* another reading operation.
*
* **WARNING**: WebGPU has an edge case in which mapping a transfer buffer
* destroys any currently acquired swapchain textures! Always remember to
* acquire your swapchain texture AFTER you've mapped your transfer buffers!
*
* \param command_buffer a command buffer.
* \param window a window that has been claimed.
* \param swapchain_texture a pointer filled in with a swapchain texture
+61
View File
@@ -0,0 +1,61 @@
/**
* # CategoryWGPU
*
* Experimental video support for WebGPU.
*/
#ifndef SDL_wgpu_h_
#define SDL_wgpu_h_
#include <SDL3/SDL_video.h>
#include <SDL3/SDL_begin_code.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef WEBGPU_H_
#define WGPU_OBJECT_ATTRIBUTE(object) typedef struct object##Impl *object;
WGPU_OBJECT_ATTRIBUTE(WGPUSurface)
WGPU_OBJECT_ATTRIBUTE(WGPUInstance)
#undef WGPU_OBJECT_ATTRIBUTE
#endif
/**
* Create a new WebGPU surface.
* This will not configure the surface.
*
* \param window the window which the surface will attach itself to.
* \param instance a WebGPU instance.
* \param surface a pointer to a WGPUSurface handle to output the newly
* created WebGPU surface.
*
* \returns true on success or false on failure; call SDL_GetError() for more
* information.
*
* \since This is part of SDL PR #16020, and is therefore not available in regular SDL.
*
* \sa SDL_WGPU_DestroySurface
*/
extern SDL_DECLSPEC bool SDLCALL SDL_WGPU_CreateSurface(SDL_Window *window, WGPUInstance instance, WGPUSurface *surface);
/**
* Destroy a WebGPU surface.
*
* \param surface the surface to destroy.
*
* \since This is part of SDL PR #16020, and is therefore not available in regular SDL.
*
* \sa SDL_WGPU_CreateSurface
*/
extern SDL_DECLSPEC void SDLCALL SDL_WGPU_DestroySurface(WGPUSurface surface);
#ifdef __cplusplus
}
#endif
#include <SDL3/SDL_close_code.h>
#endif // SDL_wgpu_h_
@@ -494,11 +494,18 @@
/* Enable Metal support */
#cmakedefine SDL_VIDEO_METAL 1
/* Enable experimental WEBGPU support */
#cmakedefine SDL_VIDEO_WEBGPU 1
#cmakedefine WGPU_STATIC 1
#cmakedefine WGPU_NATIVE 1
#cmakedefine WGPU_DAWN 1
/* Enable GPU support */
#cmakedefine SDL_GPU_D3D11 1
#cmakedefine SDL_GPU_D3D12 1
#cmakedefine SDL_GPU_VULKAN 1
#cmakedefine SDL_GPU_METAL 1
#cmakedefine SDL_GPU_WEBGPU 1
#cmakedefine HAVE_GPU_OPENXR 1
#cmakedefine SDL_GPU_PRIVATE 1
+1
View File
@@ -47,6 +47,7 @@
// These headers have system specific definitions, so aren't included above
#include <SDL3/SDL_vulkan.h>
#include <SDL3/SDL_wgpu.h>
#if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__)
#ifndef WIN32_LEAN_AND_MEAN
+2
View File
@@ -1327,3 +1327,5 @@ _SDL_GetCachePath
_SDL_SetRenderLogicalPresentationRect
_SDL_IsGooglePlayOnPC
_SDL_SetWindowMousePassthrough
_SDL_WGPU_CreateSurface
_SDL_WGPU_DestroySurface
+2
View File
@@ -1328,6 +1328,8 @@ SDL3_0.0.0 {
SDL_SetRenderLogicalPresentationRect;
SDL_IsGooglePlayOnPC;
SDL_SetWindowMousePassthrough;
SDL_WGPU_CreateSurface;
SDL_WGPU_DestroySurface;
# extra symbols go here (don't modify this line)
local: *;
};
+2
View File
@@ -1354,3 +1354,5 @@
#define SDL_SetRenderLogicalPresentationRect SDL_SetRenderLogicalPresentationRect_REAL
#define SDL_IsGooglePlayOnPC SDL_IsGooglePlayOnPC_REAL
#define SDL_SetWindowMousePassthrough SDL_SetWindowMousePassthrough_REAL
#define SDL_WGPU_CreateSurface SDL_WGPU_CreateSurface_REAL
#define SDL_WGPU_DestroySurface SDL_WGPU_DestroySurface_REAL
+2
View File
@@ -1362,3 +1362,5 @@ SDL_DYNAPI_PROC(char*,SDL_GetCachePath,(const char *a,const char *b),(a,b),retur
SDL_DYNAPI_PROC(bool,SDL_SetRenderLogicalPresentationRect,(SDL_Renderer *a,const SDL_FRect *b),(a,b),return)
SDL_DYNAPI_PROC(bool,SDL_IsGooglePlayOnPC,(void),(),return)
SDL_DYNAPI_PROC(bool,SDL_SetWindowMousePassthrough,(SDL_Window *a,bool b),(a,b),return)
SDL_DYNAPI_PROC(bool,SDL_WGPU_CreateSurface,(SDL_Window *a,WGPUInstance b,WGPUSurface *c),(a,b,c),return)
SDL_DYNAPI_PROC(void,SDL_WGPU_DestroySurface,(WGPUSurface a),(a),)
+6
View File
@@ -328,6 +328,9 @@ static const SDL_GPUBootstrap *backends[] = {
#endif
#ifdef SDL_GPU_VULKAN
&VulkanDriver,
#endif
#ifdef SDL_GPU_WEBGPU
&WebGPUDriver,
#endif
NULL
};
@@ -672,6 +675,9 @@ static void SDL_GPU_FillProperties(
if (format_flags & SDL_GPU_SHADERFORMAT_METALLIB) {
SDL_SetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_SHADERS_METALLIB_BOOLEAN, true);
}
if (format_flags & SDL_GPU_SHADERFORMAT_WGSL) {
SDL_SetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_SHADERS_WGSL_BOOLEAN, true);
}
SDL_SetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_DEBUGMODE_BOOLEAN, debug_mode);
SDL_SetStringProperty(props, SDL_PROP_GPU_DEVICE_CREATE_NAME_STRING, name);
}
+1
View File
@@ -1233,6 +1233,7 @@ extern "C" {
extern SDL_GPUBootstrap VulkanDriver;
extern SDL_GPUBootstrap D3D12Driver;
extern SDL_GPUBootstrap MetalDriver;
extern SDL_GPUBootstrap WebGPUDriver;
extern SDL_GPUBootstrap PrivateGPUDriver;
#ifdef __cplusplus
+1 -1
View File
@@ -151,7 +151,7 @@ static VkFormat SDLToVK_TextureFormat[] = {
VK_FORMAT_R8G8B8A8_SRGB, // R8G8B8A8_UNORM_SRGB
VK_FORMAT_B8G8R8A8_SRGB, // B8G8R8A8_UNORM_SRGB
VK_FORMAT_BC1_RGBA_SRGB_BLOCK, // BC1_UNORM_SRGB
VK_FORMAT_BC2_SRGB_BLOCK, // BC3_UNORM_SRGB
VK_FORMAT_BC2_SRGB_BLOCK, // BC2_UNORM_SRGB
VK_FORMAT_BC3_SRGB_BLOCK, // BC3_UNORM_SRGB
VK_FORMAT_BC7_SRGB_BLOCK, // BC7_UNORM_SRGB
VK_FORMAT_D16_UNORM, // D16_UNORM
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+24
View File
@@ -69,12 +69,22 @@ typedef struct GPU_ShaderModuleSource
#define HAVE_METAL_SHADERS 0
#endif
#ifdef SDL_GPU_WEBGPU
#define IF_WEBGPU(...) __VA_ARGS__
#define HAVE_WGSL_SHADERS 1
#include "shaders/wgsl.h"
#else
#define IF_WEBGPU(...)
#define HAVE_WGSL_SHADERS 0
#endif
typedef struct GPU_ShaderSources
{
IF_PRIVATE(GPU_ShaderModuleSource private;)
IF_VULKAN(GPU_ShaderModuleSource spirv;)
IF_D3D12(GPU_ShaderModuleSource dxil60;)
IF_METAL(GPU_ShaderModuleSource msl;)
IF_WEBGPU(GPU_ShaderModuleSource wgsl;)
unsigned int num_samplers;
unsigned int num_uniform_buffers;
} GPU_ShaderSources;
@@ -91,6 +101,9 @@ typedef struct GPU_ShaderSources
#define SHADER_METAL(code) \
IF_METAL(.msl = { code, sizeof(code), SDL_GPU_SHADERFORMAT_MSL }, )
#define SHADER_WGSL(code) \
IF_WEBGPU(.wgsl = { code, sizeof(code), SDL_GPU_SHADERFORMAT_WGSL }, )
// clang-format off
static const GPU_ShaderSources vert_shader_sources[NUM_VERT_SHADERS] = {
[VERT_SHADER_LINEPOINT] = {
@@ -100,6 +113,7 @@ static const GPU_ShaderSources vert_shader_sources[NUM_VERT_SHADERS] = {
SHADER_SPIRV(linepoint_vert_spv)
SHADER_DXIL60(linepoint_vert_dxil)
SHADER_METAL(linepoint_vert_msl)
SHADER_WGSL(linepoint_vert_wgsl)
},
[VERT_SHADER_TRI_COLOR] = {
.num_samplers = 0,
@@ -108,6 +122,7 @@ static const GPU_ShaderSources vert_shader_sources[NUM_VERT_SHADERS] = {
SHADER_SPIRV(tri_color_vert_spv)
SHADER_DXIL60(tri_color_vert_dxil)
SHADER_METAL(tri_color_vert_msl)
SHADER_WGSL(tri_color_vert_wgsl)
},
[VERT_SHADER_TRI_TEXTURE] = {
.num_samplers = 0,
@@ -116,6 +131,7 @@ static const GPU_ShaderSources vert_shader_sources[NUM_VERT_SHADERS] = {
SHADER_SPIRV(tri_texture_vert_spv)
SHADER_DXIL60(tri_texture_vert_dxil)
SHADER_METAL(tri_texture_vert_msl)
SHADER_WGSL(tri_texture_vert_wgsl)
},
};
@@ -127,6 +143,7 @@ static const GPU_ShaderSources frag_shader_sources[NUM_FRAG_SHADERS] = {
SHADER_SPIRV(color_frag_spv)
SHADER_DXIL60(color_frag_dxil)
SHADER_METAL(color_frag_msl)
SHADER_WGSL(color_frag_wgsl)
},
[FRAG_SHADER_TEXTURE_RGB] = {
.num_samplers = 1,
@@ -135,6 +152,7 @@ static const GPU_ShaderSources frag_shader_sources[NUM_FRAG_SHADERS] = {
SHADER_SPIRV(texture_rgb_frag_spv)
SHADER_DXIL60(texture_rgb_frag_dxil)
SHADER_METAL(texture_rgb_frag_msl)
SHADER_WGSL(texture_rgb_frag_wgsl)
},
[FRAG_SHADER_TEXTURE_RGBA] = {
.num_samplers = 1,
@@ -143,6 +161,7 @@ static const GPU_ShaderSources frag_shader_sources[NUM_FRAG_SHADERS] = {
SHADER_SPIRV(texture_rgba_frag_spv)
SHADER_DXIL60(texture_rgba_frag_dxil)
SHADER_METAL(texture_rgba_frag_msl)
SHADER_WGSL(texture_rgba_frag_wgsl)
},
[FRAG_SHADER_TEXTURE_ADVANCED] = {
.num_samplers = 3,
@@ -151,6 +170,7 @@ static const GPU_ShaderSources frag_shader_sources[NUM_FRAG_SHADERS] = {
SHADER_SPIRV(texture_advanced_frag_spv)
SHADER_DXIL60(texture_advanced_frag_dxil)
SHADER_METAL(texture_advanced_frag_msl)
SHADER_WGSL(texture_advanced_frag_wgsl)
},
[FRAG_SHADER_COLOR_PQ] = {
.num_samplers = 0,
@@ -187,6 +207,10 @@ static SDL_GPUShader *CompileShader(const GPU_ShaderSources *sources, SDL_GPUDev
} else if (formats & SDL_GPU_SHADERFORMAT_MSL) {
sms = &sources->msl;
#endif // HAVE_METAL_SHADERS
#if HAVE_WGSL_SHADERS
} else if (formats & SDL_GPU_SHADERFORMAT_WGSL) {
sms = &sources->wgsl;
#endif // HAVE_WGSL_SHADERS
} else {
SDL_SetError("Unsupported GPU backend");
return NULL;
+25
View File
@@ -0,0 +1,25 @@
struct Constants {
colorScale: f32,
};
struct PSInput {
@location(0u) vColor: vec4<f32>,
};
struct PSOutput {
@location(0u) oColor: vec4<f32>,
};
@group(3u) @binding(0u) var<uniform> constants: Constants;
fn getOutputColor(rgba: vec4<f32>, colorScale: f32) -> vec4<f32> {
return vec4<f32>(rgba.rgb * colorScale, rgba.a);
}
@fragment
fn main(input: PSInput) -> PSOutput {
var output: PSOutput;
output.oColor = getOutputColor(vec4<f32>(1.0f), constants.colorScale) * input.vColor;
return output;
}
+38
View File
@@ -0,0 +1,38 @@
static const unsigned char color_frag_wgsl[] = {
0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x73,
0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x53, 0x63, 0x61, 0x6c,
0x65, 0x3a, 0x20, 0x66, 0x33, 0x32, 0x2c, 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x73, 0x74, 0x72, 0x75,
0x63, 0x74, 0x20, 0x50, 0x53, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x40, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x30, 0x75, 0x29, 0x20, 0x76,
0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x20, 0x76, 0x65, 0x63, 0x34, 0x3c, 0x66, 0x33, 0x32, 0x3e,
0x2c, 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x50, 0x53, 0x4f,
0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x40, 0x6c, 0x6f, 0x63,
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x30, 0x75, 0x29, 0x20, 0x6f, 0x43, 0x6f, 0x6c, 0x6f, 0x72,
0x3a, 0x20, 0x76, 0x65, 0x63, 0x34, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x2c, 0x0a, 0x7d, 0x3b, 0x0a,
0x0a, 0x40, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x28, 0x33, 0x75, 0x29, 0x20, 0x40, 0x62, 0x69, 0x6e,
0x64, 0x69, 0x6e, 0x67, 0x28, 0x30, 0x75, 0x29, 0x20, 0x76, 0x61, 0x72, 0x3c, 0x75, 0x6e, 0x69,
0x66, 0x6f, 0x72, 0x6d, 0x3e, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x73, 0x3a,
0x20, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x73, 0x3b, 0x0a, 0x0a, 0x66, 0x6e, 0x20,
0x67, 0x65, 0x74, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x28, 0x72,
0x67, 0x62, 0x61, 0x3a, 0x20, 0x76, 0x65, 0x63, 0x34, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x2c, 0x20,
0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x53, 0x63, 0x61, 0x6c, 0x65, 0x3a, 0x20, 0x66, 0x33, 0x32, 0x29,
0x20, 0x2d, 0x3e, 0x20, 0x76, 0x65, 0x63, 0x34, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x20, 0x7b, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x76, 0x65, 0x63, 0x34, 0x3c,
0x66, 0x33, 0x32, 0x3e, 0x28, 0x72, 0x67, 0x62, 0x61, 0x2e, 0x72, 0x67, 0x62, 0x20, 0x2a, 0x20,
0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x53, 0x63, 0x61, 0x6c, 0x65, 0x2c, 0x20, 0x72, 0x67, 0x62, 0x61,
0x2e, 0x61, 0x29, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x40, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e,
0x74, 0x0a, 0x66, 0x6e, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x28, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x3a,
0x20, 0x50, 0x53, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x29, 0x20, 0x2d, 0x3e, 0x20, 0x50, 0x53, 0x4f,
0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20,
0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x3a, 0x20, 0x50, 0x53, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74,
0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2e, 0x6f, 0x43, 0x6f,
0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x67, 0x65, 0x74, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x43,
0x6f, 0x6c, 0x6f, 0x72, 0x28, 0x76, 0x65, 0x63, 0x34, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x31,
0x2e, 0x30, 0x66, 0x29, 0x2c, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x73, 0x2e,
0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x53, 0x63, 0x61, 0x6c, 0x65, 0x29, 0x20, 0x2a, 0x20, 0x69, 0x6e,
0x70, 0x75, 0x74, 0x2e, 0x76, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x3b, 0x0a,
0x7d, 0x0a
};
static const unsigned int color_frag_wgsl_len = 530;
@@ -0,0 +1,26 @@
struct Context {
mvp: mat4x4<f32>, // Model-View-Projection matrix
};
struct VSInput {
@location(0u) aPosition: vec2<f32>,
@location(1u) aColor: vec4<f32>,
};
// The point size in WebGPU is constant since WebGPU
// hates puppies, rainbows, and the concept of love
struct VSOutput {
@location(0u) vColor: vec4<f32>,
@builtin(position) glPosition: vec4<f32>,
}
@group(1u) @binding(0u) var<uniform> context: Context;
@vertex
fn main(input: VSInput) -> VSOutput {
var output: VSOutput;
output.glPosition = vec4<f32>(input.aPosition, 0.0f, 1.0f) * context.mvp;
output.vColor = input.aColor;
return output;
}
+45
View File
@@ -0,0 +1,45 @@
static const unsigned char linepoint_vert_wgsl[] = {
0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x20, 0x7b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x6d, 0x76, 0x70, 0x3a, 0x20, 0x6d, 0x61, 0x74, 0x34, 0x78, 0x34,
0x3c, 0x66, 0x33, 0x32, 0x3e, 0x2c, 0x20, 0x2f, 0x2f, 0x20, 0x4d, 0x6f, 0x64, 0x65, 0x6c, 0x2d,
0x56, 0x69, 0x65, 0x77, 0x2d, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20,
0x6d, 0x61, 0x74, 0x72, 0x69, 0x78, 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63,
0x74, 0x20, 0x56, 0x53, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x40, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x30, 0x75, 0x29, 0x20, 0x61, 0x50,
0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x76, 0x65, 0x63, 0x32, 0x3c, 0x66, 0x33,
0x32, 0x3e, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x40, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f,
0x6e, 0x28, 0x31, 0x75, 0x29, 0x20, 0x61, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x20, 0x76, 0x65,
0x63, 0x34, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x2c, 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x2f, 0x2f, 0x20,
0x54, 0x68, 0x65, 0x20, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x20, 0x73, 0x69, 0x7a, 0x65, 0x20, 0x69,
0x6e, 0x20, 0x57, 0x65, 0x62, 0x47, 0x50, 0x55, 0x20, 0x69, 0x73, 0x20, 0x63, 0x6f, 0x6e, 0x73,
0x74, 0x61, 0x6e, 0x74, 0x20, 0x73, 0x69, 0x6e, 0x63, 0x65, 0x20, 0x57, 0x65, 0x62, 0x47, 0x50,
0x55, 0x20, 0x0a, 0x2f, 0x2f, 0x20, 0x68, 0x61, 0x74, 0x65, 0x73, 0x20, 0x70, 0x75, 0x70, 0x70,
0x69, 0x65, 0x73, 0x2c, 0x20, 0x72, 0x61, 0x69, 0x6e, 0x62, 0x6f, 0x77, 0x73, 0x2c, 0x20, 0x61,
0x6e, 0x64, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x6f, 0x6e, 0x63, 0x65, 0x70, 0x74, 0x20, 0x6f,
0x66, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x56, 0x53,
0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x40, 0x6c, 0x6f,
0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x30, 0x75, 0x29, 0x20, 0x76, 0x43, 0x6f, 0x6c, 0x6f,
0x72, 0x3a, 0x20, 0x76, 0x65, 0x63, 0x34, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x2c, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x40, 0x62, 0x75, 0x69, 0x6c, 0x74, 0x69, 0x6e, 0x28, 0x70, 0x6f, 0x73, 0x69, 0x74,
0x69, 0x6f, 0x6e, 0x29, 0x20, 0x67, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3a,
0x20, 0x76, 0x65, 0x63, 0x34, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x2c, 0x0a, 0x7d, 0x0a, 0x0a, 0x40,
0x67, 0x72, 0x6f, 0x75, 0x70, 0x28, 0x31, 0x75, 0x29, 0x20, 0x40, 0x62, 0x69, 0x6e, 0x64, 0x69,
0x6e, 0x67, 0x28, 0x30, 0x75, 0x29, 0x20, 0x76, 0x61, 0x72, 0x3c, 0x75, 0x6e, 0x69, 0x66, 0x6f,
0x72, 0x6d, 0x3e, 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x3a, 0x20, 0x43, 0x6f, 0x6e,
0x74, 0x65, 0x78, 0x74, 0x3b, 0x0a, 0x0a, 0x40, 0x76, 0x65, 0x72, 0x74, 0x65, 0x78, 0x0a, 0x66,
0x6e, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x28, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x3a, 0x20, 0x56, 0x53,
0x49, 0x6e, 0x70, 0x75, 0x74, 0x29, 0x20, 0x2d, 0x3e, 0x20, 0x56, 0x53, 0x4f, 0x75, 0x74, 0x70,
0x75, 0x74, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x6f, 0x75, 0x74,
0x70, 0x75, 0x74, 0x3a, 0x20, 0x56, 0x53, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x3b, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2e, 0x67, 0x6c, 0x50, 0x6f, 0x73, 0x69,
0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x34, 0x3c, 0x66, 0x33, 0x32, 0x3e,
0x28, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x2e, 0x61, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e,
0x2c, 0x20, 0x30, 0x2e, 0x30, 0x66, 0x2c, 0x20, 0x31, 0x2e, 0x30, 0x66, 0x29, 0x20, 0x2a, 0x20,
0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x2e, 0x6d, 0x76, 0x70, 0x3b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2e, 0x76, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d,
0x20, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x2e, 0x61, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0x0a, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6f, 0x75, 0x74, 0x70, 0x75,
0x74, 0x3b, 0x0a, 0x7d, 0x0a
};
static const unsigned int linepoint_vert_wgsl_len = 645;
@@ -0,0 +1,312 @@
// I couldn't be bothered with manually porting that entire shader so I used Tint
struct Constants {
scRGB_output: f32,
texture_type: f32,
input_type: f32,
color_scale: f32,
texel_size: vec4<f32>,
tonemap_method: f32,
tonemap_factor1: f32,
tonemap_factor2: f32,
sdr_white_point: f32,
Yoffset: vec4<f32>,
Rcoeff: vec4<f32>,
Gcoeff: vec4<f32>,
Bcoeff: vec4<f32>,
}
@group(3u) @binding(0u) var<uniform> v: Constants;
@group(2u) @binding(0u) var texture0: texture_2d<f32>;
@group(2u) @binding(1u) var sampler0: sampler;
@group(2u) @binding(2u) var texture1: texture_2d<f32>;
@group(2u) @binding(3u) var sampler1: sampler;
@group(2u) @binding(4u) var texture2: texture_2d<f32>;
@group(2u) @binding(5u) var sampler2: sampler;
var<private> v_1: vec4<f32>;
fn main_inner(v_2: vec4<f32>, v_3: vec2<f32>) {
var v_4: vec4<f32>;
var v_5: vec3<f32>;
var v_6: vec3<f32>;
var v_7: vec2<f32>;
var v_8: vec2<f32>;
var v_9: vec4<f32>;
var v_10: vec3<f32>;
var v_11: vec3<f32>;
var v_12: vec3<f32>;
var v_13: vec4<f32>;
var v_14: vec3<f32>;
var v_15: vec4<f32>;
var v_16: vec3<f32>;
var v_17: vec4<f32>;
if (v.texture_type == 0.0f) {
v_9 = vec4<f32>(1.0f);
} else if (v.texture_type == 3.0f) {
v_9 = textureSample(texture0, sampler0, v_3);
} else if (v.texture_type == 4.0f) {
let v_18 = clamp((fwidth(v_3) * v.texel_size.zw), vec2<f32>(0.00000999999974737875f), vec2<f32>(1.0f));
let v_19 = ((v_3 * v.texel_size.zw) - (v_18 * 0.5f));
let v_20 = smoothstep((vec2<f32>(1.0f) - v_18), vec2<f32>(1.0f), fract(v_19));
let v_21 = (((floor(v_19) + vec2<f32>(0.5f)) + v_20) * v.texel_size.xy);
v_9 = textureSampleGrad(texture0, sampler0, v_21, dpdx(v_3), dpdy(v_3));
} else if (v.texture_type == 1.0f) {
let v_22 = textureSample(texture0, sampler0, v_3);
v_9 = vec4<f32>(v_22.x, v_22.y, v_22.z, 1.0f);
} else if (v.texture_type == 2.0f) {
let v_23 = clamp((fwidth(v_3) * v.texel_size.zw), vec2<f32>(0.00000999999974737875f), vec2<f32>(1.0f));
let v_24 = ((v_3 * v.texel_size.zw) - (v_23 * 0.5f));
let v_25 = smoothstep((vec2<f32>(1.0f) - v_23), vec2<f32>(1.0f), fract(v_24));
let v_26 = (((floor(v_24) + vec2<f32>(0.5f)) + v_25) * v.texel_size.xy);
let v_27 = textureSampleGrad(texture0, sampler0, v_26, dpdx(v_3), dpdy(v_3));
v_9 = vec4<f32>(v_27.x, v_27.y, v_27.z, 1.0f);
} else if (v.texture_type == 5.0f) {
let v_28 = (textureSample(texture0, sampler0, v_3).x * 255.0f);
v_9 = textureSample(texture1, sampler1, vec2<f32>(((v_28 + 0.5f) * 0.00390625f), 0.5f));
} else if (v.texture_type == 6.0f) {
let v_29 = ((v_3 * v.texel_size.zw) + vec2<f32>(0.5f));
let v_30 = ((floor(v_29) - vec2<f32>(0.5f)) * v.texel_size.xy);
let v_31 = ((floor(v_29) + vec2<f32>(0.5f)) * v.texel_size.xy);
let v_32 = vec4<f32>(v_30.x, v_30.y, v_31.x, v_31.y);
v_8 = fract(v_29);
let v_33 = (textureSample(texture0, sampler0, v_32.xy).x * 255.0f);
let v_34 = textureSample(texture1, sampler1, vec2<f32>(((v_33 + 0.5f) * 0.00390625f), 0.5f));
let v_35 = (textureSample(texture0, sampler0, v_32.xw).x * 255.0f);
let v_36 = textureSample(texture1, sampler1, vec2<f32>(((v_35 + 0.5f) * 0.00390625f), 0.5f));
let v_37 = (textureSample(texture0, sampler0, v_32.zy).x * 255.0f);
let v_38 = textureSample(texture1, sampler1, vec2<f32>(((v_37 + 0.5f) * 0.00390625f), 0.5f));
let v_39 = (textureSample(texture0, sampler0, v_32.zw).x * 255.0f);
let v_40 = textureSample(texture1, sampler1, vec2<f32>(((v_39 + 0.5f) * 0.00390625f), 0.5f));
let v_41 = v_8.y;
let v_42 = mix(v_34, v_36, vec4<f32>(v_41, v_41, v_41, v_41));
let v_43 = v_8.y;
let v_44 = mix(v_38, v_40, vec4<f32>(v_43, v_43, v_43, v_43));
let v_45 = v_8.x;
v_9 = mix(v_42, v_44, vec4<f32>(v_45, v_45, v_45, v_45));
} else if (v.texture_type == 7.0f) {
let v_46 = clamp((fwidth(v_3) * v.texel_size.zw), vec2<f32>(0.00000999999974737875f), vec2<f32>(1.0f));
let v_47 = ((v_3 * v.texel_size.zw) - (v_46 * 0.5f));
let v_48 = smoothstep((vec2<f32>(1.0f) - v_46), vec2<f32>(1.0f), fract(v_47));
let v_49 = (((((floor(v_47) + vec2<f32>(0.5f)) + v_48) * v.texel_size.xy) * v.texel_size.zw) + vec2<f32>(0.5f));
let v_50 = ((floor(v_49) - vec2<f32>(0.5f)) * v.texel_size.xy);
let v_51 = ((floor(v_49) + vec2<f32>(0.5f)) * v.texel_size.xy);
let v_52 = vec4<f32>(v_50.x, v_50.y, v_51.x, v_51.y);
v_7 = fract(v_49);
let v_53 = (textureSample(texture0, sampler0, v_52.xy).x * 255.0f);
let v_54 = textureSample(texture1, sampler1, vec2<f32>(((v_53 + 0.5f) * 0.00390625f), 0.5f));
let v_55 = (textureSample(texture0, sampler0, v_52.xw).x * 255.0f);
let v_56 = textureSample(texture1, sampler1, vec2<f32>(((v_55 + 0.5f) * 0.00390625f), 0.5f));
let v_57 = (textureSample(texture0, sampler0, v_52.zy).x * 255.0f);
let v_58 = textureSample(texture1, sampler1, vec2<f32>(((v_57 + 0.5f) * 0.00390625f), 0.5f));
let v_59 = (textureSample(texture0, sampler0, v_52.zw).x * 255.0f);
let v_60 = textureSample(texture1, sampler1, vec2<f32>(((v_59 + 0.5f) * 0.00390625f), 0.5f));
let v_61 = v_7.y;
let v_62 = mix(v_54, v_56, vec4<f32>(v_61, v_61, v_61, v_61));
let v_63 = v_7.y;
let v_64 = mix(v_58, v_60, vec4<f32>(v_63, v_63, v_63, v_63));
let v_65 = v_7.x;
v_9 = mix(v_62, v_64, vec4<f32>(v_65, v_65, v_65, v_65));
} else if (v.texture_type == 8.0f) {
v_10.x = textureSample(texture0, sampler0, v_3).x;
let v_66 = textureSample(texture1, sampler0, v_3);
v_10.y = v_66.x;
v_10.z = v_66.y;
let v_67 = v.Yoffset.xyz;
let v_68 = (v_10 + v_67);
v_10 = v_68;
v_9.x = dot(v_68, v.Rcoeff.xyz);
v_9.y = dot(v_68, v.Gcoeff.xyz);
v_9.z = dot(v_68, v.Bcoeff.xyz);
v_9.w = 1.0f;
} else if (v.texture_type == 9.0f) {
v_11.x = textureSample(texture0, sampler0, v_3).x;
let v_69 = textureSample(texture1, sampler0, v_3);
v_11.y = v_69.y;
v_11.z = v_69.x;
let v_70 = v.Yoffset.xyz;
let v_71 = (v_11 + v_70);
v_11 = v_71;
v_9.x = dot(v_71, v.Rcoeff.xyz);
v_9.y = dot(v_71, v.Gcoeff.xyz);
v_9.z = dot(v_71, v.Bcoeff.xyz);
v_9.w = 1.0f;
} else if (v.texture_type == 10.0f) {
v_12.x = textureSample(texture0, sampler0, v_3).x;
v_12.y = textureSample(texture1, sampler0, v_3).x;
v_12.z = textureSample(texture2, sampler0, v_3).x;
let v_72 = v.Yoffset.xyz;
let v_73 = (v_12 + v_72);
v_12 = v_73;
v_9.x = dot(v_73, v.Rcoeff.xyz);
v_9.y = dot(v_73, v.Gcoeff.xyz);
v_9.z = dot(v_73, v.Bcoeff.xyz);
v_9.w = 1.0f;
} else {
v_9.x = 1.0f;
v_9.y = 0.0f;
v_9.z = 1.0f;
v_9.w = 1.0f;
}
v_13 = v_9;
if (v.input_type == 3.0f) {
let v_74 = v_13.xyz;
let v_75 = (pow(abs((max((pow(abs(v_74), vec3<f32>(0.01268331333994865417f)) - vec3<f32>(0.8359375f)), vec3<f32>()) / (vec3<f32>(18.8515625f) - (pow(abs(v_74), vec3<f32>(0.01268331333994865417f)) * 18.6875f)))), vec3<f32>(6.27739477157592773438f)) * 10000.0f);
let v_76 = v.sdr_white_point;
let v_77 = (v_75 / vec3<f32>(v_76, v_76, v_76));
v_13.x = v_77.x;
v_13.y = v_77.y;
v_13.z = v_77.z;
}
if !((v.tonemap_method == 0.0f)) {
v_14 = v_13.xyz;
if (v.tonemap_method == 1.0f) {
let v_78 = v.tonemap_factor1;
v_14 = (v_14 * v_78);
} else if (v.tonemap_method == 2.0f) {
if (v.input_type == 2.0f) {
v_14 = (v_14 * mat3x3<f32>(vec3<f32>(0.62740397453308105469f, 0.32928299903869628906f, 0.04331300035119056702f), vec3<f32>(0.06909699738025665283f, 0.91954100131988525391f, 0.01136200036853551865f), vec3<f32>(0.01639099977910518646f, 0.08801300078630447388f, 0.89559501409530639648f)));
}
let v_79 = max(v_14.x, max(v_14.y, v_14.z));
if (v_79 > 0.0f) {
let v_80 = ((1.0f + (v.tonemap_factor1 * v_79)) / (1.0f + (v.tonemap_factor2 * v_79)));
v_14 = (v_14 * v_80);
}
if (v.input_type == 2.0f) {
v_14 = (v_14 * mat3x3<f32>(vec3<f32>(1.66049599647521972656f, -0.5876560211181640625f, -0.07283999770879745483f), vec3<f32>(-0.12454699724912643433f, 1.13289499282836914062f, -0.00834800023585557938f), vec3<f32>(-0.01815400086343288422f, -0.10059700161218643188f, 1.11875104904174804688f)));
}
}
let v_81 = v_14;
v_13.x = v_81.x;
v_13.y = v_81.y;
v_13.z = v_81.z;
}
if (v.input_type == 1.0f) {
v_16 = v_13.xyz;
if !((v.scRGB_output == 0.0f)) {
let v_82 = v_16.x;
var v_83: f32;
if (v_82 <= 0.04044999927282333374f) {
v_83 = (v_82 * 0.07739938050508499146f);
} else {
v_83 = pow((abs((v_82 + 0.05499999970197677612f)) * 0.94786733388900756836f), 2.40000009536743164062f);
}
v_16.x = v_83;
let v_84 = v_16.y;
var v_85: f32;
if (v_84 <= 0.04044999927282333374f) {
v_85 = (v_84 * 0.07739938050508499146f);
} else {
v_85 = pow((abs((v_84 + 0.05499999970197677612f)) * 0.94786733388900756836f), 2.40000009536743164062f);
}
v_16.y = v_85;
let v_86 = v_16.z;
var v_87: f32;
if (v_86 <= 0.04044999927282333374f) {
v_87 = (v_86 * 0.07739938050508499146f);
} else {
v_87 = pow((abs((v_86 + 0.05499999970197677612f)) * 0.94786733388900756836f), 2.40000009536743164062f);
}
v_16.z = v_87;
}
let v_88 = (v_16 * v.color_scale);
v_15.x = v_88.x;
v_15.y = v_88.y;
v_15.z = v_88.z;
v_15.w = v_13.w;
} else if (v.input_type == 2.0f) {
v_6 = (v_13.xyz * v.color_scale);
if (v.scRGB_output == 0.0f) {
let v_89 = v_6.x;
var v_90: f32;
if (v_89 <= 0.00313080009073019028f) {
v_90 = (v_89 * 12.9200000762939453125f);
} else {
v_90 = ((pow(abs(v_89), 0.4166666567325592041f) * 1.05499994754791259766f) - 0.05499999970197677612f);
}
v_6.x = v_90;
let v_91 = v_6.y;
var v_92: f32;
if (v_91 <= 0.00313080009073019028f) {
v_92 = (v_91 * 12.9200000762939453125f);
} else {
v_92 = ((pow(abs(v_91), 0.4166666567325592041f) * 1.05499994754791259766f) - 0.05499999970197677612f);
}
v_6.y = v_92;
let v_93 = v_6.z;
var v_94: f32;
if (v_93 <= 0.00313080009073019028f) {
v_94 = (v_93 * 12.9200000762939453125f);
} else {
v_94 = ((pow(abs(v_93), 0.4166666567325592041f) * 1.05499994754791259766f) - 0.05499999970197677612f);
}
v_6.z = v_94;
v_6 = clamp(v_6, vec3<f32>(), vec3<f32>(1.0f));
}
let v_95 = v_6;
v_15.x = v_95.x;
v_15.y = v_95.y;
v_15.z = v_95.z;
v_15.w = v_13.w;
} else if (v.input_type == 3.0f) {
let v_96 = (v_13.xyz * mat3x3<f32>(vec3<f32>(1.66049599647521972656f, -0.5876560211181640625f, -0.07283999770879745483f), vec3<f32>(-0.12454699724912643433f, 1.13289499282836914062f, -0.00834800023585557938f), vec3<f32>(-0.01815400086343288422f, -0.10059700161218643188f, 1.11875104904174804688f)));
v_13.x = v_96.x;
v_13.y = v_96.y;
v_13.z = v_96.z;
v_5 = (v_13.xyz * v.color_scale);
if (v.scRGB_output == 0.0f) {
let v_97 = v_5.x;
var v_98: f32;
if (v_97 <= 0.00313080009073019028f) {
v_98 = (v_97 * 12.9200000762939453125f);
} else {
v_98 = ((pow(abs(v_97), 0.4166666567325592041f) * 1.05499994754791259766f) - 0.05499999970197677612f);
}
v_5.x = v_98;
let v_99 = v_5.y;
var v_100: f32;
if (v_99 <= 0.00313080009073019028f) {
v_100 = (v_99 * 12.9200000762939453125f);
} else {
v_100 = ((pow(abs(v_99), 0.4166666567325592041f) * 1.05499994754791259766f) - 0.05499999970197677612f);
}
v_5.y = v_100;
let v_101 = v_5.z;
var v_102: f32;
if (v_101 <= 0.00313080009073019028f) {
v_102 = (v_101 * 12.9200000762939453125f);
} else {
v_102 = ((pow(abs(v_101), 0.4166666567325592041f) * 1.05499994754791259766f) - 0.05499999970197677612f);
}
v_5.z = v_102;
v_5 = clamp(v_5, vec3<f32>(), vec3<f32>(1.0f));
}
let v_103 = v_5;
v_15.x = v_103.x;
v_15.y = v_103.y;
v_15.z = v_103.z;
v_15.w = v_13.w;
} else {
let v_104 = v_13;
v_17 = v_104;
let v_105 = (v_104.xyz * v.color_scale);
v_4.x = v_105.x;
v_4.y = v_105.y;
v_4.z = v_105.z;
v_4.w = v_17.w;
v_15 = v_4;
}
v_1 = (v_15 * v_2);
}
@fragment
fn main(@location(0u) v_106: vec4<f32>, @location(1u) v_107: vec2<f32>) -> @location(0u) vec4<f32> {
main_inner(v_106, v_107);
return v_1;
}
+866
View File
@@ -0,0 +1,866 @@
static const unsigned char texture_advanced_frag_wgsl[] = {
0x2f, 0x2f, 0x20, 0x49, 0x20, 0x63, 0x6f, 0x75, 0x6c, 0x64, 0x6e, 0x27, 0x74, 0x20, 0x62, 0x65,
0x20, 0x62, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x6d,
0x61, 0x6e, 0x75, 0x61, 0x6c, 0x6c, 0x79, 0x20, 0x70, 0x6f, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x20,
0x74, 0x68, 0x61, 0x74, 0x20, 0x65, 0x6e, 0x74, 0x69, 0x72, 0x65, 0x20, 0x73, 0x68, 0x61, 0x64,
0x65, 0x72, 0x20, 0x73, 0x6f, 0x20, 0x49, 0x20, 0x75, 0x73, 0x65, 0x64, 0x20, 0x54, 0x69, 0x6e,
0x74, 0x0a, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x61,
0x6e, 0x74, 0x73, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x73, 0x63, 0x52, 0x47, 0x42, 0x5f,
0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x3a, 0x20, 0x66, 0x33, 0x32, 0x2c, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x66,
0x33, 0x32, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x5f, 0x74, 0x79,
0x70, 0x65, 0x3a, 0x20, 0x66, 0x33, 0x32, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6c,
0x6f, 0x72, 0x5f, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x3a, 0x20, 0x66, 0x33, 0x32, 0x2c, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x74, 0x65, 0x78, 0x65, 0x6c, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x20, 0x76,
0x65, 0x63, 0x34, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6f,
0x6e, 0x65, 0x6d, 0x61, 0x70, 0x5f, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x3a, 0x20, 0x66, 0x33,
0x32, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6f, 0x6e, 0x65, 0x6d, 0x61, 0x70, 0x5f, 0x66,
0x61, 0x63, 0x74, 0x6f, 0x72, 0x31, 0x3a, 0x20, 0x66, 0x33, 0x32, 0x2c, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x74, 0x6f, 0x6e, 0x65, 0x6d, 0x61, 0x70, 0x5f, 0x66, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x32,
0x3a, 0x20, 0x66, 0x33, 0x32, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x73, 0x64, 0x72, 0x5f, 0x77,
0x68, 0x69, 0x74, 0x65, 0x5f, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x3a, 0x20, 0x66, 0x33, 0x32, 0x2c,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x59, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x3a, 0x20, 0x76, 0x65,
0x63, 0x34, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x52, 0x63, 0x6f,
0x65, 0x66, 0x66, 0x3a, 0x20, 0x76, 0x65, 0x63, 0x34, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x2c, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x47, 0x63, 0x6f, 0x65, 0x66, 0x66, 0x3a, 0x20, 0x76, 0x65, 0x63, 0x34,
0x3c, 0x66, 0x33, 0x32, 0x3e, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x42, 0x63, 0x6f, 0x65, 0x66,
0x66, 0x3a, 0x20, 0x76, 0x65, 0x63, 0x34, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x2c, 0x0a, 0x7d, 0x0a,
0x0a, 0x40, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x28, 0x33, 0x75, 0x29, 0x20, 0x40, 0x62, 0x69, 0x6e,
0x64, 0x69, 0x6e, 0x67, 0x28, 0x30, 0x75, 0x29, 0x20, 0x76, 0x61, 0x72, 0x3c, 0x75, 0x6e, 0x69,
0x66, 0x6f, 0x72, 0x6d, 0x3e, 0x20, 0x76, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e,
0x74, 0x73, 0x3b, 0x0a, 0x0a, 0x40, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x28, 0x32, 0x75, 0x29, 0x20,
0x40, 0x62, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x28, 0x30, 0x75, 0x29, 0x20, 0x76, 0x61, 0x72,
0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x30, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x75,
0x72, 0x65, 0x5f, 0x32, 0x64, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x3b, 0x0a, 0x0a, 0x40, 0x67, 0x72,
0x6f, 0x75, 0x70, 0x28, 0x32, 0x75, 0x29, 0x20, 0x40, 0x62, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67,
0x28, 0x31, 0x75, 0x29, 0x20, 0x76, 0x61, 0x72, 0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72,
0x30, 0x3a, 0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x3b, 0x0a, 0x0a, 0x40, 0x67, 0x72,
0x6f, 0x75, 0x70, 0x28, 0x32, 0x75, 0x29, 0x20, 0x40, 0x62, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67,
0x28, 0x32, 0x75, 0x29, 0x20, 0x76, 0x61, 0x72, 0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65,
0x31, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x32, 0x64, 0x3c, 0x66, 0x33,
0x32, 0x3e, 0x3b, 0x0a, 0x0a, 0x40, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x28, 0x32, 0x75, 0x29, 0x20,
0x40, 0x62, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x28, 0x33, 0x75, 0x29, 0x20, 0x76, 0x61, 0x72,
0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x31, 0x3a, 0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c,
0x65, 0x72, 0x3b, 0x0a, 0x0a, 0x40, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x28, 0x32, 0x75, 0x29, 0x20,
0x40, 0x62, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x28, 0x34, 0x75, 0x29, 0x20, 0x76, 0x61, 0x72,
0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x32, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x75,
0x72, 0x65, 0x5f, 0x32, 0x64, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x3b, 0x0a, 0x0a, 0x40, 0x67, 0x72,
0x6f, 0x75, 0x70, 0x28, 0x32, 0x75, 0x29, 0x20, 0x40, 0x62, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67,
0x28, 0x35, 0x75, 0x29, 0x20, 0x76, 0x61, 0x72, 0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72,
0x32, 0x3a, 0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x3b, 0x0a, 0x0a, 0x76, 0x61, 0x72,
0x3c, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x3e, 0x20, 0x76, 0x5f, 0x31, 0x3a, 0x20, 0x76,
0x65, 0x63, 0x34, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x3b, 0x0a, 0x0a, 0x66, 0x6e, 0x20, 0x6d, 0x61,
0x69, 0x6e, 0x5f, 0x69, 0x6e, 0x6e, 0x65, 0x72, 0x28, 0x76, 0x5f, 0x32, 0x3a, 0x20, 0x76, 0x65,
0x63, 0x34, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x2c, 0x20, 0x76, 0x5f, 0x33, 0x3a, 0x20, 0x76, 0x65,
0x63, 0x32, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76,
0x61, 0x72, 0x20, 0x76, 0x5f, 0x34, 0x3a, 0x20, 0x76, 0x65, 0x63, 0x34, 0x3c, 0x66, 0x33, 0x32,
0x3e, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x76, 0x5f, 0x35, 0x3a, 0x20,
0x76, 0x65, 0x63, 0x33, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76,
0x61, 0x72, 0x20, 0x76, 0x5f, 0x36, 0x3a, 0x20, 0x76, 0x65, 0x63, 0x33, 0x3c, 0x66, 0x33, 0x32,
0x3e, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x76, 0x5f, 0x37, 0x3a, 0x20,
0x76, 0x65, 0x63, 0x32, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76,
0x61, 0x72, 0x20, 0x76, 0x5f, 0x38, 0x3a, 0x20, 0x76, 0x65, 0x63, 0x32, 0x3c, 0x66, 0x33, 0x32,
0x3e, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x76, 0x5f, 0x39, 0x3a, 0x20,
0x76, 0x65, 0x63, 0x34, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76,
0x61, 0x72, 0x20, 0x76, 0x5f, 0x31, 0x30, 0x3a, 0x20, 0x76, 0x65, 0x63, 0x33, 0x3c, 0x66, 0x33,
0x32, 0x3e, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x76, 0x5f, 0x31, 0x31,
0x3a, 0x20, 0x76, 0x65, 0x63, 0x33, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x3b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x76, 0x61, 0x72, 0x20, 0x76, 0x5f, 0x31, 0x32, 0x3a, 0x20, 0x76, 0x65, 0x63, 0x33, 0x3c,
0x66, 0x33, 0x32, 0x3e, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x76, 0x5f,
0x31, 0x33, 0x3a, 0x20, 0x76, 0x65, 0x63, 0x34, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x3b, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x76, 0x5f, 0x31, 0x34, 0x3a, 0x20, 0x76, 0x65, 0x63,
0x33, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20,
0x76, 0x5f, 0x31, 0x35, 0x3a, 0x20, 0x76, 0x65, 0x63, 0x34, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x3b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x76, 0x5f, 0x31, 0x36, 0x3a, 0x20, 0x76,
0x65, 0x63, 0x33, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61,
0x72, 0x20, 0x76, 0x5f, 0x31, 0x37, 0x3a, 0x20, 0x76, 0x65, 0x63, 0x34, 0x3c, 0x66, 0x33, 0x32,
0x3e, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x76, 0x2e, 0x74, 0x65, 0x78,
0x74, 0x75, 0x72, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x20, 0x3d, 0x3d, 0x20, 0x30, 0x2e, 0x30,
0x66, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x39,
0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x34, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x31, 0x2e, 0x30,
0x66, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x20, 0x69,
0x66, 0x20, 0x28, 0x76, 0x2e, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x74, 0x79, 0x70,
0x65, 0x20, 0x3d, 0x3d, 0x20, 0x33, 0x2e, 0x30, 0x66, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x39, 0x20, 0x3d, 0x20, 0x74, 0x65, 0x78, 0x74, 0x75,
0x72, 0x65, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x28, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65,
0x30, 0x2c, 0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x30, 0x2c, 0x20, 0x76, 0x5f, 0x33,
0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x20, 0x69, 0x66,
0x20, 0x28, 0x76, 0x2e, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65,
0x20, 0x3d, 0x3d, 0x20, 0x34, 0x2e, 0x30, 0x66, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x31, 0x38, 0x20, 0x3d, 0x20, 0x63,
0x6c, 0x61, 0x6d, 0x70, 0x28, 0x28, 0x66, 0x77, 0x69, 0x64, 0x74, 0x68, 0x28, 0x76, 0x5f, 0x33,
0x29, 0x20, 0x2a, 0x20, 0x76, 0x2e, 0x74, 0x65, 0x78, 0x65, 0x6c, 0x5f, 0x73, 0x69, 0x7a, 0x65,
0x2e, 0x7a, 0x77, 0x29, 0x2c, 0x20, 0x76, 0x65, 0x63, 0x32, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28,
0x30, 0x2e, 0x30, 0x30, 0x30, 0x30, 0x30, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x37, 0x34,
0x37, 0x33, 0x37, 0x38, 0x37, 0x35, 0x66, 0x29, 0x2c, 0x20, 0x76, 0x65, 0x63, 0x32, 0x3c, 0x66,
0x33, 0x32, 0x3e, 0x28, 0x31, 0x2e, 0x30, 0x66, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x31, 0x39, 0x20, 0x3d, 0x20, 0x28,
0x28, 0x76, 0x5f, 0x33, 0x20, 0x2a, 0x20, 0x76, 0x2e, 0x74, 0x65, 0x78, 0x65, 0x6c, 0x5f, 0x73,
0x69, 0x7a, 0x65, 0x2e, 0x7a, 0x77, 0x29, 0x20, 0x2d, 0x20, 0x28, 0x76, 0x5f, 0x31, 0x38, 0x20,
0x2a, 0x20, 0x30, 0x2e, 0x35, 0x66, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x32, 0x30, 0x20, 0x3d, 0x20, 0x73, 0x6d, 0x6f,
0x6f, 0x74, 0x68, 0x73, 0x74, 0x65, 0x70, 0x28, 0x28, 0x76, 0x65, 0x63, 0x32, 0x3c, 0x66, 0x33,
0x32, 0x3e, 0x28, 0x31, 0x2e, 0x30, 0x66, 0x29, 0x20, 0x2d, 0x20, 0x76, 0x5f, 0x31, 0x38, 0x29,
0x2c, 0x20, 0x76, 0x65, 0x63, 0x32, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x31, 0x2e, 0x30, 0x66,
0x29, 0x2c, 0x20, 0x66, 0x72, 0x61, 0x63, 0x74, 0x28, 0x76, 0x5f, 0x31, 0x39, 0x29, 0x29, 0x3b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x32,
0x31, 0x20, 0x3d, 0x20, 0x28, 0x28, 0x28, 0x66, 0x6c, 0x6f, 0x6f, 0x72, 0x28, 0x76, 0x5f, 0x31,
0x39, 0x29, 0x20, 0x2b, 0x20, 0x76, 0x65, 0x63, 0x32, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x30,
0x2e, 0x35, 0x66, 0x29, 0x29, 0x20, 0x2b, 0x20, 0x76, 0x5f, 0x32, 0x30, 0x29, 0x20, 0x2a, 0x20,
0x76, 0x2e, 0x74, 0x65, 0x78, 0x65, 0x6c, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x2e, 0x78, 0x79, 0x29,
0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x39, 0x20, 0x3d, 0x20,
0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x47, 0x72, 0x61,
0x64, 0x28, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x30, 0x2c, 0x20, 0x73, 0x61, 0x6d, 0x70,
0x6c, 0x65, 0x72, 0x30, 0x2c, 0x20, 0x76, 0x5f, 0x32, 0x31, 0x2c, 0x20, 0x64, 0x70, 0x64, 0x78,
0x28, 0x76, 0x5f, 0x33, 0x29, 0x2c, 0x20, 0x64, 0x70, 0x64, 0x79, 0x28, 0x76, 0x5f, 0x33, 0x29,
0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x20, 0x69, 0x66,
0x20, 0x28, 0x76, 0x2e, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65,
0x20, 0x3d, 0x3d, 0x20, 0x31, 0x2e, 0x30, 0x66, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x32, 0x32, 0x20, 0x3d, 0x20, 0x74,
0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x28, 0x74, 0x65, 0x78,
0x74, 0x75, 0x72, 0x65, 0x30, 0x2c, 0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x30, 0x2c,
0x20, 0x76, 0x5f, 0x33, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76,
0x5f, 0x39, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x34, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x76,
0x5f, 0x32, 0x32, 0x2e, 0x78, 0x2c, 0x20, 0x76, 0x5f, 0x32, 0x32, 0x2e, 0x79, 0x2c, 0x20, 0x76,
0x5f, 0x32, 0x32, 0x2e, 0x7a, 0x2c, 0x20, 0x31, 0x2e, 0x30, 0x66, 0x29, 0x3b, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x7d, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x20, 0x69, 0x66, 0x20, 0x28, 0x76, 0x2e, 0x74,
0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x20, 0x3d, 0x3d, 0x20, 0x32,
0x2e, 0x30, 0x66, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c,
0x65, 0x74, 0x20, 0x76, 0x5f, 0x32, 0x33, 0x20, 0x3d, 0x20, 0x63, 0x6c, 0x61, 0x6d, 0x70, 0x28,
0x28, 0x66, 0x77, 0x69, 0x64, 0x74, 0x68, 0x28, 0x76, 0x5f, 0x33, 0x29, 0x20, 0x2a, 0x20, 0x76,
0x2e, 0x74, 0x65, 0x78, 0x65, 0x6c, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x2e, 0x7a, 0x77, 0x29, 0x2c,
0x20, 0x76, 0x65, 0x63, 0x32, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x30, 0x2e, 0x30, 0x30, 0x30,
0x30, 0x30, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x37, 0x34, 0x37, 0x33, 0x37, 0x38, 0x37,
0x35, 0x66, 0x29, 0x2c, 0x20, 0x76, 0x65, 0x63, 0x32, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x31,
0x2e, 0x30, 0x66, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c,
0x65, 0x74, 0x20, 0x76, 0x5f, 0x32, 0x34, 0x20, 0x3d, 0x20, 0x28, 0x28, 0x76, 0x5f, 0x33, 0x20,
0x2a, 0x20, 0x76, 0x2e, 0x74, 0x65, 0x78, 0x65, 0x6c, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x2e, 0x7a,
0x77, 0x29, 0x20, 0x2d, 0x20, 0x28, 0x76, 0x5f, 0x32, 0x33, 0x20, 0x2a, 0x20, 0x30, 0x2e, 0x35,
0x66, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74,
0x20, 0x76, 0x5f, 0x32, 0x35, 0x20, 0x3d, 0x20, 0x73, 0x6d, 0x6f, 0x6f, 0x74, 0x68, 0x73, 0x74,
0x65, 0x70, 0x28, 0x28, 0x76, 0x65, 0x63, 0x32, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x31, 0x2e,
0x30, 0x66, 0x29, 0x20, 0x2d, 0x20, 0x76, 0x5f, 0x32, 0x33, 0x29, 0x2c, 0x20, 0x76, 0x65, 0x63,
0x32, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x31, 0x2e, 0x30, 0x66, 0x29, 0x2c, 0x20, 0x66, 0x72,
0x61, 0x63, 0x74, 0x28, 0x76, 0x5f, 0x32, 0x34, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x32, 0x36, 0x20, 0x3d, 0x20, 0x28,
0x28, 0x28, 0x66, 0x6c, 0x6f, 0x6f, 0x72, 0x28, 0x76, 0x5f, 0x32, 0x34, 0x29, 0x20, 0x2b, 0x20,
0x76, 0x65, 0x63, 0x32, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x30, 0x2e, 0x35, 0x66, 0x29, 0x29,
0x20, 0x2b, 0x20, 0x76, 0x5f, 0x32, 0x35, 0x29, 0x20, 0x2a, 0x20, 0x76, 0x2e, 0x74, 0x65, 0x78,
0x65, 0x6c, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x2e, 0x78, 0x79, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x32, 0x37, 0x20, 0x3d, 0x20,
0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x47, 0x72, 0x61,
0x64, 0x28, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x30, 0x2c, 0x20, 0x73, 0x61, 0x6d, 0x70,
0x6c, 0x65, 0x72, 0x30, 0x2c, 0x20, 0x76, 0x5f, 0x32, 0x36, 0x2c, 0x20, 0x64, 0x70, 0x64, 0x78,
0x28, 0x76, 0x5f, 0x33, 0x29, 0x2c, 0x20, 0x64, 0x70, 0x64, 0x79, 0x28, 0x76, 0x5f, 0x33, 0x29,
0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x39, 0x20, 0x3d,
0x20, 0x76, 0x65, 0x63, 0x34, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x76, 0x5f, 0x32, 0x37, 0x2e,
0x78, 0x2c, 0x20, 0x76, 0x5f, 0x32, 0x37, 0x2e, 0x79, 0x2c, 0x20, 0x76, 0x5f, 0x32, 0x37, 0x2e,
0x7a, 0x2c, 0x20, 0x31, 0x2e, 0x30, 0x66, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x20,
0x65, 0x6c, 0x73, 0x65, 0x20, 0x69, 0x66, 0x20, 0x28, 0x76, 0x2e, 0x74, 0x65, 0x78, 0x74, 0x75,
0x72, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x20, 0x3d, 0x3d, 0x20, 0x35, 0x2e, 0x30, 0x66, 0x29,
0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76,
0x5f, 0x32, 0x38, 0x20, 0x3d, 0x20, 0x28, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x53, 0x61,
0x6d, 0x70, 0x6c, 0x65, 0x28, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x30, 0x2c, 0x20, 0x73,
0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x30, 0x2c, 0x20, 0x76, 0x5f, 0x33, 0x29, 0x2e, 0x78, 0x20,
0x2a, 0x20, 0x32, 0x35, 0x35, 0x2e, 0x30, 0x66, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x76, 0x5f, 0x39, 0x20, 0x3d, 0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65,
0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x28, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x31, 0x2c,
0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x31, 0x2c, 0x20, 0x76, 0x65, 0x63, 0x32, 0x3c,
0x66, 0x33, 0x32, 0x3e, 0x28, 0x28, 0x28, 0x76, 0x5f, 0x32, 0x38, 0x20, 0x2b, 0x20, 0x30, 0x2e,
0x35, 0x66, 0x29, 0x20, 0x2a, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x33, 0x39, 0x30, 0x36, 0x32, 0x35,
0x66, 0x29, 0x2c, 0x20, 0x30, 0x2e, 0x35, 0x66, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x7d, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x20, 0x69, 0x66, 0x20, 0x28, 0x76, 0x2e, 0x74, 0x65, 0x78,
0x74, 0x75, 0x72, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x20, 0x3d, 0x3d, 0x20, 0x36, 0x2e, 0x30,
0x66, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74,
0x20, 0x76, 0x5f, 0x32, 0x39, 0x20, 0x3d, 0x20, 0x28, 0x28, 0x76, 0x5f, 0x33, 0x20, 0x2a, 0x20,
0x76, 0x2e, 0x74, 0x65, 0x78, 0x65, 0x6c, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x2e, 0x7a, 0x77, 0x29,
0x20, 0x2b, 0x20, 0x76, 0x65, 0x63, 0x32, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x30, 0x2e, 0x35,
0x66, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74,
0x20, 0x76, 0x5f, 0x33, 0x30, 0x20, 0x3d, 0x20, 0x28, 0x28, 0x66, 0x6c, 0x6f, 0x6f, 0x72, 0x28,
0x76, 0x5f, 0x32, 0x39, 0x29, 0x20, 0x2d, 0x20, 0x76, 0x65, 0x63, 0x32, 0x3c, 0x66, 0x33, 0x32,
0x3e, 0x28, 0x30, 0x2e, 0x35, 0x66, 0x29, 0x29, 0x20, 0x2a, 0x20, 0x76, 0x2e, 0x74, 0x65, 0x78,
0x65, 0x6c, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x2e, 0x78, 0x79, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x33, 0x31, 0x20, 0x3d, 0x20,
0x28, 0x28, 0x66, 0x6c, 0x6f, 0x6f, 0x72, 0x28, 0x76, 0x5f, 0x32, 0x39, 0x29, 0x20, 0x2b, 0x20,
0x76, 0x65, 0x63, 0x32, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x30, 0x2e, 0x35, 0x66, 0x29, 0x29,
0x20, 0x2a, 0x20, 0x76, 0x2e, 0x74, 0x65, 0x78, 0x65, 0x6c, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x2e,
0x78, 0x79, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74,
0x20, 0x76, 0x5f, 0x33, 0x32, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x34, 0x3c, 0x66, 0x33, 0x32,
0x3e, 0x28, 0x76, 0x5f, 0x33, 0x30, 0x2e, 0x78, 0x2c, 0x20, 0x76, 0x5f, 0x33, 0x30, 0x2e, 0x79,
0x2c, 0x20, 0x76, 0x5f, 0x33, 0x31, 0x2e, 0x78, 0x2c, 0x20, 0x76, 0x5f, 0x33, 0x31, 0x2e, 0x79,
0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x38, 0x20, 0x3d,
0x20, 0x66, 0x72, 0x61, 0x63, 0x74, 0x28, 0x76, 0x5f, 0x32, 0x39, 0x29, 0x3b, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x33, 0x33, 0x20, 0x3d,
0x20, 0x28, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x28,
0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x30, 0x2c, 0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65,
0x72, 0x30, 0x2c, 0x20, 0x76, 0x5f, 0x33, 0x32, 0x2e, 0x78, 0x79, 0x29, 0x2e, 0x78, 0x20, 0x2a,
0x20, 0x32, 0x35, 0x35, 0x2e, 0x30, 0x66, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x33, 0x34, 0x20, 0x3d, 0x20, 0x74, 0x65, 0x78,
0x74, 0x75, 0x72, 0x65, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x28, 0x74, 0x65, 0x78, 0x74, 0x75,
0x72, 0x65, 0x31, 0x2c, 0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x31, 0x2c, 0x20, 0x76,
0x65, 0x63, 0x32, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x28, 0x28, 0x76, 0x5f, 0x33, 0x33, 0x20,
0x2b, 0x20, 0x30, 0x2e, 0x35, 0x66, 0x29, 0x20, 0x2a, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x33, 0x39,
0x30, 0x36, 0x32, 0x35, 0x66, 0x29, 0x2c, 0x20, 0x30, 0x2e, 0x35, 0x66, 0x29, 0x29, 0x3b, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x33, 0x35,
0x20, 0x3d, 0x20, 0x28, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x53, 0x61, 0x6d, 0x70, 0x6c,
0x65, 0x28, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x30, 0x2c, 0x20, 0x73, 0x61, 0x6d, 0x70,
0x6c, 0x65, 0x72, 0x30, 0x2c, 0x20, 0x76, 0x5f, 0x33, 0x32, 0x2e, 0x78, 0x77, 0x29, 0x2e, 0x78,
0x20, 0x2a, 0x20, 0x32, 0x35, 0x35, 0x2e, 0x30, 0x66, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x33, 0x36, 0x20, 0x3d, 0x20, 0x74,
0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x28, 0x74, 0x65, 0x78,
0x74, 0x75, 0x72, 0x65, 0x31, 0x2c, 0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x31, 0x2c,
0x20, 0x76, 0x65, 0x63, 0x32, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x28, 0x28, 0x76, 0x5f, 0x33,
0x35, 0x20, 0x2b, 0x20, 0x30, 0x2e, 0x35, 0x66, 0x29, 0x20, 0x2a, 0x20, 0x30, 0x2e, 0x30, 0x30,
0x33, 0x39, 0x30, 0x36, 0x32, 0x35, 0x66, 0x29, 0x2c, 0x20, 0x30, 0x2e, 0x35, 0x66, 0x29, 0x29,
0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f,
0x33, 0x37, 0x20, 0x3d, 0x20, 0x28, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x53, 0x61, 0x6d,
0x70, 0x6c, 0x65, 0x28, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x30, 0x2c, 0x20, 0x73, 0x61,
0x6d, 0x70, 0x6c, 0x65, 0x72, 0x30, 0x2c, 0x20, 0x76, 0x5f, 0x33, 0x32, 0x2e, 0x7a, 0x79, 0x29,
0x2e, 0x78, 0x20, 0x2a, 0x20, 0x32, 0x35, 0x35, 0x2e, 0x30, 0x66, 0x29, 0x3b, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x33, 0x38, 0x20, 0x3d,
0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x28, 0x74,
0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x31, 0x2c, 0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72,
0x31, 0x2c, 0x20, 0x76, 0x65, 0x63, 0x32, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x28, 0x28, 0x76,
0x5f, 0x33, 0x37, 0x20, 0x2b, 0x20, 0x30, 0x2e, 0x35, 0x66, 0x29, 0x20, 0x2a, 0x20, 0x30, 0x2e,
0x30, 0x30, 0x33, 0x39, 0x30, 0x36, 0x32, 0x35, 0x66, 0x29, 0x2c, 0x20, 0x30, 0x2e, 0x35, 0x66,
0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20,
0x76, 0x5f, 0x33, 0x39, 0x20, 0x3d, 0x20, 0x28, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x53,
0x61, 0x6d, 0x70, 0x6c, 0x65, 0x28, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x30, 0x2c, 0x20,
0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x30, 0x2c, 0x20, 0x76, 0x5f, 0x33, 0x32, 0x2e, 0x7a,
0x77, 0x29, 0x2e, 0x78, 0x20, 0x2a, 0x20, 0x32, 0x35, 0x35, 0x2e, 0x30, 0x66, 0x29, 0x3b, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x34, 0x30,
0x20, 0x3d, 0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65,
0x28, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x31, 0x2c, 0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c,
0x65, 0x72, 0x31, 0x2c, 0x20, 0x76, 0x65, 0x63, 0x32, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x28,
0x28, 0x76, 0x5f, 0x33, 0x39, 0x20, 0x2b, 0x20, 0x30, 0x2e, 0x35, 0x66, 0x29, 0x20, 0x2a, 0x20,
0x30, 0x2e, 0x30, 0x30, 0x33, 0x39, 0x30, 0x36, 0x32, 0x35, 0x66, 0x29, 0x2c, 0x20, 0x30, 0x2e,
0x35, 0x66, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65,
0x74, 0x20, 0x76, 0x5f, 0x34, 0x31, 0x20, 0x3d, 0x20, 0x76, 0x5f, 0x38, 0x2e, 0x79, 0x3b, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x34, 0x32,
0x20, 0x3d, 0x20, 0x6d, 0x69, 0x78, 0x28, 0x76, 0x5f, 0x33, 0x34, 0x2c, 0x20, 0x76, 0x5f, 0x33,
0x36, 0x2c, 0x20, 0x76, 0x65, 0x63, 0x34, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x76, 0x5f, 0x34,
0x31, 0x2c, 0x20, 0x76, 0x5f, 0x34, 0x31, 0x2c, 0x20, 0x76, 0x5f, 0x34, 0x31, 0x2c, 0x20, 0x76,
0x5f, 0x34, 0x31, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c,
0x65, 0x74, 0x20, 0x76, 0x5f, 0x34, 0x33, 0x20, 0x3d, 0x20, 0x76, 0x5f, 0x38, 0x2e, 0x79, 0x3b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x34,
0x34, 0x20, 0x3d, 0x20, 0x6d, 0x69, 0x78, 0x28, 0x76, 0x5f, 0x33, 0x38, 0x2c, 0x20, 0x76, 0x5f,
0x34, 0x30, 0x2c, 0x20, 0x76, 0x65, 0x63, 0x34, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x76, 0x5f,
0x34, 0x33, 0x2c, 0x20, 0x76, 0x5f, 0x34, 0x33, 0x2c, 0x20, 0x76, 0x5f, 0x34, 0x33, 0x2c, 0x20,
0x76, 0x5f, 0x34, 0x33, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x34, 0x35, 0x20, 0x3d, 0x20, 0x76, 0x5f, 0x38, 0x2e, 0x78,
0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x39, 0x20, 0x3d, 0x20,
0x6d, 0x69, 0x78, 0x28, 0x76, 0x5f, 0x34, 0x32, 0x2c, 0x20, 0x76, 0x5f, 0x34, 0x34, 0x2c, 0x20,
0x76, 0x65, 0x63, 0x34, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x76, 0x5f, 0x34, 0x35, 0x2c, 0x20,
0x76, 0x5f, 0x34, 0x35, 0x2c, 0x20, 0x76, 0x5f, 0x34, 0x35, 0x2c, 0x20, 0x76, 0x5f, 0x34, 0x35,
0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x20, 0x69,
0x66, 0x20, 0x28, 0x76, 0x2e, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x74, 0x79, 0x70,
0x65, 0x20, 0x3d, 0x3d, 0x20, 0x37, 0x2e, 0x30, 0x66, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x34, 0x36, 0x20, 0x3d, 0x20,
0x63, 0x6c, 0x61, 0x6d, 0x70, 0x28, 0x28, 0x66, 0x77, 0x69, 0x64, 0x74, 0x68, 0x28, 0x76, 0x5f,
0x33, 0x29, 0x20, 0x2a, 0x20, 0x76, 0x2e, 0x74, 0x65, 0x78, 0x65, 0x6c, 0x5f, 0x73, 0x69, 0x7a,
0x65, 0x2e, 0x7a, 0x77, 0x29, 0x2c, 0x20, 0x76, 0x65, 0x63, 0x32, 0x3c, 0x66, 0x33, 0x32, 0x3e,
0x28, 0x30, 0x2e, 0x30, 0x30, 0x30, 0x30, 0x30, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x37,
0x34, 0x37, 0x33, 0x37, 0x38, 0x37, 0x35, 0x66, 0x29, 0x2c, 0x20, 0x76, 0x65, 0x63, 0x32, 0x3c,
0x66, 0x33, 0x32, 0x3e, 0x28, 0x31, 0x2e, 0x30, 0x66, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x34, 0x37, 0x20, 0x3d, 0x20,
0x28, 0x28, 0x76, 0x5f, 0x33, 0x20, 0x2a, 0x20, 0x76, 0x2e, 0x74, 0x65, 0x78, 0x65, 0x6c, 0x5f,
0x73, 0x69, 0x7a, 0x65, 0x2e, 0x7a, 0x77, 0x29, 0x20, 0x2d, 0x20, 0x28, 0x76, 0x5f, 0x34, 0x36,
0x20, 0x2a, 0x20, 0x30, 0x2e, 0x35, 0x66, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x34, 0x38, 0x20, 0x3d, 0x20, 0x73, 0x6d,
0x6f, 0x6f, 0x74, 0x68, 0x73, 0x74, 0x65, 0x70, 0x28, 0x28, 0x76, 0x65, 0x63, 0x32, 0x3c, 0x66,
0x33, 0x32, 0x3e, 0x28, 0x31, 0x2e, 0x30, 0x66, 0x29, 0x20, 0x2d, 0x20, 0x76, 0x5f, 0x34, 0x36,
0x29, 0x2c, 0x20, 0x76, 0x65, 0x63, 0x32, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x31, 0x2e, 0x30,
0x66, 0x29, 0x2c, 0x20, 0x66, 0x72, 0x61, 0x63, 0x74, 0x28, 0x76, 0x5f, 0x34, 0x37, 0x29, 0x29,
0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f,
0x34, 0x39, 0x20, 0x3d, 0x20, 0x28, 0x28, 0x28, 0x28, 0x28, 0x66, 0x6c, 0x6f, 0x6f, 0x72, 0x28,
0x76, 0x5f, 0x34, 0x37, 0x29, 0x20, 0x2b, 0x20, 0x76, 0x65, 0x63, 0x32, 0x3c, 0x66, 0x33, 0x32,
0x3e, 0x28, 0x30, 0x2e, 0x35, 0x66, 0x29, 0x29, 0x20, 0x2b, 0x20, 0x76, 0x5f, 0x34, 0x38, 0x29,
0x20, 0x2a, 0x20, 0x76, 0x2e, 0x74, 0x65, 0x78, 0x65, 0x6c, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x2e,
0x78, 0x79, 0x29, 0x20, 0x2a, 0x20, 0x76, 0x2e, 0x74, 0x65, 0x78, 0x65, 0x6c, 0x5f, 0x73, 0x69,
0x7a, 0x65, 0x2e, 0x7a, 0x77, 0x29, 0x20, 0x2b, 0x20, 0x76, 0x65, 0x63, 0x32, 0x3c, 0x66, 0x33,
0x32, 0x3e, 0x28, 0x30, 0x2e, 0x35, 0x66, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x35, 0x30, 0x20, 0x3d, 0x20, 0x28, 0x28,
0x66, 0x6c, 0x6f, 0x6f, 0x72, 0x28, 0x76, 0x5f, 0x34, 0x39, 0x29, 0x20, 0x2d, 0x20, 0x76, 0x65,
0x63, 0x32, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x30, 0x2e, 0x35, 0x66, 0x29, 0x29, 0x20, 0x2a,
0x20, 0x76, 0x2e, 0x74, 0x65, 0x78, 0x65, 0x6c, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x2e, 0x78, 0x79,
0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76,
0x5f, 0x35, 0x31, 0x20, 0x3d, 0x20, 0x28, 0x28, 0x66, 0x6c, 0x6f, 0x6f, 0x72, 0x28, 0x76, 0x5f,
0x34, 0x39, 0x29, 0x20, 0x2b, 0x20, 0x76, 0x65, 0x63, 0x32, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28,
0x30, 0x2e, 0x35, 0x66, 0x29, 0x29, 0x20, 0x2a, 0x20, 0x76, 0x2e, 0x74, 0x65, 0x78, 0x65, 0x6c,
0x5f, 0x73, 0x69, 0x7a, 0x65, 0x2e, 0x78, 0x79, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x35, 0x32, 0x20, 0x3d, 0x20, 0x76, 0x65,
0x63, 0x34, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x76, 0x5f, 0x35, 0x30, 0x2e, 0x78, 0x2c, 0x20,
0x76, 0x5f, 0x35, 0x30, 0x2e, 0x79, 0x2c, 0x20, 0x76, 0x5f, 0x35, 0x31, 0x2e, 0x78, 0x2c, 0x20,
0x76, 0x5f, 0x35, 0x31, 0x2e, 0x79, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x76, 0x5f, 0x37, 0x20, 0x3d, 0x20, 0x66, 0x72, 0x61, 0x63, 0x74, 0x28, 0x76, 0x5f, 0x34,
0x39, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20,
0x76, 0x5f, 0x35, 0x33, 0x20, 0x3d, 0x20, 0x28, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x53,
0x61, 0x6d, 0x70, 0x6c, 0x65, 0x28, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x30, 0x2c, 0x20,
0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x30, 0x2c, 0x20, 0x76, 0x5f, 0x35, 0x32, 0x2e, 0x78,
0x79, 0x29, 0x2e, 0x78, 0x20, 0x2a, 0x20, 0x32, 0x35, 0x35, 0x2e, 0x30, 0x66, 0x29, 0x3b, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x35, 0x34,
0x20, 0x3d, 0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65,
0x28, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x31, 0x2c, 0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c,
0x65, 0x72, 0x31, 0x2c, 0x20, 0x76, 0x65, 0x63, 0x32, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x28,
0x28, 0x76, 0x5f, 0x35, 0x33, 0x20, 0x2b, 0x20, 0x30, 0x2e, 0x35, 0x66, 0x29, 0x20, 0x2a, 0x20,
0x30, 0x2e, 0x30, 0x30, 0x33, 0x39, 0x30, 0x36, 0x32, 0x35, 0x66, 0x29, 0x2c, 0x20, 0x30, 0x2e,
0x35, 0x66, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65,
0x74, 0x20, 0x76, 0x5f, 0x35, 0x35, 0x20, 0x3d, 0x20, 0x28, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72,
0x65, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x28, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x30,
0x2c, 0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x30, 0x2c, 0x20, 0x76, 0x5f, 0x35, 0x32,
0x2e, 0x78, 0x77, 0x29, 0x2e, 0x78, 0x20, 0x2a, 0x20, 0x32, 0x35, 0x35, 0x2e, 0x30, 0x66, 0x29,
0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f,
0x35, 0x36, 0x20, 0x3d, 0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x53, 0x61, 0x6d, 0x70,
0x6c, 0x65, 0x28, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x31, 0x2c, 0x20, 0x73, 0x61, 0x6d,
0x70, 0x6c, 0x65, 0x72, 0x31, 0x2c, 0x20, 0x76, 0x65, 0x63, 0x32, 0x3c, 0x66, 0x33, 0x32, 0x3e,
0x28, 0x28, 0x28, 0x76, 0x5f, 0x35, 0x35, 0x20, 0x2b, 0x20, 0x30, 0x2e, 0x35, 0x66, 0x29, 0x20,
0x2a, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x33, 0x39, 0x30, 0x36, 0x32, 0x35, 0x66, 0x29, 0x2c, 0x20,
0x30, 0x2e, 0x35, 0x66, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x35, 0x37, 0x20, 0x3d, 0x20, 0x28, 0x74, 0x65, 0x78, 0x74,
0x75, 0x72, 0x65, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x28, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72,
0x65, 0x30, 0x2c, 0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x30, 0x2c, 0x20, 0x76, 0x5f,
0x35, 0x32, 0x2e, 0x7a, 0x79, 0x29, 0x2e, 0x78, 0x20, 0x2a, 0x20, 0x32, 0x35, 0x35, 0x2e, 0x30,
0x66, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20,
0x76, 0x5f, 0x35, 0x38, 0x20, 0x3d, 0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x53, 0x61,
0x6d, 0x70, 0x6c, 0x65, 0x28, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x31, 0x2c, 0x20, 0x73,
0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x31, 0x2c, 0x20, 0x76, 0x65, 0x63, 0x32, 0x3c, 0x66, 0x33,
0x32, 0x3e, 0x28, 0x28, 0x28, 0x76, 0x5f, 0x35, 0x37, 0x20, 0x2b, 0x20, 0x30, 0x2e, 0x35, 0x66,
0x29, 0x20, 0x2a, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x33, 0x39, 0x30, 0x36, 0x32, 0x35, 0x66, 0x29,
0x2c, 0x20, 0x30, 0x2e, 0x35, 0x66, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x35, 0x39, 0x20, 0x3d, 0x20, 0x28, 0x74, 0x65,
0x78, 0x74, 0x75, 0x72, 0x65, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x28, 0x74, 0x65, 0x78, 0x74,
0x75, 0x72, 0x65, 0x30, 0x2c, 0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x30, 0x2c, 0x20,
0x76, 0x5f, 0x35, 0x32, 0x2e, 0x7a, 0x77, 0x29, 0x2e, 0x78, 0x20, 0x2a, 0x20, 0x32, 0x35, 0x35,
0x2e, 0x30, 0x66, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65,
0x74, 0x20, 0x76, 0x5f, 0x36, 0x30, 0x20, 0x3d, 0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65,
0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x28, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x31, 0x2c,
0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x31, 0x2c, 0x20, 0x76, 0x65, 0x63, 0x32, 0x3c,
0x66, 0x33, 0x32, 0x3e, 0x28, 0x28, 0x28, 0x76, 0x5f, 0x35, 0x39, 0x20, 0x2b, 0x20, 0x30, 0x2e,
0x35, 0x66, 0x29, 0x20, 0x2a, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x33, 0x39, 0x30, 0x36, 0x32, 0x35,
0x66, 0x29, 0x2c, 0x20, 0x30, 0x2e, 0x35, 0x66, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x36, 0x31, 0x20, 0x3d, 0x20, 0x76,
0x5f, 0x37, 0x2e, 0x79, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65,
0x74, 0x20, 0x76, 0x5f, 0x36, 0x32, 0x20, 0x3d, 0x20, 0x6d, 0x69, 0x78, 0x28, 0x76, 0x5f, 0x35,
0x34, 0x2c, 0x20, 0x76, 0x5f, 0x35, 0x36, 0x2c, 0x20, 0x76, 0x65, 0x63, 0x34, 0x3c, 0x66, 0x33,
0x32, 0x3e, 0x28, 0x76, 0x5f, 0x36, 0x31, 0x2c, 0x20, 0x76, 0x5f, 0x36, 0x31, 0x2c, 0x20, 0x76,
0x5f, 0x36, 0x31, 0x2c, 0x20, 0x76, 0x5f, 0x36, 0x31, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x36, 0x33, 0x20, 0x3d, 0x20,
0x76, 0x5f, 0x37, 0x2e, 0x79, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c,
0x65, 0x74, 0x20, 0x76, 0x5f, 0x36, 0x34, 0x20, 0x3d, 0x20, 0x6d, 0x69, 0x78, 0x28, 0x76, 0x5f,
0x35, 0x38, 0x2c, 0x20, 0x76, 0x5f, 0x36, 0x30, 0x2c, 0x20, 0x76, 0x65, 0x63, 0x34, 0x3c, 0x66,
0x33, 0x32, 0x3e, 0x28, 0x76, 0x5f, 0x36, 0x33, 0x2c, 0x20, 0x76, 0x5f, 0x36, 0x33, 0x2c, 0x20,
0x76, 0x5f, 0x36, 0x33, 0x2c, 0x20, 0x76, 0x5f, 0x36, 0x33, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x36, 0x35, 0x20, 0x3d,
0x20, 0x76, 0x5f, 0x37, 0x2e, 0x78, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x76, 0x5f, 0x39, 0x20, 0x3d, 0x20, 0x6d, 0x69, 0x78, 0x28, 0x76, 0x5f, 0x36, 0x32, 0x2c, 0x20,
0x76, 0x5f, 0x36, 0x34, 0x2c, 0x20, 0x76, 0x65, 0x63, 0x34, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28,
0x76, 0x5f, 0x36, 0x35, 0x2c, 0x20, 0x76, 0x5f, 0x36, 0x35, 0x2c, 0x20, 0x76, 0x5f, 0x36, 0x35,
0x2c, 0x20, 0x76, 0x5f, 0x36, 0x35, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x20,
0x65, 0x6c, 0x73, 0x65, 0x20, 0x69, 0x66, 0x20, 0x28, 0x76, 0x2e, 0x74, 0x65, 0x78, 0x74, 0x75,
0x72, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x20, 0x3d, 0x3d, 0x20, 0x38, 0x2e, 0x30, 0x66, 0x29,
0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x31, 0x30, 0x2e,
0x78, 0x20, 0x3d, 0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x53, 0x61, 0x6d, 0x70, 0x6c,
0x65, 0x28, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x30, 0x2c, 0x20, 0x73, 0x61, 0x6d, 0x70,
0x6c, 0x65, 0x72, 0x30, 0x2c, 0x20, 0x76, 0x5f, 0x33, 0x29, 0x2e, 0x78, 0x3b, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x36, 0x36, 0x20, 0x3d,
0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x28, 0x74,
0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x31, 0x2c, 0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72,
0x30, 0x2c, 0x20, 0x76, 0x5f, 0x33, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x76, 0x5f, 0x31, 0x30, 0x2e, 0x79, 0x20, 0x3d, 0x20, 0x76, 0x5f, 0x36, 0x36, 0x2e, 0x78,
0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x31, 0x30, 0x2e, 0x7a,
0x20, 0x3d, 0x20, 0x76, 0x5f, 0x36, 0x36, 0x2e, 0x79, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x36, 0x37, 0x20, 0x3d, 0x20, 0x76, 0x2e,
0x59, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x2e, 0x78, 0x79, 0x7a, 0x3b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x36, 0x38, 0x20, 0x3d, 0x20,
0x28, 0x76, 0x5f, 0x31, 0x30, 0x20, 0x2b, 0x20, 0x76, 0x5f, 0x36, 0x37, 0x29, 0x3b, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x31, 0x30, 0x20, 0x3d, 0x20, 0x76, 0x5f,
0x36, 0x38, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x39, 0x2e,
0x78, 0x20, 0x3d, 0x20, 0x64, 0x6f, 0x74, 0x28, 0x76, 0x5f, 0x36, 0x38, 0x2c, 0x20, 0x76, 0x2e,
0x52, 0x63, 0x6f, 0x65, 0x66, 0x66, 0x2e, 0x78, 0x79, 0x7a, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x39, 0x2e, 0x79, 0x20, 0x3d, 0x20, 0x64, 0x6f, 0x74,
0x28, 0x76, 0x5f, 0x36, 0x38, 0x2c, 0x20, 0x76, 0x2e, 0x47, 0x63, 0x6f, 0x65, 0x66, 0x66, 0x2e,
0x78, 0x79, 0x7a, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f,
0x39, 0x2e, 0x7a, 0x20, 0x3d, 0x20, 0x64, 0x6f, 0x74, 0x28, 0x76, 0x5f, 0x36, 0x38, 0x2c, 0x20,
0x76, 0x2e, 0x42, 0x63, 0x6f, 0x65, 0x66, 0x66, 0x2e, 0x78, 0x79, 0x7a, 0x29, 0x3b, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x39, 0x2e, 0x77, 0x20, 0x3d, 0x20, 0x31,
0x2e, 0x30, 0x66, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x20,
0x69, 0x66, 0x20, 0x28, 0x76, 0x2e, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x74, 0x79,
0x70, 0x65, 0x20, 0x3d, 0x3d, 0x20, 0x39, 0x2e, 0x30, 0x66, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x31, 0x31, 0x2e, 0x78, 0x20, 0x3d, 0x20, 0x74,
0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x28, 0x74, 0x65, 0x78,
0x74, 0x75, 0x72, 0x65, 0x30, 0x2c, 0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x30, 0x2c,
0x20, 0x76, 0x5f, 0x33, 0x29, 0x2e, 0x78, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x36, 0x39, 0x20, 0x3d, 0x20, 0x74, 0x65, 0x78, 0x74,
0x75, 0x72, 0x65, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x28, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72,
0x65, 0x31, 0x2c, 0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x30, 0x2c, 0x20, 0x76, 0x5f,
0x33, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x31, 0x31,
0x2e, 0x79, 0x20, 0x3d, 0x20, 0x76, 0x5f, 0x36, 0x39, 0x2e, 0x79, 0x3b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x31, 0x31, 0x2e, 0x7a, 0x20, 0x3d, 0x20, 0x76, 0x5f,
0x36, 0x39, 0x2e, 0x78, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65,
0x74, 0x20, 0x76, 0x5f, 0x37, 0x30, 0x20, 0x3d, 0x20, 0x76, 0x2e, 0x59, 0x6f, 0x66, 0x66, 0x73,
0x65, 0x74, 0x2e, 0x78, 0x79, 0x7a, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x37, 0x31, 0x20, 0x3d, 0x20, 0x28, 0x76, 0x5f, 0x31, 0x31,
0x20, 0x2b, 0x20, 0x76, 0x5f, 0x37, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x76, 0x5f, 0x31, 0x31, 0x20, 0x3d, 0x20, 0x76, 0x5f, 0x37, 0x31, 0x3b, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x39, 0x2e, 0x78, 0x20, 0x3d, 0x20, 0x64,
0x6f, 0x74, 0x28, 0x76, 0x5f, 0x37, 0x31, 0x2c, 0x20, 0x76, 0x2e, 0x52, 0x63, 0x6f, 0x65, 0x66,
0x66, 0x2e, 0x78, 0x79, 0x7a, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x76, 0x5f, 0x39, 0x2e, 0x79, 0x20, 0x3d, 0x20, 0x64, 0x6f, 0x74, 0x28, 0x76, 0x5f, 0x37, 0x31,
0x2c, 0x20, 0x76, 0x2e, 0x47, 0x63, 0x6f, 0x65, 0x66, 0x66, 0x2e, 0x78, 0x79, 0x7a, 0x29, 0x3b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x39, 0x2e, 0x7a, 0x20, 0x3d,
0x20, 0x64, 0x6f, 0x74, 0x28, 0x76, 0x5f, 0x37, 0x31, 0x2c, 0x20, 0x76, 0x2e, 0x42, 0x63, 0x6f,
0x65, 0x66, 0x66, 0x2e, 0x78, 0x79, 0x7a, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x76, 0x5f, 0x39, 0x2e, 0x77, 0x20, 0x3d, 0x20, 0x31, 0x2e, 0x30, 0x66, 0x3b, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x7d, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x20, 0x69, 0x66, 0x20, 0x28, 0x76,
0x2e, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x20, 0x3d, 0x3d,
0x20, 0x31, 0x30, 0x2e, 0x30, 0x66, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x76, 0x5f, 0x31, 0x32, 0x2e, 0x78, 0x20, 0x3d, 0x20, 0x74, 0x65, 0x78, 0x74, 0x75,
0x72, 0x65, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x28, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65,
0x30, 0x2c, 0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x30, 0x2c, 0x20, 0x76, 0x5f, 0x33,
0x29, 0x2e, 0x78, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x31,
0x32, 0x2e, 0x79, 0x20, 0x3d, 0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x53, 0x61, 0x6d,
0x70, 0x6c, 0x65, 0x28, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x31, 0x2c, 0x20, 0x73, 0x61,
0x6d, 0x70, 0x6c, 0x65, 0x72, 0x30, 0x2c, 0x20, 0x76, 0x5f, 0x33, 0x29, 0x2e, 0x78, 0x3b, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x31, 0x32, 0x2e, 0x7a, 0x20, 0x3d,
0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x28, 0x74,
0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x32, 0x2c, 0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72,
0x30, 0x2c, 0x20, 0x76, 0x5f, 0x33, 0x29, 0x2e, 0x78, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x37, 0x32, 0x20, 0x3d, 0x20, 0x76, 0x2e,
0x59, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x2e, 0x78, 0x79, 0x7a, 0x3b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x37, 0x33, 0x20, 0x3d, 0x20,
0x28, 0x76, 0x5f, 0x31, 0x32, 0x20, 0x2b, 0x20, 0x76, 0x5f, 0x37, 0x32, 0x29, 0x3b, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x31, 0x32, 0x20, 0x3d, 0x20, 0x76, 0x5f,
0x37, 0x33, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x39, 0x2e,
0x78, 0x20, 0x3d, 0x20, 0x64, 0x6f, 0x74, 0x28, 0x76, 0x5f, 0x37, 0x33, 0x2c, 0x20, 0x76, 0x2e,
0x52, 0x63, 0x6f, 0x65, 0x66, 0x66, 0x2e, 0x78, 0x79, 0x7a, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x39, 0x2e, 0x79, 0x20, 0x3d, 0x20, 0x64, 0x6f, 0x74,
0x28, 0x76, 0x5f, 0x37, 0x33, 0x2c, 0x20, 0x76, 0x2e, 0x47, 0x63, 0x6f, 0x65, 0x66, 0x66, 0x2e,
0x78, 0x79, 0x7a, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f,
0x39, 0x2e, 0x7a, 0x20, 0x3d, 0x20, 0x64, 0x6f, 0x74, 0x28, 0x76, 0x5f, 0x37, 0x33, 0x2c, 0x20,
0x76, 0x2e, 0x42, 0x63, 0x6f, 0x65, 0x66, 0x66, 0x2e, 0x78, 0x79, 0x7a, 0x29, 0x3b, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x39, 0x2e, 0x77, 0x20, 0x3d, 0x20, 0x31,
0x2e, 0x30, 0x66, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x20,
0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x39, 0x2e, 0x78, 0x20,
0x3d, 0x20, 0x31, 0x2e, 0x30, 0x66, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x76, 0x5f, 0x39, 0x2e, 0x79, 0x20, 0x3d, 0x20, 0x30, 0x2e, 0x30, 0x66, 0x3b, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x39, 0x2e, 0x7a, 0x20, 0x3d, 0x20, 0x31, 0x2e,
0x30, 0x66, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x39, 0x2e,
0x77, 0x20, 0x3d, 0x20, 0x31, 0x2e, 0x30, 0x66, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x31, 0x33, 0x20, 0x3d, 0x20, 0x76, 0x5f, 0x39, 0x3b, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x76, 0x2e, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x5f,
0x74, 0x79, 0x70, 0x65, 0x20, 0x3d, 0x3d, 0x20, 0x33, 0x2e, 0x30, 0x66, 0x29, 0x20, 0x7b, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x37, 0x34,
0x20, 0x3d, 0x20, 0x76, 0x5f, 0x31, 0x33, 0x2e, 0x78, 0x79, 0x7a, 0x3b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x37, 0x35, 0x20, 0x3d, 0x20,
0x28, 0x70, 0x6f, 0x77, 0x28, 0x61, 0x62, 0x73, 0x28, 0x28, 0x6d, 0x61, 0x78, 0x28, 0x28, 0x70,
0x6f, 0x77, 0x28, 0x61, 0x62, 0x73, 0x28, 0x76, 0x5f, 0x37, 0x34, 0x29, 0x2c, 0x20, 0x76, 0x65,
0x63, 0x33, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x30, 0x2e, 0x30, 0x31, 0x32, 0x36, 0x38, 0x33,
0x33, 0x31, 0x33, 0x33, 0x33, 0x39, 0x39, 0x34, 0x38, 0x36, 0x35, 0x34, 0x31, 0x37, 0x66, 0x29,
0x29, 0x20, 0x2d, 0x20, 0x76, 0x65, 0x63, 0x33, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x30, 0x2e,
0x38, 0x33, 0x35, 0x39, 0x33, 0x37, 0x35, 0x66, 0x29, 0x29, 0x2c, 0x20, 0x76, 0x65, 0x63, 0x33,
0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x29, 0x29, 0x20, 0x2f, 0x20, 0x28, 0x76, 0x65, 0x63, 0x33,
0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x31, 0x38, 0x2e, 0x38, 0x35, 0x31, 0x35, 0x36, 0x32, 0x35,
0x66, 0x29, 0x20, 0x2d, 0x20, 0x28, 0x70, 0x6f, 0x77, 0x28, 0x61, 0x62, 0x73, 0x28, 0x76, 0x5f,
0x37, 0x34, 0x29, 0x2c, 0x20, 0x76, 0x65, 0x63, 0x33, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x30,
0x2e, 0x30, 0x31, 0x32, 0x36, 0x38, 0x33, 0x33, 0x31, 0x33, 0x33, 0x33, 0x39, 0x39, 0x34, 0x38,
0x36, 0x35, 0x34, 0x31, 0x37, 0x66, 0x29, 0x29, 0x20, 0x2a, 0x20, 0x31, 0x38, 0x2e, 0x36, 0x38,
0x37, 0x35, 0x66, 0x29, 0x29, 0x29, 0x29, 0x2c, 0x20, 0x76, 0x65, 0x63, 0x33, 0x3c, 0x66, 0x33,
0x32, 0x3e, 0x28, 0x36, 0x2e, 0x32, 0x37, 0x37, 0x33, 0x39, 0x34, 0x37, 0x37, 0x31, 0x35, 0x37,
0x35, 0x39, 0x32, 0x37, 0x37, 0x33, 0x34, 0x33, 0x38, 0x66, 0x29, 0x29, 0x20, 0x2a, 0x20, 0x31,
0x30, 0x30, 0x30, 0x30, 0x2e, 0x30, 0x66, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x37, 0x36, 0x20, 0x3d, 0x20, 0x76, 0x2e, 0x73,
0x64, 0x72, 0x5f, 0x77, 0x68, 0x69, 0x74, 0x65, 0x5f, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x3b, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x37, 0x37,
0x20, 0x3d, 0x20, 0x28, 0x76, 0x5f, 0x37, 0x35, 0x20, 0x2f, 0x20, 0x76, 0x65, 0x63, 0x33, 0x3c,
0x66, 0x33, 0x32, 0x3e, 0x28, 0x76, 0x5f, 0x37, 0x36, 0x2c, 0x20, 0x76, 0x5f, 0x37, 0x36, 0x2c,
0x20, 0x76, 0x5f, 0x37, 0x36, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x76, 0x5f, 0x31, 0x33, 0x2e, 0x78, 0x20, 0x3d, 0x20, 0x76, 0x5f, 0x37, 0x37, 0x2e, 0x78,
0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x31, 0x33, 0x2e, 0x79,
0x20, 0x3d, 0x20, 0x76, 0x5f, 0x37, 0x37, 0x2e, 0x79, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x76, 0x5f, 0x31, 0x33, 0x2e, 0x7a, 0x20, 0x3d, 0x20, 0x76, 0x5f, 0x37, 0x37,
0x2e, 0x7a, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66,
0x20, 0x21, 0x28, 0x28, 0x76, 0x2e, 0x74, 0x6f, 0x6e, 0x65, 0x6d, 0x61, 0x70, 0x5f, 0x6d, 0x65,
0x74, 0x68, 0x6f, 0x64, 0x20, 0x3d, 0x3d, 0x20, 0x30, 0x2e, 0x30, 0x66, 0x29, 0x29, 0x20, 0x7b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x31, 0x34, 0x20, 0x3d, 0x20,
0x76, 0x5f, 0x31, 0x33, 0x2e, 0x78, 0x79, 0x7a, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x76, 0x2e, 0x74, 0x6f, 0x6e, 0x65, 0x6d, 0x61, 0x70, 0x5f,
0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x20, 0x3d, 0x3d, 0x20, 0x31, 0x2e, 0x30, 0x66, 0x29, 0x20,
0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65,
0x74, 0x20, 0x76, 0x5f, 0x37, 0x38, 0x20, 0x3d, 0x20, 0x76, 0x2e, 0x74, 0x6f, 0x6e, 0x65, 0x6d,
0x61, 0x70, 0x5f, 0x66, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x31, 0x34, 0x20, 0x3d, 0x20, 0x28,
0x76, 0x5f, 0x31, 0x34, 0x20, 0x2a, 0x20, 0x76, 0x5f, 0x37, 0x38, 0x29, 0x3b, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x20, 0x69, 0x66, 0x20,
0x28, 0x76, 0x2e, 0x74, 0x6f, 0x6e, 0x65, 0x6d, 0x61, 0x70, 0x5f, 0x6d, 0x65, 0x74, 0x68, 0x6f,
0x64, 0x20, 0x3d, 0x3d, 0x20, 0x32, 0x2e, 0x30, 0x66, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x76, 0x2e, 0x69,
0x6e, 0x70, 0x75, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x20, 0x3d, 0x3d, 0x20, 0x32, 0x2e, 0x30,
0x66, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x31, 0x34, 0x20, 0x3d, 0x20, 0x28, 0x76, 0x5f, 0x31,
0x34, 0x20, 0x2a, 0x20, 0x6d, 0x61, 0x74, 0x33, 0x78, 0x33, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28,
0x76, 0x65, 0x63, 0x33, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x30, 0x2e, 0x36, 0x32, 0x37, 0x34,
0x30, 0x33, 0x39, 0x37, 0x34, 0x35, 0x33, 0x33, 0x30, 0x38, 0x31, 0x30, 0x35, 0x34, 0x36, 0x39,
0x66, 0x2c, 0x20, 0x30, 0x2e, 0x33, 0x32, 0x39, 0x32, 0x38, 0x32, 0x39, 0x39, 0x39, 0x30, 0x33,
0x38, 0x36, 0x39, 0x36, 0x32, 0x38, 0x39, 0x30, 0x36, 0x66, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x34,
0x33, 0x33, 0x31, 0x33, 0x30, 0x30, 0x30, 0x33, 0x35, 0x31, 0x31, 0x39, 0x30, 0x35, 0x36, 0x37,
0x30, 0x32, 0x66, 0x29, 0x2c, 0x20, 0x76, 0x65, 0x63, 0x33, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28,
0x30, 0x2e, 0x30, 0x36, 0x39, 0x30, 0x39, 0x36, 0x39, 0x39, 0x37, 0x33, 0x38, 0x30, 0x32, 0x35,
0x36, 0x36, 0x35, 0x32, 0x38, 0x33, 0x66, 0x2c, 0x20, 0x30, 0x2e, 0x39, 0x31, 0x39, 0x35, 0x34,
0x31, 0x30, 0x30, 0x31, 0x33, 0x31, 0x39, 0x38, 0x38, 0x35, 0x32, 0x35, 0x33, 0x39, 0x31, 0x66,
0x2c, 0x20, 0x30, 0x2e, 0x30, 0x31, 0x31, 0x33, 0x36, 0x32, 0x30, 0x30, 0x30, 0x33, 0x36, 0x38,
0x35, 0x33, 0x35, 0x35, 0x31, 0x38, 0x36, 0x35, 0x66, 0x29, 0x2c, 0x20, 0x76, 0x65, 0x63, 0x33,
0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x30, 0x2e, 0x30, 0x31, 0x36, 0x33, 0x39, 0x30, 0x39, 0x39,
0x39, 0x37, 0x37, 0x39, 0x31, 0x30, 0x35, 0x31, 0x38, 0x36, 0x34, 0x36, 0x66, 0x2c, 0x20, 0x30,
0x2e, 0x30, 0x38, 0x38, 0x30, 0x31, 0x33, 0x30, 0x30, 0x30, 0x37, 0x38, 0x36, 0x33, 0x30, 0x34,
0x34, 0x37, 0x33, 0x38, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x2e, 0x38, 0x39, 0x35, 0x35, 0x39, 0x35,
0x30, 0x31, 0x34, 0x30, 0x39, 0x35, 0x33, 0x30, 0x36, 0x33, 0x39, 0x36, 0x34, 0x38, 0x66, 0x29,
0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65,
0x74, 0x20, 0x76, 0x5f, 0x37, 0x39, 0x20, 0x3d, 0x20, 0x6d, 0x61, 0x78, 0x28, 0x76, 0x5f, 0x31,
0x34, 0x2e, 0x78, 0x2c, 0x20, 0x6d, 0x61, 0x78, 0x28, 0x76, 0x5f, 0x31, 0x34, 0x2e, 0x79, 0x2c,
0x20, 0x76, 0x5f, 0x31, 0x34, 0x2e, 0x7a, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x76, 0x5f, 0x37, 0x39, 0x20,
0x3e, 0x20, 0x30, 0x2e, 0x30, 0x66, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f,
0x38, 0x30, 0x20, 0x3d, 0x20, 0x28, 0x28, 0x31, 0x2e, 0x30, 0x66, 0x20, 0x2b, 0x20, 0x28, 0x76,
0x2e, 0x74, 0x6f, 0x6e, 0x65, 0x6d, 0x61, 0x70, 0x5f, 0x66, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x31,
0x20, 0x2a, 0x20, 0x76, 0x5f, 0x37, 0x39, 0x29, 0x29, 0x20, 0x2f, 0x20, 0x28, 0x31, 0x2e, 0x30,
0x66, 0x20, 0x2b, 0x20, 0x28, 0x76, 0x2e, 0x74, 0x6f, 0x6e, 0x65, 0x6d, 0x61, 0x70, 0x5f, 0x66,
0x61, 0x63, 0x74, 0x6f, 0x72, 0x32, 0x20, 0x2a, 0x20, 0x76, 0x5f, 0x37, 0x39, 0x29, 0x29, 0x29,
0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x76, 0x5f, 0x31, 0x34, 0x20, 0x3d, 0x20, 0x28, 0x76, 0x5f, 0x31, 0x34, 0x20, 0x2a,
0x20, 0x76, 0x5f, 0x38, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x76, 0x2e, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x5f, 0x74, 0x79,
0x70, 0x65, 0x20, 0x3d, 0x3d, 0x20, 0x32, 0x2e, 0x30, 0x66, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f,
0x31, 0x34, 0x20, 0x3d, 0x20, 0x28, 0x76, 0x5f, 0x31, 0x34, 0x20, 0x2a, 0x20, 0x6d, 0x61, 0x74,
0x33, 0x78, 0x33, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x76, 0x65, 0x63, 0x33, 0x3c, 0x66, 0x33,
0x32, 0x3e, 0x28, 0x31, 0x2e, 0x36, 0x36, 0x30, 0x34, 0x39, 0x35, 0x39, 0x39, 0x36, 0x34, 0x37,
0x35, 0x32, 0x31, 0x39, 0x37, 0x32, 0x36, 0x35, 0x36, 0x66, 0x2c, 0x20, 0x2d, 0x30, 0x2e, 0x35,
0x38, 0x37, 0x36, 0x35, 0x36, 0x30, 0x32, 0x31, 0x31, 0x31, 0x38, 0x31, 0x36, 0x34, 0x30, 0x36,
0x32, 0x35, 0x66, 0x2c, 0x20, 0x2d, 0x30, 0x2e, 0x30, 0x37, 0x32, 0x38, 0x33, 0x39, 0x39, 0x39,
0x37, 0x37, 0x30, 0x38, 0x37, 0x39, 0x37, 0x34, 0x35, 0x34, 0x38, 0x33, 0x66, 0x29, 0x2c, 0x20,
0x76, 0x65, 0x63, 0x33, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x2d, 0x30, 0x2e, 0x31, 0x32, 0x34,
0x35, 0x34, 0x36, 0x39, 0x39, 0x37, 0x32, 0x34, 0x39, 0x31, 0x32, 0x36, 0x34, 0x33, 0x34, 0x33,
0x33, 0x66, 0x2c, 0x20, 0x31, 0x2e, 0x31, 0x33, 0x32, 0x38, 0x39, 0x34, 0x39, 0x39, 0x32, 0x38,
0x32, 0x38, 0x33, 0x36, 0x39, 0x31, 0x34, 0x30, 0x36, 0x32, 0x66, 0x2c, 0x20, 0x2d, 0x30, 0x2e,
0x30, 0x30, 0x38, 0x33, 0x34, 0x38, 0x30, 0x30, 0x30, 0x32, 0x33, 0x35, 0x38, 0x35, 0x35, 0x35,
0x37, 0x39, 0x33, 0x38, 0x66, 0x29, 0x2c, 0x20, 0x76, 0x65, 0x63, 0x33, 0x3c, 0x66, 0x33, 0x32,
0x3e, 0x28, 0x2d, 0x30, 0x2e, 0x30, 0x31, 0x38, 0x31, 0x35, 0x34, 0x30, 0x30, 0x30, 0x38, 0x36,
0x33, 0x34, 0x33, 0x32, 0x38, 0x38, 0x34, 0x32, 0x32, 0x66, 0x2c, 0x20, 0x2d, 0x30, 0x2e, 0x31,
0x30, 0x30, 0x35, 0x39, 0x37, 0x30, 0x30, 0x31, 0x36, 0x31, 0x32, 0x31, 0x38, 0x36, 0x34, 0x33,
0x31, 0x38, 0x38, 0x66, 0x2c, 0x20, 0x31, 0x2e, 0x31, 0x31, 0x38, 0x37, 0x35, 0x31, 0x30, 0x34,
0x39, 0x30, 0x34, 0x31, 0x37, 0x34, 0x38, 0x30, 0x34, 0x36, 0x38, 0x38, 0x66, 0x29, 0x29, 0x29,
0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x38, 0x31, 0x20, 0x3d, 0x20, 0x76, 0x5f, 0x31,
0x34, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x31, 0x33, 0x2e,
0x78, 0x20, 0x3d, 0x20, 0x76, 0x5f, 0x38, 0x31, 0x2e, 0x78, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x31, 0x33, 0x2e, 0x79, 0x20, 0x3d, 0x20, 0x76, 0x5f, 0x38,
0x31, 0x2e, 0x79, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x31,
0x33, 0x2e, 0x7a, 0x20, 0x3d, 0x20, 0x76, 0x5f, 0x38, 0x31, 0x2e, 0x7a, 0x3b, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x76, 0x2e, 0x69, 0x6e,
0x70, 0x75, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x20, 0x3d, 0x3d, 0x20, 0x31, 0x2e, 0x30, 0x66,
0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x31, 0x36,
0x20, 0x3d, 0x20, 0x76, 0x5f, 0x31, 0x33, 0x2e, 0x78, 0x79, 0x7a, 0x3b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x21, 0x28, 0x28, 0x76, 0x2e, 0x73, 0x63, 0x52,
0x47, 0x42, 0x5f, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x3d, 0x3d, 0x20, 0x30, 0x2e, 0x30,
0x66, 0x29, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x38, 0x32, 0x20, 0x3d, 0x20, 0x76, 0x5f, 0x31,
0x36, 0x2e, 0x78, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x76, 0x61, 0x72, 0x20, 0x76, 0x5f, 0x38, 0x33, 0x3a, 0x20, 0x66, 0x33, 0x32, 0x3b, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28,
0x76, 0x5f, 0x38, 0x32, 0x20, 0x3c, 0x3d, 0x20, 0x30, 0x2e, 0x30, 0x34, 0x30, 0x34, 0x34, 0x39,
0x39, 0x39, 0x39, 0x32, 0x37, 0x32, 0x38, 0x32, 0x33, 0x33, 0x33, 0x33, 0x37, 0x34, 0x66, 0x29,
0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x76, 0x5f, 0x38, 0x33, 0x20, 0x3d, 0x20, 0x28, 0x76, 0x5f, 0x38, 0x32, 0x20,
0x2a, 0x20, 0x30, 0x2e, 0x30, 0x37, 0x37, 0x33, 0x39, 0x39, 0x33, 0x38, 0x30, 0x35, 0x30, 0x35,
0x30, 0x38, 0x34, 0x39, 0x39, 0x31, 0x34, 0x36, 0x66, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x20, 0x7b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x76, 0x5f, 0x38, 0x33, 0x20, 0x3d, 0x20, 0x70, 0x6f, 0x77, 0x28, 0x28, 0x61, 0x62, 0x73,
0x28, 0x28, 0x76, 0x5f, 0x38, 0x32, 0x20, 0x2b, 0x20, 0x30, 0x2e, 0x30, 0x35, 0x34, 0x39, 0x39,
0x39, 0x39, 0x39, 0x39, 0x37, 0x30, 0x31, 0x39, 0x37, 0x36, 0x37, 0x37, 0x36, 0x31, 0x32, 0x66,
0x29, 0x29, 0x20, 0x2a, 0x20, 0x30, 0x2e, 0x39, 0x34, 0x37, 0x38, 0x36, 0x37, 0x33, 0x33, 0x33,
0x38, 0x38, 0x39, 0x30, 0x30, 0x37, 0x35, 0x36, 0x38, 0x33, 0x36, 0x66, 0x29, 0x2c, 0x20, 0x32,
0x2e, 0x34, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x39, 0x35, 0x33, 0x36, 0x37, 0x34, 0x33, 0x31,
0x36, 0x34, 0x30, 0x36, 0x32, 0x66, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x76, 0x5f, 0x31, 0x36, 0x2e, 0x78, 0x20, 0x3d, 0x20, 0x76, 0x5f, 0x38, 0x33,
0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65,
0x74, 0x20, 0x76, 0x5f, 0x38, 0x34, 0x20, 0x3d, 0x20, 0x76, 0x5f, 0x31, 0x36, 0x2e, 0x79, 0x3b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72,
0x20, 0x76, 0x5f, 0x38, 0x35, 0x3a, 0x20, 0x66, 0x33, 0x32, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x76, 0x5f, 0x38, 0x34,
0x20, 0x3c, 0x3d, 0x20, 0x30, 0x2e, 0x30, 0x34, 0x30, 0x34, 0x34, 0x39, 0x39, 0x39, 0x39, 0x32,
0x37, 0x32, 0x38, 0x32, 0x33, 0x33, 0x33, 0x33, 0x37, 0x34, 0x66, 0x29, 0x20, 0x7b, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76,
0x5f, 0x38, 0x35, 0x20, 0x3d, 0x20, 0x28, 0x76, 0x5f, 0x38, 0x34, 0x20, 0x2a, 0x20, 0x30, 0x2e,
0x30, 0x37, 0x37, 0x33, 0x39, 0x39, 0x33, 0x38, 0x30, 0x35, 0x30, 0x35, 0x30, 0x38, 0x34, 0x39,
0x39, 0x31, 0x34, 0x36, 0x66, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x7d, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x38,
0x35, 0x20, 0x3d, 0x20, 0x70, 0x6f, 0x77, 0x28, 0x28, 0x61, 0x62, 0x73, 0x28, 0x28, 0x76, 0x5f,
0x38, 0x34, 0x20, 0x2b, 0x20, 0x30, 0x2e, 0x30, 0x35, 0x34, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39,
0x37, 0x30, 0x31, 0x39, 0x37, 0x36, 0x37, 0x37, 0x36, 0x31, 0x32, 0x66, 0x29, 0x29, 0x20, 0x2a,
0x20, 0x30, 0x2e, 0x39, 0x34, 0x37, 0x38, 0x36, 0x37, 0x33, 0x33, 0x33, 0x38, 0x38, 0x39, 0x30,
0x30, 0x37, 0x35, 0x36, 0x38, 0x33, 0x36, 0x66, 0x29, 0x2c, 0x20, 0x32, 0x2e, 0x34, 0x30, 0x30,
0x30, 0x30, 0x30, 0x30, 0x39, 0x35, 0x33, 0x36, 0x37, 0x34, 0x33, 0x31, 0x36, 0x34, 0x30, 0x36,
0x32, 0x66, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76,
0x5f, 0x31, 0x36, 0x2e, 0x79, 0x20, 0x3d, 0x20, 0x76, 0x5f, 0x38, 0x35, 0x3b, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f,
0x38, 0x36, 0x20, 0x3d, 0x20, 0x76, 0x5f, 0x31, 0x36, 0x2e, 0x7a, 0x3b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x76, 0x5f, 0x38,
0x37, 0x3a, 0x20, 0x66, 0x33, 0x32, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x76, 0x5f, 0x38, 0x36, 0x20, 0x3c, 0x3d, 0x20,
0x30, 0x2e, 0x30, 0x34, 0x30, 0x34, 0x34, 0x39, 0x39, 0x39, 0x39, 0x32, 0x37, 0x32, 0x38, 0x32,
0x33, 0x33, 0x33, 0x33, 0x37, 0x34, 0x66, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x38, 0x37, 0x20,
0x3d, 0x20, 0x28, 0x76, 0x5f, 0x38, 0x36, 0x20, 0x2a, 0x20, 0x30, 0x2e, 0x30, 0x37, 0x37, 0x33,
0x39, 0x39, 0x33, 0x38, 0x30, 0x35, 0x30, 0x35, 0x30, 0x38, 0x34, 0x39, 0x39, 0x31, 0x34, 0x36,
0x66, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x7d, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x38, 0x37, 0x20, 0x3d, 0x20,
0x70, 0x6f, 0x77, 0x28, 0x28, 0x61, 0x62, 0x73, 0x28, 0x28, 0x76, 0x5f, 0x38, 0x36, 0x20, 0x2b,
0x20, 0x30, 0x2e, 0x30, 0x35, 0x34, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x37, 0x30, 0x31, 0x39,
0x37, 0x36, 0x37, 0x37, 0x36, 0x31, 0x32, 0x66, 0x29, 0x29, 0x20, 0x2a, 0x20, 0x30, 0x2e, 0x39,
0x34, 0x37, 0x38, 0x36, 0x37, 0x33, 0x33, 0x33, 0x38, 0x38, 0x39, 0x30, 0x30, 0x37, 0x35, 0x36,
0x38, 0x33, 0x36, 0x66, 0x29, 0x2c, 0x20, 0x32, 0x2e, 0x34, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
0x39, 0x35, 0x33, 0x36, 0x37, 0x34, 0x33, 0x31, 0x36, 0x34, 0x30, 0x36, 0x32, 0x66, 0x29, 0x3b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x31, 0x36, 0x2e,
0x7a, 0x20, 0x3d, 0x20, 0x76, 0x5f, 0x38, 0x37, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20,
0x76, 0x5f, 0x38, 0x38, 0x20, 0x3d, 0x20, 0x28, 0x76, 0x5f, 0x31, 0x36, 0x20, 0x2a, 0x20, 0x76,
0x2e, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x29, 0x3b, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x31, 0x35, 0x2e, 0x78, 0x20, 0x3d, 0x20,
0x76, 0x5f, 0x38, 0x38, 0x2e, 0x78, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x76, 0x5f, 0x31, 0x35, 0x2e, 0x79, 0x20, 0x3d, 0x20, 0x76, 0x5f, 0x38, 0x38, 0x2e, 0x79, 0x3b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x31, 0x35, 0x2e, 0x7a, 0x20,
0x3d, 0x20, 0x76, 0x5f, 0x38, 0x38, 0x2e, 0x7a, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x76, 0x5f, 0x31, 0x35, 0x2e, 0x77, 0x20, 0x3d, 0x20, 0x76, 0x5f, 0x31, 0x33, 0x2e,
0x77, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x20, 0x69, 0x66,
0x20, 0x28, 0x76, 0x2e, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x20, 0x3d,
0x3d, 0x20, 0x32, 0x2e, 0x30, 0x66, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x76, 0x5f, 0x36, 0x20, 0x3d, 0x20, 0x28, 0x76, 0x5f, 0x31, 0x33, 0x2e, 0x78, 0x79,
0x7a, 0x20, 0x2a, 0x20, 0x76, 0x2e, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x73, 0x63, 0x61, 0x6c,
0x65, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28,
0x76, 0x2e, 0x73, 0x63, 0x52, 0x47, 0x42, 0x5f, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x3d,
0x3d, 0x20, 0x30, 0x2e, 0x30, 0x66, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x38, 0x39, 0x20, 0x3d,
0x20, 0x76, 0x5f, 0x36, 0x2e, 0x78, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x76, 0x5f, 0x39, 0x30, 0x3a, 0x20, 0x66, 0x33,
0x32, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69,
0x66, 0x20, 0x28, 0x76, 0x5f, 0x38, 0x39, 0x20, 0x3c, 0x3d, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x33,
0x31, 0x33, 0x30, 0x38, 0x30, 0x30, 0x30, 0x39, 0x30, 0x37, 0x33, 0x30, 0x31, 0x39, 0x30, 0x32,
0x38, 0x66, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x39, 0x30, 0x20, 0x3d, 0x20, 0x28, 0x76, 0x5f,
0x38, 0x39, 0x20, 0x2a, 0x20, 0x31, 0x32, 0x2e, 0x39, 0x32, 0x30, 0x30, 0x30, 0x30, 0x30, 0x37,
0x36, 0x32, 0x39, 0x33, 0x39, 0x34, 0x35, 0x33, 0x31, 0x32, 0x35, 0x66, 0x29, 0x3b, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x20, 0x65, 0x6c, 0x73,
0x65, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x39, 0x30, 0x20, 0x3d, 0x20, 0x28, 0x28, 0x70, 0x6f, 0x77,
0x28, 0x61, 0x62, 0x73, 0x28, 0x76, 0x5f, 0x38, 0x39, 0x29, 0x2c, 0x20, 0x30, 0x2e, 0x34, 0x31,
0x36, 0x36, 0x36, 0x36, 0x36, 0x35, 0x36, 0x37, 0x33, 0x32, 0x35, 0x35, 0x39, 0x32, 0x30, 0x34,
0x31, 0x66, 0x29, 0x20, 0x2a, 0x20, 0x31, 0x2e, 0x30, 0x35, 0x34, 0x39, 0x39, 0x39, 0x39, 0x34,
0x37, 0x35, 0x34, 0x37, 0x39, 0x31, 0x32, 0x35, 0x39, 0x37, 0x36, 0x36, 0x66, 0x29, 0x20, 0x2d,
0x20, 0x30, 0x2e, 0x30, 0x35, 0x34, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x37, 0x30, 0x31, 0x39,
0x37, 0x36, 0x37, 0x37, 0x36, 0x31, 0x32, 0x66, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x36, 0x2e, 0x78, 0x20, 0x3d, 0x20, 0x76, 0x5f, 0x39,
0x30, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c,
0x65, 0x74, 0x20, 0x76, 0x5f, 0x39, 0x31, 0x20, 0x3d, 0x20, 0x76, 0x5f, 0x36, 0x2e, 0x79, 0x3b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72,
0x20, 0x76, 0x5f, 0x39, 0x32, 0x3a, 0x20, 0x66, 0x33, 0x32, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x76, 0x5f, 0x39, 0x31,
0x20, 0x3c, 0x3d, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x33, 0x31, 0x33, 0x30, 0x38, 0x30, 0x30, 0x30,
0x39, 0x30, 0x37, 0x33, 0x30, 0x31, 0x39, 0x30, 0x32, 0x38, 0x66, 0x29, 0x20, 0x7b, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76,
0x5f, 0x39, 0x32, 0x20, 0x3d, 0x20, 0x28, 0x76, 0x5f, 0x39, 0x31, 0x20, 0x2a, 0x20, 0x31, 0x32,
0x2e, 0x39, 0x32, 0x30, 0x30, 0x30, 0x30, 0x30, 0x37, 0x36, 0x32, 0x39, 0x33, 0x39, 0x34, 0x35,
0x33, 0x31, 0x32, 0x35, 0x66, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x7d, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x39,
0x32, 0x20, 0x3d, 0x20, 0x28, 0x28, 0x70, 0x6f, 0x77, 0x28, 0x61, 0x62, 0x73, 0x28, 0x76, 0x5f,
0x39, 0x31, 0x29, 0x2c, 0x20, 0x30, 0x2e, 0x34, 0x31, 0x36, 0x36, 0x36, 0x36, 0x36, 0x35, 0x36,
0x37, 0x33, 0x32, 0x35, 0x35, 0x39, 0x32, 0x30, 0x34, 0x31, 0x66, 0x29, 0x20, 0x2a, 0x20, 0x31,
0x2e, 0x30, 0x35, 0x34, 0x39, 0x39, 0x39, 0x39, 0x34, 0x37, 0x35, 0x34, 0x37, 0x39, 0x31, 0x32,
0x35, 0x39, 0x37, 0x36, 0x36, 0x66, 0x29, 0x20, 0x2d, 0x20, 0x30, 0x2e, 0x30, 0x35, 0x34, 0x39,
0x39, 0x39, 0x39, 0x39, 0x39, 0x37, 0x30, 0x31, 0x39, 0x37, 0x36, 0x37, 0x37, 0x36, 0x31, 0x32,
0x66, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f,
0x36, 0x2e, 0x79, 0x20, 0x3d, 0x20, 0x76, 0x5f, 0x39, 0x32, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x39, 0x33,
0x20, 0x3d, 0x20, 0x76, 0x5f, 0x36, 0x2e, 0x7a, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x76, 0x5f, 0x39, 0x34, 0x3a, 0x20,
0x66, 0x33, 0x32, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x69, 0x66, 0x20, 0x28, 0x76, 0x5f, 0x39, 0x33, 0x20, 0x3c, 0x3d, 0x20, 0x30, 0x2e, 0x30,
0x30, 0x33, 0x31, 0x33, 0x30, 0x38, 0x30, 0x30, 0x30, 0x39, 0x30, 0x37, 0x33, 0x30, 0x31, 0x39,
0x30, 0x32, 0x38, 0x66, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x39, 0x34, 0x20, 0x3d, 0x20, 0x28,
0x76, 0x5f, 0x39, 0x33, 0x20, 0x2a, 0x20, 0x31, 0x32, 0x2e, 0x39, 0x32, 0x30, 0x30, 0x30, 0x30,
0x30, 0x37, 0x36, 0x32, 0x39, 0x33, 0x39, 0x34, 0x35, 0x33, 0x31, 0x32, 0x35, 0x66, 0x29, 0x3b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x20, 0x65,
0x6c, 0x73, 0x65, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x39, 0x34, 0x20, 0x3d, 0x20, 0x28, 0x28, 0x70,
0x6f, 0x77, 0x28, 0x61, 0x62, 0x73, 0x28, 0x76, 0x5f, 0x39, 0x33, 0x29, 0x2c, 0x20, 0x30, 0x2e,
0x34, 0x31, 0x36, 0x36, 0x36, 0x36, 0x36, 0x35, 0x36, 0x37, 0x33, 0x32, 0x35, 0x35, 0x39, 0x32,
0x30, 0x34, 0x31, 0x66, 0x29, 0x20, 0x2a, 0x20, 0x31, 0x2e, 0x30, 0x35, 0x34, 0x39, 0x39, 0x39,
0x39, 0x34, 0x37, 0x35, 0x34, 0x37, 0x39, 0x31, 0x32, 0x35, 0x39, 0x37, 0x36, 0x36, 0x66, 0x29,
0x20, 0x2d, 0x20, 0x30, 0x2e, 0x30, 0x35, 0x34, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x37, 0x30,
0x31, 0x39, 0x37, 0x36, 0x37, 0x37, 0x36, 0x31, 0x32, 0x66, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x36, 0x2e, 0x7a, 0x20, 0x3d, 0x20, 0x76,
0x5f, 0x39, 0x34, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x76, 0x5f, 0x36, 0x20, 0x3d, 0x20, 0x63, 0x6c, 0x61, 0x6d, 0x70, 0x28, 0x76, 0x5f, 0x36,
0x2c, 0x20, 0x76, 0x65, 0x63, 0x33, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x29, 0x2c, 0x20, 0x76,
0x65, 0x63, 0x33, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x31, 0x2e, 0x30, 0x66, 0x29, 0x29, 0x3b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x39, 0x35, 0x20, 0x3d, 0x20, 0x76, 0x5f,
0x36, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x31, 0x35, 0x2e,
0x78, 0x20, 0x3d, 0x20, 0x76, 0x5f, 0x39, 0x35, 0x2e, 0x78, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x31, 0x35, 0x2e, 0x79, 0x20, 0x3d, 0x20, 0x76, 0x5f, 0x39,
0x35, 0x2e, 0x79, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x31,
0x35, 0x2e, 0x7a, 0x20, 0x3d, 0x20, 0x76, 0x5f, 0x39, 0x35, 0x2e, 0x7a, 0x3b, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x31, 0x35, 0x2e, 0x77, 0x20, 0x3d, 0x20, 0x76,
0x5f, 0x31, 0x33, 0x2e, 0x77, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x20, 0x65, 0x6c, 0x73,
0x65, 0x20, 0x69, 0x66, 0x20, 0x28, 0x76, 0x2e, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x5f, 0x74, 0x79,
0x70, 0x65, 0x20, 0x3d, 0x3d, 0x20, 0x33, 0x2e, 0x30, 0x66, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x39, 0x36, 0x20, 0x3d,
0x20, 0x28, 0x76, 0x5f, 0x31, 0x33, 0x2e, 0x78, 0x79, 0x7a, 0x20, 0x2a, 0x20, 0x6d, 0x61, 0x74,
0x33, 0x78, 0x33, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x76, 0x65, 0x63, 0x33, 0x3c, 0x66, 0x33,
0x32, 0x3e, 0x28, 0x31, 0x2e, 0x36, 0x36, 0x30, 0x34, 0x39, 0x35, 0x39, 0x39, 0x36, 0x34, 0x37,
0x35, 0x32, 0x31, 0x39, 0x37, 0x32, 0x36, 0x35, 0x36, 0x66, 0x2c, 0x20, 0x2d, 0x30, 0x2e, 0x35,
0x38, 0x37, 0x36, 0x35, 0x36, 0x30, 0x32, 0x31, 0x31, 0x31, 0x38, 0x31, 0x36, 0x34, 0x30, 0x36,
0x32, 0x35, 0x66, 0x2c, 0x20, 0x2d, 0x30, 0x2e, 0x30, 0x37, 0x32, 0x38, 0x33, 0x39, 0x39, 0x39,
0x37, 0x37, 0x30, 0x38, 0x37, 0x39, 0x37, 0x34, 0x35, 0x34, 0x38, 0x33, 0x66, 0x29, 0x2c, 0x20,
0x76, 0x65, 0x63, 0x33, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x2d, 0x30, 0x2e, 0x31, 0x32, 0x34,
0x35, 0x34, 0x36, 0x39, 0x39, 0x37, 0x32, 0x34, 0x39, 0x31, 0x32, 0x36, 0x34, 0x33, 0x34, 0x33,
0x33, 0x66, 0x2c, 0x20, 0x31, 0x2e, 0x31, 0x33, 0x32, 0x38, 0x39, 0x34, 0x39, 0x39, 0x32, 0x38,
0x32, 0x38, 0x33, 0x36, 0x39, 0x31, 0x34, 0x30, 0x36, 0x32, 0x66, 0x2c, 0x20, 0x2d, 0x30, 0x2e,
0x30, 0x30, 0x38, 0x33, 0x34, 0x38, 0x30, 0x30, 0x30, 0x32, 0x33, 0x35, 0x38, 0x35, 0x35, 0x35,
0x37, 0x39, 0x33, 0x38, 0x66, 0x29, 0x2c, 0x20, 0x76, 0x65, 0x63, 0x33, 0x3c, 0x66, 0x33, 0x32,
0x3e, 0x28, 0x2d, 0x30, 0x2e, 0x30, 0x31, 0x38, 0x31, 0x35, 0x34, 0x30, 0x30, 0x30, 0x38, 0x36,
0x33, 0x34, 0x33, 0x32, 0x38, 0x38, 0x34, 0x32, 0x32, 0x66, 0x2c, 0x20, 0x2d, 0x30, 0x2e, 0x31,
0x30, 0x30, 0x35, 0x39, 0x37, 0x30, 0x30, 0x31, 0x36, 0x31, 0x32, 0x31, 0x38, 0x36, 0x34, 0x33,
0x31, 0x38, 0x38, 0x66, 0x2c, 0x20, 0x31, 0x2e, 0x31, 0x31, 0x38, 0x37, 0x35, 0x31, 0x30, 0x34,
0x39, 0x30, 0x34, 0x31, 0x37, 0x34, 0x38, 0x30, 0x34, 0x36, 0x38, 0x38, 0x66, 0x29, 0x29, 0x29,
0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x31, 0x33, 0x2e, 0x78,
0x20, 0x3d, 0x20, 0x76, 0x5f, 0x39, 0x36, 0x2e, 0x78, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x76, 0x5f, 0x31, 0x33, 0x2e, 0x79, 0x20, 0x3d, 0x20, 0x76, 0x5f, 0x39, 0x36,
0x2e, 0x79, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x31, 0x33,
0x2e, 0x7a, 0x20, 0x3d, 0x20, 0x76, 0x5f, 0x39, 0x36, 0x2e, 0x7a, 0x3b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x35, 0x20, 0x3d, 0x20, 0x28, 0x76, 0x5f, 0x31, 0x33,
0x2e, 0x78, 0x79, 0x7a, 0x20, 0x2a, 0x20, 0x76, 0x2e, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x73,
0x63, 0x61, 0x6c, 0x65, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69,
0x66, 0x20, 0x28, 0x76, 0x2e, 0x73, 0x63, 0x52, 0x47, 0x42, 0x5f, 0x6f, 0x75, 0x74, 0x70, 0x75,
0x74, 0x20, 0x3d, 0x3d, 0x20, 0x30, 0x2e, 0x30, 0x66, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x39,
0x37, 0x20, 0x3d, 0x20, 0x76, 0x5f, 0x35, 0x2e, 0x78, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x76, 0x5f, 0x39, 0x38, 0x3a,
0x20, 0x66, 0x33, 0x32, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x76, 0x5f, 0x39, 0x37, 0x20, 0x3c, 0x3d, 0x20, 0x30, 0x2e,
0x30, 0x30, 0x33, 0x31, 0x33, 0x30, 0x38, 0x30, 0x30, 0x30, 0x39, 0x30, 0x37, 0x33, 0x30, 0x31,
0x39, 0x30, 0x32, 0x38, 0x66, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x39, 0x38, 0x20, 0x3d, 0x20,
0x28, 0x76, 0x5f, 0x39, 0x37, 0x20, 0x2a, 0x20, 0x31, 0x32, 0x2e, 0x39, 0x32, 0x30, 0x30, 0x30,
0x30, 0x30, 0x37, 0x36, 0x32, 0x39, 0x33, 0x39, 0x34, 0x35, 0x33, 0x31, 0x32, 0x35, 0x66, 0x29,
0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x20,
0x65, 0x6c, 0x73, 0x65, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x39, 0x38, 0x20, 0x3d, 0x20, 0x28, 0x28,
0x70, 0x6f, 0x77, 0x28, 0x61, 0x62, 0x73, 0x28, 0x76, 0x5f, 0x39, 0x37, 0x29, 0x2c, 0x20, 0x30,
0x2e, 0x34, 0x31, 0x36, 0x36, 0x36, 0x36, 0x36, 0x35, 0x36, 0x37, 0x33, 0x32, 0x35, 0x35, 0x39,
0x32, 0x30, 0x34, 0x31, 0x66, 0x29, 0x20, 0x2a, 0x20, 0x31, 0x2e, 0x30, 0x35, 0x34, 0x39, 0x39,
0x39, 0x39, 0x34, 0x37, 0x35, 0x34, 0x37, 0x39, 0x31, 0x32, 0x35, 0x39, 0x37, 0x36, 0x36, 0x66,
0x29, 0x20, 0x2d, 0x20, 0x30, 0x2e, 0x30, 0x35, 0x34, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x37,
0x30, 0x31, 0x39, 0x37, 0x36, 0x37, 0x37, 0x36, 0x31, 0x32, 0x66, 0x29, 0x3b, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x35, 0x2e, 0x78, 0x20, 0x3d, 0x20,
0x76, 0x5f, 0x39, 0x38, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x39, 0x39, 0x20, 0x3d, 0x20, 0x76, 0x5f, 0x35,
0x2e, 0x79, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x76, 0x61, 0x72, 0x20, 0x76, 0x5f, 0x31, 0x30, 0x30, 0x3a, 0x20, 0x66, 0x33, 0x32, 0x3b, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28,
0x76, 0x5f, 0x39, 0x39, 0x20, 0x3c, 0x3d, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x33, 0x31, 0x33, 0x30,
0x38, 0x30, 0x30, 0x30, 0x39, 0x30, 0x37, 0x33, 0x30, 0x31, 0x39, 0x30, 0x32, 0x38, 0x66, 0x29,
0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x76, 0x5f, 0x31, 0x30, 0x30, 0x20, 0x3d, 0x20, 0x28, 0x76, 0x5f, 0x39, 0x39,
0x20, 0x2a, 0x20, 0x31, 0x32, 0x2e, 0x39, 0x32, 0x30, 0x30, 0x30, 0x30, 0x30, 0x37, 0x36, 0x32,
0x39, 0x33, 0x39, 0x34, 0x35, 0x33, 0x31, 0x32, 0x35, 0x66, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x20,
0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x76, 0x5f, 0x31, 0x30, 0x30, 0x20, 0x3d, 0x20, 0x28, 0x28, 0x70, 0x6f, 0x77, 0x28,
0x61, 0x62, 0x73, 0x28, 0x76, 0x5f, 0x39, 0x39, 0x29, 0x2c, 0x20, 0x30, 0x2e, 0x34, 0x31, 0x36,
0x36, 0x36, 0x36, 0x36, 0x35, 0x36, 0x37, 0x33, 0x32, 0x35, 0x35, 0x39, 0x32, 0x30, 0x34, 0x31,
0x66, 0x29, 0x20, 0x2a, 0x20, 0x31, 0x2e, 0x30, 0x35, 0x34, 0x39, 0x39, 0x39, 0x39, 0x34, 0x37,
0x35, 0x34, 0x37, 0x39, 0x31, 0x32, 0x35, 0x39, 0x37, 0x36, 0x36, 0x66, 0x29, 0x20, 0x2d, 0x20,
0x30, 0x2e, 0x30, 0x35, 0x34, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x37, 0x30, 0x31, 0x39, 0x37,
0x36, 0x37, 0x37, 0x36, 0x31, 0x32, 0x66, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x35, 0x2e, 0x79, 0x20, 0x3d, 0x20, 0x76, 0x5f, 0x31, 0x30,
0x30, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c,
0x65, 0x74, 0x20, 0x76, 0x5f, 0x31, 0x30, 0x31, 0x20, 0x3d, 0x20, 0x76, 0x5f, 0x35, 0x2e, 0x7a,
0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61,
0x72, 0x20, 0x76, 0x5f, 0x31, 0x30, 0x32, 0x3a, 0x20, 0x66, 0x33, 0x32, 0x3b, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x76, 0x5f,
0x31, 0x30, 0x31, 0x20, 0x3c, 0x3d, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x33, 0x31, 0x33, 0x30, 0x38,
0x30, 0x30, 0x30, 0x39, 0x30, 0x37, 0x33, 0x30, 0x31, 0x39, 0x30, 0x32, 0x38, 0x66, 0x29, 0x20,
0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x76, 0x5f, 0x31, 0x30, 0x32, 0x20, 0x3d, 0x20, 0x28, 0x76, 0x5f, 0x31, 0x30, 0x31,
0x20, 0x2a, 0x20, 0x31, 0x32, 0x2e, 0x39, 0x32, 0x30, 0x30, 0x30, 0x30, 0x30, 0x37, 0x36, 0x32,
0x39, 0x33, 0x39, 0x34, 0x35, 0x33, 0x31, 0x32, 0x35, 0x66, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x20,
0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x76, 0x5f, 0x31, 0x30, 0x32, 0x20, 0x3d, 0x20, 0x28, 0x28, 0x70, 0x6f, 0x77, 0x28,
0x61, 0x62, 0x73, 0x28, 0x76, 0x5f, 0x31, 0x30, 0x31, 0x29, 0x2c, 0x20, 0x30, 0x2e, 0x34, 0x31,
0x36, 0x36, 0x36, 0x36, 0x36, 0x35, 0x36, 0x37, 0x33, 0x32, 0x35, 0x35, 0x39, 0x32, 0x30, 0x34,
0x31, 0x66, 0x29, 0x20, 0x2a, 0x20, 0x31, 0x2e, 0x30, 0x35, 0x34, 0x39, 0x39, 0x39, 0x39, 0x34,
0x37, 0x35, 0x34, 0x37, 0x39, 0x31, 0x32, 0x35, 0x39, 0x37, 0x36, 0x36, 0x66, 0x29, 0x20, 0x2d,
0x20, 0x30, 0x2e, 0x30, 0x35, 0x34, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x37, 0x30, 0x31, 0x39,
0x37, 0x36, 0x37, 0x37, 0x36, 0x31, 0x32, 0x66, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x35, 0x2e, 0x7a, 0x20, 0x3d, 0x20, 0x76, 0x5f, 0x31,
0x30, 0x32, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x76, 0x5f, 0x35, 0x20, 0x3d, 0x20, 0x63, 0x6c, 0x61, 0x6d, 0x70, 0x28, 0x76, 0x5f, 0x35, 0x2c,
0x20, 0x76, 0x65, 0x63, 0x33, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x29, 0x2c, 0x20, 0x76, 0x65,
0x63, 0x33, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x31, 0x2e, 0x30, 0x66, 0x29, 0x29, 0x3b, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x6c, 0x65, 0x74, 0x20, 0x76, 0x5f, 0x31, 0x30, 0x33, 0x20, 0x3d, 0x20, 0x76, 0x5f,
0x35, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x31, 0x35, 0x2e,
0x78, 0x20, 0x3d, 0x20, 0x76, 0x5f, 0x31, 0x30, 0x33, 0x2e, 0x78, 0x3b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x31, 0x35, 0x2e, 0x79, 0x20, 0x3d, 0x20, 0x76, 0x5f,
0x31, 0x30, 0x33, 0x2e, 0x79, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76,
0x5f, 0x31, 0x35, 0x2e, 0x7a, 0x20, 0x3d, 0x20, 0x76, 0x5f, 0x31, 0x30, 0x33, 0x2e, 0x7a, 0x3b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x31, 0x35, 0x2e, 0x77, 0x20,
0x3d, 0x20, 0x76, 0x5f, 0x31, 0x33, 0x2e, 0x77, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x20,
0x65, 0x6c, 0x73, 0x65, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c,
0x65, 0x74, 0x20, 0x76, 0x5f, 0x31, 0x30, 0x34, 0x20, 0x3d, 0x20, 0x76, 0x5f, 0x31, 0x33, 0x3b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x31, 0x37, 0x20, 0x3d, 0x20,
0x76, 0x5f, 0x31, 0x30, 0x34, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c,
0x65, 0x74, 0x20, 0x76, 0x5f, 0x31, 0x30, 0x35, 0x20, 0x3d, 0x20, 0x28, 0x76, 0x5f, 0x31, 0x30,
0x34, 0x2e, 0x78, 0x79, 0x7a, 0x20, 0x2a, 0x20, 0x76, 0x2e, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f,
0x73, 0x63, 0x61, 0x6c, 0x65, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x76, 0x5f, 0x34, 0x2e, 0x78, 0x20, 0x3d, 0x20, 0x76, 0x5f, 0x31, 0x30, 0x35, 0x2e, 0x78, 0x3b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x34, 0x2e, 0x79, 0x20, 0x3d,
0x20, 0x76, 0x5f, 0x31, 0x30, 0x35, 0x2e, 0x79, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x76, 0x5f, 0x34, 0x2e, 0x7a, 0x20, 0x3d, 0x20, 0x76, 0x5f, 0x31, 0x30, 0x35, 0x2e,
0x7a, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x34, 0x2e, 0x77,
0x20, 0x3d, 0x20, 0x76, 0x5f, 0x31, 0x37, 0x2e, 0x77, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x76, 0x5f, 0x31, 0x35, 0x20, 0x3d, 0x20, 0x76, 0x5f, 0x34, 0x3b, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x5f, 0x31, 0x20, 0x3d, 0x20, 0x28,
0x76, 0x5f, 0x31, 0x35, 0x20, 0x2a, 0x20, 0x76, 0x5f, 0x32, 0x29, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a,
0x40, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x0a, 0x66, 0x6e, 0x20, 0x6d, 0x61, 0x69,
0x6e, 0x28, 0x40, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x30, 0x75, 0x29, 0x20,
0x76, 0x5f, 0x31, 0x30, 0x36, 0x3a, 0x20, 0x76, 0x65, 0x63, 0x34, 0x3c, 0x66, 0x33, 0x32, 0x3e,
0x2c, 0x20, 0x40, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x31, 0x75, 0x29, 0x20,
0x76, 0x5f, 0x31, 0x30, 0x37, 0x3a, 0x20, 0x76, 0x65, 0x63, 0x32, 0x3c, 0x66, 0x33, 0x32, 0x3e,
0x29, 0x20, 0x2d, 0x3e, 0x20, 0x40, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x30,
0x75, 0x29, 0x20, 0x76, 0x65, 0x63, 0x34, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x20, 0x7b, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x6e, 0x6e, 0x65, 0x72, 0x28, 0x76, 0x5f,
0x31, 0x30, 0x36, 0x2c, 0x20, 0x76, 0x5f, 0x31, 0x30, 0x37, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x76, 0x5f, 0x31, 0x3b, 0x0a, 0x7d, 0x0a
};
static const unsigned int texture_advanced_frag_wgsl_len = 13791;
@@ -0,0 +1,29 @@
struct Constants {
colorScale: f32,
};
struct PSInput {
@location(0u) vColor: vec4<f32>,
@location(1u) vUv: vec2<f32>,
};
struct PSOutput {
@location(0u) oColor: vec4<f32>,
};
@group(2u) @binding(0u) var uTexture: texture_2d<f32>;
@group(2u) @binding(1u) var uSampler: sampler;
@group(3u) @binding(0u) var<uniform> constants: Constants;
fn getOutputColor(rgba: vec4<f32>, colorScale: f32) -> vec4<f32> {
return vec4<f32>(rgba.rgb * colorScale, rgba.a);
}
@fragment
fn main(input: PSInput) -> PSOutput {
var output: PSOutput;
output.oColor = getOutputColor(vec4<f32>(textureSample(uTexture, uSampler, input.vUv).rgb, 1.0f), constants.colorScale) * input.vColor;
return output;
}
+49
View File
@@ -0,0 +1,49 @@
static const unsigned char texture_rgb_frag_wgsl[] = {
0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x73,
0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x53, 0x63, 0x61, 0x6c,
0x65, 0x3a, 0x20, 0x66, 0x33, 0x32, 0x2c, 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x73, 0x74, 0x72, 0x75,
0x63, 0x74, 0x20, 0x50, 0x53, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x40, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x30, 0x75, 0x29, 0x20, 0x76,
0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x20, 0x76, 0x65, 0x63, 0x34, 0x3c, 0x66, 0x33, 0x32, 0x3e,
0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x40, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x28,
0x31, 0x75, 0x29, 0x20, 0x76, 0x55, 0x76, 0x3a, 0x20, 0x76, 0x65, 0x63, 0x32, 0x3c, 0x66, 0x33,
0x32, 0x3e, 0x2c, 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x50,
0x53, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x40, 0x6c,
0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x30, 0x75, 0x29, 0x20, 0x6f, 0x43, 0x6f, 0x6c,
0x6f, 0x72, 0x3a, 0x20, 0x76, 0x65, 0x63, 0x34, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x2c, 0x0a, 0x7d,
0x3b, 0x0a, 0x0a, 0x40, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x28, 0x32, 0x75, 0x29, 0x20, 0x40, 0x62,
0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x28, 0x30, 0x75, 0x29, 0x20, 0x76, 0x61, 0x72, 0x20, 0x75,
0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65,
0x5f, 0x32, 0x64, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x3b, 0x0a, 0x40, 0x67, 0x72, 0x6f, 0x75, 0x70,
0x28, 0x32, 0x75, 0x29, 0x20, 0x40, 0x62, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x28, 0x31, 0x75,
0x29, 0x20, 0x76, 0x61, 0x72, 0x20, 0x75, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x3a, 0x20,
0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x3b, 0x0a, 0x0a, 0x40, 0x67, 0x72, 0x6f, 0x75, 0x70,
0x28, 0x33, 0x75, 0x29, 0x20, 0x40, 0x62, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x28, 0x30, 0x75,
0x29, 0x20, 0x76, 0x61, 0x72, 0x3c, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x3e, 0x20, 0x63,
0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x73, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x61,
0x6e, 0x74, 0x73, 0x3b, 0x0a, 0x0a, 0x66, 0x6e, 0x20, 0x67, 0x65, 0x74, 0x4f, 0x75, 0x74, 0x70,
0x75, 0x74, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x28, 0x72, 0x67, 0x62, 0x61, 0x3a, 0x20, 0x76, 0x65,
0x63, 0x34, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x2c, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x53, 0x63,
0x61, 0x6c, 0x65, 0x3a, 0x20, 0x66, 0x33, 0x32, 0x29, 0x20, 0x2d, 0x3e, 0x20, 0x76, 0x65, 0x63,
0x34, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74,
0x75, 0x72, 0x6e, 0x20, 0x76, 0x65, 0x63, 0x34, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x72, 0x67,
0x62, 0x61, 0x2e, 0x72, 0x67, 0x62, 0x20, 0x2a, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x53, 0x63,
0x61, 0x6c, 0x65, 0x2c, 0x20, 0x72, 0x67, 0x62, 0x61, 0x2e, 0x61, 0x29, 0x3b, 0x0a, 0x7d, 0x0a,
0x0a, 0x40, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x0a, 0x66, 0x6e, 0x20, 0x6d, 0x61,
0x69, 0x6e, 0x28, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x3a, 0x20, 0x50, 0x53, 0x49, 0x6e, 0x70, 0x75,
0x74, 0x29, 0x20, 0x2d, 0x3e, 0x20, 0x50, 0x53, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x7b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x3a,
0x20, 0x50, 0x53, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f,
0x75, 0x74, 0x70, 0x75, 0x74, 0x2e, 0x6f, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x67,
0x65, 0x74, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x28, 0x76, 0x65,
0x63, 0x34, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x53,
0x61, 0x6d, 0x70, 0x6c, 0x65, 0x28, 0x75, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x2c, 0x20,
0x75, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x2c, 0x20, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x2e,
0x76, 0x55, 0x76, 0x29, 0x2e, 0x72, 0x67, 0x62, 0x2c, 0x20, 0x31, 0x2e, 0x30, 0x66, 0x29, 0x2c,
0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6c, 0x6f, 0x72,
0x53, 0x63, 0x61, 0x6c, 0x65, 0x29, 0x20, 0x2a, 0x20, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x2e, 0x76,
0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75,
0x72, 0x6e, 0x20, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x3b, 0x0a, 0x7d, 0x0a
};
static const unsigned int texture_rgb_frag_wgsl_len = 717;
@@ -0,0 +1,29 @@
struct Constants {
colorScale: f32,
};
struct PSInput {
@location(0u) vColor: vec4<f32>,
@location(1u) vUv: vec2<f32>,
};
struct PSOutput {
@location(0u) oColor: vec4<f32>,
};
@group(2u) @binding(0u) var uTexture: texture_2d<f32>;
@group(2u) @binding(1u) var uSampler: sampler;
@group(3u) @binding(0u) var<uniform> constants: Constants;
fn getOutputColor(rgba: vec4<f32>, colorScale: f32) -> vec4<f32> {
return vec4<f32>(rgba.rgb * colorScale, rgba.a);
}
@fragment
fn main(input: PSInput) -> PSOutput {
var output: PSOutput;
output.oColor = getOutputColor(textureSample(uTexture, uSampler, input.vUv), constants.colorScale) * input.vColor;
return output;
}
+48
View File
@@ -0,0 +1,48 @@
static const unsigned char texture_rgba_frag_wgsl[] = {
0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x73,
0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x53, 0x63, 0x61, 0x6c,
0x65, 0x3a, 0x20, 0x66, 0x33, 0x32, 0x2c, 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x73, 0x74, 0x72, 0x75,
0x63, 0x74, 0x20, 0x50, 0x53, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x40, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x30, 0x75, 0x29, 0x20, 0x76,
0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x20, 0x76, 0x65, 0x63, 0x34, 0x3c, 0x66, 0x33, 0x32, 0x3e,
0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x40, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x28,
0x31, 0x75, 0x29, 0x20, 0x76, 0x55, 0x76, 0x3a, 0x20, 0x76, 0x65, 0x63, 0x32, 0x3c, 0x66, 0x33,
0x32, 0x3e, 0x2c, 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x50,
0x53, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x40, 0x6c,
0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x30, 0x75, 0x29, 0x20, 0x6f, 0x43, 0x6f, 0x6c,
0x6f, 0x72, 0x3a, 0x20, 0x76, 0x65, 0x63, 0x34, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x2c, 0x0a, 0x7d,
0x3b, 0x0a, 0x0a, 0x40, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x28, 0x32, 0x75, 0x29, 0x20, 0x40, 0x62,
0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x28, 0x30, 0x75, 0x29, 0x20, 0x76, 0x61, 0x72, 0x20, 0x75,
0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65,
0x5f, 0x32, 0x64, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x3b, 0x0a, 0x40, 0x67, 0x72, 0x6f, 0x75, 0x70,
0x28, 0x32, 0x75, 0x29, 0x20, 0x40, 0x62, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x28, 0x31, 0x75,
0x29, 0x20, 0x76, 0x61, 0x72, 0x20, 0x75, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x3a, 0x20,
0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x3b, 0x0a, 0x0a, 0x40, 0x67, 0x72, 0x6f, 0x75, 0x70,
0x28, 0x33, 0x75, 0x29, 0x20, 0x40, 0x62, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x28, 0x30, 0x75,
0x29, 0x20, 0x76, 0x61, 0x72, 0x3c, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x3e, 0x20, 0x63,
0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x73, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x61,
0x6e, 0x74, 0x73, 0x3b, 0x0a, 0x0a, 0x66, 0x6e, 0x20, 0x67, 0x65, 0x74, 0x4f, 0x75, 0x74, 0x70,
0x75, 0x74, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x28, 0x72, 0x67, 0x62, 0x61, 0x3a, 0x20, 0x76, 0x65,
0x63, 0x34, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x2c, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x53, 0x63,
0x61, 0x6c, 0x65, 0x3a, 0x20, 0x66, 0x33, 0x32, 0x29, 0x20, 0x2d, 0x3e, 0x20, 0x76, 0x65, 0x63,
0x34, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74,
0x75, 0x72, 0x6e, 0x20, 0x76, 0x65, 0x63, 0x34, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x72, 0x67,
0x62, 0x61, 0x2e, 0x72, 0x67, 0x62, 0x20, 0x2a, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x53, 0x63,
0x61, 0x6c, 0x65, 0x2c, 0x20, 0x72, 0x67, 0x62, 0x61, 0x2e, 0x61, 0x29, 0x3b, 0x0a, 0x7d, 0x0a,
0x0a, 0x40, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x0a, 0x66, 0x6e, 0x20, 0x6d, 0x61,
0x69, 0x6e, 0x28, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x3a, 0x20, 0x50, 0x53, 0x49, 0x6e, 0x70, 0x75,
0x74, 0x29, 0x20, 0x2d, 0x3e, 0x20, 0x50, 0x53, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x7b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x3a,
0x20, 0x50, 0x53, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f,
0x75, 0x74, 0x70, 0x75, 0x74, 0x2e, 0x6f, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x67,
0x65, 0x74, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x28, 0x74, 0x65,
0x78, 0x74, 0x75, 0x72, 0x65, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x28, 0x75, 0x54, 0x65, 0x78,
0x74, 0x75, 0x72, 0x65, 0x2c, 0x20, 0x75, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x2c, 0x20,
0x69, 0x6e, 0x70, 0x75, 0x74, 0x2e, 0x76, 0x55, 0x76, 0x29, 0x2c, 0x20, 0x63, 0x6f, 0x6e, 0x73,
0x74, 0x61, 0x6e, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x53, 0x63, 0x61, 0x6c, 0x65,
0x29, 0x20, 0x2a, 0x20, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x2e, 0x76, 0x43, 0x6f, 0x6c, 0x6f, 0x72,
0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6f, 0x75,
0x74, 0x70, 0x75, 0x74, 0x3b, 0x0a, 0x7d, 0x0a
};
static const unsigned int texture_rgba_frag_wgsl_len = 696;
@@ -0,0 +1,27 @@
struct Context {
mvp: mat4x4<f32>, // Model-View-Projection matrix
};
struct VSInput {
@location(0u) aPosition: vec2<f32>,
@location(1u) aColor: vec4<f32>,
@location(2u) aUv: vec2<f32>,
};
struct VSOutput {
@location(0u) vColor: vec4<f32>,
@location(1u) vUv: vec2<f32>,
@builtin(position) glPosition: vec4<f32>,
}
@group(1u) @binding(0u) var<uniform> context: Context;
@vertex
fn main(input: VSInput) -> VSOutput {
var output: VSOutput;
output.glPosition = context.mvp * vec4<f32>(input.aPosition, 0.0f, 1.0f);
output.vColor = input.aColor;
output.vUv = input.aUv;
return output;
}
+44
View File
@@ -0,0 +1,44 @@
static const unsigned char tri_color_vert_wgsl[] = {
0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x20, 0x7b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x6d, 0x76, 0x70, 0x3a, 0x20, 0x6d, 0x61, 0x74, 0x34, 0x78, 0x34,
0x3c, 0x66, 0x33, 0x32, 0x3e, 0x2c, 0x20, 0x2f, 0x2f, 0x20, 0x4d, 0x6f, 0x64, 0x65, 0x6c, 0x2d,
0x56, 0x69, 0x65, 0x77, 0x2d, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20,
0x6d, 0x61, 0x74, 0x72, 0x69, 0x78, 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63,
0x74, 0x20, 0x56, 0x53, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x40, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x30, 0x75, 0x29, 0x20, 0x61, 0x50,
0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x76, 0x65, 0x63, 0x32, 0x3c, 0x66, 0x33,
0x32, 0x3e, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x40, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f,
0x6e, 0x28, 0x31, 0x75, 0x29, 0x20, 0x61, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x20, 0x76, 0x65,
0x63, 0x34, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x40, 0x6c, 0x6f,
0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x32, 0x75, 0x29, 0x20, 0x61, 0x55, 0x76, 0x3a, 0x20,
0x76, 0x65, 0x63, 0x32, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x2c, 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x73,
0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x56, 0x53, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x7b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x40, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x30,
0x75, 0x29, 0x20, 0x76, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x20, 0x76, 0x65, 0x63, 0x34, 0x3c,
0x66, 0x33, 0x32, 0x3e, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x40, 0x6c, 0x6f, 0x63, 0x61, 0x74,
0x69, 0x6f, 0x6e, 0x28, 0x31, 0x75, 0x29, 0x20, 0x76, 0x55, 0x76, 0x3a, 0x20, 0x76, 0x65, 0x63,
0x32, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x40, 0x62, 0x75, 0x69,
0x6c, 0x74, 0x69, 0x6e, 0x28, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x29, 0x20, 0x67,
0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x76, 0x65, 0x63, 0x34, 0x3c,
0x66, 0x33, 0x32, 0x3e, 0x2c, 0x0a, 0x7d, 0x0a, 0x0a, 0x40, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x28,
0x31, 0x75, 0x29, 0x20, 0x40, 0x62, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x28, 0x30, 0x75, 0x29,
0x20, 0x76, 0x61, 0x72, 0x3c, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x3e, 0x20, 0x63, 0x6f,
0x6e, 0x74, 0x65, 0x78, 0x74, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x3b, 0x0a,
0x0a, 0x40, 0x76, 0x65, 0x72, 0x74, 0x65, 0x78, 0x0a, 0x66, 0x6e, 0x20, 0x6d, 0x61, 0x69, 0x6e,
0x28, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x3a, 0x20, 0x56, 0x53, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x29,
0x20, 0x2d, 0x3e, 0x20, 0x56, 0x53, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x7b, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x3a, 0x20, 0x56,
0x53, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x75, 0x74,
0x70, 0x75, 0x74, 0x2e, 0x67, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d,
0x20, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x2e, 0x6d, 0x76, 0x70, 0x20, 0x2a, 0x20, 0x76,
0x65, 0x63, 0x34, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x2e, 0x61,
0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x66, 0x2c, 0x20,
0x31, 0x2e, 0x30, 0x66, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x75, 0x74, 0x70, 0x75,
0x74, 0x2e, 0x76, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x69, 0x6e, 0x70, 0x75, 0x74,
0x2e, 0x61, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x75, 0x74,
0x70, 0x75, 0x74, 0x2e, 0x76, 0x55, 0x76, 0x20, 0x3d, 0x20, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x2e,
0x61, 0x55, 0x76, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e,
0x20, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x3b, 0x0a, 0x7d, 0x0a
};
static const unsigned int tri_color_vert_wgsl_len = 635;
@@ -0,0 +1,27 @@
struct Context {
mvp: mat4x4<f32>, // Model-View-Projection matrix
};
struct VSInput {
@location(0u) aPosition: vec2<f32>,
@location(1u) aColor: vec4<f32>,
@location(2u) aUv: vec2<f32>,
};
struct VSOutput {
@location(0u) vColor: vec4<f32>,
@location(1u) vUv: vec2<f32>,
@builtin(position) glPosition: vec4<f32>,
}
@group(1u) @binding(0u) var<uniform> context: Context;
@vertex
fn main(input: VSInput) -> VSOutput {
var output: VSOutput;
output.glPosition = context.mvp * vec4<f32>(input.aPosition, 0.0f, 1.0f);
output.vColor = input.aColor;
output.vUv = input.aUv;
return output;
}
+44
View File
@@ -0,0 +1,44 @@
static const unsigned char tri_texture_vert_wgsl[] = {
0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x20, 0x7b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x6d, 0x76, 0x70, 0x3a, 0x20, 0x6d, 0x61, 0x74, 0x34, 0x78, 0x34,
0x3c, 0x66, 0x33, 0x32, 0x3e, 0x2c, 0x20, 0x2f, 0x2f, 0x20, 0x4d, 0x6f, 0x64, 0x65, 0x6c, 0x2d,
0x56, 0x69, 0x65, 0x77, 0x2d, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20,
0x6d, 0x61, 0x74, 0x72, 0x69, 0x78, 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63,
0x74, 0x20, 0x56, 0x53, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x40, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x30, 0x75, 0x29, 0x20, 0x61, 0x50,
0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x76, 0x65, 0x63, 0x32, 0x3c, 0x66, 0x33,
0x32, 0x3e, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x40, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f,
0x6e, 0x28, 0x31, 0x75, 0x29, 0x20, 0x61, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x20, 0x76, 0x65,
0x63, 0x34, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x40, 0x6c, 0x6f,
0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x32, 0x75, 0x29, 0x20, 0x61, 0x55, 0x76, 0x3a, 0x20,
0x76, 0x65, 0x63, 0x32, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x2c, 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x73,
0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x56, 0x53, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x7b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x40, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x30,
0x75, 0x29, 0x20, 0x76, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x20, 0x76, 0x65, 0x63, 0x34, 0x3c,
0x66, 0x33, 0x32, 0x3e, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x40, 0x6c, 0x6f, 0x63, 0x61, 0x74,
0x69, 0x6f, 0x6e, 0x28, 0x31, 0x75, 0x29, 0x20, 0x76, 0x55, 0x76, 0x3a, 0x20, 0x76, 0x65, 0x63,
0x32, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x40, 0x62, 0x75, 0x69,
0x6c, 0x74, 0x69, 0x6e, 0x28, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x29, 0x20, 0x67,
0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x76, 0x65, 0x63, 0x34, 0x3c,
0x66, 0x33, 0x32, 0x3e, 0x2c, 0x0a, 0x7d, 0x0a, 0x0a, 0x40, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x28,
0x31, 0x75, 0x29, 0x20, 0x40, 0x62, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x28, 0x30, 0x75, 0x29,
0x20, 0x76, 0x61, 0x72, 0x3c, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x3e, 0x20, 0x63, 0x6f,
0x6e, 0x74, 0x65, 0x78, 0x74, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x3b, 0x0a,
0x0a, 0x40, 0x76, 0x65, 0x72, 0x74, 0x65, 0x78, 0x0a, 0x66, 0x6e, 0x20, 0x6d, 0x61, 0x69, 0x6e,
0x28, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x3a, 0x20, 0x56, 0x53, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x29,
0x20, 0x2d, 0x3e, 0x20, 0x56, 0x53, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x7b, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x76, 0x61, 0x72, 0x20, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x3a, 0x20, 0x56,
0x53, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x75, 0x74,
0x70, 0x75, 0x74, 0x2e, 0x67, 0x6c, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d,
0x20, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x2e, 0x6d, 0x76, 0x70, 0x20, 0x2a, 0x20, 0x76,
0x65, 0x63, 0x34, 0x3c, 0x66, 0x33, 0x32, 0x3e, 0x28, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x2e, 0x61,
0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x66, 0x2c, 0x20,
0x31, 0x2e, 0x30, 0x66, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x75, 0x74, 0x70, 0x75,
0x74, 0x2e, 0x76, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x69, 0x6e, 0x70, 0x75, 0x74,
0x2e, 0x61, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x75, 0x74,
0x70, 0x75, 0x74, 0x2e, 0x76, 0x55, 0x76, 0x20, 0x3d, 0x20, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x2e,
0x61, 0x55, 0x76, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e,
0x20, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x3b, 0x0a, 0x7d, 0x0a
};
static const unsigned int tri_texture_vert_wgsl_len = 635;
+7
View File
@@ -0,0 +1,7 @@
#include "color.frag.wgsl.h"
#include "linepoint.vert.wgsl.h"
#include "texture_advanced.frag.wgsl.h"
#include "texture_rgb.frag.wgsl.h"
#include "texture_rgba.frag.wgsl.h"
#include "tri_color.vert.wgsl.h"
#include "tri_texture.vert.wgsl.h"
+8
View File
@@ -24,6 +24,7 @@
#define SDL_sysvideo_h_
#include <SDL3/SDL_vulkan.h>
#include <SDL3/SDL_wgpu.h>
#include "SDL_surface_c.h"
@@ -371,6 +372,13 @@ struct SDL_VideoDevice
void (*Metal_DestroyView)(SDL_VideoDevice *_this, SDL_MetalView view);
void *(*Metal_GetLayer)(SDL_VideoDevice *_this, SDL_MetalView view);
/* * * */
/*
* Experimental WebGPU support
*/
bool (*WGPU_CreateSurface)(SDL_VideoDevice *_this, SDL_Window *window, WGPUInstance instance, WGPUSurface *surface);
void (*WGPU_DestroySurface)(WGPUSurface surface);
/* * * */
/*
* Event manager functions
+18
View File
@@ -6646,6 +6646,24 @@ void *SDL_Metal_GetLayer(SDL_MetalView view)
}
}
bool SDL_WGPU_CreateSurface(SDL_Window *window, WGPUInstance instance, WGPUSurface *surface)
{
if (_this && _this->WGPU_CreateSurface) {
return _this->WGPU_CreateSurface(_this, window, instance, surface);
} else {
return SDL_SetError("WebGPU is not supported.");
}
}
void SDL_WGPU_DestroySurface(WGPUSurface surface)
{
if (_this && _this->WGPU_DestroySurface) {
_this->WGPU_DestroySurface(surface);
} else {
SDL_SetError("WebGPU is not supported.");
}
}
#if defined(SDL_VIDEO_DRIVER_X11) || defined(SDL_VIDEO_DRIVER_WAYLAND) || defined(SDL_VIDEO_DRIVER_EMSCRIPTEN)
const char *SDL_GetCSSCursorName(SDL_SystemCursor id, const char **fallback_name)
{
+125
View File
@@ -0,0 +1,125 @@
// BSD 3-Clause License
//
// Copyright (c) 2019, "WebGPU native" developers
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// TODO: We already have the entire webgpu header in the GPU backend, we should just use that instead of this.
#include "SDL_internal.h"
// define to prevent C++ name mangling on extern functions
#define WGPU_EXTERN extern "C"
#ifndef WEBGPU_H_
#define NO_WEBGPU_HEADER
#endif
#ifdef NO_WEBGPU_HEADER
#if !defined(WGPU_FUNCTION_ATTRIBUTE)
#define WGPU_FUNCTION_ATTRIBUTE
#endif
#if !defined(WGPU_STRLEN)
#define WGPU_STRLEN (SIZE_MAX)
#endif
typedef enum WGPUSType
{
WGPUSType_ShaderSourceSPIRV = 0x00000001,
WGPUSType_ShaderSourceWGSL = 0x00000002,
WGPUSType_RenderPassMaxDrawCount = 0x00000003,
WGPUSType_SurfaceSourceMetalLayer = 0x00000004,
WGPUSType_SurfaceSourceWindowsHWND = 0x00000005,
WGPUSType_SurfaceSourceXlibWindow = 0x00000006,
WGPUSType_SurfaceSourceWaylandSurface = 0x00000007,
WGPUSType_SurfaceSourceAndroidNativeWindow = 0x00000008,
WGPUSType_SurfaceSourceXCBWindow = 0x00000009,
WGPUSType_SurfaceColorManagement = 0x0000000A,
WGPUSType_RequestAdapterWebXROptions = 0x0000000B,
WGPUSType_TextureComponentSwizzleDescriptor = 0x0000000C,
WGPUSType_ExternalTextureBindingLayout = 0x0000000D,
WGPUSType_ExternalTextureBindingEntry = 0x0000000E,
WGPUSType_CompatibilityModeLimits = 0x0000000F,
WGPUSType_TextureBindingViewDimension = 0x00000010,
WGPUSType_EmscriptenSurfaceSourceCanvasHTMLSelector = 0x00040000,
WGPUSType_DawnCompilationMessageUtf16 = 0x0005003F,
WGPUSType_Force32 = 0x7FFFFFFF
} WGPUSType;
typedef struct WGPUChainedStruct
{
struct WGPUChainedStruct *next;
WGPUSType sType;
} WGPUChainedStruct;
typedef struct WGPUStringView
{
char const *data;
size_t length;
} WGPUStringView;
typedef struct WGPUSurfaceDescriptor
{
WGPUChainedStruct *nextInChain;
WGPUStringView label;
} WGPUSurfaceDescriptor;
typedef struct WGPUSurfaceSourceWaylandSurface
{
WGPUChainedStruct chain;
void *display;
void *surface;
} WGPUSurfaceSourceWaylandSurface;
typedef struct WGPUSurfaceSourceXlibWindow
{
WGPUChainedStruct chain;
void *display;
uint64_t window;
} WGPUSurfaceSourceXlibWindow;
typedef struct WGPUSurfaceSourceWindowsHWND
{
WGPUChainedStruct chain;
void *hinstance;
void *hwnd;
} WGPUSurfaceSourceWindowsHWND;
typedef struct WGPUEmscriptenSurfaceSourceCanvasHTMLSelector
{
WGPUChainedStruct chain;
WGPUStringView selector;
} WGPUEmscriptenSurfaceSourceCanvasHTMLSelector;
typedef WGPUSurface (*WGPUProcInstanceCreateSurface)(WGPUInstance instance, WGPUSurfaceDescriptor const *descriptor) WGPU_FUNCTION_ATTRIBUTE;
WGPU_EXTERN WGPUSurface wgpuInstanceCreateSurface(WGPUInstance instance, WGPUSurfaceDescriptor const *descriptor) WGPU_FUNCTION_ATTRIBUTE;
WGPU_EXTERN void wgpuSurfaceRelease(WGPUSurface surface) WGPU_FUNCTION_ATTRIBUTE;
#endif
@@ -32,6 +32,7 @@
#include "SDL_emscriptenframebuffer.h"
#include "SDL_emscriptenevents.h"
#include "SDL_emscriptenmouse.h"
#include "SDL_emscriptenwgpu.h"
#define EMSCRIPTENVID_DRIVER_NAME "emscripten"
@@ -187,6 +188,11 @@ static SDL_VideoDevice *Emscripten_CreateDevice(void)
device->GL_SwapWindow = Emscripten_GLES_SwapWindow;
device->GL_DestroyContext = Emscripten_GLES_DestroyContext;
#ifdef SDL_VIDEO_WEBGPU
device->WGPU_CreateSurface = Emscripten_WGPU_CreateSurface;
device->WGPU_DestroySurface = Emscripten_WGPU_DestroySurface;
#endif
device->free = Emscripten_DeleteDevice;
Emscripten_ListenSystemTheme();
+24
View File
@@ -0,0 +1,24 @@
#ifndef SDL_emscriptenwgpu_h_
#define SDL_emscriptenwgpu_h_
#include <SDL3/SDL_wgpu.h>
#if defined(SDL_VIDEO_WEBGPU) && defined(SDL_VIDEO_DRIVER_EMSCRIPTEN)
// Dawn's a C++ lib so we'll have to do this to prevent any name mangling.
#ifdef __cplusplus
extern "C" {
#else
extern
#endif
bool Emscripten_WGPU_CreateSurface(SDL_VideoDevice *_this, SDL_Window *window, WGPUInstance instance, WGPUSurface *surface);
void Emscripten_WGPU_DestroySurface(WGPUSurface surface);
#ifdef __cplusplus
}
#endif
#endif
#endif // SDL_emscriptenwgpu_h_
@@ -0,0 +1,45 @@
#include "SDL_internal.h"
// TODO: Does this even need to be a C++ file?
#if defined(SDL_VIDEO_WEBGPU) && defined(SDL_VIDEO_DRIVER_EMSCRIPTEN)
#include "../SDL_sysvideo.h"
#include "../SDL_wgpu_defs.h"
#include "SDL_emscriptenwgpu.h"
bool Emscripten_WGPU_CreateSurface(SDL_VideoDevice *_this, SDL_Window *window, WGPUInstance instance, WGPUSurface *surface)
{
if (!surface) {
SDL_SetError("Surface pointer is NULL!");
return false;
}
SDL_PropertiesID windowProperties = SDL_GetWindowProperties(window);
const char *canvas = SDL_GetStringProperty(windowProperties, SDL_PROP_WINDOW_EMSCRIPTEN_CANVAS_ID_STRING, 0);
WGPUSurfaceDescriptor desc;
WGPUEmscriptenSurfaceSourceCanvasHTMLSelector source;
source.selector.data = canvas;
source.chain.sType = WGPUSType_EmscriptenSurfaceSourceCanvasHTMLSelector;
source.chain.next = NULL;
desc.label = (WGPUStringView){ NULL, WGPU_STRLEN };
desc.nextInChain = &source.chain;
*surface = wgpuInstanceCreateSurface(instance, &desc);
if (!surface) {
SDL_SetError("Failed to create WebGPU surface!");
return false;
}
return true;
}
void Emscripten_WGPU_DestroySurface(WGPUSurface surface) { wgpuSurfaceRelease(surface); }
#endif
+6
View File
@@ -38,6 +38,7 @@
#include "SDL_waylandframebuffer.h"
#include "SDL_waylandvulkan.h"
#include "SDL_waylandwgpu.h"
#include "SDL_waylandwindow.h"
#include <fcntl.h>
@@ -778,6 +779,11 @@ static SDL_VideoDevice *CreateWaylandDevice(bool require_preferred_protocols)
device->Vulkan_GetPresentationSupport = Wayland_Vulkan_GetPresentationSupport;
#endif
#ifdef SDL_VIDEO_WEBGPU
device->WGPU_CreateSurface = Wayland_WGPU_CreateSurface;
device->WGPU_DestroySurface = Wayland_WGPU_DestroySurface;
#endif
device->free = Wayland_DeleteDevice;
device->device_caps = VIDEO_DEVICE_CAPS_MODE_SWITCHING_EMULATED |
+24
View File
@@ -0,0 +1,24 @@
#ifndef SDL_waylandwgpu_h_
#define SDL_waylandwgpu_h_
#include <SDL3/SDL_wgpu.h>
#if defined(SDL_VIDEO_WEBGPU) && defined(SDL_VIDEO_DRIVER_WAYLAND)
// Dawn's a C++ lib so we'll have to do this to prevent any name mangling.
#ifdef __cplusplus
extern "C" {
#else
extern
#endif
bool Wayland_WGPU_CreateSurface(SDL_VideoDevice *_this, SDL_Window *window, WGPUInstance instance, WGPUSurface *surface);
void Wayland_WGPU_DestroySurface(WGPUSurface surface);
#ifdef __cplusplus
}
#endif
#endif
#endif // SDL_waylandwgpu_h_
@@ -0,0 +1,57 @@
// NOTE:
// Dawn's a C++ library.
// So, if you want to use C++, you have to have a .cpp file.
// A couple changes though:
// C++ isn't a fan of forward declaring enums, so we can't use SDL_waylandvideo.h,
// but that's fine; we're not using anything that isn't in SDL_sysvideo.h.
// I also had to add a cast for SDL_GetPointerProperty to wl_display/surface.
// UPDATE (2026-08-10): Yeah, I'll be perfectly honest. I probably just screwed up the build process.
#include "SDL_internal.h"
#if defined(SDL_VIDEO_WEBGPU) && defined(SDL_VIDEO_DRIVER_WAYLAND)
#include "../SDL_sysvideo.h"
#include "../SDL_wgpu_defs.h"
#include "SDL_waylandwgpu.h"
bool
Wayland_WGPU_CreateSurface(SDL_VideoDevice *_this, SDL_Window *window, WGPUInstance instance, WGPUSurface *_surface)
{
if(!_surface){
SDL_SetError("Surface pointer is NULL!");
return false;
}
SDL_PropertiesID windowProperties = SDL_GetWindowProperties(window);
struct wl_display *display = (wl_display *)SDL_GetPointerProperty(windowProperties, SDL_PROP_WINDOW_WAYLAND_DISPLAY_POINTER, 0);
struct wl_surface *surface = (wl_surface *)SDL_GetPointerProperty(windowProperties, SDL_PROP_WINDOW_WAYLAND_SURFACE_POINTER, 0);
WGPUSurfaceDescriptor desc;
WGPUSurfaceSourceWaylandSurface source;
source.chain.sType = WGPUSType_SurfaceSourceWaylandSurface;
source.chain.next = NULL;
source.surface = surface;
source.display = display;
// TODO: I don't know the convention on what label the surface should have?
// I'll just leave it NULL for now. - TheStickmahn
desc.label = (WGPUStringView){ NULL, WGPU_STRLEN };
desc.nextInChain = &source.chain;
// Dawn doesn't support dynamically loading, so we're just always using wgpuInstanceCreateSurface.
*_surface = wgpuInstanceCreateSurface(instance, &desc);
if(!_surface){
SDL_SetError("Failed to create WebGPU surface!");
return false;
}
return true;
}
void Wayland_WGPU_DestroySurface(WGPUSurface surface) { wgpuSurfaceRelease(surface); }
#endif
+5
View File
@@ -35,6 +35,7 @@
#include "SDL_windowsmessagebox.h"
#include "SDL_windowsrawinput.h"
#include "SDL_windowsvulkan.h"
#include "SDL_windowswgpu.h"
#if !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES))
#include <shobjidl.h>
@@ -425,6 +426,10 @@ static SDL_VideoDevice *WIN_CreateDevice(void)
device->Vulkan_DestroySurface = WIN_Vulkan_DestroySurface;
device->Vulkan_GetPresentationSupport = WIN_Vulkan_GetPresentationSupport;
#endif
#ifdef SDL_VIDEO_WEBGPU
device->WGPU_CreateSurface = WIN_WGPU_CreateSurface;
device->WGPU_DestroySurface = WIN_WGPU_DestroySurface;
#endif
#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)
device->StartTextInput = WIN_StartTextInput;
+24
View File
@@ -0,0 +1,24 @@
#ifndef SDL_windowswgpu_h_
#define SDL_windowswgpu_h_
#include <SDL3/SDL_wgpu.h>
#if defined(SDL_VIDEO_WEBGPU) && defined(SDL_VIDEO_DRIVER_WINDOWS)
// Dawn's a C++ lib so we'll have to do this to prevent any name mangling.
#ifdef __cplusplus
extern "C" {
#else
extern
#endif
bool WIN_WGPU_CreateSurface(SDL_VideoDevice *_this, SDL_Window *window, WGPUInstance instance, WGPUSurface *surface);
void WIN_WGPU_DestroySurface(WGPUSurface surface);
#ifdef __cplusplus
}
#endif
#endif
#endif // SDL_windowswgpu_h_
@@ -0,0 +1,39 @@
#include "SDL_internal.h"
#if defined(SDL_VIDEO_WEBGPU) && defined(SDL_VIDEO_DRIVER_WINDOWS)
#include "SDL_windowsvideo.h"
// We have to add some random stuff here to appease Dawn.
// I don't know why, but we have to.
#if defined(_DEBUG)
#pragma comment(lib, "dxguid.lib")
#pragma comment(lib, "OneCore")
#endif
#include "../SDL_wgpu_defs.h"
#include "SDL_windowswgpu.h"
bool WIN_WGPU_CreateSurface(SDL_VideoDevice *_this, SDL_Window *window, WGPUInstance instance, WGPUSurface *surface)
{
SDL_PropertiesID windowProperties = SDL_GetWindowProperties(window);
void *hwnd = SDL_GetPointerProperty(windowProperties, SDL_PROP_WINDOW_WIN32_HWND_POINTER, 0);
void *hinstance = SDL_GetPointerProperty(windowProperties, SDL_PROP_WINDOW_WIN32_INSTANCE_POINTER, 0);
WGPUSurfaceDescriptor desc;
WGPUSurfaceSourceWindowsHWND source;
source.hwnd = hwnd;
source.hinstance = hinstance;
source.chain.sType = WGPUSType_SurfaceSourceWindowsHWND;
source.chain.next = NULL;
desc.label = { NULL, WGPU_STRLEN };
desc.nextInChain = &source.chain;
return wgpuInstanceCreateSurface(instance, &desc);
}
void WIN_WGPU_DestroySurface(WGPUSurface surface) { wgpuSurfaceRelease(surface); }
#endif
+6
View File
@@ -35,6 +35,7 @@
#include "SDL_x11pen.h"
#include "SDL_x11touch.h"
#include "SDL_x11video.h"
#include "SDL_x11wgpu.h"
#include "SDL_x11xfixes.h"
#include "SDL_x11xinput2.h"
#include "SDL_x11messagebox.h"
@@ -270,6 +271,11 @@ static SDL_VideoDevice *X11_CreateDevice(void)
device->Vulkan_GetPresentationSupport = X11_Vulkan_GetPresentationSupport;
#endif
#ifdef SDL_VIDEO_WEBGPU
device->WGPU_CreateSurface = X11_WGPU_CreateSurface;
device->WGPU_DestroySurface = X11_WGPU_DestroySurface;
#endif
#ifdef SDL_USE_LIBDBUS
if (SDL_SystemTheme_Init())
device->system_theme = SDL_SystemTheme_Get();
+23
View File
@@ -0,0 +1,23 @@
#ifndef SDL_x11wgpu_h_
#define SDL_x11wgpu_h_
#include <SDL3/SDL_wgpu.h>
#if defined(SDL_VIDEO_WEBGPU) && defined(SDL_VIDEO_DRIVER_X11)
#ifdef __cplusplus
extern "C" {
#else
extern
#endif
bool X11_WGPU_CreateSurface(SDL_VideoDevice *_this, SDL_Window *window, WGPUInstance instance, WGPUSurface *surface);
void X11_WGPU_DestroySurface(WGPUSurface surface);
#ifdef __cplusplus
}
#endif
#endif
#endif // SDL_x11wgpu_h_
+49
View File
@@ -0,0 +1,49 @@
// NOTE: We had to remove SDL_x11video.h since that uses the register keyword which was removed in C++17.
// That means we can't use Display, but that's not an issue since we're using a pointer to Display, which is a struct.
// We'll just make it a generic struct pointer.
#include "SDL_internal.h"
#if defined(SDL_VIDEO_WEBGPU) && defined(SDL_VIDEO_DRIVER_X11)
#include "../SDL_sysvideo.h"
#include "../SDL_wgpu_defs.h"
#include "SDL_x11wgpu.h"
bool X11_WGPU_CreateSurface(SDL_VideoDevice *_this, SDL_Window *window, WGPUInstance instance, WGPUSurface *surface)
{
if (!surface) {
SDL_SetError("Surface pointer is NULL!");
return false;
}
SDL_PropertiesID windowProperties = SDL_GetWindowProperties(window);
struct Display *x11_display = (Display *)SDL_GetPointerProperty(windowProperties, SDL_PROP_WINDOW_X11_DISPLAY_POINTER, 0);
int x11_window = SDL_GetNumberProperty(windowProperties, SDL_PROP_WINDOW_X11_WINDOW_NUMBER, 0);
WGPUSurfaceDescriptor desc;
WGPUSurfaceSourceXlibWindow source;
source.window = x11_window;
source.display = x11_display;
source.chain.sType = WGPUSType_SurfaceSourceXlibWindow;
source.chain.next = NULL;
desc.label = (WGPUStringView){ NULL, WGPU_STRLEN };
desc.nextInChain = &source.chain;
*surface = wgpuInstanceCreateSurface(instance, &desc);
if(!surface){
SDL_SetError("Failed to create WebGPU surface!");
return false;
}
return true;
}
void X11_WGPU_DestroySurface(WGPUSurface surface) { wgpuSurfaceRelease(surface); }
#endif
+1
View File
@@ -17,6 +17,7 @@
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
#include <SDL3/SDL_vulkan.h>
#include <SDL3/SDL_wgpu.h>
#if !defined(SDL_PLATFORM_ANDROID)
extern SDL_DECLSPEC void SDLCALL SDL_GetAndroidActivity(void);