diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dc2691d80..ce23c2415 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -104,13 +104,13 @@ jobs: run: ./odin check examples/all -vet -strict-style -target:linux_arm64 timeout-minutes: 10 build_windows: - runs-on: windows-2019 + runs-on: windows-2022 steps: - uses: actions/checkout@v1 - name: build Odin shell: cmd run: | - call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat ./build.bat 1 - name: Odin version run: ./odin version @@ -121,58 +121,65 @@ jobs: - name: Odin check shell: cmd run: | - call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat odin check examples/demo -vet timeout-minutes: 10 - name: Odin run shell: cmd run: | - call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat odin run examples/demo timeout-minutes: 10 - name: Odin run -debug shell: cmd run: | - call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat odin run examples/demo -debug timeout-minutes: 10 - name: Odin check examples/all shell: cmd run: | - call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat odin check examples/all -strict-style timeout-minutes: 10 - name: Core library tests shell: cmd run: | - call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat cd tests\core call build.bat timeout-minutes: 10 - name: Vendor library tests shell: cmd run: | - call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat cd tests\vendor call build.bat timeout-minutes: 10 - name: Odin internals tests shell: cmd run: | - call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat cd tests\internal call build.bat timeout-minutes: 10 + - name: Odin documentation tests + shell: cmd + run: | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat + cd tests\documentation + call build.bat + timeout-minutes: 10 - name: core:math/big tests shell: cmd run: | - call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat cd tests\core\math\big call build.bat timeout-minutes: 10 - name: Odin check examples/all for Windows 32bits shell: cmd run: | - call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat odin check examples/all -strict-style -target:windows_i386 timeout-minutes: 10 diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 7fe7513e0..67d0396c1 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -7,18 +7,18 @@ on: jobs: build_windows: - runs-on: windows-2019 + runs-on: windows-2022 steps: - uses: actions/checkout@v1 - name: build Odin shell: cmd run: | - call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat ./build.bat 1 1 - name: Odin run shell: cmd run: | - call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat odin run examples/demo - name: Copy artifacts run: | diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 341a09409..10f193056 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Close Stale Issues - uses: actions/stale@v4.1.0 + uses: actions/stale@v7.0.0 with: # stale-issue-message: | # Hello! @@ -36,7 +36,7 @@ jobs: # The motivation for this automation is to help prioritize issues in the backlog and not ignore, reject, or belittle anyone.. days-before-stale: 120 - days-before-close: 30 + days-before-close: -1 exempt-draft-pr: true ascending: true operations-per-run: 1000 diff --git a/.gitignore b/.gitignore index 67314e23a..824e0c203 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,8 @@ bld/ [Oo]bj/ [Ll]og/ ![Cc]ore/[Ll]og/ +tests/documentation/verify/ +tests/documentation/all.odin-doc # Visual Studio 2015 cache/options directory .vs/ # Visual Studio Code options directory diff --git a/README.md b/README.md index f99174c46..4df71015d 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@
- + diff --git a/build.bat b/build.bat index 7391bd95f..b7537fba6 100644 --- a/build.bat +++ b/build.bat @@ -3,18 +3,20 @@ setlocal EnableDelayedExpansion where /Q cl.exe || ( - set __VSCMD_ARG_NO_LOGO=1 - for /f "tokens=*" %%i in ('"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -latest -requires Microsoft.VisualStudio.Workload.NativeDesktop -property installationPath') do set VS=%%i - if "!VS!" equ "" ( - echo ERROR: Visual Studio installation not found - exit /b 1 - ) - call "!VS!\VC\Auxiliary\Build\vcvarsall.bat" amd64 || exit /b 1 + set __VSCMD_ARG_NO_LOGO=1 + for /f "tokens=*" %%i in ('"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -latest -requires Microsoft.VisualStudio.Workload.NativeDesktop -property installationPath') do set VS=%%i + if "!VS!" equ "" ( + echo ERROR: Visual Studio installation not found + exit /b 1 + ) + call "!VS!\VC\Auxiliary\Build\vcvarsall.bat" amd64 || exit /b 1 ) if "%VSCMD_ARG_TGT_ARCH%" neq "x64" ( - echo ERROR: please run this from MSVC x64 native tools command prompt, 32-bit target is not supported! - exit /b 1 + if "%ODIN_IGNORE_MSVC_CHECK%" == "" ( + echo ERROR: please run this from MSVC x64 native tools command prompt, 32-bit target is not supported! + exit /b 1 + ) ) for /f "usebackq tokens=1,2 delims=,=- " %%i in (`wmic os get LocalDateTime /value`) do @if %%i==LocalDateTime ( @@ -48,8 +50,11 @@ set odin_version_raw="dev-%curr_year%-%curr_month%" set compiler_flags= -nologo -Oi -TP -fp:precise -Gm- -MP -FC -EHsc- -GR- -GF set compiler_defines= -DODIN_VERSION_RAW=\"%odin_version_raw%\" +if not exist .git\ goto skip_git_hash for /f %%i in ('git rev-parse --short HEAD') do set GIT_SHA=%%i if %ERRORLEVEL% equ 0 set compiler_defines=%compiler_defines% -DGIT_SHA=\"%GIT_SHA%\" +:skip_git_hash + if %nightly% equ 1 set compiler_defines=%compiler_defines% -DNIGHTLY if %release_mode% EQU 0 ( rem Debug @@ -62,12 +67,14 @@ if %release_mode% EQU 0 ( rem Debug set compiler_warnings= ^ -W4 -WX ^ -wd4100 -wd4101 -wd4127 -wd4146 ^ + -wd4505 ^ -wd4456 -wd4457 set compiler_includes= ^ /Isrc\ set libs= ^ kernel32.lib ^ + Synchronization.lib ^ bin\llvm\windows\LLVM-C.lib set linker_flags= -incremental:no -opt:ref -subsystem:console @@ -94,4 +101,4 @@ if %release_mode% EQU 0 odin run examples/demo del *.obj > NUL 2> NUL -:end_of_build \ No newline at end of file +:end_of_build diff --git a/build_odin.sh b/build_odin.sh index 5ecb7709a..9b90a80e2 100755 --- a/build_odin.sh +++ b/build_odin.sh @@ -6,13 +6,18 @@ set -eu : ${CXXFLAGS=} : ${LDFLAGS=} : ${ODIN_VERSION=dev-$(date +"%Y-%m")} +: ${GIT_SHA=} CPPFLAGS="$CPPFLAGS -DODIN_VERSION_RAW=\"$ODIN_VERSION\"" CXXFLAGS="$CXXFLAGS -std=c++14" LDFLAGS="$LDFLAGS -pthread -lm -lstdc++" -GIT_SHA=$(git rev-parse --short HEAD || :) -if [ "$GIT_SHA" ]; then CPPFLAGS="$CPPFLAGS -DGIT_SHA=\"$GIT_SHA\""; fi +if [ -d ".git" ]; then + GIT_SHA=$(git rev-parse --short HEAD || :) + if [ "$GIT_SHA" ]; then + CPPFLAGS="$CPPFLAGS -DGIT_SHA=\"$GIT_SHA\"" + fi +fi DISABLED_WARNINGS="-Wno-switch -Wno-macro-redefined -Wno-unused-value" OS=$(uname) @@ -25,11 +30,11 @@ panic() { version() { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; } config_darwin() { - ARCH=$(uname -m) + local ARCH=$(uname -m) : ${LLVM_CONFIG=llvm-config} # allow for arm only llvm's with version 13 - if [ ARCH == arm64 ]; then + if [ "${ARCH}" == "arm64" ]; then MIN_LLVM_VERSION=("13.0.0") else # allow for x86 / amd64 all llvm versions beginning from 11 @@ -37,7 +42,7 @@ config_darwin() { fi if [ $(version $($LLVM_CONFIG --version)) -lt $(version $MIN_LLVM_VERSION) ]; then - if [ ARCH == arm64 ]; then + if [ "${ARCH}" == "arm64" ]; then panic "Requirement: llvm-config must be base version 13 for arm64" else panic "Requirement: llvm-config must be base version greater than 11 for amd64/x86" @@ -50,7 +55,7 @@ config_darwin() { panic "Requirement: llvm-config must be base version smaller than 15" fi - LDFLAGS="$LDFLAGS -liconv -ldl" + LDFLAGS="$LDFLAGS -liconv -ldl -framework System" CXXFLAGS="$CXXFLAGS $($LLVM_CONFIG --cxxflags --ldflags)" LDFLAGS="$LDFLAGS -lLLVM-C" } @@ -59,11 +64,11 @@ config_freebsd() { : ${LLVM_CONFIG=} if [ ! "$LLVM_CONFIG" ]; then - if which llvm-config11 > /dev/null 2>&1; then + if [ -x "$(command -v llvm-config11)" ]; then LLVM_CONFIG=llvm-config11 - elif which llvm-config12 > /dev/null 2>&1; then + elif [ -x "$(command -v llvm-config12)" ]; then LLVM_CONFIG=llvm-config12 - elif which llvm-config13 > /dev/null 2>&1; then + elif [ -x "$(command -v llvm-config13)" ]; then LLVM_CONFIG=llvm-config13 else panic "Unable to find LLVM-config" @@ -86,12 +91,14 @@ config_linux() { : ${LLVM_CONFIG=} if [ ! "$LLVM_CONFIG" ]; then - if which llvm-config > /dev/null 2>&1; then + if [ -x "$(command -v llvm-config)" ]; then LLVM_CONFIG=llvm-config - elif which llvm-config-11 > /dev/null 2>&1; then + elif [ -x "$(command -v llvm-config-11)" ]; then LLVM_CONFIG=llvm-config-11 - elif which llvm-config-11-64 > /dev/null 2>&1; then + elif [ -x "$(command -v llvm-config-11-64)" ]; then LLVM_CONFIG=llvm-config-11-64 + elif [ -x "$(command -v llvm-config-14)" ]; then + LLVM_CONFIG=llvm-config-14 else panic "Unable to find LLVM-config" fi @@ -111,7 +118,7 @@ config_linux() { LDFLAGS="$LDFLAGS -ldl" CXXFLAGS="$CXXFLAGS $($LLVM_CONFIG --cxxflags --ldflags)" - LDFLAGS="$LDFLAGS $($LLVM_CONFIG --libs core native --system-libs --libfiles) -Wl,-rpath=\$ORIGIN" + LDFLAGS="$LDFLAGS $($LLVM_CONFIG --libs core native --system-libs --libfiles) -Wl,-rpath=\$ORIGIN" # Creates a copy of the llvm library in the build dir, this is meant to support compiler explorer. # The annoyance is that this copy can be cluttering the development folder. TODO: split staging folders @@ -128,13 +135,21 @@ build_odin() { EXTRAFLAGS="-O3" ;; release-native) - EXTRAFLAGS="-O3 -march=native" + local ARCH=$(uname -m) + if [ "${ARCH}" == "arm64" ]; then + # Use preferred flag for Arm (ie arm64 / aarch64 / etc) + EXTRAFLAGS="-O3 -mcpu=native" + else + # Use preferred flag for x86 / amd64 + EXTRAFLAGS="-O3 -march=native" + fi ;; nightly) EXTRAFLAGS="-DNIGHTLY -O3" ;; *) panic "Build mode unsupported!" + ;; esac set -x @@ -147,7 +162,7 @@ run_demo() { } have_which() { - if ! which which > /dev/null 2>&1; then + if ! command -v which > /dev/null 2>&1 ; then panic "Could not find \`which\`" fi } @@ -169,6 +184,7 @@ FreeBSD) ;; *) panic "Platform unsupported!" + ;; esac if [[ $# -eq 0 ]]; then diff --git a/core/bufio/lookahead_reader.odin b/core/bufio/lookahead_reader.odin index 7d6d7832c..f51c167b9 100644 --- a/core/bufio/lookahead_reader.odin +++ b/core/bufio/lookahead_reader.odin @@ -2,25 +2,25 @@ package bufio import "core:io" -// Loadahead_Reader provides io lookahead. +// Lookahead_Reader provides io lookahead. // This is useful for tokenizers/parsers. -// Loadahead_Reader is similar to bufio.Reader, but unlike bufio.Reader, Loadahead_Reader's buffer size +// Lookahead_Reader is similar to bufio.Reader, but unlike bufio.Reader, Lookahead_Reader's buffer size // will EXACTLY match the specified size, whereas bufio.Reader's buffer size may differ from the specified size. // This makes sure that the buffer will not be accidentally read beyond the expected size. -Loadahead_Reader :: struct { +Lookahead_Reader :: struct { r: io.Reader, buf: []byte, n: int, } -lookahead_reader_init :: proc(lr: ^Loadahead_Reader, r: io.Reader, buf: []byte) -> ^Loadahead_Reader { +lookahead_reader_init :: proc(lr: ^Lookahead_Reader, r: io.Reader, buf: []byte) -> ^Lookahead_Reader { lr.r = r lr.buf = buf lr.n = 0 return lr } -lookahead_reader_buffer :: proc(lr: ^Loadahead_Reader) -> []byte { +lookahead_reader_buffer :: proc(lr: ^Lookahead_Reader) -> []byte { return lr.buf[:lr.n] } @@ -28,7 +28,7 @@ lookahead_reader_buffer :: proc(lr: ^Loadahead_Reader) -> []byte { // lookahead_reader_peek returns a slice of the Lookahead_Reader which holds n bytes // If the Lookahead_Reader cannot hold enough bytes, it will read from the underlying reader to populate the rest. // NOTE: The returned buffer is not a copy of the underlying buffer -lookahead_reader_peek :: proc(lr: ^Loadahead_Reader, n: int) -> ([]byte, io.Error) { +lookahead_reader_peek :: proc(lr: ^Lookahead_Reader, n: int) -> ([]byte, io.Error) { switch { case n < 0: return nil, .Negative_Read @@ -58,13 +58,13 @@ lookahead_reader_peek :: proc(lr: ^Loadahead_Reader, n: int) -> ([]byte, io.Erro // lookahead_reader_peek_all returns a slice of the Lookahead_Reader populating the full buffer // If the Lookahead_Reader cannot hold enough bytes, it will read from the underlying reader to populate the rest. // NOTE: The returned buffer is not a copy of the underlying buffer -lookahead_reader_peek_all :: proc(lr: ^Loadahead_Reader) -> ([]byte, io.Error) { +lookahead_reader_peek_all :: proc(lr: ^Lookahead_Reader) -> ([]byte, io.Error) { return lookahead_reader_peek(lr, len(lr.buf)) } // lookahead_reader_consume drops the first n populated bytes from the Lookahead_Reader. -lookahead_reader_consume :: proc(lr: ^Loadahead_Reader, n: int) -> io.Error { +lookahead_reader_consume :: proc(lr: ^Lookahead_Reader, n: int) -> io.Error { switch { case n == 0: return nil @@ -78,6 +78,6 @@ lookahead_reader_consume :: proc(lr: ^Loadahead_Reader, n: int) -> io.Error { return nil } -lookahead_reader_consume_all :: proc(lr: ^Loadahead_Reader) -> io.Error { +lookahead_reader_consume_all :: proc(lr: ^Lookahead_Reader) -> io.Error { return lookahead_reader_consume(lr, lr.n) } diff --git a/core/bufio/read_writer.odin b/core/bufio/read_writer.odin index f9ae1ed45..3e6bd3aa0 100644 --- a/core/bufio/read_writer.odin +++ b/core/bufio/read_writer.odin @@ -14,51 +14,29 @@ read_writer_init :: proc(rw: ^Read_Writer, r: ^Reader, w: ^Writer) { } read_writer_to_stream :: proc(rw: ^Read_Writer) -> (s: io.Stream) { - s.stream_data = rw - s.stream_vtable = &_read_writer_vtable + s.procedure = _read_writer_procedure + s.data = rw return } @(private) -_read_writer_vtable := io.Stream_VTable{ - impl_read = proc(s: io.Stream, p: []byte) -> (n: int, err: io.Error) { - b := (^Read_Writer)(s.stream_data).r - return reader_read(b, p) - }, - impl_unread_byte = proc(s: io.Stream) -> io.Error { - b := (^Read_Writer)(s.stream_data).r - return reader_unread_byte(b) - }, - impl_read_rune = proc(s: io.Stream) -> (r: rune, size: int, err: io.Error) { - b := (^Read_Writer)(s.stream_data).r - return reader_read_rune(b) - }, - impl_unread_rune = proc(s: io.Stream) -> io.Error { - b := (^Read_Writer)(s.stream_data).r - return reader_unread_rune(b) - }, - impl_write_to = proc(s: io.Stream, w: io.Writer) -> (n: i64, err: io.Error) { - b := (^Read_Writer)(s.stream_data).r - return reader_write_to(b, w) - }, - impl_flush = proc(s: io.Stream) -> io.Error { - b := (^Read_Writer)(s.stream_data).w - return writer_flush(b) - }, - impl_write = proc(s: io.Stream, p: []byte) -> (n: int, err: io.Error) { - b := (^Read_Writer)(s.stream_data).w - return writer_write(b, p) - }, - impl_write_byte = proc(s: io.Stream, c: byte) -> io.Error { - b := (^Read_Writer)(s.stream_data).w - return writer_write_byte(b, c) - }, - impl_write_rune = proc(s: io.Stream, r: rune) -> (int, io.Error) { - b := (^Read_Writer)(s.stream_data).w - return writer_write_rune(b, r) - }, - impl_read_from = proc(s: io.Stream, r: io.Reader) -> (n: i64, err: io.Error) { - b := (^Read_Writer)(s.stream_data).w - return writer_read_from(b, r) - }, -} +_read_writer_procedure := proc(stream_data: rawptr, mode: io.Stream_Mode, p: []byte, offset: i64, whence: io.Seek_From) -> (n: i64, err: io.Error) { + rw := (^Read_Writer)(stream_data) + n_int: int + #partial switch mode { + case .Flush: + err = writer_flush(rw.w) + return + case .Read: + n_int, err = reader_read(rw.r, p) + n = i64(n_int) + return + case .Write: + n_int, err = writer_write(rw.w, p) + n = i64(n_int) + return + case .Query: + return io.query_utility({.Flush, .Read, .Write, .Query}) + } + return 0, .Empty +} \ No newline at end of file diff --git a/core/bufio/reader.odin b/core/bufio/reader.odin index 6bfc4cd9d..dc4e02c02 100644 --- a/core/bufio/reader.odin +++ b/core/bufio/reader.odin @@ -311,18 +311,6 @@ reader_write_to :: proc(b: ^Reader, w: io.Writer) -> (n: i64, err: io.Error) { } m: i64 - if nr, ok := io.to_writer_to(b.rd); ok { - m, err = io.write_to(nr, w) - n += m - return n, err - } - - if nw, ok := io.to_reader_from(w); ok { - m, err = io.read_from(nw, b.rd) - n += m - return n, err - } - if b.w-b.r < len(b.buf) { if err = _reader_read_new_chunk(b); err != nil { return @@ -352,48 +340,28 @@ reader_write_to :: proc(b: ^Reader, w: io.Writer) -> (n: i64, err: io.Error) { // reader_to_stream converts a Reader into an io.Stream reader_to_stream :: proc(b: ^Reader) -> (s: io.Stream) { - s.stream_data = b - s.stream_vtable = &_reader_vtable + s.data = b + s.procedure = _reader_proc return } @(private) -_reader_vtable := io.Stream_VTable{ - impl_destroy = proc(s: io.Stream) -> io.Error { - b := (^Reader)(s.stream_data) +_reader_proc :: proc(stream_data: rawptr, mode: io.Stream_Mode, p: []byte, offset: i64, whence: io.Seek_From) -> (n: i64, err: io.Error) { + b := (^Reader)(stream_data) + #partial switch mode { + case .Read: + return io._i64_err(reader_read(b, p)) + case .Destroy: reader_destroy(b) - return nil - }, - impl_read = proc(s: io.Stream, p: []byte) -> (n: int, err: io.Error) { - b := (^Reader)(s.stream_data) - return reader_read(b, p) - }, - impl_read_byte = proc(s: io.Stream) -> (c: byte, err: io.Error) { - b := (^Reader)(s.stream_data) - return reader_read_byte(b) - }, - impl_unread_byte = proc(s: io.Stream) -> io.Error { - b := (^Reader)(s.stream_data) - return reader_unread_byte(b) - }, - impl_read_rune = proc(s: io.Stream) -> (r: rune, size: int, err: io.Error) { - b := (^Reader)(s.stream_data) - return reader_read_rune(b) - }, - impl_unread_rune = proc(s: io.Stream) -> io.Error { - b := (^Reader)(s.stream_data) - return reader_unread_rune(b) - }, - impl_write_to = proc(s: io.Stream, w: io.Writer) -> (n: i64, err: io.Error) { - b := (^Reader)(s.stream_data) - return reader_write_to(b, w) - }, + return + case .Query: + return io.query_utility({.Read, .Destroy, .Query}) + } + return 0, .Empty } - - // // Utility procedures // diff --git a/core/bufio/writer.odin b/core/bufio/writer.odin index 9e38395ee..bfa8b804f 100644 --- a/core/bufio/writer.odin +++ b/core/bufio/writer.odin @@ -173,14 +173,6 @@ writer_read_from :: proc(b: ^Writer, r: io.Reader) -> (n: i64, err: io.Error) { if b.err != nil { return 0, b.err } - if writer_buffered(b) == 0 { - if w, ok := io.to_reader_from(b.wr); !ok { - n, err = io.read_from(w, r) - b.err = err - return - } - } - for { if writer_available(b) == 0 { writer_flush(b) or_return @@ -222,38 +214,35 @@ writer_read_from :: proc(b: ^Writer, r: io.Reader) -> (n: i64, err: io.Error) { // writer_to_stream converts a Writer into an io.Stream writer_to_stream :: proc(b: ^Writer) -> (s: io.Stream) { - s.stream_data = b - s.stream_vtable = &_writer_vtable + s.data = b + s.procedure = _writer_proc return } +// writer_to_stream converts a Writer into an io.Stream +writer_to_writer :: proc(b: ^Writer) -> (s: io.Writer) { + return writer_to_stream(b) +} + @(private) -_writer_vtable := io.Stream_VTable{ - impl_destroy = proc(s: io.Stream) -> io.Error { - b := (^Writer)(s.stream_data) +_writer_proc :: proc(stream_data: rawptr, mode: io.Stream_Mode, p: []byte, offset: i64, whence: io.Seek_From) -> (n: i64, err: io.Error) { + b := (^Writer)(stream_data) + #partial switch mode { + case .Flush: + err = writer_flush(b) + return + case .Write: + n_int: int + n_int, err = writer_write(b, p) + n = i64(n_int) + return + case .Destroy: writer_destroy(b) - return nil - }, - impl_flush = proc(s: io.Stream) -> io.Error { - b := (^Writer)(s.stream_data) - return writer_flush(b) - }, - impl_write = proc(s: io.Stream, p: []byte) -> (n: int, err: io.Error) { - b := (^Writer)(s.stream_data) - return writer_write(b, p) - }, - impl_write_byte = proc(s: io.Stream, c: byte) -> io.Error { - b := (^Writer)(s.stream_data) - return writer_write_byte(b, c) - }, - impl_write_rune = proc(s: io.Stream, r: rune) -> (int, io.Error) { - b := (^Writer)(s.stream_data) - return writer_write_rune(b, r) - }, - impl_read_from = proc(s: io.Stream, r: io.Reader) -> (n: i64, err: io.Error) { - b := (^Writer)(s.stream_data) - return writer_read_from(b, r) - }, + return + case .Query: + return io.query_utility({.Flush, .Write, .Destroy, .Query}) + } + return 0, .Empty } diff --git a/core/builtin/builtin.odin b/core/builtin/builtin.odin index d1cdfa6e7..211db9770 100644 --- a/core/builtin/builtin.odin +++ b/core/builtin/builtin.odin @@ -94,7 +94,15 @@ cap :: proc(array: Array_Type) -> int --- size_of :: proc($T: typeid) -> int --- align_of :: proc($T: typeid) -> int --- -offset_of :: proc($T: typeid) -> uintptr --- + +// e.g. offset_of(t.f), where t is an instance of the type T +offset_of_selector :: proc(selector: $T) -> uintptr --- +// e.g. offset_of(T, f), where T can be the type instead of a variable +offset_of_member :: proc($T: typeid, member: $M) -> uintptr --- +offset_of :: proc{offset_of_selector, offset_of_member} +// e.g. offset_of(T, "f"), where T can be the type instead of a variable +offset_of_by_string :: proc($T: typeid, member: string) -> uintptr --- + type_of :: proc(x: expr) -> type --- type_info_of :: proc($T: typeid) -> ^runtime.Type_Info --- typeid_of :: proc($T: typeid) -> typeid --- @@ -109,7 +117,7 @@ jmag :: proc(value: Quaternion) -> Float --- kmag :: proc(value: Quaternion) -> Float --- conj :: proc(value: Complex_Or_Quaternion) -> Complex_Or_Quaternion --- -expand_to_tuple :: proc(value: Struct_Or_Array) -> (A, B, C, ...) --- +expand_values :: proc(value: Struct_Or_Array) -> (A, B, C, ...) --- min :: proc(values: ..T) -> T --- max :: proc(values: ..T) -> T --- diff --git a/core/bytes/buffer.odin b/core/bytes/buffer.odin index bba834f7e..4375d8195 100644 --- a/core/bytes/buffer.odin +++ b/core/bytes/buffer.odin @@ -38,6 +38,11 @@ buffer_init_string :: proc(b: ^Buffer, s: string) { } buffer_init_allocator :: proc(b: ^Buffer, len, cap: int, allocator := context.allocator) { + if b.buf == nil { + b.buf = make([dynamic]byte, len, cap, allocator) + return + } + b.buf.allocator = allocator reserve(&b.buf, cap) resize(&b.buf, len) @@ -370,69 +375,31 @@ buffer_read_from :: proc(b: ^Buffer, r: io.Reader) -> (n: i64, err: io.Error) #n buffer_to_stream :: proc(b: ^Buffer) -> (s: io.Stream) { - s.stream_data = b - s.stream_vtable = &_buffer_vtable + s.data = b + s.procedure = _buffer_proc return } @(private) -_buffer_vtable := io.Stream_VTable{ - impl_size = proc(s: io.Stream) -> i64 { - b := (^Buffer)(s.stream_data) - return i64(buffer_capacity(b)) - }, - impl_read = proc(s: io.Stream, p: []byte) -> (n: int, err: io.Error) { - b := (^Buffer)(s.stream_data) - return buffer_read(b, p) - }, - impl_read_at = proc(s: io.Stream, p: []byte, offset: i64) -> (n: int, err: io.Error) { - b := (^Buffer)(s.stream_data) - return buffer_read_at(b, p, int(offset)) - }, - impl_read_byte = proc(s: io.Stream) -> (byte, io.Error) { - b := (^Buffer)(s.stream_data) - return buffer_read_byte(b) - }, - impl_read_rune = proc(s: io.Stream) -> (r: rune, size: int, err: io.Error) { - b := (^Buffer)(s.stream_data) - return buffer_read_rune(b) - }, - impl_write = proc(s: io.Stream, p: []byte) -> (n: int, err: io.Error) { - b := (^Buffer)(s.stream_data) - return buffer_write(b, p) - }, - impl_write_at = proc(s: io.Stream, p: []byte, offset: i64) -> (n: int, err: io.Error) { - b := (^Buffer)(s.stream_data) - return buffer_write_at(b, p, int(offset)) - }, - impl_write_byte = proc(s: io.Stream, c: byte) -> io.Error { - b := (^Buffer)(s.stream_data) - return buffer_write_byte(b, c) - }, - impl_write_rune = proc(s: io.Stream, r: rune) -> (int, io.Error) { - b := (^Buffer)(s.stream_data) - return buffer_write_rune(b, r) - }, - impl_unread_byte = proc(s: io.Stream) -> io.Error { - b := (^Buffer)(s.stream_data) - return buffer_unread_byte(b) - }, - impl_unread_rune = proc(s: io.Stream) -> io.Error { - b := (^Buffer)(s.stream_data) - return buffer_unread_rune(b) - }, - impl_destroy = proc(s: io.Stream) -> io.Error { - b := (^Buffer)(s.stream_data) +_buffer_proc :: proc(stream_data: rawptr, mode: io.Stream_Mode, p: []byte, offset: i64, whence: io.Seek_From) -> (n: i64, err: io.Error) { + b := (^Buffer)(stream_data) + #partial switch mode { + case .Read: + return io._i64_err(buffer_read(b, p)) + case .Read_At: + return io._i64_err(buffer_read_at(b, p, int(offset))) + case .Write: + return io._i64_err(buffer_write(b, p)) + case .Write_At: + return io._i64_err(buffer_write_at(b, p, int(offset))) + case .Size: + n = i64(buffer_capacity(b)) + return + case .Destroy: buffer_destroy(b) - return nil - }, - impl_write_to = proc(s: io.Stream, w: io.Writer) -> (n: i64, err: io.Error) { - b := (^Buffer)(s.stream_data) - return buffer_write_to(b, w) - }, - impl_read_from = proc(s: io.Stream, r: io.Reader) -> (n: i64, err: io.Error) { - b := (^Buffer)(s.stream_data) - return buffer_read_from(b, r) - }, + return + case .Query: + return io.query_utility({.Read, .Read_At, .Write, .Write_At, .Size, .Destroy}) + } + return 0, .Empty } - diff --git a/core/bytes/reader.odin b/core/bytes/reader.odin index 7c37f3061..4b18345ba 100644 --- a/core/bytes/reader.odin +++ b/core/bytes/reader.odin @@ -16,8 +16,8 @@ reader_init :: proc(r: ^Reader, s: []byte) { } reader_to_stream :: proc(r: ^Reader) -> (s: io.Stream) { - s.stream_data = r - s.stream_vtable = &_reader_vtable + s.data = r + s.procedure = _reader_proc return } @@ -137,41 +137,22 @@ reader_write_to :: proc(r: ^Reader, w: io.Writer) -> (n: i64, err: io.Error) { @(private) -_reader_vtable := io.Stream_VTable{ - impl_size = proc(s: io.Stream) -> i64 { - r := (^Reader)(s.stream_data) - return reader_size(r) - }, - impl_read = proc(s: io.Stream, p: []byte) -> (n: int, err: io.Error) { - r := (^Reader)(s.stream_data) - return reader_read(r, p) - }, - impl_read_at = proc(s: io.Stream, p: []byte, off: i64) -> (n: int, err: io.Error) { - r := (^Reader)(s.stream_data) - return reader_read_at(r, p, off) - }, - impl_read_byte = proc(s: io.Stream) -> (byte, io.Error) { - r := (^Reader)(s.stream_data) - return reader_read_byte(r) - }, - impl_unread_byte = proc(s: io.Stream) -> io.Error { - r := (^Reader)(s.stream_data) - return reader_unread_byte(r) - }, - impl_read_rune = proc(s: io.Stream) -> (ch: rune, size: int, err: io.Error) { - r := (^Reader)(s.stream_data) - return reader_read_rune(r) - }, - impl_unread_rune = proc(s: io.Stream) -> io.Error { - r := (^Reader)(s.stream_data) - return reader_unread_rune(r) - }, - impl_seek = proc(s: io.Stream, offset: i64, whence: io.Seek_From) -> (i64, io.Error) { - r := (^Reader)(s.stream_data) - return reader_seek(r, offset, whence) - }, - impl_write_to = proc(s: io.Stream, w: io.Writer) -> (n: i64, err: io.Error) { - r := (^Reader)(s.stream_data) - return reader_write_to(r, w) - }, +_reader_proc :: proc(stream_data: rawptr, mode: io.Stream_Mode, p: []byte, offset: i64, whence: io.Seek_From) -> (n: i64, err: io.Error) { + r := (^Reader)(stream_data) + #partial switch mode { + case .Read: + return io._i64_err(reader_read(r, p)) + case .Read_At: + return io._i64_err(reader_read_at(r, p, offset)) + case .Seek: + n, err = reader_seek(r, offset, whence) + return + case .Size: + n = reader_size(r) + return + case .Query: + return io.query_utility({.Read, .Read_At, .Seek, .Size, .Query}) + } + return 0, .Empty } + diff --git a/core/c/frontend/preprocessor/preprocess.odin b/core/c/frontend/preprocessor/preprocess.odin index 4cfad2c1c..b5eab0bb3 100644 --- a/core/c/frontend/preprocessor/preprocess.odin +++ b/core/c/frontend/preprocessor/preprocess.odin @@ -1118,7 +1118,7 @@ expand_macro :: proc(cpp: ^Preprocessor, rest: ^^Token, tok: ^Token) -> bool { search_include_next :: proc(cpp: ^Preprocessor, filename: string) -> (path: string, ok: bool) { for ; cpp.include_next_index < len(cpp.include_paths); cpp.include_next_index += 1 { - tpath := filepath.join(elems={cpp.include_paths[cpp.include_next_index], filename}, allocator=context.temp_allocator) + tpath := filepath.join({cpp.include_paths[cpp.include_next_index], filename}, allocator=context.temp_allocator) if os.exists(tpath) { return strings.clone(tpath), true } @@ -1136,7 +1136,7 @@ search_include_paths :: proc(cpp: ^Preprocessor, filename: string) -> (path: str } for include_path in cpp.include_paths { - tpath := filepath.join(elems={include_path, filename}, allocator=context.temp_allocator) + tpath := filepath.join({include_path, filename}, allocator=context.temp_allocator) if os.exists(tpath) { path, ok = strings.clone(tpath), true cpp.filepath_cache[filename] = path diff --git a/core/c/libc/threads.odin b/core/c/libc/threads.odin index f6aae2e98..8e3343234 100644 --- a/core/c/libc/threads.odin +++ b/core/c/libc/threads.odin @@ -44,7 +44,7 @@ when ODIN_OS == .Windows { @(link_name="_Cnd_destroy") cnd_destroy :: proc(cond: ^cnd_t) --- @(link_name="_Cnd_init") cnd_init :: proc(cond: ^cnd_t) -> int --- @(link_name="_Cnd_signal") cnd_signal :: proc(cond: ^cnd_t) -> int --- - @(link_name="_Cnd_timedwait") cnd_timedwait :: proc(cond: ^cnd_t, ts: ^timespec) -> int --- + @(link_name="_Cnd_timedwait") cnd_timedwait :: proc(cond: ^cnd_t, mtx: ^mtx_t, ts: ^timespec) -> int --- @(link_name="_Cnd_wait") cnd_wait :: proc(cond: ^cnd_t, mtx: ^mtx_t) -> int --- // 7.26.4 Mutex functions @@ -108,7 +108,7 @@ when ODIN_OS == .Linux { cnd_destroy :: proc(cond: ^cnd_t) --- cnd_init :: proc(cond: ^cnd_t) -> int --- cnd_signal :: proc(cond: ^cnd_t) -> int --- - cnd_timedwait :: proc(cond: ^cnd_t, ts: ^timespec) -> int --- + cnd_timedwait :: proc(cond: ^cnd_t, mtx: ^mtx_t, ts: ^timespec) -> int --- cnd_wait :: proc(cond: ^cnd_t, mtx: ^mtx_t) -> int --- // 7.26.4 Mutex functions diff --git a/core/compress/common.odin b/core/compress/common.odin index b42cbefff..bc56229c2 100644 --- a/core/compress/common.odin +++ b/core/compress/common.odin @@ -188,7 +188,8 @@ input_size_from_memory :: proc(z: ^Context_Memory_Input) -> (res: i64, err: Erro } input_size_from_stream :: proc(z: ^Context_Stream_Input) -> (res: i64, err: Error) { - return io.size(z.input), nil + res, _ = io.size(z.input) + return } input_size :: proc{input_size_from_memory, input_size_from_stream} @@ -212,8 +213,10 @@ read_slice_from_memory :: #force_inline proc(z: ^Context_Memory_Input, size: int @(optimization_mode="speed") read_slice_from_stream :: #force_inline proc(z: ^Context_Stream_Input, size: int) -> (res: []u8, err: io.Error) { + // TODO: REMOVE ALL USE OF context.temp_allocator here + // the is literally no need for it b := make([]u8, size, context.temp_allocator) - _, e := z.input->impl_read(b[:]) + _, e := io.read(z.input, b[:]) if e == .None { return b, .None } diff --git a/core/compress/gzip/gzip.odin b/core/compress/gzip/gzip.odin index 4de4d1b63..b0ca4491b 100644 --- a/core/compress/gzip/gzip.odin +++ b/core/compress/gzip/gzip.odin @@ -335,7 +335,7 @@ load_from_context :: proc(z: ^$C, buf: ^bytes.Buffer, known_gzip_size := -1, exp // fmt.printf("GZIP: Expected Payload Size: %v\n", expected_output_size); - zlib_error := zlib.inflate_raw(z=z, expected_output_size=expected_output_size) + zlib_error := zlib.inflate_raw(z, expected_output_size=expected_output_size) if zlib_error != nil { return zlib_error } diff --git a/core/compress/shoco/shoco.odin b/core/compress/shoco/shoco.odin index f94ce70b7..04b0bfdc2 100644 --- a/core/compress/shoco/shoco.odin +++ b/core/compress/shoco/shoco.odin @@ -177,12 +177,10 @@ decompress_slice_to_string :: proc(input: []u8, model := DEFAULT_MODEL, allocato max_output_size := decompress_bound(len(input), model) buf: [dynamic]u8 - if !resize(&buf, max_output_size) { - return "", .Out_Of_Memory - } + resize(&buf, max_output_size) or_return length, result := decompress_slice_to_output_buffer(input, buf[:]) - resize(&buf, length) + resize(&buf, length) or_return return string(buf[:]), result } decompress :: proc{decompress_slice_to_output_buffer, decompress_slice_to_string} @@ -307,12 +305,10 @@ compress_string :: proc(input: string, model := DEFAULT_MODEL, allocator := cont max_output_size := compress_bound(len(input)) buf: [dynamic]u8 - if !resize(&buf, max_output_size) { - return {}, .Out_Of_Memory - } + resize(&buf, max_output_size) or_return length, result := compress_string_to_buffer(input, buf[:]) - resize(&buf, length) + resize(&buf, length) or_return return buf[:length], result } compress :: proc{compress_string_to_buffer, compress_string} \ No newline at end of file diff --git a/core/compress/zlib/zlib.odin b/core/compress/zlib/zlib.odin index 855eef7a8..21172e8e8 100644 --- a/core/compress/zlib/zlib.odin +++ b/core/compress/zlib/zlib.odin @@ -471,7 +471,7 @@ inflate_from_context :: proc(using ctx: ^compress.Context_Memory_Input, raw := f } // Parse ZLIB stream without header. - inflate_raw(z=ctx, expected_output_size=expected_output_size) or_return + inflate_raw(ctx, expected_output_size=expected_output_size) or_return if !raw { compress.discard_to_next_byte_lsb(ctx) @@ -665,7 +665,7 @@ inflate_from_byte_array :: proc(input: []u8, buf: ^bytes.Buffer, raw := false, e ctx.input_data = input ctx.output = buf - return inflate_from_context(ctx=&ctx, raw=raw, expected_output_size=expected_output_size) + return inflate_from_context(&ctx, raw=raw, expected_output_size=expected_output_size) } inflate_from_byte_array_raw :: proc(input: []u8, buf: ^bytes.Buffer, raw := false, expected_output_size := -1) -> (err: Error) { @@ -674,7 +674,7 @@ inflate_from_byte_array_raw :: proc(input: []u8, buf: ^bytes.Buffer, raw := fals ctx.input_data = input ctx.output = buf - return inflate_raw(z=&ctx, expected_output_size=expected_output_size) + return inflate_raw(&ctx, expected_output_size=expected_output_size) } inflate :: proc{inflate_from_context, inflate_from_byte_array} diff --git a/core/container/bit_array/bit_array.odin b/core/container/bit_array/bit_array.odin index 763a19f8b..d649d039f 100644 --- a/core/container/bit_array/bit_array.odin +++ b/core/container/bit_array/bit_array.odin @@ -27,27 +27,28 @@ Bit_Array_Iterator :: struct { word_idx: int, bit_idx: uint, } - /* - In: - - ba: ^Bit_Array - the array to iterate over +Wraps a `Bit_Array` into an Iterator - Out: - - it: ^Bit_Array_Iterator - the iterator that holds iteration state +Inputs: +- ba: Pointer to the Bit_Array + +Returns: +- it: Iterator struct */ make_iterator :: proc (ba: ^Bit_Array) -> (it: Bit_Array_Iterator) { return Bit_Array_Iterator { array = ba } } - /* - In: - - it: ^Bit_Array_Iterator - the iterator struct that holds the state. +Returns the next bit, including its set-state. ok=false once exhausted - Out: - - set: bool - the state of the bit at `index` - - index: int - the next bit of the Bit_Array referenced by `it`. - - ok: bool - `true` if the iterator returned a valid index, - `false` if there were no more bits +Inputs: +- it: The iterator that holds the state. + +Returns: +- set: `true` if the bit at `index` is set. +- index: The next bit of the Bit_Array referenced by `it`. +- ok: `true` if the iterator can continue, `false` if the iterator is done */ iterate_by_all :: proc (it: ^Bit_Array_Iterator) -> (set: bool, index: int, ok: bool) { index = it.word_idx * NUM_BITS + int(it.bit_idx) + it.array.bias @@ -64,39 +65,51 @@ iterate_by_all :: proc (it: ^Bit_Array_Iterator) -> (set: bool, index: int, ok: return set, index, true } - /* - In: - - it: ^Bit_Array_Iterator - the iterator struct that holds the state. +Returns the next Set Bit, for example if `0b1010`, then the iterator will return index={1, 3} over two calls. - Out: - - index: int - the next set bit of the Bit_Array referenced by `it`. - - ok: bool - `true` if the iterator returned a valid index, - `false` if there were no more bits set +Inputs: +- it: The iterator that holds the state. + +Returns: +- index: The next *set* bit of the Bit_Array referenced by `it`. +- ok: `true` if the iterator can continue, `false` if the iterator is done */ iterate_by_set :: proc (it: ^Bit_Array_Iterator) -> (index: int, ok: bool) { return iterate_internal_(it, true) } - /* - In: - - it: ^Bit_Array_Iterator - the iterator struct that holds the state. +Returns the next Unset Bit, for example if `0b1010`, then the iterator will return index={0, 2} over two calls. - Out: - - index: int - the next unset bit of the Bit_Array referenced by `it`. - - ok: bool - `true` if the iterator returned a valid index, - `false` if there were no more unset bits +Inputs: +- it: The iterator that holds the state. + +Returns: +- index: The next *unset* bit of the Bit_Array referenced by `it`. +- ok: `true` if the iterator can continue, `false` if the iterator is done */ iterate_by_unset:: proc (it: ^Bit_Array_Iterator) -> (index: int, ok: bool) { return iterate_internal_(it, false) } +/* +Iterates through set/unset bits +*Private* + +Inputs: +- it: The iterator that holds the state. +- ITERATE_SET_BITS: `true` for returning only set bits, false for returning only unset bits + +Returns: +- index: The next *unset* bit of the Bit_Array referenced by `it`. +- ok: `true` if the iterator can continue, `false` if the iterator is done +*/ @(private="file") iterate_internal_ :: proc (it: ^Bit_Array_Iterator, $ITERATE_SET_BITS: bool) -> (index: int, ok: bool) { word := it.array.bits[it.word_idx] if len(it.array.bits) > it.word_idx else 0 when ! ITERATE_SET_BITS { word = ~word } - // if the word is empty or we have already gone over all the bits in it, + // If the word is empty or we have already gone over all the bits in it, // b.bit_idx is greater than the index of any set bit in the word, // meaning that word >> b.bit_idx == 0. for it.word_idx < len(it.array.bits) && word >> it.bit_idx == 0 { @@ -106,14 +119,14 @@ iterate_internal_ :: proc (it: ^Bit_Array_Iterator, $ITERATE_SET_BITS: bool) -> when ! ITERATE_SET_BITS { word = ~word } } - // if we are iterating the set bits, reaching the end of the array means we have no more bits to check + // If we are iterating the set bits, reaching the end of the array means we have no more bits to check when ITERATE_SET_BITS { if it.word_idx >= len(it.array.bits) { return 0, false } } - // reaching here means that the word has some set bits + // Reaching here means that the word has some set bits it.bit_idx += uint(intrinsics.count_trailing_zeros(word >> it.bit_idx)) index = it.word_idx * NUM_BITS + int(it.bit_idx) + it.array.bias @@ -124,24 +137,21 @@ iterate_internal_ :: proc (it: ^Bit_Array_Iterator, $ITERATE_SET_BITS: bool) -> } return index, index <= it.array.max_index } - - /* - In: - - ba: ^Bit_Array - a pointer to the Bit Array - - index: The bit index. Can be an enum member. +Gets the state of a bit in the bit-array - Out: - - res: The bit you're interested in. - - ok: Whether the index was valid. Returns `false` if the index is smaller than the bias. +Inputs: +- ba: Pointer to the Bit_Array +- index: Which bit in the array - The `ok` return value may be ignored. +Returns: +- res: `true` if the bit at `index` is set. +- ok: Whether the index was valid. Returns `false` if the index is smaller than the bias. */ -get :: proc(ba: ^Bit_Array, #any_int index: uint, allocator := context.allocator) -> (res: bool, ok: bool) { +get :: proc(ba: ^Bit_Array, #any_int index: uint) -> (res: bool, ok: bool) #optional_ok { idx := int(index) - ba.bias if ba == nil || int(index) < ba.bias { return false, false } - context.allocator = allocator leg_index := idx >> INDEX_SHIFT bit_index := idx & INDEX_MASK @@ -157,18 +167,36 @@ get :: proc(ba: ^Bit_Array, #any_int index: uint, allocator := context.allocator return res, true } - /* - In: - - ba: ^Bit_Array - a pointer to the Bit Array - - index: The bit index. Can be an enum member. +Gets the state of a bit in the bit-array - Out: - - ok: Whether or not we managed to set requested bit. +*Bypasses all Checks* - `set` automatically resizes the Bit Array to accommodate the requested index if needed. +Inputs: +- ba: Pointer to the Bit_Array +- index: Which bit in the array + +Returns: +- `true` if bit is set */ -set :: proc(ba: ^Bit_Array, #any_int index: uint, allocator := context.allocator) -> (ok: bool) { +unsafe_get :: #force_inline proc(ba: ^Bit_Array, #any_int index: uint) -> bool #no_bounds_check { + return bool((ba.bits[index >> INDEX_SHIFT] >> uint(index & INDEX_MASK)) & 1) +} +/* +Sets the state of a bit in the bit-array + +*Conditionally Allocates (Resizes backing data when `index > len(ba.bits)`)* + +Inputs: +- ba: Pointer to the Bit_Array +- index: Which bit in the array +- set_to: `true` sets the bit on, `false` to turn it off +- allocator: (default is context.allocator) + +Returns: +- ok: Whether the set was successful, `false` on allocation failure or bad index +*/ +set :: proc(ba: ^Bit_Array, #any_int index: uint, set_to: bool = true, allocator := context.allocator) -> (ok: bool) { idx := int(index) - ba.bias @@ -181,65 +209,97 @@ set :: proc(ba: ^Bit_Array, #any_int index: uint, allocator := context.allocator resize_if_needed(ba, leg_index) or_return ba.max_index = max(idx, ba.max_index) - ba.bits[leg_index] |= 1 << uint(bit_index) + + if set_to{ ba.bits[leg_index] |= 1 << uint(bit_index) } + else { ba.bits[leg_index] &= ~(1 << uint(bit_index)) } + return true } - /* - In: - - ba: ^Bit_Array - a pointer to the Bit Array - - index: The bit index. Can be an enum member. +Sets the state of a bit in the bit-array - Out: - - ok: Whether or not we managed to unset requested bit. +*Bypasses all checks* - `unset` automatically resizes the Bit Array to accommodate the requested index if needed. +Inputs: +- ba: Pointer to the Bit_Array +- index: Which bit in the array */ -unset :: proc(ba: ^Bit_Array, #any_int index: uint, allocator := context.allocator) -> (ok: bool) { - - idx := int(index) - ba.bias - - if ba == nil || int(index) < ba.bias { return false } - context.allocator = allocator - - leg_index := idx >> INDEX_SHIFT - bit_index := idx & INDEX_MASK - - resize_if_needed(ba, leg_index) or_return - - ba.max_index = max(idx, ba.max_index) - ba.bits[leg_index] &= ~(1 << uint(bit_index)) - return true +unsafe_set :: proc(ba: ^Bit_Array, bit: int) #no_bounds_check { + ba.bits[bit >> INDEX_SHIFT] |= 1 << uint(bit & INDEX_MASK) } - /* - A helper function to create a Bit Array with optional bias, in case your smallest index is non-zero (including negative). +Unsets the state of a bit in the bit-array. (Convienence wrapper for `set`) + +*Conditionally Allocates (Resizes backing data when `index > len(ba.bits)`)* + +Inputs: +- ba: Pointer to the Bit_Array +- index: Which bit in the array +- allocator: (default is context.allocator) + +Returns: +- ok: Whether the unset was successful, `false` on allocation failure or bad index */ -create :: proc(max_index: int, min_index := 0, allocator := context.allocator) -> (res: ^Bit_Array, ok: bool) #optional_ok { +unset :: #force_inline proc(ba: ^Bit_Array, #any_int index: uint, allocator := context.allocator) -> (ok: bool) { + return set(ba, index, false, allocator) +} +/* +Unsets the state of a bit in the bit-array + +*Bypasses all Checks* + +Inputs: +- ba: Pointer to the Bit_Array +- index: Which bit in the array +*/ +unsafe_unset :: proc(b: ^Bit_Array, bit: int) #no_bounds_check { + b.bits[bit >> INDEX_SHIFT] &= ~(1 << uint(bit & INDEX_MASK)) +} +/* +A helper function to create a Bit Array with optional bias, in case your smallest index is non-zero (including negative). + +*Allocates (`new(Bit_Array) & make(ba.bits)`)* + +Inputs: +- max_index: maximum starting index +- min_index: minimum starting index (used as a bias) +- allocator: (default is context.allocator) + +Returns: +- ba: Allocates a bit_Array, backing data is set to `max-min / 64` indices, rounded up (eg 65 - 0 allocates for [2]u64). +*/ +create :: proc(max_index: int, min_index: int = 0, allocator := context.allocator) -> (res: ^Bit_Array, ok: bool) #optional_ok { context.allocator = allocator size_in_bits := max_index - min_index if size_in_bits < 1 { return {}, false } legs := size_in_bits >> INDEX_SHIFT - + if size_in_bits & INDEX_MASK > 0 {legs+=1} + bits, err := make([dynamic]u64, legs) + ok = err == mem.Allocator_Error.None res = new(Bit_Array) + res.bits = bits res.bias = min_index res.max_index = max_index res.free_pointer = true - return res, resize_if_needed(res, legs) + return } - /* - Sets all bits to `false`. +Sets all values in the Bit_Array to zero. + +Inputs: +- ba: The target Bit_Array */ clear :: proc(ba: ^Bit_Array) { if ba == nil { return } mem.zero_slice(ba.bits[:]) } - /* - Releases the memory used by the Bit Array. +Deallocates the Bit_Array and its backing storage + +Inputs: +- ba: The target Bit_Array */ destroy :: proc(ba: ^Bit_Array) { if ba == nil { return } @@ -248,9 +308,8 @@ destroy :: proc(ba: ^Bit_Array) { free(ba) } } - /* - Resizes the Bit Array. For internal use. + Resizes the Bit Array. For internal use. Provisions needed capacity+1 If you want to reserve the memory for a given-sized Bit Array up front, you can use `create`. */ @(private="file") diff --git a/core/container/queue/queue.odin b/core/container/queue/queue.odin index b3a8ad43f..af44ef671 100644 --- a/core/container/queue/queue.odin +++ b/core/container/queue/queue.odin @@ -14,7 +14,7 @@ Queue :: struct($T: typeid) { DEFAULT_CAPACITY :: 16 // Procedure to initialize a queue -init :: proc(q: ^$Q/Queue($T), capacity := DEFAULT_CAPACITY, allocator := context.allocator) -> bool { +init :: proc(q: ^$Q/Queue($T), capacity := DEFAULT_CAPACITY, allocator := context.allocator) -> runtime.Allocator_Error { if q.data.allocator.procedure == nil { q.data.allocator = allocator } @@ -55,11 +55,11 @@ space :: proc(q: $Q/Queue($T)) -> int { } // Reserve enough space for at least the specified capacity -reserve :: proc(q: ^$Q/Queue($T), capacity: int) -> bool { +reserve :: proc(q: ^$Q/Queue($T), capacity: int) -> runtime.Allocator_Error { if uint(capacity) > q.len { return _grow(q, uint(capacity)) } - return true + return nil } @@ -112,25 +112,25 @@ peek_back :: proc(q: ^$Q/Queue($T), loc := #caller_location) -> ^T { } // Push an element to the back of the queue -push_back :: proc(q: ^$Q/Queue($T), elem: T) -> bool { +push_back :: proc(q: ^$Q/Queue($T), elem: T) -> (ok: bool, err: runtime.Allocator_Error) { if space(q^) == 0 { _grow(q) or_return } idx := (q.offset+uint(q.len))%builtin.len(q.data) q.data[idx] = elem q.len += 1 - return true + return true, nil } // Push an element to the front of the queue -push_front :: proc(q: ^$Q/Queue($T), elem: T) -> bool { +push_front :: proc(q: ^$Q/Queue($T), elem: T) -> (ok: bool, err: runtime.Allocator_Error) { if space(q^) == 0 { _grow(q) or_return } q.offset = uint(q.offset - 1 + builtin.len(q.data)) % builtin.len(q.data) q.len += 1 q.data[q.offset] = elem - return true + return true, nil } @@ -173,7 +173,7 @@ pop_front_safe :: proc(q: ^$Q/Queue($T)) -> (elem: T, ok: bool) { } // Push multiple elements to the front of the queue -push_back_elems :: proc(q: ^$Q/Queue($T), elems: ..T) -> bool { +push_back_elems :: proc(q: ^$Q/Queue($T), elems: ..T) -> (ok: bool, err: runtime.Allocator_Error) { n := uint(builtin.len(elems)) if space(q^) < int(n) { _grow(q, q.len + n) or_return @@ -188,7 +188,7 @@ push_back_elems :: proc(q: ^$Q/Queue($T), elems: ..T) -> bool { copy(q.data[insert_from:], elems[:insert_to]) copy(q.data[:insert_from], elems[insert_to:]) q.len += n - return true + return true, nil } // Consume `n` elements from the front of the queue @@ -225,7 +225,7 @@ clear :: proc(q: ^$Q/Queue($T)) { // Internal growinh procedure -_grow :: proc(q: ^$Q/Queue($T), min_capacity: uint = 0) -> bool { +_grow :: proc(q: ^$Q/Queue($T), min_capacity: uint = 0) -> runtime.Allocator_Error { new_capacity := max(min_capacity, uint(8), uint(builtin.len(q.data))*2) n := uint(builtin.len(q.data)) builtin.resize(&q.data, int(new_capacity)) or_return @@ -234,5 +234,5 @@ _grow :: proc(q: ^$Q/Queue($T), min_capacity: uint = 0) -> bool { copy(q.data[new_capacity-diff:], q.data[q.offset:][:diff]) q.offset += new_capacity - n } - return true + return nil } diff --git a/core/crypto/_fiat/fiat.odin b/core/crypto/_fiat/fiat.odin index ae9727149..f0551722f 100644 --- a/core/crypto/_fiat/fiat.odin +++ b/core/crypto/_fiat/fiat.odin @@ -9,14 +9,16 @@ package fiat u1 :: distinct u8 i1 :: distinct i8 -cmovznz_u64 :: #force_inline proc "contextless" (arg1: u1, arg2, arg3: u64) -> (out1: u64) { +@(optimization_mode="none") +cmovznz_u64 :: proc "contextless" (arg1: u1, arg2, arg3: u64) -> (out1: u64) { x1 := (u64(arg1) * 0xffffffffffffffff) x2 := ((x1 & arg3) | ((~x1) & arg2)) out1 = x2 return } -cmovznz_u32 :: #force_inline proc "contextless" (arg1: u1, arg2, arg3: u32) -> (out1: u32) { +@(optimization_mode="none") +cmovznz_u32 :: proc "contextless" (arg1: u1, arg2, arg3: u32) -> (out1: u32) { x1 := (u32(arg1) * 0xffffffff) x2 := ((x1 & arg3) | ((~x1) & arg2)) out1 = x2 diff --git a/core/crypto/_fiat/field_curve25519/field51.odin b/core/crypto/_fiat/field_curve25519/field51.odin index e4ca98b57..0be94eb51 100644 --- a/core/crypto/_fiat/field_curve25519/field51.odin +++ b/core/crypto/_fiat/field_curve25519/field51.odin @@ -305,7 +305,8 @@ fe_opp :: proc "contextless" (out1: ^Loose_Field_Element, arg1: ^Tight_Field_Ele out1[4] = x5 } -fe_cond_assign :: proc "contextless" (out1, arg1: ^Tight_Field_Element, arg2: int) { +@(optimization_mode="none") +fe_cond_assign :: #force_no_inline proc "contextless" (out1, arg1: ^Tight_Field_Element, arg2: int) { x1 := fiat.cmovznz_u64(fiat.u1(arg2), out1[0], arg1[0]) x2 := fiat.cmovznz_u64(fiat.u1(arg2), out1[1], arg1[1]) x3 := fiat.cmovznz_u64(fiat.u1(arg2), out1[2], arg1[2]) @@ -596,7 +597,8 @@ fe_set :: proc "contextless" (out1, arg1: ^Tight_Field_Element) { out1[4] = x5 } -fe_cond_swap :: proc "contextless" (out1, out2: ^Tight_Field_Element, arg1: int) { +@(optimization_mode="none") +fe_cond_swap :: #force_no_inline proc "contextless" (out1, out2: ^Tight_Field_Element, arg1: int) { mask := -u64(arg1) x := (out1[0] ~ out2[0]) & mask x1, y1 := out1[0] ~ x, out2[0] ~ x diff --git a/core/crypto/_fiat/field_poly1305/field4344.odin b/core/crypto/_fiat/field_poly1305/field4344.odin index ba9bc2694..8e8a7cc78 100644 --- a/core/crypto/_fiat/field_poly1305/field4344.odin +++ b/core/crypto/_fiat/field_poly1305/field4344.odin @@ -201,7 +201,8 @@ fe_opp :: proc "contextless" (out1: ^Loose_Field_Element, arg1: ^Tight_Field_Ele out1[2] = x3 } -fe_cond_assign :: proc "contextless" (out1, arg1: ^Tight_Field_Element, arg2: bool) { +@(optimization_mode="none") +fe_cond_assign :: #force_no_inline proc "contextless" (out1, arg1: ^Tight_Field_Element, arg2: bool) { x1 := fiat.cmovznz_u64(fiat.u1(arg2), out1[0], arg1[0]) x2 := fiat.cmovznz_u64(fiat.u1(arg2), out1[1], arg1[1]) x3 := fiat.cmovznz_u64(fiat.u1(arg2), out1[2], arg1[2]) @@ -342,7 +343,8 @@ fe_set :: #force_inline proc "contextless" (out1, arg1: ^Tight_Field_Element) { out1[2] = x3 } -fe_cond_swap :: proc "contextless" (out1, out2: ^Tight_Field_Element, arg1: bool) { +@(optimization_mode="none") +fe_cond_swap :: #force_no_inline proc "contextless" (out1, out2: ^Tight_Field_Element, arg1: bool) { mask := -u64(arg1) x := (out1[0] ~ out2[0]) & mask x1, y1 := out1[0] ~ x, out2[0] ~ x diff --git a/core/crypto/blake/blake.odin b/core/crypto/blake/blake.odin index 5fc0a02b9..3685109e4 100644 --- a/core/crypto/blake/blake.odin +++ b/core/crypto/blake/blake.odin @@ -70,7 +70,7 @@ hash_stream_224 :: proc(s: io.Stream) -> ([DIGEST_SIZE_224]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { update(&ctx, buf[:read]) } @@ -149,7 +149,7 @@ hash_stream_256 :: proc(s: io.Stream) -> ([DIGEST_SIZE_256]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { update(&ctx, buf[:read]) } @@ -228,7 +228,7 @@ hash_stream_384 :: proc(s: io.Stream) -> ([DIGEST_SIZE_384]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { update(&ctx, buf[:read]) } @@ -307,7 +307,7 @@ hash_stream_512 :: proc(s: io.Stream) -> ([DIGEST_SIZE_512]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { update(&ctx, buf[:read]) } diff --git a/core/crypto/blake2b/blake2b.odin b/core/crypto/blake2b/blake2b.odin index e75d74197..8f0770f82 100644 --- a/core/crypto/blake2b/blake2b.odin +++ b/core/crypto/blake2b/blake2b.odin @@ -77,7 +77,7 @@ hash_stream :: proc(s: io.Stream) -> ([DIGEST_SIZE]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { _blake2.update(&ctx, buf[:read]) } diff --git a/core/crypto/blake2s/blake2s.odin b/core/crypto/blake2s/blake2s.odin index 831335081..6a2d4ab9b 100644 --- a/core/crypto/blake2s/blake2s.odin +++ b/core/crypto/blake2s/blake2s.odin @@ -77,7 +77,7 @@ hash_stream :: proc(s: io.Stream) -> ([DIGEST_SIZE]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { _blake2.update(&ctx, buf[:read]) } diff --git a/core/crypto/chacha20/chacha20.odin b/core/crypto/chacha20/chacha20.odin index 229949c22..b29dc1228 100644 --- a/core/crypto/chacha20/chacha20.odin +++ b/core/crypto/chacha20/chacha20.odin @@ -8,15 +8,23 @@ KEY_SIZE :: 32 NONCE_SIZE :: 12 XNONCE_SIZE :: 24 +@(private) _MAX_CTR_IETF :: 0xffffffff +@(private) _BLOCK_SIZE :: 64 +@(private) _STATE_SIZE_U32 :: 16 +@(private) _ROUNDS :: 20 +@(private) _SIGMA_0 : u32 : 0x61707865 +@(private) _SIGMA_1 : u32 : 0x3320646e +@(private) _SIGMA_2 : u32 : 0x79622d32 +@(private) _SIGMA_3 : u32 : 0x6b206574 Context :: struct { @@ -179,6 +187,7 @@ reset :: proc (ctx: ^Context) { ctx._is_initialized = false } +@(private) _do_blocks :: proc (ctx: ^Context, dst, src: []byte, nr_blocks: int) { // Enforce the maximum consumed keystream per nonce. // @@ -441,6 +450,7 @@ _do_blocks :: proc (ctx: ^Context, dst, src: []byte, nr_blocks: int) { } } +@(private) _hchacha20 :: proc (dst, key, nonce: []byte) { x0, x1, x2, x3 := _SIGMA_0, _SIGMA_1, _SIGMA_2, _SIGMA_3 x4 := util.U32_LE(key[0:4]) diff --git a/core/crypto/chacha20poly1305/chacha20poly1305.odin b/core/crypto/chacha20poly1305/chacha20poly1305.odin index 67d89df56..ae395f9e0 100644 --- a/core/crypto/chacha20poly1305/chacha20poly1305.odin +++ b/core/crypto/chacha20poly1305/chacha20poly1305.odin @@ -10,8 +10,10 @@ KEY_SIZE :: chacha20.KEY_SIZE NONCE_SIZE :: chacha20.NONCE_SIZE TAG_SIZE :: poly1305.TAG_SIZE +@(private) _P_MAX :: 64 * 0xffffffff // 64 * (2^32-1) +@(private) _validate_common_slice_sizes :: proc (tag, key, nonce, aad, text: []byte) { if len(tag) != TAG_SIZE { panic("crypto/chacha20poly1305: invalid destination tag size") @@ -37,7 +39,10 @@ _validate_common_slice_sizes :: proc (tag, key, nonce, aad, text: []byte) { } } +@(private) _PAD: [16]byte + +@(private) _update_mac_pad16 :: #force_inline proc (ctx: ^poly1305.Context, x_len: int) { if pad_len := 16 - (x_len & (16-1)); pad_len != 16 { poly1305.update(ctx, _PAD[:pad_len]) diff --git a/core/crypto/crypto.odin b/core/crypto/crypto.odin index 35e88c5ed..6cdcacb9c 100644 --- a/core/crypto/crypto.odin +++ b/core/crypto/crypto.odin @@ -26,6 +26,7 @@ compare_constant_time :: proc "contextless" (a, b: []byte) -> int { // // The execution time of this routine is constant regardless of the // contents of the memory being compared. +@(optimization_mode="none") compare_byte_ptrs_constant_time :: proc "contextless" (a, b: ^byte, n: int) -> int { x := mem.slice_ptr(a, n) y := mem.slice_ptr(b, n) diff --git a/core/crypto/gost/gost.odin b/core/crypto/gost/gost.odin index 1d0274fae..5aca8ce95 100644 --- a/core/crypto/gost/gost.odin +++ b/core/crypto/gost/gost.odin @@ -65,7 +65,7 @@ hash_stream :: proc(s: io.Stream) -> ([DIGEST_SIZE]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { update(&ctx, buf[:read]) } diff --git a/core/crypto/groestl/groestl.odin b/core/crypto/groestl/groestl.odin index 8e5a2440d..61460808f 100644 --- a/core/crypto/groestl/groestl.odin +++ b/core/crypto/groestl/groestl.odin @@ -70,7 +70,7 @@ hash_stream_224 :: proc(s: io.Stream) -> ([DIGEST_SIZE_224]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { update(&ctx, buf[:read]) } @@ -149,7 +149,7 @@ hash_stream_256 :: proc(s: io.Stream) -> ([DIGEST_SIZE_256]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { update(&ctx, buf[:read]) } @@ -228,7 +228,7 @@ hash_stream_384 :: proc(s: io.Stream) -> ([DIGEST_SIZE_384]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { update(&ctx, buf[:read]) } @@ -307,7 +307,7 @@ hash_stream_512 :: proc(s: io.Stream) -> ([DIGEST_SIZE_512]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { update(&ctx, buf[:read]) } diff --git a/core/crypto/haval/haval.odin b/core/crypto/haval/haval.odin index 811ecf95d..b98facb33 100644 --- a/core/crypto/haval/haval.odin +++ b/core/crypto/haval/haval.odin @@ -79,7 +79,7 @@ hash_stream_128_3 :: proc(s: io.Stream) -> ([DIGEST_SIZE_128]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) ctx.str_len = u32(len(buf[:read])) if read > 0 { update(&ctx, buf[:read]) @@ -164,7 +164,7 @@ hash_stream_128_4 :: proc(s: io.Stream) -> ([DIGEST_SIZE_128]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) ctx.str_len = u32(len(buf[:read])) if read > 0 { update(&ctx, buf[:read]) @@ -249,7 +249,7 @@ hash_stream_128_5 :: proc(s: io.Stream) -> ([DIGEST_SIZE_128]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) ctx.str_len = u32(len(buf[:read])) if read > 0 { update(&ctx, buf[:read]) @@ -334,7 +334,7 @@ hash_stream_160_3 :: proc(s: io.Stream) -> ([DIGEST_SIZE_160]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) ctx.str_len = u32(len(buf[:read])) if read > 0 { update(&ctx, buf[:read]) @@ -419,7 +419,7 @@ hash_stream_160_4 :: proc(s: io.Stream) -> ([DIGEST_SIZE_160]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) ctx.str_len = u32(len(buf[:read])) if read > 0 { update(&ctx, buf[:read]) @@ -504,7 +504,7 @@ hash_stream_160_5 :: proc(s: io.Stream) -> ([DIGEST_SIZE_160]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) ctx.str_len = u32(len(buf[:read])) if read > 0 { update(&ctx, buf[:read]) @@ -589,7 +589,7 @@ hash_stream_192_3 :: proc(s: io.Stream) -> ([DIGEST_SIZE_192]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) ctx.str_len = u32(len(buf[:read])) if read > 0 { update(&ctx, buf[:read]) @@ -674,7 +674,7 @@ hash_stream_192_4 :: proc(s: io.Stream) -> ([DIGEST_SIZE_192]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) ctx.str_len = u32(len(buf[:read])) if read > 0 { update(&ctx, buf[:read]) @@ -759,7 +759,7 @@ hash_stream_192_5 :: proc(s: io.Stream) -> ([DIGEST_SIZE_192]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) ctx.str_len = u32(len(buf[:read])) if read > 0 { update(&ctx, buf[:read]) @@ -844,7 +844,7 @@ hash_stream_224_3 :: proc(s: io.Stream) -> ([DIGEST_SIZE_224]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) ctx.str_len = u32(len(buf[:read])) if read > 0 { update(&ctx, buf[:read]) @@ -929,7 +929,7 @@ hash_stream_224_4 :: proc(s: io.Stream) -> ([DIGEST_SIZE_224]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) ctx.str_len = u32(len(buf[:read])) if read > 0 { update(&ctx, buf[:read]) @@ -1014,7 +1014,7 @@ hash_stream_224_5 :: proc(s: io.Stream) -> ([DIGEST_SIZE_224]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) ctx.str_len = u32(len(buf[:read])) if read > 0 { update(&ctx, buf[:read]) @@ -1099,7 +1099,7 @@ hash_stream_256_3 :: proc(s: io.Stream) -> ([DIGEST_SIZE_256]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) ctx.str_len = u32(len(buf[:read])) if read > 0 { update(&ctx, buf[:read]) @@ -1184,7 +1184,7 @@ hash_stream_256_4 :: proc(s: io.Stream) -> ([DIGEST_SIZE_256]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) ctx.str_len = u32(len(buf[:read])) if read > 0 { update(&ctx, buf[:read]) @@ -1270,7 +1270,7 @@ hash_stream_256_5 :: proc(s: io.Stream) -> ([DIGEST_SIZE_256]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) ctx.str_len = u32(len(buf[:read])) if read > 0 { update(&ctx, buf[:read]) diff --git a/core/crypto/jh/jh.odin b/core/crypto/jh/jh.odin index 42c2d1d34..5dc6c4e6b 100644 --- a/core/crypto/jh/jh.odin +++ b/core/crypto/jh/jh.odin @@ -70,7 +70,7 @@ hash_stream_224 :: proc(s: io.Stream) -> ([DIGEST_SIZE_224]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { update(&ctx, buf[:read]) } @@ -149,7 +149,7 @@ hash_stream_256 :: proc(s: io.Stream) -> ([DIGEST_SIZE_256]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { update(&ctx, buf[:read]) } @@ -228,7 +228,7 @@ hash_stream_384 :: proc(s: io.Stream) -> ([DIGEST_SIZE_384]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { update(&ctx, buf[:read]) } @@ -307,7 +307,7 @@ hash_stream_512 :: proc(s: io.Stream) -> ([DIGEST_SIZE_512]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { update(&ctx, buf[:read]) } diff --git a/core/crypto/keccak/keccak.odin b/core/crypto/keccak/keccak.odin index aeb5aac52..4c74858d2 100644 --- a/core/crypto/keccak/keccak.odin +++ b/core/crypto/keccak/keccak.odin @@ -77,7 +77,7 @@ hash_stream_224 :: proc(s: io.Stream) -> ([DIGEST_SIZE_224]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { _sha3.update(&ctx, buf[:read]) } @@ -159,7 +159,7 @@ hash_stream_256 :: proc(s: io.Stream) -> ([DIGEST_SIZE_256]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { _sha3.update(&ctx, buf[:read]) } @@ -241,7 +241,7 @@ hash_stream_384 :: proc(s: io.Stream) -> ([DIGEST_SIZE_384]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { _sha3.update(&ctx, buf[:read]) } @@ -323,7 +323,7 @@ hash_stream_512 :: proc(s: io.Stream) -> ([DIGEST_SIZE_512]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { _sha3.update(&ctx, buf[:read]) } diff --git a/core/crypto/md2/md2.odin b/core/crypto/md2/md2.odin index 711e6e9f6..4942183e1 100644 --- a/core/crypto/md2/md2.odin +++ b/core/crypto/md2/md2.odin @@ -64,7 +64,7 @@ hash_stream :: proc(s: io.Stream) -> ([DIGEST_SIZE]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { update(&ctx, buf[:read]) } diff --git a/core/crypto/md4/md4.odin b/core/crypto/md4/md4.odin index b2651225b..8efdbb5a5 100644 --- a/core/crypto/md4/md4.odin +++ b/core/crypto/md4/md4.odin @@ -68,7 +68,7 @@ hash_stream :: proc(s: io.Stream) -> ([DIGEST_SIZE]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { update(&ctx, buf[:read]) } diff --git a/core/crypto/md5/md5.odin b/core/crypto/md5/md5.odin index 30a556102..858480b04 100644 --- a/core/crypto/md5/md5.odin +++ b/core/crypto/md5/md5.odin @@ -67,7 +67,7 @@ hash_stream :: proc(s: io.Stream) -> ([DIGEST_SIZE]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { update(&ctx, buf[:read]) } diff --git a/core/crypto/poly1305/poly1305.odin b/core/crypto/poly1305/poly1305.odin index 8986be879..ab320c80c 100644 --- a/core/crypto/poly1305/poly1305.odin +++ b/core/crypto/poly1305/poly1305.odin @@ -8,6 +8,7 @@ import "core:mem" KEY_SIZE :: 32 TAG_SIZE :: 16 +@(private) _BLOCK_SIZE :: 16 sum :: proc (dst, msg, key: []byte) { @@ -141,6 +142,7 @@ reset :: proc (ctx: ^Context) { ctx._is_initialized = false } +@(private) _blocks :: proc (ctx: ^Context, msg: []byte, final := false) { n: field.Tight_Field_Element = --- final_byte := byte(!final) diff --git a/core/crypto/rand_linux.odin b/core/crypto/rand_linux.odin index 4d1183757..e5c194220 100644 --- a/core/crypto/rand_linux.odin +++ b/core/crypto/rand_linux.odin @@ -12,7 +12,7 @@ _rand_bytes :: proc (dst: []byte) { for l > 0 { to_read := min(l, _MAX_PER_CALL_BYTES) - ret := unix.sys_getrandom(raw_data(dst), to_read, 0) + ret := unix.sys_getrandom(raw_data(dst), uint(to_read), 0) if ret < 0 { switch os.Errno(-ret) { case os.EINTR: diff --git a/core/crypto/ripemd/ripemd.odin b/core/crypto/ripemd/ripemd.odin index 702d29037..f9edb121b 100644 --- a/core/crypto/ripemd/ripemd.odin +++ b/core/crypto/ripemd/ripemd.odin @@ -69,7 +69,7 @@ hash_stream_128 :: proc(s: io.Stream) -> ([DIGEST_SIZE_128]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { update(&ctx, buf[:read]) } @@ -145,7 +145,7 @@ hash_stream_160 :: proc(s: io.Stream) -> ([DIGEST_SIZE_160]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { update(&ctx, buf[:read]) } @@ -221,7 +221,7 @@ hash_stream_256 :: proc(s: io.Stream) -> ([DIGEST_SIZE_256]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { update(&ctx, buf[:read]) } @@ -297,7 +297,7 @@ hash_stream_320 :: proc(s: io.Stream) -> ([DIGEST_SIZE_320]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { update(&ctx, buf[:read]) } diff --git a/core/crypto/sha1/sha1.odin b/core/crypto/sha1/sha1.odin index b0dbd7dc8..599d1791e 100644 --- a/core/crypto/sha1/sha1.odin +++ b/core/crypto/sha1/sha1.odin @@ -67,7 +67,7 @@ hash_stream :: proc(s: io.Stream) -> ([DIGEST_SIZE]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { update(&ctx, buf[:read]) } diff --git a/core/crypto/sha2/sha2.odin b/core/crypto/sha2/sha2.odin index 9792a4cb8..0f55c4be1 100644 --- a/core/crypto/sha2/sha2.odin +++ b/core/crypto/sha2/sha2.odin @@ -74,7 +74,7 @@ hash_stream_224 :: proc(s: io.Stream) -> ([DIGEST_SIZE_224]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { update(&ctx, buf[:read]) } @@ -153,7 +153,7 @@ hash_stream_256 :: proc(s: io.Stream) -> ([DIGEST_SIZE_256]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { update(&ctx, buf[:read]) } @@ -232,7 +232,7 @@ hash_stream_384 :: proc(s: io.Stream) -> ([DIGEST_SIZE_384]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { update(&ctx, buf[:read]) } @@ -311,7 +311,7 @@ hash_stream_512 :: proc(s: io.Stream) -> ([DIGEST_SIZE_512]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { update(&ctx, buf[:read]) } diff --git a/core/crypto/sha3/sha3.odin b/core/crypto/sha3/sha3.odin index 1202f8b23..5d8ad2106 100644 --- a/core/crypto/sha3/sha3.odin +++ b/core/crypto/sha3/sha3.odin @@ -73,7 +73,7 @@ hash_stream_224 :: proc(s: io.Stream) -> ([DIGEST_SIZE_224]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { _sha3.update(&ctx, buf[:read]) } @@ -152,7 +152,7 @@ hash_stream_256 :: proc(s: io.Stream) -> ([DIGEST_SIZE_256]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { _sha3.update(&ctx, buf[:read]) } @@ -231,7 +231,7 @@ hash_stream_384 :: proc(s: io.Stream) -> ([DIGEST_SIZE_384]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { _sha3.update(&ctx, buf[:read]) } @@ -310,7 +310,7 @@ hash_stream_512 :: proc(s: io.Stream) -> ([DIGEST_SIZE_512]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { _sha3.update(&ctx, buf[:read]) } diff --git a/core/crypto/shake/shake.odin b/core/crypto/shake/shake.odin index 525dcfbd3..020ba68f3 100644 --- a/core/crypto/shake/shake.odin +++ b/core/crypto/shake/shake.odin @@ -73,7 +73,7 @@ hash_stream_128 :: proc(s: io.Stream) -> ([DIGEST_SIZE_128]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { _sha3.update(&ctx, buf[:read]) } @@ -155,7 +155,7 @@ hash_stream_256 :: proc(s: io.Stream) -> ([DIGEST_SIZE_256]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { _sha3.update(&ctx, buf[:read]) } diff --git a/core/crypto/sm3/sm3.odin b/core/crypto/sm3/sm3.odin index 74c9f22e2..9e684ff08 100644 --- a/core/crypto/sm3/sm3.odin +++ b/core/crypto/sm3/sm3.odin @@ -66,7 +66,7 @@ hash_stream :: proc(s: io.Stream) -> ([DIGEST_SIZE]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { update(&ctx, buf[:read]) } diff --git a/core/crypto/streebog/streebog.odin b/core/crypto/streebog/streebog.odin index f85977cba..42da1e695 100644 --- a/core/crypto/streebog/streebog.odin +++ b/core/crypto/streebog/streebog.odin @@ -70,7 +70,7 @@ hash_stream_256 :: proc(s: io.Stream) -> ([DIGEST_SIZE_256]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { update(&ctx, buf[:read]) } @@ -146,7 +146,7 @@ hash_stream_512 :: proc(s: io.Stream) -> ([DIGEST_SIZE_512]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { update(&ctx, buf[:read]) } diff --git a/core/crypto/tiger/tiger.odin b/core/crypto/tiger/tiger.odin index cf6159fad..614926129 100644 --- a/core/crypto/tiger/tiger.odin +++ b/core/crypto/tiger/tiger.odin @@ -71,7 +71,7 @@ hash_stream_128 :: proc(s: io.Stream) -> ([DIGEST_SIZE_128]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { _tiger.update(&ctx, buf[:read]) } @@ -150,7 +150,7 @@ hash_stream_160 :: proc(s: io.Stream) -> ([DIGEST_SIZE_160]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { _tiger.update(&ctx, buf[:read]) } @@ -229,7 +229,7 @@ hash_stream_192 :: proc(s: io.Stream) -> ([DIGEST_SIZE_192]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { _tiger.update(&ctx, buf[:read]) } diff --git a/core/crypto/tiger2/tiger2.odin b/core/crypto/tiger2/tiger2.odin index e8f2c4edb..ead874d56 100644 --- a/core/crypto/tiger2/tiger2.odin +++ b/core/crypto/tiger2/tiger2.odin @@ -71,7 +71,7 @@ hash_stream_128 :: proc(s: io.Stream) -> ([DIGEST_SIZE_128]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { _tiger.update(&ctx, buf[:read]) } @@ -150,7 +150,7 @@ hash_stream_160 :: proc(s: io.Stream) -> ([DIGEST_SIZE_160]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { _tiger.update(&ctx, buf[:read]) } @@ -229,7 +229,7 @@ hash_stream_192 :: proc(s: io.Stream) -> ([DIGEST_SIZE_192]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { _tiger.update(&ctx, buf[:read]) } diff --git a/core/crypto/util/util.odin b/core/crypto/util/util.odin index 6273a232e..b9b80124a 100644 --- a/core/crypto/util/util.odin +++ b/core/crypto/util/util.odin @@ -11,6 +11,8 @@ package util */ import "core:mem" +// Keep vet happy +_ :: mem // @note(bp): this can replace the other two cast_slice :: #force_inline proc "contextless" ($D: typeid/[]$DE, src: $S/[]$SE) -> D { diff --git a/core/crypto/whirlpool/whirlpool.odin b/core/crypto/whirlpool/whirlpool.odin index 0cfef7c6b..cf0bf6490 100644 --- a/core/crypto/whirlpool/whirlpool.odin +++ b/core/crypto/whirlpool/whirlpool.odin @@ -66,7 +66,7 @@ hash_stream :: proc(s: io.Stream) -> ([DIGEST_SIZE]byte, bool) { defer delete(buf) read := 1 for read > 0 { - read, _ = s->impl_read(buf) + read, _ = io.read(s, buf) if read > 0 { update(&ctx, buf[:read]) } diff --git a/core/crypto/x25519/x25519.odin b/core/crypto/x25519/x25519.odin index dfc8daa47..fc446d25c 100644 --- a/core/crypto/x25519/x25519.odin +++ b/core/crypto/x25519/x25519.odin @@ -6,8 +6,10 @@ import "core:mem" SCALAR_SIZE :: 32 POINT_SIZE :: 32 +@(private) _BASE_POINT: [32]byte = {9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +@(private) _scalar_bit :: #force_inline proc "contextless" (s: ^[32]byte, i: int) -> u8 { if i < 0 { return 0 @@ -15,6 +17,7 @@ _scalar_bit :: #force_inline proc "contextless" (s: ^[32]byte, i: int) -> u8 { return (s[i>>3] >> uint(i&7)) & 1 } +@(private) _scalarmult :: proc (out, scalar, point: ^[32]byte) { // Montgomery pseduo-multiplication taken from Monocypher. diff --git a/core/debug/pe/section.odin b/core/debug/pe/section.odin index 809da8bb4..926306dbb 100644 --- a/core/debug/pe/section.odin +++ b/core/debug/pe/section.odin @@ -1,8 +1,5 @@ package debug_pe -import "core:runtime" -import "core:io" - Section_Header32 :: struct { name: [8]u8, virtual_size: u32le, diff --git a/core/dynlib/doc.odin b/core/dynlib/doc.odin new file mode 100644 index 000000000..812fb02d5 --- /dev/null +++ b/core/dynlib/doc.odin @@ -0,0 +1,7 @@ +/* +Package core:dynlib implements loading of shared libraries/DLLs and their symbols. + +The behaviour of dynamically loaded libraries is specific to the target platform of the program. +For in depth detail on the underlying behaviour please refer to your target platform's documentation. +*/ +package dynlib diff --git a/core/dynlib/lib.odin b/core/dynlib/lib.odin index a6c857ee4..b5cb16e3c 100644 --- a/core/dynlib/lib.odin +++ b/core/dynlib/lib.odin @@ -1,15 +1,94 @@ package dynlib +/* +A handle to a dynamically loaded library. +*/ Library :: distinct rawptr -load_library :: proc(path: string, global_symbols := false) -> (Library, bool) { +/* +Loads a dynamic library from the filesystem. The paramater `global_symbols` makes the symbols in the loaded +library available to resolve references in subsequently loaded libraries. + +The paramater `global_symbols` is only used for the platforms `linux`, `darwin`, `freebsd` and `openbsd`. +On `windows` this paramater is ignored. + +The underlying behaviour is platform specific. +On `linux`, `darwin`, `freebsd` and `openbsd` refer to `dlopen`. +On `windows` refer to `LoadLibraryW`. + +**Implicit Allocators** +`context.temp_allocator` + +Example: + import "core:dynlib" + import "core:fmt" + + load_my_library :: proc() { + LIBRARY_PATH :: "my_library.dll" + library, ok := dynlib.load_library(LIBRARY_PATH) + if ! ok { + return + } + fmt.println("The library %q was successfully loaded", LIBRARY_PATH) + } +*/ +load_library :: proc(path: string, global_symbols := false) -> (library: Library, did_load: bool) { return _load_library(path, global_symbols) } -unload_library :: proc(library: Library) -> bool { +/* +Unloads a dynamic library. + +The underlying behaviour is platform specific. +On `linux`, `darwin`, `freebsd` and `openbsd` refer to `dlclose`. +On `windows` refer to `FreeLibrary`. + +Example: + import "core:dynlib" + import "core:fmt" + + load_then_unload_my_library :: proc() { + LIBRARY_PATH :: "my_library.dll" + library, ok := dynlib.load_library(LIBRARY_PATH) + if ! ok { + return + } + did_unload := dynlib.unload_library(library) + if ! did_unload { + return + } + fmt.println("The library %q was successfully unloaded", LIBRARY_PATH) + } +*/ +unload_library :: proc(library: Library) -> (did_unload: bool) { return _unload_library(library) } +/* +Loads the address of a procedure/variable from a dynamic library. + +The underlying behaviour is platform specific. +On `linux`, `darwin`, `freebsd` and `openbsd` refer to `dlsym`. +On `windows` refer to `GetProcAddress`. + +**Implicit Allocators** +`context.temp_allocator` + +Example: + import "core:dynlib" + import "core:fmt" + + find_a_in_my_library :: proc() { + LIBRARY_PATH :: "my_library.dll" + library, ok := dynlib.load_library(LIBRARY_PATH) + if ! ok { + return + } + + a, found_a := dynlib.symbol_address(library, "a") + if found_a do fmt.printf("The symbol %q was found at the address %v", "a", a) + } +*/ symbol_address :: proc(library: Library, symbol: string) -> (ptr: rawptr, found: bool) #optional_ok { return _symbol_address(library, symbol) } diff --git a/core/dynlib/lib_js.odin b/core/dynlib/lib_js.odin new file mode 100644 index 000000000..ace1b0939 --- /dev/null +++ b/core/dynlib/lib_js.odin @@ -0,0 +1,15 @@ +//+build js +//+private +package dynlib + +_load_library :: proc(path: string, global_symbols := false) -> (Library, bool) { + return nil, false +} + +_unload_library :: proc(library: Library) -> bool { + return false +} + +_symbol_address :: proc(library: Library, symbol: string) -> (ptr: rawptr, found: bool) { + return nil, false +} diff --git a/core/dynlib/lib_windows.odin b/core/dynlib/lib_windows.odin index d48e43ca2..67880df4b 100644 --- a/core/dynlib/lib_windows.odin +++ b/core/dynlib/lib_windows.odin @@ -4,10 +4,12 @@ package dynlib import win32 "core:sys/windows" import "core:strings" +import "core:runtime" _load_library :: proc(path: string, global_symbols := false) -> (Library, bool) { // NOTE(bill): 'global_symbols' is here only for consistency with POSIX which has RTLD_GLOBAL + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() wide_path := win32.utf8_to_wstring(path, context.temp_allocator) handle := cast(Library)win32.LoadLibraryW(wide_path) return handle, handle != nil @@ -19,6 +21,7 @@ _unload_library :: proc(library: Library) -> bool { } _symbol_address :: proc(library: Library, symbol: string) -> (ptr: rawptr, found: bool) { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() c_str := strings.clone_to_cstring(symbol, context.temp_allocator) ptr = win32.GetProcAddress(cast(win32.HMODULE)library, c_str) found = ptr != nil diff --git a/core/encoding/csv/writer.odin b/core/encoding/csv/writer.odin index 3a0038916..d519104f2 100644 --- a/core/encoding/csv/writer.odin +++ b/core/encoding/csv/writer.odin @@ -42,7 +42,7 @@ write :: proc(w: ^Writer, record: []string) -> io.Error { } } case: - if strings.contains_rune(field, w.comma) >= 0 { + if strings.contains_rune(field, w.comma) { return true } if strings.contains_any(field, CHAR_SET) { diff --git a/core/encoding/hex/hex.odin b/core/encoding/hex/hex.odin new file mode 100644 index 000000000..ef0bab1d0 --- /dev/null +++ b/core/encoding/hex/hex.odin @@ -0,0 +1,73 @@ +package hex + +import "core:strings" + +encode :: proc(src: []byte, allocator := context.allocator) -> []byte #no_bounds_check { + dst := make([]byte, len(src) * 2, allocator) + for i, j := 0, 0; i < len(src); i += 1 { + v := src[i] + dst[j] = HEXTABLE[v>>4] + dst[j+1] = HEXTABLE[v&0x0f] + j += 2 + } + + return dst +} + + +decode :: proc(src: []byte, allocator := context.allocator) -> (dst: []byte, ok: bool) #no_bounds_check { + if len(src) % 2 == 1 { + return + } + + dst = make([]byte, len(src) / 2, allocator) + for i, j := 0, 1; j < len(src); j += 2 { + p := src[j-1] + q := src[j] + + a := hex_digit(p) or_return + b := hex_digit(q) or_return + + dst[i] = (a << 4) | b + i += 1 + } + + return dst, true +} + +// Decodes the given sequence into one byte. +// Should be called with one byte worth of the source, eg: 0x23 -> '#'. +decode_sequence :: proc(str: string) -> (res: byte, ok: bool) { + str := str + if strings.has_prefix(str, "0x") || strings.has_prefix(str, "0X") { + str = str[2:] + } + + if len(str) != 2 { + return 0, false + } + + upper := hex_digit(str[0]) or_return + lower := hex_digit(str[1]) or_return + + return upper << 4 | lower, true +} + +@(private) +HEXTABLE := [16]byte { + '0', '1', '2', '3', + '4', '5', '6', '7', + '8', '9', 'a', 'b', + 'c', 'd', 'e', 'f', +} + +@(private) +hex_digit :: proc(char: byte) -> (u8, bool) { + switch char { + case '0' ..= '9': return char - '0', true + case 'a' ..= 'f': return char - 'a' + 10, true + case 'A' ..= 'F': return char - 'A' + 10, true + case: return 0, false + } +} + diff --git a/core/encoding/json/marshal.odin b/core/encoding/json/marshal.odin index 1dadc8ef0..d25015ac7 100644 --- a/core/encoding/json/marshal.odin +++ b/core/encoding/json/marshal.odin @@ -153,7 +153,7 @@ marshal_to_writer :: proc(w: io.Writer, v: any, opt: ^Marshal_Options) -> (err: case complex128: r, i = f64(real(z)), f64(imag(z)) case: return .Unsupported_Type } - + io.write_byte(w, '[') or_return io.write_f64(w, r) or_return io.write_string(w, ", ") or_return @@ -165,8 +165,8 @@ marshal_to_writer :: proc(w: io.Writer, v: any, opt: ^Marshal_Options) -> (err: case runtime.Type_Info_String: switch s in a { - case string: io.write_quoted_string(w, s) or_return - case cstring: io.write_quoted_string(w, string(s)) or_return + case string: io.write_quoted_string(w, s, '"', nil, true) or_return + case cstring: io.write_quoted_string(w, string(s), '"', nil, true) or_return } case runtime.Type_Info_Boolean: @@ -198,7 +198,7 @@ marshal_to_writer :: proc(w: io.Writer, v: any, opt: ^Marshal_Options) -> (err: case runtime.Type_Info_Procedure: return .Unsupported_Type - case runtime.Type_Info_Tuple: + case runtime.Type_Info_Parameters: return .Unsupported_Type case runtime.Type_Info_Simd_Vector: @@ -262,10 +262,14 @@ marshal_to_writer :: proc(w: io.Writer, v: any, opt: ^Marshal_Options) -> (err: } map_cap := uintptr(runtime.map_cap(m^)) ks, vs, hs, _, _ := runtime.map_kvh_data_dynamic(m^, info.map_info) + + i := 0 for bucket_index in 0.. (err: i return } -// insert comma seperation and write indentations +// insert comma separation and write indentations opt_write_iteration :: proc(w: io.Writer, opt: ^Marshal_Options, iteration: int) -> (err: io.Error) { switch opt.spec { case .JSON, .JSON5: @@ -457,7 +461,7 @@ opt_write_iteration :: proc(w: io.Writer, opt: ^Marshal_Options, iteration: int) if opt.pretty { io.write_byte(w, '\n') or_return } else { - // comma seperation necessary for non pretty output! + // comma separation necessary for non pretty output! io.write_string(w, ", ") or_return } } diff --git a/core/encoding/json/parser.odin b/core/encoding/json/parser.odin index ed36ae33b..d007e16d7 100644 --- a/core/encoding/json/parser.odin +++ b/core/encoding/json/parser.odin @@ -2,6 +2,7 @@ package json import "core:mem" import "core:unicode/utf8" +import "core:unicode/utf16" import "core:strconv" Parser :: struct { @@ -403,11 +404,19 @@ unquote_string :: proc(token: Token, spec: Specification, allocator := context.a } i += 6 + // If this is a surrogate pair, decode as such by taking the next rune too. + if r >= utf8.SURROGATE_MIN && r <= utf8.SURROGATE_HIGH_MAX && len(s) > i + 2 && s[i:i+2] == "\\u" { + r2 := get_u4_rune(s[i:]) + if r2 >= utf8.SURROGATE_LOW_MIN && r2 <= utf8.SURROGATE_MAX { + i += 6 + r = utf16.decode_surrogate_pair(r, r2) + } + } + buf, buf_width := utf8.encode_rune(r) copy(b[w:], buf[:buf_width]) w += buf_width - case '0': if spec != .JSON { b[w] = '\x00' diff --git a/core/encoding/json/tokenizer.odin b/core/encoding/json/tokenizer.odin index 567600b90..a406a73a5 100644 --- a/core/encoding/json/tokenizer.odin +++ b/core/encoding/json/tokenizer.odin @@ -163,8 +163,9 @@ get_token :: proc(t: ^Tokenizer) -> (token: Token, err: Error) { skip_alphanum :: proc(t: ^Tokenizer) { for t.offset < len(t.data) { - switch next_rune(t) { + switch t.r { case 'A'..='Z', 'a'..='z', '0'..='9', '_': + next_rune(t) continue } diff --git a/core/encoding/json/types.odin b/core/encoding/json/types.odin index 468774aa9..089fd9c9b 100644 --- a/core/encoding/json/types.odin +++ b/core/encoding/json/types.odin @@ -87,7 +87,8 @@ Error :: enum { -destroy_value :: proc(value: Value) { +destroy_value :: proc(value: Value, allocator := context.allocator) { + context.allocator = allocator #partial switch v in value { case Object: for key, elem in v { @@ -103,5 +104,4 @@ destroy_value :: proc(value: Value) { case String: delete(v) } -} - +} \ No newline at end of file diff --git a/core/encoding/json/unmarshal.odin b/core/encoding/json/unmarshal.odin index 11cae6160..e6c61d8fa 100644 --- a/core/encoding/json/unmarshal.odin +++ b/core/encoding/json/unmarshal.odin @@ -215,6 +215,12 @@ unmarshal_value :: proc(p: ^Parser, v: any) -> (err: Unmarshal_Error) { } } + switch dst in &v { + // Handle json.Value as an unknown type + case Value: + dst = parse_value(p) or_return + return + } #partial switch token.kind { case .Null: @@ -346,6 +352,8 @@ unmarshal_object :: proc(p: ^Parser, v: any, end_token: Token_Kind) -> (err: Unm fields := reflect.struct_fields_zipped(ti.id) + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD(ignore = context.temp_allocator == context.allocator) + field_used := make([]bool, len(fields), context.temp_allocator) use_field_idx := -1 diff --git a/core/encoding/xml/xml_reader.odin b/core/encoding/xml/xml_reader.odin index b77ae97b3..f5523c299 100644 --- a/core/encoding/xml/xml_reader.odin +++ b/core/encoding/xml/xml_reader.odin @@ -33,6 +33,7 @@ import "core:intrinsics" import "core:mem" import "core:os" import "core:strings" +import "core:runtime" likely :: intrinsics.expect @@ -408,7 +409,7 @@ parse_bytes :: proc(data: []u8, options := DEFAULT_OPTIONS, path := "", error_ha next := scan(t) #partial switch next.kind { case .Ident: - if len(next.text) == 3 && strings.to_lower(next.text, context.temp_allocator) == "xml" { + if len(next.text) == 3 && strings.equal_fold(next.text, "xml") { parse_prologue(doc) or_return } else if len(doc.prologue) > 0 { /* @@ -614,6 +615,7 @@ parse_prologue :: proc(doc: ^Document) -> (err: Error) { } case "encoding": + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() switch strings.to_lower(attr.val, context.temp_allocator) { case "utf-8", "utf8": doc.encoding = .UTF_8 diff --git a/core/fmt/doc.odin b/core/fmt/doc.odin index 668fc9bc6..991058661 100644 --- a/core/fmt/doc.odin +++ b/core/fmt/doc.odin @@ -68,7 +68,7 @@ A period with no following number specifies a precision of 0. Examples: %f default width, default precision %8f width 8, default precision - %.3f default width, precision 2 + %.2f default width, precision 2 %8.3f width 8, precision 3 %8.f width 8, precision 0 diff --git a/core/fmt/fmt.odin b/core/fmt/fmt.odin index 79b575482..f1f94b1b3 100644 --- a/core/fmt/fmt.odin +++ b/core/fmt/fmt.odin @@ -44,6 +44,31 @@ Info :: struct { // Custom formatter signature. It returns true if the formatting was successful and false when it could not be done User_Formatter :: #type proc(fi: ^Info, arg: any, verb: rune) -> bool +// Example User Formatter: +// SomeType :: struct { +// value: int, +// } +// // Custom Formatter for SomeType +// User_Formatter :: proc(fi: ^fmt.Info, arg: any, verb: rune) -> bool { +// m := cast(^SomeType)arg.data +// switch verb { +// case 'v', 'd': +// fmt.fmt_int(fi, u64(m.value), true, 8 * size_of(SomeType), verb) +// case: +// return false +// } +// return true +// } +// main :: proc() { +// // Ensure the fmt._user_formatters map is initialized +// fmt.set_user_formatters(new(map[typeid]fmt.User_Formatter)) +// err := fmt.register_user_formatter(type_info_of(SomeType).id, User_Formatter) +// assert(err == .None) +// // Use the custom formatter +// x := SomeType{42} +// fmt.println("Custom type value: ", x) +// } + Register_User_Formatter_Error :: enum { None, No_User_Formatter, @@ -54,13 +79,27 @@ Register_User_Formatter_Error :: enum { // it is prefixed with `_` rather than marked with a private attribute so that users can access it if necessary _user_formatters: ^map[typeid]User_Formatter -// set_user_formatters assigns m to a global value allowing the user have custom print formatting for specific -// types +// Sets user-defined formatters for custom print formatting of specific types +// +// Inputs: +// - m: A pointer to a map of typeids to User_Formatter structs. +// +// NOTE: Must be called before using register_user_formatter. +// set_user_formatters :: proc(m: ^map[typeid]User_Formatter) { - _user_formatters = m + assert(_user_formatters == nil, "set_user_formatters must not be called more than once.") + _user_formatters = m } -// register_user_formatter assigns a formatter to a specific typeid. set_user_formatters must be called -// before any use of this procedure. +// Registers a user-defined formatter for a specific typeid +// +// Inputs: +// - id: The typeid of the custom type. +// - formatter: The User_Formatter function for the custom type. +// +// Returns: A Register_User_Formatter_Error value indicating the success or failure of the operation. +// +// WARNING: set_user_formatters must be called before using this procedure. +// register_user_formatter :: proc(id: typeid, formatter: User_Formatter) -> Register_User_Formatter_Error { if _user_formatters == nil { return .No_User_Formatter @@ -71,75 +110,151 @@ register_user_formatter :: proc(id: typeid, formatter: User_Formatter) -> Regist _user_formatters[id] = formatter return .None } - - -// aprint procedure return a string that was allocated with the current context -// They must be freed accordingly +// Creates a formatted string +// +// *Allocates Using Context's Allocator* +// +// Inputs: +// - args: A variadic list of arguments to be formatted. +// - sep: An optional separator string (default is a single space). +// +// Returns: A formatted string. +// aprint :: proc(args: ..any, sep := " ") -> string { str: strings.Builder strings.builder_init(&str) - sbprint(buf=&str, args=args, sep=sep) + sbprint(&str, ..args, sep=sep) return strings.to_string(str) } -// aprintln procedure return a string that was allocated with the current context -// They must be freed accordingly +// Creates a formatted string with a newline character at the end +// +// *Allocates Using Context's Allocator* +// +// Inputs: +// - args: A variadic list of arguments to be formatted. +// - sep: An optional separator string (default is a single space). +// +// Returns: A formatted string with a newline character at the end. +// aprintln :: proc(args: ..any, sep := " ") -> string { str: strings.Builder strings.builder_init(&str) - sbprintln(buf=&str, args=args, sep=sep) + sbprintln(&str, ..args, sep=sep) return strings.to_string(str) } -// aprintf procedure return a string that was allocated with the current context -// They must be freed accordingly +// Creates a formatted string using a format string and arguments +// +// *Allocates Using Context's Allocator* +// +// Inputs: +// - fmt: A format string with placeholders for the provided arguments. +// - args: A variadic list of arguments to be formatted. +// +// Returns: A formatted string. The returned string must be freed accordingly. +// aprintf :: proc(fmt: string, args: ..any) -> string { str: strings.Builder strings.builder_init(&str) sbprintf(&str, fmt, ..args) return strings.to_string(str) } - - -// tprint procedure return a string that was allocated with the current context's temporary allocator +// Creates a formatted string +// +// *Allocates Using Context's Temporary Allocator* +// +// Inputs: +// - args: A variadic list of arguments to be formatted. +// - sep: An optional separator string (default is a single space). +// +// Returns: A formatted string. +// tprint :: proc(args: ..any, sep := " ") -> string { str: strings.Builder strings.builder_init(&str, context.temp_allocator) - sbprint(buf=&str, args=args, sep=sep) + sbprint(&str, ..args, sep=sep) return strings.to_string(str) } -// tprintln procedure return a string that was allocated with the current context's temporary allocator +// Creates a formatted string with a newline character at the end +// +// *Allocates Using Context's Temporary Allocator* +// +// Inputs: +// - args: A variadic list of arguments to be formatted. +// - sep: An optional separator string (default is a single space). +// +// Returns: A formatted string with a newline character at the end. +// tprintln :: proc(args: ..any, sep := " ") -> string { str: strings.Builder strings.builder_init(&str, context.temp_allocator) - sbprintln(buf=&str, args=args, sep=sep) + sbprintln(&str, ..args, sep=sep) return strings.to_string(str) } -// tprintf procedure return a string that was allocated with the current context's temporary allocator +// Creates a formatted string using a format string and arguments +// +// *Allocates Using Context's Temporary Allocator* +// +// Inputs: +// - fmt: A format string with placeholders for the provided arguments. +// - args: A variadic list of arguments to be formatted. +// +// Returns: A formatted string. +// tprintf :: proc(fmt: string, args: ..any) -> string { str: strings.Builder strings.builder_init(&str, context.temp_allocator) sbprintf(&str, fmt, ..args) return strings.to_string(str) } - - -// bprint procedures return a string using a buffer from an array +// Creates a formatted string using a supplied buffer as the backing array. Writes into the buffer. +// +// Inputs: +// - buf: The backing buffer +// - args: A variadic list of arguments to be formatted +// - sep: An optional separator string (default is a single space) +// +// Returns: A formatted string +// bprint :: proc(buf: []byte, args: ..any, sep := " ") -> string { sb := strings.builder_from_bytes(buf[0:len(buf)]) - return sbprint(buf=&sb, args=args, sep=sep) + return sbprint(&sb, ..args, sep=sep) } -// bprintln procedures return a string using a buffer from an array +// Creates a formatted string using a supplied buffer as the backing array, appends newline. Writes into the buffer. +// +// Inputs: +// - buf: The backing buffer +// - args: A variadic list of arguments to be formatted +// - sep: An optional separator string (default is a single space) +// +// Returns: A formatted string with a newline character at the end +// bprintln :: proc(buf: []byte, args: ..any, sep := " ") -> string { sb := strings.builder_from_bytes(buf[0:len(buf)]) - return sbprintln(buf=&sb, args=args, sep=sep) + return sbprintln(&sb, ..args, sep=sep) } -// bprintf procedures return a string using a buffer from an array +// Creates a formatted string using a supplied buffer as the backing array. Writes into the buffer. +// +// Inputs: +// - buf: The backing buffer +// - fmt: A format string with placeholders for the provided arguments +// - args: A variadic list of arguments to be formatted +// +// Returns: A formatted string +// bprintf :: proc(buf: []byte, fmt: string, args: ..any) -> string { sb := strings.builder_from_bytes(buf[0:len(buf)]) return sbprintf(&sb, fmt, ..args) } - - -// formatted assert +// Runtime assertion with a formatted message +// +// Inputs: +// - condition: The boolean condition to be asserted +// - fmt: A format string with placeholders for the provided arguments +// - args: A variadic list of arguments to be formatted +// - loc: The location of the caller +// +// Returns: True if the condition is met, otherwise triggers a runtime assertion with a formatted message +// assertf :: proc(condition: bool, fmt: string, args: ..any, loc := #caller_location) -> bool { if !condition { p := context.assertion_failure_proc @@ -151,8 +266,13 @@ assertf :: proc(condition: bool, fmt: string, args: ..any, loc := #caller_locati } return condition } - -// formatted panic +// Runtime panic with a formatted message +// +// Inputs: +// - fmt: A format string with placeholders for the provided arguments +// - args: A variadic list of arguments to be formatted +// - loc: The location of the caller +// panicf :: proc(fmt: string, args: ..any, loc := #caller_location) -> ! { p := context.assertion_failure_proc if p == nil { @@ -161,8 +281,16 @@ panicf :: proc(fmt: string, args: ..any, loc := #caller_location) -> ! { message := tprintf(fmt, ..args) p("Panic", message, loc) } - -// formatted printing for cstrings +// Creates a formatted C string +// +// *Allocates Using Context's Allocator* +// +// Inputs: +// - format: A format string with placeholders for the provided arguments +// - args: A variadic list of arguments to be formatted +// +// Returns: A formatted C string +// caprintf :: proc(format: string, args: ..any) -> cstring { str: strings.Builder strings.builder_init(&str) @@ -171,8 +299,16 @@ caprintf :: proc(format: string, args: ..any) -> cstring { s := strings.to_string(str) return cstring(raw_data(s)) } - -// c string with temp allocator +// Creates a formatted C string +// +// *Allocates Using Context's Temporary Allocator* +// +// Inputs: +// - format: A format string with placeholders for the provided arguments +// - args: A variadic list of arguments to be formatted +// +// Returns: A formatted C string +// ctprintf :: proc(format: string, args: ..any) -> cstring { str: strings.Builder strings.builder_init(&str, context.temp_allocator) @@ -181,27 +317,54 @@ ctprintf :: proc(format: string, args: ..any) -> cstring { s := strings.to_string(str) return cstring(raw_data(s)) } - -// sbprint formats using the default print settings and writes to buf +// Formats using the default print settings and writes to the given strings.Builder +// +// Inputs: +// - buf: A pointer to a strings.Builder to store the formatted string +// - args: A variadic list of arguments to be formatted +// - sep: An optional separator string (default is a single space) +// +// Returns: A formatted string +// sbprint :: proc(buf: ^strings.Builder, args: ..any, sep := " ") -> string { - wprint(w=strings.to_writer(buf), args=args, sep=sep) + wprint(strings.to_writer(buf), ..args, sep=sep) return strings.to_string(buf^) } - -// sbprintln formats using the default print settings and writes to buf +// Formats and writes to a strings.Builder buffer using the default print settings +// +// Inputs: +// - buf: A pointer to a strings.Builder buffer +// - args: A variadic list of arguments to be formatted +// - sep: An optional separator string (default is a single space) +// +// Returns: The resulting formatted string +// sbprintln :: proc(buf: ^strings.Builder, args: ..any, sep := " ") -> string { - wprintln(w=strings.to_writer(buf), args=args, sep=sep) + wprintln(strings.to_writer(buf), ..args, sep=sep) return strings.to_string(buf^) } - -// sbprintf formats according to the specififed format string and writes to buf +// Formats and writes to a strings.Builder buffer according to the specified format string +// +// Inputs: +// - buf: A pointer to a strings.Builder buffer +// - fmt: The format string +// - args: A variadic list of arguments to be formatted +// +// Returns: The resulting formatted string +// sbprintf :: proc(buf: ^strings.Builder, fmt: string, args: ..any) -> string { - wprintf(w=strings.to_writer(buf), fmt=fmt, args=args) + wprintf(strings.to_writer(buf), fmt, ..args) return strings.to_string(buf^) } - - -// wprint formats using the default print settings and writes to w +// Formats and writes to an io.Writer using the default print settings +// +// Inputs: +// - w: An io.Writer to write to +// - args: A variadic list of arguments to be formatted +// - sep: An optional separator string (default is a single space) +// +// Returns: The number of bytes written +// wprint :: proc(w: io.Writer, args: ..any, sep := " ") -> int { fi: Info fi.writer = w @@ -232,8 +395,15 @@ wprint :: proc(w: io.Writer, args: ..any, sep := " ") -> int { return fi.n } - -// wprintln formats using the default print settings and writes to w +// Formats and writes to an io.Writer using the default print settings with a newline character at the end +// +// Inputs: +// - w: An io.Writer to write to +// - args: A variadic list of arguments to be formatted +// - sep: An optional separator string (default is a single space) +// +// Returns: The number of bytes written +// wprintln :: proc(w: io.Writer, args: ..any, sep := " ") -> int { fi: Info fi.writer = w @@ -249,8 +419,15 @@ wprintln :: proc(w: io.Writer, args: ..any, sep := " ") -> int { io.flush(auto_cast w) return fi.n } - -// wprintf formats according to the specififed format string and writes to w +// Formats and writes to an io.Writer according to the specified format string +// +// Inputs: +// - w: An io.Writer to write to +// - fmt: The format string +// - args: A variadic list of arguments to be formatted +// +// Returns: The number of bytes written +// wprintf :: proc(w: io.Writer, fmt: string, args: ..any) -> int { fi: Info arg_index: int = 0 @@ -526,28 +703,48 @@ wprintf :: proc(w: io.Writer, fmt: string, args: ..any) -> int { return fi.n } - -// wprint_type is a utility procedure to write a ^runtime.Type_Info value to w +// Writes a ^runtime.Type_Info value to an io.Writer +// +// Inputs: +// - w: An io.Writer to write to +// - info: A pointer to a runtime.Type_Info value +// +// Returns: The number of bytes written and an io.Error if encountered +// wprint_type :: proc(w: io.Writer, info: ^runtime.Type_Info) -> (int, io.Error) { n, err := reflect.write_type(w, info) io.flush(auto_cast w) return n, err } -// wprint_typeid is a utility procedure to write a typeid value to w +// Writes a typeid value to an io.Writer +// +// Inputs: +// - w: An io.Writer to write to +// - id: A typeid value +// +// Returns: The number of bytes written and an io.Error if encountered +// wprint_typeid :: proc(w: io.Writer, id: typeid) -> (int, io.Error) { n, err := reflect.write_type(w, type_info_of(id)) io.flush(auto_cast w) return n, err } - - - - +// Parses an integer from a given string starting at a specified offset +// +// Inputs: +// - s: The string to parse the integer from +// - offset: The position in the string to start parsing the integer +// +// Returns: +// - result: The parsed integer +// - new_offset: The position in the string after parsing the integer +// - ok: A boolean indicating if the parsing was successful +// _parse_int :: proc(s: string, offset: int) -> (result: int, new_offset: int, ok: bool) { is_digit :: #force_inline proc(r: byte) -> bool { return '0' <= r && r <= '9' } new_offset = offset - for new_offset <= len(s) { + for new_offset < len(s) { c := s[new_offset] if !is_digit(c) { break @@ -560,7 +757,20 @@ _parse_int :: proc(s: string, offset: int) -> (result: int, new_offset: int, ok: ok = new_offset > offset return } - +// Parses an argument number from a format string and determines if it's valid +// +// Inputs: +// - fi: A pointer to an Info structure +// - arg_index: The current argument index +// - format: The format string to parse +// - offset: The current position in the format string +// - arg_count: The total number of arguments +// +// Returns: +// - index: The parsed argument index +// - new_offset: The new position in the format string +// - ok: A boolean indicating if the parsed argument number is valid +// _arg_number :: proc(fi: ^Info, arg_index: int, format: string, offset, arg_count: int) -> (index, new_offset: int, ok: bool) { parse_arg_number :: proc(format: string) -> (int, int, bool) { if len(format) < 3 { @@ -594,7 +804,17 @@ _arg_number :: proc(fi: ^Info, arg_index: int, format: string, offset, arg_count fi.good_arg_index = false return arg_index, offset+width, false } - +// Retrieves an integer from a list of any type at the specified index +// +// Inputs: +// - args: A list of values of any type +// - arg_index: The index to retrieve the integer from +// +// Returns: +// - int: The integer value at the specified index +// - new_arg_index: The new argument index +// - ok: A boolean indicating if the conversion to integer was successful +// int_from_arg :: proc(args: []any, arg_index: int) -> (int, int, bool) { num := 0 new_arg_index := arg_index @@ -609,8 +829,12 @@ int_from_arg :: proc(args: []any, arg_index: int) -> (int, int, bool) { return num, new_arg_index, ok } - - +// Writes a bad verb error message +// +// Inputs: +// - fi: A pointer to an Info structure +// - verb: The invalid format verb +// fmt_bad_verb :: proc(using fi: ^Info, verb: rune) { prev_in_bad := fi.in_bad defer fi.in_bad = prev_in_bad @@ -628,7 +852,13 @@ fmt_bad_verb :: proc(using fi: ^Info, verb: rune) { } io.write_byte(writer, ')', &fi.n) } - +// Formats a boolean value according to the specified format verb +// +// Inputs: +// - fi: A pointer to an Info structure +// - b: The boolean value to format +// - verb: The format verb +// fmt_bool :: proc(using fi: ^Info, b: bool, verb: rune) { switch verb { case 't', 'v': @@ -637,8 +867,12 @@ fmt_bool :: proc(using fi: ^Info, b: bool, verb: rune) { fmt_bad_verb(fi, verb) } } - - +// Writes padding characters for formatting +// +// Inputs: +// - fi: A pointer to an Info structure +// - width: The number of padding characters to write +// fmt_write_padding :: proc(fi: ^Info, width: int) { if width <= 0 { return @@ -653,7 +887,18 @@ fmt_write_padding :: proc(fi: ^Info, width: int) { io.write_byte(fi.writer, pad_byte, &fi.n) } } - +// Formats an integer value with specified base, sign, bit size, and digits +// +// Inputs: +// - fi: A pointer to an Info structure +// - u: The integer value to format +// - base: The base for integer formatting +// - is_signed: A boolean indicating if the integer is signed +// - bit_size: The bit size of the integer +// - digits: A string containing the digits for formatting +// +// WARNING: May panic if the width and precision are too big, causing a buffer overrun +// _fmt_int :: proc(fi: ^Info, u: u64, base: int, is_signed: bool, bit_size: int, digits: string) { _, neg := strconv.is_integer_negative(u, is_signed, bit_size) @@ -678,7 +923,7 @@ _fmt_int :: proc(fi: ^Info, u: u64, base: int, is_signed: bool, bit_size: int, d } } else if fi.zero && fi.width_set { prec = fi.width - if neg || fi.plus || fi.space { + if neg || fi.plus { // There needs to be space for the "sign" prec -= 1 } @@ -697,7 +942,6 @@ _fmt_int :: proc(fi: ^Info, u: u64, base: int, is_signed: bool, bit_size: int, d flags: strconv.Int_Flags if fi.hash && !fi.zero { flags |= {.Prefix} } if fi.plus { flags |= {.Plus} } - if fi.space { flags |= {.Space} } s := strconv.append_bits(buf[start:], u, base, is_signed, bit_size, digits, flags) if fi.hash && fi.zero && fi.indent == 0 { @@ -719,7 +963,18 @@ _fmt_int :: proc(fi: ^Info, u: u64, base: int, is_signed: bool, bit_size: int, d fi.zero = false _pad(fi, s) } - +// Formats an int128 value based on the provided formatting options. +// +// Inputs: +// - fi: A pointer to the Info struct containing formatting options. +// - u: The int128 value to be formatted. +// - base: The base to be used for formatting the integer (e.g. 2, 8, 10, 12, 16). +// - is_signed: Whether the value should be treated as signed or unsigned. +// - bit_size: The number of bits of the value (e.g. 64, 128). +// - digits: A string containing the digit characters to use for the formatted integer. +// +// WARNING: Panics if the formatting options result in a buffer overrun. +// _fmt_int_128 :: proc(fi: ^Info, u: u128, base: int, is_signed: bool, bit_size: int, digits: string) { _, neg := strconv.is_integer_negative_128(u, is_signed, bit_size) @@ -744,7 +999,7 @@ _fmt_int_128 :: proc(fi: ^Info, u: u128, base: int, is_signed: bool, bit_size: i } } else if fi.zero && fi.width_set { prec = fi.width - if neg || fi.plus || fi.space { + if neg || fi.plus { // There needs to be space for the "sign" prec -= 1 } @@ -763,7 +1018,6 @@ _fmt_int_128 :: proc(fi: ^Info, u: u128, base: int, is_signed: bool, bit_size: i flags: strconv.Int_Flags if fi.hash && !fi.zero { flags |= {.Prefix} } if fi.plus { flags |= {.Plus} } - if fi.space { flags |= {.Space} } s := strconv.append_bits_128(buf[start:], u, base, is_signed, bit_size, digits, flags) if fi.hash && fi.zero && fi.indent == 0 { @@ -785,10 +1039,16 @@ _fmt_int_128 :: proc(fi: ^Info, u: u128, base: int, is_signed: bool, bit_size: i fi.zero = false _pad(fi, s) } - +// Hex Values: __DIGITS_LOWER := "0123456789abcdefx" __DIGITS_UPPER := "0123456789ABCDEFX" - +// Formats a rune value according to the specified formatting verb. +// +// Inputs: +// - fi: A pointer to the Info struct containing formatting options. +// - r: The rune value to be formatted. +// - verb: The formatting verb to use (e.g. 'c', 'r', 'v', 'q'). +// fmt_rune :: proc(fi: ^Info, r: rune, verb: rune) { switch verb { case 'c', 'r', 'v': @@ -799,7 +1059,15 @@ fmt_rune :: proc(fi: ^Info, r: rune, verb: rune) { fmt_int(fi, u64(r), false, 32, verb) } } - +// Formats an integer value according to the specified formatting verb. +// +// Inputs: +// - fi: A pointer to the Info struct containing formatting options. +// - u: The integer value to be formatted. +// - is_signed: Whether the value should be treated as signed or unsigned. +// - bit_size: The number of bits of the value (e.g. 32, 64). +// - verb: The formatting verb to use (e.g. 'v', 'b', 'o', 'i', 'd', 'z', 'x', 'X', 'c', 'r', 'U'). +// fmt_int :: proc(fi: ^Info, u: u64, is_signed: bool, bit_size: int, verb: rune) { switch verb { case 'v': _fmt_int(fi, u, 10, is_signed, bit_size, __DIGITS_LOWER) @@ -824,7 +1092,15 @@ fmt_int :: proc(fi: ^Info, u: u64, is_signed: bool, bit_size: int, verb: rune) { fmt_bad_verb(fi, verb) } } - +// Formats an int128 value according to the specified formatting verb. +// +// Inputs: +// - fi: A pointer to the Info struct containing formatting options. +// - u: The int128 value to be formatted. +// - is_signed: Whether the value should be treated as signed or unsigned. +// - bit_size: The number of bits of the value (e.g. 64, 128). +// - verb: The formatting verb to use (e.g. 'v', 'b', 'o', 'i', 'd', 'z', 'x', 'X', 'c', 'r', 'U'). +// fmt_int_128 :: proc(fi: ^Info, u: u128, is_signed: bool, bit_size: int, verb: rune) { switch verb { case 'v': _fmt_int_128(fi, u, 10, is_signed, bit_size, __DIGITS_LOWER) @@ -849,7 +1125,12 @@ fmt_int_128 :: proc(fi: ^Info, u: u128, is_signed: bool, bit_size: int, verb: ru fmt_bad_verb(fi, verb) } } - +// Pads a formatted string with the appropriate padding, based on the provided formatting options. +// +// Inputs: +// - fi: A pointer to the Info struct containing formatting options. +// - s: The string to be padded. +// _pad :: proc(fi: ^Info, s: string) { if !fi.width_set { io.write_string(fi.writer, s, &fi.n) @@ -861,85 +1142,58 @@ _pad :: proc(fi: ^Info, s: string) { if fi.minus { // right pad io.write_string(fi.writer, s, &fi.n) fmt_write_padding(fi, width) + } else if !fi.space && s != "" && s[0] == '-' { + // left pad accounting for zero pad of negative number + io.write_byte(fi.writer, '-', &fi.n) + fmt_write_padding(fi, width) + io.write_string(fi.writer, s[1:], &fi.n) } else { // left pad fmt_write_padding(fi, width) io.write_string(fi.writer, s, &fi.n) } } +// Formats a floating-point number with a specific format and precision. +// +// Inputs: +// - fi: Pointer to the Info struct containing format settings. +// - v: The floating-point number to format. +// - bit_size: The size of the floating-point number in bits (16, 32, or 64). +// - verb: The format specifier character. +// - float_fmt: The byte format used for formatting the float (either 'f' or 'e'). +// +// NOTE: Can return "NaN", "+Inf", "-Inf", "+", or "-". +// +_fmt_float_as :: proc(fi: ^Info, v: f64, bit_size: int, verb: rune, float_fmt: byte) { + prec := fi.prec if fi.prec_set else 3 + buf: [386]byte + // Can return "NaN", "+Inf", "-Inf", "+", "-". + str := strconv.append_float(buf[:], v, float_fmt, prec, bit_size) + + if !fi.plus { + // Strip sign from "+" but not "+Inf". + if str[0] == '+' && str[1] != 'I' { + str = str[1:] + } + } + + _pad(fi, str) +} +// Formats a floating-point number with a specific format. +// +// Inputs: +// - fi: Pointer to the Info struct containing format settings. +// - v: The floating-point number to format. +// - bit_size: The size of the floating-point number in bits (16, 32, or 64). +// - verb: The format specifier character. +// fmt_float :: proc(fi: ^Info, v: f64, bit_size: int, verb: rune) { switch verb { case 'f', 'F', 'g', 'G', 'v': - prec: int = 3 - if fi.prec_set { - prec = fi.prec - } - buf: [386]byte - - str := strconv.append_float(buf[1:], v, 'f', prec, bit_size) - b := buf[:len(str)+1] - if b[1] == '+' || b[1] == '-' { - b = b[1:] - } else { - b[0] = '+' - } - - if fi.space && !fi.plus && b[0] == '+' { - b[0] = ' ' - } - - if len(b) > 1 && (b[1] == 'N' || b[1] == 'I') { - io.write_string(fi.writer, string(b), &fi.n) - return - } - - if fi.plus || b[0] != '+' { - if fi.zero && fi.width_set && fi.width > len(b) { - io.write_byte(fi.writer, b[0], &fi.n) - fmt_write_padding(fi, fi.width - len(b)) - io.write_string(fi.writer, string(b[1:]), &fi.n) - } else { - _pad(fi, string(b)) - } - } else { - _pad(fi, string(b[1:])) - } - + _fmt_float_as(fi, v, bit_size, verb, 'f') case 'e', 'E': - prec: int = 3 - if fi.prec_set { - prec = fi.prec - } - buf: [386]byte - - str := strconv.append_float(buf[1:], v, 'e', prec, bit_size) - b := buf[:len(str)+1] - if b[1] == '+' || b[1] == '-' { - b = b[1:] - } else { - b[0] = '+' - } - - if fi.space && !fi.plus && b[0] == '+' { - b[0] = ' ' - } - - if len(b) > 1 && (b[1] == 'N' || b[1] == 'I') { - io.write_string(fi.writer, string(b), &fi.n) - return - } - - if fi.plus || str[0] != '+' { - if fi.zero && fi.width_set && fi.width > len(b) { - io.write_byte(fi.writer, b[0], &fi.n) - fmt_write_padding(fi, fi.width - len(b)) - io.write_string(fi.writer, string(b[1:]), &fi.n) - } else { - _pad(fi, string(b)) - } - } else { - _pad(fi, string(b[1:])) - } + // BUG(): "%.3e" returns "3.000e+00" + _fmt_float_as(fi, v, bit_size, verb, 'e') case 'h', 'H': prev_fi := fi^ @@ -965,8 +1219,13 @@ fmt_float :: proc(fi: ^Info, v: f64, bit_size: int, verb: rune) { fmt_bad_verb(fi, verb) } } - - +// Formats a string with a specific format. +// +// Inputs: +// - fi: Pointer to the Info struct containing format settings. +// - s: The string to format. +// - verb: The format specifier character (e.g. 's', 'v', 'q', 'x', 'X'). +// fmt_string :: proc(fi: ^Info, s: string, verb: rune) { s, verb := s, verb if ol, ok := fi.optional_len.?; ok { @@ -1024,10 +1283,23 @@ fmt_string :: proc(fi: ^Info, s: string, verb: rune) { fmt_bad_verb(fi, verb) } } +// Formats a C-style string with a specific format. +// +// Inputs: +// - fi: Pointer to the Info struct containing format settings. +// - s: The C-style string to format. +// - verb: The format specifier character (Ref fmt_string). +// fmt_cstring :: proc(fi: ^Info, s: cstring, verb: rune) { fmt_string(fi, string(s), verb) } - +// Formats a raw pointer with a specific format. +// +// Inputs: +// - fi: Pointer to the Info struct containing format settings. +// - p: The raw pointer to format. +// - verb: The format specifier character (e.g. 'p', 'v', 'b', 'o', 'i', 'd', 'z', 'x', 'X'). +// fmt_pointer :: proc(fi: ^Info, p: rawptr, verb: rune) { u := u64(uintptr(p)) switch verb { @@ -1048,7 +1320,13 @@ fmt_pointer :: proc(fi: ^Info, p: rawptr, verb: rune) { fmt_bad_verb(fi, verb) } } - +// Formats a Structure of Arrays (SoA) pointer with a specific format. +// +// Inputs: +// - fi: Pointer to the Info struct containing format settings. +// - p: The SoA pointer to format. +// - verb: The format specifier character. +// fmt_soa_pointer :: proc(fi: ^Info, p: runtime.Raw_Soa_Pointer, verb: rune) { io.write_string(fi.writer, "#soa{data=0x", &fi.n) _fmt_int(fi, u64(uintptr(p.data)), 16, false, 8*size_of(rawptr), __DIGITS_UPPER) @@ -1056,8 +1334,13 @@ fmt_soa_pointer :: proc(fi: ^Info, p: runtime.Raw_Soa_Pointer, verb: rune) { _fmt_int(fi, u64(p.index), 10, false, 8*size_of(rawptr), __DIGITS_UPPER) io.write_string(fi.writer, "}", &fi.n) } - - +// String representation of an enum value. +// +// Inputs: +// - val: The enum value. +// +// Returns: The string representation of the enum value and a boolean indicating success. +// enum_value_to_string :: proc(val: any) -> (string, bool) { v := val v.id = runtime.typeid_base(v.id) @@ -1087,7 +1370,14 @@ enum_value_to_string :: proc(val: any) -> (string, bool) { return "", false } - +// Returns the enum value of a string representation. +// +// $T: The typeid of the enum type. +// Inputs: +// - s: The string representation of the enum value. +// +// Returns: The enum value and a boolean indicating success. +// string_to_enum_value :: proc($T: typeid, s: string) -> (T, bool) { ti := runtime.type_info_base(type_info_of(T)) if e, ok := ti.variant.(runtime.Type_Info_Enum); ok { @@ -1101,7 +1391,13 @@ string_to_enum_value :: proc($T: typeid, s: string) -> (T, bool) { } return T{}, false } - +// Formats an enum value with a specific format. +// +// Inputs: +// - fi: Pointer to the Info struct containing format settings. +// - v: The enum value to format. +// - verb: The format specifier character (e.g. 'i','d','f','s','v','q'). +// fmt_enum :: proc(fi: ^Info, v: any, verb: rune) { if v.id == nil || v.data == nil { io.write_string(fi.writer, "", &fi.n) @@ -1127,8 +1423,15 @@ fmt_enum :: proc(fi: ^Info, v: any, verb: rune) { } } } - - +// Converts a stored enum value to a string representation +// +// Inputs: +// - enum_type: A pointer to the runtime.Type_Info of the enumeration. +// - ev: The runtime.Type_Info_Enum_Value of the stored enum value. +// - offset: An optional integer to adjust the enumeration value (default is 0). +// +// Returns: A tuple containing the string representation of the enum value and a bool indicating success. +// stored_enum_value_to_string :: proc(enum_type: ^runtime.Type_Info, ev: runtime.Type_Info_Enum_Value, offset: int = 0) -> (string, bool) { et := runtime.type_info_base(enum_type) ev := ev @@ -1156,7 +1459,13 @@ stored_enum_value_to_string :: proc(enum_type: ^runtime.Type_Info, ev: runtime.T return "", false } - +// Formats a bit set and writes it to the provided Info structure +// +// Inputs: +// - fi: A pointer to the Info structure where the formatted bit set will be written. +// - v: The bit set value to be formatted. +// - name: An optional string for the name of the bit set (default is an empty string). +// fmt_bit_set :: proc(fi: ^Info, v: any, name: string = "") { is_bit_set_different_endian_to_platform :: proc(ti: ^runtime.Type_Info) -> bool { if ti == nil { @@ -1250,13 +1559,26 @@ fmt_bit_set :: proc(fi: ^Info, v: any, name: string = "") { } } } - +// Writes the specified number of indents to the provided Info structure +// +// Inputs: +// - fi: A pointer to the Info structure where the indents will be written. +// fmt_write_indent :: proc(fi: ^Info) { for in 0.. (do_continue: bool) { handle_optional_len :: proc(data: rawptr, info: reflect.Type_Info_Struct, field_name: string, optional_len: ^int) { @@ -1345,7 +1677,15 @@ handle_tag :: proc(data: rawptr, info: reflect.Type_Info_Struct, idx: int, verb: } return false } - +// Formats a struct for output, handling various struct types (e.g., SOA, raw unions) +// +// Inputs: +// - fi: A mutable pointer to an Info struct containing formatting state +// - v: The value to be formatted +// - the_verb: The formatting verb to be used (e.g. 'v') +// - info: Type information about the struct +// - type_name: The name of the type being formatted +// fmt_struct :: proc(fi: ^Info, v: any, the_verb: rune, info: runtime.Type_Info_Struct, type_name: string) { if the_verb != 'v' { fmt_bad_verb(fi, the_verb) @@ -1499,7 +1839,15 @@ fmt_struct :: proc(fi: ^Info, v: any, the_verb: rune, info: runtime.Type_Info_St } } } - +// Searches for the first NUL-terminated element in a given buffer +// +// Inputs: +// - ptr: The raw pointer to the buffer. +// - elem_size: The size of each element in the buffer. +// - max_n: The maximum number of elements to search (use -1 for no limit). +// +// Returns: The number of elements before the first NUL-terminated element. +// @(private) search_nul_termination :: proc(ptr: rawptr, elem_size: int, max_n: int) -> (n: int) { for p := uintptr(ptr); max_n < 0 || n < max_n; p += uintptr(elem_size) { @@ -1510,7 +1858,16 @@ search_nul_termination :: proc(ptr: rawptr, elem_size: int, max_n: int) -> (n: i } return n } - +// Formats a NUL-terminated array into a string representation +// +// Inputs: +// - fi: Pointer to the formatting Info struct. +// - data: The raw pointer to the array data. +// - max_n: The maximum number of elements to process. +// - elem_size: The size of each element in the array. +// - elem: Pointer to the type information of the array element. +// - verb: The formatting verb. +// fmt_array_nul_terminated :: proc(fi: ^Info, data: rawptr, max_n: int, elem_size: int, elem: ^reflect.Type_Info, verb: rune) { if data == nil { io.write_string(fi.writer, "", &fi.n) @@ -1519,7 +1876,16 @@ fmt_array_nul_terminated :: proc(fi: ^Info, data: rawptr, max_n: int, elem_size: n := search_nul_termination(data, elem_size, max_n) fmt_array(fi, data, n, elem_size, elem, verb) } - +// Formats an array into a string representation +// +// Inputs: +// - fi: Pointer to the formatting Info struct. +// - data: The raw pointer to the array data. +// - n: The number of elements in the array. +// - elem_size: The size of each element in the array. +// - elem: Pointer to the type information of the array element. +// - verb: The formatting verb (e.g. 's','q','p'). +// fmt_array :: proc(fi: ^Info, data: rawptr, n: int, elem_size: int, elem: ^reflect.Type_Info, verb: rune) { if data == nil && n > 0 { io.write_string(fi.writer, "nil") @@ -1574,7 +1940,16 @@ fmt_array :: proc(fi: ^Info, data: rawptr, n: int, elem_size: int, elem: ^reflec fmt_write_array(fi, data, n, elem_size, elem.id, verb) } } - +// Formats a named type into a string representation +// +// Inputs: +// - fi: Pointer to the formatting Info struct. +// - v: The value to format. +// - verb: The formatting verb. +// - info: The named type information. +// +// NOTE: This procedure supports built-in custom formatters for core library types such as runtime.Source_Code_Location, time.Duration, and time.Time. +// fmt_named :: proc(fi: ^Info, v: any, verb: rune, info: runtime.Type_Info_Named) { write_padded_number :: proc(fi: ^Info, i: i64, width: int) { n := width-1 @@ -1591,11 +1966,22 @@ fmt_named :: proc(fi: ^Info, v: any, verb: rune, info: runtime.Type_Info_Named) switch a in v { case runtime.Source_Code_Location: io.write_string(fi.writer, a.file_path, &fi.n) - io.write_byte(fi.writer, '(', &fi.n) - io.write_int(fi.writer, int(a.line), 10, &fi.n) - io.write_byte(fi.writer, ':', &fi.n) - io.write_int(fi.writer, int(a.column), 10, &fi.n) - io.write_byte(fi.writer, ')', &fi.n) + + when ODIN_ERROR_POS_STYLE == .Default { + io.write_byte(fi.writer, '(', &fi.n) + io.write_int(fi.writer, int(a.line), 10, &fi.n) + io.write_byte(fi.writer, ':', &fi.n) + io.write_int(fi.writer, int(a.column), 10, &fi.n) + io.write_byte(fi.writer, ')', &fi.n) + } else when ODIN_ERROR_POS_STYLE == .Unix { + io.write_byte(fi.writer, ':', &fi.n) + io.write_int(fi.writer, int(a.line), 10, &fi.n) + io.write_byte(fi.writer, ':', &fi.n) + io.write_int(fi.writer, int(a.column), 10, &fi.n) + io.write_byte(fi.writer, ':', &fi.n) + } else { + #panic("Unhandled ODIN_ERROR_POS_STYLE") + } return case time.Duration: @@ -1723,7 +2109,15 @@ fmt_named :: proc(fi: ^Info, v: any, verb: rune, info: runtime.Type_Info_Named) fmt_value(fi, any{v.data, info.base.id}, verb) } } - +// Formats a union type into a string representation +// +// Inputs: +// - fi: Pointer to the formatting Info struct. +// - v: The value to format. +// - verb: The formatting verb. +// - info: The union type information. +// - type_size: The size of the union type. +// fmt_union :: proc(fi: ^Info, v: any, verb: rune, info: runtime.Type_Info_Union, type_size: int) { if type_size == 0 { io.write_string(fi.writer, "nil", &fi.n) @@ -1769,7 +2163,14 @@ fmt_union :: proc(fi: ^Info, v: any, verb: rune, info: runtime.Type_Info_Union, fmt_arg(fi, any{v.data, id}, verb) } } - +// Formats a matrix as a string +// +// Inputs: +// - fi: A pointer to an Info struct containing formatting information. +// - v: The matrix value to be formatted. +// - verb: The formatting verb rune. +// - info: A runtime.Type_Info_Matrix struct containing matrix type information. +// fmt_matrix :: proc(fi: ^Info, v: any, verb: rune, info: runtime.Type_Info_Matrix) { io.write_string(fi.writer, "matrix[", &fi.n) defer io.write_byte(fi.writer, ']', &fi.n) @@ -1812,7 +2213,15 @@ fmt_matrix :: proc(fi: ^Info, v: any, verb: rune, info: runtime.Type_Info_Matrix fmt_write_indent(fi) } } - +// Formats a value based on its type and formatting verb +// +// Inputs: +// - fi: A pointer to an Info struct containing formatting information. +// - v: The value to be formatted. +// - verb: The formatting verb rune. +// +// NOTE: Uses user formatters if available and not ignored. +// fmt_value :: proc(fi: ^Info, v: any, verb: rune) { if v.data == nil || v.id == nil { io.write_string(fi.writer, "", &fi.n) @@ -1834,8 +2243,8 @@ fmt_value :: proc(fi: ^Info, v: any, verb: rune) { type_info := type_info_of(v.id) switch info in type_info.variant { - case runtime.Type_Info_Any: // Ignore - case runtime.Type_Info_Tuple: // Ignore + case runtime.Type_Info_Any: // Ignore + case runtime.Type_Info_Parameters: // Ignore case runtime.Type_Info_Named: fmt_named(fi, v, verb, info) @@ -2157,7 +2566,14 @@ fmt_value :: proc(fi: ^Info, v: any, verb: rune) { fmt_matrix(fi, v, verb, info) } } - +// Formats a complex number based on the given formatting verb +// +// Inputs: +// - fi: A pointer to an Info struct containing formatting information. +// - c: The complex128 value to be formatted. +// - bits: The number of bits in the complex number (32 or 64). +// - verb: The formatting verb rune ('f', 'F', 'v', 'h', 'H'). +// fmt_complex :: proc(fi: ^Info, c: complex128, bits: int, verb: rune) { switch verb { case 'f', 'F', 'v', 'h', 'H': @@ -2174,7 +2590,14 @@ fmt_complex :: proc(fi: ^Info, c: complex128, bits: int, verb: rune) { return } } - +// Formats a quaternion number based on the given formatting verb +// +// Inputs: +// - fi: A pointer to an Info struct containing formatting information. +// - q: The quaternion256 value to be formatted. +// - bits: The number of bits in the quaternion number (64, 128, or 256). +// - verb: The formatting verb rune ('f', 'F', 'v', 'h', 'H'). +// fmt_quaternion :: proc(fi: ^Info, q: quaternion256, bits: int, verb: rune) { switch verb { case 'f', 'F', 'v', 'h', 'H': @@ -2205,7 +2628,15 @@ fmt_quaternion :: proc(fi: ^Info, q: quaternion256, bits: int, verb: rune) { return } } - +// Formats an argument based on its type and the given formatting verb +// +// Inputs: +// - fi: A pointer to an Info struct containing formatting information. +// - arg: The value to be formatted. +// - verb: The formatting verb rune (e.g. 'T'). +// +// NOTE: Uses user formatters if available and not ignored. +// fmt_arg :: proc(fi: ^Info, arg: any, verb: rune) { if arg == nil { io.write_string(fi.writer, "") @@ -2232,18 +2663,10 @@ fmt_arg :: proc(fi: ^Info, arg: any, verb: rune) { } } - - custom_types: switch a in arg { - case runtime.Source_Code_Location: - if fi.hash && verb == 'v' { - io.write_string(fi.writer, a.file_path, &fi.n) - io.write_byte(fi.writer, '(', &fi.n) - io.write_i64(fi.writer, i64(a.line), 10, &fi.n) - io.write_byte(fi.writer, ':', &fi.n) - io.write_i64(fi.writer, i64(a.column), 10, &fi.n) - io.write_byte(fi.writer, ')', &fi.n) - return - } + arg_info := type_info_of(arg.id) + if info, ok := arg_info.variant.(runtime.Type_Info_Named); ok { + fmt_named(fi, arg, verb, info) + return } base_arg := arg @@ -2322,7 +2745,3 @@ fmt_arg :: proc(fi: ^Info, arg: any, verb: rune) { } } - - - - diff --git a/core/fmt/fmt_js.odin b/core/fmt/fmt_js.odin index 7f6008889..5e06041f5 100644 --- a/core/fmt/fmt_js.odin +++ b/core/fmt/fmt_js.odin @@ -7,7 +7,7 @@ foreign import "odin_env" @(private="file") foreign odin_env { - write :: proc "c" (fd: u32, p: []byte) --- + write :: proc "contextless" (fd: u32, p: []byte) --- } @(private="file") diff --git a/core/fmt/fmt_os.odin b/core/fmt/fmt_os.odin index 52280a3f7..840fd1545 100644 --- a/core/fmt/fmt_os.odin +++ b/core/fmt/fmt_os.odin @@ -4,42 +4,72 @@ package fmt import "core:runtime" import "core:os" import "core:io" +import "core:bufio" // fprint formats using the default print settings and writes to fd fprint :: proc(fd: os.Handle, args: ..any, sep := " ") -> int { - w := io.to_writer(os.stream_from_handle(fd)) - return wprint(w=w, args=args, sep=sep) + buf: [1024]byte + b: bufio.Writer + defer bufio.writer_flush(&b) + + bufio.writer_init_with_buf(&b, os.stream_from_handle(fd), buf[:]) + w := bufio.writer_to_writer(&b) + return wprint(w, ..args, sep=sep) } // fprintln formats using the default print settings and writes to fd fprintln :: proc(fd: os.Handle, args: ..any, sep := " ") -> int { - w := io.to_writer(os.stream_from_handle(fd)) - return wprintln(w=w, args=args, sep=sep) + buf: [1024]byte + b: bufio.Writer + defer bufio.writer_flush(&b) + + bufio.writer_init_with_buf(&b, os.stream_from_handle(fd), buf[:]) + + w := bufio.writer_to_writer(&b) + return wprintln(w, ..args, sep=sep) } // fprintf formats according to the specified format string and writes to fd fprintf :: proc(fd: os.Handle, fmt: string, args: ..any) -> int { - w := io.to_writer(os.stream_from_handle(fd)) + buf: [1024]byte + b: bufio.Writer + defer bufio.writer_flush(&b) + + bufio.writer_init_with_buf(&b, os.stream_from_handle(fd), buf[:]) + + w := bufio.writer_to_writer(&b) return wprintf(w, fmt, ..args) } fprint_type :: proc(fd: os.Handle, info: ^runtime.Type_Info) -> (n: int, err: io.Error) { - w := io.to_writer(os.stream_from_handle(fd)) + buf: [1024]byte + b: bufio.Writer + defer bufio.writer_flush(&b) + + bufio.writer_init_with_buf(&b, os.stream_from_handle(fd), buf[:]) + + w := bufio.writer_to_writer(&b) return wprint_type(w, info) } fprint_typeid :: proc(fd: os.Handle, id: typeid) -> (n: int, err: io.Error) { - w := io.to_writer(os.stream_from_handle(fd)) + buf: [1024]byte + b: bufio.Writer + defer bufio.writer_flush(&b) + + bufio.writer_init_with_buf(&b, os.stream_from_handle(fd), buf[:]) + + w := bufio.writer_to_writer(&b) return wprint_typeid(w, id) } // print formats using the default print settings and writes to os.stdout -print :: proc(args: ..any, sep := " ") -> int { return fprint(fd=os.stdout, args=args, sep=sep) } +print :: proc(args: ..any, sep := " ") -> int { return fprint(os.stdout, ..args, sep=sep) } // println formats using the default print settings and writes to os.stdout -println :: proc(args: ..any, sep := " ") -> int { return fprintln(fd=os.stdout, args=args, sep=sep) } +println :: proc(args: ..any, sep := " ") -> int { return fprintln(os.stdout, ..args, sep=sep) } // printf formats according to the specified format string and writes to os.stdout printf :: proc(fmt: string, args: ..any) -> int { return fprintf(os.stdout, fmt, ..args) } // eprint formats using the default print settings and writes to os.stderr -eprint :: proc(args: ..any, sep := " ") -> int { return fprint(fd=os.stderr, args=args, sep=sep) } +eprint :: proc(args: ..any, sep := " ") -> int { return fprint(os.stderr, ..args, sep=sep) } // eprintln formats using the default print settings and writes to os.stderr -eprintln :: proc(args: ..any, sep := " ") -> int { return fprintln(fd=os.stderr, args=args, sep=sep) } +eprintln :: proc(args: ..any, sep := " ") -> int { return fprintln(os.stderr, ..args, sep=sep) } // eprintf formats according to the specified format string and writes to os.stderr eprintf :: proc(fmt: string, args: ..any) -> int { return fprintf(os.stderr, fmt, ..args) } diff --git a/core/hash/xxhash/xxhash_3.odin b/core/hash/xxhash/xxhash_3.odin index 5bd5537b1..fa50075f9 100644 --- a/core/hash/xxhash/xxhash_3.odin +++ b/core/hash/xxhash/xxhash_3.odin @@ -118,7 +118,7 @@ XXH_mul_64_to_128_fold_64 :: #force_inline proc(lhs, rhs: xxh_u64) -> (res: xxh_ } @(optimization_mode="speed") -XXH_xorshift_64 :: #force_inline proc(v: xxh_u64, auto_cast shift: uint) -> (res: xxh_u64) { +XXH_xorshift_64 :: #force_inline proc(v: xxh_u64, #any_int shift: uint) -> (res: xxh_u64) { return v ~ (v >> shift) } diff --git a/core/image/common.odin b/core/image/common.odin index 58ff83dd1..ad01f7e6b 100644 --- a/core/image/common.odin +++ b/core/image/common.odin @@ -634,7 +634,7 @@ alpha_add_if_missing :: proc(img: ^Image, alpha_key := Alpha_Key{}, allocator := buf := bytes.Buffer{} // Can we allocate the return buffer? - if !resize(&buf.buf, bytes_wanted) { + if resize(&buf.buf, bytes_wanted) != nil { delete(buf.buf) return false } @@ -826,7 +826,7 @@ alpha_drop_if_present :: proc(img: ^Image, options := Options{}, alpha_key := Al buf := bytes.Buffer{} // Can we allocate the return buffer? - if !resize(&buf.buf, bytes_wanted) { + if resize(&buf.buf, bytes_wanted) != nil { delete(buf.buf) return false } @@ -1075,7 +1075,7 @@ apply_palette_rgb :: proc(img: ^Image, palette: [256]RGB_Pixel, allocator := con // Can we allocate the return buffer? buf := bytes.Buffer{} bytes_wanted := compute_buffer_size(img.width, img.height, 3, 8) - if !resize(&buf.buf, bytes_wanted) { + if resize(&buf.buf, bytes_wanted) != nil { delete(buf.buf) return false } @@ -1112,7 +1112,7 @@ apply_palette_rgba :: proc(img: ^Image, palette: [256]RGBA_Pixel, allocator := c // Can we allocate the return buffer? buf := bytes.Buffer{} bytes_wanted := compute_buffer_size(img.width, img.height, 4, 8) - if !resize(&buf.buf, bytes_wanted) { + if resize(&buf.buf, bytes_wanted) != nil { delete(buf.buf) return false } @@ -1147,7 +1147,7 @@ expand_grayscale :: proc(img: ^Image, allocator := context.allocator) -> (ok: bo // Can we allocate the return buffer? buf := bytes.Buffer{} bytes_wanted := compute_buffer_size(img.width, img.height, img.channels + 2, img.depth) - if !resize(&buf.buf, bytes_wanted) { + if resize(&buf.buf, bytes_wanted) != nil { delete(buf.buf) return false } diff --git a/core/image/which.odin b/core/image/general.odin similarity index 75% rename from core/image/which.odin rename to core/image/general.odin index ab608174f..17a8f35ea 100644 --- a/core/image/which.odin +++ b/core/image/general.odin @@ -1,6 +1,48 @@ package image -import "core:os" +import "core:mem" +import "core:bytes" + +Loader_Proc :: #type proc(data: []byte, options: Options, allocator: mem.Allocator) -> (img: ^Image, err: Error) +Destroy_Proc :: #type proc(img: ^Image) + +@(private) +_internal_loaders: [Which_File_Type]Loader_Proc +_internal_destroyers: [Which_File_Type]Destroy_Proc + +register :: proc(kind: Which_File_Type, loader: Loader_Proc, destroyer: Destroy_Proc) { + assert(loader != nil) + assert(destroyer != nil) + assert(_internal_loaders[kind] == nil) + _internal_loaders[kind] = loader + + assert(_internal_destroyers[kind] == nil) + _internal_destroyers[kind] = destroyer +} + +load_from_bytes :: proc(data: []byte, options := Options{}, allocator := context.allocator) -> (img: ^Image, err: Error) { + loader := _internal_loaders[which(data)] + if loader == nil { + return nil, .Unsupported_Format + } + return loader(data, options, allocator) +} + + +destroy :: proc(img: ^Image, allocator := context.allocator) { + if img == nil { + return + } + context.allocator = allocator + destroyer := _internal_destroyers[img.which] + if destroyer != nil { + destroyer(img) + } else { + assert(img.metadata == nil) + bytes.buffer_destroy(&img.pixels) + free(img) + } +} Which_File_Type :: enum { Unknown, @@ -28,11 +70,6 @@ Which_File_Type :: enum { XBM, // X BitMap } -which :: proc{ - which_bytes, - which_file, -} - which_bytes :: proc(data: []byte) -> Which_File_Type { test_tga :: proc(s: string) -> bool { get8 :: #force_inline proc(s: ^string) -> u8 { @@ -164,16 +201,3 @@ which_bytes :: proc(data: []byte) -> Which_File_Type { } return .Unknown } - - -which_file :: proc(path: string) -> Which_File_Type { - f, err := os.open(path) - if err != 0 { - return .Unknown - } - header: [128]byte - os.read(f, header[:]) - file_type := which_bytes(header[:]) - os.close(f) - return file_type -} \ No newline at end of file diff --git a/core/image/general_js.odin b/core/image/general_js.odin new file mode 100644 index 000000000..841d9c200 --- /dev/null +++ b/core/image/general_js.odin @@ -0,0 +1,10 @@ +//+build js +package image + +load :: proc{ + load_from_bytes, +} + +which :: proc{ + which_bytes, +} diff --git a/core/image/general_loader.odin b/core/image/general_loader.odin deleted file mode 100644 index 36629c39e..000000000 --- a/core/image/general_loader.odin +++ /dev/null @@ -1,61 +0,0 @@ -package image - -import "core:mem" -import "core:os" -import "core:bytes" - -Loader_Proc :: #type proc(data: []byte, options: Options, allocator: mem.Allocator) -> (img: ^Image, err: Error) -Destroy_Proc :: #type proc(img: ^Image) - -@(private) -_internal_loaders: [Which_File_Type]Loader_Proc -_internal_destroyers: [Which_File_Type]Destroy_Proc - -register :: proc(kind: Which_File_Type, loader: Loader_Proc, destroyer: Destroy_Proc) { - assert(loader != nil) - assert(destroyer != nil) - assert(_internal_loaders[kind] == nil) - _internal_loaders[kind] = loader - - assert(_internal_destroyers[kind] == nil) - _internal_destroyers[kind] = destroyer -} - -load :: proc{ - load_from_bytes, - load_from_file, -} - -load_from_bytes :: proc(data: []byte, options := Options{}, allocator := context.allocator) -> (img: ^Image, err: Error) { - loader := _internal_loaders[which(data)] - if loader == nil { - return nil, .Unsupported_Format - } - return loader(data, options, allocator) -} - - -load_from_file :: proc(filename: string, options := Options{}, allocator := context.allocator) -> (img: ^Image, err: Error) { - data, ok := os.read_entire_file(filename, allocator) - defer delete(data, allocator) - if ok { - return load_from_bytes(data, options, allocator) - } else { - return nil, .Unable_To_Read_File - } -} - -destroy :: proc(img: ^Image, allocator := context.allocator) { - if img == nil { - return - } - context.allocator = allocator - destroyer := _internal_destroyers[img.which] - if destroyer != nil { - destroyer(img) - } else { - assert(img.metadata == nil) - bytes.buffer_destroy(&img.pixels) - free(img) - } -} \ No newline at end of file diff --git a/core/image/general_os.odin b/core/image/general_os.odin new file mode 100644 index 000000000..144a3470f --- /dev/null +++ b/core/image/general_os.odin @@ -0,0 +1,38 @@ +//+build !js +package image + +import "core:os" + +load :: proc{ + load_from_bytes, + load_from_file, +} + + +load_from_file :: proc(filename: string, options := Options{}, allocator := context.allocator) -> (img: ^Image, err: Error) { + data, ok := os.read_entire_file(filename, allocator) + defer delete(data, allocator) + if ok { + return load_from_bytes(data, options, allocator) + } else { + return nil, .Unable_To_Read_File + } +} + + +which :: proc{ + which_bytes, + which_file, +} + +which_file :: proc(path: string) -> Which_File_Type { + f, err := os.open(path) + if err != 0 { + return .Unknown + } + header: [128]byte + os.read(f, header[:]) + file_type := which_bytes(header[:]) + os.close(f) + return file_type +} \ No newline at end of file diff --git a/core/image/netpbm/netpbm.odin b/core/image/netpbm/netpbm.odin index 18545092d..cb07b1e3a 100644 --- a/core/image/netpbm/netpbm.odin +++ b/core/image/netpbm/netpbm.odin @@ -4,10 +4,10 @@ import "core:bytes" import "core:fmt" import "core:image" import "core:mem" -import "core:os" import "core:strconv" import "core:strings" import "core:unicode" +import "core:runtime" Image :: image.Image Format :: image.Netpbm_Format @@ -26,23 +26,6 @@ PFM :: Formats{.Pf, .PF} ASCII :: Formats{.P1, .P2, .P3} BINARY :: Formats{.P4, .P5, .P6} + PAM + PFM -load :: proc { - load_from_file, - load_from_bytes, -} - -load_from_file :: proc(filename: string, allocator := context.allocator) -> (img: ^Image, err: Error) { - context.allocator = allocator - - data, ok := os.read_entire_file(filename); defer delete(data) - if !ok { - err = .Unable_To_Read_File - return - } - - return load_from_bytes(data) -} - load_from_bytes :: proc(data: []byte, allocator := context.allocator) -> (img: ^Image, err: Error) { context.allocator = allocator @@ -66,24 +49,6 @@ load_from_bytes :: proc(data: []byte, allocator := context.allocator) -> (img: ^ return img, nil } -save :: proc { - save_to_file, - save_to_buffer, -} - -save_to_file :: proc(filename: string, img: ^Image, custom_info: Info = {}, allocator := context.allocator) -> (err: Error) { - context.allocator = allocator - - data: []byte; defer delete(data) - data = save_to_buffer(img, custom_info) or_return - - if ok := os.write_entire_file(filename, data); !ok { - return .Unable_To_Write_File - } - - return Format_Error.None -} - save_to_buffer :: proc(img: ^Image, custom_info: Info = {}, allocator := context.allocator) -> (buffer: []byte, err: Error) { context.allocator = allocator @@ -407,6 +372,8 @@ _parse_header_pam :: proc(data: []byte, allocator := context.allocator) -> (head } length = header_end_index + len(HEADER_END) + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD(ignore = context.temp_allocator == allocator) + // string buffer for the tupltype tupltype: strings.Builder strings.builder_init(&tupltype, context.temp_allocator); defer strings.builder_destroy(&tupltype) diff --git a/core/image/netpbm/netpbm_js.odin b/core/image/netpbm/netpbm_js.odin new file mode 100644 index 000000000..7db17a05d --- /dev/null +++ b/core/image/netpbm/netpbm_js.odin @@ -0,0 +1,10 @@ +//+build js +package netpbm + +load :: proc { + load_from_bytes, +} + +save :: proc { + save_to_buffer, +} diff --git a/core/image/netpbm/netpbm_os.odin b/core/image/netpbm/netpbm_os.odin new file mode 100644 index 000000000..609f1ea1f --- /dev/null +++ b/core/image/netpbm/netpbm_os.odin @@ -0,0 +1,41 @@ +//+build !js +package netpbm + +import "core:os" + +load :: proc { + load_from_file, + load_from_bytes, +} + + +load_from_file :: proc(filename: string, allocator := context.allocator) -> (img: ^Image, err: Error) { + context.allocator = allocator + + data, ok := os.read_entire_file(filename); defer delete(data) + if !ok { + err = .Unable_To_Read_File + return + } + + return load_from_bytes(data) +} + + +save :: proc { + save_to_file, + save_to_buffer, +} + +save_to_file :: proc(filename: string, img: ^Image, custom_info: Info = {}, allocator := context.allocator) -> (err: Error) { + context.allocator = allocator + + data: []byte; defer delete(data) + data = save_to_buffer(img, custom_info) or_return + + if ok := os.write_entire_file(filename, data); !ok { + return .Unable_To_Write_File + } + + return Format_Error.None +} \ No newline at end of file diff --git a/core/image/png/helpers.odin b/core/image/png/helpers.odin index 0ebf0b20b..025c2b866 100644 --- a/core/image/png/helpers.odin +++ b/core/image/png/helpers.odin @@ -16,6 +16,7 @@ import coretime "core:time" import "core:strings" import "core:bytes" import "core:mem" +import "core:runtime" /* Cleanup of image-specific data. @@ -91,12 +92,14 @@ core_time :: proc(c: image.PNG_Chunk) -> (t: coretime.Time, ok: bool) { } text :: proc(c: image.PNG_Chunk) -> (res: Text, ok: bool) { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD(ignore = context.temp_allocator == context.allocator) + assert(len(c.data) == int(c.header.length)) #partial switch c.header.type { case .tEXt: ok = true - fields := bytes.split(s=c.data, sep=[]u8{0}, allocator=context.temp_allocator) + fields := bytes.split(c.data, sep=[]u8{0}, allocator=context.temp_allocator) if len(fields) == 2 { res.keyword = strings.clone(string(fields[0])) res.text = strings.clone(string(fields[1])) @@ -107,7 +110,7 @@ text :: proc(c: image.PNG_Chunk) -> (res: Text, ok: bool) { case .zTXt: ok = true - fields := bytes.split_n(s=c.data, sep=[]u8{0}, n=3, allocator=context.temp_allocator) + fields := bytes.split_n(c.data, sep=[]u8{0}, n=3, allocator=context.temp_allocator) if len(fields) != 3 || len(fields[1]) != 0 { // Compression method must be 0=Deflate, which thanks to the split above turns // into an empty slice @@ -194,18 +197,18 @@ text_destroy :: proc(text: Text) { } iccp :: proc(c: image.PNG_Chunk) -> (res: iCCP, ok: bool) { - ok = true + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD(ignore = context.temp_allocator == context.allocator) - fields := bytes.split_n(s=c.data, sep=[]u8{0}, n=3, allocator=context.temp_allocator) + fields := bytes.split_n(c.data, sep=[]u8{0}, n=3, allocator=context.temp_allocator) if len(fields[0]) < 1 || len(fields[0]) > 79 { // Invalid profile name - ok = false; return + return } if len(fields[1]) != 0 { // Compression method should be a zero, which the split turned into an empty slice. - ok = false; return + return } // Set up ZLIB context and decompress iCCP payload @@ -213,12 +216,12 @@ iccp :: proc(c: image.PNG_Chunk) -> (res: iCCP, ok: bool) { zlib_error := zlib.inflate_from_byte_array(fields[2], &buf) if zlib_error != nil { bytes.buffer_destroy(&buf) - ok = false; return + return } res.name = strings.clone(string(fields[0])) res.profile = bytes.buffer_to_bytes(&buf) - + ok = true return } @@ -256,18 +259,18 @@ plte :: proc(c: image.PNG_Chunk) -> (res: PLTE, ok: bool) { splt :: proc(c: image.PNG_Chunk) -> (res: sPLT, ok: bool) { if c.header.type != .sPLT { - return {}, false + return } - ok = true + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD(ignore = context.temp_allocator == context.allocator) - fields := bytes.split_n(s=c.data, sep=[]u8{0}, n=2, allocator=context.temp_allocator) + fields := bytes.split_n(c.data, sep=[]u8{0}, n=2, allocator=context.temp_allocator) if len(fields) != 2 { - return {}, false + return } res.depth = fields[1][0] if res.depth != 8 && res.depth != 16 { - return {}, false + return } data := fields[1][1:] @@ -275,21 +278,21 @@ splt :: proc(c: image.PNG_Chunk) -> (res: sPLT, ok: bool) { if res.depth == 8 { if len(data) % 6 != 0 { - return {}, false + return } count = len(data) / 6 if count > 256 { - return {}, false + return } res.entries = mem.slice_data_cast([][4]u8, data) } else { // res.depth == 16 if len(data) % 10 != 0 { - return {}, false + return } count = len(data) / 10 if count > 256 { - return {}, false + return } res.entries = mem.slice_data_cast([][4]u16, data) @@ -297,7 +300,7 @@ splt :: proc(c: image.PNG_Chunk) -> (res: sPLT, ok: bool) { res.name = strings.clone(string(fields[0])) res.used = u16(count) - + ok = true return } diff --git a/core/image/png/png.odin b/core/image/png/png.odin index 3faa39c83..caa1e6e8a 100644 --- a/core/image/png/png.odin +++ b/core/image/png/png.odin @@ -17,12 +17,12 @@ import "core:compress" import "core:compress/zlib" import "core:image" -import "core:os" import "core:hash" import "core:bytes" import "core:io" import "core:mem" import "core:intrinsics" +import "core:runtime" // Limit chunk sizes. // By default: IDAT = 8k x 8k x 16-bits + 8k filter bytes. @@ -335,19 +335,6 @@ load_from_bytes :: proc(data: []byte, options := Options{}, allocator := context return img, err } -load_from_file :: proc(filename: string, options := Options{}, allocator := context.allocator) -> (img: ^Image, err: Error) { - context.allocator = allocator - - data, ok := os.read_entire_file(filename) - defer delete(data) - - if ok { - return load_from_bytes(data, options) - } else { - return nil, .Unable_To_Read_File - } -} - load_from_context :: proc(ctx: ^$C, options := Options{}, allocator := context.allocator) -> (img: ^Image, err: Error) { context.allocator = allocator options := options @@ -744,7 +731,7 @@ load_from_context :: proc(ctx: ^$C, options := Options{}, allocator := context.a // We need to create a new image buffer dest_raw_size := compute_buffer_size(int(header.width), int(header.height), out_image_channels, 8) t := bytes.Buffer{} - if !resize(&t.buf, dest_raw_size) { + if resize(&t.buf, dest_raw_size) != nil { return {}, .Unable_To_Allocate_Or_Resize } @@ -825,7 +812,7 @@ load_from_context :: proc(ctx: ^$C, options := Options{}, allocator := context.a // We need to create a new image buffer dest_raw_size := compute_buffer_size(int(header.width), int(header.height), out_image_channels, 16) t := bytes.Buffer{} - if !resize(&t.buf, dest_raw_size) { + if resize(&t.buf, dest_raw_size) != nil { return {}, .Unable_To_Allocate_Or_Resize } @@ -1024,7 +1011,7 @@ load_from_context :: proc(ctx: ^$C, options := Options{}, allocator := context.a // We need to create a new image buffer dest_raw_size := compute_buffer_size(int(header.width), int(header.height), out_image_channels, 8) t := bytes.Buffer{} - if !resize(&t.buf, dest_raw_size) { + if resize(&t.buf, dest_raw_size) != nil { return {}, .Unable_To_Allocate_Or_Resize } @@ -1247,6 +1234,8 @@ defilter_8 :: proc(params: ^Filter_Params) -> (ok: bool) { // TODO: See about doing a Duff's #unroll where practicable + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() + // Apron so we don't need to special case first rows. up := make([]u8, row_stride, context.temp_allocator) ok = true @@ -1299,10 +1288,9 @@ defilter_8 :: proc(params: ^Filter_Params) -> (ok: bool) { } // @(optimization_mode="speed") -defilter_less_than_8 :: proc(params: ^Filter_Params) -> (ok: bool) #no_bounds_check { +defilter_less_than_8 :: proc(params: ^Filter_Params) -> bool #no_bounds_check { using params - ok = true row_stride_in := ((channels * width * depth) + 7) >> 3 row_stride_out := channels * width @@ -1314,6 +1302,8 @@ defilter_less_than_8 :: proc(params: ^Filter_Params) -> (ok: bool) #no_bounds_ch // TODO: See about doing a Duff's #unroll where practicable + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() + // Apron so we don't need to special case first rows. up := make([]u8, row_stride_out, context.temp_allocator) @@ -1457,18 +1447,18 @@ defilter_less_than_8 :: proc(params: ^Filter_Params) -> (ok: bool) #no_bounds_ch } } - return + return true } // @(optimization_mode="speed") -defilter_16 :: proc(params: ^Filter_Params) -> (ok: bool) { - +defilter_16 :: proc(params: ^Filter_Params) -> bool { using params - ok = true stride := channels * 2 row_stride := width * stride + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() + // TODO: See about doing a Duff's #unroll where practicable // Apron so we don't need to special case first rows. up := make([]u8, row_stride, context.temp_allocator) @@ -1518,7 +1508,7 @@ defilter_16 :: proc(params: ^Filter_Params) -> (ok: bool) { dest = dest[row_stride:] } - return + return true } defilter :: proc(img: ^Image, filter_bytes: ^bytes.Buffer, header: ^image.PNG_IHDR, options: Options) -> (err: Error) { @@ -1532,7 +1522,7 @@ defilter :: proc(img: ^Image, filter_bytes: ^bytes.Buffer, header: ^image.PNG_IH bytes_per_channel := depth == 16 ? 2 : 1 num_bytes := compute_buffer_size(width, height, channels, depth == 16 ? 16 : 8) - if !resize(&img.pixels.buf, num_bytes) { + if resize(&img.pixels.buf, num_bytes) != nil { return .Unable_To_Allocate_Or_Resize } @@ -1574,7 +1564,7 @@ defilter :: proc(img: ^Image, filter_bytes: ^bytes.Buffer, header: ^image.PNG_IH if x > 0 && y > 0 { temp: bytes.Buffer temp_len := compute_buffer_size(x, y, channels, depth == 16 ? 16 : 8) - if !resize(&temp.buf, temp_len) { + if resize(&temp.buf, temp_len) != nil { return .Unable_To_Allocate_Or_Resize } @@ -1637,8 +1627,6 @@ defilter :: proc(img: ^Image, filter_bytes: ^bytes.Buffer, header: ^image.PNG_IH return nil } -load :: proc{load_from_file, load_from_bytes, load_from_context} - @(init, private) _register :: proc() { diff --git a/core/image/png/png_js.odin b/core/image/png/png_js.odin new file mode 100644 index 000000000..57c27fc64 --- /dev/null +++ b/core/image/png/png_js.odin @@ -0,0 +1,4 @@ +//+build js +package png + +load :: proc{load_from_bytes, load_from_context} diff --git a/core/image/png/png_os.odin b/core/image/png/png_os.odin new file mode 100644 index 000000000..cc65e7b42 --- /dev/null +++ b/core/image/png/png_os.odin @@ -0,0 +1,19 @@ +//+build !js +package png + +import "core:os" + +load :: proc{load_from_file, load_from_bytes, load_from_context} + +load_from_file :: proc(filename: string, options := Options{}, allocator := context.allocator) -> (img: ^Image, err: Error) { + context.allocator = allocator + + data, ok := os.read_entire_file(filename) + defer delete(data) + + if ok { + return load_from_bytes(data, options) + } else { + return nil, .Unable_To_Read_File + } +} diff --git a/core/image/qoi/qoi.odin b/core/image/qoi/qoi.odin index 29a17d4f4..c764178dc 100644 --- a/core/image/qoi/qoi.odin +++ b/core/image/qoi/qoi.odin @@ -15,7 +15,6 @@ package qoi import "core:image" import "core:compress" import "core:bytes" -import "core:os" Error :: image.Error Image :: image.Image @@ -24,7 +23,7 @@ Options :: image.Options RGB_Pixel :: image.RGB_Pixel RGBA_Pixel :: image.RGBA_Pixel -save_to_memory :: proc(output: ^bytes.Buffer, img: ^Image, options := Options{}, allocator := context.allocator) -> (err: Error) { +save_to_buffer :: proc(output: ^bytes.Buffer, img: ^Image, options := Options{}, allocator := context.allocator) -> (err: Error) { context.allocator = allocator if img == nil { @@ -54,7 +53,7 @@ save_to_memory :: proc(output: ^bytes.Buffer, img: ^Image, options := Options{} // Calculate and allocate maximum size. We'll reclaim space to actually written output at the end. max_size := pixels * (img.channels + 1) + size_of(image.QOI_Header) + size_of(u64be) - if !resize(&output.buf, max_size) { + if resize(&output.buf, max_size) != nil { return .Unable_To_Allocate_Or_Resize } @@ -166,20 +165,6 @@ save_to_memory :: proc(output: ^bytes.Buffer, img: ^Image, options := Options{} return nil } -save_to_file :: proc(output: string, img: ^Image, options := Options{}, allocator := context.allocator) -> (err: Error) { - context.allocator = allocator - - out := &bytes.Buffer{} - defer bytes.buffer_destroy(out) - - save_to_memory(out, img, options) or_return - write_ok := os.write_entire_file(output, out.buf[:]) - - return nil if write_ok else .Unable_To_Write_File -} - -save :: proc{save_to_memory, save_to_file} - load_from_bytes :: proc(data: []byte, options := Options{}, allocator := context.allocator) -> (img: ^Image, err: Error) { ctx := &compress.Context_Memory_Input{ input_data = data, @@ -189,19 +174,6 @@ load_from_bytes :: proc(data: []byte, options := Options{}, allocator := context return img, err } -load_from_file :: proc(filename: string, options := Options{}, allocator := context.allocator) -> (img: ^Image, err: Error) { - context.allocator = allocator - - data, ok := os.read_entire_file(filename) - defer delete(data) - - if ok { - return load_from_bytes(data, options) - } else { - return nil, .Unable_To_Read_File - } -} - @(optimization_mode="speed") load_from_context :: proc(ctx: ^$C, options := Options{}, allocator := context.allocator) -> (img: ^Image, err: Error) { context.allocator = allocator @@ -261,7 +233,7 @@ load_from_context :: proc(ctx: ^$C, options := Options{}, allocator := context.a bytes_needed := image.compute_buffer_size(int(header.width), int(header.height), img.channels, 8) - if !resize(&img.pixels.buf, bytes_needed) { + if resize(&img.pixels.buf, bytes_needed) != nil { return img, .Unable_To_Allocate_Or_Resize } @@ -359,8 +331,6 @@ load_from_context :: proc(ctx: ^$C, options := Options{}, allocator := context.a return } -load :: proc{load_from_file, load_from_bytes, load_from_context} - /* Cleanup of image-specific data. */ diff --git a/core/image/qoi/qoi_js.odin b/core/image/qoi/qoi_js.odin new file mode 100644 index 000000000..2c23cc17a --- /dev/null +++ b/core/image/qoi/qoi_js.odin @@ -0,0 +1,6 @@ +//+build js +package qoi + +save :: proc{save_to_buffer} + +load :: proc{load_from_bytes, load_from_context} diff --git a/core/image/qoi/qoi_os.odin b/core/image/qoi/qoi_os.odin new file mode 100644 index 000000000..efcec6c52 --- /dev/null +++ b/core/image/qoi/qoi_os.odin @@ -0,0 +1,37 @@ +//+build !js +package qoi + +import "core:os" +import "core:bytes" + +save :: proc{save_to_buffer, save_to_file} + + +save_to_file :: proc(output: string, img: ^Image, options := Options{}, allocator := context.allocator) -> (err: Error) { + context.allocator = allocator + + out := &bytes.Buffer{} + defer bytes.buffer_destroy(out) + + save_to_buffer(out, img, options) or_return + write_ok := os.write_entire_file(output, out.buf[:]) + + return nil if write_ok else .Unable_To_Write_File +} + + +load :: proc{load_from_file, load_from_bytes, load_from_context} + + +load_from_file :: proc(filename: string, options := Options{}, allocator := context.allocator) -> (img: ^Image, err: Error) { + context.allocator = allocator + + data, ok := os.read_entire_file(filename) + defer delete(data) + + if ok { + return load_from_bytes(data, options) + } else { + return nil, .Unable_To_Read_File + } +} \ No newline at end of file diff --git a/core/image/tga/tga.odin b/core/image/tga/tga.odin index 39c46c7c7..03ef1a386 100644 --- a/core/image/tga/tga.odin +++ b/core/image/tga/tga.odin @@ -14,7 +14,6 @@ package tga import "core:mem" import "core:image" import "core:bytes" -import "core:os" import "core:compress" import "core:strings" @@ -28,7 +27,7 @@ GA_Pixel :: image.GA_Pixel RGB_Pixel :: image.RGB_Pixel RGBA_Pixel :: image.RGBA_Pixel -save_to_memory :: proc(output: ^bytes.Buffer, img: ^Image, options := Options{}, allocator := context.allocator) -> (err: Error) { +save_to_buffer :: proc(output: ^bytes.Buffer, img: ^Image, options := Options{}, allocator := context.allocator) -> (err: Error) { context.allocator = allocator if img == nil { @@ -58,7 +57,7 @@ save_to_memory :: proc(output: ^bytes.Buffer, img: ^Image, options := Options{} // Calculate and allocate necessary space. necessary := pixels * img.channels + size_of(image.TGA_Header) - if !resize(&output.buf, necessary) { + if resize(&output.buf, necessary) != nil { return .Unable_To_Allocate_Or_Resize } @@ -92,20 +91,6 @@ save_to_memory :: proc(output: ^bytes.Buffer, img: ^Image, options := Options{} return nil } -save_to_file :: proc(output: string, img: ^Image, options := Options{}, allocator := context.allocator) -> (err: Error) { - context.allocator = allocator - - out := &bytes.Buffer{} - defer bytes.buffer_destroy(out) - - save_to_memory(out, img, options) or_return - write_ok := os.write_entire_file(output, out.buf[:]) - - return nil if write_ok else .Unable_To_Write_File -} - -save :: proc{save_to_memory, save_to_file} - load_from_context :: proc(ctx: ^$C, options := Options{}, allocator := context.allocator) -> (img: ^Image, err: Error) { context.allocator = allocator options := options @@ -307,7 +292,7 @@ load_from_context :: proc(ctx: ^$C, options := Options{}, allocator := context.a return img, nil } - if !resize(&img.pixels.buf, dest_channels * img.width * img.height) { + if resize(&img.pixels.buf, dest_channels * img.width * img.height) != nil { return img, .Unable_To_Allocate_Or_Resize } @@ -398,20 +383,6 @@ load_from_bytes :: proc(data: []byte, options := Options{}, allocator := context return img, err } -load_from_file :: proc(filename: string, options := Options{}, allocator := context.allocator) -> (img: ^Image, err: Error) { - context.allocator = allocator - - data, ok := os.read_entire_file(filename) - defer delete(data) - - if ok { - return load_from_bytes(data, options) - } else { - return nil, .Unable_To_Read_File - } -} - -load :: proc{load_from_file, load_from_bytes, load_from_context} destroy :: proc(img: ^Image) { if img == nil || img.width == 0 || img.height == 0 { diff --git a/core/image/tga/tga_js.odin b/core/image/tga/tga_js.odin new file mode 100644 index 000000000..d98b241a7 --- /dev/null +++ b/core/image/tga/tga_js.odin @@ -0,0 +1,5 @@ +//+build js +package tga + +save :: proc{save_to_buffer} +load :: proc{load_from_bytes, load_from_context} diff --git a/core/image/tga/tga_os.odin b/core/image/tga/tga_os.odin new file mode 100644 index 000000000..12747a684 --- /dev/null +++ b/core/image/tga/tga_os.odin @@ -0,0 +1,34 @@ +//+build !js +package tga + +import "core:os" +import "core:bytes" + +save :: proc{save_to_buffer, save_to_file} + +save_to_file :: proc(output: string, img: ^Image, options := Options{}, allocator := context.allocator) -> (err: Error) { + context.allocator = allocator + + out := &bytes.Buffer{} + defer bytes.buffer_destroy(out) + + save_to_buffer(out, img, options) or_return + write_ok := os.write_entire_file(output, out.buf[:]) + + return nil if write_ok else .Unable_To_Write_File +} + +load :: proc{load_from_file, load_from_bytes, load_from_context} + +load_from_file :: proc(filename: string, options := Options{}, allocator := context.allocator) -> (img: ^Image, err: Error) { + context.allocator = allocator + + data, ok := os.read_entire_file(filename) + defer delete(data) + + if ok { + return load_from_bytes(data, options) + } else { + return nil, .Unable_To_Read_File + } +} \ No newline at end of file diff --git a/core/intrinsics/intrinsics.odin b/core/intrinsics/intrinsics.odin index 38542d2fc..93cd0e505 100644 --- a/core/intrinsics/intrinsics.odin +++ b/core/intrinsics/intrinsics.odin @@ -192,6 +192,7 @@ type_map_info :: proc($T: typeid/map[$K]$V) -> ^runtime.Map_Info --- type_map_cell_info :: proc($T: typeid) -> ^runtime.Map_Cell_Info --- type_convert_variants_to_pointers :: proc($T: typeid) -> typeid where type_is_union(T) --- +type_merge :: proc($U, $V: typeid) -> typeid where type_is_union(U), type_is_union(V) --- constant_utf16_cstring :: proc($literal: string) -> [^]u16 --- @@ -283,7 +284,7 @@ wasm_memory_atomic_wait32 :: proc(ptr: ^u32, expected: u32, timeout_ns: i64) - wasm_memory_atomic_notify32 :: proc(ptr: ^u32, waiters: u32) -> (waiters_woken_up: u32) --- // x86 Targets (i386, amd64) -x86_cpuid :: proc(ax, cx: u32) -> (eax, ebc, ecx, edx: u32) --- +x86_cpuid :: proc(ax, cx: u32) -> (eax, ebx, ecx, edx: u32) --- x86_xgetbv :: proc(cx: u32) -> (eax, edx: u32) --- @@ -305,4 +306,4 @@ valgrind_client_request :: proc(default: uintptr, request: uintptr, a0, a1, a2, // Internal compiler use only -__entry_point :: proc() --- \ No newline at end of file +__entry_point :: proc() --- diff --git a/core/io/conv.odin b/core/io/conv.odin index 39a72d69d..e3286baca 100644 --- a/core/io/conv.odin +++ b/core/io/conv.odin @@ -1,124 +1,80 @@ package io to_reader :: proc(s: Stream) -> (r: Reader, ok: bool = true) #optional_ok { - r.stream = s - if s.stream_vtable == nil || s.impl_read == nil { - ok = false - } + r = s + ok = .Read in query(s) return } to_writer :: proc(s: Stream) -> (w: Writer, ok: bool = true) #optional_ok { - w.stream = s - if s.stream_vtable == nil || s.impl_write == nil { - ok = false - } + w = s + ok = .Write in query(s) return } to_closer :: proc(s: Stream) -> (c: Closer, ok: bool = true) #optional_ok { - c.stream = s - if s.stream_vtable == nil || s.impl_close == nil { - ok = false - } + c = s + ok = .Close in query(s) return } to_flusher :: proc(s: Stream) -> (f: Flusher, ok: bool = true) #optional_ok { - f.stream = s - if s.stream_vtable == nil || s.impl_flush == nil { - ok = false - } + f = s + ok = .Flush in query(s) return } to_seeker :: proc(s: Stream) -> (seeker: Seeker, ok: bool = true) #optional_ok { - seeker.stream = s - if s.stream_vtable == nil || s.impl_seek == nil { - ok = false - } + seeker = s + ok = .Seek in query(s) return } to_read_writer :: proc(s: Stream) -> (r: Read_Writer, ok: bool = true) #optional_ok { - r.stream = s - if s.stream_vtable == nil || s.impl_read == nil || s.impl_write == nil { - ok = false - } + r = s + ok = query(s) >= {.Read, .Write} return } to_read_closer :: proc(s: Stream) -> (r: Read_Closer, ok: bool = true) #optional_ok { - r.stream = s - if s.stream_vtable == nil || s.impl_read == nil || s.impl_close == nil { - ok = false - } + r = s + ok = query(s) >= {.Read, .Close} return } to_read_write_closer :: proc(s: Stream) -> (r: Read_Write_Closer, ok: bool = true) #optional_ok { - r.stream = s - if s.stream_vtable == nil || s.impl_read == nil || s.impl_write == nil || s.impl_close == nil { - ok = false - } + r = s + ok = query(s) >= {.Read, .Write, .Close} return } to_read_write_seeker :: proc(s: Stream) -> (r: Read_Write_Seeker, ok: bool = true) #optional_ok { - r.stream = s - if s.stream_vtable == nil || s.impl_read == nil || s.impl_write == nil || s.impl_seek == nil { - ok = false - } + r = s + ok = query(s) >= {.Read, .Write, .Seek} return } to_write_flusher :: proc(s: Stream) -> (w: Write_Flusher, ok: bool = true) #optional_ok { - w.stream = s - if s.stream_vtable == nil || s.impl_write == nil || s.impl_flush == nil { - ok = false - } + w = s + ok = query(s) >= {.Write, .Flush} return } to_write_flush_closer :: proc(s: Stream) -> (w: Write_Flush_Closer, ok: bool = true) #optional_ok { - w.stream = s - if s.stream_vtable == nil || s.impl_write == nil || s.impl_flush == nil || s.impl_close == nil { - ok = false - } + w = s + ok = query(s) >= {.Write, .Flush, .Close} return } to_reader_at :: proc(s: Stream) -> (r: Reader_At, ok: bool = true) #optional_ok { - r.stream = s - if s.stream_vtable == nil || s.impl_read_at == nil { - ok = false - } + r = s + ok = query(s) >= {.Read_At} return } to_writer_at :: proc(s: Stream) -> (w: Writer_At, ok: bool = true) #optional_ok { - w.stream = s - if s.stream_vtable == nil || s.impl_write_at == nil { - ok = false - } - return -} -to_reader_from :: proc(s: Stream) -> (r: Reader_From, ok: bool = true) #optional_ok { - r.stream = s - if s.stream_vtable == nil || s.impl_read_from == nil { - ok = false - } - return -} -to_writer_to :: proc(s: Stream) -> (w: Writer_To, ok: bool = true) #optional_ok { - w.stream = s - if s.stream_vtable == nil || s.impl_write_to == nil { - ok = false - } + w = s + ok = query(s) >= {.Write_At} return } to_write_closer :: proc(s: Stream) -> (w: Write_Closer, ok: bool = true) #optional_ok { - w.stream = s - if s.stream_vtable == nil || s.impl_write == nil || s.impl_close == nil { - ok = false - } + w = s + ok = query(s) >= {.Write, .Close} return } to_write_seeker :: proc(s: Stream) -> (w: Write_Seeker, ok: bool = true) #optional_ok { - w.stream = s - if s.stream_vtable == nil || s.impl_write == nil || s.impl_seek == nil { - ok = false - } + w = s + ok = query(s) >= {.Write, .Seek} return } diff --git a/core/io/io.odin b/core/io/io.odin index 7faa500b1..566e13c54 100644 --- a/core/io/io.odin +++ b/core/io/io.odin @@ -53,137 +53,106 @@ Error :: enum i32 { Empty = -1, } -Close_Proc :: proc(using s: Stream) -> Error -Flush_Proc :: proc(using s: Stream) -> Error -Seek_Proc :: proc(using s: Stream, offset: i64, whence: Seek_From) -> (n: i64, err: Error) -Size_Proc :: proc(using s: Stream) -> i64 -Read_Proc :: proc(using s: Stream, p: []byte) -> (n: int, err: Error) -Read_At_Proc :: proc(using s: Stream, p: []byte, off: i64) -> (n: int, err: Error) -Read_From_Proc :: proc(using s: Stream, r: Reader) -> (n: i64, err: Error) -Read_Byte_Proc :: proc(using s: Stream) -> (byte, Error) -Read_Rune_Proc :: proc(using s: Stream) -> (ch: rune, size: int, err: Error) -Unread_Byte_Proc :: proc(using s: Stream) -> Error -Unread_Rune_Proc :: proc(using s: Stream) -> Error -Write_Proc :: proc(using s: Stream, p: []byte) -> (n: int, err: Error) -Write_At_Proc :: proc(using s: Stream, p: []byte, off: i64) -> (n: int, err: Error) -Write_To_Proc :: proc(using s: Stream, w: Writer) -> (n: i64, err: Error) -Write_Byte_Proc :: proc(using s: Stream, c: byte) -> Error -Write_Rune_Proc :: proc(using s: Stream, r: rune) -> (size: int, err: Error) -Destroy_Proc :: proc(using s: Stream) -> Error +Stream_Mode :: enum { + Close, + Flush, + Read, + Read_At, + Write, + Write_At, + Seek, + Size, + Destroy, + Query, // query what modes are available +} +Stream_Mode_Set :: distinct bit_set[Stream_Mode; i64] + +Stream_Proc :: #type proc(stream_data: rawptr, mode: Stream_Mode, p: []byte, offset: i64, whence: Seek_From) -> (n: i64, err: Error) Stream :: struct { - using stream_vtable: ^Stream_VTable, - stream_data: rawptr, -} -Stream_VTable :: struct { - impl_close: Close_Proc, - impl_flush: Flush_Proc, - - impl_seek: Seek_Proc, - impl_size: Size_Proc, - - impl_read: Read_Proc, - impl_read_at: Read_At_Proc, - impl_read_byte: Read_Byte_Proc, - impl_read_rune: Read_Rune_Proc, - impl_write_to: Write_To_Proc, - - impl_write: Write_Proc, - impl_write_at: Write_At_Proc, - impl_write_byte: Write_Byte_Proc, - impl_write_rune: Write_Rune_Proc, - impl_read_from: Read_From_Proc, - - impl_unread_byte: Unread_Byte_Proc, - impl_unread_rune: Unread_Rune_Proc, - - impl_destroy: Destroy_Proc, + procedure: Stream_Proc, + data: rawptr, } +Reader :: Stream +Writer :: Stream +Closer :: Stream +Flusher :: Stream +Seeker :: Stream -Reader :: struct {using stream: Stream} -Writer :: struct {using stream: Stream} -Closer :: struct {using stream: Stream} -Flusher :: struct {using stream: Stream} -Seeker :: struct {using stream: Stream} +Read_Writer :: Stream +Read_Closer :: Stream +Read_Write_Closer :: Stream +Read_Write_Seeker :: Stream -Read_Writer :: struct {using stream: Stream} -Read_Closer :: struct {using stream: Stream} -Read_Write_Closer :: struct {using stream: Stream} -Read_Write_Seeker :: struct {using stream: Stream} +Write_Closer :: Stream +Write_Seeker :: Stream +Write_Flusher :: Stream +Write_Flush_Closer :: Stream -Write_Closer :: struct {using stream: Stream} -Write_Seeker :: struct {using stream: Stream} -Write_Flusher :: struct {using stream: Stream} -Write_Flush_Closer :: struct {using stream: Stream} - -Reader_At :: struct {using stream: Stream} -Writer_At :: struct {using stream: Stream} -Reader_From :: struct {using stream: Stream} -Writer_To :: struct {using stream: Stream} +Reader_At :: Stream +Writer_At :: Stream -destroy :: proc(s: Stream) -> Error { - close_err := close({s}) - if s.stream_vtable != nil && s.impl_destroy != nil { - return s->impl_destroy() +destroy :: proc(s: Stream) -> (err: Error) { + _ = flush(s) + _ = close(s) + if s.procedure != nil { + _, err = s.procedure(s.data, .Destroy, nil, 0, nil) + } else { + err = .Empty } - if close_err != .None { - return close_err - } - return .Empty + return } +query :: proc(s: Stream) -> (set: Stream_Mode_Set) { + if s.procedure != nil { + n, _ := s.procedure(s.data, .Query, nil, 0, nil) + set = transmute(Stream_Mode_Set)n + if set != nil { + set += {.Query} + } + } + return +} + +query_utility :: #force_inline proc "contextless" (set: Stream_Mode_Set) -> (n: i64, err: Error) { + return transmute(i64)set, nil +} + +_i64_err :: #force_inline proc "contextless" (n: int, err: Error) -> (i64, Error) { + return i64(n), err +} + + // read reads up to len(p) bytes into s. It returns the number of bytes read and any error if occurred. // // When read encounters an .EOF or error after successfully reading n > 0 bytes, it returns the number of // bytes read along with the error. read :: proc(s: Reader, p: []byte, n_read: ^int = nil) -> (n: int, err: Error) { - if s.stream_vtable != nil { - if s.impl_read != nil { - n, err = s->impl_read(p) - if n_read != nil { - n_read^ += n - } - return - } else if s.impl_read_byte != nil { - bytes_read := 0 - defer if n_read != nil { - n_read^ += bytes_read - } - for _, i in p { - p[i] = s->impl_read_byte() or_return - bytes_read += 1 - } - return - } + if s.procedure != nil { + n64: i64 + n64, err = s.procedure(s.data, .Read, p, 0, nil) + n = int(n64) + if n_read != nil { n_read^ += n } + } else { + err = .Empty } - return 0, .Empty + return } // write writes up to len(p) bytes into s. It returns the number of bytes written and any error if occurred. write :: proc(s: Writer, p: []byte, n_written: ^int = nil) -> (n: int, err: Error) { - if s.stream_vtable != nil { - if s.impl_write != nil { - n, err = s->impl_write(p) - if n_written != nil { - n_written^ += n - } - return - } else if s.impl_write_byte != nil { - bytes_written := 0 - defer if n_written != nil { - n_written^ += bytes_written - } - for c in p { - s->impl_write_byte(c) or_return - bytes_written += 1 - } - return - } + if s.procedure != nil { + n64: i64 + n64, err = s.procedure(s.data, .Write, p, 0, nil) + n = int(n64) + if n_written != nil { n_written^ += n } + } else { + err = .Empty } - return 0, .Empty + return } // seek sets the offset of the next read or write to offset. @@ -194,57 +163,45 @@ write :: proc(s: Writer, p: []byte, n_written: ^int = nil) -> (n: int, err: Erro // // seek returns the new offset to the start of the file/stream, and any error if occurred. seek :: proc(s: Seeker, offset: i64, whence: Seek_From) -> (n: i64, err: Error) { - if s.stream_vtable != nil && s.impl_seek != nil { - return s->impl_seek(offset, whence) + if s.procedure != nil { + n, err = s.procedure(s.data, .Seek, nil, offset, whence) + } else { + err = .Empty } - return 0, .Empty + return } // The behaviour of close after the first call is stream implementation defined. // Different streams may document their own behaviour. -close :: proc(s: Closer) -> Error { - if s.stream_vtable != nil && s.impl_close != nil { - return s->impl_close() +close :: proc(s: Closer) -> (err: Error) { + if s.procedure != nil { + _, err = s.procedure(s.data, .Close, nil, 0, nil) } - // Instead of .Empty, .None is fine in this case - return .None + return } -flush :: proc(s: Flusher) -> Error { - if s.stream_vtable != nil && s.impl_flush != nil { - return s->impl_flush() +flush :: proc(s: Flusher) -> (err: Error) { + if s.procedure != nil { + _, err = s.procedure(s.data, .Flush, nil, 0, nil) } - // Instead of .Empty, .None is fine in this case - return .None + return } // size returns the size of the stream. If the stream does not support querying its size, 0 will be returned. -size :: proc(s: Stream) -> i64 { - if s.stream_vtable == nil { - return 0 +size :: proc(s: Stream) -> (n: i64, err: Error) { + if s.procedure != nil { + n, err = s.procedure(s.data, .Size, nil, 0, nil) + if err == .Empty { + n = 0 + curr := seek(s, 0, .Current) or_return + end := seek(s, 0, .End) or_return + seek(s, curr, .Start) or_return + n = end + } + } else { + err = .Empty } - if s.impl_size != nil { - return s->impl_size() - } - if s.impl_seek == nil { - return 0 - } - - curr, end: i64 - err: Error - if curr, err = s->impl_seek(0, .Current); err != nil { - return 0 - } - - if end, err = s->impl_seek(0, .End); err != nil { - return 0 - } - - if _, err = s->impl_seek(curr, .Start); err != nil { - return 0 - } - - return end + return } @@ -256,29 +213,24 @@ size :: proc(s: Stream) -> i64 { // // If n == len(p), err may be either nil or .EOF read_at :: proc(r: Reader_At, p: []byte, offset: i64, n_read: ^int = nil) -> (n: int, err: Error) { - defer if n_read != nil { - n_read^ += n - } - - if r.stream_vtable == nil { - return 0, .Empty - } - if r.impl_read_at != nil { - return r->impl_read_at(p, offset) - } - if r.impl_seek == nil || r.impl_read == nil { - return 0, .Empty - } - - curr_offset := r->impl_seek(offset, .Current) or_return - - n, err = r->impl_read(p) - _, err1 := r->impl_seek(curr_offset, .Start) - if err1 != nil && err == nil { - err = err1 + if r.procedure != nil { + n64: i64 + n64, err = r.procedure(r.data, .Read_At, p, offset, nil) + if err != .Empty { + n = int(n64) + } else { + curr := seek(r, offset, .Current) or_return + n, err = read(r, p) + _, err1 := seek(r, curr, .Start) + if err1 != nil && err == nil { + err = err1 + } + } + if n_read != nil { n_read^ += n } + } else { + err = .Empty } return - } // write_at writes len(p) bytes into p starting with the provided offset in the underlying Writer_At stream w. @@ -287,97 +239,39 @@ read_at :: proc(r: Reader_At, p: []byte, offset: i64, n_read: ^int = nil) -> (n: // If write_at is writing to a Writer_At which has a seek offset, then write_at should not affect the underlying // seek offset. write_at :: proc(w: Writer_At, p: []byte, offset: i64, n_written: ^int = nil) -> (n: int, err: Error) { - defer if n_written != nil { - n_written^ += n - } - - if w.stream_vtable == nil { - return 0, .Empty - } - if w.impl_write_at != nil { - return w->impl_write_at(p, offset) - } - if w.impl_seek == nil || w.impl_write == nil { - return 0, .Empty - } - - curr_offset: i64 - curr_offset, err = w->impl_seek(offset, .Current) - if err != nil { - return 0, err - } - - n, err = w->impl_write(p) - _, err1 := w->impl_seek(curr_offset, .Start) - if err1 != nil && err == nil { - err = err1 + if w.procedure != nil { + n64: i64 + n64, err = w.procedure(w.data, .Write_At, p, offset, nil) + if err != .Empty { + n = int(n64) + } else { + curr := seek(w, offset, .Current) or_return + n, err = write(w, p) + _, err1 := seek(w, curr, .Start) + if err1 != nil && err == nil { + err = err1 + } + } + if n_written != nil { n_written^ += n } + } else { + err = .Empty } return } -write_to :: proc(r: Writer_To, w: Writer) -> (n: i64, err: Error) { - if r.stream_vtable == nil || w.stream_vtable == nil { - return 0, .Empty - } - if r.impl_write_to != nil { - return r->impl_write_to(w) - } - return 0, .Empty -} -read_from :: proc(w: Reader_From, r: Reader) -> (n: i64, err: Error) { - if r.stream_vtable == nil || w.stream_vtable == nil { - return 0, .Empty - } - if r.impl_read_from != nil { - return w->impl_read_from(r) - } - return 0, .Empty -} - - // read_byte reads and returns the next byte from r. read_byte :: proc(r: Reader, n_read: ^int = nil) -> (b: byte, err: Error) { - defer if err == nil && n_read != nil { - n_read^ += 1 - } - - if r.stream_vtable == nil { - return 0, .Empty - } - if r.impl_read_byte != nil { - return r->impl_read_byte() - } - if r.impl_read == nil { - return 0, .Empty - } - buf: [1]byte - _, err = r->impl_read(buf[:]) - return buf[0], err + _, err = read(r, buf[:], n_read) + b = buf[0] + return } write_byte :: proc(w: Writer, c: byte, n_written: ^int = nil) -> Error { - return _write_byte(auto_cast w, c, n_written) -} - -@(private) -_write_byte :: proc(w: Writer, c: byte, n_written: ^int = nil) -> (err: Error) { - defer if err == nil && n_written != nil { - n_written^ += 1 - } - if w.stream_vtable == nil { - return .Empty - } - if w.impl_write_byte != nil { - return w->impl_write_byte(c) - } - if w.impl_write == nil { - return .Empty - } - - b := [1]byte{c} - _, err = w->impl_write(b[:]) - return err + buf: [1]byte + buf[0] = c + write(w, buf[:], n_written) or_return + return nil } // read_rune reads a single UTF-8 encoded Unicode codepoint and returns the rune and its size in bytes. @@ -385,19 +279,9 @@ read_rune :: proc(br: Reader, n_read: ^int = nil) -> (ch: rune, size: int, err: defer if err == nil && n_read != nil { n_read^ += size } - if br.stream_vtable == nil { - return 0, 0, .Empty - } - if br.impl_read_rune != nil { - return br->impl_read_rune() - } - if br.impl_read == nil { - return 0, 0, .Empty - } b: [utf8.UTF_MAX]byte - _, err = br->impl_read(b[:1]) - + _, err = read(br, b[:1]) s0 := b[0] ch = rune(s0) @@ -415,7 +299,7 @@ read_rune :: proc(br: Reader, n_read: ^int = nil) -> (ch: rune, size: int, err: return } sz := int(x&7) - size, err = br->impl_read(b[1:sz]) + size, err = read(br, b[1:sz]) if err != nil || size+1 < sz { ch = utf8.RUNE_ERROR return @@ -425,28 +309,6 @@ read_rune :: proc(br: Reader, n_read: ^int = nil) -> (ch: rune, size: int, err: return } -unread_byte :: proc(s: Stream) -> Error { - if s.stream_vtable == nil { - return .Empty - } - if s.impl_unread_byte != nil { - return s->impl_unread_byte() - } - if s.impl_seek != nil { - _, err := s->impl_seek(-1, .Current) - return err - } - - return .Empty -} -unread_rune :: proc(s: Writer) -> Error { - if s.stream_vtable != nil && s.impl_unread_rune != nil { - return s->impl_unread_rune() - } - return .Empty -} - - // write_string writes the contents of the string s to w. write_string :: proc(s: Writer, str: string, n_written: ^int = nil) -> (n: int, err: Error) { return write(s, transmute([]byte)str, n_written) @@ -457,14 +319,6 @@ write_rune :: proc(s: Writer, r: rune, n_written: ^int = nil) -> (size: int, err defer if err == nil && n_written != nil { n_written^ += size } - - if s.stream_vtable == nil { - return 0, .Empty - } - if s.impl_write_rune != nil { - return s->impl_write_rune(r) - } - if r < utf8.RUNE_SELF { err = write_byte(s, byte(r)) if err == nil { @@ -542,21 +396,15 @@ copy_n :: proc(dst: Writer, src: Reader, n: i64) -> (written: i64, err: Error) { @(private) _copy_buffer :: proc(dst: Writer, src: Reader, buf: []byte) -> (written: i64, err: Error) { - if dst.stream_vtable == nil || src.stream_vtable == nil { + if dst.procedure == nil || src.procedure == nil { return 0, .Empty } - if src.impl_write_to != nil { - return src->impl_write_to(dst) - } - if src.impl_read_from != nil { - return dst->impl_read_from(src) - } buf := buf if buf == nil { DEFAULT_SIZE :: 4 * 1024 size := DEFAULT_SIZE - if src.stream_vtable == _limited_reader_vtable { - l := (^Limited_Reader)(src.stream_data) + if src.procedure == _limited_reader_proc { + l := (^Limited_Reader)(src.data) if i64(size) > l.n { if l.n < 1 { size = 1 diff --git a/core/io/multi.odin b/core/io/multi.odin index 64c533e37..e85114a7a 100644 --- a/core/io/multi.odin +++ b/core/io/multi.odin @@ -5,33 +5,37 @@ Multi_Reader :: struct { } @(private) -_multi_reader_vtable := &Stream_VTable{ - impl_read = proc(s: Stream, p: []byte) -> (n: int, err: Error) { - mr := (^Multi_Reader)(s.stream_data) - for len(mr.readers) > 0 { - r := mr.readers[0] - n, err = read(r, p) - if err == .EOF { - ordered_remove(&mr.readers, 0) - } - if n > 0 || err != .EOF { - if err == .EOF && len(mr.readers) > 0 { - // Don't return EOF yet, more readers remain - err = nil - } - return - } +_multi_reader_proc :: proc(stream_data: rawptr, mode: Stream_Mode, p: []byte, offset: i64, whence: Seek_From) -> (n: i64, err: Error) { + if mode == .Query { + return query_utility({.Read, .Query}) + } else if mode != .Read { + return 0, .Empty + } + mr := (^Multi_Reader)(stream_data) + for len(mr.readers) > 0 { + r := mr.readers[0] + n, err = _i64_err(read(r, p)) + if err == .EOF { + ordered_remove(&mr.readers, 0) } - return 0, .EOF - }, + if n > 0 || err != .EOF { + if err == .EOF && len(mr.readers) > 0 { + // Don't return EOF yet, more readers remain + err = nil + } + return + } + } + return 0, .EOF } + multi_reader_init :: proc(mr: ^Multi_Reader, readers: ..Reader, allocator := context.allocator) -> (r: Reader) { all_readers := make([dynamic]Reader, 0, len(readers), allocator) for w in readers { - if w.stream_vtable == _multi_reader_vtable { - other := (^Multi_Reader)(w.stream_data) + if w.procedure == _multi_reader_proc { + other := (^Multi_Reader)(w.data) append(&all_readers, ..other.readers[:]) } else { append(&all_readers, w) @@ -40,8 +44,8 @@ multi_reader_init :: proc(mr: ^Multi_Reader, readers: ..Reader, allocator := con mr.readers = all_readers - r.stream_vtable = _multi_reader_vtable - r.stream_data = mr + r.procedure = _multi_reader_proc + r.data = mr return } @@ -55,38 +59,42 @@ Multi_Writer :: struct { } @(private) -_multi_writer_vtable := &Stream_VTable{ - impl_write = proc(s: Stream, p: []byte) -> (n: int, err: Error) { - mw := (^Multi_Writer)(s.stream_data) - for w in mw.writers { - n, err = write(w, p) - if err != nil { - return - } - if n != len(p) { - err = .Short_Write - return - } +_multi_writer_proc :: proc(stream_data: rawptr, mode: Stream_Mode, p: []byte, offset: i64, whence: Seek_From) -> (n: i64, err: Error) { + if mode == .Query { + return query_utility({.Write, .Query}) + } else if mode != .Write { + return 0, .Empty + } + mw := (^Multi_Writer)(stream_data) + for w in mw.writers { + n, err = _i64_err(write(w, p)) + if err != nil { + return } + if n != i64(len(p)) { + err = .Short_Write + return + } + } - return len(p), nil - }, + return i64(len(p)), nil } + multi_writer_init :: proc(mw: ^Multi_Writer, writers: ..Writer, allocator := context.allocator) -> (out: Writer) { mw.writers = make([dynamic]Writer, 0, len(writers), allocator) for w in writers { - if w.stream_vtable == _multi_writer_vtable { - other := (^Multi_Writer)(w.stream_data) + if w.procedure == _multi_writer_proc { + other := (^Multi_Writer)(w.data) append(&mw.writers, ..other.writers[:]) } else { append(&mw.writers, w) } } - out.stream_vtable = _multi_writer_vtable - out.stream_data = mw + out.procedure = _multi_writer_proc + out.data = mw return } diff --git a/core/io/util.odin b/core/io/util.odin index 46aa97919..c77d0be9d 100644 --- a/core/io/util.odin +++ b/core/io/util.odin @@ -2,6 +2,7 @@ package io import "core:strconv" import "core:unicode/utf8" +import "core:unicode/utf16" read_ptr :: proc(r: Reader, p: rawptr, byte_size: int, n_read: ^int = nil) -> (n: int, err: Error) { return read(r, ([^]byte)(p)[:byte_size], n_read) @@ -146,7 +147,7 @@ write_encoded_rune :: proc(w: Writer, r: rune, write_quote := true, n_written: ^ return } -write_escaped_rune :: proc(w: Writer, r: rune, quote: byte, html_safe := false, n_written: ^int = nil) -> (n: int, err: Error) { +write_escaped_rune :: proc(w: Writer, r: rune, quote: byte, html_safe := false, n_written: ^int = nil, for_json := false) -> (n: int, err: Error) { is_printable :: proc(r: rune) -> bool { if r <= 0xff { switch r { @@ -163,7 +164,7 @@ write_escaped_rune :: proc(w: Writer, r: rune, quote: byte, html_safe := false, defer if n_written != nil { n_written^ += n } - + if html_safe { switch r { case '<', '>', '&': @@ -211,17 +212,29 @@ write_escaped_rune :: proc(w: Writer, r: rune, quote: byte, html_safe := false, write_byte(w, DIGITS_LOWER[c>>uint(s) & 0xf], &n) or_return } case: - write_byte(w, '\\', &n) or_return - write_byte(w, 'U', &n) or_return - for s := 28; s >= 0; s -= 4 { - write_byte(w, DIGITS_LOWER[c>>uint(s) & 0xf], &n) or_return + if for_json { + buf: [2]u16 + utf16.encode(buf[:], []rune{c}) + for bc in buf { + write_byte(w, '\\', &n) or_return + write_byte(w, 'u', &n) or_return + for s := 12; s >= 0; s -= 4 { + write_byte(w, DIGITS_LOWER[bc>>uint(s) & 0xf], &n) or_return + } + } + } else { + write_byte(w, '\\', &n) or_return + write_byte(w, 'U', &n) or_return + for s := 24; s >= 0; s -= 4 { + write_byte(w, DIGITS_LOWER[c>>uint(s) & 0xf], &n) or_return + } } } } return } -write_quoted_string :: proc(w: Writer, str: string, quote: byte = '"', n_written: ^int = nil) -> (n: int, err: Error) { +write_quoted_string :: proc(w: Writer, str: string, quote: byte = '"', n_written: ^int = nil, for_json := false) -> (n: int, err: Error) { defer if n_written != nil { n_written^ += n } @@ -240,7 +253,7 @@ write_quoted_string :: proc(w: Writer, str: string, quote: byte = '"', n_written continue } - n_wrapper(write_escaped_rune(w, r, quote), &n) or_return + n_wrapper(write_escaped_rune(w, r, quote, false, nil, for_json), &n) or_return } write_byte(w, quote, &n) or_return @@ -279,17 +292,21 @@ Tee_Reader :: struct { } @(private) -_tee_reader_vtable := &Stream_VTable{ - impl_read = proc(s: Stream, p: []byte) -> (n: int, err: Error) { - t := (^Tee_Reader)(s.stream_data) - n, err = read(t.r, p) +_tee_reader_proc :: proc(stream_data: rawptr, mode: Stream_Mode, p: []byte, offset: i64, whence: Seek_From) -> (n: i64, err: Error) { + t := (^Tee_Reader)(stream_data) + #partial switch mode { + case .Read: + n, err = _i64_err(read(t.r, p)) if n > 0 { if wn, werr := write(t.w, p[:n]); werr != nil { - return wn, werr + return i64(wn), werr } } return - }, + case .Query: + return query_utility({.Read, .Query}) + } + return 0, .Empty } // tee_reader_init returns a Reader that writes to 'w' what it reads from 'r' @@ -304,8 +321,8 @@ tee_reader_init :: proc(t: ^Tee_Reader, r: Reader, w: Writer, allocator := conte } tee_reader_to_reader :: proc(t: ^Tee_Reader) -> (r: Reader) { - r.stream_data = t - r.stream_vtable = _tee_reader_vtable + r.data = t + r.procedure = _tee_reader_proc return } @@ -319,9 +336,10 @@ Limited_Reader :: struct { } @(private) -_limited_reader_vtable := &Stream_VTable{ - impl_read = proc(s: Stream, p: []byte) -> (n: int, err: Error) { - l := (^Limited_Reader)(s.stream_data) +_limited_reader_proc :: proc(stream_data: rawptr, mode: Stream_Mode, p: []byte, offset: i64, whence: Seek_From) -> (n: i64, err: Error) { + l := (^Limited_Reader)(stream_data) + #partial switch mode { + case .Read: if l.n <= 0 { return 0, .EOF } @@ -329,10 +347,13 @@ _limited_reader_vtable := &Stream_VTable{ if i64(len(p)) > l.n { p = p[0:l.n] } - n, err = read(l.r, p) + n, err = _i64_err(read(l.r, p)) l.n -= i64(n) return - }, + case .Query: + return query_utility({.Read, .Query}) + } + return 0, .Empty } limited_reader_init :: proc(l: ^Limited_Reader, r: Reader, n: i64) -> Reader { @@ -342,8 +363,8 @@ limited_reader_init :: proc(l: ^Limited_Reader, r: Reader, n: i64) -> Reader { } limited_reader_to_reader :: proc(l: ^Limited_Reader) -> (r: Reader) { - r.stream_vtable = _limited_reader_vtable - r.stream_data = l + r.procedure = _limited_reader_proc + r.data = l return } @@ -362,15 +383,16 @@ section_reader_init :: proc(s: ^Section_Reader, r: Reader_At, off: i64, n: i64) return } section_reader_to_stream :: proc(s: ^Section_Reader) -> (out: Stream) { - out.stream_data = s - out.stream_vtable = _section_reader_vtable + out.data = s + out.procedure = _section_reader_proc return } @(private) -_section_reader_vtable := &Stream_VTable{ - impl_read = proc(stream: Stream, p: []byte) -> (n: int, err: Error) { - s := (^Section_Reader)(stream.stream_data) +_section_reader_proc :: proc(stream_data: rawptr, mode: Stream_Mode, p: []byte, offset: i64, whence: Seek_From) -> (n: i64, err: Error) { + s := (^Section_Reader)(stream_data) + #partial switch mode { + case .Read: if s.off >= s.limit { return 0, .EOF } @@ -378,13 +400,11 @@ _section_reader_vtable := &Stream_VTable{ if max := s.limit - s.off; i64(len(p)) > max { p = p[0:max] } - n, err = read_at(s.r, p, s.off) + n, err = _i64_err(read_at(s.r, p, s.off)) s.off += i64(n) return - }, - impl_read_at = proc(stream: Stream, p: []byte, off: i64) -> (n: int, err: Error) { - s := (^Section_Reader)(stream.stream_data) - p, off := p, off + case .Read_At: + p, off := p, offset if off < 0 || off >= s.limit - s.base { return 0, .EOF @@ -392,17 +412,15 @@ _section_reader_vtable := &Stream_VTable{ off += s.base if max := s.limit - off; i64(len(p)) > max { p = p[0:max] - n, err = read_at(s.r, p, off) + n, err = _i64_err(read_at(s.r, p, off)) if err == nil { err = .EOF } return } - return read_at(s.r, p, off) - }, - impl_seek = proc(stream: Stream, offset: i64, whence: Seek_From) -> (n: i64, err: Error) { - s := (^Section_Reader)(stream.stream_data) + return _i64_err(read_at(s.r, p, off)) + case .Seek: offset := offset switch whence { case: @@ -420,10 +438,12 @@ _section_reader_vtable := &Stream_VTable{ s.off = offset n = offset - s.base return - }, - impl_size = proc(stream: Stream) -> i64 { - s := (^Section_Reader)(stream.stream_data) - return s.limit - s.base - }, -} + case .Size: + n = s.limit - s.base + return + case .Query: + return query_utility({.Read, .Read_At, .Seek, .Size, .Query}) + } + return 0, nil +} diff --git a/core/log/log.odin b/core/log/log.odin index a699247b8..f3554791b 100644 --- a/core/log/log.odin +++ b/core/log/log.odin @@ -76,43 +76,43 @@ nil_logger :: proc() -> Logger { } debugf :: proc(fmt_str: string, args: ..any, location := #caller_location) { - logf(level=.Debug, fmt_str=fmt_str, args=args, location=location) + logf(.Debug, fmt_str, ..args, location=location) } infof :: proc(fmt_str: string, args: ..any, location := #caller_location) { - logf(level=.Info, fmt_str=fmt_str, args=args, location=location) + logf(.Info, fmt_str, ..args, location=location) } warnf :: proc(fmt_str: string, args: ..any, location := #caller_location) { - logf(level=.Warning, fmt_str=fmt_str, args=args, location=location) + logf(.Warning, fmt_str, ..args, location=location) } errorf :: proc(fmt_str: string, args: ..any, location := #caller_location) { - logf(level=.Error, fmt_str=fmt_str, args=args, location=location) + logf(.Error, fmt_str, ..args, location=location) } fatalf :: proc(fmt_str: string, args: ..any, location := #caller_location) { - logf(level=.Fatal, fmt_str=fmt_str, args=args, location=location) + logf(.Fatal, fmt_str, ..args, location=location) } debug :: proc(args: ..any, sep := " ", location := #caller_location) { - log(level=.Debug, args=args, sep=sep, location=location) + log(.Debug, ..args, sep=sep, location=location) } info :: proc(args: ..any, sep := " ", location := #caller_location) { - log(level=.Info, args=args, sep=sep, location=location) + log(.Info, ..args, sep=sep, location=location) } warn :: proc(args: ..any, sep := " ", location := #caller_location) { - log(level=.Warning, args=args, sep=sep, location=location) + log(.Warning, ..args, sep=sep, location=location) } error :: proc(args: ..any, sep := " ", location := #caller_location) { - log(level=.Error, args=args, sep=sep, location=location) + log(.Error, ..args, sep=sep, location=location) } fatal :: proc(args: ..any, sep := " ", location := #caller_location) { - log(level=.Fatal, args=args, sep=sep, location=location) + log(.Fatal, ..args, sep=sep, location=location) } panic :: proc(args: ..any, location := #caller_location) -> ! { - log(level=.Fatal, args=args, location=location) + log(.Fatal, ..args, location=location) runtime.panic("log.panic", location) } panicf :: proc(fmt_str: string, args: ..any, location := #caller_location) -> ! { - logf(level=.Fatal, fmt_str=fmt_str, args=args, location=location) + logf(.Fatal, fmt_str, ..args, location=location) runtime.panic("log.panicf", location) } @@ -127,7 +127,7 @@ log :: proc(level: Level, args: ..any, sep := " ", location := #caller_location) if level < logger.lowest_level { return } - str := fmt.tprint(args=args, sep=sep) //NOTE(Hoej): While tprint isn't thread-safe, no logging is. + str := fmt.tprint(..args, sep=sep) //NOTE(Hoej): While tprint isn't thread-safe, no logging is. logger.procedure(logger.data, level, str, logger.options, location) } diff --git a/core/log/log_allocator.odin b/core/log/log_allocator.odin index f4d1841db..934f0d643 100644 --- a/core/log/log_allocator.odin +++ b/core/log/log_allocator.odin @@ -38,60 +38,60 @@ log_allocator_proc :: proc(allocator_data: rawptr, mode: runtime.Allocator_Mode, switch mode { case .Alloc: logf( - level=la.level, - fmt_str = "%s%s>>> ALLOCATOR(mode=.Alloc, size=%d, alignment=%d)", - args = {la.prefix, padding, size, alignment}, + la.level, + "%s%s>>> ALLOCATOR(mode=.Alloc, size=%d, alignment=%d)", + la.prefix, padding, size, alignment, location = location, ) case .Alloc_Non_Zeroed: logf( - level=la.level, - fmt_str = "%s%s>>> ALLOCATOR(mode=.Alloc_Non_Zeroed, size=%d, alignment=%d)", - args = {la.prefix, padding, size, alignment}, + la.level, + "%s%s>>> ALLOCATOR(mode=.Alloc_Non_Zeroed, size=%d, alignment=%d)", + la.prefix, padding, size, alignment, location = location, ) case .Free: if old_size != 0 { logf( - level=la.level, - fmt_str = "%s%s<<< ALLOCATOR(mode=.Free, ptr=%p, size=%d)", - args = {la.prefix, padding, old_memory, old_size}, + la.level, + "%s%s<<< ALLOCATOR(mode=.Free, ptr=%p, size=%d)", + la.prefix, padding, old_memory, old_size, location = location, ) } else { logf( - level=la.level, - fmt_str = "%s%s<<< ALLOCATOR(mode=.Free, ptr=%p)", - args = {la.prefix, padding, old_memory}, + la.level, + "%s%s<<< ALLOCATOR(mode=.Free, ptr=%p)", + la.prefix, padding, old_memory, location = location, ) } case .Free_All: logf( - level=la.level, - fmt_str = "%s%s<<< ALLOCATOR(mode=.Free_All)", - args = {la.prefix, padding}, + la.level, + "%s%s<<< ALLOCATOR(mode=.Free_All)", + la.prefix, padding, location = location, ) case .Resize: logf( - level=la.level, - fmt_str = "%s%s>>> ALLOCATOR(mode=.Resize, ptr=%p, old_size=%d, size=%d, alignment=%d)", - args = {la.prefix, padding, old_memory, old_size, size, alignment}, + la.level, + "%s%s>>> ALLOCATOR(mode=.Resize, ptr=%p, old_size=%d, size=%d, alignment=%d)", + la.prefix, padding, old_memory, old_size, size, alignment, location = location, ) case .Query_Features: logf( - level=la.level, - fmt_str = "%s%ALLOCATOR(mode=.Query_Features)", - args = {la.prefix, padding}, + la.level, + "%s%ALLOCATOR(mode=.Query_Features)", + la.prefix, padding, location = location, ) case .Query_Info: logf( - level=la.level, - fmt_str = "%s%ALLOCATOR(mode=.Query_Info)", - args = {la.prefix, padding}, + la.level, + "%s%ALLOCATOR(mode=.Query_Info)", + la.prefix, padding, location = location, ) } @@ -103,9 +103,9 @@ log_allocator_proc :: proc(allocator_data: rawptr, mode: runtime.Allocator_Mode, defer la.locked = false if err != nil { logf( - level=la.level, - fmt_str = "%s%ALLOCATOR ERROR=%v", - args = {la.prefix, padding, error}, + la.level, + "%s%ALLOCATOR ERROR=%v", + la.prefix, padding, error, location = location, ) } diff --git a/core/math/big/prime.odin b/core/math/big/prime.odin index 6f972937a..2f8b81af2 100644 --- a/core/math/big/prime.odin +++ b/core/math/big/prime.odin @@ -353,14 +353,14 @@ internal_int_is_prime :: proc(a: ^Int, miller_rabin_trials := int(-1), miller_ra // Run the Miller-Rabin test with base 2 for the BPSW test. internal_set(b, 2) or_return - if !internal_int_prime_miller_rabin(a, b) or_return { return } + if !(internal_int_prime_miller_rabin(a, b) or_return) { return } // Rumours have it that Mathematica does a second M-R test with base 3. // Other rumours have it that their strong L-S test is slightly different. // It does not hurt, though, beside a bit of extra runtime. b.digit[0] += 1 - if !internal_int_prime_miller_rabin(a, b) or_return { return } + if !(internal_int_prime_miller_rabin(a, b) or_return) { return } // Both, the Frobenius-Underwood test and the the Lucas-Selfridge test are quite // slow so if speed is an issue, set `USE_MILLER_RABIN_ONLY` to use M-R tests with @@ -369,9 +369,9 @@ internal_int_is_prime :: proc(a: ^Int, miller_rabin_trials := int(-1), miller_ra if !miller_rabin_only { if miller_rabin_trials >= 0 { when MATH_BIG_USE_FROBENIUS_TEST { - if !internal_int_prime_frobenius_underwood(a) or_return { return } + if !(internal_int_prime_frobenius_underwood(a) or_return) { return } } else { - if !internal_int_prime_strong_lucas_selfridge(a) or_return { return } + if !(internal_int_prime_strong_lucas_selfridge(a) or_return) { return } } } } @@ -410,7 +410,7 @@ internal_int_is_prime :: proc(a: ^Int, miller_rabin_trials := int(-1), miller_ra // We did bases 2 and 3 already, skip them for ix := 2; ix < p_max; ix += 1 { internal_set(b, _private_prime_table[ix]) - if !internal_int_prime_miller_rabin(a, b) or_return { return } + if !(internal_int_prime_miller_rabin(a, b) or_return) { return } } } else if miller_rabin_trials > 0 { // Perform `miller_rabin_trials` M-R tests with random bases between 3 and "a". @@ -490,7 +490,7 @@ internal_int_is_prime :: proc(a: ^Int, miller_rabin_trials := int(-1), miller_ra ix -= 1 continue } - if !internal_int_prime_miller_rabin(a, b) or_return { return } + if !(internal_int_prime_miller_rabin(a, b) or_return) { return } } } diff --git a/core/math/big/radix.odin b/core/math/big/radix.odin index 2b758dc35..d15ce0e98 100644 --- a/core/math/big/radix.odin +++ b/core/math/big/radix.odin @@ -429,7 +429,7 @@ internal_int_write_to_ascii_file :: proc(a: ^Int, filename: string, radix := i8( len = l, } - ok := os.write_entire_file(name=filename, data=data, truncate=true) + ok := os.write_entire_file(filename, data, truncate=true) return nil if ok else .Cannot_Write_File } diff --git a/core/math/bits/bits.odin b/core/math/bits/bits.odin index 850e8038a..959b5536f 100644 --- a/core/math/bits/bits.odin +++ b/core/math/bits/bits.odin @@ -37,68 +37,96 @@ overflowing_sub :: intrinsics.overflow_sub overflowing_mul :: intrinsics.overflow_mul -log2 :: proc(x: $T) -> T where intrinsics.type_is_integer(T), intrinsics.type_is_unsigned(T) { +@(require_results) +log2 :: proc "contextless" (x: $T) -> T where intrinsics.type_is_integer(T), intrinsics.type_is_unsigned(T) { return (8*size_of(T)-1) - count_leading_zeros(x) } -rotate_left8 :: proc(x: u8, k: int) -> u8 { +@(require_results) +rotate_left8 :: proc "contextless" (x: u8, k: int) -> u8 { n :: 8 s := uint(k) & (n-1) return x <>(n-s) } -rotate_left16 :: proc(x: u16, k: int) -> u16 { +@(require_results) +rotate_left16 :: proc "contextless" (x: u16, k: int) -> u16 { n :: 16 s := uint(k) & (n-1) return x <>(n-s) } -rotate_left32 :: proc(x: u32, k: int) -> u32 { +@(require_results) +rotate_left32 :: proc "contextless" (x: u32, k: int) -> u32 { n :: 32 s := uint(k) & (n-1) return x <>(n-s) } -rotate_left64 :: proc(x: u64, k: int) -> u64 { +@(require_results) +rotate_left64 :: proc "contextless" (x: u64, k: int) -> u64 { n :: 64 s := uint(k) & (n-1) return x <>(n-s) } -rotate_left :: proc(x: uint, k: int) -> uint { +@(require_results) +rotate_left :: proc "contextless" (x: uint, k: int) -> uint { n :: 8*size_of(uint) s := uint(k) & (n-1) return x <>(n-s) } -from_be_u8 :: proc(i: u8) -> u8 { return i } -from_be_u16 :: proc(i: u16) -> u16 { when ODIN_ENDIAN == .Big { return i } else { return byte_swap(i) } } -from_be_u32 :: proc(i: u32) -> u32 { when ODIN_ENDIAN == .Big { return i } else { return byte_swap(i) } } -from_be_u64 :: proc(i: u64) -> u64 { when ODIN_ENDIAN == .Big { return i } else { return byte_swap(i) } } -from_be_uint :: proc(i: uint) -> uint { when ODIN_ENDIAN == .Big { return i } else { return byte_swap(i) } } +@(require_results) +from_be_u8 :: proc "contextless" (i: u8) -> u8 { return i } +@(require_results) +from_be_u16 :: proc "contextless" (i: u16) -> u16 { when ODIN_ENDIAN == .Big { return i } else { return byte_swap(i) } } +@(require_results) +from_be_u32 :: proc "contextless" (i: u32) -> u32 { when ODIN_ENDIAN == .Big { return i } else { return byte_swap(i) } } +@(require_results) +from_be_u64 :: proc "contextless" (i: u64) -> u64 { when ODIN_ENDIAN == .Big { return i } else { return byte_swap(i) } } +@(require_results) +from_be_uint :: proc "contextless" (i: uint) -> uint { when ODIN_ENDIAN == .Big { return i } else { return byte_swap(i) } } -from_le_u8 :: proc(i: u8) -> u8 { return i } -from_le_u16 :: proc(i: u16) -> u16 { when ODIN_ENDIAN == .Little { return i } else { return byte_swap(i) } } -from_le_u32 :: proc(i: u32) -> u32 { when ODIN_ENDIAN == .Little { return i } else { return byte_swap(i) } } -from_le_u64 :: proc(i: u64) -> u64 { when ODIN_ENDIAN == .Little { return i } else { return byte_swap(i) } } -from_le_uint :: proc(i: uint) -> uint { when ODIN_ENDIAN == .Little { return i } else { return byte_swap(i) } } +@(require_results) +from_le_u8 :: proc "contextless" (i: u8) -> u8 { return i } +@(require_results) +from_le_u16 :: proc "contextless" (i: u16) -> u16 { when ODIN_ENDIAN == .Little { return i } else { return byte_swap(i) } } +@(require_results) +from_le_u32 :: proc "contextless" (i: u32) -> u32 { when ODIN_ENDIAN == .Little { return i } else { return byte_swap(i) } } +@(require_results) +from_le_u64 :: proc "contextless" (i: u64) -> u64 { when ODIN_ENDIAN == .Little { return i } else { return byte_swap(i) } } +@(require_results) +from_le_uint :: proc "contextless" (i: uint) -> uint { when ODIN_ENDIAN == .Little { return i } else { return byte_swap(i) } } -to_be_u8 :: proc(i: u8) -> u8 { return i } -to_be_u16 :: proc(i: u16) -> u16 { when ODIN_ENDIAN == .Big { return i } else { return byte_swap(i) } } -to_be_u32 :: proc(i: u32) -> u32 { when ODIN_ENDIAN == .Big { return i } else { return byte_swap(i) } } -to_be_u64 :: proc(i: u64) -> u64 { when ODIN_ENDIAN == .Big { return i } else { return byte_swap(i) } } -to_be_uint :: proc(i: uint) -> uint { when ODIN_ENDIAN == .Big { return i } else { return byte_swap(i) } } +@(require_results) +to_be_u8 :: proc "contextless" (i: u8) -> u8 { return i } +@(require_results) +to_be_u16 :: proc "contextless" (i: u16) -> u16 { when ODIN_ENDIAN == .Big { return i } else { return byte_swap(i) } } +@(require_results) +to_be_u32 :: proc "contextless" (i: u32) -> u32 { when ODIN_ENDIAN == .Big { return i } else { return byte_swap(i) } } +@(require_results) +to_be_u64 :: proc "contextless" (i: u64) -> u64 { when ODIN_ENDIAN == .Big { return i } else { return byte_swap(i) } } +@(require_results) +to_be_uint :: proc "contextless" (i: uint) -> uint { when ODIN_ENDIAN == .Big { return i } else { return byte_swap(i) } } -to_le_u8 :: proc(i: u8) -> u8 { return i } -to_le_u16 :: proc(i: u16) -> u16 { when ODIN_ENDIAN == .Little { return i } else { return byte_swap(i) } } -to_le_u32 :: proc(i: u32) -> u32 { when ODIN_ENDIAN == .Little { return i } else { return byte_swap(i) } } -to_le_u64 :: proc(i: u64) -> u64 { when ODIN_ENDIAN == .Little { return i } else { return byte_swap(i) } } -to_le_uint :: proc(i: uint) -> uint { when ODIN_ENDIAN == .Little { return i } else { return byte_swap(i) } } +@(require_results) +to_le_u8 :: proc "contextless" (i: u8) -> u8 { return i } +@(require_results) +to_le_u16 :: proc "contextless" (i: u16) -> u16 { when ODIN_ENDIAN == .Little { return i } else { return byte_swap(i) } } +@(require_results) +to_le_u32 :: proc "contextless" (i: u32) -> u32 { when ODIN_ENDIAN == .Little { return i } else { return byte_swap(i) } } +@(require_results) +to_le_u64 :: proc "contextless" (i: u64) -> u64 { when ODIN_ENDIAN == .Little { return i } else { return byte_swap(i) } } +@(require_results) +to_le_uint :: proc "contextless" (i: uint) -> uint { when ODIN_ENDIAN == .Little { return i } else { return byte_swap(i) } } -len_u8 :: proc(x: u8) -> int { +@(require_results) +len_u8 :: proc "contextless" (x: u8) -> int { return int(len_u8_table[x]) } -len_u16 :: proc(x: u16) -> (n: int) { +@(require_results) +len_u16 :: proc "contextless" (x: u16) -> (n: int) { x := x if x >= 1<<8 { x >>= 8 @@ -106,7 +134,8 @@ len_u16 :: proc(x: u16) -> (n: int) { } return n + int(len_u8_table[x]) } -len_u32 :: proc(x: u32) -> (n: int) { +@(require_results) +len_u32 :: proc "contextless" (x: u32) -> (n: int) { x := x if x >= 1<<16 { x >>= 16 @@ -118,7 +147,8 @@ len_u32 :: proc(x: u32) -> (n: int) { } return n + int(len_u8_table[x]) } -len_u64 :: proc(x: u64) -> (n: int) { +@(require_results) +len_u64 :: proc "contextless" (x: u64) -> (n: int) { x := x if x >= 1<<32 { x >>= 32 @@ -134,7 +164,8 @@ len_u64 :: proc(x: u64) -> (n: int) { } return n + int(len_u8_table[x]) } -len_uint :: proc(x: uint) -> (n: int) { +@(require_results) +len_uint :: proc "contextless" (x: uint) -> (n: int) { when size_of(uint) == size_of(u64) { return len_u64(u64(x)) } else { @@ -146,21 +177,24 @@ len_uint :: proc(x: uint) -> (n: int) { len :: proc{len_u8, len_u16, len_u32, len_u64, len_uint} -add_u32 :: proc(x, y, carry: u32) -> (sum, carry_out: u32) { +@(require_results) +add_u32 :: proc "contextless" (x, y, carry: u32) -> (sum, carry_out: u32) { tmp_carry, tmp_carry2: bool sum, tmp_carry = intrinsics.overflow_add(x, y) sum, tmp_carry2 = intrinsics.overflow_add(sum, carry) carry_out = u32(tmp_carry | tmp_carry2) return } -add_u64 :: proc(x, y, carry: u64) -> (sum, carry_out: u64) { +@(require_results) +add_u64 :: proc "contextless" (x, y, carry: u64) -> (sum, carry_out: u64) { tmp_carry, tmp_carry2: bool sum, tmp_carry = intrinsics.overflow_add(x, y) sum, tmp_carry2 = intrinsics.overflow_add(sum, carry) carry_out = u64(tmp_carry | tmp_carry2) return } -add_uint :: proc(x, y, carry: uint) -> (sum, carry_out: uint) { +@(require_results) +add_uint :: proc "contextless" (x, y, carry: uint) -> (sum, carry_out: uint) { when size_of(uint) == size_of(u64) { a, b := add_u64(u64(x), u64(y), u64(carry)) } else { @@ -172,21 +206,24 @@ add_uint :: proc(x, y, carry: uint) -> (sum, carry_out: uint) { add :: proc{add_u32, add_u64, add_uint} -sub_u32 :: proc(x, y, borrow: u32) -> (diff, borrow_out: u32) { +@(require_results) +sub_u32 :: proc "contextless" (x, y, borrow: u32) -> (diff, borrow_out: u32) { tmp_borrow, tmp_borrow2: bool diff, tmp_borrow = intrinsics.overflow_sub(x, y) diff, tmp_borrow2 = intrinsics.overflow_sub(diff, borrow) borrow_out = u32(tmp_borrow | tmp_borrow2) return } -sub_u64 :: proc(x, y, borrow: u64) -> (diff, borrow_out: u64) { +@(require_results) +sub_u64 :: proc "contextless" (x, y, borrow: u64) -> (diff, borrow_out: u64) { tmp_borrow, tmp_borrow2: bool diff, tmp_borrow = intrinsics.overflow_sub(x, y) diff, tmp_borrow2 = intrinsics.overflow_sub(diff, borrow) borrow_out = u64(tmp_borrow | tmp_borrow2) return } -sub_uint :: proc(x, y, borrow: uint) -> (diff, borrow_out: uint) { +@(require_results) +sub_uint :: proc "contextless" (x, y, borrow: uint) -> (diff, borrow_out: uint) { when size_of(uint) == size_of(u64) { a, b := sub_u64(u64(x), u64(y), u64(borrow)) } else { @@ -198,18 +235,21 @@ sub_uint :: proc(x, y, borrow: uint) -> (diff, borrow_out: uint) { sub :: proc{sub_u32, sub_u64, sub_uint} -mul_u32 :: proc(x, y: u32) -> (hi, lo: u32) { +@(require_results) +mul_u32 :: proc "contextless" (x, y: u32) -> (hi, lo: u32) { z := u64(x) * u64(y) hi, lo = u32(z>>32), u32(z) return } -mul_u64 :: proc(x, y: u64) -> (hi, lo: u64) { +@(require_results) +mul_u64 :: proc "contextless" (x, y: u64) -> (hi, lo: u64) { prod_wide := u128(x) * u128(y) hi, lo = u64(prod_wide>>64), u64(prod_wide) return } -mul_uint :: proc(x, y: uint) -> (hi, lo: uint) { +@(require_results) +mul_uint :: proc "contextless" (x, y: uint) -> (hi, lo: uint) { when size_of(uint) == size_of(u32) { a, b := mul_u32(u32(x), u32(y)) } else { @@ -222,13 +262,15 @@ mul_uint :: proc(x, y: uint) -> (hi, lo: uint) { mul :: proc{mul_u32, mul_u64, mul_uint} -div_u32 :: proc(hi, lo, y: u32) -> (quo, rem: u32) { +@(require_results) +div_u32 :: proc "odin" (hi, lo, y: u32) -> (quo, rem: u32) { assert(y != 0 && y <= hi) z := u64(hi)<<32 | u64(lo) quo, rem = u32(z/u64(y)), u32(z%u64(y)) return } -div_u64 :: proc(hi, lo, y: u64) -> (quo, rem: u64) { +@(require_results) +div_u64 :: proc "odin" (hi, lo, y: u64) -> (quo, rem: u64) { y := y two32 :: 1 << 32 mask32 :: two32 - 1 @@ -273,7 +315,8 @@ div_u64 :: proc(hi, lo, y: u64) -> (quo, rem: u64) { return q1*two32 + q0, (un21*two32 + un0 - q0*y) >> s } -div_uint :: proc(hi, lo, y: uint) -> (quo, rem: uint) { +@(require_results) +div_uint :: proc "odin" (hi, lo, y: uint) -> (quo, rem: uint) { when size_of(uint) == size_of(u32) { a, b := div_u32(u32(hi), u32(lo), u32(y)) } else { @@ -286,16 +329,26 @@ div :: proc{div_u32, div_u64, div_uint} -is_power_of_two_u8 :: proc(i: u8) -> bool { return i > 0 && (i & (i-1)) == 0 } -is_power_of_two_i8 :: proc(i: i8) -> bool { return i > 0 && (i & (i-1)) == 0 } -is_power_of_two_u16 :: proc(i: u16) -> bool { return i > 0 && (i & (i-1)) == 0 } -is_power_of_two_i16 :: proc(i: i16) -> bool { return i > 0 && (i & (i-1)) == 0 } -is_power_of_two_u32 :: proc(i: u32) -> bool { return i > 0 && (i & (i-1)) == 0 } -is_power_of_two_i32 :: proc(i: i32) -> bool { return i > 0 && (i & (i-1)) == 0 } -is_power_of_two_u64 :: proc(i: u64) -> bool { return i > 0 && (i & (i-1)) == 0 } -is_power_of_two_i64 :: proc(i: i64) -> bool { return i > 0 && (i & (i-1)) == 0 } -is_power_of_two_uint :: proc(i: uint) -> bool { return i > 0 && (i & (i-1)) == 0 } -is_power_of_two_int :: proc(i: int) -> bool { return i > 0 && (i & (i-1)) == 0 } +@(require_results) +is_power_of_two_u8 :: proc "contextless" (i: u8) -> bool { return i > 0 && (i & (i-1)) == 0 } +@(require_results) +is_power_of_two_i8 :: proc "contextless" (i: i8) -> bool { return i > 0 && (i & (i-1)) == 0 } +@(require_results) +is_power_of_two_u16 :: proc "contextless" (i: u16) -> bool { return i > 0 && (i & (i-1)) == 0 } +@(require_results) +is_power_of_two_i16 :: proc "contextless" (i: i16) -> bool { return i > 0 && (i & (i-1)) == 0 } +@(require_results) +is_power_of_two_u32 :: proc "contextless" (i: u32) -> bool { return i > 0 && (i & (i-1)) == 0 } +@(require_results) +is_power_of_two_i32 :: proc "contextless" (i: i32) -> bool { return i > 0 && (i & (i-1)) == 0 } +@(require_results) +is_power_of_two_u64 :: proc "contextless" (i: u64) -> bool { return i > 0 && (i & (i-1)) == 0 } +@(require_results) +is_power_of_two_i64 :: proc "contextless" (i: i64) -> bool { return i > 0 && (i & (i-1)) == 0 } +@(require_results) +is_power_of_two_uint :: proc "contextless" (i: uint) -> bool { return i > 0 && (i & (i-1)) == 0 } +@(require_results) +is_power_of_two_int :: proc "contextless" (i: int) -> bool { return i > 0 && (i & (i-1)) == 0 } is_power_of_two :: proc{ is_power_of_two_u8, is_power_of_two_i8, @@ -320,44 +373,56 @@ len_u8_table := [256]u8{ } -bitfield_extract_u8 :: proc(value: u8, offset, bits: uint) -> u8 { return (value >> offset) & u8(1< u16 { return (value >> offset) & u16(1< u32 { return (value >> offset) & u32(1< u64 { return (value >> offset) & u64(1< u128 { return (value >> offset) & u128(1< uint { return (value >> offset) & uint(1< u8 { return (value >> offset) & u8(1< u16 { return (value >> offset) & u16(1< u32 { return (value >> offset) & u32(1< u64 { return (value >> offset) & u64(1< u128 { return (value >> offset) & u128(1< uint { return (value >> offset) & uint(1< i8 { +@(require_results) +bitfield_extract_i8 :: proc "contextless" (value: i8, offset, bits: uint) -> i8 { v := (u8(value) >> offset) & u8(1< i16 { +@(require_results) +bitfield_extract_i16 :: proc "contextless" (value: i16, offset, bits: uint) -> i16 { v := (u16(value) >> offset) & u16(1< i32 { +@(require_results) +bitfield_extract_i32 :: proc "contextless" (value: i32, offset, bits: uint) -> i32 { v := (u32(value) >> offset) & u32(1< i64 { +@(require_results) +bitfield_extract_i64 :: proc "contextless" (value: i64, offset, bits: uint) -> i64 { v := (u64(value) >> offset) & u64(1< i128 { +@(require_results) +bitfield_extract_i128 :: proc "contextless" (value: i128, offset, bits: uint) -> i128 { v := (u128(value) >> offset) & u128(1< int { +@(require_results) +bitfield_extract_int :: proc "contextless" (value: int, offset, bits: uint) -> int { v := (uint(value) >> offset) & uint(1< u8 { +@(require_results) +bitfield_insert_u8 :: proc "contextless" (base, insert: u8, offset, bits: uint) -> u8 { mask := u8(1< u16 { +@(require_results) +bitfield_insert_u16 :: proc "contextless" (base, insert: u16, offset, bits: uint) -> u16 { mask := u16(1< u32 { +@(require_results) +bitfield_insert_u32 :: proc "contextless" (base, insert: u32, offset, bits: uint) -> u32 { mask := u32(1< u64 { +@(require_results) +bitfield_insert_u64 :: proc "contextless" (base, insert: u64, offset, bits: uint) -> u64 { mask := u64(1< u128 { +@(require_results) +bitfield_insert_u128 :: proc "contextless" (base, insert: u128, offset, bits: uint) -> u128 { mask := u128(1< uint { +@(require_results) +bitfield_insert_uint :: proc "contextless" (base, insert: uint, offset, bits: uint) -> uint { mask := uint(1< i8 { +@(require_results) +bitfield_insert_i8 :: proc "contextless" (base, insert: i8, offset, bits: uint) -> i8 { mask := i8(1< i16 { +@(require_results) +bitfield_insert_i16 :: proc "contextless" (base, insert: i16, offset, bits: uint) -> i16 { mask := i16(1< i32 { +@(require_results) +bitfield_insert_i32 :: proc "contextless" (base, insert: i32, offset, bits: uint) -> i32 { mask := i32(1< i64 { +@(require_results) +bitfield_insert_i64 :: proc "contextless" (base, insert: i64, offset, bits: uint) -> i64 { mask := i64(1< i128 { +@(require_results) +bitfield_insert_i128 :: proc "contextless" (base, insert: i128, offset, bits: uint) -> i128 { mask := i128(1< int { +@(require_results) +bitfield_insert_int :: proc "contextless" (base, insert: int, offset, bits: uint) -> int { mask := int(1< T where intrinsics.type_is_float(T) { return p * p } // Modeled after the parabola y = -x^2 + 2x +@(require_results) quadratic_out :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) { return -(p * (p - 2)) } @@ -23,6 +25,7 @@ quadratic_out :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float( // Modeled after the piecewise quadratic // y = (1/2)((2x)^2) ; [0, 0.5) // y = -(1/2)((2x-1)*(2x-3) - 1) ; [0.5, 1] +@(require_results) quadratic_in_out :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) { if p < 0.5 { return 2 * p * p @@ -32,11 +35,13 @@ quadratic_in_out :: proc "contextless" (p: $T) -> T where intrinsics.type_is_flo } // Modeled after the cubic y = x^3 +@(require_results) cubic_in :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) { return p * p * p } // Modeled after the cubic y = (x - 1)^3 + 1 +@(require_results) cubic_out :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) { f := p - 1 return f * f * f + 1 @@ -45,6 +50,7 @@ cubic_out :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) { // Modeled after the piecewise cubic // y = (1/2)((2x)^3) ; [0, 0.5) // y = (1/2)((2x-2)^3 + 2) ; [0.5, 1] +@(require_results) cubic_in_out :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) { if p < 0.5 { return 4 * p * p * p @@ -55,11 +61,13 @@ cubic_in_out :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T } // Modeled after the quartic x^4 +@(require_results) quartic_in :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) { return p * p * p * p } // Modeled after the quartic y = 1 - (x - 1)^4 +@(require_results) quartic_out :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) { f := p - 1 return f * f * f * (1 - p) + 1 @@ -68,6 +76,7 @@ quartic_out :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) // Modeled after the piecewise quartic // y = (1/2)((2x)^4) ; [0, 0.5) // y = -(1/2)((2x-2)^4 - 2) ; [0.5, 1] +@(require_results) quartic_in_out :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) { if p < 0.5 { return 8 * p * p * p * p @@ -78,11 +87,13 @@ quartic_in_out :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float } // Modeled after the quintic y = x^5 +@(require_results) quintic_in :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) { return p * p * p * p * p } // Modeled after the quintic y = (x - 1)^5 + 1 +@(require_results) quintic_out :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) { f := p - 1 return f * f * f * f * f + 1 @@ -91,6 +102,7 @@ quintic_out :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) // Modeled after the piecewise quintic // y = (1/2)((2x)^5) ; [0, 0.5) // y = (1/2)((2x-2)^5 + 2) ; [0.5, 1] +@(require_results) quintic_in_out :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) { if p < 0.5 { return 16 * p * p * p * p * p @@ -101,26 +113,31 @@ quintic_in_out :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float } // Modeled after quarter-cycle of sine wave +@(require_results) sine_in :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) { return math.sin((p - 1) * PI_2) + 1 } // Modeled after quarter-cycle of sine wave (different phase) +@(require_results) sine_out :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) { return math.sin(p * PI_2) } // Modeled after half sine wave +@(require_results) sine_in_out :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) { return 0.5 * (1 - math.cos(p * math.PI)) } // Modeled after shifted quadrant IV of unit circle +@(require_results) circular_in :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) { return 1 - math.sqrt(1 - (p * p)) } // Modeled after shifted quadrant II of unit circle +@(require_results) circular_out :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) { return math.sqrt((2 - p) * p) } @@ -128,6 +145,7 @@ circular_out :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T // Modeled after the piecewise circular function // y = (1/2)(1 - sqrt(1 - 4x^2)) ; [0, 0.5) // y = (1/2)(sqrt(-(2x - 3)*(2x - 1)) + 1) ; [0.5, 1] +@(require_results) circular_in_out :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) { if p < 0.5 { return 0.5 * (1 - math.sqrt(1 - 4 * (p * p))) @@ -137,11 +155,13 @@ circular_in_out :: proc "contextless" (p: $T) -> T where intrinsics.type_is_floa } // Modeled after the exponential function y = 2^(10(x - 1)) +@(require_results) exponential_in :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) { return p == 0.0 ? p : math.pow(2, 10 * (p - 1)) } // Modeled after the exponential function y = -2^(-10x) + 1 +@(require_results) exponential_out :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) { return p == 1.0 ? p : 1 - math.pow(2, -10 * p) } @@ -149,6 +169,7 @@ exponential_out :: proc "contextless" (p: $T) -> T where intrinsics.type_is_floa // Modeled after the piecewise exponential // y = (1/2)2^(10(2x - 1)) ; [0,0.5) // y = -(1/2)*2^(-10(2x - 1))) + 1 ; [0.5,1] +@(require_results) exponential_in_out :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) { if p == 0.0 || p == 1.0 { return p @@ -162,11 +183,13 @@ exponential_in_out :: proc "contextless" (p: $T) -> T where intrinsics.type_is_f } // Modeled after the damped sine wave y = sin(13pi/2*x)*pow(2, 10 * (x - 1)) +@(require_results) elastic_in :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) { return math.sin(13 * PI_2 * p) * math.pow(2, 10 * (p - 1)) } // Modeled after the damped sine wave y = sin(-13pi/2*(x + 1))*pow(2, -10x) + 1 +@(require_results) elastic_out :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) { return math.sin(-13 * PI_2 * (p + 1)) * math.pow(2, -10 * p) + 1 } @@ -174,6 +197,7 @@ elastic_out :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) // Modeled after the piecewise exponentially-damped sine wave: // y = (1/2)*sin(13pi/2*(2*x))*pow(2, 10 * ((2*x) - 1)) ; [0,0.5) // y = (1/2)*(sin(-13pi/2*((2x-1)+1))*pow(2,-10(2*x-1)) + 2) ; [0.5, 1] +@(require_results) elastic_in_out :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) { if p < 0.5 { return 0.5 * math.sin(13 * PI_2 * (2 * p)) * math.pow(2, 10 * ((2 * p) - 1)) @@ -183,11 +207,13 @@ elastic_in_out :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float } // Modeled after the overshooting cubic y = x^3-x*sin(x*pi) +@(require_results) back_in :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) { return p * p * p - p * math.sin(p * math.PI) } // Modeled after overshooting cubic y = 1-((1-x)^3-(1-x)*sin((1-x)*pi)) +@(require_results) back_out :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) { f := 1 - p return 1 - (f * f * f - f * math.sin(f * math.PI)) @@ -196,6 +222,7 @@ back_out :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) { // Modeled after the piecewise overshooting cubic function: // y = (1/2)*((2x)^3-(2x)*sin(2*x*pi)) ; [0, 0.5) // y = (1/2)*(1-((1-x)^3-(1-x)*sin((1-x)*pi))+1) ; [0.5, 1] +@(require_results) back_in_out :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) { if p < 0.5 { f := 2 * p @@ -206,10 +233,12 @@ back_in_out :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) } } +@(require_results) bounce_in :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) { return 1 - bounce_out(1 - p) } +@(require_results) bounce_out :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) { if p < 4/11.0 { return (121 * p * p)/16.0 @@ -222,6 +251,7 @@ bounce_out :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) } } +@(require_results) bounce_in_out :: proc "contextless" (p: $T) -> T where intrinsics.type_is_float(T) { if p < 0.5 { return 0.5 * bounce_in(p*2) @@ -276,50 +306,51 @@ Ease :: enum { Bounce_In_Out, } +@(require_results) ease :: proc "contextless" (type: Ease, p: $T) -> T where intrinsics.type_is_float(T) { switch type { - case .Linear: return p - - case .Quadratic_In: return quadratic_in(p) - case .Quadratic_Out: return quadratic_out(p) - case .Quadratic_In_Out: return quadratic_in_out(p) + case .Linear: return p - case .Cubic_In: return cubic_in(p) - case .Cubic_Out: return cubic_out(p) - case .Cubic_In_Out: return cubic_in_out(p) + case .Quadratic_In: return quadratic_in(p) + case .Quadratic_Out: return quadratic_out(p) + case .Quadratic_In_Out: return quadratic_in_out(p) - case .Quartic_In: return quartic_in(p) - case .Quartic_Out: return quartic_out(p) - case .Quartic_In_Out: return quartic_in_out(p) + case .Cubic_In: return cubic_in(p) + case .Cubic_Out: return cubic_out(p) + case .Cubic_In_Out: return cubic_in_out(p) - case .Quintic_In: return quintic_in(p) - case .Quintic_Out: return quintic_out(p) - case .Quintic_In_Out: return quintic_in_out(p) + case .Quartic_In: return quartic_in(p) + case .Quartic_Out: return quartic_out(p) + case .Quartic_In_Out: return quartic_in_out(p) - case .Sine_In: return sine_in(p) - case .Sine_Out: return sine_out(p) - case .Sine_In_Out: return sine_in_out(p) + case .Quintic_In: return quintic_in(p) + case .Quintic_Out: return quintic_out(p) + case .Quintic_In_Out: return quintic_in_out(p) - case .Circular_In: return circular_in(p) - case .Circular_Out: return circular_out(p) - case .Circular_In_Out: return circular_in_out(p) + case .Sine_In: return sine_in(p) + case .Sine_Out: return sine_out(p) + case .Sine_In_Out: return sine_in_out(p) - case .Exponential_In: return exponential_in(p) - case .Exponential_Out: return exponential_out(p) - case .Exponential_In_Out: return exponential_in_out(p) + case .Circular_In: return circular_in(p) + case .Circular_Out: return circular_out(p) + case .Circular_In_Out: return circular_in_out(p) - case .Elastic_In: return elastic_in(p) - case .Elastic_Out: return elastic_out(p) - case .Elastic_In_Out: return elastic_in_out(p) + case .Exponential_In: return exponential_in(p) + case .Exponential_Out: return exponential_out(p) + case .Exponential_In_Out: return exponential_in_out(p) - case .Back_In: return back_in(p) - case .Back_Out: return back_out(p) - case .Back_In_Out: return back_in_out(p) + case .Elastic_In: return elastic_in(p) + case .Elastic_Out: return elastic_out(p) + case .Elastic_In_Out: return elastic_in_out(p) - case .Bounce_In: return bounce_in(p) - case .Bounce_Out: return bounce_out(p) - case .Bounce_In_Out: return bounce_in_out(p) + case .Back_In: return back_in(p) + case .Back_Out: return back_out(p) + case .Back_In_Out: return back_in_out(p) + + case .Bounce_In: return bounce_in(p) + case .Bounce_Out: return bounce_out(p) + case .Bounce_In_Out: return bounce_in_out(p) } // in case type was invalid @@ -353,6 +384,7 @@ Flux_Tween :: struct($T: typeid) { } // init flux map to a float type and a wanted cap +@(require_results) flux_init :: proc($T: typeid, value_capacity := 8) -> Flux_Map(T) where intrinsics.type_is_float(T) { return { values = make(map[^T]Flux_Tween(T), value_capacity), @@ -374,6 +406,7 @@ flux_clear :: proc(flux: ^Flux_Map($T)) where intrinsics.type_is_float(T) { // append / overwrite existing tween value to parameters // rest is initialized in flux_tween_init, inside update // return value can be used to set callbacks +@(require_results) flux_to :: proc( flux: ^Flux_Map($T), value: ^T, @@ -475,6 +508,7 @@ flux_update :: proc(flux: ^Flux_Map($T), dt: f64) where intrinsics.type_is_float // stop a specific key inside the map // returns true when it successfully removed the key +@(require_results) flux_stop :: proc(flux: ^Flux_Map($T), key: ^T) -> bool where intrinsics.type_is_float(T) { if key in flux.values { delete_key(&flux.values, key) @@ -486,6 +520,7 @@ flux_stop :: proc(flux: ^Flux_Map($T), key: ^T) -> bool where intrinsics.type_is // returns the amount of time left for the tween animation, if the key exists in the map // returns 0 if the tween doesnt exist on the map +@(require_results) flux_tween_time_left :: proc(flux: Flux_Map($T), key: ^T) -> f64 { if tween, ok := flux.values[key]; ok { return ((1 - tween.progress) * tween.rate) + tween.delay diff --git a/core/math/fixed/fixed.odin b/core/math/fixed/fixed.odin index 856e7f088..e080d63b6 100644 --- a/core/math/fixed/fixed.odin +++ b/core/math/fixed/fixed.odin @@ -50,39 +50,48 @@ to_f64 :: proc(x: $T/Fixed($Backing, $Fraction_Width)) -> f64 { } +@(require_results) add :: proc(x, y: $T/Fixed) -> T { return {x.i + y.i} } +@(require_results) sub :: proc(x, y: $T/Fixed) -> T { return {x.i - y.i} } +@(require_results) mul :: proc(x, y: $T/Fixed($Backing, $Fraction_Width)) -> (z: T) { z.i = intrinsics.fixed_point_mul(x.i, y.i, Fraction_Width) return } +@(require_results) mul_sat :: proc(x, y: $T/Fixed($Backing, $Fraction_Width)) -> (z: T) { z.i = intrinsics.fixed_point_mul_sat(x.i, y.i, Fraction_Width) return } +@(require_results) div :: proc(x, y: $T/Fixed($Backing, $Fraction_Width)) -> (z: T) { z.i = intrinsics.fixed_point_div(x.i, y.i, Fraction_Width) return } +@(require_results) div_sat :: proc(x, y: $T/Fixed($Backing, $Fraction_Width)) -> (z: T) { z.i = intrinsics.fixed_point_div_sat(x.i, y.i, Fraction_Width) return } +@(require_results) floor :: proc(x: $T/Fixed($Backing, $Fraction_Width)) -> Backing { return x.i >> Fraction_Width } +@(require_results) ceil :: proc(x: $T/Fixed($Backing, $Fraction_Width)) -> Backing { Integer :: 8*size_of(Backing) - Fraction_Width return (x.i + (1 << Integer-1)) >> Fraction_Width } +@(require_results) round :: proc(x: $T/Fixed($Backing, $Fraction_Width)) -> Backing { Integer :: 8*size_of(Backing) - Fraction_Width return (x.i + (1 << (Integer - 1))) >> Fraction_Width @@ -90,6 +99,7 @@ round :: proc(x: $T/Fixed($Backing, $Fraction_Width)) -> Backing { +@(require_results) append :: proc(dst: []byte, x: $T/Fixed($Backing, $Fraction_Width)) -> string { x := x buf: [48]byte @@ -123,6 +133,7 @@ append :: proc(dst: []byte, x: $T/Fixed($Backing, $Fraction_Width)) -> string { } +@(require_results) to_string :: proc(x: $T/Fixed($Backing, $Fraction_Width), allocator := context.allocator) -> string { buf: [48]byte s := append(buf[:], x) diff --git a/core/math/linalg/extended.odin b/core/math/linalg/extended.odin index b78697cbd..b6e05a2c2 100644 --- a/core/math/linalg/extended.odin +++ b/core/math/linalg/extended.odin @@ -3,20 +3,23 @@ package linalg import "core:builtin" import "core:math" -radians :: proc(degrees: $T) -> (out: T) where IS_NUMERIC(ELEM_TYPE(T)) { +@(require_results) +to_radians :: proc "contextless" (degrees: $T) -> (out: T) where IS_NUMERIC(ELEM_TYPE(T)) { when IS_ARRAY(T) { for i in 0.. (out: T) where IS_NUMERIC(ELEM_TYPE(T)) { + +@(require_results) +to_degrees :: proc "contextless" (radians: $T) -> (out: T) where IS_NUMERIC(ELEM_TYPE(T)) { when IS_ARRAY(T) { for i in 0.. (out: T) where IS_NUMERIC(ELEM_TYPE(T)) { return } -min_double :: proc(a, b: $T) -> (out: T) where IS_NUMERIC(ELEM_TYPE(T)) { +@(require_results) +min_double :: proc "contextless" (a, b: $T) -> (out: T) where IS_NUMERIC(ELEM_TYPE(T)) { when IS_ARRAY(T) { for i in 0.. (out: T) where IS_NUMERIC(ELEM_TYPE(T)) { return } -min_single :: proc(a: $T) -> (out: ELEM_TYPE(T)) where IS_NUMERIC(ELEM_TYPE(T)) { +@(require_results) +min_single :: proc "contextless" (a: $T) -> (out: ELEM_TYPE(T)) where IS_NUMERIC(ELEM_TYPE(T)) { when IS_ARRAY(T) { N :: len(T) @@ -55,13 +60,15 @@ min_single :: proc(a: $T) -> (out: ELEM_TYPE(T)) where IS_NUMERIC(ELEM_TYPE(T)) return } -min_triple :: proc(a, b, c: $T) -> T where IS_NUMERIC(ELEM_TYPE(T)) { +@(require_results) +min_triple :: proc "contextless" (a, b, c: $T) -> T where IS_NUMERIC(ELEM_TYPE(T)) { return min_double(a, min_double(b, c)) } min :: proc{min_single, min_double, min_triple} -max_double :: proc(a, b: $T) -> (out: T) where IS_NUMERIC(ELEM_TYPE(T)) { +@(require_results) +max_double :: proc "contextless" (a, b: $T) -> (out: T) where IS_NUMERIC(ELEM_TYPE(T)) { when IS_ARRAY(T) { for i in 0.. (out: T) where IS_NUMERIC(ELEM_TYPE(T)) { return } -max_single :: proc(a: $T) -> (out: ELEM_TYPE(T)) where IS_NUMERIC(ELEM_TYPE(T)) { +@(require_results) +max_single :: proc "contextless" (a: $T) -> (out: ELEM_TYPE(T)) where IS_NUMERIC(ELEM_TYPE(T)) { when IS_ARRAY(T) { N :: len(T) @@ -94,13 +102,15 @@ max_single :: proc(a: $T) -> (out: ELEM_TYPE(T)) where IS_NUMERIC(ELEM_TYPE(T)) return } -max_triple :: proc(a, b, c: $T) -> T where IS_NUMERIC(ELEM_TYPE(T)) { +@(require_results) +max_triple :: proc "contextless" (a, b, c: $T) -> T where IS_NUMERIC(ELEM_TYPE(T)) { return max_double(a, max_double(b, c)) } max :: proc{max_single, max_double, max_triple} -abs :: proc(a: $T) -> (out: T) where IS_NUMERIC(ELEM_TYPE(T)) { +@(require_results) +abs :: proc "contextless" (a: $T) -> (out: T) where IS_NUMERIC(ELEM_TYPE(T)) { when IS_ARRAY(T) { for i in 0.. (out: T) where IS_NUMERIC(ELEM_TYPE(T)) { return } -sign :: proc(a: $T) -> (out: T) where IS_NUMERIC(ELEM_TYPE(T)) { +@(require_results) +sign :: proc "contextless" (a: $T) -> (out: T) where IS_NUMERIC(ELEM_TYPE(T)) { when IS_ARRAY(T) { for i in 0.. (out: T) where IS_NUMERIC(ELEM_TYPE(T)) { return } -clamp :: proc(x, a, b: $T) -> (out: T) where IS_NUMERIC(ELEM_TYPE(T)) { +@(require_results) +clamp :: proc "contextless" (x, a, b: $T) -> (out: T) where IS_NUMERIC(ELEM_TYPE(T)) { when IS_ARRAY(T) { for i in 0.. (out: T) where IS_NUMERIC(ELEM_TYPE(T)) { } -saturate :: proc(x: $T) -> T where IS_FLOAT(ELEM_TYPE(T)) { +@(require_results) +saturate :: proc "contextless" (x: $T) -> T where IS_FLOAT(ELEM_TYPE(T)) { return clamp(x, 0.0, 1.0) } -lerp :: proc(a, b, t: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { +@(require_results) +lerp :: proc "contextless" (a, b, t: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { when IS_ARRAY(T) { for i in 0.. (out: T) where IS_FLOAT(ELEM_TYPE(T)) { } return } -mix :: proc(a, b, t: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { +@(require_results) +mix :: proc "contextless" (a, b, t: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { when IS_ARRAY(T) { for i in 0.. (out: T) where IS_FLOAT(ELEM_TYPE(T)) { return } -unlerp :: proc(a, b, x: $T) -> T where IS_FLOAT(ELEM_TYPE(T)) { +@(require_results) +unlerp :: proc "contextless" (a, b, x: $T) -> T where IS_FLOAT(ELEM_TYPE(T)) { return (x - a) / (b - a) } -step :: proc(e, x: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { +@(require_results) +step :: proc "contextless" (e, x: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { when IS_ARRAY(T) { for i in 0.. (out: T) where IS_FLOAT(ELEM_TYPE(T)) { return } -smoothstep :: proc(e0, e1, x: $T) -> T where IS_FLOAT(ELEM_TYPE(T)) { +@(require_results) +smoothstep :: proc "contextless" (e0, e1, x: $T) -> T where IS_FLOAT(ELEM_TYPE(T)) { t := saturate(unlerp(e0, e1, x)) return t * t * (3.0 - 2.0 * t) } -smootherstep :: proc(e0, e1, x: $T) -> T where IS_FLOAT(ELEM_TYPE(T)) { +@(require_results) +smootherstep :: proc "contextless" (e0, e1, x: $T) -> T where IS_FLOAT(ELEM_TYPE(T)) { t := saturate(unlerp(e0, e1, x)) return t * t * t * (t * (6*t - 15) + 10) } -sqrt :: proc(x: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { +@(require_results) +sqrt :: proc "contextless" (x: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { when IS_ARRAY(T) { for i in 0.. (out: T) where IS_FLOAT(ELEM_TYPE(T)) { return } -inverse_sqrt :: proc(x: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { +@(require_results) +inverse_sqrt :: proc "contextless" (x: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { when IS_ARRAY(T) { for i in 0.. (out: T) where IS_FLOAT(ELEM_TYPE(T)) { return } -cos :: proc(x: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { +@(require_results) +cos :: proc "contextless" (x: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { when IS_ARRAY(T) { for i in 0.. (out: T) where IS_FLOAT(ELEM_TYPE(T)) { return } -sin :: proc(x: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { +@(require_results) +sin :: proc "contextless" (x: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { when IS_ARRAY(T) { for i in 0.. (out: T) where IS_FLOAT(ELEM_TYPE(T)) { return } -tan :: proc(x: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { +@(require_results) +tan :: proc "contextless" (x: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { when IS_ARRAY(T) { for i in 0.. (out: T) where IS_FLOAT(ELEM_TYPE(T)) { return } -acos :: proc(x: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { +@(require_results) +acos :: proc "contextless" (x: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { when IS_ARRAY(T) { for i in 0.. (out: T) where IS_FLOAT(ELEM_TYPE(T)) { return } -asin :: proc(x: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { +@(require_results) +asin :: proc "contextless" (x: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { when IS_ARRAY(T) { for i in 0.. (out: T) where IS_FLOAT(ELEM_TYPE(T)) { return } -atan :: proc(x: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { +@(require_results) +atan :: proc "contextless" (x: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { when IS_ARRAY(T) { for i in 0.. (out: T) where IS_FLOAT(ELEM_TYPE(T)) { } return } -atan2 :: proc(y, x: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { +@(require_results) +atan2 :: proc "contextless" (y, x: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { when IS_ARRAY(T) { for i in 0.. (out: T) where IS_FLOAT(ELEM_TYPE(T)) { } -ln :: proc(x: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { +@(require_results) +ln :: proc "contextless" (x: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { when IS_ARRAY(T) { for i in 0.. (out: T) where IS_FLOAT(ELEM_TYPE(T)) { return } -log2 :: proc(x: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { +@(require_results) +log2 :: proc "contextless" (x: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { when IS_ARRAY(T) { for i in 0.. (out: T) where IS_FLOAT(ELEM_TYPE(T)) { return } -log10 :: proc(x: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { +@(require_results) +log10 :: proc "contextless" (x: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { when IS_ARRAY(T) { for i in 0.. (out: T) where IS_FLOAT(ELEM_TYPE(T)) { return } -log :: proc(x, b: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { +@(require_results) +log :: proc "contextless" (x, b: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { when IS_ARRAY(T) { for i in 0.. (out: T) where IS_FLOAT(ELEM_TYPE(T)) { return } -exp :: proc(x: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { +@(require_results) +exp :: proc "contextless" (x: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { when IS_ARRAY(T) { for i in 0.. (out: T) where IS_FLOAT(ELEM_TYPE(T)) { return } -exp2 :: proc(x: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { +@(require_results) +exp2 :: proc "contextless" (x: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { when IS_ARRAY(T) { for i in 0.. (out: T) where IS_FLOAT(ELEM_TYPE(T)) { return } -exp10 :: proc(x: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { +@(require_results) +exp10 :: proc "contextless" (x: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { when IS_ARRAY(T) { for i in 0.. (out: T) where IS_FLOAT(ELEM_TYPE(T)) { return } -pow :: proc(x, e: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { +@(require_results) +pow :: proc "contextless" (x, e: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { when IS_ARRAY(T) { for i in 0.. (out: T) where IS_FLOAT(ELEM_TYPE(T)) { } -ceil :: proc(x: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { +@(require_results) +ceil :: proc "contextless" (x: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { when IS_ARRAY(T) { for i in 0.. (out: T) where IS_FLOAT(ELEM_TYPE(T)) { return } -floor :: proc(x: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { +@(require_results) +floor :: proc "contextless" (x: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { when IS_ARRAY(T) { for i in 0.. (out: T) where IS_FLOAT(ELEM_TYPE(T)) { return } -round :: proc(x: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { +@(require_results) +round :: proc "contextless" (x: $T) -> (out: T) where IS_FLOAT(ELEM_TYPE(T)) { when IS_ARRAY(T) { for i in 0.. (out: T) where IS_FLOAT(ELEM_TYPE(T)) { return } -fract :: proc(x: $T) -> T where IS_FLOAT(ELEM_TYPE(T)) { +@(require_results) +fract :: proc "contextless" (x: $T) -> T where IS_FLOAT(ELEM_TYPE(T)) { f := #force_inline floor(x) return x - f } -mod :: proc(x, m: $T) -> T where IS_FLOAT(ELEM_TYPE(T)) { +@(require_results) +mod :: proc "contextless" (x, m: $T) -> T where IS_FLOAT(ELEM_TYPE(T)) { f := #force_inline floor(x / m) return x - f * m } -face_forward :: proc(N, I, N_ref: $T) -> (out: T) where IS_ARRAY(T), IS_FLOAT(ELEM_TYPE(T)) { +@(require_results) +face_forward :: proc "contextless" (N, I, N_ref: $T) -> (out: T) where IS_ARRAY(T), IS_FLOAT(ELEM_TYPE(T)) { return dot(N_ref, I) < 0 ? N : -N } -distance :: proc(p0, p1: $V/[$N]$E) -> E where IS_NUMERIC(E) { +@(require_results) +distance :: proc "contextless" (p0, p1: $V/[$N]$E) -> E where IS_NUMERIC(E) { return length(p1 - p0) } -reflect :: proc(I, N: $T) -> (out: T) where IS_ARRAY(T), IS_FLOAT(ELEM_TYPE(T)) { +@(require_results) +reflect :: proc "contextless" (I, N: $T) -> (out: T) where IS_ARRAY(T), IS_FLOAT(ELEM_TYPE(T)) { b := N * (2 * dot(N, I)) return I - b } -refract :: proc(I, N: $T) -> (out: T) where IS_ARRAY(T), IS_FLOAT(ELEM_TYPE(T)) { - dv := dot(N, I) - k := 1 - eta*eta - (1 - dv*dv) +@(require_results) +refract :: proc "contextless" (I, Normal: $V/[$N]$E, eta: E) -> (out: V) where IS_ARRAY(V), IS_FLOAT(ELEM_TYPE(V)) { + dv := dot(Normal, I) + k := 1 - eta*eta * (1 - dv*dv) a := I * eta - b := N * eta*dv*math.sqrt(k) + b := Normal * (eta*dv+math.sqrt(k)) return (a - b) * E(int(k >= 0)) } -is_nan_single :: proc(x: $T) -> bool where IS_FLOAT(T) { +@(require_results) +is_nan_single :: proc "contextless" (x: $T) -> bool where IS_FLOAT(T) { return #force_inline math.is_nan(x) } -is_nan_array :: proc(x: $A/[$N]$T) -> (out: [N]bool) where IS_FLOAT(T) { +@(require_results) +is_nan_array :: proc "contextless" (x: $A/[$N]$T) -> (out: [N]bool) where IS_FLOAT(T) { for i in 0.. bool where IS_FLOAT(T) { +@(require_results) +is_inf_single :: proc "contextless" (x: $T) -> bool where IS_FLOAT(T) { return #force_inline math.is_inf(x) } -is_inf_array :: proc(x: $A/[$N]$T) -> (out: [N]bool) where IS_FLOAT(T) { +@(require_results) +is_inf_array :: proc "contextless" (x: $A/[$N]$T) -> (out: [N]bool) where IS_FLOAT(T) { for i in 0.. math.Float_Class where IS_FLOAT(T) { +@(require_results) +classify_single :: proc "contextless" (x: $T) -> math.Float_Class where IS_FLOAT(T) { return #force_inline math.classify(x) } -classify_array :: proc(x: $A/[$N]$T) -> (out: [N]math.Float_Class) where IS_FLOAT(T) { +@(require_results) +classify_array :: proc "contextless" (x: $A/[$N]$T) -> (out: [N]math.Float_Class) where IS_FLOAT(T) { for i in 0.. (out: bool) where !IS_ARRAY(T), IS_FLOAT(T) { return x < y } -less_than_equal_single :: proc(x, y: $T) -> (out: bool) where !IS_ARRAY(T), IS_FLOAT(T) { return x <= y } -greater_than_single :: proc(x, y: $T) -> (out: bool) where !IS_ARRAY(T), IS_FLOAT(T) { return x > y } -greater_than_equal_single :: proc(x, y: $T) -> (out: bool) where !IS_ARRAY(T), IS_FLOAT(T) { return x >= y } -equal_single :: proc(x, y: $T) -> (out: bool) where !IS_ARRAY(T), IS_FLOAT(T) { return x == y } -not_equal_single :: proc(x, y: $T) -> (out: bool) where !IS_ARRAY(T), IS_FLOAT(T) { return x != y } +@(require_results) less_than_single :: proc "contextless" (x, y: $T) -> (out: bool) where !IS_ARRAY(T), IS_FLOAT(T) { return x < y } +@(require_results) less_than_equal_single :: proc "contextless" (x, y: $T) -> (out: bool) where !IS_ARRAY(T), IS_FLOAT(T) { return x <= y } +@(require_results) greater_than_single :: proc "contextless" (x, y: $T) -> (out: bool) where !IS_ARRAY(T), IS_FLOAT(T) { return x > y } +@(require_results) greater_than_equal_single :: proc "contextless" (x, y: $T) -> (out: bool) where !IS_ARRAY(T), IS_FLOAT(T) { return x >= y } +@(require_results) equal_single :: proc "contextless" (x, y: $T) -> (out: bool) where !IS_ARRAY(T), IS_FLOAT(T) { return x == y } +@(require_results) not_equal_single :: proc "contextless" (x, y: $T) -> (out: bool) where !IS_ARRAY(T), IS_FLOAT(T) { return x != y } -less_than_array :: proc(x, y: $A/[$N]$T) -> (out: [N]bool) where IS_ARRAY(A), IS_FLOAT(ELEM_TYPE(A)) { +@(require_results) +less_than_array :: proc "contextless" (x, y: $A/[$N]$T) -> (out: [N]bool) where IS_ARRAY(A), IS_FLOAT(ELEM_TYPE(A)) { for i in 0.. (out: [N]bool) where IS_ARRAY(A), IS_FLOAT(ELEM_TYPE(A)) { +@(require_results) +less_than_equal_array :: proc "contextless" (x, y: $A/[$N]$T) -> (out: [N]bool) where IS_ARRAY(A), IS_FLOAT(ELEM_TYPE(A)) { for i in 0.. (out: [N]bool) where IS_ARRAY(A), IS_FLOAT(ELEM_TYPE(A)) { +@(require_results) +greater_than_array :: proc "contextless" (x, y: $A/[$N]$T) -> (out: [N]bool) where IS_ARRAY(A), IS_FLOAT(ELEM_TYPE(A)) { for i in 0.. y[i] } return } -greater_than_equal_array :: proc(x, y: $A/[$N]$T) -> (out: [N]bool) where IS_ARRAY(A), IS_FLOAT(ELEM_TYPE(A)) { +@(require_results) +greater_than_equal_array :: proc "contextless" (x, y: $A/[$N]$T) -> (out: [N]bool) where IS_ARRAY(A), IS_FLOAT(ELEM_TYPE(A)) { for i in 0..= y[i] } return } -equal_array :: proc(x, y: $A/[$N]$T) -> (out: [N]bool) where IS_ARRAY(A), IS_FLOAT(ELEM_TYPE(A)) { +@(require_results) +equal_array :: proc "contextless" (x, y: $A/[$N]$T) -> (out: [N]bool) where IS_ARRAY(A), IS_FLOAT(ELEM_TYPE(A)) { for i in 0.. (out: [N]bool) where IS_ARRAY(A), IS_FLOAT(ELEM_TYPE(A)) { +@(require_results) +not_equal_array :: proc "contextless" (x, y: $A/[$N]$T) -> (out: [N]bool) where IS_ARRAY(A), IS_FLOAT(ELEM_TYPE(A)) { for i in 0.. (out: bool) { +@(require_results) +any :: proc "contextless" (x: $A/[$N]bool) -> (out: bool) { for e in x { if e { return true @@ -537,7 +595,8 @@ any :: proc(x: $A/[$N]bool) -> (out: bool) { } return false } -all :: proc(x: $A/[$N]bool) -> (out: bool) { +@(require_results) +all :: proc "contextless" (x: $A/[$N]bool) -> (out: bool) { for e in x { if !e { return false @@ -545,7 +604,8 @@ all :: proc(x: $A/[$N]bool) -> (out: bool) { } return true } -not :: proc(x: $A/[$N]bool) -> (out: A) { +@(require_results) +not :: proc "contextless" (x: $A/[$N]bool) -> (out: A) { for e, i in x { out[i] = !e } diff --git a/core/math/linalg/general.odin b/core/math/linalg/general.odin index c11151b25..b58305c63 100644 --- a/core/math/linalg/general.odin +++ b/core/math/linalg/general.odin @@ -38,23 +38,28 @@ DEG_PER_RAD :: 360.0/TAU @private ELEM_TYPE :: intrinsics.type_elem_type -scalar_dot :: proc(a, b: $T) -> T where IS_FLOAT(T), !IS_ARRAY(T) { +@(require_results) +scalar_dot :: proc "contextless" (a, b: $T) -> T where IS_FLOAT(T), !IS_ARRAY(T) { return a * b } -vector_dot :: proc(a, b: $T/[$N]$E) -> (c: E) where IS_NUMERIC(E) #no_bounds_check { +@(require_results) +vector_dot :: proc "contextless" (a, b: $T/[$N]$E) -> (c: E) where IS_NUMERIC(E) #no_bounds_check { for i in 0.. (c: f16) { +@(require_results) +quaternion64_dot :: proc "contextless" (a, b: $T/quaternion64) -> (c: f16) { return a.w*a.w + a.x*b.x + a.y*b.y + a.z*b.z } -quaternion128_dot :: proc(a, b: $T/quaternion128) -> (c: f32) { +@(require_results) +quaternion128_dot :: proc "contextless" (a, b: $T/quaternion128) -> (c: f32) { return a.w*a.w + a.x*b.x + a.y*b.y + a.z*b.z } -quaternion256_dot :: proc(a, b: $T/quaternion256) -> (c: f64) { +@(require_results) +quaternion256_dot :: proc "contextless" (a, b: $T/quaternion256) -> (c: f64) { return a.w*a.w + a.x*b.x + a.y*b.y + a.z*b.z } @@ -63,27 +68,32 @@ dot :: proc{scalar_dot, vector_dot, quaternion64_dot, quaternion128_dot, quatern inner_product :: dot outer_product :: builtin.outer_product -quaternion_inverse :: proc(q: $Q) -> Q where IS_QUATERNION(Q) { +@(require_results) +quaternion_inverse :: proc "contextless" (q: $Q) -> Q where IS_QUATERNION(Q) { return conj(q) * quaternion(1.0/dot(q, q), 0, 0, 0) } -scalar_cross :: proc(a, b: $T) -> T where IS_FLOAT(T), !IS_ARRAY(T) { +@(require_results) +scalar_cross :: proc "contextless" (a, b: $T) -> T where IS_FLOAT(T), !IS_ARRAY(T) { return a * b } -vector_cross2 :: proc(a, b: $T/[2]$E) -> E where IS_NUMERIC(E) { +@(require_results) +vector_cross2 :: proc "contextless" (a, b: $T/[2]$E) -> E where IS_NUMERIC(E) { return a[0]*b[1] - b[0]*a[1] } -vector_cross3 :: proc(a, b: $T/[3]$E) -> (c: T) where IS_NUMERIC(E) { +@(require_results) +vector_cross3 :: proc "contextless" (a, b: $T/[3]$E) -> (c: T) where IS_NUMERIC(E) { c[0] = a[1]*b[2] - b[1]*a[2] c[1] = a[2]*b[0] - b[2]*a[0] c[2] = a[0]*b[1] - b[0]*a[1] return } -quaternion_cross :: proc(q1, q2: $Q) -> (q3: Q) where IS_QUATERNION(Q) { +@(require_results) +quaternion_cross :: proc "contextless" (q1, q2: $Q) -> (q3: Q) where IS_QUATERNION(Q) { q3.x = q1.w * q2.x + q1.x * q2.w + q1.y * q2.z - q1.z * q2.y q3.y = q1.w * q2.y + q1.y * q2.w + q1.z * q2.x - q1.x * q2.z q3.z = q1.w * q2.z + q1.z * q2.w + q1.x * q2.y - q1.y * q2.x @@ -94,49 +104,59 @@ quaternion_cross :: proc(q1, q2: $Q) -> (q3: Q) where IS_QUATERNION(Q) { vector_cross :: proc{scalar_cross, vector_cross2, vector_cross3} cross :: proc{scalar_cross, vector_cross2, vector_cross3, quaternion_cross} -vector_normalize :: proc(v: $T/[$N]$E) -> T where IS_FLOAT(E) { +@(require_results) +vector_normalize :: proc "contextless" (v: $T/[$N]$E) -> T where IS_FLOAT(E) { return v / length(v) } -quaternion_normalize :: proc(q: $Q) -> Q where IS_QUATERNION(Q) { +@(require_results) +quaternion_normalize :: proc "contextless" (q: $Q) -> Q where IS_QUATERNION(Q) { return q/abs(q) } normalize :: proc{vector_normalize, quaternion_normalize} -vector_normalize0 :: proc(v: $T/[$N]$E) -> T where IS_FLOAT(E) { +@(require_results) +vector_normalize0 :: proc "contextless" (v: $T/[$N]$E) -> T where IS_FLOAT(E) { m := length(v) return 0 if m == 0 else v/m } -quaternion_normalize0 :: proc(q: $Q) -> Q where IS_QUATERNION(Q) { +@(require_results) +quaternion_normalize0 :: proc "contextless" (q: $Q) -> Q where IS_QUATERNION(Q) { m := abs(q) return 0 if m == 0 else q/m } normalize0 :: proc{vector_normalize0, quaternion_normalize0} -vector_length :: proc(v: $T/[$N]$E) -> E where IS_FLOAT(E) { +@(require_results) +vector_length :: proc "contextless" (v: $T/[$N]$E) -> E where IS_FLOAT(E) { return math.sqrt(dot(v, v)) } -vector_length2 :: proc(v: $T/[$N]$E) -> E where IS_NUMERIC(E) { +@(require_results) +vector_length2 :: proc "contextless" (v: $T/[$N]$E) -> E where IS_NUMERIC(E) { return dot(v, v) } -quaternion_length :: proc(q: $Q) -> Q where IS_QUATERNION(Q) { +@(require_results) +quaternion_length :: proc "contextless" (q: $Q) -> Q where IS_QUATERNION(Q) { return abs(q) } -quaternion_length2 :: proc(q: $Q) -> Q where IS_QUATERNION(Q) { +@(require_results) +quaternion_length2 :: proc "contextless" (q: $Q) -> Q where IS_QUATERNION(Q) { return dot(q, q) } -scalar_triple_product :: proc(a, b, c: $T/[$N]$E) -> E where IS_NUMERIC(E) { +@(require_results) +scalar_triple_product :: proc "contextless" (a, b, c: $T/[$N]$E) -> E where IS_NUMERIC(E) { // a . (b x c) // b . (c x a) // c . (a x b) return dot(a, cross(b, c)) } -vector_triple_product :: proc(a, b, c: $T/[$N]$E) -> T where IS_NUMERIC(E) { +@(require_results) +vector_triple_product :: proc "contextless" (a, b, c: $T/[$N]$E) -> T where IS_NUMERIC(E) { // a x (b x c) // (a . c)b - (a . b)c return cross(a, cross(b, c)) @@ -146,11 +166,13 @@ vector_triple_product :: proc(a, b, c: $T/[$N]$E) -> T where IS_NUMERIC(E) { length :: proc{vector_length, quaternion_length} length2 :: proc{vector_length2, quaternion_length2} -projection :: proc(x, normal: $T/[$N]$E) -> T where IS_NUMERIC(E) { +@(require_results) +projection :: proc "contextless" (x, normal: $T/[$N]$E) -> T where IS_NUMERIC(E) { return dot(x, normal) / dot(normal, normal) * normal } -identity :: proc($T: typeid/[$N][N]$E) -> (m: T) #no_bounds_check { +@(require_results) +identity :: proc "contextless" ($T: typeid/[$N][N]$E) -> (m: T) #no_bounds_check { for i in 0.. (m: T) #no_bounds_check { trace :: builtin.matrix_trace transpose :: builtin.transpose -matrix_mul :: proc(a, b: $M/matrix[$N, N]$E) -> (c: M) +@(require_results) +matrix_mul :: proc "contextless" (a, b: $M/matrix[$N, N]$E) -> (c: M) where !IS_ARRAY(E), IS_NUMERIC(E) #no_bounds_check { return a * b } -matrix_comp_mul :: proc(a, b: $M/matrix[$I, $J]$E) -> (c: M) +@(require_results) +matrix_comp_mul :: proc "contextless" (a, b: $M/matrix[$I, $J]$E) -> (c: M) where !IS_ARRAY(E), IS_NUMERIC(E) #no_bounds_check { return hadamard_product(a, b) } -matrix_mul_differ :: proc(a: $A/matrix[$I, $J]$E, b: $B/matrix[J, $K]E) -> (c: matrix[I, K]E) +@(require_results) +matrix_mul_differ :: proc "contextless" (a: $A/matrix[$I, $J]$E, b: $B/matrix[J, $K]E) -> (c: matrix[I, K]E) where !IS_ARRAY(E), IS_NUMERIC(E), I != K #no_bounds_check { return a * b } -matrix_mul_vector :: proc(a: $A/matrix[$I, $J]$E, b: $B/[J]E) -> (c: B) +@(require_results) +matrix_mul_vector :: proc "contextless" (a: $A/matrix[$I, $J]$E, b: $B/[J]E) -> (c: B) where !IS_ARRAY(E), IS_NUMERIC(E) #no_bounds_check { return a * b } -quaternion_mul_quaternion :: proc(q1, q2: $Q) -> Q where IS_QUATERNION(Q) { +@(require_results) +quaternion_mul_quaternion :: proc "contextless" (q1, q2: $Q) -> Q where IS_QUATERNION(Q) { return q1 * q2 } -quaternion64_mul_vector3 :: proc(q: $Q/quaternion64, v: $V/[3]$F/f16) -> V { +@(require_results) +quaternion64_mul_vector3 :: proc "contextless" (q: $Q/quaternion64, v: $V/[3]$F/f16) -> V { Raw_Quaternion :: struct {xyz: [3]f16, r: f16} q := transmute(Raw_Quaternion)q @@ -194,7 +222,8 @@ quaternion64_mul_vector3 :: proc(q: $Q/quaternion64, v: $V/[3]$F/f16) -> V { t := cross(2*q.xyz, v) return V(v + q.r*t + cross(q.xyz, t)) } -quaternion128_mul_vector3 :: proc(q: $Q/quaternion128, v: $V/[3]$F/f32) -> V { +@(require_results) +quaternion128_mul_vector3 :: proc "contextless" (q: $Q/quaternion128, v: $V/[3]$F/f32) -> V { Raw_Quaternion :: struct {xyz: [3]f32, r: f32} q := transmute(Raw_Quaternion)q @@ -203,7 +232,8 @@ quaternion128_mul_vector3 :: proc(q: $Q/quaternion128, v: $V/[3]$F/f32) -> V { t := cross(2*q.xyz, v) return V(v + q.r*t + cross(q.xyz, t)) } -quaternion256_mul_vector3 :: proc(q: $Q/quaternion256, v: $V/[3]$F/f64) -> V { +@(require_results) +quaternion256_mul_vector3 :: proc "contextless" (q: $Q/quaternion256, v: $V/[3]$F/f64) -> V { Raw_Quaternion :: struct {xyz: [3]f64, r: f64} q := transmute(Raw_Quaternion)q @@ -224,10 +254,12 @@ mul :: proc{ quaternion_mul_quaternion, } -vector_to_ptr :: proc(v: ^$V/[$N]$E) -> ^E where IS_NUMERIC(E), N > 0 #no_bounds_check { +@(require_results) +vector_to_ptr :: proc "contextless" (v: ^$V/[$N]$E) -> ^E where IS_NUMERIC(E), N > 0 #no_bounds_check { return &v[0] } -matrix_to_ptr :: proc(m: ^$A/matrix[$I, $J]$E) -> ^E where IS_NUMERIC(E), I > 0, J > 0 #no_bounds_check { +@(require_results) +matrix_to_ptr :: proc "contextless" (m: ^$A/matrix[$I, $J]$E) -> ^E where IS_NUMERIC(E), I > 0, J > 0 #no_bounds_check { return &m[0, 0] } @@ -239,7 +271,8 @@ to_ptr :: proc{vector_to_ptr, matrix_to_ptr} // Splines -vector_slerp :: proc(x, y: $T/[$N]$E, a: E) -> T { +@(require_results) +vector_slerp :: proc "contextless" (x, y: $T/[$N]$E, a: E) -> T { cos_alpha := dot(x, y) alpha := math.acos(cos_alpha) sin_alpha := math.sin(alpha) @@ -250,7 +283,8 @@ vector_slerp :: proc(x, y: $T/[$N]$E, a: E) -> T { return x * t1 + y * t2 } -catmull_rom :: proc(v1, v2, v3, v4: $T/[$N]$E, s: E) -> T { +@(require_results) +catmull_rom :: proc "contextless" (v1, v2, v3, v4: $T/[$N]$E, s: E) -> T { s2 := s*s s3 := s2*s @@ -262,7 +296,8 @@ catmull_rom :: proc(v1, v2, v3, v4: $T/[$N]$E, s: E) -> T { return (f1 * v1 + f2 * v2 + f3 * v3 + f4 * v4) * 0.5 } -hermite :: proc(v1, t1, v2, t2: $T/[$N]$E, s: E) -> T { +@(require_results) +hermite :: proc "contextless" (v1, t1, v2, t2: $T/[$N]$E, s: E) -> T { s2 := s*s s3 := s2*s @@ -274,20 +309,23 @@ hermite :: proc(v1, t1, v2, t2: $T/[$N]$E, s: E) -> T { return f1 * v1 + f2 * v2 + f3 * t1 + f4 * t2 } -cubic :: proc(v1, v2, v3, v4: $T/[$N]$E, s: E) -> T { +@(require_results) +cubic :: proc "contextless" (v1, v2, v3, v4: $T/[$N]$E, s: E) -> T { return ((v1 * s + v2) * s + v3) * s + v4 } -array_cast :: proc(v: $A/[$N]$T, $Elem_Type: typeid) -> (w: [N]Elem_Type) #no_bounds_check { +@(require_results) +array_cast :: proc "contextless" (v: $A/[$N]$T, $Elem_Type: typeid) -> (w: [N]Elem_Type) #no_bounds_check { for i in 0.. (w: matrix[M, N]Elem_Type) #no_bounds_check { +@(require_results) +matrix_cast :: proc "contextless" (v: $A/matrix[$M, $N]$T, $Elem_Type: typeid) -> (w: matrix[M, N]Elem_Type) #no_bounds_check { for j in 0.. (w: matrix[M, return } -to_f32 :: #force_inline proc(v: $A/[$N]$T) -> [N]f32 { return array_cast(v, f32) } -to_f64 :: #force_inline proc(v: $A/[$N]$T) -> [N]f64 { return array_cast(v, f64) } +@(require_results) to_f32 :: #force_inline proc(v: $A/[$N]$T) -> [N]f32 { return array_cast(v, f32) } +@(require_results) to_f64 :: #force_inline proc(v: $A/[$N]$T) -> [N]f64 { return array_cast(v, f64) } -to_i8 :: #force_inline proc(v: $A/[$N]$T) -> [N]i8 { return array_cast(v, i8) } -to_i16 :: #force_inline proc(v: $A/[$N]$T) -> [N]i16 { return array_cast(v, i16) } -to_i32 :: #force_inline proc(v: $A/[$N]$T) -> [N]i32 { return array_cast(v, i32) } -to_i64 :: #force_inline proc(v: $A/[$N]$T) -> [N]i64 { return array_cast(v, i64) } -to_int :: #force_inline proc(v: $A/[$N]$T) -> [N]int { return array_cast(v, int) } +@(require_results) to_i8 :: #force_inline proc(v: $A/[$N]$T) -> [N]i8 { return array_cast(v, i8) } +@(require_results) to_i16 :: #force_inline proc(v: $A/[$N]$T) -> [N]i16 { return array_cast(v, i16) } +@(require_results) to_i32 :: #force_inline proc(v: $A/[$N]$T) -> [N]i32 { return array_cast(v, i32) } +@(require_results) to_i64 :: #force_inline proc(v: $A/[$N]$T) -> [N]i64 { return array_cast(v, i64) } +@(require_results) to_int :: #force_inline proc(v: $A/[$N]$T) -> [N]int { return array_cast(v, int) } -to_u8 :: #force_inline proc(v: $A/[$N]$T) -> [N]u8 { return array_cast(v, u8) } -to_u16 :: #force_inline proc(v: $A/[$N]$T) -> [N]u16 { return array_cast(v, u16) } -to_u32 :: #force_inline proc(v: $A/[$N]$T) -> [N]u32 { return array_cast(v, u32) } -to_u64 :: #force_inline proc(v: $A/[$N]$T) -> [N]u64 { return array_cast(v, u64) } -to_uint :: #force_inline proc(v: $A/[$N]$T) -> [N]uint { return array_cast(v, uint) } +@(require_results) to_u8 :: #force_inline proc(v: $A/[$N]$T) -> [N]u8 { return array_cast(v, u8) } +@(require_results) to_u16 :: #force_inline proc(v: $A/[$N]$T) -> [N]u16 { return array_cast(v, u16) } +@(require_results) to_u32 :: #force_inline proc(v: $A/[$N]$T) -> [N]u32 { return array_cast(v, u32) } +@(require_results) to_u64 :: #force_inline proc(v: $A/[$N]$T) -> [N]u64 { return array_cast(v, u64) } +@(require_results) to_uint :: #force_inline proc(v: $A/[$N]$T) -> [N]uint { return array_cast(v, uint) } -to_complex32 :: #force_inline proc(v: $A/[$N]$T) -> [N]complex32 { return array_cast(v, complex32) } -to_complex64 :: #force_inline proc(v: $A/[$N]$T) -> [N]complex64 { return array_cast(v, complex64) } -to_complex128 :: #force_inline proc(v: $A/[$N]$T) -> [N]complex128 { return array_cast(v, complex128) } -to_quaternion64 :: #force_inline proc(v: $A/[$N]$T) -> [N]quaternion64 { return array_cast(v, quaternion64) } -to_quaternion128 :: #force_inline proc(v: $A/[$N]$T) -> [N]quaternion128 { return array_cast(v, quaternion128) } -to_quaternion256 :: #force_inline proc(v: $A/[$N]$T) -> [N]quaternion256 { return array_cast(v, quaternion256) } +@(require_results) to_complex32 :: #force_inline proc(v: $A/[$N]$T) -> [N]complex32 { return array_cast(v, complex32) } +@(require_results) to_complex64 :: #force_inline proc(v: $A/[$N]$T) -> [N]complex64 { return array_cast(v, complex64) } +@(require_results) to_complex128 :: #force_inline proc(v: $A/[$N]$T) -> [N]complex128 { return array_cast(v, complex128) } +@(require_results) to_quaternion64 :: #force_inline proc(v: $A/[$N]$T) -> [N]quaternion64 { return array_cast(v, quaternion64) } +@(require_results) to_quaternion128 :: #force_inline proc(v: $A/[$N]$T) -> [N]quaternion128 { return array_cast(v, quaternion128) } +@(require_results) to_quaternion256 :: #force_inline proc(v: $A/[$N]$T) -> [N]quaternion256 { return array_cast(v, quaternion256) } diff --git a/core/math/linalg/glsl/linalg_glsl.odin b/core/math/linalg/glsl/linalg_glsl.odin index 74753f66f..0d91ad4a3 100644 --- a/core/math/linalg/glsl/linalg_glsl.odin +++ b/core/math/linalg/glsl/linalg_glsl.odin @@ -89,12 +89,12 @@ cos :: proc{ cos_dvec3, cos_dvec4, } -cos_vec2 :: proc "c" (x: vec2) -> vec2 { return {cos(x.x), cos(x.y)} } -cos_vec3 :: proc "c" (x: vec3) -> vec3 { return {cos(x.x), cos(x.y), cos(x.z)} } -cos_vec4 :: proc "c" (x: vec4) -> vec4 { return {cos(x.x), cos(x.y), cos(x.z), cos(x.w)} } -cos_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {cos(x.x), cos(x.y)} } -cos_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {cos(x.x), cos(x.y), cos(x.z)} } -cos_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {cos(x.x), cos(x.y), cos(x.z), cos(x.w)} } +@(require_results) cos_vec2 :: proc "c" (x: vec2) -> vec2 { return {cos(x.x), cos(x.y)} } +@(require_results) cos_vec3 :: proc "c" (x: vec3) -> vec3 { return {cos(x.x), cos(x.y), cos(x.z)} } +@(require_results) cos_vec4 :: proc "c" (x: vec4) -> vec4 { return {cos(x.x), cos(x.y), cos(x.z), cos(x.w)} } +@(require_results) cos_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {cos(x.x), cos(x.y)} } +@(require_results) cos_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {cos(x.x), cos(x.y), cos(x.z)} } +@(require_results) cos_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {cos(x.x), cos(x.y), cos(x.z), cos(x.w)} } sin :: proc{ sin_f32, @@ -106,12 +106,12 @@ sin :: proc{ sin_dvec3, sin_dvec4, } -sin_vec2 :: proc "c" (x: vec2) -> vec2 { return {sin(x.x), sin(x.y)} } -sin_vec3 :: proc "c" (x: vec3) -> vec3 { return {sin(x.x), sin(x.y), sin(x.z)} } -sin_vec4 :: proc "c" (x: vec4) -> vec4 { return {sin(x.x), sin(x.y), sin(x.z), sin(x.w)} } -sin_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {sin(x.x), sin(x.y)} } -sin_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {sin(x.x), sin(x.y), sin(x.z)} } -sin_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {sin(x.x), sin(x.y), sin(x.z), sin(x.w)} } +@(require_results) sin_vec2 :: proc "c" (x: vec2) -> vec2 { return {sin(x.x), sin(x.y)} } +@(require_results) sin_vec3 :: proc "c" (x: vec3) -> vec3 { return {sin(x.x), sin(x.y), sin(x.z)} } +@(require_results) sin_vec4 :: proc "c" (x: vec4) -> vec4 { return {sin(x.x), sin(x.y), sin(x.z), sin(x.w)} } +@(require_results) sin_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {sin(x.x), sin(x.y)} } +@(require_results) sin_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {sin(x.x), sin(x.y), sin(x.z)} } +@(require_results) sin_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {sin(x.x), sin(x.y), sin(x.z), sin(x.w)} } tan :: proc{ tan_f32, @@ -123,12 +123,12 @@ tan :: proc{ tan_dvec3, tan_dvec4, } -tan_vec2 :: proc "c" (x: vec2) -> vec2 { return {tan(x.x), tan(x.y)} } -tan_vec3 :: proc "c" (x: vec3) -> vec3 { return {tan(x.x), tan(x.y), tan(x.z)} } -tan_vec4 :: proc "c" (x: vec4) -> vec4 { return {tan(x.x), tan(x.y), tan(x.z), tan(x.w)} } -tan_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {tan(x.x), tan(x.y)} } -tan_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {tan(x.x), tan(x.y), tan(x.z)} } -tan_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {tan(x.x), tan(x.y), tan(x.z), tan(x.w)} } +@(require_results) tan_vec2 :: proc "c" (x: vec2) -> vec2 { return {tan(x.x), tan(x.y)} } +@(require_results) tan_vec3 :: proc "c" (x: vec3) -> vec3 { return {tan(x.x), tan(x.y), tan(x.z)} } +@(require_results) tan_vec4 :: proc "c" (x: vec4) -> vec4 { return {tan(x.x), tan(x.y), tan(x.z), tan(x.w)} } +@(require_results) tan_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {tan(x.x), tan(x.y)} } +@(require_results) tan_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {tan(x.x), tan(x.y), tan(x.z)} } +@(require_results) tan_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {tan(x.x), tan(x.y), tan(x.z), tan(x.w)} } acos :: proc{ acos_f32, @@ -140,12 +140,12 @@ acos :: proc{ acos_dvec3, acos_dvec4, } -acos_vec2 :: proc "c" (x: vec2) -> vec2 { return {acos(x.x), acos(x.y)} } -acos_vec3 :: proc "c" (x: vec3) -> vec3 { return {acos(x.x), acos(x.y), acos(x.z)} } -acos_vec4 :: proc "c" (x: vec4) -> vec4 { return {acos(x.x), acos(x.y), acos(x.z), acos(x.w)} } -acos_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {acos(x.x), acos(x.y)} } -acos_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {acos(x.x), acos(x.y), acos(x.z)} } -acos_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {acos(x.x), acos(x.y), acos(x.z), acos(x.w)} } +@(require_results) acos_vec2 :: proc "c" (x: vec2) -> vec2 { return {acos(x.x), acos(x.y)} } +@(require_results) acos_vec3 :: proc "c" (x: vec3) -> vec3 { return {acos(x.x), acos(x.y), acos(x.z)} } +@(require_results) acos_vec4 :: proc "c" (x: vec4) -> vec4 { return {acos(x.x), acos(x.y), acos(x.z), acos(x.w)} } +@(require_results) acos_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {acos(x.x), acos(x.y)} } +@(require_results) acos_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {acos(x.x), acos(x.y), acos(x.z)} } +@(require_results) acos_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {acos(x.x), acos(x.y), acos(x.z), acos(x.w)} } asin :: proc{ asin_f32, @@ -157,12 +157,12 @@ asin :: proc{ asin_dvec3, asin_dvec4, } -asin_vec2 :: proc "c" (x: vec2) -> vec2 { return {asin(x.x), asin(x.y)} } -asin_vec3 :: proc "c" (x: vec3) -> vec3 { return {asin(x.x), asin(x.y), asin(x.z)} } -asin_vec4 :: proc "c" (x: vec4) -> vec4 { return {asin(x.x), asin(x.y), asin(x.z), asin(x.w)} } -asin_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {asin(x.x), asin(x.y)} } -asin_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {asin(x.x), asin(x.y), asin(x.z)} } -asin_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {asin(x.x), asin(x.y), asin(x.z), asin(x.w)} } +@(require_results) asin_vec2 :: proc "c" (x: vec2) -> vec2 { return {asin(x.x), asin(x.y)} } +@(require_results) asin_vec3 :: proc "c" (x: vec3) -> vec3 { return {asin(x.x), asin(x.y), asin(x.z)} } +@(require_results) asin_vec4 :: proc "c" (x: vec4) -> vec4 { return {asin(x.x), asin(x.y), asin(x.z), asin(x.w)} } +@(require_results) asin_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {asin(x.x), asin(x.y)} } +@(require_results) asin_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {asin(x.x), asin(x.y), asin(x.z)} } +@(require_results) asin_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {asin(x.x), asin(x.y), asin(x.z), asin(x.w)} } atan :: proc{ atan_f32, @@ -182,12 +182,12 @@ atan :: proc{ atan2_dvec3, atan2_dvec4, } -atan_vec2 :: proc "c" (x: vec2) -> vec2 { return {atan(x.x), atan(x.y)} } -atan_vec3 :: proc "c" (x: vec3) -> vec3 { return {atan(x.x), atan(x.y), atan(x.z)} } -atan_vec4 :: proc "c" (x: vec4) -> vec4 { return {atan(x.x), atan(x.y), atan(x.z), atan(x.w)} } -atan_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {atan(x.x), atan(x.y)} } -atan_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {atan(x.x), atan(x.y), atan(x.z)} } -atan_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {atan(x.x), atan(x.y), atan(x.z), atan(x.w)} } +@(require_results) atan_vec2 :: proc "c" (x: vec2) -> vec2 { return {atan(x.x), atan(x.y)} } +@(require_results) atan_vec3 :: proc "c" (x: vec3) -> vec3 { return {atan(x.x), atan(x.y), atan(x.z)} } +@(require_results) atan_vec4 :: proc "c" (x: vec4) -> vec4 { return {atan(x.x), atan(x.y), atan(x.z), atan(x.w)} } +@(require_results) atan_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {atan(x.x), atan(x.y)} } +@(require_results) atan_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {atan(x.x), atan(x.y), atan(x.z)} } +@(require_results) atan_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {atan(x.x), atan(x.y), atan(x.z), atan(x.w)} } atan2 :: proc{ atan2_f32, @@ -199,12 +199,12 @@ atan2 :: proc{ atan2_dvec3, atan2_dvec4, } -atan2_vec2 :: proc "c" (y, x: vec2) -> vec2 { return {atan2(y.x, x.x), atan2(y.y, x.y)} } -atan2_vec3 :: proc "c" (y, x: vec3) -> vec3 { return {atan2(y.x, x.x), atan2(y.y, x.y), atan2(y.z, x.z)} } -atan2_vec4 :: proc "c" (y, x: vec4) -> vec4 { return {atan2(y.x, x.x), atan2(y.y, x.y), atan2(y.z, x.z), atan2(y.w, x.w)} } -atan2_dvec2 :: proc "c" (y, x: dvec2) -> dvec2 { return {atan2(y.x, x.x), atan2(y.y, x.y)} } -atan2_dvec3 :: proc "c" (y, x: dvec3) -> dvec3 { return {atan2(y.x, x.x), atan2(y.y, x.y), atan2(y.z, x.z)} } -atan2_dvec4 :: proc "c" (y, x: dvec4) -> dvec4 { return {atan2(y.x, x.x), atan2(y.y, x.y), atan2(y.z, x.z), atan2(y.w, x.w)} } +@(require_results) atan2_vec2 :: proc "c" (y, x: vec2) -> vec2 { return {atan2(y.x, x.x), atan2(y.y, x.y)} } +@(require_results) atan2_vec3 :: proc "c" (y, x: vec3) -> vec3 { return {atan2(y.x, x.x), atan2(y.y, x.y), atan2(y.z, x.z)} } +@(require_results) atan2_vec4 :: proc "c" (y, x: vec4) -> vec4 { return {atan2(y.x, x.x), atan2(y.y, x.y), atan2(y.z, x.z), atan2(y.w, x.w)} } +@(require_results) atan2_dvec2 :: proc "c" (y, x: dvec2) -> dvec2 { return {atan2(y.x, x.x), atan2(y.y, x.y)} } +@(require_results) atan2_dvec3 :: proc "c" (y, x: dvec3) -> dvec3 { return {atan2(y.x, x.x), atan2(y.y, x.y), atan2(y.z, x.z)} } +@(require_results) atan2_dvec4 :: proc "c" (y, x: dvec4) -> dvec4 { return {atan2(y.x, x.x), atan2(y.y, x.y), atan2(y.z, x.z), atan2(y.w, x.w)} } @@ -218,12 +218,12 @@ cosh :: proc{ cosh_dvec3, cosh_dvec4, } -cosh_vec2 :: proc "c" (x: vec2) -> vec2 { return {cosh(x.x), cosh(x.y)} } -cosh_vec3 :: proc "c" (x: vec3) -> vec3 { return {cosh(x.x), cosh(x.y), cosh(x.z)} } -cosh_vec4 :: proc "c" (x: vec4) -> vec4 { return {cosh(x.x), cosh(x.y), cosh(x.z), cosh(x.w)} } -cosh_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {cosh(x.x), cosh(x.y)} } -cosh_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {cosh(x.x), cosh(x.y), cosh(x.z)} } -cosh_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {cosh(x.x), cosh(x.y), cosh(x.z), cosh(x.w)} } +@(require_results) cosh_vec2 :: proc "c" (x: vec2) -> vec2 { return {cosh(x.x), cosh(x.y)} } +@(require_results) cosh_vec3 :: proc "c" (x: vec3) -> vec3 { return {cosh(x.x), cosh(x.y), cosh(x.z)} } +@(require_results) cosh_vec4 :: proc "c" (x: vec4) -> vec4 { return {cosh(x.x), cosh(x.y), cosh(x.z), cosh(x.w)} } +@(require_results) cosh_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {cosh(x.x), cosh(x.y)} } +@(require_results) cosh_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {cosh(x.x), cosh(x.y), cosh(x.z)} } +@(require_results) cosh_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {cosh(x.x), cosh(x.y), cosh(x.z), cosh(x.w)} } sinh :: proc{ @@ -236,12 +236,12 @@ sinh :: proc{ sinh_dvec3, sinh_dvec4, } -sinh_vec2 :: proc "c" (x: vec2) -> vec2 { return {sinh(x.x), sinh(x.y)} } -sinh_vec3 :: proc "c" (x: vec3) -> vec3 { return {sinh(x.x), sinh(x.y), sinh(x.z)} } -sinh_vec4 :: proc "c" (x: vec4) -> vec4 { return {sinh(x.x), sinh(x.y), sinh(x.z), sinh(x.w)} } -sinh_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {sinh(x.x), sinh(x.y)} } -sinh_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {sinh(x.x), sinh(x.y), sinh(x.z)} } -sinh_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {sinh(x.x), sinh(x.y), sinh(x.z), sinh(x.w)} } +@(require_results) sinh_vec2 :: proc "c" (x: vec2) -> vec2 { return {sinh(x.x), sinh(x.y)} } +@(require_results) sinh_vec3 :: proc "c" (x: vec3) -> vec3 { return {sinh(x.x), sinh(x.y), sinh(x.z)} } +@(require_results) sinh_vec4 :: proc "c" (x: vec4) -> vec4 { return {sinh(x.x), sinh(x.y), sinh(x.z), sinh(x.w)} } +@(require_results) sinh_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {sinh(x.x), sinh(x.y)} } +@(require_results) sinh_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {sinh(x.x), sinh(x.y), sinh(x.z)} } +@(require_results) sinh_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {sinh(x.x), sinh(x.y), sinh(x.z), sinh(x.w)} } tanh :: proc{ tanh_f32, @@ -253,12 +253,12 @@ tanh :: proc{ tanh_dvec3, tanh_dvec4, } -tanh_vec2 :: proc "c" (x: vec2) -> vec2 { return {tanh(x.x), tanh(x.y)} } -tanh_vec3 :: proc "c" (x: vec3) -> vec3 { return {tanh(x.x), tanh(x.y), tanh(x.z)} } -tanh_vec4 :: proc "c" (x: vec4) -> vec4 { return {tanh(x.x), tanh(x.y), tanh(x.z), tanh(x.w)} } -tanh_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {tanh(x.x), tanh(x.y)} } -tanh_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {tanh(x.x), tanh(x.y), tanh(x.z)} } -tanh_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {tanh(x.x), tanh(x.y), tanh(x.z), tanh(x.w)} } +@(require_results) tanh_vec2 :: proc "c" (x: vec2) -> vec2 { return {tanh(x.x), tanh(x.y)} } +@(require_results) tanh_vec3 :: proc "c" (x: vec3) -> vec3 { return {tanh(x.x), tanh(x.y), tanh(x.z)} } +@(require_results) tanh_vec4 :: proc "c" (x: vec4) -> vec4 { return {tanh(x.x), tanh(x.y), tanh(x.z), tanh(x.w)} } +@(require_results) tanh_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {tanh(x.x), tanh(x.y)} } +@(require_results) tanh_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {tanh(x.x), tanh(x.y), tanh(x.z)} } +@(require_results) tanh_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {tanh(x.x), tanh(x.y), tanh(x.z), tanh(x.w)} } acosh :: proc{ acosh_f32, @@ -270,12 +270,12 @@ acosh :: proc{ acosh_dvec3, acosh_dvec4, } -acosh_vec2 :: proc "c" (x: vec2) -> vec2 { return {acosh(x.x), acosh(x.y)} } -acosh_vec3 :: proc "c" (x: vec3) -> vec3 { return {acosh(x.x), acosh(x.y), acosh(x.z)} } -acosh_vec4 :: proc "c" (x: vec4) -> vec4 { return {acosh(x.x), acosh(x.y), acosh(x.z), acosh(x.w)} } -acosh_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {acosh(x.x), acosh(x.y)} } -acosh_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {acosh(x.x), acosh(x.y), acosh(x.z)} } -acosh_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {acosh(x.x), acosh(x.y), acosh(x.z), acosh(x.w)} } +@(require_results) acosh_vec2 :: proc "c" (x: vec2) -> vec2 { return {acosh(x.x), acosh(x.y)} } +@(require_results) acosh_vec3 :: proc "c" (x: vec3) -> vec3 { return {acosh(x.x), acosh(x.y), acosh(x.z)} } +@(require_results) acosh_vec4 :: proc "c" (x: vec4) -> vec4 { return {acosh(x.x), acosh(x.y), acosh(x.z), acosh(x.w)} } +@(require_results) acosh_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {acosh(x.x), acosh(x.y)} } +@(require_results) acosh_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {acosh(x.x), acosh(x.y), acosh(x.z)} } +@(require_results) acosh_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {acosh(x.x), acosh(x.y), acosh(x.z), acosh(x.w)} } asinh :: proc{ asinh_f32, @@ -287,12 +287,12 @@ asinh :: proc{ asinh_dvec3, asinh_dvec4, } -asinh_vec2 :: proc "c" (x: vec2) -> vec2 { return {asinh(x.x), asinh(x.y)} } -asinh_vec3 :: proc "c" (x: vec3) -> vec3 { return {asinh(x.x), asinh(x.y), asinh(x.z)} } -asinh_vec4 :: proc "c" (x: vec4) -> vec4 { return {asinh(x.x), asinh(x.y), asinh(x.z), asinh(x.w)} } -asinh_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {asinh(x.x), asinh(x.y)} } -asinh_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {asinh(x.x), asinh(x.y), asinh(x.z)} } -asinh_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {asinh(x.x), asinh(x.y), asinh(x.z), asinh(x.w)} } +@(require_results) asinh_vec2 :: proc "c" (x: vec2) -> vec2 { return {asinh(x.x), asinh(x.y)} } +@(require_results) asinh_vec3 :: proc "c" (x: vec3) -> vec3 { return {asinh(x.x), asinh(x.y), asinh(x.z)} } +@(require_results) asinh_vec4 :: proc "c" (x: vec4) -> vec4 { return {asinh(x.x), asinh(x.y), asinh(x.z), asinh(x.w)} } +@(require_results) asinh_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {asinh(x.x), asinh(x.y)} } +@(require_results) asinh_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {asinh(x.x), asinh(x.y), asinh(x.z)} } +@(require_results) asinh_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {asinh(x.x), asinh(x.y), asinh(x.z), asinh(x.w)} } atanh :: proc{ atanh_f32, @@ -304,12 +304,12 @@ atanh :: proc{ atanh_dvec3, atanh_dvec4, } -atanh_vec2 :: proc "c" (x: vec2) -> vec2 { return {atanh(x.x), atanh(x.y)} } -atanh_vec3 :: proc "c" (x: vec3) -> vec3 { return {atanh(x.x), atanh(x.y), atanh(x.z)} } -atanh_vec4 :: proc "c" (x: vec4) -> vec4 { return {atanh(x.x), atanh(x.y), atanh(x.z), atanh(x.w)} } -atanh_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {atanh(x.x), atanh(x.y)} } -atanh_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {atanh(x.x), atanh(x.y), atanh(x.z)} } -atanh_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {atanh(x.x), atanh(x.y), atanh(x.z), atanh(x.w)} } +@(require_results) atanh_vec2 :: proc "c" (x: vec2) -> vec2 { return {atanh(x.x), atanh(x.y)} } +@(require_results) atanh_vec3 :: proc "c" (x: vec3) -> vec3 { return {atanh(x.x), atanh(x.y), atanh(x.z)} } +@(require_results) atanh_vec4 :: proc "c" (x: vec4) -> vec4 { return {atanh(x.x), atanh(x.y), atanh(x.z), atanh(x.w)} } +@(require_results) atanh_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {atanh(x.x), atanh(x.y)} } +@(require_results) atanh_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {atanh(x.x), atanh(x.y), atanh(x.z)} } +@(require_results) atanh_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {atanh(x.x), atanh(x.y), atanh(x.z), atanh(x.w)} } sqrt :: proc{ sqrt_f32, @@ -321,12 +321,12 @@ sqrt :: proc{ sqrt_dvec3, sqrt_dvec4, } -sqrt_vec2 :: proc "c" (x: vec2) -> vec2 { return {sqrt(x.x), sqrt(x.y)} } -sqrt_vec3 :: proc "c" (x: vec3) -> vec3 { return {sqrt(x.x), sqrt(x.y), sqrt(x.z)} } -sqrt_vec4 :: proc "c" (x: vec4) -> vec4 { return {sqrt(x.x), sqrt(x.y), sqrt(x.z), sqrt(x.w)} } -sqrt_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {sqrt(x.x), sqrt(x.y)} } -sqrt_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {sqrt(x.x), sqrt(x.y), sqrt(x.z)} } -sqrt_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {sqrt(x.x), sqrt(x.y), sqrt(x.z), sqrt(x.w)} } +@(require_results) sqrt_vec2 :: proc "c" (x: vec2) -> vec2 { return {sqrt(x.x), sqrt(x.y)} } +@(require_results) sqrt_vec3 :: proc "c" (x: vec3) -> vec3 { return {sqrt(x.x), sqrt(x.y), sqrt(x.z)} } +@(require_results) sqrt_vec4 :: proc "c" (x: vec4) -> vec4 { return {sqrt(x.x), sqrt(x.y), sqrt(x.z), sqrt(x.w)} } +@(require_results) sqrt_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {sqrt(x.x), sqrt(x.y)} } +@(require_results) sqrt_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {sqrt(x.x), sqrt(x.y), sqrt(x.z)} } +@(require_results) sqrt_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {sqrt(x.x), sqrt(x.y), sqrt(x.z), sqrt(x.w)} } rsqrt :: inversesqrt inversesqrt :: proc{ @@ -339,12 +339,12 @@ inversesqrt :: proc{ inversesqrt_dvec3, inversesqrt_dvec4, } -inversesqrt_vec2 :: proc "c" (x: vec2) -> vec2 { return {inversesqrt(x.x), inversesqrt(x.y)} } -inversesqrt_vec3 :: proc "c" (x: vec3) -> vec3 { return {inversesqrt(x.x), inversesqrt(x.y), inversesqrt(x.z)} } -inversesqrt_vec4 :: proc "c" (x: vec4) -> vec4 { return {inversesqrt(x.x), inversesqrt(x.y), inversesqrt(x.z), inversesqrt(x.w)} } -inversesqrt_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {inversesqrt(x.x), inversesqrt(x.y)} } -inversesqrt_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {inversesqrt(x.x), inversesqrt(x.y), inversesqrt(x.z)} } -inversesqrt_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {inversesqrt(x.x), inversesqrt(x.y), inversesqrt(x.z), inversesqrt(x.w)} } +@(require_results) inversesqrt_vec2 :: proc "c" (x: vec2) -> vec2 { return {inversesqrt(x.x), inversesqrt(x.y)} } +@(require_results) inversesqrt_vec3 :: proc "c" (x: vec3) -> vec3 { return {inversesqrt(x.x), inversesqrt(x.y), inversesqrt(x.z)} } +@(require_results) inversesqrt_vec4 :: proc "c" (x: vec4) -> vec4 { return {inversesqrt(x.x), inversesqrt(x.y), inversesqrt(x.z), inversesqrt(x.w)} } +@(require_results) inversesqrt_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {inversesqrt(x.x), inversesqrt(x.y)} } +@(require_results) inversesqrt_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {inversesqrt(x.x), inversesqrt(x.y), inversesqrt(x.z)} } +@(require_results) inversesqrt_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {inversesqrt(x.x), inversesqrt(x.y), inversesqrt(x.z), inversesqrt(x.w)} } pow :: proc{ @@ -357,12 +357,12 @@ pow :: proc{ pow_dvec3, pow_dvec4, } -pow_vec2 :: proc "c" (x, y: vec2) -> vec2 { return {pow(x.x, y.x), pow(x.y, y.y)} } -pow_vec3 :: proc "c" (x, y: vec3) -> vec3 { return {pow(x.x, y.x), pow(x.y, y.y), pow(x.z, y.z)} } -pow_vec4 :: proc "c" (x, y: vec4) -> vec4 { return {pow(x.x, y.x), pow(x.y, y.y), pow(x.z, y.z), pow(x.w, y.w)} } -pow_dvec2 :: proc "c" (x, y: dvec2) -> dvec2 { return {pow(x.x, y.x), pow(x.y, y.y)} } -pow_dvec3 :: proc "c" (x, y: dvec3) -> dvec3 { return {pow(x.x, y.x), pow(x.y, y.y), pow(x.z, y.z)} } -pow_dvec4 :: proc "c" (x, y: dvec4) -> dvec4 { return {pow(x.x, y.x), pow(x.y, y.y), pow(x.z, y.z), pow(x.w, y.w)} } +@(require_results) pow_vec2 :: proc "c" (x, y: vec2) -> vec2 { return {pow(x.x, y.x), pow(x.y, y.y)} } +@(require_results) pow_vec3 :: proc "c" (x, y: vec3) -> vec3 { return {pow(x.x, y.x), pow(x.y, y.y), pow(x.z, y.z)} } +@(require_results) pow_vec4 :: proc "c" (x, y: vec4) -> vec4 { return {pow(x.x, y.x), pow(x.y, y.y), pow(x.z, y.z), pow(x.w, y.w)} } +@(require_results) pow_dvec2 :: proc "c" (x, y: dvec2) -> dvec2 { return {pow(x.x, y.x), pow(x.y, y.y)} } +@(require_results) pow_dvec3 :: proc "c" (x, y: dvec3) -> dvec3 { return {pow(x.x, y.x), pow(x.y, y.y), pow(x.z, y.z)} } +@(require_results) pow_dvec4 :: proc "c" (x, y: dvec4) -> dvec4 { return {pow(x.x, y.x), pow(x.y, y.y), pow(x.z, y.z), pow(x.w, y.w)} } @@ -376,12 +376,12 @@ exp :: proc{ exp_dvec3, exp_dvec4, } -exp_vec2 :: proc "c" (x: vec2) -> vec2 { return {exp(x.x), exp(x.y)} } -exp_vec3 :: proc "c" (x: vec3) -> vec3 { return {exp(x.x), exp(x.y), exp(x.z)} } -exp_vec4 :: proc "c" (x: vec4) -> vec4 { return {exp(x.x), exp(x.y), exp(x.z), exp(x.w)} } -exp_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {exp(x.x), exp(x.y)} } -exp_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {exp(x.x), exp(x.y), exp(x.z)} } -exp_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {exp(x.x), exp(x.y), exp(x.z), exp(x.w)} } +@(require_results) exp_vec2 :: proc "c" (x: vec2) -> vec2 { return {exp(x.x), exp(x.y)} } +@(require_results) exp_vec3 :: proc "c" (x: vec3) -> vec3 { return {exp(x.x), exp(x.y), exp(x.z)} } +@(require_results) exp_vec4 :: proc "c" (x: vec4) -> vec4 { return {exp(x.x), exp(x.y), exp(x.z), exp(x.w)} } +@(require_results) exp_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {exp(x.x), exp(x.y)} } +@(require_results) exp_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {exp(x.x), exp(x.y), exp(x.z)} } +@(require_results) exp_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {exp(x.x), exp(x.y), exp(x.z), exp(x.w)} } @@ -395,12 +395,12 @@ log :: proc{ log_dvec3, log_dvec4, } -log_vec2 :: proc "c" (x: vec2) -> vec2 { return {log(x.x), log(x.y)} } -log_vec3 :: proc "c" (x: vec3) -> vec3 { return {log(x.x), log(x.y), log(x.z)} } -log_vec4 :: proc "c" (x: vec4) -> vec4 { return {log(x.x), log(x.y), log(x.z), log(x.w)} } -log_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {log(x.x), log(x.y)} } -log_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {log(x.x), log(x.y), log(x.z)} } -log_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {log(x.x), log(x.y), log(x.z), log(x.w)} } +@(require_results) log_vec2 :: proc "c" (x: vec2) -> vec2 { return {log(x.x), log(x.y)} } +@(require_results) log_vec3 :: proc "c" (x: vec3) -> vec3 { return {log(x.x), log(x.y), log(x.z)} } +@(require_results) log_vec4 :: proc "c" (x: vec4) -> vec4 { return {log(x.x), log(x.y), log(x.z), log(x.w)} } +@(require_results) log_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {log(x.x), log(x.y)} } +@(require_results) log_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {log(x.x), log(x.y), log(x.z)} } +@(require_results) log_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {log(x.x), log(x.y), log(x.z), log(x.w)} } @@ -414,12 +414,12 @@ exp2 :: proc{ exp2_dvec3, exp2_dvec4, } -exp2_vec2 :: proc "c" (x: vec2) -> vec2 { return {exp2(x.x), exp2(x.y)} } -exp2_vec3 :: proc "c" (x: vec3) -> vec3 { return {exp2(x.x), exp2(x.y), exp2(x.z)} } -exp2_vec4 :: proc "c" (x: vec4) -> vec4 { return {exp2(x.x), exp2(x.y), exp2(x.z), exp2(x.w)} } -exp2_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {exp2(x.x), exp2(x.y)} } -exp2_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {exp2(x.x), exp2(x.y), exp2(x.z)} } -exp2_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {exp2(x.x), exp2(x.y), exp2(x.z), exp2(x.w)} } +@(require_results) exp2_vec2 :: proc "c" (x: vec2) -> vec2 { return {exp2(x.x), exp2(x.y)} } +@(require_results) exp2_vec3 :: proc "c" (x: vec3) -> vec3 { return {exp2(x.x), exp2(x.y), exp2(x.z)} } +@(require_results) exp2_vec4 :: proc "c" (x: vec4) -> vec4 { return {exp2(x.x), exp2(x.y), exp2(x.z), exp2(x.w)} } +@(require_results) exp2_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {exp2(x.x), exp2(x.y)} } +@(require_results) exp2_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {exp2(x.x), exp2(x.y), exp2(x.z)} } +@(require_results) exp2_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {exp2(x.x), exp2(x.y), exp2(x.z), exp2(x.w)} } sign :: proc{ @@ -440,20 +440,20 @@ sign :: proc{ sign_uvec3, sign_uvec4, } -sign_i32 :: proc "c" (x: i32) -> i32 { return -1 if x < 0 else +1 if x > 0 else 0 } -sign_u32 :: proc "c" (x: u32) -> u32 { return +1 if x > 0 else 0 } -sign_vec2 :: proc "c" (x: vec2) -> vec2 { return {sign(x.x), sign(x.y)} } -sign_vec3 :: proc "c" (x: vec3) -> vec3 { return {sign(x.x), sign(x.y), sign(x.z)} } -sign_vec4 :: proc "c" (x: vec4) -> vec4 { return {sign(x.x), sign(x.y), sign(x.z), sign(x.w)} } -sign_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {sign(x.x), sign(x.y)} } -sign_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {sign(x.x), sign(x.y), sign(x.z)} } -sign_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {sign(x.x), sign(x.y), sign(x.z), sign(x.w)} } -sign_ivec2 :: proc "c" (x: ivec2) -> ivec2 { return {sign(x.x), sign(x.y)} } -sign_ivec3 :: proc "c" (x: ivec3) -> ivec3 { return {sign(x.x), sign(x.y), sign(x.z)} } -sign_ivec4 :: proc "c" (x: ivec4) -> ivec4 { return {sign(x.x), sign(x.y), sign(x.z), sign(x.w)} } -sign_uvec2 :: proc "c" (x: uvec2) -> uvec2 { return {sign(x.x), sign(x.y)} } -sign_uvec3 :: proc "c" (x: uvec3) -> uvec3 { return {sign(x.x), sign(x.y), sign(x.z)} } -sign_uvec4 :: proc "c" (x: uvec4) -> uvec4 { return {sign(x.x), sign(x.y), sign(x.z), sign(x.w)} } +@(require_results) sign_i32 :: proc "c" (x: i32) -> i32 { return -1 if x < 0 else +1 if x > 0 else 0 } +@(require_results) sign_u32 :: proc "c" (x: u32) -> u32 { return +1 if x > 0 else 0 } +@(require_results) sign_vec2 :: proc "c" (x: vec2) -> vec2 { return {sign(x.x), sign(x.y)} } +@(require_results) sign_vec3 :: proc "c" (x: vec3) -> vec3 { return {sign(x.x), sign(x.y), sign(x.z)} } +@(require_results) sign_vec4 :: proc "c" (x: vec4) -> vec4 { return {sign(x.x), sign(x.y), sign(x.z), sign(x.w)} } +@(require_results) sign_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {sign(x.x), sign(x.y)} } +@(require_results) sign_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {sign(x.x), sign(x.y), sign(x.z)} } +@(require_results) sign_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {sign(x.x), sign(x.y), sign(x.z), sign(x.w)} } +@(require_results) sign_ivec2 :: proc "c" (x: ivec2) -> ivec2 { return {sign(x.x), sign(x.y)} } +@(require_results) sign_ivec3 :: proc "c" (x: ivec3) -> ivec3 { return {sign(x.x), sign(x.y), sign(x.z)} } +@(require_results) sign_ivec4 :: proc "c" (x: ivec4) -> ivec4 { return {sign(x.x), sign(x.y), sign(x.z), sign(x.w)} } +@(require_results) sign_uvec2 :: proc "c" (x: uvec2) -> uvec2 { return {sign(x.x), sign(x.y)} } +@(require_results) sign_uvec3 :: proc "c" (x: uvec3) -> uvec3 { return {sign(x.x), sign(x.y), sign(x.z)} } +@(require_results) sign_uvec4 :: proc "c" (x: uvec4) -> uvec4 { return {sign(x.x), sign(x.y), sign(x.z), sign(x.w)} } floor :: proc{ floor_f32, @@ -465,12 +465,12 @@ floor :: proc{ floor_dvec3, floor_dvec4, } -floor_vec2 :: proc "c" (x: vec2) -> vec2 { return {floor(x.x), floor(x.y)} } -floor_vec3 :: proc "c" (x: vec3) -> vec3 { return {floor(x.x), floor(x.y), floor(x.z)} } -floor_vec4 :: proc "c" (x: vec4) -> vec4 { return {floor(x.x), floor(x.y), floor(x.z), floor(x.w)} } -floor_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {floor(x.x), floor(x.y)} } -floor_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {floor(x.x), floor(x.y), floor(x.z)} } -floor_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {floor(x.x), floor(x.y), floor(x.z), floor(x.w)} } +@(require_results) floor_vec2 :: proc "c" (x: vec2) -> vec2 { return {floor(x.x), floor(x.y)} } +@(require_results) floor_vec3 :: proc "c" (x: vec3) -> vec3 { return {floor(x.x), floor(x.y), floor(x.z)} } +@(require_results) floor_vec4 :: proc "c" (x: vec4) -> vec4 { return {floor(x.x), floor(x.y), floor(x.z), floor(x.w)} } +@(require_results) floor_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {floor(x.x), floor(x.y)} } +@(require_results) floor_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {floor(x.x), floor(x.y), floor(x.z)} } +@(require_results) floor_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {floor(x.x), floor(x.y), floor(x.z), floor(x.w)} } @@ -484,12 +484,12 @@ round :: proc{ round_dvec3, round_dvec4, } -round_vec2 :: proc "c" (x: vec2) -> vec2 { return {round(x.x), round(x.y)} } -round_vec3 :: proc "c" (x: vec3) -> vec3 { return {round(x.x), round(x.y), round(x.z)} } -round_vec4 :: proc "c" (x: vec4) -> vec4 { return {round(x.x), round(x.y), round(x.z), round(x.w)} } -round_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {round(x.x), round(x.y)} } -round_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {round(x.x), round(x.y), round(x.z)} } -round_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {round(x.x), round(x.y), round(x.z), round(x.w)} } +@(require_results) round_vec2 :: proc "c" (x: vec2) -> vec2 { return {round(x.x), round(x.y)} } +@(require_results) round_vec3 :: proc "c" (x: vec3) -> vec3 { return {round(x.x), round(x.y), round(x.z)} } +@(require_results) round_vec4 :: proc "c" (x: vec4) -> vec4 { return {round(x.x), round(x.y), round(x.z), round(x.w)} } +@(require_results) round_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {round(x.x), round(x.y)} } +@(require_results) round_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {round(x.x), round(x.y), round(x.z)} } +@(require_results) round_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {round(x.x), round(x.y), round(x.z), round(x.w)} } ceil :: proc{ @@ -502,12 +502,12 @@ ceil :: proc{ ceil_dvec3, ceil_dvec4, } -ceil_vec2 :: proc "c" (x: vec2) -> vec2 { return {ceil(x.x), ceil(x.y)} } -ceil_vec3 :: proc "c" (x: vec3) -> vec3 { return {ceil(x.x), ceil(x.y), ceil(x.z)} } -ceil_vec4 :: proc "c" (x: vec4) -> vec4 { return {ceil(x.x), ceil(x.y), ceil(x.z), ceil(x.w)} } -ceil_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {ceil(x.x), ceil(x.y)} } -ceil_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {ceil(x.x), ceil(x.y), ceil(x.z)} } -ceil_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {ceil(x.x), ceil(x.y), ceil(x.z), ceil(x.w)} } +@(require_results) ceil_vec2 :: proc "c" (x: vec2) -> vec2 { return {ceil(x.x), ceil(x.y)} } +@(require_results) ceil_vec3 :: proc "c" (x: vec3) -> vec3 { return {ceil(x.x), ceil(x.y), ceil(x.z)} } +@(require_results) ceil_vec4 :: proc "c" (x: vec4) -> vec4 { return {ceil(x.x), ceil(x.y), ceil(x.z), ceil(x.w)} } +@(require_results) ceil_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {ceil(x.x), ceil(x.y)} } +@(require_results) ceil_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {ceil(x.x), ceil(x.y), ceil(x.z)} } +@(require_results) ceil_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {ceil(x.x), ceil(x.y), ceil(x.z), ceil(x.w)} } mod :: proc{ @@ -520,12 +520,12 @@ mod :: proc{ mod_dvec3, mod_dvec4, } -mod_vec2 :: proc "c" (x, y: vec2) -> vec2 { return {mod(x.x, y.x), mod(x.y, y.y)} } -mod_vec3 :: proc "c" (x, y: vec3) -> vec3 { return {mod(x.x, y.x), mod(x.y, y.y), mod(x.z, y.z)} } -mod_vec4 :: proc "c" (x, y: vec4) -> vec4 { return {mod(x.x, y.x), mod(x.y, y.y), mod(x.z, y.z), mod(x.w, y.w)} } -mod_dvec2 :: proc "c" (x, y: dvec2) -> dvec2 { return {mod(x.x, y.x), mod(x.y, y.y)} } -mod_dvec3 :: proc "c" (x, y: dvec3) -> dvec3 { return {mod(x.x, y.x), mod(x.y, y.y), mod(x.z, y.z)} } -mod_dvec4 :: proc "c" (x, y: dvec4) -> dvec4 { return {mod(x.x, y.x), mod(x.y, y.y), mod(x.z, y.z), mod(x.w, y.w)} } +@(require_results) mod_vec2 :: proc "c" (x, y: vec2) -> vec2 { return {mod(x.x, y.x), mod(x.y, y.y)} } +@(require_results) mod_vec3 :: proc "c" (x, y: vec3) -> vec3 { return {mod(x.x, y.x), mod(x.y, y.y), mod(x.z, y.z)} } +@(require_results) mod_vec4 :: proc "c" (x, y: vec4) -> vec4 { return {mod(x.x, y.x), mod(x.y, y.y), mod(x.z, y.z), mod(x.w, y.w)} } +@(require_results) mod_dvec2 :: proc "c" (x, y: dvec2) -> dvec2 { return {mod(x.x, y.x), mod(x.y, y.y)} } +@(require_results) mod_dvec3 :: proc "c" (x, y: dvec3) -> dvec3 { return {mod(x.x, y.x), mod(x.y, y.y), mod(x.z, y.z)} } +@(require_results) mod_dvec4 :: proc "c" (x, y: dvec4) -> dvec4 { return {mod(x.x, y.x), mod(x.y, y.y), mod(x.z, y.z), mod(x.w, y.w)} } fract :: proc{ @@ -538,12 +538,12 @@ fract :: proc{ fract_dvec3, fract_dvec4, } -fract_vec2 :: proc "c" (x: vec2) -> vec2 { return {fract(x.x), fract(x.y)} } -fract_vec3 :: proc "c" (x: vec3) -> vec3 { return {fract(x.x), fract(x.y), fract(x.z)} } -fract_vec4 :: proc "c" (x: vec4) -> vec4 { return {fract(x.x), fract(x.y), fract(x.z), fract(x.w)} } -fract_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {fract(x.x), fract(x.y)} } -fract_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {fract(x.x), fract(x.y), fract(x.z)} } -fract_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {fract(x.x), fract(x.y), fract(x.z), fract(x.w)} } +@(require_results) fract_vec2 :: proc "c" (x: vec2) -> vec2 { return {fract(x.x), fract(x.y)} } +@(require_results) fract_vec3 :: proc "c" (x: vec3) -> vec3 { return {fract(x.x), fract(x.y), fract(x.z)} } +@(require_results) fract_vec4 :: proc "c" (x: vec4) -> vec4 { return {fract(x.x), fract(x.y), fract(x.z), fract(x.w)} } +@(require_results) fract_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {fract(x.x), fract(x.y)} } +@(require_results) fract_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {fract(x.x), fract(x.y), fract(x.z)} } +@(require_results) fract_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {fract(x.x), fract(x.y), fract(x.z), fract(x.w)} } @@ -557,14 +557,14 @@ radians :: proc{ radians_dvec3, radians_dvec4, } -radians_f32 :: proc "c" (degrees: f32) -> f32 { return degrees * TAU / 360.0 } -radians_f64 :: proc "c" (degrees: f64) -> f64 { return degrees * TAU / 360.0 } -radians_vec2 :: proc "c" (degrees: vec2) -> vec2 { return degrees * TAU / 360.0 } -radians_vec3 :: proc "c" (degrees: vec3) -> vec3 { return degrees * TAU / 360.0 } -radians_vec4 :: proc "c" (degrees: vec4) -> vec4 { return degrees * TAU / 360.0 } -radians_dvec2 :: proc "c" (degrees: dvec2) -> dvec2 { return degrees * TAU / 360.0 } -radians_dvec3 :: proc "c" (degrees: dvec3) -> dvec3 { return degrees * TAU / 360.0 } -radians_dvec4 :: proc "c" (degrees: dvec4) -> dvec4 { return degrees * TAU / 360.0 } +@(require_results) radians_f32 :: proc "c" (degrees: f32) -> f32 { return degrees * TAU / 360.0 } +@(require_results) radians_f64 :: proc "c" (degrees: f64) -> f64 { return degrees * TAU / 360.0 } +@(require_results) radians_vec2 :: proc "c" (degrees: vec2) -> vec2 { return degrees * TAU / 360.0 } +@(require_results) radians_vec3 :: proc "c" (degrees: vec3) -> vec3 { return degrees * TAU / 360.0 } +@(require_results) radians_vec4 :: proc "c" (degrees: vec4) -> vec4 { return degrees * TAU / 360.0 } +@(require_results) radians_dvec2 :: proc "c" (degrees: dvec2) -> dvec2 { return degrees * TAU / 360.0 } +@(require_results) radians_dvec3 :: proc "c" (degrees: dvec3) -> dvec3 { return degrees * TAU / 360.0 } +@(require_results) radians_dvec4 :: proc "c" (degrees: dvec4) -> dvec4 { return degrees * TAU / 360.0 } degrees :: proc{ @@ -577,14 +577,14 @@ degrees :: proc{ degrees_dvec3, degrees_dvec4, } -degrees_f32 :: proc "c" (radians: f32) -> f32 { return radians * 360.0 / TAU } -degrees_f64 :: proc "c" (radians: f64) -> f64 { return radians * 360.0 / TAU } -degrees_vec2 :: proc "c" (radians: vec2) -> vec2 { return radians * 360.0 / TAU } -degrees_vec3 :: proc "c" (radians: vec3) -> vec3 { return radians * 360.0 / TAU } -degrees_vec4 :: proc "c" (radians: vec4) -> vec4 { return radians * 360.0 / TAU } -degrees_dvec2 :: proc "c" (radians: dvec2) -> dvec2 { return radians * 360.0 / TAU } -degrees_dvec3 :: proc "c" (radians: dvec3) -> dvec3 { return radians * 360.0 / TAU } -degrees_dvec4 :: proc "c" (radians: dvec4) -> dvec4 { return radians * 360.0 / TAU } +@(require_results) degrees_f32 :: proc "c" (radians: f32) -> f32 { return radians * 360.0 / TAU } +@(require_results) degrees_f64 :: proc "c" (radians: f64) -> f64 { return radians * 360.0 / TAU } +@(require_results) degrees_vec2 :: proc "c" (radians: vec2) -> vec2 { return radians * 360.0 / TAU } +@(require_results) degrees_vec3 :: proc "c" (radians: vec3) -> vec3 { return radians * 360.0 / TAU } +@(require_results) degrees_vec4 :: proc "c" (radians: vec4) -> vec4 { return radians * 360.0 / TAU } +@(require_results) degrees_dvec2 :: proc "c" (radians: dvec2) -> dvec2 { return radians * 360.0 / TAU } +@(require_results) degrees_dvec3 :: proc "c" (radians: dvec3) -> dvec3 { return radians * 360.0 / TAU } +@(require_results) degrees_dvec4 :: proc "c" (radians: dvec4) -> dvec4 { return radians * 360.0 / TAU } min :: proc{ min_i32, @@ -604,22 +604,22 @@ min :: proc{ min_uvec3, min_uvec4, } -min_i32 :: proc "c" (x, y: i32) -> i32 { return builtin.min(x, y) } -min_u32 :: proc "c" (x, y: u32) -> u32 { return builtin.min(x, y) } -min_f32 :: proc "c" (x, y: f32) -> f32 { return builtin.min(x, y) } -min_f64 :: proc "c" (x, y: f64) -> f64 { return builtin.min(x, y) } -min_vec2 :: proc "c" (x, y: vec2) -> vec2 { return {min(x.x, y.x), min(x.y, y.y)} } -min_vec3 :: proc "c" (x, y: vec3) -> vec3 { return {min(x.x, y.x), min(x.y, y.y), min(x.z, y.z)} } -min_vec4 :: proc "c" (x, y: vec4) -> vec4 { return {min(x.x, y.x), min(x.y, y.y), min(x.z, y.z), min(x.w, y.w)} } -min_dvec2 :: proc "c" (x, y: dvec2) -> dvec2 { return {min(x.x, y.x), min(x.y, y.y)} } -min_dvec3 :: proc "c" (x, y: dvec3) -> dvec3 { return {min(x.x, y.x), min(x.y, y.y), min(x.z, y.z)} } -min_dvec4 :: proc "c" (x, y: dvec4) -> dvec4 { return {min(x.x, y.x), min(x.y, y.y), min(x.z, y.z), min(x.w, y.w)} } -min_ivec2 :: proc "c" (x, y: ivec2) -> ivec2 { return {min(x.x, y.x), min(x.y, y.y)} } -min_ivec3 :: proc "c" (x, y: ivec3) -> ivec3 { return {min(x.x, y.x), min(x.y, y.y), min(x.z, y.z)} } -min_ivec4 :: proc "c" (x, y: ivec4) -> ivec4 { return {min(x.x, y.x), min(x.y, y.y), min(x.z, y.z), min(x.w, y.w)} } -min_uvec2 :: proc "c" (x, y: uvec2) -> uvec2 { return {min(x.x, y.x), min(x.y, y.y)} } -min_uvec3 :: proc "c" (x, y: uvec3) -> uvec3 { return {min(x.x, y.x), min(x.y, y.y), min(x.z, y.z)} } -min_uvec4 :: proc "c" (x, y: uvec4) -> uvec4 { return {min(x.x, y.x), min(x.y, y.y), min(x.z, y.z), min(x.w, y.w)} } +@(require_results) min_i32 :: proc "c" (x, y: i32) -> i32 { return builtin.min(x, y) } +@(require_results) min_u32 :: proc "c" (x, y: u32) -> u32 { return builtin.min(x, y) } +@(require_results) min_f32 :: proc "c" (x, y: f32) -> f32 { return builtin.min(x, y) } +@(require_results) min_f64 :: proc "c" (x, y: f64) -> f64 { return builtin.min(x, y) } +@(require_results) min_vec2 :: proc "c" (x, y: vec2) -> vec2 { return {min(x.x, y.x), min(x.y, y.y)} } +@(require_results) min_vec3 :: proc "c" (x, y: vec3) -> vec3 { return {min(x.x, y.x), min(x.y, y.y), min(x.z, y.z)} } +@(require_results) min_vec4 :: proc "c" (x, y: vec4) -> vec4 { return {min(x.x, y.x), min(x.y, y.y), min(x.z, y.z), min(x.w, y.w)} } +@(require_results) min_dvec2 :: proc "c" (x, y: dvec2) -> dvec2 { return {min(x.x, y.x), min(x.y, y.y)} } +@(require_results) min_dvec3 :: proc "c" (x, y: dvec3) -> dvec3 { return {min(x.x, y.x), min(x.y, y.y), min(x.z, y.z)} } +@(require_results) min_dvec4 :: proc "c" (x, y: dvec4) -> dvec4 { return {min(x.x, y.x), min(x.y, y.y), min(x.z, y.z), min(x.w, y.w)} } +@(require_results) min_ivec2 :: proc "c" (x, y: ivec2) -> ivec2 { return {min(x.x, y.x), min(x.y, y.y)} } +@(require_results) min_ivec3 :: proc "c" (x, y: ivec3) -> ivec3 { return {min(x.x, y.x), min(x.y, y.y), min(x.z, y.z)} } +@(require_results) min_ivec4 :: proc "c" (x, y: ivec4) -> ivec4 { return {min(x.x, y.x), min(x.y, y.y), min(x.z, y.z), min(x.w, y.w)} } +@(require_results) min_uvec2 :: proc "c" (x, y: uvec2) -> uvec2 { return {min(x.x, y.x), min(x.y, y.y)} } +@(require_results) min_uvec3 :: proc "c" (x, y: uvec3) -> uvec3 { return {min(x.x, y.x), min(x.y, y.y), min(x.z, y.z)} } +@(require_results) min_uvec4 :: proc "c" (x, y: uvec4) -> uvec4 { return {min(x.x, y.x), min(x.y, y.y), min(x.z, y.z), min(x.w, y.w)} } max :: proc{ @@ -640,22 +640,22 @@ max :: proc{ max_uvec3, max_uvec4, } -max_i32 :: proc "c" (x, y: i32) -> i32 { return builtin.max(x, y) } -max_u32 :: proc "c" (x, y: u32) -> u32 { return builtin.max(x, y) } -max_f32 :: proc "c" (x, y: f32) -> f32 { return builtin.max(x, y) } -max_f64 :: proc "c" (x, y: f64) -> f64 { return builtin.max(x, y) } -max_vec2 :: proc "c" (x, y: vec2) -> vec2 { return {max(x.x, y.x), max(x.y, y.y)} } -max_vec3 :: proc "c" (x, y: vec3) -> vec3 { return {max(x.x, y.x), max(x.y, y.y), max(x.z, y.z)} } -max_vec4 :: proc "c" (x, y: vec4) -> vec4 { return {max(x.x, y.x), max(x.y, y.y), max(x.z, y.z), max(x.w, y.w)} } -max_dvec2 :: proc "c" (x, y: dvec2) -> dvec2 { return {max(x.x, y.x), max(x.y, y.y)} } -max_dvec3 :: proc "c" (x, y: dvec3) -> dvec3 { return {max(x.x, y.x), max(x.y, y.y), max(x.z, y.z)} } -max_dvec4 :: proc "c" (x, y: dvec4) -> dvec4 { return {max(x.x, y.x), max(x.y, y.y), max(x.z, y.z), max(x.w, y.w)} } -max_ivec2 :: proc "c" (x, y: ivec2) -> ivec2 { return {max(x.x, y.x), max(x.y, y.y)} } -max_ivec3 :: proc "c" (x, y: ivec3) -> ivec3 { return {max(x.x, y.x), max(x.y, y.y), max(x.z, y.z)} } -max_ivec4 :: proc "c" (x, y: ivec4) -> ivec4 { return {max(x.x, y.x), max(x.y, y.y), max(x.z, y.z), max(x.w, y.w)} } -max_uvec2 :: proc "c" (x, y: uvec2) -> uvec2 { return {max(x.x, y.x), max(x.y, y.y)} } -max_uvec3 :: proc "c" (x, y: uvec3) -> uvec3 { return {max(x.x, y.x), max(x.y, y.y), max(x.z, y.z)} } -max_uvec4 :: proc "c" (x, y: uvec4) -> uvec4 { return {max(x.x, y.x), max(x.y, y.y), max(x.z, y.z), max(x.w, y.w)} } +@(require_results) max_i32 :: proc "c" (x, y: i32) -> i32 { return builtin.max(x, y) } +@(require_results) max_u32 :: proc "c" (x, y: u32) -> u32 { return builtin.max(x, y) } +@(require_results) max_f32 :: proc "c" (x, y: f32) -> f32 { return builtin.max(x, y) } +@(require_results) max_f64 :: proc "c" (x, y: f64) -> f64 { return builtin.max(x, y) } +@(require_results) max_vec2 :: proc "c" (x, y: vec2) -> vec2 { return {max(x.x, y.x), max(x.y, y.y)} } +@(require_results) max_vec3 :: proc "c" (x, y: vec3) -> vec3 { return {max(x.x, y.x), max(x.y, y.y), max(x.z, y.z)} } +@(require_results) max_vec4 :: proc "c" (x, y: vec4) -> vec4 { return {max(x.x, y.x), max(x.y, y.y), max(x.z, y.z), max(x.w, y.w)} } +@(require_results) max_dvec2 :: proc "c" (x, y: dvec2) -> dvec2 { return {max(x.x, y.x), max(x.y, y.y)} } +@(require_results) max_dvec3 :: proc "c" (x, y: dvec3) -> dvec3 { return {max(x.x, y.x), max(x.y, y.y), max(x.z, y.z)} } +@(require_results) max_dvec4 :: proc "c" (x, y: dvec4) -> dvec4 { return {max(x.x, y.x), max(x.y, y.y), max(x.z, y.z), max(x.w, y.w)} } +@(require_results) max_ivec2 :: proc "c" (x, y: ivec2) -> ivec2 { return {max(x.x, y.x), max(x.y, y.y)} } +@(require_results) max_ivec3 :: proc "c" (x, y: ivec3) -> ivec3 { return {max(x.x, y.x), max(x.y, y.y), max(x.z, y.z)} } +@(require_results) max_ivec4 :: proc "c" (x, y: ivec4) -> ivec4 { return {max(x.x, y.x), max(x.y, y.y), max(x.z, y.z), max(x.w, y.w)} } +@(require_results) max_uvec2 :: proc "c" (x, y: uvec2) -> uvec2 { return {max(x.x, y.x), max(x.y, y.y)} } +@(require_results) max_uvec3 :: proc "c" (x, y: uvec3) -> uvec3 { return {max(x.x, y.x), max(x.y, y.y), max(x.z, y.z)} } +@(require_results) max_uvec4 :: proc "c" (x, y: uvec4) -> uvec4 { return {max(x.x, y.x), max(x.y, y.y), max(x.z, y.z), max(x.w, y.w)} } @@ -677,22 +677,22 @@ clamp :: proc{ clamp_uvec3, clamp_uvec4, } -clamp_i32 :: proc "c" (x, y, z: i32) -> i32 { return builtin.clamp(x, y, z) } -clamp_u32 :: proc "c" (x, y, z: u32) -> u32 { return builtin.clamp(x, y, z) } -clamp_f32 :: proc "c" (x, y, z: f32) -> f32 { return builtin.clamp(x, y, z) } -clamp_f64 :: proc "c" (x, y, z: f64) -> f64 { return builtin.clamp(x, y, z) } -clamp_vec2 :: proc "c" (x, y, z: vec2) -> vec2 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y)} } -clamp_vec3 :: proc "c" (x, y, z: vec3) -> vec3 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y), clamp(x.z, y.z, z.z)} } -clamp_vec4 :: proc "c" (x, y, z: vec4) -> vec4 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y), clamp(x.z, y.z, z.z), clamp(x.w, y.w, z.w)} } -clamp_dvec2 :: proc "c" (x, y, z: dvec2) -> dvec2 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y)} } -clamp_dvec3 :: proc "c" (x, y, z: dvec3) -> dvec3 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y), clamp(x.z, y.z, z.z)} } -clamp_dvec4 :: proc "c" (x, y, z: dvec4) -> dvec4 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y), clamp(x.z, y.z, z.z), clamp(x.w, y.w, z.w)} } -clamp_ivec2 :: proc "c" (x, y, z: ivec2) -> ivec2 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y)} } -clamp_ivec3 :: proc "c" (x, y, z: ivec3) -> ivec3 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y), clamp(x.z, y.z, z.z)} } -clamp_ivec4 :: proc "c" (x, y, z: ivec4) -> ivec4 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y), clamp(x.z, y.z, z.z), clamp(x.w, y.w, z.w)} } -clamp_uvec2 :: proc "c" (x, y, z: uvec2) -> uvec2 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y)} } -clamp_uvec3 :: proc "c" (x, y, z: uvec3) -> uvec3 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y), clamp(x.z, y.z, z.z)} } -clamp_uvec4 :: proc "c" (x, y, z: uvec4) -> uvec4 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y), clamp(x.z, y.z, z.z), clamp(x.w, y.w, z.w)} } +@(require_results) clamp_i32 :: proc "c" (x, y, z: i32) -> i32 { return builtin.clamp(x, y, z) } +@(require_results) clamp_u32 :: proc "c" (x, y, z: u32) -> u32 { return builtin.clamp(x, y, z) } +@(require_results) clamp_f32 :: proc "c" (x, y, z: f32) -> f32 { return builtin.clamp(x, y, z) } +@(require_results) clamp_f64 :: proc "c" (x, y, z: f64) -> f64 { return builtin.clamp(x, y, z) } +@(require_results) clamp_vec2 :: proc "c" (x, y, z: vec2) -> vec2 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y)} } +@(require_results) clamp_vec3 :: proc "c" (x, y, z: vec3) -> vec3 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y), clamp(x.z, y.z, z.z)} } +@(require_results) clamp_vec4 :: proc "c" (x, y, z: vec4) -> vec4 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y), clamp(x.z, y.z, z.z), clamp(x.w, y.w, z.w)} } +@(require_results) clamp_dvec2 :: proc "c" (x, y, z: dvec2) -> dvec2 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y)} } +@(require_results) clamp_dvec3 :: proc "c" (x, y, z: dvec3) -> dvec3 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y), clamp(x.z, y.z, z.z)} } +@(require_results) clamp_dvec4 :: proc "c" (x, y, z: dvec4) -> dvec4 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y), clamp(x.z, y.z, z.z), clamp(x.w, y.w, z.w)} } +@(require_results) clamp_ivec2 :: proc "c" (x, y, z: ivec2) -> ivec2 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y)} } +@(require_results) clamp_ivec3 :: proc "c" (x, y, z: ivec3) -> ivec3 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y), clamp(x.z, y.z, z.z)} } +@(require_results) clamp_ivec4 :: proc "c" (x, y, z: ivec4) -> ivec4 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y), clamp(x.z, y.z, z.z), clamp(x.w, y.w, z.w)} } +@(require_results) clamp_uvec2 :: proc "c" (x, y, z: uvec2) -> uvec2 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y)} } +@(require_results) clamp_uvec3 :: proc "c" (x, y, z: uvec3) -> uvec3 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y), clamp(x.z, y.z, z.z)} } +@(require_results) clamp_uvec4 :: proc "c" (x, y, z: uvec4) -> uvec4 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y), clamp(x.z, y.z, z.z), clamp(x.w, y.w, z.w)} } saturate :: proc{ saturate_i32, @@ -712,22 +712,22 @@ saturate :: proc{ saturate_uvec3, saturate_uvec4, } -saturate_i32 :: proc "c" (v: i32) -> i32 { return builtin.clamp(v, 0, 1) } -saturate_u32 :: proc "c" (v: u32) -> u32 { return builtin.clamp(v, 0, 1) } -saturate_f32 :: proc "c" (v: f32) -> f32 { return builtin.clamp(v, 0, 1) } -saturate_f64 :: proc "c" (v: f64) -> f64 { return builtin.clamp(v, 0, 1) } -saturate_vec2 :: proc "c" (v: vec2) -> vec2 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1)} } -saturate_vec3 :: proc "c" (v: vec3) -> vec3 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1), builtin.clamp(v.z, 0, 1)} } -saturate_vec4 :: proc "c" (v: vec4) -> vec4 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1), builtin.clamp(v.z, 0, 1), builtin.clamp(v.w, 0, 1)} } -saturate_dvec2 :: proc "c" (v: dvec2) -> dvec2 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1)} } -saturate_dvec3 :: proc "c" (v: dvec3) -> dvec3 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1), builtin.clamp(v.z, 0, 1)} } -saturate_dvec4 :: proc "c" (v: dvec4) -> dvec4 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1), builtin.clamp(v.z, 0, 1), builtin.clamp(v.w, 0, 1)} } -saturate_ivec2 :: proc "c" (v: ivec2) -> ivec2 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1)} } -saturate_ivec3 :: proc "c" (v: ivec3) -> ivec3 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1), builtin.clamp(v.z, 0, 1)} } -saturate_ivec4 :: proc "c" (v: ivec4) -> ivec4 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1), builtin.clamp(v.z, 0, 1), builtin.clamp(v.w, 0, 1)} } -saturate_uvec2 :: proc "c" (v: uvec2) -> uvec2 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1)} } -saturate_uvec3 :: proc "c" (v: uvec3) -> uvec3 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1), builtin.clamp(v.z, 0, 1)} } -saturate_uvec4 :: proc "c" (v: uvec4) -> uvec4 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1), builtin.clamp(v.z, 0, 1), builtin.clamp(v.w, 0, 1)} } +@(require_results) saturate_i32 :: proc "c" (v: i32) -> i32 { return builtin.clamp(v, 0, 1) } +@(require_results) saturate_u32 :: proc "c" (v: u32) -> u32 { return builtin.clamp(v, 0, 1) } +@(require_results) saturate_f32 :: proc "c" (v: f32) -> f32 { return builtin.clamp(v, 0, 1) } +@(require_results) saturate_f64 :: proc "c" (v: f64) -> f64 { return builtin.clamp(v, 0, 1) } +@(require_results) saturate_vec2 :: proc "c" (v: vec2) -> vec2 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1)} } +@(require_results) saturate_vec3 :: proc "c" (v: vec3) -> vec3 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1), builtin.clamp(v.z, 0, 1)} } +@(require_results) saturate_vec4 :: proc "c" (v: vec4) -> vec4 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1), builtin.clamp(v.z, 0, 1), builtin.clamp(v.w, 0, 1)} } +@(require_results) saturate_dvec2 :: proc "c" (v: dvec2) -> dvec2 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1)} } +@(require_results) saturate_dvec3 :: proc "c" (v: dvec3) -> dvec3 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1), builtin.clamp(v.z, 0, 1)} } +@(require_results) saturate_dvec4 :: proc "c" (v: dvec4) -> dvec4 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1), builtin.clamp(v.z, 0, 1), builtin.clamp(v.w, 0, 1)} } +@(require_results) saturate_ivec2 :: proc "c" (v: ivec2) -> ivec2 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1)} } +@(require_results) saturate_ivec3 :: proc "c" (v: ivec3) -> ivec3 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1), builtin.clamp(v.z, 0, 1)} } +@(require_results) saturate_ivec4 :: proc "c" (v: ivec4) -> ivec4 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1), builtin.clamp(v.z, 0, 1), builtin.clamp(v.w, 0, 1)} } +@(require_results) saturate_uvec2 :: proc "c" (v: uvec2) -> uvec2 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1)} } +@(require_results) saturate_uvec3 :: proc "c" (v: uvec3) -> uvec3 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1), builtin.clamp(v.z, 0, 1)} } +@(require_results) saturate_uvec4 :: proc "c" (v: uvec4) -> uvec4 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1), builtin.clamp(v.z, 0, 1), builtin.clamp(v.w, 0, 1)} } mix :: proc{ mix_f32, @@ -739,14 +739,14 @@ mix :: proc{ mix_dvec3, mix_dvec4, } -mix_f32 :: proc "c" (x, y, t: f32) -> f32 { return x*(1-t) + y*t } -mix_f64 :: proc "c" (x, y, t: f64) -> f64 { return x*(1-t) + y*t } -mix_vec2 :: proc "c" (x, y, t: vec2) -> vec2 { return {mix(x.x, y.x, t.x), mix(x.y, y.y, t.y)} } -mix_vec3 :: proc "c" (x, y, t: vec3) -> vec3 { return {mix(x.x, y.x, t.x), mix(x.y, y.y, t.y), mix(x.z, y.z, t.z)} } -mix_vec4 :: proc "c" (x, y, t: vec4) -> vec4 { return {mix(x.x, y.x, t.x), mix(x.y, y.y, y.y), mix(x.z, y.z, t.z), mix(x.w, y.w, t.w)} } -mix_dvec2 :: proc "c" (x, y, t: dvec2) -> dvec2 { return {mix(x.x, y.x, t.x), mix(x.y, y.y, t.y)} } -mix_dvec3 :: proc "c" (x, y, t: dvec3) -> dvec3 { return {mix(x.x, y.x, t.x), mix(x.y, y.y, t.y), mix(x.z, y.z, t.z)} } -mix_dvec4 :: proc "c" (x, y, t: dvec4) -> dvec4 { return {mix(x.x, y.x, t.x), mix(x.y, y.y, y.y), mix(x.z, y.z, t.z), mix(x.w, y.w, t.w)} } +@(require_results) mix_f32 :: proc "c" (x, y, t: f32) -> f32 { return x*(1-t) + y*t } +@(require_results) mix_f64 :: proc "c" (x, y, t: f64) -> f64 { return x*(1-t) + y*t } +@(require_results) mix_vec2 :: proc "c" (x, y, t: vec2) -> vec2 { return {mix(x.x, y.x, t.x), mix(x.y, y.y, t.y)} } +@(require_results) mix_vec3 :: proc "c" (x, y, t: vec3) -> vec3 { return {mix(x.x, y.x, t.x), mix(x.y, y.y, t.y), mix(x.z, y.z, t.z)} } +@(require_results) mix_vec4 :: proc "c" (x, y, t: vec4) -> vec4 { return {mix(x.x, y.x, t.x), mix(x.y, y.y, y.y), mix(x.z, y.z, t.z), mix(x.w, y.w, t.w)} } +@(require_results) mix_dvec2 :: proc "c" (x, y, t: dvec2) -> dvec2 { return {mix(x.x, y.x, t.x), mix(x.y, y.y, t.y)} } +@(require_results) mix_dvec3 :: proc "c" (x, y, t: dvec3) -> dvec3 { return {mix(x.x, y.x, t.x), mix(x.y, y.y, t.y), mix(x.z, y.z, t.z)} } +@(require_results) mix_dvec4 :: proc "c" (x, y, t: dvec4) -> dvec4 { return {mix(x.x, y.x, t.x), mix(x.y, y.y, y.y), mix(x.z, y.z, t.z), mix(x.w, y.w, t.w)} } lerp :: proc{ lerp_f32, @@ -758,14 +758,14 @@ lerp :: proc{ lerp_dvec3, lerp_dvec4, } -lerp_f32 :: proc "c" (x, y, t: f32) -> f32 { return x*(1-t) + y*t } -lerp_f64 :: proc "c" (x, y, t: f64) -> f64 { return x*(1-t) + y*t } -lerp_vec2 :: proc "c" (x, y, t: vec2) -> vec2 { return {lerp(x.x, y.x, t.x), lerp(x.y, y.y, t.y)} } -lerp_vec3 :: proc "c" (x, y, t: vec3) -> vec3 { return {lerp(x.x, y.x, t.x), lerp(x.y, y.y, t.y), lerp(x.z, y.z, t.z)} } -lerp_vec4 :: proc "c" (x, y, t: vec4) -> vec4 { return {lerp(x.x, y.x, t.x), lerp(x.y, y.y, y.y), lerp(x.z, y.z, t.z), lerp(x.w, y.w, t.w)} } -lerp_dvec2 :: proc "c" (x, y, t: dvec2) -> dvec2 { return {lerp(x.x, y.x, t.x), lerp(x.y, y.y, t.y)} } -lerp_dvec3 :: proc "c" (x, y, t: dvec3) -> dvec3 { return {lerp(x.x, y.x, t.x), lerp(x.y, y.y, t.y), lerp(x.z, y.z, t.z)} } -lerp_dvec4 :: proc "c" (x, y, t: dvec4) -> dvec4 { return {lerp(x.x, y.x, t.x), lerp(x.y, y.y, y.y), lerp(x.z, y.z, t.z), lerp(x.w, y.w, t.w)} } +@(require_results) lerp_f32 :: proc "c" (x, y, t: f32) -> f32 { return x*(1-t) + y*t } +@(require_results) lerp_f64 :: proc "c" (x, y, t: f64) -> f64 { return x*(1-t) + y*t } +@(require_results) lerp_vec2 :: proc "c" (x, y, t: vec2) -> vec2 { return {lerp(x.x, y.x, t.x), lerp(x.y, y.y, t.y)} } +@(require_results) lerp_vec3 :: proc "c" (x, y, t: vec3) -> vec3 { return {lerp(x.x, y.x, t.x), lerp(x.y, y.y, t.y), lerp(x.z, y.z, t.z)} } +@(require_results) lerp_vec4 :: proc "c" (x, y, t: vec4) -> vec4 { return {lerp(x.x, y.x, t.x), lerp(x.y, y.y, t.y), lerp(x.z, y.z, t.z), lerp(x.w, y.w, t.w)} } +@(require_results) lerp_dvec2 :: proc "c" (x, y, t: dvec2) -> dvec2 { return {lerp(x.x, y.x, t.x), lerp(x.y, y.y, t.y)} } +@(require_results) lerp_dvec3 :: proc "c" (x, y, t: dvec3) -> dvec3 { return {lerp(x.x, y.x, t.x), lerp(x.y, y.y, t.y), lerp(x.z, y.z, t.z)} } +@(require_results) lerp_dvec4 :: proc "c" (x, y, t: dvec4) -> dvec4 { return {lerp(x.x, y.x, t.x), lerp(x.y, y.y, t.y), lerp(x.z, y.z, t.z), lerp(x.w, y.w, t.w)} } step :: proc{ @@ -778,14 +778,14 @@ step :: proc{ step_dvec3, step_dvec4, } -step_f32 :: proc "c" (edge, x: f32) -> f32 { return 0 if x < edge else 1 } -step_f64 :: proc "c" (edge, x: f64) -> f64 { return 0 if x < edge else 1 } -step_vec2 :: proc "c" (edge, x: vec2) -> vec2 { return {step(edge.x, x.x), step(edge.y, x.y)} } -step_vec3 :: proc "c" (edge, x: vec3) -> vec3 { return {step(edge.x, x.x), step(edge.y, x.y), step(edge.z, x.z)} } -step_vec4 :: proc "c" (edge, x: vec4) -> vec4 { return {step(edge.x, x.x), step(edge.y, x.y), step(edge.z, x.z), step(edge.w, x.w)} } -step_dvec2 :: proc "c" (edge, x: dvec2) -> dvec2 { return {step(edge.x, x.x), step(edge.y, x.y)} } -step_dvec3 :: proc "c" (edge, x: dvec3) -> dvec3 { return {step(edge.x, x.x), step(edge.y, x.y), step(edge.z, x.z)} } -step_dvec4 :: proc "c" (edge, x: dvec4) -> dvec4 { return {step(edge.x, x.x), step(edge.y, x.y), step(edge.z, x.z), step(edge.w, x.w)} } +@(require_results) step_f32 :: proc "c" (edge, x: f32) -> f32 { return 0 if x < edge else 1 } +@(require_results) step_f64 :: proc "c" (edge, x: f64) -> f64 { return 0 if x < edge else 1 } +@(require_results) step_vec2 :: proc "c" (edge, x: vec2) -> vec2 { return {step(edge.x, x.x), step(edge.y, x.y)} } +@(require_results) step_vec3 :: proc "c" (edge, x: vec3) -> vec3 { return {step(edge.x, x.x), step(edge.y, x.y), step(edge.z, x.z)} } +@(require_results) step_vec4 :: proc "c" (edge, x: vec4) -> vec4 { return {step(edge.x, x.x), step(edge.y, x.y), step(edge.z, x.z), step(edge.w, x.w)} } +@(require_results) step_dvec2 :: proc "c" (edge, x: dvec2) -> dvec2 { return {step(edge.x, x.x), step(edge.y, x.y)} } +@(require_results) step_dvec3 :: proc "c" (edge, x: dvec3) -> dvec3 { return {step(edge.x, x.x), step(edge.y, x.y), step(edge.z, x.z)} } +@(require_results) step_dvec4 :: proc "c" (edge, x: dvec4) -> dvec4 { return {step(edge.x, x.x), step(edge.y, x.y), step(edge.z, x.z), step(edge.w, x.w)} } smoothstep :: proc{ smoothstep_f32, @@ -797,20 +797,20 @@ smoothstep :: proc{ smoothstep_dvec3, smoothstep_dvec4, } -smoothstep_f32 :: proc "c" (edge0, edge1, x: f32) -> f32 { +@(require_results) smoothstep_f32 :: proc "c" (edge0, edge1, x: f32) -> f32 { y := clamp(((x-edge0) / (edge1 - edge0)), 0, 1) return y * y * (3 - 2*y) } -smoothstep_f64 :: proc "c" (edge0, edge1, x: f64) -> f64 { +@(require_results) smoothstep_f64 :: proc "c" (edge0, edge1, x: f64) -> f64 { y := clamp(((x-edge0) / (edge1 - edge0)), 0, 1) return y * y * (3 - 2*y) } -smoothstep_vec2 :: proc "c" (edge0, edge1, x: vec2) -> vec2 { return {smoothstep(edge0.x, edge1.x, x.x), smoothstep(edge0.y, edge1.y, x.y)} } -smoothstep_vec3 :: proc "c" (edge0, edge1, x: vec3) -> vec3 { return {smoothstep(edge0.x, edge1.x, x.x), smoothstep(edge0.y, edge1.y, x.y), smoothstep(edge0.z, edge1.z, x.z)} } -smoothstep_vec4 :: proc "c" (edge0, edge1, x: vec4) -> vec4 { return {smoothstep(edge0.x, edge1.x, x.x), smoothstep(edge0.y, edge1.y, x.y), smoothstep(edge0.z, edge1.z, x.z), smoothstep(edge0.w, edge1.w, x.w)} } -smoothstep_dvec2 :: proc "c" (edge0, edge1, x: dvec2) -> dvec2 { return {smoothstep(edge0.x, edge1.x, x.x), smoothstep(edge0.y, edge1.y, x.y)} } -smoothstep_dvec3 :: proc "c" (edge0, edge1, x: dvec3) -> dvec3 { return {smoothstep(edge0.x, edge1.x, x.x), smoothstep(edge0.y, edge1.y, x.y), smoothstep(edge0.z, edge1.z, x.z)} } -smoothstep_dvec4 :: proc "c" (edge0, edge1, x: dvec4) -> dvec4 { return {smoothstep(edge0.x, edge1.x, x.x), smoothstep(edge0.y, edge1.y, x.y), smoothstep(edge0.z, edge1.z, x.z), smoothstep(edge0.w, edge1.w, x.w)} } +@(require_results) smoothstep_vec2 :: proc "c" (edge0, edge1, x: vec2) -> vec2 { return {smoothstep(edge0.x, edge1.x, x.x), smoothstep(edge0.y, edge1.y, x.y)} } +@(require_results) smoothstep_vec3 :: proc "c" (edge0, edge1, x: vec3) -> vec3 { return {smoothstep(edge0.x, edge1.x, x.x), smoothstep(edge0.y, edge1.y, x.y), smoothstep(edge0.z, edge1.z, x.z)} } +@(require_results) smoothstep_vec4 :: proc "c" (edge0, edge1, x: vec4) -> vec4 { return {smoothstep(edge0.x, edge1.x, x.x), smoothstep(edge0.y, edge1.y, x.y), smoothstep(edge0.z, edge1.z, x.z), smoothstep(edge0.w, edge1.w, x.w)} } +@(require_results) smoothstep_dvec2 :: proc "c" (edge0, edge1, x: dvec2) -> dvec2 { return {smoothstep(edge0.x, edge1.x, x.x), smoothstep(edge0.y, edge1.y, x.y)} } +@(require_results) smoothstep_dvec3 :: proc "c" (edge0, edge1, x: dvec3) -> dvec3 { return {smoothstep(edge0.x, edge1.x, x.x), smoothstep(edge0.y, edge1.y, x.y), smoothstep(edge0.z, edge1.z, x.z)} } +@(require_results) smoothstep_dvec4 :: proc "c" (edge0, edge1, x: dvec4) -> dvec4 { return {smoothstep(edge0.x, edge1.x, x.x), smoothstep(edge0.y, edge1.y, x.y), smoothstep(edge0.z, edge1.z, x.z), smoothstep(edge0.w, edge1.w, x.w)} } abs :: proc{ @@ -831,22 +831,22 @@ abs :: proc{ abs_uvec3, abs_uvec4, } -abs_i32 :: proc "c" (x: i32) -> i32 { return builtin.abs(x) } -abs_u32 :: proc "c" (x: u32) -> u32 { return x } -abs_f32 :: proc "c" (x: f32) -> f32 { return builtin.abs(x) } -abs_f64 :: proc "c" (x: f64) -> f64 { return builtin.abs(x) } -abs_vec2 :: proc "c" (x: vec2) -> vec2 { return {abs(x.x), abs(x.y)} } -abs_vec3 :: proc "c" (x: vec3) -> vec3 { return {abs(x.x), abs(x.y), abs(x.z)} } -abs_vec4 :: proc "c" (x: vec4) -> vec4 { return {abs(x.x), abs(x.y), abs(x.z), abs(x.w)} } -abs_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {abs(x.x), abs(x.y)} } -abs_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {abs(x.x), abs(x.y), abs(x.z)} } -abs_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {abs(x.x), abs(x.y), abs(x.z), abs(x.w)} } -abs_ivec2 :: proc "c" (x: ivec2) -> ivec2 { return {abs(x.x), abs(x.y)} } -abs_ivec3 :: proc "c" (x: ivec3) -> ivec3 { return {abs(x.x), abs(x.y), abs(x.z)} } -abs_ivec4 :: proc "c" (x: ivec4) -> ivec4 { return {abs(x.x), abs(x.y), abs(x.z), abs(x.w)} } -abs_uvec2 :: proc "c" (x: uvec2) -> uvec2 { return x } -abs_uvec3 :: proc "c" (x: uvec3) -> uvec3 { return x } -abs_uvec4 :: proc "c" (x: uvec4) -> uvec4 { return x } +@(require_results) abs_i32 :: proc "c" (x: i32) -> i32 { return builtin.abs(x) } +@(require_results) abs_u32 :: proc "c" (x: u32) -> u32 { return x } +@(require_results) abs_f32 :: proc "c" (x: f32) -> f32 { return builtin.abs(x) } +@(require_results) abs_f64 :: proc "c" (x: f64) -> f64 { return builtin.abs(x) } +@(require_results) abs_vec2 :: proc "c" (x: vec2) -> vec2 { return {abs(x.x), abs(x.y)} } +@(require_results) abs_vec3 :: proc "c" (x: vec3) -> vec3 { return {abs(x.x), abs(x.y), abs(x.z)} } +@(require_results) abs_vec4 :: proc "c" (x: vec4) -> vec4 { return {abs(x.x), abs(x.y), abs(x.z), abs(x.w)} } +@(require_results) abs_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return {abs(x.x), abs(x.y)} } +@(require_results) abs_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return {abs(x.x), abs(x.y), abs(x.z)} } +@(require_results) abs_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return {abs(x.x), abs(x.y), abs(x.z), abs(x.w)} } +@(require_results) abs_ivec2 :: proc "c" (x: ivec2) -> ivec2 { return {abs(x.x), abs(x.y)} } +@(require_results) abs_ivec3 :: proc "c" (x: ivec3) -> ivec3 { return {abs(x.x), abs(x.y), abs(x.z)} } +@(require_results) abs_ivec4 :: proc "c" (x: ivec4) -> ivec4 { return {abs(x.x), abs(x.y), abs(x.z), abs(x.w)} } +@(require_results) abs_uvec2 :: proc "c" (x: uvec2) -> uvec2 { return x } +@(require_results) abs_uvec3 :: proc "c" (x: uvec3) -> uvec3 { return x } +@(require_results) abs_uvec4 :: proc "c" (x: uvec4) -> uvec4 { return x } dot :: proc{ dot_i32, @@ -868,24 +868,24 @@ dot :: proc{ dot_quat, dot_dquat, } -dot_i32 :: proc "c" (a, b: i32) -> i32 { return a*b } -dot_u32 :: proc "c" (a, b: u32) -> u32 { return a*b } -dot_f32 :: proc "c" (a, b: f32) -> f32 { return a*b } -dot_f64 :: proc "c" (a, b: f64) -> f64 { return a*b } -dot_vec2 :: proc "c" (a, b: vec2) -> f32 { return a.x*b.x + a.y*b.y } -dot_vec3 :: proc "c" (a, b: vec3) -> f32 { return a.x*b.x + a.y*b.y + a.z*b.z } -dot_vec4 :: proc "c" (a, b: vec4) -> f32 { return a.x*b.x + a.y*b.y + a.z*b.z + a.w*b.w } -dot_dvec2 :: proc "c" (a, b: dvec2) -> f64 { return a.x*b.x + a.y*b.y } -dot_dvec3 :: proc "c" (a, b: dvec3) -> f64 { return a.x*b.x + a.y*b.y + a.z*b.z } -dot_dvec4 :: proc "c" (a, b: dvec4) -> f64 { return a.x*b.x + a.y*b.y + a.z*b.z + a.w*b.w } -dot_ivec2 :: proc "c" (a, b: ivec2) -> i32 { return a.x*b.x + a.y*b.y } -dot_ivec3 :: proc "c" (a, b: ivec3) -> i32 { return a.x*b.x + a.y*b.y + a.z*b.z } -dot_ivec4 :: proc "c" (a, b: ivec4) -> i32 { return a.x*b.x + a.y*b.y + a.z*b.z + a.w*b.w } -dot_uvec2 :: proc "c" (a, b: uvec2) -> u32 { return a.x*b.x + a.y*b.y } -dot_uvec3 :: proc "c" (a, b: uvec3) -> u32 { return a.x*b.x + a.y*b.y + a.z*b.z } -dot_uvec4 :: proc "c" (a, b: uvec4) -> u32 { return a.x*b.x + a.y*b.y + a.z*b.z + a.w*b.w } -dot_quat :: proc "c" (a, b: quat) -> f32 { return a.x*b.x + a.y*b.y + a.z*b.z + a.w*b.w } -dot_dquat :: proc "c" (a, b: dquat) -> f64 { return a.x*b.x + a.y*b.y + a.z*b.z + a.w*b.w } +@(require_results) dot_i32 :: proc "c" (a, b: i32) -> i32 { return a*b } +@(require_results) dot_u32 :: proc "c" (a, b: u32) -> u32 { return a*b } +@(require_results) dot_f32 :: proc "c" (a, b: f32) -> f32 { return a*b } +@(require_results) dot_f64 :: proc "c" (a, b: f64) -> f64 { return a*b } +@(require_results) dot_vec2 :: proc "c" (a, b: vec2) -> f32 { return a.x*b.x + a.y*b.y } +@(require_results) dot_vec3 :: proc "c" (a, b: vec3) -> f32 { return a.x*b.x + a.y*b.y + a.z*b.z } +@(require_results) dot_vec4 :: proc "c" (a, b: vec4) -> f32 { return a.x*b.x + a.y*b.y + a.z*b.z + a.w*b.w } +@(require_results) dot_dvec2 :: proc "c" (a, b: dvec2) -> f64 { return a.x*b.x + a.y*b.y } +@(require_results) dot_dvec3 :: proc "c" (a, b: dvec3) -> f64 { return a.x*b.x + a.y*b.y + a.z*b.z } +@(require_results) dot_dvec4 :: proc "c" (a, b: dvec4) -> f64 { return a.x*b.x + a.y*b.y + a.z*b.z + a.w*b.w } +@(require_results) dot_ivec2 :: proc "c" (a, b: ivec2) -> i32 { return a.x*b.x + a.y*b.y } +@(require_results) dot_ivec3 :: proc "c" (a, b: ivec3) -> i32 { return a.x*b.x + a.y*b.y + a.z*b.z } +@(require_results) dot_ivec4 :: proc "c" (a, b: ivec4) -> i32 { return a.x*b.x + a.y*b.y + a.z*b.z + a.w*b.w } +@(require_results) dot_uvec2 :: proc "c" (a, b: uvec2) -> u32 { return a.x*b.x + a.y*b.y } +@(require_results) dot_uvec3 :: proc "c" (a, b: uvec3) -> u32 { return a.x*b.x + a.y*b.y + a.z*b.z } +@(require_results) dot_uvec4 :: proc "c" (a, b: uvec4) -> u32 { return a.x*b.x + a.y*b.y + a.z*b.z + a.w*b.w } +@(require_results) dot_quat :: proc "c" (a, b: quat) -> f32 { return a.x*b.x + a.y*b.y + a.z*b.z + a.w*b.w } +@(require_results) dot_dquat :: proc "c" (a, b: dquat) -> f64 { return a.x*b.x + a.y*b.y + a.z*b.z + a.w*b.w } length :: proc{ length_f32, @@ -899,16 +899,16 @@ length :: proc{ length_quat, length_dquat, } -length_f32 :: proc "c" (x: f32) -> f32 { return builtin.abs(x) } -length_f64 :: proc "c" (x: f64) -> f64 { return builtin.abs(x) } -length_vec2 :: proc "c" (x: vec2) -> f32 { return sqrt(x.x*x.x + x.y*x.y) } -length_vec3 :: proc "c" (x: vec3) -> f32 { return sqrt(x.x*x.x + x.y*x.y + x.z*x.z) } -length_vec4 :: proc "c" (x: vec4) -> f32 { return sqrt(x.x*x.x + x.y*x.y + x.z*x.z + x.w*x.w) } -length_dvec2 :: proc "c" (x: dvec2) -> f64 { return sqrt(x.x*x.x + x.y*x.y) } -length_dvec3 :: proc "c" (x: dvec3) -> f64 { return sqrt(x.x*x.x + x.y*x.y + x.z*x.z) } -length_dvec4 :: proc "c" (x: dvec4) -> f64 { return sqrt(x.x*x.x + x.y*x.y + x.z*x.z + x.w*x.w) } -length_quat :: proc "c" (x: quat) -> f32 { return sqrt(x.x*x.x + x.y*x.y + x.z*x.z + x.w*x.w) } -length_dquat :: proc "c" (x: dquat) -> f64 { return sqrt(x.x*x.x + x.y*x.y + x.z*x.z + x.w*x.w) } +@(require_results) length_f32 :: proc "c" (x: f32) -> f32 { return builtin.abs(x) } +@(require_results) length_f64 :: proc "c" (x: f64) -> f64 { return builtin.abs(x) } +@(require_results) length_vec2 :: proc "c" (x: vec2) -> f32 { return sqrt(x.x*x.x + x.y*x.y) } +@(require_results) length_vec3 :: proc "c" (x: vec3) -> f32 { return sqrt(x.x*x.x + x.y*x.y + x.z*x.z) } +@(require_results) length_vec4 :: proc "c" (x: vec4) -> f32 { return sqrt(x.x*x.x + x.y*x.y + x.z*x.z + x.w*x.w) } +@(require_results) length_dvec2 :: proc "c" (x: dvec2) -> f64 { return sqrt(x.x*x.x + x.y*x.y) } +@(require_results) length_dvec3 :: proc "c" (x: dvec3) -> f64 { return sqrt(x.x*x.x + x.y*x.y + x.z*x.z) } +@(require_results) length_dvec4 :: proc "c" (x: dvec4) -> f64 { return sqrt(x.x*x.x + x.y*x.y + x.z*x.z + x.w*x.w) } +@(require_results) length_quat :: proc "c" (x: quat) -> f32 { return sqrt(x.x*x.x + x.y*x.y + x.z*x.z + x.w*x.w) } +@(require_results) length_dquat :: proc "c" (x: dquat) -> f64 { return sqrt(x.x*x.x + x.y*x.y + x.z*x.z + x.w*x.w) } distance :: proc{ @@ -921,14 +921,14 @@ distance :: proc{ distance_dvec3, distance_dvec4, } -distance_f32 :: proc "c" (x, y: f32) -> f32 { return length(y-x) } -distance_f64 :: proc "c" (x, y: f64) -> f64 { return length(y-x) } -distance_vec2 :: proc "c" (x, y: vec2) -> f32 { return length(y-x) } -distance_vec3 :: proc "c" (x, y: vec3) -> f32 { return length(y-x) } -distance_vec4 :: proc "c" (x, y: vec4) -> f32 { return length(y-x) } -distance_dvec2 :: proc "c" (x, y: dvec2) -> f64 { return length(y-x) } -distance_dvec3 :: proc "c" (x, y: dvec3) -> f64 { return length(y-x) } -distance_dvec4 :: proc "c" (x, y: dvec4) -> f64 { return length(y-x) } +@(require_results) distance_f32 :: proc "c" (x, y: f32) -> f32 { return length(y-x) } +@(require_results) distance_f64 :: proc "c" (x, y: f64) -> f64 { return length(y-x) } +@(require_results) distance_vec2 :: proc "c" (x, y: vec2) -> f32 { return length(y-x) } +@(require_results) distance_vec3 :: proc "c" (x, y: vec3) -> f32 { return length(y-x) } +@(require_results) distance_vec4 :: proc "c" (x, y: vec4) -> f32 { return length(y-x) } +@(require_results) distance_dvec2 :: proc "c" (x, y: dvec2) -> f64 { return length(y-x) } +@(require_results) distance_dvec3 :: proc "c" (x, y: dvec3) -> f64 { return length(y-x) } +@(require_results) distance_dvec4 :: proc "c" (x, y: dvec4) -> f64 { return length(y-x) } cross :: proc{ @@ -937,19 +937,19 @@ cross :: proc{ cross_ivec3, } -cross_vec3 :: proc "c" (a, b: vec3) -> (c: vec3) { +@(require_results) cross_vec3 :: proc "c" (a, b: vec3) -> (c: vec3) { c.x = a.y*b.z - b.y*a.z c.y = a.z*b.x - b.z*a.x c.z = a.x*b.y - b.x*a.y return } -cross_dvec3 :: proc "c" (a, b: dvec3) -> (c: dvec3) { +@(require_results) cross_dvec3 :: proc "c" (a, b: dvec3) -> (c: dvec3) { c.x = a.y*b.z - b.y*a.z c.y = a.z*b.x - b.z*a.x c.z = a.x*b.y - b.x*a.y return } -cross_ivec3 :: proc "c" (a, b: ivec3) -> (c: ivec3) { +@(require_results) cross_ivec3 :: proc "c" (a, b: ivec3) -> (c: ivec3) { c.x = a.y*b.z - b.y*a.z c.y = a.z*b.x - b.z*a.x c.z = a.x*b.y - b.x*a.y @@ -968,16 +968,16 @@ normalize :: proc{ normalize_quat, normalize_dquat, } -normalize_f32 :: proc "c" (x: f32) -> f32 { return 1.0 } -normalize_f64 :: proc "c" (x: f64) -> f64 { return 1.0 } -normalize_vec2 :: proc "c" (x: vec2) -> vec2 { return x / length(x) } -normalize_vec3 :: proc "c" (x: vec3) -> vec3 { return x / length(x) } -normalize_vec4 :: proc "c" (x: vec4) -> vec4 { return x / length(x) } -normalize_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return x / length(x) } -normalize_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return x / length(x) } -normalize_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return x / length(x) } -normalize_quat :: proc "c" (x: quat) -> quat { return x / quat(length(x)) } -normalize_dquat :: proc "c" (x: dquat) -> dquat { return x / dquat(length(x)) } +@(require_results) normalize_f32 :: proc "c" (x: f32) -> f32 { return 1.0 } +@(require_results) normalize_f64 :: proc "c" (x: f64) -> f64 { return 1.0 } +@(require_results) normalize_vec2 :: proc "c" (x: vec2) -> vec2 { return x / length(x) } +@(require_results) normalize_vec3 :: proc "c" (x: vec3) -> vec3 { return x / length(x) } +@(require_results) normalize_vec4 :: proc "c" (x: vec4) -> vec4 { return x / length(x) } +@(require_results) normalize_dvec2 :: proc "c" (x: dvec2) -> dvec2 { return x / length(x) } +@(require_results) normalize_dvec3 :: proc "c" (x: dvec3) -> dvec3 { return x / length(x) } +@(require_results) normalize_dvec4 :: proc "c" (x: dvec4) -> dvec4 { return x / length(x) } +@(require_results) normalize_quat :: proc "c" (x: quat) -> quat { return x / quat(length(x)) } +@(require_results) normalize_dquat :: proc "c" (x: dquat) -> dquat { return x / dquat(length(x)) } faceForward :: proc{ @@ -990,14 +990,14 @@ faceForward :: proc{ faceForward_dvec3, faceForward_dvec4, } -faceForward_f32 :: proc "c" (N, I, Nref: f32) -> f32 { return N if dot(I, Nref) < 0 else -N } -faceForward_f64 :: proc "c" (N, I, Nref: f64) -> f64 { return N if dot(I, Nref) < 0 else -N } -faceForward_vec2 :: proc "c" (N, I, Nref: vec2) -> vec2 { return N if dot(I, Nref) < 0 else -N } -faceForward_vec3 :: proc "c" (N, I, Nref: vec3) -> vec3 { return N if dot(I, Nref) < 0 else -N } -faceForward_vec4 :: proc "c" (N, I, Nref: vec4) -> vec4 { return N if dot(I, Nref) < 0 else -N } -faceForward_dvec2 :: proc "c" (N, I, Nref: dvec2) -> dvec2 { return N if dot(I, Nref) < 0 else -N } -faceForward_dvec3 :: proc "c" (N, I, Nref: dvec3) -> dvec3 { return N if dot(I, Nref) < 0 else -N } -faceForward_dvec4 :: proc "c" (N, I, Nref: dvec4) -> dvec4 { return N if dot(I, Nref) < 0 else -N } +@(require_results) faceForward_f32 :: proc "c" (N, I, Nref: f32) -> f32 { return N if dot(I, Nref) < 0 else -N } +@(require_results) faceForward_f64 :: proc "c" (N, I, Nref: f64) -> f64 { return N if dot(I, Nref) < 0 else -N } +@(require_results) faceForward_vec2 :: proc "c" (N, I, Nref: vec2) -> vec2 { return N if dot(I, Nref) < 0 else -N } +@(require_results) faceForward_vec3 :: proc "c" (N, I, Nref: vec3) -> vec3 { return N if dot(I, Nref) < 0 else -N } +@(require_results) faceForward_vec4 :: proc "c" (N, I, Nref: vec4) -> vec4 { return N if dot(I, Nref) < 0 else -N } +@(require_results) faceForward_dvec2 :: proc "c" (N, I, Nref: dvec2) -> dvec2 { return N if dot(I, Nref) < 0 else -N } +@(require_results) faceForward_dvec3 :: proc "c" (N, I, Nref: dvec3) -> dvec3 { return N if dot(I, Nref) < 0 else -N } +@(require_results) faceForward_dvec4 :: proc "c" (N, I, Nref: dvec4) -> dvec4 { return N if dot(I, Nref) < 0 else -N } reflect :: proc{ @@ -1010,14 +1010,14 @@ reflect :: proc{ reflect_dvec3, reflect_dvec4, } -reflect_f32 :: proc "c" (I, N: f32) -> f32 { return I - 2*N*dot(N, I) } -reflect_f64 :: proc "c" (I, N: f64) -> f64 { return I - 2*N*dot(N, I) } -reflect_vec2 :: proc "c" (I, N: vec2) -> vec2 { return I - 2*N*dot(N, I) } -reflect_vec3 :: proc "c" (I, N: vec3) -> vec3 { return I - 2*N*dot(N, I) } -reflect_vec4 :: proc "c" (I, N: vec4) -> vec4 { return I - 2*N*dot(N, I) } -reflect_dvec2 :: proc "c" (I, N: dvec2) -> dvec2 { return I - 2*N*dot(N, I) } -reflect_dvec3 :: proc "c" (I, N: dvec3) -> dvec3 { return I - 2*N*dot(N, I) } -reflect_dvec4 :: proc "c" (I, N: dvec4) -> dvec4 { return I - 2*N*dot(N, I) } +@(require_results) reflect_f32 :: proc "c" (I, N: f32) -> f32 { return I - 2*N*dot(N, I) } +@(require_results) reflect_f64 :: proc "c" (I, N: f64) -> f64 { return I - 2*N*dot(N, I) } +@(require_results) reflect_vec2 :: proc "c" (I, N: vec2) -> vec2 { return I - 2*N*dot(N, I) } +@(require_results) reflect_vec3 :: proc "c" (I, N: vec3) -> vec3 { return I - 2*N*dot(N, I) } +@(require_results) reflect_vec4 :: proc "c" (I, N: vec4) -> vec4 { return I - 2*N*dot(N, I) } +@(require_results) reflect_dvec2 :: proc "c" (I, N: dvec2) -> dvec2 { return I - 2*N*dot(N, I) } +@(require_results) reflect_dvec3 :: proc "c" (I, N: dvec3) -> dvec3 { return I - 2*N*dot(N, I) } +@(require_results) reflect_dvec4 :: proc "c" (I, N: dvec4) -> dvec4 { return I - 2*N*dot(N, I) } @@ -1032,49 +1032,49 @@ refract :: proc{ refract_dvec3, refract_dvec4, } -refract_f32 :: proc "c" (i, n, eta: f32) -> f32 { +@(require_results) refract_f32 :: proc "c" (i, n, eta: f32) -> f32 { cosi := dot(-i, n) cost2 := 1 - eta*eta*(1 - cosi*cosi) t := eta*i + ((eta*cosi - sqrt(abs(cost2))) * n) return t * f32(i32(cost2 > 0)) } -refract_f64 :: proc "c" (i, n, eta: f64) -> f64 { +@(require_results) refract_f64 :: proc "c" (i, n, eta: f64) -> f64 { cosi := dot(-i, n) cost2 := 1 - eta*eta*(1 - cosi*cosi) t := eta*i + ((eta*cosi - sqrt(abs(cost2))) * n) return t * f64(i32(cost2 > 0)) } -refract_vec2 :: proc "c" (i, n, eta: vec2) -> vec2 { +@(require_results) refract_vec2 :: proc "c" (i, n, eta: vec2) -> vec2 { cosi := dot(-i, n) cost2 := 1 - eta*eta*(1 - cosi*cosi) t := eta*i + ((eta*cosi - sqrt(abs(cost2))) * n) return t * vec2{f32(i32(cost2.x > 0)), f32(i32(cost2.y > 0))} } -refract_vec3 :: proc "c" (i, n, eta: vec3) -> vec3 { +@(require_results) refract_vec3 :: proc "c" (i, n, eta: vec3) -> vec3 { cosi := dot(-i, n) cost2 := 1 - eta*eta*(1 - cosi*cosi) t := eta*i + ((eta*cosi - sqrt(abs(cost2))) * n) return t * vec3{f32(i32(cost2.x > 0)), f32(i32(cost2.y > 0)), f32(i32(cost2.z > 0))} } -refract_vec4 :: proc "c" (i, n, eta: vec4) -> vec4 { +@(require_results) refract_vec4 :: proc "c" (i, n, eta: vec4) -> vec4 { cosi := dot(-i, n) cost2 := 1 - eta*eta*(1 - cosi*cosi) t := eta*i + ((eta*cosi - sqrt(abs(cost2))) * n) return t * vec4{f32(i32(cost2.x > 0)), f32(i32(cost2.y > 0)), f32(i32(cost2.z > 0)), f32(i32(cost2.w > 0))} } -refract_dvec2 :: proc "c" (i, n, eta: dvec2) -> dvec2 { +@(require_results) refract_dvec2 :: proc "c" (i, n, eta: dvec2) -> dvec2 { cosi := dot(-i, n) cost2 := 1 - eta*eta*(1 - cosi*cosi) t := eta*i + ((eta*cosi - sqrt(abs(cost2))) * n) return t * dvec2{f64(i32(cost2.x > 0)), f64(i32(cost2.y > 0))} } -refract_dvec3 :: proc "c" (i, n, eta: dvec3) -> dvec3 { +@(require_results) refract_dvec3 :: proc "c" (i, n, eta: dvec3) -> dvec3 { cosi := dot(-i, n) cost2 := 1 - eta*eta*(1 - cosi*cosi) t := eta*i + ((eta*cosi - sqrt(abs(cost2))) * n) return t * dvec3{f64(i32(cost2.x > 0)), f64(i32(cost2.y > 0)), f64(i32(cost2.z > 0))} } -refract_dvec4 :: proc "c" (i, n, eta: dvec4) -> dvec4 { +@(require_results) refract_dvec4 :: proc "c" (i, n, eta: dvec4) -> dvec4 { cosi := dot(-i, n) cost2 := 1 - eta*eta*(1 - cosi*cosi) t := eta*i + ((eta*cosi - sqrt(abs(cost2))) * n) @@ -1086,18 +1086,18 @@ scalarTripleProduct :: proc{ scalarTripleProduct_dvec3, scalarTripleProduct_ivec3, } -scalarTripleProduct_vec3 :: proc "c" (a, b, c: vec3) -> f32 { return dot(a, cross(b, c)) } -scalarTripleProduct_dvec3 :: proc "c" (a, b, c: dvec3) -> f64 { return dot(a, cross(b, c)) } -scalarTripleProduct_ivec3 :: proc "c" (a, b, c: ivec3) -> i32 { return dot(a, cross(b, c)) } +@(require_results) scalarTripleProduct_vec3 :: proc "c" (a, b, c: vec3) -> f32 { return dot(a, cross(b, c)) } +@(require_results) scalarTripleProduct_dvec3 :: proc "c" (a, b, c: dvec3) -> f64 { return dot(a, cross(b, c)) } +@(require_results) scalarTripleProduct_ivec3 :: proc "c" (a, b, c: ivec3) -> i32 { return dot(a, cross(b, c)) } vectorTripleProduct :: proc { vectorTripleProduct_vec3, vectorTripleProduct_dvec3, vectorTripleProduct_ivec3, } -vectorTripleProduct_vec3 :: proc "c" (a, b, c: vec3) -> vec3 { return cross(a, cross(b, c)) } -vectorTripleProduct_dvec3 :: proc "c" (a, b, c: dvec3) -> dvec3 { return cross(a, cross(b, c)) } -vectorTripleProduct_ivec3 :: proc "c" (a, b, c: ivec3) -> ivec3 { return cross(a, cross(b, c)) } +@(require_results) vectorTripleProduct_vec3 :: proc "c" (a, b, c: vec3) -> vec3 { return cross(a, cross(b, c)) } +@(require_results) vectorTripleProduct_dvec3 :: proc "c" (a, b, c: dvec3) -> dvec3 { return cross(a, cross(b, c)) } +@(require_results) vectorTripleProduct_ivec3 :: proc "c" (a, b, c: ivec3) -> ivec3 { return cross(a, cross(b, c)) } // Vector Relational Procedures @@ -1120,22 +1120,22 @@ lessThan :: proc{ lessThan_ivec4, lessThan_uvec4, } -lessThan_f32 :: proc "c" (a, b: f32) -> bool { return a < b } -lessThan_f64 :: proc "c" (a, b: f64) -> bool { return a < b } -lessThan_i32 :: proc "c" (a, b: i32) -> bool { return a < b } -lessThan_u32 :: proc "c" (a, b: u32) -> bool { return a < b } -lessThan_vec2 :: proc "c" (a, b: vec2) -> bvec2 { return {a.x < b.x, a.y < b.y} } -lessThan_dvec2 :: proc "c" (a, b: dvec2) -> bvec2 { return {a.x < b.x, a.y < b.y} } -lessThan_ivec2 :: proc "c" (a, b: ivec2) -> bvec2 { return {a.x < b.x, a.y < b.y} } -lessThan_uvec2 :: proc "c" (a, b: uvec2) -> bvec2 { return {a.x < b.x, a.y < b.y} } -lessThan_vec3 :: proc "c" (a, b: vec3) -> bvec3 { return {a.x < b.x, a.y < b.y, a.z < b.z} } -lessThan_dvec3 :: proc "c" (a, b: dvec3) -> bvec3 { return {a.x < b.x, a.y < b.y, a.z < b.z} } -lessThan_ivec3 :: proc "c" (a, b: ivec3) -> bvec3 { return {a.x < b.x, a.y < b.y, a.z < b.z} } -lessThan_uvec3 :: proc "c" (a, b: uvec3) -> bvec3 { return {a.x < b.x, a.y < b.y, a.z < b.z} } -lessThan_vec4 :: proc "c" (a, b: vec4) -> bvec4 { return {a.x < b.x, a.y < b.y, a.z < b.z, a.w < b.w} } -lessThan_dvec4 :: proc "c" (a, b: dvec4) -> bvec4 { return {a.x < b.x, a.y < b.y, a.z < b.z, a.w < b.w} } -lessThan_ivec4 :: proc "c" (a, b: ivec4) -> bvec4 { return {a.x < b.x, a.y < b.y, a.z < b.z, a.w < b.w} } -lessThan_uvec4 :: proc "c" (a, b: uvec4) -> bvec4 { return {a.x < b.x, a.y < b.y, a.z < b.z, a.w < b.w} } +@(require_results) lessThan_f32 :: proc "c" (a, b: f32) -> bool { return a < b } +@(require_results) lessThan_f64 :: proc "c" (a, b: f64) -> bool { return a < b } +@(require_results) lessThan_i32 :: proc "c" (a, b: i32) -> bool { return a < b } +@(require_results) lessThan_u32 :: proc "c" (a, b: u32) -> bool { return a < b } +@(require_results) lessThan_vec2 :: proc "c" (a, b: vec2) -> bvec2 { return {a.x < b.x, a.y < b.y} } +@(require_results) lessThan_dvec2 :: proc "c" (a, b: dvec2) -> bvec2 { return {a.x < b.x, a.y < b.y} } +@(require_results) lessThan_ivec2 :: proc "c" (a, b: ivec2) -> bvec2 { return {a.x < b.x, a.y < b.y} } +@(require_results) lessThan_uvec2 :: proc "c" (a, b: uvec2) -> bvec2 { return {a.x < b.x, a.y < b.y} } +@(require_results) lessThan_vec3 :: proc "c" (a, b: vec3) -> bvec3 { return {a.x < b.x, a.y < b.y, a.z < b.z} } +@(require_results) lessThan_dvec3 :: proc "c" (a, b: dvec3) -> bvec3 { return {a.x < b.x, a.y < b.y, a.z < b.z} } +@(require_results) lessThan_ivec3 :: proc "c" (a, b: ivec3) -> bvec3 { return {a.x < b.x, a.y < b.y, a.z < b.z} } +@(require_results) lessThan_uvec3 :: proc "c" (a, b: uvec3) -> bvec3 { return {a.x < b.x, a.y < b.y, a.z < b.z} } +@(require_results) lessThan_vec4 :: proc "c" (a, b: vec4) -> bvec4 { return {a.x < b.x, a.y < b.y, a.z < b.z, a.w < b.w} } +@(require_results) lessThan_dvec4 :: proc "c" (a, b: dvec4) -> bvec4 { return {a.x < b.x, a.y < b.y, a.z < b.z, a.w < b.w} } +@(require_results) lessThan_ivec4 :: proc "c" (a, b: ivec4) -> bvec4 { return {a.x < b.x, a.y < b.y, a.z < b.z, a.w < b.w} } +@(require_results) lessThan_uvec4 :: proc "c" (a, b: uvec4) -> bvec4 { return {a.x < b.x, a.y < b.y, a.z < b.z, a.w < b.w} } lessThanEqual :: proc{ @@ -1156,22 +1156,22 @@ lessThanEqual :: proc{ lessThanEqual_ivec4, lessThanEqual_uvec4, } -lessThanEqual_f32 :: proc "c" (a, b: f32) -> bool { return a <= b } -lessThanEqual_f64 :: proc "c" (a, b: f64) -> bool { return a <= b } -lessThanEqual_i32 :: proc "c" (a, b: i32) -> bool { return a <= b } -lessThanEqual_u32 :: proc "c" (a, b: u32) -> bool { return a <= b } -lessThanEqual_vec2 :: proc "c" (a, b: vec2) -> bvec2 { return {a.x <= b.x, a.y <= b.y} } -lessThanEqual_dvec2 :: proc "c" (a, b: dvec2) -> bvec2 { return {a.x <= b.x, a.y <= b.y} } -lessThanEqual_ivec2 :: proc "c" (a, b: ivec2) -> bvec2 { return {a.x <= b.x, a.y <= b.y} } -lessThanEqual_uvec2 :: proc "c" (a, b: uvec2) -> bvec2 { return {a.x <= b.x, a.y <= b.y} } -lessThanEqual_vec3 :: proc "c" (a, b: vec3) -> bvec3 { return {a.x <= b.x, a.y <= b.y, a.z <= b.z} } -lessThanEqual_dvec3 :: proc "c" (a, b: dvec3) -> bvec3 { return {a.x <= b.x, a.y <= b.y, a.z <= b.z} } -lessThanEqual_ivec3 :: proc "c" (a, b: ivec3) -> bvec3 { return {a.x <= b.x, a.y <= b.y, a.z <= b.z} } -lessThanEqual_uvec3 :: proc "c" (a, b: uvec3) -> bvec3 { return {a.x <= b.x, a.y <= b.y, a.z <= b.z} } -lessThanEqual_vec4 :: proc "c" (a, b: vec4) -> bvec4 { return {a.x <= b.x, a.y <= b.y, a.z <= b.z, a.w <= b.w} } -lessThanEqual_dvec4 :: proc "c" (a, b: dvec4) -> bvec4 { return {a.x <= b.x, a.y <= b.y, a.z <= b.z, a.w <= b.w} } -lessThanEqual_ivec4 :: proc "c" (a, b: ivec4) -> bvec4 { return {a.x <= b.x, a.y <= b.y, a.z <= b.z, a.w <= b.w} } -lessThanEqual_uvec4 :: proc "c" (a, b: uvec4) -> bvec4 { return {a.x <= b.x, a.y <= b.y, a.z <= b.z, a.w <= b.w} } +@(require_results) lessThanEqual_f32 :: proc "c" (a, b: f32) -> bool { return a <= b } +@(require_results) lessThanEqual_f64 :: proc "c" (a, b: f64) -> bool { return a <= b } +@(require_results) lessThanEqual_i32 :: proc "c" (a, b: i32) -> bool { return a <= b } +@(require_results) lessThanEqual_u32 :: proc "c" (a, b: u32) -> bool { return a <= b } +@(require_results) lessThanEqual_vec2 :: proc "c" (a, b: vec2) -> bvec2 { return {a.x <= b.x, a.y <= b.y} } +@(require_results) lessThanEqual_dvec2 :: proc "c" (a, b: dvec2) -> bvec2 { return {a.x <= b.x, a.y <= b.y} } +@(require_results) lessThanEqual_ivec2 :: proc "c" (a, b: ivec2) -> bvec2 { return {a.x <= b.x, a.y <= b.y} } +@(require_results) lessThanEqual_uvec2 :: proc "c" (a, b: uvec2) -> bvec2 { return {a.x <= b.x, a.y <= b.y} } +@(require_results) lessThanEqual_vec3 :: proc "c" (a, b: vec3) -> bvec3 { return {a.x <= b.x, a.y <= b.y, a.z <= b.z} } +@(require_results) lessThanEqual_dvec3 :: proc "c" (a, b: dvec3) -> bvec3 { return {a.x <= b.x, a.y <= b.y, a.z <= b.z} } +@(require_results) lessThanEqual_ivec3 :: proc "c" (a, b: ivec3) -> bvec3 { return {a.x <= b.x, a.y <= b.y, a.z <= b.z} } +@(require_results) lessThanEqual_uvec3 :: proc "c" (a, b: uvec3) -> bvec3 { return {a.x <= b.x, a.y <= b.y, a.z <= b.z} } +@(require_results) lessThanEqual_vec4 :: proc "c" (a, b: vec4) -> bvec4 { return {a.x <= b.x, a.y <= b.y, a.z <= b.z, a.w <= b.w} } +@(require_results) lessThanEqual_dvec4 :: proc "c" (a, b: dvec4) -> bvec4 { return {a.x <= b.x, a.y <= b.y, a.z <= b.z, a.w <= b.w} } +@(require_results) lessThanEqual_ivec4 :: proc "c" (a, b: ivec4) -> bvec4 { return {a.x <= b.x, a.y <= b.y, a.z <= b.z, a.w <= b.w} } +@(require_results) lessThanEqual_uvec4 :: proc "c" (a, b: uvec4) -> bvec4 { return {a.x <= b.x, a.y <= b.y, a.z <= b.z, a.w <= b.w} } greaterThan :: proc{ @@ -1192,22 +1192,22 @@ greaterThan :: proc{ greaterThan_ivec4, greaterThan_uvec4, } -greaterThan_f32 :: proc "c" (a, b: f32) -> bool { return a > b } -greaterThan_f64 :: proc "c" (a, b: f64) -> bool { return a > b } -greaterThan_i32 :: proc "c" (a, b: i32) -> bool { return a > b } -greaterThan_u32 :: proc "c" (a, b: u32) -> bool { return a > b } -greaterThan_vec2 :: proc "c" (a, b: vec2) -> bvec2 { return {a.x > b.x, a.y > b.y} } -greaterThan_dvec2 :: proc "c" (a, b: dvec2) -> bvec2 { return {a.x > b.x, a.y > b.y} } -greaterThan_ivec2 :: proc "c" (a, b: ivec2) -> bvec2 { return {a.x > b.x, a.y > b.y} } -greaterThan_uvec2 :: proc "c" (a, b: uvec2) -> bvec2 { return {a.x > b.x, a.y > b.y} } -greaterThan_vec3 :: proc "c" (a, b: vec3) -> bvec3 { return {a.x > b.x, a.y > b.y, a.z > b.z} } -greaterThan_dvec3 :: proc "c" (a, b: dvec3) -> bvec3 { return {a.x > b.x, a.y > b.y, a.z > b.z} } -greaterThan_ivec3 :: proc "c" (a, b: ivec3) -> bvec3 { return {a.x > b.x, a.y > b.y, a.z > b.z} } -greaterThan_uvec3 :: proc "c" (a, b: uvec3) -> bvec3 { return {a.x > b.x, a.y > b.y, a.z > b.z} } -greaterThan_vec4 :: proc "c" (a, b: vec4) -> bvec4 { return {a.x > b.x, a.y > b.y, a.z > b.z, a.w > b.w} } -greaterThan_dvec4 :: proc "c" (a, b: dvec4) -> bvec4 { return {a.x > b.x, a.y > b.y, a.z > b.z, a.w > b.w} } -greaterThan_ivec4 :: proc "c" (a, b: ivec4) -> bvec4 { return {a.x > b.x, a.y > b.y, a.z > b.z, a.w > b.w} } -greaterThan_uvec4 :: proc "c" (a, b: uvec4) -> bvec4 { return {a.x > b.x, a.y > b.y, a.z > b.z, a.w > b.w} } +@(require_results) greaterThan_f32 :: proc "c" (a, b: f32) -> bool { return a > b } +@(require_results) greaterThan_f64 :: proc "c" (a, b: f64) -> bool { return a > b } +@(require_results) greaterThan_i32 :: proc "c" (a, b: i32) -> bool { return a > b } +@(require_results) greaterThan_u32 :: proc "c" (a, b: u32) -> bool { return a > b } +@(require_results) greaterThan_vec2 :: proc "c" (a, b: vec2) -> bvec2 { return {a.x > b.x, a.y > b.y} } +@(require_results) greaterThan_dvec2 :: proc "c" (a, b: dvec2) -> bvec2 { return {a.x > b.x, a.y > b.y} } +@(require_results) greaterThan_ivec2 :: proc "c" (a, b: ivec2) -> bvec2 { return {a.x > b.x, a.y > b.y} } +@(require_results) greaterThan_uvec2 :: proc "c" (a, b: uvec2) -> bvec2 { return {a.x > b.x, a.y > b.y} } +@(require_results) greaterThan_vec3 :: proc "c" (a, b: vec3) -> bvec3 { return {a.x > b.x, a.y > b.y, a.z > b.z} } +@(require_results) greaterThan_dvec3 :: proc "c" (a, b: dvec3) -> bvec3 { return {a.x > b.x, a.y > b.y, a.z > b.z} } +@(require_results) greaterThan_ivec3 :: proc "c" (a, b: ivec3) -> bvec3 { return {a.x > b.x, a.y > b.y, a.z > b.z} } +@(require_results) greaterThan_uvec3 :: proc "c" (a, b: uvec3) -> bvec3 { return {a.x > b.x, a.y > b.y, a.z > b.z} } +@(require_results) greaterThan_vec4 :: proc "c" (a, b: vec4) -> bvec4 { return {a.x > b.x, a.y > b.y, a.z > b.z, a.w > b.w} } +@(require_results) greaterThan_dvec4 :: proc "c" (a, b: dvec4) -> bvec4 { return {a.x > b.x, a.y > b.y, a.z > b.z, a.w > b.w} } +@(require_results) greaterThan_ivec4 :: proc "c" (a, b: ivec4) -> bvec4 { return {a.x > b.x, a.y > b.y, a.z > b.z, a.w > b.w} } +@(require_results) greaterThan_uvec4 :: proc "c" (a, b: uvec4) -> bvec4 { return {a.x > b.x, a.y > b.y, a.z > b.z, a.w > b.w} } greaterThanEqual :: proc{ @@ -1228,22 +1228,22 @@ greaterThanEqual :: proc{ greaterThanEqual_ivec4, greaterThanEqual_uvec4, } -greaterThanEqual_f32 :: proc "c" (a, b: f32) -> bool { return a >= b } -greaterThanEqual_f64 :: proc "c" (a, b: f64) -> bool { return a >= b } -greaterThanEqual_i32 :: proc "c" (a, b: i32) -> bool { return a >= b } -greaterThanEqual_u32 :: proc "c" (a, b: u32) -> bool { return a >= b } -greaterThanEqual_vec2 :: proc "c" (a, b: vec2) -> bvec2 { return {a.x >= b.x, a.y >= b.y} } -greaterThanEqual_dvec2 :: proc "c" (a, b: dvec2) -> bvec2 { return {a.x >= b.x, a.y >= b.y} } -greaterThanEqual_ivec2 :: proc "c" (a, b: ivec2) -> bvec2 { return {a.x >= b.x, a.y >= b.y} } -greaterThanEqual_uvec2 :: proc "c" (a, b: uvec2) -> bvec2 { return {a.x >= b.x, a.y >= b.y} } -greaterThanEqual_vec3 :: proc "c" (a, b: vec3) -> bvec3 { return {a.x >= b.x, a.y >= b.y, a.z >= b.z} } -greaterThanEqual_dvec3 :: proc "c" (a, b: dvec3) -> bvec3 { return {a.x >= b.x, a.y >= b.y, a.z >= b.z} } -greaterThanEqual_ivec3 :: proc "c" (a, b: ivec3) -> bvec3 { return {a.x >= b.x, a.y >= b.y, a.z >= b.z} } -greaterThanEqual_uvec3 :: proc "c" (a, b: uvec3) -> bvec3 { return {a.x >= b.x, a.y >= b.y, a.z >= b.z} } -greaterThanEqual_vec4 :: proc "c" (a, b: vec4) -> bvec4 { return {a.x >= b.x, a.y >= b.y, a.z >= b.z, a.w >= b.w} } -greaterThanEqual_dvec4 :: proc "c" (a, b: dvec4) -> bvec4 { return {a.x >= b.x, a.y >= b.y, a.z >= b.z, a.w >= b.w} } -greaterThanEqual_ivec4 :: proc "c" (a, b: ivec4) -> bvec4 { return {a.x >= b.x, a.y >= b.y, a.z >= b.z, a.w >= b.w} } -greaterThanEqual_uvec4 :: proc "c" (a, b: uvec4) -> bvec4 { return {a.x >= b.x, a.y >= b.y, a.z >= b.z, a.w >= b.w} } +@(require_results) greaterThanEqual_f32 :: proc "c" (a, b: f32) -> bool { return a >= b } +@(require_results) greaterThanEqual_f64 :: proc "c" (a, b: f64) -> bool { return a >= b } +@(require_results) greaterThanEqual_i32 :: proc "c" (a, b: i32) -> bool { return a >= b } +@(require_results) greaterThanEqual_u32 :: proc "c" (a, b: u32) -> bool { return a >= b } +@(require_results) greaterThanEqual_vec2 :: proc "c" (a, b: vec2) -> bvec2 { return {a.x >= b.x, a.y >= b.y} } +@(require_results) greaterThanEqual_dvec2 :: proc "c" (a, b: dvec2) -> bvec2 { return {a.x >= b.x, a.y >= b.y} } +@(require_results) greaterThanEqual_ivec2 :: proc "c" (a, b: ivec2) -> bvec2 { return {a.x >= b.x, a.y >= b.y} } +@(require_results) greaterThanEqual_uvec2 :: proc "c" (a, b: uvec2) -> bvec2 { return {a.x >= b.x, a.y >= b.y} } +@(require_results) greaterThanEqual_vec3 :: proc "c" (a, b: vec3) -> bvec3 { return {a.x >= b.x, a.y >= b.y, a.z >= b.z} } +@(require_results) greaterThanEqual_dvec3 :: proc "c" (a, b: dvec3) -> bvec3 { return {a.x >= b.x, a.y >= b.y, a.z >= b.z} } +@(require_results) greaterThanEqual_ivec3 :: proc "c" (a, b: ivec3) -> bvec3 { return {a.x >= b.x, a.y >= b.y, a.z >= b.z} } +@(require_results) greaterThanEqual_uvec3 :: proc "c" (a, b: uvec3) -> bvec3 { return {a.x >= b.x, a.y >= b.y, a.z >= b.z} } +@(require_results) greaterThanEqual_vec4 :: proc "c" (a, b: vec4) -> bvec4 { return {a.x >= b.x, a.y >= b.y, a.z >= b.z, a.w >= b.w} } +@(require_results) greaterThanEqual_dvec4 :: proc "c" (a, b: dvec4) -> bvec4 { return {a.x >= b.x, a.y >= b.y, a.z >= b.z, a.w >= b.w} } +@(require_results) greaterThanEqual_ivec4 :: proc "c" (a, b: ivec4) -> bvec4 { return {a.x >= b.x, a.y >= b.y, a.z >= b.z, a.w >= b.w} } +@(require_results) greaterThanEqual_uvec4 :: proc "c" (a, b: uvec4) -> bvec4 { return {a.x >= b.x, a.y >= b.y, a.z >= b.z, a.w >= b.w} } equal :: proc{ @@ -1264,22 +1264,22 @@ equal :: proc{ equal_ivec4, equal_uvec4, } -equal_f32 :: proc "c" (a, b: f32) -> bool { return a == b } -equal_f64 :: proc "c" (a, b: f64) -> bool { return a == b } -equal_i32 :: proc "c" (a, b: i32) -> bool { return a == b } -equal_u32 :: proc "c" (a, b: u32) -> bool { return a == b } -equal_vec2 :: proc "c" (a, b: vec2) -> bvec2 { return {a.x == b.x, a.y == b.y} } -equal_dvec2 :: proc "c" (a, b: dvec2) -> bvec2 { return {a.x == b.x, a.y == b.y} } -equal_ivec2 :: proc "c" (a, b: ivec2) -> bvec2 { return {a.x == b.x, a.y == b.y} } -equal_uvec2 :: proc "c" (a, b: uvec2) -> bvec2 { return {a.x == b.x, a.y == b.y} } -equal_vec3 :: proc "c" (a, b: vec3) -> bvec3 { return {a.x == b.x, a.y == b.y, a.z == b.z} } -equal_dvec3 :: proc "c" (a, b: dvec3) -> bvec3 { return {a.x == b.x, a.y == b.y, a.z == b.z} } -equal_ivec3 :: proc "c" (a, b: ivec3) -> bvec3 { return {a.x == b.x, a.y == b.y, a.z == b.z} } -equal_uvec3 :: proc "c" (a, b: uvec3) -> bvec3 { return {a.x == b.x, a.y == b.y, a.z == b.z} } -equal_vec4 :: proc "c" (a, b: vec4) -> bvec4 { return {a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w} } -equal_dvec4 :: proc "c" (a, b: dvec4) -> bvec4 { return {a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w} } -equal_ivec4 :: proc "c" (a, b: ivec4) -> bvec4 { return {a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w} } -equal_uvec4 :: proc "c" (a, b: uvec4) -> bvec4 { return {a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w} } +@(require_results) equal_f32 :: proc "c" (a, b: f32) -> bool { return a == b } +@(require_results) equal_f64 :: proc "c" (a, b: f64) -> bool { return a == b } +@(require_results) equal_i32 :: proc "c" (a, b: i32) -> bool { return a == b } +@(require_results) equal_u32 :: proc "c" (a, b: u32) -> bool { return a == b } +@(require_results) equal_vec2 :: proc "c" (a, b: vec2) -> bvec2 { return {a.x == b.x, a.y == b.y} } +@(require_results) equal_dvec2 :: proc "c" (a, b: dvec2) -> bvec2 { return {a.x == b.x, a.y == b.y} } +@(require_results) equal_ivec2 :: proc "c" (a, b: ivec2) -> bvec2 { return {a.x == b.x, a.y == b.y} } +@(require_results) equal_uvec2 :: proc "c" (a, b: uvec2) -> bvec2 { return {a.x == b.x, a.y == b.y} } +@(require_results) equal_vec3 :: proc "c" (a, b: vec3) -> bvec3 { return {a.x == b.x, a.y == b.y, a.z == b.z} } +@(require_results) equal_dvec3 :: proc "c" (a, b: dvec3) -> bvec3 { return {a.x == b.x, a.y == b.y, a.z == b.z} } +@(require_results) equal_ivec3 :: proc "c" (a, b: ivec3) -> bvec3 { return {a.x == b.x, a.y == b.y, a.z == b.z} } +@(require_results) equal_uvec3 :: proc "c" (a, b: uvec3) -> bvec3 { return {a.x == b.x, a.y == b.y, a.z == b.z} } +@(require_results) equal_vec4 :: proc "c" (a, b: vec4) -> bvec4 { return {a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w} } +@(require_results) equal_dvec4 :: proc "c" (a, b: dvec4) -> bvec4 { return {a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w} } +@(require_results) equal_ivec4 :: proc "c" (a, b: ivec4) -> bvec4 { return {a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w} } +@(require_results) equal_uvec4 :: proc "c" (a, b: uvec4) -> bvec4 { return {a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w} } notEqual :: proc{ notEqual_f32, @@ -1299,22 +1299,22 @@ notEqual :: proc{ notEqual_ivec4, notEqual_uvec4, } -notEqual_f32 :: proc "c" (a, b: f32) -> bool { return a != b } -notEqual_f64 :: proc "c" (a, b: f64) -> bool { return a != b } -notEqual_i32 :: proc "c" (a, b: i32) -> bool { return a != b } -notEqual_u32 :: proc "c" (a, b: u32) -> bool { return a != b } -notEqual_vec2 :: proc "c" (a, b: vec2) -> bvec2 { return {a.x != b.x, a.y != b.y} } -notEqual_dvec2 :: proc "c" (a, b: dvec2) -> bvec2 { return {a.x != b.x, a.y != b.y} } -notEqual_ivec2 :: proc "c" (a, b: ivec2) -> bvec2 { return {a.x != b.x, a.y != b.y} } -notEqual_uvec2 :: proc "c" (a, b: uvec2) -> bvec2 { return {a.x != b.x, a.y != b.y} } -notEqual_vec3 :: proc "c" (a, b: vec3) -> bvec3 { return {a.x != b.x, a.y != b.y, a.z != b.z} } -notEqual_dvec3 :: proc "c" (a, b: dvec3) -> bvec3 { return {a.x != b.x, a.y != b.y, a.z != b.z} } -notEqual_ivec3 :: proc "c" (a, b: ivec3) -> bvec3 { return {a.x != b.x, a.y != b.y, a.z != b.z} } -notEqual_uvec3 :: proc "c" (a, b: uvec3) -> bvec3 { return {a.x != b.x, a.y != b.y, a.z != b.z} } -notEqual_vec4 :: proc "c" (a, b: vec4) -> bvec4 { return {a.x != b.x, a.y != b.y, a.z != b.z, a.w != b.w} } -notEqual_dvec4 :: proc "c" (a, b: dvec4) -> bvec4 { return {a.x != b.x, a.y != b.y, a.z != b.z, a.w != b.w} } -notEqual_ivec4 :: proc "c" (a, b: ivec4) -> bvec4 { return {a.x != b.x, a.y != b.y, a.z != b.z, a.w != b.w} } -notEqual_uvec4 :: proc "c" (a, b: uvec4) -> bvec4 { return {a.x != b.x, a.y != b.y, a.z != b.z, a.w != b.w} } +@(require_results) notEqual_f32 :: proc "c" (a, b: f32) -> bool { return a != b } +@(require_results) notEqual_f64 :: proc "c" (a, b: f64) -> bool { return a != b } +@(require_results) notEqual_i32 :: proc "c" (a, b: i32) -> bool { return a != b } +@(require_results) notEqual_u32 :: proc "c" (a, b: u32) -> bool { return a != b } +@(require_results) notEqual_vec2 :: proc "c" (a, b: vec2) -> bvec2 { return {a.x != b.x, a.y != b.y} } +@(require_results) notEqual_dvec2 :: proc "c" (a, b: dvec2) -> bvec2 { return {a.x != b.x, a.y != b.y} } +@(require_results) notEqual_ivec2 :: proc "c" (a, b: ivec2) -> bvec2 { return {a.x != b.x, a.y != b.y} } +@(require_results) notEqual_uvec2 :: proc "c" (a, b: uvec2) -> bvec2 { return {a.x != b.x, a.y != b.y} } +@(require_results) notEqual_vec3 :: proc "c" (a, b: vec3) -> bvec3 { return {a.x != b.x, a.y != b.y, a.z != b.z} } +@(require_results) notEqual_dvec3 :: proc "c" (a, b: dvec3) -> bvec3 { return {a.x != b.x, a.y != b.y, a.z != b.z} } +@(require_results) notEqual_ivec3 :: proc "c" (a, b: ivec3) -> bvec3 { return {a.x != b.x, a.y != b.y, a.z != b.z} } +@(require_results) notEqual_uvec3 :: proc "c" (a, b: uvec3) -> bvec3 { return {a.x != b.x, a.y != b.y, a.z != b.z} } +@(require_results) notEqual_vec4 :: proc "c" (a, b: vec4) -> bvec4 { return {a.x != b.x, a.y != b.y, a.z != b.z, a.w != b.w} } +@(require_results) notEqual_dvec4 :: proc "c" (a, b: dvec4) -> bvec4 { return {a.x != b.x, a.y != b.y, a.z != b.z, a.w != b.w} } +@(require_results) notEqual_ivec4 :: proc "c" (a, b: ivec4) -> bvec4 { return {a.x != b.x, a.y != b.y, a.z != b.z, a.w != b.w} } +@(require_results) notEqual_uvec4 :: proc "c" (a, b: uvec4) -> bvec4 { return {a.x != b.x, a.y != b.y, a.z != b.z, a.w != b.w} } any :: proc{ @@ -1323,10 +1323,10 @@ any :: proc{ any_bvec3, any_bvec4, } -any_bool :: proc "c" (v: bool) -> bool { return v } -any_bvec2 :: proc "c" (v: bvec2) -> bool { return v.x || v.y } -any_bvec3 :: proc "c" (v: bvec3) -> bool { return v.x || v.y || v.z } -any_bvec4 :: proc "c" (v: bvec4) -> bool { return v.x || v.y || v.z || v.w } +@(require_results) any_bool :: proc "c" (v: bool) -> bool { return v } +@(require_results) any_bvec2 :: proc "c" (v: bvec2) -> bool { return v.x || v.y } +@(require_results) any_bvec3 :: proc "c" (v: bvec3) -> bool { return v.x || v.y || v.z } +@(require_results) any_bvec4 :: proc "c" (v: bvec4) -> bool { return v.x || v.y || v.z || v.w } all :: proc{ all_bool, @@ -1334,10 +1334,10 @@ all :: proc{ all_bvec3, all_bvec4, } -all_bool :: proc "c" (v: bool) -> bool { return v } -all_bvec2 :: proc "c" (v: bvec2) -> bool { return v.x && v.y } -all_bvec3 :: proc "c" (v: bvec3) -> bool { return v.x && v.y && v.z } -all_bvec4 :: proc "c" (v: bvec4) -> bool { return v.x && v.y && v.z && v.w } +@(require_results) all_bool :: proc "c" (v: bool) -> bool { return v } +@(require_results) all_bvec2 :: proc "c" (v: bvec2) -> bool { return v.x && v.y } +@(require_results) all_bvec3 :: proc "c" (v: bvec3) -> bool { return v.x && v.y && v.z } +@(require_results) all_bvec4 :: proc "c" (v: bvec4) -> bool { return v.x && v.y && v.z && v.w } not :: proc{ not_bool, @@ -1345,17 +1345,18 @@ not :: proc{ not_bvec3, not_bvec4, } -not_bool :: proc "c" (v: bool) -> bool { return !v } -not_bvec2 :: proc "c" (v: bvec2) -> bvec2 { return {!v.x, !v.y} } -not_bvec3 :: proc "c" (v: bvec3) -> bvec3 { return {!v.x, !v.y, !v.z} } -not_bvec4 :: proc "c" (v: bvec4) -> bvec4 { return {!v.x, !v.y, !v.z, !v.w} } +@(require_results) not_bool :: proc "c" (v: bool) -> bool { return !v } +@(require_results) not_bvec2 :: proc "c" (v: bvec2) -> bvec2 { return {!v.x, !v.y} } +@(require_results) not_bvec3 :: proc "c" (v: bvec3) -> bvec3 { return {!v.x, !v.y, !v.z} } +@(require_results) not_bvec4 :: proc "c" (v: bvec4) -> bvec4 { return {!v.x, !v.y, !v.z, !v.w} } /// Matrix Utilities -identity :: proc "c" ($M: typeid/matrix[$N, N]$T) -> M { return 1 } +@(require_results) identity :: proc "c" ($M: typeid/matrix[$N, N]$T) -> M { return 1 } +@(require_results) mat4Perspective :: proc "c" (fovy, aspect, near, far: f32) -> (m: mat4) { tan_half_fovy := tan(0.5 * fovy) m[0, 0] = 1 / (aspect*tan_half_fovy) @@ -1365,6 +1366,7 @@ mat4Perspective :: proc "c" (fovy, aspect, near, far: f32) -> (m: mat4) { m[2, 3] = -2*far*near / (far - near) return } +@(require_results) mat4PerspectiveInfinite :: proc "c" (fovy, aspect, near: f32) -> (m: mat4) { tan_half_fovy := tan(0.5 * fovy) m[0, 0] = 1 / (aspect*tan_half_fovy) @@ -1374,6 +1376,7 @@ mat4PerspectiveInfinite :: proc "c" (fovy, aspect, near: f32) -> (m: mat4) { m[2, 3] = -2*near return } +@(require_results) mat4Ortho3d :: proc "c" (left, right, bottom, top, near, far: f32) -> (m: mat4) { m[0, 0] = +2 / (right - left) m[1, 1] = +2 / (top - bottom) @@ -1384,6 +1387,7 @@ mat4Ortho3d :: proc "c" (left, right, bottom, top, near, far: f32) -> (m: mat4) m[3, 3] = 1 return m } +@(require_results) mat4LookAt :: proc "c" (eye, centre, up: vec3) -> (m: mat4) { f := normalize(centre - eye) s := normalize(cross(f, up)) @@ -1397,6 +1401,7 @@ mat4LookAt :: proc "c" (eye, centre, up: vec3) -> (m: mat4) { m[3] = {-dot(s, eye), -dot(u, eye), +fe, 1} return } +@(require_results) mat4Rotate :: proc "c" (v: vec3, radians: f32) -> (rot: mat4) { c := cos(radians) s := sin(radians) @@ -1423,11 +1428,13 @@ mat4Rotate :: proc "c" (v: vec3, radians: f32) -> (rot: mat4) { return rot } +@(require_results) mat4Translate :: proc "c" (v: vec3) -> (m: mat4) { m = 1 m[3].xyz = v.xyz return } +@(require_results) mat4Scale :: proc "c" (v: vec3) -> (m: mat4) { m[0, 0] = v[0] m[1, 1] = v[1] @@ -1435,6 +1442,7 @@ mat4Scale :: proc "c" (v: vec3) -> (m: mat4) { m[3, 3] = 1 return } +@(require_results) mat4Orientation :: proc "c" (normal, up: vec3) -> mat4 { if normal == up { return 1 @@ -1445,6 +1453,7 @@ mat4Orientation :: proc "c" (normal, up: vec3) -> mat4 { return mat4Rotate(rotation_axis, angle) } +@(require_results) mat4FromQuat :: proc "c" (q: quat) -> (m: mat4) { qxx := q.x * q.x qyy := q.y * q.y @@ -1474,6 +1483,7 @@ mat4FromQuat :: proc "c" (q: quat) -> (m: mat4) { } +@(require_results) dmat4Perspective :: proc "c" (fovy, aspect, near, far: f64) -> (m: dmat4) { tan_half_fovy := tan(0.5 * fovy) m[0, 0] = 1 / (aspect*tan_half_fovy) @@ -1483,6 +1493,7 @@ dmat4Perspective :: proc "c" (fovy, aspect, near, far: f64) -> (m: dmat4) { m[2, 3] = -2*far*near / (far - near) return } +@(require_results) dmat4PerspectiveInfinite :: proc "c" (fovy, aspect, near: f64) -> (m: dmat4) { tan_half_fovy := tan(0.5 * fovy) m[0, 0] = 1 / (aspect*tan_half_fovy) @@ -1492,6 +1503,7 @@ dmat4PerspectiveInfinite :: proc "c" (fovy, aspect, near: f64) -> (m: dmat4) { m[2, 3] = -2*near return } +@(require_results) dmat4Ortho3d :: proc "c" (left, right, bottom, top, near, far: f64) -> (m: dmat4) { m[0, 0] = +2 / (right - left) m[1, 1] = +2 / (top - bottom) @@ -1502,6 +1514,7 @@ dmat4Ortho3d :: proc "c" (left, right, bottom, top, near, far: f64) -> (m: dmat4 m[3, 3] = 1 return m } +@(require_results) dmat4LookAt :: proc "c" (eye, centre, up: dvec3) -> (m: dmat4) { f := normalize(centre - eye) s := normalize(cross(f, up)) @@ -1515,6 +1528,7 @@ dmat4LookAt :: proc "c" (eye, centre, up: dvec3) -> (m: dmat4) { m[3] = {-dot(s, eye), -dot(u, eye), +fe, 1} return } +@(require_results) dmat4Rotate :: proc "c" (v: dvec3, radians: f64) -> (rot: dmat4) { c := cos(radians) s := sin(radians) @@ -1541,11 +1555,13 @@ dmat4Rotate :: proc "c" (v: dvec3, radians: f64) -> (rot: dmat4) { return rot } +@(require_results) dmat4Translate :: proc "c" (v: dvec3) -> (m: dmat4) { m = 1 m[3].xyz = v.xyz return } +@(require_results) dmat4Scale :: proc "c" (v: dvec3) -> (m: dmat4) { m[0, 0] = v[0] m[1, 1] = v[1] @@ -1553,6 +1569,7 @@ dmat4Scale :: proc "c" (v: dvec3) -> (m: dmat4) { m[3, 3] = 1 return } +@(require_results) dmat4Orientation :: proc "c" (normal, up: dvec3) -> dmat4 { if normal == up { return 1 @@ -1563,6 +1580,7 @@ dmat4Orientation :: proc "c" (normal, up: dvec3) -> dmat4 { return dmat4Rotate(rotation_axis, angle) } +@(require_results) dmat4FromDquat :: proc "c" (q: dquat) -> (m: dmat4) { qxx := q.x * q.x qyy := q.y * q.y @@ -1601,6 +1619,7 @@ slerp :: proc{ } +@(require_results) quatAxisAngle :: proc "c" (axis: vec3, radians: f32) -> (q: quat) { t := radians*0.5 v := normalize(axis) * sin(t) @@ -1610,6 +1629,7 @@ quatAxisAngle :: proc "c" (axis: vec3, radians: f32) -> (q: quat) { q.w = cos(t) return } +@(require_results) quatNlerp :: proc "c" (a, b: quat, t: f32) -> (c: quat) { c.x = a.x + (b.x-a.x)*t c.y = a.y + (b.y-a.y)*t @@ -1618,6 +1638,7 @@ quatNlerp :: proc "c" (a, b: quat, t: f32) -> (c: quat) { return c/quat(builtin.abs(c)) } +@(require_results) quatSlerp :: proc "c" (x, y: quat, t: f32) -> (q: quat) { a, b := x, y cos_angle := dot(a, b) @@ -1644,6 +1665,7 @@ quatSlerp :: proc "c" (x, y: quat, t: f32) -> (q: quat) { q.w = factor_a * a.w + factor_b * b.w return } +@(require_results) quatFromMat3 :: proc "c" (m: mat3) -> (q: quat) { four_x_squared_minus_1 := m[0, 0] - m[1, 1] - m[2, 2] four_y_squared_minus_1 := m[1, 1] - m[0, 0] - m[2, 2] @@ -1693,16 +1715,19 @@ quatFromMat3 :: proc "c" (m: mat3) -> (q: quat) { } return } +@(require_results) quatFromMat4 :: proc "c" (m: mat4) -> (q: quat) { return quatFromMat3(mat3(m)) } +@(require_results) quatMulVec3 :: proc "c" (q: quat, v: vec3) -> vec3 { xyz := vec3{q.x, q.y, q.z} t := cross(xyz, v) return v + q.w*t + cross(xyz, t) } +@(require_results) dquatAxisAngle :: proc "c" (axis: dvec3, radians: f64) -> (q: dquat) { t := radians*0.5 v := normalize(axis) * sin(t) @@ -1712,6 +1737,7 @@ dquatAxisAngle :: proc "c" (axis: dvec3, radians: f64) -> (q: dquat) { q.w = cos(t) return } +@(require_results) dquatNlerp :: proc "c" (a, b: dquat, t: f64) -> (c: dquat) { c.x = a.x + (b.x-a.x)*t c.y = a.y + (b.y-a.y)*t @@ -1720,6 +1746,7 @@ dquatNlerp :: proc "c" (a, b: dquat, t: f64) -> (c: dquat) { return c/dquat(builtin.abs(c)) } +@(require_results) dquatSlerp :: proc "c" (x, y: dquat, t: f64) -> (q: dquat) { a, b := x, y cos_angle := dot(a, b) @@ -1746,6 +1773,7 @@ dquatSlerp :: proc "c" (x, y: dquat, t: f64) -> (q: dquat) { q.w = factor_a * a.w + factor_b * b.w return } +@(require_results) dquatFromdMat3 :: proc "c" (m: dmat3) -> (q: dquat) { four_x_squared_minus_1 := m[0, 0] - m[1, 1] - m[2, 2] four_y_squared_minus_1 := m[1, 1] - m[0, 0] - m[2, 2] @@ -1795,10 +1823,12 @@ dquatFromdMat3 :: proc "c" (m: dmat3) -> (q: dquat) { } return } +@(require_results) dquatFromDmat4 :: proc "c" (m: dmat4) -> (q: dquat) { return dquatFromdMat3(dmat3(m)) } +@(require_results) dquatMulDvec3 :: proc "c" (q: dquat, v: dvec3) -> dvec3 { xyz := dvec3{q.x, q.y, q.z} t := cross(xyz, v) @@ -1808,14 +1838,14 @@ dquatMulDvec3 :: proc "c" (q: dquat, v: dvec3) -> dvec3 { -inverse_mat2 :: proc "c" (m: mat2) -> mat2 { return builtin.inverse(m) } -inverse_mat3 :: proc "c" (m: mat3) -> mat3 { return builtin.inverse(m) } -inverse_mat4 :: proc "c" (m: mat4) -> mat4 { return builtin.inverse(m) } -inverse_dmat2 :: proc "c" (m: dmat2) -> dmat2 { return builtin.inverse(m) } -inverse_dmat3 :: proc "c" (m: dmat3) -> dmat3 { return builtin.inverse(m) } -inverse_dmat4 :: proc "c" (m: dmat4) -> dmat4 { return builtin.inverse(m) } -inverse_quat :: proc "c" (q: quat) -> quat { return 1/q } -inverse_dquat :: proc "c" (q: dquat) -> dquat { return 1/q } +@(require_results) inverse_mat2 :: proc "c" (m: mat2) -> mat2 { return builtin.inverse(m) } +@(require_results) inverse_mat3 :: proc "c" (m: mat3) -> mat3 { return builtin.inverse(m) } +@(require_results) inverse_mat4 :: proc "c" (m: mat4) -> mat4 { return builtin.inverse(m) } +@(require_results) inverse_dmat2 :: proc "c" (m: dmat2) -> dmat2 { return builtin.inverse(m) } +@(require_results) inverse_dmat3 :: proc "c" (m: dmat3) -> dmat3 { return builtin.inverse(m) } +@(require_results) inverse_dmat4 :: proc "c" (m: dmat4) -> dmat4 { return builtin.inverse(m) } +@(require_results) inverse_quat :: proc "c" (q: quat) -> quat { return 1/q } +@(require_results) inverse_dquat :: proc "c" (q: dquat) -> dquat { return 1/q } inverse :: proc{ inverse_mat2, diff --git a/core/math/linalg/glsl/linalg_glsl_math.odin b/core/math/linalg/glsl/linalg_glsl_math.odin index 968a3fa5e..82b1857ab 100644 --- a/core/math/linalg/glsl/linalg_glsl_math.odin +++ b/core/math/linalg/glsl/linalg_glsl_math.odin @@ -2,30 +2,31 @@ package math_linalg_glsl import "core:math" -cos_f32 :: proc "c" (x: f32) -> f32 { return math.cos(x) } -sin_f32 :: proc "c" (x: f32) -> f32 { return math.sin(x) } -tan_f32 :: proc "c" (x: f32) -> f32 { return math.tan(x) } -acos_f32 :: proc "c" (x: f32) -> f32 { return math.acos(x) } -asin_f32 :: proc "c" (x: f32) -> f32 { return math.asin(x) } -atan_f32 :: proc "c" (x: f32) -> f32 { return math.atan(x) } -atan2_f32 :: proc "c" (y, x: f32) -> f32 { return math.atan2(y, x) } -cosh_f32 :: proc "c" (x: f32) -> f32 { return math.cosh(x) } -sinh_f32 :: proc "c" (x: f32) -> f32 { return math.sinh(x) } -tanh_f32 :: proc "c" (x: f32) -> f32 { return math.tanh(x) } -acosh_f32 :: proc "c" (x: f32) -> f32 { return math.acosh(x) } -asinh_f32 :: proc "c" (x: f32) -> f32 { return math.asinh(x) } -atanh_f32 :: proc "c" (x: f32) -> f32 { return math.atanh(x) } -sqrt_f32 :: proc "c" (x: f32) -> f32 { return math.sqrt(x) } -inversesqrt_f32 :: proc "c" (x: f32) -> f32 { return 1.0/math.sqrt(x) } -pow_f32 :: proc "c" (x, y: f32) -> f32 { return math.pow(x, y) } -exp_f32 :: proc "c" (x: f32) -> f32 { return math.exp(x) } -log_f32 :: proc "c" (x: f32) -> f32 { return math.ln(x) } -exp2_f32 :: proc "c" (x: f32) -> f32 { return math.pow(f32(2), x) } -sign_f32 :: proc "c" (x: f32) -> f32 { return math.sign(x) } -floor_f32 :: proc "c" (x: f32) -> f32 { return math.floor(x) } -round_f32 :: proc "c" (x: f32) -> f32 { return math.round(x) } -ceil_f32 :: proc "c" (x: f32) -> f32 { return math.ceil(x) } -mod_f32 :: proc "c" (x, y: f32) -> f32 { return math.mod(x, y) } +@(require_results) cos_f32 :: proc "c" (x: f32) -> f32 { return math.cos(x) } +@(require_results) sin_f32 :: proc "c" (x: f32) -> f32 { return math.sin(x) } +@(require_results) tan_f32 :: proc "c" (x: f32) -> f32 { return math.tan(x) } +@(require_results) acos_f32 :: proc "c" (x: f32) -> f32 { return math.acos(x) } +@(require_results) asin_f32 :: proc "c" (x: f32) -> f32 { return math.asin(x) } +@(require_results) atan_f32 :: proc "c" (x: f32) -> f32 { return math.atan(x) } +@(require_results) atan2_f32 :: proc "c" (y, x: f32) -> f32 { return math.atan2(y, x) } +@(require_results) cosh_f32 :: proc "c" (x: f32) -> f32 { return math.cosh(x) } +@(require_results) sinh_f32 :: proc "c" (x: f32) -> f32 { return math.sinh(x) } +@(require_results) tanh_f32 :: proc "c" (x: f32) -> f32 { return math.tanh(x) } +@(require_results) acosh_f32 :: proc "c" (x: f32) -> f32 { return math.acosh(x) } +@(require_results) asinh_f32 :: proc "c" (x: f32) -> f32 { return math.asinh(x) } +@(require_results) atanh_f32 :: proc "c" (x: f32) -> f32 { return math.atanh(x) } +@(require_results) sqrt_f32 :: proc "c" (x: f32) -> f32 { return math.sqrt(x) } +@(require_results) inversesqrt_f32 :: proc "c" (x: f32) -> f32 { return 1.0/math.sqrt(x) } +@(require_results) pow_f32 :: proc "c" (x, y: f32) -> f32 { return math.pow(x, y) } +@(require_results) exp_f32 :: proc "c" (x: f32) -> f32 { return math.exp(x) } +@(require_results) log_f32 :: proc "c" (x: f32) -> f32 { return math.ln(x) } +@(require_results) exp2_f32 :: proc "c" (x: f32) -> f32 { return math.pow(f32(2), x) } +@(require_results) sign_f32 :: proc "c" (x: f32) -> f32 { return math.sign(x) } +@(require_results) floor_f32 :: proc "c" (x: f32) -> f32 { return math.floor(x) } +@(require_results) round_f32 :: proc "c" (x: f32) -> f32 { return math.round(x) } +@(require_results) ceil_f32 :: proc "c" (x: f32) -> f32 { return math.ceil(x) } +@(require_results) mod_f32 :: proc "c" (x, y: f32) -> f32 { return math.mod(x, y) } +@(require_results) fract_f32 :: proc "c" (x: f32) -> f32 { if x >= 0 { return x - math.trunc(x) @@ -33,30 +34,31 @@ fract_f32 :: proc "c" (x: f32) -> f32 { return math.trunc(-x) + x } -cos_f64 :: proc "c" (x: f64) -> f64 { return math.cos(x) } -sin_f64 :: proc "c" (x: f64) -> f64 { return math.sin(x) } -tan_f64 :: proc "c" (x: f64) -> f64 { return math.tan(x) } -acos_f64 :: proc "c" (x: f64) -> f64 { return math.acos(x) } -asin_f64 :: proc "c" (x: f64) -> f64 { return math.asin(x) } -atan_f64 :: proc "c" (x: f64) -> f64 { return math.atan(x) } -atan2_f64 :: proc "c" (y, x: f64) -> f64 { return math.atan2(y, x) } -cosh_f64 :: proc "c" (x: f64) -> f64 { return math.cosh(x) } -sinh_f64 :: proc "c" (x: f64) -> f64 { return math.sinh(x) } -tanh_f64 :: proc "c" (x: f64) -> f64 { return math.tanh(x) } -acosh_f64 :: proc "c" (x: f64) -> f64 { return math.acosh(x) } -asinh_f64 :: proc "c" (x: f64) -> f64 { return math.asinh(x) } -atanh_f64 :: proc "c" (x: f64) -> f64 { return math.atanh(x) } -sqrt_f64 :: proc "c" (x: f64) -> f64 { return math.sqrt(x) } -inversesqrt_f64 :: proc "c" (x: f64) -> f64 { return 1.0/math.sqrt(x) } -pow_f64 :: proc "c" (x, y: f64) -> f64 { return math.pow(x, y) } -exp_f64 :: proc "c" (x: f64) -> f64 { return math.exp(x) } -log_f64 :: proc "c" (x: f64) -> f64 { return math.ln(x) } -exp2_f64 :: proc "c" (x: f64) -> f64 { return math.pow(f64(2), x) } -sign_f64 :: proc "c" (x: f64) -> f64 { return math.sign(x) } -floor_f64 :: proc "c" (x: f64) -> f64 { return math.floor(x) } -round_f64 :: proc "c" (x: f64) -> f64 { return math.round(x) } -ceil_f64 :: proc "c" (x: f64) -> f64 { return math.ceil(x) } -mod_f64 :: proc "c" (x, y: f64) -> f64 { return math.mod(x, y) } +@(require_results) cos_f64 :: proc "c" (x: f64) -> f64 { return math.cos(x) } +@(require_results) sin_f64 :: proc "c" (x: f64) -> f64 { return math.sin(x) } +@(require_results) tan_f64 :: proc "c" (x: f64) -> f64 { return math.tan(x) } +@(require_results) acos_f64 :: proc "c" (x: f64) -> f64 { return math.acos(x) } +@(require_results) asin_f64 :: proc "c" (x: f64) -> f64 { return math.asin(x) } +@(require_results) atan_f64 :: proc "c" (x: f64) -> f64 { return math.atan(x) } +@(require_results) atan2_f64 :: proc "c" (y, x: f64) -> f64 { return math.atan2(y, x) } +@(require_results) cosh_f64 :: proc "c" (x: f64) -> f64 { return math.cosh(x) } +@(require_results) sinh_f64 :: proc "c" (x: f64) -> f64 { return math.sinh(x) } +@(require_results) tanh_f64 :: proc "c" (x: f64) -> f64 { return math.tanh(x) } +@(require_results) acosh_f64 :: proc "c" (x: f64) -> f64 { return math.acosh(x) } +@(require_results) asinh_f64 :: proc "c" (x: f64) -> f64 { return math.asinh(x) } +@(require_results) atanh_f64 :: proc "c" (x: f64) -> f64 { return math.atanh(x) } +@(require_results) sqrt_f64 :: proc "c" (x: f64) -> f64 { return math.sqrt(x) } +@(require_results) inversesqrt_f64 :: proc "c" (x: f64) -> f64 { return 1.0/math.sqrt(x) } +@(require_results) pow_f64 :: proc "c" (x, y: f64) -> f64 { return math.pow(x, y) } +@(require_results) exp_f64 :: proc "c" (x: f64) -> f64 { return math.exp(x) } +@(require_results) log_f64 :: proc "c" (x: f64) -> f64 { return math.ln(x) } +@(require_results) exp2_f64 :: proc "c" (x: f64) -> f64 { return math.pow(f64(2), x) } +@(require_results) sign_f64 :: proc "c" (x: f64) -> f64 { return math.sign(x) } +@(require_results) floor_f64 :: proc "c" (x: f64) -> f64 { return math.floor(x) } +@(require_results) round_f64 :: proc "c" (x: f64) -> f64 { return math.round(x) } +@(require_results) ceil_f64 :: proc "c" (x: f64) -> f64 { return math.ceil(x) } +@(require_results) mod_f64 :: proc "c" (x, y: f64) -> f64 { return math.mod(x, y) } +@(require_results) fract_f64 :: proc "c" (x: f64) -> f64 { if x >= 0 { return x - math.trunc(x) diff --git a/core/math/linalg/hlsl/linalg_hlsl.odin b/core/math/linalg/hlsl/linalg_hlsl.odin index 3f73dcd1f..351aa7ea3 100644 --- a/core/math/linalg/hlsl/linalg_hlsl.odin +++ b/core/math/linalg/hlsl/linalg_hlsl.odin @@ -114,12 +114,12 @@ cos :: proc{ cos_double3, cos_double4, } -cos_float2 :: proc "c" (x: float2) -> float2 { return {cos(x.x), cos(x.y)} } -cos_float3 :: proc "c" (x: float3) -> float3 { return {cos(x.x), cos(x.y), cos(x.z)} } -cos_float4 :: proc "c" (x: float4) -> float4 { return {cos(x.x), cos(x.y), cos(x.z), cos(x.w)} } -cos_double2 :: proc "c" (x: double2) -> double2 { return {cos(x.x), cos(x.y)} } -cos_double3 :: proc "c" (x: double3) -> double3 { return {cos(x.x), cos(x.y), cos(x.z)} } -cos_double4 :: proc "c" (x: double4) -> double4 { return {cos(x.x), cos(x.y), cos(x.z), cos(x.w)} } +@(require_results) cos_float2 :: proc "c" (x: float2) -> float2 { return {cos(x.x), cos(x.y)} } +@(require_results) cos_float3 :: proc "c" (x: float3) -> float3 { return {cos(x.x), cos(x.y), cos(x.z)} } +@(require_results) cos_float4 :: proc "c" (x: float4) -> float4 { return {cos(x.x), cos(x.y), cos(x.z), cos(x.w)} } +@(require_results) cos_double2 :: proc "c" (x: double2) -> double2 { return {cos(x.x), cos(x.y)} } +@(require_results) cos_double3 :: proc "c" (x: double3) -> double3 { return {cos(x.x), cos(x.y), cos(x.z)} } +@(require_results) cos_double4 :: proc "c" (x: double4) -> double4 { return {cos(x.x), cos(x.y), cos(x.z), cos(x.w)} } sin :: proc{ sin_float, @@ -131,12 +131,12 @@ sin :: proc{ sin_double3, sin_double4, } -sin_float2 :: proc "c" (x: float2) -> float2 { return {sin(x.x), sin(x.y)} } -sin_float3 :: proc "c" (x: float3) -> float3 { return {sin(x.x), sin(x.y), sin(x.z)} } -sin_float4 :: proc "c" (x: float4) -> float4 { return {sin(x.x), sin(x.y), sin(x.z), sin(x.w)} } -sin_double2 :: proc "c" (x: double2) -> double2 { return {sin(x.x), sin(x.y)} } -sin_double3 :: proc "c" (x: double3) -> double3 { return {sin(x.x), sin(x.y), sin(x.z)} } -sin_double4 :: proc "c" (x: double4) -> double4 { return {sin(x.x), sin(x.y), sin(x.z), sin(x.w)} } +@(require_results) sin_float2 :: proc "c" (x: float2) -> float2 { return {sin(x.x), sin(x.y)} } +@(require_results) sin_float3 :: proc "c" (x: float3) -> float3 { return {sin(x.x), sin(x.y), sin(x.z)} } +@(require_results) sin_float4 :: proc "c" (x: float4) -> float4 { return {sin(x.x), sin(x.y), sin(x.z), sin(x.w)} } +@(require_results) sin_double2 :: proc "c" (x: double2) -> double2 { return {sin(x.x), sin(x.y)} } +@(require_results) sin_double3 :: proc "c" (x: double3) -> double3 { return {sin(x.x), sin(x.y), sin(x.z)} } +@(require_results) sin_double4 :: proc "c" (x: double4) -> double4 { return {sin(x.x), sin(x.y), sin(x.z), sin(x.w)} } tan :: proc{ tan_float, @@ -148,12 +148,12 @@ tan :: proc{ tan_double3, tan_double4, } -tan_float2 :: proc "c" (x: float2) -> float2 { return {tan(x.x), tan(x.y)} } -tan_float3 :: proc "c" (x: float3) -> float3 { return {tan(x.x), tan(x.y), tan(x.z)} } -tan_float4 :: proc "c" (x: float4) -> float4 { return {tan(x.x), tan(x.y), tan(x.z), tan(x.w)} } -tan_double2 :: proc "c" (x: double2) -> double2 { return {tan(x.x), tan(x.y)} } -tan_double3 :: proc "c" (x: double3) -> double3 { return {tan(x.x), tan(x.y), tan(x.z)} } -tan_double4 :: proc "c" (x: double4) -> double4 { return {tan(x.x), tan(x.y), tan(x.z), tan(x.w)} } +@(require_results) tan_float2 :: proc "c" (x: float2) -> float2 { return {tan(x.x), tan(x.y)} } +@(require_results) tan_float3 :: proc "c" (x: float3) -> float3 { return {tan(x.x), tan(x.y), tan(x.z)} } +@(require_results) tan_float4 :: proc "c" (x: float4) -> float4 { return {tan(x.x), tan(x.y), tan(x.z), tan(x.w)} } +@(require_results) tan_double2 :: proc "c" (x: double2) -> double2 { return {tan(x.x), tan(x.y)} } +@(require_results) tan_double3 :: proc "c" (x: double3) -> double3 { return {tan(x.x), tan(x.y), tan(x.z)} } +@(require_results) tan_double4 :: proc "c" (x: double4) -> double4 { return {tan(x.x), tan(x.y), tan(x.z), tan(x.w)} } acos :: proc{ acos_float, @@ -165,12 +165,12 @@ acos :: proc{ acos_double3, acos_double4, } -acos_float2 :: proc "c" (x: float2) -> float2 { return {acos(x.x), acos(x.y)} } -acos_float3 :: proc "c" (x: float3) -> float3 { return {acos(x.x), acos(x.y), acos(x.z)} } -acos_float4 :: proc "c" (x: float4) -> float4 { return {acos(x.x), acos(x.y), acos(x.z), acos(x.w)} } -acos_double2 :: proc "c" (x: double2) -> double2 { return {acos(x.x), acos(x.y)} } -acos_double3 :: proc "c" (x: double3) -> double3 { return {acos(x.x), acos(x.y), acos(x.z)} } -acos_double4 :: proc "c" (x: double4) -> double4 { return {acos(x.x), acos(x.y), acos(x.z), acos(x.w)} } +@(require_results) acos_float2 :: proc "c" (x: float2) -> float2 { return {acos(x.x), acos(x.y)} } +@(require_results) acos_float3 :: proc "c" (x: float3) -> float3 { return {acos(x.x), acos(x.y), acos(x.z)} } +@(require_results) acos_float4 :: proc "c" (x: float4) -> float4 { return {acos(x.x), acos(x.y), acos(x.z), acos(x.w)} } +@(require_results) acos_double2 :: proc "c" (x: double2) -> double2 { return {acos(x.x), acos(x.y)} } +@(require_results) acos_double3 :: proc "c" (x: double3) -> double3 { return {acos(x.x), acos(x.y), acos(x.z)} } +@(require_results) acos_double4 :: proc "c" (x: double4) -> double4 { return {acos(x.x), acos(x.y), acos(x.z), acos(x.w)} } asin :: proc{ asin_float, @@ -182,12 +182,12 @@ asin :: proc{ asin_double3, asin_double4, } -asin_float2 :: proc "c" (x: float2) -> float2 { return {asin(x.x), asin(x.y)} } -asin_float3 :: proc "c" (x: float3) -> float3 { return {asin(x.x), asin(x.y), asin(x.z)} } -asin_float4 :: proc "c" (x: float4) -> float4 { return {asin(x.x), asin(x.y), asin(x.z), asin(x.w)} } -asin_double2 :: proc "c" (x: double2) -> double2 { return {asin(x.x), asin(x.y)} } -asin_double3 :: proc "c" (x: double3) -> double3 { return {asin(x.x), asin(x.y), asin(x.z)} } -asin_double4 :: proc "c" (x: double4) -> double4 { return {asin(x.x), asin(x.y), asin(x.z), asin(x.w)} } +@(require_results) asin_float2 :: proc "c" (x: float2) -> float2 { return {asin(x.x), asin(x.y)} } +@(require_results) asin_float3 :: proc "c" (x: float3) -> float3 { return {asin(x.x), asin(x.y), asin(x.z)} } +@(require_results) asin_float4 :: proc "c" (x: float4) -> float4 { return {asin(x.x), asin(x.y), asin(x.z), asin(x.w)} } +@(require_results) asin_double2 :: proc "c" (x: double2) -> double2 { return {asin(x.x), asin(x.y)} } +@(require_results) asin_double3 :: proc "c" (x: double3) -> double3 { return {asin(x.x), asin(x.y), asin(x.z)} } +@(require_results) asin_double4 :: proc "c" (x: double4) -> double4 { return {asin(x.x), asin(x.y), asin(x.z), asin(x.w)} } atan :: proc{ atan_float, @@ -207,12 +207,12 @@ atan :: proc{ atan2_double3, atan2_double4, } -atan_float2 :: proc "c" (x: float2) -> float2 { return {atan(x.x), atan(x.y)} } -atan_float3 :: proc "c" (x: float3) -> float3 { return {atan(x.x), atan(x.y), atan(x.z)} } -atan_float4 :: proc "c" (x: float4) -> float4 { return {atan(x.x), atan(x.y), atan(x.z), atan(x.w)} } -atan_double2 :: proc "c" (x: double2) -> double2 { return {atan(x.x), atan(x.y)} } -atan_double3 :: proc "c" (x: double3) -> double3 { return {atan(x.x), atan(x.y), atan(x.z)} } -atan_double4 :: proc "c" (x: double4) -> double4 { return {atan(x.x), atan(x.y), atan(x.z), atan(x.w)} } +@(require_results) atan_float2 :: proc "c" (x: float2) -> float2 { return {atan(x.x), atan(x.y)} } +@(require_results) atan_float3 :: proc "c" (x: float3) -> float3 { return {atan(x.x), atan(x.y), atan(x.z)} } +@(require_results) atan_float4 :: proc "c" (x: float4) -> float4 { return {atan(x.x), atan(x.y), atan(x.z), atan(x.w)} } +@(require_results) atan_double2 :: proc "c" (x: double2) -> double2 { return {atan(x.x), atan(x.y)} } +@(require_results) atan_double3 :: proc "c" (x: double3) -> double3 { return {atan(x.x), atan(x.y), atan(x.z)} } +@(require_results) atan_double4 :: proc "c" (x: double4) -> double4 { return {atan(x.x), atan(x.y), atan(x.z), atan(x.w)} } atan2 :: proc{ atan2_float, @@ -224,12 +224,12 @@ atan2 :: proc{ atan2_double3, atan2_double4, } -atan2_float2 :: proc "c" (y, x: float2) -> float2 { return {atan2(y.x, x.x), atan2(y.y, x.y)} } -atan2_float3 :: proc "c" (y, x: float3) -> float3 { return {atan2(y.x, x.x), atan2(y.y, x.y), atan2(y.z, x.z)} } -atan2_float4 :: proc "c" (y, x: float4) -> float4 { return {atan2(y.x, x.x), atan2(y.y, x.y), atan2(y.z, x.z), atan2(y.w, x.w)} } -atan2_double2 :: proc "c" (y, x: double2) -> double2 { return {atan2(y.x, x.x), atan2(y.y, x.y)} } -atan2_double3 :: proc "c" (y, x: double3) -> double3 { return {atan2(y.x, x.x), atan2(y.y, x.y), atan2(y.z, x.z)} } -atan2_double4 :: proc "c" (y, x: double4) -> double4 { return {atan2(y.x, x.x), atan2(y.y, x.y), atan2(y.z, x.z), atan2(y.w, x.w)} } +@(require_results) atan2_float2 :: proc "c" (y, x: float2) -> float2 { return {atan2(y.x, x.x), atan2(y.y, x.y)} } +@(require_results) atan2_float3 :: proc "c" (y, x: float3) -> float3 { return {atan2(y.x, x.x), atan2(y.y, x.y), atan2(y.z, x.z)} } +@(require_results) atan2_float4 :: proc "c" (y, x: float4) -> float4 { return {atan2(y.x, x.x), atan2(y.y, x.y), atan2(y.z, x.z), atan2(y.w, x.w)} } +@(require_results) atan2_double2 :: proc "c" (y, x: double2) -> double2 { return {atan2(y.x, x.x), atan2(y.y, x.y)} } +@(require_results) atan2_double3 :: proc "c" (y, x: double3) -> double3 { return {atan2(y.x, x.x), atan2(y.y, x.y), atan2(y.z, x.z)} } +@(require_results) atan2_double4 :: proc "c" (y, x: double4) -> double4 { return {atan2(y.x, x.x), atan2(y.y, x.y), atan2(y.z, x.z), atan2(y.w, x.w)} } @@ -243,12 +243,12 @@ cosh :: proc{ cosh_double3, cosh_double4, } -cosh_float2 :: proc "c" (x: float2) -> float2 { return {cosh(x.x), cosh(x.y)} } -cosh_float3 :: proc "c" (x: float3) -> float3 { return {cosh(x.x), cosh(x.y), cosh(x.z)} } -cosh_float4 :: proc "c" (x: float4) -> float4 { return {cosh(x.x), cosh(x.y), cosh(x.z), cosh(x.w)} } -cosh_double2 :: proc "c" (x: double2) -> double2 { return {cosh(x.x), cosh(x.y)} } -cosh_double3 :: proc "c" (x: double3) -> double3 { return {cosh(x.x), cosh(x.y), cosh(x.z)} } -cosh_double4 :: proc "c" (x: double4) -> double4 { return {cosh(x.x), cosh(x.y), cosh(x.z), cosh(x.w)} } +@(require_results) cosh_float2 :: proc "c" (x: float2) -> float2 { return {cosh(x.x), cosh(x.y)} } +@(require_results) cosh_float3 :: proc "c" (x: float3) -> float3 { return {cosh(x.x), cosh(x.y), cosh(x.z)} } +@(require_results) cosh_float4 :: proc "c" (x: float4) -> float4 { return {cosh(x.x), cosh(x.y), cosh(x.z), cosh(x.w)} } +@(require_results) cosh_double2 :: proc "c" (x: double2) -> double2 { return {cosh(x.x), cosh(x.y)} } +@(require_results) cosh_double3 :: proc "c" (x: double3) -> double3 { return {cosh(x.x), cosh(x.y), cosh(x.z)} } +@(require_results) cosh_double4 :: proc "c" (x: double4) -> double4 { return {cosh(x.x), cosh(x.y), cosh(x.z), cosh(x.w)} } sinh :: proc{ @@ -261,12 +261,12 @@ sinh :: proc{ sinh_double3, sinh_double4, } -sinh_float2 :: proc "c" (x: float2) -> float2 { return {sinh(x.x), sinh(x.y)} } -sinh_float3 :: proc "c" (x: float3) -> float3 { return {sinh(x.x), sinh(x.y), sinh(x.z)} } -sinh_float4 :: proc "c" (x: float4) -> float4 { return {sinh(x.x), sinh(x.y), sinh(x.z), sinh(x.w)} } -sinh_double2 :: proc "c" (x: double2) -> double2 { return {sinh(x.x), sinh(x.y)} } -sinh_double3 :: proc "c" (x: double3) -> double3 { return {sinh(x.x), sinh(x.y), sinh(x.z)} } -sinh_double4 :: proc "c" (x: double4) -> double4 { return {sinh(x.x), sinh(x.y), sinh(x.z), sinh(x.w)} } +@(require_results) sinh_float2 :: proc "c" (x: float2) -> float2 { return {sinh(x.x), sinh(x.y)} } +@(require_results) sinh_float3 :: proc "c" (x: float3) -> float3 { return {sinh(x.x), sinh(x.y), sinh(x.z)} } +@(require_results) sinh_float4 :: proc "c" (x: float4) -> float4 { return {sinh(x.x), sinh(x.y), sinh(x.z), sinh(x.w)} } +@(require_results) sinh_double2 :: proc "c" (x: double2) -> double2 { return {sinh(x.x), sinh(x.y)} } +@(require_results) sinh_double3 :: proc "c" (x: double3) -> double3 { return {sinh(x.x), sinh(x.y), sinh(x.z)} } +@(require_results) sinh_double4 :: proc "c" (x: double4) -> double4 { return {sinh(x.x), sinh(x.y), sinh(x.z), sinh(x.w)} } tanh :: proc{ tanh_float, @@ -278,12 +278,12 @@ tanh :: proc{ tanh_double3, tanh_double4, } -tanh_float2 :: proc "c" (x: float2) -> float2 { return {tanh(x.x), tanh(x.y)} } -tanh_float3 :: proc "c" (x: float3) -> float3 { return {tanh(x.x), tanh(x.y), tanh(x.z)} } -tanh_float4 :: proc "c" (x: float4) -> float4 { return {tanh(x.x), tanh(x.y), tanh(x.z), tanh(x.w)} } -tanh_double2 :: proc "c" (x: double2) -> double2 { return {tanh(x.x), tanh(x.y)} } -tanh_double3 :: proc "c" (x: double3) -> double3 { return {tanh(x.x), tanh(x.y), tanh(x.z)} } -tanh_double4 :: proc "c" (x: double4) -> double4 { return {tanh(x.x), tanh(x.y), tanh(x.z), tanh(x.w)} } +@(require_results) tanh_float2 :: proc "c" (x: float2) -> float2 { return {tanh(x.x), tanh(x.y)} } +@(require_results) tanh_float3 :: proc "c" (x: float3) -> float3 { return {tanh(x.x), tanh(x.y), tanh(x.z)} } +@(require_results) tanh_float4 :: proc "c" (x: float4) -> float4 { return {tanh(x.x), tanh(x.y), tanh(x.z), tanh(x.w)} } +@(require_results) tanh_double2 :: proc "c" (x: double2) -> double2 { return {tanh(x.x), tanh(x.y)} } +@(require_results) tanh_double3 :: proc "c" (x: double3) -> double3 { return {tanh(x.x), tanh(x.y), tanh(x.z)} } +@(require_results) tanh_double4 :: proc "c" (x: double4) -> double4 { return {tanh(x.x), tanh(x.y), tanh(x.z), tanh(x.w)} } acosh :: proc{ acosh_float, @@ -295,12 +295,12 @@ acosh :: proc{ acosh_double3, acosh_double4, } -acosh_float2 :: proc "c" (x: float2) -> float2 { return {acosh(x.x), acosh(x.y)} } -acosh_float3 :: proc "c" (x: float3) -> float3 { return {acosh(x.x), acosh(x.y), acosh(x.z)} } -acosh_float4 :: proc "c" (x: float4) -> float4 { return {acosh(x.x), acosh(x.y), acosh(x.z), acosh(x.w)} } -acosh_double2 :: proc "c" (x: double2) -> double2 { return {acosh(x.x), acosh(x.y)} } -acosh_double3 :: proc "c" (x: double3) -> double3 { return {acosh(x.x), acosh(x.y), acosh(x.z)} } -acosh_double4 :: proc "c" (x: double4) -> double4 { return {acosh(x.x), acosh(x.y), acosh(x.z), acosh(x.w)} } +@(require_results) acosh_float2 :: proc "c" (x: float2) -> float2 { return {acosh(x.x), acosh(x.y)} } +@(require_results) acosh_float3 :: proc "c" (x: float3) -> float3 { return {acosh(x.x), acosh(x.y), acosh(x.z)} } +@(require_results) acosh_float4 :: proc "c" (x: float4) -> float4 { return {acosh(x.x), acosh(x.y), acosh(x.z), acosh(x.w)} } +@(require_results) acosh_double2 :: proc "c" (x: double2) -> double2 { return {acosh(x.x), acosh(x.y)} } +@(require_results) acosh_double3 :: proc "c" (x: double3) -> double3 { return {acosh(x.x), acosh(x.y), acosh(x.z)} } +@(require_results) acosh_double4 :: proc "c" (x: double4) -> double4 { return {acosh(x.x), acosh(x.y), acosh(x.z), acosh(x.w)} } asinh :: proc{ asinh_float, @@ -312,12 +312,12 @@ asinh :: proc{ asinh_double3, asinh_double4, } -asinh_float2 :: proc "c" (x: float2) -> float2 { return {asinh(x.x), asinh(x.y)} } -asinh_float3 :: proc "c" (x: float3) -> float3 { return {asinh(x.x), asinh(x.y), asinh(x.z)} } -asinh_float4 :: proc "c" (x: float4) -> float4 { return {asinh(x.x), asinh(x.y), asinh(x.z), asinh(x.w)} } -asinh_double2 :: proc "c" (x: double2) -> double2 { return {asinh(x.x), asinh(x.y)} } -asinh_double3 :: proc "c" (x: double3) -> double3 { return {asinh(x.x), asinh(x.y), asinh(x.z)} } -asinh_double4 :: proc "c" (x: double4) -> double4 { return {asinh(x.x), asinh(x.y), asinh(x.z), asinh(x.w)} } +@(require_results) asinh_float2 :: proc "c" (x: float2) -> float2 { return {asinh(x.x), asinh(x.y)} } +@(require_results) asinh_float3 :: proc "c" (x: float3) -> float3 { return {asinh(x.x), asinh(x.y), asinh(x.z)} } +@(require_results) asinh_float4 :: proc "c" (x: float4) -> float4 { return {asinh(x.x), asinh(x.y), asinh(x.z), asinh(x.w)} } +@(require_results) asinh_double2 :: proc "c" (x: double2) -> double2 { return {asinh(x.x), asinh(x.y)} } +@(require_results) asinh_double3 :: proc "c" (x: double3) -> double3 { return {asinh(x.x), asinh(x.y), asinh(x.z)} } +@(require_results) asinh_double4 :: proc "c" (x: double4) -> double4 { return {asinh(x.x), asinh(x.y), asinh(x.z), asinh(x.w)} } atanh :: proc{ atanh_float, @@ -329,12 +329,12 @@ atanh :: proc{ atanh_double3, atanh_double4, } -atanh_float2 :: proc "c" (x: float2) -> float2 { return {atanh(x.x), atanh(x.y)} } -atanh_float3 :: proc "c" (x: float3) -> float3 { return {atanh(x.x), atanh(x.y), atanh(x.z)} } -atanh_float4 :: proc "c" (x: float4) -> float4 { return {atanh(x.x), atanh(x.y), atanh(x.z), atanh(x.w)} } -atanh_double2 :: proc "c" (x: double2) -> double2 { return {atanh(x.x), atanh(x.y)} } -atanh_double3 :: proc "c" (x: double3) -> double3 { return {atanh(x.x), atanh(x.y), atanh(x.z)} } -atanh_double4 :: proc "c" (x: double4) -> double4 { return {atanh(x.x), atanh(x.y), atanh(x.z), atanh(x.w)} } +@(require_results) atanh_float2 :: proc "c" (x: float2) -> float2 { return {atanh(x.x), atanh(x.y)} } +@(require_results) atanh_float3 :: proc "c" (x: float3) -> float3 { return {atanh(x.x), atanh(x.y), atanh(x.z)} } +@(require_results) atanh_float4 :: proc "c" (x: float4) -> float4 { return {atanh(x.x), atanh(x.y), atanh(x.z), atanh(x.w)} } +@(require_results) atanh_double2 :: proc "c" (x: double2) -> double2 { return {atanh(x.x), atanh(x.y)} } +@(require_results) atanh_double3 :: proc "c" (x: double3) -> double3 { return {atanh(x.x), atanh(x.y), atanh(x.z)} } +@(require_results) atanh_double4 :: proc "c" (x: double4) -> double4 { return {atanh(x.x), atanh(x.y), atanh(x.z), atanh(x.w)} } sqrt :: proc{ sqrt_float, @@ -346,12 +346,12 @@ sqrt :: proc{ sqrt_double3, sqrt_double4, } -sqrt_float2 :: proc "c" (x: float2) -> float2 { return {sqrt(x.x), sqrt(x.y)} } -sqrt_float3 :: proc "c" (x: float3) -> float3 { return {sqrt(x.x), sqrt(x.y), sqrt(x.z)} } -sqrt_float4 :: proc "c" (x: float4) -> float4 { return {sqrt(x.x), sqrt(x.y), sqrt(x.z), sqrt(x.w)} } -sqrt_double2 :: proc "c" (x: double2) -> double2 { return {sqrt(x.x), sqrt(x.y)} } -sqrt_double3 :: proc "c" (x: double3) -> double3 { return {sqrt(x.x), sqrt(x.y), sqrt(x.z)} } -sqrt_double4 :: proc "c" (x: double4) -> double4 { return {sqrt(x.x), sqrt(x.y), sqrt(x.z), sqrt(x.w)} } +@(require_results) sqrt_float2 :: proc "c" (x: float2) -> float2 { return {sqrt(x.x), sqrt(x.y)} } +@(require_results) sqrt_float3 :: proc "c" (x: float3) -> float3 { return {sqrt(x.x), sqrt(x.y), sqrt(x.z)} } +@(require_results) sqrt_float4 :: proc "c" (x: float4) -> float4 { return {sqrt(x.x), sqrt(x.y), sqrt(x.z), sqrt(x.w)} } +@(require_results) sqrt_double2 :: proc "c" (x: double2) -> double2 { return {sqrt(x.x), sqrt(x.y)} } +@(require_results) sqrt_double3 :: proc "c" (x: double3) -> double3 { return {sqrt(x.x), sqrt(x.y), sqrt(x.z)} } +@(require_results) sqrt_double4 :: proc "c" (x: double4) -> double4 { return {sqrt(x.x), sqrt(x.y), sqrt(x.z), sqrt(x.w)} } rsqrt :: proc{ rsqrt_float, @@ -363,12 +363,12 @@ rsqrt :: proc{ rsqrt_double3, rsqrt_double4, } -rsqrt_float2 :: proc "c" (x: float2) -> float2 { return {rsqrt(x.x), rsqrt(x.y)} } -rsqrt_float3 :: proc "c" (x: float3) -> float3 { return {rsqrt(x.x), rsqrt(x.y), rsqrt(x.z)} } -rsqrt_float4 :: proc "c" (x: float4) -> float4 { return {rsqrt(x.x), rsqrt(x.y), rsqrt(x.z), rsqrt(x.w)} } -rsqrt_double2 :: proc "c" (x: double2) -> double2 { return {rsqrt(x.x), rsqrt(x.y)} } -rsqrt_double3 :: proc "c" (x: double3) -> double3 { return {rsqrt(x.x), rsqrt(x.y), rsqrt(x.z)} } -rsqrt_double4 :: proc "c" (x: double4) -> double4 { return {rsqrt(x.x), rsqrt(x.y), rsqrt(x.z), rsqrt(x.w)} } +@(require_results) rsqrt_float2 :: proc "c" (x: float2) -> float2 { return {rsqrt(x.x), rsqrt(x.y)} } +@(require_results) rsqrt_float3 :: proc "c" (x: float3) -> float3 { return {rsqrt(x.x), rsqrt(x.y), rsqrt(x.z)} } +@(require_results) rsqrt_float4 :: proc "c" (x: float4) -> float4 { return {rsqrt(x.x), rsqrt(x.y), rsqrt(x.z), rsqrt(x.w)} } +@(require_results) rsqrt_double2 :: proc "c" (x: double2) -> double2 { return {rsqrt(x.x), rsqrt(x.y)} } +@(require_results) rsqrt_double3 :: proc "c" (x: double3) -> double3 { return {rsqrt(x.x), rsqrt(x.y), rsqrt(x.z)} } +@(require_results) rsqrt_double4 :: proc "c" (x: double4) -> double4 { return {rsqrt(x.x), rsqrt(x.y), rsqrt(x.z), rsqrt(x.w)} } rcp :: proc{ rcp_float, @@ -380,12 +380,12 @@ rcp :: proc{ rcp_double3, rcp_double4, } -rcp_float2 :: proc "c" (x: float2) -> float2 { return {rcp(x.x), rcp(x.y)} } -rcp_float3 :: proc "c" (x: float3) -> float3 { return {rcp(x.x), rcp(x.y), rcp(x.z)} } -rcp_float4 :: proc "c" (x: float4) -> float4 { return {rcp(x.x), rcp(x.y), rcp(x.z), rcp(x.w)} } -rcp_double2 :: proc "c" (x: double2) -> double2 { return {rcp(x.x), rcp(x.y)} } -rcp_double3 :: proc "c" (x: double3) -> double3 { return {rcp(x.x), rcp(x.y), rcp(x.z)} } -rcp_double4 :: proc "c" (x: double4) -> double4 { return {rcp(x.x), rcp(x.y), rcp(x.z), rcp(x.w)} } +@(require_results) rcp_float2 :: proc "c" (x: float2) -> float2 { return {rcp(x.x), rcp(x.y)} } +@(require_results) rcp_float3 :: proc "c" (x: float3) -> float3 { return {rcp(x.x), rcp(x.y), rcp(x.z)} } +@(require_results) rcp_float4 :: proc "c" (x: float4) -> float4 { return {rcp(x.x), rcp(x.y), rcp(x.z), rcp(x.w)} } +@(require_results) rcp_double2 :: proc "c" (x: double2) -> double2 { return {rcp(x.x), rcp(x.y)} } +@(require_results) rcp_double3 :: proc "c" (x: double3) -> double3 { return {rcp(x.x), rcp(x.y), rcp(x.z)} } +@(require_results) rcp_double4 :: proc "c" (x: double4) -> double4 { return {rcp(x.x), rcp(x.y), rcp(x.z), rcp(x.w)} } pow :: proc{ @@ -398,12 +398,12 @@ pow :: proc{ pow_double3, pow_double4, } -pow_float2 :: proc "c" (x, y: float2) -> float2 { return {pow(x.x, y.x), pow(x.y, y.y)} } -pow_float3 :: proc "c" (x, y: float3) -> float3 { return {pow(x.x, y.x), pow(x.y, y.y), pow(x.z, y.z)} } -pow_float4 :: proc "c" (x, y: float4) -> float4 { return {pow(x.x, y.x), pow(x.y, y.y), pow(x.z, y.z), pow(x.w, y.w)} } -pow_double2 :: proc "c" (x, y: double2) -> double2 { return {pow(x.x, y.x), pow(x.y, y.y)} } -pow_double3 :: proc "c" (x, y: double3) -> double3 { return {pow(x.x, y.x), pow(x.y, y.y), pow(x.z, y.z)} } -pow_double4 :: proc "c" (x, y: double4) -> double4 { return {pow(x.x, y.x), pow(x.y, y.y), pow(x.z, y.z), pow(x.w, y.w)} } +@(require_results) pow_float2 :: proc "c" (x, y: float2) -> float2 { return {pow(x.x, y.x), pow(x.y, y.y)} } +@(require_results) pow_float3 :: proc "c" (x, y: float3) -> float3 { return {pow(x.x, y.x), pow(x.y, y.y), pow(x.z, y.z)} } +@(require_results) pow_float4 :: proc "c" (x, y: float4) -> float4 { return {pow(x.x, y.x), pow(x.y, y.y), pow(x.z, y.z), pow(x.w, y.w)} } +@(require_results) pow_double2 :: proc "c" (x, y: double2) -> double2 { return {pow(x.x, y.x), pow(x.y, y.y)} } +@(require_results) pow_double3 :: proc "c" (x, y: double3) -> double3 { return {pow(x.x, y.x), pow(x.y, y.y), pow(x.z, y.z)} } +@(require_results) pow_double4 :: proc "c" (x, y: double4) -> double4 { return {pow(x.x, y.x), pow(x.y, y.y), pow(x.z, y.z), pow(x.w, y.w)} } @@ -417,12 +417,12 @@ exp :: proc{ exp_double3, exp_double4, } -exp_float2 :: proc "c" (x: float2) -> float2 { return {exp(x.x), exp(x.y)} } -exp_float3 :: proc "c" (x: float3) -> float3 { return {exp(x.x), exp(x.y), exp(x.z)} } -exp_float4 :: proc "c" (x: float4) -> float4 { return {exp(x.x), exp(x.y), exp(x.z), exp(x.w)} } -exp_double2 :: proc "c" (x: double2) -> double2 { return {exp(x.x), exp(x.y)} } -exp_double3 :: proc "c" (x: double3) -> double3 { return {exp(x.x), exp(x.y), exp(x.z)} } -exp_double4 :: proc "c" (x: double4) -> double4 { return {exp(x.x), exp(x.y), exp(x.z), exp(x.w)} } +@(require_results) exp_float2 :: proc "c" (x: float2) -> float2 { return {exp(x.x), exp(x.y)} } +@(require_results) exp_float3 :: proc "c" (x: float3) -> float3 { return {exp(x.x), exp(x.y), exp(x.z)} } +@(require_results) exp_float4 :: proc "c" (x: float4) -> float4 { return {exp(x.x), exp(x.y), exp(x.z), exp(x.w)} } +@(require_results) exp_double2 :: proc "c" (x: double2) -> double2 { return {exp(x.x), exp(x.y)} } +@(require_results) exp_double3 :: proc "c" (x: double3) -> double3 { return {exp(x.x), exp(x.y), exp(x.z)} } +@(require_results) exp_double4 :: proc "c" (x: double4) -> double4 { return {exp(x.x), exp(x.y), exp(x.z), exp(x.w)} } @@ -436,12 +436,12 @@ log :: proc{ log_double3, log_double4, } -log_float2 :: proc "c" (x: float2) -> float2 { return {log(x.x), log(x.y)} } -log_float3 :: proc "c" (x: float3) -> float3 { return {log(x.x), log(x.y), log(x.z)} } -log_float4 :: proc "c" (x: float4) -> float4 { return {log(x.x), log(x.y), log(x.z), log(x.w)} } -log_double2 :: proc "c" (x: double2) -> double2 { return {log(x.x), log(x.y)} } -log_double3 :: proc "c" (x: double3) -> double3 { return {log(x.x), log(x.y), log(x.z)} } -log_double4 :: proc "c" (x: double4) -> double4 { return {log(x.x), log(x.y), log(x.z), log(x.w)} } +@(require_results) log_float2 :: proc "c" (x: float2) -> float2 { return {log(x.x), log(x.y)} } +@(require_results) log_float3 :: proc "c" (x: float3) -> float3 { return {log(x.x), log(x.y), log(x.z)} } +@(require_results) log_float4 :: proc "c" (x: float4) -> float4 { return {log(x.x), log(x.y), log(x.z), log(x.w)} } +@(require_results) log_double2 :: proc "c" (x: double2) -> double2 { return {log(x.x), log(x.y)} } +@(require_results) log_double3 :: proc "c" (x: double3) -> double3 { return {log(x.x), log(x.y), log(x.z)} } +@(require_results) log_double4 :: proc "c" (x: double4) -> double4 { return {log(x.x), log(x.y), log(x.z), log(x.w)} } log2 :: proc{ @@ -454,12 +454,12 @@ log2 :: proc{ log2_double3, log2_double4, } -log2_float2 :: proc "c" (x: float2) -> float2 { return {log2(x.x), log2(x.y)} } -log2_float3 :: proc "c" (x: float3) -> float3 { return {log2(x.x), log2(x.y), log2(x.z)} } -log2_float4 :: proc "c" (x: float4) -> float4 { return {log2(x.x), log2(x.y), log2(x.z), log2(x.w)} } -log2_double2 :: proc "c" (x: double2) -> double2 { return {log2(x.x), log2(x.y)} } -log2_double3 :: proc "c" (x: double3) -> double3 { return {log2(x.x), log2(x.y), log2(x.z)} } -log2_double4 :: proc "c" (x: double4) -> double4 { return {log2(x.x), log2(x.y), log2(x.z), log2(x.w)} } +@(require_results) log2_float2 :: proc "c" (x: float2) -> float2 { return {log2(x.x), log2(x.y)} } +@(require_results) log2_float3 :: proc "c" (x: float3) -> float3 { return {log2(x.x), log2(x.y), log2(x.z)} } +@(require_results) log2_float4 :: proc "c" (x: float4) -> float4 { return {log2(x.x), log2(x.y), log2(x.z), log2(x.w)} } +@(require_results) log2_double2 :: proc "c" (x: double2) -> double2 { return {log2(x.x), log2(x.y)} } +@(require_results) log2_double3 :: proc "c" (x: double3) -> double3 { return {log2(x.x), log2(x.y), log2(x.z)} } +@(require_results) log2_double4 :: proc "c" (x: double4) -> double4 { return {log2(x.x), log2(x.y), log2(x.z), log2(x.w)} } @@ -473,12 +473,12 @@ log10 :: proc{ log10_double3, log10_double4, } -log10_float2 :: proc "c" (x: float2) -> float2 { return {log10(x.x), log10(x.y)} } -log10_float3 :: proc "c" (x: float3) -> float3 { return {log10(x.x), log10(x.y), log10(x.z)} } -log10_float4 :: proc "c" (x: float4) -> float4 { return {log10(x.x), log10(x.y), log10(x.z), log10(x.w)} } -log10_double2 :: proc "c" (x: double2) -> double2 { return {log10(x.x), log10(x.y)} } -log10_double3 :: proc "c" (x: double3) -> double3 { return {log10(x.x), log10(x.y), log10(x.z)} } -log10_double4 :: proc "c" (x: double4) -> double4 { return {log10(x.x), log10(x.y), log10(x.z), log10(x.w)} } +@(require_results) log10_float2 :: proc "c" (x: float2) -> float2 { return {log10(x.x), log10(x.y)} } +@(require_results) log10_float3 :: proc "c" (x: float3) -> float3 { return {log10(x.x), log10(x.y), log10(x.z)} } +@(require_results) log10_float4 :: proc "c" (x: float4) -> float4 { return {log10(x.x), log10(x.y), log10(x.z), log10(x.w)} } +@(require_results) log10_double2 :: proc "c" (x: double2) -> double2 { return {log10(x.x), log10(x.y)} } +@(require_results) log10_double3 :: proc "c" (x: double3) -> double3 { return {log10(x.x), log10(x.y), log10(x.z)} } +@(require_results) log10_double4 :: proc "c" (x: double4) -> double4 { return {log10(x.x), log10(x.y), log10(x.z), log10(x.w)} } @@ -493,12 +493,12 @@ exp2 :: proc{ exp2_double3, exp2_double4, } -exp2_float2 :: proc "c" (x: float2) -> float2 { return {exp2(x.x), exp2(x.y)} } -exp2_float3 :: proc "c" (x: float3) -> float3 { return {exp2(x.x), exp2(x.y), exp2(x.z)} } -exp2_float4 :: proc "c" (x: float4) -> float4 { return {exp2(x.x), exp2(x.y), exp2(x.z), exp2(x.w)} } -exp2_double2 :: proc "c" (x: double2) -> double2 { return {exp2(x.x), exp2(x.y)} } -exp2_double3 :: proc "c" (x: double3) -> double3 { return {exp2(x.x), exp2(x.y), exp2(x.z)} } -exp2_double4 :: proc "c" (x: double4) -> double4 { return {exp2(x.x), exp2(x.y), exp2(x.z), exp2(x.w)} } +@(require_results) exp2_float2 :: proc "c" (x: float2) -> float2 { return {exp2(x.x), exp2(x.y)} } +@(require_results) exp2_float3 :: proc "c" (x: float3) -> float3 { return {exp2(x.x), exp2(x.y), exp2(x.z)} } +@(require_results) exp2_float4 :: proc "c" (x: float4) -> float4 { return {exp2(x.x), exp2(x.y), exp2(x.z), exp2(x.w)} } +@(require_results) exp2_double2 :: proc "c" (x: double2) -> double2 { return {exp2(x.x), exp2(x.y)} } +@(require_results) exp2_double3 :: proc "c" (x: double3) -> double3 { return {exp2(x.x), exp2(x.y), exp2(x.z)} } +@(require_results) exp2_double4 :: proc "c" (x: double4) -> double4 { return {exp2(x.x), exp2(x.y), exp2(x.z), exp2(x.w)} } sign :: proc{ @@ -519,20 +519,20 @@ sign :: proc{ sign_uint3, sign_uint4, } -sign_int :: proc "c" (x: int) -> int { return -1 if x < 0 else +1 if x > 0 else 0 } -sign_uint :: proc "c" (x: uint) -> uint { return +1 if x > 0 else 0 } -sign_float2 :: proc "c" (x: float2) -> float2 { return {sign(x.x), sign(x.y)} } -sign_float3 :: proc "c" (x: float3) -> float3 { return {sign(x.x), sign(x.y), sign(x.z)} } -sign_float4 :: proc "c" (x: float4) -> float4 { return {sign(x.x), sign(x.y), sign(x.z), sign(x.w)} } -sign_double2 :: proc "c" (x: double2) -> double2 { return {sign(x.x), sign(x.y)} } -sign_double3 :: proc "c" (x: double3) -> double3 { return {sign(x.x), sign(x.y), sign(x.z)} } -sign_double4 :: proc "c" (x: double4) -> double4 { return {sign(x.x), sign(x.y), sign(x.z), sign(x.w)} } -sign_int2 :: proc "c" (x: int2) -> int2 { return {sign(x.x), sign(x.y)} } -sign_int3 :: proc "c" (x: int3) -> int3 { return {sign(x.x), sign(x.y), sign(x.z)} } -sign_int4 :: proc "c" (x: int4) -> int4 { return {sign(x.x), sign(x.y), sign(x.z), sign(x.w)} } -sign_uint2 :: proc "c" (x: uint2) -> uint2 { return {sign(x.x), sign(x.y)} } -sign_uint3 :: proc "c" (x: uint3) -> uint3 { return {sign(x.x), sign(x.y), sign(x.z)} } -sign_uint4 :: proc "c" (x: uint4) -> uint4 { return {sign(x.x), sign(x.y), sign(x.z), sign(x.w)} } +@(require_results) sign_int :: proc "c" (x: int) -> int { return -1 if x < 0 else +1 if x > 0 else 0 } +@(require_results) sign_uint :: proc "c" (x: uint) -> uint { return +1 if x > 0 else 0 } +@(require_results) sign_float2 :: proc "c" (x: float2) -> float2 { return {sign(x.x), sign(x.y)} } +@(require_results) sign_float3 :: proc "c" (x: float3) -> float3 { return {sign(x.x), sign(x.y), sign(x.z)} } +@(require_results) sign_float4 :: proc "c" (x: float4) -> float4 { return {sign(x.x), sign(x.y), sign(x.z), sign(x.w)} } +@(require_results) sign_double2 :: proc "c" (x: double2) -> double2 { return {sign(x.x), sign(x.y)} } +@(require_results) sign_double3 :: proc "c" (x: double3) -> double3 { return {sign(x.x), sign(x.y), sign(x.z)} } +@(require_results) sign_double4 :: proc "c" (x: double4) -> double4 { return {sign(x.x), sign(x.y), sign(x.z), sign(x.w)} } +@(require_results) sign_int2 :: proc "c" (x: int2) -> int2 { return {sign(x.x), sign(x.y)} } +@(require_results) sign_int3 :: proc "c" (x: int3) -> int3 { return {sign(x.x), sign(x.y), sign(x.z)} } +@(require_results) sign_int4 :: proc "c" (x: int4) -> int4 { return {sign(x.x), sign(x.y), sign(x.z), sign(x.w)} } +@(require_results) sign_uint2 :: proc "c" (x: uint2) -> uint2 { return {sign(x.x), sign(x.y)} } +@(require_results) sign_uint3 :: proc "c" (x: uint3) -> uint3 { return {sign(x.x), sign(x.y), sign(x.z)} } +@(require_results) sign_uint4 :: proc "c" (x: uint4) -> uint4 { return {sign(x.x), sign(x.y), sign(x.z), sign(x.w)} } floor :: proc{ floor_float, @@ -544,12 +544,12 @@ floor :: proc{ floor_double3, floor_double4, } -floor_float2 :: proc "c" (x: float2) -> float2 { return {floor(x.x), floor(x.y)} } -floor_float3 :: proc "c" (x: float3) -> float3 { return {floor(x.x), floor(x.y), floor(x.z)} } -floor_float4 :: proc "c" (x: float4) -> float4 { return {floor(x.x), floor(x.y), floor(x.z), floor(x.w)} } -floor_double2 :: proc "c" (x: double2) -> double2 { return {floor(x.x), floor(x.y)} } -floor_double3 :: proc "c" (x: double3) -> double3 { return {floor(x.x), floor(x.y), floor(x.z)} } -floor_double4 :: proc "c" (x: double4) -> double4 { return {floor(x.x), floor(x.y), floor(x.z), floor(x.w)} } +@(require_results) floor_float2 :: proc "c" (x: float2) -> float2 { return {floor(x.x), floor(x.y)} } +@(require_results) floor_float3 :: proc "c" (x: float3) -> float3 { return {floor(x.x), floor(x.y), floor(x.z)} } +@(require_results) floor_float4 :: proc "c" (x: float4) -> float4 { return {floor(x.x), floor(x.y), floor(x.z), floor(x.w)} } +@(require_results) floor_double2 :: proc "c" (x: double2) -> double2 { return {floor(x.x), floor(x.y)} } +@(require_results) floor_double3 :: proc "c" (x: double3) -> double3 { return {floor(x.x), floor(x.y), floor(x.z)} } +@(require_results) floor_double4 :: proc "c" (x: double4) -> double4 { return {floor(x.x), floor(x.y), floor(x.z), floor(x.w)} } round :: proc{ round_float, @@ -561,12 +561,12 @@ round :: proc{ round_double3, round_double4, } -round_float2 :: proc "c" (x: float2) -> float2 { return {round(x.x), round(x.y)} } -round_float3 :: proc "c" (x: float3) -> float3 { return {round(x.x), round(x.y), round(x.z)} } -round_float4 :: proc "c" (x: float4) -> float4 { return {round(x.x), round(x.y), round(x.z), round(x.w)} } -round_double2 :: proc "c" (x: double2) -> double2 { return {round(x.x), round(x.y)} } -round_double3 :: proc "c" (x: double3) -> double3 { return {round(x.x), round(x.y), round(x.z)} } -round_double4 :: proc "c" (x: double4) -> double4 { return {round(x.x), round(x.y), round(x.z), round(x.w)} } +@(require_results) round_float2 :: proc "c" (x: float2) -> float2 { return {round(x.x), round(x.y)} } +@(require_results) round_float3 :: proc "c" (x: float3) -> float3 { return {round(x.x), round(x.y), round(x.z)} } +@(require_results) round_float4 :: proc "c" (x: float4) -> float4 { return {round(x.x), round(x.y), round(x.z), round(x.w)} } +@(require_results) round_double2 :: proc "c" (x: double2) -> double2 { return {round(x.x), round(x.y)} } +@(require_results) round_double3 :: proc "c" (x: double3) -> double3 { return {round(x.x), round(x.y), round(x.z)} } +@(require_results) round_double4 :: proc "c" (x: double4) -> double4 { return {round(x.x), round(x.y), round(x.z), round(x.w)} } ceil :: proc{ @@ -579,22 +579,22 @@ ceil :: proc{ ceil_double3, ceil_double4, } -ceil_float2 :: proc "c" (x: float2) -> float2 { return {ceil(x.x), ceil(x.y)} } -ceil_float3 :: proc "c" (x: float3) -> float3 { return {ceil(x.x), ceil(x.y), ceil(x.z)} } -ceil_float4 :: proc "c" (x: float4) -> float4 { return {ceil(x.x), ceil(x.y), ceil(x.z), ceil(x.w)} } -ceil_double2 :: proc "c" (x: double2) -> double2 { return {ceil(x.x), ceil(x.y)} } -ceil_double3 :: proc "c" (x: double3) -> double3 { return {ceil(x.x), ceil(x.y), ceil(x.z)} } -ceil_double4 :: proc "c" (x: double4) -> double4 { return {ceil(x.x), ceil(x.y), ceil(x.z), ceil(x.w)} } +@(require_results) ceil_float2 :: proc "c" (x: float2) -> float2 { return {ceil(x.x), ceil(x.y)} } +@(require_results) ceil_float3 :: proc "c" (x: float3) -> float3 { return {ceil(x.x), ceil(x.y), ceil(x.z)} } +@(require_results) ceil_float4 :: proc "c" (x: float4) -> float4 { return {ceil(x.x), ceil(x.y), ceil(x.z), ceil(x.w)} } +@(require_results) ceil_double2 :: proc "c" (x: double2) -> double2 { return {ceil(x.x), ceil(x.y)} } +@(require_results) ceil_double3 :: proc "c" (x: double3) -> double3 { return {ceil(x.x), ceil(x.y), ceil(x.z)} } +@(require_results) ceil_double4 :: proc "c" (x: double4) -> double4 { return {ceil(x.x), ceil(x.y), ceil(x.z), ceil(x.w)} } -isfinite_float :: proc "c" (x: float) -> bool { return !isinf_float(x) } -isfinite_float2 :: proc "c" (x: float2) -> bool2 { return {isfinite_float(x.x), isfinite_float(x.y)} } -isfinite_float3 :: proc "c" (x: float3) -> bool3 { return {isfinite_float(x.x), isfinite_float(x.y), isfinite_float(x.z)} } -isfinite_float4 :: proc "c" (x: float4) -> bool4 { return {isfinite_float(x.x), isfinite_float(x.y), isfinite_float(x.z), isfinite_float(x.w)} } -isfinite_double :: proc "c" (x: double) -> bool { return !isinf_double(x) } -isfinite_double2 :: proc "c" (x: double2) -> bool2 { return {isfinite_double(x.x), isfinite_double(x.y)} } -isfinite_double3 :: proc "c" (x: double3) -> bool3 { return {isfinite_double(x.x), isfinite_double(x.y), isfinite_double(x.z)} } -isfinite_double4 :: proc "c" (x: double4) -> bool4 { return {isfinite_double(x.x), isfinite_double(x.y), isfinite_double(x.z), isfinite_double(x.w)} } +@(require_results) isfinite_float :: proc "c" (x: float) -> bool { return !isinf_float(x) } +@(require_results) isfinite_float2 :: proc "c" (x: float2) -> bool2 { return {isfinite_float(x.x), isfinite_float(x.y)} } +@(require_results) isfinite_float3 :: proc "c" (x: float3) -> bool3 { return {isfinite_float(x.x), isfinite_float(x.y), isfinite_float(x.z)} } +@(require_results) isfinite_float4 :: proc "c" (x: float4) -> bool4 { return {isfinite_float(x.x), isfinite_float(x.y), isfinite_float(x.z), isfinite_float(x.w)} } +@(require_results) isfinite_double :: proc "c" (x: double) -> bool { return !isinf_double(x) } +@(require_results) isfinite_double2 :: proc "c" (x: double2) -> bool2 { return {isfinite_double(x.x), isfinite_double(x.y)} } +@(require_results) isfinite_double3 :: proc "c" (x: double3) -> bool3 { return {isfinite_double(x.x), isfinite_double(x.y), isfinite_double(x.z)} } +@(require_results) isfinite_double4 :: proc "c" (x: double4) -> bool4 { return {isfinite_double(x.x), isfinite_double(x.y), isfinite_double(x.z), isfinite_double(x.w)} } // isfinite is the opposite of isinf and returns true if the number is neither positive-infinite or negative-infinite isfinite :: proc{ @@ -609,14 +609,14 @@ isfinite :: proc{ } -isinf_float :: proc "c" (x: float) -> bool { return x * 0.5 == x } -isinf_float2 :: proc "c" (x: float2) -> bool2 { return {isinf_float(x.x), isinf_float(x.y)} } -isinf_float3 :: proc "c" (x: float3) -> bool3 { return {isinf_float(x.x), isinf_float(x.y), isinf_float(x.z)} } -isinf_float4 :: proc "c" (x: float4) -> bool4 { return {isinf_float(x.x), isinf_float(x.y), isinf_float(x.z), isinf_float(x.w)} } -isinf_double :: proc "c" (x: double) -> bool { return x * 0.5 == x } -isinf_double2 :: proc "c" (x: double2) -> bool2 { return {isinf_double(x.x), isinf_double(x.y)} } -isinf_double3 :: proc "c" (x: double3) -> bool3 { return {isinf_double(x.x), isinf_double(x.y), isinf_double(x.z)} } -isinf_double4 :: proc "c" (x: double4) -> bool4 { return {isinf_double(x.x), isinf_double(x.y), isinf_double(x.z), isinf_double(x.w)} } +@(require_results) isinf_float :: proc "c" (x: float) -> bool { return x * 0.5 == x } +@(require_results) isinf_float2 :: proc "c" (x: float2) -> bool2 { return {isinf_float(x.x), isinf_float(x.y)} } +@(require_results) isinf_float3 :: proc "c" (x: float3) -> bool3 { return {isinf_float(x.x), isinf_float(x.y), isinf_float(x.z)} } +@(require_results) isinf_float4 :: proc "c" (x: float4) -> bool4 { return {isinf_float(x.x), isinf_float(x.y), isinf_float(x.z), isinf_float(x.w)} } +@(require_results) isinf_double :: proc "c" (x: double) -> bool { return x * 0.5 == x } +@(require_results) isinf_double2 :: proc "c" (x: double2) -> bool2 { return {isinf_double(x.x), isinf_double(x.y)} } +@(require_results) isinf_double3 :: proc "c" (x: double3) -> bool3 { return {isinf_double(x.x), isinf_double(x.y), isinf_double(x.z)} } +@(require_results) isinf_double4 :: proc "c" (x: double4) -> bool4 { return {isinf_double(x.x), isinf_double(x.y), isinf_double(x.z), isinf_double(x.w)} } // isinf is the opposite of isfinite and returns true if the number is either positive-infinite or negative-infinite isinf :: proc{ @@ -631,12 +631,12 @@ isinf :: proc{ } -isnan_float2 :: proc "c" (x: float2) -> bool2 { return {isnan_float(x.x), isnan_float(x.y)} } -isnan_float3 :: proc "c" (x: float3) -> bool3 { return {isnan_float(x.x), isnan_float(x.y), isnan_float(x.z)} } -isnan_float4 :: proc "c" (x: float4) -> bool4 { return {isnan_float(x.x), isnan_float(x.y), isnan_float(x.z), isnan_float(x.w)} } -isnan_double2 :: proc "c" (x: double2) -> bool2 { return {isnan_double(x.x), isnan_double(x.y)} } -isnan_double3 :: proc "c" (x: double3) -> bool3 { return {isnan_double(x.x), isnan_double(x.y), isnan_double(x.z)} } -isnan_double4 :: proc "c" (x: double4) -> bool4 { return {isnan_double(x.x), isnan_double(x.y), isnan_double(x.z), isnan_double(x.w)} } +@(require_results) isnan_float2 :: proc "c" (x: float2) -> bool2 { return {isnan_float(x.x), isnan_float(x.y)} } +@(require_results) isnan_float3 :: proc "c" (x: float3) -> bool3 { return {isnan_float(x.x), isnan_float(x.y), isnan_float(x.z)} } +@(require_results) isnan_float4 :: proc "c" (x: float4) -> bool4 { return {isnan_float(x.x), isnan_float(x.y), isnan_float(x.z), isnan_float(x.w)} } +@(require_results) isnan_double2 :: proc "c" (x: double2) -> bool2 { return {isnan_double(x.x), isnan_double(x.y)} } +@(require_results) isnan_double3 :: proc "c" (x: double3) -> bool3 { return {isnan_double(x.x), isnan_double(x.y), isnan_double(x.z)} } +@(require_results) isnan_double4 :: proc "c" (x: double4) -> bool4 { return {isnan_double(x.x), isnan_double(x.y), isnan_double(x.z), isnan_double(x.w)} } // isnan returns true if the input value is the special case of Not-A-Number isnan :: proc{ @@ -660,12 +660,12 @@ fmod :: proc{ fmod_double3, fmod_double4, } -fmod_float2 :: proc "c" (x, y: float2) -> float2 { return {fmod(x.x, y.x), fmod(x.y, y.y)} } -fmod_float3 :: proc "c" (x, y: float3) -> float3 { return {fmod(x.x, y.x), fmod(x.y, y.y), fmod(x.z, y.z)} } -fmod_float4 :: proc "c" (x, y: float4) -> float4 { return {fmod(x.x, y.x), fmod(x.y, y.y), fmod(x.z, y.z), fmod(x.w, y.w)} } -fmod_double2 :: proc "c" (x, y: double2) -> double2 { return {fmod(x.x, y.x), fmod(x.y, y.y)} } -fmod_double3 :: proc "c" (x, y: double3) -> double3 { return {fmod(x.x, y.x), fmod(x.y, y.y), fmod(x.z, y.z)} } -fmod_double4 :: proc "c" (x, y: double4) -> double4 { return {fmod(x.x, y.x), fmod(x.y, y.y), fmod(x.z, y.z), fmod(x.w, y.w)} } +@(require_results) fmod_float2 :: proc "c" (x, y: float2) -> float2 { return {fmod(x.x, y.x), fmod(x.y, y.y)} } +@(require_results) fmod_float3 :: proc "c" (x, y: float3) -> float3 { return {fmod(x.x, y.x), fmod(x.y, y.y), fmod(x.z, y.z)} } +@(require_results) fmod_float4 :: proc "c" (x, y: float4) -> float4 { return {fmod(x.x, y.x), fmod(x.y, y.y), fmod(x.z, y.z), fmod(x.w, y.w)} } +@(require_results) fmod_double2 :: proc "c" (x, y: double2) -> double2 { return {fmod(x.x, y.x), fmod(x.y, y.y)} } +@(require_results) fmod_double3 :: proc "c" (x, y: double3) -> double3 { return {fmod(x.x, y.x), fmod(x.y, y.y), fmod(x.z, y.z)} } +@(require_results) fmod_double4 :: proc "c" (x, y: double4) -> double4 { return {fmod(x.x, y.x), fmod(x.y, y.y), fmod(x.z, y.z), fmod(x.w, y.w)} } frac :: proc{ @@ -678,12 +678,12 @@ frac :: proc{ frac_double3, frac_double4, } -frac_float2 :: proc "c" (x: float2) -> float2 { return {frac(x.x), frac(x.y)} } -frac_float3 :: proc "c" (x: float3) -> float3 { return {frac(x.x), frac(x.y), frac(x.z)} } -frac_float4 :: proc "c" (x: float4) -> float4 { return {frac(x.x), frac(x.y), frac(x.z), frac(x.w)} } -frac_double2 :: proc "c" (x: double2) -> double2 { return {frac(x.x), frac(x.y)} } -frac_double3 :: proc "c" (x: double3) -> double3 { return {frac(x.x), frac(x.y), frac(x.z)} } -frac_double4 :: proc "c" (x: double4) -> double4 { return {frac(x.x), frac(x.y), frac(x.z), frac(x.w)} } +@(require_results) frac_float2 :: proc "c" (x: float2) -> float2 { return {frac(x.x), frac(x.y)} } +@(require_results) frac_float3 :: proc "c" (x: float3) -> float3 { return {frac(x.x), frac(x.y), frac(x.z)} } +@(require_results) frac_float4 :: proc "c" (x: float4) -> float4 { return {frac(x.x), frac(x.y), frac(x.z), frac(x.w)} } +@(require_results) frac_double2 :: proc "c" (x: double2) -> double2 { return {frac(x.x), frac(x.y)} } +@(require_results) frac_double3 :: proc "c" (x: double3) -> double3 { return {frac(x.x), frac(x.y), frac(x.z)} } +@(require_results) frac_double4 :: proc "c" (x: double4) -> double4 { return {frac(x.x), frac(x.y), frac(x.z), frac(x.w)} } @@ -697,14 +697,14 @@ radians :: proc{ radians_double3, radians_double4, } -radians_float :: proc "c" (degrees: float) -> float { return degrees * TAU / 360.0 } -radians_double :: proc "c" (degrees: double) -> double { return degrees * TAU / 360.0 } -radians_float2 :: proc "c" (degrees: float2) -> float2 { return degrees * TAU / 360.0 } -radians_float3 :: proc "c" (degrees: float3) -> float3 { return degrees * TAU / 360.0 } -radians_float4 :: proc "c" (degrees: float4) -> float4 { return degrees * TAU / 360.0 } -radians_double2 :: proc "c" (degrees: double2) -> double2 { return degrees * TAU / 360.0 } -radians_double3 :: proc "c" (degrees: double3) -> double3 { return degrees * TAU / 360.0 } -radians_double4 :: proc "c" (degrees: double4) -> double4 { return degrees * TAU / 360.0 } +@(require_results) radians_float :: proc "c" (degrees: float) -> float { return degrees * TAU / 360.0 } +@(require_results) radians_double :: proc "c" (degrees: double) -> double { return degrees * TAU / 360.0 } +@(require_results) radians_float2 :: proc "c" (degrees: float2) -> float2 { return degrees * TAU / 360.0 } +@(require_results) radians_float3 :: proc "c" (degrees: float3) -> float3 { return degrees * TAU / 360.0 } +@(require_results) radians_float4 :: proc "c" (degrees: float4) -> float4 { return degrees * TAU / 360.0 } +@(require_results) radians_double2 :: proc "c" (degrees: double2) -> double2 { return degrees * TAU / 360.0 } +@(require_results) radians_double3 :: proc "c" (degrees: double3) -> double3 { return degrees * TAU / 360.0 } +@(require_results) radians_double4 :: proc "c" (degrees: double4) -> double4 { return degrees * TAU / 360.0 } degrees :: proc{ @@ -717,14 +717,14 @@ degrees :: proc{ degrees_double3, degrees_double4, } -degrees_float :: proc "c" (radians: float) -> float { return radians * 360.0 / TAU } -degrees_double :: proc "c" (radians: double) -> double { return radians * 360.0 / TAU } -degrees_float2 :: proc "c" (radians: float2) -> float2 { return radians * 360.0 / TAU } -degrees_float3 :: proc "c" (radians: float3) -> float3 { return radians * 360.0 / TAU } -degrees_float4 :: proc "c" (radians: float4) -> float4 { return radians * 360.0 / TAU } -degrees_double2 :: proc "c" (radians: double2) -> double2 { return radians * 360.0 / TAU } -degrees_double3 :: proc "c" (radians: double3) -> double3 { return radians * 360.0 / TAU } -degrees_double4 :: proc "c" (radians: double4) -> double4 { return radians * 360.0 / TAU } +@(require_results) degrees_float :: proc "c" (radians: float) -> float { return radians * 360.0 / TAU } +@(require_results) degrees_double :: proc "c" (radians: double) -> double { return radians * 360.0 / TAU } +@(require_results) degrees_float2 :: proc "c" (radians: float2) -> float2 { return radians * 360.0 / TAU } +@(require_results) degrees_float3 :: proc "c" (radians: float3) -> float3 { return radians * 360.0 / TAU } +@(require_results) degrees_float4 :: proc "c" (radians: float4) -> float4 { return radians * 360.0 / TAU } +@(require_results) degrees_double2 :: proc "c" (radians: double2) -> double2 { return radians * 360.0 / TAU } +@(require_results) degrees_double3 :: proc "c" (radians: double3) -> double3 { return radians * 360.0 / TAU } +@(require_results) degrees_double4 :: proc "c" (radians: double4) -> double4 { return radians * 360.0 / TAU } min :: proc{ min_int, @@ -744,22 +744,22 @@ min :: proc{ min_uint3, min_uint4, } -min_int :: proc "c" (x, y: int) -> int { return builtin.min(x, y) } -min_uint :: proc "c" (x, y: uint) -> uint { return builtin.min(x, y) } -min_float :: proc "c" (x, y: float) -> float { return builtin.min(x, y) } -min_double :: proc "c" (x, y: double) -> double { return builtin.min(x, y) } -min_float2 :: proc "c" (x, y: float2) -> float2 { return {min(x.x, y.x), min(x.y, y.y)} } -min_float3 :: proc "c" (x, y: float3) -> float3 { return {min(x.x, y.x), min(x.y, y.y), min(x.z, y.z)} } -min_float4 :: proc "c" (x, y: float4) -> float4 { return {min(x.x, y.x), min(x.y, y.y), min(x.z, y.z), min(x.w, y.w)} } -min_double2 :: proc "c" (x, y: double2) -> double2 { return {min(x.x, y.x), min(x.y, y.y)} } -min_double3 :: proc "c" (x, y: double3) -> double3 { return {min(x.x, y.x), min(x.y, y.y), min(x.z, y.z)} } -min_double4 :: proc "c" (x, y: double4) -> double4 { return {min(x.x, y.x), min(x.y, y.y), min(x.z, y.z), min(x.w, y.w)} } -min_int2 :: proc "c" (x, y: int2) -> int2 { return {min(x.x, y.x), min(x.y, y.y)} } -min_int3 :: proc "c" (x, y: int3) -> int3 { return {min(x.x, y.x), min(x.y, y.y), min(x.z, y.z)} } -min_int4 :: proc "c" (x, y: int4) -> int4 { return {min(x.x, y.x), min(x.y, y.y), min(x.z, y.z), min(x.w, y.w)} } -min_uint2 :: proc "c" (x, y: uint2) -> uint2 { return {min(x.x, y.x), min(x.y, y.y)} } -min_uint3 :: proc "c" (x, y: uint3) -> uint3 { return {min(x.x, y.x), min(x.y, y.y), min(x.z, y.z)} } -min_uint4 :: proc "c" (x, y: uint4) -> uint4 { return {min(x.x, y.x), min(x.y, y.y), min(x.z, y.z), min(x.w, y.w)} } +@(require_results) min_int :: proc "c" (x, y: int) -> int { return builtin.min(x, y) } +@(require_results) min_uint :: proc "c" (x, y: uint) -> uint { return builtin.min(x, y) } +@(require_results) min_float :: proc "c" (x, y: float) -> float { return builtin.min(x, y) } +@(require_results) min_double :: proc "c" (x, y: double) -> double { return builtin.min(x, y) } +@(require_results) min_float2 :: proc "c" (x, y: float2) -> float2 { return {min(x.x, y.x), min(x.y, y.y)} } +@(require_results) min_float3 :: proc "c" (x, y: float3) -> float3 { return {min(x.x, y.x), min(x.y, y.y), min(x.z, y.z)} } +@(require_results) min_float4 :: proc "c" (x, y: float4) -> float4 { return {min(x.x, y.x), min(x.y, y.y), min(x.z, y.z), min(x.w, y.w)} } +@(require_results) min_double2 :: proc "c" (x, y: double2) -> double2 { return {min(x.x, y.x), min(x.y, y.y)} } +@(require_results) min_double3 :: proc "c" (x, y: double3) -> double3 { return {min(x.x, y.x), min(x.y, y.y), min(x.z, y.z)} } +@(require_results) min_double4 :: proc "c" (x, y: double4) -> double4 { return {min(x.x, y.x), min(x.y, y.y), min(x.z, y.z), min(x.w, y.w)} } +@(require_results) min_int2 :: proc "c" (x, y: int2) -> int2 { return {min(x.x, y.x), min(x.y, y.y)} } +@(require_results) min_int3 :: proc "c" (x, y: int3) -> int3 { return {min(x.x, y.x), min(x.y, y.y), min(x.z, y.z)} } +@(require_results) min_int4 :: proc "c" (x, y: int4) -> int4 { return {min(x.x, y.x), min(x.y, y.y), min(x.z, y.z), min(x.w, y.w)} } +@(require_results) min_uint2 :: proc "c" (x, y: uint2) -> uint2 { return {min(x.x, y.x), min(x.y, y.y)} } +@(require_results) min_uint3 :: proc "c" (x, y: uint3) -> uint3 { return {min(x.x, y.x), min(x.y, y.y), min(x.z, y.z)} } +@(require_results) min_uint4 :: proc "c" (x, y: uint4) -> uint4 { return {min(x.x, y.x), min(x.y, y.y), min(x.z, y.z), min(x.w, y.w)} } max :: proc{ @@ -780,22 +780,22 @@ max :: proc{ max_uint3, max_uint4, } -max_int :: proc "c" (x, y: int) -> int { return builtin.max(x, y) } -max_uint :: proc "c" (x, y: uint) -> uint { return builtin.max(x, y) } -max_float :: proc "c" (x, y: float) -> float { return builtin.max(x, y) } -max_double :: proc "c" (x, y: double) -> double { return builtin.max(x, y) } -max_float2 :: proc "c" (x, y: float2) -> float2 { return {max(x.x, y.x), max(x.y, y.y)} } -max_float3 :: proc "c" (x, y: float3) -> float3 { return {max(x.x, y.x), max(x.y, y.y), max(x.z, y.z)} } -max_float4 :: proc "c" (x, y: float4) -> float4 { return {max(x.x, y.x), max(x.y, y.y), max(x.z, y.z), max(x.w, y.w)} } -max_double2 :: proc "c" (x, y: double2) -> double2 { return {max(x.x, y.x), max(x.y, y.y)} } -max_double3 :: proc "c" (x, y: double3) -> double3 { return {max(x.x, y.x), max(x.y, y.y), max(x.z, y.z)} } -max_double4 :: proc "c" (x, y: double4) -> double4 { return {max(x.x, y.x), max(x.y, y.y), max(x.z, y.z), max(x.w, y.w)} } -max_int2 :: proc "c" (x, y: int2) -> int2 { return {max(x.x, y.x), max(x.y, y.y)} } -max_int3 :: proc "c" (x, y: int3) -> int3 { return {max(x.x, y.x), max(x.y, y.y), max(x.z, y.z)} } -max_int4 :: proc "c" (x, y: int4) -> int4 { return {max(x.x, y.x), max(x.y, y.y), max(x.z, y.z), max(x.w, y.w)} } -max_uint2 :: proc "c" (x, y: uint2) -> uint2 { return {max(x.x, y.x), max(x.y, y.y)} } -max_uint3 :: proc "c" (x, y: uint3) -> uint3 { return {max(x.x, y.x), max(x.y, y.y), max(x.z, y.z)} } -max_uint4 :: proc "c" (x, y: uint4) -> uint4 { return {max(x.x, y.x), max(x.y, y.y), max(x.z, y.z), max(x.w, y.w)} } +@(require_results) max_int :: proc "c" (x, y: int) -> int { return builtin.max(x, y) } +@(require_results) max_uint :: proc "c" (x, y: uint) -> uint { return builtin.max(x, y) } +@(require_results) max_float :: proc "c" (x, y: float) -> float { return builtin.max(x, y) } +@(require_results) max_double :: proc "c" (x, y: double) -> double { return builtin.max(x, y) } +@(require_results) max_float2 :: proc "c" (x, y: float2) -> float2 { return {max(x.x, y.x), max(x.y, y.y)} } +@(require_results) max_float3 :: proc "c" (x, y: float3) -> float3 { return {max(x.x, y.x), max(x.y, y.y), max(x.z, y.z)} } +@(require_results) max_float4 :: proc "c" (x, y: float4) -> float4 { return {max(x.x, y.x), max(x.y, y.y), max(x.z, y.z), max(x.w, y.w)} } +@(require_results) max_double2 :: proc "c" (x, y: double2) -> double2 { return {max(x.x, y.x), max(x.y, y.y)} } +@(require_results) max_double3 :: proc "c" (x, y: double3) -> double3 { return {max(x.x, y.x), max(x.y, y.y), max(x.z, y.z)} } +@(require_results) max_double4 :: proc "c" (x, y: double4) -> double4 { return {max(x.x, y.x), max(x.y, y.y), max(x.z, y.z), max(x.w, y.w)} } +@(require_results) max_int2 :: proc "c" (x, y: int2) -> int2 { return {max(x.x, y.x), max(x.y, y.y)} } +@(require_results) max_int3 :: proc "c" (x, y: int3) -> int3 { return {max(x.x, y.x), max(x.y, y.y), max(x.z, y.z)} } +@(require_results) max_int4 :: proc "c" (x, y: int4) -> int4 { return {max(x.x, y.x), max(x.y, y.y), max(x.z, y.z), max(x.w, y.w)} } +@(require_results) max_uint2 :: proc "c" (x, y: uint2) -> uint2 { return {max(x.x, y.x), max(x.y, y.y)} } +@(require_results) max_uint3 :: proc "c" (x, y: uint3) -> uint3 { return {max(x.x, y.x), max(x.y, y.y), max(x.z, y.z)} } +@(require_results) max_uint4 :: proc "c" (x, y: uint4) -> uint4 { return {max(x.x, y.x), max(x.y, y.y), max(x.z, y.z), max(x.w, y.w)} } @@ -817,22 +817,22 @@ clamp :: proc{ clamp_uint3, clamp_uint4, } -clamp_int :: proc "c" (x, y, z: int) -> int { return builtin.clamp(x, y, z) } -clamp_uint :: proc "c" (x, y, z: uint) -> uint { return builtin.clamp(x, y, z) } -clamp_float :: proc "c" (x, y, z: float) -> float { return builtin.clamp(x, y, z) } -clamp_double :: proc "c" (x, y, z: double) -> double { return builtin.clamp(x, y, z) } -clamp_float2 :: proc "c" (x, y, z: float2) -> float2 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y)} } -clamp_float3 :: proc "c" (x, y, z: float3) -> float3 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y), clamp(x.z, y.z, z.z)} } -clamp_float4 :: proc "c" (x, y, z: float4) -> float4 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y), clamp(x.z, y.z, z.z), clamp(x.w, y.w, z.w)} } -clamp_double2 :: proc "c" (x, y, z: double2) -> double2 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y)} } -clamp_double3 :: proc "c" (x, y, z: double3) -> double3 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y), clamp(x.z, y.z, z.z)} } -clamp_double4 :: proc "c" (x, y, z: double4) -> double4 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y), clamp(x.z, y.z, z.z), clamp(x.w, y.w, z.w)} } -clamp_int2 :: proc "c" (x, y, z: int2) -> int2 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y)} } -clamp_int3 :: proc "c" (x, y, z: int3) -> int3 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y), clamp(x.z, y.z, z.z)} } -clamp_int4 :: proc "c" (x, y, z: int4) -> int4 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y), clamp(x.z, y.z, z.z), clamp(x.w, y.w, z.w)} } -clamp_uint2 :: proc "c" (x, y, z: uint2) -> uint2 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y)} } -clamp_uint3 :: proc "c" (x, y, z: uint3) -> uint3 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y), clamp(x.z, y.z, z.z)} } -clamp_uint4 :: proc "c" (x, y, z: uint4) -> uint4 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y), clamp(x.z, y.z, z.z), clamp(x.w, y.w, z.w)} } +@(require_results) clamp_int :: proc "c" (x, y, z: int) -> int { return builtin.clamp(x, y, z) } +@(require_results) clamp_uint :: proc "c" (x, y, z: uint) -> uint { return builtin.clamp(x, y, z) } +@(require_results) clamp_float :: proc "c" (x, y, z: float) -> float { return builtin.clamp(x, y, z) } +@(require_results) clamp_double :: proc "c" (x, y, z: double) -> double { return builtin.clamp(x, y, z) } +@(require_results) clamp_float2 :: proc "c" (x, y, z: float2) -> float2 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y)} } +@(require_results) clamp_float3 :: proc "c" (x, y, z: float3) -> float3 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y), clamp(x.z, y.z, z.z)} } +@(require_results) clamp_float4 :: proc "c" (x, y, z: float4) -> float4 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y), clamp(x.z, y.z, z.z), clamp(x.w, y.w, z.w)} } +@(require_results) clamp_double2 :: proc "c" (x, y, z: double2) -> double2 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y)} } +@(require_results) clamp_double3 :: proc "c" (x, y, z: double3) -> double3 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y), clamp(x.z, y.z, z.z)} } +@(require_results) clamp_double4 :: proc "c" (x, y, z: double4) -> double4 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y), clamp(x.z, y.z, z.z), clamp(x.w, y.w, z.w)} } +@(require_results) clamp_int2 :: proc "c" (x, y, z: int2) -> int2 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y)} } +@(require_results) clamp_int3 :: proc "c" (x, y, z: int3) -> int3 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y), clamp(x.z, y.z, z.z)} } +@(require_results) clamp_int4 :: proc "c" (x, y, z: int4) -> int4 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y), clamp(x.z, y.z, z.z), clamp(x.w, y.w, z.w)} } +@(require_results) clamp_uint2 :: proc "c" (x, y, z: uint2) -> uint2 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y)} } +@(require_results) clamp_uint3 :: proc "c" (x, y, z: uint3) -> uint3 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y), clamp(x.z, y.z, z.z)} } +@(require_results) clamp_uint4 :: proc "c" (x, y, z: uint4) -> uint4 { return {clamp(x.x, y.x, z.x), clamp(x.y, y.y, z.y), clamp(x.z, y.z, z.z), clamp(x.w, y.w, z.w)} } saturate :: proc{ saturate_int, @@ -852,22 +852,22 @@ saturate :: proc{ saturate_uint3, saturate_uint4, } -saturate_int :: proc "c" (v: int) -> int { return builtin.clamp(v, 0, 1) } -saturate_uint :: proc "c" (v: uint) -> uint { return builtin.clamp(v, 0, 1) } -saturate_float :: proc "c" (v: float) -> float { return builtin.clamp(v, 0, 1) } -saturate_double :: proc "c" (v: double) -> double { return builtin.clamp(v, 0, 1) } -saturate_float2 :: proc "c" (v: float2) -> float2 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1)} } -saturate_float3 :: proc "c" (v: float3) -> float3 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1), builtin.clamp(v.z, 0, 1)} } -saturate_float4 :: proc "c" (v: float4) -> float4 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1), builtin.clamp(v.z, 0, 1), builtin.clamp(v.w, 0, 1)} } -saturate_double2 :: proc "c" (v: double2) -> double2 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1)} } -saturate_double3 :: proc "c" (v: double3) -> double3 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1), builtin.clamp(v.z, 0, 1)} } -saturate_double4 :: proc "c" (v: double4) -> double4 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1), builtin.clamp(v.z, 0, 1), builtin.clamp(v.w, 0, 1)} } -saturate_int2 :: proc "c" (v: int2) -> int2 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1)} } -saturate_int3 :: proc "c" (v: int3) -> int3 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1), builtin.clamp(v.z, 0, 1)} } -saturate_int4 :: proc "c" (v: int4) -> int4 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1), builtin.clamp(v.z, 0, 1), builtin.clamp(v.w, 0, 1)} } -saturate_uint2 :: proc "c" (v: uint2) -> uint2 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1)} } -saturate_uint3 :: proc "c" (v: uint3) -> uint3 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1), builtin.clamp(v.z, 0, 1)} } -saturate_uint4 :: proc "c" (v: uint4) -> uint4 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1), builtin.clamp(v.z, 0, 1), builtin.clamp(v.w, 0, 1)} } +@(require_results) saturate_int :: proc "c" (v: int) -> int { return builtin.clamp(v, 0, 1) } +@(require_results) saturate_uint :: proc "c" (v: uint) -> uint { return builtin.clamp(v, 0, 1) } +@(require_results) saturate_float :: proc "c" (v: float) -> float { return builtin.clamp(v, 0, 1) } +@(require_results) saturate_double :: proc "c" (v: double) -> double { return builtin.clamp(v, 0, 1) } +@(require_results) saturate_float2 :: proc "c" (v: float2) -> float2 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1)} } +@(require_results) saturate_float3 :: proc "c" (v: float3) -> float3 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1), builtin.clamp(v.z, 0, 1)} } +@(require_results) saturate_float4 :: proc "c" (v: float4) -> float4 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1), builtin.clamp(v.z, 0, 1), builtin.clamp(v.w, 0, 1)} } +@(require_results) saturate_double2 :: proc "c" (v: double2) -> double2 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1)} } +@(require_results) saturate_double3 :: proc "c" (v: double3) -> double3 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1), builtin.clamp(v.z, 0, 1)} } +@(require_results) saturate_double4 :: proc "c" (v: double4) -> double4 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1), builtin.clamp(v.z, 0, 1), builtin.clamp(v.w, 0, 1)} } +@(require_results) saturate_int2 :: proc "c" (v: int2) -> int2 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1)} } +@(require_results) saturate_int3 :: proc "c" (v: int3) -> int3 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1), builtin.clamp(v.z, 0, 1)} } +@(require_results) saturate_int4 :: proc "c" (v: int4) -> int4 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1), builtin.clamp(v.z, 0, 1), builtin.clamp(v.w, 0, 1)} } +@(require_results) saturate_uint2 :: proc "c" (v: uint2) -> uint2 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1)} } +@(require_results) saturate_uint3 :: proc "c" (v: uint3) -> uint3 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1), builtin.clamp(v.z, 0, 1)} } +@(require_results) saturate_uint4 :: proc "c" (v: uint4) -> uint4 { return {builtin.clamp(v.x, 0, 1), builtin.clamp(v.y, 0, 1), builtin.clamp(v.z, 0, 1), builtin.clamp(v.w, 0, 1)} } lerp :: proc{ @@ -880,14 +880,14 @@ lerp :: proc{ lerp_double3, lerp_double4, } -lerp_float :: proc "c" (x, y, t: float) -> float { return x*(1-t) + y*t } -lerp_double :: proc "c" (x, y, t: double) -> double { return x*(1-t) + y*t } -lerp_float2 :: proc "c" (x, y, t: float2) -> float2 { return {lerp(x.x, y.x, t.x), lerp(x.y, y.y, t.y)} } -lerp_float3 :: proc "c" (x, y, t: float3) -> float3 { return {lerp(x.x, y.x, t.x), lerp(x.y, y.y, t.y), lerp(x.z, y.z, t.z)} } -lerp_float4 :: proc "c" (x, y, t: float4) -> float4 { return {lerp(x.x, y.x, t.x), lerp(x.y, y.y, y.y), lerp(x.z, y.z, t.z), lerp(x.w, y.w, t.w)} } -lerp_double2 :: proc "c" (x, y, t: double2) -> double2 { return {lerp(x.x, y.x, t.x), lerp(x.y, y.y, t.y)} } -lerp_double3 :: proc "c" (x, y, t: double3) -> double3 { return {lerp(x.x, y.x, t.x), lerp(x.y, y.y, t.y), lerp(x.z, y.z, t.z)} } -lerp_double4 :: proc "c" (x, y, t: double4) -> double4 { return {lerp(x.x, y.x, t.x), lerp(x.y, y.y, y.y), lerp(x.z, y.z, t.z), lerp(x.w, y.w, t.w)} } +@(require_results) lerp_float :: proc "c" (x, y, t: float) -> float { return x*(1-t) + y*t } +@(require_results) lerp_double :: proc "c" (x, y, t: double) -> double { return x*(1-t) + y*t } +@(require_results) lerp_float2 :: proc "c" (x, y, t: float2) -> float2 { return {lerp(x.x, y.x, t.x), lerp(x.y, y.y, t.y)} } +@(require_results) lerp_float3 :: proc "c" (x, y, t: float3) -> float3 { return {lerp(x.x, y.x, t.x), lerp(x.y, y.y, t.y), lerp(x.z, y.z, t.z)} } +@(require_results) lerp_float4 :: proc "c" (x, y, t: float4) -> float4 { return {lerp(x.x, y.x, t.x), lerp(x.y, y.y, y.y), lerp(x.z, y.z, t.z), lerp(x.w, y.w, t.w)} } +@(require_results) lerp_double2 :: proc "c" (x, y, t: double2) -> double2 { return {lerp(x.x, y.x, t.x), lerp(x.y, y.y, t.y)} } +@(require_results) lerp_double3 :: proc "c" (x, y, t: double3) -> double3 { return {lerp(x.x, y.x, t.x), lerp(x.y, y.y, t.y), lerp(x.z, y.z, t.z)} } +@(require_results) lerp_double4 :: proc "c" (x, y, t: double4) -> double4 { return {lerp(x.x, y.x, t.x), lerp(x.y, y.y, y.y), lerp(x.z, y.z, t.z), lerp(x.w, y.w, t.w)} } step :: proc{ @@ -900,14 +900,14 @@ step :: proc{ step_double3, step_double4, } -step_float :: proc "c" (edge, x: float) -> float { return 0 if x < edge else 1 } -step_double :: proc "c" (edge, x: double) -> double { return 0 if x < edge else 1 } -step_float2 :: proc "c" (edge, x: float2) -> float2 { return {step(edge.x, x.x), step(edge.y, x.y)} } -step_float3 :: proc "c" (edge, x: float3) -> float3 { return {step(edge.x, x.x), step(edge.y, x.y), step(edge.z, x.z)} } -step_float4 :: proc "c" (edge, x: float4) -> float4 { return {step(edge.x, x.x), step(edge.y, x.y), step(edge.z, x.z), step(edge.w, x.w)} } -step_double2 :: proc "c" (edge, x: double2) -> double2 { return {step(edge.x, x.x), step(edge.y, x.y)} } -step_double3 :: proc "c" (edge, x: double3) -> double3 { return {step(edge.x, x.x), step(edge.y, x.y), step(edge.z, x.z)} } -step_double4 :: proc "c" (edge, x: double4) -> double4 { return {step(edge.x, x.x), step(edge.y, x.y), step(edge.z, x.z), step(edge.w, x.w)} } +@(require_results) step_float :: proc "c" (edge, x: float) -> float { return 0 if x < edge else 1 } +@(require_results) step_double :: proc "c" (edge, x: double) -> double { return 0 if x < edge else 1 } +@(require_results) step_float2 :: proc "c" (edge, x: float2) -> float2 { return {step(edge.x, x.x), step(edge.y, x.y)} } +@(require_results) step_float3 :: proc "c" (edge, x: float3) -> float3 { return {step(edge.x, x.x), step(edge.y, x.y), step(edge.z, x.z)} } +@(require_results) step_float4 :: proc "c" (edge, x: float4) -> float4 { return {step(edge.x, x.x), step(edge.y, x.y), step(edge.z, x.z), step(edge.w, x.w)} } +@(require_results) step_double2 :: proc "c" (edge, x: double2) -> double2 { return {step(edge.x, x.x), step(edge.y, x.y)} } +@(require_results) step_double3 :: proc "c" (edge, x: double3) -> double3 { return {step(edge.x, x.x), step(edge.y, x.y), step(edge.z, x.z)} } +@(require_results) step_double4 :: proc "c" (edge, x: double4) -> double4 { return {step(edge.x, x.x), step(edge.y, x.y), step(edge.z, x.z), step(edge.w, x.w)} } smoothstep :: proc{ smoothstep_float, @@ -919,20 +919,20 @@ smoothstep :: proc{ smoothstep_double3, smoothstep_double4, } -smoothstep_float :: proc "c" (edge0, edge1, x: float) -> float { +@(require_results) smoothstep_float :: proc "c" (edge0, edge1, x: float) -> float { y := clamp(((x-edge0) / (edge1 - edge0)), 0, 1) return y * y * (3 - 2*y) } -smoothstep_double :: proc "c" (edge0, edge1, x: double) -> double { +@(require_results) smoothstep_double :: proc "c" (edge0, edge1, x: double) -> double { y := clamp(((x-edge0) / (edge1 - edge0)), 0, 1) return y * y * (3 - 2*y) } -smoothstep_float2 :: proc "c" (edge0, edge1, x: float2) -> float2 { return {smoothstep(edge0.x, edge1.x, x.x), smoothstep(edge0.y, edge1.y, x.y)} } -smoothstep_float3 :: proc "c" (edge0, edge1, x: float3) -> float3 { return {smoothstep(edge0.x, edge1.x, x.x), smoothstep(edge0.y, edge1.y, x.y), smoothstep(edge0.z, edge1.z, x.z)} } -smoothstep_float4 :: proc "c" (edge0, edge1, x: float4) -> float4 { return {smoothstep(edge0.x, edge1.x, x.x), smoothstep(edge0.y, edge1.y, x.y), smoothstep(edge0.z, edge1.z, x.z), smoothstep(edge0.w, edge1.w, x.w)} } -smoothstep_double2 :: proc "c" (edge0, edge1, x: double2) -> double2 { return {smoothstep(edge0.x, edge1.x, x.x), smoothstep(edge0.y, edge1.y, x.y)} } -smoothstep_double3 :: proc "c" (edge0, edge1, x: double3) -> double3 { return {smoothstep(edge0.x, edge1.x, x.x), smoothstep(edge0.y, edge1.y, x.y), smoothstep(edge0.z, edge1.z, x.z)} } -smoothstep_double4 :: proc "c" (edge0, edge1, x: double4) -> double4 { return {smoothstep(edge0.x, edge1.x, x.x), smoothstep(edge0.y, edge1.y, x.y), smoothstep(edge0.z, edge1.z, x.z), smoothstep(edge0.w, edge1.w, x.w)} } +@(require_results) smoothstep_float2 :: proc "c" (edge0, edge1, x: float2) -> float2 { return {smoothstep(edge0.x, edge1.x, x.x), smoothstep(edge0.y, edge1.y, x.y)} } +@(require_results) smoothstep_float3 :: proc "c" (edge0, edge1, x: float3) -> float3 { return {smoothstep(edge0.x, edge1.x, x.x), smoothstep(edge0.y, edge1.y, x.y), smoothstep(edge0.z, edge1.z, x.z)} } +@(require_results) smoothstep_float4 :: proc "c" (edge0, edge1, x: float4) -> float4 { return {smoothstep(edge0.x, edge1.x, x.x), smoothstep(edge0.y, edge1.y, x.y), smoothstep(edge0.z, edge1.z, x.z), smoothstep(edge0.w, edge1.w, x.w)} } +@(require_results) smoothstep_double2 :: proc "c" (edge0, edge1, x: double2) -> double2 { return {smoothstep(edge0.x, edge1.x, x.x), smoothstep(edge0.y, edge1.y, x.y)} } +@(require_results) smoothstep_double3 :: proc "c" (edge0, edge1, x: double3) -> double3 { return {smoothstep(edge0.x, edge1.x, x.x), smoothstep(edge0.y, edge1.y, x.y), smoothstep(edge0.z, edge1.z, x.z)} } +@(require_results) smoothstep_double4 :: proc "c" (edge0, edge1, x: double4) -> double4 { return {smoothstep(edge0.x, edge1.x, x.x), smoothstep(edge0.y, edge1.y, x.y), smoothstep(edge0.z, edge1.z, x.z), smoothstep(edge0.w, edge1.w, x.w)} } abs :: proc{ @@ -953,22 +953,22 @@ abs :: proc{ abs_uint3, abs_uint4, } -abs_int :: proc "c" (x: int) -> int { return builtin.abs(x) } -abs_uint :: proc "c" (x: uint) -> uint { return x } -abs_float :: proc "c" (x: float) -> float { return builtin.abs(x) } -abs_double :: proc "c" (x: double) -> double { return builtin.abs(x) } -abs_float2 :: proc "c" (x: float2) -> float2 { return {abs(x.x), abs(x.y)} } -abs_float3 :: proc "c" (x: float3) -> float3 { return {abs(x.x), abs(x.y), abs(x.z)} } -abs_float4 :: proc "c" (x: float4) -> float4 { return {abs(x.x), abs(x.y), abs(x.z), abs(x.w)} } -abs_double2 :: proc "c" (x: double2) -> double2 { return {abs(x.x), abs(x.y)} } -abs_double3 :: proc "c" (x: double3) -> double3 { return {abs(x.x), abs(x.y), abs(x.z)} } -abs_double4 :: proc "c" (x: double4) -> double4 { return {abs(x.x), abs(x.y), abs(x.z), abs(x.w)} } -abs_int2 :: proc "c" (x: int2) -> int2 { return {abs(x.x), abs(x.y)} } -abs_int3 :: proc "c" (x: int3) -> int3 { return {abs(x.x), abs(x.y), abs(x.z)} } -abs_int4 :: proc "c" (x: int4) -> int4 { return {abs(x.x), abs(x.y), abs(x.z), abs(x.w)} } -abs_uint2 :: proc "c" (x: uint2) -> uint2 { return x } -abs_uint3 :: proc "c" (x: uint3) -> uint3 { return x } -abs_uint4 :: proc "c" (x: uint4) -> uint4 { return x } +@(require_results) abs_int :: proc "c" (x: int) -> int { return builtin.abs(x) } +@(require_results) abs_uint :: proc "c" (x: uint) -> uint { return x } +@(require_results) abs_float :: proc "c" (x: float) -> float { return builtin.abs(x) } +@(require_results) abs_double :: proc "c" (x: double) -> double { return builtin.abs(x) } +@(require_results) abs_float2 :: proc "c" (x: float2) -> float2 { return {abs(x.x), abs(x.y)} } +@(require_results) abs_float3 :: proc "c" (x: float3) -> float3 { return {abs(x.x), abs(x.y), abs(x.z)} } +@(require_results) abs_float4 :: proc "c" (x: float4) -> float4 { return {abs(x.x), abs(x.y), abs(x.z), abs(x.w)} } +@(require_results) abs_double2 :: proc "c" (x: double2) -> double2 { return {abs(x.x), abs(x.y)} } +@(require_results) abs_double3 :: proc "c" (x: double3) -> double3 { return {abs(x.x), abs(x.y), abs(x.z)} } +@(require_results) abs_double4 :: proc "c" (x: double4) -> double4 { return {abs(x.x), abs(x.y), abs(x.z), abs(x.w)} } +@(require_results) abs_int2 :: proc "c" (x: int2) -> int2 { return {abs(x.x), abs(x.y)} } +@(require_results) abs_int3 :: proc "c" (x: int3) -> int3 { return {abs(x.x), abs(x.y), abs(x.z)} } +@(require_results) abs_int4 :: proc "c" (x: int4) -> int4 { return {abs(x.x), abs(x.y), abs(x.z), abs(x.w)} } +@(require_results) abs_uint2 :: proc "c" (x: uint2) -> uint2 { return x } +@(require_results) abs_uint3 :: proc "c" (x: uint3) -> uint3 { return x } +@(require_results) abs_uint4 :: proc "c" (x: uint4) -> uint4 { return x } dot :: proc{ dot_int, @@ -988,22 +988,22 @@ dot :: proc{ dot_uint3, dot_uint4, } -dot_int :: proc "c" (a, b: int) -> int { return a*b } -dot_uint :: proc "c" (a, b: uint) -> uint { return a*b } -dot_float :: proc "c" (a, b: float) -> float { return a*b } -dot_double :: proc "c" (a, b: double) -> double { return a*b } -dot_float2 :: proc "c" (a, b: float2) -> float { return a.x*b.x + a.y*b.y } -dot_float3 :: proc "c" (a, b: float3) -> float { return a.x*b.x + a.y*b.y + a.z*b.z } -dot_float4 :: proc "c" (a, b: float4) -> float { return a.x*b.x + a.y*b.y + a.z*b.z + a.w*b.w } -dot_double2 :: proc "c" (a, b: double2) -> double { return a.x*b.x + a.y*b.y } -dot_double3 :: proc "c" (a, b: double3) -> double { return a.x*b.x + a.y*b.y + a.z*b.z } -dot_double4 :: proc "c" (a, b: double4) -> double { return a.x*b.x + a.y*b.y + a.z*b.z + a.w*b.w } -dot_int2 :: proc "c" (a, b: int2) -> int { return a.x*b.x + a.y*b.y } -dot_int3 :: proc "c" (a, b: int3) -> int { return a.x*b.x + a.y*b.y + a.z*b.z } -dot_int4 :: proc "c" (a, b: int4) -> int { return a.x*b.x + a.y*b.y + a.z*b.z + a.w*b.w } -dot_uint2 :: proc "c" (a, b: uint2) -> uint { return a.x*b.x + a.y*b.y } -dot_uint3 :: proc "c" (a, b: uint3) -> uint { return a.x*b.x + a.y*b.y + a.z*b.z } -dot_uint4 :: proc "c" (a, b: uint4) -> uint { return a.x*b.x + a.y*b.y + a.z*b.z + a.w*b.w } +@(require_results) dot_int :: proc "c" (a, b: int) -> int { return a*b } +@(require_results) dot_uint :: proc "c" (a, b: uint) -> uint { return a*b } +@(require_results) dot_float :: proc "c" (a, b: float) -> float { return a*b } +@(require_results) dot_double :: proc "c" (a, b: double) -> double { return a*b } +@(require_results) dot_float2 :: proc "c" (a, b: float2) -> float { return a.x*b.x + a.y*b.y } +@(require_results) dot_float3 :: proc "c" (a, b: float3) -> float { return a.x*b.x + a.y*b.y + a.z*b.z } +@(require_results) dot_float4 :: proc "c" (a, b: float4) -> float { return a.x*b.x + a.y*b.y + a.z*b.z + a.w*b.w } +@(require_results) dot_double2 :: proc "c" (a, b: double2) -> double { return a.x*b.x + a.y*b.y } +@(require_results) dot_double3 :: proc "c" (a, b: double3) -> double { return a.x*b.x + a.y*b.y + a.z*b.z } +@(require_results) dot_double4 :: proc "c" (a, b: double4) -> double { return a.x*b.x + a.y*b.y + a.z*b.z + a.w*b.w } +@(require_results) dot_int2 :: proc "c" (a, b: int2) -> int { return a.x*b.x + a.y*b.y } +@(require_results) dot_int3 :: proc "c" (a, b: int3) -> int { return a.x*b.x + a.y*b.y + a.z*b.z } +@(require_results) dot_int4 :: proc "c" (a, b: int4) -> int { return a.x*b.x + a.y*b.y + a.z*b.z + a.w*b.w } +@(require_results) dot_uint2 :: proc "c" (a, b: uint2) -> uint { return a.x*b.x + a.y*b.y } +@(require_results) dot_uint3 :: proc "c" (a, b: uint3) -> uint { return a.x*b.x + a.y*b.y + a.z*b.z } +@(require_results) dot_uint4 :: proc "c" (a, b: uint4) -> uint { return a.x*b.x + a.y*b.y + a.z*b.z + a.w*b.w } length :: proc{ length_float, @@ -1015,14 +1015,14 @@ length :: proc{ length_double3, length_double4, } -length_float :: proc "c" (x: float) -> float { return builtin.abs(x) } -length_double :: proc "c" (x: double) -> double { return builtin.abs(x) } -length_float2 :: proc "c" (x: float2) -> float { return sqrt(x.x*x.x + x.y*x.y) } -length_float3 :: proc "c" (x: float3) -> float { return sqrt(x.x*x.x + x.y*x.y + x.z*x.z) } -length_float4 :: proc "c" (x: float4) -> float { return sqrt(x.x*x.x + x.y*x.y + x.z*x.z + x.w*x.w) } -length_double2 :: proc "c" (x: double2) -> double { return sqrt(x.x*x.x + x.y*x.y) } -length_double3 :: proc "c" (x: double3) -> double { return sqrt(x.x*x.x + x.y*x.y + x.z*x.z) } -length_double4 :: proc "c" (x: double4) -> double { return sqrt(x.x*x.x + x.y*x.y + x.z*x.z + x.w*x.w) } +@(require_results) length_float :: proc "c" (x: float) -> float { return builtin.abs(x) } +@(require_results) length_double :: proc "c" (x: double) -> double { return builtin.abs(x) } +@(require_results) length_float2 :: proc "c" (x: float2) -> float { return sqrt(x.x*x.x + x.y*x.y) } +@(require_results) length_float3 :: proc "c" (x: float3) -> float { return sqrt(x.x*x.x + x.y*x.y + x.z*x.z) } +@(require_results) length_float4 :: proc "c" (x: float4) -> float { return sqrt(x.x*x.x + x.y*x.y + x.z*x.z + x.w*x.w) } +@(require_results) length_double2 :: proc "c" (x: double2) -> double { return sqrt(x.x*x.x + x.y*x.y) } +@(require_results) length_double3 :: proc "c" (x: double3) -> double { return sqrt(x.x*x.x + x.y*x.y + x.z*x.z) } +@(require_results) length_double4 :: proc "c" (x: double4) -> double { return sqrt(x.x*x.x + x.y*x.y + x.z*x.z + x.w*x.w) } distance :: proc{ @@ -1035,14 +1035,14 @@ distance :: proc{ distance_double3, distance_double4, } -distance_float :: proc "c" (x, y: float) -> float { return length(y-x) } -distance_double :: proc "c" (x, y: double) -> double { return length(y-x) } -distance_float2 :: proc "c" (x, y: float2) -> float { return length(y-x) } -distance_float3 :: proc "c" (x, y: float3) -> float { return length(y-x) } -distance_float4 :: proc "c" (x, y: float4) -> float { return length(y-x) } -distance_double2 :: proc "c" (x, y: double2) -> double { return length(y-x) } -distance_double3 :: proc "c" (x, y: double3) -> double { return length(y-x) } -distance_double4 :: proc "c" (x, y: double4) -> double { return length(y-x) } +@(require_results) distance_float :: proc "c" (x, y: float) -> float { return length(y-x) } +@(require_results) distance_double :: proc "c" (x, y: double) -> double { return length(y-x) } +@(require_results) distance_float2 :: proc "c" (x, y: float2) -> float { return length(y-x) } +@(require_results) distance_float3 :: proc "c" (x, y: float3) -> float { return length(y-x) } +@(require_results) distance_float4 :: proc "c" (x, y: float4) -> float { return length(y-x) } +@(require_results) distance_double2 :: proc "c" (x, y: double2) -> double { return length(y-x) } +@(require_results) distance_double3 :: proc "c" (x, y: double3) -> double { return length(y-x) } +@(require_results) distance_double4 :: proc "c" (x, y: double4) -> double { return length(y-x) } cross :: proc{ @@ -1051,19 +1051,19 @@ cross :: proc{ cross_int3, } -cross_float3 :: proc "c" (a, b: float3) -> (c: float3) { +@(require_results) cross_float3 :: proc "c" (a, b: float3) -> (c: float3) { c.x = a.y*b.z - b.y*a.z c.y = a.z*b.x - b.z*a.x c.z = a.x*b.y - b.x*a.y return } -cross_double3 :: proc "c" (a, b: double3) -> (c: double3) { +@(require_results) cross_double3 :: proc "c" (a, b: double3) -> (c: double3) { c.x = a.y*b.z - b.y*a.z c.y = a.z*b.x - b.z*a.x c.z = a.x*b.y - b.x*a.y return } -cross_int3 :: proc "c" (a, b: int3) -> (c: int3) { +@(require_results) cross_int3 :: proc "c" (a, b: int3) -> (c: int3) { c.x = a.y*b.z - b.y*a.z c.y = a.z*b.x - b.z*a.x c.z = a.x*b.y - b.x*a.y @@ -1080,14 +1080,14 @@ normalize :: proc{ normalize_double3, normalize_double4, } -normalize_float :: proc "c" (x: float) -> float { return 1.0 } -normalize_double :: proc "c" (x: double) -> double { return 1.0 } -normalize_float2 :: proc "c" (x: float2) -> float2 { return x / length(x) } -normalize_float3 :: proc "c" (x: float3) -> float3 { return x / length(x) } -normalize_float4 :: proc "c" (x: float4) -> float4 { return x / length(x) } -normalize_double2 :: proc "c" (x: double2) -> double2 { return x / length(x) } -normalize_double3 :: proc "c" (x: double3) -> double3 { return x / length(x) } -normalize_double4 :: proc "c" (x: double4) -> double4 { return x / length(x) } +@(require_results) normalize_float :: proc "c" (x: float) -> float { return 1.0 } +@(require_results) normalize_double :: proc "c" (x: double) -> double { return 1.0 } +@(require_results) normalize_float2 :: proc "c" (x: float2) -> float2 { return x / length(x) } +@(require_results) normalize_float3 :: proc "c" (x: float3) -> float3 { return x / length(x) } +@(require_results) normalize_float4 :: proc "c" (x: float4) -> float4 { return x / length(x) } +@(require_results) normalize_double2 :: proc "c" (x: double2) -> double2 { return x / length(x) } +@(require_results) normalize_double3 :: proc "c" (x: double3) -> double3 { return x / length(x) } +@(require_results) normalize_double4 :: proc "c" (x: double4) -> double4 { return x / length(x) } faceforward :: proc{ @@ -1100,14 +1100,14 @@ faceforward :: proc{ faceforward_double3, faceforward_double4, } -faceforward_float :: proc "c" (N, I, Nref: float) -> float { return N if dot(I, Nref) < 0 else -N } -faceforward_double :: proc "c" (N, I, Nref: double) -> double { return N if dot(I, Nref) < 0 else -N } -faceforward_float2 :: proc "c" (N, I, Nref: float2) -> float2 { return N if dot(I, Nref) < 0 else -N } -faceforward_float3 :: proc "c" (N, I, Nref: float3) -> float3 { return N if dot(I, Nref) < 0 else -N } -faceforward_float4 :: proc "c" (N, I, Nref: float4) -> float4 { return N if dot(I, Nref) < 0 else -N } -faceforward_double2 :: proc "c" (N, I, Nref: double2) -> double2 { return N if dot(I, Nref) < 0 else -N } -faceforward_double3 :: proc "c" (N, I, Nref: double3) -> double3 { return N if dot(I, Nref) < 0 else -N } -faceforward_double4 :: proc "c" (N, I, Nref: double4) -> double4 { return N if dot(I, Nref) < 0 else -N } +@(require_results) faceforward_float :: proc "c" (N, I, Nref: float) -> float { return N if dot(I, Nref) < 0 else -N } +@(require_results) faceforward_double :: proc "c" (N, I, Nref: double) -> double { return N if dot(I, Nref) < 0 else -N } +@(require_results) faceforward_float2 :: proc "c" (N, I, Nref: float2) -> float2 { return N if dot(I, Nref) < 0 else -N } +@(require_results) faceforward_float3 :: proc "c" (N, I, Nref: float3) -> float3 { return N if dot(I, Nref) < 0 else -N } +@(require_results) faceforward_float4 :: proc "c" (N, I, Nref: float4) -> float4 { return N if dot(I, Nref) < 0 else -N } +@(require_results) faceforward_double2 :: proc "c" (N, I, Nref: double2) -> double2 { return N if dot(I, Nref) < 0 else -N } +@(require_results) faceforward_double3 :: proc "c" (N, I, Nref: double3) -> double3 { return N if dot(I, Nref) < 0 else -N } +@(require_results) faceforward_double4 :: proc "c" (N, I, Nref: double4) -> double4 { return N if dot(I, Nref) < 0 else -N } reflect :: proc{ @@ -1120,14 +1120,14 @@ reflect :: proc{ reflect_double3, reflect_double4, } -reflect_float :: proc "c" (I, N: float) -> float { return I - 2*N*dot(N, I) } -reflect_double :: proc "c" (I, N: double) -> double { return I - 2*N*dot(N, I) } -reflect_float2 :: proc "c" (I, N: float2) -> float2 { return I - 2*N*dot(N, I) } -reflect_float3 :: proc "c" (I, N: float3) -> float3 { return I - 2*N*dot(N, I) } -reflect_float4 :: proc "c" (I, N: float4) -> float4 { return I - 2*N*dot(N, I) } -reflect_double2 :: proc "c" (I, N: double2) -> double2 { return I - 2*N*dot(N, I) } -reflect_double3 :: proc "c" (I, N: double3) -> double3 { return I - 2*N*dot(N, I) } -reflect_double4 :: proc "c" (I, N: double4) -> double4 { return I - 2*N*dot(N, I) } +@(require_results) reflect_float :: proc "c" (I, N: float) -> float { return I - 2*N*dot(N, I) } +@(require_results) reflect_double :: proc "c" (I, N: double) -> double { return I - 2*N*dot(N, I) } +@(require_results) reflect_float2 :: proc "c" (I, N: float2) -> float2 { return I - 2*N*dot(N, I) } +@(require_results) reflect_float3 :: proc "c" (I, N: float3) -> float3 { return I - 2*N*dot(N, I) } +@(require_results) reflect_float4 :: proc "c" (I, N: float4) -> float4 { return I - 2*N*dot(N, I) } +@(require_results) reflect_double2 :: proc "c" (I, N: double2) -> double2 { return I - 2*N*dot(N, I) } +@(require_results) reflect_double3 :: proc "c" (I, N: double3) -> double3 { return I - 2*N*dot(N, I) } +@(require_results) reflect_double4 :: proc "c" (I, N: double4) -> double4 { return I - 2*N*dot(N, I) } @@ -1142,49 +1142,57 @@ refract :: proc{ refract_double3, refract_double4, } -refract_float :: proc "c" (i, n, eta: float) -> float { +@(require_results) +refract_float :: proc "c" (i, n, eta: float) -> float { cosi := dot(-i, n) cost2 := 1 - eta*eta*(1 - cosi*cosi) t := eta*i + ((eta*cosi - sqrt(abs(cost2))) * n) return t * float(int(cost2 > 0)) } -refract_double :: proc "c" (i, n, eta: double) -> double { +@(require_results) +refract_double :: proc "c" (i, n, eta: double) -> double { cosi := dot(-i, n) cost2 := 1 - eta*eta*(1 - cosi*cosi) t := eta*i + ((eta*cosi - sqrt(abs(cost2))) * n) return t * double(int(cost2 > 0)) } -refract_float2 :: proc "c" (i, n, eta: float2) -> float2 { +@(require_results) +refract_float2 :: proc "c" (i, n, eta: float2) -> float2 { cosi := dot(-i, n) cost2 := 1 - eta*eta*(1 - cosi*cosi) t := eta*i + ((eta*cosi - sqrt(abs(cost2))) * n) return t * float2{float(int(cost2.x > 0)), float(int(cost2.y > 0))} } -refract_float3 :: proc "c" (i, n, eta: float3) -> float3 { +@(require_results) +refract_float3 :: proc "c" (i, n, eta: float3) -> float3 { cosi := dot(-i, n) cost2 := 1 - eta*eta*(1 - cosi*cosi) t := eta*i + ((eta*cosi - sqrt(abs(cost2))) * n) return t * float3{float(int(cost2.x > 0)), float(int(cost2.y > 0)), float(int(cost2.z > 0))} } -refract_float4 :: proc "c" (i, n, eta: float4) -> float4 { +@(require_results) +refract_float4 :: proc "c" (i, n, eta: float4) -> float4 { cosi := dot(-i, n) cost2 := 1 - eta*eta*(1 - cosi*cosi) t := eta*i + ((eta*cosi - sqrt(abs(cost2))) * n) return t * float4{float(int(cost2.x > 0)), float(int(cost2.y > 0)), float(int(cost2.z > 0)), float(int(cost2.w > 0))} } -refract_double2 :: proc "c" (i, n, eta: double2) -> double2 { +@(require_results) +refract_double2 :: proc "c" (i, n, eta: double2) -> double2 { cosi := dot(-i, n) cost2 := 1 - eta*eta*(1 - cosi*cosi) t := eta*i + ((eta*cosi - sqrt(abs(cost2))) * n) return t * double2{double(int(cost2.x > 0)), double(int(cost2.y > 0))} } -refract_double3 :: proc "c" (i, n, eta: double3) -> double3 { +@(require_results) +refract_double3 :: proc "c" (i, n, eta: double3) -> double3 { cosi := dot(-i, n) cost2 := 1 - eta*eta*(1 - cosi*cosi) t := eta*i + ((eta*cosi - sqrt(abs(cost2))) * n) return t * double3{double(int(cost2.x > 0)), double(int(cost2.y > 0)), double(int(cost2.z > 0))} } -refract_double4 :: proc "c" (i, n, eta: double4) -> double4 { +@(require_results) +refract_double4 :: proc "c" (i, n, eta: double4) -> double4 { cosi := dot(-i, n) cost2 := 1 - eta*eta*(1 - cosi*cosi) t := eta*i + ((eta*cosi - sqrt(abs(cost2))) * n) @@ -1196,18 +1204,18 @@ scalarTripleProduct :: proc{ scalarTripleProduct_double3, scalarTripleProduct_int3, } -scalarTripleProduct_float3 :: proc "c" (a, b, c: float3) -> float { return dot(a, cross(b, c)) } -scalarTripleProduct_double3 :: proc "c" (a, b, c: double3) -> double { return dot(a, cross(b, c)) } -scalarTripleProduct_int3 :: proc "c" (a, b, c: int3) -> int { return dot(a, cross(b, c)) } +@(require_results) scalarTripleProduct_float3 :: proc "c" (a, b, c: float3) -> float { return dot(a, cross(b, c)) } +@(require_results) scalarTripleProduct_double3 :: proc "c" (a, b, c: double3) -> double { return dot(a, cross(b, c)) } +@(require_results) scalarTripleProduct_int3 :: proc "c" (a, b, c: int3) -> int { return dot(a, cross(b, c)) } vectorTripleProduct :: proc { vectorTripleProduct_float3, vectorTripleProduct_double3, vectorTripleProduct_int3, } -vectorTripleProduct_float3 :: proc "c" (a, b, c: float3) -> float3 { return cross(a, cross(b, c)) } -vectorTripleProduct_double3 :: proc "c" (a, b, c: double3) -> double3 { return cross(a, cross(b, c)) } -vectorTripleProduct_int3 :: proc "c" (a, b, c: int3) -> int3 { return cross(a, cross(b, c)) } +@(require_results) vectorTripleProduct_float3 :: proc "c" (a, b, c: float3) -> float3 { return cross(a, cross(b, c)) } +@(require_results) vectorTripleProduct_double3 :: proc "c" (a, b, c: double3) -> double3 { return cross(a, cross(b, c)) } +@(require_results) vectorTripleProduct_int3 :: proc "c" (a, b, c: int3) -> int3 { return cross(a, cross(b, c)) } // Vector Relational Procedures @@ -1230,22 +1238,22 @@ lessThan :: proc{ lessThan_int4, lessThan_uint4, } -lessThan_float :: proc "c" (a, b: float) -> bool { return a < b } -lessThan_double :: proc "c" (a, b: double) -> bool { return a < b } -lessThan_int :: proc "c" (a, b: int) -> bool { return a < b } -lessThan_uint :: proc "c" (a, b: uint) -> bool { return a < b } -lessThan_float2 :: proc "c" (a, b: float2) -> bool2 { return {a.x < b.x, a.y < b.y} } -lessThan_double2 :: proc "c" (a, b: double2) -> bool2 { return {a.x < b.x, a.y < b.y} } -lessThan_int2 :: proc "c" (a, b: int2) -> bool2 { return {a.x < b.x, a.y < b.y} } -lessThan_uint2 :: proc "c" (a, b: uint2) -> bool2 { return {a.x < b.x, a.y < b.y} } -lessThan_float3 :: proc "c" (a, b: float3) -> bool3 { return {a.x < b.x, a.y < b.y, a.z < b.z} } -lessThan_double3 :: proc "c" (a, b: double3) -> bool3 { return {a.x < b.x, a.y < b.y, a.z < b.z} } -lessThan_int3 :: proc "c" (a, b: int3) -> bool3 { return {a.x < b.x, a.y < b.y, a.z < b.z} } -lessThan_uint3 :: proc "c" (a, b: uint3) -> bool3 { return {a.x < b.x, a.y < b.y, a.z < b.z} } -lessThan_float4 :: proc "c" (a, b: float4) -> bool4 { return {a.x < b.x, a.y < b.y, a.z < b.z, a.w < b.w} } -lessThan_double4 :: proc "c" (a, b: double4) -> bool4 { return {a.x < b.x, a.y < b.y, a.z < b.z, a.w < b.w} } -lessThan_int4 :: proc "c" (a, b: int4) -> bool4 { return {a.x < b.x, a.y < b.y, a.z < b.z, a.w < b.w} } -lessThan_uint4 :: proc "c" (a, b: uint4) -> bool4 { return {a.x < b.x, a.y < b.y, a.z < b.z, a.w < b.w} } +@(require_results) lessThan_float :: proc "c" (a, b: float) -> bool { return a < b } +@(require_results) lessThan_double :: proc "c" (a, b: double) -> bool { return a < b } +@(require_results) lessThan_int :: proc "c" (a, b: int) -> bool { return a < b } +@(require_results) lessThan_uint :: proc "c" (a, b: uint) -> bool { return a < b } +@(require_results) lessThan_float2 :: proc "c" (a, b: float2) -> bool2 { return {a.x < b.x, a.y < b.y} } +@(require_results) lessThan_double2 :: proc "c" (a, b: double2) -> bool2 { return {a.x < b.x, a.y < b.y} } +@(require_results) lessThan_int2 :: proc "c" (a, b: int2) -> bool2 { return {a.x < b.x, a.y < b.y} } +@(require_results) lessThan_uint2 :: proc "c" (a, b: uint2) -> bool2 { return {a.x < b.x, a.y < b.y} } +@(require_results) lessThan_float3 :: proc "c" (a, b: float3) -> bool3 { return {a.x < b.x, a.y < b.y, a.z < b.z} } +@(require_results) lessThan_double3 :: proc "c" (a, b: double3) -> bool3 { return {a.x < b.x, a.y < b.y, a.z < b.z} } +@(require_results) lessThan_int3 :: proc "c" (a, b: int3) -> bool3 { return {a.x < b.x, a.y < b.y, a.z < b.z} } +@(require_results) lessThan_uint3 :: proc "c" (a, b: uint3) -> bool3 { return {a.x < b.x, a.y < b.y, a.z < b.z} } +@(require_results) lessThan_float4 :: proc "c" (a, b: float4) -> bool4 { return {a.x < b.x, a.y < b.y, a.z < b.z, a.w < b.w} } +@(require_results) lessThan_double4 :: proc "c" (a, b: double4) -> bool4 { return {a.x < b.x, a.y < b.y, a.z < b.z, a.w < b.w} } +@(require_results) lessThan_int4 :: proc "c" (a, b: int4) -> bool4 { return {a.x < b.x, a.y < b.y, a.z < b.z, a.w < b.w} } +@(require_results) lessThan_uint4 :: proc "c" (a, b: uint4) -> bool4 { return {a.x < b.x, a.y < b.y, a.z < b.z, a.w < b.w} } lessThanEqual :: proc{ @@ -1266,22 +1274,22 @@ lessThanEqual :: proc{ lessThanEqual_int4, lessThanEqual_uint4, } -lessThanEqual_float :: proc "c" (a, b: float) -> bool { return a <= b } -lessThanEqual_double :: proc "c" (a, b: double) -> bool { return a <= b } -lessThanEqual_int :: proc "c" (a, b: int) -> bool { return a <= b } -lessThanEqual_uint :: proc "c" (a, b: uint) -> bool { return a <= b } -lessThanEqual_float2 :: proc "c" (a, b: float2) -> bool2 { return {a.x <= b.x, a.y <= b.y} } -lessThanEqual_double2 :: proc "c" (a, b: double2) -> bool2 { return {a.x <= b.x, a.y <= b.y} } -lessThanEqual_int2 :: proc "c" (a, b: int2) -> bool2 { return {a.x <= b.x, a.y <= b.y} } -lessThanEqual_uint2 :: proc "c" (a, b: uint2) -> bool2 { return {a.x <= b.x, a.y <= b.y} } -lessThanEqual_float3 :: proc "c" (a, b: float3) -> bool3 { return {a.x <= b.x, a.y <= b.y, a.z <= b.z} } -lessThanEqual_double3 :: proc "c" (a, b: double3) -> bool3 { return {a.x <= b.x, a.y <= b.y, a.z <= b.z} } -lessThanEqual_int3 :: proc "c" (a, b: int3) -> bool3 { return {a.x <= b.x, a.y <= b.y, a.z <= b.z} } -lessThanEqual_uint3 :: proc "c" (a, b: uint3) -> bool3 { return {a.x <= b.x, a.y <= b.y, a.z <= b.z} } -lessThanEqual_float4 :: proc "c" (a, b: float4) -> bool4 { return {a.x <= b.x, a.y <= b.y, a.z <= b.z, a.w <= b.w} } -lessThanEqual_double4 :: proc "c" (a, b: double4) -> bool4 { return {a.x <= b.x, a.y <= b.y, a.z <= b.z, a.w <= b.w} } -lessThanEqual_int4 :: proc "c" (a, b: int4) -> bool4 { return {a.x <= b.x, a.y <= b.y, a.z <= b.z, a.w <= b.w} } -lessThanEqual_uint4 :: proc "c" (a, b: uint4) -> bool4 { return {a.x <= b.x, a.y <= b.y, a.z <= b.z, a.w <= b.w} } +@(require_results) lessThanEqual_float :: proc "c" (a, b: float) -> bool { return a <= b } +@(require_results) lessThanEqual_double :: proc "c" (a, b: double) -> bool { return a <= b } +@(require_results) lessThanEqual_int :: proc "c" (a, b: int) -> bool { return a <= b } +@(require_results) lessThanEqual_uint :: proc "c" (a, b: uint) -> bool { return a <= b } +@(require_results) lessThanEqual_float2 :: proc "c" (a, b: float2) -> bool2 { return {a.x <= b.x, a.y <= b.y} } +@(require_results) lessThanEqual_double2 :: proc "c" (a, b: double2) -> bool2 { return {a.x <= b.x, a.y <= b.y} } +@(require_results) lessThanEqual_int2 :: proc "c" (a, b: int2) -> bool2 { return {a.x <= b.x, a.y <= b.y} } +@(require_results) lessThanEqual_uint2 :: proc "c" (a, b: uint2) -> bool2 { return {a.x <= b.x, a.y <= b.y} } +@(require_results) lessThanEqual_float3 :: proc "c" (a, b: float3) -> bool3 { return {a.x <= b.x, a.y <= b.y, a.z <= b.z} } +@(require_results) lessThanEqual_double3 :: proc "c" (a, b: double3) -> bool3 { return {a.x <= b.x, a.y <= b.y, a.z <= b.z} } +@(require_results) lessThanEqual_int3 :: proc "c" (a, b: int3) -> bool3 { return {a.x <= b.x, a.y <= b.y, a.z <= b.z} } +@(require_results) lessThanEqual_uint3 :: proc "c" (a, b: uint3) -> bool3 { return {a.x <= b.x, a.y <= b.y, a.z <= b.z} } +@(require_results) lessThanEqual_float4 :: proc "c" (a, b: float4) -> bool4 { return {a.x <= b.x, a.y <= b.y, a.z <= b.z, a.w <= b.w} } +@(require_results) lessThanEqual_double4 :: proc "c" (a, b: double4) -> bool4 { return {a.x <= b.x, a.y <= b.y, a.z <= b.z, a.w <= b.w} } +@(require_results) lessThanEqual_int4 :: proc "c" (a, b: int4) -> bool4 { return {a.x <= b.x, a.y <= b.y, a.z <= b.z, a.w <= b.w} } +@(require_results) lessThanEqual_uint4 :: proc "c" (a, b: uint4) -> bool4 { return {a.x <= b.x, a.y <= b.y, a.z <= b.z, a.w <= b.w} } greaterThan :: proc{ @@ -1302,22 +1310,22 @@ greaterThan :: proc{ greaterThan_int4, greaterThan_uint4, } -greaterThan_float :: proc "c" (a, b: float) -> bool { return a > b } -greaterThan_double :: proc "c" (a, b: double) -> bool { return a > b } -greaterThan_int :: proc "c" (a, b: int) -> bool { return a > b } -greaterThan_uint :: proc "c" (a, b: uint) -> bool { return a > b } -greaterThan_float2 :: proc "c" (a, b: float2) -> bool2 { return {a.x > b.x, a.y > b.y} } -greaterThan_double2 :: proc "c" (a, b: double2) -> bool2 { return {a.x > b.x, a.y > b.y} } -greaterThan_int2 :: proc "c" (a, b: int2) -> bool2 { return {a.x > b.x, a.y > b.y} } -greaterThan_uint2 :: proc "c" (a, b: uint2) -> bool2 { return {a.x > b.x, a.y > b.y} } -greaterThan_float3 :: proc "c" (a, b: float3) -> bool3 { return {a.x > b.x, a.y > b.y, a.z > b.z} } -greaterThan_double3 :: proc "c" (a, b: double3) -> bool3 { return {a.x > b.x, a.y > b.y, a.z > b.z} } -greaterThan_int3 :: proc "c" (a, b: int3) -> bool3 { return {a.x > b.x, a.y > b.y, a.z > b.z} } -greaterThan_uint3 :: proc "c" (a, b: uint3) -> bool3 { return {a.x > b.x, a.y > b.y, a.z > b.z} } -greaterThan_float4 :: proc "c" (a, b: float4) -> bool4 { return {a.x > b.x, a.y > b.y, a.z > b.z, a.w > b.w} } -greaterThan_double4 :: proc "c" (a, b: double4) -> bool4 { return {a.x > b.x, a.y > b.y, a.z > b.z, a.w > b.w} } -greaterThan_int4 :: proc "c" (a, b: int4) -> bool4 { return {a.x > b.x, a.y > b.y, a.z > b.z, a.w > b.w} } -greaterThan_uint4 :: proc "c" (a, b: uint4) -> bool4 { return {a.x > b.x, a.y > b.y, a.z > b.z, a.w > b.w} } +@(require_results) greaterThan_float :: proc "c" (a, b: float) -> bool { return a > b } +@(require_results) greaterThan_double :: proc "c" (a, b: double) -> bool { return a > b } +@(require_results) greaterThan_int :: proc "c" (a, b: int) -> bool { return a > b } +@(require_results) greaterThan_uint :: proc "c" (a, b: uint) -> bool { return a > b } +@(require_results) greaterThan_float2 :: proc "c" (a, b: float2) -> bool2 { return {a.x > b.x, a.y > b.y} } +@(require_results) greaterThan_double2 :: proc "c" (a, b: double2) -> bool2 { return {a.x > b.x, a.y > b.y} } +@(require_results) greaterThan_int2 :: proc "c" (a, b: int2) -> bool2 { return {a.x > b.x, a.y > b.y} } +@(require_results) greaterThan_uint2 :: proc "c" (a, b: uint2) -> bool2 { return {a.x > b.x, a.y > b.y} } +@(require_results) greaterThan_float3 :: proc "c" (a, b: float3) -> bool3 { return {a.x > b.x, a.y > b.y, a.z > b.z} } +@(require_results) greaterThan_double3 :: proc "c" (a, b: double3) -> bool3 { return {a.x > b.x, a.y > b.y, a.z > b.z} } +@(require_results) greaterThan_int3 :: proc "c" (a, b: int3) -> bool3 { return {a.x > b.x, a.y > b.y, a.z > b.z} } +@(require_results) greaterThan_uint3 :: proc "c" (a, b: uint3) -> bool3 { return {a.x > b.x, a.y > b.y, a.z > b.z} } +@(require_results) greaterThan_float4 :: proc "c" (a, b: float4) -> bool4 { return {a.x > b.x, a.y > b.y, a.z > b.z, a.w > b.w} } +@(require_results) greaterThan_double4 :: proc "c" (a, b: double4) -> bool4 { return {a.x > b.x, a.y > b.y, a.z > b.z, a.w > b.w} } +@(require_results) greaterThan_int4 :: proc "c" (a, b: int4) -> bool4 { return {a.x > b.x, a.y > b.y, a.z > b.z, a.w > b.w} } +@(require_results) greaterThan_uint4 :: proc "c" (a, b: uint4) -> bool4 { return {a.x > b.x, a.y > b.y, a.z > b.z, a.w > b.w} } greaterThanEqual :: proc{ @@ -1338,22 +1346,22 @@ greaterThanEqual :: proc{ greaterThanEqual_int4, greaterThanEqual_uint4, } -greaterThanEqual_float :: proc "c" (a, b: float) -> bool { return a >= b } -greaterThanEqual_double :: proc "c" (a, b: double) -> bool { return a >= b } -greaterThanEqual_int :: proc "c" (a, b: int) -> bool { return a >= b } -greaterThanEqual_uint :: proc "c" (a, b: uint) -> bool { return a >= b } -greaterThanEqual_float2 :: proc "c" (a, b: float2) -> bool2 { return {a.x >= b.x, a.y >= b.y} } -greaterThanEqual_double2 :: proc "c" (a, b: double2) -> bool2 { return {a.x >= b.x, a.y >= b.y} } -greaterThanEqual_int2 :: proc "c" (a, b: int2) -> bool2 { return {a.x >= b.x, a.y >= b.y} } -greaterThanEqual_uint2 :: proc "c" (a, b: uint2) -> bool2 { return {a.x >= b.x, a.y >= b.y} } -greaterThanEqual_float3 :: proc "c" (a, b: float3) -> bool3 { return {a.x >= b.x, a.y >= b.y, a.z >= b.z} } -greaterThanEqual_double3 :: proc "c" (a, b: double3) -> bool3 { return {a.x >= b.x, a.y >= b.y, a.z >= b.z} } -greaterThanEqual_int3 :: proc "c" (a, b: int3) -> bool3 { return {a.x >= b.x, a.y >= b.y, a.z >= b.z} } -greaterThanEqual_uint3 :: proc "c" (a, b: uint3) -> bool3 { return {a.x >= b.x, a.y >= b.y, a.z >= b.z} } -greaterThanEqual_float4 :: proc "c" (a, b: float4) -> bool4 { return {a.x >= b.x, a.y >= b.y, a.z >= b.z, a.w >= b.w} } -greaterThanEqual_double4 :: proc "c" (a, b: double4) -> bool4 { return {a.x >= b.x, a.y >= b.y, a.z >= b.z, a.w >= b.w} } -greaterThanEqual_int4 :: proc "c" (a, b: int4) -> bool4 { return {a.x >= b.x, a.y >= b.y, a.z >= b.z, a.w >= b.w} } -greaterThanEqual_uint4 :: proc "c" (a, b: uint4) -> bool4 { return {a.x >= b.x, a.y >= b.y, a.z >= b.z, a.w >= b.w} } +@(require_results) greaterThanEqual_float :: proc "c" (a, b: float) -> bool { return a >= b } +@(require_results) greaterThanEqual_double :: proc "c" (a, b: double) -> bool { return a >= b } +@(require_results) greaterThanEqual_int :: proc "c" (a, b: int) -> bool { return a >= b } +@(require_results) greaterThanEqual_uint :: proc "c" (a, b: uint) -> bool { return a >= b } +@(require_results) greaterThanEqual_float2 :: proc "c" (a, b: float2) -> bool2 { return {a.x >= b.x, a.y >= b.y} } +@(require_results) greaterThanEqual_double2 :: proc "c" (a, b: double2) -> bool2 { return {a.x >= b.x, a.y >= b.y} } +@(require_results) greaterThanEqual_int2 :: proc "c" (a, b: int2) -> bool2 { return {a.x >= b.x, a.y >= b.y} } +@(require_results) greaterThanEqual_uint2 :: proc "c" (a, b: uint2) -> bool2 { return {a.x >= b.x, a.y >= b.y} } +@(require_results) greaterThanEqual_float3 :: proc "c" (a, b: float3) -> bool3 { return {a.x >= b.x, a.y >= b.y, a.z >= b.z} } +@(require_results) greaterThanEqual_double3 :: proc "c" (a, b: double3) -> bool3 { return {a.x >= b.x, a.y >= b.y, a.z >= b.z} } +@(require_results) greaterThanEqual_int3 :: proc "c" (a, b: int3) -> bool3 { return {a.x >= b.x, a.y >= b.y, a.z >= b.z} } +@(require_results) greaterThanEqual_uint3 :: proc "c" (a, b: uint3) -> bool3 { return {a.x >= b.x, a.y >= b.y, a.z >= b.z} } +@(require_results) greaterThanEqual_float4 :: proc "c" (a, b: float4) -> bool4 { return {a.x >= b.x, a.y >= b.y, a.z >= b.z, a.w >= b.w} } +@(require_results) greaterThanEqual_double4 :: proc "c" (a, b: double4) -> bool4 { return {a.x >= b.x, a.y >= b.y, a.z >= b.z, a.w >= b.w} } +@(require_results) greaterThanEqual_int4 :: proc "c" (a, b: int4) -> bool4 { return {a.x >= b.x, a.y >= b.y, a.z >= b.z, a.w >= b.w} } +@(require_results) greaterThanEqual_uint4 :: proc "c" (a, b: uint4) -> bool4 { return {a.x >= b.x, a.y >= b.y, a.z >= b.z, a.w >= b.w} } equal :: proc{ @@ -1374,22 +1382,22 @@ equal :: proc{ equal_int4, equal_uint4, } -equal_float :: proc "c" (a, b: float) -> bool { return a == b } -equal_double :: proc "c" (a, b: double) -> bool { return a == b } -equal_int :: proc "c" (a, b: int) -> bool { return a == b } -equal_uint :: proc "c" (a, b: uint) -> bool { return a == b } -equal_float2 :: proc "c" (a, b: float2) -> bool2 { return {a.x == b.x, a.y == b.y} } -equal_double2 :: proc "c" (a, b: double2) -> bool2 { return {a.x == b.x, a.y == b.y} } -equal_int2 :: proc "c" (a, b: int2) -> bool2 { return {a.x == b.x, a.y == b.y} } -equal_uint2 :: proc "c" (a, b: uint2) -> bool2 { return {a.x == b.x, a.y == b.y} } -equal_float3 :: proc "c" (a, b: float3) -> bool3 { return {a.x == b.x, a.y == b.y, a.z == b.z} } -equal_double3 :: proc "c" (a, b: double3) -> bool3 { return {a.x == b.x, a.y == b.y, a.z == b.z} } -equal_int3 :: proc "c" (a, b: int3) -> bool3 { return {a.x == b.x, a.y == b.y, a.z == b.z} } -equal_uint3 :: proc "c" (a, b: uint3) -> bool3 { return {a.x == b.x, a.y == b.y, a.z == b.z} } -equal_float4 :: proc "c" (a, b: float4) -> bool4 { return {a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w} } -equal_double4 :: proc "c" (a, b: double4) -> bool4 { return {a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w} } -equal_int4 :: proc "c" (a, b: int4) -> bool4 { return {a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w} } -equal_uint4 :: proc "c" (a, b: uint4) -> bool4 { return {a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w} } +@(require_results) equal_float :: proc "c" (a, b: float) -> bool { return a == b } +@(require_results) equal_double :: proc "c" (a, b: double) -> bool { return a == b } +@(require_results) equal_int :: proc "c" (a, b: int) -> bool { return a == b } +@(require_results) equal_uint :: proc "c" (a, b: uint) -> bool { return a == b } +@(require_results) equal_float2 :: proc "c" (a, b: float2) -> bool2 { return {a.x == b.x, a.y == b.y} } +@(require_results) equal_double2 :: proc "c" (a, b: double2) -> bool2 { return {a.x == b.x, a.y == b.y} } +@(require_results) equal_int2 :: proc "c" (a, b: int2) -> bool2 { return {a.x == b.x, a.y == b.y} } +@(require_results) equal_uint2 :: proc "c" (a, b: uint2) -> bool2 { return {a.x == b.x, a.y == b.y} } +@(require_results) equal_float3 :: proc "c" (a, b: float3) -> bool3 { return {a.x == b.x, a.y == b.y, a.z == b.z} } +@(require_results) equal_double3 :: proc "c" (a, b: double3) -> bool3 { return {a.x == b.x, a.y == b.y, a.z == b.z} } +@(require_results) equal_int3 :: proc "c" (a, b: int3) -> bool3 { return {a.x == b.x, a.y == b.y, a.z == b.z} } +@(require_results) equal_uint3 :: proc "c" (a, b: uint3) -> bool3 { return {a.x == b.x, a.y == b.y, a.z == b.z} } +@(require_results) equal_float4 :: proc "c" (a, b: float4) -> bool4 { return {a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w} } +@(require_results) equal_double4 :: proc "c" (a, b: double4) -> bool4 { return {a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w} } +@(require_results) equal_int4 :: proc "c" (a, b: int4) -> bool4 { return {a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w} } +@(require_results) equal_uint4 :: proc "c" (a, b: uint4) -> bool4 { return {a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w} } notEqual :: proc{ notEqual_float, @@ -1409,22 +1417,22 @@ notEqual :: proc{ notEqual_int4, notEqual_uint4, } -notEqual_float :: proc "c" (a, b: float) -> bool { return a != b } -notEqual_double :: proc "c" (a, b: double) -> bool { return a != b } -notEqual_int :: proc "c" (a, b: int) -> bool { return a != b } -notEqual_uint :: proc "c" (a, b: uint) -> bool { return a != b } -notEqual_float2 :: proc "c" (a, b: float2) -> bool2 { return {a.x != b.x, a.y != b.y} } -notEqual_double2 :: proc "c" (a, b: double2) -> bool2 { return {a.x != b.x, a.y != b.y} } -notEqual_int2 :: proc "c" (a, b: int2) -> bool2 { return {a.x != b.x, a.y != b.y} } -notEqual_uint2 :: proc "c" (a, b: uint2) -> bool2 { return {a.x != b.x, a.y != b.y} } -notEqual_float3 :: proc "c" (a, b: float3) -> bool3 { return {a.x != b.x, a.y != b.y, a.z != b.z} } -notEqual_double3 :: proc "c" (a, b: double3) -> bool3 { return {a.x != b.x, a.y != b.y, a.z != b.z} } -notEqual_int3 :: proc "c" (a, b: int3) -> bool3 { return {a.x != b.x, a.y != b.y, a.z != b.z} } -notEqual_uint3 :: proc "c" (a, b: uint3) -> bool3 { return {a.x != b.x, a.y != b.y, a.z != b.z} } -notEqual_float4 :: proc "c" (a, b: float4) -> bool4 { return {a.x != b.x, a.y != b.y, a.z != b.z, a.w != b.w} } -notEqual_double4 :: proc "c" (a, b: double4) -> bool4 { return {a.x != b.x, a.y != b.y, a.z != b.z, a.w != b.w} } -notEqual_int4 :: proc "c" (a, b: int4) -> bool4 { return {a.x != b.x, a.y != b.y, a.z != b.z, a.w != b.w} } -notEqual_uint4 :: proc "c" (a, b: uint4) -> bool4 { return {a.x != b.x, a.y != b.y, a.z != b.z, a.w != b.w} } +@(require_results) notEqual_float :: proc "c" (a, b: float) -> bool { return a != b } +@(require_results) notEqual_double :: proc "c" (a, b: double) -> bool { return a != b } +@(require_results) notEqual_int :: proc "c" (a, b: int) -> bool { return a != b } +@(require_results) notEqual_uint :: proc "c" (a, b: uint) -> bool { return a != b } +@(require_results) notEqual_float2 :: proc "c" (a, b: float2) -> bool2 { return {a.x != b.x, a.y != b.y} } +@(require_results) notEqual_double2 :: proc "c" (a, b: double2) -> bool2 { return {a.x != b.x, a.y != b.y} } +@(require_results) notEqual_int2 :: proc "c" (a, b: int2) -> bool2 { return {a.x != b.x, a.y != b.y} } +@(require_results) notEqual_uint2 :: proc "c" (a, b: uint2) -> bool2 { return {a.x != b.x, a.y != b.y} } +@(require_results) notEqual_float3 :: proc "c" (a, b: float3) -> bool3 { return {a.x != b.x, a.y != b.y, a.z != b.z} } +@(require_results) notEqual_double3 :: proc "c" (a, b: double3) -> bool3 { return {a.x != b.x, a.y != b.y, a.z != b.z} } +@(require_results) notEqual_int3 :: proc "c" (a, b: int3) -> bool3 { return {a.x != b.x, a.y != b.y, a.z != b.z} } +@(require_results) notEqual_uint3 :: proc "c" (a, b: uint3) -> bool3 { return {a.x != b.x, a.y != b.y, a.z != b.z} } +@(require_results) notEqual_float4 :: proc "c" (a, b: float4) -> bool4 { return {a.x != b.x, a.y != b.y, a.z != b.z, a.w != b.w} } +@(require_results) notEqual_double4 :: proc "c" (a, b: double4) -> bool4 { return {a.x != b.x, a.y != b.y, a.z != b.z, a.w != b.w} } +@(require_results) notEqual_int4 :: proc "c" (a, b: int4) -> bool4 { return {a.x != b.x, a.y != b.y, a.z != b.z, a.w != b.w} } +@(require_results) notEqual_uint4 :: proc "c" (a, b: uint4) -> bool4 { return {a.x != b.x, a.y != b.y, a.z != b.z, a.w != b.w} } any :: proc{ @@ -1433,10 +1441,10 @@ any :: proc{ any_bool3, any_bool4, } -any_bool :: proc "c" (v: bool) -> bool { return v } -any_bool2 :: proc "c" (v: bool2) -> bool { return v.x || v.y } -any_bool3 :: proc "c" (v: bool3) -> bool { return v.x || v.y || v.z } -any_bool4 :: proc "c" (v: bool4) -> bool { return v.x || v.y || v.z || v.w } +@(require_results) any_bool :: proc "c" (v: bool) -> bool { return v } +@(require_results) any_bool2 :: proc "c" (v: bool2) -> bool { return v.x || v.y } +@(require_results) any_bool3 :: proc "c" (v: bool3) -> bool { return v.x || v.y || v.z } +@(require_results) any_bool4 :: proc "c" (v: bool4) -> bool { return v.x || v.y || v.z || v.w } all :: proc{ all_bool, @@ -1444,10 +1452,10 @@ all :: proc{ all_bool3, all_bool4, } -all_bool :: proc "c" (v: bool) -> bool { return v } -all_bool2 :: proc "c" (v: bool2) -> bool { return v.x && v.y } -all_bool3 :: proc "c" (v: bool3) -> bool { return v.x && v.y && v.z } -all_bool4 :: proc "c" (v: bool4) -> bool { return v.x && v.y && v.z && v.w } +@(require_results) all_bool :: proc "c" (v: bool) -> bool { return v } +@(require_results) all_bool2 :: proc "c" (v: bool2) -> bool { return v.x && v.y } +@(require_results) all_bool3 :: proc "c" (v: bool3) -> bool { return v.x && v.y && v.z } +@(require_results) all_bool4 :: proc "c" (v: bool4) -> bool { return v.x && v.y && v.z && v.w } not :: proc{ not_bool, @@ -1455,22 +1463,22 @@ not :: proc{ not_bool3, not_bool4, } -not_bool :: proc "c" (v: bool) -> bool { return !v } -not_bool2 :: proc "c" (v: bool2) -> bool2 { return {!v.x, !v.y} } -not_bool3 :: proc "c" (v: bool3) -> bool3 { return {!v.x, !v.y, !v.z} } -not_bool4 :: proc "c" (v: bool4) -> bool4 { return {!v.x, !v.y, !v.z, !v.w} } +@(require_results) not_bool :: proc "c" (v: bool) -> bool { return !v } +@(require_results) not_bool2 :: proc "c" (v: bool2) -> bool2 { return {!v.x, !v.y} } +@(require_results) not_bool3 :: proc "c" (v: bool3) -> bool3 { return {!v.x, !v.y, !v.z} } +@(require_results) not_bool4 :: proc "c" (v: bool4) -> bool4 { return {!v.x, !v.y, !v.z, !v.w} } -inverse_float1x1 :: proc "c" (m: float1x1) -> float1x1 { return builtin.inverse(m) } -inverse_float2x2 :: proc "c" (m: float2x2) -> float2x2 { return builtin.inverse(m) } -inverse_float3x3 :: proc "c" (m: float3x3) -> float3x3 { return builtin.inverse(m) } -inverse_float4x4 :: proc "c" (m: float4x4) -> float4x4 { return builtin.inverse(m) } -inverse_double1x1 :: proc "c" (m: double1x1) -> double1x1 { return builtin.inverse(m) } -inverse_double2x2 :: proc "c" (m: double2x2) -> double2x2 { return builtin.inverse(m) } -inverse_double3x3 :: proc "c" (m: double3x3) -> double3x3 { return builtin.inverse(m) } -inverse_double4x4 :: proc "c" (m: double4x4) -> double4x4 { return builtin.inverse(m) } +@(require_results) inverse_float1x1 :: proc "c" (m: float1x1) -> float1x1 { return builtin.inverse(m) } +@(require_results) inverse_float2x2 :: proc "c" (m: float2x2) -> float2x2 { return builtin.inverse(m) } +@(require_results) inverse_float3x3 :: proc "c" (m: float3x3) -> float3x3 { return builtin.inverse(m) } +@(require_results) inverse_float4x4 :: proc "c" (m: float4x4) -> float4x4 { return builtin.inverse(m) } +@(require_results) inverse_double1x1 :: proc "c" (m: double1x1) -> double1x1 { return builtin.inverse(m) } +@(require_results) inverse_double2x2 :: proc "c" (m: double2x2) -> double2x2 { return builtin.inverse(m) } +@(require_results) inverse_double3x3 :: proc "c" (m: double3x3) -> double3x3 { return builtin.inverse(m) } +@(require_results) inverse_double4x4 :: proc "c" (m: double4x4) -> double4x4 { return builtin.inverse(m) } inverse :: proc{ inverse_float1x1, @@ -1544,57 +1552,57 @@ asfloat :: proc{ asfloat_double3, asfloat_double4, } -asfloat_float :: proc "c" (v: float) -> float { return float(v) } -asfloat_double :: proc "c" (v: double) -> float { return float(v) } -asfloat_int :: proc "c" (v: int) -> float { return float(v) } -asfloat_uint :: proc "c" (v: uint) -> float { return float(v) } -asfloat_float1x1 :: proc "c" (v: float1x1) -> float1x1 { return float1x1(v) } -asfloat_float2x2 :: proc "c" (v: float2x2) -> float2x2 { return float2x2(v) } -asfloat_float3x3 :: proc "c" (v: float3x3) -> float3x3 { return float3x3(v) } -asfloat_float4x4 :: proc "c" (v: float4x4) -> float4x4 { return float4x4(v) } -asfloat_float1x2 :: proc "c" (v: float1x2) -> float1x2 { return float1x2(v) } -asfloat_float1x3 :: proc "c" (v: float1x3) -> float1x3 { return float1x3(v) } -asfloat_float1x4 :: proc "c" (v: float1x4) -> float1x4 { return float1x4(v) } -asfloat_float2x1 :: proc "c" (v: float2x1) -> float2x1 { return float2x1(v) } -asfloat_float2x3 :: proc "c" (v: float2x3) -> float2x3 { return float2x3(v) } -asfloat_float2x4 :: proc "c" (v: float2x4) -> float2x4 { return float2x4(v) } -asfloat_float3x1 :: proc "c" (v: float3x1) -> float3x1 { return float3x1(v) } -asfloat_float3x2 :: proc "c" (v: float3x2) -> float3x2 { return float3x2(v) } -asfloat_float3x4 :: proc "c" (v: float3x4) -> float3x4 { return float3x4(v) } -asfloat_float4x1 :: proc "c" (v: float4x1) -> float4x1 { return float4x1(v) } -asfloat_float4x2 :: proc "c" (v: float4x2) -> float4x2 { return float4x2(v) } -asfloat_float4x3 :: proc "c" (v: float4x3) -> float4x3 { return float4x3(v) } -asfloat_float2 :: proc "c" (v: float2) -> float2 { return float2(v) } -asfloat_float3 :: proc "c" (v: float3) -> float3 { return float3(v) } -asfloat_float4 :: proc "c" (v: float4) -> float4 { return float4(v) } -asfloat_int2 :: proc "c" (v: int2) -> float2 { return float2{float(v.x), float(v.y)} } -asfloat_int3 :: proc "c" (v: int3) -> float3 { return float3{float(v.x), float(v.y), float(v.z)} } -asfloat_int4 :: proc "c" (v: int4) -> float4 { return float4{float(v.x), float(v.y), float(v.z), float(v.w)} } -asfloat_uint2 :: proc "c" (v: uint2) -> float2 { return float2{float(v.x), float(v.y)} } -asfloat_uint3 :: proc "c" (v: uint3) -> float3 { return float3{float(v.x), float(v.y), float(v.z)} } -asfloat_uint4 :: proc "c" (v: uint4) -> float4 { return float4{float(v.x), float(v.y), float(v.z), float(v.w)} } -asfloat_bool2 :: proc "c" (v: bool2) -> float2 { return float2{float(int(v.x)), float(int(v.y))} } -asfloat_bool3 :: proc "c" (v: bool3) -> float3 { return float3{float(int(v.x)), float(int(v.y)), float(int(v.z))} } -asfloat_bool4 :: proc "c" (v: bool4) -> float4 { return float4{float(int(v.x)), float(int(v.y)), float(int(v.z)), float(int(v.w))} } -asfloat_double1x1 :: proc "c" (v: double1x1) -> float1x1 { return float1x1(v) } -asfloat_double2x2 :: proc "c" (v: double2x2) -> float2x2 { return float2x2(v) } -asfloat_double3x3 :: proc "c" (v: double3x3) -> float3x3 { return float3x3(v) } -asfloat_double4x4 :: proc "c" (v: double4x4) -> float4x4 { return float4x4(v) } -asfloat_double1x2 :: proc "c" (v: double1x2) -> float1x2 { return float1x2(v) } -asfloat_double1x3 :: proc "c" (v: double1x3) -> float1x3 { return float1x3(v) } -asfloat_double1x4 :: proc "c" (v: double1x4) -> float1x4 { return float1x4(v) } -asfloat_double2x1 :: proc "c" (v: double2x1) -> float2x1 { return float2x1(v) } -asfloat_double2x3 :: proc "c" (v: double2x3) -> float2x3 { return float2x3(v) } -asfloat_double2x4 :: proc "c" (v: double2x4) -> float2x4 { return float2x4(v) } -asfloat_double3x1 :: proc "c" (v: double3x1) -> float3x1 { return float3x1(v) } -asfloat_double3x2 :: proc "c" (v: double3x2) -> float3x2 { return float3x2(v) } -asfloat_double3x4 :: proc "c" (v: double3x4) -> float3x4 { return float3x4(v) } -asfloat_double4x1 :: proc "c" (v: double4x1) -> float4x1 { return float4x1(v) } -asfloat_double4x2 :: proc "c" (v: double4x2) -> float4x2 { return float4x2(v) } -asfloat_double4x3 :: proc "c" (v: double4x3) -> float4x3 { return float4x3(v) } -asfloat_double2 :: proc "c" (v: double2) -> float2 { return float2{float(v.x), float(v.y)} } -asfloat_double3 :: proc "c" (v: double3) -> float3 { return float3{float(v.x), float(v.y), float(v.z)} } -asfloat_double4 :: proc "c" (v: double4) -> float4 { return float4{float(v.x), float(v.y), float(v.z), float(v.w)} } +@(require_results) asfloat_float :: proc "c" (v: float) -> float { return float(v) } +@(require_results) asfloat_double :: proc "c" (v: double) -> float { return float(v) } +@(require_results) asfloat_int :: proc "c" (v: int) -> float { return float(v) } +@(require_results) asfloat_uint :: proc "c" (v: uint) -> float { return float(v) } +@(require_results) asfloat_float1x1 :: proc "c" (v: float1x1) -> float1x1 { return float1x1(v) } +@(require_results) asfloat_float2x2 :: proc "c" (v: float2x2) -> float2x2 { return float2x2(v) } +@(require_results) asfloat_float3x3 :: proc "c" (v: float3x3) -> float3x3 { return float3x3(v) } +@(require_results) asfloat_float4x4 :: proc "c" (v: float4x4) -> float4x4 { return float4x4(v) } +@(require_results) asfloat_float1x2 :: proc "c" (v: float1x2) -> float1x2 { return float1x2(v) } +@(require_results) asfloat_float1x3 :: proc "c" (v: float1x3) -> float1x3 { return float1x3(v) } +@(require_results) asfloat_float1x4 :: proc "c" (v: float1x4) -> float1x4 { return float1x4(v) } +@(require_results) asfloat_float2x1 :: proc "c" (v: float2x1) -> float2x1 { return float2x1(v) } +@(require_results) asfloat_float2x3 :: proc "c" (v: float2x3) -> float2x3 { return float2x3(v) } +@(require_results) asfloat_float2x4 :: proc "c" (v: float2x4) -> float2x4 { return float2x4(v) } +@(require_results) asfloat_float3x1 :: proc "c" (v: float3x1) -> float3x1 { return float3x1(v) } +@(require_results) asfloat_float3x2 :: proc "c" (v: float3x2) -> float3x2 { return float3x2(v) } +@(require_results) asfloat_float3x4 :: proc "c" (v: float3x4) -> float3x4 { return float3x4(v) } +@(require_results) asfloat_float4x1 :: proc "c" (v: float4x1) -> float4x1 { return float4x1(v) } +@(require_results) asfloat_float4x2 :: proc "c" (v: float4x2) -> float4x2 { return float4x2(v) } +@(require_results) asfloat_float4x3 :: proc "c" (v: float4x3) -> float4x3 { return float4x3(v) } +@(require_results) asfloat_float2 :: proc "c" (v: float2) -> float2 { return float2(v) } +@(require_results) asfloat_float3 :: proc "c" (v: float3) -> float3 { return float3(v) } +@(require_results) asfloat_float4 :: proc "c" (v: float4) -> float4 { return float4(v) } +@(require_results) asfloat_int2 :: proc "c" (v: int2) -> float2 { return float2{float(v.x), float(v.y)} } +@(require_results) asfloat_int3 :: proc "c" (v: int3) -> float3 { return float3{float(v.x), float(v.y), float(v.z)} } +@(require_results) asfloat_int4 :: proc "c" (v: int4) -> float4 { return float4{float(v.x), float(v.y), float(v.z), float(v.w)} } +@(require_results) asfloat_uint2 :: proc "c" (v: uint2) -> float2 { return float2{float(v.x), float(v.y)} } +@(require_results) asfloat_uint3 :: proc "c" (v: uint3) -> float3 { return float3{float(v.x), float(v.y), float(v.z)} } +@(require_results) asfloat_uint4 :: proc "c" (v: uint4) -> float4 { return float4{float(v.x), float(v.y), float(v.z), float(v.w)} } +@(require_results) asfloat_bool2 :: proc "c" (v: bool2) -> float2 { return float2{float(int(v.x)), float(int(v.y))} } +@(require_results) asfloat_bool3 :: proc "c" (v: bool3) -> float3 { return float3{float(int(v.x)), float(int(v.y)), float(int(v.z))} } +@(require_results) asfloat_bool4 :: proc "c" (v: bool4) -> float4 { return float4{float(int(v.x)), float(int(v.y)), float(int(v.z)), float(int(v.w))} } +@(require_results) asfloat_double1x1 :: proc "c" (v: double1x1) -> float1x1 { return float1x1(v) } +@(require_results) asfloat_double2x2 :: proc "c" (v: double2x2) -> float2x2 { return float2x2(v) } +@(require_results) asfloat_double3x3 :: proc "c" (v: double3x3) -> float3x3 { return float3x3(v) } +@(require_results) asfloat_double4x4 :: proc "c" (v: double4x4) -> float4x4 { return float4x4(v) } +@(require_results) asfloat_double1x2 :: proc "c" (v: double1x2) -> float1x2 { return float1x2(v) } +@(require_results) asfloat_double1x3 :: proc "c" (v: double1x3) -> float1x3 { return float1x3(v) } +@(require_results) asfloat_double1x4 :: proc "c" (v: double1x4) -> float1x4 { return float1x4(v) } +@(require_results) asfloat_double2x1 :: proc "c" (v: double2x1) -> float2x1 { return float2x1(v) } +@(require_results) asfloat_double2x3 :: proc "c" (v: double2x3) -> float2x3 { return float2x3(v) } +@(require_results) asfloat_double2x4 :: proc "c" (v: double2x4) -> float2x4 { return float2x4(v) } +@(require_results) asfloat_double3x1 :: proc "c" (v: double3x1) -> float3x1 { return float3x1(v) } +@(require_results) asfloat_double3x2 :: proc "c" (v: double3x2) -> float3x2 { return float3x2(v) } +@(require_results) asfloat_double3x4 :: proc "c" (v: double3x4) -> float3x4 { return float3x4(v) } +@(require_results) asfloat_double4x1 :: proc "c" (v: double4x1) -> float4x1 { return float4x1(v) } +@(require_results) asfloat_double4x2 :: proc "c" (v: double4x2) -> float4x2 { return float4x2(v) } +@(require_results) asfloat_double4x3 :: proc "c" (v: double4x3) -> float4x3 { return float4x3(v) } +@(require_results) asfloat_double2 :: proc "c" (v: double2) -> float2 { return float2{float(v.x), float(v.y)} } +@(require_results) asfloat_double3 :: proc "c" (v: double3) -> float3 { return float3{float(v.x), float(v.y), float(v.z)} } +@(require_results) asfloat_double4 :: proc "c" (v: double4) -> float4 { return float4{float(v.x), float(v.y), float(v.z), float(v.w)} } asdouble :: proc{ asdouble_float, @@ -1649,57 +1657,57 @@ asdouble :: proc{ asdouble_double3, asdouble_double4, } -asdouble_float :: proc "c" (v: float) -> double { return double(v) } -asdouble_double :: proc "c" (v: double) -> double { return double(v) } -asdouble_int :: proc "c" (v: int) -> double { return double(v) } -asdouble_uint :: proc "c" (v: uint) -> double { return double(v) } -asdouble_float1x1 :: proc "c" (v: float1x1) -> double1x1 { return double1x1(v) } -asdouble_float2x2 :: proc "c" (v: float2x2) -> double2x2 { return double2x2(v) } -asdouble_float3x3 :: proc "c" (v: float3x3) -> double3x3 { return double3x3(v) } -asdouble_float4x4 :: proc "c" (v: float4x4) -> double4x4 { return double4x4(v) } -asdouble_float1x2 :: proc "c" (v: float1x2) -> double1x2 { return double1x2(v) } -asdouble_float1x3 :: proc "c" (v: float1x3) -> double1x3 { return double1x3(v) } -asdouble_float1x4 :: proc "c" (v: float1x4) -> double1x4 { return double1x4(v) } -asdouble_float2x1 :: proc "c" (v: float2x1) -> double2x1 { return double2x1(v) } -asdouble_float2x3 :: proc "c" (v: float2x3) -> double2x3 { return double2x3(v) } -asdouble_float2x4 :: proc "c" (v: float2x4) -> double2x4 { return double2x4(v) } -asdouble_float3x1 :: proc "c" (v: float3x1) -> double3x1 { return double3x1(v) } -asdouble_float3x2 :: proc "c" (v: float3x2) -> double3x2 { return double3x2(v) } -asdouble_float3x4 :: proc "c" (v: float3x4) -> double3x4 { return double3x4(v) } -asdouble_float4x1 :: proc "c" (v: float4x1) -> double4x1 { return double4x1(v) } -asdouble_float4x2 :: proc "c" (v: float4x2) -> double4x2 { return double4x2(v) } -asdouble_float4x3 :: proc "c" (v: float4x3) -> double4x3 { return double4x3(v) } -asdouble_float2 :: proc "c" (v: float2) -> double2 { return double2{double(v.x), double(v.y)} } -asdouble_float3 :: proc "c" (v: float3) -> double3 { return double3{double(v.x), double(v.y), double(v.z)} } -asdouble_float4 :: proc "c" (v: float4) -> double4 { return double4{double(v.x), double(v.y), double(v.z), double(v.w)} } -asdouble_int2 :: proc "c" (v: int2) -> double2 { return double2{double(v.x), double(v.y)} } -asdouble_int3 :: proc "c" (v: int3) -> double3 { return double3{double(v.x), double(v.y), double(v.z)} } -asdouble_int4 :: proc "c" (v: int4) -> double4 { return double4{double(v.x), double(v.y), double(v.z), double(v.w)} } -asdouble_uint2 :: proc "c" (v: uint2) -> double2 { return double2{double(v.x), double(v.y)} } -asdouble_uint3 :: proc "c" (v: uint3) -> double3 { return double3{double(v.x), double(v.y), double(v.z)} } -asdouble_uint4 :: proc "c" (v: uint4) -> double4 { return double4{double(v.x), double(v.y), double(v.z), double(v.w)} } -asdouble_bool2 :: proc "c" (v: bool2) -> double2 { return double2{double(int(v.x)), double(int(v.y))} } -asdouble_bool3 :: proc "c" (v: bool3) -> double3 { return double3{double(int(v.x)), double(int(v.y)), double(int(v.z))} } -asdouble_bool4 :: proc "c" (v: bool4) -> double4 { return double4{double(int(v.x)), double(int(v.y)), double(int(v.z)), double(int(v.w))} } -asdouble_double1x1 :: proc "c" (v: double1x1) -> double1x1 { return double1x1(v) } -asdouble_double2x2 :: proc "c" (v: double2x2) -> double2x2 { return double2x2(v) } -asdouble_double3x3 :: proc "c" (v: double3x3) -> double3x3 { return double3x3(v) } -asdouble_double4x4 :: proc "c" (v: double4x4) -> double4x4 { return double4x4(v) } -asdouble_double1x2 :: proc "c" (v: double1x2) -> double1x2 { return double1x2(v) } -asdouble_double1x3 :: proc "c" (v: double1x3) -> double1x3 { return double1x3(v) } -asdouble_double1x4 :: proc "c" (v: double1x4) -> double1x4 { return double1x4(v) } -asdouble_double2x1 :: proc "c" (v: double2x1) -> double2x1 { return double2x1(v) } -asdouble_double2x3 :: proc "c" (v: double2x3) -> double2x3 { return double2x3(v) } -asdouble_double2x4 :: proc "c" (v: double2x4) -> double2x4 { return double2x4(v) } -asdouble_double3x1 :: proc "c" (v: double3x1) -> double3x1 { return double3x1(v) } -asdouble_double3x2 :: proc "c" (v: double3x2) -> double3x2 { return double3x2(v) } -asdouble_double3x4 :: proc "c" (v: double3x4) -> double3x4 { return double3x4(v) } -asdouble_double4x1 :: proc "c" (v: double4x1) -> double4x1 { return double4x1(v) } -asdouble_double4x2 :: proc "c" (v: double4x2) -> double4x2 { return double4x2(v) } -asdouble_double4x3 :: proc "c" (v: double4x3) -> double4x3 { return double4x3(v) } -asdouble_double2 :: proc "c" (v: double2) -> double2 { return double2{double(v.x), double(v.y)} } -asdouble_double3 :: proc "c" (v: double3) -> double3 { return double3{double(v.x), double(v.y), double(v.z)} } -asdouble_double4 :: proc "c" (v: double4) -> double4 { return double4{double(v.x), double(v.y), double(v.z), double(v.w)} } +@(require_results) asdouble_float :: proc "c" (v: float) -> double { return double(v) } +@(require_results) asdouble_double :: proc "c" (v: double) -> double { return double(v) } +@(require_results) asdouble_int :: proc "c" (v: int) -> double { return double(v) } +@(require_results) asdouble_uint :: proc "c" (v: uint) -> double { return double(v) } +@(require_results) asdouble_float1x1 :: proc "c" (v: float1x1) -> double1x1 { return double1x1(v) } +@(require_results) asdouble_float2x2 :: proc "c" (v: float2x2) -> double2x2 { return double2x2(v) } +@(require_results) asdouble_float3x3 :: proc "c" (v: float3x3) -> double3x3 { return double3x3(v) } +@(require_results) asdouble_float4x4 :: proc "c" (v: float4x4) -> double4x4 { return double4x4(v) } +@(require_results) asdouble_float1x2 :: proc "c" (v: float1x2) -> double1x2 { return double1x2(v) } +@(require_results) asdouble_float1x3 :: proc "c" (v: float1x3) -> double1x3 { return double1x3(v) } +@(require_results) asdouble_float1x4 :: proc "c" (v: float1x4) -> double1x4 { return double1x4(v) } +@(require_results) asdouble_float2x1 :: proc "c" (v: float2x1) -> double2x1 { return double2x1(v) } +@(require_results) asdouble_float2x3 :: proc "c" (v: float2x3) -> double2x3 { return double2x3(v) } +@(require_results) asdouble_float2x4 :: proc "c" (v: float2x4) -> double2x4 { return double2x4(v) } +@(require_results) asdouble_float3x1 :: proc "c" (v: float3x1) -> double3x1 { return double3x1(v) } +@(require_results) asdouble_float3x2 :: proc "c" (v: float3x2) -> double3x2 { return double3x2(v) } +@(require_results) asdouble_float3x4 :: proc "c" (v: float3x4) -> double3x4 { return double3x4(v) } +@(require_results) asdouble_float4x1 :: proc "c" (v: float4x1) -> double4x1 { return double4x1(v) } +@(require_results) asdouble_float4x2 :: proc "c" (v: float4x2) -> double4x2 { return double4x2(v) } +@(require_results) asdouble_float4x3 :: proc "c" (v: float4x3) -> double4x3 { return double4x3(v) } +@(require_results) asdouble_float2 :: proc "c" (v: float2) -> double2 { return double2{double(v.x), double(v.y)} } +@(require_results) asdouble_float3 :: proc "c" (v: float3) -> double3 { return double3{double(v.x), double(v.y), double(v.z)} } +@(require_results) asdouble_float4 :: proc "c" (v: float4) -> double4 { return double4{double(v.x), double(v.y), double(v.z), double(v.w)} } +@(require_results) asdouble_int2 :: proc "c" (v: int2) -> double2 { return double2{double(v.x), double(v.y)} } +@(require_results) asdouble_int3 :: proc "c" (v: int3) -> double3 { return double3{double(v.x), double(v.y), double(v.z)} } +@(require_results) asdouble_int4 :: proc "c" (v: int4) -> double4 { return double4{double(v.x), double(v.y), double(v.z), double(v.w)} } +@(require_results) asdouble_uint2 :: proc "c" (v: uint2) -> double2 { return double2{double(v.x), double(v.y)} } +@(require_results) asdouble_uint3 :: proc "c" (v: uint3) -> double3 { return double3{double(v.x), double(v.y), double(v.z)} } +@(require_results) asdouble_uint4 :: proc "c" (v: uint4) -> double4 { return double4{double(v.x), double(v.y), double(v.z), double(v.w)} } +@(require_results) asdouble_bool2 :: proc "c" (v: bool2) -> double2 { return double2{double(int(v.x)), double(int(v.y))} } +@(require_results) asdouble_bool3 :: proc "c" (v: bool3) -> double3 { return double3{double(int(v.x)), double(int(v.y)), double(int(v.z))} } +@(require_results) asdouble_bool4 :: proc "c" (v: bool4) -> double4 { return double4{double(int(v.x)), double(int(v.y)), double(int(v.z)), double(int(v.w))} } +@(require_results) asdouble_double1x1 :: proc "c" (v: double1x1) -> double1x1 { return double1x1(v) } +@(require_results) asdouble_double2x2 :: proc "c" (v: double2x2) -> double2x2 { return double2x2(v) } +@(require_results) asdouble_double3x3 :: proc "c" (v: double3x3) -> double3x3 { return double3x3(v) } +@(require_results) asdouble_double4x4 :: proc "c" (v: double4x4) -> double4x4 { return double4x4(v) } +@(require_results) asdouble_double1x2 :: proc "c" (v: double1x2) -> double1x2 { return double1x2(v) } +@(require_results) asdouble_double1x3 :: proc "c" (v: double1x3) -> double1x3 { return double1x3(v) } +@(require_results) asdouble_double1x4 :: proc "c" (v: double1x4) -> double1x4 { return double1x4(v) } +@(require_results) asdouble_double2x1 :: proc "c" (v: double2x1) -> double2x1 { return double2x1(v) } +@(require_results) asdouble_double2x3 :: proc "c" (v: double2x3) -> double2x3 { return double2x3(v) } +@(require_results) asdouble_double2x4 :: proc "c" (v: double2x4) -> double2x4 { return double2x4(v) } +@(require_results) asdouble_double3x1 :: proc "c" (v: double3x1) -> double3x1 { return double3x1(v) } +@(require_results) asdouble_double3x2 :: proc "c" (v: double3x2) -> double3x2 { return double3x2(v) } +@(require_results) asdouble_double3x4 :: proc "c" (v: double3x4) -> double3x4 { return double3x4(v) } +@(require_results) asdouble_double4x1 :: proc "c" (v: double4x1) -> double4x1 { return double4x1(v) } +@(require_results) asdouble_double4x2 :: proc "c" (v: double4x2) -> double4x2 { return double4x2(v) } +@(require_results) asdouble_double4x3 :: proc "c" (v: double4x3) -> double4x3 { return double4x3(v) } +@(require_results) asdouble_double2 :: proc "c" (v: double2) -> double2 { return double2{double(v.x), double(v.y)} } +@(require_results) asdouble_double3 :: proc "c" (v: double3) -> double3 { return double3{double(v.x), double(v.y), double(v.z)} } +@(require_results) asdouble_double4 :: proc "c" (v: double4) -> double4 { return double4{double(v.x), double(v.y), double(v.z), double(v.w)} } asint :: proc{ asint_float, @@ -1754,57 +1762,57 @@ asint :: proc{ asint_double3, asint_double4, } -asint_float :: proc "c" (v: float) -> int { return int(v) } -asint_double :: proc "c" (v: double) -> int { return int(v) } -asint_int :: proc "c" (v: int) -> int { return int(v) } -asint_uint :: proc "c" (v: uint) -> int { return int(v) } -asint_float1x1 :: proc "c" (v: float1x1) -> int1x1 { return int1x1(v) } -asint_float2x2 :: proc "c" (v: float2x2) -> int2x2 { return int2x2(v) } -asint_float3x3 :: proc "c" (v: float3x3) -> int3x3 { return int3x3(v) } -asint_float4x4 :: proc "c" (v: float4x4) -> int4x4 { return int4x4(v) } -asint_float1x2 :: proc "c" (v: float1x2) -> int1x2 { return int1x2(v) } -asint_float1x3 :: proc "c" (v: float1x3) -> int1x3 { return int1x3(v) } -asint_float1x4 :: proc "c" (v: float1x4) -> int1x4 { return int1x4(v) } -asint_float2x1 :: proc "c" (v: float2x1) -> int2x1 { return int2x1(v) } -asint_float2x3 :: proc "c" (v: float2x3) -> int2x3 { return int2x3(v) } -asint_float2x4 :: proc "c" (v: float2x4) -> int2x4 { return int2x4(v) } -asint_float3x1 :: proc "c" (v: float3x1) -> int3x1 { return int3x1(v) } -asint_float3x2 :: proc "c" (v: float3x2) -> int3x2 { return int3x2(v) } -asint_float3x4 :: proc "c" (v: float3x4) -> int3x4 { return int3x4(v) } -asint_float4x1 :: proc "c" (v: float4x1) -> int4x1 { return int4x1(v) } -asint_float4x2 :: proc "c" (v: float4x2) -> int4x2 { return int4x2(v) } -asint_float4x3 :: proc "c" (v: float4x3) -> int4x3 { return int4x3(v) } -asint_float2 :: proc "c" (v: float2) -> int2 { return int2{int(v.x), int(v.y)} } -asint_float3 :: proc "c" (v: float3) -> int3 { return int3{int(v.x), int(v.y), int(v.z)} } -asint_float4 :: proc "c" (v: float4) -> int4 { return int4{int(v.x), int(v.y), int(v.z), int(v.w)} } -asint_int2 :: proc "c" (v: int2) -> int2 { return int2{int(v.x), int(v.y)} } -asint_int3 :: proc "c" (v: int3) -> int3 { return int3{int(v.x), int(v.y), int(v.z)} } -asint_int4 :: proc "c" (v: int4) -> int4 { return int4{int(v.x), int(v.y), int(v.z), int(v.w)} } -asint_uint2 :: proc "c" (v: uint2) -> int2 { return int2{int(v.x), int(v.y)} } -asint_uint3 :: proc "c" (v: uint3) -> int3 { return int3{int(v.x), int(v.y), int(v.z)} } -asint_uint4 :: proc "c" (v: uint4) -> int4 { return int4{int(v.x), int(v.y), int(v.z), int(v.w)} } -asint_bool2 :: proc "c" (v: bool2) -> int2 { return int2{int(int(v.x)), int(int(v.y))} } -asint_bool3 :: proc "c" (v: bool3) -> int3 { return int3{int(int(v.x)), int(int(v.y)), int(int(v.z))} } -asint_bool4 :: proc "c" (v: bool4) -> int4 { return int4{int(int(v.x)), int(int(v.y)), int(int(v.z)), int(int(v.w))} } -asint_double1x1 :: proc "c" (v: double1x1) -> int1x1 { return int1x1(v) } -asint_double2x2 :: proc "c" (v: double2x2) -> int2x2 { return int2x2(v) } -asint_double3x3 :: proc "c" (v: double3x3) -> int3x3 { return int3x3(v) } -asint_double4x4 :: proc "c" (v: double4x4) -> int4x4 { return int4x4(v) } -asint_double1x2 :: proc "c" (v: double1x2) -> int1x2 { return int1x2(v) } -asint_double1x3 :: proc "c" (v: double1x3) -> int1x3 { return int1x3(v) } -asint_double1x4 :: proc "c" (v: double1x4) -> int1x4 { return int1x4(v) } -asint_double2x1 :: proc "c" (v: double2x1) -> int2x1 { return int2x1(v) } -asint_double2x3 :: proc "c" (v: double2x3) -> int2x3 { return int2x3(v) } -asint_double2x4 :: proc "c" (v: double2x4) -> int2x4 { return int2x4(v) } -asint_double3x1 :: proc "c" (v: double3x1) -> int3x1 { return int3x1(v) } -asint_double3x2 :: proc "c" (v: double3x2) -> int3x2 { return int3x2(v) } -asint_double3x4 :: proc "c" (v: double3x4) -> int3x4 { return int3x4(v) } -asint_double4x1 :: proc "c" (v: double4x1) -> int4x1 { return int4x1(v) } -asint_double4x2 :: proc "c" (v: double4x2) -> int4x2 { return int4x2(v) } -asint_double4x3 :: proc "c" (v: double4x3) -> int4x3 { return int4x3(v) } -asint_double2 :: proc "c" (v: double2) -> int2 { return int2{int(v.x), int(v.y)} } -asint_double3 :: proc "c" (v: double3) -> int3 { return int3{int(v.x), int(v.y), int(v.z)} } -asint_double4 :: proc "c" (v: double4) -> int4 { return int4{int(v.x), int(v.y), int(v.z), int(v.w)} } +@(require_results) asint_float :: proc "c" (v: float) -> int { return int(v) } +@(require_results) asint_double :: proc "c" (v: double) -> int { return int(v) } +@(require_results) asint_int :: proc "c" (v: int) -> int { return int(v) } +@(require_results) asint_uint :: proc "c" (v: uint) -> int { return int(v) } +@(require_results) asint_float1x1 :: proc "c" (v: float1x1) -> int1x1 { return int1x1(v) } +@(require_results) asint_float2x2 :: proc "c" (v: float2x2) -> int2x2 { return int2x2(v) } +@(require_results) asint_float3x3 :: proc "c" (v: float3x3) -> int3x3 { return int3x3(v) } +@(require_results) asint_float4x4 :: proc "c" (v: float4x4) -> int4x4 { return int4x4(v) } +@(require_results) asint_float1x2 :: proc "c" (v: float1x2) -> int1x2 { return int1x2(v) } +@(require_results) asint_float1x3 :: proc "c" (v: float1x3) -> int1x3 { return int1x3(v) } +@(require_results) asint_float1x4 :: proc "c" (v: float1x4) -> int1x4 { return int1x4(v) } +@(require_results) asint_float2x1 :: proc "c" (v: float2x1) -> int2x1 { return int2x1(v) } +@(require_results) asint_float2x3 :: proc "c" (v: float2x3) -> int2x3 { return int2x3(v) } +@(require_results) asint_float2x4 :: proc "c" (v: float2x4) -> int2x4 { return int2x4(v) } +@(require_results) asint_float3x1 :: proc "c" (v: float3x1) -> int3x1 { return int3x1(v) } +@(require_results) asint_float3x2 :: proc "c" (v: float3x2) -> int3x2 { return int3x2(v) } +@(require_results) asint_float3x4 :: proc "c" (v: float3x4) -> int3x4 { return int3x4(v) } +@(require_results) asint_float4x1 :: proc "c" (v: float4x1) -> int4x1 { return int4x1(v) } +@(require_results) asint_float4x2 :: proc "c" (v: float4x2) -> int4x2 { return int4x2(v) } +@(require_results) asint_float4x3 :: proc "c" (v: float4x3) -> int4x3 { return int4x3(v) } +@(require_results) asint_float2 :: proc "c" (v: float2) -> int2 { return int2{int(v.x), int(v.y)} } +@(require_results) asint_float3 :: proc "c" (v: float3) -> int3 { return int3{int(v.x), int(v.y), int(v.z)} } +@(require_results) asint_float4 :: proc "c" (v: float4) -> int4 { return int4{int(v.x), int(v.y), int(v.z), int(v.w)} } +@(require_results) asint_int2 :: proc "c" (v: int2) -> int2 { return int2{int(v.x), int(v.y)} } +@(require_results) asint_int3 :: proc "c" (v: int3) -> int3 { return int3{int(v.x), int(v.y), int(v.z)} } +@(require_results) asint_int4 :: proc "c" (v: int4) -> int4 { return int4{int(v.x), int(v.y), int(v.z), int(v.w)} } +@(require_results) asint_uint2 :: proc "c" (v: uint2) -> int2 { return int2{int(v.x), int(v.y)} } +@(require_results) asint_uint3 :: proc "c" (v: uint3) -> int3 { return int3{int(v.x), int(v.y), int(v.z)} } +@(require_results) asint_uint4 :: proc "c" (v: uint4) -> int4 { return int4{int(v.x), int(v.y), int(v.z), int(v.w)} } +@(require_results) asint_bool2 :: proc "c" (v: bool2) -> int2 { return int2{int(int(v.x)), int(int(v.y))} } +@(require_results) asint_bool3 :: proc "c" (v: bool3) -> int3 { return int3{int(int(v.x)), int(int(v.y)), int(int(v.z))} } +@(require_results) asint_bool4 :: proc "c" (v: bool4) -> int4 { return int4{int(int(v.x)), int(int(v.y)), int(int(v.z)), int(int(v.w))} } +@(require_results) asint_double1x1 :: proc "c" (v: double1x1) -> int1x1 { return int1x1(v) } +@(require_results) asint_double2x2 :: proc "c" (v: double2x2) -> int2x2 { return int2x2(v) } +@(require_results) asint_double3x3 :: proc "c" (v: double3x3) -> int3x3 { return int3x3(v) } +@(require_results) asint_double4x4 :: proc "c" (v: double4x4) -> int4x4 { return int4x4(v) } +@(require_results) asint_double1x2 :: proc "c" (v: double1x2) -> int1x2 { return int1x2(v) } +@(require_results) asint_double1x3 :: proc "c" (v: double1x3) -> int1x3 { return int1x3(v) } +@(require_results) asint_double1x4 :: proc "c" (v: double1x4) -> int1x4 { return int1x4(v) } +@(require_results) asint_double2x1 :: proc "c" (v: double2x1) -> int2x1 { return int2x1(v) } +@(require_results) asint_double2x3 :: proc "c" (v: double2x3) -> int2x3 { return int2x3(v) } +@(require_results) asint_double2x4 :: proc "c" (v: double2x4) -> int2x4 { return int2x4(v) } +@(require_results) asint_double3x1 :: proc "c" (v: double3x1) -> int3x1 { return int3x1(v) } +@(require_results) asint_double3x2 :: proc "c" (v: double3x2) -> int3x2 { return int3x2(v) } +@(require_results) asint_double3x4 :: proc "c" (v: double3x4) -> int3x4 { return int3x4(v) } +@(require_results) asint_double4x1 :: proc "c" (v: double4x1) -> int4x1 { return int4x1(v) } +@(require_results) asint_double4x2 :: proc "c" (v: double4x2) -> int4x2 { return int4x2(v) } +@(require_results) asint_double4x3 :: proc "c" (v: double4x3) -> int4x3 { return int4x3(v) } +@(require_results) asint_double2 :: proc "c" (v: double2) -> int2 { return int2{int(v.x), int(v.y)} } +@(require_results) asint_double3 :: proc "c" (v: double3) -> int3 { return int3{int(v.x), int(v.y), int(v.z)} } +@(require_results) asint_double4 :: proc "c" (v: double4) -> int4 { return int4{int(v.x), int(v.y), int(v.z), int(v.w)} } asuint :: proc{ @@ -1828,25 +1836,25 @@ asuint :: proc{ asuint_double3, asuint_double4, } -asuint_float :: proc "c" (v: float) -> uint { return uint(v) } -asuint_double :: proc "c" (v: double) -> uint { return uint(v) } -asuint_int :: proc "c" (v: int) -> uint { return uint(v) } -asuint_uint :: proc "c" (v: uint) -> uint { return uint(v) } -asuint_float2 :: proc "c" (v: float2) -> uint2 { return uint2{uint(v.x), uint(v.y)} } -asuint_float3 :: proc "c" (v: float3) -> uint3 { return uint3{uint(v.x), uint(v.y), uint(v.z)} } -asuint_float4 :: proc "c" (v: float4) -> uint4 { return uint4{uint(v.x), uint(v.y), uint(v.z), uint(v.w)} } -asuint_int2 :: proc "c" (v: int2) -> uint2 { return uint2{uint(v.x), uint(v.y)} } -asuint_int3 :: proc "c" (v: int3) -> uint3 { return uint3{uint(v.x), uint(v.y), uint(v.z)} } -asuint_int4 :: proc "c" (v: int4) -> uint4 { return uint4{uint(v.x), uint(v.y), uint(v.z), uint(v.w)} } -asuint_uint2 :: proc "c" (v: uint2) -> uint2 { return uint2{uint(v.x), uint(v.y)} } -asuint_uint3 :: proc "c" (v: uint3) -> uint3 { return uint3{uint(v.x), uint(v.y), uint(v.z)} } -asuint_uint4 :: proc "c" (v: uint4) -> uint4 { return uint4{uint(v.x), uint(v.y), uint(v.z), uint(v.w)} } -asuint_bool2 :: proc "c" (v: bool2) -> uint2 { return uint2{uint(uint(v.x)), uint(uint(v.y))} } -asuint_bool3 :: proc "c" (v: bool3) -> uint3 { return uint3{uint(uint(v.x)), uint(uint(v.y)), uint(uint(v.z))} } -asuint_bool4 :: proc "c" (v: bool4) -> uint4 { return uint4{uint(uint(v.x)), uint(uint(v.y)), uint(uint(v.z)), uint(uint(v.w))} } -asuint_double2 :: proc "c" (v: double2) -> uint2 { return uint2{uint(v.x), uint(v.y)} } -asuint_double3 :: proc "c" (v: double3) -> uint3 { return uint3{uint(v.x), uint(v.y), uint(v.z)} } -asuint_double4 :: proc "c" (v: double4) -> uint4 { return uint4{uint(v.x), uint(v.y), uint(v.z), uint(v.w)} } +@(require_results) asuint_float :: proc "c" (v: float) -> uint { return uint(v) } +@(require_results) asuint_double :: proc "c" (v: double) -> uint { return uint(v) } +@(require_results) asuint_int :: proc "c" (v: int) -> uint { return uint(v) } +@(require_results) asuint_uint :: proc "c" (v: uint) -> uint { return uint(v) } +@(require_results) asuint_float2 :: proc "c" (v: float2) -> uint2 { return uint2{uint(v.x), uint(v.y)} } +@(require_results) asuint_float3 :: proc "c" (v: float3) -> uint3 { return uint3{uint(v.x), uint(v.y), uint(v.z)} } +@(require_results) asuint_float4 :: proc "c" (v: float4) -> uint4 { return uint4{uint(v.x), uint(v.y), uint(v.z), uint(v.w)} } +@(require_results) asuint_int2 :: proc "c" (v: int2) -> uint2 { return uint2{uint(v.x), uint(v.y)} } +@(require_results) asuint_int3 :: proc "c" (v: int3) -> uint3 { return uint3{uint(v.x), uint(v.y), uint(v.z)} } +@(require_results) asuint_int4 :: proc "c" (v: int4) -> uint4 { return uint4{uint(v.x), uint(v.y), uint(v.z), uint(v.w)} } +@(require_results) asuint_uint2 :: proc "c" (v: uint2) -> uint2 { return uint2{uint(v.x), uint(v.y)} } +@(require_results) asuint_uint3 :: proc "c" (v: uint3) -> uint3 { return uint3{uint(v.x), uint(v.y), uint(v.z)} } +@(require_results) asuint_uint4 :: proc "c" (v: uint4) -> uint4 { return uint4{uint(v.x), uint(v.y), uint(v.z), uint(v.w)} } +@(require_results) asuint_bool2 :: proc "c" (v: bool2) -> uint2 { return uint2{uint(uint(v.x)), uint(uint(v.y))} } +@(require_results) asuint_bool3 :: proc "c" (v: bool3) -> uint3 { return uint3{uint(uint(v.x)), uint(uint(v.y)), uint(uint(v.z))} } +@(require_results) asuint_bool4 :: proc "c" (v: bool4) -> uint4 { return uint4{uint(uint(v.x)), uint(uint(v.y)), uint(uint(v.z)), uint(uint(v.w))} } +@(require_results) asuint_double2 :: proc "c" (v: double2) -> uint2 { return uint2{uint(v.x), uint(v.y)} } +@(require_results) asuint_double3 :: proc "c" (v: double3) -> uint3 { return uint3{uint(v.x), uint(v.y), uint(v.z)} } +@(require_results) asuint_double4 :: proc "c" (v: double4) -> uint4 { return uint4{uint(v.x), uint(v.y), uint(v.z), uint(v.w)} } // TODO(bill): All of the `mul` procedures diff --git a/core/math/linalg/hlsl/linalg_hlsl_math.odin b/core/math/linalg/hlsl/linalg_hlsl_math.odin index 91c542b59..5b8004342 100644 --- a/core/math/linalg/hlsl/linalg_hlsl_math.odin +++ b/core/math/linalg/hlsl/linalg_hlsl_math.odin @@ -2,34 +2,35 @@ package math_linalg_hlsl import "core:math" -cos_float :: proc "c" (x: float) -> float { return math.cos(x) } -sin_float :: proc "c" (x: float) -> float { return math.sin(x) } -tan_float :: proc "c" (x: float) -> float { return math.tan(x) } -acos_float :: proc "c" (x: float) -> float { return math.acos(x) } -asin_float :: proc "c" (x: float) -> float { return math.asin(x) } -atan_float :: proc "c" (x: float) -> float { return math.atan(x) } -atan2_float :: proc "c" (y, x: float) -> float { return math.atan2(y, x) } -cosh_float :: proc "c" (x: float) -> float { return math.cosh(x) } -sinh_float :: proc "c" (x: float) -> float { return math.sinh(x) } -tanh_float :: proc "c" (x: float) -> float { return math.tanh(x) } -acosh_float :: proc "c" (x: float) -> float { return math.acosh(x) } -asinh_float :: proc "c" (x: float) -> float { return math.asinh(x) } -atanh_float :: proc "c" (x: float) -> float { return math.atanh(x) } -sqrt_float :: proc "c" (x: float) -> float { return math.sqrt(x) } -rsqrt_float :: proc "c" (x: float) -> float { return 1.0/math.sqrt(x) } -rcp_float :: proc "c" (x: float) -> float { return 1.0/x } -pow_float :: proc "c" (x, y: float) -> float { return math.pow(x, y) } -exp_float :: proc "c" (x: float) -> float { return math.exp(x) } -log_float :: proc "c" (x: float) -> float { return math.ln(x) } -log2_float :: proc "c" (x: float) -> float { return math.log(x, 2) } -log10_float :: proc "c" (x: float) -> float { return math.log(x, 10) } -exp2_float :: proc "c" (x: float) -> float { return math.pow(float(2), x) } -sign_float :: proc "c" (x: float) -> float { return math.sign(x) } -floor_float :: proc "c" (x: float) -> float { return math.floor(x) } -round_float :: proc "c" (x: float) -> float { return math.round(x) } -ceil_float :: proc "c" (x: float) -> float { return math.ceil(x) } -isnan_float :: proc "c" (x: float) -> bool { return math.classify(x) == .NaN} -fmod_float :: proc "c" (x, y: float) -> float { return math.mod(x, y) } +@(require_results) cos_float :: proc "c" (x: float) -> float { return math.cos(x) } +@(require_results) sin_float :: proc "c" (x: float) -> float { return math.sin(x) } +@(require_results) tan_float :: proc "c" (x: float) -> float { return math.tan(x) } +@(require_results) acos_float :: proc "c" (x: float) -> float { return math.acos(x) } +@(require_results) asin_float :: proc "c" (x: float) -> float { return math.asin(x) } +@(require_results) atan_float :: proc "c" (x: float) -> float { return math.atan(x) } +@(require_results) atan2_float :: proc "c" (y, x: float) -> float { return math.atan2(y, x) } +@(require_results) cosh_float :: proc "c" (x: float) -> float { return math.cosh(x) } +@(require_results) sinh_float :: proc "c" (x: float) -> float { return math.sinh(x) } +@(require_results) tanh_float :: proc "c" (x: float) -> float { return math.tanh(x) } +@(require_results) acosh_float :: proc "c" (x: float) -> float { return math.acosh(x) } +@(require_results) asinh_float :: proc "c" (x: float) -> float { return math.asinh(x) } +@(require_results) atanh_float :: proc "c" (x: float) -> float { return math.atanh(x) } +@(require_results) sqrt_float :: proc "c" (x: float) -> float { return math.sqrt(x) } +@(require_results) rsqrt_float :: proc "c" (x: float) -> float { return 1.0/math.sqrt(x) } +@(require_results) rcp_float :: proc "c" (x: float) -> float { return 1.0/x } +@(require_results) pow_float :: proc "c" (x, y: float) -> float { return math.pow(x, y) } +@(require_results) exp_float :: proc "c" (x: float) -> float { return math.exp(x) } +@(require_results) log_float :: proc "c" (x: float) -> float { return math.ln(x) } +@(require_results) log2_float :: proc "c" (x: float) -> float { return math.log(x, 2) } +@(require_results) log10_float :: proc "c" (x: float) -> float { return math.log(x, 10) } +@(require_results) exp2_float :: proc "c" (x: float) -> float { return math.pow(float(2), x) } +@(require_results) sign_float :: proc "c" (x: float) -> float { return math.sign(x) } +@(require_results) floor_float :: proc "c" (x: float) -> float { return math.floor(x) } +@(require_results) round_float :: proc "c" (x: float) -> float { return math.round(x) } +@(require_results) ceil_float :: proc "c" (x: float) -> float { return math.ceil(x) } +@(require_results) isnan_float :: proc "c" (x: float) -> bool { return math.classify(x) == .NaN} +@(require_results) fmod_float :: proc "c" (x, y: float) -> float { return math.mod(x, y) } +@(require_results) frac_float :: proc "c" (x: float) -> float { if x >= 0 { return x - math.trunc(x) @@ -38,34 +39,35 @@ frac_float :: proc "c" (x: float) -> float { } -cos_double :: proc "c" (x: double) -> double { return math.cos(x) } -sin_double :: proc "c" (x: double) -> double { return math.sin(x) } -tan_double :: proc "c" (x: double) -> double { return math.tan(x) } -acos_double :: proc "c" (x: double) -> double { return math.acos(x) } -asin_double :: proc "c" (x: double) -> double { return math.asin(x) } -atan_double :: proc "c" (x: double) -> double { return math.atan(x) } -atan2_double :: proc "c" (y, x: double) -> double { return math.atan2(y, x) } -cosh_double :: proc "c" (x: double) -> double { return math.cosh(x) } -sinh_double :: proc "c" (x: double) -> double { return math.sinh(x) } -tanh_double :: proc "c" (x: double) -> double { return math.tanh(x) } -acosh_double :: proc "c" (x: double) -> double { return math.acosh(x) } -asinh_double :: proc "c" (x: double) -> double { return math.asinh(x) } -atanh_double :: proc "c" (x: double) -> double { return math.atanh(x) } -sqrt_double :: proc "c" (x: double) -> double { return math.sqrt(x) } -rsqrt_double :: proc "c" (x: double) -> double { return 1.0/math.sqrt(x) } -rcp_double :: proc "c" (x: double) -> double { return 1.0/x } -pow_double :: proc "c" (x, y: double) -> double { return math.pow(x, y) } -exp_double :: proc "c" (x: double) -> double { return math.exp(x) } -log_double :: proc "c" (x: double) -> double { return math.ln(x) } -log2_double :: proc "c" (x: double) -> double { return math.log(x, 2) } -log10_double :: proc "c" (x: double) -> double { return math.log(x, 10) } -exp2_double :: proc "c" (x: double) -> double { return math.pow(double(2), x) } -sign_double :: proc "c" (x: double) -> double { return math.sign(x) } -floor_double :: proc "c" (x: double) -> double { return math.floor(x) } -round_double :: proc "c" (x: double) -> double { return math.round(x) } -ceil_double :: proc "c" (x: double) -> double { return math.ceil(x) } -isnan_double :: proc "c" (x: double) -> bool { return math.classify(x) == .NaN} -fmod_double :: proc "c" (x, y: double) -> double { return math.mod(x, y) } +@(require_results) cos_double :: proc "c" (x: double) -> double { return math.cos(x) } +@(require_results) sin_double :: proc "c" (x: double) -> double { return math.sin(x) } +@(require_results) tan_double :: proc "c" (x: double) -> double { return math.tan(x) } +@(require_results) acos_double :: proc "c" (x: double) -> double { return math.acos(x) } +@(require_results) asin_double :: proc "c" (x: double) -> double { return math.asin(x) } +@(require_results) atan_double :: proc "c" (x: double) -> double { return math.atan(x) } +@(require_results) atan2_double :: proc "c" (y, x: double) -> double { return math.atan2(y, x) } +@(require_results) cosh_double :: proc "c" (x: double) -> double { return math.cosh(x) } +@(require_results) sinh_double :: proc "c" (x: double) -> double { return math.sinh(x) } +@(require_results) tanh_double :: proc "c" (x: double) -> double { return math.tanh(x) } +@(require_results) acosh_double :: proc "c" (x: double) -> double { return math.acosh(x) } +@(require_results) asinh_double :: proc "c" (x: double) -> double { return math.asinh(x) } +@(require_results) atanh_double :: proc "c" (x: double) -> double { return math.atanh(x) } +@(require_results) sqrt_double :: proc "c" (x: double) -> double { return math.sqrt(x) } +@(require_results) rsqrt_double :: proc "c" (x: double) -> double { return 1.0/math.sqrt(x) } +@(require_results) rcp_double :: proc "c" (x: double) -> double { return 1.0/x } +@(require_results) pow_double :: proc "c" (x, y: double) -> double { return math.pow(x, y) } +@(require_results) exp_double :: proc "c" (x: double) -> double { return math.exp(x) } +@(require_results) log_double :: proc "c" (x: double) -> double { return math.ln(x) } +@(require_results) log2_double :: proc "c" (x: double) -> double { return math.log(x, 2) } +@(require_results) log10_double :: proc "c" (x: double) -> double { return math.log(x, 10) } +@(require_results) exp2_double :: proc "c" (x: double) -> double { return math.pow(double(2), x) } +@(require_results) sign_double :: proc "c" (x: double) -> double { return math.sign(x) } +@(require_results) floor_double :: proc "c" (x: double) -> double { return math.floor(x) } +@(require_results) round_double :: proc "c" (x: double) -> double { return math.round(x) } +@(require_results) ceil_double :: proc "c" (x: double) -> double { return math.ceil(x) } +@(require_results) isnan_double :: proc "c" (x: double) -> bool { return math.classify(x) == .NaN} +@(require_results) fmod_double :: proc "c" (x, y: double) -> double { return math.mod(x, y) } +@(require_results) frac_double :: proc "c" (x: double) -> double { if x >= 0 { return x - math.trunc(x) diff --git a/core/math/linalg/specific.odin b/core/math/linalg/specific.odin index c4ecb194f..6607b241f 100644 --- a/core/math/linalg/specific.odin +++ b/core/math/linalg/specific.odin @@ -130,11 +130,13 @@ VECTOR3F64_Y_AXIS :: Vector3f64{0, 1, 0} VECTOR3F64_Z_AXIS :: Vector3f64{0, 0, 1} -vector2_orthogonal :: proc(v: $V/[2]$E) -> V where !IS_ARRAY(E), IS_FLOAT(E) { +@(require_results) +vector2_orthogonal :: proc "contextless" (v: $V/[2]$E) -> V where !IS_ARRAY(E), IS_FLOAT(E) { return {-v.y, v.x} } -vector3_orthogonal :: proc(v: $V/[3]$E) -> V where !IS_ARRAY(E), IS_FLOAT(E) { +@(require_results) +vector3_orthogonal :: proc "contextless" (v: $V/[3]$E) -> V where !IS_ARRAY(E), IS_FLOAT(E) { x := abs(v.x) y := abs(v.y) z := abs(v.z) @@ -160,21 +162,24 @@ orthogonal :: proc{vector2_orthogonal, vector3_orthogonal} -vector4_srgb_to_linear_f16 :: proc(col: Vector4f16) -> Vector4f16 { +@(require_results) +vector4_srgb_to_linear_f16 :: proc "contextless" (col: Vector4f16) -> Vector4f16 { r := math.pow(col.x, 2.2) g := math.pow(col.y, 2.2) b := math.pow(col.z, 2.2) a := col.w return {r, g, b, a} } -vector4_srgb_to_linear_f32 :: proc(col: Vector4f32) -> Vector4f32 { +@(require_results) +vector4_srgb_to_linear_f32 :: proc "contextless" (col: Vector4f32) -> Vector4f32 { r := math.pow(col.x, 2.2) g := math.pow(col.y, 2.2) b := math.pow(col.z, 2.2) a := col.w return {r, g, b, a} } -vector4_srgb_to_linear_f64 :: proc(col: Vector4f64) -> Vector4f64 { +@(require_results) +vector4_srgb_to_linear_f64 :: proc "contextless" (col: Vector4f64) -> Vector4f64 { r := math.pow(col.x, 2.2) g := math.pow(col.y, 2.2) b := math.pow(col.z, 2.2) @@ -188,7 +193,8 @@ vector4_srgb_to_linear :: proc{ } -vector4_linear_to_srgb_f16 :: proc(col: Vector4f16) -> Vector4f16 { +@(require_results) +vector4_linear_to_srgb_f16 :: proc "contextless" (col: Vector4f16) -> Vector4f16 { a :: 2.51 b :: 0.03 c :: 2.43 @@ -209,7 +215,8 @@ vector4_linear_to_srgb_f16 :: proc(col: Vector4f16) -> Vector4f16 { return {x, y, z, col.w} } -vector4_linear_to_srgb_f32 :: proc(col: Vector4f32) -> Vector4f32 { +@(require_results) +vector4_linear_to_srgb_f32 :: proc "contextless" (col: Vector4f32) -> Vector4f32 { a :: 2.51 b :: 0.03 c :: 2.43 @@ -230,7 +237,8 @@ vector4_linear_to_srgb_f32 :: proc(col: Vector4f32) -> Vector4f32 { return {x, y, z, col.w} } -vector4_linear_to_srgb_f64 :: proc(col: Vector4f64) -> Vector4f64 { +@(require_results) +vector4_linear_to_srgb_f64 :: proc "contextless" (col: Vector4f64) -> Vector4f64 { a :: 2.51 b :: 0.03 c :: 2.43 @@ -258,8 +266,10 @@ vector4_linear_to_srgb :: proc{ } -vector4_hsl_to_rgb_f16 :: proc(h, s, l: f16, a: f16 = 1) -> Vector4f16 { - hue_to_rgb :: proc(p, q, t: f16) -> f16 { +@(require_results) +vector4_hsl_to_rgb_f16 :: proc "contextless" (h, s, l: f16, a: f16 = 1) -> Vector4f16 { + @(require_results) + hue_to_rgb :: proc "contextless" (p, q, t: f16) -> f16 { t := t if t < 0 { t += 1 } if t > 1 { t -= 1 } @@ -285,8 +295,10 @@ vector4_hsl_to_rgb_f16 :: proc(h, s, l: f16, a: f16 = 1) -> Vector4f16 { } return {r, g, b, a} } -vector4_hsl_to_rgb_f32 :: proc(h, s, l: f32, a: f32 = 1) -> Vector4f32 { - hue_to_rgb :: proc(p, q, t: f32) -> f32 { +@(require_results) +vector4_hsl_to_rgb_f32 :: proc "contextless" (h, s, l: f32, a: f32 = 1) -> Vector4f32 { + @(require_results) + hue_to_rgb :: proc "contextless" (p, q, t: f32) -> f32 { t := t if t < 0 { t += 1 } if t > 1 { t -= 1 } @@ -312,8 +324,10 @@ vector4_hsl_to_rgb_f32 :: proc(h, s, l: f32, a: f32 = 1) -> Vector4f32 { } return {r, g, b, a} } -vector4_hsl_to_rgb_f64 :: proc(h, s, l: f64, a: f64 = 1) -> Vector4f64 { - hue_to_rgb :: proc(p, q, t: f64) -> f64 { +@(require_results) +vector4_hsl_to_rgb_f64 :: proc "contextless" (h, s, l: f64, a: f64 = 1) -> Vector4f64 { + @(require_results) + hue_to_rgb :: proc "contextless" (p, q, t: f64) -> f64 { t := t if t < 0 { t += 1 } if t > 1 { t -= 1 } @@ -346,7 +360,8 @@ vector4_hsl_to_rgb :: proc{ } -vector4_rgb_to_hsl_f16 :: proc(col: Vector4f16) -> Vector4f16 { +@(require_results) +vector4_rgb_to_hsl_f16 :: proc "contextless" (col: Vector4f16) -> Vector4f16 { r := col.x g := col.y b := col.z @@ -375,7 +390,8 @@ vector4_rgb_to_hsl_f16 :: proc(col: Vector4f16) -> Vector4f16 { return {h, s, l, a} } -vector4_rgb_to_hsl_f32 :: proc(col: Vector4f32) -> Vector4f32 { +@(require_results) +vector4_rgb_to_hsl_f32 :: proc "contextless" (col: Vector4f32) -> Vector4f32 { r := col.x g := col.y b := col.z @@ -404,7 +420,8 @@ vector4_rgb_to_hsl_f32 :: proc(col: Vector4f32) -> Vector4f32 { return {h, s, l, a} } -vector4_rgb_to_hsl_f64 :: proc(col: Vector4f64) -> Vector4f64 { +@(require_results) +vector4_rgb_to_hsl_f64 :: proc "contextless" (col: Vector4f64) -> Vector4f64 { r := col.x g := col.y b := col.z @@ -441,7 +458,8 @@ vector4_rgb_to_hsl :: proc{ -quaternion_angle_axis_f16 :: proc(angle_radians: f16, axis: Vector3f16) -> (q: Quaternionf16) { +@(require_results) +quaternion_angle_axis_f16 :: proc "contextless" (angle_radians: f16, axis: Vector3f16) -> (q: Quaternionf16) { t := angle_radians*0.5 v := normalize(axis) * math.sin(t) q.x = v.x @@ -450,7 +468,8 @@ quaternion_angle_axis_f16 :: proc(angle_radians: f16, axis: Vector3f16) -> (q: Q q.w = math.cos(t) return } -quaternion_angle_axis_f32 :: proc(angle_radians: f32, axis: Vector3f32) -> (q: Quaternionf32) { +@(require_results) +quaternion_angle_axis_f32 :: proc "contextless" (angle_radians: f32, axis: Vector3f32) -> (q: Quaternionf32) { t := angle_radians*0.5 v := normalize(axis) * math.sin(t) q.x = v.x @@ -459,7 +478,8 @@ quaternion_angle_axis_f32 :: proc(angle_radians: f32, axis: Vector3f32) -> (q: Q q.w = math.cos(t) return } -quaternion_angle_axis_f64 :: proc(angle_radians: f64, axis: Vector3f64) -> (q: Quaternionf64) { +@(require_results) +quaternion_angle_axis_f64 :: proc "contextless" (angle_radians: f64, axis: Vector3f64) -> (q: Quaternionf64) { t := angle_radians*0.5 v := normalize(axis) * math.sin(t) q.x = v.x @@ -474,21 +494,24 @@ quaternion_angle_axis :: proc{ quaternion_angle_axis_f64, } -angle_from_quaternion_f16 :: proc(q: Quaternionf16) -> f16 { +@(require_results) +angle_from_quaternion_f16 :: proc "contextless" (q: Quaternionf16) -> f16 { if abs(q.w) > math.SQRT_THREE*0.5 { return math.asin(math.sqrt(q.x*q.x + q.y*q.y + q.z*q.z)) * 2 } return math.acos(q.w) * 2 } -angle_from_quaternion_f32 :: proc(q: Quaternionf32) -> f32 { +@(require_results) +angle_from_quaternion_f32 :: proc "contextless" (q: Quaternionf32) -> f32 { if abs(q.w) > math.SQRT_THREE*0.5 { return math.asin(math.sqrt(q.x*q.x + q.y*q.y + q.z*q.z)) * 2 } return math.acos(q.w) * 2 } -angle_from_quaternion_f64 :: proc(q: Quaternionf64) -> f64 { +@(require_results) +angle_from_quaternion_f64 :: proc "contextless" (q: Quaternionf64) -> f64 { if abs(q.w) > math.SQRT_THREE*0.5 { return math.asin(math.sqrt(q.x*q.x + q.y*q.y + q.z*q.z)) * 2 } @@ -501,7 +524,8 @@ angle_from_quaternion :: proc{ angle_from_quaternion_f64, } -axis_from_quaternion_f16 :: proc(q: Quaternionf16) -> Vector3f16 { +@(require_results) +axis_from_quaternion_f16 :: proc "contextless" (q: Quaternionf16) -> Vector3f16 { t1 := 1 - q.w*q.w if t1 < 0 { return {0, 0, 1} @@ -509,7 +533,8 @@ axis_from_quaternion_f16 :: proc(q: Quaternionf16) -> Vector3f16 { t2 := 1.0 / math.sqrt(t1) return {q.x*t2, q.y*t2, q.z*t2} } -axis_from_quaternion_f32 :: proc(q: Quaternionf32) -> Vector3f32 { +@(require_results) +axis_from_quaternion_f32 :: proc "contextless" (q: Quaternionf32) -> Vector3f32 { t1 := 1 - q.w*q.w if t1 < 0 { return {0, 0, 1} @@ -517,7 +542,8 @@ axis_from_quaternion_f32 :: proc(q: Quaternionf32) -> Vector3f32 { t2 := 1.0 / math.sqrt(t1) return {q.x*t2, q.y*t2, q.z*t2} } -axis_from_quaternion_f64 :: proc(q: Quaternionf64) -> Vector3f64 { +@(require_results) +axis_from_quaternion_f64 :: proc "contextless" (q: Quaternionf64) -> Vector3f64 { t1 := 1 - q.w*q.w if t1 < 0 { return {0, 0, 1} @@ -532,17 +558,20 @@ axis_from_quaternion :: proc{ } -angle_axis_from_quaternion_f16 :: proc(q: Quaternionf16) -> (angle: f16, axis: Vector3f16) { +@(require_results) +angle_axis_from_quaternion_f16 :: proc "contextless" (q: Quaternionf16) -> (angle: f16, axis: Vector3f16) { angle = angle_from_quaternion(q) axis = axis_from_quaternion(q) return } -angle_axis_from_quaternion_f32 :: proc(q: Quaternionf32) -> (angle: f32, axis: Vector3f32) { +@(require_results) +angle_axis_from_quaternion_f32 :: proc "contextless" (q: Quaternionf32) -> (angle: f32, axis: Vector3f32) { angle = angle_from_quaternion(q) axis = axis_from_quaternion(q) return } -angle_axis_from_quaternion_f64 :: proc(q: Quaternionf64) -> (angle: f64, axis: Vector3f64) { +@(require_results) +angle_axis_from_quaternion_f64 :: proc "contextless" (q: Quaternionf64) -> (angle: f64, axis: Vector3f64) { angle = angle_from_quaternion(q) axis = axis_from_quaternion(q) return @@ -554,7 +583,8 @@ angle_axis_from_quaternion :: proc { } -quaternion_from_forward_and_up_f16 :: proc(forward, up: Vector3f16) -> Quaternionf16 { +@(require_results) +quaternion_from_forward_and_up_f16 :: proc "contextless" (forward, up: Vector3f16) -> Quaternionf16 { f := normalize(forward) s := normalize(cross(f, up)) u := cross(s, f) @@ -597,7 +627,8 @@ quaternion_from_forward_and_up_f16 :: proc(forward, up: Vector3f16) -> Quaternio return normalize(q) } -quaternion_from_forward_and_up_f32 :: proc(forward, up: Vector3f32) -> Quaternionf32 { +@(require_results) +quaternion_from_forward_and_up_f32 :: proc "contextless" (forward, up: Vector3f32) -> Quaternionf32 { f := normalize(forward) s := normalize(cross(f, up)) u := cross(s, f) @@ -640,7 +671,8 @@ quaternion_from_forward_and_up_f32 :: proc(forward, up: Vector3f32) -> Quaternio return normalize(q) } -quaternion_from_forward_and_up_f64 :: proc(forward, up: Vector3f64) -> Quaternionf64 { +@(require_results) +quaternion_from_forward_and_up_f64 :: proc "contextless" (forward, up: Vector3f64) -> Quaternionf64 { f := normalize(forward) s := normalize(cross(f, up)) u := cross(s, f) @@ -689,13 +721,16 @@ quaternion_from_forward_and_up :: proc{ quaternion_from_forward_and_up_f64, } -quaternion_look_at_f16 :: proc(eye, centre: Vector3f16, up: Vector3f16) -> Quaternionf16 { +@(require_results) +quaternion_look_at_f16 :: proc "contextless" (eye, centre: Vector3f16, up: Vector3f16) -> Quaternionf16 { return quaternion_from_matrix3(matrix3_look_at(eye, centre, up)) } -quaternion_look_at_f32 :: proc(eye, centre: Vector3f32, up: Vector3f32) -> Quaternionf32 { +@(require_results) +quaternion_look_at_f32 :: proc "contextless" (eye, centre: Vector3f32, up: Vector3f32) -> Quaternionf32 { return quaternion_from_matrix3(matrix3_look_at(eye, centre, up)) } -quaternion_look_at_f64 :: proc(eye, centre: Vector3f64, up: Vector3f64) -> Quaternionf64 { +@(require_results) +quaternion_look_at_f64 :: proc "contextless" (eye, centre: Vector3f64, up: Vector3f64) -> Quaternionf64 { return quaternion_from_matrix3(matrix3_look_at(eye, centre, up)) } quaternion_look_at :: proc{ @@ -706,21 +741,24 @@ quaternion_look_at :: proc{ -quaternion_nlerp_f16 :: proc(a, b: Quaternionf16, t: f16) -> (c: Quaternionf16) { +@(require_results) +quaternion_nlerp_f16 :: proc "contextless" (a, b: Quaternionf16, t: f16) -> (c: Quaternionf16) { c.x = a.x + (b.x-a.x)*t c.y = a.y + (b.y-a.y)*t c.z = a.z + (b.z-a.z)*t c.w = a.w + (b.w-a.w)*t return normalize(c) } -quaternion_nlerp_f32 :: proc(a, b: Quaternionf32, t: f32) -> (c: Quaternionf32) { +@(require_results) +quaternion_nlerp_f32 :: proc "contextless" (a, b: Quaternionf32, t: f32) -> (c: Quaternionf32) { c.x = a.x + (b.x-a.x)*t c.y = a.y + (b.y-a.y)*t c.z = a.z + (b.z-a.z)*t c.w = a.w + (b.w-a.w)*t return normalize(c) } -quaternion_nlerp_f64 :: proc(a, b: Quaternionf64, t: f64) -> (c: Quaternionf64) { +@(require_results) +quaternion_nlerp_f64 :: proc "contextless" (a, b: Quaternionf64, t: f64) -> (c: Quaternionf64) { c.x = a.x + (b.x-a.x)*t c.y = a.y + (b.y-a.y)*t c.z = a.z + (b.z-a.z)*t @@ -734,7 +772,8 @@ quaternion_nlerp :: proc{ } -quaternion_slerp_f16 :: proc(x, y: Quaternionf16, t: f16) -> (q: Quaternionf16) { +@(require_results) +quaternion_slerp_f16 :: proc "contextless" (x, y: Quaternionf16, t: f16) -> (q: Quaternionf16) { a, b := x, y cos_angle := dot(a, b) if cos_angle < 0 { @@ -761,7 +800,8 @@ quaternion_slerp_f16 :: proc(x, y: Quaternionf16, t: f16) -> (q: Quaternionf16) q.w = factor_a * a.w + factor_b * b.w return } -quaternion_slerp_f32 :: proc(x, y: Quaternionf32, t: f32) -> (q: Quaternionf32) { +@(require_results) +quaternion_slerp_f32 :: proc "contextless" (x, y: Quaternionf32, t: f32) -> (q: Quaternionf32) { a, b := x, y cos_angle := dot(a, b) if cos_angle < 0 { @@ -788,7 +828,8 @@ quaternion_slerp_f32 :: proc(x, y: Quaternionf32, t: f32) -> (q: Quaternionf32) q.w = factor_a * a.w + factor_b * b.w return } -quaternion_slerp_f64 :: proc(x, y: Quaternionf64, t: f64) -> (q: Quaternionf64) { +@(require_results) +quaternion_slerp_f64 :: proc "contextless" (x, y: Quaternionf64, t: f64) -> (q: Quaternionf64) { a, b := x, y cos_angle := dot(a, b) if cos_angle < 0 { @@ -822,15 +863,18 @@ quaternion_slerp :: proc{ } -quaternion_squad_f16 :: proc(q1, q2, s1, s2: Quaternionf16, h: f16) -> Quaternionf16 { +@(require_results) +quaternion_squad_f16 :: proc "contextless" (q1, q2, s1, s2: Quaternionf16, h: f16) -> Quaternionf16 { slerp :: quaternion_slerp return slerp(slerp(q1, q2, h), slerp(s1, s2, h), 2 * (1 - h) * h) } -quaternion_squad_f32 :: proc(q1, q2, s1, s2: Quaternionf32, h: f32) -> Quaternionf32 { +@(require_results) +quaternion_squad_f32 :: proc "contextless" (q1, q2, s1, s2: Quaternionf32, h: f32) -> Quaternionf32 { slerp :: quaternion_slerp return slerp(slerp(q1, q2, h), slerp(s1, s2, h), 2 * (1 - h) * h) } -quaternion_squad_f64 :: proc(q1, q2, s1, s2: Quaternionf64, h: f64) -> Quaternionf64 { +@(require_results) +quaternion_squad_f64 :: proc "contextless" (q1, q2, s1, s2: Quaternionf64, h: f64) -> Quaternionf64 { slerp :: quaternion_slerp return slerp(slerp(q1, q2, h), slerp(s1, s2, h), 2 * (1 - h) * h) } @@ -841,21 +885,24 @@ quaternion_squad :: proc{ } -quaternion_from_matrix4_f16 :: proc(m: Matrix4f16) -> (q: Quaternionf16) { +@(require_results) +quaternion_from_matrix4_f16 :: proc "contextless" (m: Matrix4f16) -> (q: Quaternionf16) { m3: Matrix3f16 = --- m3[0, 0], m3[1, 0], m3[2, 0] = m[0, 0], m[1, 0], m[2, 0] m3[0, 1], m3[1, 1], m3[2, 1] = m[0, 1], m[1, 1], m[2, 1] m3[0, 2], m3[1, 2], m3[2, 2] = m[0, 2], m[1, 2], m[2, 2] return quaternion_from_matrix3(m3) } -quaternion_from_matrix4_f32 :: proc(m: Matrix4f32) -> (q: Quaternionf32) { +@(require_results) +quaternion_from_matrix4_f32 :: proc "contextless" (m: Matrix4f32) -> (q: Quaternionf32) { m3: Matrix3f32 = --- m3[0, 0], m3[1, 0], m3[2, 0] = m[0, 0], m[1, 0], m[2, 0] m3[0, 1], m3[1, 1], m3[2, 1] = m[0, 1], m[1, 1], m[2, 1] m3[0, 2], m3[1, 2], m3[2, 2] = m[0, 2], m[1, 2], m[2, 2] return quaternion_from_matrix3(m3) } -quaternion_from_matrix4_f64 :: proc(m: Matrix4f64) -> (q: Quaternionf64) { +@(require_results) +quaternion_from_matrix4_f64 :: proc "contextless" (m: Matrix4f64) -> (q: Quaternionf64) { m3: Matrix3f64 = --- m3[0, 0], m3[1, 0], m3[2, 0] = m[0, 0], m[1, 0], m[2, 0] m3[0, 1], m3[1, 1], m3[2, 1] = m[0, 1], m[1, 1], m[2, 1] @@ -869,7 +916,8 @@ quaternion_from_matrix4 :: proc{ } -quaternion_from_matrix3_f16 :: proc(m: Matrix3f16) -> (q: Quaternionf16) { +@(require_results) +quaternion_from_matrix3_f16 :: proc "contextless" (m: Matrix3f16) -> (q: Quaternionf16) { four_x_squared_minus_1 := m[0, 0] - m[1, 1] - m[2, 2] four_y_squared_minus_1 := m[1, 1] - m[0, 0] - m[2, 2] four_z_squared_minus_1 := m[2, 2] - m[0, 0] - m[1, 1] @@ -918,7 +966,8 @@ quaternion_from_matrix3_f16 :: proc(m: Matrix3f16) -> (q: Quaternionf16) { } return } -quaternion_from_matrix3_f32 :: proc(m: Matrix3f32) -> (q: Quaternionf32) { +@(require_results) +quaternion_from_matrix3_f32 :: proc "contextless" (m: Matrix3f32) -> (q: Quaternionf32) { four_x_squared_minus_1 := m[0, 0] - m[1, 1] - m[2, 2] four_y_squared_minus_1 := m[1, 1] - m[0, 0] - m[2, 2] four_z_squared_minus_1 := m[2, 2] - m[0, 0] - m[1, 1] @@ -967,7 +1016,8 @@ quaternion_from_matrix3_f32 :: proc(m: Matrix3f32) -> (q: Quaternionf32) { } return } -quaternion_from_matrix3_f64 :: proc(m: Matrix3f64) -> (q: Quaternionf64) { +@(require_results) +quaternion_from_matrix3_f64 :: proc "contextless" (m: Matrix3f64) -> (q: Quaternionf64) { four_x_squared_minus_1 := m[0, 0] - m[1, 1] - m[2, 2] four_y_squared_minus_1 := m[1, 1] - m[0, 0] - m[2, 2] four_z_squared_minus_1 := m[2, 2] - m[0, 0] - m[1, 1] @@ -1023,7 +1073,8 @@ quaternion_from_matrix3 :: proc{ } -quaternion_between_two_vector3_f16 :: proc(from, to: Vector3f16) -> (q: Quaternionf16) { +@(require_results) +quaternion_between_two_vector3_f16 :: proc "contextless" (from, to: Vector3f16) -> (q: Quaternionf16) { x := normalize(from) y := normalize(to) @@ -1044,7 +1095,8 @@ quaternion_between_two_vector3_f16 :: proc(from, to: Vector3f16) -> (q: Quaterni q.z = v.z return normalize(q) } -quaternion_between_two_vector3_f32 :: proc(from, to: Vector3f32) -> (q: Quaternionf32) { +@(require_results) +quaternion_between_two_vector3_f32 :: proc "contextless" (from, to: Vector3f32) -> (q: Quaternionf32) { x := normalize(from) y := normalize(to) @@ -1065,7 +1117,8 @@ quaternion_between_two_vector3_f32 :: proc(from, to: Vector3f32) -> (q: Quaterni q.z = v.z return normalize(q) } -quaternion_between_two_vector3_f64 :: proc(from, to: Vector3f64) -> (q: Quaternionf64) { +@(require_results) +quaternion_between_two_vector3_f64 :: proc "contextless" (from, to: Vector3f64) -> (q: Quaternionf64) { x := normalize(from) y := normalize(to) @@ -1093,7 +1146,8 @@ quaternion_between_two_vector3 :: proc{ } -matrix2_inverse_transpose_f16 :: proc(m: Matrix2f16) -> (c: Matrix2f16) { +@(require_results) +matrix2_inverse_transpose_f16 :: proc "contextless" (m: Matrix2f16) -> (c: Matrix2f16) { d := m[0, 0]*m[1, 1] - m[0, 1]*m[1, 0] id := 1.0/d c[0, 0] = +m[1, 1] * id @@ -1102,7 +1156,8 @@ matrix2_inverse_transpose_f16 :: proc(m: Matrix2f16) -> (c: Matrix2f16) { c[1, 1] = +m[0, 0] * id return c } -matrix2_inverse_transpose_f32 :: proc(m: Matrix2f32) -> (c: Matrix2f32) { +@(require_results) +matrix2_inverse_transpose_f32 :: proc "contextless" (m: Matrix2f32) -> (c: Matrix2f32) { d := m[0, 0]*m[1, 1] - m[0, 1]*m[1, 0] id := 1.0/d c[0, 0] = +m[1, 1] * id @@ -1111,7 +1166,8 @@ matrix2_inverse_transpose_f32 :: proc(m: Matrix2f32) -> (c: Matrix2f32) { c[1, 1] = +m[0, 0] * id return c } -matrix2_inverse_transpose_f64 :: proc(m: Matrix2f64) -> (c: Matrix2f64) { +@(require_results) +matrix2_inverse_transpose_f64 :: proc "contextless" (m: Matrix2f64) -> (c: Matrix2f64) { d := m[0, 0]*m[1, 1] - m[0, 1]*m[1, 0] id := 1.0/d c[0, 0] = +m[1, 1] * id @@ -1127,13 +1183,16 @@ matrix2_inverse_transpose :: proc{ } -matrix2_determinant_f16 :: proc(m: Matrix2f16) -> f16 { +@(require_results) +matrix2_determinant_f16 :: proc "contextless" (m: Matrix2f16) -> f16 { return m[0, 0]*m[1, 1] - m[0, 1]*m[1, 0] } -matrix2_determinant_f32 :: proc(m: Matrix2f32) -> f32 { +@(require_results) +matrix2_determinant_f32 :: proc "contextless" (m: Matrix2f32) -> f32 { return m[0, 0]*m[1, 1] - m[0, 1]*m[1, 0] } -matrix2_determinant_f64 :: proc(m: Matrix2f64) -> f64 { +@(require_results) +matrix2_determinant_f64 :: proc "contextless" (m: Matrix2f64) -> f64 { return m[0, 0]*m[1, 1] - m[0, 1]*m[1, 0] } matrix2_determinant :: proc{ @@ -1143,7 +1202,8 @@ matrix2_determinant :: proc{ } -matrix2_inverse_f16 :: proc(m: Matrix2f16) -> (c: Matrix2f16) { +@(require_results) +matrix2_inverse_f16 :: proc "contextless" (m: Matrix2f16) -> (c: Matrix2f16) { d := m[0, 0]*m[1, 1] - m[0, 1]*m[1, 0] id := 1.0/d c[0, 0] = +m[1, 1] * id @@ -1152,7 +1212,8 @@ matrix2_inverse_f16 :: proc(m: Matrix2f16) -> (c: Matrix2f16) { c[1, 1] = +m[0, 0] * id return c } -matrix2_inverse_f32 :: proc(m: Matrix2f32) -> (c: Matrix2f32) { +@(require_results) +matrix2_inverse_f32 :: proc "contextless" (m: Matrix2f32) -> (c: Matrix2f32) { d := m[0, 0]*m[1, 1] - m[0, 1]*m[1, 0] id := 1.0/d c[0, 0] = +m[1, 1] * id @@ -1161,7 +1222,8 @@ matrix2_inverse_f32 :: proc(m: Matrix2f32) -> (c: Matrix2f32) { c[1, 1] = +m[0, 0] * id return c } -matrix2_inverse_f64 :: proc(m: Matrix2f64) -> (c: Matrix2f64) { +@(require_results) +matrix2_inverse_f64 :: proc "contextless" (m: Matrix2f64) -> (c: Matrix2f64) { d := m[0, 0]*m[1, 1] - m[0, 1]*m[1, 0] id := 1.0/d c[0, 0] = +m[1, 1] * id @@ -1177,21 +1239,24 @@ matrix2_inverse :: proc{ } -matrix2_adjoint_f16 :: proc(m: Matrix2f16) -> (c: Matrix2f16) { +@(require_results) +matrix2_adjoint_f16 :: proc "contextless" (m: Matrix2f16) -> (c: Matrix2f16) { c[0, 0] = +m[1, 1] c[1, 0] = -m[0, 1] c[0, 1] = -m[1, 0] c[1, 1] = +m[0, 0] return c } -matrix2_adjoint_f32 :: proc(m: Matrix2f32) -> (c: Matrix2f32) { +@(require_results) +matrix2_adjoint_f32 :: proc "contextless" (m: Matrix2f32) -> (c: Matrix2f32) { c[0, 0] = +m[1, 1] c[1, 0] = -m[0, 1] c[0, 1] = -m[1, 0] c[1, 1] = +m[0, 0] return c } -matrix2_adjoint_f64 :: proc(m: Matrix2f64) -> (c: Matrix2f64) { +@(require_results) +matrix2_adjoint_f64 :: proc "contextless" (m: Matrix2f64) -> (c: Matrix2f64) { c[0, 0] = +m[1, 1] c[1, 0] = -m[0, 1] c[0, 1] = -m[1, 0] @@ -1205,7 +1270,8 @@ matrix2_adjoint :: proc{ } -matrix3_from_quaternion_f16 :: proc(q: Quaternionf16) -> (m: Matrix3f16) { +@(require_results) +matrix3_from_quaternion_f16 :: proc "contextless" (q: Quaternionf16) -> (m: Matrix3f16) { qxx := q.x * q.x qyy := q.y * q.y qzz := q.z * q.z @@ -1229,7 +1295,8 @@ matrix3_from_quaternion_f16 :: proc(q: Quaternionf16) -> (m: Matrix3f16) { m[2, 2] = 1 - 2 * (qxx + qyy) return m } -matrix3_from_quaternion_f32 :: proc(q: Quaternionf32) -> (m: Matrix3f32) { +@(require_results) +matrix3_from_quaternion_f32 :: proc "contextless" (q: Quaternionf32) -> (m: Matrix3f32) { qxx := q.x * q.x qyy := q.y * q.y qzz := q.z * q.z @@ -1253,7 +1320,8 @@ matrix3_from_quaternion_f32 :: proc(q: Quaternionf32) -> (m: Matrix3f32) { m[2, 2] = 1 - 2 * (qxx + qyy) return m } -matrix3_from_quaternion_f64 :: proc(q: Quaternionf64) -> (m: Matrix3f64) { +@(require_results) +matrix3_from_quaternion_f64 :: proc "contextless" (q: Quaternionf64) -> (m: Matrix3f64) { qxx := q.x * q.x qyy := q.y * q.y qzz := q.z * q.z @@ -1284,13 +1352,16 @@ matrix3_from_quaternion :: proc{ } -matrix3_inverse_f16 :: proc(m: Matrix3f16) -> Matrix3f16 { +@(require_results) +matrix3_inverse_f16 :: proc "contextless" (m: Matrix3f16) -> Matrix3f16 { return transpose(matrix3_inverse_transpose(m)) } -matrix3_inverse_f32 :: proc(m: Matrix3f32) -> Matrix3f32 { +@(require_results) +matrix3_inverse_f32 :: proc "contextless" (m: Matrix3f32) -> Matrix3f32 { return transpose(matrix3_inverse_transpose(m)) } -matrix3_inverse_f64 :: proc(m: Matrix3f64) -> Matrix3f64 { +@(require_results) +matrix3_inverse_f64 :: proc "contextless" (m: Matrix3f64) -> Matrix3f64 { return transpose(matrix3_inverse_transpose(m)) } matrix3_inverse :: proc{ @@ -1300,19 +1371,22 @@ matrix3_inverse :: proc{ } -matrix3_determinant_f16 :: proc(m: Matrix3f16) -> f16 { +@(require_results) +matrix3_determinant_f16 :: proc "contextless" (m: Matrix3f16) -> f16 { a := +m[0, 0] * (m[1, 1] * m[2, 2] - m[1, 2] * m[2, 1]) b := -m[0, 1] * (m[1, 0] * m[2, 2] - m[1, 2] * m[2, 0]) c := +m[0, 2] * (m[1, 0] * m[2, 1] - m[1, 1] * m[2, 0]) return a + b + c } -matrix3_determinant_f32 :: proc(m: Matrix3f32) -> f32 { +@(require_results) +matrix3_determinant_f32 :: proc "contextless" (m: Matrix3f32) -> f32 { a := +m[0, 0] * (m[1, 1] * m[2, 2] - m[1, 2] * m[2, 1]) b := -m[0, 1] * (m[1, 0] * m[2, 2] - m[1, 2] * m[2, 0]) c := +m[0, 2] * (m[1, 0] * m[2, 1] - m[1, 1] * m[2, 0]) return a + b + c } -matrix3_determinant_f64 :: proc(m: Matrix3f64) -> f64 { +@(require_results) +matrix3_determinant_f64 :: proc "contextless" (m: Matrix3f64) -> f64 { a := +m[0, 0] * (m[1, 1] * m[2, 2] - m[1, 2] * m[2, 1]) b := -m[0, 1] * (m[1, 0] * m[2, 2] - m[1, 2] * m[2, 0]) c := +m[0, 2] * (m[1, 0] * m[2, 1] - m[1, 1] * m[2, 0]) @@ -1325,7 +1399,8 @@ matrix3_determinant :: proc{ } -matrix3_adjoint_f16 :: proc(m: Matrix3f16) -> (adjoint: Matrix3f16) { +@(require_results) +matrix3_adjoint_f16 :: proc "contextless" (m: Matrix3f16) -> (adjoint: Matrix3f16) { adjoint[0, 0] = +(m[1, 1] * m[2, 2] - m[2, 1] * m[1, 2]) adjoint[0, 1] = -(m[1, 0] * m[2, 2] - m[2, 0] * m[1, 2]) adjoint[0, 2] = +(m[1, 0] * m[2, 1] - m[2, 0] * m[1, 1]) @@ -1337,7 +1412,8 @@ matrix3_adjoint_f16 :: proc(m: Matrix3f16) -> (adjoint: Matrix3f16) { adjoint[2, 2] = +(m[0, 0] * m[1, 1] - m[1, 0] * m[0, 1]) return adjoint } -matrix3_adjoint_f32 :: proc(m: Matrix3f32) -> (adjoint: Matrix3f32) { +@(require_results) +matrix3_adjoint_f32 :: proc "contextless" (m: Matrix3f32) -> (adjoint: Matrix3f32) { adjoint[0, 0] = +(m[1, 1] * m[2, 2] - m[2, 1] * m[1, 2]) adjoint[0, 1] = -(m[1, 0] * m[2, 2] - m[2, 0] * m[1, 2]) adjoint[0, 2] = +(m[1, 0] * m[2, 1] - m[2, 0] * m[1, 1]) @@ -1349,7 +1425,8 @@ matrix3_adjoint_f32 :: proc(m: Matrix3f32) -> (adjoint: Matrix3f32) { adjoint[2, 2] = +(m[0, 0] * m[1, 1] - m[1, 0] * m[0, 1]) return adjoint } -matrix3_adjoint_f64 :: proc(m: Matrix3f64) -> (adjoint: Matrix3f64) { +@(require_results) +matrix3_adjoint_f64 :: proc "contextless" (m: Matrix3f64) -> (adjoint: Matrix3f64) { adjoint[0, 0] = +(m[1, 1] * m[2, 2] - m[2, 1] * m[1, 2]) adjoint[0, 1] = -(m[1, 0] * m[2, 2] - m[2, 0] * m[1, 2]) adjoint[0, 2] = +(m[1, 0] * m[2, 1] - m[2, 0] * m[1, 1]) @@ -1369,13 +1446,16 @@ matrix3_adjoint :: proc{ -matrix3_inverse_transpose_f16 :: proc(m: Matrix3f16) -> (inverse_transpose: Matrix3f16) { +@(require_results) +matrix3_inverse_transpose_f16 :: proc "contextless" (m: Matrix3f16) -> (inverse_transpose: Matrix3f16) { return builtin.inverse_transpose(m) } -matrix3_inverse_transpose_f32 :: proc(m: Matrix3f32) -> (inverse_transpose: Matrix3f32) { +@(require_results) +matrix3_inverse_transpose_f32 :: proc "contextless" (m: Matrix3f32) -> (inverse_transpose: Matrix3f32) { return builtin.inverse_transpose(m) } -matrix3_inverse_transpose_f64 :: proc(m: Matrix3f64) -> (inverse_transpose: Matrix3f64) { +@(require_results) +matrix3_inverse_transpose_f64 :: proc "contextless" (m: Matrix3f64) -> (inverse_transpose: Matrix3f64) { return builtin.inverse_transpose(m) } matrix3_inverse_transpose :: proc{ @@ -1385,19 +1465,22 @@ matrix3_inverse_transpose :: proc{ } -matrix3_scale_f16 :: proc(s: Vector3f16) -> (m: Matrix3f16) { +@(require_results) +matrix3_scale_f16 :: proc "contextless" (s: Vector3f16) -> (m: Matrix3f16) { m[0, 0] = s[0] m[1, 1] = s[1] m[2, 2] = s[2] return m } -matrix3_scale_f32 :: proc(s: Vector3f32) -> (m: Matrix3f32) { +@(require_results) +matrix3_scale_f32 :: proc "contextless" (s: Vector3f32) -> (m: Matrix3f32) { m[0, 0] = s[0] m[1, 1] = s[1] m[2, 2] = s[2] return m } -matrix3_scale_f64 :: proc(s: Vector3f64) -> (m: Matrix3f64) { +@(require_results) +matrix3_scale_f64 :: proc "contextless" (s: Vector3f64) -> (m: Matrix3f64) { m[0, 0] = s[0] m[1, 1] = s[1] m[2, 2] = s[2] @@ -1410,7 +1493,8 @@ matrix3_scale :: proc{ } -matrix3_rotate_f16 :: proc(angle_radians: f16, v: Vector3f16) -> (rot: Matrix3f16) { +@(require_results) +matrix3_rotate_f16 :: proc "contextless" (angle_radians: f16, v: Vector3f16) -> (rot: Matrix3f16) { c := math.cos(angle_radians) s := math.sin(angle_radians) @@ -1431,7 +1515,8 @@ matrix3_rotate_f16 :: proc(angle_radians: f16, v: Vector3f16) -> (rot: Matrix3f1 return rot } -matrix3_rotate_f32 :: proc(angle_radians: f32, v: Vector3f32) -> (rot: Matrix3f32) { +@(require_results) +matrix3_rotate_f32 :: proc "contextless" (angle_radians: f32, v: Vector3f32) -> (rot: Matrix3f32) { c := math.cos(angle_radians) s := math.sin(angle_radians) @@ -1452,7 +1537,8 @@ matrix3_rotate_f32 :: proc(angle_radians: f32, v: Vector3f32) -> (rot: Matrix3f3 return rot } -matrix3_rotate_f64 :: proc(angle_radians: f64, v: Vector3f64) -> (rot: Matrix3f64) { +@(require_results) +matrix3_rotate_f64 :: proc "contextless" (angle_radians: f64, v: Vector3f64) -> (rot: Matrix3f64) { c := math.cos(angle_radians) s := math.sin(angle_radians) @@ -1480,7 +1566,8 @@ matrix3_rotate :: proc{ } -matrix3_look_at_f16 :: proc(eye, centre, up: Vector3f16) -> Matrix3f16 { +@(require_results) +matrix3_look_at_f16 :: proc "contextless" (eye, centre, up: Vector3f16) -> Matrix3f16 { f := normalize(centre - eye) s := normalize(cross(f, up)) u := cross(s, f) @@ -1490,7 +1577,8 @@ matrix3_look_at_f16 :: proc(eye, centre, up: Vector3f16) -> Matrix3f16 { -f.x, -f.y, -f.z, } } -matrix3_look_at_f32 :: proc(eye, centre, up: Vector3f32) -> Matrix3f32 { +@(require_results) +matrix3_look_at_f32 :: proc "contextless" (eye, centre, up: Vector3f32) -> Matrix3f32 { f := normalize(centre - eye) s := normalize(cross(f, up)) u := cross(s, f) @@ -1500,7 +1588,8 @@ matrix3_look_at_f32 :: proc(eye, centre, up: Vector3f32) -> Matrix3f32 { -f.x, -f.y, -f.z, } } -matrix3_look_at_f64 :: proc(eye, centre, up: Vector3f64) -> Matrix3f64 { +@(require_results) +matrix3_look_at_f64 :: proc "contextless" (eye, centre, up: Vector3f64) -> Matrix3f64 { f := normalize(centre - eye) s := normalize(cross(f, up)) u := cross(s, f) @@ -1517,7 +1606,8 @@ matrix3_look_at :: proc{ } -matrix4_from_quaternion_f16 :: proc(q: Quaternionf16) -> (m: Matrix4f16) { +@(require_results) +matrix4_from_quaternion_f16 :: proc "contextless" (q: Quaternionf16) -> (m: Matrix4f16) { qxx := q.x * q.x qyy := q.y * q.y qzz := q.z * q.z @@ -1544,7 +1634,8 @@ matrix4_from_quaternion_f16 :: proc(q: Quaternionf16) -> (m: Matrix4f16) { return m } -matrix4_from_quaternion_f32 :: proc(q: Quaternionf32) -> (m: Matrix4f32) { +@(require_results) +matrix4_from_quaternion_f32 :: proc "contextless" (q: Quaternionf32) -> (m: Matrix4f32) { qxx := q.x * q.x qyy := q.y * q.y qzz := q.z * q.z @@ -1571,7 +1662,8 @@ matrix4_from_quaternion_f32 :: proc(q: Quaternionf32) -> (m: Matrix4f32) { return m } -matrix4_from_quaternion_f64 :: proc(q: Quaternionf64) -> (m: Matrix4f64) { +@(require_results) +matrix4_from_quaternion_f64 :: proc "contextless" (q: Quaternionf64) -> (m: Matrix4f64) { qxx := q.x * q.x qyy := q.y * q.y qzz := q.z * q.z @@ -1605,19 +1697,22 @@ matrix4_from_quaternion :: proc{ } -matrix4_from_trs_f16 :: proc(t: Vector3f16, r: Quaternionf16, s: Vector3f16) -> Matrix4f16 { +@(require_results) +matrix4_from_trs_f16 :: proc "contextless" (t: Vector3f16, r: Quaternionf16, s: Vector3f16) -> Matrix4f16 { translation := matrix4_translate(t) rotation := matrix4_from_quaternion(r) scale := matrix4_scale(s) return mul(translation, mul(rotation, scale)) } -matrix4_from_trs_f32 :: proc(t: Vector3f32, r: Quaternionf32, s: Vector3f32) -> Matrix4f32 { +@(require_results) +matrix4_from_trs_f32 :: proc "contextless" (t: Vector3f32, r: Quaternionf32, s: Vector3f32) -> Matrix4f32 { translation := matrix4_translate(t) rotation := matrix4_from_quaternion(r) scale := matrix4_scale(s) return mul(translation, mul(rotation, scale)) } -matrix4_from_trs_f64 :: proc(t: Vector3f64, r: Quaternionf64, s: Vector3f64) -> Matrix4f64 { +@(require_results) +matrix4_from_trs_f64 :: proc "contextless" (t: Vector3f64, r: Quaternionf64, s: Vector3f64) -> Matrix4f64 { translation := matrix4_translate(t) rotation := matrix4_from_quaternion(r) scale := matrix4_scale(s) @@ -1631,13 +1726,16 @@ matrix4_from_trs :: proc{ -matrix4_inverse_f16 :: proc(m: Matrix4f16) -> Matrix4f16 { +@(require_results) +matrix4_inverse_f16 :: proc "contextless" (m: Matrix4f16) -> Matrix4f16 { return transpose(matrix4_inverse_transpose(m)) } -matrix4_inverse_f32 :: proc(m: Matrix4f32) -> Matrix4f32 { +@(require_results) +matrix4_inverse_f32 :: proc "contextless" (m: Matrix4f32) -> Matrix4f32 { return transpose(matrix4_inverse_transpose(m)) } -matrix4_inverse_f64 :: proc(m: Matrix4f64) -> Matrix4f64 { +@(require_results) +matrix4_inverse_f64 :: proc "contextless" (m: Matrix4f64) -> Matrix4f64 { return transpose(matrix4_inverse_transpose(m)) } matrix4_inverse :: proc{ @@ -1647,7 +1745,8 @@ matrix4_inverse :: proc{ } -matrix4_minor_f16 :: proc(m: Matrix4f16, c, r: int) -> f16 { +@(require_results) +matrix4_minor_f16 :: proc "contextless" (m: Matrix4f16, c, r: int) -> f16 { cut_down: Matrix3f16 for i in 0..<3 { col := i if i < c else i+1 @@ -1658,7 +1757,8 @@ matrix4_minor_f16 :: proc(m: Matrix4f16, c, r: int) -> f16 { } return matrix3_determinant(cut_down) } -matrix4_minor_f32 :: proc(m: Matrix4f32, c, r: int) -> f32 { +@(require_results) +matrix4_minor_f32 :: proc "contextless" (m: Matrix4f32, c, r: int) -> f32 { cut_down: Matrix3f32 for i in 0..<3 { col := i if i < c else i+1 @@ -1669,7 +1769,8 @@ matrix4_minor_f32 :: proc(m: Matrix4f32, c, r: int) -> f32 { } return matrix3_determinant(cut_down) } -matrix4_minor_f64 :: proc(m: Matrix4f64, c, r: int) -> f64 { +@(require_results) +matrix4_minor_f64 :: proc "contextless" (m: Matrix4f64, c, r: int) -> f64 { cut_down: Matrix3f64 for i in 0..<3 { col := i if i < c else i+1 @@ -1687,19 +1788,22 @@ matrix4_minor :: proc{ } -matrix4_cofactor_f16 :: proc(m: Matrix4f16, c, r: int) -> f16 { +@(require_results) +matrix4_cofactor_f16 :: proc "contextless" (m: Matrix4f16, c, r: int) -> f16 { sign, minor: f16 sign = 1 if (c + r) % 2 == 0 else -1 minor = matrix4_minor(m, c, r) return sign * minor } -matrix4_cofactor_f32 :: proc(m: Matrix4f32, c, r: int) -> f32 { +@(require_results) +matrix4_cofactor_f32 :: proc "contextless" (m: Matrix4f32, c, r: int) -> f32 { sign, minor: f32 sign = 1 if (c + r) % 2 == 0 else -1 minor = matrix4_minor(m, c, r) return sign * minor } -matrix4_cofactor_f64 :: proc(m: Matrix4f64, c, r: int) -> f64 { +@(require_results) +matrix4_cofactor_f64 :: proc "contextless" (m: Matrix4f64, c, r: int) -> f64 { sign, minor: f64 sign = 1 if (c + r) % 2 == 0 else -1 minor = matrix4_minor(m, c, r) @@ -1712,7 +1816,8 @@ matrix4_cofactor :: proc{ } -matrix4_adjoint_f16 :: proc(m: Matrix4f16) -> (adjoint: Matrix4f16) { +@(require_results) +matrix4_adjoint_f16 :: proc "contextless" (m: Matrix4f16) -> (adjoint: Matrix4f16) { for i in 0..<4 { for j in 0..<4 { adjoint[i][j] = matrix4_cofactor(m, i, j) @@ -1720,7 +1825,8 @@ matrix4_adjoint_f16 :: proc(m: Matrix4f16) -> (adjoint: Matrix4f16) { } return } -matrix4_adjoint_f32 :: proc(m: Matrix4f32) -> (adjoint: Matrix4f32) { +@(require_results) +matrix4_adjoint_f32 :: proc "contextless" (m: Matrix4f32) -> (adjoint: Matrix4f32) { for i in 0..<4 { for j in 0..<4 { adjoint[i][j] = matrix4_cofactor(m, i, j) @@ -1728,7 +1834,8 @@ matrix4_adjoint_f32 :: proc(m: Matrix4f32) -> (adjoint: Matrix4f32) { } return } -matrix4_adjoint_f64 :: proc(m: Matrix4f64) -> (adjoint: Matrix4f64) { +@(require_results) +matrix4_adjoint_f64 :: proc "contextless" (m: Matrix4f64) -> (adjoint: Matrix4f64) { for i in 0..<4 { for j in 0..<4 { adjoint[i][j] = matrix4_cofactor(m, i, j) @@ -1743,21 +1850,24 @@ matrix4_adjoint :: proc{ } -matrix4_determinant_f16 :: proc(m: Matrix4f16) -> (determinant: f16) { +@(require_results) +matrix4_determinant_f16 :: proc "contextless" (m: Matrix4f16) -> (determinant: f16) { adjoint := matrix4_adjoint(m) for i in 0..<4 { determinant += m[i][0] * adjoint[i][0] } return } -matrix4_determinant_f32 :: proc(m: Matrix4f32) -> (determinant: f32) { +@(require_results) +matrix4_determinant_f32 :: proc "contextless" (m: Matrix4f32) -> (determinant: f32) { adjoint := matrix4_adjoint(m) for i in 0..<4 { determinant += m[i][0] * adjoint[i][0] } return } -matrix4_determinant_f64 :: proc(m: Matrix4f64) -> (determinant: f64) { +@(require_results) +matrix4_determinant_f64 :: proc "contextless" (m: Matrix4f64) -> (determinant: f64) { adjoint := matrix4_adjoint(m) for i in 0..<4 { determinant += m[i][0] * adjoint[i][0] @@ -1771,7 +1881,8 @@ matrix4_determinant :: proc{ } -matrix4_inverse_transpose_f16 :: proc(m: Matrix4f16) -> (inverse_transpose: Matrix4f16) { +@(require_results) +matrix4_inverse_transpose_f16 :: proc "contextless" (m: Matrix4f16) -> (inverse_transpose: Matrix4f16) { adjoint := matrix4_adjoint(m) determinant: f16 = 0 for i in 0..<4 { @@ -1785,7 +1896,8 @@ matrix4_inverse_transpose_f16 :: proc(m: Matrix4f16) -> (inverse_transpose: Matr } return } -matrix4_inverse_transpose_f32 :: proc(m: Matrix4f32) -> (inverse_transpose: Matrix4f32) { +@(require_results) +matrix4_inverse_transpose_f32 :: proc "contextless" (m: Matrix4f32) -> (inverse_transpose: Matrix4f32) { adjoint := matrix4_adjoint(m) determinant: f32 = 0 for i in 0..<4 { @@ -1799,7 +1911,8 @@ matrix4_inverse_transpose_f32 :: proc(m: Matrix4f32) -> (inverse_transpose: Matr } return } -matrix4_inverse_transpose_f64 :: proc(m: Matrix4f64) -> (inverse_transpose: Matrix4f64) { +@(require_results) +matrix4_inverse_transpose_f64 :: proc "contextless" (m: Matrix4f64) -> (inverse_transpose: Matrix4f64) { adjoint := matrix4_adjoint(m) determinant: f64 = 0 for i in 0..<4 { @@ -1820,21 +1933,24 @@ matrix4_inverse_transpose :: proc{ } -matrix4_translate_f16 :: proc(v: Vector3f16) -> Matrix4f16 { +@(require_results) +matrix4_translate_f16 :: proc "contextless" (v: Vector3f16) -> Matrix4f16 { m := MATRIX4F16_IDENTITY m[3][0] = v[0] m[3][1] = v[1] m[3][2] = v[2] return m } -matrix4_translate_f32 :: proc(v: Vector3f32) -> Matrix4f32 { +@(require_results) +matrix4_translate_f32 :: proc "contextless" (v: Vector3f32) -> Matrix4f32 { m := MATRIX4F32_IDENTITY m[3][0] = v[0] m[3][1] = v[1] m[3][2] = v[2] return m } -matrix4_translate_f64 :: proc(v: Vector3f64) -> Matrix4f64 { +@(require_results) +matrix4_translate_f64 :: proc "contextless" (v: Vector3f64) -> Matrix4f64 { m := MATRIX4F64_IDENTITY m[3][0] = v[0] m[3][1] = v[1] @@ -1848,7 +1964,8 @@ matrix4_translate :: proc{ } -matrix4_rotate_f16 :: proc(angle_radians: f16, v: Vector3f16) -> Matrix4f16 { +@(require_results) +matrix4_rotate_f16 :: proc "contextless" (angle_radians: f16, v: Vector3f16) -> Matrix4f16 { c := math.cos(angle_radians) s := math.sin(angle_radians) @@ -1874,7 +1991,8 @@ matrix4_rotate_f16 :: proc(angle_radians: f16, v: Vector3f16) -> Matrix4f16 { return rot } -matrix4_rotate_f32 :: proc(angle_radians: f32, v: Vector3f32) -> Matrix4f32 { +@(require_results) +matrix4_rotate_f32 :: proc "contextless" (angle_radians: f32, v: Vector3f32) -> Matrix4f32 { c := math.cos(angle_radians) s := math.sin(angle_radians) @@ -1900,7 +2018,8 @@ matrix4_rotate_f32 :: proc(angle_radians: f32, v: Vector3f32) -> Matrix4f32 { return rot } -matrix4_rotate_f64 :: proc(angle_radians: f64, v: Vector3f64) -> Matrix4f64 { +@(require_results) +matrix4_rotate_f64 :: proc "contextless" (angle_radians: f64, v: Vector3f64) -> Matrix4f64 { c := math.cos(angle_radians) s := math.sin(angle_radians) @@ -1933,21 +2052,24 @@ matrix4_rotate :: proc{ } -matrix4_scale_f16 :: proc(v: Vector3f16) -> (m: Matrix4f16) { +@(require_results) +matrix4_scale_f16 :: proc "contextless" (v: Vector3f16) -> (m: Matrix4f16) { m[0][0] = v[0] m[1][1] = v[1] m[2][2] = v[2] m[3][3] = 1 return } -matrix4_scale_f32 :: proc(v: Vector3f32) -> (m: Matrix4f32) { +@(require_results) +matrix4_scale_f32 :: proc "contextless" (v: Vector3f32) -> (m: Matrix4f32) { m[0][0] = v[0] m[1][1] = v[1] m[2][2] = v[2] m[3][3] = 1 return } -matrix4_scale_f64 :: proc(v: Vector3f64) -> (m: Matrix4f64) { +@(require_results) +matrix4_scale_f64 :: proc "contextless" (v: Vector3f64) -> (m: Matrix4f64) { m[0][0] = v[0] m[1][1] = v[1] m[2][2] = v[2] @@ -1961,7 +2083,8 @@ matrix4_scale :: proc{ } -matrix4_look_at_f16 :: proc(eye, centre, up: Vector3f16, flip_z_axis := true) -> (m: Matrix4f16) { +@(require_results) +matrix4_look_at_f16 :: proc "contextless" (eye, centre, up: Vector3f16, flip_z_axis := true) -> (m: Matrix4f16) { f := normalize(centre - eye) s := normalize(cross(f, up)) u := cross(s, f) @@ -1975,7 +2098,8 @@ matrix4_look_at_f16 :: proc(eye, centre, up: Vector3f16, flip_z_axis := true) -> 0, 0, 0, 1, } } -matrix4_look_at_f32 :: proc(eye, centre, up: Vector3f32, flip_z_axis := true) -> (m: Matrix4f32) { +@(require_results) +matrix4_look_at_f32 :: proc "contextless" (eye, centre, up: Vector3f32, flip_z_axis := true) -> (m: Matrix4f32) { f := normalize(centre - eye) s := normalize(cross(f, up)) u := cross(s, f) @@ -1989,7 +2113,8 @@ matrix4_look_at_f32 :: proc(eye, centre, up: Vector3f32, flip_z_axis := true) -> 0, 0, 0, 1, } } -matrix4_look_at_f64 :: proc(eye, centre, up: Vector3f64, flip_z_axis := true) -> (m: Matrix4f64) { +@(require_results) +matrix4_look_at_f64 :: proc "contextless" (eye, centre, up: Vector3f64, flip_z_axis := true) -> (m: Matrix4f64) { f := normalize(centre - eye) s := normalize(cross(f, up)) u := cross(s, f) @@ -2010,7 +2135,8 @@ matrix4_look_at :: proc{ } -matrix4_look_at_from_fru_f16 :: proc(eye, f, r, u: Vector3f16, flip_z_axis := true) -> (m: Matrix4f16) { +@(require_results) +matrix4_look_at_from_fru_f16 :: proc "contextless" (eye, f, r, u: Vector3f16, flip_z_axis := true) -> (m: Matrix4f16) { f, s, u := f, r, u f = normalize(f) s = normalize(s) @@ -2024,7 +2150,8 @@ matrix4_look_at_from_fru_f16 :: proc(eye, f, r, u: Vector3f16, flip_z_axis := tr 0, 0, 0, 1, } } -matrix4_look_at_from_fru_f32 :: proc(eye, f, r, u: Vector3f32, flip_z_axis := true) -> (m: Matrix4f32) { +@(require_results) +matrix4_look_at_from_fru_f32 :: proc "contextless" (eye, f, r, u: Vector3f32, flip_z_axis := true) -> (m: Matrix4f32) { f, s, u := f, r, u f = normalize(f) s = normalize(s) @@ -2038,7 +2165,8 @@ matrix4_look_at_from_fru_f32 :: proc(eye, f, r, u: Vector3f32, flip_z_axis := tr 0, 0, 0, 1, } } -matrix4_look_at_from_fru_f64 :: proc(eye, f, r, u: Vector3f64, flip_z_axis := true) -> (m: Matrix4f64) { +@(require_results) +matrix4_look_at_from_fru_f64 :: proc "contextless" (eye, f, r, u: Vector3f64, flip_z_axis := true) -> (m: Matrix4f64) { f, s, u := f, r, u f = normalize(f) s = normalize(s) @@ -2059,7 +2187,8 @@ matrix4_look_at_from_fru :: proc{ } -matrix4_perspective_f16 :: proc(fovy, aspect, near, far: f16, flip_z_axis := true) -> (m: Matrix4f16) { +@(require_results) +matrix4_perspective_f16 :: proc "contextless" (fovy, aspect, near, far: f16, flip_z_axis := true) -> (m: Matrix4f16) { tan_half_fovy := math.tan(0.5 * fovy) m[0, 0] = 1 / (aspect*tan_half_fovy) m[1, 1] = 1 / (tan_half_fovy) @@ -2073,7 +2202,8 @@ matrix4_perspective_f16 :: proc(fovy, aspect, near, far: f16, flip_z_axis := tru return } -matrix4_perspective_f32 :: proc(fovy, aspect, near, far: f32, flip_z_axis := true) -> (m: Matrix4f32) { +@(require_results) +matrix4_perspective_f32 :: proc "contextless" (fovy, aspect, near, far: f32, flip_z_axis := true) -> (m: Matrix4f32) { tan_half_fovy := math.tan(0.5 * fovy) m[0, 0] = 1 / (aspect*tan_half_fovy) m[1, 1] = 1 / (tan_half_fovy) @@ -2087,7 +2217,8 @@ matrix4_perspective_f32 :: proc(fovy, aspect, near, far: f32, flip_z_axis := tru return } -matrix4_perspective_f64 :: proc(fovy, aspect, near, far: f64, flip_z_axis := true) -> (m: Matrix4f64) { +@(require_results) +matrix4_perspective_f64 :: proc "contextless" (fovy, aspect, near, far: f64, flip_z_axis := true) -> (m: Matrix4f64) { tan_half_fovy := math.tan(0.5 * fovy) m[0, 0] = 1 / (aspect*tan_half_fovy) m[1, 1] = 1 / (tan_half_fovy) @@ -2109,7 +2240,8 @@ matrix4_perspective :: proc{ -matrix_ortho3d_f16 :: proc(left, right, bottom, top, near, far: f16, flip_z_axis := true) -> (m: Matrix4f16) { +@(require_results) +matrix_ortho3d_f16 :: proc "contextless" (left, right, bottom, top, near, far: f16, flip_z_axis := true) -> (m: Matrix4f16) { m[0, 0] = +2 / (right - left) m[1, 1] = +2 / (top - bottom) m[2, 2] = +2 / (far - near) @@ -2124,7 +2256,8 @@ matrix_ortho3d_f16 :: proc(left, right, bottom, top, near, far: f16, flip_z_axis return } -matrix_ortho3d_f32 :: proc(left, right, bottom, top, near, far: f32, flip_z_axis := true) -> (m: Matrix4f32) { +@(require_results) +matrix_ortho3d_f32 :: proc "contextless" (left, right, bottom, top, near, far: f32, flip_z_axis := true) -> (m: Matrix4f32) { m[0, 0] = +2 / (right - left) m[1, 1] = +2 / (top - bottom) m[2, 2] = +2 / (far - near) @@ -2139,7 +2272,8 @@ matrix_ortho3d_f32 :: proc(left, right, bottom, top, near, far: f32, flip_z_axis return } -matrix_ortho3d_f64 :: proc(left, right, bottom, top, near, far: f64, flip_z_axis := true) -> (m: Matrix4f64) { +@(require_results) +matrix_ortho3d_f64 :: proc "contextless" (left, right, bottom, top, near, far: f64, flip_z_axis := true) -> (m: Matrix4f64) { m[0, 0] = +2 / (right - left) m[1, 1] = +2 / (top - bottom) m[2, 2] = +2 / (far - near) @@ -2162,7 +2296,8 @@ matrix_ortho3d :: proc{ -matrix4_infinite_perspective_f16 :: proc(fovy, aspect, near: f16, flip_z_axis := true) -> (m: Matrix4f16) { +@(require_results) +matrix4_infinite_perspective_f16 :: proc "contextless" (fovy, aspect, near: f16, flip_z_axis := true) -> (m: Matrix4f16) { tan_half_fovy := math.tan(0.5 * fovy) m[0, 0] = 1 / (aspect*tan_half_fovy) m[1, 1] = 1 / (tan_half_fovy) @@ -2176,7 +2311,8 @@ matrix4_infinite_perspective_f16 :: proc(fovy, aspect, near: f16, flip_z_axis := return } -matrix4_infinite_perspective_f32 :: proc(fovy, aspect, near: f32, flip_z_axis := true) -> (m: Matrix4f32) { +@(require_results) +matrix4_infinite_perspective_f32 :: proc "contextless" (fovy, aspect, near: f32, flip_z_axis := true) -> (m: Matrix4f32) { tan_half_fovy := math.tan(0.5 * fovy) m[0, 0] = 1 / (aspect*tan_half_fovy) m[1, 1] = 1 / (tan_half_fovy) @@ -2190,7 +2326,8 @@ matrix4_infinite_perspective_f32 :: proc(fovy, aspect, near: f32, flip_z_axis := return } -matrix4_infinite_perspective_f64 :: proc(fovy, aspect, near: f64, flip_z_axis := true) -> (m: Matrix4f64) { +@(require_results) +matrix4_infinite_perspective_f64 :: proc "contextless" (fovy, aspect, near: f64, flip_z_axis := true) -> (m: Matrix4f64) { tan_half_fovy := math.tan(0.5 * fovy) m[0, 0] = 1 / (aspect*tan_half_fovy) m[1, 1] = 1 / (tan_half_fovy) @@ -2212,17 +2349,20 @@ matrix4_infinite_perspective :: proc{ -matrix2_from_scalar_f16 :: proc(f: f16) -> (m: Matrix2f16) { +@(require_results) +matrix2_from_scalar_f16 :: proc "contextless" (f: f16) -> (m: Matrix2f16) { m[0, 0], m[1, 0] = f, 0 m[0, 1], m[1, 1] = 0, f return } -matrix2_from_scalar_f32 :: proc(f: f32) -> (m: Matrix2f32) { +@(require_results) +matrix2_from_scalar_f32 :: proc "contextless" (f: f32) -> (m: Matrix2f32) { m[0, 0], m[1, 0] = f, 0 m[0, 1], m[1, 1] = 0, f return } -matrix2_from_scalar_f64 :: proc(f: f64) -> (m: Matrix2f64) { +@(require_results) +matrix2_from_scalar_f64 :: proc "contextless" (f: f64) -> (m: Matrix2f64) { m[0, 0], m[1, 0] = f, 0 m[0, 1], m[1, 1] = 0, f return @@ -2234,19 +2374,22 @@ matrix2_from_scalar :: proc{ } -matrix3_from_scalar_f16 :: proc(f: f16) -> (m: Matrix3f16) { +@(require_results) +matrix3_from_scalar_f16 :: proc "contextless" (f: f16) -> (m: Matrix3f16) { m[0, 0], m[1, 0], m[2, 0] = f, 0, 0 m[0, 1], m[1, 1], m[2, 1] = 0, f, 0 m[0, 2], m[1, 2], m[2, 2] = 0, 0, f return } -matrix3_from_scalar_f32 :: proc(f: f32) -> (m: Matrix3f32) { +@(require_results) +matrix3_from_scalar_f32 :: proc "contextless" (f: f32) -> (m: Matrix3f32) { m[0, 0], m[1, 0], m[2, 0] = f, 0, 0 m[0, 1], m[1, 1], m[2, 1] = 0, f, 0 m[0, 2], m[1, 2], m[2, 2] = 0, 0, f return } -matrix3_from_scalar_f64 :: proc(f: f64) -> (m: Matrix3f64) { +@(require_results) +matrix3_from_scalar_f64 :: proc "contextless" (f: f64) -> (m: Matrix3f64) { m[0, 0], m[1, 0], m[2, 0] = f, 0, 0 m[0, 1], m[1, 1], m[2, 1] = 0, f, 0 m[0, 2], m[1, 2], m[2, 2] = 0, 0, f @@ -2259,21 +2402,24 @@ matrix3_from_scalar :: proc{ } -matrix4_from_scalar_f16 :: proc(f: f16) -> (m: Matrix4f16) { +@(require_results) +matrix4_from_scalar_f16 :: proc "contextless" (f: f16) -> (m: Matrix4f16) { m[0, 0], m[1, 0], m[2, 0], m[3, 0] = f, 0, 0, 0 m[0, 1], m[1, 1], m[2, 1], m[3, 1] = 0, f, 0, 0 m[0, 2], m[1, 2], m[2, 2], m[3, 2] = 0, 0, f, 0 m[0, 3], m[1, 3], m[2, 3], m[3, 3] = 0, 0, 0, f return } -matrix4_from_scalar_f32 :: proc(f: f32) -> (m: Matrix4f32) { +@(require_results) +matrix4_from_scalar_f32 :: proc "contextless" (f: f32) -> (m: Matrix4f32) { m[0, 0], m[1, 0], m[2, 0], m[3, 0] = f, 0, 0, 0 m[0, 1], m[1, 1], m[2, 1], m[3, 1] = 0, f, 0, 0 m[0, 2], m[1, 2], m[2, 2], m[3, 2] = 0, 0, f, 0 m[0, 3], m[1, 3], m[2, 3], m[3, 3] = 0, 0, 0, f return } -matrix4_from_scalar_f64 :: proc(f: f64) -> (m: Matrix4f64) { +@(require_results) +matrix4_from_scalar_f64 :: proc "contextless" (f: f64) -> (m: Matrix4f64) { m[0, 0], m[1, 0], m[2, 0], m[3, 0] = f, 0, 0, 0 m[0, 1], m[1, 1], m[2, 1], m[3, 1] = 0, f, 0, 0 m[0, 2], m[1, 2], m[2, 2], m[3, 2] = 0, 0, f, 0 @@ -2287,17 +2433,20 @@ matrix4_from_scalar :: proc{ } -matrix2_from_matrix3_f16 :: proc(m: Matrix3f16) -> (r: Matrix2f16) { +@(require_results) +matrix2_from_matrix3_f16 :: proc "contextless" (m: Matrix3f16) -> (r: Matrix2f16) { r[0, 0], r[1, 0] = m[0, 0], m[1, 0] r[0, 1], r[1, 1] = m[0, 1], m[1, 1] return } -matrix2_from_matrix3_f32 :: proc(m: Matrix3f32) -> (r: Matrix2f32) { +@(require_results) +matrix2_from_matrix3_f32 :: proc "contextless" (m: Matrix3f32) -> (r: Matrix2f32) { r[0, 0], r[1, 0] = m[0, 0], m[1, 0] r[0, 1], r[1, 1] = m[0, 1], m[1, 1] return } -matrix2_from_matrix3_f64 :: proc(m: Matrix3f64) -> (r: Matrix2f64) { +@(require_results) +matrix2_from_matrix3_f64 :: proc "contextless" (m: Matrix3f64) -> (r: Matrix2f64) { r[0, 0], r[1, 0] = m[0, 0], m[1, 0] r[0, 1], r[1, 1] = m[0, 1], m[1, 1] return @@ -2309,17 +2458,20 @@ matrix2_from_matrix3 :: proc{ } -matrix2_from_matrix4_f16 :: proc(m: Matrix4f16) -> (r: Matrix2f16) { +@(require_results) +matrix2_from_matrix4_f16 :: proc "contextless" (m: Matrix4f16) -> (r: Matrix2f16) { r[0, 0], r[1, 0] = m[0, 0], m[1, 0] r[0, 1], r[1, 1] = m[0, 1], m[1, 1] return } -matrix2_from_matrix4_f32 :: proc(m: Matrix4f32) -> (r: Matrix2f32) { +@(require_results) +matrix2_from_matrix4_f32 :: proc "contextless" (m: Matrix4f32) -> (r: Matrix2f32) { r[0, 0], r[1, 0] = m[0, 0], m[1, 0] r[0, 1], r[1, 1] = m[0, 1], m[1, 1] return } -matrix2_from_matrix4_f64 :: proc(m: Matrix4f64) -> (r: Matrix2f64) { +@(require_results) +matrix2_from_matrix4_f64 :: proc "contextless" (m: Matrix4f64) -> (r: Matrix2f64) { r[0, 0], r[1, 0] = m[0, 0], m[1, 0] r[0, 1], r[1, 1] = m[0, 1], m[1, 1] return @@ -2331,19 +2483,22 @@ matrix2_from_matrix4 :: proc{ } -matrix3_from_matrix2_f16 :: proc(m: Matrix2f16) -> (r: Matrix3f16) { +@(require_results) +matrix3_from_matrix2_f16 :: proc "contextless" (m: Matrix2f16) -> (r: Matrix3f16) { r[0, 0], r[1, 0], r[2, 0] = m[0, 0], m[1, 0], 0 r[0, 1], r[1, 1], r[2, 1] = m[0, 1], m[1, 1], 0 r[0, 2], r[1, 2], r[2, 2] = 0, 0, 1 return } -matrix3_from_matrix2_f32 :: proc(m: Matrix2f32) -> (r: Matrix3f32) { +@(require_results) +matrix3_from_matrix2_f32 :: proc "contextless" (m: Matrix2f32) -> (r: Matrix3f32) { r[0, 0], r[1, 0], r[2, 0] = m[0, 0], m[1, 0], 0 r[0, 1], r[1, 1], r[2, 1] = m[0, 1], m[1, 1], 0 r[0, 2], r[1, 2], r[2, 2] = 0, 0, 1 return } -matrix3_from_matrix2_f64 :: proc(m: Matrix2f64) -> (r: Matrix3f64) { +@(require_results) +matrix3_from_matrix2_f64 :: proc "contextless" (m: Matrix2f64) -> (r: Matrix3f64) { r[0, 0], r[1, 0], r[2, 0] = m[0, 0], m[1, 0], 0 r[0, 1], r[1, 1], r[2, 1] = m[0, 1], m[1, 1], 0 r[0, 2], r[1, 2], r[2, 2] = 0, 0, 1 @@ -2356,19 +2511,22 @@ matrix3_from_matrix2 :: proc{ } -matrix3_from_matrix4_f16 :: proc(m: Matrix4f16) -> (r: Matrix3f16) { +@(require_results) +matrix3_from_matrix4_f16 :: proc "contextless" (m: Matrix4f16) -> (r: Matrix3f16) { r[0, 0], r[1, 0], r[2, 0] = m[0, 0], m[1, 0], m[2, 0] r[0, 1], r[1, 1], r[2, 1] = m[0, 1], m[1, 1], m[2, 1] r[0, 2], r[1, 2], r[2, 2] = m[0, 2], m[1, 2], m[2, 2] return } -matrix3_from_matrix4_f32 :: proc(m: Matrix4f32) -> (r: Matrix3f32) { +@(require_results) +matrix3_from_matrix4_f32 :: proc "contextless" (m: Matrix4f32) -> (r: Matrix3f32) { r[0, 0], r[1, 0], r[2, 0] = m[0, 0], m[1, 0], m[2, 0] r[0, 1], r[1, 1], r[2, 1] = m[0, 1], m[1, 1], m[2, 1] r[0, 2], r[1, 2], r[2, 2] = m[0, 2], m[1, 2], m[2, 2] return } -matrix3_from_matrix4_f64 :: proc(m: Matrix4f64) -> (r: Matrix3f64) { +@(require_results) +matrix3_from_matrix4_f64 :: proc "contextless" (m: Matrix4f64) -> (r: Matrix3f64) { r[0, 0], r[1, 0], r[2, 0] = m[0, 0], m[1, 0], m[2, 0] r[0, 1], r[1, 1], r[2, 1] = m[0, 1], m[1, 1], m[2, 1] r[0, 2], r[1, 2], r[2, 2] = m[0, 2], m[1, 2], m[2, 2] @@ -2381,21 +2539,24 @@ matrix3_from_matrix4 :: proc{ } -matrix4_from_matrix2_f16 :: proc(m: Matrix2f16) -> (r: Matrix4f16) { +@(require_results) +matrix4_from_matrix2_f16 :: proc "contextless" (m: Matrix2f16) -> (r: Matrix4f16) { r[0, 0], r[1, 0], r[2, 0], r[3, 0] = m[0, 0], m[1, 0], 0, 0 r[0, 1], r[1, 1], r[2, 1], r[3, 1] = m[0, 1], m[1, 1], 0, 0 r[0, 2], r[1, 2], r[2, 2], r[3, 2] = 0, 0, 1, 0 r[0, 3], r[1, 3], r[2, 3], r[3, 3] = 0, 0, 0, 1 return } -matrix4_from_matrix2_f32 :: proc(m: Matrix2f32) -> (r: Matrix4f32) { +@(require_results) +matrix4_from_matrix2_f32 :: proc "contextless" (m: Matrix2f32) -> (r: Matrix4f32) { r[0, 0], r[1, 0], r[2, 0], r[3, 0] = m[0, 0], m[1, 0], 0, 0 r[0, 1], r[1, 1], r[2, 1], r[3, 1] = m[0, 1], m[1, 1], 0, 0 r[0, 2], r[1, 2], r[2, 2], r[3, 2] = 0, 0, 1, 0 r[0, 3], r[1, 3], r[2, 3], r[3, 3] = 0, 0, 0, 1 return } -matrix4_from_matrix2_f64 :: proc(m: Matrix2f64) -> (r: Matrix4f64) { +@(require_results) +matrix4_from_matrix2_f64 :: proc "contextless" (m: Matrix2f64) -> (r: Matrix4f64) { r[0, 0], r[1, 0], r[2, 0], r[3, 0] = m[0, 0], m[1, 0], 0, 0 r[0, 1], r[1, 1], r[2, 1], r[3, 1] = m[0, 1], m[1, 1], 0, 0 r[0, 2], r[1, 2], r[2, 2], r[3, 2] = 0, 0, 1, 0 @@ -2409,21 +2570,24 @@ matrix4_from_matrix2 :: proc{ } -matrix4_from_matrix3_f16 :: proc(m: Matrix3f16) -> (r: Matrix4f16) { +@(require_results) +matrix4_from_matrix3_f16 :: proc "contextless" (m: Matrix3f16) -> (r: Matrix4f16) { r[0, 0], r[1, 0], r[2, 0], r[3, 0] = m[0, 0], m[1, 0], m[2, 0], 0 r[0, 1], r[1, 1], r[2, 1], r[3, 1] = m[0, 1], m[1, 1], m[2, 1], 0 r[0, 2], r[1, 2], r[2, 2], r[3, 2] = m[0, 2], m[1, 2], m[2, 2], 0 r[0, 3], r[1, 3], r[2, 3], r[3, 3] = 0, 0, 0, 1 return } -matrix4_from_matrix3_f32 :: proc(m: Matrix3f32) -> (r: Matrix4f32) { +@(require_results) +matrix4_from_matrix3_f32 :: proc "contextless" (m: Matrix3f32) -> (r: Matrix4f32) { r[0, 0], r[1, 0], r[2, 0], r[3, 0] = m[0, 0], m[1, 0], m[2, 0], 0 r[0, 1], r[1, 1], r[2, 1], r[3, 1] = m[0, 1], m[1, 1], m[2, 1], 0 r[0, 2], r[1, 2], r[2, 2], r[3, 2] = m[0, 2], m[1, 2], m[2, 2], 0 r[0, 3], r[1, 3], r[2, 3], r[3, 3] = 0, 0, 0, 1 return } -matrix4_from_matrix3_f64 :: proc(m: Matrix3f64) -> (r: Matrix4f64) { +@(require_results) +matrix4_from_matrix3_f64 :: proc "contextless" (m: Matrix3f64) -> (r: Matrix4f64) { r[0, 0], r[1, 0], r[2, 0], r[3, 0] = m[0, 0], m[1, 0], m[2, 0], 0 r[0, 1], r[1, 1], r[2, 1], r[3, 1] = m[0, 1], m[1, 1], m[2, 1], 0 r[0, 2], r[1, 2], r[2, 2], r[3, 2] = m[0, 2], m[1, 2], m[2, 2], 0 @@ -2437,15 +2601,18 @@ matrix4_from_matrix3 :: proc{ } -quaternion_from_scalar_f16 :: proc(f: f16) -> (q: Quaternionf16) { +@(require_results) +quaternion_from_scalar_f16 :: proc "contextless" (f: f16) -> (q: Quaternionf16) { q.w = f return } -quaternion_from_scalar_f32 :: proc(f: f32) -> (q: Quaternionf32) { +@(require_results) +quaternion_from_scalar_f32 :: proc "contextless" (f: f32) -> (q: Quaternionf32) { q.w = f return } -quaternion_from_scalar_f64 :: proc(f: f64) -> (q: Quaternionf64) { +@(require_results) +quaternion_from_scalar_f64 :: proc "contextless" (f: f64) -> (q: Quaternionf64) { q.w = f return } @@ -2505,7 +2672,8 @@ to_quaternion :: proc{ -matrix2_orthonormalize_f16 :: proc(m: Matrix2f16) -> (r: Matrix2f16) { +@(require_results) +matrix2_orthonormalize_f16 :: proc "contextless" (m: Matrix2f16) -> (r: Matrix2f16) { r[0] = normalize(m[0]) d0 := dot(r[0], r[1]) @@ -2514,7 +2682,8 @@ matrix2_orthonormalize_f16 :: proc(m: Matrix2f16) -> (r: Matrix2f16) { return } -matrix2_orthonormalize_f32 :: proc(m: Matrix2f32) -> (r: Matrix2f32) { +@(require_results) +matrix2_orthonormalize_f32 :: proc "contextless" (m: Matrix2f32) -> (r: Matrix2f32) { r[0] = normalize(m[0]) d0 := dot(r[0], r[1]) @@ -2523,7 +2692,8 @@ matrix2_orthonormalize_f32 :: proc(m: Matrix2f32) -> (r: Matrix2f32) { return } -matrix2_orthonormalize_f64 :: proc(m: Matrix2f64) -> (r: Matrix2f64) { +@(require_results) +matrix2_orthonormalize_f64 :: proc "contextless" (m: Matrix2f64) -> (r: Matrix2f64) { r[0] = normalize(m[0]) d0 := dot(r[0], r[1]) @@ -2539,7 +2709,8 @@ matrix2_orthonormalize :: proc{ } -matrix3_orthonormalize_f16 :: proc(m: Matrix3f16) -> (r: Matrix3f16) { +@(require_results) +matrix3_orthonormalize_f16 :: proc "contextless" (m: Matrix3f16) -> (r: Matrix3f16) { r[0] = normalize(m[0]) d0 := dot(r[0], r[1]) @@ -2553,7 +2724,8 @@ matrix3_orthonormalize_f16 :: proc(m: Matrix3f16) -> (r: Matrix3f16) { return } -matrix3_orthonormalize_f32 :: proc(m: Matrix3f32) -> (r: Matrix3f32) { +@(require_results) +matrix3_orthonormalize_f32 :: proc "contextless" (m: Matrix3f32) -> (r: Matrix3f32) { r[0] = normalize(m[0]) d0 := dot(r[0], r[1]) @@ -2567,7 +2739,8 @@ matrix3_orthonormalize_f32 :: proc(m: Matrix3f32) -> (r: Matrix3f32) { return } -matrix3_orthonormalize_f64 :: proc(m: Matrix3f64) -> (r: Matrix3f64) { +@(require_results) +matrix3_orthonormalize_f64 :: proc "contextless" (m: Matrix3f64) -> (r: Matrix3f64) { r[0] = normalize(m[0]) d0 := dot(r[0], r[1]) @@ -2588,13 +2761,16 @@ matrix3_orthonormalize :: proc{ } -vector3_orthonormalize_f16 :: proc(x, y: Vector3f16) -> (z: Vector3f16) { +@(require_results) +vector3_orthonormalize_f16 :: proc "contextless" (x, y: Vector3f16) -> (z: Vector3f16) { return normalize(x - y * dot(y, x)) } -vector3_orthonormalize_f32 :: proc(x, y: Vector3f32) -> (z: Vector3f32) { +@(require_results) +vector3_orthonormalize_f32 :: proc "contextless" (x, y: Vector3f32) -> (z: Vector3f32) { return normalize(x - y * dot(y, x)) } -vector3_orthonormalize_f64 :: proc(x, y: Vector3f64) -> (z: Vector3f64) { +@(require_results) +vector3_orthonormalize_f64 :: proc "contextless" (x, y: Vector3f64) -> (z: Vector3f64) { return normalize(x - y * dot(y, x)) } vector3_orthonormalize :: proc{ @@ -2611,7 +2787,8 @@ orthonormalize :: proc{ } -matrix4_orientation_f16 :: proc(normal, up: Vector3f16) -> Matrix4f16 { +@(require_results) +matrix4_orientation_f16 :: proc "contextless" (normal, up: Vector3f16) -> Matrix4f16 { if all(equal(normal, up)) { return MATRIX4F16_IDENTITY } @@ -2621,7 +2798,8 @@ matrix4_orientation_f16 :: proc(normal, up: Vector3f16) -> Matrix4f16 { return matrix4_rotate(angle, rotation_axis) } -matrix4_orientation_f32 :: proc(normal, up: Vector3f32) -> Matrix4f32 { +@(require_results) +matrix4_orientation_f32 :: proc "contextless" (normal, up: Vector3f32) -> Matrix4f32 { if all(equal(normal, up)) { return MATRIX4F32_IDENTITY } @@ -2631,7 +2809,8 @@ matrix4_orientation_f32 :: proc(normal, up: Vector3f32) -> Matrix4f32 { return matrix4_rotate(angle, rotation_axis) } -matrix4_orientation_f64 :: proc(normal, up: Vector3f64) -> Matrix4f64 { +@(require_results) +matrix4_orientation_f64 :: proc "contextless" (normal, up: Vector3f64) -> Matrix4f64 { if all(equal(normal, up)) { return MATRIX4F64_IDENTITY } @@ -2648,7 +2827,8 @@ matrix4_orientation :: proc{ } -euclidean_from_polar_f16 :: proc(polar: Vector2f16) -> Vector3f16 { +@(require_results) +euclidean_from_polar_f16 :: proc "contextless" (polar: Vector2f16) -> Vector3f16 { latitude, longitude := polar.x, polar.y cx, sx := math.cos(latitude), math.sin(latitude) cy, sy := math.cos(longitude), math.sin(longitude) @@ -2659,7 +2839,8 @@ euclidean_from_polar_f16 :: proc(polar: Vector2f16) -> Vector3f16 { cx*cy, } } -euclidean_from_polar_f32 :: proc(polar: Vector2f32) -> Vector3f32 { +@(require_results) +euclidean_from_polar_f32 :: proc "contextless" (polar: Vector2f32) -> Vector3f32 { latitude, longitude := polar.x, polar.y cx, sx := math.cos(latitude), math.sin(latitude) cy, sy := math.cos(longitude), math.sin(longitude) @@ -2670,7 +2851,8 @@ euclidean_from_polar_f32 :: proc(polar: Vector2f32) -> Vector3f32 { cx*cy, } } -euclidean_from_polar_f64 :: proc(polar: Vector2f64) -> Vector3f64 { +@(require_results) +euclidean_from_polar_f64 :: proc "contextless" (polar: Vector2f64) -> Vector3f64 { latitude, longitude := polar.x, polar.y cx, sx := math.cos(latitude), math.sin(latitude) cy, sy := math.cos(longitude), math.sin(longitude) @@ -2688,7 +2870,8 @@ euclidean_from_polar :: proc{ } -polar_from_euclidean_f16 :: proc(euclidean: Vector3f16) -> Vector3f16 { +@(require_results) +polar_from_euclidean_f16 :: proc "contextless" (euclidean: Vector3f16) -> Vector3f16 { n := length(euclidean) tmp := euclidean / n @@ -2700,7 +2883,8 @@ polar_from_euclidean_f16 :: proc(euclidean: Vector3f16) -> Vector3f16 { xz_dist, } } -polar_from_euclidean_f32 :: proc(euclidean: Vector3f32) -> Vector3f32 { +@(require_results) +polar_from_euclidean_f32 :: proc "contextless" (euclidean: Vector3f32) -> Vector3f32 { n := length(euclidean) tmp := euclidean / n @@ -2712,7 +2896,8 @@ polar_from_euclidean_f32 :: proc(euclidean: Vector3f32) -> Vector3f32 { xz_dist, } } -polar_from_euclidean_f64 :: proc(euclidean: Vector3f64) -> Vector3f64 { +@(require_results) +polar_from_euclidean_f64 :: proc "contextless" (euclidean: Vector3f64) -> Vector3f64 { n := length(euclidean) tmp := euclidean / n diff --git a/core/math/linalg/specific_euler_angles_f16.odin b/core/math/linalg/specific_euler_angles_f16.odin index 9e21c7f97..bacda163e 100644 --- a/core/math/linalg/specific_euler_angles_f16.odin +++ b/core/math/linalg/specific_euler_angles_f16.odin @@ -2,7 +2,8 @@ package linalg import "core:math" -euler_angles_from_matrix3_f16 :: proc(m: Matrix3f16, order: Euler_Angle_Order) -> (t1, t2, t3: f16) { +@(require_results) +euler_angles_from_matrix3_f16 :: proc "contextless" (m: Matrix3f16, order: Euler_Angle_Order) -> (t1, t2, t3: f16) { switch order { case .XYZ: t1, t2, t3 = euler_angles_xyz_from_matrix3(m) case .XZY: t1, t2, t3 = euler_angles_xzy_from_matrix3(m) @@ -19,7 +20,8 @@ euler_angles_from_matrix3_f16 :: proc(m: Matrix3f16, order: Euler_Angle_Order) - } return } -euler_angles_from_matrix4_f16 :: proc(m: Matrix4f16, order: Euler_Angle_Order) -> (t1, t2, t3: f16) { +@(require_results) +euler_angles_from_matrix4_f16 :: proc "contextless" (m: Matrix4f16, order: Euler_Angle_Order) -> (t1, t2, t3: f16) { switch order { case .XYZ: t1, t2, t3 = euler_angles_xyz_from_matrix4(m) case .XZY: t1, t2, t3 = euler_angles_xzy_from_matrix4(m) @@ -36,7 +38,8 @@ euler_angles_from_matrix4_f16 :: proc(m: Matrix4f16, order: Euler_Angle_Order) - } return } -euler_angles_from_quaternion_f16 :: proc(m: Quaternionf16, order: Euler_Angle_Order) -> (t1, t2, t3: f16) { +@(require_results) +euler_angles_from_quaternion_f16 :: proc "contextless" (m: Quaternionf16, order: Euler_Angle_Order) -> (t1, t2, t3: f16) { switch order { case .XYZ: t1, t2, t3 = euler_angles_xyz_from_quaternion(m) case .XZY: t1, t2, t3 = euler_angles_xzy_from_quaternion(m) @@ -54,7 +57,8 @@ euler_angles_from_quaternion_f16 :: proc(m: Quaternionf16, order: Euler_Angle_Or return } -matrix3_from_euler_angles_f16 :: proc(t1, t2, t3: f16, order: Euler_Angle_Order) -> (m: Matrix3f16) { +@(require_results) +matrix3_from_euler_angles_f16 :: proc "contextless" (t1, t2, t3: f16, order: Euler_Angle_Order) -> (m: Matrix3f16) { switch order { case .XYZ: return matrix3_from_euler_angles_xyz(t1, t2, t3) // m1, m2, m3 = X(t1), Y(t2), Z(t3); case .XZY: return matrix3_from_euler_angles_xzy(t1, t2, t3) // m1, m2, m3 = X(t1), Z(t2), Y(t3); @@ -71,7 +75,8 @@ matrix3_from_euler_angles_f16 :: proc(t1, t2, t3: f16, order: Euler_Angle_Order) } return } -matrix4_from_euler_angles_f16 :: proc(t1, t2, t3: f16, order: Euler_Angle_Order) -> (m: Matrix4f16) { +@(require_results) +matrix4_from_euler_angles_f16 :: proc "contextless" (t1, t2, t3: f16, order: Euler_Angle_Order) -> (m: Matrix4f16) { switch order { case .XYZ: return matrix4_from_euler_angles_xyz(t1, t2, t3) // m1, m2, m3 = X(t1), Y(t2), Z(t3); case .XZY: return matrix4_from_euler_angles_xzy(t1, t2, t3) // m1, m2, m3 = X(t1), Z(t2), Y(t3); @@ -89,7 +94,8 @@ matrix4_from_euler_angles_f16 :: proc(t1, t2, t3: f16, order: Euler_Angle_Order) return } -quaternion_from_euler_angles_f16 :: proc(t1, t2, t3: f16, order: Euler_Angle_Order) -> Quaternionf16 { +@(require_results) +quaternion_from_euler_angles_f16 :: proc "contextless" (t1, t2, t3: f16, order: Euler_Angle_Order) -> Quaternionf16 { X :: quaternion_from_euler_angle_x Y :: quaternion_from_euler_angle_y Z :: quaternion_from_euler_angle_z @@ -117,17 +123,21 @@ quaternion_from_euler_angles_f16 :: proc(t1, t2, t3: f16, order: Euler_Angle_Ord // Quaternionf16s -quaternion_from_euler_angle_x_f16 :: proc(angle_x: f16) -> (q: Quaternionf16) { +@(require_results) +quaternion_from_euler_angle_x_f16 :: proc "contextless" (angle_x: f16) -> (q: Quaternionf16) { return quaternion_angle_axis_f16(angle_x, {1, 0, 0}) } -quaternion_from_euler_angle_y_f16 :: proc(angle_y: f16) -> (q: Quaternionf16) { +@(require_results) +quaternion_from_euler_angle_y_f16 :: proc "contextless" (angle_y: f16) -> (q: Quaternionf16) { return quaternion_angle_axis_f16(angle_y, {0, 1, 0}) } -quaternion_from_euler_angle_z_f16 :: proc(angle_z: f16) -> (q: Quaternionf16) { +@(require_results) +quaternion_from_euler_angle_z_f16 :: proc "contextless" (angle_z: f16) -> (q: Quaternionf16) { return quaternion_angle_axis_f16(angle_z, {0, 0, 1}) } -quaternion_from_pitch_yaw_roll_f16 :: proc(pitch, yaw, roll: f16) -> Quaternionf16 { +@(require_results) +quaternion_from_pitch_yaw_roll_f16 :: proc "contextless" (pitch, yaw, roll: f16) -> Quaternionf16 { a, b, c := pitch, yaw, roll ca, sa := math.cos(a*0.5), math.sin(a*0.5) @@ -142,11 +152,13 @@ quaternion_from_pitch_yaw_roll_f16 :: proc(pitch, yaw, roll: f16) -> Quaternionf return q } -roll_from_quaternion_f16 :: proc(q: Quaternionf16) -> f16 { +@(require_results) +roll_from_quaternion_f16 :: proc "contextless" (q: Quaternionf16) -> f16 { return math.atan2(2 * q.x*q.y + q.w*q.z, q.w*q.w + q.x*q.x - q.y*q.y - q.z*q.z) } -pitch_from_quaternion_f16 :: proc(q: Quaternionf16) -> f16 { +@(require_results) +pitch_from_quaternion_f16 :: proc "contextless" (q: Quaternionf16) -> f16 { y := 2 * (q.y*q.z + q.w*q.w) x := q.w*q.w - q.x*q.x - q.y*q.y + q.z*q.z @@ -157,52 +169,66 @@ pitch_from_quaternion_f16 :: proc(q: Quaternionf16) -> f16 { return math.atan2(y, x) } -yaw_from_quaternion_f16 :: proc(q: Quaternionf16) -> f16 { +@(require_results) +yaw_from_quaternion_f16 :: proc "contextless" (q: Quaternionf16) -> f16 { return math.asin(clamp(-2 * (q.x*q.z - q.w*q.y), -1, 1)) } -pitch_yaw_roll_from_quaternion_f16 :: proc(q: Quaternionf16) -> (pitch, yaw, roll: f16) { +@(require_results) +pitch_yaw_roll_from_quaternion_f16 :: proc "contextless" (q: Quaternionf16) -> (pitch, yaw, roll: f16) { pitch = pitch_from_quaternion(q) yaw = yaw_from_quaternion(q) roll = roll_from_quaternion(q) return } -euler_angles_xyz_from_quaternion_f16 :: proc(q: Quaternionf16) -> (t1, t2, t3: f16) { +@(require_results) +euler_angles_xyz_from_quaternion_f16 :: proc "contextless" (q: Quaternionf16) -> (t1, t2, t3: f16) { return euler_angles_xyz_from_matrix4(matrix4_from_quaternion(q)) } -euler_angles_yxz_from_quaternion_f16 :: proc(q: Quaternionf16) -> (t1, t2, t3: f16) { +@(require_results) +euler_angles_yxz_from_quaternion_f16 :: proc "contextless" (q: Quaternionf16) -> (t1, t2, t3: f16) { return euler_angles_yxz_from_matrix4(matrix4_from_quaternion(q)) } -euler_angles_xzx_from_quaternion_f16 :: proc(q: Quaternionf16) -> (t1, t2, t3: f16) { +@(require_results) +euler_angles_xzx_from_quaternion_f16 :: proc "contextless" (q: Quaternionf16) -> (t1, t2, t3: f16) { return euler_angles_xzx_from_matrix4(matrix4_from_quaternion(q)) } -euler_angles_xyx_from_quaternion_f16 :: proc(q: Quaternionf16) -> (t1, t2, t3: f16) { +@(require_results) +euler_angles_xyx_from_quaternion_f16 :: proc "contextless" (q: Quaternionf16) -> (t1, t2, t3: f16) { return euler_angles_xyx_from_matrix4(matrix4_from_quaternion(q)) } -euler_angles_yxy_from_quaternion_f16 :: proc(q: Quaternionf16) -> (t1, t2, t3: f16) { +@(require_results) +euler_angles_yxy_from_quaternion_f16 :: proc "contextless" (q: Quaternionf16) -> (t1, t2, t3: f16) { return euler_angles_yxy_from_matrix4(matrix4_from_quaternion(q)) } -euler_angles_yzy_from_quaternion_f16 :: proc(q: Quaternionf16) -> (t1, t2, t3: f16) { +@(require_results) +euler_angles_yzy_from_quaternion_f16 :: proc "contextless" (q: Quaternionf16) -> (t1, t2, t3: f16) { return euler_angles_yzy_from_matrix4(matrix4_from_quaternion(q)) } -euler_angles_zyz_from_quaternion_f16 :: proc(q: Quaternionf16) -> (t1, t2, t3: f16) { +@(require_results) +euler_angles_zyz_from_quaternion_f16 :: proc "contextless" (q: Quaternionf16) -> (t1, t2, t3: f16) { return euler_angles_zyz_from_matrix4(matrix4_from_quaternion(q)) } -euler_angles_zxz_from_quaternion_f16 :: proc(q: Quaternionf16) -> (t1, t2, t3: f16) { +@(require_results) +euler_angles_zxz_from_quaternion_f16 :: proc "contextless" (q: Quaternionf16) -> (t1, t2, t3: f16) { return euler_angles_zxz_from_matrix4(matrix4_from_quaternion(q)) } -euler_angles_xzy_from_quaternion_f16 :: proc(q: Quaternionf16) -> (t1, t2, t3: f16) { +@(require_results) +euler_angles_xzy_from_quaternion_f16 :: proc "contextless" (q: Quaternionf16) -> (t1, t2, t3: f16) { return euler_angles_xzy_from_matrix4(matrix4_from_quaternion(q)) } -euler_angles_yzx_from_quaternion_f16 :: proc(q: Quaternionf16) -> (t1, t2, t3: f16) { +@(require_results) +euler_angles_yzx_from_quaternion_f16 :: proc "contextless" (q: Quaternionf16) -> (t1, t2, t3: f16) { return euler_angles_yzx_from_matrix4(matrix4_from_quaternion(q)) } -euler_angles_zyx_from_quaternion_f16 :: proc(q: Quaternionf16) -> (t1, t2, t3: f16) { +@(require_results) +euler_angles_zyx_from_quaternion_f16 :: proc "contextless" (q: Quaternionf16) -> (t1, t2, t3: f16) { return euler_angles_zyx_from_matrix4(matrix4_from_quaternion(q)) } -euler_angles_zxy_from_quaternion_f16 :: proc(q: Quaternionf16) -> (t1, t2, t3: f16) { +@(require_results) +euler_angles_zxy_from_quaternion_f16 :: proc "contextless" (q: Quaternionf16) -> (t1, t2, t3: f16) { return euler_angles_zxy_from_matrix4(matrix4_from_quaternion(q)) } @@ -210,7 +236,8 @@ euler_angles_zxy_from_quaternion_f16 :: proc(q: Quaternionf16) -> (t1, t2, t3: f // Matrix3 -matrix3_from_euler_angle_x_f16 :: proc(angle_x: f16) -> (m: Matrix3f16) { +@(require_results) +matrix3_from_euler_angle_x_f16 :: proc "contextless" (angle_x: f16) -> (m: Matrix3f16) { cos_x, sin_x := math.cos(angle_x), math.sin(angle_x) m[0, 0] = 1 m[1, 1] = +cos_x @@ -219,7 +246,8 @@ matrix3_from_euler_angle_x_f16 :: proc(angle_x: f16) -> (m: Matrix3f16) { m[2, 2] = +cos_x return } -matrix3_from_euler_angle_y_f16 :: proc(angle_y: f16) -> (m: Matrix3f16) { +@(require_results) +matrix3_from_euler_angle_y_f16 :: proc "contextless" (angle_y: f16) -> (m: Matrix3f16) { cos_y, sin_y := math.cos(angle_y), math.sin(angle_y) m[0, 0] = +cos_y m[0, 2] = -sin_y @@ -228,7 +256,8 @@ matrix3_from_euler_angle_y_f16 :: proc(angle_y: f16) -> (m: Matrix3f16) { m[2, 2] = +cos_y return } -matrix3_from_euler_angle_z_f16 :: proc(angle_z: f16) -> (m: Matrix3f16) { +@(require_results) +matrix3_from_euler_angle_z_f16 :: proc "contextless" (angle_z: f16) -> (m: Matrix3f16) { cos_z, sin_z := math.cos(angle_z), math.sin(angle_z) m[0, 0] = +cos_z m[0, 1] = +sin_z @@ -239,7 +268,8 @@ matrix3_from_euler_angle_z_f16 :: proc(angle_z: f16) -> (m: Matrix3f16) { } -matrix3_from_derived_euler_angle_x_f16 :: proc(angle_x: f16, angular_velocity_x: f16) -> (m: Matrix3f16) { +@(require_results) +matrix3_from_derived_euler_angle_x_f16 :: proc "contextless" (angle_x: f16, angular_velocity_x: f16) -> (m: Matrix3f16) { cos_x := math.cos(angle_x) * angular_velocity_x sin_x := math.sin(angle_x) * angular_velocity_x m[0, 0] = 1 @@ -249,7 +279,8 @@ matrix3_from_derived_euler_angle_x_f16 :: proc(angle_x: f16, angular_velocity_x: m[2, 2] = +cos_x return } -matrix3_from_derived_euler_angle_y_f16 :: proc(angle_y: f16, angular_velocity_y: f16) -> (m: Matrix3f16) { +@(require_results) +matrix3_from_derived_euler_angle_y_f16 :: proc "contextless" (angle_y: f16, angular_velocity_y: f16) -> (m: Matrix3f16) { cos_y := math.cos(angle_y) * angular_velocity_y sin_y := math.sin(angle_y) * angular_velocity_y m[0, 0] = +cos_y @@ -259,7 +290,8 @@ matrix3_from_derived_euler_angle_y_f16 :: proc(angle_y: f16, angular_velocity_y: m[2, 2] = +cos_y return } -matrix3_from_derived_euler_angle_z_f16 :: proc(angle_z: f16, angular_velocity_z: f16) -> (m: Matrix3f16) { +@(require_results) +matrix3_from_derived_euler_angle_z_f16 :: proc "contextless" (angle_z: f16, angular_velocity_z: f16) -> (m: Matrix3f16) { cos_z := math.cos(angle_z) * angular_velocity_z sin_z := math.sin(angle_z) * angular_velocity_z m[0, 0] = +cos_z @@ -271,7 +303,8 @@ matrix3_from_derived_euler_angle_z_f16 :: proc(angle_z: f16, angular_velocity_z: } -matrix3_from_euler_angles_xy_f16 :: proc(angle_x, angle_y: f16) -> (m: Matrix3f16) { +@(require_results) +matrix3_from_euler_angles_xy_f16 :: proc "contextless" (angle_x, angle_y: f16) -> (m: Matrix3f16) { cos_x, sin_x := math.cos(angle_x), math.sin(angle_x) cos_y, sin_y := math.cos(angle_y), math.sin(angle_y) m[0, 0] = cos_y @@ -286,7 +319,8 @@ matrix3_from_euler_angles_xy_f16 :: proc(angle_x, angle_y: f16) -> (m: Matrix3f1 } -matrix3_from_euler_angles_yx_f16 :: proc(angle_y, angle_x: f16) -> (m: Matrix3f16) { +@(require_results) +matrix3_from_euler_angles_yx_f16 :: proc "contextless" (angle_y, angle_x: f16) -> (m: Matrix3f16) { cos_x, sin_x := math.cos(angle_x), math.sin(angle_x) cos_y, sin_y := math.cos(angle_y), math.sin(angle_y) m[0, 0] = cos_y @@ -300,21 +334,26 @@ matrix3_from_euler_angles_yx_f16 :: proc(angle_y, angle_x: f16) -> (m: Matrix3f1 return } -matrix3_from_euler_angles_xz_f16 :: proc(angle_x, angle_z: f16) -> (m: Matrix3f16) { +@(require_results) +matrix3_from_euler_angles_xz_f16 :: proc "contextless" (angle_x, angle_z: f16) -> (m: Matrix3f16) { return mul(matrix3_from_euler_angle_x(angle_x), matrix3_from_euler_angle_z(angle_z)) } -matrix3_from_euler_angles_zx_f16 :: proc(angle_z, angle_x: f16) -> (m: Matrix3f16) { +@(require_results) +matrix3_from_euler_angles_zx_f16 :: proc "contextless" (angle_z, angle_x: f16) -> (m: Matrix3f16) { return mul(matrix3_from_euler_angle_z(angle_z), matrix3_from_euler_angle_x(angle_x)) } -matrix3_from_euler_angles_yz_f16 :: proc(angle_y, angle_z: f16) -> (m: Matrix3f16) { +@(require_results) +matrix3_from_euler_angles_yz_f16 :: proc "contextless" (angle_y, angle_z: f16) -> (m: Matrix3f16) { return mul(matrix3_from_euler_angle_y(angle_y), matrix3_from_euler_angle_z(angle_z)) } -matrix3_from_euler_angles_zy_f16 :: proc(angle_z, angle_y: f16) -> (m: Matrix3f16) { +@(require_results) +matrix3_from_euler_angles_zy_f16 :: proc "contextless" (angle_z, angle_y: f16) -> (m: Matrix3f16) { return mul(matrix3_from_euler_angle_z(angle_z), matrix3_from_euler_angle_y(angle_y)) } -matrix3_from_euler_angles_xyz_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix3f16) { +@(require_results) +matrix3_from_euler_angles_xyz_f16 :: proc "contextless" (t1, t2, t3: f16) -> (m: Matrix3f16) { c1 := math.cos(-t1) c2 := math.cos(-t2) c3 := math.cos(-t3) @@ -334,7 +373,8 @@ matrix3_from_euler_angles_xyz_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix3f16) { return } -matrix3_from_euler_angles_yxz_f16 :: proc(yaw, pitch, roll: f16) -> (m: Matrix3f16) { +@(require_results) +matrix3_from_euler_angles_yxz_f16 :: proc "contextless" (yaw, pitch, roll: f16) -> (m: Matrix3f16) { ch := math.cos(yaw) sh := math.sin(yaw) cp := math.cos(pitch) @@ -354,7 +394,8 @@ matrix3_from_euler_angles_yxz_f16 :: proc(yaw, pitch, roll: f16) -> (m: Matrix3f return } -matrix3_from_euler_angles_xzx_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix3f16) { +@(require_results) +matrix3_from_euler_angles_xzx_f16 :: proc "contextless" (t1, t2, t3: f16) -> (m: Matrix3f16) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -374,7 +415,8 @@ matrix3_from_euler_angles_xzx_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix3f16) { return } -matrix3_from_euler_angles_xyx_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix3f16) { +@(require_results) +matrix3_from_euler_angles_xyx_f16 :: proc "contextless" (t1, t2, t3: f16) -> (m: Matrix3f16) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -394,7 +436,8 @@ matrix3_from_euler_angles_xyx_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix3f16) { return } -matrix3_from_euler_angles_yxy_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix3f16) { +@(require_results) +matrix3_from_euler_angles_yxy_f16 :: proc "contextless" (t1, t2, t3: f16) -> (m: Matrix3f16) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -414,7 +457,8 @@ matrix3_from_euler_angles_yxy_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix3f16) { return } -matrix3_from_euler_angles_yzy_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix3f16) { +@(require_results) +matrix3_from_euler_angles_yzy_f16 :: proc "contextless" (t1, t2, t3: f16) -> (m: Matrix3f16) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -434,7 +478,8 @@ matrix3_from_euler_angles_yzy_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix3f16) { return } -matrix3_from_euler_angles_zyz_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix3f16) { +@(require_results) +matrix3_from_euler_angles_zyz_f16 :: proc "contextless" (t1, t2, t3: f16) -> (m: Matrix3f16) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -454,7 +499,8 @@ matrix3_from_euler_angles_zyz_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix3f16) { return } -matrix3_from_euler_angles_zxz_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix3f16) { +@(require_results) +matrix3_from_euler_angles_zxz_f16 :: proc "contextless" (t1, t2, t3: f16) -> (m: Matrix3f16) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -475,7 +521,8 @@ matrix3_from_euler_angles_zxz_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix3f16) { } -matrix3_from_euler_angles_xzy_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix3f16) { +@(require_results) +matrix3_from_euler_angles_xzy_f16 :: proc "contextless" (t1, t2, t3: f16) -> (m: Matrix3f16) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -495,7 +542,8 @@ matrix3_from_euler_angles_xzy_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix3f16) { return } -matrix3_from_euler_angles_yzx_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix3f16) { +@(require_results) +matrix3_from_euler_angles_yzx_f16 :: proc "contextless" (t1, t2, t3: f16) -> (m: Matrix3f16) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -515,7 +563,8 @@ matrix3_from_euler_angles_yzx_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix3f16) { return } -matrix3_from_euler_angles_zyx_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix3f16) { +@(require_results) +matrix3_from_euler_angles_zyx_f16 :: proc "contextless" (t1, t2, t3: f16) -> (m: Matrix3f16) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -535,7 +584,8 @@ matrix3_from_euler_angles_zyx_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix3f16) { return } -matrix3_from_euler_angles_zxy_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix3f16) { +@(require_results) +matrix3_from_euler_angles_zxy_f16 :: proc "contextless" (t1, t2, t3: f16) -> (m: Matrix3f16) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -556,7 +606,8 @@ matrix3_from_euler_angles_zxy_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix3f16) { } -matrix3_from_yaw_pitch_roll_f16 :: proc(yaw, pitch, roll: f16) -> (m: Matrix3f16) { +@(require_results) +matrix3_from_yaw_pitch_roll_f16 :: proc "contextless" (yaw, pitch, roll: f16) -> (m: Matrix3f16) { ch := math.cos(yaw) sh := math.sin(yaw) cp := math.cos(pitch) @@ -576,7 +627,8 @@ matrix3_from_yaw_pitch_roll_f16 :: proc(yaw, pitch, roll: f16) -> (m: Matrix3f16 return m } -euler_angles_xyz_from_matrix3_f16 :: proc(m: Matrix3f16) -> (t1, t2, t3: f16) { +@(require_results) +euler_angles_xyz_from_matrix3_f16 :: proc "contextless" (m: Matrix3f16) -> (t1, t2, t3: f16) { T1 := math.atan2(m[1, 2], m[2, 2]) C2 := math.sqrt(m[0, 0]*m[0, 0] + m[0, 1]*m[0, 1]) T2 := math.atan2(-m[0, 2], C2) @@ -589,7 +641,8 @@ euler_angles_xyz_from_matrix3_f16 :: proc(m: Matrix3f16) -> (t1, t2, t3: f16) { return } -euler_angles_yxz_from_matrix3_f16 :: proc(m: Matrix3f16) -> (t1, t2, t3: f16) { +@(require_results) +euler_angles_yxz_from_matrix3_f16 :: proc "contextless" (m: Matrix3f16) -> (t1, t2, t3: f16) { T1 := math.atan2(m[0, 2], m[2, 2]) C2 := math.sqrt(m[1, 0]*m[1, 0] + m[1, 1]*m[1, 1]) T2 := math.atan2(-m[1, 2], C2) @@ -602,7 +655,8 @@ euler_angles_yxz_from_matrix3_f16 :: proc(m: Matrix3f16) -> (t1, t2, t3: f16) { return } -euler_angles_xzx_from_matrix3_f16 :: proc(m: Matrix3f16) -> (t1, t2, t3: f16) { +@(require_results) +euler_angles_xzx_from_matrix3_f16 :: proc "contextless" (m: Matrix3f16) -> (t1, t2, t3: f16) { T1 := math.atan2(m[2, 0], m[1, 0]) S2 := math.sqrt(m[0, 1]*m[0, 1] + m[0, 2]*m[0, 2]) T2 := math.atan2(S2, m[0, 0]) @@ -615,7 +669,8 @@ euler_angles_xzx_from_matrix3_f16 :: proc(m: Matrix3f16) -> (t1, t2, t3: f16) { return } -euler_angles_xyx_from_matrix3_f16 :: proc(m: Matrix3f16) -> (t1, t2, t3: f16) { +@(require_results) +euler_angles_xyx_from_matrix3_f16 :: proc "contextless" (m: Matrix3f16) -> (t1, t2, t3: f16) { T1 := math.atan2(m[1, 0], -m[2, 0]) S2 := math.sqrt(m[0, 1]*m[0, 1] + m[0, 2]*m[0, 2]) T2 := math.atan2(S2, m[0, 0]) @@ -628,7 +683,8 @@ euler_angles_xyx_from_matrix3_f16 :: proc(m: Matrix3f16) -> (t1, t2, t3: f16) { return } -euler_angles_yxy_from_matrix3_f16 :: proc(m: Matrix3f16) -> (t1, t2, t3: f16) { +@(require_results) +euler_angles_yxy_from_matrix3_f16 :: proc "contextless" (m: Matrix3f16) -> (t1, t2, t3: f16) { T1 := math.atan2(m[0, 1], m[2, 1]) S2 := math.sqrt(m[1, 0]*m[1, 0] + m[1, 2]*m[1, 2]) T2 := math.atan2(S2, m[1, 1]) @@ -641,7 +697,8 @@ euler_angles_yxy_from_matrix3_f16 :: proc(m: Matrix3f16) -> (t1, t2, t3: f16) { return } -euler_angles_yzy_from_matrix3_f16 :: proc(m: Matrix3f16) -> (t1, t2, t3: f16) { +@(require_results) +euler_angles_yzy_from_matrix3_f16 :: proc "contextless" (m: Matrix3f16) -> (t1, t2, t3: f16) { T1 := math.atan2(m[2, 1], -m[0, 1]) S2 := math.sqrt(m[1, 0]*m[1, 0] + m[1, 2]*m[1, 2]) T2 := math.atan2(S2, m[1, 1]) @@ -653,7 +710,8 @@ euler_angles_yzy_from_matrix3_f16 :: proc(m: Matrix3f16) -> (t1, t2, t3: f16) { t3 = T3 return } -euler_angles_zyz_from_matrix3_f16 :: proc(m: Matrix3f16) -> (t1, t2, t3: f16) { +@(require_results) +euler_angles_zyz_from_matrix3_f16 :: proc "contextless" (m: Matrix3f16) -> (t1, t2, t3: f16) { T1 := math.atan2(m[1, 2], m[0, 2]) S2 := math.sqrt(m[2, 0]*m[2, 0] + m[2, 1]*m[2, 1]) T2 := math.atan2(S2, m[2, 2]) @@ -666,7 +724,8 @@ euler_angles_zyz_from_matrix3_f16 :: proc(m: Matrix3f16) -> (t1, t2, t3: f16) { return } -euler_angles_zxz_from_matrix3_f16 :: proc(m: Matrix3f16) -> (t1, t2, t3: f16) { +@(require_results) +euler_angles_zxz_from_matrix3_f16 :: proc "contextless" (m: Matrix3f16) -> (t1, t2, t3: f16) { T1 := math.atan2(m[0, 2], -m[1, 2]) S2 := math.sqrt(m[2, 0]*m[2, 0] + m[2, 1]*m[2, 1]) T2 := math.atan2(S2, m[2, 2]) @@ -679,7 +738,8 @@ euler_angles_zxz_from_matrix3_f16 :: proc(m: Matrix3f16) -> (t1, t2, t3: f16) { return } -euler_angles_xzy_from_matrix3_f16 :: proc(m: Matrix3f16) -> (t1, t2, t3: f16) { +@(require_results) +euler_angles_xzy_from_matrix3_f16 :: proc "contextless" (m: Matrix3f16) -> (t1, t2, t3: f16) { T1 := math.atan2(m[2, 1], m[1, 1]) C2 := math.sqrt(m[0, 0]*m[0, 0] + m[0, 2]*m[0, 2]) T2 := math.atan2(-m[0, 1], C2) @@ -692,7 +752,8 @@ euler_angles_xzy_from_matrix3_f16 :: proc(m: Matrix3f16) -> (t1, t2, t3: f16) { return } -euler_angles_yzx_from_matrix3_f16 :: proc(m: Matrix3f16) -> (t1, t2, t3: f16) { +@(require_results) +euler_angles_yzx_from_matrix3_f16 :: proc "contextless" (m: Matrix3f16) -> (t1, t2, t3: f16) { T1 := math.atan2(-m[2, 0], m[0, 0]) C2 := math.sqrt(m[1, 1]*m[1, 1] + m[1, 2]*m[1, 2]) T2 := math.atan2(m[1, 0], C2) @@ -705,7 +766,8 @@ euler_angles_yzx_from_matrix3_f16 :: proc(m: Matrix3f16) -> (t1, t2, t3: f16) { return } -euler_angles_zyx_from_matrix3_f16 :: proc(m: Matrix3f16) -> (t1, t2, t3: f16) { +@(require_results) +euler_angles_zyx_from_matrix3_f16 :: proc "contextless" (m: Matrix3f16) -> (t1, t2, t3: f16) { T1 := math.atan2(m[1, 0], m[0, 0]) C2 := math.sqrt(m[2, 1]*m[2, 1] + m[2, 2]*m[2, 2]) T2 := math.atan2(-m[2, 0], C2) @@ -718,7 +780,8 @@ euler_angles_zyx_from_matrix3_f16 :: proc(m: Matrix3f16) -> (t1, t2, t3: f16) { return } -euler_angles_zxy_from_matrix3_f16 :: proc(m: Matrix3f16) -> (t1, t2, t3: f16) { +@(require_results) +euler_angles_zxy_from_matrix3_f16 :: proc "contextless" (m: Matrix3f16) -> (t1, t2, t3: f16) { T1 := math.atan2(-m[0, 1], m[1, 1]) C2 := math.sqrt(m[2, 0]*m[2, 0] + m[2, 2]*m[2, 2]) T2 := math.atan2(m[2, 1], C2) @@ -735,7 +798,8 @@ euler_angles_zxy_from_matrix3_f16 :: proc(m: Matrix3f16) -> (t1, t2, t3: f16) { // Matrix4 -matrix4_from_euler_angle_x_f16 :: proc(angle_x: f16) -> (m: Matrix4f16) { +@(require_results) +matrix4_from_euler_angle_x_f16 :: proc "contextless" (angle_x: f16) -> (m: Matrix4f16) { cos_x, sin_x := math.cos(angle_x), math.sin(angle_x) m[0, 0] = 1 m[1, 1] = +cos_x @@ -745,7 +809,8 @@ matrix4_from_euler_angle_x_f16 :: proc(angle_x: f16) -> (m: Matrix4f16) { m[3, 3] = 1 return } -matrix4_from_euler_angle_y_f16 :: proc(angle_y: f16) -> (m: Matrix4f16) { +@(require_results) +matrix4_from_euler_angle_y_f16 :: proc "contextless" (angle_y: f16) -> (m: Matrix4f16) { cos_y, sin_y := math.cos(angle_y), math.sin(angle_y) m[0, 0] = +cos_y m[0, 2] = -sin_y @@ -755,7 +820,8 @@ matrix4_from_euler_angle_y_f16 :: proc(angle_y: f16) -> (m: Matrix4f16) { m[3, 3] = 1 return } -matrix4_from_euler_angle_z_f16 :: proc(angle_z: f16) -> (m: Matrix4f16) { +@(require_results) +matrix4_from_euler_angle_z_f16 :: proc "contextless" (angle_z: f16) -> (m: Matrix4f16) { cos_z, sin_z := math.cos(angle_z), math.sin(angle_z) m[0, 0] = +cos_z m[0, 1] = +sin_z @@ -767,7 +833,8 @@ matrix4_from_euler_angle_z_f16 :: proc(angle_z: f16) -> (m: Matrix4f16) { } -matrix4_from_derived_euler_angle_x_f16 :: proc(angle_x: f16, angular_velocity_x: f16) -> (m: Matrix4f16) { +@(require_results) +matrix4_from_derived_euler_angle_x_f16 :: proc "contextless" (angle_x: f16, angular_velocity_x: f16) -> (m: Matrix4f16) { cos_x := math.cos(angle_x) * angular_velocity_x sin_x := math.sin(angle_x) * angular_velocity_x m[0, 0] = 1 @@ -778,7 +845,8 @@ matrix4_from_derived_euler_angle_x_f16 :: proc(angle_x: f16, angular_velocity_x: m[3, 3] = 1 return } -matrix4_from_derived_euler_angle_y_f16 :: proc(angle_y: f16, angular_velocity_y: f16) -> (m: Matrix4f16) { +@(require_results) +matrix4_from_derived_euler_angle_y_f16 :: proc "contextless" (angle_y: f16, angular_velocity_y: f16) -> (m: Matrix4f16) { cos_y := math.cos(angle_y) * angular_velocity_y sin_y := math.sin(angle_y) * angular_velocity_y m[0, 0] = +cos_y @@ -789,7 +857,8 @@ matrix4_from_derived_euler_angle_y_f16 :: proc(angle_y: f16, angular_velocity_y: m[3, 3] = 1 return } -matrix4_from_derived_euler_angle_z_f16 :: proc(angle_z: f16, angular_velocity_z: f16) -> (m: Matrix4f16) { +@(require_results) +matrix4_from_derived_euler_angle_z_f16 :: proc "contextless" (angle_z: f16, angular_velocity_z: f16) -> (m: Matrix4f16) { cos_z := math.cos(angle_z) * angular_velocity_z sin_z := math.sin(angle_z) * angular_velocity_z m[0, 0] = +cos_z @@ -802,7 +871,8 @@ matrix4_from_derived_euler_angle_z_f16 :: proc(angle_z: f16, angular_velocity_z: } -matrix4_from_euler_angles_xy_f16 :: proc(angle_x, angle_y: f16) -> (m: Matrix4f16) { +@(require_results) +matrix4_from_euler_angles_xy_f16 :: proc "contextless" (angle_x, angle_y: f16) -> (m: Matrix4f16) { cos_x, sin_x := math.cos(angle_x), math.sin(angle_x) cos_y, sin_y := math.cos(angle_y), math.sin(angle_y) m[0, 0] = cos_y @@ -818,7 +888,8 @@ matrix4_from_euler_angles_xy_f16 :: proc(angle_x, angle_y: f16) -> (m: Matrix4f1 } -matrix4_from_euler_angles_yx_f16 :: proc(angle_y, angle_x: f16) -> (m: Matrix4f16) { +@(require_results) +matrix4_from_euler_angles_yx_f16 :: proc "contextless" (angle_y, angle_x: f16) -> (m: Matrix4f16) { cos_x, sin_x := math.cos(angle_x), math.sin(angle_x) cos_y, sin_y := math.cos(angle_y), math.sin(angle_y) m[0, 0] = cos_y @@ -833,21 +904,26 @@ matrix4_from_euler_angles_yx_f16 :: proc(angle_y, angle_x: f16) -> (m: Matrix4f1 return } -matrix4_from_euler_angles_xz_f16 :: proc(angle_x, angle_z: f16) -> (m: Matrix4f16) { +@(require_results) +matrix4_from_euler_angles_xz_f16 :: proc "contextless" (angle_x, angle_z: f16) -> (m: Matrix4f16) { return mul(matrix4_from_euler_angle_x(angle_x), matrix4_from_euler_angle_z(angle_z)) } -matrix4_from_euler_angles_zx_f16 :: proc(angle_z, angle_x: f16) -> (m: Matrix4f16) { +@(require_results) +matrix4_from_euler_angles_zx_f16 :: proc "contextless" (angle_z, angle_x: f16) -> (m: Matrix4f16) { return mul(matrix4_from_euler_angle_z(angle_z), matrix4_from_euler_angle_x(angle_x)) } -matrix4_from_euler_angles_yz_f16 :: proc(angle_y, angle_z: f16) -> (m: Matrix4f16) { +@(require_results) +matrix4_from_euler_angles_yz_f16 :: proc "contextless" (angle_y, angle_z: f16) -> (m: Matrix4f16) { return mul(matrix4_from_euler_angle_y(angle_y), matrix4_from_euler_angle_z(angle_z)) } -matrix4_from_euler_angles_zy_f16 :: proc(angle_z, angle_y: f16) -> (m: Matrix4f16) { +@(require_results) +matrix4_from_euler_angles_zy_f16 :: proc "contextless" (angle_z, angle_y: f16) -> (m: Matrix4f16) { return mul(matrix4_from_euler_angle_z(angle_z), matrix4_from_euler_angle_y(angle_y)) } -matrix4_from_euler_angles_xyz_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix4f16) { +@(require_results) +matrix4_from_euler_angles_xyz_f16 :: proc "contextless" (t1, t2, t3: f16) -> (m: Matrix4f16) { c1 := math.cos(-t1) c2 := math.cos(-t2) c3 := math.cos(-t3) @@ -874,7 +950,8 @@ matrix4_from_euler_angles_xyz_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix4f16) { return } -matrix4_from_euler_angles_yxz_f16 :: proc(yaw, pitch, roll: f16) -> (m: Matrix4f16) { +@(require_results) +matrix4_from_euler_angles_yxz_f16 :: proc "contextless" (yaw, pitch, roll: f16) -> (m: Matrix4f16) { ch := math.cos(yaw) sh := math.sin(yaw) cp := math.cos(pitch) @@ -901,7 +978,8 @@ matrix4_from_euler_angles_yxz_f16 :: proc(yaw, pitch, roll: f16) -> (m: Matrix4f return } -matrix4_from_euler_angles_xzx_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix4f16) { +@(require_results) +matrix4_from_euler_angles_xzx_f16 :: proc "contextless" (t1, t2, t3: f16) -> (m: Matrix4f16) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -928,7 +1006,8 @@ matrix4_from_euler_angles_xzx_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix4f16) { return } -matrix4_from_euler_angles_xyx_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix4f16) { +@(require_results) +matrix4_from_euler_angles_xyx_f16 :: proc "contextless" (t1, t2, t3: f16) -> (m: Matrix4f16) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -955,7 +1034,8 @@ matrix4_from_euler_angles_xyx_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix4f16) { return } -matrix4_from_euler_angles_yxy_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix4f16) { +@(require_results) +matrix4_from_euler_angles_yxy_f16 :: proc "contextless" (t1, t2, t3: f16) -> (m: Matrix4f16) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -982,7 +1062,8 @@ matrix4_from_euler_angles_yxy_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix4f16) { return } -matrix4_from_euler_angles_yzy_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix4f16) { +@(require_results) +matrix4_from_euler_angles_yzy_f16 :: proc "contextless" (t1, t2, t3: f16) -> (m: Matrix4f16) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -1009,7 +1090,8 @@ matrix4_from_euler_angles_yzy_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix4f16) { return } -matrix4_from_euler_angles_zyz_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix4f16) { +@(require_results) +matrix4_from_euler_angles_zyz_f16 :: proc "contextless" (t1, t2, t3: f16) -> (m: Matrix4f16) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -1036,7 +1118,8 @@ matrix4_from_euler_angles_zyz_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix4f16) { return } -matrix4_from_euler_angles_zxz_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix4f16) { +@(require_results) +matrix4_from_euler_angles_zxz_f16 :: proc "contextless" (t1, t2, t3: f16) -> (m: Matrix4f16) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -1064,7 +1147,8 @@ matrix4_from_euler_angles_zxz_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix4f16) { } -matrix4_from_euler_angles_xzy_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix4f16) { +@(require_results) +matrix4_from_euler_angles_xzy_f16 :: proc "contextless" (t1, t2, t3: f16) -> (m: Matrix4f16) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -1091,7 +1175,8 @@ matrix4_from_euler_angles_xzy_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix4f16) { return } -matrix4_from_euler_angles_yzx_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix4f16) { +@(require_results) +matrix4_from_euler_angles_yzx_f16 :: proc "contextless" (t1, t2, t3: f16) -> (m: Matrix4f16) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -1118,7 +1203,8 @@ matrix4_from_euler_angles_yzx_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix4f16) { return } -matrix4_from_euler_angles_zyx_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix4f16) { +@(require_results) +matrix4_from_euler_angles_zyx_f16 :: proc "contextless" (t1, t2, t3: f16) -> (m: Matrix4f16) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -1145,7 +1231,8 @@ matrix4_from_euler_angles_zyx_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix4f16) { return } -matrix4_from_euler_angles_zxy_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix4f16) { +@(require_results) +matrix4_from_euler_angles_zxy_f16 :: proc "contextless" (t1, t2, t3: f16) -> (m: Matrix4f16) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -1173,7 +1260,8 @@ matrix4_from_euler_angles_zxy_f16 :: proc(t1, t2, t3: f16) -> (m: Matrix4f16) { } -matrix4_from_yaw_pitch_roll_f16 :: proc(yaw, pitch, roll: f16) -> (m: Matrix4f16) { +@(require_results) +matrix4_from_yaw_pitch_roll_f16 :: proc "contextless" (yaw, pitch, roll: f16) -> (m: Matrix4f16) { ch := math.cos(yaw) sh := math.sin(yaw) cp := math.cos(pitch) @@ -1200,7 +1288,8 @@ matrix4_from_yaw_pitch_roll_f16 :: proc(yaw, pitch, roll: f16) -> (m: Matrix4f16 return m } -euler_angles_xyz_from_matrix4_f16 :: proc(m: Matrix4f16) -> (t1, t2, t3: f16) { +@(require_results) +euler_angles_xyz_from_matrix4_f16 :: proc "contextless" (m: Matrix4f16) -> (t1, t2, t3: f16) { T1 := math.atan2(m[1, 2], m[2, 2]) C2 := math.sqrt(m[0, 0]*m[0, 0] + m[0, 1]*m[0, 1]) T2 := math.atan2(-m[0, 2], C2) @@ -1213,7 +1302,8 @@ euler_angles_xyz_from_matrix4_f16 :: proc(m: Matrix4f16) -> (t1, t2, t3: f16) { return } -euler_angles_yxz_from_matrix4_f16 :: proc(m: Matrix4f16) -> (t1, t2, t3: f16) { +@(require_results) +euler_angles_yxz_from_matrix4_f16 :: proc "contextless" (m: Matrix4f16) -> (t1, t2, t3: f16) { T1 := math.atan2(m[0, 2], m[2, 2]) C2 := math.sqrt(m[1, 0]*m[1, 0] + m[1, 1]*m[1, 1]) T2 := math.atan2(-m[1, 2], C2) @@ -1226,7 +1316,8 @@ euler_angles_yxz_from_matrix4_f16 :: proc(m: Matrix4f16) -> (t1, t2, t3: f16) { return } -euler_angles_xzx_from_matrix4_f16 :: proc(m: Matrix4f16) -> (t1, t2, t3: f16) { +@(require_results) +euler_angles_xzx_from_matrix4_f16 :: proc "contextless" (m: Matrix4f16) -> (t1, t2, t3: f16) { T1 := math.atan2(m[2, 0], m[1, 0]) S2 := math.sqrt(m[0, 1]*m[0, 1] + m[0, 2]*m[0, 2]) T2 := math.atan2(S2, m[0, 0]) @@ -1239,7 +1330,8 @@ euler_angles_xzx_from_matrix4_f16 :: proc(m: Matrix4f16) -> (t1, t2, t3: f16) { return } -euler_angles_xyx_from_matrix4_f16 :: proc(m: Matrix4f16) -> (t1, t2, t3: f16) { +@(require_results) +euler_angles_xyx_from_matrix4_f16 :: proc "contextless" (m: Matrix4f16) -> (t1, t2, t3: f16) { T1 := math.atan2(m[1, 0], -m[2, 0]) S2 := math.sqrt(m[0, 1]*m[0, 1] + m[0, 2]*m[0, 2]) T2 := math.atan2(S2, m[0, 0]) @@ -1252,7 +1344,8 @@ euler_angles_xyx_from_matrix4_f16 :: proc(m: Matrix4f16) -> (t1, t2, t3: f16) { return } -euler_angles_yxy_from_matrix4_f16 :: proc(m: Matrix4f16) -> (t1, t2, t3: f16) { +@(require_results) +euler_angles_yxy_from_matrix4_f16 :: proc "contextless" (m: Matrix4f16) -> (t1, t2, t3: f16) { T1 := math.atan2(m[0, 1], m[2, 1]) S2 := math.sqrt(m[1, 0]*m[1, 0] + m[1, 2]*m[1, 2]) T2 := math.atan2(S2, m[1, 1]) @@ -1265,7 +1358,8 @@ euler_angles_yxy_from_matrix4_f16 :: proc(m: Matrix4f16) -> (t1, t2, t3: f16) { return } -euler_angles_yzy_from_matrix4_f16 :: proc(m: Matrix4f16) -> (t1, t2, t3: f16) { +@(require_results) +euler_angles_yzy_from_matrix4_f16 :: proc "contextless" (m: Matrix4f16) -> (t1, t2, t3: f16) { T1 := math.atan2(m[2, 1], -m[0, 1]) S2 := math.sqrt(m[1, 0]*m[1, 0] + m[1, 2]*m[1, 2]) T2 := math.atan2(S2, m[1, 1]) @@ -1277,7 +1371,8 @@ euler_angles_yzy_from_matrix4_f16 :: proc(m: Matrix4f16) -> (t1, t2, t3: f16) { t3 = T3 return } -euler_angles_zyz_from_matrix4_f16 :: proc(m: Matrix4f16) -> (t1, t2, t3: f16) { +@(require_results) +euler_angles_zyz_from_matrix4_f16 :: proc "contextless" (m: Matrix4f16) -> (t1, t2, t3: f16) { T1 := math.atan2(m[1, 2], m[0, 2]) S2 := math.sqrt(m[2, 0]*m[2, 0] + m[2, 1]*m[2, 1]) T2 := math.atan2(S2, m[2, 2]) @@ -1290,7 +1385,8 @@ euler_angles_zyz_from_matrix4_f16 :: proc(m: Matrix4f16) -> (t1, t2, t3: f16) { return } -euler_angles_zxz_from_matrix4_f16 :: proc(m: Matrix4f16) -> (t1, t2, t3: f16) { +@(require_results) +euler_angles_zxz_from_matrix4_f16 :: proc "contextless" (m: Matrix4f16) -> (t1, t2, t3: f16) { T1 := math.atan2(m[0, 2], -m[1, 2]) S2 := math.sqrt(m[2, 0]*m[2, 0] + m[2, 1]*m[2, 1]) T2 := math.atan2(S2, m[2, 2]) @@ -1303,7 +1399,8 @@ euler_angles_zxz_from_matrix4_f16 :: proc(m: Matrix4f16) -> (t1, t2, t3: f16) { return } -euler_angles_xzy_from_matrix4_f16 :: proc(m: Matrix4f16) -> (t1, t2, t3: f16) { +@(require_results) +euler_angles_xzy_from_matrix4_f16 :: proc "contextless" (m: Matrix4f16) -> (t1, t2, t3: f16) { T1 := math.atan2(m[2, 1], m[1, 1]) C2 := math.sqrt(m[0, 0]*m[0, 0] + m[0, 2]*m[0, 2]) T2 := math.atan2(-m[0, 1], C2) @@ -1316,7 +1413,8 @@ euler_angles_xzy_from_matrix4_f16 :: proc(m: Matrix4f16) -> (t1, t2, t3: f16) { return } -euler_angles_yzx_from_matrix4_f16 :: proc(m: Matrix4f16) -> (t1, t2, t3: f16) { +@(require_results) +euler_angles_yzx_from_matrix4_f16 :: proc "contextless" (m: Matrix4f16) -> (t1, t2, t3: f16) { T1 := math.atan2(-m[2, 0], m[0, 0]) C2 := math.sqrt(m[1, 1]*m[1, 1] + m[1, 2]*m[1, 2]) T2 := math.atan2(m[1, 0], C2) @@ -1329,7 +1427,8 @@ euler_angles_yzx_from_matrix4_f16 :: proc(m: Matrix4f16) -> (t1, t2, t3: f16) { return } -euler_angles_zyx_from_matrix4_f16 :: proc(m: Matrix4f16) -> (t1, t2, t3: f16) { +@(require_results) +euler_angles_zyx_from_matrix4_f16 :: proc "contextless" (m: Matrix4f16) -> (t1, t2, t3: f16) { T1 := math.atan2(m[1, 0], m[0, 0]) C2 := math.sqrt(m[2, 1]*m[2, 1] + m[2, 2]*m[2, 2]) T2 := math.atan2(-m[2, 0], C2) @@ -1342,7 +1441,8 @@ euler_angles_zyx_from_matrix4_f16 :: proc(m: Matrix4f16) -> (t1, t2, t3: f16) { return } -euler_angles_zxy_from_matrix4_f16 :: proc(m: Matrix4f16) -> (t1, t2, t3: f16) { +@(require_results) +euler_angles_zxy_from_matrix4_f16 :: proc "contextless" (m: Matrix4f16) -> (t1, t2, t3: f16) { T1 := math.atan2(-m[0, 1], m[1, 1]) C2 := math.sqrt(m[2, 0]*m[2, 0] + m[2, 2]*m[2, 2]) T2 := math.atan2(m[2, 1], C2) diff --git a/core/math/linalg/specific_euler_angles_f32.odin b/core/math/linalg/specific_euler_angles_f32.odin index 80e19ce85..b9957034f 100644 --- a/core/math/linalg/specific_euler_angles_f32.odin +++ b/core/math/linalg/specific_euler_angles_f32.odin @@ -2,7 +2,8 @@ package linalg import "core:math" -euler_angles_from_matrix3_f32 :: proc(m: Matrix3f32, order: Euler_Angle_Order) -> (t1, t2, t3: f32) { +@(require_results) +euler_angles_from_matrix3_f32 :: proc "contextless" (m: Matrix3f32, order: Euler_Angle_Order) -> (t1, t2, t3: f32) { switch order { case .XYZ: t1, t2, t3 = euler_angles_xyz_from_matrix3(m) case .XZY: t1, t2, t3 = euler_angles_xzy_from_matrix3(m) @@ -19,7 +20,8 @@ euler_angles_from_matrix3_f32 :: proc(m: Matrix3f32, order: Euler_Angle_Order) - } return } -euler_angles_from_matrix4_f32 :: proc(m: Matrix4f32, order: Euler_Angle_Order) -> (t1, t2, t3: f32) { +@(require_results) +euler_angles_from_matrix4_f32 :: proc "contextless" (m: Matrix4f32, order: Euler_Angle_Order) -> (t1, t2, t3: f32) { switch order { case .XYZ: t1, t2, t3 = euler_angles_xyz_from_matrix4(m) case .XZY: t1, t2, t3 = euler_angles_xzy_from_matrix4(m) @@ -36,7 +38,8 @@ euler_angles_from_matrix4_f32 :: proc(m: Matrix4f32, order: Euler_Angle_Order) - } return } -euler_angles_from_quaternion_f32 :: proc(m: Quaternionf32, order: Euler_Angle_Order) -> (t1, t2, t3: f32) { +@(require_results) +euler_angles_from_quaternion_f32 :: proc "contextless" (m: Quaternionf32, order: Euler_Angle_Order) -> (t1, t2, t3: f32) { switch order { case .XYZ: t1, t2, t3 = euler_angles_xyz_from_quaternion(m) case .XZY: t1, t2, t3 = euler_angles_xzy_from_quaternion(m) @@ -54,7 +57,8 @@ euler_angles_from_quaternion_f32 :: proc(m: Quaternionf32, order: Euler_Angle_Or return } -matrix3_from_euler_angles_f32 :: proc(t1, t2, t3: f32, order: Euler_Angle_Order) -> (m: Matrix3f32) { +@(require_results) +matrix3_from_euler_angles_f32 :: proc "contextless" (t1, t2, t3: f32, order: Euler_Angle_Order) -> (m: Matrix3f32) { switch order { case .XYZ: return matrix3_from_euler_angles_xyz(t1, t2, t3) // m1, m2, m3 = X(t1), Y(t2), Z(t3); case .XZY: return matrix3_from_euler_angles_xzy(t1, t2, t3) // m1, m2, m3 = X(t1), Z(t2), Y(t3); @@ -71,7 +75,8 @@ matrix3_from_euler_angles_f32 :: proc(t1, t2, t3: f32, order: Euler_Angle_Order) } return } -matrix4_from_euler_angles_f32 :: proc(t1, t2, t3: f32, order: Euler_Angle_Order) -> (m: Matrix4f32) { +@(require_results) +matrix4_from_euler_angles_f32 :: proc "contextless" (t1, t2, t3: f32, order: Euler_Angle_Order) -> (m: Matrix4f32) { switch order { case .XYZ: return matrix4_from_euler_angles_xyz(t1, t2, t3) // m1, m2, m3 = X(t1), Y(t2), Z(t3); case .XZY: return matrix4_from_euler_angles_xzy(t1, t2, t3) // m1, m2, m3 = X(t1), Z(t2), Y(t3); @@ -89,7 +94,8 @@ matrix4_from_euler_angles_f32 :: proc(t1, t2, t3: f32, order: Euler_Angle_Order) return } -quaternion_from_euler_angles_f32 :: proc(t1, t2, t3: f32, order: Euler_Angle_Order) -> Quaternionf32 { +@(require_results) +quaternion_from_euler_angles_f32 :: proc "contextless" (t1, t2, t3: f32, order: Euler_Angle_Order) -> Quaternionf32 { X :: quaternion_from_euler_angle_x Y :: quaternion_from_euler_angle_y Z :: quaternion_from_euler_angle_z @@ -117,17 +123,21 @@ quaternion_from_euler_angles_f32 :: proc(t1, t2, t3: f32, order: Euler_Angle_Ord // Quaternionf32s -quaternion_from_euler_angle_x_f32 :: proc(angle_x: f32) -> (q: Quaternionf32) { +@(require_results) +quaternion_from_euler_angle_x_f32 :: proc "contextless" (angle_x: f32) -> (q: Quaternionf32) { return quaternion_angle_axis_f32(angle_x, {1, 0, 0}) } -quaternion_from_euler_angle_y_f32 :: proc(angle_y: f32) -> (q: Quaternionf32) { +@(require_results) +quaternion_from_euler_angle_y_f32 :: proc "contextless" (angle_y: f32) -> (q: Quaternionf32) { return quaternion_angle_axis_f32(angle_y, {0, 1, 0}) } -quaternion_from_euler_angle_z_f32 :: proc(angle_z: f32) -> (q: Quaternionf32) { +@(require_results) +quaternion_from_euler_angle_z_f32 :: proc "contextless" (angle_z: f32) -> (q: Quaternionf32) { return quaternion_angle_axis_f32(angle_z, {0, 0, 1}) } -quaternion_from_pitch_yaw_roll_f32 :: proc(pitch, yaw, roll: f32) -> Quaternionf32 { +@(require_results) +quaternion_from_pitch_yaw_roll_f32 :: proc "contextless" (pitch, yaw, roll: f32) -> Quaternionf32 { a, b, c := pitch, yaw, roll ca, sa := math.cos(a*0.5), math.sin(a*0.5) @@ -142,11 +152,13 @@ quaternion_from_pitch_yaw_roll_f32 :: proc(pitch, yaw, roll: f32) -> Quaternionf return q } -roll_from_quaternion_f32 :: proc(q: Quaternionf32) -> f32 { +@(require_results) +roll_from_quaternion_f32 :: proc "contextless" (q: Quaternionf32) -> f32 { return math.atan2(2 * q.x*q.y + q.w*q.z, q.w*q.w + q.x*q.x - q.y*q.y - q.z*q.z) } -pitch_from_quaternion_f32 :: proc(q: Quaternionf32) -> f32 { +@(require_results) +pitch_from_quaternion_f32 :: proc "contextless" (q: Quaternionf32) -> f32 { y := 2 * (q.y*q.z + q.w*q.w) x := q.w*q.w - q.x*q.x - q.y*q.y + q.z*q.z @@ -157,52 +169,66 @@ pitch_from_quaternion_f32 :: proc(q: Quaternionf32) -> f32 { return math.atan2(y, x) } -yaw_from_quaternion_f32 :: proc(q: Quaternionf32) -> f32 { +@(require_results) +yaw_from_quaternion_f32 :: proc "contextless" (q: Quaternionf32) -> f32 { return math.asin(clamp(-2 * (q.x*q.z - q.w*q.y), -1, 1)) } -pitch_yaw_roll_from_quaternion_f32 :: proc(q: Quaternionf32) -> (pitch, yaw, roll: f32) { +@(require_results) +pitch_yaw_roll_from_quaternion_f32 :: proc "contextless" (q: Quaternionf32) -> (pitch, yaw, roll: f32) { pitch = pitch_from_quaternion(q) yaw = yaw_from_quaternion(q) roll = roll_from_quaternion(q) return } -euler_angles_xyz_from_quaternion_f32 :: proc(q: Quaternionf32) -> (t1, t2, t3: f32) { +@(require_results) +euler_angles_xyz_from_quaternion_f32 :: proc "contextless" (q: Quaternionf32) -> (t1, t2, t3: f32) { return euler_angles_xyz_from_matrix4(matrix4_from_quaternion(q)) } -euler_angles_yxz_from_quaternion_f32 :: proc(q: Quaternionf32) -> (t1, t2, t3: f32) { +@(require_results) +euler_angles_yxz_from_quaternion_f32 :: proc "contextless" (q: Quaternionf32) -> (t1, t2, t3: f32) { return euler_angles_yxz_from_matrix4(matrix4_from_quaternion(q)) } -euler_angles_xzx_from_quaternion_f32 :: proc(q: Quaternionf32) -> (t1, t2, t3: f32) { +@(require_results) +euler_angles_xzx_from_quaternion_f32 :: proc "contextless" (q: Quaternionf32) -> (t1, t2, t3: f32) { return euler_angles_xzx_from_matrix4(matrix4_from_quaternion(q)) } -euler_angles_xyx_from_quaternion_f32 :: proc(q: Quaternionf32) -> (t1, t2, t3: f32) { +@(require_results) +euler_angles_xyx_from_quaternion_f32 :: proc "contextless" (q: Quaternionf32) -> (t1, t2, t3: f32) { return euler_angles_xyx_from_matrix4(matrix4_from_quaternion(q)) } -euler_angles_yxy_from_quaternion_f32 :: proc(q: Quaternionf32) -> (t1, t2, t3: f32) { +@(require_results) +euler_angles_yxy_from_quaternion_f32 :: proc "contextless" (q: Quaternionf32) -> (t1, t2, t3: f32) { return euler_angles_yxy_from_matrix4(matrix4_from_quaternion(q)) } -euler_angles_yzy_from_quaternion_f32 :: proc(q: Quaternionf32) -> (t1, t2, t3: f32) { +@(require_results) +euler_angles_yzy_from_quaternion_f32 :: proc "contextless" (q: Quaternionf32) -> (t1, t2, t3: f32) { return euler_angles_yzy_from_matrix4(matrix4_from_quaternion(q)) } -euler_angles_zyz_from_quaternion_f32 :: proc(q: Quaternionf32) -> (t1, t2, t3: f32) { +@(require_results) +euler_angles_zyz_from_quaternion_f32 :: proc "contextless" (q: Quaternionf32) -> (t1, t2, t3: f32) { return euler_angles_zyz_from_matrix4(matrix4_from_quaternion(q)) } -euler_angles_zxz_from_quaternion_f32 :: proc(q: Quaternionf32) -> (t1, t2, t3: f32) { +@(require_results) +euler_angles_zxz_from_quaternion_f32 :: proc "contextless" (q: Quaternionf32) -> (t1, t2, t3: f32) { return euler_angles_zxz_from_matrix4(matrix4_from_quaternion(q)) } -euler_angles_xzy_from_quaternion_f32 :: proc(q: Quaternionf32) -> (t1, t2, t3: f32) { +@(require_results) +euler_angles_xzy_from_quaternion_f32 :: proc "contextless" (q: Quaternionf32) -> (t1, t2, t3: f32) { return euler_angles_xzy_from_matrix4(matrix4_from_quaternion(q)) } -euler_angles_yzx_from_quaternion_f32 :: proc(q: Quaternionf32) -> (t1, t2, t3: f32) { +@(require_results) +euler_angles_yzx_from_quaternion_f32 :: proc "contextless" (q: Quaternionf32) -> (t1, t2, t3: f32) { return euler_angles_yzx_from_matrix4(matrix4_from_quaternion(q)) } -euler_angles_zyx_from_quaternion_f32 :: proc(q: Quaternionf32) -> (t1, t2, t3: f32) { +@(require_results) +euler_angles_zyx_from_quaternion_f32 :: proc "contextless" (q: Quaternionf32) -> (t1, t2, t3: f32) { return euler_angles_zyx_from_matrix4(matrix4_from_quaternion(q)) } -euler_angles_zxy_from_quaternion_f32 :: proc(q: Quaternionf32) -> (t1, t2, t3: f32) { +@(require_results) +euler_angles_zxy_from_quaternion_f32 :: proc "contextless" (q: Quaternionf32) -> (t1, t2, t3: f32) { return euler_angles_zxy_from_matrix4(matrix4_from_quaternion(q)) } @@ -210,7 +236,8 @@ euler_angles_zxy_from_quaternion_f32 :: proc(q: Quaternionf32) -> (t1, t2, t3: f // Matrix3 -matrix3_from_euler_angle_x_f32 :: proc(angle_x: f32) -> (m: Matrix3f32) { +@(require_results) +matrix3_from_euler_angle_x_f32 :: proc "contextless" (angle_x: f32) -> (m: Matrix3f32) { cos_x, sin_x := math.cos(angle_x), math.sin(angle_x) m[0, 0] = 1 m[1, 1] = +cos_x @@ -219,7 +246,8 @@ matrix3_from_euler_angle_x_f32 :: proc(angle_x: f32) -> (m: Matrix3f32) { m[2, 2] = +cos_x return } -matrix3_from_euler_angle_y_f32 :: proc(angle_y: f32) -> (m: Matrix3f32) { +@(require_results) +matrix3_from_euler_angle_y_f32 :: proc "contextless" (angle_y: f32) -> (m: Matrix3f32) { cos_y, sin_y := math.cos(angle_y), math.sin(angle_y) m[0, 0] = +cos_y m[0, 2] = -sin_y @@ -228,7 +256,8 @@ matrix3_from_euler_angle_y_f32 :: proc(angle_y: f32) -> (m: Matrix3f32) { m[2, 2] = +cos_y return } -matrix3_from_euler_angle_z_f32 :: proc(angle_z: f32) -> (m: Matrix3f32) { +@(require_results) +matrix3_from_euler_angle_z_f32 :: proc "contextless" (angle_z: f32) -> (m: Matrix3f32) { cos_z, sin_z := math.cos(angle_z), math.sin(angle_z) m[0, 0] = +cos_z m[0, 1] = +sin_z @@ -239,7 +268,8 @@ matrix3_from_euler_angle_z_f32 :: proc(angle_z: f32) -> (m: Matrix3f32) { } -matrix3_from_derived_euler_angle_x_f32 :: proc(angle_x: f32, angular_velocity_x: f32) -> (m: Matrix3f32) { +@(require_results) +matrix3_from_derived_euler_angle_x_f32 :: proc "contextless" (angle_x: f32, angular_velocity_x: f32) -> (m: Matrix3f32) { cos_x := math.cos(angle_x) * angular_velocity_x sin_x := math.sin(angle_x) * angular_velocity_x m[0, 0] = 1 @@ -249,7 +279,8 @@ matrix3_from_derived_euler_angle_x_f32 :: proc(angle_x: f32, angular_velocity_x: m[2, 2] = +cos_x return } -matrix3_from_derived_euler_angle_y_f32 :: proc(angle_y: f32, angular_velocity_y: f32) -> (m: Matrix3f32) { +@(require_results) +matrix3_from_derived_euler_angle_y_f32 :: proc "contextless" (angle_y: f32, angular_velocity_y: f32) -> (m: Matrix3f32) { cos_y := math.cos(angle_y) * angular_velocity_y sin_y := math.sin(angle_y) * angular_velocity_y m[0, 0] = +cos_y @@ -259,7 +290,8 @@ matrix3_from_derived_euler_angle_y_f32 :: proc(angle_y: f32, angular_velocity_y: m[2, 2] = +cos_y return } -matrix3_from_derived_euler_angle_z_f32 :: proc(angle_z: f32, angular_velocity_z: f32) -> (m: Matrix3f32) { +@(require_results) +matrix3_from_derived_euler_angle_z_f32 :: proc "contextless" (angle_z: f32, angular_velocity_z: f32) -> (m: Matrix3f32) { cos_z := math.cos(angle_z) * angular_velocity_z sin_z := math.sin(angle_z) * angular_velocity_z m[0, 0] = +cos_z @@ -271,7 +303,8 @@ matrix3_from_derived_euler_angle_z_f32 :: proc(angle_z: f32, angular_velocity_z: } -matrix3_from_euler_angles_xy_f32 :: proc(angle_x, angle_y: f32) -> (m: Matrix3f32) { +@(require_results) +matrix3_from_euler_angles_xy_f32 :: proc "contextless" (angle_x, angle_y: f32) -> (m: Matrix3f32) { cos_x, sin_x := math.cos(angle_x), math.sin(angle_x) cos_y, sin_y := math.cos(angle_y), math.sin(angle_y) m[0, 0] = cos_y @@ -286,7 +319,8 @@ matrix3_from_euler_angles_xy_f32 :: proc(angle_x, angle_y: f32) -> (m: Matrix3f3 } -matrix3_from_euler_angles_yx_f32 :: proc(angle_y, angle_x: f32) -> (m: Matrix3f32) { +@(require_results) +matrix3_from_euler_angles_yx_f32 :: proc "contextless" (angle_y, angle_x: f32) -> (m: Matrix3f32) { cos_x, sin_x := math.cos(angle_x), math.sin(angle_x) cos_y, sin_y := math.cos(angle_y), math.sin(angle_y) m[0, 0] = cos_y @@ -300,21 +334,26 @@ matrix3_from_euler_angles_yx_f32 :: proc(angle_y, angle_x: f32) -> (m: Matrix3f3 return } -matrix3_from_euler_angles_xz_f32 :: proc(angle_x, angle_z: f32) -> (m: Matrix3f32) { +@(require_results) +matrix3_from_euler_angles_xz_f32 :: proc "contextless" (angle_x, angle_z: f32) -> (m: Matrix3f32) { return mul(matrix3_from_euler_angle_x(angle_x), matrix3_from_euler_angle_z(angle_z)) } -matrix3_from_euler_angles_zx_f32 :: proc(angle_z, angle_x: f32) -> (m: Matrix3f32) { +@(require_results) +matrix3_from_euler_angles_zx_f32 :: proc "contextless" (angle_z, angle_x: f32) -> (m: Matrix3f32) { return mul(matrix3_from_euler_angle_z(angle_z), matrix3_from_euler_angle_x(angle_x)) } -matrix3_from_euler_angles_yz_f32 :: proc(angle_y, angle_z: f32) -> (m: Matrix3f32) { +@(require_results) +matrix3_from_euler_angles_yz_f32 :: proc "contextless" (angle_y, angle_z: f32) -> (m: Matrix3f32) { return mul(matrix3_from_euler_angle_y(angle_y), matrix3_from_euler_angle_z(angle_z)) } -matrix3_from_euler_angles_zy_f32 :: proc(angle_z, angle_y: f32) -> (m: Matrix3f32) { +@(require_results) +matrix3_from_euler_angles_zy_f32 :: proc "contextless" (angle_z, angle_y: f32) -> (m: Matrix3f32) { return mul(matrix3_from_euler_angle_z(angle_z), matrix3_from_euler_angle_y(angle_y)) } -matrix3_from_euler_angles_xyz_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix3f32) { +@(require_results) +matrix3_from_euler_angles_xyz_f32 :: proc "contextless" (t1, t2, t3: f32) -> (m: Matrix3f32) { c1 := math.cos(-t1) c2 := math.cos(-t2) c3 := math.cos(-t3) @@ -334,7 +373,8 @@ matrix3_from_euler_angles_xyz_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix3f32) { return } -matrix3_from_euler_angles_yxz_f32 :: proc(yaw, pitch, roll: f32) -> (m: Matrix3f32) { +@(require_results) +matrix3_from_euler_angles_yxz_f32 :: proc "contextless" (yaw, pitch, roll: f32) -> (m: Matrix3f32) { ch := math.cos(yaw) sh := math.sin(yaw) cp := math.cos(pitch) @@ -354,7 +394,8 @@ matrix3_from_euler_angles_yxz_f32 :: proc(yaw, pitch, roll: f32) -> (m: Matrix3f return } -matrix3_from_euler_angles_xzx_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix3f32) { +@(require_results) +matrix3_from_euler_angles_xzx_f32 :: proc "contextless" (t1, t2, t3: f32) -> (m: Matrix3f32) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -374,7 +415,8 @@ matrix3_from_euler_angles_xzx_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix3f32) { return } -matrix3_from_euler_angles_xyx_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix3f32) { +@(require_results) +matrix3_from_euler_angles_xyx_f32 :: proc "contextless" (t1, t2, t3: f32) -> (m: Matrix3f32) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -394,7 +436,8 @@ matrix3_from_euler_angles_xyx_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix3f32) { return } -matrix3_from_euler_angles_yxy_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix3f32) { +@(require_results) +matrix3_from_euler_angles_yxy_f32 :: proc "contextless" (t1, t2, t3: f32) -> (m: Matrix3f32) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -414,7 +457,8 @@ matrix3_from_euler_angles_yxy_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix3f32) { return } -matrix3_from_euler_angles_yzy_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix3f32) { +@(require_results) +matrix3_from_euler_angles_yzy_f32 :: proc "contextless" (t1, t2, t3: f32) -> (m: Matrix3f32) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -434,7 +478,8 @@ matrix3_from_euler_angles_yzy_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix3f32) { return } -matrix3_from_euler_angles_zyz_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix3f32) { +@(require_results) +matrix3_from_euler_angles_zyz_f32 :: proc "contextless" (t1, t2, t3: f32) -> (m: Matrix3f32) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -454,7 +499,8 @@ matrix3_from_euler_angles_zyz_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix3f32) { return } -matrix3_from_euler_angles_zxz_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix3f32) { +@(require_results) +matrix3_from_euler_angles_zxz_f32 :: proc "contextless" (t1, t2, t3: f32) -> (m: Matrix3f32) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -475,7 +521,8 @@ matrix3_from_euler_angles_zxz_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix3f32) { } -matrix3_from_euler_angles_xzy_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix3f32) { +@(require_results) +matrix3_from_euler_angles_xzy_f32 :: proc "contextless" (t1, t2, t3: f32) -> (m: Matrix3f32) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -495,7 +542,8 @@ matrix3_from_euler_angles_xzy_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix3f32) { return } -matrix3_from_euler_angles_yzx_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix3f32) { +@(require_results) +matrix3_from_euler_angles_yzx_f32 :: proc "contextless" (t1, t2, t3: f32) -> (m: Matrix3f32) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -515,7 +563,8 @@ matrix3_from_euler_angles_yzx_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix3f32) { return } -matrix3_from_euler_angles_zyx_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix3f32) { +@(require_results) +matrix3_from_euler_angles_zyx_f32 :: proc "contextless" (t1, t2, t3: f32) -> (m: Matrix3f32) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -535,7 +584,8 @@ matrix3_from_euler_angles_zyx_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix3f32) { return } -matrix3_from_euler_angles_zxy_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix3f32) { +@(require_results) +matrix3_from_euler_angles_zxy_f32 :: proc "contextless" (t1, t2, t3: f32) -> (m: Matrix3f32) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -556,7 +606,8 @@ matrix3_from_euler_angles_zxy_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix3f32) { } -matrix3_from_yaw_pitch_roll_f32 :: proc(yaw, pitch, roll: f32) -> (m: Matrix3f32) { +@(require_results) +matrix3_from_yaw_pitch_roll_f32 :: proc "contextless" (yaw, pitch, roll: f32) -> (m: Matrix3f32) { ch := math.cos(yaw) sh := math.sin(yaw) cp := math.cos(pitch) @@ -576,7 +627,8 @@ matrix3_from_yaw_pitch_roll_f32 :: proc(yaw, pitch, roll: f32) -> (m: Matrix3f32 return m } -euler_angles_xyz_from_matrix3_f32 :: proc(m: Matrix3f32) -> (t1, t2, t3: f32) { +@(require_results) +euler_angles_xyz_from_matrix3_f32 :: proc "contextless" (m: Matrix3f32) -> (t1, t2, t3: f32) { T1 := math.atan2(m[1, 2], m[2, 2]) C2 := math.sqrt(m[0, 0]*m[0, 0] + m[0, 1]*m[0, 1]) T2 := math.atan2(-m[0, 2], C2) @@ -589,7 +641,8 @@ euler_angles_xyz_from_matrix3_f32 :: proc(m: Matrix3f32) -> (t1, t2, t3: f32) { return } -euler_angles_yxz_from_matrix3_f32 :: proc(m: Matrix3f32) -> (t1, t2, t3: f32) { +@(require_results) +euler_angles_yxz_from_matrix3_f32 :: proc "contextless" (m: Matrix3f32) -> (t1, t2, t3: f32) { T1 := math.atan2(m[0, 2], m[2, 2]) C2 := math.sqrt(m[1, 0]*m[1, 0] + m[1, 1]*m[1, 1]) T2 := math.atan2(-m[1, 2], C2) @@ -602,7 +655,8 @@ euler_angles_yxz_from_matrix3_f32 :: proc(m: Matrix3f32) -> (t1, t2, t3: f32) { return } -euler_angles_xzx_from_matrix3_f32 :: proc(m: Matrix3f32) -> (t1, t2, t3: f32) { +@(require_results) +euler_angles_xzx_from_matrix3_f32 :: proc "contextless" (m: Matrix3f32) -> (t1, t2, t3: f32) { T1 := math.atan2(m[2, 0], m[1, 0]) S2 := math.sqrt(m[0, 1]*m[0, 1] + m[0, 2]*m[0, 2]) T2 := math.atan2(S2, m[0, 0]) @@ -615,7 +669,8 @@ euler_angles_xzx_from_matrix3_f32 :: proc(m: Matrix3f32) -> (t1, t2, t3: f32) { return } -euler_angles_xyx_from_matrix3_f32 :: proc(m: Matrix3f32) -> (t1, t2, t3: f32) { +@(require_results) +euler_angles_xyx_from_matrix3_f32 :: proc "contextless" (m: Matrix3f32) -> (t1, t2, t3: f32) { T1 := math.atan2(m[1, 0], -m[2, 0]) S2 := math.sqrt(m[0, 1]*m[0, 1] + m[0, 2]*m[0, 2]) T2 := math.atan2(S2, m[0, 0]) @@ -628,7 +683,8 @@ euler_angles_xyx_from_matrix3_f32 :: proc(m: Matrix3f32) -> (t1, t2, t3: f32) { return } -euler_angles_yxy_from_matrix3_f32 :: proc(m: Matrix3f32) -> (t1, t2, t3: f32) { +@(require_results) +euler_angles_yxy_from_matrix3_f32 :: proc "contextless" (m: Matrix3f32) -> (t1, t2, t3: f32) { T1 := math.atan2(m[0, 1], m[2, 1]) S2 := math.sqrt(m[1, 0]*m[1, 0] + m[1, 2]*m[1, 2]) T2 := math.atan2(S2, m[1, 1]) @@ -641,7 +697,8 @@ euler_angles_yxy_from_matrix3_f32 :: proc(m: Matrix3f32) -> (t1, t2, t3: f32) { return } -euler_angles_yzy_from_matrix3_f32 :: proc(m: Matrix3f32) -> (t1, t2, t3: f32) { +@(require_results) +euler_angles_yzy_from_matrix3_f32 :: proc "contextless" (m: Matrix3f32) -> (t1, t2, t3: f32) { T1 := math.atan2(m[2, 1], -m[0, 1]) S2 := math.sqrt(m[1, 0]*m[1, 0] + m[1, 2]*m[1, 2]) T2 := math.atan2(S2, m[1, 1]) @@ -653,7 +710,8 @@ euler_angles_yzy_from_matrix3_f32 :: proc(m: Matrix3f32) -> (t1, t2, t3: f32) { t3 = T3 return } -euler_angles_zyz_from_matrix3_f32 :: proc(m: Matrix3f32) -> (t1, t2, t3: f32) { +@(require_results) +euler_angles_zyz_from_matrix3_f32 :: proc "contextless" (m: Matrix3f32) -> (t1, t2, t3: f32) { T1 := math.atan2(m[1, 2], m[0, 2]) S2 := math.sqrt(m[2, 0]*m[2, 0] + m[2, 1]*m[2, 1]) T2 := math.atan2(S2, m[2, 2]) @@ -666,7 +724,8 @@ euler_angles_zyz_from_matrix3_f32 :: proc(m: Matrix3f32) -> (t1, t2, t3: f32) { return } -euler_angles_zxz_from_matrix3_f32 :: proc(m: Matrix3f32) -> (t1, t2, t3: f32) { +@(require_results) +euler_angles_zxz_from_matrix3_f32 :: proc "contextless" (m: Matrix3f32) -> (t1, t2, t3: f32) { T1 := math.atan2(m[0, 2], -m[1, 2]) S2 := math.sqrt(m[2, 0]*m[2, 0] + m[2, 1]*m[2, 1]) T2 := math.atan2(S2, m[2, 2]) @@ -679,7 +738,8 @@ euler_angles_zxz_from_matrix3_f32 :: proc(m: Matrix3f32) -> (t1, t2, t3: f32) { return } -euler_angles_xzy_from_matrix3_f32 :: proc(m: Matrix3f32) -> (t1, t2, t3: f32) { +@(require_results) +euler_angles_xzy_from_matrix3_f32 :: proc "contextless" (m: Matrix3f32) -> (t1, t2, t3: f32) { T1 := math.atan2(m[2, 1], m[1, 1]) C2 := math.sqrt(m[0, 0]*m[0, 0] + m[0, 2]*m[0, 2]) T2 := math.atan2(-m[0, 1], C2) @@ -692,7 +752,8 @@ euler_angles_xzy_from_matrix3_f32 :: proc(m: Matrix3f32) -> (t1, t2, t3: f32) { return } -euler_angles_yzx_from_matrix3_f32 :: proc(m: Matrix3f32) -> (t1, t2, t3: f32) { +@(require_results) +euler_angles_yzx_from_matrix3_f32 :: proc "contextless" (m: Matrix3f32) -> (t1, t2, t3: f32) { T1 := math.atan2(-m[2, 0], m[0, 0]) C2 := math.sqrt(m[1, 1]*m[1, 1] + m[1, 2]*m[1, 2]) T2 := math.atan2(m[1, 0], C2) @@ -705,7 +766,8 @@ euler_angles_yzx_from_matrix3_f32 :: proc(m: Matrix3f32) -> (t1, t2, t3: f32) { return } -euler_angles_zyx_from_matrix3_f32 :: proc(m: Matrix3f32) -> (t1, t2, t3: f32) { +@(require_results) +euler_angles_zyx_from_matrix3_f32 :: proc "contextless" (m: Matrix3f32) -> (t1, t2, t3: f32) { T1 := math.atan2(m[1, 0], m[0, 0]) C2 := math.sqrt(m[2, 1]*m[2, 1] + m[2, 2]*m[2, 2]) T2 := math.atan2(-m[2, 0], C2) @@ -718,7 +780,8 @@ euler_angles_zyx_from_matrix3_f32 :: proc(m: Matrix3f32) -> (t1, t2, t3: f32) { return } -euler_angles_zxy_from_matrix3_f32 :: proc(m: Matrix3f32) -> (t1, t2, t3: f32) { +@(require_results) +euler_angles_zxy_from_matrix3_f32 :: proc "contextless" (m: Matrix3f32) -> (t1, t2, t3: f32) { T1 := math.atan2(-m[0, 1], m[1, 1]) C2 := math.sqrt(m[2, 0]*m[2, 0] + m[2, 2]*m[2, 2]) T2 := math.atan2(m[2, 1], C2) @@ -735,7 +798,8 @@ euler_angles_zxy_from_matrix3_f32 :: proc(m: Matrix3f32) -> (t1, t2, t3: f32) { // Matrix4 -matrix4_from_euler_angle_x_f32 :: proc(angle_x: f32) -> (m: Matrix4f32) { +@(require_results) +matrix4_from_euler_angle_x_f32 :: proc "contextless" (angle_x: f32) -> (m: Matrix4f32) { cos_x, sin_x := math.cos(angle_x), math.sin(angle_x) m[0, 0] = 1 m[1, 1] = +cos_x @@ -745,7 +809,8 @@ matrix4_from_euler_angle_x_f32 :: proc(angle_x: f32) -> (m: Matrix4f32) { m[3, 3] = 1 return } -matrix4_from_euler_angle_y_f32 :: proc(angle_y: f32) -> (m: Matrix4f32) { +@(require_results) +matrix4_from_euler_angle_y_f32 :: proc "contextless" (angle_y: f32) -> (m: Matrix4f32) { cos_y, sin_y := math.cos(angle_y), math.sin(angle_y) m[0, 0] = +cos_y m[0, 2] = -sin_y @@ -755,7 +820,8 @@ matrix4_from_euler_angle_y_f32 :: proc(angle_y: f32) -> (m: Matrix4f32) { m[3, 3] = 1 return } -matrix4_from_euler_angle_z_f32 :: proc(angle_z: f32) -> (m: Matrix4f32) { +@(require_results) +matrix4_from_euler_angle_z_f32 :: proc "contextless" (angle_z: f32) -> (m: Matrix4f32) { cos_z, sin_z := math.cos(angle_z), math.sin(angle_z) m[0, 0] = +cos_z m[0, 1] = +sin_z @@ -767,7 +833,8 @@ matrix4_from_euler_angle_z_f32 :: proc(angle_z: f32) -> (m: Matrix4f32) { } -matrix4_from_derived_euler_angle_x_f32 :: proc(angle_x: f32, angular_velocity_x: f32) -> (m: Matrix4f32) { +@(require_results) +matrix4_from_derived_euler_angle_x_f32 :: proc "contextless" (angle_x: f32, angular_velocity_x: f32) -> (m: Matrix4f32) { cos_x := math.cos(angle_x) * angular_velocity_x sin_x := math.sin(angle_x) * angular_velocity_x m[0, 0] = 1 @@ -778,7 +845,8 @@ matrix4_from_derived_euler_angle_x_f32 :: proc(angle_x: f32, angular_velocity_x: m[3, 3] = 1 return } -matrix4_from_derived_euler_angle_y_f32 :: proc(angle_y: f32, angular_velocity_y: f32) -> (m: Matrix4f32) { +@(require_results) +matrix4_from_derived_euler_angle_y_f32 :: proc "contextless" (angle_y: f32, angular_velocity_y: f32) -> (m: Matrix4f32) { cos_y := math.cos(angle_y) * angular_velocity_y sin_y := math.sin(angle_y) * angular_velocity_y m[0, 0] = +cos_y @@ -789,7 +857,8 @@ matrix4_from_derived_euler_angle_y_f32 :: proc(angle_y: f32, angular_velocity_y: m[3, 3] = 1 return } -matrix4_from_derived_euler_angle_z_f32 :: proc(angle_z: f32, angular_velocity_z: f32) -> (m: Matrix4f32) { +@(require_results) +matrix4_from_derived_euler_angle_z_f32 :: proc "contextless" (angle_z: f32, angular_velocity_z: f32) -> (m: Matrix4f32) { cos_z := math.cos(angle_z) * angular_velocity_z sin_z := math.sin(angle_z) * angular_velocity_z m[0, 0] = +cos_z @@ -802,7 +871,8 @@ matrix4_from_derived_euler_angle_z_f32 :: proc(angle_z: f32, angular_velocity_z: } -matrix4_from_euler_angles_xy_f32 :: proc(angle_x, angle_y: f32) -> (m: Matrix4f32) { +@(require_results) +matrix4_from_euler_angles_xy_f32 :: proc "contextless" (angle_x, angle_y: f32) -> (m: Matrix4f32) { cos_x, sin_x := math.cos(angle_x), math.sin(angle_x) cos_y, sin_y := math.cos(angle_y), math.sin(angle_y) m[0, 0] = cos_y @@ -818,7 +888,8 @@ matrix4_from_euler_angles_xy_f32 :: proc(angle_x, angle_y: f32) -> (m: Matrix4f3 } -matrix4_from_euler_angles_yx_f32 :: proc(angle_y, angle_x: f32) -> (m: Matrix4f32) { +@(require_results) +matrix4_from_euler_angles_yx_f32 :: proc "contextless" (angle_y, angle_x: f32) -> (m: Matrix4f32) { cos_x, sin_x := math.cos(angle_x), math.sin(angle_x) cos_y, sin_y := math.cos(angle_y), math.sin(angle_y) m[0, 0] = cos_y @@ -833,21 +904,26 @@ matrix4_from_euler_angles_yx_f32 :: proc(angle_y, angle_x: f32) -> (m: Matrix4f3 return } -matrix4_from_euler_angles_xz_f32 :: proc(angle_x, angle_z: f32) -> (m: Matrix4f32) { +@(require_results) +matrix4_from_euler_angles_xz_f32 :: proc "contextless" (angle_x, angle_z: f32) -> (m: Matrix4f32) { return mul(matrix4_from_euler_angle_x(angle_x), matrix4_from_euler_angle_z(angle_z)) } -matrix4_from_euler_angles_zx_f32 :: proc(angle_z, angle_x: f32) -> (m: Matrix4f32) { +@(require_results) +matrix4_from_euler_angles_zx_f32 :: proc "contextless" (angle_z, angle_x: f32) -> (m: Matrix4f32) { return mul(matrix4_from_euler_angle_z(angle_z), matrix4_from_euler_angle_x(angle_x)) } -matrix4_from_euler_angles_yz_f32 :: proc(angle_y, angle_z: f32) -> (m: Matrix4f32) { +@(require_results) +matrix4_from_euler_angles_yz_f32 :: proc "contextless" (angle_y, angle_z: f32) -> (m: Matrix4f32) { return mul(matrix4_from_euler_angle_y(angle_y), matrix4_from_euler_angle_z(angle_z)) } -matrix4_from_euler_angles_zy_f32 :: proc(angle_z, angle_y: f32) -> (m: Matrix4f32) { +@(require_results) +matrix4_from_euler_angles_zy_f32 :: proc "contextless" (angle_z, angle_y: f32) -> (m: Matrix4f32) { return mul(matrix4_from_euler_angle_z(angle_z), matrix4_from_euler_angle_y(angle_y)) } -matrix4_from_euler_angles_xyz_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix4f32) { +@(require_results) +matrix4_from_euler_angles_xyz_f32 :: proc "contextless" (t1, t2, t3: f32) -> (m: Matrix4f32) { c1 := math.cos(-t1) c2 := math.cos(-t2) c3 := math.cos(-t3) @@ -874,7 +950,8 @@ matrix4_from_euler_angles_xyz_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix4f32) { return } -matrix4_from_euler_angles_yxz_f32 :: proc(yaw, pitch, roll: f32) -> (m: Matrix4f32) { +@(require_results) +matrix4_from_euler_angles_yxz_f32 :: proc "contextless" (yaw, pitch, roll: f32) -> (m: Matrix4f32) { ch := math.cos(yaw) sh := math.sin(yaw) cp := math.cos(pitch) @@ -901,7 +978,8 @@ matrix4_from_euler_angles_yxz_f32 :: proc(yaw, pitch, roll: f32) -> (m: Matrix4f return } -matrix4_from_euler_angles_xzx_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix4f32) { +@(require_results) +matrix4_from_euler_angles_xzx_f32 :: proc "contextless" (t1, t2, t3: f32) -> (m: Matrix4f32) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -928,7 +1006,8 @@ matrix4_from_euler_angles_xzx_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix4f32) { return } -matrix4_from_euler_angles_xyx_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix4f32) { +@(require_results) +matrix4_from_euler_angles_xyx_f32 :: proc "contextless" (t1, t2, t3: f32) -> (m: Matrix4f32) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -955,7 +1034,8 @@ matrix4_from_euler_angles_xyx_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix4f32) { return } -matrix4_from_euler_angles_yxy_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix4f32) { +@(require_results) +matrix4_from_euler_angles_yxy_f32 :: proc "contextless" (t1, t2, t3: f32) -> (m: Matrix4f32) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -982,7 +1062,8 @@ matrix4_from_euler_angles_yxy_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix4f32) { return } -matrix4_from_euler_angles_yzy_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix4f32) { +@(require_results) +matrix4_from_euler_angles_yzy_f32 :: proc "contextless" (t1, t2, t3: f32) -> (m: Matrix4f32) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -1009,7 +1090,8 @@ matrix4_from_euler_angles_yzy_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix4f32) { return } -matrix4_from_euler_angles_zyz_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix4f32) { +@(require_results) +matrix4_from_euler_angles_zyz_f32 :: proc "contextless" (t1, t2, t3: f32) -> (m: Matrix4f32) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -1036,7 +1118,8 @@ matrix4_from_euler_angles_zyz_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix4f32) { return } -matrix4_from_euler_angles_zxz_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix4f32) { +@(require_results) +matrix4_from_euler_angles_zxz_f32 :: proc "contextless" (t1, t2, t3: f32) -> (m: Matrix4f32) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -1064,7 +1147,8 @@ matrix4_from_euler_angles_zxz_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix4f32) { } -matrix4_from_euler_angles_xzy_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix4f32) { +@(require_results) +matrix4_from_euler_angles_xzy_f32 :: proc "contextless" (t1, t2, t3: f32) -> (m: Matrix4f32) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -1091,7 +1175,8 @@ matrix4_from_euler_angles_xzy_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix4f32) { return } -matrix4_from_euler_angles_yzx_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix4f32) { +@(require_results) +matrix4_from_euler_angles_yzx_f32 :: proc "contextless" (t1, t2, t3: f32) -> (m: Matrix4f32) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -1118,7 +1203,8 @@ matrix4_from_euler_angles_yzx_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix4f32) { return } -matrix4_from_euler_angles_zyx_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix4f32) { +@(require_results) +matrix4_from_euler_angles_zyx_f32 :: proc "contextless" (t1, t2, t3: f32) -> (m: Matrix4f32) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -1145,7 +1231,8 @@ matrix4_from_euler_angles_zyx_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix4f32) { return } -matrix4_from_euler_angles_zxy_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix4f32) { +@(require_results) +matrix4_from_euler_angles_zxy_f32 :: proc "contextless" (t1, t2, t3: f32) -> (m: Matrix4f32) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -1173,7 +1260,8 @@ matrix4_from_euler_angles_zxy_f32 :: proc(t1, t2, t3: f32) -> (m: Matrix4f32) { } -matrix4_from_yaw_pitch_roll_f32 :: proc(yaw, pitch, roll: f32) -> (m: Matrix4f32) { +@(require_results) +matrix4_from_yaw_pitch_roll_f32 :: proc "contextless" (yaw, pitch, roll: f32) -> (m: Matrix4f32) { ch := math.cos(yaw) sh := math.sin(yaw) cp := math.cos(pitch) @@ -1200,7 +1288,8 @@ matrix4_from_yaw_pitch_roll_f32 :: proc(yaw, pitch, roll: f32) -> (m: Matrix4f32 return m } -euler_angles_xyz_from_matrix4_f32 :: proc(m: Matrix4f32) -> (t1, t2, t3: f32) { +@(require_results) +euler_angles_xyz_from_matrix4_f32 :: proc "contextless" (m: Matrix4f32) -> (t1, t2, t3: f32) { T1 := math.atan2(m[1, 2], m[2, 2]) C2 := math.sqrt(m[0, 0]*m[0, 0] + m[0, 1]*m[0, 1]) T2 := math.atan2(-m[0, 2], C2) @@ -1213,7 +1302,8 @@ euler_angles_xyz_from_matrix4_f32 :: proc(m: Matrix4f32) -> (t1, t2, t3: f32) { return } -euler_angles_yxz_from_matrix4_f32 :: proc(m: Matrix4f32) -> (t1, t2, t3: f32) { +@(require_results) +euler_angles_yxz_from_matrix4_f32 :: proc "contextless" (m: Matrix4f32) -> (t1, t2, t3: f32) { T1 := math.atan2(m[0, 2], m[2, 2]) C2 := math.sqrt(m[1, 0]*m[1, 0] + m[1, 1]*m[1, 1]) T2 := math.atan2(-m[1, 2], C2) @@ -1226,7 +1316,8 @@ euler_angles_yxz_from_matrix4_f32 :: proc(m: Matrix4f32) -> (t1, t2, t3: f32) { return } -euler_angles_xzx_from_matrix4_f32 :: proc(m: Matrix4f32) -> (t1, t2, t3: f32) { +@(require_results) +euler_angles_xzx_from_matrix4_f32 :: proc "contextless" (m: Matrix4f32) -> (t1, t2, t3: f32) { T1 := math.atan2(m[2, 0], m[1, 0]) S2 := math.sqrt(m[0, 1]*m[0, 1] + m[0, 2]*m[0, 2]) T2 := math.atan2(S2, m[0, 0]) @@ -1239,7 +1330,8 @@ euler_angles_xzx_from_matrix4_f32 :: proc(m: Matrix4f32) -> (t1, t2, t3: f32) { return } -euler_angles_xyx_from_matrix4_f32 :: proc(m: Matrix4f32) -> (t1, t2, t3: f32) { +@(require_results) +euler_angles_xyx_from_matrix4_f32 :: proc "contextless" (m: Matrix4f32) -> (t1, t2, t3: f32) { T1 := math.atan2(m[1, 0], -m[2, 0]) S2 := math.sqrt(m[0, 1]*m[0, 1] + m[0, 2]*m[0, 2]) T2 := math.atan2(S2, m[0, 0]) @@ -1252,7 +1344,8 @@ euler_angles_xyx_from_matrix4_f32 :: proc(m: Matrix4f32) -> (t1, t2, t3: f32) { return } -euler_angles_yxy_from_matrix4_f32 :: proc(m: Matrix4f32) -> (t1, t2, t3: f32) { +@(require_results) +euler_angles_yxy_from_matrix4_f32 :: proc "contextless" (m: Matrix4f32) -> (t1, t2, t3: f32) { T1 := math.atan2(m[0, 1], m[2, 1]) S2 := math.sqrt(m[1, 0]*m[1, 0] + m[1, 2]*m[1, 2]) T2 := math.atan2(S2, m[1, 1]) @@ -1265,7 +1358,8 @@ euler_angles_yxy_from_matrix4_f32 :: proc(m: Matrix4f32) -> (t1, t2, t3: f32) { return } -euler_angles_yzy_from_matrix4_f32 :: proc(m: Matrix4f32) -> (t1, t2, t3: f32) { +@(require_results) +euler_angles_yzy_from_matrix4_f32 :: proc "contextless" (m: Matrix4f32) -> (t1, t2, t3: f32) { T1 := math.atan2(m[2, 1], -m[0, 1]) S2 := math.sqrt(m[1, 0]*m[1, 0] + m[1, 2]*m[1, 2]) T2 := math.atan2(S2, m[1, 1]) @@ -1277,7 +1371,8 @@ euler_angles_yzy_from_matrix4_f32 :: proc(m: Matrix4f32) -> (t1, t2, t3: f32) { t3 = T3 return } -euler_angles_zyz_from_matrix4_f32 :: proc(m: Matrix4f32) -> (t1, t2, t3: f32) { +@(require_results) +euler_angles_zyz_from_matrix4_f32 :: proc "contextless" (m: Matrix4f32) -> (t1, t2, t3: f32) { T1 := math.atan2(m[1, 2], m[0, 2]) S2 := math.sqrt(m[2, 0]*m[2, 0] + m[2, 1]*m[2, 1]) T2 := math.atan2(S2, m[2, 2]) @@ -1290,7 +1385,8 @@ euler_angles_zyz_from_matrix4_f32 :: proc(m: Matrix4f32) -> (t1, t2, t3: f32) { return } -euler_angles_zxz_from_matrix4_f32 :: proc(m: Matrix4f32) -> (t1, t2, t3: f32) { +@(require_results) +euler_angles_zxz_from_matrix4_f32 :: proc "contextless" (m: Matrix4f32) -> (t1, t2, t3: f32) { T1 := math.atan2(m[0, 2], -m[1, 2]) S2 := math.sqrt(m[2, 0]*m[2, 0] + m[2, 1]*m[2, 1]) T2 := math.atan2(S2, m[2, 2]) @@ -1303,7 +1399,8 @@ euler_angles_zxz_from_matrix4_f32 :: proc(m: Matrix4f32) -> (t1, t2, t3: f32) { return } -euler_angles_xzy_from_matrix4_f32 :: proc(m: Matrix4f32) -> (t1, t2, t3: f32) { +@(require_results) +euler_angles_xzy_from_matrix4_f32 :: proc "contextless" (m: Matrix4f32) -> (t1, t2, t3: f32) { T1 := math.atan2(m[2, 1], m[1, 1]) C2 := math.sqrt(m[0, 0]*m[0, 0] + m[0, 2]*m[0, 2]) T2 := math.atan2(-m[0, 1], C2) @@ -1316,7 +1413,8 @@ euler_angles_xzy_from_matrix4_f32 :: proc(m: Matrix4f32) -> (t1, t2, t3: f32) { return } -euler_angles_yzx_from_matrix4_f32 :: proc(m: Matrix4f32) -> (t1, t2, t3: f32) { +@(require_results) +euler_angles_yzx_from_matrix4_f32 :: proc "contextless" (m: Matrix4f32) -> (t1, t2, t3: f32) { T1 := math.atan2(-m[2, 0], m[0, 0]) C2 := math.sqrt(m[1, 1]*m[1, 1] + m[1, 2]*m[1, 2]) T2 := math.atan2(m[1, 0], C2) @@ -1329,7 +1427,8 @@ euler_angles_yzx_from_matrix4_f32 :: proc(m: Matrix4f32) -> (t1, t2, t3: f32) { return } -euler_angles_zyx_from_matrix4_f32 :: proc(m: Matrix4f32) -> (t1, t2, t3: f32) { +@(require_results) +euler_angles_zyx_from_matrix4_f32 :: proc "contextless" (m: Matrix4f32) -> (t1, t2, t3: f32) { T1 := math.atan2(m[1, 0], m[0, 0]) C2 := math.sqrt(m[2, 1]*m[2, 1] + m[2, 2]*m[2, 2]) T2 := math.atan2(-m[2, 0], C2) @@ -1342,7 +1441,8 @@ euler_angles_zyx_from_matrix4_f32 :: proc(m: Matrix4f32) -> (t1, t2, t3: f32) { return } -euler_angles_zxy_from_matrix4_f32 :: proc(m: Matrix4f32) -> (t1, t2, t3: f32) { +@(require_results) +euler_angles_zxy_from_matrix4_f32 :: proc "contextless" (m: Matrix4f32) -> (t1, t2, t3: f32) { T1 := math.atan2(-m[0, 1], m[1, 1]) C2 := math.sqrt(m[2, 0]*m[2, 0] + m[2, 2]*m[2, 2]) T2 := math.atan2(m[2, 1], C2) diff --git a/core/math/linalg/specific_euler_angles_f64.odin b/core/math/linalg/specific_euler_angles_f64.odin index 2f8f758b0..8001d080a 100644 --- a/core/math/linalg/specific_euler_angles_f64.odin +++ b/core/math/linalg/specific_euler_angles_f64.odin @@ -2,7 +2,8 @@ package linalg import "core:math" -euler_angles_from_matrix3_f64 :: proc(m: Matrix3f64, order: Euler_Angle_Order) -> (t1, t2, t3: f64) { +@(require_results) +euler_angles_from_matrix3_f64 :: proc "contextless" (m: Matrix3f64, order: Euler_Angle_Order) -> (t1, t2, t3: f64) { switch order { case .XYZ: t1, t2, t3 = euler_angles_xyz_from_matrix3(m) case .XZY: t1, t2, t3 = euler_angles_xzy_from_matrix3(m) @@ -19,7 +20,8 @@ euler_angles_from_matrix3_f64 :: proc(m: Matrix3f64, order: Euler_Angle_Order) - } return } -euler_angles_from_matrix4_f64 :: proc(m: Matrix4f64, order: Euler_Angle_Order) -> (t1, t2, t3: f64) { +@(require_results) +euler_angles_from_matrix4_f64 :: proc "contextless" (m: Matrix4f64, order: Euler_Angle_Order) -> (t1, t2, t3: f64) { switch order { case .XYZ: t1, t2, t3 = euler_angles_xyz_from_matrix4(m) case .XZY: t1, t2, t3 = euler_angles_xzy_from_matrix4(m) @@ -36,7 +38,8 @@ euler_angles_from_matrix4_f64 :: proc(m: Matrix4f64, order: Euler_Angle_Order) - } return } -euler_angles_from_quaternion_f64 :: proc(m: Quaternionf64, order: Euler_Angle_Order) -> (t1, t2, t3: f64) { +@(require_results) +euler_angles_from_quaternion_f64 :: proc "contextless" (m: Quaternionf64, order: Euler_Angle_Order) -> (t1, t2, t3: f64) { switch order { case .XYZ: t1, t2, t3 = euler_angles_xyz_from_quaternion(m) case .XZY: t1, t2, t3 = euler_angles_xzy_from_quaternion(m) @@ -54,7 +57,8 @@ euler_angles_from_quaternion_f64 :: proc(m: Quaternionf64, order: Euler_Angle_Or return } -matrix3_from_euler_angles_f64 :: proc(t1, t2, t3: f64, order: Euler_Angle_Order) -> (m: Matrix3f64) { +@(require_results) +matrix3_from_euler_angles_f64 :: proc "contextless" (t1, t2, t3: f64, order: Euler_Angle_Order) -> (m: Matrix3f64) { switch order { case .XYZ: return matrix3_from_euler_angles_xyz(t1, t2, t3) // m1, m2, m3 = X(t1), Y(t2), Z(t3); case .XZY: return matrix3_from_euler_angles_xzy(t1, t2, t3) // m1, m2, m3 = X(t1), Z(t2), Y(t3); @@ -71,7 +75,8 @@ matrix3_from_euler_angles_f64 :: proc(t1, t2, t3: f64, order: Euler_Angle_Order) } return } -matrix4_from_euler_angles_f64 :: proc(t1, t2, t3: f64, order: Euler_Angle_Order) -> (m: Matrix4f64) { +@(require_results) +matrix4_from_euler_angles_f64 :: proc "contextless" (t1, t2, t3: f64, order: Euler_Angle_Order) -> (m: Matrix4f64) { switch order { case .XYZ: return matrix4_from_euler_angles_xyz(t1, t2, t3) // m1, m2, m3 = X(t1), Y(t2), Z(t3); case .XZY: return matrix4_from_euler_angles_xzy(t1, t2, t3) // m1, m2, m3 = X(t1), Z(t2), Y(t3); @@ -89,7 +94,8 @@ matrix4_from_euler_angles_f64 :: proc(t1, t2, t3: f64, order: Euler_Angle_Order) return } -quaternion_from_euler_angles_f64 :: proc(t1, t2, t3: f64, order: Euler_Angle_Order) -> Quaternionf64 { +@(require_results) +quaternion_from_euler_angles_f64 :: proc "contextless" (t1, t2, t3: f64, order: Euler_Angle_Order) -> Quaternionf64 { X :: quaternion_from_euler_angle_x Y :: quaternion_from_euler_angle_y Z :: quaternion_from_euler_angle_z @@ -117,17 +123,21 @@ quaternion_from_euler_angles_f64 :: proc(t1, t2, t3: f64, order: Euler_Angle_Ord // Quaternionf64s -quaternion_from_euler_angle_x_f64 :: proc(angle_x: f64) -> (q: Quaternionf64) { +@(require_results) +quaternion_from_euler_angle_x_f64 :: proc "contextless" (angle_x: f64) -> (q: Quaternionf64) { return quaternion_angle_axis_f64(angle_x, {1, 0, 0}) } -quaternion_from_euler_angle_y_f64 :: proc(angle_y: f64) -> (q: Quaternionf64) { +@(require_results) +quaternion_from_euler_angle_y_f64 :: proc "contextless" (angle_y: f64) -> (q: Quaternionf64) { return quaternion_angle_axis_f64(angle_y, {0, 1, 0}) } -quaternion_from_euler_angle_z_f64 :: proc(angle_z: f64) -> (q: Quaternionf64) { +@(require_results) +quaternion_from_euler_angle_z_f64 :: proc "contextless" (angle_z: f64) -> (q: Quaternionf64) { return quaternion_angle_axis_f64(angle_z, {0, 0, 1}) } -quaternion_from_pitch_yaw_roll_f64 :: proc(pitch, yaw, roll: f64) -> Quaternionf64 { +@(require_results) +quaternion_from_pitch_yaw_roll_f64 :: proc "contextless" (pitch, yaw, roll: f64) -> Quaternionf64 { a, b, c := pitch, yaw, roll ca, sa := math.cos(a*0.5), math.sin(a*0.5) @@ -142,11 +152,13 @@ quaternion_from_pitch_yaw_roll_f64 :: proc(pitch, yaw, roll: f64) -> Quaternionf return q } -roll_from_quaternion_f64 :: proc(q: Quaternionf64) -> f64 { +@(require_results) +roll_from_quaternion_f64 :: proc "contextless" (q: Quaternionf64) -> f64 { return math.atan2(2 * q.x*q.y + q.w*q.z, q.w*q.w + q.x*q.x - q.y*q.y - q.z*q.z) } -pitch_from_quaternion_f64 :: proc(q: Quaternionf64) -> f64 { +@(require_results) +pitch_from_quaternion_f64 :: proc "contextless" (q: Quaternionf64) -> f64 { y := 2 * (q.y*q.z + q.w*q.w) x := q.w*q.w - q.x*q.x - q.y*q.y + q.z*q.z @@ -157,52 +169,66 @@ pitch_from_quaternion_f64 :: proc(q: Quaternionf64) -> f64 { return math.atan2(y, x) } -yaw_from_quaternion_f64 :: proc(q: Quaternionf64) -> f64 { +@(require_results) +yaw_from_quaternion_f64 :: proc "contextless" (q: Quaternionf64) -> f64 { return math.asin(clamp(-2 * (q.x*q.z - q.w*q.y), -1, 1)) } -pitch_yaw_roll_from_quaternion_f64 :: proc(q: Quaternionf64) -> (pitch, yaw, roll: f64) { +@(require_results) +pitch_yaw_roll_from_quaternion_f64 :: proc "contextless" (q: Quaternionf64) -> (pitch, yaw, roll: f64) { pitch = pitch_from_quaternion(q) yaw = yaw_from_quaternion(q) roll = roll_from_quaternion(q) return } -euler_angles_xyz_from_quaternion_f64 :: proc(q: Quaternionf64) -> (t1, t2, t3: f64) { +@(require_results) +euler_angles_xyz_from_quaternion_f64 :: proc "contextless" (q: Quaternionf64) -> (t1, t2, t3: f64) { return euler_angles_xyz_from_matrix4(matrix4_from_quaternion(q)) } -euler_angles_yxz_from_quaternion_f64 :: proc(q: Quaternionf64) -> (t1, t2, t3: f64) { +@(require_results) +euler_angles_yxz_from_quaternion_f64 :: proc "contextless" (q: Quaternionf64) -> (t1, t2, t3: f64) { return euler_angles_yxz_from_matrix4(matrix4_from_quaternion(q)) } -euler_angles_xzx_from_quaternion_f64 :: proc(q: Quaternionf64) -> (t1, t2, t3: f64) { +@(require_results) +euler_angles_xzx_from_quaternion_f64 :: proc "contextless" (q: Quaternionf64) -> (t1, t2, t3: f64) { return euler_angles_xzx_from_matrix4(matrix4_from_quaternion(q)) } -euler_angles_xyx_from_quaternion_f64 :: proc(q: Quaternionf64) -> (t1, t2, t3: f64) { +@(require_results) +euler_angles_xyx_from_quaternion_f64 :: proc "contextless" (q: Quaternionf64) -> (t1, t2, t3: f64) { return euler_angles_xyx_from_matrix4(matrix4_from_quaternion(q)) } -euler_angles_yxy_from_quaternion_f64 :: proc(q: Quaternionf64) -> (t1, t2, t3: f64) { +@(require_results) +euler_angles_yxy_from_quaternion_f64 :: proc "contextless" (q: Quaternionf64) -> (t1, t2, t3: f64) { return euler_angles_yxy_from_matrix4(matrix4_from_quaternion(q)) } -euler_angles_yzy_from_quaternion_f64 :: proc(q: Quaternionf64) -> (t1, t2, t3: f64) { +@(require_results) +euler_angles_yzy_from_quaternion_f64 :: proc "contextless" (q: Quaternionf64) -> (t1, t2, t3: f64) { return euler_angles_yzy_from_matrix4(matrix4_from_quaternion(q)) } -euler_angles_zyz_from_quaternion_f64 :: proc(q: Quaternionf64) -> (t1, t2, t3: f64) { +@(require_results) +euler_angles_zyz_from_quaternion_f64 :: proc "contextless" (q: Quaternionf64) -> (t1, t2, t3: f64) { return euler_angles_zyz_from_matrix4(matrix4_from_quaternion(q)) } -euler_angles_zxz_from_quaternion_f64 :: proc(q: Quaternionf64) -> (t1, t2, t3: f64) { +@(require_results) +euler_angles_zxz_from_quaternion_f64 :: proc "contextless" (q: Quaternionf64) -> (t1, t2, t3: f64) { return euler_angles_zxz_from_matrix4(matrix4_from_quaternion(q)) } -euler_angles_xzy_from_quaternion_f64 :: proc(q: Quaternionf64) -> (t1, t2, t3: f64) { +@(require_results) +euler_angles_xzy_from_quaternion_f64 :: proc "contextless" (q: Quaternionf64) -> (t1, t2, t3: f64) { return euler_angles_xzy_from_matrix4(matrix4_from_quaternion(q)) } -euler_angles_yzx_from_quaternion_f64 :: proc(q: Quaternionf64) -> (t1, t2, t3: f64) { +@(require_results) +euler_angles_yzx_from_quaternion_f64 :: proc "contextless" (q: Quaternionf64) -> (t1, t2, t3: f64) { return euler_angles_yzx_from_matrix4(matrix4_from_quaternion(q)) } -euler_angles_zyx_from_quaternion_f64 :: proc(q: Quaternionf64) -> (t1, t2, t3: f64) { +@(require_results) +euler_angles_zyx_from_quaternion_f64 :: proc "contextless" (q: Quaternionf64) -> (t1, t2, t3: f64) { return euler_angles_zyx_from_matrix4(matrix4_from_quaternion(q)) } -euler_angles_zxy_from_quaternion_f64 :: proc(q: Quaternionf64) -> (t1, t2, t3: f64) { +@(require_results) +euler_angles_zxy_from_quaternion_f64 :: proc "contextless" (q: Quaternionf64) -> (t1, t2, t3: f64) { return euler_angles_zxy_from_matrix4(matrix4_from_quaternion(q)) } @@ -210,7 +236,8 @@ euler_angles_zxy_from_quaternion_f64 :: proc(q: Quaternionf64) -> (t1, t2, t3: f // Matrix3 -matrix3_from_euler_angle_x_f64 :: proc(angle_x: f64) -> (m: Matrix3f64) { +@(require_results) +matrix3_from_euler_angle_x_f64 :: proc "contextless" (angle_x: f64) -> (m: Matrix3f64) { cos_x, sin_x := math.cos(angle_x), math.sin(angle_x) m[0, 0] = 1 m[1, 1] = +cos_x @@ -219,7 +246,8 @@ matrix3_from_euler_angle_x_f64 :: proc(angle_x: f64) -> (m: Matrix3f64) { m[2, 2] = +cos_x return } -matrix3_from_euler_angle_y_f64 :: proc(angle_y: f64) -> (m: Matrix3f64) { +@(require_results) +matrix3_from_euler_angle_y_f64 :: proc "contextless" (angle_y: f64) -> (m: Matrix3f64) { cos_y, sin_y := math.cos(angle_y), math.sin(angle_y) m[0, 0] = +cos_y m[0, 2] = -sin_y @@ -228,7 +256,8 @@ matrix3_from_euler_angle_y_f64 :: proc(angle_y: f64) -> (m: Matrix3f64) { m[2, 2] = +cos_y return } -matrix3_from_euler_angle_z_f64 :: proc(angle_z: f64) -> (m: Matrix3f64) { +@(require_results) +matrix3_from_euler_angle_z_f64 :: proc "contextless" (angle_z: f64) -> (m: Matrix3f64) { cos_z, sin_z := math.cos(angle_z), math.sin(angle_z) m[0, 0] = +cos_z m[0, 1] = +sin_z @@ -239,7 +268,8 @@ matrix3_from_euler_angle_z_f64 :: proc(angle_z: f64) -> (m: Matrix3f64) { } -matrix3_from_derived_euler_angle_x_f64 :: proc(angle_x: f64, angular_velocity_x: f64) -> (m: Matrix3f64) { +@(require_results) +matrix3_from_derived_euler_angle_x_f64 :: proc "contextless" (angle_x: f64, angular_velocity_x: f64) -> (m: Matrix3f64) { cos_x := math.cos(angle_x) * angular_velocity_x sin_x := math.sin(angle_x) * angular_velocity_x m[0, 0] = 1 @@ -249,7 +279,8 @@ matrix3_from_derived_euler_angle_x_f64 :: proc(angle_x: f64, angular_velocity_x: m[2, 2] = +cos_x return } -matrix3_from_derived_euler_angle_y_f64 :: proc(angle_y: f64, angular_velocity_y: f64) -> (m: Matrix3f64) { +@(require_results) +matrix3_from_derived_euler_angle_y_f64 :: proc "contextless" (angle_y: f64, angular_velocity_y: f64) -> (m: Matrix3f64) { cos_y := math.cos(angle_y) * angular_velocity_y sin_y := math.sin(angle_y) * angular_velocity_y m[0, 0] = +cos_y @@ -259,7 +290,8 @@ matrix3_from_derived_euler_angle_y_f64 :: proc(angle_y: f64, angular_velocity_y: m[2, 2] = +cos_y return } -matrix3_from_derived_euler_angle_z_f64 :: proc(angle_z: f64, angular_velocity_z: f64) -> (m: Matrix3f64) { +@(require_results) +matrix3_from_derived_euler_angle_z_f64 :: proc "contextless" (angle_z: f64, angular_velocity_z: f64) -> (m: Matrix3f64) { cos_z := math.cos(angle_z) * angular_velocity_z sin_z := math.sin(angle_z) * angular_velocity_z m[0, 0] = +cos_z @@ -271,7 +303,8 @@ matrix3_from_derived_euler_angle_z_f64 :: proc(angle_z: f64, angular_velocity_z: } -matrix3_from_euler_angles_xy_f64 :: proc(angle_x, angle_y: f64) -> (m: Matrix3f64) { +@(require_results) +matrix3_from_euler_angles_xy_f64 :: proc "contextless" (angle_x, angle_y: f64) -> (m: Matrix3f64) { cos_x, sin_x := math.cos(angle_x), math.sin(angle_x) cos_y, sin_y := math.cos(angle_y), math.sin(angle_y) m[0, 0] = cos_y @@ -286,7 +319,8 @@ matrix3_from_euler_angles_xy_f64 :: proc(angle_x, angle_y: f64) -> (m: Matrix3f6 } -matrix3_from_euler_angles_yx_f64 :: proc(angle_y, angle_x: f64) -> (m: Matrix3f64) { +@(require_results) +matrix3_from_euler_angles_yx_f64 :: proc "contextless" (angle_y, angle_x: f64) -> (m: Matrix3f64) { cos_x, sin_x := math.cos(angle_x), math.sin(angle_x) cos_y, sin_y := math.cos(angle_y), math.sin(angle_y) m[0, 0] = cos_y @@ -300,21 +334,26 @@ matrix3_from_euler_angles_yx_f64 :: proc(angle_y, angle_x: f64) -> (m: Matrix3f6 return } -matrix3_from_euler_angles_xz_f64 :: proc(angle_x, angle_z: f64) -> (m: Matrix3f64) { +@(require_results) +matrix3_from_euler_angles_xz_f64 :: proc "contextless" (angle_x, angle_z: f64) -> (m: Matrix3f64) { return mul(matrix3_from_euler_angle_x(angle_x), matrix3_from_euler_angle_z(angle_z)) } -matrix3_from_euler_angles_zx_f64 :: proc(angle_z, angle_x: f64) -> (m: Matrix3f64) { +@(require_results) +matrix3_from_euler_angles_zx_f64 :: proc "contextless" (angle_z, angle_x: f64) -> (m: Matrix3f64) { return mul(matrix3_from_euler_angle_z(angle_z), matrix3_from_euler_angle_x(angle_x)) } -matrix3_from_euler_angles_yz_f64 :: proc(angle_y, angle_z: f64) -> (m: Matrix3f64) { +@(require_results) +matrix3_from_euler_angles_yz_f64 :: proc "contextless" (angle_y, angle_z: f64) -> (m: Matrix3f64) { return mul(matrix3_from_euler_angle_y(angle_y), matrix3_from_euler_angle_z(angle_z)) } -matrix3_from_euler_angles_zy_f64 :: proc(angle_z, angle_y: f64) -> (m: Matrix3f64) { +@(require_results) +matrix3_from_euler_angles_zy_f64 :: proc "contextless" (angle_z, angle_y: f64) -> (m: Matrix3f64) { return mul(matrix3_from_euler_angle_z(angle_z), matrix3_from_euler_angle_y(angle_y)) } -matrix3_from_euler_angles_xyz_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix3f64) { +@(require_results) +matrix3_from_euler_angles_xyz_f64 :: proc "contextless" (t1, t2, t3: f64) -> (m: Matrix3f64) { c1 := math.cos(-t1) c2 := math.cos(-t2) c3 := math.cos(-t3) @@ -334,7 +373,8 @@ matrix3_from_euler_angles_xyz_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix3f64) { return } -matrix3_from_euler_angles_yxz_f64 :: proc(yaw, pitch, roll: f64) -> (m: Matrix3f64) { +@(require_results) +matrix3_from_euler_angles_yxz_f64 :: proc "contextless" (yaw, pitch, roll: f64) -> (m: Matrix3f64) { ch := math.cos(yaw) sh := math.sin(yaw) cp := math.cos(pitch) @@ -354,7 +394,8 @@ matrix3_from_euler_angles_yxz_f64 :: proc(yaw, pitch, roll: f64) -> (m: Matrix3f return } -matrix3_from_euler_angles_xzx_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix3f64) { +@(require_results) +matrix3_from_euler_angles_xzx_f64 :: proc "contextless" (t1, t2, t3: f64) -> (m: Matrix3f64) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -374,7 +415,8 @@ matrix3_from_euler_angles_xzx_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix3f64) { return } -matrix3_from_euler_angles_xyx_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix3f64) { +@(require_results) +matrix3_from_euler_angles_xyx_f64 :: proc "contextless" (t1, t2, t3: f64) -> (m: Matrix3f64) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -394,7 +436,8 @@ matrix3_from_euler_angles_xyx_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix3f64) { return } -matrix3_from_euler_angles_yxy_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix3f64) { +@(require_results) +matrix3_from_euler_angles_yxy_f64 :: proc "contextless" (t1, t2, t3: f64) -> (m: Matrix3f64) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -414,7 +457,8 @@ matrix3_from_euler_angles_yxy_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix3f64) { return } -matrix3_from_euler_angles_yzy_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix3f64) { +@(require_results) +matrix3_from_euler_angles_yzy_f64 :: proc "contextless" (t1, t2, t3: f64) -> (m: Matrix3f64) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -434,7 +478,8 @@ matrix3_from_euler_angles_yzy_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix3f64) { return } -matrix3_from_euler_angles_zyz_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix3f64) { +@(require_results) +matrix3_from_euler_angles_zyz_f64 :: proc "contextless" (t1, t2, t3: f64) -> (m: Matrix3f64) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -454,7 +499,8 @@ matrix3_from_euler_angles_zyz_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix3f64) { return } -matrix3_from_euler_angles_zxz_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix3f64) { +@(require_results) +matrix3_from_euler_angles_zxz_f64 :: proc "contextless" (t1, t2, t3: f64) -> (m: Matrix3f64) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -475,7 +521,8 @@ matrix3_from_euler_angles_zxz_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix3f64) { } -matrix3_from_euler_angles_xzy_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix3f64) { +@(require_results) +matrix3_from_euler_angles_xzy_f64 :: proc "contextless" (t1, t2, t3: f64) -> (m: Matrix3f64) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -495,7 +542,8 @@ matrix3_from_euler_angles_xzy_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix3f64) { return } -matrix3_from_euler_angles_yzx_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix3f64) { +@(require_results) +matrix3_from_euler_angles_yzx_f64 :: proc "contextless" (t1, t2, t3: f64) -> (m: Matrix3f64) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -515,7 +563,8 @@ matrix3_from_euler_angles_yzx_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix3f64) { return } -matrix3_from_euler_angles_zyx_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix3f64) { +@(require_results) +matrix3_from_euler_angles_zyx_f64 :: proc "contextless" (t1, t2, t3: f64) -> (m: Matrix3f64) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -535,7 +584,8 @@ matrix3_from_euler_angles_zyx_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix3f64) { return } -matrix3_from_euler_angles_zxy_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix3f64) { +@(require_results) +matrix3_from_euler_angles_zxy_f64 :: proc "contextless" (t1, t2, t3: f64) -> (m: Matrix3f64) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -556,7 +606,8 @@ matrix3_from_euler_angles_zxy_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix3f64) { } -matrix3_from_yaw_pitch_roll_f64 :: proc(yaw, pitch, roll: f64) -> (m: Matrix3f64) { +@(require_results) +matrix3_from_yaw_pitch_roll_f64 :: proc "contextless" (yaw, pitch, roll: f64) -> (m: Matrix3f64) { ch := math.cos(yaw) sh := math.sin(yaw) cp := math.cos(pitch) @@ -576,7 +627,8 @@ matrix3_from_yaw_pitch_roll_f64 :: proc(yaw, pitch, roll: f64) -> (m: Matrix3f64 return m } -euler_angles_xyz_from_matrix3_f64 :: proc(m: Matrix3f64) -> (t1, t2, t3: f64) { +@(require_results) +euler_angles_xyz_from_matrix3_f64 :: proc "contextless" (m: Matrix3f64) -> (t1, t2, t3: f64) { T1 := math.atan2(m[1, 2], m[2, 2]) C2 := math.sqrt(m[0, 0]*m[0, 0] + m[0, 1]*m[0, 1]) T2 := math.atan2(-m[0, 2], C2) @@ -589,7 +641,8 @@ euler_angles_xyz_from_matrix3_f64 :: proc(m: Matrix3f64) -> (t1, t2, t3: f64) { return } -euler_angles_yxz_from_matrix3_f64 :: proc(m: Matrix3f64) -> (t1, t2, t3: f64) { +@(require_results) +euler_angles_yxz_from_matrix3_f64 :: proc "contextless" (m: Matrix3f64) -> (t1, t2, t3: f64) { T1 := math.atan2(m[0, 2], m[2, 2]) C2 := math.sqrt(m[1, 0]*m[1, 0] + m[1, 1]*m[1, 1]) T2 := math.atan2(-m[1, 2], C2) @@ -602,7 +655,8 @@ euler_angles_yxz_from_matrix3_f64 :: proc(m: Matrix3f64) -> (t1, t2, t3: f64) { return } -euler_angles_xzx_from_matrix3_f64 :: proc(m: Matrix3f64) -> (t1, t2, t3: f64) { +@(require_results) +euler_angles_xzx_from_matrix3_f64 :: proc "contextless" (m: Matrix3f64) -> (t1, t2, t3: f64) { T1 := math.atan2(m[2, 0], m[1, 0]) S2 := math.sqrt(m[0, 1]*m[0, 1] + m[0, 2]*m[0, 2]) T2 := math.atan2(S2, m[0, 0]) @@ -615,7 +669,8 @@ euler_angles_xzx_from_matrix3_f64 :: proc(m: Matrix3f64) -> (t1, t2, t3: f64) { return } -euler_angles_xyx_from_matrix3_f64 :: proc(m: Matrix3f64) -> (t1, t2, t3: f64) { +@(require_results) +euler_angles_xyx_from_matrix3_f64 :: proc "contextless" (m: Matrix3f64) -> (t1, t2, t3: f64) { T1 := math.atan2(m[1, 0], -m[2, 0]) S2 := math.sqrt(m[0, 1]*m[0, 1] + m[0, 2]*m[0, 2]) T2 := math.atan2(S2, m[0, 0]) @@ -628,7 +683,8 @@ euler_angles_xyx_from_matrix3_f64 :: proc(m: Matrix3f64) -> (t1, t2, t3: f64) { return } -euler_angles_yxy_from_matrix3_f64 :: proc(m: Matrix3f64) -> (t1, t2, t3: f64) { +@(require_results) +euler_angles_yxy_from_matrix3_f64 :: proc "contextless" (m: Matrix3f64) -> (t1, t2, t3: f64) { T1 := math.atan2(m[0, 1], m[2, 1]) S2 := math.sqrt(m[1, 0]*m[1, 0] + m[1, 2]*m[1, 2]) T2 := math.atan2(S2, m[1, 1]) @@ -641,7 +697,8 @@ euler_angles_yxy_from_matrix3_f64 :: proc(m: Matrix3f64) -> (t1, t2, t3: f64) { return } -euler_angles_yzy_from_matrix3_f64 :: proc(m: Matrix3f64) -> (t1, t2, t3: f64) { +@(require_results) +euler_angles_yzy_from_matrix3_f64 :: proc "contextless" (m: Matrix3f64) -> (t1, t2, t3: f64) { T1 := math.atan2(m[2, 1], -m[0, 1]) S2 := math.sqrt(m[1, 0]*m[1, 0] + m[1, 2]*m[1, 2]) T2 := math.atan2(S2, m[1, 1]) @@ -653,7 +710,8 @@ euler_angles_yzy_from_matrix3_f64 :: proc(m: Matrix3f64) -> (t1, t2, t3: f64) { t3 = T3 return } -euler_angles_zyz_from_matrix3_f64 :: proc(m: Matrix3f64) -> (t1, t2, t3: f64) { +@(require_results) +euler_angles_zyz_from_matrix3_f64 :: proc "contextless" (m: Matrix3f64) -> (t1, t2, t3: f64) { T1 := math.atan2(m[1, 2], m[0, 2]) S2 := math.sqrt(m[2, 0]*m[2, 0] + m[2, 1]*m[2, 1]) T2 := math.atan2(S2, m[2, 2]) @@ -666,7 +724,8 @@ euler_angles_zyz_from_matrix3_f64 :: proc(m: Matrix3f64) -> (t1, t2, t3: f64) { return } -euler_angles_zxz_from_matrix3_f64 :: proc(m: Matrix3f64) -> (t1, t2, t3: f64) { +@(require_results) +euler_angles_zxz_from_matrix3_f64 :: proc "contextless" (m: Matrix3f64) -> (t1, t2, t3: f64) { T1 := math.atan2(m[0, 2], -m[1, 2]) S2 := math.sqrt(m[2, 0]*m[2, 0] + m[2, 1]*m[2, 1]) T2 := math.atan2(S2, m[2, 2]) @@ -679,7 +738,8 @@ euler_angles_zxz_from_matrix3_f64 :: proc(m: Matrix3f64) -> (t1, t2, t3: f64) { return } -euler_angles_xzy_from_matrix3_f64 :: proc(m: Matrix3f64) -> (t1, t2, t3: f64) { +@(require_results) +euler_angles_xzy_from_matrix3_f64 :: proc "contextless" (m: Matrix3f64) -> (t1, t2, t3: f64) { T1 := math.atan2(m[2, 1], m[1, 1]) C2 := math.sqrt(m[0, 0]*m[0, 0] + m[0, 2]*m[0, 2]) T2 := math.atan2(-m[0, 1], C2) @@ -692,7 +752,8 @@ euler_angles_xzy_from_matrix3_f64 :: proc(m: Matrix3f64) -> (t1, t2, t3: f64) { return } -euler_angles_yzx_from_matrix3_f64 :: proc(m: Matrix3f64) -> (t1, t2, t3: f64) { +@(require_results) +euler_angles_yzx_from_matrix3_f64 :: proc "contextless" (m: Matrix3f64) -> (t1, t2, t3: f64) { T1 := math.atan2(-m[2, 0], m[0, 0]) C2 := math.sqrt(m[1, 1]*m[1, 1] + m[1, 2]*m[1, 2]) T2 := math.atan2(m[1, 0], C2) @@ -705,7 +766,8 @@ euler_angles_yzx_from_matrix3_f64 :: proc(m: Matrix3f64) -> (t1, t2, t3: f64) { return } -euler_angles_zyx_from_matrix3_f64 :: proc(m: Matrix3f64) -> (t1, t2, t3: f64) { +@(require_results) +euler_angles_zyx_from_matrix3_f64 :: proc "contextless" (m: Matrix3f64) -> (t1, t2, t3: f64) { T1 := math.atan2(m[1, 0], m[0, 0]) C2 := math.sqrt(m[2, 1]*m[2, 1] + m[2, 2]*m[2, 2]) T2 := math.atan2(-m[2, 0], C2) @@ -718,7 +780,8 @@ euler_angles_zyx_from_matrix3_f64 :: proc(m: Matrix3f64) -> (t1, t2, t3: f64) { return } -euler_angles_zxy_from_matrix3_f64 :: proc(m: Matrix3f64) -> (t1, t2, t3: f64) { +@(require_results) +euler_angles_zxy_from_matrix3_f64 :: proc "contextless" (m: Matrix3f64) -> (t1, t2, t3: f64) { T1 := math.atan2(-m[0, 1], m[1, 1]) C2 := math.sqrt(m[2, 0]*m[2, 0] + m[2, 2]*m[2, 2]) T2 := math.atan2(m[2, 1], C2) @@ -735,7 +798,8 @@ euler_angles_zxy_from_matrix3_f64 :: proc(m: Matrix3f64) -> (t1, t2, t3: f64) { // Matrix4 -matrix4_from_euler_angle_x_f64 :: proc(angle_x: f64) -> (m: Matrix4f64) { +@(require_results) +matrix4_from_euler_angle_x_f64 :: proc "contextless" (angle_x: f64) -> (m: Matrix4f64) { cos_x, sin_x := math.cos(angle_x), math.sin(angle_x) m[0, 0] = 1 m[1, 1] = +cos_x @@ -745,7 +809,8 @@ matrix4_from_euler_angle_x_f64 :: proc(angle_x: f64) -> (m: Matrix4f64) { m[3, 3] = 1 return } -matrix4_from_euler_angle_y_f64 :: proc(angle_y: f64) -> (m: Matrix4f64) { +@(require_results) +matrix4_from_euler_angle_y_f64 :: proc "contextless" (angle_y: f64) -> (m: Matrix4f64) { cos_y, sin_y := math.cos(angle_y), math.sin(angle_y) m[0, 0] = +cos_y m[0, 2] = -sin_y @@ -755,7 +820,8 @@ matrix4_from_euler_angle_y_f64 :: proc(angle_y: f64) -> (m: Matrix4f64) { m[3, 3] = 1 return } -matrix4_from_euler_angle_z_f64 :: proc(angle_z: f64) -> (m: Matrix4f64) { +@(require_results) +matrix4_from_euler_angle_z_f64 :: proc "contextless" (angle_z: f64) -> (m: Matrix4f64) { cos_z, sin_z := math.cos(angle_z), math.sin(angle_z) m[0, 0] = +cos_z m[0, 1] = +sin_z @@ -767,7 +833,8 @@ matrix4_from_euler_angle_z_f64 :: proc(angle_z: f64) -> (m: Matrix4f64) { } -matrix4_from_derived_euler_angle_x_f64 :: proc(angle_x: f64, angular_velocity_x: f64) -> (m: Matrix4f64) { +@(require_results) +matrix4_from_derived_euler_angle_x_f64 :: proc "contextless" (angle_x: f64, angular_velocity_x: f64) -> (m: Matrix4f64) { cos_x := math.cos(angle_x) * angular_velocity_x sin_x := math.sin(angle_x) * angular_velocity_x m[0, 0] = 1 @@ -778,7 +845,8 @@ matrix4_from_derived_euler_angle_x_f64 :: proc(angle_x: f64, angular_velocity_x: m[3, 3] = 1 return } -matrix4_from_derived_euler_angle_y_f64 :: proc(angle_y: f64, angular_velocity_y: f64) -> (m: Matrix4f64) { +@(require_results) +matrix4_from_derived_euler_angle_y_f64 :: proc "contextless" (angle_y: f64, angular_velocity_y: f64) -> (m: Matrix4f64) { cos_y := math.cos(angle_y) * angular_velocity_y sin_y := math.sin(angle_y) * angular_velocity_y m[0, 0] = +cos_y @@ -789,7 +857,8 @@ matrix4_from_derived_euler_angle_y_f64 :: proc(angle_y: f64, angular_velocity_y: m[3, 3] = 1 return } -matrix4_from_derived_euler_angle_z_f64 :: proc(angle_z: f64, angular_velocity_z: f64) -> (m: Matrix4f64) { +@(require_results) +matrix4_from_derived_euler_angle_z_f64 :: proc "contextless" (angle_z: f64, angular_velocity_z: f64) -> (m: Matrix4f64) { cos_z := math.cos(angle_z) * angular_velocity_z sin_z := math.sin(angle_z) * angular_velocity_z m[0, 0] = +cos_z @@ -802,7 +871,8 @@ matrix4_from_derived_euler_angle_z_f64 :: proc(angle_z: f64, angular_velocity_z: } -matrix4_from_euler_angles_xy_f64 :: proc(angle_x, angle_y: f64) -> (m: Matrix4f64) { +@(require_results) +matrix4_from_euler_angles_xy_f64 :: proc "contextless" (angle_x, angle_y: f64) -> (m: Matrix4f64) { cos_x, sin_x := math.cos(angle_x), math.sin(angle_x) cos_y, sin_y := math.cos(angle_y), math.sin(angle_y) m[0, 0] = cos_y @@ -818,7 +888,8 @@ matrix4_from_euler_angles_xy_f64 :: proc(angle_x, angle_y: f64) -> (m: Matrix4f6 } -matrix4_from_euler_angles_yx_f64 :: proc(angle_y, angle_x: f64) -> (m: Matrix4f64) { +@(require_results) +matrix4_from_euler_angles_yx_f64 :: proc "contextless" (angle_y, angle_x: f64) -> (m: Matrix4f64) { cos_x, sin_x := math.cos(angle_x), math.sin(angle_x) cos_y, sin_y := math.cos(angle_y), math.sin(angle_y) m[0, 0] = cos_y @@ -833,21 +904,26 @@ matrix4_from_euler_angles_yx_f64 :: proc(angle_y, angle_x: f64) -> (m: Matrix4f6 return } -matrix4_from_euler_angles_xz_f64 :: proc(angle_x, angle_z: f64) -> (m: Matrix4f64) { +@(require_results) +matrix4_from_euler_angles_xz_f64 :: proc "contextless" (angle_x, angle_z: f64) -> (m: Matrix4f64) { return mul(matrix4_from_euler_angle_x(angle_x), matrix4_from_euler_angle_z(angle_z)) } -matrix4_from_euler_angles_zx_f64 :: proc(angle_z, angle_x: f64) -> (m: Matrix4f64) { +@(require_results) +matrix4_from_euler_angles_zx_f64 :: proc "contextless" (angle_z, angle_x: f64) -> (m: Matrix4f64) { return mul(matrix4_from_euler_angle_z(angle_z), matrix4_from_euler_angle_x(angle_x)) } -matrix4_from_euler_angles_yz_f64 :: proc(angle_y, angle_z: f64) -> (m: Matrix4f64) { +@(require_results) +matrix4_from_euler_angles_yz_f64 :: proc "contextless" (angle_y, angle_z: f64) -> (m: Matrix4f64) { return mul(matrix4_from_euler_angle_y(angle_y), matrix4_from_euler_angle_z(angle_z)) } -matrix4_from_euler_angles_zy_f64 :: proc(angle_z, angle_y: f64) -> (m: Matrix4f64) { +@(require_results) +matrix4_from_euler_angles_zy_f64 :: proc "contextless" (angle_z, angle_y: f64) -> (m: Matrix4f64) { return mul(matrix4_from_euler_angle_z(angle_z), matrix4_from_euler_angle_y(angle_y)) } -matrix4_from_euler_angles_xyz_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix4f64) { +@(require_results) +matrix4_from_euler_angles_xyz_f64 :: proc "contextless" (t1, t2, t3: f64) -> (m: Matrix4f64) { c1 := math.cos(-t1) c2 := math.cos(-t2) c3 := math.cos(-t3) @@ -874,7 +950,8 @@ matrix4_from_euler_angles_xyz_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix4f64) { return } -matrix4_from_euler_angles_yxz_f64 :: proc(yaw, pitch, roll: f64) -> (m: Matrix4f64) { +@(require_results) +matrix4_from_euler_angles_yxz_f64 :: proc "contextless" (yaw, pitch, roll: f64) -> (m: Matrix4f64) { ch := math.cos(yaw) sh := math.sin(yaw) cp := math.cos(pitch) @@ -901,7 +978,8 @@ matrix4_from_euler_angles_yxz_f64 :: proc(yaw, pitch, roll: f64) -> (m: Matrix4f return } -matrix4_from_euler_angles_xzx_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix4f64) { +@(require_results) +matrix4_from_euler_angles_xzx_f64 :: proc "contextless" (t1, t2, t3: f64) -> (m: Matrix4f64) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -928,7 +1006,8 @@ matrix4_from_euler_angles_xzx_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix4f64) { return } -matrix4_from_euler_angles_xyx_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix4f64) { +@(require_results) +matrix4_from_euler_angles_xyx_f64 :: proc "contextless" (t1, t2, t3: f64) -> (m: Matrix4f64) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -955,7 +1034,8 @@ matrix4_from_euler_angles_xyx_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix4f64) { return } -matrix4_from_euler_angles_yxy_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix4f64) { +@(require_results) +matrix4_from_euler_angles_yxy_f64 :: proc "contextless" (t1, t2, t3: f64) -> (m: Matrix4f64) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -982,7 +1062,8 @@ matrix4_from_euler_angles_yxy_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix4f64) { return } -matrix4_from_euler_angles_yzy_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix4f64) { +@(require_results) +matrix4_from_euler_angles_yzy_f64 :: proc "contextless" (t1, t2, t3: f64) -> (m: Matrix4f64) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -1009,7 +1090,8 @@ matrix4_from_euler_angles_yzy_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix4f64) { return } -matrix4_from_euler_angles_zyz_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix4f64) { +@(require_results) +matrix4_from_euler_angles_zyz_f64 :: proc "contextless" (t1, t2, t3: f64) -> (m: Matrix4f64) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -1036,7 +1118,8 @@ matrix4_from_euler_angles_zyz_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix4f64) { return } -matrix4_from_euler_angles_zxz_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix4f64) { +@(require_results) +matrix4_from_euler_angles_zxz_f64 :: proc "contextless" (t1, t2, t3: f64) -> (m: Matrix4f64) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -1064,7 +1147,8 @@ matrix4_from_euler_angles_zxz_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix4f64) { } -matrix4_from_euler_angles_xzy_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix4f64) { +@(require_results) +matrix4_from_euler_angles_xzy_f64 :: proc "contextless" (t1, t2, t3: f64) -> (m: Matrix4f64) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -1091,7 +1175,8 @@ matrix4_from_euler_angles_xzy_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix4f64) { return } -matrix4_from_euler_angles_yzx_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix4f64) { +@(require_results) +matrix4_from_euler_angles_yzx_f64 :: proc "contextless" (t1, t2, t3: f64) -> (m: Matrix4f64) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -1118,7 +1203,8 @@ matrix4_from_euler_angles_yzx_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix4f64) { return } -matrix4_from_euler_angles_zyx_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix4f64) { +@(require_results) +matrix4_from_euler_angles_zyx_f64 :: proc "contextless" (t1, t2, t3: f64) -> (m: Matrix4f64) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -1145,7 +1231,8 @@ matrix4_from_euler_angles_zyx_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix4f64) { return } -matrix4_from_euler_angles_zxy_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix4f64) { +@(require_results) +matrix4_from_euler_angles_zxy_f64 :: proc "contextless" (t1, t2, t3: f64) -> (m: Matrix4f64) { c1 := math.cos(t1) s1 := math.sin(t1) c2 := math.cos(t2) @@ -1173,7 +1260,8 @@ matrix4_from_euler_angles_zxy_f64 :: proc(t1, t2, t3: f64) -> (m: Matrix4f64) { } -matrix4_from_yaw_pitch_roll_f64 :: proc(yaw, pitch, roll: f64) -> (m: Matrix4f64) { +@(require_results) +matrix4_from_yaw_pitch_roll_f64 :: proc "contextless" (yaw, pitch, roll: f64) -> (m: Matrix4f64) { ch := math.cos(yaw) sh := math.sin(yaw) cp := math.cos(pitch) @@ -1200,7 +1288,8 @@ matrix4_from_yaw_pitch_roll_f64 :: proc(yaw, pitch, roll: f64) -> (m: Matrix4f64 return m } -euler_angles_xyz_from_matrix4_f64 :: proc(m: Matrix4f64) -> (t1, t2, t3: f64) { +@(require_results) +euler_angles_xyz_from_matrix4_f64 :: proc "contextless" (m: Matrix4f64) -> (t1, t2, t3: f64) { T1 := math.atan2(m[1, 2], m[2, 2]) C2 := math.sqrt(m[0, 0]*m[0, 0] + m[0, 1]*m[0, 1]) T2 := math.atan2(-m[0, 2], C2) @@ -1213,7 +1302,8 @@ euler_angles_xyz_from_matrix4_f64 :: proc(m: Matrix4f64) -> (t1, t2, t3: f64) { return } -euler_angles_yxz_from_matrix4_f64 :: proc(m: Matrix4f64) -> (t1, t2, t3: f64) { +@(require_results) +euler_angles_yxz_from_matrix4_f64 :: proc "contextless" (m: Matrix4f64) -> (t1, t2, t3: f64) { T1 := math.atan2(m[0, 2], m[2, 2]) C2 := math.sqrt(m[1, 0]*m[1, 0] + m[1, 1]*m[1, 1]) T2 := math.atan2(-m[1, 2], C2) @@ -1226,7 +1316,8 @@ euler_angles_yxz_from_matrix4_f64 :: proc(m: Matrix4f64) -> (t1, t2, t3: f64) { return } -euler_angles_xzx_from_matrix4_f64 :: proc(m: Matrix4f64) -> (t1, t2, t3: f64) { +@(require_results) +euler_angles_xzx_from_matrix4_f64 :: proc "contextless" (m: Matrix4f64) -> (t1, t2, t3: f64) { T1 := math.atan2(m[2, 0], m[1, 0]) S2 := math.sqrt(m[0, 1]*m[0, 1] + m[0, 2]*m[0, 2]) T2 := math.atan2(S2, m[0, 0]) @@ -1239,7 +1330,8 @@ euler_angles_xzx_from_matrix4_f64 :: proc(m: Matrix4f64) -> (t1, t2, t3: f64) { return } -euler_angles_xyx_from_matrix4_f64 :: proc(m: Matrix4f64) -> (t1, t2, t3: f64) { +@(require_results) +euler_angles_xyx_from_matrix4_f64 :: proc "contextless" (m: Matrix4f64) -> (t1, t2, t3: f64) { T1 := math.atan2(m[1, 0], -m[2, 0]) S2 := math.sqrt(m[0, 1]*m[0, 1] + m[0, 2]*m[0, 2]) T2 := math.atan2(S2, m[0, 0]) @@ -1252,7 +1344,8 @@ euler_angles_xyx_from_matrix4_f64 :: proc(m: Matrix4f64) -> (t1, t2, t3: f64) { return } -euler_angles_yxy_from_matrix4_f64 :: proc(m: Matrix4f64) -> (t1, t2, t3: f64) { +@(require_results) +euler_angles_yxy_from_matrix4_f64 :: proc "contextless" (m: Matrix4f64) -> (t1, t2, t3: f64) { T1 := math.atan2(m[0, 1], m[2, 1]) S2 := math.sqrt(m[1, 0]*m[1, 0] + m[1, 2]*m[1, 2]) T2 := math.atan2(S2, m[1, 1]) @@ -1265,7 +1358,8 @@ euler_angles_yxy_from_matrix4_f64 :: proc(m: Matrix4f64) -> (t1, t2, t3: f64) { return } -euler_angles_yzy_from_matrix4_f64 :: proc(m: Matrix4f64) -> (t1, t2, t3: f64) { +@(require_results) +euler_angles_yzy_from_matrix4_f64 :: proc "contextless" (m: Matrix4f64) -> (t1, t2, t3: f64) { T1 := math.atan2(m[2, 1], -m[0, 1]) S2 := math.sqrt(m[1, 0]*m[1, 0] + m[1, 2]*m[1, 2]) T2 := math.atan2(S2, m[1, 1]) @@ -1277,7 +1371,8 @@ euler_angles_yzy_from_matrix4_f64 :: proc(m: Matrix4f64) -> (t1, t2, t3: f64) { t3 = T3 return } -euler_angles_zyz_from_matrix4_f64 :: proc(m: Matrix4f64) -> (t1, t2, t3: f64) { +@(require_results) +euler_angles_zyz_from_matrix4_f64 :: proc "contextless" (m: Matrix4f64) -> (t1, t2, t3: f64) { T1 := math.atan2(m[1, 2], m[0, 2]) S2 := math.sqrt(m[2, 0]*m[2, 0] + m[2, 1]*m[2, 1]) T2 := math.atan2(S2, m[2, 2]) @@ -1290,7 +1385,8 @@ euler_angles_zyz_from_matrix4_f64 :: proc(m: Matrix4f64) -> (t1, t2, t3: f64) { return } -euler_angles_zxz_from_matrix4_f64 :: proc(m: Matrix4f64) -> (t1, t2, t3: f64) { +@(require_results) +euler_angles_zxz_from_matrix4_f64 :: proc "contextless" (m: Matrix4f64) -> (t1, t2, t3: f64) { T1 := math.atan2(m[0, 2], -m[1, 2]) S2 := math.sqrt(m[2, 0]*m[2, 0] + m[2, 1]*m[2, 1]) T2 := math.atan2(S2, m[2, 2]) @@ -1303,7 +1399,8 @@ euler_angles_zxz_from_matrix4_f64 :: proc(m: Matrix4f64) -> (t1, t2, t3: f64) { return } -euler_angles_xzy_from_matrix4_f64 :: proc(m: Matrix4f64) -> (t1, t2, t3: f64) { +@(require_results) +euler_angles_xzy_from_matrix4_f64 :: proc "contextless" (m: Matrix4f64) -> (t1, t2, t3: f64) { T1 := math.atan2(m[2, 1], m[1, 1]) C2 := math.sqrt(m[0, 0]*m[0, 0] + m[0, 2]*m[0, 2]) T2 := math.atan2(-m[0, 1], C2) @@ -1316,7 +1413,8 @@ euler_angles_xzy_from_matrix4_f64 :: proc(m: Matrix4f64) -> (t1, t2, t3: f64) { return } -euler_angles_yzx_from_matrix4_f64 :: proc(m: Matrix4f64) -> (t1, t2, t3: f64) { +@(require_results) +euler_angles_yzx_from_matrix4_f64 :: proc "contextless" (m: Matrix4f64) -> (t1, t2, t3: f64) { T1 := math.atan2(-m[2, 0], m[0, 0]) C2 := math.sqrt(m[1, 1]*m[1, 1] + m[1, 2]*m[1, 2]) T2 := math.atan2(m[1, 0], C2) @@ -1329,7 +1427,8 @@ euler_angles_yzx_from_matrix4_f64 :: proc(m: Matrix4f64) -> (t1, t2, t3: f64) { return } -euler_angles_zyx_from_matrix4_f64 :: proc(m: Matrix4f64) -> (t1, t2, t3: f64) { +@(require_results) +euler_angles_zyx_from_matrix4_f64 :: proc "contextless" (m: Matrix4f64) -> (t1, t2, t3: f64) { T1 := math.atan2(m[1, 0], m[0, 0]) C2 := math.sqrt(m[2, 1]*m[2, 1] + m[2, 2]*m[2, 2]) T2 := math.atan2(-m[2, 0], C2) @@ -1342,7 +1441,8 @@ euler_angles_zyx_from_matrix4_f64 :: proc(m: Matrix4f64) -> (t1, t2, t3: f64) { return } -euler_angles_zxy_from_matrix4_f64 :: proc(m: Matrix4f64) -> (t1, t2, t3: f64) { +@(require_results) +euler_angles_zxy_from_matrix4_f64 :: proc "contextless" (m: Matrix4f64) -> (t1, t2, t3: f64) { T1 := math.atan2(-m[0, 1], m[1, 1]) C2 := math.sqrt(m[2, 0]*m[2, 0] + m[2, 2]*m[2, 2]) T2 := math.atan2(m[2, 1], C2) diff --git a/core/math/linalg/swizzle.odin b/core/math/linalg/swizzle.odin index ada4aebcf..f1dafbeca 100644 --- a/core/math/linalg/swizzle.odin +++ b/core/math/linalg/swizzle.odin @@ -37,110 +37,142 @@ Vector4_Components :: enum u8 { a = 3, } -scalar_f32_swizzle1 :: proc(f: f32, c0: Scalar_Components) -> f32 { +@(require_results) +scalar_f32_swizzle1 :: proc "contextless" (f: f32, c0: Scalar_Components) -> f32 { return f } -scalar_f32_swizzle2 :: proc(f: f32, c0, c1: Scalar_Components) -> Vector2f32 { +@(require_results) +scalar_f32_swizzle2 :: proc "contextless" (f: f32, c0, c1: Scalar_Components) -> Vector2f32 { return {f, f} } -scalar_f32_swizzle3 :: proc(f: f32, c0, c1, c2: Scalar_Components) -> Vector3f32 { +@(require_results) +scalar_f32_swizzle3 :: proc "contextless" (f: f32, c0, c1, c2: Scalar_Components) -> Vector3f32 { return {f, f, f} } -scalar_f32_swizzle4 :: proc(f: f32, c0, c1, c2, c3: Scalar_Components) -> Vector4f32 { +@(require_results) +scalar_f32_swizzle4 :: proc "contextless" (f: f32, c0, c1, c2, c3: Scalar_Components) -> Vector4f32 { return {f, f, f, f} } -vector2f32_swizzle1 :: proc(v: Vector2f32, c0: Vector2_Components) -> f32 { +@(require_results) +vector2f32_swizzle1 :: proc "contextless" (v: Vector2f32, c0: Vector2_Components) -> f32 { return v[c0] } -vector2f32_swizzle2 :: proc(v: Vector2f32, c0, c1: Vector2_Components) -> Vector2f32 { +@(require_results) +vector2f32_swizzle2 :: proc "contextless" (v: Vector2f32, c0, c1: Vector2_Components) -> Vector2f32 { return {v[c0], v[c1]} } -vector2f32_swizzle3 :: proc(v: Vector2f32, c0, c1, c2: Vector2_Components) -> Vector3f32 { +@(require_results) +vector2f32_swizzle3 :: proc "contextless" (v: Vector2f32, c0, c1, c2: Vector2_Components) -> Vector3f32 { return {v[c0], v[c1], v[c2]} } -vector2f32_swizzle4 :: proc(v: Vector2f32, c0, c1, c2, c3: Vector2_Components) -> Vector4f32 { +@(require_results) +vector2f32_swizzle4 :: proc "contextless" (v: Vector2f32, c0, c1, c2, c3: Vector2_Components) -> Vector4f32 { return {v[c0], v[c1], v[c2], v[c3]} } -vector3f32_swizzle1 :: proc(v: Vector3f32, c0: Vector3_Components) -> f32 { +@(require_results) +vector3f32_swizzle1 :: proc "contextless" (v: Vector3f32, c0: Vector3_Components) -> f32 { return v[c0] } -vector3f32_swizzle2 :: proc(v: Vector3f32, c0, c1: Vector3_Components) -> Vector2f32 { +@(require_results) +vector3f32_swizzle2 :: proc "contextless" (v: Vector3f32, c0, c1: Vector3_Components) -> Vector2f32 { return {v[c0], v[c1]} } -vector3f32_swizzle3 :: proc(v: Vector3f32, c0, c1, c2: Vector3_Components) -> Vector3f32 { +@(require_results) +vector3f32_swizzle3 :: proc "contextless" (v: Vector3f32, c0, c1, c2: Vector3_Components) -> Vector3f32 { return {v[c0], v[c1], v[c2]} } -vector3f32_swizzle4 :: proc(v: Vector3f32, c0, c1, c2, c3: Vector3_Components) -> Vector4f32 { +@(require_results) +vector3f32_swizzle4 :: proc "contextless" (v: Vector3f32, c0, c1, c2, c3: Vector3_Components) -> Vector4f32 { return {v[c0], v[c1], v[c2], v[c3]} } -vector4f32_swizzle1 :: proc(v: Vector4f32, c0: Vector4_Components) -> f32 { +@(require_results) +vector4f32_swizzle1 :: proc "contextless" (v: Vector4f32, c0: Vector4_Components) -> f32 { return v[c0] } -vector4f32_swizzle2 :: proc(v: Vector4f32, c0, c1: Vector4_Components) -> Vector2f32 { +@(require_results) +vector4f32_swizzle2 :: proc "contextless" (v: Vector4f32, c0, c1: Vector4_Components) -> Vector2f32 { return {v[c0], v[c1]} } -vector4f32_swizzle3 :: proc(v: Vector4f32, c0, c1, c2: Vector4_Components) -> Vector3f32 { +@(require_results) +vector4f32_swizzle3 :: proc "contextless" (v: Vector4f32, c0, c1, c2: Vector4_Components) -> Vector3f32 { return {v[c0], v[c1], v[c2]} } -vector4f32_swizzle4 :: proc(v: Vector4f32, c0, c1, c2, c3: Vector4_Components) -> Vector4f32 { +@(require_results) +vector4f32_swizzle4 :: proc "contextless" (v: Vector4f32, c0, c1, c2, c3: Vector4_Components) -> Vector4f32 { return {v[c0], v[c1], v[c2], v[c3]} } -scalar_f64_swizzle1 :: proc(f: f64, c0: Scalar_Components) -> f64 { +@(require_results) +scalar_f64_swizzle1 :: proc "contextless" (f: f64, c0: Scalar_Components) -> f64 { return f } -scalar_f64_swizzle2 :: proc(f: f64, c0, c1: Scalar_Components) -> Vector2f64 { +@(require_results) +scalar_f64_swizzle2 :: proc "contextless" (f: f64, c0, c1: Scalar_Components) -> Vector2f64 { return {f, f} } -scalar_f64_swizzle3 :: proc(f: f64, c0, c1, c2: Scalar_Components) -> Vector3f64 { +@(require_results) +scalar_f64_swizzle3 :: proc "contextless" (f: f64, c0, c1, c2: Scalar_Components) -> Vector3f64 { return {f, f, f} } -scalar_f64_swizzle4 :: proc(f: f64, c0, c1, c2, c3: Scalar_Components) -> Vector4f64 { +@(require_results) +scalar_f64_swizzle4 :: proc "contextless" (f: f64, c0, c1, c2, c3: Scalar_Components) -> Vector4f64 { return {f, f, f, f} } -vector2f64_swizzle1 :: proc(v: Vector2f64, c0: Vector2_Components) -> f64 { +@(require_results) +vector2f64_swizzle1 :: proc "contextless" (v: Vector2f64, c0: Vector2_Components) -> f64 { return v[c0] } -vector2f64_swizzle2 :: proc(v: Vector2f64, c0, c1: Vector2_Components) -> Vector2f64 { +@(require_results) +vector2f64_swizzle2 :: proc "contextless" (v: Vector2f64, c0, c1: Vector2_Components) -> Vector2f64 { return {v[c0], v[c1]} } -vector2f64_swizzle3 :: proc(v: Vector2f64, c0, c1, c2: Vector2_Components) -> Vector3f64 { +@(require_results) +vector2f64_swizzle3 :: proc "contextless" (v: Vector2f64, c0, c1, c2: Vector2_Components) -> Vector3f64 { return {v[c0], v[c1], v[c2]} } -vector2f64_swizzle4 :: proc(v: Vector2f64, c0, c1, c2, c3: Vector2_Components) -> Vector4f64 { +@(require_results) +vector2f64_swizzle4 :: proc "contextless" (v: Vector2f64, c0, c1, c2, c3: Vector2_Components) -> Vector4f64 { return {v[c0], v[c1], v[c2], v[c3]} } -vector3f64_swizzle1 :: proc(v: Vector3f64, c0: Vector3_Components) -> f64 { +@(require_results) +vector3f64_swizzle1 :: proc "contextless" (v: Vector3f64, c0: Vector3_Components) -> f64 { return v[c0] } -vector3f64_swizzle2 :: proc(v: Vector3f64, c0, c1: Vector3_Components) -> Vector2f64 { +@(require_results) +vector3f64_swizzle2 :: proc "contextless" (v: Vector3f64, c0, c1: Vector3_Components) -> Vector2f64 { return {v[c0], v[c1]} } -vector3f64_swizzle3 :: proc(v: Vector3f64, c0, c1, c2: Vector3_Components) -> Vector3f64 { +@(require_results) +vector3f64_swizzle3 :: proc "contextless" (v: Vector3f64, c0, c1, c2: Vector3_Components) -> Vector3f64 { return {v[c0], v[c1], v[c2]} } -vector3f64_swizzle4 :: proc(v: Vector3f64, c0, c1, c2, c3: Vector3_Components) -> Vector4f64 { +@(require_results) +vector3f64_swizzle4 :: proc "contextless" (v: Vector3f64, c0, c1, c2, c3: Vector3_Components) -> Vector4f64 { return {v[c0], v[c1], v[c2], v[c3]} } -vector4f64_swizzle1 :: proc(v: Vector4f64, c0: Vector4_Components) -> f64 { +@(require_results) +vector4f64_swizzle1 :: proc "contextless" (v: Vector4f64, c0: Vector4_Components) -> f64 { return v[c0] } -vector4f64_swizzle2 :: proc(v: Vector4f64, c0, c1: Vector4_Components) -> Vector2f64 { +@(require_results) +vector4f64_swizzle2 :: proc "contextless" (v: Vector4f64, c0, c1: Vector4_Components) -> Vector2f64 { return {v[c0], v[c1]} } -vector4f64_swizzle3 :: proc(v: Vector4f64, c0, c1, c2: Vector4_Components) -> Vector3f64 { +@(require_results) +vector4f64_swizzle3 :: proc "contextless" (v: Vector4f64, c0, c1, c2: Vector4_Components) -> Vector3f64 { return {v[c0], v[c1], v[c2]} } -vector4f64_swizzle4 :: proc(v: Vector4f64, c0, c1, c2, c3: Vector4_Components) -> Vector4f64 { +@(require_results) +vector4f64_swizzle4 :: proc "contextless" (v: Vector4f64, c0, c1, c2, c3: Vector4_Components) -> Vector4f64 { return {v[c0], v[c1], v[c2], v[c3]} } diff --git a/core/math/math.odin b/core/math/math.odin index 12fe1bfd7..05177378f 100644 --- a/core/math/math.odin +++ b/core/math/math.odin @@ -42,90 +42,91 @@ min :: builtin.min max :: builtin.max clamp :: builtin.clamp -sqrt_f16le :: proc "contextless" (x: f16le) -> f16le { return #force_inline f16le(sqrt_f16(f16(x))) } -sqrt_f16be :: proc "contextless" (x: f16be) -> f16be { return #force_inline f16be(sqrt_f16(f16(x))) } -sqrt_f32le :: proc "contextless" (x: f32le) -> f32le { return #force_inline f32le(sqrt_f32(f32(x))) } -sqrt_f32be :: proc "contextless" (x: f32be) -> f32be { return #force_inline f32be(sqrt_f32(f32(x))) } -sqrt_f64le :: proc "contextless" (x: f64le) -> f64le { return #force_inline f64le(sqrt_f64(f64(x))) } -sqrt_f64be :: proc "contextless" (x: f64be) -> f64be { return #force_inline f64be(sqrt_f64(f64(x))) } -sqrt :: proc{ +@(require_results) sqrt_f16le :: proc "contextless" (x: f16le) -> f16le { return #force_inline f16le(sqrt_f16(f16(x))) } +@(require_results) sqrt_f16be :: proc "contextless" (x: f16be) -> f16be { return #force_inline f16be(sqrt_f16(f16(x))) } +@(require_results) sqrt_f32le :: proc "contextless" (x: f32le) -> f32le { return #force_inline f32le(sqrt_f32(f32(x))) } +@(require_results) sqrt_f32be :: proc "contextless" (x: f32be) -> f32be { return #force_inline f32be(sqrt_f32(f32(x))) } +@(require_results) sqrt_f64le :: proc "contextless" (x: f64le) -> f64le { return #force_inline f64le(sqrt_f64(f64(x))) } +@(require_results) sqrt_f64be :: proc "contextless" (x: f64be) -> f64be { return #force_inline f64be(sqrt_f64(f64(x))) } +sqrt :: proc{ sqrt_f16, sqrt_f16le, sqrt_f16be, sqrt_f32, sqrt_f32le, sqrt_f32be, sqrt_f64, sqrt_f64le, sqrt_f64be, } -sin_f16le :: proc "contextless" (Īø: f16le) -> f16le { return #force_inline f16le(sin_f16(f16(Īø))) } -sin_f16be :: proc "contextless" (Īø: f16be) -> f16be { return #force_inline f16be(sin_f16(f16(Īø))) } -sin_f32le :: proc "contextless" (Īø: f32le) -> f32le { return #force_inline f32le(sin_f32(f32(Īø))) } -sin_f32be :: proc "contextless" (Īø: f32be) -> f32be { return #force_inline f32be(sin_f32(f32(Īø))) } -sin_f64le :: proc "contextless" (Īø: f64le) -> f64le { return #force_inline f64le(sin_f64(f64(Īø))) } -sin_f64be :: proc "contextless" (Īø: f64be) -> f64be { return #force_inline f64be(sin_f64(f64(Īø))) } -sin :: proc{ +@(require_results) sin_f16le :: proc "contextless" (Īø: f16le) -> f16le { return #force_inline f16le(sin_f16(f16(Īø))) } +@(require_results) sin_f16be :: proc "contextless" (Īø: f16be) -> f16be { return #force_inline f16be(sin_f16(f16(Īø))) } +@(require_results) sin_f32le :: proc "contextless" (Īø: f32le) -> f32le { return #force_inline f32le(sin_f32(f32(Īø))) } +@(require_results) sin_f32be :: proc "contextless" (Īø: f32be) -> f32be { return #force_inline f32be(sin_f32(f32(Īø))) } +@(require_results) sin_f64le :: proc "contextless" (Īø: f64le) -> f64le { return #force_inline f64le(sin_f64(f64(Īø))) } +@(require_results) sin_f64be :: proc "contextless" (Īø: f64be) -> f64be { return #force_inline f64be(sin_f64(f64(Īø))) } +sin :: proc{ sin_f16, sin_f16le, sin_f16be, sin_f32, sin_f32le, sin_f32be, sin_f64, sin_f64le, sin_f64be, } -cos_f16le :: proc "contextless" (Īø: f16le) -> f16le { return #force_inline f16le(cos_f16(f16(Īø))) } -cos_f16be :: proc "contextless" (Īø: f16be) -> f16be { return #force_inline f16be(cos_f16(f16(Īø))) } -cos_f32le :: proc "contextless" (Īø: f32le) -> f32le { return #force_inline f32le(cos_f32(f32(Īø))) } -cos_f32be :: proc "contextless" (Īø: f32be) -> f32be { return #force_inline f32be(cos_f32(f32(Īø))) } -cos_f64le :: proc "contextless" (Īø: f64le) -> f64le { return #force_inline f64le(cos_f64(f64(Īø))) } -cos_f64be :: proc "contextless" (Īø: f64be) -> f64be { return #force_inline f64be(cos_f64(f64(Īø))) } -cos :: proc{ +@(require_results) cos_f16le :: proc "contextless" (Īø: f16le) -> f16le { return #force_inline f16le(cos_f16(f16(Īø))) } +@(require_results) cos_f16be :: proc "contextless" (Īø: f16be) -> f16be { return #force_inline f16be(cos_f16(f16(Īø))) } +@(require_results) cos_f32le :: proc "contextless" (Īø: f32le) -> f32le { return #force_inline f32le(cos_f32(f32(Īø))) } +@(require_results) cos_f32be :: proc "contextless" (Īø: f32be) -> f32be { return #force_inline f32be(cos_f32(f32(Īø))) } +@(require_results) cos_f64le :: proc "contextless" (Īø: f64le) -> f64le { return #force_inline f64le(cos_f64(f64(Īø))) } +@(require_results) cos_f64be :: proc "contextless" (Īø: f64be) -> f64be { return #force_inline f64be(cos_f64(f64(Īø))) } +cos :: proc{ cos_f16, cos_f16le, cos_f16be, cos_f32, cos_f32le, cos_f32be, cos_f64, cos_f64le, cos_f64be, } -pow_f16le :: proc "contextless" (x, power: f16le) -> f16le { return #force_inline f16le(pow_f16(f16(x), f16(power))) } -pow_f16be :: proc "contextless" (x, power: f16be) -> f16be { return #force_inline f16be(pow_f16(f16(x), f16(power))) } -pow_f32le :: proc "contextless" (x, power: f32le) -> f32le { return #force_inline f32le(pow_f32(f32(x), f32(power))) } -pow_f32be :: proc "contextless" (x, power: f32be) -> f32be { return #force_inline f32be(pow_f32(f32(x), f32(power))) } -pow_f64le :: proc "contextless" (x, power: f64le) -> f64le { return #force_inline f64le(pow_f64(f64(x), f64(power))) } -pow_f64be :: proc "contextless" (x, power: f64be) -> f64be { return #force_inline f64be(pow_f64(f64(x), f64(power))) } -pow :: proc{ +@(require_results) pow_f16le :: proc "contextless" (x, power: f16le) -> f16le { return #force_inline f16le(pow_f16(f16(x), f16(power))) } +@(require_results) pow_f16be :: proc "contextless" (x, power: f16be) -> f16be { return #force_inline f16be(pow_f16(f16(x), f16(power))) } +@(require_results) pow_f32le :: proc "contextless" (x, power: f32le) -> f32le { return #force_inline f32le(pow_f32(f32(x), f32(power))) } +@(require_results) pow_f32be :: proc "contextless" (x, power: f32be) -> f32be { return #force_inline f32be(pow_f32(f32(x), f32(power))) } +@(require_results) pow_f64le :: proc "contextless" (x, power: f64le) -> f64le { return #force_inline f64le(pow_f64(f64(x), f64(power))) } +@(require_results) pow_f64be :: proc "contextless" (x, power: f64be) -> f64be { return #force_inline f64be(pow_f64(f64(x), f64(power))) } +pow :: proc{ pow_f16, pow_f16le, pow_f16be, pow_f32, pow_f32le, pow_f32be, pow_f64, pow_f64le, pow_f64be, } -fmuladd_f16le :: proc "contextless" (a, b, c: f16le) -> f16le { return #force_inline f16le(fmuladd_f16(f16(a), f16(b), f16(c))) } -fmuladd_f16be :: proc "contextless" (a, b, c: f16be) -> f16be { return #force_inline f16be(fmuladd_f16(f16(a), f16(b), f16(c))) } -fmuladd_f32le :: proc "contextless" (a, b, c: f32le) -> f32le { return #force_inline f32le(fmuladd_f32(f32(a), f32(b), f32(c))) } -fmuladd_f32be :: proc "contextless" (a, b, c: f32be) -> f32be { return #force_inline f32be(fmuladd_f32(f32(a), f32(b), f32(c))) } -fmuladd_f64le :: proc "contextless" (a, b, c: f64le) -> f64le { return #force_inline f64le(fmuladd_f64(f64(a), f64(b), f64(c))) } -fmuladd_f64be :: proc "contextless" (a, b, c: f64be) -> f64be { return #force_inline f64be(fmuladd_f64(f64(a), f64(b), f64(c))) } -fmuladd :: proc{ +@(require_results) fmuladd_f16le :: proc "contextless" (a, b, c: f16le) -> f16le { return #force_inline f16le(fmuladd_f16(f16(a), f16(b), f16(c))) } +@(require_results) fmuladd_f16be :: proc "contextless" (a, b, c: f16be) -> f16be { return #force_inline f16be(fmuladd_f16(f16(a), f16(b), f16(c))) } +@(require_results) fmuladd_f32le :: proc "contextless" (a, b, c: f32le) -> f32le { return #force_inline f32le(fmuladd_f32(f32(a), f32(b), f32(c))) } +@(require_results) fmuladd_f32be :: proc "contextless" (a, b, c: f32be) -> f32be { return #force_inline f32be(fmuladd_f32(f32(a), f32(b), f32(c))) } +@(require_results) fmuladd_f64le :: proc "contextless" (a, b, c: f64le) -> f64le { return #force_inline f64le(fmuladd_f64(f64(a), f64(b), f64(c))) } +@(require_results) fmuladd_f64be :: proc "contextless" (a, b, c: f64be) -> f64be { return #force_inline f64be(fmuladd_f64(f64(a), f64(b), f64(c))) } +fmuladd :: proc{ fmuladd_f16, fmuladd_f16le, fmuladd_f16be, fmuladd_f32, fmuladd_f32le, fmuladd_f32be, fmuladd_f64, fmuladd_f64le, fmuladd_f64be, } -exp_f16le :: proc "contextless" (x: f16le) -> f16le { return #force_inline f16le(exp_f16(f16(x))) } -exp_f16be :: proc "contextless" (x: f16be) -> f16be { return #force_inline f16be(exp_f16(f16(x))) } -exp_f32le :: proc "contextless" (x: f32le) -> f32le { return #force_inline f32le(exp_f32(f32(x))) } -exp_f32be :: proc "contextless" (x: f32be) -> f32be { return #force_inline f32be(exp_f32(f32(x))) } -exp_f64le :: proc "contextless" (x: f64le) -> f64le { return #force_inline f64le(exp_f64(f64(x))) } -exp_f64be :: proc "contextless" (x: f64be) -> f64be { return #force_inline f64be(exp_f64(f64(x))) } -exp :: proc{ +@(require_results) exp_f16le :: proc "contextless" (x: f16le) -> f16le { return #force_inline f16le(exp_f16(f16(x))) } +@(require_results) exp_f16be :: proc "contextless" (x: f16be) -> f16be { return #force_inline f16be(exp_f16(f16(x))) } +@(require_results) exp_f32le :: proc "contextless" (x: f32le) -> f32le { return #force_inline f32le(exp_f32(f32(x))) } +@(require_results) exp_f32be :: proc "contextless" (x: f32be) -> f32be { return #force_inline f32be(exp_f32(f32(x))) } +@(require_results) exp_f64le :: proc "contextless" (x: f64le) -> f64le { return #force_inline f64le(exp_f64(f64(x))) } +@(require_results) exp_f64be :: proc "contextless" (x: f64be) -> f64be { return #force_inline f64be(exp_f64(f64(x))) } +exp :: proc{ exp_f16, exp_f16le, exp_f16be, exp_f32, exp_f32le, exp_f32be, exp_f64, exp_f64le, exp_f64be, } -pow10_f16le :: proc "contextless" (x: f16le) -> f16le { return #force_inline f16le(pow10_f16(f16(x))) } -pow10_f16be :: proc "contextless" (x: f16be) -> f16be { return #force_inline f16be(pow10_f16(f16(x))) } -pow10_f32le :: proc "contextless" (x: f32le) -> f32le { return #force_inline f32le(pow10_f32(f32(x))) } -pow10_f32be :: proc "contextless" (x: f32be) -> f32be { return #force_inline f32be(pow10_f32(f32(x))) } -pow10_f64le :: proc "contextless" (x: f64le) -> f64le { return #force_inline f64le(pow10_f64(f64(x))) } -pow10_f64be :: proc "contextless" (x: f64be) -> f64be { return #force_inline f64be(pow10_f64(f64(x))) } -pow10 :: proc{ +@(require_results) pow10_f16le :: proc "contextless" (x: f16le) -> f16le { return #force_inline f16le(pow10_f16(f16(x))) } +@(require_results) pow10_f16be :: proc "contextless" (x: f16be) -> f16be { return #force_inline f16be(pow10_f16(f16(x))) } +@(require_results) pow10_f32le :: proc "contextless" (x: f32le) -> f32le { return #force_inline f32le(pow10_f32(f32(x))) } +@(require_results) pow10_f32be :: proc "contextless" (x: f32be) -> f32be { return #force_inline f32be(pow10_f32(f32(x))) } +@(require_results) pow10_f64le :: proc "contextless" (x: f64le) -> f64le { return #force_inline f64le(pow10_f64(f64(x))) } +@(require_results) pow10_f64be :: proc "contextless" (x: f64be) -> f64be { return #force_inline f64be(pow10_f64(f64(x))) } +pow10 :: proc{ pow10_f16, pow10_f16le, pow10_f16be, pow10_f32, pow10_f32le, pow10_f32be, pow10_f64, pow10_f64le, pow10_f64be, } +@(require_results) pow10_f16 :: proc "contextless" (n: f16) -> f16 { @static pow10_pos_tab := [?]f16{ 1e00, 1e01, 1e02, 1e03, 1e04, @@ -146,6 +147,7 @@ pow10_f16 :: proc "contextless" (n: f16) -> f16 { return 0 } +@(require_results) pow10_f32 :: proc "contextless" (n: f32) -> f32 { @static pow10_pos_tab := [?]f32{ 1e00, 1e01, 1e02, 1e03, 1e04, 1e05, 1e06, 1e07, 1e08, 1e09, @@ -173,6 +175,7 @@ pow10_f32 :: proc "contextless" (n: f32) -> f32 { return 0 } +@(require_results) pow10_f64 :: proc "contextless" (n: f64) -> f64 { @static pow10_tab := [?]f64{ 1e00, 1e01, 1e02, 1e03, 1e04, 1e05, 1e06, 1e07, 1e08, 1e09, @@ -202,6 +205,7 @@ pow10_f64 :: proc "contextless" (n: f64) -> f64 { +@(require_results) ldexp_f64 :: proc "contextless" (val: f64, exp: int) -> f64 { mask :: F64_MASK shift :: F64_SHIFT @@ -236,14 +240,14 @@ ldexp_f64 :: proc "contextless" (val: f64, exp: int) -> f64 { x |= u64(exp+bias) << shift return m * transmute(f64)x } -ldexp_f16 :: proc "contextless" (val: f16, exp: int) -> f16 { return f16(ldexp_f64(f64(val), exp)) } -ldexp_f32 :: proc "contextless" (val: f32, exp: int) -> f32 { return f32(ldexp_f64(f64(val), exp)) } -ldexp_f16le :: proc "contextless" (val: f16le, exp: int) -> f16le { return #force_inline f16le(ldexp_f16(f16(val), exp)) } -ldexp_f16be :: proc "contextless" (val: f16be, exp: int) -> f16be { return #force_inline f16be(ldexp_f16(f16(val), exp)) } -ldexp_f32le :: proc "contextless" (val: f32le, exp: int) -> f32le { return #force_inline f32le(ldexp_f32(f32(val), exp)) } -ldexp_f32be :: proc "contextless" (val: f32be, exp: int) -> f32be { return #force_inline f32be(ldexp_f32(f32(val), exp)) } -ldexp_f64le :: proc "contextless" (val: f64le, exp: int) -> f64le { return #force_inline f64le(ldexp_f64(f64(val), exp)) } -ldexp_f64be :: proc "contextless" (val: f64be, exp: int) -> f64be { return #force_inline f64be(ldexp_f64(f64(val), exp)) } +@(require_results) ldexp_f16 :: proc "contextless" (val: f16, exp: int) -> f16 { return f16(ldexp_f64(f64(val), exp)) } +@(require_results) ldexp_f32 :: proc "contextless" (val: f32, exp: int) -> f32 { return f32(ldexp_f64(f64(val), exp)) } +@(require_results) ldexp_f16le :: proc "contextless" (val: f16le, exp: int) -> f16le { return #force_inline f16le(ldexp_f16(f16(val), exp)) } +@(require_results) ldexp_f16be :: proc "contextless" (val: f16be, exp: int) -> f16be { return #force_inline f16be(ldexp_f16(f16(val), exp)) } +@(require_results) ldexp_f32le :: proc "contextless" (val: f32le, exp: int) -> f32le { return #force_inline f32le(ldexp_f32(f32(val), exp)) } +@(require_results) ldexp_f32be :: proc "contextless" (val: f32be, exp: int) -> f32be { return #force_inline f32be(ldexp_f32(f32(val), exp)) } +@(require_results) ldexp_f64le :: proc "contextless" (val: f64le, exp: int) -> f64le { return #force_inline f64le(ldexp_f64(f64(val), exp)) } +@(require_results) ldexp_f64be :: proc "contextless" (val: f64be, exp: int) -> f64be { return #force_inline f64be(ldexp_f64(f64(val), exp)) } // ldexp is the inverse of frexp // it returns val * 2**exp. // @@ -260,82 +264,84 @@ ldexp :: proc{ } -log_f16 :: proc "contextless" (x, base: f16) -> f16 { return ln(x) / ln(base) } -log_f16le :: proc "contextless" (x, base: f16le) -> f16le { return f16le(log_f16(f16(x), f16(base))) } -log_f16be :: proc "contextless" (x, base: f16be) -> f16be { return f16be(log_f16(f16(x), f16(base))) } +@(require_results) log_f16 :: proc "contextless" (x, base: f16) -> f16 { return ln(x) / ln(base) } +@(require_results) log_f16le :: proc "contextless" (x, base: f16le) -> f16le { return f16le(log_f16(f16(x), f16(base))) } +@(require_results) log_f16be :: proc "contextless" (x, base: f16be) -> f16be { return f16be(log_f16(f16(x), f16(base))) } -log_f32 :: proc "contextless" (x, base: f32) -> f32 { return ln(x) / ln(base) } -log_f32le :: proc "contextless" (x, base: f32le) -> f32le { return f32le(log_f32(f32(x), f32(base))) } -log_f32be :: proc "contextless" (x, base: f32be) -> f32be { return f32be(log_f32(f32(x), f32(base))) } +@(require_results) log_f32 :: proc "contextless" (x, base: f32) -> f32 { return ln(x) / ln(base) } +@(require_results) log_f32le :: proc "contextless" (x, base: f32le) -> f32le { return f32le(log_f32(f32(x), f32(base))) } +@(require_results) log_f32be :: proc "contextless" (x, base: f32be) -> f32be { return f32be(log_f32(f32(x), f32(base))) } -log_f64 :: proc "contextless" (x, base: f64) -> f64 { return ln(x) / ln(base) } -log_f64le :: proc "contextless" (x, base: f64le) -> f64le { return f64le(log_f64(f64(x), f64(base))) } -log_f64be :: proc "contextless" (x, base: f64be) -> f64be { return f64be(log_f64(f64(x), f64(base))) } -log :: proc{ +@(require_results) log_f64 :: proc "contextless" (x, base: f64) -> f64 { return ln(x) / ln(base) } +@(require_results) log_f64le :: proc "contextless" (x, base: f64le) -> f64le { return f64le(log_f64(f64(x), f64(base))) } +@(require_results) log_f64be :: proc "contextless" (x, base: f64be) -> f64be { return f64be(log_f64(f64(x), f64(base))) } +log :: proc{ log_f16, log_f16le, log_f16be, log_f32, log_f32le, log_f32be, log_f64, log_f64le, log_f64be, } -log2_f16 :: proc "contextless" (x: f16) -> f16 { return log(f16(x), f16(2.0)) } -log2_f16le :: proc "contextless" (x: f16le) -> f16le { return f16le(log_f16(f16(x), f16(2.0))) } -log2_f16be :: proc "contextless" (x: f16be) -> f16be { return f16be(log_f16(f16(x), f16(2.0))) } +@(require_results) log2_f16 :: proc "contextless" (x: f16) -> f16 { return log(f16(x), f16(2.0)) } +@(require_results) log2_f16le :: proc "contextless" (x: f16le) -> f16le { return f16le(log_f16(f16(x), f16(2.0))) } +@(require_results) log2_f16be :: proc "contextless" (x: f16be) -> f16be { return f16be(log_f16(f16(x), f16(2.0))) } -log2_f32 :: proc "contextless" (x: f32) -> f32 { return log(f32(x), f32(2.0)) } -log2_f32le :: proc "contextless" (x: f32le) -> f32le { return f32le(log_f32(f32(x), f32(2.0))) } -log2_f32be :: proc "contextless" (x: f32be) -> f32be { return f32be(log_f32(f32(x), f32(2.0))) } +@(require_results) log2_f32 :: proc "contextless" (x: f32) -> f32 { return log(f32(x), f32(2.0)) } +@(require_results) log2_f32le :: proc "contextless" (x: f32le) -> f32le { return f32le(log_f32(f32(x), f32(2.0))) } +@(require_results) log2_f32be :: proc "contextless" (x: f32be) -> f32be { return f32be(log_f32(f32(x), f32(2.0))) } -log2_f64 :: proc "contextless" (x: f64) -> f64 { return log(f64(x), f64(2.0)) } -log2_f64le :: proc "contextless" (x: f64le) -> f64le { return f64le(log_f64(f64(x), f64(2.0))) } -log2_f64be :: proc "contextless" (x: f64be) -> f64be { return f64be(log_f64(f64(x), f64(2.0))) } +@(require_results) log2_f64 :: proc "contextless" (x: f64) -> f64 { return log(f64(x), f64(2.0)) } +@(require_results) log2_f64le :: proc "contextless" (x: f64le) -> f64le { return f64le(log_f64(f64(x), f64(2.0))) } +@(require_results) log2_f64be :: proc "contextless" (x: f64be) -> f64be { return f64be(log_f64(f64(x), f64(2.0))) } -log2 :: proc{ +log2 :: proc{ log2_f16, log2_f16le, log2_f16be, log2_f32, log2_f32le, log2_f32be, log2_f64, log2_f64le, log2_f64be, } -log10_f16 :: proc "contextless" (x: f16) -> f16 { return ln(x)/LN10 } -log10_f16le :: proc "contextless" (x: f16le) -> f16le { return f16le(log10_f16(f16(x))) } -log10_f16be :: proc "contextless" (x: f16be) -> f16be { return f16be(log10_f16(f16(x))) } +@(require_results) log10_f16 :: proc "contextless" (x: f16) -> f16 { return ln(x)/LN10 } +@(require_results) log10_f16le :: proc "contextless" (x: f16le) -> f16le { return f16le(log10_f16(f16(x))) } +@(require_results) log10_f16be :: proc "contextless" (x: f16be) -> f16be { return f16be(log10_f16(f16(x))) } -log10_f32 :: proc "contextless" (x: f32) -> f32 { return ln(x)/LN10 } -log10_f32le :: proc "contextless" (x: f32le) -> f32le { return f32le(log10_f32(f32(x))) } -log10_f32be :: proc "contextless" (x: f32be) -> f32be { return f32be(log10_f32(f32(x))) } +@(require_results) log10_f32 :: proc "contextless" (x: f32) -> f32 { return ln(x)/LN10 } +@(require_results) log10_f32le :: proc "contextless" (x: f32le) -> f32le { return f32le(log10_f32(f32(x))) } +@(require_results) log10_f32be :: proc "contextless" (x: f32be) -> f32be { return f32be(log10_f32(f32(x))) } -log10_f64 :: proc "contextless" (x: f64) -> f64 { return ln(x)/LN10 } -log10_f64le :: proc "contextless" (x: f64le) -> f64le { return f64le(log10_f64(f64(x))) } -log10_f64be :: proc "contextless" (x: f64be) -> f64be { return f64be(log10_f64(f64(x))) } -log10 :: proc{ +@(require_results) log10_f64 :: proc "contextless" (x: f64) -> f64 { return ln(x)/LN10 } +@(require_results) log10_f64le :: proc "contextless" (x: f64le) -> f64le { return f64le(log10_f64(f64(x))) } +@(require_results) log10_f64be :: proc "contextless" (x: f64be) -> f64be { return f64be(log10_f64(f64(x))) } +log10 :: proc{ log10_f16, log10_f16le, log10_f16be, log10_f32, log10_f32le, log10_f32be, log10_f64, log10_f64le, log10_f64be, } -tan_f16 :: proc "contextless" (Īø: f16) -> f16 { return sin(Īø)/cos(Īø) } -tan_f16le :: proc "contextless" (Īø: f16le) -> f16le { return f16le(tan_f16(f16(Īø))) } -tan_f16be :: proc "contextless" (Īø: f16be) -> f16be { return f16be(tan_f16(f16(Īø))) } +@(require_results) tan_f16 :: proc "contextless" (Īø: f16) -> f16 { return sin(Īø)/cos(Īø) } +@(require_results) tan_f16le :: proc "contextless" (Īø: f16le) -> f16le { return f16le(tan_f16(f16(Īø))) } +@(require_results) tan_f16be :: proc "contextless" (Īø: f16be) -> f16be { return f16be(tan_f16(f16(Īø))) } -tan_f32 :: proc "contextless" (Īø: f32) -> f32 { return sin(Īø)/cos(Īø) } -tan_f32le :: proc "contextless" (Īø: f32le) -> f32le { return f32le(tan_f32(f32(Īø))) } -tan_f32be :: proc "contextless" (Īø: f32be) -> f32be { return f32be(tan_f32(f32(Īø))) } +@(require_results) tan_f32 :: proc "contextless" (Īø: f32) -> f32 { return sin(Īø)/cos(Īø) } +@(require_results) tan_f32le :: proc "contextless" (Īø: f32le) -> f32le { return f32le(tan_f32(f32(Īø))) } +@(require_results) tan_f32be :: proc "contextless" (Īø: f32be) -> f32be { return f32be(tan_f32(f32(Īø))) } -tan_f64 :: proc "contextless" (Īø: f64) -> f64 { return sin(Īø)/cos(Īø) } -tan_f64le :: proc "contextless" (Īø: f64le) -> f64le { return f64le(tan_f64(f64(Īø))) } -tan_f64be :: proc "contextless" (Īø: f64be) -> f64be { return f64be(tan_f64(f64(Īø))) } -tan :: proc{ +@(require_results) tan_f64 :: proc "contextless" (Īø: f64) -> f64 { return sin(Īø)/cos(Īø) } +@(require_results) tan_f64le :: proc "contextless" (Īø: f64le) -> f64le { return f64le(tan_f64(f64(Īø))) } +@(require_results) tan_f64be :: proc "contextless" (Īø: f64be) -> f64be { return f64be(tan_f64(f64(Īø))) } +tan :: proc{ tan_f16, tan_f16le, tan_f16be, tan_f32, tan_f32le, tan_f32be, tan_f64, tan_f64le, tan_f64be, } -lerp :: proc "contextless" (a, b: $T, t: $E) -> (x: T) { return a*(1-t) + b*t } -saturate :: proc "contextless" (a: $T) -> (x: T) { return clamp(a, 0, 1) } +@(require_results) lerp :: proc "contextless" (a, b: $T, t: $E) -> (x: T) { return a*(1-t) + b*t } +@(require_results) saturate :: proc "contextless" (a: $T) -> (x: T) { return clamp(a, 0, 1) } -unlerp :: proc "contextless" (a, b, x: $T) -> (t: T) where intrinsics.type_is_float(T), !intrinsics.type_is_array(T) { +@(require_results) +unlerp :: proc "contextless" (a, b, x: $T) -> (t: T) where intrinsics.type_is_float(T), !intrinsics.type_is_array(T) { return (x-a)/(b-a) } +@(require_results) remap :: proc "contextless" (old_value, old_min, old_max, new_min, new_max: $T) -> (x: T) where intrinsics.type_is_numeric(T), !intrinsics.type_is_array(T) { old_range := old_max - old_min new_range := new_max - new_min @@ -345,32 +351,39 @@ remap :: proc "contextless" (old_value, old_min, old_max, new_min, new_max: $T) return ((old_value - old_min) / old_range) * new_range + new_min } +@(require_results) wrap :: proc "contextless" (x, y: $T) -> T where intrinsics.type_is_numeric(T), !intrinsics.type_is_array(T) { tmp := mod(x, y) return y + tmp if tmp < 0 else tmp } +@(require_results) angle_diff :: proc "contextless" (a, b: $T) -> T where intrinsics.type_is_numeric(T), !intrinsics.type_is_array(T) { dist := wrap(b - a, TAU) return wrap(dist*2, TAU) - dist } +@(require_results) angle_lerp :: proc "contextless" (a, b, t: $T) -> T where intrinsics.type_is_numeric(T), !intrinsics.type_is_array(T) { return a + angle_diff(a, b) * t } +@(require_results) step :: proc "contextless" (edge, x: $T) -> T where intrinsics.type_is_numeric(T), !intrinsics.type_is_array(T) { return 0 if x < edge else 1 } +@(require_results) smoothstep :: proc "contextless" (edge0, edge1, x: $T) -> T where intrinsics.type_is_numeric(T), !intrinsics.type_is_array(T) { t := clamp((x - edge0) / (edge1 - edge0), 0, 1) return t * t * (3 - 2*t) } +@(require_results) bias :: proc "contextless" (t, b: $T) -> T where intrinsics.type_is_numeric(T) { return t / (((1/b) - 2) * (1 - t) + 1) } +@(require_results) gain :: proc "contextless" (t, g: $T) -> T where intrinsics.type_is_numeric(T) { if t < 0.5 { return bias(t*2, g)*0.5 @@ -379,51 +392,47 @@ gain :: proc "contextless" (t, g: $T) -> T where intrinsics.type_is_numeric(T) { } -sign_f16 :: proc "contextless" (x: f16) -> f16 { return f16(int(0 < x) - int(x < 0)) } -sign_f16le :: proc "contextless" (x: f16le) -> f16le { return f16le(int(0 < x) - int(x < 0)) } -sign_f16be :: proc "contextless" (x: f16be) -> f16be { return f16be(int(0 < x) - int(x < 0)) } -sign_f32 :: proc "contextless" (x: f32) -> f32 { return f32(int(0 < x) - int(x < 0)) } -sign_f32le :: proc "contextless" (x: f32le) -> f32le { return f32le(int(0 < x) - int(x < 0)) } -sign_f32be :: proc "contextless" (x: f32be) -> f32be { return f32be(int(0 < x) - int(x < 0)) } -sign_f64 :: proc "contextless" (x: f64) -> f64 { return f64(int(0 < x) - int(x < 0)) } -sign_f64le :: proc "contextless" (x: f64le) -> f64le { return f64le(int(0 < x) - int(x < 0)) } -sign_f64be :: proc "contextless" (x: f64be) -> f64be { return f64be(int(0 < x) - int(x < 0)) } -sign :: proc{ +@(require_results) sign_f16 :: proc "contextless" (x: f16) -> f16 { return f16(int(0 < x) - int(x < 0)) } +@(require_results) sign_f16le :: proc "contextless" (x: f16le) -> f16le { return f16le(int(0 < x) - int(x < 0)) } +@(require_results) sign_f16be :: proc "contextless" (x: f16be) -> f16be { return f16be(int(0 < x) - int(x < 0)) } +@(require_results) sign_f32 :: proc "contextless" (x: f32) -> f32 { return f32(int(0 < x) - int(x < 0)) } +@(require_results) sign_f32le :: proc "contextless" (x: f32le) -> f32le { return f32le(int(0 < x) - int(x < 0)) } +@(require_results) sign_f32be :: proc "contextless" (x: f32be) -> f32be { return f32be(int(0 < x) - int(x < 0)) } +@(require_results) sign_f64 :: proc "contextless" (x: f64) -> f64 { return f64(int(0 < x) - int(x < 0)) } +@(require_results) sign_f64le :: proc "contextless" (x: f64le) -> f64le { return f64le(int(0 < x) - int(x < 0)) } +@(require_results) sign_f64be :: proc "contextless" (x: f64be) -> f64be { return f64be(int(0 < x) - int(x < 0)) } +sign :: proc{ sign_f16, sign_f16le, sign_f16be, sign_f32, sign_f32le, sign_f32be, sign_f64, sign_f64le, sign_f64be, } -sign_bit_f16 :: proc "contextless" (x: f16) -> bool { - return (transmute(u16)x) & (1<<15) != 0 -} -sign_bit_f16le :: proc "contextless" (x: f16le) -> bool { return #force_inline sign_bit_f16(f16(x)) } -sign_bit_f16be :: proc "contextless" (x: f16be) -> bool { return #force_inline sign_bit_f16(f16(x)) } -sign_bit_f32 :: proc "contextless" (x: f32) -> bool { - return (transmute(u32)x) & (1<<31) != 0 -} -sign_bit_f32le :: proc "contextless" (x: f32le) -> bool { return #force_inline sign_bit_f32(f32(x)) } -sign_bit_f32be :: proc "contextless" (x: f32be) -> bool { return #force_inline sign_bit_f32(f32(x)) } -sign_bit_f64 :: proc "contextless" (x: f64) -> bool { - return (transmute(u64)x) & (1<<63) != 0 -} -sign_bit_f64le :: proc "contextless" (x: f64le) -> bool { return #force_inline sign_bit_f64(f64(x)) } -sign_bit_f64be :: proc "contextless" (x: f64be) -> bool { return #force_inline sign_bit_f64(f64(x)) } -sign_bit :: proc{ +@(require_results) sign_bit_f16 :: proc "contextless" (x: f16) -> bool { return (transmute(u16)x) & (1<<15) != 0 } +@(require_results) sign_bit_f16le :: proc "contextless" (x: f16le) -> bool { return #force_inline sign_bit_f16(f16(x)) } +@(require_results) sign_bit_f16be :: proc "contextless" (x: f16be) -> bool { return #force_inline sign_bit_f16(f16(x)) } +@(require_results) sign_bit_f32 :: proc "contextless" (x: f32) -> bool { return (transmute(u32)x) & (1<<31) != 0 } +@(require_results) sign_bit_f32le :: proc "contextless" (x: f32le) -> bool { return #force_inline sign_bit_f32(f32(x)) } +@(require_results) sign_bit_f32be :: proc "contextless" (x: f32be) -> bool { return #force_inline sign_bit_f32(f32(x)) } +@(require_results) sign_bit_f64 :: proc "contextless" (x: f64) -> bool { return (transmute(u64)x) & (1<<63) != 0 } +@(require_results) sign_bit_f64le :: proc "contextless" (x: f64le) -> bool { return #force_inline sign_bit_f64(f64(x)) } +@(require_results) sign_bit_f64be :: proc "contextless" (x: f64be) -> bool { return #force_inline sign_bit_f64(f64(x)) } +sign_bit :: proc{ sign_bit_f16, sign_bit_f16le, sign_bit_f16be, sign_bit_f32, sign_bit_f32le, sign_bit_f32be, sign_bit_f64, sign_bit_f64le, sign_bit_f64be, } -copy_sign_f16 :: proc "contextless" (x, y: f16) -> f16 { +@(require_results) +copy_sign_f16 :: proc "contextless" (x, y: f16) -> f16 { ix := transmute(u16)x iy := transmute(u16)y ix &= 0x7fff ix |= iy & 0x8000 return transmute(f16)ix } -copy_sign_f16le :: proc "contextless" (x, y: f16le) -> f16le { return #force_inline f16le(copy_sign_f16(f16(x), f16(y))) } -copy_sign_f16be :: proc "contextless" (x, y: f16be) -> f16be { return #force_inline f16be(copy_sign_f16(f16(x), f16(y))) } +@(require_results) copy_sign_f16le :: proc "contextless" (x, y: f16le) -> f16le { return #force_inline f16le(copy_sign_f16(f16(x), f16(y))) } +@(require_results) copy_sign_f16be :: proc "contextless" (x, y: f16be) -> f16be { return #force_inline f16be(copy_sign_f16(f16(x), f16(y))) } +@(require_results) copy_sign_f32 :: proc "contextless" (x, y: f32) -> f32 { ix := transmute(u32)x iy := transmute(u32)y @@ -431,53 +440,55 @@ copy_sign_f32 :: proc "contextless" (x, y: f32) -> f32 { ix |= iy & 0x8000_0000 return transmute(f32)ix } -copy_sign_f32le :: proc "contextless" (x, y: f32le) -> f32le { return #force_inline f32le(copy_sign_f32(f32(x), f32(y))) } -copy_sign_f32be :: proc "contextless" (x, y: f32be) -> f32be { return #force_inline f32be(copy_sign_f32(f32(x), f32(y))) } -copy_sign_f64 :: proc "contextless" (x, y: f64) -> f64 { +@(require_results) copy_sign_f32le :: proc "contextless" (x, y: f32le) -> f32le { return #force_inline f32le(copy_sign_f32(f32(x), f32(y))) } +@(require_results) copy_sign_f32be :: proc "contextless" (x, y: f32be) -> f32be { return #force_inline f32be(copy_sign_f32(f32(x), f32(y))) } +@(require_results) +copy_sign_f64 :: proc "contextless" (x, y: f64) -> f64 { ix := transmute(u64)x iy := transmute(u64)y ix &= 0x7fff_ffff_ffff_ffff ix |= iy & 0x8000_0000_0000_0000 return transmute(f64)ix } -copy_sign_f64le :: proc "contextless" (x, y: f64le) -> f64le { return #force_inline f64le(copy_sign_f64(f64(x), f64(y))) } -copy_sign_f64be :: proc "contextless" (x, y: f64be) -> f64be { return #force_inline f64be(copy_sign_f64(f64(x), f64(y))) } -copy_sign :: proc{ +@(require_results) copy_sign_f64le :: proc "contextless" (x, y: f64le) -> f64le { return #force_inline f64le(copy_sign_f64(f64(x), f64(y))) } +@(require_results) copy_sign_f64be :: proc "contextless" (x, y: f64be) -> f64be { return #force_inline f64be(copy_sign_f64(f64(x), f64(y))) } +copy_sign :: proc{ copy_sign_f16, copy_sign_f16le, copy_sign_f16be, copy_sign_f32, copy_sign_f32le, copy_sign_f32be, copy_sign_f64, copy_sign_f64le, copy_sign_f64be, } -to_radians_f16 :: proc "contextless" (degrees: f16) -> f16 { return degrees * RAD_PER_DEG } -to_radians_f16le :: proc "contextless" (degrees: f16le) -> f16le { return degrees * RAD_PER_DEG } -to_radians_f16be :: proc "contextless" (degrees: f16be) -> f16be { return degrees * RAD_PER_DEG } -to_radians_f32 :: proc "contextless" (degrees: f32) -> f32 { return degrees * RAD_PER_DEG } -to_radians_f32le :: proc "contextless" (degrees: f32le) -> f32le { return degrees * RAD_PER_DEG } -to_radians_f32be :: proc "contextless" (degrees: f32be) -> f32be { return degrees * RAD_PER_DEG } -to_radians_f64 :: proc "contextless" (degrees: f64) -> f64 { return degrees * RAD_PER_DEG } -to_radians_f64le :: proc "contextless" (degrees: f64le) -> f64le { return degrees * RAD_PER_DEG } -to_radians_f64be :: proc "contextless" (degrees: f64be) -> f64be { return degrees * RAD_PER_DEG } -to_degrees_f16 :: proc "contextless" (radians: f16) -> f16 { return radians * DEG_PER_RAD } -to_degrees_f16le :: proc "contextless" (radians: f16le) -> f16le { return radians * DEG_PER_RAD } -to_degrees_f16be :: proc "contextless" (radians: f16be) -> f16be { return radians * DEG_PER_RAD } -to_degrees_f32 :: proc "contextless" (radians: f32) -> f32 { return radians * DEG_PER_RAD } -to_degrees_f32le :: proc "contextless" (radians: f32le) -> f32le { return radians * DEG_PER_RAD } -to_degrees_f32be :: proc "contextless" (radians: f32be) -> f32be { return radians * DEG_PER_RAD } -to_degrees_f64 :: proc "contextless" (radians: f64) -> f64 { return radians * DEG_PER_RAD } -to_degrees_f64le :: proc "contextless" (radians: f64le) -> f64le { return radians * DEG_PER_RAD } -to_degrees_f64be :: proc "contextless" (radians: f64be) -> f64be { return radians * DEG_PER_RAD } -to_radians :: proc{ +@(require_results) to_radians_f16 :: proc "contextless" (degrees: f16) -> f16 { return degrees * RAD_PER_DEG } +@(require_results) to_radians_f16le :: proc "contextless" (degrees: f16le) -> f16le { return degrees * RAD_PER_DEG } +@(require_results) to_radians_f16be :: proc "contextless" (degrees: f16be) -> f16be { return degrees * RAD_PER_DEG } +@(require_results) to_radians_f32 :: proc "contextless" (degrees: f32) -> f32 { return degrees * RAD_PER_DEG } +@(require_results) to_radians_f32le :: proc "contextless" (degrees: f32le) -> f32le { return degrees * RAD_PER_DEG } +@(require_results) to_radians_f32be :: proc "contextless" (degrees: f32be) -> f32be { return degrees * RAD_PER_DEG } +@(require_results) to_radians_f64 :: proc "contextless" (degrees: f64) -> f64 { return degrees * RAD_PER_DEG } +@(require_results) to_radians_f64le :: proc "contextless" (degrees: f64le) -> f64le { return degrees * RAD_PER_DEG } +@(require_results) to_radians_f64be :: proc "contextless" (degrees: f64be) -> f64be { return degrees * RAD_PER_DEG } +@(require_results) to_degrees_f16 :: proc "contextless" (radians: f16) -> f16 { return radians * DEG_PER_RAD } +@(require_results) to_degrees_f16le :: proc "contextless" (radians: f16le) -> f16le { return radians * DEG_PER_RAD } +@(require_results) to_degrees_f16be :: proc "contextless" (radians: f16be) -> f16be { return radians * DEG_PER_RAD } +@(require_results) to_degrees_f32 :: proc "contextless" (radians: f32) -> f32 { return radians * DEG_PER_RAD } +@(require_results) to_degrees_f32le :: proc "contextless" (radians: f32le) -> f32le { return radians * DEG_PER_RAD } +@(require_results) to_degrees_f32be :: proc "contextless" (radians: f32be) -> f32be { return radians * DEG_PER_RAD } +@(require_results) to_degrees_f64 :: proc "contextless" (radians: f64) -> f64 { return radians * DEG_PER_RAD } +@(require_results) to_degrees_f64le :: proc "contextless" (radians: f64le) -> f64le { return radians * DEG_PER_RAD } +@(require_results) to_degrees_f64be :: proc "contextless" (radians: f64be) -> f64be { return radians * DEG_PER_RAD } +to_radians :: proc{ to_radians_f16, to_radians_f16le, to_radians_f16be, to_radians_f32, to_radians_f32le, to_radians_f32be, to_radians_f64, to_radians_f64le, to_radians_f64be, } -to_degrees :: proc{ +to_degrees :: proc{ to_degrees_f16, to_degrees_f16le, to_degrees_f16be, to_degrees_f32, to_degrees_f32le, to_degrees_f32be, to_degrees_f64, to_degrees_f64le, to_degrees_f64be, } -trunc_f16 :: proc "contextless" (x: f16) -> f16 { +@(require_results) +trunc_f16 :: proc "contextless" (x: f16) -> f16 { trunc_internal :: proc "contextless" (f: f16) -> f16 { mask :: F16_MASK shift :: F16_SHIFT @@ -506,10 +517,11 @@ trunc_f16 :: proc "contextless" (x: f16) -> f16 { } return trunc_internal(x) } -trunc_f16le :: proc "contextless" (x: f16le) -> f16le { return #force_inline f16le(trunc_f16(f16(x))) } -trunc_f16be :: proc "contextless" (x: f16be) -> f16be { return #force_inline f16be(trunc_f16(f16(x))) } +@(require_results) trunc_f16le :: proc "contextless" (x: f16le) -> f16le { return #force_inline f16le(trunc_f16(f16(x))) } +@(require_results) trunc_f16be :: proc "contextless" (x: f16be) -> f16be { return #force_inline f16be(trunc_f16(f16(x))) } -trunc_f32 :: proc "contextless" (x: f32) -> f32 { +@(require_results) +trunc_f32 :: proc "contextless" (x: f32) -> f32 { trunc_internal :: proc "contextless" (f: f32) -> f32 { mask :: F32_MASK shift :: F32_SHIFT @@ -538,10 +550,11 @@ trunc_f32 :: proc "contextless" (x: f32) -> f32 { } return trunc_internal(x) } -trunc_f32le :: proc "contextless" (x: f32le) -> f32le { return #force_inline f32le(trunc_f32(f32(x))) } -trunc_f32be :: proc "contextless" (x: f32be) -> f32be { return #force_inline f32be(trunc_f32(f32(x))) } +@(require_results) trunc_f32le :: proc "contextless" (x: f32le) -> f32le { return #force_inline f32le(trunc_f32(f32(x))) } +@(require_results) trunc_f32be :: proc "contextless" (x: f32be) -> f32be { return #force_inline f32be(trunc_f32(f32(x))) } -trunc_f64 :: proc "contextless" (x: f64) -> f64 { +@(require_results) +trunc_f64 :: proc "contextless" (x: f64) -> f64 { trunc_internal :: proc "contextless" (f: f64) -> f64 { mask :: F64_MASK shift :: F64_SHIFT @@ -570,68 +583,78 @@ trunc_f64 :: proc "contextless" (x: f64) -> f64 { } return trunc_internal(x) } -trunc_f64le :: proc "contextless" (x: f64le) -> f64le { return #force_inline f64le(trunc_f64(f64(x))) } -trunc_f64be :: proc "contextless" (x: f64be) -> f64be { return #force_inline f64be(trunc_f64(f64(x))) } +@(require_results) trunc_f64le :: proc "contextless" (x: f64le) -> f64le { return #force_inline f64le(trunc_f64(f64(x))) } +@(require_results) trunc_f64be :: proc "contextless" (x: f64be) -> f64be { return #force_inline f64be(trunc_f64(f64(x))) } // Removes the fractional part of the value, i.e. rounds towards zero. -trunc :: proc{ +trunc :: proc{ trunc_f16, trunc_f16le, trunc_f16be, trunc_f32, trunc_f32le, trunc_f32be, trunc_f64, trunc_f64le, trunc_f64be, } +@(require_results) round_f16 :: proc "contextless" (x: f16) -> f16 { return ceil(x - 0.5) if x < 0 else floor(x + 0.5) } +@(require_results) round_f16le :: proc "contextless" (x: f16le) -> f16le { return ceil(x - 0.5) if x < 0 else floor(x + 0.5) } +@(require_results) round_f16be :: proc "contextless" (x: f16be) -> f16be { return ceil(x - 0.5) if x < 0 else floor(x + 0.5) } +@(require_results) round_f32 :: proc "contextless" (x: f32) -> f32 { return ceil(x - 0.5) if x < 0 else floor(x + 0.5) } +@(require_results) round_f32le :: proc "contextless" (x: f32le) -> f32le { return ceil(x - 0.5) if x < 0 else floor(x + 0.5) } +@(require_results) round_f32be :: proc "contextless" (x: f32be) -> f32be { return ceil(x - 0.5) if x < 0 else floor(x + 0.5) } +@(require_results) round_f64 :: proc "contextless" (x: f64) -> f64 { return ceil(x - 0.5) if x < 0 else floor(x + 0.5) } +@(require_results) round_f64le :: proc "contextless" (x: f64le) -> f64le { return ceil(x - 0.5) if x < 0 else floor(x + 0.5) } +@(require_results) round_f64be :: proc "contextless" (x: f64be) -> f64be { return ceil(x - 0.5) if x < 0 else floor(x + 0.5) } -round :: proc{ +round :: proc{ round_f16, round_f16le, round_f16be, round_f32, round_f32le, round_f32be, round_f64, round_f64le, round_f64be, } -ceil_f16 :: proc "contextless" (x: f16) -> f16 { return -floor(-x) } -ceil_f16le :: proc "contextless" (x: f16le) -> f16le { return -floor(-x) } -ceil_f16be :: proc "contextless" (x: f16be) -> f16be { return -floor(-x) } +@(require_results) ceil_f16 :: proc "contextless" (x: f16) -> f16 { return -floor(-x) } +@(require_results) ceil_f16le :: proc "contextless" (x: f16le) -> f16le { return -floor(-x) } +@(require_results) ceil_f16be :: proc "contextless" (x: f16be) -> f16be { return -floor(-x) } -ceil_f32 :: proc "contextless" (x: f32) -> f32 { return -floor(-x) } -ceil_f32le :: proc "contextless" (x: f32le) -> f32le { return -floor(-x) } -ceil_f32be :: proc "contextless" (x: f32be) -> f32be { return -floor(-x) } +@(require_results) ceil_f32 :: proc "contextless" (x: f32) -> f32 { return -floor(-x) } +@(require_results) ceil_f32le :: proc "contextless" (x: f32le) -> f32le { return -floor(-x) } +@(require_results) ceil_f32be :: proc "contextless" (x: f32be) -> f32be { return -floor(-x) } -ceil_f64 :: proc "contextless" (x: f64) -> f64 { return -floor(-x) } -ceil_f64le :: proc "contextless" (x: f64le) -> f64le { return -floor(-x) } -ceil_f64be :: proc "contextless" (x: f64be) -> f64be { return -floor(-x) } +@(require_results) ceil_f64 :: proc "contextless" (x: f64) -> f64 { return -floor(-x) } +@(require_results) ceil_f64le :: proc "contextless" (x: f64le) -> f64le { return -floor(-x) } +@(require_results) ceil_f64be :: proc "contextless" (x: f64be) -> f64be { return -floor(-x) } -ceil :: proc{ +ceil :: proc{ ceil_f16, ceil_f16le, ceil_f16be, ceil_f32, ceil_f32le, ceil_f32be, ceil_f64, ceil_f64le, ceil_f64be, } +@(require_results) floor_f16 :: proc "contextless" (x: f16) -> f16 { if x == 0 || is_nan(x) || is_inf(x) { return x @@ -646,9 +669,10 @@ floor_f16 :: proc "contextless" (x: f16) -> f16 { d, _ := modf(x) return d } -floor_f16le :: proc "contextless" (x: f16le) -> f16le { return #force_inline f16le(floor_f16(f16(x))) } -floor_f16be :: proc "contextless" (x: f16be) -> f16be { return #force_inline f16be(floor_f16(f16(x))) } -floor_f32 :: proc "contextless" (x: f32) -> f32 { +@(require_results) floor_f16le :: proc "contextless" (x: f16le) -> f16le { return #force_inline f16le(floor_f16(f16(x))) } +@(require_results) floor_f16be :: proc "contextless" (x: f16be) -> f16be { return #force_inline f16be(floor_f16(f16(x))) } +@(require_results) +floor_f32 :: proc "contextless" (x: f32) -> f32 { if x == 0 || is_nan(x) || is_inf(x) { return x } @@ -662,8 +686,9 @@ floor_f32 :: proc "contextless" (x: f32) -> f32 { d, _ := modf(x) return d } -floor_f32le :: proc "contextless" (x: f32le) -> f32le { return #force_inline f32le(floor_f32(f32(x))) } -floor_f32be :: proc "contextless" (x: f32be) -> f32be { return #force_inline f32be(floor_f32(f32(x))) } +@(require_results) floor_f32le :: proc "contextless" (x: f32le) -> f32le { return #force_inline f32le(floor_f32(f32(x))) } +@(require_results) floor_f32be :: proc "contextless" (x: f32be) -> f32be { return #force_inline f32be(floor_f32(f32(x))) } +@(require_results) floor_f64 :: proc "contextless" (x: f64) -> f64 { if x == 0 || is_nan(x) || is_inf(x) { return x @@ -678,15 +703,16 @@ floor_f64 :: proc "contextless" (x: f64) -> f64 { d, _ := modf(x) return d } -floor_f64le :: proc "contextless" (x: f64le) -> f64le { return #force_inline f64le(floor_f64(f64(x))) } -floor_f64be :: proc "contextless" (x: f64be) -> f64be { return #force_inline f64be(floor_f64(f64(x))) } -floor :: proc{ +@(require_results) floor_f64le :: proc "contextless" (x: f64le) -> f64le { return #force_inline f64le(floor_f64(f64(x))) } +@(require_results) floor_f64be :: proc "contextless" (x: f64be) -> f64be { return #force_inline f64be(floor_f64(f64(x))) } +floor :: proc{ floor_f16, floor_f16le, floor_f16be, floor_f32, floor_f32le, floor_f32be, floor_f64, floor_f64le, floor_f64be, } +@(require_results) floor_div :: proc "contextless" (x, y: $T) -> T where intrinsics.type_is_integer(T) { a := x / y @@ -697,6 +723,7 @@ floor_div :: proc "contextless" (x, y: $T) -> T return a } +@(require_results) floor_mod :: proc "contextless" (x, y: $T) -> T where intrinsics.type_is_integer(T) { r := x % y @@ -706,6 +733,7 @@ floor_mod :: proc "contextless" (x, y: $T) -> T return r } +@(require_results) divmod :: #force_inline proc "contextless" (x, y: $T) -> (div, mod: T) where intrinsics.type_is_integer(T) { div = x / y @@ -713,6 +741,7 @@ divmod :: #force_inline proc "contextless" (x, y: $T) -> (div, mod: T) return } +@(require_results) floor_divmod :: #force_inline proc "contextless" (x, y: $T) -> (div, mod: T) where intrinsics.type_is_integer(T) { div = x / y @@ -725,6 +754,7 @@ floor_divmod :: #force_inline proc "contextless" (x, y: $T) -> (div, mod: T) } +@(require_results) modf_f16 :: proc "contextless" (x: f16) -> (int: f16, frac: f16) { shift :: F16_SHIFT mask :: F16_MASK @@ -751,15 +781,18 @@ modf_f16 :: proc "contextless" (x: f16) -> (int: f16, frac: f16) { frac = x - int return } +@(require_results) modf_f16le :: proc "contextless" (x: f16le) -> (int: f16le, frac: f16le) { i, f := #force_inline modf_f16(f16(x)) return f16le(i), f16le(f) } +@(require_results) modf_f16be :: proc "contextless" (x: f16be) -> (int: f16be, frac: f16be) { i, f := #force_inline modf_f16(f16(x)) return f16be(i), f16be(f) } -modf_f32 :: proc "contextless" (x: f32) -> (int: f32, frac: f32) { +@(require_results) +modf_f32 :: proc "contextless" (x: f32) -> (int: f32, frac: f32) { shift :: F32_SHIFT mask :: F32_MASK bias :: F32_BIAS @@ -785,14 +818,17 @@ modf_f32 :: proc "contextless" (x: f32) -> (int: f32, frac: f32) { frac = x - int return } +@(require_results) modf_f32le :: proc "contextless" (x: f32le) -> (int: f32le, frac: f32le) { i, f := #force_inline modf_f32(f32(x)) return f32le(i), f32le(f) } +@(require_results) modf_f32be :: proc "contextless" (x: f32be) -> (int: f32be, frac: f32be) { i, f := #force_inline modf_f32(f32(x)) return f32be(i), f32be(f) } +@(require_results) modf_f64 :: proc "contextless" (x: f64) -> (int: f64, frac: f64) { shift :: F64_SHIFT mask :: F64_MASK @@ -819,10 +855,12 @@ modf_f64 :: proc "contextless" (x: f64) -> (int: f64, frac: f64) { frac = x - int return } +@(require_results) modf_f64le :: proc "contextless" (x: f64le) -> (int: f64le, frac: f64le) { i, f := #force_inline modf_f64(f64(x)) return f64le(i), f64le(f) } +@(require_results) modf_f64be :: proc "contextless" (x: f64be) -> (int: f64be, frac: f64be) { i, f := #force_inline modf_f64(f64(x)) return f64be(i), f64be(f) @@ -834,7 +872,8 @@ modf :: proc{ } split_decimal :: modf -mod_f16 :: proc "contextless" (x, y: f16) -> (n: f16) { +@(require_results) +mod_f16 :: proc "contextless" (x, y: f16) -> (n: f16) { z := abs(y) n = remainder(abs(x), z) if sign(n) < 0 { @@ -842,9 +881,10 @@ mod_f16 :: proc "contextless" (x, y: f16) -> (n: f16) { } return copy_sign(n, x) } -mod_f16le :: proc "contextless" (x, y: f16le) -> (n: f16le) { return #force_inline f16le(mod_f16(f16(x), f16(y))) } -mod_f16be :: proc "contextless" (x, y: f16be) -> (n: f16be) { return #force_inline f16be(mod_f16(f16(x), f16(y))) } -mod_f32 :: proc "contextless" (x, y: f32) -> (n: f32) { +@(require_results) mod_f16le :: proc "contextless" (x, y: f16le) -> (n: f16le) { return #force_inline f16le(mod_f16(f16(x), f16(y))) } +@(require_results) mod_f16be :: proc "contextless" (x, y: f16be) -> (n: f16be) { return #force_inline f16be(mod_f16(f16(x), f16(y))) } +@(require_results) +mod_f32 :: proc "contextless" (x, y: f32) -> (n: f32) { z := abs(y) n = remainder(abs(x), z) if sign(n) < 0 { @@ -852,9 +892,12 @@ mod_f32 :: proc "contextless" (x, y: f32) -> (n: f32) { } return copy_sign(n, x) } +@(require_results) mod_f32le :: proc "contextless" (x, y: f32le) -> (n: f32le) { return #force_inline f32le(mod_f32(f32(x), f32(y))) } +@(require_results) mod_f32be :: proc "contextless" (x, y: f32be) -> (n: f32be) { return #force_inline f32be(mod_f32(f32(x), f32(y))) } -mod_f64 :: proc "contextless" (x, y: f64) -> (n: f64) { +@(require_results) +mod_f64 :: proc "contextless" (x, y: f64) -> (n: f64) { z := abs(y) n = remainder(abs(x), z) if sign(n) < 0 { @@ -862,29 +905,32 @@ mod_f64 :: proc "contextless" (x, y: f64) -> (n: f64) { } return copy_sign(n, x) } +@(require_results) mod_f64le :: proc "contextless" (x, y: f64le) -> (n: f64le) { return #force_inline f64le(mod_f64(f64(x), f64(y))) } +@(require_results) mod_f64be :: proc "contextless" (x, y: f64be) -> (n: f64be) { return #force_inline f64be(mod_f64(f64(x), f64(y))) } -mod :: proc{ +mod :: proc{ mod_f16, mod_f16le, mod_f16be, mod_f32, mod_f32le, mod_f32be, mod_f64, mod_f64le, mod_f64be, } -remainder_f16 :: proc "contextless" (x, y: f16 ) -> f16 { return x - round(x/y) * y } -remainder_f16le :: proc "contextless" (x, y: f16le) -> f16le { return x - round(x/y) * y } -remainder_f16be :: proc "contextless" (x, y: f16be) -> f16be { return x - round(x/y) * y } -remainder_f32 :: proc "contextless" (x, y: f32 ) -> f32 { return x - round(x/y) * y } -remainder_f32le :: proc "contextless" (x, y: f32le) -> f32le { return x - round(x/y) * y } -remainder_f32be :: proc "contextless" (x, y: f32be) -> f32be { return x - round(x/y) * y } -remainder_f64 :: proc "contextless" (x, y: f64 ) -> f64 { return x - round(x/y) * y } -remainder_f64le :: proc "contextless" (x, y: f64le) -> f64le { return x - round(x/y) * y } -remainder_f64be :: proc "contextless" (x, y: f64be) -> f64be { return x - round(x/y) * y } -remainder :: proc{ +@(require_results) remainder_f16 :: proc "contextless" (x, y: f16 ) -> f16 { return x - round(x/y) * y } +@(require_results) remainder_f16le :: proc "contextless" (x, y: f16le) -> f16le { return x - round(x/y) * y } +@(require_results) remainder_f16be :: proc "contextless" (x, y: f16be) -> f16be { return x - round(x/y) * y } +@(require_results) remainder_f32 :: proc "contextless" (x, y: f32 ) -> f32 { return x - round(x/y) * y } +@(require_results) remainder_f32le :: proc "contextless" (x, y: f32le) -> f32le { return x - round(x/y) * y } +@(require_results) remainder_f32be :: proc "contextless" (x, y: f32be) -> f32be { return x - round(x/y) * y } +@(require_results) remainder_f64 :: proc "contextless" (x, y: f64 ) -> f64 { return x - round(x/y) * y } +@(require_results) remainder_f64le :: proc "contextless" (x, y: f64le) -> f64le { return x - round(x/y) * y } +@(require_results) remainder_f64be :: proc "contextless" (x, y: f64be) -> f64be { return x - round(x/y) * y } +remainder :: proc{ remainder_f16, remainder_f16le, remainder_f16be, remainder_f32, remainder_f32le, remainder_f32be, remainder_f64, remainder_f64le, remainder_f64be, } +@(require_results) gcd :: proc "contextless" (x, y: $T) -> T where intrinsics.type_is_ordered_numeric(T) { x, y := x, y @@ -895,23 +941,27 @@ gcd :: proc "contextless" (x, y: $T) -> T return abs(x) } +@(require_results) lcm :: proc "contextless" (x, y: $T) -> T where intrinsics.type_is_ordered_numeric(T) { return x / gcd(x, y) * y } +@(require_results) normalize_f16 :: proc "contextless" (x: f16) -> (y: f16, exponent: int) { if abs(x) < F16_MIN { return x * (1< (y: f32, exponent: int) { if abs(x) < F32_MIN { return x * (1< (y: f64, exponent: int) { if abs(x) < F64_MIN { return x * (1< (y: f64, exponent: int) { return x, 0 } -normalize_f16le :: proc "contextless" (x: f16le) -> (y: f16le, exponent: int) { y0, e := normalize_f16(f16(x)); return f16le(y0), e } -normalize_f16be :: proc "contextless" (x: f16be) -> (y: f16be, exponent: int) { y0, e := normalize_f16(f16(x)); return f16be(y0), e } -normalize_f32le :: proc "contextless" (x: f32le) -> (y: f32le, exponent: int) { y0, e := normalize_f32(f32(x)); return f32le(y0), e } -normalize_f32be :: proc "contextless" (x: f32be) -> (y: f32be, exponent: int) { y0, e := normalize_f32(f32(x)); return f32be(y0), e } -normalize_f64le :: proc "contextless" (x: f64le) -> (y: f64le, exponent: int) { y0, e := normalize_f64(f64(x)); return f64le(y0), e } -normalize_f64be :: proc "contextless" (x: f64be) -> (y: f64be, exponent: int) { y0, e := normalize_f64(f64(x)); return f64be(y0), e } +@(require_results) normalize_f16le :: proc "contextless" (x: f16le) -> (y: f16le, exponent: int) { y0, e := normalize_f16(f16(x)); return f16le(y0), e } +@(require_results) normalize_f16be :: proc "contextless" (x: f16be) -> (y: f16be, exponent: int) { y0, e := normalize_f16(f16(x)); return f16be(y0), e } +@(require_results) normalize_f32le :: proc "contextless" (x: f32le) -> (y: f32le, exponent: int) { y0, e := normalize_f32(f32(x)); return f32le(y0), e } +@(require_results) normalize_f32be :: proc "contextless" (x: f32be) -> (y: f32be, exponent: int) { y0, e := normalize_f32(f32(x)); return f32be(y0), e } +@(require_results) normalize_f64le :: proc "contextless" (x: f64le) -> (y: f64le, exponent: int) { y0, e := normalize_f64(f64(x)); return f64le(y0), e } +@(require_results) normalize_f64be :: proc "contextless" (x: f64be) -> (y: f64be, exponent: int) { y0, e := normalize_f64(f64(x)); return f64be(y0), e } normalize :: proc{ normalize_f16, @@ -938,30 +988,37 @@ normalize :: proc{ normalize_f64be, } +@(require_results) frexp_f16 :: proc "contextless" (x: f16) -> (significand: f16, exponent: int) { f, e := frexp_f64(f64(x)) return f16(f), e } +@(require_results) frexp_f16le :: proc "contextless" (x: f16le) -> (significand: f16le, exponent: int) { f, e := frexp_f64(f64(x)) return f16le(f), e } +@(require_results) frexp_f16be :: proc "contextless" (x: f16be) -> (significand: f16be, exponent: int) { f, e := frexp_f64(f64(x)) return f16be(f), e } +@(require_results) frexp_f32 :: proc "contextless" (x: f32) -> (significand: f32, exponent: int) { f, e := frexp_f64(f64(x)) return f32(f), e } +@(require_results) frexp_f32le :: proc "contextless" (x: f32le) -> (significand: f32le, exponent: int) { f, e := frexp_f64(f64(x)) return f32le(f), e } +@(require_results) frexp_f32be :: proc "contextless" (x: f32be) -> (significand: f32be, exponent: int) { f, e := frexp_f64(f64(x)) return f32be(f), e } +@(require_results) frexp_f64 :: proc "contextless" (f: f64) -> (significand: f64, exponent: int) { mask :: F64_MASK shift :: F64_SHIFT @@ -983,10 +1040,12 @@ frexp_f64 :: proc "contextless" (f: f64) -> (significand: f64, exponent: int) { significand = transmute(f64)x return } +@(require_results) frexp_f64le :: proc "contextless" (x: f64le) -> (significand: f64le, exponent: int) { f, e := frexp_f64(f64(x)) return f64le(f), e } +@(require_results) frexp_f64be :: proc "contextless" (x: f64be) -> (significand: f64be, exponent: int) { f, e := frexp_f64(f64(x)) return f64be(f), e @@ -1011,6 +1070,7 @@ frexp :: proc{ +@(require_results) binomial :: proc "contextless" (n, k: int) -> int { switch { case k <= 0: return 1 @@ -1024,6 +1084,7 @@ binomial :: proc "contextless" (n, k: int) -> int { return b } +@(require_results) factorial :: proc "contextless" (n: int) -> int { when size_of(int) == size_of(i64) { @static table := [21]int{ @@ -1069,7 +1130,8 @@ factorial :: proc "contextless" (n: int) -> int { return table[n] } -classify_f16 :: proc "contextless" (x: f16) -> Float_Class { +@(require_results) +classify_f16 :: proc "contextless" (x: f16) -> Float_Class { switch { case x == 0: i := transmute(i16)x @@ -1093,8 +1155,9 @@ classify_f16 :: proc "contextless" (x: f16) -> Float_Class { } return .Normal } -classify_f16le :: proc "contextless" (x: f16le) -> Float_Class { return #force_inline classify_f16(f16(x)) } -classify_f16be :: proc "contextless" (x: f16be) -> Float_Class { return #force_inline classify_f16(f16(x)) } +@(require_results) classify_f16le :: proc "contextless" (x: f16le) -> Float_Class { return #force_inline classify_f16(f16(x)) } +@(require_results) classify_f16be :: proc "contextless" (x: f16be) -> Float_Class { return #force_inline classify_f16(f16(x)) } +@(require_results) classify_f32 :: proc "contextless" (x: f32) -> Float_Class { switch { case x == 0: @@ -1119,8 +1182,9 @@ classify_f32 :: proc "contextless" (x: f32) -> Float_Class { } return .Normal } -classify_f32le :: proc "contextless" (x: f32le) -> Float_Class { return #force_inline classify_f32(f32(x)) } -classify_f32be :: proc "contextless" (x: f32be) -> Float_Class { return #force_inline classify_f32(f32(x)) } +@(require_results) classify_f32le :: proc "contextless" (x: f32le) -> Float_Class { return #force_inline classify_f32(f32(x)) } +@(require_results) classify_f32be :: proc "contextless" (x: f32be) -> Float_Class { return #force_inline classify_f32(f32(x)) } +@(require_results) classify_f64 :: proc "contextless" (x: f64) -> Float_Class { switch { case x == 0: @@ -1144,26 +1208,26 @@ classify_f64 :: proc "contextless" (x: f64) -> Float_Class { } return .Normal } -classify_f64le :: proc "contextless" (x: f64le) -> Float_Class { return #force_inline classify_f64(f64(x)) } -classify_f64be :: proc "contextless" (x: f64be) -> Float_Class { return #force_inline classify_f64(f64(x)) } +@(require_results) classify_f64le :: proc "contextless" (x: f64le) -> Float_Class { return #force_inline classify_f64(f64(x)) } +@(require_results) classify_f64be :: proc "contextless" (x: f64be) -> Float_Class { return #force_inline classify_f64(f64(x)) } // Returns the `Float_Class` of the value, i.e. whether normal, subnormal, zero, negative zero, NaN, infinity or // negative infinity. -classify :: proc{ +classify :: proc{ classify_f16, classify_f16le, classify_f16be, classify_f32, classify_f32le, classify_f32be, classify_f64, classify_f64le, classify_f64be, } -is_nan_f16 :: proc "contextless" (x: f16) -> bool { return classify(x) == .NaN } -is_nan_f16le :: proc "contextless" (x: f16le) -> bool { return classify(x) == .NaN } -is_nan_f16be :: proc "contextless" (x: f16be) -> bool { return classify(x) == .NaN } -is_nan_f32 :: proc "contextless" (x: f32) -> bool { return classify(x) == .NaN } -is_nan_f32le :: proc "contextless" (x: f32le) -> bool { return classify(x) == .NaN } -is_nan_f32be :: proc "contextless" (x: f32be) -> bool { return classify(x) == .NaN } -is_nan_f64 :: proc "contextless" (x: f64) -> bool { return classify(x) == .NaN } -is_nan_f64le :: proc "contextless" (x: f64le) -> bool { return classify(x) == .NaN } -is_nan_f64be :: proc "contextless" (x: f64be) -> bool { return classify(x) == .NaN } -is_nan :: proc{ +@(require_results) is_nan_f16 :: proc "contextless" (x: f16) -> bool { return classify(x) == .NaN } +@(require_results) is_nan_f16le :: proc "contextless" (x: f16le) -> bool { return classify(x) == .NaN } +@(require_results) is_nan_f16be :: proc "contextless" (x: f16be) -> bool { return classify(x) == .NaN } +@(require_results) is_nan_f32 :: proc "contextless" (x: f32) -> bool { return classify(x) == .NaN } +@(require_results) is_nan_f32le :: proc "contextless" (x: f32le) -> bool { return classify(x) == .NaN } +@(require_results) is_nan_f32be :: proc "contextless" (x: f32be) -> bool { return classify(x) == .NaN } +@(require_results) is_nan_f64 :: proc "contextless" (x: f64) -> bool { return classify(x) == .NaN } +@(require_results) is_nan_f64le :: proc "contextless" (x: f64le) -> bool { return classify(x) == .NaN } +@(require_results) is_nan_f64be :: proc "contextless" (x: f64be) -> bool { return classify(x) == .NaN } +is_nan :: proc{ is_nan_f16, is_nan_f16le, is_nan_f16be, is_nan_f32, is_nan_f32le, is_nan_f32be, is_nan_f64, is_nan_f64le, is_nan_f64be, @@ -1173,6 +1237,7 @@ is_nan :: proc{ // If sign > 0, is_inf reports whether f is positive infinity. // If sign < 0, is_inf reports whether f is negative infinity. // If sign == 0, is_inf reports whether f is either infinity. +@(require_results) is_inf_f16 :: proc "contextless" (x: f16, sign: int = 0) -> bool { class := classify(x) switch { @@ -1183,13 +1248,16 @@ is_inf_f16 :: proc "contextless" (x: f16, sign: int = 0) -> bool { } return class == .Inf || class == .Neg_Inf } +@(require_results) is_inf_f16le :: proc "contextless" (x: f16le, sign: int = 0) -> bool { return #force_inline is_inf_f16(f16(x), sign) } +@(require_results) is_inf_f16be :: proc "contextless" (x: f16be, sign: int = 0) -> bool { return #force_inline is_inf_f16(f16(x), sign) } +@(require_results) is_inf_f32 :: proc "contextless" (x: f32, sign: int = 0) -> bool { class := classify(x) switch { @@ -1200,13 +1268,16 @@ is_inf_f32 :: proc "contextless" (x: f32, sign: int = 0) -> bool { } return class == .Inf || class == .Neg_Inf } +@(require_results) is_inf_f32le :: proc "contextless" (x: f32le, sign: int = 0) -> bool { return #force_inline is_inf_f32(f32(x), sign) } +@(require_results) is_inf_f32be :: proc "contextless" (x: f32be, sign: int = 0) -> bool { return #force_inline is_inf_f32(f32(x), sign) } +@(require_results) is_inf_f64 :: proc "contextless" (x: f64, sign: int = 0) -> bool { class := classify(x) switch { @@ -1217,9 +1288,11 @@ is_inf_f64 :: proc "contextless" (x: f64, sign: int = 0) -> bool { } return class == .Inf || class == .Neg_Inf } +@(require_results) is_inf_f64le :: proc "contextless" (x: f64le, sign: int = 0) -> bool { return #force_inline is_inf_f64(f64(x), sign) } +@(require_results) is_inf_f64be :: proc "contextless" (x: f64be, sign: int = 0) -> bool { return #force_inline is_inf_f64(f64(x), sign) } @@ -1229,24 +1302,31 @@ is_inf :: proc{ is_inf_f64, is_inf_f64le, is_inf_f64be, } +@(require_results) inf_f16 :: proc "contextless" (sign: int) -> f16 { return f16(inf_f64(sign)) } +@(require_results) inf_f16le :: proc "contextless" (sign: int) -> f16le { return f16le(inf_f64(sign)) } +@(require_results) inf_f16be :: proc "contextless" (sign: int) -> f16be { return f16be(inf_f64(sign)) } +@(require_results) inf_f32 :: proc "contextless" (sign: int) -> f32 { return f32(inf_f64(sign)) } +@(require_results) inf_f32le :: proc "contextless" (sign: int) -> f32le { return f32le(inf_f64(sign)) } +@(require_results) inf_f32be :: proc "contextless" (sign: int) -> f32be { return f32be(inf_f64(sign)) } +@(require_results) inf_f64 :: proc "contextless" (sign: int) -> f64 { if sign >= 0 { return 0h7ff00000_00000000 @@ -1254,45 +1334,58 @@ inf_f64 :: proc "contextless" (sign: int) -> f64 { return 0hfff00000_00000000 } } +@(require_results) inf_f64le :: proc "contextless" (sign: int) -> f64le { return f64le(inf_f64(sign)) } +@(require_results) inf_f64be :: proc "contextless" (sign: int) -> f64be { return f64be(inf_f64(sign)) } +@(require_results) nan_f16 :: proc "contextless" () -> f16 { return f16(nan_f64()) } +@(require_results) nan_f16le :: proc "contextless" () -> f16le { return f16le(nan_f64()) } +@(require_results) nan_f16be :: proc "contextless" () -> f16be { return f16be(nan_f64()) } +@(require_results) nan_f32 :: proc "contextless" () -> f32 { return f32(nan_f64()) } +@(require_results) nan_f32le :: proc "contextless" () -> f32le { return f32le(nan_f64()) } +@(require_results) nan_f32be :: proc "contextless" () -> f32be { return f32be(nan_f64()) } +@(require_results) nan_f64 :: proc "contextless" () -> f64 { return 0h7ff80000_00000001 } +@(require_results) nan_f64le :: proc "contextless" () -> f64le { return f64le(nan_f64()) } +@(require_results) nan_f64be :: proc "contextless" () -> f64be { return f64be(nan_f64()) } +@(require_results) is_power_of_two :: proc "contextless" (x: int) -> bool { return x > 0 && (x & (x-1)) == 0 } +@(require_results) next_power_of_two :: proc "contextless" (x: int) -> int { k := x -1 when size_of(int) == 8 { @@ -1307,6 +1400,7 @@ next_power_of_two :: proc "contextless" (x: int) -> int { return k } +@(require_results) sum :: proc "contextless" (x: $T/[]$E) -> (res: E) where intrinsics.type_is_numeric(E) { for i in x { @@ -1315,6 +1409,7 @@ sum :: proc "contextless" (x: $T/[]$E) -> (res: E) return } +@(require_results) prod :: proc "contextless" (x: $T/[]$E) -> (res: E) where intrinsics.type_is_numeric(E) { res = 1 @@ -1332,6 +1427,7 @@ cumsum_inplace :: proc "contextless" (x: $T/[]$E) } +@(require_results) cumsum :: proc "contextless" (dst, src: $T/[]$E) -> T where intrinsics.type_is_numeric(E) { N := min(len(dst), len(src)) @@ -1345,31 +1441,38 @@ cumsum :: proc "contextless" (dst, src: $T/[]$E) -> T } +@(require_results) atan2_f16 :: proc "contextless" (y, x: f16) -> f16 { // TODO(bill): Better atan2_f16 return f16(atan2_f64(f64(y), f64(x))) } +@(require_results) atan2_f16le :: proc "contextless" (y, x: f16le) -> f16le { // TODO(bill): Better atan2_f16 return f16le(atan2_f64(f64(y), f64(x))) } +@(require_results) atan2_f16be :: proc "contextless" (y, x: f16be) -> f16be { // TODO(bill): Better atan2_f16 return f16be(atan2_f64(f64(y), f64(x))) } +@(require_results) atan2_f32 :: proc "contextless" (y, x: f32) -> f32 { // TODO(bill): Better atan2_f32 return f32(atan2_f64(f64(y), f64(x))) } +@(require_results) atan2_f32le :: proc "contextless" (y, x: f32le) -> f32le { // TODO(bill): Better atan2_f32 return f32le(atan2_f64(f64(y), f64(x))) } +@(require_results) atan2_f32be :: proc "contextless" (y, x: f32be) -> f32be { // TODO(bill): Better atan2_f32 return f32be(atan2_f64(f64(y), f64(x))) } +@(require_results) atan2_f64 :: proc "contextless" (y, x: f64) -> f64 { // TODO(bill): Faster atan2_f64 if possible @@ -1455,10 +1558,12 @@ atan2_f64 :: proc "contextless" (y, x: f64) -> f64 { } return q } +@(require_results) atan2_f64le :: proc "contextless" (y, x: f64le) -> f64le { // TODO(bill): Better atan2_f32 return f64le(atan2_f64(f64(y), f64(x))) } +@(require_results) atan2_f64be :: proc "contextless" (y, x: f64be) -> f64be { // TODO(bill): Better atan2_f32 return f64be(atan2_f64(f64(y), f64(x))) @@ -1471,12 +1576,14 @@ atan2 :: proc{ atan2_f16le, atan2_f16be, } +@(require_results) atan :: proc "contextless" (x: $T) -> T where intrinsics.type_is_float(T) { return atan2(x, 1) } +@(require_results) asin_f64 :: proc "contextless" (x: f64) -> f64 { /* origin: FreeBSD /usr/src/lib/msun/src/e_asin.c */ /* @@ -1548,27 +1655,35 @@ asin_f64 :: proc "contextless" (x: f64) -> f64 { } return -x if hx >> 31 != 0 else x } +@(require_results) asin_f64le :: proc "contextless" (x: f64le) -> f64le { return f64le(asin_f64(f64(x))) } +@(require_results) asin_f64be :: proc "contextless" (x: f64be) -> f64be { return f64be(asin_f64(f64(x))) } +@(require_results) asin_f32 :: proc "contextless" (x: f32) -> f32 { return f32(asin_f64(f64(x))) } +@(require_results) asin_f32le :: proc "contextless" (x: f32le) -> f32le { return f32le(asin_f64(f64(x))) } +@(require_results) asin_f32be :: proc "contextless" (x: f32be) -> f32be { return f32be(asin_f64(f64(x))) } +@(require_results) asin_f16 :: proc "contextless" (x: f16) -> f16 { return f16(asin_f64(f64(x))) } +@(require_results) asin_f16le :: proc "contextless" (x: f16le) -> f16le { return f16le(asin_f64(f64(x))) } +@(require_results) asin_f16be :: proc "contextless" (x: f16be) -> f16be { return f16be(asin_f64(f64(x))) } @@ -1580,6 +1695,7 @@ asin :: proc{ } +@(require_results) acos_f64 :: proc "contextless" (x: f64) -> f64 { /* origin: FreeBSD /usr/src/lib/msun/src/e_acos.c */ /* @@ -1653,27 +1769,35 @@ acos_f64 :: proc "contextless" (x: f64) -> f64 { w = R(z)*s+c return 2*(df+w) } +@(require_results) acos_f64le :: proc "contextless" (x: f64le) -> f64le { return f64le(acos_f64(f64(x))) } +@(require_results) acos_f64be :: proc "contextless" (x: f64be) -> f64be { return f64be(acos_f64(f64(x))) } +@(require_results) acos_f32 :: proc "contextless" (x: f32) -> f32 { return f32(acos_f64(f64(x))) } +@(require_results) acos_f32le :: proc "contextless" (x: f32le) -> f32le { return f32le(acos_f64(f64(x))) } +@(require_results) acos_f32be :: proc "contextless" (x: f32be) -> f32be { return f32be(acos_f64(f64(x))) } +@(require_results) acos_f16 :: proc "contextless" (x: f16) -> f16 { return f16(acos_f64(f64(x))) } +@(require_results) acos_f16le :: proc "contextless" (x: f16le) -> f16le { return f16le(acos_f64(f64(x))) } +@(require_results) acos_f16be :: proc "contextless" (x: f16be) -> f16be { return f16be(acos_f64(f64(x))) } @@ -1684,14 +1808,17 @@ acos :: proc{ acos_f16le, acos_f16be, } +@(require_results) sinh :: proc "contextless" (x: $T) -> T where intrinsics.type_is_float(T) { return copy_sign(((exp(x) - exp(-x))*0.5), x) } +@(require_results) cosh :: proc "contextless" (x: $T) -> T where intrinsics.type_is_float(T) { return ((exp(x) + exp(-x))*0.5) } +@(require_results) tanh :: proc "contextless" (y: $T) -> T where intrinsics.type_is_float(T) { P0 :: -9.64399179425052238628e-1 P1 :: -9.92877231001918586564e1 @@ -1727,6 +1854,7 @@ tanh :: proc "contextless" (y: $T) -> T where intrinsics.type_is_float(T) { return T(z) } +@(require_results) asinh :: proc "contextless" (y: $T) -> T where intrinsics.type_is_float(T) { // The original C code, the long comment, and the constants // below are from FreeBSD's /usr/src/lib/msun/src/s_asinh.c @@ -1773,6 +1901,7 @@ asinh :: proc "contextless" (y: $T) -> T where intrinsics.type_is_float(T) { return T(temp) } +@(require_results) acosh :: proc "contextless" (y: $T) -> T where intrinsics.type_is_float(T) { // The original C code, the long comment, and the constants // below are from FreeBSD's /usr/src/lib/msun/src/e_acosh.c @@ -1804,6 +1933,7 @@ acosh :: proc "contextless" (y: $T) -> T where intrinsics.type_is_float(T) { return T(log1p(t + sqrt(2*t + t*t))) } +@(require_results) atanh :: proc "contextless" (y: $T) -> T where intrinsics.type_is_float(T) { // The original C code, the long comment, and the constants // below are from FreeBSD's /usr/src/lib/msun/src/e_atanh.c @@ -1848,6 +1978,7 @@ atanh :: proc "contextless" (y: $T) -> T where intrinsics.type_is_float(T) { return T(temp) } +@(require_results) ilogb_f16 :: proc "contextless" (val: f16) -> int { switch { case val == 0: return int(min(i32)) @@ -1857,6 +1988,7 @@ ilogb_f16 :: proc "contextless" (val: f16) -> int { x, exp := normalize_f16(val) return int(((transmute(u16)x)>>F16_SHIFT)&F16_MASK) - F16_BIAS + exp } +@(require_results) ilogb_f32 :: proc "contextless" (val: f32) -> int { switch { case val == 0: return int(min(i32)) @@ -1866,6 +1998,7 @@ ilogb_f32 :: proc "contextless" (val: f32) -> int { x, exp := normalize_f32(val) return int(((transmute(u32)x)>>F32_SHIFT)&F32_MASK) - F32_BIAS + exp } +@(require_results) ilogb_f64 :: proc "contextless" (val: f64) -> int { switch { case val == 0: return int(min(i32)) @@ -1875,12 +2008,12 @@ ilogb_f64 :: proc "contextless" (val: f64) -> int { x, exp := normalize_f64(val) return int(((transmute(u64)x)>>F64_SHIFT)&F64_MASK) - F64_BIAS + exp } -ilogb_f16le :: proc "contextless" (value: f16le) -> int { return ilogb_f16(f16(value)) } -ilogb_f16be :: proc "contextless" (value: f16be) -> int { return ilogb_f16(f16(value)) } -ilogb_f32le :: proc "contextless" (value: f32le) -> int { return ilogb_f32(f32(value)) } -ilogb_f32be :: proc "contextless" (value: f32be) -> int { return ilogb_f32(f32(value)) } -ilogb_f64le :: proc "contextless" (value: f64le) -> int { return ilogb_f64(f64(value)) } -ilogb_f64be :: proc "contextless" (value: f64be) -> int { return ilogb_f64(f64(value)) } +@(require_results) ilogb_f16le :: proc "contextless" (value: f16le) -> int { return ilogb_f16(f16(value)) } +@(require_results) ilogb_f16be :: proc "contextless" (value: f16be) -> int { return ilogb_f16(f16(value)) } +@(require_results) ilogb_f32le :: proc "contextless" (value: f32le) -> int { return ilogb_f32(f32(value)) } +@(require_results) ilogb_f32be :: proc "contextless" (value: f32be) -> int { return ilogb_f32(f32(value)) } +@(require_results) ilogb_f64le :: proc "contextless" (value: f64le) -> int { return ilogb_f64(f64(value)) } +@(require_results) ilogb_f64be :: proc "contextless" (value: f64be) -> int { return ilogb_f64(f64(value)) } ilogb :: proc { ilogb_f16, ilogb_f32, @@ -1893,6 +2026,7 @@ ilogb :: proc { ilogb_f64be, } +@(require_results) logb_f16 :: proc "contextless" (val: f16) -> f16 { switch { case val == 0: return inf_f16(-1) @@ -1901,6 +2035,7 @@ logb_f16 :: proc "contextless" (val: f16) -> f16 { } return f16(ilogb(val)) } +@(require_results) logb_f32 :: proc "contextless" (val: f32) -> f32 { switch { case val == 0: return inf_f32(-1) @@ -1909,6 +2044,7 @@ logb_f32 :: proc "contextless" (val: f32) -> f32 { } return f32(ilogb(val)) } +@(require_results) logb_f64 :: proc "contextless" (val: f64) -> f64 { switch { case val == 0: return inf_f64(-1) @@ -1917,12 +2053,12 @@ logb_f64 :: proc "contextless" (val: f64) -> f64 { } return f64(ilogb(val)) } -logb_f16le :: proc "contextless" (value: f16le) -> f16le { return f16le(logb_f16(f16(value))) } -logb_f16be :: proc "contextless" (value: f16be) -> f16be { return f16be(logb_f16(f16(value))) } -logb_f32le :: proc "contextless" (value: f32le) -> f32le { return f32le(logb_f32(f32(value))) } -logb_f32be :: proc "contextless" (value: f32be) -> f32be { return f32be(logb_f32(f32(value))) } -logb_f64le :: proc "contextless" (value: f64le) -> f64le { return f64le(logb_f64(f64(value))) } -logb_f64be :: proc "contextless" (value: f64be) -> f64be { return f64be(logb_f64(f64(value))) } +@(require_results) logb_f16le :: proc "contextless" (value: f16le) -> f16le { return f16le(logb_f16(f16(value))) } +@(require_results) logb_f16be :: proc "contextless" (value: f16be) -> f16be { return f16be(logb_f16(f16(value))) } +@(require_results) logb_f32le :: proc "contextless" (value: f32le) -> f32le { return f32le(logb_f32(f32(value))) } +@(require_results) logb_f32be :: proc "contextless" (value: f32be) -> f32be { return f32be(logb_f32(f32(value))) } +@(require_results) logb_f64le :: proc "contextless" (value: f64le) -> f64le { return f64le(logb_f64(f64(value))) } +@(require_results) logb_f64be :: proc "contextless" (value: f64be) -> f64be { return f64be(logb_f64(f64(value))) } logb :: proc { logb_f16, logb_f32, @@ -1935,6 +2071,7 @@ logb :: proc { logb_f64be, } +@(require_results) nextafter_f16 :: proc "contextless" (x, y: f16) -> (r: f16) { switch { case is_nan(x) || is_nan(y): @@ -1950,6 +2087,7 @@ nextafter_f16 :: proc "contextless" (x, y: f16) -> (r: f16) { } return } +@(require_results) nextafter_f32 :: proc "contextless" (x, y: f32) -> (r: f32) { switch { case is_nan(x) || is_nan(y): @@ -1965,6 +2103,7 @@ nextafter_f32 :: proc "contextless" (x, y: f32) -> (r: f32) { } return } +@(require_results) nextafter_f64 :: proc "contextless" (x, y: f64) -> (r: f64) { switch { case is_nan(x) || is_nan(y): @@ -1980,12 +2119,12 @@ nextafter_f64 :: proc "contextless" (x, y: f64) -> (r: f64) { } return } -nextafter_f16le :: proc "contextless" (x, y: f16le) -> (r: f16le) { return f16le(nextafter_f16(f16(x), f16(y))) } -nextafter_f16be :: proc "contextless" (x, y: f16be) -> (r: f16be) { return f16be(nextafter_f16(f16(x), f16(y))) } -nextafter_f32le :: proc "contextless" (x, y: f32le) -> (r: f32le) { return f32le(nextafter_f32(f32(x), f32(y))) } -nextafter_f32be :: proc "contextless" (x, y: f32be) -> (r: f32be) { return f32be(nextafter_f32(f32(x), f32(y))) } -nextafter_f64le :: proc "contextless" (x, y: f64le) -> (r: f64le) { return f64le(nextafter_f64(f64(x), f64(y))) } -nextafter_f64be :: proc "contextless" (x, y: f64be) -> (r: f64be) { return f64be(nextafter_f64(f64(x), f64(y))) } +@(require_results) nextafter_f16le :: proc "contextless" (x, y: f16le) -> (r: f16le) { return f16le(nextafter_f16(f16(x), f16(y))) } +@(require_results) nextafter_f16be :: proc "contextless" (x, y: f16be) -> (r: f16be) { return f16be(nextafter_f16(f16(x), f16(y))) } +@(require_results) nextafter_f32le :: proc "contextless" (x, y: f32le) -> (r: f32le) { return f32le(nextafter_f32(f32(x), f32(y))) } +@(require_results) nextafter_f32be :: proc "contextless" (x, y: f32be) -> (r: f32be) { return f32be(nextafter_f32(f32(x), f32(y))) } +@(require_results) nextafter_f64le :: proc "contextless" (x, y: f64le) -> (r: f64le) { return f64le(nextafter_f64(f64(x), f64(y))) } +@(require_results) nextafter_f64be :: proc "contextless" (x, y: f64be) -> (r: f64be) { return f64be(nextafter_f64(f64(x), f64(y))) } nextafter :: proc{ nextafter_f16, nextafter_f16le, nextafter_f16be, @@ -1993,21 +2132,24 @@ nextafter :: proc{ nextafter_f64, nextafter_f64le, nextafter_f64be, } +@(require_results) signbit_f16 :: proc "contextless" (x: f16) -> bool { return (transmute(u16)x)&(1<<15) != 0 } +@(require_results) signbit_f32 :: proc "contextless" (x: f32) -> bool { return (transmute(u32)x)&(1<<31) != 0 } +@(require_results) signbit_f64 :: proc "contextless" (x: f64) -> bool { return (transmute(u64)x)&(1<<63) != 0 } -signbit_f16le :: proc "contextless" (x: f16le) -> bool { return signbit_f16(f16(x)) } -signbit_f32le :: proc "contextless" (x: f32le) -> bool { return signbit_f32(f32(x)) } -signbit_f64le :: proc "contextless" (x: f64le) -> bool { return signbit_f64(f64(x)) } -signbit_f16be :: proc "contextless" (x: f16be) -> bool { return signbit_f16(f16(x)) } -signbit_f32be :: proc "contextless" (x: f32be) -> bool { return signbit_f32(f32(x)) } -signbit_f64be :: proc "contextless" (x: f64be) -> bool { return signbit_f64(f64(x)) } +@(require_results) signbit_f16le :: proc "contextless" (x: f16le) -> bool { return signbit_f16(f16(x)) } +@(require_results) signbit_f32le :: proc "contextless" (x: f32le) -> bool { return signbit_f32(f32(x)) } +@(require_results) signbit_f64le :: proc "contextless" (x: f64le) -> bool { return signbit_f64(f64(x)) } +@(require_results) signbit_f16be :: proc "contextless" (x: f16be) -> bool { return signbit_f16(f16(x)) } +@(require_results) signbit_f32be :: proc "contextless" (x: f32be) -> bool { return signbit_f32(f32(x)) } +@(require_results) signbit_f64be :: proc "contextless" (x: f64be) -> bool { return signbit_f64(f64(x)) } signbit :: proc{ signbit_f16, signbit_f16le, signbit_f16be, diff --git a/core/math/math_basic.odin b/core/math/math_basic.odin index c9d2e632d..785c43b10 100644 --- a/core/math/math_basic.odin +++ b/core/math/math_basic.odin @@ -5,54 +5,58 @@ import "core:intrinsics" @(default_calling_convention="none") foreign _ { - @(link_name="llvm.sin.f16") + @(link_name="llvm.sin.f16", require_results) sin_f16 :: proc(Īø: f16) -> f16 --- - @(link_name="llvm.sin.f32") + @(link_name="llvm.sin.f32", require_results) sin_f32 :: proc(Īø: f32) -> f32 --- - @(link_name="llvm.sin.f64") + @(link_name="llvm.sin.f64", require_results) sin_f64 :: proc(Īø: f64) -> f64 --- - @(link_name="llvm.cos.f16") + @(link_name="llvm.cos.f16", require_results) cos_f16 :: proc(Īø: f16) -> f16 --- - @(link_name="llvm.cos.f32") + @(link_name="llvm.cos.f32", require_results) cos_f32 :: proc(Īø: f32) -> f32 --- - @(link_name="llvm.cos.f64") + @(link_name="llvm.cos.f64", require_results) cos_f64 :: proc(Īø: f64) -> f64 --- - @(link_name="llvm.pow.f16") + @(link_name="llvm.pow.f16", require_results) pow_f16 :: proc(x, power: f16) -> f16 --- - @(link_name="llvm.pow.f32") + @(link_name="llvm.pow.f32", require_results) pow_f32 :: proc(x, power: f32) -> f32 --- - @(link_name="llvm.pow.f64") + @(link_name="llvm.pow.f64", require_results) pow_f64 :: proc(x, power: f64) -> f64 --- - @(link_name="llvm.fmuladd.f16") + @(link_name="llvm.fmuladd.f16", require_results) fmuladd_f16 :: proc(a, b, c: f16) -> f16 --- - @(link_name="llvm.fmuladd.f32") + @(link_name="llvm.fmuladd.f32", require_results) fmuladd_f32 :: proc(a, b, c: f32) -> f32 --- - @(link_name="llvm.fmuladd.f64") + @(link_name="llvm.fmuladd.f64", require_results) fmuladd_f64 :: proc(a, b, c: f64) -> f64 --- - @(link_name="llvm.exp.f16") + @(link_name="llvm.exp.f16", require_results) exp_f16 :: proc(x: f16) -> f16 --- - @(link_name="llvm.exp.f32") + @(link_name="llvm.exp.f32", require_results) exp_f32 :: proc(x: f32) -> f32 --- - @(link_name="llvm.exp.f64") + @(link_name="llvm.exp.f64", require_results) exp_f64 :: proc(x: f64) -> f64 --- } +@(require_results) sqrt_f16 :: proc "contextless" (x: f16) -> f16 { return intrinsics.sqrt(x) } +@(require_results) sqrt_f32 :: proc "contextless" (x: f32) -> f32 { return intrinsics.sqrt(x) } +@(require_results) sqrt_f64 :: proc "contextless" (x: f64) -> f64 { return intrinsics.sqrt(x) } +@(require_results) ln_f64 :: proc "contextless" (x: f64) -> f64 { // The original C code, the long comment, and the constants // below are from FreeBSD's /usr/src/lib/msun/src/e_log.c @@ -154,14 +158,14 @@ ln_f64 :: proc "contextless" (x: f64) -> f64 { return k*LN2_HI - ((hfsq - (s*(hfsq+R) + k*LN2_LO)) - f) } -ln_f16 :: proc "contextless" (x: f16) -> f16 { return #force_inline f16(ln_f64(f64(x))) } -ln_f32 :: proc "contextless" (x: f32) -> f32 { return #force_inline f32(ln_f64(f64(x))) } -ln_f16le :: proc "contextless" (x: f16le) -> f16le { return #force_inline f16le(ln_f64(f64(x))) } -ln_f16be :: proc "contextless" (x: f16be) -> f16be { return #force_inline f16be(ln_f64(f64(x))) } -ln_f32le :: proc "contextless" (x: f32le) -> f32le { return #force_inline f32le(ln_f64(f64(x))) } -ln_f32be :: proc "contextless" (x: f32be) -> f32be { return #force_inline f32be(ln_f64(f64(x))) } -ln_f64le :: proc "contextless" (x: f64le) -> f64le { return #force_inline f64le(ln_f64(f64(x))) } -ln_f64be :: proc "contextless" (x: f64be) -> f64be { return #force_inline f64be(ln_f64(f64(x))) } +@(require_results) ln_f16 :: proc "contextless" (x: f16) -> f16 { return #force_inline f16(ln_f64(f64(x))) } +@(require_results) ln_f32 :: proc "contextless" (x: f32) -> f32 { return #force_inline f32(ln_f64(f64(x))) } +@(require_results) ln_f16le :: proc "contextless" (x: f16le) -> f16le { return #force_inline f16le(ln_f64(f64(x))) } +@(require_results) ln_f16be :: proc "contextless" (x: f16be) -> f16be { return #force_inline f16be(ln_f64(f64(x))) } +@(require_results) ln_f32le :: proc "contextless" (x: f32le) -> f32le { return #force_inline f32le(ln_f64(f64(x))) } +@(require_results) ln_f32be :: proc "contextless" (x: f32be) -> f32be { return #force_inline f32be(ln_f64(f64(x))) } +@(require_results) ln_f64le :: proc "contextless" (x: f64le) -> f64le { return #force_inline f64le(ln_f64(f64(x))) } +@(require_results) ln_f64be :: proc "contextless" (x: f64be) -> f64be { return #force_inline f64be(ln_f64(f64(x))) } ln :: proc{ ln_f16, ln_f16le, ln_f16be, ln_f32, ln_f32le, ln_f32be, diff --git a/core/math/math_basic_js.odin b/core/math/math_basic_js.odin index ec572f898..acd3c2b39 100644 --- a/core/math/math_basic_js.odin +++ b/core/math/math_basic_js.odin @@ -7,46 +7,47 @@ foreign import "odin_env" @(default_calling_convention="c") foreign odin_env { - @(link_name="sin") + @(link_name="sin", require_results) sin_f64 :: proc(Īø: f64) -> f64 --- - @(link_name="cos") + @(link_name="cos", require_results) cos_f64 :: proc(Īø: f64) -> f64 --- - @(link_name="pow") + @(link_name="pow", require_results) pow_f64 :: proc(x, power: f64) -> f64 --- - @(link_name="fmuladd") + @(link_name="fmuladd", require_results) fmuladd_f64 :: proc(a, b, c: f64) -> f64 --- - @(link_name="ln") + @(link_name="ln", require_results) ln_f64 :: proc(x: f64) -> f64 --- - @(link_name="exp") + @(link_name="exp", require_results) exp_f64 :: proc(x: f64) -> f64 --- } +@(require_results) sqrt_f64 :: proc "contextless" (x: f64) -> f64 { return intrinsics.sqrt(x) } -sqrt_f16 :: proc "c" (x: f16) -> f16 { return f16(sqrt_f64(f64(x))) } -sin_f16 :: proc "c" (Īø: f16) -> f16 { return f16(sin_f64(f64(Īø))) } -cos_f16 :: proc "c" (Īø: f16) -> f16 { return f16(cos_f64(f64(Īø))) } -pow_f16 :: proc "c" (x, power: f16) -> f16 { return f16(pow_f64(f64(x), f64(power))) } -fmuladd_f16 :: proc "c" (a, b, c: f16) -> f16 { return f16(fmuladd_f64(f64(a), f64(a), f64(c))) } -ln_f16 :: proc "c" (x: f16) -> f16 { return f16(ln_f64(f64(x))) } -exp_f16 :: proc "c" (x: f16) -> f16 { return f16(exp_f64(f64(x))) } +@(require_results) sqrt_f16 :: proc "c" (x: f16) -> f16 { return f16(sqrt_f64(f64(x))) } +@(require_results) sin_f16 :: proc "c" (Īø: f16) -> f16 { return f16(sin_f64(f64(Īø))) } +@(require_results) cos_f16 :: proc "c" (Īø: f16) -> f16 { return f16(cos_f64(f64(Īø))) } +@(require_results) pow_f16 :: proc "c" (x, power: f16) -> f16 { return f16(pow_f64(f64(x), f64(power))) } +@(require_results) fmuladd_f16 :: proc "c" (a, b, c: f16) -> f16 { return f16(fmuladd_f64(f64(a), f64(a), f64(c))) } +@(require_results) ln_f16 :: proc "c" (x: f16) -> f16 { return f16(ln_f64(f64(x))) } +@(require_results) exp_f16 :: proc "c" (x: f16) -> f16 { return f16(exp_f64(f64(x))) } -sqrt_f32 :: proc "c" (x: f32) -> f32 { return f32(sqrt_f64(f64(x))) } -sin_f32 :: proc "c" (Īø: f32) -> f32 { return f32(sin_f64(f64(Īø))) } -cos_f32 :: proc "c" (Īø: f32) -> f32 { return f32(cos_f64(f64(Īø))) } -pow_f32 :: proc "c" (x, power: f32) -> f32 { return f32(pow_f64(f64(x), f64(power))) } -fmuladd_f32 :: proc "c" (a, b, c: f32) -> f32 { return f32(fmuladd_f64(f64(a), f64(a), f64(c))) } -ln_f32 :: proc "c" (x: f32) -> f32 { return f32(ln_f64(f64(x))) } -exp_f32 :: proc "c" (x: f32) -> f32 { return f32(exp_f64(f64(x))) } +@(require_results) sqrt_f32 :: proc "c" (x: f32) -> f32 { return f32(sqrt_f64(f64(x))) } +@(require_results) sin_f32 :: proc "c" (Īø: f32) -> f32 { return f32(sin_f64(f64(Īø))) } +@(require_results) cos_f32 :: proc "c" (Īø: f32) -> f32 { return f32(cos_f64(f64(Īø))) } +@(require_results) pow_f32 :: proc "c" (x, power: f32) -> f32 { return f32(pow_f64(f64(x), f64(power))) } +@(require_results) fmuladd_f32 :: proc "c" (a, b, c: f32) -> f32 { return f32(fmuladd_f64(f64(a), f64(a), f64(c))) } +@(require_results) ln_f32 :: proc "c" (x: f32) -> f32 { return f32(ln_f64(f64(x))) } +@(require_results) exp_f32 :: proc "c" (x: f32) -> f32 { return f32(exp_f64(f64(x))) } -ln_f16le :: proc "contextless" (x: f16le) -> f16le { return #force_inline f16le(ln_f64(f64(x))) } -ln_f16be :: proc "contextless" (x: f16be) -> f16be { return #force_inline f16be(ln_f64(f64(x))) } -ln_f32le :: proc "contextless" (x: f32le) -> f32le { return #force_inline f32le(ln_f64(f64(x))) } -ln_f32be :: proc "contextless" (x: f32be) -> f32be { return #force_inline f32be(ln_f64(f64(x))) } -ln_f64le :: proc "contextless" (x: f64le) -> f64le { return #force_inline f64le(ln_f64(f64(x))) } -ln_f64be :: proc "contextless" (x: f64be) -> f64be { return #force_inline f64be(ln_f64(f64(x))) } +@(require_results) ln_f16le :: proc "contextless" (x: f16le) -> f16le { return #force_inline f16le(ln_f64(f64(x))) } +@(require_results) ln_f16be :: proc "contextless" (x: f16be) -> f16be { return #force_inline f16be(ln_f64(f64(x))) } +@(require_results) ln_f32le :: proc "contextless" (x: f32le) -> f32le { return #force_inline f32le(ln_f64(f64(x))) } +@(require_results) ln_f32be :: proc "contextless" (x: f32be) -> f32be { return #force_inline f32be(ln_f64(f64(x))) } +@(require_results) ln_f64le :: proc "contextless" (x: f64le) -> f64le { return #force_inline f64le(ln_f64(f64(x))) } +@(require_results) ln_f64be :: proc "contextless" (x: f64be) -> f64be { return #force_inline f64be(ln_f64(f64(x))) } ln :: proc{ ln_f16, ln_f16le, ln_f16be, ln_f32, ln_f32le, ln_f32be, diff --git a/core/math/math_erf.odin b/core/math/math_erf.odin index cdade59c5..b5a4663ae 100644 --- a/core/math/math_erf.odin +++ b/core/math/math_erf.odin @@ -117,13 +117,14 @@ erf :: proc{ erf_f64, } -erf_f16 :: proc "contextless" (x: f16) -> f16 { return f16(erf_f64(f64(x))) } -erf_f16le :: proc "contextless" (x: f16le) -> f16le { return f16le(erf_f64(f64(x))) } -erf_f16be :: proc "contextless" (x: f16be) -> f16be { return f16be(erf_f64(f64(x))) } -erf_f32 :: proc "contextless" (x: f32) -> f32 { return f32(erf_f64(f64(x))) } -erf_f32le :: proc "contextless" (x: f32le) -> f32le { return f32le(erf_f64(f64(x))) } -erf_f32be :: proc "contextless" (x: f32be) -> f32be { return f32be(erf_f64(f64(x))) } +@(require_results) erf_f16 :: proc "contextless" (x: f16) -> f16 { return f16(erf_f64(f64(x))) } +@(require_results) erf_f16le :: proc "contextless" (x: f16le) -> f16le { return f16le(erf_f64(f64(x))) } +@(require_results) erf_f16be :: proc "contextless" (x: f16be) -> f16be { return f16be(erf_f64(f64(x))) } +@(require_results) erf_f32 :: proc "contextless" (x: f32) -> f32 { return f32(erf_f64(f64(x))) } +@(require_results) erf_f32le :: proc "contextless" (x: f32le) -> f32le { return f32le(erf_f64(f64(x))) } +@(require_results) erf_f32be :: proc "contextless" (x: f32be) -> f32be { return f32be(erf_f64(f64(x))) } +@(require_results) erf_f64 :: proc "contextless" (x: f64) -> f64 { erx :: 0h3FEB0AC160000000 // Coefficients for approximation to erf in [0, 0.84375] @@ -268,13 +269,14 @@ erfc :: proc{ erfc_f64, } -erfc_f16 :: proc "contextless" (x: f16) -> f16 { return f16(erfc_f64(f64(x))) } -erfc_f16le :: proc "contextless" (x: f16le) -> f16le { return f16le(erfc_f64(f64(x))) } -erfc_f16be :: proc "contextless" (x: f16be) -> f16be { return f16be(erfc_f64(f64(x))) } -erfc_f32 :: proc "contextless" (x: f32) -> f32 { return f32(erfc_f64(f64(x))) } -erfc_f32le :: proc "contextless" (x: f32le) -> f32le { return f32le(erfc_f64(f64(x))) } -erfc_f32be :: proc "contextless" (x: f32be) -> f32be { return f32be(erfc_f64(f64(x))) } +@(require_results) erfc_f16 :: proc "contextless" (x: f16) -> f16 { return f16(erfc_f64(f64(x))) } +@(require_results) erfc_f16le :: proc "contextless" (x: f16le) -> f16le { return f16le(erfc_f64(f64(x))) } +@(require_results) erfc_f16be :: proc "contextless" (x: f16be) -> f16be { return f16be(erfc_f64(f64(x))) } +@(require_results) erfc_f32 :: proc "contextless" (x: f32) -> f32 { return f32(erfc_f64(f64(x))) } +@(require_results) erfc_f32le :: proc "contextless" (x: f32le) -> f32le { return f32le(erfc_f64(f64(x))) } +@(require_results) erfc_f32be :: proc "contextless" (x: f32be) -> f32be { return f32be(erfc_f64(f64(x))) } +@(require_results) erfc_f64 :: proc "contextless" (x: f64) -> f64 { erx :: 0h3FEB0AC160000000 // Coefficients for approximation to erf in [0, 0.84375] diff --git a/core/math/math_gamma.odin b/core/math/math_gamma.odin index 6b783cc25..00d4b7316 100644 --- a/core/math/math_gamma.odin +++ b/core/math/math_gamma.odin @@ -65,7 +65,7 @@ package math // The polynomial is valid for 33 <= x <= 172; larger values are only used // in reciprocal and produce denormalized floats. The lower precision there // masks any imprecision in the polynomial. -@(private="file") +@(private="file", require_results) stirling :: proc "contextless" (x: f64) -> (f64, f64) { @(static) gamS := [?]f64{ +7.87311395793093628397e-04, @@ -93,6 +93,7 @@ stirling :: proc "contextless" (x: f64) -> (f64, f64) { return y1, SQRT_TWO_PI * w * y2 } +@(require_results) gamma_f64 :: proc "contextless" (x: f64) -> f64 { is_neg_int :: proc "contextless" (x: f64) -> bool { if x < 0 { @@ -210,14 +211,14 @@ gamma_f64 :: proc "contextless" (x: f64) -> f64 { } -gamma_f16 :: proc "contextless" (x: f16) -> f16 { return f16(gamma_f64(f64(x))) } -gamma_f16le :: proc "contextless" (x: f16le) -> f16le { return f16le(gamma_f64(f64(x))) } -gamma_f16be :: proc "contextless" (x: f16be) -> f16be { return f16be(gamma_f64(f64(x))) } -gamma_f32 :: proc "contextless" (x: f32) -> f32 { return f32(gamma_f64(f64(x))) } -gamma_f32le :: proc "contextless" (x: f32le) -> f32le { return f32le(gamma_f64(f64(x))) } -gamma_f32be :: proc "contextless" (x: f32be) -> f32be { return f32be(gamma_f64(f64(x))) } -gamma_f64le :: proc "contextless" (x: f64le) -> f64le { return f64le(gamma_f64(f64(x))) } -gamma_f64be :: proc "contextless" (x: f64be) -> f64be { return f64be(gamma_f64(f64(x))) } +@(require_results) gamma_f16 :: proc "contextless" (x: f16) -> f16 { return f16(gamma_f64(f64(x))) } +@(require_results) gamma_f16le :: proc "contextless" (x: f16le) -> f16le { return f16le(gamma_f64(f64(x))) } +@(require_results) gamma_f16be :: proc "contextless" (x: f16be) -> f16be { return f16be(gamma_f64(f64(x))) } +@(require_results) gamma_f32 :: proc "contextless" (x: f32) -> f32 { return f32(gamma_f64(f64(x))) } +@(require_results) gamma_f32le :: proc "contextless" (x: f32le) -> f32le { return f32le(gamma_f64(f64(x))) } +@(require_results) gamma_f32be :: proc "contextless" (x: f32be) -> f32be { return f32be(gamma_f64(f64(x))) } +@(require_results) gamma_f64le :: proc "contextless" (x: f64le) -> f64le { return f64le(gamma_f64(f64(x))) } +@(require_results) gamma_f64be :: proc "contextless" (x: f64be) -> f64be { return f64be(gamma_f64(f64(x))) } gamma :: proc{ gamma_f16, gamma_f16le, gamma_f16be, diff --git a/core/math/math_lgamma.odin b/core/math/math_lgamma.odin index 98b2731c9..0705d8564 100644 --- a/core/math/math_lgamma.odin +++ b/core/math/math_lgamma.odin @@ -80,7 +80,9 @@ package math // +@(require_results) lgamma_f64 :: proc "contextless" (x: f64) -> (lgamma: f64, sign: int) { + @(require_results) sin_pi :: proc "contextless" (x: f64) -> f64 { if x < 0.25 { return -sin(PI * x) @@ -345,14 +347,14 @@ lgamma_f64 :: proc "contextless" (x: f64) -> (lgamma: f64, sign: int) { } -lgamma_f16 :: proc "contextless" (x: f16) -> (lgamma: f16, sign: int) { r, s := lgamma_f64(f64(x)); return f16(r), s } -lgamma_f32 :: proc "contextless" (x: f32) -> (lgamma: f32, sign: int) { r, s := lgamma_f64(f64(x)); return f32(r), s } -lgamma_f16le :: proc "contextless" (x: f16le) -> (lgamma: f16le, sign: int) { r, s := lgamma_f64(f64(x)); return f16le(r), s } -lgamma_f16be :: proc "contextless" (x: f16be) -> (lgamma: f16be, sign: int) { r, s := lgamma_f64(f64(x)); return f16be(r), s } -lgamma_f32le :: proc "contextless" (x: f32le) -> (lgamma: f32le, sign: int) { r, s := lgamma_f64(f64(x)); return f32le(r), s } -lgamma_f32be :: proc "contextless" (x: f32be) -> (lgamma: f32be, sign: int) { r, s := lgamma_f64(f64(x)); return f32be(r), s } -lgamma_f64le :: proc "contextless" (x: f64le) -> (lgamma: f64le, sign: int) { r, s := lgamma_f64(f64(x)); return f64le(r), s } -lgamma_f64be :: proc "contextless" (x: f64be) -> (lgamma: f64be, sign: int) { r, s := lgamma_f64(f64(x)); return f64be(r), s } +@(require_results) lgamma_f16 :: proc "contextless" (x: f16) -> (lgamma: f16, sign: int) { r, s := lgamma_f64(f64(x)); return f16(r), s } +@(require_results) lgamma_f32 :: proc "contextless" (x: f32) -> (lgamma: f32, sign: int) { r, s := lgamma_f64(f64(x)); return f32(r), s } +@(require_results) lgamma_f16le :: proc "contextless" (x: f16le) -> (lgamma: f16le, sign: int) { r, s := lgamma_f64(f64(x)); return f16le(r), s } +@(require_results) lgamma_f16be :: proc "contextless" (x: f16be) -> (lgamma: f16be, sign: int) { r, s := lgamma_f64(f64(x)); return f16be(r), s } +@(require_results) lgamma_f32le :: proc "contextless" (x: f32le) -> (lgamma: f32le, sign: int) { r, s := lgamma_f64(f64(x)); return f32le(r), s } +@(require_results) lgamma_f32be :: proc "contextless" (x: f32be) -> (lgamma: f32be, sign: int) { r, s := lgamma_f64(f64(x)); return f32be(r), s } +@(require_results) lgamma_f64le :: proc "contextless" (x: f64le) -> (lgamma: f64le, sign: int) { r, s := lgamma_f64(f64(x)); return f64le(r), s } +@(require_results) lgamma_f64be :: proc "contextless" (x: f64be) -> (lgamma: f64be, sign: int) { r, s := lgamma_f64(f64(x)); return f64be(r), s } lgamma :: proc{ lgamma_f16, lgamma_f16le, lgamma_f16be, diff --git a/core/math/math_log1p.odin b/core/math/math_log1p.odin index a4a1aa2ae..fc10ed364 100644 --- a/core/math/math_log1p.odin +++ b/core/math/math_log1p.odin @@ -90,15 +90,16 @@ log1p :: proc { log1p_f64le, log1p_f64be, } -log1p_f16 :: proc "contextless" (x: f16) -> f16 { return f16(log1p_f64(f64(x))) } -log1p_f32 :: proc "contextless" (x: f32) -> f32 { return f32(log1p_f64(f64(x))) } -log1p_f16le :: proc "contextless" (x: f16le) -> f16le { return f16le(log1p_f64(f64(x))) } -log1p_f16be :: proc "contextless" (x: f16be) -> f16be { return f16be(log1p_f64(f64(x))) } -log1p_f32le :: proc "contextless" (x: f32le) -> f32le { return f32le(log1p_f64(f64(x))) } -log1p_f32be :: proc "contextless" (x: f32be) -> f32be { return f32be(log1p_f64(f64(x))) } -log1p_f64le :: proc "contextless" (x: f64le) -> f64le { return f64le(log1p_f64(f64(x))) } -log1p_f64be :: proc "contextless" (x: f64be) -> f64be { return f64be(log1p_f64(f64(x))) } +@(require_results) log1p_f16 :: proc "contextless" (x: f16) -> f16 { return f16(log1p_f64(f64(x))) } +@(require_results) log1p_f32 :: proc "contextless" (x: f32) -> f32 { return f32(log1p_f64(f64(x))) } +@(require_results) log1p_f16le :: proc "contextless" (x: f16le) -> f16le { return f16le(log1p_f64(f64(x))) } +@(require_results) log1p_f16be :: proc "contextless" (x: f16be) -> f16be { return f16be(log1p_f64(f64(x))) } +@(require_results) log1p_f32le :: proc "contextless" (x: f32le) -> f32le { return f32le(log1p_f64(f64(x))) } +@(require_results) log1p_f32be :: proc "contextless" (x: f32be) -> f32be { return f32be(log1p_f64(f64(x))) } +@(require_results) log1p_f64le :: proc "contextless" (x: f64le) -> f64le { return f64le(log1p_f64(f64(x))) } +@(require_results) log1p_f64be :: proc "contextless" (x: f64be) -> f64be { return f64be(log1p_f64(f64(x))) } +@(require_results) log1p_f64 :: proc "contextless" (x: f64) -> f64 { SQRT2_M1 :: 0h3fda827999fcef34 // sqrt(2)-1 SQRT2_HALF_M1 :: 0hbfd2bec333018866 // sqrt(2)/2-1 diff --git a/core/math/noise/opensimplex2.odin b/core/math/noise/opensimplex2.odin index d90dafdf5..d28356f2c 100644 --- a/core/math/noise/opensimplex2.odin +++ b/core/math/noise/opensimplex2.odin @@ -20,6 +20,7 @@ Vec4 :: [4]f64 /* 2D Simplex noise, standard lattice orientation. */ +@(require_results) noise_2d :: proc(seed: i64, coord: Vec2) -> (value: f32) { // Get points for A2* lattice skew := SKEW_2D * (coord.x + coord.y) @@ -35,6 +36,7 @@ noise_2d :: proc(seed: i64, coord: Vec2) -> (value: f32) { unless your map is centered around an equator. It's a subtle difference, but the option is here to make it an easy choice. */ +@(require_results) noise_2d_improve_x :: proc(seed: i64, coord: Vec2) -> (value: f32) { // Skew transform and rotation baked into one. xx := coord.x * ROOT_2_OVER_2 @@ -51,6 +53,7 @@ noise_2d_improve_x :: proc(seed: i64, coord: Vec2) -> (value: f32) { If Z is vertical in world coordinates, call `noise_3d_improve_xz(x, y, Z)`. For a time varied animation, call `noise_3d_improve_xz(x, y, T)`. */ +@(require_results) noise_3d_improve_xy :: proc(seed: i64, coord: Vec3) -> (value: f32) { /* Re-orient the cubic lattices without skewing, so Z points up the main lattice diagonal, @@ -75,6 +78,7 @@ noise_3d_improve_xy :: proc(seed: i64, coord: Vec3) -> (value: f32) { If Z is vertical in world coordinates, call `noise_3d_improve_xz(x, Z, y)` or use `noise_3d_improve_xy`. For a time varied animation, call `noise_3d_improve_xz(x, T, y)` or use `noise_3d_improve_xy`. */ +@(require_results) noise_3d_improve_xz :: proc(seed: i64, coord: Vec3) -> (value: f32) { /* Re-orient the cubic lattices without skewing, so Y points up the main lattice diagonal, @@ -96,6 +100,7 @@ noise_3d_improve_xz :: proc(seed: i64, coord: Vec3) -> (value: f32) { Use `noise_3d_improve_xy` or `noise_3d_improve_xz` instead, wherever appropriate. They have less diagonal bias. This function's best use is as a fallback. */ +@(require_results) noise_3d_fallback :: proc(seed: i64, coord: Vec3) -> (value: f32) { /* Re-orient the cubic lattices via rotation, to produce a familiar look. @@ -114,6 +119,7 @@ noise_3d_fallback :: proc(seed: i64, coord: Vec3) -> (value: f32) { Recommended for time-varied animations which texture a 3D object (W=time) in a space where Z is vertical. */ +@(require_results) noise_4d_improve_xyz_improve_xy :: proc(seed: i64, coord: Vec4) -> (value: f32) { xy := coord.x + coord.y s2 := xy * -0.21132486540518699998 @@ -133,6 +139,7 @@ noise_4d_improve_xyz_improve_xy :: proc(seed: i64, coord: Vec4) -> (value: f32) Recommended for time-varied animations which texture a 3D object (W=time) in a space where Y is vertical. */ +@(require_results) noise_4d_improve_xyz_improve_xz :: proc(seed: i64, coord: Vec4) -> (value: f32) { xz := coord.x + coord.z s2 := xz * -0.21132486540518699998 @@ -152,6 +159,7 @@ noise_4d_improve_xyz_improve_xz :: proc(seed: i64, coord: Vec4) -> (value: f32) Recommended for time-varied animations which texture a 3D object (W=time) where there isn't a clear distinction between horizontal and vertical */ +@(require_results) noise_4d_improve_xyz :: proc(seed: i64, coord: Vec4) -> (value: f32) { xyz := coord.x + coord.y + coord.z ww := coord.w * 0.2236067977499788 @@ -164,6 +172,7 @@ noise_4d_improve_xyz :: proc(seed: i64, coord: Vec4) -> (value: f32) { /* 4D OpenSimplex2 noise, fallback lattice orientation. */ +@(require_results) noise_4d_fallback :: proc(seed: i64, coord: Vec4) -> (value: f32) { // Get points for A4 lattice skew := f64(SKEW_4D) * (coord.x + coord.y + coord.z + coord.w) diff --git a/core/math/rand/distributions.odin b/core/math/rand/distributions.odin index ada89afad..9365e8b76 100644 --- a/core/math/rand/distributions.odin +++ b/core/math/rand/distributions.odin @@ -7,6 +7,7 @@ float32_uniform :: float32_range // Triangular Distribution // See: http://wikipedia.org/wiki/Triangular_distribution +@(require_results) float64_triangular :: proc(lo, hi: f64, mode: Maybe(f64), r: ^Rand = nil) -> f64 { if hi-lo == 0 { return lo @@ -24,6 +25,7 @@ float64_triangular :: proc(lo, hi: f64, mode: Maybe(f64), r: ^Rand = nil) -> f64 } // Triangular Distribution // See: http://wikipedia.org/wiki/Triangular_distribution +@(require_results) float32_triangular :: proc(lo, hi: f32, mode: Maybe(f32), r: ^Rand = nil) -> f32 { if hi-lo == 0 { return lo @@ -41,20 +43,24 @@ float32_triangular :: proc(lo, hi: f32, mode: Maybe(f32), r: ^Rand = nil) -> f32 // Normal/Gaussian Distribution +@(require_results) float64_normal :: proc(mean, stddev: f64, r: ^Rand = nil) -> f64 { return norm_float64(r) * stddev + mean } // Normal/Gaussian Distribution +@(require_results) float32_normal :: proc(mean, stddev: f32, r: ^Rand = nil) -> f32 { return f32(float64_normal(f64(mean), f64(stddev), r)) } // Log Normal Distribution +@(require_results) float64_log_normal :: proc(mean, stddev: f64, r: ^Rand = nil) -> f64 { return math.exp(float64_normal(mean, stddev, r)) } // Log Normal Distribution +@(require_results) float32_log_normal :: proc(mean, stddev: f32, r: ^Rand = nil) -> f32 { return f32(float64_log_normal(f64(mean), f64(stddev), r)) } @@ -65,6 +71,7 @@ float32_log_normal :: proc(mean, stddev: f32, r: ^Rand = nil) -> f32 { // Return values range from // 0 to positive infinity if lambda > 0 // negative infinity to 0 if lambda <= 0 +@(require_results) float64_exponential :: proc(lambda: f64, r: ^Rand = nil) -> f64 { return - math.ln(1 - float64(r)) / lambda } @@ -73,6 +80,7 @@ float64_exponential :: proc(lambda: f64, r: ^Rand = nil) -> f64 { // Return values range from // 0 to positive infinity if lambda > 0 // negative infinity to 0 if lambda <= 0 +@(require_results) float32_exponential :: proc(lambda: f32, r: ^Rand = nil) -> f32 { return f32(float64_exponential(f64(lambda), r)) } @@ -87,6 +95,7 @@ float32_exponential :: proc(lambda: f32, r: ^Rand = nil) -> f32 { // math.gamma(alpha) * math.pow(beta, alpha) // // mean is alpha*beta, variance is math.pow(alpha*beta, 2) +@(require_results) float64_gamma :: proc(alpha, beta: f64, r: ^Rand = nil) -> f64 { if alpha <= 0 || beta <= 0 { panic(#procedure + ": alpha and beta must be > 0.0") @@ -152,6 +161,7 @@ float64_gamma :: proc(alpha, beta: f64, r: ^Rand = nil) -> f64 { // math.gamma(alpha) * math.pow(beta, alpha) // // mean is alpha*beta, variance is math.pow(alpha*beta, 2) +@(require_results) float32_gamma :: proc(alpha, beta: f32, r: ^Rand = nil) -> f32 { return f32(float64_gamma(f64(alpha), f64(beta), r)) } @@ -162,6 +172,7 @@ float32_gamma :: proc(alpha, beta: f32, r: ^Rand = nil) -> f32 { // Required: alpha > 0 and beta > 0 // // Return values range between 0 and 1 +@(require_results) float64_beta :: proc(alpha, beta: f64, r: ^Rand = nil) -> f64 { if alpha <= 0 || beta <= 0 { panic(#procedure + ": alpha and beta must be > 0.0") @@ -178,6 +189,7 @@ float64_beta :: proc(alpha, beta: f64, r: ^Rand = nil) -> f64 { // Required: alpha > 0 and beta > 0 // // Return values range between 0 and 1 +@(require_results) float32_beta :: proc(alpha, beta: f32, r: ^Rand = nil) -> f32 { return f32(float64_beta(f64(alpha), f64(beta), r)) } @@ -185,22 +197,26 @@ float32_beta :: proc(alpha, beta: f32, r: ^Rand = nil) -> f32 { // Pareto distribution, `alpha` is the shape parameter. // https://wikipedia.org/wiki/Pareto_distribution +@(require_results) float64_pareto :: proc(alpha: f64, r: ^Rand = nil) -> f64 { return math.pow(1 - float64(r), -1.0 / alpha) } // Pareto distribution, `alpha` is the shape parameter. // https://wikipedia.org/wiki/Pareto_distribution +@(require_results) float32_pareto :: proc(alpha, beta: f32, r: ^Rand = nil) -> f32 { return f32(float64_pareto(f64(alpha), r)) } // Weibull distribution, `alpha` is the scale parameter, `beta` is the shape parameter. +@(require_results) float64_weibull :: proc(alpha, beta: f64, r: ^Rand = nil) -> f64 { u := 1 - float64(r) return alpha * math.pow(-math.ln(u), 1.0/beta) } // Weibull distribution, `alpha` is the scale parameter, `beta` is the shape parameter. +@(require_results) float32_weibull :: proc(alpha, beta: f32, r: ^Rand = nil) -> f32 { return f32(float64_weibull(f64(alpha), f64(beta), r)) } @@ -210,6 +226,7 @@ float32_weibull :: proc(alpha, beta: f32, r: ^Rand = nil) -> f32 { // `mean_angle` is the in mean angle between 0 and 2pi radians // `kappa` is the concentration parameter which must be >= 0 // When `kappa` is zero, the Distribution is a uniform Distribution over the range 0 to 2pi +@(require_results) float64_von_mises :: proc(mean_angle, kappa: f64, r: ^Rand = nil) -> f64 { // Fisher, N.I., "Statistical Analysis of Circular Data", Cambridge University Press, 1993. @@ -245,6 +262,7 @@ float64_von_mises :: proc(mean_angle, kappa: f64, r: ^Rand = nil) -> f64 { // `mean_angle` is the in mean angle between 0 and 2pi radians // `kappa` is the concentration parameter which must be >= 0 // When `kappa` is zero, the Distribution is a uniform Distribution over the range 0 to 2pi +@(require_results) float32_von_mises :: proc(mean_angle, kappa: f32, r: ^Rand = nil) -> f32 { return f32(float64_von_mises(f64(mean_angle), f64(kappa), r)) } @@ -252,6 +270,7 @@ float32_von_mises :: proc(mean_angle, kappa: f32, r: ^Rand = nil) -> f32 { // Cauchy-Lorentz Distribution // `x_0` is the location, `gamma` is the scale where `gamma` > 0 +@(require_results) float64_cauchy_lorentz :: proc(x_0, gamma: f64, r: ^Rand = nil) -> f64 { assert(gamma > 0) @@ -261,6 +280,7 @@ float64_cauchy_lorentz :: proc(x_0, gamma: f64, r: ^Rand = nil) -> f64 { } // Cauchy-Lorentz Distribution // `x_0` is the location, `gamma` is the scale where `gamma` > 0 +@(require_results) float32_cauchy_lorentz :: proc(x_0, gamma: f32, r: ^Rand = nil) -> f32 { return f32(float64_cauchy_lorentz(f64(x_0), f64(gamma), r)) } @@ -268,12 +288,14 @@ float32_cauchy_lorentz :: proc(x_0, gamma: f32, r: ^Rand = nil) -> f32 { // Log Cauchy-Lorentz Distribution // `x_0` is the location, `gamma` is the scale where `gamma` > 0 +@(require_results) float64_log_cauchy_lorentz :: proc(x_0, gamma: f64, r: ^Rand = nil) -> f64 { assert(gamma > 0) return math.exp(math.tan(math.PI * (float64(r) - 0.5))*gamma + x_0) } // Log Cauchy-Lorentz Distribution // `x_0` is the location, `gamma` is the scale where `gamma` > 0 +@(require_results) float32_log_cauchy_lorentz :: proc(x_0, gamma: f32, r: ^Rand = nil) -> f32 { return f32(float64_log_cauchy_lorentz(f64(x_0), f64(gamma), r)) } @@ -281,6 +303,7 @@ float32_log_cauchy_lorentz :: proc(x_0, gamma: f32, r: ^Rand = nil) -> f32 { // Laplace Distribution // `b` is the scale where `b` > 0 +@(require_results) float64_laplace :: proc(mean, b: f64, r: ^Rand = nil) -> f64 { assert(b > 0) p := float64(r)-0.5 @@ -288,6 +311,7 @@ float64_laplace :: proc(mean, b: f64, r: ^Rand = nil) -> f64 { } // Laplace Distribution // `b` is the scale where `b` > 0 +@(require_results) float32_laplace :: proc(mean, b: f32, r: ^Rand = nil) -> f32 { return f32(float64_laplace(f64(mean), f64(b), r)) } @@ -296,6 +320,7 @@ float32_laplace :: proc(mean, b: f32, r: ^Rand = nil) -> f32 { // Gompertz Distribution // `eta` is the shape, `b` is the scale // Both `eta` and `b` must be > 0 +@(require_results) float64_gompertz :: proc(eta, b: f64, r: ^Rand = nil) -> f64 { if eta <= 0 || b <= 0 { panic(#procedure + ": eta and b must be > 0.0") @@ -307,6 +332,7 @@ float64_gompertz :: proc(eta, b: f64, r: ^Rand = nil) -> f64 { // Gompertz Distribution // `eta` is the shape, `b` is the scale // Both `eta` and `b` must be > 0 +@(require_results) float32_gompertz :: proc(eta, b: f32, r: ^Rand = nil) -> f32 { return f32(float64_gompertz(f64(eta), f64(b), r)) } diff --git a/core/math/rand/exp.odin b/core/math/rand/exp.odin index c0f92e99c..719debe75 100644 --- a/core/math/rand/exp.odin +++ b/core/math/rand/exp.odin @@ -15,6 +15,7 @@ import "core:math" // https://www.jstatsoft.org/index.php/jss/article/view/v005i08/ziggurat.pdf [pdf] // https://www.jstatsoft.org/article/view/v005i08 [web page] // +@(require_results) exp_float64 :: proc(r: ^Rand = nil) -> f64 { re :: 7.69711747013104972 diff --git a/core/math/rand/normal.odin b/core/math/rand/normal.odin index a9edd0f19..f96163fe9 100644 --- a/core/math/rand/normal.odin +++ b/core/math/rand/normal.odin @@ -17,6 +17,7 @@ import "core:math" // https://www.jstatsoft.org/index.php/jss/article/view/v005i08/ziggurat.pdf [pdf] // https://www.jstatsoft.org/article/view/v005i08 [web page] // +@(require_results) norm_float64 :: proc(r: ^Rand = nil) -> f64 { rn :: 3.442619855899 diff --git a/core/math/rand/rand.odin b/core/math/rand/rand.odin index 2d92d29ff..2fec1efc5 100644 --- a/core/math/rand/rand.odin +++ b/core/math/rand/rand.odin @@ -1,6 +1,10 @@ +/* +Package core:math/rand implements various random number generators +*/ package rand import "core:intrinsics" +import "core:mem" Rand :: struct { state: u64, @@ -12,16 +16,82 @@ Rand :: struct { @(private) global_rand := create(u64(intrinsics.read_cycle_counter())) +/* +Sets the seed used by the global random number generator. + +Inputs: +- seed: The seed value + +Example: + import "core:math/rand" + import "core:fmt" + + set_global_seed_example :: proc() { + rand.set_global_seed(1) + fmt.println(rand.uint64()) + } + +Possible Output: + + 10 + +*/ set_global_seed :: proc(seed: u64) { init(&global_rand, seed) } -create :: proc(seed: u64) -> Rand { +/* +Creates a new random number generator. + +Inputs: +- seed: The seed value to create the random number generator with + +Returns: +- res: The created random number generator + +Example: + import "core:math/rand" + import "core:fmt" + + create_example :: proc() { + my_rand := rand.create(1) + fmt.println(rand.uint64(&my_rand)) + } + +Possible Output: + + 10 + +*/ +@(require_results) +create :: proc(seed: u64) -> (res: Rand) { r: Rand init(&r, seed) return r } +/* +Initialises a random number generator. + +Inputs: +- r: The random number generator to initialise +- seed: The seed value to initialise this random number generator + +Example: + import "core:math/rand" + import "core:fmt" + + init_example :: proc() { + my_rand: rand.Rand + rand.init(&my_rand, 1) + fmt.println(rand.uint64(&my_rand)) + } + +Possible Output: + + 10 + +*/ init :: proc(r: ^Rand, seed: u64) { r.state = 0 r.inc = (seed << 1) | 1 @@ -30,6 +100,35 @@ init :: proc(r: ^Rand, seed: u64) { _random(r) } +/* +Initialises a random number generator to use the system random number generator. +The system random number generator is platform specific. +On `linux` refer to the `getrandom` syscall. +On `darwin` refer to `getentropy`. +On `windows` refer to `BCryptGenRandom`. + +All other platforms wi + +Inputs: +- r: The random number generator to use the system random number generator + +WARNING: Panics if the system is not either `windows`, `darwin` or `linux` + +Example: + import "core:math/rand" + import "core:fmt" + + init_as_system_example :: proc() { + my_rand: rand.Rand + rand.init_as_system(&my_rand) + fmt.println(rand.uint64(&my_rand)) + } + +Possible Output: + + 10 + +*/ init_as_system :: proc(r: ^Rand) { if !#defined(_system_random) { panic(#procedure + " is not supported on this platform yet") @@ -60,15 +159,99 @@ _random :: proc(r: ^Rand) -> u32 { return (xor_shifted >> rot) | (xor_shifted << ((-rot) & 31)) } -uint32 :: proc(r: ^Rand = nil) -> u32 { return _random(r) } +/* +Generates a random 32 bit value using the provided random number generator. If no generator is provided the global random number generator will be used. -uint64 :: proc(r: ^Rand = nil) -> u64 { +Inputs: +- r: The random number generator to use, or nil for the global generator + +Returns: +- val: A random unsigned 32 bit value + +Example: + import "core:math/rand" + import "core:fmt" + + uint32_example :: proc() { + // Using the global random number generator + fmt.println(rand.uint32()) + // Using local random number generator + my_rand := rand.create(1) + fmt.println(rand.uint32(&my_rand)) + } + +Possible Output: + + 10 + 389 + +*/ +@(require_results) +uint32 :: proc(r: ^Rand = nil) -> (val: u32) { return _random(r) } + +/* +Generates a random 64 bit value using the provided random number generator. If no generator is provided the global random number generator will be used. + +Inputs: +- r: The random number generator to use, or nil for the global generator + +Returns: +- val: A random unsigned 64 bit value + +Example: + import "core:math/rand" + import "core:fmt" + + uint64_example :: proc() { + // Using the global random number generator + fmt.println(rand.uint64()) + // Using local random number generator + my_rand := rand.create(1) + fmt.println(rand.uint64(&my_rand)) + } + +Possible Output: + + 10 + 389 + +*/ +@(require_results) +uint64 :: proc(r: ^Rand = nil) -> (val: u64) { a := u64(_random(r)) b := u64(_random(r)) return (a<<32) | b } -uint128 :: proc(r: ^Rand = nil) -> u128 { +/* +Generates a random 128 bit value using the provided random number generator. If no generator is provided the global random number generator will be used. + +Inputs: +- r: The random number generator to use, or nil for the global generator + +Returns: +- val: A random unsigned 128 bit value + +Example: + import "core:math/rand" + import "core:fmt" + + uint128_example :: proc() { + // Using the global random number generator + fmt.println(rand.uint128()) + // Using local random number generator + my_rand := rand.create(1) + fmt.println(rand.uint128(&my_rand)) + } + +Possible Output: + + 10 + 389 + +*/ +@(require_results) +uint128 :: proc(r: ^Rand = nil) -> (val: u128) { a := u128(_random(r)) b := u128(_random(r)) c := u128(_random(r)) @@ -76,11 +259,126 @@ uint128 :: proc(r: ^Rand = nil) -> u128 { return (a<<96) | (b<<64) | (c<<32) | d } -int31 :: proc(r: ^Rand = nil) -> i32 { return i32(uint32(r) << 1 >> 1) } -int63 :: proc(r: ^Rand = nil) -> i64 { return i64(uint64(r) << 1 >> 1) } -int127 :: proc(r: ^Rand = nil) -> i128 { return i128(uint128(r) << 1 >> 1) } +/* +Generates a random 31 bit value using the provided random number generator. If no generator is provided the global random number generator will be used. +The sign bit will always be set to 0, thus all generated numbers will be positive. -int31_max :: proc(n: i32, r: ^Rand = nil) -> i32 { +Inputs: +- r: The random number generator to use, or nil for the global generator + +Returns: +- val: A random 31 bit value + +Example: + import "core:math/rand" + import "core:fmt" + + int31_example :: proc() { + // Using the global random number generator + fmt.println(rand.int31()) + // Using local random number generator + my_rand := rand.create(1) + fmt.println(rand.int31(&my_rand)) + } + +Possible Output: + + 10 + 389 + +*/ +@(require_results) int31 :: proc(r: ^Rand = nil) -> (val: i32) { return i32(uint32(r) << 1 >> 1) } +/* +Generates a random 63 bit value using the provided random number generator. If no generator is provided the global random number generator will be used. +The sign bit will always be set to 0, thus all generated numbers will be positive. + +Inputs: +- r: The random number generator to use, or nil for the global generator + +Returns: +- val: A random 63 bit value + +Example: + import "core:math/rand" + import "core:fmt" + + int63_example :: proc() { + // Using the global random number generator + fmt.println(rand.int63()) + // Using local random number generator + my_rand := rand.create(1) + fmt.println(rand.int63(&my_rand)) + } + +Possible Output: + + 10 + 389 + +*/ +@(require_results) int63 :: proc(r: ^Rand = nil) -> (val: i64) { return i64(uint64(r) << 1 >> 1) } +/* +Generates a random 127 bit value using the provided random number generator. If no generator is provided the global random number generator will be used. +The sign bit will always be set to 0, thus all generated numbers will be positive. + +Inputs: +- r: The random number generator to use, or nil for the global generator + +Returns: +- val: A random 127 bit value + +Example: + import "core:math/rand" + import "core:fmt" + + int127_example :: proc() { + // Using the global random number generator + fmt.println(rand.int127()) + // Using local random number generator + my_rand := rand.create(1) + fmt.println(rand.int127(&my_rand)) + } + +Possible Output: + + 10 + 389 + +*/ +@(require_results) int127 :: proc(r: ^Rand = nil) -> (val: i128) { return i128(uint128(r) << 1 >> 1) } + +/* +Generates a random 31 bit value in the range `(0, n]` using the provided random number generator. If no generator is provided the global random number generator will be used. + +Inputs: +- n: The upper bound of the generated number, this value is exclusive +- r: The random number generator to use, or nil for the global generator + +Returns: +- val: A random 31 bit value in the range `(0, n]` + +WARNING: Panics if n is less than 0 + +Example: + import "core:math/rand" + import "core:fmt" + + int31_max_example :: proc() { + // Using the global random number generator + fmt.println(rand.int31_max(16)) + // Using local random number generator + my_rand := rand.create(1) + fmt.println(rand.int31_max(1024, &my_rand)) + } + +Possible Output: + + 6 + 500 + +*/ +@(require_results) +int31_max :: proc(n: i32, r: ^Rand = nil) -> (val: i32) { if n <= 0 { panic("Invalid argument to int31_max") } @@ -94,8 +392,38 @@ int31_max :: proc(n: i32, r: ^Rand = nil) -> i32 { } return v % n } +/* +Generates a random 63 bit value in the range `(0, n]` using the provided random number generator. If no generator is provided the global random number generator will be used. -int63_max :: proc(n: i64, r: ^Rand = nil) -> i64 { +Inputs: +- n: The upper bound of the generated number, this value is exclusive +- r: The random number generator to use, or nil for the global generator + +Returns: +- val: A random 63 bit value in the range `(0, n]` + +WARNING: Panics if n is less than 0 + +Example: + import "core:math/rand" + import "core:fmt" + + int63_max_example :: proc() { + // Using the global random number generator + fmt.println(rand.int63_max(16)) + // Using local random number generator + my_rand := rand.create(1) + fmt.println(rand.int63_max(1024, &my_rand)) + } + +Possible Output: + + 6 + 500 + +*/ +@(require_results) +int63_max :: proc(n: i64, r: ^Rand = nil) -> (val: i64) { if n <= 0 { panic("Invalid argument to int63_max") } @@ -109,8 +437,38 @@ int63_max :: proc(n: i64, r: ^Rand = nil) -> i64 { } return v % n } +/* +Generates a random 127 bit value in the range `(0, n]` using the provided random number generator. If no generator is provided the global random number generator will be used. -int127_max :: proc(n: i128, r: ^Rand = nil) -> i128 { +Inputs: +- n: The upper bound of the generated number, this value is exclusive +- r: The random number generator to use, or nil for the global generator + +Returns: +- val: A random 127 bit value in the range `(0, n]` + +WARNING: Panics if n is less than 0 + +Example: + import "core:math/rand" + import "core:fmt" + + int127_max_example :: proc() { + // Using the global random number generator + fmt.println(rand.int127_max(16)) + // Using local random number generator + my_rand := rand.create(1) + fmt.println(rand.int127_max(1024, &my_rand)) + } + +Possible Output: + + 6 + 500 + +*/ +@(require_results) +int127_max :: proc(n: i128, r: ^Rand = nil) -> (val: i128) { if n <= 0 { panic("Invalid argument to int127_max") } @@ -124,8 +482,38 @@ int127_max :: proc(n: i128, r: ^Rand = nil) -> i128 { } return v % n } +/* +Generates a random integer value in the range `(0, n]` using the provided random number generator. If no generator is provided the global random number generator will be used. -int_max :: proc(n: int, r: ^Rand = nil) -> int { +Inputs: +- n: The upper bound of the generated number, this value is exclusive +- r: The random number generator to use, or nil for the global generator + +Returns: +- val: A random integer value in the range `(0, n]` + +WARNING: Panics if n is less than 0 + +Example: + import "core:math/rand" + import "core:fmt" + + int_max_example :: proc() { + // Using the global random number generator + fmt.println(rand.int_max(16)) + // Using local random number generator + my_rand := rand.create(1) + fmt.println(rand.int_max(1024, &my_rand)) + } + +Possible Output: + + 6 + 500 + +*/ +@(require_results) +int_max :: proc(n: int, r: ^Rand = nil) -> (val: int) { if n <= 0 { panic("Invalid argument to int_max") } @@ -136,14 +524,154 @@ int_max :: proc(n: int, r: ^Rand = nil) -> int { } } -// Uniform random distribution [0, 1) -float64 :: proc(r: ^Rand = nil) -> f64 { return f64(int63_max(1<<53, r)) / (1 << 53) } -// Uniform random distribution [0, 1) -float32 :: proc(r: ^Rand = nil) -> f32 { return f32(float64(r)) } +/* +Generates a random double floating point value in the range `(0, 1]` using the provided random number generator. If no generator is provided the global random number generator will be used. -float64_range :: proc(lo, hi: f64, r: ^Rand = nil) -> f64 { return (hi-lo)*float64(r) + lo } -float32_range :: proc(lo, hi: f32, r: ^Rand = nil) -> f32 { return (hi-lo)*float32(r) + lo } +Inputs: +- r: The random number generator to use, or nil for the global generator +Returns: +- val: A random double floating point value in the range `(0, 1]` + +Example: + import "core:math/rand" + import "core:fmt" + + float64_example :: proc() { + // Using the global random number generator + fmt.println(rand.float64()) + // Using local random number generator + my_rand := rand.create(1) + fmt.println(rand.float64(&my_rand)) + } + +Possible Output: + + 0.043 + 0.511 + +*/ +@(require_results) float64 :: proc(r: ^Rand = nil) -> (val: f64) { return f64(int63_max(1<<53, r)) / (1 << 53) } + +/* +Generates a random single floating point value in the range `(0, 1]` using the provided random number generator. If no generator is provided the global random number generator will be used. + +Inputs: +- r: The random number generator to use, or nil for the global generator + +Returns: +- val: A random single floating point value in the range `(0, 1]` + +Example: + import "core:math/rand" + import "core:fmt" + + float32_example :: proc() { + // Using the global random number generator + fmt.println(rand.float32()) + // Using local random number generator + my_rand := rand.create(1) + fmt.println(rand.float32(&my_rand)) + } + +Possible Output: + + 0.043 + 0.511 + +*/ +@(require_results) float32 :: proc(r: ^Rand = nil) -> (val: f32) { return f32(float64(r)) } + +/* +Generates a random double floating point value in the range `(low, high]` using the provided random number generator. If no generator is provided the global random number generator will be used. + +Inputs: +- low: The lower bounds of the value, this value is inclusive +- high: The upper bounds of the value, this value is exclusive +- r: The random number generator to use, or nil for the global generator + +Returns: +- val: A random double floating point value in the range `(low, high]` + +Example: + import "core:math/rand" + import "core:fmt" + + float64_range_example :: proc() { + // Using the global random number generator + fmt.println(rand.float64_range(-10, 300)) + // Using local random number generator + my_rand := rand.create(1) + fmt.println(rand.float64_range(600, 900, &my_rand)) + } + +Possible Output: + + 15.312 + 673.130 + +*/ +@(require_results) float64_range :: proc(low, high: f64, r: ^Rand = nil) -> (val: f64) { return (high-low)*float64(r) + low } +/* +Generates a random single floating point value in the range `(low, high]` using the provided random number generator. If no generator is provided the global random number generator will be used. + +Inputs: +- low: The lower bounds of the value, this value is inclusive +- high: The upper bounds of the value, this value is exclusive +- r: The random number generator to use, or nil for the global generator + +Returns: +- val: A random single floating point value in the range `(low, high]` + +Example: + import "core:math/rand" + import "core:fmt" + + float32_range_example :: proc() { + // Using the global random number generator + fmt.println(rand.float32_range(-10, 300)) + // Using local random number generator + my_rand := rand.create(1) + fmt.println(rand.float32_range(600, 900, &my_rand)) + } + +Possible Output: + + 15.312 + 673.130 + +*/ +@(require_results) float32_range :: proc(low, high: f32, r: ^Rand = nil) -> (val: f32) { return (high-low)*float32(r) + low } + +/* +Fills a byte slice with random values using the provided random number generator. If no generator is provided the global random number generator will be used. + +Inputs: +- p: The byte slice to fill +- r: The random number generator to use, or nil for the global generator + +Returns: +- n: The number of bytes generated + +Example: + import "core:math/rand" + import "core:fmt" + + read_example :: proc() { + // Using the global random number generator + data: [8]byte + n := rand.read(data[:]) + fmt.println(n) + fmt.println(data) + } + +Possible Output: + + 8 + [32, 4, 59, 7, 1, 2, 2, 119] + +*/ +@(require_results) read :: proc(p: []byte, r: ^Rand = nil) -> (n: int) { pos := i8(0) val := i64(0) @@ -159,18 +687,81 @@ read :: proc(p: []byte, r: ^Rand = nil) -> (n: int) { return } -// perm returns a slice of n ints in a pseudo-random permutation of integers in the range [0, n) -perm :: proc(n: int, r: ^Rand = nil, allocator := context.allocator) -> []int { - m := make([]int, n, allocator) +/* +Creates a slice of `int` filled with random values using the provided random number generator. If no generator is provided the global random number generator will be used. + +*Allocates Using Provided Allocator* + +Inputs: +- n: The size of the created slice +- r: The random number generator to use, or nil for the global generator +- allocator: (default: context.allocator) + +Returns: +- res: A slice filled with random values +- err: An allocator error if one occured, `nil` otherwise + +Example: + import "core:math/rand" + import "core:mem" + import "core:fmt" + + perm_example :: proc() -> (err: mem.Allocator_Error) { + // Using the global random number generator and using the context allocator + data := rand.perm(4) or_return + fmt.println(data) + defer delete(data, context.allocator) + + // Using local random number generator and temp allocator + my_rand := rand.create(1) + data_tmp := rand.perm(4, &my_rand, context.temp_allocator) or_return + fmt.println(data_tmp) + + return + } + +Possible Output: + + [7201011, 3, 9123, 231131] + [19578, 910081, 131, 7] + +*/ +@(require_results) +perm :: proc(n: int, r: ^Rand = nil, allocator := context.allocator) -> (res: []int, err: mem.Allocator_Error) #optional_allocator_error { + m := make([]int, n, allocator) or_return for i := 0; i < n; i += 1 { j := int_max(i+1, r) m[i] = m[j] m[j] = i } - return m + return m, {} } +/* +Randomizes the ordering of elements for the provided slice. If no generator is provided the global random number generator will be used. +Inputs: +- array: The slice to randomize +- r: The random number generator to use, or nil for the global generator + +Example: + import "core:math/rand" + import "core:fmt" + + shuffle_example :: proc() { + // Using the global random number generator + data: [4]int = { 1, 2, 3, 4 } + fmt.println(data) // the contents are in order + rand.shuffle(data[:]) + fmt.println(data) // the contents have been shuffled + } + +Possible Output: + + [1, 2, 3, 4] + [2, 4, 3, 1] + +*/ shuffle :: proc(array: $T/[]$E, r: ^Rand = nil) { n := i64(len(array)) if n < 2 { @@ -183,11 +774,43 @@ shuffle :: proc(array: $T/[]$E, r: ^Rand = nil) { } } -// Returns a random element from the given slice +/* +Returns a random element from the provided slice. If no generator is provided the global random number generator will be used. + +Inputs: +- array: The slice to choose an element from +- r: The random number generator to use, or nil for the global generator + +Returns: +- res: A random element from `array` + +Example: + import "core:math/rand" + import "core:fmt" + + choice_example :: proc() { + // Using the global random number generator + data: [4]int = { 1, 2, 3, 4 } + fmt.println(rand.choice(data[:])) + fmt.println(rand.choice(data[:])) + fmt.println(rand.choice(data[:])) + fmt.println(rand.choice(data[:])) + } + + +Possible Output: + + 3 + 2 + 2 + 4 + +*/ +@(require_results) choice :: proc(array: $T/[]$E, r: ^Rand = nil) -> (res: E) { n := i64(len(array)) if n < 1 { return E{} } return array[int63_max(n, r)] -} \ No newline at end of file +} diff --git a/core/math/rand/system_darwin.odin b/core/math/rand/system_darwin.odin index f51e4473e..a2890d1b4 100644 --- a/core/math/rand/system_darwin.odin +++ b/core/math/rand/system_darwin.odin @@ -2,6 +2,7 @@ package rand import "core:sys/darwin" +@(require_results) _system_random :: proc() -> u32 { for { value: u32 diff --git a/core/math/rand/system_linux.odin b/core/math/rand/system_linux.odin index bfdc8872b..0e34228dc 100644 --- a/core/math/rand/system_linux.odin +++ b/core/math/rand/system_linux.odin @@ -2,6 +2,7 @@ package rand import "core:sys/unix" +@(require_results) _system_random :: proc() -> u32 { for { value: u32 diff --git a/core/math/rand/system_windows.odin b/core/math/rand/system_windows.odin index ee9cd0294..b6af9e6a4 100644 --- a/core/math/rand/system_windows.odin +++ b/core/math/rand/system_windows.odin @@ -2,6 +2,7 @@ package rand import win32 "core:sys/windows" +@(require_results) _system_random :: proc() -> u32 { value: u32 status := win32.BCryptGenRandom(nil, ([^]u8)(&value), 4, win32.BCRYPT_USE_SYSTEM_PREFERRED_RNG) diff --git a/core/mem/alloc.odin b/core/mem/alloc.odin index c7a21dcd4..57e82a5f8 100644 --- a/core/mem/alloc.odin +++ b/core/mem/alloc.odin @@ -56,19 +56,22 @@ Allocator :: struct { DEFAULT_ALIGNMENT :: 2*align_of(rawptr) DEFAULT_PAGE_SIZE :: - 64 * 1024 when ODIN_ARCH == .wasm32 || ODIN_ARCH == .wasm64 else + 64 * 1024 when ODIN_ARCH == .wasm32 || ODIN_ARCH == .wasm64p32 else 16 * 1024 when ODIN_OS == .Darwin && ODIN_ARCH == .arm64 else 4 * 1024 -alloc :: proc(size: int, alignment: int = DEFAULT_ALIGNMENT, allocator := context.allocator, loc := #caller_location) -> rawptr { - data, _ := runtime.mem_alloc(size, alignment, allocator, loc) - return raw_data(data) +@(require_results) +alloc :: proc(size: int, alignment: int = DEFAULT_ALIGNMENT, allocator := context.allocator, loc := #caller_location) -> (rawptr, Allocator_Error) { + data, err := runtime.mem_alloc(size, alignment, allocator, loc) + return raw_data(data), err } +@(require_results) alloc_bytes :: proc(size: int, alignment: int = DEFAULT_ALIGNMENT, allocator := context.allocator, loc := #caller_location) -> ([]byte, Allocator_Error) { return runtime.mem_alloc(size, alignment, allocator, loc) } +@(require_results) alloc_bytes_non_zeroed :: proc(size: int, alignment: int = DEFAULT_ALIGNMENT, allocator := context.allocator, loc := #caller_location) -> ([]byte, Allocator_Error) { return runtime.mem_alloc_non_zeroed(size, alignment, allocator, loc) } @@ -93,15 +96,18 @@ free_all :: proc(allocator := context.allocator, loc := #caller_location) -> All return runtime.mem_free_all(allocator, loc) } -resize :: proc(ptr: rawptr, old_size, new_size: int, alignment: int = DEFAULT_ALIGNMENT, allocator := context.allocator, loc := #caller_location) -> rawptr { - data, _ := runtime.mem_resize(ptr, old_size, new_size, alignment, allocator, loc) - return raw_data(data) +@(require_results) +resize :: proc(ptr: rawptr, old_size, new_size: int, alignment: int = DEFAULT_ALIGNMENT, allocator := context.allocator, loc := #caller_location) -> (rawptr, Allocator_Error) { + data, err := runtime.mem_resize(ptr, old_size, new_size, alignment, allocator, loc) + return raw_data(data), err } +@(require_results) resize_bytes :: proc(old_data: []byte, new_size: int, alignment: int = DEFAULT_ALIGNMENT, allocator := context.allocator, loc := #caller_location) -> ([]byte, Allocator_Error) { return runtime.mem_resize(raw_data(old_data), len(old_data), new_size, alignment, allocator, loc) } +@(require_results) query_features :: proc(allocator: Allocator, loc := #caller_location) -> (set: Allocator_Mode_Set) { if allocator.procedure != nil { allocator.procedure(allocator.data, .Query_Features, 0, 0, &set, 0, loc) @@ -110,6 +116,7 @@ query_features :: proc(allocator: Allocator, loc := #caller_location) -> (set: A return nil } +@(require_results) query_info :: proc(pointer: rawptr, allocator: Allocator, loc := #caller_location) -> (props: Allocator_Query_Info) { props.pointer = pointer if allocator.procedure != nil { @@ -146,14 +153,17 @@ delete :: proc{ } +@(require_results) new :: proc($T: typeid, allocator := context.allocator, loc := #caller_location) -> (^T, Allocator_Error) { return new_aligned(T, align_of(T), allocator, loc) } +@(require_results) new_aligned :: proc($T: typeid, alignment: int, allocator := context.allocator, loc := #caller_location) -> (t: ^T, err: Allocator_Error) { data := alloc_bytes(size_of(T), alignment, allocator, loc) or_return t = (^T)(raw_data(data)) return } +@(require_results) new_clone :: proc(data: $T, allocator := context.allocator, loc := #caller_location) -> (t: ^T, err: Allocator_Error) { backing := alloc_bytes(size_of(T), align_of(T), allocator, loc) or_return t = (^T)(raw_data(backing)) @@ -164,6 +174,7 @@ new_clone :: proc(data: $T, allocator := context.allocator, loc := #caller_locat return nil, .Out_Of_Memory } +@(require_results) make_aligned :: proc($T: typeid/[]$E, #any_int len: int, alignment: int, allocator := context.allocator, loc := #caller_location) -> (slice: T, err: Allocator_Error) { runtime.make_slice_error_loc(loc, len) data := alloc_bytes(size_of(E)*len, alignment, allocator, loc) or_return @@ -173,15 +184,19 @@ make_aligned :: proc($T: typeid/[]$E, #any_int len: int, alignment: int, allocat slice = transmute(T)Raw_Slice{raw_data(data), len} return } +@(require_results) make_slice :: proc($T: typeid/[]$E, #any_int len: int, allocator := context.allocator, loc := #caller_location) -> (T, Allocator_Error) { return make_aligned(T, len, align_of(E), allocator, loc) } +@(require_results) make_dynamic_array :: proc($T: typeid/[dynamic]$E, allocator := context.allocator, loc := #caller_location) -> (T, Allocator_Error) { return make_dynamic_array_len_cap(T, 0, 16, allocator, loc) } +@(require_results) make_dynamic_array_len :: proc($T: typeid/[dynamic]$E, #any_int len: int, allocator := context.allocator, loc := #caller_location) -> (T, Allocator_Error) { return make_dynamic_array_len_cap(T, len, len, allocator, loc) } +@(require_results) make_dynamic_array_len_cap :: proc($T: typeid/[dynamic]$E, #any_int len: int, #any_int cap: int, allocator := context.allocator, loc := #caller_location) -> (array: T, err: Allocator_Error) { runtime.make_dynamic_array_error_loc(loc, len, cap) data := alloc_bytes(size_of(E)*cap, align_of(E), allocator, loc) or_return @@ -192,14 +207,15 @@ make_dynamic_array_len_cap :: proc($T: typeid/[dynamic]$E, #any_int len: int, #a array = transmute(T)s return } -make_map :: proc($T: typeid/map[$K]$E, #any_int cap: int = 1< T { +@(require_results) +make_map :: proc($T: typeid/map[$K]$E, #any_int cap: int = 1< (m: T, err: Allocator_Error) { runtime.make_map_expr_error_loc(loc, cap) context.allocator = allocator - m: T - reserve_map(&m, cap, loc) - return m + err = reserve_map(&m, cap, loc) + return } +@(require_results) make_multi_pointer :: proc($T: typeid/[^]$E, #any_int len: int, allocator := context.allocator, loc := #caller_location) -> (mp: T, err: Allocator_Error) { runtime.make_slice_error_loc(loc, len) data := alloc_bytes(size_of(E)*len, align_of(E), allocator, loc) or_return @@ -220,30 +236,14 @@ make :: proc{ } - -default_resize_align :: proc(old_memory: rawptr, old_size, new_size, alignment: int, allocator := context.allocator, loc := #caller_location) -> rawptr { - if old_memory == nil { - return alloc(new_size, alignment, allocator, loc) - } - - if new_size == 0 { - free(old_memory, allocator, loc) - return nil - } - - if new_size == old_size { - return old_memory - } - - new_memory := alloc(new_size, alignment, allocator, loc) - if new_memory == nil { - return nil - } - - copy(new_memory, old_memory, min(old_size, new_size)) - free(old_memory, allocator, loc) - return new_memory +@(require_results) +default_resize_align :: proc(old_memory: rawptr, old_size, new_size, alignment: int, allocator := context.allocator, loc := #caller_location) -> (res: rawptr, err: Allocator_Error) { + data: []byte + data, err = default_resize_bytes_align(([^]byte)(old_memory)[:old_size], new_size, alignment, allocator, loc) + res = raw_data(data) + return } +@(require_results) default_resize_bytes_align :: proc(old_data: []byte, new_size, alignment: int, allocator := context.allocator, loc := #caller_location) -> ([]byte, Allocator_Error) { old_memory := raw_data(old_data) old_size := len(old_data) diff --git a/core/mem/allocators.odin b/core/mem/allocators.odin index 66da12959..603c2a6c7 100644 --- a/core/mem/allocators.odin +++ b/core/mem/allocators.odin @@ -2,6 +2,7 @@ package mem import "core:intrinsics" import "core:runtime" +import "core:sync" nil_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode, size, alignment: int, @@ -46,6 +47,7 @@ init_arena :: proc(a: ^Arena, data: []byte) { a.temp_count = 0 } +@(require_results) arena_allocator :: proc(arena: ^Arena) -> Allocator { return Allocator{ procedure = arena_allocator_proc, @@ -100,6 +102,7 @@ arena_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode, return nil, nil } +@(require_results) begin_arena_temp_memory :: proc(a: ^Arena) -> Arena_Temp_Memory { tmp: Arena_Temp_Memory tmp.arena = a @@ -286,6 +289,7 @@ scratch_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode, return nil, nil } +@(require_results) scratch_allocator :: proc(allocator: ^Scratch_Allocator) -> Allocator { return Allocator{ procedure = scratch_allocator_proc, @@ -325,6 +329,7 @@ init_stack :: proc(s: ^Stack, data: []byte) { s.peak_used = 0 } +@(require_results) stack_allocator :: proc(stack: ^Stack) -> Allocator { return Allocator{ procedure = stack_allocator_proc, @@ -490,6 +495,7 @@ init_small_stack :: proc(s: ^Small_Stack, data: []byte) { s.peak_used = 0 } +@(require_results) small_stack_allocator :: proc(stack: ^Small_Stack) -> Allocator { return Allocator{ procedure = small_stack_allocator_proc, @@ -673,6 +679,7 @@ dynamic_pool_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode } +@(require_results) dynamic_pool_allocator :: proc(pool: ^Dynamic_Pool) -> Allocator { return Allocator{ procedure = dynamic_pool_allocator_proc, @@ -705,12 +712,13 @@ dynamic_pool_destroy :: proc(using pool: ^Dynamic_Pool) { } -dynamic_pool_alloc :: proc(pool: ^Dynamic_Pool, bytes: int) -> rawptr { +@(require_results) +dynamic_pool_alloc :: proc(pool: ^Dynamic_Pool, bytes: int) -> (rawptr, Allocator_Error) { data, err := dynamic_pool_alloc_bytes(pool, bytes) - assert(err == nil) - return raw_data(data) + return raw_data(data), err } +@(require_results) dynamic_pool_alloc_bytes :: proc(using pool: ^Dynamic_Pool, bytes: int) -> ([]byte, Allocator_Error) { cycle_new_block :: proc(using pool: ^Dynamic_Pool) -> (err: Allocator_Error) { if block_allocator.procedure == nil { @@ -836,6 +844,7 @@ panic_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode, return nil, nil } +@(require_results) panic_allocator :: proc() -> Allocator { return Allocator{ procedure = panic_allocator_proc, @@ -860,6 +869,7 @@ Tracking_Allocator :: struct { backing: Allocator, allocation_map: map[rawptr]Tracking_Allocator_Entry, bad_free_array: [dynamic]Tracking_Allocator_Bad_Free_Entry, + mutex: sync.Mutex, clear_on_free_all: bool, } @@ -880,11 +890,14 @@ tracking_allocator_destroy :: proc(t: ^Tracking_Allocator) { tracking_allocator_clear :: proc(t: ^Tracking_Allocator) { + sync.mutex_lock(&t.mutex) clear(&t.allocation_map) clear(&t.bad_free_array) + sync.mutex_unlock(&t.mutex) } +@(require_results) tracking_allocator :: proc(data: ^Tracking_Allocator) -> Allocator { return Allocator{ data = data, @@ -896,6 +909,9 @@ tracking_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode, size, alignment: int, old_memory: rawptr, old_size: int, loc := #caller_location) -> (result: []byte, err: Allocator_Error) { data := (^Tracking_Allocator)(allocator_data) + + sync.mutex_guard(&data.mutex) + if mode == .Query_Info { info := (^Allocator_Query_Info)(old_memory) if info != nil && info.pointer != nil { diff --git a/core/mem/doc.odin b/core/mem/doc.odin index fe53dee83..295a69e96 100644 --- a/core/mem/doc.odin +++ b/core/mem/doc.odin @@ -18,6 +18,7 @@ _main :: proc() { main :: proc() { track: mem.Tracking_Allocator mem.tracking_allocator_init(&track, context.allocator) + defer mem.tracking_allocator_destroy(&track) context.allocator = mem.tracking_allocator(&track) _main() @@ -31,4 +32,4 @@ main :: proc() { } ``` */ -package mem \ No newline at end of file +package mem diff --git a/core/mem/mem.odin b/core/mem/mem.odin index bc77ca287..a06579d71 100644 --- a/core/mem/mem.odin +++ b/core/mem/mem.odin @@ -53,14 +53,17 @@ compare :: proc "contextless" (a, b: []byte) -> int { return res } +@(require_results) compare_byte_ptrs :: proc "contextless" (a, b: ^byte, n: int) -> int #no_bounds_check { return runtime.memory_compare(a, b, n) } +@(require_results) check_zero :: proc(data: []byte) -> bool { return check_zero_ptr(raw_data(data), len(data)) } +@(require_results) check_zero_ptr :: proc(ptr: rawptr, len: int) -> bool { switch { case len <= 0: @@ -101,11 +104,13 @@ check_zero_ptr :: proc(ptr: rawptr, len: int) -> bool { return true } +@(require_results) simple_equal :: proc "contextless" (a, b: $T) -> bool where intrinsics.type_is_simple_compare(T) { a, b := a, b return compare_byte_ptrs((^byte)(&a), (^byte)(&b), size_of(T)) == 0 } +@(require_results) compare_ptrs :: proc "contextless" (a, b: rawptr, n: int) -> int { return compare_byte_ptrs((^byte)(a), (^byte)(b), n) } @@ -113,20 +118,24 @@ compare_ptrs :: proc "contextless" (a, b: rawptr, n: int) -> int { ptr_offset :: intrinsics.ptr_offset ptr_sub :: intrinsics.ptr_sub +@(require_results) slice_ptr :: proc "contextless" (ptr: ^$T, len: int) -> []T { return ([^]T)(ptr)[:len] } +@(require_results) byte_slice :: #force_inline proc "contextless" (data: rawptr, #any_int len: int) -> []byte { return ([^]u8)(data)[:max(len, 0)] } +@(require_results) slice_to_bytes :: proc "contextless" (slice: $E/[]$T) -> []byte { s := transmute(Raw_Slice)slice s.len *= size_of(T) return transmute([]byte)s } +@(require_results) slice_data_cast :: proc "contextless" ($T: typeid/[]$A, slice: $S/[]$B) -> T { when size_of(A) == 0 || size_of(B) == 0 { return nil @@ -137,11 +146,13 @@ slice_data_cast :: proc "contextless" ($T: typeid/[]$A, slice: $S/[]$B) -> T { } } +@(require_results) slice_to_components :: proc "contextless" (slice: $E/[]$T) -> (data: ^T, len: int) { s := transmute(Raw_Slice)slice return (^T)(s.data), s.len } +@(require_results) buffer_from_slice :: proc "contextless" (backing: $T/[]$E) -> [dynamic]E { return transmute([dynamic]E)Raw_Dynamic_Array{ data = raw_data(backing), @@ -154,10 +165,12 @@ buffer_from_slice :: proc "contextless" (backing: $T/[]$E) -> [dynamic]E { } } +@(require_results) ptr_to_bytes :: proc "contextless" (ptr: ^$T, len := 1) -> []byte { return transmute([]byte)Raw_Slice{ptr, len*size_of(T)} } +@(require_results) any_to_bytes :: proc "contextless" (val: any) -> []byte { ti := type_info_of(val.id) size := ti != nil ? ti.size : 0 @@ -165,6 +178,7 @@ any_to_bytes :: proc "contextless" (val: any) -> []byte { } +@(require_results) is_power_of_two :: proc "contextless" (x: uintptr) -> bool { if x <= 0 { return false @@ -172,10 +186,12 @@ is_power_of_two :: proc "contextless" (x: uintptr) -> bool { return (x & (x-1)) == 0 } +@(require_results) align_forward :: proc(ptr: rawptr, align: uintptr) -> rawptr { return rawptr(align_forward_uintptr(uintptr(ptr), align)) } +@(require_results) align_forward_uintptr :: proc(ptr, align: uintptr) -> uintptr { assert(is_power_of_two(align)) @@ -187,33 +203,41 @@ align_forward_uintptr :: proc(ptr, align: uintptr) -> uintptr { return p } +@(require_results) align_forward_int :: proc(ptr, align: int) -> int { return int(align_forward_uintptr(uintptr(ptr), uintptr(align))) } +@(require_results) align_forward_uint :: proc(ptr, align: uint) -> uint { return uint(align_forward_uintptr(uintptr(ptr), uintptr(align))) } +@(require_results) align_backward :: proc(ptr: rawptr, align: uintptr) -> rawptr { return rawptr(align_backward_uintptr(uintptr(ptr), align)) } +@(require_results) align_backward_uintptr :: proc(ptr, align: uintptr) -> uintptr { return align_forward_uintptr(ptr - align + 1, align) } +@(require_results) align_backward_int :: proc(ptr, align: int) -> int { return int(align_backward_uintptr(uintptr(ptr), uintptr(align))) } +@(require_results) align_backward_uint :: proc(ptr, align: uint) -> uint { return uint(align_backward_uintptr(uintptr(ptr), uintptr(align))) } +@(require_results) context_from_allocator :: proc(a: Allocator) -> type_of(context) { context.allocator = a return context } +@(require_results) reinterpret_copy :: proc "contextless" ($T: typeid, ptr: rawptr) -> (value: T) { copy(&value, ptr, size_of(T)) return @@ -222,6 +246,7 @@ reinterpret_copy :: proc "contextless" ($T: typeid, ptr: rawptr) -> (value: T) { Fixed_Byte_Buffer :: distinct [dynamic]byte +@(require_results) make_fixed_byte_buffer :: proc "contextless" (backing: []byte) -> Fixed_Byte_Buffer { s := transmute(Raw_Slice)backing d: Raw_Dynamic_Array @@ -237,11 +262,13 @@ make_fixed_byte_buffer :: proc "contextless" (backing: []byte) -> Fixed_Byte_Buf +@(require_results) align_formula :: proc "contextless" (size, align: int) -> int { result := size + align-1 return result - result%align } +@(require_results) calc_padding_with_header :: proc "contextless" (ptr: uintptr, align: uintptr, header_size: int) -> int { p, a := ptr, align modulo := p & (a-1) @@ -267,6 +294,7 @@ calc_padding_with_header :: proc "contextless" (ptr: uintptr, align: uintptr, he +@(require_results, deprecated="prefer 'slice.clone'") clone_slice :: proc(slice: $T/[]$E, allocator := context.allocator, loc := #caller_location) -> (new_slice: T) { new_slice, _ = make(T, len(slice), allocator, loc) runtime.copy(new_slice, slice) diff --git a/core/mem/virtual/arena.odin b/core/mem/virtual/arena.odin index 0ddb116fd..e73a39660 100644 --- a/core/mem/virtual/arena.odin +++ b/core/mem/virtual/arena.odin @@ -1,6 +1,7 @@ package mem_virtual import "core:mem" +import "core:sync" Arena_Kind :: enum uint { Growing = 0, // Chained memory blocks (singly linked list). @@ -8,6 +9,13 @@ Arena_Kind :: enum uint { Buffer = 2, // Uses a fixed sized buffer. } +/* + Arena is a generalized arena allocator that supports 3 different variants. + + Growing: A linked list of `Memory_Block`s allocated with virtual memory. + Static: A single `Memory_Block` allocated with virtual memory. + Buffer: A single `Memory_Block` created from a user provided []byte. +*/ Arena :: struct { kind: Arena_Kind, curr_block: ^Memory_Block, @@ -15,6 +23,7 @@ Arena :: struct { total_reserved: uint, minimum_block_size: uint, temp_count: uint, + mutex: sync.Mutex, } @@ -27,6 +36,8 @@ DEFAULT_ARENA_STATIC_RESERVE_SIZE :: mem.Gigabyte when size_of(uintptr) == 8 els +// Initialization of an `Arena` to be a `.Growing` variant. +// A growing arena is a linked list of `Memory_Block`s allocated with virtual memory. @(require_results) arena_init_growing :: proc(arena: ^Arena, reserved: uint = DEFAULT_ARENA_GROWING_MINIMUM_BLOCK_SIZE) -> (err: Allocator_Error) { arena.kind = .Growing @@ -37,6 +48,8 @@ arena_init_growing :: proc(arena: ^Arena, reserved: uint = DEFAULT_ARENA_GROWING } +// Initialization of an `Arena` to be a `.Static` variant. +// A static arena contains a single `Memory_Block` allocated with virtual memory. @(require_results) arena_init_static :: proc(arena: ^Arena, reserved: uint, commit_size: uint = DEFAULT_ARENA_STATIC_COMMIT_SIZE) -> (err: Allocator_Error) { arena.kind = .Static @@ -46,6 +59,8 @@ arena_init_static :: proc(arena: ^Arena, reserved: uint, commit_size: uint = DEF return } +// Initialization of an `Arena` to be a `.Buffer` variant. +// A buffer arena contains single `Memory_Block` created from a user provided []byte. @(require_results) arena_init_buffer :: proc(arena: ^Arena, buffer: []byte) -> (err: Allocator_Error) { if len(buffer) < size_of(Memory_Block) { @@ -69,6 +84,7 @@ arena_init_buffer :: proc(arena: ^Arena, buffer: []byte) -> (err: Allocator_Erro return } +// Allocates memory from the provided arena. @(require_results) arena_alloc :: proc(arena: ^Arena, size: uint, alignment: uint, loc := #caller_location) -> (data: []byte, err: Allocator_Error) { assert(alignment & (alignment-1) == 0, "non-power of two alignment", loc) @@ -78,6 +94,8 @@ arena_alloc :: proc(arena: ^Arena, size: uint, alignment: uint, loc := #caller_l return nil, nil } + sync.mutex_guard(&arena.mutex) + switch arena.kind { case .Growing: if arena.curr_block == nil || (safe_add(arena.curr_block.used, size) or_else 0) > arena.curr_block.reserved { @@ -102,7 +120,7 @@ arena_alloc :: proc(arena: ^Arena, size: uint, alignment: uint, loc := #caller_l if arena.minimum_block_size == 0 { arena.minimum_block_size = DEFAULT_ARENA_STATIC_RESERVE_SIZE } - arena_init_static(arena=arena, reserved=arena.minimum_block_size, commit_size=DEFAULT_ARENA_STATIC_COMMIT_SIZE) or_return + arena_init_static(arena, reserved=arena.minimum_block_size, commit_size=DEFAULT_ARENA_STATIC_COMMIT_SIZE) or_return } fallthrough case .Buffer: @@ -115,7 +133,10 @@ arena_alloc :: proc(arena: ^Arena, size: uint, alignment: uint, loc := #caller_l return } +// Resets the memory of a Static or Buffer arena to a specific `pos`ition (offset) and zeroes the previously used memory. arena_static_reset_to :: proc(arena: ^Arena, pos: uint, loc := #caller_location) -> bool { + sync.mutex_guard(&arena.mutex) + if arena.curr_block != nil { assert(arena.kind != .Growing, "expected a non .Growing arena", loc) @@ -134,48 +155,72 @@ arena_static_reset_to :: proc(arena: ^Arena, pos: uint, loc := #caller_location) return false } +// Frees the last memory block of a Growing Arena arena_growing_free_last_memory_block :: proc(arena: ^Arena, loc := #caller_location) { if free_block := arena.curr_block; free_block != nil { assert(arena.kind == .Growing, "expected a .Growing arena", loc) + arena.total_used -= free_block.used + arena.total_reserved -= free_block.reserved + arena.curr_block = free_block.prev memory_block_dealloc(free_block) } } -arena_free_all :: proc(arena: ^Arena) { +// Deallocates all but the first memory block of the arena and resets the allocator's usage to 0. +arena_free_all :: proc(arena: ^Arena, loc := #caller_location) { switch arena.kind { case .Growing: - for arena.curr_block != nil { - arena_growing_free_last_memory_block(arena) + sync.mutex_guard(&arena.mutex) + // NOTE(bill): Free all but the first memory block (if it exists) + for arena.curr_block != nil && arena.curr_block.prev != nil { + arena_growing_free_last_memory_block(arena, loc) } - arena.total_reserved = 0 + // Zero the first block's memory + if arena.curr_block != nil { + mem.zero(arena.curr_block.base, int(arena.curr_block.used)) + arena.curr_block.used = 0 + } + arena.total_used = 0 case .Static, .Buffer: arena_static_reset_to(arena, 0) } arena.total_used = 0 } -arena_destroy :: proc(arena: ^Arena) { - arena_free_all(arena) - if arena.kind != .Buffer { +// Frees all of the memory allocated by the arena and zeros all of the values of an arena. +// A buffer based arena does not `delete` the provided `[]byte` bufffer. +arena_destroy :: proc(arena: ^Arena, loc := #caller_location) { + sync.mutex_guard(&arena.mutex) + switch arena.kind { + case .Growing: + for arena.curr_block != nil { + arena_growing_free_last_memory_block(arena, loc) + } + case .Static: memory_block_dealloc(arena.curr_block) + case .Buffer: + // nothing } - arena.curr_block = nil + arena.curr_block = nil arena.total_used = 0 arena.total_reserved = 0 arena.temp_count = 0 } +// Ability to bootstrap allocate a struct with an arena within the struct itself using the growing variant strategy. arena_growing_bootstrap_new :: proc{ arena_growing_bootstrap_new_by_offset, arena_growing_bootstrap_new_by_name, } +// Ability to bootstrap allocate a struct with an arena within the struct itself using the static variant strategy. arena_static_bootstrap_new :: proc{ arena_static_bootstrap_new_by_offset, arena_static_bootstrap_new_by_name, } +// Ability to bootstrap allocate a struct with an arena within the struct itself using the growing variant strategy. @(require_results) arena_growing_bootstrap_new_by_offset :: proc($T: typeid, offset_to_arena: uintptr, minimum_block_size: uint = DEFAULT_ARENA_GROWING_MINIMUM_BLOCK_SIZE) -> (ptr: ^T, err: Allocator_Error) { bootstrap: Arena @@ -191,11 +236,13 @@ arena_growing_bootstrap_new_by_offset :: proc($T: typeid, offset_to_arena: uintp return } +// Ability to bootstrap allocate a struct with an arena within the struct itself using the growing variant strategy. @(require_results) arena_growing_bootstrap_new_by_name :: proc($T: typeid, $field_name: string, minimum_block_size: uint = DEFAULT_ARENA_GROWING_MINIMUM_BLOCK_SIZE) -> (ptr: ^T, err: Allocator_Error) { return arena_growing_bootstrap_new_by_offset(T, offset_of_by_string(T, field_name), minimum_block_size) } +// Ability to bootstrap allocate a struct with an arena within the struct itself using the growing variant strategy. @(require_results) arena_static_bootstrap_new_by_offset :: proc($T: typeid, offset_to_arena: uintptr, reserved: uint) -> (ptr: ^T, err: Allocator_Error) { bootstrap: Arena @@ -211,17 +258,20 @@ arena_static_bootstrap_new_by_offset :: proc($T: typeid, offset_to_arena: uintpt return } +// Ability to bootstrap allocate a struct with an arena within the struct itself using the growing variant strategy. @(require_results) arena_static_bootstrap_new_by_name :: proc($T: typeid, $field_name: string, reserved: uint) -> (ptr: ^T, err: Allocator_Error) { return arena_static_bootstrap_new_by_offset(T, offset_of_by_string(T, field_name), reserved) } +// Create an `Allocator` from the provided `Arena` @(require_results) arena_allocator :: proc(arena: ^Arena) -> mem.Allocator { return mem.Allocator{arena_allocator_proc, arena} } +// The allocator procedured by an `Allocator` produced by `arena_allocator` arena_allocator_proc :: proc(allocator_data: rawptr, mode: mem.Allocator_Mode, size, alignment: int, old_memory: rawptr, old_size: int, @@ -233,17 +283,17 @@ arena_allocator_proc :: proc(allocator_data: rawptr, mode: mem.Allocator_Mode, switch mode { case .Alloc, .Alloc_Non_Zeroed: - return arena_alloc(arena, size, alignment) + return arena_alloc(arena, size, alignment, location) case .Free: err = .Mode_Not_Implemented case .Free_All: - arena_free_all(arena) + arena_free_all(arena, location) case .Resize: old_data := ([^]byte)(old_memory) switch { case old_data == nil: - return arena_alloc(arena, size, alignment) + return arena_alloc(arena, size, alignment, location) case size == old_size: // return old memory data = old_data[:size] @@ -257,7 +307,7 @@ arena_allocator_proc :: proc(allocator_data: rawptr, mode: mem.Allocator_Mode, return } - new_memory := arena_alloc(arena, size, alignment) or_return + new_memory := arena_alloc(arena, size, alignment, location) or_return if new_memory == nil { return } @@ -278,15 +328,20 @@ arena_allocator_proc :: proc(allocator_data: rawptr, mode: mem.Allocator_Mode, +// An `Arena_Temp` is a way to produce temporary watermarks to reset a arena to a previous state. +// All uses of an `Arena_Temp` must be handled by ending them with `arena_temp_end` or ignoring them with `arena_temp_ignore`. Arena_Temp :: struct { arena: ^Arena, block: ^Memory_Block, used: uint, } +// Begins the section of temporary arena memory. @(require_results) arena_temp_begin :: proc(arena: ^Arena, loc := #caller_location) -> (temp: Arena_Temp) { assert(arena != nil, "nil arena", loc) + sync.mutex_guard(&arena.mutex) + temp.arena = arena temp.block = arena.curr_block if arena.curr_block != nil { @@ -296,36 +351,51 @@ arena_temp_begin :: proc(arena: ^Arena, loc := #caller_location) -> (temp: Arena return } +// Ends the section of temporary arena memory by resetting the memory to the stored position. arena_temp_end :: proc(temp: Arena_Temp, loc := #caller_location) { assert(temp.arena != nil, "nil arena", loc) arena := temp.arena + sync.mutex_guard(&arena.mutex) - memory_block_found := false - for block := arena.curr_block; block != nil; block = block.prev { - if block == temp.block { - memory_block_found = true - break + if temp.block != nil { + memory_block_found := false + for block := arena.curr_block; block != nil; block = block.prev { + if block == temp.block { + memory_block_found = true + break + } + } + if !memory_block_found { + assert(arena.curr_block == temp.block, "memory block stored within Arena_Temp not owned by Arena", loc) } - } - if !memory_block_found { - assert(arena.curr_block == temp.block, "memory block stored within Arena_Temp not owned by Arena", loc) - } - for arena.curr_block != temp.block { - arena_growing_free_last_memory_block(arena) - } + for arena.curr_block != temp.block { + arena_growing_free_last_memory_block(arena) + } - if block := arena.curr_block; block != nil { - assert(block.used >= temp.used, "out of order use of arena_temp_end", loc) - amount_to_zero := min(block.used-temp.used, block.reserved-block.used) - mem.zero_slice(block.base[temp.used:][:amount_to_zero]) - block.used = temp.used + if block := arena.curr_block; block != nil { + assert(block.used >= temp.used, "out of order use of arena_temp_end", loc) + amount_to_zero := min(block.used-temp.used, block.reserved-block.used) + mem.zero_slice(block.base[temp.used:][:amount_to_zero]) + block.used = temp.used + } } assert(arena.temp_count > 0, "double-use of arena_temp_end", loc) arena.temp_count -= 1 } +// Ignore the use of a `arena_temp_begin` entirely by __not__ resetting to the stored position. +arena_temp_ignore :: proc(temp: Arena_Temp, loc := #caller_location) { + assert(temp.arena != nil, "nil arena", loc) + arena := temp.arena + sync.mutex_guard(&arena.mutex) + + assert(arena.temp_count > 0, "double-use of arena_temp_end", loc) + arena.temp_count -= 1 +} + +// Asserts that all uses of `Arena_Temp` has been used by an `Arena` arena_check_temp :: proc(arena: ^Arena, loc := #caller_location) { assert(arena.temp_count == 0, "Arena_Temp not been ended", loc) } diff --git a/core/mem/virtual/virtual.odin b/core/mem/virtual/virtual.odin index 5e831a0c3..12815b7f1 100644 --- a/core/mem/virtual/virtual.odin +++ b/core/mem/virtual/virtual.odin @@ -7,6 +7,7 @@ DEFAULT_PAGE_SIZE := uint(4096) Allocator_Error :: mem.Allocator_Error +@(require_results) reserve :: proc "contextless" (size: uint) -> (data: []byte, err: Allocator_Error) { return _reserve(size) } @@ -15,6 +16,7 @@ commit :: proc "contextless" (data: rawptr, size: uint) -> Allocator_Error { return _commit(data, size) } +@(require_results) reserve_and_commit :: proc "contextless" (size: uint) -> (data: []byte, err: Allocator_Error) { data = reserve(size) or_return commit(raw_data(data), size) or_return @@ -57,6 +59,7 @@ Memory_Block_Flag :: enum u32 { Memory_Block_Flags :: distinct bit_set[Memory_Block_Flag; u32] +@(require_results) memory_block_alloc :: proc(committed, reserved: uint, flags: Memory_Block_Flags) -> (block: ^Memory_Block, err: Allocator_Error) { align_formula :: proc "contextless" (size, align: uint) -> uint { result := size + align-1 @@ -100,6 +103,7 @@ memory_block_alloc :: proc(committed, reserved: uint, flags: Memory_Block_Flags) return &pmblock.block, nil } +@(require_results) alloc_from_memory_block :: proc(block: ^Memory_Block, min_size, alignment: uint) -> (data: []byte, err: Allocator_Error) { calc_alignment_offset :: proc "contextless" (block: ^Memory_Block, alignment: uintptr) -> uint { alignment_offset := uint(0) @@ -160,7 +164,7 @@ memory_block_dealloc :: proc(block_to_free: ^Memory_Block) { -@(private) +@(private, require_results) safe_add :: #force_inline proc "contextless" (x, y: uint) -> (uint, bool) { z, did_overflow := intrinsics.overflow_add(x, y) return z, !did_overflow diff --git a/core/mem/virtual/virtual_bsd.odin b/core/mem/virtual/virtual_bsd.odin new file mode 100644 index 000000000..103e48074 --- /dev/null +++ b/core/mem/virtual/virtual_bsd.odin @@ -0,0 +1,24 @@ +//+build freebsd, openbsd +//+private +package mem_virtual + + + +_reserve :: proc "contextless" (size: uint) -> (data: []byte, err: Allocator_Error) { + return nil, nil +} + +_commit :: proc "contextless" (data: rawptr, size: uint) -> Allocator_Error { + return nil +} +_decommit :: proc "contextless" (data: rawptr, size: uint) { +} +_release :: proc "contextless" (data: rawptr, size: uint) { +} +_protect :: proc "contextless" (data: rawptr, size: uint, flags: Protect_Flags) -> bool { + return false +} + +_platform_memory_init :: proc() { + +} diff --git a/core/net/addr.odin b/core/net/addr.odin new file mode 100644 index 000000000..e6b503aaf --- /dev/null +++ b/core/net/addr.odin @@ -0,0 +1,744 @@ +// +build windows, linux, darwin +package net + +/* + Package net implements cross-platform Berkeley Sockets, DNS resolution and associated procedures. + For other protocols and their features, see subdirectories of this package. +*/ + +/* + Copyright 2022 Tetralux + Copyright 2022 Colin Davidson + Copyright 2022 Jeroen van Rijn . + Made available under Odin's BSD-3 license. + + List of contributors: + Tetralux: Initial implementation + Colin Davidson: Linux platform code, OSX platform code, Odin-native DNS resolver + Jeroen van Rijn: Cross platform unification, code style, documentation +*/ + +import "core:strconv" +import "core:strings" +import "core:fmt" + +/* + Expects an IPv4 address with no leading or trailing whitespace: + - a.b.c.d + - a.b.c.d:port + - [a.b.c.d]:port + + If the IP address is bracketed, the port must be present and valid (though it will be ignored): + - [a.b.c.d] will be treated as a parsing failure. + + The port, if present, is required to be a base 10 number in the range 0-65535, inclusive. + + If `allow_non_decimal` is false, `aton` is told each component must be decimal and max 255. +*/ +parse_ip4_address :: proc(address_and_maybe_port: string, allow_non_decimal := false) -> (addr: IP4_Address, ok: bool) { + res := aton(address_and_maybe_port, .IP4, !allow_non_decimal) or_return + return res.? +} + +/* + Parses an IP address in "non-decimal" `inet_aton` form. + + e.g."00377.0x0ff.65534" = 255.255.255.254 + 00377 = 255 in octal + 0x0ff = 255 in hexadecimal + This leaves 16 bits worth of address + .65534 then accounts for the last two digits + + For the address part the allowed forms are: + a.b.c.d - where each part represents a byte + a.b.c - where `a` & `b` represent a byte and `c` a u16 + a.b - where `a` represents a byte and `b` supplies the trailing 24 bits + a - where `a` gives the entire 32-bit value + + The port, if present, is required to be a base 10 number in the range 0-65535, inclusive. +*/ +aton :: proc(address_and_maybe_port: string, family: Address_Family, allow_decimal_only := false) -> (addr: Address, ok: bool) { + switch family { + case .IP4: + // There is no valid address shorter than `0.0.0.0`. + if len(address_and_maybe_port) < 7 { + return {}, false + } + + address, _ := split_port(address_and_maybe_port) or_return // This call doesn't allocate + + buf: [4]u64 = {} + i := 0 + + max_value := u64(max(u32)) + bases := DEFAULT_DIGIT_BASES + + if allow_decimal_only { + max_value = 255 + bases = {.Dec} + } + + for len(address) > 0 { + if i == 4 { + return {}, false + } + + // Decimal-only addresses may not have a leading zero. + if allow_decimal_only && len(address) > 1 && address[0] == '0' && address[1] != '.' { + return + } + + number, consumed, number_ok := parse_ip_component(address, max_value, bases) + if !number_ok || consumed == 0 { + return {}, false + } + + buf[i] = number + + address = address[consumed:] + + if len(address) > 0 && address[0] == '.' { + address = address[1:] + } + i += 1 + } + + // Distribute parts. + switch i { + case 1: + buf[1] = buf[0] & 0xffffff + buf[0] >>= 24 + fallthrough + case 2: + buf[2] = buf[1] & 0xffff + buf[1] >>= 16 + fallthrough + case 3: + buf[3] = buf[2] & 0xff + buf[2] >>= 8 + } + + a: [4]u8 = --- + for v, i in buf { + if v > 255 { return {}, false } + a[i] = u8(v) + } + return IP4_Address(a), true + + case .IP6: + return parse_ip6_address(address_and_maybe_port) + + case: + return nil, false + } +} + +/* + The minimum length of a valid IPv6 address string is 2, e.g. `::` + + The maximum length of a valid IPv6 address string is 45, when it embeds an IPv4, + e.g. `0000:0000:0000:0000:0000:ffff:255.255.255.255` + + An IPv6 address must contain at least 3 pieces, e.g. `::`, + and at most 9 (using `::` for a trailing or leading 0) +*/ +IPv6_MIN_STRING_LENGTH :: 2 +IPv6_MAX_STRING_LENGTH :: 45 +IPv6_MIN_COLONS :: 2 +IPv6_PIECE_COUNT :: 8 + +parse_ip6_address :: proc(address_and_maybe_port: string) -> (addr: IP6_Address, ok: bool) { + // If we have an IPv6 address of the form [IP]:Port, first get us just the IP. + address, _ := split_port(address_and_maybe_port) or_return + + // Early bailouts based on length and number of pieces. + if len(address) < IPv6_MIN_STRING_LENGTH || len(address) > IPv6_MAX_STRING_LENGTH { return } + + /* + Do a pre-pass on the string that checks how many `:` and `.` we have, + if they're in the right order, and if the things between them are digits as expected. + + It's not strictly necessary considering we could use `strings.split`, + but this way we can avoid using an allocator and return earlier on bogus input. Win-win. + */ + colon_count := 0 + dot_count := 0 + + pieces_temp: [IPv6_PIECE_COUNT + 1]string + + piece_start := 0 + piece_end := 0 + + for ch, i in address { + switch ch { + case '0'..='9', 'a'..='f', 'A'..='F': + piece_end += 1 + + case ':': + // If we see a `:` after a `.`, it means an IPv4 part was sandwiched between IPv6, instead of it being the tail: invalid. + if dot_count > 0 { return } + + pieces_temp[colon_count] = address[piece_start:piece_end] + + colon_count += 1 + if colon_count > IPv6_PIECE_COUNT { return } + + // If there's anything left, put it in the next piece. + piece_start = i + 1 + piece_end = piece_start + + case '.': + // IPv4 address is treated as one piece. No need to update `piece_*`. + dot_count += 1 + + case: // Invalid character, return early + return + } + } + + if colon_count < IPv6_MIN_COLONS { return } + + // Assign the last piece string. + pieces_temp[colon_count] = address[piece_start:] + + // `pieces` now holds the same output as it would if had used `strings.split`. + pieces := pieces_temp[:colon_count + 1] + + // Check if we have what looks like an embedded IPv4 address. + ipv4: IP4_Address + have_ipv4: bool + + if dot_count > 0 { + /* + If we have an IPv4 address accounting for the last 32 bits, + this means we can have at most 6 IPv6 pieces, like so: `x:x:X:x:x:x:d.d.d.d` + + Or, put differently: 6 pieces IPv6 (5 colons), a colon, 1 piece IPv4 (3 dots), + for a total of 6 colons and 3 dots. + */ + if dot_count != 3 || colon_count > 6 { return } + + /* + Try to parse IPv4 address. + If successful, we have our least significant 32 bits. + If not, it invalidates the whole address and we can bail. + */ + ipv4, have_ipv4 = parse_ip4_address(pieces_temp[colon_count]) + if !have_ipv4 { return } + } + + // Check for `::` being used more than once, and save the skip. + zero_skip := -1 + for i in 1.. 0 { return } + } + + // Adjust for trailing `::`. + if pieces[colon_count] == "" { + after_skip -= 1 + // Trailing `:` can only be part of `::`. + if after_skip > 0 { return } + } + + /* + Calculate how many zero pieces we skipped. + It should be at least one, considering we encountered a `::`. + */ + num_skipped = IPv6_PIECE_COUNT - before_skip - after_skip + if num_skipped < 1 { return } + + } else { + /* + No zero skip means everything is part of "before the skip". + An IPv4 "piece" accounts for 2 IPv6 pieces we haven't added to the pieces slice, so add 1. + */ + piece_count := colon_count + 1 + if have_ipv4 { + piece_count += 1 + } + + // Do we have the complete set? + if piece_count != IPv6_PIECE_COUNT { return } + + // Validate leading and trailing empty parts, as they can only be part of a `::`. + if pieces[0] == "" || pieces[colon_count] == "" { return } + + + before_skip = piece_count + after_skip = 0 + num_skipped = 0 + } + + // Now try to parse the pieces into a 8 16-bit pieces. + piece_values: [IPv6_PIECE_COUNT]u16be + + idx := 0 + val_idx := 0 + + for _ in 0.. 4 { return } + + if piece != "" { + val, _ := parse_ip_component(piece, 65535, {.IPv6}) or_return + piece_values[val_idx] = u16be(val) + } + + idx += 1 + val_idx += 1 + } + + if before_skip == 0 { + idx += 1 + } + + if num_skipped > 0 { + idx += 1 + val_idx += num_skipped + } + + if after_skip > 0 { + for _ in 0.. 4 { return } + + if piece != "" { + val, _ := parse_ip_component(piece, 65535, {.IPv6}) or_return + piece_values[val_idx] = u16be(val) + } + + idx += 1 + val_idx += 1 + } + } + + // Distribute IPv4 address into last two pieces, if applicable. + if have_ipv4 { + val := u16(ipv4[0]) << 8 + val |= u16(ipv4[1]) + piece_values[6] = u16be(val) + + val = u16(ipv4[2]) << 8 + val |= u16(ipv4[3]) + piece_values[7] = u16be(val) + } + return transmute(IP6_Address)piece_values, true +} + +/* + Try parsing as an IPv6 address. + If it's determined not to be, try as an IPv4 address, optionally in non-decimal format. +*/ +parse_address :: proc(address_and_maybe_port: string, non_decimal_address := false) -> Address { + if addr6, ok6 := parse_ip6_address(address_and_maybe_port); ok6 { + return addr6 + } + if addr4, ok4 := parse_ip4_address(address_and_maybe_port, non_decimal_address); ok4 { + return addr4 + } + return nil +} + +parse_endpoint :: proc(endpoint_str: string) -> (ep: Endpoint, ok: bool) { + if addr_str, port, split_ok := split_port(endpoint_str); split_ok { + if addr := parse_address(addr_str); addr != nil { + return Endpoint { address = addr, port = port }, true + } + } + return +} + +Host :: struct { + hostname: string, + port: int, +} +Host_Or_Endpoint :: union { + Host, + Endpoint, +} + +// Takes a string consisting of a hostname or IP address, and an optional port, +// and return the component parts in a useful form. +parse_hostname_or_endpoint :: proc(endpoint_str: string) -> (target: Host_Or_Endpoint, err: Parse_Endpoint_Error) { + host, port, port_ok := split_port(endpoint_str) + if !port_ok { + return nil, .Bad_Port + } + if addr := parse_address(host); addr != nil { + return Endpoint{addr, port}, .None + } + if !validate_hostname(host) { + return nil, .Bad_Hostname + } + return Host{host, port}, .None +} + + +// Takes an endpoint string and returns its parts. +// Returns ok=false if port is not a number. +split_port :: proc(endpoint_str: string) -> (addr_or_host: string, port: int, ok: bool) { + // IP6 [addr_or_host]:port + if i := strings.last_index(endpoint_str, "]:"); i >= 0 { + addr_or_host = endpoint_str[1:i] + port, ok = strconv.parse_int(endpoint_str[i+2:], 10) + + if port > 65535 { + ok = false + } + return + } + + if n := strings.count(endpoint_str, ":"); n == 1 { + // IP4 addr_or_host:port + i := strings.last_index(endpoint_str, ":") + assert(i != -1) + + addr_or_host = endpoint_str[:i] + port, ok = strconv.parse_int(endpoint_str[i+1:], 10) + + if port > 65535 { + ok = false + } + return + } else if n > 1 { + // IP6 address without port + } + + // No port + addr_or_host = endpoint_str + port = 0 + ok = true + return +} + +// Joins an address or hostname with a port. +join_port :: proc(address_or_host: string, port: int, allocator := context.allocator) -> string { + addr_or_host, _, ok := split_port(address_or_host) + if !ok do return addr_or_host + + b := strings.builder_make(allocator) + + addr := parse_address(addr_or_host) + if addr == nil { + // hostname + fmt.sbprintf(&b, "%v:%v", addr_or_host, port) + } else { + switch in addr { + case IP4_Address: + fmt.sbprintf(&b, "%v:%v", address_to_string(addr), port) + case IP6_Address: + fmt.sbprintf(&b, "[%v]:%v", address_to_string(addr), port) + } + } + return strings.to_string(b) +} + + + +// TODO(tetra): Do we need this? +map_to_ip6 :: proc(addr: Address) -> Address { + if addr6, ok := addr.(IP6_Address); ok { + return addr6 + } + addr4 := addr.(IP4_Address) + addr4_u16 := transmute([2]u16be) addr4 + addr6: IP6_Address + addr6[4] = 0xffff + copy(addr6[5:], addr4_u16[:]) + return addr6 +} + +/* + Returns a temporarily-allocated string representation of the address. + + See RFC 5952 section 4 for IPv6 representation recommendations. +*/ +address_to_string :: proc(addr: Address, allocator := context.temp_allocator) -> string { + b := strings.builder_make(allocator) + switch v in addr { + case IP4_Address: + fmt.sbprintf(&b, "%v.%v.%v.%v", v[0], v[1], v[2], v[3]) + case IP6_Address: + // First find the longest run of zeroes. + Zero_Run :: struct { + start: int, + end: int, + } + + /* + We're dealing with 0-based indices, appropriately enough for runs of zeroes. + Still, it means we need to initialize runs with some value outside of the possible range. + */ + run := Zero_Run{-1, -1} + best := Zero_Run{-1, -1} + + addr := transmute([8]u16be)v + + last := u16be(1) + for val, i in addr { + /* + If we encounter adjacent zeroes, then start a new run if not already in one. + Also remember the rightmost index regardless, because it'll be the new + frontier of both new and existing runs. + */ + if last == 0 && val == 0 { + run.end = i + if run.start == -1 { + run.start = i - 1 + } + } + + /* + If we're in a run check if its length is better than the best recorded so far. + If so, update the best run's start and end. + */ + if run.start != -1 { + length_to_beat := best.end - best.start + length := run.end - run.start + + if length > length_to_beat { + best = run + } + } + + // If we were in a run, this is where we reset it. + if val != 0 { + run = {-1, -1} + } + + last = val + } + + for val, i in addr { + if best.start == i || best.end == i { + // For the left and right side of the best zero run, print a `:`. + fmt.sbprint(&b, ":") + } else if i < best.start { + /* + If we haven't made it to the best run yet, print the digit. + Make sure we only print a `:` after the digit if it's not + immediately followed by the run's own leftmost `:`. + */ + fmt.sbprintf(&b, "%x", val) + if i < best.start - 1 { + fmt.sbprintf(&b, ":") + } + } else if i > best.end { + /* + If there are any digits after the zero run, print them. + But don't print the `:` at the end of the IP number. + */ + fmt.sbprintf(&b, "%x", val) + if i != 7 { + fmt.sbprintf(&b, ":") + } + } + } + } + return strings.to_string(b) +} + +// Returns a temporarily-allocated string representation of the endpoint. +// If there's a port, uses the `[address]:port` format. +endpoint_to_string :: proc(ep: Endpoint, allocator := context.temp_allocator) -> string { + if ep.port == 0 { + return address_to_string(ep.address, allocator) + } else { + s := address_to_string(ep.address, context.temp_allocator) + b := strings.builder_make(allocator) + switch a in ep.address { + case IP4_Address: fmt.sbprintf(&b, "%v:%v", s, ep.port) + case IP6_Address: fmt.sbprintf(&b, "[%v]:%v", s, ep.port) + } + return strings.to_string(b) + } +} + +to_string :: proc{address_to_string, endpoint_to_string} + + +family_from_address :: proc(addr: Address) -> Address_Family { + switch in addr { + case IP4_Address: return .IP4 + case IP6_Address: return .IP6 + case: + unreachable() + } +} +family_from_endpoint :: proc(ep: Endpoint) -> Address_Family { + return family_from_address(ep.address) +} + + +Digit_Parse_Base :: enum u8 { + Dec = 0, // No prefix + Oct = 1, // Leading zero + Hex = 2, // 0x prefix + IPv6 = 3, // Unprefixed IPv6 piece hex. Can't be used with other bases. +} +Digit_Parse_Bases :: bit_set[Digit_Parse_Base; u8] +DEFAULT_DIGIT_BASES :: Digit_Parse_Bases{.Dec, .Oct, .Hex} + +/* + Parses a single unsigned number in requested `bases` from `input`. + `max_value` represents the maximum allowed value for this number. + + Returns the `value`, the `bytes_consumed` so far, and `ok` to signal success or failure. + + An out-of-range or invalid number will return the accumulated value so far (which can be out of range), + the number of bytes consumed leading up the error, and `ok = false`. + + When `.` or `:` are encountered, they'll be considered valid separators and will stop parsing, + returning the valid number leading up to it. + + Other non-digit characters are treated as an error. + + Octal numbers are expected to have a leading zero, with no 'o' format specifier. + Hexadecimal numbers are expected to be preceded by '0x' or '0X'. + Numbers will otherwise be considered to be in base 10. +*/ +parse_ip_component :: proc(input: string, max_value := u64(max(u32)), bases := DEFAULT_DIGIT_BASES) -> (value: u64, bytes_consumed: int, ok: bool) { + // Default to base 10 + base := u64(10) + input := input + + /* + We keep track of the number of prefix bytes and digit bytes separately. + This way if a prefix is consumed and we encounter a separator or the end of the string, + the number is only considered valid if at least 1 digit byte has been consumed and the value is within range. + */ + prefix_bytes := 0 + digit_bytes := 0 + + /* + IPv6 hex bytes are unprefixed and can't be disambiguated from octal or hex unless the digit is out of range. + If we got the `.IPv6` option, skip prefix scanning and other flags aren't also used. + */ + if .IPv6 in bases { + if bases != {.IPv6} { return } // Must be used on its own. + base = 16 + } else { + // Scan for and consume prefix, if applicable. + if len(input) >= 2 && input[0] == '0' { + if .Hex in bases && (input[1] == 'x' || input[1] == 'X') { + base = 16 + input = input[2:] + prefix_bytes = 2 + } + if prefix_bytes == 0 && .Oct in bases { + base = 8 + input = input[1:] + prefix_bytes = 1 + } + } + } + + parse_loop: for ch in input { + switch ch { + case '0'..='7': + digit_bytes += 1 + value = value * base + u64(ch - '0') + + case '8'..='9': + digit_bytes += 1 + + if base == 8 { + // Out of range for octal numbers. + return value, digit_bytes + prefix_bytes, false + } + value = value * base + u64(ch - '0') + + case 'a'..='f': + digit_bytes += 1 + + if base == 8 || base == 10 { + // Out of range for octal and decimal numbers. + return value, digit_bytes + prefix_bytes, false + } + value = value * base + (u64(ch - 'a') + 10) + + case 'A'..='F': + digit_bytes += 1 + + if base == 8 || base == 10 { + // Out of range for octal and decimal numbers. + return value, digit_bytes + prefix_bytes, false + } + value = value * base + (u64(ch - 'A') + 10) + + case '.', ':': + /* + Number separator. Return early. + We don't need to check if the number is in range. + We do that each time through the loop. + */ + break parse_loop + + case: + // Invalid character encountered. + return value, digit_bytes + prefix_bytes, false + } + + if value > max_value { + // Out-of-range number. + return value, digit_bytes + prefix_bytes, false + } + } + + // If we consumed at least 1 digit byte, `value` *should* continue a valid number in an appropriate base in the allowable range. + return value, digit_bytes + prefix_bytes, digit_bytes >= 1 +} + +// Returns an address for each interface that can be bound to. +get_network_interfaces :: proc() -> []Address { + // TODO: Implement using `enumerate_interfaces` and returning only the addresses of active interfaces. + return nil +} \ No newline at end of file diff --git a/core/net/common.odin b/core/net/common.odin new file mode 100644 index 000000000..70a027138 --- /dev/null +++ b/core/net/common.odin @@ -0,0 +1,416 @@ +// +build windows, linux, darwin +package net + +/* + Package net implements cross-platform Berkeley Sockets, DNS resolution and associated procedures. + For other protocols and their features, see subdirectories of this package. + + This file collects structs, enums and settings applicable to the entire package in one handy place. + Platform-specific ones can be found in their respective `*_windows.odin` and similar files. +*/ + +/* + Copyright 2022 Tetralux + Copyright 2022 Colin Davidson + Copyright 2022 Jeroen van Rijn . + Made available under Odin's BSD-3 license. + + List of contributors: + Tetralux: Initial implementation + Colin Davidson: Linux platform code, OSX platform code, Odin-native DNS resolver + Jeroen van Rijn: Cross platform unification, code style, documentation +*/ + +import "core:runtime" + +/* + TUNEABLES - See also top of `dns.odin` for DNS configuration. + + Determines the default value for whether dial_tcp() and accept_tcp() will set TCP_NODELAY on the new + socket, and the client socket, respectively. + This can also be set on a per-socket basis using the 'options' optional parameter to those procedures. + + When TCP_NODELAY is set, data will be sent out to the peer as quickly as possible, rather than being + coalesced into fewer network packets. + + This makes the networking layer more eagerly send data when you ask it to, + which can reduce latency by up to 200ms. + + This does mean that a lot of small writes will negatively effect throughput however, + since the Nagle algorithm will be disabled, and each write becomes one + IP packet. This will increase traffic by a factor of 40, with IP and TCP + headers for each payload. + + However, you can avoid this by buffering things up yourself if you wish to send a lot of + short data chunks, when TCP_NODELAY is enabled on that socket. +*/ + +ODIN_NET_TCP_NODELAY_DEFAULT :: #config(ODIN_NET_TCP_NODELAY_DEFAULT, true) + +// COMMON DEFINITIONS +Maybe :: runtime.Maybe + +Network_Error :: union #shared_nil { + General_Error, + Platform_Error, + Create_Socket_Error, + Dial_Error, + Listen_Error, + Accept_Error, + Bind_Error, + TCP_Send_Error, + UDP_Send_Error, + TCP_Recv_Error, + UDP_Recv_Error, + Shutdown_Error, + Socket_Option_Error, + Set_Blocking_Error, + Parse_Endpoint_Error, + Resolve_Error, + DNS_Error, +} + +General_Error :: enum u32 { + None = 0, + Unable_To_Enumerate_Network_Interfaces = 1, +} + +// `Platform_Error` is used to wrap errors returned by the different platforms that don't fit a common error. +Platform_Error :: enum u32 {} + +Parse_Endpoint_Error :: enum { + None = 0, + Bad_Port = 1, + Bad_Address, + Bad_Hostname, +} + +Resolve_Error :: enum u32 { + None = 0, + Unable_To_Resolve = 1, +} + +DNS_Error :: enum u32 { + Invalid_Hostname_Error = 1, + Invalid_Hosts_Config_Error, + Invalid_Resolv_Config_Error, + Connection_Error, + Server_Error, + System_Error, +} + +// SOCKET OPTIONS & DEFINITIONS +TCP_Options :: struct { + no_delay: bool, +} + +default_tcp_options := TCP_Options { + no_delay = ODIN_NET_TCP_NODELAY_DEFAULT, +} + +/* + To allow freely using `Socket` in your own data structures in a cross-platform manner, + we treat it as a handle large enough to accomodate OS-specific notions of socket handles. + + The platform code will perform the cast so you don't have to. +*/ +Socket :: distinct i64 + +TCP_Socket :: distinct Socket +UDP_Socket :: distinct Socket + +Socket_Protocol :: enum { + TCP, + UDP, +} + +Any_Socket :: union { + TCP_Socket, + UDP_Socket, +} + +/* + ADDRESS DEFINITIONS +*/ + +IP4_Address :: distinct [4]u8 +IP6_Address :: distinct [8]u16be +Address :: union {IP4_Address, IP6_Address} + +IP4_Loopback := IP4_Address{127, 0, 0, 1} +IP6_Loopback := IP6_Address{0, 0, 0, 0, 0, 0, 0, 1} + +IP4_Any := IP4_Address{} +IP6_Any := IP6_Address{} + +Endpoint :: struct { + address: Address, + port: int, +} + +Address_Family :: enum { + IP4, + IP6, +} + +Netmask :: distinct Address + +/* + INTERFACE / LINK STATE +*/ +Network_Interface :: struct { + adapter_name: string, // On Windows this is a GUID that we could parse back into its u128 for more compact storage. + friendly_name: string, + description: string, + dns_suffix: string, + + physical_address: string, // MAC address, etc. + mtu: u32, + + unicast: [dynamic]Lease, + multicast: [dynamic]Address, + anycast: [dynamic]Address, + + gateways: [dynamic]Address, + dhcp_v4: Address, + dhcp_v6: Address, + + tunnel_type: Tunnel_Type, + + link: struct { + state: Link_State, + transmit_speed: u64, + receive_speed: u64, + }, +} + +// Empty bit set is unknown state. +Link_States :: enum u32 { + Up = 1, + Down = 2, + Testing = 3, + Dormant = 4, + Not_Present = 5, + Lower_Layer_Down = 6, + Loopback = 7, +} +Link_State :: bit_set[Link_States; u32] + +Lease :: struct { + address: Address, + netmask: Netmask, + lifetime: struct { + valid: u32, + preferred: u32, + lease: u32, + }, + origin: struct { + prefix: Prefix_Origin, + suffix: Suffix_Origin, + }, + address_duplication: Address_Duplication, +} + +Tunnel_Type :: enum i32 { + None = 0, + Other = 1, + Direct = 2, + IPv4_To_IPv6 = 11, + ISA_TAP = 13, + Teredo = 14, + IP_HTTPS = 15, +} + +Prefix_Origin :: enum i32 { + Other = 0, + Manual = 1, + Well_Known = 2, + DHCP = 3, + Router_Advertisement = 4, + Unchanged = 16, +} + +Suffix_Origin :: enum i32 { + Other = 0, + Manual = 1, + Well_Known = 2, + DHCP = 3, + Link_Layer_Address = 4, + Random = 5, + Unchanged = 16, +} + +Address_Duplication :: enum i32 { + Invalid = 0, + Tentative = 1, + Duplicate = 2, + Deprecated = 3, + Preferred = 4, +} + +// DNS DEFINITIONS +DNS_Configuration :: struct { + // Configuration files. + resolv_conf: string, + hosts_file: string, + + // TODO: Allow loading these up with `reload_configuration()` call or the like, + // so we don't have to do it each call. + name_servers: []Endpoint, + hosts_file_entries: []DNS_Record, +} + +DNS_Record_Type :: enum u16 { + DNS_TYPE_A = 0x1, // IP4 address. + DNS_TYPE_NS = 0x2, // IP6 address. + DNS_TYPE_CNAME = 0x5, // Another host name. + DNS_TYPE_MX = 0xf, // Arbitrary binary data or text. + DNS_TYPE_AAAA = 0x1c, // Address of a name (DNS) server. + DNS_TYPE_TEXT = 0x10, // Address and preference priority of a mail exchange server. + DNS_TYPE_SRV = 0x21, // Address, port, priority, and weight of a host that provides a particular service. + + IP4 = DNS_TYPE_A, + IP6 = DNS_TYPE_AAAA, + CNAME = DNS_TYPE_CNAME, + TXT = DNS_TYPE_TEXT, + NS = DNS_TYPE_NS, + MX = DNS_TYPE_MX, + SRV = DNS_TYPE_SRV, +} + +// Base DNS Record. All DNS responses will carry a hostname and TTL (time to live) field. +DNS_Record_Base :: struct { + record_name: string, + ttl_seconds: u32, // The time in seconds that this service will take to update, after the record is updated. +} + +// An IP4 address that the domain name maps to. There can be any number of these. +DNS_Record_IP4 :: struct { + using base: DNS_Record_Base, + address: IP4_Address, +} + +// An IPv6 address that the domain name maps to. There can be any number of these. +DNS_Record_IP6 :: struct { + using base: DNS_Record_Base, + address: IP6_Address, +} + +/* + Another domain name that the domain name maps to. + Domains can be pointed to another domain instead of directly to an IP address. + `get_dns_records` will recursively follow these if you request this type of record. +*/ +DNS_Record_CNAME :: struct { + using base: DNS_Record_Base, + host_name: string, +} + +/* + Arbitrary string data that is associated with the domain name. + Commonly of the form `key=value` to be parsed, though there is no specific format for them. + These can be used for any purpose. +*/ +DNS_Record_TXT :: struct { + using base: DNS_Record_Base, + value: string, +} + +/* + Domain names of other DNS servers that are associated with the domain name. + TODO(tetra): Expand on what these records are used for, and when you should use pay attention to these. +*/ +DNS_Record_NS :: struct { + using base: DNS_Record_Base, + host_name: string, +} + +// Domain names for email servers that are associated with the domain name. +// These records also have values which ranks them in the order they should be preferred. Lower is more-preferred. +DNS_Record_MX :: struct { + using base: DNS_Record_Base, + host_name: string, + preference: int, +} + +/* + An endpoint for a service that is available through the domain name. + This is the way to discover the services that a domain name provides. + + Clients MUST attempt to contact the host with the lowest priority that they can reach. + If two hosts have the same priority, they should be contacted in the order according to their weight. + Hosts with larger weights should have a proportionally higher chance of being contacted by clients. + A weight of zero indicates a very low weight, or, when there is no choice (to reduce visual noise). + + The host may be "." to indicate that it is "decidedly not available" on this domain. +*/ +DNS_Record_SRV :: struct { + // base contains the full name of this record. + // e.g: _sip._tls.example.com + using base: DNS_Record_Base, + + // The hostname or address where this service can be found. + target: string, + // The port on which this service can be found. + port: int, + + service_name: string, // NOTE(tetra): These are substrings of 'record_name' + protocol_name: string, // NOTE(tetra): These are substrings of 'record_name' + + // Lower is higher priority + priority: int, + // Relative weight of this host compared to other of same priority; the chance of using this host should be proporitional to this weight. + // The number of seconds that it will take to update the record. + weight: int, +} + +DNS_Record :: union { + DNS_Record_IP4, + DNS_Record_IP6, + DNS_Record_CNAME, + DNS_Record_TXT, + DNS_Record_NS, + DNS_Record_MX, + DNS_Record_SRV, +} + +DNS_Response_Code :: enum u16be { + No_Error, + Format_Error, + Server_Failure, + Name_Error, + Not_Implemented, + Refused, +} + +DNS_Query :: enum u16be { + Host_Address = 1, + Authoritative_Name_Server = 2, + Mail_Destination = 3, + Mail_Forwarder = 4, + CNAME = 5, + All = 255, +} + +DNS_Header :: struct { + id: u16be, + is_response: bool, + opcode: u16be, + is_authoritative: bool, + is_truncated: bool, + is_recursion_desired: bool, + is_recursion_available: bool, + response_code: DNS_Response_Code, +} + +DNS_Record_Header :: struct #packed { + type: u16be, + class: u16be, + ttl: u32be, + length: u16be, +} + +DNS_Host_Entry :: struct { + name: string, + addr: Address, +} \ No newline at end of file diff --git a/core/net/dns.odin b/core/net/dns.odin new file mode 100644 index 000000000..6afa844fe --- /dev/null +++ b/core/net/dns.odin @@ -0,0 +1,870 @@ +// +build windows, linux, darwin +package net + +/* + Package net implements cross-platform Berkeley Sockets, DNS resolution and associated procedures. + For other protocols and their features, see subdirectories of this package. +*/ + +/* + Copyright 2022 Tetralux + Copyright 2022 Colin Davidson + Copyright 2022 Jeroen van Rijn . + Made available under Odin's BSD-3 license. + + List of contributors: + Tetralux: Initial implementation + Colin Davidson: Linux platform code, OSX platform code, Odin-native DNS resolver + Jeroen van Rijn: Cross platform unification, code style, documentation +*/ + +import "core:mem" +import "core:strings" +import "core:time" +import "core:os" +/* + Default configuration for DNS resolution. +*/ +when ODIN_OS == .Windows { + DEFAULT_DNS_CONFIGURATION :: DNS_Configuration{ + resolv_conf = "", + hosts_file = "%WINDIR%\\system32\\drivers\\etc\\hosts", + } +} else when ODIN_OS == .Linux || ODIN_OS == .Darwin || ODIN_OS == .OpenBSD { + DEFAULT_DNS_CONFIGURATION :: DNS_Configuration{ + resolv_conf = "/etc/resolv.conf", + hosts_file = "/etc/hosts", + } +} else { + #panic("Please add a configuration for this OS.") +} + +@(init) +init_dns_configuration :: proc() { + /* + Resolve %ENVIRONMENT% placeholders in their paths. + */ + dns_configuration.resolv_conf, _ = replace_environment_path(dns_configuration.resolv_conf) + dns_configuration.hosts_file, _ = replace_environment_path(dns_configuration.hosts_file) +} + +destroy_dns_configuration :: proc() { + delete(dns_configuration.resolv_conf) + delete(dns_configuration.hosts_file) +} + +dns_configuration := DEFAULT_DNS_CONFIGURATION + +// Always allocates for consistency. +replace_environment_path :: proc(path: string, allocator := context.allocator) -> (res: string, ok: bool) { + // Nothing to replace. Return a clone of the original. + if strings.count(path, "%") != 2 { + return strings.clone(path, allocator), true + } + + left := strings.index(path, "%") + 1 + assert(left > 0 && left <= len(path)) // should be covered by there being two % + + right := strings.index(path[left:], "%") + 1 + assert(right > 0 && right <= len(path)) // should be covered by there being two % + + env_key := path[left: right] + env_val := os.get_env(env_key, allocator) + defer delete(env_val) + + res, _ = strings.replace(path, path[left - 1: right + 1], env_val, 1, allocator) + return res, true +} + + +/* + Resolves a hostname to exactly one IP4 and IP6 endpoint. + It's then up to you which one you use. + Note that which address you use to open a socket, determines the type of the socket you get. + + Returns `ok=false` if the host name could not be resolved to any endpoints. + + Returned endpoints have the same port as provided in the string, or 0 if absent. + If you want to use a specific port, just modify the field after the call to this procedure. + + If the hostname part of the endpoint is actually a string representation of an IP address, DNS resolution will be skipped. + This allows you to pass both strings like "example.com:9000" and "1.2.3.4:9000" to this function end reliably get + back an endpoint in both cases. +*/ +resolve :: proc(hostname_and_maybe_port: string) -> (ep4, ep6: Endpoint, err: Network_Error) { + target := parse_hostname_or_endpoint(hostname_and_maybe_port) or_return + switch t in target { + case Endpoint: + // NOTE(tetra): The hostname was actually an IP address; nothing to resolve, so just return it. + switch in t.address { + case IP4_Address: ep4 = t + case IP6_Address: ep6 = t + case: unreachable() + } + return + + case Host: + err4, err6: Network_Error = ---, --- + ep4, err4 = resolve_ip4(t.hostname) + ep6, err6 = resolve_ip6(t.hostname) + ep4.port = t.port if err4 == nil else 0 + ep6.port = t.port if err6 == nil else 0 + if err4 != nil && err6 != nil { + err = err4 + } + return + } + unreachable() +} + +resolve_ip4 :: proc(hostname_and_maybe_port: string) -> (ep4: Endpoint, err: Network_Error) { + target := parse_hostname_or_endpoint(hostname_and_maybe_port) or_return + switch t in target { + case Endpoint: + // NOTE(tetra): The hostname was actually an IP address; nothing to resolve, so just return it. + switch in t.address { + case IP4_Address: + return t, nil + case IP6_Address: + err = .Unable_To_Resolve + return + } + case Host: + recs, _ := get_dns_records_from_os(t.hostname, .IP4, context.temp_allocator) + if len(recs) == 0 { + err = .Unable_To_Resolve + return + } + ep4 = { + address = recs[0].(DNS_Record_IP4).address, + port = t.port, + } + return + } + unreachable() +} + +resolve_ip6 :: proc(hostname_and_maybe_port: string) -> (ep6: Endpoint, err: Network_Error) { + target := parse_hostname_or_endpoint(hostname_and_maybe_port) or_return + switch t in target { + case Endpoint: + // NOTE(tetra): The hostname was actually an IP address; nothing to resolve, so just return it. + switch in t.address { + case IP4_Address: + err = .Unable_To_Resolve + return + case IP6_Address: + return t, nil + } + case Host: + recs, _ := get_dns_records_from_os(t.hostname, .IP6, context.temp_allocator) + if len(recs) == 0 { + err = .Unable_To_Resolve + return + } + ep6 = { + address = recs[0].(DNS_Record_IP6).address, + port = t.port, + } + return + } + unreachable() +} + +/* + Performs a recursive DNS query for records of a particular type for the hostname using the OS. + + NOTE: This procedure instructs the DNS resolver to recursively perform CNAME requests on our behalf, + meaning that DNS queries for a hostname will resolve through CNAME records until an + IP address is reached. + + IMPORTANT: This procedure allocates memory for each record returned; deleting just the returned slice is not enough! + See `destroy_records`. +*/ +get_dns_records_from_os :: proc(hostname: string, type: DNS_Record_Type, allocator := context.allocator) -> (records: []DNS_Record, err: DNS_Error) { + return _get_dns_records_os(hostname, type, allocator) +} + +/* + A generic DNS client usable on any platform. + Performs a recursive DNS query for records of a particular type for the hostname. + + NOTE: This procedure instructs the DNS resolver to recursively perform CNAME requests on our behalf, + meaning that DNS queries for a hostname will resolve through CNAME records until an + IP address is reached. + + IMPORTANT: This procedure allocates memory for each record returned; deleting just the returned slice is not enough! + See `destroy_records`. +*/ +get_dns_records_from_nameservers :: proc(hostname: string, type: DNS_Record_Type, name_servers: []Endpoint, host_overrides: []DNS_Record, allocator := context.allocator) -> (records: []DNS_Record, err: DNS_Error) { + context.allocator = allocator + + if type != .SRV { + // NOTE(tetra): 'hostname' can contain underscores when querying SRV records + ok := validate_hostname(hostname) + if !ok { + return nil, .Invalid_Hostname_Error + } + } + + hdr := DNS_Header{ + id = 0, + is_response = false, + opcode = 0, + is_authoritative = false, + is_truncated = false, + is_recursion_desired = true, + is_recursion_available = false, + response_code = DNS_Response_Code.No_Error, + } + + id, bits := pack_dns_header(hdr) + dns_hdr := [6]u16be{} + dns_hdr[0] = id + dns_hdr[1] = bits + dns_hdr[2] = 1 + + dns_query := [2]u16be{ u16be(type), 1 } + + output := [(size_of(u16be) * 6) + NAME_MAX + (size_of(u16be) * 2)]u8{} + b := strings.builder_from_slice(output[:]) + + strings.write_bytes(&b, mem.slice_data_cast([]u8, dns_hdr[:])) + ok := encode_hostname(&b, hostname) + if !ok { + return nil, .Invalid_Hostname_Error + } + strings.write_bytes(&b, mem.slice_data_cast([]u8, dns_query[:])) + + dns_packet := output[:strings.builder_len(b)] + + dns_response_buf := [4096]u8{} + dns_response: []u8 + for name_server in name_servers { + conn, sock_err := make_unbound_udp_socket(family_from_endpoint(name_server)) + if sock_err != nil { + return nil, .Connection_Error + } + defer close(conn) + + _, send_err := send(conn, dns_packet[:], name_server) + if send_err != nil { + continue + } + + set_err := set_option(conn, .Receive_Timeout, time.Second * 1) + if set_err != nil { + return nil, .Connection_Error + } + + recv_sz, _, recv_err := recv_udp(conn, dns_response_buf[:]) + if recv_err == UDP_Recv_Error.Timeout { + continue + } else if recv_err != nil { + continue + } + + if recv_sz == 0 { + continue + } + + dns_response = dns_response_buf[:recv_sz] + + rsp, _ok := parse_response(dns_response, type) + if !_ok { + return nil, .Server_Error + } + + if len(rsp) == 0 { + continue + } + + return rsp[:], nil + } + + return +} + +// `records` slice is also destroyed. +destroy_dns_records :: proc(records: []DNS_Record, allocator := context.allocator) { + context.allocator = allocator + + for rec in records { + switch r in rec { + case DNS_Record_IP4: + delete(r.base.record_name) + + case DNS_Record_IP6: + delete(r.base.record_name) + + case DNS_Record_CNAME: + delete(r.base.record_name) + delete(r.host_name) + + case DNS_Record_TXT: + delete(r.base.record_name) + delete(r.value) + + case DNS_Record_NS: + delete(r.base.record_name) + delete(r.host_name) + + case DNS_Record_MX: + delete(r.base.record_name) + delete(r.host_name) + + case DNS_Record_SRV: + delete(r.record_name) + delete(r.target) + } + } + + delete(records, allocator) +} + +/* + TODO(cloin): Does the DNS Resolver need to recursively hop through CNAMEs to get the IP + or is that what recursion desired does? Do we need to handle recursion unavailable? + How do we deal with is_authoritative / is_truncated? +*/ + +NAME_MAX :: 255 +LABEL_MAX :: 63 + +pack_dns_header :: proc(hdr: DNS_Header) -> (id: u16be, bits: u16be) { + id = hdr.id + bits = hdr.opcode << 1 | u16be(hdr.response_code) + if hdr.is_response { + bits |= 1 << 15 + } + if hdr.is_authoritative { + bits |= 1 << 10 + } + if hdr.is_truncated { + bits |= 1 << 9 + } + if hdr.is_recursion_desired { + bits |= 1 << 8 + } + if hdr.is_recursion_available { + bits |= 1 << 7 + } + + return id, bits +} + +unpack_dns_header :: proc(id: u16be, bits: u16be) -> (hdr: DNS_Header) { + hdr.id = id + hdr.is_response = (bits & (1 << 15)) != 0 + hdr.opcode = (bits >> 11) & 0xF + hdr.is_authoritative = (bits & (1 << 10)) != 0 + hdr.is_truncated = (bits & (1 << 9)) != 0 + hdr.is_recursion_desired = (bits & (1 << 8)) != 0 + hdr.is_recursion_available = (bits & (1 << 7)) != 0 + hdr.response_code = DNS_Response_Code(bits & 0xF) + + return hdr +} + +load_resolv_conf :: proc(resolv_conf_path: string, allocator := context.allocator) -> (name_servers: []Endpoint, ok: bool) { + context.allocator = allocator + + res := os.read_entire_file_from_filename(resolv_conf_path) or_return + defer delete(res) + resolv_str := string(res) + + id_str := "nameserver" + id_len := len(id_str) + + _name_servers := make([dynamic]Endpoint, 0, allocator) + for line in strings.split_lines_iterator(&resolv_str) { + if len(line) == 0 || line[0] == '#' { + continue + } + + if len(line) < id_len || strings.compare(line[:id_len], id_str) != 0 { + continue + } + + server_ip_str := strings.trim_left_space(line[id_len:]) + if len(server_ip_str) == 0 { + continue + } + + addr := parse_address(server_ip_str) + if addr == nil { + continue + } + + endpoint := Endpoint{ + addr, + 53, + } + append(&_name_servers, endpoint) + } + + return _name_servers[:], true +} + +load_hosts :: proc(hosts_file_path: string, allocator := context.allocator) -> (hosts: []DNS_Host_Entry, ok: bool) { + context.allocator = allocator + + res := os.read_entire_file_from_filename(hosts_file_path, allocator) or_return + defer delete(res) + + _hosts := make([dynamic]DNS_Host_Entry, 0, allocator) + hosts_str := string(res) + for line in strings.split_lines_iterator(&hosts_str) { + if len(line) == 0 || line[0] == '#' { + continue + } + + splits := strings.fields(line) + defer delete(splits) + + ip_str := splits[0] + addr := parse_address(ip_str) + if addr == nil { + continue + } + + for hostname in splits[1:] { + if len(hostname) == 0 { + continue + } + + append(&_hosts, DNS_Host_Entry{hostname, addr}) + } + } + + return _hosts[:], true +} + +// www.google.com -> 3www6google3com0 +encode_hostname :: proc(b: ^strings.Builder, hostname: string) -> (ok: bool) { + _hostname := hostname + for section in strings.split_iterator(&_hostname, ".") { + if len(section) > LABEL_MAX { + return + } + + strings.write_byte(b, u8(len(section))) + strings.write_string(b, section) + } + strings.write_byte(b, 0) + + return true +} + +skip_hostname :: proc(packet: []u8, start_idx: int) -> (encode_size: int, ok: bool) { + out_size := 0 + + cur_idx := start_idx + iteration_max := 0 + top: for cur_idx < len(packet) { + if packet[cur_idx] == 0 { + out_size += 1 + break + } + + if iteration_max > 255 { + return + } + + if packet[cur_idx] > 63 && packet[cur_idx] != 0xC0 { + return + } + + switch packet[cur_idx] { + case 0xC0: + out_size += 2 + break top + case: + label_size := int(packet[cur_idx]) + 1 + idx2 := cur_idx + label_size + + if idx2 < cur_idx + 1 || idx2 > len(packet) { + return + } + + out_size += label_size + cur_idx = idx2 + } + + iteration_max += 1 + } + + if start_idx + out_size > len(packet) { + return + } + + return out_size, true +} + +decode_hostname :: proc(packet: []u8, start_idx: int, allocator := context.allocator) -> (hostname: string, encode_size: int, ok: bool) { + output := [NAME_MAX]u8{} + b := strings.builder_from_slice(output[:]) + + // If you're on level 0, update out_bytes, everything through a pointer + // doesn't count towards this hostname's packet length + + // Evaluate tokens to generate the hostname + out_size := 0 + level := 0 + print_size := 0 + cur_idx := start_idx + iteration_max := 0 + labels_added := 0 + for cur_idx < len(packet) { + if packet[cur_idx] == 0 { + + if (level == 0) { + out_size += 1 + } + + break + } + + if iteration_max > 255 { + return + } + + if packet[cur_idx] > 63 && packet[cur_idx] != 0xC0 { + return + } + + switch packet[cur_idx] { + + // This is a offset to more data in the packet, jump to it + case 0xC0: + pkt := packet[cur_idx:cur_idx+2] + val := (^u16be)(raw_data(pkt))^ + offset := int(val & 0x3FFF) + if offset > len(packet) { + return + } + + cur_idx = offset + + if (level == 0) { + out_size += 2 + level += 1 + } + + // This is a label, insert it into the hostname + case: + label_size := int(packet[cur_idx]) + idx2 := cur_idx + label_size + 1 + if idx2 < cur_idx + 1 || idx2 > len(packet) { + return + } + + if print_size + label_size + 1 > NAME_MAX { + return + } + + if labels_added > 0 { + strings.write_byte(&b, '.') + } + strings.write_bytes(&b, packet[cur_idx+1:idx2]) + print_size += label_size + 1 + labels_added += 1 + + cur_idx = idx2 + + if (level == 0) { + out_size += label_size + 1 + } + } + + iteration_max += 1 + } + + if start_idx + out_size > len(packet) { + return + } + + return strings.clone(strings.to_string(b), allocator), out_size, true +} + +// Uses RFC 952 & RFC 1123 +validate_hostname :: proc(hostname: string) -> (ok: bool) { + if len(hostname) > 255 || len(hostname) == 0 { + return + } + + if hostname[0] == '-' { + return + } + + _hostname := hostname + for label in strings.split_iterator(&_hostname, ".") { + if len(label) > 63 || len(label) == 0 { + return + } + + for ch in label { + switch ch { + case: + return + case 'a'..='z', 'A'..='Z', '0'..='9', '-': + continue + } + } + } + + return true +} + +parse_record :: proc(packet: []u8, cur_off: ^int, filter: DNS_Record_Type = nil) -> (record: DNS_Record, ok: bool) { + record_buf := packet[cur_off^:] + + srv_record_name, hn_sz := decode_hostname(packet, cur_off^, context.temp_allocator) or_return + // TODO(tetra): Not sure what we should call this. + // Is it really only used in SRVs? + // Maybe some refactoring is required? + + ahdr_sz := size_of(DNS_Record_Header) + if len(record_buf) - hn_sz < ahdr_sz { + return + } + + record_hdr_bytes := record_buf[hn_sz:hn_sz+ahdr_sz] + record_hdr := cast(^DNS_Record_Header)raw_data(record_hdr_bytes) + + data_sz := record_hdr.length + data_off := cur_off^ + int(hn_sz) + int(ahdr_sz) + data := packet[data_off:data_off+int(data_sz)] + cur_off^ += int(hn_sz) + int(ahdr_sz) + int(data_sz) + + if u16be(filter) != record_hdr.type { + return nil, true + } + + _record: DNS_Record + #partial switch DNS_Record_Type(record_hdr.type) { + case .IP4: + if len(data) != 4 { + return + } + + addr := (^IP4_Address)(raw_data(data))^ + + _record = DNS_Record_IP4{ + base = DNS_Record_Base{ + record_name = strings.clone(srv_record_name), + ttl_seconds = u32(record_hdr.ttl), + }, + address = addr, + } + + case .IP6: + if len(data) != 16 { + return + } + + addr := (^IP6_Address)(raw_data(data))^ + + _record = DNS_Record_IP6{ + base = DNS_Record_Base{ + record_name = strings.clone(srv_record_name), + ttl_seconds = u32(record_hdr.ttl), + }, + address = addr, + } + + case .CNAME: + hostname, _ := decode_hostname(packet, data_off) or_return + + _record = DNS_Record_CNAME{ + base = DNS_Record_Base{ + record_name = strings.clone(srv_record_name), + ttl_seconds = u32(record_hdr.ttl), + }, + host_name = hostname, + } + + case .TXT: + _record = DNS_Record_TXT{ + base = DNS_Record_Base{ + record_name = strings.clone(srv_record_name), + ttl_seconds = u32(record_hdr.ttl), + }, + value = strings.clone(string(data)), + } + + case .NS: + name, _ := decode_hostname(packet, data_off) or_return + + _record = DNS_Record_NS{ + base = DNS_Record_Base{ + record_name = strings.clone(srv_record_name), + ttl_seconds = u32(record_hdr.ttl), + }, + host_name = name, + } + + case .SRV: + if len(data) <= 6 { + return + } + + _data := mem.slice_data_cast([]u16be, data) + + priority, weight, port := _data[0], _data[1], _data[2] + target, _ := decode_hostname(packet, data_off + (size_of(u16be) * 3)) or_return + + // NOTE(tetra): Srv record name should be of the form '_servicename._protocol.hostname' + // The record name is the name of the record. + // Not to be confused with the _target_ of the record, which is--in combination with the port--what we're looking up + // by making this request in the first place. + + // NOTE(Jeroen): Service Name and Protocol Name can probably just be string slices into the record name. + // It's already cloned, after all. I wouldn't put them on the temp allocator like this. + + parts := strings.split_n(srv_record_name, ".", 3, context.temp_allocator) + if len(parts) != 3 { + return + } + service_name, protocol_name := parts[0], parts[1] + + _record = DNS_Record_SRV{ + base = DNS_Record_Base{ + record_name = strings.clone(srv_record_name), + ttl_seconds = u32(record_hdr.ttl), + }, + target = target, + service_name = service_name, + protocol_name = protocol_name, + priority = int(priority), + weight = int(weight), + port = int(port), + } + + case .MX: + if len(data) <= 2 { + return + } + + preference: u16be = mem.slice_data_cast([]u16be, data)[0] + hostname, _ := decode_hostname(packet, data_off + size_of(u16be)) or_return + + _record = DNS_Record_MX{ + base = DNS_Record_Base{ + record_name = strings.clone(srv_record_name), + ttl_seconds = u32(record_hdr.ttl), + }, + host_name = hostname, + preference = int(preference), + } + + case: + return + + } + + return _record, true +} + +/* + DNS Query Response Format: + - DNS_Header (packed) + - Query Count + - Answer Count + - Authority Count + - Additional Count + - Query[] + - Hostname -- encoded + - Type + - Class + - Answer[] + - DNS Record Data + - Authority[] + - DNS Record Data + - Additional[] + - DNS Record Data + + DNS Record Data: + - DNS_Record_Header + - Data[] +*/ + +parse_response :: proc(response: []u8, filter: DNS_Record_Type = nil, allocator := context.allocator) -> (records: []DNS_Record, ok: bool) { + context.allocator = allocator + + HEADER_SIZE_BYTES :: 12 + if len(response) < HEADER_SIZE_BYTES { + return + } + + _records := make([dynamic]DNS_Record, 0) + + dns_hdr_chunks := mem.slice_data_cast([]u16be, response[:HEADER_SIZE_BYTES]) + hdr := unpack_dns_header(dns_hdr_chunks[0], dns_hdr_chunks[1]) + if !hdr.is_response { + return + } + + question_count := int(dns_hdr_chunks[2]) + if question_count != 1 { + return + } + answer_count := int(dns_hdr_chunks[3]) + authority_count := int(dns_hdr_chunks[4]) + additional_count := int(dns_hdr_chunks[5]) + + cur_idx := HEADER_SIZE_BYTES + + for _ in 0.. + Copyright 2022 Colin Davidson + Copyright 2022 Jeroen van Rijn . + Made available under Odin's BSD-3 license. + + List of contributors: + Tetralux: Initial implementation + Colin Davidson: Linux platform code, OSX platform code, Odin-native DNS resolver + Jeroen van Rijn: Cross platform unification, code style, documentation +*/ +import "core:strings" + +@(private) +_get_dns_records_os :: proc(hostname: string, type: DNS_Record_Type, allocator := context.allocator) -> (records: []DNS_Record, err: DNS_Error) { + context.allocator = allocator + + if type != .SRV { + // NOTE(tetra): 'hostname' can contain underscores when querying SRV records + ok := validate_hostname(hostname) + if !ok { + return nil, .Invalid_Hostname_Error + } + } + + name_servers, resolve_ok := load_resolv_conf(dns_configuration.resolv_conf) + defer delete(name_servers) + if !resolve_ok { + return nil, .Invalid_Resolv_Config_Error + } + if len(name_servers) == 0 { + return + } + + hosts, hosts_ok := load_hosts(dns_configuration.hosts_file) + defer delete(hosts) + if !hosts_ok { + return nil, .Invalid_Hosts_Config_Error + } + + host_overrides := make([dynamic]DNS_Record) + for host in hosts { + if strings.compare(host.name, hostname) != 0 { + continue + } + + if type == .IP4 && family_from_address(host.addr) == .IP4 { + record := DNS_Record_IP4{ + base = { + record_name = strings.clone(hostname), + ttl_seconds = 0, + }, + address = host.addr.(IP4_Address), + } + append(&host_overrides, record) + } else if type == .IP6 && family_from_address(host.addr) == .IP6 { + record := DNS_Record_IP6{ + base = { + record_name = strings.clone(hostname), + ttl_seconds = 0, + }, + address = host.addr.(IP6_Address), + } + append(&host_overrides, record) + } + } + + if len(host_overrides) > 0 { + return host_overrides[:], nil + } + + return get_dns_records_from_nameservers(hostname, type, name_servers, host_overrides[:]) +} diff --git a/core/net/dns_windows.odin b/core/net/dns_windows.odin new file mode 100644 index 000000000..72d67c54a --- /dev/null +++ b/core/net/dns_windows.odin @@ -0,0 +1,159 @@ +//+build windows +package net + +/* + Package net implements cross-platform Berkeley Sockets, DNS resolution and associated procedures. + For other protocols and their features, see subdirectories of this package. +*/ + +/* + Copyright 2022 Tetralux + Copyright 2022 Colin Davidson + Copyright 2022 Jeroen van Rijn . + Made available under Odin's BSD-3 license. + + List of contributors: + Tetralux: Initial implementation + Colin Davidson: Linux platform code, OSX platform code, Odin-native DNS resolver + Jeroen van Rijn: Cross platform unification, code style, documentation +*/ + +import "core:strings" +import "core:mem" + +import win "core:sys/windows" + +@(private) +_get_dns_records_os :: proc(hostname: string, type: DNS_Record_Type, allocator := context.allocator) -> (records: []DNS_Record, err: DNS_Error) { + context.allocator = allocator + + host_cstr := strings.clone_to_cstring(hostname, context.temp_allocator) + rec: ^win.DNS_RECORD + res := win.DnsQuery_UTF8(host_cstr, u16(type), 0, nil, &rec, nil) + + switch u32(res) { + case 0: + // okay + case win.ERROR_INVALID_NAME: + return nil, .Invalid_Hostname_Error + case win.DNS_INFO_NO_RECORDS: + return + case: + return nil, .System_Error + } + defer win.DnsRecordListFree(rec, 1) // 1 means that we're freeing a list... because the proc name isn't enough. + + count := 0 + for r := rec; r != nil; r = r.pNext { + if r.wType != u16(type) do continue // NOTE(tetra): Should never happen, but... + count += 1 + } + + recs := make([dynamic]DNS_Record, 0, count) + if recs == nil do return nil, .System_Error // return no results if OOM. + + for r := rec; r != nil; r = r.pNext { + if r.wType != u16(type) do continue // NOTE(tetra): Should never happen, but... + + base_record := DNS_Record_Base{ + record_name = strings.clone(string(r.pName)), + ttl_seconds = r.dwTtl, + } + + switch DNS_Record_Type(r.wType) { + case .IP4: + addr := IP4_Address(transmute([4]u8)r.Data.A) + record := DNS_Record_IP4{ + base = base_record, + address = addr, + } + append(&recs, record) + + case .IP6: + addr := IP6_Address(transmute([8]u16be) r.Data.AAAA) + record := DNS_Record_IP6{ + base = base_record, + address = addr, + } + append(&recs, record) + + case .CNAME: + + hostname := strings.clone(string(r.Data.CNAME)) + record := DNS_Record_CNAME{ + base = base_record, + host_name = hostname, + } + append(&recs, record) + + case .TXT: + n := r.Data.TXT.dwStringCount + ptr := &r.Data.TXT.pStringArray + c_strs := mem.slice_ptr(ptr, int(n)) + + for cstr in c_strs { + record := DNS_Record_TXT{ + base = base_record, + value = strings.clone(string(cstr)), + } + append(&recs, record) + } + + case .NS: + hostname := strings.clone(string(r.Data.NS)) + record := DNS_Record_NS{ + base = base_record, + host_name = hostname, + } + append(&recs, record) + + case .MX: + /* + TODO(tetra): Order by preference priority? (Prefer hosts with lower preference values.) + Or maybe not because you're supposed to just use the first one that works + and which order they're in changes every few calls. + */ + + record := DNS_Record_MX{ + base = base_record, + host_name = strings.clone(string(r.Data.MX.pNameExchange)), + preference = int(r.Data.MX.wPreference), + } + append(&recs, record) + + case .SRV: + target := strings.clone(string(r.Data.SRV.pNameTarget)) // The target hostname/address that the service can be found on + priority := int(r.Data.SRV.wPriority) + weight := int(r.Data.SRV.wWeight) + port := int(r.Data.SRV.wPort) + + // NOTE(tetra): Srv record name should be of the form '_servicename._protocol.hostname' + // The record name is the name of the record. + // Not to be confused with the _target_ of the record, which is--in combination with the port--what we're looking up + // by making this request in the first place. + + // NOTE(Jeroen): Service Name and Protocol Name can probably just be string slices into the record name. + // It's already cloned, after all. I wouldn't put them on the temp allocator like this. + + parts := strings.split_n(base_record.record_name, ".", 3, context.temp_allocator) + if len(parts) != 3 { + continue + } + service_name, protocol_name := parts[0], parts[1] + + append(&recs, DNS_Record_SRV { + base = base_record, + target = target, + port = port, + service_name = service_name, + protocol_name = protocol_name, + priority = priority, + weight = weight, + + }) + } + } + + records = recs[:] + return +} \ No newline at end of file diff --git a/core/net/doc.odin b/core/net/doc.odin new file mode 100644 index 000000000..0f1b33172 --- /dev/null +++ b/core/net/doc.odin @@ -0,0 +1,46 @@ +/* + Copyright 2022 Tetralux + Copyright 2022 Colin Davidson + Copyright 2022 Jeroen van Rijn . + Made available under Odin's BSD-3 license. + + List of contributors: + Tetralux: Initial implementation + Colin Davidson: Linux platform code, OSX platform code, Odin-native DNS resolver + Jeroen van Rijn: Cross platform unification, code style, documentation +*/ + +/* + Package net implements cross-platform Berkeley Sockets, DNS resolution and associated procedures. + For other protocols and their features, see subdirectories of this package. + + Features: + - Supports Windows, Linux and OSX. + - Opening and closing of TCP and UDP sockets. + - Sending to and receiving from these sockets. + - DNS name lookup, using either the OS or our own resolver. + + Planned: + - Nonblocking IO + - `Connection` struct + A "fat socket" struct that remembers how you opened it, etc, instead of just being a handle. + - IP Range structs, CIDR/class ranges, netmask calculator and associated helper procedures. + - Use `context.temp_allocator` instead of stack-based arenas? + And check it's the default temp allocator or can give us 4 MiB worth of memory + without punting to the main allocator by comparing their addresses in an @(init) procedure. + Panic if this assumption is not met. + + - Document assumptions about libc usage (or avoidance thereof) for each platform. + + Assumptions: + - For performance reasons this package relies on the `context.temp_allocator` in some places. + + You can replace the default `context.temp_allocator` with your own as long as it meets + this requirement: A minimum of 4 MiB of scratch space that's expected not to be freed. + + If this expectation is not met, the package's @(init) procedure will attempt to detect + this and panic to avoid temp allocations prematurely overwriting data and garbling results, + or worse. This means that should you replace the temp allocator with an insufficient one, + we'll do our best to loudly complain the first time you try it. +*/ +package net \ No newline at end of file diff --git a/core/net/errors_darwin.odin b/core/net/errors_darwin.odin new file mode 100644 index 000000000..39cf4c665 --- /dev/null +++ b/core/net/errors_darwin.odin @@ -0,0 +1,206 @@ +package net +// +build darwin + +/* + Package net implements cross-platform Berkeley Sockets, DNS resolution and associated procedures. + For other protocols and their features, see subdirectories of this package. +*/ + +/* + Copyright 2022 Tetralux + Copyright 2022 Colin Davidson + Copyright 2022 Jeroen van Rijn . + Made available under Odin's BSD-3 license. + + List of contributors: + Tetralux: Initial implementation + Colin Davidson: Linux platform code, OSX platform code, Odin-native DNS resolver + Jeroen van Rijn: Cross platform unification, code style, documentation +*/ + +import "core:c" +import "core:os" + +Create_Socket_Error :: enum c.int { + None = 0, + Family_Not_Supported_For_This_Socket = c.int(os.EAFNOSUPPORT), + No_Socket_Descriptors_Available = c.int(os.EMFILE), + No_Buffer_Space_Available = c.int(os.ENOBUFS), + No_Memory_Available_Available = c.int(os.ENOMEM), + Protocol_Unsupported_By_System = c.int(os.EPROTONOSUPPORT), + Wrong_Protocol_For_Socket = c.int(os.EPROTONOSUPPORT), + Family_And_Socket_Type_Mismatch = c.int(os.EPROTONOSUPPORT), +} + +Dial_Error :: enum c.int { + None = 0, + Port_Required = -1, + + Address_In_Use = c.int(os.EADDRINUSE), + In_Progress = c.int(os.EINPROGRESS), + Cannot_Use_Any_Address = c.int(os.EADDRNOTAVAIL), + Wrong_Family_For_Socket = c.int(os.EAFNOSUPPORT), + Refused = c.int(os.ECONNREFUSED), + Is_Listening_Socket = c.int(os.EACCES), + Already_Connected = c.int(os.EISCONN), + Network_Unreachable = c.int(os.ENETUNREACH), // Device is offline + Host_Unreachable = c.int(os.EHOSTUNREACH), // Remote host cannot be reached + No_Buffer_Space_Available = c.int(os.ENOBUFS), + Not_Socket = c.int(os.ENOTSOCK), + Timeout = c.int(os.ETIMEDOUT), + + // TODO: we may need special handling for this; maybe make a socket a struct with metadata? + Would_Block = c.int(os.EWOULDBLOCK), +} + +Bind_Error :: enum c.int { + None = 0, + Address_In_Use = c.int(os.EADDRINUSE), // Another application is currently bound to this endpoint. + Given_Nonlocal_Address = c.int(os.EADDRNOTAVAIL), // The address is not a local address on this machine. + Broadcast_Disabled = c.int(os.EACCES), // To bind a UDP socket to the broadcast address, the appropriate socket option must be set. + Address_Family_Mismatch = c.int(os.EFAULT), // The address family of the address does not match that of the socket. + Already_Bound = c.int(os.EINVAL), // The socket is already bound to an address. + No_Ports_Available = c.int(os.ENOBUFS), // There are not enough ephemeral ports available. +} + +Listen_Error :: enum c.int { + None = 0, + Address_In_Use = c.int(os.EADDRINUSE), + Already_Connected = c.int(os.EISCONN), + No_Socket_Descriptors_Available = c.int(os.EMFILE), + No_Buffer_Space_Available = c.int(os.ENOBUFS), + Nonlocal_Address = c.int(os.EADDRNOTAVAIL), + Not_Socket = c.int(os.ENOTSOCK), + Listening_Not_Supported_For_This_Socket = c.int(os.EOPNOTSUPP), +} + +Accept_Error :: enum c.int { + None = 0, + // TODO(tetra): Is this error actually possible here? Or is like Linux, in which case we can remove it. + Reset = c.int(os.ECONNRESET), + Not_Listening = c.int(os.EINVAL), + No_Socket_Descriptors_Available_For_Client_Socket = c.int(os.EMFILE), + No_Buffer_Space_Available = c.int(os.ENOBUFS), + Not_Socket = c.int(os.ENOTSOCK), + Not_Connection_Oriented_Socket = c.int(os.EOPNOTSUPP), + + // TODO: we may need special handling for this; maybe make a socket a struct with metadata? + Would_Block = c.int(os.EWOULDBLOCK), +} + +TCP_Recv_Error :: enum c.int { + None = 0, + Shutdown = c.int(os.ESHUTDOWN), + Not_Connected = c.int(os.ENOTCONN), + + // TODO(tetra): Is this error actually possible here? + Connection_Broken = c.int(os.ENETRESET), + Not_Socket = c.int(os.ENOTSOCK), + Aborted = c.int(os.ECONNABORTED), + + // TODO(tetra): Determine when this is different from the syscall returning n=0 and maybe normalize them? + Connection_Closed = c.int(os.ECONNRESET), + Offline = c.int(os.ENETDOWN), + Host_Unreachable = c.int(os.EHOSTUNREACH), + Interrupted = c.int(os.EINTR), + + // NOTE: No, really. Presumably this means something different for nonblocking sockets... + Timeout = c.int(os.EWOULDBLOCK), +} + +UDP_Recv_Error :: enum c.int { + None = 0, + Truncated = c.int(os.EMSGSIZE), // The buffer is too small to fit the entire message, and the message was truncated. + Not_Socket = c.int(os.ENOTSOCK), // The so-called socket is not an open socket. + Not_Descriptor = c.int(os.EBADF), // The so-called socket is, in fact, not even a valid descriptor. + Bad_Buffer = c.int(os.EFAULT), // The buffer did not point to a valid location in memory. + Interrupted = c.int(os.EINTR), // A signal occurred before any data was transmitted. See signal(7). + + // The send timeout duration passed before all data was sent. See Socket_Option.Send_Timeout. + // NOTE: No, really. Presumably this means something different for nonblocking sockets... + Timeout = c.int(os.EWOULDBLOCK), + Socket_Not_Bound = c.int(os.EINVAL), // The socket must be bound for this operation, but isn't. +} + +// TODO +TCP_Send_Error :: enum c.int { + None = 0, + + // TODO: merge with other errors? + Aborted = c.int(os.ECONNABORTED), + Connection_Closed = c.int(os.ECONNRESET), + Not_Connected = c.int(os.ENOTCONN), + Shutdown = c.int(os.ESHUTDOWN), + + // The send queue was full. + // This is usually a transient issue. + // + // This also shouldn't normally happen on Linux, as data is dropped if it + // doesn't fit in the send queue. + No_Buffer_Space_Available = c.int(os.ENOBUFS), + Offline = c.int(os.ENETDOWN), + Host_Unreachable = c.int(os.EHOSTUNREACH), + Interrupted = c.int(os.EINTR), // A signal occurred before any data was transmitted. See signal(7). + + // NOTE: No, really. Presumably this means something different for nonblocking sockets... + // The send timeout duration passed before all data was sent. See Socket_Option.Send_Timeout. + Timeout = c.int(os.EWOULDBLOCK), + Not_Socket = c.int(os.ENOTSOCK), // The so-called socket is not an open socket. +} + +// TODO +UDP_Send_Error :: enum c.int { + None = 0, + Truncated = c.int(os.EMSGSIZE), // The message is too big. No data was sent. + + // TODO: not sure what the exact circumstances for this is yet + Network_Unreachable = c.int(os.ENETUNREACH), + No_Outbound_Ports_Available = c.int(os.EAGAIN), // There are no more emphemeral outbound ports available to bind the socket to, in order to send. + + // The send timeout duration passed before all data was sent. See Socket_Option.Send_Timeout. + // NOTE: No, really. Presumably this means something different for nonblocking sockets... + Timeout = c.int(os.EWOULDBLOCK), + Not_Socket = c.int(os.ENOTSOCK), // The so-called socket is not an open socket. + Not_Descriptor = c.int(os.EBADF), // The so-called socket is, in fact, not even a valid descriptor. + Bad_Buffer = c.int(os.EFAULT), // The buffer did not point to a valid location in memory. + Interrupted = c.int(os.EINTR), // A signal occurred before any data was transmitted. See signal(7). + + // The send queue was full. + // This is usually a transient issue. + // + // This also shouldn't normally happen on Linux, as data is dropped if it + // doesn't fit in the send queue. + No_Buffer_Space_Available = c.int(os.ENOBUFS), + No_Memory_Available = c.int(os.ENOMEM), // No memory was available to properly manage the send queue. +} + +Shutdown_Manner :: enum c.int { + Receive = c.int(os.SHUT_RD), + Send = c.int(os.SHUT_WR), + Both = c.int(os.SHUT_RDWR), +} + +Shutdown_Error :: enum c.int { + None = 0, + Aborted = c.int(os.ECONNABORTED), + Reset = c.int(os.ECONNRESET), + Offline = c.int(os.ENETDOWN), + Not_Connected = c.int(os.ENOTCONN), + Not_Socket = c.int(os.ENOTSOCK), + Invalid_Manner = c.int(os.EINVAL), +} + +Socket_Option_Error :: enum c.int { + None = 0, + Offline = c.int(os.ENETDOWN), + Timeout_When_Keepalive_Set = c.int(os.ENETRESET), + Invalid_Option_For_Socket = c.int(os.ENOPROTOOPT), + Reset_When_Keepalive_Set = c.int(os.ENOTCONN), + Not_Socket = c.int(os.ENOTSOCK), +} + +Set_Blocking_Error :: enum c.int { + None = 0, + + // TODO: Add errors for `set_blocking` +} \ No newline at end of file diff --git a/core/net/errors_linux.odin b/core/net/errors_linux.odin new file mode 100644 index 000000000..9366f4435 --- /dev/null +++ b/core/net/errors_linux.odin @@ -0,0 +1,201 @@ +package net +// +build linux + +/* + Package net implements cross-platform Berkeley Sockets, DNS resolution and associated procedures. + For other protocols and their features, see subdirectories of this package. +*/ + +/* + Copyright 2022 Tetralux + Copyright 2022 Colin Davidson + Copyright 2022 Jeroen van Rijn . + Made available under Odin's BSD-3 license. + + List of contributors: + Tetralux: Initial implementation + Colin Davidson: Linux platform code, OSX platform code, Odin-native DNS resolver + Jeroen van Rijn: Cross platform unification, code style, documentation +*/ + +import "core:c" +import "core:os" + +Create_Socket_Error :: enum c.int { + None = 0, + Family_Not_Supported_For_This_Socket = c.int(os.EAFNOSUPPORT), + No_Socket_Descriptors_Available = c.int(os.EMFILE), + No_Buffer_Space_Available = c.int(os.ENOBUFS), + No_Memory_Available_Available = c.int(os.ENOMEM), + Protocol_Unsupported_By_System = c.int(os.EPROTONOSUPPORT), + Wrong_Protocol_For_Socket = c.int(os.EPROTONOSUPPORT), + Family_And_Socket_Type_Mismatch = c.int(os.EPROTONOSUPPORT), +} + +Dial_Error :: enum c.int { + None = 0, + Port_Required = -1, + + Address_In_Use = c.int(os.EADDRINUSE), + In_Progress = c.int(os.EINPROGRESS), + Cannot_Use_Any_Address = c.int(os.EADDRNOTAVAIL), + Wrong_Family_For_Socket = c.int(os.EAFNOSUPPORT), + Refused = c.int(os.ECONNREFUSED), + Is_Listening_Socket = c.int(os.EACCES), + Already_Connected = c.int(os.EISCONN), + Network_Unreachable = c.int(os.ENETUNREACH), // Device is offline + Host_Unreachable = c.int(os.EHOSTUNREACH), // Remote host cannot be reached + No_Buffer_Space_Available = c.int(os.ENOBUFS), + Not_Socket = c.int(os.ENOTSOCK), + Timeout = c.int(os.ETIMEDOUT), + + // TODO: we may need special handling for this; maybe make a socket a struct with metadata? + Would_Block = c.int(os.EWOULDBLOCK), +} + +Bind_Error :: enum c.int { + None = 0, + Address_In_Use = c.int(os.EADDRINUSE), // Another application is currently bound to this endpoint. + Given_Nonlocal_Address = c.int(os.EADDRNOTAVAIL), // The address is not a local address on this machine. + Broadcast_Disabled = c.int(os.EACCES), // To bind a UDP socket to the broadcast address, the appropriate socket option must be set. + Address_Family_Mismatch = c.int(os.EFAULT), // The address family of the address does not match that of the socket. + Already_Bound = c.int(os.EINVAL), // The socket is already bound to an address. + No_Ports_Available = c.int(os.ENOBUFS), // There are not enough ephemeral ports available. +} + +Listen_Error :: enum c.int { + None = 0, + Address_In_Use = c.int(os.EADDRINUSE), + Already_Connected = c.int(os.EISCONN), + No_Socket_Descriptors_Available = c.int(os.EMFILE), + No_Buffer_Space_Available = c.int(os.ENOBUFS), + Nonlocal_Address = c.int(os.EADDRNOTAVAIL), + Not_Socket = c.int(os.ENOTSOCK), + Listening_Not_Supported_For_This_Socket = c.int(os.EOPNOTSUPP), +} + +Accept_Error :: enum c.int { + None = 0, + Not_Listening = c.int(os.EINVAL), + No_Socket_Descriptors_Available_For_Client_Socket = c.int(os.EMFILE), + No_Buffer_Space_Available = c.int(os.ENOBUFS), + Not_Socket = c.int(os.ENOTSOCK), + Not_Connection_Oriented_Socket = c.int(os.EOPNOTSUPP), + + // TODO: we may need special handling for this; maybe make a socket a struct with metadata? + Would_Block = c.int(os.EWOULDBLOCK), +} + +TCP_Recv_Error :: enum c.int { + None = 0, + Shutdown = c.int(os.ESHUTDOWN), + Not_Connected = c.int(os.ENOTCONN), + Connection_Broken = c.int(os.ENETRESET), + Not_Socket = c.int(os.ENOTSOCK), + Aborted = c.int(os.ECONNABORTED), + + // TODO(tetra): Determine when this is different from the syscall returning n=0 and maybe normalize them? + Connection_Closed = c.int(os.ECONNRESET), + Offline = c.int(os.ENETDOWN), + Host_Unreachable = c.int(os.EHOSTUNREACH), + Interrupted = c.int(os.EINTR), + Timeout = c.int(os.EWOULDBLOCK), // NOTE: No, really. Presumably this means something different for nonblocking sockets... +} + +UDP_Recv_Error :: enum c.int { + None = 0, + + // The buffer is too small to fit the entire message, and the message was truncated. + // When this happens, the rest of message is lost. + Buffer_Too_Small = c.int(os.EMSGSIZE), + Not_Socket = c.int(os.ENOTSOCK), // The so-called socket is not an open socket. + Not_Descriptor = c.int(os.EBADF), // The so-called socket is, in fact, not even a valid descriptor. + Bad_Buffer = c.int(os.EFAULT), // The buffer did not point to a valid location in memory. + Interrupted = c.int(os.EINTR), // A signal occurred before any data was transmitted. See signal(7). + + // The send timeout duration passed before all data was received. See Socket_Option.Receive_Timeout. + // NOTE: No, really. Presumably this means something different for nonblocking sockets... + Timeout = c.int(os.EWOULDBLOCK), + Socket_Not_Bound = c.int(os.EINVAL), // The socket must be bound for this operation, but isn't. +} + +// TODO +TCP_Send_Error :: enum c.int { + None = 0, + // TODO(tetra): merge with other errors? + Aborted = c.int(os.ECONNABORTED), + Connection_Closed = c.int(os.ECONNRESET), + Not_Connected = c.int(os.ENOTCONN), + Shutdown = c.int(os.ESHUTDOWN), + + // The send queue was full. + // This is usually a transient issue. + // + // This also shouldn't normally happen on Linux, as data is dropped if it + // doesn't fit in the send queue. + No_Buffer_Space_Available = c.int(os.ENOBUFS), + Offline = c.int(os.ENETDOWN), + Host_Unreachable = c.int(os.EHOSTUNREACH), // A signal occurred before any data was transmitted. See signal(7). + Interrupted = c.int(os.EINTR), // The send timeout duration passed before all data was sent. See Socket_Option.Send_Timeout. + Timeout = c.int(os.EWOULDBLOCK), // NOTE: No, really. Presumably this means something different for nonblocking sockets... + Not_Socket = c.int(os.ENOTSOCK), // The so-called socket is not an open socket. +} + +// TODO +UDP_Send_Error :: enum c.int { + None = 0, + Message_Too_Long = c.int(os.EMSGSIZE), // The message is too big. No data was sent. + + // TODO: not sure what the exact circumstances for this is yet + Network_Unreachable = c.int(os.ENETUNREACH), + No_Outbound_Ports_Available = c.int(os.EAGAIN), // There are no more emphemeral outbound ports available to bind the socket to, in order to send. + + // The send timeout duration passed before all data was sent. See Socket_Option.Send_Timeout. + // NOTE: No, really. Presumably this means something different for nonblocking sockets... + Timeout = c.int(os.EWOULDBLOCK), + Not_Socket = c.int(os.ENOTSOCK), // The so-called socket is not an open socket. + Not_Descriptor = c.int(os.EBADF), // The so-called socket is, in fact, not even a valid descriptor. + Bad_Buffer = c.int(os.EFAULT), // The buffer did not point to a valid location in memory. + Interrupted = c.int(os.EINTR), // A signal occurred before any data was transmitted. See signal(7). + + // The send queue was full. + // This is usually a transient issue. + // + // This also shouldn't normally happen on Linux, as data is dropped if it + // doesn't fit in the send queue. + No_Buffer_Space_Available = c.int(os.ENOBUFS), + No_Memory_Available = c.int(os.ENOMEM), // No memory was available to properly manage the send queue. +} + +Shutdown_Manner :: enum c.int { + Receive = c.int(os.SHUT_RD), + Send = c.int(os.SHUT_WR), + Both = c.int(os.SHUT_RDWR), +} + +Shutdown_Error :: enum c.int { + None = 0, + Aborted = c.int(os.ECONNABORTED), + Reset = c.int(os.ECONNRESET), + Offline = c.int(os.ENETDOWN), + Not_Connected = c.int(os.ENOTCONN), + Not_Socket = c.int(os.ENOTSOCK), + Invalid_Manner = c.int(os.EINVAL), +} + +Socket_Option_Error :: enum c.int { + None = 0, + Offline = c.int(os.ENETDOWN), + Timeout_When_Keepalive_Set = c.int(os.ENETRESET), + Invalid_Option_For_Socket = c.int(os.ENOPROTOOPT), + Reset_When_Keepalive_Set = c.int(os.ENOTCONN), + Not_Socket = c.int(os.ENOTSOCK), +} + +Set_Blocking_Error :: enum c.int { + None = 0, + + // TODO: add errors occuring on followig calls: + // flags, _ := os.fcntl(sd, os.F_GETFL, 0) + // os.fcntl(sd, os.F_SETFL, flags | int(os.O_NONBLOCK)) +} \ No newline at end of file diff --git a/core/net/errors_windows.odin b/core/net/errors_windows.odin new file mode 100644 index 000000000..272aa0a96 --- /dev/null +++ b/core/net/errors_windows.odin @@ -0,0 +1,273 @@ +package net +// +build windows + +/* + Package net implements cross-platform Berkeley Sockets, DNS resolution and associated procedures. + For other protocols and their features, see subdirectories of this package. +*/ + +/* + Copyright 2022 Tetralux + Copyright 2022 Colin Davidson + Copyright 2022 Jeroen van Rijn . + Made available under Odin's BSD-3 license. + + List of contributors: + Tetralux: Initial implementation + Colin Davidson: Linux platform code, OSX platform code, Odin-native DNS resolver + Jeroen van Rijn: Cross platform unification, code style, documentation +*/ + +import "core:c" +import win "core:sys/windows" + +Create_Socket_Error :: enum c.int { + None = 0, + Network_Subsystem_Failure = win.WSAENETDOWN, + Family_Not_Supported_For_This_Socket = win.WSAEAFNOSUPPORT, + No_Socket_Descriptors_Available = win.WSAEMFILE, + No_Buffer_Space_Available = win.WSAENOBUFS, + Protocol_Unsupported_By_System = win.WSAEPROTONOSUPPORT, + Wrong_Protocol_For_Socket = win.WSAEPROTOTYPE, + Family_And_Socket_Type_Mismatch = win.WSAESOCKTNOSUPPORT, +} + +Dial_Error :: enum c.int { + None = 0, + Port_Required = -1, + Address_In_Use = win.WSAEADDRINUSE, + In_Progress = win.WSAEALREADY, + Cannot_Use_Any_Address = win.WSAEADDRNOTAVAIL, + Wrong_Family_For_Socket = win.WSAEAFNOSUPPORT, + Refused = win.WSAECONNREFUSED, + Is_Listening_Socket = win.WSAEINVAL, + Already_Connected = win.WSAEISCONN, + Network_Unreachable = win.WSAENETUNREACH, // Device is offline + Host_Unreachable = win.WSAEHOSTUNREACH, // Remote host cannot be reached + No_Buffer_Space_Available = win.WSAENOBUFS, + Not_Socket = win.WSAENOTSOCK, + Timeout = win.WSAETIMEDOUT, + Would_Block = win.WSAEWOULDBLOCK, // TODO: we may need special handling for this; maybe make a socket a struct with metadata? +} + +Bind_Error :: enum c.int { + None = 0, + Address_In_Use = win.WSAEADDRINUSE, // Another application is currently bound to this endpoint. + Given_Nonlocal_Address = win.WSAEADDRNOTAVAIL, // The address is not a local address on this machine. + Broadcast_Disabled = win.WSAEACCES, // To bind a UDP socket to the broadcast address, the appropriate socket option must be set. + Address_Family_Mismatch = win.WSAEFAULT, // The address family of the address does not match that of the socket. + Already_Bound = win.WSAEINVAL, // The socket is already bound to an address. + No_Ports_Available = win.WSAENOBUFS, // There are not enough ephemeral ports available. +} + +Listen_Error :: enum c.int { + None = 0, + Address_In_Use = win.WSAEADDRINUSE, + Already_Connected = win.WSAEISCONN, + No_Socket_Descriptors_Available = win.WSAEMFILE, + No_Buffer_Space_Available = win.WSAENOBUFS, + Nonlocal_Address = win.WSAEADDRNOTAVAIL, + Not_Socket = win.WSAENOTSOCK, + Listening_Not_Supported_For_This_Socket = win.WSAEOPNOTSUPP, +} + +Accept_Error :: enum c.int { + None = 0, + Not_Listening = win.WSAEINVAL, + No_Socket_Descriptors_Available_For_Client_Socket = win.WSAEMFILE, + No_Buffer_Space_Available = win.WSAENOBUFS, + Not_Socket = win.WSAENOTSOCK, + Not_Connection_Oriented_Socket = win.WSAEOPNOTSUPP, + + // TODO: we may need special handling for this; maybe make a socket a struct with metadata? + Would_Block = win.WSAEWOULDBLOCK, +} + +TCP_Recv_Error :: enum c.int { + None = 0, + Network_Subsystem_Failure = win.WSAENETDOWN, + Not_Connected = win.WSAENOTCONN, + Bad_Buffer = win.WSAEFAULT, + Keepalive_Failure = win.WSAENETRESET, + Not_Socket = win.WSAENOTSOCK, + Shutdown = win.WSAESHUTDOWN, + Would_Block = win.WSAEWOULDBLOCK, + + // TODO: not functionally different from Reset; merge? + Aborted = win.WSAECONNABORTED, + Timeout = win.WSAETIMEDOUT, + + // TODO(tetra): Determine when this is different from the syscall returning n=0 and maybe normalize them? + Connection_Closed = win.WSAECONNRESET, + + // TODO: verify can actually happen + Host_Unreachable = win.WSAEHOSTUNREACH, +} + +UDP_Recv_Error :: enum c.int { + None = 0, + Network_Subsystem_Failure = win.WSAENETDOWN, + + // TODO: not functionally different from Reset; merge? + // UDP packets are limited in size, and the length of the incoming message exceeded it. + Aborted = win.WSAECONNABORTED, + Truncated = win.WSAEMSGSIZE, + Remote_Not_Listening = win.WSAECONNRESET, // The machine at the remote endpoint doesn't have the given port open to receiving UDP data. + Shutdown = win.WSAESHUTDOWN, + Broadcast_Disabled = win.WSAEACCES, // A broadcast address was specified, but the .Broadcast socket option isn't set. + Bad_Buffer = win.WSAEFAULT, + No_Buffer_Space_Available = win.WSAENOBUFS, + Not_Socket = win.WSAENOTSOCK, // The socket is not valid socket handle. + Would_Block = win.WSAEWOULDBLOCK, + Host_Unreachable = win.WSAEHOSTUNREACH, // The remote host cannot be reached from this host at this time. + Offline = win.WSAENETUNREACH, // The network cannot be reached from this host at this time. + Timeout = win.WSAETIMEDOUT, + + // TODO: can this actually happen? The socket isn't bound; an unknown flag specified; or MSG_OOB specified with SO_OOBINLINE enabled. + Incorrectly_Configured = win.WSAEINVAL, + TTL_Expired = win.WSAENETRESET, // The message took more hops than was allowed (the Time To Live) to reach the remote endpoint. +} + +// TODO: consider merging some errors to make handling them easier +// TODO: verify once more what errors to actually expose +TCP_Send_Error :: enum c.int { + None = 0, + + // TODO: not functionally different from Reset; merge? + Aborted = win.WSAECONNABORTED, + Not_Connected = win.WSAENOTCONN, + Shutdown = win.WSAESHUTDOWN, + Connection_Closed = win.WSAECONNRESET, + No_Buffer_Space_Available = win.WSAENOBUFS, + Network_Subsystem_Failure = win.WSAENETDOWN, + Host_Unreachable = win.WSAEHOSTUNREACH, + + // TODO: verify possible, as not mentioned in docs + Offline = win.WSAENETUNREACH, + Timeout = win.WSAETIMEDOUT, + + // A broadcast address was specified, but the .Broadcast socket option isn't set. + Broadcast_Disabled = win.WSAEACCES, + Bad_Buffer = win.WSAEFAULT, + + // Connection is broken due to keepalive activity detecting a failure during the operation. + Keepalive_Failure = win.WSAENETRESET, // TODO: not functionally different from Reset; merge? + Not_Socket = win.WSAENOTSOCK, // The so-called socket is not an open socket. +} + +UDP_Send_Error :: enum c.int { + None = 0, + Network_Subsystem_Failure = win.WSAENETDOWN, + + // TODO: not functionally different from Reset; merge? + Aborted = win.WSAECONNABORTED, // UDP packets are limited in size, and len(buf) exceeded it. + Message_Too_Long = win.WSAEMSGSIZE, // The machine at the remote endpoint doesn't have the given port open to receiving UDP data. + Remote_Not_Listening = win.WSAECONNRESET, + Shutdown = win.WSAESHUTDOWN, // A broadcast address was specified, but the .Broadcast socket option isn't set. + Broadcast_Disabled = win.WSAEACCES, + Bad_Buffer = win.WSAEFAULT, // Connection is broken due to keepalive activity detecting a failure during the operation. + + // TODO: not functionally different from Reset; merge? + Keepalive_Failure = win.WSAENETRESET, + No_Buffer_Space_Available = win.WSAENOBUFS, + Not_Socket = win.WSAENOTSOCK, // The socket is not valid socket handle. + + // This socket is unidirectional and cannot be used to send any data. + // TODO: verify possible; decide whether to keep if not + Receive_Only = win.WSAEOPNOTSUPP, + Would_Block = win.WSAEWOULDBLOCK, + Host_Unreachable = win.WSAEHOSTUNREACH, // The remote host cannot be reached from this host at this time. + Cannot_Use_Any_Address = win.WSAEADDRNOTAVAIL, // Attempt to send to the Any address. + Family_Not_Supported_For_This_Socket = win.WSAEAFNOSUPPORT, // The address is of an incorrect address family for this socket. + Offline = win.WSAENETUNREACH, // The network cannot be reached from this host at this time. + Timeout = win.WSAETIMEDOUT, +} + +Shutdown_Manner :: enum c.int { + Receive = win.SD_RECEIVE, + Send = win.SD_SEND, + Both = win.SD_BOTH, +} + +Shutdown_Error :: enum c.int { + None = 0, + Aborted = win.WSAECONNABORTED, + Reset = win.WSAECONNRESET, + Offline = win.WSAENETDOWN, + Not_Connected = win.WSAENOTCONN, + Not_Socket = win.WSAENOTSOCK, + Invalid_Manner = win.WSAEINVAL, +} + +Socket_Option :: enum c.int { + // bool: Whether the address that this socket is bound to can be reused by other sockets. + // This allows you to bypass the cooldown period if a program dies while the socket is bound. + Reuse_Address = win.SO_REUSEADDR, + + // bool: Whether other programs will be inhibited from binding the same endpoint as this socket. + Exclusive_Addr_Use = win.SO_EXCLUSIVEADDRUSE, + + // bool: When true, keepalive packets will be automatically be sent for this connection. TODO: verify this understanding + Keep_Alive = win.SO_KEEPALIVE, + + // bool: When true, client connections will immediately be sent a TCP/IP RST response, rather than being accepted. + Conditional_Accept = win.SO_CONDITIONAL_ACCEPT, + + // bool: If true, when the socket is closed, but data is still waiting to be sent, discard that data. + Dont_Linger = win.SO_DONTLINGER, + + // bool: When true, 'out-of-band' data sent over the socket will be read by a normal net.recv() call, the same as normal 'in-band' data. + Out_Of_Bounds_Data_Inline = win.SO_OOBINLINE, + + // bool: When true, disables send-coalescing, therefore reducing latency. + TCP_Nodelay = win.TCP_NODELAY, + + // win.LINGER: Customizes how long (if at all) the socket will remain open when there + // is some remaining data waiting to be sent, and net.close() is called. + Linger = win.SO_LINGER, + + // win.DWORD: The size, in bytes, of the OS-managed receive-buffer for this socket. + Receive_Buffer_Size = win.SO_RCVBUF, + + // win.DWORD: The size, in bytes, of the OS-managed send-buffer for this socket. + Send_Buffer_Size = win.SO_SNDBUF, + + // win.DWORD: For blocking sockets, the time in milliseconds to wait for incoming data to be received, before giving up and returning .Timeout. + // For non-blocking sockets, ignored. + // Use a value of zero to potentially wait forever. + Receive_Timeout = win.SO_RCVTIMEO, + + // win.DWORD: For blocking sockets, the time in milliseconds to wait for outgoing data to be sent, before giving up and returning .Timeout. + // For non-blocking sockets, ignored. + // Use a value of zero to potentially wait forever. + Send_Timeout = win.SO_SNDTIMEO, + + // bool: Allow sending to, receiving from, and binding to, a broadcast address. + Broadcast = win.SO_BROADCAST, +} + +Socket_Option_Error :: enum c.int { + None = 0, + Linger_Only_Supports_Whole_Seconds = 1, + + // The given value is too big or small to be given to the OS. + Value_Out_Of_Range, + + Network_Subsystem_Failure = win.WSAENETDOWN, + Timeout_When_Keepalive_Set = win.WSAENETRESET, + Invalid_Option_For_Socket = win.WSAENOPROTOOPT, + Reset_When_Keepalive_Set = win.WSAENOTCONN, + Not_Socket = win.WSAENOTSOCK, +} + +Set_Blocking_Error :: enum c.int { + None = 0, + + Network_Subsystem_Failure = win.WSAENETDOWN, + Blocking_Call_In_Progress = win.WSAEINPROGRESS, + Not_Socket = win.WSAENOTSOCK, + + // TODO: are those errors possible? + Network_Subsystem_Not_Initialized = win.WSAENOTINITIALISED, + Invalid_Argument_Pointer = win.WSAEFAULT, +} \ No newline at end of file diff --git a/core/net/interface.odin b/core/net/interface.odin new file mode 100644 index 000000000..df7d0223e --- /dev/null +++ b/core/net/interface.odin @@ -0,0 +1,79 @@ +// +build windows, linux, darwin +package net + +/* + Package net implements cross-platform Berkeley Sockets, DNS resolution and associated procedures. + For other protocols and their features, see subdirectories of this package. +*/ + +/* + Copyright 2022 Tetralux + Copyright 2022 Colin Davidson + Copyright 2022 Jeroen van Rijn . + Made available under Odin's BSD-3 license. + + List of contributors: + Tetralux: Initial implementation + Colin Davidson: Linux platform code, OSX platform code, Odin-native DNS resolver + Jeroen van Rijn: Cross platform unification, code style, documentation +*/ + +import "core:strings" + +MAX_INTERFACE_ENUMERATION_TRIES :: 3 + +/* + `enumerate_interfaces` retrieves a list of network interfaces with their associated properties. +*/ +enumerate_interfaces :: proc(allocator := context.allocator) -> (interfaces: []Network_Interface, err: Network_Error) { + return _enumerate_interfaces(allocator) +} + +/* + `destroy_interfaces` cleans up a list of network interfaces retrieved by e.g. `enumerate_interfaces`. +*/ +destroy_interfaces :: proc(interfaces: []Network_Interface, allocator := context.allocator) { + context.allocator = allocator + + for i in interfaces { + delete(i.adapter_name) + delete(i.friendly_name) + delete(i.description) + delete(i.dns_suffix) + + delete(i.physical_address) + + delete(i.unicast) + delete(i.multicast) + delete(i.anycast) + delete(i.gateways) + } + delete(interfaces, allocator) +} + +/* + Turns a slice of bytes (from e.g. `get_adapters_addresses`) into a "XX:XX:XX:..." string. +*/ +physical_address_to_string :: proc(phy_addr: []u8, allocator := context.allocator) -> (phy_string: string) { + context.allocator = allocator + + MAC_HEX := "0123456789ABCDEF" + + if len(phy_addr) == 0 { + return "" + } + + buf: strings.Builder + + for b, i in phy_addr { + if i > 0 { + strings.write_rune(&buf, ':') + } + + hi := rune(MAC_HEX[b >> 4]) + lo := rune(MAC_HEX[b & 15]) + strings.write_rune(&buf, hi) + strings.write_rune(&buf, lo) + } + return strings.to_string(buf) +} diff --git a/core/net/interface_darwin.odin b/core/net/interface_darwin.odin new file mode 100644 index 000000000..90d996a4a --- /dev/null +++ b/core/net/interface_darwin.odin @@ -0,0 +1,32 @@ +package net +//+build darwin + +/* + Package net implements cross-platform Berkeley Sockets, DNS resolution and associated procedures. + For other protocols and their features, see subdirectories of this package. +*/ + +/* + Copyright 2022 Tetralux + Copyright 2022 Colin Davidson + Copyright 2022 Jeroen van Rijn . + Made available under Odin's BSD-3 license. + + List of contributors: + Tetralux: Initial implementation + Colin Davidson: Linux platform code, OSX platform code, Odin-native DNS resolver + Jeroen van Rijn: Cross platform unification, code style, documentation + +*/ + +@(private) +_enumerate_interfaces :: proc(allocator := context.allocator) -> (interfaces: []Network_Interface, err: Network_Error) { + context.allocator = allocator + + + // TODO: Implement. Can probably use the (current) Linux implementation, + // which will itself be switched over to talking to the kernel via NETLINK protocol + // once we have raw sockets. + + unimplemented() +} \ No newline at end of file diff --git a/core/net/interface_linux.odin b/core/net/interface_linux.odin new file mode 100644 index 000000000..e889cfa97 --- /dev/null +++ b/core/net/interface_linux.odin @@ -0,0 +1,140 @@ +package net +//+build linux + +/* + Package net implements cross-platform Berkeley Sockets, DNS resolution and associated procedures. + For other protocols and their features, see subdirectories of this package. +*/ + +/* + Copyright 2022 Tetralux + Copyright 2022 Colin Davidson + Copyright 2022 Jeroen van Rijn . + Made available under Odin's BSD-3 license. + + List of contributors: + Tetralux: Initial implementation + Colin Davidson: Linux platform code, OSX platform code, Odin-native DNS resolver + Jeroen van Rijn: Cross platform unification, code style, documentation + + This file uses `getifaddrs` libc call to enumerate interfaces. + TODO: When we have raw sockets, split off into its own file for Linux so we can use the NETLINK protocol and bypass libc. +*/ + +import "core:os" +import "core:strings" + +@(private) +_enumerate_interfaces :: proc(allocator := context.allocator) -> (interfaces: []Network_Interface, err: Network_Error) { + context.allocator = allocator + + head: ^os.ifaddrs + + if res := os._getifaddrs(&head); res < 0 { + return {}, .Unable_To_Enumerate_Network_Interfaces + } + + /* + Unlike Windows, *nix regrettably doesn't return all it knows about an interface in one big struct. + We're going to have to iterate over a list and coalesce information as we go. + */ + ifaces: map[string]^Network_Interface + defer delete(ifaces) + + for ifaddr := head; ifaddr != nil; ifaddr = ifaddr.next { + adapter_name := string(ifaddr.name) + + /* + Check if we have seen this interface name before so we can reuse the `Network_Interface`. + Else, create a new one. + */ + if adapter_name not_in ifaces { + ifaces[adapter_name] = new(Network_Interface) + ifaces[adapter_name].adapter_name = strings.clone(adapter_name) + } + iface := ifaces[adapter_name] + + address: Address + netmask: Netmask + + if ifaddr.address != nil { + switch int(ifaddr.address.sa_family) { + case os.AF_INET, os.AF_INET6: + address = _sockaddr_basic_to_endpoint(ifaddr.address).address + + case os.AF_PACKET: + /* + For some obscure reason the 64-bit `getifaddrs` call returns a pointer to a + 32-bit `RTNL_LINK_STATS` structure, which of course means that tx/rx byte count + is truncated beyond usefulness. + + We're not going to retrieve stats now. Instead this serves as a reminder to use + the NETLINK protocol for this purpose. + + But in case you were curious: + stats := transmute(^os.rtnl_link_stats)ifaddr.data + fmt.println(stats) + */ + case: + } + } + + if ifaddr.netmask != nil { + switch int(ifaddr.netmask.sa_family) { + case os.AF_INET, os.AF_INET6: + netmask = Netmask(_sockaddr_basic_to_endpoint(ifaddr.netmask).address) + case: + } + } + + if ifaddr.broadcast_or_dest != nil && .BROADCAST in ifaddr.flags { + switch int(ifaddr.broadcast_or_dest.sa_family) { + case os.AF_INET, os.AF_INET6: + broadcast := _sockaddr_basic_to_endpoint(ifaddr.broadcast_or_dest).address + append(&iface.multicast, broadcast) + case: + } + } + + if address != nil { + lease := Lease{ + address = address, + netmask = netmask, + } + append(&iface.unicast, lease) + } + + /* + TODO: Refine this based on the type of adapter. + */ + state := Link_State{} + + if .UP in ifaddr.flags { + state |= {.Up} + } + + if .DORMANT in ifaddr.flags { + state |= {.Dormant} + } + + if .LOOPBACK in ifaddr.flags { + state |= {.Loopback} + } + iface.link.state = state + } + + /* + Free the OS structures. + */ + os._freeifaddrs(head) + + /* + Turn the map into a slice to return. + */ + _interfaces := make([dynamic]Network_Interface, 0, allocator) + for _, iface in ifaces { + append(&_interfaces, iface^) + free(iface) + } + return _interfaces[:], {} +} \ No newline at end of file diff --git a/core/net/interface_windows.odin b/core/net/interface_windows.odin new file mode 100644 index 000000000..f8bac253a --- /dev/null +++ b/core/net/interface_windows.odin @@ -0,0 +1,177 @@ +package net +//+build windows + +/* + Package net implements cross-platform Berkeley Sockets, DNS resolution and associated procedures. + For other protocols and their features, see subdirectories of this package. +*/ + +/* + Copyright 2022 Tetralux + Copyright 2022 Colin Davidson + Copyright 2022 Jeroen van Rijn . + Made available under Odin's BSD-3 license. + + List of contributors: + Tetralux: Initial implementation + Colin Davidson: Linux platform code, OSX platform code, Odin-native DNS resolver + Jeroen van Rijn: Cross platform unification, code style, documentation +*/ + +import sys "core:sys/windows" +import strings "core:strings" + +_enumerate_interfaces :: proc(allocator := context.allocator) -> (interfaces: []Network_Interface, err: Network_Error) { + context.allocator = allocator + + buf: []u8 + defer delete(buf) + + buf_size: u32 + res: u32 + + gaa: for _ in 1..=MAX_INTERFACE_ENUMERATION_TRIES { + res = sys.get_adapters_addresses( + .Unspecified, // Return both IPv4 and IPv6 adapters. + sys.GAA_Flags{ + .Include_Prefix, // (XP SP1+) Return a list of IP address prefixes on this adapter. When this flag is set, IP address prefixes are returned for both IPv6 and IPv4 addresses. + .Include_Gateways, // (Vista+) Return the addresses of default gateways. + .Include_Tunnel_Binding_Order, // (Vista+) Return the adapter addresses sorted in tunnel binding order. + }, + nil, // Reserved + (^sys.IP_Adapter_Addresses)(raw_data(buf)), + &buf_size, + ) + + switch res { + case 111: // ERROR_BUFFER_OVERFLOW: + delete(buf) + buf = make([]u8, buf_size) + case 0: + break gaa + case: + return {}, Platform_Error(res) + } + } + + if res != 0 { + return {}, .Unable_To_Enumerate_Network_Interfaces + } + + _interfaces := make([dynamic]Network_Interface, 0, allocator) + for adapter := (^sys.IP_Adapter_Addresses)(raw_data(buf)); adapter != nil; adapter = adapter.Next { + friendly_name, err1 := sys.wstring_to_utf8(sys.wstring(adapter.FriendlyName), 256, allocator) + if err1 != nil { return {}, Platform_Error(err1) } + + description, err2 := sys.wstring_to_utf8(sys.wstring(adapter.Description), 256, allocator) + if err2 != nil { return {}, Platform_Error(err2) } + + dns_suffix, err3 := sys.wstring_to_utf8(sys.wstring(adapter.DnsSuffix), 256, allocator) + if err3 != nil { return {}, Platform_Error(err3) } + + interface := Network_Interface{ + adapter_name = strings.clone(string(adapter.AdapterName)), + friendly_name = friendly_name, + description = description, + dns_suffix = dns_suffix, + + mtu = adapter.MTU, + + link = { + transmit_speed = adapter.TransmitLinkSpeed, + receive_speed = adapter.ReceiveLinkSpeed, + }, + } + + if adapter.PhysicalAddressLength > 0 && adapter.PhysicalAddressLength <= len(adapter.PhysicalAddress) { + interface.physical_address = physical_address_to_string(adapter.PhysicalAddress[:adapter.PhysicalAddressLength]) + } + + for u_addr := (^sys.IP_ADAPTER_UNICAST_ADDRESS_LH)(adapter.FirstUnicastAddress); u_addr != nil; u_addr = u_addr.Next { + win_addr := parse_socket_address(u_addr.Address) + + lease := Lease{ + address = win_addr.address, + origin = { + prefix = Prefix_Origin(u_addr.PrefixOrigin), + suffix = Suffix_Origin(u_addr.SuffixOrigin), + }, + lifetime = { + valid = u_addr.ValidLifetime, + preferred = u_addr.PreferredLifetime, + lease = u_addr.LeaseLifetime, + }, + address_duplication = Address_Duplication(u_addr.DadState), + } + append(&interface.unicast, lease) + } + + for a_addr := (^sys.IP_ADAPTER_ANYCAST_ADDRESS_XP)(adapter.FirstAnycastAddress); a_addr != nil; a_addr = a_addr.Next { + addr := parse_socket_address(a_addr.Address) + append(&interface.anycast, addr.address) + } + + for m_addr := (^sys.IP_ADAPTER_MULTICAST_ADDRESS_XP)(adapter.FirstMulticastAddress); m_addr != nil; m_addr = m_addr.Next { + addr := parse_socket_address(m_addr.Address) + append(&interface.multicast, addr.address) + } + + for g_addr := (^sys.IP_ADAPTER_GATEWAY_ADDRESS_LH)(adapter.FirstGatewayAddress); g_addr != nil; g_addr = g_addr.Next { + addr := parse_socket_address(g_addr.Address) + append(&interface.gateways, addr.address) + } + + interface.dhcp_v4 = parse_socket_address(adapter.Dhcpv4Server).address + interface.dhcp_v6 = parse_socket_address(adapter.Dhcpv6Server).address + + switch adapter.OperStatus { + case .Up: interface.link.state = {.Up} + case .Down: interface.link.state = {.Down} + case .Testing: interface.link.state = {.Testing} + case .Dormant: interface.link.state = {.Dormant} + case .NotPresent: interface.link.state = {.Not_Present} + case .LowerLayerDown: interface.link.state = {.Lower_Layer_Down} + case .Unknown: fallthrough + case: interface.link.state = {} + } + + interface.tunnel_type = Tunnel_Type(adapter.TunnelType) + + append(&_interfaces, interface) + } + + return _interfaces[:], {} +} + +/* + Interpret SOCKET_ADDRESS as an Address +*/ +parse_socket_address :: proc(addr_in: sys.SOCKET_ADDRESS) -> (addr: Endpoint) { + if addr_in.lpSockaddr == nil { + return // Empty or invalid address type + } + + sock := addr_in.lpSockaddr^ + + switch sock.sa_family { + case u16(sys.AF_INET): + win_addr := cast(^sys.sockaddr_in)addr_in.lpSockaddr + port := int(win_addr.sin_port) + return Endpoint { + address = IP4_Address(transmute([4]byte)win_addr.sin_addr), + port = port, + } + + case u16(sys.AF_INET6): + win_addr := cast(^sys.sockaddr_in6)addr_in.lpSockaddr + port := int(win_addr.sin6_port) + return Endpoint { + address = IP6_Address(transmute([8]u16be)win_addr.sin6_addr), + port = port, + } + + + case: return // Empty or invalid address type + } + unreachable() +} \ No newline at end of file diff --git a/core/net/socket.odin b/core/net/socket.odin new file mode 100644 index 000000000..8cdf7cceb --- /dev/null +++ b/core/net/socket.odin @@ -0,0 +1,183 @@ +// +build windows, linux, darwin +package net + +/* + Package net implements cross-platform Berkeley Sockets, DNS resolution and associated procedures. + For other protocols and their features, see subdirectories of this package. +*/ + +/* + Copyright 2022-2023 Tetralux + Copyright 2022-2023 Colin Davidson + Copyright 2022-2023 Jeroen van Rijn . + Made available under Odin's BSD-3 license. + + List of contributors: + Tetralux: Initial implementation + Colin Davidson: Linux platform code, OSX platform code, Odin-native DNS resolver + Jeroen van Rijn: Cross platform unification, code style, documentation +*/ + +any_socket_to_socket :: proc(socket: Any_Socket) -> Socket { + switch s in socket { + case TCP_Socket: return Socket(s) + case UDP_Socket: return Socket(s) + case: + // TODO(tetra): Bluetooth, Raw + return Socket({}) + } +} + +/* + Expects both hostname and port to be present in the `hostname_and_port` parameter, either as: + `a.host.name:9999`, or as `1.2.3.4:9999`, or IP6 equivalent. + + Calls `parse_hostname_or_endpoint` and `resolve`, then `dial_tcp_from_endpoint`. +*/ +dial_tcp_from_hostname_and_port_string :: proc(hostname_and_port: string, options := default_tcp_options) -> (socket: TCP_Socket, err: Network_Error) { + target := parse_hostname_or_endpoint(hostname_and_port) or_return + switch t in target { + case Endpoint: + return dial_tcp_from_endpoint(t, options) + case Host: + if t.port == 0 { + return 0, .Port_Required + } + ep4, ep6 := resolve(t.hostname) or_return + ep := ep4 if ep4.address != nil else ep6 // NOTE(tetra): We don't know what family the server uses, so we just default to IP4. + ep.port = t.port + return dial_tcp_from_endpoint(ep, options) + } + unreachable() +} + +/* + Expects the `hostname` as a string and `port` as a `int`. + `parse_hostname_or_endpoint` is called and the `hostname` will be resolved into an IP. + + If a `hostname` of form `a.host.name:9999` is given, the port will be ignored in favor of the explicit `port` param. +*/ +dial_tcp_from_hostname_with_port_override :: proc(hostname: string, port: int, options := default_tcp_options) -> (socket: TCP_Socket, err: Network_Error) { + target := parse_hostname_or_endpoint(hostname) or_return + switch t in target { + case Endpoint: + return dial_tcp_from_endpoint({t.address, port}, options) + case Host: + if port == 0 { + return 0, .Port_Required + } + ep4, ep6 := resolve(t.hostname) or_return + ep := ep4 if ep4.address != nil else ep6 // NOTE(tetra): We don't know what family the server uses, so we just default to IP4. + ep.port = port + return dial_tcp_from_endpoint(ep, options) + } + unreachable() +} + +// Dial from an Address +dial_tcp_from_address_and_port :: proc(address: Address, port: int, options := default_tcp_options) -> (socket: TCP_Socket, err: Network_Error) { + return dial_tcp_from_endpoint({address, port}, options) +} + +dial_tcp_from_endpoint :: proc(endpoint: Endpoint, options := default_tcp_options) -> (socket: TCP_Socket, err: Network_Error) { + return _dial_tcp_from_endpoint(endpoint, options) +} + +dial_tcp :: proc{ + dial_tcp_from_endpoint, + dial_tcp_from_address_and_port, + dial_tcp_from_hostname_and_port_string, + dial_tcp_from_hostname_with_port_override, +} + +create_socket :: proc(family: Address_Family, protocol: Socket_Protocol) -> (socket: Any_Socket, err: Network_Error) { + return _create_socket(family, protocol) +} + +bind :: proc(socket: Any_Socket, ep: Endpoint) -> (err: Network_Error) { + return _bind(socket, ep) +} + +/* + This type of socket becomes bound when you try to send data. + It is likely what you want if you want to send data unsolicited. + + This is like a client TCP socket, except that it can send data to any remote endpoint without needing to establish a connection first. +*/ +make_unbound_udp_socket :: proc(family: Address_Family) -> (socket: UDP_Socket, err: Network_Error) { + sock := create_socket(family, .UDP) or_return + socket = sock.(UDP_Socket) + return +} + +/* + This type of socket is bound immediately, which enables it to receive data on the port. + Since it's UDP, it's also able to send data without receiving any first. + + This is like a listening TCP socket, except that data packets can be sent and received without needing to establish a connection first. + The `bound_address` is the address of the network interface that you want to use, or a loopback address if you don't care which to use. +*/ +make_bound_udp_socket :: proc(bound_address: Address, port: int) -> (socket: UDP_Socket, err: Network_Error) { + if bound_address == nil { + return {}, .Bad_Address + } + socket = make_unbound_udp_socket(family_from_address(bound_address)) or_return + bind(socket, {bound_address, port}) or_return + return +} + +listen_tcp :: proc(interface_endpoint: Endpoint, backlog := 1000) -> (socket: TCP_Socket, err: Network_Error) { + assert(backlog > 0 && backlog < int(max(i32))) + + return _listen_tcp(interface_endpoint, backlog) +} + +accept_tcp :: proc(socket: TCP_Socket, options := default_tcp_options) -> (client: TCP_Socket, source: Endpoint, err: Network_Error) { + return _accept_tcp(socket, options) +} + +close :: proc(socket: Any_Socket) { + _close(socket) +} + +recv_tcp :: proc(socket: TCP_Socket, buf: []byte) -> (bytes_read: int, err: Network_Error) { + return _recv_tcp(socket, buf) +} + +recv_udp :: proc(socket: UDP_Socket, buf: []byte) -> (bytes_read: int, remote_endpoint: Endpoint, err: Network_Error) { + return _recv_udp(socket, buf) +} + +recv :: proc{recv_tcp, recv_udp} + +/* + Repeatedly sends data until the entire buffer is sent. + If a send fails before all data is sent, returns the amount sent up to that point. +*/ +send_tcp :: proc(socket: TCP_Socket, buf: []byte) -> (bytes_written: int, err: Network_Error) { + return _send_tcp(socket, buf) +} + +/* + Sends a single UDP datagram packet. + + Datagrams are limited in size; attempting to send more than this limit at once will result in a Message_Too_Long error. + UDP packets are not guarenteed to be received in order. +*/ +send_udp :: proc(socket: UDP_Socket, buf: []byte, to: Endpoint) -> (bytes_written: int, err: Network_Error) { + return _send_udp(socket, buf, to) +} + +send :: proc{send_tcp, send_udp} + +shutdown :: proc(socket: Any_Socket, manner: Shutdown_Manner) -> (err: Network_Error) { + return _shutdown(socket, manner) +} + +set_option :: proc(socket: Any_Socket, option: Socket_Option, value: any, loc := #caller_location) -> Network_Error { + return _set_option(socket, option, value, loc) +} + +set_blocking :: proc(socket: Any_Socket, should_block: bool) -> (err: Network_Error) { + return _set_blocking(socket, should_block) +} \ No newline at end of file diff --git a/core/net/socket_darwin.odin b/core/net/socket_darwin.odin new file mode 100644 index 000000000..081892afd --- /dev/null +++ b/core/net/socket_darwin.odin @@ -0,0 +1,371 @@ +package net +// +build darwin + +/* + Package net implements cross-platform Berkeley Sockets, DNS resolution and associated procedures. + For other protocols and their features, see subdirectories of this package. +*/ + +/* + Copyright 2022 Tetralux + Copyright 2022 Colin Davidson + Copyright 2022 Jeroen van Rijn . + Made available under Odin's BSD-3 license. + + List of contributors: + Tetralux: Initial implementation + Colin Davidson: Linux platform code, OSX platform code, Odin-native DNS resolver + Jeroen van Rijn: Cross platform unification, code style, documentation +*/ + +import "core:c" +import "core:os" +import "core:time" + +Socket_Option :: enum c.int { + Reuse_Address = c.int(os.SO_REUSEADDR), + Keep_Alive = c.int(os.SO_KEEPALIVE), + Out_Of_Bounds_Data_Inline = c.int(os.SO_OOBINLINE), + TCP_Nodelay = c.int(os.TCP_NODELAY), + Linger = c.int(os.SO_LINGER), + Receive_Buffer_Size = c.int(os.SO_RCVBUF), + Send_Buffer_Size = c.int(os.SO_SNDBUF), + Receive_Timeout = c.int(os.SO_RCVTIMEO), + Send_Timeout = c.int(os.SO_SNDTIMEO), +} + +@(private) +_create_socket :: proc(family: Address_Family, protocol: Socket_Protocol) -> (socket: Any_Socket, err: Network_Error) { + c_type, c_protocol, c_family: int + + switch family { + case .IP4: c_family = os.AF_INET + case .IP6: c_family = os.AF_INET6 + case: + unreachable() + } + + switch protocol { + case .TCP: c_type = os.SOCK_STREAM; c_protocol = os.IPPROTO_TCP + case .UDP: c_type = os.SOCK_DGRAM; c_protocol = os.IPPROTO_UDP + case: + unreachable() + } + + sock, ok := os.socket(c_family, c_type, c_protocol) + if ok != os.ERROR_NONE { + err = Create_Socket_Error(ok) + return + } + + switch protocol { + case .TCP: return TCP_Socket(sock), nil + case .UDP: return UDP_Socket(sock), nil + case: + unreachable() + } +} + +@(private) +_dial_tcp_from_endpoint :: proc(endpoint: Endpoint, options := default_tcp_options) -> (skt: TCP_Socket, err: Network_Error) { + if endpoint.port == 0 { + return 0, .Port_Required + } + + family := family_from_endpoint(endpoint) + sock := create_socket(family, .TCP) or_return + skt = sock.(TCP_Socket) + + // NOTE(tetra): This is so that if we crash while the socket is open, we can + // bypass the cooldown period, and allow the next run of the program to + // use the same address immediately. + _ = set_option(skt, .Reuse_Address, true) + + sockaddr := _endpoint_to_sockaddr(endpoint) + res := os.connect(os.Socket(skt), (^os.SOCKADDR)(&sockaddr), i32(sockaddr.len)) + if res != os.ERROR_NONE { + err = Dial_Error(res) + return + } + + return +} + +@(private) +_bind :: proc(skt: Any_Socket, ep: Endpoint) -> (err: Network_Error) { + sockaddr := _endpoint_to_sockaddr(ep) + s := any_socket_to_socket(skt) + res := os.bind(os.Socket(s), (^os.SOCKADDR)(&sockaddr), i32(sockaddr.len)) + if res != os.ERROR_NONE { + err = Bind_Error(res) + } + return +} + +@(private) +_listen_tcp :: proc(interface_endpoint: Endpoint, backlog := 1000) -> (skt: TCP_Socket, err: Network_Error) { + assert(backlog > 0 && i32(backlog) < max(i32)) + + family := family_from_endpoint(interface_endpoint) + sock := create_socket(family, .TCP) or_return + skt = sock.(TCP_Socket) + + // NOTE(tetra): This is so that if we crash while the socket is open, we can + // bypass the cooldown period, and allow the next run of the program to + // use the same address immediately. + // + // TODO(tetra, 2022-02-15): Confirm that this doesn't mean other processes can hijack the address! + set_option(sock, .Reuse_Address, true) or_return + + bind(sock, interface_endpoint) or_return + + res := os.listen(os.Socket(skt), backlog) + if res != os.ERROR_NONE { + err = Listen_Error(res) + return + } + + return +} + +@(private) +_accept_tcp :: proc(sock: TCP_Socket, options := default_tcp_options) -> (client: TCP_Socket, source: Endpoint, err: Network_Error) { + sockaddr: os.SOCKADDR_STORAGE_LH + sockaddrlen := c.int(size_of(sockaddr)) + + client_sock, ok := os.accept(os.Socket(sock), cast(^os.SOCKADDR) &sockaddr, &sockaddrlen) + if ok != os.ERROR_NONE { + err = Accept_Error(ok) + return + } + client = TCP_Socket(client_sock) + source = _sockaddr_to_endpoint(&sockaddr) + return +} + +@(private) +_close :: proc(skt: Any_Socket) { + s := any_socket_to_socket(skt) + os.close(os.Handle(os.Socket(s))) +} + +@(private) +_recv_tcp :: proc(skt: TCP_Socket, buf: []byte) -> (bytes_read: int, err: Network_Error) { + if len(buf) <= 0 { + return + } + res, ok := os.recv(os.Socket(skt), buf, 0) + if ok != os.ERROR_NONE { + err = TCP_Recv_Error(ok) + return + } + return int(res), nil +} + +@(private) +_recv_udp :: proc(skt: UDP_Socket, buf: []byte) -> (bytes_read: int, remote_endpoint: Endpoint, err: Network_Error) { + if len(buf) <= 0 { + return + } + + from: os.SOCKADDR_STORAGE_LH + fromsize := c.int(size_of(from)) + res, ok := os.recvfrom(os.Socket(skt), buf, 0, cast(^os.SOCKADDR) &from, &fromsize) + if ok != os.ERROR_NONE { + err = UDP_Recv_Error(ok) + return + } + + bytes_read = int(res) + remote_endpoint = _sockaddr_to_endpoint(&from) + return +} + +@(private) +_send_tcp :: proc(skt: TCP_Socket, buf: []byte) -> (bytes_written: int, err: Network_Error) { + for bytes_written < len(buf) { + limit := min(int(max(i32)), len(buf) - bytes_written) + remaining := buf[bytes_written:][:limit] + res, ok := os.send(os.Socket(skt), remaining, 0) + if ok != os.ERROR_NONE { + err = TCP_Send_Error(ok) + return + } + bytes_written += int(res) + } + return +} + +@(private) +_send_udp :: proc(skt: UDP_Socket, buf: []byte, to: Endpoint) -> (bytes_written: int, err: Network_Error) { + toaddr := _endpoint_to_sockaddr(to) + for bytes_written < len(buf) { + limit := min(1<<31, len(buf) - bytes_written) + remaining := buf[bytes_written:][:limit] + res, ok := os.sendto(os.Socket(skt), remaining, 0, cast(^os.SOCKADDR)&toaddr, i32(toaddr.len)) + if ok != os.ERROR_NONE { + err = UDP_Send_Error(ok) + return + } + bytes_written += int(res) + } + return +} + +@(private) +_shutdown :: proc(skt: Any_Socket, manner: Shutdown_Manner) -> (err: Network_Error) { + s := any_socket_to_socket(skt) + res := os.shutdown(os.Socket(s), int(manner)) + if res != os.ERROR_NONE { + return Shutdown_Error(res) + } + return +} + +@(private) +_set_option :: proc(s: Any_Socket, option: Socket_Option, value: any, loc := #caller_location) -> Network_Error { + level := os.SOL_SOCKET if option != .TCP_Nodelay else os.IPPROTO_TCP + + // NOTE(tetra, 2022-02-15): On Linux, you cannot merely give a single byte for a bool; + // it _has_ to be a b32. + // I haven't tested if you can give more than that. + bool_value: b32 + int_value: i32 + timeval_value: os.Timeval + + ptr: rawptr + len: os.socklen_t + + switch option { + case + .Reuse_Address, + .Keep_Alive, + .Out_Of_Bounds_Data_Inline, + .TCP_Nodelay: + // TODO: verify whether these are options or not on Linux + // .Broadcast, + // .Conditional_Accept, + // .Dont_Linger: + switch x in value { + case bool, b8: + x2 := x + bool_value = b32((^bool)(&x2)^) + case b16: + bool_value = b32(x) + case b32: + bool_value = b32(x) + case b64: + bool_value = b32(x) + case: + panic("set_option() value must be a boolean here", loc) + } + ptr = &bool_value + len = size_of(bool_value) + case + .Linger, + .Send_Timeout, + .Receive_Timeout: + t, ok := value.(time.Duration) + if !ok do panic("set_option() value must be a time.Duration here", loc) + + micros := i64(time.duration_microseconds(t)) + timeval_value.microseconds = int(micros % 1e6) + timeval_value.seconds = (micros - i64(timeval_value.microseconds)) / 1e6 + + ptr = &timeval_value + len = size_of(timeval_value) + case + .Receive_Buffer_Size, + .Send_Buffer_Size: + // TODO: check for out of range values and return .Value_Out_Of_Range? + switch i in value { + case i8, u8: i2 := i; int_value = os.socklen_t((^u8)(&i2)^) + case i16, u16: i2 := i; int_value = os.socklen_t((^u16)(&i2)^) + case i32, u32: i2 := i; int_value = os.socklen_t((^u32)(&i2)^) + case i64, u64: i2 := i; int_value = os.socklen_t((^u64)(&i2)^) + case i128, u128: i2 := i; int_value = os.socklen_t((^u128)(&i2)^) + case int, uint: i2 := i; int_value = os.socklen_t((^uint)(&i2)^) + case: + panic("set_option() value must be an integer here", loc) + } + ptr = &int_value + len = size_of(int_value) + } + + skt := any_socket_to_socket(s) + res := os.setsockopt(os.Socket(skt), int(level), int(option), ptr, len) + if res != os.ERROR_NONE { + return Socket_Option_Error(res) + } + + return nil +} + +@(private) +_set_blocking :: proc(socket: Any_Socket, should_block: bool) -> (err: Network_Error) { + socket := any_socket_to_socket(socket) + + flags, getfl_err := os.fcntl(int(socket), os.F_GETFL, 0) + if getfl_err != os.ERROR_NONE { + return Set_Blocking_Error(getfl_err) + } + + if should_block { + flags &= ~int(os.O_NONBLOCK) + } else { + flags |= int(os.O_NONBLOCK) + } + + _, setfl_err := os.fcntl(int(socket), os.F_SETFL, flags) + if setfl_err != os.ERROR_NONE { + return Set_Blocking_Error(setfl_err) + } + + return nil +} + +@private +_endpoint_to_sockaddr :: proc(ep: Endpoint) -> (sockaddr: os.SOCKADDR_STORAGE_LH) { + switch a in ep.address { + case IP4_Address: + (^os.sockaddr_in)(&sockaddr)^ = os.sockaddr_in { + sin_port = u16be(ep.port), + sin_addr = transmute(os.in_addr) a, + sin_family = u8(os.AF_INET), + sin_len = size_of(os.sockaddr_in), + } + return + case IP6_Address: + (^os.sockaddr_in6)(&sockaddr)^ = os.sockaddr_in6 { + sin6_port = u16be(ep.port), + sin6_addr = transmute(os.in6_addr) a, + sin6_family = u8(os.AF_INET6), + sin6_len = size_of(os.sockaddr_in6), + } + return + } + unreachable() +} + +@private +_sockaddr_to_endpoint :: proc(native_addr: ^os.SOCKADDR_STORAGE_LH) -> (ep: Endpoint) { + switch native_addr.family { + case u8(os.AF_INET): + addr := cast(^os.sockaddr_in) native_addr + port := int(addr.sin_port) + ep = Endpoint { + address = IP4_Address(transmute([4]byte) addr.sin_addr), + port = port, + } + case u8(os.AF_INET6): + addr := cast(^os.sockaddr_in6) native_addr + port := int(addr.sin6_port) + ep = Endpoint { + address = IP6_Address(transmute([8]u16be) addr.sin6_addr), + port = port, + } + case: + panic("native_addr is neither IP4 or IP6 address") + } + return +} diff --git a/core/net/socket_linux.odin b/core/net/socket_linux.odin new file mode 100644 index 000000000..b7141e8ba --- /dev/null +++ b/core/net/socket_linux.odin @@ -0,0 +1,407 @@ +package net +// +build linux + +/* + Package net implements cross-platform Berkeley Sockets, DNS resolution and associated procedures. + For other protocols and their features, see subdirectories of this package. +*/ + +/* + Copyright 2022 Tetralux + Copyright 2022 Colin Davidson + Copyright 2022 Jeroen van Rijn . + Made available under Odin's BSD-3 license. + + List of contributors: + Tetralux: Initial implementation + Colin Davidson: Linux platform code, OSX platform code, Odin-native DNS resolver + Jeroen van Rijn: Cross platform unification, code style, documentation +*/ + +import "core:c" +import "core:os" +import "core:time" + +Socket_Option :: enum c.int { + Reuse_Address = c.int(os.SO_REUSEADDR), + Keep_Alive = c.int(os.SO_KEEPALIVE), + Out_Of_Bounds_Data_Inline = c.int(os.SO_OOBINLINE), + TCP_Nodelay = c.int(os.TCP_NODELAY), + Linger = c.int(os.SO_LINGER), + Receive_Buffer_Size = c.int(os.SO_RCVBUF), + Send_Buffer_Size = c.int(os.SO_SNDBUF), + Receive_Timeout = c.int(os.SO_RCVTIMEO_NEW), + Send_Timeout = c.int(os.SO_SNDTIMEO_NEW), +} + +@(private) +_create_socket :: proc(family: Address_Family, protocol: Socket_Protocol) -> (socket: Any_Socket, err: Network_Error) { + c_type, c_protocol, c_family: int + + switch family { + case .IP4: c_family = os.AF_INET + case .IP6: c_family = os.AF_INET6 + case: + unreachable() + } + + switch protocol { + case .TCP: c_type = os.SOCK_STREAM; c_protocol = os.IPPROTO_TCP + case .UDP: c_type = os.SOCK_DGRAM; c_protocol = os.IPPROTO_UDP + case: + unreachable() + } + + sock, ok := os.socket(c_family, c_type, c_protocol) + if ok != os.ERROR_NONE { + err = Create_Socket_Error(ok) + return + } + + switch protocol { + case .TCP: return TCP_Socket(sock), nil + case .UDP: return UDP_Socket(sock), nil + case: + unreachable() + } +} + +@(private) +_dial_tcp_from_endpoint :: proc(endpoint: Endpoint, options := default_tcp_options) -> (skt: TCP_Socket, err: Network_Error) { + if endpoint.port == 0 { + return 0, .Port_Required + } + + family := family_from_endpoint(endpoint) + sock := create_socket(family, .TCP) or_return + skt = sock.(TCP_Socket) + + // NOTE(tetra): This is so that if we crash while the socket is open, we can + // bypass the cooldown period, and allow the next run of the program to + // use the same address immediately. + _ = set_option(skt, .Reuse_Address, true) + + sockaddr := _endpoint_to_sockaddr(endpoint) + res := os.connect(os.Socket(skt), (^os.SOCKADDR)(&sockaddr), size_of(sockaddr)) + if res != os.ERROR_NONE { + err = Dial_Error(res) + return + } + + if options.no_delay { + _ = _set_option(sock, .TCP_Nodelay, true) // NOTE(tetra): Not vital to succeed; error ignored + } + + return +} + +@(private) +_bind :: proc(skt: Any_Socket, ep: Endpoint) -> (err: Network_Error) { + sockaddr := _endpoint_to_sockaddr(ep) + s := any_socket_to_socket(skt) + res := os.bind(os.Socket(s), (^os.SOCKADDR)(&sockaddr), size_of(sockaddr)) + if res != os.ERROR_NONE { + err = Bind_Error(res) + } + return +} + +@(private) +_listen_tcp :: proc(interface_endpoint: Endpoint, backlog := 1000) -> (skt: TCP_Socket, err: Network_Error) { + assert(backlog > 0 && i32(backlog) < max(i32)) + + family := family_from_endpoint(interface_endpoint) + sock := create_socket(family, .TCP) or_return + skt = sock.(TCP_Socket) + + // NOTE(tetra): This is so that if we crash while the socket is open, we can + // bypass the cooldown period, and allow the next run of the program to + // use the same address immediately. + // + // TODO(tetra, 2022-02-15): Confirm that this doesn't mean other processes can hijack the address! + set_option(sock, .Reuse_Address, true) or_return + + bind(sock, interface_endpoint) or_return + + res := os.listen(os.Socket(skt), backlog) + if res != os.ERROR_NONE { + err = Listen_Error(res) + return + } + + return +} + +@(private) +_accept_tcp :: proc(sock: TCP_Socket, options := default_tcp_options) -> (client: TCP_Socket, source: Endpoint, err: Network_Error) { + sockaddr: os.SOCKADDR_STORAGE_LH + sockaddrlen := c.int(size_of(sockaddr)) + + client_sock, ok := os.accept(os.Socket(sock), cast(^os.SOCKADDR) &sockaddr, &sockaddrlen) + if ok != os.ERROR_NONE { + err = Accept_Error(ok) + return + } + client = TCP_Socket(client_sock) + source = _sockaddr_storage_to_endpoint(&sockaddr) + if options.no_delay { + _ = _set_option(client, .TCP_Nodelay, true) // NOTE(tetra): Not vital to succeed; error ignored + } + return +} + +@(private) +_close :: proc(skt: Any_Socket) { + s := any_socket_to_socket(skt) + os.close(os.Handle(os.Socket(s))) +} + +@(private) +_recv_tcp :: proc(skt: TCP_Socket, buf: []byte) -> (bytes_read: int, err: Network_Error) { + if len(buf) <= 0 { + return + } + res, ok := os.recv(os.Socket(skt), buf, 0) + if ok != os.ERROR_NONE { + err = TCP_Recv_Error(ok) + return + } + return int(res), nil +} + +@(private) +_recv_udp :: proc(skt: UDP_Socket, buf: []byte) -> (bytes_read: int, remote_endpoint: Endpoint, err: Network_Error) { + if len(buf) <= 0 { + return + } + + from: os.SOCKADDR_STORAGE_LH = --- + fromsize := c.int(size_of(from)) + + // NOTE(tetra): On Linux, if the buffer is too small to fit the entire datagram payload, the rest is silently discarded, + // and no error is returned. + // However, if you pass MSG_TRUNC here, 'res' will be the size of the incoming message, rather than how much was read. + // We can use this fact to detect this condition and return .Buffer_Too_Small. + res, ok := os.recvfrom(os.Socket(skt), buf, os.MSG_TRUNC, cast(^os.SOCKADDR) &from, &fromsize) + if ok != os.ERROR_NONE { + err = UDP_Recv_Error(ok) + return + } + + bytes_read = int(res) + remote_endpoint = _sockaddr_storage_to_endpoint(&from) + + if bytes_read > len(buf) { + // NOTE(tetra): The buffer has been filled, with a partial message. + bytes_read = len(buf) + err = .Buffer_Too_Small + } + + return +} + +@(private) +_send_tcp :: proc(skt: TCP_Socket, buf: []byte) -> (bytes_written: int, err: Network_Error) { + for bytes_written < len(buf) { + limit := min(int(max(i32)), len(buf) - bytes_written) + remaining := buf[bytes_written:][:limit] + res, ok := os.send(os.Socket(skt), remaining, 0) + if ok != os.ERROR_NONE { + err = TCP_Send_Error(ok) + return + } + bytes_written += int(res) + } + return +} + +@(private) +_send_udp :: proc(skt: UDP_Socket, buf: []byte, to: Endpoint) -> (bytes_written: int, err: Network_Error) { + toaddr := _endpoint_to_sockaddr(to) + res, os_err := os.sendto(os.Socket(skt), buf, 0, cast(^os.SOCKADDR) &toaddr, size_of(toaddr)) + if os_err != os.ERROR_NONE { + err = UDP_Send_Error(os_err) + return + } + bytes_written = int(res) + return +} + +@(private) +_shutdown :: proc(skt: Any_Socket, manner: Shutdown_Manner) -> (err: Network_Error) { + s := any_socket_to_socket(skt) + res := os.shutdown(os.Socket(s), int(manner)) + if res != os.ERROR_NONE { + return Shutdown_Error(res) + } + return +} + +@(private) +_set_option :: proc(s: Any_Socket, option: Socket_Option, value: any, loc := #caller_location) -> Network_Error { + level := os.SOL_SOCKET if option != .TCP_Nodelay else os.IPPROTO_TCP + + // NOTE(tetra, 2022-02-15): On Linux, you cannot merely give a single byte for a bool; + // it _has_ to be a b32. + // I haven't tested if you can give more than that. + bool_value: b32 + int_value: i32 + timeval_value: os.Timeval + + ptr: rawptr + len: os.socklen_t + + switch option { + case + .Reuse_Address, + .Keep_Alive, + .Out_Of_Bounds_Data_Inline, + .TCP_Nodelay: + // TODO: verify whether these are options or not on Linux + // .Broadcast, + // .Conditional_Accept, + // .Dont_Linger: + switch x in value { + case bool, b8: + x2 := x + bool_value = b32((^bool)(&x2)^) + case b16: + bool_value = b32(x) + case b32: + bool_value = b32(x) + case b64: + bool_value = b32(x) + case: + panic("set_option() value must be a boolean here", loc) + } + ptr = &bool_value + len = size_of(bool_value) + case + .Linger, + .Send_Timeout, + .Receive_Timeout: + t, ok := value.(time.Duration) + if !ok do panic("set_option() value must be a time.Duration here", loc) + + micros := i64(time.duration_microseconds(t)) + timeval_value.microseconds = int(micros % 1e6) + timeval_value.seconds = (micros - i64(timeval_value.microseconds)) / 1e6 + + ptr = &timeval_value + len = size_of(timeval_value) + case + .Receive_Buffer_Size, + .Send_Buffer_Size: + // TODO: check for out of range values and return .Value_Out_Of_Range? + switch i in value { + case i8, u8: i2 := i; int_value = os.socklen_t((^u8)(&i2)^) + case i16, u16: i2 := i; int_value = os.socklen_t((^u16)(&i2)^) + case i32, u32: i2 := i; int_value = os.socklen_t((^u32)(&i2)^) + case i64, u64: i2 := i; int_value = os.socklen_t((^u64)(&i2)^) + case i128, u128: i2 := i; int_value = os.socklen_t((^u128)(&i2)^) + case int, uint: i2 := i; int_value = os.socklen_t((^uint)(&i2)^) + case: + panic("set_option() value must be an integer here", loc) + } + ptr = &int_value + len = size_of(int_value) + } + + skt := any_socket_to_socket(s) + res := os.setsockopt(os.Socket(skt), int(level), int(option), ptr, len) + if res != os.ERROR_NONE { + return Socket_Option_Error(res) + } + + return nil +} + +@(private) +_set_blocking :: proc(socket: Any_Socket, should_block: bool) -> (err: Network_Error) { + socket := any_socket_to_socket(socket) + + flags, getfl_err := os.fcntl(int(socket), os.F_GETFL, 0) + if getfl_err != os.ERROR_NONE { + return Set_Blocking_Error(getfl_err) + } + + if should_block { + flags &= ~int(os.O_NONBLOCK) + } else { + flags |= int(os.O_NONBLOCK) + } + + _, setfl_err := os.fcntl(int(socket), os.F_SETFL, flags) + if setfl_err != os.ERROR_NONE { + return Set_Blocking_Error(setfl_err) + } + + return nil +} + +@(private) +_endpoint_to_sockaddr :: proc(ep: Endpoint) -> (sockaddr: os.SOCKADDR_STORAGE_LH) { + switch a in ep.address { + case IP4_Address: + (^os.sockaddr_in)(&sockaddr)^ = os.sockaddr_in { + sin_port = u16be(ep.port), + sin_addr = transmute(os.in_addr) a, + sin_family = u16(os.AF_INET), + } + return + case IP6_Address: + (^os.sockaddr_in6)(&sockaddr)^ = os.sockaddr_in6 { + sin6_port = u16be(ep.port), + sin6_addr = transmute(os.in6_addr) a, + sin6_family = u16(os.AF_INET6), + } + return + } + unreachable() +} + +@(private) +_sockaddr_storage_to_endpoint :: proc(native_addr: ^os.SOCKADDR_STORAGE_LH) -> (ep: Endpoint) { + switch native_addr.ss_family { + case u16(os.AF_INET): + addr := cast(^os.sockaddr_in) native_addr + port := int(addr.sin_port) + ep = Endpoint { + address = IP4_Address(transmute([4]byte) addr.sin_addr), + port = port, + } + case u16(os.AF_INET6): + addr := cast(^os.sockaddr_in6) native_addr + port := int(addr.sin6_port) + ep = Endpoint { + address = IP6_Address(transmute([8]u16be) addr.sin6_addr), + port = port, + } + case: + panic("native_addr is neither IP4 or IP6 address") + } + return +} + +@(private) +_sockaddr_basic_to_endpoint :: proc(native_addr: ^os.SOCKADDR) -> (ep: Endpoint) { + switch native_addr.sa_family { + case u16(os.AF_INET): + addr := cast(^os.sockaddr_in) native_addr + port := int(addr.sin_port) + ep = Endpoint { + address = IP4_Address(transmute([4]byte) addr.sin_addr), + port = port, + } + case u16(os.AF_INET6): + addr := cast(^os.sockaddr_in6) native_addr + port := int(addr.sin6_port) + ep = Endpoint { + address = IP6_Address(transmute([8]u16be) addr.sin6_addr), + port = port, + } + case: + panic("native_addr is neither IP4 or IP6 address") + } + return +} diff --git a/core/net/socket_windows.odin b/core/net/socket_windows.odin new file mode 100644 index 000000000..3b9623749 --- /dev/null +++ b/core/net/socket_windows.odin @@ -0,0 +1,367 @@ +package net +// +build windows + +/* + Package net implements cross-platform Berkeley Sockets, DNS resolution and associated procedures. + For other protocols and their features, see subdirectories of this package. +*/ + +/* + Copyright 2022 Tetralux + Copyright 2022 Colin Davidson + Copyright 2022 Jeroen van Rijn . + Made available under Odin's BSD-3 license. + + List of contributors: + Tetralux: Initial implementation + Colin Davidson: Linux platform code, OSX platform code, Odin-native DNS resolver + Jeroen van Rijn: Cross platform unification, code style, documentation +*/ + +import "core:c" +import win "core:sys/windows" +import "core:time" + +@(init, private) +ensure_winsock_initialized :: proc() { + win.ensure_winsock_initialized() +} + +@(private) +_create_socket :: proc(family: Address_Family, protocol: Socket_Protocol) -> (socket: Any_Socket, err: Network_Error) { + c_type, c_protocol, c_family: c.int + + switch family { + case .IP4: c_family = win.AF_INET + case .IP6: c_family = win.AF_INET6 + case: + unreachable() + } + + switch protocol { + case .TCP: c_type = win.SOCK_STREAM; c_protocol = win.IPPROTO_TCP + case .UDP: c_type = win.SOCK_DGRAM; c_protocol = win.IPPROTO_UDP + case: + unreachable() + } + + sock := win.socket(c_family, c_type, c_protocol) + if sock == win.INVALID_SOCKET { + err = Create_Socket_Error(win.WSAGetLastError()) + return + } + + switch protocol { + case .TCP: return TCP_Socket(sock), nil + case .UDP: return UDP_Socket(sock), nil + case: + unreachable() + } +} + +@(private) +_dial_tcp_from_endpoint :: proc(endpoint: Endpoint, options := default_tcp_options) -> (socket: TCP_Socket, err: Network_Error) { + if endpoint.port == 0 { + err = .Port_Required + return + } + + family := family_from_endpoint(endpoint) + sock := create_socket(family, .TCP) or_return + socket = sock.(TCP_Socket) + + // NOTE(tetra): This is so that if we crash while the socket is open, we can + // bypass the cooldown period, and allow the next run of the program to + // use the same address immediately. + _ = set_option(socket, .Reuse_Address, true) + + sockaddr := _endpoint_to_sockaddr(endpoint) + res := win.connect(win.SOCKET(socket), &sockaddr, size_of(sockaddr)) + if res < 0 { + err = Dial_Error(win.WSAGetLastError()) + return + } + + if options.no_delay { + _ = set_option(sock, .TCP_Nodelay, true) // NOTE(tetra): Not vital to succeed; error ignored + } + + return +} + +@(private) +_bind :: proc(socket: Any_Socket, ep: Endpoint) -> (err: Network_Error) { + sockaddr := _endpoint_to_sockaddr(ep) + sock := any_socket_to_socket(socket) + res := win.bind(win.SOCKET(sock), &sockaddr, size_of(sockaddr)) + if res < 0 { + err = Bind_Error(win.WSAGetLastError()) + } + return +} + +@(private) +_listen_tcp :: proc(interface_endpoint: Endpoint, backlog := 1000) -> (socket: TCP_Socket, err: Network_Error) { + family := family_from_endpoint(interface_endpoint) + sock := create_socket(family, .TCP) or_return + socket = sock.(TCP_Socket) + + // NOTE(tetra): While I'm not 100% clear on it, my understanding is that this will + // prevent hijacking of the server's endpoint by other applications. + set_option(socket, .Exclusive_Addr_Use, true) or_return + + bind(sock, interface_endpoint) or_return + + if res := win.listen(win.SOCKET(socket), i32(backlog)); res == win.SOCKET_ERROR { + err = Listen_Error(win.WSAGetLastError()) + } + return +} + +@(private) +_accept_tcp :: proc(sock: TCP_Socket, options := default_tcp_options) -> (client: TCP_Socket, source: Endpoint, err: Network_Error) { + for { + sockaddr: win.SOCKADDR_STORAGE_LH + sockaddrlen := c.int(size_of(sockaddr)) + client_sock := win.accept(win.SOCKET(sock), &sockaddr, &sockaddrlen) + if int(client_sock) == win.SOCKET_ERROR { + e := win.WSAGetLastError() + if e == win.WSAECONNRESET { + // NOTE(tetra): Reset just means that a client that connection immediately lost the connection. + // There's no need to concern the user with this, so we handle it for them. + // On Linux, this error isn't possible in the first place according the man pages, so we also + // can do this to match the behaviour. + continue + } + err = Accept_Error(e) + return + } + client = TCP_Socket(client_sock) + source = _sockaddr_to_endpoint(&sockaddr) + if options.no_delay { + _ = set_option(client, .TCP_Nodelay, true) // NOTE(tetra): Not vital to succeed; error ignored + } + return + } +} + +@(private) +_close :: proc(socket: Any_Socket) { + if s := any_socket_to_socket(socket); s != {} { + win.closesocket(win.SOCKET(s)) + } +} + +@(private) +_recv_tcp :: proc(socket: TCP_Socket, buf: []byte) -> (bytes_read: int, err: Network_Error) { + if len(buf) <= 0 { + return + } + res := win.recv(win.SOCKET(socket), raw_data(buf), c.int(len(buf)), 0) + if res < 0 { + err = TCP_Recv_Error(win.WSAGetLastError()) + return + } + return int(res), nil +} + +@(private) +_recv_udp :: proc(socket: UDP_Socket, buf: []byte) -> (bytes_read: int, remote_endpoint: Endpoint, err: Network_Error) { + if len(buf) <= 0 { + return + } + + from: win.SOCKADDR_STORAGE_LH + fromsize := c.int(size_of(from)) + res := win.recvfrom(win.SOCKET(socket), raw_data(buf), c.int(len(buf)), 0, &from, &fromsize) + if res < 0 { + err = UDP_Recv_Error(win.WSAGetLastError()) + return + } + + bytes_read = int(res) + remote_endpoint = _sockaddr_to_endpoint(&from) + return +} + +@(private) +_send_tcp :: proc(socket: TCP_Socket, buf: []byte) -> (bytes_written: int, err: Network_Error) { + for bytes_written < len(buf) { + limit := min(int(max(i32)), len(buf) - bytes_written) + remaining := buf[bytes_written:] + res := win.send(win.SOCKET(socket), raw_data(remaining), c.int(limit), 0) + if res < 0 { + err = TCP_Send_Error(win.WSAGetLastError()) + return + } + bytes_written += int(res) + } + return +} + +@(private) +_send_udp :: proc(socket: UDP_Socket, buf: []byte, to: Endpoint) -> (bytes_written: int, err: Network_Error) { + if len(buf) > int(max(c.int)) { + // NOTE(tetra): If we don't guard this, we'll return (0, nil) instead, which is misleading. + err = .Message_Too_Long + return + } + toaddr := _endpoint_to_sockaddr(to) + res := win.sendto(win.SOCKET(socket), raw_data(buf), c.int(len(buf)), 0, &toaddr, size_of(toaddr)) + if res < 0 { + err = UDP_Send_Error(win.WSAGetLastError()) + return + } + bytes_written = int(res) + return +} + +@(private) +_shutdown :: proc(socket: Any_Socket, manner: Shutdown_Manner) -> (err: Network_Error) { + s := any_socket_to_socket(socket) + res := win.shutdown(win.SOCKET(s), c.int(manner)) + if res < 0 { + return Shutdown_Error(win.WSAGetLastError()) + } + return +} + +@(private) +_set_option :: proc(s: Any_Socket, option: Socket_Option, value: any, loc := #caller_location) -> Network_Error { + level := win.SOL_SOCKET if option != .TCP_Nodelay else win.IPPROTO_TCP + + bool_value: b32 + int_value: i32 + linger_value: win.LINGER + + ptr: rawptr + len: c.int + + switch option { + case + .Reuse_Address, + .Exclusive_Addr_Use, + .Keep_Alive, + .Out_Of_Bounds_Data_Inline, + .TCP_Nodelay, + .Broadcast, + .Conditional_Accept, + .Dont_Linger: + switch x in value { + case bool, b8: + x2 := x + bool_value = b32((^bool)(&x2)^) + case b16: + bool_value = b32(x) + case b32: + bool_value = b32(x) + case b64: + bool_value = b32(x) + case: + panic("set_option() value must be a boolean here", loc) + } + ptr = &bool_value + len = size_of(bool_value) + case .Linger: + t, ok := value.(time.Duration) + if !ok do panic("set_option() value must be a time.Duration here", loc) + + num_secs := i64(time.duration_seconds(t)) + if time.Duration(num_secs * 1e9) != t do return .Linger_Only_Supports_Whole_Seconds + if num_secs > i64(max(u16)) do return .Value_Out_Of_Range + linger_value.l_onoff = 1 + linger_value.l_linger = c.ushort(num_secs) + + ptr = &linger_value + len = size_of(linger_value) + case + .Receive_Timeout, + .Send_Timeout: + t, ok := value.(time.Duration) + if !ok do panic("set_option() value must be a time.Duration here", loc) + + int_value = i32(time.duration_milliseconds(t)) + ptr = &int_value + len = size_of(int_value) + + case + .Receive_Buffer_Size, + .Send_Buffer_Size: + switch i in value { + case i8, u8: i2 := i; int_value = c.int((^u8)(&i2)^) + case i16, u16: i2 := i; int_value = c.int((^u16)(&i2)^) + case i32, u32: i2 := i; int_value = c.int((^u32)(&i2)^) + case i64, u64: i2 := i; int_value = c.int((^u64)(&i2)^) + case i128, u128: i2 := i; int_value = c.int((^u128)(&i2)^) + case int, uint: i2 := i; int_value = c.int((^uint)(&i2)^) + case: + panic("set_option() value must be an integer here", loc) + } + ptr = &int_value + len = size_of(int_value) + } + + socket := any_socket_to_socket(s) + res := win.setsockopt(win.SOCKET(socket), c.int(level), c.int(option), ptr, len) + if res < 0 { + return Socket_Option_Error(win.WSAGetLastError()) + } + + return nil +} + +@(private) +_set_blocking :: proc(socket: Any_Socket, should_block: bool) -> (err: Network_Error) { + socket := any_socket_to_socket(socket) + arg: win.DWORD = 0 if should_block else 1 + res := win.ioctlsocket(win.SOCKET(socket), transmute(win.c_long)win.FIONBIO, &arg) + if res == win.SOCKET_ERROR { + return Set_Blocking_Error(win.WSAGetLastError()) + } + + return nil +} + +@(private) +_endpoint_to_sockaddr :: proc(ep: Endpoint) -> (sockaddr: win.SOCKADDR_STORAGE_LH) { + switch a in ep.address { + case IP4_Address: + (^win.sockaddr_in)(&sockaddr)^ = win.sockaddr_in { + sin_port = u16be(win.USHORT(ep.port)), + sin_addr = transmute(win.in_addr) a, + sin_family = u16(win.AF_INET), + } + return + case IP6_Address: + (^win.sockaddr_in6)(&sockaddr)^ = win.sockaddr_in6 { + sin6_port = u16be(win.USHORT(ep.port)), + sin6_addr = transmute(win.in6_addr) a, + sin6_family = u16(win.AF_INET6), + } + return + } + unreachable() +} + +@(private) +_sockaddr_to_endpoint :: proc(native_addr: ^win.SOCKADDR_STORAGE_LH) -> (ep: Endpoint) { + switch native_addr.ss_family { + case u16(win.AF_INET): + addr := cast(^win.sockaddr_in) native_addr + port := int(addr.sin_port) + ep = Endpoint { + address = IP4_Address(transmute([4]byte) addr.sin_addr), + port = port, + } + case u16(win.AF_INET6): + addr := cast(^win.sockaddr_in6) native_addr + port := int(addr.sin6_port) + ep = Endpoint { + address = IP6_Address(transmute([8]u16be) addr.sin6_addr), + port = port, + } + case: + panic("native_addr is neither IP4 or IP6 address") + } + return +} \ No newline at end of file diff --git a/core/net/url.odin b/core/net/url.odin new file mode 100644 index 000000000..ed39f7859 --- /dev/null +++ b/core/net/url.odin @@ -0,0 +1,209 @@ +package net +/* + Package net implements cross-platform Berkeley Sockets, DNS resolution and associated procedures. + For other protocols and their features, see subdirectories of this package. +*/ + +/* + Copyright 2022 Tetralux + Copyright 2022 Colin Davidson + Copyright 2022 Jeroen van Rijn . + Made available under Odin's BSD-3 license. + + List of contributors: + Tetralux: Initial implementation + Colin Davidson: Linux platform code, OSX platform code, Odin-native DNS resolver + Jeroen van Rijn: Cross platform unification, code style, documentation +*/ + +import "core:strings" +import "core:strconv" +import "core:unicode/utf8" +import "core:encoding/hex" + +split_url :: proc(url: string, allocator := context.allocator) -> (scheme, host, path: string, queries: map[string]string) { + s := url + + i := strings.last_index(s, "://") + if i >= 0 { + scheme = s[:i] + s = s[i+3:] + } + + i = strings.index(s, "?") + if i != -1 { + query_str := s[i+1:] + s = s[:i] + if query_str != "" { + queries_parts := strings.split(query_str, "&") + defer delete(queries_parts) + queries = make(map[string]string, len(queries_parts), allocator) + for q in queries_parts { + parts := strings.split(q, "=") + defer delete(parts) + switch len(parts) { + case 1: queries[parts[0]] = "" // NOTE(tetra): Query not set to anything, was but present. + case 2: queries[parts[0]] = parts[1] // NOTE(tetra): Query set to something. + case: break + } + } + } + } + + i = strings.index(s, "/") + if i == -1 { + host = s + path = "/" + } else { + host = s[:i] + path = s[i:] + } + + return +} + +join_url :: proc(scheme, host, path: string, queries: map[string]string, allocator := context.allocator) -> string { + using strings + + b := builder_make(allocator) + builder_grow(&b, len(scheme) + 3 + len(host) + 1 + len(path)) + + write_string(&b, scheme) + write_string(&b, "://") + write_string(&b, trim_space(host)) + + if path != "" { + if path[0] != '/' do write_string(&b, "/") + write_string(&b, trim_space(path)) + } + + + query_length := len(queries) + if query_length > 0 do write_string(&b, "?") + i := 0 + for query_name, query_value in queries { + write_string(&b, query_name) + if query_value != "" { + write_string(&b, "=") + write_string(&b, query_value) + } + if i < query_length - 1 { + write_string(&b, "&") + } + i += 1 + } + + return to_string(b) +} + +percent_encode :: proc(s: string, allocator := context.allocator) -> string { + using strings + + b := builder_make(allocator) + builder_grow(&b, len(s) + 16) // NOTE(tetra): A reasonable number to allow for the number of things we need to escape. + + for ch in s { + switch ch { + case 'A'..='Z', 'a'..='z', '0'..='9', '-', '_', '.', '~': + write_rune(&b, ch) + case: + bytes, n := utf8.encode_rune(ch) + for byte in bytes[:n] { + buf: [2]u8 = --- + t := strconv.append_int(buf[:], i64(byte), 16) + write_rune(&b, '%') + write_string(&b, t) + } + } + } + + return to_string(b) +} + +percent_decode :: proc(encoded_string: string, allocator := context.allocator) -> (decoded_string: string, ok: bool) { + using strings + + b := builder_make(allocator) + builder_grow(&b, len(encoded_string)) + defer if !ok do builder_destroy(&b) + + s := encoded_string + + for len(s) > 0 { + i := index_byte(s, '%') + if i == -1 { + write_string(&b, s) // no '%'s; the string is already decoded + break + } + + write_string(&b, s[:i]) + s = s[i:] + + if len(s) == 0 do return // percent without anything after it + s = s[1:] + + if s[0] == '%' { + write_byte(&b, '%') + s = s[1:] + continue + } + + if len(s) < 2 do return // percent without encoded value + + val := hex.decode_sequence(s[:2]) or_return + write_byte(&b, val) + s = s[2:] + } + + ok = true + decoded_string = to_string(b) + return +} + +// +// TODO: encoding/base64 is broken... +// + +// // TODO(tetra): The whole "table" stuff in encoding/base64 is too impenetrable for me to +// // make a table for this ... sigh - so this'll do for now. +/* +base64url_encode :: proc(data: []byte, allocator := context.allocator) -> string { + out := transmute([]byte) base64.encode(data, base64.ENC_TABLE, allocator); + for b, i in out { + switch b { + case '+': out[i] = '-'; + case '/': out[i] = '_'; + } + } + i := len(out)-1; + for ; i >= 0; i -= 1 { + if out[i] != '=' do break; + } + return string(out[:i+1]); +} + +base64url_decode :: proc(s: string, allocator := context.allocator) -> []byte { + size := len(s); + padding := 0; + for size % 4 != 0 { + size += 1; // TODO: SPEED + padding += 1; + } + + temp := make([]byte, size, context.temp_allocator); + copy(temp, transmute([]byte) s); + + for b, i in temp { + switch b { + case '-': temp[i] = '+'; + case '_': temp[i] = '/'; + } + } + + for in 0..padding-1 { + temp[len(temp)-1] = '='; + } + + return base64.decode(string(temp), base64.DEC_TABLE, allocator); +} +*/ diff --git a/core/odin/ast/ast.odin b/core/odin/ast/ast.odin index 99b2cde98..58d977171 100644 --- a/core/odin/ast/ast.odin +++ b/core/odin/ast/ast.odin @@ -740,6 +740,7 @@ Struct_Type :: struct { where_clauses: []^Expr, is_packed: bool, is_raw_union: bool, + is_no_copy: bool, fields: ^Field_List, name_count: int, } diff --git a/core/odin/ast/clone.odin b/core/odin/ast/clone.odin index 5ec6bc335..b8c0b8087 100644 --- a/core/odin/ast/clone.odin +++ b/core/odin/ast/clone.odin @@ -82,7 +82,11 @@ clone_node :: proc(node: ^Node) -> ^Node { panic("Cannot clone this node type") } - res := cast(^Node)mem.alloc(size, align) + res := cast(^Node)(mem.alloc(size, align) or_else nil) + if res == nil { + // allocation failure + return nil + } src: rawptr = node if node.derived != nil { src = (^rawptr)(&node.derived)^ diff --git a/core/odin/parser/parser.odin b/core/odin/parser/parser.odin index b70c8528e..15a33d86b 100644 --- a/core/odin/parser/parser.odin +++ b/core/odin/parser/parser.odin @@ -1425,7 +1425,7 @@ parse_stmt :: proc(p: ^Parser) -> ^ast.Stmt { return es case "force_inline", "force_no_inline": - expr := parse_inlining_operand(p, true, tok) + expr := parse_inlining_operand(p, true, tag) es := ast.new(ast.Expr_Stmt, expr.pos, expr.end) es.expr = expr return es @@ -2527,6 +2527,7 @@ parse_operand :: proc(p: ^Parser, lhs: bool) -> ^ast.Expr { align: ^ast.Expr is_packed: bool is_raw_union: bool + is_no_copy: bool fields: ^ast.Field_List name_count: int @@ -2560,6 +2561,11 @@ parse_operand :: proc(p: ^Parser, lhs: bool) -> ^ast.Expr { error(p, tag.pos, "duplicate struct tag '#%s'", tag.text) } is_raw_union = true + case "no_copy": + if is_no_copy { + error(p, tag.pos, "duplicate struct tag '#%s'", tag.text) + } + is_no_copy = true case: error(p, tag.pos, "invalid struct tag '#%s", tag.text) } @@ -2594,6 +2600,7 @@ parse_operand :: proc(p: ^Parser, lhs: bool) -> ^ast.Expr { st.align = align st.is_packed = is_packed st.is_raw_union = is_raw_union + st.is_no_copy = is_no_copy st.fields = fields st.name_count = name_count st.where_token = where_token diff --git a/core/os/dir_freebsd.odin b/core/os/dir_freebsd.odin index c664ffb34..2965182cd 100644 --- a/core/os/dir_freebsd.odin +++ b/core/os/dir_freebsd.odin @@ -50,7 +50,7 @@ read_dir :: proc(fd: Handle, n: int, allocator := context.allocator) -> (fi: []F continue } - fullpath := make([]byte, len(dirpath)+1+len(filename)) + fullpath := make([]byte, len(dirpath)+1+len(filename), context.temp_allocator) copy(fullpath, dirpath) copy(fullpath[len(dirpath):], "/") copy(fullpath[len(dirpath)+1:], filename) diff --git a/core/os/dir_linux.odin b/core/os/dir_linux.odin index 74c410a51..4971fa9d5 100644 --- a/core/os/dir_linux.odin +++ b/core/os/dir_linux.odin @@ -2,6 +2,7 @@ package os import "core:strings" import "core:mem" +import "core:runtime" read_dir :: proc(fd: Handle, n: int, allocator := context.allocator) -> (fi: []File_Info, err: Errno) { dirp: Dir @@ -51,6 +52,7 @@ read_dir :: proc(fd: Handle, n: int, allocator := context.allocator) -> (fi: []F continue } + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD(ignore = context.temp_allocator == allocator) fullpath := strings.join( []string{ dirpath, filename }, "/", context.temp_allocator) defer delete(fullpath, context.temp_allocator) diff --git a/core/os/dir_windows.odin b/core/os/dir_windows.odin index 9333548cf..531a5cd82 100644 --- a/core/os/dir_windows.odin +++ b/core/os/dir_windows.odin @@ -2,6 +2,7 @@ package os import win32 "core:sys/windows" import "core:strings" +import "core:runtime" read_dir :: proc(fd: Handle, n: int, allocator := context.allocator) -> (fi: []File_Info, err: Errno) { find_data_to_file_info :: proc(base_path: string, d: ^win32.WIN32_FIND_DATAW) -> (fi: File_Info) { @@ -65,13 +66,16 @@ read_dir :: proc(fd: Handle, n: int, allocator := context.allocator) -> (fi: []F n = -1 size = 100 } - dfi := make([dynamic]File_Info, 0, size) + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD(ignore = context.temp_allocator == allocator) wpath: []u16 - wpath, err = cleanpath_from_handle_u16(fd) + wpath, err = cleanpath_from_handle_u16(fd, context.temp_allocator) if len(wpath) == 0 || err != ERROR_NONE { return } + + dfi := make([dynamic]File_Info, 0, size) + wpath_search := make([]u16, len(wpath)+3, context.temp_allocator) copy(wpath_search, wpath) wpath_search[len(wpath)+0] = '\\' diff --git a/core/os/env_windows.odin b/core/os/env_windows.odin index 6e14127ed..ff20f126a 100644 --- a/core/os/env_windows.odin +++ b/core/os/env_windows.odin @@ -1,6 +1,7 @@ package os import win32 "core:sys/windows" +import "core:runtime" // lookup_env gets the value of the environment variable named by the key // If the variable is found in the environment the value (which can be empty) is returned and the boolean is true @@ -18,6 +19,8 @@ lookup_env :: proc(key: string, allocator := context.allocator) -> (value: strin return "", false } } + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD(ignore = context.temp_allocator == allocator) + b := make([dynamic]u16, n, context.temp_allocator) n = win32.GetEnvironmentVariableW(wkey, raw_data(b), u32(len(b))) if n == 0 { @@ -87,6 +90,7 @@ environ :: proc(allocator := context.allocator) -> []string { // clear_env deletes all environment variables clear_env :: proc() { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() envs := environ(context.temp_allocator) for env in envs { for j in 1.. bool { @@ -219,6 +220,7 @@ file_size :: proc(fd: Handle) -> (i64, Errno) { @(private) MAX_RW :: 1<<30 +ERROR_EOF :: 38 @(private) pread :: proc(fd: Handle, data: []byte, offset: i64) -> (int, Errno) { @@ -227,11 +229,6 @@ pread :: proc(fd: Handle, data: []byte, offset: i64) -> (int, Errno) { buf = buf[:MAX_RW] } - curr_offset, e := seek(fd, offset, 1) - if e != 0 { - return 0, e - } - defer seek(fd, curr_offset, 0) o := win32.OVERLAPPED{ OffsetHigh = u32(offset>>32), @@ -242,6 +239,7 @@ pread :: proc(fd: Handle, data: []byte, offset: i64) -> (int, Errno) { h := win32.HANDLE(fd) done: win32.DWORD + e: Errno if !win32.ReadFile(h, raw_data(buf), u32(len(buf)), &done, &o) { e = Errno(win32.GetLastError()) done = 0 @@ -255,11 +253,6 @@ pwrite :: proc(fd: Handle, data: []byte, offset: i64) -> (int, Errno) { buf = buf[:MAX_RW] } - curr_offset, e := seek(fd, offset, 1) - if e != 0 { - return 0, e - } - defer seek(fd, curr_offset, 0) o := win32.OVERLAPPED{ OffsetHigh = u32(offset>>32), @@ -268,6 +261,7 @@ pwrite :: proc(fd: Handle, data: []byte, offset: i64) -> (int, Errno) { h := win32.HANDLE(fd) done: win32.DWORD + e: Errno if !win32.WriteFile(h, raw_data(buf), u32(len(buf)), &done, &o) { e = Errno(win32.GetLastError()) done = 0 @@ -275,6 +269,16 @@ pwrite :: proc(fd: Handle, data: []byte, offset: i64) -> (int, Errno) { return int(done), e } +/* +read_at returns n: 0, err: 0 on EOF +on Windows, read_at changes the position of the file cursor, on *nix, it does not. + + bytes: [8]u8{} + read_at(fd, bytes, 0) + read(fd, bytes) + +will read from the location twice on *nix, and from two different locations on Windows +*/ read_at :: proc(fd: Handle, data: []byte, offset: i64) -> (n: int, err: Errno) { if offset < 0 { return 0, ERROR_NEGATIVE_OFFSET @@ -283,6 +287,10 @@ read_at :: proc(fd: Handle, data: []byte, offset: i64) -> (n: int, err: Errno) { b, offset := data, offset for len(b) > 0 { m, e := pread(fd, b, offset) + if e == ERROR_EOF { + err = 0 + break + } if e != 0 { err = e break @@ -293,6 +301,16 @@ read_at :: proc(fd: Handle, data: []byte, offset: i64) -> (n: int, err: Errno) { } return } + +/* +on Windows, write_at changes the position of the file cursor, on *nix, it does not. + + bytes: [8]u8{} + write_at(fd, bytes, 0) + write(fd, bytes) + +will write to the location twice on *nix, and to two different locations on Windows +*/ write_at :: proc(fd: Handle, data: []byte, offset: i64) -> (n: int, err: Errno) { if offset < 0 { return 0, ERROR_NEGATIVE_OFFSET @@ -327,6 +345,7 @@ get_std_handle :: proc "contextless" (h: uint) -> Handle { exists :: proc(path: string) -> bool { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() wpath := win32.utf8_to_wstring(path, context.temp_allocator) attribs := win32.GetFileAttributesW(wpath) @@ -334,6 +353,7 @@ exists :: proc(path: string) -> bool { } is_file :: proc(path: string) -> bool { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() wpath := win32.utf8_to_wstring(path, context.temp_allocator) attribs := win32.GetFileAttributesW(wpath) @@ -344,6 +364,7 @@ is_file :: proc(path: string) -> bool { } is_dir :: proc(path: string) -> bool { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() wpath := win32.utf8_to_wstring(path, context.temp_allocator) attribs := win32.GetFileAttributesW(wpath) @@ -359,6 +380,8 @@ is_dir :: proc(path: string) -> bool { get_current_directory :: proc(allocator := context.allocator) -> string { win32.AcquireSRWLockExclusive(&cwd_lock) + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD(ignore = context.temp_allocator == allocator) + sz_utf16 := win32.GetCurrentDirectoryW(0, nil) dir_buf_wstr := make([]u16, sz_utf16, context.temp_allocator) // the first time, it _includes_ the NUL. @@ -387,6 +410,7 @@ set_current_directory :: proc(path: string) -> (err: Errno) { change_directory :: proc(path: string) -> (err: Errno) { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() wpath := win32.utf8_to_wstring(path, context.temp_allocator) if !win32.SetCurrentDirectoryW(wpath) { @@ -396,6 +420,7 @@ change_directory :: proc(path: string) -> (err: Errno) { } make_directory :: proc(path: string, mode: u32 = 0) -> (err: Errno) { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() // Mode is unused on Windows, but is needed on *nix wpath := win32.utf8_to_wstring(path, context.temp_allocator) @@ -407,6 +432,7 @@ make_directory :: proc(path: string, mode: u32 = 0) -> (err: Errno) { remove_directory :: proc(path: string) -> (err: Errno) { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() wpath := win32.utf8_to_wstring(path, context.temp_allocator) if !win32.RemoveDirectoryW(wpath) { @@ -479,12 +505,14 @@ fix_long_path :: proc(path: string) -> string { link :: proc(old_name, new_name: string) -> (err: Errno) { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() n := win32.utf8_to_wstring(fix_long_path(new_name)) o := win32.utf8_to_wstring(fix_long_path(old_name)) return Errno(win32.CreateHardLinkW(n, o, nil)) } unlink :: proc(path: string) -> (err: Errno) { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() wpath := win32.utf8_to_wstring(path, context.temp_allocator) if !win32.DeleteFileW(wpath) { @@ -496,6 +524,7 @@ unlink :: proc(path: string) -> (err: Errno) { rename :: proc(old_path, new_path: string) -> (err: Errno) { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() from := win32.utf8_to_wstring(old_path, context.temp_allocator) to := win32.utf8_to_wstring(new_path, context.temp_allocator) diff --git a/core/os/os.odin b/core/os/os.odin index dd20de17c..b71ea261e 100644 --- a/core/os/os.odin +++ b/core/os/os.odin @@ -93,7 +93,7 @@ file_size_from_path :: proc(path: string) -> i64 { return length } -read_entire_file_from_filename :: proc(name: string, allocator := context.allocator) -> (data: []byte, success: bool) { +read_entire_file_from_filename :: proc(name: string, allocator := context.allocator, loc := #caller_location) -> (data: []byte, success: bool) { context.allocator = allocator fd, err := open(name, O_RDONLY, 0) @@ -102,10 +102,10 @@ read_entire_file_from_filename :: proc(name: string, allocator := context.alloca } defer close(fd) - return read_entire_file_from_handle(fd, allocator) + return read_entire_file_from_handle(fd, allocator, loc) } -read_entire_file_from_handle :: proc(fd: Handle, allocator := context.allocator) -> (data: []byte, success: bool) { +read_entire_file_from_handle :: proc(fd: Handle, allocator := context.allocator, loc := #caller_location) -> (data: []byte, success: bool) { context.allocator = allocator length: i64 @@ -118,7 +118,7 @@ read_entire_file_from_handle :: proc(fd: Handle, allocator := context.allocator) return nil, true } - data = make([]byte, int(length), allocator) + data = make([]byte, int(length), allocator, loc) if data == nil { return nil, false } @@ -194,7 +194,7 @@ heap_allocator_proc :: proc(allocator_data: rawptr, mode: mem.Allocator_Mode, ptr := uintptr(aligned_mem) aligned_ptr := (ptr - 1 + uintptr(a)) & -uintptr(a) diff := int(aligned_ptr - ptr) - if (size + diff) > space { + if (size + diff) > space || allocated_mem == nil { return nil, .Out_Of_Memory } @@ -216,7 +216,7 @@ heap_allocator_proc :: proc(allocator_data: rawptr, mode: mem.Allocator_Mode, } new_memory = aligned_alloc(new_size, new_alignment, p) or_return - + // NOTE: heap_resize does not zero the new memory, so we do it if new_size > old_size { new_region := mem.raw_data(new_memory[old_size:]) @@ -261,3 +261,7 @@ heap_allocator :: proc() -> mem.Allocator { data = nil, } } + +processor_core_count :: proc() -> int { + return _processor_core_count() +} diff --git a/core/os/os2/env.odin b/core/os/os2/env.odin index f25290a59..54c26981b 100644 --- a/core/os/os2/env.odin +++ b/core/os/os2/env.odin @@ -1,10 +1,12 @@ package os2 +import "core:runtime" + // get_env retrieves the value of the environment variable named by the key // It returns the value, which will be empty if the variable is not present // To distinguish between an empty value and an unset value, use lookup_env // NOTE: the value will be allocated with the supplied allocator -get_env :: proc(key: string, allocator := context.allocator) -> string { +get_env :: proc(key: string, allocator: runtime.Allocator) -> string { value, _ := lookup_env(key, allocator) return value } @@ -13,7 +15,7 @@ get_env :: proc(key: string, allocator := context.allocator) -> string { // If the variable is found in the environment the value (which can be empty) is returned and the boolean is true // Otherwise the returned value will be empty and the boolean will be false // NOTE: the value will be allocated with the supplied allocator -lookup_env :: proc(key: string, allocator := context.allocator) -> (value: string, found: bool) { +lookup_env :: proc(key: string, allocator: runtime.Allocator) -> (value: string, found: bool) { return _lookup_env(key, allocator) } @@ -36,7 +38,7 @@ clear_env :: proc() { // environ returns a copy of strings representing the environment, in the form "key=value" // NOTE: the slice of strings and the strings with be allocated using the supplied allocator -environ :: proc(allocator := context.allocator) -> []string { +environ :: proc(allocator: runtime.Allocator) -> []string { return _environ(allocator) } diff --git a/core/os/os2/env_linux.odin b/core/os/os2/env_linux.odin index 1833ac4dc..e7165b583 100644 --- a/core/os/os2/env_linux.odin +++ b/core/os/os2/env_linux.odin @@ -1,7 +1,9 @@ //+private package os2 -_get_env :: proc(key: string, allocator := context.allocator) -> (value: string, found: bool) { +import "core:runtime" + +_lookup_env :: proc(key: string, allocator: runtime.Allocator) -> (value: string, found: bool) { //TODO return } @@ -20,7 +22,7 @@ _clear_env :: proc() { //TODO } -_environ :: proc(allocator := context.allocator) -> []string { +_environ :: proc(allocator: runtime.Allocator) -> []string { //TODO return nil } diff --git a/core/os/os2/env_windows.odin b/core/os/os2/env_windows.odin index f58922fac..105063343 100644 --- a/core/os/os2/env_windows.odin +++ b/core/os/os2/env_windows.odin @@ -65,7 +65,19 @@ _environ :: proc(allocator: runtime.Allocator) -> []string { } defer win32.FreeEnvironmentStringsW(envs) - r := make([dynamic]string, 0, 50, allocator) + n := 0 + for from, i, p := 0, 0, envs; true; i += 1 { + c := ([^]u16)(p)[i] + if c == 0 { + if i <= from { + break + } + n += 1 + from = i + 1 + } + } + + r := make([dynamic]string, 0, n, allocator) for from, i, p := 0, 0, envs; true; i += 1 { c := ([^]u16)(p)[i] if c == 0 { diff --git a/core/os/os2/errors_windows.odin b/core/os/os2/errors_windows.odin index 27c16e72e..6500e7ccc 100644 --- a/core/os/os2/errors_windows.odin +++ b/core/os/os2/errors_windows.odin @@ -37,14 +37,18 @@ _get_platform_error :: proc() -> Error { case win32.ERROR_NOT_SUPPORTED: return .Unsupported + case win32.ERROR_HANDLE_EOF: + return .EOF + + case win32.ERROR_INVALID_HANDLE: + return .Invalid_File + case win32.ERROR_BAD_ARGUMENTS, win32.ERROR_INVALID_PARAMETER, win32.ERROR_NOT_ENOUGH_MEMORY, - win32.ERROR_INVALID_HANDLE, win32.ERROR_NO_MORE_FILES, win32.ERROR_LOCK_VIOLATION, - win32.ERROR_HANDLE_EOF, win32.ERROR_BROKEN_PIPE, win32.ERROR_CALL_NOT_IMPLEMENTED, win32.ERROR_INSUFFICIENT_BUFFER, diff --git a/core/os/os2/file.odin b/core/os/os2/file.odin index eb6d9e366..da822374a 100644 --- a/core/os/os2/file.odin +++ b/core/os/os2/file.odin @@ -8,12 +8,6 @@ File :: struct { impl: _File, } -Seek_From :: enum { - Start = 0, // seek relative to the origin of the file - Current = 1, // seek relative to the current offset - End = 2, // seek relative to the end -} - File_Mode :: distinct u32 File_Mode_Dir :: File_Mode(1<<16) File_Mode_Named_Pipe :: File_Mode(1<<17) @@ -72,54 +66,68 @@ fd :: proc(f: ^File) -> uintptr { return _fd(f) } - -close :: proc(f: ^File) -> Error { - return _close(f) -} - name :: proc(f: ^File) -> string { return _name(f) } -seek :: proc(f: ^File, offset: i64, whence: Seek_From) -> (ret: i64, err: Error) { - return _seek(f, offset, whence) +close :: proc(f: ^File) -> Error { + if f != nil { + return io.close(f.impl.stream) + } + return nil +} + +seek :: proc(f: ^File, offset: i64, whence: io.Seek_From) -> (ret: i64, err: Error) { + if f != nil { + return io.seek(f.impl.stream, offset, whence) + } + return 0, .Invalid_File } read :: proc(f: ^File, p: []byte) -> (n: int, err: Error) { - return _read(f, p) + if f != nil { + return io.read(f.impl.stream, p) + } + return 0, .Invalid_File } read_at :: proc(f: ^File, p: []byte, offset: i64) -> (n: int, err: Error) { - return _read_at(f, p, offset) -} - -read_from :: proc(f: ^File, r: io.Reader) -> (n: i64, err: Error) { - return _read_from(f, r) + if f != nil { + return io.read_at(f.impl.stream, p, offset) + } + return 0, .Invalid_File } write :: proc(f: ^File, p: []byte) -> (n: int, err: Error) { - return _write(f, p) + if f != nil { + return io.write(f.impl.stream, p) + } + return 0, .Invalid_File } write_at :: proc(f: ^File, p: []byte, offset: i64) -> (n: int, err: Error) { - return _write_at(f, p, offset) -} - -write_to :: proc(f: ^File, w: io.Writer) -> (n: i64, err: Error) { - return _write_to(f, w) + if f != nil { + return io.write_at(f.impl.stream, p, offset) + } + return 0, .Invalid_File } file_size :: proc(f: ^File) -> (n: i64, err: Error) { - return _file_size(f) -} - - -sync :: proc(f: ^File) -> Error { - return _sync(f) + if f != nil { + return io.size(f.impl.stream) + } + return 0, .Invalid_File } flush :: proc(f: ^File) -> Error { - return _flush(f) + if f != nil { + return io.flush(f.impl.stream) + } + return nil +} + +sync :: proc(f: ^File) -> Error { + return _sync(f) } truncate :: proc(f: ^File, size: i64) -> Error { diff --git a/core/os/os2/file_linux.odin b/core/os/os2/file_linux.odin index 0f2e810f4..ddd827bce 100644 --- a/core/os/os2/file_linux.odin +++ b/core/os/os2/file_linux.odin @@ -9,19 +9,20 @@ import "core:sys/unix" INVALID_HANDLE :: -1 -_O_RDONLY :: 0o0 -_O_WRONLY :: 0o1 -_O_RDWR :: 0o2 -_O_CREAT :: 0o100 -_O_EXCL :: 0o200 -_O_TRUNC :: 0o1000 -_O_APPEND :: 0o2000 -_O_NONBLOCK :: 0o4000 -_O_LARGEFILE :: 0o100000 -_O_DIRECTORY :: 0o200000 -_O_NOFOLLOW :: 0o400000 -_O_SYNC :: 0o4010000 -_O_CLOEXEC :: 0o2000000 +_O_RDONLY :: 0o00000000 +_O_WRONLY :: 0o00000001 +_O_RDWR :: 0o00000002 +_O_CREAT :: 0o00000100 +_O_EXCL :: 0o00000200 +_O_NOCTTY :: 0o00000400 +_O_TRUNC :: 0o00001000 +_O_APPEND :: 0o00002000 +_O_NONBLOCK :: 0o00004000 +_O_LARGEFILE :: 0o00100000 +_O_DIRECTORY :: 0o00200000 +_O_NOFOLLOW :: 0o00400000 +_O_SYNC :: 0o04010000 +_O_CLOEXEC :: 0o02000000 _O_PATH :: 0o10000000 _AT_FDCWD :: -100 @@ -32,6 +33,8 @@ _File :: struct { name: string, fd: int, allocator: runtime.Allocator, + + stream: io.Stream, } _file_allocator :: proc() -> runtime.Allocator { @@ -39,12 +42,13 @@ _file_allocator :: proc() -> runtime.Allocator { } _open :: proc(name: string, flags: File_Flags, perm: File_Mode) -> (^File, Error) { - name_cstr, allocated := _name_to_cstring(name) - defer if allocated { - delete(name_cstr) - } + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() + name_cstr := strings.clone_to_cstring(name, context.temp_allocator) - flags_i: int + // Just default to using O_NOCTTY because needing to open a controlling + // terminal would be incredibly rare. This has no effect on files while + // allowing us to open serial devices. + flags_i: int = _O_NOCTTY switch flags & O_RDONLY|O_WRONLY|O_RDWR { case O_RDONLY: flags_i = _O_RDONLY case O_WRONLY: flags_i = _O_WRONLY @@ -58,7 +62,7 @@ _open :: proc(name: string, flags: File_Flags, perm: File_Mode) -> (^File, Error flags_i |= (_O_TRUNC * int(.Trunc in flags)) flags_i |= (_O_CLOEXEC * int(.Close_On_Exec in flags)) - fd := unix.sys_open(name_cstr, flags_i, int(perm)) + fd := unix.sys_open(name_cstr, flags_i, uint(perm)) if fd < 0 { return nil, _get_platform_error(fd) } @@ -71,6 +75,10 @@ _new_file :: proc(fd: uintptr, _: string) -> ^File { file.impl.fd = int(fd) file.impl.allocator = _file_allocator() file.impl.name = _get_full_path(file.impl.fd, file.impl.allocator) + file.impl.stream = { + data = file, + procedure = _file_stream_proc, + } return file } @@ -100,7 +108,7 @@ _name :: proc(f: ^File) -> string { return f.impl.name if f != nil else "" } -_seek :: proc(f: ^File, offset: i64, whence: Seek_From) -> (ret: i64, err: Error) { +_seek :: proc(f: ^File, offset: i64, whence: io.Seek_From) -> (ret: i64, err: Error) { res := unix.sys_lseek(f.impl.fd, offset, int(whence)) if res < 0 { return -1, _get_platform_error(int(res)) @@ -108,18 +116,18 @@ _seek :: proc(f: ^File, offset: i64, whence: Seek_From) -> (ret: i64, err: Error return res, nil } -_read :: proc(f: ^File, p: []byte) -> (n: int, err: Error) { +_read :: proc(f: ^File, p: []byte) -> (i64, Error) { if len(p) == 0 { return 0, nil } - n = unix.sys_read(f.impl.fd, &p[0], len(p)) + n := unix.sys_read(f.impl.fd, &p[0], len(p)) if n < 0 { return -1, _get_platform_error(n) } - return n, nil + return i64(n), nil } -_read_at :: proc(f: ^File, p: []byte, offset: i64) -> (n: int, err: Error) { +_read_at :: proc(f: ^File, p: []byte, offset: i64) -> (n: i64, err: Error) { if offset < 0 { return 0, .Invalid_Offset } @@ -130,30 +138,25 @@ _read_at :: proc(f: ^File, p: []byte, offset: i64) -> (n: int, err: Error) { if m < 0 { return -1, _get_platform_error(m) } - n += m + n += i64(m) b = b[m:] offset += i64(m) } return } -_read_from :: proc(f: ^File, r: io.Reader) -> (n: i64, err: Error) { - //TODO - return -} - -_write :: proc(f: ^File, p: []byte) -> (n: int, err: Error) { +_write :: proc(f: ^File, p: []byte) -> (i64, Error) { if len(p) == 0 { return 0, nil } - n = unix.sys_write(f.impl.fd, &p[0], uint(len(p))) + n := unix.sys_write(f.impl.fd, &p[0], uint(len(p))) if n < 0 { return -1, _get_platform_error(n) } - return int(n), nil + return i64(n), nil } -_write_at :: proc(f: ^File, p: []byte, offset: i64) -> (n: int, err: Error) { +_write_at :: proc(f: ^File, p: []byte, offset: i64) -> (n: i64, err: Error) { if offset < 0 { return 0, .Invalid_Offset } @@ -164,18 +167,13 @@ _write_at :: proc(f: ^File, p: []byte, offset: i64) -> (n: int, err: Error) { if m < 0 { return -1, _get_platform_error(m) } - n += m + n += i64(m) b = b[m:] offset += i64(m) } return } -_write_to :: proc(f: ^File, w: io.Writer) -> (n: i64, err: Error) { - //TODO - return -} - _file_size :: proc(f: ^File) -> (n: i64, err: Error) { s: _Stat = --- res := unix.sys_fstat(f.impl.fd, &s) @@ -198,10 +196,7 @@ _truncate :: proc(f: ^File, size: i64) -> Error { } _remove :: proc(name: string) -> Error { - name_cstr, allocated := _name_to_cstring(name) - defer if allocated { - delete(name_cstr) - } + name_cstr := strings.clone_to_cstring(name, context.temp_allocator) fd := unix.sys_open(name_cstr, int(File_Flags.Read)) if fd < 0 { @@ -216,45 +211,27 @@ _remove :: proc(name: string) -> Error { } _rename :: proc(old_name, new_name: string) -> Error { - old_name_cstr, old_allocated := _name_to_cstring(old_name) - new_name_cstr, new_allocated := _name_to_cstring(new_name) - defer if old_allocated { - delete(old_name_cstr) - } - defer if new_allocated { - delete(new_name_cstr) - } + old_name_cstr := strings.clone_to_cstring(old_name, context.temp_allocator) + new_name_cstr := strings.clone_to_cstring(new_name, context.temp_allocator) return _ok_or_error(unix.sys_rename(old_name_cstr, new_name_cstr)) } _link :: proc(old_name, new_name: string) -> Error { - old_name_cstr, old_allocated := _name_to_cstring(old_name) - new_name_cstr, new_allocated := _name_to_cstring(new_name) - defer if old_allocated { - delete(old_name_cstr) - } - defer if new_allocated { - delete(new_name_cstr) - } + old_name_cstr := strings.clone_to_cstring(old_name, context.temp_allocator) + new_name_cstr := strings.clone_to_cstring(new_name, context.temp_allocator) return _ok_or_error(unix.sys_link(old_name_cstr, new_name_cstr)) } _symlink :: proc(old_name, new_name: string) -> Error { - old_name_cstr, old_allocated := _name_to_cstring(old_name) - new_name_cstr, new_allocated := _name_to_cstring(new_name) - defer if old_allocated { - delete(old_name_cstr) - } - defer if new_allocated { - delete(new_name_cstr) - } + old_name_cstr := strings.clone_to_cstring(old_name, context.temp_allocator) + new_name_cstr := strings.clone_to_cstring(new_name, context.temp_allocator) return _ok_or_error(unix.sys_symlink(old_name_cstr, new_name_cstr)) } -_read_link_cstr :: proc(name_cstr: cstring, allocator := context.allocator) -> (string, Error) { +_read_link_cstr :: proc(name_cstr: cstring, allocator: runtime.Allocator) -> (string, Error) { bufsz : uint = 256 buf := make([]byte, bufsz, allocator) for { @@ -272,27 +249,18 @@ _read_link_cstr :: proc(name_cstr: cstring, allocator := context.allocator) -> ( } } -_read_link :: proc(name: string, allocator := context.allocator) -> (string, Error) { - name_cstr, allocated := _name_to_cstring(name) - defer if allocated { - delete(name_cstr) - } +_read_link :: proc(name: string, allocator: runtime.Allocator) -> (string, Error) { + name_cstr := strings.clone_to_cstring(name, context.temp_allocator) return _read_link_cstr(name_cstr, allocator) } _unlink :: proc(name: string) -> Error { - name_cstr, allocated := _name_to_cstring(name) - defer if allocated { - delete(name_cstr) - } + name_cstr := strings.clone_to_cstring(name, context.temp_allocator) return _ok_or_error(unix.sys_unlink(name_cstr)) } _chdir :: proc(name: string) -> Error { - name_cstr, allocated := _name_to_cstring(name) - defer if allocated { - delete(name_cstr) - } + name_cstr := strings.clone_to_cstring(name, context.temp_allocator) return _ok_or_error(unix.sys_chdir(name_cstr)) } @@ -301,32 +269,23 @@ _fchdir :: proc(f: ^File) -> Error { } _chmod :: proc(name: string, mode: File_Mode) -> Error { - name_cstr, allocated := _name_to_cstring(name) - defer if allocated { - delete(name_cstr) - } - return _ok_or_error(unix.sys_chmod(name_cstr, int(mode))) + name_cstr := strings.clone_to_cstring(name, context.temp_allocator) + return _ok_or_error(unix.sys_chmod(name_cstr, uint(mode))) } _fchmod :: proc(f: ^File, mode: File_Mode) -> Error { - return _ok_or_error(unix.sys_fchmod(f.impl.fd, int(mode))) + return _ok_or_error(unix.sys_fchmod(f.impl.fd, uint(mode))) } // NOTE: will throw error without super user priviledges _chown :: proc(name: string, uid, gid: int) -> Error { - name_cstr, allocated := _name_to_cstring(name) - defer if allocated { - delete(name_cstr) - } + name_cstr := strings.clone_to_cstring(name, context.temp_allocator) return _ok_or_error(unix.sys_chown(name_cstr, uid, gid)) } // NOTE: will throw error without super user priviledges _lchown :: proc(name: string, uid, gid: int) -> Error { - name_cstr, allocated := _name_to_cstring(name) - defer if allocated { - delete(name_cstr) - } + name_cstr := strings.clone_to_cstring(name, context.temp_allocator) return _ok_or_error(unix.sys_lchown(name_cstr, uid, gid)) } @@ -336,10 +295,7 @@ _fchown :: proc(f: ^File, uid, gid: int) -> Error { } _chtimes :: proc(name: string, atime, mtime: time.Time) -> Error { - name_cstr, allocated := _name_to_cstring(name) - defer if allocated { - delete(name_cstr) - } + name_cstr := strings.clone_to_cstring(name, context.temp_allocator) times := [2]Unix_File_Time { { atime._nsec, 0 }, { mtime._nsec, 0 }, @@ -356,18 +312,12 @@ _fchtimes :: proc(f: ^File, atime, mtime: time.Time) -> Error { } _exists :: proc(name: string) -> bool { - name_cstr, allocated := _name_to_cstring(name) - defer if allocated { - delete(name_cstr) - } + name_cstr := strings.clone_to_cstring(name, context.temp_allocator) return unix.sys_access(name_cstr, F_OK) == 0 } _is_file :: proc(name: string) -> bool { - name_cstr, allocated := _name_to_cstring(name) - defer if allocated { - delete(name_cstr) - } + name_cstr := strings.clone_to_cstring(name, context.temp_allocator) s: _Stat res := unix.sys_stat(name_cstr, &s) if res < 0 { @@ -386,10 +336,7 @@ _is_file_fd :: proc(fd: int) -> bool { } _is_dir :: proc(name: string) -> bool { - name_cstr, allocated := _name_to_cstring(name) - defer if allocated { - delete(name_cstr) - } + name_cstr := strings.clone_to_cstring(name, context.temp_allocator) s: _Stat res := unix.sys_stat(name_cstr, &s) if res < 0 { @@ -411,12 +358,53 @@ _is_dir_fd :: proc(fd: int) -> bool { // defined as 512, however, it is well known that paths can exceed that limit. // So, in theory you could have a path larger than the entire temp_allocator's // buffer. Therefor, any large paths will use context.allocator. -_name_to_cstring :: proc(name: string) -> (cname: cstring, allocated: bool) { - if len(name) > _CSTRING_NAME_HEAP_THRESHOLD { - cname = strings.clone_to_cstring(name) - allocated = true - return - } - cname = strings.clone_to_cstring(name, context.temp_allocator) - return +@(private="file") +_temp_name_to_cstring :: proc(name: string) -> (cname: cstring) { + return strings.clone_to_cstring(name, context.temp_allocator) } + + +@(private="package") +_file_stream_proc :: proc(stream_data: rawptr, mode: io.Stream_Mode, p: []byte, offset: i64, whence: io.Seek_From) -> (n: i64, err: io.Error) { + f := (^File)(stream_data) + ferr: Error + i: int + switch mode { + case .Read: + n, ferr = _read(f, p) + err = error_to_io_error(ferr) + return + case .Read_At: + n, ferr = _read_at(f, p, offset) + err = error_to_io_error(ferr) + return + case .Write: + n, ferr = _write(f, p) + err = error_to_io_error(ferr) + return + case .Write_At: + n, ferr = _write_at(f, p, offset) + err = error_to_io_error(ferr) + return + case .Seek: + n, ferr = _seek(f, offset, whence) + err = error_to_io_error(ferr) + return + case .Size: + n, ferr = _file_size(f) + err = error_to_io_error(ferr) + return + case .Flush: + ferr = _flush(f) + err = error_to_io_error(ferr) + return + case .Close, .Destroy: + ferr = _close(f) + err = error_to_io_error(ferr) + return + case .Query: + return io.query_utility({.Read, .Read_At, .Write, .Write_At, .Seek, .Size, .Flush, .Close, .Destroy, .Query}) + } + return 0, .Empty +} + diff --git a/core/os/os2/file_stream.odin b/core/os/os2/file_stream.odin index 7edbd68fa..da1e3344f 100644 --- a/core/os/os2/file_stream.odin +++ b/core/os/os2/file_stream.odin @@ -3,17 +3,15 @@ package os2 import "core:io" to_stream :: proc(f: ^File) -> (s: io.Stream) { - s.stream_data = f - s.stream_vtable = &_file_stream_vtable + if f != nil { + assert(f.impl.stream.procedure != nil) + s = f.impl.stream + } return } -to_writer :: proc(f: ^File) -> (s: io.Writer) { - return {to_stream(f)} -} -to_reader :: proc(f: ^File) -> (s: io.Reader) { - return {to_stream(f)} -} +to_writer :: to_stream +to_reader :: to_stream @(private) @@ -23,71 +21,3 @@ error_to_io_error :: proc(ferr: Error) -> io.Error { } return ferr.(io.Error) or_else .Unknown } - - -@(private) -_file_stream_vtable := io.Stream_VTable{ - impl_read = proc(s: io.Stream, p: []byte) -> (n: int, err: io.Error) { - f := (^File)(s.stream_data) - ferr: Error - n, ferr = read(f, p) - err = error_to_io_error(ferr) - return - }, - impl_read_at = proc(s: io.Stream, p: []byte, offset: i64) -> (n: int, err: io.Error) { - f := (^File)(s.stream_data) - ferr: Error - n, ferr = read_at(f, p, offset) - err = error_to_io_error(ferr) - return - }, - impl_write_to = proc(s: io.Stream, w: io.Writer) -> (n: i64, err: io.Error) { - f := (^File)(s.stream_data) - ferr: Error - n, ferr = write_to(f, w) - err = error_to_io_error(ferr) - return - }, - impl_write = proc(s: io.Stream, p: []byte) -> (n: int, err: io.Error) { - f := (^File)(s.stream_data) - ferr: Error - n, ferr = write(f, p) - err = error_to_io_error(ferr) - return - }, - impl_write_at = proc(s: io.Stream, p: []byte, offset: i64) -> (n: int, err: io.Error) { - f := (^File)(s.stream_data) - ferr: Error - n, ferr = write_at(f, p, offset) - err = error_to_io_error(ferr) - return - }, - impl_read_from = proc(s: io.Stream, r: io.Reader) -> (n: i64, err: io.Error) { - f := (^File)(s.stream_data) - ferr: Error - n, ferr = read_from(f, r) - err = error_to_io_error(ferr) - return - }, - impl_seek = proc(s: io.Stream, offset: i64, whence: io.Seek_From) -> (i64, io.Error) { - f := (^File)(s.stream_data) - n, ferr := seek(f, offset, Seek_From(whence)) - err := error_to_io_error(ferr) - return n, err - }, - impl_size = proc(s: io.Stream) -> i64 { - f := (^File)(s.stream_data) - sz, _ := file_size(f) - return sz - }, - impl_flush = proc(s: io.Stream) -> io.Error { - f := (^File)(s.stream_data) - ferr := flush(f) - return error_to_io_error(ferr) - }, - impl_close = proc(s: io.Stream) -> io.Error { - f := (^File)(s.stream_data) - ferr := close(f) - return error_to_io_error(ferr) - }, -} diff --git a/core/os/os2/file_util.odin b/core/os/os2/file_util.odin index 9f9064244..60c3efe44 100644 --- a/core/os/os2/file_util.odin +++ b/core/os/os2/file_util.odin @@ -1,6 +1,7 @@ package os2 import "core:mem" +import "core:runtime" import "core:strconv" import "core:unicode/utf8" @@ -74,7 +75,7 @@ read_ptr :: proc(f: ^File, data: rawptr, len: int) -> (n: int, err: Error) { -read_entire_file :: proc(name: string, allocator := context.allocator) -> (data: []byte, err: Error) { +read_entire_file :: proc(name: string, allocator: runtime.Allocator) -> (data: []byte, err: Error) { f, ferr := open(name) if ferr != nil { return nil, ferr diff --git a/core/os/os2/file_windows.odin b/core/os/os2/file_windows.odin index e4ae4856a..600ecde21 100644 --- a/core/os/os2/file_windows.odin +++ b/core/os/os2/file_windows.odin @@ -38,6 +38,8 @@ _File :: struct { wname: win32.wstring, kind: _File_Kind, + stream: io.Stream, + allocator: runtime.Allocator, rw_mutex: sync.RW_Mutex, // read write calls @@ -144,6 +146,11 @@ _new_file :: proc(handle: uintptr, name: string) -> ^File { } f.impl.kind = kind + f.impl.stream = { + data = f, + procedure = _file_stream_proc, + } + return f } @@ -181,7 +188,7 @@ _name :: proc(f: ^File) -> string { return f.impl.name if f != nil else "" } -_seek :: proc(f: ^File, offset: i64, whence: Seek_From) -> (ret: i64, err: Error) { +_seek :: proc(f: ^File, offset: i64, whence: io.Seek_From) -> (ret: i64, err: Error) { handle := _handle(f) if handle == win32.INVALID_HANDLE { return 0, .Invalid_File @@ -208,7 +215,7 @@ _seek :: proc(f: ^File, offset: i64, whence: Seek_From) -> (ret: i64, err: Error return i64(hi)<<32 + i64(dw_ptr), nil } -_read :: proc(f: ^File, p: []byte) -> (n: int, err: Error) { +_read :: proc(f: ^File, p: []byte) -> (n: i64, err: Error) { read_console :: proc(handle: win32.HANDLE, b: []byte) -> (n: int, err: Error) { if len(b) == 0 { return 0, nil @@ -274,7 +281,7 @@ _read :: proc(f: ^File, p: []byte) -> (n: int, err: Error) { n, err := read_console(handle, p[total_read:][:to_read]) total_read += n if err != nil { - return int(total_read), err + return i64(total_read), err } } else { ok = win32.ReadFile(handle, &p[total_read], to_read, &single_read_length, nil) @@ -287,11 +294,11 @@ _read :: proc(f: ^File, p: []byte) -> (n: int, err: Error) { } } - return int(total_read), nil + return i64(total_read), err } -_read_at :: proc(f: ^File, p: []byte, offset: i64) -> (n: int, err: Error) { - pread :: proc(f: ^File, data: []byte, offset: i64) -> (n: int, err: Error) { +_read_at :: proc(f: ^File, p: []byte, offset: i64) -> (n: i64, err: Error) { + pread :: proc(f: ^File, data: []byte, offset: i64) -> (n: i64, err: Error) { buf := data if len(buf) > MAX_RW { buf = buf[:MAX_RW] @@ -313,7 +320,7 @@ _read_at :: proc(f: ^File, p: []byte, offset: i64) -> (n: int, err: Error) { err = _get_platform_error() done = 0 } - n = int(done) + n = i64(done) return } @@ -329,12 +336,7 @@ _read_at :: proc(f: ^File, p: []byte, offset: i64) -> (n: int, err: Error) { return } -_read_from :: proc(f: ^File, r: io.Reader) -> (n: i64, err: Error) { - // TODO(bill) - return -} - -_write :: proc(f: ^File, p: []byte) -> (n: int, err: Error) { +_write :: proc(f: ^File, p: []byte) -> (n: i64, err: Error) { if len(p) == 0 { return } @@ -352,17 +354,17 @@ _write :: proc(f: ^File, p: []byte) -> (n: int, err: Error) { e := win32.WriteFile(handle, &p[total_write], to_write, &single_write_length, nil) if single_write_length <= 0 || !e { - n = int(total_write) + n = i64(total_write) err = _get_platform_error() return } total_write += i64(single_write_length) } - return int(total_write), nil + return i64(total_write), nil } -_write_at :: proc(f: ^File, p: []byte, offset: i64) -> (n: int, err: Error) { - pwrite :: proc(f: ^File, data: []byte, offset: i64) -> (n: int, err: Error) { +_write_at :: proc(f: ^File, p: []byte, offset: i64) -> (n: i64, err: Error) { + pwrite :: proc(f: ^File, data: []byte, offset: i64) -> (n: i64, err: Error) { buf := data if len(buf) > MAX_RW { buf = buf[:MAX_RW] @@ -382,7 +384,7 @@ _write_at :: proc(f: ^File, p: []byte, offset: i64) -> (n: int, err: Error) { err = _get_platform_error() done = 0 } - n = int(done) + n = i64(done) return } @@ -397,11 +399,6 @@ _write_at :: proc(f: ^File, p: []byte, offset: i64) -> (n: int, err: Error) { return } -_write_to :: proc(f: ^File, w: io.Writer) -> (n: i64, err: Error) { - // TODO(bill) - return -} - _file_size :: proc(f: ^File) -> (n: i64, err: Error) { length: win32.LARGE_INTEGER handle := _handle(f) @@ -727,3 +724,51 @@ _is_dir :: proc(path: string) -> bool { } return false } + + +@(private="package") +_file_stream_proc :: proc(stream_data: rawptr, mode: io.Stream_Mode, p: []byte, offset: i64, whence: io.Seek_From) -> (n: i64, err: io.Error) { + f := (^File)(stream_data) + ferr: Error + i: int + switch mode { + case .Read: + n, ferr = _read(f, p) + err = error_to_io_error(ferr) + return + case .Read_At: + n, ferr = _read_at(f, p, offset) + err = error_to_io_error(ferr) + return + case .Write: + n, ferr = _write(f, p) + err = error_to_io_error(ferr) + return + case .Write_At: + n, ferr = _write_at(f, p, offset) + err = error_to_io_error(ferr) + return + case .Seek: + n, ferr = _seek(f, offset, whence) + err = error_to_io_error(ferr) + return + case .Size: + n, ferr = _file_size(f) + err = error_to_io_error(ferr) + return + case .Flush: + ferr = _flush(f) + err = error_to_io_error(ferr) + return + case .Close: + ferr = _close(f) + err = error_to_io_error(ferr) + return + case .Query: + return io.query_utility({.Read, .Read_At, .Write, .Write_At, .Seek, .Size, .Flush, .Close, .Query}) + case .Destroy: + return 0, .Empty + } + return 0, .Empty +} + diff --git a/core/os/os2/heap_linux.odin b/core/os/os2/heap_linux.odin index b631268a1..136c3e6cb 100644 --- a/core/os/os2/heap_linux.odin +++ b/core/os/os2/heap_linux.odin @@ -166,7 +166,7 @@ _heap_allocator_proc :: proc(allocator_data: rawptr, mode: mem.Allocator_Mode, ptr := uintptr(aligned_mem) aligned_ptr := (ptr - 1 + uintptr(a)) & -uintptr(a) diff := int(aligned_ptr - ptr) - if (size + diff) > space { + if (size + diff) > space || allocated_mem == nil { return nil, .Out_Of_Memory } diff --git a/core/os/os2/heap_windows.odin b/core/os/os2/heap_windows.odin index 0f154cd8c..eba403c1d 100644 --- a/core/os/os2/heap_windows.odin +++ b/core/os/os2/heap_windows.odin @@ -52,7 +52,7 @@ _heap_allocator_proc :: proc(allocator_data: rawptr, mode: mem.Allocator_Mode, ptr := uintptr(aligned_mem) aligned_ptr := (ptr - 1 + uintptr(a)) & -uintptr(a) diff := int(aligned_ptr - ptr) - if (size + diff) > space { + if (size + diff) > space || allocated_mem == nil { return nil, .Out_Of_Memory } diff --git a/core/os/os2/path_linux.odin b/core/os/os2/path_linux.odin index 2f59d1f13..2a0ef29d8 100644 --- a/core/os/os2/path_linux.odin +++ b/core/os/os2/path_linux.odin @@ -31,11 +31,8 @@ _mkdir :: proc(path: string, perm: File_Mode) -> Error { return .Invalid_Argument } - path_cstr, allocated := _name_to_cstring(path) - defer if allocated { - delete(path_cstr) - } - return _ok_or_error(unix.sys_mkdir(path_cstr, int(perm & 0o777))) + path_cstr := strings.clone_to_cstring(path, context.temp_allocator) + return _ok_or_error(unix.sys_mkdir(path_cstr, uint(perm & 0o777))) } _mkdir_all :: proc(path: string, perm: File_Mode) -> Error { @@ -49,7 +46,7 @@ _mkdir_all :: proc(path: string, perm: File_Mode) -> Error { new_dfd := unix.sys_openat(dfd, cstring(&path[0]), _OPENDIR_FLAGS) switch new_dfd { case -ENOENT: - if res := unix.sys_mkdirat(dfd, cstring(&path[0]), perm); res < 0 { + if res := unix.sys_mkdirat(dfd, cstring(&path[0]), uint(perm)); res < 0 { return _get_platform_error(res) } has_created^ = true @@ -83,9 +80,6 @@ _mkdir_all :: proc(path: string, perm: File_Mode) -> Error { } else { path_bytes = make([]u8, len(path) + 1, context.temp_allocator) } - defer if allocated { - delete(path_bytes) - } // NULL terminate the byte slice to make it a valid cstring copy(path_bytes, path) @@ -182,10 +176,7 @@ _remove_all :: proc(path: string) -> Error { return nil } - path_cstr, allocated := _name_to_cstring(path) - defer if allocated { - delete(path_cstr) - } + path_cstr := strings.clone_to_cstring(path, context.temp_allocator) fd := unix.sys_open(path_cstr, _OPENDIR_FLAGS) switch fd { @@ -211,7 +202,7 @@ _getwd :: proc(allocator: runtime.Allocator) -> (string, Error) { #no_bounds_check res := unix.sys_getcwd(&buf[0], uint(len(buf))) if res >= 0 { - return strings.string_from_nul_terminated_ptr(&buf[0], len(buf)), nil + return strings.string_from_null_terminated_ptr(&buf[0], len(buf)), nil } if res != -ERANGE { return "", _get_platform_error(res) @@ -222,14 +213,11 @@ _getwd :: proc(allocator: runtime.Allocator) -> (string, Error) { } _setwd :: proc(dir: string) -> Error { - dir_cstr, allocated := _name_to_cstring(dir) - defer if allocated { - delete(dir_cstr) - } + dir_cstr := strings.clone_to_cstring(dir, context.temp_allocator) return _ok_or_error(unix.sys_chdir(dir_cstr)) } -_get_full_path :: proc(fd: int, allocator := context.allocator) -> string { +_get_full_path :: proc(fd: int, allocator: runtime.Allocator) -> string { PROC_FD_PATH :: "/proc/self/fd/" buf: [32]u8 diff --git a/core/os/os2/path_windows.odin b/core/os/os2/path_windows.odin index 2dc667822..a2306784e 100644 --- a/core/os/os2/path_windows.odin +++ b/core/os/os2/path_windows.odin @@ -23,7 +23,7 @@ _mkdir_all :: proc(path: string, perm: File_Mode) -> Error { fix_root_directory :: proc(p: string) -> (s: string, allocated: bool, err: runtime.Allocator_Error) { if len(p) == len(`\\?\c:`) { if is_path_separator(p[0]) && is_path_separator(p[1]) && p[2] == '?' && is_path_separator(p[3]) && p[5] == ':' { - s = strings.concatenate_safe({p, `\`}, _file_allocator()) or_return + s = strings.concatenate({p, `\`}, _file_allocator()) or_return allocated = true return } diff --git a/core/os/os2/stat_linux.odin b/core/os/os2/stat_linux.odin index b627cef15..530e0e7d0 100644 --- a/core/os/os2/stat_linux.odin +++ b/core/os/os2/stat_linux.odin @@ -3,6 +3,7 @@ package os2 import "core:time" import "core:runtime" +import "core:strings" import "core:sys/unix" import "core:path/filepath" @@ -83,7 +84,7 @@ _Stat :: struct { } -_fstat :: proc(f: ^File, allocator := context.allocator) -> (File_Info, Error) { +_fstat :: proc(f: ^File, allocator: runtime.Allocator) -> (File_Info, Error) { return _fstat_internal(f.impl.fd, allocator) } @@ -111,11 +112,8 @@ _fstat_internal :: proc(fd: int, allocator: runtime.Allocator) -> (File_Info, Er } // NOTE: _stat and _lstat are using _fstat to avoid a race condition when populating fullpath -_stat :: proc(name: string, allocator := context.allocator) -> (File_Info, Error) { - name_cstr, allocated := _name_to_cstring(name) - defer if allocated { - delete(name_cstr) - } +_stat :: proc(name: string, allocator: runtime.Allocator) -> (File_Info, Error) { + name_cstr := strings.clone_to_cstring(name, context.temp_allocator) fd := unix.sys_open(name_cstr, _O_RDONLY) if fd < 0 { @@ -125,11 +123,9 @@ _stat :: proc(name: string, allocator := context.allocator) -> (File_Info, Error return _fstat_internal(fd, allocator) } -_lstat :: proc(name: string, allocator := context.allocator) -> (File_Info, Error) { - name_cstr, allocated := _name_to_cstring(name) - defer if allocated { - delete(name_cstr) - } +_lstat :: proc(name: string, allocator: runtime.Allocator) -> (File_Info, Error) { + name_cstr := strings.clone_to_cstring(name, context.temp_allocator) + fd := unix.sys_open(name_cstr, _O_RDONLY | _O_PATH | _O_NOFOLLOW) if fd < 0 { return {}, _get_platform_error(fd) @@ -143,10 +139,7 @@ _same_file :: proc(fi1, fi2: File_Info) -> bool { } _stat_internal :: proc(name: string) -> (s: _Stat, res: int) { - name_cstr, allocated := _name_to_cstring(name) - defer if allocated { - delete(name_cstr) - } + name_cstr := strings.clone_to_cstring(name, context.temp_allocator) res = unix.sys_stat(name_cstr, &s) return } diff --git a/core/os/os2/user.odin b/core/os/os2/user.odin index 00cccd2a7..0e9f126aa 100644 --- a/core/os/os2/user.odin +++ b/core/os/os2/user.odin @@ -8,12 +8,12 @@ user_cache_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Error case .Windows: dir = get_env("LocalAppData", allocator) if dir != "" { - dir = strings.clone_safe(dir, allocator) or_return + dir = strings.clone(dir, allocator) or_return } case .Darwin: dir = get_env("HOME", allocator) if dir != "" { - dir = strings.concatenate_safe({dir, "/Library/Caches"}, allocator) or_return + dir = strings.concatenate({dir, "/Library/Caches"}, allocator) or_return } case: // All other UNIX systems dir = get_env("XDG_CACHE_HOME", allocator) @@ -22,7 +22,7 @@ user_cache_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Error if dir == "" { return } - dir = strings.concatenate_safe({dir, "/.cache"}, allocator) or_return + dir = strings.concatenate({dir, "/.cache"}, allocator) or_return } } if dir == "" { @@ -36,12 +36,12 @@ user_config_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Erro case .Windows: dir = get_env("AppData", allocator) if dir != "" { - dir = strings.clone_safe(dir, allocator) or_return + dir = strings.clone(dir, allocator) or_return } case .Darwin: dir = get_env("HOME", allocator) if dir != "" { - dir = strings.concatenate_safe({dir, "/Library/Application Support"}, allocator) or_return + dir = strings.concatenate({dir, "/Library/Application Support"}, allocator) or_return } case: // All other UNIX systems dir = get_env("XDG_CACHE_HOME", allocator) @@ -50,7 +50,7 @@ user_config_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Erro if dir == "" { return } - dir = strings.concatenate_safe({dir, "/.config"}, allocator) or_return + dir = strings.concatenate({dir, "/.config"}, allocator) or_return } } if dir == "" { diff --git a/core/os/os_darwin.odin b/core/os/os_darwin.odin index b40edb410..ab05756ae 100644 --- a/core/os/os_darwin.odin +++ b/core/os/os_darwin.odin @@ -67,6 +67,7 @@ ENOPROTOOPT: Errno : 42 /* Protocol not available */ EPROTONOSUPPORT: Errno : 43 /* Protocol not supported */ ESOCKTNOSUPPORT: Errno : 44 /* Socket type not supported */ ENOTSUP: Errno : 45 /* Operation not supported */ +EOPNOTSUPP:: ENOTSUP EPFNOSUPPORT: Errno : 46 /* Protocol family not supported */ EAFNOSUPPORT: Errno : 47 /* Address family not supported by protocol family */ EADDRINUSE: Errno : 48 /* Address already in use */ @@ -179,6 +180,95 @@ RTLD_NODELETE :: 0x80 RTLD_NOLOAD :: 0x10 RTLD_FIRST :: 0x100 +SOL_SOCKET :: 0xFFFF + +SOCK_STREAM :: 1 +SOCK_DGRAM :: 2 +SOCK_RAW :: 3 +SOCK_RDM :: 4 +SOCK_SEQPACKET :: 5 + +SO_DEBUG :: 0x0001 +SO_ACCEPTCONN :: 0x0002 +SO_REUSEADDR :: 0x0004 +SO_KEEPALIVE :: 0x0008 +SO_DONTROUTE :: 0x0010 +SO_BROADCAST :: 0x0020 +SO_USELOOPBACK :: 0x0040 +SO_LINGER :: 0x0080 +SO_OOBINLINE :: 0x0100 +SO_REUSEPORT :: 0x0200 +SO_TIMESTAMP :: 0x0400 + +SO_DONTTRUNC :: 0x2000 +SO_WANTMORE :: 0x4000 +SO_WANTOOBFLAG :: 0x8000 +SO_SNDBUF :: 0x1001 +SO_RCVBUF :: 0x1002 +SO_SNDLOWAT :: 0x1003 +SO_RCVLOWAT :: 0x1004 +SO_SNDTIMEO :: 0x1005 +SO_RCVTIMEO :: 0x1006 +SO_ERROR :: 0x1007 +SO_TYPE :: 0x1008 +SO_PRIVSTATE :: 0x1009 +SO_NREAD :: 0x1020 +SO_NKE :: 0x1021 + +AF_UNSPEC :: 0 +AF_LOCAL :: 1 +AF_UNIX :: AF_LOCAL +AF_INET :: 2 +AF_IMPLINK :: 3 +AF_PUP :: 4 +AF_CHAOS :: 5 +AF_NS :: 6 +AF_ISO :: 7 +AF_OSI :: AF_ISO +AF_ECMA :: 8 +AF_DATAKIT :: 9 +AF_CCITT :: 10 +AF_SNA :: 11 +AF_DECnet :: 12 +AF_DLI :: 13 +AF_LAT :: 14 +AF_HYLINK :: 15 +AF_APPLETALK :: 16 +AF_ROUTE :: 17 +AF_LINK :: 18 +pseudo_AF_XTP :: 19 +AF_COIP :: 20 +AF_CNT :: 21 +pseudo_AF_RTIP :: 22 +AF_IPX :: 23 +AF_SIP :: 24 +pseudo_AF_PIP :: 25 +pseudo_AF_BLUE :: 26 +AF_NDRV :: 27 +AF_ISDN :: 28 +AF_E164 :: AF_ISDN +pseudo_AF_KEY :: 29 +AF_INET6 :: 30 +AF_NATM :: 31 +AF_SYSTEM :: 32 +AF_NETBIOS :: 33 +AF_PPP :: 34 + +TCP_NODELAY :: 0x01 +TCP_MAXSEG :: 0x02 +TCP_NOPUSH :: 0x04 +TCP_NOOPT :: 0x08 + +IPPROTO_ICMP :: 1 +IPPROTO_TCP :: 6 +IPPROTO_UDP :: 17 + +SHUT_RD :: 0 +SHUT_WR :: 1 +SHUT_RDWR :: 2 + +F_GETFL: int : 3 /* Get file flags */ +F_SETFL: int : 4 /* Set file flags */ // "Argv" arguments converted to Odin strings args := _alloc_command_line_arguments() @@ -224,6 +314,58 @@ Dirent :: struct { Dir :: distinct rawptr // DIR* +SOCKADDR :: struct #packed { + len: c.char, + family: c.char, + sa_data: [14]c.char, +} + +SOCKADDR_STORAGE_LH :: struct #packed { + len: c.char, + family: c.char, + __ss_pad1: [6]c.char, + __ss_align: i64, + __ss_pad2: [112]c.char, +} + +sockaddr_in :: struct #packed { + sin_len: c.char, + sin_family: c.char, + sin_port: u16be, + sin_addr: in_addr, + sin_zero: [8]c.char, +} + +sockaddr_in6 :: struct #packed { + sin6_len: c.char, + sin6_family: c.char, + sin6_port: u16be, + sin6_flowinfo: c.uint, + sin6_addr: in6_addr, + sin6_scope_id: c.uint, +} + +in_addr :: struct #packed { + s_addr: u32, +} + +in6_addr :: struct #packed { + s6_addr: [16]u8, +} + +Timeval :: struct { + seconds: i64, + microseconds: int, +} + +Linger :: struct { + onoff: int, + linger: int, +} + +Socket :: distinct int +socklen_t :: c.int + // File type S_IFMT :: 0o170000 // Type of file mask S_IFIFO :: 0o010000 // Named pipe (fifo) @@ -273,12 +415,14 @@ F_OK :: 0 // Test for file existance F_GETPATH :: 50 // return the full path of the fd foreign libc { - @(link_name="__error") __error :: proc() -> ^int --- + @(link_name="__error") __error :: proc() -> ^c.int --- @(link_name="open") _unix_open :: proc(path: cstring, flags: i32, mode: u16) -> Handle --- @(link_name="close") _unix_close :: proc(handle: Handle) -> c.int --- - @(link_name="read") _unix_read :: proc(handle: Handle, buffer: rawptr, count: int) -> int --- - @(link_name="write") _unix_write :: proc(handle: Handle, buffer: rawptr, count: int) -> int --- + @(link_name="read") _unix_read :: proc(handle: Handle, buffer: rawptr, count: c.size_t) -> int --- + @(link_name="write") _unix_write :: proc(handle: Handle, buffer: rawptr, count: c.size_t) -> int --- + @(link_name="pread") _unix_pread :: proc(handle: Handle, buffer: rawptr, count: c.size_t, offset: i64) -> int --- + @(link_name="pwrite") _unix_pwrite :: proc(handle: Handle, buffer: rawptr, count: c.size_t, offset: i64) -> int --- @(link_name="lseek") _unix_lseek :: proc(fs: Handle, offset: int, whence: int) -> int --- @(link_name="gettid") _unix_gettid :: proc() -> u64 --- @(link_name="getpagesize") _unix_getpagesize :: proc() -> i32 --- @@ -296,7 +440,7 @@ foreign libc { @(link_name="closedir") _unix_closedir :: proc(dirp: Dir) -> c.int --- @(link_name="rewinddir") _unix_rewinddir :: proc(dirp: Dir) --- - @(link_name="__fcntl") _unix__fcntl :: proc(fd: Handle, cmd: c.int, buf: ^byte) -> c.int --- + @(link_name="__fcntl") _unix__fcntl :: proc(fd: Handle, cmd: c.int, arg: uintptr) -> c.int --- @(link_name="rename") _unix_rename :: proc(old: cstring, new: cstring) -> c.int --- @(link_name="remove") _unix_remove :: proc(path: cstring) -> c.int --- @@ -314,6 +458,20 @@ foreign libc { @(link_name="realpath") _unix_realpath :: proc(path: cstring, resolved_path: rawptr) -> rawptr --- @(link_name="strerror") _darwin_string_error :: proc(num : c.int) -> cstring --- + @(link_name="sysctlbyname") _sysctlbyname :: proc(path: cstring, oldp: rawptr, oldlenp: rawptr, newp: rawptr, newlen: int) -> c.int --- + + @(link_name="socket") _unix_socket :: proc(domain: int, type: int, protocol: int) -> int --- + @(link_name="listen") _unix_listen :: proc(socket: int, backlog: int) -> int --- + @(link_name="accept") _unix_accept :: proc(socket: int, addr: rawptr, addr_len: rawptr) -> int --- + @(link_name="connect") _unix_connect :: proc(socket: int, addr: rawptr, addr_len: socklen_t) -> int --- + @(link_name="bind") _unix_bind :: proc(socket: int, addr: rawptr, addr_len: socklen_t) -> int --- + @(link_name="setsockopt") _unix_setsockopt :: proc(socket: int, level: int, opt_name: int, opt_val: rawptr, opt_len: socklen_t) -> int --- + @(link_name="getsockopt") _unix_getsockopt :: proc(socket: int, level: int, opt_name: int, opt_val: rawptr, opt_len: socklen_t) -> int --- + @(link_name="recvfrom") _unix_recvfrom :: proc(socket: int, buffer: rawptr, buffer_len: c.size_t, flags: int, addr: rawptr, addr_len: ^socklen_t) -> c.ssize_t --- + @(link_name="recv") _unix_recv :: proc(socket: int, buffer: rawptr, buffer_len: c.size_t, flags: int) -> c.ssize_t --- + @(link_name="sendto") _unix_sendto :: proc(socket: int, buffer: rawptr, buffer_len: c.size_t, flags: int, addr: rawptr, addr_len: socklen_t) -> c.ssize_t --- + @(link_name="send") _unix_send :: proc(socket: int, buffer: rawptr, buffer_len: c.size_t, flags: int) -> c.ssize_t --- + @(link_name="shutdown") _unix_shutdown :: proc(socket: int, how: int) -> int --- @(link_name="exit") _unix_exit :: proc(status: c.int) -> ! --- } @@ -334,7 +492,7 @@ foreign dl { } get_last_error :: proc "contextless" () -> int { - return __error()^ + return int(__error()^) } get_last_error_string :: proc() -> string { @@ -352,6 +510,7 @@ open :: proc(path: string, flags: int = O_RDWR, mode: int = 0) -> (Handle, Errno flags = O_RDONLY } + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() cstr := strings.clone_to_cstring(path, context.temp_allocator) handle := _unix_open(cstr, i32(flags), u16(mode)) if handle == -1 { @@ -384,45 +543,51 @@ close :: proc(fd: Handle) -> bool { @(private) MAX_RW :: 0x7fffffff // The limit on Darwin is max(i32), trying to read/write more than that fails. -write :: proc(fd: Handle, data: []u8) -> (int, Errno) { - assert(fd != -1) - - bytes_total := len(data) - bytes_written_total := 0 - - for bytes_written_total < bytes_total { - bytes_to_write := min(bytes_total - bytes_written_total, MAX_RW) - slice := data[bytes_written_total:bytes_written_total + bytes_to_write] - bytes_written := _unix_write(fd, raw_data(slice), bytes_to_write) - if bytes_written == -1 { - return bytes_written_total, 1 - } - bytes_written_total += bytes_written +write :: proc(fd: Handle, data: []byte) -> (int, Errno) { + if len(data) == 0 { + return 0, ERROR_NONE } - return bytes_written_total, 0 + bytes_written := _unix_write(fd, raw_data(data), c.size_t(len(data))) + if bytes_written < 0 { + return -1, Errno(get_last_error()) + } + return bytes_written, ERROR_NONE } read :: proc(fd: Handle, data: []u8) -> (int, Errno) { - assert(fd != -1) - - bytes_total := len(data) - bytes_read_total := 0 - - for bytes_read_total < bytes_total { - bytes_to_read := min(bytes_total - bytes_read_total, MAX_RW) - slice := data[bytes_read_total:bytes_read_total + bytes_to_read] - bytes_read := _unix_read(fd, raw_data(slice), bytes_to_read) - if bytes_read == -1 { - return bytes_read_total, 1 - } - if bytes_read == 0 { - break - } - bytes_read_total += bytes_read + if len(data) == 0 { + return 0, ERROR_NONE } - return bytes_read_total, 0 + bytes_read := _unix_read(fd, raw_data(data), c.size_t(len(data))) + if bytes_read < 0 { + return -1, Errno(get_last_error()) + } + return bytes_read, ERROR_NONE +} +read_at :: proc(fd: Handle, data: []byte, offset: i64) -> (int, Errno) { + if len(data) == 0 { + return 0, ERROR_NONE + } + + bytes_read := _unix_pread(fd, raw_data(data), c.size_t(len(data)), offset) + if bytes_read < 0 { + return -1, Errno(get_last_error()) + } + return bytes_read, ERROR_NONE +} + +write_at :: proc(fd: Handle, data: []byte, offset: i64) -> (int, Errno) { + if len(data) == 0 { + return 0, ERROR_NONE + } + + bytes_written := _unix_pwrite(fd, raw_data(data), c.size_t(len(data)), offset) + if bytes_written < 0 { + return -1, Errno(get_last_error()) + } + return bytes_written, ERROR_NONE } seek :: proc(fd: Handle, offset: i64, whence: int) -> (i64, Errno) { @@ -507,24 +672,28 @@ is_file :: proc {is_file_path, is_file_handle} is_dir :: proc {is_dir_path, is_dir_handle} exists :: proc(path: string) -> bool { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() cpath := strings.clone_to_cstring(path, context.temp_allocator) res := _unix_access(cpath, O_RDONLY) return res == 0 } rename :: proc(old: string, new: string) -> bool { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() old_cstr := strings.clone_to_cstring(old, context.temp_allocator) new_cstr := strings.clone_to_cstring(new, context.temp_allocator) return _unix_rename(old_cstr, new_cstr) != -1 } remove :: proc(path: string) -> bool { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() path_cstr := strings.clone_to_cstring(path, context.temp_allocator) return _unix_remove(path_cstr) != -1 } @private _stat :: proc(path: string) -> (OS_Stat, Errno) { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() cstr := strings.clone_to_cstring(path, context.temp_allocator) s: OS_Stat @@ -537,6 +706,7 @@ _stat :: proc(path: string) -> (OS_Stat, Errno) { @private _lstat :: proc(path: string) -> (OS_Stat, Errno) { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() cstr := strings.clone_to_cstring(path, context.temp_allocator) s: OS_Stat @@ -602,6 +772,7 @@ _readdir :: proc(dirp: Dir) -> (entry: Dirent, err: Errno, end_of_stream: bool) @private _readlink :: proc(path: string) -> (string, Errno) { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD(ignore = context.temp_allocator == context.allocator) path_cstr := strings.clone_to_cstring(path, context.temp_allocator) bufsz : uint = 256 @@ -623,14 +794,14 @@ _readlink :: proc(path: string) -> (string, Errno) { } absolute_path_from_handle :: proc(fd: Handle) -> (string, Errno) { - buf : [256]byte - res := _unix__fcntl(fd, F_GETPATH, &buf[0]) - if res != 0 { - return "", Errno(get_last_error()) + buf: [DARWIN_MAXPATHLEN]byte + _, err := fcntl(int(fd), F_GETPATH, int(uintptr(&buf[0]))) + if err != ERROR_NONE { + return "", err } path := strings.clone_from_cstring(cstring(&buf[0])) - return path, ERROR_NONE + return path, err } absolute_path_from_relative :: proc(rel: string) -> (path: string, err: Errno) { @@ -639,6 +810,7 @@ absolute_path_from_relative :: proc(rel: string) -> (path: string, err: Errno) { rel = "." } + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD(ignore = context.temp_allocator == context.allocator) rel_cstr := strings.clone_to_cstring(rel, context.temp_allocator) path_ptr := _unix_realpath(rel_cstr, nil) @@ -654,6 +826,7 @@ absolute_path_from_relative :: proc(rel: string) -> (path: string, err: Errno) { } access :: proc(path: string, mask: int) -> bool { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() cstr := strings.clone_to_cstring(path, context.temp_allocator) return _unix_access(cstr, mask) == 0 } @@ -678,6 +851,7 @@ heap_free :: proc(ptr: rawptr) { } lookup_env :: proc(key: string, allocator := context.allocator) -> (value: string, found: bool) { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD(ignore = context.temp_allocator == allocator) path_str := strings.clone_to_cstring(key, context.temp_allocator) cstr := _unix_getenv(path_str) if cstr == nil { @@ -700,6 +874,7 @@ get_current_directory :: proc() -> string { return string(cwd) } if Errno(get_last_error()) != ERANGE { + delete(buf) return "" } resize(&buf, len(buf)+page_size) @@ -708,6 +883,7 @@ get_current_directory :: proc() -> string { } set_current_directory :: proc(path: string) -> (err: Errno) { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() cstr := strings.clone_to_cstring(path, context.temp_allocator) res := _unix_chdir(cstr) if res == -1 { @@ -717,6 +893,7 @@ set_current_directory :: proc(path: string) -> (err: Errno) { } make_directory :: proc(path: string, mode: u16 = 0o775) -> Errno { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() path_cstr := strings.clone_to_cstring(path, context.temp_allocator) res := _unix_mkdir(path_cstr, mode) if res == -1 { @@ -741,12 +918,14 @@ current_thread_id :: proc "contextless" () -> int { } dlopen :: proc(filename: string, flags: int) -> rawptr { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() cstr := strings.clone_to_cstring(filename, context.temp_allocator) handle := _unix_dlopen(cstr, flags) return handle } dlsym :: proc(handle: rawptr, symbol: string) -> rawptr { assert(handle != nil) + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() cstr := strings.clone_to_cstring(symbol, context.temp_allocator) proc_handle := _unix_dlsym(handle, cstr) return proc_handle @@ -771,11 +950,127 @@ get_page_size :: proc() -> int { return page_size } +@(private) +_processor_core_count :: proc() -> int { + count : int = 0 + count_size := size_of(count) + if _sysctlbyname("hw.logicalcpu", &count, &count_size, nil, 0) == 0 { + if count > 0 { + return count + } + } + + return 1 +} _alloc_command_line_arguments :: proc() -> []string { res := make([]string, len(runtime.args__)) - for arg, i in runtime.args__ { - res[i] = string(arg) + for _, i in res { + res[i] = string(runtime.args__[i]) } return res } + +socket :: proc(domain: int, type: int, protocol: int) -> (Socket, Errno) { + result := _unix_socket(domain, type, protocol) + if result < 0 { + return 0, Errno(get_last_error()) + } + return Socket(result), ERROR_NONE +} + +connect :: proc(sd: Socket, addr: ^SOCKADDR, len: socklen_t) -> (Errno) { + result := _unix_connect(int(sd), addr, len) + if result < 0 { + return Errno(get_last_error()) + } + return ERROR_NONE +} + +bind :: proc(sd: Socket, addr: ^SOCKADDR, len: socklen_t) -> (Errno) { + result := _unix_bind(int(sd), addr, len) + if result < 0 { + return Errno(get_last_error()) + } + return ERROR_NONE +} + +accept :: proc(sd: Socket, addr: ^SOCKADDR, len: rawptr) -> (Socket, Errno) { + result := _unix_accept(int(sd), rawptr(addr), len) + if result < 0 { + return 0, Errno(get_last_error()) + } + return Socket(result), ERROR_NONE +} + +listen :: proc(sd: Socket, backlog: int) -> (Errno) { + result := _unix_listen(int(sd), backlog) + if result < 0 { + return Errno(get_last_error()) + } + return ERROR_NONE +} + +setsockopt :: proc(sd: Socket, level: int, optname: int, optval: rawptr, optlen: socklen_t) -> (Errno) { + result := _unix_setsockopt(int(sd), level, optname, optval, optlen) + if result < 0 { + return Errno(get_last_error()) + } + return ERROR_NONE +} + +getsockopt :: proc(sd: Socket, level: int, optname: int, optval: rawptr, optlen: socklen_t) -> Errno { + result := _unix_getsockopt(int(sd), level, optname, optval, optlen) + if result < 0 { + return Errno(get_last_error()) + } + return ERROR_NONE +} + +recvfrom :: proc(sd: Socket, data: []byte, flags: int, addr: ^SOCKADDR, addr_size: ^socklen_t) -> (u32, Errno) { + result := _unix_recvfrom(int(sd), raw_data(data), len(data), flags, addr, addr_size) + if result < 0 { + return 0, Errno(get_last_error()) + } + return u32(result), ERROR_NONE +} + +recv :: proc(sd: Socket, data: []byte, flags: int) -> (u32, Errno) { + result := _unix_recv(int(sd), raw_data(data), len(data), flags) + if result < 0 { + return 0, Errno(get_last_error()) + } + return u32(result), ERROR_NONE +} + +sendto :: proc(sd: Socket, data: []u8, flags: int, addr: ^SOCKADDR, addrlen: socklen_t) -> (u32, Errno) { + result := _unix_sendto(int(sd), raw_data(data), len(data), flags, addr, addrlen) + if result < 0 { + return 0, Errno(get_last_error()) + } + return u32(result), ERROR_NONE +} + +send :: proc(sd: Socket, data: []byte, flags: int) -> (u32, Errno) { + result := _unix_send(int(sd), raw_data(data), len(data), 0) + if result < 0 { + return 0, Errno(get_last_error()) + } + return u32(result), ERROR_NONE +} + +shutdown :: proc(sd: Socket, how: int) -> (Errno) { + result := _unix_shutdown(int(sd), how) + if result < 0 { + return Errno(get_last_error()) + } + return ERROR_NONE +} + +fcntl :: proc(fd: int, cmd: int, arg: int) -> (int, Errno) { + result := _unix__fcntl(Handle(fd), c.int(cmd), uintptr(arg)) + if result < 0 { + return 0, Errno(get_last_error()) + } + return int(result), ERROR_NONE +} diff --git a/core/os/os_freebsd.odin b/core/os/os_freebsd.odin index 2a0381a5d..c2ea82bf5 100644 --- a/core/os/os_freebsd.odin +++ b/core/os/os_freebsd.odin @@ -287,6 +287,7 @@ foreign libc { @(link_name="getenv") _unix_getenv :: proc(cstring) -> cstring --- @(link_name="realpath") _unix_realpath :: proc(path: cstring, resolved_path: rawptr) -> rawptr --- + @(link_name="sysctlbyname") _sysctlbyname :: proc(path: cstring, oldp: rawptr, oldlenp: rawptr, newp: rawptr, newlen: int) -> c.int --- @(link_name="exit") _unix_exit :: proc(status: c.int) -> ! --- } @@ -308,6 +309,7 @@ get_last_error :: proc "contextless" () -> int { } open :: proc(path: string, flags: int = O_RDONLY, mode: int = 0) -> (Handle, Errno) { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() cstr := strings.clone_to_cstring(path, context.temp_allocator) handle := _unix_open(cstr, c.int(flags), c.int(mode)) if handle == -1 { @@ -360,6 +362,7 @@ file_size :: proc(fd: Handle) -> (i64, Errno) { } rename :: proc(old_path, new_path: string) -> Errno { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() old_path_cstr := strings.clone_to_cstring(old_path, context.temp_allocator) new_path_cstr := strings.clone_to_cstring(new_path, context.temp_allocator) res := _unix_rename(old_path_cstr, new_path_cstr) @@ -370,6 +373,7 @@ rename :: proc(old_path, new_path: string) -> Errno { } remove :: proc(path: string) -> Errno { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() path_cstr := strings.clone_to_cstring(path, context.temp_allocator) res := _unix_unlink(path_cstr) if res == -1 { @@ -379,6 +383,7 @@ remove :: proc(path: string) -> Errno { } make_directory :: proc(path: string, mode: mode_t = 0o775) -> Errno { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() path_cstr := strings.clone_to_cstring(path, context.temp_allocator) res := _unix_mkdir(path_cstr, mode) if res == -1 { @@ -388,6 +393,7 @@ make_directory :: proc(path: string, mode: mode_t = 0o775) -> Errno { } remove_directory :: proc(path: string) -> Errno { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() path_cstr := strings.clone_to_cstring(path, context.temp_allocator) res := _unix_rmdir(path_cstr) if res == -1 { @@ -473,6 +479,7 @@ last_write_time_by_name :: proc(name: string) -> (File_Time, Errno) { @private _stat :: proc(path: string) -> (OS_Stat, Errno) { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() cstr := strings.clone_to_cstring(path, context.temp_allocator) s: OS_Stat = --- result := _unix_lstat(cstr, &s) @@ -484,6 +491,7 @@ _stat :: proc(path: string) -> (OS_Stat, Errno) { @private _lstat :: proc(path: string) -> (OS_Stat, Errno) { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() cstr := strings.clone_to_cstring(path, context.temp_allocator) // deliberately uninitialized @@ -549,6 +557,8 @@ _readdir :: proc(dirp: Dir) -> (entry: Dirent, err: Errno, end_of_stream: bool) @private _readlink :: proc(path: string) -> (string, Errno) { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD(ignore = context.temp_allocator == context.allocator) + path_cstr := strings.clone_to_cstring(path, context.temp_allocator) bufsz : uint = MAX_PATH @@ -566,7 +576,8 @@ _readlink :: proc(path: string) -> (string, Errno) { return strings.string_from_ptr(&buf[0], rc), ERROR_NONE } } - unreachable() + + return "", Errno{} } // XXX FreeBSD @@ -579,6 +590,7 @@ absolute_path_from_relative :: proc(rel: string) -> (path: string, err: Errno) { if rel == "" { rel = "." } + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD(ignore = context.temp_allocator == context.allocator) rel_cstr := strings.clone_to_cstring(rel, context.temp_allocator) @@ -595,6 +607,8 @@ absolute_path_from_relative :: proc(rel: string) -> (path: string, err: Errno) { } access :: proc(path: string, mask: int) -> (bool, Errno) { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() + cstr := strings.clone_to_cstring(path, context.temp_allocator) result := _unix_access(cstr, c.int(mask)) if result == -1 { @@ -625,6 +639,8 @@ heap_free :: proc(ptr: rawptr) { } lookup_env :: proc(key: string, allocator := context.allocator) -> (value: string, found: bool) { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD(ignore = context.temp_allocator == allocator) + path_str := strings.clone_to_cstring(key, context.temp_allocator) cstr := _unix_getenv(path_str) if cstr == nil { @@ -650,6 +666,7 @@ get_current_directory :: proc() -> string { return string(cwd) } if Errno(get_last_error()) != ERANGE { + delete(buf) return "" } resize(&buf, len(buf)+page_size) @@ -658,6 +675,7 @@ get_current_directory :: proc() -> string { } set_current_directory :: proc(path: string) -> (err: Errno) { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() cstr := strings.clone_to_cstring(path, context.temp_allocator) res := _unix_chdir(cstr) if res == -1 do return Errno(get_last_error()) @@ -674,12 +692,14 @@ current_thread_id :: proc "contextless" () -> int { } dlopen :: proc(filename: string, flags: int) -> rawptr { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() cstr := strings.clone_to_cstring(filename, context.temp_allocator) handle := _unix_dlopen(cstr, c.int(flags)) return handle } dlsym :: proc(handle: rawptr, symbol: string) -> rawptr { assert(handle != nil) + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() cstr := strings.clone_to_cstring(symbol, context.temp_allocator) proc_handle := _unix_dlsym(handle, cstr) return proc_handle @@ -702,6 +722,19 @@ get_page_size :: proc() -> int { return page_size } +@(private) +_processor_core_count :: proc() -> int { + count : int = 0 + count_size := size_of(count) + if _sysctlbyname("hw.logicalcpu", &count, &count_size, nil, 0) == 0 { + if count > 0 { + return count + } + } + + return 1 +} + _alloc_command_line_arguments :: proc() -> []string { res := make([]string, len(runtime.args__)) diff --git a/core/os/os_js.odin b/core/os/os_js.odin index ba65aa073..5d7eb784e 100644 --- a/core/os/os_js.odin +++ b/core/os/os_js.odin @@ -1,4 +1,277 @@ -//+js +//+build js package os -#panic("package os does not support a js target") \ No newline at end of file +import "core:intrinsics" +import "core:runtime" +import "core:unicode/utf16" + +is_path_separator :: proc(c: byte) -> bool { + return c == '/' || c == '\\' +} + +open :: proc(path: string, mode: int = O_RDONLY, perm: int = 0) -> (Handle, Errno) { + unimplemented("core:os procedure not supported on JS target") +} + +close :: proc(fd: Handle) -> Errno { + unimplemented("core:os procedure not supported on JS target") +} + +flush :: proc(fd: Handle) -> (err: Errno) { + unimplemented("core:os procedure not supported on JS target") +} + + + +write :: proc(fd: Handle, data: []byte) -> (int, Errno) { + unimplemented("core:os procedure not supported on JS target") +} + +@(private="file") +read_console :: proc(handle: Handle, b: []byte) -> (n: int, err: Errno) { + unimplemented("core:os procedure not supported on JS target") +} + +read :: proc(fd: Handle, data: []byte) -> (int, Errno) { + unimplemented("core:os procedure not supported on JS target") +} + +seek :: proc(fd: Handle, offset: i64, whence: int) -> (i64, Errno) { + unimplemented("core:os procedure not supported on JS target") +} + +file_size :: proc(fd: Handle) -> (i64, Errno) { + unimplemented("core:os procedure not supported on JS target") +} + + +@(private) +MAX_RW :: 1<<30 + +@(private) +pread :: proc(fd: Handle, data: []byte, offset: i64) -> (int, Errno) { + unimplemented("core:os procedure not supported on JS target") +} +@(private) +pwrite :: proc(fd: Handle, data: []byte, offset: i64) -> (int, Errno) { + unimplemented("core:os procedure not supported on JS target") +} + +read_at :: proc(fd: Handle, data: []byte, offset: i64) -> (n: int, err: Errno) { + unimplemented("core:os procedure not supported on JS target") +} +write_at :: proc(fd: Handle, data: []byte, offset: i64) -> (n: int, err: Errno) { + unimplemented("core:os procedure not supported on JS target") +} + + + +// NOTE(bill): Uses startup to initialize it +//stdin := get_std_handle(uint(win32.STD_INPUT_HANDLE)) +//stdout := get_std_handle(uint(win32.STD_OUTPUT_HANDLE)) +//stderr := get_std_handle(uint(win32.STD_ERROR_HANDLE)) + + +get_std_handle :: proc "contextless" (h: uint) -> Handle { + context = runtime.default_context() + unimplemented("core:os procedure not supported on JS target") +} + + +exists :: proc(path: string) -> bool { + unimplemented("core:os procedure not supported on JS target") +} + +is_file :: proc(path: string) -> bool { + unimplemented("core:os procedure not supported on JS target") +} + +is_dir :: proc(path: string) -> bool { + unimplemented("core:os procedure not supported on JS target") +} + +// NOTE(tetra): GetCurrentDirectory is not thread safe with SetCurrentDirectory and GetFullPathName +//@private cwd_lock := win32.SRWLOCK{} // zero is initialized + +get_current_directory :: proc(allocator := context.allocator) -> string { + unimplemented("core:os procedure not supported on JS target") +} + +set_current_directory :: proc(path: string) -> (err: Errno) { + unimplemented("core:os procedure not supported on JS target") +} + + + +change_directory :: proc(path: string) -> (err: Errno) { + unimplemented("core:os procedure not supported on JS target") +} + +make_directory :: proc(path: string, mode: u32 = 0) -> (err: Errno) { + unimplemented("core:os procedure not supported on JS target") +} + + +remove_directory :: proc(path: string) -> (err: Errno) { + unimplemented("core:os procedure not supported on JS target") +} + + + +@(private) +is_abs :: proc(path: string) -> bool { + unimplemented("core:os procedure not supported on JS target") +} + +@(private) +fix_long_path :: proc(path: string) -> string { + unimplemented("core:os procedure not supported on JS target") +} + + +link :: proc(old_name, new_name: string) -> (err: Errno) { + unimplemented("core:os procedure not supported on JS target") +} + +unlink :: proc(path: string) -> (err: Errno) { + unimplemented("core:os procedure not supported on JS target") +} + + + +rename :: proc(old_path, new_path: string) -> (err: Errno) { + unimplemented("core:os procedure not supported on JS target") +} + + +ftruncate :: proc(fd: Handle, length: i64) -> (err: Errno) { + unimplemented("core:os procedure not supported on JS target") +} + +truncate :: proc(path: string, length: i64) -> (err: Errno) { + unimplemented("core:os procedure not supported on JS target") +} + + +remove :: proc(name: string) -> Errno { + unimplemented("core:os procedure not supported on JS target") +} + + +pipe :: proc() -> (r, w: Handle, err: Errno) { + unimplemented("core:os procedure not supported on JS target") +} + +read_dir :: proc(fd: Handle, n: int, allocator := context.allocator) -> (fi: []File_Info, err: Errno) { + unimplemented("core:os procedure not supported on JS target") +} + +Handle :: distinct uintptr +File_Time :: distinct u64 +Errno :: distinct int + + +INVALID_HANDLE :: ~Handle(0) + + + +O_RDONLY :: 0x00000 +O_WRONLY :: 0x00001 +O_RDWR :: 0x00002 +O_CREATE :: 0x00040 +O_EXCL :: 0x00080 +O_NOCTTY :: 0x00100 +O_TRUNC :: 0x00200 +O_NONBLOCK :: 0x00800 +O_APPEND :: 0x00400 +O_SYNC :: 0x01000 +O_ASYNC :: 0x02000 +O_CLOEXEC :: 0x80000 + + +ERROR_NONE: Errno : 0 +ERROR_FILE_NOT_FOUND: Errno : 2 +ERROR_PATH_NOT_FOUND: Errno : 3 +ERROR_ACCESS_DENIED: Errno : 5 +ERROR_INVALID_HANDLE: Errno : 6 +ERROR_NOT_ENOUGH_MEMORY: Errno : 8 +ERROR_NO_MORE_FILES: Errno : 18 +ERROR_HANDLE_EOF: Errno : 38 +ERROR_NETNAME_DELETED: Errno : 64 +ERROR_FILE_EXISTS: Errno : 80 +ERROR_INVALID_PARAMETER: Errno : 87 +ERROR_BROKEN_PIPE: Errno : 109 +ERROR_BUFFER_OVERFLOW: Errno : 111 +ERROR_INSUFFICIENT_BUFFER: Errno : 122 +ERROR_MOD_NOT_FOUND: Errno : 126 +ERROR_PROC_NOT_FOUND: Errno : 127 +ERROR_DIR_NOT_EMPTY: Errno : 145 +ERROR_ALREADY_EXISTS: Errno : 183 +ERROR_ENVVAR_NOT_FOUND: Errno : 203 +ERROR_MORE_DATA: Errno : 234 +ERROR_OPERATION_ABORTED: Errno : 995 +ERROR_IO_PENDING: Errno : 997 +ERROR_NOT_FOUND: Errno : 1168 +ERROR_PRIVILEGE_NOT_HELD: Errno : 1314 +WSAEACCES: Errno : 10013 +WSAECONNRESET: Errno : 10054 + +// Windows reserves errors >= 1<<29 for application use +ERROR_FILE_IS_PIPE: Errno : 1<<29 + 0 +ERROR_FILE_IS_NOT_DIR: Errno : 1<<29 + 1 +ERROR_NEGATIVE_OFFSET: Errno : 1<<29 + 2 + +// "Argv" arguments converted to Odin strings +args := _alloc_command_line_arguments() + + + + + +last_write_time :: proc(fd: Handle) -> (File_Time, Errno) { + unimplemented("core:os procedure not supported on JS target") +} + +last_write_time_by_name :: proc(name: string) -> (File_Time, Errno) { + unimplemented("core:os procedure not supported on JS target") +} + + + +heap_alloc :: proc(size: int, zero_memory := true) -> rawptr { + unimplemented("core:os procedure not supported on JS target") +} +heap_resize :: proc(ptr: rawptr, new_size: int) -> rawptr { + unimplemented("core:os procedure not supported on JS target") +} +heap_free :: proc(ptr: rawptr) { + unimplemented("core:os procedure not supported on JS target") +} + +get_page_size :: proc() -> int { + unimplemented("core:os procedure not supported on JS target") +} + +@(private) +_processor_core_count :: proc() -> int { + unimplemented("core:os procedure not supported on JS target") +} + +exit :: proc "contextless" (code: int) -> ! { + context = runtime.default_context() + unimplemented("core:os procedure not supported on JS target") +} + + + +current_thread_id :: proc "contextless" () -> int { + context = runtime.default_context() + unimplemented("core:os procedure not supported on JS target") +} + + + +_alloc_command_line_arguments :: proc() -> []string { + return nil +} + diff --git a/core/os/os_linux.odin b/core/os/os_linux.odin index ac40b8cde..e0b60fd36 100644 --- a/core/os/os_linux.odin +++ b/core/os/os_linux.odin @@ -14,6 +14,7 @@ Handle :: distinct i32 Pid :: distinct i32 File_Time :: distinct u64 Errno :: distinct i32 +Socket :: distinct int INVALID_HANDLE :: ~Handle(0) @@ -171,6 +172,64 @@ SEEK_DATA :: 3 SEEK_HOLE :: 4 SEEK_MAX :: SEEK_HOLE + +AF_UNSPEC: int : 0 +AF_UNIX: int : 1 +AF_LOCAL: int : AF_UNIX +AF_INET: int : 2 +AF_INET6: int : 10 +AF_PACKET: int : 17 +AF_BLUETOOTH: int : 31 + +SOCK_STREAM: int : 1 +SOCK_DGRAM: int : 2 +SOCK_RAW: int : 3 +SOCK_RDM: int : 4 +SOCK_SEQPACKET: int : 5 +SOCK_PACKET: int : 10 + +INADDR_ANY: c.ulong : 0 +INADDR_BROADCAST: c.ulong : 0xffffffff +INADDR_NONE: c.ulong : 0xffffffff +INADDR_DUMMY: c.ulong : 0xc0000008 + +IPPROTO_IP: int : 0 +IPPROTO_ICMP: int : 1 +IPPROTO_TCP: int : 6 +IPPROTO_UDP: int : 17 +IPPROTO_IPV6: int : 41 +IPPROTO_ETHERNET: int : 143 +IPPROTO_RAW: int : 255 + +SHUT_RD: int : 0 +SHUT_WR: int : 1 +SHUT_RDWR: int : 2 + + +SOL_SOCKET: int : 1 +SO_DEBUG: int : 1 +SO_REUSEADDR: int : 2 +SO_DONTROUTE: int : 5 +SO_BROADCAST: int : 6 +SO_SNDBUF: int : 7 +SO_RCVBUF: int : 8 +SO_KEEPALIVE: int : 9 +SO_OOBINLINE: int : 10 +SO_LINGER: int : 13 +SO_REUSEPORT: int : 15 +SO_RCVTIMEO_NEW: int : 66 +SO_SNDTIMEO_NEW: int : 67 + +TCP_NODELAY: int : 1 +TCP_CORK: int : 3 + +MSG_TRUNC : int : 0x20 + +// TODO: add remaining fcntl commands +// reference: https://github.com/torvalds/linux/blob/master/include/uapi/asm-generic/fcntl.h +F_GETFL: int : 3 /* Get file flags */ +F_SETFL: int : 4 /* Set file flags */ + // NOTE(zangent): These are OS specific! // Do not mix these up! RTLD_LAZY :: 0x001 @@ -178,6 +237,13 @@ RTLD_NOW :: 0x002 RTLD_BINDING_MASK :: 0x3 RTLD_GLOBAL :: 0x100 +socklen_t :: c.int + +Timeval :: struct { + seconds: i64, + microseconds: int, +} + // "Argv" arguments converted to Odin strings args := _alloc_command_line_arguments() @@ -217,6 +283,102 @@ Dirent :: struct { name: [256]byte, } +ADDRESS_FAMILY :: u16 +SOCKADDR :: struct #packed { + sa_family: ADDRESS_FAMILY, + sa_data: [14]c.char, +} + +SOCKADDR_STORAGE_LH :: struct #packed { + ss_family: ADDRESS_FAMILY, + __ss_pad1: [6]c.char, + __ss_align: i64, + __ss_pad2: [112]c.char, +} + +sockaddr_in :: struct #packed { + sin_family: ADDRESS_FAMILY, + sin_port: u16be, + sin_addr: in_addr, + sin_zero: [8]c.char, +} + +sockaddr_in6 :: struct #packed { + sin6_family: ADDRESS_FAMILY, + sin6_port: u16be, + sin6_flowinfo: c.ulong, + sin6_addr: in6_addr, + sin6_scope_id: c.ulong, +} + +in_addr :: struct #packed { + s_addr: u32, +} + +in6_addr :: struct #packed { + s6_addr: [16]u8, +} + +rtnl_link_stats :: struct #packed { + rx_packets: u32, + tx_packets: u32, + rx_bytes: u32, + tx_bytes: u32, + rx_errors: u32, + tx_errors: u32, + rx_dropped: u32, + tx_dropped: u32, + multicast: u32, + collisions: u32, + rx_length_errors: u32, + rx_over_errors: u32, + rx_crc_errors: u32, + rx_frame_errors: u32, + rx_fifo_errors: u32, + rx_missed_errors: u32, + tx_aborted_errors: u32, + tx_carrier_errors: u32, + tx_fifo_errors: u32, + tx_heartbeat_errors: u32, + tx_window_errors: u32, + rx_compressed: u32, + tx_compressed: u32, + rx_nohandler: u32, +} + +SIOCGIFFLAG :: enum c.int { + UP = 0, /* Interface is up. */ + BROADCAST = 1, /* Broadcast address valid. */ + DEBUG = 2, /* Turn on debugging. */ + LOOPBACK = 3, /* Is a loopback net. */ + POINT_TO_POINT = 4, /* Interface is point-to-point link. */ + NO_TRAILERS = 5, /* Avoid use of trailers. */ + RUNNING = 6, /* Resources allocated. */ + NOARP = 7, /* No address resolution protocol. */ + PROMISC = 8, /* Receive all packets. */ + ALL_MULTI = 9, /* Receive all multicast packets. Unimplemented. */ + MASTER = 10, /* Master of a load balancer. */ + SLAVE = 11, /* Slave of a load balancer. */ + MULTICAST = 12, /* Supports multicast. */ + PORTSEL = 13, /* Can set media type. */ + AUTOMEDIA = 14, /* Auto media select active. */ + DYNAMIC = 15, /* Dialup device with changing addresses. */ + LOWER_UP = 16, + DORMANT = 17, + ECHO = 18, +} +SIOCGIFFLAGS :: bit_set[SIOCGIFFLAG; c.int] + +ifaddrs :: struct { + next: ^ifaddrs, + name: cstring, + flags: SIOCGIFFLAGS, + address: ^SOCKADDR, + netmask: ^SOCKADDR, + broadcast_or_dest: ^SOCKADDR, // Broadcast or Point-to-Point address + data: rawptr, // Address-specific data. +} + Dir :: distinct rawptr // DIR* // File type @@ -236,13 +398,13 @@ S_IRUSR :: 0o0400 // R for owner S_IWUSR :: 0o0200 // W for owner S_IXUSR :: 0o0100 // X for owner - // Read, write, execute/search by group +// Read, write, execute/search by group S_IRWXG :: 0o0070 // RWX mask for group S_IRGRP :: 0o0040 // R for group S_IWGRP :: 0o0020 // W for group S_IXGRP :: 0o0010 // X for group - // Read, write, execute/search by others +// Read, write, execute/search by others S_IRWXO :: 0o0007 // RWX mask for other S_IROTH :: 0o0004 // R for other S_IWOTH :: 0o0002 // W for other @@ -270,140 +432,19 @@ AT_FDCWD :: ~uintptr(99) /* -100 */ AT_REMOVEDIR :: uintptr(0x200) AT_SYMLINK_NOFOLLOW :: uintptr(0x100) -_unix_personality :: proc(persona: u64) -> int { - return int(intrinsics.syscall(unix.SYS_personality, uintptr(persona))) +pollfd :: struct { + fd: c.int, + events: c.short, + revents: c.short, } -_unix_fork :: proc() -> Pid { - when ODIN_ARCH != .arm64 { - res := int(intrinsics.syscall(unix.SYS_fork)) - } else { - res := int(intrinsics.syscall(unix.SYS_clone, unix.SIGCHLD)) - } - return -1 if res < 0 else Pid(res) -} - -_unix_open :: proc(path: cstring, flags: int, mode: int = 0o000) -> Handle { - when ODIN_ARCH != .arm64 { - res := int(intrinsics.syscall(unix.SYS_open, uintptr(rawptr(path)), uintptr(flags), uintptr(mode))) - } else { // NOTE: arm64 does not have open - res := int(intrinsics.syscall(unix.SYS_openat, AT_FDCWD, uintptr(rawptr(path)), uintptr(flags), uintptr(mode))) - } - return -1 if res < 0 else Handle(res) -} - -_unix_close :: proc(fd: Handle) -> int { - return int(intrinsics.syscall(unix.SYS_close, uintptr(fd))) -} - -_unix_read :: proc(fd: Handle, buf: rawptr, size: uint) -> int { - return int(intrinsics.syscall(unix.SYS_read, uintptr(fd), uintptr(buf), uintptr(size))) -} - -_unix_write :: proc(fd: Handle, buf: rawptr, size: uint) -> int { - return int(intrinsics.syscall(unix.SYS_write, uintptr(fd), uintptr(buf), uintptr(size))) -} - -_unix_seek :: proc(fd: Handle, offset: i64, whence: int) -> i64 { - when ODIN_ARCH == .amd64 || ODIN_ARCH == .arm64 { - return i64(intrinsics.syscall(unix.SYS_lseek, uintptr(fd), uintptr(offset), uintptr(whence))) - } else { - low := uintptr(offset & 0xFFFFFFFF) - high := uintptr(offset >> 32) - result: i64 - res := i64(intrinsics.syscall(unix.SYS__llseek, uintptr(fd), high, low, uintptr(&result), uintptr(whence))) - return -1 if res < 0 else result - } -} - -_unix_stat :: proc(path: cstring, stat: ^OS_Stat) -> int { - when ODIN_ARCH == .amd64 { - return int(intrinsics.syscall(unix.SYS_stat, uintptr(rawptr(path)), uintptr(stat))) - } else when ODIN_ARCH != .arm64 { - return int(intrinsics.syscall(unix.SYS_stat64, uintptr(rawptr(path)), uintptr(stat))) - } else { // NOTE: arm64 does not have stat - return int(intrinsics.syscall(unix.SYS_fstatat, AT_FDCWD, uintptr(rawptr(path)), uintptr(stat), 0)) - } -} - -_unix_fstat :: proc(fd: Handle, stat: ^OS_Stat) -> int { - when ODIN_ARCH == .amd64 || ODIN_ARCH == .arm64 { - return int(intrinsics.syscall(unix.SYS_fstat, uintptr(fd), uintptr(stat))) - } else { - return int(intrinsics.syscall(unix.SYS_fstat64, uintptr(fd), uintptr(stat))) - } -} - -_unix_lstat :: proc(path: cstring, stat: ^OS_Stat) -> int { - when ODIN_ARCH == .amd64 { - return int(intrinsics.syscall(unix.SYS_lstat, uintptr(rawptr(path)), uintptr(stat))) - } else when ODIN_ARCH != .arm64 { - return int(intrinsics.syscall(unix.SYS_lstat64, uintptr(rawptr(path)), uintptr(stat))) - } else { // NOTE: arm64 does not have any lstat - return int(intrinsics.syscall(unix.SYS_fstatat, AT_FDCWD, uintptr(rawptr(path)), uintptr(stat), AT_SYMLINK_NOFOLLOW)) - } -} - -_unix_readlink :: proc(path: cstring, buf: rawptr, bufsiz: uint) -> int { - when ODIN_ARCH != .arm64 { - return int(intrinsics.syscall(unix.SYS_readlink, uintptr(rawptr(path)), uintptr(buf), uintptr(bufsiz))) - } else { // NOTE: arm64 does not have readlink - return int(intrinsics.syscall(unix.SYS_readlinkat, AT_FDCWD, uintptr(rawptr(path)), uintptr(buf), uintptr(bufsiz))) - } -} - -_unix_access :: proc(path: cstring, mask: int) -> int { - when ODIN_ARCH != .arm64 { - return int(intrinsics.syscall(unix.SYS_access, uintptr(rawptr(path)), uintptr(mask))) - } else { // NOTE: arm64 does not have access - return int(intrinsics.syscall(unix.SYS_faccessat, AT_FDCWD, uintptr(rawptr(path)), uintptr(mask))) - } -} - -_unix_getcwd :: proc(buf: rawptr, size: uint) -> int { - return int(intrinsics.syscall(unix.SYS_getcwd, uintptr(buf), uintptr(size))) -} - -_unix_chdir :: proc(path: cstring) -> int { - return int(intrinsics.syscall(unix.SYS_chdir, uintptr(rawptr(path)))) -} - -_unix_rename :: proc(old, new: cstring) -> int { - when ODIN_ARCH != .arm64 { - return int(intrinsics.syscall(unix.SYS_rename, uintptr(rawptr(old)), uintptr(rawptr(new)))) - } else { // NOTE: arm64 does not have rename - return int(intrinsics.syscall(unix.SYS_renameat, AT_FDCWD, uintptr(rawptr(old)), uintptr(rawptr(new)))) - } -} - -_unix_unlink :: proc(path: cstring) -> int { - when ODIN_ARCH != .arm64 { - return int(intrinsics.syscall(unix.SYS_unlink, uintptr(rawptr(path)))) - } else { // NOTE: arm64 does not have unlink - return int(intrinsics.syscall(unix.SYS_unlinkat, AT_FDCWD, uintptr(rawptr(path)), 0)) - } -} - -_unix_rmdir :: proc(path: cstring) -> int { - when ODIN_ARCH != .arm64 { - return int(intrinsics.syscall(unix.SYS_rmdir, uintptr(rawptr(path)))) - } else { // NOTE: arm64 does not have rmdir - return int(intrinsics.syscall(unix.SYS_unlinkat, AT_FDCWD, uintptr(rawptr(path)), AT_REMOVEDIR)) - } -} - -_unix_mkdir :: proc(path: cstring, mode: u32) -> int { - when ODIN_ARCH != .arm64 { - return int(intrinsics.syscall(unix.SYS_mkdir, uintptr(rawptr(path)), uintptr(mode))) - } else { // NOTE: arm64 does not have mkdir - return int(intrinsics.syscall(unix.SYS_mkdirat, AT_FDCWD, uintptr(rawptr(path)), uintptr(mode))) - } -} +sigset_t :: distinct u64 foreign libc { @(link_name="__errno_location") __errno_location :: proc() -> ^int --- @(link_name="getpagesize") _unix_getpagesize :: proc() -> c.int --- + @(link_name="get_nprocs") _unix_get_nprocs :: proc() -> c.int --- @(link_name="fdopendir") _unix_fdopendir :: proc(fd: Handle) -> Dir --- @(link_name="closedir") _unix_closedir :: proc(dirp: Dir) -> c.int --- @(link_name="rewinddir") _unix_rewinddir :: proc(dirp: Dir) --- @@ -414,6 +455,7 @@ foreign libc { @(link_name="free") _unix_free :: proc(ptr: rawptr) --- @(link_name="realloc") _unix_realloc :: proc(ptr: rawptr, size: c.size_t) -> rawptr --- + @(link_name="execvp") _unix_execvp :: proc(path: cstring, argv: [^]cstring) -> int --- @(link_name="getenv") _unix_getenv :: proc(cstring) -> cstring --- @(link_name="putenv") _unix_putenv :: proc(cstring) -> c.int --- @(link_name="realpath") _unix_realpath :: proc(path: cstring, resolved_path: rawptr) -> rawptr --- @@ -425,6 +467,9 @@ foreign dl { @(link_name="dlsym") _unix_dlsym :: proc(handle: rawptr, symbol: cstring) -> rawptr --- @(link_name="dlclose") _unix_dlclose :: proc(handle: rawptr) -> c.int --- @(link_name="dlerror") _unix_dlerror :: proc() -> cstring --- + + @(link_name="getifaddrs") _getifaddrs :: proc(ifap: ^^ifaddrs) -> (c.int) --- + @(link_name="freeifaddrs") _freeifaddrs :: proc(ifa: ^ifaddrs) --- } is_path_separator :: proc(r: rune) -> bool { @@ -446,7 +491,7 @@ get_last_error :: proc "contextless" () -> int { } personality :: proc(persona: u64) -> (Errno) { - res := _unix_personality(persona) + res := unix.sys_personality(persona) if res == -1 { return _get_errno(res) } @@ -454,28 +499,48 @@ personality :: proc(persona: u64) -> (Errno) { } fork :: proc() -> (Pid, Errno) { - pid := _unix_fork() + pid := unix.sys_fork() if pid == -1 { - return -1, _get_errno(int(pid)) + return -1, _get_errno(pid) } - return pid, ERROR_NONE + return Pid(pid), ERROR_NONE } -open :: proc(path: string, flags: int = O_RDONLY, mode: int = 0) -> (Handle, Errno) { - cstr := strings.clone_to_cstring(path, context.temp_allocator) - handle := _unix_open(cstr, flags, mode) - if handle < 0 { - return INVALID_HANDLE, _get_errno(int(handle)) +execvp :: proc(path: string, args: []string) -> Errno { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() + path_cstr := strings.clone_to_cstring(path, context.temp_allocator) + + args_cstrs := make([]cstring, len(args) + 2, context.temp_allocator) + args_cstrs[0] = strings.clone_to_cstring(path, context.temp_allocator) + for i := 0; i < len(args); i += 1 { + args_cstrs[i+1] = strings.clone_to_cstring(args[i], context.temp_allocator) } - return handle, ERROR_NONE + + _unix_execvp(path_cstr, raw_data(args_cstrs)) + return Errno(get_last_error()) +} + + +open :: proc(path: string, flags: int = O_RDONLY, mode: int = 0o000) -> (Handle, Errno) { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() + cstr := strings.clone_to_cstring(path, context.temp_allocator) + handle := unix.sys_open(cstr, flags, uint(mode)) + if handle < 0 { + return INVALID_HANDLE, _get_errno(handle) + } + return Handle(handle), ERROR_NONE } close :: proc(fd: Handle) -> Errno { - return _get_errno(_unix_close(fd)) + return _get_errno(unix.sys_close(int(fd))) } read :: proc(fd: Handle, data: []byte) -> (int, Errno) { - bytes_read := _unix_read(fd, &data[0], c.size_t(len(data))) + if len(data) == 0 { + return 0, ERROR_NONE + } + + bytes_read := unix.sys_read(int(fd), raw_data(data), len(data)) if bytes_read < 0 { return -1, _get_errno(bytes_read) } @@ -486,50 +551,78 @@ write :: proc(fd: Handle, data: []byte) -> (int, Errno) { if len(data) == 0 { return 0, ERROR_NONE } - bytes_written := _unix_write(fd, &data[0], uint(len(data))) + + bytes_written := unix.sys_write(int(fd), raw_data(data), len(data)) if bytes_written < 0 { return -1, _get_errno(bytes_written) } - return int(bytes_written), ERROR_NONE + return bytes_written, ERROR_NONE +} +read_at :: proc(fd: Handle, data: []byte, offset: i64) -> (int, Errno) { + if len(data) == 0 { + return 0, ERROR_NONE + } + + bytes_read := unix.sys_pread(int(fd), raw_data(data), len(data), offset) + if bytes_read < 0 { + return -1, _get_errno(bytes_read) + } + return bytes_read, ERROR_NONE +} + +write_at :: proc(fd: Handle, data: []byte, offset: i64) -> (int, Errno) { + if len(data) == 0 { + return 0, ERROR_NONE + } + + bytes_written := unix.sys_pwrite(int(fd), raw_data(data), uint(len(data)), offset) + if bytes_written < 0 { + return -1, _get_errno(bytes_written) + } + return bytes_written, ERROR_NONE } seek :: proc(fd: Handle, offset: i64, whence: int) -> (i64, Errno) { - res := _unix_seek(fd, offset, whence) + res := unix.sys_lseek(int(fd), offset, whence) if res < 0 { return -1, _get_errno(int(res)) } - return res, ERROR_NONE + return i64(res), ERROR_NONE } file_size :: proc(fd: Handle) -> (i64, Errno) { - // deliberately uninitialized; the syscall fills this buffer for us - s: OS_Stat = --- - result := _unix_fstat(fd, &s) - if result < 0 { - return 0, _get_errno(result) - } - return max(s.size, 0), ERROR_NONE + // deliberately uninitialized; the syscall fills this buffer for us + s: OS_Stat = --- + result := unix.sys_fstat(int(fd), rawptr(&s)) + if result < 0 { + return 0, _get_errno(result) + } + return max(s.size, 0), ERROR_NONE } rename :: proc(old_path, new_path: string) -> Errno { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() old_path_cstr := strings.clone_to_cstring(old_path, context.temp_allocator) new_path_cstr := strings.clone_to_cstring(new_path, context.temp_allocator) - return _get_errno(_unix_rename(old_path_cstr, new_path_cstr)) + return _get_errno(unix.sys_rename(old_path_cstr, new_path_cstr)) } remove :: proc(path: string) -> Errno { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() path_cstr := strings.clone_to_cstring(path, context.temp_allocator) - return _get_errno(_unix_unlink(path_cstr)) + return _get_errno(unix.sys_unlink(path_cstr)) } make_directory :: proc(path: string, mode: u32 = 0o775) -> Errno { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() path_cstr := strings.clone_to_cstring(path, context.temp_allocator) - return _get_errno(_unix_mkdir(path_cstr, mode)) + return _get_errno(unix.sys_mkdir(path_cstr, uint(mode))) } remove_directory :: proc(path: string) -> Errno { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() path_cstr := strings.clone_to_cstring(path, context.temp_allocator) - return _get_errno(_unix_rmdir(path_cstr)) + return _get_errno(unix.sys_rmdir(path_cstr)) } is_file_handle :: proc(fd: Handle) -> bool { @@ -581,8 +674,9 @@ is_file :: proc {is_file_path, is_file_handle} is_dir :: proc {is_dir_path, is_dir_handle} exists :: proc(path: string) -> bool { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() cpath := strings.clone_to_cstring(path, context.temp_allocator) - res := _unix_access(cpath, O_RDONLY) + res := unix.sys_access(cpath, O_RDONLY) return res == 0 } @@ -616,11 +710,12 @@ last_write_time_by_name :: proc(name: string) -> (File_Time, Errno) { @private _stat :: proc(path: string) -> (OS_Stat, Errno) { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() cstr := strings.clone_to_cstring(path, context.temp_allocator) // deliberately uninitialized; the syscall fills this buffer for us s: OS_Stat = --- - result := _unix_stat(cstr, &s) + result := unix.sys_stat(cstr, &s) if result < 0 { return s, _get_errno(result) } @@ -629,11 +724,12 @@ _stat :: proc(path: string) -> (OS_Stat, Errno) { @private _lstat :: proc(path: string) -> (OS_Stat, Errno) { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() cstr := strings.clone_to_cstring(path, context.temp_allocator) // deliberately uninitialized; the syscall fills this buffer for us s: OS_Stat = --- - result := _unix_lstat(cstr, &s) + result := unix.sys_lstat(cstr, &s) if result < 0 { return s, _get_errno(result) } @@ -644,7 +740,7 @@ _lstat :: proc(path: string) -> (OS_Stat, Errno) { _fstat :: proc(fd: Handle) -> (OS_Stat, Errno) { // deliberately uninitialized; the syscall fills this buffer for us s: OS_Stat = --- - result := _unix_fstat(fd, &s) + result := unix.sys_fstat(int(fd), rawptr(&s)) if result < 0 { return s, _get_errno(result) } @@ -696,12 +792,13 @@ _readdir :: proc(dirp: Dir) -> (entry: Dirent, err: Errno, end_of_stream: bool) @private _readlink :: proc(path: string) -> (string, Errno) { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD(ignore = context.temp_allocator == context.allocator) path_cstr := strings.clone_to_cstring(path, context.temp_allocator) bufsz : uint = 256 buf := make([]byte, bufsz) for { - rc := _unix_readlink(path_cstr, &(buf[0]), bufsz) + rc := unix.sys_readlink(path_cstr, &(buf[0]), bufsz) if rc < 0 { delete(buf) return "", _get_errno(rc) @@ -731,6 +828,7 @@ absolute_path_from_relative :: proc(rel: string) -> (path: string, err: Errno) { if rel == "" { rel = "." } + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD(ignore = context.temp_allocator == context.allocator) rel_cstr := strings.clone_to_cstring(rel, context.temp_allocator) @@ -747,8 +845,9 @@ absolute_path_from_relative :: proc(rel: string) -> (path: string, err: Errno) { } access :: proc(path: string, mask: int) -> (bool, Errno) { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() cstr := strings.clone_to_cstring(path, context.temp_allocator) - result := _unix_access(cstr, mask) + result := unix.sys_access(cstr, mask) if result < 0 { return false, _get_errno(result) } @@ -777,6 +876,7 @@ heap_free :: proc(ptr: rawptr) { } lookup_env :: proc(key: string, allocator := context.allocator) -> (value: string, found: bool) { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD(ignore = context.temp_allocator == allocator) path_str := strings.clone_to_cstring(key, context.temp_allocator) // NOTE(tetra): Lifetime of 'cstr' is unclear, but _unix_free(cstr) segfaults. cstr := _unix_getenv(path_str) @@ -792,6 +892,7 @@ get_env :: proc(key: string, allocator := context.allocator) -> (value: string) } set_env :: proc(key, value: string) -> Errno { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() s := strings.concatenate({key, "=", value, "\x00"}, context.temp_allocator) res := _unix_putenv(strings.unsafe_string_to_cstring(s)) if res < 0 { @@ -801,6 +902,7 @@ set_env :: proc(key, value: string) -> Errno { } unset_env :: proc(key: string) -> Errno { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() s := strings.clone_to_cstring(key, context.temp_allocator) res := _unix_putenv(s) if res < 0 { @@ -816,12 +918,13 @@ get_current_directory :: proc() -> string { page_size := get_page_size() buf := make([dynamic]u8, page_size) for { - #no_bounds_check res := _unix_getcwd(&buf[0], uint(len(buf))) + #no_bounds_check res := unix.sys_getcwd(&buf[0], uint(len(buf))) if res >= 0 { - return strings.string_from_nul_terminated_ptr(&buf[0], len(buf)) + return strings.string_from_null_terminated_ptr(&buf[0], len(buf)) } if _get_errno(res) != ERANGE { + delete(buf) return "" } resize(&buf, len(buf)+page_size) @@ -830,8 +933,9 @@ get_current_directory :: proc() -> string { } set_current_directory :: proc(path: string) -> (err: Errno) { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() cstr := strings.clone_to_cstring(path, context.temp_allocator) - res := _unix_chdir(cstr) + res := unix.sys_chdir(cstr) if res < 0 { return _get_errno(res) } @@ -848,12 +952,14 @@ current_thread_id :: proc "contextless" () -> int { } dlopen :: proc(filename: string, flags: int) -> rawptr { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() cstr := strings.clone_to_cstring(filename, context.temp_allocator) handle := _unix_dlopen(cstr, c.int(flags)) return handle } dlsym :: proc(handle: rawptr, symbol: string) -> rawptr { assert(handle != nil) + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() cstr := strings.clone_to_cstring(symbol, context.temp_allocator) proc_handle := _unix_dlsym(handle, cstr) return proc_handle @@ -878,6 +984,10 @@ get_page_size :: proc() -> int { return page_size } +@(private) +_processor_core_count :: proc() -> int { + return int(_unix_get_nprocs()) +} _alloc_command_line_arguments :: proc() -> []string { res := make([]string, len(runtime.args__)) @@ -886,3 +996,118 @@ _alloc_command_line_arguments :: proc() -> []string { } return res } + +socket :: proc(domain: int, type: int, protocol: int) -> (Socket, Errno) { + result := unix.sys_socket(domain, type, protocol) + if result < 0 { + return 0, _get_errno(result) + } + return Socket(result), ERROR_NONE +} + +bind :: proc(sd: Socket, addr: ^SOCKADDR, len: socklen_t) -> (Errno) { + result := unix.sys_bind(int(sd), addr, len) + if result < 0 { + return _get_errno(result) + } + return ERROR_NONE +} + + +connect :: proc(sd: Socket, addr: ^SOCKADDR, len: socklen_t) -> (Errno) { + result := unix.sys_connect(int(sd), addr, len) + if result < 0 { + return _get_errno(result) + } + return ERROR_NONE +} + +accept :: proc(sd: Socket, addr: ^SOCKADDR, len: rawptr) -> (Socket, Errno) { + result := unix.sys_accept(int(sd), rawptr(addr), len) + if result < 0 { + return 0, _get_errno(result) + } + return Socket(result), ERROR_NONE +} + +listen :: proc(sd: Socket, backlog: int) -> (Errno) { + result := unix.sys_listen(int(sd), backlog) + if result < 0 { + return _get_errno(result) + } + return ERROR_NONE +} + +setsockopt :: proc(sd: Socket, level: int, optname: int, optval: rawptr, optlen: socklen_t) -> (Errno) { + result := unix.sys_setsockopt(int(sd), level, optname, optval, optlen) + if result < 0 { + return _get_errno(result) + } + return ERROR_NONE +} + + +recvfrom :: proc(sd: Socket, data: []byte, flags: int, addr: ^SOCKADDR, addr_size: ^socklen_t) -> (u32, Errno) { + result := unix.sys_recvfrom(int(sd), raw_data(data), len(data), flags, addr, uintptr(addr_size)) + if result < 0 { + return 0, _get_errno(int(result)) + } + return u32(result), ERROR_NONE +} + +recv :: proc(sd: Socket, data: []byte, flags: int) -> (u32, Errno) { + result := unix.sys_recvfrom(int(sd), raw_data(data), len(data), flags, nil, 0) + if result < 0 { + return 0, _get_errno(int(result)) + } + return u32(result), ERROR_NONE +} + + +sendto :: proc(sd: Socket, data: []u8, flags: int, addr: ^SOCKADDR, addrlen: socklen_t) -> (u32, Errno) { + result := unix.sys_sendto(int(sd), raw_data(data), len(data), flags, addr, addrlen) + if result < 0 { + return 0, _get_errno(int(result)) + } + return u32(result), ERROR_NONE +} + +send :: proc(sd: Socket, data: []byte, flags: int) -> (u32, Errno) { + result := unix.sys_sendto(int(sd), raw_data(data), len(data), 0, nil, 0) + if result < 0 { + return 0, _get_errno(int(result)) + } + return u32(result), ERROR_NONE +} + +shutdown :: proc(sd: Socket, how: int) -> (Errno) { + result := unix.sys_shutdown(int(sd), how) + if result < 0 { + return _get_errno(result) + } + return ERROR_NONE +} + +fcntl :: proc(fd: int, cmd: int, arg: int) -> (int, Errno) { + result := unix.sys_fcntl(fd, cmd, arg) + if result < 0 { + return 0, _get_errno(result) + } + return result, ERROR_NONE +} + +poll :: proc(fds: []pollfd, timeout: int) -> (int, Errno) { + result := unix.sys_poll(raw_data(fds), uint(len(fds)), timeout) + if result < 0 { + return 0, _get_errno(result) + } + return result, ERROR_NONE +} + +ppoll :: proc(fds: []pollfd, timeout: ^unix.timespec, sigmask: ^sigset_t) -> (int, Errno) { + result := unix.sys_ppoll(raw_data(fds), uint(len(fds)), timeout, sigmask, size_of(sigset_t)) + if result < 0 { + return 0, _get_errno(result) + } + return result, ERROR_NONE +} diff --git a/core/os/os_openbsd.odin b/core/os/os_openbsd.odin index 0375107ca..957873a0b 100644 --- a/core/os/os_openbsd.odin +++ b/core/os/os_openbsd.odin @@ -269,6 +269,7 @@ foreign libc { @(link_name="mkdir") _unix_mkdir :: proc(path: cstring, mode: mode_t) -> c.int --- @(link_name="getpagesize") _unix_getpagesize :: proc() -> c.int --- + @(link_name="sysconf") _sysconf :: proc(name: c.int) -> c.long --- @(link_name="fdopendir") _unix_fdopendir :: proc(fd: Handle) -> Dir --- @(link_name="closedir") _unix_closedir :: proc(dirp: Dir) -> c.int --- @(link_name="rewinddir") _unix_rewinddir :: proc(dirp: Dir) --- @@ -307,6 +308,7 @@ fork :: proc() -> (Pid, Errno) { } open :: proc(path: string, flags: int = O_RDONLY, mode: int = 0) -> (Handle, Errno) { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() cstr := strings.clone_to_cstring(path, context.temp_allocator) handle := _unix_open(cstr, c.int(flags), c.int(mode)) if handle == -1 { @@ -359,6 +361,7 @@ file_size :: proc(fd: Handle) -> (i64, Errno) { } rename :: proc(old_path, new_path: string) -> Errno { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() old_path_cstr := strings.clone_to_cstring(old_path, context.temp_allocator) new_path_cstr := strings.clone_to_cstring(new_path, context.temp_allocator) res := _unix_rename(old_path_cstr, new_path_cstr) @@ -369,6 +372,7 @@ rename :: proc(old_path, new_path: string) -> Errno { } remove :: proc(path: string) -> Errno { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() path_cstr := strings.clone_to_cstring(path, context.temp_allocator) res := _unix_unlink(path_cstr) if res == -1 { @@ -378,6 +382,7 @@ remove :: proc(path: string) -> Errno { } make_directory :: proc(path: string, mode: mode_t = 0o775) -> Errno { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() path_cstr := strings.clone_to_cstring(path, context.temp_allocator) res := _unix_mkdir(path_cstr, mode) if res == -1 { @@ -387,6 +392,7 @@ make_directory :: proc(path: string, mode: mode_t = 0o775) -> Errno { } remove_directory :: proc(path: string) -> Errno { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() path_cstr := strings.clone_to_cstring(path, context.temp_allocator) res := _unix_rmdir(path_cstr) if res == -1 { @@ -472,6 +478,7 @@ last_write_time_by_name :: proc(name: string) -> (File_Time, Errno) { @private _stat :: proc(path: string) -> (OS_Stat, Errno) { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() cstr := strings.clone_to_cstring(path, context.temp_allocator) // deliberately uninitialized @@ -485,6 +492,7 @@ _stat :: proc(path: string) -> (OS_Stat, Errno) { @private _lstat :: proc(path: string) -> (OS_Stat, Errno) { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() cstr := strings.clone_to_cstring(path, context.temp_allocator) // deliberately uninitialized @@ -551,6 +559,7 @@ _readdir :: proc(dirp: Dir) -> (entry: Dirent, err: Errno, end_of_stream: bool) @private _readlink :: proc(path: string) -> (string, Errno) { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD(ignore = context.temp_allocator == context.allocator) path_cstr := strings.clone_to_cstring(path, context.temp_allocator) bufsz : uint = MAX_PATH @@ -568,7 +577,6 @@ _readlink :: proc(path: string) -> (string, Errno) { return strings.string_from_ptr(&buf[0], rc), ERROR_NONE } } - unreachable() } // XXX OpenBSD @@ -582,6 +590,7 @@ absolute_path_from_relative :: proc(rel: string) -> (path: string, err: Errno) { rel = "." } + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD(ignore = context.temp_allocator == context.allocator) rel_cstr := strings.clone_to_cstring(rel, context.temp_allocator) path_ptr := _unix_realpath(rel_cstr, nil) @@ -597,6 +606,7 @@ absolute_path_from_relative :: proc(rel: string) -> (path: string, err: Errno) { } access :: proc(path: string, mask: int) -> (bool, Errno) { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() cstr := strings.clone_to_cstring(path, context.temp_allocator) res := _unix_access(cstr, c.int(mask)) if res == -1 { @@ -627,6 +637,7 @@ heap_free :: proc(ptr: rawptr) { } lookup_env :: proc(key: string, allocator := context.allocator) -> (value: string, found: bool) { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD(ignore = context.temp_allocator == allocator) path_str := strings.clone_to_cstring(key, context.temp_allocator) cstr := _unix_getenv(path_str) if cstr == nil { @@ -648,6 +659,7 @@ get_current_directory :: proc() -> string { return string(cwd) } if Errno(get_last_error()) != ERANGE { + delete(buf) return "" } resize(&buf, len(buf) + MAX_PATH) @@ -656,6 +668,7 @@ get_current_directory :: proc() -> string { } set_current_directory :: proc(path: string) -> (err: Errno) { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() cstr := strings.clone_to_cstring(path, context.temp_allocator) res := _unix_chdir(cstr) if res == -1 { @@ -674,12 +687,14 @@ current_thread_id :: proc "contextless" () -> int { } dlopen :: proc(filename: string, flags: int) -> rawptr { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() cstr := strings.clone_to_cstring(filename, context.temp_allocator) handle := _unix_dlopen(cstr, c.int(flags)) return handle } dlsym :: proc(handle: rawptr, symbol: string) -> rawptr { assert(handle != nil) + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() cstr := strings.clone_to_cstring(symbol, context.temp_allocator) proc_handle := _unix_dlsym(handle, cstr) return proc_handle @@ -704,6 +719,12 @@ get_page_size :: proc() -> int { return page_size } +_SC_NPROCESSORS_ONLN :: 503 + +@(private) +_processor_core_count :: proc() -> int { + return int(_sysconf(_SC_NPROCESSORS_ONLN)) +} _alloc_command_line_arguments :: proc() -> []string { res := make([]string, len(runtime.args__)) @@ -711,4 +732,4 @@ _alloc_command_line_arguments :: proc() -> []string { res[i] = string(arg) } return res -} \ No newline at end of file +} diff --git a/core/os/os_wasi.odin b/core/os/os_wasi.odin index 70f7481f0..c407acdb4 100644 --- a/core/os/os_wasi.odin +++ b/core/os/os_wasi.odin @@ -89,7 +89,10 @@ seek :: proc(fd: Handle, offset: i64, whence: int) -> (i64, Errno) { current_thread_id :: proc "contextless" () -> int { return 0 } - +@(private) +_processor_core_count :: proc() -> int { + return 1 +} file_size :: proc(fd: Handle) -> (i64, Errno) { stat, err := wasi.fd_filestat_get(wasi.fd_t(fd)) diff --git a/core/os/os_windows.odin b/core/os/os_windows.odin index f48f46fa3..7b4c2f6c2 100644 --- a/core/os/os_windows.odin +++ b/core/os/os_windows.odin @@ -3,6 +3,7 @@ package os import win32 "core:sys/windows" import "core:runtime" +import "core:intrinsics" Handle :: distinct uintptr File_Time :: distinct u64 @@ -126,7 +127,29 @@ get_page_size :: proc() -> int { return page_size } +@(private) +_processor_core_count :: proc() -> int { + length : win32.DWORD = 0 + result := win32.GetLogicalProcessorInformation(nil, &length) + thread_count := 0 + if !result && win32.GetLastError() == 122 && length > 0 { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() + processors := make([]win32.SYSTEM_LOGICAL_PROCESSOR_INFORMATION, length, context.temp_allocator) + + result = win32.GetLogicalProcessorInformation(&processors[0], &length) + if result { + for processor in processors { + if processor.Relationship == .RelationProcessorCore { + thread := intrinsics.count_ones(processor.ProcessorMask) + thread_count += int(thread) + } + } + } + } + + return thread_count +} exit :: proc "contextless" (code: int) -> ! { runtime._cleanup_runtime_contextless() @@ -214,4 +237,4 @@ is_windows_10 :: proc() -> bool { is_windows_11 :: proc() -> bool { osvi := get_windows_version_w() return (osvi.dwMajorVersion == 10 && osvi.dwMinorVersion == 0 && osvi.dwBuildNumber >= WINDOWS_11_BUILD_CUTOFF) -} \ No newline at end of file +} diff --git a/core/os/stat_windows.odin b/core/os/stat_windows.odin index c63fb4cf0..efea329ce 100644 --- a/core/os/stat_windows.odin +++ b/core/os/stat_windows.odin @@ -1,6 +1,7 @@ package os import "core:time" +import "core:runtime" import win32 "core:sys/windows" @(private) @@ -11,6 +12,7 @@ full_path_from_name :: proc(name: string, allocator := context.allocator) -> (pa if name == "" { name = "." } + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD(ignore = context.temp_allocator == allocator) p := win32.utf8_to_utf16(name, context.temp_allocator) buf := make([dynamic]u16, 100) defer delete(buf) @@ -36,6 +38,7 @@ _stat :: proc(name: string, create_file_attributes: u32, allocator := context.al context.allocator = allocator + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD(ignore = context.temp_allocator == allocator) wname := win32.utf8_to_wstring(fix_long_path(name), context.temp_allocator) fa: win32.WIN32_FILE_ATTRIBUTE_DATA @@ -132,14 +135,15 @@ cleanpath_strip_prefix :: proc(buf: []u16) -> []u16 { @(private) cleanpath_from_handle :: proc(fd: Handle) -> (string, Errno) { - buf, err := cleanpath_from_handle_u16(fd) + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD(ignore = context.temp_allocator == context.allocator) + buf, err := cleanpath_from_handle_u16(fd, context.temp_allocator) if err != 0 { return "", err } return win32.utf16_to_utf8(buf, context.allocator) or_else "", err } @(private) -cleanpath_from_handle_u16 :: proc(fd: Handle) -> ([]u16, Errno) { +cleanpath_from_handle_u16 :: proc(fd: Handle, allocator: runtime.Allocator) -> ([]u16, Errno) { if fd == 0 { return nil, ERROR_INVALID_HANDLE } @@ -149,7 +153,7 @@ cleanpath_from_handle_u16 :: proc(fd: Handle) -> ([]u16, Errno) { if n == 0 { return nil, Errno(win32.GetLastError()) } - buf := make([]u16, max(n, win32.DWORD(260))+1, context.temp_allocator) + buf := make([]u16, max(n, win32.DWORD(260))+1, allocator) buf_len := win32.GetFinalPathNameByHandleW(h, raw_data(buf), n, 0) return buf[:buf_len], ERROR_NONE } diff --git a/core/os/stream.odin b/core/os/stream.odin index 9506ed3a3..2b4c83663 100644 --- a/core/os/stream.odin +++ b/core/os/stream.odin @@ -4,66 +4,60 @@ import "core:io" stream_from_handle :: proc(fd: Handle) -> io.Stream { s: io.Stream - s.stream_data = rawptr(uintptr(fd)) - s.stream_vtable = &_file_stream_vtable + s.data = rawptr(uintptr(fd)) + s.procedure = _file_stream_proc return s } @(private) -_file_stream_vtable := io.Stream_VTable{ - impl_read = proc(s: io.Stream, p: []byte) -> (n: int, err: io.Error) { - fd := Handle(uintptr(s.stream_data)) - os_err: Errno - n, os_err = read(fd, p) - return - }, - impl_read_at = proc(s: io.Stream, p: []byte, offset: i64) -> (n: int, err: io.Error) { - when ODIN_OS == .Windows || ODIN_OS == .WASI { - fd := Handle(uintptr(s.stream_data)) - os_err: Errno - n, os_err = read_at(fd, p, offset) - } - return - }, - impl_write = proc(s: io.Stream, p: []byte) -> (n: int, err: io.Error) { - fd := Handle(uintptr(s.stream_data)) - os_err: Errno - n, os_err = write(fd, p) - return - }, - impl_write_at = proc(s: io.Stream, p: []byte, offset: i64) -> (n: int, err: io.Error) { - when ODIN_OS == .Windows || ODIN_OS == .WASI { - fd := Handle(uintptr(s.stream_data)) - os_err: Errno - n, os_err = write_at(fd, p, offset) - _ = os_err - } - return - }, - impl_seek = proc(s: io.Stream, offset: i64, whence: io.Seek_From) -> (i64, io.Error) { - fd := Handle(uintptr(s.stream_data)) - n, os_err := seek(fd, offset, int(whence)) - _ = os_err - return n, nil - }, - impl_size = proc(s: io.Stream) -> i64 { - fd := Handle(uintptr(s.stream_data)) - sz, _ := file_size(fd) - return sz - }, - impl_flush = proc(s: io.Stream) -> io.Error { +_file_stream_proc :: proc(stream_data: rawptr, mode: io.Stream_Mode, p: []byte, offset: i64, whence: io.Seek_From) -> (n: i64, err: io.Error) { + fd := Handle(uintptr(stream_data)) + n_int: int + os_err: Errno + switch mode { + case .Close: + close(fd) + case .Flush: when ODIN_OS == .Windows { - fd := Handle(uintptr(s.stream_data)) flush(fd) } else { // TOOD(bill): other operating systems } - return nil - }, - impl_close = proc(s: io.Stream) -> io.Error { - fd := Handle(uintptr(s.stream_data)) - close(fd) - return nil - }, + case .Read: + n_int, os_err = read(fd, p) + n = i64(n_int) + if os_err != 0 { + err = .Unknown + } + case .Read_At: + when !(ODIN_OS == .FreeBSD || ODIN_OS == .OpenBSD) { + n_int, os_err = read_at(fd, p, offset) + n = i64(n_int) + } + case .Write: + n_int, os_err = write(fd, p) + n = i64(n_int) + case .Write_At: + when !(ODIN_OS == .FreeBSD || ODIN_OS == .OpenBSD) { + n_int, os_err = write_at(fd, p, offset) + n = i64(n_int) + } + case .Seek: + n, os_err = seek(fd, offset, int(whence)) + case .Size: + n, os_err = file_size(fd) + case .Destroy: + err = .Empty + case .Query: + when ODIN_OS == .FreeBSD || ODIN_OS == .OpenBSD { + return io.query_utility({.Close, .Flush, .Read, .Write, .Seek, .Size, .Query}) + } else { + return io.query_utility({.Close, .Flush, .Read, .Read_At, .Write, .Write_At, .Seek, .Size, .Query}) + } + } + if err == nil && os_err != 0 { + err = .Unknown + } + return } diff --git a/core/path/filepath/match.odin b/core/path/filepath/match.odin index c932f202a..fe67ebe2c 100644 --- a/core/path/filepath/match.odin +++ b/core/path/filepath/match.odin @@ -218,7 +218,6 @@ get_escape :: proc(chunk: string) -> (r: rune, next_chunk: string, err: Match_Er // // glob ignores file system errors // - glob :: proc(pattern: string, allocator := context.allocator) -> (matches: []string, err: Match_Error) { context.allocator = allocator @@ -261,6 +260,8 @@ glob :: proc(pattern: string, allocator := context.allocator) -> (matches: []str } return } + +// Internal implementation of `glob`, not meant to be used by the user. Prefer `glob`. _glob :: proc(dir, pattern: string, matches: ^[dynamic]string, allocator := context.allocator) -> (m: [dynamic]string, e: Match_Error) { context.allocator = allocator diff --git a/core/path/filepath/path.odin b/core/path/filepath/path.odin index 32e4a8a37..370de59a2 100644 --- a/core/path/filepath/path.odin +++ b/core/path/filepath/path.odin @@ -20,6 +20,8 @@ is_slash :: proc(c: byte) -> bool { return c == '\\' || c == '/' } +// Splits path immediate following the last separator; separating the path into a directory and file. +// If no separator is found, `dir` will be empty and `path` set to `path`. split :: proc(path: string) -> (dir, file: string) { vol := volume_name(path) i := len(path) - 1 @@ -29,10 +31,18 @@ split :: proc(path: string) -> (dir, file: string) { return path[:i+1], path[i+1:] } +/* + Returns leading volume name. + + e.g. + "C:\foo\bar\baz" will return "C:" on Windows. + Everything else will be "". +*/ volume_name :: proc(path: string) -> string { return path[:volume_name_len(path)] } +// Returns the length of the volume name in bytes. volume_name_len :: proc(path: string) -> int { if ODIN_OS == .Windows { if len(path) < 2 { @@ -74,7 +84,7 @@ volume_name_len :: proc(path: string) -> int { /* Gets the file name and extension from a path. - i.e: + e.g. 'path/to/name.tar.gz' -> 'name.tar.gz' 'path/to/name.txt' -> 'name.txt' 'path/to/name' -> 'name' @@ -114,7 +124,7 @@ base :: proc(path: string) -> string { Only the last dot is considered when splitting the file extension. See `short_stem`. - i.e: + e.g. 'name.tar.gz' -> 'name.tar' 'name.txt' -> 'name' @@ -147,7 +157,7 @@ stem :: proc(path: string) -> string { The first dot is used to split off the file extension, unlike `stem` which uses the last dot. - i.e: + e.g. 'name.tar.gz' -> 'name' 'name.txt' -> 'name' @@ -170,7 +180,7 @@ short_stem :: proc(path: string) -> string { Only the last dot is considered when splitting the file extension. See `long_ext`. - i.e: + e.g. 'name.tar.gz' -> '.gz' 'name.txt' -> '.txt' @@ -193,7 +203,7 @@ ext :: proc(path: string) -> string { The first dot is used to split off the file extension, unlike `ext` which uses the last dot. - i.e: + e.g. 'name.tar.gz' -> '.tar.gz' 'name.txt' -> '.txt' @@ -219,6 +229,21 @@ long_ext :: proc(path: string) -> string { return "" } +/* + Returns the shortest path name equivalent to `path` through solely lexical processing. + It applies the folliwng rules until none of them can be applied: + + * Replace multiple separators with a single one + * Remove each current directory (`.`) path name element + * Remove each inner parent directory (`..`) path and the preceding paths + * Remove `..` that begin at the root of a path + * All possible separators are replaced with the OS specific separator + + The return path ends in a slash only if it represents the root of a directory (`C:\` on Windows and `/` on *nix systems). + + If the result of the path is an empty string, the returned path with be `"."`. + +*/ clean :: proc(path: string, allocator := context.allocator) -> string { context.allocator = allocator @@ -299,6 +324,7 @@ clean :: proc(path: string, allocator := context.allocator) -> string { return cleaned } +// Returns the result of replacing each forward slash `/` character in the path with the separate OS specific character. from_slash :: proc(path: string, allocator := context.allocator) -> (new_path: string, new_allocation: bool) { if SEPARATOR == '/' { return path, false @@ -306,6 +332,7 @@ from_slash :: proc(path: string, allocator := context.allocator) -> (new_path: s return strings.replace_all(path, "/", SEPARATOR_STRING, allocator) } +// Returns the result of replacing each OS specific separator with a forward slash `/` character. to_slash :: proc(path: string, allocator := context.allocator) -> (new_path: string, new_allocation: bool) { if SEPARATOR == '/' { return path, false @@ -320,6 +347,13 @@ Relative_Error :: enum { Cannot_Relate, } +/* + Returns a relative path that is lexically equivalent to the `target_path` when joined with the `base_path` with an OS specific separator. + + e.g. `join(base_path, rel(base_path, target_path))` is equivalent to `target_path` + + On failure, the `Relative_Error` will be state it cannot compute the necessary relative path. +*/ rel :: proc(base_path, target_path: string, allocator := context.allocator) -> (string, Relative_Error) { context.allocator = allocator base_clean, target_clean := clean(base_path), clean(target_path) @@ -398,6 +432,11 @@ rel :: proc(base_path, target_path: string, allocator := context.allocator) -> ( return target[t0:], .None } +/* + Returns all but the last element path, usually the path's directory. Once the final element has been removed, + `dir` calls `clean` on the path and trailing separators are removed. If the path consists purely of separators, + then `"."` is returned. +*/ dir :: proc(path: string, allocator := context.allocator) -> string { context.allocator = allocator vol := volume_name(path) diff --git a/core/path/filepath/path_unix.odin b/core/path/filepath/path_unix.odin index 8faf6097c..898f34b6a 100644 --- a/core/path/filepath/path_unix.odin +++ b/core/path/filepath/path_unix.odin @@ -7,6 +7,7 @@ when ODIN_OS == .Darwin { foreign import libc "system:c" } +import "core:runtime" import "core:strings" SEPARATOR :: '/' @@ -41,6 +42,7 @@ abs :: proc(path: string, allocator := context.allocator) -> (string, bool) { join :: proc(elems: []string, allocator := context.allocator) -> string { for e, i in elems { if e != "" { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD(ignore = context.temp_allocator == allocator) p := strings.join(elems[i:], SEPARATOR_STRING, context.temp_allocator) return clean(p, allocator) } diff --git a/core/path/filepath/path_windows.odin b/core/path/filepath/path_windows.odin index cdfe3ddbb..e7dd4ab3e 100644 --- a/core/path/filepath/path_windows.odin +++ b/core/path/filepath/path_windows.odin @@ -1,6 +1,7 @@ package filepath import "core:strings" +import "core:runtime" import "core:os" import win32 "core:sys/windows" @@ -60,25 +61,25 @@ temp_full_path :: proc(name: string) -> (path: string, err: os.Errno) { } p := win32.utf8_to_utf16(name, ta) - buf := make([dynamic]u16, 100, ta) - for { - n := win32.GetFullPathNameW(raw_data(p), u32(len(buf)), raw_data(buf), nil) - if n == 0 { - delete(buf) - return "", os.Errno(win32.GetLastError()) - } - if n <= u32(len(buf)) { - return win32.utf16_to_utf8(buf[:n], ta) or_else "", os.ERROR_NONE - } - resize(&buf, len(buf)*2) + n := win32.GetFullPathNameW(raw_data(p), 0, nil, nil) + if n == 0 { + return "", os.Errno(win32.GetLastError()) } - return + buf := make([]u16, n, ta) + n = win32.GetFullPathNameW(raw_data(p), u32(len(buf)), raw_data(buf), nil) + if n == 0 { + delete(buf) + return "", os.Errno(win32.GetLastError()) + } + + return win32.utf16_to_utf8(buf[:n], ta) or_else "", os.ERROR_NONE } abs :: proc(path: string, allocator := context.allocator) -> (string, bool) { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD(ignore = allocator == context.temp_allocator) full_path, err := temp_full_path(path) if err != 0 { return "", false @@ -99,6 +100,8 @@ join :: proc(elems: []string, allocator := context.allocator) -> string { join_non_empty :: proc(elems: []string, allocator := context.allocator) -> string { context.allocator = allocator + + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD(ignore = allocator == context.temp_allocator) if len(elems[0]) == 2 && elems[0][1] == ':' { i := 1 diff --git a/core/path/slashpath/path.odin b/core/path/slashpath/path.odin index 865f619bf..5f5ab2ae9 100644 --- a/core/path/slashpath/path.odin +++ b/core/path/slashpath/path.odin @@ -5,6 +5,7 @@ // To manipulate operating system specific paths, use the path/filepath package package slashpath +import "core:runtime" import "core:strings" // is_separator checks whether the byte is a valid separator character @@ -150,8 +151,9 @@ join :: proc(elems: []string, allocator := context.allocator) -> string { context.allocator = allocator for elem, i in elems { if elem != "" { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD(ignore = context.temp_allocator == allocator) s := strings.join(elems[i:], "/", context.temp_allocator) - return clean(s) + return clean(s, allocator) } } return "" diff --git a/core/prof/spall/doc.odin b/core/prof/spall/doc.odin new file mode 100644 index 000000000..0f3cc8bb8 --- /dev/null +++ b/core/prof/spall/doc.odin @@ -0,0 +1,26 @@ +/* +import "core:prof/spall" + +spall_ctx: spall.Context +spall_buffer: spall.Buffer + +foo :: proc() { + spall.SCOPED_EVENT(&spall_ctx, &spall_buffer, #procedure) +} + +main :: proc() { + spall_ctx = spall.context_create("trace_test.spall") + defer spall.context_destroy(&spall_ctx) + + buffer_backing := make([]u8, spall.BUFFER_DEFAULT_SIZE) + spall_buffer = spall.buffer_create(buffer_backing) + defer spall.buffer_destroy(&spall_ctx, &spall_buffer) + + spall.SCOPED_EVENT(&spall_ctx, &spall_buffer, #procedure) + + for i := 0; i < 9001; i += 1 { + foo() + } +} +*/ +package spall diff --git a/core/prof/spall/spall.odin b/core/prof/spall/spall.odin new file mode 100644 index 000000000..19a05d70a --- /dev/null +++ b/core/prof/spall/spall.odin @@ -0,0 +1,222 @@ +package spall + +import "core:os" +import "core:time" +import "core:intrinsics" +import "core:mem" + +// File Format + +MANUAL_MAGIC :: u64le(0x0BADF00D) + +Manual_Header :: struct #packed { + magic: u64le, + version: u64le, + timestamp_scale: f64le, + reserved: u64le, +} + +Manual_Event_Type :: enum u8 { + Invalid = 0, + + Begin = 3, + End = 4, + Instant = 5, + + Pad_Skip = 7, +} + +Begin_Event :: struct #packed { + type: Manual_Event_Type, + category: u8, + pid: u32le, + tid: u32le, + ts: f64le, + name_len: u8, + args_len: u8, +} +BEGIN_EVENT_MAX :: size_of(Begin_Event) + 255 + 255 + +End_Event :: struct #packed { + type: Manual_Event_Type, + pid: u32le, + tid: u32le, + ts: f64le, +} + +Pad_Skip :: struct #packed { + type: Manual_Event_Type, + size: u32le, +} + +// User Interface + +Context :: struct { + precise_time: bool, + timestamp_scale: f64, + fd: os.Handle, +} + +Buffer :: struct { + data: []u8, + head: int, + tid: u32, + pid: u32, +} + +BUFFER_DEFAULT_SIZE :: 0x10_0000 + + +context_create_with_scale :: proc(filename: string, precise_time: bool, timestamp_scale: f64) -> (ctx: Context, ok: bool) #optional_ok { + fd, err := os.open(filename, os.O_WRONLY | os.O_APPEND | os.O_CREATE | os.O_TRUNC, 0o600) + if err != os.ERROR_NONE { + return + } + + ctx.fd = fd + ctx.precise_time = precise_time + ctx.timestamp_scale = timestamp_scale + + temp := [size_of(Manual_Header)]u8{} + _build_header(temp[:], ctx.timestamp_scale) + os.write(ctx.fd, temp[:]) + ok = true + return +} + +context_create_with_sleep :: proc(filename: string, sleep := 2 * time.Second) -> (ctx: Context, ok: bool) #optional_ok { + freq, freq_ok := time.tsc_frequency(sleep) + timestamp_scale: f64 = ((1 / f64(freq)) * 1_000_000) if freq_ok else 1 + return context_create_with_scale(filename, freq_ok, timestamp_scale) +} + +context_create :: proc{context_create_with_scale, context_create_with_sleep} + +context_destroy :: proc(ctx: ^Context) { + if ctx == nil { + return + } + + os.close(ctx.fd) + ctx^ = Context{} +} + +buffer_create :: proc(data: []byte, tid: u32 = 0, pid: u32 = 0) -> (buffer: Buffer, ok: bool) #optional_ok { + assert(len(data) >= 1024) + buffer.data = data + buffer.tid = tid + buffer.pid = pid + buffer.head = 0 + ok = true + return +} + +buffer_flush :: proc(ctx: ^Context, buffer: ^Buffer) { + start := _trace_now(ctx) + os.write(ctx.fd, buffer.data[:buffer.head]) + buffer.head = 0 + end := _trace_now(ctx) + + buffer.head += _build_begin(buffer.data[buffer.head:], "Spall Trace Buffer Flush", "", start, buffer.tid, buffer.pid) + buffer.head += _build_end(buffer.data[buffer.head:], end, buffer.tid, buffer.pid) +} + +buffer_destroy :: proc(ctx: ^Context, buffer: ^Buffer) { + buffer_flush(ctx, buffer) + + buffer^ = Buffer{} +} + + + +@(deferred_in=_scoped_buffer_end) +SCOPED_EVENT :: proc(ctx: ^Context, buffer: ^Buffer, name: string, args: string = "", location := #caller_location) -> bool { + _buffer_begin(ctx, buffer, name, args, location) + return true +} + +@(private) +_scoped_buffer_end :: proc(ctx: ^Context, buffer: ^Buffer, _, _: string, _ := #caller_location) { + _buffer_end(ctx, buffer) +} + + +_trace_now :: proc "contextless" (ctx: ^Context) -> f64 { + if !ctx.precise_time { + return f64(time.tick_now()._nsec) / 1_000 + } + + return f64(intrinsics.read_cycle_counter()) +} + +_build_header :: proc "contextless" (buffer: []u8, timestamp_scale: f64) -> (header_size: int, ok: bool) #optional_ok { + header_size = size_of(Manual_Header) + if header_size > len(buffer) { + return 0, false + } + + hdr := (^Manual_Header)(raw_data(buffer)) + hdr.magic = MANUAL_MAGIC + hdr.version = 1 + hdr.timestamp_scale = f64le(timestamp_scale) + hdr.reserved = 0 + ok = true + return +} + +_build_begin :: proc "contextless" (buffer: []u8, name: string, args: string, ts: f64, tid: u32, pid: u32) -> (event_size: int, ok: bool) #optional_ok { + ev := (^Begin_Event)(raw_data(buffer)) + name_len := min(len(name), 255) + args_len := min(len(args), 255) + + event_size = size_of(Begin_Event) + name_len + args_len + if event_size > len(buffer) { + return 0, false + } + + ev.type = .Begin + ev.pid = u32le(pid) + ev.tid = u32le(tid) + ev.ts = f64le(ts) + ev.name_len = u8(name_len) + ev.args_len = u8(args_len) + mem.copy(raw_data(buffer[size_of(Begin_Event):]), raw_data(name), name_len) + mem.copy(raw_data(buffer[size_of(Begin_Event)+name_len:]), raw_data(args), args_len) + ok = true + + return +} + +_build_end :: proc "contextless" (buffer: []u8, ts: f64, tid: u32, pid: u32) -> (event_size: int, ok: bool) #optional_ok { + ev := (^End_Event)(raw_data(buffer)) + event_size = size_of(End_Event) + if event_size > len(buffer) { + return 0, false + } + + ev.type = .End + ev.pid = u32le(pid) + ev.tid = u32le(tid) + ev.ts = f64le(ts) + ok = true + + return +} + +_buffer_begin :: proc(ctx: ^Context, buffer: ^Buffer, name: string, args: string = "", location := #caller_location) { + if buffer.head + BEGIN_EVENT_MAX > len(buffer.data) { + buffer_flush(ctx, buffer) + } + name := location.procedure if name == "" else name + buffer.head += _build_begin(buffer.data[buffer.head:], name, args, _trace_now(ctx), buffer.tid, buffer.pid) +} + +_buffer_end :: proc(ctx: ^Context, buffer: ^Buffer) { + ts := _trace_now(ctx) + + if buffer.head + size_of(End_Event) > len(buffer.data) { + buffer_flush(ctx, buffer) + } + + buffer.head += _build_end(buffer.data[buffer.head:], ts, buffer.tid, buffer.pid) +} diff --git a/core/reflect/iterator.odin b/core/reflect/iterator.odin index 9fb6489ca..2e143284a 100644 --- a/core/reflect/iterator.odin +++ b/core/reflect/iterator.odin @@ -2,6 +2,7 @@ package reflect import "core:runtime" +@(require_results) iterate_array :: proc(val: any, it: ^int) -> (elem: any, index: int, ok: bool) { if val == nil || it == nil { return @@ -41,6 +42,7 @@ iterate_array :: proc(val: any, it: ^int) -> (elem: any, index: int, ok: bool) { return } +@(require_results) iterate_map :: proc(val: any, it: ^int) -> (key, value: any, ok: bool) { if val == nil || it == nil { return diff --git a/core/reflect/reflect.odin b/core/reflect/reflect.odin index 0312ffd95..2eb31c21b 100644 --- a/core/reflect/reflect.odin +++ b/core/reflect/reflect.odin @@ -25,7 +25,8 @@ Type_Info_Array :: runtime.Type_Info_Array Type_Info_Enumerated_Array :: runtime.Type_Info_Enumerated_Array Type_Info_Dynamic_Array :: runtime.Type_Info_Dynamic_Array Type_Info_Slice :: runtime.Type_Info_Slice -Type_Info_Tuple :: runtime.Type_Info_Tuple +Type_Info_Parameters :: runtime.Type_Info_Parameters +Type_Info_Tuple :: runtime.Type_Info_Parameters Type_Info_Struct :: runtime.Type_Info_Struct Type_Info_Union :: runtime.Type_Info_Union Type_Info_Enum :: runtime.Type_Info_Enum @@ -74,6 +75,7 @@ Type_Kind :: enum { } +@(require_results) type_kind :: proc(T: typeid) -> Type_Kind { ti := type_info_of(T) if ti != nil { @@ -95,7 +97,7 @@ type_kind :: proc(T: typeid) -> Type_Kind { case Type_Info_Enumerated_Array: return .Enumerated_Array case Type_Info_Dynamic_Array: return .Dynamic_Array case Type_Info_Slice: return .Slice - case Type_Info_Tuple: return .Tuple + case Type_Info_Parameters: return .Tuple case Type_Info_Struct: return .Struct case Type_Info_Union: return .Union case Type_Info_Enum: return .Enum @@ -113,11 +115,13 @@ type_kind :: proc(T: typeid) -> Type_Kind { } // TODO(bill): Better name +@(require_results) underlying_type_kind :: proc(T: typeid) -> Type_Kind { return type_kind(runtime.typeid_base(T)) } // TODO(bill): Better name +@(require_results) backing_type_kind :: proc(T: typeid) -> Type_Kind { return type_kind(runtime.typeid_core(T)) } @@ -128,13 +132,14 @@ type_info_core :: runtime.type_info_core type_info_base_without_enum :: type_info_core -when !ODIN_DISALLOW_RTTI { +when !ODIN_NO_RTTI { typeid_base :: runtime.typeid_base typeid_core :: runtime.typeid_core typeid_base_without_enum :: typeid_core } +@(require_results) any_base :: proc(v: any) -> any { v := v if v != nil { @@ -142,6 +147,7 @@ any_base :: proc(v: any) -> any { } return v } +@(require_results) any_core :: proc(v: any) -> any { v := v if v != nil { @@ -150,6 +156,7 @@ any_core :: proc(v: any) -> any { return v } +@(require_results) typeid_elem :: proc(id: typeid) -> typeid { ti := type_info_of(id) if ti == nil { return nil } @@ -179,6 +186,7 @@ typeid_elem :: proc(id: typeid) -> typeid { } +@(require_results) size_of_typeid :: proc(T: typeid) -> int { if ti := type_info_of(T); ti != nil { return ti.size @@ -186,6 +194,7 @@ size_of_typeid :: proc(T: typeid) -> int { return 0 } +@(require_results) align_of_typeid :: proc(T: typeid) -> int { if ti := type_info_of(T); ti != nil { return ti.align @@ -193,6 +202,7 @@ align_of_typeid :: proc(T: typeid) -> int { return 1 } +@(require_results) as_bytes :: proc(v: any) -> []byte { if v != nil { sz := size_of_typeid(v.id) @@ -201,10 +211,12 @@ as_bytes :: proc(v: any) -> []byte { return nil } +@(require_results) any_data :: #force_inline proc(v: any) -> (data: rawptr, id: typeid) { return v.data, v.id } +@(require_results) is_nil :: proc(v: any) -> bool { if v == nil { return true @@ -221,6 +233,7 @@ is_nil :: proc(v: any) -> bool { return true } +@(require_results) length :: proc(val: any) -> int { if val == nil { return 0 } @@ -256,6 +269,7 @@ length :: proc(val: any) -> int { return 0 } +@(require_results) capacity :: proc(val: any) -> int { if val == nil { return 0 } @@ -282,6 +296,7 @@ capacity :: proc(val: any) -> int { } +@(require_results) index :: proc(val: any, i: int, loc := #caller_location) -> any { if val == nil { return nil } @@ -341,6 +356,7 @@ index :: proc(val: any, i: int, loc := #caller_location) -> any { return nil } +@(require_results) deref :: proc(val: any) -> any { if val != nil { ti := type_info_base(type_info_of(val.id)) @@ -370,6 +386,7 @@ Struct_Field :: struct { is_using: bool, } +@(require_results) struct_field_at :: proc(T: typeid, i: int) -> (field: Struct_Field) { ti := runtime.type_info_base(type_info_of(T)) if s, ok := ti.variant.(runtime.Type_Info_Struct); ok { @@ -384,6 +401,7 @@ struct_field_at :: proc(T: typeid, i: int) -> (field: Struct_Field) { return } +@(require_results) struct_field_by_name :: proc(T: typeid, name: string) -> (field: Struct_Field) { ti := runtime.type_info_base(type_info_of(T)) if s, ok := ti.variant.(runtime.Type_Info_Struct); ok { @@ -401,6 +419,7 @@ struct_field_by_name :: proc(T: typeid, name: string) -> (field: Struct_Field) { return } +@(require_results) struct_field_value_by_name :: proc(a: any, field: string, allow_using := false) -> any { if a == nil { return nil } @@ -430,8 +449,16 @@ struct_field_value_by_name :: proc(a: any, field: string, allow_using := false) return nil } +@(require_results) +struct_field_value :: proc(a: any, field: Struct_Field) -> any { + if a == nil { return nil } + return any { + rawptr(uintptr(a.data) + field.offset), + field.type.id, + } +} - +@(require_results) struct_field_names :: proc(T: typeid) -> []string { ti := runtime.type_info_base(type_info_of(T)) if s, ok := ti.variant.(runtime.Type_Info_Struct); ok { @@ -440,6 +467,7 @@ struct_field_names :: proc(T: typeid) -> []string { return nil } +@(require_results) struct_field_types :: proc(T: typeid) -> []^Type_Info { ti := runtime.type_info_base(type_info_of(T)) if s, ok := ti.variant.(runtime.Type_Info_Struct); ok { @@ -449,6 +477,7 @@ struct_field_types :: proc(T: typeid) -> []^Type_Info { } +@(require_results) struct_field_tags :: proc(T: typeid) -> []Struct_Tag { ti := runtime.type_info_base(type_info_of(T)) if s, ok := ti.variant.(runtime.Type_Info_Struct); ok { @@ -457,6 +486,7 @@ struct_field_tags :: proc(T: typeid) -> []Struct_Tag { return nil } +@(require_results) struct_field_offsets :: proc(T: typeid) -> []uintptr { ti := runtime.type_info_base(type_info_of(T)) if s, ok := ti.variant.(runtime.Type_Info_Struct); ok { @@ -465,6 +495,7 @@ struct_field_offsets :: proc(T: typeid) -> []uintptr { return nil } +@(require_results) struct_fields_zipped :: proc(T: typeid) -> (fields: #soa[]Struct_Field) { ti := runtime.type_info_base(type_info_of(T)) if s, ok := ti.variant.(runtime.Type_Info_Struct); ok { @@ -481,11 +512,13 @@ struct_fields_zipped :: proc(T: typeid) -> (fields: #soa[]Struct_Field) { +@(require_results) struct_tag_get :: proc(tag: Struct_Tag, key: string) -> (value: Struct_Tag) { value, _ = struct_tag_lookup(tag, key) return } +@(require_results) struct_tag_lookup :: proc(tag: Struct_Tag, key: string) -> (value: Struct_Tag, ok: bool) { for t := tag; t != ""; /**/ { i := 0 @@ -544,6 +577,7 @@ struct_tag_lookup :: proc(tag: Struct_Tag, key: string) -> (value: Struct_Tag, o } +@(require_results) enum_string :: proc(a: any) -> string { if a == nil { return "" } ti := runtime.type_info_base(type_info_of(a.id)) @@ -562,6 +596,7 @@ enum_string :: proc(a: any) -> string { } // Given a enum type and a value name, get the enum value. +@(require_results) enum_from_name :: proc($Enum_Type: typeid, name: string) -> (value: Enum_Type, ok: bool) { ti := type_info_base(type_info_of(Enum_Type)) if eti, eti_ok := ti.variant.(runtime.Type_Info_Enum); eti_ok { @@ -578,6 +613,7 @@ enum_from_name :: proc($Enum_Type: typeid, name: string) -> (value: Enum_Type, o return } +@(require_results) enum_from_name_any :: proc(Enum_Type: typeid, name: string) -> (value: Type_Info_Enum_Value, ok: bool) { ti := runtime.type_info_base(type_info_of(Enum_Type)) if eti, eti_ok := ti.variant.(runtime.Type_Info_Enum); eti_ok { @@ -594,6 +630,7 @@ enum_from_name_any :: proc(Enum_Type: typeid, name: string) -> (value: Type_Info } +@(require_results) enum_field_names :: proc(Enum_Type: typeid) -> []string { ti := runtime.type_info_base(type_info_of(Enum_Type)) if eti, eti_ok := ti.variant.(runtime.Type_Info_Enum); eti_ok { @@ -601,6 +638,7 @@ enum_field_names :: proc(Enum_Type: typeid) -> []string { } return nil } +@(require_results) enum_field_values :: proc(Enum_Type: typeid) -> []Type_Info_Enum_Value { ti := runtime.type_info_base(type_info_of(Enum_Type)) if eti, eti_ok := ti.variant.(runtime.Type_Info_Enum); eti_ok { @@ -614,6 +652,7 @@ Enum_Field :: struct { value: Type_Info_Enum_Value, } +@(require_results) enum_fields_zipped :: proc(Enum_Type: typeid) -> (fields: #soa[]Enum_Field) { ti := runtime.type_info_base(type_info_of(Enum_Type)) if eti, eti_ok := ti.variant.(runtime.Type_Info_Enum); eti_ok { @@ -624,15 +663,18 @@ enum_fields_zipped :: proc(Enum_Type: typeid) -> (fields: #soa[]Enum_Field) { +@(require_results) union_variant_type_info :: proc(a: any) -> ^Type_Info { id := union_variant_typeid(a) return type_info_of(id) } +@(require_results) type_info_union_is_pure_maybe :: proc(info: runtime.Type_Info_Union) -> bool { return len(info.variants) == 1 && is_pointer(info.variants[0]) } +@(require_results) union_variant_typeid :: proc(a: any) -> typeid { if a == nil { return nil } @@ -661,9 +703,10 @@ union_variant_typeid :: proc(a: any) -> typeid { case: unimplemented() } - if a.data != nil && tag != 0 { - i := tag if info.no_nil else tag-1 - return info.variants[i].id + if info.no_nil { + return info.variants[tag].id + } else if tag != 0 { + return info.variants[tag-1].id } return nil @@ -671,6 +714,7 @@ union_variant_typeid :: proc(a: any) -> typeid { panic("expected a union to reflect.union_variant_typeid") } +@(require_results) get_union_variant_raw_tag :: proc(a: any) -> i64 { if a == nil { return -1 } @@ -701,6 +745,7 @@ get_union_variant_raw_tag :: proc(a: any) -> i64 { panic("expected a union to reflect.get_union_variant_raw_tag") } +@(require_results) get_union_variant :: proc(a: any) -> any { if a == nil { return nil @@ -712,6 +757,7 @@ get_union_variant :: proc(a: any) -> any { return any{a.data, id} } +@(require_results) get_union_as_ptr_variants :: proc(val: ^$T) -> (res: intrinsics.type_convert_variants_to_pointers(T)) where intrinsics.type_is_union(T) { ptr := rawptr(val) tag := get_union_variant_raw_tag(val^) @@ -852,6 +898,7 @@ set_union_value :: proc(dst: any, value: any) -> bool { +@(require_results) as_bool :: proc(a: any) -> (value: bool, valid: bool) { if a == nil { return } a := a @@ -874,6 +921,7 @@ as_bool :: proc(a: any) -> (value: bool, valid: bool) { return } +@(require_results) as_int :: proc(a: any) -> (value: int, valid: bool) { v: i64 v, valid = as_i64(a) @@ -881,6 +929,7 @@ as_int :: proc(a: any) -> (value: int, valid: bool) { return } +@(require_results) as_uint :: proc(a: any) -> (value: uint, valid: bool) { v: u64 v, valid = as_u64(a) @@ -888,6 +937,7 @@ as_uint :: proc(a: any) -> (value: uint, valid: bool) { return } +@(require_results) as_i64 :: proc(a: any) -> (value: i64, valid: bool) { if a == nil { return } a := a @@ -995,6 +1045,7 @@ as_i64 :: proc(a: any) -> (value: i64, valid: bool) { return } +@(require_results) as_u64 :: proc(a: any) -> (value: u64, valid: bool) { if a == nil { return } a := a @@ -1104,6 +1155,7 @@ as_u64 :: proc(a: any) -> (value: u64, valid: bool) { } +@(require_results) as_f64 :: proc(a: any) -> (value: f64, valid: bool) { if a == nil { return } a := a @@ -1210,6 +1262,7 @@ as_f64 :: proc(a: any) -> (value: f64, valid: bool) { } +@(require_results) as_string :: proc(a: any) -> (value: string, valid: bool) { if a == nil { return } a := a @@ -1229,6 +1282,7 @@ as_string :: proc(a: any) -> (value: string, valid: bool) { return } +@(require_results) relative_pointer_to_absolute :: proc(a: any) -> rawptr { if a == nil { return nil } a := a @@ -1243,6 +1297,7 @@ relative_pointer_to_absolute :: proc(a: any) -> rawptr { } +@(require_results) relative_pointer_to_absolute_raw :: proc(data: rawptr, base_integer_id: typeid) -> rawptr { _handle :: proc(ptr: ^$T) -> rawptr where intrinsics.type_is_integer(T) { if ptr^ == 0 { @@ -1285,6 +1340,7 @@ relative_pointer_to_absolute_raw :: proc(data: rawptr, base_integer_id: typeid) +@(require_results) as_pointer :: proc(a: any) -> (value: rawptr, valid: bool) { if a == nil { return } a := a @@ -1312,6 +1368,7 @@ as_pointer :: proc(a: any) -> (value: rawptr, valid: bool) { } +@(require_results) as_raw_data :: proc(a: any) -> (value: rawptr, valid: bool) { if a == nil { return } a := a @@ -1348,9 +1405,11 @@ ne :: not_equal DEFAULT_EQUAL_MAX_RECURSION_LEVEL :: 32 +@(require_results) not_equal :: proc(a, b: any, including_indirect_array_recursion := false, recursion_level := 0) -> bool { return !equal(a, b, including_indirect_array_recursion, recursion_level) } +@(require_results) equal :: proc(a, b: any, including_indirect_array_recursion := false, recursion_level := 0) -> bool { if a == nil && b == nil { return true @@ -1387,7 +1446,7 @@ equal :: proc(a, b: any, including_indirect_array_recursion := false, recursion_ switch v in t.variant { case Type_Info_Named: unreachable() - case Type_Info_Tuple: + case Type_Info_Parameters: unreachable() case Type_Info_Any: if !including_indirect_array_recursion { diff --git a/core/reflect/types.odin b/core/reflect/types.odin index f53b18e0d..cad9b1f66 100644 --- a/core/reflect/types.odin +++ b/core/reflect/types.odin @@ -3,17 +3,16 @@ package reflect import "core:io" import "core:strings" +@(require_results) are_types_identical :: proc(a, b: ^Type_Info) -> bool { if a == b { return true } - if (a == nil && b != nil) || - (a != nil && b == nil) { + if a == nil || b == nil { return false } - switch { case a.size != b.size, a.align != b.align: return false @@ -102,8 +101,8 @@ are_types_identical :: proc(a, b: ^Type_Info) -> bool { y := b.variant.(Type_Info_Slice) or_return return are_types_identical(x.elem, y.elem) - case Type_Info_Tuple: - y := b.variant.(Type_Info_Tuple) or_return + case Type_Info_Parameters: + y := b.variant.(Type_Info_Parameters) or_return if len(x.types) != len(y.types) { return false } for _, i in x.types { xt, yt := x.types[i], y.types[i] @@ -180,6 +179,7 @@ are_types_identical :: proc(a, b: ^Type_Info) -> bool { return false } +@(require_results) is_signed :: proc(info: ^Type_Info) -> bool { if info == nil { return false } #partial switch i in type_info_base(info).variant { @@ -188,6 +188,7 @@ is_signed :: proc(info: ^Type_Info) -> bool { } return false } +@(require_results) is_unsigned :: proc(info: ^Type_Info) -> bool { if info == nil { return false } #partial switch i in type_info_base(info).variant { @@ -197,6 +198,7 @@ is_unsigned :: proc(info: ^Type_Info) -> bool { return false } +@(require_results) is_byte :: proc(info: ^Type_Info) -> bool { if info == nil { return false } #partial switch i in type_info_base(info).variant { @@ -206,66 +208,79 @@ is_byte :: proc(info: ^Type_Info) -> bool { } +@(require_results) is_integer :: proc(info: ^Type_Info) -> bool { if info == nil { return false } _, ok := type_info_base(info).variant.(Type_Info_Integer) return ok } +@(require_results) is_rune :: proc(info: ^Type_Info) -> bool { if info == nil { return false } _, ok := type_info_base(info).variant.(Type_Info_Rune) return ok } +@(require_results) is_float :: proc(info: ^Type_Info) -> bool { if info == nil { return false } _, ok := type_info_base(info).variant.(Type_Info_Float) return ok } +@(require_results) is_complex :: proc(info: ^Type_Info) -> bool { if info == nil { return false } _, ok := type_info_base(info).variant.(Type_Info_Complex) return ok } +@(require_results) is_quaternion :: proc(info: ^Type_Info) -> bool { if info == nil { return false } _, ok := type_info_base(info).variant.(Type_Info_Quaternion) return ok } +@(require_results) is_any :: proc(info: ^Type_Info) -> bool { if info == nil { return false } _, ok := type_info_base(info).variant.(Type_Info_Any) return ok } +@(require_results) is_string :: proc(info: ^Type_Info) -> bool { if info == nil { return false } _, ok := type_info_base(info).variant.(Type_Info_String) return ok } +@(require_results) is_cstring :: proc(info: ^Type_Info) -> bool { if info == nil { return false } v, ok := type_info_base(info).variant.(Type_Info_String) return ok && v.is_cstring } +@(require_results) is_boolean :: proc(info: ^Type_Info) -> bool { if info == nil { return false } _, ok := type_info_base(info).variant.(Type_Info_Boolean) return ok } +@(require_results) is_pointer :: proc(info: ^Type_Info) -> bool { if info == nil { return false } _, ok := type_info_base(info).variant.(Type_Info_Pointer) return ok } +@(require_results) is_multi_pointer :: proc(info: ^Type_Info) -> bool { if info == nil { return false } _, ok := type_info_base(info).variant.(Type_Info_Multi_Pointer) return ok } +@(require_results) is_soa_pointer :: proc(info: ^Type_Info) -> bool { if info == nil { return false } _, ok := type_info_base(info).variant.(Type_Info_Soa_Pointer) return ok } +@(require_results) is_pointer_internally :: proc(info: ^Type_Info) -> bool { if info == nil { return false } #partial switch v in info.variant { @@ -277,76 +292,97 @@ is_pointer_internally :: proc(info: ^Type_Info) -> bool { } return false } +@(require_results) is_procedure :: proc(info: ^Type_Info) -> bool { if info == nil { return false } _, ok := type_info_base(info).variant.(Type_Info_Procedure) return ok } +@(require_results) is_array :: proc(info: ^Type_Info) -> bool { if info == nil { return false } _, ok := type_info_base(info).variant.(Type_Info_Array) return ok } +@(require_results) is_enumerated_array :: proc(info: ^Type_Info) -> bool { if info == nil { return false } _, ok := type_info_base(info).variant.(Type_Info_Enumerated_Array) return ok } +@(require_results) is_dynamic_array :: proc(info: ^Type_Info) -> bool { if info == nil { return false } _, ok := type_info_base(info).variant.(Type_Info_Dynamic_Array) return ok } +@(require_results) is_dynamic_map :: proc(info: ^Type_Info) -> bool { if info == nil { return false } _, ok := type_info_base(info).variant.(Type_Info_Map) return ok } +@(require_results) is_bit_set :: proc(info: ^Type_Info) -> bool { if info == nil { return false } _, ok := type_info_base(info).variant.(Type_Info_Bit_Set) return ok } +@(require_results) is_slice :: proc(info: ^Type_Info) -> bool { if info == nil { return false } _, ok := type_info_base(info).variant.(Type_Info_Slice) return ok } -is_tuple :: proc(info: ^Type_Info) -> bool { +@(require_results) +is_parameters :: proc(info: ^Type_Info) -> bool { if info == nil { return false } - _, ok := type_info_base(info).variant.(Type_Info_Tuple) + _, ok := type_info_base(info).variant.(Type_Info_Parameters) return ok } +@(require_results, deprecated="prefer is_parameters") +is_tuple :: proc(info: ^Type_Info) -> bool { + if info == nil { return false } + _, ok := type_info_base(info).variant.(Type_Info_Parameters) + return ok +} +@(require_results) is_struct :: proc(info: ^Type_Info) -> bool { if info == nil { return false } s, ok := type_info_base(info).variant.(Type_Info_Struct) return ok && !s.is_raw_union } +@(require_results) is_raw_union :: proc(info: ^Type_Info) -> bool { if info == nil { return false } s, ok := type_info_base(info).variant.(Type_Info_Struct) return ok && s.is_raw_union } +@(require_results) is_union :: proc(info: ^Type_Info) -> bool { if info == nil { return false } _, ok := type_info_base(info).variant.(Type_Info_Union) return ok } +@(require_results) is_enum :: proc(info: ^Type_Info) -> bool { if info == nil { return false } _, ok := type_info_base(info).variant.(Type_Info_Enum) return ok } +@(require_results) is_simd_vector :: proc(info: ^Type_Info) -> bool { if info == nil { return false } _, ok := type_info_base(info).variant.(Type_Info_Simd_Vector) return ok } +@(require_results) is_relative_pointer :: proc(info: ^Type_Info) -> bool { if info == nil { return false } _, ok := type_info_base(info).variant.(Type_Info_Relative_Pointer) return ok } +@(require_results) is_relative_slice :: proc(info: ^Type_Info) -> bool { if info == nil { return false } _, ok := type_info_base(info).variant.(Type_Info_Relative_Slice) @@ -460,7 +496,7 @@ write_type_writer :: proc(w: io.Writer, ti: ^Type_Info, n_written: ^int = nil) - if info.params == nil { io.write_string(w, "()", &n) or_return } else { - t := info.params.variant.(Type_Info_Tuple) + t := info.params.variant.(Type_Info_Parameters) io.write_string(w, "(", &n) or_return for t, i in t.types { if i > 0 { @@ -474,7 +510,7 @@ write_type_writer :: proc(w: io.Writer, ti: ^Type_Info, n_written: ^int = nil) - io.write_string(w, " -> ", &n) or_return write_type(w, info.results, &n) or_return } - case Type_Info_Tuple: + case Type_Info_Parameters: count := len(info.names) if count != 1 { io.write_string(w, "(", &n) or_return @@ -527,7 +563,7 @@ write_type_writer :: proc(w: io.Writer, ti: ^Type_Info, n_written: ^int = nil) - case .None: // Ignore case .Fixed: io.write_string(w, "#soa[", &n) or_return - io.write_i64(w, i64(info.soa_len), 10 &n) or_return + io.write_i64(w, i64(info.soa_len), 10) or_return io.write_byte(w, ']', &n) or_return write_type(w, info.soa_base_type, &n) or_return return diff --git a/core/runtime/core.odin b/core/runtime/core.odin index a74bf4285..83504c9ee 100644 --- a/core/runtime/core.odin +++ b/core/runtime/core.odin @@ -83,8 +83,8 @@ Type_Info_Multi_Pointer :: struct { elem: ^Type_Info, } Type_Info_Procedure :: struct { - params: ^Type_Info, // Type_Info_Tuple - results: ^Type_Info, // Type_Info_Tuple + params: ^Type_Info, // Type_Info_Parameters + results: ^Type_Info, // Type_Info_Parameters variadic: bool, convention: Calling_Convention, } @@ -104,10 +104,12 @@ Type_Info_Enumerated_Array :: struct { } Type_Info_Dynamic_Array :: struct {elem: ^Type_Info, elem_size: int} Type_Info_Slice :: struct {elem: ^Type_Info, elem_size: int} -Type_Info_Tuple :: struct { // Only used for procedures parameters and results + +Type_Info_Parameters :: struct { // Only used for procedures parameters and results types: []^Type_Info, names: []string, } +Type_Info_Tuple :: Type_Info_Parameters // Will be removed eventually Type_Info_Struct :: struct { types: []^Type_Info, @@ -117,6 +119,7 @@ Type_Info_Struct :: struct { tags: []string, is_packed: bool, is_raw_union: bool, + is_no_copy: bool, custom_align: bool, equal: Equal_Proc, // set only when the struct has .Comparable set but does not have .Simple_Compare set @@ -208,7 +211,7 @@ Type_Info :: struct { Type_Info_Enumerated_Array, Type_Info_Dynamic_Array, Type_Info_Slice, - Type_Info_Tuple, + Type_Info_Parameters, Type_Info_Struct, Type_Info_Union, Type_Info_Enum, @@ -422,7 +425,7 @@ Raw_Map :: struct { // Map_Hash directly, though for consistency sake it's written as if it were // an array of Map_Cell(Map_Hash). data: uintptr, // 8-bytes on 64-bits, 4-bytes on 32-bits - len: int, // 8-bytes on 64-bits, 4-bytes on 32-bits + len: uintptr, // 8-bytes on 64-bits, 4-bytes on 32-bits allocator: Allocator, // 16-bytes on 64-bits, 8-bytes on 32-bits } @@ -468,7 +471,7 @@ Odin_OS_Type :: type_of(ODIN_OS) arm32, arm64, wasm32, - wasm64, + wasm64p32, } */ Odin_Arch_Type :: type_of(ODIN_ARCH) @@ -505,11 +508,8 @@ Odin_Endian_Type :: type_of(ODIN_ENDIAN) foreign { @(link_name="__$startup_runtime") _startup_runtime :: proc "odin" () --- -} - -@(link_name="__$cleanup_runtime") -_cleanup_runtime :: proc() { - default_temp_allocator_destroy(&global_default_temp_allocator_data) + @(link_name="__$cleanup_runtime") + _cleanup_runtime :: proc "odin" () --- } _cleanup_runtime_contextless :: proc "contextless" () { @@ -566,7 +566,7 @@ __type_info_of :: proc "contextless" (id: typeid) -> ^Type_Info #no_bounds_check return &type_table[n] } -when !ODIN_DISALLOW_RTTI { +when !ODIN_NO_RTTI { typeid_base :: proc "contextless" (id: typeid) -> typeid { ti := type_info_of(id) ti = type_info_base(ti) @@ -622,7 +622,9 @@ __init_context :: proc "contextless" (c: ^Context) { c.allocator.data = nil c.temp_allocator.procedure = default_temp_allocator_proc - c.temp_allocator.data = &global_default_temp_allocator_data + when !NO_DEFAULT_TEMP_ALLOCATOR { + c.temp_allocator.data = &global_default_temp_allocator_data + } when !ODIN_DISABLE_ASSERT { c.assertion_failure_proc = default_assertion_failure_proc diff --git a/core/runtime/core_builtin.odin b/core/runtime/core_builtin.odin index cbcb162a8..9f2899bcc 100644 --- a/core/runtime/core_builtin.odin +++ b/core/runtime/core_builtin.odin @@ -6,7 +6,7 @@ import "core:intrinsics" Maybe :: union($T: typeid) {T} -@builtin +@(builtin, require_results) container_of :: #force_inline proc "contextless" (ptr: $P/^$Field_Type, $T: typeid, $field_name: string) -> ^T where intrinsics.type_has_field(T, field_name), intrinsics.type_field_type(T, field_name) == Field_Type { @@ -15,14 +15,23 @@ container_of :: #force_inline proc "contextless" (ptr: $P/^$Field_Type, $T: type } -@thread_local global_default_temp_allocator_data: Default_Temp_Allocator +when !NO_DEFAULT_TEMP_ALLOCATOR { + @thread_local global_default_temp_allocator_data: Default_Temp_Allocator +} -@builtin +@(builtin, disabled=NO_DEFAULT_TEMP_ALLOCATOR) init_global_temporary_allocator :: proc(size: int, backup_allocator := context.allocator) { - default_temp_allocator_init(&global_default_temp_allocator_data, size, backup_allocator) + when !NO_DEFAULT_TEMP_ALLOCATOR { + default_temp_allocator_init(&global_default_temp_allocator_data, size, backup_allocator) + } } +// `copy_slice` is a built-in procedure that copies elements from a source slice `src` to a destination slice `dst`. +// The source and destination may overlap. Copy returns the number of elements copied, which will be the minimum +// of len(src) and len(dst). +// +// Prefer the procedure group `copy`. @builtin copy_slice :: proc "contextless" (dst, src: $T/[]$E) -> int { n := max(0, min(len(dst), len(src))) @@ -31,6 +40,11 @@ copy_slice :: proc "contextless" (dst, src: $T/[]$E) -> int { } return n } +// `copy_from_string` is a built-in procedure that copies elements from a source slice `src` to a destination string `dst`. +// The source and destination may overlap. Copy returns the number of elements copied, which will be the minimum +// of len(src) and len(dst). +// +// Prefer the procedure group `copy`. @builtin copy_from_string :: proc "contextless" (dst: $T/[]$E/u8, src: $S/string) -> int { n := max(0, min(len(dst), len(src))) @@ -39,11 +53,20 @@ copy_from_string :: proc "contextless" (dst: $T/[]$E/u8, src: $S/string) -> int } return n } +// `copy` is a built-in procedure that copies elements from a source slice `src` to a destination slice/string `dst`. +// The source and destination may overlap. Copy returns the number of elements copied, which will be the minimum +// of len(src) and len(dst). @builtin copy :: proc{copy_slice, copy_from_string} +// `unordered_remove` removed the element at the specified `index`. It does so by replacing the current end value +// with the old value, and reducing the length of the dynamic array by 1. +// +// Note: This is an O(1) operation. +// Note: If you the elements to remain in their order, use `ordered_remove`. +// Note: If the index is out of bounds, this procedure will panic. @builtin unordered_remove :: proc(array: ^$D/[dynamic]$T, index: int, loc := #caller_location) #no_bounds_check { bounds_check_error_loc(loc, index, len(array)) @@ -53,7 +76,11 @@ unordered_remove :: proc(array: ^$D/[dynamic]$T, index: int, loc := #caller_loca } (^Raw_Dynamic_Array)(array).len -= 1 } - +// `ordered_remove` removed the element at the specified `index` whilst keeping the order of the other elements. +// +// Note: This is an O(N) operation. +// Note: If you the elements do not have to remain in their order, prefer `unordered_remove`. +// Note: If the index is out of bounds, this procedure will panic. @builtin ordered_remove :: proc(array: ^$D/[dynamic]$T, index: int, loc := #caller_location) #no_bounds_check { bounds_check_error_loc(loc, index, len(array)) @@ -63,6 +90,10 @@ ordered_remove :: proc(array: ^$D/[dynamic]$T, index: int, loc := #caller_locati (^Raw_Dynamic_Array)(array).len -= 1 } +// `remove_range` removes a range of elements specified by the range `lo` and `hi`, whilst keeping the order of the other elements. +// +// Note: This is an O(N) operation. +// Note: If the range is out of bounds, this procedure will panic. @builtin remove_range :: proc(array: ^$D/[dynamic]$T, lo, hi: int, loc := #caller_location) #no_bounds_check { slice_expr_error_lo_hi_loc(loc, lo, hi, len(array)) @@ -76,15 +107,20 @@ remove_range :: proc(array: ^$D/[dynamic]$T, lo, hi: int, loc := #caller_locatio } +// `pop` will remove and return the end value of dynamic array `array` and reduces the length of `array` by 1. +// +// Note: If the dynamic array as no elements (`len(array) == 0`), this procedure will panic. @builtin pop :: proc(array: ^$T/[dynamic]$E, loc := #caller_location) -> (res: E) #no_bounds_check { - assert(len(array) > 0, "", loc) + assert(len(array) > 0, loc=loc) res = array[len(array)-1] (^Raw_Dynamic_Array)(array).len -= 1 return res } +// `pop_safe` trys to remove and return the end value of dynamic array `array` and reduces the length of `array` by 1. +// If the operation is not possible, it will return false. @builtin pop_safe :: proc(array: ^$T/[dynamic]$E) -> (res: E, ok: bool) #no_bounds_check { if len(array) == 0 { @@ -95,9 +131,12 @@ pop_safe :: proc(array: ^$T/[dynamic]$E) -> (res: E, ok: bool) #no_bounds_check return } +// `pop_front` will remove and return the first value of dynamic array `array` and reduces the length of `array` by 1. +// +// Note: If the dynamic array as no elements (`len(array) == 0`), this procedure will panic. @builtin pop_front :: proc(array: ^$T/[dynamic]$E, loc := #caller_location) -> (res: E) #no_bounds_check { - assert(len(array) > 0, "", loc) + assert(len(array) > 0, loc=loc) res = array[0] if len(array) > 1 { copy(array[0:], array[1:]) @@ -106,6 +145,8 @@ pop_front :: proc(array: ^$T/[dynamic]$E, loc := #caller_location) -> (res: E) # return res } +// `pop_front_safe` trys to return and remove the first value of dynamic array `array` and reduces the length of `array` by 1. +// If the operation is not possible, it will return false. @builtin pop_front_safe :: proc(array: ^$T/[dynamic]$E) -> (res: E, ok: bool) #no_bounds_check { if len(array) == 0 { @@ -120,12 +161,15 @@ pop_front_safe :: proc(array: ^$T/[dynamic]$E) -> (res: E, ok: bool) #no_bounds_ } +// `clear` will set the length of a passed dynamic array or map to `0` @builtin clear :: proc{clear_dynamic_array, clear_map} +// `reserve` will try to reserve memory of a passed dynamic array or map to the requested element count (setting the `cap`). @builtin reserve :: proc{reserve_dynamic_array, reserve_map} +// `resize` will try to resize memory of a passed dynamic array or map to the requested element count (setting the `len`, and possibly `cap`). @builtin resize :: proc{resize_dynamic_array} @@ -133,36 +177,56 @@ resize :: proc{resize_dynamic_array} @builtin shrink :: proc{shrink_dynamic_array, shrink_map} +// `free` will try to free the passed pointer, with the given `allocator` if the allocator supports this operation. @builtin free :: proc{mem_free} +// `free_all` will try to free/reset all of the memory of the given `allocator` if the allocator supports this operation. @builtin free_all :: proc{mem_free_all} +// `delete_string` will try to free the underlying data of the passed string, with the given `allocator` if the allocator supports this operation. +// +// Note: Prefer the procedure group `delete`. @builtin delete_string :: proc(str: string, allocator := context.allocator, loc := #caller_location) -> Allocator_Error { return mem_free_with_size(raw_data(str), len(str), allocator, loc) } +// `delete_cstring` will try to free the underlying data of the passed string, with the given `allocator` if the allocator supports this operation. +// +// Note: Prefer the procedure group `delete`. @builtin delete_cstring :: proc(str: cstring, allocator := context.allocator, loc := #caller_location) -> Allocator_Error { return mem_free((^byte)(str), allocator, loc) } +// `delete_dynamic_array` will try to free the underlying data of the passed dynamic array, with the given `allocator` if the allocator supports this operation. +// +// Note: Prefer the procedure group `delete`. @builtin delete_dynamic_array :: proc(array: $T/[dynamic]$E, loc := #caller_location) -> Allocator_Error { return mem_free_with_size(raw_data(array), cap(array)*size_of(E), array.allocator, loc) } +// `delete_slice` will try to free the underlying data of the passed sliced, with the given `allocator` if the allocator supports this operation. +// +// Note: Prefer the procedure group `delete`. @builtin delete_slice :: proc(array: $T/[]$E, allocator := context.allocator, loc := #caller_location) -> Allocator_Error { return mem_free_with_size(raw_data(array), len(array)*size_of(E), allocator, loc) } +// `delete_map` will try to free the underlying data of the passed map, with the given `allocator` if the allocator supports this operation. +// +// Note: Prefer the procedure group `delete`. @builtin delete_map :: proc(m: $T/map[$K]$V, loc := #caller_location) -> Allocator_Error { return map_free_dynamic(transmute(Raw_Map)m, map_info(T), loc) } +// `delete` will try to free the underlying data of the passed built-in data structure (string, cstring, dynamic array, slice, or map), with the given `allocator` if the allocator supports this operation. +// +// Note: Prefer `delete` over the specific `delete_*` procedures where possible. @builtin delete :: proc{ delete_string, @@ -175,17 +239,18 @@ delete :: proc{ // The new built-in procedure allocates memory. The first argument is a type, not a value, and the value // return is a pointer to a newly allocated value of that type using the specified allocator, default is context.allocator -@builtin +@(builtin, require_results) new :: proc($T: typeid, allocator := context.allocator, loc := #caller_location) -> (^T, Allocator_Error) #optional_allocator_error { return new_aligned(T, align_of(T), allocator, loc) } +@(require_results) new_aligned :: proc($T: typeid, alignment: int, allocator := context.allocator, loc := #caller_location) -> (t: ^T, err: Allocator_Error) { data := mem_alloc_bytes(size_of(T), alignment, allocator, loc) or_return t = (^T)(raw_data(data)) return } -@builtin +@(builtin, require_results) new_clone :: proc(data: $T, allocator := context.allocator, loc := #caller_location) -> (t: ^T, err: Allocator_Error) #optional_allocator_error { t_data := mem_alloc_bytes(size_of(T), align_of(T), allocator, loc) or_return t = (^T)(raw_data(t_data)) @@ -197,6 +262,7 @@ new_clone :: proc(data: $T, allocator := context.allocator, loc := #caller_locat DEFAULT_RESERVE_CAPACITY :: 16 +@(require_results) make_aligned :: proc($T: typeid/[]$E, #any_int len: int, alignment: int, allocator := context.allocator, loc := #caller_location) -> (T, Allocator_Error) #optional_allocator_error { make_slice_error_loc(loc, len) data, err := mem_alloc_bytes(size_of(E)*len, alignment, allocator, loc) @@ -207,19 +273,35 @@ make_aligned :: proc($T: typeid/[]$E, #any_int len: int, alignment: int, allocat return transmute(T)s, err } -@(builtin) +// `make_slice` allocates and initializes a slice. Like `new`, the first argument is a type, not a value. +// Unlike `new`, `make`'s return value is the same as the type of its argument, not a pointer to it. +// +// Note: Prefer using the procedure group `make`. +@(builtin, require_results) make_slice :: proc($T: typeid/[]$E, #any_int len: int, allocator := context.allocator, loc := #caller_location) -> (T, Allocator_Error) #optional_allocator_error { return make_aligned(T, len, align_of(E), allocator, loc) } -@(builtin) +// `make_dynamic_array` allocates and initializes a dynamic array. Like `new`, the first argument is a type, not a value. +// Unlike `new`, `make`'s return value is the same as the type of its argument, not a pointer to it. +// +// Note: Prefer using the procedure group `make`. +@(builtin, require_results) make_dynamic_array :: proc($T: typeid/[dynamic]$E, allocator := context.allocator, loc := #caller_location) -> (T, Allocator_Error) #optional_allocator_error { return make_dynamic_array_len_cap(T, 0, DEFAULT_RESERVE_CAPACITY, allocator, loc) } -@(builtin) +// `make_dynamic_array_len` allocates and initializes a dynamic array. Like `new`, the first argument is a type, not a value. +// Unlike `new`, `make`'s return value is the same as the type of its argument, not a pointer to it. +// +// Note: Prefer using the procedure group `make`. +@(builtin, require_results) make_dynamic_array_len :: proc($T: typeid/[dynamic]$E, #any_int len: int, allocator := context.allocator, loc := #caller_location) -> (T, Allocator_Error) #optional_allocator_error { return make_dynamic_array_len_cap(T, len, len, allocator, loc) } -@(builtin) +// `make_dynamic_array_len_cap` allocates and initializes a dynamic array. Like `new`, the first argument is a type, not a value. +// Unlike `new`, `make`'s return value is the same as the type of its argument, not a pointer to it. +// +// Note: Prefer using the procedure group `make`. +@(builtin, require_results) make_dynamic_array_len_cap :: proc($T: typeid/[dynamic]$E, #any_int len: int, #any_int cap: int, allocator := context.allocator, loc := #caller_location) -> (array: T, err: Allocator_Error) #optional_allocator_error { make_dynamic_array_error_loc(loc, len, cap) data := mem_alloc_bytes(size_of(E)*cap, align_of(E), allocator, loc) or_return @@ -230,16 +312,25 @@ make_dynamic_array_len_cap :: proc($T: typeid/[dynamic]$E, #any_int len: int, #a array = transmute(T)s return } -@(builtin) -make_map :: proc($T: typeid/map[$K]$E, #any_int capacity: int = 1< T { +// `make_map` allocates and initializes a dynamic array. Like `new`, the first argument is a type, not a value. +// Unlike `new`, `make`'s return value is the same as the type of its argument, not a pointer to it. +// +// Note: Prefer using the procedure group `make`. +@(builtin, require_results) +make_map :: proc($T: typeid/map[$K]$E, #any_int capacity: int = 1< (m: T, err: Allocator_Error) #optional_allocator_error { make_map_expr_error_loc(loc, capacity) context.allocator = allocator - m: T - reserve_map(&m, capacity, loc) - return m + err = reserve_map(&m, capacity, loc) + return } -@(builtin) +// `make_multi_pointer` allocates and initializes a dynamic array. Like `new`, the first argument is a type, not a value. +// Unlike `new`, `make`'s return value is the same as the type of its argument, not a pointer to it. +// +// This is "similar" to doing `raw_data(make([]E, len, allocator))`. +// +// Note: Prefer using the procedure group `make`. +@(builtin, require_results) make_multi_pointer :: proc($T: typeid/[^]$E, #any_int len: int, allocator := context.allocator, loc := #caller_location) -> (mp: T, err: Allocator_Error) #optional_allocator_error { make_slice_error_loc(loc, len) data := mem_alloc_bytes(size_of(E)*len, align_of(E), allocator, loc) or_return @@ -251,8 +342,9 @@ make_multi_pointer :: proc($T: typeid/[^]$E, #any_int len: int, allocator := con } -// The make built-in procedure allocates and initializes a value of type slice, dynamic array, or map (only) -// Similar to new, the first argument is a type, not a value. Unlike new, make's return type is the same as the +// `make` built-in procedure allocates and initializes a value of type slice, dynamic array, map, or multi-pointer (only). +// +// Similar to `new`, the first argument is a type, not a value. Unlike new, make's return type is the same as the // type of its argument, not a pointer to it. // Make uses the specified allocator, default is context.allocator, default is context.allocator @builtin @@ -267,6 +359,9 @@ make :: proc{ +// `clear_map` will set the length of a passed map to `0` +// +// Note: Prefer the procedure group `clear` @builtin clear_map :: proc "contextless" (m: ^$T/map[$K]$V) { if m == nil { @@ -275,21 +370,21 @@ clear_map :: proc "contextless" (m: ^$T/map[$K]$V) { map_clear_dynamic((^Raw_Map)(m), map_info(T)) } +// `reserve_map` will try to reserve memory of a passed map to the requested element count (setting the `cap`). +// +// Note: Prefer the procedure group `reserve` @builtin -reserve_map :: proc(m: ^$T/map[$K]$V, capacity: int, loc := #caller_location) { - if m != nil { - __dynamic_map_reserve((^Raw_Map)(m), map_info(T), uint(capacity), loc) - } +reserve_map :: proc(m: ^$T/map[$K]$V, capacity: int, loc := #caller_location) -> Allocator_Error { + return __dynamic_map_reserve((^Raw_Map)(m), map_info(T), uint(capacity), loc) if m != nil else nil } -/* - Shrinks the capacity of a map down to the current length. -*/ +// Shrinks the capacity of a map down to the current length. +// +// Note: Prefer the procedure group `shrink` @builtin -shrink_map :: proc(m: ^$T/map[$K]$V, loc := #caller_location) -> (did_shrink: bool) { +shrink_map :: proc(m: ^$T/map[$K]$V, loc := #caller_location) -> (did_shrink: bool, err: Allocator_Error) { if m != nil { - err := map_shrink_dynamic((^Raw_Map)(m), map_info(T), loc) - did_shrink = err == nil + return map_shrink_dynamic((^Raw_Map)(m), map_info(T), loc) } return } @@ -312,78 +407,85 @@ delete_key :: proc(m: ^$T/map[$K]$V, key: K) -> (deleted_key: K, deleted_value: @builtin -append_elem :: proc(array: ^$T/[dynamic]$E, arg: E, loc := #caller_location) -> int { +append_elem :: proc(array: ^$T/[dynamic]$E, arg: E, loc := #caller_location) -> (n: int, err: Allocator_Error) #optional_allocator_error { if array == nil { - return 0 + return 0, nil } when size_of(E) == 0 { + array := (^Raw_Dynamic_Array)(array) array.len += 1 - return 1 + return 1, nil } else { if cap(array) < len(array)+1 { cap := 2 * cap(array) + max(8, 1) - _ = reserve(array, cap, loc) + err = reserve(array, cap, loc) // do not 'or_return' here as it could be a partial success } if cap(array)-len(array) > 0 { a := (^Raw_Dynamic_Array)(array) when size_of(E) != 0 { data := ([^]E)(a.data) - assert(condition=data != nil, loc=loc) + assert(data != nil, loc=loc) data[a.len] = arg } a.len += 1 - return 1 + return 1, err } - return 0 + return 0, err } } @builtin -append_elems :: proc(array: ^$T/[dynamic]$E, args: ..E, loc := #caller_location) -> int { +append_elems :: proc(array: ^$T/[dynamic]$E, args: ..E, loc := #caller_location) -> (n: int, err: Allocator_Error) #optional_allocator_error { if array == nil { - return 0 + return 0, nil } arg_len := len(args) if arg_len <= 0 { - return 0 + return 0, nil } when size_of(E) == 0 { + array := (^Raw_Dynamic_Array)(array) array.len += arg_len - return arg_len + return arg_len, nil } else { if cap(array) < len(array)+arg_len { cap := 2 * cap(array) + max(8, arg_len) - _ = reserve(array, cap, loc) + err = reserve(array, cap, loc) // do not 'or_return' here as it could be a partial success } arg_len = min(cap(array)-len(array), arg_len) if arg_len > 0 { a := (^Raw_Dynamic_Array)(array) when size_of(E) != 0 { data := ([^]E)(a.data) - assert(condition=data != nil, loc=loc) + assert(data != nil, loc=loc) intrinsics.mem_copy(&data[a.len], raw_data(args), size_of(E) * arg_len) } a.len += arg_len } - return arg_len + return arg_len, err } } // The append_string built-in procedure appends a string to the end of a [dynamic]u8 like type @builtin -append_elem_string :: proc(array: ^$T/[dynamic]$E/u8, arg: $A/string, loc := #caller_location) -> int { +append_elem_string :: proc(array: ^$T/[dynamic]$E/u8, arg: $A/string, loc := #caller_location) -> (n: int, err: Allocator_Error) #optional_allocator_error { args := transmute([]E)arg - return append_elems(array=array, args=args, loc=loc) + return append_elems(array, ..args, loc=loc) } // The append_string built-in procedure appends multiple strings to the end of a [dynamic]u8 like type @builtin -append_string :: proc(array: ^$T/[dynamic]$E/u8, args: ..string, loc := #caller_location) -> (n: int) { +append_string :: proc(array: ^$T/[dynamic]$E/u8, args: ..string, loc := #caller_location) -> (n: int, err: Allocator_Error) #optional_allocator_error { + n_arg: int for arg in args { - n += append(array = array, args = transmute([]E)(arg), loc = loc) + n_arg, err = append(array, ..transmute([]E)(arg), loc=loc) + n += n_arg + if err != nil { + return + } } return } @@ -393,18 +495,18 @@ append_string :: proc(array: ^$T/[dynamic]$E/u8, args: ..string, loc := #caller_ @builtin -append_nothing :: proc(array: ^$T/[dynamic]$E, loc := #caller_location) -> int { +append_nothing :: proc(array: ^$T/[dynamic]$E, loc := #caller_location) -> (n: int, err: Allocator_Error) #optional_allocator_error { if array == nil { - return 0 + return 0, nil } prev_len := len(array) - resize(array, len(array)+1) - return len(array)-prev_len + resize(array, len(array)+1, loc) or_return + return len(array)-prev_len, nil } @builtin -inject_at_elem :: proc(array: ^$T/[dynamic]$E, index: int, arg: E, loc := #caller_location) -> (ok: bool) #no_bounds_check { +inject_at_elem :: proc(array: ^$T/[dynamic]$E, index: int, arg: E, loc := #caller_location) -> (ok: bool, err: Allocator_Error) #no_bounds_check #optional_allocator_error { if array == nil { return } @@ -412,18 +514,17 @@ inject_at_elem :: proc(array: ^$T/[dynamic]$E, index: int, arg: E, loc := #calle m :: 1 new_size := n + m - if resize(array, new_size, loc) { - when size_of(E) != 0 { - copy(array[index + m:], array[index:]) - array[index] = arg - } - ok = true + resize(array, new_size, loc) or_return + when size_of(E) != 0 { + copy(array[index + m:], array[index:]) + array[index] = arg } + ok = true return } @builtin -inject_at_elems :: proc(array: ^$T/[dynamic]$E, index: int, args: ..E, loc := #caller_location) -> (ok: bool) #no_bounds_check { +inject_at_elems :: proc(array: ^$T/[dynamic]$E, index: int, args: ..E, loc := #caller_location) -> (ok: bool, err: Allocator_Error) #no_bounds_check #optional_allocator_error { if array == nil { return } @@ -436,18 +537,17 @@ inject_at_elems :: proc(array: ^$T/[dynamic]$E, index: int, args: ..E, loc := #c m := len(args) new_size := n + m - if resize(array, new_size, loc) { - when size_of(E) != 0 { - copy(array[index + m:], array[index:]) - copy(array[index:], args) - } - ok = true + resize(array, new_size, loc) or_return + when size_of(E) != 0 { + copy(array[index + m:], array[index:]) + copy(array[index:], args) } + ok = true return } @builtin -inject_at_elem_string :: proc(array: ^$T/[dynamic]$E/u8, index: int, arg: string, loc := #caller_location) -> (ok: bool) #no_bounds_check { +inject_at_elem_string :: proc(array: ^$T/[dynamic]$E/u8, index: int, arg: string, loc := #caller_location) -> (ok: bool, err: Allocator_Error) #no_bounds_check #optional_allocator_error { if array == nil { return } @@ -460,11 +560,10 @@ inject_at_elem_string :: proc(array: ^$T/[dynamic]$E/u8, index: int, arg: string m := len(arg) new_size := n + m - if resize(array, new_size, loc) { - copy(array[index+m:], array[index:]) - copy(array[index:], arg) - ok = true - } + resize(array, new_size, loc) or_return + copy(array[index+m:], array[index:]) + copy(array[index:], arg) + ok = true return } @@ -473,11 +572,12 @@ inject_at_elem_string :: proc(array: ^$T/[dynamic]$E/u8, index: int, arg: string @builtin -assign_at_elem :: proc(array: ^$T/[dynamic]$E, index: int, arg: E, loc := #caller_location) -> (ok: bool) #no_bounds_check { +assign_at_elem :: proc(array: ^$T/[dynamic]$E, index: int, arg: E, loc := #caller_location) -> (ok: bool, err: Allocator_Error) #no_bounds_check #optional_allocator_error { if index < len(array) { array[index] = arg ok = true - } else if resize(array, index+1, loc) { + } else { + resize(array, index+1, loc) or_return array[index] = arg ok = true } @@ -486,11 +586,12 @@ assign_at_elem :: proc(array: ^$T/[dynamic]$E, index: int, arg: E, loc := #calle @builtin -assign_at_elems :: proc(array: ^$T/[dynamic]$E, index: int, args: ..E, loc := #caller_location) -> (ok: bool) #no_bounds_check { +assign_at_elems :: proc(array: ^$T/[dynamic]$E, index: int, args: ..E, loc := #caller_location) -> (ok: bool, err: Allocator_Error) #no_bounds_check #optional_allocator_error { if index+len(args) < len(array) { copy(array[index:], args) ok = true - } else if resize(array, index+1+len(args), loc) { + } else { + resize(array, index+1+len(args), loc) or_return copy(array[index:], args) ok = true } @@ -499,13 +600,14 @@ assign_at_elems :: proc(array: ^$T/[dynamic]$E, index: int, args: ..E, loc := #c @builtin -assign_at_elem_string :: proc(array: ^$T/[dynamic]$E/u8, index: int, arg: string, loc := #caller_location) -> (ok: bool) #no_bounds_check { +assign_at_elem_string :: proc(array: ^$T/[dynamic]$E/u8, index: int, arg: string, loc := #caller_location) -> (ok: bool, err: Allocator_Error) #no_bounds_check #optional_allocator_error { if len(args) == 0 { ok = true } else if index+len(args) < len(array) { copy(array[index:], args) ok = true - } else if resize(array, index+1+len(args), loc) { + } else { + resize(array, index+1+len(args), loc) or_return copy(array[index:], args) ok = true } @@ -517,6 +619,9 @@ assign_at_elem_string :: proc(array: ^$T/[dynamic]$E/u8, index: int, arg: string +// `clear_dynamic_array` will set the length of a passed dynamic array to `0` +// +// Note: Prefer the procedure group `clear`. @builtin clear_dynamic_array :: proc "contextless" (array: ^$T/[dynamic]$E) { if array != nil { @@ -524,15 +629,18 @@ clear_dynamic_array :: proc "contextless" (array: ^$T/[dynamic]$E) { } } +// `reserve_dynamic_array` will try to reserve memory of a passed dynamic array or map to the requested element count (setting the `cap`). +// +// Note: Prefer the procedure group `reserve`. @builtin -reserve_dynamic_array :: proc(array: ^$T/[dynamic]$E, capacity: int, loc := #caller_location) -> bool { +reserve_dynamic_array :: proc(array: ^$T/[dynamic]$E, capacity: int, loc := #caller_location) -> Allocator_Error { if array == nil { - return false + return nil } a := (^Raw_Dynamic_Array)(array) if capacity <= a.cap { - return true + return nil } if a.allocator.procedure == nil { @@ -544,26 +652,29 @@ reserve_dynamic_array :: proc(array: ^$T/[dynamic]$E, capacity: int, loc := #cal new_size := capacity * size_of(E) allocator := a.allocator - new_data, err := mem_resize(a.data, old_size, new_size, align_of(E), allocator, loc) - if new_data == nil || err != nil { - return false + new_data := mem_resize(a.data, old_size, new_size, align_of(E), allocator, loc) or_return + if new_data == nil && new_size > 0 { + return .Out_Of_Memory } a.data = raw_data(new_data) a.cap = capacity - return true + return nil } +// `resize_dynamic_array` will try to resize memory of a passed dynamic array or map to the requested element count (setting the `len`, and possibly `cap`). +// +// Note: Prefer the procedure group `resize` @builtin -resize_dynamic_array :: proc(array: ^$T/[dynamic]$E, length: int, loc := #caller_location) -> bool { +resize_dynamic_array :: proc(array: ^$T/[dynamic]$E, length: int, loc := #caller_location) -> Allocator_Error { if array == nil { - return false + return nil } a := (^Raw_Dynamic_Array)(array) if length <= a.cap { a.len = max(length, 0) - return true + return nil } if a.allocator.procedure == nil { @@ -575,15 +686,15 @@ resize_dynamic_array :: proc(array: ^$T/[dynamic]$E, length: int, loc := #caller new_size := length * size_of(E) allocator := a.allocator - new_data, err := mem_resize(a.data, old_size, new_size, align_of(E), allocator, loc) - if new_data == nil || err != nil { - return false + new_data := mem_resize(a.data, old_size, new_size, align_of(E), allocator, loc) or_return + if new_data == nil && new_size > 0 { + return .Out_Of_Memory } a.data = raw_data(new_data) a.len = length a.cap = length - return true + return nil } /* @@ -594,8 +705,10 @@ resize_dynamic_array :: proc(array: ^$T/[dynamic]$E, length: int, loc := #caller Returns false if `cap(array) < new_cap`, or the allocator report failure. If `len(array) < new_cap`, then `len(array)` will be left unchanged. + + Note: Prefer the procedure group `shrink` */ -shrink_dynamic_array :: proc(array: ^$T/[dynamic]$E, new_cap := -1, loc := #caller_location) -> (did_shrink: bool) { +shrink_dynamic_array :: proc(array: ^$T/[dynamic]$E, new_cap := -1, loc := #caller_location) -> (did_shrink: bool, err: Allocator_Error) { if array == nil { return } @@ -615,15 +728,12 @@ shrink_dynamic_array :: proc(array: ^$T/[dynamic]$E, new_cap := -1, loc := #call old_size := a.cap * size_of(E) new_size := new_cap * size_of(E) - new_data, err := mem_resize(a.data, old_size, new_size, align_of(E), a.allocator, loc) - if err != nil { - return - } + new_data := mem_resize(a.data, old_size, new_size, align_of(E), a.allocator, loc) or_return a.data = raw_data(new_data) a.len = min(new_cap, a.len) a.cap = new_cap - return true + return true, nil } @builtin diff --git a/core/runtime/core_builtin_matrix.odin b/core/runtime/core_builtin_matrix.odin index 53589587c..7d60d625c 100644 --- a/core/runtime/core_builtin_matrix.odin +++ b/core/runtime/core_builtin_matrix.odin @@ -37,12 +37,12 @@ inverse :: proc{ matrix4x4_inverse, } -@(builtin) +@(builtin, require_results) hermitian_adjoint :: proc "contextless" (m: $M/matrix[$N, N]$T) -> M where intrinsics.type_is_complex(T), N >= 1 { return conj(transpose(m)) } -@(builtin) +@(builtin, require_results) matrix_trace :: proc "contextless" (m: $M/matrix[$N, N]$T) -> (trace: T) { for i in 0.. (trace: T) { return } -@(builtin) +@(builtin, require_results) matrix_minor :: proc "contextless" (m: $M/matrix[$N, N]$T, row, column: int) -> (minor: T) where N > 1 { K :: N-1 cut_down: matrix[K, K]T @@ -66,23 +66,23 @@ matrix_minor :: proc "contextless" (m: $M/matrix[$N, N]$T, row, column: int) -> -@(builtin) +@(builtin, require_results) matrix1x1_determinant :: proc "contextless" (m: $M/matrix[1, 1]$T) -> (det: T) { return m[0, 0] } -@(builtin) +@(builtin, require_results) matrix2x2_determinant :: proc "contextless" (m: $M/matrix[2, 2]$T) -> (det: T) { return m[0, 0]*m[1, 1] - m[0, 1]*m[1, 0] } -@(builtin) +@(builtin, require_results) matrix3x3_determinant :: proc "contextless" (m: $M/matrix[3, 3]$T) -> (det: T) { a := +m[0, 0] * (m[1, 1] * m[2, 2] - m[1, 2] * m[2, 1]) b := -m[0, 1] * (m[1, 0] * m[2, 2] - m[1, 2] * m[2, 0]) c := +m[0, 2] * (m[1, 0] * m[2, 1] - m[1, 1] * m[2, 0]) return a + b + c } -@(builtin) +@(builtin, require_results) matrix4x4_determinant :: proc "contextless" (m: $M/matrix[4, 4]$T) -> (det: T) { a := adjugate(m) #no_bounds_check for i in 0..<4 { @@ -94,13 +94,13 @@ matrix4x4_determinant :: proc "contextless" (m: $M/matrix[4, 4]$T) -> (det: T) { -@(builtin) +@(builtin, require_results) matrix1x1_adjugate :: proc "contextless" (x: $M/matrix[1, 1]$T) -> (y: M) { y = x return } -@(builtin) +@(builtin, require_results) matrix2x2_adjugate :: proc "contextless" (x: $M/matrix[2, 2]$T) -> (y: M) { y[0, 0] = +x[1, 1] y[0, 1] = -x[1, 0] @@ -109,7 +109,7 @@ matrix2x2_adjugate :: proc "contextless" (x: $M/matrix[2, 2]$T) -> (y: M) { return } -@(builtin) +@(builtin, require_results) matrix3x3_adjugate :: proc "contextless" (m: $M/matrix[3, 3]$T) -> (y: M) { y[0, 0] = +(m[1, 1] * m[2, 2] - m[2, 1] * m[1, 2]) y[0, 1] = -(m[1, 0] * m[2, 2] - m[2, 0] * m[1, 2]) @@ -124,7 +124,7 @@ matrix3x3_adjugate :: proc "contextless" (m: $M/matrix[3, 3]$T) -> (y: M) { } -@(builtin) +@(builtin, require_results) matrix4x4_adjugate :: proc "contextless" (x: $M/matrix[4, 4]$T) -> (y: M) { for i in 0..<4 { for j in 0..<4 { @@ -135,13 +135,13 @@ matrix4x4_adjugate :: proc "contextless" (x: $M/matrix[4, 4]$T) -> (y: M) { return } -@(builtin) +@(builtin, require_results) matrix1x1_inverse_transpose :: proc "contextless" (x: $M/matrix[1, 1]$T) -> (y: M) { y[0, 0] = 1/x[0, 0] return } -@(builtin) +@(builtin, require_results) matrix2x2_inverse_transpose :: proc "contextless" (x: $M/matrix[2, 2]$T) -> (y: M) { d := x[0, 0]*x[1, 1] - x[0, 1]*x[1, 0] when intrinsics.type_is_integer(T) { @@ -159,7 +159,7 @@ matrix2x2_inverse_transpose :: proc "contextless" (x: $M/matrix[2, 2]$T) -> (y: return } -@(builtin) +@(builtin, require_results) matrix3x3_inverse_transpose :: proc "contextless" (x: $M/matrix[3, 3]$T) -> (y: M) #no_bounds_check { a := adjugate(x) d := determinant(x) @@ -180,7 +180,7 @@ matrix3x3_inverse_transpose :: proc "contextless" (x: $M/matrix[3, 3]$T) -> (y: return } -@(builtin) +@(builtin, require_results) matrix4x4_inverse_transpose :: proc "contextless" (x: $M/matrix[4, 4]$T) -> (y: M) #no_bounds_check { a := adjugate(x) d: T @@ -204,13 +204,13 @@ matrix4x4_inverse_transpose :: proc "contextless" (x: $M/matrix[4, 4]$T) -> (y: return } -@(builtin) +@(builtin, require_results) matrix1x1_inverse :: proc "contextless" (x: $M/matrix[1, 1]$T) -> (y: M) { y[0, 0] = 1/x[0, 0] return } -@(builtin) +@(builtin, require_results) matrix2x2_inverse :: proc "contextless" (x: $M/matrix[2, 2]$T) -> (y: M) { d := x[0, 0]*x[1, 1] - x[0, 1]*x[1, 0] when intrinsics.type_is_integer(T) { @@ -228,7 +228,7 @@ matrix2x2_inverse :: proc "contextless" (x: $M/matrix[2, 2]$T) -> (y: M) { return } -@(builtin) +@(builtin, require_results) matrix3x3_inverse :: proc "contextless" (x: $M/matrix[3, 3]$T) -> (y: M) #no_bounds_check { a := adjugate(x) d := determinant(x) @@ -249,7 +249,7 @@ matrix3x3_inverse :: proc "contextless" (x: $M/matrix[3, 3]$T) -> (y: M) #no_bou return } -@(builtin) +@(builtin, require_results) matrix4x4_inverse :: proc "contextless" (x: $M/matrix[4, 4]$T) -> (y: M) #no_bounds_check { a := adjugate(x) d: T diff --git a/core/runtime/core_builtin_soa.odin b/core/runtime/core_builtin_soa.odin index a6b356642..ee2a5f2d0 100644 --- a/core/runtime/core_builtin_soa.odin +++ b/core/runtime/core_builtin_soa.odin @@ -50,6 +50,7 @@ Raw_SOA_Footer_Dynamic_Array :: struct { allocator: Allocator, } +@(builtin, require_results) raw_soa_footer_slice :: proc(array: ^$T/#soa[]$E) -> (footer: ^Raw_SOA_Footer_Slice) { if array == nil { return nil @@ -58,6 +59,7 @@ raw_soa_footer_slice :: proc(array: ^$T/#soa[]$E) -> (footer: ^Raw_SOA_Footer_Sl footer = (^Raw_SOA_Footer_Slice)(uintptr(array) + field_count*size_of(rawptr)) return } +@(builtin, require_results) raw_soa_footer_dynamic_array :: proc(array: ^$T/#soa[dynamic]$E) -> (footer: ^Raw_SOA_Footer_Dynamic_Array) { if array == nil { return nil @@ -78,7 +80,7 @@ raw_soa_footer :: proc{ -@builtin +@(builtin, require_results) make_soa_aligned :: proc($T: typeid/#soa[]$E, length: int, alignment: int, allocator := context.allocator, loc := #caller_location) -> (array: T, err: Allocator_Error) #optional_allocator_error { if length <= 0 { return @@ -137,32 +139,31 @@ make_soa_aligned :: proc($T: typeid/#soa[]$E, length: int, alignment: int, alloc return } -@builtin +@(builtin, require_results) make_soa_slice :: proc($T: typeid/#soa[]$E, length: int, allocator := context.allocator, loc := #caller_location) -> (array: T, err: Allocator_Error) #optional_allocator_error { return make_soa_aligned(T, length, align_of(E), allocator, loc) } -@builtin -make_soa_dynamic_array :: proc($T: typeid/#soa[dynamic]$E, allocator := context.allocator, loc := #caller_location) -> (array: T) { +@(builtin, require_results) +make_soa_dynamic_array :: proc($T: typeid/#soa[dynamic]$E, allocator := context.allocator, loc := #caller_location) -> (array: T, err: Allocator_Error) #optional_allocator_error { context.allocator = allocator - reserve_soa(&array, DEFAULT_RESERVE_CAPACITY, loc) - return + reserve_soa(&array, DEFAULT_RESERVE_CAPACITY, loc) or_return + return array, nil } -@builtin -make_soa_dynamic_array_len :: proc($T: typeid/#soa[dynamic]$E, auto_cast length: int, allocator := context.allocator, loc := #caller_location) -> (array: T) { +@(builtin, require_results) +make_soa_dynamic_array_len :: proc($T: typeid/#soa[dynamic]$E, #any_int length: int, allocator := context.allocator, loc := #caller_location) -> (array: T, err: Allocator_Error) #optional_allocator_error { context.allocator = allocator - resize_soa(&array, length, loc) - return + resize_soa(&array, length, loc) or_return + return array, nil } -@builtin -make_soa_dynamic_array_len_cap :: proc($T: typeid/#soa[dynamic]$E, auto_cast length, capacity: int, allocator := context.allocator, loc := #caller_location) -> (array: T) { +@(builtin, require_results) +make_soa_dynamic_array_len_cap :: proc($T: typeid/#soa[dynamic]$E, #any_int length, capacity: int, allocator := context.allocator, loc := #caller_location) -> (array: T, err: Allocator_Error) #optional_allocator_error { context.allocator = allocator - if reserve_soa(&array, capacity, loc) { - resize_soa(&array, length, loc) - } - return + reserve_soa(&array, capacity, loc) or_return + resize_soa(&array, length, loc) or_return + return array, nil } @@ -176,27 +177,25 @@ make_soa :: proc{ @builtin -resize_soa :: proc(array: ^$T/#soa[dynamic]$E, length: int, loc := #caller_location) -> bool { +resize_soa :: proc(array: ^$T/#soa[dynamic]$E, length: int, loc := #caller_location) -> Allocator_Error { if array == nil { - return false - } - if !reserve_soa(array, length, loc) { - return false + return nil } + reserve_soa(array, length, loc) or_return footer := raw_soa_footer(array) footer.len = length - return true + return nil } @builtin -reserve_soa :: proc(array: ^$T/#soa[dynamic]$E, capacity: int, loc := #caller_location) -> bool { +reserve_soa :: proc(array: ^$T/#soa[dynamic]$E, capacity: int, loc := #caller_location) -> Allocator_Error { if array == nil { - return false + return nil } old_cap := cap(array) if capacity <= old_cap { - return true + return nil } if array.allocator.procedure == nil { @@ -207,7 +206,7 @@ reserve_soa :: proc(array: ^$T/#soa[dynamic]$E, capacity: int, loc := #caller_lo footer := raw_soa_footer(array) if size_of(E) == 0 { footer.cap = capacity - return true + return nil } ti := type_info_of(typeid_of(T)) @@ -238,13 +237,10 @@ reserve_soa :: proc(array: ^$T/#soa[dynamic]$E, capacity: int, loc := #caller_lo old_data := (^rawptr)(array)^ - new_bytes, err := array.allocator.procedure( + new_bytes := array.allocator.procedure( array.allocator.data, .Alloc, new_size, max_align, nil, old_size, loc, - ) - if new_bytes == nil || err != nil { - return false - } + ) or_return new_data := raw_data(new_bytes) @@ -269,31 +265,28 @@ reserve_soa :: proc(array: ^$T/#soa[dynamic]$E, capacity: int, loc := #caller_lo new_offset += type.size * capacity } - _, err = array.allocator.procedure( + array.allocator.procedure( array.allocator.data, .Free, 0, max_align, old_data, old_size, loc, - ) + ) or_return - return true + return nil } @builtin -append_soa_elem :: proc(array: ^$T/#soa[dynamic]$E, arg: E, loc := #caller_location) { +append_soa_elem :: proc(array: ^$T/#soa[dynamic]$E, arg: E, loc := #caller_location) -> (n: int, err: Allocator_Error) #optional_allocator_error { if array == nil { - return + return 0, nil } - arg_len := 1 - - if cap(array) <= len(array)+arg_len { - cap := 2 * cap(array) + max(8, arg_len) - _ = reserve_soa(array, cap, loc) + if cap(array) <= len(array) + 1 { + cap := 2 * cap(array) + 8 + err = reserve_soa(array, cap, loc) // do not 'or_return' here as it could be a partial success } - arg_len = min(cap(array)-len(array), arg_len) footer := raw_soa_footer(array) - if size_of(E) > 0 && arg_len > 0 { + if size_of(E) > 0 && cap(array)-len(array) > 0 { ti := type_info_of(typeid_of(T)) ti = type_info_base(ti) si := &ti.variant.(Type_Info_Struct) @@ -326,12 +319,14 @@ append_soa_elem :: proc(array: ^$T/#soa[dynamic]$E, arg: E, loc := #caller_locat soa_offset += type.size * cap(array) item_offset += type.size } + footer.len += 1 + return 1, err } - footer.len += arg_len + return 0, err } @builtin -append_soa_elems :: proc(array: ^$T/#soa[dynamic]$E, args: ..E, loc := #caller_location) { +append_soa_elems :: proc(array: ^$T/#soa[dynamic]$E, args: ..E, loc := #caller_location) -> (n: int, err: Allocator_Error) #optional_allocator_error { if array == nil { return } @@ -343,7 +338,7 @@ append_soa_elems :: proc(array: ^$T/#soa[dynamic]$E, args: ..E, loc := #caller_l if cap(array) <= len(array)+arg_len { cap := 2 * cap(array) + max(8, arg_len) - _ = reserve_soa(array, cap, loc) + err = reserve_soa(array, cap, loc) // do not 'or_return' here as it could be a partial success } arg_len = min(cap(array)-len(array), arg_len) @@ -380,8 +375,8 @@ append_soa_elems :: proc(array: ^$T/#soa[dynamic]$E, args: ..E, loc := #caller_l item_offset += type.size } } - footer.len += arg_len + return arg_len, err } @@ -393,21 +388,23 @@ append_soa :: proc{ } -delete_soa_slice :: proc(array: $T/#soa[]$E, allocator := context.allocator, loc := #caller_location) { +delete_soa_slice :: proc(array: $T/#soa[]$E, allocator := context.allocator, loc := #caller_location) -> Allocator_Error { when intrinsics.type_struct_field_count(E) != 0 { array := array ptr := (^rawptr)(&array)^ - free(ptr, allocator, loc) + free(ptr, allocator, loc) or_return } + return nil } -delete_soa_dynamic_array :: proc(array: $T/#soa[dynamic]$E, loc := #caller_location) { +delete_soa_dynamic_array :: proc(array: $T/#soa[dynamic]$E, loc := #caller_location) -> Allocator_Error { when intrinsics.type_struct_field_count(E) != 0 { array := array ptr := (^rawptr)(&array)^ footer := raw_soa_footer(&array) - free(ptr, footer.allocator, loc) + free(ptr, footer.allocator, loc) or_return } + return nil } diff --git a/core/runtime/default_allocators_arena.odin b/core/runtime/default_allocators_arena.odin new file mode 100644 index 000000000..1c36c4f7c --- /dev/null +++ b/core/runtime/default_allocators_arena.odin @@ -0,0 +1,304 @@ +package runtime + +import "core:intrinsics" + +DEFAULT_ARENA_GROWING_MINIMUM_BLOCK_SIZE :: uint(DEFAULT_TEMP_ALLOCATOR_BACKING_SIZE) + +Memory_Block :: struct { + prev: ^Memory_Block, + allocator: Allocator, + base: [^]byte, + used: uint, + capacity: uint, +} + +Arena :: struct { + backing_allocator: Allocator, + curr_block: ^Memory_Block, + total_used: uint, + total_capacity: uint, + minimum_block_size: uint, + temp_count: uint, +} + +@(private, require_results) +safe_add :: #force_inline proc "contextless" (x, y: uint) -> (uint, bool) { + z, did_overflow := intrinsics.overflow_add(x, y) + return z, !did_overflow +} + +@(require_results) +memory_block_alloc :: proc(allocator: Allocator, capacity: uint, loc := #caller_location) -> (block: ^Memory_Block, err: Allocator_Error) { + total_size := uint(capacity + size_of(Memory_Block)) + base_offset := uintptr(size_of(Memory_Block)) + + min_alignment: int = max(16, align_of(Memory_Block)) + data := mem_alloc(int(total_size), min_alignment, allocator, loc) or_return + block = (^Memory_Block)(raw_data(data)) + end := uintptr(raw_data(data)[len(data):]) + + block.allocator = allocator + block.base = ([^]byte)(uintptr(block) + base_offset) + block.capacity = uint(end - uintptr(block.base)) + + // Should be zeroed + assert(block.used == 0) + assert(block.prev == nil) + return +} + +memory_block_dealloc :: proc(block_to_free: ^Memory_Block, loc := #caller_location) { + if block_to_free != nil { + allocator := block_to_free.allocator + mem_free(block_to_free, allocator, loc) + } +} + +@(require_results) +alloc_from_memory_block :: proc(block: ^Memory_Block, min_size, alignment: uint) -> (data: []byte, err: Allocator_Error) { + calc_alignment_offset :: proc "contextless" (block: ^Memory_Block, alignment: uintptr) -> uint { + alignment_offset := uint(0) + ptr := uintptr(block.base[block.used:]) + mask := alignment-1 + if ptr & mask != 0 { + alignment_offset = uint(alignment - (ptr & mask)) + } + return alignment_offset + + } + if block == nil { + return nil, .Out_Of_Memory + } + alignment_offset := calc_alignment_offset(block, uintptr(alignment)) + size, size_ok := safe_add(min_size, alignment_offset) + if !size_ok { + err = .Out_Of_Memory + return + } + + if to_be_used, ok := safe_add(block.used, size); !ok || to_be_used > block.capacity { + err = .Out_Of_Memory + return + } + data = block.base[block.used+alignment_offset:][:min_size] + block.used += size + return +} + +@(require_results) +arena_alloc :: proc(arena: ^Arena, size, alignment: uint, loc := #caller_location) -> (data: []byte, err: Allocator_Error) { + align_forward_uint :: proc "contextless" (ptr, align: uint) -> uint { + p := ptr + modulo := p & (align-1) + if modulo != 0 { + p += align - modulo + } + return p + } + + assert(alignment & (alignment-1) == 0, "non-power of two alignment", loc) + + size := size + if size == 0 { + return + } + + if arena.curr_block == nil || (safe_add(arena.curr_block.used, size) or_else 0) > arena.curr_block.capacity { + size = align_forward_uint(size, alignment) + if arena.minimum_block_size == 0 { + arena.minimum_block_size = DEFAULT_ARENA_GROWING_MINIMUM_BLOCK_SIZE + } + + block_size := max(size, arena.minimum_block_size) + + if arena.backing_allocator.procedure == nil { + arena.backing_allocator = default_allocator() + } + + new_block := memory_block_alloc(arena.backing_allocator, block_size, loc) or_return + new_block.prev = arena.curr_block + arena.curr_block = new_block + arena.total_capacity += new_block.capacity + } + + prev_used := arena.curr_block.used + data, err = alloc_from_memory_block(arena.curr_block, size, alignment) + arena.total_used += arena.curr_block.used - prev_used + return +} + +// `arena_init` will initialize the arena with a usuable block. +// This procedure is not necessary to use the Arena as the default zero as `arena_alloc` will set things up if necessary +@(require_results) +arena_init :: proc(arena: ^Arena, size: uint, backing_allocator: Allocator, loc := #caller_location) -> Allocator_Error { + arena^ = {} + arena.backing_allocator = backing_allocator + arena.minimum_block_size = max(size, 1<<12) // minimum block size of 4 KiB + new_block := memory_block_alloc(arena.backing_allocator, arena.minimum_block_size, loc) or_return + arena.curr_block = new_block + arena.total_capacity += new_block.capacity + return nil +} + + +arena_free_last_memory_block :: proc(arena: ^Arena, loc := #caller_location) { + if free_block := arena.curr_block; free_block != nil { + arena.curr_block = free_block.prev + + arena.total_capacity -= free_block.capacity + memory_block_dealloc(free_block, loc) + } +} + +// `arena_free_all` will free all but the first memory block, and then reset the memory block +arena_free_all :: proc(arena: ^Arena, loc := #caller_location) { + for arena.curr_block != nil && arena.curr_block.prev != nil { + arena_free_last_memory_block(arena, loc) + } + + if arena.curr_block != nil { + intrinsics.mem_zero(arena.curr_block.base, arena.curr_block.used) + arena.curr_block.used = 0 + } + arena.total_used = 0 +} + +arena_destroy :: proc(arena: ^Arena, loc := #caller_location) { + for arena.curr_block != nil { + free_block := arena.curr_block + arena.curr_block = free_block.prev + + arena.total_capacity -= free_block.capacity + memory_block_dealloc(free_block, loc) + } + arena.total_used = 0 + arena.total_capacity = 0 +} + +arena_allocator :: proc(arena: ^Arena) -> Allocator { + return Allocator{arena_allocator_proc, arena} +} + +arena_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode, + size, alignment: int, + old_memory: rawptr, old_size: int, + location := #caller_location) -> (data: []byte, err: Allocator_Error) { + arena := (^Arena)(allocator_data) + + size, alignment := uint(size), uint(alignment) + old_size := uint(old_size) + + switch mode { + case .Alloc, .Alloc_Non_Zeroed: + return arena_alloc(arena, size, alignment, location) + case .Free: + err = .Mode_Not_Implemented + case .Free_All: + arena_free_all(arena, location) + case .Resize: + old_data := ([^]byte)(old_memory) + + switch { + case old_data == nil: + return arena_alloc(arena, size, alignment, location) + case size == old_size: + // return old memory + data = old_data[:size] + return + case size == 0: + err = .Mode_Not_Implemented + return + case (uintptr(old_data) & uintptr(alignment-1) == 0) && size < old_size: + // shrink data in-place + data = old_data[:size] + return + } + + new_memory := arena_alloc(arena, size, alignment, location) or_return + if new_memory == nil { + return + } + copy(new_memory, old_data[:old_size]) + return new_memory, nil + case .Query_Features: + set := (^Allocator_Mode_Set)(old_memory) + if set != nil { + set^ = {.Alloc, .Alloc_Non_Zeroed, .Free_All, .Resize, .Query_Features} + } + case .Query_Info: + err = .Mode_Not_Implemented + } + + return +} + + + + +Arena_Temp :: struct { + arena: ^Arena, + block: ^Memory_Block, + used: uint, +} + +@(require_results) +arena_temp_begin :: proc(arena: ^Arena, loc := #caller_location) -> (temp: Arena_Temp) { + assert(arena != nil, "nil arena", loc) + + temp.arena = arena + temp.block = arena.curr_block + if arena.curr_block != nil { + temp.used = arena.curr_block.used + } + arena.temp_count += 1 + return +} + +arena_temp_end :: proc(temp: Arena_Temp, loc := #caller_location) { + if temp.arena == nil { + assert(temp.block == nil) + assert(temp.used == 0) + return + } + arena := temp.arena + + if temp.block != nil { + memory_block_found := false + for block := arena.curr_block; block != nil; block = block.prev { + if block == temp.block { + memory_block_found = true + break + } + } + if !memory_block_found { + assert(arena.curr_block == temp.block, "memory block stored within Arena_Temp not owned by Arena", loc) + } + + for arena.curr_block != temp.block { + arena_free_last_memory_block(arena) + } + + if block := arena.curr_block; block != nil { + assert(block.used >= temp.used, "out of order use of arena_temp_end", loc) + amount_to_zero := min(block.used-temp.used, block.capacity-block.used) + intrinsics.mem_zero(block.base[temp.used:], amount_to_zero) + block.used = temp.used + } + } + + assert(arena.temp_count > 0, "double-use of arena_temp_end", loc) + arena.temp_count -= 1 +} + +// Ignore the use of a `arena_temp_begin` entirely +arena_temp_ignore :: proc(temp: Arena_Temp, loc := #caller_location) { + assert(temp.arena != nil, "nil arena", loc) + arena := temp.arena + + assert(arena.temp_count > 0, "double-use of arena_temp_end", loc) + arena.temp_count -= 1 +} + +arena_check_temp :: proc(arena: ^Arena, loc := #caller_location) { + assert(arena.temp_count == 0, "Arena_Temp not been ended", loc) +} diff --git a/core/runtime/default_temporary_allocator.odin b/core/runtime/default_temporary_allocator.odin index b71cd103a..c90f0388d 100644 --- a/core/runtime/default_temporary_allocator.odin +++ b/core/runtime/default_temporary_allocator.odin @@ -1,159 +1,38 @@ package runtime DEFAULT_TEMP_ALLOCATOR_BACKING_SIZE: int : #config(DEFAULT_TEMP_ALLOCATOR_BACKING_SIZE, 4 * Megabyte) +NO_DEFAULT_TEMP_ALLOCATOR: bool : ODIN_OS == .Freestanding || ODIN_OS == .JS || ODIN_DEFAULT_TO_NIL_ALLOCATOR - -when ODIN_OS == .Freestanding || ODIN_OS == .JS || ODIN_DEFAULT_TO_NIL_ALLOCATOR { +when NO_DEFAULT_TEMP_ALLOCATOR { Default_Temp_Allocator :: struct {} - default_temp_allocator_init :: proc(s: ^Default_Temp_Allocator, size: int, backup_allocator := context.allocator) {} + default_temp_allocator_init :: proc(s: ^Default_Temp_Allocator, size: int, backing_allocator := context.allocator) {} default_temp_allocator_destroy :: proc(s: ^Default_Temp_Allocator) {} default_temp_allocator_proc :: nil_allocator_proc + + @(require_results) + default_temp_allocator_temp_begin :: proc(loc := #caller_location) -> (temp: Arena_Temp) { + return + } + + default_temp_allocator_temp_end :: proc(temp: Arena_Temp, loc := #caller_location) { + } } else { Default_Temp_Allocator :: struct { - data: []byte, - curr_offset: int, - prev_allocation: rawptr, - backup_allocator: Allocator, - leaked_allocations: [dynamic][]byte, + arena: Arena, } - default_temp_allocator_init :: proc(s: ^Default_Temp_Allocator, size: int, backup_allocator := context.allocator) { - s.data = make_aligned([]byte, size, 2*align_of(rawptr), backup_allocator) - s.curr_offset = 0 - s.prev_allocation = nil - s.backup_allocator = backup_allocator - s.leaked_allocations.allocator = backup_allocator + default_temp_allocator_init :: proc(s: ^Default_Temp_Allocator, size: int, backing_allocator := context.allocator) { + _ = arena_init(&s.arena, uint(size), backing_allocator) } default_temp_allocator_destroy :: proc(s: ^Default_Temp_Allocator) { - if s == nil { - return + if s != nil { + arena_destroy(&s.arena) + s^ = {} } - for ptr in s.leaked_allocations { - free(raw_data(ptr), s.backup_allocator) - } - delete(s.leaked_allocations) - delete(s.data, s.backup_allocator) - s^ = {} - } - - @(private) - default_temp_allocator_alloc :: proc(s: ^Default_Temp_Allocator, size, alignment: int, loc := #caller_location) -> ([]byte, Allocator_Error) { - size := size - size = align_forward_int(size, alignment) - - switch { - case s.curr_offset+size <= len(s.data): - start := uintptr(raw_data(s.data)) - ptr := start + uintptr(s.curr_offset) - ptr = align_forward_uintptr(ptr, uintptr(alignment)) - mem_zero(rawptr(ptr), size) - - s.prev_allocation = rawptr(ptr) - offset := int(ptr - start) - s.curr_offset = offset + size - return byte_slice(rawptr(ptr), size), .None - - case size <= len(s.data): - start := uintptr(raw_data(s.data)) - ptr := align_forward_uintptr(start, uintptr(alignment)) - mem_zero(rawptr(ptr), size) - - s.prev_allocation = rawptr(ptr) - offset := int(ptr - start) - s.curr_offset = offset + size - return byte_slice(rawptr(ptr), size), .None - } - a := s.backup_allocator - if a.procedure == nil { - a = context.allocator - s.backup_allocator = a - } - - data, err := mem_alloc_bytes(size, alignment, a, loc) - if err != nil { - return data, err - } - if s.leaked_allocations == nil { - s.leaked_allocations = make([dynamic][]byte, a) - } - append(&s.leaked_allocations, data) - - // TODO(bill): Should leaks be notified about? - if logger := context.logger; logger.lowest_level <= .Warning { - if logger.procedure != nil { - logger.procedure(logger.data, .Warning, "default temp allocator resorted to backup_allocator" , logger.options, loc) - } - } - - return data, .None - } - - @(private) - default_temp_allocator_free :: proc(s: ^Default_Temp_Allocator, old_memory: rawptr, loc := #caller_location) -> Allocator_Error { - if old_memory == nil { - return .None - } - - start := uintptr(raw_data(s.data)) - end := start + uintptr(len(s.data)) - old_ptr := uintptr(old_memory) - - if s.prev_allocation == old_memory { - s.curr_offset = int(uintptr(s.prev_allocation) - start) - s.prev_allocation = nil - return .None - } - - if start <= old_ptr && old_ptr < end { - // NOTE(bill): Cannot free this pointer but it is valid - return .None - } - - if len(s.leaked_allocations) != 0 { - for data, i in s.leaked_allocations { - ptr := raw_data(data) - if ptr == old_memory { - free(ptr, s.backup_allocator) - ordered_remove(&s.leaked_allocations, i) - return .None - } - } - } - return .Invalid_Pointer - // panic("invalid pointer passed to default_temp_allocator"); - } - - @(private) - default_temp_allocator_free_all :: proc(s: ^Default_Temp_Allocator, loc := #caller_location) { - s.curr_offset = 0 - s.prev_allocation = nil - for data in s.leaked_allocations { - free(raw_data(data), s.backup_allocator) - } - clear(&s.leaked_allocations) - } - - @(private) - default_temp_allocator_resize :: proc(s: ^Default_Temp_Allocator, old_memory: rawptr, old_size, size, alignment: int, loc := #caller_location) -> ([]byte, Allocator_Error) { - begin := uintptr(raw_data(s.data)) - end := begin + uintptr(len(s.data)) - old_ptr := uintptr(old_memory) - if old_memory == s.prev_allocation && old_ptr & uintptr(alignment)-1 == 0 { - if old_ptr+uintptr(size) < end { - s.curr_offset = int(old_ptr-begin)+size - return byte_slice(old_memory, size), .None - } - } - data, err := default_temp_allocator_alloc(s, size, alignment, loc) - if err == .None { - copy(data, byte_slice(old_memory, old_size)) - err = default_temp_allocator_free(s, old_memory, loc) - } - return data, err } default_temp_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode, @@ -161,40 +40,40 @@ when ODIN_OS == .Freestanding || ODIN_OS == .JS || ODIN_DEFAULT_TO_NIL_ALLOCATOR old_memory: rawptr, old_size: int, loc := #caller_location) -> (data: []byte, err: Allocator_Error) { s := (^Default_Temp_Allocator)(allocator_data) + return arena_allocator_proc(&s.arena, mode, size, alignment, old_memory, old_size, loc) + } - if s.data == nil { - default_temp_allocator_init(s, DEFAULT_TEMP_ALLOCATOR_BACKING_SIZE, default_allocator()) + @(require_results) + default_temp_allocator_temp_begin :: proc(loc := #caller_location) -> (temp: Arena_Temp) { + if context.temp_allocator.data == &global_default_temp_allocator_data { + temp = arena_temp_begin(&global_default_temp_allocator_data.arena, loc) } - - switch mode { - case .Alloc, .Alloc_Non_Zeroed: - data, err = default_temp_allocator_alloc(s, size, alignment, loc) - case .Free: - err = default_temp_allocator_free(s, old_memory, loc) - - case .Free_All: - default_temp_allocator_free_all(s, loc) - - case .Resize: - data, err = default_temp_allocator_resize(s, old_memory, old_size, size, alignment, loc) - - case .Query_Features: - set := (^Allocator_Mode_Set)(old_memory) - if set != nil { - set^ = {.Alloc, .Alloc_Non_Zeroed, .Free, .Free_All, .Resize, .Query_Features} - } - - case .Query_Info: - return nil, .Mode_Not_Implemented - } - return } + + default_temp_allocator_temp_end :: proc(temp: Arena_Temp, loc := #caller_location) { + arena_temp_end(temp, loc) + } + + @(fini, private) + _destroy_temp_allocator_fini :: proc() { + default_temp_allocator_destroy(&global_default_temp_allocator_data) + } } +@(deferred_out=default_temp_allocator_temp_end) +DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD :: #force_inline proc(ignore := false, loc := #caller_location) -> (Arena_Temp, Source_Code_Location) { + if ignore { + return {}, loc + } else { + return default_temp_allocator_temp_begin(loc), loc + } +} + + default_temp_allocator :: proc(allocator: ^Default_Temp_Allocator) -> Allocator { return Allocator{ procedure = default_temp_allocator_proc, - data = allocator, + data = allocator, } } diff --git a/core/runtime/dynamic_map_internal.odin b/core/runtime/dynamic_map_internal.odin index fb4ad29a9..05c03028f 100644 --- a/core/runtime/dynamic_map_internal.odin +++ b/core/runtime/dynamic_map_internal.odin @@ -184,7 +184,7 @@ map_cell_index_static :: #force_inline proc "contextless" (cells: [^]Map_Cell($T // len() for map @(require_results) map_len :: #force_inline proc "contextless" (m: Raw_Map) -> int { - return m.len + return int(m.len) } // cap() for map @@ -207,8 +207,8 @@ map_load_factor :: #force_inline proc "contextless" (log2_capacity: uintptr) -> } @(require_results) -map_resize_threshold :: #force_inline proc "contextless" (m: Raw_Map) -> int { - return int(map_load_factor(map_log2_cap(m))) +map_resize_threshold :: #force_inline proc "contextless" (m: Raw_Map) -> uintptr { + return map_load_factor(map_log2_cap(m)) } // The data stores the log2 capacity in the lower six bits. This is primarily @@ -251,6 +251,26 @@ map_hash_is_valid :: #force_inline proc "contextless" (hash: Map_Hash) -> bool { return (hash != 0) & (hash & TOMBSTONE_MASK == 0) } +@(require_results) +map_seed :: #force_inline proc "contextless" (m: Raw_Map) -> uintptr { + return map_seed_from_map_data(map_data(m)) +} + +// splitmix for uintptr +@(require_results) +map_seed_from_map_data :: #force_inline proc "contextless" (data: uintptr) -> uintptr { + when size_of(uintptr) == size_of(u64) { + mix := data + 0x9e3779b97f4a7c15 + mix = (mix ~ (mix >> 30)) * 0xbf58476d1ce4e5b9 + mix = (mix ~ (mix >> 27)) * 0x94d049bb133111eb + return mix ~ (mix >> 31) + } else { + mix := data + 0x9e3779b9 + mix = (mix ~ (mix >> 16)) * 0x21f0aaad + mix = (mix ~ (mix >> 15)) * 0x735a2d97 + return mix ~ (mix >> 15) + } +} // Computes the desired position in the array. This is just index % capacity, // but a procedure as there's some math involved here to recover the capacity. @@ -394,32 +414,71 @@ map_insert_hash_dynamic :: proc "odin" (#no_alias m: ^Raw_Map, #no_alias info: ^ tk := map_cell_index_dynamic(sk, info.ks, 1) tv := map_cell_index_dynamic(sv, info.vs, 1) - for { hp := &hs[pos] element_hash := hp^ if map_hash_is_empty(element_hash) { - k_dst := map_cell_index_dynamic(ks, info.ks, pos) - v_dst := map_cell_index_dynamic(vs, info.vs, pos) - intrinsics.mem_copy_non_overlapping(rawptr(k_dst), rawptr(k), size_of_k) - intrinsics.mem_copy_non_overlapping(rawptr(v_dst), rawptr(v), size_of_v) + kp := map_cell_index_dynamic(ks, info.ks, pos) + vp := map_cell_index_dynamic(vs, info.vs, pos) + intrinsics.mem_copy_non_overlapping(rawptr(kp), rawptr(k), size_of_k) + intrinsics.mem_copy_non_overlapping(rawptr(vp), rawptr(v), size_of_v) hp^ = h - return result if result != 0 else v_dst + return result if result != 0 else vp + } + + if map_hash_is_deleted(element_hash) { + next_pos := (pos + 1) & mask + + // backward shift + for !map_hash_is_empty(hs[next_pos]) { + probe_distance := map_probe_distance(m^, hs[next_pos], next_pos) + if probe_distance == 0 { + break + } + probe_distance -= 1 + + kp := map_cell_index_dynamic(ks, info.ks, pos) + vp := map_cell_index_dynamic(vs, info.vs, pos) + kn := map_cell_index_dynamic(ks, info.ks, next_pos) + vn := map_cell_index_dynamic(vs, info.vs, next_pos) + + if distance > probe_distance { + if result == 0 { + result = vp + } + // move stored into pos; store next + intrinsics.mem_copy_non_overlapping(rawptr(kp), rawptr(k), size_of_k) + intrinsics.mem_copy_non_overlapping(rawptr(vp), rawptr(v), size_of_v) + hs[pos] = h + + intrinsics.mem_copy_non_overlapping(rawptr(k), rawptr(kn), size_of_k) + intrinsics.mem_copy_non_overlapping(rawptr(v), rawptr(vn), size_of_v) + h = hs[next_pos] + } else { + // move next back 1 + intrinsics.mem_copy_non_overlapping(rawptr(kp), rawptr(kn), size_of_k) + intrinsics.mem_copy_non_overlapping(rawptr(vp), rawptr(vn), size_of_v) + hs[pos] = hs[next_pos] + distance = probe_distance + } + hs[next_pos] = 0 + pos = (pos + 1) & mask + next_pos = (next_pos + 1) & mask + distance += 1 + } + + kp := map_cell_index_dynamic(ks, info.ks, pos) + vp := map_cell_index_dynamic(vs, info.vs, pos) + intrinsics.mem_copy_non_overlapping(rawptr(kp), rawptr(k), size_of_k) + intrinsics.mem_copy_non_overlapping(rawptr(vp), rawptr(v), size_of_v) + hs[pos] = h + + return result if result != 0 else vp } if probe_distance := map_probe_distance(m^, element_hash, pos); distance > probe_distance { - if map_hash_is_deleted(element_hash) { - k_dst := map_cell_index_dynamic(ks, info.ks, pos) - v_dst := map_cell_index_dynamic(vs, info.vs, pos) - intrinsics.mem_copy_non_overlapping(rawptr(k_dst), rawptr(k), size_of_k) - intrinsics.mem_copy_non_overlapping(rawptr(v_dst), rawptr(v), size_of_v) - hp^ = h - - return result if result != 0 else v_dst - } - if result == 0 { result = map_cell_index_dynamic(vs, info.vs, pos) } @@ -503,6 +562,7 @@ map_reserve_dynamic :: proc "odin" (#no_alias m: ^Raw_Map, #no_alias info: ^Map_ } k := map_cell_index_dynamic(ks, info.ks, i) v := map_cell_index_dynamic(vs, info.vs, i) + hash = info.key_hasher(rawptr(k), map_seed(resized)) _ = map_insert_hash_dynamic(&resized, info, hash, k, v) // Only need to do this comparison on each actually added pair, so do not // fold it into the for loop comparator as a micro-optimization. @@ -550,6 +610,7 @@ map_shrink_dynamic :: proc "odin" (#no_alias m: ^Raw_Map, #no_alias info: ^Map_I k := map_cell_index_dynamic(ks, info.ks, i) v := map_cell_index_dynamic(vs, info.vs, i) + hash = info.key_hasher(rawptr(k), map_seed(shrunk)) _ = map_insert_hash_dynamic(&shrunk, info, hash, k, v) // Only need to do this comparison on each actually added pair, so do not // fold it into the for loop comparator as a micro-optimization. @@ -581,7 +642,7 @@ map_lookup_dynamic :: proc "contextless" (m: Raw_Map, #no_alias info: ^Map_Info, if map_len(m) == 0 { return 0, false } - h := info.key_hasher(rawptr(k), 0) + h := info.key_hasher(rawptr(k), map_seed(m)) p := map_desired_position(m, h) d := uintptr(0) c := (uintptr(1) << map_log2_cap(m)) - 1 @@ -604,7 +665,7 @@ map_exists_dynamic :: proc "contextless" (m: Raw_Map, #no_alias info: ^Map_Info, if map_len(m) == 0 { return false } - h := info.key_hasher(rawptr(k), 0) + h := info.key_hasher(rawptr(k), map_seed(m)) p := map_desired_position(m, h) d := uintptr(0) c := (uintptr(1) << map_log2_cap(m)) - 1 @@ -637,7 +698,6 @@ map_erase_dynamic :: #force_inline proc "contextless" (#no_alias m: ^Raw_Map, #n { // coalesce tombstones // HACK NOTE(bill): This is an ugly bodge but it is coalescing the tombstone slots - // TODO(bill): we should do backward shift deletion and not rely on tombstone slots mask := (uintptr(1)< (stored_key: K, store info := intrinsics.type_map_info(T) key := key - h := info.key_hasher(&key, 0) + h := info.key_hasher(&key, map_seed(rm)) pos := map_desired_position(rm, h) distance := uintptr(0) mask := (uintptr(1) << map_log2_cap(rm)) - 1 @@ -762,15 +822,15 @@ __dynamic_map_get :: proc "contextless" (#no_alias m: ^Raw_Map, #no_alias info: } // IMPORTANT: USED WITHIN THE COMPILER -__dynamic_map_check_grow :: proc "odin" (#no_alias m: ^Raw_Map, #no_alias info: ^Map_Info, loc := #caller_location) -> Allocator_Error { +__dynamic_map_check_grow :: proc "odin" (#no_alias m: ^Raw_Map, #no_alias info: ^Map_Info, loc := #caller_location) -> (err: Allocator_Error, has_grown: bool) { if m.len >= map_resize_threshold(m^) { - return map_grow_dynamic(m, info, loc) + return map_grow_dynamic(m, info, loc), true } - return nil + return nil, false } __dynamic_map_set_without_hash :: proc "odin" (#no_alias m: ^Raw_Map, #no_alias info: ^Map_Info, key, value: rawptr, loc := #caller_location) -> rawptr { - return __dynamic_map_set(m, info, info.key_hasher(key, 0), key, value, loc) + return __dynamic_map_set(m, info, info.key_hasher(key, map_seed(m^)), key, value, loc) } @@ -781,9 +841,14 @@ __dynamic_map_set :: proc "odin" (#no_alias m: ^Raw_Map, #no_alias info: ^Map_In return found } - if __dynamic_map_check_grow(m, info, loc) != nil { + hash := hash + err, has_grown := __dynamic_map_check_grow(m, info, loc) + if err != nil { return nil } + if has_grown { + hash = info.key_hasher(key, map_seed(m^)) + } result := map_insert_hash_dynamic(m, info, hash, uintptr(key), uintptr(value)) m.len += 1 diff --git a/core/runtime/entry_wasm.odin b/core/runtime/entry_wasm.odin index 125abc756..235d5611b 100644 --- a/core/runtime/entry_wasm.odin +++ b/core/runtime/entry_wasm.odin @@ -1,5 +1,5 @@ //+private -//+build wasm32, wasm64 +//+build wasm32, wasm64p32 package runtime import "core:intrinsics" diff --git a/core/runtime/error_checks.odin b/core/runtime/error_checks.odin index 8539c724d..c189642af 100644 --- a/core/runtime/error_checks.odin +++ b/core/runtime/error_checks.odin @@ -22,7 +22,7 @@ bounds_check_error :: proc "contextless" (file: string, line, column: i32, index return } @(cold) - handle_error :: proc "contextless" (file: string, line, column: i32, index, count: int) { + handle_error :: proc "contextless" (file: string, line, column: i32, index, count: int) -> ! { print_caller_location(Source_Code_Location{file, line, column, ""}) print_string(" Index ") print_i64(i64(index)) @@ -83,7 +83,7 @@ dynamic_array_expr_error :: proc "contextless" (file: string, line, column: i32, return } @(cold) - handle_error :: proc "contextless" (file: string, line, column: i32, low, high, max: int) { + handle_error :: proc "contextless" (file: string, line, column: i32, low, high, max: int) -> ! { print_caller_location(Source_Code_Location{file, line, column, ""}) print_string(" Invalid dynamic array indices ") print_i64(i64(low)) @@ -104,7 +104,7 @@ matrix_bounds_check_error :: proc "contextless" (file: string, line, column: i32 return } @(cold) - handle_error :: proc "contextless" (file: string, line, column: i32, row_index, column_index, row_count, column_count: int) { + handle_error :: proc "contextless" (file: string, line, column: i32, row_index, column_index, row_count, column_count: int) -> ! { print_caller_location(Source_Code_Location{file, line, column, ""}) print_string(" Matrix indices [") print_i64(i64(row_index)) @@ -122,13 +122,13 @@ matrix_bounds_check_error :: proc "contextless" (file: string, line, column: i32 } -when ODIN_DISALLOW_RTTI { +when ODIN_NO_RTTI { type_assertion_check :: proc "contextless" (ok: bool, file: string, line, column: i32) { if ok { return } @(cold) - handle_error :: proc "contextless" (file: string, line, column: i32) { + handle_error :: proc "contextless" (file: string, line, column: i32) -> ! { print_caller_location(Source_Code_Location{file, line, column, ""}) print_string(" Invalid type assertion\n") type_assertion_trap() @@ -141,7 +141,7 @@ when ODIN_DISALLOW_RTTI { return } @(cold) - handle_error :: proc "contextless" (file: string, line, column: i32) { + handle_error :: proc "contextless" (file: string, line, column: i32) -> ! { print_caller_location(Source_Code_Location{file, line, column, ""}) print_string(" Invalid type assertion\n") type_assertion_trap() @@ -154,7 +154,7 @@ when ODIN_DISALLOW_RTTI { return } @(cold) - handle_error :: proc "contextless" (file: string, line, column: i32, from, to: typeid) { + handle_error :: proc "contextless" (file: string, line, column: i32, from, to: typeid) -> ! { print_caller_location(Source_Code_Location{file, line, column, ""}) print_string(" Invalid type assertion from ") print_typeid(from) @@ -199,7 +199,7 @@ when ODIN_DISALLOW_RTTI { } @(cold) - handle_error :: proc "contextless" (file: string, line, column: i32, from, to: typeid, from_data: rawptr) { + handle_error :: proc "contextless" (file: string, line, column: i32, from, to: typeid, from_data: rawptr) -> ! { actual := variant_type(from, from_data) @@ -225,7 +225,7 @@ make_slice_error_loc :: #force_inline proc "contextless" (loc := #caller_locatio return } @(cold) - handle_error :: proc "contextless" (loc: Source_Code_Location, len: int) { + handle_error :: proc "contextless" (loc: Source_Code_Location, len: int) -> ! { print_caller_location(loc) print_string(" Invalid slice length for make: ") print_i64(i64(len)) @@ -240,7 +240,7 @@ make_dynamic_array_error_loc :: #force_inline proc "contextless" (using loc := # return } @(cold) - handle_error :: proc "contextless" (loc: Source_Code_Location, len, cap: int) { + handle_error :: proc "contextless" (loc: Source_Code_Location, len, cap: int) -> ! { print_caller_location(loc) print_string(" Invalid dynamic array parameters for make: ") print_i64(i64(len)) @@ -257,7 +257,7 @@ make_map_expr_error_loc :: #force_inline proc "contextless" (loc := #caller_loca return } @(cold) - handle_error :: proc "contextless" (loc: Source_Code_Location, cap: int) { + handle_error :: proc "contextless" (loc: Source_Code_Location, cap: int) -> ! { print_caller_location(loc) print_string(" Invalid map capacity for make: ") print_i64(i64(cap)) diff --git a/core/runtime/internal.odin b/core/runtime/internal.odin index cb04ff0aa..71ad9386a 100644 --- a/core/runtime/internal.odin +++ b/core/runtime/internal.odin @@ -3,7 +3,7 @@ package runtime import "core:intrinsics" @(private="file") -IS_WASM :: ODIN_ARCH == .wasm32 || ODIN_ARCH == .wasm64 +IS_WASM :: ODIN_ARCH == .wasm32 || ODIN_ARCH == .wasm64p32 @(private) RUNTIME_LINKAGE :: "strong" when ( @@ -184,32 +184,33 @@ mem_free_all :: #force_inline proc(allocator := context.allocator, loc := #calle return } -mem_resize :: proc(ptr: rawptr, old_size, new_size: int, alignment: int = DEFAULT_ALIGNMENT, allocator := context.allocator, loc := #caller_location) -> ([]byte, Allocator_Error) { +mem_resize :: proc(ptr: rawptr, old_size, new_size: int, alignment: int = DEFAULT_ALIGNMENT, allocator := context.allocator, loc := #caller_location) -> (data: []byte, err: Allocator_Error) { if allocator.procedure == nil { return nil, nil } if new_size == 0 { if ptr != nil { - _, err := allocator.procedure(allocator.data, .Free, 0, 0, ptr, old_size, loc) - return nil, err + _, err = allocator.procedure(allocator.data, .Free, 0, 0, ptr, old_size, loc) + return } - return nil, nil + return } else if ptr == nil { return allocator.procedure(allocator.data, .Alloc, new_size, alignment, nil, 0, loc) } else if old_size == new_size && uintptr(ptr) % uintptr(alignment) == 0 { - return ([^]byte)(ptr)[:old_size], nil + data = ([^]byte)(ptr)[:old_size] + return } - data, err := allocator.procedure(allocator.data, .Resize, new_size, alignment, ptr, old_size, loc) + data, err = allocator.procedure(allocator.data, .Resize, new_size, alignment, ptr, old_size, loc) if err == .Mode_Not_Implemented { data, err = allocator.procedure(allocator.data, .Alloc, new_size, alignment, nil, 0, loc) if err != nil { - return data, err + return } copy(data, ([^]byte)(ptr)[:old_size]) _, err = allocator.procedure(allocator.data, .Free, 0, 0, ptr, old_size, loc) } - return data, err + return } memory_equal :: proc "contextless" (x, y: rawptr, n: int) -> bool { @@ -223,7 +224,7 @@ memory_equal :: proc "contextless" (x, y: rawptr, n: int) -> bool { when size_of(uint) == 8 { if word_length := length >> 3; word_length != 0 { - for i in 0.. bool { return true } else { if word_length := length >> 2; word_length != 0 { - for i in 0.. (rune, int return rune(s0&MASK4)<<18 | rune(b1&MASKX)<<12 | rune(b2&MASKX)<<6 | rune(b3&MASKX), 4 } +string_decode_last_rune :: proc "contextless" (s: string) -> (rune, int) { + RUNE_ERROR :: '\ufffd' + RUNE_SELF :: 0x80 + UTF_MAX :: 4 + + r: rune + size: int + start, end, limit: int + + end = len(s) + if end == 0 { + return RUNE_ERROR, 0 + } + start = end-1 + r = rune(s[start]) + if r < RUNE_SELF { + return r, 1 + } + + limit = max(end - UTF_MAX, 0) + + for start-=1; start >= limit; start-=1 { + if (s[start] & 0xc0) != RUNE_SELF { + break + } + } + + start = max(start, 0) + r, size = string_decode_rune(s[start:end]) + if start+size != end { + return RUNE_ERROR, 1 + } + return r, size +} + + abs_f16 :: #force_inline proc "contextless" (x: f16) -> f16 { return -x if x < 0 else x } diff --git a/core/runtime/os_specific_js.odin b/core/runtime/os_specific_js.odin index a9ba871f9..246141d87 100644 --- a/core/runtime/os_specific_js.odin +++ b/core/runtime/os_specific_js.odin @@ -5,7 +5,7 @@ foreign import "odin_env" _os_write :: proc "contextless" (data: []byte) -> (int, _OS_Errno) { foreign odin_env { - write :: proc "c" (fd: u32, p: []byte) --- + write :: proc "contextless" (fd: u32, p: []byte) --- } write(1, data) return len(data), 0 diff --git a/core/runtime/os_specific_windows.odin b/core/runtime/os_specific_windows.odin index 6e7474257..732715793 100644 --- a/core/runtime/os_specific_windows.odin +++ b/core/runtime/os_specific_windows.odin @@ -112,7 +112,7 @@ _windows_default_alloc_or_resize :: proc "contextless" (size, alignment: int, ol ptr := uintptr(aligned_mem) aligned_ptr := (ptr - 1 + uintptr(a)) & -uintptr(a) diff := int(aligned_ptr - ptr) - if (size + diff) > space { + if (size + diff) > space || allocated_mem == nil { return nil, .Out_Of_Memory } diff --git a/core/runtime/print.odin b/core/runtime/print.odin index 959dad3a9..732ed9c12 100644 --- a/core/runtime/print.odin +++ b/core/runtime/print.odin @@ -2,6 +2,82 @@ package runtime _INTEGER_DIGITS :: "0123456789abcdefghijklmnopqrstuvwxyz" +@(private="file") +_INTEGER_DIGITS_VAR := _INTEGER_DIGITS + +when !ODIN_NO_RTTI { + print_any_single :: proc "contextless" (arg: any) { + x := arg + if loc, ok := x.(Source_Code_Location); ok { + print_caller_location(loc) + return + } + x.id = typeid_base(x.id) + switch v in x { + case typeid: print_typeid(v) + case ^Type_Info: print_type(v) + + case string: print_string(v) + case cstring: print_string(string(v)) + case []byte: print_string(string(v)) + + case rune: print_rune(v) + + case u8: print_u64(u64(v)) + case u16: print_u64(u64(v)) + case u16le: print_u64(u64(v)) + case u16be: print_u64(u64(v)) + case u32: print_u64(u64(v)) + case u32le: print_u64(u64(v)) + case u32be: print_u64(u64(v)) + case u64: print_u64(u64(v)) + case u64le: print_u64(u64(v)) + case u64be: print_u64(u64(v)) + + case i8: print_i64(i64(v)) + case i16: print_i64(i64(v)) + case i16le: print_i64(i64(v)) + case i16be: print_i64(i64(v)) + case i32: print_i64(i64(v)) + case i32le: print_i64(i64(v)) + case i32be: print_i64(i64(v)) + case i64: print_i64(i64(v)) + case i64le: print_i64(i64(v)) + case i64be: print_i64(i64(v)) + + case int: print_int(v) + case uint: print_uint(v) + case uintptr: print_uintptr(v) + + case bool: print_string("true" if v else "false") + case b8: print_string("true" if v else "false") + case b16: print_string("true" if v else "false") + case b32: print_string("true" if v else "false") + case b64: print_string("true" if v else "false") + + case: + ti := type_info_of(x.id) + #partial switch v in ti.variant { + case Type_Info_Pointer: + print_uintptr((^uintptr)(x.data)^) + return + } + + print_string("") + } + } + println_any :: proc "contextless" (args: ..any) { + loop: for arg, i in args { + if i != 0 { + print_string(" ") + } + print_any_single(arg) + } + print_string("\n") + } +} + + encode_rune :: proc "contextless" (c: rune) -> ([4]u8, int) { r := c @@ -38,14 +114,14 @@ encode_rune :: proc "contextless" (c: rune) -> ([4]u8, int) { return buf, 4 } -print_string :: proc "contextless" (str: string) -> (int, _OS_Errno) { - return os_write(transmute([]byte)str) +print_string :: proc "contextless" (str: string) -> (n: int) { + n, _ = os_write(transmute([]byte)str) + return } -print_strings :: proc "contextless" (args: ..string) -> (n: int, err: _OS_Errno) { +print_strings :: proc "contextless" (args: ..string) -> (n: int) { for str in args { - m: int - m, err = os_write(transmute([]byte)str) + m, err := os_write(transmute([]byte)str) n += m if err != 0 { break @@ -54,8 +130,9 @@ print_strings :: proc "contextless" (args: ..string) -> (n: int, err: _OS_Errno) return } -print_byte :: proc "contextless" (b: byte) -> (int, _OS_Errno) { - return os_write([]byte{b}) +print_byte :: proc "contextless" (b: byte) -> (n: int) { + n, _ = os_write([]byte{b}) + return } print_encoded_rune :: proc "contextless" (r: rune) { @@ -74,11 +151,10 @@ print_encoded_rune :: proc "contextless" (r: rune) { if r <= 0 { print_string("\\x00") } else if r < 32 { - digits := _INTEGER_DIGITS n0, n1 := u8(r) >> 4, u8(r) & 0xf print_string("\\x") - print_byte(digits[n0]) - print_byte(digits[n1]) + print_byte(_INTEGER_DIGITS_VAR[n0]) + print_byte(_INTEGER_DIGITS_VAR[n1]) } else { print_rune(r) } @@ -86,7 +162,7 @@ print_encoded_rune :: proc "contextless" (r: rune) { print_byte('\'') } -print_rune :: proc "contextless" (r: rune) -> (int, _OS_Errno) #no_bounds_check { +print_rune :: proc "contextless" (r: rune) -> int #no_bounds_check { RUNE_SELF :: 0x80 if r < RUNE_SELF { @@ -94,29 +170,27 @@ print_rune :: proc "contextless" (r: rune) -> (int, _OS_Errno) #no_bounds_check } b, n := encode_rune(r) - return os_write(b[:n]) + m, _ := os_write(b[:n]) + return m } print_u64 :: proc "contextless" (x: u64) #no_bounds_check { - digits := _INTEGER_DIGITS - a: [129]byte i := len(a) b := u64(10) u := x for u >= b { - i -= 1; a[i] = digits[u % b] + i -= 1; a[i] = _INTEGER_DIGITS_VAR[u % b] u /= b } - i -= 1; a[i] = digits[u % b] + i -= 1; a[i] = _INTEGER_DIGITS_VAR[u % b] os_write(a[i:]) } print_i64 :: proc "contextless" (x: i64) #no_bounds_check { - digits := _INTEGER_DIGITS b :: i64(10) u := x @@ -126,10 +200,10 @@ print_i64 :: proc "contextless" (x: i64) #no_bounds_check { a: [129]byte i := len(a) for u >= b { - i -= 1; a[i] = digits[u % b] + i -= 1; a[i] = _INTEGER_DIGITS_VAR[u % b] u /= b } - i -= 1; a[i] = digits[u % b] + i -= 1; a[i] = _INTEGER_DIGITS_VAR[u % b] if neg { i -= 1; a[i] = '-' } @@ -160,7 +234,7 @@ print_caller_location :: proc "contextless" (using loc: Source_Code_Location) { } } print_typeid :: proc "contextless" (id: typeid) { - when ODIN_DISALLOW_RTTI { + when ODIN_NO_RTTI { if id == nil { print_string("nil") } else { @@ -236,7 +310,7 @@ print_type :: proc "contextless" (ti: ^Type_Info) { if info.params == nil { print_string("()") } else { - t := info.params.variant.(Type_Info_Tuple) + t := info.params.variant.(Type_Info_Parameters) print_byte('(') for t, i in t.types { if i > 0 { print_string(", ") } @@ -248,7 +322,7 @@ print_type :: proc "contextless" (ti: ^Type_Info) { print_string(" -> ") print_type(info.results) } - case Type_Info_Tuple: + case Type_Info_Parameters: count := len(info.names) if count != 1 { print_byte('(') } for name, i in info.names { diff --git a/core/runtime/procs.odin b/core/runtime/procs.odin index 510abcbb9..3a433c3bf 100644 --- a/core/runtime/procs.odin +++ b/core/runtime/procs.odin @@ -25,7 +25,7 @@ when ODIN_NO_CRT && ODIN_OS == .Windows { RtlMoveMemory(dst, src, len) return dst } -} else when ODIN_NO_CRT || (ODIN_ARCH == .wasm32 || ODIN_ARCH == .wasm64) { +} else when ODIN_NO_CRT || (ODIN_ARCH == .wasm32 || ODIN_ARCH == .wasm64p32) { @(link_name="memset", linkage="strong", require) memset :: proc "c" (ptr: rawptr, val: i32, len: int) -> rawptr { if ptr != nil && len != 0 { diff --git a/core/runtime/procs_js_wasm32.odin b/core/runtime/procs_js.odin similarity index 93% rename from core/runtime/procs_js_wasm32.odin rename to core/runtime/procs_js.odin index b8acebc87..d3e12410c 100644 --- a/core/runtime/procs_js_wasm32.odin +++ b/core/runtime/procs_js.odin @@ -1,4 +1,4 @@ -//+build js wasm32 +//+build js package runtime init_default_context_for_js: Context diff --git a/core/runtime/procs_wasm32.odin b/core/runtime/procs_wasm.odin similarity index 82% rename from core/runtime/procs_wasm32.odin rename to core/runtime/procs_wasm.odin index 2a4210c1e..26dcfef77 100644 --- a/core/runtime/procs_wasm32.odin +++ b/core/runtime/procs_wasm.odin @@ -1,4 +1,4 @@ -//+build wasm32 +//+build wasm32, wasm64p32 package runtime @(private="file") @@ -8,7 +8,7 @@ ti_int :: struct #raw_union { } @(link_name="__ashlti3", linkage="strong") -__ashlti3 :: proc "c" (a: i128, b_: u32) -> i128 { +__ashlti3 :: proc "contextless" (a: i128, b_: u32) -> i128 { bits_in_dword :: size_of(u32)*8 b := u32(b_) @@ -29,7 +29,7 @@ __ashlti3 :: proc "c" (a: i128, b_: u32) -> i128 { @(link_name="__multi3", linkage="strong") -__multi3 :: proc "c" (a, b: i128) -> i128 { +__multi3 :: proc "contextless" (a, b: i128) -> i128 { x, y, r: ti_int x.all = a diff --git a/core/slice/ptr.odin b/core/slice/ptr.odin index 214b745f7..e2f1c3e7b 100644 --- a/core/slice/ptr.odin +++ b/core/slice/ptr.odin @@ -73,24 +73,26 @@ ptr_rotate :: proc(left: int, mid: ^$T, right: int) { left, mid, right := left, mid, right // TODO(bill): Optimization with a buffer for smaller ranges - if left >= right { - for { - ptr_swap_non_overlapping(ptr_sub(mid, right), mid, right) - mid = ptr_sub(mid, right) + for left > 0 && right > 0 { + if left >= right { + for { + ptr_swap_non_overlapping(ptr_sub(mid, right), mid, right * size_of(T)) + mid = ptr_sub(mid, right) - left -= right - if left < right { - break + left -= right + if left < right { + break + } } - } - } else { - for { - ptr_swap_non_overlapping(ptr_sub(mid, left), mid, left) - mid = ptr_add(mid, left) + } else { + for { + ptr_swap_non_overlapping(ptr_sub(mid, left), mid, left * size_of(T)) + mid = ptr_add(mid, left) - right -= left - if right < left { - break + right -= left + if right < left { + break + } } } } diff --git a/core/slice/slice.odin b/core/slice/slice.odin index 032a8ca6e..412c90fc8 100644 --- a/core/slice/slice.odin +++ b/core/slice/slice.odin @@ -13,6 +13,7 @@ _ :: mem /* Turn a pointer and a length into a slice. */ +@(require_results) from_ptr :: proc "contextless" (ptr: ^$T, count: int) -> []T { return ([^]T)(ptr)[:count] } @@ -20,6 +21,7 @@ from_ptr :: proc "contextless" (ptr: ^$T, count: int) -> []T { /* Turn a pointer and a length into a byte slice. */ +@(require_results) bytes_from_ptr :: proc "contextless" (ptr: rawptr, byte_count: int) -> []byte { return ([^]byte)(ptr)[:byte_count] } @@ -29,6 +31,7 @@ bytes_from_ptr :: proc "contextless" (ptr: rawptr, byte_count: int) -> []byte { See `slice.reinterpret` to go the other way. */ +@(require_results) to_bytes :: proc "contextless" (s: []$T) -> []byte { return ([^]byte)(raw_data(s))[:len(s) * size_of(T)] } @@ -51,10 +54,15 @@ to_bytes :: proc "contextless" (s: []$T) -> []byte { assert(len(large_items) == 1) // only enough bytes to make 1 x i64; two would need at least 8 bytes. ``` */ +@(require_results) reinterpret :: proc "contextless" ($T: typeid/[]$U, s: []$V) -> []U { - bytes := to_bytes(s) - n := len(bytes) / size_of(U) - return ([^]U)(raw_data(bytes))[:n] + when size_of(U) == 0 || size_of(V) == 0 { + return nil + } else { + bytes := to_bytes(s) + n := len(bytes) / size_of(U) + return ([^]U)(raw_data(bytes))[:n] + } } @@ -77,17 +85,18 @@ swap_between :: proc(a, b: $T/[]$E) { reverse :: proc(array: $T/[]$E) { n := len(array)/2 for i in 0.. bool where intrinsics.type_is_comparable(E) { _, found := linear_search(array, value) return found } +@(require_results) linear_search :: proc(array: $A/[]$T, key: T) -> (index: int, found: bool) where intrinsics.type_is_comparable(T) #no_bounds_check { for x, i in array { @@ -98,6 +107,7 @@ linear_search :: proc(array: $A/[]$T, key: T) -> (index: int, found: bool) return -1, false } +@(require_results) linear_search_proc :: proc(array: $A/[]$T, f: proc(T) -> bool) -> (index: int, found: bool) #no_bounds_check { for x, i in array { if f(x) { @@ -107,6 +117,7 @@ linear_search_proc :: proc(array: $A/[]$T, f: proc(T) -> bool) -> (index: int, f return -1, false } +@(require_results) binary_search :: proc(array: $A/[]$T, key: T) -> (index: int, found: bool) where intrinsics.type_is_ordered(T) #no_bounds_check { @@ -147,6 +158,7 @@ binary_search :: proc(array: $A/[]$T, key: T) -> (index: int, found: bool) } +@(require_results) equal :: proc(a, b: $T/[]$E) -> bool where intrinsics.type_is_comparable(E) { if len(a) != len(b) { return false @@ -163,6 +175,7 @@ equal :: proc(a, b: $T/[]$E) -> bool where intrinsics.type_is_comparable(E) { } } +@(require_results) simple_equal :: proc(a, b: $T/[]$E) -> bool where intrinsics.type_is_simple_compare(E) { if len(a) != len(b) { return false @@ -177,6 +190,7 @@ simple_equal :: proc(a, b: $T/[]$E) -> bool where intrinsics.type_is_simple_comp slice.prefix_length([]u8{1, 2, 3, 4}, []u8{1, 2, 3}) -> 3 slice.prefix_length([]u8{1, 2, 3, 4}, []u8{2, 3, 4}) -> 0 */ +@(require_results) prefix_length :: proc(a, b: $T/[]$E) -> (n: int) where intrinsics.type_is_comparable(E) { _len := builtin.min(len(a), len(b)) @@ -186,6 +200,7 @@ prefix_length :: proc(a, b: $T/[]$E) -> (n: int) where intrinsics.type_is_compar return } +@(require_results) has_prefix :: proc(array: $T/[]$E, needle: E) -> bool where intrinsics.type_is_comparable(E) { n := len(needle) if len(array) >= n { @@ -195,6 +210,7 @@ has_prefix :: proc(array: $T/[]$E, needle: E) -> bool where intrinsics.type_is_c } +@(require_results) has_suffix :: proc(array: $T/[]$E, needle: E) -> bool where intrinsics.type_is_comparable(E) { array := array m, n := len(array), len(needle) @@ -218,8 +234,10 @@ rotate_left :: proc(array: $T/[]$E, mid: int) { n := len(array) m := mid %% n k := n - m - p := raw_data(array) - ptr_rotate(mid, ptr_add(p, mid), k) + // FIXME: (ap29600) this cast is a temporary fix for the compiler not matching + // [^T] with $P/^$T + p := cast(^E)raw_data(array) + ptr_rotate(m, ptr_add(p, m), k) } rotate_right :: proc(array: $T/[]$E, k: int) { rotate_left(array, -k) @@ -231,7 +249,8 @@ swap_with_slice :: proc(a, b: $T/[]$E, loc := #caller_location) { ptr_swap_non_overlapping(raw_data(a), raw_data(b), len(a)*size_of(E)) } -concatenate :: proc(a: []$T/[]$E, allocator := context.allocator) -> (res: T) { +@(require_results) +concatenate :: proc(a: []$T/[]$E, allocator := context.allocator) -> (res: T, err: mem.Allocator_Error) #optional_allocator_error { if len(a) == 0 { return } @@ -239,7 +258,7 @@ concatenate :: proc(a: []$T/[]$E, allocator := context.allocator) -> (res: T) { for s in a { n += len(s) } - res = make(T, n, allocator) + res = make(T, n, allocator) or_return i := 0 for s in a { i += copy(res[i:], s) @@ -248,22 +267,24 @@ concatenate :: proc(a: []$T/[]$E, allocator := context.allocator) -> (res: T) { } // copies a slice into a new slice -clone :: proc(a: $T/[]$E, allocator := context.allocator) -> []E { - d := make([]E, len(a), allocator) +@(require_results) +clone :: proc(a: $T/[]$E, allocator := context.allocator) -> ([]E, mem.Allocator_Error) #optional_allocator_error { + d, err := make([]E, len(a), allocator) copy(d[:], a) - return d + return d, err } // copies slice into a new dynamic array -clone_to_dynamic :: proc(a: $T/[]$E, allocator := context.allocator) -> [dynamic]E { - d := make([dynamic]E, len(a), allocator) +clone_to_dynamic :: proc(a: $T/[]$E, allocator := context.allocator) -> ([dynamic]E, mem.Allocator_Error) #optional_allocator_error { + d, err := make([dynamic]E, len(a), allocator) copy(d[:], a) - return d + return d, err } to_dynamic :: clone_to_dynamic // Converts slice into a dynamic array without cloning or allocating memory +@(require_results) into_dynamic :: proc(a: $T/[]$E) -> [dynamic]E { s := transmute(mem.Raw_Slice)a d := mem.Raw_Dynamic_Array{ @@ -276,43 +297,51 @@ into_dynamic :: proc(a: $T/[]$E) -> [dynamic]E { } +@(require_results) length :: proc(a: $T/[]$E) -> int { return len(a) } +@(require_results) is_empty :: proc(a: $T/[]$E) -> bool { return len(a) == 0 } - +@(require_results) split_at :: proc(array: $T/[]$E, index: int) -> (a, b: T) { return array[:index], array[index:] } +@(require_results) split_first :: proc(array: $T/[]$E) -> (first: E, rest: T) { return array[0], array[1:] } +@(require_results) split_last :: proc(array: $T/[]$E) -> (rest: T, last: E) { n := len(array)-1 return array[:n], array[n] } +@(require_results) first :: proc(array: $T/[]$E) -> E { return array[0] } +@(require_results) last :: proc(array: $T/[]$E) -> E { return array[len(array)-1] } +@(require_results) first_ptr :: proc(array: $T/[]$E) -> ^E { if len(array) != 0 { return &array[0] } return nil } +@(require_results) last_ptr :: proc(array: $T/[]$E) -> ^E { if len(array) != 0 { return &array[len(array)-1] @@ -320,6 +349,7 @@ last_ptr :: proc(array: $T/[]$E) -> ^E { return nil } +@(require_results) get :: proc(array: $T/[]$E, index: int) -> (value: E, ok: bool) { if uint(index) < len(array) { value = array[index] @@ -327,6 +357,7 @@ get :: proc(array: $T/[]$E, index: int) -> (value: E, ok: bool) { } return } +@(require_results) get_ptr :: proc(array: $T/[]$E, index: int) -> (value: ^E, ok: bool) { if uint(index) < len(array) { value = &array[index] @@ -335,19 +366,22 @@ get_ptr :: proc(array: $T/[]$E, index: int) -> (value: ^E, ok: bool) { return } +@(require_results) as_ptr :: proc(array: $T/[]$E) -> [^]E { return raw_data(array) } -mapper :: proc(s: $S/[]$U, f: proc(U) -> $V, allocator := context.allocator) -> []V { - r := make([]V, len(s), allocator) +@(require_results) +mapper :: proc(s: $S/[]$U, f: proc(U) -> $V, allocator := context.allocator) -> (r: []V, err: mem.Allocator_Error) #optional_allocator_error { + r = make([]V, len(s), allocator) or_return for v, i in s { r[i] = f(v) } - return r + return } +@(require_results) reduce :: proc(s: $S/[]$U, initializer: $V, f: proc(V, U) -> V) -> V { r := initializer for v in s { @@ -356,6 +390,7 @@ reduce :: proc(s: $S/[]$U, initializer: $V, f: proc(V, U) -> V) -> V { return r } +@(require_results) filter :: proc(s: $S/[]$U, f: proc(U) -> bool, allocator := context.allocator) -> S { r := make([dynamic]U, 0, 0, allocator) for v in s { @@ -366,10 +401,11 @@ filter :: proc(s: $S/[]$U, f: proc(U) -> bool, allocator := context.allocator) - return r[:] } -scanner :: proc (s: $S/[]$U, initializer: $V, f: proc(V, U) -> V, allocator := context.allocator) -> []V { - if len(s) == 0 { return {} } +@(require_results) +scanner :: proc (s: $S/[]$U, initializer: $V, f: proc(V, U) -> V, allocator := context.allocator) -> (res: []V, err: mem.Allocator_Error) #optional_allocator_error { + if len(s) == 0 { return } - res := make([]V, len(s), allocator) + res = make([]V, len(s), allocator) or_return p := as_ptr(s) q := as_ptr(res) r := initializer @@ -381,10 +417,11 @@ scanner :: proc (s: $S/[]$U, initializer: $V, f: proc(V, U) -> V, allocator := c q = q[1:] } - return res + return } +@(require_results) min :: proc(s: $S/[]$T) -> (res: T, ok: bool) where intrinsics.type_is_ordered(T) #optional_ok { if len(s) != 0 { res = s[0] @@ -395,6 +432,7 @@ min :: proc(s: $S/[]$T) -> (res: T, ok: bool) where intrinsics.type_is_ordered(T } return } +@(require_results) max :: proc(s: $S/[]$T) -> (res: T, ok: bool) where intrinsics.type_is_ordered(T) #optional_ok { if len(s) != 0 { res = s[0] @@ -406,6 +444,7 @@ max :: proc(s: $S/[]$T) -> (res: T, ok: bool) where intrinsics.type_is_ordered(T return } +@(require_results) min_max :: proc(s: $S/[]$T) -> (min, max: T, ok: bool) where intrinsics.type_is_ordered(T) { if len(s) != 0 { min, max = s[0], s[0] @@ -418,6 +457,7 @@ min_max :: proc(s: $S/[]$T) -> (min, max: T, ok: bool) where intrinsics.type_is_ return } +@(require_results) any_of :: proc(s: $S/[]$T, value: T) -> bool where intrinsics.type_is_comparable(T) { for v in s { if v == value { @@ -427,6 +467,7 @@ any_of :: proc(s: $S/[]$T, value: T) -> bool where intrinsics.type_is_comparable return false } +@(require_results) none_of :: proc(s: $S/[]$T, value: T) -> bool where intrinsics.type_is_comparable(T) { for v in s { if v == value { @@ -436,6 +477,7 @@ none_of :: proc(s: $S/[]$T, value: T) -> bool where intrinsics.type_is_comparabl return true } +@(require_results) all_of :: proc(s: $S/[]$T, value: T) -> bool where intrinsics.type_is_comparable(T) { if len(s) == 0 { return false @@ -449,6 +491,7 @@ all_of :: proc(s: $S/[]$T, value: T) -> bool where intrinsics.type_is_comparable } +@(require_results) any_of_proc :: proc(s: $S/[]$T, f: proc(T) -> bool) -> bool { for v in s { if f(v) { @@ -458,6 +501,7 @@ any_of_proc :: proc(s: $S/[]$T, f: proc(T) -> bool) -> bool { return false } +@(require_results) none_of_proc :: proc(s: $S/[]$T, f: proc(T) -> bool) -> bool { for v in s { if f(v) { @@ -467,6 +511,7 @@ none_of_proc :: proc(s: $S/[]$T, f: proc(T) -> bool) -> bool { return true } +@(require_results) all_of_proc :: proc(s: $S/[]$T, f: proc(T) -> bool) -> bool { if len(s) == 0 { return false @@ -480,6 +525,7 @@ all_of_proc :: proc(s: $S/[]$T, f: proc(T) -> bool) -> bool { } +@(require_results) count :: proc(s: $S/[]$T, value: T) -> (n: int) where intrinsics.type_is_comparable(T) { for v in s { if v == value { @@ -489,6 +535,7 @@ count :: proc(s: $S/[]$T, value: T) -> (n: int) where intrinsics.type_is_compara return } +@(require_results) count_proc :: proc(s: $S/[]$T, f: proc(T) -> bool) -> (n: int) { for v in s { if f(v) { @@ -499,6 +546,7 @@ count_proc :: proc(s: $S/[]$T, f: proc(T) -> bool) -> (n: int) { } +@(require_results) dot_product :: proc(a, b: $S/[]$T) -> (r: T, ok: bool) where intrinsics.type_is_numeric(T) { if len(a) != len(b) { @@ -512,7 +560,8 @@ dot_product :: proc(a, b: $S/[]$T) -> (r: T, ok: bool) // Convert a pointer to an enumerated array to a slice of the element type +@(require_results) enumerated_array :: proc(ptr: ^$T) -> []intrinsics.type_elem_type(T) where intrinsics.type_is_enumerated_array(T) { return ([^]intrinsics.type_elem_type(T))(ptr)[:len(T)] -} \ No newline at end of file +} diff --git a/core/slice/sort.odin b/core/slice/sort.odin index 8177205ed..515eddcc3 100644 --- a/core/slice/sort.odin +++ b/core/slice/sort.odin @@ -6,6 +6,7 @@ Ordering :: enum { Greater = +1, } +@(require_results) cmp :: proc(a, b: $E) -> Ordering where ORD(E) { switch { case a < b: @@ -16,6 +17,7 @@ cmp :: proc(a, b: $E) -> Ordering where ORD(E) { return .Equal } +@(require_results) cmp_proc :: proc($E: typeid) -> (proc(E, E) -> Ordering) where ORD(E) { return proc(a, b: E) -> Ordering { switch { @@ -144,6 +146,7 @@ stable_sort_by_cmp :: proc(data: $T/[]$E, cmp: proc(i, j: E) -> Ordering) { } } +@(require_results) is_sorted :: proc(array: $T/[]$E) -> bool where ORD(E) { for i := len(array)-1; i > 0; i -= 1 { if array[i] < array[i-1] { @@ -153,6 +156,7 @@ is_sorted :: proc(array: $T/[]$E) -> bool where ORD(E) { return true } +@(require_results) is_sorted_by :: proc(array: $T/[]$E, less: proc(i, j: E) -> bool) -> bool { for i := len(array)-1; i > 0; i -= 1 { if less(array[i], array[i-1]) { @@ -163,6 +167,8 @@ is_sorted_by :: proc(array: $T/[]$E, less: proc(i, j: E) -> bool) -> bool { } is_sorted_by_cmp :: is_sorted_cmp + +@(require_results) is_sorted_cmp :: proc(array: $T/[]$E, cmp: proc(i, j: E) -> Ordering) -> bool { for i := len(array)-1; i > 0; i -= 1 { if cmp(array[i], array[i-1]) == .Less { @@ -181,7 +187,7 @@ reverse_sort :: proc(data: $T/[]$E) where ORD(E) { } -reverse_sort_by :: proc(data: $T/[]$E, less: proc(i, j: E) -> bool) where ORD(E) { +reverse_sort_by :: proc(data: $T/[]$E, less: proc(i, j: E) -> bool) { context._internal = rawptr(less) sort_by(data, proc(i, j: E) -> bool { k := (proc(i, j: E) -> bool)(context._internal) @@ -189,7 +195,7 @@ reverse_sort_by :: proc(data: $T/[]$E, less: proc(i, j: E) -> bool) where ORD(E) }) } -reverse_sort_by_cmp :: proc(data: $T/[]$E, cmp: proc(i, j: E) -> Ordering) where ORD(E) { +reverse_sort_by_cmp :: proc(data: $T/[]$E, cmp: proc(i, j: E) -> Ordering) { context._internal = rawptr(cmp) sort_by_cmp(data, proc(i, j: E) -> Ordering { k := (proc(i, j: E) -> Ordering)(context._internal) @@ -215,6 +221,7 @@ reverse_sort_by_key :: proc(data: $T/[]$E, key: proc(E) -> $K) where ORD(K) { }) } +@(require_results) is_sorted_by_key :: proc(array: $T/[]$E, key: proc(E) -> $K) -> bool where ORD(K) { for i := len(array)-1; i > 0; i -= 1 { if key(array[i]) < key(array[i-1]) { @@ -224,7 +231,7 @@ is_sorted_by_key :: proc(array: $T/[]$E, key: proc(E) -> $K) -> bool where ORD(K return true } -@(private) +@(private, require_results) _max_depth :: proc(n: int) -> (depth: int) { // 2*ceil(log2(n+1)) for i := n; i > 0; i >>= 1 { depth += 1 diff --git a/core/sort/map.odin b/core/sort/map.odin deleted file mode 100644 index 32f5e09a2..000000000 --- a/core/sort/map.odin +++ /dev/null @@ -1,36 +0,0 @@ -package sort - -import "core:intrinsics" -import "core:runtime" -import "core:slice" - -_ :: runtime -_ :: slice - -map_entries_by_key :: proc(m: ^$M/map[$K]$V, loc := #caller_location) where intrinsics.type_is_ordered(K) { - Entry :: struct { - hash: uintptr, - next: int, - key: K, - value: V, - } - - header := runtime.__get_map_header(m) - entries := (^[dynamic]Entry)(&header.m.entries) - slice.sort_by_key(entries[:], proc(e: Entry) -> K { return e.key }) - runtime.__dynamic_map_reset_entries(header, loc) -} - -map_entries_by_value :: proc(m: ^$M/map[$K]$V, loc := #caller_location) where intrinsics.type_is_ordered(V) { - Entry :: struct { - hash: uintptr, - next: int, - key: K, - value: V, - } - - header := runtime.__get_map_header(m) - entries := (^[dynamic]Entry)(&header.m.entries) - slice.sort_by_key(entries[:], proc(e: Entry) -> V { return e.value }) - runtime.__dynamic_map_reset_entries(header, loc) -} \ No newline at end of file diff --git a/core/strconv/decimal/decimal.odin b/core/strconv/decimal/decimal.odin index 03fde3012..4130da306 100644 --- a/core/strconv/decimal/decimal.odin +++ b/core/strconv/decimal/decimal.odin @@ -8,7 +8,17 @@ Decimal :: struct { decimal_point: int, neg, trunc: bool, } +/* +Sets a Decimal from a given string `s`. The string is expected to represent a float. Stores parsed number in the given Decimal structure. +If parsing fails, the Decimal will be left in an undefined state. +**Inputs** +- d: Pointer to a Decimal struct where the parsed result will be stored +- s: The input string representing the floating-point number + +**Returns** +- ok: A boolean indicating whether the parsing was successful +*/ set :: proc(d: ^Decimal, s: string) -> (ok: bool) { d^ = {} @@ -91,7 +101,16 @@ set :: proc(d: ^Decimal, s: string) -> (ok: bool) { return i == len(s) } +/* +Converts a Decimal to a string representation, using the provided buffer as storage. +**Inputs** +- buf: A byte slice buffer to hold the resulting string +- a: The struct to be converted to a string + +**Returns** +- A string representation of the Decimal +*/ decimal_to_string :: proc(buf: []byte, a: ^Decimal) -> string { digit_zero :: proc(buf: []byte) -> int { for _, i in buf { @@ -100,7 +119,6 @@ decimal_to_string :: proc(buf: []byte, a: ^Decimal) -> string { return len(buf) } - n := 10 + a.count + abs(a.decimal_point) // TODO(bill): make this work with a buffer that's not big enough @@ -129,8 +147,12 @@ decimal_to_string :: proc(buf: []byte, a: ^Decimal) -> string { return string(b[0:w]) } +/* +Trims trailing zeros in the given Decimal, updating the count and decimal_point values as needed. -// trim trailing zeros +**Inputs** +- a: Pointer to the Decimal struct to be trimmed +*/ trim :: proc(a: ^Decimal) { for a.count > 0 && a.digits[a.count-1] == '0' { a.count -= 1 @@ -139,8 +161,15 @@ trim :: proc(a: ^Decimal) { a.decimal_point = 0 } } +/* +Converts a given u64 integer `idx` to its Decimal representation in the provided Decimal struct. +**Used for internal Decimal Operations.** +**Inputs** +- a: Where the result will be stored +- idx: The value to be assigned to the Decimal +*/ assign :: proc(a: ^Decimal, idx: u64) { buf: [64]byte n := 0 @@ -160,9 +189,15 @@ assign :: proc(a: ^Decimal, idx: u64) { a.decimal_point = a.count trim(a) } +/* +Shifts the Decimal value to the right by k positions. +**Used for internal Decimal Operations.** - +**Inputs** +- a: The Decimal struct to be shifted +- k: The number of positions to shift right +*/ shift_right :: proc(a: ^Decimal, k: uint) { r := 0 // read index w := 0 // write index @@ -214,25 +249,136 @@ shift_right :: proc(a: ^Decimal, k: uint) { trim(a) } -shift_left :: proc(a: ^Decimal, k: uint) { - // NOTE(bill): used to determine buffer size required for the decimal from the binary shift - // 'k' means `1< bool #no_bounds_check { + for i in 0..= len(b) { + return true + } + if b[i] != s[i] { + return b[i] < s[i] + } + } + return false + } + + assert(k < 61) + + delta := _shift_left_offsets[k].delta + if prefix_less(a.digits[:a.count], _shift_left_offsets[k].cutoff) { + delta -= 1 + } + + read_index := a.count + write_index := a.count+delta n: uint - for r -= 1; r >= 0; r -= 1 { - n += (uint(a.digits[r]) - '0') << k + for read_index -= 1; read_index >= 0; read_index -= 1 { + n += (uint(a.digits[read_index]) - '0') << k quo := n/10 rem := n - 10*quo - w -= 1 - if w < d { - a.digits[w] = byte('0' + rem) + write_index -= 1 + if write_index < len(a.digits) { + a.digits[write_index] = byte('0' + rem) } else if rem != 0 { a.trunc = true } @@ -242,24 +388,27 @@ shift_left :: proc(a: ^Decimal, k: uint) { for n > 0 { quo := n/10 rem := n - 10*quo - w -= 1 - if w < d { - a.digits[w] = byte('0' + rem) + write_index -= 1 + if write_index < len(a.digits) { + a.digits[write_index] = byte('0' + rem) } else if rem != 0 { a.trunc = true } n = quo } - // NOTE(bill): Remove unused buffer size - assert(w >= 0) - capacity -= w + a.decimal_point += delta - a.count = min(a.count+capacity, d) - a.decimal_point += capacity + a.count = clamp(a.count, 0, len(a.digits)) trim(a) } +/* +Shifts the decimal of the input value by the specified number of places +**Inputs** +- a: The Decimal to be modified +- i: The number of places to shift the decimal (positive for left shift, negative for right shift) +*/ shift :: proc(a: ^Decimal, i: int) { uint_size :: 8*size_of(uint) max_shift :: uint_size-4 @@ -283,7 +432,15 @@ shift :: proc(a: ^Decimal, i: int) { shift_right(a, uint(-k)) } } +/* +Determines if the Decimal can be rounded up at the given digit index +**Inputs** +- a: The Decimal to check +- nd: The digit index to consider for rounding up + +**Returns** Boolean if can be rounded up at the given index (>=5) +*/ can_round_up :: proc(a: ^Decimal, nd: int) -> bool { if nd < 0 || nd >= a.count { return false } if a.digits[nd] == '5' && nd+1 == a.count { @@ -295,7 +452,13 @@ can_round_up :: proc(a: ^Decimal, nd: int) -> bool { return a.digits[nd] >= '5' } +/* +Rounds the Decimal at the given digit index +**Inputs** +- a: The Decimal to be modified +- nd: The digit index to round +*/ round :: proc(a: ^Decimal, nd: int) { if nd < 0 || nd >= a.count { return } if can_round_up(a, nd) { @@ -304,7 +467,13 @@ round :: proc(a: ^Decimal, nd: int) { round_down(a, nd) } } +/* +Rounds the Decimal up at the given digit index +**Inputs** +- a: The Decimal to be modified +- nd: The digit index to round up +*/ round_up :: proc(a: ^Decimal, nd: int) { if nd < 0 || nd >= a.count { return } @@ -321,15 +490,60 @@ round_up :: proc(a: ^Decimal, nd: int) { a.count = 1 a.decimal_point += 1 } +/* +Rounds down the decimal value to the specified number of decimal places +**Inputs** +- a: The Decimal value to be rounded down +- nd: The number of decimal places to round down to + +Example: + + import "core:fmt" + import "core:strconv/decimal" + round_down_example :: proc() { + d: decimal.Decimal + str := [64]u8{} + ok := decimal.set(&d, "123.456") + decimal.round_down(&d, 5) + fmt.println(decimal.decimal_to_string(str[:], &d)) + } + +Output: + + 123.45 + +*/ round_down :: proc(a: ^Decimal, nd: int) { if nd < 0 || nd >= a.count { return } a.count = nd trim(a) } +/* +Extracts the rounded integer part of a decimal value +**Inputs** +- a: A pointer to the Decimal value to extract the rounded integer part from -// Extract integer part, rounded appropriately. There are no guarantees about overflow. +WARNING: There are no guarantees about overflow. + +**Returns** The rounded integer part of the input decimal value + +Example: + + import "core:fmt" + import "core:strconv/decimal" + rounded_integer_example :: proc() { + d: decimal.Decimal + ok := decimal.set(&d, "123.456") + fmt.println(decimal.rounded_integer(&d)) + } + +Output: + + 123 + +*/ rounded_integer :: proc(a: ^Decimal) -> u64 { if a.decimal_point > 20 { return 0xffff_ffff_ffff_ffff diff --git a/core/strconv/generic_float.odin b/core/strconv/generic_float.odin index 489124fbf..70febf832 100644 --- a/core/strconv/generic_float.odin +++ b/core/strconv/generic_float.odin @@ -20,7 +20,29 @@ _f16_info := Float_Info{10, 5, -15} _f32_info := Float_Info{23, 8, -127} _f64_info := Float_Info{52, 11, -1023} +/* +Converts a floating-point number to a string with the specified format and precision. +**Inputs** + +buf: A byte slice to store the resulting string +val: The floating-point value to be converted +fmt: The formatting byte, accepted values are 'e', 'E', 'f', 'F', 'g', 'G' +precision: The number of decimal places to round to +bit_size: The size of the floating-point number in bits, valid values are 16, 32, 64 + +Example: + + buf: [32]byte + val := 3.141592 + fmt := 'f' + precision := 2 + bit_size := 64 + result := strconv.generic_ftoa(buf[:], val, fmt, precision, bit_size) -> "3.14" + +**Returns** +- A byte slice containing the formatted string +*/ generic_ftoa :: proc(buf: []byte, val: f64, fmt: byte, precision, bit_size: int) -> []byte { bits: u64 flt: ^Float_Info @@ -95,8 +117,20 @@ generic_ftoa :: proc(buf: []byte, val: f64, fmt: byte, precision, bit_size: int) return format_digits(buf, shortest, neg, digs, prec, fmt) } +/* +Converts a decimal floating-point number into a byte buffer with the given format +**Inputs** +- buf: The byte buffer to store the formatted number +- shortest: If true, generates the shortest representation of the number +- neg: If true, the number is negative +- digs: The decimal number to be formatted +- precision: The number of digits after the decimal point +- fmt: The format specifier (accepted values: 'f', 'F', 'e', 'E', 'g', 'G') +**Returns** +- A byte slice containing the formatted decimal floating-point number +*/ format_digits :: proc(buf: []byte, shortest: bool, neg: bool, digs: Decimal_Slice, precision: int, fmt: byte) -> []byte { Buffer :: struct { b: []byte, @@ -217,7 +251,15 @@ format_digits :: proc(buf: []byte, shortest: bool, neg: bool, digs: Decimal_Slic } +/* +Rounds the given decimal number to its shortest representation, considering the provided floating-point format +**Inputs** +- d: The decimal number to round +- mant: The mantissa of the floating-point number +- exp: The exponent of the floating-point number +- flt: Pointer to the Float_Info structure containing information about the floating-point format +*/ round_shortest :: proc(d: ^decimal.Decimal, mant: u64, exp: int, flt: ^Float_Info) { if mant == 0 { // If mantissa is zero, the number is zero d.count = 0 @@ -284,16 +326,26 @@ round_shortest :: proc(d: ^decimal.Decimal, mant: u64, exp: int, flt: ^Float_Inf } } +/* +Converts a decimal number to its floating-point representation with the given format and returns the resulting bits +**Inputs** +- d: Pointer to the decimal number to convert +- info: Pointer to the Float_Info structure containing information about the floating-point format + +**Returns** +- b: The bits representing the floating-point number +- overflow: A boolean indicating whether an overflow occurred during conversion +*/ @(private) decimal_to_float_bits :: proc(d: ^decimal.Decimal, info: ^Float_Info) -> (b: u64, overflow: bool) { - end :: proc "contextless" (d: ^decimal.Decimal, mant: u64, exp: int, info: ^Float_Info) -> (b: u64) { - bits := mant & (u64(1)< (bits: u64) { + bits = mant & (u64(1)< bool { mant^ = 0 @@ -303,7 +355,7 @@ decimal_to_float_bits :: proc(d: ^decimal.Decimal, info: ^Float_Info) -> (b: u64 mant: u64 exp: int - if d.decimal_point == 0 { + if d.count == 0 { mant = 0 exp = info.bias b = end(d, mant, exp, info) @@ -326,7 +378,7 @@ decimal_to_float_bits :: proc(d: ^decimal.Decimal, info: ^Float_Info) -> (b: u64 exp = 0 for d.decimal_point > 0 { n := 27 if d.decimal_point >= len(power_table) else power_table[d.decimal_point] - decimal.shift(d, n) + decimal.shift(d, -n) exp += n } for d.decimal_point < 0 || d.decimal_point == 0 && d.digits[0] < '5' { diff --git a/core/strconv/integers.odin b/core/strconv/integers.odin index 2b6d0786e..98a432ac5 100644 --- a/core/strconv/integers.odin +++ b/core/strconv/integers.odin @@ -3,14 +3,24 @@ package strconv Int_Flag :: enum { Prefix, Plus, - Space, } Int_Flags :: bit_set[Int_Flag] MAX_BASE :: 32 digits := "0123456789abcdefghijklmnopqrstuvwxyz" +/* +Determines whether the given unsigned 64-bit integer is a negative value by interpreting it as a signed integer with the specified bit size. +**Inputs** +- x: The unsigned 64-bit integer to check for negativity +- is_signed: A boolean indicating if the input should be treated as a signed integer +- bit_size: The bit size of the signed integer representation (8, 16, 32, or 64) + +**Returns** +- u: The absolute value of the input integer +- neg: A boolean indicating whether the input integer is negative +*/ is_integer_negative :: proc(x: u64, is_signed: bool, bit_size: int) -> (u: u64, neg: bool) { u = x if is_signed { @@ -37,7 +47,21 @@ is_integer_negative :: proc(x: u64, is_signed: bool, bit_size: int) -> (u: u64, } return } +/* +Appends the string representation of an integer to a buffer with specified base, flags, and digit set. +**Inputs** +- buf: The buffer to append the integer representation to +- x: The integer value to convert +- base: The base for the integer representation (2 <= base <= MAX_BASE) +- is_signed: A boolean indicating if the input should be treated as a signed integer +- bit_size: The bit size of the signed integer representation (8, 16, 32, or 64) +- digits: The digit set used for the integer representation +- flags: The Int_Flags bit set to control integer formatting + +**Returns** +- The string containing the integer representation appended to the buffer +*/ append_bits :: proc(buf: []byte, x: u64, base: int, is_signed: bool, bit_size: int, digits: string, flags: Int_Flags) -> string { if base < 2 || base > MAX_BASE { panic("strconv: illegal base passed to append_bits") @@ -73,15 +97,24 @@ append_bits :: proc(buf: []byte, x: u64, base: int, is_signed: bool, bit_size: i i-=1; a[i] = '-' case .Plus in flags: i-=1; a[i] = '+' - case .Space in flags: - i-=1; a[i] = ' ' } out := a[i:] copy(buf, out) return string(buf[0:len(out)]) } +/* +Determines whether the given unsigned 128-bit integer is a negative value by interpreting it as a signed integer with the specified bit size. +**Inputs** +- x: The unsigned 128-bit integer to check for negativity +- is_signed: A boolean indicating if the input should be treated as a signed integer +- bit_size: The bit size of the signed integer representation (8, 16, 32, 64, or 128) + +**Returns** +- u: The absolute value of the input integer +- neg: A boolean indicating whether the input integer is negative +*/ is_integer_negative_128 :: proc(x: u128, is_signed: bool, bit_size: int) -> (u: u128, neg: bool) { u = x if is_signed { @@ -112,9 +145,21 @@ is_integer_negative_128 :: proc(x: u128, is_signed: bool, bit_size: int) -> (u: } return } +/* +Appends the string representation of a 128-bit integer to a buffer with specified base, flags, and digit set. -// import "core:runtime" +**Inputs** +- buf: The buffer to append the integer representation to +- x: The 128-bit integer value to convert +- base: The base for the integer representation (2 <= base <= MAX_BASE) +- is_signed: A boolean indicating if the input should be treated as a signed integer +- bit_size: The bit size of the signed integer representation (8, 16, 32, 64, or 128) +- digits: The digit set used for the integer representation +- flags: The Int_Flags bit set to control integer formatting +**Returns** +- The string containing the integer representation appended to the buffer +*/ append_bits_128 :: proc(buf: []byte, x: u128, base: int, is_signed: bool, bit_size: int, digits: string, flags: Int_Flags) -> string { if base < 2 || base > MAX_BASE { panic("strconv: illegal base passed to append_bits") @@ -157,8 +202,6 @@ append_bits_128 :: proc(buf: []byte, x: u128, base: int, is_signed: bool, bit_si i-=1; a[i] = '-' case .Plus in flags: i-=1; a[i] = '+' - case .Space in flags: - i-=1; a[i] = ' ' } out := a[i:] diff --git a/core/strconv/strconv.odin b/core/strconv/strconv.odin index 0f27d5a1d..eae9f9504 100644 --- a/core/strconv/strconv.odin +++ b/core/strconv/strconv.odin @@ -2,7 +2,19 @@ package strconv import "core:unicode/utf8" import "decimal" +/* +Parses a boolean value from the input string +**Inputs** +- s: The input string + - true: "1", "t", "T", "true", "TRUE", "True" + - false: "0", "f", "F", "false", "FALSE", "False" +- n: An optional pointer to an int to store the length of the parsed substring (default: nil) + +**Returns** +- result: The parsed boolean value (default: false) +- ok: A boolean indicating whether the parsing was successful +*/ parse_bool :: proc(s: string, n: ^int = nil) -> (result: bool = false, ok: bool) { switch s { case "1", "t", "T", "true", "TRUE", "True": @@ -14,7 +26,14 @@ parse_bool :: proc(s: string, n: ^int = nil) -> (result: bool = false, ok: bool) } return } +/* +Finds the integer value of the given rune +**Inputs** +- r: The input rune to find the integer value of + +**Returns** The integer value of the given rune +*/ _digit_value :: proc(r: rune) -> int { ri := int(r) v: int = 16 @@ -25,16 +44,31 @@ _digit_value :: proc(r: rune) -> int { } return v } +/* +Parses an integer value from the input string in the given base, without a prefix -// Parses an integer value from a string, in the given base, without a prefix. -// -// Returns ok=false if no numeric value of the appropriate base could be found, -// or if the input string contained more than just the number. -// -// ``` -// n, ok := strconv.parse_i64_of_base("-1234eeee", 10); -// assert(n == -1234 && ok); -// ``` +**Inputs** +- str: The input string to parse the integer value from +- base: The base of the integer value to be parsed (must be between 1 and 16) +- n: An optional pointer to an int to store the length of the parsed substring (default: nil) + +Example: + + import "core:fmt" + import "core:strconv" + parse_i64_of_base_example :: proc() { + n, ok := strconv.parse_i64_of_base("-1234e3", 10) + fmt.println(n, ok) + } + +Output: + + -1234 false + +**Returns** +- value: Parses an integer value from a string, in the given base, without a prefix. +- ok: ok=false if no numeric value of the appropriate base could be found, or if the input string contained more than just the number. +*/ parse_i64_of_base :: proc(str: string, base: int, n: ^int = nil) -> (value: i64, ok: bool) { assert(base <= 16, "base must be 1-16") @@ -80,19 +114,34 @@ parse_i64_of_base :: proc(str: string, base: int, n: ^int = nil) -> (value: i64, ok = len(s) == 0 return } +/* +Parses an integer value from the input string in base 10, unless there's a prefix -// Parses a integer value from a string, in base 10, unless there's a prefix. -// -// Returns ok=false if a valid integer could not be found, -// or if the input string contained more than just the number. -// -// ``` -// n, ok := strconv.parse_i64_maybe_prefixed("1234"); -// assert(n == 1234 && ok); -// -// n, ok = strconv.parse_i64_maybe_prefixed("0xeeee"); -// assert(n == 0xeeee && ok); -// ``` +**Inputs** +- str: The input string to parse the integer value from +- n: An optional pointer to an int to store the length of the parsed substring (default: nil) + +Example: + + import "core:fmt" + import "core:strconv" + parse_i64_maybe_prefixed_example :: proc() { + n, ok := strconv.parse_i64_maybe_prefixed("1234") + fmt.println(n,ok) + + n, ok = strconv.parse_i64_maybe_prefixed("0xeeee") + fmt.println(n,ok) + } + +Output: + + 1234 true + 61166 true + +**Returns** +- value: The parsed integer value +- ok: ok=false if a valid integer could not be found, or if the input string contained more than just the number. +*/ parse_i64_maybe_prefixed :: proc(str: string, n: ^int = nil) -> (value: i64, ok: bool) { s := str defer if n != nil { n^ = len(str)-len(s) } @@ -146,22 +195,38 @@ parse_i64_maybe_prefixed :: proc(str: string, n: ^int = nil) -> (value: i64, ok: ok = len(s) == 0 return } - +// parse_i64 :: proc{parse_i64_maybe_prefixed, parse_i64_of_base} +/* +Parses an unsigned 64-bit integer value from the input string without a prefix, using the specified base -// Parses an unsigned integer value from a string, in the given base, and -// without a prefix. -// -// Returns ok=false if no numeric value of the appropriate base could be found, -// or if the input string contained more than just the number. -// -// ``` -// n, ok := strconv.parse_u64_of_base("1234eeee", 10); -// assert(n == 1234 && ok); -// -// n, ok = strconv.parse_u64_of_base("5678eeee", 16); -// assert(n == 0x5678eeee && ok); -// ``` +**Inputs** +- str: The input string to parse +- base: The base of the number system to use for parsing + - Must be between 1 and 16 (inclusive) +- n: An optional pointer to an int to store the length of the parsed substring (default: nil) + +Example: + + import "core:fmt" + import "core:strconv" + parse_u64_of_base_example :: proc() { + n, ok := strconv.parse_u64_of_base("1234e3", 10) + fmt.println(n,ok) + + n, ok = strconv.parse_u64_of_base("5678eee",16) + fmt.println(n,ok) + } + +Output: + + 1234 false + 90672878 true + +**Returns** +- value: The parsed uint64 value +- ok: A boolean indicating whether the parsing was successful +*/ parse_u64_of_base :: proc(str: string, base: int, n: ^int = nil) -> (value: u64, ok: bool) { assert(base <= 16, "base must be 1-16") s := str @@ -193,19 +258,37 @@ parse_u64_of_base :: proc(str: string, base: int, n: ^int = nil) -> (value: u64, ok = len(s) == 0 return } +/* +Parses an unsigned 64-bit integer value from the input string, using the specified base or inferring the base from a prefix -// Parses an unsigned integer value from a string in base 10, unless there's a prefix. -// -// Returns ok=false if a valid integer could not be found, if the value was negative, -// or if the input string contained more than just the number. -// -// ``` -// n, ok := strconv.parse_u64_maybe_prefixed("1234"); -// assert(n == 1234 && ok); -// -// n, ok = strconv.parse_u64_maybe_prefixed("0xeeee"); -// assert(n == 0xeeee && ok); -// ``` +**Inputs** +- str: The input string to parse +- base: The base of the number system to use for parsing (default: 0) + - If base is 0, it will be inferred based on the prefix in the input string (e.g. '0x' for hexadecimal) + - If base is not 0, it will be used for parsing regardless of any prefix in the input string +- n: An optional pointer to an int to store the length of the parsed substring (default: nil) + +Example: + + import "core:fmt" + import "core:strconv" + parse_u64_maybe_prefixed_example :: proc() { + n, ok := strconv.parse_u64_maybe_prefixed("1234") + fmt.println(n,ok) + + n, ok = strconv.parse_u64_maybe_prefixed("0xee") + fmt.println(n,ok) + } + +Output: + + 1234 true + 238 true + +**Returns** +- value: The parsed uint64 value +- ok: ok=false if a valid integer could not be found, if the value was negative, or if the input string contained more than just the number. +*/ parse_u64_maybe_prefixed :: proc(str: string, n: ^int = nil) -> (value: u64, ok: bool) { s := str defer if n != nil { n^ = len(str)-len(s) } @@ -248,26 +331,42 @@ parse_u64_maybe_prefixed :: proc(str: string, n: ^int = nil) -> (value: u64, ok: ok = len(s) == 0 return } - +// parse_u64 :: proc{parse_u64_maybe_prefixed, parse_u64_of_base} +/* +Parses a signed integer value from the input string, using the specified base or inferring the base from a prefix -// Parses an integer value from a string in the given base, or -// - if the string has a prefix (e.g: '0x') then that will determine the base; -// - otherwise, assumes base 10. -// -// Returns ok=false if no appropriate value could be found, or if the input string -// contained more than just the number. -// -// ``` -// n, ok := strconv.parse_int("1234"); // without prefix, inferred base 10 -// assert(n == 1234 && ok); -// -// n, ok = strconv.parse_int("ffff", 16); // without prefix, explicit base -// assert(n == 0xffff && ok); -// -// n, ok = strconv.parse_int("0xffff"); // with prefix and inferred base -// assert(n == 0xffff && ok); -// ``` +**Inputs** +- s: The input string to parse +- base: The base of the number system to use for parsing (default: 0) + - If base is 0, it will be inferred based on the prefix in the input string (e.g. '0x' for hexadecimal) + - If base is not 0, it will be used for parsing regardless of any prefix in the input string + +Example: + + import "core:fmt" + import "core:strconv" + parse_int_example :: proc() { + n, ok := strconv.parse_int("1234") // without prefix, inferred base 10 + fmt.println(n,ok) + + n, ok = strconv.parse_int("ffff", 16) // without prefix, explicit base + fmt.println(n,ok) + + n, ok = strconv.parse_int("0xffff") // with prefix and inferred base + fmt.println(n,ok) + } + +Output: + + 1234 true + 65535 true + 65535 true + +**Returns** +- value: The parsed int value +- ok: `false` if no appropriate value could be found, or if the input string contained more than just the number. +*/ parse_int :: proc(s: string, base := 0, n: ^int = nil) -> (value: int, ok: bool) { v: i64 = --- switch base { @@ -277,27 +376,41 @@ parse_int :: proc(s: string, base := 0, n: ^int = nil) -> (value: int, ok: bool) value = int(v) return } +/* +Parses an unsigned integer value from the input string, using the specified base or inferring the base from a prefix +**Inputs** +- s: The input string to parse +- base: The base of the number system to use for parsing (default: 0, inferred) + - If base is 0, it will be inferred based on the prefix in the input string (e.g. '0x' for hexadecimal) + - If base is not 0, it will be used for parsing regardless of any prefix in the input string -// Parses an unsigned integer value from a string in the given base, or -// - if the string has a prefix (e.g: '0x') then that will determine the base; -// - otherwise, assumes base 10. -// -// Returns ok=false if: -// - no appropriate value could be found; or -// - the value was negative. -// - the input string contained more than just the number. -// -// ``` -// n, ok := strconv.parse_uint("1234"); // without prefix, inferred base 10 -// assert(n == 1234 && ok); -// -// n, ok = strconv.parse_uint("ffff", 16); // without prefix, explicit base -// assert(n == 0xffff && ok); -// -// n, ok = strconv.parse_uint("0xffff"); // with prefix and inferred base -// assert(n == 0xffff && ok); -// ``` +Example: + + import "core:fmt" + import "core:strconv" + parse_uint_example :: proc() { + n, ok := strconv.parse_uint("1234") // without prefix, inferred base 10 + fmt.println(n,ok) + + n, ok = strconv.parse_uint("ffff", 16) // without prefix, explicit base + fmt.println(n,ok) + + n, ok = strconv.parse_uint("0xffff") // with prefix and inferred base + fmt.println(n,ok) + } + +Output: + + 1234 true + 65535 true + 65535 true + +**Returns** + +value: The parsed uint value +ok: `false` if no appropriate value could be found; the value was negative; he input string contained more than just the number +*/ parse_uint :: proc(s: string, base := 0, n: ^int = nil) -> (value: uint, ok: bool) { v: u64 = --- switch base { @@ -307,17 +420,31 @@ parse_uint :: proc(s: string, base := 0, n: ^int = nil) -> (value: uint, ok: boo value = uint(v) return } +/* +Parses an integer value from a string in the given base, without any prefix +**Inputs** +- str: The input string containing the integer value +- base: The base (radix) to use for parsing the integer (1-16) +- n: An optional pointer to an int to store the length of the parsed substring (default: nil) -// Parses an integer value from a string, in the given base, without a prefix. -// -// Returns ok=false if no numeric value of the appropriate base could be found, -// or if the input string contained more than just the number. -// -// ``` -// n, ok := strconv.parse_i128_of_base("-1234eeee", 10); -// assert(n == -1234 && ok); -// ``` +Example: + + import "core:fmt" + import "core:strconv" + parse_i128_of_base_example :: proc() { + n, ok := strconv.parse_i128_of_base("-1234eeee", 10) + fmt.println(n,ok) + } + +Output: + + -1234 false + +**Returns** +- value: The parsed i128 value +- ok: false if no numeric value of the appropriate base could be found, or if the input string contained more than just the number. +*/ parse_i128_of_base :: proc(str: string, base: int, n: ^int = nil) -> (value: i128, ok: bool) { assert(base <= 16, "base must be 1-16") @@ -361,19 +488,34 @@ parse_i128_of_base :: proc(str: string, base: int, n: ^int = nil) -> (value: i12 ok = len(s) == 0 return } +/* +Parses an integer value from a string in base 10, unless there's a prefix -// Parses a integer value from a string, in base 10, unless there's a prefix. -// -// Returns ok=false if a valid integer could not be found, -// or if the input string contained more than just the number. -// -// ``` -// n, ok := strconv.parse_i128_maybe_prefixed("1234"); -// assert(n == 1234 && ok); -// -// n, ok = strconv.parse_i128_maybe_prefixed("0xeeee"); -// assert(n == 0xeeee && ok); -// ``` +**Inputs** +- str: The input string containing the integer value +- n: An optional pointer to an int to store the length of the parsed substring (default: nil) + +Example: + + import "core:fmt" + import "core:strconv" + parse_i128_maybe_prefixed_example :: proc() { + n, ok := strconv.parse_i128_maybe_prefixed("1234") + fmt.println(n, ok) + + n, ok = strconv.parse_i128_maybe_prefixed("0xeeee") + fmt.println(n, ok) + } + +Output: + + 1234 true + 61166 true + +**Returns** +- value: The parsed i128 value +- ok: `false` if a valid integer could not be found, or if the input string contained more than just the number. +*/ parse_i128_maybe_prefixed :: proc(str: string, n: ^int = nil) -> (value: i128, ok: bool) { s := str defer if n != nil { n^ = len(str)-len(s) } @@ -427,22 +569,37 @@ parse_i128_maybe_prefixed :: proc(str: string, n: ^int = nil) -> (value: i128, o ok = len(s) == 0 return } - +// parse_i128 :: proc{parse_i128_maybe_prefixed, parse_i128_of_base} +/* +Parses an unsigned integer value from a string in the given base, without any prefix -// Parses an unsigned integer value from a string, in the given base, and -// without a prefix. -// -// Returns ok=false if no numeric value of the appropriate base could be found, -// or if the input string contained more than just the number. -// -// ``` -// n, ok := strconv.parse_u128_of_base("1234eeee", 10); -// assert(n == 1234 && ok); -// -// n, ok = strconv.parse_u128_of_base("5678eeee", 16); -// assert(n == 0x5678eeee && ok); -// ``` +**Inputs** +- str: The input string containing the integer value +- base: The base (radix) to use for parsing the integer (1-16) +- n: An optional pointer to an int to store the length of the parsed substring (default: nil) + +Example: + + import "core:fmt" + import "core:strconv" + parse_u128_of_base_example :: proc() { + n, ok := strconv.parse_u128_of_base("1234eeee", 10) + fmt.println(n, ok) + + n, ok = strconv.parse_u128_of_base("5678eeee", 16) + fmt.println(n, ok) + } + +Output: + + 1234 false + 1450766062 true + +**Returns** +- value: The parsed u128 value +- ok: `false` if no numeric value of the appropriate base could be found, or if the input string contained more than just the number. +*/ parse_u128_of_base :: proc(str: string, base: int, n: ^int = nil) -> (value: u128, ok: bool) { assert(base <= 16, "base must be 1-16") s := str @@ -474,19 +631,34 @@ parse_u128_of_base :: proc(str: string, base: int, n: ^int = nil) -> (value: u12 ok = len(s) == 0 return } +/* +Parses an unsigned integer value from a string in base 10, unless there's a prefix -// Parses an unsigned integer value from a string in base 10, unless there's a prefix. -// -// Returns ok=false if a valid integer could not be found, if the value was negative, -// or if the input string contained more than just the number. -// -// ``` -// n, ok := strconv.parse_u128_maybe_prefixed("1234"); -// assert(n == 1234 && ok); -// -// n, ok = strconv.parse_u128_maybe_prefixed("0xeeee"); -// assert(n == 0xeeee && ok); -// ``` +**Inputs** +- str: The input string containing the integer value +- n: An optional pointer to an int to store the length of the parsed substring (default: nil) + +Example: + + import "core:fmt" + import "core:strconv" + parse_u128_maybe_prefixed_example :: proc() { + n, ok := strconv.parse_u128_maybe_prefixed("1234") + fmt.println(n, ok) + + n, ok = strconv.parse_u128_maybe_prefixed("5678eeee") + fmt.println(n, ok) + } + +Output: + + 1234 true + 5678 false + +**Returns** +- value: The parsed u128 value +- ok: false if a valid integer could not be found, if the value was negative, or if the input string contained more than just the number. +*/ parse_u128_maybe_prefixed :: proc(str: string, n: ^int = nil) -> (value: u128, ok: bool) { s := str defer if n != nil { n^ = len(str)-len(s) } @@ -529,46 +701,153 @@ parse_u128_maybe_prefixed :: proc(str: string, n: ^int = nil) -> (value: u128, o ok = len(s) == 0 return } - +// parse_u128 :: proc{parse_u128_maybe_prefixed, parse_u128_of_base} +/* +Converts a byte to lowercase +**Inputs** +- ch: A byte character to be converted to lowercase. +**Returns** +- A lowercase byte character. +*/ @(private) lower :: #force_inline proc "contextless" (ch: byte) -> byte { return ('a' - 'A') | ch } +/* +Parses a 32-bit floating point number from a string +**Inputs** +- s: The input string containing a 32-bit floating point number. +- n: An optional pointer to an int to store the length of the parsed substring (default: nil). +Example: -// Parses a 32-bit floating point number from a string. -// -// Returns ok=false if a base 10 float could not be found, -// or if the input string contained more than just the number. -// -// ``` -// n, ok := strconv.parse_f32("12.34eee"); -// assert(n == 12.34 && ok); -// -// n, ok = strconv.parse_f32("12.34"); -// assert(n == 12.34 && ok); -// ``` + import "core:fmt" + import "core:strconv" + parse_f32_example :: proc() { + n, ok := strconv.parse_f32("1234eee") + fmt.println(n, ok) + + n, ok = strconv.parse_f32("5678e2") + fmt.println(n, ok) + } + +Output: + + 0.000 false + 567800.000 true + +**Returns** +- value: The parsed 32-bit floating point number. +- ok: `false` if a base 10 float could not be found, or if the input string contained more than just the number. +*/ parse_f32 :: proc(s: string, n: ^int = nil) -> (value: f32, ok: bool) { v: f64 = --- v, ok = parse_f64(s, n) return f32(v), ok } +/* +Parses a 64-bit floating point number from a string -// Parses a 64-bit floating point number from a string. -// -// Returns ok=false if a base 10 float could not be found, -// or if the input string contained more than just the number. -// -// ``` -// n, ok := strconv.parse_f32("12.34eee"); -// assert(n == 12.34 && ok); -// -// n, ok = strconv.parse_f32("12.34"); -// assert(n == 12.34 && ok); -// ``` +**Inputs** +- str: The input string containing a 64-bit floating point number. +- n: An optional pointer to an int to store the length of the parsed substring (default: nil). + +Example: + + import "core:fmt" + import "core:strconv" + parse_f64_example :: proc() { + n, ok := strconv.parse_f64("1234eee") + fmt.println(n, ok) + + n, ok = strconv.parse_f64("5678e2") + fmt.println(n, ok) + } + +Output: + + 0.000 false + 567800.000 true + +**Returns** +- value: The parsed 64-bit floating point number. +- ok: `false` if a base 10 float could not be found, or if the input string contained more than just the number. +*/ parse_f64 :: proc(str: string, n: ^int = nil) -> (value: f64, ok: bool) { + nr: int + value, nr, ok = parse_f64_prefix(str) + if ok && len(str) != nr { + ok = false + } + if n != nil { n^ = nr } + return +} +/* +Parses a 32-bit floating point number from a string and returns the parsed number, the length of the parsed substring, and a boolean indicating whether the parsing was successful + +**Inputs** +- str: The input string containing a 32-bit floating point number. + +Example: + + import "core:fmt" + import "core:strconv" + parse_f32_prefix_example :: proc() { + n, _, ok := strconv.parse_f32_prefix("1234eee") + fmt.println(n, ok) + + n, _, ok = strconv.parse_f32_prefix("5678e2") + fmt.println(n, ok) + } + +Output: + + 0.000 false + 567800.000 true + + +**Returns** +- value: The parsed 32-bit floating point number. +- nr: The length of the parsed substring. +- ok: A boolean indicating whether the parsing was successful. +*/ +parse_f32_prefix :: proc(str: string) -> (value: f32, nr: int, ok: bool) { + f: f64 + f, nr, ok = parse_f64_prefix(str) + value = f32(f) + return +} +/* +Parses a 64-bit floating point number from a string and returns the parsed number, the length of the parsed substring, and a boolean indicating whether the parsing was successful + +**Inputs** +- str: The input string containing a 64-bit floating point number. + +Example: + + import "core:fmt" + import "core:strconv" + parse_f64_prefix_example :: proc() { + n, _, ok := strconv.parse_f64_prefix("12.34eee") + fmt.println(n, ok) + + n, _, ok = strconv.parse_f64_prefix("12.34e2") + fmt.println(n, ok) + } + +Output: + + 0.000 false + 1234.000 true + +**Returns** +- value: The parsed 64-bit floating point number. +- nr: The length of the parsed substring. +- ok: `false` if a base 10 float could not be found, or if the input string contained more than just the number. +*/ +parse_f64_prefix :: proc(str: string) -> (value: f64, nr: int, ok: bool) { common_prefix_len_ignore_case :: proc "contextless" (s, prefix: string) -> int { n := len(prefix) if n > len(s) { @@ -678,8 +957,8 @@ parse_f64 :: proc(str: string, n: ^int = nil) -> (value: f64, ok: bool) { saw_digits = true nd += 1 if nd_mant < MAX_MANT_DIGITS { - MAX_MANT_DIGITS *= 16 - MAX_MANT_DIGITS += int(lower(c) - 'a' + 10) + mantissa *= 16 + mantissa += u64(lower(c) - 'a' + 10) nd_mant += 1 } else { trunc = true @@ -729,12 +1008,11 @@ parse_f64 :: proc(str: string, n: ^int = nil) -> (value: f64, ok: bool) { if mantissa != 0 { exp = decimal_point - nd_mant } - // TODO(bill): check underscore correctness ok = true return } - parse_hex :: proc(s: string, mantissa: u64, exp: int, neg, trunc: bool) -> (f64, bool) { + parse_hex :: proc "contextless" (s: string, mantissa: u64, exp: int, neg, trunc: bool) -> (f64, bool) { info := &_f64_info mantissa, exp := mantissa, exp @@ -751,7 +1029,7 @@ parse_f64 :: proc(str: string, n: ^int = nil) -> (value: f64, ok: bool) { mantissa |= 1 } - for mantissa >> (info.mantbits+2) == 0 { + for mantissa != 0 && mantissa >> (info.mantbits+2) == 0 { mantissa = mantissa>>1 | mantissa&1 exp += 1 } @@ -795,9 +1073,6 @@ parse_f64 :: proc(str: string, n: ^int = nil) -> (value: f64, ok: bool) { } - nr: int - defer if n != nil { n^ = nr } - if value, nr, ok = check_special(str); ok { return } @@ -808,7 +1083,8 @@ parse_f64 :: proc(str: string, n: ^int = nil) -> (value: f64, ok: bool) { mantissa, exp, neg, trunc, hex, nr = parse_components(str) or_return if hex { - return parse_hex(str, mantissa, exp, neg, trunc) + value, ok = parse_hex(str, mantissa, exp, neg, trunc) + return } trunc_block: if !trunc { @@ -819,7 +1095,7 @@ parse_f64 :: proc(str: string, n: ^int = nil) -> (value: f64, ok: bool) { } if mantissa>>_f64_info.mantbits != 0 { - return + break trunc_block } f := f64(mantissa) if neg { @@ -827,7 +1103,7 @@ parse_f64 :: proc(str: string, n: ^int = nil) -> (value: f64, ok: bool) { } switch { case exp == 0: - return f, true + return f, nr, true case exp > 0 && exp <= 15+22: if exp > 22 { f *= pow10[exp-22] @@ -836,12 +1112,11 @@ parse_f64 :: proc(str: string, n: ^int = nil) -> (value: f64, ok: bool) { if f > 1e15 || f < 1e-15 { break trunc_block } - return f * pow10[exp], true + return f * pow10[exp], nr, true case -22 <= exp && exp < 0: - return f / pow10[-exp], true + return f / pow10[-exp], nr, true } } - d: decimal.Decimal decimal.set(&d, str[:nr]) b, overflow := decimal_to_float_bits(&d, &_f64_info) @@ -849,8 +1124,30 @@ parse_f64 :: proc(str: string, n: ^int = nil) -> (value: f64, ok: bool) { ok = !overflow return } +/* +Appends a boolean value as a string to the given buffer +**Inputs** +- buf: The buffer to append the boolean value to +- b: The boolean value to be appended +Example: + + import "core:fmt" + import "core:strconv" + append_bool_example :: proc() { + buf: [6]byte + result := strconv.append_bool(buf[:], true) + fmt.println(result, buf) + } + +Output: + + true [116, 114, 117, 101, 0, 0] + +**Returns** +- The resulting string after appending the boolean value +*/ append_bool :: proc(buf: []byte, b: bool) -> string { n := 0 if b { @@ -860,32 +1157,197 @@ append_bool :: proc(buf: []byte, b: bool) -> string { } return string(buf[:n]) } +/* +Appends an unsigned integer value as a string to the given buffer with the specified base +**Inputs** +- buf: The buffer to append the unsigned integer value to +- u: The unsigned integer value to be appended +- base: The base to use for converting the integer value + +Example: + + import "core:fmt" + import "core:strconv" + append_uint_example :: proc() { + buf: [4]byte + result := strconv.append_uint(buf[:], 42, 16) + fmt.println(result, buf) + } + +Output: + + 2a [50, 97, 0, 0] + +**Returns** +- The resulting string after appending the unsigned integer value +*/ append_uint :: proc(buf: []byte, u: u64, base: int) -> string { return append_bits(buf, u, base, false, 8*size_of(uint), digits, nil) } +/* +Appends a signed integer value as a string to the given buffer with the specified base + +**Inputs** +- buf: The buffer to append the signed integer value to +- i: The signed integer value to be appended +- base: The base to use for converting the integer value + +Example: + + import "core:fmt" + import "core:strconv" + append_int_example :: proc() { + buf: [4]byte + result := strconv.append_int(buf[:], -42, 10) + fmt.println(result, buf) + } + +Output: + + -42 [45, 52, 50, 0] + +**Returns** +- The resulting string after appending the signed integer value +*/ append_int :: proc(buf: []byte, i: i64, base: int) -> string { return append_bits(buf, u64(i), base, true, 8*size_of(int), digits, nil) } +/* +Converts an integer value to a string and stores it in the given buffer +**Inputs** +- buf: The buffer to store the resulting string +- i: The integer value to be converted + +Example: + + import "core:fmt" + import "core:strconv" + itoa_example :: proc() { + buf: [4]byte + result := strconv.itoa(buf[:], 42) + fmt.println(result, buf) // "42" + } + +Output: + + 42 [52, 50, 0, 0] + +**Returns** +- The resulting string after converting the integer value +*/ itoa :: proc(buf: []byte, i: int) -> string { return append_int(buf, i64(i), 10) } +/* +Converts a string to an integer value + +**Inputs** +- s: The string to be converted + +Example: + + import "core:fmt" + import "core:strconv" + atoi_example :: proc() { + fmt.println(strconv.atoi("42")) + } + +Output: + + 42 + +**Returns** +- The resulting integer value +*/ atoi :: proc(s: string) -> int { v, _ := parse_int(s) return v } +/* +Converts a string to a float64 value + +**Inputs** +- s: The string to be converted + +Example: + + import "core:fmt" + import "core:strconv" + atof_example :: proc() { + fmt.println(strconv.atof("3.14")) + } + +Output: + + 3.140 + +**Returns** +- The resulting float64 value after converting the string +*/ atof :: proc(s: string) -> f64 { v, _ := parse_f64(s) return v } - +// Alias to `append_float` ftoa :: append_float +/* +Appends a float64 value as a string to the given buffer with the specified format and precision + +**Inputs** +- buf: The buffer to append the float64 value to +- f: The float64 value to be appended +- fmt: The byte specifying the format to use for the conversion +- prec: The precision to use for the conversion +- bit_size: The size of the float in bits (32 or 64) + +Example: + + import "core:fmt" + import "core:strconv" + append_float_example :: proc() { + buf: [8]byte + result := strconv.append_float(buf[:], 3.14159, 'f', 2, 64) + fmt.println(result, buf) + } + +Output: + + +3.14 [43, 51, 46, 49, 52, 0, 0, 0] + +**Returns** +- The resulting string after appending the float +*/ append_float :: proc(buf: []byte, f: f64, fmt: byte, prec, bit_size: int) -> string { return string(generic_ftoa(buf, f, fmt, prec, bit_size)) } +/* +Appends a quoted string representation of the input string to a given byte slice and returns the result as a string +**Inputs** +- buf: The byte slice to which the quoted string will be appended +- str: The input string to be quoted +!! ISSUE !! NOT EXPECTED -- "\"hello\"" was expected + +Example: + + import "core:fmt" + import "core:strconv" + quote_example :: proc() { + buf: [20]byte + result := strconv.quote(buf[:], "hello") + fmt.println(result, buf) + } + +Output: + + "'h''e''l''l''o'" [34, 39, 104, 39, 39, 101, 39, 39, 108, 39, 39, 108, 39, 39, 111, 39, 34, 0, 0, 0] + +**Returns** +- The resulting string after appending the quoted string representation +*/ quote :: proc(buf: []byte, str: string) -> string { write_byte :: proc(buf: []byte, i: ^int, bytes: ..byte) { if i^ >= len(buf) { @@ -923,7 +1385,30 @@ quote :: proc(buf: []byte, str: string) -> string { write_byte(buf, &i, c) return string(buf[:i]) } +/* +Appends a quoted rune representation of the input rune to a given byte slice and returns the result as a string +**Inputs** +- buf: The byte slice to which the quoted rune will be appended +- r: The input rune to be quoted + +Example: + + import "core:fmt" + import "core:strconv" + quote_rune_example :: proc() { + buf: [4]byte + result := strconv.quote_rune(buf[:], 'A') + fmt.println(result, buf) + } + +Output: + + 'A' [39, 65, 39, 0] + +**Returns** +- The resulting string after appending the quoted rune representation +*/ quote_rune :: proc(buf: []byte, r: rune) -> string { write_byte :: proc(buf: []byte, i: ^int, bytes: ..byte) { if i^ < len(buf) { @@ -979,10 +1464,35 @@ quote_rune :: proc(buf: []byte, r: rune) -> string { return string(buf[:i]) } +/* +Unquotes a single character from the input string, considering the given quote character +**Inputs** +- str: The input string containing the character to unquote +- quote: The quote character to consider (e.g., '"') +Example: + import "core:fmt" + import "core:strconv" + unquote_char_example :: proc() { + src:="\'The\' raven" + r, multiple_bytes, tail_string, success := strconv.unquote_char(src,'\'') + fmt.println("Source:", src) + fmt.printf("r: <%v>, multiple_bytes:%v, tail_string:<%s>, success:%v\n",r, multiple_bytes, tail_string, success) + } +Output: + + Source: 'The' raven + r: <'>, multiple_bytes:false, tail_string:, success:true + +**Returns** +- r: The unquoted rune +- multiple_bytes: A boolean indicating if the rune has multiple bytes +- tail_string: The remaining portion of the input string after unquoting the character +- success: A boolean indicating whether the unquoting was successful +*/ unquote_char :: proc(str: string, quote: byte) -> (r: rune, multiple_bytes: bool, tail_string: string, success: bool) { hex_to_int :: proc(c: byte) -> int { switch c { @@ -1077,7 +1587,54 @@ unquote_char :: proc(str: string, quote: byte) -> (r: rune, multiple_bytes: bool tail_string = s return } +/* +Unquotes the input string considering any type of quote character and returns the unquoted string +**Inputs** +- lit: The input string to unquote +- allocator: (default: context.allocator) + +WARNING: This procedure gives unexpected results if the quotes are not the first and last characters. + +Example: + + import "core:fmt" + import "core:strconv" + unquote_string_example :: proc() { + src:="\"The raven Huginn is black.\"" + s, allocated, ok := strconv.unquote_string(src) + fmt.println(src) + fmt.printf("Unquoted: <%s>, alloc:%v, ok:%v\n\n", s, allocated, ok) + + src="\'The raven Huginn\' is black." + s, allocated, ok = strconv.unquote_string(src) + fmt.println(src) + fmt.printf("Unquoted: <%s>, alloc:%v, ok:%v\n\n", s, allocated, ok) + + src="The raven \'Huginn\' is black." + s, allocated, ok = strconv.unquote_string(src) // Will produce undesireable results + fmt.println(src) + fmt.printf("Unquoted: <%s>, alloc:%v, ok:%v\n", s, allocated, ok) + } + +Output: + + "The raven Huginn is black." + Unquoted: , alloc:false, ok:true + + 'The raven Huginn' is black. + Unquoted: , alloc:false, ok:true + + The raven 'Huginn' is black. + Unquoted: , alloc:false, ok:true + +**Returns** +- res: The resulting unquoted string +- allocated: A boolean indicating if the resulting string was allocated using the provided allocator +- success: A boolean indicating whether the unquoting was successful + +NOTE: If unquoting is unsuccessful, the allocated memory for the result will be freed. +*/ unquote_string :: proc(lit: string, allocator := context.allocator) -> (res: string, allocated, success: bool) { contains_rune :: proc(s: string, r: rune) -> int { for c, offset in s { diff --git a/core/strings/ascii_set.odin b/core/strings/ascii_set.odin index 9b59666f3..247b38527 100644 --- a/core/strings/ascii_set.odin +++ b/core/strings/ascii_set.odin @@ -3,9 +3,22 @@ package strings import "core:unicode/utf8" +/* +Ascii_Set is designed to store ASCII characters efficiently as a bit-array +Each bit in the array corresponds to a specific ASCII character, where the value of the bit (0 or 1) +indicates if the character is present in the set or not. +*/ Ascii_Set :: distinct [8]u32 +/* +Creates an Ascii_Set with unique characters from the input string. -// create an ascii set of all unique characters in the string +Inputs: +- chars: A string containing characters to include in the Ascii_Set. + +Returns: +- as: An Ascii_Set with unique characters from the input string. +- ok: false if any character in the input string is not a valid ASCII character. +*/ ascii_set_make :: proc(chars: string) -> (as: Ascii_Set, ok: bool) #no_bounds_check { for i in 0.. (as: Ascii_Set, ok: bool) #no_bounds_ch ok = true return } +/* +Determines if a given char is contained within an Ascii_Set. -// returns true when the `c` byte is contained in the `as` ascii set -ascii_set_contains :: proc(as: Ascii_Set, c: byte) -> bool #no_bounds_check { +Inputs: +- as: The Ascii_Set to search. +- c: The char to check for in the Ascii_Set. + +Returns: +- res: A boolean indicating if the byte is contained in the Ascii_Set (true) or not (false). +*/ +ascii_set_contains :: proc(as: Ascii_Set, c: byte) -> (res: bool) #no_bounds_check { return as[c>>5] & (1<<(c&31)) != 0 -} \ No newline at end of file +} diff --git a/core/strings/builder.odin b/core/strings/builder.odin index 02177ba8c..28c56f6f9 100644 --- a/core/strings/builder.odin +++ b/core/strings/builder.odin @@ -3,176 +3,352 @@ package strings import "core:runtime" import "core:unicode/utf8" import "core:strconv" +import "core:mem" import "core:io" - -Builder_Flush_Proc :: #type proc(b: ^Builder) -> (do_reset: bool) - /* - dynamic byte buffer / string builder with helper procedures - the dynamic array is wrapped inside the struct to be more opaque - you can use `fmt.sbprint*` procedures with a `^strings.Builder` directly +Type definition for a procedure that flushes a Builder + +Inputs: +- b: A pointer to the Builder + +Returns: +A boolean indicating whether the Builder should be reset +*/ +Builder_Flush_Proc :: #type proc(b: ^Builder) -> (do_reset: bool) +/* +A dynamic byte buffer / string builder with helper procedures +The dynamic array is wrapped inside the struct to be more opaque +You can use `fmt.sbprint*` procedures with a `^strings.Builder` directly */ Builder :: struct { buf: [dynamic]byte, } +/* +Produces a Builder with a default length of 0 and cap of 16 -// return a builder, default length 0 / cap 16 are done through make -builder_make_none :: proc(allocator := context.allocator) -> Builder { - return Builder{buf=make([dynamic]byte, allocator)} +*Allocates Using Provided Allocator* + +Inputs: +- allocator: (default is context.allocator) + +Returns: +- res: The new Builder +- err: An optional allocator error if one occured, `nil` otherwise +*/ +builder_make_none :: proc(allocator := context.allocator) -> (res: Builder, err: mem.Allocator_Error) #optional_allocator_error { + return Builder{buf=make([dynamic]byte, allocator) or_return }, nil } +/* +Produces a Builder with a specified length and cap of max(16,len) byte buffer -// return a builder, with a set length `len` and cap 16 byte buffer -builder_make_len :: proc(len: int, allocator := context.allocator) -> Builder { - return Builder{buf=make([dynamic]byte, len, allocator)} +*Allocates Using Provided Allocator* + +Inputs: +- len: The desired length of the Builder's buffer +- allocator: (default is context.allocator) + +Returns: +- res: The new Builder +- err: An optional allocator error if one occured, `nil` otherwise +*/ +builder_make_len :: proc(len: int, allocator := context.allocator) -> (res: Builder, err: mem.Allocator_Error) #optional_allocator_error { + return Builder{buf=make([dynamic]byte, len, allocator) or_return }, nil } +/* +Produces a Builder with a specified length and cap -// return a builder, with a set length `len` byte buffer and a custom `cap` -builder_make_len_cap :: proc(len, cap: int, allocator := context.allocator) -> Builder { - return Builder{buf=make([dynamic]byte, len, cap, allocator)} +*Allocates Using Provided Allocator* + +Inputs: +- len: The desired length of the Builder's buffer +- cap: The desired capacity of the Builder's buffer, cap is max(cap, len) +- allocator: (default is context.allocator) + +Returns: +- res: The new Builder +- err: An optional allocator error if one occured, `nil` otherwise +*/ +builder_make_len_cap :: proc(len, cap: int, allocator := context.allocator) -> (res: Builder, err: mem.Allocator_Error) #optional_allocator_error { + return Builder{buf=make([dynamic]byte, len, cap, allocator) or_return }, nil } +/* +Produces a String Builder -// overload simple `builder_make_*` with or without len / cap parameters +*Allocates Using Provided Allocator* + +Example: + + import "core:fmt" + import "core:strings" + builder_make_example :: proc() { + sb := strings.builder_make() + strings.write_byte(&sb, 'a') + strings.write_string(&sb, " slice of ") + strings.write_f64(&sb, 3.14,'g',true) // See `fmt.fmt_float` byte codes + strings.write_string(&sb, " is ") + strings.write_int(&sb, 180) + strings.write_rune(&sb,'°') + the_string :=strings.to_string(sb) + fmt.println(the_string) + } + +Output: + + a slice of +3.14 is 180° + +*/ builder_make :: proc{ builder_make_none, builder_make_len, builder_make_len_cap, } +/* +Initializes a Builder with a length of 0 and cap of 16 +It replaces the existing `buf` -// initialize a builder, default length 0 / cap 16 are done through make -// replaces the existing `buf` -builder_init_none :: proc(b: ^Builder, allocator := context.allocator) -> ^Builder { - b.buf = make([dynamic]byte, allocator) - return b +*Allocates Using Provided Allocator* + +Inputs: +- b: A pointer to the Builder +- allocator: (default is context.allocator) + +Returns: +- res: A pointer to the initialized Builder +- err: An optional allocator error if one occured, `nil` otherwise +*/ +builder_init_none :: proc(b: ^Builder, allocator := context.allocator) -> (res: ^Builder, err: mem.Allocator_Error) #optional_allocator_error { + b.buf = make([dynamic]byte, allocator) or_return + return b, nil } +/* +Initializes a Builder with a specified length and cap, which is max(len,16) +It replaces the existing `buf` -// initialize a builder, with a set length `len` and cap 16 byte buffer -// replaces the existing `buf` -builder_init_len :: proc(b: ^Builder, len: int, allocator := context.allocator) -> ^Builder { - b.buf = make([dynamic]byte, len, allocator) - return b +*Allocates Using Provided Allocator* + +Inputs: +- b: A pointer to the Builder +- len: The desired length of the Builder's buffer +- allocator: (default is context.allocator) + +Returns: +- res: A pointer to the initialized Builder +- err: An optional allocator error if one occured, `nil` otherwise +*/ +builder_init_len :: proc(b: ^Builder, len: int, allocator := context.allocator) -> (res: ^Builder, err: mem.Allocator_Error) #optional_allocator_error { + b.buf = make([dynamic]byte, len, allocator) or_return + return b, nil } +/* +Initializes a Builder with a specified length and cap +It replaces the existing `buf` -// initialize a builder, with a set length `len` byte buffer and a custom `cap` -// replaces the existing `buf` -builder_init_len_cap :: proc(b: ^Builder, len, cap: int, allocator := context.allocator) -> ^Builder { - b.buf = make([dynamic]byte, len, cap, allocator) - return b +Inputs: +- b: A pointer to the Builder +- len: The desired length of the Builder's buffer +- cap: The desired capacity of the Builder's buffer, actual max(len,cap) +- allocator: (default is context.allocator) + +Returns: +- res: A pointer to the initialized Builder +- err: An optional allocator error if one occured, `nil` otherwise +*/ +builder_init_len_cap :: proc(b: ^Builder, len, cap: int, allocator := context.allocator) -> (res: ^Builder, err: mem.Allocator_Error) #optional_allocator_error { + b.buf = make([dynamic]byte, len, cap, allocator) or_return + return b, nil } - -// overload simple `builder_init_*` with or without len / ap parameters +// Overload simple `builder_init_*` with or without len / ap parameters builder_init :: proc{ builder_init_none, builder_init_len, builder_init_len_cap, } - @(private) -_builder_stream_vtable := io.Stream_VTable{ - impl_write = proc(s: io.Stream, p: []byte) -> (n: int, err: io.Error) { - b := (^Builder)(s.stream_data) - n = write_bytes(b, p) - if n < len(p) { +_builder_stream_proc :: proc(stream_data: rawptr, mode: io.Stream_Mode, p: []byte, offset: i64, whence: io.Seek_From) -> (n: i64, err: io.Error) { + b := (^Builder)(stream_data) + #partial switch mode { + case .Write: + n = i64(write_bytes(b, p)) + if n < i64(len(p)) { err = .EOF } return - }, - impl_write_byte = proc(s: io.Stream, c: byte) -> (err: io.Error) { - b := (^Builder)(s.stream_data) - n := write_byte(b, c) - if n == 0 { - err = .EOF - } + case .Size: + n = i64(len(b.buf)) return - }, - impl_size = proc(s: io.Stream) -> i64 { - b := (^Builder)(s.stream_data) - return i64(len(b.buf)) - }, - impl_destroy = proc(s: io.Stream) -> io.Error { - b := (^Builder)(s.stream_data) - delete(b.buf) - return .None - }, + case .Destroy: + builder_destroy(b) + return + case .Query: + return io.query_utility({.Write, .Size, .Destroy, .Query}) + } + return 0, .Empty } -// return an `io.Stream` from a builder -to_stream :: proc(b: ^Builder) -> io.Stream { - return io.Stream{stream_vtable=&_builder_stream_vtable, stream_data=b} -} +/* +Returns an io.Stream from a Builder -// return an `io.Writer` from a builder -to_writer :: proc(b: ^Builder) -> io.Writer { +Inputs: +- b: A pointer to the Builder + +Returns: +- res: the io.Stream +*/ +to_stream :: proc(b: ^Builder) -> (res: io.Stream) { + return io.Stream{procedure=_builder_stream_proc, data=b} +} +/* +Returns an io.Writer from a Builder + +Inputs: +- b: A pointer to the Builder + +Returns: +- res: The io.Writer +*/ +to_writer :: proc(b: ^Builder) -> (res: io.Writer) { return io.to_writer(to_stream(b)) } +/* +Deletes the Builder byte buffer content -// delete and clear the builder byte buffer content +Inputs: +- b: A pointer to the Builder +*/ builder_destroy :: proc(b: ^Builder) { delete(b.buf) - clear(&b.buf) + b.buf = nil } +/* +Reserves the Builder byte buffer to a specific capacity, when it's higher than before -// reserve the builfer byte buffer to a specific cap, when it's higher than before +Inputs: +- b: A pointer to the Builder +- cap: The desired capacity for the Builder's buffer +*/ builder_grow :: proc(b: ^Builder, cap: int) { reserve(&b.buf, cap) } +/* +Clears the Builder byte buffer content (sets len to zero) -// clear the builder byte buffer content +Inputs: +- b: A pointer to the Builder +*/ builder_reset :: proc(b: ^Builder) { clear(&b.buf) } - /* - create an empty builder with the same slice length as its cap - uses the `mem.nil_allocator` to avoid allocation and keep a fixed length - used in `fmt.bprint*` - - bytes: [8]byte // <-- gets filled - builder := strings.builder_from_bytes(bytes[:]) - strings.write_byte(&builder, 'a') -> "a" - strings.write_byte(&builder, 'b') -> "ab" -*/ -builder_from_bytes :: proc(backing: []byte) -> Builder { - s := transmute(runtime.Raw_Slice)backing - d := runtime.Raw_Dynamic_Array{ - data = s.data, - len = 0, - cap = s.len, - allocator = runtime.nil_allocator(), - } - return Builder{ - buf = transmute([dynamic]byte)d, - } -} -builder_from_slice :: builder_from_bytes +Creates a Builder from a slice of bytes with the same slice length as its capacity. Used in fmt.bprint* -// cast the builder byte buffer to a string and return it -to_string :: proc(b: Builder) -> string { +*Uses Nil Allocator - Does NOT allocate* + +Inputs: +- backing: A slice of bytes to be used as the backing buffer + +Returns: +- res: The new Builder + +Example: + + import "core:fmt" + import "core:strings" + builder_from_bytes_example :: proc() { + bytes: [8]byte // <-- gets filled + builder := strings.builder_from_bytes(bytes[:]) + strings.write_byte(&builder, 'a') + fmt.println(strings.to_string(builder)) // -> "a" + strings.write_byte(&builder, 'b') + fmt.println(strings.to_string(builder)) // -> "ab" + } + +Output: + + a + ab + +*/ +builder_from_bytes :: proc(backing: []byte) -> (res: Builder) { + return Builder{ buf = mem.buffer_from_slice(backing) } +} +// Alias to `builder_from_bytes` +builder_from_slice :: builder_from_bytes +/* +Casts the Builder byte buffer to a string and returns it + +Inputs: +- b: A Builder + +Returns: +- res: The contents of the Builder's buffer, as a string +*/ +to_string :: proc(b: Builder) -> (res: string) { return string(b.buf[:]) } +/* +Returns the length of the Builder's buffer, in bytes -// return the length of the builder byte buffer -builder_len :: proc(b: Builder) -> int { +Inputs: +- b: A Builder + +Returns: +- res: The length of the Builder's buffer +*/ +builder_len :: proc(b: Builder) -> (res: int) { return len(b.buf) } +/* +Returns the capacity of the Builder's buffer, in bytes -// return the cap of the builder byte buffer -builder_cap :: proc(b: Builder) -> int { +Inputs: +- b: A Builder + +Returns: +- res: The capacity of the Builder's buffer +*/ +builder_cap :: proc(b: Builder) -> (res: int) { return cap(b.buf) } +/* +The free space left in the Builder's buffer, in bytes -// returns the space left in the builder byte buffer to use up -builder_space :: proc(b: Builder) -> int { +Inputs: +- b: A Builder + +Returns: +- res: The available space left in the Builder's buffer +*/ +builder_space :: proc(b: Builder) -> (res: int) { return cap(b.buf) - len(b.buf) } - /* - appends a byte to the builder, returns the append diff +Appends a byte to the Builder and returns the number of bytes appended + +Inputs: +- b: A pointer to the Builder +- x: The byte to be appended + +Returns: +- n: The number of bytes appended + +NOTE: The backing dynamic array may be fixed in capacity or fail to resize, `n` states the number actually written. + +Example: + + import "core:fmt" + import "core:strings" + + write_byte_example :: proc() { + builder := strings.builder_make() + strings.write_byte(&builder, 'a') // 1 + strings.write_byte(&builder, 'b') // 1 + fmt.println(strings.to_string(builder)) // -> ab + } + +Output: + + ab - builder := strings.builder_make() - strings.write_byte(&builder, 'a') // 1 - strings.write_byte(&builder, 'b') // 1 - strings.write_byte(&builder, 'c') // 1 - fmt.println(strings.to_string(builder)) // -> abc */ write_byte :: proc(b: ^Builder, x: byte) -> (n: int) { n0 := len(b.buf) @@ -180,14 +356,29 @@ write_byte :: proc(b: ^Builder, x: byte) -> (n: int) { n1 := len(b.buf) return n1-n0 } - /* - appends a slice of bytes to the builder, returns the append diff +Appends a slice of bytes to the Builder and returns the number of bytes appended - builder := strings.builder_make() - bytes := [?]byte { 'a', 'b', 'c' } - strings.write_bytes(&builder, bytes[:]) // 3 - fmt.println(strings.to_string(builder)) // -> abc +Inputs: +- b: A pointer to the Builder +- x: The slice of bytes to be appended + +Example: + + import "core:fmt" + import "core:strings" + + write_bytes_example :: proc() { + builder := strings.builder_make() + bytes := [?]byte { 'a', 'b', 'c' } + strings.write_bytes(&builder, bytes[:]) // 3 + fmt.println(strings.to_string(builder)) // -> abc + } + +NOTE: The backing dynamic array may be fixed in capacity or fail to resize, `n` states the number actually written. + +Returns: +- n: The number of bytes appended */ write_bytes :: proc(b: ^Builder, x: []byte) -> (n: int) { n0 := len(b.buf) @@ -195,42 +386,100 @@ write_bytes :: proc(b: ^Builder, x: []byte) -> (n: int) { n1 := len(b.buf) return n1-n0 } - /* - appends a single rune into the builder, returns written rune size and an `io.Error` +Appends a single rune to the Builder and returns the number of bytes written and an `io.Error` + +Inputs: +- b: A pointer to the Builder +- r: The rune to be appended + +Returns: +- res: The number of bytes written +- err: An io.Error if one occured, `nil` otherwise + +NOTE: The backing dynamic array may be fixed in capacity or fail to resize, `n` states the number actually written. + +Example: + + import "core:fmt" + import "core:strings" + + write_rune_example :: proc() { + builder := strings.builder_make() + strings.write_rune(&builder, 'Ƥ') // 2 None + strings.write_rune(&builder, 'b') // 1 None + fmt.println(strings.to_string(builder)) // -> Ƥb + } + +Output: + + Ƥb - builder := strings.builder_make() - strings.write_rune(&builder, 'Ƥ') // 2 None - strings.write_rune(&builder, 'b') // 1 None - strings.write_rune(&builder, 'c') // 1 None - fmt.println(strings.to_string(builder)) // -> Ƥbc */ -write_rune :: proc(b: ^Builder, r: rune) -> (int, io.Error) { +write_rune :: proc(b: ^Builder, r: rune) -> (res: int, err: io.Error) { return io.write_rune(to_writer(b), r) } - /* - appends a quoted rune into the builder, returns written size +Appends a quoted rune to the Builder and returns the number of bytes written + +Inputs: +- b: A pointer to the Builder +- r: The rune to be appended + +Returns: +- n: The number of bytes written + +NOTE: The backing dynamic array may be fixed in capacity or fail to resize, `n` states the number actually written. + +Example: + + import "core:fmt" + import "core:strings" + + write_quoted_rune_example :: proc() { + builder := strings.builder_make() + strings.write_string(&builder, "abc") // 3 + strings.write_quoted_rune(&builder, 'Ƥ') // 4 + strings.write_string(&builder, "abc") // 3 + fmt.println(strings.to_string(builder)) // -> abc'Ƥ'abc + } + +Output: + + abc'Ƥ'abc - builder := strings.builder_make() - strings.write_string(&builder, "abc") // 3 - strings.write_quoted_rune(&builder, 'Ƥ') // 4 - strings.write_string(&builder, "abc") // 3 - fmt.println(strings.to_string(builder)) // -> abc'Ƥ'abc */ write_quoted_rune :: proc(b: ^Builder, r: rune) -> (n: int) { return io.write_quoted_rune(to_writer(b), r) } - - /* - appends a string to the builder, return the written byte size - - builder := strings.builder_make() - strings.write_string(&builder, "a") // 1 - strings.write_string(&builder, "bc") // 2 - strings.write_string(&builder, "xyz") // 3 - fmt.println(strings.to_string(builder)) // -> abcxyz +Appends a string to the Builder and returns the number of bytes written + +Inputs: +- b: A pointer to the Builder +- s: The string to be appended + +Returns: +- n: The number of bytes written + +NOTE: The backing dynamic array may be fixed in capacity or fail to resize, `n` states the number actually written. + +Example: + + import "core:fmt" + import "core:strings" + + write_string_example :: proc() { + builder := strings.builder_make() + strings.write_string(&builder, "a") // 1 + strings.write_string(&builder, "bc") // 2 + fmt.println(strings.to_string(builder)) // -> abc + } + +Output: + + abc + */ write_string :: proc(b: ^Builder, s: string) -> (n: int) { n0 := len(b.buf) @@ -238,10 +487,15 @@ write_string :: proc(b: ^Builder, s: string) -> (n: int) { n1 := len(b.buf) return n1-n0 } +/* +Pops and returns the last byte in the Builder or 0 when the Builder is empty +Inputs: +- b: A pointer to the Builder -// pops and returns the last byte in the builder -// returns 0 when the builder is empty +Returns: +- r: The last byte in the Builder or 0 if empty +*/ pop_byte :: proc(b: ^Builder) -> (r: byte) { if len(b.buf) == 0 { return 0 @@ -252,9 +506,16 @@ pop_byte :: proc(b: ^Builder) -> (r: byte) { d.len = max(d.len-1, 0) return } +/* +Pops the last rune in the Builder and returns the popped rune and its rune width or (0, 0) if empty -// pops the last rune in the builder and returns the popped rune and its rune width -// returns 0, 0 when the builder is empty +Inputs: +- b: A pointer to the Builder + +Returns: +- r: The popped rune +- width: The rune width or 0 if the builder was empty +*/ pop_rune :: proc(b: ^Builder) -> (r: rune, width: int) { if len(b.buf) == 0 { return 0, 0 @@ -265,41 +526,116 @@ pop_rune :: proc(b: ^Builder) -> (r: rune, width: int) { d.len = max(d.len-width, 0) return } - @(private) DIGITS_LOWER := "0123456789abcdefx" - /* - append a quoted string into the builder, return the written byte size +Inputs: +- b: A pointer to the Builder +- str: The string to be quoted and appended +- quote: The optional quote character (default is double quotes) + +Returns: +- n: The number of bytes written + +NOTE: The backing dynamic array may be fixed in capacity or fail to resize, `n` states the number actually written. + +Example: + + import "core:fmt" + import "core:strings" + + write_quoted_string_example :: proc() { + builder := strings.builder_make() + strings.write_quoted_string(&builder, "a") // 3 + strings.write_quoted_string(&builder, "bc", '\'') // 4 + strings.write_quoted_string(&builder, "xyz") // 5 + fmt.println(strings.to_string(builder)) + } + +Output: + + "a"'bc'"xyz" - builder := strings.builder_make() - strings.write_quoted_string(&builder, "a") // 3 - strings.write_quoted_string(&builder, "bc", '\'') // 4 - strings.write_quoted_string(&builder, "xyz") // 5 - fmt.println(strings.to_string(builder)) // -> "a"'bc'xyz" */ write_quoted_string :: proc(b: ^Builder, str: string, quote: byte = '"') -> (n: int) { n, _ = io.write_quoted_string(to_writer(b), str, quote) return } +/* +Appends a rune to the Builder and returns the number of bytes written +Inputs: +- b: A pointer to the Builder +- r: The rune to be appended +- write_quote: Optional boolean flag to wrap in single-quotes (') (default is true) -// appends a rune to the builder, optional `write_quote` boolean tag, returns the written rune size +Returns: +- n: The number of bytes written + +NOTE: The backing dynamic array may be fixed in capacity or fail to resize, `n` states the number actually written. + +Example: + + import "core:fmt" + import "core:strings" + + write_encoded_rune_example :: proc() { + builder := strings.builder_make() + strings.write_encoded_rune(&builder, 'a', false) // 1 + strings.write_encoded_rune(&builder, '\"', true) // 3 + strings.write_encoded_rune(&builder, 'x', false) // 1 + fmt.println(strings.to_string(builder)) + } + +Output: + + a'"'x + +*/ write_encoded_rune :: proc(b: ^Builder, r: rune, write_quote := true) -> (n: int) { n, _ = io.write_encoded_rune(to_writer(b), r, write_quote) return } +/* +Appends an escaped rune to the Builder and returns the number of bytes written -// appends a rune to the builder, fully written out in case of escaped runes e.g. '\a' will be written as such -// when `r` and `quote` match and `quote` is `\\` - they will be written as two slashes -// `html_safe` flag in case the runes '<', '>', '&' should be encoded as digits e.g. `\u0026` +Inputs: +- b: A pointer to the Builder +- r: The rune to be appended +- quote: The quote character +- html_safe: Optional boolean flag to encode '<', '>', '&' as digits (default is false) + +**Usage** +- '\a' will be written as such +- `r` and `quote` match and `quote` is `\\` - they will be written as two slashes +- `html_safe` flag in case the runes '<', '>', '&' should be encoded as digits e.g. `\u0026` + +NOTE: The backing dynamic array may be fixed in capacity or fail to resize, `n` states the number actually written. + +Returns: +- n: The number of bytes written +*/ write_escaped_rune :: proc(b: ^Builder, r: rune, quote: byte, html_safe := false) -> (n: int) { n, _ = io.write_escaped_rune(to_writer(b), r, quote, html_safe) return } +/* +Writes a f64 value to the Builder and returns the number of characters written -// writes a f64 value into the builder, returns the written amount of characters +Inputs: +- b: A pointer to the Builder +- f: The f64 value to be appended +- fmt: The format byte +- prec: The precision +- bit_size: The bit size +- always_signed: Optional boolean flag to always include the sign (default is false) + +NOTE: The backing dynamic array may be fixed in capacity or fail to resize, `n` states the number actually written. + +Returns: +- n: The number of characters written +*/ write_float :: proc(b: ^Builder, f: f64, fmt: byte, prec, bit_size: int, always_signed := false) -> (n: int) { buf: [384]byte s := strconv.append_float(buf[:], f, fmt, prec, bit_size) @@ -310,8 +646,20 @@ write_float :: proc(b: ^Builder, f: f64, fmt: byte, prec, bit_size: int, always_ } return write_string(b, s) } +/* +Writes a f16 value to the Builder and returns the number of characters written -// writes a f16 value into the builder, returns the written amount of characters +Inputs: +- b: A pointer to the Builder +- f: The f16 value to be appended +- fmt: The format byte +- always_signed: Optional boolean flag to always include the sign + +NOTE: The backing dynamic array may be fixed in capacity or fail to resize, `n` states the number actually written. + +Returns: +- n: The number of characters written +*/ write_f16 :: proc(b: ^Builder, f: f16, fmt: byte, always_signed := false) -> (n: int) { buf: [384]byte s := strconv.append_float(buf[:], f64(f), fmt, 2*size_of(f), 8*size_of(f)) @@ -320,8 +668,38 @@ write_f16 :: proc(b: ^Builder, f: f16, fmt: byte, always_signed := false) -> (n: } return write_string(b, s) } +/* +Writes a f32 value to the Builder and returns the number of characters written -// writes a f32 value into the builder, returns the written amount of characters +Inputs: +- b: A pointer to the Builder +- f: The f32 value to be appended +- fmt: The format byte +- always_signed: Optional boolean flag to always include the sign + +Returns: +- n: The number of characters written + +NOTE: The backing dynamic array may be fixed in capacity or fail to resize, `n` states the number actually written. + +Example: + + import "core:fmt" + import "core:strings" + + write_f32_example :: proc() { + builder := strings.builder_make() + strings.write_f32(&builder, 3.14159, 'f') // 6 + strings.write_string(&builder, " - ") // 3 + strings.write_f32(&builder, -0.123, 'e') // 8 + fmt.println(strings.to_string(builder)) // -> 3.14159012 - -1.23000003e-01 + } + +Output: + + 3.14159012 - -1.23000003e-01 + +*/ write_f32 :: proc(b: ^Builder, f: f32, fmt: byte, always_signed := false) -> (n: int) { buf: [384]byte s := strconv.append_float(buf[:], f64(f), fmt, 2*size_of(f), 8*size_of(f)) @@ -330,8 +708,20 @@ write_f32 :: proc(b: ^Builder, f: f32, fmt: byte, always_signed := false) -> (n: } return write_string(b, s) } +/* +Writes a f32 value to the Builder and returns the number of characters written -// writes a f64 value into the builder, returns the written amount of characters +Inputs: +- b: A pointer to the Builder +- f: The f32 value to be appended +- fmt: The format byte +- always_signed: Optional boolean flag to always include the sign + +NOTE: The backing dynamic array may be fixed in capacity or fail to resize, `n` states the number actually written. + +Returns: +- n: The number of characters written +*/ write_f64 :: proc(b: ^Builder, f: f64, fmt: byte, always_signed := false) -> (n: int) { buf: [384]byte s := strconv.append_float(buf[:], f64(f), fmt, 2*size_of(f), 8*size_of(f)) @@ -340,30 +730,71 @@ write_f64 :: proc(b: ^Builder, f: f64, fmt: byte, always_signed := false) -> (n: } return write_string(b, s) } +/* +Writes a u64 value to the Builder and returns the number of characters written +Inputs: +- b: A pointer to the Builder +- i: The u64 value to be appended +- base: The optional base for the numeric representation +NOTE: The backing dynamic array may be fixed in capacity or fail to resize, `n` states the number actually written. -// writes a u64 value `i` in `base` = 10 into the builder, returns the written amount of characters +Returns: +- n: The number of characters written +*/ write_u64 :: proc(b: ^Builder, i: u64, base: int = 10) -> (n: int) { buf: [32]byte s := strconv.append_bits(buf[:], i, base, false, 64, strconv.digits, nil) return write_string(b, s) } +/* +Writes a i64 value to the Builder and returns the number of characters written -// writes a i64 value `i` in `base` = 10 into the builder, returns the written amount of characters +Inputs: +- b: A pointer to the Builder +- i: The i64 value to be appended +- base: The optional base for the numeric representation + +NOTE: The backing dynamic array may be fixed in capacity or fail to resize, `n` states the number actually written. + +Returns: +- n: The number of characters written +*/ write_i64 :: proc(b: ^Builder, i: i64, base: int = 10) -> (n: int) { buf: [32]byte s := strconv.append_bits(buf[:], u64(i), base, true, 64, strconv.digits, nil) return write_string(b, s) } +/* +Writes a uint value to the Builder and returns the number of characters written -// writes a uint value `i` in `base` = 10 into the builder, returns the written amount of characters +Inputs: +- b: A pointer to the Builder +- i: The uint value to be appended +- base: The optional base for the numeric representation + +NOTE: The backing dynamic array may be fixed in capacity or fail to resize, `n` states the number actually written. + +Returns: +- n: The number of characters written +*/ write_uint :: proc(b: ^Builder, i: uint, base: int = 10) -> (n: int) { return write_u64(b, u64(i), base) } +/* +Writes a int value to the Builder and returns the number of characters written -// writes a int value `i` in `base` = 10 into the builder, returns the written amount of characters +Inputs: +- b: A pointer to the Builder +- i: The int value to be appended +- base: The optional base for the numeric representation + +NOTE: The backing dynamic array may be fixed in capacity or fail to resize, `n` states the number actually written. + +Returns: +- n: The number of characters written +*/ write_int :: proc(b: ^Builder, i: int, base: int = 10) -> (n: int) { return write_i64(b, i64(i), base) } - diff --git a/core/strings/conversion.odin b/core/strings/conversion.odin index ab827490d..2e82fff58 100644 --- a/core/strings/conversion.odin +++ b/core/strings/conversion.odin @@ -1,16 +1,33 @@ package strings import "core:io" +import "core:mem" import "core:unicode" import "core:unicode/utf8" -to_valid_utf8 :: proc(s, replacement: string, allocator := context.allocator) -> string { +/* +Converts invalid UTF-8 sequences in the input string `s` to the `replacement` string. + +*Allocates Using Provided Allocator* + +Inputs: +- s: Input string that may contain invalid UTF-8 sequences. +- replacement: String to replace invalid UTF-8 sequences with. +- allocator: (default: context.allocator). + +WARNING: Allocation does not occur when len(s) == 0 + +Returns: +- res: A valid UTF-8 string with invalid sequences replaced by `replacement`. +- err: An optional allocator error if one occured, `nil` otherwise +*/ +to_valid_utf8 :: proc(s, replacement: string, allocator := context.allocator) -> (res: string, err: mem.Allocator_Error) #optional_allocator_error { if len(s) == 0 { - return "" + return "", nil } b: Builder - builder_init(&b, 0, 0, allocator) + builder_init(&b, 0, 0, allocator) or_return s := s for c, i in s { @@ -33,7 +50,7 @@ to_valid_utf8 :: proc(s, replacement: string, allocator := context.allocator) -> invalid := false - for i := 0; i < len(s); /**/ { + for i := 0; i < len(s); /**/{ c := s[i] if c < utf8.RUNE_SELF { i += 1 @@ -55,55 +72,110 @@ to_valid_utf8 :: proc(s, replacement: string, allocator := context.allocator) -> write_string(&b, s[i:][:w]) i += w } - return to_string(b) + return to_string(b), nil } - /* - returns the input string `s` with all runes set to lowered case - always allocates using the `allocator` +Converts the input string `s` to all lowercase characters. + +*Allocates Using Provided Allocator* + +Inputs: +- s: Input string to be converted. +- allocator: (default: context.allocator). + +Returns: +- res: The new string with all characters converted to lowercase +- err: An optional allocator error if one occured, `nil` otherwise + +Example: + + import "core:fmt" + import "core:strings" + + to_lower_example :: proc() { + fmt.println(strings.to_lower("TeST")) + } + +Output: + + test - strings.to_lower("test") -> test - strings.to_lower("Test") -> test */ -to_lower :: proc(s: string, allocator := context.allocator) -> string { +to_lower :: proc(s: string, allocator := context.allocator) -> (res: string, err: mem.Allocator_Error) #optional_allocator_error { b: Builder - builder_init(&b, 0, len(s), allocator) + builder_init(&b, 0, len(s), allocator) or_return for r in s { write_rune(&b, unicode.to_lower(r)) } - return to_string(b) + return to_string(b), nil } - /* - returns the input string `s` with all runes set to upper case - always allocates using the `allocator` +Converts the input string `s` to all uppercase characters. + +*Allocates Using Provided Allocator* + +Inputs: +- s: Input string to be converted. +- allocator: (default: context.allocator). + +Returns: +- res: The new string with all characters converted to uppercase +- err: An optional allocator error if one occured, `nil` otherwise + +Example: + + import "core:fmt" + import "core:strings" + + to_upper_example :: proc() { + fmt.println(strings.to_upper("Test")) + } + +Output: + + TEST - strings.to_lower("test") -> TEST - strings.to_lower("Test") -> TEST */ -to_upper :: proc(s: string, allocator := context.allocator) -> string { +to_upper :: proc(s: string, allocator := context.allocator) -> (res: string, err: mem.Allocator_Error) #optional_allocator_error { b: Builder - builder_init(&b, 0, len(s), allocator) + builder_init(&b, 0, len(s), allocator) or_return for r in s { write_rune(&b, unicode.to_upper(r)) } - return to_string(b) + return to_string(b), nil } +/* +Checks if the rune `r` is a delimiter (' ', '-', or '_'). -// returns true when the `c` rune is a space, '-' or '_' -// useful when treating strings like words in a text editor or html paths -is_delimiter :: proc(c: rune) -> bool { - return c == '-' || c == '_' || is_space(c) +Inputs: +- r: Rune to check for delimiter status. + +Returns: +- res: True if `r` is a delimiter, false otherwise. +*/ +is_delimiter :: proc(r: rune) -> (res: bool) { + return r == '-' || r == '_' || is_space(r) } +/* +Checks if the rune `r` is a non-alphanumeric or space character. -// returns true when the `r` rune is a non alpha or `unicode.is_space` rune -is_separator :: proc(r: rune) -> bool { +Inputs: +- r: Rune to check for separator status. + +Returns: +- res: True if `r` is a non-alpha or `unicode.is_space` rune. +*/ +is_separator :: proc(r: rune) -> (res: bool) { if r <= 0x7f { switch r { - case '0'..='9': return false - case 'a'..='z': return false - case 'A'..='Z': return false - case '_': return false + case '0' ..= '9': + return false + case 'a' ..= 'z': + return false + case 'A' ..= 'Z': + return false + case '_': + return false } return true } @@ -115,12 +187,46 @@ is_separator :: proc(r: rune) -> bool { return unicode.is_space(r) } - /* - iterator that loops through the string and calls the callback with the `prev`, `curr` and `next` rune - on empty string `s` the callback gets called once with empty runes +Iterates over a string, calling a callback for each rune with the previous, current, and next runes as arguments. + +Inputs: +- w: An io.Writer to be used by the callback for writing output. +- s: The input string to be iterated over. +- callback: A procedure to be called for each rune in the string, with arguments (w: io.Writer, prev, curr, next: rune). +The callback can utilize the provided io.Writer to write output during the iteration. + +Example: + + import "core:fmt" + import "core:strings" + import "core:io" + + string_case_iterator_example :: proc() { + my_callback :: proc(w: io.Writer, prev, curr, next: rune) { + fmt.println("my_callback", curr) // <-- Custom logic here + } + s := "hello" + b: strings.Builder + strings.builder_init_len(&b, len(s)) + w := strings.to_writer(&b) + strings.string_case_iterator(w, s, my_callback) + } + +Output: + + my_callback h + my_callback e + my_callback l + my_callback l + my_callback o + */ -string_case_iterator :: proc(w: io.Writer, s: string, callback: proc(w: io.Writer, prev, curr, next: rune)) { +string_case_iterator :: proc( + w: io.Writer, + s: string, + callback: proc(w: io.Writer, prev, curr, next: rune), +) { prev, curr: rune for next in s { if curr == 0 { @@ -139,15 +245,26 @@ string_case_iterator :: proc(w: io.Writer, s: string, callback: proc(w: io.Write callback(w, prev, curr, 0) } } - +// Alias to `to_camel_case` to_lower_camel_case :: to_camel_case +/* +Converts the input string `s` to "lowerCamelCase". -// converts the `s` string to "lowerCamelCase" -to_camel_case :: proc(s: string, allocator := context.allocator) -> string { +*Allocates Using Provided Allocator* + +Inputs: +- s: Input string to be converted. +- allocator: (default: context.allocator). + +Returns: +- res: The converted string +- err: An optional allocator error if one occured, `nil` otherwise +*/ +to_camel_case :: proc(s: string, allocator := context.allocator) -> (res: string, err: mem.Allocator_Error) #optional_allocator_error { s := s s = trim_space(s) b: Builder - builder_init(&b, 0, len(s), allocator) + builder_init(&b, 0, len(s), allocator) or_return w := to_writer(&b) string_case_iterator(w, s, proc(w: io.Writer, prev, curr, next: rune) { @@ -162,17 +279,28 @@ to_camel_case :: proc(s: string, allocator := context.allocator) -> string { } }) - return to_string(b) + return to_string(b), nil } - +// Alias to `to_pascal_case` to_upper_camel_case :: to_pascal_case +/* +Converts the input string `s` to "UpperCamelCase" (PascalCase). -// converts the `s` string to "PascalCase" -to_pascal_case :: proc(s: string, allocator := context.allocator) -> string { +*Allocates Using Provided Allocator* + +Inputs: +- s: Input string to be converted. +- allocator: (default: context.allocator). + +Returns: +- res: The converted string +- err: An optional allocator error if one occured, `nil` otherwise +*/ +to_pascal_case :: proc(s: string, allocator := context.allocator) -> (res: string, err: mem.Allocator_Error) #optional_allocator_error { s := s s = trim_space(s) b: Builder - builder_init(&b, 0, len(s), allocator) + builder_init(&b, 0, len(s), allocator) or_return w := to_writer(&b) string_case_iterator(w, s, proc(w: io.Writer, prev, curr, next: rune) { @@ -187,23 +315,51 @@ to_pascal_case :: proc(s: string, allocator := context.allocator) -> string { } }) - return to_string(b) + return to_string(b), nil } +/* +Returns a string converted to a delimiter-separated case with configurable casing -/* - returns the `s` string to words seperated by the given `delimiter` rune - all runes will be upper or lowercased based on the `all_uppercase` bool +*Allocates Using Provided Allocator* + +Inputs: +- s: The input string to be converted +- delimiter: The rune to be used as the delimiter between words +- all_upper_case: A boolean indicating if the output should be all uppercased (true) or lowercased (false) +- allocator: (default: context.allocator). + +Returns: +- res: The converted string +- err: An optional allocator error if one occured, `nil` otherwise + +Example: + + import "core:fmt" + import "core:strings" + + to_delimiter_case_example :: proc() { + fmt.println(strings.to_delimiter_case("Hello World", '_', false)) + fmt.println(strings.to_delimiter_case("Hello World", ' ', true)) + fmt.println(strings.to_delimiter_case("aBC", '_', false)) + } + +Output: + + hello_world + HELLO WORLD + a_bc - strings.to_delimiter_case("Hello World", '_', false) -> hello_world - strings.to_delimiter_case("Hello World", ' ', true) -> HELLO WORLD - strings.to_delimiter_case("Hello World", ' ', true) -> HELLO WORLD - strings.to_delimiter_case("aBC", '_', false) -> a_b_c */ -to_delimiter_case :: proc(s: string, delimiter: rune, all_upper_case: bool, allocator := context.allocator) -> string { +to_delimiter_case :: proc( + s: string, + delimiter: rune, + all_upper_case: bool, + allocator := context.allocator, +) -> (res: string, err: mem.Allocator_Error) #optional_allocator_error { s := s s = trim_space(s) b: Builder - builder_init(&b, 0, len(s), allocator) + builder_init(&b, 0, len(s), allocator) or_return w := to_writer(&b) adjust_case := unicode.to_upper if all_upper_case else unicode.to_lower @@ -235,75 +391,178 @@ to_delimiter_case :: proc(s: string, delimiter: rune, all_upper_case: bool, allo io.write_rune(w, adjust_case(curr)) } - return to_string(b) + return to_string(b), nil } +/* +Converts a string to "snake_case" with all runes lowercased + +*Allocates Using Provided Allocator* + +Inputs: +- s: The input string to be converted +- allocator: (default: context.allocator). + +Returns: +- res: The converted string +- err: An optional allocator error if one occured, `nil` otherwise + +Example: + + import "core:fmt" + import "core:strings" + + to_snake_case_example :: proc() { + fmt.println(strings.to_snake_case("HelloWorld")) + fmt.println(strings.to_snake_case("Hello World")) + } + +Output: + + hello_world + hello_world -/* - converts the `s` string to "snake_case" with all runes lowercased - - strings.to_snake_case("HelloWorld") -> hello_world - strings.to_snake_case("Hello World") -> hello_world */ -to_snake_case :: proc(s: string, allocator := context.allocator) -> string { +to_snake_case :: proc(s: string, allocator := context.allocator) -> (res: string, err: mem.Allocator_Error) #optional_allocator_error { return to_delimiter_case(s, '_', false, allocator) } - +// Alias for `to_upper_snake_case` to_screaming_snake_case :: to_upper_snake_case +/* +Converts a string to "SNAKE_CASE" with all runes uppercased -// converts the `s` string to "SNAKE_CASE" with all runes uppercased -to_upper_snake_case :: proc(s: string, allocator := context.allocator) -> string { +*Allocates Using Provided Allocator* + +Inputs: +- s: The input string to be converted +- allocator: (default: context.allocator). + +Returns: +- res: The converted string +- err: An optional allocator error if one occured, `nil` otherwise + +Example: + + import "core:fmt" + import "core:strings" + + to_upper_snake_case_example :: proc() { + fmt.println(strings.to_upper_snake_case("HelloWorld")) + } + +Output: + + HELLO_WORLD + +*/ +to_upper_snake_case :: proc(s: string, allocator := context.allocator) -> (res: string, err: mem.Allocator_Error) #optional_allocator_error { return to_delimiter_case(s, '_', true, allocator) } +/* +Converts a string to "kebab-case" with all runes lowercased -// converts the `s` string to "kebab-case" with all runes lowercased -to_kebab_case :: proc(s: string, allocator := context.allocator) -> string { +*Allocates Using Provided Allocator* + +Inputs: +- s: The input string to be converted +- allocator: (default: context.allocator). + +Returns: +- res: The converted string +- err: An optional allocator error if one occured, `nil` otherwise + +Example: + + import "core:fmt" + import "core:strings" + + to_kebab_case_example :: proc() { + fmt.println(strings.to_kebab_case("HelloWorld")) + } + +Output: + + hello-world + +*/ +to_kebab_case :: proc(s: string, allocator := context.allocator) -> (res: string, err: mem.Allocator_Error) #optional_allocator_error { return to_delimiter_case(s, '-', false, allocator) } +/* +Converts a string to "KEBAB-CASE" with all runes uppercased -// converts the `s` string to "KEBAB-CASE" with all runes uppercased -to_upper_kebab_case :: proc(s: string, allocator := context.allocator) -> string { +*Allocates Using Provided Allocator* + +Inputs: +- s: The input string to be converted +- allocator: (default: context.allocator). + +Returns: +- res: The converted string +- err: An optional allocator error if one occured, `nil` otherwise + +Example: + + import "core:fmt" + import "core:strings" + + to_upper_kebab_case_example :: proc() { + fmt.println(strings.to_upper_kebab_case("HelloWorld")) + } + +Output: + + HELLO-WORLD + +*/ +to_upper_kebab_case :: proc(s: string, allocator := context.allocator) -> (res: string, err: mem.Allocator_Error) #optional_allocator_error { return to_delimiter_case(s, '-', true, allocator) } +/* +Converts a string to "Ada_Case" -// converts the `s` string to "Ada_case" -to_ada_case :: proc(s: string, allocator := context.allocator) -> string { - delimiter :: '_' +*Allocates Using Provided Allocator* +Inputs: +- s: The input string to be converted +- allocator: (default: context.allocator). + +Returns: +- res: The converted string +- err: An optional allocator error if one occured, `nil` otherwise + +Example: + + import "core:fmt" + import "core:strings" + + to_ada_case_example :: proc() { + fmt.println(strings.to_ada_case("HelloWorld")) + } + +Output: + + Hello_World + +*/ +to_ada_case :: proc(s: string, allocator := context.allocator) -> (res: string, err: mem.Allocator_Error) #optional_allocator_error { s := s s = trim_space(s) b: Builder - builder_init(&b, 0, len(s), allocator) + builder_init(&b, 0, len(s), allocator) or_return w := to_writer(&b) - prev, curr: rune - - for next in s { - if is_delimiter(curr) { - if !is_delimiter(prev) { - io.write_rune(w, delimiter) + string_case_iterator(w, s, proc(w: io.Writer, prev, curr, next: rune) { + if !is_delimiter(curr) { + if is_delimiter(prev) || prev == 0 || (unicode.is_lower(prev) && unicode.is_upper(curr)) { + if prev != 0 { + io.write_rune(w, '_') + } + io.write_rune(w, unicode.to_upper(curr)) + } else { + io.write_rune(w, unicode.to_lower(curr)) } - } else if unicode.is_upper(curr) { - if unicode.is_lower(prev) || (unicode.is_upper(prev) && unicode.is_lower(next)) { - io.write_rune(w, delimiter) - } - io.write_rune(w, unicode.to_upper(curr)) - } else if curr != 0 { - io.write_rune(w, unicode.to_lower(curr)) } + }) - prev = curr - curr = next - } - - if len(s) > 0 { - if unicode.is_upper(curr) && unicode.is_lower(prev) && prev != 0 { - io.write_rune(w, delimiter) - io.write_rune(w, unicode.to_upper(curr)) - } else { - io.write_rune(w, unicode.to_lower(curr)) - } - } - - return to_string(b) + return to_string(b), nil } - diff --git a/core/strings/intern.odin b/core/strings/intern.odin index 5e9193a0d..73f91d4d4 100644 --- a/core/strings/intern.odin +++ b/core/strings/intern.odin @@ -1,50 +1,108 @@ package strings import "core:runtime" +import "core:mem" -// custom string entry struct +// Custom string entry struct Intern_Entry :: struct { len: int, str: [1]byte, // string is allocated inline with the entry to keep allocations simple } +/* +Intern is a more memory efficient string map -// "intern" is a more memory efficient string map -// `allocator` is used to allocate the actual `Intern_Entry` strings +Uses Specified Allocator for `Intern_Entry` strings + +Fields: +- allocator: The allocator used for the Intern_Entry strings +- entries: A map of strings to interned string entries +*/ Intern :: struct { allocator: runtime.Allocator, entries: map[string]^Intern_Entry, } +/* +Initializes the entries map and sets the allocator for the string entries -// initialize the entries map and set the allocator for the string entries -intern_init :: proc(m: ^Intern, allocator := context.allocator, map_allocator := context.allocator) { +*Allocates Using Provided Allocators* + +Inputs: +- m: A pointer to the Intern struct to be initialized +- allocator: The allocator for the Intern_Entry strings (Default: context.allocator) +- map_allocator: The allocator for the map of entries (Default: context.allocator) + +Returns: +- err: An allocator error if one occured, `nil` otherwise +*/ +intern_init :: proc(m: ^Intern, allocator := context.allocator, map_allocator := context.allocator) -> (err: mem.Allocator_Error) { m.allocator = allocator - m.entries = make(map[string]^Intern_Entry, 16, map_allocator) + m.entries = make(map[string]^Intern_Entry, 16, map_allocator) or_return + return nil } +/* +Frees the map and all its content allocated using the `.allocator`. -// free the map and all its content allocated using the `.allocator` +Inputs: +- m: A pointer to the Intern struct to be destroyed +*/ intern_destroy :: proc(m: ^Intern) { for _, value in m.entries { free(value, m.allocator) } delete(m.entries) } +/* +Returns an interned copy of the given text, adding it to the map if not already present. -// returns the `text` string from the intern map - gets set if it didnt exist yet -// the returned string lives as long as the map entry lives +*Allocate using the Intern's Allocator (First time string is seen only)* + +Inputs: +- m: A pointer to the Intern struct +- text: The string to be interned + +NOTE: The returned string lives as long as the map entry lives. + +Returns: +- str: The interned string +- err: An allocator error if one occured, `nil` otherwise +*/ intern_get :: proc(m: ^Intern, text: string) -> (str: string, err: runtime.Allocator_Error) { entry := _intern_get_entry(m, text) or_return #no_bounds_check return string(entry.str[:entry.len]), nil } +/* +Returns an interned copy of the given text as a cstring, adding it to the map if not already present. -// returns the `text` cstring from the intern map - gets set if it didnt exist yet -// the returned cstring lives as long as the map entry lives +*Allocate using the Intern's Allocator (First time string is seen only)* + +Inputs: +- m: A pointer to the Intern struct +- text: The string to be interned + +NOTE: The returned cstring lives as long as the map entry lives + +Returns: +- str: The interned cstring +- err: An allocator error if one occured, `nil` otherwise +*/ intern_get_cstring :: proc(m: ^Intern, text: string) -> (str: cstring, err: runtime.Allocator_Error) { entry := _intern_get_entry(m, text) or_return return cstring(&entry.str[0]), nil } +/* +Internal function to lookup whether the text string exists in the map, returns the entry +Sets and allocates the entry if it wasn't set yet -// looks up wether the `text` string exists in the map, returns the entry -// sets & allocates the entry if it wasnt set yet +*Allocate using the Intern's Allocator (First time string is seen only)* + +Inputs: +- m: A pointer to the Intern struct +- text: The string to be looked up or interned + +Returns: +- new_entry: The interned cstring +- err: An allocator error if one occured, `nil` otherwise +*/ _intern_get_entry :: proc(m: ^Intern, text: string) -> (new_entry: ^Intern_Entry, err: runtime.Allocator_Error) #no_bounds_check { if prev, ok := m.entries[text]; ok { return prev, nil diff --git a/core/strings/reader.odin b/core/strings/reader.odin index 038740526..bb49bf917 100644 --- a/core/strings/reader.odin +++ b/core/strings/reader.odin @@ -4,59 +4,109 @@ import "core:io" import "core:unicode/utf8" /* - io stream data for a string reader that can read based on bytes or runes - implements the vtable when using the io.Reader variants - "read" calls advance the current reading offset `i` +io stream data for a string reader that can read based on bytes or runes +implements the vtable when using the `io.Reader` variants +"read" calls advance the current reading offset `i` */ Reader :: struct { s: string, // read-only buffer i: i64, // current reading index prev_rune: int, // previous reading index of rune or < 0 } +/* +Initializes a string Reader with the provided string -// init the reader to the string `s` +Inputs: +- r: A pointer to a Reader struct +- s: The input string to be read +*/ reader_init :: proc(r: ^Reader, s: string) { r.s = s r.i = 0 r.prev_rune = -1 } +/* +Converts a Reader into an `io.Stream` -// returns a stream from the reader data +Inputs: +- r: A pointer to a Reader struct + +Returns: +- s: An io.Stream for the given Reader +*/ reader_to_stream :: proc(r: ^Reader) -> (s: io.Stream) { - s.stream_data = r - s.stream_vtable = &_reader_vtable + s.data = r + s.procedure = _reader_proc return } +/* +Initializes a string Reader and returns an `io.Reader` for the given string -// init a reader to the string `s` and return an io.Reader -to_reader :: proc(r: ^Reader, s: string) -> io.Reader { +Inputs: +- r: A pointer to a Reader struct +- s: The input string to be read + +Returns: +- res: An io.Reader for the given string +*/ +to_reader :: proc(r: ^Reader, s: string) -> (res: io.Reader) { reader_init(r, s) rr, _ := io.to_reader(reader_to_stream(r)) return rr } +/* +Initializes a string Reader and returns an `io.Reader_At` for the given string -// init a reader to the string `s` and return an io.Reader_At -to_reader_at :: proc(r: ^Reader, s: string) -> io.Reader_At { +Inputs: +- r: A pointer to a Reader struct +- s: The input string to be read + +Returns: +- res: An `io.Reader_At` for the given string +*/ +to_reader_at :: proc(r: ^Reader, s: string) -> (res: io.Reader_At) { reader_init(r, s) rr, _ := io.to_reader_at(reader_to_stream(r)) return rr } +/* +Returns the remaining length of the Reader -// remaining length of the reader -reader_length :: proc(r: ^Reader) -> int { +Inputs: +- r: A pointer to a Reader struct + +Returns: +- res: The remaining length of the Reader +*/ +reader_length :: proc(r: ^Reader) -> (res: int) { if r.i >= i64(len(r.s)) { return 0 } return int(i64(len(r.s)) - r.i) } +/* +Returns the length of the string stored in the Reader -// returns the string length stored by the reader -reader_size :: proc(r: ^Reader) -> i64 { +Inputs: +- r: A pointer to a Reader struct + +Returns: +- res: The length of the string stored in the Reader +*/ +reader_size :: proc(r: ^Reader) -> (res: i64) { return i64(len(r.s)) } +/* +Reads len(p) bytes from the Reader's string and copies into the provided slice. -// reads len(p) bytes into the slice from the string in the reader -// returns `n` amount of read bytes and an io.Error +Inputs: +- r: A pointer to a Reader struct +- p: A byte slice to copy data into + +Returns: +- n: The number of bytes read +- err: An `io.Error` if an error occurs while reading, including `.EOF`, otherwise `nil` denotes success. +*/ reader_read :: proc(r: ^Reader, p: []byte) -> (n: int, err: io.Error) { if r.i >= i64(len(r.s)) { return 0, .EOF @@ -66,9 +116,18 @@ reader_read :: proc(r: ^Reader, p: []byte) -> (n: int, err: io.Error) { r.i += i64(n) return } +/* +Reads len(p) bytes from the Reader's string and copies into the provided slice, at the specified offset from the current index. -// reads len(p) bytes into the slice from the string in the reader at an offset -// returns `n` amount of read bytes and an io.Error +Inputs: +- r: A pointer to a Reader struct +- p: A byte slice to copy data into +- off: The offset from which to read + +Returns: +- n: The number of bytes read +- err: An `io.Error` if an error occurs while reading, including `.EOF`, otherwise `nil` denotes success. +*/ reader_read_at :: proc(r: ^Reader, p: []byte, off: i64) -> (n: int, err: io.Error) { if off < 0 { return 0, .Invalid_Offset @@ -82,9 +141,17 @@ reader_read_at :: proc(r: ^Reader, p: []byte, off: i64) -> (n: int, err: io.Erro } return } +/* +Reads and returns a single byte from the Reader's string -// reads and returns a single byte - error when out of bounds -reader_read_byte :: proc(r: ^Reader) -> (byte, io.Error) { +Inputs: +- r: A pointer to a Reader struct + +Returns: +- The byte read from the Reader +- err: An `io.Error` if an error occurs while reading, including `.EOF`, otherwise `nil` denotes success. +*/ +reader_read_byte :: proc(r: ^Reader) -> (res: byte, err: io.Error) { r.prev_rune = -1 if r.i >= i64(len(r.s)) { return 0, .EOF @@ -93,9 +160,16 @@ reader_read_byte :: proc(r: ^Reader) -> (byte, io.Error) { r.i += 1 return b, nil } +/* +Decrements the Reader's index (i) by 1 -// decreases the reader offset - error when below 0 -reader_unread_byte :: proc(r: ^Reader) -> io.Error { +Inputs: +- r: A pointer to a Reader struct + +Returns: +- err: An `io.Error` if `r.i <= 0` (`.Invalid_Unread`), otherwise `nil` denotes success. +*/ +reader_unread_byte :: proc(r: ^Reader) -> (err: io.Error) { if r.i <= 0 { return .Invalid_Unread } @@ -103,9 +177,18 @@ reader_unread_byte :: proc(r: ^Reader) -> io.Error { r.i -= 1 return nil } +/* +Reads and returns a single rune and its `size` from the Reader's string -// reads and returns a single rune and the rune size - error when out bounds -reader_read_rune :: proc(r: ^Reader) -> (ch: rune, size: int, err: io.Error) { +Inputs: +- r: A pointer to a Reader struct + +Returns: +- rr: The rune read from the Reader +- size: The size of the rune in bytes +- err: An `io.Error` if an error occurs while reading +*/ +reader_read_rune :: proc(r: ^Reader) -> (rr: rune, size: int, err: io.Error) { if r.i >= i64(len(r.s)) { r.prev_rune = -1 return 0, 0, .EOF @@ -115,14 +198,22 @@ reader_read_rune :: proc(r: ^Reader) -> (ch: rune, size: int, err: io.Error) { r.i += 1 return rune(c), 1, nil } - ch, size = utf8.decode_rune_in_string(r.s[r.i:]) + rr, size = utf8.decode_rune_in_string(r.s[r.i:]) r.i += i64(size) return } +/* +Decrements the Reader's index (i) by the size of the last read rune -// decreases the reader offset by the last rune -// can only be used once and after a valid read_rune call -reader_unread_rune :: proc(r: ^Reader) -> io.Error { +Inputs: +- r: A pointer to a Reader struct + +WARNING: May only be used once and after a valid `read_rune` call + +Returns: +- err: An `io.Error` if an error occurs while unreading (`.Invalid_Unread`), else `nil` denotes success. +*/ +reader_unread_rune :: proc(r: ^Reader) -> (err: io.Error) { if r.i <= 0 { return .Invalid_Unread } @@ -133,9 +224,19 @@ reader_unread_rune :: proc(r: ^Reader) -> io.Error { r.prev_rune = -1 return nil } +/* +Seeks the Reader's index to a new position -// seeks the reader offset to a wanted offset -reader_seek :: proc(r: ^Reader, offset: i64, whence: io.Seek_From) -> (i64, io.Error) { +Inputs: +- r: A pointer to a Reader struct +- offset: The new offset position +- whence: The reference point for the new position (`.Start`, `.Current`, or `.End`) + +Returns: +- The absolute offset after seeking +- err: An `io.Error` if an error occurs while seeking (`.Invalid_Whence`, `.Invalid_Offset`) +*/ +reader_seek :: proc(r: ^Reader, offset: i64, whence: io.Seek_From) -> (res: i64, err: io.Error) { r.prev_rune = -1 abs: i64 switch whence { @@ -155,8 +256,19 @@ reader_seek :: proc(r: ^Reader, offset: i64, whence: io.Seek_From) -> (i64, io.E r.i = abs return abs, nil } +/* +Writes the remaining content of the Reader's string into the provided `io.Writer` -// writes the string content left to read into the io.Writer `w` +Inputs: +- r: A pointer to a Reader struct +- w: The io.Writer to write the remaining content into + +WARNING: Panics if writer writes more bytes than remainig length of string. + +Returns: +- n: The number of bytes written +- err: An io.Error if an error occurs while writing (`.Short_Write`) +*/ reader_write_to :: proc(r: ^Reader, w: io.Writer) -> (n: i64, err: io.Error) { r.prev_rune = -1 if r.i >= i64(len(r.s)) { @@ -175,43 +287,28 @@ reader_write_to :: proc(r: ^Reader, w: io.Writer) -> (n: i64, err: io.Error) { } return } +/* +VTable containing implementations for various `io.Stream` methods +This VTable is used by the Reader struct to provide its functionality +as an `io.Stream`. +*/ @(private) -_reader_vtable := io.Stream_VTable{ - impl_size = proc(s: io.Stream) -> i64 { - r := (^Reader)(s.stream_data) - return reader_size(r) - }, - impl_read = proc(s: io.Stream, p: []byte) -> (n: int, err: io.Error) { - r := (^Reader)(s.stream_data) - return reader_read(r, p) - }, - impl_read_at = proc(s: io.Stream, p: []byte, off: i64) -> (n: int, err: io.Error) { - r := (^Reader)(s.stream_data) - return reader_read_at(r, p, off) - }, - impl_read_byte = proc(s: io.Stream) -> (byte, io.Error) { - r := (^Reader)(s.stream_data) - return reader_read_byte(r) - }, - impl_unread_byte = proc(s: io.Stream) -> io.Error { - r := (^Reader)(s.stream_data) - return reader_unread_byte(r) - }, - impl_read_rune = proc(s: io.Stream) -> (ch: rune, size: int, err: io.Error) { - r := (^Reader)(s.stream_data) - return reader_read_rune(r) - }, - impl_unread_rune = proc(s: io.Stream) -> io.Error { - r := (^Reader)(s.stream_data) - return reader_unread_rune(r) - }, - impl_seek = proc(s: io.Stream, offset: i64, whence: io.Seek_From) -> (i64, io.Error) { - r := (^Reader)(s.stream_data) - return reader_seek(r, offset, whence) - }, - impl_write_to = proc(s: io.Stream, w: io.Writer) -> (n: i64, err: io.Error) { - r := (^Reader)(s.stream_data) - return reader_write_to(r, w) - }, +_reader_proc :: proc(stream_data: rawptr, mode: io.Stream_Mode, p: []byte, offset: i64, whence: io.Seek_From) -> (n: i64, err: io.Error) { + r := (^Reader)(stream_data) + #partial switch mode { + case .Size: + n = reader_size(r) + return + case .Read: + return io._i64_err(reader_read(r, p)) + case .Read_At: + return io._i64_err(reader_read_at(r, p, offset)) + case .Seek: + n, err = reader_seek(r, offset, whence) + return + case .Query: + return io.query_utility({.Size, .Read, .Read_At, .Seek, .Query}) + } + return 0, .Empty } diff --git a/core/strings/strings.odin b/core/strings/strings.odin index ba357e027..6daa5f9c9 100644 --- a/core/strings/strings.odin +++ b/core/strings/strings.odin @@ -1,178 +1,409 @@ -// simple procedures to manipulate UTF-8 encoded strings +// Procedures to manipulate UTF-8 encoded strings package strings import "core:io" import "core:mem" -import "core:slice" import "core:unicode" import "core:unicode/utf8" -// returns a clone of the string `s` allocated using the `allocator` -clone :: proc(s: string, allocator := context.allocator, loc := #caller_location) -> string { - c := make([]byte, len(s), allocator, loc) - copy(c, s) - return string(c[:len(s)]) -} +/* +Clones a string -// returns a clone of the string `s` allocated using the `allocator` -clone_safe :: proc(s: string, allocator := context.allocator, loc := #caller_location) -> (str: string, err: mem.Allocator_Error) { +*Allocates Using Provided Allocator* + +Inputs: +- s: The string to be cloned +- allocator: (default: context.allocator) +- loc: The caller location for debugging purposes (default: #caller_location) + +Returns: +- res: The cloned string +- err: An optional allocator error if one occured, `nil` otherwise +*/ +clone :: proc(s: string, allocator := context.allocator, loc := #caller_location) -> (res: string, err: mem.Allocator_Error) #optional_allocator_error { c := make([]byte, len(s), allocator, loc) or_return copy(c, s) return string(c[:len(s)]), nil } +/* +Clones a string safely (returns early with an allocation error on failure) -// returns a clone of the string `s` allocated using the `allocator` as a cstring -// a nul byte is appended to the clone, to make the cstring safe -clone_to_cstring :: proc(s: string, allocator := context.allocator, loc := #caller_location) -> cstring { - c := make([]byte, len(s)+1, allocator, loc) +*Allocates Using Provided Allocator* + +Inputs: +- s: The string to be cloned +- allocator: (default: context.allocator) +- loc: The caller location for debugging purposes (default: #caller_location) + +Returns: +- res: The cloned string +- err: An allocator error if one occured, `nil` otherwise +*/ +@(deprecated="Prefer clone. It now returns an optional allocator error") +clone_safe :: proc(s: string, allocator := context.allocator, loc := #caller_location) -> (res: string, err: mem.Allocator_Error) { + return clone(s, allocator, loc) +} +/* +Clones a string and appends a null-byte to make it a cstring + +*Allocates Using Provided Allocator* + +Inputs: +- s: The string to be cloned +- allocator: (default: context.allocator) +- loc: The caller location for debugging purposes (default: #caller_location) + +Returns: +- res: A cloned cstring with an appended null-byte +- err: An optional allocator error if one occured, `nil` otherwise +*/ +clone_to_cstring :: proc(s: string, allocator := context.allocator, loc := #caller_location) -> (res: cstring, err: mem.Allocator_Error) #optional_allocator_error { + c := make([]byte, len(s)+1, allocator, loc) or_return copy(c, s) c[len(s)] = 0 - return cstring(&c[0]) + return cstring(&c[0]), nil } +/* +Transmutes a raw pointer into a string. Non-allocating. -// returns a string from a byte pointer `ptr` and byte length `len` -// the string is valid as long as the parameters stay alive -string_from_ptr :: proc(ptr: ^byte, len: int) -> string { +Inputs: +- ptr: A pointer to the start of the byte sequence +- len: The length of the byte sequence + +NOTE: The created string is only valid as long as the pointer and length are valid. + +Returns: +- res: A string created from the byte pointer and length +*/ +string_from_ptr :: proc(ptr: ^byte, len: int) -> (res: string) { return transmute(string)mem.Raw_String{ptr, len} } +/* +Transmutes a raw pointer (null-terminated) into a string. Non-allocating. Searches for a null-byte from `0.. string { +NOTE: The created string is only valid as long as the pointer and length are valid. + The string is truncated at the first null-byte encountered. + +Inputs: +- ptr: A pointer to the start of the null-terminated byte sequence +- len: The length of the byte sequence + +Returns: +- res: A string created from the null-terminated byte pointer and length +*/ +string_from_null_terminated_ptr :: proc(ptr: ^byte, len: int) -> (res: string) { s := transmute(string)mem.Raw_String{ptr, len} s = truncate_to_byte(s, 0) return s } +/* +Gets the raw byte pointer for the start of a string `str` -// returns the raw ^byte start of the string `str` -ptr_from_string :: proc(str: string) -> ^byte { +Inputs: +- str: The input string + +Returns: +- res: A pointer to the start of the string's bytes +*/ +@(deprecated="Prefer the builtin raw_data.") +ptr_from_string :: proc(str: string) -> (res: ^byte) { d := transmute(mem.Raw_String)str return d.data } +/* +Converts a string `str` to a cstring -// returns the transmute of string `str` to a cstring -// not safe since the origin string may not contain a nul byte -unsafe_string_to_cstring :: proc(str: string) -> cstring { +Inputs: +- str: The input string + +WARNING: This is unsafe because the original string may not contain a null-byte. + +Returns: +- res: The converted cstring +*/ +unsafe_string_to_cstring :: proc(str: string) -> (res: cstring) { d := transmute(mem.Raw_String)str return cstring(d.data) } +/* +Truncates a string `str` at the first occurrence of char/byte `b` -// returns a string truncated to the first time it finds the byte `b` -// uses the `len` of the string `str` when it couldn't find the input -truncate_to_byte :: proc(str: string, b: byte) -> string { +Inputs: +- str: The input string +- b: The byte to truncate the string at + +NOTE: Failure to find the byte results in returning the entire string. + +Returns: +- res: The truncated string +*/ +truncate_to_byte :: proc(str: string, b: byte) -> (res: string) { n := index_byte(str, b) if n < 0 { n = len(str) } return str[:n] } +/* +Truncates a string `str` at the first occurrence of rune `r` as a slice of the original, entire string if not found -// returns a string truncated to the first time it finds the rune `r` -// uses the `len` of the string `str` when it couldn't find the input -truncate_to_rune :: proc(str: string, r: rune) -> string { +Inputs: +- str: The input string +- r: The rune to truncate the string at + +Returns: +- res: The truncated string +*/ +truncate_to_rune :: proc(str: string, r: rune) -> (res: string) { n := index_rune(str, r) if n < 0 { n = len(str) } return str[:n] } +/* +Clones a byte array `s` and appends a null-byte -// returns a cloned string of the byte array `s` using the `allocator` -// appends a leading nul byte -clone_from_bytes :: proc(s: []byte, allocator := context.allocator, loc := #caller_location) -> string { - c := make([]byte, len(s)+1, allocator, loc) +*Allocates Using Provided Allocator* + +Inputs: +- s: The byte array to be cloned +- allocator: (default: context.allocator) +- loc: The caller location for debugging purposes (default: `#caller_location`) + +Returns: +- res: The cloned string from the byte array with a null-byte +- err: An optional allocator error if one occured, `nil` otherwise +*/ +clone_from_bytes :: proc(s: []byte, allocator := context.allocator, loc := #caller_location) -> (res: string, err: mem.Allocator_Error) #optional_allocator_error { + c := make([]byte, len(s)+1, allocator, loc) or_return copy(c, s) c[len(s)] = 0 - return string(c[:len(s)]) + return string(c[:len(s)]), nil } +/* +Clones a cstring `s` as a string -// returns a clone of the cstring `s` using the `allocator` as a string -clone_from_cstring :: proc(s: cstring, allocator := context.allocator, loc := #caller_location) -> string { +*Allocates Using Provided Allocator* + +Inputs: +- s: The cstring to be cloned +- allocator: (default: context.allocator) +- loc: The caller location for debugging purposes (default: `#caller_location`) + +Returns: +- res: The cloned string from the cstring +- err: An optional allocator error if one occured, `nil` otherwise +*/ +clone_from_cstring :: proc(s: cstring, allocator := context.allocator, loc := #caller_location) -> (res: string, err: mem.Allocator_Error) #optional_allocator_error { return clone(string(s), allocator, loc) } +/* +Clones a string from a byte pointer `ptr` and a byte length `len` -// returns a cloned string from the pointer `ptr` and a byte length `len` using the `allocator` -// same to `string_from_ptr` but allocates -clone_from_ptr :: proc(ptr: ^byte, len: int, allocator := context.allocator, loc := #caller_location) -> string { +*Allocates Using Provided Allocator* + +Inputs: +- ptr: A pointer to the start of the byte sequence +- len: The length of the byte sequence +- allocator: (default: context.allocator) +- loc: The caller location for debugging purposes (default: `#caller_location`) + +NOTE: Same as `string_from_ptr`, but perform an additional `clone` operation + +Returns: +- res: The cloned string from the byte pointer and length +- err: An optional allocator error if one occured, `nil` otherwise +*/ +clone_from_ptr :: proc(ptr: ^byte, len: int, allocator := context.allocator, loc := #caller_location) -> (res: string, err: mem.Allocator_Error) #optional_allocator_error { s := string_from_ptr(ptr, len) return clone(s, allocator, loc) } - -// overload to clone from a `string`, `[]byte`, `cstring` or a `^byte + length` to a string +// Overloaded procedure to clone from a string, `[]byte`, `cstring` or a `^byte` + length clone_from :: proc{ clone, clone_from_bytes, clone_from_cstring, clone_from_ptr, } +/* +Clones a string from a null-terminated cstring `ptr` and a byte length `len` -// returns a cloned string from the cstring `ptr` and a byte length `len` using the `allocator` -// truncates till the first nul byte it finds or the byte len -clone_from_cstring_bounded :: proc(ptr: cstring, len: int, allocator := context.allocator, loc := #caller_location) -> string { +*Allocates Using Provided Allocator* + +Inputs: +- ptr: A pointer to the start of the null-terminated cstring +- len: The byte length of the cstring +- allocator: (default: context.allocator) +- loc: The caller location for debugging purposes (default: `#caller_location`) + +NOTE: Truncates at the first null-byte encountered or the byte length. + +Returns: +- res: The cloned string from the null-terminated cstring and byte length +- err: An optional allocator error if one occured, `nil` otherwise +*/ +clone_from_cstring_bounded :: proc(ptr: cstring, len: int, allocator := context.allocator, loc := #caller_location) -> (res: string, err: mem.Allocator_Error) #optional_allocator_error { s := string_from_ptr((^u8)(ptr), len) s = truncate_to_byte(s, 0) return clone(s, allocator, loc) } +/* +Compares two strings, returning a value representing which one comes first lexicographically. +-1 for `lhs`; 1 for `rhs`, or 0 if they are equal. -// Compares two strings, returning a value representing which one comes first lexiographically. -// -1 for `lhs`; 1 for `rhs`, or 0 if they are equal. -compare :: proc(lhs, rhs: string) -> int { +Inputs: +- lhs: First string for comparison +- rhs: Second string for comparison + +Returns: +- result: `-1` if `lhs` comes first, `1` if `rhs` comes first, or `0` if they are equal +*/ +compare :: proc(lhs, rhs: string) -> (result: int) { return mem.compare(transmute([]byte)lhs, transmute([]byte)rhs) } +/* +Checks if rune `r` in the string `s` -// returns the byte offset of the rune `r` in the string `s`, -1 when not found -contains_rune :: proc(s: string, r: rune) -> int { - for c, offset in s { +Inputs: +- s: The input string +- r: The rune to search for + +Returns: +- result: `true` if the rune `r` in the string `s`, `false` otherwise +*/ +contains_rune :: proc(s: string, r: rune) -> (result: bool) { + for c in s { if c == r { - return offset + return true } } - return -1 + return false } - /* - returns true when the string `substr` is contained inside the string `s` +Returns true when the string `substr` is contained inside the string `s` + +Inputs: +- s: The input string +- substr: The substring to search for + +Returns: +- res: `true` if `substr` is contained inside the string `s`, `false` otherwise + +Example: + + import "core:fmt" + import "core:strings" + + contains_example :: proc() { + fmt.println(strings.contains("testing", "test")) + fmt.println(strings.contains("testing", "ing")) + fmt.println(strings.contains("testing", "text")) + } + +Output: + + true + true + false - strings.contains("testing", "test") -> true - strings.contains("testing", "ing") -> true - strings.contains("testing", "text") -> false */ -contains :: proc(s, substr: string) -> bool { +contains :: proc(s, substr: string) -> (res: bool) { return index(s, substr) >= 0 } - /* - returns true when the string `s` contains any of the characters inside the string `chars` - - strings.contains_any("test", "test") -> true - strings.contains_any("test", "ts") -> true - strings.contains_any("test", "et") -> true - strings.contains_any("test", "a") -> false +Returns `true` when the string `s` contains any of the characters inside the string `chars` + +Inputs: +- s: The input string +- chars: The characters to search for + +Returns: +- res: `true` if the string `s` contains any of the characters in `chars`, `false` otherwise + +Example: + + import "core:fmt" + import "core:strings" + + contains_any_example :: proc() { + fmt.println(strings.contains_any("test", "test")) + fmt.println(strings.contains_any("test", "ts")) + fmt.println(strings.contains_any("test", "et")) + fmt.println(strings.contains_any("test", "a")) + } + +Output: + + true + true + true + false + */ -contains_any :: proc(s, chars: string) -> bool { +contains_any :: proc(s, chars: string) -> (res: bool) { return index_any(s, chars) >= 0 } - /* - returns the utf8 rune count of the string `s` +Returns the UTF-8 rune count of the string `s` + +Inputs: +- s: The input string + +Returns: +- res: The UTF-8 rune count of the string `s` + +Example: + + import "core:fmt" + import "core:strings" + + rune_count_example :: proc() { + fmt.println(strings.rune_count("test")) + fmt.println(strings.rune_count("testƶ")) // where len("testƶ") == 6 + } + +Output: + + 4 + 5 - strings.rune_count("test") -> 4 - strings.rune_count("testƶ") -> 5, where len("testƶ") -> 6 */ -rune_count :: proc(s: string) -> int { +rune_count :: proc(s: string) -> (res: int) { return utf8.rune_count_in_string(s) } - /* - returns wether the strings `u` and `v` are the same alpha characters - works with utf8 string content and ignores different casings +Returns whether the strings `u` and `v` are the same alpha characters, ignoring different casings +Works with UTF-8 string content + +Inputs: +- u: The first string for comparison +- v: The second string for comparison + +Returns: +- res: `true` if the strings `u` and `v` are the same alpha characters (ignoring case) + +Example: + + import "core:fmt" + import "core:strings" + + equal_fold_example :: proc() { + fmt.println(strings.equal_fold("test", "test")) + fmt.println(strings.equal_fold("Test", "test")) + fmt.println(strings.equal_fold("Test", "tEsT")) + fmt.println(strings.equal_fold("test", "tes")) + } + +Output: + + true + true + true + false - strings.equal_fold("test", "test") -> true - strings.equal_fold("Test", "test") -> true - strings.equal_fold("Test", "tEsT") -> true - strings.equal_fold("test", "tes") -> false */ -equal_fold :: proc(u, v: string) -> bool { +equal_fold :: proc(u, v: string) -> (res: bool) { s, t := u, v loop: for s != "" && t != "" { sr, tr: rune @@ -214,14 +445,35 @@ equal_fold :: proc(u, v: string) -> bool { return s == t } - /* - return the prefix length common between strings `a` and `b`. +Returns the prefix length common between strings `a` and `b` + +Inputs: +- a: The first input string +- b: The second input string + +Returns: +- n: The prefix length common between strings `a` and `b` + +Example: + + import "core:fmt" + import "core:strings" + + prefix_length_example :: proc() { + fmt.println(strings.prefix_length("testing", "test")) + fmt.println(strings.prefix_length("testing", "te")) + fmt.println(strings.prefix_length("telephone", "te")) + fmt.println(strings.prefix_length("testing", "est")) + } + +Output: + + 4 + 2 + 2 + 0 - strings.prefix_length("testing", "test") -> 4 - strings.prefix_length("testing", "te") -> 2 - strings.prefix_length("telephone", "te") -> 2 - strings.prefix_length("testing", "est") -> 0 */ prefix_length :: proc(a, b: string) -> (n: int) { _len := min(len(a), len(b)) @@ -246,60 +498,104 @@ prefix_length :: proc(a, b: string) -> (n: int) { } return } - /* - return true when the string `prefix` is contained at the start of the string `s` +Determines if a string `s` starts with a given `prefix` + +Inputs: +- s: The string to check for the `prefix` +- prefix: The prefix to look for + +Returns: +- result: `true` if the string `s` starts with the `prefix`, otherwise `false` + +Example: + + import "core:fmt" + import "core:strings" + + has_prefix_example :: proc() { + fmt.println(strings.has_prefix("testing", "test")) + fmt.println(strings.has_prefix("testing", "te")) + fmt.println(strings.has_prefix("telephone", "te")) + fmt.println(strings.has_prefix("testing", "est")) + } + +Output: + + true + true + true + false - strings.has_prefix("testing", "test") -> true - strings.has_prefix("testing", "te") -> true - strings.has_prefix("telephone", "te") -> true - strings.has_prefix("testing", "est") -> false */ -has_prefix :: proc(s, prefix: string) -> bool { +has_prefix :: proc(s, prefix: string) -> (result: bool) { return len(s) >= len(prefix) && s[0:len(prefix)] == prefix } - /* - returns true when the string `suffix` is contained at the end of the string `s` - good example to use this is for file extensions +Determines if a string `s` ends with a given `suffix` + +Inputs: +- s: The string to check for the `suffix` +- suffix: The suffix to look for + +Returns: +- result: `true` if the string `s` ends with the `suffix`, otherwise `false` + +Example: + + import "core:fmt" + import "core:strings" + + has_suffix_example :: proc() { + fmt.println(strings.has_suffix("todo.txt", ".txt")) + fmt.println(strings.has_suffix("todo.doc", ".txt")) + fmt.println(strings.has_suffix("todo.doc.txt", ".txt")) + } + +Output: + + true + false + true - strings.has_suffix("todo.txt", ".txt") -> true - strings.has_suffix("todo.doc", ".txt") -> false - strings.has_suffix("todo.doc.txt", ".txt") -> true */ -has_suffix :: proc(s, suffix: string) -> bool { +has_suffix :: proc(s, suffix: string) -> (result: bool) { return len(s) >= len(suffix) && s[len(s)-len(suffix):] == suffix } - /* - returns a combined string from the slice of strings `a` seperated with the `sep` string - allocates the string using the `allocator` +Joins a slice of strings `a` with a `sep` string + +*Allocates Using Provided Allocator* + +Inputs: +- a: A slice of strings to join +- sep: The separator string +- allocator: (default is context.allocator) + +Returns: +- res: A combined string from the slice of strings `a` separated with the `sep` string +- err: An optional allocator error if one occured, `nil` otherwise + +Example: + + import "core:fmt" + import "core:strings" + + join_example :: proc() { + a := [?]string { "a", "b", "c" } + fmt.println(strings.join(a[:], " ")) + fmt.println(strings.join(a[:], "-")) + fmt.println(strings.join(a[:], "...")) + } + +Output: + + a b c + a-b-c + a...b...c - a := [?]string { "a", "b", "c" } - b := strings.join(a[:], " ") -> "a b c" - c := strings.join(a[:], "-") -> "a-b-c" - d := strings.join(a[:], "...") -> "a...b...c" */ -join :: proc(a: []string, sep: string, allocator := context.allocator) -> string { - if len(a) == 0 { - return "" - } - - n := len(sep) * (len(a) - 1) - for s in a { - n += len(s) - } - - b := make([]byte, n, allocator) - i := copy(b, a[0]) - for s in a[1:] { - i += copy(b[i:], sep) - i += copy(b[i:], s) - } - return string(b) -} - -join_safe :: proc(a: []string, sep: string, allocator := context.allocator) -> (str: string, err: mem.Allocator_Error) { +join :: proc(a: []string, sep: string, allocator := context.allocator) -> (res: string, err: mem.Allocator_Error) #optional_allocator_error { if len(a) == 0 { return "", nil } @@ -317,58 +613,118 @@ join_safe :: proc(a: []string, sep: string, allocator := context.allocator) -> ( } return string(b), nil } - /* - returns a combined string from the slice of strings `a` without a seperator - allocates the string using the `allocator` - +Joins a slice of strings `a` with a `sep` string, returns an error on allocation failure - a := [?]string { "a", "b", "c" } - b := strings.concatenate(a[:]) -> "abc" +*Allocates Using Provided Allocator* + +Inputs: +- a: A slice of strings to join +- sep: The separator string +- allocator: (default is context.allocator) + +Returns: +- str: A combined string from the slice of strings `a` separated with the `sep` string +- err: An allocator error if one occured, `nil` otherwise */ -concatenate :: proc(a: []string, allocator := context.allocator) -> string { +@(deprecated="Prefer join. It now returns an optional allocator error") +join_safe :: proc(a: []string, sep: string, allocator := context.allocator) -> (res: string, err: mem.Allocator_Error) { + return join(a, sep, allocator) +} +/* +Returns a combined string from the slice of strings `a` without a separator + +*Allocates Using Provided Allocator* + +Inputs: +- a: A slice of strings to concatenate +- allocator: (default is context.allocator) + +Returns: +- res: The concatenated string +- err: An optional allocator error if one occured, `nil` otherwise + +Example: + + import "core:fmt" + import "core:strings" + + concatenate_example :: proc() { + a := [?]string { "a", "b", "c" } + fmt.println(strings.concatenate(a[:])) + } + +Output: + + abc + +*/ +concatenate :: proc(a: []string, allocator := context.allocator) -> (res: string, err: mem.Allocator_Error) #optional_allocator_error { if len(a) == 0 { - return "" + return "", nil } n := 0 for s in a { n += len(s) } - b := make([]byte, n, allocator) + b := make([]byte, n, allocator) or_return i := 0 for s in a { i += copy(b[i:], s) } - return string(b) + return string(b), nil } +/* +Returns a combined string from the slice of strings `a` without a separator, or an error if allocation fails +*Allocates Using Provided Allocator* + +Inputs: +- a: A slice of strings to concatenate +- allocator: (default is context.allocator) + +Returns: +The concatenated string, and an error if allocation fails +*/ +@(deprecated="Prefer concatenate. It now returns an optional allocator error") concatenate_safe :: proc(a: []string, allocator := context.allocator) -> (res: string, err: mem.Allocator_Error) { - if len(a) == 0 { - return "", nil - } - - n := 0 - for s in a { - n += len(s) - } - b := make([]byte, n, allocator) or_return - i := 0 - for s in a { - i += copy(b[i:], s) - } - return string(b), nil + return concatenate(a, allocator) } - /* - `rune_offset` and `rune_length` are in runes, not bytes. - If `rune_length` <= 0, then it'll return the remainder of the string starting at `rune_offset`. +Returns a substring of the input string `s` with the specified rune offset and length + +*Allocates Using Provided Allocator* + +Inputs: +- s: The input string to cut +- rune_offset: The starting rune index (default is 0). In runes, not bytes. +- rune_length: The number of runes to include in the substring (default is 0, which returns the remainder of the string). In runes, not bytes. +- allocator: (default is context.allocator) + +Returns: +- res: The substring +- err: An optional allocator error if one occured, `nil` otherwise + +Example: + + import "core:fmt" + import "core:strings" + + cut_example :: proc() { + fmt.println(strings.cut("some example text", 0, 4)) // -> "some" + fmt.println(strings.cut("some example text", 2, 2)) // -> "me" + fmt.println(strings.cut("some example text", 5, 7)) // -> "example" + } + +Output: + + some + me + example - strings.cut("some example text", 0, 4) -> "some" - strings.cut("some example text", 2, 2) -> "me" - strings.cut("some example text", 5, 7) -> "example" */ -cut :: proc(s: string, rune_offset := int(0), rune_length := int(0), allocator := context.allocator) -> (res: string) { +cut :: proc(s: string, rune_offset := int(0), rune_length := int(0), allocator := context.allocator) -> (res: string, err: mem.Allocator_Error) #optional_allocator_error { s := s; rune_length := rune_length context.allocator = allocator @@ -384,7 +740,7 @@ cut :: proc(s: string, rune_offset := int(0), rune_length := int(0), allocator : // We're asking for a substring starting after the end of the input string. // That's just an empty string. if rune_offset >= rune_count { - return "" + return "", nil } // If we don't specify the length of the substring, use the remainder. @@ -396,7 +752,7 @@ cut :: proc(s: string, rune_offset := int(0), rune_length := int(0), allocator : // But we do know it's bounded by the number of runes * 4 bytes, // and can be no more than the size of the input string. bytes_needed := min(rune_length * 4, len(s)) - buf := make([]u8, bytes_needed) + buf := make([]u8, bytes_needed) or_return byte_offset := 0 for i := 0; i < rune_count; i += 1 { @@ -417,15 +773,34 @@ cut :: proc(s: string, rune_offset := int(0), rune_length := int(0), allocator : } s = s[w:] } - return string(buf[:byte_offset]) + return string(buf[:byte_offset]), nil } +/* +Splits the input string `s` into a slice of substrings separated by the specified `sep` string +*Allocates Using Provided Allocator* + +*Used Internally - Private Function* + +Inputs: +- s: The input string to split +- sep: The separator string +- sep_save: A flag determining if the separator should be saved in the resulting substrings +- n: The maximum number of substrings to return, returns `nil` without alloc when `n=0` +- allocator: (default is context.allocator) + +NOTE: Allocation occurs for the array, the splits are all views of the original string. + +Returns: +- res: The slice of substrings +- err: An optional allocator error if one occured, `nil` otherwise +*/ @private -_split :: proc(s_, sep: string, sep_save, n_: int, allocator := context.allocator) -> []string { +_split :: proc(s_, sep: string, sep_save, n_: int, allocator := context.allocator) -> (res: []string, err: mem.Allocator_Error) { s, n := s_, n_ if n == 0 { - return nil + return nil, nil } if sep == "" { @@ -434,7 +809,7 @@ _split :: proc(s_, sep: string, sep_save, n_: int, allocator := context.allocato n = l } - res := make([dynamic]string, n, allocator) + res := make([]string, n, allocator) or_return for i := 0; i < n-1; i += 1 { _, w := utf8.decode_rune_in_string(s) res[i] = s[:w] @@ -443,14 +818,14 @@ _split :: proc(s_, sep: string, sep_save, n_: int, allocator := context.allocato if n > 0 { res[n-1] = s } - return res[:] + return res[:], nil } if n < 0 { n = count(s, sep) + 1 } - res := make([dynamic]string, n, allocator) + res = make([]string, n, allocator) or_return n -= 1 @@ -465,60 +840,164 @@ _split :: proc(s_, sep: string, sep_save, n_: int, allocator := context.allocato } res[i] = s - return res[:i+1] + return res[:i+1], nil } - /* - Splits a string into parts, based on a separator. - Returned strings are substrings of 's'. - ``` - s := "aaa.bbb.ccc.ddd.eee" // 5 parts - ss := split(s, ".") - fmt.println(ss) // [aaa, bbb, ccc, ddd, eee] - ``` +Splits a string into parts based on a separator. + +*Allocates Using Provided Allocator* + +Inputs: +- s: The string to split. +- sep: The separator string used to split the input string. +- allocator: (default is context.allocator). + +Returns: +- res: The slice of strings, each representing a part of the split string. +- err: An optional allocator error if one occured, `nil` otherwise + +NOTE: Allocation occurs for the array, the splits are all views of the original string. + +Example: + + import "core:fmt" + import "core:strings" + + split_example :: proc() { + s := "aaa.bbb.ccc.ddd.eee" // 5 parts + ss := strings.split(s, ".") + fmt.println(ss) + } + +Output: + + ["aaa", "bbb", "ccc", "ddd", "eee"] + */ -split :: proc(s, sep: string, allocator := context.allocator) -> []string { +split :: proc(s, sep: string, allocator := context.allocator) -> (res: []string, err: mem.Allocator_Error) #optional_allocator_error { return _split(s, sep, 0, -1, allocator) } - /* - Splits a string into a total of 'n' parts, based on a separator. - Returns fewer parts if there wasn't enough occurrences of the separator. - Returned strings are substrings of 's'. - ``` - s := "aaa.bbb.ccc.ddd.eee" // 5 parts present - ss := split_n(s, ".", 3) // total of 3 wanted - fmt.println(ss) // [aaa, bbb, ccc.ddd.eee] - ``` +Splits a string into parts based on a separator. If n < count of seperators, the remainder of the string is returned in the last entry. + +*Allocates Using Provided Allocator* + +Inputs: +- s: The string to split. +- sep: The separator string used to split the input string. +- allocator: (default is context.allocator) + +Returns: +- res: The slice of strings, each representing a part of the split string. +- err: An optional allocator error if one occured, `nil` otherwise + +NOTE: Allocation occurs for the array, the splits are all views of the original string. + +Example: + + import "core:fmt" + import "core:strings" + + split_n_example :: proc() { + s := "aaa.bbb.ccc.ddd.eee" // 5 parts present + ss := strings.split_n(s, ".",3) // total of 3 wanted + fmt.println(ss) + } + +Output: + + ["aaa", "bbb", "ccc.ddd.eee"] + */ -split_n :: proc(s, sep: string, n: int, allocator := context.allocator) -> []string { +split_n :: proc(s, sep: string, n: int, allocator := context.allocator) -> (res: []string, err: mem.Allocator_Error) #optional_allocator_error { return _split(s, sep, 0, n, allocator) } - /* - splits the string `s` after the seperator string `sep` appears - returns the slice of split strings allocated using `allocator` +Splits a string into parts after the separator, retaining it in the substrings. + +*Allocates Using Provided Allocator* + +Inputs: +- s: The string to split. +- sep: The separator string used to split the input string. +- allocator: (default is context.allocator). + +Returns: +- res: The slice of strings, each representing a part of the split string after the separator +- err: An optional allocator error if one occured, `nil` otherwise + +NOTE: Allocation occurs for the array, the splits are all views of the original string. + +Example: + + import "core:fmt" + import "core:strings" + + split_after_example :: proc() { + a := "aaa.bbb.ccc.ddd.eee" // 5 parts + aa := strings.split_after(a, ".") + fmt.println(aa) + } + +Output: + + ["aaa.", "bbb.", "ccc.", "ddd.", "eee"] - a := "aaa.bbb.ccc.ddd.eee" - aa := strings.split_after(a, ".") - fmt.eprintln(aa) // [aaa., bbb., ccc., ddd., eee] */ -split_after :: proc(s, sep: string, allocator := context.allocator) -> []string { +split_after :: proc(s, sep: string, allocator := context.allocator) -> (res: []string, err: mem.Allocator_Error) #optional_allocator_error { return _split(s, sep, len(sep), -1, allocator) } - /* - splits the string `s` after the seperator string `sep` appears into a total of `n` parts - returns the slice of split strings allocated using `allocator` +Splits a string into a total of `n` parts after the separator. + +*Allocates Using Provided Allocator* + +Inputs: +- s: The string to split. +- sep: The separator string used to split the input string. +- n: The maximum number of parts to split the string into. +- allocator: (default is context.allocator) + +Returns: +- res: The slice of strings with `n` parts or fewer if there weren't +- err: An optional allocator error if one occured, `nil` otherwise + +NOTE: Allocation occurs for the array, the splits are all views of the original string. + +Example: + + import "core:fmt" + import "core:strings" + + split_after_n_example :: proc() { + a := "aaa.bbb.ccc.ddd.eee" + aa := strings.split_after_n(a, ".", 3) + fmt.println(aa) + } + +Output: + + ["aaa.", "bbb.", "ccc.ddd.eee"] - a := "aaa.bbb.ccc.ddd.eee" - aa := strings.split_after(a, ".") - fmt.eprintln(aa) // [aaa., bbb., ccc., ddd., eee] */ -split_after_n :: proc(s, sep: string, n: int, allocator := context.allocator) -> []string { +split_after_n :: proc(s, sep: string, n: int, allocator := context.allocator) -> (res: []string, err: mem.Allocator_Error) #optional_allocator_error { return _split(s, sep, len(sep), n, allocator) } +/* +Searches for the first occurrence of `sep` in the given string and returns the substring +up to (but not including) the separator, as well as a boolean indicating success. +*Used Internally - Private Function* + +Inputs: +- s: Pointer to the input string, which is modified during the search. +- sep: The separator string to search for. +- sep_save: Number of characters from the separator to include in the result. + +Returns: +- res: The resulting substring +- ok: `true` if an iteration result was returned, `false` if the iterator has reached the end +*/ @private _split_iterator :: proc(s: ^string, sep: string, sep_save: int) -> (res: string, ok: bool) { // stop once the string is empty or nil @@ -546,15 +1025,37 @@ _split_iterator :: proc(s: ^string, sep: string, sep_save: int) -> (res: string, } return } - /* - split the ^string `s` by the byte seperator `sep` in an iterator fashion - consumes the original string till the end, leaving the string `s` with len == 0 +Splits the input string by the byte separator in an iterator fashion. - text := "a.b.c.d.e" - for str in strings.split_by_byte_iterator(&text, '.') { - fmt.eprintln(str) // every loop -> a b c d e +Inputs: +- s: Pointer to the input string, which is modified during the search. +- sep: The byte separator to search for. + +Returns: +- res: The resulting substring +- ok: `true` if an iteration result was returned, `false` if the iterator has reached the end + +Example: + + import "core:fmt" + import "core:strings" + + split_by_byte_iterator_example :: proc() { + text := "a.b.c.d.e" + for str in strings.split_by_byte_iterator(&text, '.') { + fmt.println(str) // every loop -> a b c d e + } } + +Output: + + a + b + c + d + e + */ split_by_byte_iterator :: proc(s: ^string, sep: u8) -> (res: string, ok: bool) { m := index_byte(s^, sep) @@ -570,36 +1071,89 @@ split_by_byte_iterator :: proc(s: ^string, sep: u8) -> (res: string, ok: bool) { } return } - /* - split the ^string `s` by the seperator string `sep` in an iterator fashion - consumes the original string till the end +Splits the input string by the separator string in an iterator fashion. - text := "a.b.c.d.e" - for str in strings.split_iterator(&text, ".") { - fmt.eprintln(str) // every loop -> a b c d e +Inputs: +- s: Pointer to the input string, which is modified during the search. +- sep: The separator string to search for. + +Returns: +- res: The resulting substring +- ok: `true` if an iteration result was returned, `false` if the iterator has reached the end + +Example: + + import "core:fmt" + import "core:strings" + + split_iterator_example :: proc() { + text := "a.b.c.d.e" + for str in strings.split_iterator(&text, ".") { + fmt.println(str) + } } + +Output: + + a + b + c + d + e + */ -split_iterator :: proc(s: ^string, sep: string) -> (string, bool) { +split_iterator :: proc(s: ^string, sep: string) -> (res: string, ok: bool) { return _split_iterator(s, sep, 0) } - /* - split the ^string `s` after every seperator string `sep` in an iterator fashion - consumes the original string till the end +Splits the input string after every separator string in an iterator fashion. - text := "a.b.c.d.e" - for str in strings.split_after_iterator(&text, ".") { - fmt.eprintln(str) // every loop -> a. b. c. d. e +Inputs: +- s: Pointer to the input string, which is modified during the search. +- sep: The separator string to search for. + +Returns: +- res: The resulting substring +- ok: `true` if an iteration result was returned, `false` if the iterator has reached the end + +Example: + + import "core:fmt" + import "core:strings" + + split_after_iterator_example :: proc() { + text := "a.b.c.d.e" + for str in strings.split_after_iterator(&text, ".") { + fmt.println(str) + } } + +Output: + + a. + b. + c. + d. + e + */ -split_after_iterator :: proc(s: ^string, sep: string) -> (string, bool) { +split_after_iterator :: proc(s: ^string, sep: string) -> (res: string, ok: bool) { return _split_iterator(s, sep, len(sep)) } +/* +Trims the carriage return character from the end of the input string. +*Used Internally - Private Function* +Inputs: +- s: The input string to trim. + +Returns: +- res: The trimmed string as a slice of the original. +*/ @(private) -_trim_cr :: proc(s: string) -> string { +_trim_cr :: proc(s: string) -> (res: string) { n := len(s) if n > 0 { if s[n-1] == '\r' { @@ -608,116 +1162,266 @@ _trim_cr :: proc(s: string) -> string { } return s } - /* - split the string `s` at every line break '\n' - return an allocated slice of strings +Splits the input string at every line break `\n`. + +*Allocates Using Provided Allocator* + +Inputs: +- s: The input string to split. +- allocator: (default is context.allocator) + +Returns: +- res: The slice (allocated) of the split string (slices into original string) +- err: An optional allocator error if one occured, `nil` otherwise + +Example: + + import "core:fmt" + import "core:strings" + + split_lines_example :: proc() { + a := "a\nb\nc\nd\ne" + b := strings.split_lines(a) + fmt.println(b) + } + +Output: + + ["a", "b", "c", "d", "e"] - a := "a\nb\nc\nd\ne" - b := strings.split_lines(a) - fmt.eprintln(b) // [a, b, c, d, e] */ -split_lines :: proc(s: string, allocator := context.allocator) -> []string { +split_lines :: proc(s: string, allocator := context.allocator) -> (res: []string, err: mem.Allocator_Error) #optional_allocator_error { sep :: "\n" - lines := _split(s, sep, 0, -1, allocator) + lines := _split(s, sep, 0, -1, allocator) or_return for line in &lines { line = _trim_cr(line) } - return lines + return lines, nil } - /* - split the string `s` at every line break '\n' for `n` parts - return an allocated slice of strings +Splits the input string at every line break `\n` for `n` parts. + +*Allocates Using Provided Allocator* + +Inputs: +- s: The input string to split. +- n: The number of parts to split into. +- allocator: (default is context.allocator) + +Returns: +- res: The slice (allocated) of the split string (slices into original string) +- err: An optional allocator error if one occured, `nil` otherwise + +NOTE: Allocation occurs for the array, the splits are all views of the original string. + +Example: + + import "core:fmt" + import "core:strings" + + split_lines_n_example :: proc() { + a := "a\nb\nc\nd\ne" + b := strings.split_lines_n(a, 3) + fmt.println(b) + } + +Output: + + ["a", "b", "c\nd\ne"] - a := "a\nb\nc\nd\ne" - b := strings.split_lines_n(a, 3) - fmt.eprintln(b) // [a, b, c, d\ne\n] */ -split_lines_n :: proc(s: string, n: int, allocator := context.allocator) -> []string { +split_lines_n :: proc(s: string, n: int, allocator := context.allocator) -> (res: []string, err: mem.Allocator_Error) #optional_allocator_error { sep :: "\n" - lines := _split(s, sep, 0, n, allocator) + lines := _split(s, sep, 0, n, allocator) or_return for line in &lines { line = _trim_cr(line) } - return lines + return lines, nil } - /* - split the string `s` at every line break '\n' leaving the '\n' in the resulting strings - return an allocated slice of strings +Splits the input string at every line break `\n` leaving the `\n` in the resulting strings. + +*Allocates Using Provided Allocator* + +Inputs: +- s: The input string to split. +- allocator: (default is context.allocator) + +Returns: +- res: The slice (allocated) of the split string (slices into original string), with `\n` included +- err: An optional allocator error if one occured, `nil` otherwise + +NOTE: Allocation occurs for the array, the splits are all views of the original string. + +Example: + + import "core:fmt" + import "core:strings" + + split_lines_after_example :: proc() { + a := "a\nb\nc\nd\ne" + b := strings.split_lines_after(a) + fmt.println(b) + } + +Output: + + ["a\n", "b\n", "c\n", "d\n", "e"] - a := "a\nb\nc\nd\ne" - b := strings.split_lines_after(a) - fmt.eprintln(b) // [a\n, b\n, c\n, d\n, e\n] */ -split_lines_after :: proc(s: string, allocator := context.allocator) -> []string { +split_lines_after :: proc(s: string, allocator := context.allocator) -> (res: []string, err: mem.Allocator_Error) #optional_allocator_error { sep :: "\n" - lines := _split(s, sep, len(sep), -1, allocator) + lines := _split(s, sep, len(sep), -1, allocator) or_return for line in &lines { line = _trim_cr(line) } - return lines + return lines, nil } - /* - split the string `s` at every line break '\n' leaving the '\n' in the resulting strings - only runs for `n` parts - return an allocated slice of strings +Splits the input string at every line break `\n` leaving the `\n` in the resulting strings. +Only runs for n parts. + +*Allocates Using Provided Allocator* + +Inputs: +- s: The input string to split. +- n: The number of parts to split into. +- allocator: (default is context.allocator) + +Returns: +- res: The slice (allocated) of the split string (slices into original string), with `\n` included +- err: An optional allocator error if one occured, `nil` otherwise + +NOTE: Allocation occurs for the array, the splits are all views of the original string. + +Example: + + import "core:fmt" + import "core:strings" + + split_lines_after_n_example :: proc() { + a := "a\nb\nc\nd\ne" + b := strings.split_lines_after_n(a, 3) + fmt.println(b) + } + +Output: + + ["a\n", "b\n", "c\nd\ne"] - a := "a\nb\nc\nd\ne" - b := strings.split_lines_after_n(a, 3) - fmt.eprintln(b) // [a\n, b\n, c\n, d\ne\n] */ -split_lines_after_n :: proc(s: string, n: int, allocator := context.allocator) -> []string { +split_lines_after_n :: proc(s: string, n: int, allocator := context.allocator) -> (res: []string, err: mem.Allocator_Error) #optional_allocator_error { sep :: "\n" - lines := _split(s, sep, len(sep), n, allocator) + lines := _split(s, sep, len(sep), n, allocator) or_return for line in &lines { line = _trim_cr(line) } - return lines + return lines, nil } - /* - split the string `s` at every line break '\n' - returns the current split string every iteration till the string is consumed +Splits the input string at every line break `\n`. +Returns the current split string every iteration until the string is consumed. - text := "a\nb\nc\nd\ne" - for str in strings.split_lines_iterator(&text) { - fmt.eprintln(text) // every loop -> a b c d e +Inputs: +- s: Pointer to the input string, which is modified during the search. + +Returns: +- line: The resulting substring +- ok: `true` if an iteration result was returned, `false` if the iterator has reached the end + +Example: + + import "core:fmt" + import "core:strings" + + split_lines_iterator_example :: proc() { + text := "a\nb\nc\nd\ne" + for str in strings.split_lines_iterator(&text) { + fmt.print(str) // every loop -> a b c d e + } + fmt.print("\n") } + +Output: + + abcde + */ split_lines_iterator :: proc(s: ^string) -> (line: string, ok: bool) { sep :: "\n" line = _split_iterator(s, sep, 0) or_return return _trim_cr(line), true } - /* - split the string `s` at every line break '\n' - returns the current split string every iteration till the string is consumed +Splits the input string at every line break `\n`. +Returns the current split string with line breaks included every iteration until the string is consumed. - text := "a\nb\nc\nd\ne" - for str in strings.split_lines_after_iterator(&text) { - fmt.eprintln(text) // every loop -> a\n b\n c\n d\n e\n +Inputs: +- s: Pointer to the input string, which is modified during the search. + +Returns: +- line: The resulting substring with line breaks included +- ok: `true` if an iteration result was returned, `false` if the iterator has reached the end + +Example: + + import "core:fmt" + import "core:strings" + + split_lines_after_iterator_example :: proc() { + text := "a\nb\nc\nd\ne\n" + for str in strings.split_lines_after_iterator(&text) { + fmt.print(str) // every loop -> a\n b\n c\n d\n e\n + } } + +Output: + + a + b + c + d + e + */ split_lines_after_iterator :: proc(s: ^string) -> (line: string, ok: bool) { sep :: "\n" line = _split_iterator(s, sep, len(sep)) or_return return _trim_cr(line), true } - /* - returns the byte offset of the first byte `c` in the string `s` it finds, -1 when not found - can't find utf8 based runes +Returns the byte offset of the first byte `c` in the string s it finds, -1 when not found. +NOTE: Can't find UTF-8 based runes. + +Inputs: +- s: The input string to search in. +- c: The byte to search for. + +Returns: +- res: The byte offset of the first occurrence of `c` in `s`, or -1 if not found. + +Example: + + import "core:fmt" + import "core:strings" + + index_byte_example :: proc() { + fmt.println(strings.index_byte("test", 't')) + fmt.println(strings.index_byte("test", 'e')) + fmt.println(strings.index_byte("test", 'x')) + fmt.println(strings.index_byte("teƤst", 'Ƥ')) + } + +Output: + + 0 + 1 + -1 + -1 - strings.index_byte("test", 't') -> 0 - strings.index_byte("test", 'e') -> 1 - strings.index_byte("test", 'x') -> -1 - strings.index_byte("teƤst", 'Ƥ') -> -1 */ -index_byte :: proc(s: string, c: byte) -> int { +index_byte :: proc(s: string, c: byte) -> (res: int) { for i := 0; i < len(s); i += 1 { if s[i] == c { return i @@ -725,17 +1429,39 @@ index_byte :: proc(s: string, c: byte) -> int { } return -1 } - /* - returns the byte offset of the last byte `c` in the string `s` it finds, -1 when not found - can't find utf8 based runes +Returns the byte offset of the last byte `c` in the string `s`, -1 when not found. + +Inputs: +- s: The input string to search in. +- c: The byte to search for. + +Returns: +- res: The byte offset of the last occurrence of `c` in `s`, or -1 if not found. + +NOTE: Can't find UTF-8 based runes. + +Example: + + import "core:fmt" + import "core:strings" + + last_index_byte_example :: proc() { + fmt.println(strings.last_index_byte("test", 't')) + fmt.println(strings.last_index_byte("test", 'e')) + fmt.println(strings.last_index_byte("test", 'x')) + fmt.println(strings.last_index_byte("teƤst", 'Ƥ')) + } + +Output: + + 3 + 1 + -1 + -1 - strings.index_byte("test", 't') -> 3 - strings.index_byte("test", 'e') -> 1 - strings.index_byte("test", 'x') -> -1 - strings.index_byte("teƤst", 'Ƥ') -> -1 */ -last_index_byte :: proc(s: string, c: byte) -> int { +last_index_byte :: proc(s: string, c: byte) -> (res: int) { for i := len(s)-1; i >= 0; i -= 1 { if s[i] == c { return i @@ -743,22 +1469,46 @@ last_index_byte :: proc(s: string, c: byte) -> int { } return -1 } - - /* - returns the byte offset of the first rune `r` in the string `s` it finds, -1 when not found - avoids invalid runes +Returns the byte offset of the first rune `r` in the string `s` it finds, -1 when not found. +Invalid runes return -1 + +Inputs: +- s: The input string to search in. +- r: The rune to search for. + +Returns: +- res: The byte offset of the first occurrence of `r` in `s`, or -1 if not found. + +Example: + + import "core:fmt" + import "core:strings" + + index_rune_example :: proc() { + fmt.println(strings.index_rune("abcƤdef", 'x')) + fmt.println(strings.index_rune("abcƤdef", 'a')) + fmt.println(strings.index_rune("abcƤdef", 'b')) + fmt.println(strings.index_rune("abcƤdef", 'c')) + fmt.println(strings.index_rune("abcƤdef", 'Ƥ')) + fmt.println(strings.index_rune("abcƤdef", 'd')) + fmt.println(strings.index_rune("abcƤdef", 'e')) + fmt.println(strings.index_rune("abcƤdef", 'f')) + } + +Output: + + -1 + 0 + 1 + 2 + 3 + 5 + 6 + 7 - strings.index_rune("abcƤdef", 'x') -> -1 - strings.index_rune("abcƤdef", 'a') -> 0 - strings.index_rune("abcƤdef", 'b') -> 1 - strings.index_rune("abcƤdef", 'c') -> 2 - strings.index_rune("abcƤdef", 'Ƥ') -> 3 - strings.index_rune("abcƤdef", 'd') -> 5 - strings.index_rune("abcƤdef", 'e') -> 6 - strings.index_rune("abcƤdef", 'f') -> 7 */ -index_rune :: proc(s: string, r: rune) -> int { +index_rune :: proc(s: string, r: rune) -> (res: int) { switch { case u32(r) < utf8.RUNE_SELF: return index_byte(s, byte(r)) @@ -780,16 +1530,37 @@ index_rune :: proc(s: string, r: rune) -> int { } @private PRIME_RABIN_KARP :: 16777619 - /* - returns the byte offset of the string `substr` in the string `s`, -1 when not found - - strings.index("test", "t") -> 0 - strings.index("test", "te") -> 0 - strings.index("test", "st") -> 2 - strings.index("test", "tt") -> -1 +Returns the byte offset of the string `substr` in the string `s`, -1 when not found. + +Inputs: +- s: The input string to search in. +- substr: The substring to search for. + +Returns: +- res: The byte offset of the first occurrence of `substr` in `s`, or -1 if not found. + +Example: + + import "core:fmt" + import "core:strings" + + index_example :: proc() { + fmt.println(strings.index("test", "t")) + fmt.println(strings.index("test", "te")) + fmt.println(strings.index("test", "st")) + fmt.println(strings.index("test", "tt")) + } + +Output: + + 0 + 0 + 2 + -1 + */ -index :: proc(s, substr: string) -> int { +index :: proc(s, substr: string) -> (res: int) { hash_str_rabin_karp :: proc(s: string) -> (hash: u32 = 0, pow: u32 = 1) { for i := 0; i < len(s); i += 1 { hash = hash*PRIME_RABIN_KARP + u32(s[i]) @@ -838,16 +1609,37 @@ index :: proc(s, substr: string) -> int { } return -1 } - /* - returns the last byte offset of the string `substr` in the string `s`, -1 when not found - - strings.index("test", "t") -> 3 - strings.index("test", "te") -> 0 - strings.index("test", "st") -> 2 - strings.index("test", "tt") -> -1 +Returns the last byte offset of the string `substr` in the string `s`, -1 when not found. + +Inputs: +- s: The input string to search in. +- substr: The substring to search for. + +Returns: +- res: The byte offset of the last occurrence of `substr` in `s`, or -1 if not found. + +Example: + + import "core:fmt" + import "core:strings" + + last_index_example :: proc() { + fmt.println(strings.last_index("test", "t")) + fmt.println(strings.last_index("test", "te")) + fmt.println(strings.last_index("test", "st")) + fmt.println(strings.last_index("test", "tt")) + } + +Output: + + 3 + 0 + 2 + -1 + */ -last_index :: proc(s, substr: string) -> int { +last_index :: proc(s, substr: string) -> (res: int) { hash_str_rabin_karp_reverse :: proc(s: string) -> (hash: u32 = 0, pow: u32 = 1) { for i := len(s) - 1; i >= 0; i -= 1 { hash = hash*PRIME_RABIN_KARP + u32(s[i]) @@ -894,17 +1686,39 @@ last_index :: proc(s, substr: string) -> int { } return -1 } - /* - returns the index of any first char of `chars` found in `s`, -1 if not found - - strings.index_any("test", "s") -> 2 - strings.index_any("test", "se") -> 1 - strings.index_any("test", "et") -> 0 - strings.index_any("test", "set") -> 0 - strings.index_any("test", "x") -> -1 +Returns the index of any first char of `chars` found in `s`, -1 if not found. + +Inputs: +- s: The input string to search in. +- chars: The characters to look for + +Returns: +- res: The index of the first character of `chars` found in `s`, or -1 if not found. + +Example: + + import "core:fmt" + import "core:strings" + + index_any_example :: proc() { + fmt.println(strings.index_any("test", "s")) + fmt.println(strings.index_any("test", "se")) + fmt.println(strings.index_any("test", "et")) + fmt.println(strings.index_any("test", "set")) + fmt.println(strings.index_any("test", "x")) + } + +Output: + + 2 + 1 + 0 + 0 + -1 + */ -index_any :: proc(s, chars: string) -> int { +index_any :: proc(s, chars: string) -> (res: int) { if chars == "" { return -1 } @@ -935,18 +1749,39 @@ index_any :: proc(s, chars: string) -> int { } return -1 } - /* - returns the last matching index in `s` of any char in `chars` found in `s`, -1 if not found - iterates the string in reverse +Finds the last occurrence of any character in `chars` within `s`. Iterates in reverse. + +Inputs: +- s: The string to search in +- chars: The characters to look for + +Returns: +- res: The index of the last matching character, or -1 if not found + +Example: + + import "core:fmt" + import "core:strings" + + last_index_any_example :: proc() { + fmt.println(strings.last_index_any("test", "s")) + fmt.println(strings.last_index_any("test", "se")) + fmt.println(strings.last_index_any("test", "et")) + fmt.println(strings.last_index_any("test", "set")) + fmt.println(strings.last_index_any("test", "x")) + } + +Output: + + 2 + 2 + 3 + 3 + -1 - strings.last_index_any("test", "s") -> 2 - strings.last_index_any("test", "se") -> 2 - strings.last_index_any("test", "et") -> 3 - strings.last_index_any("test", "set") -> 3 - strings.last_index_any("test", "x") -> -1 */ -last_index_any :: proc(s, chars: string) -> int { +last_index_any :: proc(s, chars: string) -> (res: int) { if chars == "" { return -1 } @@ -994,18 +1829,79 @@ last_index_any :: proc(s, chars: string) -> int { } return -1 } - /* - returns the count of the string `substr` found in the string `s` - returns the rune_count + 1 of the string `s` on empty `substr` +Finds the first occurrence of any substring in `substrs` within `s` - strings.count("abbccc", "a") -> 1 - strings.count("abbccc", "b") -> 2 - strings.count("abbccc", "c") -> 3 - strings.count("abbccc", "ab") -> 1 - strings.count("abbccc", " ") -> 0 +Inputs: +- s: The string to search in +- substrs: The substrings to look for + +Returns: +- idx: the index of the first matching substring +- width: the length of the found substring */ -count :: proc(s, substr: string) -> int { +index_multi :: proc(s: string, substrs: []string) -> (idx: int, width: int) { + idx = -1 + if s == "" || len(substrs) <= 0 { + return + } + // disallow "" substr + for substr in substrs { + if len(substr) == 0 { + return + } + } + + lowest_index := len(s) + found := false + for substr in substrs { + if i := index(s, substr); i >= 0 { + if i < lowest_index { + lowest_index = i + width = len(substr) + found = true + } + } + } + + if found { + idx = lowest_index + } + return +} +/* +Counts the number of non-overlapping occurrences of `substr` in `s` + +Inputs: +- s: The string to search in +- substr: The substring to count + +Returns: +- res: The number of occurrences of `substr` in `s`, returns the rune_count + 1 of the string `s` on empty `substr` + +Example: + + import "core:fmt" + import "core:strings" + + count_example :: proc() { + fmt.println(strings.count("abbccc", "a")) + fmt.println(strings.count("abbccc", "b")) + fmt.println(strings.count("abbccc", "c")) + fmt.println(strings.count("abbccc", "ab")) + fmt.println(strings.count("abbccc", " ")) + } + +Output: + + 1 + 2 + 3 + 1 + 0 + +*/ +count :: proc(s, substr: string) -> (res: int) { if len(substr) == 0 { // special case return rune_count(s) + 1 } @@ -1039,50 +1935,122 @@ count :: proc(s, substr: string) -> int { } return n } - /* - repeats the string `s` multiple `count` times and returns the allocated string - panics when `count` is below 0 +Repeats the string `s` `count` times, concatenating the result + +*Allocates Using Provided Allocator* + +Inputs: +- s: The string to repeat +- count: The number of times to repeat `s` +- allocator: (default is context.allocator) + +Returns: +- res: The concatenated repeated string +- err: An optional allocator error if one occured, `nil` otherwise + +WARNING: Panics if count < 0 + +Example: + + import "core:fmt" + import "core:strings" + + repeat_example :: proc() { + fmt.println(strings.repeat("abc", 2)) + } + +Output: + + abcabc - strings.repeat("abc", 2) -> "abcabc" */ -repeat :: proc(s: string, count: int, allocator := context.allocator) -> string { +repeat :: proc(s: string, count: int, allocator := context.allocator) -> (res: string, err: mem.Allocator_Error) #optional_allocator_error { if count < 0 { panic("strings: negative repeat count") } else if count > 0 && (len(s)*count)/count != len(s) { panic("strings: repeat count will cause an overflow") } - b := make([]byte, len(s)*count, allocator) + b := make([]byte, len(s)*count, allocator) or_return i := copy(b, s) for i < len(b) { // 2^N trick to reduce the need to copy copy(b[i:], b[:i]) i *= 2 } - return string(b) + return string(b), nil } - /* - replaces all instances of `old` in the string `s` with the `new` string - returns the `output` string and true when an a allocation through a replace happened +Replaces all occurrences of `old` in `s` with `new` + +*Allocates Using Provided Allocator* + +Inputs: +- s: The string to modify +- old: The substring to replace +- new: The substring to replace `old` with +- allocator: The allocator to use for the new string (default is context.allocator) + +Returns: +- output: The modified string +- was_allocation: `true` if an allocation occurred during the replacement, `false` otherwise + +Example: + + import "core:fmt" + import "core:strings" + + replace_all_example :: proc() { + fmt.println(strings.replace_all("xyzxyz", "xyz", "abc")) + fmt.println(strings.replace_all("xyzxyz", "abc", "xyz")) + fmt.println(strings.replace_all("xyzxyz", "xy", "z")) + } + +Output: + + abcabc true + xyzxyz false + zzzz true - strings.replace_all("xyzxyz", "xyz", "abc") -> "abcabc", true - strings.replace_all("xyzxyz", "abc", "xyz") -> "xyzxyz", false - strings.replace_all("xyzxyz", "xy", "z") -> "zzzz", true */ replace_all :: proc(s, old, new: string, allocator := context.allocator) -> (output: string, was_allocation: bool) { return replace(s, old, new, -1, allocator) } - /* - replaces `n` instances of `old` in the string `s` with the `new` string - if n < 0, no limit on the number of replacements - returns the `output` string and true when an a allocation through a replace happened +Replaces n instances of old in the string s with the new string + +*Allocates Using Provided Allocator* + +Inputs: +- s: The input string +- old: The substring to be replaced +- new: The replacement string +- n: The number of instances to replace (if `n < 0`, no limit on the number of replacements) +- allocator: (default: context.allocator) + +Returns: +- output: The modified string +- was_allocation: `true` if an allocation occurred during the replacement, `false` otherwise + +Example: + + import "core:fmt" + import "core:strings" + + replace_example :: proc() { + fmt.println(strings.replace("xyzxyz", "xyz", "abc", 2)) + fmt.println(strings.replace("xyzxyz", "xyz", "abc", 1)) + fmt.println(strings.replace("xyzxyz", "abc", "xyz", -1)) + fmt.println(strings.replace("xyzxyz", "xy", "z", -1)) + } + +Output: + + abcabc true + abcxyz true + xyzxyz false + zzzz true - strings.replace("xyzxyz", "xyz", "abc", 2) -> "abcabc", true - strings.replace("xyzxyz", "xyz", "abc", 1) -> "abcxyz", true - strings.replace("xyzxyz", "abc", "xyz", -1) -> "xyzxyz", false - strings.replace("xyzxyz", "xy", "z", -1) -> "zzzz", true */ replace :: proc(s, old, new: string, n: int, allocator := context.allocator) -> (output: string, was_allocation: bool) { if old == new || n == 0 { @@ -1123,45 +2091,108 @@ replace :: proc(s, old, new: string, n: int, allocator := context.allocator) -> output = string(t[0:w]) return } - /* - removes the `key` string `n` times from the `s` string - if n < 0, no limit on the number of removes - returns the `output` string and true when an a allocation through a remove happened +Removes the key string `n` times from the `s` string + +*Allocates Using Provided Allocator* + +Inputs: +- s: The input string +- key: The substring to be removed +- n: The number of instances to remove (if `n < 0`, no limit on the number of removes) +- allocator: (default: context.allocator) + +Returns: +- output: The modified string +- was_allocation: `true` if an allocation occurred during the replacement, `false` otherwise + +Example: + + import "core:fmt" + import "core:strings" + + remove_example :: proc() { + fmt.println(strings.remove("abcabc", "abc", 1)) + fmt.println(strings.remove("abcabc", "abc", -1)) + fmt.println(strings.remove("abcabc", "a", -1)) + fmt.println(strings.remove("abcabc", "x", -1)) + } + +Output: + + abc true + true + bcbc true + abcabc false - strings.remove("abcabc", "abc", 1) -> "abc", true - strings.remove("abcabc", "abc", -1) -> "", true - strings.remove("abcabc", "a", -1) -> "bcbc", true - strings.remove("abcabc", "x", -1) -> "abcabc", false */ remove :: proc(s, key: string, n: int, allocator := context.allocator) -> (output: string, was_allocation: bool) { return replace(s, key, "", n, allocator) } - /* - removes all the `key` string instanes from the `s` string - returns the `output` string and true when an a allocation through a remove happened +Removes all the `key` string instances from the `s` string + +*Allocates Using Provided Allocator* + +Inputs: +- s: The input string +- key: The substring to be removed +- allocator: (default: context.allocator) + +Returns: +- output: The modified string +- was_allocation: `true` if an allocation occurred during the replacement, `false` otherwise + +Example: + + import "core:fmt" + import "core:strings" + + remove_all_example :: proc() { + fmt.println(strings.remove_all("abcabc", "abc")) + fmt.println(strings.remove_all("abcabc", "a")) + fmt.println(strings.remove_all("abcabc", "x")) + } + +Output: + + true + bcbc true + abcabc false - strings.remove("abcabc", "abc") -> "", true - strings.remove("abcabc", "a") -> "bcbc", true - strings.remove("abcabc", "x") -> "abcabc", false */ remove_all :: proc(s, key: string, allocator := context.allocator) -> (output: string, was_allocation: bool) { return remove(s, key, -1, allocator) } - +// Returns true if is an ASCII space character ('\t', '\n', '\v', '\f', '\r', ' ') @(private) _ascii_space := [256]bool{'\t' = true, '\n' = true, '\v' = true, '\f' = true, '\r' = true, ' ' = true} -// return true when the `r` rune is '\t', '\n', '\v', '\f', '\r' or ' ' -is_ascii_space :: proc(r: rune) -> bool { +/* +Returns true when the `r` rune is an ASCII whitespace character. + +Inputs: +- r: the rune to test + +Returns: +-res: `true` if `r` is a whitespace character, `false` if otherwise +*/ +is_ascii_space :: proc(r: rune) -> (res: bool) { if r < utf8.RUNE_SELF { return _ascii_space[u8(r)] } return false } -// returns true when the `r` rune is any asci or utf8 based whitespace -is_space :: proc(r: rune) -> bool { +/* +Returns true when the `r` rune is an ASCII or UTF-8 whitespace character. + +Inputs: +- r: the rune to test + +Returns: +-res: `true` if `r` is a whitespace character, `false` if otherwise +*/ +is_space :: proc(r: rune) -> (res: bool) { if r < 0x2000 { switch r { case '\t', '\n', '\v', '\f', '\r', ' ', 0x85, 0xa0, 0x1680: @@ -1179,25 +2210,56 @@ is_space :: proc(r: rune) -> bool { return false } -// returns true when the `r` rune is a nul byte -is_null :: proc(r: rune) -> bool { +/* +Returns true when the `r` rune is `0x0` + +Inputs: +- r: the rune to test + +Returns: +-res: `true` if `r` is `0x0`, `false` if otherwise +*/ +is_null :: proc(r: rune) -> (res: bool) { return r == 0x0000 } /* - runs trough the `s` string linearly and watches wether the `p` procedure matches the `truth` bool - returns the rune offset or -1 when no match was found +Find the index of the first rune `r` in string `s` for which procedure `p` returns the same as truth, or -1 if no such rune appears. - call :: proc(r: rune) -> bool { - return r == 'a' +Inputs: +- s: The input string +- p: A procedure that takes a rune and returns a boolean +- truth: The boolean value to be matched (default: `true`) + +Returns: +- res: The index of the first matching rune, or -1 if no match was found + +Example: + + import "core:fmt" + import "core:strings" + + index_proc_example :: proc() { + call :: proc(r: rune) -> bool { + return r == 'a' + } + fmt.println(strings.index_proc("abcabc", call)) + fmt.println(strings.index_proc("cbacba", call)) + fmt.println(strings.index_proc("cbacba", call, false)) + fmt.println(strings.index_proc("abcabc", call, false)) + fmt.println(strings.index_proc("xyz", call)) } - strings.index_proc("abcabc", call) -> 0 - strings.index_proc("cbacba", call) -> 2 - strings.index_proc("cbacba", call, false) -> 0 - strings.index_proc("abcabc", call, false) -> 1 - strings.index_proc("xyz", call) -> -1 + +Output: + + 0 + 2 + 0 + 1 + -1 + */ -index_proc :: proc(s: string, p: proc(rune) -> bool, truth := true) -> int { +index_proc :: proc(s: string, p: proc(rune) -> bool, truth := true) -> (res: int) { for r, i in s { if p(r) == truth { return i @@ -1205,9 +2267,8 @@ index_proc :: proc(s: string, p: proc(rune) -> bool, truth := true) -> int { } return -1 } - -// same as `index_proc` but with a `p` procedure taking a rawptr for state -index_proc_with_state :: proc(s: string, p: proc(rawptr, rune) -> bool, state: rawptr, truth := true) -> int { +// Same as `index_proc`, but the procedure p takes a raw pointer for state +index_proc_with_state :: proc(s: string, p: proc(rawptr, rune) -> bool, state: rawptr, truth := true) -> (res: int) { for r, i in s { if p(state, r) == truth { return i @@ -1215,9 +2276,8 @@ index_proc_with_state :: proc(s: string, p: proc(rawptr, rune) -> bool, state: r } return -1 } - -// same as `index_proc` but runs through the string in reverse -last_index_proc :: proc(s: string, p: proc(rune) -> bool, truth := true) -> int { +// Finds the index of the *last* rune in the string s for which the procedure p returns the same value as truth +last_index_proc :: proc(s: string, p: proc(rune) -> bool, truth := true) -> (res: int) { // TODO(bill): Probably use Rabin-Karp Search for i := len(s); i > 0; { r, size := utf8.decode_last_rune_in_string(s[:i]) @@ -1228,9 +2288,8 @@ last_index_proc :: proc(s: string, p: proc(rune) -> bool, truth := true) -> int } return -1 } - -// same as `index_proc_with_state` but runs through the string in reverse -last_index_proc_with_state :: proc(s: string, p: proc(rawptr, rune) -> bool, state: rawptr, truth := true) -> int { +// Same as `index_proc_with_state`, runs through the string in reverse +last_index_proc_with_state :: proc(s: string, p: proc(rawptr, rune) -> bool, state: rawptr, truth := true) -> (res: int) { // TODO(bill): Probably use Rabin-Karp Search for i := len(s); i > 0; { r, size := utf8.decode_last_rune_in_string(s[:i]) @@ -1241,48 +2300,86 @@ last_index_proc_with_state :: proc(s: string, p: proc(rawptr, rune) -> bool, sta } return -1 } - /* - trims the input string `s` until the procedure `p` returns false - does not allocate - only returns a cut variant of the input string - returns an empty string when no match was found at all +Trims the input string `s` from the left until the procedure `p` returns false - find :: proc(r: rune) -> bool { - return r != 'i' +Inputs: +- s: The input string +- p: A procedure that takes a rune and returns a boolean + +Returns: +- res: The trimmed string as a slice of the original + +Example: + + import "core:fmt" + import "core:strings" + + trim_left_proc_example :: proc() { + find :: proc(r: rune) -> bool { + return r == 'x' + } + fmt.println(strings.trim_left_proc("xxxxxxtesting", find)) } - strings.trim_left_proc("testing", find) -> "ing" + +Output: + + testing + */ -trim_left_proc :: proc(s: string, p: proc(rune) -> bool) -> string { +trim_left_proc :: proc(s: string, p: proc(rune) -> bool) -> (res: string) { i := index_proc(s, p, false) if i == -1 { return "" } return s[i:] } - /* - trims the input string `s` until the procedure `p` with state returns false - returns an empty string when no match was found at all +Trims the input string `s` from the left until the procedure `p` with state returns false + +Inputs: +- s: The input string +- p: A procedure that takes a raw pointer and a rune and returns a boolean +- state: The raw pointer to be passed to the procedure `p` + +Returns: +- res: The trimmed string as a slice of the original */ -trim_left_proc_with_state :: proc(s: string, p: proc(rawptr, rune) -> bool, state: rawptr) -> string { +trim_left_proc_with_state :: proc(s: string, p: proc(rawptr, rune) -> bool, state: rawptr) -> (res: string) { i := index_proc_with_state(s, p, state, false) if i == -1 { return "" } return s[i:] } - /* - trims the input string `s` from the right until the procedure `p` returns false - does not allocate - only returns a cut variant of the input string - returns an empty string when no match was found at all +Trims the input string `s` from the right until the procedure `p` returns `false` - find :: proc(r: rune) -> bool { - return r != 't' +Inputs: +- s: The input string +- p: A procedure that takes a rune and returns a boolean + +Returns: +- res: The trimmed string as a slice of the original + +Example: + + import "core:fmt" + import "core:strings" + + trim_right_proc_example :: proc() { + find :: proc(r: rune) -> bool { + return r != 't' + } + fmt.println(strings.trim_right_proc("testing", find)) } - strings.trim_left_proc("testing", find) -> "test" + +Output: + + test + */ -trim_right_proc :: proc(s: string, p: proc(rune) -> bool) -> string { +trim_right_proc :: proc(s: string, p: proc(rune) -> bool) -> (res: string) { i := last_index_proc(s, p, false) if i >= 0 && s[i] >= utf8.RUNE_SELF { _, w := utf8.decode_rune_in_string(s[i:]) @@ -1292,12 +2389,18 @@ trim_right_proc :: proc(s: string, p: proc(rune) -> bool) -> string { } return s[0:i] } - /* - trims the input string `s` from the right until the procedure `p` with state returns false - returns an empty string when no match was found at all +Trims the input string `s` from the right until the procedure `p` with state returns `false` + +Inputs: +- s: The input string +- p: A procedure that takes a raw pointer and a rune and returns a boolean +- state: The raw pointer to be passed to the procedure `p` + +Returns: +- res: The trimmed string as a slice of the original, empty when no match */ -trim_right_proc_with_state :: proc(s: string, p: proc(rawptr, rune) -> bool, state: rawptr) -> string { +trim_right_proc_with_state :: proc(s: string, p: proc(rawptr, rune) -> bool, state: rawptr) -> (res: string) { i := last_index_proc_with_state(s, p, state, false) if i >= 0 && s[i] >= utf8.RUNE_SELF { _, w := utf8.decode_rune_in_string(s[i:]) @@ -1307,9 +2410,8 @@ trim_right_proc_with_state :: proc(s: string, p: proc(rawptr, rune) -> bool, sta } return s[0:i] } - -// procedure for `trim_*_proc` variants, which has a string rawptr cast + rune comparison -is_in_cutset :: proc(state: rawptr, r: rune) -> bool { +// Procedure for `trim_*_proc` variants, which has a string rawptr cast + rune comparison +is_in_cutset :: proc(state: rawptr, r: rune) -> (res: bool) { if state == nil { return false } @@ -1321,98 +2423,296 @@ is_in_cutset :: proc(state: rawptr, r: rune) -> bool { } return false } +/* +Trims the cutset string from the `s` string -// trims the `cutset` string from the `s` string -trim_left :: proc(s: string, cutset: string) -> string { +Inputs: +- s: The input string +- cutset: The set of characters to be trimmed from the left of the input string + +Returns: +- res: The trimmed string as a slice of the original +*/ +trim_left :: proc(s: string, cutset: string) -> (res: string) { if s == "" || cutset == "" { return s } state := cutset return trim_left_proc_with_state(s, is_in_cutset, &state) } +/* +Trims the cutset string from the `s` string from the right -// trims the `cutset` string from the `s` string from the right -trim_right :: proc(s: string, cutset: string) -> string { +Inputs: +- s: The input string +- cutset: The set of characters to be trimmed from the right of the input string + +Returns: +- res: The trimmed string as a slice of the original +*/ +trim_right :: proc(s: string, cutset: string) -> (res: string) { if s == "" || cutset == "" { return s } state := cutset return trim_right_proc_with_state(s, is_in_cutset, &state) } +/* +Trims the cutset string from the `s` string, both from left and right -// trims the `cutset` string from the `s` string, both from left and right -trim :: proc(s: string, cutset: string) -> string { +Inputs: +- s: The input string +- cutset: The set of characters to be trimmed from both sides of the input string + +Returns: +- res: The trimmed string as a slice of the original +*/ +trim :: proc(s: string, cutset: string) -> (res: string) { return trim_right(trim_left(s, cutset), cutset) } +/* +Trims until a valid non-space rune from the left, "\t\txyz\t\t" -> "xyz\t\t" -// trims until a valid non space rune: "\t\txyz\t\t" -> "xyz\t\t" -trim_left_space :: proc(s: string) -> string { +Inputs: +- s: The input string + +Returns: +- res: The trimmed string as a slice of the original +*/ +trim_left_space :: proc(s: string) -> (res: string) { return trim_left_proc(s, is_space) } +/* +Trims from the right until a valid non-space rune, "\t\txyz\t\t" -> "\t\txyz" -// trims from the right until a valid non space rune: "\t\txyz\t\t" -> "\t\txyz" -trim_right_space :: proc(s: string) -> string { +Inputs: +- s: The input string + +Returns: +- res: The trimmed string as a slice of the original +*/ +trim_right_space :: proc(s: string) -> (res: string) { return trim_right_proc(s, is_space) } +/* +Trims from both sides until a valid non-space rune, "\t\txyz\t\t" -> "xyz" -// trims from both sides until a valid non space rune: "\t\txyz\t\t" -> "xyz" -trim_space :: proc(s: string) -> string { +Inputs: +- s: The input string + +Returns: +- res: The trimmed string as a slice of the original +*/ +trim_space :: proc(s: string) -> (res: string) { return trim_right_space(trim_left_space(s)) } +/* +Trims null runes from the left, "\x00\x00testing\x00\x00" -> "testing\x00\x00" -// trims nul runes from the left: "\x00\x00testing\x00\x00" -> "testing\x00\x00" -trim_left_null :: proc(s: string) -> string { +Inputs: +- s: The input string + +Returns: +- res: The trimmed string as a slice of the original +*/ +trim_left_null :: proc(s: string) -> (res: string) { return trim_left_proc(s, is_null) } +/* +Trims null runes from the right, "\x00\x00testing\x00\x00" -> "\x00\x00testing" -// trims nul runes from the right: "\x00\x00testing\x00\x00" -> "\x00\x00testing" -trim_right_null :: proc(s: string) -> string { +Inputs: +- s: The input string + +Returns: +- res: The trimmed string as a slice of the original +*/ +trim_right_null :: proc(s: string) -> (res: string) { return trim_right_proc(s, is_null) } +/* +Trims null runes from both sides, "\x00\x00testing\x00\x00" -> "testing" -// trims nul runes from both sides: "\x00\x00testing\x00\x00" -> "testing" -trim_null :: proc(s: string) -> string { +Inputs: +- s: The input string +Returns: +- res: The trimmed string as a slice of the original +*/ +trim_null :: proc(s: string) -> (res: string) { return trim_right_null(trim_left_null(s)) } - /* - trims a `prefix` string from the start of the `s` string and returns the trimmed string - returns the input string `s` when no prefix was found +Trims a `prefix` string from the start of the `s` string and returns the trimmed string + +Inputs: +- s: The input string +- prefix: The prefix string to be removed + +Returns: +- res: The trimmed string as a slice of original, or the input string if no prefix was found + +Example: + + import "core:fmt" + import "core:strings" + + trim_prefix_example :: proc() { + fmt.println(strings.trim_prefix("testing", "test")) + fmt.println(strings.trim_prefix("testing", "abc")) + } + +Output: + + ing + testing - strings.trim_prefix("testing", "test") -> "ing" - strings.trim_prefix("testing", "abc") -> "testing" */ -trim_prefix :: proc(s, prefix: string) -> string { +trim_prefix :: proc(s, prefix: string) -> (res: string) { if has_prefix(s, prefix) { return s[len(prefix):] } return s } - /* - trims a `suffix` string from the end of the `s` string and returns the trimmed string - returns the input string `s` when no suffix was found +Trims a `suffix` string from the end of the `s` string and returns the trimmed string + +Inputs: +- s: The input string +- suffix: The suffix string to be removed + +Returns: +- res: The trimmed string as a slice of original, or the input string if no suffix was found + +Example: + + import "core:fmt" + import "core:strings" + + trim_suffix_example :: proc() { + fmt.println(strings.trim_suffix("todo.txt", ".txt")) + fmt.println(strings.trim_suffix("todo.doc", ".txt")) + } + +Output: + + todo + todo.doc - strings.trim_suffix("todo.txt", ".txt") -> "todo" - strings.trim_suffix("todo.doc", ".txt") -> "todo.doc" */ -trim_suffix :: proc(s, suffix: string) -> string { +trim_suffix :: proc(s, suffix: string) -> (res: string) { if has_suffix(s, suffix) { return s[:len(s)-len(suffix)] } return s } - /* - splits the input string `s` by all possible `substrs` []string - returns the allocated []string, nil on any empty substring or no matches +Splits the input string `s` by all possible `substrs` and returns an allocated array of strings + +*Allocates Using Provided Allocator* + +Inputs: +- s: The input string +- substrs: An array of substrings used for splitting +- allocator: (default is context.allocator) + +Returns: +- res: An array of strings, or nil on empty substring or no matches +- err: An optional allocator error if one occured, `nil` otherwise + +NOTE: Allocation occurs for the array, the splits are all views of the original string. + +Example: + + import "core:fmt" + import "core:strings" + + split_multi_example :: proc() { + splits := [?]string { "---", "~~~", ".", "_", "," } + res := strings.split_multi("testing,this.out_nice---done~~~last", splits[:]) + fmt.println(res) // -> [testing, this, out, nice, done, last] + } + +Output: + + ["testing", "this", "out", "nice", "done", "last"] - splits := [?]string { "---", "~~~", ".", "_", "," } - res := strings.split_multi("testing,this.out_nice---done~~~last", splits[:]) - fmt.eprintln(res) // -> [testing, this, out, nice, done, last] */ -split_multi :: proc(s: string, substrs: []string, allocator := context.allocator) -> (buf: []string) #no_bounds_check { +split_multi :: proc(s: string, substrs: []string, allocator := context.allocator) -> (res: []string, err: mem.Allocator_Error) #optional_allocator_error #no_bounds_check { if s == "" || len(substrs) <= 0 { + return nil, nil + } + + // disallow "" substr + for substr in substrs { + if len(substr) == 0 { + return nil, nil + } + } + + // calculate the needed len of `results` + n := 1 + for it := s; len(it) > 0; { + i, w := index_multi(it, substrs) + if i < 0 { + break + } + n += 1 + it = it[i+w:] + } + + results := make([dynamic]string, 0, n, allocator) or_return + { + it := s + for len(it) > 0 { + i, w := index_multi(it, substrs) + if i < 0 { + break + } + part := it[:i] + append(&results, part) + it = it[i+w:] + } + append(&results, it) + } + assert(len(results) == n) + return results[:], nil +} +/* +Splits the input string `s` by all possible `substrs` in an iterator fashion. The full string is returned if no match. + +Inputs: +- it: A pointer to the input string +- substrs: An array of substrings used for splitting + +Returns: +- res: The split string +- ok: `true` if an iteration result was returned, `false` if the iterator has reached the end + +Example: + + import "core:fmt" + import "core:strings" + + split_multi_iterate_example :: proc() { + it := "testing,this.out_nice---done~~~last" + splits := [?]string { "---", "~~~", ".", "_", "," } + for str in strings.split_multi_iterate(&it, splits[:]) { + fmt.println(str) + } + } + +Output: + + testing + this + out + nice + done + last + +*/ +split_multi_iterate :: proc(it: ^string, substrs: []string) -> (res: string, ok: bool) #no_bounds_check { + if it == nil || len(it) == 0 || len(substrs) <= 0 { return } @@ -1423,137 +2723,52 @@ split_multi :: proc(s: string, substrs: []string, allocator := context.allocator } } - // TODO maybe remove duplicate substrs - // sort substrings by string size, largest to smallest - temp_substrs := slice.clone(substrs, context.temp_allocator) - slice.sort_by(temp_substrs, proc(a, b: string) -> bool { - return len(a) > len(b) - }) - - substrings_found: int - temp := s - - // count substr results found in string - first_pass: for len(temp) > 0 { - for substr in temp_substrs { - size := len(substr) - - // check range and compare string to substr - if size <= len(temp) && temp[:size] == substr { - substrings_found += 1 - temp = temp[size:] - continue first_pass - } - } - - // step through string - _, skip := utf8.decode_rune_in_string(temp[:]) - temp = temp[skip:] + // calculate the needed len of `results` + i, w := index_multi(it^, substrs) + if i >= 0 { + res = it[:i] + it^ = it[i+w:] + } else { + // last value + res = it^ + it^ = it[len(it):] } - - // skip when no results - if substrings_found < 1 { - return - } - - buf = make([]string, substrings_found + 1, allocator) - buf_index: int - temp = s - temp_old := temp - - // gather results in the same fashion - second_pass: for len(temp) > 0 { - for substr in temp_substrs { - size := len(substr) - - // check range and compare string to substr - if size <= len(temp) && temp[:size] == substr { - buf[buf_index] = temp_old[:len(temp_old) - len(temp)] - buf_index += 1 - temp = temp[size:] - temp_old = temp - continue second_pass - } - } - - // step through string - _, skip := utf8.decode_rune_in_string(temp[:]) - temp = temp[skip:] - } - - buf[buf_index] = temp_old[:] - - return buf -} - -// state for the split multi iterator -Split_Multi :: struct { - temp: string, - temp_old: string, - substrs: []string, -} - -// returns split multi state with sorted `substrs` -split_multi_init :: proc(s: string, substrs: []string) -> Split_Multi { - // sort substrings, largest to smallest - temp_substrs := slice.clone(substrs, context.temp_allocator) - slice.sort_by(temp_substrs, proc(a, b: string) -> bool { - return len(a) > len(b) - }) - - return { - temp = s, - temp_old = s, - substrs = temp_substrs, - } -} - -/* - splits the input string `s` by all possible `substrs` []string in an iterator fashion - returns the split string every iteration, the full string on no match - - splits := [?]string { "---", "~~~", ".", "_", "," } - state := strings.split_multi_init("testing,this.out_nice---done~~~last", splits[:]) - for str in strings.split_multi_iterate(&state) { - fmt.eprintln(str) // every iteration -> [testing, this, out, nice, done, last] - } -*/ -split_multi_iterate :: proc(using sm: ^Split_Multi) -> (res: string, ok: bool) #no_bounds_check { - pass: for len(temp) > 0 { - for substr in substrs { - size := len(substr) - - // check range and compare string to substr - if size <= len(temp) && temp[:size] == substr { - res = temp_old[:len(temp_old) - len(temp)] - temp = temp[size:] - temp_old = temp - ok = true - return - } - } - - // step through string - _, skip := utf8.decode_rune_in_string(temp[:]) - temp = temp[skip:] - } - - // allow last iteration - if temp_old != "" { - res = temp_old[:] - ok = true - temp_old = "" - } - + ok = true return } +/* +Replaces invalid UTF-8 characters in the input string with a specified replacement string. Adjacent invalid bytes are only replaced once. -// scrub scruvs invalid utf-8 characters and replaces them with the replacement string -// Adjacent invalid bytes are only replaced once -scrub :: proc(s: string, replacement: string, allocator := context.allocator) -> string { +*Allocates Using Provided Allocator* + +Inputs: +- s: The input string +- replacement: The string used to replace invalid UTF-8 characters +- allocator: (default is context.allocator) + +Returns: +- res: A new string with invalid UTF-8 characters replaced +- err: An optional allocator error if one occured, `nil` otherwise + +Example: + + import "core:fmt" + import "core:strings" + + scrub_example :: proc() { + text := "Hello\xC0\x80World" + fmt.println(strings.scrub(text, "?")) // -> "Hello?World" + } + +Output: + + Hello? + +*/ +scrub :: proc(s: string, replacement: string, allocator := context.allocator) -> (res: string, err: mem.Allocator_Error) #optional_allocator_error { str := s b: Builder - builder_init(&b, 0, len(s), allocator) + builder_init(&b, 0, len(s), allocator) or_return has_error := false cursor := 0 @@ -1579,20 +2794,41 @@ scrub :: proc(s: string, replacement: string, allocator := context.allocator) -> str = str[w:] } - return to_string(b) + return to_string(b), nil } - /* - returns a reversed version of the `s` string +Reverses the input string `s` + +*Allocates Using Provided Allocator* + +Inputs: +- s: The input string +- allocator: (default is context.allocator) + +Returns: +- res: A reversed version of the input string +- err: An optional allocator error if one occured, `nil` otherwise + +Example: + + import "core:fmt" + import "core:strings" + + reverse_example :: proc() { + a := "abcxyz" + b := strings.reverse(a) + fmt.println(a, b) + } + +Output: + + abcxyz zyxcba - a := "abcxyz" - b := strings.reverse(a) - fmt.eprintln(a, b) // abcxyz zyxcba */ -reverse :: proc(s: string, allocator := context.allocator) -> string { +reverse :: proc(s: string, allocator := context.allocator) -> (res: string, err: mem.Allocator_Error) #optional_allocator_error { str := s n := len(str) - buf := make([]byte, n) + buf := make([]byte, n) or_return i := n for len(str) > 0 { @@ -1601,28 +2837,50 @@ reverse :: proc(s: string, allocator := context.allocator) -> string { copy(buf[i:], str[:w]) str = str[w:] } - return string(buf) + return string(buf), nil } - /* - expands the string to a grid spaced by `tab_size` whenever a `\t` character appears - returns the tabbed string, panics on tab_size <= 0 +Expands the input string by replacing tab characters with spaces to align to a specified tab size + +*Allocates Using Provided Allocator* + +Inputs: +- s: The input string +- tab_size: The number of spaces to use for each tab character +- allocator: (default is context.allocator) + +Returns: +- res: A new string with tab characters expanded to the specified tab size +- err: An optional allocator error if one occured, `nil` otherwise + +WARNING: Panics if tab_size <= 0 + +Example: + + import "core:fmt" + import "core:strings" + + expand_tabs_example :: proc() { + text := "abc1\tabc2\tabc3" + fmt.println(strings.expand_tabs(text, 4)) + } + +Output: + + abc1 abc2 abc3 - strings.expand_tabs("abc1\tabc2\tabc3", 4) -> abc1 abc2 abc3 - strings.expand_tabs("abc1\tabc2\tabc3", 5) -> abc1 abc2 abc3 - strings.expand_tabs("abc1\tabc2\tabc3", 6) -> abc1 abc2 abc3 */ -expand_tabs :: proc(s: string, tab_size: int, allocator := context.allocator) -> string { +expand_tabs :: proc(s: string, tab_size: int, allocator := context.allocator) -> (res: string, err: mem.Allocator_Error) #optional_allocator_error { if tab_size <= 0 { panic("tab size must be positive") } if s == "" { - return "" + return "", nil } b: Builder - builder_init(&b, allocator) + builder_init(&b, allocator) or_return writer := to_writer(&b) str := s column: int @@ -1651,18 +2909,45 @@ expand_tabs :: proc(s: string, tab_size: int, allocator := context.allocator) -> str = str[w:] } - return to_string(b) + return to_string(b), nil } - /* - splits the `str` string by the seperator `sep` string and returns 3 parts - `head`: before the split, `match`: the seperator, `tail`: the end of the split - returns the input string when the `sep` was not found +Splits the input string `str` by the separator `sep` string and returns 3 parts. The values are slices of the original string. + +Inputs: +- str: The input string +- sep: The separator string + +Returns: +- head: the string before the split +- match: the seperator string +- tail: the string after the split + +Example: + + import "core:fmt" + import "core:strings" + + partition_example :: proc() { + text := "testing this out" + head, match, tail := strings.partition(text, " this ") // -> head: "testing", match: " this ", tail: "out" + fmt.println(head, match, tail) + head, match, tail = strings.partition(text, "hi") // -> head: "testing t", match: "hi", tail: "s out" + fmt.println(head, match, tail) + head, match, tail = strings.partition(text, "xyz") // -> head: "testing this out", match: "", tail: "" + fmt.println(head) + fmt.println(match == "") + fmt.println(tail == "") + } + +Output: + + testing this out + testing t hi s out + testing this out + true + true - text := "testing this out" - strings.partition(text, " this ") -> head: "testing", match: " this ", tail: "out" - strings.partition(text, "hi") -> head: "testing t", match: "hi", tail: "s out" - strings.partition(text, "xyz") -> head: "testing this out", match: "", tail: "" */ partition :: proc(str, sep: string) -> (head, match, tail: string) { i := index(str, sep) @@ -1676,11 +2961,24 @@ partition :: proc(str, sep: string) -> (head, match, tail: string) { tail = str[i+len(sep):] return } - +// Alias for centre_justify center_justify :: centre_justify // NOTE(bill): Because Americans exist +/* +Centers the input string within a field of specified length by adding pad string on both sides, if its length is less than the target length. -// centre_justify returns a string with a pad string at boths sides if the str's rune length is smaller than length -centre_justify :: proc(str: string, length: int, pad: string, allocator := context.allocator) -> string { +*Allocates Using Provided Allocator* + +Inputs: +- str: The input string +- length: The desired length of the centered string, in runes +- pad: The string used for padding on both sides +- allocator: (default is context.allocator) + +Returns: +- res: A new string centered within a field of the specified length +- err: An optional allocator error if one occured, `nil` otherwise +*/ +centre_justify :: proc(str: string, length: int, pad: string, allocator := context.allocator) -> (res: string, err: mem.Allocator_Error) #optional_allocator_error { n := rune_count(str) if n >= length || pad == "" { return clone(str, allocator) @@ -1690,8 +2988,7 @@ centre_justify :: proc(str: string, length: int, pad: string, allocator := conte pad_len := rune_count(pad) b: Builder - builder_init(&b, allocator) - builder_grow(&b, len(str) + (remains/pad_len + 1)*len(pad)) + builder_init(&b, 0, len(str) + (remains/pad_len + 1)*len(pad), allocator) or_return w := to_writer(&b) @@ -1699,11 +2996,24 @@ centre_justify :: proc(str: string, length: int, pad: string, allocator := conte io.write_string(w, str) write_pad_string(w, pad, pad_len, (remains+1)/2) - return to_string(b) + return to_string(b), nil } +/* +Left-justifies the input string within a field of specified length by adding pad string on the right side, if its length is less than the target length. -// left_justify returns a string with a pad string at right side if the str's rune length is smaller than length -left_justify :: proc(str: string, length: int, pad: string, allocator := context.allocator) -> string { +*Allocates Using Provided Allocator* + +Inputs: +- str: The input string +- length: The desired length of the left-justified string +- pad: The string used for padding on the right side +- allocator: (default is context.allocator) + +Returns: +- res: A new string left-justified within a field of the specified length +- err: An optional allocator error if one occured, `nil` otherwise +*/ +left_justify :: proc(str: string, length: int, pad: string, allocator := context.allocator) -> (res: string, err: mem.Allocator_Error) #optional_allocator_error { n := rune_count(str) if n >= length || pad == "" { return clone(str, allocator) @@ -1714,18 +3024,31 @@ left_justify :: proc(str: string, length: int, pad: string, allocator := context b: Builder builder_init(&b, allocator) - builder_grow(&b, len(str) + (remains/pad_len + 1)*len(pad)) + builder_init(&b, 0, len(str) + (remains/pad_len + 1)*len(pad), allocator) or_return w := to_writer(&b) io.write_string(w, str) write_pad_string(w, pad, pad_len, remains) - return to_string(b) + return to_string(b), nil } +/* +Right-justifies the input string within a field of specified length by adding pad string on the left side, if its length is less than the target length. -// right_justify returns a string with a pad string at left side if the str's rune length is smaller than length -right_justify :: proc(str: string, length: int, pad: string, allocator := context.allocator) -> string { +*Allocates Using Provided Allocator* + +Inputs: +- str: The input string +- length: The desired length of the right-justified string +- pad: The string used for padding on the left side +- allocator: (default is context.allocator) + +Returns: +- res: A new string right-justified within a field of the specified length +- err: An optional allocator error if one occured, `nil` otherwise +*/ +right_justify :: proc(str: string, length: int, pad: string, allocator := context.allocator) -> (res: string, err: mem.Allocator_Error) #optional_allocator_error { n := rune_count(str) if n >= length || pad == "" { return clone(str, allocator) @@ -1736,19 +3059,24 @@ right_justify :: proc(str: string, length: int, pad: string, allocator := contex b: Builder builder_init(&b, allocator) - builder_grow(&b, len(str) + (remains/pad_len + 1)*len(pad)) + builder_init(&b, 0, len(str) + (remains/pad_len + 1)*len(pad), allocator) or_return w := to_writer(&b) write_pad_string(w, pad, pad_len, remains) io.write_string(w, str) - return to_string(b) + return to_string(b), nil } +/* +Writes a given pad string a specified number of times to an `io.Writer` - - - +Inputs: +- w: The io.Writer to write the pad string to +- pad: The pad string to be written +- pad_len: The length of the pad string, in runes +- remains: The number of times to write the pad string, in runes +*/ @private write_pad_string :: proc(w: io.Writer, pad: string, pad_len, remains: int) { repeats := remains / pad_len @@ -1766,11 +3094,20 @@ write_pad_string :: proc(w: io.Writer, pad: string, pad_len, remains: int) { p = p[width:] } } +/* +Splits a string into a slice of substrings at each instance of one or more consecutive white space characters, as defined by `unicode.is_space` +*Allocates Using Provided Allocator* -// fields splits the string s around each instance of one or more consecutive white space character, defined by unicode.is_space -// returning a slice of substrings of s or an empty slice if s only contains white space -fields :: proc(s: string, allocator := context.allocator) -> []string #no_bounds_check { +Inputs: +- s: The input string +- allocator: (default is context.allocator) + +Returns: +- res: A slice of substrings of the input string, or an empty slice if the input string only contains white space +- err: An optional allocator error if one occured, `nil` otherwise +*/ +fields :: proc(s: string, allocator := context.allocator) -> (res: []string, err: mem.Allocator_Error) #optional_allocator_error #no_bounds_check { n := 0 was_space := 1 set_bits := u8(0) @@ -1789,10 +3126,10 @@ fields :: proc(s: string, allocator := context.allocator) -> []string #no_bounds } if n == 0 { - return nil + return nil, nil } - a := make([]string, n, allocator) + a := make([]string, n, allocator) or_return na := 0 field_start := 0 i := 0 @@ -1816,18 +3153,26 @@ fields :: proc(s: string, allocator := context.allocator) -> []string #no_bounds if field_start < len(s) { a[na] = s[field_start:] } - return a + return a, nil } +/* +Splits a string into a slice of substrings at each run of unicode code points `r` satisfying the predicate `f(r)` +*Allocates Using Provided Allocator* -// fields_proc splits the string s at each run of unicode code points `ch` satisfying f(ch) -// returns a slice of substrings of s -// If all code points in s satisfy f(ch) or string is empty, an empty slice is returned -// -// fields_proc makes no guarantee about the order in which it calls f(ch) -// it assumes that `f` always returns the same value for a given ch -fields_proc :: proc(s: string, f: proc(rune) -> bool, allocator := context.allocator) -> []string #no_bounds_check { - substrings := make([dynamic]string, 0, 32, allocator) +Inputs: +- s: The input string +- f: A predicate function to determine the split points +- allocator: (default is context.allocator) + +NOTE: fields_proc makes no guarantee about the order in which it calls `f(r)`, it assumes that `f` always returns the same value for a given `r` + +Returns: +- res: A slice of substrings of the input string, or an empty slice if all code points in the input string satisfy the predicate or if the input string is empty +- err: An optional allocator error if one occured, `nil` otherwise +*/ +fields_proc :: proc(s: string, f: proc(rune) -> bool, allocator := context.allocator) -> (res: []string, err: mem.Allocator_Error) #optional_allocator_error #no_bounds_check { + substrings := make([dynamic]string, 0, 32, allocator) or_return start, end := -1, -1 for r, offset in s { @@ -1850,12 +3195,18 @@ fields_proc :: proc(s: string, f: proc(rune) -> bool, allocator := context.alloc append(&substrings, s[start : len(s)]) } - return substrings[:] + return substrings[:], nil } +/* +Retrieves the first non-space substring from a mutable string reference and advances the reference. `s` is advanced from any space after the substring, or be an empty string if the substring was the remaining characters +Inputs: +- s: A mutable string reference to be iterated -// `fields_iterator` returns the first run of characters in `s` that does not contain white space, defined by `unicode.is_space` -// `s` will then start from any space after the substring, or be an empty string if the substring was the remaining characters +Returns: +- field: The first non-space substring found +- ok: A boolean indicating if a non-space substring was found +*/ fields_iterator :: proc(s: ^string) -> (field: string, ok: bool) { start, end := -1, -1 for r, offset in s { @@ -1884,11 +3235,24 @@ fields_iterator :: proc(s: ^string) -> (field: string, ok: bool) { s^ = s[len(s):] return } +/* +Computes the Levenshtein edit distance between two strings -// `levenshtein_distance` returns the Levenshtein edit distance between 2 strings. -// This is a single-row-version of the Wagner–Fischer algorithm, based on C code by Martin Ettl. -// Note: allocator isn't used if the length of string b in runes is smaller than 64. -levenshtein_distance :: proc(a, b: string, allocator := context.allocator) -> int { +*Allocates Using Provided Allocator (deletion occurs internal to proc)* + +NOTE: Does not perform internal allocation if length of string `b`, in runes, is smaller than 64 + +Inputs: +- a, b: The two strings to compare +- allocator: (default is context.allocator) + +Returns: +- res: The Levenshtein edit distance between the two strings +- err: An optional allocator error if one occured, `nil` otherwise + +NOTE: This implementation is a single-row-version of the Wagner–Fischer algorithm, based on C code by Martin Ettl. +*/ +levenshtein_distance :: proc(a, b: string, allocator := context.allocator) -> (res: int, err: mem.Allocator_Error) #optional_allocator_error { LEVENSHTEIN_DEFAULT_COSTS: []int : { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, @@ -1902,16 +3266,16 @@ levenshtein_distance :: proc(a, b: string, allocator := context.allocator) -> in m, n := utf8.rune_count_in_string(a), utf8.rune_count_in_string(b) if m == 0 { - return n + return n, nil } if n == 0 { - return m + return m, nil } costs: []int if n + 1 > len(LEVENSHTEIN_DEFAULT_COSTS) { - costs = make([]int, n + 1, allocator) + costs = make([]int, n + 1, allocator) or_return for k in 0..=n { costs[k] = k } @@ -1944,5 +3308,5 @@ levenshtein_distance :: proc(a, b: string, allocator := context.allocator) -> in i += 1 } - return costs[n] + return costs[n], nil } diff --git a/core/sync/extended.odin b/core/sync/extended.odin index 7370d6544..c76ab504b 100644 --- a/core/sync/extended.odin +++ b/core/sync/extended.odin @@ -1,11 +1,13 @@ package sync import "core:time" +import vg "core:sys/valgrind" +_ :: vg // A Wait_Group waits for a collection of threads to finish // // A Wait_Group must not be copied after first use -Wait_Group :: struct { +Wait_Group :: struct #no_copy { counter: int, mutex: Mutex, cond: Cond, @@ -99,7 +101,7 @@ Example: fmt.println("Finished") } */ -Barrier :: struct { +Barrier :: struct #no_copy { mutex: Mutex, cond: Cond, index: int, @@ -108,6 +110,9 @@ Barrier :: struct { } barrier_init :: proc "contextless" (b: ^Barrier, thread_count: int) { + when ODIN_VALGRIND_SUPPORT { + vg.helgrind_barrier_resize_pre(b, uint(thread_count)) + } b.index = 0 b.generation_id = 0 b.thread_count = thread_count @@ -116,6 +121,9 @@ barrier_init :: proc "contextless" (b: ^Barrier, thread_count: int) { // Block the current thread until all threads have rendezvoused // Barrier can be reused after all threads rendezvoused once, and can be used continuously barrier_wait :: proc "contextless" (b: ^Barrier) -> (is_leader: bool) { + when ODIN_VALGRIND_SUPPORT { + vg.helgrind_barrier_wait_pre(b) + } guard(&b.mutex) local_gen := b.generation_id b.index += 1 @@ -133,7 +141,7 @@ barrier_wait :: proc "contextless" (b: ^Barrier) -> (is_leader: bool) { } -Auto_Reset_Event :: struct { +Auto_Reset_Event :: struct #no_copy { // status == 0: Event is reset and no threads are waiting // status == 1: Event is signaled // status == -N: Event is reset and N threads are waiting @@ -164,7 +172,7 @@ auto_reset_event_wait :: proc "contextless" (e: ^Auto_Reset_Event) { -Ticket_Mutex :: struct { +Ticket_Mutex :: struct #no_copy { ticket: uint, serving: uint, } @@ -186,7 +194,7 @@ ticket_mutex_guard :: proc "contextless" (m: ^Ticket_Mutex) -> bool { } -Benaphore :: struct { +Benaphore :: struct #no_copy { counter: i32, sema: Sema, } @@ -214,7 +222,7 @@ benaphore_guard :: proc "contextless" (m: ^Benaphore) -> bool { return true } -Recursive_Benaphore :: struct { +Recursive_Benaphore :: struct #no_copy { counter: int, owner: int, recursion: i32, @@ -276,7 +284,7 @@ recursive_benaphore_guard :: proc "contextless" (m: ^Recursive_Benaphore) -> boo // Once is a data value that will perform exactly on action. // // A Once must not be copied after first use. -Once :: struct { +Once :: struct #no_copy { m: Mutex, done: bool, } @@ -364,7 +372,7 @@ once_do_with_data_contextless :: proc "contextless" (o: ^Once, fn: proc "context // blocks for the specified duration. // * The `unpark` procedure automatically makes the token available if it // was not already. -Parker :: struct { +Parker :: struct #no_copy { state: Futex, } diff --git a/core/sync/futex_openbsd.odin b/core/sync/futex_openbsd.odin index e02221277..4883a0841 100644 --- a/core/sync/futex_openbsd.odin +++ b/core/sync/futex_openbsd.odin @@ -3,7 +3,6 @@ package sync import "core:c" -import "core:os" import "core:time" FUTEX_WAIT :: 1 @@ -14,11 +13,16 @@ FUTEX_PRIVATE_FLAG :: 128 FUTEX_WAIT_PRIVATE :: (FUTEX_WAIT | FUTEX_PRIVATE_FLAG) FUTEX_WAKE_PRIVATE :: (FUTEX_WAKE | FUTEX_PRIVATE_FLAG) +ETIMEDOUT :: 60 + + foreign import libc "system:c" foreign libc { @(link_name="futex") _unix_futex :: proc "c" (f: ^Futex, op: c.int, val: u32, timeout: rawptr) -> c.int --- + + @(link_name="__errno") __errno :: proc() -> ^int --- } _futex_wait :: proc "contextless" (f: ^Futex, expected: u32) -> bool { @@ -28,7 +32,7 @@ _futex_wait :: proc "contextless" (f: ^Futex, expected: u32) -> bool { return true } - if os.Errno(os.get_last_error()) == os.ETIMEDOUT { + if __errno()^ == ETIMEDOUT { return false } @@ -54,7 +58,7 @@ _futex_wait_with_timeout :: proc "contextless" (f: ^Futex, expected: u32, durati return true } - if os.Errno(os.get_last_error()) == os.ETIMEDOUT { + if __errno()^ == ETIMEDOUT { return false } diff --git a/core/sync/futex_wasm.odin b/core/sync/futex_wasm.odin index 621f4edaa..248542836 100644 --- a/core/sync/futex_wasm.odin +++ b/core/sync/futex_wasm.odin @@ -1,5 +1,5 @@ //+private -//+build wasm32, wasm64 +//+build wasm32, wasm64p32 package sync import "core:intrinsics" diff --git a/core/sync/primitives.odin b/core/sync/primitives.odin index 00d7812a8..b8bcfad70 100644 --- a/core/sync/primitives.odin +++ b/core/sync/primitives.odin @@ -11,7 +11,7 @@ current_thread_id :: proc "contextless" () -> int { // The zero value for a Mutex is an unlocked mutex // // A Mutex must not be copied after first use -Mutex :: struct { +Mutex :: struct #no_copy { impl: _Mutex, } @@ -47,7 +47,7 @@ mutex_guard :: proc "contextless" (m: ^Mutex) -> bool { // The zero value for a RW_Mutex is an unlocked mutex // // A RW_Mutex must not be copied after first use -RW_Mutex :: struct { +RW_Mutex :: struct #no_copy { impl: _RW_Mutex, } @@ -111,7 +111,7 @@ rw_mutex_shared_guard :: proc "contextless" (m: ^RW_Mutex) -> bool { // The zero value for a Recursive_Mutex is an unlocked mutex // // A Recursive_Mutex must not be copied after first use -Recursive_Mutex :: struct { +Recursive_Mutex :: struct #no_copy { impl: _Recursive_Mutex, } @@ -144,7 +144,7 @@ recursive_mutex_guard :: proc "contextless" (m: ^Recursive_Mutex) -> bool { // waiting for signalling the occurence of an event // // A Cond must not be copied after first use -Cond :: struct { +Cond :: struct #no_copy { impl: _Cond, } @@ -172,7 +172,7 @@ cond_broadcast :: proc "contextless" (c: ^Cond) { // Posting to the semaphore increases the count by one, or the provided amount. // // A Sema must not be copied after first use -Sema :: struct { +Sema :: struct #no_copy { impl: _Sema, } @@ -236,4 +236,4 @@ _panic :: proc "contextless" (msg: string) -> ! { runtime.print_string(msg) runtime.print_byte('\n') runtime.trap() -} \ No newline at end of file +} diff --git a/core/sync/primitives_atomic.odin b/core/sync/primitives_atomic.odin index 1abad5875..1b7cdfe35 100644 --- a/core/sync/primitives_atomic.odin +++ b/core/sync/primitives_atomic.odin @@ -13,7 +13,7 @@ Atomic_Mutex_State :: enum Futex { // The zero value for a Atomic_Mutex is an unlocked mutex // // An Atomic_Mutex must not be copied after first use -Atomic_Mutex :: struct { +Atomic_Mutex :: struct #no_copy { state: Atomic_Mutex_State, } @@ -109,7 +109,7 @@ Atomic_RW_Mutex_State_Reader_Mask :: Atomic_RW_Mutex_State(1<<(Atomic_RW_Mutex_S // The zero value for an Atomic_RW_Mutex is an unlocked mutex // // An Atomic_RW_Mutex must not be copied after first use -Atomic_RW_Mutex :: struct { +Atomic_RW_Mutex :: struct #no_copy { state: Atomic_RW_Mutex_State, mutex: Atomic_Mutex, sema: Atomic_Sema, @@ -222,7 +222,7 @@ atomic_rw_mutex_shared_guard :: proc "contextless" (m: ^Atomic_RW_Mutex) -> bool // The zero value for a Recursive_Mutex is an unlocked mutex // // An Atomic_Recursive_Mutex must not be copied after first use -Atomic_Recursive_Mutex :: struct { +Atomic_Recursive_Mutex :: struct #no_copy { owner: int, recursion: int, mutex: Mutex, @@ -285,7 +285,7 @@ atomic_recursive_mutex_guard :: proc "contextless" (m: ^Atomic_Recursive_Mutex) // waiting for signalling the occurence of an event // // An Atomic_Cond must not be copied after first use -Atomic_Cond :: struct { +Atomic_Cond :: struct #no_copy { state: Futex, } @@ -320,7 +320,7 @@ atomic_cond_broadcast :: proc "contextless" (c: ^Atomic_Cond) { // Posting to the semaphore increases the count by one, or the provided amount. // // An Atomic_Sema must not be copied after first use -Atomic_Sema :: struct { +Atomic_Sema :: struct #no_copy { count: Futex, } diff --git a/core/sync/primitives_internal.odin b/core/sync/primitives_internal.odin index d613d821d..23483aef5 100644 --- a/core/sync/primitives_internal.odin +++ b/core/sync/primitives_internal.odin @@ -2,20 +2,31 @@ package sync import "core:time" +import vg "core:sys/valgrind" +_ :: vg _Sema :: struct { atomic: Atomic_Sema, } _sema_post :: proc "contextless" (s: ^Sema, count := 1) { + when ODIN_VALGRIND_SUPPORT { + vg.helgrind_sem_post_pre(s) + } atomic_sema_post(&s.impl.atomic, count) } _sema_wait :: proc "contextless" (s: ^Sema) { atomic_sema_wait(&s.impl.atomic) + when ODIN_VALGRIND_SUPPORT { + vg.helgrind_sem_wait_post(s) + } } _sema_wait_with_timeout :: proc "contextless" (s: ^Sema, duration: time.Duration) -> bool { + when ODIN_VALGRIND_SUPPORT { + defer vg.helgrind_sem_wait_post(s) + } return atomic_sema_wait_with_timeout(&s.impl.atomic, duration) } @@ -26,6 +37,11 @@ _Recursive_Mutex :: struct { } _recursive_mutex_lock :: proc "contextless" (m: ^Recursive_Mutex) { + when ODIN_VALGRIND_SUPPORT { + vg.helgrind_mutex_lock_pre(m, false) + defer vg.helgrind_mutex_lock_post(m) + } + tid := Futex(current_thread_id()) for { prev_owner := atomic_compare_exchange_strong_explicit(&m.impl.owner, 0, tid, .Acquire, .Acquire) @@ -41,6 +57,11 @@ _recursive_mutex_lock :: proc "contextless" (m: ^Recursive_Mutex) { } _recursive_mutex_unlock :: proc "contextless" (m: ^Recursive_Mutex) { + when ODIN_VALGRIND_SUPPORT { + vg.helgrind_mutex_unlock_pre(m) + defer vg.helgrind_mutex_unlock_post(m) + } + m.impl.recursion -= 1 if m.impl.recursion != 0 { return @@ -71,14 +92,26 @@ when ODIN_OS != .Windows { } _mutex_lock :: proc "contextless" (m: ^Mutex) { + when ODIN_VALGRIND_SUPPORT { + vg.helgrind_mutex_lock_pre(m, false) + defer vg.helgrind_mutex_lock_post(m) + } atomic_mutex_lock(&m.impl.mutex) } _mutex_unlock :: proc "contextless" (m: ^Mutex) { + when ODIN_VALGRIND_SUPPORT { + vg.helgrind_mutex_unlock_pre(m) + defer vg.helgrind_mutex_unlock_post(m) + } atomic_mutex_unlock(&m.impl.mutex) } _mutex_try_lock :: proc "contextless" (m: ^Mutex) -> bool { + when ODIN_VALGRIND_SUPPORT { + vg.helgrind_mutex_lock_pre(m, true) + defer vg.helgrind_mutex_lock_post(m) + } return atomic_mutex_try_lock(&m.impl.mutex) } @@ -87,18 +120,32 @@ when ODIN_OS != .Windows { } _cond_wait :: proc "contextless" (c: ^Cond, m: ^Mutex) { + when ODIN_VALGRIND_SUPPORT { + _ = vg.helgrind_cond_wait_pre(c, m) + defer _ = vg.helgrind_cond_wait_post(c, m) + } atomic_cond_wait(&c.impl.cond, &m.impl.mutex) } _cond_wait_with_timeout :: proc "contextless" (c: ^Cond, m: ^Mutex, duration: time.Duration) -> bool { + when ODIN_VALGRIND_SUPPORT { + _ = vg.helgrind_cond_wait_pre(c, m) + defer _ = vg.helgrind_cond_wait_post(c, m) + } return atomic_cond_wait_with_timeout(&c.impl.cond, &m.impl.mutex, duration) } _cond_signal :: proc "contextless" (c: ^Cond) { + when ODIN_VALGRIND_SUPPORT { + vg.helgrind_cond_signal_pre(c) + } atomic_cond_signal(&c.impl.cond) } _cond_broadcast :: proc "contextless" (c: ^Cond) { + when ODIN_VALGRIND_SUPPORT { + vg.helgrind_cond_broadcast_pre(c) + } atomic_cond_broadcast(&c.impl.cond) } @@ -108,11 +155,17 @@ when ODIN_OS != .Windows { } _rw_mutex_lock :: proc "contextless" (rw: ^RW_Mutex) { + when ODIN_VALGRIND_SUPPORT { + vg.helgrind_rwlock_lock_pre(rw, true) + } atomic_rw_mutex_lock(&rw.impl.mutex) } _rw_mutex_unlock :: proc "contextless" (rw: ^RW_Mutex) { atomic_rw_mutex_unlock(&rw.impl.mutex) + when ODIN_VALGRIND_SUPPORT { + vg.helgrind_rwlock_unlock_post(rw, true) + } } _rw_mutex_try_lock :: proc "contextless" (rw: ^RW_Mutex) -> bool { @@ -120,11 +173,17 @@ when ODIN_OS != .Windows { } _rw_mutex_shared_lock :: proc "contextless" (rw: ^RW_Mutex) { + when ODIN_VALGRIND_SUPPORT { + vg.helgrind_rwlock_lock_pre(rw, false) + } atomic_rw_mutex_shared_lock(&rw.impl.mutex) } _rw_mutex_shared_unlock :: proc "contextless" (rw: ^RW_Mutex) { atomic_rw_mutex_shared_unlock(&rw.impl.mutex) + when ODIN_VALGRIND_SUPPORT { + vg.helgrind_rwlock_unlock_post(rw, false) + } } _rw_mutex_try_shared_lock :: proc "contextless" (rw: ^RW_Mutex) -> bool { diff --git a/core/sync/primitives_openbsd.odin b/core/sync/primitives_openbsd.odin index 4072a14e8..ff3ff837f 100644 --- a/core/sync/primitives_openbsd.odin +++ b/core/sync/primitives_openbsd.odin @@ -2,8 +2,14 @@ //+private package sync -import "core:os" +foreign import libc "system:c" + +@(default_calling_convention="c") +foreign libc { + @(link_name="getthrid", private="file") + _unix_getthrid :: proc() -> int --- +} _current_thread_id :: proc "contextless" () -> int { - return os.current_thread_id() + return _unix_getthrid() } diff --git a/core/sync/primitives_wasm.odin b/core/sync/primitives_wasm.odin index ac36404d9..f8d9ab657 100644 --- a/core/sync/primitives_wasm.odin +++ b/core/sync/primitives_wasm.odin @@ -1,5 +1,5 @@ //+private -//+build wasm32, wasm64 +//+build wasm32, wasm64p32 package sync _current_thread_id :: proc "contextless" () -> int { diff --git a/core/sys/darwin/xnu_system_call_helpers.odin b/core/sys/darwin/xnu_system_call_helpers.odin index 9522b9908..c225c77fb 100644 --- a/core/sys/darwin/xnu_system_call_helpers.odin +++ b/core/sys/darwin/xnu_system_call_helpers.odin @@ -97,6 +97,7 @@ clone_to_cstring :: proc(s: string, allocator: runtime.Allocator, loc := #caller sys_open :: proc(path: string, oflag: Open_Flags, mode: Permission) -> (c.int, bool) { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() cmode: u32 = 0 cflags: u32 = 0 @@ -132,30 +133,35 @@ sys_open :: proc(path: string, oflag: Open_Flags, mode: Permission) -> (c.int, b } sys_mkdir :: proc(path: string, mode: Permission) -> bool { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() cpath: cstring = clone_to_cstring(path, context.temp_allocator) cflags := _sys_permission_mode(mode) return syscall_mkdir(cpath, cflags) != -1 } sys_mkdir_at :: proc(fd: c.int, path: string, mode: Permission) -> bool { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() cpath: cstring = clone_to_cstring(path, context.temp_allocator) cflags := _sys_permission_mode(mode) return syscall_mkdir_at(fd, cpath, cflags) != -1 } sys_rmdir :: proc(path: string, mode: Permission) -> bool { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() cpath: cstring = clone_to_cstring(path, context.temp_allocator) cflags := _sys_permission_mode(mode) return syscall_rmdir(cpath, cflags) != -1 } sys_rename :: proc(path: string, new_path: string) -> bool { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() cpath: cstring = clone_to_cstring(path, context.temp_allocator) cnpath: cstring = clone_to_cstring(new_path, context.temp_allocator) return syscall_rename(cpath, cnpath) != -1 } sys_rename_at :: proc(fd: c.int, path: string, to_fd: c.int, new_path: string) -> bool { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() cpath: cstring = clone_to_cstring(path, context.temp_allocator) cnpath: cstring = clone_to_cstring(new_path, context.temp_allocator) return syscall_rename_at(fd, cpath, to_fd, cnpath) != -1 @@ -166,12 +172,14 @@ sys_lseek :: proc(fd: c.int, offset: i64, whence: Offset_From) -> i64 { } sys_chmod :: proc(path: string, mode: Permission) -> bool { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() cpath: cstring = clone_to_cstring(path, context.temp_allocator) cmode := _sys_permission_mode(mode) return syscall_chmod(cpath, cmode) != -1 } sys_lstat :: proc(path: string, status: ^stat) -> bool { + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() cpath: cstring = clone_to_cstring(path, context.temp_allocator) return syscall_lstat(cpath, status) != -1 } diff --git a/core/sys/darwin/xnu_system_call_numbers.odin b/core/sys/darwin/xnu_system_call_numbers.odin index b90373fdc..429d18964 100644 --- a/core/sys/darwin/xnu_system_call_numbers.odin +++ b/core/sys/darwin/xnu_system_call_numbers.odin @@ -1,6 +1,6 @@ package darwin -unix_offset_syscall :: proc(number: System_Call_Number) -> uintptr { +unix_offset_syscall :: proc "contextless" (number: System_Call_Number) -> uintptr { return uintptr(number) + uintptr(0x2000000) } diff --git a/core/sys/darwin/xnu_system_call_wrappers.odin b/core/sys/darwin/xnu_system_call_wrappers.odin index 685f75ffa..c7a6d6bc4 100644 --- a/core/sys/darwin/xnu_system_call_wrappers.odin +++ b/core/sys/darwin/xnu_system_call_wrappers.odin @@ -229,191 +229,191 @@ _Proc_Bsdinfo :: struct { /*--==========================================================================--*/ -syscall_fsync :: #force_inline proc(fildes: c.int) -> bool { +syscall_fsync :: #force_inline proc "contextless" (fildes: c.int) -> bool { return !(cast(bool)intrinsics.syscall(unix_offset_syscall(.fsync), uintptr(fildes))) } -syscall_write :: #force_inline proc (fildes: c.int, buf: ^byte, nbyte: u64) -> bool { +syscall_write :: #force_inline proc "contextless" (fildes: c.int, buf: ^byte, nbyte: u64) -> bool { return !(cast(bool)intrinsics.syscall(unix_offset_syscall(.write), uintptr(fildes), uintptr(buf), uintptr(nbyte))) } -syscall_read :: #force_inline proc(fildes: c.int, buf: ^byte, nbyte: u64) -> i64 { +syscall_read :: #force_inline proc "contextless" (fildes: c.int, buf: ^byte, nbyte: u64) -> i64 { return cast(i64)intrinsics.syscall(unix_offset_syscall(.read), uintptr(fildes), uintptr(buf), uintptr(nbyte)) } -syscall_open :: #force_inline proc(path: cstring, oflag: u32, mode: u32) -> c.int { +syscall_open :: #force_inline proc "contextless" (path: cstring, oflag: u32, mode: u32) -> c.int { return cast(c.int)intrinsics.syscall(unix_offset_syscall(.open), transmute(uintptr)path, uintptr(oflag), uintptr(mode)) } -syscall_close :: #force_inline proc(fd: c.int) -> bool { +syscall_close :: #force_inline proc "contextless" (fd: c.int) -> bool { return !(cast(bool)intrinsics.syscall(unix_offset_syscall(.close), uintptr(fd))) } -syscall_fchmod :: #force_inline proc(fildes: c.int, mode: u32) -> c.int { +syscall_fchmod :: #force_inline proc "contextless" (fildes: c.int, mode: u32) -> c.int { return (cast(c.int)intrinsics.syscall(unix_offset_syscall(.fchmod), uintptr(fildes), uintptr(mode))) } -syscall_chmod :: #force_inline proc(path: cstring, mode: u32) -> c.int { +syscall_chmod :: #force_inline proc "contextless" (path: cstring, mode: u32) -> c.int { return (cast(c.int)intrinsics.syscall(unix_offset_syscall(.chmod), transmute(uintptr)path, uintptr(mode))) } -syscall_mkdir :: #force_inline proc(path: cstring, mode: u32) -> c.int { +syscall_mkdir :: #force_inline proc "contextless" (path: cstring, mode: u32) -> c.int { return (cast(c.int)intrinsics.syscall(unix_offset_syscall(.mkdir), transmute(uintptr)path, uintptr(mode))) } -syscall_mkdir_at :: #force_inline proc(fd: c.int, path: cstring, mode: u32) -> c.int { +syscall_mkdir_at :: #force_inline proc "contextless" (fd: c.int, path: cstring, mode: u32) -> c.int { return (cast(c.int)intrinsics.syscall(unix_offset_syscall(.mkdir), uintptr(fd), transmute(uintptr)path, uintptr(mode))) } -syscall_rmdir :: #force_inline proc(path: cstring, mode: u32) -> c.int { +syscall_rmdir :: #force_inline proc "contextless" (path: cstring, mode: u32) -> c.int { return (cast(c.int)intrinsics.syscall(unix_offset_syscall(.rmdir), transmute(uintptr)path, uintptr(mode))) } -syscall_rename :: #force_inline proc(path_old: cstring, path_new: cstring) -> c.int { +syscall_rename :: #force_inline proc "contextless" (path_old: cstring, path_new: cstring) -> c.int { return (cast(c.int)intrinsics.syscall(unix_offset_syscall(.rename), transmute(uintptr)path_old, transmute(uintptr)path_new)) } -syscall_rename_at :: #force_inline proc(from_fd: c.int, from: cstring, to_fd: c.int, to: cstring) -> c.int { +syscall_rename_at :: #force_inline proc "contextless" (from_fd: c.int, from: cstring, to_fd: c.int, to: cstring) -> c.int { return (cast(c.int)intrinsics.syscall(unix_offset_syscall(.renameat), uintptr(from_fd), transmute(uintptr)from, uintptr(to_fd), transmute(uintptr)to)) } -syscall_lseek :: #force_inline proc(fd: c.int, offset: i64, whence: c.int) -> i64 { +syscall_lseek :: #force_inline proc "contextless" (fd: c.int, offset: i64, whence: c.int) -> i64 { return cast(i64)intrinsics.syscall(unix_offset_syscall(.lseek), uintptr(fd), uintptr(offset), uintptr(whence)) } -syscall_gettid :: #force_inline proc() -> u64 { +syscall_gettid :: #force_inline proc "contextless" () -> u64 { return cast(u64)intrinsics.syscall(unix_offset_syscall(.gettid)) } -syscall_fstat :: #force_inline proc(fd: c.int, status: ^stat) -> c.int { +syscall_fstat :: #force_inline proc "contextless" (fd: c.int, status: ^stat) -> c.int { return cast(c.int)intrinsics.syscall(unix_offset_syscall(.fstat), uintptr(fd), uintptr(status)) } -syscall_lstat :: #force_inline proc(path: cstring, status: ^stat) -> c.int { +syscall_lstat :: #force_inline proc "contextless" (path: cstring, status: ^stat) -> c.int { return cast(c.int)intrinsics.syscall(unix_offset_syscall(.lstat), transmute(uintptr)path, uintptr(status)) } -syscall_stat :: #force_inline proc(path: cstring, status: ^stat) -> c.int { +syscall_stat :: #force_inline proc "contextless" (path: cstring, status: ^stat) -> c.int { return cast(c.int)intrinsics.syscall(unix_offset_syscall(.stat), transmute(uintptr)path, uintptr(status)) } -syscall_fstatat :: #force_inline proc(fd: c.int, path: cstring, status: ^stat) -> c.int { +syscall_fstatat :: #force_inline proc "contextless" (fd: c.int, path: cstring, status: ^stat) -> c.int { return cast(c.int)intrinsics.syscall(unix_offset_syscall(.fstatat), uintptr(fd), transmute(uintptr)path, uintptr(status)) } -syscall_link :: #force_inline proc(path: cstring, to_link: cstring) -> c.int { +syscall_link :: #force_inline proc "contextless" (path: cstring, to_link: cstring) -> c.int { return cast(c.int)intrinsics.syscall(unix_offset_syscall(.link), transmute(uintptr)path, transmute(uintptr)to_link) } -syscall_linkat :: #force_inline proc(fd: c.int, path: cstring, fd2: c.int, to_link: cstring) -> c.int { +syscall_linkat :: #force_inline proc "contextless" (fd: c.int, path: cstring, fd2: c.int, to_link: cstring) -> c.int { return cast(c.int)intrinsics.syscall(unix_offset_syscall(.linkat), uintptr(fd), transmute(uintptr)path, uintptr(fd2), transmute(uintptr)to_link) } -syscall_readlink :: #force_inline proc(path: cstring, buf: ^u8, buf_size: u64) -> i64 { +syscall_readlink :: #force_inline proc "contextless" (path: cstring, buf: ^u8, buf_size: u64) -> i64 { return cast(i64)intrinsics.syscall(unix_offset_syscall(.readlink), transmute(uintptr)path, uintptr(buf), uintptr(buf_size)) } -syscall_readlinkat :: #force_inline proc(fd: c.int, path: cstring, buf: ^u8, buf_size: u64) -> i64 { +syscall_readlinkat :: #force_inline proc "contextless" (fd: c.int, path: cstring, buf: ^u8, buf_size: u64) -> i64 { return cast(i64)intrinsics.syscall(unix_offset_syscall(.readlinkat), uintptr(fd), transmute(uintptr)path, uintptr(buf), uintptr(buf_size)) } -syscall_access :: #force_inline proc(path: cstring, mode: c.int) -> c.int { +syscall_access :: #force_inline proc "contextless" (path: cstring, mode: c.int) -> c.int { return cast(c.int)intrinsics.syscall(unix_offset_syscall(.access), transmute(uintptr)path, uintptr(mode)) } -syscall_faccessat :: #force_inline proc(fd: c.int, path: cstring, mode: c.int, flag: c.int) -> c.int { +syscall_faccessat :: #force_inline proc "contextless" (fd: c.int, path: cstring, mode: c.int, flag: c.int) -> c.int { return cast(c.int)intrinsics.syscall(unix_offset_syscall(.faccessat), uintptr(fd), transmute(uintptr)path, uintptr(mode), uintptr(flag)) } -syscall_getdirentries :: #force_inline proc(fd: c.int, buf: ^u8, nbytes: c.int, base_pointer: ^u32) -> c.int { +syscall_getdirentries :: #force_inline proc "contextless" (fd: c.int, buf: ^u8, nbytes: c.int, base_pointer: ^u32) -> c.int { return cast(c.int)intrinsics.syscall(unix_offset_syscall(.getdirentries), uintptr(fd), uintptr(buf), uintptr(nbytes), uintptr(base_pointer)) } -syscall_truncate :: #force_inline proc (path: cstring, length: off_t) -> c.int { +syscall_truncate :: #force_inline proc "contextless" (path: cstring, length: off_t) -> c.int { return cast(c.int)intrinsics.syscall(unix_offset_syscall(.truncate), transmute(uintptr)path, uintptr(length)) } -syscall_ftruncate :: #force_inline proc (fd: c.int, length: off_t) -> c.int { +syscall_ftruncate :: #force_inline proc "contextless" (fd: c.int, length: off_t) -> c.int { return cast(c.int)intrinsics.syscall(unix_offset_syscall(.ftruncate), uintptr(fd), uintptr(length)) } -syscall_sysctl :: #force_inline proc (name: ^c.int, namelen: c.uint, oldp: rawptr, oldlenp: ^i64, newp: ^i8, newlen: i64) -> c.int { +syscall_sysctl :: #force_inline proc "contextless" (name: ^c.int, namelen: c.uint, oldp: rawptr, oldlenp: ^i64, newp: ^i8, newlen: i64) -> c.int { return cast(c.int)intrinsics.syscall(unix_offset_syscall(.sysctl), uintptr(name), uintptr(namelen), uintptr(oldp), uintptr(oldlenp), uintptr(newp), uintptr(newlen)) } -syscall_copyfile :: #force_inline proc(from: cstring, to: cstring, state: rawptr, flags: u32) -> c.int { +syscall_copyfile :: #force_inline proc "contextless" (from: cstring, to: cstring, state: rawptr, flags: u32) -> c.int { return cast(c.int)intrinsics.syscall(unix_offset_syscall(.copyfile), transmute(uintptr)from, transmute(uintptr)to, uintptr(state), uintptr(flags)) } // think about this? last arg should be more than one -syscall_fcntl :: #force_inline proc(fd: c.int, cmd: c.int, other: rawptr) -> c.int { +syscall_fcntl :: #force_inline proc "contextless" (fd: c.int, cmd: c.int, other: rawptr) -> c.int { return cast(c.int)intrinsics.syscall(unix_offset_syscall(.fsctl), uintptr(fd), uintptr(cmd), uintptr(other)) } -syscall_exit :: #force_inline proc(code: c.int) { +syscall_exit :: #force_inline proc "contextless" (code: c.int) { intrinsics.syscall(unix_offset_syscall(.exit), uintptr(code)) } -syscall_kill :: #force_inline proc(pid: pid_t, sig: c.int) -> c.int { +syscall_kill :: #force_inline proc "contextless" (pid: pid_t, sig: c.int) -> c.int { return cast(c.int)intrinsics.syscall(unix_offset_syscall(.kill), uintptr(pid), uintptr(sig)) } -syscall_dup :: #force_inline proc(fd: c.int) -> c.int { +syscall_dup :: #force_inline proc "contextless" (fd: c.int) -> c.int { return cast(c.int)intrinsics.syscall(unix_offset_syscall(.dup), uintptr(fd)) } -syscall_execve :: #force_inline proc(path: cstring, argv: [^]cstring, env: [^]cstring) -> c.int { +syscall_execve :: #force_inline proc "contextless" (path: cstring, argv: [^]cstring, env: [^]cstring) -> c.int { return cast(c.int)intrinsics.syscall(unix_offset_syscall(.execve), transmute(uintptr)path, transmute(uintptr)argv, transmute(uintptr)env) } -syscall_munmap :: #force_inline proc(addr: rawptr, len: u64) -> c.int { +syscall_munmap :: #force_inline proc "contextless" (addr: rawptr, len: u64) -> c.int { return cast(c.int)intrinsics.syscall(unix_offset_syscall(.mmap), uintptr(addr), uintptr(len)) } -syscall_mmap :: #force_inline proc(addr: ^u8, len: u64, port: c.int, flags: c.int, fd: int, offset: off_t) -> ^u8 { +syscall_mmap :: #force_inline proc "contextless" (addr: ^u8, len: u64, port: c.int, flags: c.int, fd: int, offset: off_t) -> ^u8 { return cast(^u8)intrinsics.syscall(unix_offset_syscall(.mmap), uintptr(addr), uintptr(len), uintptr(port), uintptr(flags), uintptr(fd), uintptr(offset)) } -syscall_flock :: #force_inline proc(fd: c.int, operation: c.int) -> c.int { +syscall_flock :: #force_inline proc "contextless" (fd: c.int, operation: c.int) -> c.int { return cast(c.int)intrinsics.syscall(unix_offset_syscall(.flock), uintptr(fd), uintptr(operation)) } -syscall_utimes :: #force_inline proc(path: cstring, times: ^timeval) -> c.int { +syscall_utimes :: #force_inline proc "contextless" (path: cstring, times: ^timeval) -> c.int { return cast(c.int)intrinsics.syscall(unix_offset_syscall(.utimes), transmute(uintptr)path, uintptr(times)) } -syscall_futimes :: #force_inline proc(fd: c.int, times: ^timeval) -> c.int { +syscall_futimes :: #force_inline proc "contextless" (fd: c.int, times: ^timeval) -> c.int { return cast(c.int)intrinsics.syscall(unix_offset_syscall(.futimes), uintptr(fd), uintptr(times)) } -syscall_adjtime :: #force_inline proc(delta: ^timeval, old_delta: ^timeval) -> c.int { +syscall_adjtime :: #force_inline proc "contextless" (delta: ^timeval, old_delta: ^timeval) -> c.int { return cast(c.int)intrinsics.syscall(unix_offset_syscall(.adjtime), uintptr(delta), uintptr(old_delta)) } -syscall_sysctlbyname :: #force_inline proc(name: cstring, oldp: rawptr, oldlenp: ^i64, newp: rawptr, newlen: i64) -> c.int { +syscall_sysctlbyname :: #force_inline proc "contextless" (name: cstring, oldp: rawptr, oldlenp: ^i64, newp: rawptr, newlen: i64) -> c.int { return cast(c.int)intrinsics.syscall(unix_offset_syscall(.sysctlbyname), transmute(uintptr)name, uintptr(oldp), uintptr(oldlenp), uintptr(newp), uintptr(newlen)) } -syscall_proc_info :: #force_inline proc(num: c.int, pid: u32, flavor: c.int, arg: u64, buffer: rawptr, buffer_size: c.int) -> c.int { +syscall_proc_info :: #force_inline proc "contextless" (num: c.int, pid: u32, flavor: c.int, arg: u64, buffer: rawptr, buffer_size: c.int) -> c.int { return cast(c.int)intrinsics.syscall(unix_offset_syscall(.proc_info), uintptr(num), uintptr(pid), uintptr(flavor), uintptr(arg), uintptr(buffer), uintptr(buffer_size)) } -syscall_openat :: #force_inline proc(fd: int, path: cstring, oflag: u32, mode: u32) -> c.int { +syscall_openat :: #force_inline proc "contextless" (fd: int, path: cstring, oflag: u32, mode: u32) -> c.int { return cast(c.int)intrinsics.syscall(unix_offset_syscall(.openat), uintptr(fd), transmute(uintptr)path, uintptr(oflag), uintptr(mode)) } -syscall_getentropy :: #force_inline proc(buf: [^]u8, buflen: u64) -> c.int { +syscall_getentropy :: #force_inline proc "contextless" (buf: [^]u8, buflen: u64) -> c.int { return cast(c.int)intrinsics.syscall(unix_offset_syscall(.getentropy), uintptr(buf), uintptr(buflen)) } -syscall_pipe :: #force_inline proc(fds: [^]c.int) -> c.int { +syscall_pipe :: #force_inline proc "contextless" (fds: [^]c.int) -> c.int { return cast(c.int)intrinsics.syscall(unix_offset_syscall(.getentropy), uintptr(&fds[0]), uintptr(&fds[1])) } -syscall_chdir :: #force_inline proc(path: cstring) -> c.int { +syscall_chdir :: #force_inline proc "contextless" (path: cstring) -> c.int { return cast(c.int)intrinsics.syscall(unix_offset_syscall(.getentropy), transmute(uintptr)path) } -syscall_fchdir :: #force_inline proc(fd: c.int, path: cstring) -> c.int { +syscall_fchdir :: #force_inline proc "contextless" (fd: c.int, path: cstring) -> c.int { return cast(c.int)intrinsics.syscall(unix_offset_syscall(.getentropy), uintptr(fd), transmute(uintptr)path) -} \ No newline at end of file +} diff --git a/core/sys/info/cpu_intel.odin b/core/sys/info/cpu_intel.odin index 8cd723203..5a11863d4 100644 --- a/core/sys/info/cpu_intel.odin +++ b/core/sys/info/cpu_intel.odin @@ -38,7 +38,7 @@ cpu_name: Maybe(string) @(init, private) init_cpu_features :: proc "c" () { is_set :: #force_inline proc "c" (hwc: u32, value: u32) -> bool { - return hwc&value != 0 + return hwc&(1 << value) != 0 } try_set :: #force_inline proc "c" (set: ^CPU_Features, feature: CPU_Feature, hwc: u32, value: u32) { if is_set(hwc, value) { @@ -74,8 +74,15 @@ init_cpu_features :: proc "c" () { return } + // In certain rare cases (reason unknown), XGETBV generates an + // illegal instruction, even if OSXSAVE is set per CPUID. + // + // When Chrome ran into this problem, the problem went away + // after they started checking both OSXSAVE and XSAVE. + // + // See: crbug.com/375968 os_supports_avx := false - if .os_xsave in set { + if .os_xsave in set && is_set(26, ecx1) { eax, _ := xgetbv(0) os_supports_avx = is_set(1, eax) && is_set(2, eax) } diff --git a/core/sys/info/platform_darwin.odin b/core/sys/info/platform_darwin.odin index d226f668c..7a56f1e23 100644 --- a/core/sys/info/platform_darwin.odin +++ b/core/sys/info/platform_darwin.odin @@ -4,6 +4,7 @@ package sysinfo import sys "core:sys/unix" import "core:strconv" import "core:strings" +import "core:runtime" @(private) version_string_buf: [1024]u8 @@ -41,6 +42,8 @@ init_os_version :: proc () { major_ok, minor_ok, patch_ok: bool + tmp := runtime.default_temp_allocator_temp_begin() + triplet := strings.split(string(cstring(&version_bits[0])), ".", context.temp_allocator) if len(triplet) != 3 { have_kernel_version = false @@ -54,6 +57,8 @@ init_os_version :: proc () { } } + runtime.default_temp_allocator_temp_end(tmp) + if !have_kernel_version { // We don't know the kernel version, but we do know the build strings.write_string(&b, "macOS Unknown (build ") diff --git a/core/sys/info/platform_freebsd.odin b/core/sys/info/platform_freebsd.odin index 0ca2841be..1d53da998 100644 --- a/core/sys/info/platform_freebsd.odin +++ b/core/sys/info/platform_freebsd.odin @@ -4,6 +4,7 @@ package sysinfo import sys "core:sys/unix" import "core:strings" import "core:strconv" +import "core:runtime" @(private) version_string_buf: [1024]u8 @@ -47,6 +48,8 @@ init_os_version :: proc () { return } + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() + // Parse kernel version release := string(cstring(raw_data(kernel_version_buf[:]))) version_bits := strings.split_n(release, "-", 2, context.temp_allocator) diff --git a/core/sys/info/platform_linux.odin b/core/sys/info/platform_linux.odin index d1f9ca599..e9cc1dbc9 100644 --- a/core/sys/info/platform_linux.odin +++ b/core/sys/info/platform_linux.odin @@ -4,6 +4,7 @@ package sysinfo import "core:c" import sys "core:sys/unix" import "core:intrinsics" +import "core:runtime" import "core:os" import "core:strings" import "core:strconv" @@ -69,6 +70,8 @@ init_os_version :: proc () { l := strings.builder_len(b) strings.write_string(&b, string(cstring(&uts.release[0]))) + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() + // Parse kernel version, as substrings of the version info in `version_string_buf` version_bits := strings.split_n(strings.to_string(b)[l:], "-", 2, context.temp_allocator) if len(version_bits) > 1 { diff --git a/core/sys/info/platform_openbsd.odin b/core/sys/info/platform_openbsd.odin index 080fad9b7..dbca6eaf3 100644 --- a/core/sys/info/platform_openbsd.odin +++ b/core/sys/info/platform_openbsd.odin @@ -4,6 +4,7 @@ package sysinfo import sys "core:sys/unix" import "core:strings" import "core:strconv" +import "core:runtime" @(private) version_string_buf: [1024]u8 @@ -32,7 +33,9 @@ init_os_version :: proc () { version := string(cstring(raw_data(kernel_version_buf[:]))) strings.write_string(&b, version) - // // Parse kernel version + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() + + // Parse kernel version triplet := strings.split(version, ".", context.temp_allocator) if len(triplet) == 2 { major, major_ok := strconv.parse_int(triplet[0]) diff --git a/core/sys/info/platform_windows.odin b/core/sys/info/platform_windows.odin index f7f689346..9c1c7b04c 100644 --- a/core/sys/info/platform_windows.odin +++ b/core/sys/info/platform_windows.odin @@ -7,6 +7,7 @@ import "core:strings" import "core:unicode/utf16" import "core:fmt" +import "core:runtime" @(private) version_string_buf: [1024]u8 @@ -222,11 +223,10 @@ init_os_version :: proc () { // Grab Windows DisplayVersion (like 20H02) format_display_version :: proc (b: ^strings.Builder) -> (version: string) { - dv, ok := read_reg( + dv, ok := read_reg_string( sys.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", "DisplayVersion", - string, ) defer delete(dv) // It'll be interned into `version_string_buf` @@ -242,11 +242,10 @@ init_os_version :: proc () { // Grab build number and UBR format_build_number :: proc (b: ^strings.Builder, major_build: int) -> (ubr: int) { - res, ok := read_reg( + res, ok := read_reg_i32( sys.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", "UBR", - i32, ) if ok { @@ -288,17 +287,17 @@ init_gpu_info :: proc() { for { key := fmt.tprintf("%v\\%04d", GPU_INFO_BASE, gpu_index) - if vendor, ok := read_reg(sys.HKEY_LOCAL_MACHINE, key, "ProviderName", string); ok { + if vendor, ok := read_reg_string(sys.HKEY_LOCAL_MACHINE, key, "ProviderName"); ok { append(&gpu_list, GPU{vendor_name = vendor}) } else { break } - if desc, ok := read_reg(sys.HKEY_LOCAL_MACHINE, key, "DriverDesc", string); ok { + if desc, ok := read_reg_string(sys.HKEY_LOCAL_MACHINE, key, "DriverDesc"); ok { gpu_list[gpu_index].model_name = desc } - if vram, ok := read_reg(sys.HKEY_LOCAL_MACHINE, key, "HardwareInformation.qwMemorySize", i64); ok { + if vram, ok := read_reg_i64(sys.HKEY_LOCAL_MACHINE, key, "HardwareInformation.qwMemorySize"); ok { gpu_list[gpu_index].total_ram = int(vram) } gpu_index += 1 @@ -307,69 +306,93 @@ init_gpu_info :: proc() { } @(private) -read_reg :: proc(hkey: sys.HKEY, subkey, val: string, $T: typeid) -> (res: T, ok: bool) { - BUF_SIZE :: 1024 - +read_reg_string :: proc(hkey: sys.HKEY, subkey, val: string) -> (res: string, ok: bool) { if len(subkey) == 0 || len(val) == 0 { - return {}, false + return } + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() + + BUF_SIZE :: 1024 key_name_wide := make([]u16, BUF_SIZE, context.temp_allocator) val_name_wide := make([]u16, BUF_SIZE, context.temp_allocator) utf16.encode_string(key_name_wide, subkey) utf16.encode_string(val_name_wide, val) - when T == string { - result_wide := make([]u16, BUF_SIZE, context.temp_allocator) - result_size := sys.DWORD(BUF_SIZE * size_of(u16)) + result_wide := make([]u16, BUF_SIZE, context.temp_allocator) + result_size := sys.DWORD(BUF_SIZE * size_of(u16)) - status := sys.RegGetValueW( - hkey, - &key_name_wide[0], - &val_name_wide[0], - sys.RRF_RT_REG_SZ, - nil, - raw_data(result_wide[:]), - &result_size, - ) - if status != 0 { - // Couldn't retrieve string - return - } - - // Result string will be allocated for the caller. - result_utf8 := make([]u8, BUF_SIZE * 4, context.temp_allocator) - utf16.decode_to_utf8(result_utf8, result_wide[:result_size]) - return strings.clone_from_cstring(cstring(raw_data(result_utf8))), true - - } else when T == i32 { - result_size := sys.DWORD(size_of(i32)) - status := sys.RegGetValueW( - hkey, - &key_name_wide[0], - &val_name_wide[0], - sys.RRF_RT_REG_DWORD, - nil, - &res, - &result_size, - ) - return res, status == 0 - - } else when T == i64 { - result_size := sys.DWORD(size_of(i64)) - status := sys.RegGetValueW( - hkey, - &key_name_wide[0], - &val_name_wide[0], - sys.RRF_RT_REG_QWORD, - nil, - &res, - &result_size, - ) - return res, status == 0 - } else { - #assert(false, "Unhandled type for read_reg") + status := sys.RegGetValueW( + hkey, + &key_name_wide[0], + &val_name_wide[0], + sys.RRF_RT_REG_SZ, + nil, + raw_data(result_wide[:]), + &result_size, + ) + if status != 0 { + // Couldn't retrieve string + return } - return -} \ No newline at end of file + + // Result string will be allocated for the caller. + result_utf8 := make([]u8, BUF_SIZE * 4, context.temp_allocator) + utf16.decode_to_utf8(result_utf8, result_wide[:result_size]) + return strings.clone_from_cstring(cstring(raw_data(result_utf8))), true +} +@(private) +read_reg_i32 :: proc(hkey: sys.HKEY, subkey, val: string) -> (res: i32, ok: bool) { + if len(subkey) == 0 || len(val) == 0 { + return + } + + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() + + BUF_SIZE :: 1024 + key_name_wide := make([]u16, BUF_SIZE, context.temp_allocator) + val_name_wide := make([]u16, BUF_SIZE, context.temp_allocator) + + utf16.encode_string(key_name_wide, subkey) + utf16.encode_string(val_name_wide, val) + + result_size := sys.DWORD(size_of(i32)) + status := sys.RegGetValueW( + hkey, + &key_name_wide[0], + &val_name_wide[0], + sys.RRF_RT_REG_DWORD, + nil, + &res, + &result_size, + ) + return res, status == 0 +} +@(private) +read_reg_i64 :: proc(hkey: sys.HKEY, subkey, val: string) -> (res: i64, ok: bool) { + if len(subkey) == 0 || len(val) == 0 { + return + } + + runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() + + BUF_SIZE :: 1024 + key_name_wide := make([]u16, BUF_SIZE, context.temp_allocator) + val_name_wide := make([]u16, BUF_SIZE, context.temp_allocator) + + utf16.encode_string(key_name_wide, subkey) + utf16.encode_string(val_name_wide, val) + + result_size := sys.DWORD(size_of(i64)) + status := sys.RegGetValueW( + hkey, + &key_name_wide[0], + &val_name_wide[0], + sys.RRF_RT_REG_QWORD, + nil, + &res, + &result_size, + ) + return res, status == 0 +} diff --git a/core/sys/unix/syscalls_linux.odin b/core/sys/unix/syscalls_linux.odin index 8ce3ca3cb..3083c084b 100644 --- a/core/sys/unix/syscalls_linux.odin +++ b/core/sys/unix/syscalls_linux.odin @@ -1518,6 +1518,7 @@ when ODIN_ARCH == .amd64 { #panic("Unsupported architecture") } + // syscall related constants AT_FDCWD :: ~uintptr(99) AT_REMOVEDIR :: uintptr(0x200) @@ -1563,15 +1564,184 @@ MADV_WIPEONFORK :: 18 MADV_KEEPONFORK :: 19 MADV_HWPOISON :: 100 +// pipe2 flags +O_CLOEXEC :: 0o2000000 + +// poll events +POLLIN :: 0x0001 +POLLPRI :: 0x0002 +POLLOUT :: 0x0004 +POLLERR :: 0x0008 +POLLHUP :: 0x0010 +POLLNVAL :: 0x0020 +POLLRDNORM :: 0x0040 +POLLRDBAND :: 0x0080 +POLLWRNORM :: 0x0100 +POLLWRBAND :: 0x0200 +POLLMSG :: 0x0400 +POLLREMOVE :: 0x1000 +POLLRDHUP :: 0x2000 +POLLFREE :: 0x4000 +POLL_BUSY_LOOP :: 0x8000 + +// perf event data +Perf_Sample :: struct #raw_union { + period: u64, + frequency: u64, +} +Perf_Wakeup :: struct #raw_union { + events: u32, + watermark: u32, +} +Perf_Field1 :: struct #raw_union { + breakpoint_addr: u64, + kprobe_func: u64, + uprobe_path: u64, + config1: u64, +} +Perf_Field2 :: struct #raw_union { + breakpoint_len: u64, + kprobe_addr: u64, + uprobe_offset: u64, + config2: u64, +} +Perf_Event_Attr :: struct #packed { + type: u32, + size: u32, + config: u64, + sample: Perf_Sample, + sample_type: u64, + read_format: u64, + flags: Perf_Flags, + wakeup: Perf_Wakeup, + breakpoint_type: u32, + field1: Perf_Field1, + field2: Perf_Field2, + branch_sample_type: u64, + sample_regs_user: u64, + sample_stack_user: u32, + clock_id: i32, + sample_regs_intr: u64, + aux_watermark: u32, + sample_max_stack: u16, + _padding: u16, +} + +Perf_Event_Flags :: distinct bit_set[Perf_Event_Flag; u64] +Perf_Event_Flag :: enum u64 { + Bit0 = 0, + Bit0_Is_Deprecated = 1, + User_Rdpmc = 2, + User_Time = 3, + User_Time_Zero = 4, + User_Time_Short = 5, +} +Perf_Capabilities :: struct #raw_union { + capabilities: u64, + flags: Perf_Event_Flags, +} +Perf_Event_mmap_Page :: struct #packed { + version: u32, + compat_version: u32, + lock: u32, + index: u32, + offset: i64, + time_enabled: u64, + time_running: u64, + cap: Perf_Capabilities, + pmc_width: u16, + time_shift: u16, + time_mult: u32, + time_offset: u64, + time_zero: u64, + size: u32, + reserved1: u32, + time_cycles: u64, + time_mask: u64, + reserved2: [116*8]u8, + data_head: u64, + data_tail: u64, + data_offset: u64, + data_size: u64, + aux_head: u64, + aux_tail: u64, + aux_offset: u64, + aux_size: u64, +} + +Perf_Type_Id :: enum u32 { + Hardware = 0, + Software = 1, + Tracepoint = 2, + HW_Cache = 3, + Raw = 4, + Breakpoint = 5, +} + +Perf_Hardware_Id :: enum u64 { + CPU_Cycles = 0, + Instructions = 1, + Cache_References = 2, + Cache_Misses = 3, + Branch_Instructions = 4, + Branch_Misses = 5, + Bus_Cycles = 6, + Stalled_Cycles_Frontend = 7, + Stalled_Cycles_Backend = 8, + Ref_CPU_Cycles = 9, +} + +Perf_Flags :: distinct bit_set[Perf_Flag; u64] +Perf_Flag :: enum u64 { + Disabled = 0, + Inherit = 1, + Pinned = 2, + Exclusive = 3, + Exclude_User = 4, + Exclude_Kernel = 5, + Exclude_HV = 6, + Exclude_Idle = 7, + mmap = 8, + Comm = 9, + Freq = 10, + Inherit_Stat = 11, + Enable_On_Exec = 12, + Task = 13, + Watermark = 14, + Precise_IP_0 = 15, + Precise_IP_1 = 16, + mmap_Data = 17, + Sample_Id_All = 18, + Exclude_Host = 19, + Exclude_Guest = 20, + Exclude_Callchain_Kernel = 21, + Exclude_Callchain_User = 22, + mmap2 = 23, + Comm_Exec = 24, + Use_Clockid = 25, + Context_Switch = 26, + Write_Backward = 27, + Namespaces = 28, + KSymbol = 29, + BPF_Event = 30, + Aux_Output = 31, + CGroup = 32, + Text_Poke = 33, + Build_Id = 34, + Inherit_Thread = 35, + Remove_On_Exec = 36, + Sigtrap = 37, +} + sys_gettid :: proc "contextless" () -> int { - return cast(int)intrinsics.syscall(SYS_gettid) + return int(intrinsics.syscall(SYS_gettid)) } -sys_getrandom :: proc "contextless" (buf: [^]byte, buflen: int, flags: uint) -> int { - return cast(int)intrinsics.syscall(SYS_getrandom, uintptr(buf), uintptr(buflen), uintptr(flags)) +sys_getrandom :: proc "contextless" (buf: [^]byte, buflen: uint, flags: int) -> int { + return int(intrinsics.syscall(SYS_getrandom, uintptr(buf), uintptr(buflen), uintptr(flags))) } -sys_open :: proc "contextless" (path: cstring, flags: int, mode: int = 0o000) -> int { +sys_open :: proc "contextless" (path: cstring, flags: int, mode: uint = 0o000) -> int { when ODIN_ARCH != .arm64 { return int(intrinsics.syscall(SYS_open, uintptr(rawptr(path)), uintptr(flags), uintptr(mode))) } else { // NOTE: arm64 does not have open @@ -1579,7 +1749,7 @@ sys_open :: proc "contextless" (path: cstring, flags: int, mode: int = 0o000) -> } } -sys_openat :: proc "contextless" (dfd: int, path: cstring, flags: int, mode: int = 0o000) -> int { +sys_openat :: proc "contextless" (dfd: int, path: cstring, flags: int, mode: uint = 0o000) -> int { return int(intrinsics.syscall(SYS_openat, uintptr(dfd), uintptr(rawptr(path)), uintptr(flags), uintptr(mode))) } @@ -1691,7 +1861,7 @@ sys_fchdir :: proc "contextless" (fd: int) -> int { return int(intrinsics.syscall(SYS_fchdir, uintptr(fd))) } -sys_chmod :: proc "contextless" (path: cstring, mode: int) -> int { +sys_chmod :: proc "contextless" (path: cstring, mode: uint) -> int { when ODIN_ARCH != .arm64 { return int(intrinsics.syscall(SYS_chmod, uintptr(rawptr(path)), uintptr(mode))) } else { // NOTE: arm64 does not have chmod @@ -1699,7 +1869,7 @@ sys_chmod :: proc "contextless" (path: cstring, mode: int) -> int { } } -sys_fchmod :: proc "contextless" (fd: int, mode: int) -> int { +sys_fchmod :: proc "contextless" (fd: int, mode: uint) -> int { return int(intrinsics.syscall(SYS_fchmod, uintptr(fd), uintptr(mode))) } @@ -1759,7 +1929,7 @@ sys_rmdir :: proc "contextless" (path: cstring) -> int { } } -sys_mkdir :: proc "contextless" (path: cstring, mode: int) -> int { +sys_mkdir :: proc "contextless" (path: cstring, mode: uint) -> int { when ODIN_ARCH != .arm64 { return int(intrinsics.syscall(SYS_mkdir, uintptr(rawptr(path)), uintptr(mode))) } else { // NOTE: arm64 does not have mkdir @@ -1767,11 +1937,11 @@ sys_mkdir :: proc "contextless" (path: cstring, mode: int) -> int { } } -sys_mkdirat :: proc "contextless" (dfd: int, path: cstring, mode: int) -> int { +sys_mkdirat :: proc "contextless" (dfd: int, path: cstring, mode: uint) -> int { return int(intrinsics.syscall(SYS_mkdirat, uintptr(dfd), uintptr(rawptr(path)), uintptr(mode))) } -sys_mknod :: proc "contextless" (path: cstring, mode: int, dev: int) -> int { +sys_mknod :: proc "contextless" (path: cstring, mode: uint, dev: int) -> int { when ODIN_ARCH != .arm64 { return int(intrinsics.syscall(SYS_mknod, uintptr(rawptr(path)), uintptr(mode), uintptr(dev))) } else { // NOTE: arm64 does not have mknod @@ -1779,7 +1949,7 @@ sys_mknod :: proc "contextless" (path: cstring, mode: int, dev: int) -> int { } } -sys_mknodat :: proc "contextless" (dfd: int, path: cstring, mode: int, dev: int) -> int { +sys_mknodat :: proc "contextless" (dfd: int, path: cstring, mode: uint, dev: int) -> int { return int(intrinsics.syscall(SYS_mknodat, uintptr(dfd), uintptr(rawptr(path)), uintptr(mode), uintptr(dev))) } @@ -1818,6 +1988,16 @@ sys_fork :: proc "contextless" () -> int { return int(intrinsics.syscall(SYS_clone, SIGCHLD)) } } +sys_pipe2 :: proc "contextless" (fds: rawptr, flags: int) -> int { + return int(intrinsics.syscall(SYS_pipe2, uintptr(fds), uintptr(flags))) +} +sys_dup2 :: proc "contextless" (oldfd: int, newfd: int) -> int { + when ODIN_ARCH != .arm64 { + return int(intrinsics.syscall(SYS_dup2, uintptr(oldfd), uintptr(newfd))) + } else { + return int(intrinsics.syscall(SYS_dup3, uintptr(oldfd), uintptr(newfd), 0)) + } +} sys_mmap :: proc "contextless" (addr: rawptr, length: uint, prot, flags, fd: int, offset: uintptr) -> int { return int(intrinsics.syscall(SYS_mmap, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), offset)) @@ -1846,6 +2026,71 @@ sys_utimensat :: proc "contextless" (dfd: int, path: cstring, times: rawptr, fla return int(intrinsics.syscall(SYS_utimensat, uintptr(dfd), uintptr(rawptr(path)), uintptr(times), uintptr(flags))) } +sys_socket :: proc "contextless" (domain: int, type: int, protocol: int) -> int { + return int(intrinsics.syscall(SYS_socket, uintptr(domain), uintptr(type), uintptr(protocol))) +} + +sys_connect :: proc "contextless" (sd: int, addr: rawptr, len: i32) -> int { + return int(intrinsics.syscall(SYS_connect, uintptr(sd), uintptr(addr), uintptr(len))) +} + +sys_accept :: proc "contextless" (sd: int, addr: rawptr, len: rawptr) -> int { + return int(intrinsics.syscall(SYS_accept4, uintptr(sd), uintptr(addr), uintptr(len), uintptr(0))) +} + +sys_listen :: proc "contextless" (sd: int, backlog: int) -> int { + return int(intrinsics.syscall(SYS_listen, uintptr(sd), uintptr(backlog))) +} + +sys_bind :: proc "contextless" (sd: int, addr: rawptr, len: i32) -> int { + return int(intrinsics.syscall(SYS_bind, uintptr(sd), uintptr(addr), uintptr(len))) +} + +sys_setsockopt :: proc "contextless" (sd: int, level: int, optname: int, optval: rawptr, optlen: i32) -> int { + return int(intrinsics.syscall(SYS_setsockopt, uintptr(sd), uintptr(level), uintptr(optname), uintptr(optval), uintptr(optlen))) +} + +sys_recvfrom :: proc "contextless" (sd: int, buf: rawptr, len: uint, flags: int, addr: rawptr, alen: uintptr) -> i64 { + return i64(intrinsics.syscall(SYS_recvfrom, uintptr(sd), uintptr(buf), uintptr(len), uintptr(flags), uintptr(addr), uintptr(alen))) +} + +sys_sendto :: proc "contextless" (sd: int, buf: rawptr, len: uint, flags: int, addr: rawptr, alen: i32) -> i64 { + return i64(intrinsics.syscall(SYS_sendto, uintptr(sd), uintptr(buf), uintptr(len), uintptr(flags), uintptr(addr), uintptr(alen))) +} + +sys_shutdown :: proc "contextless" (sd: int, how: int) -> int { + return int(intrinsics.syscall(SYS_shutdown, uintptr(sd), uintptr(how))) +} + +sys_perf_event_open :: proc "contextless" (event_attr: rawptr, pid: i32, cpu: i32, group_fd: i32, flags: u32) -> int { + return int(intrinsics.syscall(SYS_perf_event_open, uintptr(event_attr), uintptr(pid), uintptr(cpu), uintptr(group_fd), uintptr(flags))) +} + +sys_personality :: proc(persona: u64) -> int { + return int(intrinsics.syscall(SYS_personality, uintptr(persona))) +} + +sys_fcntl :: proc "contextless" (fd: int, cmd: int, arg: int) -> int { + return int(intrinsics.syscall(SYS_fcntl, uintptr(fd), uintptr(cmd), uintptr(arg))) +} + +sys_poll :: proc "contextless" (fds: rawptr, nfds: uint, timeout: int) -> int { + // NOTE: specialcased here because `arm64` does not have `poll` + when ODIN_ARCH == .arm64 { + seconds := i64(timeout / 1_000) + nanoseconds := i64((timeout % 1000) * 1_000_000) + timeout_spec := timespec{seconds, nanoseconds} + + return int(intrinsics.syscall(SYS_ppoll, uintptr(fds), uintptr(nfds), uintptr(&timeout_spec), uintptr(0), uintptr(8))) + } else { + return int(intrinsics.syscall(SYS_poll, uintptr(fds), uintptr(nfds), uintptr(timeout))) + } +} + +sys_ppoll :: proc "contextless" (fds: rawptr, nfds: uint, timeout: rawptr, sigmask: rawptr, sigsetsize: uint) -> int { + return int(intrinsics.syscall(SYS_ppoll, uintptr(fds), uintptr(nfds), uintptr(timeout), uintptr(sigmask), uintptr(sigsetsize))) +} + get_errno :: proc "contextless" (res: int) -> i32 { if res < 0 && res > -4096 { return i32(-res) diff --git a/core/sys/wasm/wasi/wasi_api.odin b/core/sys/wasm/wasi/wasi_api.odin index d4f0d19cf..e9ceb4667 100644 --- a/core/sys/wasm/wasi/wasi_api.odin +++ b/core/sys/wasm/wasi/wasi_api.odin @@ -968,7 +968,7 @@ prestat_t :: struct { }, } -@(default_calling_convention="c") +@(default_calling_convention="contextless") foreign wasi { /** * Read command-line argument data. @@ -1306,7 +1306,7 @@ foreign wasi { * Returns the number of arguments and the size of the argument string * data, or an error. */ -args_sizes_get :: proc "c" () -> (num_args, size_of_args: size_t, err: errno_t) { +args_sizes_get :: proc "contextless" () -> (num_args, size_of_args: size_t, err: errno_t) { err = wasi_args_sizes_get(&num_args, &size_of_args) return } @@ -1316,7 +1316,7 @@ args_sizes_get :: proc "c" () -> (num_args, size_of_args: size_t, err: errno_t) * Returns the number of environment variable arguments and the size of the * environment variable data. */ -environ_sizes_get :: proc "c" () -> (num_envs, size_of_envs: size_t, err: errno_t) { +environ_sizes_get :: proc "contextless" () -> (num_envs, size_of_envs: size_t, err: errno_t) { err = wasi_environ_sizes_get(&num_envs, &size_of_envs) return } @@ -1328,7 +1328,7 @@ environ_sizes_get :: proc "c" () -> (num_envs, size_of_envs: size_t, err: errno_ * @return * The resolution of the clock, or an error if one happened. */ -clock_res_get :: proc "c" ( +clock_res_get :: proc "contextless" ( /** * The clock for which to return the resolution. */ @@ -1343,7 +1343,7 @@ clock_res_get :: proc "c" ( * @return * The time value of the clock. */ -clock_time_get :: proc "c" ( +clock_time_get :: proc "contextless" ( /** * The clock for which to return the time. */ @@ -1362,7 +1362,7 @@ clock_time_get :: proc "c" ( * @return * The buffer where the file descriptor's attributes are stored. */ -fd_fdstat_get :: proc "c" ( +fd_fdstat_get :: proc "contextless" ( fd: fd_t, ) -> (stat: fdstat_t, err: errno_t) { err = wasi_fd_fdstat_get(fd, &stat) @@ -1373,7 +1373,7 @@ fd_fdstat_get :: proc "c" ( * @return * The buffer where the file's attributes are stored. */ -fd_filestat_get :: proc "c" ( +fd_filestat_get :: proc "contextless" ( fd: fd_t, ) -> (stat: filestat_t, err: errno_t) { err = wasi_fd_filestat_get(fd, &stat) @@ -1389,7 +1389,7 @@ fd_filestat_get :: proc "c" ( * @return * The number of bytes read. */ -fd_pread :: proc "c" ( +fd_pread :: proc "contextless" ( fd: fd_t, /** * List of scatter/gather vectors in which to store data. @@ -1408,7 +1408,7 @@ fd_pread :: proc "c" ( * @return * The buffer where the description is stored. */ -fd_prestat_get :: proc "c" ( +fd_prestat_get :: proc "contextless" ( fd: fd_t, ) -> (desc: prestat_t, err: errno_t) { err = wasi_fd_prestat_get(fd, &desc) @@ -1420,7 +1420,7 @@ fd_prestat_get :: proc "c" ( * @return * The number of bytes written. */ -fd_pwrite :: proc "c" ( +fd_pwrite :: proc "contextless" ( fd: fd_t, /** * List of scatter/gather vectors from which to retrieve data. @@ -1440,7 +1440,7 @@ fd_pwrite :: proc "c" ( * @return * The number of bytes read. */ -fd_read :: proc "c" ( +fd_read :: proc "contextless" ( fd: fd_t, /** * List of scatter/gather vectors to which to store data. @@ -1463,7 +1463,7 @@ fd_read :: proc "c" ( * @return * The number of bytes stored in the read buffer. If less than the size of the read buffer, the end of the directory has been reached. */ -fd_readdir :: proc "c" ( +fd_readdir :: proc "contextless" ( fd: fd_t, /** * The buffer where directory entries are stored @@ -1483,7 +1483,7 @@ fd_readdir :: proc "c" ( * @return * The new offset of the file descriptor, relative to the start of the file. */ -fd_seek :: proc "c" ( +fd_seek :: proc "contextless" ( fd: fd_t, /** * The number of bytes to move. @@ -1503,7 +1503,7 @@ fd_seek :: proc "c" ( * @return * The current offset of the file descriptor, relative to the start of the file. */ -fd_tell :: proc "c" ( +fd_tell :: proc "contextless" ( fd: fd_t, ) -> (offset: filesize_t, err: errno_t) { err = wasi_fd_tell(fd, &offset) @@ -1513,7 +1513,7 @@ fd_tell :: proc "c" ( * Write to a file descriptor. * Note: This is similar to `writev` in POSIX. */ -fd_write :: proc "c" ( +fd_write :: proc "contextless" ( fd: fd_t, /** * List of scatter/gather vectors from which to retrieve data. @@ -1529,7 +1529,7 @@ fd_write :: proc "c" ( * @return * The buffer where the file's attributes are stored. */ -path_filestat_get :: proc "c" ( +path_filestat_get :: proc "contextless" ( fd: fd_t, /** * Flags determining the method of how the path is resolved. @@ -1554,7 +1554,7 @@ path_filestat_get :: proc "c" ( * @return * The file descriptor of the file that has been opened. */ -path_open :: proc "c" ( +path_open :: proc "contextless" ( fd: fd_t, /** * Flags determining the method of how the path is resolved. @@ -1591,7 +1591,7 @@ path_open :: proc "c" ( * @return * The number of bytes placed in the buffer. */ -path_readlink :: proc "c" ( +path_readlink :: proc "contextless" ( fd: fd_t, /** * The path of the symbolic link from which to read. @@ -1610,7 +1610,7 @@ path_readlink :: proc "c" ( * @return * The number of events stored. */ -poll_oneoff :: proc "c" ( +poll_oneoff :: proc "contextless" ( /** * The events to which to subscribe. */ @@ -1634,7 +1634,7 @@ poll_oneoff :: proc "c" ( * @return * Number of bytes stored in ri_data and message flags. */ -sock_recv :: proc "c" ( +sock_recv :: proc "contextless" ( fd: fd_t, /** * List of scatter/gather vectors to which to store data. @@ -1655,7 +1655,7 @@ sock_recv :: proc "c" ( * @return * Number of bytes transmitted. */ -sock_send :: proc "c" ( +sock_send :: proc "contextless" ( fd: fd_t, /** * List of scatter/gather vectors to which to retrieve data @@ -1675,7 +1675,7 @@ sock_send :: proc "c" ( -@(default_calling_convention="c") +@(default_calling_convention="contextless") foreign wasi { @(link_name="args_sizes_get") wasi_args_sizes_get :: proc( diff --git a/core/sys/windows/advapi32.odin b/core/sys/windows/advapi32.odin index e98aa6c43..dc7ec1e08 100644 --- a/core/sys/windows/advapi32.odin +++ b/core/sys/windows/advapi32.odin @@ -52,7 +52,7 @@ foreign advapi32 { dwCreationFlags: DWORD, lpEnvironment: LPVOID, lpCurrentDirectory: wstring, - lpStartupInfo: LPSTARTUPINFO, + lpStartupInfo: LPSTARTUPINFOW, lpProcessInformation: LPPROCESS_INFORMATION, ) -> BOOL --- @@ -67,7 +67,7 @@ foreign advapi32 { dwCreationFlags: DWORD, lpEnvironment: LPVOID, lpCurrentDirectory: wstring, - lpStartupInfo: LPSTARTUPINFO, + lpStartupInfo: LPSTARTUPINFOW, lpProcessInformation: LPPROCESS_INFORMATION, ) -> BOOL --- diff --git a/core/sys/windows/dnsapi.odin b/core/sys/windows/dnsapi.odin new file mode 100644 index 000000000..623fa2889 --- /dev/null +++ b/core/sys/windows/dnsapi.odin @@ -0,0 +1,10 @@ +// +build windows +package sys_windows + +foreign import "system:Dnsapi.lib" + +@(default_calling_convention="std") +foreign Dnsapi { + DnsQuery_UTF8 :: proc(name: cstring, type: u16, options: DWORD, extra: PVOID, results: ^^DNS_RECORD, reserved: PVOID) -> DNS_STATUS --- + DnsRecordListFree :: proc(list: ^DNS_RECORD, options: DWORD) --- +} diff --git a/core/sys/windows/dwmapi.odin b/core/sys/windows/dwmapi.odin index 468b5bb87..9b5916ab1 100644 --- a/core/sys/windows/dwmapi.odin +++ b/core/sys/windows/dwmapi.odin @@ -3,7 +3,45 @@ package sys_windows foreign import dwmapi "system:Dwmapi.lib" +DWMWINDOWATTRIBUTE :: enum { + DWMWA_NCRENDERING_ENABLED, + DWMWA_NCRENDERING_POLICY, + DWMWA_TRANSITIONS_FORCEDISABLED, + DWMWA_ALLOW_NCPAINT, + DWMWA_CAPTION_BUTTON_BOUNDS, + DWMWA_NONCLIENT_RTL_LAYOUT, + DWMWA_FORCE_ICONIC_REPRESENTATION, + DWMWA_FLIP3D_POLICY, + DWMWA_EXTENDED_FRAME_BOUNDS, + DWMWA_HAS_ICONIC_BITMAP, + DWMWA_DISALLOW_PEEK, + DWMWA_EXCLUDED_FROM_PEEK, + DWMWA_CLOAK, + DWMWA_CLOAKED, + DWMWA_FREEZE_REPRESENTATION, + DWMWA_PASSIVE_UPDATE_MODE, + DWMWA_USE_HOSTBACKDROPBRUSH, + DWMWA_USE_IMMERSIVE_DARK_MODE = 20, + DWMWA_WINDOW_CORNER_PREFERENCE = 33, + DWMWA_BORDER_COLOR, + DWMWA_CAPTION_COLOR, + DWMWA_TEXT_COLOR, + DWMWA_VISIBLE_FRAME_BORDER_THICKNESS, + DWMWA_SYSTEMBACKDROP_TYPE, + DWMWA_LAST, +} + +DWMNCRENDERINGPOLICY :: enum { + DWMNCRP_USEWINDOWSTYLE, + DWMNCRP_DISABLED, + DWMNCRP_ENABLED, + DWMNCRP_LAST, +} + @(default_calling_convention="stdcall") foreign dwmapi { DwmFlush :: proc() -> HRESULT --- + DwmIsCompositionEnabled :: proc(pfEnabled: ^BOOL) -> HRESULT --- + DwmExtendFrameIntoClientArea :: proc(hWnd: HWND, pMarInset: PMARGINS) -> HRESULT --- + DwmSetWindowAttribute :: proc(hWnd: HWND, dwAttribute: DWORD, pvAttribute: LPCVOID, cbAttribute: DWORD) -> HRESULT --- } diff --git a/core/sys/windows/gdi32.odin b/core/sys/windows/gdi32.odin index d83d2aa6c..9e2294c71 100644 --- a/core/sys/windows/gdi32.odin +++ b/core/sys/windows/gdi32.odin @@ -79,6 +79,8 @@ foreign gdi32 { TextOutW :: proc(hdc: HDC, x, y: c_int, lpString: LPCWSTR, c: c_int) -> BOOL --- GetTextExtentPoint32W :: proc(hdc: HDC, lpString: LPCWSTR, c: c_int, psizl: LPSIZE) -> BOOL --- GetTextMetricsW :: proc(hdc: HDC, lptm: LPTEXTMETRICW) -> BOOL --- + + CreateSolidBrush :: proc(color: COLORREF) -> HBRUSH --- } RGB :: #force_inline proc "contextless" (r, g, b: u8) -> COLORREF { diff --git a/core/sys/windows/ip_helper.odin b/core/sys/windows/ip_helper.odin new file mode 100644 index 000000000..d8f93f533 --- /dev/null +++ b/core/sys/windows/ip_helper.odin @@ -0,0 +1,234 @@ +// +build windows +package sys_windows + +foreign import "system:iphlpapi.lib" + +Address_Family :: enum u32 { + Unspecified = 0, // Return both IPv4 and IPv6 addresses associated with adapters with them enabled. + IPv4 = 2, // Return only IPv4 addresses associated with adapters with it enabled. + IPv6 = 23, // Return only IPv6 addresses associated with adapters with it enabled. +} + +GAA_Flag :: enum u32 { + Skip_Unicast = 0, // Do not return unicast addresses. + Skip_Anycast = 1, // Do not return IPv6 anycast addresses. + Skip_Multicast = 2, // Do not return multicast addresses. + Skip_DNS_Server = 3, // Do not return addresses of DNS servers. + Include_Prefix = 4, // (XP SP1+) Return a list of IP address prefixes on this adapter. When this flag is set, IP address prefixes are returned for both IPv6 and IPv4 addresses. + Skip_Friendly_Name = 5, // Do not return the adapter friendly name. + Include_WINS_info = 6, // (Vista+) Return addresses of Windows Internet Name Service (WINS) servers. + Include_Gateways = 7, // (Vista+) Return the addresses of default gateways. + Include_All_Interfaces = 8, // (Vista+) Return addresses for all NDIS interfaces. + Include_All_Compartments = 9, // (Reserved, Unsupported) Return addresses in all routing compartments. + Include_Tunnel_Binding_Order = 10, // (Vista+) Return the adapter addresses sorted in tunnel binding order. +} +GAA_Flags :: bit_set[GAA_Flag; u32] + +IP_Adapter_Addresses :: struct { + Raw: struct #raw_union { + Alignment: u64, + Anonymous: struct { + Length: u32, + IfIndex: u32, + }, + }, + Next: ^IP_Adapter_Addresses, + AdapterName: cstring, + FirstUnicastAddress: ^IP_ADAPTER_UNICAST_ADDRESS_LH, + FirstAnycastAddress: ^IP_ADAPTER_ANYCAST_ADDRESS_XP, + FirstMulticastAddress: ^IP_ADAPTER_MULTICAST_ADDRESS_XP, + FirstDnsServerAddress: ^IP_ADAPTER_DNS_SERVER_ADDRESS_XP, + DnsSuffix: ^u16, + Description: ^u16, + FriendlyName: ^u16, + PhysicalAddress: [8]u8, + PhysicalAddressLength: u32, + Anonymous2: struct #raw_union { + Flags: u32, + Anonymous: struct { + _bitfield: u32, + }, + }, + MTU: u32, + IfType: u32, + OperStatus: IF_OPER_STATUS, + Ipv6IfIndex: u32, + ZoneIndices: [16]u32, + FirstPrefix: rawptr, // ^IP_ADAPTER_PREFIX_XP, + TransmitLinkSpeed: u64, + ReceiveLinkSpeed: u64, + FirstWinsServerAddress: rawptr, // ^IP_ADAPTER_WINS_SERVER_ADDRESS_LH, + FirstGatewayAddress: ^IP_ADAPTER_GATEWAY_ADDRESS_LH, + Ipv4Metric: u32, + Ipv6Metric: u32, + Luid: NET_LUID_LH, + Dhcpv4Server: SOCKET_ADDRESS, + CompartmentId: u32, + NetworkGuid: GUID, + ConnectionType: NET_IF_CONNECTION_TYPE, + TunnelType: TUNNEL_TYPE, + Dhcpv6Server: SOCKET_ADDRESS, + Dhcpv6ClientDuid: [130]u8, + Dhcpv6ClientDuidLength: u32, + Dhcpv6Iaid: u32, + FirstDnsSuffix: rawptr, // ^IP_ADAPTER_DNS_SUFFIX, +} + +IP_ADAPTER_UNICAST_ADDRESS_LH :: struct { + Anonymous: struct #raw_union { + Alignment: u64, + Anonymous: struct { + Length: u32, + Flags: u32, + }, + }, + Next: ^IP_ADAPTER_UNICAST_ADDRESS_LH, + Address: SOCKET_ADDRESS, + PrefixOrigin: NL_PREFIX_ORIGIN, + SuffixOrigin: NL_SUFFIX_ORIGIN, + DadState: NL_DAD_STATE, + ValidLifetime: u32, + PreferredLifetime: u32, + LeaseLifetime: u32, + OnLinkPrefixLength: u8, +} + +IP_ADAPTER_ANYCAST_ADDRESS_XP :: struct { + Anonymous: struct #raw_union { + Alignment: u64, + Anonymous: struct { + Length: u32, + Flags: u32, + }, + }, + Next: ^IP_ADAPTER_ANYCAST_ADDRESS_XP, + Address: SOCKET_ADDRESS, +} + +IP_ADAPTER_MULTICAST_ADDRESS_XP :: struct { + Anonymous: struct #raw_union { + Alignment: u64, + Anonymous: struct { + Length: u32, + Flags: u32, + }, + }, + Next: ^IP_ADAPTER_MULTICAST_ADDRESS_XP, + Address: SOCKET_ADDRESS, +} + +IP_ADAPTER_GATEWAY_ADDRESS_LH :: struct { + Anonymous: struct #raw_union { + Alignment: u64, + Anonymous: struct { + Length: u32, + Reserved: u32, + }, + }, + Next: ^IP_ADAPTER_GATEWAY_ADDRESS_LH, + Address: SOCKET_ADDRESS, +} + +IP_ADAPTER_DNS_SERVER_ADDRESS_XP :: struct { + Anonymous: struct #raw_union { + Alignment: u64, + Anonymous: struct { + Length: u32, + Reserved: u32, + }, + }, + Next: ^IP_ADAPTER_DNS_SERVER_ADDRESS_XP, + Address: SOCKET_ADDRESS, +} + +IF_OPER_STATUS :: enum i32 { + Up = 1, + Down = 2, + Testing = 3, + Unknown = 4, + Dormant = 5, + NotPresent = 6, + LowerLayerDown = 7, +} + +NET_LUID_LH :: struct #raw_union { + Value: u64, + Info: struct { + _bitfield: u64, + }, +} + +SOCKET_ADDRESS :: struct { + lpSockaddr: ^SOCKADDR, + iSockaddrLength: i32, +} + +NET_IF_CONNECTION_TYPE :: enum i32 { + NET_IF_CONNECTION_DEDICATED = 1, + NET_IF_CONNECTION_PASSIVE = 2, + NET_IF_CONNECTION_DEMAND = 3, + NET_IF_CONNECTION_MAXIMUM = 4, +} + +TUNNEL_TYPE :: enum i32 { + TUNNEL_TYPE_NONE = 0, + TUNNEL_TYPE_OTHER = 1, + TUNNEL_TYPE_DIRECT = 2, + TUNNEL_TYPE_6TO4 = 11, + TUNNEL_TYPE_ISATAP = 13, + TUNNEL_TYPE_TEREDO = 14, + TUNNEL_TYPE_IPHTTPS = 15, +} +NL_PREFIX_ORIGIN :: enum i32 { + IpPrefixOriginOther = 0, + IpPrefixOriginManual = 1, + IpPrefixOriginWellKnown = 2, + IpPrefixOriginDhcp = 3, + IpPrefixOriginRouterAdvertisement = 4, + IpPrefixOriginUnchanged = 16, +} + +NL_SUFFIX_ORIGIN :: enum i32 { + NlsoOther = 0, + NlsoManual = 1, + NlsoWellKnown = 2, + NlsoDhcp = 3, + NlsoLinkLayerAddress = 4, + NlsoRandom = 5, + IpSuffixOriginOther = 0, + IpSuffixOriginManual = 1, + IpSuffixOriginWellKnown = 2, + IpSuffixOriginDhcp = 3, + IpSuffixOriginLinkLayerAddress = 4, + IpSuffixOriginRandom = 5, + IpSuffixOriginUnchanged = 16, +} + +NL_DAD_STATE :: enum i32 { + NldsInvalid = 0, + NldsTentative = 1, + NldsDuplicate = 2, + NldsDeprecated = 3, + NldsPreferred = 4, + IpDadStateInvalid = 0, + IpDadStateTentative = 1, + IpDadStateDuplicate = 2, + IpDadStateDeprecated = 3, + IpDadStatePreferred = 4, +} + +@(default_calling_convention = "std") +foreign iphlpapi { + /* + The GetAdaptersAddresses function retrieves the addresses associated with the adapters on the local computer. + See: https://docs.microsoft.com/en-us/windows/win32/api/iphlpapi/nf-iphlpapi-getadaptersaddresses + */ + @(link_name="GetAdaptersAddresses") get_adapters_addresses :: proc( + family: Address_Family, + flags: GAA_Flags, + _reserved: rawptr, + adapter_addresses: [^]IP_Adapter_Addresses, + size: ^u32, + ) -> ULONG --- + +} diff --git a/core/sys/windows/kernel32.odin b/core/sys/windows/kernel32.odin index 3eb42a3ad..beed3a7e5 100644 --- a/core/sys/windows/kernel32.odin +++ b/core/sys/windows/kernel32.odin @@ -2,6 +2,24 @@ package sys_windows foreign import kernel32 "system:Kernel32.lib" +foreign import one_core "system:OneCore.lib" + +FOREGROUND_BLUE :: WORD(0x0001) +FOREGROUND_GREEN :: WORD(0x0002) +FOREGROUND_RED :: WORD(0x0004) +FOREGROUND_INTENSITY :: WORD(0x0008) +BACKGROUND_BLUE :: WORD(0x0010) +BACKGROUND_GREEN :: WORD(0x0020) +BACKGROUND_RED :: WORD(0x0040) +BACKGROUND_INTENSITY :: WORD(0x0080) +COMMON_LVB_LEADING_BYTE :: WORD(0x0100) +COMMON_LVB_TRAILING_BYTE :: WORD(0x0200) +COMMON_LVB_GRID_HORIZONTAL :: WORD(0x0400) +COMMON_LVB_GRID_LVERTICAL :: WORD(0x0800) +COMMON_LVB_GRID_RVERTICAL :: WORD(0x1000) +COMMON_LVB_REVERSE_VIDEO :: WORD(0x4000) +COMMON_LVB_UNDERSCORE :: WORD(0x8000) +COMMON_LVB_SBCSDBCS :: WORD(0x0300) @(default_calling_convention="stdcall") foreign kernel32 { @@ -26,7 +44,10 @@ foreign kernel32 { dwMode: DWORD) -> BOOL --- SetConsoleCursorPosition :: proc(hConsoleHandle: HANDLE, dwCursorPosition: COORD) -> BOOL --- - + SetConsoleTextAttribute :: proc(hConsoleOutput: HANDLE, + wAttributes: WORD) -> BOOL --- + SetConsoleOutputCP :: proc(wCodePageID: UINT) -> BOOL --- + GetFileInformationByHandle :: proc(hFile: HANDLE, lpFileInformation: LPBY_HANDLE_FILE_INFORMATION) -> BOOL --- SetHandleInformation :: proc(hObject: HANDLE, dwMask: DWORD, @@ -173,9 +194,10 @@ foreign kernel32 { dwCreationFlags: DWORD, lpEnvironment: LPVOID, lpCurrentDirectory: LPCWSTR, - lpStartupInfo: LPSTARTUPINFO, + lpStartupInfo: LPSTARTUPINFOW, lpProcessInformation: LPPROCESS_INFORMATION, ) -> BOOL --- + GetStartupInfoW :: proc(lpStartupInfo: LPSTARTUPINFOW) --- GetEnvironmentVariableW :: proc(n: LPCWSTR, v: LPWSTR, nsize: DWORD) -> DWORD --- SetEnvironmentVariableW :: proc(n: LPCWSTR, v: LPCWSTR) -> BOOL --- GetEnvironmentStringsW :: proc() -> LPWCH --- @@ -315,6 +337,13 @@ foreign kernel32 { lpOverlapped: LPOVERLAPPED, lpCompletionRoutine: LPOVERLAPPED_COMPLETION_ROUTINE, ) -> BOOL --- + FindFirstChangeNotificationW :: proc( + lpPathName: LPWSTR, + bWatchSubtree: BOOL, + dwNotifyFilter: DWORD, + ) -> HANDLE --- + FindNextChangeNotification :: proc(hChangeHandle: HANDLE) -> BOOL --- + FindCloseChangeNotification :: proc(hChangeHandle: HANDLE) -> BOOL --- InitializeSRWLock :: proc(SRWLock: ^SRWLOCK) --- AcquireSRWLockExclusive :: proc(SRWLock: ^SRWLOCK) --- @@ -363,6 +392,11 @@ foreign kernel32 { GenerateConsoleCtrlEvent :: proc(dwCtrlEvent: DWORD, dwProcessGroupId: DWORD) -> BOOL --- FreeConsole :: proc() -> BOOL --- GetConsoleWindow :: proc() -> HWND --- + GetConsoleScreenBufferInfo :: proc(hConsoleOutput: HANDLE, lpConsoleScreenBufferInfo: PCONSOLE_SCREEN_BUFFER_INFO) -> BOOL --- + SetConsoleScreenBufferSize :: proc(hConsoleOutput: HANDLE, dwSize: COORD) -> BOOL --- + SetConsoleWindowInfo :: proc(hConsoleOutput: HANDLE, bAbsolute : BOOL, lpConsoleWindow: ^SMALL_RECT) -> BOOL --- + GetConsoleCursorInfo :: proc(hConsoleOutput: HANDLE, lpConsoleCursorInfo: PCONSOLE_CURSOR_INFO) -> BOOL --- + SetConsoleCursorInfo :: proc(hConsoleOutput: HANDLE, lpConsoleCursorInfo: PCONSOLE_CURSOR_INFO) -> BOOL --- GetDiskFreeSpaceExW :: proc( lpDirectoryName: LPCWSTR, @@ -370,8 +404,89 @@ foreign kernel32 { lpTotalNumberOfBytes: PULARGE_INTEGER, lpTotalNumberOfFreeBytes: PULARGE_INTEGER, ) -> BOOL --- + + GetLogicalProcessorInformation :: proc(buffer: ^SYSTEM_LOGICAL_PROCESSOR_INFORMATION, returnedLength: PDWORD) -> BOOL --- + + // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setfilecompletionnotificationmodes) + SetFileCompletionNotificationModes :: proc(FileHandle: HANDLE, Flags: u8) -> BOOL --- + // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/ioapiset/nf-ioapiset-createiocompletionport) + CreateIoCompletionPort :: proc(FileHandle: HANDLE, ExistingCompletionPort: HANDLE, CompletionKey: ^uintptr, NumberOfConcurrentThreads: DWORD) -> HANDLE --- + //[MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/ioapiset/nf-ioapiset-getqueuedcompletionstatus) + GetQueuedCompletionStatus :: proc(CompletionPort: HANDLE, lpNumberOfBytesTransferred: ^DWORD, lpCompletionKey: uintptr, lpOverlapped: ^^OVERLAPPED, dwMilliseconds: DWORD) -> BOOL --- + // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/ioapiset/nf-ioapiset-getqueuedcompletionstatusex) + GetQueuedCompletionStatusEx :: proc(CompletionPort: HANDLE, lpCompletionPortEntries: ^OVERLAPPED_ENTRY, ulCount: c_ulong, ulNumEntriesRemoved: ^c_ulong, dwMilliseconds: DWORD, fAlertable: BOOL) -> BOOL --- + // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/ioapiset/nf-ioapiset-postqueuedcompletionstatus) + PostQueuedCompletionStatus :: proc(CompletionPort: HANDLE, dwNumberOfBytesTransferred: DWORD, dwCompletionKey: c_ulong, lpOverlapped: ^OVERLAPPED) -> BOOL --- + // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/handleapi/nf-handleapi-gethandleinformation) + GetHandleInformation :: proc(hObject: HANDLE, lpdwFlags: ^DWORD) -> BOOL --- } +DEBUG_PROCESS :: 0x00000001 +DEBUG_ONLY_THIS_PROCESS :: 0x00000002 +CREATE_SUSPENDED :: 0x00000004 +DETACHED_PROCESS :: 0x00000008 +CREATE_NEW_CONSOLE :: 0x00000010 +NORMAL_PRIORITY_CLASS :: 0x00000020 +IDLE_PRIORITY_CLASS :: 0x00000040 +HIGH_PRIORITY_CLASS :: 0x00000080 +REALTIME_PRIORITY_CLASS :: 0x00000100 +CREATE_NEW_PROCESS_GROUP :: 0x00000200 +CREATE_UNICODE_ENVIRONMENT :: 0x00000400 +CREATE_SEPARATE_WOW_VDM :: 0x00000800 +CREATE_SHARED_WOW_VDM :: 0x00001000 +CREATE_FORCEDOS :: 0x00002000 +BELOW_NORMAL_PRIORITY_CLASS :: 0x00004000 +ABOVE_NORMAL_PRIORITY_CLASS :: 0x00008000 +INHERIT_PARENT_AFFINITY :: 0x00010000 +INHERIT_CALLER_PRIORITY :: 0x00020000 // Deprecated +CREATE_PROTECTED_PROCESS :: 0x00040000 +EXTENDED_STARTUPINFO_PRESENT :: 0x00080000 +PROCESS_MODE_BACKGROUND_BEGIN :: 0x00100000 +PROCESS_MODE_BACKGROUND_END :: 0x00200000 +CREATE_SECURE_PROCESS :: 0x00400000 +CREATE_BREAKAWAY_FROM_JOB :: 0x01000000 +CREATE_PRESERVE_CODE_AUTHZ_LEVEL :: 0x02000000 +CREATE_DEFAULT_ERROR_MODE :: 0x04000000 +CREATE_NO_WINDOW :: 0x08000000 +PROFILE_USER :: 0x10000000 +PROFILE_KERNEL :: 0x20000000 +PROFILE_SERVER :: 0x40000000 +CREATE_IGNORE_SYSTEM_DEFAULT :: 0x80000000 + +THREAD_BASE_PRIORITY_LOWRT :: 15 // value that gets a thread to LowRealtime-1 +THREAD_BASE_PRIORITY_MAX :: 2 // maximum thread base priority boost +THREAD_BASE_PRIORITY_MIN :: (-2) // minimum thread base priority boost +THREAD_BASE_PRIORITY_IDLE :: (-15) // value that gets a thread to idle + +THREAD_PRIORITY_LOWEST :: THREAD_BASE_PRIORITY_MIN +THREAD_PRIORITY_BELOW_NORMAL :: (THREAD_PRIORITY_LOWEST+1) +THREAD_PRIORITY_NORMAL :: 0 +THREAD_PRIORITY_HIGHEST :: THREAD_BASE_PRIORITY_MAX +THREAD_PRIORITY_ABOVE_NORMAL :: (THREAD_PRIORITY_HIGHEST-1) +THREAD_PRIORITY_ERROR_RETURN :: (MAXLONG) +THREAD_PRIORITY_TIME_CRITICAL :: THREAD_BASE_PRIORITY_LOWRT +THREAD_PRIORITY_IDLE :: THREAD_BASE_PRIORITY_IDLE +THREAD_MODE_BACKGROUND_BEGIN :: 0x00010000 +THREAD_MODE_BACKGROUND_END :: 0x00020000 + +COPY_FILE_FAIL_IF_EXISTS :: 0x00000001 +COPY_FILE_RESTARTABLE :: 0x00000002 +COPY_FILE_OPEN_SOURCE_FOR_WRITE :: 0x00000004 +COPY_FILE_ALLOW_DECRYPTED_DESTINATION :: 0x00000008 +COPY_FILE_COPY_SYMLINK :: 0x00000800 +COPY_FILE_NO_BUFFERING :: 0x00001000 +COPY_FILE_REQUEST_SECURITY_PRIVILEGES :: 0x00002000 +COPY_FILE_RESUME_FROM_PAUSE :: 0x00004000 +COPY_FILE_NO_OFFLOAD :: 0x00040000 +COPY_FILE_IGNORE_EDP_BLOCK :: 0x00400000 +COPY_FILE_IGNORE_SOURCE_ENCRYPTION :: 0x00800000 +COPY_FILE_DONT_REQUEST_DEST_WRITE_DAC :: 0x02000000 +COPY_FILE_REQUEST_COMPRESSED_TRAFFIC :: 0x10000000 +COPY_FILE_OPEN_AND_COPY_REPARSE_POINT :: 0x00200000 +COPY_FILE_DIRECTORY :: 0x00000080 +COPY_FILE_SKIP_ALTERNATE_STREAMS :: 0x00008000 +COPY_FILE_DISABLE_PRE_ALLOCATION :: 0x04000000 +COPY_FILE_ENABLE_LOW_FREE_SPACE_MODE :: 0x08000000 SECTION_QUERY :: DWORD(0x0001) SECTION_MAP_WRITE :: DWORD(0x0002) @@ -777,7 +892,7 @@ WIN32_MEMORY_REGION_INFORMATION_u_s_Bitfield :: distinct ULONG }*/ @(default_calling_convention="stdcall") -foreign kernel32 { +foreign one_core { QueryVirtualMemoryInformation :: proc( Process: HANDLE, VirtualAddress: PVOID, @@ -999,3 +1114,49 @@ foreign kernel32 { ConvertThreadToFiber :: proc(lpParameter: LPVOID) -> LPVOID --- SwitchToFiber :: proc(lpFiber: LPVOID) --- } + +LOGICAL_PROCESSOR_RELATIONSHIP :: enum c_int { + RelationProcessorCore, + RelationNumaNode, + RelationCache, + RelationProcessorPackage, + RelationGroup, + RelationProcessorDie, + RelationNumaNodeEx, + RelationProcessorModule, + RelationAll = 0xffff, +} + +PROCESSOR_CACHE_TYPE :: enum c_int { + CacheUnified, + CacheInstruction, + CacheData, + CacheTrace, +} + +CACHE_DESCRIPTOR :: struct { + Level: BYTE, + Associativity: BYTE, + LineSize: WORD, + Size: DWORD, + Type: PROCESSOR_CACHE_TYPE, +} + +ProcessorCore :: struct { + Flags: BYTE, +} +NumaNode :: struct { + NodeNumber: DWORD, +} +DUMMYUNIONNAME_u :: struct #raw_union { + Core: ProcessorCore, + Node: NumaNode, + Cache: CACHE_DESCRIPTOR, + Reserved: [2]ULONGLONG, +} + +SYSTEM_LOGICAL_PROCESSOR_INFORMATION :: struct { + ProcessorMask: ULONG_PTR, + Relationship: LOGICAL_PROCESSOR_RELATIONSHIP, + DummyUnion: DUMMYUNIONNAME_u, +} diff --git a/core/sys/windows/shell32.odin b/core/sys/windows/shell32.odin index 28da58a50..0a6f90a44 100644 --- a/core/sys/windows/shell32.odin +++ b/core/sys/windows/shell32.odin @@ -22,4 +22,39 @@ foreign shell32 { ) -> c_int --- SHFileOperationW :: proc(lpFileOp: LPSHFILEOPSTRUCTW) -> c_int --- SHGetFolderPathW :: proc(hwnd: HWND, csidl: c_int, hToken: HANDLE, dwFlags: DWORD, pszPath: LPWSTR) -> HRESULT --- + SHAppBarMessage :: proc(dwMessage: DWORD, pData: PAPPBARDATA) -> UINT_PTR --- + + Shell_NotifyIconW :: proc(dwMessage: DWORD, lpData: ^NOTIFYICONDATAW) -> BOOL --- } + +APPBARDATA :: struct { + cbSize: DWORD, + hWnd: HWND, + uCallbackMessage: UINT, + uEdge: UINT, + rc: RECT, + lParam: LPARAM, +} +PAPPBARDATA :: ^APPBARDATA + +ABM_NEW :: 0x00000000 +ABM_REMOVE :: 0x00000001 +ABM_QUERYPOS :: 0x00000002 +ABM_SETPOS :: 0x00000003 +ABM_GETSTATE :: 0x00000004 +ABM_GETTASKBARPOS :: 0x00000005 +ABM_ACTIVATE :: 0x00000006 +ABM_GETAUTOHIDEBAR :: 0x00000007 +ABM_SETAUTOHIDEBAR :: 0x00000008 +ABM_WINDOWPOSCHANGED :: 0x0000009 +ABM_SETSTATE :: 0x0000000a +ABN_STATECHANGE :: 0x0000000 +ABN_POSCHANGED :: 0x0000001 +ABN_FULLSCREENAPP :: 0x0000002 +ABN_WINDOWARRANGE :: 0x0000003 +ABS_AUTOHIDE :: 0x0000001 +ABS_ALWAYSONTOP :: 0x0000002 +ABE_LEFT :: 0 +ABE_TOP :: 1 +ABE_RIGHT :: 2 +ABE_BOTTOM :: 3 diff --git a/core/sys/windows/types.odin b/core/sys/windows/types.odin index 210c39aaa..11b87e0dc 100644 --- a/core/sys/windows/types.odin +++ b/core/sys/windows/types.odin @@ -38,6 +38,7 @@ HHOOK :: distinct HANDLE HKEY :: distinct HANDLE HDESK :: distinct HANDLE HFONT :: distinct HANDLE +HRGN :: distinct HANDLE BOOL :: distinct b32 BYTE :: distinct u8 BOOLEAN :: distinct b8 @@ -110,7 +111,7 @@ LPOVERLAPPED :: ^OVERLAPPED LPPROCESS_INFORMATION :: ^PROCESS_INFORMATION PSECURITY_ATTRIBUTES :: ^SECURITY_ATTRIBUTES LPSECURITY_ATTRIBUTES :: ^SECURITY_ATTRIBUTES -LPSTARTUPINFO :: ^STARTUPINFO +LPSTARTUPINFOW :: ^STARTUPINFOW LPTRACKMOUSEEVENT :: ^TRACKMOUSEEVENT VOID :: rawptr PVOID :: rawptr @@ -144,8 +145,6 @@ PCONDITION_VARIABLE :: ^CONDITION_VARIABLE PLARGE_INTEGER :: ^LARGE_INTEGER PSRWLOCK :: ^SRWLOCK -MMRESULT :: UINT - CREATE_WAITABLE_TIMER_MANUAL_RESET :: 0x00000001 CREATE_WAITABLE_TIMER_HIGH_RESOLUTION :: 0x00000002 @@ -153,10 +152,6 @@ TIMER_QUERY_STATE :: 0x0001 TIMER_MODIFY_STATE :: 0x0002 TIMER_ALL_ACCESS :: STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | TIMER_QUERY_STATE | TIMER_MODIFY_STATE -SOCKET :: distinct uintptr // TODO -socklen_t :: c_int -ADDRESS_FAMILY :: USHORT - TRUE :: BOOL(true) FALSE :: BOOL(false) @@ -167,6 +162,8 @@ SIZE :: struct { PSIZE :: ^SIZE LPSIZE :: ^SIZE +MAXLONG :: 0x7fffffff + FILE_ATTRIBUTE_READONLY: DWORD : 0x00000001 FILE_ATTRIBUTE_HIDDEN: DWORD : 0x00000002 FILE_ATTRIBUTE_SYSTEM: DWORD : 0x00000004 @@ -264,26 +261,6 @@ GET_FILEEX_INFO_LEVELS :: distinct i32 GetFileExInfoStandard: GET_FILEEX_INFO_LEVELS : 0 GetFileExMaxInfoLevel: GET_FILEEX_INFO_LEVELS : 1 -// String resource number bases (internal use) - -MMSYSERR_BASE :: 0 -WAVERR_BASE :: 32 -MIDIERR_BASE :: 64 -TIMERR_BASE :: 96 -JOYERR_BASE :: 160 -MCIERR_BASE :: 256 -MIXERR_BASE :: 1024 - -MCI_STRING_OFFSET :: 512 -MCI_VD_OFFSET :: 1024 -MCI_CD_OFFSET :: 1088 -MCI_WAVE_OFFSET :: 1152 -MCI_SEQ_OFFSET :: 1216 - -// timer error return values -TIMERR_NOERROR :: 0 // no error -TIMERR_NOCANDO :: TIMERR_BASE + 1 // request not completed -TIMERR_STRUCT :: TIMERR_BASE + 33 // time struct size DIAGNOSTIC_REASON_VERSION :: 0 @@ -727,6 +704,14 @@ CWPRETSTRUCT :: struct { hwnd: HWND, } +MSLLHOOKSTRUCT :: struct { + pt: POINT, + mouseData: DWORD, + flags: DWORD, + time: DWORD, + dwExtraInfo: ULONG_PTR, +} + KBDLLHOOKSTRUCT :: struct { vkCode: DWORD, scanCode: DWORD, @@ -735,6 +720,59 @@ KBDLLHOOKSTRUCT :: struct { dwExtraInfo: ULONG_PTR, } +MOUSEINPUT :: struct { + dx: LONG, + dy: LONG, + mouseData: DWORD, + dwFlags: DWORD, + time: DWORD, + dwExtraInfo: ULONG_PTR, +} + +KEYBDINPUT :: struct { + wVk: WORD, + wScan: WORD, + dwFlags: DWORD, + time: DWORD, + dwExtraInfo: ULONG_PTR, +} + +HARDWAREINPUT :: struct { + uMsg: DWORD, + wParamL: WORD, + wParamH: WORD, +} + +INPUT_TYPE :: enum DWORD { + MOUSE = 0, + KEYBOARD = 1, + HARDWARE = 2, +} + +INPUT :: struct { + type: INPUT_TYPE, + using _: struct #raw_union { + mi: MOUSEINPUT, + ki: KEYBDINPUT, + hi: HARDWAREINPUT, + }, +} + +MOUSEEVENTF_MOVE :: 0x0001 +MOUSEEVENTF_LEFTDOWN :: 0x0002 +MOUSEEVENTF_LEFTUP :: 0x0004 +MOUSEEVENTF_RIGHTDOWN :: 0x0008 +MOUSEEVENTF_RIGHTUP :: 0x0010 +MOUSEEVENTF_MIDDLEDOWN :: 0x0020 +MOUSEEVENTF_MIDDLEUP :: 0x0040 +MOUSEEVENTF_XDOWN :: 0x0080 +MOUSEEVENTF_XUP :: 0x0100 +MOUSEEVENTF_WHEEL :: 0x0800 +MOUSEEVENTF_HWHEEL :: 0x1000 +MOUSEEVENTF_MOVE_NOCOALESCE :: 0x2000 +MOUSEEVENTF_VIRTUALDESK :: 0x4000 +MOUSEEVENTF_ABSOLUTE :: 0x8000 + WNDCLASSA :: struct { style: UINT, lpfnWndProc: WNDPROC, @@ -802,6 +840,104 @@ MSG :: struct { LPMSG :: ^MSG +NOTIFYICONDATAW :: struct { + cbSize: DWORD, + hWnd: HWND, + uID: UINT, + uFlags: UINT, + uCallbackMessage: UINT, + hIcon: HICON, + szTip: [128]WCHAR, + dwState: DWORD, + dwStateMask: DWORD, + szInfo: [256]WCHAR, + using _: struct #raw_union { + uTimeout: UINT, + uVersion: UINT, + }, + szInfoTitle: [64]WCHAR, + dwInfoFlags: DWORD, + guidItem: GUID, + hBalloonIcon: HICON, +} + +NIF_MESSAGE :: 0x00000001 +NIF_ICON :: 0x00000002 +NIF_TIP :: 0x00000004 +NIF_STATE :: 0x00000008 +NIF_INFO :: 0x00000010 +NIF_GUID :: 0x00000020 +NIF_REALTIME :: 0x00000040 +NIF_SHOWTIP :: 0x00000080 + +NIM_ADD :: 0x00000000 +NIM_MODIFY :: 0x00000001 +NIM_DELETE :: 0x00000002 +NIM_SETFOCUS :: 0x00000003 +NIM_SETVERSION :: 0x00000004 + +// Menu flags for Add/Check/EnableMenuItem() +MF_INSERT :: 0x00000000 +MF_CHANGE :: 0x00000080 +MF_APPEND :: 0x00000100 +MF_DELETE :: 0x00000200 +MF_REMOVE :: 0x00001000 + +MF_BYCOMMAND :: 0x00000000 +MF_BYPOSITION :: 0x00000400 + +MF_SEPARATOR :: 0x00000800 + +MF_ENABLED :: 0x00000000 +MF_GRAYED :: 0x00000001 +MF_DISABLED :: 0x00000002 + +MF_UNCHECKED :: 0x00000000 +MF_CHECKED :: 0x00000008 +MF_USECHECKBITMAPS :: 0x00000200 + +MF_STRING :: 0x00000000 +MF_BITMAP :: 0x00000004 +MF_OWNERDRAW :: 0x00000100 + +MF_POPUP :: 0x00000010 +MF_MENUBARBREAK :: 0x00000020 +MF_MENUBREAK :: 0x00000040 + +MF_UNHILITE :: 0x00000000 +MF_HILITE :: 0x00000080 + +MF_DEFAULT :: 0x00001000 +MF_SYSMENU :: 0x00002000 +MF_HELP :: 0x00004000 +MF_RIGHTJUSTIFY :: 0x00004000 + +MF_MOUSESELECT :: 0x00008000 +MF_END :: 0x00000080 // Obsolete -- only used by old RES files + +// Flags for TrackPopupMenu +TPM_LEFTBUTTON :: 0x0000 +TPM_RIGHTBUTTON :: 0x0002 +TPM_LEFTALIGN :: 0x0000 +TPM_CENTERALIGN :: 0x0004 +TPM_RIGHTALIGN :: 0x0008 +TPM_TOPALIGN :: 0x0000 +TPM_VCENTERALIGN :: 0x0010 +TPM_BOTTOMALIGN :: 0x0020 + +TPM_HORIZONTAL :: 0x0000 /* Horz alignment matters more */ +TPM_VERTICAL :: 0x0040 /* Vert alignment matters more */ +TPM_NONOTIFY :: 0x0080 /* Don't send any notification msgs */ +TPM_RETURNCMD :: 0x0100 +TPM_RECURSE :: 0x0001 +TPM_HORPOSANIMATION :: 0x0400 +TPM_HORNEGANIMATION :: 0x0800 +TPM_VERPOSANIMATION :: 0x1000 +TPM_VERNEGANIMATION :: 0x2000 +TPM_NOANIMATION :: 0x4000 +TPM_LAYOUTRTL :: 0x8000 +TPM_WORKAREA :: 0x10000 + // WM_NCHITTEST and MOUSEHOOKSTRUCT Mouse Position Codes HTERROR :: -2 HTTRANSPARENT :: -1 @@ -1867,30 +2003,6 @@ BI_BITFIELDS :: 3 BI_JPEG :: 4 BI_PNG :: 5 -WSA_FLAG_OVERLAPPED: DWORD : 0x01 -WSA_FLAG_NO_HANDLE_INHERIT: DWORD : 0x80 - -WSADESCRIPTION_LEN :: 256 -WSASYS_STATUS_LEN :: 128 -WSAPROTOCOL_LEN: DWORD : 255 -INVALID_SOCKET :: ~SOCKET(0) - -WSAEACCES: c_int : 10013 -WSAEINVAL: c_int : 10022 -WSAEWOULDBLOCK: c_int : 10035 -WSAEPROTOTYPE: c_int : 10041 -WSAEADDRINUSE: c_int : 10048 -WSAEADDRNOTAVAIL: c_int : 10049 -WSAECONNABORTED: c_int : 10053 -WSAECONNRESET: c_int : 10054 -WSAENOTCONN: c_int : 10057 -WSAESHUTDOWN: c_int : 10058 -WSAETIMEDOUT: c_int : 10060 -WSAECONNREFUSED: c_int : 10061 -WSATRY_AGAIN: c_int : 11002 - -MAX_PROTOCOL_CHAIN: DWORD : 7 - MAXIMUM_REPARSE_DATA_BUFFER_SIZE :: 16 * 1024 FSCTL_GET_REPARSE_POINT: DWORD : 0x900a8 IO_REPARSE_TAG_SYMLINK: DWORD : 0xa000000c @@ -1932,7 +2044,6 @@ TLS_OUT_OF_INDEXES: DWORD : 0xFFFFFFFF DLL_THREAD_DETACH: DWORD : 3 DLL_PROCESS_DETACH: DWORD : 0 -CREATE_SUSPENDED :: DWORD(0x00000004) INFINITE :: ~DWORD(0) @@ -1941,51 +2052,8 @@ DUPLICATE_SAME_ACCESS: DWORD : 0x00000002 CONDITION_VARIABLE_INIT :: CONDITION_VARIABLE{} SRWLOCK_INIT :: SRWLOCK{} -DETACHED_PROCESS: DWORD : 0x00000008 -CREATE_NEW_CONSOLE: DWORD : 0x00000010 -CREATE_NO_WINDOW: DWORD : 0x08000000 -CREATE_NEW_PROCESS_GROUP: DWORD : 0x00000200 -CREATE_UNICODE_ENVIRONMENT: DWORD : 0x00000400 STARTF_USESTDHANDLES: DWORD : 0x00000100 -AF_INET: c_int : 2 -AF_INET6: c_int : 23 -SD_BOTH: c_int : 2 -SD_RECEIVE: c_int : 0 -SD_SEND: c_int : 1 -SOCK_DGRAM: c_int : 2 -SOCK_STREAM: c_int : 1 -SOL_SOCKET: c_int : 0xffff -SO_RCVTIMEO: c_int : 0x1006 -SO_SNDTIMEO: c_int : 0x1005 -SO_REUSEADDR: c_int : 0x0004 -IPPROTO_IP: c_int : 0 -IPPROTO_TCP: c_int : 6 -IPPROTO_IPV6: c_int : 41 -TCP_NODELAY: c_int : 0x0001 -IP_TTL: c_int : 4 -IPV6_V6ONLY: c_int : 27 -SO_ERROR: c_int : 0x1007 -SO_BROADCAST: c_int : 0x0020 -IP_MULTICAST_LOOP: c_int : 11 -IPV6_MULTICAST_LOOP: c_int : 11 -IP_MULTICAST_TTL: c_int : 10 -IP_ADD_MEMBERSHIP: c_int : 12 -IP_DROP_MEMBERSHIP: c_int : 13 -IPV6_ADD_MEMBERSHIP: c_int : 12 -IPV6_DROP_MEMBERSHIP: c_int : 13 -MSG_PEEK: c_int : 0x2 - -ip_mreq :: struct { - imr_multiaddr: in_addr, - imr_interface: in_addr, -} - -ipv6_mreq :: struct { - ipv6mr_multiaddr: in6_addr, - ipv6mr_interface: c_uint, -} - VOLUME_NAME_DOS: DWORD : 0x0 MOVEFILE_REPLACE_EXISTING: DWORD : 1 @@ -2346,8 +2414,7 @@ PROCESS_INFORMATION :: struct { dwThreadId: DWORD, } -// FYI: This is STARTUPINFOW, not STARTUPINFOA -STARTUPINFO :: struct { +STARTUPINFOW :: struct { cb: DWORD, lpReserved: LPWSTR, lpDesktop: LPWSTR, @@ -2368,11 +2435,6 @@ STARTUPINFO :: struct { hStdError: HANDLE, } -SOCKADDR :: struct { - sa_family: ADDRESS_FAMILY, - sa_data: [14]CHAR, -} - FILETIME :: struct { dwLowDateTime: DWORD, dwHighDateTime: DWORD, @@ -2383,6 +2445,20 @@ FILETIME_as_unix_nanoseconds :: proc "contextless" (ft: FILETIME) -> i64 { return (t - 116444736000000000) * 100 } +OBJECT_ATTRIBUTES :: struct { + Length: c_ulong, + RootDirectory: HANDLE, + ObjectName: ^UNICODE_STRING, + Attributes: c_ulong, + SecurityDescriptor: rawptr, + SecurityQualityOfService: rawptr, +} + +UNICODE_STRING :: struct { + Length: u16, + MaximumLength: u16, + Buffer: ^u16, +} OVERLAPPED :: struct { Internal: ^c_ulong, @@ -2392,6 +2468,13 @@ OVERLAPPED :: struct { hEvent: HANDLE, } +OVERLAPPED_ENTRY :: struct { + lpCompletionKey: c_ulong, + lpOverlapped: ^OVERLAPPED, + Internal: c_ulong, + dwNumberOfBytesTransferred: DWORD, +} + LPOVERLAPPED_COMPLETION_ROUTINE :: #type proc "stdcall" ( dwErrorCode: DWORD, dwNumberOfBytesTransfered: DWORD, @@ -2405,74 +2488,6 @@ ADDRESS_MODE :: enum c_int { AddrModeFlat, } -SOCKADDR_STORAGE_LH :: struct { - ss_family: ADDRESS_FAMILY, - __ss_pad1: [6]CHAR, - __ss_align: i64, - __ss_pad2: [112]CHAR, -} - -ADDRINFOA :: struct { - ai_flags: c_int, - ai_family: c_int, - ai_socktype: c_int, - ai_protocol: c_int, - ai_addrlen: size_t, - ai_canonname: ^c_char, - ai_addr: ^SOCKADDR, - ai_next: ^ADDRINFOA, -} - -PADDRINFOEXW :: ^ADDRINFOEXW -LPADDRINFOEXW :: ^ADDRINFOEXW -ADDRINFOEXW :: struct { - ai_flags: c_int, - ai_family: c_int, - ai_socktype: c_int, - ai_protocol: c_int, - ai_addrlen: size_t, - ai_canonname: wstring, - ai_addr: ^sockaddr, - ai_blob: rawptr, - ai_bloblen: size_t, - ai_provider: LPGUID, - ai_next: ^ADDRINFOEXW, -} - -LPLOOKUPSERVICE_COMPLETION_ROUTINE :: #type proc "stdcall" ( - dwErrorCode: DWORD, - dwNumberOfBytesTransfered: DWORD, - lpOverlapped: LPOVERLAPPED, -) - -sockaddr :: struct { - sa_family: USHORT, - sa_data: [14]byte, -} - -sockaddr_in :: struct { - sin_family: ADDRESS_FAMILY, - sin_port: USHORT, - sin_addr: in_addr, - sin_zero: [8]CHAR, -} - -sockaddr_in6 :: struct { - sin6_family: ADDRESS_FAMILY, - sin6_port: USHORT, - sin6_flowinfo: c_ulong, - sin6_addr: in6_addr, - sin6_scope_id: c_ulong, -} - -in_addr :: struct { - s_addr: u32, -} - -in6_addr :: struct { - s6_addr: [16]u8, -} - EXCEPTION_DISPOSITION :: enum c_int { ExceptionContinueExecution, ExceptionContinueSearch, @@ -2563,6 +2578,27 @@ FILE_ATTRIBUTE_TAG_INFO :: struct { ReparseTag: DWORD, } +PADDRINFOEXW :: ^ADDRINFOEXW +LPADDRINFOEXW :: ^ADDRINFOEXW +ADDRINFOEXW :: struct { + ai_flags: c_int, + ai_family: c_int, + ai_socktype: c_int, + ai_protocol: c_int, + ai_addrlen: size_t, + ai_canonname: wstring, + ai_addr: ^sockaddr, + ai_blob: rawptr, + ai_bloblen: size_t, + ai_provider: LPGUID, + ai_next: ^ADDRINFOEXW, +} + +LPLOOKUPSERVICE_COMPLETION_ROUTINE :: #type proc "stdcall" ( + dwErrorCode: DWORD, + dwNumberOfBytesTransfered: DWORD, + lpOverlapped: LPOVERLAPPED, +) // https://docs.microsoft.com/en-gb/windows/win32/api/sysinfoapi/ns-sysinfoapi-system_info @@ -3883,3 +3919,262 @@ COORD :: struct { X: SHORT, Y: SHORT, } + +SMALL_RECT :: struct { + Left: SHORT, + Top: SHORT, + Right: SHORT, + Bottom: SHORT, +} + +CONSOLE_SCREEN_BUFFER_INFO :: struct { + dwSize: COORD, + dwCursorPosition: COORD, + wAttributes: WORD, + srWindow: SMALL_RECT, + dwMaximumWindowSize: COORD, +} + +CONSOLE_CURSOR_INFO :: struct { + dwSize: DWORD, + bVisible: BOOL, +} + + +PCONSOLE_SCREEN_BUFFER_INFO :: ^CONSOLE_SCREEN_BUFFER_INFO +PCONSOLE_CURSOR_INFO :: ^CONSOLE_CURSOR_INFO + +// +// Networking +// +WSA_FLAG_OVERLAPPED :: 1 +WSA_FLAG_MULTIPOINT_C_ROOT :: 2 +WSA_FLAG_MULTIPOINT_C_LEAF :: 4 +WSA_FLAG_MULTIPOINT_D_ROOT :: 8 +WSA_FLAG_MULTIPOINT_D_LEAF :: 16 +WSA_FLAG_ACCESS_SYSTEM_SECURITY :: 32 +WSA_FLAG_NO_HANDLE_INHERIT :: 128 +WSADESCRIPTION_LEN :: 256 +WSASYS_STATUS_LEN :: 128 +WSAPROTOCOL_LEN :: 255 +INVALID_SOCKET :: ~SOCKET(0) +SOMAXCONN :: 128 // The number of messages that can be queued in memory after being received; use 2-4 for Bluetooth. + // This is for the 'backlog' parameter to listen(). +SOCKET_ERROR :: -1 + +// Networking errors +WSAEINTR :: 10004 // Call interrupted. CancelBlockingCall was called. (This is different on Linux.) +WSAEACCES :: 10013 // If you try to bind a Udp socket to the broadcast address without the socket option set. +WSAEFAULT :: 10014 // A pointer that was passed to a WSA function is invalid, such as a buffer size is smaller than you said it was +WSAEINVAL :: 10022 // Invalid argument supplied +WSAEMFILE :: 10024 // SOCKET handles exhausted +WSAEWOULDBLOCK :: 10035 // No data is ready yet +WSAENOTSOCK :: 10038 // Not a socket. +WSAEINPROGRESS :: 10036 // WS1.1 call is in progress or callback function is still being processed +WSAEALREADY :: 10037 // Already connecting in parallel. +WSAEMSGSIZE :: 10040 // Message was truncated because it exceeded max datagram size. +WSAEPROTOTYPE :: 10041 // Wrong protocol for the provided socket +WSAENOPROTOOPT :: 10042 // TODO +WSAEPROTONOSUPPORT :: 10043 // Protocol not supported +WSAESOCKTNOSUPPORT :: 10044 // Socket type not supported in the given address family +WSAEAFNOSUPPORT :: 10047 // Address family not supported +WSAEOPNOTSUPP :: 10045 // Attempt to accept on non-stream socket, etc. +WSAEADDRINUSE :: 10048 // Endpoint being bound is in use by another socket. +WSAEADDRNOTAVAIL :: 10049 // Not a valid local IP address on this computer. +WSAENETDOWN :: 10050 // Network subsystem failure on the local machine. +WSAENETUNREACH :: 10051 // The local machine is not connected to the network. +WSAENETRESET :: 10052 // Keepalive failure detected, or TTL exceeded when receiving UDP packets. +WSAECONNABORTED :: 10053 // Connection has been aborted by software in the host machine. +WSAECONNRESET :: 10054 // The connection was reset while trying to accept, read or write. +WSAENOBUFS :: 10055 // No buffer space is available. The outgoing queue may be full in which case you should probably try again after a pause. +WSAEISCONN :: 10056 // The socket is already connected. +WSAENOTCONN :: 10057 // The socket is not connected yet, or no address was supplied to sendto. +WSAESHUTDOWN :: 10058 // The socket has been shutdown in the direction required. +WSAETIMEDOUT :: 10060 // The timeout duration was reached before any data was received / before all data was sent. +WSAECONNREFUSED :: 10061 // The remote machine is not listening on that endpoint. +WSAEHOSTDOWN :: 10064 // Destination host was down. +WSAEHOSTUNREACH :: 10065 // The remote machine is not connected to the network. +WSAENOTINITIALISED :: 10093 // Needs WSAStartup call +WSAEINVALIDPROCTABLE :: 10104 // Invalid or incomplete procedure table was returned +WSAEINVALIDPROVIDER :: 10105 // Service provider version is not 2.2 +WSAEPROVIDERFAILEDINIT :: 10106 // Service provider failed to initialize + +// Address families +AF_UNSPEC : c_int : 0 // Unspecified +AF_INET : c_int : 2 // IPv4 +AF_INET6 : c_int : 23 // IPv6 +AF_IRDA : c_int : 26 // Infrared +AF_BTH : c_int : 32 // Bluetooth + +// Socket types +SOCK_STREAM : c_int : 1 // TCP +SOCK_DGRAM : c_int : 2 // UDP +SOCK_RAW : c_int : 3 // Requires options IP_HDRINCL for v4, IPV6_HDRINCL for v6, on the socket +SOCK_RDM : c_int : 4 // Requires "Reliable Multicast Protocol" to be installed - see WSAEnumProtocols +SOCK_SEQPACKET : c_int : 5 // Provides psuedo-stream packet based on DGRAMs. + +// Protocols +IPPROTO_IP : c_int : 0 +IPPROTO_ICMP : c_int : 1 // (AF_UNSPEC, AF_INET, AF_INET6) + SOCK_RAW | not specified +IPPROTO_IGMP : c_int : 2 // (AF_UNSPEC, AF_INET, AF_INET6) + SOCK_RAW | not specified +BTHPROTO_RFCOMM : c_int : 3 // Bluetooth: AF_BTH + SOCK_STREAM +IPPROTO_TCP : c_int : 6 // (AF_INET, AF_INET6) + SOCK_STREAM +IPPROTO_UDP : c_int : 17 // (AF_INET, AF_INET6) + SOCK_DGRAM +IPPROTO_ICMPV6 : c_int : 58 // (AF_UNSPEC, AF_INET, AF_INET6) + SOCK_RAW +IPPROTO_RM : c_int : 113 // AF_INET + SOCK_RDM [requires "Reliable Multicast Protocol" to be installed - see WSAEnumProtocols] + +// Shutdown manners +SD_RECEIVE : c_int : 0 +SD_SEND : c_int : 1 +SD_BOTH : c_int : 2 + +// Socket 'levels' +SOL_SOCKET : c_int : 0xffff // Socket options for any socket. +IPPROTO_IPV6 : c_int : 41 // Socket options for IPV6. + +// Options for any sockets +SO_ACCEPTCONN : c_int : 0x0002 +SO_REUSEADDR : c_int : 0x0004 +SO_KEEPALIVE : c_int : 0x0008 +SO_SNDTIMEO : c_int : 0x1005 +SO_RCVTIMEO : c_int : 0x1006 +SO_EXCLUSIVEADDRUSE : c_int : ~SO_REUSEADDR +SO_CONDITIONAL_ACCEPT : c_int : 0x3002 +SO_DONTLINGER : c_int : ~SO_LINGER +SO_OOBINLINE : c_int : 0x0100 +SO_LINGER : c_int : 0x0080 +SO_RCVBUF : c_int : 0x1002 +SO_SNDBUF : c_int : 0x1001 +SO_ERROR : c_int : 0x1007 +SO_BROADCAST : c_int : 0x0020 + +TCP_NODELAY: c_int : 0x0001 +IP_TTL: c_int : 4 +IPV6_V6ONLY: c_int : 27 +IP_MULTICAST_LOOP: c_int : 11 +IPV6_MULTICAST_LOOP: c_int : 11 +IP_MULTICAST_TTL: c_int : 10 +IP_ADD_MEMBERSHIP: c_int : 12 + +IPV6_ADD_MEMBERSHIP: c_int : 12 +IPV6_DROP_MEMBERSHIP: c_int : 13 + +MAX_PROTOCOL_CHAIN: DWORD : 7 + +// Used with the SO_LINGER socket option to setsockopt(). +LINGER :: struct { + l_onoff: c.ushort, + l_linger: c.ushort, +} +// Send/Receive flags. +MSG_OOB : c_int : 1 // `send`/`recv` should process out-of-band data. +MSG_PEEK : c_int : 2 // `recv` should not remove the data from the buffer. Only valid for non-overlapped operations. + + +SOCKET :: distinct uintptr // TODO +socklen_t :: c_int +ADDRESS_FAMILY :: USHORT + +ip_mreq :: struct { + imr_multiaddr: in_addr, + imr_interface: in_addr, +} + +ipv6_mreq :: struct { + ipv6mr_multiaddr: in6_addr, + ipv6mr_interface: c_uint, +} + +SOCKADDR_STORAGE_LH :: struct { + ss_family: ADDRESS_FAMILY, + __ss_pad1: [6]CHAR, + __ss_align: i64, + __ss_pad2: [112]CHAR, +} + +ADDRINFOA :: struct { + ai_flags: c_int, + ai_family: c_int, + ai_socktype: c_int, + ai_protocol: c_int, + ai_addrlen: size_t, + ai_canonname: ^c_char, + ai_addr: ^SOCKADDR, + ai_next: ^ADDRINFOA, +} + +sockaddr :: struct { + sa_family: USHORT, + sa_data: [14]byte, +} + +sockaddr_in :: struct { + sin_family: ADDRESS_FAMILY, + sin_port: u16be, + sin_addr: in_addr, + sin_zero: [8]CHAR, +} +sockaddr_in6 :: struct { + sin6_family: ADDRESS_FAMILY, + sin6_port: u16be, + sin6_flowinfo: c_ulong, + sin6_addr: in6_addr, + sin6_scope_id: c_ulong, +} + +in_addr :: struct { + s_addr: u32, +} + +in6_addr :: struct { + s6_addr: [16]u8, +} + + +DNS_STATUS :: distinct DWORD // zero is success +DNS_INFO_NO_RECORDS :: 9501 +DNS_QUERY_NO_RECURSION :: 0x00000004 + +DNS_RECORD :: struct { + pNext: ^DNS_RECORD, + pName: cstring, + wType: WORD, + wDataLength: USHORT, + Flags: DWORD, + dwTtl: DWORD, + _: DWORD, + Data: struct #raw_union { + CNAME: DNS_PTR_DATAA, + A: u32be, // Ipv4 Address + AAAA: u128be, // Ipv6 Address + TXT: DNS_TXT_DATAA, + NS: DNS_PTR_DATAA, + MX: DNS_MX_DATAA, + SRV: DNS_SRV_DATAA, + }, +} + +DNS_TXT_DATAA :: struct { + dwStringCount: DWORD, + pStringArray: cstring, +} + +DNS_PTR_DATAA :: cstring + +DNS_MX_DATAA :: struct { + pNameExchange: cstring, // the hostname + wPreference: WORD, // lower values preferred + _: WORD, // padding. +} +DNS_SRV_DATAA :: struct { + pNameTarget: cstring, + wPriority: u16, + wWeight: u16, + wPort: u16, + _: WORD, // padding +} + +SOCKADDR :: struct { + sa_family: ADDRESS_FAMILY, + sa_data: [14]CHAR, +} diff --git a/core/sys/windows/user32.odin b/core/sys/windows/user32.odin index 61f2a3dac..29fa4da17 100644 --- a/core/sys/windows/user32.odin +++ b/core/sys/windows/user32.odin @@ -38,6 +38,7 @@ foreign user32 { DestroyWindow :: proc(hWnd: HWND) -> BOOL --- ShowWindow :: proc(hWnd: HWND, nCmdShow: c_int) -> BOOL --- + IsWindow :: proc(hWnd: HWND) -> BOOL --- BringWindowToTop :: proc(hWnd: HWND) -> BOOL --- GetTopWindow :: proc(hWnd: HWND) -> HWND --- SetForegroundWindow :: proc(hWnd: HWND) -> BOOL --- @@ -51,6 +52,8 @@ foreign user32 { TranslateMessage :: proc(lpMsg: ^MSG) -> BOOL --- DispatchMessageW :: proc(lpMsg: ^MSG) -> LRESULT --- + WaitMessage :: proc() -> BOOL --- + PeekMessageA :: proc(lpMsg: ^MSG, hWnd: HWND, wMsgFilterMin: UINT, wMsgFilterMax: UINT, wRemoveMsg: UINT) -> BOOL --- PeekMessageW :: proc(lpMsg: ^MSG, hWnd: HWND, wMsgFilterMin: UINT, wMsgFilterMax: UINT, wRemoveMsg: UINT) -> BOOL --- @@ -109,6 +112,12 @@ foreign user32 { GetDlgCtrlID :: proc(hWnd: HWND) -> c_int --- GetDlgItem :: proc(hDlg: HWND, nIDDlgItem: c_int) -> HWND --- + CreatePopupMenu :: proc() -> HMENU --- + DestroyMenu :: proc(hMenu: HMENU) -> BOOL --- + AppendMenuW :: proc(hMenu: HMENU, uFlags: UINT, uIDNewItem: UINT_PTR, lpNewItem: LPCWSTR) -> BOOL --- + TrackPopupMenu :: proc(hMenu: HMENU, uFlags: UINT, x: int, y: int, nReserved: int, hWnd: HWND, prcRect: ^RECT) -> i32 --- + RegisterWindowMessageW :: proc(lpString: LPCWSTR) -> UINT --- + GetUpdateRect :: proc(hWnd: HWND, lpRect: LPRECT, bErase: BOOL) -> BOOL --- ValidateRect :: proc(hWnd: HWND, lpRect: ^RECT) -> BOOL --- InvalidateRect :: proc(hWnd: HWND, lpRect: ^RECT, bErase: BOOL) -> BOOL --- @@ -123,6 +132,8 @@ foreign user32 { GetKeyState :: proc(nVirtKey: c_int) -> SHORT --- GetAsyncKeyState :: proc(vKey: c_int) -> SHORT --- + + GetKeyboardState :: proc(lpKeyState: PBYTE) -> BOOL --- MapVirtualKeyW :: proc(uCode: UINT, uMapType: UINT) -> UINT --- @@ -203,6 +214,20 @@ foreign user32 { GetRawInputDeviceList :: proc(pRawInputDeviceList: PRAWINPUTDEVICELIST, puiNumDevices: PUINT, cbSize: UINT) -> UINT --- GetRegisteredRawInputDevices :: proc(pRawInputDevices: PRAWINPUTDEVICE, puiNumDevices: PUINT, cbSize: UINT) -> UINT --- RegisterRawInputDevices :: proc(pRawInputDevices: PCRAWINPUTDEVICE, uiNumDevices: UINT, cbSize: UINT) -> BOOL --- + + SendInput :: proc(cInputs: UINT, pInputs: [^]INPUT, cbSize: c_int) -> UINT --- + + SetLayeredWindowAttributes :: proc(hWnd: HWND, crKey: COLORREF, bAlpha: BYTE, dwFlags: DWORD) -> BOOL --- + + FillRect :: proc(hDC: HDC, lprc: ^RECT, hbr: HBRUSH) -> int --- + EqualRect :: proc(lprc1: ^RECT, lprc2: ^RECT) -> BOOL --- + + GetWindowInfo :: proc(hwnd: HWND, pwi: PWINDOWINFO) -> BOOL --- + GetWindowPlacement :: proc(hWnd: HWND, lpwndpl: ^WINDOWPLACEMENT) -> BOOL --- + SetWindowPlacement :: proc(hwnd: HWND, lpwndpl: ^WINDOWPLACEMENT) -> BOOL --- + SetWindowRgn :: proc(hWnd: HWND, hRgn: HRGN, bRedraw: BOOL) -> int --- + CreateRectRgnIndirect :: proc(lprect: ^RECT) -> HRGN --- + GetSystemMetricsForDpi :: proc(nIndex: int, dpi: UINT) -> int --- } CreateWindowW :: #force_inline proc "stdcall" ( @@ -433,3 +458,26 @@ RI_MOUSE_BUTTON_5_DOWN :: 0x0100 RI_MOUSE_BUTTON_5_UP :: 0x0200 RI_MOUSE_WHEEL :: 0x0400 RI_MOUSE_HWHEEL :: 0x0800 + +WINDOWPLACEMENT :: struct { + length: UINT, + flags: UINT, + showCmd: UINT, + ptMinPosition: POINT, + ptMaxPosition: POINT, + rcNormalPosition: RECT, +} + +WINDOWINFO :: struct { + cbSize: DWORD, + rcWindow: RECT, + rcClient: RECT, + dwStyle: DWORD, + dwExStyle: DWORD, + dwWindowStatus: DWORD, + cxWindowBorders: UINT, + cyWindowBorders: UINT, + atomWindowType: ATOM, + wCreatorVersion: WORD, +} +PWINDOWINFO :: ^WINDOWINFO diff --git a/core/sys/windows/util.odin b/core/sys/windows/util.odin index 298588cb6..9c9d8f7b4 100644 --- a/core/sys/windows/util.odin +++ b/core/sys/windows/util.odin @@ -457,8 +457,8 @@ run_as_user :: proc(username, password, application, commandline: string, pi: ^P // err := GetLastError(); // fmt.printf("GetLastError: %v\n", err); } - si := STARTUPINFO{} - si.cb = size_of(STARTUPINFO) + si := STARTUPINFOW{} + si.cb = size_of(STARTUPINFOW) pi := pi ok = bool(CreateProcessAsUserW( @@ -485,3 +485,24 @@ run_as_user :: proc(username, password, application, commandline: string, pi: ^P return false } } + +ensure_winsock_initialized :: proc() { + @static gate := false + @static initted := false + + if initted { + return + } + + for intrinsics.atomic_compare_exchange_strong(&gate, false, true) { + intrinsics.cpu_relax() + } + defer intrinsics.atomic_store(&gate, false) + + unused_info: WSADATA + version_requested := WORD(2) << 8 | 2 + res := WSAStartup(version_requested, &unused_info) + assert(res == 0, "unable to initialized Winsock2") + + initted = true +} diff --git a/core/sys/windows/ux_theme.odin b/core/sys/windows/ux_theme.odin new file mode 100644 index 000000000..39b489bc0 --- /dev/null +++ b/core/sys/windows/ux_theme.odin @@ -0,0 +1,12 @@ +// +build windows +package sys_windows + +foreign import uxtheme "system:UxTheme.lib" + +MARGINS :: distinct [4]int +PMARGINS :: ^MARGINS + +@(default_calling_convention="stdcall") +foreign uxtheme { + IsThemeActive :: proc() -> BOOL --- +} diff --git a/core/sys/windows/winmm.odin b/core/sys/windows/winmm.odin index 64ace19fc..445470f6e 100644 --- a/core/sys/windows/winmm.odin +++ b/core/sys/windows/winmm.odin @@ -3,9 +3,170 @@ package sys_windows foreign import winmm "system:Winmm.lib" +MMRESULT :: UINT + @(default_calling_convention="stdcall") foreign winmm { + timeGetDevCaps :: proc(ptc: LPTIMECAPS, cbtc: UINT) -> MMRESULT --- timeBeginPeriod :: proc(uPeriod: UINT) -> MMRESULT --- timeEndPeriod :: proc(uPeriod: UINT) -> MMRESULT --- timeGetTime :: proc() -> DWORD --- } + +LPTIMECAPS :: ^TIMECAPS +TIMECAPS :: struct { + wPeriodMin: UINT, + wPeriodMax: UINT, +} + +// String resource number bases (internal use) +MMSYSERR_BASE :: 0 +WAVERR_BASE :: 32 +MIDIERR_BASE :: 64 +TIMERR_BASE :: 96 +JOYERR_BASE :: 160 +MCIERR_BASE :: 256 +MIXERR_BASE :: 1024 + +MCI_STRING_OFFSET :: 512 +MCI_VD_OFFSET :: 1024 +MCI_CD_OFFSET :: 1088 +MCI_WAVE_OFFSET :: 1152 +MCI_SEQ_OFFSET :: 1216 + +/* general error return values */ +MMSYSERR_NOERROR :: 0 /* no error */ +MMSYSERR_ERROR :: MMSYSERR_BASE + 1 /* unspecified error */ +MMSYSERR_BADDEVICEID :: MMSYSERR_BASE + 2 /* device ID out of range */ +MMSYSERR_NOTENABLED :: MMSYSERR_BASE + 3 /* driver failed enable */ +MMSYSERR_ALLOCATED :: MMSYSERR_BASE + 4 /* device already allocated */ +MMSYSERR_INVALHANDLE :: MMSYSERR_BASE + 5 /* device handle is invalid */ +MMSYSERR_NODRIVER :: MMSYSERR_BASE + 6 /* no device driver present */ +MMSYSERR_NOMEM :: MMSYSERR_BASE + 7 /* memory allocation error */ +MMSYSERR_NOTSUPPORTED :: MMSYSERR_BASE + 8 /* function isn't supported */ +MMSYSERR_BADERRNUM :: MMSYSERR_BASE + 9 /* error value out of range */ +MMSYSERR_INVALFLAG :: MMSYSERR_BASE + 10 /* invalid flag passed */ +MMSYSERR_INVALPARAM :: MMSYSERR_BASE + 11 /* invalid parameter passed */ +MMSYSERR_HANDLEBUSY :: MMSYSERR_BASE + 12 /* handle being used simultaneously on another thread (eg callback) */ +MMSYSERR_INVALIDALIAS :: MMSYSERR_BASE + 13 /* specified alias not found */ +MMSYSERR_BADDB :: MMSYSERR_BASE + 14 /* bad registry database */ +MMSYSERR_KEYNOTFOUND :: MMSYSERR_BASE + 15 /* registry key not found */ +MMSYSERR_READERROR :: MMSYSERR_BASE + 16 /* registry read error */ +MMSYSERR_WRITEERROR :: MMSYSERR_BASE + 17 /* registry write error */ +MMSYSERR_DELETEERROR :: MMSYSERR_BASE + 18 /* registry delete error */ +MMSYSERR_VALNOTFOUND :: MMSYSERR_BASE + 19 /* registry value not found */ +MMSYSERR_NODRIVERCB :: MMSYSERR_BASE + 20 /* driver does not call DriverCallback */ +MMSYSERR_MOREDATA :: MMSYSERR_BASE + 21 /* more data to be returned */ +MMSYSERR_LASTERROR :: MMSYSERR_BASE + 21 /* last error in range */ + +/* waveform audio error return values */ +WAVERR_BADFORMAT :: WAVERR_BASE + 0 /* unsupported wave format */ +WAVERR_STILLPLAYING :: WAVERR_BASE + 1 /* still something playing */ +WAVERR_UNPREPARED :: WAVERR_BASE + 2 /* header not prepared */ +WAVERR_SYNC :: WAVERR_BASE + 3 /* device is synchronous */ +WAVERR_LASTERROR :: WAVERR_BASE + 3 /* last error in range */ + +/* MIDI error return values */ +MIDIERR_UNPREPARED :: MIDIERR_BASE + 0 /* header not prepared */ +MIDIERR_STILLPLAYING :: MIDIERR_BASE + 1 /* still something playing */ +MIDIERR_NOMAP :: MIDIERR_BASE + 2 /* no configured instruments */ +MIDIERR_NOTREADY :: MIDIERR_BASE + 3 /* hardware is still busy */ +MIDIERR_NODEVICE :: MIDIERR_BASE + 4 /* port no longer connected */ +MIDIERR_INVALIDSETUP :: MIDIERR_BASE + 5 /* invalid MIF */ +MIDIERR_BADOPENMODE :: MIDIERR_BASE + 6 /* operation unsupported w/ open mode */ +MIDIERR_DONT_CONTINUE :: MIDIERR_BASE + 7 /* thru device 'eating' a message */ +MIDIERR_LASTERROR :: MIDIERR_BASE + 7 /* last error in range */ + +/* timer error return values */ +TIMERR_NOERROR :: 0 /* no error */ +TIMERR_NOCANDO :: TIMERR_BASE + 1 /* request not completed */ +TIMERR_STRUCT :: TIMERR_BASE + 33 /* time struct size */ + +/* joystick error return values */ +JOYERR_NOERROR :: 0 /* no error */ +JOYERR_PARMS :: JOYERR_BASE + 5 /* bad parameters */ +JOYERR_NOCANDO :: JOYERR_BASE + 6 /* request not completed */ +JOYERR_UNPLUGGED :: JOYERR_BASE + 7 /* joystick is unplugged */ + +/* MCI error return values */ +MCIERR_INVALID_DEVICE_ID :: MCIERR_BASE + 1 +MCIERR_UNRECOGNIZED_KEYWORD :: MCIERR_BASE + 3 +MCIERR_UNRECOGNIZED_COMMAND :: MCIERR_BASE + 5 +MCIERR_HARDWARE :: MCIERR_BASE + 6 +MCIERR_INVALID_DEVICE_NAME :: MCIERR_BASE + 7 +MCIERR_OUT_OF_MEMORY :: MCIERR_BASE + 8 +MCIERR_DEVICE_OPEN :: MCIERR_BASE + 9 +MCIERR_CANNOT_LOAD_DRIVER :: MCIERR_BASE + 10 +MCIERR_MISSING_COMMAND_STRING :: MCIERR_BASE + 11 +MCIERR_PARAM_OVERFLOW :: MCIERR_BASE + 12 +MCIERR_MISSING_STRING_ARGUMENT :: MCIERR_BASE + 13 +MCIERR_BAD_INTEGER :: MCIERR_BASE + 14 +MCIERR_PARSER_INTERNAL :: MCIERR_BASE + 15 +MCIERR_DRIVER_INTERNAL :: MCIERR_BASE + 16 +MCIERR_MISSING_PARAMETER :: MCIERR_BASE + 17 +MCIERR_UNSUPPORTED_FUNCTION :: MCIERR_BASE + 18 +MCIERR_FILE_NOT_FOUND :: MCIERR_BASE + 19 +MCIERR_DEVICE_NOT_READY :: MCIERR_BASE + 20 +MCIERR_INTERNAL :: MCIERR_BASE + 21 +MCIERR_DRIVER :: MCIERR_BASE + 22 +MCIERR_CANNOT_USE_ALL :: MCIERR_BASE + 23 +MCIERR_MULTIPLE :: MCIERR_BASE + 24 +MCIERR_EXTENSION_NOT_FOUND :: MCIERR_BASE + 25 +MCIERR_OUTOFRANGE :: MCIERR_BASE + 26 +MCIERR_FLAGS_NOT_COMPATIBLE :: MCIERR_BASE + 28 +MCIERR_FILE_NOT_SAVED :: MCIERR_BASE + 30 +MCIERR_DEVICE_TYPE_REQUIRED :: MCIERR_BASE + 31 +MCIERR_DEVICE_LOCKED :: MCIERR_BASE + 32 +MCIERR_DUPLICATE_ALIAS :: MCIERR_BASE + 33 +MCIERR_BAD_CONSTANT :: MCIERR_BASE + 34 +MCIERR_MUST_USE_SHAREABLE :: MCIERR_BASE + 35 +MCIERR_MISSING_DEVICE_NAME :: MCIERR_BASE + 36 +MCIERR_BAD_TIME_FORMAT :: MCIERR_BASE + 37 +MCIERR_NO_CLOSING_QUOTE :: MCIERR_BASE + 38 +MCIERR_DUPLICATE_FLAGS :: MCIERR_BASE + 39 +MCIERR_INVALID_FILE :: MCIERR_BASE + 40 +MCIERR_NULL_PARAMETER_BLOCK :: MCIERR_BASE + 41 +MCIERR_UNNAMED_RESOURCE :: MCIERR_BASE + 42 +MCIERR_NEW_REQUIRES_ALIAS :: MCIERR_BASE + 43 +MCIERR_NOTIFY_ON_AUTO_OPEN :: MCIERR_BASE + 44 +MCIERR_NO_ELEMENT_ALLOWED :: MCIERR_BASE + 45 +MCIERR_NONAPPLICABLE_FUNCTION :: MCIERR_BASE + 46 +MCIERR_ILLEGAL_FOR_AUTO_OPEN :: MCIERR_BASE + 47 +MCIERR_FILENAME_REQUIRED :: MCIERR_BASE + 48 +MCIERR_EXTRA_CHARACTERS :: MCIERR_BASE + 49 +MCIERR_DEVICE_NOT_INSTALLED :: MCIERR_BASE + 50 +MCIERR_GET_CD :: MCIERR_BASE + 51 +MCIERR_SET_CD :: MCIERR_BASE + 52 +MCIERR_SET_DRIVE :: MCIERR_BASE + 53 +MCIERR_DEVICE_LENGTH :: MCIERR_BASE + 54 +MCIERR_DEVICE_ORD_LENGTH :: MCIERR_BASE + 55 +MCIERR_NO_INTEGER :: MCIERR_BASE + 56 +MCIERR_WAVE_OUTPUTSINUSE :: MCIERR_BASE + 64 +MCIERR_WAVE_SETOUTPUTINUSE :: MCIERR_BASE + 65 +MCIERR_WAVE_INPUTSINUSE :: MCIERR_BASE + 66 +MCIERR_WAVE_SETINPUTINUSE :: MCIERR_BASE + 67 +MCIERR_WAVE_OUTPUTUNSPECIFIED :: MCIERR_BASE + 68 +MCIERR_WAVE_INPUTUNSPECIFIED :: MCIERR_BASE + 69 +MCIERR_WAVE_OUTPUTSUNSUITABLE :: MCIERR_BASE + 70 +MCIERR_WAVE_SETOUTPUTUNSUITABLE :: MCIERR_BASE + 71 +MCIERR_WAVE_INPUTSUNSUITABLE :: MCIERR_BASE + 72 +MCIERR_WAVE_SETINPUTUNSUITABLE :: MCIERR_BASE + 73 +MCIERR_SEQ_DIV_INCOMPATIBLE :: MCIERR_BASE + 80 +MCIERR_SEQ_PORT_INUSE :: MCIERR_BASE + 81 +MCIERR_SEQ_PORT_NONEXISTENT :: MCIERR_BASE + 82 +MCIERR_SEQ_PORT_MAPNODEVICE :: MCIERR_BASE + 83 +MCIERR_SEQ_PORT_MISCERROR :: MCIERR_BASE + 84 +MCIERR_SEQ_TIMER :: MCIERR_BASE + 85 +MCIERR_SEQ_PORTUNSPECIFIED :: MCIERR_BASE + 86 +MCIERR_SEQ_NOMIDIPRESENT :: MCIERR_BASE + 87 +MCIERR_NO_WINDOW :: MCIERR_BASE + 90 +MCIERR_CREATEWINDOW :: MCIERR_BASE + 91 +MCIERR_FILE_READ :: MCIERR_BASE + 92 +MCIERR_FILE_WRITE :: MCIERR_BASE + 93 +MCIERR_NO_IDENTITY :: MCIERR_BASE + 94 + +/* MMRESULT error return values specific to the mixer API */ +MIXERR_INVALLINE :: (MIXERR_BASE + 0) +MIXERR_INVALCONTROL :: (MIXERR_BASE + 1) +MIXERR_INVALVALUE :: (MIXERR_BASE + 2) +MIXERR_LASTERROR :: (MIXERR_BASE + 2) \ No newline at end of file diff --git a/core/sys/windows/ws2_32.odin b/core/sys/windows/ws2_32.odin index 09af86bce..631ef4241 100644 --- a/core/sys/windows/ws2_32.odin +++ b/core/sys/windows/ws2_32.odin @@ -1,18 +1,78 @@ // +build windows package sys_windows -foreign import ws2_32 "system:Ws2_32.lib" +// Define flags to be used with the WSAAsyncSelect() call. +FD_READ :: 0x01 +FD_WRITE :: 0x02 +FD_OOB :: 0x04 +FD_ACCEPT :: 0x08 +FD_CONNECT :: 0x10 +FD_CLOSE :: 0x20 +FD_MAX_EVENTS :: 10 +INADDR_LOOPBACK :: 0x7f000001 + +// Event flag definitions for WSAPoll(). +POLLRDNORM :: 0x0100 +POLLRDBAND :: 0x0200 +POLLIN :: (POLLRDNORM | POLLRDBAND) +POLLPRI :: 0x0400 +POLLWRNORM :: 0x0010 +POLLOUT :: (POLLWRNORM) +POLLWRBAND :: 0x0020 +POLLERR :: 0x0001 +POLLHUP :: 0x0002 +POLLNVAL :: 0x0004 + +WSA_POLLFD::struct{ + fd:SOCKET, + events:c_short, + revents:c_short, +} + +WSANETWORKEVENTS :: struct { + lNetworkEvents: c_long, + iErrorCode: [FD_MAX_EVENTS]c_int, +} + +WSAEVENT :: HANDLE + +WSAID_ACCEPTEX :: GUID{0xb5367df1, 0xcbac, 0x11cf, {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}} +WSAID_GETACCEPTEXSOCKADDRS :: GUID{0xb5367df2, 0xcbac, 0x11cf, {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}} +SIO_GET_EXTENSION_FUNCTION_POINTER :: IOC_INOUT | IOC_WS2 | 6 +IOC_OUT :: 0x40000000 +IOC_IN :: 0x80000000 +IOC_INOUT :: (IOC_IN | IOC_OUT) +IOC_WS2 :: 0x08000000 +/* +Example Load: + load_accept_ex :: proc(listener: SOCKET, fn_acceptex: rawptr) { + bytes: u32 + guid_accept_ex := WSAID_ACCEPTEX + rc := WSAIoctl(listener, SIO_GET_EXTENSION_FUNCTION_POINTER, &guid_accept_ex, size_of(guid_accept_ex), + fn_acceptex, size_of(fn_acceptex), &bytes, nil, nil,) + assert(rc != windows.SOCKET_ERROR) + } +*/ + +foreign import ws2_32 "system:Ws2_32.lib" @(default_calling_convention="stdcall") foreign ws2_32 { + // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsastartup) WSAStartup :: proc(wVersionRequested: WORD, lpWSAData: LPWSADATA) -> c_int --- + // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsacleanup) WSACleanup :: proc() -> c_int --- + // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsagetlasterror) WSAGetLastError :: proc() -> c_int --- + // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsapoll) + WSAPoll :: proc(fdArray: ^WSA_POLLFD, fds: c_ulong, timeout: c_int) -> c_int --- + // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsaduplicatesocketw) WSADuplicateSocketW :: proc( s: SOCKET, dwProcessId: DWORD, lpProtocolInfo: LPWSAPROTOCOL_INFO, ) -> c_int --- + // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsasend) WSASend :: proc( s: SOCKET, lpBuffers: LPWSABUF, @@ -22,6 +82,7 @@ foreign ws2_32 { lpOverlapped: LPWSAOVERLAPPED, lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE, ) -> c_int --- + // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsarecv) WSARecv :: proc( s: SOCKET, lpBuffers: LPWSABUF, @@ -31,6 +92,7 @@ foreign ws2_32 { lpOverlapped: LPWSAOVERLAPPED, lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE, ) -> c_int --- + // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsasocketw) WSASocketW :: proc( af: c_int, kind: c_int, @@ -39,35 +101,55 @@ foreign ws2_32 { g: GROUP, dwFlags: DWORD, ) -> SOCKET --- + // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsaioctl) + WSAIoctl :: proc(s: SOCKET, dwIoControlCode: DWORD, lpvInBuffer: rawptr, cbInBuffer: DWORD, lpvOutBuffer: rawptr, cbOutBuffer: DWORD, lpcbBytesReturned: ^DWORD, lpOverlapped: ^OVERLAPPED, lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE) -> c_int --- + // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsaeventselect) + WSAEventSelect :: proc(s: SOCKET, hEventObject: WSAEVENT, lNetworkEvents: i32) -> c_int --- + // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsawaitformultipleevents) + WSAWaitForMultipleEvents :: proc(cEvents: DWORD, lphEvents: ^WSAEVENT, fWaitAll: BOOL, dwTimeout: DWORD, fAlertable: BOOL) -> DWORD --- + // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsaenumnetworkevents) + WSAEnumNetworkEvents :: proc(s: SOCKET, hEventObject: WSAEVENT, lpNetworkEvents: ^WSANETWORKEVENTS) -> c_int --- + //[MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsagetoverlappedresult) + WSAGetOverlappedResult :: proc(s: SOCKET, lpOverlapped: ^OVERLAPPED, lpcbTransfer: ^DWORD, fWait: BOOL, lpdwFlags: ^DWORD) -> BOOL --- + // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-socket) socket :: proc( af: c_int, type: c_int, protocol: c_int, ) -> SOCKET --- + // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-ioctlsocket) ioctlsocket :: proc(s: SOCKET, cmd: c_long, argp: ^c_ulong) -> c_int --- + // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-closesocket) closesocket :: proc(socket: SOCKET) -> c_int --- + // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-recv) recv :: proc(socket: SOCKET, buf: rawptr, len: c_int, flags: c_int) -> c_int --- + // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-send) send :: proc(socket: SOCKET, buf: rawptr, len: c_int, flags: c_int) -> c_int --- + // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-recvfrom) recvfrom :: proc( socket: SOCKET, buf: rawptr, len: c_int, flags: c_int, - addr: ^SOCKADDR, + addr: ^SOCKADDR_STORAGE_LH, addrlen: ^c_int, ) -> c_int --- + // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-sendto) sendto :: proc( socket: SOCKET, buf: rawptr, len: c_int, flags: c_int, - addr: ^SOCKADDR, + addr: ^SOCKADDR_STORAGE_LH, addrlen: c_int, ) -> c_int --- + // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-shutdown) shutdown :: proc(socket: SOCKET, how: c_int) -> c_int --- - accept :: proc(socket: SOCKET, address: ^SOCKADDR, address_len: ^c_int) -> SOCKET --- + // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-accept) + accept :: proc(socket: SOCKET, address: ^SOCKADDR_STORAGE_LH, address_len: ^c_int) -> SOCKET --- + // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-setsockopt) setsockopt :: proc( s: SOCKET, level: c_int, @@ -75,19 +157,28 @@ foreign ws2_32 { optval: rawptr, optlen: c_int, ) -> c_int --- - getsockname :: proc(socket: SOCKET, address: ^SOCKADDR, address_len: ^c_int) -> c_int --- - getpeername :: proc(socket: SOCKET, address: ^SOCKADDR, address_len: ^c_int) -> c_int --- - bind :: proc(socket: SOCKET, address: ^SOCKADDR, address_len: socklen_t) -> c_int --- + // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-getsockname) + getsockname :: proc(socket: SOCKET, address: ^SOCKADDR_STORAGE_LH, address_len: ^c_int) -> c_int --- + // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-getpeername) + getpeername :: proc(socket: SOCKET, address: ^SOCKADDR_STORAGE_LH, address_len: ^c_int) -> c_int --- + // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-bind) + bind :: proc(socket: SOCKET, address: ^SOCKADDR_STORAGE_LH, address_len: socklen_t) -> c_int --- + // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-listen) listen :: proc(socket: SOCKET, backlog: c_int) -> c_int --- - connect :: proc(socket: SOCKET, address: ^SOCKADDR, len: c_int) -> c_int --- + // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-connect) + connect :: proc(socket: SOCKET, address: ^SOCKADDR_STORAGE_LH, len: c_int) -> c_int --- + // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/ws2tcpip/nf-ws2tcpip-getaddrinfo) getaddrinfo :: proc( node: cstring, service: cstring, hints: ^ADDRINFOA, res: ^^ADDRINFOA, ) -> c_int --- + // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/ws2tcpip/nf-ws2tcpip-freeaddrinfo) freeaddrinfo :: proc(res: ^ADDRINFOA) --- + // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/ws2tcpip/nf-ws2tcpip-freeaddrinfoexw) FreeAddrInfoExW :: proc(pAddrInfoEx: PADDRINFOEXW) --- + // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/ws2tcpip/nf-ws2tcpip-getaddrinfoexw) GetAddrInfoExW :: proc( pName: PCWSTR, pServiceName: PCWSTR, @@ -99,7 +190,7 @@ foreign ws2_32 { lpOverlapped: LPOVERLAPPED, lpCompletionRoutine: LPLOOKUPSERVICE_COMPLETION_ROUTINE, lpHandle: LPHANDLE) -> INT --- - + // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-select) select :: proc( nfds: c_int, readfds: ^fd_set, @@ -107,6 +198,7 @@ foreign ws2_32 { exceptfds: ^fd_set, timeout: ^timeval, ) -> c_int --- + // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-getsockopt) getsockopt :: proc( s: SOCKET, level: c_int, @@ -114,5 +206,4 @@ foreign ws2_32 { optval: ^c_char, optlen: ^c_int, ) -> c_int --- - } diff --git a/core/testing/runner_windows.odin b/core/testing/runner_windows.odin index 525eae685..17bcfce26 100644 --- a/core/testing/runner_windows.odin +++ b/core/testing/runner_windows.odin @@ -191,7 +191,7 @@ run_internal_test :: proc(t: ^T, it: Internal_Test) { global_exception_handler = win32.AddVectoredExceptionHandler(0, exception_handler_proc) context.assertion_failure_proc = proc(prefix, message: string, loc: runtime.Source_Code_Location) -> ! { - errorf(t=global_current_t, format="%s %s", args={prefix, message}, loc=loc) + errorf(global_current_t, "%s %s", prefix, message, loc=loc) intrinsics.trap() } diff --git a/core/testing/testing.odin b/core/testing/testing.odin index 37f9fe4d9..0ceb58e33 100644 --- a/core/testing/testing.odin +++ b/core/testing/testing.odin @@ -46,15 +46,15 @@ errorf :: proc(t: ^T, format: string, args: ..any, loc := #caller_location) { } fail :: proc(t: ^T, loc := #caller_location) { - error(t=t, args={"FAIL"}, loc=loc) + error(t, "FAIL", loc=loc) t.error_count += 1 } fail_now :: proc(t: ^T, msg := "", loc := #caller_location) { if msg != "" { - error(t=t, args={"FAIL:", msg}, loc=loc) + error(t, "FAIL:", msg, loc=loc) } else { - error(t=t, args={"FAIL"}, loc=loc) + error(t, "FAIL", loc=loc) } t.error_count += 1 if t._fail_now != nil { @@ -84,14 +84,14 @@ cleanup :: proc(t: ^T, procedure: proc(rawptr), user_data: rawptr) { expect :: proc(t: ^T, ok: bool, msg: string = "", loc := #caller_location) -> bool { if !ok { - error(t=t, args={msg}, loc=loc) + error(t, msg, loc=loc) } return ok } expect_value :: proc(t: ^T, value, expected: $T, loc := #caller_location) -> bool where intrinsics.type_is_comparable(T) { ok := value == expected if !ok { - errorf(t=t, format="expected %v, got %v", args={expected, value}, loc=loc) + errorf(t, "expected %v, got %v", expected, value, loc=loc) } return ok } diff --git a/core/text/edit/text_edit.odin b/core/text/edit/text_edit.odin index b53e2f8bc..8520ba674 100644 --- a/core/text/edit/text_edit.odin +++ b/core/text/edit/text_edit.odin @@ -113,15 +113,16 @@ set_text :: proc(s: ^State, text: string) { } -undo_state_push :: proc(s: ^State, undo: ^[dynamic]^Undo_State) { +undo_state_push :: proc(s: ^State, undo: ^[dynamic]^Undo_State) -> mem.Allocator_Error { text := string(s.builder.buf[:]) - item := (^Undo_State)(mem.alloc(size_of(Undo_State) + len(text), align_of(Undo_State), s.undo_text_allocator)) + item := (^Undo_State)(mem.alloc(size_of(Undo_State) + len(text), align_of(Undo_State), s.undo_text_allocator) or_return) item.selection = s.selection item.len = len(text) #no_bounds_check { runtime.copy(item.text[:len(text)], text) } - append(undo, item) + append(undo, item) or_return + return nil } undo :: proc(s: ^State, undo, redo: ^[dynamic]^Undo_State) { @@ -219,7 +220,7 @@ selection_delete :: proc(s: ^State) { translate_position :: proc(s: ^State, pos: int, t: Translation) -> int { is_continuation_byte :: proc(b: byte) -> bool { - return b <= 0x80 && b < 0xc0 + return b >= 0x80 && b < 0xc0 } is_space :: proc(b: byte) -> bool { return b == ' ' || b == '\t' || b == '\n' @@ -410,4 +411,4 @@ perform_command :: proc(s: ^State, cmd: Command) { case .Select_Line_Start: select_to(s, .Soft_Line_Start) case .Select_Line_End: select_to(s, .Soft_Line_End) } -} \ No newline at end of file +} diff --git a/core/text/match/strlib.odin b/core/text/match/strlib.odin index b8c2861fa..654996bc7 100644 --- a/core/text/match/strlib.odin +++ b/core/text/match/strlib.odin @@ -266,6 +266,7 @@ match_balance :: proc(ms: ^Match_State, s, p: int) -> (unused: int, err: Error) return INVALID, .Invalid_Pattern_Capture } + schar, ssize := utf8_peek(ms.src[s:]) or_return pchar, psize := utf8_peek(ms.pattern[p:]) or_return @@ -274,9 +275,9 @@ match_balance :: proc(ms: ^Match_State, s, p: int) -> (unused: int, err: Error) return INVALID, .OK } - s_begin := s cont := 1 - s := s + ssize + s := s + s += ssize begin := pchar end, _ := utf8_peek(ms.pattern[p + psize:]) or_return diff --git a/core/text/table/doc.odin b/core/text/table/doc.odin new file mode 100644 index 000000000..9b5c1f932 --- /dev/null +++ b/core/text/table/doc.odin @@ -0,0 +1,100 @@ +/* + package table implements ascii/markdown/html/custom rendering of tables. + + --- + + Custom rendering example: + + ```odin + tbl := init(&Table{}) + padding(tbl, 0, 1) + row(tbl, "A_LONG_ENUM", "= 54,", "// A comment about A_LONG_ENUM") + row(tbl, "AN_EVEN_LONGER_ENUM", "= 1,", "// A comment about AN_EVEN_LONGER_ENUM") + build(tbl) + for row in 0.. + Made available under Odin's BSD-3 license. + + List of contributors: + oskarnp: Initial implementation. +*/ + +package text_table + +import "core:io" +import "core:fmt" +import "core:mem" +import "core:mem/virtual" +import "core:runtime" + +Cell :: struct { + text: string, + alignment: Cell_Alignment, +} + +Cell_Alignment :: enum { + Left, + Center, + Right, +} + +Table :: struct { + lpad, rpad: int, // Cell padding (left/right) + cells: [dynamic]Cell, + caption: string, + nr_rows, nr_cols: int, + has_header_row: bool, + table_allocator: runtime.Allocator, // Used for allocating cells/colw + format_allocator: runtime.Allocator, // Used for allocating Cell.text when applicable + + dirty: bool, // True if build() needs to be called before rendering + + // The following are computed on build() + colw: [dynamic]int, // Width of each column (including padding, excluding borders) + tblw: int, // Width of entire table (including padding, excluding borders) +} + +init :: proc{init_with_allocator, init_with_virtual_arena, init_with_mem_arena} + +init_with_allocator :: proc(tbl: ^Table, format_allocator := context.temp_allocator, table_allocator := context.allocator) -> ^Table { + tbl.table_allocator = table_allocator + tbl.cells = make([dynamic]Cell, tbl.table_allocator) + tbl.colw = make([dynamic]int, tbl.table_allocator) + tbl.format_allocator = format_allocator + return tbl +} +init_with_virtual_arena :: proc(tbl: ^Table, format_arena: ^virtual.Arena, table_allocator := context.allocator) -> ^Table { + return init_with_allocator(tbl, virtual.arena_allocator(format_arena), table_allocator) +} +init_with_mem_arena :: proc(tbl: ^Table, format_arena: ^mem.Arena, table_allocator := context.allocator) -> ^Table { + return init_with_allocator(tbl, mem.arena_allocator(format_arena), table_allocator) +} + +destroy :: proc(tbl: ^Table) { + free_all(tbl.format_allocator) + delete(tbl.cells) + delete(tbl.colw) +} + +caption :: proc(tbl: ^Table, value: string) { + tbl.caption = value + tbl.dirty = true +} + +padding :: proc(tbl: ^Table, lpad, rpad: int) { + tbl.lpad = lpad + tbl.rpad = rpad + tbl.dirty = true +} + +get_cell :: proc(tbl: ^Table, row, col: int, loc := #caller_location) -> ^Cell { + assert(col >= 0 && col < tbl.nr_cols, "cell column out of range", loc) + assert(row >= 0 && row < tbl.nr_rows, "cell row out of range", loc) + resize(&tbl.cells, tbl.nr_cols * tbl.nr_rows) + return &tbl.cells[row*tbl.nr_cols + col] +} + +set_cell_value_and_alignment :: proc(tbl: ^Table, row, col: int, value: string, alignment: Cell_Alignment) { + cell := get_cell(tbl, row, col) + cell.text = format(tbl, "%v", value) + cell.alignment = alignment + tbl.dirty = true +} + +set_cell_value :: proc(tbl: ^Table, row, col: int, value: any, loc := #caller_location) { + cell := get_cell(tbl, row, col, loc) + switch val in value { + case nil: + cell.text = "" + case string: + cell.text = string(val) + case cstring: + cell.text = string(val) + case: + cell.text = format(tbl, "%v", val) + if cell.text == "" { + fmt.eprintf("{} text/table: format() resulted in empty string (arena out of memory?)\n", loc) + } + } + tbl.dirty = true +} + +set_cell_alignment :: proc(tbl: ^Table, row, col: int, alignment: Cell_Alignment, loc := #caller_location) { + cell := get_cell(tbl, row, col, loc) + cell.alignment = alignment + tbl.dirty = true +} + +format :: proc(tbl: ^Table, _fmt: string, args: ..any, loc := #caller_location) -> string { + context.allocator = tbl.format_allocator + return fmt.aprintf(_fmt, ..args) +} + +header :: proc(tbl: ^Table, values: ..any, loc := #caller_location) { + if (tbl.has_header_row && tbl.nr_rows != 1) || (!tbl.has_header_row && tbl.nr_rows != 0) { + panic("Cannot add headers after rows have been added", loc) + } + + if tbl.nr_rows == 0 { + tbl.nr_rows += 1 + tbl.has_header_row = true + } + + col := tbl.nr_cols + tbl.nr_cols += len(values) + for val in values { + set_cell_value(tbl, header_row(tbl), col, val, loc) + col += 1 + } + + tbl.dirty = true +} + +row :: proc(tbl: ^Table, values: ..any, loc := #caller_location) { + if tbl.nr_cols == 0 { + if len(values) == 0 { + panic("Cannot create row without values unless knowing amount of columns in advance") + } else { + tbl.nr_cols = len(values) + } + } + tbl.nr_rows += 1 + for col in 0.. int { + return tbl.nr_rows - 1 +} + +header_row :: proc(tbl: ^Table) -> int { + return 0 if tbl.has_header_row else -1 +} + +first_row :: proc(tbl: ^Table) -> int { + return header_row(tbl)+1 if tbl.has_header_row else 0 +} + +build :: proc(tbl: ^Table) { + tbl.dirty = false + + resize(&tbl.colw, tbl.nr_cols) + mem.zero_slice(tbl.colw[:]) + + for row in 0.. tbl.colw[col] { + tbl.colw[col] = w + } + } + } + + colw_sum := 0 + for v in tbl.colw { + colw_sum += v + } + + tbl.tblw = max(colw_sum, len(tbl.caption) + tbl.lpad + tbl.rpad) + + // Resize columns to match total width of table + remain := tbl.tblw-colw_sum + for col := 0; remain > 0; col = (col + 1) % tbl.nr_cols { + tbl.colw[col] += 1 + remain -= 1 + } + + return +} + +write_html_table :: proc(w: io.Writer, tbl: ^Table) { + if tbl.dirty { + build(tbl) + } + + io.write_string(w, "\n") + if tbl.caption != "" { + io.write_string(w, "\n") + } + + align_attribute :: proc(cell: ^Cell) -> string { + switch cell.alignment { + case .Left: return ` align="left"` + case .Center: return ` align="center"` + case .Right: return ` align="right"` + } + unreachable() + } + + if tbl.has_header_row { + io.write_string(w, "\n") + io.write_string(w, " \n") + for col in 0..") + io.write_string(w, cell.text) + io.write_string(w, "\n") + } + io.write_string(w, " \n") + io.write_string(w, "\n") + } + + io.write_string(w, "\n") + for row in 0..\n") + for col in 0..") + io.write_string(w, cell.text) + io.write_string(w, "\n") + } + io.write_string(w, " \n") + } + io.write_string(w, " \n") + + io.write_string(w, "
") + io.write_string(w, tbl.caption) + io.write_string(w, "
\n") +} + +write_ascii_table :: proc(w: io.Writer, tbl: ^Table) { + if tbl.dirty { + build(tbl) + } + + write_caption_separator :: proc(w: io.Writer, tbl: ^Table) { + io.write_byte(w, '+') + write_byte_repeat(w, tbl.tblw + tbl.nr_cols - 1, '-') + io.write_byte(w, '+') + io.write_byte(w, '\n') + } + + write_table_separator :: proc(w: io.Writer, tbl: ^Table) { + for col in 0.. io.Writer { + return io.to_writer(os.stream_from_handle(os.stdout)) +} + +strings_builder_writer :: proc(b: ^strings.Builder) -> io.Writer { + return strings.to_writer(b) +} diff --git a/core/thread/thread.odin b/core/thread/thread.odin index 90230ae75..fd8e59a5d 100644 --- a/core/thread/thread.odin +++ b/core/thread/thread.odin @@ -10,16 +10,50 @@ Thread_Proc :: #type proc(^Thread) MAX_USER_ARGUMENTS :: 8 +Thread_State :: enum u8 { + Started, + Joined, + Done, + Self_Cleanup, +} + Thread :: struct { using specific: Thread_Os_Specific, + flags: bit_set[Thread_State; u8], id: int, procedure: Thread_Proc, + + /* + These are values that the user can set as they wish, after the thread has been created. + This data is easily available to the thread proc. + + These fields can be assigned to directly. + + Should be set after the thread is created, but before it is started. + */ data: rawptr, user_index: int, user_args: [MAX_USER_ARGUMENTS]rawptr, - init_context: Maybe(runtime.Context), + /* + The context to be used as 'context' in the thread proc. + This field can be assigned to directly, after the thread has been created, but __before__ the thread has been started. + This field must not be changed after the thread has started. + + NOTE: If you __don't__ set this, the temp allocator will be managed for you; + If you __do__ set this, then you're expected to handle whatever allocators you set, yourself. + + IMPORTANT: + By default, the thread proc will get the same context as `main()` gets. + In this situation, the thread will get a new temporary allocator which will be cleaned up when the thread dies. + ***This does NOT happen when you set `init_context`.*** + This means that if you set `init_context`, but still have the `temp_allocator` field set to the default temp allocator, + then you'll need to call `runtime.default_temp_allocator_destroy(auto_cast the_thread.init_context.temp_allocator.data)` manually, + in order to prevent any memory leaks. + This call ***must*** be done ***in the thread proc*** because the default temporary allocator uses thread local state! + */ + init_context: Maybe(runtime.Context), creation_allocator: mem.Allocator, } @@ -32,6 +66,12 @@ Thread_Priority :: enum { High, } +/* + Creates a thread in a suspended state with the given priority. + To start the thread, call `thread.start()`. + + See `thread.create_and_start()`. +*/ create :: proc(procedure: Thread_Proc, priority := Thread_Priority.Normal) -> ^Thread { return _create(procedure, priority) } @@ -68,125 +108,46 @@ yield :: proc() { run :: proc(fn: proc(), init_context: Maybe(runtime.Context) = nil, priority := Thread_Priority.Normal) { - thread_proc :: proc(t: ^Thread) { - fn := cast(proc())t.data - fn() - destroy(t) - } - t := create(thread_proc, priority) - t.data = rawptr(fn) - t.init_context = init_context - start(t) + create_and_start(fn, init_context, priority, true) } run_with_data :: proc(data: rawptr, fn: proc(data: rawptr), init_context: Maybe(runtime.Context) = nil, priority := Thread_Priority.Normal) { - thread_proc :: proc(t: ^Thread) { - fn := cast(proc(rawptr))t.data - assert(t.user_index >= 1) - data := t.user_args[0] - fn(data) - destroy(t) - } - t := create(thread_proc, priority) - t.data = rawptr(fn) - t.user_index = 1 - t.user_args = data - t.init_context = init_context - start(t) + create_and_start_with_data(data, fn, init_context, priority, true) } run_with_poly_data :: proc(data: $T, fn: proc(data: T), init_context: Maybe(runtime.Context) = nil, priority := Thread_Priority.Normal) where size_of(T) <= size_of(rawptr) { - thread_proc :: proc(t: ^Thread) { - fn := cast(proc(T))t.data - assert(t.user_index >= 1) - data := (^T)(&t.user_args[0])^ - fn(data) - destroy(t) - } - t := create(thread_proc, priority) - t.data = rawptr(fn) - t.user_index = 1 - data := data - mem.copy(&t.user_args[0], &data, size_of(data)) - t.init_context = init_context - start(t) + create_and_start_with_poly_data(data, fn, init_context, priority, true) } run_with_poly_data2 :: proc(arg1: $T1, arg2: $T2, fn: proc(T1, T2), init_context: Maybe(runtime.Context) = nil, priority := Thread_Priority.Normal) where size_of(T1) <= size_of(rawptr), size_of(T2) <= size_of(rawptr) { - thread_proc :: proc(t: ^Thread) { - fn := cast(proc(T1, T2))t.data - assert(t.user_index >= 2) - arg1 := (^T1)(&t.user_args[0])^ - arg2 := (^T2)(&t.user_args[1])^ - fn(arg1, arg2) - destroy(t) - } - t := create(thread_proc, priority) - t.data = rawptr(fn) - t.user_index = 2 - arg1, arg2 := arg1, arg2 - mem.copy(&t.user_args[0], &arg1, size_of(arg1)) - mem.copy(&t.user_args[1], &arg2, size_of(arg2)) - t.init_context = init_context - start(t) + create_and_start_with_poly_data2(arg1, arg2, fn, init_context, priority, true) } run_with_poly_data3 :: proc(arg1: $T1, arg2: $T2, arg3: $T3, fn: proc(arg1: T1, arg2: T2, arg3: T3), init_context: Maybe(runtime.Context) = nil, priority := Thread_Priority.Normal) where size_of(T1) <= size_of(rawptr), size_of(T2) <= size_of(rawptr), size_of(T3) <= size_of(rawptr) { - thread_proc :: proc(t: ^Thread) { - fn := cast(proc(T1, T2, T3))t.data - assert(t.user_index >= 3) - arg1 := (^T1)(&t.user_args[0])^ - arg2 := (^T2)(&t.user_args[1])^ - arg3 := (^T3)(&t.user_args[2])^ - fn(arg1, arg2, arg3) - destroy(t) - } - t := create(thread_proc, priority) - t.data = rawptr(fn) - t.user_index = 3 - arg1, arg2, arg3 := arg1, arg2, arg3 - mem.copy(&t.user_args[0], &arg1, size_of(arg1)) - mem.copy(&t.user_args[1], &arg2, size_of(arg2)) - mem.copy(&t.user_args[2], &arg3, size_of(arg3)) - t.init_context = init_context - start(t) + create_and_start_with_poly_data3(arg1, arg2, arg3, fn, init_context, priority, true) } run_with_poly_data4 :: proc(arg1: $T1, arg2: $T2, arg3: $T3, arg4: $T4, fn: proc(arg1: T1, arg2: T2, arg3: T3, arg4: T4), init_context: Maybe(runtime.Context) = nil, priority := Thread_Priority.Normal) where size_of(T1) <= size_of(rawptr), size_of(T2) <= size_of(rawptr), size_of(T3) <= size_of(rawptr) { - thread_proc :: proc(t: ^Thread) { - fn := cast(proc(T1, T2, T3, T4))t.data - assert(t.user_index >= 4) - arg1 := (^T1)(&t.user_args[0])^ - arg2 := (^T2)(&t.user_args[1])^ - arg3 := (^T3)(&t.user_args[2])^ - arg4 := (^T4)(&t.user_args[3])^ - fn(arg1, arg2, arg3, arg4) - destroy(t) - } - t := create(thread_proc, priority) - t.data = rawptr(fn) - t.user_index = 4 - arg1, arg2, arg3, arg4 := arg1, arg2, arg3, arg4 - mem.copy(&t.user_args[0], &arg1, size_of(arg1)) - mem.copy(&t.user_args[1], &arg2, size_of(arg2)) - mem.copy(&t.user_args[2], &arg3, size_of(arg3)) - mem.copy(&t.user_args[3], &arg4, size_of(arg4)) - t.init_context = init_context - start(t) + create_and_start_with_poly_data4(arg1, arg2, arg3, arg4, fn, init_context, priority, true) } - -create_and_start :: proc(fn: Thread_Proc, init_context: Maybe(runtime.Context) = nil, priority := Thread_Priority.Normal) -> ^Thread { - t := create(fn, priority) +create_and_start :: proc(fn: proc(), init_context: Maybe(runtime.Context) = nil, priority := Thread_Priority.Normal, self_cleanup := false) -> ^Thread { + thread_proc :: proc(t: ^Thread) { + fn := cast(proc())t.data + fn() + } + t := create(thread_proc, priority) + t.data = rawptr(fn) + if self_cleanup do t.flags += {.Self_Cleanup} t.init_context = init_context start(t) return t @@ -195,7 +156,7 @@ create_and_start :: proc(fn: Thread_Proc, init_context: Maybe(runtime.Context) = -create_and_start_with_data :: proc(data: rawptr, fn: proc(data: rawptr), init_context: Maybe(runtime.Context) = nil, priority := Thread_Priority.Normal) -> ^Thread { +create_and_start_with_data :: proc(data: rawptr, fn: proc(data: rawptr), init_context: Maybe(runtime.Context) = nil, priority := Thread_Priority.Normal, self_cleanup := false) -> ^Thread { thread_proc :: proc(t: ^Thread) { fn := cast(proc(rawptr))t.data assert(t.user_index >= 1) @@ -206,12 +167,13 @@ create_and_start_with_data :: proc(data: rawptr, fn: proc(data: rawptr), init_co t.data = rawptr(fn) t.user_index = 1 t.user_args = data + if self_cleanup do t.flags += {.Self_Cleanup} t.init_context = init_context start(t) return t } -create_and_start_with_poly_data :: proc(data: $T, fn: proc(data: T), init_context: Maybe(runtime.Context) = nil, priority := Thread_Priority.Normal) -> ^Thread +create_and_start_with_poly_data :: proc(data: $T, fn: proc(data: T), init_context: Maybe(runtime.Context) = nil, priority := Thread_Priority.Normal, self_cleanup := false) -> ^Thread where size_of(T) <= size_of(rawptr) { thread_proc :: proc(t: ^Thread) { fn := cast(proc(T))t.data @@ -224,12 +186,13 @@ create_and_start_with_poly_data :: proc(data: $T, fn: proc(data: T), init_contex t.user_index = 1 data := data mem.copy(&t.user_args[0], &data, size_of(data)) + if self_cleanup do t.flags += {.Self_Cleanup} t.init_context = init_context start(t) return t } -create_and_start_with_poly_data2 :: proc(arg1: $T1, arg2: $T2, fn: proc(T1, T2), init_context: Maybe(runtime.Context) = nil, priority := Thread_Priority.Normal) -> ^Thread +create_and_start_with_poly_data2 :: proc(arg1: $T1, arg2: $T2, fn: proc(T1, T2), init_context: Maybe(runtime.Context) = nil, priority := Thread_Priority.Normal, self_cleanup := false) -> ^Thread where size_of(T1) <= size_of(rawptr), size_of(T2) <= size_of(rawptr) { thread_proc :: proc(t: ^Thread) { @@ -245,12 +208,13 @@ create_and_start_with_poly_data2 :: proc(arg1: $T1, arg2: $T2, fn: proc(T1, T2), arg1, arg2 := arg1, arg2 mem.copy(&t.user_args[0], &arg1, size_of(arg1)) mem.copy(&t.user_args[1], &arg2, size_of(arg2)) + if self_cleanup do t.flags += {.Self_Cleanup} t.init_context = init_context start(t) return t } -create_and_start_with_poly_data3 :: proc(arg1: $T1, arg2: $T2, arg3: $T3, fn: proc(arg1: T1, arg2: T2, arg3: T3), init_context: Maybe(runtime.Context) = nil, priority := Thread_Priority.Normal) -> ^Thread +create_and_start_with_poly_data3 :: proc(arg1: $T1, arg2: $T2, arg3: $T3, fn: proc(arg1: T1, arg2: T2, arg3: T3), init_context: Maybe(runtime.Context) = nil, priority := Thread_Priority.Normal, self_cleanup := false) -> ^Thread where size_of(T1) <= size_of(rawptr), size_of(T2) <= size_of(rawptr), size_of(T3) <= size_of(rawptr) { @@ -269,11 +233,12 @@ create_and_start_with_poly_data3 :: proc(arg1: $T1, arg2: $T2, arg3: $T3, fn: pr mem.copy(&t.user_args[0], &arg1, size_of(arg1)) mem.copy(&t.user_args[1], &arg2, size_of(arg2)) mem.copy(&t.user_args[2], &arg3, size_of(arg3)) + if self_cleanup do t.flags += {.Self_Cleanup} t.init_context = init_context start(t) return t } -create_and_start_with_poly_data4 :: proc(arg1: $T1, arg2: $T2, arg3: $T3, arg4: $T4, fn: proc(arg1: T1, arg2: T2, arg3: T3, arg4: T4), init_context: Maybe(runtime.Context) = nil, priority := Thread_Priority.Normal) -> ^Thread +create_and_start_with_poly_data4 :: proc(arg1: $T1, arg2: $T2, arg3: $T3, arg4: $T4, fn: proc(arg1: T1, arg2: T2, arg3: T3, arg4: T4), init_context: Maybe(runtime.Context) = nil, priority := Thread_Priority.Normal, self_cleanup := false) -> ^Thread where size_of(T1) <= size_of(rawptr), size_of(T2) <= size_of(rawptr), size_of(T3) <= size_of(rawptr) { @@ -294,7 +259,38 @@ create_and_start_with_poly_data4 :: proc(arg1: $T1, arg2: $T2, arg3: $T3, arg4: mem.copy(&t.user_args[1], &arg2, size_of(arg2)) mem.copy(&t.user_args[2], &arg3, size_of(arg3)) mem.copy(&t.user_args[3], &arg4, size_of(arg4)) + if self_cleanup do t.flags += {.Self_Cleanup} t.init_context = init_context start(t) return t } + + +_select_context_for_thread :: proc(init_context: Maybe(runtime.Context)) -> runtime.Context { + ctx, ok := init_context.? + if !ok { + return runtime.default_context() + } + + /* + NOTE(tetra, 2023-05-31): + Ensure that the temp allocator is thread-safe when the user provides a specific initial context to use. + Without this, the thread will use the same temp allocator state as the parent thread, and thus, bork it up. + */ + if ctx.temp_allocator.procedure == runtime.default_temp_allocator_proc { + ctx.temp_allocator.data = &runtime.global_default_temp_allocator_data + } + return ctx +} + +_maybe_destroy_default_temp_allocator :: proc(init_context: Maybe(runtime.Context)) { + if init_context != nil { + // NOTE(tetra, 2023-05-31): If the user specifies a custom context for the thread, + // then it's entirely up to them to handle whatever allocators they're using. + return + } + + if context.temp_allocator.procedure == runtime.default_temp_allocator_proc { + runtime.default_temp_allocator_destroy(auto_cast context.temp_allocator.data) + } +} diff --git a/core/thread/thread_js.odin b/core/thread/thread_js.odin new file mode 100644 index 000000000..3c4935495 --- /dev/null +++ b/core/thread/thread_js.odin @@ -0,0 +1,47 @@ +//+build js +package thread + +import "core:intrinsics" +import "core:sync" +import "core:mem" + +Thread_Os_Specific :: struct {} + +_thread_priority_map := [Thread_Priority]i32{ + .Normal = 0, + .Low = -2, + .High = +2, +} + +_create :: proc(procedure: Thread_Proc, priority := Thread_Priority.Normal) -> ^Thread { + unimplemented("core:thread procedure not supported on js target") +} + +_start :: proc(t: ^Thread) { + unimplemented("core:thread procedure not supported on js target") +} + +_is_done :: proc(t: ^Thread) -> bool { + unimplemented("core:thread procedure not supported on js target") +} + +_join :: proc(t: ^Thread) { + unimplemented("core:thread procedure not supported on js target") +} + +_join_multiple :: proc(threads: ..^Thread) { + unimplemented("core:thread procedure not supported on js target") +} + +_destroy :: proc(thread: ^Thread) { + unimplemented("core:thread procedure not supported on js target") +} + +_terminate :: proc(using thread : ^Thread, exit_code: int) { + unimplemented("core:thread procedure not supported on js target") +} + +_yield :: proc() { + unimplemented("core:thread procedure not supported on js target") +} + diff --git a/core/thread/thread_unix.odin b/core/thread/thread_unix.odin index 8c7058f17..6e734a03a 100644 --- a/core/thread/thread_unix.odin +++ b/core/thread/thread_unix.odin @@ -2,32 +2,24 @@ // +private package thread -import "core:runtime" import "core:intrinsics" import "core:sync" import "core:sys/unix" CAS :: intrinsics.atomic_compare_exchange_strong -Thread_State :: enum u8 { - Started, - Joined, - Done, -} - // NOTE(tetra): Aligned here because of core/unix/pthread_linux.odin/pthread_t. // Also see core/sys/darwin/mach_darwin.odin/semaphore_t. Thread_Os_Specific :: struct #align 16 { unix_thread: unix.pthread_t, // NOTE: very large on Darwin, small on Linux. cond: sync.Cond, mutex: sync.Mutex, - flags: bit_set[Thread_State; u8], } // // Creates a thread which will run the given procedure. // It then waits for `start` to be called. // -_create :: proc(procedure: Thread_Proc, priority := Thread_Priority.Normal) -> ^Thread { +_create :: proc(procedure: Thread_Proc, priority: Thread_Priority) -> ^Thread { __linux_thread_entry_proc :: proc "c" (t: rawptr) -> rawptr { t := (^Thread)(t) @@ -36,8 +28,6 @@ _create :: proc(procedure: Thread_Proc, priority := Thread_Priority.Normal) -> ^ can_set_thread_cancel_state := unix.pthread_setcancelstate(unix.PTHREAD_CANCEL_DISABLE, nil) == 0 } - context = runtime.default_context() - sync.lock(&t.mutex) t.id = sync.current_thread_id() @@ -46,9 +36,6 @@ _create :: proc(procedure: Thread_Proc, priority := Thread_Priority.Normal) -> ^ sync.wait(&t.cond, &t.mutex) } - init_context := t.init_context - context = init_context.? or_else runtime.default_context() - when ODIN_OS != .Darwin { // Enable thread's cancelability. if can_set_thread_cancel_state { @@ -57,14 +44,27 @@ _create :: proc(procedure: Thread_Proc, priority := Thread_Priority.Normal) -> ^ } } - t.procedure(t) + { + init_context := t.init_context + + // NOTE(tetra, 2023-05-31): Must do this AFTER thread.start() is called, so that the user can set the init_context, etc! + // Here on Unix, we start the OS thread in a running state, and so we manually have it wait on a condition + // variable above. We must perform that waiting BEFORE we select the context! + context = _select_context_for_thread(init_context) + defer _maybe_destroy_default_temp_allocator(init_context) + + t.procedure(t) + } intrinsics.atomic_store(&t.flags, t.flags + { .Done }) sync.unlock(&t.mutex) - if init_context == nil && context.temp_allocator.data == &runtime.global_default_temp_allocator_data { - runtime.default_temp_allocator_destroy(auto_cast context.temp_allocator.data) + if .Self_Cleanup in t.flags { + t.unix_thread = {} + // NOTE(ftphikari): It doesn't matter which context 'free' received, right? + context = {} + free(t, t.creation_allocator) } return nil diff --git a/core/thread/thread_windows.odin b/core/thread/thread_windows.odin index 68382444c..0d004c8c3 100644 --- a/core/thread/thread_windows.odin +++ b/core/thread/thread_windows.odin @@ -2,22 +2,14 @@ //+private package thread -import "core:runtime" import "core:intrinsics" import "core:sync" import win32 "core:sys/windows" -Thread_State :: enum u8 { - Started, - Joined, - Done, -} - Thread_Os_Specific :: struct { win32_thread: win32.HANDLE, win32_thread_id: win32.DWORD, mutex: sync.Mutex, - flags: bit_set[Thread_State; u8], } _thread_priority_map := [Thread_Priority]i32{ @@ -26,24 +18,36 @@ _thread_priority_map := [Thread_Priority]i32{ .High = +2, } -_create :: proc(procedure: Thread_Proc, priority := Thread_Priority.Normal) -> ^Thread { +_create :: proc(procedure: Thread_Proc, priority: Thread_Priority) -> ^Thread { win32_thread_id: win32.DWORD __windows_thread_entry_proc :: proc "stdcall" (t_: rawptr) -> win32.DWORD { t := (^Thread)(t_) - context = t.init_context.? or_else runtime.default_context() - + t.id = sync.current_thread_id() - t.procedure(t) + { + init_context := t.init_context + + // NOTE(tetra, 2023-05-31): Must do this AFTER thread.start() is called, so that the user can set the init_context, etc! + // Here on Windows, the thread is created in a suspended state, and so we can select the context anywhere before the call + // to t.procedure(). + context = _select_context_for_thread(init_context) + defer _maybe_destroy_default_temp_allocator(init_context) + + t.procedure(t) + } intrinsics.atomic_store(&t.flags, t.flags + {.Done}) - if t.init_context == nil { - if context.temp_allocator.data == &runtime.global_default_temp_allocator_data { - runtime.default_temp_allocator_destroy(auto_cast context.temp_allocator.data) - } + if .Self_Cleanup in t.flags { + win32.CloseHandle(t.win32_thread) + t.win32_thread = win32.INVALID_HANDLE + // NOTE(ftphikari): It doesn't matter which context 'free' received, right? + context = {} + free(t, t.creation_allocator) } + return 0 } @@ -62,7 +66,6 @@ _create :: proc(procedure: Thread_Proc, priority := Thread_Priority.Normal) -> ^ thread.procedure = procedure thread.win32_thread = win32_thread thread.win32_thread_id = win32_thread_id - thread.init_context = context ok := win32.SetThreadPriority(win32_thread, _thread_priority_map[priority]) assert(ok == true) diff --git a/core/time/perf.odin b/core/time/perf.odin index 53406646f..87192093a 100644 --- a/core/time/perf.odin +++ b/core/time/perf.odin @@ -1,11 +1,11 @@ package time import "core:runtime" +import "core:intrinsics" Tick :: struct { _nsec: i64, // relative amount } - tick_now :: proc "contextless" () -> Tick { return _tick_now() } @@ -40,6 +40,59 @@ _tick_duration_end :: proc "contextless" (d: ^Duration, t: Tick) { d^ = tick_since(t) } +when ODIN_ARCH == .amd64 { + @(private) + x86_has_invariant_tsc :: proc "contextless" () -> bool { + eax, _, _, _ := intrinsics.x86_cpuid(0x80_000_000, 0) + + // Is this processor *really* ancient? + if eax < 0x80_000_007 { + return false + } + + // check if the invariant TSC bit is set + _, _, _, edx := intrinsics.x86_cpuid(0x80_000_007, 0) + return (edx & (1 << 8)) != 0 + } +} + +when ODIN_OS != .Darwin && ODIN_OS != .Linux && ODIN_OS != .FreeBSD { + _get_tsc_frequency :: proc "contextless" () -> (u64, bool) { + return 0, false + } +} + +has_invariant_tsc :: proc "contextless" () -> bool { + when ODIN_ARCH == .amd64 { + return x86_has_invariant_tsc() + } + + return false +} + +tsc_frequency :: proc "contextless" (fallback_sleep := 2 * Second) -> (u64, bool) { + if !has_invariant_tsc() { + return 0, false + } + + hz, ok := _get_tsc_frequency() + if !ok { + // fallback to approximate TSC + tsc_begin := intrinsics.read_cycle_counter() + tick_begin := tick_now() + + sleep(fallback_sleep) + + tsc_end := intrinsics.read_cycle_counter() + tick_end := tick_now() + + time_diff := u128(duration_nanoseconds(tick_diff(tick_begin, tick_end))) + hz = u64((u128(tsc_end - tsc_begin) * 1_000_000_000) / time_diff) + } + + return hz, true +} + /* Benchmark helpers */ @@ -94,4 +147,4 @@ benchmark :: proc(options: ^Benchmark_Options, allocator := context.allocator) - options->teardown(allocator) or_return } return -} \ No newline at end of file +} diff --git a/core/time/time.odin b/core/time/time.odin index 74c80c8f7..6c424a62e 100644 --- a/core/time/time.odin +++ b/core/time/time.odin @@ -170,6 +170,12 @@ day :: proc "contextless" (t: Time) -> (day: int) { return } +weekday :: proc "contextless" (t: Time) -> (weekday: Weekday) { + abs := _time_abs(t) + sec := (abs + u64(Weekday.Monday) * SECONDS_PER_DAY) % SECONDS_PER_WEEK + return Weekday(int(sec) / SECONDS_PER_DAY) +} + clock :: proc { clock_from_time, clock_from_duration, clock_from_stopwatch } clock_from_time :: proc "contextless" (t: Time) -> (hour, min, sec: int) { diff --git a/core/time/tsc_darwin.odin b/core/time/tsc_darwin.odin new file mode 100644 index 000000000..9e54ee8f7 --- /dev/null +++ b/core/time/tsc_darwin.odin @@ -0,0 +1,21 @@ +//+private +//+build darwin +package time + +import "core:c" + +foreign import libc "System.framework" +foreign libc { + @(link_name="sysctlbyname") _sysctlbyname :: proc(path: cstring, oldp: rawptr, oldlenp: rawptr, newp: rawptr, newlen: int) -> c.int --- +} + +_get_tsc_frequency :: proc "contextless" () -> (u64, bool) { + tmp_freq : u64 = 0 + tmp_size : i64 = size_of(tmp_freq) + ret := _sysctlbyname("machdep.tsc.frequency", &tmp_freq, &tmp_size, nil, 0) + if ret < 0 { + return 0, false + } + + return tmp_freq, true +} diff --git a/core/time/tsc_freebsd.odin b/core/time/tsc_freebsd.odin new file mode 100644 index 000000000..f4d6ccc3a --- /dev/null +++ b/core/time/tsc_freebsd.odin @@ -0,0 +1,21 @@ +//+private +//+build freebsd +package time + +import "core:c" + +foreign import libc "system:c" +foreign libc { + @(link_name="sysctlbyname") _sysctlbyname :: proc(path: cstring, oldp: rawptr, oldlenp: rawptr, newp: rawptr, newlen: int) -> c.int --- +} + +_get_tsc_frequency :: proc "contextless" () -> (u64, bool) { + tmp_freq : u64 = 0 + tmp_size : i64 = size_of(tmp_freq) + ret := _sysctlbyname("machdep.tsc_freq", &tmp_freq, &tmp_size, nil, 0) + if ret < 0 { + return 0, false + } + + return tmp_freq, true +} diff --git a/core/time/tsc_linux.odin b/core/time/tsc_linux.odin new file mode 100644 index 000000000..c5f2902e9 --- /dev/null +++ b/core/time/tsc_linux.odin @@ -0,0 +1,35 @@ +//+private +//+build linux +package time + +import "core:intrinsics" +import "core:sys/unix" + +_get_tsc_frequency :: proc "contextless" () -> (u64, bool) { + perf_attr := unix.Perf_Event_Attr{} + perf_attr.type = u32(unix.Perf_Type_Id.Hardware) + perf_attr.config = u64(unix.Perf_Hardware_Id.Instructions) + perf_attr.size = size_of(perf_attr) + perf_attr.flags = {.Disabled, .Exclude_Kernel, .Exclude_HV} + fd := unix.sys_perf_event_open(&perf_attr, 0, -1, -1, 0) + if fd == -1 { + return 0, false + } + defer unix.sys_close(fd) + + page_size : uint = 4096 + ret := unix.sys_mmap(nil, page_size, unix.PROT_READ, unix.MAP_SHARED, fd, 0) + if ret < 0 && ret > -4096 { + return 0, false + } + addr := rawptr(uintptr(ret)) + defer unix.sys_munmap(addr, page_size) + + event_page := (^unix.Perf_Event_mmap_Page)(addr) + if .User_Time not_in event_page.cap.flags { + return 0, false + } + + frequency := u64((u128(1_000_000_000) << u128(event_page.time_shift)) / u128(event_page.time_mult)) + return frequency, true +} diff --git a/core/unicode/utf8/utf8.odin b/core/unicode/utf8/utf8.odin index a0da5c5d1..3642b8078 100644 --- a/core/unicode/utf8/utf8.odin +++ b/core/unicode/utf8/utf8.odin @@ -10,6 +10,11 @@ UTF_MAX :: 4 SURROGATE_MIN :: 0xd800 SURROGATE_MAX :: 0xdfff +// A high/leading surrogate is in range SURROGATE_MIN..SURROGATE_HIGH_MAX, +// A low/trailing surrogate is in range SURROGATE_LOW_MIN..SURROGATE_MAX. +SURROGATE_HIGH_MAX :: 0xdbff +SURROGATE_LOW_MIN :: 0xdc00 + T1 :: 0b0000_0000 TX :: 0b1000_0000 T2 :: 0b1100_0000 @@ -54,7 +59,7 @@ accept_sizes := [256]u8{ 0xf5..=0xff = 0xf1, } -encode_rune :: proc(c: rune) -> ([4]u8, int) { +encode_rune :: proc "contextless" (c: rune) -> ([4]u8, int) { r := c buf: [4]u8 @@ -95,10 +100,10 @@ decode_rune :: proc{ decode_rune_in_string, decode_rune_in_bytes, } -decode_rune_in_string :: #force_inline proc(s: string) -> (rune, int) { +decode_rune_in_string :: #force_inline proc "contextless" (s: string) -> (rune, int) { return decode_rune_in_bytes(transmute([]u8)s) } -decode_rune_in_bytes :: proc(s: []u8) -> (rune, int) { +decode_rune_in_bytes :: proc "contextless" (s: []u8) -> (rune, int) { n := len(s) if n < 1 { return RUNE_ERROR, 0 @@ -135,7 +140,7 @@ decode_rune_in_bytes :: proc(s: []u8) -> (rune, int) { return rune(s0&MASK4)<<18 | rune(b1&MASKX)<<12 | rune(b2&MASKX)<<6 | rune(b3&MASKX), 4 } -string_to_runes :: proc(s: string, allocator := context.allocator) -> (runes: []rune) { +string_to_runes :: proc "odin" (s: string, allocator := context.allocator) -> (runes: []rune) { n := rune_count_in_string(s) runes = make([]rune, n, allocator) @@ -147,7 +152,7 @@ string_to_runes :: proc(s: string, allocator := context.allocator) -> (runes: [] return } -runes_to_string :: proc(runes: []rune, allocator := context.allocator) -> string { +runes_to_string :: proc "odin" (runes: []rune, allocator := context.allocator) -> string { byte_count := 0 for r in runes { _, w := encode_rune(r) @@ -171,10 +176,10 @@ decode_last_rune :: proc{ decode_last_rune_in_bytes, } -decode_last_rune_in_string :: #force_inline proc(s: string) -> (rune, int) { +decode_last_rune_in_string :: #force_inline proc "contextless" (s: string) -> (rune, int) { return decode_last_rune_in_bytes(transmute([]u8)s) } -decode_last_rune_in_bytes :: proc(s: []u8) -> (rune, int) { +decode_last_rune_in_bytes :: proc "contextless" (s: []u8) -> (rune, int) { r: rune size: int start, end, limit: int @@ -206,7 +211,7 @@ decode_last_rune_in_bytes :: proc(s: []u8) -> (rune, int) { return r, size } -rune_at_pos :: proc(s: string, pos: int) -> rune { +rune_at_pos :: proc "contextless" (s: string, pos: int) -> rune { if pos < 0 { return RUNE_ERROR } @@ -221,7 +226,7 @@ rune_at_pos :: proc(s: string, pos: int) -> rune { return RUNE_ERROR } -rune_string_at_pos :: proc(s: string, pos: int) -> string { +rune_string_at_pos :: proc "contextless" (s: string, pos: int) -> string { if pos < 0 { return "" } @@ -237,14 +242,14 @@ rune_string_at_pos :: proc(s: string, pos: int) -> string { return "" } -rune_at :: proc(s: string, byte_index: int) -> rune { +rune_at :: proc "contextless" (s: string, byte_index: int) -> rune { r, _ := decode_rune_in_string(s[byte_index:]) return r } // Returns the byte position of rune at position pos in s with an optional start byte position. // Returns -1 if it runs out of the string. -rune_offset :: proc(s: string, pos: int, start: int = 0) -> int { +rune_offset :: proc "contextless" (s: string, pos: int, start: int = 0) -> int { if pos < 0 { return -1 } @@ -259,7 +264,7 @@ rune_offset :: proc(s: string, pos: int, start: int = 0) -> int { return -1 } -valid_rune :: proc(r: rune) -> bool { +valid_rune :: proc "contextless" (r: rune) -> bool { if r < 0 { return false } else if SURROGATE_MIN <= r && r <= SURROGATE_MAX { @@ -270,7 +275,7 @@ valid_rune :: proc(r: rune) -> bool { return true } -valid_string :: proc(s: string) -> bool { +valid_string :: proc "contextless" (s: string) -> bool { n := len(s) for i := 0; i < n; { si := s[i] @@ -303,7 +308,7 @@ valid_string :: proc(s: string) -> bool { return true } -rune_start :: #force_inline proc(b: u8) -> bool { +rune_start :: #force_inline proc "contextless" (b: u8) -> bool { return b&0xc0 != 0x80 } @@ -315,7 +320,7 @@ rune_count :: proc{ rune_count_in_string :: #force_inline proc(s: string) -> int { return rune_count_in_bytes(transmute([]u8)s) } -rune_count_in_bytes :: proc(s: []u8) -> int { +rune_count_in_bytes :: proc "contextless" (s: []u8) -> int { count := 0 n := len(s) @@ -354,7 +359,7 @@ rune_count_in_bytes :: proc(s: []u8) -> int { } -rune_size :: proc(r: rune) -> int { +rune_size :: proc "contextless" (r: rune) -> int { switch { case r < 0: return -1 case r <= 1<<7 - 1: return 1 @@ -375,7 +380,7 @@ full_rune :: proc{ // full_rune_in_bytes reports if the bytes in b begin with a full utf-8 encoding of a rune or not // An invalid encoding is considered a full rune since it will convert as an error rune of width 1 (RUNE_ERROR) -full_rune_in_bytes :: proc(b: []byte) -> bool { +full_rune_in_bytes :: proc "contextless" (b: []byte) -> bool { n := len(b) if n == 0 { return false @@ -395,7 +400,7 @@ full_rune_in_bytes :: proc(b: []byte) -> bool { // full_rune_in_string reports if the bytes in s begin with a full utf-8 encoding of a rune or not // An invalid encoding is considered a full rune since it will convert as an error rune of width 1 (RUNE_ERROR) -full_rune_in_string :: proc(s: string) -> bool { +full_rune_in_string :: proc "contextless" (s: string) -> bool { return full_rune_in_bytes(transmute([]byte)s) } diff --git a/examples/all/all_main.odin b/examples/all/all_main.odin index 9f1865d46..60850c806 100644 --- a/examples/all/all_main.odin +++ b/examples/all/all_main.odin @@ -19,6 +19,8 @@ import priority_queue "core:container/priority_queue" import queue "core:container/queue" import small_array "core:container/small_array" import lru "core:container/lru" +import list "core:container/intrusive/list" +import topological_sort "core:container/topological_sort" import crypto "core:crypto" import blake "core:crypto/blake" @@ -48,7 +50,10 @@ import crypto_util "core:crypto/util" import whirlpool "core:crypto/whirlpool" import x25519 "core:crypto/x25519" +import pe "core:debug/pe" + import dynlib "core:dynlib" +import net "core:net" import base32 "core:encoding/base32" import base64 "core:encoding/base64" @@ -57,9 +62,11 @@ import hxa "core:encoding/hxa" import json "core:encoding/json" import varint "core:encoding/varint" import xml "core:encoding/xml" +import endian "core:encoding/endian" import fmt "core:fmt" import hash "core:hash" +import xxhash "core:hash/xxhash" import image "core:image" import netpbm "core:image/netpbm" @@ -79,9 +86,10 @@ import glm "core:math/linalg/glsl" import hlm "core:math/linalg/hlsl" import noise "core:math/noise" import rand "core:math/rand" +import ease "core:math/ease" import mem "core:mem" -// import virtual "core:mem/virtual" +import virtual "core:mem/virtual" import ast "core:odin/ast" import doc_format "core:odin/doc-format" @@ -90,6 +98,8 @@ import odin_parser "core:odin/parser" import odin_printer "core:odin/printer" import odin_tokenizer "core:odin/tokenizer" +import spall "core:prof/spall" + import os "core:os" import slashpath "core:path/slashpath" @@ -107,6 +117,9 @@ import sync "core:sync" import testing "core:testing" import scanner "core:text/scanner" import i18n "core:text/i18n" +import match "core:text/match" +import table "core:text/table" +import edit "core:text/edit" import thread "core:thread" import time "core:time" @@ -133,6 +146,8 @@ _ :: priority_queue _ :: queue _ :: small_array _ :: lru +_ :: list +_ :: topological_sort _ :: crypto _ :: blake _ :: blake2b @@ -160,7 +175,9 @@ _ :: tiger2 _ :: crypto_util _ :: whirlpool _ :: x25519 +_ :: pe _ :: dynlib +_ :: net _ :: base32 _ :: base64 _ :: csv @@ -168,8 +185,10 @@ _ :: hxa _ :: json _ :: varint _ :: xml +_ :: endian _ :: fmt _ :: hash +_ :: xxhash _ :: image _ :: netpbm _ :: png @@ -186,7 +205,9 @@ _ :: glm _ :: hlm _ :: noise _ :: rand +_ :: ease _ :: mem +_ :: virtual _ :: ast _ :: doc_format _ :: odin_format @@ -194,6 +215,7 @@ _ :: odin_parser _ :: odin_printer _ :: odin_tokenizer _ :: os +_ :: spall _ :: slashpath _ :: filepath _ :: reflect @@ -208,10 +230,13 @@ _ :: sync _ :: testing _ :: scanner _ :: i18n +_ :: match +_ :: table +_ :: edit _ :: thread _ :: time _ :: sysinfo _ :: unicode _ :: utf8 _ :: utf8string -_ :: utf16 \ No newline at end of file +_ :: utf16 diff --git a/examples/all/all_vendor.odin b/examples/all/all_vendor.odin index bd5921e6a..fe1080e20 100644 --- a/examples/all/all_vendor.odin +++ b/examples/all/all_vendor.odin @@ -1,7 +1,27 @@ package all -import botan "vendor:botan" +import botan_bindings "vendor:botan/bindings" +import botan_blake2b "vendor:botan/blake2b" +import gost "vendor:botan/gost" +import keccak "vendor:botan/keccak" +import md4 "vendor:botan/md4" +import md5 "vendor:botan/md5" +import ripemd "vendor:botan/ripemd" +import sha1 "vendor:botan/sha1" +import sha2 "vendor:botan/sha2" +import sha3 "vendor:botan/sha3" +import shake "vendor:botan/shake" +import siphash "vendor:botan/siphash" +import skein512 "vendor:botan/skein512" +import sm3 "vendor:botan/sm3" +import streebog "vendor:botan/streebog" +import tiger "vendor:botan/tiger" +import whirlpool "vendor:botan/whirlpool" + +import cgltf "vendor:cgltf" +// import commonmark "vendor:commonmark" import ENet "vendor:ENet" +import exr "vendor:OpenEXRCore" import ggpo "vendor:ggpo" import gl "vendor:OpenGL" import glfw "vendor:glfw" @@ -9,8 +29,7 @@ import microui "vendor:microui" import miniaudio "vendor:miniaudio" import PM "vendor:portmidi" import rl "vendor:raylib" -import exr "vendor:OpenEXRCore" -import cgltf "vendor:cgltf" +import zlib "vendor:zlib" import SDL "vendor:sdl2" import SDLNet "vendor:sdl2/net" @@ -22,10 +41,35 @@ import vk "vendor:vulkan" import NS "vendor:darwin/Foundation" import MTL "vendor:darwin/Metal" +import MTK "vendor:darwin/MetalKit" import CA "vendor:darwin/QuartzCore" -_ :: botan +// NOTE(bill): only one can be checked at a time +import lua_5_4 "vendor:lua/5.4" + +_ :: botan_bindings +_ :: botan_blake2b +_ :: gost +_ :: keccak +_ :: md4 +_ :: md5 +_ :: ripemd +_ :: sha1 +_ :: sha2 +_ :: sha3 +_ :: shake +_ :: siphash +_ :: skein512 +_ :: sm3 +_ :: streebog +_ :: tiger +_ :: whirlpool + + +_ :: cgltf +// _ :: commonmark _ :: ENet +_ :: exr _ :: ggpo _ :: gl _ :: glfw @@ -33,8 +77,7 @@ _ :: microui _ :: miniaudio _ :: PM _ :: rl -_ :: exr -_ :: cgltf +_ :: zlib _ :: SDL _ :: SDLNet @@ -46,4 +89,7 @@ _ :: vk _ :: NS _ :: MTL -_ :: CA \ No newline at end of file +_ :: MTK +_ :: CA + +_ :: lua_5_4 \ No newline at end of file diff --git a/examples/demo/demo.odin b/examples/demo/demo.odin index 457aa786a..7c98ca728 100644 --- a/examples/demo/demo.odin +++ b/examples/demo/demo.odin @@ -352,7 +352,7 @@ control_flow :: proc() { if false { f, err := os.open("my_file.txt") - if err != 0 { + if err != os.ERROR_NONE { // handle error } defer os.close(f) @@ -1175,13 +1175,13 @@ threading_example :: proc() { N :: 3 pool: thread.Pool - thread.pool_init(pool=&pool, thread_count=N, allocator=context.allocator) + thread.pool_init(&pool, allocator=context.allocator, thread_count=N) defer thread.pool_destroy(&pool) for i in 0..<30 { // be mindful of the allocator used for tasks. The allocator needs to be thread safe, or be owned by the task for exclusive use - thread.pool_add_task(pool=&pool, procedure=task_proc, data=nil, user_index=i, allocator=context.allocator) + thread.pool_add_task(&pool, allocator=context.allocator, procedure=task_proc, data=nil, user_index=i) } thread.pool_start(&pool) @@ -2145,10 +2145,8 @@ or_return_operator :: proc() { return -345 * z, zerr } - // If the other return values need to be set depending on what the end value is, - // the 'defer if' idiom is can be used defer if err != nil { - n = -1 + fmt.println("Error in", #procedure, ":" , err) } n = 123 diff --git a/misc/old_demos/demo001.odin b/misc/old_demos/demo001.odin deleted file mode 100644 index a3aea1cb7..000000000 --- a/misc/old_demos/demo001.odin +++ /dev/null @@ -1,337 +0,0 @@ -import "core:fmt.odin"; -import "core:os.odin"; -import "core:mem.odin"; -// import "http_test.odin" as ht; -// import "game.odin" as game; -// import "punity.odin" as pn; - -main :: proc() { - struct_padding(); - bounds_checking(); - type_introspection(); - any_type(); - crazy_introspection(); - namespaces_and_files(); - miscellany(); - - /* - ht.run(); - game.run(); - { - init :: proc(c: ^pn.Core) {} - step :: proc(c: ^pn.Core) {} - - pn.run(init, step); - } - */ -} - -struct_padding :: proc() { - { - A :: struct { - a: u8, - b: u32, - c: u16, - } - - B :: struct { - a: [7]u8, - b: [3]u16, - c: u8, - d: u16, - } - - fmt.println("size_of(A):", size_of(A)); - fmt.println("size_of(B):", size_of(B)); - - // n.b. http://cbloomrants.blogspot.co.uk/2012/07/07-23-12-structs-are-not-what-you-want.html - } - { - A :: struct #ordered { - a: u8, - b: u32, - c: u16, - } - - B :: struct #ordered { - a: [7]u8, - b: [3]u16, - c: u8, - d: u16, - } - - fmt.println("size_of(A):", size_of(A)); - fmt.println("size_of(B):", size_of(B)); - - // C-style structure layout - } - { - A :: struct #packed { - a: u8, - b: u32, - c: u16, - } - - B :: struct #packed { - a: [7]u8, - b: [3]u16, - c: u8, - d: u16, - } - - fmt.println("size_of(A):", size_of(A)); - fmt.println("size_of(B):", size_of(B)); - - // Useful for explicit layout - } - - // Member sorting by priority - // Alignment desc. - // Size desc. - // source order asc. - - /* - A :: struct { - a: u8 - b: u32 - c: u16 - } - - B :: struct { - a: [7]u8 - b: [3]u16 - c: u8 - d: u16 - } - - Equivalent too - - A :: struct #ordered { - b: u32 - c: u16 - a: u8 - } - - B :: struct #ordered { - b: [3]u16 - d: u16 - a: [7]u8 - c: u8 - } - */ -} - -bounds_checking :: proc() { - x: [4]int; - // x[-1] = 0; // Compile Time - // x[4] = 0; // Compile Time - - { - a, b := -1, 4; - // x[a] = 0; // Runtime Time - // x[b] = 0; // Runtime Time - } - - // Works for arrays, strings, slices, and related procedures & operations - - { - base: [10]int; - s := base[2..6]; - a, b := -1, 6; - - #no_bounds_check { - s[a] = 0; - // #bounds_check s[b] = 0; - } - - #no_bounds_check - if s[a] == 0 { - // Do whatever - } - - // Bounds checking can be toggled explicit - // on a per statement basis. - // _any statement_ - } -} - -type_introspection :: proc() { - { - info: ^Type_Info; - x: int; - - info = type_info_of(int); // by type - info = type_info_of(x); // by value - // See: runtime.odin - - match i in info.variant { - case Type_Info_Integer: - fmt.println("integer!"); - case Type_Info_Float: - fmt.println("float!"); - case: - fmt.println("potato!"); - } - - // Unsafe cast - integer_info := cast(^Type_Info_Integer)cast(rawptr)info; - } - - { - Vector2 :: struct { x, y: f32 } - Vector3 :: struct { x, y, z: f32 } - - v1: Vector2; - v2: Vector3; - v3: Vector3; - - t1 := type_info_of(v1); - t2 := type_info_of(v2); - t3 := type_info_of(v3); - - fmt.println(); - fmt.print("Type of v1 is:\n\t", t1); - - fmt.println(); - fmt.print("Type of v2 is:\n\t", t2); - - fmt.println("\n"); - fmt.println("t1 == t2:", t1 == t2); - fmt.println("t2 == t3:", t2 == t3); - } -} - -any_type :: proc() { - a: any; - - x: int = 123; - y: f64 = 6.28; - z: string = "Yo-Yo Ma"; - // All types can be implicit cast to `any` - a = x; - a = y; - a = z; - a = a; // This the "identity" type, it doesn't get converted - - a = 123; // Literals are copied onto the stack first - - // any has two members - // data - rawptr to the data - // type_info - pointer to the type info - - fmt.println(x, y, z); - // See: fmt.odin - // For variadic any procedures in action -} - -crazy_introspection :: proc() { - { - Fruit :: enum { - APPLE, - BANANA, - GRAPE, - MELON, - PEACH, - TOMATO, - } - - s: string; - // s = enum_to_string(Fruit.PEACH); - fmt.println(s); - - f := Fruit.GRAPE; - // s = enum_to_string(f); - fmt.println(s); - - fmt.println(f); - // See: runtime.odin - } - - - { - // NOTE(bill): This is not safe code and I would not recommend this at all - // I'd recommend you use `match type` to get the subtype rather than - // casting pointers - - Fruit :: enum { - APPLE, - BANANA, - GRAPE, - MELON, - PEACH, - TOMATO, - } - - fruit_ti := type_info_of(Fruit); - name := fruit_ti.variant.(Type_Info_Named).name; - info, _ := type_info_base(fruit_ti).variant.(Type_Info_Enum); - - fmt.printf("%s :: enum %T {\n", name, info.base); - for _, i in info.values { - fmt.printf("\t%s\t= %v,\n", info.names[i], info.values[i]); - } - fmt.printf("}\n"); - - // NOTE(bill): look at that type-safe printf! - } - - { - Vector3 :: struct {x, y, z: f32} - - a := Vector3{x = 1, y = 4, z = 9}; - fmt.println(a); - b := Vector3{x = 9, y = 3, z = 1}; - fmt.println(b); - - // NOTE(bill): See fmt.odin - } - - // n.b. This pretty much "solves" serialization (to strings) -} - -// #import "test.odin" - -namespaces_and_files :: proc() { - - // test.thing() - // test.format.println() - // test.println() - /* - // Non-exporting import - #import "file.odin" - #import "file.odin" as file - #import "file.odin" as . - #import "file.odin" as _ - - // Exporting import - #include "file.odin" - */ - - // Talk about scope rules and diagram -} - -miscellany :: proc() { - /* - win32 `__imp__` prefix - #dll_import - #dll_export - - Change exported name/symbol for linking - #link_name - - Custom calling conventions - #stdcall - #fastcall - - Runtime stuff - #shared_global_scope - */ - - // assert(false) - // #assert(false) - // panic("Panic message goes here") -} - - - - diff --git a/misc/old_demos/demo002.odin b/misc/old_demos/demo002.odin deleted file mode 100644 index a790aadf3..000000000 --- a/misc/old_demos/demo002.odin +++ /dev/null @@ -1,879 +0,0 @@ -// Demo 002 -export "core:fmt.odin"; -export "core:math.odin"; -export "core:mem.odin"; -// export "game.odin" - -#thread_local tls_int: int; - -main :: proc() { - // Forenotes - - // Semicolons are now optional - // Rule for when a semicolon is expected after a statement - // - If the next token is not on the same line - // - if the next token is a closing brace } - // - Otherwise, a semicolon is needed - // - // Expections: - // for, if, match - // if x := thing(); x < 123 {} - // for i := 0; i < 123; i++ {} - - // Q: Should I use the new rule or go back to the old one without optional semicolons? - - - // #thread_local - see runtime.odin and above at `tls_int` - // #foreign_system_library - see win32.odin - - // struct_compound_literals(); - // enumerations(); - // variadic_procedures(); - // new_builtins(); - // match_statement(); - // namespacing(); - // subtyping(); - // tagged_unions(); -} - -struct_compound_literals :: proc() { - Thing :: struct { - id: int, - x: f32, - name: string, - }; - { - t1: Thing; - t1.id = 1; - - t3 := Thing{}; - t4 := Thing{1, 2, "Fred"}; - // t5 := Thing{1, 2}; - - t6 := Thing{ - name = "Tom", - x = 23, - }; - } -} - -enumerations :: proc() { - { - Fruit :: enum { - APPLE, // 0 - BANANA, // 1 - PEAR, // 2 - }; - - f := Fruit.APPLE; - // g12: int = Fruit.BANANA - g: int = cast(int)Fruit.BANANA; - // However, you can use enums are index values as _any_ integer allowed - } - { - Fruit1 :: enum int { - APPLE, - BANANA, - PEAR, - } - - Fruit2 :: enum u8 { - APPLE, - BANANA, - PEAR, - } - - Fruit3 :: enum u8 { - APPLE = 1, - BANANA, // 2 - PEAR = 5, - TOMATO, // 6 - } - } - - // Q: remove the need for `type` if it's a record (struct/enum/raw_union/union)? -} - -variadic_procedures :: proc() { - print_ints :: proc(args: ..int) { - for arg, i in args { - if i > 0 do print(", "); - print(arg); - } - } - - print_ints(); // nl() - print_ints(1); nl(); - print_ints(1, 2, 3); nl(); - - print_prefix_f32s :: proc(prefix: string, args: ..f32) { - print(prefix); - print(": "); - for arg, i in args { - if i > 0 do print(", "); - print(arg); - } - } - - print_prefix_f32s("a"); nl(); - print_prefix_f32s("b", 1); nl(); - print_prefix_f32s("c", 1, 2, 3); nl(); - - // Internally, the variadic procedures get allocated to an array on the stack, - // and this array is passed a slice - - // This is first step for a `print` procedure but I do not have an `any` type - // yet as this requires a few other things first - i.e. introspection - - // NOTE(bill): I haven't yet added the feature of expanding a slice or array into - // a variadic a parameter but it's pretty trivial to add -} - -new_builtins :: proc() { - { - a := new(int); - b := make([]int, 12); - c := make([]int, 12, 16); - - defer free(a); - defer free(b); - defer free(c); - - // NOTE(bill): These use the current context's allocator not the default allocator - // see runtime.odin - - // Q: Should this be `free` rather than `free` and should I overload it for slices too? - - push_allocator default_allocator() { - a := new(int); - defer free(a); - - // Do whatever - - } - } - - { - a: int = 123; - b: type_of(a) = 321; - - // NOTE(bill): This matches the current naming scheme - // size_of - // align_of - // offset_of - // - // size_of_val - // align_of_val - // offset_of_val - // type_of_val - } - - { - // Compile time assert - COND :: true; - #assert(COND); - // #assert(!COND) - - // Runtime assert - x := true; - assert(x); - // assert(!x); - } - - { - x: ^u32 = nil; - y := x+100; - z := y-x; - w := slice_ptr(x, 12); - t := slice_ptr(x, 12, 16); - - // NOTE(bill): These are here because I've removed: - // pointer arithmetic - // pointer indexing - // pointer slicing - - // Reason - - a: [16]int; - a[1] = 1; - b := &a; - // Auto pointer deref - // consistent with record members - assert(b[1] == 1); - - // Q: Should I add them back in at the cost of inconsitency? - } - - { - a, b := -1, 2; - print(min(a, b)); nl(); - print(max(a, b)); nl(); - print(abs(a)); nl(); - - // These work at compile time too - A :: -1; - B :: 2; - C :: min(A, B); - D :: max(A, B); - E :: abs(A); - - print(C); nl(); - print(D); nl(); - print(E); nl(); - } -} - - -match_statement :: proc() { - // NOTE(bill): `match` statements are similar to `switch` statements - // in other languages but there are few differences - - { - match x := 5; x { - case 1: // cases must be constant expression - print("1!\n"); - // break by default - - case 2: - s := "2!\n"; // Each case has its own scope - print(s); - break; // explicit break - - case 3, 4: // multiple cases - print("3 or 4!\n"); - - case 5: - print("5!\n"); - fallthrough; // explicit fallthrough - - case: - print("default!\n"); - } - - - - match x := 1.5; x { - case 1.5: - print("1.5!\n"); - // break by default - case TAU: - print("Ļ„!\n"); - case: - print("default!\n"); - } - - - - match x := "Hello"; x { - case "Hello": - print("greeting\n"); - // break by default - case "Goodbye": - print("farewell\n"); - case: - print("???\n"); - } - - - - - - - a := 53; - match { - case a == 1: - print("one\n"); - case a == 2: - print("a couple\n"); - case a < 7, a == 7: - print("a few\n"); - case a < 12: // intentional bug - print("several\n"); - case a >= 12 && a < 100: - print("dozens\n"); - case a >= 100 && a < 1000: - print("hundreds\n"); - case: - print("a fuck ton\n"); - } - - // Identical to this - - b := 53; - if b == 1 { - print("one\n"); - } else if b == 2 { - print("a couple\n"); - } else if b < 7 || b == 7 { - print("a few\n"); - } else if b < 12 { // intentional bug - print("several\n"); - } else if b >= 12 && b < 100 { - print("dozens\n"); - } else if b >= 100 && b < 1000 { - print("hundreds\n"); - } else { - print("a fuck ton\n"); - } - - // However, match statements allow for `break` and `fallthrough` unlike - // an if statement - } -} - -Vector3 :: struct {x, y, z: f32} - -print_floats :: proc(args: ..f32) { - for arg, i in args { - if i > 0 do print(", "); - print(arg); - } - println(); -} - -namespacing :: proc() { - { - Thing :: #type struct { - x: f32, - name: string, - }; - - a: Thing; - a.x = 3; - { - Thing :: #type struct { - y: int, - test: bool, - }; - - b: Thing; // Uses this scope's Thing - b.test = true; - } - } -/* - { - Entity :: struct { - Guid :: int - Nested :: struct { - MyInt :: int - i: int - } - - CONSTANT :: 123 - - - guid: Guid - name: string - pos: Vector3 - vel: Vector3 - nested: Nested - } - - guid: Entity.Guid = Entity.CONSTANT - i: Entity.Nested.MyInt - - - - { - using Entity - guid: Guid = CONSTANT - using Nested - i: MyInt - } - - - { - using Entity.Nested - guid: Entity.Guid = Entity.CONSTANT - i: MyInt - } - - - { - e: Entity - using e - guid = 27832 - name = "Bob" - - print(e.guid as int); nl() - print(e.name); nl() - } - - { - using e: Entity - guid = 78456 - name = "Thing" - - print(e.guid as int); nl() - print(e.name); nl() - } - } - - { - Entity :: struct { - Guid :: int - Nested :: struct { - MyInt :: int - i: int - } - - CONSTANT :: 123 - - - guid: Guid - name: string - using pos: Vector3 - vel: Vector3 - using nested: ^Nested - } - - e := Entity{nested = new(Entity.Nested)} - e.x = 123 - e.i = Entity.CONSTANT - } - -*/ - - { - Entity :: struct { - position: Vector3 - } - - print_pos_1 :: proc(entity: ^Entity) { - print("print_pos_1: "); - print_floats(entity.position.x, entity.position.y, entity.position.z); - } - - print_pos_2 :: proc(entity: ^Entity) { - using entity; - print("print_pos_2: "); - print_floats(position.x, position.y, position.z); - } - - print_pos_3 :: proc(using entity: ^Entity) { - print("print_pos_3: "); - print_floats(position.x, position.y, position.z); - } - - print_pos_4 :: proc(using entity: ^Entity) { - using position; - print("print_pos_4: "); - print_floats(x, y, z); - } - - e := Entity{position = Vector3{1, 2, 3}}; - print_pos_1(&e); - print_pos_2(&e); - print_pos_3(&e); - print_pos_4(&e); - - // This is similar to C++'s `this` pointer that is implicit and only available in methods - } -} - -subtyping :: proc() { - { - // C way for subtyping/subclassing - - Entity :: struct { - position: Vector3, - } - - Frog :: struct { - entity: Entity, - jump_height: f32, - } - - f: Frog; - f.entity.position = Vector3{1, 2, 3}; - - using f.entity; - position = Vector3{1, 2, 3}; - - } - - { - // C++ way for subtyping/subclassing - - Entity :: struct { - position: Vector3 - } - - Frog :: struct { - using entity: Entity, - jump_height: f32, - } - - f: Frog; - f.position = Vector3{1, 2, 3}; - - - print_pos :: proc(using entity: Entity) { - print("print_pos: "); - print_floats(position.x, position.y, position.z); - } - - print_pos(f.entity); - // print_pos(f); - - // Subtype Polymorphism - } - - { - // More than C++ way for subtyping/subclassing - - Entity :: struct { - position: Vector3, - } - - Frog :: struct { - jump_height: f32, - using entity: ^Entity, // Doesn't have to be first member! - } - - f: Frog; - f.entity = new(Entity); - f.position = Vector3{1, 2, 3}; - - - print_pos :: proc(using entity: ^Entity) { - print("print_pos: "); - print_floats(position.x, position.y, position.z); - } - - print_pos(f.entity); - // print_pos(^f); - // print_pos(f); - } - - { - // More efficient subtyping - - Entity :: struct { - position: Vector3, - } - - Frog :: struct { - jump_height: f32, - using entity: ^Entity, - } - - MAX_ENTITES :: 64; - entities: [MAX_ENTITES]Entity; - entity_count := 0; - - next_entity :: proc(entities: []Entity, entity_count: ^int) -> ^Entity { - e := &entities[entity_count^]; - entity_count^ += 1; - return e; - } - - f: Frog; - f.entity = next_entity(entities[..], &entity_count); - f.position = Vector3{3, 4, 6}; - - using f.position; - print_floats(x, y, z); - } - - /*{ - // Down casting - - Entity :: struct { - position: Vector3, - } - - Frog :: struct { - jump_height: f32, - using entity: Entity, - } - - f: Frog; - f.jump_height = 564; - e := ^f.entity; - - frog := down_cast(^Frog)e; - print("down_cast: "); - print(frog.jump_height); nl(); - - // NOTE(bill): `down_cast` is unsafe and there are not check are compile time or run time - // Q: Should I completely remove `down_cast` as I added it in about 30 minutes - }*/ - - { - // Multiple "inheritance"/subclassing - - Entity :: struct { - position: Vector3, - } - Climber :: struct { - speed: f32, - } - - Frog :: struct { - using entity: Entity, - using climber: Climber, - } - } -} - -tagged_unions :: proc() { - { - Entity_Kind :: enum { - INVALID, - FROG, - GIRAFFE, - HELICOPTER, - } - - Entity :: struct { - kind: Entity_Kind - using data: struct #raw_union { - frog: struct { - jump_height: f32, - colour: u32, - }, - giraffe: struct { - neck_length: f32, - spot_count: int, - }, - helicopter: struct { - blade_count: int, - weight: f32, - pilot_name: string, - }, - } - } - - e: Entity; - e.kind = Entity_Kind.FROG; - e.frog.jump_height = 12; - - f: type_of(e.frog); - - // But this is very unsafe and extremely cumbersome to write - // In C++, I use macros to alleviate this but it's not a solution - } - - { - Frog :: struct { - jump_height: f32, - colour: u32, - } - Giraffe :: struct { - neck_length: f32, - spot_count: int, - } - Helicopter :: struct { - blade_count: int, - weight: f32, - pilot_name: string, - } - Entity :: union {Frog, Giraffe, Helicopter}; - - f1: Frog = Frog{12, 0xff9900}; - f2: Entity = Frog{12, 0xff9900}; // Implicit cast - f3 := cast(Entity)Frog{12, 0xff9900}; // Explicit cast - - // f3.Frog.jump_height = 12 // There are "members" of a union - - - - e, f, g, h: Entity; - f = Frog{12, 0xff9900}; - g = Giraffe{2.1, 23}; - h = Helicopter{4, 1000, "Frank"}; - - - - - // Requires a pointer to the union - // `x` will be a pointer to type of the case - - match x in &f { - case Frog: - print("Frog!\n"); - print(x.jump_height); nl(); - // x.jump_height = 3; - print(x.jump_height); nl(); - case Giraffe: - print("Giraffe!\n"); - case Helicopter: - print("ROFLCOPTER!\n"); - case: - print("invalid entity\n"); - } - - - // Q: Allow for a non pointer version with takes a copy instead? - // Or it takes the pointer the data and not a copy - - - // fp := cast(^Frog)^f; // Unsafe - // print(fp.jump_height); nl(); - - - // Internals of a tagged union - /* - struct { - data: [size_of_biggest_tag]u8, - tag_index: int, - } - */ - // This is to allow for pointer casting if needed - - - // Advantage over subtyping version - MAX_ENTITES :: 64; - entities: [MAX_ENTITES]Entity; - - entities[0] = Frog{}; - entities[1] = Helicopter{}; - // etc. - } - - - { - // Transliteration of code from this actual compiler - // Some stuff is missing - Type :: struct {}; - Scope :: struct {}; - Token :: struct {}; - AstNode :: struct {}; - ExactValue :: struct {}; - - Entity_Kind :: enum { - Invalid, - Constant, - Variable, - Using_Variable, - TypeName, - Procedure, - Builtin, - Count, - } - - Guid :: i64; - Entity :: struct { - - kind: Entity_Kind, - guid: Guid, - - scope: ^Scope, - token: Token, - type_: ^Type, - - using data: struct #raw_union { - Constant: struct { - value: ExactValue, - }, - Variable: struct { - visited: bool, // Cycle detection - used: bool, // Variable is used - is_field: bool, // Is struct field - anonymous: bool, // Variable is an anonymous - }, - Using_Variable: struct { - }, - TypeName: struct { - }, - Procedure: struct { - used: bool, - }, - Builtin: struct { - id: int, - }, - }, - } - - // Plus all the constructing procedures that go along with them!!!! - // It's a nightmare - } - - { - Type :: struct {}; - Scope :: struct {}; - Token :: struct {}; - AstNode :: struct {}; - ExactValue :: struct {}; - - - Guid :: i64; - Entity_Base :: struct { - } - - - Constant :: struct { - value: ExactValue, - } - Variable :: struct { - visited: bool, // Cycle detection - used: bool, // Variable is used - is_field: bool, // Is struct field - anonymous: bool, // Variable is an anonymous - } - Using_Variable :: struct { - } - TypeName :: struct { - } - Procedure :: struct { - used: bool, - } - Builtin :: struct { - id: int, - } - - Entity :: struct { - guid: Guid, - - scope: ^Scope, - token: Token, - type_: ^Type, - - variant: union {Constant, Variable, Using_Variable, TypeName, Procedure, Builtin}, - } - - e := Entity{ - variant = Variable{ - used = true, - anonymous = false, - }, - }; - - - - // Q: Allow a "base" type to be added to a union? - // Or even `using` on union to get the same properties? - } - - - { - // `Raw` unions still have uses, especially for mathematic types - - Vector2 :: struct #raw_union { - using xy_: struct { x, y: f32 }, - e: [2]f32, - v: [vector 2]f32, - } - - Vector3 :: struct #raw_union { - using xyz_: struct { x, y, z: f32 }, - xy: Vector2, - e: [3]f32, - v: [vector 3]f32, - } - - v2: Vector2; - v2.x = 1; - v2.e[0] = 1; - v2.v[0] = 1; - - v3: Vector3; - v3.x = 1; - v3.e[0] = 1; - v3.v[0] = 1; - v3.xy.x = 1; - } -} - -nl :: proc() { println(); } diff --git a/misc/old_demos/demo004.odin b/misc/old_demos/demo004.odin deleted file mode 100644 index c9acc9a15..000000000 --- a/misc/old_demos/demo004.odin +++ /dev/null @@ -1,66 +0,0 @@ -import "core:fmt.odin"; -import "core:utf8.odin"; -import "core:hash.odin"; -import "core:mem.odin"; - -main :: proc() { - { // New Standard Library stuff - s := "Hello"; - fmt.println(s, - utf8.valid_string(s), - hash.murmur64(cast([]u8)s)); - - // utf8.odin - // hash.odin - // - crc, fnv, fnva, murmur - // mem.odin - // - Custom allocators - // - Helpers - } - - { - arena: mem.Arena; - mem.init_arena_from_context(&arena, mem.megabytes(16)); // Uses default allocator - defer mem.destroy_arena(&arena); - - push_allocator mem.arena_allocator(&arena) { - x := new(int); - x^ = 1337; - - fmt.println(x^); - } - - /* - push_allocator x { - .. - } - - is equivalent to: - - { - prev_allocator := __context.allocator - __context.allocator = x - defer __context.allocator = prev_allocator - - .. - } - */ - - // You can also "push" a context - - c := context; // Create copy of the allocator - c.allocator = mem.arena_allocator(&arena); - - push_context c { - x := new(int); - x^ = 365; - - fmt.println(x^); - } - } - - // Backend improvements - // - Minimal dependency building (only build what is needed) - // - Numerous bugs fixed - // - Mild parsing recovery after bad syntax error -} diff --git a/misc/old_demos/demo005.odin b/misc/old_demos/demo005.odin deleted file mode 100644 index c8273b03b..000000000 --- a/misc/old_demos/demo005.odin +++ /dev/null @@ -1,283 +0,0 @@ -import "core:fmt.odin"; -import "core:utf8.odin"; -// import "core:atomic.odin"; -// import "core:hash.odin"; -// import "core:math.odin"; -// import "core:mem.odin"; -// import "core:opengl.odin"; -// import "core:os.odin"; -// import "core:sync.odin"; -// import win32 "core:sys/windows.odin"; - -main :: proc() { - // syntax(); - procedure_overloading(); -} - -syntax :: proc() { - // Cyclic type checking - // Uncomment to see the error - // A :: struct {b: B}; - // B :: struct {a: A}; - - x: int; - y := cast(f32)x; - z := transmute(u32)y; - // down_cast, union_cast are similar too - - - - // Basic directives - fmt.printf("Basic directives = %s(%d): %s\n", #file, #line, #procedure); - // NOTE: new and improved `printf` - // TODO: It does need accurate float printing - - - - // record fields use the same syntax a procedure signatures - Thing1 :: struct { - x: f32, - y: int, - z: ^[]int, - }; - Thing2 :: struct {x: f32, y: int, z: ^[]int}; - - // Slice interals are now just a `ptr+len+cap` - slice: []int; #assert(size_of(slice) == 3*size_of(int)); - - // Helper type - Help the reader understand what it is quicker - My_Int :: #type int; - My_Proc :: #type proc(int) -> f32; - - - // All declarations with : are either variable or constant - // To make these declarations syntactically consistent - v_variable := 123; - c_constant :: 123; - c_type1 :: int; - c_type2 :: []int; - c_proc :: proc() { /* code here */ }; - - -/* - x += 1; - x -= 1; - // ++ and -- have been removed - // x++; - // x--; - // Question: Should they be added again? - // They were removed as they are redundant and statements, not expressions - // like in C/C++ -*/ - - // You can now build files as a `.dll` - // `odin build_dll demo.odin` - - - // New vector syntax - u, v: [vector 3]f32; - v[0] = 123; - v.x = 123; // valid for all vectors with count 1 to 4 - - // Next part - prefixes(); -} - - -Prefix_Type :: struct {x: int, y: f32, z: rawptr}; - -#thread_local my_tls: Prefix_Type; - -prefixes :: proc() { - using var: Prefix_Type; - var.x = 123; - x = 123; - - - foo :: proc(using pt: Prefix_Type) { - } - - - - // Same as C99's `restrict` - bar :: proc(#no_alias a, b: ^int) { - // Assumes a never equals b so it can perform optimizations with that fact - } - - - when_statements(); -} - - - - - -when_statements :: proc() { - X :: 123 + 12; - Y :: X/5; - COND :: Y > 0; - - when COND { - fmt.println("Y > 0"); - } else { - fmt.println("Y <= 0"); - } - - - when false { - this_code_does_not_exist(123, 321); - but_its_syntax_is_valid(); - x :: ^^^^int; - } - - foreign_procedures(); -} - -when ODIN_OS == "windows" { - foreign_system_library win32_user "user32.lib"; -} -// NOTE: This is done on purpose for two reasons: -// * Makes it clear where the platform specific stuff is -// * Removes the need to solve the travelling salesman problem when importing files :P - -foreign_procedures :: proc() { - foreign win32_user { - ShowWindow :: proc(hwnd: rawptr, cmd_show: i32) -> i32 ---; - show_window :: proc(hwnd: rawptr, cmd_show: i32) -> i32 #link_name "ShowWindow" ---; - } - // NOTE: If that library doesn't get used, it doesn't get linked with - // NOTE: There is not link checking yet to see if that procedure does come from that library - - // See sys/windows.odin for more examples - - special_expressions(); -} - -special_expressions :: proc() { -/* - // Block expression - x := { - a: f32 = 123; - b := a-123; - c := b/a; - give c; - }; // semicolon is required as it's an expression - - y := if x < 50 { - give x; - } else { - // TODO: Type cohesion is not yet finished - give 123; - }; // semicolon is required as it's an expression -*/ - - // This is allows for inline blocks of code and will be a useful feature to have when - // macros will be implemented into the language - - loops(); -} - -loops :: proc() { - // The C-style for loop - for i := 0; i < 123; i += 1 { - break; - } - for i := 0; i < 123; { - break; - } - for false { - break; - } - for { - break; - } - - for i in 0..123 { // 123 exclusive - } - - for i in 0..123-1 { // 122 inclusive - } - - for val, idx in 12..16 { - fmt.println(val, idx); - } - - primes := [?]int{2, 3, 5, 7, 11, 13, 17, 19}; - - for p in primes { - fmt.println(p); - } - - // Pointers to arrays, slices, or strings are allowed - for _ in &primes { - // ignore the value and just iterate across it - } - - - - name := "ä½ å„½ļ¼Œäø–ē•Œ"; - fmt.println(name); - for r in name { - #assert(type_of(r) == rune); - fmt.printf("%r\n", r); - } - - when false { - for i, size := 0; i < name.count; i += size { - r: rune; - r, size = utf8.decode_rune(name[i..]); - fmt.printf("%r\n", r); - } - } - - procedure_overloading(); -} - - -procedure_overloading :: proc() { - THINGF :: 14451.1; - THINGI :: 14451; - - foo :: proc() { - fmt.printf("Zero args\n"); - } - foo :: proc(i: int) { - fmt.printf("int arg, i=%d\n", i); - } - foo :: proc(f: f64) { - i := cast(int)f; - fmt.printf("f64 arg, f=%d\n", i); - } - - foo(); - foo(THINGF); - // foo(THINGI); // 14451 is just a number so it could go to either procedures - foo(cast(int)THINGI); - - - - - foo :: proc(x: ^i32) -> (int, int) { - fmt.println("^int"); - return 123, cast(int)(x^); - } - foo :: proc(x: rawptr) { - fmt.println("rawptr"); - } - - - a: i32 = 123; - b: f32; - c: rawptr; - fmt.println(foo(&a)); - foo(&b); - foo(c); - // foo(nil); // nil could go to numerous types thus the ambiguity - - f: proc(); - f = foo; // The correct `foo` to chosen - f(); - - - // See math.odin and atomic.odin for more examples -} diff --git a/misc/old_demos/demo006.odin b/misc/old_demos/demo006.odin deleted file mode 100644 index c2f64151b..000000000 --- a/misc/old_demos/demo006.odin +++ /dev/null @@ -1,310 +0,0 @@ -// import "core:atomic.odin"; -import "core:hash.odin"; -import "core:mem.odin"; -import "core:opengl.odin"; -import "core:strconv.odin"; -import "core:sync.odin"; -import win32 "core:sys/windows.odin"; - -import "core:fmt.odin"; -import "core:os.odin"; -import "core:math.odin"; - - -main :: proc() { -when true { -/* - Added: - * Unexported entities and fields using an underscore prefix - - See `sync.odin` and explain - - Removed: - * Maybe/option types - * Remove `type` keyword and other "reserved" keywords - * ..< and .. removed and replace with .. (half-closed range) - - Changed: - * `#assert` and `assert` return the value of the condition for semantic reasons - * thread_local -> #thread_local - * #include -> #load - * Files only get checked if they are actually used - * match x in y {} // For type match statements - * Version numbering now starts from 0.1.0 and uses the convention: - - major.minor.patch - * Core library additions to Windows specific stuff - */ - - { - Fruit :: enum { - APPLE, - BANANA, - COCONUT, - } - fmt.println(Fruit.names); - } - - { - A :: struct {x, y: f32}; - B :: struct #align 16 {x, y: f32}; - fmt.println("align_of(A) =", align_of(A)); - fmt.println("align_of(B) =", align_of(B)); - } - - { - // Removal of ..< and .. - for i in 0..16 { - } - // Is similar to - for i := 0; i < 16; i += 1 { - } - } - - { - thing: for i in 0..10 { - for j in i+1..10 { - if j == 2 { - fmt.println(i, j); - continue thing; - } - if j == 3 { - break thing; - } - } - } - - // Works with, `for`, `for in`, `match`, `match in` - // NOTE(bill): This solves most of the problems I need `goto` for - } - - { - t := type_info_of(int); - match i in t.variant { - case Type_Info_Integer, Type_Info_Float: - fmt.println("It's a number"); - } - - - x: any = 123; - foo: match i in x { - case int, f32: - fmt.println("It's an int or f32"); - break foo; - } - } - - { - cond := true; - x: int; - if cond { - x = 3; - } else { - x = 4; - } - - - // Ternary operator - y := cond ? 3 : 4; - - FOO :: true ? 123 : 432; // Constant ternary expression - fmt.println("Ternary values:", y, FOO); - } - - { - // Slices now store a capacity - buf: [256]u8; - s: []u8; - s = buf[..0]; // == buf[0..0]; - fmt.println("count =", len(s)); - fmt.println("capacity =", cap(s)); - append(&s, 1, 2, 3); - fmt.println(s); - - s = buf[1..2..3]; - fmt.println("count =", len(s)); - fmt.println("capacity =", cap(s)); - fmt.println(s); - - clear(&s); // Sets count to zero - } - - { - Foo :: struct { - x, y, z: f32, - ok: bool, - flags: u32, - } - foo_array: [256]Foo; - foo_as_bytes: []u8 = mem.slice_to_bytes(foo_array[..]); - // Useful for things like - // os.write(handle, foo_as_bytes); - - foo_slice := mem.slice_ptr(cast(^Foo)&foo_as_bytes[0], len(foo_as_bytes)/size_of(Foo), cap(foo_as_bytes)/size_of(Foo)); - // Question: Should there be a bytes_to_slice procedure or is it clearer to do this even if it is error prone? - // And if so what would the syntax be? - // slice_transmute([]Foo, foo_as_bytes); - } - - { - Vec3 :: [vector 3]f32; - - x := Vec3{1, 2, 3}; - y := Vec3{4, 5, 6}; - fmt.println(x < y); - fmt.println(x + y); - fmt.println(x - y); - fmt.println(x * y); - fmt.println(x / y); - - for i in x { - fmt.println(i); - } - - #assert(size_of([vector 7]bool) >= size_of([7]bool)); - #assert(size_of([vector 7]i32) >= size_of([7]i32)); - // align_of([vector 7]i32) != align_of([7]i32) // this may be the case - } - - { - // fmt.* changes - // bprint* returns `string` - - data: [256]u8; - str := fmt.bprintf(data[..], "Hellope %d %s %c", 123, "others", '!'); - fmt.println(str); - } - - { - x: [dynamic]f64; - reserve(&x, 16); - defer free(x); // `free` is overloaded for numerous types - // Number literals can have underscores in them for readability - append(&x, 2_000_000.500_000, 123, 5, 7); // variadic append - - for p, i in x { - if i > 0 { fmt.print(", "); } - fmt.print(p); - } - fmt.println(); - } - - { - // Dynamic array "literals" - x := [dynamic]f64{2_000_000.500_000, 3, 5, 7}; - defer free(x); - fmt.println(x); // fmt.print* supports printing of dynamic types - clear(&x); - fmt.println(x); - } - - { - m: map[f32]int; - reserve(&m, 16); - defer free(m); - - m[1.0] = 1278; - m[2.0] = 7643; - m[3.0] = 564; - _, ok := m[3.0]; - c := m[3.0]; - assert(ok && c == 564); - - fmt.print("map["); - i := 0; - for val, key in m { - if i > 0 { - fmt.print(", "); - } - fmt.printf("%v=%v", key, val); - i += 1; - } - fmt.println("]"); - } - { - m := map[string]u32{ - "a" = 56, - "b" = 13453, - "c" = 7654, - }; - defer free(m); - - c := m["c"]; - _, ok := m["c"]; - assert(ok && c == 7654); - fmt.println(m); - - delete(&m, "c"); // deletes entry with key "c" - _, found := m["c"]; - assert(!found); - - fmt.println(m); - clear(&m); - fmt.println(m); - - // NOTE: Fixed size maps are planned but we have not yet implemented - // them as we have had no need for them as of yet - } - - { - Vector3 :: struct{x, y, z: f32}; - Quaternion :: struct{x, y, z, w: f32}; - - // Variants - Frog :: struct { - ribbit_volume: f32, - jump_height: f32, - } - Door :: struct { - openness: f32, - } - Map :: struct { - width, height: f32, - place_positions: []Vector3, - place_names: []string, - } - - Entity :: struct { - // Common Fields - id: u64, - name: string, - using position: Vector3, - orientation: Quaternion, - flags: u32, - - variant: union { Frog, Door, Map }, - } - - entity: Entity; - entity.id = 1337; - // implicit conversion from variant to base type - entity.variant = Frog{ - ribbit_volume = 0.5, - jump_height = 2.1, - /*other data */ - }; - - entity.name = "Frank"; - entity.position = Vector3{1, 4, 9}; - - match e in entity.variant { - case Frog: - fmt.println("Ribbit"); - case Door: - fmt.println("Creak"); - case Map: - fmt.println("Rustle"); - case: - fmt.println("Just a normal entity"); - } - - if frog, ok := entity.variant.(Frog); ok { - fmt.printf("The frog jumps %f feet high at %v\n", frog.jump_height, entity.position); - } - - // Panics if not the correct type - frog: Frog; - frog = entity.variant.(Frog); - frog, _ = entity.variant.(Frog); // ignore error and force cast - } -} -} - diff --git a/misc/old_demos/demo007.odin b/misc/old_demos/demo007.odin deleted file mode 100644 index d19446ecb..000000000 --- a/misc/old_demos/demo007.odin +++ /dev/null @@ -1,570 +0,0 @@ -import "core:fmt.odin" -import "core:strconv.odin" -import "core:mem.odin" -import "core:bits.odin" -import "core:hash.odin" -import "core:math.odin" -import "core:os.odin" -import "core:raw.odin" -import "core:sort.odin" -import "core:strings.odin" -import "core:types.odin" -import "core:utf16.odin" -import "core:utf8.odin" - -when ODIN_OS == "windows" { - import "core:atomics.odin" - import "core:opengl.odin" - import "core:thread.odin" - import win32 "core:sys/windows.odin" -} - -general_stuff :: proc() { - { // `do` for inline statmes rather than block - foo :: proc() do fmt.println("Foo!"); - if false do foo(); - for false do foo(); - when false do foo(); - - if false do foo(); - else do foo(); - } - - { // Removal of `++` and `--` (again) - x: int; - x += 1; - x -= 1; - } - { // Casting syntaxes - i := i32(137); - ptr := &i; - - fp1 := (^f32)(ptr); - // ^f32(ptr) == ^(f32(ptr)) - fp2 := cast(^f32)ptr; - - f1 := (^f32)(ptr)^; - f2 := (cast(^f32)ptr)^; - - // Questions: Should there be two ways to do it? - } - - /* - * Remove *_val_of built-in procedures - * size_of, align_of, offset_of - * type_of, type_info_of - */ - - { // `expand_to_tuple` built-in procedure - Foo :: struct { - x: int, - b: bool, - } - f := Foo{137, true}; - x, b := expand_to_tuple(f); - fmt.println(f); - fmt.println(x, b); - fmt.println(expand_to_tuple(f)); - } - - { - // .. half-closed range - // .. open range - - for in 0..2 {} // 0, 1 - for in 0..2 {} // 0, 1, 2 - } -} - -default_struct_values :: proc() { - { - Vector3 :: struct { - x: f32, - y: f32, - z: f32, - } - v: Vector3; - fmt.println(v); - } - { - // Default values must be constants - Vector3 :: struct { - x: f32 = 1, - y: f32 = 4, - z: f32 = 9, - } - v: Vector3; - fmt.println(v); - - v = Vector3{}; - fmt.println(v); - - // Uses the same semantics as a default values in a procedure - v = Vector3{137}; - fmt.println(v); - - v = Vector3{z = 137}; - fmt.println(v); - } - - { - Vector3 :: struct { - x := 1.0, - y := 4.0, - z := 9.0, - } - stack_default: Vector3; - stack_literal := Vector3{}; - heap_one := new(Vector3); defer free(heap_one); - heap_two := new_clone(Vector3{}); defer free(heap_two); - - fmt.println("stack_default - ", stack_default); - fmt.println("stack_literal - ", stack_literal); - fmt.println("heap_one - ", heap_one^); - fmt.println("heap_two - ", heap_two^); - - - N :: 4; - stack_array: [N]Vector3; - heap_array := new([N]Vector3); defer free(heap_array); - heap_slice := make([]Vector3, N); defer free(heap_slice); - fmt.println("stack_array[1] - ", stack_array[1]); - fmt.println("heap_array[1] - ", heap_array[1]); - fmt.println("heap_slice[1] - ", heap_slice[1]); - } -} - - - - -union_type :: proc() { - { - val: union{int, bool}; - val = 137; - if i, ok := val.(int); ok { - fmt.println(i); - } - val = true; - fmt.println(val); - - val = nil; - - switch v in val { - case int: fmt.println("int", v); - case bool: fmt.println("bool", v); - case: fmt.println("nil"); - } - } - { - // There is a duality between `any` and `union` - // An `any` has a pointer to the data and allows for any type (open) - // A `union` has as binary blob to store the data and allows only certain types (closed) - // The following code is with `any` but has the same syntax - val: any; - val = 137; - if i, ok := val.(int); ok { - fmt.println(i); - } - val = true; - fmt.println(val); - - val = nil; - - switch v in val { - case int: fmt.println("int", v); - case bool: fmt.println("bool", v); - case: fmt.println("nil"); - } - } - - Vector3 :: struct {x, y, z: f32}; - Quaternion :: struct {x, y, z: f32, w: f32 = 1}; - - // More realistic examples - { - // NOTE(bill): For the above basic examples, you may not have any - // particular use for it. However, my main use for them is not for these - // simple cases. My main use is for hierarchical types. Many prefer - // subtyping, embedding the base data into the derived types. Below is - // an example of this for a basic game Entity. - - Entity :: struct { - id: u64, - name: string, - position: Vector3, - orientation: Quaternion, - - derived: any, - } - - Frog :: struct { - using entity: Entity, - jump_height: f32, - } - - Monster :: struct { - using entity: Entity, - is_robot: bool, - is_zombie: bool, - } - - // See `parametric_polymorphism` procedure for details - new_entity :: proc(T: type) -> ^Entity { - t := new(T); - t.derived = t^; - return t; - } - - entity := new_entity(Monster); - - switch e in entity.derived { - case Frog: - fmt.println("Ribbit"); - case Monster: - if e.is_robot do fmt.println("Robotic"); - if e.is_zombie do fmt.println("Grrrr!"); - } - } - - { - // NOTE(bill): A union can be used to achieve something similar. Instead - // of embedding the base data into the derived types, the derived data - // in embedded into the base type. Below is the same example of the - // basic game Entity but using an union. - - Entity :: struct { - id: u64, - name: string, - position: Vector3, - orientation: Quaternion, - - derived: union {Frog, Monster}, - } - - Frog :: struct { - using entity: ^Entity, - jump_height: f32, - } - - Monster :: struct { - using entity: ^Entity, - is_robot: bool, - is_zombie: bool, - } - - // See `parametric_polymorphism` procedure for details - new_entity :: proc(T: type) -> ^Entity { - t := new(Entity); - t.derived = T{entity = t}; - return t; - } - - entity := new_entity(Monster); - - switch e in entity.derived { - case Frog: - fmt.println("Ribbit"); - case Monster: - if e.is_robot do fmt.println("Robotic"); - if e.is_zombie do fmt.println("Grrrr!"); - } - - // NOTE(bill): As you can see, the usage code has not changed, only its - // memory layout. Both approaches have their own advantages but they can - // be used together to achieve different results. The subtyping approach - // can allow for a greater control of the memory layout and memory - // allocation, e.g. storing the derivatives together. However, this is - // also its disadvantage. You must either preallocate arrays for each - // derivative separation (which can be easily missed) or preallocate a - // bunch of "raw" memory; determining the maximum size of the derived - // types would require the aid of metaprogramming. Unions solve this - // particular problem as the data is stored with the base data. - // Therefore, it is possible to preallocate, e.g. [100]Entity. - - // It should be noted that the union approach can have the same memory - // layout as the any and with the same type restrictions by using a - // pointer type for the derivatives. - - /* - Entity :: struct { - .. - derived: union{^Frog, ^Monster}; - } - - Frog :: struct { - using entity: Entity; - .. - } - Monster :: struct { - using entity: Entity; - .. - - } - new_entity :: proc(T: type) -> ^Entity { - t := new(T); - t.derived = t; - return t; - } - */ - } -} - -parametric_polymorphism :: proc() { - print_value :: proc(value: $T) { - fmt.printf("print_value: %T %v\n", value, value); - } - - v1: int = 1; - v2: f32 = 2.1; - v3: f64 = 3.14; - v4: string = "message"; - - print_value(v1); - print_value(v2); - print_value(v3); - print_value(v4); - - fmt.println(); - - add :: proc(p, q: $T) -> T { - x: T = p + q; - return x; - } - - a := add(3, 4); - fmt.printf("a: %T = %v\n", a, a); - - b := add(3.2, 4.3); - fmt.printf("b: %T = %v\n", b, b); - - // This is how `new` is implemented - alloc_type :: proc(T: type) -> ^T { - t := cast(^T)alloc(size_of(T), align_of(T)); - t^ = T{}; // Use default initialization value - return t; - } - - copy_slice :: proc(dst, src: []$T) -> int { - n := min(len(dst), len(src)); - if n > 0 { - mem.copy(&dst[0], &src[0], n*size_of(T)); - } - return n; - } - - double_params :: proc(a: $A, b: $B) -> A { - return a + A(b); - } - - fmt.println(double_params(12, 1.345)); - - - - { // Polymorphic Types and Type Specialization - Table_Slot :: struct(Key, Value: type) { - occupied: bool, - hash: u32, - key: Key, - value: Value, - } - TABLE_SIZE_MIN :: 32; - Table :: struct(Key, Value: type) { - count: int, - allocator: Allocator, - slots: []Table_Slot(Key, Value), - } - - // Only allow types that are specializations of a (polymorphic) slice - make_slice :: proc(T: type/[]$E, len: int) -> T { - return make(T, len); - } - - - // Only allow types that are specializations of `Table` - allocate :: proc(table: ^$T/Table, capacity: int) { - c := context; - if table.allocator.procedure != nil do c.allocator = table.allocator; - - push_context c { - table.slots = make_slice(type_of(table.slots), max(capacity, TABLE_SIZE_MIN)); - } - } - - expand :: proc(table: ^$T/Table) { - c := context; - if table.allocator.procedure != nil do c.allocator = table.allocator; - - push_context c { - old_slots := table.slots; - - cap := max(2*cap(table.slots), TABLE_SIZE_MIN); - allocate(table, cap); - - for s in old_slots do if s.occupied { - put(table, s.key, s.value); - } - - free(old_slots); - } - } - - // Polymorphic determination of a polymorphic struct - // put :: proc(table: ^$T/Table, key: T.Key, value: T.Value) { - put :: proc(table: ^Table($Key, $Value), key: Key, value: Value) { - hash := get_hash(key); // Ad-hoc method which would fail in a different scope - index := find_index(table, key, hash); - if index < 0 { - if f64(table.count) >= 0.75*f64(cap(table.slots)) { - expand(table); - } - assert(table.count <= cap(table.slots)); - - hash := get_hash(key); - index = int(hash % u32(cap(table.slots))); - - for table.slots[index].occupied { - if index += 1; index >= cap(table.slots) { - index = 0; - } - } - - table.count += 1; - } - - slot := &table.slots[index]; - slot.occupied = true; - slot.hash = hash; - slot.key = key; - slot.value = value; - } - - - // find :: proc(table: ^$T/Table, key: T.Key) -> (T.Value, bool) { - find :: proc(table: ^Table($Key, $Value), key: Key) -> (Value, bool) { - hash := get_hash(key); - index := find_index(table, key, hash); - if index < 0 { - return Value{}, false; - } - return table.slots[index].value, true; - } - - find_index :: proc(table: ^Table($Key, $Value), key: Key, hash: u32) -> int { - if cap(table.slots) <= 0 do return -1; - - index := int(hash % u32(cap(table.slots))); - for table.slots[index].occupied { - if table.slots[index].hash == hash { - if table.slots[index].key == key { - return index; - } - } - - if index += 1; index >= cap(table.slots) { - index = 0; - } - } - - return -1; - } - - get_hash :: proc(s: string) -> u32 { // fnv32a - h: u32 = 0x811c9dc5; - for i in 0..len(s) { - h = (h ~ u32(s[i])) * 0x01000193; - } - return h; - } - - - table: Table(string, int); - - for i in 0..36 do put(&table, "Hellope", i); - for i in 0..42 do put(&table, "World!", i); - - found, _ := find(&table, "Hellope"); - fmt.printf("`found` is %v\n", found); - - found, _ = find(&table, "World!"); - fmt.printf("`found` is %v\n", found); - - // I would not personally design a hash table like this in production - // but this is a nice basic example - // A better approach would either use a `u64` or equivalent for the key - // and let the user specify the hashing function or make the user store - // the hashing procedure with the table - } -} - - - - -prefix_table := [?]string{ - "White", - "Red", - "Green", - "Blue", - "Octarine", - "Black", -}; - -threading_example :: proc() { - when ODIN_OS == "windows" { - unordered_remove :: proc(array: ^[]$T, index: int, loc := #caller_location) { - __bounds_check_error_loc(loc, index, len(array)); - array[index] = array[len(array)-1]; - pop(array); - } - ordered_remove :: proc(array: ^[]$T, index: int, loc := #caller_location) { - __bounds_check_error_loc(loc, index, len(array)); - copy(array[index..], array[index+1..]); - pop(array); - } - - worker_proc :: proc(t: ^thread.Thread) -> int { - for iteration in 1..5 { - fmt.printf("Thread %d is on iteration %d\n", t.user_index, iteration); - fmt.printf("`%s`: iteration %d\n", prefix_table[t.user_index], iteration); - // win32.sleep(1); - } - return 0; - } - - threads := make([]^thread.Thread, 0, len(prefix_table)); - defer free(threads); - - for i in 0..len(prefix_table) { - if t := thread.create(worker_proc); t != nil { - t.init_context = context; - t.use_init_context = true; - t.user_index = len(threads); - append(&threads, t); - thread.start(t); - } - } - - for len(threads) > 0 { - for i := 0; i < len(threads); /**/ { - if t := threads[i]; thread.is_done(t) { - fmt.printf("Thread %d is done\n", t.user_index); - thread.destroy(t); - - ordered_remove(&threads, i); - } else { - i += 1; - } - } - } - } -} - -main :: proc() { - when false { - fmt.println("\n# general_stuff"); general_stuff(); - fmt.println("\n# default_struct_values"); default_struct_values(); - fmt.println("\n# union_type"); union_type(); - fmt.println("\n# parametric_polymorphism"); parametric_polymorphism(); - fmt.println("\n# threading_example"); threading_example(); - } -} - diff --git a/misc/old_demos/demo008.odin b/misc/old_demos/demo008.odin deleted file mode 100644 index a122414e7..000000000 --- a/misc/old_demos/demo008.odin +++ /dev/null @@ -1,778 +0,0 @@ -import "core:fmt.odin" -import "core:strconv.odin" -import "core:mem.odin" -import "core:bits.odin" -import "core:hash.odin" -import "core:math.odin" -import "core:math/rand.odin" -import "core:os.odin" -import "core:raw.odin" -import "core:sort.odin" -import "core:strings.odin" -import "core:types.odin" -import "core:utf16.odin" -import "core:utf8.odin" - -// File scope `when` statements -when ODIN_OS == "windows" { - import "core:atomics.odin" - import "core:thread.odin" - import win32 "core:sys/windows.odin" -} - -@(link_name="general_stuff") -general_stuff :: proc() { - fmt.println("# general_stuff"); - { // `do` for inline statements rather than block - foo :: proc() do fmt.println("Foo!"); - if false do foo(); - for false do foo(); - when false do foo(); - - if false do foo(); - else do foo(); - } - - { // Removal of `++` and `--` (again) - x: int; - x += 1; - x -= 1; - } - { // Casting syntaxes - i := i32(137); - ptr := &i; - - _ = (^f32)(ptr); - // ^f32(ptr) == ^(f32(ptr)) - _ = cast(^f32)ptr; - - _ = (^f32)(ptr)^; - _ = (cast(^f32)ptr)^; - - // Questions: Should there be two ways to do it? - } - - /* - * Remove *_val_of built-in procedures - * size_of, align_of, offset_of - * type_of, type_info_of - */ - - { // `expand_to_tuple` built-in procedure - Foo :: struct { - x: int, - b: bool, - } - f := Foo{137, true}; - x, b := expand_to_tuple(f); - fmt.println(f); - fmt.println(x, b); - fmt.println(expand_to_tuple(f)); - } - - { - // .. half-closed range - // .. open range - - for in 0..2 {} // 0, 1 - for in 0..2 {} // 0, 1, 2 - } - - { // Multiple sized booleans - - x0: bool; // default - x1: b8 = true; - x2: b16 = false; - x3: b32 = true; - x4: b64 = false; - - fmt.printf("x1: %T = %v;\n", x1, x1); - fmt.printf("x2: %T = %v;\n", x2, x2); - fmt.printf("x3: %T = %v;\n", x3, x3); - fmt.printf("x4: %T = %v;\n", x4, x4); - - // Having specific sized booleans is very useful when dealing with foreign code - // and to enforce specific alignment for a boolean, especially within a struct - } - - { // `distinct` types - // Originally, all type declarations would create a distinct type unless #type_alias was present. - // Now the behaviour has been reversed. All type declarations create a type alias unless `distinct` is present. - // If the type expression is `struct`, `union`, `enum`, or `proc`, the types will always been distinct. - - Int32 :: i32; - #assert(Int32 == i32); - - My_Int32 :: distinct i32; - #assert(My_Int32 != i32); - - My_Struct :: struct{x: int}; - #assert(My_Struct != struct{x: int}); - } -} - -default_struct_values :: proc() { - fmt.println("# default_struct_values"); - { - Vector3 :: struct { - x: f32, - y: f32, - z: f32, - } - v: Vector3; - fmt.println(v); - } - { - // Default values must be constants - Vector3 :: struct { - x: f32 = 1, - y: f32 = 4, - z: f32 = 9, - } - v: Vector3; - fmt.println(v); - - v = Vector3{}; - fmt.println(v); - - // Uses the same semantics as a default values in a procedure - v = Vector3{137}; - fmt.println(v); - - v = Vector3{z = 137}; - fmt.println(v); - } - - { - Vector3 :: struct { - x := 1.0, - y := 4.0, - z := 9.0, - } - stack_default: Vector3; - stack_literal := Vector3{}; - heap_one := new(Vector3); defer free(heap_one); - heap_two := new_clone(Vector3{}); defer free(heap_two); - - fmt.println("stack_default - ", stack_default); - fmt.println("stack_literal - ", stack_literal); - fmt.println("heap_one - ", heap_one^); - fmt.println("heap_two - ", heap_two^); - - - N :: 4; - stack_array: [N]Vector3; - heap_array := new([N]Vector3); defer free(heap_array); - heap_slice := make([]Vector3, N); defer free(heap_slice); - fmt.println("stack_array[1] - ", stack_array[1]); - fmt.println("heap_array[1] - ", heap_array[1]); - fmt.println("heap_slice[1] - ", heap_slice[1]); - } -} - - - - -union_type :: proc() { - fmt.println("\n# union_type"); - { - val: union{int, bool}; - val = 137; - if i, ok := val.(int); ok { - fmt.println(i); - } - val = true; - fmt.println(val); - - val = nil; - - switch v in val { - case int: fmt.println("int", v); - case bool: fmt.println("bool", v); - case: fmt.println("nil"); - } - } - { - // There is a duality between `any` and `union` - // An `any` has a pointer to the data and allows for any type (open) - // A `union` has as binary blob to store the data and allows only certain types (closed) - // The following code is with `any` but has the same syntax - val: any; - val = 137; - if i, ok := val.(int); ok { - fmt.println(i); - } - val = true; - fmt.println(val); - - val = nil; - - switch v in val { - case int: fmt.println("int", v); - case bool: fmt.println("bool", v); - case: fmt.println("nil"); - } - } - - Vector3 :: struct {x, y, z: f32}; - Quaternion :: struct {x, y, z: f32, w: f32 = 1}; - - // More realistic examples - { - // NOTE(bill): For the above basic examples, you may not have any - // particular use for it. However, my main use for them is not for these - // simple cases. My main use is for hierarchical types. Many prefer - // subtyping, embedding the base data into the derived types. Below is - // an example of this for a basic game Entity. - - Entity :: struct { - id: u64, - name: string, - position: Vector3, - orientation: Quaternion, - - derived: any, - } - - Frog :: struct { - using entity: Entity, - jump_height: f32, - } - - Monster :: struct { - using entity: Entity, - is_robot: bool, - is_zombie: bool, - } - - // See `parametric_polymorphism` procedure for details - new_entity :: proc(T: type) -> ^Entity { - t := new(T); - t.derived = t^; - return t; - } - - entity := new_entity(Monster); - - switch e in entity.derived { - case Frog: - fmt.println("Ribbit"); - case Monster: - if e.is_robot do fmt.println("Robotic"); - if e.is_zombie do fmt.println("Grrrr!"); - } - } - - { - // NOTE(bill): A union can be used to achieve something similar. Instead - // of embedding the base data into the derived types, the derived data - // in embedded into the base type. Below is the same example of the - // basic game Entity but using an union. - - Entity :: struct { - id: u64, - name: string, - position: Vector3, - orientation: Quaternion, - - derived: union {Frog, Monster}, - } - - Frog :: struct { - using entity: ^Entity, - jump_height: f32, - } - - Monster :: struct { - using entity: ^Entity, - is_robot: bool, - is_zombie: bool, - } - - // See `parametric_polymorphism` procedure for details - new_entity :: proc(T: type) -> ^Entity { - t := new(Entity); - t.derived = T{entity = t}; - return t; - } - - entity := new_entity(Monster); - - switch e in entity.derived { - case Frog: - fmt.println("Ribbit"); - case Monster: - if e.is_robot do fmt.println("Robotic"); - if e.is_zombie do fmt.println("Grrrr!"); - } - - // NOTE(bill): As you can see, the usage code has not changed, only its - // memory layout. Both approaches have their own advantages but they can - // be used together to achieve different results. The subtyping approach - // can allow for a greater control of the memory layout and memory - // allocation, e.g. storing the derivatives together. However, this is - // also its disadvantage. You must either preallocate arrays for each - // derivative separation (which can be easily missed) or preallocate a - // bunch of "raw" memory; determining the maximum size of the derived - // types would require the aid of metaprogramming. Unions solve this - // particular problem as the data is stored with the base data. - // Therefore, it is possible to preallocate, e.g. [100]Entity. - - // It should be noted that the union approach can have the same memory - // layout as the any and with the same type restrictions by using a - // pointer type for the derivatives. - - /* - Entity :: struct { - .. - derived: union{^Frog, ^Monster}, - } - - Frog :: struct { - using entity: Entity, - .. - } - Monster :: struct { - using entity: Entity, - .. - - } - new_entity :: proc(T: type) -> ^Entity { - t := new(T); - t.derived = t; - return t; - } - */ - } -} - -parametric_polymorphism :: proc() { - fmt.println("# parametric_polymorphism"); - - print_value :: proc(value: $T) { - fmt.printf("print_value: %T %v\n", value, value); - } - - v1: int = 1; - v2: f32 = 2.1; - v3: f64 = 3.14; - v4: string = "message"; - - print_value(v1); - print_value(v2); - print_value(v3); - print_value(v4); - - fmt.println(); - - add :: proc(p, q: $T) -> T { - x: T = p + q; - return x; - } - - a := add(3, 4); - fmt.printf("a: %T = %v\n", a, a); - - b := add(3.2, 4.3); - fmt.printf("b: %T = %v\n", b, b); - - // This is how `new` is implemented - alloc_type :: proc(T: type) -> ^T { - t := cast(^T)alloc(size_of(T), align_of(T)); - t^ = T{}; // Use default initialization value - return t; - } - - copy_slice :: proc(dst, src: []$T) -> int { - return mem.copy(&dst[0], &src[0], n*size_of(T)); - } - - double_params :: proc(a: $A, b: $B) -> A { - return a + A(b); - } - - fmt.println(double_params(12, 1.345)); - - - - { // Polymorphic Types and Type Specialization - Table_Slot :: struct(Key, Value: type) { - occupied: bool, - hash: u32, - key: Key, - value: Value, - } - TABLE_SIZE_MIN :: 32; - Table :: struct(Key, Value: type) { - count: int, - allocator: Allocator, - slots: []Table_Slot(Key, Value), - } - - // Only allow types that are specializations of a (polymorphic) slice - make_slice :: proc(T: type/[]$E, len: int) -> T { - return make(T, len); - } - - - // Only allow types that are specializations of `Table` - allocate :: proc(table: ^$T/Table, capacity: int) { - c := context; - if table.allocator.procedure != nil do c.allocator = table.allocator; - - context <- c { - table.slots = make_slice(type_of(table.slots), max(capacity, TABLE_SIZE_MIN)); - } - } - - expand :: proc(table: ^$T/Table) { - c := context; - if table.allocator.procedure != nil do c.allocator = table.allocator; - - context <- c { - old_slots := table.slots; - - cap := max(2*len(table.slots), TABLE_SIZE_MIN); - allocate(table, cap); - - for s in old_slots do if s.occupied { - put(table, s.key, s.value); - } - - free(old_slots); - } - } - - // Polymorphic determination of a polymorphic struct - // put :: proc(table: ^$T/Table, key: T.Key, value: T.Value) { - put :: proc(table: ^Table($Key, $Value), key: Key, value: Value) { - hash := get_hash(key); // Ad-hoc method which would fail in a different scope - index := find_index(table, key, hash); - if index < 0 { - if f64(table.count) >= 0.75*f64(len(table.slots)) { - expand(table); - } - assert(table.count <= len(table.slots)); - - hash := get_hash(key); - index = int(hash % u32(len(table.slots))); - - for table.slots[index].occupied { - if index += 1; index >= len(table.slots) { - index = 0; - } - } - - table.count += 1; - } - - slot := &table.slots[index]; - slot.occupied = true; - slot.hash = hash; - slot.key = key; - slot.value = value; - } - - - // find :: proc(table: ^$T/Table, key: T.Key) -> (T.Value, bool) { - find :: proc(table: ^Table($Key, $Value), key: Key) -> (Value, bool) { - hash := get_hash(key); - index := find_index(table, key, hash); - if index < 0 { - return Value{}, false; - } - return table.slots[index].value, true; - } - - find_index :: proc(table: ^Table($Key, $Value), key: Key, hash: u32) -> int { - if len(table.slots) <= 0 do return -1; - - index := int(hash % u32(len(table.slots))); - for table.slots[index].occupied { - if table.slots[index].hash == hash { - if table.slots[index].key == key { - return index; - } - } - - if index += 1; index >= len(table.slots) { - index = 0; - } - } - - return -1; - } - - get_hash :: proc(s: string) -> u32 { // fnv32a - h: u32 = 0x811c9dc5; - for i in 0..len(s) { - h = (h ~ u32(s[i])) * 0x01000193; - } - return h; - } - - - table: Table(string, int); - - for i in 0..36 do put(&table, "Hellope", i); - for i in 0..42 do put(&table, "World!", i); - - found, _ := find(&table, "Hellope"); - fmt.printf("`found` is %v\n", found); - - found, _ = find(&table, "World!"); - fmt.printf("`found` is %v\n", found); - - // I would not personally design a hash table like this in production - // but this is a nice basic example - // A better approach would either use a `u64` or equivalent for the key - // and let the user specify the hashing function or make the user store - // the hashing procedure with the table - } -} - - - - -prefix_table := [?]string{ - "White", - "Red", - "Green", - "Blue", - "Octarine", - "Black", -}; - -threading_example :: proc() { - when ODIN_OS == "windows" { - fmt.println("# threading_example"); - - unordered_remove :: proc(array: ^[dynamic]$T, index: int, loc := #caller_location) { - __bounds_check_error_loc(loc, index, len(array)); - array[index] = array[len(array)-1]; - pop(array); - } - ordered_remove :: proc(array: ^[dynamic]$T, index: int, loc := #caller_location) { - __bounds_check_error_loc(loc, index, len(array)); - copy(array[index..], array[index+1..]); - pop(array); - } - - worker_proc :: proc(t: ^thread.Thread) -> int { - for iteration in 1..5 { - fmt.printf("Thread %d is on iteration %d\n", t.user_index, iteration); - fmt.printf("`%s`: iteration %d\n", prefix_table[t.user_index], iteration); - // win32.sleep(1); - } - return 0; - } - - threads := make([dynamic]^thread.Thread, 0, len(prefix_table)); - defer free(threads); - - for in prefix_table { - if t := thread.create(worker_proc); t != nil { - t.init_context = context; - t.use_init_context = true; - t.user_index = len(threads); - append(&threads, t); - thread.start(t); - } - } - - for len(threads) > 0 { - for i := 0; i < len(threads); /**/ { - if t := threads[i]; thread.is_done(t) { - fmt.printf("Thread %d is done\n", t.user_index); - thread.destroy(t); - - ordered_remove(&threads, i); - } else { - i += 1; - } - } - } - } -} - -array_programming :: proc() { - fmt.println("# array_programming"); - { - a := [3]f32{1, 2, 3}; - b := [3]f32{5, 6, 7}; - c := a * b; - d := a + b; - e := 1 + (c - d) / 2; - fmt.printf("%.1f\n", e); // [0.5, 3.0, 6.5] - } - - { - a := [3]f32{1, 2, 3}; - b := swizzle(a, 2, 1, 0); - assert(b == [3]f32{3, 2, 1}); - - c := swizzle(a, 0, 0); - assert(c == [2]f32{1, 1}); - assert(c == 1); - } - - { - Vector3 :: distinct [3]f32; - a := Vector3{1, 2, 3}; - b := Vector3{5, 6, 7}; - c := (a * b)/2 + 1; - d := c.x + c.y + c.z; - fmt.printf("%.1f\n", d); // 22.0 - - cross :: proc(a, b: Vector3) -> Vector3 { - i := swizzle(a, 1, 2, 0) * swizzle(b, 2, 0, 1); - j := swizzle(a, 2, 0, 1) * swizzle(b, 1, 2, 0); - return i - j; - } - - blah :: proc(a: Vector3) -> f32 { - return a.x + a.y + a.z; - } - - x := cross(a, b); - fmt.println(x); - fmt.println(blah(x)); - } -} - - -using println in import "core:fmt.odin" - -using_in :: proc() { - fmt.println("# using in"); - using print in fmt; - - println("Hellope1"); - print("Hellope2\n"); - - Foo :: struct { - x, y: int, - b: bool, - } - f: Foo; - f.x, f.y = 123, 321; - println(f); - using x, y in f; - x, y = 456, 654; - println(f); -} - -named_proc_return_parameters :: proc() { - fmt.println("# named proc return parameters"); - - foo0 :: proc() -> int { - return 123; - } - foo1 :: proc() -> (a: int) { - a = 123; - return; - } - foo2 :: proc() -> (a, b: int) { - // Named return values act like variables within the scope - a = 321; - b = 567; - return b, a; - } - fmt.println("foo0 =", foo0()); // 123 - fmt.println("foo1 =", foo1()); // 123 - fmt.println("foo2 =", foo2()); // 567 321 -} - - -enum_export :: proc() { - fmt.println("# enum #export"); - - Foo :: enum #export {A, B, C}; - - f0 := A; - f1 := B; - f2 := C; - fmt.println(f0, f1, f2); -} - -explicit_procedure_overloading :: proc() { - fmt.println("# explicit procedure overloading"); - - add_ints :: proc(a, b: int) -> int { - x := a + b; - fmt.println("add_ints", x); - return x; - } - add_floats :: proc(a, b: f32) -> f32 { - x := a + b; - fmt.println("add_floats", x); - return x; - } - add_numbers :: proc(a: int, b: f32, c: u8) -> int { - x := int(a) + int(b) + int(c); - fmt.println("add_numbers", x); - return x; - } - - add :: proc[add_ints, add_floats, add_numbers]; - - add(int(1), int(2)); - add(f32(1), f32(2)); - add(int(1), f32(2), u8(3)); - - add(1, 2); // untyped ints coerce to int tighter than f32 - add(1.0, 2.0); // untyped floats coerce to f32 tighter than int - add(1, 2, 3); // three parameters - - // Ambiguous answers - // add(1.0, 2); - // add(1, 2.0); -} - -complete_switch :: proc() { - fmt.println("# complete_switch"); - { // enum - Foo :: enum #export { - A, - B, - C, - D, - } - - b := Foo.B; - f := Foo.A; - #complete switch f { - case A: fmt.println("A"); - case B: fmt.println("B"); - case C: fmt.println("C"); - case D: fmt.println("D"); - case: fmt.println("?"); - } - } - { // union - Foo :: union {int, bool}; - f: Foo = 123; - #complete switch in f { - case int: fmt.println("int"); - case bool: fmt.println("bool"); - case: - } - } -} - - -main :: proc() { - when true { - general_stuff(); - default_struct_values(); - union_type(); - parametric_polymorphism(); - threading_example(); - array_programming(); - using_in(); - named_proc_return_parameters(); - enum_export(); - explicit_procedure_overloading(); - complete_switch(); - } -} diff --git a/misc/old_demos/old_runtime.odin b/misc/old_demos/old_runtime.odin deleted file mode 100644 index e605e7820..000000000 --- a/misc/old_demos/old_runtime.odin +++ /dev/null @@ -1,412 +0,0 @@ -#include "win32.odin" - -assume :: proc(cond: bool) #foreign "llvm.assume" - -__debug_trap :: proc() #foreign "llvm.debugtrap" -__trap :: proc() #foreign "llvm.trap" -read_cycle_counter :: proc() -> u64 #foreign "llvm.readcyclecounter" - -bit_reverse16 :: proc(b: u16) -> u16 #foreign "llvm.bitreverse.i16" -bit_reverse32 :: proc(b: u32) -> u32 #foreign "llvm.bitreverse.i32" -bit_reverse64 :: proc(b: u64) -> u64 #foreign "llvm.bitreverse.i64" - -byte_swap16 :: proc(b: u16) -> u16 #foreign "llvm.bswap.i16" -byte_swap32 :: proc(b: u32) -> u32 #foreign "llvm.bswap.i32" -byte_swap64 :: proc(b: u64) -> u64 #foreign "llvm.bswap.i64" - -fmuladd_f32 :: proc(a, b, c: f32) -> f32 #foreign "llvm.fmuladd.f32" -fmuladd_f64 :: proc(a, b, c: f64) -> f64 #foreign "llvm.fmuladd.f64" - -// TODO(bill): make custom heap procedures -heap_alloc :: proc(len: int) -> rawptr #foreign "malloc" -heap_dealloc :: proc(ptr: rawptr) #foreign "free" - -memory_zero :: proc(data: rawptr, len: int) { - d := slice_ptr(data as ^byte, len) - for i := 0; i < len; i++ { - d[i] = 0 - } -} - -memory_compare :: proc(dst, src: rawptr, len: int) -> int { - s1, s2: ^byte = dst, src - for i := 0; i < len; i++ { - a := ptr_offset(s1, i)^ - b := ptr_offset(s2, i)^ - if a != b { - return (a - b) as int - } - } - return 0 -} - -memory_copy :: proc(dst, src: rawptr, n: int) #inline { - if dst == src { - return - } - - v128b :: type {4}u32 - #assert(align_of(v128b) == 16) - - d, s: ^byte = dst, src - - for ; s as uint % 16 != 0 && n != 0; n-- { - d^ = s^ - d, s = ptr_offset(d, 1), ptr_offset(s, 1) - } - - if d as uint % 16 == 0 { - for ; n >= 16; d, s, n = ptr_offset(d, 16), ptr_offset(s, 16), n-16 { - (d as ^v128b)^ = (s as ^v128b)^ - } - - if n&8 != 0 { - (d as ^u64)^ = (s as ^u64)^ - d, s = ptr_offset(d, 8), ptr_offset(s, 8) - } - if n&4 != 0 { - (d as ^u32)^ = (s as ^u32)^; - d, s = ptr_offset(d, 4), ptr_offset(s, 4) - } - if n&2 != 0 { - (d as ^u16)^ = (s as ^u16)^ - d, s = ptr_offset(d, 2), ptr_offset(s, 2) - } - if n&1 != 0 { - d^ = s^ - d, s = ptr_offset(d, 1), ptr_offset(s, 1) - } - return; - } - - // IMPORTANT NOTE(bill): Little endian only - LS :: proc(a, b: u32) -> u32 #inline { return a << b } - RS :: proc(a, b: u32) -> u32 #inline { return a >> b } - /* NOTE(bill): Big endian version - LS :: proc(a, b: u32) -> u32 #inline { return a >> b; } - RS :: proc(a, b: u32) -> u32 #inline { return a << b; } - */ - - w, x: u32 - - if d as uint % 4 == 1 { - w = (s as ^u32)^ - d^ = s^; d = ptr_offset(d, 1); s = ptr_offset(s, 1) - d^ = s^; d = ptr_offset(d, 1); s = ptr_offset(s, 1) - d^ = s^; d = ptr_offset(d, 1); s = ptr_offset(s, 1) - n -= 3 - - for n > 16 { - d32 := d as ^u32 - s32 := ptr_offset(s, 1) as ^u32 - x = s32^; d32^ = LS(w, 24) | RS(x, 8) - d32, s32 = ptr_offset(d32, 1), ptr_offset(s32, 1) - w = s32^; d32^ = LS(x, 24) | RS(w, 8) - d32, s32 = ptr_offset(d32, 1), ptr_offset(s32, 1) - x = s32^; d32^ = LS(w, 24) | RS(x, 8) - d32, s32 = ptr_offset(d32, 1), ptr_offset(s32, 1) - w = s32^; d32^ = LS(x, 24) | RS(w, 8) - d32, s32 = ptr_offset(d32, 1), ptr_offset(s32, 1) - - d, s, n = ptr_offset(d, 16), ptr_offset(s, 16), n-16 - } - - } else if d as uint % 4 == 2 { - w = (s as ^u32)^ - d^ = s^; d = ptr_offset(d, 1); s = ptr_offset(s, 1) - d^ = s^; d = ptr_offset(d, 1); s = ptr_offset(s, 1) - n -= 2 - - for n > 17 { - d32 := d as ^u32 - s32 := ptr_offset(s, 2) as ^u32 - x = s32^; d32^ = LS(w, 16) | RS(x, 16) - d32, s32 = ptr_offset(d32, 1), ptr_offset(s32, 1) - w = s32^; d32^ = LS(x, 16) | RS(w, 16) - d32, s32 = ptr_offset(d32, 1), ptr_offset(s32, 1) - x = s32^; d32^ = LS(w, 16) | RS(x, 16) - d32, s32 = ptr_offset(d32, 1), ptr_offset(s32, 1) - w = s32^; d32^ = LS(x, 16) | RS(w, 16) - d32, s32 = ptr_offset(d32, 1), ptr_offset(s32, 1) - - d, s, n = ptr_offset(d, 16), ptr_offset(s, 16), n-16 - } - - } else if d as uint % 4 == 3 { - w = (s as ^u32)^ - d^ = s^ - n -= 1 - - for n > 18 { - d32 := d as ^u32 - s32 := ptr_offset(s, 3) as ^u32 - x = s32^; d32^ = LS(w, 8) | RS(x, 24) - d32, s32 = ptr_offset(d32, 1), ptr_offset(s32, 1) - w = s32^; d32^ = LS(x, 8) | RS(w, 24) - d32, s32 = ptr_offset(d32, 1), ptr_offset(s32, 1) - x = s32^; d32^ = LS(w, 8) | RS(x, 24) - d32, s32 = ptr_offset(d32, 1), ptr_offset(s32, 1) - w = s32^; d32^ = LS(x, 8) | RS(w, 24) - d32, s32 = ptr_offset(d32, 1), ptr_offset(s32, 1) - - d, s, n = ptr_offset(d, 16), ptr_offset(s, 16), n-16 - } - } - - if n&16 != 0 { - (d as ^v128b)^ = (s as ^v128b)^ - d, s = ptr_offset(d, 16), ptr_offset(s, 16) - } - if n&8 != 0 { - (d as ^u64)^ = (s as ^u64)^ - d, s = ptr_offset(d, 8), ptr_offset(s, 8) - } - if n&4 != 0 { - (d as ^u32)^ = (s as ^u32)^; - d, s = ptr_offset(d, 4), ptr_offset(s, 4) - } - if n&2 != 0 { - (d as ^u16)^ = (s as ^u16)^ - d, s = ptr_offset(d, 2), ptr_offset(s, 2) - } - if n&1 != 0 { - d^ = s^ - } -} - -memory_move :: proc(dst, src: rawptr, n: int) #inline { - d, s: ^byte = dst, src - if d == s { - return - } - if d >= ptr_offset(s, n) || ptr_offset(d, n) <= s { - memory_copy(d, s, n) - return - } - - // TODO(bill): Vectorize the shit out of this - if d < s { - if s as int % size_of(int) == d as int % size_of(int) { - for d as int % size_of(int) != 0 { - if n == 0 { - return - } - n-- - d^ = s^ - d, s = ptr_offset(d, 1), ptr_offset(s, 1) - } - di, si := d as ^int, s as ^int - for n >= size_of(int) { - di^ = si^ - di, si = ptr_offset(di, 1), ptr_offset(si, 1) - n -= size_of(int) - } - } - for ; n > 0; n-- { - d^ = s^ - d, s = ptr_offset(d, 1), ptr_offset(s, 1) - } - } else { - if s as int % size_of(int) == d as int % size_of(int) { - for ptr_offset(d, n) as int % size_of(int) != 0 { - if n == 0 { - return - } - n-- - d^ = s^ - d, s = ptr_offset(d, 1), ptr_offset(s, 1) - } - for n >= size_of(int) { - n -= size_of(int) - di := ptr_offset(d, n) as ^int - si := ptr_offset(s, n) as ^int - di^ = si^ - } - for ; n > 0; n-- { - d^ = s^ - d, s = ptr_offset(d, 1), ptr_offset(s, 1) - } - } - for n > 0 { - n-- - dn := ptr_offset(d, n) - sn := ptr_offset(s, n) - dn^ = sn^ - } - } -} - -__string_eq :: proc(a, b: string) -> bool { - if len(a) != len(b) { - return false - } - if ^a[0] == ^b[0] { - return true - } - return memory_compare(^a[0], ^b[0], len(a)) == 0 -} - -__string_cmp :: proc(a, b : string) -> int { - min_len := len(a) - if len(b) < min_len { - min_len = len(b) - } - for i := 0; i < min_len; i++ { - x := a[i] - y := b[i] - if x < y { - return -1 - } else if x > y { - return +1 - } - } - - if len(a) < len(b) { - return -1 - } else if len(a) > len(b) { - return +1 - } - return 0 -} - -__string_ne :: proc(a, b : string) -> bool #inline { return !__string_eq(a, b) } -__string_lt :: proc(a, b : string) -> bool #inline { return __string_cmp(a, b) < 0 } -__string_gt :: proc(a, b : string) -> bool #inline { return __string_cmp(a, b) > 0 } -__string_le :: proc(a, b : string) -> bool #inline { return __string_cmp(a, b) <= 0 } -__string_ge :: proc(a, b : string) -> bool #inline { return __string_cmp(a, b) >= 0 } - - - - -Allocation_Mode :: type enum { - ALLOC, - DEALLOC, - DEALLOC_ALL, - RESIZE, -} - - - -Allocator_Proc :: type proc(allocator_data: rawptr, mode: Allocation_Mode, - size, alignment: int, - old_memory: rawptr, old_size: int, flags: u64) -> rawptr - -Allocator :: type struct { - procedure: Allocator_Proc; - data: rawptr -} - - -Context :: type struct { - thread_ptr: rawptr - - user_data: rawptr - user_index: int - - allocator: Allocator -} - -#thread_local context: Context - -DEFAULT_ALIGNMENT :: 2*size_of(int) - - -__check_context :: proc() { - if context.allocator.procedure == null { - context.allocator = __default_allocator() - } - if context.thread_ptr == null { - // TODO(bill): - // context.thread_ptr = current_thread_pointer() - } -} - - -alloc :: proc(size: int) -> rawptr #inline { return alloc_align(size, DEFAULT_ALIGNMENT) } - -alloc_align :: proc(size, alignment: int) -> rawptr #inline { - __check_context() - a := context.allocator - return a.procedure(a.data, Allocation_Mode.ALLOC, size, alignment, null, 0, 0) -} - -dealloc :: proc(ptr: rawptr) #inline { - __check_context() - a := context.allocator - _ = a.procedure(a.data, Allocation_Mode.DEALLOC, 0, 0, ptr, 0, 0) -} -dealloc_all :: proc(ptr: rawptr) #inline { - __check_context() - a := context.allocator - _ = a.procedure(a.data, Allocation_Mode.DEALLOC_ALL, 0, 0, ptr, 0, 0) -} - - -resize :: proc(ptr: rawptr, old_size, new_size: int) -> rawptr #inline { return resize_align(ptr, old_size, new_size, DEFAULT_ALIGNMENT) } -resize_align :: proc(ptr: rawptr, old_size, new_size, alignment: int) -> rawptr #inline { - __check_context() - a := context.allocator - return a.procedure(a.data, Allocation_Mode.RESIZE, new_size, alignment, ptr, old_size, 0) -} - - - -default_resize_align :: proc(old_memory: rawptr, old_size, new_size, alignment: int) -> rawptr { - if old_memory == null { - return alloc_align(new_size, alignment) - } - - if new_size == 0 { - dealloc(old_memory) - return null - } - - if new_size == old_size { - return old_memory - } - - new_memory := alloc_align(new_size, alignment) - if new_memory == null { - return null - } - - memory_copy(new_memory, old_memory, min(old_size, new_size)); - dealloc(old_memory) - return new_memory -} - - -__default_allocator_proc :: proc(allocator_data: rawptr, mode: Allocation_Mode, - size, alignment: int, - old_memory: rawptr, old_size: int, flags: u64) -> rawptr { - using Allocation_Mode - match mode { - case ALLOC: - return heap_alloc(size) - case RESIZE: - return default_resize_align(old_memory, old_size, size, alignment) - case DEALLOC: - heap_dealloc(old_memory) - case DEALLOC_ALL: - // NOTE(bill): Does nothing - } - - return null -} - -__default_allocator :: proc() -> Allocator { - return Allocator{ - __default_allocator_proc, - null, - } -} - - - - -__assert :: proc(msg: string) { - file_write(file_get_standard(File_Standard.ERROR), msg as []byte) - // TODO(bill): Which is better? - // __trap() - __debug_trap() -} diff --git a/misc/old_stuff/demo_backup.odin b/misc/old_stuff/demo_backup.odin deleted file mode 100644 index b8bbbb02d..000000000 --- a/misc/old_stuff/demo_backup.odin +++ /dev/null @@ -1,430 +0,0 @@ -import ( - "fmt.odin"; - "atomics.odin"; - "bits.odin"; - "decimal.odin"; - "hash.odin"; - "math.odin"; - "mem.odin"; - "opengl.odin"; - "os.odin"; - "raw.odin"; - "strconv.odin"; - "strings.odin"; - "sync.odin"; - "sort.odin"; - "types.odin"; - "utf8.odin"; - "utf16.odin"; -/* -*/ -) - - -general_stuff :: proc() { - // Complex numbers - a := 3 + 4i; - b: complex64 = 3 + 4i; - c: complex128 = 3 + 4i; - d := complex(2, 3); - - e := a / conj(a); - fmt.println("(3+4i)/(3-4i) =", e); - fmt.println(real(e), "+", imag(e), "i"); - - - // C-style variadic procedures - foreign __llvm_core { - // The variadic part allows for extra type checking too which C does not provide - c_printf :: proc(fmt: ^u8, #c_vararg args: ..any) -> i32 #link_name "printf" ---; - } - str := "%d\n\x00"; - // c_printf(&str[0], i32(789456123)); - - - Foo :: struct { - x: int; - y: f32; - z: string; - } - foo := Foo{123, 0.513, "A string"}; - x, y, z := expand_to_tuple(foo); - fmt.println(x, y, z); - #assert(type_of(x) == int); - #assert(type_of(y) == f32); - #assert(type_of(z) == string); - - - // By default, all variables are zeroed - // This can be overridden with the "uninitialized value" - // This is similar to `nil` but applied to everything - undef_int: int = ---; - - - // Context system is now implemented using Implicit Parameter Passing (IPP) - // The previous implementation was Thread Local Storage (TLS) - // IPP has the advantage that it works on systems without TLS and that you can - // link the context to the stack frame and thus look at previous contexts - // - // It does mean that a pointer is implicitly passed procedures with the default - // Odin calling convention (#cc_odin) - // This can be overridden with something like #cc_contextless or #cc_c if performance - // is worried about - -} - -foreign_blocks :: proc() { - // See sys/windows.odin -} - -default_arguments :: proc() { - hello :: proc(a: int = 9, b: int = 9) do fmt.printf("a is %d; b is %d\n", a, b); - fmt.println("\nTesting default arguments:"); - hello(1, 2); - hello(1); - hello(); -} - -named_arguments :: proc() { - Colour :: enum { - Red, - Orange, - Yellow, - Green, - Blue, - Octarine, - }; - using Colour; - - make_character :: proc(name, catch_phrase: string, favourite_colour, least_favourite_colour: Colour) { - fmt.println(); - fmt.printf("My name is %v and I like %v. %v\n", name, favourite_colour, catch_phrase); - } - - make_character("Frank", "Ā”Ay, caramba!", Blue, Green); - - - // As the procedures have more and more parameters, it is very easy - // to get many of the arguments in the wrong order especialy if the - // types are the same - make_character("Ā”Ay, caramba!", "Frank", Green, Blue); - - // Named arguments help to disambiguate this problem - make_character(catch_phrase = "Ā”Ay, caramba!", name = "Frank", - least_favourite_colour = Green, favourite_colour = Blue); - - - // The named arguments can be specifed in any order. - make_character(favourite_colour = Octarine, catch_phrase = "U wot m8!", - least_favourite_colour = Green, name = "Dennis"); - - - // NOTE: You cannot mix named arguments with normal values - /* - make_character("Dennis", - favourite_colour = Octarine, catch_phrase = "U wot m8!", - least_favourite_colour = Green); - */ - - - // Named arguments can also aid with default arguments - numerous_things :: proc(s: string, a := 1, b := 2, c := 3.14, - d := "The Best String!", e := false, f := 10.3/3.1, g := false) { - g_str := g ? "true" : "false"; - fmt.printf("How many?! %s: %v\n", s, g_str); - } - - numerous_things("First"); - numerous_things(s = "Second", g = true); - - - // Default values can be placed anywhere, not just at the end like in other languages - weird :: proc(pre: string, mid: int = 0, post: string) { - fmt.println(pre, mid, post); - } - - weird("How many things", 42, "huh?"); - weird(pre = "Prefix", post = "Pat"); - -} - - -default_return_values :: proc() { - foo :: proc(x: int) -> (first: string = "Hellope", second := "world!") { - match x { - case 0: return; - case 1: return "Goodbye"; - case 2: return "Goodbye", "cruel world.."; - case 3: return second = "cruel world..", first = "Goodbye"; - } - - return second = "my old friend."; - } - - fmt.printf("%s %s\n", foo(0)); - fmt.printf("%s %s\n", foo(1)); - fmt.printf("%s %s\n", foo(2)); - fmt.printf("%s %s\n", foo(3)); - fmt.printf("%s %s\n", foo(4)); - fmt.println(); - - - // A more "real" example - Error :: enum { - None, - WhyTheNumberThree, - TenIsTooBig, - }; - - Entity :: struct { - name: string; - id: u32; - } - - some_thing :: proc(input: int) -> (result: ^Entity = nil, err := Error.None) { - match { - case input == 3: return err = Error.WhyTheNumberThree; - case input >= 10: return err = Error.TenIsTooBig; - } - - e := new(Entity); - e.id = u32(input); - - return result = e; - } -} - -call_location :: proc() { - amazing :: proc(n: int, using loc := #caller_location) { - fmt.printf("%s(%d:%d) just asked to do something amazing.\n", - fully_pathed_filename, line, column); - fmt.printf("Normal -> %d\n", n); - fmt.printf("Amazing -> %d\n", n+1); - fmt.println(); - } - - loc := #location(main); - fmt.println("`main` is located at", loc); - - fmt.println("This line is located at", #location()); - fmt.println(); - - amazing(3); - amazing(4, #location(call_location)); - - // See _preload.odin for the implementations of `assert` and `panic` - -} - - -explicit_parametric_polymorphic_procedures :: proc() { - // This is how `new` is actually implemented, see _preload.odin - alloc_type :: proc(T: type) -> ^T do return cast(^T)alloc(size_of(T), align_of(T)); - - int_ptr := alloc_type(int); - defer free(int_ptr); - int_ptr^ = 137; - fmt.println(int_ptr, int_ptr^); - - // Named arguments work too! - another_ptr := alloc_type(T = f32); - defer free(another_ptr); - - - add :: proc(T: type, args: ..T) -> T { - res: T; - for arg in args do res += arg; - return res; - } - - fmt.println("add =", add(int, 1, 2, 3, 4, 5, 6)); - - swap :: proc(T: type, a, b: ^T) { - tmp := a^; - a^ = b^; - b^ = tmp; - } - - a, b: int = 3, 4; - fmt.println("Pre-swap:", a, b); - swap(int, &a, &b); - fmt.println("Post-swap:", a, b); - a, b = b, a; // Or use this syntax for this silly example case - - - Vector2 :: struct {x, y: f32;}; - { - // A more complicated example using subtyping - // Something like this could be used in a game - - Entity :: struct { - using position: Vector2; - flags: u64; - id: u64; - derived: any; - } - - Rock :: struct { - using entity: Entity; - heavy: bool; - } - Door :: struct { - using entity: Entity; - open: bool; - } - Monster :: struct { - using entity: Entity; - is_robot: bool; - is_zombie: bool; - } - - new_entity :: proc(T: type, x, y: f32) -> ^T { - result := new(T); - result.derived = result^; - result.x = x; - result.y = y; - - return result; - } - - entities: [dynamic]^Entity; - - rock := new_entity(Rock, 3, 5); - - // Named arguments work too! - door := new_entity(T = Door, x = 3, y = 6); - - // And named arguments can be any order - monster := new_entity( - y = 1, - x = 2, - T = Monster, - ); - - append(&entities, rock, door, monster); - - fmt.println("Subtyping"); - for entity in entities { - match e in entity.derived { - case Rock: fmt.println("Rock", e.x, e.y); - case Door: fmt.println("Door", e.x, e.y); - case Monster: fmt.println("Monster", e.x, e.y); - } - } - } - { - Entity :: struct { - using position: Vector2; - flags: u64; - id: u64; - variant: union { Rock, Door, Monster }; - } - - Rock :: struct { - using entity: ^Entity; - heavy: bool; - } - Door :: struct { - using entity: ^Entity; - open: bool; - } - Monster :: struct { - using entity: ^Entity; - is_robot: bool; - is_zombie: bool; - } - - new_entity :: proc(T: type, x, y: f32) -> ^T { - result := new(Entity); - result.variant = T{entity = result}; - result.x = x; - result.y = y; - - return cast(^T)&result.variant; - } - - entities: [dynamic]^Entity; - - rock := new_entity(Rock, 3, 5); - - // Named arguments work too! - door := new_entity(T = Door, x = 3, y = 6); - - // And named arguments can be any order - monster := new_entity( - y = 1, - x = 2, - T = Monster, - ); - - append(&entities, rock, door, monster); - - fmt.println("Union"); - for entity in entities { - match e in entity.variant { - case Rock: fmt.println("Rock", e.x, e.y); - case Door: fmt.println("Door", e.x, e.y); - case Monster: fmt.println("Monster", e.x, e.y); - } - } - } -} - - -implicit_polymorphic_assignment :: proc() { - yep :: proc(p: proc(x: int)) { - p(123); - } - - frank :: proc(x: $T) do fmt.println("frank ->", x); - tim :: proc(x, y: $T) do fmt.println("tim ->", x, y); - yep(frank); - // yep(tim); -} - - - - -main :: proc() { -/* - foo :: proc(x: i64, y: f32) do fmt.println("#1", x, y); - foo :: proc(x: type, y: f32) do fmt.println("#2", type_info(x), y); - foo :: proc(x: type) do fmt.println("#3", type_info(x)); - - f :: foo; - - f(y = 3785.1546, x = 123); - f(x = int, y = 897.513); - f(x = f32); - - general_stuff(); - foreign_blocks(); - default_arguments(); - named_arguments(); - default_return_values(); - call_location(); - explicit_parametric_polymorphic_procedures(); - implicit_polymorphic_assignment(); - - - // Command line argument(s)! - // -opt=0,1,2,3 -*/ -/* - program := "+ + * - /"; - accumulator := 0; - - for token in program { - match token { - case '+': accumulator += 1; - case '-': accumulator -= 1; - case '*': accumulator *= 2; - case '/': accumulator /= 2; - case: // Ignore everything else - } - } - - fmt.printf("The program \"%s\" calculates the value %d\n", - program, accumulator); -*/ -} diff --git a/misc/remove_libraries_for_other_platforms.sh b/misc/remove_libraries_for_other_platforms.sh new file mode 100755 index 000000000..db2e33ccd --- /dev/null +++ b/misc/remove_libraries_for_other_platforms.sh @@ -0,0 +1,56 @@ +#!/bin/bash +OS=$(uname) + +panic() { + printf "%s\n" "$1" + exit 1 +} + +assert_vendor() { + if [ $(basename $(pwd)) != 'vendor' ]; then + panic "Not in vendor directory!" + fi +} + +remove_windows_libraries() { + find . -type f -name '*.dll' | xargs rm -f + find . -type f -name '*.lib' | xargs rm -f + find . -type d -name 'windows' | xargs rm -rf +} + +remove_macos_libraries() { + find . -type f -name '*.dylib' | xargs rm -f + find . -type d -name '*macos*' | xargs rm -rf +} + +remove_linux_libraries() { + find . -type f -name '*.so' | xargs rm -f + find . -type d -name 'linux' | xargs rm -rf +} + +case $OS in + Linux) + assert_vendor + remove_windows_libraries + remove_macos_libraries + ;; + Darwin) + assert_vendor + remove_windows_libraries + remove_linux_libraries + ;; + OpenBSD) + assert_vendor + remove_windows_libraries + remove_macos_libraries + remove_linux_libraries + ;; + FreeBSD) + assert_vendor + remove_windows_libraries + remove_macos_libraries + remove_linux_libraries + ;; +*) + panic "Platform unsupported!" +esac diff --git a/misc/shell.bat b/misc/shell.bat index 60f603bc1..bfb444396 100644 --- a/misc/shell.bat +++ b/misc/shell.bat @@ -7,5 +7,7 @@ rem call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxil rem call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 1> NUL set _NO_DEBUG_HEAP=1 +set ODIN_IGNORE_MSVC_CHECK=1 + rem set path=w:\Odin\misc;%path% cls diff --git a/src/array.cpp b/src/array.cpp index d08bd647f..d8e25d25d 100644 --- a/src/array.cpp +++ b/src/array.cpp @@ -10,45 +10,45 @@ struct Array { T &operator[](isize index) { #if !defined(NO_ARRAY_BOUNDS_CHECK) - GB_ASSERT_MSG(0 <= index && index < count, "Index %td is out of bounds ranges 0..<%td", index, count); + GB_ASSERT_MSG(cast(usize)index < cast(usize)count, "Index %td is out of bounds ranges 0..<%td", index, count); #endif return data[index]; } T const &operator[](isize index) const { #if !defined(NO_ARRAY_BOUNDS_CHECK) - GB_ASSERT_MSG(0 <= index && index < count, "Index %td is out of bounds ranges 0..<%td", index, count); + GB_ASSERT_MSG(cast(usize)index < cast(usize)count, "Index %td is out of bounds ranges 0..<%td", index, count); #endif return data[index]; } }; -template void array_init (Array *array, gbAllocator const &a); -template void array_init (Array *array, gbAllocator const &a, isize count); -template void array_init (Array *array, gbAllocator const &a, isize count, isize capacity); -template Array array_make (gbAllocator const &a); -template Array array_make (gbAllocator const &a, isize count); -template Array array_make (gbAllocator const &a, isize count, isize capacity); -template Array array_make_from_ptr (T *data, isize count, isize capacity); -template void array_free (Array *array); -template void array_add (Array *array, T const &t); -template T * array_add_and_get (Array *array); -template void array_add_elems (Array *array, T const *elems, isize elem_count); -template T array_pop (Array *array); -template void array_clear (Array *array); -template void array_reserve (Array *array, isize capacity); -template void array_resize (Array *array, isize count); -template void array_set_capacity (Array *array, isize capacity); -template Array array_slice (Array const &array, isize lo, isize hi); -template Array array_clone (gbAllocator const &a, Array const &array); +template gb_internal void array_init (Array *array, gbAllocator const &a); +template gb_internal void array_init (Array *array, gbAllocator const &a, isize count); +template gb_internal void array_init (Array *array, gbAllocator const &a, isize count, isize capacity); +template gb_internal Array array_make (gbAllocator const &a); +template gb_internal Array array_make (gbAllocator const &a, isize count); +template gb_internal Array array_make (gbAllocator const &a, isize count, isize capacity); +template gb_internal Array array_make_from_ptr (T *data, isize count, isize capacity); +template gb_internal void array_free (Array *array); +template gb_internal void array_add (Array *array, T const &t); +template gb_internal T * array_add_and_get (Array *array); +template gb_internal void array_add_elems (Array *array, T const *elems, isize elem_count); +template gb_internal T array_pop (Array *array); +template gb_internal void array_clear (Array *array); +template gb_internal void array_reserve (Array *array, isize capacity); +template gb_internal void array_resize (Array *array, isize count); +template gb_internal void array_set_capacity (Array *array, isize capacity); +template gb_internal Array array_slice (Array const &array, isize lo, isize hi); +template gb_internal Array array_clone (gbAllocator const &a, Array const &array); -template void array_ordered_remove (Array *array, isize index); -template void array_unordered_remove(Array *array, isize index); +template gb_internal void array_ordered_remove (Array *array, isize index); +template gb_internal void array_unordered_remove(Array *array, isize index); -template void array_copy(Array *array, Array const &data, isize offset); -template void array_copy(Array *array, Array const &data, isize offset, isize count); +template gb_internal void array_copy(Array *array, Array const &data, isize offset); +template gb_internal void array_copy(Array *array, Array const &data, isize offset, isize count); -template T *array_end_ptr(Array *array); +template gb_internal T *array_end_ptr(Array *array); template @@ -56,37 +56,39 @@ struct Slice { T *data; isize count; - T &operator[](isize index) { + gb_inline T &operator[](isize index) { #if !defined(NO_ARRAY_BOUNDS_CHECK) - GB_ASSERT_MSG(0 <= index && index < count, "Index %td is out of bounds ranges 0..<%td", index, count); + GB_ASSERT_MSG(cast(usize)index < cast(usize)count, "Index %td is out of bounds ranges 0..<%td", index, count); #endif return data[index]; } - T const &operator[](isize index) const { + gb_inline T const &operator[](isize index) const { #if !defined(NO_ARRAY_BOUNDS_CHECK) - GB_ASSERT_MSG(0 <= index && index < count, "Index %td is out of bounds ranges 0..<%td", index, count); + GB_ASSERT_MSG(cast(usize)index < cast(usize)count, "Index %td is out of bounds ranges 0..<%td", index, count); #endif return data[index]; } }; -template Slice slice_from_array(Array const &a); +template gb_internal Slice slice_from_array(Array const &a); template -Slice slice_make(gbAllocator const &allocator, isize count) { +gb_internal Slice slice_make(gbAllocator const &allocator, isize count) { GB_ASSERT(count >= 0); Slice s = {}; s.data = gb_alloc_array(allocator, T, count); - GB_ASSERT(s.data != nullptr); + if (count > 0) { + GB_ASSERT(s.data != nullptr); + } s.count = count; return s; } template -void slice_init(Slice *s, gbAllocator const &allocator, isize count) { +gb_internal void slice_init(Slice *s, gbAllocator const &allocator, isize count) { GB_ASSERT(count >= 0); s->data = gb_alloc_array(allocator, T, count); if (count > 0) { @@ -96,23 +98,23 @@ void slice_init(Slice *s, gbAllocator const &allocator, isize count) { } template -void slice_free(Slice *s, gbAllocator const &allocator) { +gb_internal void slice_free(Slice *s, gbAllocator const &allocator) { gb_free(allocator, s->data); } template -void slice_resize(Slice *s, gbAllocator const &allocator, isize new_count) { +gb_internal void slice_resize(Slice *s, gbAllocator const &allocator, isize new_count) { resize_array_raw(&s->data, allocator, s->count, new_count); s->count = new_count; } template -Slice slice_from_array(Array const &a) { +gb_internal Slice slice_from_array(Array const &a) { return {a.data, a.count}; } template -Slice slice_array(Array const &array, isize lo, isize hi) { +gb_internal Slice slice_array(Array const &array, isize lo, isize hi) { GB_ASSERT(0 <= lo && lo <= hi && hi <= array.count); Slice out = {}; isize len = hi-lo; @@ -125,30 +127,30 @@ Slice slice_array(Array const &array, isize lo, isize hi) { template -Slice slice_clone(gbAllocator const &allocator, Slice const &a) { +gb_internal Slice slice_clone(gbAllocator const &allocator, Slice const &a) { T *data = cast(T *)gb_alloc_copy_align(allocator, a.data, a.count*gb_size_of(T), gb_align_of(T)); return {data, a.count}; } template -Slice slice_clone_from_array(gbAllocator const &allocator, Array const &a) { +gb_internal Slice slice_clone_from_array(gbAllocator const &allocator, Array const &a) { auto c = array_clone(allocator, a); return {c.data, c.count}; } template -void slice_copy(Slice *slice, Slice const &data) { +gb_internal void slice_copy(Slice *slice, Slice const &data) { isize n = gb_min(slice->count, data.count); gb_memmove(slice->data, data.data, gb_size_of(T)*n); } template -void slice_copy(Slice *slice, Slice const &data, isize offset) { +gb_internal void slice_copy(Slice *slice, Slice const &data, isize offset) { isize n = gb_clamp(slice->count-offset, 0, data.count); gb_memmove(slice->data+offset, data.data, gb_size_of(T)*n); } template -void slice_copy(Slice *slice, Slice const &data, isize offset, isize count) { +gb_internal void slice_copy(Slice *slice, Slice const &data, isize offset, isize count) { isize n = gb_clamp(slice->count-offset, 0, gb_min(data.count, count)); gb_memmove(slice->data+offset, data.data, gb_size_of(T)*n); } @@ -156,7 +158,7 @@ void slice_copy(Slice *slice, Slice const &data, isize offset, isize count template -gb_inline Slice slice(Slice const &array, isize lo, isize hi) { +gb_internal gb_inline Slice slice(Slice const &array, isize lo, isize hi) { GB_ASSERT(0 <= lo && lo <= hi && hi <= array.count); Slice out = {}; isize len = hi-lo; @@ -169,7 +171,7 @@ gb_inline Slice slice(Slice const &array, isize lo, isize hi) { template -void slice_ordered_remove(Slice *array, isize index) { +gb_internal void slice_ordered_remove(Slice *array, isize index) { GB_ASSERT(0 <= index && index < array->count); isize bytes = gb_size_of(T) * (array->count-(index+1)); @@ -178,7 +180,7 @@ void slice_ordered_remove(Slice *array, isize index) { } template -void slice_unordered_remove(Slice *array, isize index) { +gb_internal void slice_unordered_remove(Slice *array, isize index) { GB_ASSERT(0 <= index && index < array->count); isize n = array->count-1; @@ -190,18 +192,18 @@ void slice_unordered_remove(Slice *array, isize index) { template -void array_copy(Array *array, Array const &data, isize offset) { +gb_internal void array_copy(Array *array, Array const &data, isize offset) { gb_memmove(array->data+offset, data.data, gb_size_of(T)*data.count); } template -void array_copy(Array *array, Array const &data, isize offset, isize count) { +gb_internal void array_copy(Array *array, Array const &data, isize offset, isize count) { gb_memmove(array->data+offset, data.data, gb_size_of(T)*gb_min(data.count, count)); } template -T *array_end_ptr(Array *array) { +gb_internal T *array_end_ptr(Array *array) { if (array->count > 0) { return &array->data[array->count-1]; } @@ -210,18 +212,18 @@ T *array_end_ptr(Array *array) { template -gb_inline void array_init(Array *array, gbAllocator const &a) { +gb_internal gb_inline void array_init(Array *array, gbAllocator const &a) { isize cap = ARRAY_GROW_FORMULA(0); array_init(array, a, 0, cap); } template -gb_inline void array_init(Array *array, gbAllocator const &a, isize count) { +gb_internal gb_inline void array_init(Array *array, gbAllocator const &a, isize count) { array_init(array, a, count, count); } template -gb_inline void array_init(Array *array, gbAllocator const &a, isize count, isize capacity) { +gb_internal gb_inline void array_init(Array *array, gbAllocator const &a, isize count, isize capacity) { array->allocator = a; array->data = nullptr; if (capacity > 0) { @@ -234,7 +236,7 @@ gb_inline void array_init(Array *array, gbAllocator const &a, isize count, is template -gb_inline Array array_make_from_ptr(T *data, isize count, isize capacity) { +gb_internal gb_inline Array array_make_from_ptr(T *data, isize count, isize capacity) { Array a = {0}; a.data = data; a.count = count; @@ -244,7 +246,7 @@ gb_inline Array array_make_from_ptr(T *data, isize count, isize capacity) { template -gb_inline Array array_make(gbAllocator const &a) { +gb_internal gb_inline Array array_make(gbAllocator const &a) { isize capacity = ARRAY_GROW_FORMULA(0); Array array = {}; array.allocator = a; @@ -254,7 +256,7 @@ gb_inline Array array_make(gbAllocator const &a) { return array; } template -gb_inline Array array_make(gbAllocator const &a, isize count) { +gb_internal gb_inline Array array_make(gbAllocator const &a, isize count) { Array array = {}; array.allocator = a; array.data = gb_alloc_array(a, T, count); @@ -263,7 +265,7 @@ gb_inline Array array_make(gbAllocator const &a, isize count) { return array; } template -gb_inline Array array_make(gbAllocator const &a, isize count, isize capacity) { +gb_internal gb_inline Array array_make(gbAllocator const &a, isize count, isize capacity) { Array array = {}; array.allocator = a; array.data = gb_alloc_array(a, T, capacity); @@ -275,7 +277,7 @@ gb_inline Array array_make(gbAllocator const &a, isize count, isize capacity) template -gb_inline void array_free(Array *array) { +gb_internal gb_inline void array_free(Array *array) { if (array->allocator.proc != nullptr) { gb_free(array->allocator, array->data); } @@ -284,7 +286,7 @@ gb_inline void array_free(Array *array) { } template -void array__grow(Array *array, isize min_capacity) { +gb_internal void array__grow(Array *array, isize min_capacity) { isize new_capacity = ARRAY_GROW_FORMULA(array->capacity); if (new_capacity < min_capacity) { new_capacity = min_capacity; @@ -293,7 +295,7 @@ void array__grow(Array *array, isize min_capacity) { } template -void array_add(Array *array, T const &t) { +gb_internal void array_add(Array *array, T const &t) { if (array->capacity < array->count+1) { array__grow(array, 0); } @@ -302,7 +304,7 @@ void array_add(Array *array, T const &t) { } template -T *array_add_and_get(Array *array) { +gb_internal T *array_add_and_get(Array *array) { if (array->count < array->capacity) { return &array->data[array->count++]; } @@ -314,7 +316,7 @@ T *array_add_and_get(Array *array) { template -void array_add_elems(Array *array, T const *elems, isize elem_count) { +gb_internal void array_add_elems(Array *array, T const *elems, isize elem_count) { GB_ASSERT(elem_count >= 0); if (array->capacity < array->count+elem_count) { array__grow(array, array->count+elem_count); @@ -325,26 +327,26 @@ void array_add_elems(Array *array, T const *elems, isize elem_count) { template -gb_inline T array_pop(Array *array) { +gb_internal gb_inline T array_pop(Array *array) { GB_ASSERT(array->count > 0); array->count--; return array->data[array->count]; } template -void array_clear(Array *array) { +gb_internal void array_clear(Array *array) { array->count = 0; } template -void array_reserve(Array *array, isize capacity) { +gb_internal void array_reserve(Array *array, isize capacity) { if (array->capacity < capacity) { array_set_capacity(array, capacity); } } template -void array_resize(Array *array, isize count) { +gb_internal void array_resize(Array *array, isize count) { if (array->capacity < count) { array__grow(array, count); } @@ -352,7 +354,7 @@ void array_resize(Array *array, isize count) { } template -void array_set_capacity(Array *array, isize capacity) { +gb_internal void array_set_capacity(Array *array, isize capacity) { if (capacity == array->capacity) { return; } @@ -381,7 +383,7 @@ void array_set_capacity(Array *array, isize capacity) { template -gb_inline Array array_slice(Array const &array, isize lo, isize hi) { +gb_internal gb_inline Array array_slice(Array const &array, isize lo, isize hi) { GB_ASSERT(0 <= lo && lo <= hi && hi <= array.count); Array out = {}; isize len = hi-lo; @@ -394,7 +396,7 @@ gb_inline Array array_slice(Array const &array, isize lo, isize hi) { } template -Array array_clone(gbAllocator const &allocator, Array const &array) { +gb_internal Array array_clone(gbAllocator const &allocator, Array const &array) { auto clone = array_make(allocator, array.count, array.count); array_copy(&clone, array, 0); return clone; @@ -402,7 +404,7 @@ Array array_clone(gbAllocator const &allocator, Array const &array) { template -void array_ordered_remove(Array *array, isize index) { +gb_internal void array_ordered_remove(Array *array, isize index) { GB_ASSERT(0 <= index && index < array->count); isize bytes = gb_size_of(T) * (array->count-(index+1)); @@ -411,7 +413,7 @@ void array_ordered_remove(Array *array, isize index) { } template -void array_unordered_remove(Array *array, isize index) { +gb_internal void array_unordered_remove(Array *array, isize index) { GB_ASSERT(0 <= index && index < array->count); isize n = array->count-1; @@ -424,35 +426,35 @@ void array_unordered_remove(Array *array, isize index) { template -T *begin(Array &array) { +gb_internal T *begin(Array &array) { return array.data; } template -T const *begin(Array const &array) { +gb_internal T const *begin(Array const &array) { return array.data; } template -T *end(Array &array) { +gb_internal T *end(Array &array) { return array.data + array.count; } template -T const *end(Array const &array) { +gb_internal T const *end(Array const &array) { return array.data + array.count; } template -T *begin(Slice &array) { +gb_internal T *begin(Slice &array) { return array.data; } template -T const *begin(Slice const &array) { +gb_internal T const *begin(Slice const &array) { return array.data; } template -T *end(Slice &array) { +gb_internal T *end(Slice &array) { return array.data + array.count; } template -T const *end(Slice const &array) { +gb_internal T const *end(Slice const &array) { return array.data + array.count; } diff --git a/src/big_int.cpp b/src/big_int.cpp index d8b3e63a7..e350687b4 100644 --- a/src/big_int.cpp +++ b/src/big_int.cpp @@ -37,86 +37,86 @@ void MP_FREE(void *mem, size_t size) { typedef mp_int BigInt; -void big_int_from_u64(BigInt *dst, u64 x); -void big_int_from_i64(BigInt *dst, i64 x); -void big_int_init (BigInt *dst, BigInt const *src); -void big_int_from_string(BigInt *dst, String const &s, bool *success); +gb_internal void big_int_from_u64(BigInt *dst, u64 x); +gb_internal void big_int_from_i64(BigInt *dst, i64 x); +gb_internal void big_int_init (BigInt *dst, BigInt const *src); +gb_internal void big_int_from_string(BigInt *dst, String const &s, bool *success); -void big_int_dealloc(BigInt *dst) { +gb_internal void big_int_dealloc(BigInt *dst) { mp_clear(dst); } -BigInt big_int_make(BigInt const *b, bool abs=false); -BigInt big_int_make_abs(BigInt const *b); -BigInt big_int_make_u64(u64 x); -BigInt big_int_make_i64(i64 x); +gb_internal BigInt big_int_make(BigInt const *b, bool abs=false); +gb_internal BigInt big_int_make_abs(BigInt const *b); +gb_internal BigInt big_int_make_u64(u64 x); +gb_internal BigInt big_int_make_i64(i64 x); -u64 big_int_to_u64 (BigInt const *x); -i64 big_int_to_i64 (BigInt const *x); -f64 big_int_to_f64 (BigInt const *x); -String big_int_to_string(gbAllocator allocator, BigInt const *x, u64 base = 10); +gb_internal u64 big_int_to_u64 (BigInt const *x); +gb_internal i64 big_int_to_i64 (BigInt const *x); +gb_internal f64 big_int_to_f64 (BigInt const *x); +gb_internal String big_int_to_string(gbAllocator allocator, BigInt const *x, u64 base = 10); -void big_int_add (BigInt *dst, BigInt const *x, BigInt const *y); -void big_int_sub (BigInt *dst, BigInt const *x, BigInt const *y); -void big_int_shl (BigInt *dst, BigInt const *x, BigInt const *y); -void big_int_shr (BigInt *dst, BigInt const *x, BigInt const *y); -void big_int_mul (BigInt *dst, BigInt const *x, BigInt const *y); -void big_int_mul_u64(BigInt *dst, BigInt const *x, u64 y); +gb_internal void big_int_add (BigInt *dst, BigInt const *x, BigInt const *y); +gb_internal void big_int_sub (BigInt *dst, BigInt const *x, BigInt const *y); +gb_internal void big_int_shl (BigInt *dst, BigInt const *x, BigInt const *y); +gb_internal void big_int_shr (BigInt *dst, BigInt const *x, BigInt const *y); +gb_internal void big_int_mul (BigInt *dst, BigInt const *x, BigInt const *y); +gb_internal void big_int_mul_u64(BigInt *dst, BigInt const *x, u64 y); -void big_int_quo_rem(BigInt const *x, BigInt const *y, BigInt *q, BigInt *r); -void big_int_quo (BigInt *z, BigInt const *x, BigInt const *y); -void big_int_rem (BigInt *z, BigInt const *x, BigInt const *y); +gb_internal void big_int_quo_rem(BigInt const *x, BigInt const *y, BigInt *q, BigInt *r); +gb_internal void big_int_quo (BigInt *z, BigInt const *x, BigInt const *y); +gb_internal void big_int_rem (BigInt *z, BigInt const *x, BigInt const *y); -void big_int_and (BigInt *dst, BigInt const *x, BigInt const *y); -void big_int_and_not(BigInt *dst, BigInt const *x, BigInt const *y); -void big_int_xor (BigInt *dst, BigInt const *x, BigInt const *y); -void big_int_or (BigInt *dst, BigInt const *x, BigInt const *y); -void big_int_not (BigInt *dst, BigInt const *x, i32 bit_count, bool is_signed); +gb_internal void big_int_and (BigInt *dst, BigInt const *x, BigInt const *y); +gb_internal void big_int_and_not(BigInt *dst, BigInt const *x, BigInt const *y); +gb_internal void big_int_xor (BigInt *dst, BigInt const *x, BigInt const *y); +gb_internal void big_int_or (BigInt *dst, BigInt const *x, BigInt const *y); +gb_internal void big_int_not (BigInt *dst, BigInt const *x, i32 bit_count, bool is_signed); -void big_int_add_eq(BigInt *dst, BigInt const *x); -void big_int_sub_eq(BigInt *dst, BigInt const *x); -void big_int_shl_eq(BigInt *dst, BigInt const *x); -void big_int_shr_eq(BigInt *dst, BigInt const *x); -void big_int_mul_eq(BigInt *dst, BigInt const *x); +gb_internal void big_int_add_eq(BigInt *dst, BigInt const *x); +gb_internal void big_int_sub_eq(BigInt *dst, BigInt const *x); +gb_internal void big_int_shl_eq(BigInt *dst, BigInt const *x); +gb_internal void big_int_shr_eq(BigInt *dst, BigInt const *x); +gb_internal void big_int_mul_eq(BigInt *dst, BigInt const *x); -void big_int_quo_eq(BigInt *dst, BigInt const *x); -void big_int_rem_eq(BigInt *dst, BigInt const *x); +gb_internal void big_int_quo_eq(BigInt *dst, BigInt const *x); +gb_internal void big_int_rem_eq(BigInt *dst, BigInt const *x); -bool big_int_is_neg(BigInt const *x); -void big_int_neg(BigInt *dst, BigInt const *x); +gb_internal bool big_int_is_neg(BigInt const *x); +gb_internal void big_int_neg(BigInt *dst, BigInt const *x); -void big_int_add_eq(BigInt *dst, BigInt const *x) { +gb_internal void big_int_add_eq(BigInt *dst, BigInt const *x) { BigInt res = {}; big_int_init(&res, dst); big_int_add(dst, &res, x); } -void big_int_sub_eq(BigInt *dst, BigInt const *x) { +gb_internal void big_int_sub_eq(BigInt *dst, BigInt const *x) { BigInt res = {}; big_int_init(&res, dst); big_int_sub(dst, &res, x); } -void big_int_shl_eq(BigInt *dst, BigInt const *x) { +gb_internal void big_int_shl_eq(BigInt *dst, BigInt const *x) { BigInt res = {}; big_int_init(&res, dst); big_int_shl(dst, &res, x); } -void big_int_shr_eq(BigInt *dst, BigInt const *x) { +gb_internal void big_int_shr_eq(BigInt *dst, BigInt const *x) { BigInt res = {}; big_int_init(&res, dst); big_int_shr(dst, &res, x); } -void big_int_mul_eq(BigInt *dst, BigInt const *x) { +gb_internal void big_int_mul_eq(BigInt *dst, BigInt const *x) { BigInt res = {}; big_int_init(&res, dst); big_int_mul(dst, &res, x); } -void big_int_quo_eq(BigInt *dst, BigInt const *x) { +gb_internal void big_int_quo_eq(BigInt *dst, BigInt const *x) { BigInt res = {}; big_int_init(&res, dst); big_int_quo(dst, &res, x); } -void big_int_rem_eq(BigInt *dst, BigInt const *x) { +gb_internal void big_int_rem_eq(BigInt *dst, BigInt const *x) { BigInt res = {}; big_int_init(&res, dst); big_int_rem(dst, &res, x); @@ -124,7 +124,7 @@ void big_int_rem_eq(BigInt *dst, BigInt const *x) { -i64 big_int_sign(BigInt const *x) { +gb_internal i64 big_int_sign(BigInt const *x) { if (mp_iszero(x)) { return 0; } @@ -132,44 +132,44 @@ i64 big_int_sign(BigInt const *x) { } -void big_int_from_u64(BigInt *dst, u64 x) { +gb_internal void big_int_from_u64(BigInt *dst, u64 x) { mp_init_u64(dst, x); } -void big_int_from_i64(BigInt *dst, i64 x) { +gb_internal void big_int_from_i64(BigInt *dst, i64 x) { mp_init_i64(dst, x); } -void big_int_init(BigInt *dst, BigInt const *src) { +gb_internal void big_int_init(BigInt *dst, BigInt const *src) { if (dst == src) { return; } mp_init_copy(dst, src); } -BigInt big_int_make(BigInt const *b, bool abs) { +gb_internal BigInt big_int_make(BigInt const *b, bool abs) { BigInt i = {}; big_int_init(&i, b); if (abs) mp_abs(&i, &i); return i; } -BigInt big_int_make_abs(BigInt const *b) { +gb_internal BigInt big_int_make_abs(BigInt const *b) { return big_int_make(b, true); } -BigInt big_int_make_u64(u64 x) { +gb_internal BigInt big_int_make_u64(u64 x) { BigInt i = {}; big_int_from_u64(&i, x); return i; } -BigInt big_int_make_i64(i64 x) { +gb_internal BigInt big_int_make_i64(i64 x) { BigInt i = {}; big_int_from_i64(&i, x); return i; } -void big_int_from_string(BigInt *dst, String const &s, bool *success) { +gb_internal void big_int_from_string(BigInt *dst, String const &s, bool *success) { *success = true; bool is_negative = false; @@ -262,66 +262,66 @@ void big_int_from_string(BigInt *dst, String const &s, bool *success) { -u64 big_int_to_u64(BigInt const *x) { +gb_internal u64 big_int_to_u64(BigInt const *x) { GB_ASSERT(x->sign == 0); return mp_get_u64(x); } -i64 big_int_to_i64(BigInt const *x) { +gb_internal i64 big_int_to_i64(BigInt const *x) { return mp_get_i64(x); } -f64 big_int_to_f64(BigInt const *x) { +gb_internal f64 big_int_to_f64(BigInt const *x) { return mp_get_double(x); } -void big_int_neg(BigInt *dst, BigInt const *x) { +gb_internal void big_int_neg(BigInt *dst, BigInt const *x) { mp_neg(x, dst); } -int big_int_cmp(BigInt const *x, BigInt const *y) { +gb_internal int big_int_cmp(BigInt const *x, BigInt const *y) { return mp_cmp(x, y); } -int big_int_cmp_zero(BigInt const *x) { +gb_internal int big_int_cmp_zero(BigInt const *x) { if (mp_iszero(x)) { return 0; } return x->sign ? -1 : +1; } -bool big_int_is_zero(BigInt const *x) { +gb_internal bool big_int_is_zero(BigInt const *x) { return mp_iszero(x); } -void big_int_add(BigInt *dst, BigInt const *x, BigInt const *y) { +gb_internal void big_int_add(BigInt *dst, BigInt const *x, BigInt const *y) { mp_add(x, y, dst); } -void big_int_sub(BigInt *dst, BigInt const *x, BigInt const *y) { +gb_internal void big_int_sub(BigInt *dst, BigInt const *x, BigInt const *y) { mp_sub(x, y, dst); } -void big_int_shl(BigInt *dst, BigInt const *x, BigInt const *y) { +gb_internal void big_int_shl(BigInt *dst, BigInt const *x, BigInt const *y) { u32 yy = mp_get_u32(y); mp_mul_2d(x, yy, dst); } -void big_int_shr(BigInt *dst, BigInt const *x, BigInt const *y) { +gb_internal void big_int_shr(BigInt *dst, BigInt const *x, BigInt const *y) { u32 yy = mp_get_u32(y); BigInt d = {}; mp_div_2d(x, yy, dst, &d); big_int_dealloc(&d); } -void big_int_mul_u64(BigInt *dst, BigInt const *x, u64 y) { +gb_internal void big_int_mul_u64(BigInt *dst, BigInt const *x, u64 y) { BigInt d = {}; big_int_from_u64(&d, y); mp_mul(x, &d, dst); @@ -329,12 +329,12 @@ void big_int_mul_u64(BigInt *dst, BigInt const *x, u64 y) { } -void big_int_mul(BigInt *dst, BigInt const *x, BigInt const *y) { +gb_internal void big_int_mul(BigInt *dst, BigInt const *x, BigInt const *y) { mp_mul(x, y, dst); } -u64 leading_zeros_u64(u64 x) { +gb_internal u64 leading_zeros_u64(u64 x) { #if defined(GB_COMPILER_MSVC) #if defined(GB_ARCH_64_BIT) return __lzcnt64(x); @@ -367,23 +367,23 @@ u64 leading_zeros_u64(u64 x) { // // q = x/y with the result truncated to zero // r = x - y*q -void big_int_quo_rem(BigInt const *x, BigInt const *y, BigInt *q_, BigInt *r_) { +gb_internal void big_int_quo_rem(BigInt const *x, BigInt const *y, BigInt *q_, BigInt *r_) { mp_div(x, y, q_, r_); } -void big_int_quo(BigInt *z, BigInt const *x, BigInt const *y) { +gb_internal void big_int_quo(BigInt *z, BigInt const *x, BigInt const *y) { BigInt r = {}; big_int_quo_rem(x, y, z, &r); big_int_dealloc(&r); } -void big_int_rem(BigInt *z, BigInt const *x, BigInt const *y) { +gb_internal void big_int_rem(BigInt *z, BigInt const *x, BigInt const *y) { BigInt q = {}; big_int_quo_rem(x, y, &q, z); big_int_dealloc(&q); } -void big_int_euclidean_mod(BigInt *z, BigInt const *x, BigInt const *y) { +gb_internal void big_int_euclidean_mod(BigInt *z, BigInt const *x, BigInt const *y) { BigInt y0 = {}; big_int_init(&y0, y); @@ -400,11 +400,11 @@ void big_int_euclidean_mod(BigInt *z, BigInt const *x, BigInt const *y) { -void big_int_and(BigInt *dst, BigInt const *x, BigInt const *y) { +gb_internal void big_int_and(BigInt *dst, BigInt const *x, BigInt const *y) { mp_and(x, y, dst); } -void big_int_and_not(BigInt *dst, BigInt const *x, BigInt const *y) { +gb_internal void big_int_and_not(BigInt *dst, BigInt const *x, BigInt const *y) { if (mp_iszero(x)) { big_int_init(dst, y); return; @@ -467,22 +467,23 @@ void big_int_and_not(BigInt *dst, BigInt const *x, BigInt const *y) { return; } -void big_int_xor(BigInt *dst, BigInt const *x, BigInt const *y) { +gb_internal void big_int_xor(BigInt *dst, BigInt const *x, BigInt const *y) { mp_xor(x, y, dst); } -void big_int_or(BigInt *dst, BigInt const *x, BigInt const *y) { +gb_internal void big_int_or(BigInt *dst, BigInt const *x, BigInt const *y) { mp_or(x, y, dst); } -void debug_print_big_int(BigInt const *x) { +gb_internal void debug_print_big_int(BigInt const *x) { + TEMPORARY_ALLOCATOR_GUARD(); String s = big_int_to_string(temporary_allocator(), x, 10); gb_printf_err("[DEBUG] %.*s\n", LIT(s)); } -void big_int_not(BigInt *dst, BigInt const *x, i32 bit_count, bool is_signed) { +gb_internal void big_int_not(BigInt *dst, BigInt const *x, i32 bit_count, bool is_signed) { GB_ASSERT(bit_count >= 0); if (bit_count == 0) { big_int_from_u64(dst, 0); @@ -530,7 +531,7 @@ void big_int_not(BigInt *dst, BigInt const *x, i32 bit_count, bool is_signed) { big_int_dealloc(&v); } -bool big_int_is_neg(BigInt const *x) { +gb_internal bool big_int_is_neg(BigInt const *x) { if (x == nullptr) { return false; } @@ -538,7 +539,7 @@ bool big_int_is_neg(BigInt const *x) { } -char digit_to_char(u8 digit) { +gb_internal char digit_to_char(u8 digit) { GB_ASSERT(digit < 16); if (digit <= 9) { return digit + '0'; @@ -548,7 +549,7 @@ char digit_to_char(u8 digit) { return '0'; } -String big_int_to_string(gbAllocator allocator, BigInt const *x, u64 base) { +gb_internal String big_int_to_string(gbAllocator allocator, BigInt const *x, u64 base) { GB_ASSERT(base <= 16); if (mp_iszero(x)) { @@ -560,40 +561,63 @@ String big_int_to_string(gbAllocator allocator, BigInt const *x, u64 base) { Array buf = {}; array_init(&buf, allocator, 0, 32); - BigInt v = {}; - mp_init_copy(&v, x); + if (x->used >= 498) { // 2^498 ~ 10^150 + mp_int val = {}; + mp_abs(x, &val); + int exp = 0; + mp_err err = mp_log_n(&val, 10, &exp); + GB_ASSERT(err == MP_OKAY); + GB_ASSERT(exp >= 100); - if (v.sign) { - array_add(&buf, '-'); - mp_abs(&v, &v); - } + mp_int thousand_below = {}; + mp_int thousand_above = {}; + mp_init_i32(&thousand_below, 10); - isize first_word_idx = buf.count; + mp_expt_n(&thousand_below, exp-3, &thousand_below); + mp_div(&val, &thousand_below, &thousand_above, nullptr); - BigInt r = {}; - BigInt b = {}; - big_int_from_u64(&b, base); + double mant = 1.0e-3 * mp_get_double(&thousand_above); - u8 digit = 0; - while (big_int_cmp(&v, &b) >= 0) { - big_int_quo_rem(&v, &b, &v, &r); + char val_buf[256] = {}; + isize n = gb_snprintf(val_buf, gb_size_of(val_buf)-1, "~ %s%.fe%u", (x->sign ? "-" : ""), mant, exp); + + array_add_elems(&buf, val_buf, n-1); + } else { + BigInt v = {}; + mp_init_copy(&v, x); + + if (v.sign) { + array_add(&buf, '-'); + mp_abs(&v, &v); + } + + isize first_word_idx = buf.count; + + BigInt r = {}; + BigInt b = {}; + big_int_from_u64(&b, base); + + u8 digit = 0; + while (big_int_cmp(&v, &b) >= 0) { + big_int_quo_rem(&v, &b, &v, &r); + digit = cast(u8)big_int_to_u64(&r); + array_add(&buf, digit_to_char(digit)); + } + + big_int_rem(&r, &v, &b); digit = cast(u8)big_int_to_u64(&r); array_add(&buf, digit_to_char(digit)); + + big_int_dealloc(&r); + big_int_dealloc(&b); + + for (isize i = first_word_idx; i < buf.count/2; i++) { + isize j = buf.count + first_word_idx - i - 1; + char tmp = buf[i]; + buf[i] = buf[j]; + buf[j] = tmp; + } + } - - big_int_rem(&r, &v, &b); - digit = cast(u8)big_int_to_u64(&r); - array_add(&buf, digit_to_char(digit)); - - big_int_dealloc(&r); - big_int_dealloc(&b); - - for (isize i = first_word_idx; i < buf.count/2; i++) { - isize j = buf.count + first_word_idx - i - 1; - char tmp = buf[i]; - buf[i] = buf[j]; - buf[j] = tmp; - } - return make_string(cast(u8 *)buf.data, buf.count); } diff --git a/src/bug_report.cpp b/src/bug_report.cpp index f4f1b51be..fbf616efb 100644 --- a/src/bug_report.cpp +++ b/src/bug_report.cpp @@ -30,7 +30,7 @@ NOTE(Jeroen): This prints the Windows product edition only, to be called from `print_platform_details`. */ #if defined(GB_SYSTEM_WINDOWS) -void report_windows_product_type(DWORD ProductType) { +gb_internal void report_windows_product_type(DWORD ProductType) { switch (ProductType) { case PRODUCT_ULTIMATE: gb_printf("Ultimate"); @@ -154,7 +154,7 @@ void report_windows_product_type(DWORD ProductType) { } #endif -void odin_cpuid(int leaf, int result[]) { +gb_internal void odin_cpuid(int leaf, int result[]) { #if defined(GB_CPU_ARM) return; @@ -169,7 +169,7 @@ void odin_cpuid(int leaf, int result[]) { #endif } -void report_cpu_info() { +gb_internal void report_cpu_info() { gb_printf("\tCPU: "); #if defined(GB_CPU_X86) @@ -220,7 +220,7 @@ void report_cpu_info() { /* Report the amount of installed RAM. */ -void report_ram_info() { +gb_internal void report_ram_info() { gb_printf("\tRAM: "); #if defined(GB_SYSTEM_WINDOWS) @@ -271,7 +271,7 @@ void report_ram_info() { #endif } -void report_os_info() { +gb_internal void report_os_info() { gb_printf("\tOS: "); #if defined(GB_SYSTEM_WINDOWS) @@ -966,7 +966,7 @@ void report_os_info() { } // NOTE(Jeroen): `odin report` prints some system information for easier bug reporting. -void print_bug_report_help() { +gb_internal void print_bug_report_help() { gb_printf("Where to find more information and get into contact when you encounter a bug:\n\n"); gb_printf("\tWebsite: https://odin-lang.org\n"); gb_printf("\tGitHub: https://github.com/odin-lang/Odin/issues\n"); diff --git a/src/build_settings.cpp b/src/build_settings.cpp index 1cd2899c4..866631f9a 100644 --- a/src/build_settings.cpp +++ b/src/build_settings.cpp @@ -7,6 +7,8 @@ // #define DEFAULT_TO_THREADED_CHECKER // #endif +#define DEFAULT_MAX_ERROR_COLLECTOR_COUNT (36) + enum TargetOsKind : u16 { TargetOs_Invalid, @@ -33,14 +35,12 @@ enum TargetArchKind : u16 { TargetArch_arm32, TargetArch_arm64, TargetArch_wasm32, - TargetArch_wasm64, + TargetArch_wasm64p32, TargetArch_COUNT, }; enum TargetEndianKind : u8 { - TargetEndian_Invalid, - TargetEndian_Little, TargetEndian_Big, @@ -57,7 +57,7 @@ enum TargetABIKind : u16 { }; -String target_os_names[TargetOs_COUNT] = { +gb_global String target_os_names[TargetOs_COUNT] = { str_lit(""), str_lit("windows"), str_lit("darwin"), @@ -72,30 +72,30 @@ String target_os_names[TargetOs_COUNT] = { str_lit("freestanding"), }; -String target_arch_names[TargetArch_COUNT] = { +gb_global String target_arch_names[TargetArch_COUNT] = { str_lit(""), str_lit("amd64"), str_lit("i386"), str_lit("arm32"), str_lit("arm64"), str_lit("wasm32"), - str_lit("wasm64"), + str_lit("wasm64p32"), }; -String target_endian_names[TargetEndian_COUNT] = { - str_lit(""), +gb_global String target_endian_names[TargetEndian_COUNT] = { str_lit("little"), str_lit("big"), }; -String target_abi_names[TargetABI_COUNT] = { +gb_global String target_abi_names[TargetABI_COUNT] = { str_lit(""), str_lit("win64"), str_lit("sysv"), }; -TargetEndianKind target_endians[TargetArch_COUNT] = { - TargetEndian_Invalid, +gb_global TargetEndianKind target_endians[TargetArch_COUNT] = { + TargetEndian_Little, + TargetEndian_Little, TargetEndian_Little, TargetEndian_Little, TargetEndian_Little, @@ -107,14 +107,15 @@ TargetEndianKind target_endians[TargetArch_COUNT] = { #define ODIN_VERSION_RAW "dev-unknown-unknown" #endif -String const ODIN_VERSION = str_lit(ODIN_VERSION_RAW); +gb_global String const ODIN_VERSION = str_lit(ODIN_VERSION_RAW); struct TargetMetrics { TargetOsKind os; TargetArchKind arch; - isize word_size; + isize ptr_size; + isize int_size; isize max_align; isize max_simd_align; String target_triplet; @@ -149,7 +150,6 @@ enum CommandKind : u32 { Command_run = 1<<0, Command_build = 1<<1, Command_check = 1<<3, - Command_query = 1<<4, Command_doc = 1<<5, Command_version = 1<<6, Command_test = 1<<7, @@ -157,16 +157,15 @@ enum CommandKind : u32 { Command_strip_semicolon = 1<<8, Command_bug_report = 1<<9, - Command__does_check = Command_run|Command_build|Command_check|Command_query|Command_doc|Command_test|Command_strip_semicolon, + Command__does_check = Command_run|Command_build|Command_check|Command_doc|Command_test|Command_strip_semicolon, Command__does_build = Command_run|Command_build|Command_test, Command_all = ~(u32)0, }; -char const *odin_command_strings[32] = { +gb_global char const *odin_command_strings[32] = { "run", "build", "check", - "query", "doc", "version", "test", @@ -237,9 +236,10 @@ struct BuildContext { TargetEndianKind endian_kind; // In bytes - i64 word_size; // Size of a pointer, must be >= 4 - i64 max_align; // max alignment, must be >= 1 (and typically >= word_size) - i64 max_simd_align; // max alignment, must be >= 1 (and typically >= word_size) + i64 ptr_size; // Size of a pointer, must be >= 4 + i64 int_size; // Size of a int/uint, must be >= 4 + i64 max_align; // max alignment, must be >= 1 (and typically >= ptr_size) + i64 max_simd_align; // max alignment, must be >= 1 (and typically >= ptr_size) CommandKind command_kind; String command; @@ -262,6 +262,7 @@ struct BuildContext { String microarch; BuildModeKind build_mode; bool generate_docs; + bool custom_optimization_level; i32 optimization_level; bool show_timings; TimingsExportFormat export_timings_format; @@ -277,6 +278,7 @@ struct BuildContext { bool no_output_files; bool no_crt; bool no_entry_point; + bool no_thread_local; bool use_lld; bool vet; bool vet_extra; @@ -290,34 +292,36 @@ struct BuildContext { bool ignore_warnings; bool warnings_as_errors; - bool show_error_line; + bool hide_error_line; + bool has_ansi_terminal_colours; bool ignore_lazy; + bool ignore_llvm_build; bool use_subsystem_windows; bool ignore_microsoft_magic; bool linker_map_file; bool use_separate_modules; - bool threaded_checker; + bool no_threaded_checker; bool show_debug_messages; bool copy_file_contents; - bool disallow_rtti; + bool no_rtti; - bool use_static_map_calls; + bool dynamic_map_calls; RelocMode reloc_mode; bool disable_red_zone; + isize max_error_count; + u32 cmd_doc_flags; Array extra_packages; - QueryDataSetSettings query_data_set_settings; - StringSet test_names; gbAffinity affinity; @@ -333,24 +337,37 @@ struct BuildContext { gb_global BuildContext build_context = {0}; -bool global_warnings_as_errors(void) { +gb_internal bool IS_ODIN_DEBUG(void) { + return build_context.ODIN_DEBUG; +} + + +gb_internal bool global_warnings_as_errors(void) { return build_context.warnings_as_errors; } -bool global_ignore_warnings(void) { +gb_internal bool global_ignore_warnings(void) { return build_context.ignore_warnings; } +gb_internal isize MAX_ERROR_COLLECTOR_COUNT(void) { + if (build_context.max_error_count <= 0) { + return DEFAULT_MAX_ERROR_COLLECTOR_COUNT; + } + return build_context.max_error_count; +} + + gb_global TargetMetrics target_windows_i386 = { TargetOs_windows, TargetArch_i386, - 4, 4, 8, + 4, 4, 4, 8, str_lit("i386-pc-windows-msvc"), }; gb_global TargetMetrics target_windows_amd64 = { TargetOs_windows, TargetArch_amd64, - 8, 8, 16, + 8, 8, 8, 16, str_lit("x86_64-pc-windows-msvc"), str_lit("e-m:w-i64:64-f80:128-n8:16:32:64-S128"), }; @@ -358,21 +375,21 @@ gb_global TargetMetrics target_windows_amd64 = { gb_global TargetMetrics target_linux_i386 = { TargetOs_linux, TargetArch_i386, - 4, 4, 8, + 4, 4, 4, 8, str_lit("i386-pc-linux-gnu"), }; gb_global TargetMetrics target_linux_amd64 = { TargetOs_linux, TargetArch_amd64, - 8, 8, 16, + 8, 8, 8, 16, str_lit("x86_64-pc-linux-gnu"), str_lit("e-m:w-i64:64-f80:128-n8:16:32:64-S128"), }; gb_global TargetMetrics target_linux_arm64 = { TargetOs_linux, TargetArch_arm64, - 8, 8, 16, + 8, 8, 8, 16, str_lit("aarch64-linux-elf"), str_lit("e-m:o-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"), }; @@ -380,7 +397,7 @@ gb_global TargetMetrics target_linux_arm64 = { gb_global TargetMetrics target_linux_arm32 = { TargetOs_linux, TargetArch_arm32, - 4, 4, 8, + 4, 4, 4, 8, str_lit("arm-linux-gnu"), str_lit("e-m:o-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"), }; @@ -388,7 +405,7 @@ gb_global TargetMetrics target_linux_arm32 = { gb_global TargetMetrics target_darwin_amd64 = { TargetOs_darwin, TargetArch_amd64, - 8, 8, 16, + 8, 8, 8, 16, str_lit("x86_64-apple-darwin"), str_lit("e-m:o-i64:64-f80:128-n8:16:32:64-S128"), }; @@ -396,22 +413,22 @@ gb_global TargetMetrics target_darwin_amd64 = { gb_global TargetMetrics target_darwin_arm64 = { TargetOs_darwin, TargetArch_arm64, - 8, 8, 16, + 8, 8, 8, 16, str_lit("arm64-apple-macosx11.0.0"), - str_lit("e-m:o-i64:64-i128:128-n32:64-S128"), // TODO(bill): Is this correct? + str_lit("e-m:o-i64:64-i128:128-n32:64-S128"), }; gb_global TargetMetrics target_freebsd_i386 = { TargetOs_freebsd, TargetArch_i386, - 4, 4, 8, + 4, 4, 4, 8, str_lit("i386-unknown-freebsd-elf"), }; gb_global TargetMetrics target_freebsd_amd64 = { TargetOs_freebsd, TargetArch_amd64, - 8, 8, 16, + 8, 8, 8, 16, str_lit("x86_64-unknown-freebsd-elf"), str_lit("e-m:w-i64:64-f80:128-n8:16:32:64-S128"), }; @@ -419,7 +436,7 @@ gb_global TargetMetrics target_freebsd_amd64 = { gb_global TargetMetrics target_openbsd_amd64 = { TargetOs_openbsd, TargetArch_amd64, - 8, 8, 16, + 8, 8, 8, 16, str_lit("x86_64-unknown-openbsd-elf"), str_lit("e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"), }; @@ -427,7 +444,7 @@ gb_global TargetMetrics target_openbsd_amd64 = { gb_global TargetMetrics target_essence_amd64 = { TargetOs_essence, TargetArch_amd64, - 8, 8, 16, + 8, 8, 8, 16, str_lit("x86_64-pc-none-elf"), }; @@ -435,7 +452,7 @@ gb_global TargetMetrics target_essence_amd64 = { gb_global TargetMetrics target_freestanding_wasm32 = { TargetOs_freestanding, TargetArch_wasm32, - 4, 8, 16, + 4, 4, 8, 16, str_lit("wasm32-freestanding-js"), str_lit("e-m:e-p:32:32-i64:64-n32:64-S128"), }; @@ -443,7 +460,7 @@ gb_global TargetMetrics target_freestanding_wasm32 = { gb_global TargetMetrics target_js_wasm32 = { TargetOs_js, TargetArch_wasm32, - 4, 8, 16, + 4, 4, 8, 16, str_lit("wasm32-js-js"), str_lit("e-m:e-p:32:32-i64:64-n32:64-S128"), }; @@ -451,24 +468,42 @@ gb_global TargetMetrics target_js_wasm32 = { gb_global TargetMetrics target_wasi_wasm32 = { TargetOs_wasi, TargetArch_wasm32, - 4, 8, 16, + 4, 4, 8, 16, str_lit("wasm32-wasi-js"), str_lit("e-m:e-p:32:32-i64:64-n32:64-S128"), }; -gb_global TargetMetrics target_js_wasm64 = { - TargetOs_js, - TargetArch_wasm64, - 8, 8, 16, - str_lit("wasm64-js-js"), - str_lit(""), +gb_global TargetMetrics target_freestanding_wasm64p32 = { + TargetOs_freestanding, + TargetArch_wasm64p32, + 4, 8, 8, 16, + str_lit("wasm32-freestanding-js"), + str_lit("e-m:e-p:32:32-i64:64-n32:64-S128"), }; +gb_global TargetMetrics target_js_wasm64p32 = { + TargetOs_js, + TargetArch_wasm64p32, + 4, 8, 8, 16, + str_lit("wasm32-js-js"), + str_lit("e-m:e-p:32:32-i64:64-n32:64-S128"), +}; + +gb_global TargetMetrics target_wasi_wasm64p32 = { + TargetOs_wasi, + TargetArch_wasm32, + 4, 8, 8, 16, + str_lit("wasm32-wasi-js"), + str_lit("e-m:e-p:32:32-i64:64-n32:64-S128"), +}; + + + gb_global TargetMetrics target_freestanding_amd64_sysv = { TargetOs_freestanding, TargetArch_amd64, - 8, 8, 16, + 8, 8, 8, 16, str_lit("x86_64-pc-none-gnu"), str_lit("e-m:w-i64:64-f80:128-n8:16:32:64-S128"), TargetABI_SysV, @@ -484,27 +519,36 @@ struct NamedTargetMetrics { gb_global NamedTargetMetrics named_targets[] = { { str_lit("darwin_amd64"), &target_darwin_amd64 }, { str_lit("darwin_arm64"), &target_darwin_arm64 }, + { str_lit("essence_amd64"), &target_essence_amd64 }, + { str_lit("linux_i386"), &target_linux_i386 }, { str_lit("linux_amd64"), &target_linux_amd64 }, { str_lit("linux_arm64"), &target_linux_arm64 }, { str_lit("linux_arm32"), &target_linux_arm32 }, + { str_lit("windows_i386"), &target_windows_i386 }, { str_lit("windows_amd64"), &target_windows_amd64 }, + { str_lit("freebsd_i386"), &target_freebsd_i386 }, { str_lit("freebsd_amd64"), &target_freebsd_amd64 }, + { str_lit("openbsd_amd64"), &target_openbsd_amd64 }, + { str_lit("freestanding_wasm32"), &target_freestanding_wasm32 }, { str_lit("wasi_wasm32"), &target_wasi_wasm32 }, { str_lit("js_wasm32"), &target_js_wasm32 }, - // { str_lit("js_wasm64"), &target_js_wasm64 }, + + { str_lit("freestanding_wasm64p32"), &target_freestanding_wasm64p32 }, + { str_lit("js_wasm64p32"), &target_js_wasm64p32 }, + { str_lit("wasi_wasm64p32"), &target_wasi_wasm64p32 }, { str_lit("freestanding_amd64_sysv"), &target_freestanding_amd64_sysv }, }; -NamedTargetMetrics *selected_target_metrics; +gb_global NamedTargetMetrics *selected_target_metrics; -TargetOsKind get_target_os_from_string(String str) { +gb_internal TargetOsKind get_target_os_from_string(String str) { for (isize i = 0; i < TargetOs_COUNT; i++) { if (str_eq_ignore_case(target_os_names[i], str)) { return cast(TargetOsKind)i; @@ -513,7 +557,7 @@ TargetOsKind get_target_os_from_string(String str) { return TargetOs_Invalid; } -TargetArchKind get_target_arch_from_string(String str) { +gb_internal TargetArchKind get_target_arch_from_string(String str) { for (isize i = 0; i < TargetArch_COUNT; i++) { if (str_eq_ignore_case(target_arch_names[i], str)) { return cast(TargetArchKind)i; @@ -523,7 +567,7 @@ TargetArchKind get_target_arch_from_string(String str) { } -bool is_excluded_target_filename(String name) { +gb_internal bool is_excluded_target_filename(String name) { String original_name = name; name = remove_extension_from_path(name); @@ -588,32 +632,31 @@ struct LibraryCollections { gb_global Array library_collections = {0}; -void add_library_collection(String name, String path) { - // TODO(bill): Check the path is valid and a directory +gb_internal void add_library_collection(String name, String path) { LibraryCollections lc = {name, string_trim_whitespace(path)}; array_add(&library_collections, lc); } -bool find_library_collection_path(String name, String *path) { - for_array(i, library_collections) { - if (library_collections[i].name == name) { - if (path) *path = library_collections[i].path; +gb_internal bool find_library_collection_path(String name, String *path) { + for (auto const &lc : library_collections) { + if (lc.name == name) { + if (path) *path = lc.path; return true; } } return false; } -bool is_arch_wasm(void) { +gb_internal bool is_arch_wasm(void) { switch (build_context.metrics.arch) { case TargetArch_wasm32: - case TargetArch_wasm64: + case TargetArch_wasm64p32: return true; } return false; } -bool is_arch_x86(void) { +gb_internal bool is_arch_x86(void) { switch (build_context.metrics.arch) { case TargetArch_i386: case TargetArch_amd64: @@ -622,10 +665,10 @@ bool is_arch_x86(void) { return false; } -bool allow_check_foreign_filepath(void) { +gb_internal bool allow_check_foreign_filepath(void) { switch (build_context.metrics.arch) { case TargetArch_wasm32: - case TargetArch_wasm64: + case TargetArch_wasm64p32: return false; } return true; @@ -638,13 +681,14 @@ bool allow_check_foreign_filepath(void) { // is_abs_path // has_subdir -String const WIN32_SEPARATOR_STRING = {cast(u8 *)"\\", 1}; -String const NIX_SEPARATOR_STRING = {cast(u8 *)"/", 1}; +gb_global String const WIN32_SEPARATOR_STRING = {cast(u8 *)"\\", 1}; +gb_global String const NIX_SEPARATOR_STRING = {cast(u8 *)"/", 1}; -String const WASM_MODULE_NAME_SEPARATOR = str_lit(".."); +gb_global String const WASM_MODULE_NAME_SEPARATOR = str_lit(".."); -String internal_odin_root_dir(void); -String odin_root_dir(void) { +gb_internal String internal_odin_root_dir(void); + +gb_internal String odin_root_dir(void) { if (global_module_path_set) { return global_module_path; } @@ -670,7 +714,7 @@ String odin_root_dir(void) { #if defined(GB_SYSTEM_WINDOWS) -String internal_odin_root_dir(void) { +gb_internal String internal_odin_root_dir(void) { String path = global_module_path; isize len, i; wchar_t *text; @@ -723,9 +767,9 @@ String internal_odin_root_dir(void) { #include -String path_to_fullpath(gbAllocator a, String s); +gb_internal String path_to_fullpath(gbAllocator a, String s); -String internal_odin_root_dir(void) { +gb_internal String internal_odin_root_dir(void) { String path = global_module_path; isize len, i; u8 *text; @@ -777,9 +821,9 @@ String internal_odin_root_dir(void) { // NOTE: Linux / Unix is unfinished and not tested very well. #include -String path_to_fullpath(gbAllocator a, String s); +gb_internal String path_to_fullpath(gbAllocator a, String s); -String internal_odin_root_dir(void) { +gb_internal String internal_odin_root_dir(void) { String path = global_module_path; isize len, i; u8 *text; @@ -938,18 +982,22 @@ String internal_odin_root_dir(void) { gb_global BlockingMutex fullpath_mutex; #if defined(GB_SYSTEM_WINDOWS) -String path_to_fullpath(gbAllocator a, String s) { +gb_internal String path_to_fullpath(gbAllocator a, String s) { String result = {}; - mutex_lock(&fullpath_mutex); - defer (mutex_unlock(&fullpath_mutex)); String16 string16 = string_to_string16(heap_allocator(), s); defer (gb_free(heap_allocator(), string16.text)); - DWORD len = GetFullPathNameW(&string16[0], 0, nullptr, nullptr); + DWORD len; + + mutex_lock(&fullpath_mutex); + + len = GetFullPathNameW(&string16[0], 0, nullptr, nullptr); if (len != 0) { wchar_t *text = gb_alloc_array(permanent_allocator(), wchar_t, len+1); GetFullPathNameW(&string16[0], len, text, nullptr); + mutex_unlock(&fullpath_mutex); + text[len] = 0; result = string16_to_string(a, make_string16(text, len)); result = string_trim_whitespace(result); @@ -960,12 +1008,14 @@ String path_to_fullpath(gbAllocator a, String s) { result.text[i] = '/'; } } + } else { + mutex_unlock(&fullpath_mutex); } return result; } #elif defined(GB_SYSTEM_OSX) || defined(GB_SYSTEM_UNIX) -String path_to_fullpath(gbAllocator a, String s) { +gb_internal String path_to_fullpath(gbAllocator a, String s) { char *p; mutex_lock(&fullpath_mutex); p = realpath(cast(char *)s.text, 0); @@ -978,7 +1028,7 @@ String path_to_fullpath(gbAllocator a, String s) { #endif -String get_fullpath_relative(gbAllocator a, String base_dir, String path) { +gb_internal String get_fullpath_relative(gbAllocator a, String base_dir, String path) { u8 *str = gb_alloc_array(heap_allocator(), u8, base_dir.len+1+path.len+1); defer (gb_free(heap_allocator(), str)); @@ -1004,7 +1054,7 @@ String get_fullpath_relative(gbAllocator a, String base_dir, String path) { } -String get_fullpath_core(gbAllocator a, String path) { +gb_internal String get_fullpath_core(gbAllocator a, String path) { String module_dir = odin_root_dir(); String core = str_lit("core/"); @@ -1024,11 +1074,14 @@ String get_fullpath_core(gbAllocator a, String path) { return path_to_fullpath(a, res); } -bool show_error_line(void) { - return build_context.show_error_line; +gb_internal bool show_error_line(void) { + return !build_context.hide_error_line; +} +gb_internal bool has_ansi_terminal_colours(void) { + return build_context.has_ansi_terminal_colours; } -bool has_asm_extension(String const &path) { +gb_internal bool has_asm_extension(String const &path) { String ext = path_extension(path); if (ext == ".asm") { return true; @@ -1041,7 +1094,7 @@ bool has_asm_extension(String const &path) { } // temporary -char *token_pos_to_string(TokenPos const &pos) { +gb_internal char *token_pos_to_string(TokenPos const &pos) { gbString s = gb_string_make_reserve(temporary_allocator(), 128); String file = get_file_path_string(pos.file_id); switch (build_context.ODIN_ERROR_POS_STYLE) { @@ -1056,7 +1109,7 @@ char *token_pos_to_string(TokenPos const &pos) { return s; } -void init_build_context(TargetMetrics *cross_target) { +gb_internal void init_build_context(TargetMetrics *cross_target) { BuildContext *bc = &build_context; gb_affinity_init(&bc->affinity); @@ -1068,6 +1121,10 @@ void init_build_context(TargetMetrics *cross_target) { bc->ODIN_VERSION = ODIN_VERSION; bc->ODIN_ROOT = odin_root_dir(); + if (bc->max_error_count <= 0) { + bc->max_error_count = DEFAULT_MAX_ERROR_COLLECTOR_COUNT; + } + { char const *found = gb_get_env("ODIN_ERROR_POS_STYLE", permanent_allocator()); if (found) { @@ -1134,16 +1191,24 @@ void init_build_context(TargetMetrics *cross_target) { GB_ASSERT(metrics->os != TargetOs_Invalid); GB_ASSERT(metrics->arch != TargetArch_Invalid); - GB_ASSERT(metrics->word_size > 1); + GB_ASSERT(metrics->ptr_size > 1); + GB_ASSERT(metrics->int_size > 1); GB_ASSERT(metrics->max_align > 1); GB_ASSERT(metrics->max_simd_align > 1); + GB_ASSERT(metrics->int_size >= metrics->ptr_size); + if (metrics->int_size > metrics->ptr_size) { + GB_ASSERT(metrics->int_size == 2*metrics->ptr_size); + } + + bc->metrics = *metrics; bc->ODIN_OS = target_os_names[metrics->os]; bc->ODIN_ARCH = target_arch_names[metrics->arch]; bc->endian_kind = target_endians[metrics->arch]; - bc->word_size = metrics->word_size; + bc->ptr_size = metrics->ptr_size; + bc->int_size = metrics->int_size; bc->max_align = metrics->max_align; bc->max_simd_align = metrics->max_simd_align; bc->link_flags = str_lit(" "); @@ -1162,8 +1227,8 @@ void init_build_context(TargetMetrics *cross_target) { if (bc->metrics.os == TargetOs_freestanding) { bc->no_entry_point = true; } else { - if (bc->disallow_rtti) { - gb_printf_err("-disallow-rtti is only allowed on freestanding targets\n"); + if (bc->no_rtti) { + gb_printf_err("-no-rtti is only allowed on freestanding targets\n"); gb_exit(1); } } @@ -1227,9 +1292,9 @@ void init_build_context(TargetMetrics *cross_target) { // link_flags = gb_string_appendc(link_flags, "--export-all "); // link_flags = gb_string_appendc(link_flags, "--export-table "); link_flags = gb_string_appendc(link_flags, "--allow-undefined "); - if (bc->metrics.arch == TargetArch_wasm64) { - link_flags = gb_string_appendc(link_flags, "-mwasm64 "); - } + // if (bc->metrics.arch == TargetArch_wasm64) { + // link_flags = gb_string_appendc(link_flags, "-mwasm64 "); + // } if (bc->no_entry_point) { link_flags = gb_string_appendc(link_flags, "--no-entry "); } @@ -1243,12 +1308,25 @@ void init_build_context(TargetMetrics *cross_target) { gb_exit(1); } - bc->optimization_level = gb_clamp(bc->optimization_level, 0, 3); + if (bc->ODIN_DEBUG && !bc->custom_optimization_level) { + // NOTE(bill): when building with `-debug` but not specifying an optimization level + // default to `-o:none` to improve the debug symbol generation by default + bc->optimization_level = -1; // -o:none + } - bc->ODIN_VALGRIND_SUPPORT = is_arch_x86() && build_context.metrics.os != TargetOs_windows; + bc->optimization_level = gb_clamp(bc->optimization_level, -1, 2); - #undef LINK_FLAG_X64 - #undef LINK_FLAG_386 + // ENFORCE DYNAMIC MAP CALLS + bc->dynamic_map_calls = true; + + bc->ODIN_VALGRIND_SUPPORT = false; + if (build_context.metrics.os != TargetOs_windows) { + switch (bc->metrics.arch) { + case TargetArch_amd64: + bc->ODIN_VALGRIND_SUPPORT = true; + break; + } + } } #if defined(GB_SYSTEM_WINDOWS) @@ -1258,7 +1336,7 @@ void init_build_context(TargetMetrics *cross_target) { #endif -Array split_by_comma(String const &list) { +gb_internal Array split_by_comma(String const &list) { isize n = 1; for (isize i = 0; i < list.len; i++) { if (list.text[i] == ',') { @@ -1280,20 +1358,19 @@ Array split_by_comma(String const &list) { return res; } -bool check_target_feature_is_valid(TokenPos pos, String const &feature) { +gb_internal bool check_target_feature_is_valid(TokenPos pos, String const &feature) { // TODO(bill): check_target_feature_is_valid return true; } -bool check_target_feature_is_enabled(TokenPos pos, String const &target_feature_list) { +gb_internal bool check_target_feature_is_enabled(TokenPos pos, String const &target_feature_list) { BuildContext *bc = &build_context; mutex_lock(&bc->target_features_mutex); defer (mutex_unlock(&bc->target_features_mutex)); auto items = split_by_comma(target_feature_list); array_free(&items); - for_array(i, items) { - String const &item = items.data[i]; + for (String const &item : items) { if (!check_target_feature_is_valid(pos, item)) { error(pos, "Target feature '%.*s' is not valid", LIT(item)); return false; @@ -1307,14 +1384,13 @@ bool check_target_feature_is_enabled(TokenPos pos, String const &target_feature_ return true; } -void enable_target_feature(TokenPos pos, String const &target_feature_list) { +gb_internal void enable_target_feature(TokenPos pos, String const &target_feature_list) { BuildContext *bc = &build_context; mutex_lock(&bc->target_features_mutex); defer (mutex_unlock(&bc->target_features_mutex)); auto items = split_by_comma(target_feature_list); - for_array(i, items) { - String const &item = items.data[i]; + for (String const &item : items) { if (!check_target_feature_is_valid(pos, item)) { error(pos, "Target feature '%.*s' is not valid", LIT(item)); continue; @@ -1326,28 +1402,30 @@ void enable_target_feature(TokenPos pos, String const &target_feature_list) { } -char const *target_features_set_to_cstring(gbAllocator allocator, bool with_quotes) { +gb_internal char const *target_features_set_to_cstring(gbAllocator allocator, bool with_quotes) { isize len = 0; - for_array(i, build_context.target_features_set.entries) { + isize i = 0; + for (String const &feature : build_context.target_features_set) { if (i != 0) { len += 1; } - String feature = build_context.target_features_set.entries[i].value; len += feature.len; if (with_quotes) len += 2; + i += 1; } char *features = gb_alloc_array(allocator, char, len+1); len = 0; - for_array(i, build_context.target_features_set.entries) { + i = 0; + for (String const &feature : build_context.target_features_set) { if (i != 0) { features[len++] = ','; } if (with_quotes) features[len++] = '"'; - String feature = build_context.target_features_set.entries[i].value; gb_memmove(features + len, feature.text, feature.len); len += feature.len; if (with_quotes) features[len++] = '"'; + i += 1; } features[len++] = 0; @@ -1356,15 +1434,14 @@ char const *target_features_set_to_cstring(gbAllocator allocator, bool with_quot // NOTE(Jeroen): Set/create the output and other paths and report an error as appropriate. // We've previously called `parse_build_flags`, so `out_filepath` should be set. -bool init_build_paths(String init_filename) { +gb_internal bool init_build_paths(String init_filename) { gbAllocator ha = heap_allocator(); BuildContext *bc = &build_context; // NOTE(Jeroen): We're pre-allocating BuildPathCOUNT slots so that certain paths are always at the same enumerated index. array_init(&bc->build_paths, permanent_allocator(), BuildPathCOUNT); - string_set_init(&bc->target_features_set, heap_allocator(), 1024); - mutex_init(&bc->target_features_mutex); + string_set_init(&bc->target_features_set, 1024); // [BuildPathMainPackage] Turn given init path into a `Path`, which includes normalizing it into a full path. bc->build_paths[BuildPath_Main_Package] = path_from_string(ha, init_filename); @@ -1408,7 +1485,6 @@ bool init_build_paths(String init_filename) { if ((bc->command_kind & Command__does_build) && (!bc->ignore_microsoft_magic)) { // NOTE(ic): It would be nice to extend this so that we could specify the Visual Studio version that we want instead of defaulting to the latest. Find_Result find_result = find_visual_studio_and_windows_sdk(); - defer (mc_free_all()); if (find_result.windows_sdk_version == 0) { gb_printf_err("Windows SDK not found.\n"); @@ -1460,13 +1536,23 @@ bool init_build_paths(String init_filename) { } else if (is_arch_wasm()) { output_extension = STR_LIT("wasm"); } else if (build_context.build_mode == BuildMode_Executable) { - // By default use a .bin executable extension. - output_extension = STR_LIT("bin"); + // By default use no executable extension. + output_extension = make_string(nullptr, 0); + String const single_file_extension = str_lit(".odin"); if (build_context.metrics.os == TargetOs_windows) { output_extension = STR_LIT("exe"); } else if (build_context.cross_compiling && selected_target_metrics->metrics == &target_essence_amd64) { - output_extension = make_string(nullptr, 0); + // Do nothing: we don't want the .bin extension + // when cross compiling + } else if (path_is_directory(last_path_element(bc->build_paths[BuildPath_Main_Package].basename))) { + // Add .bin extension to avoid collision + // with package directory name + output_extension = STR_LIT("bin"); + } else if (string_ends_with(init_filename, single_file_extension) && path_is_directory(remove_extension_from_path(init_filename))) { + // Add bin extension if compiling single-file package + // with same output name as a directory + output_extension = STR_LIT("bin"); } } else if (build_context.build_mode == BuildMode_DynamicLibrary) { // By default use a .so shared library extension. @@ -1533,6 +1619,25 @@ bool init_build_paths(String init_filename) { output_name = remove_extension_from_path(output_name); output_name = copy_string(ha, string_trim_whitespace(output_name)); output_path = path_from_string(ha, output_name); + + // Note(Dragos): This is a fix for empty filenames + // Turn the trailing folder into the file name + if (output_path.name.len == 0) { + isize len = output_path.basename.len; + while (len > 1 && output_path.basename[len - 1] != '/') { + len -= 1; + } + // We reached the slash + String old_basename = output_path.basename; + output_path.basename.len = len - 1; // Remove the slash + output_path.name = substring(old_basename, len, old_basename.len); + output_path.basename = copy_string(ha, output_path.basename); + output_path.name = copy_string(ha, output_path.name); + // The old basename is wrong. Delete it + gb_free(ha, old_basename.text); + + + } // Replace extension. if (output_path.ext.len > 0) { @@ -1559,6 +1664,14 @@ bool init_build_paths(String init_filename) { return false; } + if (!write_directory(bc->build_paths[BuildPath_Output].basename)) { + String output_file = path_to_string(ha, bc->build_paths[BuildPath_Output]); + defer (gb_free(ha, output_file.text)); + gb_printf_err("No write permissions for output path: %.*s\n", LIT(output_file)); + return false; + } + + if (bc->target_features_string.len != 0) { enable_target_feature({}, bc->target_features_string); } diff --git a/src/check_builtin.cpp b/src/check_builtin.cpp index 809d1d9a5..269a0ec48 100644 --- a/src/check_builtin.cpp +++ b/src/check_builtin.cpp @@ -1,6 +1,6 @@ typedef bool (BuiltinTypeIsProc)(Type *t); -BuiltinTypeIsProc *builtin_type_is_procs[BuiltinProc__type_simple_boolean_end - BuiltinProc__type_simple_boolean_begin] = { +gb_global BuiltinTypeIsProc *builtin_type_is_procs[BuiltinProc__type_simple_boolean_end - BuiltinProc__type_simple_boolean_begin] = { nullptr, // BuiltinProc__type_simple_boolean_begin is_type_boolean, @@ -51,7 +51,7 @@ BuiltinTypeIsProc *builtin_type_is_procs[BuiltinProc__type_simple_boolean_end - }; -void check_or_else_right_type(CheckerContext *c, Ast *expr, String const &name, Type *right_type) { +gb_internal void check_or_else_right_type(CheckerContext *c, Ast *expr, String const &name, Type *right_type) { if (right_type == nullptr) { return; } @@ -62,7 +62,7 @@ void check_or_else_right_type(CheckerContext *c, Ast *expr, String const &name, } } -void check_or_else_split_types(CheckerContext *c, Operand *x, String const &name, Type **left_type_, Type **right_type_) { +gb_internal void check_or_else_split_types(CheckerContext *c, Operand *x, String const &name, Type **left_type_, Type **right_type_) { Type *left_type = nullptr; Type *right_type = nullptr; if (x->type->kind == Type_Tuple) { @@ -88,8 +88,7 @@ void check_or_else_split_types(CheckerContext *c, Operand *x, String const &name } -void check_or_else_expr_no_value_error(CheckerContext *c, String const &name, Operand const &x, Type *type_hint) { - // TODO(bill): better error message +gb_internal void check_or_else_expr_no_value_error(CheckerContext *c, String const &name, Operand const &x, Type *type_hint) { gbString t = type_to_string(x.type); error(x.expr, "'%.*s' does not return a value, value is of type %s", LIT(name), t); if (is_type_union(type_deref(x.type))) { @@ -97,8 +96,7 @@ void check_or_else_expr_no_value_error(CheckerContext *c, String const &name, Op gbString th = nullptr; if (type_hint != nullptr) { GB_ASSERT(bsrc->kind == Type_Union); - for_array(i, bsrc->Union.variants) { - Type *vt = bsrc->Union.variants[i]; + for (Type *vt : bsrc->Union.variants) { if (are_types_identical(vt, type_hint)) { th = type_to_string(type_hint); break; @@ -118,7 +116,7 @@ void check_or_else_expr_no_value_error(CheckerContext *c, String const &name, Op } -void check_or_return_split_types(CheckerContext *c, Operand *x, String const &name, Type **left_type_, Type **right_type_) { +gb_internal void check_or_return_split_types(CheckerContext *c, Operand *x, String const &name, Type **left_type_, Type **right_type_) { Type *left_type = nullptr; Type *right_type = nullptr; if (x->type->kind == Type_Tuple) { @@ -144,7 +142,7 @@ void check_or_return_split_types(CheckerContext *c, Operand *x, String const &na } -bool does_require_msgSend_stret(Type *return_type) { +gb_internal bool does_require_msgSend_stret(Type *return_type) { if (return_type == nullptr) { return false; } @@ -165,7 +163,7 @@ bool does_require_msgSend_stret(Type *return_type) { return false; } -ObjcMsgKind get_objc_proc_kind(Type *return_type) { +gb_internal ObjcMsgKind get_objc_proc_kind(Type *return_type) { if (return_type == nullptr) { return ObjcMsg_normal; } @@ -189,7 +187,7 @@ ObjcMsgKind get_objc_proc_kind(Type *return_type) { return ObjcMsg_normal; } -void add_objc_proc_type(CheckerContext *c, Ast *call, Type *return_type, Slice param_types) { +gb_internal void add_objc_proc_type(CheckerContext *c, Ast *call, Type *return_type, Slice param_types) { ObjcMsgKind kind = get_objc_proc_kind(return_type); Scope *scope = create_scope(c->info, nullptr); @@ -199,8 +197,7 @@ void add_objc_proc_type(CheckerContext *c, Ast *call, Type *return_type, Slice(permanent_allocator(), 0, param_types.count); - for_array(i, param_types) { - Type *type = param_types[i]; + for (Type *type : param_types) { Entity *param = alloc_entity_param(scope, blank_token, type, false, true); array_add(&variables, param); } @@ -230,7 +227,7 @@ void add_objc_proc_type(CheckerContext *c, Ast *call, Type *return_type, Sliceproc); String builtin_name = bd->name.string; @@ -1111,7 +1108,7 @@ bool cache_load_file_directive(CheckerContext *c, Ast *call, String const &origi new_cache->path = path; new_cache->data = data; new_cache->file_error = file_error; - string_map_init(&new_cache->hashes, heap_allocator(), 32); + string_map_init(&new_cache->hashes, 32); string_map_set(&c->info->load_file_cache, path, new_cache); if (cache_) *cache_ = new_cache; } else { @@ -1121,8 +1118,8 @@ bool cache_load_file_directive(CheckerContext *c, Ast *call, String const &origi } }); - char *c_str = alloc_cstring(heap_allocator(), path); - defer (gb_free(heap_allocator(), c_str)); + TEMPORARY_ALLOCATOR_GUARD(); + char *c_str = alloc_cstring(temporary_allocator(), path); gbFile f = {}; if (cache == nullptr) { @@ -1170,7 +1167,7 @@ bool cache_load_file_directive(CheckerContext *c, Ast *call, String const &origi } -bool is_valid_type_for_load(Type *type) { +gb_internal bool is_valid_type_for_load(Type *type) { if (type == t_invalid) { return false; } else if (is_type_string(type)) { @@ -1191,7 +1188,16 @@ bool is_valid_type_for_load(Type *type) { return false; } -LoadDirectiveResult check_load_directive(CheckerContext *c, Operand *operand, Ast *call, Type *type_hint, bool err_on_not_found) { +gb_internal bool check_atomic_ptr_argument(Operand *operand, String const &builtin_name, Type *elem) { + if (!is_type_valid_atomic_type(elem)) { + error(operand->expr, "Only an integer, floating-point, boolean, or pointer can be used as an atomic for '%.*s'", LIT(builtin_name)); + return false; + } + return true; + +} + +gb_internal LoadDirectiveResult check_load_directive(CheckerContext *c, Operand *operand, Ast *call, Type *type_hint, bool err_on_not_found) { ast_node(ce, CallExpr, call); ast_node(bd, BasicDirective, ce->proc); String name = bd->name.string; @@ -1256,7 +1262,7 @@ LoadDirectiveResult check_load_directive(CheckerContext *c, Operand *operand, As } -bool check_builtin_procedure_directive(CheckerContext *c, Operand *operand, Ast *call, Type *type_hint) { +gb_internal bool check_builtin_procedure_directive(CheckerContext *c, Operand *operand, Ast *call, Type *type_hint) { ast_node(ce, CallExpr, call); ast_node(bd, BasicDirective, ce->proc); String name = bd->name.string; @@ -1581,7 +1587,7 @@ bool check_builtin_procedure_directive(CheckerContext *c, Operand *operand, Ast return true; } -bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 id, Type *type_hint) { +gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 id, Type *type_hint) { ast_node(ce, CallExpr, call); if (ce->inlining != ProcInlining_none) { error(call, "Inlining operators are not allowed on built-in procedures"); @@ -1690,7 +1696,7 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 case BuiltinProc___entry_point: operand->mode = Addressing_NoValue; operand->type = nullptr; - mpmc_enqueue(&c->info->intrinsics_entry_point_usage, call); + mpsc_enqueue(&c->info->intrinsics_entry_point_usage, call); break; case BuiltinProc_DIRECTIVE: @@ -2057,7 +2063,7 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 if (c->scope->flags&ScopeFlag_Global) { compiler_error("'type_info_of' Cannot be declared within the runtime package due to how the internals of the compiler works"); } - if (build_context.disallow_rtti) { + if (build_context.no_rtti) { error(call, "'%.*s' has been disallowed", LIT(builtin_name)); return false; } @@ -2100,7 +2106,7 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 if (c->scope->flags&ScopeFlag_Global) { compiler_error("'typeid_of' Cannot be declared within the runtime package due to how the internals of the compiler works"); } - if (build_context.disallow_rtti) { + if (build_context.no_rtti) { error(call, "'%.*s' has been disallowed", LIT(builtin_name)); return false; } @@ -2544,7 +2550,7 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 break; } - case BuiltinProc_expand_to_tuple: { + case BuiltinProc_expand_values: { Type *type = base_type(operand->type); if (!is_type_struct(type) && !is_type_array(type)) { gbString type_str = type_to_string(operand->type); @@ -2559,7 +2565,7 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 if (is_type_struct(type)) { isize variable_count = type->Struct.fields.count; slice_init(&tuple->Tuple.variables, a, variable_count); - // TODO(bill): Should I copy each of the entities or is this good enough? + // NOTE(bill): don't copy the entities, this should be good enough gb_memmove_array(tuple->Tuple.variables.data, type->Struct.fields.data, variable_count); } else if (is_type_array(type)) { isize variable_count = cast(isize)type->Array.count; @@ -3066,14 +3072,14 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 } case BuiltinProc_soa_zip: { + TEMPORARY_ALLOCATOR_GUARD(); auto types = array_make(temporary_allocator(), 0, ce->args.count); auto names = array_make(temporary_allocator(), 0, ce->args.count); bool first_is_field_value = (ce->args[0]->kind == Ast_FieldValue); bool fail = false; - for_array(i, ce->args) { - Ast *arg = ce->args[i]; + for (Ast *arg : ce->args) { bool mix = false; if (first_is_field_value) { mix = arg->kind != Ast_FieldValue; @@ -3087,11 +3093,10 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 } } StringSet name_set = {}; - string_set_init(&name_set, heap_allocator(), 2*ce->args.count); + string_set_init(&name_set, 2*ce->args.count); - for_array(i, ce->args) { + for (Ast *arg : ce->args) { String name = {}; - Ast *arg = ce->args[i]; if (arg->kind == Ast_FieldValue) { Ast *ename = arg->FieldValue.field; if (!fail && ename->kind != Ast_Ident) { @@ -3126,13 +3131,11 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 } - if (string_set_exists(&name_set, name)) { + if (string_set_update(&name_set, name)) { error(op.expr, "Field argument name '%.*s' already exists", LIT(name)); } else { array_add(&types, arg_type->Slice.elem); array_add(&names, name); - - string_set_add(&name_set, name); } } @@ -3455,9 +3458,8 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 error(ce->args[0], "Expected a constant string for '%.*s'", LIT(builtin_name)); } else if (operand->value.kind == ExactValue_String) { String pkg_name = operand->value.value_string; - // TODO(bill): probably should have this be a `StringMap` eventually - for_array(i, c->info->packages.entries) { - AstPackage *pkg = c->info->packages.entries[i].value; + for (auto const &entry : c->info->packages) { + AstPackage *pkg = entry.value; if (pkg->name == pkg_name) { value = true; break; @@ -3769,9 +3771,7 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 mp_err err = mp_pack(rop, max_count, &written, MP_LSB_FIRST, size, endian, nails, &x.value.value_integer); GB_ASSERT(err == MP_OKAY); - if (id == BuiltinProc_reverse_bits) { - // TODO(bill): Should this even be allowed at compile time? - } else { + if (id != BuiltinProc_reverse_bits) { u64 v = 0; switch (id) { case BuiltinProc_count_ones: @@ -4255,6 +4255,9 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 error(operand->expr, "Expected a pointer for '%.*s'", LIT(builtin_name)); return false; } + if (id == BuiltinProc_atomic_store && !check_atomic_ptr_argument(operand, builtin_name, elem)) { + return false; + } Operand x = {}; check_expr_with_type_hint(c, &x, ce->args[1], elem); check_assignment(c, &x, elem, builtin_name); @@ -4271,6 +4274,9 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 error(operand->expr, "Expected a pointer for '%.*s'", LIT(builtin_name)); return false; } + if (!check_atomic_ptr_argument(operand, builtin_name, elem)) { + return false; + } Operand x = {}; check_expr_with_type_hint(c, &x, ce->args[1], elem); check_assignment(c, &x, elem, builtin_name); @@ -4303,6 +4309,10 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 error(operand->expr, "Expected a pointer for '%.*s'", LIT(builtin_name)); return false; } + if (id == BuiltinProc_atomic_load && !check_atomic_ptr_argument(operand, builtin_name, elem)) { + return false; + } + operand->type = elem; operand->mode = Addressing_Value; break; @@ -4315,6 +4325,9 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 error(operand->expr, "Expected a pointer for '%.*s'", LIT(builtin_name)); return false; } + if (!check_atomic_ptr_argument(operand, builtin_name, elem)) { + return false; + } OdinAtomicMemoryOrder memory_order = {}; if (!check_atomic_memory_order_argument(c, ce->args[1], builtin_name, &memory_order)) { @@ -4346,6 +4359,9 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 error(operand->expr, "Expected a pointer for '%.*s'", LIT(builtin_name)); return false; } + if (!check_atomic_ptr_argument(operand, builtin_name, elem)) { + return false; + } Operand x = {}; check_expr_with_type_hint(c, &x, ce->args[1], elem); check_assignment(c, &x, elem, builtin_name); @@ -4383,6 +4399,9 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 error(operand->expr, "Expected a pointer for '%.*s'", LIT(builtin_name)); return false; } + if (!check_atomic_ptr_argument(operand, builtin_name, elem)) { + return false; + } Operand x = {}; check_expr_with_type_hint(c, &x, ce->args[1], elem); check_assignment(c, &x, elem, builtin_name); @@ -4421,6 +4440,9 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 error(operand->expr, "Expected a pointer for '%.*s'", LIT(builtin_name)); return false; } + if (!check_atomic_ptr_argument(operand, builtin_name, elem)) { + return false; + } Operand x = {}; Operand y = {}; check_expr_with_type_hint(c, &x, ce->args[1], elem); @@ -4448,6 +4470,9 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 error(operand->expr, "Expected a pointer for '%.*s'", LIT(builtin_name)); return false; } + if (!check_atomic_ptr_argument(operand, builtin_name, elem)) { + return false; + } Operand x = {}; Operand y = {}; check_expr_with_type_hint(c, &x, ce->args[1], elem); @@ -4818,6 +4843,89 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 } operand->mode = Addressing_Type; break; + case BuiltinProc_type_merge: + { + operand->mode = Addressing_Type; + operand->type = t_invalid; + + Operand x = {}; + Operand y = {}; + check_expr_or_type(c, &x, ce->args[0]); + check_expr_or_type(c, &y, ce->args[1]); + if (x.mode != Addressing_Type) { + error(x.expr, "Expected a type for '%.*s'", LIT(builtin_name)); + return false; + } + if (y.mode != Addressing_Type) { + error(y.expr, "Expected a type for '%.*s'", LIT(builtin_name)); + return false; + } + + if (is_type_polymorphic(x.type)) { + gbString t = type_to_string(x.type); + error(x.expr, "Expected a non-polymorphic type for '%.*s', got %s", LIT(builtin_name), t); + gb_string_free(t); + return false; + } + if (is_type_polymorphic(y.type)) { + gbString t = type_to_string(y.type); + error(y.expr, "Expected a non-polymorphic type for '%.*s', got %s", LIT(builtin_name), t); + gb_string_free(t); + return false; + } + if (!is_type_union(x.type)) { + gbString t = type_to_string(x.type); + error(x.expr, "Expected a union type for '%.*s', got %s", LIT(builtin_name), t); + gb_string_free(t); + return false; + } + if (!is_type_union(y.type)) { + gbString t = type_to_string(y.type); + error(x.expr, "Expected a union type for '%.*s', got %s", LIT(builtin_name), t); + gb_string_free(t); + return false; + } + Type *ux = base_type(x.type); + Type *uy = base_type(y.type); + GB_ASSERT(ux->kind == Type_Union); + GB_ASSERT(uy->kind == Type_Union); + + i64 custom_align = gb_max(ux->Union.custom_align, uy->Union.custom_align); + if (ux->Union.kind != uy->Union.kind) { + error(x.expr, "Union kinds must match, got %s vs %s", union_type_kind_strings[ux->Union.kind], union_type_kind_strings[uy->Union.kind]); + } + + Type *merged_union = alloc_type_union(); + + merged_union->Union.node = call; + merged_union->Union.scope = create_scope(c->info, c->scope); + merged_union->Union.kind = ux->Union.kind; + merged_union->Union.custom_align = custom_align; + + auto variants = array_make(permanent_allocator(), 0, ux->Union.variants.count+uy->Union.variants.count); + for (Type *t : ux->Union.variants) { + array_add(&variants, t); + } + for (Type *t : uy->Union.variants) { + bool ok = true; + for (Type *other_t : ux->Union.variants) { + if (are_types_identical(other_t, t)) { + ok = false; + break; + } + } + if (ok) { + array_add(&variants, t); + } + + } + merged_union->Union.variants = slice_from_array(variants); + + operand->mode = Addressing_Type; + operand->type = merged_union; + } + break; + case BuiltinProc_type_is_boolean: case BuiltinProc_type_is_integer: @@ -4993,8 +5101,7 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 bool is_variant = false; - for_array(i, u->Union.variants) { - Type *vt = u->Union.variants[i]; + for (Type *vt : u->Union.variants) { if (are_types_identical(v, vt)) { is_variant = true; break; diff --git a/src/check_decl.cpp b/src/check_decl.cpp index 0e41dbbb5..b651e33e6 100644 --- a/src/check_decl.cpp +++ b/src/check_decl.cpp @@ -1,7 +1,7 @@ -void check_stmt (CheckerContext *ctx, Ast *node, u32 flags); +gb_internal void check_stmt(CheckerContext *ctx, Ast *node, u32 flags); // NOTE(bill): 'content_name' is for debugging and error messages -Type *check_init_variable(CheckerContext *ctx, Entity *e, Operand *operand, String context_name) { +gb_internal Type *check_init_variable(CheckerContext *ctx, Entity *e, Operand *operand, String context_name) { if (operand->mode == Addressing_Invalid || operand->type == t_invalid || e->type == t_invalid) { @@ -10,7 +10,6 @@ Type *check_init_variable(CheckerContext *ctx, Entity *e, Operand *operand, Stri gbString expr_str = expr_to_string(operand->expr); // TODO(bill): is this a good enough error message? - // TODO(bill): Actually allow built in procedures to be passed around and thus be created on use error(operand->expr, "Cannot assign built-in procedure '%s' in %.*s", expr_str, @@ -44,14 +43,20 @@ Type *check_init_variable(CheckerContext *ctx, Entity *e, Operand *operand, Stri } if (operand->mode == Addressing_Type) { - if (e->type != nullptr && is_type_typeid(e->type)) { + if (e->type != nullptr && is_type_typeid(e->type) && !is_type_polymorphic(operand->type)) { add_type_info_type(ctx, operand->type); - add_type_and_value(ctx->info, operand->expr, Addressing_Value, e->type, exact_value_typeid(operand->type)); + add_type_and_value(ctx, operand->expr, Addressing_Value, e->type, exact_value_typeid(operand->type)); return e->type; } else { + ERROR_BLOCK(); + gbString t = type_to_string(operand->type); defer (gb_string_free(t)); - error(operand->expr, "Cannot assign a type '%s' to variable '%.*s'", t, LIT(e->token.string)); + if (is_type_polymorphic(operand->type)) { + error(operand->expr, "Cannot assign a non-specialized polymorphic type '%s' to variable '%.*s'", t, LIT(e->token.string)); + } else { + error(operand->expr, "Cannot assign a type '%s' to variable '%.*s'", t, LIT(e->token.string)); + } if (e->type == nullptr) { error_line("\tThe type of the variable '%.*s' cannot be inferred as a type does not have a default type\n", LIT(e->token.string)); } @@ -60,20 +65,17 @@ Type *check_init_variable(CheckerContext *ctx, Entity *e, Operand *operand, Stri } } - - if (e->type == nullptr) { // NOTE(bill): Use the type of the operand Type *t = operand->type; if (is_type_untyped(t)) { - if (t == t_invalid || is_type_untyped_nil(t)) { - error(e->token, "Invalid use of untyped nil in %.*s", LIT(context_name)); + if (is_type_untyped_uninit(t)) { + error(e->token, "Invalid use of --- in %.*s", LIT(context_name)); e->type = t_invalid; return nullptr; - } - if (t == t_invalid || is_type_untyped_undef(t)) { - error(e->token, "Invalid use of --- in %.*s", LIT(context_name)); + } else if (t == t_invalid || is_type_untyped_nil(t)) { + error(e->token, "Invalid use of untyped nil in %.*s", LIT(context_name)); e->type = t_invalid; return nullptr; } @@ -110,7 +112,7 @@ Type *check_init_variable(CheckerContext *ctx, Entity *e, Operand *operand, Stri return e->type; } -void check_init_variables(CheckerContext *ctx, Entity **lhs, isize lhs_count, Slice const &inits, String context_name) { +gb_internal void check_init_variables(CheckerContext *ctx, Entity **lhs, isize lhs_count, Slice const &inits, String context_name) { if ((lhs == nullptr || lhs_count == 0) && inits.count == 0) { return; } @@ -118,17 +120,11 @@ void check_init_variables(CheckerContext *ctx, Entity **lhs, isize lhs_count, Sl // NOTE(bill): If there is a bad syntax error, rhs > lhs which would mean there would need to be // an extra allocation + TEMPORARY_ALLOCATOR_GUARD(); auto operands = array_make(temporary_allocator(), 0, 2*lhs_count); - check_unpack_arguments(ctx, lhs, lhs_count, &operands, inits, true, false); + check_unpack_arguments(ctx, lhs, lhs_count, &operands, inits, UnpackFlag_AllowOk|UnpackFlag_AllowUndef); isize rhs_count = operands.count; - for_array(i, operands) { - if (operands[i].mode == Addressing_Invalid) { - // TODO(bill): Should I ignore invalid parameters? - // rhs_count--; - } - } - isize max = gb_min(lhs_count, rhs_count); for (isize i = 0; i < max; i++) { Entity *e = lhs[i]; @@ -138,13 +134,21 @@ void check_init_variables(CheckerContext *ctx, Entity **lhs, isize lhs_count, Sl if (d != nullptr) { d->init_expr = o->expr; } + + if (o->type && is_type_no_copy(o->type)) { + begin_error_block(); + if (check_no_copy_assignment(*o, str_lit("initialization"))) { + error_line("\tInitialization of a #no_copy type must be either implicitly zero, a constant literal, or a return value from a call expression"); + } + end_error_block(); + } } if (rhs_count > 0 && lhs_count != rhs_count) { error(lhs[0]->token, "Assignment count mismatch '%td' = '%td'", lhs_count, rhs_count); } } -void check_init_constant(CheckerContext *ctx, Entity *e, Operand *operand) { +gb_internal void check_init_constant(CheckerContext *ctx, Entity *e, Operand *operand) { if (operand->mode == Addressing_Invalid || operand->type == t_invalid || e->type == t_invalid) { @@ -184,7 +188,7 @@ void check_init_constant(CheckerContext *ctx, Entity *e, Operand *operand) { } -bool is_type_distinct(Ast *node) { +gb_internal bool is_type_distinct(Ast *node) { for (;;) { if (node == nullptr) { return false; @@ -217,7 +221,7 @@ bool is_type_distinct(Ast *node) { return false; } -Ast *remove_type_alias_clutter(Ast *node) { +gb_internal Ast *remove_type_alias_clutter(Ast *node) { for (;;) { if (node == nullptr) { return nullptr; @@ -232,17 +236,7 @@ Ast *remove_type_alias_clutter(Ast *node) { } } -isize total_attribute_count(DeclInfo *decl) { - isize attribute_count = 0; - for_array(i, decl->attributes) { - Ast *attr = decl->attributes[i]; - if (attr->kind != Ast_Attribute) continue; - attribute_count += attr->Attribute.elems.count; - } - return attribute_count; -} - -Type *clone_enum_type(CheckerContext *ctx, Type *original_enum_type, Type *named_type) { +gb_internal Type *clone_enum_type(CheckerContext *ctx, Type *original_enum_type, Type *named_type) { // NOTE(bill, 2022-02-05): Stupid edge case for `distinct` declarations // // X :: enum {A, B, C} @@ -288,7 +282,7 @@ Type *clone_enum_type(CheckerContext *ctx, Type *original_enum_type, Type *named return et; } -void check_type_decl(CheckerContext *ctx, Entity *e, Ast *init_expr, Type *def) { +gb_internal void check_type_decl(CheckerContext *ctx, Entity *e, Ast *init_expr, Type *def) { GB_ASSERT(e->type == nullptr); DeclInfo *decl = decl_info_of_entity(e); @@ -372,8 +366,7 @@ void check_type_decl(CheckerContext *ctx, Entity *e, Ast *init_expr, Type *def) Type *t = base_type(e->type); if (t->kind == Type_Enum) { - for_array(i, t->Enum.fields) { - Entity *f = t->Enum.fields[i]; + for (Entity *f : t->Enum.fields) { if (f->kind != Entity_Constant) { continue; } @@ -390,7 +383,7 @@ void check_type_decl(CheckerContext *ctx, Entity *e, Ast *init_expr, Type *def) } -void override_entity_in_scope(Entity *original_entity, Entity *new_entity) { +gb_internal void override_entity_in_scope(Entity *original_entity, Entity *new_entity) { // NOTE(bill): The original_entity's scope may not be same scope that it was inserted into // e.g. file entity inserted into its package scope String original_name = original_entity->token.string; @@ -400,8 +393,8 @@ void override_entity_in_scope(Entity *original_entity, Entity *new_entity) { if (found_scope == nullptr) { return; } - mutex_lock(&found_scope->mutex); - defer (mutex_unlock(&found_scope->mutex)); + rw_mutex_lock(&found_scope->mutex); + defer (rw_mutex_unlock(&found_scope->mutex)); // IMPORTANT NOTE(bill, 2021-04-10): Overriding behaviour was flawed in that the // original entity was still used check checked, but the checking was only @@ -433,7 +426,7 @@ void override_entity_in_scope(Entity *original_entity, Entity *new_entity) { -void check_const_decl(CheckerContext *ctx, Entity *e, Ast *type_expr, Ast *init, Type *named_type) { +gb_internal void check_const_decl(CheckerContext *ctx, Entity *e, Ast *type_expr, Ast *init, Type *named_type) { GB_ASSERT(e->type == nullptr); GB_ASSERT(e->kind == Entity_Constant); init = unparen_expr(init); @@ -596,7 +589,7 @@ void check_const_decl(CheckerContext *ctx, Entity *e, Ast *type_expr, Ast *init, if (operand.mode == Addressing_Invalid || base_type(operand.type) == t_invalid) { gbString str = expr_to_string(init); - error(e->token, "Invalid declaration type '%s'", str); + error(init, "Invalid declaration value '%s'", str); gb_string_free(str); } @@ -609,12 +602,12 @@ void check_const_decl(CheckerContext *ctx, Entity *e, Ast *type_expr, Ast *init, typedef bool TypeCheckSig(Type *t); -bool sig_compare(TypeCheckSig *a, Type *x, Type *y) { +gb_internal bool sig_compare(TypeCheckSig *a, Type *x, Type *y) { x = core_type(x); y = core_type(y); return (a(x) && a(y)); } -bool sig_compare(TypeCheckSig *a, TypeCheckSig *b, Type *x, Type *y) { +gb_internal bool sig_compare(TypeCheckSig *a, TypeCheckSig *b, Type *x, Type *y) { x = core_type(x); y = core_type(y); if (a == b) { @@ -623,7 +616,7 @@ bool sig_compare(TypeCheckSig *a, TypeCheckSig *b, Type *x, Type *y) { return ((a(x) && b(y)) || (b(x) && a(y))); } -bool signature_parameter_similar_enough(Type *x, Type *y) { +gb_internal bool signature_parameter_similar_enough(Type *x, Type *y) { if (sig_compare(is_type_pointer, x, y)) { return true; } @@ -674,7 +667,7 @@ bool signature_parameter_similar_enough(Type *x, Type *y) { } -bool are_signatures_similar_enough(Type *a_, Type *b_) { +gb_internal bool are_signatures_similar_enough(Type *a_, Type *b_) { GB_ASSERT(a_->kind == Type_Proc); GB_ASSERT(b_->kind == Type_Proc); TypeProc *a = &a_->Proc; @@ -704,7 +697,7 @@ bool are_signatures_similar_enough(Type *a_, Type *b_) { return true; } -Entity *init_entity_foreign_library(CheckerContext *ctx, Entity *e) { +gb_internal Entity *init_entity_foreign_library(CheckerContext *ctx, Entity *e) { Ast *ident = nullptr; Entity **foreign_library = nullptr; @@ -747,7 +740,7 @@ Entity *init_entity_foreign_library(CheckerContext *ctx, Entity *e) { return nullptr; } -String handle_link_name(CheckerContext *ctx, Token token, String link_name, String link_prefix) { +gb_internal String handle_link_name(CheckerContext *ctx, Token token, String link_name, String link_prefix) { if (link_prefix.len > 0) { if (link_name.len > 0) { error(token, "'link_name' and 'link_prefix' cannot be used together"); @@ -764,7 +757,7 @@ String handle_link_name(CheckerContext *ctx, Token token, String link_name, Stri return link_name; } -void check_proc_decl(CheckerContext *ctx, Entity *e, DeclInfo *d) { +gb_internal void check_proc_decl(CheckerContext *ctx, Entity *e, DeclInfo *d) { GB_ASSERT(e->type == nullptr); if (d->proc_lit->kind != Ast_ProcLit) { // TOOD(bill): Better error message @@ -834,9 +827,14 @@ void check_proc_decl(CheckerContext *ctx, Entity *e, DeclInfo *d) { if (ac.test) { e->flags |= EntityFlag_Test; } - if (ac.init) { + if (ac.init && ac.fini) { + error(e->token, "A procedure cannot be both declared as @(init) and @(fini)"); + } else if (ac.init) { e->flags |= EntityFlag_Init; + } else if (ac.fini) { + e->flags |= EntityFlag_Fini; } + if (ac.set_cold) { e->flags |= EntityFlag_Cold; } @@ -952,6 +950,7 @@ void check_proc_decl(CheckerContext *ctx, Entity *e, DeclInfo *d) { if (ac.require_declaration) { e->flags |= EntityFlag_Require; + pl->inlining = ProcInlining_no_inline; } @@ -1004,7 +1003,7 @@ void check_proc_decl(CheckerContext *ctx, Entity *e, DeclInfo *d) { GB_ASSERT(pl->body->kind == Ast_BlockStmt); if (!pt->is_polymorphic) { - check_procedure_later(ctx, ctx->file, e->token, d, proc_type, pl->body, pl->tags); + check_procedure_later(ctx->checker, ctx->file, e->token, d, proc_type, pl->body, pl->tags); } } else if (!is_foreign) { if (e->Procedure.is_export) { @@ -1028,7 +1027,7 @@ void check_proc_decl(CheckerContext *ctx, Entity *e, DeclInfo *d) { if (ac.deferred_procedure.entity != nullptr) { e->Procedure.deferred_procedure = ac.deferred_procedure; - mpmc_enqueue(&ctx->checker->procs_with_deferred_to_check, e); + mpsc_enqueue(&ctx->checker->procs_with_deferred_to_check, e); } if (is_foreign) { @@ -1121,7 +1120,7 @@ void check_proc_decl(CheckerContext *ctx, Entity *e, DeclInfo *d) { } } -void check_global_variable_decl(CheckerContext *ctx, Entity *&e, Ast *type_expr, Ast *init_expr) { +gb_internal void check_global_variable_decl(CheckerContext *ctx, Entity *&e, Ast *type_expr, Ast *init_expr) { GB_ASSERT(e->type == nullptr); GB_ASSERT(e->kind == Entity_Variable); @@ -1142,7 +1141,7 @@ void check_global_variable_decl(CheckerContext *ctx, Entity *&e, Ast *type_expr, if (ac.require_declaration) { e->flags |= EntityFlag_Require; - mpmc_enqueue(&ctx->info->required_global_variable_queue, e); + mpsc_enqueue(&ctx->info->required_global_variable_queue, e); } @@ -1156,9 +1155,12 @@ void check_global_variable_decl(CheckerContext *ctx, Entity *&e, Ast *type_expr, if (is_arch_wasm() && e->Variable.thread_local_model.len != 0) { e->Variable.thread_local_model.len = 0; - // NOTE(bill): ignore this message for the time begin + // NOTE(bill): ignore this message for the time being // error(e->token, "@(thread_local) is not supported for this target platform"); } + if(build_context.no_thread_local) { + e->Variable.thread_local_model.len = 0; + } String context_name = str_lit("variable declaration"); @@ -1239,7 +1241,7 @@ void check_global_variable_decl(CheckerContext *ctx, Entity *&e, Ast *type_expr, check_rtti_type_disallowed(e->token, e->type, "A variable declaration is using a type, %s, which has been disallowed"); } -void check_proc_group_decl(CheckerContext *ctx, Entity *&pg_entity, DeclInfo *d) { +gb_internal void check_proc_group_decl(CheckerContext *ctx, Entity *&pg_entity, DeclInfo *d) { GB_ASSERT(pg_entity->kind == Entity_ProcGroup); auto *pge = &pg_entity->ProcGroup; String proc_group_name = pg_entity->token.string; @@ -1253,10 +1255,9 @@ void check_proc_group_decl(CheckerContext *ctx, Entity *&pg_entity, DeclInfo *d) pg_entity->type = t_invalid; PtrSet entity_set = {}; - ptr_set_init(&entity_set, heap_allocator(), 2*pg->args.count); + ptr_set_init(&entity_set, 2*pg->args.count); - for_array(i, pg->args) { - Ast *arg = pg->args[i]; + for (Ast *arg : pg->args) { Entity *e = nullptr; Operand o = {}; if (arg->kind == Ast_Ident) { @@ -1289,7 +1290,7 @@ void check_proc_group_decl(CheckerContext *ctx, Entity *&pg_entity, DeclInfo *d) ptr_set_destroy(&entity_set); - for_array(j, pge->entities) { + for (isize j = 0; j < pge->entities.count; j++) { Entity *p = pge->entities[j]; if (p->type == t_invalid) { // NOTE(bill): This invalid overload has already been handled @@ -1367,7 +1368,7 @@ void check_proc_group_decl(CheckerContext *ctx, Entity *&pg_entity, DeclInfo *d) } -void check_entity_decl(CheckerContext *ctx, Entity *e, DeclInfo *d, Type *named_type) { +gb_internal void check_entity_decl(CheckerContext *ctx, Entity *e, DeclInfo *d, Type *named_type) { if (e->state == EntityState_Resolved) { return; } @@ -1431,15 +1432,46 @@ end:; } +gb_internal void add_deps_from_child_to_parent(DeclInfo *decl) { + if (decl && decl->parent) { + Scope *ps = decl->parent->scope; + if (ps->flags & (ScopeFlag_File & ScopeFlag_Pkg & ScopeFlag_Global)) { + return; + } else { + // NOTE(bill): Add the dependencies from the procedure literal (lambda) + // But only at the procedure level + rw_mutex_shared_lock(&decl->deps_mutex); + rw_mutex_lock(&decl->parent->deps_mutex); + + for (Entity *e : decl->deps) { + ptr_set_add(&decl->parent->deps, e); + } + + rw_mutex_unlock(&decl->parent->deps_mutex); + rw_mutex_shared_unlock(&decl->deps_mutex); + + rw_mutex_shared_lock(&decl->type_info_deps_mutex); + rw_mutex_lock(&decl->parent->type_info_deps_mutex); + + for (Type *t : decl->type_info_deps) { + ptr_set_add(&decl->parent->type_info_deps, t); + } + + rw_mutex_unlock(&decl->parent->type_info_deps_mutex); + rw_mutex_shared_unlock(&decl->type_info_deps_mutex); + } + } +} + struct ProcUsingVar { Entity *e; Entity *uvar; }; -void check_proc_body(CheckerContext *ctx_, Token token, DeclInfo *decl, Type *type, Ast *body) { +gb_internal bool check_proc_body(CheckerContext *ctx_, Token token, DeclInfo *decl, Type *type, Ast *body) { if (body == nullptr) { - return; + return false; } GB_ASSERT(body->kind == Ast_BlockStmt); @@ -1480,8 +1512,7 @@ void check_proc_body(CheckerContext *ctx_, Token token, DeclInfo *decl, Type *ty { if (type->Proc.param_count > 0) { TypeTuple *params = &type->Proc.params->Tuple; - for_array(i, params->variables) { - Entity *e = params->variables[i]; + for (Entity *e : params->variables) { if (e->kind != Entity_Variable) { continue; } @@ -1489,7 +1520,7 @@ void check_proc_body(CheckerContext *ctx_, Token token, DeclInfo *decl, Type *ty continue; } if (is_blank_ident(e->token)) { - error(e->token, "'using' a procedure parameter requires a non blank identifier"); + error(e->token, "'using' a procedure parameter requires a non blank identifier"); break; } @@ -1499,8 +1530,9 @@ void check_proc_body(CheckerContext *ctx_, Token token, DeclInfo *decl, Type *ty if (t->kind == Type_Struct) { Scope *scope = t->Struct.scope; GB_ASSERT(scope != nullptr); - MUTEX_GUARD_BLOCK(scope->mutex) for_array(i, scope->elements.entries) { - Entity *f = scope->elements.entries[i].value; + rw_mutex_lock(&scope->mutex); + for (auto const &entry : scope->elements) { + Entity *f = entry.value; if (f->kind == Entity_Variable) { Entity *uvar = alloc_entity_using_variable(e, f->token, f->type, nullptr); if (is_value) uvar->flags |= EntityFlag_Value; @@ -1509,6 +1541,7 @@ void check_proc_body(CheckerContext *ctx_, Token token, DeclInfo *decl, Type *ty array_add(&using_entities, puv); } } + rw_mutex_unlock(&scope->mutex); } else { error(e->token, "'using' can only be applied to variables of type struct"); break; @@ -1517,45 +1550,50 @@ void check_proc_body(CheckerContext *ctx_, Token token, DeclInfo *decl, Type *ty } } - MUTEX_GUARD_BLOCK(ctx->scope->mutex) for_array(i, using_entities) { - Entity *e = using_entities[i].e; - Entity *uvar = using_entities[i].uvar; - Entity *prev = scope_insert(ctx->scope, uvar, false); + rw_mutex_lock(&ctx->scope->mutex); + for (auto const &entry : using_entities) { + Entity *e = entry.e; + Entity *uvar = entry.uvar; + Entity *prev = scope_insert_no_mutex(ctx->scope, uvar); if (prev != nullptr) { error(e->token, "Namespace collision while 'using' procedure argument '%.*s' of: %.*s", LIT(e->token.string), LIT(prev->token.string)); error_line("%.*s != %.*s\n", LIT(uvar->token.string), LIT(prev->token.string)); break; } } + rw_mutex_unlock(&ctx->scope->mutex); bool where_clause_ok = evaluate_where_clauses(ctx, nullptr, decl->scope, &decl->proc_lit->ProcLit.where_clauses, !decl->where_clauses_evaluated); if (!where_clause_ok) { // NOTE(bill, 2019-08-31): Don't check the body as the where clauses failed - return; + return false; } check_open_scope(ctx, body); { - for_array(i, using_entities) { - Entity *uvar = using_entities[i].uvar; + for (auto const &entry : using_entities) { + Entity *uvar = entry.uvar; Entity *prev = scope_insert(ctx->scope, uvar); gb_unused(prev); // NOTE(bill): Don't err here } - GB_ASSERT(decl->defer_use_checked == false); + GB_ASSERT(decl->proc_checked_state != ProcCheckedState_Checked); + if (decl->defer_use_checked) { + GB_ASSERT(is_type_polymorphic(type, true)); + error(token, "Defer Use Checked: %.*s", LIT(decl->entity->token.string)); + GB_ASSERT(decl->defer_use_checked == false); + } check_stmt_list(ctx, bs->stmts, Stmt_CheckScopeDecls); decl->defer_use_checked = true; - for_array(i, bs->stmts) { - Ast *stmt = bs->stmts[i]; + for (Ast *stmt : bs->stmts) { if (stmt->kind == Ast_ValueDecl) { ast_node(vd, ValueDecl, stmt); - for_array(j, vd->names) { - Ast *name = vd->names[j]; + for (Ast *name : vd->names) { if (!is_blank_ident(name)) { if (name->kind == Ast_Ident) { GB_ASSERT(name->Ident.entity != nullptr); @@ -1590,25 +1628,7 @@ void check_proc_body(CheckerContext *ctx_, Token token, DeclInfo *decl, Type *ty check_scope_usage(ctx->checker, ctx->scope); - if (decl->parent != nullptr) { - Scope *ps = decl->parent->scope; - if (ps->flags & (ScopeFlag_File & ScopeFlag_Pkg & ScopeFlag_Global)) { - return; - } else { - mutex_lock(&ctx->info->deps_mutex); + add_deps_from_child_to_parent(decl); - // NOTE(bill): Add the dependencies from the procedure literal (lambda) - // But only at the procedure level - for_array(i, decl->deps.entries) { - Entity *e = decl->deps.entries[i].ptr; - ptr_set_add(&decl->parent->deps, e); - } - for_array(i, decl->type_info_deps.entries) { - Type *t = decl->type_info_deps.entries[i].ptr; - ptr_set_add(&decl->parent->type_info_deps, t); - } - - mutex_unlock(&ctx->info->deps_mutex); - } - } + return true; } diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 9846199f8..83e44b39f 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -14,10 +14,11 @@ enum CallArgumentError { CallArgumentError_ParameterMissing, CallArgumentError_DuplicateParameter, CallArgumentError_NoneConstantParameter, + CallArgumentError_OutOfOrderParameters, CallArgumentError_MAX, }; -char const *CallArgumentError_strings[CallArgumentError_MAX] = { +gb_global char const *CallArgumentError_strings[CallArgumentError_MAX] = { "None", "NoneProcedureType", "WrongTypes", @@ -33,12 +34,13 @@ char const *CallArgumentError_strings[CallArgumentError_MAX] = { "ParameterMissing", "DuplicateParameter", "NoneConstantParameter", + "OutOfOrderParameters", }; -enum CallArgumentErrorMode { - CallArgumentMode_NoErrors, - CallArgumentMode_ShowErrors, +enum struct CallArgumentErrorMode { + NoErrors, + ShowErrors, }; struct CallArgumentData { @@ -57,7 +59,7 @@ struct ValidIndexAndScore { i64 score; }; -int valid_index_and_score_cmp(void const *a, void const *b) { +gb_internal int valid_index_and_score_cmp(void const *a, void const *b) { i64 si = (cast(ValidIndexAndScore const *)a)->score; i64 sj = (cast(ValidIndexAndScore const *)b)->score; return sj < si ? -1 : sj > si; @@ -65,62 +67,57 @@ int valid_index_and_score_cmp(void const *a, void const *b) { -#define CALL_ARGUMENT_CHECKER(name) CallArgumentError name(CheckerContext *c, Ast *call, Type *proc_type, Entity *entity, Array operands, CallArgumentErrorMode show_error_mode, CallArgumentData *data) -typedef CALL_ARGUMENT_CHECKER(CallArgumentCheckerType); +gb_internal void check_expr (CheckerContext *c, Operand *operand, Ast *expression); +gb_internal void check_multi_expr (CheckerContext *c, Operand *operand, Ast *expression); +gb_internal void check_multi_expr_or_type (CheckerContext *c, Operand *operand, Ast *expression); +gb_internal void check_multi_expr_with_type_hint(CheckerContext *c, Operand *o, Ast *e, Type *type_hint); +gb_internal void check_expr_or_type (CheckerContext *c, Operand *operand, Ast *expression, Type *type_hint); +gb_internal ExprKind check_expr_base (CheckerContext *c, Operand *operand, Ast *expression, Type *type_hint); +gb_internal void check_expr_with_type_hint (CheckerContext *c, Operand *o, Ast *e, Type *t); +gb_internal Type * check_type (CheckerContext *c, Ast *expression); +gb_internal Type * check_type_expr (CheckerContext *c, Ast *expression, Type *named_type); +gb_internal Type * make_optional_ok_type (Type *value, bool typed=true); +gb_internal Entity * check_selector (CheckerContext *c, Operand *operand, Ast *node, Type *type_hint); +gb_internal Entity * check_ident (CheckerContext *c, Operand *o, Ast *n, Type *named_type, Type *type_hint, bool allow_import_name); +gb_internal Entity * find_polymorphic_record_entity (CheckerContext *c, Type *original_type, isize param_count, Array const &ordered_operands, bool *failure); +gb_internal void check_not_tuple (CheckerContext *c, Operand *operand); +gb_internal void convert_to_typed (CheckerContext *c, Operand *operand, Type *target_type); +gb_internal gbString expr_to_string (Ast *expression); +gb_internal gbString expr_to_string (Ast *expression, gbAllocator allocator); +gb_internal void update_untyped_expr_type (CheckerContext *c, Ast *e, Type *type, bool final); +gb_internal bool check_is_terminating (Ast *node, String const &label); +gb_internal bool check_has_break (Ast *stmt, String const &label, bool implicit); +gb_internal void check_stmt (CheckerContext *c, Ast *node, u32 flags); +gb_internal void check_stmt_list (CheckerContext *c, Slice const &stmts, u32 flags); +gb_internal void check_init_constant (CheckerContext *c, Entity *e, Operand *operand); +gb_internal bool check_representable_as_constant(CheckerContext *c, ExactValue in_value, Type *type, ExactValue *out_value); +gb_internal bool check_procedure_type (CheckerContext *c, Type *type, Ast *proc_type_node, Array const *operands = nullptr); +gb_internal void check_struct_type (CheckerContext *c, Type *struct_type, Ast *node, Array *poly_operands, + Type *named_type = nullptr, Type *original_type_for_poly = nullptr); +gb_internal void check_union_type (CheckerContext *c, Type *union_type, Ast *node, Array *poly_operands, + Type *named_type = nullptr, Type *original_type_for_poly = nullptr); + +gb_internal Type * check_init_variable (CheckerContext *c, Entity *e, Operand *operand, String context_name); +gb_internal void check_assignment_error_suggestion(CheckerContext *c, Operand *o, Type *type); +gb_internal void add_map_key_type_dependencies(CheckerContext *ctx, Type *key); -void check_expr (CheckerContext *c, Operand *operand, Ast *expression); -void check_multi_expr (CheckerContext *c, Operand *operand, Ast *expression); -void check_multi_expr_or_type (CheckerContext *c, Operand *operand, Ast *expression); -void check_multi_expr_with_type_hint(CheckerContext *c, Operand *o, Ast *e, Type *type_hint); -void check_expr_or_type (CheckerContext *c, Operand *operand, Ast *expression, Type *type_hint); -ExprKind check_expr_base (CheckerContext *c, Operand *operand, Ast *expression, Type *type_hint); -void check_expr_with_type_hint (CheckerContext *c, Operand *o, Ast *e, Type *t); -Type * check_type (CheckerContext *c, Ast *expression); -Type * check_type_expr (CheckerContext *c, Ast *expression, Type *named_type); -Type * make_optional_ok_type (Type *value, bool typed=true); -Entity * check_selector (CheckerContext *c, Operand *operand, Ast *node, Type *type_hint); -Entity * check_ident (CheckerContext *c, Operand *o, Ast *n, Type *named_type, Type *type_hint, bool allow_import_name); -Entity * find_polymorphic_record_entity (CheckerContext *c, Type *original_type, isize param_count, Array const &ordered_operands, bool *failure); -void check_not_tuple (CheckerContext *c, Operand *operand); -void convert_to_typed (CheckerContext *c, Operand *operand, Type *target_type); -gbString expr_to_string (Ast *expression); -void check_proc_body (CheckerContext *c, Token token, DeclInfo *decl, Type *type, Ast *body); -void update_untyped_expr_type (CheckerContext *c, Ast *e, Type *type, bool final); -bool check_is_terminating (Ast *node, String const &label); -bool check_has_break (Ast *stmt, String const &label, bool implicit); -void check_stmt (CheckerContext *c, Ast *node, u32 flags); -void check_stmt_list (CheckerContext *c, Slice const &stmts, u32 flags); -void check_init_constant (CheckerContext *c, Entity *e, Operand *operand); -bool check_representable_as_constant(CheckerContext *c, ExactValue in_value, Type *type, ExactValue *out_value); -bool check_procedure_type (CheckerContext *c, Type *type, Ast *proc_type_node, Array *operands = nullptr); -void check_struct_type (CheckerContext *c, Type *struct_type, Ast *node, Array *poly_operands, - Type *named_type = nullptr, Type *original_type_for_poly = nullptr); -void check_union_type (CheckerContext *c, Type *union_type, Ast *node, Array *poly_operands, - Type *named_type = nullptr, Type *original_type_for_poly = nullptr); +gb_internal Type *make_soa_struct_slice(CheckerContext *ctx, Ast *array_typ_expr, Ast *elem_expr, Type *elem); +gb_internal Type *make_soa_struct_dynamic_array(CheckerContext *ctx, Ast *array_typ_expr, Ast *elem_expr, Type *elem); -CallArgumentData check_call_arguments (CheckerContext *c, Operand *operand, Type *proc_type, Ast *call); -Type * check_init_variable (CheckerContext *c, Entity *e, Operand *operand, String context_name); +gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 id, Type *type_hint); +gb_internal void check_promote_optional_ok(CheckerContext *c, Operand *x, Type **val_type_, Type **ok_type_); -void check_assignment_error_suggestion(CheckerContext *c, Operand *o, Type *type); -void add_map_key_type_dependencies(CheckerContext *ctx, Type *key); +gb_internal void check_or_else_right_type(CheckerContext *c, Ast *expr, String const &name, Type *right_type); +gb_internal void check_or_else_split_types(CheckerContext *c, Operand *x, String const &name, Type **left_type_, Type **right_type_); +gb_internal void check_or_else_expr_no_value_error(CheckerContext *c, String const &name, Operand const &x, Type *type_hint); +gb_internal void check_or_return_split_types(CheckerContext *c, Operand *x, String const &name, Type **left_type_, Type **right_type_); -Type *make_soa_struct_slice(CheckerContext *ctx, Ast *array_typ_expr, Ast *elem_expr, Type *elem); -Type *make_soa_struct_dynamic_array(CheckerContext *ctx, Ast *array_typ_expr, Ast *elem_expr, Type *elem); - -bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 id, Type *type_hint); - -void check_promote_optional_ok(CheckerContext *c, Operand *x, Type **val_type_, Type **ok_type_); - -void check_or_else_right_type(CheckerContext *c, Ast *expr, String const &name, Type *right_type); -void check_or_else_split_types(CheckerContext *c, Operand *x, String const &name, Type **left_type_, Type **right_type_); -void check_or_else_expr_no_value_error(CheckerContext *c, String const &name, Operand const &x, Type *type_hint); -void check_or_return_split_types(CheckerContext *c, Operand *x, String const &name, Type **left_type_, Type **right_type_); - -bool is_diverging_expr(Ast *expr); +gb_internal bool is_diverging_expr(Ast *expr); +gb_internal isize get_procedure_param_count_excluding_defaults(Type *pt, isize *param_count_); enum LoadDirectiveResult { LoadDirective_Success = 0, @@ -128,7 +125,7 @@ enum LoadDirectiveResult { LoadDirective_NotFound = 2, }; -bool is_load_directive_call(Ast *call) { +gb_internal bool is_load_directive_call(Ast *call) { call = unparen_expr(call); if (call->kind != Ast_CallExpr) { return false; @@ -141,21 +138,21 @@ bool is_load_directive_call(Ast *call) { String name = bd->name.string; return name == "load"; } -LoadDirectiveResult check_load_directive(CheckerContext *c, Operand *operand, Ast *call, Type *type_hint, bool err_on_not_found); +gb_internal LoadDirectiveResult check_load_directive(CheckerContext *c, Operand *operand, Ast *call, Type *type_hint, bool err_on_not_found); -void check_did_you_mean_print(DidYouMeanAnswers *d, char const *prefix = "") { +gb_internal void check_did_you_mean_print(DidYouMeanAnswers *d, char const *prefix = "") { auto results = did_you_mean_results(d); if (results.count != 0) { error_line("\tSuggestion: Did you mean?\n"); - for_array(i, results) { - String const &target = results[i].target; + for (auto const &result : results) { + String const &target = result.target; error_line("\t\t%s%.*s\n", prefix, LIT(target)); // error_line("\t\t%.*s %td\n", LIT(target), results[i].distance); } } } -void populate_check_did_you_mean_objc_entity(StringSet *set, Entity *e, bool is_type) { +gb_internal void populate_check_did_you_mean_objc_entity(StringSet *set, Entity *e, bool is_type) { if (e->kind != Entity_TypeName) { return; } @@ -167,19 +164,16 @@ void populate_check_did_you_mean_objc_entity(StringSet *set, Entity *e, bool is_ GB_ASSERT(t->kind == Type_Struct); if (is_type) { - for_array(i, objc_metadata->type_entries) { - String name = objc_metadata->type_entries[i].name; - string_set_add(set, name); + for (auto const &entry : objc_metadata->type_entries) { + string_set_add(set, entry.name); } } else { - for_array(i, objc_metadata->value_entries) { - String name = objc_metadata->value_entries[i].name; - string_set_add(set, name); + for (auto const &entry : objc_metadata->value_entries) { + string_set_add(set, entry.name); } } - for_array(i, t->Struct.fields) { - Entity *f = t->Struct.fields[i]; + for (Entity *f : t->Struct.fields) { if (f->flags & EntityFlag_Using && f->type != nullptr) { if (f->type->kind == Type_Named && f->type->Named.type_name) { populate_check_did_you_mean_objc_entity(set, f->type->Named.type_name, is_type); @@ -189,69 +183,67 @@ void populate_check_did_you_mean_objc_entity(StringSet *set, Entity *e, bool is_ } -void check_did_you_mean_objc_entity(String const &name, Entity *e, bool is_type, char const *prefix = "") { +gb_internal void check_did_you_mean_objc_entity(String const &name, Entity *e, bool is_type, char const *prefix = "") { ERROR_BLOCK(); GB_ASSERT(e->kind == Entity_TypeName); GB_ASSERT(e->TypeName.objc_metadata != nullptr); auto *objc_metadata = e->TypeName.objc_metadata; - mutex_lock(objc_metadata->mutex); - defer (mutex_unlock(objc_metadata->mutex)); + MUTEX_GUARD(objc_metadata->mutex); StringSet set = {}; - string_set_init(&set, heap_allocator()); defer (string_set_destroy(&set)); populate_check_did_you_mean_objc_entity(&set, e, is_type); DidYouMeanAnswers d = did_you_mean_make(heap_allocator(), set.entries.count, name); defer (did_you_mean_destroy(&d)); - for_array(i, set.entries) { - did_you_mean_append(&d, set.entries[i].value); + for (String const &target : set) { + did_you_mean_append(&d, target); } check_did_you_mean_print(&d, prefix); } -void check_did_you_mean_type(String const &name, Array const &fields, char const *prefix = "") { +gb_internal void check_did_you_mean_type(String const &name, Array const &fields, char const *prefix = "") { ERROR_BLOCK(); DidYouMeanAnswers d = did_you_mean_make(heap_allocator(), fields.count, name); defer (did_you_mean_destroy(&d)); - for_array(i, fields) { - did_you_mean_append(&d, fields[i]->token.string); - } - check_did_you_mean_print(&d, prefix); -} - - -void check_did_you_mean_type(String const &name, Slice const &fields, char const *prefix = "") { - ERROR_BLOCK(); - - DidYouMeanAnswers d = did_you_mean_make(heap_allocator(), fields.count, name); - defer (did_you_mean_destroy(&d)); - - for_array(i, fields) { - did_you_mean_append(&d, fields[i]->token.string); - } - check_did_you_mean_print(&d, prefix); -} - -void check_did_you_mean_scope(String const &name, Scope *scope, char const *prefix = "") { - ERROR_BLOCK(); - - DidYouMeanAnswers d = did_you_mean_make(heap_allocator(), scope->elements.entries.count, name); - defer (did_you_mean_destroy(&d)); - - mutex_lock(&scope->mutex); - for_array(i, scope->elements.entries) { - Entity *e = scope->elements.entries[i].value; + for (Entity *e : fields) { did_you_mean_append(&d, e->token.string); } - mutex_unlock(&scope->mutex); check_did_you_mean_print(&d, prefix); } -Entity *entity_from_expr(Ast *expr) { + +gb_internal void check_did_you_mean_type(String const &name, Slice const &fields, char const *prefix = "") { + ERROR_BLOCK(); + + DidYouMeanAnswers d = did_you_mean_make(heap_allocator(), fields.count, name); + defer (did_you_mean_destroy(&d)); + + for (Entity *e : fields) { + did_you_mean_append(&d, e->token.string); + } + check_did_you_mean_print(&d, prefix); +} + +gb_internal void check_did_you_mean_scope(String const &name, Scope *scope, char const *prefix = "") { + ERROR_BLOCK(); + + DidYouMeanAnswers d = did_you_mean_make(heap_allocator(), scope->elements.count, name); + defer (did_you_mean_destroy(&d)); + + rw_mutex_shared_lock(&scope->mutex); + for (auto const &entry : scope->elements) { + Entity *e = entry.value; + did_you_mean_append(&d, e->token.string); + } + rw_mutex_shared_unlock(&scope->mutex); + check_did_you_mean_print(&d, prefix); +} + +gb_internal Entity *entity_from_expr(Ast *expr) { expr = unparen_expr(expr); switch (expr->kind) { case Ast_Ident: @@ -262,7 +254,7 @@ Entity *entity_from_expr(Ast *expr) { return nullptr; } -void error_operand_not_expression(Operand *o) { +gb_internal void error_operand_not_expression(Operand *o) { if (o->mode == Addressing_Type) { gbString err = expr_to_string(o->expr); error(o->expr, "'%s' is not an expression but a type", err); @@ -271,7 +263,7 @@ void error_operand_not_expression(Operand *o) { } } -void error_operand_no_value(Operand *o) { +gb_internal void error_operand_no_value(Operand *o) { if (o->mode == Addressing_NoValue) { gbString err = expr_to_string(o->expr); Ast *x = unparen_expr(o->expr); @@ -285,16 +277,16 @@ void error_operand_no_value(Operand *o) { } } -void add_map_get_dependencies(CheckerContext *c) { - if (build_context.use_static_map_calls) { +gb_internal void add_map_get_dependencies(CheckerContext *c) { + if (build_context.dynamic_map_calls) { + add_package_dependency(c, "runtime", "__dynamic_map_get"); + } else { add_package_dependency(c, "runtime", "map_desired_position"); add_package_dependency(c, "runtime", "map_probe_distance"); - } else { - add_package_dependency(c, "runtime", "__dynamic_map_get"); } } -void add_map_set_dependencies(CheckerContext *c) { +gb_internal void add_map_set_dependencies(CheckerContext *c) { init_core_source_code_location(c->checker); if (t_map_set_proc == nullptr) { @@ -302,28 +294,28 @@ void add_map_set_dependencies(CheckerContext *c) { t_map_set_proc = alloc_type_proc_from_types(map_set_args, gb_count_of(map_set_args), t_rawptr, false, ProcCC_Odin); } - if (build_context.use_static_map_calls) { + if (build_context.dynamic_map_calls) { + add_package_dependency(c, "runtime", "__dynamic_map_set"); + } else { add_package_dependency(c, "runtime", "__dynamic_map_check_grow"); add_package_dependency(c, "runtime", "map_insert_hash_dynamic"); - } else { - add_package_dependency(c, "runtime", "__dynamic_map_set"); } } -void add_map_reserve_dependencies(CheckerContext *c) { +gb_internal void add_map_reserve_dependencies(CheckerContext *c) { init_core_source_code_location(c->checker); add_package_dependency(c, "runtime", "__dynamic_map_reserve"); } -void check_scope_decls(CheckerContext *c, Slice const &nodes, isize reserve_size) { +gb_internal void check_scope_decls(CheckerContext *c, Slice const &nodes, isize reserve_size) { Scope *s = c->scope; check_collect_entities(c, nodes); - for_array(i, s->elements.entries) { - Entity *e = s->elements.entries[i].value; + for (auto const &entry : s->elements) { + Entity *e = entry.value; switch (e->kind) { case Entity_Constant: case Entity_TypeName: @@ -339,8 +331,8 @@ void check_scope_decls(CheckerContext *c, Slice const &nodes, isize reser } } -bool find_or_generate_polymorphic_procedure(CheckerContext *old_c, Entity *base_entity, Type *type, - Array *param_operands, Ast *poly_def_node, PolyProcData *poly_proc_data) { +gb_internal bool find_or_generate_polymorphic_procedure(CheckerContext *old_c, Entity *base_entity, Type *type, + Array const *param_operands, Ast *poly_def_node, PolyProcData *poly_proc_data) { /////////////////////////////////////////////////////////////////////////////// // // // TODO CLEANUP(bill): This procedure is very messy and hacky. Clean this!!! // @@ -372,9 +364,6 @@ bool find_or_generate_polymorphic_procedure(CheckerContext *old_c, Entity *base_ GB_ASSERT(dst == nullptr); } - mutex_lock(&info->gen_procs_mutex); - defer (mutex_unlock(&info->gen_procs_mutex)); - if (!src->Proc.is_polymorphic || src->Proc.is_poly_specialized) { return false; } @@ -419,8 +408,6 @@ bool find_or_generate_polymorphic_procedure(CheckerContext *old_c, Entity *base_ CheckerContext nctx = *old_c; - nctx.procs_to_check_queue = old_c->procs_to_check_queue; - Scope *scope = create_scope(info, base_entity->scope); scope->flags |= ScopeFlag_Proc; nctx.scope = scope; @@ -441,21 +428,39 @@ bool find_or_generate_polymorphic_procedure(CheckerContext *old_c, Entity *base_ return false; } - auto *found_gen_procs = map_get(&info->gen_procs, base_entity->identifier.load()); - if (found_gen_procs) { - auto procs = *found_gen_procs; - for_array(i, procs) { - Entity *other = procs[i]; + GenProcsData *gen_procs = nullptr; + + GB_ASSERT(base_entity->identifier.load()->kind == Ast_Ident); + GB_ASSERT(base_entity->kind == Entity_Procedure); + + mutex_lock(&base_entity->Procedure.gen_procs_mutex); // @entity-mutex + gen_procs = base_entity->Procedure.gen_procs; + if (gen_procs) { + rw_mutex_shared_lock(&gen_procs->mutex); // @local-mutex + + mutex_unlock(&base_entity->Procedure.gen_procs_mutex); // @entity-mutex + + for (Entity *other : gen_procs->procs) { Type *pt = base_type(other->type); if (are_types_identical(pt, final_proc_type)) { + rw_mutex_shared_unlock(&gen_procs->mutex); // @local-mutex + if (poly_proc_data) { poly_proc_data->gen_entity = other; } return true; } } + + rw_mutex_shared_unlock(&gen_procs->mutex); // @local-mutex + } else { + gen_procs = gb_alloc_item(permanent_allocator(), GenProcsData); + gen_procs->procs.allocator = heap_allocator(); + base_entity->Procedure.gen_procs = gen_procs; + mutex_unlock(&base_entity->Procedure.gen_procs_mutex); // @entity-mutex } + { // LEAK TODO(bill): This is technically a memory leak as it has to generate the type twice bool prev_no_polymorphic_errors = nctx.no_polymorphic_errors; @@ -468,24 +473,39 @@ bool find_or_generate_polymorphic_procedure(CheckerContext *old_c, Entity *base_ // LEAK TODO(bill): Cloning this AST may be leaky Ast *cloned_proc_type_node = clone_ast(pt->node); success = check_procedure_type(&nctx, final_proc_type, cloned_proc_type_node, &operands); - if (!success) { return false; } - if (found_gen_procs) { - auto procs = *found_gen_procs; - for_array(i, procs) { - Entity *other = procs[i]; - Type *pt = base_type(other->type); - if (are_types_identical(pt, final_proc_type)) { - if (poly_proc_data) { - poly_proc_data->gen_entity = other; - } - return true; + rw_mutex_shared_lock(&gen_procs->mutex); // @local-mutex + for (Entity *other : gen_procs->procs) { + Type *pt = base_type(other->type); + if (are_types_identical(pt, final_proc_type)) { + rw_mutex_shared_unlock(&gen_procs->mutex); // @local-mutex + + if (poly_proc_data) { + poly_proc_data->gen_entity = other; } + + DeclInfo *decl = other->decl_info; + if (decl->proc_checked_state != ProcCheckedState_Checked) { + ProcInfo *proc_info = gb_alloc_item(permanent_allocator(), ProcInfo); + proc_info->file = other->file; + proc_info->token = other->token; + proc_info->decl = decl; + proc_info->type = other->type; + proc_info->body = decl->proc_lit->ProcLit.body; + proc_info->tags = other->Procedure.tags;; + proc_info->generated_from_polymorphic = true; + proc_info->poly_def_node = poly_def_node; + + check_procedure_later(nctx.checker, proc_info); + } + + return true; } } + rw_mutex_shared_unlock(&gen_procs->mutex); // @local-mutex } @@ -522,7 +542,8 @@ bool find_or_generate_polymorphic_procedure(CheckerContext *old_c, Entity *base_ d->gen_proc_type = final_proc_type; d->type_expr = pl->type; d->proc_lit = proc_lit; - d->proc_checked = false; + d->proc_checked_state = ProcCheckedState_Unchecked; + d->defer_use_checked = false; Entity *entity = alloc_entity_procedure(nullptr, token, final_proc_type, tags); entity->identifier = ident; @@ -532,7 +553,8 @@ bool find_or_generate_polymorphic_procedure(CheckerContext *old_c, Entity *base_ entity->scope = scope->parent; entity->file = base_entity->file; entity->pkg = base_entity->pkg; - entity->flags &= ~EntityFlag_ProcBodyChecked; + entity->flags = 0; + d->entity = entity; AstFile *file = nullptr; { @@ -543,6 +565,10 @@ bool find_or_generate_polymorphic_procedure(CheckerContext *old_c, Entity *base_ } } + rw_mutex_lock(&gen_procs->mutex); // @local-mutex + array_add(&gen_procs->procs, entity); + rw_mutex_unlock(&gen_procs->mutex); // @local-mutex + ProcInfo *proc_info = gb_alloc_item(permanent_allocator(), ProcInfo); proc_info->file = file; proc_info->token = token; @@ -553,13 +579,6 @@ bool find_or_generate_polymorphic_procedure(CheckerContext *old_c, Entity *base_ proc_info->generated_from_polymorphic = true; proc_info->poly_def_node = poly_def_node; - if (found_gen_procs) { - array_add(found_gen_procs, entity); - } else { - auto array = array_make(heap_allocator()); - array_add(&array, entity); - map_set(&info->gen_procs, base_entity->identifier.load(), array); - } if (poly_proc_data) { poly_proc_data->gen_entity = entity; @@ -568,29 +587,29 @@ bool find_or_generate_polymorphic_procedure(CheckerContext *old_c, Entity *base_ } // NOTE(bill): Check the newly generated procedure body - check_procedure_later(&nctx, proc_info); + check_procedure_later(nctx.checker, proc_info); return true; } -bool check_polymorphic_procedure_assignment(CheckerContext *c, Operand *operand, Type *type, Ast *poly_def_node, PolyProcData *poly_proc_data) { +gb_internal bool check_polymorphic_procedure_assignment(CheckerContext *c, Operand *operand, Type *type, Ast *poly_def_node, PolyProcData *poly_proc_data) { if (operand->expr == nullptr) return false; Entity *base_entity = entity_of_node(operand->expr); if (base_entity == nullptr) return false; return find_or_generate_polymorphic_procedure(c, base_entity, type, nullptr, poly_def_node, poly_proc_data); } -bool find_or_generate_polymorphic_procedure_from_parameters(CheckerContext *c, Entity *base_entity, Array *operands, Ast *poly_def_node, PolyProcData *poly_proc_data) { +gb_internal bool find_or_generate_polymorphic_procedure_from_parameters(CheckerContext *c, Entity *base_entity, Array const *operands, Ast *poly_def_node, PolyProcData *poly_proc_data) { return find_or_generate_polymorphic_procedure(c, base_entity, nullptr, operands, poly_def_node, poly_proc_data); } -bool check_type_specialization_to(CheckerContext *c, Type *specialization, Type *type, bool compound, bool modify_type); -bool is_polymorphic_type_assignable(CheckerContext *c, Type *poly, Type *source, bool compound, bool modify_type); -bool check_cast_internal(CheckerContext *c, Operand *x, Type *type); +gb_internal bool check_type_specialization_to(CheckerContext *c, Type *specialization, Type *type, bool compound, bool modify_type); +gb_internal bool is_polymorphic_type_assignable(CheckerContext *c, Type *poly, Type *source, bool compound, bool modify_type); +gb_internal bool check_cast_internal(CheckerContext *c, Operand *x, Type *type); #define MAXIMUM_TYPE_DISTANCE 10 -i64 check_distance_between_types(CheckerContext *c, Operand *operand, Type *type) { +gb_internal i64 check_distance_between_types(CheckerContext *c, Operand *operand, Type *type) { if (c == nullptr) { GB_ASSERT(operand->mode == Addressing_Value); GB_ASSERT(is_type_typed(operand->type)); @@ -624,11 +643,8 @@ i64 check_distance_between_types(CheckerContext *c, Operand *operand, Type *type Type *src = base_type(s); Type *dst = base_type(type); - if (is_type_untyped_undef(src)) { - if (type_has_undef(dst)) { - return 1; - } - return -1; + if (is_type_untyped_uninit(src)) { + return 1; } if (is_type_untyped_nil(src)) { @@ -658,6 +674,11 @@ i64 check_distance_between_types(CheckerContext *c, Operand *operand, Type *type return 1; } break; + case Basic_UntypedString: + if (is_type_string(dst)) { + return 1; + } + break; case Basic_UntypedFloat: if (is_type_float(dst)) { return 1; @@ -682,23 +703,49 @@ i64 check_distance_between_types(CheckerContext *c, Operand *operand, Type *type } return -1; } - if (src->kind == Type_Basic && src->Basic.kind == Basic_UntypedRune) { - if (is_type_integer(dst) || is_type_rune(dst)) { - if (is_type_typed(type)) { - return 2; + if (src->kind == Type_Basic) { + i64 score = -1; + switch (src->Basic.kind) { + case Basic_UntypedRune: + if (is_type_integer(dst) || is_type_rune(dst)) { + score = 1; } - return 1; - } - return -1; - } - if (src->kind == Type_Basic && src->Basic.kind == Basic_UntypedBool) { - if (is_type_boolean(dst)) { - if (is_type_typed(type)) { - return 2; + break; + case Basic_UntypedInteger: + if (is_type_integer(dst) || is_type_rune(dst)) { + score = 1; } - return 1; + break; + case Basic_UntypedString: + if (is_type_string(dst)) { + score = 1; + } + break; + case Basic_UntypedFloat: + if (is_type_float(dst)) { + score = 1; + } + break; + case Basic_UntypedComplex: + if (is_type_complex(dst)) { + score = 1; + } + if (is_type_quaternion(dst)) { + score = 2; + } + break; + case Basic_UntypedQuaternion: + if (is_type_quaternion(dst)) { + score = 1; + } + break; } - return -1; + if (score > 0) { + if (is_type_typed(dst)) { + score += 1; + } + } + return score; } } } @@ -757,8 +804,7 @@ i64 check_distance_between_types(CheckerContext *c, Operand *operand, Type *type } if (is_type_union(dst)) { - for_array(i, dst->Union.variants) { - Type *vt = dst->Union.variants[i]; + for (Type *vt : dst->Union.variants) { if (are_types_identical(vt, s)) { return 1; } @@ -774,8 +820,7 @@ i64 check_distance_between_types(CheckerContext *c, Operand *operand, Type *type } else if (is_type_untyped(src)) { i64 prev_lowest_score = -1; i64 lowest_score = -1; - for_array(i, dst->Union.variants) { - Type *vt = dst->Union.variants[i]; + for (Type *vt : dst->Union.variants) { i64 score = check_distance_between_types(c, operand, vt); if (score >= 0) { if (lowest_score < 0) { @@ -819,7 +864,7 @@ i64 check_distance_between_types(CheckerContext *c, Operand *operand, Type *type PolyProcData poly_proc_data = {}; if (check_polymorphic_procedure_assignment(c, operand, type, operand->expr, &poly_proc_data)) { Entity *e = poly_proc_data.gen_entity; - add_type_and_value(c->info, operand->expr, Addressing_Value, e->type, {}); + add_type_and_value(c, operand->expr, Addressing_Value, e->type, {}); add_entity_use(c, operand->expr, e); return 4; } @@ -889,7 +934,7 @@ i64 check_distance_between_types(CheckerContext *c, Operand *operand, Type *type } -i64 assign_score_function(i64 distance, bool is_variadic=false) { +gb_internal i64 assign_score_function(i64 distance, bool is_variadic=false) { // 3*x^2 + 1 > x^2 + x + 1 (for positive x) i64 const c = 3*MAXIMUM_TYPE_DISTANCE*MAXIMUM_TYPE_DISTANCE + 1; @@ -902,7 +947,7 @@ i64 assign_score_function(i64 distance, bool is_variadic=false) { } -bool check_is_assignable_to_with_score(CheckerContext *c, Operand *operand, Type *type, i64 *score_, bool is_variadic=false) { +gb_internal bool check_is_assignable_to_with_score(CheckerContext *c, Operand *operand, Type *type, i64 *score_, bool is_variadic=false) { i64 score = 0; i64 distance = check_distance_between_types(c, operand, type); bool ok = distance >= 0; @@ -914,19 +959,19 @@ bool check_is_assignable_to_with_score(CheckerContext *c, Operand *operand, Type } -bool check_is_assignable_to(CheckerContext *c, Operand *operand, Type *type) { +gb_internal bool check_is_assignable_to(CheckerContext *c, Operand *operand, Type *type) { i64 score = 0; return check_is_assignable_to_with_score(c, operand, type, &score); } -bool internal_check_is_assignable_to(Type *src, Type *dst) { +gb_internal bool internal_check_is_assignable_to(Type *src, Type *dst) { Operand x = {}; x.type = src; x.mode = Addressing_Value; return check_is_assignable_to(nullptr, &x, dst); } -AstPackage *get_package_of_type(Type *type) { +gb_internal AstPackage *get_package_of_type(Type *type) { for (;;) { if (type == nullptr) { return nullptr; @@ -964,7 +1009,7 @@ AstPackage *get_package_of_type(Type *type) { // NOTE(bill): 'content_name' is for debugging and error messages -void check_assignment(CheckerContext *c, Operand *operand, Type *type, String context_name) { +gb_internal void check_assignment(CheckerContext *c, Operand *operand, Type *type, String context_name) { check_not_tuple(c, operand); if (operand->mode == Addressing_Invalid) { return; @@ -973,13 +1018,13 @@ void check_assignment(CheckerContext *c, Operand *operand, Type *type, String co if (is_type_untyped(operand->type)) { Type *target_type = type; if (type == nullptr || is_type_any(type)) { - if (type == nullptr && is_type_untyped_nil(operand->type)) { - error(operand->expr, "Use of untyped nil in %.*s", LIT(context_name)); + if (type == nullptr && is_type_untyped_uninit(operand->type)) { + error(operand->expr, "Use of --- in %.*s", LIT(context_name)); operand->mode = Addressing_Invalid; return; } - if (type == nullptr && is_type_untyped_undef(operand->type)) { - error(operand->expr, "Use of --- in %.*s", LIT(context_name)); + if (type == nullptr && is_type_untyped_nil(operand->type)) { + error(operand->expr, "Use of untyped nil in %.*s", LIT(context_name)); operand->mode = Addressing_Invalid; return; } @@ -1007,8 +1052,8 @@ void check_assignment(CheckerContext *c, Operand *operand, Type *type, String co if (type != nullptr && is_type_proc(type)) { Array procs = proc_group_entities(c, *operand); // NOTE(bill): These should be done - for_array(i, procs) { - Type *t = base_type(procs[i]->type); + for (Entity *e : procs) { + Type *t = base_type(e->type); if (t == t_invalid) { continue; } @@ -1016,7 +1061,6 @@ void check_assignment(CheckerContext *c, Operand *operand, Type *type, String co x.mode = Addressing_Value; x.type = t; if (check_is_assignable_to(c, &x, type)) { - Entity *e = procs[i]; add_entity_use(c, operand->expr, e); good = true; break; @@ -1048,8 +1092,8 @@ void check_assignment(CheckerContext *c, Operand *operand, Type *type, String co if (check_is_assignable_to(c, operand, type)) { if (operand->mode == Addressing_Type && is_type_typeid(type)) { - add_type_info_type(c, operand->type); - add_type_and_value(c->info, operand->expr, Addressing_Value, type, exact_value_typeid(operand->type)); + add_type_info_type(c, operand->type); + add_type_and_value(c, operand->expr, Addressing_Value, type, exact_value_typeid(operand->type)); } } else { gbString expr_str = expr_to_string(operand->expr); @@ -1112,7 +1156,7 @@ void check_assignment(CheckerContext *c, Operand *operand, Type *type, String co } } -bool polymorphic_assign_index(Type **gt_, i64 *dst_count, i64 source_count) { +gb_internal bool polymorphic_assign_index(Type **gt_, i64 *dst_count, i64 source_count) { Type *gt = *gt_; GB_ASSERT(gt->kind == Type_Generic); @@ -1141,7 +1185,7 @@ bool polymorphic_assign_index(Type **gt_, i64 *dst_count, i64 source_count) { return false; } -bool is_polymorphic_type_assignable(CheckerContext *c, Type *poly, Type *source, bool compound, bool modify_type) { +gb_internal bool is_polymorphic_type_assignable(CheckerContext *c, Type *poly, Type *source, bool compound, bool modify_type) { Operand o = {Addressing_Value}; o.type = source; switch (poly->kind) { @@ -1441,12 +1485,12 @@ bool is_polymorphic_type_assignable(CheckerContext *c, Type *poly, Type *source, return false; } -bool check_cycle(CheckerContext *c, Entity *curr, bool report) { +gb_internal bool check_cycle(CheckerContext *c, Entity *curr, bool report) { if (curr->state != EntityState_InProgress) { return false; } for_array(i, *c->type_path) { - Entity *prev = (*c->type_path)[i]; + Entity *prev = c->type_path->data[i]; if (prev == curr) { if (report) { error(curr->token, "Illegal declaration cycle of `%.*s`", LIT(curr->token.string)); @@ -1463,7 +1507,7 @@ bool check_cycle(CheckerContext *c, Entity *curr, bool report) { return false; } -Entity *check_ident(CheckerContext *c, Operand *o, Ast *n, Type *named_type, Type *type_hint, bool allow_import_name) { +gb_internal Entity *check_ident(CheckerContext *c, Operand *o, Ast *n, Type *named_type, Type *type_hint, bool allow_import_name) { GB_ASSERT(n->kind == Ast_Ident); o->mode = Addressing_Invalid; o->expr = n; @@ -1511,8 +1555,8 @@ Entity *check_ident(CheckerContext *c, Operand *o, Ast *n, Type *named_type, Typ if (type_hint != nullptr && is_type_proc(type_hint)) { // NOTE(bill): These should be done - for_array(i, procs) { - Type *t = base_type(procs[i]->type); + for (Entity *proc : procs) { + Type *t = base_type(proc->type); if (t == t_invalid) { continue; } @@ -1520,7 +1564,7 @@ Entity *check_ident(CheckerContext *c, Operand *o, Ast *n, Type *named_type, Typ x.mode = Addressing_Value; x.type = t; if (check_is_assignable_to(c, &x, type_hint)) { - e = procs[i]; + e = proc; add_entity_use(c, n, e); skip = true; break; @@ -1612,7 +1656,9 @@ Entity *check_ident(CheckerContext *c, Operand *o, Ast *n, Type *named_type, Typ } return e; case Entity_LibraryName: - error(n, "Use of library '%.*s' not in foreign block", LIT(name)); + if (!allow_import_name) { + error(n, "Use of library '%.*s' not in foreign block", LIT(name)); + } return e; case Entity_Label: @@ -1632,7 +1678,7 @@ Entity *check_ident(CheckerContext *c, Operand *o, Ast *n, Type *named_type, Typ } -bool check_unary_op(CheckerContext *c, Operand *o, Token op) { +gb_internal bool check_unary_op(CheckerContext *c, Operand *o, Token op) { if (o->type == nullptr) { gbString str = expr_to_string(o->expr); error(o->expr, "Expression has no value '%s'", str); @@ -1660,9 +1706,15 @@ bool check_unary_op(CheckerContext *c, Operand *o, Token op) { case Token_Not: if (!is_type_boolean(type)) { + ERROR_BLOCK(); str = expr_to_string(o->expr); - error(op, "Operator '%.*s' is only allowed on boolean expression", LIT(op.string)); + error(op, "Operator '%.*s' is only allowed on boolean expressions", LIT(op.string)); gb_string_free(str); + if (is_type_integer(type)) { + error_line("\tSuggestion: Did you mean to use the bitwise not operator '~'?\n"); + } + } else { + o->type = t_untyped_bool; } break; @@ -1674,7 +1726,7 @@ bool check_unary_op(CheckerContext *c, Operand *o, Token op) { return true; } -bool check_binary_op(CheckerContext *c, Operand *o, Token op) { +gb_internal bool check_binary_op(CheckerContext *c, Operand *o, Token op) { Type *main_type = o->type; // TODO(bill): Handle errors correctly @@ -1785,7 +1837,7 @@ bool check_binary_op(CheckerContext *c, Operand *o, Token op) { } -bool check_representable_as_constant(CheckerContext *c, ExactValue in_value, Type *type, ExactValue *out_value) { +gb_internal bool check_representable_as_constant(CheckerContext *c, ExactValue in_value, Type *type, ExactValue *out_value) { if (in_value.kind == ExactValue_Invalid) { // NOTE(bill): There's already been an error return true; @@ -2000,7 +2052,48 @@ bool check_representable_as_constant(CheckerContext *c, ExactValue in_value, Typ } -void check_assignment_error_suggestion(CheckerContext *c, Operand *o, Type *type) { +gb_internal bool check_integer_exceed_suggestion(CheckerContext *c, Operand *o, Type *type) { + if (is_type_integer(type) && o->value.kind == ExactValue_Integer) { + gbString b = type_to_string(type); + + i64 sz = type_size_of(type); + BigInt *bi = &o->value.value_integer; + if (is_type_unsigned(type)) { + if (big_int_is_neg(bi)) { + error_line("\tA negative value cannot be represented by the unsigned integer type '%s'\n", b); + } else { + BigInt one = big_int_make_u64(1); + BigInt max_size = big_int_make_u64(1); + BigInt bits = big_int_make_i64(8*sz); + big_int_shl_eq(&max_size, &bits); + big_int_sub_eq(&max_size, &one); + String max_size_str = big_int_to_string(temporary_allocator(), &max_size); + error_line("\tThe maximum value that can be represented by '%s' is '%.*s'\n", b, LIT(max_size_str)); + } + } else { + BigInt zero = big_int_make_u64(0); + BigInt one = big_int_make_u64(1); + BigInt max_size = big_int_make_u64(1); + BigInt bits = big_int_make_i64(8*sz - 1); + big_int_shl_eq(&max_size, &bits); + if (big_int_is_neg(bi)) { + big_int_neg(&max_size, &max_size); + String max_size_str = big_int_to_string(temporary_allocator(), &max_size); + error_line("\tThe minimum value that can be represented by '%s' is '%.*s'\n", b, LIT(max_size_str)); + } else { + big_int_sub_eq(&max_size, &one); + String max_size_str = big_int_to_string(temporary_allocator(), &max_size); + error_line("\tThe maximum value that can be represented by '%s' is '%.*s'\n", b, LIT(max_size_str)); + } + } + + gb_string_free(b); + + return true; + } + return false; +} +gb_internal void check_assignment_error_suggestion(CheckerContext *c, Operand *o, Type *type) { gbString a = expr_to_string(o->expr); gbString b = type_to_string(type); defer( @@ -2031,10 +2124,12 @@ void check_assignment_error_suggestion(CheckerContext *c, Operand *o, Type *type error_line("\t whereas slices in general are assumed to be mutable.\n"); } else if (is_type_u8_slice(src) && are_types_identical(dst, t_string) && o->mode != Addressing_Constant) { error_line("\tSuggestion: the expression may be casted to %s\n", b); + } else if (check_integer_exceed_suggestion(c, o, type)) { + return; } } -void check_cast_error_suggestion(CheckerContext *c, Operand *o, Type *type) { +gb_internal void check_cast_error_suggestion(CheckerContext *c, Operand *o, Type *type) { gbString a = expr_to_string(o->expr); gbString b = type_to_string(type); defer( @@ -2070,13 +2165,13 @@ void check_cast_error_suggestion(CheckerContext *c, Operand *o, Type *type) { } } else if (are_types_identical(src, t_string) && is_type_u8_slice(dst)) { error_line("\tSuggestion: a string may be transmuted to %s\n", b); - } else if (is_type_u8_slice(src) && are_types_identical(dst, t_string) && o->mode != Addressing_Constant) { - error_line("\tSuggestion: the expression may be casted to %s\n", b); + } else if (check_integer_exceed_suggestion(c, o, type)) { + return; } } -bool check_is_expressible(CheckerContext *ctx, Operand *o, Type *type) { +gb_internal bool check_is_expressible(CheckerContext *ctx, Operand *o, Type *type) { GB_ASSERT(o->mode == Addressing_Constant); ExactValue out_value = o->value; if (is_type_constant_type(type) && check_representable_as_constant(ctx, o->value, type, &out_value)) { @@ -2097,16 +2192,22 @@ bool check_is_expressible(CheckerContext *ctx, Operand *o, Type *type) { o->mode = Addressing_Invalid; ); + ERROR_BLOCK(); + + if (is_type_numeric(o->type) && is_type_numeric(type)) { if (!is_type_integer(o->type) && is_type_integer(type)) { error(o->expr, "'%s' truncated to '%s', got %s", a, b, s); } else { - ERROR_BLOCK(); - error(o->expr, "Cannot convert numeric value '%s' to '%s' from '%s', got %s", a, b, c, s); + if (are_types_identical(o->type, type)) { + error(o->expr, "Numeric value '%s' from '%s' cannot be represented by '%s'", s, a, b); + } else { + error(o->expr, "Cannot convert numeric value '%s' from '%s' to '%s' from '%s'", s, a, b, c); + } + check_assignment_error_suggestion(ctx, o, type); } } else { - ERROR_BLOCK(); error(o->expr, "Cannot convert '%s' to '%s' from '%s', got %s", a, b, c, s); check_assignment_error_suggestion(ctx, o, type); } @@ -2114,7 +2215,7 @@ bool check_is_expressible(CheckerContext *ctx, Operand *o, Type *type) { } } -bool check_is_not_addressable(CheckerContext *c, Operand *o) { +gb_internal bool check_is_not_addressable(CheckerContext *c, Operand *o) { if (o->mode == Addressing_OptionalOk) { Ast *expr = unselector_expr(o->expr); if (expr->kind != Ast_TypeAssertion) { @@ -2145,7 +2246,7 @@ bool check_is_not_addressable(CheckerContext *c, Operand *o) { return o->mode != Addressing_Variable && o->mode != Addressing_SoaVariable; } -void check_unary_expr(CheckerContext *c, Operand *o, Token op, Ast *node) { +gb_internal void check_unary_expr(CheckerContext *c, Operand *o, Token op, Ast *node) { switch (op.kind) { case Token_And: { // Pointer address if (check_is_not_addressable(c, o)) { @@ -2272,7 +2373,7 @@ void check_unary_expr(CheckerContext *c, Operand *o, Token op, Ast *node) { o->mode = Addressing_Value; } -void add_comparison_procedures_for_fields(CheckerContext *c, Type *t) { +gb_internal void add_comparison_procedures_for_fields(CheckerContext *c, Type *t) { if (t == nullptr) { return; } @@ -2325,7 +2426,7 @@ void add_comparison_procedures_for_fields(CheckerContext *c, Type *t) { } -void check_comparison(CheckerContext *c, Operand *x, Operand *y, TokenKind op) { +gb_internal void check_comparison(CheckerContext *c, Ast *node, Operand *x, Operand *y, TokenKind op) { if (x->mode == Addressing_Type && y->mode == Addressing_Type) { bool comp = are_types_identical(x->type, y->type); switch (op) { @@ -2341,7 +2442,7 @@ void check_comparison(CheckerContext *c, Operand *x, Operand *y, TokenKind op) { if (x->mode == Addressing_Type && is_type_typeid(y->type)) { add_type_info_type(c, x->type); add_type_info_type(c, y->type); - add_type_and_value(c->info, x->expr, Addressing_Value, y->type, exact_value_typeid(x->type)); + add_type_and_value(c, x->expr, Addressing_Value, y->type, exact_value_typeid(x->type)); x->mode = Addressing_Value; x->type = t_untyped_bool; @@ -2349,14 +2450,14 @@ void check_comparison(CheckerContext *c, Operand *x, Operand *y, TokenKind op) { } else if (is_type_typeid(x->type) && y->mode == Addressing_Type) { add_type_info_type(c, x->type); add_type_info_type(c, y->type); - add_type_and_value(c->info, y->expr, Addressing_Value, x->type, exact_value_typeid(y->type)); + add_type_and_value(c, y->expr, Addressing_Value, x->type, exact_value_typeid(y->type)); x->mode = Addressing_Value; x->type = t_untyped_bool; return; } - + TEMPORARY_ALLOCATOR_GUARD(); gbString err_str = nullptr; if (check_is_assignable_to(c, x, y->type) || @@ -2383,13 +2484,11 @@ void check_comparison(CheckerContext *c, Operand *x, Operand *y, TokenKind op) { } if (!defined) { - if (x->type == err_type && is_operand_nil(*x)) { - err_type = y->type; - } - gbString type_string = type_to_string(err_type); - defer (gb_string_free(type_string)); + gbString xs = type_to_string(x->type, temporary_allocator()); + gbString ys = type_to_string(y->type, temporary_allocator()); err_str = gb_string_make(temporary_allocator(), - gb_bprintf("operator '%.*s' not defined for type '%s'", LIT(token_strings[op]), type_string)); + gb_bprintf("operator '%.*s' not defined between the types '%s' and '%s'", LIT(token_strings[op]), xs, ys) + ); } else { Type *comparison_type = x->type; if (x->type == err_type && is_operand_nil(*x)) { @@ -2401,22 +2500,20 @@ void check_comparison(CheckerContext *c, Operand *x, Operand *y, TokenKind op) { } else { gbString xt, yt; if (x->mode == Addressing_ProcGroup) { - xt = gb_string_make(heap_allocator(), "procedure group"); + xt = gb_string_make(temporary_allocator(), "procedure group"); } else { xt = type_to_string(x->type); } if (y->mode == Addressing_ProcGroup) { - yt = gb_string_make(heap_allocator(), "procedure group"); + yt = gb_string_make(temporary_allocator(), "procedure group"); } else { yt = type_to_string(y->type); } err_str = gb_string_make(temporary_allocator(), gb_bprintf("mismatched types '%s' and '%s'", xt, yt)); - gb_string_free(yt); - gb_string_free(xt); } if (err_str != nullptr) { - error(x->expr, "Cannot compare expression, %s", err_str); + error(node, "Cannot compare expression, %s", err_str); x->type = t_untyped_bool; } else { if (x->mode == Addressing_Constant && @@ -2518,7 +2615,7 @@ void check_comparison(CheckerContext *c, Operand *x, Operand *y, TokenKind op) { } -void check_shift(CheckerContext *c, Operand *x, Operand *y, Ast *node, Type *type_hint) { +gb_internal void check_shift(CheckerContext *c, Operand *x, Operand *y, Ast *node, Type *type_hint) { GB_ASSERT(node->kind == Ast_BinaryExpr); ast_node(be, BinaryExpr, node); @@ -2581,10 +2678,12 @@ void check_shift(CheckerContext *c, Operand *x, Operand *y, Ast *node, Type *typ x->type = t_untyped_integer; } + x->expr = node; x->value = exact_value_shift(be->op.kind, x_val, y_val); + if (is_type_typed(x->type)) { - check_is_expressible(c, x, base_type(x->type)); + check_is_expressible(c, x, x->type); } return; } @@ -2637,7 +2736,7 @@ void check_shift(CheckerContext *c, Operand *x, Operand *y, Ast *node, Type *typ -bool check_is_castable_to(CheckerContext *c, Operand *operand, Type *y) { +gb_internal bool check_is_castable_to(CheckerContext *c, Operand *operand, Type *y) { if (check_is_assignable_to(c, operand, y)) { return true; } @@ -2853,7 +2952,7 @@ bool check_is_castable_to(CheckerContext *c, Operand *operand, Type *y) { return false; } -bool check_cast_internal(CheckerContext *c, Operand *x, Type *type) { +gb_internal bool check_cast_internal(CheckerContext *c, Operand *x, Type *type) { bool is_const_expr = x->mode == Addressing_Constant; Type *bt = base_type(type); @@ -2888,7 +2987,7 @@ bool check_cast_internal(CheckerContext *c, Operand *x, Type *type) { } -void check_cast(CheckerContext *c, Operand *x, Type *type) { +gb_internal void check_cast(CheckerContext *c, Operand *x, Type *type) { if (!is_operand_value(*x)) { error(x->expr, "Only values can be casted"); x->mode = Addressing_Invalid; @@ -2899,17 +2998,38 @@ void check_cast(CheckerContext *c, Operand *x, Type *type) { bool can_convert = check_cast_internal(c, x, type); if (!can_convert) { - gbString expr_str = expr_to_string(x->expr); - gbString to_type = type_to_string(type); - gbString from_type = type_to_string(x->type); - error(x->expr, "Cannot cast '%s' as '%s' from '%s'", expr_str, to_type, from_type); - gb_string_free(from_type); - gb_string_free(to_type); - gb_string_free(expr_str); - - check_cast_error_suggestion(c, x, type); + TEMPORARY_ALLOCATOR_GUARD(); + gbString expr_str = expr_to_string(x->expr, temporary_allocator()); + gbString to_type = type_to_string(type, temporary_allocator()); + gbString from_type = type_to_string(x->type, temporary_allocator()); x->mode = Addressing_Invalid; + + begin_error_block(); + error(x->expr, "Cannot cast '%s' as '%s' from '%s'", expr_str, to_type, from_type); + if (is_const_expr) { + gbString val_str = exact_value_to_string(x->value); + if (is_type_float(x->type) && is_type_integer(type)) { + error_line("\t%s cannot be represented without truncation/rounding as the type '%s'\n", val_str, to_type); + + // NOTE(bill): keep the mode and modify the type to minimize errors further on + x->mode = Addressing_Constant; + x->type = type; + } else { + error_line("\t'%s' cannot be represented as the type '%s'\n", val_str, to_type); + if (is_type_numeric(type)) { + // NOTE(bill): keep the mode and modify the type to minimize errors further on + x->mode = Addressing_Constant; + x->type = type; + } + } + gb_string_free(val_str); + + } + check_cast_error_suggestion(c, x, type); + + end_error_block(); + return; } @@ -2932,7 +3052,7 @@ void check_cast(CheckerContext *c, Operand *x, Type *type) { x->type = type; } -bool check_transmute(CheckerContext *c, Ast *node, Operand *o, Type *t) { +gb_internal bool check_transmute(CheckerContext *c, Ast *node, Operand *o, Type *t) { if (!is_operand_value(*o)) { error(o->expr, "'transmute' can only be applied to values"); o->mode = Addressing_Invalid; @@ -3045,7 +3165,7 @@ bool check_transmute(CheckerContext *c, Ast *node, Operand *o, Type *t) { return true; } -bool check_binary_array_expr(CheckerContext *c, Token op, Operand *x, Operand *y) { +gb_internal bool check_binary_array_expr(CheckerContext *c, Token op, Operand *x, Operand *y) { if (is_type_array(x->type) && !is_type_array(y->type)) { if (check_is_assignable_to(c, y, x->type)) { if (check_binary_op(c, x, op)) { @@ -3056,19 +3176,19 @@ bool check_binary_array_expr(CheckerContext *c, Token op, Operand *x, Operand *y return false; } -bool is_ise_expr(Ast *node) { +gb_internal bool is_ise_expr(Ast *node) { node = unparen_expr(node); return node->kind == Ast_ImplicitSelectorExpr; } -bool can_use_other_type_as_type_hint(bool use_lhs_as_type_hint, Type *other_type) { +gb_internal bool can_use_other_type_as_type_hint(bool use_lhs_as_type_hint, Type *other_type) { if (use_lhs_as_type_hint) { // RHS in this case return other_type != nullptr && other_type != t_invalid && is_type_typed(other_type); } return false; } -Type *check_matrix_type_hint(Type *matrix, Type *type_hint) { +gb_internal Type *check_matrix_type_hint(Type *matrix, Type *type_hint) { Type *xt = base_type(matrix); if (type_hint != nullptr) { Type *th = base_type(type_hint); @@ -3088,7 +3208,7 @@ Type *check_matrix_type_hint(Type *matrix, Type *type_hint) { } -void check_binary_matrix(CheckerContext *c, Token const &op, Operand *x, Operand *y, Type *type_hint, bool use_lhs_as_type_hint) { +gb_internal void check_binary_matrix(CheckerContext *c, Token const &op, Operand *x, Operand *y, Type *type_hint, bool use_lhs_as_type_hint) { if (!check_binary_op(c, x, op)) { x->mode = Addressing_Invalid; return; @@ -3199,7 +3319,7 @@ matrix_error: } -void check_binary_expr(CheckerContext *c, Operand *x, Ast *node, Type *type_hint, bool use_lhs_as_type_hint=false) { +gb_internal void check_binary_expr(CheckerContext *c, Operand *x, Ast *node, Type *type_hint, bool use_lhs_as_type_hint=false) { GB_ASSERT(node->kind == Ast_BinaryExpr); Operand y_ = {}, *y = &y_; @@ -3406,7 +3526,7 @@ void check_binary_expr(CheckerContext *c, Operand *x, Ast *node, Type *type_hint if (token_is_comparison(op.kind)) { - check_comparison(c, x, y, op.kind); + check_comparison(c, node, x, y, op.kind); return; } @@ -3565,7 +3685,7 @@ void check_binary_expr(CheckerContext *c, Operand *x, Ast *node, Type *type_hint x->mode = Addressing_Value; } -Operand make_operand_from_node(Ast *node) { +gb_internal Operand make_operand_from_node(Ast *node) { GB_ASSERT(node != nullptr); Operand x = {}; x.expr = node; @@ -3576,13 +3696,13 @@ Operand make_operand_from_node(Ast *node) { } -void update_untyped_expr_type(CheckerContext *c, Ast *e, Type *type, bool final) { +gb_internal void update_untyped_expr_type(CheckerContext *c, Ast *e, Type *type, bool final) { GB_ASSERT(e != nullptr); ExprInfo *old = check_get_expr_info(c, e); if (old == nullptr) { if (type != nullptr && type != t_invalid) { if (e->tav.type == nullptr || e->tav.type == t_invalid) { - add_type_and_value(c->info, e, e->tav.mode, type ? type : e->tav.type, e->tav.value); + add_type_and_value(c, e, e->tav.mode, type ? type : e->tav.type, e->tav.value); if (e->kind == Ast_TernaryIfExpr) { update_untyped_expr_type(c, e->TernaryIfExpr.x, type, final); update_untyped_expr_type(c, e->TernaryIfExpr.y, type, final); @@ -3688,10 +3808,10 @@ void update_untyped_expr_type(CheckerContext *c, Ast *e, Type *type, bool final) return; } - add_type_and_value(c->info, e, old->mode, type, old->value); + add_type_and_value(c, e, old->mode, type, old->value); } -void update_untyped_expr_value(CheckerContext *c, Ast *e, ExactValue value) { +gb_internal void update_untyped_expr_value(CheckerContext *c, Ast *e, ExactValue value) { GB_ASSERT(e != nullptr); ExprInfo *found = check_get_expr_info(c, e); if (found) { @@ -3699,7 +3819,7 @@ void update_untyped_expr_value(CheckerContext *c, Ast *e, ExactValue value) { } } -void convert_untyped_error(CheckerContext *c, Operand *operand, Type *target_type) { +gb_internal void convert_untyped_error(CheckerContext *c, Operand *operand, Type *target_type) { gbString expr_str = expr_to_string(operand->expr); gbString type_str = type_to_string(target_type); gbString from_type_str = type_to_string(operand->type); @@ -3730,7 +3850,7 @@ void convert_untyped_error(CheckerContext *c, Operand *operand, Type *target_typ operand->mode = Addressing_Invalid; } -ExactValue convert_exact_value_for_type(ExactValue v, Type *type) { +gb_internal ExactValue convert_exact_value_for_type(ExactValue v, Type *type) { Type *t = core_type(type); if (is_type_boolean(t)) { // v = exact_value_to_boolean(v); @@ -3748,7 +3868,7 @@ ExactValue convert_exact_value_for_type(ExactValue v, Type *type) { return v; } -void convert_to_typed(CheckerContext *c, Operand *operand, Type *target_type) { +gb_internal void convert_to_typed(CheckerContext *c, Operand *operand, Type *target_type) { GB_ASSERT_NOT_NULL(target_type); if (operand->mode == Addressing_Invalid || operand->mode == Addressing_Type || @@ -3874,7 +3994,9 @@ void convert_to_typed(CheckerContext *c, Operand *operand, Type *target_type) { case Type_Union: - if (!is_operand_nil(*operand) && !is_operand_undef(*operand)) { + if (!is_operand_nil(*operand) && !is_operand_uninit(*operand)) { + TEMPORARY_ALLOCATOR_GUARD(); + isize count = t->Union.variants.count; ValidIndexAndScore *valids = gb_alloc_array(temporary_allocator(), ValidIndexAndScore, count); isize valid_count = 0; @@ -3939,8 +4061,8 @@ void convert_to_typed(CheckerContext *c, Operand *operand, Type *target_type) { error_line("\n\n"); return; - } else if (is_type_untyped_undef(operand->type) && type_has_undef(target_type)) { - target_type = t_untyped_undef; + } else if (is_type_untyped_uninit(operand->type)) { + target_type = t_untyped_uninit; } else if (!is_type_untyped_nil(operand->type) || !type_has_nil(target_type)) { begin_error_block(); defer (end_error_block()); @@ -3973,8 +4095,8 @@ void convert_to_typed(CheckerContext *c, Operand *operand, Type *target_type) { default: - if (is_type_untyped_undef(operand->type) && type_has_undef(target_type)) { - target_type = t_untyped_undef; + if (is_type_untyped_uninit(operand->type)) { + target_type = t_untyped_uninit; } else if (is_type_untyped_nil(operand->type) && type_has_nil(target_type)) { target_type = t_untyped_nil; } else { @@ -3986,8 +4108,8 @@ void convert_to_typed(CheckerContext *c, Operand *operand, Type *target_type) { } if (is_type_any(target_type) && is_type_untyped(operand->type)) { - if (is_type_untyped_nil(operand->type) && is_type_untyped_undef(operand->type)) { - + if (is_type_untyped_nil(operand->type) && is_type_untyped_uninit(operand->type)) { + } else { target_type = default_type(operand->type); } @@ -3997,7 +4119,7 @@ void convert_to_typed(CheckerContext *c, Operand *operand, Type *target_type) { operand->type = target_type; } -bool check_index_value(CheckerContext *c, Type *main_type, bool open_range, Ast *index_value, i64 max_count, i64 *value, Type *type_hint=nullptr) { +gb_internal bool check_index_value(CheckerContext *c, Type *main_type, bool open_range, Ast *index_value, i64 max_count, i64 *value, Type *type_hint=nullptr) { Operand operand = {Addressing_Invalid}; check_expr_with_type_hint(c, &operand, index_value, type_hint); if (operand.mode == Addressing_Invalid) { @@ -4039,10 +4161,10 @@ bool check_index_value(CheckerContext *c, Type *main_type, bool open_range, Ast (c->state_flags & StateFlag_no_bounds_check) == 0) { BigInt i = exact_value_to_integer(operand.value).value_integer; if (i.sign && !is_type_enum(index_type) && !is_type_multi_pointer(main_type)) { + TEMPORARY_ALLOCATOR_GUARD(); String idx_str = big_int_to_string(temporary_allocator(), &i); - gbString expr_str = expr_to_string(operand.expr); + gbString expr_str = expr_to_string(operand.expr, temporary_allocator()); error(operand.expr, "Index '%s' cannot be a negative value, got %.*s", expr_str, LIT(idx_str)); - gb_string_free(expr_str); if (value) *value = 0; return false; } @@ -4102,10 +4224,10 @@ bool check_index_value(CheckerContext *c, Type *main_type, bool open_range, Ast } if (out_of_bounds) { + TEMPORARY_ALLOCATOR_GUARD(); String idx_str = big_int_to_string(temporary_allocator(), &i); - gbString expr_str = expr_to_string(operand.expr); + gbString expr_str = expr_to_string(operand.expr, temporary_allocator()); error(operand.expr, "Index '%s' is out of bounds range 0..<%lld, got %.*s", expr_str, max_count, LIT(idx_str)); - gb_string_free(expr_str); return false; } @@ -4123,7 +4245,7 @@ bool check_index_value(CheckerContext *c, Type *main_type, bool open_range, Ast return true; } -ExactValue get_constant_field_single(CheckerContext *c, ExactValue value, i32 index, bool *success_, bool *finish_) { +gb_internal ExactValue get_constant_field_single(CheckerContext *c, ExactValue value, i32 index, bool *success_, bool *finish_) { if (value.kind == ExactValue_String) { GB_ASSERT(0 <= index && index < value.value_string.len); u8 val = value.value_string[index]; @@ -4150,8 +4272,7 @@ ExactValue get_constant_field_single(CheckerContext *c, ExactValue value, i32 in if (cl->elems[0]->kind == Ast_FieldValue) { if (is_type_struct(node->tav.type)) { bool found = false; - for_array(i, cl->elems) { - Ast *elem = cl->elems[i]; + for (Ast *elem : cl->elems) { if (elem->kind != Ast_FieldValue) { continue; } @@ -4170,8 +4291,7 @@ ExactValue get_constant_field_single(CheckerContext *c, ExactValue value, i32 in value = {}; } } else if (is_type_array(node->tav.type) || is_type_enumerated_array(node->tav.type)) { - for_array(i, cl->elems) { - Ast *elem = cl->elems[i]; + for (Ast *elem : cl->elems) { if (elem->kind != Ast_FieldValue) { continue; } @@ -4271,7 +4391,7 @@ ExactValue get_constant_field_single(CheckerContext *c, ExactValue value, i32 in -ExactValue get_constant_field(CheckerContext *c, Operand const *operand, Selection sel, bool *success_) { +gb_internal ExactValue get_constant_field(CheckerContext *c, Operand const *operand, Selection sel, bool *success_) { if (operand->mode != Addressing_Constant) { if (success_) *success_ = false; return empty_exact_value; @@ -4351,7 +4471,7 @@ ExactValue get_constant_field(CheckerContext *c, Operand const *operand, Selecti return empty_exact_value; } -Type *determine_swizzle_array_type(Type *original_type, Type *type_hint, isize new_count) { +gb_internal Type *determine_swizzle_array_type(Type *original_type, Type *type_hint, isize new_count) { Type *array_type = base_type(type_deref(original_type)); GB_ASSERT(array_type->kind == Type_Array || array_type->kind == Type_SimdVector); if (array_type->kind == Type_SimdVector) { @@ -4378,7 +4498,7 @@ Type *determine_swizzle_array_type(Type *original_type, Type *type_hint, isize n } -bool is_entity_declared_for_selector(Entity *entity, Scope *import_scope, bool *allow_builtin) { +gb_internal bool is_entity_declared_for_selector(Entity *entity, Scope *import_scope, bool *allow_builtin) { bool is_declared = entity != nullptr; if (is_declared) { if (entity->kind == Entity_Builtin) { @@ -4393,7 +4513,7 @@ bool is_entity_declared_for_selector(Entity *entity, Scope *import_scope, bool * } // NOTE(bill, 2022-02-03): see `check_const_decl` for why it exists reasoning -Entity *check_entity_from_ident_or_selector(CheckerContext *c, Ast *node, bool ident_only) { +gb_internal Entity *check_entity_from_ident_or_selector(CheckerContext *c, Ast *node, bool ident_only) { if (node->kind == Ast_Ident) { String name = node->Ident.token.string; return scope_lookup(c->scope, name); @@ -4473,7 +4593,7 @@ Entity *check_entity_from_ident_or_selector(CheckerContext *c, Ast *node, bool i } -Entity *check_selector(CheckerContext *c, Operand *operand, Ast *node, Type *type_hint) { +gb_internal Entity *check_selector(CheckerContext *c, Operand *operand, Ast *node, Type *type_hint) { ast_node(se, SelectorExpr, node); bool check_op_expr = true; @@ -4523,7 +4643,7 @@ Entity *check_selector(CheckerContext *c, Operand *operand, Ast *node, Type *typ entity = scope_lookup_current(import_scope, entity_name); bool allow_builtin = false; if (!is_entity_declared_for_selector(entity, import_scope, &allow_builtin)) { - error(op_expr, "'%.*s' is not declared by '%.*s'", LIT(entity_name), LIT(import_name)); + error(node, "'%.*s' is not declared by '%.*s'", LIT(entity_name), LIT(import_name)); operand->mode = Addressing_Invalid; operand->expr = node; @@ -4536,14 +4656,14 @@ Entity *check_selector(CheckerContext *c, Operand *operand, Ast *node, Type *typ operand->mode = Addressing_ProcGroup; operand->proc_group = entity; - add_type_and_value(c->info, operand->expr, operand->mode, operand->type, operand->value); + add_type_and_value(c, operand->expr, operand->mode, operand->type, operand->value); return entity; } GB_ASSERT_MSG(entity->type != nullptr, "%.*s (%.*s)", LIT(entity->token.string), LIT(entity_strings[entity->kind])); if (!is_entity_exported(entity, allow_builtin)) { gbString sel_str = expr_to_string(selector); - error(op_expr, "'%s' is not exported by '%.*s'", sel_str, LIT(import_name)); + error(node, "'%s' is not exported by '%.*s'", sel_str, LIT(import_name)); gb_string_free(sel_str); // NOTE(bill): make the state valid still, even if it's "invalid" // operand->mode = Addressing_Invalid; @@ -4554,8 +4674,7 @@ Entity *check_selector(CheckerContext *c, Operand *operand, Ast *node, Type *typ if (entity->kind == Entity_ProcGroup) { Array procs = entity->ProcGroup.entities; bool skip = false; - for_array(i, procs) { - Entity *p = procs[i]; + for (Entity *p : procs) { Type *t = base_type(p->type); if (t == t_invalid) { continue; @@ -4705,7 +4824,7 @@ Entity *check_selector(CheckerContext *c, Operand *operand, Ast *node, Type *typ } Entity *swizzle_entity = alloc_entity_variable(nullptr, make_token_ident(field_name), operand->type, EntityState_Resolved); - add_type_and_value(c->info, operand->expr, operand->mode, operand->type, operand->value); + add_type_and_value(c, operand->expr, operand->mode, operand->type, operand->value); return swizzle_entity; } end_of_array_selector_swizzle:; @@ -4715,20 +4834,29 @@ Entity *check_selector(CheckerContext *c, Operand *operand, Ast *node, Type *typ gbString op_str = expr_to_string(op_expr); gbString type_str = type_to_string_shorthand(operand->type); gbString sel_str = expr_to_string(selector); - error(op_expr, "'%s' of type '%s' has no field '%s'", op_str, type_str, sel_str); - if (operand->type != nullptr && selector->kind == Ast_Ident) { - String const &name = selector->Ident.token.string; - Type *bt = base_type(operand->type); - if (operand->type->kind == Type_Named && - operand->type->Named.type_name && - operand->type->Named.type_name->kind == Entity_TypeName && - operand->type->Named.type_name->TypeName.objc_metadata) { - check_did_you_mean_objc_entity(name, operand->type->Named.type_name, operand->mode == Addressing_Type); - } else if (bt->kind == Type_Struct) { - check_did_you_mean_type(name, bt->Struct.fields); - } else if (bt->kind == Type_Enum) { - check_did_you_mean_type(name, bt->Enum.fields); + if (operand->mode == Addressing_Type) { + if (is_type_polymorphic(operand->type, true)) { + error(op_expr, "Type '%s' has no field nor polymorphic parameter '%s'", op_str, sel_str); + } else { + error(op_expr, "Type '%s' has no field '%s'", op_str, sel_str); + } + } else { + error(op_expr, "'%s' of type '%s' has no field '%s'", op_str, type_str, sel_str); + + if (operand->type != nullptr && selector->kind == Ast_Ident) { + String const &name = selector->Ident.token.string; + Type *bt = base_type(operand->type); + if (operand->type->kind == Type_Named && + operand->type->Named.type_name && + operand->type->Named.type_name->kind == Entity_TypeName && + operand->type->Named.type_name->TypeName.objc_metadata) { + check_did_you_mean_objc_entity(name, operand->type->Named.type_name, operand->mode == Addressing_Type); + } else if (bt->kind == Type_Struct) { + check_did_you_mean_type(name, bt->Struct.fields); + } else if (bt->kind == Type_Enum) { + check_did_you_mean_type(name, bt->Enum.fields); + } } } @@ -4749,7 +4877,7 @@ Entity *check_selector(CheckerContext *c, Operand *operand, Ast *node, Type *typ operand->value = field_value; operand->type = entity->type; add_entity_use(c, selector, entity); - add_type_and_value(c->info, operand->expr, operand->mode, operand->type, operand->value); + add_type_and_value(c, operand->expr, operand->mode, operand->type, operand->value); return entity; } @@ -4774,7 +4902,7 @@ Entity *check_selector(CheckerContext *c, Operand *operand, Ast *node, Type *typ operand->value = field_value; operand->type = entity->type; add_entity_use(c, selector, entity); - add_type_and_value(c->info, operand->expr, operand->mode, operand->type, operand->value); + add_type_and_value(c, operand->expr, operand->mode, operand->type, operand->value); return entity; } @@ -4862,12 +4990,12 @@ Entity *check_selector(CheckerContext *c, Operand *operand, Ast *node, Type *typ break; } - add_type_and_value(c->info, operand->expr, operand->mode, operand->type, operand->value); + add_type_and_value(c, operand->expr, operand->mode, operand->type, operand->value); return entity; } -bool is_type_normal_pointer(Type *ptr, Type **elem) { +gb_internal bool is_type_normal_pointer(Type *ptr, Type **elem) { ptr = base_type(ptr); if (is_type_pointer(ptr)) { if (is_type_rawptr(ptr)) { @@ -4879,7 +5007,21 @@ bool is_type_normal_pointer(Type *ptr, Type **elem) { return false; } -bool check_identifier_exists(Scope *s, Ast *node, bool nested = false, Scope **out_scope = nullptr) { +gb_internal bool is_type_valid_atomic_type(Type *elem) { + elem = core_type(elem); + if (is_type_internally_pointer_like(elem)) { + return true; + } + if (elem->kind == Type_BitSet) { + elem = bit_set_to_int(elem); + } + if (elem->kind != Type_Basic) { + return false; + } + return (elem->Basic.flags & (BasicFlag_Boolean|BasicFlag_OrderedNumeric)) != 0; +} + +gb_internal bool check_identifier_exists(Scope *s, Ast *node, bool nested = false, Scope **out_scope = nullptr) { switch (node->kind) { case_ast_node(i, Ident, node); String name = i->token.string; @@ -4909,33 +5051,47 @@ bool check_identifier_exists(Scope *s, Ast *node, bool nested = false, Scope **o return false; } -isize add_dependencies_from_unpacking(CheckerContext *c, Entity **lhs, isize lhs_count, isize tuple_index, isize tuple_count) { +gb_internal isize add_dependencies_from_unpacking(CheckerContext *c, Entity **lhs, isize lhs_count, isize tuple_index, isize tuple_count) { if (lhs != nullptr && c->decl != nullptr) { - mutex_lock(&c->info->deps_mutex); - for (isize j = 0; (tuple_index + j) < lhs_count && j < tuple_count; j++) { Entity *e = lhs[tuple_index + j]; if (e != nullptr) { DeclInfo *decl = decl_info_of_entity(e); if (decl != nullptr) { - for_array(k, decl->deps.entries) { - Entity *dep = decl->deps.entries[k].ptr; + rw_mutex_shared_lock(&decl->deps_mutex); + rw_mutex_lock(&c->decl->deps_mutex); + for (Entity *dep : decl->deps) { ptr_set_add(&c->decl->deps, dep); } + rw_mutex_unlock(&c->decl->deps_mutex); + rw_mutex_shared_unlock(&decl->deps_mutex); } } } - - mutex_unlock(&c->info->deps_mutex); } return tuple_count; } +gb_internal bool check_no_copy_assignment(Operand const &o, String const &context) { + if (o.type && is_type_no_copy(o.type)) { + Ast *expr = unparen_expr(o.expr); + if (expr && o.mode != Addressing_Constant) { + if (expr->kind == Ast_CallExpr) { + // Okay + } else { + error(o.expr, "Invalid use of #no_copy value in %.*s", LIT(context)); + return true; + } + } + } + return false; +} -bool check_assignment_arguments(CheckerContext *ctx, Array const &lhs, Array *operands, Slice const &rhs) { + +gb_internal bool check_assignment_arguments(CheckerContext *ctx, Array const &lhs, Array *operands, Slice const &rhs) { bool optional_ok = false; isize tuple_index = 0; - for_array(i, rhs) { + for (Ast *rhs_expr : rhs) { CheckerContext c_ = *ctx; CheckerContext *c = &c_; @@ -4947,7 +5103,7 @@ bool check_assignment_arguments(CheckerContext *ctx, Array const &lhs, type_hint = lhs[tuple_index].type; } - check_expr_base(c, &o, rhs[i], type_hint); + check_expr_base(c, &o, rhs_expr, type_hint); if (o.mode == Addressing_NoValue) { error_operand_no_value(&o); o.mode = Addressing_Invalid; @@ -4999,9 +5155,10 @@ bool check_assignment_arguments(CheckerContext *ctx, Array const &lhs, } } else { TypeTuple *tuple = &o.type->Tuple; - for_array(j, tuple->variables) { - o.type = tuple->variables[j]->type; + for (Entity *e : tuple->variables) { + o.type = e->type; array_add(operands, o); + check_no_copy_assignment(o, str_lit("assignment")); } tuple_index += tuple->variables.count; @@ -5012,11 +5169,28 @@ bool check_assignment_arguments(CheckerContext *ctx, Array const &lhs, } +typedef u32 UnpackFlags; +enum UnpackFlag : u32 { + UnpackFlag_None = 0, + UnpackFlag_AllowOk = 1<<0, + UnpackFlag_IsVariadic = 1<<1, + UnpackFlag_AllowUndef = 1<<2, +}; + + +gb_internal bool check_unpack_arguments(CheckerContext *ctx, Entity **lhs, isize lhs_count, Array *operands, Slice const &rhs_arguments, UnpackFlags flags) { + bool allow_ok = (flags & UnpackFlag_AllowOk) != 0; + bool is_variadic = (flags & UnpackFlag_IsVariadic) != 0; + bool allow_undef = (flags & UnpackFlag_AllowUndef) != 0; -bool check_unpack_arguments(CheckerContext *ctx, Entity **lhs, isize lhs_count, Array *operands, Slice const &rhs, bool allow_ok, bool is_variadic) { bool optional_ok = false; isize tuple_index = 0; - for_array(i, rhs) { + for (Ast *rhs : rhs_arguments) { + if (rhs->kind == Ast_FieldValue) { + error(rhs, "Invalid use of 'field = value'"); + rhs = rhs->FieldValue.value; + } + CheckerContext c_ = *ctx; CheckerContext *c = &c_; @@ -5024,12 +5198,11 @@ bool check_unpack_arguments(CheckerContext *ctx, Entity **lhs, isize lhs_count, Type *type_hint = nullptr; + if (lhs != nullptr && tuple_index < lhs_count) { // NOTE(bill): override DeclInfo for dependency Entity *e = lhs[tuple_index]; if (e != nullptr) { - // DeclInfo *decl = decl_info_of_entity(e); - // if (decl) c->decl = decl; type_hint = e->type; if (e->flags & EntityFlag_Ellipsis) { GB_ASSERT(is_type_slice(e->type)); @@ -5041,8 +5214,6 @@ bool check_unpack_arguments(CheckerContext *ctx, Entity **lhs, isize lhs_count, // NOTE(bill): override DeclInfo for dependency Entity *e = lhs[lhs_count-1]; if (e != nullptr) { - // DeclInfo *decl = decl_info_of_entity(e); - // if (decl) c->decl = decl; type_hint = e->type; if (e->flags & EntityFlag_Ellipsis) { GB_ASSERT(is_type_slice(e->type)); @@ -5052,14 +5223,23 @@ bool check_unpack_arguments(CheckerContext *ctx, Entity **lhs, isize lhs_count, } } - check_expr_base(c, &o, rhs[i], type_hint); + Ast *rhs_expr = unparen_expr(rhs); + if (allow_undef && rhs_expr != nullptr && rhs_expr->kind == Ast_Uninit) { + // NOTE(bill): Just handle this very specific logic here + o.type = t_untyped_uninit; + o.mode = Addressing_Value; + o.expr = rhs; + add_type_and_value(c, rhs, o.mode, o.type, o.value); + } else { + check_expr_base(c, &o, rhs, type_hint); + } if (o.mode == Addressing_NoValue) { error_operand_no_value(&o); o.mode = Addressing_Invalid; } if (o.type == nullptr || o.type->kind != Type_Tuple) { - if (allow_ok && lhs_count == 2 && rhs.count == 1 && + if (allow_ok && lhs_count == 2 && rhs_arguments.count == 1 && (o.mode == Addressing_MapIndex || o.mode == Addressing_OptionalOk || o.mode == Addressing_OptionalOkPtr)) { Ast *expr = unparen_expr(o.expr); @@ -5092,8 +5272,8 @@ bool check_unpack_arguments(CheckerContext *ctx, Entity **lhs, isize lhs_count, } } else { TypeTuple *tuple = &o.type->Tuple; - for_array(j, tuple->variables) { - o.type = tuple->variables[j]->type; + for (Entity *e : tuple->variables) { + o.type = e->type; array_add(operands, o); } @@ -5105,17 +5285,7 @@ bool check_unpack_arguments(CheckerContext *ctx, Entity **lhs, isize lhs_count, return optional_ok; } - -bool is_expr_constant_zero(Ast *expr) { - GB_ASSERT(expr != nullptr); - auto v = exact_value_to_integer(expr->tav.value); - if (v.kind == ExactValue_Integer) { - return big_int_cmp_zero(&v.value_integer) == 0; - } - return false; -} - -isize get_procedure_param_count_excluding_defaults(Type *pt, isize *param_count_) { +gb_internal isize get_procedure_param_count_excluding_defaults(Type *pt, isize *param_count_) { GB_ASSERT(pt != nullptr); GB_ASSERT(pt->kind == Type_Proc); isize param_count = 0; @@ -5169,7 +5339,36 @@ isize get_procedure_param_count_excluding_defaults(Type *pt, isize *param_count_ } -CALL_ARGUMENT_CHECKER(check_call_arguments_internal) { +gb_internal isize lookup_procedure_parameter(TypeProc *pt, String const ¶meter_name) { + isize param_count = pt->param_count; + for (isize i = 0; i < param_count; i++) { + Entity *e = pt->params->Tuple.variables[i]; + String name = e->token.string; + if (is_blank_ident(name)) { + continue; + } + if (name == parameter_name) { + return i; + } + } + return -1; +} + +gb_internal isize lookup_procedure_parameter(Type *type, String const ¶meter_name) { + type = base_type(type); + GB_ASSERT(type->kind == Type_Proc); + return lookup_procedure_parameter(&type->Proc, parameter_name); +} + +gb_internal CallArgumentError check_call_arguments_internal(CheckerContext *c, Ast *call, + Entity *entity, Type *proc_type, + Array positional_operands, Array const &named_operands, + CallArgumentErrorMode show_error_mode, + CallArgumentData *data) { + TEMPORARY_ALLOCATOR_GUARD(); + + CallArgumentError err = CallArgumentError_None; + ast_node(ce, CallExpr, call); GB_ASSERT(is_type_proc(proc_type)); proc_type = base_type(proc_type); @@ -5180,16 +5379,8 @@ CALL_ARGUMENT_CHECKER(check_call_arguments_internal) { bool variadic = pt->variadic; bool vari_expand = (ce->ellipsis.pos.line != 0); i64 score = 0; - bool show_error = show_error_mode == CallArgumentMode_ShowErrors; + bool show_error = show_error_mode == CallArgumentErrorMode::ShowErrors; - - TypeTuple *param_tuple = nullptr; - if (pt->params != nullptr) { - param_tuple = &pt->params->Tuple; - } - - - CallArgumentError err = CallArgumentError_None; Type *final_proc_type = proc_type; Entity *gen_entity = nullptr; @@ -5207,306 +5398,135 @@ CALL_ARGUMENT_CHECKER(check_call_arguments_internal) { LIT(ce->proc->Ident.token.string)); } err = CallArgumentError_NonVariadicExpand; - } else if (operands.count == 0 && param_count_excluding_defaults == 0) { - err = CallArgumentError_None; - - if (variadic) { - GB_ASSERT(param_tuple != nullptr && param_tuple->variables.count > 0); - Type *t = param_tuple->variables[0]->type; - if (is_type_polymorphic(t)) { - error(call, "Ambiguous call to a polymorphic variadic procedure with no variadic input"); - err = CallArgumentError_AmbiguousPolymorphicVariadic; - } - } - } else { - i32 error_code = 0; - if (operands.count < param_count_excluding_defaults) { - error_code = -1; - } else if (!variadic && operands.count > param_count) { - error_code = +1; - } - if (error_code != 0) { - err = CallArgumentError_TooManyArguments; - char const *err_fmt = "Too many arguments for '%s', expected %td arguments, got %td"; - if (error_code < 0) { - err = CallArgumentError_TooFewArguments; - err_fmt = "Too few arguments for '%s', expected %td arguments, got %td"; - } - - if (show_error) { - gbString proc_str = expr_to_string(ce->proc); - defer (gb_string_free(proc_str)); - error(call, err_fmt, proc_str, param_count_excluding_defaults, operands.count); - - #if 0 - error_line("\t"); - for_array(i, operands) { - if (i > 0) { - error_line(", "); - } - gbString s = expr_to_string(operands[i].expr); - error_line("%s", s); - gb_string_free(s); - } - error_line("\n"); - #endif - } - } else { - // NOTE(bill): Generate the procedure type for this generic instance - if (pt->is_polymorphic && !pt->is_poly_specialized) { - PolyProcData poly_proc_data = {}; - if (find_or_generate_polymorphic_procedure_from_parameters(c, entity, &operands, call, &poly_proc_data)) { - gen_entity = poly_proc_data.gen_entity; - GB_ASSERT(is_type_proc(gen_entity->type)); - final_proc_type = gen_entity->type; - } else { - err = CallArgumentError_WrongTypes; - } - } - - GB_ASSERT(is_type_proc(final_proc_type)); - TypeProc *pt = &final_proc_type->Proc; - - GB_ASSERT(pt->params != nullptr); - auto sig_params = pt->params->Tuple.variables; - isize operand_index = 0; - isize max_operand_count = gb_min(param_count, operands.count); - for (; operand_index < max_operand_count; operand_index++) { - Entity *e = sig_params[operand_index]; - Type *t = e->type; - Operand o = operands[operand_index]; - if (o.expr != nullptr) { - call->viral_state_flags |= o.expr->viral_state_flags; - } - - if (e->kind == Entity_TypeName) { - // GB_ASSERT(!variadic); - if (o.mode == Addressing_Invalid) { - continue; - } else if (o.mode != Addressing_Type) { - if (show_error) { - error(o.expr, "Expected a type for the argument '%.*s'", LIT(e->token.string)); - } - err = CallArgumentError_WrongTypes; - } - - if (are_types_identical(e->type, o.type)) { - score += assign_score_function(1); - } else { - score += assign_score_function(MAXIMUM_TYPE_DISTANCE); - } - - continue; - } - - bool param_is_variadic = pt->variadic && pt->variadic_index == operand_index; - - i64 s = 0; - if (!check_is_assignable_to_with_score(c, &o, t, &s, param_is_variadic)) { - bool ok = false; - if (e->flags & EntityFlag_AutoCast) { - ok = check_is_castable_to(c, &o, t); - } else if (e->flags & EntityFlag_AnyInt) { - if (is_type_integer(t)) { - ok = check_is_castable_to(c, &o, t); - } - } - if (ok) { - s = assign_score_function(MAXIMUM_TYPE_DISTANCE); - } else { - if (show_error) { - check_assignment(c, &o, t, str_lit("argument")); - } - // TODO(bill, 2021-05-05): Is this incorrect logic to only fail if there is ambiguity for definite? - if (o.mode == Addressing_Invalid) { - err = CallArgumentError_WrongTypes; - } - } - } else if (show_error) { - check_assignment(c, &o, t, str_lit("argument")); - } - score += s; - - if (e->flags & EntityFlag_ConstInput) { - if (o.mode != Addressing_Constant) { - if (show_error) { - error(o.expr, "Expected a constant value for the argument '%.*s'", LIT(e->token.string)); - } - err = CallArgumentError_NoneConstantParameter; - } - } - - if (o.mode == Addressing_Type && is_type_typeid(e->type)) { - add_type_info_type(c, o.type); - add_type_and_value(c->info, o.expr, Addressing_Value, e->type, exact_value_typeid(o.type)); - } else if (show_error && is_type_untyped(o.type)) { - update_untyped_expr_type(c, o.expr, t, true); - } - - } - - if (variadic) { - bool variadic_expand = false; - Type *slice = sig_params[param_count]->type; - GB_ASSERT(is_type_slice(slice)); - Type *elem = base_type(slice)->Slice.elem; - Type *t = elem; - - if (is_type_polymorphic(t)) { - error(call, "Ambiguous call to a polymorphic variadic procedure with no variadic input"); - err = CallArgumentError_AmbiguousPolymorphicVariadic; - } - - for (; operand_index < operands.count; operand_index++) { - Operand o = operands[operand_index]; - if (vari_expand) { - variadic_expand = true; - t = slice; - if (operand_index != param_count) { - if (show_error) { - error(o.expr, "'..' in a variadic procedure can only have one variadic argument at the end"); - } - if (data) { - data->score = score; - data->result_type = final_proc_type->Proc.results; - data->gen_entity = gen_entity; - } - return CallArgumentError_MultipleVariadicExpand; - } - } - i64 s = 0; - if (!check_is_assignable_to_with_score(c, &o, t, &s, true)) { - if (show_error) { - check_assignment(c, &o, t, str_lit("argument")); - } - err = CallArgumentError_WrongTypes; - } else if (show_error) { - check_assignment(c, &o, t, str_lit("argument")); - } - score += s; - if (is_type_any(elem)) { - add_type_info_type(c, o.type); - } - if (o.mode == Addressing_Type && is_type_typeid(t)) { - add_type_info_type(c, o.type); - add_type_and_value(c->info, o.expr, Addressing_Value, t, exact_value_typeid(o.type)); - } else if (show_error && is_type_untyped(o.type)) { - update_untyped_expr_type(c, o.expr, t, true); - } - } - } - } } - if (data) { - data->score = score; - data->result_type = final_proc_type->Proc.results; - data->gen_entity = gen_entity; - add_type_and_value(c->info, ce->proc, Addressing_Value, final_proc_type, {}); - } - - return err; -} - -bool is_call_expr_field_value(AstCallExpr *ce) { - GB_ASSERT(ce != nullptr); - - if (ce->args.count == 0) { - return false; - } - return ce->args[0]->kind == Ast_FieldValue; -} - -isize lookup_procedure_parameter(TypeProc *pt, String parameter_name) { - isize param_count = pt->param_count; - for (isize i = 0; i < param_count; i++) { - Entity *e = pt->params->Tuple.variables[i]; - String name = e->token.string; - if (is_blank_ident(name)) { - continue; - } - if (name == parameter_name) { - return i; - } - } - return -1; -} -isize lookup_procedure_result(TypeProc *pt, String result_name) { - isize result_count = pt->result_count; - for (isize i = 0; i < result_count; i++) { - Entity *e = pt->results->Tuple.variables[i]; - String name = e->token.string; - if (is_blank_ident(name)) { - continue; - } - if (name == result_name) { - return i; - } - } - return -1; -} - -CALL_ARGUMENT_CHECKER(check_named_call_arguments) { - ast_node(ce, CallExpr, call); - GB_ASSERT(is_type_proc(proc_type)); - proc_type = base_type(proc_type); - TypeProc *pt = &proc_type->Proc; - - i64 score = 0; - bool show_error = show_error_mode == CallArgumentMode_ShowErrors; - CallArgumentError err = CallArgumentError_None; - - isize param_count = pt->param_count; - bool *visited = gb_alloc_array(temporary_allocator(), bool, param_count); - auto ordered_operands = array_make(temporary_allocator(), param_count); + GB_ASSERT(ce->split_args); + auto visited = slice_make(temporary_allocator(), pt->param_count); + auto ordered_operands = array_make(temporary_allocator(), pt->param_count); defer ({ - for_array(i, ordered_operands) { - Operand const &o = ordered_operands[i]; + for (Operand const &o : ordered_operands) { if (o.expr != nullptr) { call->viral_state_flags |= o.expr->viral_state_flags; } } }); - for_array(i, ce->args) { - Ast *arg = ce->args[i]; - ast_node(fv, FieldValue, arg); - if (fv->field->kind != Ast_Ident) { - if (show_error) { - gbString expr_str = expr_to_string(fv->field); - error(arg, "Invalid parameter name '%s' in procedure call", expr_str); - gb_string_free(expr_str); - } - err = CallArgumentError_InvalidFieldValue; - continue; + isize positional_operand_count = positional_operands.count; + if (variadic) { + positional_operand_count = gb_min(positional_operands.count, pt->variadic_index); + } else if (positional_operand_count > pt->param_count) { + err = CallArgumentError_TooManyArguments; + char const *err_fmt = "Too many arguments for '%s', expected %td arguments, got %td"; + if (show_error) { + gbString proc_str = expr_to_string(ce->proc); + defer (gb_string_free(proc_str)); + error(call, err_fmt, proc_str, param_count_excluding_defaults, positional_operands.count); } - String name = fv->field->Ident.token.string; - isize index = lookup_procedure_parameter(pt, name); - if (index < 0) { - if (show_error) { - error(arg, "No parameter named '%.*s' for this procedure type", LIT(name)); + return err; + } + positional_operand_count = gb_min(positional_operand_count, pt->param_count); + + for (isize i = 0; i < positional_operand_count; i++) { + ordered_operands[i] = positional_operands[i]; + visited[i] = true; + } + + auto variadic_operands = slice(slice_from_array(positional_operands), positional_operand_count, positional_operands.count); + + if (named_operands.count != 0) { + GB_ASSERT(ce->split_args->named.count == named_operands.count); + for_array(i, ce->split_args->named) { + Ast *arg = ce->split_args->named[i]; + Operand operand = named_operands[i]; + + ast_node(fv, FieldValue, arg); + if (fv->field->kind != Ast_Ident) { + if (show_error) { + gbString expr_str = expr_to_string(fv->field); + error(arg, "Invalid parameter name '%s' in procedure call", expr_str); + gb_string_free(expr_str); + } + err = CallArgumentError_InvalidFieldValue; + continue; } - err = CallArgumentError_ParameterNotFound; - continue; + String name = fv->field->Ident.token.string; + isize param_index = lookup_procedure_parameter(pt, name); + if (param_index < 0) { + if (show_error) { + error(arg, "No parameter named '%.*s' for this procedure type", LIT(name)); + } + err = CallArgumentError_ParameterNotFound; + continue; + } + if (visited[param_index]) { + if (show_error) { + error(arg, "Duplicate parameter '%.*s' in procedure call", LIT(name)); + } + err = CallArgumentError_DuplicateParameter; + continue; + } + + visited[param_index] = true; + ordered_operands[param_index] = operand; } - if (visited[index]) { + } + + isize dummy_argument_count = 0; + bool actually_variadic = false; + + if (variadic) { + if (visited[pt->variadic_index] && + positional_operand_count < positional_operands.count) { if (show_error) { - error(arg, "Duplicate parameter '%.*s' in procedure call", LIT(name)); + String name = pt->params->Tuple.variables[pt->variadic_index]->token.string; + error(call, "Variadic parameters already handled with a named argument '%.*s' in procedure call", LIT(name)); } err = CallArgumentError_DuplicateParameter; - continue; + } else if (!visited[pt->variadic_index]) { + visited[pt->variadic_index] = true; + + Operand *variadic_operand = &ordered_operands[pt->variadic_index]; + + if (vari_expand) { + GB_ASSERT(variadic_operands.count != 0); + *variadic_operand = variadic_operands[0]; + variadic_operand->type = default_type(variadic_operand->type); + actually_variadic = true; + } else { + AstFile *f = call->file(); + + // HACK(bill): this is an awful hack + Operand o = {}; + o.mode = Addressing_Value; + o.expr = ast_ident(f, make_token_ident("nil")); + o.expr->Ident.token.pos = ast_token(call).pos; + if (variadic_operands.count != 0) { + actually_variadic = true; + o.expr->Ident.token.pos = ast_token(variadic_operands[0].expr).pos; + + Entity *vt = pt->params->Tuple.variables[pt->variadic_index]; + if (is_type_polymorphic(vt->type)) { + o.type = alloc_type_slice(default_type(variadic_operands[0].type)); + } else { + o.type = vt->type; + } + } else { + dummy_argument_count += 1; + o.type = t_untyped_nil; + } + *variadic_operand = o; + } } - visited[index] = true; - ordered_operands[index] = operands[i]; } - // NOTE(bill): Check for default values and missing parameters - isize param_count_to_check = param_count; - if (pt->variadic) { - param_count_to_check--; + for (Operand const &o : ordered_operands) { + if (o.mode != Addressing_Invalid) { + check_no_copy_assignment(o, str_lit("procedure call expression")); + } } - for (isize i = 0; i < param_count_to_check; i++) { + + for (isize i = 0; i < pt->param_count; i++) { if (!visited[i]) { Entity *e = pt->params->Tuple.variables[i]; if (is_blank_ident(e->token)) { @@ -5514,6 +5534,11 @@ CALL_ARGUMENT_CHECKER(check_named_call_arguments) { } if (e->kind == Entity_Variable) { if (e->Variable.param_value.kind != ParameterValue_Invalid) { + ordered_operands[i].mode = Addressing_Value; + ordered_operands[i].type = e->type; + ordered_operands[i].expr = e->Variable.param_value.original_ast_expr; + + dummy_argument_count += 1; score += assign_score_function(1); continue; } @@ -5536,101 +5561,175 @@ CALL_ARGUMENT_CHECKER(check_named_call_arguments) { } } - Entity *gen_entity = nullptr; - if (pt->is_polymorphic && !pt->is_poly_specialized && err == CallArgumentError_None) { - PolyProcData poly_proc_data = {}; - if (find_or_generate_polymorphic_procedure_from_parameters(c, entity, &ordered_operands, call, &poly_proc_data)) { - gen_entity = poly_proc_data.gen_entity; - Type *gept = base_type(gen_entity->type); - GB_ASSERT(is_type_proc(gept)); - proc_type = gept; - pt = &gept->Proc; - } else { - err = CallArgumentError_WrongTypes; - } - } - - - for (isize i = 0; i < param_count; i++) { - Entity *e = pt->params->Tuple.variables[i]; - Operand *o = &ordered_operands[i]; - bool param_is_variadic = pt->variadic && pt->variadic_index == i; - - - if (o->mode == Addressing_Invalid) { - if (param_is_variadic) { - Type *slice = e->type; - GB_ASSERT(is_type_slice(slice)); - Type *elem = base_type(slice)->Slice.elem; - if (is_type_polymorphic(elem)) { - error(call, "Ambiguous call to a polymorphic variadic procedure with no variadic input"); - err = CallArgumentError_AmbiguousPolymorphicVariadic; - return err; + auto eval_param_and_score = [](CheckerContext *c, Operand *o, Type *param_type, CallArgumentError &err, bool param_is_variadic, Entity *e, bool show_error) -> i64 { + i64 s = 0; + if (!check_is_assignable_to_with_score(c, o, param_type, &s, param_is_variadic)) { + bool ok = false; + if (e && e->flags & EntityFlag_AnyInt) { + if (is_type_integer(param_type)) { + ok = check_is_castable_to(c, o, param_type); } } - continue; - } - - if (e->kind == Entity_TypeName) { - GB_ASSERT(pt->is_polymorphic); - if (o->mode != Addressing_Type) { + if (ok) { + s = assign_score_function(MAXIMUM_TYPE_DISTANCE); + } else { if (show_error) { - error(o->expr, "Expected a type for the argument '%.*s'", LIT(e->token.string)); + check_assignment(c, o, param_type, str_lit("procedure argument")); } err = CallArgumentError_WrongTypes; } - if (are_types_identical(e->type, o->type)) { - score += assign_score_function(1); - } else { - score += assign_score_function(MAXIMUM_TYPE_DISTANCE); - } - } else { - i64 s = 0; - if (!check_is_assignable_to_with_score(c, o, e->type, &s, param_is_variadic)) { - bool ok = false; - if (e->flags & EntityFlag_AutoCast) { - ok = check_is_castable_to(c, o, e->type); + + } else if (show_error) { + check_assignment(c, o, param_type, str_lit("procedure argument")); + } + + if (e && e->flags & EntityFlag_ConstInput) { + if (o->mode != Addressing_Constant) { + if (show_error) { + error(o->expr, "Expected a constant value for the argument '%.*s'", LIT(e->token.string)); } - if (ok) { - s = assign_score_function(MAXIMUM_TYPE_DISTANCE); - } else { + err = CallArgumentError_NoneConstantParameter; + } + } + + + if (!err && is_type_any(param_type)) { + add_type_info_type(c, o->type); + } + if (o->mode == Addressing_Type && is_type_typeid(param_type)) { + add_type_info_type(c, o->type); + add_type_and_value(c, o->expr, Addressing_Value, param_type, exact_value_typeid(o->type)); + } else if (show_error && is_type_untyped(o->type)) { + update_untyped_expr_type(c, o->expr, param_type, true); + } + + return s; + }; + + + if (ordered_operands.count == 0 && param_count_excluding_defaults == 0) { + err = CallArgumentError_None; + + if (variadic) { + GB_ASSERT(pt->params != nullptr && pt->params->Tuple.variables.count > 0); + Type *t = pt->params->Tuple.variables[0]->type; + if (is_type_polymorphic(t)) { + if (show_error) { + error(call, "Ambiguous call to a polymorphic variadic procedure with no variadic input"); + } + err = CallArgumentError_AmbiguousPolymorphicVariadic; + } + } + } else { + if (pt->is_polymorphic && !pt->is_poly_specialized && err == CallArgumentError_None) { + PolyProcData poly_proc_data = {}; + if (find_or_generate_polymorphic_procedure_from_parameters(c, entity, &ordered_operands, call, &poly_proc_data)) { + gen_entity = poly_proc_data.gen_entity; + Type *gept = base_type(gen_entity->type); + GB_ASSERT(is_type_proc(gept)); + final_proc_type = gen_entity->type; + pt = &gept->Proc; + + } else { + err = CallArgumentError_WrongTypes; + } + } + + for (isize i = 0; i < pt->param_count; i++) { + Operand *o = &ordered_operands[i]; + if (o->mode == Addressing_Invalid) { + continue; + } + + Entity *e = pt->params->Tuple.variables[i]; + bool param_is_variadic = pt->variadic && pt->variadic_index == i; + + if (e->kind == Entity_TypeName) { + GB_ASSERT(pt->is_polymorphic); + if (o->mode != Addressing_Type) { if (show_error) { - check_assignment(c, o, e->type, str_lit("procedure argument")); + error(o->expr, "Expected a type for the argument '%.*s'", LIT(e->token.string)); } err = CallArgumentError_WrongTypes; } - - if (e->flags & EntityFlag_ConstInput) { - if (o->mode != Addressing_Constant) { - if (show_error) { - error(o->expr, "Expected a constant value for the argument '%.*s'", LIT(e->token.string)); - } - err = CallArgumentError_NoneConstantParameter; - } + if (are_types_identical(e->type, o->type)) { + score += assign_score_function(1); + } else { + score += assign_score_function(MAXIMUM_TYPE_DISTANCE); } - } else if (show_error) { - check_assignment(c, o, e->type, str_lit("procedure argument")); + continue; } - score += s; + + if (param_is_variadic) { + continue; + } + + score += eval_param_and_score(c, o, e->type, err, param_is_variadic, e, show_error); + } + } + + if (variadic) { + Type *slice = pt->params->Tuple.variables[pt->variadic_index]->type; + GB_ASSERT(is_type_slice(slice)); + Type *elem = base_type(slice)->Slice.elem; + Type *t = elem; + + if (is_type_polymorphic(t)) { + error(call, "Ambiguous call to a polymorphic variadic procedure with no variadic input %s", type_to_string(final_proc_type)); + err = CallArgumentError_AmbiguousPolymorphicVariadic; } - if (o->mode == Addressing_Type && is_type_typeid(e->type)) { - add_type_info_type(c, o->type); - add_type_and_value(c->info, o->expr, Addressing_Value, e->type, exact_value_typeid(o->type)); + for_array(operand_index, variadic_operands) { + Operand *o = &variadic_operands[operand_index]; + if (vari_expand) { + t = slice; + if (operand_index > 0) { + if (show_error) { + error(o->expr, "'..' in a variadic procedure can only have one variadic argument at the end"); + } + if (data) { + data->score = score; + data->result_type = final_proc_type->Proc.results; + data->gen_entity = gen_entity; + } + return CallArgumentError_MultipleVariadicExpand; + } + } + score += eval_param_and_score(c, o, t, err, true, nullptr, show_error); } } if (data) { data->score = score; - data->result_type = pt->results; + data->result_type = final_proc_type->Proc.results; data->gen_entity = gen_entity; - add_type_and_value(c->info, ce->proc, Addressing_Value, proc_type, {}); + + + Ast *proc_lit = nullptr; + if (ce->proc->tav.value.kind == ExactValue_Procedure) { + Ast *vp = unparen_expr(ce->proc->tav.value.value_procedure); + if (vp && vp->kind == Ast_ProcLit) { + proc_lit = vp; + } + } + if (proc_lit == nullptr) { + add_type_and_value(c, ce->proc, Addressing_Value, final_proc_type, {}); + } } return err; } -Entity **populate_proc_parameter_list(CheckerContext *c, Type *proc_type, isize *lhs_count_, bool *is_variadic) { +gb_internal bool is_call_expr_field_value(AstCallExpr *ce) { + GB_ASSERT(ce != nullptr); + + if (ce->args.count == 0) { + return false; + } + return ce->args[0]->kind == Ast_FieldValue; +} + +gb_internal Entity **populate_proc_parameter_list(CheckerContext *c, Type *proc_type, isize *lhs_count_, bool *is_variadic) { Entity **lhs = nullptr; isize lhs_count = -1; @@ -5669,10 +5768,9 @@ Entity **populate_proc_parameter_list(CheckerContext *c, Type *proc_type, isize } -bool evaluate_where_clauses(CheckerContext *ctx, Ast *call_expr, Scope *scope, Slice *clauses, bool print_err) { +gb_internal bool evaluate_where_clauses(CheckerContext *ctx, Ast *call_expr, Scope *scope, Slice *clauses, bool print_err) { if (clauses != nullptr) { - for_array(i, *clauses) { - Ast *clause = (*clauses)[i]; + for (Ast *clause : *clauses) { Operand o = {}; check_expr(ctx, &o, clause); if (o.mode != Addressing_Constant) { @@ -5693,8 +5791,8 @@ bool evaluate_where_clauses(CheckerContext *ctx, Ast *call_expr, Scope *scope, S if (scope != nullptr) { isize print_count = 0; - for_array(j, scope->elements.entries) { - Entity *e = scope->elements.entries[j].value; + for (auto const &entry : scope->elements) { + Entity *e = entry.value; switch (e->kind) { case Entity_TypeName: { if (print_count == 0) error_line("\n\tWith the following definitions:\n"); @@ -5735,537 +5833,659 @@ bool evaluate_where_clauses(CheckerContext *ctx, Ast *call_expr, Scope *scope, S return true; } +gb_internal bool check_named_arguments(CheckerContext *c, Type *type, Slice const &named_args, Array *named_operands, bool show_error) { + bool success = true; -CallArgumentData check_call_arguments(CheckerContext *c, Operand *operand, Type *proc_type, Ast *call, Slice const &args) { - ast_node(ce, CallExpr, call); - - CallArgumentCheckerType *call_checker = check_call_arguments_internal; - Array operands = {}; - defer (array_free(&operands)); - - Type *result_type = t_invalid; - - if (is_call_expr_field_value(ce)) { - call_checker = check_named_call_arguments; - - operands = array_make(heap_allocator(), args.count); - - // NOTE(bill): This is give type hints for the named parameters - // in order to improve the type inference system - - StringMap type_hint_map = {}; // Key: String - string_map_init(&type_hint_map, heap_allocator(), 2*args.count); - defer (string_map_destroy(&type_hint_map)); - - Type *ptype = nullptr; - bool single_case = true; - - if (operand->mode == Addressing_ProcGroup) { - single_case = false; - Array procs = proc_group_entities(c, *operand); - if (procs.count == 1) { - ptype = procs[0]->type; - single_case = true; - } - } else { - ptype = proc_type; + type = base_type(type); + if (named_args.count > 0) { + TypeProc *pt = nullptr; + if (is_type_proc(type)) { + pt = &type->Proc; } - if (single_case) { - Type *bptype = base_type(ptype); - if (is_type_proc(bptype)) { - TypeProc *pt = &bptype->Proc; - TypeTuple *param_tuple = nullptr; - if (pt->params != nullptr) { - param_tuple = &pt->params->Tuple; - } - if (param_tuple != nullptr) { - for_array(i, param_tuple->variables) { - Entity *e = param_tuple->variables[i]; - if (is_blank_ident(e->token)) { - continue; - } - string_map_set(&type_hint_map, e->token.string, e->type); - } + for_array(i, named_args) { + Ast *arg = named_args[i]; + if (arg->kind != Ast_FieldValue) { + if (show_error) { + error(arg, "Expected a 'field = value'"); } + return false; } - } else { - Array procs = proc_group_entities(c, *operand); - for_array(j, procs) { - Type *proc_type = base_type(procs[j]->type); - if (is_type_proc(proc_type)) { - TypeProc *pt = &proc_type->Proc; - TypeTuple *param_tuple = nullptr; - if (pt->params != nullptr) { - param_tuple = &pt->params->Tuple; - } - if (param_tuple == nullptr) { - continue; - } - for_array(i, param_tuple->variables) { - Entity *e = param_tuple->variables[i]; - if (is_blank_ident(e->token)) { - continue; - } - StringHashKey key = string_hash_string(e->token.string); - Type **found = string_map_get(&type_hint_map, key); - if (found) { - Type *t = *found; - if (t == nullptr) { - // NOTE(bill): Ambiguous named parameter across all types - continue; - } - if (are_types_identical(t, e->type)) { - // NOTE(bill): No need to set again - } else { - // NOTE(bill): Ambiguous named parameter across all types so set it to a nullptr - string_map_set(&type_hint_map, key, cast(Type *)nullptr); - } - } else { - string_map_set(&type_hint_map, key, e->type); - } - } - } - } - - } - - - for_array(i, args) { - Ast *arg = args[i]; ast_node(fv, FieldValue, arg); - Ast *field = fv->field; + if (fv->field->kind != Ast_Ident) { + if (show_error) { + gbString expr_str = expr_to_string(fv->field); + error(arg, "Invalid parameter name '%s' in procedure call", expr_str); + gb_string_free(expr_str); + } + success = false; + continue; + } + String key = fv->field->Ident.token.string; + Ast *value = fv->value; Type *type_hint = nullptr; - - if (field != nullptr && field->kind == Ast_Ident) { - String key = field->Ident.token.string; - Type **found = string_map_get(&type_hint_map, key); - if (found) { - type_hint = *found; + if (pt) { + isize param_index = lookup_procedure_parameter(pt, key); + if (param_index < 0) { + if (show_error) { + error(value, "No parameter named '%.*s' for this procedure type", LIT(key)); + } + success = false; + continue; } + + Entity *e = pt->params->Tuple.variables[param_index]; + if (!is_type_polymorphic(e->type)) { + type_hint = e->type; + } + } - check_expr_or_type(c, &operands[i], fv->value, type_hint); + Operand o = {}; + check_expr_with_type_hint(c, &o, value, type_hint); + if (o.mode == Addressing_Invalid) { + success = false; + } + array_add(named_operands, o); } - } else { - operands = array_make(heap_allocator(), 0, 2*args.count); - Entity **lhs = nullptr; - isize lhs_count = -1; - bool is_variadic = false; - if (proc_type != nullptr && is_type_proc(proc_type)) { - lhs = populate_proc_parameter_list(c, proc_type, &lhs_count, &is_variadic); - } - if (operand->mode != Addressing_ProcGroup) { - check_unpack_arguments(c, lhs, lhs_count, &operands, args, false, is_variadic); + + } + return success; +} + +gb_internal bool check_call_arguments_single(CheckerContext *c, Ast *call, Operand *operand, + Entity *e, Type *proc_type, + Array const &positional_operands, Array const &named_operands, + CallArgumentErrorMode show_error_mode, + CallArgumentData *data) { + + bool return_on_failure = show_error_mode == CallArgumentErrorMode::NoErrors; + + Ast *ident = operand->expr; + while (ident->kind == Ast_SelectorExpr) { + Ast *s = ident->SelectorExpr.selector; + ident = s; + } + + if (e == nullptr) { + e = entity_of_node(ident); + if (e != nullptr) { + proc_type = e->type; } } - if (operand->mode == Addressing_ProcGroup) { - check_entity_decl(c, operand->proc_group, nullptr, nullptr); + GB_ASSERT(proc_type != nullptr); + proc_type = base_type(proc_type); + GB_ASSERT(proc_type->kind == Type_Proc); - auto procs = proc_group_entities_cloned(c, *operand); + CallArgumentError err = check_call_arguments_internal(c, call, e, proc_type, positional_operands, named_operands, show_error_mode, data); + if (return_on_failure && err != CallArgumentError_None) { + return false; + } - if (procs.count > 1) { - isize max_arg_count = args.count; - for_array(i, args) { - // NOTE(bill): The only thing that may have multiple values - // will be a call expression (assuming `or_return` and `()` will be stripped) - Ast *arg = strip_or_return_expr(args[i]); + Entity *entity_to_use = data->gen_entity != nullptr ? data->gen_entity : e; + if (!return_on_failure && entity_to_use != nullptr) { + add_entity_use(c, ident, entity_to_use); + update_untyped_expr_type(c, operand->expr, entity_to_use->type, true); + add_type_and_value(c, operand->expr, operand->mode, entity_to_use->type, operand->value); + } + + if (data->gen_entity != nullptr) { + Entity *e = data->gen_entity; + DeclInfo *decl = data->gen_entity->decl_info; + CheckerContext ctx = *c; + ctx.scope = decl->scope; + ctx.decl = decl; + ctx.proc_name = e->token.string; + ctx.curr_proc_decl = decl; + ctx.curr_proc_sig = e->type; + + GB_ASSERT(decl->proc_lit->kind == Ast_ProcLit); + bool ok = evaluate_where_clauses(&ctx, call, decl->scope, &decl->proc_lit->ProcLit.where_clauses, !return_on_failure); + if (return_on_failure) { + if (!ok) { + return false; + } + + } else { + decl->where_clauses_evaluated = true; + if (ok && (data->gen_entity->flags & EntityFlag_ProcBodyChecked) == 0) { + check_procedure_later(c->checker, e->file, e->token, decl, e->type, decl->proc_lit->ProcLit.body, decl->proc_lit->ProcLit.tags); + } + if (is_type_proc(data->gen_entity->type)) { + Type *t = base_type(entity_to_use->type); + data->result_type = t->Proc.results; + } + } + } + + return true; +} + + +gb_internal CallArgumentData check_call_arguments_proc_group(CheckerContext *c, Operand *operand, Ast *call) { + ast_node(ce, CallExpr, call); + GB_ASSERT(ce->split_args != nullptr); + + Slice const &positional_args = ce->split_args->positional; + Slice const &named_args = ce->split_args->named; + + CallArgumentData data = {}; + data.result_type = t_invalid; + + GB_ASSERT(operand->mode == Addressing_ProcGroup); + auto procs = proc_group_entities_cloned(c, *operand); + + if (procs.count > 1) { + isize max_arg_count = positional_args.count + named_args.count; + for (Ast *arg : positional_args) { + // NOTE(bill): The only thing that may have multiple values + // will be a call expression (assuming `or_return` and `()` will be stripped) + arg = strip_or_return_expr(arg); + if (arg && arg->kind == Ast_CallExpr) { + max_arg_count = ISIZE_MAX; + break; + } + } + if (max_arg_count != ISIZE_MAX) for (Ast *arg : named_args) { + // NOTE(bill): The only thing that may have multiple values + // will be a call expression (assuming `or_return` and `()` will be stripped) + if (arg->kind == Ast_FieldValue) { + arg = strip_or_return_expr(arg->FieldValue.value); if (arg && arg->kind == Ast_CallExpr) { max_arg_count = ISIZE_MAX; break; } } + } - for (isize proc_index = 0; proc_index < procs.count; /**/) { - Entity *proc = procs[proc_index]; - Type *pt = base_type(proc->type); - if (!(pt != nullptr && is_type_proc(pt))) { - proc_index++; - continue; + // ignore named arguments first + for (Ast *arg : named_args) { + if (arg->kind != Ast_FieldValue) { + continue; + } + ast_node(fv, FieldValue, arg); + if (fv->field->kind != Ast_Ident) { + continue; + } + String key = fv->field->Ident.token.string; + for (isize proc_index = procs.count-1; proc_index >= 0; proc_index--) { + Type *t = procs[proc_index]->type; + if (is_type_proc(t)) { + isize param_index = lookup_procedure_parameter(t, key); + if (param_index < 0) { + array_unordered_remove(&procs, proc_index); + } } + } + } - isize param_count = 0; - isize param_count_excluding_defaults = get_procedure_param_count_excluding_defaults(pt, ¶m_count); + if (procs.count == 0) { + // if any of the named arguments are wrong, the `procs` will be empty + // just start from scratch + array_free(&procs); + procs = proc_group_entities_cloned(c, *operand); + } - if (param_count_excluding_defaults > max_arg_count) { - array_unordered_remove(&procs, proc_index); + // filter by positional argument length + for (isize proc_index = 0; proc_index < procs.count; /**/) { + Entity *proc = procs[proc_index]; + Type *pt = base_type(proc->type); + if (!(pt != nullptr && is_type_proc(pt))) { + proc_index++; + continue; + } + + isize param_count = 0; + isize param_count_excluding_defaults = get_procedure_param_count_excluding_defaults(pt, ¶m_count); + + if (param_count_excluding_defaults > max_arg_count) { + array_unordered_remove(&procs, proc_index); + continue; + } + proc_index++; + } + } + + Entity **lhs = nullptr; + isize lhs_count = -1; + bool is_variadic = false; + + auto positional_operands = array_make(heap_allocator(), 0, 0); + auto named_operands = array_make(heap_allocator(), 0, 0); + defer (array_free(&positional_operands)); + defer (array_free(&named_operands)); + + if (procs.count == 1) { + Entity *e = procs[0]; + + lhs = populate_proc_parameter_list(c, e->type, &lhs_count, &is_variadic); + check_unpack_arguments(c, lhs, lhs_count, &positional_operands, positional_args, is_variadic ? UnpackFlag_IsVariadic : UnpackFlag_None); + + if (check_named_arguments(c, e->type, named_args, &named_operands, true)) { + check_call_arguments_single(c, call, operand, + e, e->type, + positional_operands, named_operands, + CallArgumentErrorMode::ShowErrors, + &data); + } + return data; + } + + { + // NOTE(bill, 2019-07-13): This code is used to improve the type inference for procedure groups + // where the same positional parameter has the same type value (and ellipsis) + bool proc_arg_count_all_equal = true; + isize proc_arg_count = -1; + for (Entity *p : procs) { + Type *pt = base_type(p->type); + if (pt != nullptr && is_type_proc(pt)) { + if (proc_arg_count < 0) { + proc_arg_count = pt->Proc.param_count; } else { - proc_index++; + if (proc_arg_count != pt->Proc.param_count) { + proc_arg_count_all_equal = false; + break; + } } } } - if (procs.count == 1) { - Ast *ident = operand->expr; - while (ident->kind == Ast_SelectorExpr) { - Ast *s = ident->SelectorExpr.selector; - ident = s; - } + if (proc_arg_count >= 0 && proc_arg_count_all_equal) { + lhs_count = proc_arg_count; + if (lhs_count > 0) { + lhs = gb_alloc_array(heap_allocator(), Entity *, lhs_count); + for (isize param_index = 0; param_index < lhs_count; param_index++) { + Entity *e = nullptr; + for (Entity *p : procs) { + Type *pt = base_type(p->type); + if (!(pt != nullptr && is_type_proc(pt))) { + continue; + } - Entity *e = procs[0]; - - Entity **lhs = nullptr; - isize lhs_count = -1; - bool is_variadic = false; - lhs = populate_proc_parameter_list(c, e->type, &lhs_count, &is_variadic); - check_unpack_arguments(c, lhs, lhs_count, &operands, args, false, is_variadic); - - CallArgumentData data = {}; - CallArgumentError err = call_checker(c, call, e->type, e, operands, CallArgumentMode_ShowErrors, &data); - if (err != CallArgumentError_None) { - // handle error - } - Entity *entity_to_use = data.gen_entity != nullptr ? data.gen_entity : e; - add_entity_use(c, ident, entity_to_use); - if (entity_to_use != nullptr) { - update_untyped_expr_type(c, operand->expr, entity_to_use->type, true); - } - return data; - } - - - Entity **lhs = nullptr; - isize lhs_count = -1; - - { - // NOTE(bill, 2019-07-13): This code is used to improve the type inference for procedure groups - // where the same positional parameter has the same type value (and ellipsis) - bool proc_arg_count_all_equal = true; - isize proc_arg_count = -1; - for_array(i, procs) { - Entity *p = procs[i]; - Type *pt = base_type(p->type); - if (pt != nullptr && is_type_proc(pt)) { - if (proc_arg_count < 0) { - proc_arg_count = pt->Proc.param_count; - } else { - if (proc_arg_count != pt->Proc.param_count) { - proc_arg_count_all_equal = false; + if (e == nullptr) { + e = pt->Proc.params->Tuple.variables[param_index]; + } else { + Entity *f = pt->Proc.params->Tuple.variables[param_index]; + if (e == f) { + continue; + } + if (are_types_identical(e->type, f->type)) { + bool ee = (e->flags & EntityFlag_Ellipsis) != 0; + bool fe = (f->flags & EntityFlag_Ellipsis) != 0; + if (ee == fe) { + continue; + } + } + // NOTE(bill): Entities are not close enough to be used + e = nullptr; break; } } - } - } - - - - if (proc_arg_count >= 0 && proc_arg_count_all_equal) { - lhs_count = proc_arg_count; - if (lhs_count > 0) { - lhs = gb_alloc_array(heap_allocator(), Entity *, lhs_count); - for (isize param_index = 0; param_index < lhs_count; param_index++) { - Entity *e = nullptr; - for_array(j, procs) { - Entity *p = procs[j]; - Type *pt = base_type(p->type); - if (pt != nullptr && is_type_proc(pt)) { - if (e == nullptr) { - e = pt->Proc.params->Tuple.variables[param_index]; - } else { - Entity *f = pt->Proc.params->Tuple.variables[param_index]; - if (e == f) { - continue; - } - if (are_types_identical(e->type, f->type)) { - bool ee = (e->flags & EntityFlag_Ellipsis) != 0; - bool fe = (f->flags & EntityFlag_Ellipsis) != 0; - if (ee == fe) { - continue; - } - } - // NOTE(bill): Entities are not close enough to be used - e = nullptr; - break; - } - } - } - lhs[param_index] = e; - } + lhs[param_index] = e; } } } + } + check_unpack_arguments(c, lhs, lhs_count, &positional_operands, positional_args, is_variadic ? UnpackFlag_IsVariadic : UnpackFlag_None); - check_unpack_arguments(c, lhs, lhs_count, &operands, args, false, false); - - if (lhs != nullptr) { - gb_free(heap_allocator(), lhs); - } - - auto valids = array_make(heap_allocator(), 0, procs.count); - defer (array_free(&valids)); - - auto proc_entities = array_make(heap_allocator(), 0, procs.count*2 + 1); - defer (array_free(&proc_entities)); - for_array(i, procs) { - array_add(&proc_entities, procs[i]); - } - - - gbString expr_name = expr_to_string(operand->expr); - defer (gb_string_free(expr_name)); - - for_array(i, procs) { - Entity *p = procs[i]; - Type *pt = base_type(p->type); - if (pt != nullptr && is_type_proc(pt)) { - CallArgumentError err = CallArgumentError_None; - CallArgumentData data = {}; - CheckerContext ctx = *c; - - ctx.no_polymorphic_errors = true; - ctx.allow_polymorphic_types = is_type_polymorphic(pt); - ctx.hide_polymorphic_errors = true; - - err = call_checker(&ctx, call, pt, p, operands, CallArgumentMode_NoErrors, &data); - if (err != CallArgumentError_None) { - continue; - } - isize index = i; - - if (data.gen_entity != nullptr) { - Entity *e = data.gen_entity; - DeclInfo *decl = data.gen_entity->decl_info; - ctx.scope = decl->scope; - ctx.decl = decl; - ctx.proc_name = e->token.string; - ctx.curr_proc_decl = decl; - ctx.curr_proc_sig = e->type; - - GB_ASSERT(decl->proc_lit->kind == Ast_ProcLit); - if (!evaluate_where_clauses(&ctx, call, decl->scope, &decl->proc_lit->ProcLit.where_clauses, false)) { - continue; - } - - array_add(&proc_entities, data.gen_entity); - index = proc_entities.count-1; - } - - ValidIndexAndScore item = {}; - item.index = index; - item.score = data.score; - array_add(&valids, item); - } - } - - if (valids.count > 1) { - gb_sort_array(valids.data, valids.count, valid_index_and_score_cmp); - i64 best_score = valids[0].score; - Entity *best_entity = proc_entities[valids[0].index]; - GB_ASSERT(best_entity != nullptr); - for (isize i = 1; i < valids.count; i++) { - if (best_score > valids[i].score) { - valids.count = i; - break; - } - if (best_entity == proc_entities[valids[i].index]) { - valids.count = i; - break; - } - } - } - - - if (valids.count == 0) { - begin_error_block(); - defer (end_error_block()); - - error(operand->expr, "No procedures or ambiguous call for procedure group '%s' that match with the given arguments", expr_name); - if (operands.count == 0) { - error_line("\tNo given arguments\n"); - } else { - error_line("\tGiven argument types: ("); - for_array(i, operands) { - Operand o = operands[i]; - if (i > 0) error_line(", "); - gbString type = type_to_string(o.type); - defer (gb_string_free(type)); - error_line("%s", type); - } - error_line(")\n"); - } - - if (procs.count > 0) { - error_line("Did you mean to use one of the following:\n"); - } - for_array(i, procs) { - Entity *proc = procs[i]; - TokenPos pos = proc->token.pos; - Type *t = base_type(proc->type); - if (t == t_invalid) continue; - GB_ASSERT(t->kind == Type_Proc); - gbString pt; - defer (gb_string_free(pt)); - if (t->Proc.node != nullptr) { - pt = expr_to_string(t->Proc.node); - } else { - pt = type_to_string(t); - } - String prefix = {}; - String prefix_sep = {}; - if (proc->pkg) { - prefix = proc->pkg->name; - prefix_sep = str_lit("."); - } - String name = proc->token.string; - - char const *sep = "::"; - if (proc->kind == Entity_Variable) { - sep = ":="; - } - error_line("\t%.*s%.*s%.*s %s %s at %s\n", LIT(prefix), LIT(prefix_sep), LIT(name), sep, pt, token_pos_to_string(pos)); - } - if (procs.count > 0) { - error_line("\n"); - } - - result_type = t_invalid; - } else if (valids.count > 1) { - begin_error_block(); - defer (end_error_block()); - - error(operand->expr, "Ambiguous procedure group call '%s' that match with the given arguments", expr_name); - error_line("\tGiven argument types: ("); - for_array(i, operands) { - Operand o = operands[i]; - if (i > 0) error_line(", "); - gbString type = type_to_string(o.type); - defer (gb_string_free(type)); - error_line("%s", type); - } - error_line(")\n"); - - for (isize i = 0; i < valids.count; i++) { - Entity *proc = proc_entities[valids[i].index]; - GB_ASSERT(proc != nullptr); - TokenPos pos = proc->token.pos; - Type *t = base_type(proc->type); GB_ASSERT(t->kind == Type_Proc); - gbString pt = nullptr; - defer (gb_string_free(pt)); - if (t->Proc.node != nullptr) { - pt = expr_to_string(t->Proc.node); - } else { - pt = type_to_string(t); - } - String name = proc->token.string; - char const *sep = "::"; - if (proc->kind == Entity_Variable) { - sep = ":="; - } - error_line("\t%.*s %s %s ", LIT(name), sep, pt); - if (proc->decl_info->proc_lit != nullptr) { - GB_ASSERT(proc->decl_info->proc_lit->kind == Ast_ProcLit); - auto *pl = &proc->decl_info->proc_lit->ProcLit; - if (pl->where_token.kind != Token_Invalid) { - error_line("\n\t\twhere "); - for_array(j, pl->where_clauses) { - Ast *clause = pl->where_clauses[j]; - if (j != 0) { - error_line("\t\t "); - } - gbString str = expr_to_string(clause); - error_line("%s", str); - gb_string_free(str); - - if (j != pl->where_clauses.count-1) { - error_line(","); - } - } - error_line("\n\t"); - } - } - error_line("at %s\n", token_pos_to_string(pos)); - } - result_type = t_invalid; - } else { - GB_ASSERT(valids.count == 1); - Ast *ident = operand->expr; - while (ident->kind == Ast_SelectorExpr) { - Ast *s = ident->SelectorExpr.selector; - ident = s; - } - - Entity *e = proc_entities[valids[0].index]; - GB_ASSERT(e != nullptr); - - proc_type = e->type; - CallArgumentData data = {}; - CallArgumentError err = call_checker(c, call, proc_type, e, operands, CallArgumentMode_ShowErrors, &data); - gb_unused(err); - Entity *entity_to_use = data.gen_entity != nullptr ? data.gen_entity : e; - add_entity_use(c, ident, entity_to_use); - if (entity_to_use != nullptr) { - update_untyped_expr_type(c, operand->expr, entity_to_use->type, true); - } - - if (data.gen_entity != nullptr) { - Entity *e = data.gen_entity; - DeclInfo *decl = data.gen_entity->decl_info; - CheckerContext ctx = *c; - ctx.scope = decl->scope; - ctx.decl = decl; - ctx.proc_name = e->token.string; - ctx.curr_proc_decl = decl; - ctx.curr_proc_sig = e->type; - - GB_ASSERT(decl->proc_lit->kind == Ast_ProcLit); - bool ok = evaluate_where_clauses(&ctx, call, decl->scope, &decl->proc_lit->ProcLit.where_clauses, true); - decl->where_clauses_evaluated = true; - - if (ok && (data.gen_entity->flags & EntityFlag_ProcBodyChecked) == 0) { - check_procedure_later(c, e->file, e->token, decl, e->type, decl->proc_lit->ProcLit.body, decl->proc_lit->ProcLit.tags); - } - } + for_array(i, named_args) { + Ast *arg = named_args[i]; + if (arg->kind != Ast_FieldValue) { + error(arg, "Expected a 'field = value'"); return data; } + ast_node(fv, FieldValue, arg); + if (fv->field->kind != Ast_Ident) { + gbString expr_str = expr_to_string(fv->field); + error(arg, "Invalid parameter name '%s' in procedure call", expr_str); + gb_string_free(expr_str); + return data; + } + String key = fv->field->Ident.token.string; + Ast *value = fv->value; + + Type *type_hint = nullptr; + + for (isize lhs_idx = 0; lhs_idx < lhs_count; lhs_idx++) { + Entity *e = lhs[lhs_idx]; + if (e != nullptr && e->token.string == key && + !is_type_polymorphic(e->type)) { + type_hint = e->type; + break; + } + } + Operand o = {}; + check_expr_with_type_hint(c, &o, value, type_hint); + array_add(&named_operands, o); + } + + gb_free(heap_allocator(), lhs); + + auto valids = array_make(heap_allocator(), 0, procs.count); + defer (array_free(&valids)); + + auto proc_entities = array_make(heap_allocator(), 0, procs.count*2 + 1); + defer (array_free(&proc_entities)); + for (Entity *proc : procs) { + array_add(&proc_entities, proc); + } + + + gbString expr_name = expr_to_string(operand->expr); + defer (gb_string_free(expr_name)); + + for_array(i, procs) { + Entity *p = procs[i]; + Type *pt = base_type(p->type); + if (pt != nullptr && is_type_proc(pt)) { + CallArgumentData data = {}; + CheckerContext ctx = *c; + + ctx.no_polymorphic_errors = true; + ctx.allow_polymorphic_types = is_type_polymorphic(pt); + ctx.hide_polymorphic_errors = true; + + bool is_a_candidate = check_call_arguments_single(&ctx, call, operand, + p, pt, + positional_operands, named_operands, + CallArgumentErrorMode::NoErrors, + &data); + if (!is_a_candidate) { + continue; + } + isize index = i; + + if (data.gen_entity != nullptr) { + array_add(&proc_entities, data.gen_entity); + index = proc_entities.count-1; + } + + ValidIndexAndScore item = {}; + item.index = index; + item.score = data.score; + array_add(&valids, item); + } + } + + if (valids.count > 1) { + gb_sort_array(valids.data, valids.count, valid_index_and_score_cmp); + i64 best_score = valids[0].score; + Entity *best_entity = proc_entities[valids[0].index]; + GB_ASSERT(best_entity != nullptr); + for (isize i = 1; i < valids.count; i++) { + if (best_score > valids[i].score) { + valids.count = i; + break; + } + if (best_entity == proc_entities[valids[i].index]) { + valids.count = i; + break; + } + } + } + + auto print_argument_types = [&]() { + error_line("\tGiven argument types: ("); + isize i = 0; + for (Operand const &o : positional_operands) { + if (i++ > 0) error_line(", "); + gbString type = type_to_string(o.type); + defer (gb_string_free(type)); + error_line("%s", type); + } + for (Operand const &o : named_operands) { + if (i++ > 0) error_line(", "); + + gbString type = type_to_string(o.type); + defer (gb_string_free(type)); + + if (i < ce->split_args->named.count) { + Ast *named_field = ce->split_args->named[i]; + ast_node(fv, FieldValue, named_field); + + gbString field = expr_to_string(fv->field); + defer (gb_string_free(field)); + + error_line("%s = %s", field, type); + } else { + error_line("%s", type); + } + } + error_line(")\n"); + }; + + if (valids.count == 0) { + begin_error_block(); + defer (end_error_block()); + + error(operand->expr, "No procedures or ambiguous call for procedure group '%s' that match with the given arguments", expr_name); + if (positional_operands.count == 0 && named_operands.count == 0) { + error_line("\tNo given arguments\n"); + } else { + print_argument_types(); + } + + if (procs.count > 0) { + error_line("Did you mean to use one of the following:\n"); + } + for (Entity *proc : procs) { + TokenPos pos = proc->token.pos; + Type *t = base_type(proc->type); + if (t == t_invalid) continue; + GB_ASSERT(t->kind == Type_Proc); + gbString pt; + defer (gb_string_free(pt)); + if (t->Proc.node != nullptr) { + pt = expr_to_string(t->Proc.node); + } else { + pt = type_to_string(t); + } + String prefix = {}; + String prefix_sep = {}; + if (proc->pkg) { + prefix = proc->pkg->name; + prefix_sep = str_lit("."); + } + String name = proc->token.string; + + char const *sep = "::"; + if (proc->kind == Entity_Variable) { + sep = ":="; + } + error_line("\t%.*s%.*s%.*s %s %s at %s\n", LIT(prefix), LIT(prefix_sep), LIT(name), sep, pt, token_pos_to_string(pos)); + } + if (procs.count > 0) { + error_line("\n"); + } + + data.result_type = t_invalid; + } else if (valids.count > 1) { + begin_error_block(); + defer (end_error_block()); + + error(operand->expr, "Ambiguous procedure group call '%s' that match with the given arguments", expr_name); + print_argument_types(); + + for (isize i = 0; i < valids.count; i++) { + Entity *proc = proc_entities[valids[i].index]; + GB_ASSERT(proc != nullptr); + TokenPos pos = proc->token.pos; + Type *t = base_type(proc->type); GB_ASSERT(t->kind == Type_Proc); + gbString pt = nullptr; + defer (gb_string_free(pt)); + if (t->Proc.node != nullptr) { + pt = expr_to_string(t->Proc.node); + } else { + pt = type_to_string(t); + } + String name = proc->token.string; + char const *sep = "::"; + if (proc->kind == Entity_Variable) { + sep = ":="; + } + error_line("\t%.*s %s %s ", LIT(name), sep, pt); + if (proc->decl_info->proc_lit != nullptr) { + GB_ASSERT(proc->decl_info->proc_lit->kind == Ast_ProcLit); + auto *pl = &proc->decl_info->proc_lit->ProcLit; + if (pl->where_token.kind != Token_Invalid) { + error_line("\n\t\twhere "); + for_array(j, pl->where_clauses) { + Ast *clause = pl->where_clauses[j]; + if (j != 0) { + error_line("\t\t "); + } + gbString str = expr_to_string(clause); + error_line("%s", str); + gb_string_free(str); + + if (j != pl->where_clauses.count-1) { + error_line(","); + } + } + error_line("\n\t"); + } + } + error_line("at %s\n", token_pos_to_string(pos)); + } + data.result_type = t_invalid; } else { + GB_ASSERT(valids.count == 1); Ast *ident = operand->expr; while (ident->kind == Ast_SelectorExpr) { Ast *s = ident->SelectorExpr.selector; ident = s; } - Entity *e = entity_of_node(ident); + Entity *e = proc_entities[valids[0].index]; + GB_ASSERT(e != nullptr); + Array named_operands = {}; - CallArgumentData data = {}; - CallArgumentError err = call_checker(c, call, proc_type, e, operands, CallArgumentMode_ShowErrors, &data); - gb_unused(err); - Entity *entity_to_use = data.gen_entity != nullptr ? data.gen_entity : e; - add_entity_use(c, ident, entity_to_use); - if (entity_to_use != nullptr) { - update_untyped_expr_type(c, operand->expr, entity_to_use->type, true); - } - if (data.gen_entity != nullptr) { - Entity *e = data.gen_entity; - DeclInfo *decl = data.gen_entity->decl_info; - CheckerContext ctx = *c; - ctx.scope = decl->scope; - ctx.decl = decl; - ctx.proc_name = e->token.string; - ctx.curr_proc_decl = decl; - ctx.curr_proc_sig = e->type; - - GB_ASSERT(decl->proc_lit->kind == Ast_ProcLit); - bool ok = evaluate_where_clauses(&ctx, call, decl->scope, &decl->proc_lit->ProcLit.where_clauses, true); - decl->where_clauses_evaluated = true; - - if (ok && (data.gen_entity->flags & EntityFlag_ProcBodyChecked) == 0) { - check_procedure_later(c, e->file, e->token, decl, e->type, decl->proc_lit->ProcLit.body, decl->proc_lit->ProcLit.tags); - } - } + check_call_arguments_single(c, call, operand, + e, e->type, + positional_operands, named_operands, + CallArgumentErrorMode::ShowErrors, + &data); return data; } - - CallArgumentData data = {}; - data.result_type = t_invalid; return data; } -isize lookup_polymorphic_record_parameter(Type *t, String parameter_name) { +gb_internal CallArgumentData check_call_arguments(CheckerContext *c, Operand *operand, Ast *call) { + Type *proc_type = nullptr; + + CallArgumentData data = {}; + data.result_type = t_invalid; + + proc_type = base_type(operand->type); + + TypeProc *pt = nullptr; + if (proc_type) { + pt = &proc_type->Proc; + } + + TEMPORARY_ALLOCATOR_GUARD(); + ast_node(ce, CallExpr, call); + + bool any_failure = false; + + // Split positional and named args into separate arrays/slices + Slice positional_args = {}; + Slice named_args = {}; + + if (ce->split_args == nullptr) { + positional_args = ce->args; + for (isize i = 0; i < ce->args.count; i++) { + Ast *arg = ce->args.data[i]; + if (arg->kind == Ast_FieldValue) { + positional_args.count = i; + break; + } + } + named_args = slice(ce->args, positional_args.count, ce->args.count); + + auto split_args = gb_alloc_item(permanent_allocator(), AstSplitArgs); + split_args->positional = positional_args; + split_args->named = named_args; + ce->split_args = split_args; + } else { + positional_args = ce->split_args->positional; + named_args = ce->split_args->named; + } + + if (operand->mode == Addressing_ProcGroup) { + return check_call_arguments_proc_group(c, operand, call); + } + + auto positional_operands = array_make(heap_allocator(), 0, positional_args.count); + auto named_operands = array_make(heap_allocator(), 0, 0); + + defer (array_free(&positional_operands)); + defer (array_free(&named_operands)); + + if (positional_args.count > 0) { + isize lhs_count = -1; + bool is_variadic = false; + Entity **lhs = nullptr; + if (pt != nullptr) { + lhs = populate_proc_parameter_list(c, proc_type, &lhs_count, &is_variadic); + } + check_unpack_arguments(c, lhs, lhs_count, &positional_operands, positional_args, is_variadic ? UnpackFlag_IsVariadic : UnpackFlag_None); + } + + if (named_args.count > 0) { + for_array(i, named_args) { + Ast *arg = named_args[i]; + if (arg->kind != Ast_FieldValue) { + error(arg, "Expected a 'field = value'"); + return data; + } + ast_node(fv, FieldValue, arg); + if (fv->field->kind != Ast_Ident) { + gbString expr_str = expr_to_string(fv->field); + error(arg, "Invalid parameter name '%s' in procedure call", expr_str); + any_failure = true; + gb_string_free(expr_str); + continue; + } + String key = fv->field->Ident.token.string; + Ast *value = fv->value; + + isize param_index = lookup_procedure_parameter(pt, key); + Type *type_hint = nullptr; + if (param_index >= 0) { + Entity *e = pt->params->Tuple.variables[param_index]; + type_hint = e->type; + } + + Operand o = {}; + check_expr_with_type_hint(c, &o, value, type_hint); + if (o.mode == Addressing_Invalid) { + any_failure = true; + } + array_add(&named_operands, o); + } + + } + + if (!any_failure) { + check_call_arguments_single(c, call, operand, + nullptr, proc_type, + positional_operands, named_operands, + CallArgumentErrorMode::ShowErrors, + &data); + } else if (pt) { + data.result_type = pt->results; + } + + return data; +} + +gb_internal isize lookup_polymorphic_record_parameter(Type *t, String parameter_name) { if (!is_type_polymorphic_record(t)) { return -1; } @@ -6288,7 +6508,7 @@ isize lookup_polymorphic_record_parameter(Type *t, String parameter_name) { } -CallArgumentError check_polymorphic_record_type(CheckerContext *c, Operand *operand, Ast *call) { +gb_internal CallArgumentError check_polymorphic_record_type(CheckerContext *c, Operand *operand, Ast *call) { ast_node(ce, CallExpr, call); Type *original_type = operand->type; @@ -6349,7 +6569,7 @@ CallArgumentError check_polymorphic_record_type(CheckerContext *c, Operand *oper lhs_count = params->variables.count; } - check_unpack_arguments(c, lhs, lhs_count, &operands, ce->args, false, false); + check_unpack_arguments(c, lhs, lhs_count, &operands, ce->args, UnpackFlag_None); } } @@ -6375,6 +6595,8 @@ CallArgumentError check_polymorphic_record_type(CheckerContext *c, Operand *oper ordered_operands = array_make(permanent_allocator(), param_count); array_copy(&ordered_operands, operands, 0); } else { + TEMPORARY_ALLOCATOR_GUARD(); + bool *visited = gb_alloc_array(temporary_allocator(), bool, param_count); // LEAK(bill) @@ -6607,8 +6829,48 @@ CallArgumentError check_polymorphic_record_type(CheckerContext *c, Operand *oper +// returns true on success +gb_internal bool check_call_parameter_mixture(Slice const &args, char const *context, bool allow_mixed=false) { + bool success = true; + if (args.count > 0) { + if (allow_mixed) { + bool was_named = false; + for (Ast *arg : args) { + if (was_named && arg->kind != Ast_FieldValue) { + error(arg, "Non-named parameter is not allowed to follow named parameter i.e. 'field = value' in a %s", context); + success = false; + break; + } + was_named = was_named || arg->kind == Ast_FieldValue; + } + } else { + bool first_is_field_value = (args[0]->kind == Ast_FieldValue); + for (Ast *arg : args) { + bool mix = false; + if (first_is_field_value) { + mix = arg->kind != Ast_FieldValue; + } else { + mix = arg->kind == Ast_FieldValue; + } + if (mix) { + error(arg, "Mixture of 'field = value' and value elements in a %s is not allowed", context); + success = false; + } + } + } -ExprKind check_call_expr(CheckerContext *c, Operand *operand, Ast *call, Ast *proc, Slice const &args, ProcInlining inlining, Type *type_hint) { + } + return success; +} + +#define CHECK_CALL_PARAMETER_MIXTURE_OR_RETURN(context_, ...) if (!check_call_parameter_mixture(args, context_, ##__VA_ARGS__)) { \ + operand->mode = Addressing_Invalid; \ + operand->expr = call; \ + return Expr_Stmt; \ +} + + +gb_internal ExprKind check_call_expr(CheckerContext *c, Operand *operand, Ast *call, Ast *proc, Slice const &args, ProcInlining inlining, Type *type_hint) { if (proc != nullptr && proc->kind == Ast_BasicDirective) { ast_node(bd, BasicDirective, proc); @@ -6627,7 +6889,7 @@ ExprKind check_call_expr(CheckerContext *c, Operand *operand, Ast *call, Ast *pr operand->builtin_id = BuiltinProc_DIRECTIVE; operand->expr = proc; operand->type = t_invalid; - add_type_and_value(c->info, proc, operand->mode, operand->type, operand->value); + add_type_and_value(c, proc, operand->mode, operand->type, operand->value); } else { error(proc, "Unknown directive: #%.*s", LIT(name)); operand->expr = proc; @@ -6646,33 +6908,9 @@ ExprKind check_call_expr(CheckerContext *c, Operand *operand, Ast *call, Ast *pr } } - if (args.count > 0) { - bool fail = false; - bool first_is_field_value = (args[0]->kind == Ast_FieldValue); - for_array(i, args) { - Ast *arg = args[i]; - bool mix = false; - if (first_is_field_value) { - mix = arg->kind != Ast_FieldValue; - } else { - mix = arg->kind == Ast_FieldValue; - } - if (mix) { - error(arg, "Mixture of 'field = value' and value elements in a procedure call is not allowed"); - fail = true; - } - } - - if (fail) { - operand->mode = Addressing_Invalid; - operand->expr = call; - return Expr_Stmt; - } - } - if (operand->mode == Addressing_Invalid) { - for_array(i, args) { - Ast *arg = args[i]; + CHECK_CALL_PARAMETER_MIXTURE_OR_RETURN("procedure call"); + for (Ast *arg : args) { if (arg->kind == Ast_FieldValue) { arg = arg->FieldValue.value; } @@ -6686,6 +6924,8 @@ ExprKind check_call_expr(CheckerContext *c, Operand *operand, Ast *call, Ast *pr if (operand->mode == Addressing_Type) { Type *t = operand->type; if (is_type_polymorphic_record(t)) { + CHECK_CALL_PARAMETER_MIXTURE_OR_RETURN("polymorphic type construction"); + if (!is_type_named(t)) { gbString s = expr_to_string(operand->expr); error(call, "Illegal use of an unnamed polymorphic record, %s", s); @@ -6705,20 +6945,29 @@ ExprKind check_call_expr(CheckerContext *c, Operand *operand, Ast *call, Ast *pr GB_ASSERT(ot->kind == Type_Named); Entity *e = ot->Named.type_name; add_entity_use(c, ident, e); - add_type_and_value(c->info, call, Addressing_Type, ot, empty_exact_value); + add_type_and_value(c, call, Addressing_Type, ot, empty_exact_value); } else { operand->mode = Addressing_Invalid; operand->type = t_invalid; } } else { - gbString str = type_to_string(t); - defer (gb_string_free(str)); + CHECK_CALL_PARAMETER_MIXTURE_OR_RETURN("type conversion"); operand->mode = Addressing_Invalid; isize arg_count = args.count; switch (arg_count) { - case 0: error(call, "Missing argument in conversion to '%s'", str); break; - default: error(call, "Too many arguments in conversion to '%s'", str); break; + case 0: + { + gbString str = type_to_string(t); + error(call, "Missing argument in conversion to '%s'", str); + gb_string_free(str); + } break; + default: + { + gbString str = type_to_string(t); + error(call, "Too many arguments in conversion to '%s'", str); + gb_string_free(str); + } break; case 1: { Ast *arg = args[0]; if (arg->kind == Ast_FieldValue) { @@ -6749,7 +6998,13 @@ ExprKind check_call_expr(CheckerContext *c, Operand *operand, Ast *call, Ast *pr } if (operand->mode == Addressing_Builtin) { + CHECK_CALL_PARAMETER_MIXTURE_OR_RETURN("builtin call"); + i32 id = operand->builtin_id; + Entity *e = entity_of_node(operand->expr); + if (e != nullptr && e->token.string == "expand_to_tuple") { + warning(operand->expr, "'expand_to_tuple' has been replaced with 'expand_values'"); + } if (!check_builtin_procedure(c, operand, call, id, type_hint)) { operand->mode = Addressing_Invalid; operand->type = t_invalid; @@ -6758,6 +7013,8 @@ ExprKind check_call_expr(CheckerContext *c, Operand *operand, Ast *call, Ast *pr return builtin_procs[id].kind; } + CHECK_CALL_PARAMETER_MIXTURE_OR_RETURN(operand->mode == Addressing_ProcGroup ? "procedure group call": "procedure call", true); + Entity *initial_entity = entity_of_node(operand->expr); if (initial_entity != nullptr && initial_entity->kind == Entity_Procedure) { @@ -6769,8 +7026,8 @@ ExprKind check_call_expr(CheckerContext *c, Operand *operand, Ast *call, Ast *pr } } - Type *proc_type = base_type(operand->type); if (operand->mode != Addressing_ProcGroup) { + Type *proc_type = base_type(operand->type); bool valid_type = (proc_type != nullptr) && is_type_proc(proc_type); bool valid_mode = is_operand_value(*operand); if (!valid_type || !valid_mode) { @@ -6788,7 +7045,7 @@ ExprKind check_call_expr(CheckerContext *c, Operand *operand, Ast *call, Ast *pr } } - CallArgumentData data = check_call_arguments(c, operand, proc_type, call, args); + CallArgumentData data = check_call_arguments(c, operand, call); Type *result_type = data.result_type; gb_zero_item(operand); operand->expr = call; @@ -6799,7 +7056,10 @@ ExprKind check_call_expr(CheckerContext *c, Operand *operand, Ast *call, Ast *pr return Expr_Stmt; } - Type *pt = base_type(proc_type); + Type *pt = base_type(operand->type); + if (pt == nullptr) { + pt = t_invalid; + } if (pt == t_invalid) { if (operand->expr != nullptr && operand->expr->kind == Ast_CallExpr) { pt = type_of_expr(operand->expr->CallExpr.proc); @@ -6844,7 +7104,7 @@ ExprKind check_call_expr(CheckerContext *c, Operand *operand, Ast *call, Ast *pr if (decl->proc_lit) { ast_node(pl, ProcLit, decl->proc_lit); if (pl->inlining == ProcInlining_no_inline) { - error(call, "'inline' cannot be applied to a procedure that has be marked as 'no_inline'"); + error(call, "'#force_inline' cannot be applied to a procedure that has be marked as '#force_no_inline'"); } } } @@ -6857,9 +7117,6 @@ ExprKind check_call_expr(CheckerContext *c, Operand *operand, Ast *call, Ast *pr operand->expr = call; { - if (proc_type == t_invalid) { - // gb_printf_err("%s\n", expr_to_string(operand->expr)); - } Type *type = nullptr; if (operand->expr != nullptr && operand->expr->kind == Ast_CallExpr) { type = type_of_expr(operand->expr->CallExpr.proc); @@ -6877,13 +7134,11 @@ ExprKind check_call_expr(CheckerContext *c, Operand *operand, Ast *call, Ast *pr } } - // add_type_and_value(c->info, operand->expr, operand->mode, operand->type, operand->value); - return Expr_Expr; } -void check_expr_with_type_hint(CheckerContext *c, Operand *o, Ast *e, Type *t) { +gb_internal void check_expr_with_type_hint(CheckerContext *c, Operand *o, Ast *e, Type *t) { check_expr_base(c, o, e, t); check_not_tuple(c, o); char const *err_str = nullptr; @@ -6908,7 +7163,7 @@ void check_expr_with_type_hint(CheckerContext *c, Operand *o, Ast *e, Type *t) { } } -bool check_set_index_data(Operand *o, Type *t, bool indirection, i64 *max_count, Type *original_type) { +gb_internal bool check_set_index_data(Operand *o, Type *t, bool indirection, i64 *max_count, Type *original_type) { switch (t->kind) { case Type_Basic: if (t->Basic.kind == Basic_string) { @@ -7021,12 +7276,12 @@ bool check_set_index_data(Operand *o, Type *t, bool indirection, i64 *max_count, return false; } -bool ternary_compare_types(Type *x, Type *y) { - if (is_type_untyped_undef(x) && type_has_undef(y)) { +gb_internal bool ternary_compare_types(Type *x, Type *y) { + if (is_type_untyped_uninit(x)) { return true; } else if (is_type_untyped_nil(x) && type_has_nil(y)) { return true; - } else if (is_type_untyped_undef(y) && type_has_undef(x)) { + } else if (is_type_untyped_uninit(y)) { return true; } else if (is_type_untyped_nil(y) && type_has_nil(x)) { return true; @@ -7035,7 +7290,7 @@ bool ternary_compare_types(Type *x, Type *y) { } -bool check_range(CheckerContext *c, Ast *node, Operand *x, Operand *y, ExactValue *inline_for_depth_, Type *type_hint=nullptr) { +gb_internal bool check_range(CheckerContext *c, Ast *node, bool is_for_loop, Operand *x, Operand *y, ExactValue *inline_for_depth_, Type *type_hint=nullptr) { if (!is_ast_range(node)) { return false; } @@ -7084,9 +7339,17 @@ bool check_range(CheckerContext *c, Ast *node, Operand *x, Operand *y, ExactValu } Type *type = x->type; - if (!is_type_integer(type) && !is_type_float(type) && !is_type_pointer(type) && !is_type_enum(type)) { - error(ie->op, "Only numerical and pointer types are allowed within interval expressions"); - return false; + + if (is_for_loop) { + if (!is_type_integer(type) && !is_type_float(type) && !is_type_enum(type)) { + error(ie->op, "Only numerical types are allowed within interval expressions"); + return false; + } + } else { + if (!is_type_integer(type) && !is_type_float(type) && !is_type_pointer(type) && !is_type_enum(type)) { + error(ie->op, "Only numerical and pointer types are allowed within interval expressions"); + return false; + } } if (x->mode == Addressing_Constant && @@ -7121,13 +7384,13 @@ bool check_range(CheckerContext *c, Ast *node, Operand *x, Operand *y, ExactValu return false; } - add_type_and_value(c->info, ie->left, x->mode, x->type, x->value); - add_type_and_value(c->info, ie->right, y->mode, y->type, y->value); + add_type_and_value(c, ie->left, x->mode, x->type, x->value); + add_type_and_value(c, ie->right, y->mode, y->type, y->value); return true; } -bool check_is_operand_compound_lit_constant(CheckerContext *c, Operand *o) { +gb_internal bool check_is_operand_compound_lit_constant(CheckerContext *c, Operand *o) { if (is_operand_nil(*o)) { return true; } @@ -7138,7 +7401,7 @@ bool check_is_operand_compound_lit_constant(CheckerContext *c, Operand *o) { return true; } if (expr->kind == Ast_ProcLit) { - add_type_and_value(c->info, expr, Addressing_Constant, type_of_expr(expr), exact_value_procedure(expr)); + add_type_and_value(c, expr, Addressing_Constant, type_of_expr(expr), exact_value_procedure(expr)); return true; } } @@ -7146,7 +7409,7 @@ bool check_is_operand_compound_lit_constant(CheckerContext *c, Operand *o) { } -bool attempt_implicit_selector_expr(CheckerContext *c, Operand *o, AstImplicitSelectorExpr *ise, Type *th) { +gb_internal bool attempt_implicit_selector_expr(CheckerContext *c, Operand *o, AstImplicitSelectorExpr *ise, Type *th) { if (is_type_enum(th)) { Type *enum_type = base_type(th); GB_ASSERT(enum_type->kind == Type_Enum); @@ -7165,12 +7428,12 @@ bool attempt_implicit_selector_expr(CheckerContext *c, Operand *o, AstImplicitSe return true; } if (is_type_union(th)) { + TEMPORARY_ALLOCATOR_GUARD(); + Type *union_type = base_type(th); auto operands = array_make(temporary_allocator(), 0, union_type->Union.variants.count); - for_array(i, union_type->Union.variants) { - Type *vt = union_type->Union.variants[i]; - + for (Type *vt : union_type->Union.variants) { Operand x = {}; if (attempt_implicit_selector_expr(c, &x, ise, vt)) { array_add(&operands, x); @@ -7185,7 +7448,7 @@ bool attempt_implicit_selector_expr(CheckerContext *c, Operand *o, AstImplicitSe return false; } -ExprKind check_implicit_selector_expr(CheckerContext *c, Operand *o, Ast *node, Type *type_hint) { +gb_internal ExprKind check_implicit_selector_expr(CheckerContext *c, Operand *o, Ast *node, Type *type_hint) { ast_node(ise, ImplicitSelectorExpr, node); o->type = t_invalid; @@ -7229,7 +7492,7 @@ ExprKind check_implicit_selector_expr(CheckerContext *c, Operand *o, Ast *node, } -void check_promote_optional_ok(CheckerContext *c, Operand *x, Type **val_type_, Type **ok_type_) { +gb_internal void check_promote_optional_ok(CheckerContext *c, Operand *x, Type **val_type_, Type **ok_type_) { switch (x->mode) { case Addressing_MapIndex: case Addressing_OptionalOk: @@ -7247,7 +7510,7 @@ void check_promote_optional_ok(CheckerContext *c, Operand *x, Type **val_type_, Type *pt = base_type(type_of_expr(expr->CallExpr.proc)); if (is_type_proc(pt)) { Type *tuple = pt->Proc.results; - add_type_and_value(c->info, x->expr, x->mode, tuple, x->value); + add_type_and_value(c, x->expr, x->mode, tuple, x->value); if (pt->Proc.result_count >= 2) { if (ok_type_) *ok_type_ = tuple->Tuple.variables[1]->type; @@ -7260,13 +7523,13 @@ void check_promote_optional_ok(CheckerContext *c, Operand *x, Type **val_type_, Type *tuple = make_optional_ok_type(x->type); if (ok_type_) *ok_type_ = tuple->Tuple.variables[1]->type; - add_type_and_value(c->info, x->expr, x->mode, tuple, x->value); + add_type_and_value(c, x->expr, x->mode, tuple, x->value); x->type = tuple; GB_ASSERT(is_type_tuple(type_of_expr(x->expr))); } -void check_matrix_index_expr(CheckerContext *c, Operand *o, Ast *node, Type *type_hint) { +gb_internal void check_matrix_index_expr(CheckerContext *c, Operand *o, Ast *node, Type *type_hint) { ast_node(ie, MatrixIndexExpr, node); check_expr(c, o, ie->expr); @@ -7325,8 +7588,10 @@ void check_matrix_index_expr(CheckerContext *c, Operand *o, Ast *node, Type *typ i64 column_index = 0; bool row_ok = check_index_value(c, t, false, ie->row_index, row_count, &row_index, nullptr); bool column_ok = check_index_value(c, t, false, ie->column_index, column_count, &column_index, nullptr); - - + if (is_const && (ie->row_index->tav.mode != Addressing_Constant || ie->column_index->tav.mode != Addressing_Constant)) { + error(o->expr, "Cannot index constant matrix with non-constant indices '%s'", expr_to_string(node)); + } + gb_unused(row_ok); gb_unused(column_ok); } @@ -7339,7 +7604,7 @@ struct TypeAndToken { typedef PtrMap SeenMap; -void add_constant_switch_case(CheckerContext *ctx, SeenMap *seen, Operand operand, bool use_expr = true) { +gb_internal void add_constant_switch_case(CheckerContext *ctx, SeenMap *seen, Operand operand, bool use_expr = true) { if (operand.mode != Addressing_Constant) { return; } @@ -7350,6 +7615,8 @@ void add_constant_switch_case(CheckerContext *ctx, SeenMap *seen, Operand operan uintptr key = hash_exact_value(operand.value); TypeAndToken *found = map_get(seen, key); if (found != nullptr) { + TEMPORARY_ALLOCATOR_GUARD(); + isize count = multi_map_count(seen, key); TypeAndToken *taps = gb_alloc_array(temporary_allocator(), TypeAndToken, count); @@ -7381,7 +7648,7 @@ void add_constant_switch_case(CheckerContext *ctx, SeenMap *seen, Operand operan } -void add_to_seen_map(CheckerContext *ctx, SeenMap *seen, TokenKind upper_op, Operand const &x, Operand const &lhs, Operand const &rhs) { +gb_internal void add_to_seen_map(CheckerContext *ctx, SeenMap *seen, TokenKind upper_op, Operand const &x, Operand const &lhs, Operand const &rhs) { if (is_type_enum(x.type)) { // TODO(bill): Fix this logic so it's fast!!! @@ -7400,8 +7667,7 @@ void add_to_seen_map(CheckerContext *ctx, SeenMap *seen, TokenKind upper_op, Ope } bool found = false; - for_array(j, bt->Enum.fields) { - Entity *f = bt->Enum.fields[j]; + for (Entity *f : bt->Enum.fields) { GB_ASSERT(f->kind == Entity_Constant); i64 fv = exact_value_to_i64(f->Constant.value); @@ -7422,11 +7688,11 @@ void add_to_seen_map(CheckerContext *ctx, SeenMap *seen, TokenKind upper_op, Ope } } } -void add_to_seen_map(CheckerContext *ctx, SeenMap *seen, Operand const &x) { +gb_internal void add_to_seen_map(CheckerContext *ctx, SeenMap *seen, Operand const &x) { add_constant_switch_case(ctx, seen, x); } -ExprKind check_basic_directive_expr(CheckerContext *c, Operand *o, Ast *node, Type *type_hint) { +gb_internal ExprKind check_basic_directive_expr(CheckerContext *c, Operand *o, Ast *node, Type *type_hint) { ast_node(bd, BasicDirective, node); ExprKind kind = Expr_Expr; @@ -7480,7 +7746,7 @@ ExprKind check_basic_directive_expr(CheckerContext *c, Operand *o, Ast *node, Ty return kind; } -ExprKind check_ternary_if_expr(CheckerContext *c, Operand *o, Ast *node, Type *type_hint) { +gb_internal ExprKind check_ternary_if_expr(CheckerContext *c, Operand *o, Ast *node, Type *type_hint) { ExprKind kind = Expr_Expr; Operand cond = {Addressing_Invalid}; ast_node(te, TernaryIfExpr, node); @@ -7521,16 +7787,27 @@ ExprKind check_ternary_if_expr(CheckerContext *c, Operand *o, Ast *node, Type *t return kind; } - convert_to_typed(c, &x, y.type); + bool use_type_hint = type_hint != nullptr && (is_operand_nil(x) || is_operand_nil(y)); + + convert_to_typed(c, &x, use_type_hint ? type_hint : y.type); if (x.mode == Addressing_Invalid) { return kind; } - convert_to_typed(c, &y, x.type); + convert_to_typed(c, &y, use_type_hint ? type_hint : x.type); if (y.mode == Addressing_Invalid) { x.mode = Addressing_Invalid; return kind; } + // NOTE(bill, 2023-01-30): Allow for expression like this: + // x: union{f32} = f32(123) if cond else nil + if (type_hint && !is_type_any(type_hint) && !ternary_compare_types(x.type, y.type)) { + if (check_is_assignable_to(c, &x, type_hint) && check_is_assignable_to(c, &y, type_hint)) { + check_cast(c, &x, type_hint); + check_cast(c, &y, type_hint); + } + } + if (!ternary_compare_types(x.type, y.type)) { gbString its = type_to_string(x.type); gbString ets = type_to_string(y.type); @@ -7541,13 +7818,13 @@ ExprKind check_ternary_if_expr(CheckerContext *c, Operand *o, Ast *node, Type *t } o->type = x.type; - if (is_type_untyped_nil(o->type) || is_type_untyped_undef(o->type)) { + if (is_type_untyped_nil(o->type) || is_type_untyped_uninit(o->type)) { o->type = y.type; } o->mode = Addressing_Value; o->expr = node; - if (type_hint != nullptr && is_type_untyped(o->type)) { + if (type_hint != nullptr && is_type_untyped(o->type) && !is_type_any(type_hint)) { if (check_cast_internal(c, &x, type_hint) && check_cast_internal(c, &y, type_hint)) { convert_to_typed(c, o, type_hint); @@ -7558,7 +7835,7 @@ ExprKind check_ternary_if_expr(CheckerContext *c, Operand *o, Ast *node, Type *t return kind; } -ExprKind check_ternary_when_expr(CheckerContext *c, Operand *o, Ast *node, Type *type_hint) { +gb_internal ExprKind check_ternary_when_expr(CheckerContext *c, Operand *o, Ast *node, Type *type_hint) { ExprKind kind = Expr_Expr; Operand cond = {}; ast_node(te, TernaryWhenExpr, node); @@ -7585,7 +7862,7 @@ ExprKind check_ternary_when_expr(CheckerContext *c, Operand *o, Ast *node, Type return kind; } -ExprKind check_or_else_expr(CheckerContext *c, Operand *o, Ast *node, Type *type_hint) { +gb_internal ExprKind check_or_else_expr(CheckerContext *c, Operand *o, Ast *node, Type *type_hint) { ast_node(oe, OrElseExpr, node); String name = oe->token.string; @@ -7680,7 +7957,7 @@ ExprKind check_or_else_expr(CheckerContext *c, Operand *o, Ast *node, Type *type Type *left_type = nullptr; Type *right_type = nullptr; check_or_else_split_types(c, &x, name, &left_type, &right_type); - add_type_and_value(&c->checker->info, arg, x.mode, x.type, x.value); + add_type_and_value(c, arg, x.mode, x.type, x.value); if (left_type != nullptr) { if (!y_is_diverging) { @@ -7699,7 +7976,7 @@ ExprKind check_or_else_expr(CheckerContext *c, Operand *o, Ast *node, Type *type return Expr_Expr; } -ExprKind check_or_return_expr(CheckerContext *c, Operand *o, Ast *node, Type *type_hint) { +gb_internal ExprKind check_or_return_expr(CheckerContext *c, Operand *o, Ast *node, Type *type_hint) { ast_node(re, OrReturnExpr, node); String name = re->token.string; @@ -7715,7 +7992,7 @@ ExprKind check_or_return_expr(CheckerContext *c, Operand *o, Ast *node, Type *ty Type *left_type = nullptr; Type *right_type = nullptr; check_or_return_split_types(c, &x, name, &left_type, &right_type); - add_type_and_value(&c->checker->info, re->expr, x.mode, x.type, x.value); + add_type_and_value(c, re->expr, x.mode, x.type, x.value); if (right_type == nullptr) { check_or_else_expr_no_value_error(c, name, x, type_hint); @@ -7741,8 +8018,11 @@ ExprKind check_or_return_expr(CheckerContext *c, Operand *o, Ast *node, Type *ty rhs.type = right_type; rhs.mode = Addressing_Value; - // TODO(bill): better error message - if (!check_is_assignable_to(c, &rhs, end_type)) { + if (is_type_boolean(right_type) && is_type_boolean(end_type)) { + // NOTE(bill): allow implicit conversion between boolean types + // within 'or_return' to improve the experience using third-party code + } else if (!check_is_assignable_to(c, &rhs, end_type)) { + // TODO(bill): better error message gbString a = type_to_string(right_type); gbString b = type_to_string(end_type); gbString ret_type = type_to_string(result_type); @@ -7778,7 +8058,125 @@ ExprKind check_or_return_expr(CheckerContext *c, Operand *o, Ast *node, Type *ty return Expr_Expr; } -ExprKind check_compound_literal(CheckerContext *c, Operand *o, Ast *node, Type *type_hint) { + +gb_internal void check_compound_literal_field_values(CheckerContext *c, Slice const &elems, Operand *o, Type *type, bool &is_constant) { + Type *bt = base_type(type); + + StringSet fields_visited = {}; + defer (string_set_destroy(&fields_visited)); + + StringMap fields_visited_through_raw_union = {}; + defer (string_map_destroy(&fields_visited_through_raw_union)); + + for (Ast *elem : elems) { + if (elem->kind != Ast_FieldValue) { + error(elem, "Mixture of 'field = value' and value elements in a literal is not allowed"); + continue; + } + ast_node(fv, FieldValue, elem); + if (fv->field->kind != Ast_Ident) { + gbString expr_str = expr_to_string(fv->field); + error(elem, "Invalid field name '%s' in structure literal", expr_str); + gb_string_free(expr_str); + continue; + } + String name = fv->field->Ident.token.string; + + Selection sel = lookup_field(type, name, o->mode == Addressing_Type); + bool is_unknown = sel.entity == nullptr; + if (is_unknown) { + error(fv->field, "Unknown field '%.*s' in structure literal", LIT(name)); + continue; + } + + Entity *field = bt->Struct.fields[sel.index[0]]; + add_entity_use(c, fv->field, field); + if (string_set_update(&fields_visited, name)) { + if (sel.index.count > 1) { + if (String *found = string_map_get(&fields_visited_through_raw_union, sel.entity->token.string)) { + error(fv->field, "Field '%.*s' is already initialized due to a previously assigned struct #raw_union field '%.*s'", LIT(sel.entity->token.string), LIT(*found)); + } else { + error(fv->field, "Duplicate or reused field '%.*s' in structure literal", LIT(sel.entity->token.string)); + } + } else { + error(fv->field, "Duplicate field '%.*s' in structure literal", LIT(field->token.string)); + } + continue; + } else if (String *found = string_map_get(&fields_visited_through_raw_union, sel.entity->token.string)) { + error(fv->field, "Field '%.*s' is already initialized due to a previously assigned struct #raw_union field '%.*s'", LIT(sel.entity->token.string), LIT(*found)); + continue; + } + if (sel.indirect) { + error(fv->field, "Cannot assign to the %d-nested anonymous indirect field '%.*s' in a structure literal", cast(int)sel.index.count-1, LIT(name)); + continue; + } + + if (sel.index.count > 1) { + if (is_constant) { + Type *ft = type; + for (i32 index : sel.index) { + Type *bt = base_type(ft); + switch (bt->kind) { + case Type_Struct: + if (bt->Struct.is_raw_union) { + is_constant = false; + break; + } + ft = bt->Struct.fields[index]->type; + break; + case Type_Array: + ft = bt->Array.elem; + break; + default: + GB_PANIC("invalid type: %s", type_to_string(ft)); + break; + } + } + if (is_constant && + (is_type_any(ft) || is_type_union(ft) || is_type_raw_union(ft) || is_type_typeid(ft))) { + is_constant = false; + } + } + + Type *nested_ft = bt; + for (i32 index : sel.index) { + Type *bt = base_type(nested_ft); + switch (bt->kind) { + case Type_Struct: + if (bt->Struct.is_raw_union) { + for (Entity *re : bt->Struct.fields) { + string_map_set(&fields_visited_through_raw_union, re->token.string, sel.entity->token.string); + } + } + nested_ft = bt->Struct.fields[index]->type; + break; + case Type_Array: + nested_ft = bt->Array.elem; + break; + default: + GB_PANIC("invalid type %s", type_to_string(nested_ft)); + break; + } + } + field = sel.entity; + } + + + Operand o = {}; + check_expr_or_type(c, &o, fv->value, field->type); + + if (is_type_any(field->type) || is_type_union(field->type) || is_type_raw_union(field->type) || is_type_typeid(field->type)) { + is_constant = false; + } + if (is_constant) { + is_constant = check_is_operand_compound_lit_constant(c, &o); + } + + check_assignment(c, &o, field->type, str_lit("structure literal")); + } +} + +gb_internal ExprKind check_compound_literal(CheckerContext *c, Operand *o, Ast *node, Type *type_hint) { ExprKind kind = Expr_Expr; ast_node(cl, CompoundLit, node); @@ -7865,45 +8263,13 @@ ExprKind check_compound_literal(CheckerContext *c, Operand *o, Ast *node, Type * error(node, "%s ('struct #raw_union') compound literals are only allowed to contain up to 1 'field = value' element, got %td", type_str, cl->elems.count); gb_string_free(type_str); } else { - Ast *elem = cl->elems[0]; - ast_node(fv, FieldValue, elem); - if (fv->field->kind != Ast_Ident) { - gbString expr_str = expr_to_string(fv->field); - error(elem, "Invalid field name '%s' in structure literal", expr_str); - gb_string_free(expr_str); - break; - } - - String name = fv->field->Ident.token.string; - - Selection sel = lookup_field(type, name, o->mode == Addressing_Type); - bool is_unknown = sel.entity == nullptr; - if (is_unknown) { - error(elem, "Unknown field '%.*s' in structure literal", LIT(name)); - break; - } - - if (sel.index.count > 1) { - error(elem, "Cannot assign to an anonymous field '%.*s' in a structure literal (at the moment)", LIT(name)); - break; - } - - Entity *field = t->Struct.fields[sel.index[0]]; - add_entity_use(c, fv->field, field); - - Operand o = {}; - check_expr_or_type(c, &o, fv->value, field->type); - - - check_assignment(c, &o, field->type, str_lit("structure literal")); + check_compound_literal_field_values(c, cl->elems, o, type, is_constant); } - } } break; } - isize field_count = t->Struct.fields.count; isize min_field_count = t->Struct.fields.count; for (isize i = min_field_count-1; i >= 0; i--) { @@ -7917,57 +8283,7 @@ ExprKind check_compound_literal(CheckerContext *c, Operand *o, Ast *node, Type * } if (cl->elems[0]->kind == Ast_FieldValue) { - bool *fields_visited = gb_alloc_array(temporary_allocator(), bool, field_count); - - for_array(i, cl->elems) { - Ast *elem = cl->elems[i]; - if (elem->kind != Ast_FieldValue) { - error(elem, "Mixture of 'field = value' and value elements in a literal is not allowed"); - continue; - } - ast_node(fv, FieldValue, elem); - if (fv->field->kind != Ast_Ident) { - gbString expr_str = expr_to_string(fv->field); - error(elem, "Invalid field name '%s' in structure literal", expr_str); - gb_string_free(expr_str); - continue; - } - String name = fv->field->Ident.token.string; - - Selection sel = lookup_field(type, name, o->mode == Addressing_Type); - bool is_unknown = sel.entity == nullptr; - if (is_unknown) { - error(elem, "Unknown field '%.*s' in structure literal", LIT(name)); - continue; - } - - if (sel.index.count > 1) { - error(elem, "Cannot assign to an anonymous field '%.*s' in a structure literal (at the moment)", LIT(name)); - continue; - } - - Entity *field = t->Struct.fields[sel.index[0]]; - add_entity_use(c, fv->field, field); - - if (fields_visited[sel.index[0]]) { - error(elem, "Duplicate field '%.*s' in structure literal", LIT(name)); - continue; - } - - fields_visited[sel.index[0]] = true; - - Operand o = {}; - check_expr_or_type(c, &o, fv->value, field->type); - - if (is_type_any(field->type) || is_type_union(field->type) || is_type_raw_union(field->type) || is_type_typeid(field->type)) { - is_constant = false; - } - if (is_constant) { - is_constant = check_is_operand_compound_lit_constant(c, &o); - } - - check_assignment(c, &o, field->type, str_lit("structure literal")); - } + check_compound_literal_field_values(c, cl->elems, o, type, is_constant); } else { bool seen_field_value = false; @@ -8072,8 +8388,7 @@ ExprKind check_compound_literal(CheckerContext *c, Operand *o, Ast *node, Type * RangeCache rc = range_cache_make(heap_allocator()); defer (range_cache_destroy(&rc)); - for_array(i, cl->elems) { - Ast *elem = cl->elems[i]; + for (Ast *elem : cl->elems) { if (elem->kind != Ast_FieldValue) { error(elem, "Mixture of 'field = value' and value elements in a literal is not allowed"); continue; @@ -8085,7 +8400,7 @@ ExprKind check_compound_literal(CheckerContext *c, Operand *o, Ast *node, Type * Operand x = {}; Operand y = {}; - bool ok = check_range(c, fv->field, &x, &y, nullptr); + bool ok = check_range(c, fv->field, false, &x, &y, nullptr); if (!ok) { continue; } @@ -8141,7 +8456,7 @@ ExprKind check_compound_literal(CheckerContext *c, Operand *o, Ast *node, Type * error(elem, "Expected a constant integer as an array field"); continue; } - // add_type_and_value(c->info, op_index.expr, op_index.mode, op_index.type, op_index.value); + // add_type_and_value(c, op_index.expr, op_index.mode, op_index.type, op_index.value); i64 index = exact_value_to_i64(op_index.value); @@ -8254,8 +8569,7 @@ ExprKind check_compound_literal(CheckerContext *c, Operand *o, Ast *node, Type * { Type *bt = base_type(index_type); GB_ASSERT(bt->kind == Type_Enum); - for_array(i, bt->Enum.fields) { - Entity *f = bt->Enum.fields[i]; + for (Entity *f : bt->Enum.fields) { if (f->kind != Entity_Constant) { continue; } @@ -8284,15 +8598,13 @@ ExprKind check_compound_literal(CheckerContext *c, Operand *o, Ast *node, Type * bool is_partial = cl->tag && (cl->tag->BasicDirective.name.string == "partial"); SeenMap seen = {}; // NOTE(bill): Multimap, Key: ExactValue - map_init(&seen, heap_allocator()); defer (map_destroy(&seen)); if (cl->elems.count > 0 && cl->elems[0]->kind == Ast_FieldValue) { RangeCache rc = range_cache_make(heap_allocator()); defer (range_cache_destroy(&rc)); - for_array(i, cl->elems) { - Ast *elem = cl->elems[i]; + for (Ast *elem : cl->elems) { if (elem->kind != Ast_FieldValue) { error(elem, "Mixture of 'field = value' and value elements in a literal is not allowed"); continue; @@ -8304,7 +8616,7 @@ ExprKind check_compound_literal(CheckerContext *c, Operand *o, Ast *node, Type * Operand x = {}; Operand y = {}; - bool ok = check_range(c, fv->field, &x, &y, nullptr, index_type); + bool ok = check_range(c, fv->field, false, &x, &y, nullptr, index_type); if (!ok) { continue; } @@ -8450,14 +8762,15 @@ ExprKind check_compound_literal(CheckerContext *c, Operand *o, Ast *node, Type * // NOTE(bill): Check for missing cases when `#partial literal` is not present if (cl->elems.count > 0 && !was_error && !is_partial) { + TEMPORARY_ALLOCATOR_GUARD(); + Type *et = base_type(index_type); GB_ASSERT(et->kind == Type_Enum); auto fields = et->Enum.fields; auto unhandled = array_make(temporary_allocator(), 0, fields.count); - for_array(i, fields) { - Entity *f = fields[i]; + for (Entity *f : fields) { if (f->kind != Entity_Constant) { continue; } @@ -8583,8 +8896,7 @@ ExprKind check_compound_literal(CheckerContext *c, Operand *o, Ast *node, Type * bool key_is_typeid = is_type_typeid(t->Map.key); bool value_is_typeid = is_type_typeid(t->Map.value); - for_array(i, cl->elems) { - Ast *elem = cl->elems[i]; + for (Ast *elem : cl->elems) { if (elem->kind != Ast_FieldValue) { error(elem, "Only 'field = value' elements are allowed in a map literal"); continue; @@ -8633,8 +8945,7 @@ ExprKind check_compound_literal(CheckerContext *c, Operand *o, Ast *node, Type * error(cl->elems[0], "'field = value' in a bit_set a literal is not allowed"); is_constant = false; } else { - for_array(index, cl->elems) { - Ast *elem = cl->elems[index]; + for (Ast *elem : cl->elems) { if (elem->kind == Ast_FieldValue) { error(elem, "'field = value' in a bit_set a literal is not allowed"); continue; @@ -8686,8 +8997,7 @@ ExprKind check_compound_literal(CheckerContext *c, Operand *o, Ast *node, Type * BigInt one = {}; big_int_from_u64(&one, 1); - for_array(i, cl->elems) { - Ast *e = cl->elems[i]; + for (Ast *e : cl->elems) { GB_ASSERT(e->kind != Ast_FieldValue); TypeAndValue tav = e->tav; @@ -8742,7 +9052,7 @@ ExprKind check_compound_literal(CheckerContext *c, Operand *o, Ast *node, Type * return kind; } -ExprKind check_type_assertion(CheckerContext *c, Operand *o, Ast *node, Type *type_hint) { +gb_internal ExprKind check_type_assertion(CheckerContext *c, Operand *o, Ast *node, Type *type_hint) { ExprKind kind = Expr_Expr; ast_node(ta, TypeAssertion, node); check_expr(c, o, ta->expr); @@ -8786,8 +9096,7 @@ ExprKind check_type_assertion(CheckerContext *c, Operand *o, Ast *node, Type *ty if (bsrc->Union.variants.count != 1 && type_hint != nullptr) { bool allowed = false; - for_array(i, bsrc->Union.variants) { - Type *vt = bsrc->Union.variants[i]; + for (Type *vt : bsrc->Union.variants) { if (are_types_identical(vt, type_hint)) { allowed = true; add_type_info_type(c, vt); @@ -8820,8 +9129,7 @@ ExprKind check_type_assertion(CheckerContext *c, Operand *o, Ast *node, Type *ty if (is_type_union(src)) { bool ok = false; - for_array(i, bsrc->Union.variants) { - Type *vt = bsrc->Union.variants[i]; + for (Type *vt : bsrc->Union.variants) { if (are_types_identical(vt, dst)) { ok = true; break; @@ -8871,7 +9179,7 @@ ExprKind check_type_assertion(CheckerContext *c, Operand *o, Ast *node, Type *ty return kind; } -ExprKind check_selector_call_expr(CheckerContext *c, Operand *o, Ast *node, Type *type_hint) { +gb_internal ExprKind check_selector_call_expr(CheckerContext *c, Operand *o, Ast *node, Type *type_hint) { ast_node(se, SelectorCallExpr, node); // IMPORTANT NOTE(bill, 2020-05-22): This is a complete hack to get a shorthand which is extremely useful for vtables // COM APIs is a great example of where this kind of thing is extremely useful @@ -8981,8 +9289,7 @@ ExprKind check_selector_call_expr(CheckerContext *c, Operand *o, Ast *node, Type if (ce->args.count > 0) { bool fail = false; bool first_is_field_value = (ce->args[0]->kind == Ast_FieldValue); - for_array(i, ce->args) { - Ast *arg = ce->args[i]; + for (Ast *arg : ce->args) { bool mix = false; if (first_is_field_value) { mix = arg->kind != Ast_FieldValue; @@ -9019,7 +9326,7 @@ ExprKind check_selector_call_expr(CheckerContext *c, Operand *o, Ast *node, Type } -ExprKind check_index_expr(CheckerContext *c, Operand *o, Ast *node, Type *type_hint) { +gb_internal ExprKind check_index_expr(CheckerContext *c, Operand *o, Ast *node, Type *type_hint) { ExprKind kind = Expr_Expr; ast_node(ie, IndexExpr, node); check_expr(c, o, ie->expr); @@ -9143,7 +9450,7 @@ ExprKind check_index_expr(CheckerContext *c, Operand *o, Ast *node, Type *type_h return kind; } -ExprKind check_slice_expr(CheckerContext *c, Operand *o, Ast *node, Type *type_hint) { +gb_internal ExprKind check_slice_expr(CheckerContext *c, Operand *o, Ast *node, Type *type_hint) { ExprKind kind = Expr_Stmt; ast_node(se, SliceExpr, node); check_expr(c, o, se->expr); @@ -9331,7 +9638,7 @@ ExprKind check_slice_expr(CheckerContext *c, Operand *o, Ast *node, Type *type_h return kind; } -ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type *type_hint) { +gb_internal ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type *type_hint) { u32 prev_state_flags = c->state_flags; defer (c->state_flags = prev_state_flags); if (node->state_flags != 0) { @@ -9404,9 +9711,10 @@ ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type check_ident(c, o, node, nullptr, type_hint, false); case_end; - case_ast_node(u, Undef, node); + case_ast_node(u, Uninit, node); o->mode = Addressing_Value; - o->type = t_untyped_undef; + o->type = t_untyped_uninit; + error(node, "Use of --- outside of variable declaration"); case_end; @@ -9474,7 +9782,10 @@ ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type } pl->decl = decl; - check_procedure_later(&ctx, ctx.file, empty_token, decl, type, pl->body, pl->tags); + check_procedure_later(ctx.checker, ctx.file, empty_token, decl, type, pl->body, pl->tags); + mutex_lock(&ctx.checker->nested_proc_lits_mutex); + array_add(&ctx.checker->nested_proc_lits, decl); + mutex_unlock(&ctx.checker->nested_proc_lits_mutex); } check_close_scope(&ctx); @@ -9758,7 +10069,7 @@ ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type -ExprKind check_expr_base(CheckerContext *c, Operand *o, Ast *node, Type *type_hint) { +gb_internal ExprKind check_expr_base(CheckerContext *c, Operand *o, Ast *node, Type *type_hint) { ExprKind kind = check_expr_base_internal(c, o, node, type_hint); if (o->type != nullptr && core_type(o->type) == nullptr) { o->type = t_invalid; @@ -9775,12 +10086,12 @@ ExprKind check_expr_base(CheckerContext *c, Operand *o, Ast *node, Type *type_hi } check_rtti_type_disallowed(node, o->type, "An expression is using a type, %s, which has been disallowed"); - add_type_and_value(c->info, node, o->mode, o->type, o->value); + add_type_and_value(c, node, o->mode, o->type, o->value); return kind; } -void check_multi_expr_or_type(CheckerContext *c, Operand *o, Ast *e) { +gb_internal void check_multi_expr_or_type(CheckerContext *c, Operand *o, Ast *e) { check_expr_base(c, o, e, nullptr); switch (o->mode) { default: @@ -9792,7 +10103,7 @@ void check_multi_expr_or_type(CheckerContext *c, Operand *o, Ast *e) { o->mode = Addressing_Invalid; } -void check_multi_expr(CheckerContext *c, Operand *o, Ast *e) { +gb_internal void check_multi_expr(CheckerContext *c, Operand *o, Ast *e) { check_expr_base(c, o, e, nullptr); switch (o->mode) { default: @@ -9807,7 +10118,7 @@ void check_multi_expr(CheckerContext *c, Operand *o, Ast *e) { o->mode = Addressing_Invalid; } -void check_multi_expr_with_type_hint(CheckerContext *c, Operand *o, Ast *e, Type *type_hint) { +gb_internal void check_multi_expr_with_type_hint(CheckerContext *c, Operand *o, Ast *e, Type *type_hint) { check_expr_base(c, o, e, type_hint); switch (o->mode) { default: @@ -9822,7 +10133,7 @@ void check_multi_expr_with_type_hint(CheckerContext *c, Operand *o, Ast *e, Type o->mode = Addressing_Invalid; } -void check_not_tuple(CheckerContext *c, Operand *o) { +gb_internal void check_not_tuple(CheckerContext *c, Operand *o) { if (o->mode == Addressing_Value) { // NOTE(bill): Tuples are not first class thus never named if (o->type->kind == Type_Tuple) { @@ -9835,13 +10146,13 @@ void check_not_tuple(CheckerContext *c, Operand *o) { } } -void check_expr(CheckerContext *c, Operand *o, Ast *e) { +gb_internal void check_expr(CheckerContext *c, Operand *o, Ast *e) { check_multi_expr(c, o, e); check_not_tuple(c, o); } -void check_expr_or_type(CheckerContext *c, Operand *o, Ast *e, Type *type_hint) { +gb_internal void check_expr_or_type(CheckerContext *c, Operand *o, Ast *e, Type *type_hint) { check_expr_base(c, o, e, type_hint); check_not_tuple(c, o); error_operand_no_value(o); @@ -9849,7 +10160,7 @@ void check_expr_or_type(CheckerContext *c, Operand *o, Ast *e, Type *type_hint) -bool is_exact_value_zero(ExactValue const &v) { +gb_internal bool is_exact_value_zero(ExactValue const &v) { switch (v.kind) { case ExactValue_Invalid: return true; @@ -9884,12 +10195,9 @@ bool is_exact_value_zero(ExactValue const &v) { if (cl->elems.count == 0) { return true; } else { - for_array(i, cl->elems) { - Ast *elem = cl->elems[i]; + for (Ast *elem : cl->elems) { if (elem->tav.mode != Addressing_Constant) { - // if (elem->tav.value.kind != ExactValue_Invalid) { return false; - // } } if (!is_exact_value_zero(elem->tav.value)) { return false; @@ -9913,9 +10221,9 @@ bool is_exact_value_zero(ExactValue const &v) { -gbString write_expr_to_string(gbString str, Ast *node, bool shorthand); +gb_internal gbString write_expr_to_string(gbString str, Ast *node, bool shorthand); -gbString write_struct_fields_to_string(gbString str, Slice const ¶ms) { +gb_internal gbString write_struct_fields_to_string(gbString str, Slice const ¶ms) { for_array(i, params) { if (i > 0) { str = gb_string_appendc(str, ", "); @@ -9925,7 +10233,7 @@ gbString write_struct_fields_to_string(gbString str, Slice const ¶ms) return str; } -gbString string_append_string(gbString str, String string) { +gb_internal gbString string_append_string(gbString str, String string) { if (string.len > 0) { return gb_string_append_length(str, &string[0], string.len); } @@ -9933,13 +10241,13 @@ gbString string_append_string(gbString str, String string) { } -gbString string_append_token(gbString str, Token token) { +gb_internal gbString string_append_token(gbString str, Token token) { str = string_append_string(str, token.string); return str; } -gbString write_expr_to_string(gbString str, Ast *node, bool shorthand) { +gb_internal gbString write_expr_to_string(gbString str, Ast *node, bool shorthand) { if (node == nullptr) return str; @@ -9969,7 +10277,7 @@ gbString write_expr_to_string(gbString str, Ast *node, bool shorthand) { str = string_append_string(str, bd->name.string); case_end; - case_ast_node(ud, Undef, node); + case_ast_node(ud, Uninit, node); str = gb_string_appendc(str, "---"); case_end; @@ -10250,9 +10558,6 @@ gbString write_expr_to_string(gbString str, Ast *node, bool shorthand) { if (f->flags&FieldFlag_c_vararg) { str = gb_string_appendc(str, "#c_vararg "); } - if (f->flags&FieldFlag_auto_cast) { - str = gb_string_appendc(str, "auto_cast "); - } if (f->flags&FieldFlag_any_int) { str = gb_string_appendc(str, "#any_int "); } @@ -10369,8 +10674,7 @@ gbString write_expr_to_string(gbString str, Ast *node, bool shorthand) { bool parens_needed = false; if (pt->results && pt->results->kind == Ast_FieldList) { - for_array(i, pt->results->FieldList.list) { - Ast *field = pt->results->FieldList.list[i]; + for (Ast *field : pt->results->FieldList.list) { ast_node(f, Field, field); if (f->names.count != 0) { parens_needed = true; @@ -10504,9 +10808,12 @@ gbString write_expr_to_string(gbString str, Ast *node, bool shorthand) { return str; } -gbString expr_to_string(Ast *expression) { +gb_internal gbString expr_to_string(Ast *expression) { return write_expr_to_string(gb_string_make(heap_allocator(), ""), expression, false); } -gbString expr_to_string_shorthand(Ast *expression) { +gb_internal gbString expr_to_string(Ast *expression, gbAllocator allocator) { + return write_expr_to_string(gb_string_make(allocator, ""), expression, false); +} +gb_internal gbString expr_to_string_shorthand(Ast *expression) { return write_expr_to_string(gb_string_make(heap_allocator(), ""), expression, true); } diff --git a/src/check_stmt.cpp b/src/check_stmt.cpp index 502eed57e..cf6f998e5 100644 --- a/src/check_stmt.cpp +++ b/src/check_stmt.cpp @@ -1,4 +1,4 @@ -bool is_diverging_expr(Ast *expr) { +gb_internal bool is_diverging_expr(Ast *expr) { expr = unparen_expr(expr); if (expr->kind != Ast_CallExpr) { return false; @@ -23,14 +23,14 @@ bool is_diverging_expr(Ast *expr) { t = base_type(t); return t != nullptr && t->kind == Type_Proc && t->Proc.diverging; } -bool is_diverging_stmt(Ast *stmt) { +gb_internal bool is_diverging_stmt(Ast *stmt) { if (stmt->kind != Ast_ExprStmt) { return false; } return is_diverging_expr(stmt->ExprStmt.expr); } -bool contains_deferred_call(Ast *node) { +gb_internal bool contains_deferred_call(Ast *node) { if (node->viral_state_flags & ViralStateFlag_ContainsDeferredProcedure) { return true; } @@ -61,7 +61,7 @@ bool contains_deferred_call(Ast *node) { return false; } -void check_stmt_list(CheckerContext *ctx, Slice const &stmts, u32 flags) { +gb_internal void check_stmt_list(CheckerContext *ctx, Slice const &stmts, u32 flags) { if (stmts.count == 0) { return; } @@ -137,7 +137,7 @@ void check_stmt_list(CheckerContext *ctx, Slice const &stmts, u32 flags) } } -bool check_is_terminating_list(Slice const &stmts, String const &label) { +gb_internal bool check_is_terminating_list(Slice const &stmts, String const &label) { // Iterate backwards for (isize n = stmts.count-1; n >= 0; n--) { Ast *stmt = stmts[n]; @@ -155,7 +155,7 @@ bool check_is_terminating_list(Slice const &stmts, String const &label) { return false; } -bool check_has_break_list(Slice const &stmts, String const &label, bool implicit) { +gb_internal bool check_has_break_list(Slice const &stmts, String const &label, bool implicit) { for_array(i, stmts) { Ast *stmt = stmts[i]; if (check_has_break(stmt, label, implicit)) { @@ -166,7 +166,7 @@ bool check_has_break_list(Slice const &stmts, String const &label, bool i } -bool check_has_break(Ast *stmt, String const &label, bool implicit) { +gb_internal bool check_has_break(Ast *stmt, String const &label, bool implicit) { switch (stmt->kind) { case Ast_BranchStmt: if (stmt->BranchStmt.token.kind == Token_break) { @@ -225,7 +225,7 @@ bool check_has_break(Ast *stmt, String const &label, bool implicit) { // NOTE(bill): The last expression has to be a 'return' statement // TODO(bill): This is a mild hack and should be probably handled properly -bool check_is_terminating(Ast *node, String const &label) { +gb_internal bool check_is_terminating(Ast *node, String const &label) { switch (node->kind) { case_ast_node(rs, ReturnStmt, node); return true; @@ -239,6 +239,10 @@ bool check_is_terminating(Ast *node, String const &label) { return check_is_terminating(unparen_expr(es->expr), label); case_end; + case_ast_node(bs, BranchStmt, node); + return bs->token.kind == Token_fallthrough; + case_end; + case_ast_node(is, IfStmt, node); if (is->else_stmt != nullptr) { if (check_is_terminating(is->body, label) && @@ -326,8 +330,7 @@ bool check_is_terminating(Ast *node, String const &label) { - -Type *check_assignment_variable(CheckerContext *ctx, Operand *lhs, Operand *rhs) { +gb_internal Type *check_assignment_variable(CheckerContext *ctx, Operand *lhs, Operand *rhs) { if (rhs->mode == Addressing_Invalid) { return nullptr; } @@ -339,6 +342,8 @@ Type *check_assignment_variable(CheckerContext *ctx, Operand *lhs, Operand *rhs) Ast *node = unparen_expr(lhs->expr); + check_no_copy_assignment(*rhs, str_lit("assignment")); + // NOTE(bill): Ignore assignments to '_' if (is_blank_ident(node)) { check_assignment(ctx, rhs, nullptr, str_lit("assignment to '_' identifier")); @@ -400,6 +405,13 @@ Type *check_assignment_variable(CheckerContext *ctx, Operand *lhs, Operand *rhs) } Type *assignment_type = lhs->type; + + if (rhs->mode == Addressing_Type && is_type_polymorphic(rhs->type)) { + gbString t = type_to_string(rhs->type); + error(rhs->expr, "Invalid use of a non-specialized polymorphic type '%s'", t); + gb_string_free(t); + } + switch (lhs->mode) { case Addressing_Invalid: return nullptr; @@ -477,8 +489,8 @@ Type *check_assignment_variable(CheckerContext *ctx, Operand *lhs, Operand *rhs) } -void check_stmt_internal(CheckerContext *ctx, Ast *node, u32 flags); -void check_stmt(CheckerContext *ctx, Ast *node, u32 flags) { +gb_internal void check_stmt_internal(CheckerContext *ctx, Ast *node, u32 flags); +gb_internal void check_stmt(CheckerContext *ctx, Ast *node, u32 flags) { u32 prev_state_flags = ctx->state_flags; if (node->state_flags != 0) { @@ -510,7 +522,7 @@ void check_stmt(CheckerContext *ctx, Ast *node, u32 flags) { } -void check_when_stmt(CheckerContext *ctx, AstWhenStmt *ws, u32 flags) { +gb_internal void check_when_stmt(CheckerContext *ctx, AstWhenStmt *ws, u32 flags) { Operand operand = {Addressing_Invalid}; check_expr(ctx, &operand, ws->cond); if (operand.mode != Addressing_Constant || !is_type_boolean(operand.type)) { @@ -539,7 +551,7 @@ void check_when_stmt(CheckerContext *ctx, AstWhenStmt *ws, u32 flags) { } } -void check_label(CheckerContext *ctx, Ast *label, Ast *parent) { +gb_internal void check_label(CheckerContext *ctx, Ast *label, Ast *parent) { if (label == nullptr) { return; } @@ -582,7 +594,7 @@ void check_label(CheckerContext *ctx, Ast *label, Ast *parent) { } // Returns 'true' for 'continue', 'false' for 'return' -bool check_using_stmt_entity(CheckerContext *ctx, AstUsingStmt *us, Ast *expr, bool is_selector, Entity *e) { +gb_internal bool check_using_stmt_entity(CheckerContext *ctx, AstUsingStmt *us, Ast *expr, bool is_selector, Entity *e) { if (e == nullptr) { if (is_blank_ident(expr)) { error(us->token, "'using' in a statement is not allowed with the blank identifier '_'"); @@ -622,9 +634,12 @@ bool check_using_stmt_entity(CheckerContext *ctx, AstUsingStmt *us, Ast *expr, b case Entity_ImportName: { Scope *scope = e->ImportName.scope; - MUTEX_GUARD_BLOCK(scope->mutex) for_array(i, scope->elements.entries) { - String name = scope->elements.entries[i].key.string; - Entity *decl = scope->elements.entries[i].value; + rw_mutex_lock(&scope->mutex); + defer (rw_mutex_unlock(&scope->mutex)); + + for (auto const &entry : scope->elements) { + String name = entry.key; + Entity *decl = entry.value; if (!is_entity_exported(decl)) continue; Entity *found = scope_insert_with_name(ctx->scope, name, decl); @@ -652,8 +667,8 @@ bool check_using_stmt_entity(CheckerContext *ctx, AstUsingStmt *us, Ast *expr, b if (t->kind == Type_Struct) { Scope *found = t->Struct.scope; GB_ASSERT(found != nullptr); - for_array(i, found->elements.entries) { - Entity *f = found->elements.entries[i].value; + for (auto const &entry : found->elements) { + Entity *f = entry.value; if (f->kind == Entity_Variable) { Entity *uvar = alloc_entity_using_variable(e, f->token, f->type, expr); if (!is_ptr && e->flags & EntityFlag_Value) uvar->flags |= EntityFlag_Value; @@ -704,7 +719,7 @@ bool check_using_stmt_entity(CheckerContext *ctx, AstUsingStmt *us, Ast *expr, b return true; } -void check_inline_range_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags) { +gb_internal void check_inline_range_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags) { ast_node(irs, UnrollRangeStmt, node); check_open_scope(ctx, node); @@ -722,7 +737,7 @@ void check_inline_range_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags) { Operand x = {}; Operand y = {}; - bool ok = check_range(ctx, expr, &x, &y, &inline_for_depth); + bool ok = check_range(ctx, expr, true, &x, &y, &inline_for_depth); if (!ok) { goto skip_expr; } @@ -863,7 +878,7 @@ void check_inline_range_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags) { check_close_scope(ctx); } -void check_switch_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags) { +gb_internal void check_switch_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags) { ast_node(ss, SwitchStmt, node); Operand x = {}; @@ -929,19 +944,17 @@ void check_switch_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags) { } SeenMap seen = {}; // NOTE(bill): Multimap, Key: ExactValue - map_init(&seen, heap_allocator()); defer (map_destroy(&seen)); - for_array(stmt_index, bs->stmts) { - Ast *stmt = bs->stmts[stmt_index]; + for (Ast *stmt : bs->stmts) { if (stmt->kind != Ast_CaseClause) { // NOTE(bill): error handled by above multiple default checker continue; } ast_node(cc, CaseClause, stmt); - for_array(j, cc->list) { - Ast *expr = unparen_expr(cc->list[j]); + for (Ast *expr : cc->list) { + expr = unparen_expr(expr); if (is_ast_range(expr)) { ast_node(be, BinaryExpr, expr); @@ -977,19 +990,19 @@ void check_switch_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags) { Operand a = lhs; Operand b = rhs; - check_comparison(ctx, &a, &x, Token_LtEq); + check_comparison(ctx, expr, &a, &x, Token_LtEq); if (a.mode == Addressing_Invalid) { continue; } - check_comparison(ctx, &b, &x, upper_op); + check_comparison(ctx, expr, &b, &x, upper_op); if (b.mode == Addressing_Invalid) { continue; } Operand a1 = lhs; Operand b1 = rhs; - check_comparison(ctx, &a1, &b1, Token_LtEq); + check_comparison(ctx, expr, &a1, &b1, Token_LtEq); add_to_seen_map(ctx, &seen, upper_op, x, lhs, rhs); @@ -1028,7 +1041,7 @@ void check_switch_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags) { // NOTE(bill): the ordering here matters Operand z = y; - check_comparison(ctx, &z, &x, Token_CmpEq); + check_comparison(ctx, expr, &z, &x, Token_CmpEq); if (z.mode == Addressing_Invalid) { continue; } @@ -1047,14 +1060,15 @@ void check_switch_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags) { } if (!is_partial && is_type_enum(x.type)) { + TEMPORARY_ALLOCATOR_GUARD(); + Type *et = base_type(x.type); GB_ASSERT(is_type_enum(et)); auto fields = et->Enum.fields; auto unhandled = array_make(temporary_allocator(), 0, fields.count); - for_array(i, fields) { - Entity *f = fields[i]; + for (Entity *f : fields) { if (f->kind != Entity_Constant) { continue; } @@ -1073,8 +1087,7 @@ void check_switch_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags) { error_no_newline(node, "Unhandled switch case: %.*s", LIT(unhandled[0]->token.string)); } else { error(node, "Unhandled switch cases:"); - for_array(i, unhandled) { - Entity *f = unhandled[i]; + for (Entity *f : unhandled) { error_line("\t%.*s\n", LIT(f->token.string)); } } @@ -1092,7 +1105,7 @@ enum TypeSwitchKind { TypeSwitch_Any, }; -TypeSwitchKind check_valid_type_switch_type(Type *type) { +gb_internal TypeSwitchKind check_valid_type_switch_type(Type *type) { type = type_deref(type); if (is_type_union(type)) { return TypeSwitch_Union; @@ -1103,7 +1116,7 @@ TypeSwitchKind check_valid_type_switch_type(Type *type) { return TypeSwitch_Invalid; } -void check_type_switch_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags) { +gb_internal void check_type_switch_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags) { ast_node(ss, TypeSwitchStmt, node); Operand x = {}; @@ -1155,8 +1168,7 @@ void check_type_switch_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags) { // NOTE(bill): Check for multiple defaults Ast *first_default = nullptr; ast_node(bs, BlockStmt, ss->body); - for_array(i, bs->stmts) { - Ast *stmt = bs->stmts[i]; + for (Ast *stmt : bs->stmts) { Ast *default_stmt = nullptr; if (stmt->kind == Ast_CaseClause) { ast_node(cc, CaseClause, stmt); @@ -1184,27 +1196,46 @@ void check_type_switch_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags) { return; } + + Ast *nil_seen = nullptr; PtrSet seen = {}; - ptr_set_init(&seen, heap_allocator()); defer (ptr_set_destroy(&seen)); - for_array(i, bs->stmts) { - Ast *stmt = bs->stmts[i]; + for (Ast *stmt : bs->stmts) { if (stmt->kind != Ast_CaseClause) { // NOTE(bill): error handled by above multiple default checker continue; } ast_node(cc, CaseClause, stmt); + bool saw_nil = false; // TODO(bill): Make robust Type *bt = base_type(type_deref(x.type)); Type *case_type = nullptr; - for_array(type_index, cc->list) { - Ast *type_expr = cc->list[type_index]; + for (Ast *type_expr : cc->list) { if (type_expr != nullptr) { // Otherwise it's a default expression Operand y = {}; check_expr_or_type(ctx, &y, type_expr); + + if (is_operand_nil(y)) { + if (!type_has_nil(type_deref(x.type))) { + error(type_expr, "'nil' case is not allowed for the type '%s'", type_to_string(type_deref(x.type))); + continue; + } + saw_nil = true; + + if (nil_seen) { + ERROR_BLOCK(); + error(type_expr, "'nil' case has already been handled previously"); + error_line("\t 'nil' was already previously seen at %s", token_pos_to_string(ast_token(nil_seen).pos)); + } else { + nil_seen = type_expr; + } + case_type = y.type; + continue; + } + if (y.mode != Addressing_Type) { gbString str = expr_to_string(type_expr); error(type_expr, "Expected a type as a case, got %s", str); @@ -1215,8 +1246,7 @@ void check_type_switch_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags) { if (switch_kind == TypeSwitch_Union) { GB_ASSERT(is_type_union(bt)); bool tag_type_found = false; - for_array(j, bt->Union.variants) { - Type *vt = bt->Union.variants[j]; + for (Type *vt : bt->Union.variants) { if (are_types_identical(vt, y.type)) { tag_type_found = true; break; @@ -1237,7 +1267,7 @@ void check_type_switch_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags) { GB_PANIC("Unknown type to type switch statement"); } - if (type_ptr_set_exists(&seen, y.type)) { + if (type_ptr_set_update(&seen, y.type)) { TokenPos pos = cc->token.pos; gbString expr_str = expr_to_string(y.expr); error(y.expr, @@ -1248,7 +1278,6 @@ void check_type_switch_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags) { gb_string_free(expr_str); break; } - ptr_set_add(&seen, y.type); } } @@ -1260,13 +1289,17 @@ void check_type_switch_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags) { is_reference = true; } - if (cc->list.count > 1) { + if (cc->list.count > 1 || saw_nil) { case_type = nullptr; } if (case_type == nullptr) { case_type = x.type; } - add_type_info_type(ctx, case_type); + if (switch_kind == TypeSwitch_Any) { + if (!is_type_untyped(case_type)) { + add_type_info_type(ctx, case_type); + } + } check_open_scope(ctx, stmt); { @@ -1285,14 +1318,15 @@ void check_type_switch_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags) { } if (!is_partial && is_type_union(type_deref(x.type))) { + TEMPORARY_ALLOCATOR_GUARD(); + Type *ut = base_type(type_deref(x.type)); GB_ASSERT(is_type_union(ut)); auto variants = ut->Union.variants; auto unhandled = array_make(temporary_allocator(), 0, variants.count); - for_array(i, variants) { - Type *t = variants[i]; + for (Type *t : variants) { if (!type_ptr_set_exists(&seen, t)) { array_add(&unhandled, t); } @@ -1305,8 +1339,7 @@ void check_type_switch_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags) { gb_string_free(s); } else { error_no_newline(node, "Unhandled switch cases:\n"); - for_array(i, unhandled) { - Type *t = unhandled[i]; + for (Type *t : unhandled) { gbString s = type_to_string(t); error_line("\t%s\n", s); gb_string_free(s); @@ -1318,14 +1351,14 @@ void check_type_switch_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags) { } } -void check_block_stmt_for_errors(CheckerContext *ctx, Ast *body) { +gb_internal void check_block_stmt_for_errors(CheckerContext *ctx, Ast *body) { if (body->kind != Ast_BlockStmt) { return; } ast_node(bs, BlockStmt, body); // NOTE(bill, 2020-09-23): This logic is prevent common erros with block statements // e.g. if cond { x := 123; } // this is an error - if (bs->scope != nullptr && bs->scope->elements.entries.count > 0) { + if (bs->scope != nullptr && bs->scope->elements.count > 0) { if (bs->scope->parent->node != nullptr) { switch (bs->scope->parent->node->kind) { case Ast_IfStmt: @@ -1343,8 +1376,7 @@ void check_block_stmt_for_errors(CheckerContext *ctx, Ast *body) { isize stmt_count = 0; Ast *the_stmt = nullptr; - for_array(i, bs->stmts) { - Ast *stmt = bs->stmts[i]; + for (Ast *stmt : bs->stmts) { GB_ASSERT(stmt != nullptr); switch (stmt->kind) { case_ast_node(es, EmptyStmt, stmt); @@ -1362,8 +1394,7 @@ void check_block_stmt_for_errors(CheckerContext *ctx, Ast *body) { if (stmt_count == 1) { if (the_stmt->kind == Ast_ValueDecl) { - for_array(i, the_stmt->ValueDecl.names) { - Ast *name = the_stmt->ValueDecl.names[i]; + for (Ast *name : the_stmt->ValueDecl.names) { if (name->kind != Ast_Ident) { continue; } @@ -1377,10 +1408,10 @@ void check_block_stmt_for_errors(CheckerContext *ctx, Ast *body) { } } -bool all_operands_valid(Array const &operands) { +gb_internal bool all_operands_valid(Array const &operands) { if (any_errors()) { - for_array(i, operands) { - if (operands[i].type == t_invalid) { + for (Operand const &o : operands) { + if (o.type == t_invalid) { return false; } } @@ -1388,7 +1419,7 @@ bool all_operands_valid(Array const &operands) { return true; } -bool check_stmt_internal_builtin_proc_id(Ast *expr, BuiltinProcId *id_) { +gb_internal bool check_stmt_internal_builtin_proc_id(Ast *expr, BuiltinProcId *id_) { BuiltinProcId id = BuiltinProc_Invalid; Entity *e = entity_of_node(expr); if (e != nullptr && e->kind == Entity_Builtin) { @@ -1400,7 +1431,7 @@ bool check_stmt_internal_builtin_proc_id(Ast *expr, BuiltinProcId *id_) { return id != BuiltinProc_Invalid; } -bool check_expr_is_stack_variable(Ast *expr) { +gb_internal bool check_expr_is_stack_variable(Ast *expr) { /* expr = unparen_expr(expr); Entity *e = entity_of_node(expr); @@ -1419,7 +1450,837 @@ bool check_expr_is_stack_variable(Ast *expr) { return false; } -void check_stmt_internal(CheckerContext *ctx, Ast *node, u32 flags) { +gb_internal void check_range_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags) { + ast_node(rs, RangeStmt, node); + + TEMPORARY_ALLOCATOR_GUARD(); + + u32 new_flags = mod_flags | Stmt_BreakAllowed | Stmt_ContinueAllowed; + + check_open_scope(ctx, node); + check_label(ctx, rs->label, node); + + auto vals = array_make(temporary_allocator(), 0, 2); + auto entities = array_make(temporary_allocator(), 0, 2); + bool is_map = false; + bool use_by_reference_for_value = false; + bool is_soa = false; + bool is_reverse = rs->reverse; + + Ast *expr = unparen_expr(rs->expr); + + isize max_val_count = 2; + if (is_ast_range(expr)) { + ast_node(ie, BinaryExpr, expr); + Operand x = {}; + Operand y = {}; + + bool ok = check_range(ctx, expr, true, &x, &y, nullptr); + if (!ok) { + goto skip_expr_range_stmt; + } + array_add(&vals, x.type); + array_add(&vals, t_int); + + if (is_reverse) { + error(node, "#reverse for is not supported with ranges, prefer an explicit for loop with init, condition, and post arguments"); + } + } else { + Operand operand = {Addressing_Invalid}; + check_expr_base(ctx, &operand, expr, nullptr); + error_operand_no_value(&operand); + + if (operand.mode == Addressing_Type) { + if (!is_type_enum(operand.type)) { + gbString t = type_to_string(operand.type); + error(operand.expr, "Cannot iterate over the type '%s'", t); + gb_string_free(t); + goto skip_expr_range_stmt; + } else { + if (is_reverse) { + error(node, "#reverse for is not supported for enum types"); + } + array_add(&vals, operand.type); + array_add(&vals, t_int); + add_type_info_type(ctx, operand.type); + goto skip_expr_range_stmt; + } + } else if (operand.mode != Addressing_Invalid) { + bool is_ptr = is_type_pointer(operand.type); + Type *t = base_type(type_deref(operand.type)); + switch (t->kind) { + case Type_Basic: + if (is_type_string(t) && t->Basic.kind != Basic_cstring) { + array_add(&vals, t_rune); + array_add(&vals, t_int); + if (is_reverse) { + add_package_dependency(ctx, "runtime", "string_decode_last_rune"); + } else { + add_package_dependency(ctx, "runtime", "string_decode_rune"); + } + } + break; + + case Type_EnumeratedArray: + if (is_ptr) use_by_reference_for_value = true; + array_add(&vals, t->EnumeratedArray.elem); + array_add(&vals, t->EnumeratedArray.index); + break; + + case Type_Array: + if (is_ptr) use_by_reference_for_value = true; + array_add(&vals, t->Array.elem); + array_add(&vals, t_int); + break; + + case Type_DynamicArray: + if (is_ptr) use_by_reference_for_value = true; + array_add(&vals, t->DynamicArray.elem); + array_add(&vals, t_int); + break; + + case Type_Slice: + if (is_ptr) use_by_reference_for_value = true; + array_add(&vals, t->Slice.elem); + array_add(&vals, t_int); + break; + + case Type_Map: + if (is_ptr) use_by_reference_for_value = true; + is_map = true; + array_add(&vals, t->Map.key); + array_add(&vals, t->Map.value); + if (is_reverse) { + error(node, "#reverse for is not supported for map types, as maps are unordered"); + } + break; + + case Type_Tuple: + { + isize count = t->Tuple.variables.count; + if (count < 1 || count > 3) { + check_not_tuple(ctx, &operand); + error_line("\tMultiple return valued parameters in a range statement are limited to a maximum of 2 usable values with a trailing boolean for the conditional\n"); + break; + } + Type *cond_type = t->Tuple.variables[count-1]->type; + if (!is_type_boolean(cond_type)) { + gbString s = type_to_string(cond_type); + error(operand.expr, "The final type of %td-valued expression must be a boolean, got %s", count, s); + gb_string_free(s); + break; + } + + for (Entity *e : t->Tuple.variables) { + array_add(&vals, e->type); + } + + if (rs->vals.count > 1 && rs->vals[1] != nullptr && count < 3) { + gbString s = type_to_string(t); + error(operand.expr, "Expected a 3-valued expression on the rhs, got (%s)", s); + gb_string_free(s); + break; + } + + if (rs->vals.count > 0 && rs->vals[0] != nullptr && count < 2) { + gbString s = type_to_string(t); + error(operand.expr, "Expected at least a 2-valued expression on the rhs, got (%s)", s); + gb_string_free(s); + break; + } + + if (is_reverse) { + error(node, "#reverse for is not supported for multiple return valued parameters"); + } + } + break; + + case Type_Struct: + if (t->Struct.soa_kind != StructSoa_None) { + is_soa = true; + if (is_ptr) use_by_reference_for_value = true; + array_add(&vals, t->Struct.soa_elem); + array_add(&vals, t_int); + } + break; + } + } + + if (vals.count == 0 || vals[0] == nullptr) { + gbString s = expr_to_string(operand.expr); + gbString t = type_to_string(operand.type); + defer (gb_string_free(s)); + defer (gb_string_free(t)); + + error(operand.expr, "Cannot iterate over '%s' of type '%s'", s, t); + + if (rs->vals.count == 1) { + Type *t = type_deref(operand.type); + if (is_type_map(t) || is_type_bit_set(t)) { + gbString v = expr_to_string(rs->vals[0]); + defer (gb_string_free(v)); + error_line("\tSuggestion: place parentheses around the expression\n"); + error_line("\t for (%s in %s) {\n", v, s); + } + } + } + } + + skip_expr_range_stmt:; // NOTE(zhiayang): again, declaring a variable immediately after a label... weird. + + if (rs->vals.count > max_val_count) { + error(rs->vals[max_val_count], "Expected a maximum of %td identifier%s, got %td", max_val_count, max_val_count == 1 ? "" : "s", rs->vals.count); + } + + auto rhs = slice_from_array(vals); + auto lhs = slice_make(temporary_allocator(), rhs.count); + slice_copy(&lhs, rs->vals); + + isize addressable_index = cast(isize)is_map; + + for_array(i, rhs) { + if (lhs[i] == nullptr) { + continue; + } + Ast * name = lhs[i]; + Type *type = rhs[i]; + + Entity *entity = nullptr; + if (name->kind == Ast_Ident) { + Token token = name->Ident.token; + String str = token.string; + Entity *found = nullptr; + + if (!is_blank_ident(str)) { + found = scope_lookup_current(ctx->scope, str); + } + if (found == nullptr) { + entity = alloc_entity_variable(ctx->scope, token, type, EntityState_Resolved); + entity->flags |= EntityFlag_ForValue; + entity->flags |= EntityFlag_Value; + entity->identifier = name; + if (i == addressable_index && use_by_reference_for_value) { + entity->flags &= ~EntityFlag_Value; + } + if (is_soa) { + if (i == 0) { + entity->flags |= EntityFlag_SoaPtrField; + } + } + + add_entity_definition(&ctx->checker->info, name, entity); + } else { + TokenPos pos = found->token.pos; + error(token, + "Redeclaration of '%.*s' in this scope\n" + "\tat %s", + LIT(str), token_pos_to_string(pos)); + entity = found; + } + } else { + error(name, "A variable declaration must be an identifier"); + } + + if (entity == nullptr) { + entity = alloc_entity_dummy_variable(builtin_pkg->scope, ast_token(name)); + entity->identifier = name; // might not be an identifier + } + + array_add(&entities, entity); + + if (type == nullptr) { + entity->type = t_invalid; + entity->flags |= EntityFlag_Used; + } + } + + for (Entity *e : entities) { + DeclInfo *d = decl_info_of_entity(e); + GB_ASSERT(d == nullptr); + add_entity(ctx, ctx->scope, e->identifier, e); + d = make_decl_info(ctx->scope, ctx->decl); + add_entity_and_decl_info(ctx, e->identifier, e, d); + } + + check_stmt(ctx, rs->body, new_flags); + + check_close_scope(ctx); +} + +gb_internal void check_value_decl_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags) { + ast_node(vd, ValueDecl, node); + if (!vd->is_mutable) { + // constant value declaration + // NOTE(bill): Check `_` declarations + for (Ast *name : vd->names) { + if (is_blank_ident(name)) { + Entity *e = name->Ident.entity; + DeclInfo *d = decl_info_of_entity(e); + if (d != nullptr) { + check_entity_decl(ctx, e, d, nullptr); + } + } + } + return; + } + Entity **entities = gb_alloc_array(permanent_allocator(), Entity *, vd->names.count); + isize entity_count = 0; + + isize new_name_count = 0; + for (Ast *name : vd->names) { + Entity *entity = nullptr; + if (name->kind != Ast_Ident) { + error(name, "A variable declaration must be an identifier"); + } else { + Token token = name->Ident.token; + String str = token.string; + Entity *found = nullptr; + // NOTE(bill): Ignore assignments to '_' + if (!is_blank_ident(str)) { + found = scope_lookup_current(ctx->scope, str); + new_name_count += 1; + } + if (found == nullptr) { + entity = alloc_entity_variable(ctx->scope, token, nullptr); + entity->identifier = name; + + Ast *fl = ctx->foreign_context.curr_library; + if (fl != nullptr) { + GB_ASSERT(fl->kind == Ast_Ident); + entity->Variable.is_foreign = true; + entity->Variable.foreign_library_ident = fl; + } + } else { + TokenPos pos = found->token.pos; + error(token, + "Redeclaration of '%.*s' in this scope\n" + "\tat %s", + LIT(str), token_pos_to_string(pos)); + entity = found; + } + } + if (entity == nullptr) { + entity = alloc_entity_dummy_variable(builtin_pkg->scope, ast_token(name)); + } + entity->parent_proc_decl = ctx->curr_proc_decl; + entities[entity_count++] = entity; + if (name->kind == Ast_Ident) { + name->Ident.entity = entity; + } + } + + if (new_name_count == 0) { + begin_error_block(); + error(node, "No new declarations on the left hand side"); + bool all_underscore = true; + for (Ast *name : vd->names) { + if (name->kind == Ast_Ident) { + if (!is_blank_ident(name)) { + all_underscore = false; + break; + } + } else { + all_underscore = false; + break; + } + } + if (all_underscore) { + error_line("\tSuggestion: Try changing the declaration (:=) to an assignment (=)\n"); + } + + end_error_block(); + } + + Type *init_type = nullptr; + if (vd->type != nullptr) { + init_type = check_type(ctx, vd->type); + if (init_type == nullptr) { + init_type = t_invalid; + } else if (is_type_polymorphic(base_type(init_type))) { + gbString str = type_to_string(init_type); + error(vd->type, "Invalid use of a polymorphic type '%s' in variable declaration", str); + gb_string_free(str); + init_type = t_invalid; + } + } + + + // TODO NOTE(bill): This technically checks things multple times + AttributeContext ac = make_attribute_context(ctx->foreign_context.link_prefix); + check_decl_attributes(ctx, vd->attributes, var_decl_attribute, &ac); + + for (isize i = 0; i < entity_count; i++) { + Entity *e = entities[i]; + GB_ASSERT(e != nullptr); + if (e->flags & EntityFlag_Visited) { + e->type = t_invalid; + continue; + } + e->flags |= EntityFlag_Visited; + + e->state = EntityState_InProgress; + if (e->type == nullptr) { + e->type = init_type; + e->state = EntityState_Resolved; + } + ac.link_name = handle_link_name(ctx, e->token, ac.link_name, ac.link_prefix); + + if (ac.link_name.len > 0) { + e->Variable.link_name = ac.link_name; + } + + e->flags &= ~EntityFlag_Static; + if (ac.is_static) { + String name = e->token.string; + if (name == "_") { + error(e->token, "The 'static' attribute is not allowed to be applied to '_'"); + } else { + e->flags |= EntityFlag_Static; + if (ctx->in_defer) { + error(e->token, "'static' variables cannot be declared within a defer statement"); + } + } + } + if (ac.thread_local_model != "") { + String name = e->token.string; + if (name == "_") { + error(e->token, "The 'thread_local' attribute is not allowed to be applied to '_'"); + } else { + e->flags |= EntityFlag_Static; + if (ctx->in_defer) { + error(e->token, "'thread_local' variables cannot be declared within a defer statement"); + } + } + e->Variable.thread_local_model = ac.thread_local_model; + } + + if (is_arch_wasm() && e->Variable.thread_local_model.len != 0) { + error(e->token, "@(thread_local) is not supported for this target platform"); + } + + + if (ac.is_static && ac.thread_local_model != "") { + error(e->token, "The 'static' attribute is not needed if 'thread_local' is applied"); + } + } + + check_init_variables(ctx, entities, entity_count, vd->values, str_lit("variable declaration")); + check_arity_match(ctx, vd, false); + + for (isize i = 0; i < entity_count; i++) { + Entity *e = entities[i]; + + if (e->Variable.is_foreign) { + if (vd->values.count > 0) { + error(e->token, "A foreign variable declaration cannot have a default value"); + } + + String name = e->token.string; + if (e->Variable.link_name.len > 0) { + name = e->Variable.link_name; + } + + if (vd->values.count > 0) { + error(e->token, "A foreign variable declaration cannot have a default value"); + } + init_entity_foreign_library(ctx, e); + + auto *fp = &ctx->checker->info.foreigns; + StringHashKey key = string_hash_string(name); + Entity **found = string_map_get(fp, key); + if (found) { + Entity *f = *found; + TokenPos pos = f->token.pos; + Type *this_type = base_type(e->type); + Type *other_type = base_type(f->type); + if (!are_types_identical(this_type, other_type)) { + error(e->token, + "Foreign entity '%.*s' previously declared elsewhere with a different type\n" + "\tat %s", + LIT(name), token_pos_to_string(pos)); + } + } else { + string_map_set(fp, key, e); + } + } else if (e->flags & EntityFlag_Static) { + if (vd->values.count > 0) { + if (entity_count != vd->values.count) { + error(e->token, "A static variable declaration with a default value must be constant"); + } else { + Ast *value = vd->values[i]; + if (value->tav.mode != Addressing_Constant) { + error(e->token, "A static variable declaration with a default value must be constant"); + } + } + } + } + add_entity(ctx, ctx->scope, e->identifier, e); + } + + if (vd->is_using != 0) { + Token token = ast_token(node); + if (vd->type != nullptr && entity_count > 1) { + error(token, "'using' can only be applied to one variable of the same type"); + // TODO(bill): Should a 'continue' happen here? + } + + for (isize entity_index = 0; entity_index < 1; entity_index++) { + Entity *e = entities[entity_index]; + if (e == nullptr) { + continue; + } + if (e->kind != Entity_Variable) { + continue; + } + String name = e->token.string; + Type *t = base_type(type_deref(e->type)); + + if (is_blank_ident(name)) { + error(token, "'using' cannot be applied variable declared as '_'"); + } else if (is_type_struct(t) || is_type_raw_union(t)) { + ERROR_BLOCK(); + + Scope *scope = t->Struct.scope; + GB_ASSERT(scope != nullptr); + for (auto const &entry : scope->elements) { + Entity *f = entry.value; + if (f->kind == Entity_Variable) { + Entity *uvar = alloc_entity_using_variable(e, f->token, f->type, nullptr); + uvar->flags |= (e->flags & EntityFlag_Value); + Entity *prev = scope_insert(ctx->scope, uvar); + if (prev != nullptr) { + error(token, "Namespace collision while 'using' '%.*s' of: %.*s", LIT(name), LIT(prev->token.string)); + return; + } + } + } + + add_entity_use(ctx, nullptr, e); + } else { + // NOTE(bill): skip the rest to remove extra errors + error(token, "'using' can only be applied to variables of type struct or raw_union"); + return; + } + } + } +} + +gb_internal void check_expr_stmt(CheckerContext *ctx, Ast *node) { + ast_node(es, ExprStmt, node); + + Operand operand = {Addressing_Invalid}; + ExprKind kind = check_expr_base(ctx, &operand, es->expr, nullptr); + switch (operand.mode) { + case Addressing_Type: + { + gbString str = type_to_string(operand.type); + error(node, "'%s' is not an expression but a type and cannot be used as a statement", str); + gb_string_free(str); + break; + } + case Addressing_NoValue: + return; + } + if (kind == Expr_Stmt) { + return; + } + + Ast *expr = strip_or_return_expr(operand.expr); + if (expr->kind == Ast_CallExpr) { + BuiltinProcId builtin_id = BuiltinProc_Invalid; + bool do_require = false; + + AstCallExpr *ce = &expr->CallExpr; + Type *t = base_type(type_of_expr(ce->proc)); + if (t->kind == Type_Proc) { + do_require = t->Proc.require_results; + } else if (check_stmt_internal_builtin_proc_id(ce->proc, &builtin_id)) { + auto const &bp = builtin_procs[builtin_id]; + do_require = bp.kind == Expr_Expr && !bp.ignore_results; + } + if (do_require) { + gbString expr_str = expr_to_string(ce->proc); + error(node, "'%s' requires that its results must be handled", expr_str); + gb_string_free(expr_str); + } + return; + } else if (expr->kind == Ast_SelectorCallExpr) { + BuiltinProcId builtin_id = BuiltinProc_Invalid; + bool do_require = false; + + AstSelectorCallExpr *se = &expr->SelectorCallExpr; + ast_node(ce, CallExpr, se->call); + Type *t = base_type(type_of_expr(ce->proc)); + if (t == nullptr) { + gbString expr_str = expr_to_string(ce->proc); + error(node, "'%s' is not a value field nor procedure", expr_str); + gb_string_free(expr_str); + return; + } + if (t->kind == Type_Proc) { + do_require = t->Proc.require_results; + } else if (check_stmt_internal_builtin_proc_id(ce->proc, &builtin_id)) { + auto const &bp = builtin_procs[builtin_id]; + do_require = bp.kind == Expr_Expr && !bp.ignore_results; + } + if (do_require) { + gbString expr_str = expr_to_string(ce->proc); + error(node, "'%s' requires that its results must be handled", expr_str); + gb_string_free(expr_str); + } + return; + } + gbString expr_str = expr_to_string(operand.expr); + error(node, "Expression is not used: '%s'", expr_str); + gb_string_free(expr_str); + if (operand.expr->kind == Ast_BinaryExpr) { + ast_node(be, BinaryExpr, operand.expr); + if (be->op.kind != Token_CmpEq) { + return; + } + + switch (be->left->tav.mode) { + case Addressing_Context: + case Addressing_Variable: + case Addressing_MapIndex: + case Addressing_SoaVariable: + { + gbString lhs = expr_to_string(be->left); + gbString rhs = expr_to_string(be->right); + error_line("\tSuggestion: Did you mean to do an assignment?\n", lhs, rhs); + error_line("\t '%s = %s;'\n", lhs, rhs); + gb_string_free(rhs); + gb_string_free(lhs); + } + break; + } + } +} + +gb_internal void check_assign_stmt(CheckerContext *ctx, Ast *node) { + ast_node(as, AssignStmt, node); + + if (as->op.kind == Token_Eq) { + // a, b, c = 1, 2, 3; // Multisided + + isize lhs_count = as->lhs.count; + if (lhs_count == 0) { + error(as->op, "Missing lhs in assignment statement"); + return; + } + + TEMPORARY_ALLOCATOR_GUARD(); + + // NOTE(bill): If there is a bad syntax error, rhs > lhs which would mean there would need to be + // an extra allocation + auto lhs_operands = array_make(temporary_allocator(), lhs_count); + auto rhs_operands = array_make(temporary_allocator(), 0, 2*lhs_count); + + for_array(i, as->lhs) { + if (is_blank_ident(as->lhs[i])) { + Operand *o = &lhs_operands[i]; + o->expr = as->lhs[i]; + o->mode = Addressing_Value; + } else { + ctx->assignment_lhs_hint = unparen_expr(as->lhs[i]); + check_expr(ctx, &lhs_operands[i], as->lhs[i]); + } + } + ctx->assignment_lhs_hint = nullptr; // Reset the assignment_lhs_hint + + check_assignment_arguments(ctx, lhs_operands, &rhs_operands, as->rhs); + + auto lhs_to_ignore = array_make(temporary_allocator(), lhs_count); + + isize rhs_count = rhs_operands.count; + isize max = gb_min(lhs_count, rhs_count); + for (isize i = 0; i < max; i++) { + if (lhs_to_ignore[i]) { + continue; + } + check_assignment_variable(ctx, &lhs_operands[i], &rhs_operands[i]); + } + if (lhs_count != rhs_count) { + error(as->lhs[0], "Assignment count mismatch '%td' = '%td'", lhs_count, rhs_count); + } + + } else { + // a += 1; // Single-sided + Token op = as->op; + if (as->lhs.count != 1 || as->rhs.count != 1) { + error(op, "Assignment operation '%.*s' requires single-valued expressions", LIT(op.string)); + return; + } + if (!gb_is_between(op.kind, Token__AssignOpBegin+1, Token__AssignOpEnd-1)) { + error(op, "Unknown Assignment operation '%.*s'", LIT(op.string)); + return; + } + Operand lhs = {Addressing_Invalid}; + Operand rhs = {Addressing_Invalid}; + Ast *binary_expr = alloc_ast_node(node->file(), Ast_BinaryExpr); + ast_node(be, BinaryExpr, binary_expr); + be->op = op; + be->op.kind = cast(TokenKind)(cast(i32)be->op.kind - (Token_AddEq - Token_Add)); + // NOTE(bill): Only use the first one will be used + be->left = as->lhs[0]; + be->right = as->rhs[0]; + + check_expr(ctx, &lhs, as->lhs[0]); + check_binary_expr(ctx, &rhs, binary_expr, nullptr, true); + if (rhs.mode != Addressing_Invalid) { + // NOTE(bill): Only use the first one will be used + check_assignment_variable(ctx, &lhs, &rhs); + } + } +} + +gb_internal void check_if_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags) { + ast_node(is, IfStmt, node); + check_open_scope(ctx, node); + + check_label(ctx, is->label, node); + + if (is->init != nullptr) { + check_stmt(ctx, is->init, 0); + } + + Operand operand = {Addressing_Invalid}; + check_expr(ctx, &operand, is->cond); + if (operand.mode != Addressing_Invalid && !is_type_boolean(operand.type)) { + error(is->cond, "Non-boolean condition in 'if' statement"); + } + + check_stmt(ctx, is->body, mod_flags); + + if (is->else_stmt != nullptr) { + switch (is->else_stmt->kind) { + case Ast_IfStmt: + case Ast_BlockStmt: + check_stmt(ctx, is->else_stmt, mod_flags); + break; + default: + error(is->else_stmt, "Invalid 'else' statement in 'if' statement"); + break; + } + } + + check_close_scope(ctx); +} + +gb_internal void check_return_stmt(CheckerContext *ctx, Ast *node) { + ast_node(rs, ReturnStmt, node); + + GB_ASSERT(ctx->curr_proc_sig != nullptr); + + if (ctx->in_defer) { + error(rs->token, "'return' cannot be used within a defer statement"); + return; + } + + Type *proc_type = ctx->curr_proc_sig; + GB_ASSERT(proc_type != nullptr); + GB_ASSERT(proc_type->kind == Type_Proc); + + TypeProc *pt = &proc_type->Proc; + if (pt->diverging) { + error(rs->token, "Diverging procedures may not return"); + return; + } + + Entity **result_entities = nullptr; + isize result_count = 0; + bool has_named_results = pt->has_named_results; + if (pt->results) { + result_entities = proc_type->Proc.results->Tuple.variables.data; + result_count = proc_type->Proc.results->Tuple.variables.count; + } + + auto operands = array_make(heap_allocator(), 0, 2*rs->results.count); + defer (array_free(&operands)); + + check_unpack_arguments(ctx, result_entities, result_count, &operands, rs->results, UnpackFlag_AllowOk); + + if (result_count == 0 && rs->results.count > 0) { + error(rs->results[0], "No return values expected"); + } else if (has_named_results && operands.count == 0) { + // Okay + } else if (operands.count != result_count) { + // Ignore error message as it has most likely already been reported + if (all_operands_valid(operands)) { + if (operands.count == 1) { + gbString t = type_to_string(operands[0].type); + error(node, "Expected %td return values, got %td (%s)", result_count, operands.count, t); + gb_string_free(t); + } else { + error(node, "Expected %td return values, got %td", result_count, operands.count); + } + } + } else { + for (isize i = 0; i < result_count; i++) { + Entity *e = pt->results->Tuple.variables[i]; + Operand *o = &operands[i]; + check_assignment(ctx, o, e->type, str_lit("return statement")); + if (is_type_untyped(o->type)) { + update_untyped_expr_type(ctx, o->expr, e->type, true); + } + + + // NOTE(bill): This is very basic escape analysis + // This needs to be improved tremendously, and a lot of it done during the + // middle-end (or LLVM side) to improve checks and error messages + Ast *expr = unparen_expr(o->expr); + if (expr->kind == Ast_UnaryExpr && expr->UnaryExpr.op.kind == Token_And) { + Ast *x = unparen_expr(expr->UnaryExpr.expr); + if (x->kind == Ast_CompoundLit) { + error(expr, "Cannot return the address to a stack value from a procedure"); + } else if (x->kind == Ast_IndexExpr) { + Ast *array = x->IndexExpr.expr; + if (is_type_array_like(type_of_expr(array)) && check_expr_is_stack_variable(array)) { + gbString t = type_to_string(type_of_expr(array)); + error(expr, "Cannot return the address to an element of stack variable from a procedure, of type %s", t); + gb_string_free(t); + } + } else { + if (check_expr_is_stack_variable(x)) { + error(expr, "Cannot return the address to a stack variable from a procedure"); + } + } + } + } + } +} + +gb_internal void check_for_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags) { + ast_node(fs, ForStmt, node); + mod_flags |= Stmt_BreakAllowed | Stmt_ContinueAllowed; + + check_open_scope(ctx, node); + check_label(ctx, fs->label, node); // TODO(bill): What should the label's "scope" be? + + if (fs->init != nullptr) { + check_stmt(ctx, fs->init, 0); + } + if (fs->cond != nullptr) { + Operand o = {Addressing_Invalid}; + check_expr(ctx, &o, fs->cond); + if (o.mode != Addressing_Invalid && !is_type_boolean(o.type)) { + error(fs->cond, "Non-boolean condition in 'for' statement"); + } + } + if (fs->post != nullptr) { + check_stmt(ctx, fs->post, 0); + + if (fs->post->kind != Ast_AssignStmt) { + error(fs->post, "'for' statement post statement must be a simple statement"); + } + } + check_stmt(ctx, fs->body, mod_flags); + + check_close_scope(ctx); +} + + +gb_internal void check_stmt_internal(CheckerContext *ctx, Ast *node, u32 flags) { u32 mod_flags = flags & (~Stmt_FallthroughAllowed); switch (node->kind) { case_ast_node(_, EmptyStmt, node); case_end; @@ -1427,191 +2288,11 @@ void check_stmt_internal(CheckerContext *ctx, Ast *node, u32 flags) { case_ast_node(_, BadDecl, node); case_end; case_ast_node(es, ExprStmt, node) - Operand operand = {Addressing_Invalid}; - ExprKind kind = check_expr_base(ctx, &operand, es->expr, nullptr); - switch (operand.mode) { - case Addressing_Type: { - gbString str = type_to_string(operand.type); - error(node, "'%s' is not an expression", str); - gb_string_free(str); - - break; - } - case Addressing_NoValue: - return; - default: { - if (kind == Expr_Stmt) { - return; - } - - Ast *expr = strip_or_return_expr(operand.expr); - if (expr->kind == Ast_CallExpr) { - BuiltinProcId builtin_id = BuiltinProc_Invalid; - bool do_require = false; - - AstCallExpr *ce = &expr->CallExpr; - Type *t = base_type(type_of_expr(ce->proc)); - if (t->kind == Type_Proc) { - do_require = t->Proc.require_results; - } else if (check_stmt_internal_builtin_proc_id(ce->proc, &builtin_id)) { - auto const &bp = builtin_procs[builtin_id]; - do_require = bp.kind == Expr_Expr && !bp.ignore_results; - } - if (do_require) { - gbString expr_str = expr_to_string(ce->proc); - error(node, "'%s' requires that its results must be handled", expr_str); - gb_string_free(expr_str); - } - return; - } else if (expr->kind == Ast_SelectorCallExpr) { - BuiltinProcId builtin_id = BuiltinProc_Invalid; - bool do_require = false; - - AstSelectorCallExpr *se = &expr->SelectorCallExpr; - ast_node(ce, CallExpr, se->call); - Type *t = base_type(type_of_expr(ce->proc)); - if (t == nullptr) { - gbString expr_str = expr_to_string(ce->proc); - error(node, "'%s' is not a value field nor procedure", expr_str); - gb_string_free(expr_str); - return; - } - if (t->kind == Type_Proc) { - do_require = t->Proc.require_results; - } else if (check_stmt_internal_builtin_proc_id(ce->proc, &builtin_id)) { - auto const &bp = builtin_procs[builtin_id]; - do_require = bp.kind == Expr_Expr && !bp.ignore_results; - } - if (do_require) { - gbString expr_str = expr_to_string(ce->proc); - error(node, "'%s' requires that its results must be handled", expr_str); - gb_string_free(expr_str); - } - return; - } - gbString expr_str = expr_to_string(operand.expr); - error(node, "Expression is not used: '%s'", expr_str); - gb_string_free(expr_str); - if (operand.expr->kind == Ast_BinaryExpr) { - ast_node(be, BinaryExpr, operand.expr); - if (be->op.kind != Token_CmpEq) { - break; - } - - switch (be->left->tav.mode) { - case Addressing_Context: - case Addressing_Variable: - case Addressing_MapIndex: - case Addressing_SoaVariable: - { - gbString lhs = expr_to_string(be->left); - gbString rhs = expr_to_string(be->right); - error_line("\tSuggestion: Did you mean to do an assignment?\n", lhs, rhs); - error_line("\t '%s = %s;'\n", lhs, rhs); - gb_string_free(rhs); - gb_string_free(lhs); - } - break; - } - } - - break; - } - } - case_end; - - case_ast_node(ts, TagStmt, node); - // TODO(bill): Tag Statements - error(node, "Tag statements are not supported yet"); - check_stmt(ctx, ts->stmt, flags); + check_expr_stmt(ctx, node); case_end; case_ast_node(as, AssignStmt, node); - switch (as->op.kind) { - case Token_Eq: { - // a, b, c = 1, 2, 3; // Multisided - - isize lhs_count = as->lhs.count; - if (lhs_count == 0) { - error(as->op, "Missing lhs in assignment statement"); - return; - } - - - // NOTE(bill): If there is a bad syntax error, rhs > lhs which would mean there would need to be - // an extra allocation - auto lhs_operands = array_make(temporary_allocator(), lhs_count); - auto rhs_operands = array_make(temporary_allocator(), 0, 2*lhs_count); - - for_array(i, as->lhs) { - if (is_blank_ident(as->lhs[i])) { - Operand *o = &lhs_operands[i]; - o->expr = as->lhs[i]; - o->mode = Addressing_Value; - } else { - ctx->assignment_lhs_hint = unparen_expr(as->lhs[i]); - check_expr(ctx, &lhs_operands[i], as->lhs[i]); - } - } - ctx->assignment_lhs_hint = nullptr; // Reset the assignment_lhs_hint - - check_assignment_arguments(ctx, lhs_operands, &rhs_operands, as->rhs); - - isize rhs_count = rhs_operands.count; - for_array(i, rhs_operands) { - if (rhs_operands[i].mode == Addressing_Invalid) { - // TODO(bill): Should I ignore invalid parameters? - // rhs_count--; - } - } - - auto lhs_to_ignore = array_make(temporary_allocator(), lhs_count); - - isize max = gb_min(lhs_count, rhs_count); - for (isize i = 0; i < max; i++) { - if (lhs_to_ignore[i]) { - continue; - } - check_assignment_variable(ctx, &lhs_operands[i], &rhs_operands[i]); - } - if (lhs_count != rhs_count) { - error(as->lhs[0], "Assignment count mismatch '%td' = '%td'", lhs_count, rhs_count); - } - break; - } - - default: { - // a += 1; // Single-sided - Token op = as->op; - if (as->lhs.count != 1 || as->rhs.count != 1) { - error(op, "Assignment operation '%.*s' requires single-valued expressions", LIT(op.string)); - return; - } - if (!gb_is_between(op.kind, Token__AssignOpBegin+1, Token__AssignOpEnd-1)) { - error(op, "Unknown Assignment operation '%.*s'", LIT(op.string)); - return; - } - Operand lhs = {Addressing_Invalid}; - Operand rhs = {Addressing_Invalid}; - Ast *binary_expr = alloc_ast_node(node->file(), Ast_BinaryExpr); - ast_node(be, BinaryExpr, binary_expr); - be->op = op; - be->op.kind = cast(TokenKind)(cast(i32)be->op.kind - (Token_AddEq - Token_Add)); - // NOTE(bill): Only use the first one will be used - be->left = as->lhs[0]; - be->right = as->rhs[0]; - - check_expr(ctx, &lhs, as->lhs[0]); - check_binary_expr(ctx, &rhs, binary_expr, nullptr, true); - if (rhs.mode == Addressing_Invalid) { - return; - } - // NOTE(bill): Only use the first one will be used - check_assignment_variable(ctx, &lhs, &rhs); - - break; - } - } + check_assign_stmt(ctx, node); case_end; case_ast_node(bs, BlockStmt, node); @@ -1624,35 +2305,7 @@ void check_stmt_internal(CheckerContext *ctx, Ast *node, u32 flags) { case_end; case_ast_node(is, IfStmt, node); - check_open_scope(ctx, node); - - check_label(ctx, is->label, node); - - if (is->init != nullptr) { - check_stmt(ctx, is->init, 0); - } - - Operand operand = {Addressing_Invalid}; - check_expr(ctx, &operand, is->cond); - if (operand.mode != Addressing_Invalid && !is_type_boolean(operand.type)) { - error(is->cond, "Non-boolean condition in 'if' statement"); - } - - check_stmt(ctx, is->body, mod_flags); - - if (is->else_stmt != nullptr) { - switch (is->else_stmt->kind) { - case Ast_IfStmt: - case Ast_BlockStmt: - check_stmt(ctx, is->else_stmt, mod_flags); - break; - default: - error(is->else_stmt, "Invalid 'else' statement in 'if' statement"); - break; - } - } - - check_close_scope(ctx); + check_if_stmt(ctx, node, mod_flags); case_end; case_ast_node(ws, WhenStmt, node); @@ -1660,341 +2313,15 @@ void check_stmt_internal(CheckerContext *ctx, Ast *node, u32 flags) { case_end; case_ast_node(rs, ReturnStmt, node); - GB_ASSERT(ctx->curr_proc_sig != nullptr); - - if (ctx->in_defer) { - error(rs->token, "'return' cannot be used within a defer statement"); - break; - } - - Type *proc_type = ctx->curr_proc_sig; - GB_ASSERT(proc_type != nullptr); - GB_ASSERT(proc_type->kind == Type_Proc); - - TypeProc *pt = &proc_type->Proc; - if (pt->diverging) { - error(rs->token, "Diverging procedures may not return"); - break; - } - - Entity **result_entities = nullptr; - isize result_count = 0; - bool has_named_results = pt->has_named_results; - if (pt->results) { - result_entities = proc_type->Proc.results->Tuple.variables.data; - result_count = proc_type->Proc.results->Tuple.variables.count; - } - - auto operands = array_make(heap_allocator(), 0, 2*rs->results.count); - defer (array_free(&operands)); - - check_unpack_arguments(ctx, result_entities, result_count, &operands, rs->results, true, false); - - if (result_count == 0 && rs->results.count > 0) { - error(rs->results[0], "No return values expected"); - } else if (has_named_results && operands.count == 0) { - // Okay - } else if (operands.count != result_count) { - // Ignore error message as it has most likely already been reported - if (all_operands_valid(operands)) { - error(node, "Expected %td return values, got %td", result_count, operands.count); - } - } else { - for (isize i = 0; i < result_count; i++) { - Entity *e = pt->results->Tuple.variables[i]; - Operand *o = &operands[i]; - check_assignment(ctx, o, e->type, str_lit("return statement")); - if (is_type_untyped(o->type)) { - update_untyped_expr_type(ctx, o->expr, e->type, true); - } - - - // NOTE(bill): This is very basic escape analysis - // This needs to be improved tremendously, and a lot of it done during the - // middle-end (or LLVM side) to improve checks and error messages - Ast *expr = unparen_expr(o->expr); - if (expr->kind == Ast_UnaryExpr && expr->UnaryExpr.op.kind == Token_And) { - Ast *x = unparen_expr(expr->UnaryExpr.expr); - if (x->kind == Ast_CompoundLit) { - error(expr, "Cannot return the address to a stack value from a procedure"); - } else if (x->kind == Ast_IndexExpr) { - Ast *array = x->IndexExpr.expr; - if (is_type_array_like(type_of_expr(array)) && check_expr_is_stack_variable(array)) { - gbString t = type_to_string(type_of_expr(array)); - error(expr, "Cannot return the address to an element of stack variable from a procedure, of type %s", t); - gb_string_free(t); - } - } else { - if (check_expr_is_stack_variable(x)) { - error(expr, "Cannot return the address to a stack variable from a procedure"); - } - } - } - } - } + check_return_stmt(ctx, node); case_end; case_ast_node(fs, ForStmt, node); - u32 new_flags = mod_flags | Stmt_BreakAllowed | Stmt_ContinueAllowed; - - check_open_scope(ctx, node); - check_label(ctx, fs->label, node); // TODO(bill): What should the label's "scope" be? - - if (fs->init != nullptr) { - check_stmt(ctx, fs->init, 0); - } - if (fs->cond != nullptr) { - Operand o = {Addressing_Invalid}; - check_expr(ctx, &o, fs->cond); - if (o.mode != Addressing_Invalid && !is_type_boolean(o.type)) { - error(fs->cond, "Non-boolean condition in 'for' statement"); - } - } - if (fs->post != nullptr) { - check_stmt(ctx, fs->post, 0); - - if (fs->post->kind != Ast_AssignStmt) { - error(fs->post, "'for' statement post statement must be a simple statement"); - } - } - check_stmt(ctx, fs->body, new_flags); - - check_close_scope(ctx); + check_for_stmt(ctx, node, mod_flags); case_end; - case_ast_node(rs, RangeStmt, node); - u32 new_flags = mod_flags | Stmt_BreakAllowed | Stmt_ContinueAllowed; - - check_open_scope(ctx, node); - check_label(ctx, rs->label, node); - - auto vals = array_make(temporary_allocator(), 0, 2); - auto entities = array_make(temporary_allocator(), 0, 2); - bool is_map = false; - bool use_by_reference_for_value = false; - bool is_soa = false; - - Ast *expr = unparen_expr(rs->expr); - - isize max_val_count = 2; - if (is_ast_range(expr)) { - ast_node(ie, BinaryExpr, expr); - Operand x = {}; - Operand y = {}; - - bool ok = check_range(ctx, expr, &x, &y, nullptr); - if (!ok) { - goto skip_expr_range_stmt; - } - array_add(&vals, x.type); - array_add(&vals, t_int); - } else { - Operand operand = {Addressing_Invalid}; - check_expr_base(ctx, &operand, expr, nullptr); - error_operand_no_value(&operand); - - if (operand.mode == Addressing_Type) { - if (!is_type_enum(operand.type)) { - gbString t = type_to_string(operand.type); - error(operand.expr, "Cannot iterate over the type '%s'", t); - gb_string_free(t); - goto skip_expr_range_stmt; - } else { - array_add(&vals, operand.type); - array_add(&vals, t_int); - add_type_info_type(ctx, operand.type); - goto skip_expr_range_stmt; - } - } else if (operand.mode != Addressing_Invalid) { - bool is_ptr = is_type_pointer(operand.type); - Type *t = base_type(type_deref(operand.type)); - switch (t->kind) { - case Type_Basic: - if (is_type_string(t) && t->Basic.kind != Basic_cstring) { - array_add(&vals, t_rune); - array_add(&vals, t_int); - add_package_dependency(ctx, "runtime", "string_decode_rune"); - } - break; - - case Type_EnumeratedArray: - if (is_ptr) use_by_reference_for_value = true; - array_add(&vals, t->EnumeratedArray.elem); - array_add(&vals, t->EnumeratedArray.index); - break; - - case Type_Array: - if (is_ptr) use_by_reference_for_value = true; - array_add(&vals, t->Array.elem); - array_add(&vals, t_int); - break; - - case Type_DynamicArray: - if (is_ptr) use_by_reference_for_value = true; - array_add(&vals, t->DynamicArray.elem); - array_add(&vals, t_int); - break; - - case Type_Slice: - if (is_ptr) use_by_reference_for_value = true; - array_add(&vals, t->Slice.elem); - array_add(&vals, t_int); - break; - - case Type_Map: - if (is_ptr) use_by_reference_for_value = true; - is_map = true; - array_add(&vals, t->Map.key); - array_add(&vals, t->Map.value); - break; - - case Type_Tuple: - { - isize count = t->Tuple.variables.count; - if (count < 1 || count > 3) { - check_not_tuple(ctx, &operand); - error_line("\tMultiple return valued parameters in a range statement are limited to a maximum of 2 usable values with a trailing boolean for the conditional\n"); - break; - } - Type *cond_type = t->Tuple.variables[count-1]->type; - if (!is_type_boolean(cond_type)) { - gbString s = type_to_string(cond_type); - error(operand.expr, "The final type of %td-valued expression must be a boolean, got %s", count, s); - gb_string_free(s); - break; - } - - for_array(ti, t->Tuple.variables) { - array_add(&vals, t->Tuple.variables[ti]->type); - } - - if (rs->vals.count > 1 && rs->vals[1] != nullptr && count < 3) { - gbString s = type_to_string(t); - error(operand.expr, "Expected a 3-valued expression on the rhs, got (%s)", s); - gb_string_free(s); - break; - } - - if (rs->vals.count > 0 && rs->vals[0] != nullptr && count < 2) { - gbString s = type_to_string(t); - error(operand.expr, "Expected at least a 2-valued expression on the rhs, got (%s)", s); - gb_string_free(s); - break; - } - - } - break; - - case Type_Struct: - if (t->Struct.soa_kind != StructSoa_None) { - is_soa = true; - if (is_ptr) use_by_reference_for_value = true; - array_add(&vals, t->Struct.soa_elem); - array_add(&vals, t_int); - } - break; - } - } - - if (vals.count == 0 || vals[0] == nullptr) { - gbString s = expr_to_string(operand.expr); - gbString t = type_to_string(operand.type); - defer (gb_string_free(s)); - defer (gb_string_free(t)); - - error(operand.expr, "Cannot iterate over '%s' of type '%s'", s, t); - - if (rs->vals.count == 1) { - Type *t = type_deref(operand.type); - if (is_type_map(t) || is_type_bit_set(t)) { - gbString v = expr_to_string(rs->vals[0]); - defer (gb_string_free(v)); - error_line("\tSuggestion: place parentheses around the expression\n"); - error_line("\t for (%s in %s) {\n", v, s); - } - } - } - } - - skip_expr_range_stmt:; // NOTE(zhiayang): again, declaring a variable immediately after a label... weird. - - if (rs->vals.count > max_val_count) { - error(rs->vals[max_val_count], "Expected a maximum of %td identifier%s, got %td", max_val_count, max_val_count == 1 ? "" : "s", rs->vals.count); - } - - auto rhs = slice_from_array(vals); - auto lhs = slice_make(temporary_allocator(), rhs.count); - slice_copy(&lhs, rs->vals); - - isize addressable_index = cast(isize)is_map; - - for_array(i, rhs) { - if (lhs[i] == nullptr) { - continue; - } - Ast * name = lhs[i]; - Type *type = rhs[i]; - - Entity *entity = nullptr; - if (name->kind == Ast_Ident) { - Token token = name->Ident.token; - String str = token.string; - Entity *found = nullptr; - - if (!is_blank_ident(str)) { - found = scope_lookup_current(ctx->scope, str); - } - if (found == nullptr) { - entity = alloc_entity_variable(ctx->scope, token, type, EntityState_Resolved); - entity->flags |= EntityFlag_ForValue; - entity->flags |= EntityFlag_Value; - if (i == addressable_index && use_by_reference_for_value) { - entity->flags &= ~EntityFlag_Value; - } - if (is_soa) { - if (i == 0) { - entity->flags |= EntityFlag_SoaPtrField; - } - } - - add_entity_definition(&ctx->checker->info, name, entity); - } else { - TokenPos pos = found->token.pos; - error(token, - "Redeclaration of '%.*s' in this scope\n" - "\tat %s", - LIT(str), token_pos_to_string(pos)); - entity = found; - } - } else { - error(name, "A variable declaration must be an identifier"); - } - - if (entity == nullptr) { - entity = alloc_entity_dummy_variable(builtin_pkg->scope, ast_token(name)); - } - - array_add(&entities, entity); - - if (type == nullptr) { - entity->type = t_invalid; - entity->flags |= EntityFlag_Used; - } - } - - for_array(i, entities) { - Entity *e = entities[i]; - DeclInfo *d = decl_info_of_entity(e); - GB_ASSERT(d == nullptr); - add_entity(ctx, ctx->scope, e->identifier, e); - d = make_decl_info(ctx->scope, ctx->decl); - add_entity_and_decl_info(ctx, e->identifier, e, d); - } - - check_stmt(ctx, rs->body, new_flags); - - check_close_scope(ctx); + check_range_stmt(ctx, node, mod_flags); case_end; case_ast_node(irs, UnrollRangeStmt, node); @@ -2098,8 +2425,8 @@ void check_stmt_internal(CheckerContext *ctx, Ast *node, u32 flags) { error(us->token, "Empty 'using' list"); return; } - for_array(i, us->list) { - Ast *expr = unparen_expr(us->list[i]); + for (Ast *expr : us->list) { + expr = unparen_expr(expr); Entity *e = nullptr; bool is_selector = false; @@ -2139,8 +2466,7 @@ void check_stmt_internal(CheckerContext *ctx, Ast *node, u32 flags) { check_decl_attributes(&c, fb->attributes, foreign_block_decl_attribute, nullptr); ast_node(block, BlockStmt, fb->body); - for_array(i, block->stmts) { - Ast *decl = block->stmts[i]; + for (Ast *decl : block->stmts) { if (decl->kind == Ast_ValueDecl && decl->ValueDecl.is_mutable) { check_stmt(&c, decl, flags); } @@ -2148,265 +2474,7 @@ void check_stmt_internal(CheckerContext *ctx, Ast *node, u32 flags) { case_end; case_ast_node(vd, ValueDecl, node); - if (vd->is_mutable) { - Entity **entities = gb_alloc_array(permanent_allocator(), Entity *, vd->names.count); - isize entity_count = 0; - - isize new_name_count = 0; - for_array(i, vd->names) { - Ast *name = vd->names[i]; - Entity *entity = nullptr; - if (name->kind != Ast_Ident) { - error(name, "A variable declaration must be an identifier"); - } else { - Token token = name->Ident.token; - String str = token.string; - Entity *found = nullptr; - // NOTE(bill): Ignore assignments to '_' - if (!is_blank_ident(str)) { - found = scope_lookup_current(ctx->scope, str); - new_name_count += 1; - } - if (found == nullptr) { - entity = alloc_entity_variable(ctx->scope, token, nullptr); - entity->identifier = name; - - Ast *fl = ctx->foreign_context.curr_library; - if (fl != nullptr) { - GB_ASSERT(fl->kind == Ast_Ident); - entity->Variable.is_foreign = true; - entity->Variable.foreign_library_ident = fl; - } - } else { - TokenPos pos = found->token.pos; - error(token, - "Redeclaration of '%.*s' in this scope\n" - "\tat %s", - LIT(str), token_pos_to_string(pos)); - entity = found; - } - } - if (entity == nullptr) { - entity = alloc_entity_dummy_variable(builtin_pkg->scope, ast_token(name)); - } - entity->parent_proc_decl = ctx->curr_proc_decl; - entities[entity_count++] = entity; - if (name->kind == Ast_Ident) { - name->Ident.entity = entity; - } - } - - if (new_name_count == 0) { - begin_error_block(); - error(node, "No new declarations on the left hand side"); - bool all_underscore = true; - for_array(i, vd->names) { - Ast *name = vd->names[i]; - if (name->kind == Ast_Ident) { - if (!is_blank_ident(name)) { - all_underscore = false; - break; - } - } else { - all_underscore = false; - break; - } - } - if (all_underscore) { - error_line("\tSuggestion: Try changing the declaration (:=) to an assignment (=)\n"); - } - - end_error_block(); - } - - Type *init_type = nullptr; - if (vd->type != nullptr) { - init_type = check_type(ctx, vd->type); - if (init_type == nullptr) { - init_type = t_invalid; - } else if (is_type_polymorphic(base_type(init_type))) { - gbString str = type_to_string(init_type); - error(vd->type, "Invalid use of a polymorphic type '%s' in variable declaration", str); - gb_string_free(str); - init_type = t_invalid; - } - } - - - // TODO NOTE(bill): This technically checks things multple times - AttributeContext ac = make_attribute_context(ctx->foreign_context.link_prefix); - check_decl_attributes(ctx, vd->attributes, var_decl_attribute, &ac); - - for (isize i = 0; i < entity_count; i++) { - Entity *e = entities[i]; - GB_ASSERT(e != nullptr); - if (e->flags & EntityFlag_Visited) { - e->type = t_invalid; - continue; - } - e->flags |= EntityFlag_Visited; - - e->state = EntityState_InProgress; - if (e->type == nullptr) { - e->type = init_type; - e->state = EntityState_Resolved; - } - ac.link_name = handle_link_name(ctx, e->token, ac.link_name, ac.link_prefix); - - if (ac.link_name.len > 0) { - e->Variable.link_name = ac.link_name; - } - - e->flags &= ~EntityFlag_Static; - if (ac.is_static) { - String name = e->token.string; - if (name == "_") { - error(e->token, "The 'static' attribute is not allowed to be applied to '_'"); - } else { - e->flags |= EntityFlag_Static; - if (ctx->in_defer) { - error(e->token, "'static' variables cannot be declared within a defer statement"); - } - } - } - if (ac.thread_local_model != "") { - String name = e->token.string; - if (name == "_") { - error(e->token, "The 'thread_local' attribute is not allowed to be applied to '_'"); - } else { - e->flags |= EntityFlag_Static; - if (ctx->in_defer) { - error(e->token, "'thread_local' variables cannot be declared within a defer statement"); - } - } - e->Variable.thread_local_model = ac.thread_local_model; - } - - if (is_arch_wasm() && e->Variable.thread_local_model.len != 0) { - error(e->token, "@(thread_local) is not supported for this target platform"); - } - - - if (ac.is_static && ac.thread_local_model != "") { - error(e->token, "The 'static' attribute is not needed if 'thread_local' is applied"); - } - } - - check_init_variables(ctx, entities, entity_count, vd->values, str_lit("variable declaration")); - check_arity_match(ctx, vd, false); - - for (isize i = 0; i < entity_count; i++) { - Entity *e = entities[i]; - - if (e->Variable.is_foreign) { - if (vd->values.count > 0) { - error(e->token, "A foreign variable declaration cannot have a default value"); - } - - String name = e->token.string; - if (e->Variable.link_name.len > 0) { - name = e->Variable.link_name; - } - - if (vd->values.count > 0) { - error(e->token, "A foreign variable declaration cannot have a default value"); - } - init_entity_foreign_library(ctx, e); - - auto *fp = &ctx->checker->info.foreigns; - StringHashKey key = string_hash_string(name); - Entity **found = string_map_get(fp, key); - if (found) { - Entity *f = *found; - TokenPos pos = f->token.pos; - Type *this_type = base_type(e->type); - Type *other_type = base_type(f->type); - if (!are_types_identical(this_type, other_type)) { - error(e->token, - "Foreign entity '%.*s' previously declared elsewhere with a different type\n" - "\tat %s", - LIT(name), token_pos_to_string(pos)); - } - } else { - string_map_set(fp, key, e); - } - } else if (e->flags & EntityFlag_Static) { - if (vd->values.count > 0) { - if (entity_count != vd->values.count) { - error(e->token, "A static variable declaration with a default value must be constant"); - } else { - Ast *value = vd->values[i]; - if (value->tav.mode != Addressing_Constant) { - error(e->token, "A static variable declaration with a default value must be constant"); - } - } - } - } - add_entity(ctx, ctx->scope, e->identifier, e); - } - - if (vd->is_using != 0) { - Token token = ast_token(node); - if (vd->type != nullptr && entity_count > 1) { - error(token, "'using' can only be applied to one variable of the same type"); - // TODO(bill): Should a 'continue' happen here? - } - - for (isize entity_index = 0; entity_index < 1; entity_index++) { - Entity *e = entities[entity_index]; - if (e == nullptr) { - continue; - } - if (e->kind != Entity_Variable) { - continue; - } - String name = e->token.string; - Type *t = base_type(type_deref(e->type)); - - if (is_blank_ident(name)) { - error(token, "'using' cannot be applied variable declared as '_'"); - } else if (is_type_struct(t) || is_type_raw_union(t)) { - ERROR_BLOCK(); - - Scope *scope = t->Struct.scope; - GB_ASSERT(scope != nullptr); - for_array(i, scope->elements.entries) { - Entity *f = scope->elements.entries[i].value; - if (f->kind == Entity_Variable) { - Entity *uvar = alloc_entity_using_variable(e, f->token, f->type, nullptr); - uvar->flags |= (e->flags & EntityFlag_Value); - Entity *prev = scope_insert(ctx->scope, uvar); - if (prev != nullptr) { - error(token, "Namespace collision while 'using' '%.*s' of: %.*s", LIT(name), LIT(prev->token.string)); - return; - } - } - } - - add_entity_use(ctx, nullptr, e); - } else { - // NOTE(bill): skip the rest to remove extra errors - error(token, "'using' can only be applied to variables of type struct or raw_union"); - return; - } - } - } - - } else { - // constant value declaration - // NOTE(bill): Check `_` declarations - for_array(i, vd->names) { - Ast *name = vd->names[i]; - if (is_blank_ident(name)) { - Entity *e = name->Ident.entity; - DeclInfo *d = decl_info_of_entity(e); - if (d != nullptr) { - check_entity_decl(ctx, e, d, nullptr); - } - } - } - - } + check_value_decl_stmt(ctx, node, mod_flags); case_end; } } diff --git a/src/check_type.cpp b/src/check_type.cpp index 377b2da1f..a68f83ba9 100644 --- a/src/check_type.cpp +++ b/src/check_type.cpp @@ -1,6 +1,6 @@ -ParameterValue handle_parameter_value(CheckerContext *ctx, Type *in_type, Type **out_type_, Ast *expr, bool allow_caller_location); +gb_internal ParameterValue handle_parameter_value(CheckerContext *ctx, Type *in_type, Type **out_type_, Ast *expr, bool allow_caller_location); -void populate_using_array_index(CheckerContext *ctx, Ast *node, AstField *field, Type *t, String name, i32 idx) { +gb_internal void populate_using_array_index(CheckerContext *ctx, Ast *node, AstField *field, Type *t, String name, i32 idx) { t = base_type(t); GB_ASSERT(t->kind == Type_Array); Entity *e = scope_lookup_current(ctx->scope, name); @@ -27,7 +27,7 @@ void populate_using_array_index(CheckerContext *ctx, Ast *node, AstField *field, } } -void populate_using_entity_scope(CheckerContext *ctx, Ast *node, AstField *field, Type *t) { +gb_internal void populate_using_entity_scope(CheckerContext *ctx, Ast *node, AstField *field, Type *t) { if (t == nullptr) { return; } @@ -81,7 +81,7 @@ void populate_using_entity_scope(CheckerContext *ctx, Ast *node, AstField *field } } -bool does_field_type_allow_using(Type *t) { +gb_internal bool does_field_type_allow_using(Type *t) { t = base_type(t); if (is_type_struct(t)) { return true; @@ -91,8 +91,8 @@ bool does_field_type_allow_using(Type *t) { return false; } -void check_struct_fields(CheckerContext *ctx, Ast *node, Slice *fields, String **tags, Slice const ¶ms, - isize init_field_capacity, Type *struct_type, String context) { +gb_internal void check_struct_fields(CheckerContext *ctx, Ast *node, Slice *fields, String **tags, Slice const ¶ms, + isize init_field_capacity, Type *struct_type, String context) { auto fields_array = array_make(heap_allocator(), 0, init_field_capacity); auto tags_array = array_make(heap_allocator(), 0, init_field_capacity); @@ -135,7 +135,7 @@ void check_struct_fields(CheckerContext *ctx, Ast *node, Slice *fields type = t_invalid; } if (is_type_untyped(type)) { - if (is_type_untyped_undef(type)) { + if (is_type_untyped_uninit(type)) { error(params[i], "Cannot determine parameter type from ---"); } else { error(params[i], "Cannot determine parameter type from a nil"); @@ -219,7 +219,7 @@ void check_struct_fields(CheckerContext *ctx, Ast *node, Slice *fields } -bool check_custom_align(CheckerContext *ctx, Ast *node, i64 *align_) { +gb_internal bool check_custom_align(CheckerContext *ctx, Ast *node, i64 *align_) { GB_ASSERT(align_ != nullptr); Operand o = {}; check_expr(ctx, &o, node); @@ -256,71 +256,88 @@ bool check_custom_align(CheckerContext *ctx, Ast *node, i64 *align_) { } -Entity *find_polymorphic_record_entity(CheckerContext *ctx, Type *original_type, isize param_count, Array const &ordered_operands, bool *failure) { - mutex_lock(&ctx->info->gen_types_mutex); - defer (mutex_unlock(&ctx->info->gen_types_mutex)); +gb_internal Entity *find_polymorphic_record_entity(CheckerContext *ctx, Type *original_type, isize param_count, Array const &ordered_operands, bool *failure) { + rw_mutex_shared_lock(&ctx->info->gen_types_mutex); // @@global auto *found_gen_types = map_get(&ctx->info->gen_types, original_type); - if (found_gen_types != nullptr) { - // GB_ASSERT_MSG(ordered_operands.count >= param_count, "%td >= %td", ordered_operands.count, param_count); + if (found_gen_types == nullptr) { + rw_mutex_shared_unlock(&ctx->info->gen_types_mutex); // @@global + return nullptr; + } - for_array(i, *found_gen_types) { - Entity *e = (*found_gen_types)[i]; - Type *t = base_type(e->type); - TypeTuple *tuple = get_record_polymorphic_params(t); - GB_ASSERT(param_count == tuple->variables.count); + rw_mutex_shared_lock(&found_gen_types->mutex); // @@local + defer (rw_mutex_shared_unlock(&found_gen_types->mutex)); // @@local - bool skip = false; + rw_mutex_shared_unlock(&ctx->info->gen_types_mutex); // @@global - for (isize j = 0; j < param_count; j++) { - Entity *p = tuple->variables[j]; - Operand o = {}; - if (j < ordered_operands.count) { - o = ordered_operands[j]; - } - if (o.expr == nullptr) { - continue; - } - Entity *oe = entity_of_node(o.expr); - if (p == oe) { - // NOTE(bill): This is the same type, make sure that it will be be same thing and use that - // Saves on a lot of checking too below - continue; - } - - if (p->kind == Entity_TypeName) { - if (is_type_polymorphic(o.type)) { - // NOTE(bill): Do not add polymorphic version to the gen_types - skip = true; - break; - } - if (!are_types_identical(o.type, p->type)) { - skip = true; - break; - } - } else if (p->kind == Entity_Constant) { - if (!compare_exact_values(Token_CmpEq, o.value, p->Constant.value)) { - skip = true; - break; - } - if (!are_types_identical(o.type, p->type)) { - skip = true; - break; - } - } else { - GB_PANIC("Unknown entity kind"); - } + for (Entity *e : found_gen_types->types) { + Type *t = base_type(e->type); + TypeTuple *tuple = nullptr; + switch (t->kind) { + case Type_Struct: + if (t->Struct.polymorphic_params) { + tuple = &t->Struct.polymorphic_params->Tuple; } - if (!skip) { - return e; + break; + case Type_Union: + if (t->Union.polymorphic_params) { + tuple = &t->Union.polymorphic_params->Tuple; } + break; + } + GB_ASSERT_MSG(tuple != nullptr, "%s :: %s", type_to_string(e->type), type_to_string(t)); + GB_ASSERT(param_count == tuple->variables.count); + + bool skip = false; + + for (isize j = 0; j < param_count; j++) { + Entity *p = tuple->variables[j]; + Operand o = {}; + if (j < ordered_operands.count) { + o = ordered_operands[j]; + } + if (o.expr == nullptr) { + continue; + } + Entity *oe = entity_of_node(o.expr); + if (p == oe) { + // NOTE(bill): This is the same type, make sure that it will be be same thing and use that + // Saves on a lot of checking too below + continue; + } + + if (p->kind == Entity_TypeName) { + if (is_type_polymorphic(o.type)) { + // NOTE(bill): Do not add polymorphic version to the gen_types + skip = true; + break; + } + if (!are_types_identical(o.type, p->type)) { + skip = true; + break; + } + } else if (p->kind == Entity_Constant) { + if (!compare_exact_values(Token_CmpEq, o.value, p->Constant.value)) { + skip = true; + break; + } + if (!are_types_identical(o.type, p->type)) { + skip = true; + break; + } + } else { + GB_PANIC("Unknown entity kind"); + } + } + if (!skip) { + return e; } } return nullptr; } -void add_polymorphic_record_entity(CheckerContext *ctx, Ast *node, Type *named_type, Type *original_type) { +gb_internal void add_polymorphic_record_entity(CheckerContext *ctx, Ast *node, Type *named_type, Type *original_type) { GB_ASSERT(is_type_named(named_type)); gbAllocator a = heap_allocator(); Scope *s = ctx->scope->parent; @@ -346,22 +363,35 @@ void add_polymorphic_record_entity(CheckerContext *ctx, Ast *node, Type *named_t // TODO(bill): Is this even correct? Or should the metadata be copied? e->TypeName.objc_metadata = original_type->Named.type_name->TypeName.objc_metadata; - mutex_lock(&ctx->info->gen_types_mutex); + rw_mutex_lock(&ctx->info->gen_types_mutex); auto *found_gen_types = map_get(&ctx->info->gen_types, original_type); if (found_gen_types) { - array_add(found_gen_types, e); + rw_mutex_lock(&found_gen_types->mutex); + array_add(&found_gen_types->types, e); + rw_mutex_unlock(&found_gen_types->mutex); } else { - auto array = array_make(heap_allocator()); - array_add(&array, e); - map_set(&ctx->info->gen_types, original_type, array); + GenTypesData gen_types = {}; + gen_types.types = array_make(heap_allocator()); + array_add(&gen_types.types, e); + map_set(&ctx->info->gen_types, original_type, gen_types); } - mutex_unlock(&ctx->info->gen_types_mutex); + rw_mutex_unlock(&ctx->info->gen_types_mutex); } -Type *check_record_polymorphic_params(CheckerContext *ctx, Ast *polymorphic_params, - bool *is_polymorphic_, - Ast *node, Array *poly_operands, - Type *named_type, Type *original_type_for_poly) { + +bool check_constant_parameter_value(Type *type, Ast *expr) { + if (!is_type_constant_type(type)) { + gbString str = type_to_string(type); + defer (gb_string_free(str)); + error(expr, "A parameter must be a valid constant type, got %s", str); + return true; + } + return false; +} + +gb_internal Type *check_record_polymorphic_params(CheckerContext *ctx, Ast *polymorphic_params, + bool *is_polymorphic_, + Ast *node, Array *poly_operands) { Type *polymorphic_params_type = nullptr; bool can_check_fields = true; GB_ASSERT(is_polymorphic_ != nullptr); @@ -443,7 +473,7 @@ Type *check_record_polymorphic_params(CheckerContext *ctx, Ast *polymorphic_para type = t_invalid; } if (is_type_untyped(type)) { - if (is_type_untyped_undef(type)) { + if (is_type_untyped_uninit(type)) { error(params[i], "Cannot determine parameter type from ---"); } else { error(params[i], "Cannot determine parameter type from a nil"); @@ -458,10 +488,8 @@ Type *check_record_polymorphic_params(CheckerContext *ctx, Ast *polymorphic_para type = t_invalid; } - if (!is_type_param && !is_type_constant_type(type)) { - gbString str = type_to_string(type); - error(params[i], "A parameter must be a valid constant type, got %s", str); - gb_string_free(str); + if (!is_type_param && check_constant_parameter_value(type, params[i])) { + // failed } Scope *scope = ctx->scope; @@ -528,11 +556,6 @@ Type *check_record_polymorphic_params(CheckerContext *ctx, Ast *polymorphic_para } } - if (original_type_for_poly != nullptr) { - GB_ASSERT(named_type != nullptr); - add_polymorphic_record_entity(ctx, node, named_type, original_type_for_poly); - } - if (!*is_polymorphic_) { *is_polymorphic_ = polymorphic_params != nullptr && poly_operands == nullptr; } @@ -540,7 +563,7 @@ Type *check_record_polymorphic_params(CheckerContext *ctx, Ast *polymorphic_para return polymorphic_params_type; } -bool check_record_poly_operand_specialization(CheckerContext *ctx, Type *record_type, Array *poly_operands, bool *is_polymorphic_) { +gb_internal bool check_record_poly_operand_specialization(CheckerContext *ctx, Type *record_type, Array *poly_operands, bool *is_polymorphic_) { if (poly_operands == nullptr) { return false; } @@ -569,7 +592,7 @@ bool check_record_poly_operand_specialization(CheckerContext *ctx, Type *record_ } -void check_struct_type(CheckerContext *ctx, Type *struct_type, Ast *node, Array *poly_operands, Type *named_type, Type *original_type_for_poly) { +gb_internal void check_struct_type(CheckerContext *ctx, Type *struct_type, Ast *node, Array *poly_operands, Type *named_type, Type *original_type_for_poly) { GB_ASSERT(is_type_struct(struct_type)); ast_node(st, StructType, node); @@ -595,15 +618,19 @@ void check_struct_type(CheckerContext *ctx, Type *struct_type, Ast *node, Array< context = str_lit("struct #raw_union"); } - struct_type->Struct.scope = ctx->scope; - struct_type->Struct.is_packed = st->is_packed; + struct_type->Struct.scope = ctx->scope; + struct_type->Struct.is_packed = st->is_packed; + struct_type->Struct.is_no_copy = st->is_no_copy; struct_type->Struct.polymorphic_params = check_record_polymorphic_params( ctx, st->polymorphic_params, &struct_type->Struct.is_polymorphic, - node, poly_operands, - named_type, original_type_for_poly - );; + node, poly_operands + ); struct_type->Struct.is_poly_specialized = check_record_poly_operand_specialization(ctx, struct_type, poly_operands, &struct_type->Struct.is_polymorphic); + if (original_type_for_poly) { + GB_ASSERT(named_type != nullptr); + add_polymorphic_record_entity(ctx, node, named_type, original_type_for_poly); + } if (!struct_type->Struct.is_polymorphic) { if (st->where_clauses.count > 0 && st->polymorphic_params == nullptr) { @@ -626,7 +653,7 @@ void check_struct_type(CheckerContext *ctx, Type *struct_type, Ast *node, Array< } } } -void check_union_type(CheckerContext *ctx, Type *union_type, Ast *node, Array *poly_operands, Type *named_type, Type *original_type_for_poly) { +gb_internal void check_union_type(CheckerContext *ctx, Type *union_type, Ast *node, Array *poly_operands, Type *named_type, Type *original_type_for_poly) { GB_ASSERT(is_type_union(union_type)); ast_node(ut, UnionType, node); @@ -635,10 +662,13 @@ void check_union_type(CheckerContext *ctx, Type *union_type, Ast *node, ArrayUnion.polymorphic_params = check_record_polymorphic_params( ctx, ut->polymorphic_params, &union_type->Union.is_polymorphic, - node, poly_operands, - named_type, original_type_for_poly + node, poly_operands ); union_type->Union.is_poly_specialized = check_record_poly_operand_specialization(ctx, union_type, poly_operands, &union_type->Union.is_polymorphic); + if (original_type_for_poly) { + GB_ASSERT(named_type != nullptr); + add_polymorphic_record_entity(ctx, node, named_type, original_type_for_poly); + } if (!union_type->Union.is_polymorphic) { if (ut->where_clauses.count > 0 && ut->polymorphic_params == nullptr) { @@ -654,6 +684,10 @@ void check_union_type(CheckerContext *ctx, Type *union_type, Ast *node, Arrayvariants) { Ast *node = ut->variants[i]; Type *t = check_type_expr(ctx, node, nullptr); + if (union_type->Union.is_polymorphic && poly_operands == nullptr) { + // NOTE(bill): don't add any variants if this is this is an unspecialized polymorphic record + continue; + } if (t != nullptr && t != t_invalid) { bool ok = true; t = default_type(t); @@ -666,8 +700,12 @@ void check_union_type(CheckerContext *ctx, Type *union_type, Ast *node, Arrayvariants.count) { + error_line("\tPrevious found at %s\n", token_pos_to_string(ast_token(ut->variants[j]).pos)); + } gb_string_free(str); break; } @@ -691,6 +729,12 @@ void check_union_type(CheckerContext *ctx, Type *union_type, Ast *node, ArrayUnion.kind = ut->kind; switch (ut->kind) { case UnionType_no_nil: + if (union_type->Union.is_polymorphic && poly_operands == nullptr) { + GB_ASSERT(variants.count == 0); + if (ut->variants.count != 1) { + break; + } + } if (variants.count < 2) { error(ut->align, "A union with #no_nil must have at least 2 variants"); } @@ -709,7 +753,7 @@ void check_union_type(CheckerContext *ctx, Type *union_type, Ast *node, ArrayEnum.max_value_index = max_value_index; } -bool is_type_valid_bit_set_range(Type *t) { +gb_internal bool is_type_valid_bit_set_range(Type *t) { if (is_type_integer(t)) { return true; } @@ -861,7 +905,7 @@ bool is_type_valid_bit_set_range(Type *t) { return false; } -void check_bit_set_type(CheckerContext *c, Type *type, Type *named_type, Ast *node) { +gb_internal void check_bit_set_type(CheckerContext *c, Type *type, Type *named_type, Ast *node) { ast_node(bs, BitSetType, node); GB_ASSERT(type->kind == Type_BitSet); type->BitSet.node = node; @@ -1102,7 +1146,7 @@ void check_bit_set_type(CheckerContext *c, Type *type, Type *named_type, Ast *no } -bool check_type_specialization_to(CheckerContext *ctx, Type *specialization, Type *type, bool compound, bool modify_type) { +gb_internal bool check_type_specialization_to(CheckerContext *ctx, Type *specialization, Type *type, bool compound, bool modify_type) { if (type == nullptr || type == t_invalid) { return true; @@ -1229,7 +1273,7 @@ bool check_type_specialization_to(CheckerContext *ctx, Type *specialization, Typ } -Type *determine_type_from_polymorphic(CheckerContext *ctx, Type *poly_type, Operand const &operand) { +gb_internal Type *determine_type_from_polymorphic(CheckerContext *ctx, Type *poly_type, Operand const &operand) { bool modify_type = !ctx->no_polymorphic_errors; bool show_error = modify_type && !ctx->hide_polymorphic_errors; if (!is_operand_value(operand)) { @@ -1256,7 +1300,7 @@ Type *determine_type_from_polymorphic(CheckerContext *ctx, Type *poly_type, Oper return t_invalid; } -bool is_expr_from_a_parameter(CheckerContext *ctx, Ast *expr) { +gb_internal bool is_expr_from_a_parameter(CheckerContext *ctx, Ast *expr) { if (expr == nullptr) { return false; } @@ -1275,7 +1319,7 @@ bool is_expr_from_a_parameter(CheckerContext *ctx, Ast *expr) { } -ParameterValue handle_parameter_value(CheckerContext *ctx, Type *in_type, Type **out_type_, Ast *expr, bool allow_caller_location) { +gb_internal ParameterValue handle_parameter_value(CheckerContext *ctx, Type *in_type, Type **out_type_, Ast *expr, bool allow_caller_location) { ParameterValue param_value = {}; param_value.original_ast_expr = expr; if (expr == nullptr) { @@ -1289,6 +1333,8 @@ ParameterValue handle_parameter_value(CheckerContext *ctx, Type *in_type, Type * init_core_source_code_location(ctx->checker); param_value.kind = ParameterValue_Location; o.type = t_source_code_location; + o.mode = Addressing_Value; + o.expr = expr; if (in_type) { check_assignment(ctx, &o, in_type, str_lit("parameter value")); @@ -1370,7 +1416,7 @@ ParameterValue handle_parameter_value(CheckerContext *ctx, Type *in_type, Type * } -Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_params, bool *is_variadic_, isize *variadic_index_, bool *success_, isize *specialization_count_, Array *operands) { +gb_internal Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_params, bool *is_variadic_, isize *variadic_index_, bool *success_, isize *specialization_count_, Array const *operands) { if (_params == nullptr) { return nullptr; } @@ -1488,7 +1534,7 @@ Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_params, bool *is type = t_invalid; } if (is_type_untyped(type)) { - if (is_type_untyped_undef(type)) { + if (is_type_untyped_uninit(type)) { error(param, "Cannot determine parameter type from ---"); } else { error(param, "Cannot determine parameter type from a nil"); @@ -1599,10 +1645,6 @@ Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_params, bool *is } } - if (p->flags&FieldFlag_auto_cast) { - error(name, "'auto_cast' can only be applied to variable fields"); - p->flags &= ~FieldFlag_auto_cast; - } if (p->flags&FieldFlag_const) { error(name, "'#const' can only be applied to variable fields"); p->flags &= ~FieldFlag_const; @@ -1622,7 +1664,6 @@ Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_params, bool *is ExactValue poly_const = {}; if (operands != nullptr && variables.count < operands->count) { - Operand op = (*operands)[variables.count]; if (op.expr == nullptr) { // NOTE(bill): 2019-03-30 @@ -1639,33 +1680,39 @@ Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_params, bool *is } else if (!ctx->no_polymorphic_errors) { // NOTE(bill): The type should be determined now and thus, no need to determine the type any more is_type_polymorphic_type = false; + Entity *proc_entity = entity_from_expr(op.expr); + if ((proc_entity != nullptr) && (op.value.kind == ExactValue_Procedure)) { + if (is_type_polymorphic(proc_entity->type, false)) { + error(op.expr, "Cannot determine complete type of partial polymorphic procedure"); + } + } } } if (is_poly_name) { bool valid = false; if (is_type_proc(op.type)) { - Entity *proc_entity = entity_from_expr(op.expr); - valid = (proc_entity != nullptr) && (op.value.kind == ExactValue_Procedure); - if (valid) { + Ast *expr = unparen_expr(op.expr); + Entity *proc_entity = entity_from_expr(expr); + if (proc_entity) { poly_const = exact_value_procedure(proc_entity->identifier.load() ? proc_entity->identifier.load() : op.expr); + valid = true; + } else if (expr->kind == Ast_ProcLit) { + poly_const = exact_value_procedure(expr); + valid = true; } } if (!valid) { if (op.mode == Addressing_Constant) { poly_const = op.value; } else { - error(op.expr, "Expected a constant value for this polymorphic name parameter"); + error(op.expr, "Expected a constant value for this polymorphic name parameter, got %s", expr_to_string(op.expr)); success = false; } } } if (type != t_invalid && !check_is_assignable_to(ctx, &op, type)) { bool ok = true; - if (p->flags&FieldFlag_auto_cast) { - if (!check_is_castable_to(ctx, &op, type)) { - ok = false; - } - } else if (p->flags&FieldFlag_any_int) { + if (p->flags&FieldFlag_any_int) { if ((!is_type_integer(op.type) && !is_type_enum(op.type)) || (!is_type_integer(type) && !is_type_enum(type))) { ok = false; } else if (!check_is_castable_to(ctx, &op, type)) { @@ -1711,10 +1758,6 @@ Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_params, bool *is error(name, "'#no_alias' can only be applied to non constant values"); p->flags &= ~FieldFlag_no_alias; // Remove the flag } - if (p->flags&FieldFlag_auto_cast) { - error(name, "'auto_cast' can only be applied to variable fields"); - p->flags &= ~FieldFlag_auto_cast; - } if (p->flags&FieldFlag_any_int) { error(name, "'#any_int' can only be applied to variable fields"); p->flags &= ~FieldFlag_any_int; @@ -1728,10 +1771,8 @@ Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_params, bool *is p->flags &= ~FieldFlag_by_ptr; } - if (!is_type_constant_type(type) && !is_type_polymorphic(type)) { - gbString str = type_to_string(type); - error(params[i], "A parameter must be a valid constant type, got %s", str); - gb_string_free(str); + if (!is_type_polymorphic(type) && check_constant_parameter_value(type, params[i])) { + // failed } param = alloc_entity_const_param(scope, name->Ident.token, type, poly_const, is_type_polymorphic(type)); @@ -1745,9 +1786,6 @@ Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_params, bool *is if (p->flags&FieldFlag_no_alias) { param->flags |= EntityFlag_NoAlias; } - if (p->flags&FieldFlag_auto_cast) { - param->flags |= EntityFlag_AutoCast; - } if (p->flags&FieldFlag_any_int) { if (!is_type_integer(param->type) && !is_type_enum(param->type)) { gbString str = type_to_string(param->type); @@ -1791,8 +1829,8 @@ Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_params, bool *is isize specialization_count = 0; if (scope != nullptr) { - for_array(i, scope->elements.entries) { - Entity *e = scope->elements.entries[i].value; + for (auto const &entry : scope->elements) { + Entity *e = entry.value; if (e->kind == Entity_TypeName) { Type *t = e->type; if (t->kind == Type_Generic && @@ -1814,7 +1852,7 @@ Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_params, bool *is return tuple; } -Type *check_get_results(CheckerContext *ctx, Scope *scope, Ast *_results) { +gb_internal Type *check_get_results(CheckerContext *ctx, Scope *scope, Ast *_results) { if (_results == nullptr) { return nullptr; } @@ -1928,7 +1966,7 @@ Type *check_get_results(CheckerContext *ctx, Scope *scope, Ast *_results) { // NOTE(bill): 'operands' is for generating non generic procedure type -bool check_procedure_type(CheckerContext *ctx, Type *type, Ast *proc_type_node, Array *operands) { +gb_internal bool check_procedure_type(CheckerContext *ctx, Type *type, Ast *proc_type_node, Array const *operands) { ast_node(pt, ProcType, proc_type_node); if (ctx->polymorphic_scope == nullptr && ctx->allow_polymorphic_types) { @@ -2084,7 +2122,7 @@ bool check_procedure_type(CheckerContext *ctx, Type *type, Ast *proc_type_node, } -i64 check_array_count(CheckerContext *ctx, Operand *o, Ast *e) { +gb_internal i64 check_array_count(CheckerContext *ctx, Operand *o, Ast *e) { if (e == nullptr) { return 0; } @@ -2169,7 +2207,7 @@ i64 check_array_count(CheckerContext *ctx, Operand *o, Ast *e) { return 0; } -Type *make_optional_ok_type(Type *value, bool typed) { +gb_internal Type *make_optional_ok_type(Type *value, bool typed) { gbAllocator a = permanent_allocator(); Type *t = alloc_type_tuple(); slice_init(&t->Tuple.variables, a, 2); @@ -2181,23 +2219,23 @@ Type *make_optional_ok_type(Type *value, bool typed) { // IMPORTANT NOTE(bill): This must match the definition in dynamic_map_internal.odin enum : i64 { - MAP_CACHE_LINE_LOG2 = 6, - MAP_CACHE_LINE_SIZE = 1 << MAP_CACHE_LINE_LOG2 + MAP_CELL_CACHE_LINE_LOG2 = 6, + MAP_CELL_CACHE_LINE_SIZE = 1 << MAP_CELL_CACHE_LINE_LOG2, }; -GB_STATIC_ASSERT(MAP_CACHE_LINE_SIZE >= 64); -void map_cell_size_and_len(Type *type, i64 *size_, i64 *len_) { +GB_STATIC_ASSERT(MAP_CELL_CACHE_LINE_SIZE >= 64); +gb_internal void map_cell_size_and_len(Type *type, i64 *size_, i64 *len_) { i64 elem_sz = type_size_of(type); i64 len = 1; - if (0 < elem_sz && elem_sz < MAP_CACHE_LINE_SIZE) { - len = MAP_CACHE_LINE_SIZE / elem_sz; + if (0 < elem_sz && elem_sz < MAP_CELL_CACHE_LINE_SIZE) { + len = MAP_CELL_CACHE_LINE_SIZE / elem_sz; } - i64 size = align_formula(elem_sz * len, MAP_CACHE_LINE_SIZE); + i64 size = align_formula(elem_sz * len, MAP_CELL_CACHE_LINE_SIZE); if (size_) *size_ = size; if (len_) *len_ = len; } -void init_map_internal_types(Type *type) { +gb_internal void init_map_internal_types(Type *type) { GB_ASSERT(type->kind == Type_Map); GB_ASSERT(t_allocator != nullptr); if (type->Map.lookup_result_type != nullptr) return; @@ -2210,7 +2248,7 @@ void init_map_internal_types(Type *type) { type->Map.lookup_result_type = make_optional_ok_type(value); } -void add_map_key_type_dependencies(CheckerContext *ctx, Type *key) { +gb_internal void add_map_key_type_dependencies(CheckerContext *ctx, Type *key) { key = core_type(key); if (is_type_cstring(key)) { @@ -2249,7 +2287,7 @@ void add_map_key_type_dependencies(CheckerContext *ctx, Type *key) { } } -void check_map_type(CheckerContext *ctx, Type *type, Ast *node) { +gb_internal void check_map_type(CheckerContext *ctx, Type *type, Ast *node) { GB_ASSERT(type->kind == Type_Map); ast_node(mt, MapType, node); @@ -2282,7 +2320,7 @@ void check_map_type(CheckerContext *ctx, Type *type, Ast *node) { // error(node, "'map' types are not yet implemented"); } -void check_matrix_type(CheckerContext *ctx, Type **type, Ast *node) { +gb_internal void check_matrix_type(CheckerContext *ctx, Type **type, Ast *node) { ast_node(mt, MatrixType, node); Operand row = {}; @@ -2346,7 +2384,7 @@ type_assign:; -Type *make_soa_struct_internal(CheckerContext *ctx, Ast *array_typ_expr, Ast *elem_expr, Type *elem, i64 count, Type *generic_type, StructSoaKind soa_kind) { +gb_internal Type *make_soa_struct_internal(CheckerContext *ctx, Ast *array_typ_expr, Ast *elem_expr, Type *elem, i64 count, Type *generic_type, StructSoaKind soa_kind) { Type *bt_elem = base_type(elem); bool is_polymorphic = is_type_polymorphic(elem); @@ -2398,7 +2436,8 @@ Type *make_soa_struct_internal(CheckerContext *ctx, Ast *array_typ_expr, Ast *el } soa_struct->Struct.soa_count = cast(i32)count; - scope = create_scope(ctx->info, ctx->scope, 8); + scope = create_scope(ctx->info, ctx->scope); + string_map_init(&scope->elements, 8); soa_struct->Struct.scope = scope; String params_xyzw[4] = { @@ -2501,20 +2540,20 @@ Type *make_soa_struct_internal(CheckerContext *ctx, Ast *array_typ_expr, Ast *el } -Type *make_soa_struct_fixed(CheckerContext *ctx, Ast *array_typ_expr, Ast *elem_expr, Type *elem, i64 count, Type *generic_type) { +gb_internal Type *make_soa_struct_fixed(CheckerContext *ctx, Ast *array_typ_expr, Ast *elem_expr, Type *elem, i64 count, Type *generic_type) { return make_soa_struct_internal(ctx, array_typ_expr, elem_expr, elem, count, generic_type, StructSoa_Fixed); } -Type *make_soa_struct_slice(CheckerContext *ctx, Ast *array_typ_expr, Ast *elem_expr, Type *elem) { +gb_internal Type *make_soa_struct_slice(CheckerContext *ctx, Ast *array_typ_expr, Ast *elem_expr, Type *elem) { return make_soa_struct_internal(ctx, array_typ_expr, elem_expr, elem, -1, nullptr, StructSoa_Slice); } -Type *make_soa_struct_dynamic_array(CheckerContext *ctx, Ast *array_typ_expr, Ast *elem_expr, Type *elem) { +gb_internal Type *make_soa_struct_dynamic_array(CheckerContext *ctx, Ast *array_typ_expr, Ast *elem_expr, Type *elem) { return make_soa_struct_internal(ctx, array_typ_expr, elem_expr, elem, -1, nullptr, StructSoa_Dynamic); } -bool check_type_internal(CheckerContext *ctx, Ast *e, Type **type, Type *named_type) { +gb_internal bool check_type_internal(CheckerContext *ctx, Ast *e, Type **type, Type *named_type) { GB_ASSERT_NOT_NULL(type); if (e == nullptr) { *type = t_invalid; @@ -2997,7 +3036,7 @@ bool check_type_internal(CheckerContext *ctx, Ast *e, Type **type, Type *named_t return false; } -Type *check_type(CheckerContext *ctx, Ast *e) { +gb_internal Type *check_type(CheckerContext *ctx, Ast *e) { CheckerContext c = *ctx; c.type_path = new_checker_type_path(); defer (destroy_checker_type_path(c.type_path)); @@ -3005,7 +3044,7 @@ Type *check_type(CheckerContext *ctx, Ast *e) { return check_type_expr(&c, e, nullptr); } -Type *check_type_expr(CheckerContext *ctx, Ast *e, Type *named_type) { +gb_internal Type *check_type_expr(CheckerContext *ctx, Ast *e, Type *named_type) { Type *type = nullptr; bool ok = check_type_internal(ctx, e, &type, named_type); @@ -3045,7 +3084,7 @@ Type *check_type_expr(CheckerContext *ctx, Ast *e, Type *named_type) { #endif if (is_type_typed(type)) { - add_type_and_value(ctx->info, e, Addressing_Type, type, empty_exact_value); + add_type_and_value(ctx, e, Addressing_Type, type, empty_exact_value); } else { gbString name = type_to_string(type); error(e, "Invalid type definition of %s", name); diff --git a/src/checker.cpp b/src/checker.cpp index 30a070d06..354cdadd3 100644 --- a/src/checker.cpp +++ b/src/checker.cpp @@ -1,12 +1,14 @@ +#define DEBUG_CHECK_ALL_PROCEDURES 1 + #include "entity.cpp" #include "types.cpp" -void check_expr(CheckerContext *c, Operand *operand, Ast *expression); -void check_expr_or_type(CheckerContext *c, Operand *operand, Ast *expression, Type *type_hint=nullptr); -void add_comparison_procedures_for_fields(CheckerContext *c, Type *t); -Type *check_type(CheckerContext *ctx, Ast *e); +gb_internal void check_expr(CheckerContext *c, Operand *operand, Ast *expression); +gb_internal void check_expr_or_type(CheckerContext *c, Operand *operand, Ast *expression, Type *type_hint=nullptr); +gb_internal void add_comparison_procedures_for_fields(CheckerContext *c, Type *t); +gb_internal Type *check_type(CheckerContext *ctx, Ast *e); -bool is_operand_value(Operand o) { +gb_internal bool is_operand_value(Operand o) { switch (o.mode) { case Addressing_Value: case Addressing_Context: @@ -22,15 +24,15 @@ bool is_operand_value(Operand o) { } return false; } -bool is_operand_nil(Operand o) { +gb_internal bool is_operand_nil(Operand o) { return o.mode == Addressing_Value && o.type == t_untyped_nil; } -bool is_operand_undef(Operand o) { - return o.mode == Addressing_Value && o.type == t_untyped_undef; +gb_internal bool is_operand_uninit(Operand o) { + return o.mode == Addressing_Value && o.type == t_untyped_uninit; } -bool check_rtti_type_disallowed(Token const &token, Type *type, char const *format) { - if (build_context.disallow_rtti && type) { +gb_internal bool check_rtti_type_disallowed(Token const &token, Type *type, char const *format) { + if (build_context.no_rtti && type) { if (is_type_any(type)) { gbString t = type_to_string(type); error(token, format, t); @@ -41,67 +43,49 @@ bool check_rtti_type_disallowed(Token const &token, Type *type, char const *form return false; } -bool check_rtti_type_disallowed(Ast *expr, Type *type, char const *format) { +gb_internal bool check_rtti_type_disallowed(Ast *expr, Type *type, char const *format) { GB_ASSERT(expr != nullptr); return check_rtti_type_disallowed(ast_token(expr), type, format); } -void scope_reset(Scope *scope) { +gb_internal void scope_reset(Scope *scope) { if (scope == nullptr) return; + rw_mutex_lock(&scope->mutex); scope->head_child.store(nullptr, std::memory_order_relaxed); string_map_clear(&scope->elements); ptr_set_clear(&scope->imported); + rw_mutex_unlock(&scope->mutex); } -void scope_reserve(Scope *scope, isize capacity) { - isize cap = 2*capacity; - if (cap > scope->elements.hashes.count) { - string_map_rehash(&scope->elements, capacity); - } +gb_internal void scope_reserve(Scope *scope, isize count) { + string_map_reserve(&scope->elements, 2*count); } -i32 is_scope_an_ancestor(Scope *parent, Scope *child) { - i32 i = 0; - while (child != nullptr) { - if (parent == child) { - return i; - } - child = child->parent; - i++; - } - return -1; +gb_internal void entity_graph_node_set_destroy(EntityGraphNodeSet *s) { + ptr_set_destroy(s); } -void entity_graph_node_set_destroy(EntityGraphNodeSet *s) { - if (s->hashes.data != nullptr) { - ptr_set_destroy(s); - } -} - -void entity_graph_node_set_add(EntityGraphNodeSet *s, EntityGraphNode *n) { - if (s->hashes.data == nullptr) { - ptr_set_init(s, heap_allocator()); - } +gb_internal void entity_graph_node_set_add(EntityGraphNodeSet *s, EntityGraphNode *n) { ptr_set_add(s, n); } -bool entity_graph_node_set_exists(EntityGraphNodeSet *s, EntityGraphNode *n) { - return ptr_set_exists(s, n); -} +// gb_internal bool entity_graph_node_set_exists(EntityGraphNodeSet *s, EntityGraphNode *n) { +// return ptr_set_exists(s, n); +// } -void entity_graph_node_set_remove(EntityGraphNodeSet *s, EntityGraphNode *n) { +gb_internal void entity_graph_node_set_remove(EntityGraphNodeSet *s, EntityGraphNode *n) { ptr_set_remove(s, n); } -void entity_graph_node_destroy(EntityGraphNode *n, gbAllocator a) { +gb_internal void entity_graph_node_destroy(EntityGraphNode *n, gbAllocator a) { entity_graph_node_set_destroy(&n->pred); entity_graph_node_set_destroy(&n->succ); gb_free(a, n); } -int entity_graph_node_cmp(EntityGraphNode **data, isize i, isize j) { +gb_internal int entity_graph_node_cmp(EntityGraphNode **data, isize i, isize j) { EntityGraphNode *x = data[i]; EntityGraphNode *y = data[j]; u64 a = x->entity->order_in_src; @@ -115,7 +99,7 @@ int entity_graph_node_cmp(EntityGraphNode **data, isize i, isize j) { return +1; } -void entity_graph_node_swap(EntityGraphNode **data, isize i, isize j) { +gb_internal void entity_graph_node_swap(EntityGraphNode **data, isize i, isize j) { EntityGraphNode *x = data[i]; EntityGraphNode *y = data[j]; data[i] = y; @@ -126,42 +110,37 @@ void entity_graph_node_swap(EntityGraphNode **data, isize i, isize j) { -void import_graph_node_set_destroy(ImportGraphNodeSet *s) { - if (s->hashes.data != nullptr) { - ptr_set_destroy(s); - } +gb_internal void import_graph_node_set_destroy(ImportGraphNodeSet *s) { + ptr_set_destroy(s); } -void import_graph_node_set_add(ImportGraphNodeSet *s, ImportGraphNode *n) { - if (s->hashes.data == nullptr) { - ptr_set_init(s, heap_allocator()); - } +gb_internal void import_graph_node_set_add(ImportGraphNodeSet *s, ImportGraphNode *n) { ptr_set_add(s, n); } -bool import_graph_node_set_exists(ImportGraphNodeSet *s, ImportGraphNode *n) { - return ptr_set_exists(s, n); -} +// gb_internal bool import_graph_node_set_exists(ImportGraphNodeSet *s, ImportGraphNode *n) { +// return ptr_set_exists(s, n); +// } -void import_graph_node_set_remove(ImportGraphNodeSet *s, ImportGraphNode *n) { - ptr_set_remove(s, n); -} +// gb_internal void import_graph_node_set_remove(ImportGraphNodeSet *s, ImportGraphNode *n) { +// ptr_set_remove(s, n); +// } -ImportGraphNode *import_graph_node_create(gbAllocator a, AstPackage *pkg) { +gb_internal ImportGraphNode *import_graph_node_create(gbAllocator a, AstPackage *pkg) { ImportGraphNode *n = gb_alloc_item(a, ImportGraphNode); n->pkg = pkg; n->scope = pkg->scope; return n; } -void import_graph_node_destroy(ImportGraphNode *n, gbAllocator a) { +gb_internal void import_graph_node_destroy(ImportGraphNode *n, gbAllocator a) { import_graph_node_set_destroy(&n->pred); import_graph_node_set_destroy(&n->succ); gb_free(a, n); } -int import_graph_node_cmp(ImportGraphNode **data, isize i, isize j) { +gb_internal int import_graph_node_cmp(ImportGraphNode **data, isize i, isize j) { ImportGraphNode *x = data[i]; ImportGraphNode *y = data[j]; GB_ASSERT(x != y); @@ -177,7 +156,7 @@ int import_graph_node_cmp(ImportGraphNode **data, isize i, isize j) { return 0; } -void import_graph_node_swap(ImportGraphNode **data, isize i, isize j) { +gb_internal void import_graph_node_swap(ImportGraphNode **data, isize i, isize j) { ImportGraphNode *x = data[i]; ImportGraphNode *y = data[j]; data[i] = y; @@ -186,65 +165,61 @@ void import_graph_node_swap(ImportGraphNode **data, isize i, isize j) { y->index = i; } -GB_COMPARE_PROC(ast_node_cmp) { - Ast *x = *cast(Ast **)a; - Ast *y = *cast(Ast **)b; - Token i = ast_token(x); - Token j = ast_token(y); - return token_pos_cmp(i.pos, j.pos); -} - - -void init_decl_info(DeclInfo *d, Scope *scope, DeclInfo *parent) { +gb_internal void init_decl_info(DeclInfo *d, Scope *scope, DeclInfo *parent) { + gb_zero_item(d); + if (parent) { + mutex_lock(&parent->next_mutex); + d->next_sibling = parent->next_child; + parent->next_child = d; + mutex_unlock(&parent->next_mutex); + } d->parent = parent; d->scope = scope; - ptr_set_init(&d->deps, heap_allocator()); - ptr_set_init(&d->type_info_deps, heap_allocator()); - array_init (&d->labels, heap_allocator()); + ptr_set_init(&d->deps, 0); + ptr_set_init(&d->type_info_deps, 0); + d->labels.allocator = heap_allocator(); } -DeclInfo *make_decl_info(Scope *scope, DeclInfo *parent) { +gb_internal DeclInfo *make_decl_info(Scope *scope, DeclInfo *parent) { DeclInfo *d = gb_alloc_item(permanent_allocator(), DeclInfo); init_decl_info(d, scope, parent); return d; } -void destroy_declaration_info(DeclInfo *d) { - ptr_set_destroy(&d->deps); - array_free(&d->labels); -} +// gb_internal void destroy_declaration_info(DeclInfo *d) { +// mutex_destroy(&d->proc_checked_mutex); +// ptr_set_destroy(&d->deps); +// array_free(&d->labels); +// } -bool decl_info_has_init(DeclInfo *d) { - if (d->init_expr != nullptr) { - return true; - } - if (d->proc_lit != nullptr) { - switch (d->proc_lit->kind) { - case_ast_node(pl, ProcLit, d->proc_lit); - if (pl->body != nullptr) { - return true; - } - case_end; - } - } +// gb_internal bool decl_info_has_init(DeclInfo *d) { +// if (d->init_expr != nullptr) { +// return true; +// } +// if (d->proc_lit != nullptr) { +// switch (d->proc_lit->kind) { +// case_ast_node(pl, ProcLit, d->proc_lit); +// if (pl->body != nullptr) { +// return true; +// } +// case_end; +// } +// } - return false; -} +// return false; +// } -Scope *create_scope(CheckerInfo *info, Scope *parent, isize init_elements_capacity=DEFAULT_SCOPE_CAPACITY) { +gb_internal Scope *create_scope(CheckerInfo *info, Scope *parent) { Scope *s = gb_alloc_item(permanent_allocator(), Scope); s->parent = parent; - string_map_init(&s->elements, heap_allocator(), init_elements_capacity); - ptr_set_init(&s->imported, heap_allocator(), 0); - mutex_init(&s->mutex); if (parent != nullptr && parent != builtin_pkg->scope) { Scope *prev_head_child = parent->head_child.exchange(s, std::memory_order_acq_rel); @@ -260,13 +235,14 @@ Scope *create_scope(CheckerInfo *info, Scope *parent, isize init_elements_capaci return s; } -Scope *create_scope_from_file(CheckerInfo *info, AstFile *f) { +gb_internal Scope *create_scope_from_file(CheckerInfo *info, AstFile *f) { GB_ASSERT(f != nullptr); GB_ASSERT(f->pkg != nullptr); GB_ASSERT(f->pkg->scope != nullptr); isize init_elements_capacity = gb_max(DEFAULT_SCOPE_CAPACITY, 2*f->total_file_decl_count); - Scope *s = create_scope(info, f->pkg->scope, init_elements_capacity); + Scope *s = create_scope(info, f->pkg->scope); + string_map_init(&s->elements, init_elements_capacity); s->flags |= ScopeFlag_File; @@ -276,16 +252,17 @@ Scope *create_scope_from_file(CheckerInfo *info, AstFile *f) { return s; } -Scope *create_scope_from_package(CheckerContext *c, AstPackage *pkg) { +gb_internal Scope *create_scope_from_package(CheckerContext *c, AstPackage *pkg) { GB_ASSERT(pkg != nullptr); isize total_pkg_decl_count = 0; - for_array(j, pkg->files) { - total_pkg_decl_count += pkg->files.data[j]->total_file_decl_count; + for (AstFile *file : pkg->files) { + total_pkg_decl_count += file->total_file_decl_count; } isize init_elements_capacity = gb_max(DEFAULT_SCOPE_CAPACITY, 2*total_pkg_decl_count); - Scope *s = create_scope(c->info, builtin_pkg->scope, init_elements_capacity); + Scope *s = create_scope(c->info, builtin_pkg->scope); + string_map_init(&s->elements, init_elements_capacity); s->flags |= ScopeFlag_Pkg; s->pkg = pkg; @@ -307,9 +284,9 @@ Scope *create_scope_from_package(CheckerContext *c, AstPackage *pkg) { return s; } -void destroy_scope(Scope *scope) { - for_array(i, scope->elements.entries) { - Entity *e =scope->elements.entries[i].value; +gb_internal void destroy_scope(Scope *scope) { + for (auto const &entry : scope->elements) { + Entity *e = entry.value; if (e->kind == Entity_Variable) { if (!(e->flags & EntityFlag_Used)) { #if 0 @@ -325,13 +302,12 @@ void destroy_scope(Scope *scope) { string_map_destroy(&scope->elements); ptr_set_destroy(&scope->imported); - mutex_destroy(&scope->mutex); // NOTE(bill): No need to free scope as it "should" be allocated in an arena (except for the global scope) } -void add_scope(CheckerContext *c, Ast *node, Scope *scope) { +gb_internal void add_scope(CheckerContext *c, Ast *node, Scope *scope) { GB_ASSERT(node != nullptr); GB_ASSERT(scope != nullptr); scope->node = node; @@ -352,7 +328,7 @@ void add_scope(CheckerContext *c, Ast *node, Scope *scope) { } } -Scope *scope_of_node(Ast *node) { +gb_internal Scope *scope_of_node(Ast *node) { if (node == nullptr) { return nullptr; } @@ -375,7 +351,7 @@ Scope *scope_of_node(Ast *node) { } -void check_open_scope(CheckerContext *c, Ast *node) { +gb_internal void check_open_scope(CheckerContext *c, Ast *node) { node = unparen_expr(node); GB_ASSERT(node->kind == Ast_Invalid || is_ast_stmt(node) || @@ -397,12 +373,12 @@ void check_open_scope(CheckerContext *c, Ast *node) { c->state_flags |= StateFlag_bounds_check; } -void check_close_scope(CheckerContext *c) { +gb_internal void check_close_scope(CheckerContext *c) { c->scope = c->scope->parent; } -Entity *scope_lookup_current(Scope *s, String const &name) { +gb_internal Entity *scope_lookup_current(Scope *s, String const &name) { Entity **found = string_map_get(&s->elements, name); if (found) { return *found; @@ -410,20 +386,19 @@ Entity *scope_lookup_current(Scope *s, String const &name) { return nullptr; } -void scope_lookup_parent(Scope *scope, String const &name, Scope **scope_, Entity **entity_) { +gb_internal void scope_lookup_parent(Scope *scope, String const &name, Scope **scope_, Entity **entity_) { if (scope != nullptr) { bool gone_thru_proc = false; bool gone_thru_package = false; StringHashKey key = string_hash_string(name); for (Scope *s = scope; s != nullptr; s = s->parent) { Entity **found = nullptr; - mutex_lock(&s->mutex); + rw_mutex_shared_lock(&s->mutex); found = string_map_get(&s->elements, key); - mutex_unlock(&s->mutex); + rw_mutex_shared_unlock(&s->mutex); if (found) { Entity *e = *found; if (gone_thru_proc) { - // IMPORTANT TODO(bill): Is this correct?! if (e->kind == Entity_Label) { continue; } @@ -455,15 +430,13 @@ void scope_lookup_parent(Scope *scope, String const &name, Scope **scope_, Entit if (scope_) *scope_ = nullptr; } -Entity *scope_lookup(Scope *s, String const &name) { +gb_internal Entity *scope_lookup(Scope *s, String const &name) { Entity *entity = nullptr; scope_lookup_parent(s, name, nullptr, &entity); return entity; } - - -Entity *scope_insert_with_name(Scope *s, String const &name, Entity *entity, bool use_mutex=true) { +gb_internal Entity *scope_insert_with_name_no_mutex(Scope *s, String const &name, Entity *entity) { if (name == "") { return nullptr; } @@ -471,9 +444,6 @@ Entity *scope_insert_with_name(Scope *s, String const &name, Entity *entity, boo Entity **found = nullptr; Entity *result = nullptr; - if (use_mutex) mutex_lock(&s->mutex); - defer (if (use_mutex) mutex_unlock(&s->mutex)); - found = string_map_get(&s->elements, key); if (found) { @@ -502,9 +472,55 @@ end:; return result; } -Entity *scope_insert(Scope *s, Entity *entity, bool use_mutex) { + +gb_internal Entity *scope_insert_with_name(Scope *s, String const &name, Entity *entity) { + if (name == "") { + return nullptr; + } + StringHashKey key = string_hash_string(name); + Entity **found = nullptr; + Entity *result = nullptr; + + rw_mutex_lock(&s->mutex); + + found = string_map_get(&s->elements, key); + + if (found) { + if (entity != *found) { + result = *found; + } + goto end; + } + if (s->parent != nullptr && (s->parent->flags & ScopeFlag_Proc) != 0) { + found = string_map_get(&s->parent->elements, key); + if (found) { + if ((*found)->flags & EntityFlag_Result) { + if (entity != *found) { + result = *found; + } + goto end; + } + } + } + + string_map_set(&s->elements, key, entity); + if (entity->scope == nullptr) { + entity->scope = s; + } +end:; + rw_mutex_unlock(&s->mutex); + + return result; +} + +gb_internal Entity *scope_insert(Scope *s, Entity *entity) { String name = entity->token.string; - return scope_insert_with_name(s, name, entity, use_mutex); + return scope_insert_with_name(s, name, entity); +} + +gb_internal Entity *scope_insert_no_mutex(Scope *s, Entity *entity) { + String name = entity->token.string; + return scope_insert_with_name_no_mutex(s, name, entity); } @@ -528,14 +544,9 @@ struct VettedEntity { Entity *entity; Entity *other; }; -void init_vetted_entity(VettedEntity *ve, VettedEntityKind kind, Entity *entity, Entity *other=nullptr) { - ve->kind = kind; - ve->entity = entity; - ve->other = other; -} -GB_COMPARE_PROC(vetted_entity_variable_pos_cmp) { +gb_internal GB_COMPARE_PROC(vetted_entity_variable_pos_cmp) { Entity *x = (cast(VettedEntity *)a)->entity; Entity *y = (cast(VettedEntity *)b)->entity; GB_ASSERT(x != nullptr); @@ -544,7 +555,7 @@ GB_COMPARE_PROC(vetted_entity_variable_pos_cmp) { return token_pos_cmp(x->token.pos, y->token.pos); } -bool check_vet_shadowing_assignment(Checker *c, Entity *shadowed, Ast *expr) { +gb_internal bool check_vet_shadowing_assignment(Checker *c, Entity *shadowed, Ast *expr) { Ast *init = unparen_expr(expr); if (init == nullptr) { return false; @@ -568,7 +579,7 @@ bool check_vet_shadowing_assignment(Checker *c, Entity *shadowed, Ast *expr) { } -bool check_vet_shadowing(Checker *c, Entity *e, VettedEntity *ve) { +gb_internal bool check_vet_shadowing(Checker *c, Entity *e, VettedEntity *ve) { if (e->kind != Entity_Variable) { return false; } @@ -634,12 +645,15 @@ bool check_vet_shadowing(Checker *c, Entity *e, VettedEntity *ve) { return true; } -bool check_vet_unused(Checker *c, Entity *e, VettedEntity *ve) { +gb_internal bool check_vet_unused(Checker *c, Entity *e, VettedEntity *ve) { if ((e->flags&EntityFlag_Used) == 0) { switch (e->kind) { case Entity_Variable: if (e->scope->flags & (ScopeFlag_Global|ScopeFlag_Type|ScopeFlag_File)) { return false; + } else if (e->flags & EntityFlag_Static) { + // ignore these for the time being + return false; } case Entity_ImportName: case Entity_LibraryName: @@ -652,15 +666,16 @@ bool check_vet_unused(Checker *c, Entity *e, VettedEntity *ve) { return false; } -void check_scope_usage(Checker *c, Scope *scope) { +gb_internal void check_scope_usage(Checker *c, Scope *scope) { bool vet_unused = true; bool vet_shadowing = true; Array vetted_entities = {}; array_init(&vetted_entities, heap_allocator()); - MUTEX_GUARD_BLOCK(scope->mutex) for_array(i, scope->elements.entries) { - Entity *e = scope->elements.entries[i].value; + rw_mutex_shared_lock(&scope->mutex); + for (auto const &entry : scope->elements) { + Entity *e = entry.value; if (e == nullptr) continue; VettedEntity ve_unused = {}; VettedEntity ve_shadowed = {}; @@ -676,11 +691,11 @@ void check_scope_usage(Checker *c, Scope *scope) { array_add(&vetted_entities, ve_shadowed); } } + rw_mutex_shared_unlock(&scope->mutex); gb_sort(vetted_entities.data, vetted_entities.count, gb_size_of(VettedEntity), vetted_entity_variable_pos_cmp); - for_array(i, vetted_entities) { - auto ve = vetted_entities[i]; + for (auto const &ve : vetted_entities) { Entity *e = ve.entity; Entity *other = ve.other; String name = e->token.string; @@ -728,25 +743,21 @@ void check_scope_usage(Checker *c, Scope *scope) { } -void add_dependency(CheckerInfo *info, DeclInfo *d, Entity *e) { - mutex_lock(&info->deps_mutex); +gb_internal void add_dependency(CheckerInfo *info, DeclInfo *d, Entity *e) { + rw_mutex_lock(&d->deps_mutex); ptr_set_add(&d->deps, e); - mutex_unlock(&info->deps_mutex); + rw_mutex_unlock(&d->deps_mutex); } -void add_type_info_dependency(CheckerInfo *info, DeclInfo *d, Type *type, bool require_mutex) { +gb_internal void add_type_info_dependency(CheckerInfo *info, DeclInfo *d, Type *type) { if (d == nullptr) { return; } - if (require_mutex) { - mutex_lock(&info->deps_mutex); - } + rw_mutex_lock(&d->type_info_deps_mutex); ptr_set_add(&d->type_info_deps, type); - if (require_mutex) { - mutex_unlock(&info->deps_mutex); - } + rw_mutex_unlock(&d->type_info_deps_mutex); } -AstPackage *get_core_package(CheckerInfo *info, String name) { +gb_internal AstPackage *get_core_package(CheckerInfo *info, String name) { gbAllocator a = heap_allocator(); String path = get_fullpath_core(a, name); defer (gb_free(a, path.text)); @@ -755,9 +766,8 @@ AstPackage *get_core_package(CheckerInfo *info, String name) { gb_printf_err("Name: %.*s\n", LIT(name)); gb_printf_err("Fullpath: %.*s\n", LIT(path)); - for_array(i, info->packages.entries) { - auto *entry = &info->packages.entries[i]; - gb_printf_err("%.*s\n", LIT(entry->key.string)); + for (auto const &entry : info->packages) { + gb_printf_err("%.*s\n", LIT(entry.key)); } GB_ASSERT_MSG(found != nullptr, "Missing core package %.*s", LIT(name)); } @@ -765,7 +775,7 @@ AstPackage *get_core_package(CheckerInfo *info, String name) { } -void add_package_dependency(CheckerContext *c, char const *package_name, char const *name) { +gb_internal void add_package_dependency(CheckerContext *c, char const *package_name, char const *name) { String n = make_string_c(name); AstPackage *p = get_core_package(&c->checker->info, make_string_c(package_name)); Entity *e = scope_lookup(p->scope, n); @@ -775,7 +785,7 @@ void add_package_dependency(CheckerContext *c, char const *package_name, char co add_dependency(c->info, c->decl, e); } -void try_to_add_package_dependency(CheckerContext *c, char const *package_name, char const *name) { +gb_internal void try_to_add_package_dependency(CheckerContext *c, char const *package_name, char const *name) { String n = make_string_c(name); AstPackage *p = get_core_package(&c->checker->info, make_string_c(package_name)); Entity *e = scope_lookup(p->scope, n); @@ -788,7 +798,7 @@ void try_to_add_package_dependency(CheckerContext *c, char const *package_name, } -void add_declaration_dependency(CheckerContext *c, Entity *e) { +gb_internal void add_declaration_dependency(CheckerContext *c, Entity *e) { if (e == nullptr) { return; } @@ -798,7 +808,7 @@ void add_declaration_dependency(CheckerContext *c, Entity *e) { } -Entity *add_global_entity(Entity *entity, Scope *scope=builtin_pkg->scope) { +gb_internal Entity *add_global_entity(Entity *entity, Scope *scope=builtin_pkg->scope) { String name = entity->token.string; defer (entity->state = EntityState_Resolved); @@ -811,27 +821,27 @@ Entity *add_global_entity(Entity *entity, Scope *scope=builtin_pkg->scope) { return entity; } -void add_global_constant(char const *name, Type *type, ExactValue value) { +gb_internal void add_global_constant(char const *name, Type *type, ExactValue value) { Entity *entity = alloc_entity(Entity_Constant, nullptr, make_token_ident(name), type); entity->Constant.value = value; add_global_entity(entity); } -void add_global_string_constant(char const *name, String const &value) { +gb_internal void add_global_string_constant(char const *name, String const &value) { add_global_constant(name, t_untyped_string, exact_value_string(value)); } -void add_global_bool_constant(char const *name, bool value) { +gb_internal void add_global_bool_constant(char const *name, bool value) { add_global_constant(name, t_untyped_bool, exact_value_bool(value)); } -void add_global_type_entity(String name, Type *type) { +gb_internal void add_global_type_entity(String name, Type *type) { add_global_entity(alloc_entity_type_name(nullptr, make_token_ident(name), type)); } -AstPackage *create_builtin_package(char const *name) { +gb_internal AstPackage *create_builtin_package(char const *name) { gbAllocator a = permanent_allocator(); AstPackage *pkg = gb_alloc_item(a, AstPackage); pkg->name = make_string_c(name); @@ -848,7 +858,7 @@ struct GlobalEnumValue { i64 value; }; -Slice add_global_enum_type(String const &type_name, GlobalEnumValue *values, isize value_count, Type **enum_type_ = nullptr) { +gb_internal Slice add_global_enum_type(String const &type_name, GlobalEnumValue *values, isize value_count, Type **enum_type_ = nullptr) { Scope *scope = create_scope(nullptr, builtin_pkg->scope); Entity *entity = alloc_entity_type_name(scope, make_token_ident(type_name), nullptr, EntityState_Resolved); @@ -883,7 +893,7 @@ Slice add_global_enum_type(String const &type_name, GlobalEnumValue *v return slice_from_array(fields); } -void add_global_enum_constant(Slice const &fields, char const *name, i64 value) { +gb_internal void add_global_enum_constant(Slice const &fields, char const *name, i64 value) { for (Entity *field : fields) { GB_ASSERT(field->kind == Entity_Constant); if (value == exact_value_to_i64(field->Constant.value)) { @@ -894,7 +904,7 @@ void add_global_enum_constant(Slice const &fields, char const *name, i GB_PANIC("Unfound enum value for global constant: %s %lld", name, cast(long long)value); } -Type *add_global_type_name(Scope *scope, String const &type_name, Type *backing_type) { +gb_internal Type *add_global_type_name(Scope *scope, String const &type_name, Type *backing_type) { Entity *e = alloc_entity_type_name(scope, make_token_ident(type_name), nullptr, EntityState_Resolved); Type *named_type = alloc_type_named(type_name, backing_type, e); e->type = named_type; @@ -905,8 +915,15 @@ Type *add_global_type_name(Scope *scope, String const &type_name, Type *backing_ return named_type; } +gb_internal i64 odin_compile_timestamp(void) { + i64 us_after_1601 = cast(i64)gb_utc_time_now(); + i64 us_after_1970 = us_after_1601 - 11644473600000000ll; + i64 ns_after_1970 = us_after_1970*1000ll; + return ns_after_1970; +} -void init_universal(void) { + +gb_internal void init_universal(void) { BuildContext *bc = &build_context; builtin_pkg = create_builtin_package("builtin"); @@ -964,13 +981,13 @@ void init_universal(void) { { GlobalEnumValue values[TargetArch_COUNT] = { - {"Unknown", TargetArch_Invalid}, - {"amd64", TargetArch_amd64}, - {"i386", TargetArch_i386}, - {"arm32", TargetArch_arm32}, - {"arm64", TargetArch_arm64}, - {"wasm32", TargetArch_wasm32}, - {"wasm64", TargetArch_wasm64}, + {"Unknown", TargetArch_Invalid}, + {"amd64", TargetArch_amd64}, + {"i386", TargetArch_i386}, + {"arm32", TargetArch_arm32}, + {"arm64", TargetArch_arm64}, + {"wasm32", TargetArch_wasm32}, + {"wasm64p32", TargetArch_wasm64p32}, }; auto fields = add_global_enum_type(str_lit("Odin_Arch_Type"), values, gb_count_of(values)); @@ -993,8 +1010,6 @@ void init_universal(void) { { GlobalEnumValue values[TargetEndian_COUNT] = { - {"Unknown", TargetEndian_Invalid}, - {"Little", TargetEndian_Little}, {"Big", TargetEndian_Big}, }; @@ -1039,10 +1054,11 @@ void init_universal(void) { add_global_bool_constant("ODIN_TEST", bc->command_kind == Command_test); add_global_bool_constant("ODIN_NO_ENTRY_POINT", bc->no_entry_point); add_global_bool_constant("ODIN_FOREIGN_ERROR_PROCEDURES", bc->ODIN_FOREIGN_ERROR_PROCEDURES); - add_global_bool_constant("ODIN_DISALLOW_RTTI", bc->disallow_rtti); + add_global_bool_constant("ODIN_NO_RTTI", bc->no_rtti); add_global_bool_constant("ODIN_VALGRIND_SUPPORT", bc->ODIN_VALGRIND_SUPPORT); + add_global_constant("ODIN_COMPILE_TIMESTAMP", t_untyped_integer, exact_value_i64(odin_compile_timestamp())); // Builtin Procedures @@ -1063,11 +1079,18 @@ void init_universal(void) { } } } + { + BuiltinProcId id = BuiltinProc_expand_values; + String name = str_lit("expand_to_tuple"); + Entity *entity = alloc_entity(Entity_Builtin, nullptr, make_token_ident(name), t_invalid); + entity->Builtin.id = id; + add_global_entity(entity, builtin_pkg->scope); + } bool defined_values_double_declaration = false; - for_array(i, bc->defined_values.entries) { - char const *name = bc->defined_values.entries[i].key; - ExactValue value = bc->defined_values.entries[i].value; + for (auto const &entry : bc->defined_values) { + char const *name = entry.key; + ExactValue value = entry.value; GB_ASSERT(value.kind != ExactValue_Invalid); Type *type = nullptr; @@ -1123,102 +1146,62 @@ void init_universal(void) { -void init_checker_info(CheckerInfo *i) { +gb_internal void init_checker_info(CheckerInfo *i) { gbAllocator a = heap_allocator(); TIME_SECTION("checker info: general"); array_init(&i->definitions, a); array_init(&i->entities, a); - map_init(&i->global_untyped, a); - string_map_init(&i->foreigns, a); - map_init(&i->gen_procs, a); - map_init(&i->gen_types, a); + map_init(&i->global_untyped); + string_map_init(&i->foreigns); + // map_init(&i->gen_procs); + map_init(&i->gen_types); array_init(&i->type_info_types, a); - map_init(&i->type_info_map, a); - string_map_init(&i->files, a); - string_map_init(&i->packages, a); + map_init(&i->type_info_map); + string_map_init(&i->files); + string_map_init(&i->packages); array_init(&i->variable_init_order, a); array_init(&i->testing_procedures, a, 0, 0); array_init(&i->init_procedures, a, 0, 0); + array_init(&i->fini_procedures, a, 0, 0); array_init(&i->required_foreign_imports_through_force, a, 0, 0); + map_init(&i->objc_msgSend_types); + string_map_init(&i->load_file_cache); + array_init(&i->all_procedures, heap_allocator()); - - i->allow_identifier_uses = build_context.query_data_set_settings.kind == QueryDataSet_GoToDefinitions; - if (i->allow_identifier_uses) { - array_init(&i->identifier_uses, a); - } - - - TIME_SECTION("checker info: mpmc queues"); - - mpmc_init(&i->entity_queue, a, 1<<20); - mpmc_init(&i->definition_queue, a, 1<<20); - mpmc_init(&i->required_global_variable_queue, a, 1<<10); - mpmc_init(&i->required_foreign_imports_through_force_queue, a, 1<<10); - - TIME_SECTION("checker info: mutexes"); - - mutex_init(&i->gen_procs_mutex); - mutex_init(&i->gen_types_mutex); - mutex_init(&i->lazy_mutex); - mutex_init(&i->builtin_mutex); - mutex_init(&i->global_untyped_mutex); - mutex_init(&i->type_info_mutex); - mutex_init(&i->deps_mutex); - mutex_init(&i->type_and_value_mutex); - mutex_init(&i->identifier_uses_mutex); - mutex_init(&i->foreign_mutex); - - semaphore_init(&i->collect_semaphore); - - mpmc_init(&i->intrinsics_entry_point_usage, a, 1<<10); // just waste some memory here, even if it probably never used - - mutex_init(&i->objc_types_mutex); - map_init(&i->objc_msgSend_types, a); - mutex_init(&i->load_file_mutex); - string_map_init(&i->load_file_cache, a); + mpsc_init(&i->entity_queue, a); // 1<<20); + mpsc_init(&i->definition_queue, a); //); // 1<<20); + mpsc_init(&i->required_global_variable_queue, a); // 1<<10); + mpsc_init(&i->required_foreign_imports_through_force_queue, a); // 1<<10); + mpsc_init(&i->intrinsics_entry_point_usage, a); // 1<<10); // just waste some memory here, even if it probably never used } -void destroy_checker_info(CheckerInfo *i) { +gb_internal void destroy_checker_info(CheckerInfo *i) { array_free(&i->definitions); array_free(&i->entities); map_destroy(&i->global_untyped); string_map_destroy(&i->foreigns); - map_destroy(&i->gen_procs); + // map_destroy(&i->gen_procs); map_destroy(&i->gen_types); array_free(&i->type_info_types); map_destroy(&i->type_info_map); string_map_destroy(&i->files); string_map_destroy(&i->packages); array_free(&i->variable_init_order); - array_free(&i->identifier_uses); array_free(&i->required_foreign_imports_through_force); - mpmc_destroy(&i->entity_queue); - mpmc_destroy(&i->definition_queue); - mpmc_destroy(&i->required_global_variable_queue); - mpmc_destroy(&i->required_foreign_imports_through_force_queue); + mpsc_destroy(&i->entity_queue); + mpsc_destroy(&i->definition_queue); + mpsc_destroy(&i->required_global_variable_queue); + mpsc_destroy(&i->required_foreign_imports_through_force_queue); - mutex_destroy(&i->gen_procs_mutex); - mutex_destroy(&i->gen_types_mutex); - mutex_destroy(&i->lazy_mutex); - mutex_destroy(&i->builtin_mutex); - mutex_destroy(&i->global_untyped_mutex); - mutex_destroy(&i->type_info_mutex); - mutex_destroy(&i->deps_mutex); - mutex_destroy(&i->type_and_value_mutex); - mutex_destroy(&i->identifier_uses_mutex); - mutex_destroy(&i->foreign_mutex); - - mutex_destroy(&i->objc_types_mutex); map_destroy(&i->objc_msgSend_types); - mutex_init(&i->load_file_mutex); string_map_destroy(&i->load_file_cache); } -CheckerContext make_checker_context(Checker *c) { +gb_internal CheckerContext make_checker_context(Checker *c) { CheckerContext ctx = {}; ctx.checker = c; ctx.info = &c->info; @@ -1227,39 +1210,53 @@ CheckerContext make_checker_context(Checker *c) { ctx.type_path = new_checker_type_path(); ctx.type_level = 0; - ctx.poly_path = new_checker_poly_path(); - ctx.poly_level = 0; return ctx; } -void destroy_checker_context(CheckerContext *ctx) { +gb_internal void destroy_checker_context(CheckerContext *ctx) { destroy_checker_type_path(ctx->type_path); - destroy_checker_poly_path(ctx->poly_path); } -void add_curr_ast_file(CheckerContext *ctx, AstFile *file) { +gb_internal bool add_curr_ast_file(CheckerContext *ctx, AstFile *file) { if (file != nullptr) { ctx->file = file; ctx->decl = file->pkg->decl_info; ctx->scope = file->scope; ctx->pkg = file->pkg; + return true; } + return false; } -void reset_checker_context(CheckerContext *ctx, AstFile *file, UntypedExprInfoMap *untyped) { +gb_internal void reset_checker_context(CheckerContext *ctx, AstFile *file, UntypedExprInfoMap *untyped) { if (ctx == nullptr) { return; } - destroy_checker_context(ctx); - auto *queue = ctx->procs_to_check_queue; - *ctx = make_checker_context(ctx->checker); + GB_ASSERT(ctx->checker != nullptr); + mutex_lock(&ctx->mutex); + + auto type_path = ctx->type_path; + array_clear(type_path); + + zero_size(&ctx->pkg, gb_size_of(CheckerContext) - gb_offset_of(CheckerContext, pkg)); + + ctx->file = nullptr; + ctx->scope = builtin_pkg->scope; + ctx->pkg = builtin_pkg; + ctx->decl = nullptr; + + ctx->type_path = type_path; + ctx->type_level = 0; + add_curr_ast_file(ctx, file); - ctx->procs_to_check_queue = queue; + ctx->untyped = untyped; + + mutex_unlock(&ctx->mutex); } -void init_checker(Checker *c) { +gb_internal void init_checker(Checker *c) { gbAllocator a = heap_allocator(); TIME_SECTION("init checker info"); @@ -1268,30 +1265,29 @@ void init_checker(Checker *c) { c->info.checker = c; TIME_SECTION("init proc queues"); - mpmc_init(&c->procs_with_deferred_to_check, a, 1<<10); + mpsc_init(&c->procs_with_deferred_to_check, a); //, 1<<10); // NOTE(bill): 1 Mi elements should be enough on average - mpmc_init(&c->procs_to_check_queue, heap_allocator(), 1<<20); - semaphore_init(&c->procs_to_check_semaphore); + array_init(&c->procs_to_check, heap_allocator(), 0, 1<<20); + array_init(&c->nested_proc_lits, heap_allocator(), 0, 1<<20); - mpmc_init(&c->global_untyped_queue, a, 1<<20); + mpsc_init(&c->global_untyped_queue, a); // , 1<<20); c->builtin_ctx = make_checker_context(c); } -void destroy_checker(Checker *c) { +gb_internal void destroy_checker(Checker *c) { destroy_checker_info(&c->info); destroy_checker_context(&c->builtin_ctx); - mpmc_destroy(&c->procs_to_check_queue); - semaphore_destroy(&c->procs_to_check_semaphore); - - mpmc_destroy(&c->global_untyped_queue); + array_free(&c->nested_proc_lits); + array_free(&c->procs_to_check); + mpsc_destroy(&c->global_untyped_queue); } -TypeAndValue type_and_value_of_expr(Ast *expr) { +gb_internal TypeAndValue type_and_value_of_expr(Ast *expr) { TypeAndValue tav = {}; if (expr != nullptr) { tav = expr->tav; @@ -1299,7 +1295,7 @@ TypeAndValue type_and_value_of_expr(Ast *expr) { return tav; } -Type *type_of_expr(Ast *expr) { +gb_internal Type *type_of_expr(Ast *expr) { TypeAndValue tav = expr->tav; if (tav.mode != Addressing_Invalid) { return tav.type; @@ -1314,14 +1310,14 @@ Type *type_of_expr(Ast *expr) { return nullptr; } -Entity *implicit_entity_of_node(Ast *clause) { +gb_internal Entity *implicit_entity_of_node(Ast *clause) { if (clause != nullptr && clause->kind == Ast_CaseClause) { return clause->CaseClause.implicit_entity; } return nullptr; } -Entity *entity_of_node(Ast *expr) { +gb_internal Entity *entity_of_node(Ast *expr) { expr = unparen_expr(expr); switch (expr->kind) { case_ast_node(ident, Ident, expr); @@ -1342,25 +1338,25 @@ Entity *entity_of_node(Ast *expr) { return nullptr; } -DeclInfo *decl_info_of_entity(Entity *e) { +gb_internal DeclInfo *decl_info_of_entity(Entity *e) { if (e != nullptr) { return e->decl_info; } return nullptr; } -DeclInfo *decl_info_of_ident(Ast *ident) { - return decl_info_of_entity(entity_of_node(ident)); -} +// gb_internal DeclInfo *decl_info_of_ident(Ast *ident) { +// return decl_info_of_entity(entity_of_node(ident)); +// } -AstFile *ast_file_of_filename(CheckerInfo *i, String filename) { - AstFile **found = string_map_get(&i->files, filename); - if (found != nullptr) { - return *found; - } - return nullptr; -} -ExprInfo *check_get_expr_info(CheckerContext *c, Ast *expr) { +// gb_internal AstFile *ast_file_of_filename(CheckerInfo *i, String filename) { +// AstFile **found = string_map_get(&i->files, filename); +// if (found != nullptr) { +// return *found; +// } +// return nullptr; +// } +gb_internal ExprInfo *check_get_expr_info(CheckerContext *c, Ast *expr) { if (c->untyped != nullptr) { ExprInfo **found = map_get(c->untyped, expr); if (found) { @@ -1368,9 +1364,9 @@ ExprInfo *check_get_expr_info(CheckerContext *c, Ast *expr) { } return nullptr; } else { - mutex_lock(&c->info->global_untyped_mutex); - defer (mutex_unlock(&c->info->global_untyped_mutex)); + rw_mutex_shared_lock(&c->info->global_untyped_mutex); ExprInfo **found = map_get(&c->info->global_untyped, expr); + rw_mutex_shared_unlock(&c->info->global_untyped_mutex); if (found) { return *found; } @@ -1378,31 +1374,31 @@ ExprInfo *check_get_expr_info(CheckerContext *c, Ast *expr) { } } -void check_set_expr_info(CheckerContext *c, Ast *expr, AddressingMode mode, Type *type, ExactValue value) { +gb_internal void check_set_expr_info(CheckerContext *c, Ast *expr, AddressingMode mode, Type *type, ExactValue value) { if (c->untyped != nullptr) { map_set(c->untyped, expr, make_expr_info(mode, type, value, false)); } else { - mutex_lock(&c->info->global_untyped_mutex); + rw_mutex_lock(&c->info->global_untyped_mutex); map_set(&c->info->global_untyped, expr, make_expr_info(mode, type, value, false)); - mutex_unlock(&c->info->global_untyped_mutex); + rw_mutex_unlock(&c->info->global_untyped_mutex); } } -void check_remove_expr_info(CheckerContext *c, Ast *e) { +gb_internal void check_remove_expr_info(CheckerContext *c, Ast *e) { if (c->untyped != nullptr) { map_remove(c->untyped, e); GB_ASSERT(map_get(c->untyped, e) == nullptr); } else { auto *untyped = &c->info->global_untyped; - mutex_lock(&c->info->global_untyped_mutex); + rw_mutex_lock(&c->info->global_untyped_mutex); map_remove(untyped, e); GB_ASSERT(map_get(untyped, e) == nullptr); - mutex_unlock(&c->info->global_untyped_mutex); + rw_mutex_unlock(&c->info->global_untyped_mutex); } } -isize type_info_index(CheckerInfo *info, Type *type, bool error_on_failure) { +gb_internal isize type_info_index(CheckerInfo *info, Type *type, bool error_on_failure) { type = default_type(type); if (type == t_llvm_bool) { type = t_bool; @@ -1416,12 +1412,10 @@ isize type_info_index(CheckerInfo *info, Type *type, bool error_on_failure) { entry_index = *found_entry_index; } if (entry_index < 0) { - // NOTE(bill): Do manual search - // TODO(bill): This is O(n) and can be very slow - for_array(i, info->type_info_map.entries){ - auto *e = &info->type_info_map.entries[i]; - if (are_types_identical_unique_tuples(e->key, type)) { - entry_index = e->value; + // NOTE(bill): Do manual linear search + for (auto const &e : info->type_info_map) { + if (are_types_identical_unique_tuples(e.key, type)) { + entry_index = e.value; // NOTE(bill): Add it to the search map map_set(&info->type_info_map, type, entry_index); break; @@ -1438,7 +1432,7 @@ isize type_info_index(CheckerInfo *info, Type *type, bool error_on_failure) { } -void add_untyped(CheckerContext *c, Ast *expr, AddressingMode mode, Type *type, ExactValue value) { +gb_internal void add_untyped(CheckerContext *c, Ast *expr, AddressingMode mode, Type *type, ExactValue const &value) { if (expr == nullptr) { return; } @@ -1455,7 +1449,7 @@ void add_untyped(CheckerContext *c, Ast *expr, AddressingMode mode, Type *type, check_set_expr_info(c, expr, mode, type, value); } -void add_type_and_value(CheckerInfo *i, Ast *expr, AddressingMode mode, Type *type, ExactValue value) { +gb_internal void add_type_and_value(CheckerContext *ctx, Ast *expr, AddressingMode mode, Type *type, ExactValue const &value) { if (expr == nullptr) { return; } @@ -1466,7 +1460,15 @@ void add_type_and_value(CheckerInfo *i, Ast *expr, AddressingMode mode, Type *ty return; } - mutex_lock(&i->type_and_value_mutex); + BlockingMutex *mutex = &ctx->info->type_and_value_mutex; + if (ctx->decl) { + mutex = &ctx->decl->type_and_value_mutex; + } else if (ctx->pkg) { + // TODO(bill): is a per package mutex is a good idea here? + mutex = &ctx->pkg->type_and_value_mutex; + } + + mutex_lock(mutex); Ast *prev_expr = nullptr; while (prev_expr != expr) { prev_expr = expr; @@ -1488,15 +1490,14 @@ void add_type_and_value(CheckerInfo *i, Ast *expr, AddressingMode mode, Type *ty expr = unparen_expr(expr); } - mutex_unlock(&i->type_and_value_mutex); + mutex_unlock(mutex); } -void add_entity_definition(CheckerInfo *i, Ast *identifier, Entity *entity) { +gb_internal void add_entity_definition(CheckerInfo *i, Ast *identifier, Entity *entity) { GB_ASSERT(identifier != nullptr); - GB_ASSERT(identifier->kind == Ast_Ident); - // if (is_blank_ident(identifier)) { - // return; - // } + if (identifier->kind != Ast_Ident) { + return; + } if (identifier->Ident.entity != nullptr) { // NOTE(bill): Identifier has already been handled return; @@ -1504,10 +1505,10 @@ void add_entity_definition(CheckerInfo *i, Ast *identifier, Entity *entity) { GB_ASSERT(entity != nullptr); identifier->Ident.entity = entity; entity->identifier = identifier; - mpmc_enqueue(&i->definition_queue, entity); + mpsc_enqueue(&i->definition_queue, entity); } -bool redeclaration_error(String name, Entity *prev, Entity *found) { +gb_internal bool redeclaration_error(String name, Entity *prev, Entity *found) { TokenPos pos = found->token.pos; Entity *up = found->using_parent; if (up != nullptr) { @@ -1550,12 +1551,12 @@ bool redeclaration_error(String name, Entity *prev, Entity *found) { return false; } -void add_entity_flags_from_file(CheckerContext *c, Entity *e, Scope *scope) { +gb_internal void add_entity_flags_from_file(CheckerContext *c, Entity *e, Scope *scope) { if (c->file != nullptr && (c->file->flags & AstFile_IsLazy) != 0 && scope->flags & ScopeFlag_File) { AstPackage *pkg = c->file->pkg; if (pkg->kind == Package_Init && e->kind == Entity_Procedure && e->token.string == "main") { // Do nothing - } else if (e->flags & (EntityFlag_Test|EntityFlag_Init)) { + } else if (e->flags & (EntityFlag_Test|EntityFlag_Init|EntityFlag_Fini)) { // Do nothing } else { e->flags |= EntityFlag_Lazy; @@ -1563,7 +1564,7 @@ void add_entity_flags_from_file(CheckerContext *c, Entity *e, Scope *scope) { } } -bool add_entity_with_name(CheckerContext *c, Scope *scope, Ast *identifier, Entity *entity, String name) { +gb_internal bool add_entity_with_name(CheckerContext *c, Scope *scope, Ast *identifier, Entity *entity, String name) { if (scope == nullptr) { return false; } @@ -1583,11 +1584,11 @@ bool add_entity_with_name(CheckerContext *c, Scope *scope, Ast *identifier, Enti } return true; } -bool add_entity(CheckerContext *c, Scope *scope, Ast *identifier, Entity *entity) { +gb_internal bool add_entity(CheckerContext *c, Scope *scope, Ast *identifier, Entity *entity) { return add_entity_with_name(c, scope, identifier, entity, entity->token.string); } -void add_entity_use(CheckerContext *c, Ast *identifier, Entity *entity) { +gb_internal void add_entity_use(CheckerContext *c, Ast *identifier, Entity *entity) { if (entity == nullptr) { return; } @@ -1600,12 +1601,6 @@ void add_entity_use(CheckerContext *c, Ast *identifier, Entity *entity) { identifier->Ident.entity = entity; - if (c->info->allow_identifier_uses) { - mutex_lock(&c->info->identifier_uses_mutex); - array_add(&c->info->identifier_uses, identifier); - mutex_unlock(&c->info->identifier_uses_mutex); - } - String dmsg = entity->deprecated_message; if (dmsg.len > 0) { warning(identifier, "%.*s is deprecated: %.*s", LIT(entity->token.string), LIT(dmsg)); @@ -1624,12 +1619,12 @@ void add_entity_use(CheckerContext *c, Ast *identifier, Entity *entity) { } -bool could_entity_be_lazy(Entity *e, DeclInfo *d) { +gb_internal bool could_entity_be_lazy(Entity *e, DeclInfo *d) { if ((e->flags & EntityFlag_Lazy) == 0) { return false; } - if (e->flags & (EntityFlag_Test|EntityFlag_Init)) { + if (e->flags & (EntityFlag_Test|EntityFlag_Init|EntityFlag_Fini)) { return false; } else if (e->kind == Entity_Variable && e->Variable.is_export) { return false; @@ -1637,11 +1632,9 @@ bool could_entity_be_lazy(Entity *e, DeclInfo *d) { return false; } - for_array(i, d->attributes) { - Ast *attr = d->attributes[i]; + for (Ast *attr : d->attributes) { if (attr->kind != Ast_Attribute) continue; - for_array(j, attr->Attribute.elems) { - Ast *elem = attr->Attribute.elems[j]; + for (Ast *elem : attr->Attribute.elems) { String name = {}; switch (elem->kind) { @@ -1675,7 +1668,7 @@ bool could_entity_be_lazy(Entity *e, DeclInfo *d) { return true; } -void add_entity_and_decl_info(CheckerContext *c, Ast *identifier, Entity *e, DeclInfo *d, bool is_exported) { +gb_internal void add_entity_and_decl_info(CheckerContext *c, Ast *identifier, Entity *e, DeclInfo *d, bool is_exported) { if (identifier == nullptr) { // NOTE(bill): Should only happen on errors error(e->token, "Invalid variable declaration"); @@ -1728,7 +1721,7 @@ void add_entity_and_decl_info(CheckerContext *c, Ast *identifier, Entity *e, Dec is_lazy = (e->flags & EntityFlag_Lazy) == EntityFlag_Lazy; if (!is_lazy) { - queue_count = mpmc_enqueue(&info->entity_queue, e); + queue_count = mpsc_enqueue(&info->entity_queue, e); } if (e->token.pos.file_id != 0) { @@ -1740,26 +1733,18 @@ void add_entity_and_decl_info(CheckerContext *c, Ast *identifier, Entity *e, Dec } -void add_implicit_entity(CheckerContext *c, Ast *clause, Entity *e) { +gb_internal void add_implicit_entity(CheckerContext *c, Ast *clause, Entity *e) { GB_ASSERT(clause != nullptr); GB_ASSERT(e != nullptr); GB_ASSERT(clause->kind == Ast_CaseClause); clause->CaseClause.implicit_entity = e; } -void add_type_info_type(CheckerContext *c, Type *t) { - void add_type_info_type_internal(CheckerContext *c, Type *t); - - if (build_context.disallow_rtti) { +gb_internal void add_type_info_type_internal(CheckerContext *c, Type *t); +gb_internal void add_type_info_type(CheckerContext *c, Type *t) { + if (build_context.no_rtti) { return; } - - mutex_lock(&c->info->type_info_mutex); - add_type_info_type_internal(c, t); - mutex_unlock(&c->info->type_info_mutex); -} - -void add_type_info_type_internal(CheckerContext *c, Type *t) { if (t == nullptr) { return; } @@ -1767,40 +1752,52 @@ void add_type_info_type_internal(CheckerContext *c, Type *t) { if (is_type_untyped(t)) { return; // Could be nil } - if (is_type_polymorphic(base_type(t))) { + if (is_type_polymorphic(t)) { return; } - add_type_info_dependency(c->info, c->decl, t, false); + add_type_info_type_internal(c, t); +} - auto found = map_get(&c->info->type_info_map, t); - if (found != nullptr) { - // Types have already been added +gb_internal void add_type_info_type_internal(CheckerContext *c, Type *t) { + if (t == nullptr) { return; } - bool prev = false; - isize ti_index = -1; - for_array(i, c->info->type_info_map.entries) { - auto *e = &c->info->type_info_map.entries[i]; - if (are_types_identical_unique_tuples(t, e->key)) { - // Duplicate entry - ti_index = e->value; - prev = true; - break; + add_type_info_dependency(c->info, c->decl, t); + + MUTEX_GUARD_BLOCK(&c->info->type_info_mutex) { + MapFindResult fr; + auto found = map_try_get(&c->info->type_info_map, t, &fr); + if (found != nullptr) { + // Types have already been added + return; } - } - if (ti_index < 0) { - // Unique entry - // NOTE(bill): map entries grow linearly and in order - ti_index = c->info->type_info_types.count; - array_add(&c->info->type_info_types, t); - } - map_set(&c->checker->info.type_info_map, t, ti_index); - if (prev) { - // NOTE(bill): If a previous one exists already, no need to continue - return; + bool prev = false; + isize ti_index = -1; + // NOTE(bill): this is a linear lookup, and is most likely very costly + // as this map keeps growing linearly + for (auto const &e : c->info->type_info_map) { + if (are_types_identical_unique_tuples(t, e.key)) { + // Duplicate entry + ti_index = e.value; + prev = true; + break; + } + } + if (ti_index < 0) { + // Unique entry + // NOTE(bill): map entries grow linearly and in order + ti_index = c->info->type_info_types.count; + array_add(&c->info->type_info_types, t); + } + map_set_internal_from_try_get(&c->checker->info.type_info_map, t, ti_index, fr); + + if (prev) { + // NOTE(bill): If a previous one exists already, no need to continue + return; + } } // Add nested types @@ -1908,8 +1905,8 @@ void add_type_info_type_internal(CheckerContext *c, Type *t) { case Type_Struct: if (bt->Struct.scope != nullptr) { - for_array(i, bt->Struct.scope->elements.entries) { - Entity *e = bt->Struct.scope->elements.entries[i].value; + for (auto const &entry : bt->Struct.scope->elements) { + Entity *e = entry.value; switch (bt->Struct.soa_kind) { case StructSoa_Dynamic: add_type_info_type_internal(c, t_allocator); @@ -1983,21 +1980,36 @@ void add_type_info_type_internal(CheckerContext *c, Type *t) { -gb_global bool global_procedure_body_in_worker_queue = false; +gb_global std::atomic global_procedure_body_in_worker_queue; +gb_global std::atomic global_after_checking_procedure_bodies; -void check_procedure_later(CheckerContext *c, ProcInfo *info) { +gb_internal WORKER_TASK_PROC(check_proc_info_worker_proc); + +gb_internal void check_procedure_later(Checker *c, ProcInfo *info) { GB_ASSERT(info != nullptr); GB_ASSERT(info->decl != nullptr); - if (build_context.threaded_checker && global_procedure_body_in_worker_queue) { - GB_ASSERT(c->procs_to_check_queue != nullptr); + if (global_after_checking_procedure_bodies) { + Entity *e = info->decl->entity; + debugf("CHECK PROCEDURE LATER! %.*s :: %s {...}\n", LIT(e->token.string), type_to_string(e->type)); } - auto *queue = c->procs_to_check_queue ? c->procs_to_check_queue : &c->checker->procs_to_check_queue; - mpmc_enqueue(queue, info); + if (global_procedure_body_in_worker_queue.load()) { + thread_pool_add_task(check_proc_info_worker_proc, info); + } else { + array_add(&c->procs_to_check, info); + } + + if (DEBUG_CHECK_ALL_PROCEDURES) { + MUTEX_GUARD_BLOCK(&c->info.all_procedures_mutex) { + GB_ASSERT(info != nullptr); + GB_ASSERT(info->decl != nullptr); + array_add(&c->info.all_procedures, info); + } + } } -void check_procedure_later(CheckerContext *c, AstFile *file, Token token, DeclInfo *decl, Type *type, Ast *body, u64 tags) { +gb_internal void check_procedure_later(Checker *c, AstFile *file, Token token, DeclInfo *decl, Type *type, Ast *body, u64 tags) { ProcInfo *info = gb_alloc_item(permanent_allocator(), ProcInfo); info->file = file; info->token = token; @@ -2009,7 +2021,7 @@ void check_procedure_later(CheckerContext *c, AstFile *file, Token token, DeclIn } -void add_min_dep_type_info(Checker *c, Type *t) { +gb_internal void add_min_dep_type_info(Checker *c, Type *t) { if (t == nullptr) { return; } @@ -2029,8 +2041,11 @@ void add_min_dep_type_info(Checker *c, Type *t) { ti_index = type_info_index(&c->info, t, false); } GB_ASSERT(ti_index >= 0); - if (ptr_set_update(set, ti_index)) { - // Type Already exists + // IMPORTANT NOTE(bill): this must be copied as `map_set` takes a const ref + // and effectively assigns the `+1` of the value + isize const count = set->count; + if (map_set_if_not_previously_exists(set, ti_index, count)) { + // Type already exists; return; } @@ -2132,8 +2147,8 @@ void add_min_dep_type_info(Checker *c, Type *t) { case Type_Struct: if (bt->Struct.scope != nullptr) { - for_array(i, bt->Struct.scope->elements.entries) { - Entity *e = bt->Struct.scope->elements.entries[i].value; + for (auto const &entry : bt->Struct.scope->elements) { + Entity *e = entry.value; switch (bt->Struct.soa_kind) { case StructSoa_Dynamic: add_min_dep_type_info(c, t_allocator); @@ -2204,7 +2219,7 @@ void add_min_dep_type_info(Checker *c, Type *t) { } -void add_dependency_to_set(Checker *c, Entity *entity) { +gb_internal void add_dependency_to_set(Checker *c, Entity *entity) { if (entity == nullptr) { return; } @@ -2230,13 +2245,11 @@ void add_dependency_to_set(Checker *c, Entity *entity) { return; } - for_array(i, decl->type_info_deps.entries) { - Type *type = decl->type_info_deps.entries[i].ptr; - add_min_dep_type_info(c, type); + for (Type *t : decl->type_info_deps) { + add_min_dep_type_info(c, t); } - for_array(i, decl->deps.entries) { - Entity *e = decl->deps.entries[i].ptr; + for (Entity *e : decl->deps) { add_dependency_to_set(c, e); if (e->kind == Entity_Procedure && e->Procedure.is_foreign) { Entity *fl = e->Procedure.foreign_library; @@ -2258,7 +2271,7 @@ void add_dependency_to_set(Checker *c, Entity *entity) { } } -void force_add_dependency_entity(Checker *c, Scope *scope, String const &name) { +gb_internal void force_add_dependency_entity(Checker *c, Scope *scope, String const &name) { Entity *e = scope_lookup(scope, name); if (e == nullptr) { return; @@ -2270,12 +2283,12 @@ void force_add_dependency_entity(Checker *c, Scope *scope, String const &name) { -void generate_minimum_dependency_set(Checker *c, Entity *start) { +gb_internal void generate_minimum_dependency_set(Checker *c, Entity *start) { isize entity_count = c->info.entities.count; isize min_dep_set_cap = next_pow2_isize(entity_count*4); // empirically determined factor - ptr_set_init(&c->info.minimum_dependency_set, heap_allocator(), min_dep_set_cap); - ptr_set_init(&c->info.minimum_dependency_type_info_set, heap_allocator()); + ptr_set_init(&c->info.minimum_dependency_set, min_dep_set_cap); + map_init(&c->info.minimum_dependency_type_info_set); #define FORCE_ADD_RUNTIME_ENTITIES(condition, ...) do { \ if (condition) { \ @@ -2330,7 +2343,7 @@ void generate_minimum_dependency_set(Checker *c, Entity *start) { str_lit("__multi3"), ); - FORCE_ADD_RUNTIME_ENTITIES(!build_context.disallow_rtti, + FORCE_ADD_RUNTIME_ENTITIES(!build_context.no_rtti, // Odin types str_lit("Type_Info"), @@ -2361,7 +2374,7 @@ void generate_minimum_dependency_set(Checker *c, Entity *start) { for_array(i, c->info.definitions) { Entity *e = c->info.definitions[i]; - if (e->scope == builtin_pkg->scope) { // TODO(bill): is the check enough? + if (e->scope == builtin_pkg->scope) { if (e->type == nullptr) { add_dependency_to_set(c, e); } @@ -2372,12 +2385,12 @@ void generate_minimum_dependency_set(Checker *c, Entity *start) { } } - for (Entity *e; mpmc_dequeue(&c->info.required_foreign_imports_through_force_queue, &e); /**/) { + for (Entity *e; mpsc_dequeue(&c->info.required_foreign_imports_through_force_queue, &e); /**/) { array_add(&c->info.required_foreign_imports_through_force, e); add_dependency_to_set(c, e); } - for (Entity *e; mpmc_dequeue(&c->info.required_global_variable_queue, &e); /**/) { + for (Entity *e; mpsc_dequeue(&c->info.required_global_variable_queue, &e); /**/) { e->flags |= EntityFlag_Used; add_dependency_to_set(c, e); } @@ -2420,6 +2433,28 @@ void generate_minimum_dependency_set(Checker *c, Entity *start) { add_dependency_to_set(c, e); array_add(&c->info.init_procedures, e); } + } else if (e->flags & EntityFlag_Fini) { + Type *t = base_type(e->type); + GB_ASSERT(t->kind == Type_Proc); + + bool is_fini = true; + + if (t->Proc.param_count != 0 || t->Proc.result_count != 0) { + gbString str = type_to_string(t); + error(e->token, "@(fini) procedures must have a signature type with no parameters nor results, got %s", str); + gb_string_free(str); + is_fini = false; + } + + if ((e->scope->flags & (ScopeFlag_File|ScopeFlag_Pkg)) == 0) { + error(e->token, "@(fini) procedures must be declared at the file scope"); + is_fini = false; + } + + if (is_fini) { + add_dependency_to_set(c, e); + array_add(&c->info.fini_procedures, e); + } } break; } @@ -2430,8 +2465,8 @@ void generate_minimum_dependency_set(Checker *c, Entity *start) { Scope *testing_scope = testing_package->scope; // Add all of testing library as a dependency - for_array(i, testing_scope->elements.entries) { - Entity *e = testing_scope->elements.entries[i].value; + for (auto const &entry : testing_scope->elements) { + Entity *e = entry.value; if (e != nullptr) { e->flags |= EntityFlag_Used; add_dependency_to_set(c, e); @@ -2445,8 +2480,8 @@ void generate_minimum_dependency_set(Checker *c, Entity *start) { AstPackage *pkg = c->info.init_package; Scope *s = pkg->scope; - for_array(i, s->elements.entries) { - Entity *e = s->elements.entries[i].value; + for (auto const &entry : s->elements) { + Entity *e = entry.value; if (e->kind != Entity_Procedure) { continue; } @@ -2483,7 +2518,7 @@ void generate_minimum_dependency_set(Checker *c, Entity *start) { #undef FORCE_ADD_RUNTIME_ENTITIES } -bool is_entity_a_dependency(Entity *e) { +gb_internal bool is_entity_a_dependency(Entity *e) { if (e == nullptr) return false; switch (e->kind) { case Entity_Procedure: @@ -2497,9 +2532,9 @@ bool is_entity_a_dependency(Entity *e) { return false; } -Array generate_entity_dependency_graph(CheckerInfo *info, gbAllocator allocator) { +gb_internal Array generate_entity_dependency_graph(CheckerInfo *info, gbAllocator allocator) { PtrMap M = {}; - map_init(&M, allocator, info->entities.count); + map_init(&M, info->entities.count); defer (map_destroy(&M)); for_array(i, info->entities) { Entity *e = info->entities[i]; @@ -2512,15 +2547,14 @@ Array generate_entity_dependency_graph(CheckerInfo *info, gbA TIME_SECTION("generate_entity_dependency_graph: Calculate edges for graph M - Part 1"); // Calculate edges for graph M - for_array(i, M.entries) { - EntityGraphNode *n = M.entries[i].value; + for (auto const &entry : M) { + EntityGraphNode *n = entry.value; Entity *e = n->entity; DeclInfo *decl = decl_info_of_entity(e); GB_ASSERT(decl != nullptr); - for_array(j, decl->deps.entries) { - Entity *dep = decl->deps.entries[j].ptr; + for (Entity *dep : decl->deps) { if (dep->flags & EntityFlag_Field) { continue; } @@ -2537,25 +2571,21 @@ Array generate_entity_dependency_graph(CheckerInfo *info, gbA // This means that the entity graph node set will have to be thread safe TIME_SECTION("generate_entity_dependency_graph: Calculate edges for graph M - Part 2"); - auto G = array_make(allocator, 0, M.entries.count); + auto G = array_make(allocator, 0, M.count); - for_array(i, M.entries) { - auto *entry = &M.entries[i]; - auto *e = entry->key; - EntityGraphNode *n = entry->value; + for (auto const &m_entry : M) { + auto *e = m_entry.key; + EntityGraphNode *n = m_entry.value; if (e->kind == Entity_Procedure) { // Connect each pred 'p' of 'n' with each succ 's' and from // the procedure node - for_array(j, n->pred.entries) { - EntityGraphNode *p = n->pred.entries[j].ptr; - + for (EntityGraphNode *p : n->pred) { // Ignore self-cycles if (p != n) { // Each succ 's' of 'n' becomes a succ of 'p', and // each pred 'p' of 'n' becomes a pred of 's' - for_array(k, n->succ.entries) { - EntityGraphNode *s = n->succ.entries[k].ptr; + for (EntityGraphNode *s : n->succ) { // Ignore self-cycles if (s != n) { if (p->entity->kind == Entity_Procedure && @@ -2566,7 +2596,6 @@ Array generate_entity_dependency_graph(CheckerInfo *info, gbA } // IMPORTANT NOTE/TODO(bill, 2020-11-15): These three calls take the majority of the // the time to process - entity_graph_node_set_add(&p->succ, s); entity_graph_node_set_add(&s->pred, p); // Remove edge to 'n' @@ -2587,7 +2616,7 @@ Array generate_entity_dependency_graph(CheckerInfo *info, gbA for_array(i, G) { EntityGraphNode *n = G[i]; n->index = i; - n->dep_count = n->succ.entries.count; + n->dep_count = n->succ.count; GB_ASSERT(n->dep_count >= 0); } @@ -2617,10 +2646,10 @@ Array generate_entity_dependency_graph(CheckerInfo *info, gbA } -void check_single_global_entity(Checker *c, Entity *e, DeclInfo *d); +gb_internal void check_single_global_entity(Checker *c, Entity *e, DeclInfo *d); -Entity *find_core_entity(Checker *c, String name) { +gb_internal Entity *find_core_entity(Checker *c, String name) { Entity *e = scope_lookup_current(c->info.runtime_package->scope, name); if (e == nullptr) { compiler_error("Could not find type declaration for '%.*s'\n" @@ -2630,7 +2659,7 @@ Entity *find_core_entity(Checker *c, String name) { return e; } -Type *find_core_type(Checker *c, String name) { +gb_internal Type *find_core_type(Checker *c, String name) { Entity *e = scope_lookup_current(c->info.runtime_package->scope, name); if (e == nullptr) { compiler_error("Could not find type declaration for '%.*s'\n" @@ -2645,7 +2674,7 @@ Type *find_core_type(Checker *c, String name) { } -Entity *find_entity_in_pkg(CheckerInfo *info, String const &pkg, String const &name) { +gb_internal Entity *find_entity_in_pkg(CheckerInfo *info, String const &pkg, String const &name) { AstPackage *package = get_core_package(info, pkg); Entity *e = scope_lookup_current(package->scope, name); if (e == nullptr) { @@ -2655,7 +2684,7 @@ Entity *find_entity_in_pkg(CheckerInfo *info, String const &pkg, String const &n return e; } -Type *find_type_in_pkg(CheckerInfo *info, String const &pkg, String const &name) { +gb_internal Type *find_type_in_pkg(CheckerInfo *info, String const &pkg, String const &name) { AstPackage *package = get_core_package(info, pkg); Entity *e = scope_lookup_current(package->scope, name); if (e == nullptr) { @@ -2666,58 +2695,32 @@ Type *find_type_in_pkg(CheckerInfo *info, String const &pkg, String const &name) return e->type; } -CheckerTypePath *new_checker_type_path() { +gb_internal CheckerTypePath *new_checker_type_path() { gbAllocator a = heap_allocator(); auto *tp = gb_alloc_item(a, CheckerTypePath); array_init(tp, a, 0, 16); return tp; } -void destroy_checker_type_path(CheckerTypePath *tp) { +gb_internal void destroy_checker_type_path(CheckerTypePath *tp) { array_free(tp); gb_free(heap_allocator(), tp); } -void check_type_path_push(CheckerContext *c, Entity *e) { +gb_internal void check_type_path_push(CheckerContext *c, Entity *e) { GB_ASSERT(c->type_path != nullptr); GB_ASSERT(e != nullptr); array_add(c->type_path, e); } -Entity *check_type_path_pop(CheckerContext *c) { +gb_internal Entity *check_type_path_pop(CheckerContext *c) { GB_ASSERT(c->type_path != nullptr); return array_pop(c->type_path); } -CheckerPolyPath *new_checker_poly_path(void) { - gbAllocator a = heap_allocator(); - auto *pp = gb_alloc_item(a, CheckerPolyPath); - array_init(pp, a, 0, 16); - return pp; -} -void destroy_checker_poly_path(CheckerPolyPath *pp) { - array_free(pp); - gb_free(heap_allocator(), pp); -} - - -void check_poly_path_push(CheckerContext *c, Type *t) { - GB_ASSERT(c->poly_path != nullptr); - GB_ASSERT(t != nullptr); - GB_ASSERT(is_type_polymorphic(t)); - array_add(c->poly_path, t); -} - -Type *check_poly_path_pop(CheckerContext *c) { - GB_ASSERT(c->poly_path != nullptr); - return array_pop(c->poly_path); -} - - - -Array proc_group_entities(CheckerContext *c, Operand o) { +gb_internal Array proc_group_entities(CheckerContext *c, Operand o) { Array procs = {}; if (o.mode == Addressing_ProcGroup) { GB_ASSERT(o.proc_group != nullptr); @@ -2729,7 +2732,7 @@ Array proc_group_entities(CheckerContext *c, Operand o) { return procs; } -Array proc_group_entities_cloned(CheckerContext *c, Operand o) { +gb_internal Array proc_group_entities_cloned(CheckerContext *c, Operand o) { auto entities = proc_group_entities(c, o); if (entities.count == 0) { return {}; @@ -2740,7 +2743,7 @@ Array proc_group_entities_cloned(CheckerContext *c, Operand o) { -void init_core_type_info(Checker *c) { +gb_internal void init_core_type_info(Checker *c) { if (t_type_info != nullptr) { return; } @@ -2779,7 +2782,7 @@ void init_core_type_info(Checker *c) { t_type_info_enumerated_array = find_core_type(c, str_lit("Type_Info_Enumerated_Array")); t_type_info_dynamic_array = find_core_type(c, str_lit("Type_Info_Dynamic_Array")); t_type_info_slice = find_core_type(c, str_lit("Type_Info_Slice")); - t_type_info_tuple = find_core_type(c, str_lit("Type_Info_Tuple")); + t_type_info_parameters = find_core_type(c, str_lit("Type_Info_Parameters")); t_type_info_struct = find_core_type(c, str_lit("Type_Info_Struct")); t_type_info_union = find_core_type(c, str_lit("Type_Info_Union")); t_type_info_enum = find_core_type(c, str_lit("Type_Info_Enum")); @@ -2808,7 +2811,7 @@ void init_core_type_info(Checker *c) { t_type_info_enumerated_array_ptr = alloc_type_pointer(t_type_info_enumerated_array); t_type_info_dynamic_array_ptr = alloc_type_pointer(t_type_info_dynamic_array); t_type_info_slice_ptr = alloc_type_pointer(t_type_info_slice); - t_type_info_tuple_ptr = alloc_type_pointer(t_type_info_tuple); + t_type_info_parameters_ptr = alloc_type_pointer(t_type_info_parameters); t_type_info_struct_ptr = alloc_type_pointer(t_type_info_struct); t_type_info_union_ptr = alloc_type_pointer(t_type_info_union); t_type_info_enum_ptr = alloc_type_pointer(t_type_info_enum); @@ -2821,7 +2824,7 @@ void init_core_type_info(Checker *c) { t_type_info_soa_pointer_ptr = alloc_type_pointer(t_type_info_soa_pointer); } -void init_mem_allocator(Checker *c) { +gb_internal void init_mem_allocator(Checker *c) { if (t_allocator != nullptr) { return; } @@ -2830,7 +2833,7 @@ void init_mem_allocator(Checker *c) { t_allocator_error = find_core_type(c, str_lit("Allocator_Error")); } -void init_core_context(Checker *c) { +gb_internal void init_core_context(Checker *c) { if (t_context != nullptr) { return; } @@ -2838,7 +2841,7 @@ void init_core_context(Checker *c) { t_context_ptr = alloc_type_pointer(t_context); } -void init_core_source_code_location(Checker *c) { +gb_internal void init_core_source_code_location(Checker *c) { if (t_source_code_location != nullptr) { return; } @@ -2846,7 +2849,7 @@ void init_core_source_code_location(Checker *c) { t_source_code_location_ptr = alloc_type_pointer(t_source_code_location); } -void init_core_map_type(Checker *c) { +gb_internal void init_core_map_type(Checker *c) { if (t_map_info != nullptr) { return; } @@ -2860,7 +2863,7 @@ void init_core_map_type(Checker *c) { t_raw_map_ptr = alloc_type_pointer(t_raw_map); } -void init_preload(Checker *c) { +gb_internal void init_preload(Checker *c) { init_core_type_info(c); init_mem_allocator(c); init_core_context(c); @@ -2868,7 +2871,7 @@ void init_preload(Checker *c) { init_core_map_type(c); } -ExactValue check_decl_attribute_value(CheckerContext *c, Ast *value) { +gb_internal ExactValue check_decl_attribute_value(CheckerContext *c, Ast *value) { ExactValue ev = {}; if (value != nullptr) { Operand op = {}; @@ -2884,18 +2887,11 @@ ExactValue check_decl_attribute_value(CheckerContext *c, Ast *value) { return ev; } -Type *check_decl_attribute_type(CheckerContext *c, Ast *value) { - if (value != nullptr) { - return check_type(c, value); - } - return nullptr; -} - #define ATTRIBUTE_USER_TAG_NAME "tag" -DECL_ATTRIBUTE_PROC(foreign_block_decl_attribute) { +gb_internal DECL_ATTRIBUTE_PROC(foreign_block_decl_attribute) { ExactValue ev = check_decl_attribute_value(c, value); if (name == ATTRIBUTE_USER_TAG_NAME) { @@ -2950,7 +2946,7 @@ DECL_ATTRIBUTE_PROC(foreign_block_decl_attribute) { return false; } -DECL_ATTRIBUTE_PROC(proc_decl_attribute) { +gb_internal DECL_ATTRIBUTE_PROC(proc_decl_attribute) { if (name == ATTRIBUTE_USER_TAG_NAME) { ExactValue ev = check_decl_attribute_value(c, value); if (ev.kind != ExactValue_String) { @@ -3010,6 +3006,12 @@ DECL_ATTRIBUTE_PROC(proc_decl_attribute) { } ac->init = true; return true; + } else if (name == "fini") { + if (value != nullptr) { + error(value, "'%.*s' expects no parameter, or a string literal containing \"file\" or \"package\"", LIT(name)); + } + ac->fini = true; + return true; } else if (name == "deferred") { if (value != nullptr) { Operand o = {}; @@ -3088,6 +3090,54 @@ DECL_ATTRIBUTE_PROC(proc_decl_attribute) { } error(elem, "Expected a procedure entity for '%.*s'", LIT(name)); return false; + } else if (name == "deferred_in_by_ptr") { + if (value != nullptr) { + Operand o = {}; + check_expr(c, &o, value); + Entity *e = entity_of_node(o.expr); + if (e != nullptr && e->kind == Entity_Procedure) { + if (ac->deferred_procedure.entity != nullptr) { + error(elem, "Previous usage of a 'deferred_*' attribute"); + } + ac->deferred_procedure.kind = DeferredProcedure_in_by_ptr; + ac->deferred_procedure.entity = e; + return true; + } + } + error(elem, "Expected a procedure entity for '%.*s'", LIT(name)); + return false; + } else if (name == "deferred_out_by_ptr") { + if (value != nullptr) { + Operand o = {}; + check_expr(c, &o, value); + Entity *e = entity_of_node(o.expr); + if (e != nullptr && e->kind == Entity_Procedure) { + if (ac->deferred_procedure.entity != nullptr) { + error(elem, "Previous usage of a 'deferred_*' attribute"); + } + ac->deferred_procedure.kind = DeferredProcedure_out_by_ptr; + ac->deferred_procedure.entity = e; + return true; + } + } + error(elem, "Expected a procedure entity for '%.*s'", LIT(name)); + return false; + } else if (name == "deferred_in_out_by_ptr") { + if (value != nullptr) { + Operand o = {}; + check_expr(c, &o, value); + Entity *e = entity_of_node(o.expr); + if (e != nullptr && e->kind == Entity_Procedure) { + if (ac->deferred_procedure.entity != nullptr) { + error(elem, "Previous usage of a 'deferred_*' attribute"); + } + ac->deferred_procedure.kind = DeferredProcedure_in_out_by_ptr; + ac->deferred_procedure.entity = e; + return true; + } + } + error(elem, "Expected a procedure entity for '%.*s'", LIT(name)); + return false; } else if (name == "link_name") { ExactValue ev = check_decl_attribute_value(c, value); @@ -3247,7 +3297,7 @@ DECL_ATTRIBUTE_PROC(proc_decl_attribute) { return false; } -DECL_ATTRIBUTE_PROC(var_decl_attribute) { +gb_internal DECL_ATTRIBUTE_PROC(var_decl_attribute) { if (name == ATTRIBUTE_USER_TAG_NAME) { ExactValue ev = check_decl_attribute_value(c, value); if (ev.kind != ExactValue_String) { @@ -3372,7 +3422,7 @@ DECL_ATTRIBUTE_PROC(var_decl_attribute) { return false; } -DECL_ATTRIBUTE_PROC(const_decl_attribute) { +gb_internal DECL_ATTRIBUTE_PROC(const_decl_attribute) { if (name == ATTRIBUTE_USER_TAG_NAME) { ExactValue ev = check_decl_attribute_value(c, value); if (ev.kind != ExactValue_String) { @@ -3386,7 +3436,7 @@ DECL_ATTRIBUTE_PROC(const_decl_attribute) { return false; } -DECL_ATTRIBUTE_PROC(type_decl_attribute) { +gb_internal DECL_ATTRIBUTE_PROC(type_decl_attribute) { if (name == ATTRIBUTE_USER_TAG_NAME) { ExactValue ev = check_decl_attribute_value(c, value); if (ev.kind != ExactValue_String) { @@ -3417,7 +3467,7 @@ DECL_ATTRIBUTE_PROC(type_decl_attribute) { -void check_decl_attributes(CheckerContext *c, Array const &attributes, DeclAttributeProc *proc, AttributeContext *ac) { +gb_internal void check_decl_attributes(CheckerContext *c, Array const &attributes, DeclAttributeProc *proc, AttributeContext *ac) { if (attributes.count == 0) return; String original_link_prefix = {}; @@ -3426,9 +3476,21 @@ void check_decl_attributes(CheckerContext *c, Array const &attributes, De } StringSet set = {}; - string_set_init(&set, heap_allocator()); defer (string_set_destroy(&set)); + bool is_runtime = false; + if (c->scope && c->scope->file && (c->scope->flags & ScopeFlag_File) && + c->scope->file->pkg && + c->scope->file->pkg->kind == Package_Runtime) { + is_runtime = true; + } else if (c->scope && c->scope->parent && + (c->scope->flags & ScopeFlag_Proc) && + (c->scope->parent->flags & ScopeFlag_File) && + c->scope->parent->file->pkg && + c->scope->parent->file->pkg->kind == Package_Runtime) { + is_runtime = true; + } + for_array(i, attributes) { Ast *attr = attributes[i]; if (attr->kind != Ast_Attribute) continue; @@ -3459,16 +3521,19 @@ void check_decl_attributes(CheckerContext *c, Array const &attributes, De continue; } - if (string_set_exists(&set, name)) { + if (string_set_update(&set, name)) { error(elem, "Previous declaration of '%.*s'", LIT(name)); continue; - } else { - string_set_add(&set, name); + } + + if (name == "builtin" && is_runtime) { + continue; } if (!proc(c, elem, name, value, ac)) { if (!build_context.ignore_unknown_attributes) { error(elem, "Unknown attribute element name '%.*s'", LIT(name)); + error_line("\tDid you forget to use build flag '-ignore-unknown-attributes'?\n"); } } } @@ -3485,7 +3550,7 @@ void check_decl_attributes(CheckerContext *c, Array const &attributes, De } -isize get_total_value_count(Slice const &values) { +gb_internal isize get_total_value_count(Slice const &values) { isize count = 0; for_array(i, values) { Type *t = type_of_expr(values[i]); @@ -3503,7 +3568,7 @@ isize get_total_value_count(Slice const &values) { return count; } -bool check_arity_match(CheckerContext *c, AstValueDecl *vd, bool is_global) { +gb_internal bool check_arity_match(CheckerContext *c, AstValueDecl *vd, bool is_global) { isize lhs = vd->names.count; isize rhs = 0; if (is_global) { @@ -3546,7 +3611,7 @@ bool check_arity_match(CheckerContext *c, AstValueDecl *vd, bool is_global) { return true; } -void check_collect_entities_from_when_stmt(CheckerContext *c, AstWhenStmt *ws) { +gb_internal void check_collect_entities_from_when_stmt(CheckerContext *c, AstWhenStmt *ws) { Operand operand = {Addressing_Invalid}; if (!ws->is_cond_determined) { check_expr(c, &operand, ws->cond); @@ -3582,7 +3647,7 @@ void check_collect_entities_from_when_stmt(CheckerContext *c, AstWhenStmt *ws) { } } -void check_builtin_attributes(CheckerContext *ctx, Entity *e, Array *attributes) { +gb_internal void check_builtin_attributes(CheckerContext *ctx, Entity *e, Array *attributes) { switch (e->kind) { case Entity_ProcGroup: case Entity_Procedure: @@ -3625,9 +3690,9 @@ void check_builtin_attributes(CheckerContext *ctx, Entity *e, Array *attr error(value, "'builtin' cannot have a field value"); } // Remove the builtin tag - attr->Attribute.elems[k] = attr->Attribute.elems[attr->Attribute.elems.count-1]; - attr->Attribute.elems.count -= 1; - k--; + // attr->Attribute.elems[k] = attr->Attribute.elems[attr->Attribute.elems.count-1]; + // attr->Attribute.elems.count -= 1; + // k--; mutex_unlock(&ctx->info->builtin_mutex); } @@ -3645,7 +3710,7 @@ void check_builtin_attributes(CheckerContext *ctx, Entity *e, Array *attr } } -void check_collect_value_decl(CheckerContext *c, Ast *decl) { +gb_internal void check_collect_value_decl(CheckerContext *c, Ast *decl) { if (decl->state_flags & StateFlag_BeenHandled) return; decl->state_flags |= StateFlag_BeenHandled; @@ -3654,6 +3719,7 @@ void check_collect_value_decl(CheckerContext *c, Ast *decl) { EntityVisiblityKind entity_visibility_kind = c->foreign_context.visibility_kind; bool is_test = false; bool is_init = false; + bool is_fini = false; for_array(i, vd->attributes) { Ast *attr = vd->attributes[i]; @@ -3713,6 +3779,8 @@ void check_collect_value_decl(CheckerContext *c, Ast *decl) { is_test = true; } else if (name == "init") { is_init = true; + } else if (name == "fini") { + is_fini = true; } } } @@ -3833,6 +3901,13 @@ void check_collect_value_decl(CheckerContext *c, Ast *decl) { cc = ProcCC_CDecl; if (c->foreign_context.default_cc > 0) { cc = c->foreign_context.default_cc; + } else if (is_arch_wasm()) { + begin_error_block(); + error(init, "For wasm related targets, it is required that you either define the" + " @(default_calling_convention=) on the foreign block or" + " explicitly assign it on the procedure signature"); + error_line("\tSuggestion: when dealing with normal Odin code (e.g. js_wasm32), use \"contextless\"; when dealing with Emscripten like code, use \"c\"\n"); + end_error_block(); } } e->Procedure.link_prefix = c->foreign_context.link_prefix; @@ -3846,8 +3921,12 @@ void check_collect_value_decl(CheckerContext *c, Ast *decl) { if (is_test) { e->flags |= EntityFlag_Test; } - if (is_init) { + if (is_init && is_fini) { + error(name, "A procedure cannot be both declared as @(init) and @(fini)"); + } else if (is_init) { e->flags |= EntityFlag_Init; + } else if (is_fini) { + e->flags |= EntityFlag_Fini; } } else if (init->kind == Ast_ProcGroup) { ast_node(pg, ProcGroup, init); @@ -3896,10 +3975,9 @@ void check_collect_value_decl(CheckerContext *c, Ast *decl) { } } -void check_add_foreign_block_decl(CheckerContext *ctx, Ast *decl) { - if (decl->state_flags & StateFlag_BeenHandled) return; - decl->state_flags |= StateFlag_BeenHandled; +gb_internal bool collect_file_decls(CheckerContext *ctx, Slice const &decls); +gb_internal bool check_add_foreign_block_decl(CheckerContext *ctx, Ast *decl) { ast_node(fb, ForeignBlockDecl, decl); Ast *foreign_library = fb->foreign_library; @@ -3914,10 +3992,14 @@ void check_add_foreign_block_decl(CheckerContext *ctx, Ast *decl) { check_decl_attributes(&c, fb->attributes, foreign_block_decl_attribute, nullptr); ast_node(block, BlockStmt, fb->body); + if (c.collect_delayed_decls && (c.scope->flags&ScopeFlag_File) != 0) { + return collect_file_decls(&c, block->stmts); + } check_collect_entities(&c, block->stmts); + return false; } -bool correct_single_type_alias(CheckerContext *c, Entity *e) { +gb_internal bool correct_single_type_alias(CheckerContext *c, Entity *e) { if (e->kind == Entity_Constant) { DeclInfo *d = e->decl_info; if (d != nullptr && d->init_expr != nullptr) { @@ -3932,17 +4014,17 @@ bool correct_single_type_alias(CheckerContext *c, Entity *e) { return false; } -bool correct_type_alias_in_scope_backwards(CheckerContext *c, Scope *s) { - isize n = s->elements.entries.count; +gb_internal bool correct_type_alias_in_scope_backwards(CheckerContext *c, Scope *s) { bool correction = false; - for (isize i = n-1; i >= 0; i--) { + u32 n = s->elements.count; + for (u32 i = n-1; i < n; i--) { correction |= correct_single_type_alias(c, s->elements.entries[i].value); } return correction; } -bool correct_type_alias_in_scope_forwards(CheckerContext *c, Scope *s) { - isize n = s->elements.entries.count; +gb_internal bool correct_type_alias_in_scope_forwards(CheckerContext *c, Scope *s) { bool correction = false; + u32 n = s->elements.count; for (isize i = 0; i < n; i++) { correction |= correct_single_type_alias(c, s->elements.entries[i].value); } @@ -3950,7 +4032,7 @@ bool correct_type_alias_in_scope_forwards(CheckerContext *c, Scope *s) { } -void correct_type_aliases_in_scope(CheckerContext *c, Scope *s) { +gb_internal void correct_type_aliases_in_scope(CheckerContext *c, Scope *s) { // NOTE(bill, 2022-02-04): This is used to solve the problem caused by type aliases // of type aliases being "confused" as constants // @@ -3969,9 +4051,8 @@ void correct_type_aliases_in_scope(CheckerContext *c, Scope *s) { } } - // NOTE(bill): If file_scopes == nullptr, this will act like a local scope -void check_collect_entities(CheckerContext *c, Slice const &nodes) { +gb_internal void check_collect_entities(CheckerContext *c, Slice const &nodes) { AstFile *curr_file = nullptr; if ((c->scope->flags&ScopeFlag_File) != 0) { curr_file = c->scope->file; @@ -3988,7 +4069,7 @@ void check_collect_entities(CheckerContext *c, Slice const &nodes) { if (c->collect_delayed_decls) { if (decl->state_flags & StateFlag_BeenHandled) return; decl->state_flags |= StateFlag_BeenHandled; - mpmc_enqueue(&curr_file->delayed_decls_queues[AstDelayQueue_Expr], expr); + array_add(&curr_file->delayed_decls_queues[AstDelayQueue_Expr], expr); } continue; } @@ -4012,18 +4093,16 @@ void check_collect_entities(CheckerContext *c, Slice const &nodes) { if (curr_file == nullptr) { error(decl, "import declarations are only allowed in the file scope"); // NOTE(bill): _Should_ be caught by the parser - // TODO(bill): Better error handling if it isn't continue; } // Will be handled later - mpmc_enqueue(&curr_file->delayed_decls_queues[AstDelayQueue_Import], decl); + array_add(&curr_file->delayed_decls_queues[AstDelayQueue_Import], decl); case_end; case_ast_node(fl, ForeignImportDecl, decl); if ((c->scope->flags&ScopeFlag_File) == 0) { error(decl, "%.*s declarations are only allowed in the file scope", LIT(fl->token.string)); // NOTE(bill): _Should_ be caught by the parser - // TODO(bill): Better error handling if it isn't continue; } check_add_foreign_import_decl(c, decl); @@ -4055,13 +4134,13 @@ void check_collect_entities(CheckerContext *c, Slice const &nodes) { } } -CheckerContext *create_checker_context(Checker *c) { +gb_internal CheckerContext *create_checker_context(Checker *c) { CheckerContext *ctx = gb_alloc_item(permanent_allocator(), CheckerContext); *ctx = make_checker_context(c); return ctx; } -void check_single_global_entity(Checker *c, Entity *e, DeclInfo *d) { +gb_internal void check_single_global_entity(Checker *c, Entity *e, DeclInfo *d) { GB_ASSERT(e != nullptr); GB_ASSERT(d != nullptr); @@ -4094,11 +4173,12 @@ void check_single_global_entity(Checker *c, Entity *e, DeclInfo *d) { check_entity_decl(ctx, e, d, nullptr); } -void check_all_global_entities(Checker *c) { +gb_internal void check_all_global_entities(Checker *c) { // NOTE(bill): This must be single threaded // Don't bother trying for_array(i, c->info.entities) { Entity *e = c->info.entities[i]; + GB_ASSERT(e != nullptr); if (e->flags & EntityFlag_Lazy) { continue; } @@ -4112,7 +4192,7 @@ void check_all_global_entities(Checker *c) { } -bool is_string_an_identifier(String s) { +gb_internal bool is_string_an_identifier(String s) { isize offset = 0; if (s.len < 1) { return false; @@ -4136,7 +4216,7 @@ bool is_string_an_identifier(String s) { return offset == s.len; } -String path_to_entity_name(String name, String fullpath, bool strip_extension=true) { +gb_internal String path_to_entity_name(String name, String fullpath, bool strip_extension=true) { if (name.len != 0) { return name; } @@ -4182,7 +4262,7 @@ String path_to_entity_name(String name, String fullpath, bool strip_extension=tr #if 1 -void add_import_dependency_node(Checker *c, Ast *decl, PtrMap *M) { +gb_internal void add_import_dependency_node(Checker *c, Ast *decl, PtrMap *M) { AstPackage *parent_pkg = decl->file()->pkg; switch (decl->kind) { @@ -4214,7 +4294,6 @@ void add_import_dependency_node(Checker *c, Ast *decl, PtrMapsucc, m); import_graph_node_set_add(&m->pred, n); ptr_set_add(&m->scope->imported, n->scope); @@ -4247,9 +4326,9 @@ void add_import_dependency_node(Checker *c, Ast *decl, PtrMap generate_import_dependency_graph(Checker *c) { +gb_internal Array generate_import_dependency_graph(Checker *c) { PtrMap M = {}; - map_init(&M, heap_allocator(), 2*c->parser->packages.count); + map_init(&M, 2*c->parser->packages.count); defer (map_destroy(&M)); for_array(i, c->parser->packages) { @@ -4271,12 +4350,13 @@ Array generate_import_dependency_graph(Checker *c) { } Array G = {}; - array_init(&G, heap_allocator(), 0, M.entries.count); + array_init(&G, heap_allocator(), 0, M.count); - for_array(i, M.entries) { - auto n = M.entries[i].value; - n->index = i; - n->dep_count = n->succ.entries.count; + isize i = 0; + for (auto const &entry : M) { + auto n = entry.value; + n->index = i++; + n->dep_count = n->succ.count; GB_ASSERT(n->dep_count >= 0); array_add(&G, n); } @@ -4289,7 +4369,7 @@ struct ImportPathItem { Ast * decl; }; -Array find_import_path(Checker *c, AstPackage *start, AstPackage *end, PtrSet *visited) { +gb_internal Array find_import_path(Checker *c, AstPackage *start, AstPackage *end, PtrSet *visited) { Array empty_path = {}; if (ptr_set_update(visited, start)) { @@ -4339,7 +4419,7 @@ Array find_import_path(Checker *c, AstPackage *start, AstPackage } #endif -String get_invalid_import_name(String input) { +gb_internal String get_invalid_import_name(String input) { isize slash = 0; for (isize i = input.len-1; i >= 0; i--) { if (input[i] == '/' || input[i] == '\\') { @@ -4351,7 +4431,7 @@ String get_invalid_import_name(String input) { return input; } -void check_add_import_decl(CheckerContext *ctx, Ast *decl) { +gb_internal void check_add_import_decl(CheckerContext *ctx, Ast *decl) { if (decl->state_flags & StateFlag_BeenHandled) return; decl->state_flags |= StateFlag_BeenHandled; @@ -4376,8 +4456,8 @@ void check_add_import_decl(CheckerContext *ctx, Ast *decl) { } else { AstPackage **found = string_map_get(pkgs, id->fullpath); if (found == nullptr) { - for_array(pkg_index, pkgs->entries) { - AstPackage *pkg = pkgs->entries[pkg_index].value; + for (auto const &entry : *pkgs) { + AstPackage *pkg = entry.value; gb_printf_err("%.*s\n", LIT(pkg->fullpath)); } gb_printf_err("%s\n", token_pos_to_string(token.pos)); @@ -4426,7 +4506,7 @@ void check_add_import_decl(CheckerContext *ctx, Ast *decl) { scope->flags |= ScopeFlag_HasBeenImported; } -DECL_ATTRIBUTE_PROC(foreign_import_decl_attribute) { +gb_internal DECL_ATTRIBUTE_PROC(foreign_import_decl_attribute) { if (name == ATTRIBUTE_USER_TAG_NAME) { ExactValue ev = check_decl_attribute_value(c, value); if (ev.kind != ExactValue_String) { @@ -4449,11 +4529,19 @@ DECL_ATTRIBUTE_PROC(foreign_import_decl_attribute) { ac->foreign_import_priority_index = exact_value_to_i64(ev); } return true; + } else if (name == "extra_linker_flags") { + ExactValue ev = check_decl_attribute_value(c, value); + if (ev.kind != ExactValue_String) { + error(elem, "Expected a string value for '%.*s'", LIT(name)); + } else { + ac->extra_linker_flags = ev.value_string; + } + return true; } return false; } -void check_add_foreign_import_decl(CheckerContext *ctx, Ast *decl) { +gb_internal void check_add_foreign_import_decl(CheckerContext *ctx, Ast *decl) { if (decl->state_flags & StateFlag_BeenHandled) return; decl->state_flags |= StateFlag_BeenHandled; @@ -4502,12 +4590,16 @@ void check_add_foreign_import_decl(CheckerContext *ctx, Ast *decl) { AttributeContext ac = {}; check_decl_attributes(ctx, fl->attributes, foreign_import_decl_attribute, &ac); if (ac.require_declaration) { - mpmc_enqueue(&ctx->info->required_foreign_imports_through_force_queue, e); + mpsc_enqueue(&ctx->info->required_foreign_imports_through_force_queue, e); add_entity_use(ctx, nullptr, e); } if (ac.foreign_import_priority_index != 0) { e->LibraryName.priority_index = ac.foreign_import_priority_index; } + String extra_linker_flags = string_trim_whitespace(ac.extra_linker_flags); + if (extra_linker_flags.len != 0) { + e->LibraryName.extra_linker_flags = extra_linker_flags; + } if (has_asm_extension(fullpath)) { if (build_context.metrics.arch != TargetArch_amd64 || @@ -4519,10 +4611,10 @@ void check_add_foreign_import_decl(CheckerContext *ctx, Ast *decl) { } // Returns true if a new package is present -bool collect_file_decls(CheckerContext *ctx, Slice const &decls); -bool collect_file_decls_from_when_stmt(CheckerContext *ctx, AstWhenStmt *ws); +gb_internal bool collect_file_decls(CheckerContext *ctx, Slice const &decls); +gb_internal bool collect_file_decls_from_when_stmt(CheckerContext *ctx, AstWhenStmt *ws); -bool collect_when_stmt_from_file(CheckerContext *ctx, AstWhenStmt *ws) { +gb_internal bool collect_when_stmt_from_file(CheckerContext *ctx, AstWhenStmt *ws) { Operand operand = {Addressing_Invalid}; if (!ws->is_cond_determined) { check_expr(ctx, &operand, ws->cond); @@ -4561,7 +4653,7 @@ bool collect_when_stmt_from_file(CheckerContext *ctx, AstWhenStmt *ws) { return false; } -bool collect_file_decls_from_when_stmt(CheckerContext *ctx, AstWhenStmt *ws) { +gb_internal bool collect_file_decls_from_when_stmt(CheckerContext *ctx, AstWhenStmt *ws) { Operand operand = {Addressing_Invalid}; if (!ws->is_cond_determined) { check_expr(ctx, &operand, ws->cond); @@ -4598,7 +4690,7 @@ bool collect_file_decls_from_when_stmt(CheckerContext *ctx, AstWhenStmt *ws) { } -bool collect_file_decl(CheckerContext *ctx, Ast *decl) { +gb_internal bool collect_file_decl(CheckerContext *ctx, Ast *decl) { GB_ASSERT(ctx->scope->flags&ScopeFlag_File); AstFile *curr_file = ctx->scope->file; @@ -4622,7 +4714,9 @@ bool collect_file_decl(CheckerContext *ctx, Ast *decl) { case_end; case_ast_node(fb, ForeignBlockDecl, decl); - check_add_foreign_block_decl(ctx, decl); + if (check_add_foreign_block_decl(ctx, decl)) { + return true; + } case_end; case_ast_node(ws, WhenStmt, decl); @@ -4653,7 +4747,7 @@ bool collect_file_decl(CheckerContext *ctx, Ast *decl) { if (es->expr->kind == Ast_CallExpr) { ast_node(ce, CallExpr, es->expr); if (ce->proc->kind == Ast_BasicDirective) { - mpmc_enqueue(&curr_file->delayed_decls_queues[AstDelayQueue_Expr], es->expr); + array_add(&curr_file->delayed_decls_queues[AstDelayQueue_Expr], es->expr); } } case_end; @@ -4662,7 +4756,7 @@ bool collect_file_decl(CheckerContext *ctx, Ast *decl) { return false; } -bool collect_file_decls(CheckerContext *ctx, Slice const &decls) { +gb_internal bool collect_file_decls(CheckerContext *ctx, Slice const &decls) { GB_ASSERT(ctx->scope->flags&ScopeFlag_File); for_array(i, decls) { @@ -4675,7 +4769,7 @@ bool collect_file_decls(CheckerContext *ctx, Slice const &decls) { return false; } -GB_COMPARE_PROC(sort_file_by_name) { +gb_internal GB_COMPARE_PROC(sort_file_by_name) { AstFile const *x = *cast(AstFile const **)a; AstFile const *y = *cast(AstFile const **)b; String x_name = filename_from_path(x->fullpath); @@ -4683,13 +4777,13 @@ GB_COMPARE_PROC(sort_file_by_name) { return string_compare(x_name, y_name); } -void check_create_file_scopes(Checker *c) { +gb_internal void check_create_file_scopes(Checker *c) { for_array(i, c->parser->packages) { AstPackage *pkg = c->parser->packages[i]; - isize total_pkg_decl_count = 0; gb_sort_array(pkg->files.data, pkg->files.count, sort_file_by_name); + isize total_pkg_decl_count = 0; for_array(j, pkg->files) { AstFile *f = pkg->files[j]; string_map_set(&c->info.files, f->fullpath, f); @@ -4698,92 +4792,55 @@ void check_create_file_scopes(Checker *c) { total_pkg_decl_count += f->total_file_decl_count; } - mpmc_init(&pkg->exported_entity_queue, heap_allocator(), total_pkg_decl_count); + mpmc_init(&pkg->exported_entity_queue, total_pkg_decl_count); } } -struct ThreadProcCheckerSection { - Checker *checker; - isize offset; - isize count; +struct CollectEntityWorkerData { + Checker *c; + CheckerContext ctx; + UntypedExprInfoMap untyped; }; +gb_global CollectEntityWorkerData *collect_entity_worker_data; -void check_with_workers(Checker *c, WorkerTaskProc *proc, isize total_count) { - isize thread_count = gb_max(build_context.thread_count, 1); - isize worker_count = thread_count-1; // NOTE(bill): The main thread will also be used for work - if (!build_context.threaded_checker) { - worker_count = 0; - } +gb_internal WORKER_TASK_PROC(check_collect_entities_all_worker_proc) { + CollectEntityWorkerData *wd = &collect_entity_worker_data[current_thread_index()]; - semaphore_post(&c->info.collect_semaphore, cast(i32)thread_count); - if (worker_count == 0) { - ThreadProcCheckerSection section_all = {}; - section_all.checker = c; - section_all.offset = 0; - section_all.count = total_count; - proc(§ion_all); - return; - } + Checker *c = wd->c; + CheckerContext *ctx = &wd->ctx; + UntypedExprInfoMap *untyped = &wd->untyped; - isize file_load_count = (total_count+thread_count-1)/thread_count; - isize remaining_count = total_count; + AstFile *f = cast(AstFile *)data; + reset_checker_context(ctx, f, untyped); - ThreadProcCheckerSection *thread_data = gb_alloc_array(permanent_allocator(), ThreadProcCheckerSection, thread_count); - for (isize i = 0; i < thread_count; i++) { - ThreadProcCheckerSection *data = thread_data + i; - data->checker = c; - data->offset = total_count-remaining_count; - data->count = file_load_count; - remaining_count -= file_load_count; - } - GB_ASSERT(remaining_count <= 0); + check_collect_entities(ctx, f->decls); + GB_ASSERT(ctx->collect_delayed_decls == false); + add_untyped_expressions(&c->info, ctx->untyped); - for (isize i = 0; i < thread_count; i++) { - global_thread_pool_add_task(proc, thread_data+i); - } - global_thread_pool_wait(); - semaphore_wait(&c->info.collect_semaphore); -} - - -WORKER_TASK_PROC(thread_proc_collect_entities) { - auto *cs = cast(ThreadProcCheckerSection *)data; - Checker *c = cs->checker; - CheckerContext collect_entity_ctx = make_checker_context(c); - defer (destroy_checker_context(&collect_entity_ctx)); - - CheckerContext *ctx = &collect_entity_ctx; - - UntypedExprInfoMap untyped = {}; - map_init(&untyped, heap_allocator()); - - isize offset = cs->offset; - isize file_end = gb_min(offset+cs->count, c->info.files.entries.count); - - for (isize i = offset; i < file_end; i++) { - AstFile *f = c->info.files.entries[i].value; - reset_checker_context(ctx, f, &untyped); - - check_collect_entities(ctx, f->decls); - GB_ASSERT(ctx->collect_delayed_decls == false); - - add_untyped_expressions(&c->info, ctx->untyped); - } - - map_destroy(&untyped); - - semaphore_release(&c->info.collect_semaphore); return 0; } +gb_internal void check_collect_entities_all(Checker *c) { + isize thread_count = global_thread_pool.threads.count; -void check_collect_entities_all(Checker *c) { - check_with_workers(c, thread_proc_collect_entities, c->info.files.entries.count); + collect_entity_worker_data = gb_alloc_array(permanent_allocator(), CollectEntityWorkerData, thread_count); + for (isize i = 0; i < thread_count; i++) { + auto *wd = &collect_entity_worker_data[i]; + wd->c = c; + wd->ctx = make_checker_context(c); + map_init(&wd->untyped); + } + + for (auto const &entry : c->info.files) { + AstFile *f = entry.value; + thread_pool_add_task(check_collect_entities_all_worker_proc, f); + } + thread_pool_wait(); } -void check_export_entities_in_pkg(CheckerContext *ctx, AstPackage *pkg, UntypedExprInfoMap *untyped) { +gb_internal void check_export_entities_in_pkg(CheckerContext *ctx, AstPackage *pkg, UntypedExprInfoMap *untyped) { if (pkg->files.count != 0) { AstPackageExportedEntity item = {}; while (mpmc_dequeue(&pkg->exported_entity_queue, &item)) { @@ -4797,33 +4854,33 @@ void check_export_entities_in_pkg(CheckerContext *ctx, AstPackage *pkg, UntypedE } } -WORKER_TASK_PROC(thread_proc_check_export_entities) { - auto cs = cast(ThreadProcCheckerSection *)data; - Checker *c = cs->checker; - - CheckerContext ctx = make_checker_context(c); - defer (destroy_checker_context(&ctx)); - - UntypedExprInfoMap untyped = {}; - map_init(&untyped, heap_allocator()); - - isize end = gb_min(cs->offset + cs->count, c->info.packages.entries.count); - for (isize i = cs->offset; i < end; i++) { - AstPackage *pkg = c->info.packages.entries[i].value; - check_export_entities_in_pkg(&ctx, pkg, &untyped); - } - - map_destroy(&untyped); - - semaphore_release(&c->info.collect_semaphore); +gb_internal WORKER_TASK_PROC(check_export_entities_worker_proc) { + AstPackage *pkg = (AstPackage *)data; + auto *wd = &collect_entity_worker_data[current_thread_index()]; + check_export_entities_in_pkg(&wd->ctx, pkg, &wd->untyped); return 0; } -void check_export_entities(Checker *c) { - check_with_workers(c, thread_proc_check_export_entities, c->info.packages.entries.count); + +gb_internal void check_export_entities(Checker *c) { + isize thread_count = global_thread_pool.threads.count; + + // NOTE(bill): reuse `collect_entity_worker_data` + + for (isize i = 0; i < thread_count; i++) { + auto *wd = &collect_entity_worker_data[i]; + map_clear(&wd->untyped); + wd->ctx = make_checker_context(c); + } + + for (auto const &entry : c->info.packages) { + AstPackage *pkg = entry.value; + thread_pool_add_task(check_export_entities_worker_proc, pkg); + } + thread_pool_wait(); } -void check_import_entities(Checker *c) { +gb_internal void check_import_entities(Checker *c) { Array dep_graph = generate_import_dependency_graph(c); defer ({ for_array(i, dep_graph) { @@ -4838,7 +4895,6 @@ void check_import_entities(Checker *c) { auto pq = priority_queue_create(dep_graph, import_graph_node_cmp, import_graph_node_swap); PtrSet emitted = {}; - ptr_set_init(&emitted, heap_allocator()); defer (ptr_set_destroy(&emitted)); Array package_order = {}; @@ -4852,7 +4908,6 @@ void check_import_entities(Checker *c) { if (n->dep_count > 0) { PtrSet visited = {}; - ptr_set_init(&visited, heap_allocator()); defer (ptr_set_destroy(&visited)); auto path = find_import_path(c, pkg, pkg, &visited); @@ -4871,8 +4926,7 @@ void check_import_entities(Checker *c) { } } - for_array(i, n->pred.entries) { - ImportGraphNode *p = n->pred.entries[i].ptr; + for (ImportGraphNode *p : n->pred) { p->dep_count = gb_max(p->dep_count-1, 0); priority_queue_fix(&pq, p->index); } @@ -4891,7 +4945,6 @@ void check_import_entities(Checker *c) { CheckerContext ctx = make_checker_context(c); UntypedExprInfoMap untyped = {}; - map_init(&untyped, heap_allocator()); defer (map_destroy(&untyped)); isize min_pkg_index = 0; @@ -4907,9 +4960,10 @@ void check_import_entities(Checker *c) { ctx.collect_delayed_decls = true; // Check import declarations first to simplify things - for (Ast *id = nullptr; mpmc_dequeue(&f->delayed_decls_queues[AstDelayQueue_Import], &id); /**/) { - check_add_import_decl(&ctx, id); + for (Ast *decl : f->delayed_decls_queues[AstDelayQueue_Import]) { + check_add_import_decl(&ctx, decl); } + array_clear(&f->delayed_decls_queues[AstDelayQueue_Import]); if (collect_file_decls(&ctx, f->decls)) { check_export_entities_in_pkg(&ctx, pkg, &untyped); @@ -4935,10 +4989,10 @@ void check_import_entities(Checker *c) { AstFile *f = pkg->files[i]; reset_checker_context(&ctx, f, &untyped); - auto *q = &f->delayed_decls_queues[AstDelayQueue_Import]; - for (Ast *decl = nullptr; mpmc_dequeue(q, &decl); /**/) { + for (Ast *decl : f->delayed_decls_queues[AstDelayQueue_Import]) { check_add_import_decl(&ctx, decl); } + array_clear(&f->delayed_decls_queues[AstDelayQueue_Import]); add_untyped_expressions(ctx.info, &untyped); } @@ -4954,20 +5008,21 @@ void check_import_entities(Checker *c) { AstFile *f = pkg->files[i]; reset_checker_context(&ctx, f, &untyped); - auto *q = &f->delayed_decls_queues[AstDelayQueue_Expr]; - for (Ast *expr = nullptr; mpmc_dequeue(q, &expr); /**/) { + for (Ast *expr : f->delayed_decls_queues[AstDelayQueue_Expr]) { Operand o = {}; check_expr(&ctx, &o, expr); } + array_clear(&f->delayed_decls_queues[AstDelayQueue_Expr]); + add_untyped_expressions(ctx.info, &untyped); } } } -Array find_entity_path(Entity *start, Entity *end, PtrSet *visited = nullptr); +gb_internal Array find_entity_path(Entity *start, Entity *end, PtrSet *visited = nullptr); -bool find_entity_path_tuple(Type *tuple, Entity *end, PtrSet *visited, Array *path_) { +gb_internal bool find_entity_path_tuple(Type *tuple, Entity *end, PtrSet *visited, Array *path_) { GB_ASSERT(path_ != nullptr); if (tuple == nullptr) { return false; @@ -4979,8 +5034,7 @@ bool find_entity_path_tuple(Type *tuple, Entity *end, PtrSet *visited, if (var_decl == nullptr) { continue; } - for_array(i, var_decl->deps.entries) { - Entity *dep = var_decl->deps.entries[i].ptr; + for (Entity *dep : var_decl->deps) { if (dep == end) { auto path = array_make(heap_allocator()); array_add(&path, dep); @@ -4999,12 +5053,11 @@ bool find_entity_path_tuple(Type *tuple, Entity *end, PtrSet *visited, return false; } -Array find_entity_path(Entity *start, Entity *end, PtrSet *visited) { +gb_internal Array find_entity_path(Entity *start, Entity *end, PtrSet *visited) { PtrSet visited_ = {}; bool made_visited = false; if (visited == nullptr) { made_visited = true; - ptr_set_init(&visited_, heap_allocator()); visited = &visited_; } defer (if (made_visited) { @@ -5013,10 +5066,9 @@ Array find_entity_path(Entity *start, Entity *end, PtrSet *v Array empty_path = {}; - if (ptr_set_exists(visited, start)) { + if (ptr_set_update(visited, start)) { return empty_path; } - ptr_set_add(visited, start); DeclInfo *decl = start->decl_info; if (decl) { @@ -5032,8 +5084,7 @@ Array find_entity_path(Entity *start, Entity *end, PtrSet *v return path; } } else { - for_array(i, decl->deps.entries) { - Entity *dep = decl->deps.entries[i].ptr; + for (Entity *dep : decl->deps) { if (dep == end) { auto path = array_make(heap_allocator()); array_add(&path, dep); @@ -5051,7 +5102,7 @@ Array find_entity_path(Entity *start, Entity *end, PtrSet *v } -void calculate_global_init_order(Checker *c) { +gb_internal void calculate_global_init_order(Checker *c) { CheckerInfo *info = &c->info; TIME_SECTION("calculate_global_init_order: generate entity dependency graph"); @@ -5068,7 +5119,6 @@ void calculate_global_init_order(Checker *c) { auto pq = priority_queue_create(dep_graph, entity_graph_node_cmp, entity_graph_node_swap); PtrSet emitted = {}; - ptr_set_init(&emitted, heap_allocator()); defer (ptr_set_destroy(&emitted)); TIME_SECTION("calculate_global_init_order: queue sort"); @@ -5091,8 +5141,7 @@ void calculate_global_init_order(Checker *c) { } } - for_array(i, n->pred.entries) { - EntityGraphNode *p = n->pred.entries[i].ptr; + for (EntityGraphNode *p : n->pred) { p->dep_count -= 1; p->dep_count = gb_max(p->dep_count, 0); priority_queue_fix(&pq, p->index); @@ -5126,27 +5175,36 @@ void calculate_global_init_order(Checker *c) { } -bool check_proc_info(Checker *c, ProcInfo *pi, UntypedExprInfoMap *untyped, ProcBodyQueue *procs_to_check_queue) { +gb_internal bool check_proc_info(Checker *c, ProcInfo *pi, UntypedExprInfoMap *untyped) { if (pi == nullptr) { return false; } if (pi->type == nullptr) { return false; } + + if (!mutex_try_lock(&pi->decl->proc_checked_mutex)) { + return false; + } + defer (mutex_unlock(&pi->decl->proc_checked_mutex)); + Entity *e = pi->decl->entity; - if (pi->decl->proc_checked) { + switch (pi->decl->proc_checked_state.load()) { + case ProcCheckedState_InProgress: + if (e) { + GB_ASSERT(global_procedure_body_in_worker_queue.load()); + } + return false; + case ProcCheckedState_Checked: if (e != nullptr) { GB_ASSERT(e->flags & EntityFlag_ProcBodyChecked); } return true; + case ProcCheckedState_Unchecked: + // okay + break; } - - CheckerContext ctx = make_checker_context(c); - defer (destroy_checker_context(&ctx)); - reset_checker_context(&ctx, pi->file, untyped); - ctx.decl = pi->decl; - ctx.procs_to_check_queue = procs_to_check_queue; - GB_ASSERT(procs_to_check_queue != nullptr); + pi->decl->proc_checked_state.store(ProcCheckedState_InProgress); GB_ASSERT(pi->type->kind == Type_Proc); TypeProc *pt = &pi->type->Proc; @@ -5158,16 +5216,26 @@ bool check_proc_info(Checker *c, ProcInfo *pi, UntypedExprInfoMap *untyped, Proc token = ast_token(pi->poly_def_node); } error(token, "Unspecialized polymorphic procedure '%.*s'", LIT(name)); + pi->decl->proc_checked_state.store(ProcCheckedState_Unchecked); return false; } if (pt->is_polymorphic && pt->is_poly_specialized) { + Entity *e = pi->decl->entity; + GB_ASSERT(e != nullptr); if ((e->flags & EntityFlag_Used) == 0) { // NOTE(bill, 2019-08-31): It was never used, don't check + // NOTE(bill, 2023-01-02): This may need to be checked again if it is used elsewhere? + pi->decl->proc_checked_state.store(ProcCheckedState_Unchecked); return false; } } + CheckerContext ctx = make_checker_context(c); + defer (destroy_checker_context(&ctx)); + reset_checker_context(&ctx, pi->file, untyped); + ctx.decl = pi->decl; + bool bounds_check = (pi->tags & ProcTag_bounds_check) != 0; bool no_bounds_check = (pi->tags & ProcTag_no_bounds_check) != 0; @@ -5190,35 +5258,50 @@ bool check_proc_info(Checker *c, ProcInfo *pi, UntypedExprInfoMap *untyped, Proc ctx.state_flags &= ~StateFlag_type_assert; } - if (pi->body != nullptr && e != nullptr) { - GB_ASSERT((e->flags & EntityFlag_ProcBodyChecked) == 0); + bool body_was_checked = check_proc_body(&ctx, pi->token, pi->decl, pi->type, pi->body); + + if (body_was_checked) { + pi->decl->proc_checked_state.store(ProcCheckedState_Checked); + if (pi->body) { + Entity *e = pi->decl->entity; + if (e != nullptr) { + e->flags |= EntityFlag_ProcBodyChecked; + } + } + } else { + pi->decl->proc_checked_state.store(ProcCheckedState_Unchecked); + if (pi->body) { + Entity *e = pi->decl->entity; + if (e != nullptr) { + e->flags &= ~EntityFlag_ProcBodyChecked; + } + } } - check_proc_body(&ctx, pi->token, pi->decl, pi->type, pi->body); - if (e != nullptr) { - e->flags |= EntityFlag_ProcBodyChecked; - } - pi->decl->proc_checked = true; add_untyped_expressions(&c->info, ctx.untyped); + return true; } GB_STATIC_ASSERT(sizeof(isize) == sizeof(void *)); -bool consume_proc_info_queue(Checker *c, ProcInfo *pi, ProcBodyQueue *q, UntypedExprInfoMap *untyped); +gb_internal bool consume_proc_info(Checker *c, ProcInfo *pi, UntypedExprInfoMap *untyped); -void check_unchecked_bodies(Checker *c) { +gb_internal void check_unchecked_bodies(Checker *c) { // NOTE(2021-02-26, bill): Sanity checker // This is a partial hack to make sure all procedure bodies have been checked // even ones which should not exist, due to the multithreaded nature of the parser // HACK TODO(2021-02-26, bill): Actually fix this race condition + GB_ASSERT(c->procs_to_check.count == 0); + UntypedExprInfoMap untyped = {}; - map_init(&untyped, heap_allocator()); defer (map_destroy(&untyped)); - for_array(i, c->info.minimum_dependency_set.entries) { - Entity *e = c->info.minimum_dependency_set.entries[i].ptr; + // use the `procs_to_check` array + global_procedure_body_in_worker_queue = false; + + for (Entity *e : c->info.minimum_dependency_set) { if (e == nullptr || e->kind != Entity_Procedure) { continue; } @@ -5241,25 +5324,50 @@ void check_unchecked_bodies(Checker *c) { if (pi->body == nullptr) { continue; } - - debugf("unchecked: %.*s\n", LIT(e->token.string)); - mpmc_enqueue(&c->procs_to_check_queue, pi); + check_procedure_later(c, pi); } } - auto *q = &c->procs_to_check_queue; - ProcInfo *pi = nullptr; - while (mpmc_dequeue(q, &pi)) { - Entity *e = pi->decl->entity; - if (consume_proc_info_queue(c, pi, q, &untyped)) { - add_dependency_to_set(c, e); - GB_ASSERT(e->flags & EntityFlag_ProcBodyChecked); + if (!global_procedure_body_in_worker_queue) { + for_array(i, c->procs_to_check) { + ProcInfo *pi = c->procs_to_check[i]; + consume_proc_info(c, pi, &untyped); } + array_clear(&c->procs_to_check); + } else { + thread_pool_wait(); } + global_procedure_body_in_worker_queue = false; + global_after_checking_procedure_bodies = true; } -void check_test_procedures(Checker *c) { +gb_internal void check_safety_all_procedures_for_unchecked(Checker *c) { + GB_ASSERT(DEBUG_CHECK_ALL_PROCEDURES); + UntypedExprInfoMap untyped = {}; + defer (map_destroy(&untyped)); + + + for_array(i, c->info.all_procedures) { + ProcInfo *pi = c->info.all_procedures[i]; + GB_ASSERT(pi != nullptr); + GB_ASSERT(pi->decl != nullptr); + Entity *e = pi->decl->entity; + auto proc_checked_state = pi->decl->proc_checked_state.load(); + gb_unused(proc_checked_state); + if (e && ((e->flags & EntityFlag_ProcBodyChecked) == 0)) { + if ((e->flags & EntityFlag_Used) != 0) { + // debugf("%.*s :: %s\n", LIT(e->token.string), type_to_string(e->type)); + // debugf("proc body unchecked\n"); + // debugf("Checked State: %s\n\n", ProcCheckedState_strings[proc_checked_state]); + + consume_proc_info(c, pi, &untyped); + } + } + } +} + +gb_internal void check_test_procedures(Checker *c) { if (build_context.test_names.entries.count == 0) { return; } @@ -5267,8 +5375,7 @@ void check_test_procedures(Checker *c) { AstPackage *pkg = c->info.init_package; Scope *s = pkg->scope; - for_array(i, build_context.test_names.entries) { - String name = build_context.test_names.entries[i].value; + for (String const &name : build_context.test_names) { Entity *e = scope_lookup(s, name); if (e == nullptr) { Token tok = {}; @@ -5294,7 +5401,49 @@ void check_test_procedures(Checker *c) { gb_global std::atomic total_bodies_checked; -bool consume_proc_info_queue(Checker *c, ProcInfo *pi, ProcBodyQueue *q, UntypedExprInfoMap *untyped) { +gb_internal bool consume_proc_info(Checker *c, ProcInfo *pi, UntypedExprInfoMap *untyped) { + GB_ASSERT(pi->decl != nullptr); + switch (pi->decl->proc_checked_state.load()) { + case ProcCheckedState_InProgress: + return false; + case ProcCheckedState_Checked: + return true; + } + + if (pi->decl->parent && pi->decl->parent->entity) { + Entity *parent = pi->decl->parent->entity; + // NOTE(bill): Only check a nested procedure if its parent's body has been checked first + // This is prevent any possible race conditions in evaluation when multithreaded + // NOTE(bill): In single threaded mode, this should never happen + if (parent->kind == Entity_Procedure && (parent->flags & EntityFlag_ProcBodyChecked) == 0) { + check_procedure_later(c, pi); + return false; + } + } + if (untyped) { + map_clear(untyped); + } + if (check_proc_info(c, pi, untyped)) { + total_bodies_checked.fetch_add(1, std::memory_order_relaxed); + return true; + } + return false; +} + +struct CheckProcedureBodyWorkerData { + Checker *c; + UntypedExprInfoMap untyped; +}; + +gb_global CheckProcedureBodyWorkerData *check_procedure_bodies_worker_data; + +gb_internal WORKER_TASK_PROC(check_proc_info_worker_proc) { + auto *wd = &check_procedure_bodies_worker_data[current_thread_index()]; + UntypedExprInfoMap *untyped = &wd->untyped; + Checker *c = wd->c; + + ProcInfo *pi = cast(ProcInfo *)data; + GB_ASSERT(pi->decl != nullptr); if (pi->decl->parent && pi->decl->parent->entity) { Entity *parent = pi->decl->parent->entity; @@ -5302,65 +5451,43 @@ bool consume_proc_info_queue(Checker *c, ProcInfo *pi, ProcBodyQueue *q, Untyped // This is prevent any possible race conditions in evaluation when multithreaded // NOTE(bill): In single threaded mode, this should never happen if (parent->kind == Entity_Procedure && (parent->flags & EntityFlag_ProcBodyChecked) == 0) { - mpmc_enqueue(q, pi); - return false; + thread_pool_add_task(check_proc_info_worker_proc, pi); + return 1; } } - if (untyped) { - map_clear(untyped); + map_clear(untyped); + if (check_proc_info(c, pi, untyped)) { + total_bodies_checked.fetch_add(1, std::memory_order_relaxed); + return 0; } - bool ok = check_proc_info(c, pi, untyped, q); - total_bodies_checked.fetch_add(1, std::memory_order_relaxed); - return ok; + return 1; } -struct ThreadProcBodyData { - Checker *checker; - ProcBodyQueue *queue; - u32 thread_index; - u32 thread_count; - ThreadProcBodyData *all_data; -}; +gb_internal void check_init_worker_data(Checker *c) { + u32 thread_count = cast(u32)global_thread_pool.threads.count; -WORKER_TASK_PROC(thread_proc_body) { - ThreadProcBodyData *bd = cast(ThreadProcBodyData *)data; - Checker *c = bd->checker; - GB_ASSERT(c != nullptr); - ProcBodyQueue *this_queue = bd->queue; + check_procedure_bodies_worker_data = gb_alloc_array(permanent_allocator(), CheckProcedureBodyWorkerData, thread_count); - UntypedExprInfoMap untyped = {}; - map_init(&untyped, heap_allocator()); - - for (ProcInfo *pi; mpmc_dequeue(this_queue, &pi); /**/) { - consume_proc_info_queue(c, pi, this_queue, &untyped); + for (isize i = 0; i < thread_count; i++) { + check_procedure_bodies_worker_data[i].c = c; + map_init(&check_procedure_bodies_worker_data[i].untyped); } - - map_destroy(&untyped); - - semaphore_release(&c->procs_to_check_semaphore); - - return 0; } -void check_procedure_bodies(Checker *c) { +gb_internal void check_procedure_bodies(Checker *c) { GB_ASSERT(c != nullptr); - u32 thread_count = cast(u32)gb_max(build_context.thread_count, 1); - u32 worker_count = thread_count-1; // NOTE(bill): The main thread will also be used for work - if (!build_context.threaded_checker) { - worker_count = 0; + u32 thread_count = cast(u32)global_thread_pool.threads.count; + if (build_context.no_threaded_checker) { + thread_count = 1; } - if (worker_count == 0) { - auto *this_queue = &c->procs_to_check_queue; - UntypedExprInfoMap untyped = {}; - map_init(&untyped, heap_allocator()); - - for (ProcInfo *pi = nullptr; mpmc_dequeue(this_queue, &pi); /**/) { - consume_proc_info_queue(c, pi, this_queue, &untyped); + if (thread_count == 1) { + UntypedExprInfoMap *untyped = &check_procedure_bodies_worker_data[0].untyped; + for_array(i, c->procs_to_check) { + consume_proc_info(c, c->procs_to_check[i], untyped); } - - map_destroy(&untyped); + array_clear(&c->procs_to_check); debugf("Total Procedure Bodies Checked: %td\n", total_bodies_checked.load(std::memory_order_relaxed)); return; @@ -5368,72 +5495,53 @@ void check_procedure_bodies(Checker *c) { global_procedure_body_in_worker_queue = true; - isize original_queue_count = c->procs_to_check_queue.count.load(std::memory_order_relaxed); - isize load_count = (original_queue_count+thread_count-1)/thread_count; - - ThreadProcBodyData *thread_data = gb_alloc_array(permanent_allocator(), ThreadProcBodyData, thread_count); - for (u32 i = 0; i < thread_count; i++) { - ThreadProcBodyData *data = thread_data + i; - data->checker = c; - data->queue = gb_alloc_item(permanent_allocator(), ProcBodyQueue); - data->thread_index = i; - data->thread_count = thread_count; - data->all_data = thread_data; - // NOTE(bill) 2x the amount assumes on average only 1 nested procedure - // TODO(bill): Determine a good heuristic - mpmc_init(data->queue, heap_allocator(), next_pow2_isize(load_count*2)); + isize prev_procs_to_check_count = c->procs_to_check.count; + for_array(i, c->procs_to_check) { + thread_pool_add_task(check_proc_info_worker_proc, c->procs_to_check[i]); } + GB_ASSERT(prev_procs_to_check_count == c->procs_to_check.count); + array_clear(&c->procs_to_check); - // Distibute the work load into multiple queues - for (isize j = 0; j < load_count; j++) { - for (isize i = 0; i < thread_count; i++) { - ProcBodyQueue *queue = thread_data[i].queue; - ProcInfo *pi = nullptr; - if (!mpmc_dequeue(&c->procs_to_check_queue, &pi)) { - break; - } - mpmc_enqueue(queue, pi); - } - } - isize total_queued = 0; - for (isize i = 0; i < thread_count; i++) { - ProcBodyQueue *queue = thread_data[i].queue; - total_queued += queue->count.load(); - } - GB_ASSERT(total_queued == original_queue_count); - - semaphore_post(&c->procs_to_check_semaphore, cast(i32)thread_count); - - for (isize i = 0; i < thread_count; i++) { - global_thread_pool_add_task(thread_proc_body, thread_data+i); - } - global_thread_pool_wait(); - semaphore_wait(&c->procs_to_check_semaphore); - - isize global_remaining = c->procs_to_check_queue.count.load(std::memory_order_relaxed); - GB_ASSERT(global_remaining == 0); - - debugf("Total Procedure Bodies Checked: %td\n", total_bodies_checked.load(std::memory_order_relaxed)); - + thread_pool_wait(); global_procedure_body_in_worker_queue = false; } -void add_untyped_expressions(CheckerInfo *cinfo, UntypedExprInfoMap *untyped) { +gb_internal void add_untyped_expressions(CheckerInfo *cinfo, UntypedExprInfoMap *untyped) { if (untyped == nullptr) { return; } - for_array(i, untyped->entries) { - Ast *expr = untyped->entries[i].key; - ExprInfo *info = untyped->entries[i].value; + for (auto const &entry : *untyped) { + Ast *expr = entry.key; + ExprInfo *info = entry.value; if (expr != nullptr && info != nullptr) { - mpmc_enqueue(&cinfo->checker->global_untyped_queue, UntypedExprInfo{expr, info}); + mpsc_enqueue(&cinfo->checker->global_untyped_queue, UntypedExprInfo{expr, info}); } } map_clear(untyped); } -void check_deferred_procedures(Checker *c) { - for (Entity *src = nullptr; mpmc_dequeue(&c->procs_with_deferred_to_check, &src); /**/) { +gb_internal Type *tuple_to_pointers(Type *ot) { + if (ot == nullptr) { + return nullptr; + } + GB_ASSERT(ot->kind == Type_Tuple); + + + Type *t = alloc_type_tuple(); + t->Tuple.variables = slice_make(heap_allocator(), ot->Tuple.variables.count); + + Scope *scope = nullptr; + for_array(i, t->Tuple.variables) { + Entity *e = ot->Tuple.variables[i]; + t->Tuple.variables[i] = alloc_entity_variable(scope, e->token, alloc_type_pointer(e->type)); + } + t->Tuple.is_packed = ot->Tuple.is_packed; + + return t; +} + +gb_internal void check_deferred_procedures(Checker *c) { + for (Entity *src = nullptr; mpsc_dequeue(&c->procs_with_deferred_to_check, &src); /**/) { GB_ASSERT(src->kind == Entity_Procedure); DeferredProcedureKind dst_kind = src->Procedure.deferred_procedure.kind; @@ -5443,18 +5551,13 @@ void check_deferred_procedures(Checker *c) { char const *attribute = "deferred_none"; switch (dst_kind) { - case DeferredProcedure_none: - attribute = "deferred_none"; - break; - case DeferredProcedure_in: - attribute = "deferred_in"; - break; - case DeferredProcedure_out: - attribute = "deferred_out"; - break; - case DeferredProcedure_in_out: - attribute = "deferred_in_out"; - break; + case DeferredProcedure_none: attribute = "deferred_none"; break; + case DeferredProcedure_in: attribute = "deferred_in"; break; + case DeferredProcedure_out: attribute = "deferred_out"; break; + case DeferredProcedure_in_out: attribute = "deferred_in_out"; break; + case DeferredProcedure_in_by_ptr: attribute = "deferred_in_by_ptr"; break; + case DeferredProcedure_out_by_ptr: attribute = "deferred_out_by_ptr"; break; + case DeferredProcedure_in_out_by_ptr: attribute = "deferred_in_out_by_ptr"; break; } if (is_type_polymorphic(src->type) || is_type_polymorphic(dst->type)) { @@ -5468,130 +5571,158 @@ void check_deferred_procedures(Checker *c) { Type *src_results = base_type(src->type)->Proc.results; Type *dst_params = base_type(dst->type)->Proc.params; - if (dst_kind == DeferredProcedure_none) { - if (dst_params == nullptr) { - // Okay - continue; - } + bool by_ptr = false; + switch (dst_kind) { + case DeferredProcedure_in_by_ptr: + by_ptr = true; + src_params = tuple_to_pointers(src_params); + break; + case DeferredProcedure_out_by_ptr: + by_ptr = true; + src_results = tuple_to_pointers(src_results); + break; + case DeferredProcedure_in_out_by_ptr: + by_ptr = true; + src_params = tuple_to_pointers(src_params); + src_results = tuple_to_pointers(src_results); + break; + } - error(src->token, "Deferred procedure '%.*s' must have no input parameters", LIT(dst->token.string)); - } else if (dst_kind == DeferredProcedure_in) { - if (src_params == nullptr && dst_params == nullptr) { - // Okay - continue; - } - if ((src_params == nullptr && dst_params != nullptr) || - (src_params != nullptr && dst_params == nullptr)) { - error(src->token, "Deferred procedure '%.*s' parameters do not match the inputs of initial procedure '%.*s'", LIT(src->token.string), LIT(dst->token.string)); - continue; - } + switch (dst_kind) { + case DeferredProcedure_none: + { + if (dst_params == nullptr) { + // Okay + continue; + } - GB_ASSERT(src_params->kind == Type_Tuple); - GB_ASSERT(dst_params->kind == Type_Tuple); + error(src->token, "Deferred procedure '%.*s' must have no input parameters", LIT(dst->token.string)); + } break; + case DeferredProcedure_in: + case DeferredProcedure_in_by_ptr: + { + if (src_params == nullptr && dst_params == nullptr) { + // Okay + continue; + } + if ((src_params == nullptr && dst_params != nullptr) || + (src_params != nullptr && dst_params == nullptr)) { + error(src->token, "Deferred procedure '%.*s' parameters do not match the inputs of initial procedure '%.*s'", LIT(src->token.string), LIT(dst->token.string)); + continue; + } - if (are_types_identical(src_params, dst_params)) { - // Okay! - } else { - gbString s = type_to_string(src_params); - gbString d = type_to_string(dst_params); - error(src->token, "Deferred procedure '%.*s' parameters do not match the inputs of initial procedure '%.*s':\n\t(%s) =/= (%s)", - LIT(src->token.string), LIT(dst->token.string), - s, d - ); - gb_string_free(d); - gb_string_free(s); - continue; - } - - } else if (dst_kind == DeferredProcedure_out) { - if (src_results == nullptr && dst_params == nullptr) { - // Okay - continue; - } - if ((src_results == nullptr && dst_params != nullptr) || - (src_results != nullptr && dst_params == nullptr)) { - error(src->token, "Deferred procedure '%.*s' parameters do not match the results of initial procedure '%.*s'", LIT(src->token.string), LIT(dst->token.string)); - continue; - } - - GB_ASSERT(src_results->kind == Type_Tuple); - GB_ASSERT(dst_params->kind == Type_Tuple); - - if (are_types_identical(src_results, dst_params)) { - // Okay! - } else { - gbString s = type_to_string(src_results); - gbString d = type_to_string(dst_params); - error(src->token, "Deferred procedure '%.*s' parameters do not match the results of initial procedure '%.*s':\n\t(%s) =/= (%s)", - LIT(src->token.string), LIT(dst->token.string), - s, d - ); - gb_string_free(d); - gb_string_free(s); - continue; - } - } else if (dst_kind == DeferredProcedure_in_out) { - if (src_params == nullptr && src_results == nullptr && dst_params == nullptr) { - // Okay - continue; - } - - GB_ASSERT(dst_params->kind == Type_Tuple); - - Type *tsrc = alloc_type_tuple(); - auto &sv = tsrc->Tuple.variables; - auto const &dv = dst_params->Tuple.variables; - gb_unused(dv); - - isize len = 0; - if (src_params != nullptr) { GB_ASSERT(src_params->kind == Type_Tuple); - len += src_params->Tuple.variables.count; - } - if (src_results != nullptr) { + GB_ASSERT(dst_params->kind == Type_Tuple); + + if (are_types_identical(src_params, dst_params)) { + // Okay! + } else { + gbString s = type_to_string(src_params); + gbString d = type_to_string(dst_params); + error(src->token, "Deferred procedure '%.*s' parameters do not match the inputs of initial procedure '%.*s':\n\t(%s) =/= (%s)", + LIT(src->token.string), LIT(dst->token.string), + s, d + ); + gb_string_free(d); + gb_string_free(s); + continue; + } + } break; + case DeferredProcedure_out: + case DeferredProcedure_out_by_ptr: + { + if (src_results == nullptr && dst_params == nullptr) { + // Okay + continue; + } + if ((src_results == nullptr && dst_params != nullptr) || + (src_results != nullptr && dst_params == nullptr)) { + error(src->token, "Deferred procedure '%.*s' parameters do not match the results of initial procedure '%.*s'", LIT(src->token.string), LIT(dst->token.string)); + continue; + } + GB_ASSERT(src_results->kind == Type_Tuple); - len += src_results->Tuple.variables.count; - } - slice_init(&sv, heap_allocator(), len); - isize offset = 0; - if (src_params != nullptr) { - for_array(i, src_params->Tuple.variables) { - sv[offset++] = src_params->Tuple.variables[i]; + GB_ASSERT(dst_params->kind == Type_Tuple); + + if (are_types_identical(src_results, dst_params)) { + // Okay! + } else { + gbString s = type_to_string(src_results); + gbString d = type_to_string(dst_params); + error(src->token, "Deferred procedure '%.*s' parameters do not match the results of initial procedure '%.*s':\n\t(%s) =/= (%s)", + LIT(src->token.string), LIT(dst->token.string), + s, d + ); + gb_string_free(d); + gb_string_free(s); + continue; } - } - if (src_results != nullptr) { - for_array(i, src_results->Tuple.variables) { - sv[offset++] = src_results->Tuple.variables[i]; + } break; + case DeferredProcedure_in_out: + case DeferredProcedure_in_out_by_ptr: + { + if (src_params == nullptr && src_results == nullptr && dst_params == nullptr) { + // Okay + continue; } - } - GB_ASSERT(offset == len); + + GB_ASSERT(dst_params->kind == Type_Tuple); + + Type *tsrc = alloc_type_tuple(); + auto &sv = tsrc->Tuple.variables; + auto const &dv = dst_params->Tuple.variables; + gb_unused(dv); + + isize len = 0; + if (src_params != nullptr) { + GB_ASSERT(src_params->kind == Type_Tuple); + len += src_params->Tuple.variables.count; + } + if (src_results != nullptr) { + GB_ASSERT(src_results->kind == Type_Tuple); + len += src_results->Tuple.variables.count; + } + slice_init(&sv, heap_allocator(), len); + isize offset = 0; + if (src_params != nullptr) { + for_array(i, src_params->Tuple.variables) { + sv[offset++] = src_params->Tuple.variables[i]; + } + } + if (src_results != nullptr) { + for_array(i, src_results->Tuple.variables) { + sv[offset++] = src_results->Tuple.variables[i]; + } + } + GB_ASSERT(offset == len); - if (are_types_identical(tsrc, dst_params)) { - // Okay! - } else { - gbString s = type_to_string(tsrc); - gbString d = type_to_string(dst_params); - error(src->token, "Deferred procedure '%.*s' parameters do not match the results of initial procedure '%.*s':\n\t(%s) =/= (%s)", - LIT(src->token.string), LIT(dst->token.string), - s, d - ); - gb_string_free(d); - gb_string_free(s); - continue; - } + if (are_types_identical(tsrc, dst_params)) { + // Okay! + } else { + gbString s = type_to_string(tsrc); + gbString d = type_to_string(dst_params); + error(src->token, "Deferred procedure '%.*s' parameters do not match the results of initial procedure '%.*s':\n\t(%s) =/= (%s)", + LIT(src->token.string), LIT(dst->token.string), + s, d + ); + gb_string_free(d); + gb_string_free(s); + continue; + } + } break; } } } -void check_unique_package_names(Checker *c) { +gb_internal void check_unique_package_names(Checker *c) { StringMap pkgs = {}; // Key: package name - string_map_init(&pkgs, heap_allocator(), 2*c->info.packages.entries.count); + string_map_init(&pkgs, 2*c->info.packages.count); defer (string_map_destroy(&pkgs)); - for_array(i, c->info.packages.entries) { - AstPackage *pkg = c->info.packages.entries[i].value; + for (auto const &entry : c->info.packages) { + AstPackage *pkg = entry.value; if (pkg->files.count == 0) { continue; // Sanity check } @@ -5618,28 +5749,28 @@ void check_unique_package_names(Checker *c) { } } -void check_add_entities_from_queues(Checker *c) { +gb_internal void check_add_entities_from_queues(Checker *c) { isize cap = c->info.entities.count + c->info.entity_queue.count.load(std::memory_order_relaxed); array_reserve(&c->info.entities, cap); - for (Entity *e; mpmc_dequeue(&c->info.entity_queue, &e); /**/) { + for (Entity *e; mpsc_dequeue(&c->info.entity_queue, &e); /**/) { array_add(&c->info.entities, e); } } -void check_add_definitions_from_queues(Checker *c) { +gb_internal void check_add_definitions_from_queues(Checker *c) { isize cap = c->info.definitions.count + c->info.definition_queue.count.load(std::memory_order_relaxed); array_reserve(&c->info.definitions, cap); - for (Entity *e; mpmc_dequeue(&c->info.definition_queue, &e); /**/) { + for (Entity *e; mpsc_dequeue(&c->info.definition_queue, &e); /**/) { array_add(&c->info.definitions, e); } } -void check_merge_queues_into_arrays(Checker *c) { +gb_internal void check_merge_queues_into_arrays(Checker *c) { check_add_entities_from_queues(c); check_add_definitions_from_queues(c); } -GB_COMPARE_PROC(init_procedures_cmp) { +gb_internal GB_COMPARE_PROC(init_procedures_cmp) { int cmp = 0; Entity *x = *(Entity **)a; Entity *y = *(Entity **)b; @@ -5676,12 +5807,17 @@ GB_COMPARE_PROC(init_procedures_cmp) { return i32_cmp(x->token.pos.offset, y->token.pos.offset); } - -void check_sort_init_procedures(Checker *c) { - gb_sort_array(c->info.init_procedures.data, c->info.init_procedures.count, init_procedures_cmp); +gb_internal GB_COMPARE_PROC(fini_procedures_cmp) { + return init_procedures_cmp(b, a); } -void add_type_info_for_type_definitions(Checker *c) { + +gb_internal void check_sort_init_and_fini_procedures(Checker *c) { + gb_sort_array(c->info.init_procedures.data, c->info.init_procedures.count, init_procedures_cmp); + gb_sort_array(c->info.fini_procedures.data, c->info.fini_procedures.count, fini_procedures_cmp); +} + +gb_internal void add_type_info_for_type_definitions(Checker *c) { for_array(i, c->info.definitions) { Entity *e = c->info.definitions[i]; if (e->kind == Entity_TypeName && e->type != nullptr) { @@ -5693,7 +5829,29 @@ void add_type_info_for_type_definitions(Checker *c) { } } -void check_parsed_files(Checker *c) { +gb_internal void check_walk_all_dependencies(DeclInfo *decl) { + if (decl == nullptr) { + return; + } + for (DeclInfo *child = decl->next_child; child != nullptr; child = child->next_sibling) { + check_walk_all_dependencies(child); + } + add_deps_from_child_to_parent(decl); +} + +gb_internal void check_update_dependency_tree_for_procedures(Checker *c) { + mutex_lock(&c->nested_proc_lits_mutex); + for (DeclInfo *decl : c->nested_proc_lits) { + check_walk_all_dependencies(decl); + } + mutex_unlock(&c->nested_proc_lits_mutex); + for (Entity *e : c->info.entities) { + DeclInfo *decl = e->decl_info; + check_walk_all_dependencies(decl); + } +} + +gb_internal void check_parsed_files(Checker *c) { TIME_SECTION("map full filepaths to scope"); add_type_info_type(&c->builtin_ctx, t_invalid); @@ -5714,6 +5872,9 @@ void check_parsed_files(Checker *c) { } } + TIME_SECTION("init worker data"); + check_init_worker_data(c); + TIME_SECTION("create file scopes"); check_create_file_scopes(c); @@ -5752,22 +5913,11 @@ void check_parsed_files(Checker *c) { check_merge_queues_into_arrays(c); TIME_SECTION("check scope usage"); - for_array(i, c->info.files.entries) { - AstFile *f = c->info.files.entries[i].value; + for (auto const &entry : c->info.files) { + AstFile *f = entry.value; check_scope_usage(c, f->scope); } - TIME_SECTION("add untyped expression values"); - // Add untyped expression values - for (UntypedExprInfo u = {}; mpmc_dequeue(&c->global_untyped_queue, &u); /**/) { - GB_ASSERT(u.expr != nullptr && u.info != nullptr); - if (is_type_typed(u.info->type)) { - compiler_error("%s (type %s) is typed!", expr_to_string(u.expr), type_to_string(u.info->type)); - } - add_type_and_value(&c->info, u.expr, u.info->mode, u.info->type, u.info->value); - } - - TIME_SECTION("add basic type information"); // Add "Basic" type information for (isize i = 0; i < Basic_COUNT; i++) { @@ -5789,8 +5939,7 @@ void check_parsed_files(Checker *c) { DeclInfo *decl = e->decl_info; ast_node(pl, ProcLit, decl->proc_lit); if (pl->inlining == ProcInlining_inline) { - for_array(j, decl->deps.entries) { - Entity *dep = decl->deps.entries[j].ptr; + for (Entity *dep : decl->deps) { if (dep == e) { error(e->token, "Cannot inline recursive procedure '%.*s'", LIT(e->token.string)); break; @@ -5809,16 +5958,22 @@ void check_parsed_files(Checker *c) { TIME_SECTION("check test procedures"); check_test_procedures(c); - TIME_SECTION("check bodies have all been checked"); - check_unchecked_bodies(c); - TIME_SECTION("add type info for type definitions"); add_type_info_for_type_definitions(c); check_merge_queues_into_arrays(c); + TIME_SECTION("update dependency tree for procedures"); + check_update_dependency_tree_for_procedures(c); + TIME_SECTION("generate minimum dependency set"); generate_minimum_dependency_set(c, c->info.entry_point); + TIME_SECTION("check bodies have all been checked"); + check_unchecked_bodies(c); + + check_merge_queues_into_arrays(c); + + TIME_SECTION("check entry point"); if (build_context.build_mode == BuildMode_Executable && !build_context.no_entry_point && build_context.command_kind != Command_test) { Scope *s = c->info.init_scope; @@ -5841,21 +5996,41 @@ void check_parsed_files(Checker *c) { } } + thread_pool_wait(); + GB_ASSERT(c->procs_to_check.count == 0); + + if (DEBUG_CHECK_ALL_PROCEDURES) { + TIME_SECTION("check unchecked (safety measure)"); + check_safety_all_procedures_for_unchecked(c); + } + + debugf("Total Procedure Bodies Checked: %td\n", total_bodies_checked.load(std::memory_order_relaxed)); + TIME_SECTION("check unique package names"); check_unique_package_names(c); - TIME_SECTION("sanity checks"); + check_merge_queues_into_arrays(c); GB_ASSERT(c->info.entity_queue.count.load(std::memory_order_relaxed) == 0); GB_ASSERT(c->info.definition_queue.count.load(std::memory_order_relaxed) == 0); - TIME_SECTION("sort init procedures"); - check_sort_init_procedures(c); + TIME_SECTION("add untyped expression values"); + // Add untyped expression values + for (UntypedExprInfo u = {}; mpsc_dequeue(&c->global_untyped_queue, &u); /**/) { + GB_ASSERT(u.expr != nullptr && u.info != nullptr); + if (is_type_typed(u.info->type)) { + compiler_error("%s (type %s) is typed!", expr_to_string(u.expr), type_to_string(u.info->type)); + } + add_type_and_value(&c->builtin_ctx, u.expr, u.info->mode, u.info->type, u.info->value); + } + + TIME_SECTION("sort init and fini procedures"); + check_sort_init_and_fini_procedures(c); if (c->info.intrinsics_entry_point_usage.count > 0) { TIME_SECTION("check intrinsics.__entry_point usage"); Ast *node = nullptr; - while (mpmc_dequeue(&c->info.intrinsics_entry_point_usage, &node)) { + while (mpsc_dequeue(&c->info.intrinsics_entry_point_usage, &node)) { if (c->info.entry_point == nullptr && node != nullptr) { if (node->file()->pkg->kind != Package_Runtime) { warning(node, "usage of intrinsics.__entry_point will be a no-op"); @@ -5864,5 +6039,6 @@ void check_parsed_files(Checker *c) { } } + TIME_SECTION("type check finish"); } diff --git a/src/checker.hpp b/src/checker.hpp index 37232ea95..b06d0a8f9 100644 --- a/src/checker.hpp +++ b/src/checker.hpp @@ -20,7 +20,7 @@ struct ExprInfo { ExactValue value; }; -gb_inline ExprInfo *make_expr_info(AddressingMode mode, Type *type, ExactValue const &value, bool is_lhs) { +gb_internal gb_inline ExprInfo *make_expr_info(AddressingMode mode, Type *type, ExactValue const &value, bool is_lhs) { ExprInfo *ei = gb_alloc_item(permanent_allocator(), ExprInfo); ei->mode = mode; ei->type = type; @@ -92,6 +92,10 @@ enum DeferredProcedureKind { DeferredProcedure_in, DeferredProcedure_out, DeferredProcedure_in_out, + + DeferredProcedure_in_by_ptr, + DeferredProcedure_out_by_ptr, + DeferredProcedure_in_out_by_ptr, }; struct DeferredProcedure { DeferredProcedureKind kind; @@ -117,9 +121,11 @@ struct AttributeContext { bool disabled_proc : 1; bool test : 1; bool init : 1; + bool fini : 1; bool set_cold : 1; u32 optimization_mode; // ProcedureOptimizationMode i64 foreign_import_priority_index; + String extra_linker_flags; String objc_class; String objc_name; @@ -130,7 +136,7 @@ struct AttributeContext { String enable_target_feature; // will be enabled for the procedure only }; -AttributeContext make_attribute_context(String link_prefix) { +gb_internal gb_inline AttributeContext make_attribute_context(String link_prefix) { AttributeContext ac = {}; ac.link_prefix = link_prefix; return ac; @@ -139,12 +145,31 @@ AttributeContext make_attribute_context(String link_prefix) { #define DECL_ATTRIBUTE_PROC(_name) bool _name(CheckerContext *c, Ast *elem, String name, Ast *value, AttributeContext *ac) typedef DECL_ATTRIBUTE_PROC(DeclAttributeProc); -void check_decl_attributes(CheckerContext *c, Array const &attributes, DeclAttributeProc *proc, AttributeContext *ac); +gb_internal void check_decl_attributes(CheckerContext *c, Array const &attributes, DeclAttributeProc *proc, AttributeContext *ac); +enum ProcCheckedState : u8 { + ProcCheckedState_Unchecked, + ProcCheckedState_InProgress, + ProcCheckedState_Checked, + + ProcCheckedState_COUNT +}; + +char const *ProcCheckedState_strings[ProcCheckedState_COUNT] { + "Unchecked", + "In Progress", + "Checked", +}; + // DeclInfo is used to store information of certain declarations to allow for "any order" usage struct DeclInfo { DeclInfo * parent; // NOTE(bill): only used for procedure literals at the moment + + BlockingMutex next_mutex; + DeclInfo * next_child; + DeclInfo * next_sibling; + Scope * scope; Entity *entity; @@ -157,16 +182,26 @@ struct DeclInfo { Type * gen_proc_type; // Precalculated bool is_using; bool where_clauses_evaluated; - bool proc_checked; + std::atomic proc_checked_state; + BlockingMutex proc_checked_mutex; isize defer_used; bool defer_use_checked; CommentGroup *comment; CommentGroup *docs; - PtrSet deps; + RwMutex deps_mutex; + PtrSet deps; + + RwMutex type_info_deps_mutex; PtrSet type_info_deps; + + BlockingMutex type_and_value_mutex; + Array labels; + + // NOTE(bill): this is to prevent a race condition since these procedure literals can be created anywhere at any time + struct lbModule *code_gen_module; }; // ProcInfo stores the information needed for checking a procedure @@ -197,7 +232,7 @@ enum ScopeFlag : i32 { ScopeFlag_ContextDefined = 1<<16, }; -enum { DEFAULT_SCOPE_CAPACITY = 29 }; +enum { DEFAULT_SCOPE_CAPACITY = 32 }; struct Scope { Ast * node; @@ -205,7 +240,7 @@ struct Scope { std::atomic next; std::atomic head_child; - BlockingMutex mutex; + RwMutex mutex; StringMap elements; PtrSet imported; @@ -277,7 +312,6 @@ struct UntypedExprInfo { }; typedef PtrMap UntypedExprInfoMap; -typedef MPMCQueue ProcBodyQueue; enum ObjcMsgKind : u32 { ObjcMsg_normal, @@ -296,6 +330,16 @@ struct LoadFileCache { StringMap hashes; }; +struct GenProcsData { + Array procs; + RwMutex mutex; +}; + +struct GenTypesData { + Array types; + RwMutex mutex; +}; + // CheckerInfo stores all the symbol information for a type-checked program struct CheckerInfo { Checker *checker; @@ -310,12 +354,13 @@ struct CheckerInfo { Scope * init_scope; Entity * entry_point; PtrSet minimum_dependency_set; - PtrSet minimum_dependency_type_info_set; + PtrMap minimum_dependency_type_info_set; Array testing_procedures; Array init_procedures; + Array fini_procedures; Array definitions; Array entities; @@ -323,30 +368,17 @@ struct CheckerInfo { // Below are accessed within procedures - // NOTE(bill): If the semantic checker (check_proc_body) is to ever to be multithreaded, - // these variables will be of contention - - Semaphore collect_semaphore; - + RwMutex global_untyped_mutex; UntypedExprInfoMap global_untyped; // NOTE(bill): This needs to be a map and not on the Ast // as it needs to be iterated across afterwards - BlockingMutex global_untyped_mutex; BlockingMutex builtin_mutex; - // NOT recursive & only used at the end of `check_proc_body` - // and in `add_dependency`. - // This is a possible source of contention but probably not - // too much of a problem in practice - BlockingMutex deps_mutex; - BlockingMutex type_and_value_mutex; RecursiveMutex lazy_mutex; // Mutex required for lazy type checking of specific files - RecursiveMutex gen_procs_mutex; - RecursiveMutex gen_types_mutex; - PtrMap > gen_procs; // Key: Ast * | Identifier -> Entity - PtrMap > gen_types; + RwMutex gen_types_mutex; + PtrMap gen_types; BlockingMutex type_info_mutex; // NOT recursive Array type_info_types; @@ -355,37 +387,39 @@ struct CheckerInfo { BlockingMutex foreign_mutex; // NOT recursive StringMap foreigns; - // only used by 'odin query' - bool allow_identifier_uses; - BlockingMutex identifier_uses_mutex; - Array identifier_uses; - // NOTE(bill): These are actually MPSC queues // TODO(bill): Convert them to be MPSC queues - MPMCQueue definition_queue; - MPMCQueue entity_queue; - MPMCQueue required_global_variable_queue; - MPMCQueue required_foreign_imports_through_force_queue; + MPSCQueue definition_queue; + MPSCQueue entity_queue; + MPSCQueue required_global_variable_queue; + MPSCQueue required_foreign_imports_through_force_queue; - MPMCQueue intrinsics_entry_point_usage; + MPSCQueue intrinsics_entry_point_usage; BlockingMutex objc_types_mutex; PtrMap objc_msgSend_types; BlockingMutex load_file_mutex; StringMap load_file_cache; + + BlockingMutex all_procedures_mutex; + Array all_procedures; }; struct CheckerContext { + // Order matters here + BlockingMutex mutex; Checker * checker; CheckerInfo * info; + AstPackage * pkg; AstFile * file; Scope * scope; DeclInfo * decl; + // Order doesn't matter after this u32 state_flags; - bool in_defer; // TODO(bill): Actually handle correctly + bool in_defer; Type * type_hint; String proc_name; @@ -396,9 +430,7 @@ struct CheckerContext { ForeignContext foreign_context; CheckerTypePath *type_path; - isize type_level; // TODO(bill): Actually handle correctly - CheckerPolyPath *poly_path; - isize poly_level; // TODO(bill): Actually handle correctly + isize type_level; UntypedExprInfoMap *untyped; @@ -415,8 +447,6 @@ struct CheckerContext { Scope * polymorphic_scope; Ast *assignment_lhs_hint; - - ProcBodyQueue *procs_to_check_queue; }; @@ -426,13 +456,14 @@ struct Checker { CheckerContext builtin_ctx; - MPMCQueue procs_with_deferred_to_check; + MPSCQueue procs_with_deferred_to_check; + Array procs_to_check; - ProcBodyQueue procs_to_check_queue; - Semaphore procs_to_check_semaphore; + BlockingMutex nested_proc_lits_mutex; + Array nested_proc_lits; - // TODO(bill): Technically MPSC queue - MPMCQueue global_untyped_queue; + + MPSCQueue global_untyped_queue; }; @@ -443,59 +474,53 @@ gb_global AstPackage *config_pkg = nullptr; // CheckerInfo API -TypeAndValue type_and_value_of_expr (Ast *expr); -Type * type_of_expr (Ast *expr); -Entity * implicit_entity_of_node(Ast *clause); -DeclInfo * decl_info_of_ident (Ast *ident); -DeclInfo * decl_info_of_entity (Entity * e); -AstFile * ast_file_of_filename (CheckerInfo *i, String filename); +gb_internal TypeAndValue type_and_value_of_expr (Ast *expr); +gb_internal Type * type_of_expr (Ast *expr); +gb_internal Entity * implicit_entity_of_node(Ast *clause); +gb_internal DeclInfo * decl_info_of_ident (Ast *ident); +gb_internal DeclInfo * decl_info_of_entity (Entity * e); +gb_internal AstFile * ast_file_of_filename (CheckerInfo *i, String filename); // IMPORTANT: Only to use once checking is done -isize type_info_index (CheckerInfo *i, Type *type, bool error_on_failure); +gb_internal isize type_info_index (CheckerInfo *i, Type *type, bool error_on_failure); // Will return nullptr if not found -Entity *entity_of_node(Ast *expr); +gb_internal Entity *entity_of_node(Ast *expr); -Entity *scope_lookup_current(Scope *s, String const &name); -Entity *scope_lookup (Scope *s, String const &name); -void scope_lookup_parent (Scope *s, String const &name, Scope **scope_, Entity **entity_); -Entity *scope_insert (Scope *s, Entity *entity, bool use_mutex=true); +gb_internal Entity *scope_lookup_current(Scope *s, String const &name); +gb_internal Entity *scope_lookup (Scope *s, String const &name); +gb_internal void scope_lookup_parent (Scope *s, String const &name, Scope **scope_, Entity **entity_); +gb_internal Entity *scope_insert (Scope *s, Entity *entity); -void add_type_and_value (CheckerInfo *i, Ast *expression, AddressingMode mode, Type *type, ExactValue value); -ExprInfo *check_get_expr_info (CheckerContext *c, Ast *expr); -void add_untyped (CheckerContext *c, Ast *expression, AddressingMode mode, Type *basic_type, ExactValue value); -void add_entity_use (CheckerContext *c, Ast *identifier, Entity *entity); -void add_implicit_entity (CheckerContext *c, Ast *node, Entity *e); -void add_entity_and_decl_info(CheckerContext *c, Ast *identifier, Entity *e, DeclInfo *d, bool is_exported=true); -void add_type_info_type (CheckerContext *c, Type *t); +gb_internal void add_type_and_value (CheckerContext *c, Ast *expression, AddressingMode mode, Type *type, ExactValue const &value); +gb_internal ExprInfo *check_get_expr_info (CheckerContext *c, Ast *expr); +gb_internal void add_untyped (CheckerContext *c, Ast *expression, AddressingMode mode, Type *basic_type, ExactValue const &value); +gb_internal void add_entity_use (CheckerContext *c, Ast *identifier, Entity *entity); +gb_internal void add_implicit_entity (CheckerContext *c, Ast *node, Entity *e); +gb_internal void add_entity_and_decl_info(CheckerContext *c, Ast *identifier, Entity *e, DeclInfo *d, bool is_exported=true); +gb_internal void add_type_info_type (CheckerContext *c, Type *t); -void check_add_import_decl(CheckerContext *c, Ast *decl); -void check_add_foreign_import_decl(CheckerContext *c, Ast *decl); +gb_internal void check_add_import_decl(CheckerContext *c, Ast *decl); +gb_internal void check_add_foreign_import_decl(CheckerContext *c, Ast *decl); -void check_entity_decl(CheckerContext *c, Entity *e, DeclInfo *d, Type *named_type); -void check_const_decl(CheckerContext *c, Entity *e, Ast *type_expr, Ast *init_expr, Type *named_type); -void check_type_decl(CheckerContext *c, Entity *e, Ast *type_expr, Type *def); +gb_internal void check_entity_decl(CheckerContext *c, Entity *e, DeclInfo *d, Type *named_type); +gb_internal void check_const_decl(CheckerContext *c, Entity *e, Ast *type_expr, Ast *init_expr, Type *named_type); +gb_internal void check_type_decl(CheckerContext *c, Entity *e, Ast *type_expr, Type *def); -bool check_arity_match(CheckerContext *c, AstValueDecl *vd, bool is_global = false); -void check_collect_entities(CheckerContext *c, Slice const &nodes); -void check_collect_entities_from_when_stmt(CheckerContext *c, AstWhenStmt *ws); -void check_delayed_file_import_entity(CheckerContext *c, Ast *decl); +gb_internal bool check_arity_match(CheckerContext *c, AstValueDecl *vd, bool is_global = false); +gb_internal void check_collect_entities(CheckerContext *c, Slice const &nodes); +gb_internal void check_collect_entities_from_when_stmt(CheckerContext *c, AstWhenStmt *ws); +gb_internal void check_delayed_file_import_entity(CheckerContext *c, Ast *decl); -CheckerTypePath *new_checker_type_path(); -void destroy_checker_type_path(CheckerTypePath *tp); +gb_internal CheckerTypePath *new_checker_type_path(); +gb_internal void destroy_checker_type_path(CheckerTypePath *tp); -void check_type_path_push(CheckerContext *c, Entity *e); -Entity *check_type_path_pop (CheckerContext *c); +gb_internal void check_type_path_push(CheckerContext *c, Entity *e); +gb_internal Entity *check_type_path_pop (CheckerContext *c); -CheckerPolyPath *new_checker_poly_path(); -void destroy_checker_poly_path(CheckerPolyPath *); +gb_internal void init_core_context(Checker *c); +gb_internal void init_mem_allocator(Checker *c); -void check_poly_path_push(CheckerContext *c, Type *t); -Type *check_poly_path_pop (CheckerContext *c); - -void init_core_context(Checker *c); -void init_mem_allocator(Checker *c); - -void add_untyped_expressions(CheckerInfo *cinfo, UntypedExprInfoMap *untyped); +gb_internal void add_untyped_expressions(CheckerInfo *cinfo, UntypedExprInfoMap *untyped); diff --git a/src/checker_builtin_procs.hpp b/src/checker_builtin_procs.hpp index e03e94ab4..edd046087 100644 --- a/src/checker_builtin_procs.hpp +++ b/src/checker_builtin_procs.hpp @@ -25,7 +25,7 @@ enum BuiltinProcId { BuiltinProc_kmag, BuiltinProc_conj, - BuiltinProc_expand_to_tuple, + BuiltinProc_expand_values, BuiltinProc_min, BuiltinProc_max, @@ -203,6 +203,7 @@ BuiltinProc__type_begin, BuiltinProc_type_elem_type, BuiltinProc_type_convert_variants_to_pointers, + BuiltinProc_type_merge, BuiltinProc__type_simple_boolean_begin, BuiltinProc_type_is_boolean, @@ -325,7 +326,7 @@ gb_global BuiltinProc builtin_procs[BuiltinProc_COUNT] = { {STR_LIT("kmag"), 1, false, Expr_Expr, BuiltinProcPkg_builtin}, {STR_LIT("conj"), 1, false, Expr_Expr, BuiltinProcPkg_builtin}, - {STR_LIT("expand_to_tuple"), 1, false, Expr_Expr, BuiltinProcPkg_builtin}, + {STR_LIT("expand_values"), 1, false, Expr_Expr, BuiltinProcPkg_builtin}, {STR_LIT("min"), 1, true, Expr_Expr, BuiltinProcPkg_builtin}, {STR_LIT("max"), 1, true, Expr_Expr, BuiltinProcPkg_builtin}, @@ -501,6 +502,7 @@ gb_global BuiltinProc builtin_procs[BuiltinProc_COUNT] = { {STR_LIT("type_core_type"), 1, false, Expr_Expr, BuiltinProcPkg_intrinsics}, {STR_LIT("type_elem_type"), 1, false, Expr_Expr, BuiltinProcPkg_intrinsics}, {STR_LIT("type_convert_variants_to_pointers"), 1, false, Expr_Expr, BuiltinProcPkg_intrinsics}, + {STR_LIT("type_merge"), 2, false, Expr_Expr, BuiltinProcPkg_intrinsics}, {STR_LIT(""), 0, false, Expr_Stmt, BuiltinProcPkg_intrinsics}, {STR_LIT("type_is_boolean"), 1, false, Expr_Expr, BuiltinProcPkg_intrinsics}, diff --git a/src/common.cpp b/src/common.cpp index bc421b5fd..90632def3 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -29,36 +29,56 @@ #include #include // Because I wanted the C++11 memory order semantics, of which gb.h does not offer (because it was a C89 library) -gbAllocator heap_allocator(void); +gb_internal gbAllocator heap_allocator(void); -#define for_array(index_, array_) for (isize index_ = 0; index_ < (array_).count; index_++) +#define for_array_off(index_, off_, array_) for (isize index_ = off_; index_ < (array_).count; index_++) +#define for_array(index_, array_) for_array_off(index_, 0, array_) -i32 next_pow2(i32 n); -i64 next_pow2(i64 n); -isize next_pow2_isize(isize n); -void debugf(char const *fmt, ...); +gb_internal i32 next_pow2(i32 n); +gb_internal i64 next_pow2(i64 n); +gb_internal isize next_pow2_isize(isize n); +gb_internal void debugf(char const *fmt, ...); #if defined(GB_SYSTEM_WINDOWS) && defined(GB_ARCH_32_BIT) #error Odin on Windows requires a 64-bit build-system. The 'Developer Command Prompt' for VS still defaults to 32-bit shell. The 64-bit shell can be found under the name 'x64 Native Tools Command Prompt' for VS. For more information, please see https://odin-lang.org/docs/install/#for-windows #endif -#include "threading.cpp" +template +struct TypeIsPointer { + enum {value = false}; +}; + +template +struct TypeIsPointer { + enum {value = true}; +}; + +template struct TypeIsPtrSizedInteger { enum {value = false}; }; +template <> struct TypeIsPtrSizedInteger { enum {value = true}; }; +template <> struct TypeIsPtrSizedInteger { enum {value = true}; }; + + #include "unicode.cpp" #include "array.cpp" -#include "queue.cpp" +#include "threading.cpp" #include "common_memory.cpp" +#include "queue.cpp" #include "string.cpp" #include "range_cache.cpp" +#if defined(GB_SYSTEM_WINDOWS) + #pragma warning(push) + #pragma warning(disable: 4505) +#endif -bool is_power_of_two(i64 x) { +gb_internal gb_inline bool is_power_of_two(i64 x) { if (x <= 0) { return false; } return !(x & (x-1)); } -int isize_cmp(isize x, isize y) { +gb_internal int isize_cmp(isize x, isize y) { if (x < y) { return -1; } else if (x > y) { @@ -66,7 +86,7 @@ int isize_cmp(isize x, isize y) { } return 0; } -int u64_cmp(u64 x, u64 y) { +gb_internal int u64_cmp(u64 x, u64 y) { if (x < y) { return -1; } else if (x > y) { @@ -74,7 +94,7 @@ int u64_cmp(u64 x, u64 y) { } return 0; } -int i64_cmp(i64 x, i64 y) { +gb_internal int i64_cmp(i64 x, i64 y) { if (x < y) { return -1; } else if (x > y) { @@ -82,7 +102,7 @@ int i64_cmp(i64 x, i64 y) { } return 0; } -int i32_cmp(i32 x, i32 y) { +gb_internal int i32_cmp(i32 x, i32 y) { if (x < y) { return -1; } else if (x > y) { @@ -91,7 +111,7 @@ int i32_cmp(i32 x, i32 y) { return 0; } -u32 fnv32a(void const *data, isize len) { +gb_internal u32 fnv32a(void const *data, isize len) { u8 const *bytes = cast(u8 const *)data; u32 h = 0x811c9dc5; @@ -112,7 +132,7 @@ u32 fnv32a(void const *data, isize len) { return h; } -u64 fnv64a(void const *data, isize len) { +gb_internal u64 fnv64a(void const *data, isize len) { u8 const *bytes = cast(u8 const *)data; u64 h = 0xcbf29ce484222325ull; @@ -133,7 +153,7 @@ u64 fnv64a(void const *data, isize len) { return h; } -u64 u64_digit_value(Rune r) { +gb_internal u64 u64_digit_value(Rune r) { switch (r) { case '0': return 0; case '1': return 1; @@ -162,7 +182,7 @@ u64 u64_digit_value(Rune r) { } -u64 u64_from_string(String string) { +gb_internal u64 u64_from_string(String string) { u64 base = 10; bool has_prefix = false; if (string.len > 2 && string[0] == '0') { @@ -205,7 +225,7 @@ gb_global char const global_num_to_char_table[] = "abcdefghijklmnopqrstuvwxyz" "@$"; -String u64_to_string(u64 v, char *out_buf, isize out_buf_len) { +gb_internal String u64_to_string(u64 v, char *out_buf, isize out_buf_len) { char buf[32] = {0}; isize i = gb_size_of(buf); @@ -220,7 +240,7 @@ String u64_to_string(u64 v, char *out_buf, isize out_buf_len) { gb_memmove(out_buf, &buf[i], len); return make_string(cast(u8 *)out_buf, len); } -String i64_to_string(i64 a, char *out_buf, isize out_buf_len) { +gb_internal String i64_to_string(i64 a, char *out_buf, isize out_buf_len) { char buf[32] = {0}; isize i = gb_size_of(buf); bool negative = false; @@ -282,17 +302,17 @@ gb_global u64 const unsigned_integer_maxs[] = { }; -bool add_overflow_u64(u64 x, u64 y, u64 *result) { +gb_internal bool add_overflow_u64(u64 x, u64 y, u64 *result) { *result = x + y; return *result < x || *result < y; } -bool sub_overflow_u64(u64 x, u64 y, u64 *result) { +gb_internal bool sub_overflow_u64(u64 x, u64 y, u64 *result) { *result = x - y; return *result > x; } -void mul_overflow_u64(u64 x, u64 y, u64 *lo, u64 *hi) { +gb_internal void mul_overflow_u64(u64 x, u64 y, u64 *lo, u64 *hi) { #if defined(GB_COMPILER_MSVC) && defined(GB_ARCH_64_BIT) *lo = _umul128(x, y, hi); #else @@ -342,7 +362,7 @@ struct StringIntern { PtrMap string_intern_map = {}; // Key: u64 gb_global Arena string_intern_arena = {}; -char const *string_intern(char const *text, isize len) { +gb_internal char const *string_intern(char const *text, isize len) { u64 hash = gb_fnv64a(text, len); uintptr key = cast(uintptr)(hash ? hash : 1); StringIntern **found = map_get(&string_intern_map, key); @@ -363,18 +383,18 @@ char const *string_intern(char const *text, isize len) { return new_intern->str; } -char const *string_intern(String const &string) { +gb_internal char const *string_intern(String const &string) { return string_intern(cast(char const *)string.text, string.len); } -void init_string_interner(void) { - map_init(&string_intern_map, heap_allocator()); +gb_internal void init_string_interner(void) { + map_init(&string_intern_map); } -i32 next_pow2(i32 n) { +gb_internal i32 next_pow2(i32 n) { if (n <= 0) { return 0; } @@ -387,7 +407,7 @@ i32 next_pow2(i32 n) { n++; return n; } -i64 next_pow2(i64 n) { +gb_internal i64 next_pow2(i64 n) { if (n <= 0) { return 0; } @@ -401,7 +421,7 @@ i64 next_pow2(i64 n) { n++; return n; } -isize next_pow2_isize(isize n) { +gb_internal isize next_pow2_isize(isize n) { if (n <= 0) { return 0; } @@ -417,7 +437,7 @@ isize next_pow2_isize(isize n) { n++; return n; } -u32 next_pow2_u32(u32 n) { +gb_internal u32 next_pow2_u32(u32 n) { if (n == 0) { return 0; } @@ -432,7 +452,7 @@ u32 next_pow2_u32(u32 n) { } -i32 bit_set_count(u32 x) { +gb_internal i32 bit_set_count(u32 x) { x -= ((x >> 1) & 0x55555555); x = (((x >> 2) & 0x33333333) + (x & 0x33333333)); x = (((x >> 4) + x) & 0x0f0f0f0f); @@ -442,13 +462,13 @@ i32 bit_set_count(u32 x) { return cast(i32)(x & 0x0000003f); } -i64 bit_set_count(u64 x) { +gb_internal i64 bit_set_count(u64 x) { u32 a = *(cast(u32 *)&x); u32 b = *(cast(u32 *)&x + 1); return bit_set_count(a) + bit_set_count(b); } -u32 floor_log2(u32 x) { +gb_internal u32 floor_log2(u32 x) { x |= x >> 1; x |= x >> 2; x |= x >> 4; @@ -457,7 +477,7 @@ u32 floor_log2(u32 x) { return cast(u32)(bit_set_count(x) - 1); } -u64 floor_log2(u64 x) { +gb_internal u64 floor_log2(u64 x) { x |= x >> 1; x |= x >> 2; x |= x >> 4; @@ -468,7 +488,7 @@ u64 floor_log2(u64 x) { } -u32 ceil_log2(u32 x) { +gb_internal u32 ceil_log2(u32 x) { i32 y = cast(i32)(x & (x-1)); y |= -y; y >>= 32-1; @@ -480,7 +500,7 @@ u32 ceil_log2(u32 x) { return cast(u32)(bit_set_count(x) - 1 - y); } -u64 ceil_log2(u64 x) { +gb_internal u64 ceil_log2(u64 x) { i64 y = cast(i64)(x & (x-1)); y |= -y; y >>= 64-1; @@ -493,7 +513,7 @@ u64 ceil_log2(u64 x) { return cast(u64)(bit_set_count(x) - 1 - y); } -u32 prev_pow2(u32 n) { +gb_internal u32 prev_pow2(u32 n) { if (n == 0) { return 0; } @@ -504,7 +524,7 @@ u32 prev_pow2(u32 n) { n |= n >> 16; return n - (n >> 1); } -i32 prev_pow2(i32 n) { +gb_internal i32 prev_pow2(i32 n) { if (n <= 0) { return 0; } @@ -515,7 +535,7 @@ i32 prev_pow2(i32 n) { n |= n >> 16; return n - (n >> 1); } -i64 prev_pow2(i64 n) { +gb_internal i64 prev_pow2(i64 n) { if (n <= 0) { return 0; } @@ -528,7 +548,7 @@ i64 prev_pow2(i64 n) { return n - (n >> 1); } -u16 f32_to_f16(f32 value) { +gb_internal u16 f32_to_f16(f32 value) { union { u32 i; f32 f; } v; i32 i, s, e, m; @@ -579,7 +599,7 @@ u16 f32_to_f16(f32 value) { } } -f32 f16_to_f32(u16 value) { +gb_internal f32 f16_to_f32(u16 value) { typedef union { u32 u; f32 f; } fp32; fp32 v; @@ -595,7 +615,7 @@ f32 f16_to_f32(u16 value) { return v.f; } -f64 gb_sqrt(f64 x) { +gb_internal gb_inline f64 gb_sqrt(f64 x) { return sqrt(x); } @@ -623,7 +643,7 @@ f64 gb_sqrt(f64 x) { #if defined(GB_SYSTEM_WINDOWS) -wchar_t **command_line_to_wargv(wchar_t *cmd_line, int *_argc) { +gb_internal wchar_t **command_line_to_wargv(wchar_t *cmd_line, int *_argc) { u32 i, j; u32 len = cast(u32)string16_len(cmd_line); @@ -706,11 +726,13 @@ enum LoadedFileError { LoadedFile_COUNT, }; -LoadedFileError load_file_32(char const *fullpath, LoadedFile *memory_mapped_file, bool copy_file_contents) { +gb_internal LoadedFileError load_file_32(char const *fullpath, LoadedFile *memory_mapped_file, bool copy_file_contents) { LoadedFileError err = LoadedFile_None; if (!copy_file_contents) { #if defined(GB_SYSTEM_WINDOWS) + TEMPORARY_ALLOCATOR_GUARD(); + isize w_len = 0; wchar_t *w_str = gb__alloc_utf8_to_ucs2(temporary_allocator(), fullpath, &w_len); if (w_str == nullptr) { @@ -727,7 +749,7 @@ LoadedFileError load_file_32(char const *fullpath, LoadedFile *memory_mapped_fil handle = nullptr; goto window_handle_file_error; } - + li_file_size = {}; if (!GetFileSizeEx(handle, &li_file_size)) { goto window_handle_file_error; @@ -737,7 +759,7 @@ LoadedFileError load_file_32(char const *fullpath, LoadedFile *memory_mapped_fil CloseHandle(handle); return LoadedFile_FileTooLarge; } - + if (file_size == 0) { CloseHandle(handle); err = LoadedFile_Empty; @@ -746,10 +768,10 @@ LoadedFileError load_file_32(char const *fullpath, LoadedFile *memory_mapped_fil memory_mapped_file->size = 0; return err; } - + file_mapping = CreateFileMappingW(handle, nullptr, PAGE_READONLY, 0, 0, nullptr); CloseHandle(handle); - + file_data = MapViewOfFileEx(file_mapping, FILE_MAP_READ, 0, 0, 0/*file_size*/, nullptr/*base address*/); memory_mapped_file->handle = cast(void *)file_mapping; memory_mapped_file->data = file_data; @@ -811,7 +833,9 @@ LoadedFileError load_file_32(char const *fullpath, LoadedFile *memory_mapped_fil #define USE_DAMERAU_LEVENSHTEIN 1 -isize levenstein_distance_case_insensitive(String const &a, String const &b) { +gb_internal isize levenstein_distance_case_insensitive(String const &a, String const &b) { + TEMPORARY_ALLOCATOR_GUARD(); + isize w = b.len+1; isize h = a.len+1; isize *matrix = gb_alloc_array(temporary_allocator(), isize, w*h); @@ -870,16 +894,16 @@ struct DidYouMeanAnswers { enum {MAX_SMALLEST_DID_YOU_MEAN_DISTANCE = 3-USE_DAMERAU_LEVENSHTEIN}; -DidYouMeanAnswers did_you_mean_make(gbAllocator allocator, isize cap, String const &key) { +gb_internal DidYouMeanAnswers did_you_mean_make(gbAllocator allocator, isize cap, String const &key) { DidYouMeanAnswers d = {}; array_init(&d.distances, allocator, 0, cap); d.key = key; return d; } -void did_you_mean_destroy(DidYouMeanAnswers *d) { +gb_internal void did_you_mean_destroy(DidYouMeanAnswers *d) { array_free(&d->distances); } -void did_you_mean_append(DidYouMeanAnswers *d, String const &target) { +gb_internal void did_you_mean_append(DidYouMeanAnswers *d, String const &target) { if (target.len == 0 || target == "_") { return; } @@ -888,7 +912,7 @@ void did_you_mean_append(DidYouMeanAnswers *d, String const &target) { dat.distance = levenstein_distance_case_insensitive(d->key, target); array_add(&d->distances, dat); } -Slice did_you_mean_results(DidYouMeanAnswers *d) { +gb_internal Slice did_you_mean_results(DidYouMeanAnswers *d) { gb_sort_array(d->distances.data, d->distances.count, gb_isize_cmp(gb_offset_of(DistanceAndTarget, distance))); isize count = 0; for (isize i = 0; i < d->distances.count; i++) { @@ -900,3 +924,8 @@ Slice did_you_mean_results(DidYouMeanAnswers *d) { } return slice_array(d->distances, 0, count); } + + +#if defined(GB_SYSTEM_WINDOWS) + #pragma warning(pop) +#endif diff --git a/src/common_memory.cpp b/src/common_memory.cpp index 953462077..c6ee88f03 100644 --- a/src/common_memory.cpp +++ b/src/common_memory.cpp @@ -1,5 +1,8 @@ +#if defined(GB_SYSTEM_LINUX) +#include +#endif -gb_inline void zero_size(void *ptr, isize len) { +gb_internal gb_inline void zero_size(void *ptr, isize len) { memset(ptr, 0, len); } @@ -7,43 +10,31 @@ gb_inline void zero_size(void *ptr, isize len) { template -gb_inline U bit_cast(V &v) { return reinterpret_cast(v); } +gb_internal gb_inline U bit_cast(V &v) { return reinterpret_cast(v); } template -gb_inline U const &bit_cast(V const &v) { return reinterpret_cast(v); } +gb_internal gb_inline U const &bit_cast(V const &v) { return reinterpret_cast(v); } -gb_inline i64 align_formula(i64 size, i64 align) { - if (align > 0) { - i64 result = size + align-1; - return result - result%align; - } - return size; +gb_internal gb_inline i64 align_formula(i64 size, i64 align) { + i64 result = size + align-1; + return result - (i64)((u64)result%(u64)align); } -gb_inline isize align_formula_isize(isize size, isize align) { - if (align > 0) { - isize result = size + align-1; - return result - result%align; - } - return size; +gb_internal gb_inline isize align_formula_isize(isize size, isize align) { + isize result = size + align-1; + return result - (isize)((usize)result%(usize)align); } -gb_inline void *align_formula_ptr(void *ptr, isize align) { - if (align > 0) { - uintptr result = (cast(uintptr)ptr) + align-1; - return (void *)(result - result%align); - } - return ptr; +gb_internal gb_inline void *align_formula_ptr(void *ptr, isize align) { + uintptr result = (cast(uintptr)ptr) + align-1; + return (void *)(result - result%align); } gb_global BlockingMutex global_memory_block_mutex; -gb_global BlockingMutex global_memory_allocator_mutex; -void platform_virtual_memory_init(void); +gb_internal void platform_virtual_memory_init(void); -void virtual_memory_init(void) { - mutex_init(&global_memory_block_mutex); - mutex_init(&global_memory_allocator_mutex); +gb_internal void virtual_memory_init(void) { platform_virtual_memory_init(); } @@ -57,22 +48,22 @@ struct MemoryBlock { }; struct Arena { - MemoryBlock *curr_block; - isize minimum_block_size; - bool ignore_mutex; + MemoryBlock * curr_block; + isize minimum_block_size; + BlockingMutex mutex; + isize temp_count; }; enum { DEFAULT_MINIMUM_BLOCK_SIZE = 8ll*1024ll*1024ll }; gb_global isize DEFAULT_PAGE_SIZE = 4096; -MemoryBlock *virtual_memory_alloc(isize size); -void virtual_memory_dealloc(MemoryBlock *block); -void *arena_alloc(Arena *arena, isize min_size, isize alignment); -void arena_free_all(Arena *arena); +gb_internal MemoryBlock *virtual_memory_alloc(isize size); +gb_internal void virtual_memory_dealloc(MemoryBlock *block); +gb_internal void *arena_alloc(Arena *arena, isize min_size, isize alignment); +gb_internal void arena_free_all(Arena *arena); - -isize arena_align_forward_offset(Arena *arena, isize alignment) { +gb_internal isize arena_align_forward_offset(Arena *arena, isize alignment) { isize alignment_offset = 0; isize ptr = cast(isize)(arena->curr_block->base + arena->curr_block->used); isize mask = alignment-1; @@ -82,14 +73,11 @@ isize arena_align_forward_offset(Arena *arena, isize alignment) { return alignment_offset; } -void *arena_alloc(Arena *arena, isize min_size, isize alignment) { +gb_internal void *arena_alloc(Arena *arena, isize min_size, isize alignment) { GB_ASSERT(gb_is_power_of_two(alignment)); - BlockingMutex *mutex = &global_memory_allocator_mutex; - if (!arena->ignore_mutex) { - mutex_lock(mutex); - } - + mutex_lock(&arena->mutex); + isize size = 0; if (arena->curr_block != nullptr) { size = min_size + arena_align_forward_offset(arena, alignment); @@ -115,15 +103,13 @@ void *arena_alloc(Arena *arena, isize min_size, isize alignment) { curr_block->used += size; GB_ASSERT(curr_block->used <= curr_block->size); - if (!arena->ignore_mutex) { - mutex_unlock(mutex); - } + mutex_unlock(&arena->mutex); // NOTE(bill): memory will be zeroed by default due to virtual memory return ptr; } -void arena_free_all(Arena *arena) { +gb_internal void arena_free_all(Arena *arena) { while (arena->curr_block != nullptr) { MemoryBlock *free_block = arena->curr_block; arena->curr_block = free_block->prev; @@ -138,16 +124,15 @@ struct PlatformMemoryBlock { PlatformMemoryBlock *prev, *next; }; - gb_global std::atomic global_platform_memory_total_usage; gb_global PlatformMemoryBlock global_platform_memory_block_sentinel; -PlatformMemoryBlock *platform_virtual_memory_alloc(isize total_size); -void platform_virtual_memory_free(PlatformMemoryBlock *block); -void platform_virtual_memory_protect(void *memory, isize size); +gb_internal PlatformMemoryBlock *platform_virtual_memory_alloc(isize total_size); +gb_internal void platform_virtual_memory_free(PlatformMemoryBlock *block); +gb_internal void platform_virtual_memory_protect(void *memory, isize size); #if defined(GB_SYSTEM_WINDOWS) - void platform_virtual_memory_init(void) { + gb_internal void platform_virtual_memory_init(void) { global_platform_memory_block_sentinel.prev = &global_platform_memory_block_sentinel; global_platform_memory_block_sentinel.next = &global_platform_memory_block_sentinel; @@ -157,7 +142,7 @@ void platform_virtual_memory_protect(void *memory, isize size); GB_ASSERT(gb_is_power_of_two(DEFAULT_PAGE_SIZE)); } - PlatformMemoryBlock *platform_virtual_memory_alloc(isize total_size) { + gb_internal PlatformMemoryBlock *platform_virtual_memory_alloc(isize total_size) { PlatformMemoryBlock *pmblock = (PlatformMemoryBlock *)VirtualAlloc(0, total_size, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE); if (pmblock == nullptr) { gb_printf_err("Out of Virtual memory, oh no...\n"); @@ -165,20 +150,20 @@ void platform_virtual_memory_protect(void *memory, isize size); gb_printf_err("Total Usage: %lld bytes\n", cast(long long)global_platform_memory_total_usage); GB_ASSERT_MSG(pmblock != nullptr, "Out of Virtual Memory, oh no..."); } - global_platform_memory_total_usage += total_size; + global_platform_memory_total_usage.fetch_add(total_size); return pmblock; } - void platform_virtual_memory_free(PlatformMemoryBlock *block) { - global_platform_memory_total_usage -= block->total_size; + gb_internal void platform_virtual_memory_free(PlatformMemoryBlock *block) { + global_platform_memory_total_usage.fetch_sub(block->total_size); GB_ASSERT(VirtualFree(block, 0, MEM_RELEASE)); } - void platform_virtual_memory_protect(void *memory, isize size) { + gb_internal void platform_virtual_memory_protect(void *memory, isize size) { DWORD old_protect = 0; BOOL is_protected = VirtualProtect(memory, size, PAGE_NOACCESS, &old_protect); GB_ASSERT(is_protected); } #else - void platform_virtual_memory_init(void) { + gb_internal void platform_virtual_memory_init(void) { global_platform_memory_block_sentinel.prev = &global_platform_memory_block_sentinel; global_platform_memory_block_sentinel.next = &global_platform_memory_block_sentinel; @@ -186,7 +171,7 @@ void platform_virtual_memory_protect(void *memory, isize size); GB_ASSERT(gb_is_power_of_two(DEFAULT_PAGE_SIZE)); } - PlatformMemoryBlock *platform_virtual_memory_alloc(isize total_size) { + gb_internal PlatformMemoryBlock *platform_virtual_memory_alloc(isize total_size) { PlatformMemoryBlock *pmblock = (PlatformMemoryBlock *)mmap(nullptr, total_size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); if (pmblock == nullptr) { gb_printf_err("Out of Virtual memory, oh no...\n"); @@ -194,21 +179,21 @@ void platform_virtual_memory_protect(void *memory, isize size); gb_printf_err("Total Usage: %lld bytes\n", cast(long long)global_platform_memory_total_usage); GB_ASSERT_MSG(pmblock != nullptr, "Out of Virtual Memory, oh no..."); } - global_platform_memory_total_usage += total_size; + global_platform_memory_total_usage.fetch_add(total_size); return pmblock; } - void platform_virtual_memory_free(PlatformMemoryBlock *block) { + gb_internal void platform_virtual_memory_free(PlatformMemoryBlock *block) { isize size = block->total_size; - global_platform_memory_total_usage -= size; + global_platform_memory_total_usage.fetch_sub(size); munmap(block, size); } - void platform_virtual_memory_protect(void *memory, isize size) { + gb_internal void platform_virtual_memory_protect(void *memory, isize size) { int err = mprotect(memory, size, PROT_NONE); GB_ASSERT(err == 0); } #endif -MemoryBlock *virtual_memory_alloc(isize size) { +gb_internal MemoryBlock *virtual_memory_alloc(isize size) { isize const page_size = DEFAULT_PAGE_SIZE; isize total_size = size + gb_size_of(PlatformMemoryBlock); @@ -250,7 +235,7 @@ MemoryBlock *virtual_memory_alloc(isize size) { return &pmblock->block; } -void virtual_memory_dealloc(MemoryBlock *block_to_free) { +gb_internal void virtual_memory_dealloc(MemoryBlock *block_to_free) { PlatformMemoryBlock *block = cast(PlatformMemoryBlock *)block_to_free; if (block != nullptr) { mutex_lock(&global_memory_block_mutex); @@ -262,12 +247,87 @@ void virtual_memory_dealloc(MemoryBlock *block_to_free) { } } +struct ArenaTemp { + Arena * arena; + MemoryBlock *block; + isize used; +}; + +ArenaTemp arena_temp_begin(Arena *arena) { + GB_ASSERT(arena); + MUTEX_GUARD(&arena->mutex); + + ArenaTemp temp = {}; + temp.arena = arena; + temp.block = arena->curr_block; + if (arena->curr_block != nullptr) { + temp.used = arena->curr_block->used; + } + arena->temp_count += 1; + return temp; +} + +void arena_temp_end(ArenaTemp const &temp) { + GB_ASSERT(temp.arena); + Arena *arena = temp.arena; + MUTEX_GUARD(&arena->mutex); + + if (temp.block) { + bool memory_block_found = false; + for (MemoryBlock *block = arena->curr_block; block != nullptr; block = block->prev) { + if (block == temp.block) { + memory_block_found = true; + break; + } + } + GB_ASSERT_MSG(memory_block_found, "memory block stored within ArenaTemp not owned by Arena"); + + while (arena->curr_block != temp.block) { + MemoryBlock *free_block = arena->curr_block; + if (free_block != nullptr) { + arena->curr_block = free_block->prev; + virtual_memory_dealloc(free_block); + } + } + + MemoryBlock *block = arena->curr_block; + if (block) { + GB_ASSERT_MSG(block->used >= temp.used, "out of order use of arena_temp_end"); + isize amount_to_zero = gb_min(block->used - temp.used, block->size - block->used); + gb_zero_size(block->base + temp.used, amount_to_zero); + block->used = temp.used; + } + } + + GB_ASSERT_MSG(arena->temp_count > 0, "double-use of arena_temp_end"); + arena->temp_count -= 1; +} + +void arena_temp_ignore(ArenaTemp const &temp) { + GB_ASSERT(temp.arena); + Arena *arena = temp.arena; + MUTEX_GUARD(&arena->mutex); + + GB_ASSERT_MSG(arena->temp_count > 0, "double-use of arena_temp_end"); + arena->temp_count -= 1; +} -GB_ALLOCATOR_PROC(arena_allocator_proc); +struct ArenaTempGuard { + ArenaTempGuard(Arena *arena) { + this->temp = arena_temp_begin(arena); + } + ~ArenaTempGuard() { + arena_temp_end(this->temp); + } + ArenaTemp temp; +}; -gbAllocator arena_allocator(Arena *arena) { + +gb_internal GB_ALLOCATOR_PROC(arena_allocator_proc); + +gb_internal gbAllocator arena_allocator(Arena *arena) { gbAllocator a; a.proc = arena_allocator_proc; a.data = arena; @@ -275,7 +335,7 @@ gbAllocator arena_allocator(Arena *arena) { } -GB_ALLOCATOR_PROC(arena_allocator_proc) { +gb_internal GB_ALLOCATOR_PROC(arena_allocator_proc) { void *ptr = nullptr; Arena *arena = cast(Arena *)allocator_data; GB_ASSERT_NOT_NULL(arena); @@ -306,37 +366,47 @@ GB_ALLOCATOR_PROC(arena_allocator_proc) { } -gb_global gb_thread_local Arena permanent_arena = {nullptr, DEFAULT_MINIMUM_BLOCK_SIZE, true}; -gbAllocator permanent_allocator() { +gb_global gb_thread_local Arena permanent_arena = {nullptr, DEFAULT_MINIMUM_BLOCK_SIZE}; +gb_internal gbAllocator permanent_allocator() { return arena_allocator(&permanent_arena); } -gbAllocator temporary_allocator() { - return permanent_allocator(); +gb_global gb_thread_local Arena temporary_arena = {nullptr, DEFAULT_MINIMUM_BLOCK_SIZE}; +gb_internal gbAllocator temporary_allocator() { + return arena_allocator(&temporary_arena); } +#define TEMP_ARENA_GUARD(arena) ArenaTempGuard GB_DEFER_3(_arena_guard_){arena} + + +// #define TEMPORARY_ALLOCATOR_GUARD() +#define TEMPORARY_ALLOCATOR_GUARD() TEMP_ARENA_GUARD(&temporary_arena) +#define PERMANENT_ALLOCATOR_GUARD() +gb_internal bool IS_ODIN_DEBUG(void); -GB_ALLOCATOR_PROC(heap_allocator_proc); +gb_internal GB_ALLOCATOR_PROC(heap_allocator_proc); -gbAllocator heap_allocator(void) { + +gb_internal gbAllocator heap_allocator(void) { gbAllocator a; a.proc = heap_allocator_proc; a.data = nullptr; return a; } +gb_internal std::atomic total_heap_memory_allocated; -GB_ALLOCATOR_PROC(heap_allocator_proc) { + +gb_internal GB_ALLOCATOR_PROC(heap_allocator_proc) { void *ptr = nullptr; gb_unused(allocator_data); gb_unused(old_size); - // TODO(bill): Throughly test! switch (type) { #if defined(GB_COMPILER_MSVC) @@ -369,28 +439,34 @@ GB_ALLOCATOR_PROC(heap_allocator_proc) { #elif defined(GB_SYSTEM_LINUX) // TODO(bill): *nix version that's decent case gbAllocation_Alloc: { - ptr = aligned_alloc(alignment, (size + alignment - 1) & ~(alignment - 1)); + isize total_size = (size + alignment - 1) & ~(alignment - 1); + total_heap_memory_allocated.fetch_add(total_size); + ptr = aligned_alloc(alignment, total_size); gb_zero_size(ptr, size); } break; case gbAllocation_Free: if (old_memory != nullptr) { + total_heap_memory_allocated.fetch_sub(malloc_usable_size(old_memory)); free(old_memory); } break; - case gbAllocation_Resize: + case gbAllocation_Resize: { if (size == 0) { if (old_memory != nullptr) { + total_heap_memory_allocated.fetch_sub(malloc_usable_size(old_memory)); free(old_memory); } break; } - + alignment = gb_max(alignment, gb_align_of(max_align_t)); - + if (old_memory == nullptr) { - ptr = aligned_alloc(alignment, (size + alignment - 1) & ~(alignment - 1)); + isize total_size = (size + alignment - 1) & ~(alignment - 1); + total_heap_memory_allocated.fetch_add(total_size); + ptr = aligned_alloc(alignment, total_size); gb_zero_size(ptr, size); break; } @@ -399,11 +475,19 @@ GB_ALLOCATOR_PROC(heap_allocator_proc) { break; } - ptr = aligned_alloc(alignment, (size + alignment - 1) & ~(alignment - 1)); + size_t actual_old_size = malloc_usable_size(old_memory); + if (size <= actual_old_size) { + ptr = old_memory; + break; + } + + isize total_size = (size + alignment - 1) & ~(alignment - 1); + total_heap_memory_allocated.fetch_add(total_size); + ptr = aligned_alloc(alignment, total_size); gb_memmove(ptr, old_memory, old_size); free(old_memory); gb_zero_size(cast(u8 *)ptr + old_size, gb_max(size-old_size, 0)); - break; + } break; #else // TODO(bill): *nix version that's decent case gbAllocation_Alloc: { @@ -460,21 +544,22 @@ GB_ALLOCATOR_PROC(heap_allocator_proc) { template -void resize_array_raw(T **array, gbAllocator const &a, isize old_count, isize new_count) { +gb_internal isize resize_array_raw(T **array, gbAllocator const &a, isize old_count, isize new_count, isize custom_alignment=1) { GB_ASSERT(new_count >= 0); if (new_count == 0) { gb_free(a, *array); *array = nullptr; - return; + return 0; } if (new_count < old_count) { - return; + return old_count; } isize old_size = old_count * gb_size_of(T); isize new_size = new_count * gb_size_of(T); - isize alignment = gb_align_of(T); + isize alignment = gb_max(gb_align_of(T), custom_alignment); auto new_data = cast(T *)gb_resize_align(a, *array, old_size, new_size, alignment); GB_ASSERT(new_data != nullptr); *array = new_data; + return new_count; } diff --git a/src/docs.cpp b/src/docs.cpp index 3ea3cce1b..f00d4e15a 100644 --- a/src/docs.cpp +++ b/src/docs.cpp @@ -28,7 +28,7 @@ gb_global char const *print_entity_names[Entity_Count] = { }; -GB_COMPARE_PROC(cmp_entities_for_printing) { +gb_internal GB_COMPARE_PROC(cmp_entities_for_printing) { GB_ASSERT(a != nullptr); GB_ASSERT(b != nullptr); Entity *x = *cast(Entity **)a; @@ -49,14 +49,13 @@ GB_COMPARE_PROC(cmp_entities_for_printing) { int ox = print_entity_kind_ordering[x->kind]; int oy = print_entity_kind_ordering[y->kind]; res = ox - oy; - if (res != 0) { - return res; + if (res == 0) { + res = string_compare(x->token.string, y->token.string); } - res = string_compare(x->token.string, y->token.string); return res; } -GB_COMPARE_PROC(cmp_ast_package_by_name) { +gb_internal GB_COMPARE_PROC(cmp_ast_package_by_name) { GB_ASSERT(a != nullptr); GB_ASSERT(b != nullptr); AstPackage *x = *cast(AstPackage **)a; @@ -67,7 +66,7 @@ GB_COMPARE_PROC(cmp_ast_package_by_name) { #include "docs_format.cpp" #include "docs_writer.cpp" -void print_doc_line(i32 indent, String const &data) { +gb_internal void print_doc_line(i32 indent, String const &data) { while (indent --> 0) { gb_printf("\t"); } @@ -75,7 +74,7 @@ void print_doc_line(i32 indent, String const &data) { gb_printf("\n"); } -void print_doc_line(i32 indent, char const *fmt, ...) { +gb_internal void print_doc_line(i32 indent, char const *fmt, ...) { while (indent --> 0) { gb_printf("\t"); } @@ -85,16 +84,7 @@ void print_doc_line(i32 indent, char const *fmt, ...) { va_end(va); gb_printf("\n"); } -void print_doc_line_no_newline(i32 indent, char const *fmt, ...) { - while (indent --> 0) { - gb_printf("\t"); - } - va_list va; - va_start(va, fmt); - gb_printf_va(fmt, va); - va_end(va); -} -void print_doc_line_no_newline(i32 indent, String const &data) { +gb_internal void print_doc_line_no_newline(i32 indent, String const &data) { while (indent --> 0) { gb_printf("\t"); } @@ -102,7 +92,7 @@ void print_doc_line_no_newline(i32 indent, String const &data) { } -bool print_doc_comment_group_string(i32 indent, CommentGroup *g) { +gb_internal bool print_doc_comment_group_string(i32 indent, CommentGroup *g) { if (g == nullptr) { return false; } @@ -191,7 +181,7 @@ bool print_doc_comment_group_string(i32 indent, CommentGroup *g) { -void print_doc_expr(Ast *expr) { +gb_internal void print_doc_expr(Ast *expr) { gbString s = nullptr; if (build_context.cmd_doc_flags & CmdDocFlag_Short) { s = expr_to_string_shorthand(expr); @@ -202,8 +192,7 @@ void print_doc_expr(Ast *expr) { gb_string_free(s); } - -void print_doc_package(CheckerInfo *info, AstPackage *pkg) { +gb_internal void print_doc_package(CheckerInfo *info, AstPackage *pkg) { if (pkg == nullptr) { return; } @@ -220,10 +209,10 @@ void print_doc_package(CheckerInfo *info, AstPackage *pkg) { } if (pkg->scope != nullptr) { - auto entities = array_make(heap_allocator(), 0, pkg->scope->elements.entries.count); + auto entities = array_make(heap_allocator(), 0, pkg->scope->elements.count); defer (array_free(&entities)); - for_array(i, pkg->scope->elements.entries) { - Entity *e = pkg->scope->elements.entries[i].value; + for (auto const &entry : pkg->scope->elements) { + Entity *e = entry.value; switch (e->kind) { case Entity_Invalid: case Entity_Builtin: @@ -240,6 +229,12 @@ void print_doc_package(CheckerInfo *info, AstPackage *pkg) { // Fine break; } + if (e->pkg != pkg) { + continue; + } + if (!is_entity_exported(e)) { + continue; + } array_add(&entities, e); } gb_sort_array(entities.data, entities.count, cmp_entities_for_printing); @@ -247,16 +242,7 @@ void print_doc_package(CheckerInfo *info, AstPackage *pkg) { bool show_docs = (build_context.cmd_doc_flags & CmdDocFlag_Short) == 0; EntityKind curr_entity_kind = Entity_Invalid; - for_array(i, entities) { - Entity *e = entities[i]; - if (e->pkg != pkg) { - continue; - } - if (!is_entity_exported(e)) { - continue; - } - - + for (Entity *e : entities) { if (curr_entity_kind != e->kind) { if (curr_entity_kind != Entity_Invalid) { print_doc_line(0, ""); @@ -297,7 +283,7 @@ void print_doc_package(CheckerInfo *info, AstPackage *pkg) { print_doc_expr(init_expr); } - gb_printf(";\n"); + gb_printf("\n"); if (show_docs) { print_doc_comment_group_string(3, docs); @@ -320,7 +306,7 @@ void print_doc_package(CheckerInfo *info, AstPackage *pkg) { } -void generate_documentation(Checker *c) { +gb_internal void generate_documentation(Checker *c) { CheckerInfo *info = &c->info; if (build_context.cmd_doc_flags & CmdDocFlag_DocFormat) { @@ -358,9 +344,9 @@ void generate_documentation(Checker *c) { odin_doc_write(info, output_file_path); } else { - auto pkgs = array_make(permanent_allocator(), 0, info->packages.entries.count); - for_array(i, info->packages.entries) { - AstPackage *pkg = info->packages.entries[i].value; + auto pkgs = array_make(permanent_allocator(), 0, info->packages.count); + for (auto const &entry : info->packages) { + AstPackage *pkg = entry.value; if (build_context.cmd_doc_flags & CmdDocFlag_AllPackages) { array_add(&pkgs, pkg); } else { diff --git a/src/docs_format.cpp b/src/docs_format.cpp index b13b8b364..34114f08e 100644 --- a/src/docs_format.cpp +++ b/src/docs_format.cpp @@ -27,14 +27,14 @@ struct OdinDocHeaderBase { }; template -Slice from_array(OdinDocHeaderBase *base, OdinDocArray const &a) { +gb_internal Slice from_array(OdinDocHeaderBase *base, OdinDocArray const &a) { Slice s = {}; s.data = cast(T *)(cast(uintptr)base + cast(uintptr)a.offset); s.count = cast(isize)a.length; return s; } -String from_string(OdinDocHeaderBase *base, OdinDocString const &s) { +gb_internal String from_string(OdinDocHeaderBase *base, OdinDocString const &s) { String str = {}; str.text = cast(u8 *)(cast(uintptr)base + cast(uintptr)s.offset); str.len = cast(isize)s.length; diff --git a/src/docs_writer.cpp b/src/docs_writer.cpp index 5246971ff..2dd2f338b 100644 --- a/src/docs_writer.cpp +++ b/src/docs_writer.cpp @@ -11,7 +11,7 @@ enum OdinDocWriterState { OdinDocWriterState_Writing, }; -char const* OdinDocWriterState_strings[] { +gb_global char const* OdinDocWriterState_strings[] { "preparing", "writing ", }; @@ -30,6 +30,7 @@ struct OdinDocWriter { PtrMap pkg_cache; PtrMap entity_cache; PtrMap type_cache; + PtrMap stable_type_cache; OdinDocWriterItemTracker files; OdinDocWriterItemTracker pkgs; @@ -40,26 +41,27 @@ struct OdinDocWriter { OdinDocWriterItemTracker blob; }; -OdinDocEntityIndex odin_doc_add_entity(OdinDocWriter *w, Entity *e); -OdinDocTypeIndex odin_doc_type(OdinDocWriter *w, Type *type); +gb_internal OdinDocEntityIndex odin_doc_add_entity(OdinDocWriter *w, Entity *e); +gb_internal OdinDocTypeIndex odin_doc_type(OdinDocWriter *w, Type *type); template -void odin_doc_writer_item_tracker_init(OdinDocWriterItemTracker *t, isize size) { +gb_internal void odin_doc_writer_item_tracker_init(OdinDocWriterItemTracker *t, isize size) { t->len = size; t->cap = size; } -void odin_doc_writer_prepare(OdinDocWriter *w) { +gb_internal void odin_doc_writer_prepare(OdinDocWriter *w) { + debugf("odin_doc_writer_prepare\n"); w->state = OdinDocWriterState_Preparing; - gbAllocator a = heap_allocator(); - string_map_init(&w->string_cache, a); + string_map_init(&w->string_cache); - map_init(&w->file_cache, a); - map_init(&w->pkg_cache, a); - map_init(&w->entity_cache, a); - map_init(&w->type_cache, a); + map_init(&w->file_cache); + map_init(&w->pkg_cache); + map_init(&w->entity_cache); + map_init(&w->type_cache); + map_init(&w->stable_type_cache); odin_doc_writer_item_tracker_init(&w->files, 1); odin_doc_writer_item_tracker_init(&w->pkgs, 1); @@ -70,7 +72,8 @@ void odin_doc_writer_prepare(OdinDocWriter *w) { } -void odin_doc_writer_destroy(OdinDocWriter *w) { +gb_internal void odin_doc_writer_destroy(OdinDocWriter *w) { + debugf("odin_doc_writer_destroy\n"); gb_free(heap_allocator(), w->data); string_map_destroy(&w->string_cache); @@ -78,12 +81,13 @@ void odin_doc_writer_destroy(OdinDocWriter *w) { map_destroy(&w->pkg_cache); map_destroy(&w->entity_cache); map_destroy(&w->type_cache); + map_destroy(&w->stable_type_cache); } template -void odin_doc_writer_tracker_size(isize *offset, OdinDocWriterItemTracker *t, isize alignment=1) { +gb_internal void odin_doc_writer_tracker_size(isize *offset, OdinDocWriterItemTracker *t, isize alignment=1) { isize size = t->cap*gb_size_of(T); isize align = gb_max(gb_align_of(T), alignment); *offset = align_formula_isize(*offset, align); @@ -91,7 +95,7 @@ void odin_doc_writer_tracker_size(isize *offset, OdinDocWriterItemTracker *t, *offset += size; } -isize odin_doc_writer_calc_total_size(OdinDocWriter *w) { +gb_internal isize odin_doc_writer_calc_total_size(OdinDocWriter *w) { isize total_size = gb_size_of(OdinDocHeader); odin_doc_writer_tracker_size(&total_size, &w->files); odin_doc_writer_tracker_size(&total_size, &w->pkgs); @@ -102,7 +106,8 @@ isize odin_doc_writer_calc_total_size(OdinDocWriter *w) { return total_size; } -void odin_doc_writer_start_writing(OdinDocWriter *w) { +gb_internal void odin_doc_writer_start_writing(OdinDocWriter *w) { + debugf("odin_doc_writer_start_writing\n"); w->state = OdinDocWriterState_Writing; string_map_clear(&w->string_cache); @@ -118,7 +123,7 @@ void odin_doc_writer_start_writing(OdinDocWriter *w) { w->header = cast(OdinDocHeader *)w->data; } -u32 hash_data_after_header(OdinDocHeaderBase *base, void *data, isize data_len) { +gb_internal u32 hash_data_after_header(OdinDocHeaderBase *base, void *data, isize data_len) { u8 *start = cast(u8 *)data; u8 *end = start + base->total_size; start += base->header_size; @@ -132,13 +137,14 @@ u32 hash_data_after_header(OdinDocHeaderBase *base, void *data, isize data_len) template -void odin_doc_writer_assign_tracker(OdinDocArray *array, OdinDocWriterItemTracker const &t) { +gb_internal void odin_doc_writer_assign_tracker(OdinDocArray *array, OdinDocWriterItemTracker const &t) { array->offset = cast(u32)t.offset; array->length = cast(u32)t.len; } -void odin_doc_writer_end_writing(OdinDocWriter *w) { +gb_internal void odin_doc_writer_end_writing(OdinDocWriter *w) { + debugf("odin_doc_writer_end_writing\n"); OdinDocHeader *h = w->header; gb_memmove(h->base.magic, OdinDocHeader_MagicString, gb_strlen(OdinDocHeader_MagicString)); @@ -156,7 +162,7 @@ void odin_doc_writer_end_writing(OdinDocWriter *w) { } template -u32 odin_doc_write_item(OdinDocWriter *w, OdinDocWriterItemTracker *t, T const *item, T **dst=nullptr) { +gb_internal u32 odin_doc_write_item(OdinDocWriter *w, OdinDocWriterItemTracker *t, T const *item, T **dst=nullptr) { if (w->state == OdinDocWriterState_Preparing) { t->cap += 1; if (dst) *dst = nullptr; @@ -175,7 +181,7 @@ u32 odin_doc_write_item(OdinDocWriter *w, OdinDocWriterItemTracker *t, T cons } template -T *odin_doc_get_item(OdinDocWriter *w, OdinDocWriterItemTracker *t, u32 index) { +gb_internal T *odin_doc_get_item(OdinDocWriter *w, OdinDocWriterItemTracker *t, u32 index) { if (w->state != OdinDocWriterState_Writing) { return nullptr; } @@ -184,7 +190,7 @@ T *odin_doc_get_item(OdinDocWriter *w, OdinDocWriterItemTracker *t, u32 index return cast(T *)data; } -OdinDocString odin_doc_write_string_without_cache(OdinDocWriter *w, String const &str) { +gb_internal OdinDocString odin_doc_write_string_without_cache(OdinDocWriter *w, String const &str) { OdinDocString res = {}; if (w->state == OdinDocWriterState_Preparing) { @@ -204,7 +210,7 @@ OdinDocString odin_doc_write_string_without_cache(OdinDocWriter *w, String const return res; } -OdinDocString odin_doc_write_string(OdinDocWriter *w, String const &str) { +gb_internal OdinDocString odin_doc_write_string(OdinDocWriter *w, String const &str) { OdinDocString *c = string_map_get(&w->string_cache, str); if (c != nullptr) { if (w->state == OdinDocWriterState_Writing) { @@ -223,7 +229,7 @@ OdinDocString odin_doc_write_string(OdinDocWriter *w, String const &str) { template -OdinDocArray odin_write_slice(OdinDocWriter *w, T *data, isize len) { +gb_internal OdinDocArray odin_write_slice(OdinDocWriter *w, T *data, isize len) { GB_ASSERT(gb_align_of(T) <= 4); if (len <= 0) { return {0, 0}; @@ -249,12 +255,12 @@ OdinDocArray odin_write_slice(OdinDocWriter *w, T *data, isize len) { template -OdinDocArray odin_write_item_as_slice(OdinDocWriter *w, T data) { +gb_internal OdinDocArray odin_write_item_as_slice(OdinDocWriter *w, T data) { return odin_write_slice(w, &data, 1); } -OdinDocPosition odin_doc_token_pos_cast(OdinDocWriter *w, TokenPos const &pos) { +gb_internal OdinDocPosition odin_doc_token_pos_cast(OdinDocWriter *w, TokenPos const &pos) { OdinDocFileIndex file_index = 0; if (pos.file_id != 0) { AstFile *file = global_files[pos.file_id]; @@ -273,7 +279,7 @@ OdinDocPosition odin_doc_token_pos_cast(OdinDocWriter *w, TokenPos const &pos) { return doc_pos; } -bool odin_doc_append_comment_group_string(Array *buf, CommentGroup *g) { +gb_internal bool odin_doc_append_comment_group_string(Array *buf, CommentGroup *g) { if (g == nullptr) { return false; } @@ -361,7 +367,7 @@ bool odin_doc_append_comment_group_string(Array *buf, CommentGroup *g) { return false; } -OdinDocString odin_doc_pkg_doc_string(OdinDocWriter *w, AstPackage *pkg) { +gb_internal OdinDocString odin_doc_pkg_doc_string(OdinDocWriter *w, AstPackage *pkg) { if (pkg == nullptr) { return {}; } @@ -378,7 +384,7 @@ OdinDocString odin_doc_pkg_doc_string(OdinDocWriter *w, AstPackage *pkg) { return odin_doc_write_string_without_cache(w, make_string(buf.data, buf.count)); } -OdinDocString odin_doc_comment_group_string(OdinDocWriter *w, CommentGroup *g) { +gb_internal OdinDocString odin_doc_comment_group_string(OdinDocWriter *w, CommentGroup *g) { if (g == nullptr) { return {}; } @@ -389,7 +395,7 @@ OdinDocString odin_doc_comment_group_string(OdinDocWriter *w, CommentGroup *g) { return odin_doc_write_string_without_cache(w, make_string(buf.data, buf.count)); } -OdinDocString odin_doc_expr_string(OdinDocWriter *w, Ast *expr) { +gb_internal OdinDocString odin_doc_expr_string(OdinDocWriter *w, Ast *expr) { if (expr == nullptr) { return {}; } @@ -402,7 +408,7 @@ OdinDocString odin_doc_expr_string(OdinDocWriter *w, Ast *expr) { return odin_doc_write_string(w, make_string(cast(u8 *)s, gb_string_length(s))); } -OdinDocArray odin_doc_attributes(OdinDocWriter *w, Array const &attributes) { +gb_internal OdinDocArray odin_doc_attributes(OdinDocWriter *w, Array const &attributes) { isize count = 0; for_array(i, attributes) { Ast *attr = attributes[i]; @@ -448,7 +454,7 @@ OdinDocArray odin_doc_attributes(OdinDocWriter *w, Array odin_doc_where_clauses(OdinDocWriter *w, Slice const &where_clauses) { +gb_internal OdinDocArray odin_doc_where_clauses(OdinDocWriter *w, Slice const &where_clauses) { if (where_clauses.count == 0) { return {}; } @@ -462,32 +468,70 @@ OdinDocArray odin_doc_where_clauses(OdinDocWriter *w, Slice odin_doc_type_as_slice(OdinDocWriter *w, Type *type) { +gb_internal OdinDocArray odin_doc_type_as_slice(OdinDocWriter *w, Type *type) { OdinDocTypeIndex index = odin_doc_type(w, type); return odin_write_item_as_slice(w, index); } -OdinDocArray odin_doc_add_entity_as_slice(OdinDocWriter *w, Entity *e) { +gb_internal OdinDocArray odin_doc_add_entity_as_slice(OdinDocWriter *w, Entity *e) { OdinDocEntityIndex index = odin_doc_add_entity(w, e); return odin_write_item_as_slice(w, index); } -OdinDocTypeIndex odin_doc_type(OdinDocWriter *w, Type *type) { + + +gb_internal OdinDocTypeIndex odin_doc_type(OdinDocWriter *w, Type *type) { if (type == nullptr) { return 0; } + + // Type **mapped_type = map_get(&w->stable_type_cache, type); // may map to itself + // if (mapped_type && *mapped_type) { + // type = *mapped_type; + // } + OdinDocTypeIndex *found = map_get(&w->type_cache, type); if (found) { return *found; } - for_array(i, w->type_cache.entries) { + for (auto const &entry : w->type_cache) { // NOTE(bill): THIS IS SLOW - Type *other = w->type_cache.entries[i].key; - if (are_types_identical_unique_tuples(type, other)) { - OdinDocTypeIndex index = w->type_cache.entries[i].value; - map_set(&w->type_cache, type, index); - return index; + Type *x = type; + Type *y = entry.key; + + if (x == y) { + goto do_set; } + + if (!x | !y) { + continue; + } + + if (x->kind == Type_Named) { + Entity *e = x->Named.type_name; + if (e->TypeName.is_type_alias) { + x = x->Named.base; + } + } + if (y->kind == Type_Named) { + Entity *e = y->Named.type_name; + if (e->TypeName.is_type_alias) { + y = y->Named.base; + } + } + if (x->kind != y->kind) { + continue; + } + + if (!are_types_identical_internal(x, y, true)) { + continue; + } + + do_set: + OdinDocTypeIndex index = entry.value; + map_set(&w->type_cache, type, index); + map_set(&w->stable_type_cache, type, entry.key); + return index; } @@ -496,6 +540,7 @@ OdinDocTypeIndex odin_doc_type(OdinDocWriter *w, Type *type) { OdinDocTypeIndex type_index = 0; type_index = odin_doc_write_item(w, &w->types, &doc_type, &dst); map_set(&w->type_cache, type, type_index); + map_set(&w->stable_type_cache, type, type); switch (type->kind) { case Type_Basic: @@ -750,7 +795,7 @@ OdinDocTypeIndex odin_doc_type(OdinDocWriter *w, Type *type) { } return type_index; } -OdinDocEntityIndex odin_doc_add_entity(OdinDocWriter *w, Entity *e) { +gb_internal OdinDocEntityIndex odin_doc_add_entity(OdinDocWriter *w, Entity *e) { if (e == nullptr) { return 0; } @@ -857,14 +902,12 @@ OdinDocEntityIndex odin_doc_add_entity(OdinDocWriter *w, Entity *e) { break; } - if (e->flags & EntityFlag_Param) { - if (e->flags & EntityFlag_Using) { flags |= OdinDocEntityFlag_Param_Using; } - if (e->flags & EntityFlag_ConstInput) { flags |= OdinDocEntityFlag_Param_Const; } - if (e->flags & EntityFlag_AutoCast) { flags |= OdinDocEntityFlag_Param_AutoCast; } - if (e->flags & EntityFlag_Ellipsis) { flags |= OdinDocEntityFlag_Param_Ellipsis; } - if (e->flags & EntityFlag_NoAlias) { flags |= OdinDocEntityFlag_Param_NoAlias; } - if (e->flags & EntityFlag_AnyInt) { flags |= OdinDocEntityFlag_Param_AnyInt; } - } + if (e->flags & EntityFlag_Using) { flags |= OdinDocEntityFlag_Param_Using; } + if (e->flags & EntityFlag_ConstInput) { flags |= OdinDocEntityFlag_Param_Const; } + if (e->flags & EntityFlag_Ellipsis) { flags |= OdinDocEntityFlag_Param_Ellipsis; } + if (e->flags & EntityFlag_NoAlias) { flags |= OdinDocEntityFlag_Param_NoAlias; } + if (e->flags & EntityFlag_AnyInt) { flags |= OdinDocEntityFlag_Param_AnyInt; } + if (e->scope && (e->scope->flags & (ScopeFlag_File|ScopeFlag_Pkg)) && !is_entity_exported(e)) { flags |= OdinDocEntityFlag_Private; } @@ -911,24 +954,26 @@ OdinDocEntityIndex odin_doc_add_entity(OdinDocWriter *w, Entity *e) { return doc_entity_index; } -void odin_doc_update_entities(OdinDocWriter *w) { +gb_internal void odin_doc_update_entities(OdinDocWriter *w) { + debugf("odin_doc_update_entities %s\n", w->state ? "preparing" : "writing"); + { // NOTE(bill): Double pass, just in case entities are created on odin_doc_type - auto entities = array_make(heap_allocator(), w->entity_cache.entries.count); + auto entities = array_make(heap_allocator(), 0, w->entity_cache.count); defer (array_free(&entities)); - for_array(i, w->entity_cache.entries) { + for (u32 i = 0; i < w->entity_cache.count; i++) { Entity *e = w->entity_cache.entries[i].key; - entities[i] = e; + array_add(&entities, e); } - for_array(i, entities) { - Entity *e = entities[i]; + for (Entity *e : entities) { + GB_ASSERT(e != nullptr); OdinDocTypeIndex type_index = odin_doc_type(w, e->type); gb_unused(type_index); } } - for_array(i, w->entity_cache.entries) { + for (u32 i = 0; i < w->entity_cache.count; i++) { Entity *e = w->entity_cache.entries[i].key; OdinDocEntityIndex entity_index = w->entity_cache.entries[i].value; OdinDocTypeIndex type_index = odin_doc_type(w, e->type); @@ -948,8 +993,8 @@ void odin_doc_update_entities(OdinDocWriter *w) { auto pges = array_make(heap_allocator(), 0, e->ProcGroup.entities.count); defer (array_free(&pges)); - for_array(j, e->ProcGroup.entities) { - OdinDocEntityIndex index = odin_doc_add_entity(w, e->ProcGroup.entities[j]); + for (Entity *entity : e->ProcGroup.entities) { + OdinDocEntityIndex index = odin_doc_add_entity(w, entity); array_add(&pges, index); } grouped_entities = odin_write_slice(w, pges.data, pges.count); @@ -968,7 +1013,7 @@ void odin_doc_update_entities(OdinDocWriter *w) { -OdinDocArray odin_doc_add_pkg_entries(OdinDocWriter *w, AstPackage *pkg) { +gb_internal OdinDocArray odin_doc_add_pkg_entries(OdinDocWriter *w, AstPackage *pkg) { if (pkg->scope == nullptr) { return {}; } @@ -976,12 +1021,14 @@ OdinDocArray odin_doc_add_pkg_entries(OdinDocWriter *w, AstPa return {}; } - auto entries = array_make(heap_allocator(), 0, w->entity_cache.entries.count); + debugf("odin_doc_add_pkg_entries %s -> package %.*s\n", w->state ? "preparing" : "writing", LIT(pkg->name)); + + auto entries = array_make(heap_allocator(), 0, w->entity_cache.count); defer (array_free(&entries)); - for_array(i, pkg->scope->elements.entries) { - String name = pkg->scope->elements.entries[i].key.string; - Entity *e = pkg->scope->elements.entries[i].value; + for (auto const &element : pkg->scope->elements) { + String name = element.key; + Entity *e = element.value; switch (e->kind) { case Entity_Invalid: case Entity_Nil: @@ -1018,11 +1065,13 @@ OdinDocArray odin_doc_add_pkg_entries(OdinDocWriter *w, AstPa } -void odin_doc_write_docs(OdinDocWriter *w) { - auto pkgs = array_make(heap_allocator(), 0, w->info->packages.entries.count); +gb_internal void odin_doc_write_docs(OdinDocWriter *w) { + debugf("odin_doc_write_docs %s", w->state ? "preparing" : "writing"); + + auto pkgs = array_make(heap_allocator(), 0, w->info->packages.count); defer (array_free(&pkgs)); - for_array(i, w->info->packages.entries) { - AstPackage *pkg = w->info->packages.entries[i].value; + for (auto const &entry : w->info->packages) { + AstPackage *pkg = entry.value; if (build_context.cmd_doc_flags & CmdDocFlag_AllPackages) { array_add(&pkgs, pkg); } else { @@ -1034,6 +1083,7 @@ void odin_doc_write_docs(OdinDocWriter *w) { } } + debugf("odin_doc_update_entities sort pkgs %s\n", w->state ? "preparing" : "writing"); gb_sort_array(pkgs.data, pkgs.count, cmp_ast_package_by_name); for_array(i, pkgs) { @@ -1093,7 +1143,8 @@ void odin_doc_write_docs(OdinDocWriter *w) { } -void odin_doc_write_to_file(OdinDocWriter *w, char const *filename) { +gb_internal void odin_doc_write_to_file(OdinDocWriter *w, char const *filename) { + debugf("odin_doc_write_to_file %s\n", filename); gbFile f = {}; gbFileError err = gb_file_open_mode(&f, gbFileMode_Write, filename); if (err != gbFileError_None) { @@ -1104,16 +1155,19 @@ void odin_doc_write_to_file(OdinDocWriter *w, char const *filename) { defer (gb_file_close(&f)); if (gb_file_write(&f, w->data, w->data_len)) { err = gb_file_truncate(&f, w->data_len); + debugf("Wrote .odin-doc file to: %s\n", filename); gb_printf("Wrote .odin-doc file to: %s\n", filename); } } -void odin_doc_write(CheckerInfo *info, char const *filename) { +gb_internal void odin_doc_write(CheckerInfo *info, char const *filename) { OdinDocWriter w_ = {}; OdinDocWriter *w = &w_; defer (odin_doc_writer_destroy(w)); w->info = info; + debugf("odin_doc_write %s\n", filename); + odin_doc_writer_prepare(w); odin_doc_write_docs(w); diff --git a/src/entity.cpp b/src/entity.cpp index 3d3712328..d6f4edece 100644 --- a/src/entity.cpp +++ b/src/entity.cpp @@ -26,7 +26,7 @@ enum EntityKind { Entity_Count, }; -String const entity_strings[] = { +gb_global String const entity_strings[] = { #define ENTITY_KIND(k) {cast(u8 *)#k, gb_size_of(#k)-1}, ENTITY_KINDS #undef ENTITY_KIND @@ -61,7 +61,7 @@ enum EntityFlag : u64 { EntityFlag_ProcBodyChecked = 1ull<<21, EntityFlag_CVarArg = 1ull<<22, - EntityFlag_AutoCast = 1ull<<23, + EntityFlag_AnyInt = 1ull<<24, EntityFlag_Disabled = 1ull<<25, @@ -75,6 +75,7 @@ enum EntityFlag : u64 { EntityFlag_Test = 1ull<<30, EntityFlag_Init = 1ull<<31, EntityFlag_Subtype = 1ull<<32, + EntityFlag_Fini = 1ull<<33, EntityFlag_CustomLinkName = 1ull<<40, EntityFlag_CustomLinkage_Internal = 1ull<<41, @@ -116,7 +117,7 @@ struct ParameterValue { }; }; -bool has_parameter_value(ParameterValue const ¶m_value) { +gb_internal gb_inline bool has_parameter_value(ParameterValue const ¶m_value) { if (param_value.kind != ParameterValue_Invalid) { return true; } @@ -130,7 +131,7 @@ enum EntityConstantFlags : u32 { EntityConstantFlag_ImplicitEnumValue = 1<<0, }; -enum ProcedureOptimizationMode : u32 { +enum ProcedureOptimizationMode : u8 { ProcedureOptimizationMode_Default, ProcedureOptimizationMode_None, ProcedureOptimizationMode_Minimal, @@ -151,10 +152,9 @@ struct TypeNameObjCMetadata { Array value_entries; }; -TypeNameObjCMetadata *create_type_name_obj_c_metadata() { +gb_internal TypeNameObjCMetadata *create_type_name_obj_c_metadata() { TypeNameObjCMetadata *md = gb_alloc_item(permanent_allocator(), TypeNameObjCMetadata); md->mutex = gb_alloc_item(permanent_allocator(), BlockingMutex); - mutex_init(md->mutex); array_init(&md->type_entries, heap_allocator()); array_init(&md->value_entries, heap_allocator()); return md; @@ -234,6 +234,9 @@ struct Entity { String link_name; String link_prefix; DeferredProcedure deferred_procedure; + + struct GenProcsData *gen_procs; + BlockingMutex gen_procs_mutex; ProcedureOptimizationMode optimization_mode; bool is_foreign : 1; bool is_export : 1; @@ -256,6 +259,7 @@ struct Entity { Slice paths; String name; i64 priority_index; + String extra_linker_flags; } LibraryName; i32 Nil; struct { @@ -266,7 +270,7 @@ struct Entity { }; }; -bool is_entity_kind_exported(EntityKind kind, bool allow_builtin = false) { +gb_internal bool is_entity_kind_exported(EntityKind kind, bool allow_builtin = false) { switch (kind) { case Entity_Builtin: return allow_builtin; @@ -278,7 +282,7 @@ bool is_entity_kind_exported(EntityKind kind, bool allow_builtin = false) { return true; } -bool is_entity_exported(Entity *e, bool allow_builtin = false) { +gb_internal bool is_entity_exported(Entity *e, bool allow_builtin = false) { // TODO(bill): Determine the actual exportation rules for imports of entities GB_ASSERT(e != nullptr); if (!is_entity_kind_exported(e->kind, allow_builtin)) { @@ -300,7 +304,7 @@ bool is_entity_exported(Entity *e, bool allow_builtin = false) { return true; } -bool entity_has_deferred_procedure(Entity *e) { +gb_internal bool entity_has_deferred_procedure(Entity *e) { GB_ASSERT(e != nullptr); if (e->kind == Entity_Procedure) { return e->Procedure.deferred_procedure.entity != nullptr; @@ -311,7 +315,7 @@ bool entity_has_deferred_procedure(Entity *e) { gb_global std::atomic global_entity_id; -Entity *alloc_entity(EntityKind kind, Scope *scope, Token token, Type *type) { +gb_internal Entity *alloc_entity(EntityKind kind, Scope *scope, Token token, Type *type) { gbAllocator a = permanent_allocator(); Entity *entity = gb_alloc_item(a, Entity); entity->kind = kind; @@ -323,13 +327,13 @@ Entity *alloc_entity(EntityKind kind, Scope *scope, Token token, Type *type) { return entity; } -Entity *alloc_entity_variable(Scope *scope, Token token, Type *type, EntityState state = EntityState_Unresolved) { +gb_internal Entity *alloc_entity_variable(Scope *scope, Token token, Type *type, EntityState state = EntityState_Unresolved) { Entity *entity = alloc_entity(Entity_Variable, scope, token, type); entity->state = state; return entity; } -Entity *alloc_entity_using_variable(Entity *parent, Token token, Type *type, Ast *using_expr) { +gb_internal Entity *alloc_entity_using_variable(Entity *parent, Token token, Type *type, Ast *using_expr) { GB_ASSERT(parent != nullptr); token.pos = parent->token.pos; Entity *entity = alloc_entity(Entity_Variable, parent->scope, token, type); @@ -343,19 +347,19 @@ Entity *alloc_entity_using_variable(Entity *parent, Token token, Type *type, Ast } -Entity *alloc_entity_constant(Scope *scope, Token token, Type *type, ExactValue value) { +gb_internal Entity *alloc_entity_constant(Scope *scope, Token token, Type *type, ExactValue value) { Entity *entity = alloc_entity(Entity_Constant, scope, token, type); entity->Constant.value = value; return entity; } -Entity *alloc_entity_type_name(Scope *scope, Token token, Type *type, EntityState state = EntityState_Unresolved) { +gb_internal Entity *alloc_entity_type_name(Scope *scope, Token token, Type *type, EntityState state = EntityState_Unresolved) { Entity *entity = alloc_entity(Entity_TypeName, scope, token, type); entity->state = state; return entity; } -Entity *alloc_entity_param(Scope *scope, Token token, Type *type, bool is_using, bool is_value) { +gb_internal Entity *alloc_entity_param(Scope *scope, Token token, Type *type, bool is_using, bool is_value) { Entity *entity = alloc_entity_variable(scope, token, type); entity->flags |= EntityFlag_Used; entity->flags |= EntityFlag_Param; @@ -366,7 +370,7 @@ Entity *alloc_entity_param(Scope *scope, Token token, Type *type, bool is_using, } -Entity *alloc_entity_const_param(Scope *scope, Token token, Type *type, ExactValue value, bool poly_const) { +gb_internal Entity *alloc_entity_const_param(Scope *scope, Token token, Type *type, ExactValue value, bool poly_const) { Entity *entity = alloc_entity_constant(scope, token, type, value); entity->flags |= EntityFlag_Used; if (poly_const) entity->flags |= EntityFlag_PolyConst; @@ -375,7 +379,7 @@ Entity *alloc_entity_const_param(Scope *scope, Token token, Type *type, ExactVal } -Entity *alloc_entity_field(Scope *scope, Token token, Type *type, bool is_using, i32 field_index, EntityState state = EntityState_Unresolved) { +gb_internal Entity *alloc_entity_field(Scope *scope, Token token, Type *type, bool is_using, i32 field_index, EntityState state = EntityState_Unresolved) { Entity *entity = alloc_entity_variable(scope, token, type); entity->Variable.field_index = field_index; if (is_using) entity->flags |= EntityFlag_Using; @@ -384,7 +388,7 @@ Entity *alloc_entity_field(Scope *scope, Token token, Type *type, bool is_using, return entity; } -Entity *alloc_entity_array_elem(Scope *scope, Token token, Type *type, i32 field_index) { +gb_internal Entity *alloc_entity_array_elem(Scope *scope, Token token, Type *type, i32 field_index) { Entity *entity = alloc_entity_variable(scope, token, type); entity->Variable.field_index = field_index; entity->flags |= EntityFlag_Field; @@ -393,26 +397,18 @@ Entity *alloc_entity_array_elem(Scope *scope, Token token, Type *type, i32 field return entity; } -Entity *alloc_entity_procedure(Scope *scope, Token token, Type *signature_type, u64 tags) { +gb_internal Entity *alloc_entity_procedure(Scope *scope, Token token, Type *signature_type, u64 tags) { Entity *entity = alloc_entity(Entity_Procedure, scope, token, signature_type); entity->Procedure.tags = tags; return entity; } -Entity *alloc_entity_proc_group(Scope *scope, Token token, Type *type) { +gb_internal Entity *alloc_entity_proc_group(Scope *scope, Token token, Type *type) { Entity *entity = alloc_entity(Entity_ProcGroup, scope, token, type); return entity; } - -Entity *alloc_entity_builtin(Scope *scope, Token token, Type *type, i32 id) { - Entity *entity = alloc_entity(Entity_Builtin, scope, token, type); - entity->Builtin.id = id; - entity->state = EntityState_Resolved; - return entity; -} - -Entity *alloc_entity_import_name(Scope *scope, Token token, Type *type, +gb_internal Entity *alloc_entity_import_name(Scope *scope, Token token, Type *type, String path, String name, Scope *import_scope) { Entity *entity = alloc_entity(Entity_ImportName, scope, token, type); entity->ImportName.path = path; @@ -422,7 +418,7 @@ Entity *alloc_entity_import_name(Scope *scope, Token token, Type *type, return entity; } -Entity *alloc_entity_library_name(Scope *scope, Token token, Type *type, +gb_internal Entity *alloc_entity_library_name(Scope *scope, Token token, Type *type, Slice paths, String name) { Entity *entity = alloc_entity(Entity_LibraryName, scope, token, type); entity->LibraryName.paths = paths; @@ -435,12 +431,12 @@ Entity *alloc_entity_library_name(Scope *scope, Token token, Type *type, -Entity *alloc_entity_nil(String name, Type *type) { +gb_internal Entity *alloc_entity_nil(String name, Type *type) { Entity *entity = alloc_entity(Entity_Nil, nullptr, make_token_ident(name), type); return entity; } -Entity *alloc_entity_label(Scope *scope, Token token, Type *type, Ast *node, Ast *parent) { +gb_internal Entity *alloc_entity_label(Scope *scope, Token token, Type *type, Ast *node, Ast *parent) { Entity *entity = alloc_entity(Entity_Label, scope, token, type); entity->Label.node = node; entity->Label.parent = parent; @@ -448,15 +444,15 @@ Entity *alloc_entity_label(Scope *scope, Token token, Type *type, Ast *node, Ast return entity; } -Entity *alloc_entity_dummy_variable(Scope *scope, Token token) { +gb_internal Entity *alloc_entity_dummy_variable(Scope *scope, Token token) { token.string = str_lit("_"); return alloc_entity_variable(scope, token, nullptr); } -Entity *entity_from_expr(Ast *expr); +gb_internal Entity *entity_from_expr(Ast *expr); -Entity *strip_entity_wrapping(Entity *e) { +gb_internal Entity *strip_entity_wrapping(Entity *e) { if (e == nullptr) { return nullptr; } @@ -469,7 +465,7 @@ Entity *strip_entity_wrapping(Entity *e) { return e; } -Entity *strip_entity_wrapping(Ast *expr) { +gb_internal Entity *strip_entity_wrapping(Ast *expr) { Entity *e = entity_from_expr(expr); return strip_entity_wrapping(e); } diff --git a/src/error.cpp b/src/error.cpp index faf4d11fb..eb010eb36 100644 --- a/src/error.cpp +++ b/src/error.cpp @@ -8,36 +8,33 @@ struct ErrorCollector { BlockingMutex string_mutex; RecursiveMutex block_mutex; - Array error_buffer; - Array errors; + RecursiveMutex error_buffer_mutex; + Array error_buffer; + Array errors; }; gb_global ErrorCollector global_error_collector; -#define MAX_ERROR_COLLECTOR_COUNT (36) - -bool any_errors(void) { +gb_internal bool any_errors(void) { return global_error_collector.count.load() != 0; } -void init_global_error_collector(void) { - mutex_init(&global_error_collector.mutex); - mutex_init(&global_error_collector.block_mutex); - mutex_init(&global_error_collector.error_out_mutex); - mutex_init(&global_error_collector.string_mutex); +gb_internal void init_global_error_collector(void) { array_init(&global_error_collector.errors, heap_allocator()); array_init(&global_error_collector.error_buffer, heap_allocator()); array_init(&global_file_path_strings, heap_allocator(), 1, 4096); array_init(&global_files, heap_allocator(), 1, 4096); } +gb_internal isize MAX_ERROR_COLLECTOR_COUNT(void); + // temporary // defined in build_settings.cpp -char *token_pos_to_string(TokenPos const &pos); +gb_internal char *token_pos_to_string(TokenPos const &pos); -bool set_file_path_string(i32 index, String const &path) { +gb_internal bool set_file_path_string(i32 index, String const &path) { bool ok = false; GB_ASSERT(index >= 0); mutex_lock(&global_error_collector.string_mutex); @@ -55,7 +52,7 @@ bool set_file_path_string(i32 index, String const &path) { return ok; } -bool thread_safe_set_ast_file_from_id(i32 index, AstFile *file) { +gb_internal bool thread_safe_set_ast_file_from_id(i32 index, AstFile *file) { bool ok = false; GB_ASSERT(index >= 0); mutex_lock(&global_error_collector.string_mutex); @@ -73,7 +70,7 @@ bool thread_safe_set_ast_file_from_id(i32 index, AstFile *file) { return ok; } -String get_file_path_string(i32 index) { +gb_internal String get_file_path_string(i32 index) { GB_ASSERT(index >= 0); mutex_lock(&global_error_collector.string_mutex); @@ -86,7 +83,7 @@ String get_file_path_string(i32 index) { return path; } -AstFile *thread_safe_get_ast_file_from_id(i32 index) { +gb_internal AstFile *thread_safe_get_ast_file_from_id(i32 index) { GB_ASSERT(index >= 0); mutex_lock(&global_error_collector.string_mutex); @@ -101,22 +98,70 @@ AstFile *thread_safe_get_ast_file_from_id(i32 index) { -void begin_error_block(void) { +// NOTE: defined in build_settings.cpp +gb_internal bool global_warnings_as_errors(void); +gb_internal bool global_ignore_warnings(void); +gb_internal bool show_error_line(void); +gb_internal bool has_ansi_terminal_colours(void); +gb_internal gbString get_file_line_as_string(TokenPos const &pos, i32 *offset); + +gb_internal void warning(Token const &token, char const *fmt, ...); +gb_internal void error(Token const &token, char const *fmt, ...); +gb_internal void error(TokenPos pos, char const *fmt, ...); +gb_internal void error_line(char const *fmt, ...); +gb_internal void syntax_error(Token const &token, char const *fmt, ...); +gb_internal void syntax_error(TokenPos pos, char const *fmt, ...); +gb_internal void syntax_warning(Token const &token, char const *fmt, ...); +gb_internal void compiler_error(char const *fmt, ...); + +gb_internal void begin_error_block(void) { mutex_lock(&global_error_collector.block_mutex); global_error_collector.in_block.store(true); } -void end_error_block(void) { - if (global_error_collector.error_buffer.count > 0) { - isize n = global_error_collector.error_buffer.count; - u8 *text = gb_alloc_array(permanent_allocator(), u8, n+1); +gb_internal void end_error_block(void) { + mutex_lock(&global_error_collector.error_buffer_mutex); + isize n = global_error_collector.error_buffer.count; + if (n > 0) { + u8 *text = global_error_collector.error_buffer.data; + + bool add_extra_newline = false; + + if (show_error_line()) { + if (n >= 2 && !(text[n-2] == '\n' && text[n-1] == '\n')) { + add_extra_newline = true; + } + } else { + isize newline_count = 0; + for (isize i = 0; i < n; i++) { + if (text[i] == '\n') { + newline_count += 1; + } + } + if (newline_count > 1) { + add_extra_newline = true; + } + } + + if (add_extra_newline) { + // add an extra new line as padding when the error line is being shown + error_line("\n"); + } + + n = global_error_collector.error_buffer.count; + text = gb_alloc_array(permanent_allocator(), u8, n+1); gb_memmove(text, global_error_collector.error_buffer.data, n); text[n] = 0; + + + mutex_lock(&global_error_collector.error_out_mutex); String s = {text, n}; array_add(&global_error_collector.errors, s); + mutex_unlock(&global_error_collector.error_out_mutex); + global_error_collector.error_buffer.count = 0; } - + mutex_unlock(&global_error_collector.error_buffer_mutex); global_error_collector.in_block.store(false); mutex_unlock(&global_error_collector.block_mutex); } @@ -127,18 +172,22 @@ void end_error_block(void) { #define ERROR_OUT_PROC(name) void name(char const *fmt, va_list va) typedef ERROR_OUT_PROC(ErrorOutProc); -ERROR_OUT_PROC(default_error_out_va) { +gb_internal ERROR_OUT_PROC(default_error_out_va) { gbFile *f = gb_file_get_standard(gbFileStandard_Error); char buf[4096] = {}; isize len = gb_snprintf_va(buf, gb_size_of(buf), fmt, va); isize n = len-1; if (global_error_collector.in_block) { + mutex_lock(&global_error_collector.error_buffer_mutex); + isize cap = global_error_collector.error_buffer.count + n; array_reserve(&global_error_collector.error_buffer, cap); u8 *data = global_error_collector.error_buffer.data + global_error_collector.error_buffer.count; gb_memmove(data, buf, n); global_error_collector.error_buffer.count += n; + + mutex_unlock(&global_error_collector.error_buffer_mutex); } else { mutex_lock(&global_error_collector.error_out_mutex); { @@ -153,24 +202,60 @@ ERROR_OUT_PROC(default_error_out_va) { gb_file_write(f, buf, n); } +gb_global ErrorOutProc *error_out_va = default_error_out_va; -ErrorOutProc *error_out_va = default_error_out_va; - -// NOTE: defined in build_settings.cpp -bool global_warnings_as_errors(void); -bool global_ignore_warnings(void); -bool show_error_line(void); -gbString get_file_line_as_string(TokenPos const &pos, i32 *offset); - -void error_out(char const *fmt, ...) { +gb_internal void error_out(char const *fmt, ...) { va_list va; va_start(va, fmt); error_out_va(fmt, va); va_end(va); } +enum TerminalStyle { + TerminalStyle_Normal, + TerminalStyle_Bold, + TerminalStyle_Underline, +}; -bool show_error_on_line(TokenPos const &pos, TokenPos end) { +enum TerminalColour { + TerminalColour_White, + TerminalColour_Red, + TerminalColour_Yellow, + TerminalColour_Green, + TerminalColour_Cyan, + TerminalColour_Blue, + TerminalColour_Purple, + TerminalColour_Black, +}; + +gb_internal void terminal_set_colours(TerminalStyle style, TerminalColour foreground) { + if (has_ansi_terminal_colours()) { + char const *ss = "0"; + switch (style) { + case TerminalStyle_Normal: ss = "0"; break; + case TerminalStyle_Bold: ss = "1"; break; + case TerminalStyle_Underline: ss = "4"; break; + } + switch (foreground) { + case TerminalColour_White: error_out("\x1b[%s;37m", ss); break; + case TerminalColour_Red: error_out("\x1b[%s;31m", ss); break; + case TerminalColour_Yellow: error_out("\x1b[%s;33m", ss); break; + case TerminalColour_Green: error_out("\x1b[%s;32m", ss); break; + case TerminalColour_Cyan: error_out("\x1b[%s;36m", ss); break; + case TerminalColour_Blue: error_out("\x1b[%s;34m", ss); break; + case TerminalColour_Purple: error_out("\x1b[%s;35m", ss); break; + case TerminalColour_Black: error_out("\x1b[%s;30m", ss); break; + } + } +} +gb_internal void terminal_reset_colours(void) { + if (has_ansi_terminal_colours()) { + error_out("\x1b[0m"); + } +} + + +gb_internal bool show_error_on_line(TokenPos const &pos, TokenPos end) { if (!show_error_line()) { return false; } @@ -180,84 +265,121 @@ bool show_error_on_line(TokenPos const &pos, TokenPos end) { defer (gb_string_free(the_line)); if (the_line != nullptr) { - String line = make_string(cast(u8 const *)the_line, gb_string_length(the_line)); + char const *line_text = the_line; + isize line_len = gb_string_length(the_line); // TODO(bill): This assumes ASCII enum { - MAX_LINE_LENGTH = 76, + MAX_LINE_LENGTH = 80, MAX_TAB_WIDTH = 8, - ELLIPSIS_PADDING = 8 + ELLIPSIS_PADDING = 8, // `... ...` + MAX_LINE_LENGTH_PADDED = MAX_LINE_LENGTH-MAX_TAB_WIDTH-ELLIPSIS_PADDING, }; - error_out("\n\t"); - if (line.len+MAX_TAB_WIDTH+ELLIPSIS_PADDING > MAX_LINE_LENGTH) { - i32 const half_width = MAX_LINE_LENGTH/2; - i32 left = cast(i32)(offset); - i32 right = cast(i32)(line.len - offset); - left = gb_min(left, half_width); - right = gb_min(right, half_width); + error_out("\t"); - line.text += offset-left; - line.len -= offset+right-left; + terminal_set_colours(TerminalStyle_Bold, TerminalColour_White); - line = string_trim_whitespace(line); - offset = left + ELLIPSIS_PADDING/2; + i32 error_length = gb_max(end.offset - pos.offset, 1); - error_out("... %.*s ...", LIT(line)); + isize squiggle_extra = 0; + + if (line_len > MAX_LINE_LENGTH_PADDED) { + i32 left = MAX_TAB_WIDTH; + if (offset > 0) { + line_text += offset-left; + line_len -= offset-left; + offset = left+MAX_TAB_WIDTH/2; + } + if (line_len > MAX_LINE_LENGTH_PADDED) { + line_len = MAX_LINE_LENGTH_PADDED; + if (error_length > line_len-left) { + error_length = cast(i32)line_len - left; + squiggle_extra = 1; + } + } + if (offset > 0) { + error_out("... %.*s ...", cast(i32)line_len, line_text); + } else { + error_out("%.*s ...", cast(i32)line_len, line_text); + } } else { - error_out("%.*s", LIT(line)); + error_out("%.*s", cast(i32)line_len, line_text); } error_out("\n\t"); for (i32 i = 0; i < offset; i++) { error_out(" "); } + + terminal_set_colours(TerminalStyle_Bold, TerminalColour_Green); + error_out("^"); if (end.file_id == pos.file_id) { if (end.line > pos.line) { - for (i32 i = offset; i < line.len; i++) { + for (i32 i = offset; i < line_len; i++) { error_out("~"); } } else if (end.line == pos.line && end.column > pos.column) { - i32 length = gb_min(end.offset - pos.offset, cast(i32)(line.len-offset)); - for (i32 i = 1; i < length-1; i++) { + for (i32 i = 1; i < error_length-1+squiggle_extra; i++) { error_out("~"); } - if (length > 1) { + if (error_length > 1 && squiggle_extra == 0) { error_out("^"); } } } - error_out("\n\n"); + terminal_reset_colours(); + + error_out("\n"); return true; } return false; } -void error_va(TokenPos const &pos, TokenPos end, char const *fmt, va_list va) { +gb_internal void error_out_pos(TokenPos pos) { + terminal_set_colours(TerminalStyle_Bold, TerminalColour_White); + error_out("%s ", token_pos_to_string(pos)); + terminal_reset_colours(); +} + +gb_internal void error_out_coloured(char const *str, TerminalStyle style, TerminalColour foreground) { + terminal_set_colours(style, foreground); + error_out(str); + terminal_reset_colours(); +} + + + +gb_internal void error_va(TokenPos const &pos, TokenPos end, char const *fmt, va_list va) { global_error_collector.count.fetch_add(1); mutex_lock(&global_error_collector.mutex); // NOTE(bill): Duplicate error, skip it if (pos.line == 0) { - error_out("Error: %s\n", gb_bprintf_va(fmt, va)); + error_out_coloured("Error: ", TerminalStyle_Normal, TerminalColour_Red); + error_out_va(fmt, va); + error_out("\n"); } else if (global_error_collector.prev != pos) { global_error_collector.prev = pos; - error_out("%s %s\n", - token_pos_to_string(pos), - gb_bprintf_va(fmt, va)); + error_out_pos(pos); + if (has_ansi_terminal_colours()) { + error_out_coloured("Error: ", TerminalStyle_Normal, TerminalColour_Red); + } + error_out_va(fmt, va); + error_out("\n"); show_error_on_line(pos, end); } mutex_unlock(&global_error_collector.mutex); - if (global_error_collector.count > MAX_ERROR_COLLECTOR_COUNT) { + if (global_error_collector.count > MAX_ERROR_COLLECTOR_COUNT()) { gb_exit(1); } } -void warning_va(TokenPos const &pos, TokenPos end, char const *fmt, va_list va) { +gb_internal void warning_va(TokenPos const &pos, TokenPos end, char const *fmt, va_list va) { if (global_warnings_as_errors()) { error_va(pos, end, fmt, va); return; @@ -267,12 +389,15 @@ void warning_va(TokenPos const &pos, TokenPos end, char const *fmt, va_list va) if (!global_ignore_warnings()) { // NOTE(bill): Duplicate error, skip it if (pos.line == 0) { - error_out("Warning: %s\n", gb_bprintf_va(fmt, va)); + error_out_coloured("Warning: ", TerminalStyle_Normal, TerminalColour_Yellow); + error_out_va(fmt, va); + error_out("\n"); } else if (global_error_collector.prev != pos) { global_error_collector.prev = pos; - error_out("%s Warning: %s\n", - token_pos_to_string(pos), - gb_bprintf_va(fmt, va)); + error_out_pos(pos); + error_out_coloured("Warning: ", TerminalStyle_Normal, TerminalColour_Yellow); + error_out_va(fmt, va); + error_out("\n"); show_error_on_line(pos, end); } } @@ -280,50 +405,82 @@ void warning_va(TokenPos const &pos, TokenPos end, char const *fmt, va_list va) } -void error_line_va(char const *fmt, va_list va) { +gb_internal void error_line_va(char const *fmt, va_list va) { error_out_va(fmt, va); } -void error_no_newline_va(TokenPos const &pos, char const *fmt, va_list va) { +gb_internal void error_no_newline_va(TokenPos const &pos, char const *fmt, va_list va) { mutex_lock(&global_error_collector.mutex); global_error_collector.count++; // NOTE(bill): Duplicate error, skip it if (pos.line == 0) { - error_out("Error: %s", gb_bprintf_va(fmt, va)); + error_out_coloured("Error: ", TerminalStyle_Normal, TerminalColour_Red); + error_out_va(fmt, va); } else if (global_error_collector.prev != pos) { global_error_collector.prev = pos; - error_out("%s %s", - token_pos_to_string(pos), - gb_bprintf_va(fmt, va)); + error_out_pos(pos); + if (has_ansi_terminal_colours()) { + error_out_coloured("Error: ", TerminalStyle_Normal, TerminalColour_Red); + } + error_out_va(fmt, va); } mutex_unlock(&global_error_collector.mutex); - if (global_error_collector.count > MAX_ERROR_COLLECTOR_COUNT) { + if (global_error_collector.count > MAX_ERROR_COLLECTOR_COUNT()) { gb_exit(1); } } -void syntax_error_va(TokenPos const &pos, TokenPos end, char const *fmt, va_list va) { +gb_internal void syntax_error_va(TokenPos const &pos, TokenPos end, char const *fmt, va_list va) { mutex_lock(&global_error_collector.mutex); global_error_collector.count++; // NOTE(bill): Duplicate error, skip it if (global_error_collector.prev != pos) { global_error_collector.prev = pos; - error_out("%s Syntax Error: %s\n", - token_pos_to_string(pos), - gb_bprintf_va(fmt, va)); - show_error_on_line(pos, end); + error_out_pos(pos); + error_out_coloured("Syntax Error: ", TerminalStyle_Normal, TerminalColour_Red); + error_out_va(fmt, va); + error_out("\n"); + // show_error_on_line(pos, end); } else if (pos.line == 0) { - error_out("Syntax Error: %s\n", gb_bprintf_va(fmt, va)); + error_out_coloured("Syntax Error: ", TerminalStyle_Normal, TerminalColour_Red); + error_out_va(fmt, va); + error_out("\n"); } mutex_unlock(&global_error_collector.mutex); - if (global_error_collector.count > MAX_ERROR_COLLECTOR_COUNT) { + if (global_error_collector.count > MAX_ERROR_COLLECTOR_COUNT()) { gb_exit(1); } } -void syntax_warning_va(TokenPos const &pos, TokenPos end, char const *fmt, va_list va) { +gb_internal void syntax_error_with_verbose_va(TokenPos const &pos, TokenPos end, char const *fmt, va_list va) { + global_error_collector.count.fetch_add(1); + + mutex_lock(&global_error_collector.mutex); + // NOTE(bill): Duplicate error, skip it + if (pos.line == 0) { + error_out_coloured("Syntax_Error: ", TerminalStyle_Normal, TerminalColour_Red); + error_out_va(fmt, va); + error_out("\n"); + } else if (global_error_collector.prev != pos) { + global_error_collector.prev = pos; + error_out_pos(pos); + if (has_ansi_terminal_colours()) { + error_out_coloured("Syntax_Error: ", TerminalStyle_Normal, TerminalColour_Red); + } + error_out_va(fmt, va); + error_out("\n"); + show_error_on_line(pos, end); + } + mutex_unlock(&global_error_collector.mutex); + if (global_error_collector.count > MAX_ERROR_COLLECTOR_COUNT()) { + gb_exit(1); + } +} + + +gb_internal void syntax_warning_va(TokenPos const &pos, TokenPos end, char const *fmt, va_list va) { if (global_warnings_as_errors()) { syntax_error_va(pos, end, fmt, va); return; @@ -334,12 +491,15 @@ void syntax_warning_va(TokenPos const &pos, TokenPos end, char const *fmt, va_li // NOTE(bill): Duplicate error, skip it if (global_error_collector.prev != pos) { global_error_collector.prev = pos; - error_out("%s Syntax Warning: %s\n", - token_pos_to_string(pos), - gb_bprintf_va(fmt, va)); - show_error_on_line(pos, end); + error_out_pos(pos); + error_out_coloured("Syntax Warning: ", TerminalStyle_Normal, TerminalColour_Yellow); + error_out_va(fmt, va); + error_out("\n"); + // show_error_on_line(pos, end); } else if (pos.line == 0) { - error_out("Warning: %s\n", gb_bprintf_va(fmt, va)); + error_out_coloured("Syntax Warning: ", TerminalStyle_Normal, TerminalColour_Yellow); + error_out_va(fmt, va); + error_out("\n"); } } mutex_unlock(&global_error_collector.mutex); @@ -347,21 +507,21 @@ void syntax_warning_va(TokenPos const &pos, TokenPos end, char const *fmt, va_li -void warning(Token const &token, char const *fmt, ...) { +gb_internal void warning(Token const &token, char const *fmt, ...) { va_list va; va_start(va, fmt); warning_va(token.pos, {}, fmt, va); va_end(va); } -void error(Token const &token, char const *fmt, ...) { +gb_internal void error(Token const &token, char const *fmt, ...) { va_list va; va_start(va, fmt); error_va(token.pos, {}, fmt, va); va_end(va); } -void error(TokenPos pos, char const *fmt, ...) { +gb_internal void error(TokenPos pos, char const *fmt, ...) { va_list va; va_start(va, fmt); Token token = {}; @@ -370,7 +530,7 @@ void error(TokenPos pos, char const *fmt, ...) { va_end(va); } -void error_line(char const *fmt, ...) { +gb_internal void error_line(char const *fmt, ...) { va_list va; va_start(va, fmt); error_line_va(fmt, va); @@ -378,29 +538,37 @@ void error_line(char const *fmt, ...) { } -void syntax_error(Token const &token, char const *fmt, ...) { +gb_internal void syntax_error(Token const &token, char const *fmt, ...) { va_list va; va_start(va, fmt); syntax_error_va(token.pos, {}, fmt, va); va_end(va); } -void syntax_error(TokenPos pos, char const *fmt, ...) { +gb_internal void syntax_error(TokenPos pos, char const *fmt, ...) { va_list va; va_start(va, fmt); syntax_error_va(pos, {}, fmt, va); va_end(va); } -void syntax_warning(Token const &token, char const *fmt, ...) { +gb_internal void syntax_warning(Token const &token, char const *fmt, ...) { va_list va; va_start(va, fmt); syntax_warning_va(token.pos, {}, fmt, va); va_end(va); } +gb_internal void syntax_error_with_verbose(TokenPos pos, TokenPos end, char const *fmt, ...) { + va_list va; + va_start(va, fmt); + syntax_error_with_verbose_va(pos, end, fmt, va); + va_end(va); +} -void compiler_error(char const *fmt, ...) { + + +gb_internal void compiler_error(char const *fmt, ...) { va_list va; va_start(va, fmt); diff --git a/src/exact_value.cpp b/src/exact_value.cpp index 25ff08a82..ff940aabb 100644 --- a/src/exact_value.cpp +++ b/src/exact_value.cpp @@ -1,4 +1,5 @@ #include +#include gb_global BlockingMutex hash_exact_value_mutex; @@ -6,7 +7,7 @@ struct Ast; struct HashKey; struct Type; struct Entity; -bool are_types_identical(Type *x, Type *y); +gb_internal bool are_types_identical(Type *x, Type *y); struct Complex128 { f64 real, imag; @@ -15,16 +16,6 @@ struct Quaternion256 { f64 imag, jmag, kmag, real; }; -Quaternion256 quaternion256_inverse(Quaternion256 x) { - f64 invmag2 = 1.0 / (x.real*x.real + x.imag*x.imag + x.jmag*x.jmag + x.kmag*x.kmag); - x.real = +x.real * invmag2; - x.imag = -x.imag * invmag2; - x.jmag = -x.jmag * invmag2; - x.kmag = -x.kmag * invmag2; - return x; -} - - enum ExactValueKind { ExactValue_Invalid = 0, @@ -60,7 +51,7 @@ struct ExactValue { gb_global ExactValue const empty_exact_value = {}; -uintptr hash_exact_value(ExactValue v) { +gb_internal uintptr hash_exact_value(ExactValue v) { mutex_lock(&hash_exact_value_mutex); defer (mutex_unlock(&hash_exact_value_mutex)); @@ -70,7 +61,7 @@ uintptr hash_exact_value(ExactValue v) { case ExactValue_Bool: return gb_fnv32a(&v.value_bool, gb_size_of(v.value_bool)); case ExactValue_String: - return ptr_map_hash_key(string_intern(v.value_string)); + return gb_fnv32a(v.value_string.text, v.value_string.len); case ExactValue_Integer: { u32 key = gb_fnv32a(v.value_integer.dp, gb_size_of(*v.value_integer.dp) * v.value_integer.used); @@ -97,44 +88,44 @@ uintptr hash_exact_value(ExactValue v) { } -ExactValue exact_value_compound(Ast *node) { +gb_internal ExactValue exact_value_compound(Ast *node) { ExactValue result = {ExactValue_Compound}; result.value_compound = node; return result; } -ExactValue exact_value_bool(bool b) { +gb_internal ExactValue exact_value_bool(bool b) { ExactValue result = {ExactValue_Bool}; result.value_bool = (b != 0); return result; } -ExactValue exact_value_string(String string) { +gb_internal ExactValue exact_value_string(String string) { // TODO(bill): Allow for numbers with underscores in them ExactValue result = {ExactValue_String}; result.value_string = string; return result; } -ExactValue exact_value_i64(i64 i) { +gb_internal ExactValue exact_value_i64(i64 i) { ExactValue result = {ExactValue_Integer}; big_int_from_i64(&result.value_integer, i); return result; } -ExactValue exact_value_u64(u64 i) { +gb_internal ExactValue exact_value_u64(u64 i) { ExactValue result = {ExactValue_Integer}; big_int_from_u64(&result.value_integer, i); return result; } -ExactValue exact_value_float(f64 f) { +gb_internal ExactValue exact_value_float(f64 f) { ExactValue result = {ExactValue_Float}; result.value_float = f; return result; } -ExactValue exact_value_complex(f64 real, f64 imag) { +gb_internal ExactValue exact_value_complex(f64 real, f64 imag) { ExactValue result = {ExactValue_Complex}; result.value_complex = gb_alloc_item(permanent_allocator(), Complex128); result.value_complex->real = real; @@ -142,7 +133,7 @@ ExactValue exact_value_complex(f64 real, f64 imag) { return result; } -ExactValue exact_value_quaternion(f64 real, f64 imag, f64 jmag, f64 kmag) { +gb_internal ExactValue exact_value_quaternion(f64 real, f64 imag, f64 jmag, f64 kmag) { ExactValue result = {ExactValue_Quaternion}; result.value_quaternion = gb_alloc_item(permanent_allocator(), Quaternion256); result.value_quaternion->real = real; @@ -152,27 +143,27 @@ ExactValue exact_value_quaternion(f64 real, f64 imag, f64 jmag, f64 kmag) { return result; } -ExactValue exact_value_pointer(i64 ptr) { +gb_internal ExactValue exact_value_pointer(i64 ptr) { ExactValue result = {ExactValue_Pointer}; result.value_pointer = ptr; return result; } -ExactValue exact_value_procedure(Ast *node) { +gb_internal ExactValue exact_value_procedure(Ast *node) { ExactValue result = {ExactValue_Procedure}; result.value_procedure = node; return result; } -ExactValue exact_value_typeid(Type *type) { +gb_internal ExactValue exact_value_typeid(Type *type) { ExactValue result = {ExactValue_Typeid}; result.value_typeid = type; return result; } -ExactValue exact_value_integer_from_string(String const &string) { +gb_internal ExactValue exact_value_integer_from_string(String const &string) { ExactValue result = {ExactValue_Integer}; bool success; big_int_from_string(&result.value_integer, string, &success); @@ -184,7 +175,36 @@ ExactValue exact_value_integer_from_string(String const &string) { -f64 float_from_string(String string) { +gb_internal f64 float_from_string(String const &string) { + if (string.len < 128) { + char buf[128] = {}; + isize n = 0; + for (isize i = 0; i < string.len; i++) { + u8 c = string.text[i]; + if (c == '_') { + continue; + } + if (c == 'E') { c = 'e'; } + buf[n++] = cast(char)c; + } + buf[n] = 0; + return atof(buf); + } else { + TEMPORARY_ALLOCATOR_GUARD(); + char *buf = gb_alloc_array(temporary_allocator(), char, string.len+1); + isize n = 0; + for (isize i = 0; i < string.len; i++) { + u8 c = string.text[i]; + if (c == '_') { + continue; + } + if (c == 'E') { c = 'e'; } + buf[n++] = cast(char)c; + } + buf[n] = 0; + return atof(buf); + } +/* isize i = 0; u8 *str = string.text; isize len = string.len; @@ -260,9 +280,10 @@ f64 float_from_string(String string) { } return sign * (frac ? (value / scale) : (value * scale)); +*/ } -ExactValue exact_value_float_from_string(String string) { +gb_internal ExactValue exact_value_float_from_string(String string) { if (string.len > 2 && string[0] == '0' && string[1] == 'h') { isize digit_count = 0; @@ -298,7 +319,7 @@ ExactValue exact_value_float_from_string(String string) { } -ExactValue exact_value_from_basic_literal(TokenKind kind, String const &string) { +gb_internal ExactValue exact_value_from_basic_literal(TokenKind kind, String const &string) { switch (kind) { case Token_String: return exact_value_string(string); case Token_Integer: return exact_value_integer_from_string(string); @@ -321,16 +342,13 @@ ExactValue exact_value_from_basic_literal(TokenKind kind, String const &string) utf8_decode(string.text, string.len, &r); return exact_value_i64(r); } - default: - GB_PANIC("Invalid token for basic literal"); - break; } ExactValue result = {ExactValue_Invalid}; return result; } -ExactValue exact_value_to_integer(ExactValue v) { +gb_internal ExactValue exact_value_to_integer(ExactValue v) { switch (v.kind) { case ExactValue_Bool: { i64 i = 0; @@ -357,7 +375,7 @@ ExactValue exact_value_to_integer(ExactValue v) { return r; } -ExactValue exact_value_to_float(ExactValue v) { +gb_internal ExactValue exact_value_to_float(ExactValue v) { switch (v.kind) { case ExactValue_Integer: return exact_value_float(big_int_to_f64(&v.value_integer)); @@ -368,7 +386,7 @@ ExactValue exact_value_to_float(ExactValue v) { return r; } -ExactValue exact_value_to_complex(ExactValue v) { +gb_internal ExactValue exact_value_to_complex(ExactValue v) { switch (v.kind) { case ExactValue_Integer: return exact_value_complex(big_int_to_f64(&v.value_integer), 0); @@ -383,7 +401,7 @@ ExactValue exact_value_to_complex(ExactValue v) { v.value_complex = gb_alloc_item(permanent_allocator(), Complex128); return r; } -ExactValue exact_value_to_quaternion(ExactValue v) { +gb_internal ExactValue exact_value_to_quaternion(ExactValue v) { switch (v.kind) { case ExactValue_Integer: return exact_value_quaternion(big_int_to_f64(&v.value_integer), 0, 0, 0); @@ -399,7 +417,7 @@ ExactValue exact_value_to_quaternion(ExactValue v) { return r; } -ExactValue exact_value_real(ExactValue v) { +gb_internal ExactValue exact_value_real(ExactValue v) { switch (v.kind) { case ExactValue_Integer: case ExactValue_Float: @@ -413,7 +431,7 @@ ExactValue exact_value_real(ExactValue v) { return r; } -ExactValue exact_value_imag(ExactValue v) { +gb_internal ExactValue exact_value_imag(ExactValue v) { switch (v.kind) { case ExactValue_Integer: case ExactValue_Float: @@ -427,7 +445,7 @@ ExactValue exact_value_imag(ExactValue v) { return r; } -ExactValue exact_value_jmag(ExactValue v) { +gb_internal ExactValue exact_value_jmag(ExactValue v) { switch (v.kind) { case ExactValue_Integer: case ExactValue_Float: @@ -440,7 +458,7 @@ ExactValue exact_value_jmag(ExactValue v) { return r; } -ExactValue exact_value_kmag(ExactValue v) { +gb_internal ExactValue exact_value_kmag(ExactValue v) { switch (v.kind) { case ExactValue_Integer: case ExactValue_Float: @@ -453,60 +471,60 @@ ExactValue exact_value_kmag(ExactValue v) { return r; } -ExactValue exact_value_make_imag(ExactValue v) { - switch (v.kind) { - case ExactValue_Integer: - return exact_value_complex(0, exact_value_to_float(v).value_float); - case ExactValue_Float: - return exact_value_complex(0, v.value_float); - default: - GB_PANIC("Expected an integer or float type for 'exact_value_make_imag'"); - } - ExactValue r = {ExactValue_Invalid}; - return r; -} +// gb_internal ExactValue exact_value_make_imag(ExactValue v) { +// switch (v.kind) { +// case ExactValue_Integer: +// return exact_value_complex(0, exact_value_to_float(v).value_float); +// case ExactValue_Float: +// return exact_value_complex(0, v.value_float); +// default: +// GB_PANIC("Expected an integer or float type for 'exact_value_make_imag'"); +// } +// ExactValue r = {ExactValue_Invalid}; +// return r; +// } -ExactValue exact_value_make_jmag(ExactValue v) { - switch (v.kind) { - case ExactValue_Integer: - return exact_value_quaternion(0, 0, exact_value_to_float(v).value_float, 0); - case ExactValue_Float: - return exact_value_quaternion(0, 0, v.value_float, 0); - default: - GB_PANIC("Expected an integer or float type for 'exact_value_make_imag'"); - } - ExactValue r = {ExactValue_Invalid}; - return r; -} +// gb_internal ExactValue exact_value_make_jmag(ExactValue v) { +// switch (v.kind) { +// case ExactValue_Integer: +// return exact_value_quaternion(0, 0, exact_value_to_float(v).value_float, 0); +// case ExactValue_Float: +// return exact_value_quaternion(0, 0, v.value_float, 0); +// default: +// GB_PANIC("Expected an integer or float type for 'exact_value_make_jmag'"); +// } +// ExactValue r = {ExactValue_Invalid}; +// return r; +// } -ExactValue exact_value_make_kmag(ExactValue v) { - switch (v.kind) { - case ExactValue_Integer: - return exact_value_quaternion(0, 0, 0, exact_value_to_float(v).value_float); - case ExactValue_Float: - return exact_value_quaternion(0, 0, 0, v.value_float); - default: - GB_PANIC("Expected an integer or float type for 'exact_value_make_imag'"); - } - ExactValue r = {ExactValue_Invalid}; - return r; -} +// gb_internal ExactValue exact_value_make_kmag(ExactValue v) { +// switch (v.kind) { +// case ExactValue_Integer: +// return exact_value_quaternion(0, 0, 0, exact_value_to_float(v).value_float); +// case ExactValue_Float: +// return exact_value_quaternion(0, 0, 0, v.value_float); +// default: +// GB_PANIC("Expected an integer or float type for 'exact_value_make_kmag'"); +// } +// ExactValue r = {ExactValue_Invalid}; +// return r; +// } -i64 exact_value_to_i64(ExactValue v) { +gb_internal i64 exact_value_to_i64(ExactValue v) { v = exact_value_to_integer(v); if (v.kind == ExactValue_Integer) { return big_int_to_i64(&v.value_integer); } return 0; } -u64 exact_value_to_u64(ExactValue v) { +gb_internal u64 exact_value_to_u64(ExactValue v) { v = exact_value_to_integer(v); if (v.kind == ExactValue_Integer) { return big_int_to_u64(&v.value_integer); } return 0; } -f64 exact_value_to_f64(ExactValue v) { +gb_internal f64 exact_value_to_f64(ExactValue v) { v = exact_value_to_float(v); if (v.kind == ExactValue_Float) { return v.value_float; @@ -519,7 +537,7 @@ f64 exact_value_to_f64(ExactValue v) { -ExactValue exact_unary_operator_value(TokenKind op, ExactValue v, i32 precision, bool is_unsigned) { +gb_internal ExactValue exact_unary_operator_value(TokenKind op, ExactValue v, i32 precision, bool is_unsigned) { switch (op) { case Token_Add: { switch (v.kind) { @@ -588,15 +606,13 @@ ExactValue exact_unary_operator_value(TokenKind op, ExactValue v, i32 precision, } } -failure: - GB_PANIC("Invalid unary operation, %.*s", LIT(token_strings[op])); - +failure:; ExactValue error_value = {}; return error_value; } // NOTE(bill): Make sure things are evaluated in correct order -i32 exact_value_order(ExactValue const &v) { +gb_internal i32 exact_value_order(ExactValue const &v) { switch (v.kind) { case ExactValue_Invalid: case ExactValue_Compound: @@ -623,7 +639,7 @@ i32 exact_value_order(ExactValue const &v) { } } -void match_exact_values(ExactValue *x, ExactValue *y) { +gb_internal void match_exact_values(ExactValue *x, ExactValue *y) { if (exact_value_order(*y) < exact_value_order(*x)) { match_exact_values(y, x); return; @@ -687,7 +703,7 @@ void match_exact_values(ExactValue *x, ExactValue *y) { } // TODO(bill): Allow for pointer arithmetic? Or are pointer slices good enough? -ExactValue exact_binary_operator_value(TokenKind op, ExactValue x, ExactValue y) { +gb_internal ExactValue exact_binary_operator_value(TokenKind op, ExactValue x, ExactValue y) { match_exact_values(&x, &y); switch (x.kind) { @@ -846,32 +862,32 @@ error:; // NOTE(bill): MSVC accepts this??? apparently you cannot declare variab return empty_exact_value; } -gb_inline ExactValue exact_value_add(ExactValue const &x, ExactValue const &y) { +gb_internal gb_inline ExactValue exact_value_add(ExactValue const &x, ExactValue const &y) { return exact_binary_operator_value(Token_Add, x, y); } -gb_inline ExactValue exact_value_sub(ExactValue const &x, ExactValue const &y) { +gb_internal gb_inline ExactValue exact_value_sub(ExactValue const &x, ExactValue const &y) { return exact_binary_operator_value(Token_Sub, x, y); } -gb_inline ExactValue exact_value_mul(ExactValue const &x, ExactValue const &y) { +gb_internal gb_inline ExactValue exact_value_mul(ExactValue const &x, ExactValue const &y) { return exact_binary_operator_value(Token_Mul, x, y); } -gb_inline ExactValue exact_value_quo(ExactValue const &x, ExactValue const &y) { +gb_internal gb_inline ExactValue exact_value_quo(ExactValue const &x, ExactValue const &y) { return exact_binary_operator_value(Token_Quo, x, y); } -gb_inline ExactValue exact_value_shift(TokenKind op, ExactValue const &x, ExactValue const &y) { +gb_internal gb_inline ExactValue exact_value_shift(TokenKind op, ExactValue const &x, ExactValue const &y) { return exact_binary_operator_value(op, x, y); } -gb_inline ExactValue exact_value_increment_one(ExactValue const &x) { +gb_internal gb_inline ExactValue exact_value_increment_one(ExactValue const &x) { return exact_binary_operator_value(Token_Add, x, exact_value_i64(1)); } -i32 cmp_f64(f64 a, f64 b) { +gb_internal gb_inline i32 cmp_f64(f64 a, f64 b) { return (a > b) - (a < b); } -bool compare_exact_values(TokenKind op, ExactValue x, ExactValue y) { +gb_internal bool compare_exact_values(TokenKind op, ExactValue x, ExactValue y) { match_exact_values(&x, &y); switch (x.kind) { @@ -969,12 +985,12 @@ bool compare_exact_values(TokenKind op, ExactValue x, ExactValue y) { return false; } -Entity *strip_entity_wrapping(Ast *expr); -Entity *strip_entity_wrapping(Entity *e); +gb_internal Entity *strip_entity_wrapping(Ast *expr); +gb_internal Entity *strip_entity_wrapping(Entity *e); -gbString write_expr_to_string(gbString str, Ast *node, bool shorthand); +gb_internal gbString write_expr_to_string(gbString str, Ast *node, bool shorthand); -gbString write_exact_value_to_string(gbString str, ExactValue const &v, isize string_limit=36) { +gb_internal gbString write_exact_value_to_string(gbString str, ExactValue const &v, isize string_limit=36) { switch (v.kind) { case ExactValue_Invalid: return str; @@ -1017,6 +1033,6 @@ gbString write_exact_value_to_string(gbString str, ExactValue const &v, isize st return str; }; -gbString exact_value_to_string(ExactValue const &v, isize string_limit=36) { +gb_internal gbString exact_value_to_string(ExactValue const &v, isize string_limit=36) { return write_exact_value_to_string(gb_string_make(heap_allocator(), ""), v, string_limit); } diff --git a/src/gb/gb.h b/src/gb/gb.h index 90f2fd15a..3d4bff9b4 100644 --- a/src/gb/gb.h +++ b/src/gb/gb.h @@ -465,8 +465,6 @@ typedef i32 b32; // NOTE(bill): Prefer this!!! #if !defined(gb_thread_local) #if defined(_MSC_VER) && _MSC_VER >= 1300 #define gb_thread_local __declspec(thread) - #elif defined(__GNUC__) - #define gb_thread_local __thread #else #define gb_thread_local thread_local #endif @@ -3301,12 +3299,39 @@ void const *gb_memrchr(void const *data, u8 c, isize n) { -gb_inline void *gb_alloc_align (gbAllocator a, isize size, isize alignment) { return a.proc(a.data, gbAllocation_Alloc, size, alignment, NULL, 0, GB_DEFAULT_ALLOCATOR_FLAGS); } -gb_inline void *gb_alloc (gbAllocator a, isize size) { return gb_alloc_align(a, size, GB_DEFAULT_MEMORY_ALIGNMENT); } -gb_inline void gb_free (gbAllocator a, void *ptr) { if (ptr != NULL) a.proc(a.data, gbAllocation_Free, 0, 0, ptr, 0, GB_DEFAULT_ALLOCATOR_FLAGS); } -gb_inline void gb_free_all (gbAllocator a) { a.proc(a.data, gbAllocation_FreeAll, 0, 0, NULL, 0, GB_DEFAULT_ALLOCATOR_FLAGS); } -gb_inline void *gb_resize (gbAllocator a, void *ptr, isize old_size, isize new_size) { return gb_resize_align(a, ptr, old_size, new_size, GB_DEFAULT_MEMORY_ALIGNMENT); } -gb_inline void *gb_resize_align(gbAllocator a, void *ptr, isize old_size, isize new_size, isize alignment) { return a.proc(a.data, gbAllocation_Resize, new_size, alignment, ptr, old_size, GB_DEFAULT_ALLOCATOR_FLAGS); } +gb_inline void *gb_alloc_align (gbAllocator a, isize size, isize alignment) { + if (size == 0) { + return NULL; + } + return a.proc(a.data, gbAllocation_Alloc, size, alignment, NULL, 0, GB_DEFAULT_ALLOCATOR_FLAGS); +} +gb_inline void *gb_alloc(gbAllocator a, isize size) { + return gb_alloc_align(a, size, GB_DEFAULT_MEMORY_ALIGNMENT); +} +gb_inline void gb_free(gbAllocator a, void *ptr) { + if (ptr != NULL) { + a.proc(a.data, gbAllocation_Free, 0, 0, ptr, 0, GB_DEFAULT_ALLOCATOR_FLAGS); + } +} +gb_inline void gb_free_all(gbAllocator a) { + a.proc(a.data, gbAllocation_FreeAll, 0, 0, NULL, 0, GB_DEFAULT_ALLOCATOR_FLAGS); +} +gb_inline void *gb_resize(gbAllocator a, void *ptr, isize old_size, isize new_size) { + return gb_resize_align(a, ptr, old_size, new_size, GB_DEFAULT_MEMORY_ALIGNMENT); +} +gb_inline void *gb_resize_align(gbAllocator a, void *ptr, isize old_size, isize new_size, isize alignment) { + if (new_size == 0) { + if (ptr != NULL) { + return a.proc(a.data, gbAllocation_Free, 0, 0, ptr, old_size, GB_DEFAULT_ALLOCATOR_FLAGS); + } + return NULL; + } else if (ptr == NULL) { + return a.proc(a.data, gbAllocation_Alloc, new_size, alignment, NULL, 0, GB_DEFAULT_ALLOCATOR_FLAGS); + } else if (old_size == new_size && ((uintptr)ptr % (uintptr)alignment) == 0) { + return ptr; + } + return a.proc(a.data, gbAllocation_Resize, new_size, alignment, ptr, old_size, GB_DEFAULT_ALLOCATOR_FLAGS); +} gb_inline void *gb_alloc_copy (gbAllocator a, void const *src, isize size) { return gb_memcopy(gb_alloc(a, size), src, size); diff --git a/src/llvm_abi.cpp b/src/llvm_abi.cpp index 2cabc2dc7..b0045d869 100644 --- a/src/llvm_abi.cpp +++ b/src/llvm_abi.cpp @@ -18,21 +18,21 @@ struct lbArgType { }; -i64 lb_sizeof(LLVMTypeRef type); -i64 lb_alignof(LLVMTypeRef type); +gb_internal i64 lb_sizeof(LLVMTypeRef type); +gb_internal i64 lb_alignof(LLVMTypeRef type); -lbArgType lb_arg_type_direct(LLVMTypeRef type, LLVMTypeRef cast_type, LLVMTypeRef pad_type, LLVMAttributeRef attr) { +gb_internal lbArgType lb_arg_type_direct(LLVMTypeRef type, LLVMTypeRef cast_type, LLVMTypeRef pad_type, LLVMAttributeRef attr) { return lbArgType{lbArg_Direct, type, cast_type, pad_type, attr, nullptr, 0, false}; } -lbArgType lb_arg_type_direct(LLVMTypeRef type) { +gb_internal lbArgType lb_arg_type_direct(LLVMTypeRef type) { return lb_arg_type_direct(type, nullptr, nullptr, nullptr); } -lbArgType lb_arg_type_indirect(LLVMTypeRef type, LLVMAttributeRef attr) { +gb_internal lbArgType lb_arg_type_indirect(LLVMTypeRef type, LLVMAttributeRef attr) { return lbArgType{lbArg_Indirect, type, nullptr, nullptr, attr, nullptr, 0, false}; } -lbArgType lb_arg_type_indirect_byval(LLVMContextRef c, LLVMTypeRef type) { +gb_internal lbArgType lb_arg_type_indirect_byval(LLVMContextRef c, LLVMTypeRef type) { i64 alignment = lb_alignof(type); alignment = gb_max(alignment, 8); @@ -41,7 +41,7 @@ lbArgType lb_arg_type_indirect_byval(LLVMContextRef c, LLVMTypeRef type) { return lbArgType{lbArg_Indirect, type, nullptr, nullptr, byval_attr, align_attr, alignment, true}; } -lbArgType lb_arg_type_ignore(LLVMTypeRef type) { +gb_internal lbArgType lb_arg_type_ignore(LLVMTypeRef type) { return lbArgType{lbArg_Ignore, type, nullptr, nullptr, nullptr, nullptr, 0, false}; } @@ -55,24 +55,24 @@ struct lbFunctionType { isize original_arg_count; }; -gbAllocator lb_function_type_args_allocator(void) { +gb_internal gbAllocator lb_function_type_args_allocator(void) { return heap_allocator(); } -i64 llvm_align_formula(i64 off, i64 a) { +gb_internal gb_inline i64 llvm_align_formula(i64 off, i64 a) { return (off + a - 1) / a * a; } -bool lb_is_type_kind(LLVMTypeRef type, LLVMTypeKind kind) { +gb_internal bool lb_is_type_kind(LLVMTypeRef type, LLVMTypeKind kind) { if (type == nullptr) { return false; } return LLVMGetTypeKind(type) == kind; } -LLVMTypeRef lb_function_type_to_llvm_raw(lbFunctionType *ft, bool is_var_arg) { +gb_internal LLVMTypeRef lb_function_type_to_llvm_raw(lbFunctionType *ft, bool is_var_arg) { unsigned arg_count = cast(unsigned)ft->args.count; unsigned offset = 0; @@ -130,7 +130,7 @@ LLVMTypeRef lb_function_type_to_llvm_raw(lbFunctionType *ft, bool is_var_arg) { // } -void lb_add_function_type_attributes(LLVMValueRef fn, lbFunctionType *ft, ProcCallingConvention calling_convention) { +gb_internal void lb_add_function_type_attributes(LLVMValueRef fn, lbFunctionType *ft, ProcCallingConvention calling_convention) { if (ft == nullptr) { return; } @@ -201,7 +201,7 @@ void lb_add_function_type_attributes(LLVMValueRef fn, lbFunctionType *ft, ProcCa } -i64 lb_sizeof(LLVMTypeRef type) { +gb_internal i64 lb_sizeof(LLVMTypeRef type) { LLVMTypeKind kind = LLVMGetTypeKind(type); switch (kind) { case LLVMVoidTypeKind: @@ -218,7 +218,7 @@ i64 lb_sizeof(LLVMTypeRef type) { case LLVMDoubleTypeKind: return 8; case LLVMPointerTypeKind: - return build_context.word_size; + return build_context.ptr_size; case LLVMStructTypeKind: { unsigned field_count = LLVMCountStructElementTypes(type); @@ -267,7 +267,7 @@ i64 lb_sizeof(LLVMTypeRef type) { return 0; } -i64 lb_alignof(LLVMTypeRef type) { +gb_internal i64 lb_alignof(LLVMTypeRef type) { LLVMTypeKind kind = LLVMGetTypeKind(type); switch (kind) { case LLVMVoidTypeKind: @@ -275,7 +275,7 @@ i64 lb_alignof(LLVMTypeRef type) { case LLVMIntegerTypeKind: { unsigned w = LLVMGetIntTypeWidth(type); - return gb_clamp((w + 7)/8, 1, build_context.word_size); + return gb_clamp((w + 7)/8, 1, build_context.ptr_size); } case LLVMHalfTypeKind: return 2; @@ -284,7 +284,7 @@ i64 lb_alignof(LLVMTypeRef type) { case LLVMDoubleTypeKind: return 8; case LLVMPointerTypeKind: - return build_context.word_size; + return build_context.ptr_size; case LLVMStructTypeKind: { if (LLVMIsPackedStruct(type)) { @@ -326,14 +326,14 @@ i64 lb_alignof(LLVMTypeRef type) { } -#define LB_ABI_INFO(name) lbFunctionType *name(LLVMContextRef c, LLVMTypeRef *arg_types, unsigned arg_count, LLVMTypeRef return_type, bool return_is_defined, bool return_is_tuple, ProcCallingConvention calling_convention) +#define LB_ABI_INFO(name) lbFunctionType *name(LLVMContextRef c, LLVMTypeRef *arg_types, unsigned arg_count, LLVMTypeRef return_type, bool return_is_defined, bool return_is_tuple, ProcCallingConvention calling_convention, Type *original_type) typedef LB_ABI_INFO(lbAbiInfoType); #define LB_ABI_COMPUTE_RETURN_TYPE(name) lbArgType name(lbFunctionType *ft, LLVMContextRef c, LLVMTypeRef return_type, bool return_is_defined, bool return_is_tuple) typedef LB_ABI_COMPUTE_RETURN_TYPE(lbAbiComputeReturnType); -lbArgType lb_abi_modify_return_is_tuple(lbFunctionType *ft, LLVMContextRef c, LLVMTypeRef return_type, lbAbiComputeReturnType *compute_return_type) { +gb_internal lbArgType lb_abi_modify_return_is_tuple(lbFunctionType *ft, LLVMContextRef c, LLVMTypeRef return_type, lbAbiComputeReturnType *compute_return_type) { GB_ASSERT(return_type != nullptr); GB_ASSERT(compute_return_type != nullptr); @@ -370,10 +370,10 @@ lbArgType lb_abi_modify_return_is_tuple(lbFunctionType *ft, LLVMContextRef c, LL // NOTE(bill): I hate `namespace` in C++ but this is just because I don't want to prefix everything namespace lbAbi386 { - Array compute_arg_types(LLVMContextRef c, LLVMTypeRef *arg_types, unsigned arg_count); - LB_ABI_COMPUTE_RETURN_TYPE(compute_return_type); + gb_internal Array compute_arg_types(LLVMContextRef c, LLVMTypeRef *arg_types, unsigned arg_count); + gb_internal LB_ABI_COMPUTE_RETURN_TYPE(compute_return_type); - LB_ABI_INFO(abi_info) { + gb_internal LB_ABI_INFO(abi_info) { lbFunctionType *ft = gb_alloc_item(permanent_allocator(), lbFunctionType); ft->ctx = c; ft->args = compute_arg_types(c, arg_types, arg_count); @@ -382,13 +382,13 @@ namespace lbAbi386 { return ft; } - lbArgType non_struct(LLVMContextRef c, LLVMTypeRef type, bool is_return) { + gb_internal lbArgType non_struct(LLVMContextRef c, LLVMTypeRef type, bool is_return) { if (!is_return && lb_sizeof(type) > 8) { return lb_arg_type_indirect(type, nullptr); } if (build_context.metrics.os == TargetOs_windows && - build_context.word_size == 8 && + build_context.ptr_size == 8 && lb_is_type_kind(type, LLVMIntegerTypeKind) && type == LLVMIntTypeInContext(c, 128)) { // NOTE(bill): Because Windows AMD64 is weird @@ -409,7 +409,7 @@ namespace lbAbi386 { return lb_arg_type_direct(type, nullptr, nullptr, attr); } - Array compute_arg_types(LLVMContextRef c, LLVMTypeRef *arg_types, unsigned arg_count) { + gb_internal Array compute_arg_types(LLVMContextRef c, LLVMTypeRef *arg_types, unsigned arg_count) { auto args = array_make(lb_function_type_args_allocator(), arg_count); for (unsigned i = 0; i < arg_count; i++) { @@ -429,7 +429,7 @@ namespace lbAbi386 { return args; } - LB_ABI_COMPUTE_RETURN_TYPE(compute_return_type) { + gb_internal LB_ABI_COMPUTE_RETURN_TYPE(compute_return_type) { if (!return_is_defined) { return lb_arg_type_direct(LLVMVoidTypeInContext(c)); } else if (lb_is_type_kind(return_type, LLVMStructTypeKind) || lb_is_type_kind(return_type, LLVMArrayTypeKind)) { @@ -451,10 +451,10 @@ namespace lbAbi386 { }; namespace lbAbiAmd64Win64 { - Array compute_arg_types(LLVMContextRef c, LLVMTypeRef *arg_types, unsigned arg_count); - LB_ABI_COMPUTE_RETURN_TYPE(compute_return_type); + gb_internal Array compute_arg_types(LLVMContextRef c, LLVMTypeRef *arg_types, unsigned arg_count); + gb_internal LB_ABI_COMPUTE_RETURN_TYPE(compute_return_type); - LB_ABI_INFO(abi_info) { + gb_internal LB_ABI_INFO(abi_info) { lbFunctionType *ft = gb_alloc_item(permanent_allocator(), lbFunctionType); ft->ctx = c; ft->args = compute_arg_types(c, arg_types, arg_count); @@ -463,7 +463,7 @@ namespace lbAbiAmd64Win64 { return ft; } - Array compute_arg_types(LLVMContextRef c, LLVMTypeRef *arg_types, unsigned arg_count) { + gb_internal Array compute_arg_types(LLVMContextRef c, LLVMTypeRef *arg_types, unsigned arg_count) { auto args = array_make(lb_function_type_args_allocator(), arg_count); for (unsigned i = 0; i < arg_count; i++) { @@ -489,7 +489,7 @@ namespace lbAbiAmd64Win64 { return args; } - LB_ABI_COMPUTE_RETURN_TYPE(compute_return_type) { + gb_internal LB_ABI_COMPUTE_RETURN_TYPE(compute_return_type) { if (!return_is_defined) { return lb_arg_type_direct(LLVMVoidTypeInContext(c)); } else if (lb_is_type_kind(return_type, LLVMStructTypeKind) || lb_is_type_kind(return_type, LLVMArrayTypeKind)) { @@ -530,7 +530,7 @@ namespace lbAbiAmd64SysV { RegClass_Memory, }; - bool is_sse(RegClass reg_class) { + gb_internal bool is_sse(RegClass reg_class) { switch (reg_class) { case RegClass_SSEFs: case RegClass_SSEFv: @@ -546,7 +546,7 @@ namespace lbAbiAmd64SysV { return false; } - void all_mem(Array *cs) { + gb_internal void all_mem(Array *cs) { for_array(i, *cs) { (*cs)[i] = RegClass_Memory; } @@ -558,14 +558,14 @@ namespace lbAbiAmd64SysV { Amd64TypeAttribute_StructRect, }; - LB_ABI_COMPUTE_RETURN_TYPE(compute_return_type); - void classify_with(LLVMTypeRef t, Array *cls, i64 ix, i64 off); - void fixup(LLVMTypeRef t, Array *cls); - lbArgType amd64_type(LLVMContextRef c, LLVMTypeRef type, Amd64TypeAttributeKind attribute_kind, ProcCallingConvention calling_convention); - Array classify(LLVMTypeRef t); - LLVMTypeRef llreg(LLVMContextRef c, Array const ®_classes); + gb_internal LB_ABI_COMPUTE_RETURN_TYPE(compute_return_type); + gb_internal void classify_with(LLVMTypeRef t, Array *cls, i64 ix, i64 off); + gb_internal void fixup(LLVMTypeRef t, Array *cls); + gb_internal lbArgType amd64_type(LLVMContextRef c, LLVMTypeRef type, Amd64TypeAttributeKind attribute_kind, ProcCallingConvention calling_convention); + gb_internal Array classify(LLVMTypeRef t); + gb_internal LLVMTypeRef llreg(LLVMContextRef c, Array const ®_classes, LLVMTypeRef type); - LB_ABI_INFO(abi_info) { + gb_internal LB_ABI_INFO(abi_info) { lbFunctionType *ft = gb_alloc_item(permanent_allocator(), lbFunctionType); ft->ctx = c; ft->calling_convention = calling_convention; @@ -584,7 +584,7 @@ namespace lbAbiAmd64SysV { return ft; } - bool is_mem_cls(Array const &cls, Amd64TypeAttributeKind attribute_kind) { + gb_internal bool is_mem_cls(Array const &cls, Amd64TypeAttributeKind attribute_kind) { if (attribute_kind == Amd64TypeAttribute_ByVal) { if (cls.count == 0) { return false; @@ -600,7 +600,7 @@ namespace lbAbiAmd64SysV { return false; } - bool is_register(LLVMTypeRef type) { + gb_internal bool is_register(LLVMTypeRef type) { LLVMTypeKind kind = LLVMGetTypeKind(type); i64 sz = lb_sizeof(type); if (sz == 0) { @@ -617,7 +617,7 @@ namespace lbAbiAmd64SysV { return false; } - bool is_llvm_type_slice_like(LLVMTypeRef type) { + gb_internal bool is_llvm_type_slice_like(LLVMTypeRef type) { if (!lb_is_type_kind(type, LLVMStructTypeKind)) { return false; } @@ -633,7 +633,7 @@ namespace lbAbiAmd64SysV { } - lbArgType amd64_type(LLVMContextRef c, LLVMTypeRef type, Amd64TypeAttributeKind attribute_kind, ProcCallingConvention calling_convention) { + gb_internal lbArgType amd64_type(LLVMContextRef c, LLVMTypeRef type, Amd64TypeAttributeKind attribute_kind, ProcCallingConvention calling_convention) { if (is_register(type)) { LLVMAttributeRef attribute = nullptr; if (type == LLVMInt1TypeInContext(c)) { @@ -662,13 +662,13 @@ namespace lbAbiAmd64SysV { // the ABI rules for SysV reg_type = type; } else { - reg_type = llreg(c, cls); + reg_type = llreg(c, cls, type); } return lb_arg_type_direct(type, reg_type, nullptr, nullptr); } } - lbArgType non_struct(LLVMContextRef c, LLVMTypeRef type) { + gb_internal lbArgType non_struct(LLVMContextRef c, LLVMTypeRef type) { LLVMAttributeRef attr = nullptr; LLVMTypeRef i1 = LLVMInt1TypeInContext(c); if (type == i1) { @@ -677,7 +677,7 @@ namespace lbAbiAmd64SysV { return lb_arg_type_direct(type, nullptr, nullptr, attr); } - Array classify(LLVMTypeRef t) { + gb_internal Array classify(LLVMTypeRef t) { i64 sz = lb_sizeof(t); i64 words = (sz + 7)/8; auto reg_classes = array_make(heap_allocator(), cast(isize)words); @@ -690,7 +690,7 @@ namespace lbAbiAmd64SysV { return reg_classes; } - void unify(Array *cls, i64 i, RegClass const newv) { + gb_internal void unify(Array *cls, i64 i, RegClass const newv) { RegClass const oldv = (*cls)[cast(isize)i]; if (oldv == newv) { return; @@ -726,7 +726,7 @@ namespace lbAbiAmd64SysV { (*cls)[cast(isize)i] = to_write; } - void fixup(LLVMTypeRef t, Array *cls) { + gb_internal void fixup(LLVMTypeRef t, Array *cls) { i64 i = 0; i64 e = cls->count; if (e > 2 && (lb_is_type_kind(t, LLVMStructTypeKind) || @@ -773,7 +773,7 @@ namespace lbAbiAmd64SysV { } } - unsigned llvec_len(Array const ®_classes, isize offset) { + gb_internal unsigned llvec_len(Array const ®_classes, isize offset) { unsigned len = 1; for (isize i = offset; i < reg_classes.count; i++) { if (reg_classes[i] != RegClass_SSEUp) { @@ -785,67 +785,92 @@ namespace lbAbiAmd64SysV { } - LLVMTypeRef llreg(LLVMContextRef c, Array const ®_classes) { + gb_internal LLVMTypeRef llreg(LLVMContextRef c, Array const ®_classes, LLVMTypeRef type) { auto types = array_make(heap_allocator(), 0, reg_classes.count); - for (isize i = 0; i < reg_classes.count; /**/) { - RegClass reg_class = reg_classes[i]; - switch (reg_class) { - case RegClass_Int: - array_add(&types, LLVMIntTypeInContext(c, 64)); - break; - case RegClass_SSEFv: - case RegClass_SSEDv: - case RegClass_SSEInt8: - case RegClass_SSEInt16: - case RegClass_SSEInt32: - case RegClass_SSEInt64: - { - unsigned elems_per_word = 0; - LLVMTypeRef elem_type = nullptr; - switch (reg_class) { - case RegClass_SSEFv: - elems_per_word = 2; - elem_type = LLVMFloatTypeInContext(c); - break; - case RegClass_SSEDv: - elems_per_word = 1; - elem_type = LLVMDoubleTypeInContext(c); - break; - case RegClass_SSEInt8: - elems_per_word = 64/8; - elem_type = LLVMIntTypeInContext(c, 8); - break; - case RegClass_SSEInt16: - elems_per_word = 64/16; - elem_type = LLVMIntTypeInContext(c, 16); - break; - case RegClass_SSEInt32: - elems_per_word = 64/32; - elem_type = LLVMIntTypeInContext(c, 32); - break; - case RegClass_SSEInt64: - elems_per_word = 64/64; - elem_type = LLVMIntTypeInContext(c, 64); - break; - } - unsigned vec_len = llvec_len(reg_classes, i+1); - LLVMTypeRef vec_type = LLVMVectorType(elem_type, vec_len * elems_per_word); - array_add(&types, vec_type); - i += vec_len; - continue; - } + bool all_ints = true; + for (RegClass reg_class : reg_classes) { + if (reg_class != RegClass_Int) { + all_ints = false; break; - case RegClass_SSEFs: - array_add(&types, LLVMFloatTypeInContext(c)); - break; - case RegClass_SSEDs: - array_add(&types, LLVMDoubleTypeInContext(c)); - break; - default: - GB_PANIC("Unhandled RegClass"); } - i += 1; + } + + if (all_ints) { + i64 sz = lb_sizeof(type); + for_array(i, reg_classes) { + GB_ASSERT(sz != 0); + // TODO(bill): is this even correct? BECAUSE LLVM DOES NOT DOCUMENT ANY OF THIS!!! + if (sz >= 8) { + array_add(&types, LLVMIntTypeInContext(c, 64)); + sz -= 8; + } else { + array_add(&types, LLVMIntTypeInContext(c, cast(unsigned)(sz*8))); + sz = 0; + } + } + } else { + for (isize i = 0; i < reg_classes.count; /**/) { + RegClass reg_class = reg_classes[i]; + switch (reg_class) { + case RegClass_Int: + // TODO(bill): is this even correct? BECAUSE LLVM DOES NOT DOCUMENT ANY OF THIS!!! + array_add(&types, LLVMIntTypeInContext(c, 64)); + break; + case RegClass_SSEFv: + case RegClass_SSEDv: + case RegClass_SSEInt8: + case RegClass_SSEInt16: + case RegClass_SSEInt32: + case RegClass_SSEInt64: + { + unsigned elems_per_word = 0; + LLVMTypeRef elem_type = nullptr; + switch (reg_class) { + case RegClass_SSEFv: + elems_per_word = 2; + elem_type = LLVMFloatTypeInContext(c); + break; + case RegClass_SSEDv: + elems_per_word = 1; + elem_type = LLVMDoubleTypeInContext(c); + break; + case RegClass_SSEInt8: + elems_per_word = 64/8; + elem_type = LLVMIntTypeInContext(c, 8); + break; + case RegClass_SSEInt16: + elems_per_word = 64/16; + elem_type = LLVMIntTypeInContext(c, 16); + break; + case RegClass_SSEInt32: + elems_per_word = 64/32; + elem_type = LLVMIntTypeInContext(c, 32); + break; + case RegClass_SSEInt64: + elems_per_word = 64/64; + elem_type = LLVMIntTypeInContext(c, 64); + break; + } + + unsigned vec_len = llvec_len(reg_classes, i+1); + LLVMTypeRef vec_type = LLVMVectorType(elem_type, vec_len * elems_per_word); + array_add(&types, vec_type); + i += vec_len; + continue; + } + break; + case RegClass_SSEFs: + array_add(&types, LLVMFloatTypeInContext(c)); + break; + case RegClass_SSEDs: + array_add(&types, LLVMDoubleTypeInContext(c)); + break; + default: + GB_PANIC("Unhandled RegClass"); + } + i += 1; + } } if (types.count == 1) { @@ -854,7 +879,7 @@ namespace lbAbiAmd64SysV { return LLVMStructTypeInContext(c, types.data, cast(unsigned)types.count, false); } - void classify_with(LLVMTypeRef t, Array *cls, i64 ix, i64 off) { + gb_internal void classify_with(LLVMTypeRef t, Array *cls, i64 ix, i64 off) { i64 t_align = lb_alignof(t); i64 t_size = lb_sizeof(t); @@ -955,7 +980,7 @@ namespace lbAbiAmd64SysV { } } - LB_ABI_COMPUTE_RETURN_TYPE(compute_return_type) { + gb_internal LB_ABI_COMPUTE_RETURN_TYPE(compute_return_type) { if (!return_is_defined) { return lb_arg_type_direct(LLVMVoidTypeInContext(c)); } else if (lb_is_type_kind(return_type, LLVMStructTypeKind)) { @@ -980,11 +1005,11 @@ namespace lbAbiAmd64SysV { namespace lbAbiArm64 { - Array compute_arg_types(LLVMContextRef c, LLVMTypeRef *arg_types, unsigned arg_count); - LB_ABI_COMPUTE_RETURN_TYPE(compute_return_type); - bool is_homogenous_aggregate(LLVMContextRef c, LLVMTypeRef type, LLVMTypeRef *base_type_, unsigned *member_count_); + gb_internal Array compute_arg_types(LLVMContextRef c, LLVMTypeRef *arg_types, unsigned arg_count); + gb_internal LB_ABI_COMPUTE_RETURN_TYPE(compute_return_type); + gb_internal bool is_homogenous_aggregate(LLVMContextRef c, LLVMTypeRef type, LLVMTypeRef *base_type_, unsigned *member_count_); - LB_ABI_INFO(abi_info) { + gb_internal LB_ABI_INFO(abi_info) { lbFunctionType *ft = gb_alloc_item(permanent_allocator(), lbFunctionType); ft->ctx = c; ft->args = compute_arg_types(c, arg_types, arg_count); @@ -993,7 +1018,7 @@ namespace lbAbiArm64 { return ft; } - bool is_register(LLVMTypeRef type) { + gb_internal bool is_register(LLVMTypeRef type) { LLVMTypeKind kind = LLVMGetTypeKind(type); switch (kind) { case LLVMIntegerTypeKind: @@ -1006,7 +1031,7 @@ namespace lbAbiArm64 { return false; } - lbArgType non_struct(LLVMContextRef c, LLVMTypeRef type) { + gb_internal lbArgType non_struct(LLVMContextRef c, LLVMTypeRef type) { LLVMAttributeRef attr = nullptr; LLVMTypeRef i1 = LLVMInt1TypeInContext(c); if (type == i1) { @@ -1015,7 +1040,7 @@ namespace lbAbiArm64 { return lb_arg_type_direct(type, nullptr, nullptr, attr); } - bool is_homogenous_array(LLVMContextRef c, LLVMTypeRef type, LLVMTypeRef *base_type_, unsigned *member_count_) { + gb_internal bool is_homogenous_array(LLVMContextRef c, LLVMTypeRef type, LLVMTypeRef *base_type_, unsigned *member_count_) { GB_ASSERT(lb_is_type_kind(type, LLVMArrayTypeKind)); unsigned len = LLVMGetArrayLength(type); if (len == 0) { @@ -1032,7 +1057,7 @@ namespace lbAbiArm64 { } return false; } - bool is_homogenous_struct(LLVMContextRef c, LLVMTypeRef type, LLVMTypeRef *base_type_, unsigned *member_count_) { + gb_internal bool is_homogenous_struct(LLVMContextRef c, LLVMTypeRef type, LLVMTypeRef *base_type_, unsigned *member_count_) { GB_ASSERT(lb_is_type_kind(type, LLVMStructTypeKind)); unsigned elem_count = LLVMCountStructElementTypes(type); if (elem_count == 0) { @@ -1075,7 +1100,7 @@ namespace lbAbiArm64 { } - bool is_homogenous_aggregate(LLVMContextRef c, LLVMTypeRef type, LLVMTypeRef *base_type_, unsigned *member_count_) { + gb_internal bool is_homogenous_aggregate(LLVMContextRef c, LLVMTypeRef type, LLVMTypeRef *base_type_, unsigned *member_count_) { LLVMTypeKind kind = LLVMGetTypeKind(type); switch (kind) { case LLVMFloatTypeKind: @@ -1091,11 +1116,11 @@ namespace lbAbiArm64 { return false; } - unsigned is_homogenous_aggregate_small_enough(LLVMTypeRef base_type, unsigned member_count) { + gb_internal unsigned is_homogenous_aggregate_small_enough(LLVMTypeRef base_type, unsigned member_count) { return (member_count <= 4); } - LB_ABI_COMPUTE_RETURN_TYPE(compute_return_type) { + gb_internal LB_ABI_COMPUTE_RETURN_TYPE(compute_return_type) { LLVMTypeRef homo_base_type = nullptr; unsigned homo_member_count = 0; @@ -1142,7 +1167,7 @@ namespace lbAbiArm64 { } } - Array compute_arg_types(LLVMContextRef c, LLVMTypeRef *arg_types, unsigned arg_count) { + gb_internal Array compute_arg_types(LLVMContextRef c, LLVMTypeRef *arg_types, unsigned arg_count) { auto args = array_make(lb_function_type_args_allocator(), arg_count); for (unsigned i = 0; i < arg_count; i++) { @@ -1154,7 +1179,11 @@ namespace lbAbiArm64 { if (is_register(type)) { args[i] = non_struct(c, type); } else if (is_homogenous_aggregate(c, type, &homo_base_type, &homo_member_count)) { - args[i] = lb_arg_type_direct(type, LLVMArrayType(homo_base_type, homo_member_count), nullptr, nullptr); + if (is_homogenous_aggregate_small_enough(homo_base_type, homo_member_count)) { + args[i] = lb_arg_type_direct(type, LLVMArrayType(homo_base_type, homo_member_count), nullptr, nullptr); + } else { + args[i] = lb_arg_type_indirect(type, nullptr);; + } } else { i64 size = lb_sizeof(type); if (size <= 16) { @@ -1188,21 +1217,21 @@ namespace lbAbiWasm { The approach taken optimizes for passing things in multiple registers/arguments if possible rather than by pointer. */ - Array compute_arg_types(LLVMContextRef c, LLVMTypeRef *arg_types, unsigned arg_count); - LB_ABI_COMPUTE_RETURN_TYPE(compute_return_type); + gb_internal Array compute_arg_types(LLVMContextRef c, LLVMTypeRef *arg_types, unsigned arg_count, ProcCallingConvention calling_convention, Type *original_type); + gb_internal LB_ABI_COMPUTE_RETURN_TYPE(compute_return_type); enum {MAX_DIRECT_STRUCT_SIZE = 32}; - LB_ABI_INFO(abi_info) { + gb_internal LB_ABI_INFO(abi_info) { lbFunctionType *ft = gb_alloc_item(permanent_allocator(), lbFunctionType); ft->ctx = c; - ft->args = compute_arg_types(c, arg_types, arg_count); + ft->args = compute_arg_types(c, arg_types, arg_count, calling_convention, original_type); ft->ret = compute_return_type(ft, c, return_type, return_is_defined, return_is_tuple); ft->calling_convention = calling_convention; return ft; } - lbArgType non_struct(LLVMContextRef c, LLVMTypeRef type, bool is_return) { + gb_internal lbArgType non_struct(LLVMContextRef c, LLVMTypeRef type, bool is_return) { if (!is_return && type == LLVMIntTypeInContext(c, 128)) { LLVMTypeRef cast_type = LLVMVectorType(LLVMInt64TypeInContext(c), 2); return lb_arg_type_direct(type, cast_type, nullptr, nullptr); @@ -1220,7 +1249,7 @@ namespace lbAbiWasm { return lb_arg_type_direct(type, nullptr, nullptr, attr); } - bool is_basic_register_type(LLVMTypeRef type) { + gb_internal bool is_basic_register_type(LLVMTypeRef type) { switch (LLVMGetTypeKind(type)) { case LLVMHalfTypeKind: case LLVMFloatTypeKind: @@ -1233,13 +1262,26 @@ namespace lbAbiWasm { return false; } - bool type_can_be_direct(LLVMTypeRef type) { + gb_internal bool type_can_be_direct(LLVMTypeRef type, ProcCallingConvention calling_convention) { LLVMTypeKind kind = LLVMGetTypeKind(type); i64 sz = lb_sizeof(type); if (sz == 0) { return false; } - if (sz <= MAX_DIRECT_STRUCT_SIZE) { + if (calling_convention == ProcCC_CDecl) { + // WASM Basic C ABI: + // https://github.com/WebAssembly/tool-conventions/blob/main/BasicCABI.md#function-signatures + if (kind == LLVMArrayTypeKind) { + return false; + } else if (kind == LLVMStructTypeKind) { + unsigned count = LLVMCountStructElementTypes(type); + if (count == 1) { + return type_can_be_direct(LLVMStructGetTypeAtIndex(type, 0), calling_convention); + } + } else if (is_basic_register_type(type)) { + return true; + } + } else if (sz <= MAX_DIRECT_STRUCT_SIZE) { if (kind == LLVMArrayTypeKind) { if (is_basic_register_type(OdinLLVMGetArrayElementType(type))) { return true; @@ -1259,7 +1301,7 @@ namespace lbAbiWasm { return false; } - lbArgType is_struct(LLVMContextRef c, LLVMTypeRef type) { + gb_internal lbArgType is_struct(LLVMContextRef c, LLVMTypeRef type, ProcCallingConvention calling_convention) { LLVMTypeKind kind = LLVMGetTypeKind(type); GB_ASSERT(kind == LLVMArrayTypeKind || kind == LLVMStructTypeKind); @@ -1267,21 +1309,48 @@ namespace lbAbiWasm { if (sz == 0) { return lb_arg_type_ignore(type); } - if (type_can_be_direct(type)) { + if (type_can_be_direct(type, calling_convention)) { return lb_arg_type_direct(type); } return lb_arg_type_indirect(type, nullptr); } + gb_internal lbArgType pseudo_slice(LLVMContextRef c, LLVMTypeRef type, ProcCallingConvention calling_convention) { + if (build_context.metrics.ptr_size < build_context.metrics.int_size && + type_can_be_direct(type, calling_convention)) { + LLVMTypeRef types[2] = { + LLVMStructGetTypeAtIndex(type, 0), + // ignore padding + LLVMStructGetTypeAtIndex(type, 2) + }; + LLVMTypeRef new_type = LLVMStructTypeInContext(c, types, gb_count_of(types), false); + return lb_arg_type_direct(type, new_type, nullptr, nullptr); + } else { + return is_struct(c, type, calling_convention); + } + } - Array compute_arg_types(LLVMContextRef c, LLVMTypeRef *arg_types, unsigned arg_count) { + gb_internal Array compute_arg_types(LLVMContextRef c, LLVMTypeRef *arg_types, unsigned arg_count, ProcCallingConvention calling_convention, + Type *original_type) { auto args = array_make(lb_function_type_args_allocator(), arg_count); - for (unsigned i = 0; i < arg_count; i++) { + GB_ASSERT(original_type->kind == Type_Proc); + GB_ASSERT(cast(isize)arg_count <= original_type->Proc.param_count); + auto const ¶ms = original_type->Proc.params->Tuple.variables; + + for (unsigned i = 0, j = 0; i < arg_count; i++, j++) { + while (params[j]->kind != Entity_Variable) { + j++; + } + Type *ptype = params[j]->type; LLVMTypeRef t = arg_types[i]; LLVMTypeKind kind = LLVMGetTypeKind(t); if (kind == LLVMStructTypeKind || kind == LLVMArrayTypeKind) { - args[i] = is_struct(c, t); + if (is_type_slice(ptype) || is_type_string(ptype)) { + args[i] = pseudo_slice(c, t, calling_convention); + } else { + args[i] = is_struct(c, t, calling_convention); + } } else { args[i] = non_struct(c, t, false); } @@ -1289,11 +1358,11 @@ namespace lbAbiWasm { return args; } - LB_ABI_COMPUTE_RETURN_TYPE(compute_return_type) { + gb_internal LB_ABI_COMPUTE_RETURN_TYPE(compute_return_type) { if (!return_is_defined) { return lb_arg_type_direct(LLVMVoidTypeInContext(c)); } else if (lb_is_type_kind(return_type, LLVMStructTypeKind) || lb_is_type_kind(return_type, LLVMArrayTypeKind)) { - if (type_can_be_direct(return_type)) { + if (type_can_be_direct(return_type, ft->calling_convention)) { return lb_arg_type_direct(return_type); } @@ -1315,10 +1384,10 @@ namespace lbAbiWasm { } namespace lbAbiArm32 { - Array compute_arg_types(LLVMContextRef c, LLVMTypeRef *arg_types, unsigned arg_count, ProcCallingConvention calling_convention); - lbArgType compute_return_type(LLVMContextRef c, LLVMTypeRef return_type, bool return_is_defined); + gb_internal Array compute_arg_types(LLVMContextRef c, LLVMTypeRef *arg_types, unsigned arg_count, ProcCallingConvention calling_convention); + gb_internal lbArgType compute_return_type(LLVMContextRef c, LLVMTypeRef return_type, bool return_is_defined); - LB_ABI_INFO(abi_info) { + gb_internal LB_ABI_INFO(abi_info) { lbFunctionType *ft = gb_alloc_item(permanent_allocator(), lbFunctionType); ft->ctx = c; ft->args = compute_arg_types(c, arg_types, arg_count, calling_convention); @@ -1327,7 +1396,7 @@ namespace lbAbiArm32 { return ft; } - bool is_register(LLVMTypeRef type, bool is_return) { + gb_internal bool is_register(LLVMTypeRef type, bool is_return) { LLVMTypeKind kind = LLVMGetTypeKind(type); switch (kind) { case LLVMHalfTypeKind: @@ -1346,7 +1415,7 @@ namespace lbAbiArm32 { return false; } - lbArgType non_struct(LLVMContextRef c, LLVMTypeRef type, bool is_return) { + gb_internal lbArgType non_struct(LLVMContextRef c, LLVMTypeRef type, bool is_return) { LLVMAttributeRef attr = nullptr; LLVMTypeRef i1 = LLVMInt1TypeInContext(c); if (type == i1) { @@ -1355,7 +1424,7 @@ namespace lbAbiArm32 { return lb_arg_type_direct(type, nullptr, nullptr, attr); } - Array compute_arg_types(LLVMContextRef c, LLVMTypeRef *arg_types, unsigned arg_count, ProcCallingConvention calling_convention) { + gb_internal Array compute_arg_types(LLVMContextRef c, LLVMTypeRef *arg_types, unsigned arg_count, ProcCallingConvention calling_convention) { auto args = array_make(lb_function_type_args_allocator(), arg_count); for (unsigned i = 0; i < arg_count; i++) { @@ -1380,7 +1449,7 @@ namespace lbAbiArm32 { return args; } - lbArgType compute_return_type(LLVMContextRef c, LLVMTypeRef return_type, bool return_is_defined) { + gb_internal lbArgType compute_return_type(LLVMContextRef c, LLVMTypeRef return_type, bool return_is_defined) { if (!return_is_defined) { return lb_arg_type_direct(LLVMVoidTypeInContext(c)); } else if (!is_register(return_type, true)) { @@ -1397,7 +1466,7 @@ namespace lbAbiArm32 { }; -LB_ABI_INFO(lb_get_abi_info_internal) { +gb_internal LB_ABI_INFO(lb_get_abi_info_internal) { switch (calling_convention) { case ProcCC_None: case ProcCC_InlineAsm: @@ -1418,32 +1487,33 @@ LB_ABI_INFO(lb_get_abi_info_internal) { } case ProcCC_Win64: GB_ASSERT(build_context.metrics.arch == TargetArch_amd64); - return lbAbiAmd64Win64::abi_info(c, arg_types, arg_count, return_type, return_is_defined, return_is_tuple, calling_convention); + return lbAbiAmd64Win64::abi_info(c, arg_types, arg_count, return_type, return_is_defined, return_is_tuple, calling_convention, original_type); case ProcCC_SysV: GB_ASSERT(build_context.metrics.arch == TargetArch_amd64); - return lbAbiAmd64SysV::abi_info(c, arg_types, arg_count, return_type, return_is_defined, return_is_tuple, calling_convention); + return lbAbiAmd64SysV::abi_info(c, arg_types, arg_count, return_type, return_is_defined, return_is_tuple, calling_convention, original_type); } switch (build_context.metrics.arch) { case TargetArch_amd64: if (build_context.metrics.os == TargetOs_windows) { - return lbAbiAmd64Win64::abi_info(c, arg_types, arg_count, return_type, return_is_defined, return_is_tuple, calling_convention); + return lbAbiAmd64Win64::abi_info(c, arg_types, arg_count, return_type, return_is_defined, return_is_tuple, calling_convention, original_type); } else if (build_context.metrics.abi == TargetABI_Win64) { - return lbAbiAmd64Win64::abi_info(c, arg_types, arg_count, return_type, return_is_defined, return_is_tuple, calling_convention); + return lbAbiAmd64Win64::abi_info(c, arg_types, arg_count, return_type, return_is_defined, return_is_tuple, calling_convention, original_type); } else if (build_context.metrics.abi == TargetABI_SysV) { - return lbAbiAmd64SysV::abi_info(c, arg_types, arg_count, return_type, return_is_defined, return_is_tuple, calling_convention); + return lbAbiAmd64SysV::abi_info(c, arg_types, arg_count, return_type, return_is_defined, return_is_tuple, calling_convention, original_type); } else { - return lbAbiAmd64SysV::abi_info(c, arg_types, arg_count, return_type, return_is_defined, return_is_tuple, calling_convention); + return lbAbiAmd64SysV::abi_info(c, arg_types, arg_count, return_type, return_is_defined, return_is_tuple, calling_convention, original_type); } case TargetArch_i386: - return lbAbi386::abi_info(c, arg_types, arg_count, return_type, return_is_defined, return_is_tuple, calling_convention); + return lbAbi386::abi_info(c, arg_types, arg_count, return_type, return_is_defined, return_is_tuple, calling_convention, original_type); case TargetArch_arm32: - return lbAbiArm32::abi_info(c, arg_types, arg_count, return_type, return_is_defined, return_is_tuple, calling_convention); + return lbAbiArm32::abi_info(c, arg_types, arg_count, return_type, return_is_defined, return_is_tuple, calling_convention, original_type); case TargetArch_arm64: - return lbAbiArm64::abi_info(c, arg_types, arg_count, return_type, return_is_defined, return_is_tuple, calling_convention); + return lbAbiArm64::abi_info(c, arg_types, arg_count, return_type, return_is_defined, return_is_tuple, calling_convention, original_type); case TargetArch_wasm32: - case TargetArch_wasm64: - return lbAbiWasm::abi_info(c, arg_types, arg_count, return_type, return_is_defined, return_is_tuple, calling_convention); + return lbAbiWasm::abi_info(c, arg_types, arg_count, return_type, return_is_defined, return_is_tuple, calling_convention, original_type); + case TargetArch_wasm64p32: + return lbAbiWasm::abi_info(c, arg_types, arg_count, return_type, return_is_defined, return_is_tuple, calling_convention, original_type); } GB_PANIC("Unsupported ABI"); @@ -1451,13 +1521,14 @@ LB_ABI_INFO(lb_get_abi_info_internal) { } -LB_ABI_INFO(lb_get_abi_info) { +gb_internal LB_ABI_INFO(lb_get_abi_info) { lbFunctionType *ft = lb_get_abi_info_internal( c, arg_types, arg_count, return_type, return_is_defined, ALLOW_SPLIT_MULTI_RETURNS && return_is_tuple && is_calling_convention_odin(calling_convention), - calling_convention); + calling_convention, + base_type(original_type)); // NOTE(bill): this is handled here rather than when developing the type in `lb_type_internal_for_procedures_raw` diff --git a/src/llvm_backend.cpp b/src/llvm_backend.cpp index 1182beb53..730610ad9 100644 --- a/src/llvm_backend.cpp +++ b/src/llvm_backend.cpp @@ -22,7 +22,7 @@ #include "llvm_backend_proc.cpp" -void lb_add_foreign_library_path(lbModule *m, Entity *e) { +gb_internal void lb_add_foreign_library_path(lbModule *m, Entity *e) { if (e == nullptr) { return; } @@ -36,7 +36,7 @@ void lb_add_foreign_library_path(lbModule *m, Entity *e) { mutex_unlock(&m->gen->foreign_mutex); } -GB_COMPARE_PROC(foreign_library_cmp) { +gb_internal GB_COMPARE_PROC(foreign_library_cmp) { int cmp = 0; Entity *x = *(Entity **)a; Entity *y = *(Entity **)b; @@ -78,7 +78,7 @@ GB_COMPARE_PROC(foreign_library_cmp) { return i32_cmp(x->token.pos.offset, y->token.pos.offset); } -void lb_set_entity_from_other_modules_linkage_correctly(lbModule *other_module, Entity *e, String const &name) { +gb_internal void lb_set_entity_from_other_modules_linkage_correctly(lbModule *other_module, Entity *e, String const &name) { if (other_module == nullptr) { return; } @@ -95,16 +95,18 @@ void lb_set_entity_from_other_modules_linkage_correctly(lbModule *other_module, } } -void lb_emit_init_context(lbProcedure *p, lbAddr addr) { +gb_internal void lb_emit_init_context(lbProcedure *p, lbAddr addr) { + TEMPORARY_ALLOCATOR_GUARD(); + GB_ASSERT(addr.kind == lbAddr_Context); GB_ASSERT(addr.ctx.sel.index.count == 0); - auto args = array_make(permanent_allocator(), 1); + auto args = array_make(temporary_allocator(), 1); args[0] = addr.addr; lb_emit_runtime_call(p, "__init_context", args); } -lbContextData *lb_push_context_onto_stack_from_implicit_parameter(lbProcedure *p) { +gb_internal lbContextData *lb_push_context_onto_stack_from_implicit_parameter(lbProcedure *p) { Type *pt = base_type(p->type); GB_ASSERT(pt->kind == Type_Proc); GB_ASSERT(pt->Proc.calling_convention == ProcCC_Odin); @@ -131,7 +133,7 @@ lbContextData *lb_push_context_onto_stack_from_implicit_parameter(lbProcedure *p return cd; } -lbContextData *lb_push_context_onto_stack(lbProcedure *p, lbAddr ctx) { +gb_internal lbContextData *lb_push_context_onto_stack(lbProcedure *p, lbAddr ctx) { ctx.kind = lbAddr_Context; lbContextData *cd = array_add_and_get(&p->context_stack); cd->ctx = ctx; @@ -140,7 +142,7 @@ lbContextData *lb_push_context_onto_stack(lbProcedure *p, lbAddr ctx) { } -lbValue lb_equal_proc_for_type(lbModule *m, Type *type) { +gb_internal lbValue lb_equal_proc_for_type(lbModule *m, Type *type) { type = base_type(type); GB_ASSERT(is_type_comparable(type)); @@ -155,10 +157,10 @@ lbValue lb_equal_proc_for_type(lbModule *m, Type *type) { return {compare_proc->value, compare_proc->type}; } - static u32 proc_index = 0; + static std::atomic proc_index; char buf[32] = {}; - isize n = gb_snprintf(buf, 32, "__$equal%u", ++proc_index); + isize n = gb_snprintf(buf, 32, "__$equal%u", 1+proc_index.fetch_add(1)); char *str = gb_alloc_str_len(permanent_allocator(), buf, n-1); String proc_name = make_string_c(str); @@ -240,11 +242,10 @@ lbValue lb_equal_proc_for_type(lbModule *m, Type *type) { LLVMValueRef v_switch = LLVMBuildSwitch(p->builder, left_tag.value, block_false->block, cast(unsigned)type->Union.variants.count); - for_array(i, type->Union.variants) { + for (Type *v : type->Union.variants) { lbBlock *case_block = lb_create_block(p, "bcase"); lb_start_block(p, case_block); - Type *v = type->Union.variants[i]; lbValue case_tag = lb_const_union_tag(p->module, type, v); Type *vp = alloc_type_pointer(v); @@ -279,21 +280,23 @@ lbValue lb_equal_proc_for_type(lbModule *m, Type *type) { return {compare_proc->value, compare_proc->type}; } -lbValue lb_simple_compare_hash(lbProcedure *p, Type *type, lbValue data, lbValue seed) { +gb_internal lbValue lb_simple_compare_hash(lbProcedure *p, Type *type, lbValue data, lbValue seed) { + TEMPORARY_ALLOCATOR_GUARD(); + GB_ASSERT_MSG(is_type_simple_compare(type), "%s", type_to_string(type)); - auto args = array_make(permanent_allocator(), 3); + auto args = array_make(temporary_allocator(), 3); args[0] = data; args[1] = seed; args[2] = lb_const_int(p->module, t_int, type_size_of(type)); return lb_emit_runtime_call(p, "default_hasher", args); } -void lb_add_callsite_force_inline(lbProcedure *p, lbValue ret_value) { +gb_internal void lb_add_callsite_force_inline(lbProcedure *p, lbValue ret_value) { LLVMAddCallSiteAttribute(ret_value.value, LLVMAttributeIndex_FunctionIndex, lb_create_enum_attribute(p->module->ctx, "alwaysinline")); } -lbValue lb_hasher_proc_for_type(lbModule *m, Type *type) { +gb_internal lbValue lb_hasher_proc_for_type(lbModule *m, Type *type) { type = core_type(type); GB_ASSERT_MSG(is_type_valid_for_keys(type), "%s", type_to_string(type)); @@ -305,10 +308,10 @@ lbValue lb_hasher_proc_for_type(lbModule *m, Type *type) { return {(*found)->value, (*found)->type}; } - static u32 proc_index = 0; + static std::atomic proc_index; char buf[32] = {}; - isize n = gb_snprintf(buf, 32, "__$hasher%u", ++proc_index); + isize n = gb_snprintf(buf, 32, "__$hasher%u", 1+proc_index.fetch_add(1)); char *str = gb_alloc_str_len(permanent_allocator(), buf, n-1); String proc_name = make_string_c(str); @@ -335,11 +338,13 @@ lbValue lb_hasher_proc_for_type(lbModule *m, Type *type) { return {p->value, p->type}; } + TEMPORARY_ALLOCATOR_GUARD(); + if (type->kind == Type_Struct) { type_set_offsets(type); data = lb_emit_conv(p, data, t_u8_ptr); - auto args = array_make(permanent_allocator(), 2); + auto args = array_make(temporary_allocator(), 2); for_array(i, type->Struct.fields) { GB_ASSERT(type->Struct.offsets != nullptr); i64 offset = type->Struct.offsets[i]; @@ -353,7 +358,7 @@ lbValue lb_hasher_proc_for_type(lbModule *m, Type *type) { } LLVMBuildRet(p->builder, seed.value); } else if (type->kind == Type_Union) { - auto args = array_make(permanent_allocator(), 2); + auto args = array_make(temporary_allocator(), 2); if (is_type_union_maybe_pointer(type)) { Type *v = type->Union.variants[0]; @@ -374,11 +379,10 @@ lbValue lb_hasher_proc_for_type(lbModule *m, Type *type) { LLVMValueRef v_switch = LLVMBuildSwitch(p->builder, tag.value, end_block->block, cast(unsigned)type->Union.variants.count); - for_array(i, type->Union.variants) { + for (Type *v : type->Union.variants) { lbBlock *case_block = lb_create_block(p, "bcase"); lb_start_block(p, case_block); - Type *v = type->Union.variants[i]; lbValue case_tag = lb_const_union_tag(p->module, type, v); lbValue variant_hasher = lb_hasher_proc_for_type(m, v); @@ -398,7 +402,7 @@ lbValue lb_hasher_proc_for_type(lbModule *m, Type *type) { lbAddr pres = lb_add_local_generated(p, t_uintptr, false); lb_addr_store(p, pres, seed); - auto args = array_make(permanent_allocator(), 2); + auto args = array_make(temporary_allocator(), 2); lbValue elem_hasher = lb_hasher_proc_for_type(m, type->Array.elem); auto loop_data = lb_loop_start(p, cast(isize)type->Array.count, t_i32); @@ -419,7 +423,7 @@ lbValue lb_hasher_proc_for_type(lbModule *m, Type *type) { lbAddr res = lb_add_local_generated(p, t_uintptr, false); lb_addr_store(p, res, seed); - auto args = array_make(permanent_allocator(), 2); + auto args = array_make(temporary_allocator(), 2); lbValue elem_hasher = lb_hasher_proc_for_type(m, type->EnumeratedArray.elem); auto loop_data = lb_loop_start(p, cast(isize)type->EnumeratedArray.count, t_i32); @@ -437,14 +441,14 @@ lbValue lb_hasher_proc_for_type(lbModule *m, Type *type) { lbValue vres = lb_addr_load(p, res); LLVMBuildRet(p->builder, vres.value); } else if (is_type_cstring(type)) { - auto args = array_make(permanent_allocator(), 2); + auto args = array_make(temporary_allocator(), 2); args[0] = data; args[1] = seed; lbValue res = lb_emit_runtime_call(p, "default_hasher_cstring", args); lb_add_callsite_force_inline(p, res); LLVMBuildRet(p->builder, res.value); } else if (is_type_string(type)) { - auto args = array_make(permanent_allocator(), 2); + auto args = array_make(temporary_allocator(), 2); args[0] = data; args[1] = seed; lbValue res = lb_emit_runtime_call(p, "default_hasher_string", args); @@ -458,8 +462,10 @@ lbValue lb_hasher_proc_for_type(lbModule *m, Type *type) { } -lbValue lb_map_get_proc_for_type(lbModule *m, Type *type) { - GB_ASSERT(build_context.use_static_map_calls); +#define LLVM_SET_VALUE_NAME(value, name) LLVMSetValueName2((value), (name), gb_count_of((name))-1); + +gb_internal lbValue lb_map_get_proc_for_type(lbModule *m, Type *type) { + GB_ASSERT(!build_context.dynamic_map_calls); type = base_type(type); GB_ASSERT(type->kind == Type_Map); @@ -469,10 +475,10 @@ lbValue lb_map_get_proc_for_type(lbModule *m, Type *type) { GB_ASSERT(*found != nullptr); return {(*found)->value, (*found)->type}; } - static u32 proc_index = 0; + static std::atomic proc_index; char buf[32] = {}; - isize n = gb_snprintf(buf, 32, "__$map_get-%u", ++proc_index); + isize n = gb_snprintf(buf, 32, "__$map_get-%u", 1+proc_index.fetch_add(1)); char *str = gb_alloc_str_len(permanent_allocator(), buf, n-1); String proc_name = make_string_c(str); @@ -482,11 +488,10 @@ lbValue lb_map_get_proc_for_type(lbModule *m, Type *type) { defer (lb_end_procedure_body(p)); LLVMSetLinkage(p->value, LLVMInternalLinkage); - lb_add_attribute_to_proc(m, p->value, "readonly"); lb_add_attribute_to_proc(m, p->value, "nounwind"); - if (build_context.ODIN_DEBUG) { + // if (build_context.ODIN_DEBUG) { lb_add_attribute_to_proc(m, p->value, "noinline"); - } + // } LLVMValueRef x = LLVMGetParam(p->value, 0); LLVMValueRef y = LLVMGetParam(p->value, 1); @@ -495,44 +500,56 @@ lbValue lb_map_get_proc_for_type(lbModule *m, Type *type) { lbValue h = {y, t_uintptr}; lbValue key_ptr = {z, t_rawptr}; + LLVM_SET_VALUE_NAME(h.value, "hash"); + lb_add_proc_attribute_at_index(p, 1+0, "nonnull"); - lb_add_proc_attribute_at_index(p, 1+0, "noalias"); lb_add_proc_attribute_at_index(p, 1+0, "readonly"); lb_add_proc_attribute_at_index(p, 1+2, "nonnull"); - lb_add_proc_attribute_at_index(p, 1+2, "noalias"); lb_add_proc_attribute_at_index(p, 1+2, "readonly"); - lbBlock *loop_block = lb_create_block(p, "loop"); - lbBlock *hash_block = lb_create_block(p, "hash"); - lbBlock *probe_block = lb_create_block(p, "probe"); - lbBlock *increment_block = lb_create_block(p, "increment"); + lbBlock *loop_block = lb_create_block(p, "loop"); + lbBlock *hash_block = lb_create_block(p, "hash"); + lbBlock *probe_block = lb_create_block(p, "probe"); + lbBlock *increment_block = lb_create_block(p, "increment"); lbBlock *hash_compare_block = lb_create_block(p, "hash_compare"); - lbBlock *key_compare_block = lb_create_block(p, "key_compare"); - lbBlock *value_block = lb_create_block(p, "value"); - lbBlock *nil_block = lb_create_block(p, "nil"); + lbBlock *key_compare_block = lb_create_block(p, "key_compare"); + lbBlock *value_block = lb_create_block(p, "value"); + lbBlock *nil_block = lb_create_block(p, "nil"); map_ptr = lb_emit_conv(p, map_ptr, t_raw_map_ptr); + LLVM_SET_VALUE_NAME(map_ptr.value, "map_ptr"); + lbValue map = lb_emit_load(p, map_ptr); + LLVM_SET_VALUE_NAME(map.value, "map"); lbValue length = lb_map_len(p, map); + LLVM_SET_VALUE_NAME(length.value, "length"); lb_emit_if(p, lb_emit_comp(p, Token_CmpEq, length, lb_const_nil(m, t_int)), nil_block, hash_block); lb_start_block(p, hash_block); key_ptr = lb_emit_conv(p, key_ptr, alloc_type_pointer(type->Map.key)); + LLVM_SET_VALUE_NAME(key_ptr.value, "key_ptr"); lbValue key = lb_emit_load(p, key_ptr); + LLVM_SET_VALUE_NAME(key.value, "key"); lbAddr pos = lb_add_local_generated(p, t_uintptr, false); lbAddr distance = lb_add_local_generated(p, t_uintptr, true); + LLVM_SET_VALUE_NAME(pos.addr.value, "pos"); + LLVM_SET_VALUE_NAME(distance.addr.value, "distance"); + lbValue capacity = lb_map_cap(p, map); - lbValue mask = lb_emit_conv(p, lb_emit_arith(p, Token_Sub, capacity, lb_const_int(m, t_int, 1), t_int), t_uintptr); + LLVM_SET_VALUE_NAME(capacity.value, "capacity"); + lbValue cap_minus_1 = lb_emit_arith(p, Token_Sub, capacity, lb_const_int(m, t_int, 1), t_int); + lbValue mask = lb_emit_conv(p, cap_minus_1, t_uintptr); + LLVM_SET_VALUE_NAME(mask.value, "mask"); { - auto args = array_make(heap_allocator(), 2); - args[0] = map; - args[1] = h; - lb_addr_store(p, pos, lb_emit_runtime_call(p, "map_desired_position", args)); + // map_desired_position inlined + lbValue the_pos = lb_emit_arith(p, Token_And, h, mask, t_uintptr); + the_pos = lb_emit_conv(p, the_pos, t_uintptr); + lb_addr_store(p, pos, the_pos); } lbValue zero_uintptr = lb_const_int(m, t_uintptr, 0); lbValue one_uintptr = lb_const_int(m, t_uintptr, 1); @@ -545,10 +562,16 @@ lbValue lb_map_get_proc_for_type(lbModule *m, Type *type) { vs = lb_emit_conv(p, vs, alloc_type_pointer(type->Map.value)); hs = lb_emit_conv(p, hs, alloc_type_pointer(t_uintptr)); + LLVM_SET_VALUE_NAME(ks.value, "ks"); + LLVM_SET_VALUE_NAME(vs.value, "vs"); + LLVM_SET_VALUE_NAME(hs.value, "hs"); + lb_emit_jump(p, loop_block); lb_start_block(p, loop_block); lbValue element_hash = lb_emit_load(p, lb_emit_ptr_offset(p, hs, lb_addr_load(p, pos))); + LLVM_SET_VALUE_NAME(element_hash.value, "element_hash"); + { // if element_hash == 0 { return nil } lb_emit_if(p, lb_emit_comp(p, Token_CmpEq, element_hash, zero_uintptr), nil_block, probe_block); @@ -556,11 +579,16 @@ lbValue lb_map_get_proc_for_type(lbModule *m, Type *type) { lb_start_block(p, probe_block); { - auto args = array_make(heap_allocator(), 3); - args[0] = map; - args[1] = element_hash; - args[2] = lb_addr_load(p, pos); - lbValue probe_distance = lb_emit_runtime_call(p, "map_probe_distance", args); + // map_probe_distance inlined + lbValue probe_distance = lb_emit_arith(p, Token_And, h, mask, t_uintptr); + probe_distance = lb_emit_conv(p, probe_distance, t_uintptr); + + lbValue cap = lb_emit_conv(p, capacity, t_uintptr); + lbValue base = lb_emit_arith(p, Token_Add, lb_addr_load(p, pos), cap, t_uintptr); + probe_distance = lb_emit_arith(p, Token_Sub, base, probe_distance, t_uintptr); + probe_distance = lb_emit_arith(p, Token_And, probe_distance, mask, t_uintptr); + LLVM_SET_VALUE_NAME(probe_distance.value, "probe_distance"); + lbValue cond = lb_emit_comp(p, Token_Gt, lb_addr_load(p, distance), probe_distance); lb_emit_if(p, cond, nil_block, hash_compare_block); } @@ -574,6 +602,8 @@ lbValue lb_map_get_proc_for_type(lbModule *m, Type *type) { { lbValue element_key = lb_map_cell_index_static(p, type->Map.key, ks, lb_addr_load(p, pos)); element_key = lb_emit_conv(p, element_key, ks.type); + + LLVM_SET_VALUE_NAME(element_key.value, "element_key_ptr"); lbValue cond = lb_emit_comp(p, Token_CmpEq, lb_emit_load(p, element_key), key); lb_emit_if(p, cond, value_block, increment_block); } @@ -581,6 +611,7 @@ lbValue lb_map_get_proc_for_type(lbModule *m, Type *type) { lb_start_block(p, value_block); { lbValue element_value = lb_map_cell_index_static(p, type->Map.value, vs, lb_addr_load(p, pos)); + LLVM_SET_VALUE_NAME(element_value.value, "element_value_ptr"); element_value = lb_emit_conv(p, element_value, t_rawptr); LLVMBuildRet(p->builder, element_value.value); } @@ -601,18 +632,21 @@ lbValue lb_map_get_proc_for_type(lbModule *m, Type *type) { LLVMBuildRet(p->builder, res.value); } + // gb_printf_err("%s\n", LLVMPrintValueToString(p->value)); return {p->value, p->type}; } -void lb_debug_print(lbProcedure *p, String const &str) { - auto args = array_make(heap_allocator(), 1); - args[0] = lb_const_string(p->module, str); - lb_emit_runtime_call(p, "print_string", args); -} +// gb_internal void lb_debug_print(lbProcedure *p, String const &str) { +// auto args = array_make(heap_allocator(), 1); +// args[0] = lb_const_string(p->module, str); +// lb_emit_runtime_call(p, "print_string", args); +// } -lbValue lb_map_set_proc_for_type(lbModule *m, Type *type) { - GB_ASSERT(build_context.use_static_map_calls); +gb_internal lbValue lb_map_set_proc_for_type(lbModule *m, Type *type) { + TEMPORARY_ALLOCATOR_GUARD(); + + GB_ASSERT(!build_context.dynamic_map_calls); type = base_type(type); GB_ASSERT(type->kind == Type_Map); @@ -622,10 +656,10 @@ lbValue lb_map_set_proc_for_type(lbModule *m, Type *type) { GB_ASSERT(*found != nullptr); return {(*found)->value, (*found)->type}; } - static u32 proc_index = 0; + static std::atomic proc_index; char buf[32] = {}; - isize n = gb_snprintf(buf, 32, "__$map_set-%u", ++proc_index); + isize n = gb_snprintf(buf, 32, "__$map_set-%u", 1+proc_index.fetch_add(1)); char *str = gb_alloc_str_len(permanent_allocator(), buf, n-1); String proc_name = make_string_c(str); @@ -673,7 +707,7 @@ lbValue lb_map_set_proc_for_type(lbModule *m, Type *type) { { lbValue map_get_proc = lb_map_get_proc_for_type(m, type); - auto args = array_make(permanent_allocator(), 3); + auto args = array_make(temporary_allocator(), 3); args[0] = lb_emit_conv(p, map_ptr, t_rawptr); args[1] = hash; args[2] = key_ptr; @@ -686,6 +720,7 @@ lbValue lb_map_set_proc_for_type(lbModule *m, Type *type) { lbBlock *check_grow_block = lb_create_block(p, "check-grow"); lbBlock *grow_fail_block = lb_create_block(p, "grow-fail"); lbBlock *insert_block = lb_create_block(p, "insert"); + lbBlock *rehash_block = lb_create_block(p, "rehash"); lb_emit_if(p, lb_emit_comp_against_nil(p, Token_NotEq, found_ptr), found_block, check_grow_block); lb_start_block(p, found_block); @@ -699,21 +734,28 @@ lbValue lb_map_set_proc_for_type(lbModule *m, Type *type) { lbValue map_info = lb_gen_map_info_ptr(p->module, type); { - auto args = array_make(permanent_allocator(), 3); + auto args = array_make(temporary_allocator(), 3); args[0] = lb_emit_conv(p, map_ptr, t_rawptr); args[1] = map_info; args[2] = lb_emit_load(p, location_ptr); - lbValue grow_err = lb_emit_runtime_call(p, "__dynamic_map_check_grow", args); + lbValue grow_err_and_has_grown = lb_emit_runtime_call(p, "__dynamic_map_check_grow", args); + lbValue grow_err = lb_emit_struct_ev(p, grow_err_and_has_grown, 0); + lbValue has_grown = lb_emit_struct_ev(p, grow_err_and_has_grown, 1); lb_emit_if(p, lb_emit_comp_against_nil(p, Token_NotEq, grow_err), grow_fail_block, insert_block); lb_start_block(p, grow_fail_block); LLVMBuildRet(p->builder, LLVMConstNull(lb_type(m, t_rawptr))); + + lb_emit_if(p, has_grown, grow_fail_block, rehash_block); + lb_start_block(p, rehash_block); + lbValue key = lb_emit_load(p, key_ptr); + hash = lb_gen_map_key_hash(p, map_ptr, key, nullptr); } lb_start_block(p, insert_block); { - auto args = array_make(permanent_allocator(), 5); + auto args = array_make(temporary_allocator(), 5); args[0] = lb_emit_conv(p, map_ptr, t_rawptr); args[1] = map_info; args[2] = hash; @@ -730,55 +772,7 @@ lbValue lb_map_set_proc_for_type(lbModule *m, Type *type) { return {p->value, p->type}; } - -lbValue lb_generate_anonymous_proc_lit(lbModule *m, String const &prefix_name, Ast *expr, lbProcedure *parent) { - lbProcedure **found = map_get(&m->gen->anonymous_proc_lits, expr); - if (found) { - return lb_find_procedure_value_from_entity(m, (*found)->entity); - } - - ast_node(pl, ProcLit, expr); - - // NOTE(bill): Generate a new name - // parent$count - isize name_len = prefix_name.len + 1 + 8 + 1; - char *name_text = gb_alloc_array(permanent_allocator(), char, name_len); - i32 name_id = cast(i32)m->gen->anonymous_proc_lits.entries.count; - - name_len = gb_snprintf(name_text, name_len, "%.*s$anon-%d", LIT(prefix_name), name_id); - String name = make_string((u8 *)name_text, name_len-1); - - Type *type = type_of_expr(expr); - - Token token = {}; - token.pos = ast_token(expr).pos; - token.kind = Token_Ident; - token.string = name; - Entity *e = alloc_entity_procedure(nullptr, token, type, pl->tags); - e->file = expr->file(); - e->decl_info = pl->decl; - e->code_gen_module = m; - e->flags |= EntityFlag_ProcBodyChecked; - lbProcedure *p = lb_create_procedure(m, e); - - lbValue value = {}; - value.value = p->value; - value.type = p->type; - - array_add(&m->procedures_to_generate, p); - if (parent != nullptr) { - array_add(&parent->children, p); - } else { - string_map_set(&m->members, name, value); - } - - map_set(&m->gen->anonymous_proc_lits, expr, p); - - return value; -} - - -lbValue lb_gen_map_cell_info_ptr(lbModule *m, Type *type) { +gb_internal lbValue lb_gen_map_cell_info_ptr(lbModule *m, Type *type) { lbAddr *found = map_get(&m->map_cell_info_map, type); if (found) { return found->addr; @@ -802,7 +796,7 @@ lbValue lb_gen_map_cell_info_ptr(lbModule *m, Type *type) { return addr.addr; } -lbValue lb_gen_map_info_ptr(lbModule *m, Type *map_type) { +gb_internal lbValue lb_gen_map_info_ptr(lbModule *m, Type *map_type) { map_type = base_type(map_type); GB_ASSERT(map_type->kind == Type_Map); @@ -833,7 +827,7 @@ lbValue lb_gen_map_info_ptr(lbModule *m, Type *map_type) { return addr.addr; } -lbValue lb_const_hash(lbModule *m, lbValue key, Type *key_type) { +gb_internal lbValue lb_const_hash(lbModule *m, lbValue key, Type *key_type) { if (true) { return {}; } @@ -880,78 +874,82 @@ lbValue lb_const_hash(lbModule *m, lbValue key, Type *key_type) { return hashed_key; } -lbValue lb_gen_map_key_hash(lbProcedure *p, lbValue key, Type *key_type, lbValue *key_ptr_) { +gb_internal lbValue lb_gen_map_key_hash(lbProcedure *p, lbValue const &map_ptr, lbValue key, lbValue *key_ptr_) { + TEMPORARY_ALLOCATOR_GUARD(); + lbValue key_ptr = lb_address_from_load_or_generate_local(p, key); key_ptr = lb_emit_conv(p, key_ptr, t_rawptr); if (key_ptr_) *key_ptr_ = key_ptr; + Type* key_type = base_type(type_deref(map_ptr.type))->Map.key; + lbValue hashed_key = lb_const_hash(p->module, key, key_type); if (hashed_key.value == nullptr) { lbValue hasher = lb_hasher_proc_for_type(p->module, key_type); - auto args = array_make(permanent_allocator(), 2); + lbValue seed = {}; + { + auto args = array_make(temporary_allocator(), 1); + args[0] = lb_map_data_uintptr(p, lb_emit_load(p, map_ptr)); + seed = lb_emit_runtime_call(p, "map_seed_from_map_data", args); + } + + auto args = array_make(temporary_allocator(), 2); args[0] = key_ptr; - args[1] = lb_const_int(p->module, t_uintptr, 0); + args[1] = seed; hashed_key = lb_emit_call(p, hasher, args); } return hashed_key; } -lbValue lb_internal_dynamic_map_get_ptr(lbProcedure *p, lbValue const &map_ptr, lbValue const &key) { +gb_internal lbValue lb_internal_dynamic_map_get_ptr(lbProcedure *p, lbValue const &map_ptr, lbValue const &key) { + TEMPORARY_ALLOCATOR_GUARD(); + Type *map_type = base_type(type_deref(map_ptr.type)); GB_ASSERT(map_type->kind == Type_Map); lbValue ptr = {}; lbValue key_ptr = {}; - lbValue hash = lb_gen_map_key_hash(p, key, map_type->Map.key, &key_ptr); + lbValue hash = lb_gen_map_key_hash(p, map_ptr, key, &key_ptr); - if (build_context.use_static_map_calls) { - lbValue map_get_proc = lb_map_get_proc_for_type(p->module, map_type); - - auto args = array_make(permanent_allocator(), 3); - args[0] = lb_emit_conv(p, map_ptr, t_rawptr); - args[1] = hash; - args[2] = key_ptr; - - ptr = lb_emit_call(p, map_get_proc, args); - } else { - auto args = array_make(permanent_allocator(), 4); + if (build_context.dynamic_map_calls) { + auto args = array_make(temporary_allocator(), 4); args[0] = lb_emit_transmute(p, map_ptr, t_raw_map_ptr); args[1] = lb_gen_map_info_ptr(p->module, map_type); args[2] = hash; args[3] = key_ptr; ptr = lb_emit_runtime_call(p, "__dynamic_map_get", args); + } else { + lbValue map_get_proc = lb_map_get_proc_for_type(p->module, map_type); + + auto args = array_make(temporary_allocator(), 3); + args[0] = lb_emit_conv(p, map_ptr, t_rawptr); + args[1] = hash; + args[2] = key_ptr; + + ptr = lb_emit_call(p, map_get_proc, args); } return lb_emit_conv(p, ptr, alloc_type_pointer(map_type->Map.value)); } -void lb_internal_dynamic_map_set(lbProcedure *p, lbValue const &map_ptr, Type *map_type, - lbValue const &map_key, lbValue const &map_value, Ast *node) { +gb_internal void lb_internal_dynamic_map_set(lbProcedure *p, lbValue const &map_ptr, Type *map_type, + lbValue const &map_key, lbValue const &map_value, Ast *node) { + TEMPORARY_ALLOCATOR_GUARD(); + map_type = base_type(map_type); GB_ASSERT(map_type->kind == Type_Map); lbValue key_ptr = {}; - lbValue hash = lb_gen_map_key_hash(p, map_key, map_type->Map.key, &key_ptr); + lbValue hash = lb_gen_map_key_hash(p, map_ptr, map_key, &key_ptr); lbValue v = lb_emit_conv(p, map_value, map_type->Map.value); lbValue value_ptr = lb_address_from_load_or_generate_local(p, v); - if (build_context.use_static_map_calls) { - lbValue map_set_proc = lb_map_set_proc_for_type(p->module, map_type); - - auto args = array_make(permanent_allocator(), 5); - args[0] = lb_emit_conv(p, map_ptr, t_rawptr); - args[1] = hash; - args[2] = lb_emit_conv(p, key_ptr, t_rawptr); - args[3] = lb_emit_conv(p, value_ptr, t_rawptr); - args[4] = lb_emit_source_code_location_as_global(p, node); - - lb_emit_call(p, map_set_proc, args); - } else { - auto args = array_make(permanent_allocator(), 6); + if (build_context.dynamic_map_calls) { + auto args = array_make(temporary_allocator(), 6); args[0] = lb_emit_conv(p, map_ptr, t_raw_map_ptr); args[1] = lb_gen_map_info_ptr(p->module, map_type); args[2] = hash; @@ -959,18 +957,31 @@ void lb_internal_dynamic_map_set(lbProcedure *p, lbValue const &map_ptr, Type *m args[4] = lb_emit_conv(p, value_ptr, t_rawptr); args[5] = lb_emit_source_code_location_as_global(p, node); lb_emit_runtime_call(p, "__dynamic_map_set", args); + } else { + lbValue map_set_proc = lb_map_set_proc_for_type(p->module, map_type); + + auto args = array_make(temporary_allocator(), 5); + args[0] = lb_emit_conv(p, map_ptr, t_rawptr); + args[1] = hash; + args[2] = lb_emit_conv(p, key_ptr, t_rawptr); + args[3] = lb_emit_conv(p, value_ptr, t_rawptr); + args[4] = lb_emit_source_code_location_as_global(p, node); + + lb_emit_call(p, map_set_proc, args); } } -lbValue lb_dynamic_map_reserve(lbProcedure *p, lbValue const &map_ptr, isize const capacity, TokenPos const &pos) { +gb_internal lbValue lb_dynamic_map_reserve(lbProcedure *p, lbValue const &map_ptr, isize const capacity, TokenPos const &pos) { GB_ASSERT(!build_context.no_dynamic_literals); + TEMPORARY_ALLOCATOR_GUARD(); + String proc_name = {}; if (p->entity) { proc_name = p->entity->token.string; } - auto args = array_make(permanent_allocator(), 4); + auto args = array_make(temporary_allocator(), 4); args[0] = lb_emit_conv(p, map_ptr, t_rawptr); args[1] = lb_gen_map_info_ptr(p->module, type_deref(map_ptr.type)); args[2] = lb_const_int(p->module, t_uint, capacity); @@ -986,14 +997,10 @@ struct lbGlobalVariable { bool is_initialized; }; -lbProcedure *lb_create_startup_type_info(lbModule *m) { - if (build_context.disallow_rtti) { +gb_internal lbProcedure *lb_create_startup_type_info(lbModule *m) { + if (build_context.no_rtti) { return nullptr; } - LLVMPassManagerRef default_function_pass_manager = LLVMCreateFunctionPassManagerForModule(m->mod); - lb_populate_function_pass_manager(m, default_function_pass_manager, false, build_context.optimization_level); - LLVMFinalizeFunctionPassManager(default_function_pass_manager); - Type *proc_type = alloc_type_proc(nullptr, nullptr, 0, nullptr, 0, false, ProcCC_CDecl); lbProcedure *p = lb_create_dummy_procedure(m, str_lit(LB_STARTUP_TYPE_INFO_PROC_NAME), proc_type); @@ -1014,13 +1021,10 @@ lbProcedure *lb_create_startup_type_info(lbModule *m) { gb_printf_err("\n\n\n\n"); LLVMVerifyFunction(p->value, LLVMAbortProcessAction); } - - lb_run_function_pass_manager(default_function_pass_manager, p); - return p; } -lbProcedure *lb_create_objc_names(lbModule *main_module) { +gb_internal lbProcedure *lb_create_objc_names(lbModule *main_module) { if (build_context.metrics.os != TargetOs_darwin) { return nullptr; } @@ -1031,48 +1035,36 @@ lbProcedure *lb_create_objc_names(lbModule *main_module) { return p; } -void lb_finalize_objc_names(lbProcedure *p) { +gb_internal void lb_finalize_objc_names(lbProcedure *p) { if (p == nullptr) { return; } lbModule *m = p->module; - LLVMPassManagerRef default_function_pass_manager = LLVMCreateFunctionPassManagerForModule(m->mod); - lb_populate_function_pass_manager(m, default_function_pass_manager, false, build_context.optimization_level); - LLVMFinalizeFunctionPassManager(default_function_pass_manager); + TEMPORARY_ALLOCATOR_GUARD(); - - auto args = array_make(permanent_allocator(), 1); + auto args = array_make(temporary_allocator(), 1); LLVMSetLinkage(p->value, LLVMInternalLinkage); lb_begin_procedure_body(p); - for_array(i, m->objc_classes.entries) { - auto const &entry = m->objc_classes.entries[i]; - String name = entry.key.string; + for (auto const &entry : m->objc_classes) { + String name = entry.key; args[0] = lb_const_value(m, t_cstring, exact_value_string(name)); lbValue ptr = lb_emit_runtime_call(p, "objc_lookUpClass", args); lb_addr_store(p, entry.value, ptr); } - for_array(i, m->objc_selectors.entries) { - auto const &entry = m->objc_selectors.entries[i]; - String name = entry.key.string; + for (auto const &entry : m->objc_selectors) { + String name = entry.key; args[0] = lb_const_value(m, t_cstring, exact_value_string(name)); lbValue ptr = lb_emit_runtime_call(p, "sel_registerName", args); lb_addr_store(p, entry.value, ptr); } lb_end_procedure_body(p); - - lb_run_function_pass_manager(default_function_pass_manager, p); - } -lbProcedure *lb_create_startup_runtime(lbModule *main_module, lbProcedure *startup_type_info, lbProcedure *objc_names, Array &global_variables) { // Startup Runtime - LLVMPassManagerRef default_function_pass_manager = LLVMCreateFunctionPassManagerForModule(main_module->mod); - lb_populate_function_pass_manager(main_module, default_function_pass_manager, false, build_context.optimization_level); - LLVMFinalizeFunctionPassManager(default_function_pass_manager); - +gb_internal lbProcedure *lb_create_startup_runtime(lbModule *main_module, lbProcedure *startup_type_info, lbProcedure *objc_names, Array &global_variables) { // Startup Runtime Type *proc_type = alloc_type_proc(nullptr, nullptr, 0, nullptr, 0, false, ProcCC_Odin); lbProcedure *p = lb_create_dummy_procedure(main_module, str_lit(LB_STARTUP_RUNTIME_PROC_NAME), proc_type); @@ -1088,76 +1080,70 @@ lbProcedure *lb_create_startup_runtime(lbModule *main_module, lbProcedure *start LLVMBuildCall2(p->builder, lb_type_internal_for_procedures_raw(main_module, objc_names->type), objc_names->value, nullptr, 0, ""); } - for_array(i, global_variables) { - auto *var = &global_variables[i]; - if (var->is_initialized) { + for (auto &var : global_variables) { + if (var.is_initialized) { continue; } lbModule *entity_module = main_module; - Entity *e = var->decl->entity; + Entity *e = var.decl->entity; GB_ASSERT(e->kind == Entity_Variable); e->code_gen_module = entity_module; - Ast *init_expr = var->decl->init_expr; + Ast *init_expr = var.decl->init_expr; if (init_expr != nullptr) { lbValue init = lb_build_expr(p, init_expr); if (init.value == nullptr) { - LLVMTypeRef global_type = llvm_addr_type(p->module, var->var); - if (is_type_untyped_undef(init.type)) { - // LLVMSetInitializer(var->var.value, LLVMGetUndef(global_type)); - LLVMSetInitializer(var->var.value, LLVMConstNull(global_type)); - var->is_initialized = true; - continue; - } else if (is_type_untyped_nil(init.type)) { - LLVMSetInitializer(var->var.value, LLVMConstNull(global_type)); - var->is_initialized = true; + LLVMTypeRef global_type = llvm_addr_type(p->module, var.var); + if (is_type_untyped_nil(init.type)) { + LLVMSetInitializer(var.var.value, LLVMConstNull(global_type)); + var.is_initialized = true; continue; } GB_PANIC("Invalid init value, got %s", expr_to_string(init_expr)); } if (is_type_any(e->type) || is_type_union(e->type)) { - var->init = init; + var.init = init; } else if (lb_is_const_or_global(init)) { - if (!var->is_initialized) { + if (!var.is_initialized) { if (is_type_proc(init.type)) { init.value = LLVMConstPointerCast(init.value, lb_type(p->module, init.type)); } - LLVMSetInitializer(var->var.value, init.value); - var->is_initialized = true; + LLVMSetInitializer(var.var.value, init.value); + var.is_initialized = true; continue; } } else { - var->init = init; + var.init = init; } } - if (var->init.value != nullptr) { - GB_ASSERT(!var->is_initialized); - Type *t = type_deref(var->var.type); + if (var.init.value != nullptr) { + GB_ASSERT(!var.is_initialized); + Type *t = type_deref(var.var.type); if (is_type_any(t)) { // NOTE(bill): Edge case for 'any' type - Type *var_type = default_type(var->init.type); - lbAddr g = lb_add_global_generated(main_module, var_type, var->init); - lb_addr_store(p, g, var->init); + Type *var_type = default_type(var.init.type); + lbAddr g = lb_add_global_generated(main_module, var_type, var.init); + lb_addr_store(p, g, var.init); lbValue gp = lb_addr_get_ptr(p, g); - lbValue data = lb_emit_struct_ep(p, var->var, 0); - lbValue ti = lb_emit_struct_ep(p, var->var, 1); + lbValue data = lb_emit_struct_ep(p, var.var, 0); + lbValue ti = lb_emit_struct_ep(p, var.var, 1); lb_emit_store(p, data, lb_emit_conv(p, gp, t_rawptr)); lb_emit_store(p, ti, lb_type_info(main_module, var_type)); } else { - LLVMTypeRef vt = llvm_addr_type(p->module, var->var); - lbValue src0 = lb_emit_conv(p, var->init, t); + LLVMTypeRef vt = llvm_addr_type(p->module, var.var); + lbValue src0 = lb_emit_conv(p, var.init, t); LLVMValueRef src = OdinLLVMBuildTransmute(p, src0.value, vt); - LLVMValueRef dst = var->var.value; + LLVMValueRef dst = var.var.value; LLVMBuildStore(p->builder, src, dst); } - var->is_initialized = true; + var.is_initialized = true; } } @@ -1178,13 +1164,556 @@ lbProcedure *lb_create_startup_runtime(lbModule *main_module, lbProcedure *start LLVMVerifyFunction(p->value, LLVMAbortProcessAction); } - lb_run_function_pass_manager(default_function_pass_manager, p); + return p; +} + +gb_internal lbProcedure *lb_create_cleanup_runtime(lbModule *main_module) { // Cleanup Runtime + Type *proc_type = alloc_type_proc(nullptr, nullptr, 0, nullptr, 0, false, ProcCC_Odin); + + lbProcedure *p = lb_create_dummy_procedure(main_module, str_lit(LB_CLEANUP_RUNTIME_PROC_NAME), proc_type); + p->is_startup = true; + + lb_begin_procedure_body(p); + + CheckerInfo *info = main_module->gen->info; + + for (Entity *e : info->fini_procedures) { + lbValue value = lb_find_procedure_value_from_entity(main_module, e); + lb_emit_call(p, value, {}, ProcInlining_none); + } + + lb_end_procedure_body(p); + + if (!main_module->debug_builder && LLVMVerifyFunction(p->value, LLVMReturnStatusAction)) { + gb_printf_err("LLVM CODE GEN FAILED FOR PROCEDURE: %s\n", "main"); + LLVMDumpValue(p->value); + gb_printf_err("\n\n\n\n"); + LLVMVerifyFunction(p->value, LLVMAbortProcessAction); + } return p; } -lbProcedure *lb_create_main_procedure(lbModule *m, lbProcedure *startup_runtime) { +gb_internal WORKER_TASK_PROC(lb_generate_procedures_and_types_per_module) { + lbModule *m = cast(lbModule *)data; + for (Entity *e : m->global_procedures_and_types_to_create) { + if (e->kind == Entity_TypeName) { + (void)lb_get_entity_name(m, e); + lb_type(m, e->type); + } + } + + for (Entity *e : m->global_procedures_and_types_to_create) { + if (e->kind == Entity_Procedure) { + (void)lb_get_entity_name(m, e); + array_add(&m->procedures_to_generate, lb_create_procedure(m, e)); + } + } + return 0; +} + +gb_internal void lb_create_global_procedures_and_types(lbGenerator *gen, CheckerInfo *info, bool do_threading) { + auto *min_dep_set = &info->minimum_dependency_set; + + for (Entity *e : info->entities) { + String name = e->token.string; + Scope * scope = e->scope; + + if ((scope->flags & ScopeFlag_File) == 0) { + continue; + } + + Scope *package_scope = scope->parent; + GB_ASSERT(package_scope->flags & ScopeFlag_Pkg); + + switch (e->kind) { + case Entity_Variable: + // NOTE(bill): Handled above as it requires a specific load order + continue; + case Entity_ProcGroup: + continue; + + case Entity_TypeName: + case Entity_Procedure: + break; + case Entity_Constant: + if (build_context.ODIN_DEBUG) { + add_debug_info_for_global_constant_from_entity(gen, e); + } + break; + } + + bool polymorphic_struct = false; + if (e->type != nullptr && e->kind == Entity_TypeName) { + Type *bt = base_type(e->type); + if (bt->kind == Type_Struct) { + polymorphic_struct = is_type_polymorphic(bt); + } + } + + if (!polymorphic_struct && !ptr_set_exists(min_dep_set, e)) { + // NOTE(bill): Nothing depends upon it so doesn't need to be built + continue; + } + + lbModule *m = &gen->default_module; + if (USE_SEPARATE_MODULES) { + m = lb_module_of_entity(gen, e); + } + + array_add(&m->global_procedures_and_types_to_create, e); + } + + for (auto const &entry : gen->modules) { + lbModule *m = entry.value; + if (do_threading) { + thread_pool_add_task(lb_generate_procedures_and_types_per_module, m); + } else { + lb_generate_procedures_and_types_per_module(m); + } + } + + thread_pool_wait(); +} + +gb_internal void lb_generate_procedure(lbModule *m, lbProcedure *p); + + +gb_internal bool lb_is_module_empty(lbModule *m) { + if (LLVMGetFirstFunction(m->mod) == nullptr && + LLVMGetFirstGlobal(m->mod) == nullptr) { + return true; + } + for (auto fn = LLVMGetFirstFunction(m->mod); fn != nullptr; fn = LLVMGetNextFunction(fn)) { + if (LLVMGetFirstBasicBlock(fn) != nullptr) { + return false; + } + } + + for (auto g = LLVMGetFirstGlobal(m->mod); g != nullptr; g = LLVMGetNextGlobal(g)) { + if (LLVMGetLinkage(g) == LLVMExternalLinkage) { + continue; + } + if (!LLVMIsExternallyInitialized(g)) { + return false; + } + } + return true; +} + +struct lbLLVMEmitWorker { + LLVMTargetMachineRef target_machine; + LLVMCodeGenFileType code_gen_file_type; + String filepath_obj; + lbModule *m; +}; + +gb_internal WORKER_TASK_PROC(lb_llvm_emit_worker_proc) { + GB_ASSERT(MULTITHREAD_OBJECT_GENERATION); + + char *llvm_error = nullptr; + + auto wd = cast(lbLLVMEmitWorker *)data; + + if (LLVMTargetMachineEmitToFile(wd->target_machine, wd->m->mod, cast(char *)wd->filepath_obj.text, wd->code_gen_file_type, &llvm_error)) { + gb_printf_err("LLVM Error: %s\n", llvm_error); + gb_exit(1); + } + debugf("Generated File: %.*s\n", LIT(wd->filepath_obj)); + return 0; +} + + +gb_internal void lb_llvm_function_pass_per_function_internal(lbModule *module, lbProcedure *p, lbFunctionPassManagerKind pass_manager_kind = lbFunctionPassManager_default) { + LLVMPassManagerRef pass_manager = module->function_pass_managers[pass_manager_kind]; + lb_run_function_pass_manager(pass_manager, p, pass_manager_kind); +} + +gb_internal WORKER_TASK_PROC(lb_llvm_function_pass_per_module) { + lbModule *m = cast(lbModule *)data; + { + GB_ASSERT(m->function_pass_managers[lbFunctionPassManager_default] == nullptr); + + m->function_pass_managers[lbFunctionPassManager_default] = LLVMCreateFunctionPassManagerForModule(m->mod); + m->function_pass_managers[lbFunctionPassManager_default_without_memcpy] = LLVMCreateFunctionPassManagerForModule(m->mod); + m->function_pass_managers[lbFunctionPassManager_none] = LLVMCreateFunctionPassManagerForModule(m->mod); + m->function_pass_managers[lbFunctionPassManager_minimal] = LLVMCreateFunctionPassManagerForModule(m->mod); + m->function_pass_managers[lbFunctionPassManager_size] = LLVMCreateFunctionPassManagerForModule(m->mod); + m->function_pass_managers[lbFunctionPassManager_speed] = LLVMCreateFunctionPassManagerForModule(m->mod); + + LLVMInitializeFunctionPassManager(m->function_pass_managers[lbFunctionPassManager_default]); + LLVMInitializeFunctionPassManager(m->function_pass_managers[lbFunctionPassManager_default_without_memcpy]); + LLVMInitializeFunctionPassManager(m->function_pass_managers[lbFunctionPassManager_none]); + LLVMInitializeFunctionPassManager(m->function_pass_managers[lbFunctionPassManager_minimal]); + LLVMInitializeFunctionPassManager(m->function_pass_managers[lbFunctionPassManager_size]); + LLVMInitializeFunctionPassManager(m->function_pass_managers[lbFunctionPassManager_speed]); + + lb_populate_function_pass_manager(m, m->function_pass_managers[lbFunctionPassManager_default], false, build_context.optimization_level); + lb_populate_function_pass_manager(m, m->function_pass_managers[lbFunctionPassManager_default_without_memcpy], true, build_context.optimization_level); + lb_populate_function_pass_manager_specific(m, m->function_pass_managers[lbFunctionPassManager_none], -1); + lb_populate_function_pass_manager_specific(m, m->function_pass_managers[lbFunctionPassManager_minimal], 0); + lb_populate_function_pass_manager_specific(m, m->function_pass_managers[lbFunctionPassManager_size], 1); + lb_populate_function_pass_manager_specific(m, m->function_pass_managers[lbFunctionPassManager_speed], 2); + + LLVMFinalizeFunctionPassManager(m->function_pass_managers[lbFunctionPassManager_default]); + LLVMFinalizeFunctionPassManager(m->function_pass_managers[lbFunctionPassManager_default_without_memcpy]); + LLVMFinalizeFunctionPassManager(m->function_pass_managers[lbFunctionPassManager_none]); + LLVMFinalizeFunctionPassManager(m->function_pass_managers[lbFunctionPassManager_minimal]); + LLVMFinalizeFunctionPassManager(m->function_pass_managers[lbFunctionPassManager_size]); + LLVMFinalizeFunctionPassManager(m->function_pass_managers[lbFunctionPassManager_speed]); + } + + if (m == &m->gen->default_module) { + lb_llvm_function_pass_per_function_internal(m, m->gen->startup_type_info); + lb_llvm_function_pass_per_function_internal(m, m->gen->startup_runtime); + lb_llvm_function_pass_per_function_internal(m, m->gen->cleanup_runtime); + lb_llvm_function_pass_per_function_internal(m, m->gen->objc_names); + } + + for (lbProcedure *p : m->procedures_to_generate) { + if (p->body != nullptr) { // Build Procedure + lbFunctionPassManagerKind pass_manager_kind = lbFunctionPassManager_default; + if (p->flags & lbProcedureFlag_WithoutMemcpyPass) { + pass_manager_kind = lbFunctionPassManager_default_without_memcpy; + } else { + if (p->entity && p->entity->kind == Entity_Procedure) { + switch (p->entity->Procedure.optimization_mode) { + case ProcedureOptimizationMode_None: + case ProcedureOptimizationMode_Minimal: + pass_manager_kind = lbFunctionPassManager_minimal; + break; + case ProcedureOptimizationMode_Size: + pass_manager_kind = lbFunctionPassManager_size; + break; + case ProcedureOptimizationMode_Speed: + pass_manager_kind = lbFunctionPassManager_speed; + break; + } + } + } + + lb_llvm_function_pass_per_function_internal(m, p, pass_manager_kind); + } + } + + for (auto const &entry : m->equal_procs) { + lbProcedure *p = entry.value; + lb_llvm_function_pass_per_function_internal(m, p); + } + for (auto const &entry : m->hasher_procs) { + lbProcedure *p = entry.value; + lb_llvm_function_pass_per_function_internal(m, p); + } + for (auto const &entry : m->map_get_procs) { + lbProcedure *p = entry.value; + lb_llvm_function_pass_per_function_internal(m, p, lbFunctionPassManager_none); + } + for (auto const &entry : m->map_set_procs) { + lbProcedure *p = entry.value; + lb_llvm_function_pass_per_function_internal(m, p, lbFunctionPassManager_none); + } + + return 0; +} + + +struct lbLLVMModulePassWorkerData { + lbModule *m; + LLVMTargetMachineRef target_machine; +}; + +gb_internal WORKER_TASK_PROC(lb_llvm_module_pass_worker_proc) { + auto wd = cast(lbLLVMModulePassWorkerData *)data; + + lb_run_remove_unused_function_pass(wd->m); + lb_run_remove_unused_globals_pass(wd->m); + + LLVMPassManagerRef module_pass_manager = LLVMCreatePassManager(); + lb_populate_module_pass_manager(wd->target_machine, module_pass_manager, build_context.optimization_level); + LLVMRunPassManager(module_pass_manager, wd->m->mod); + return 0; +} + + + +gb_internal WORKER_TASK_PROC(lb_generate_procedures_worker_proc) { + lbModule *m = cast(lbModule *)data; + for (isize i = 0; i < m->procedures_to_generate.count; i++) { + lbProcedure *p = m->procedures_to_generate[i]; + lb_generate_procedure(p->module, p); + } + return 0; +} + +gb_internal void lb_generate_procedures(lbGenerator *gen, bool do_threading) { + for (auto const &entry : gen->modules) { + lbModule *m = entry.value; + if (do_threading) { + thread_pool_add_task(lb_generate_procedures_worker_proc, m); + } else { + lb_generate_procedures_worker_proc(m); + } + } + + thread_pool_wait(); +} + +gb_internal WORKER_TASK_PROC(lb_generate_missing_procedures_to_check_worker_proc) { + lbModule *m = cast(lbModule *)data; + for (isize i = 0; i < m->missing_procedures_to_check.count; i++) { + lbProcedure *p = m->missing_procedures_to_check[i]; + debugf("Generate missing procedure: %.*s module %p\n", LIT(p->name), m); + lb_generate_procedure(m, p); + } + return 0; +} + +gb_internal void lb_generate_missing_procedures(lbGenerator *gen, bool do_threading) { + for (auto const &entry : gen->modules) { + lbModule *m = entry.value; + // NOTE(bill): procedures may be added during generation + if (do_threading) { + thread_pool_add_task(lb_generate_missing_procedures_to_check_worker_proc, m); + } else { + lb_generate_missing_procedures_to_check_worker_proc(m); + } + } + + thread_pool_wait(); +} + +gb_internal void lb_debug_info_complete_types_and_finalize(lbGenerator *gen) { + for (auto const &entry : gen->modules) { + lbModule *m = entry.value; + if (m->debug_builder != nullptr) { + lb_debug_complete_types(m); + } + } + for (auto const &entry : gen->modules) { + lbModule *m = entry.value; + if (m->debug_builder != nullptr) { + LLVMDIBuilderFinalize(m->debug_builder); + } + } +} + +gb_internal void lb_llvm_function_passes(lbGenerator *gen, bool do_threading) { + for (auto const &entry : gen->modules) { + lbModule *m = entry.value; + if (do_threading) { + thread_pool_add_task(lb_llvm_function_pass_per_module, m); + } else { + lb_llvm_function_pass_per_module(m); + } + } + thread_pool_wait(); +} + + +gb_internal void lb_llvm_module_passes(lbGenerator *gen, bool do_threading) { + for (auto const &entry : gen->modules) { + lbModule *m = entry.value; + auto wd = gb_alloc_item(permanent_allocator(), lbLLVMModulePassWorkerData); + wd->m = m; + wd->target_machine = m->target_machine; + + if (do_threading) { + thread_pool_add_task(lb_llvm_module_pass_worker_proc, wd); + } else { + lb_llvm_module_pass_worker_proc(wd); + } + } + thread_pool_wait(); +} + +gb_internal String lb_filepath_ll_for_module(lbModule *m) { + String path = concatenate3_strings(permanent_allocator(), + build_context.build_paths[BuildPath_Output].basename, + STR_LIT("/"), + build_context.build_paths[BuildPath_Output].name + ); + + if (m->file) { + char buf[32] = {}; + isize n = gb_snprintf(buf, gb_size_of(buf), "-%u", m->file->id); + String suffix = make_string((u8 *)buf, n-1); + path = concatenate_strings(permanent_allocator(), path, suffix); + } else if (m->pkg) { + path = concatenate3_strings(permanent_allocator(), path, STR_LIT("-"), m->pkg->name); + } else if (USE_SEPARATE_MODULES) { + path = concatenate_strings(permanent_allocator(), path, STR_LIT("-builtin")); + } + path = concatenate_strings(permanent_allocator(), path, STR_LIT(".ll")); + + return path; +} +gb_internal String lb_filepath_obj_for_module(lbModule *m) { + String path = concatenate3_strings(permanent_allocator(), + build_context.build_paths[BuildPath_Output].basename, + STR_LIT("/"), + build_context.build_paths[BuildPath_Output].name + ); + + if (m->file) { + char buf[32] = {}; + isize n = gb_snprintf(buf, gb_size_of(buf), "-%u", m->file->id); + String suffix = make_string((u8 *)buf, n-1); + path = concatenate_strings(permanent_allocator(), path, suffix); + } else if (m->pkg) { + path = concatenate3_strings(permanent_allocator(), path, STR_LIT("-"), m->pkg->name); + } + + String ext = {}; + + if (build_context.build_mode == BuildMode_Assembly) { + ext = STR_LIT(".S"); + } else { + if (is_arch_wasm()) { + ext = STR_LIT(".wasm.o"); + } else { + switch (build_context.metrics.os) { + case TargetOs_windows: + ext = STR_LIT(".obj"); + break; + default: + case TargetOs_darwin: + case TargetOs_linux: + case TargetOs_essence: + ext = STR_LIT(".o"); + break; + + case TargetOs_freestanding: + switch (build_context.metrics.abi) { + default: + case TargetABI_Default: + case TargetABI_SysV: + ext = STR_LIT(".o"); + break; + case TargetABI_Win64: + ext = STR_LIT(".obj"); + break; + } + break; + } + } + } + + return concatenate_strings(permanent_allocator(), path, ext); +} + +gb_internal WORKER_TASK_PROC(lb_llvm_module_verification_worker_proc) { + char *llvm_error = nullptr; + defer (LLVMDisposeMessage(llvm_error)); + lbModule *m = cast(lbModule *)data; + if (LLVMVerifyModule(m->mod, LLVMReturnStatusAction, &llvm_error)) { + gb_printf_err("LLVM Error:\n%s\n", llvm_error); + if (build_context.keep_temp_files) { + TIME_SECTION("LLVM Print Module to File"); + String filepath_ll = lb_filepath_ll_for_module(m); + if (LLVMPrintModuleToFile(m->mod, cast(char const *)filepath_ll.text, &llvm_error)) { + gb_printf_err("LLVM Error: %s\n", llvm_error); + gb_exit(1); + return false; + } + } + gb_exit(1); + return 1; + } + return 0; +} + + +gb_internal bool lb_llvm_module_verification(lbGenerator *gen, bool do_threading) { + for (auto const &entry : gen->modules) { + lbModule *m = entry.value; + if (do_threading) { + thread_pool_add_task(lb_llvm_module_verification_worker_proc, m); + } else { + if (lb_llvm_module_verification_worker_proc(m)) { + return false; + } + } + } + thread_pool_wait(); + + return true; +} + +gb_internal void lb_add_foreign_library_paths(lbGenerator *gen) { + for (auto const &entry : gen->modules) { + lbModule *m = entry.value; + for (Entity *e : m->info->required_foreign_imports_through_force) { + lb_add_foreign_library_path(m, e); + } + + if (lb_is_module_empty(m)) { + continue; + } + } +} + +gb_internal bool lb_llvm_object_generation(lbGenerator *gen, bool do_threading) { + LLVMCodeGenFileType code_gen_file_type = LLVMObjectFile; + if (build_context.build_mode == BuildMode_Assembly) { + code_gen_file_type = LLVMAssemblyFile; + } + + char *llvm_error = nullptr; + defer (LLVMDisposeMessage(llvm_error)); + + if (do_threading) { + for (auto const &entry : gen->modules) { + lbModule *m = entry.value; + if (lb_is_module_empty(m)) { + continue; + } + + String filepath_ll = lb_filepath_ll_for_module(m); + String filepath_obj = lb_filepath_obj_for_module(m); + // gb_printf_err("%.*s\n", LIT(filepath_obj)); + array_add(&gen->output_object_paths, filepath_obj); + array_add(&gen->output_temp_paths, filepath_ll); + + auto *wd = gb_alloc_item(permanent_allocator(), lbLLVMEmitWorker); + wd->target_machine = m->target_machine; + wd->code_gen_file_type = code_gen_file_type; + wd->filepath_obj = filepath_obj; + wd->m = m; + thread_pool_add_task(lb_llvm_emit_worker_proc, wd); + } + + thread_pool_wait(&global_thread_pool); + } else { + for (auto const &entry : gen->modules) { + lbModule *m = entry.value; + if (lb_is_module_empty(m)) { + continue; + } + + String filepath_obj = lb_filepath_obj_for_module(m); + array_add(&gen->output_object_paths, filepath_obj); + + String short_name = remove_directory_from_path(filepath_obj); + gbString section_name = gb_string_make(permanent_allocator(), "LLVM Generate Object: "); + section_name = gb_string_append_length(section_name, short_name.text, short_name.len); + + TIME_SECTION_WITH_LEN(section_name, gb_string_length(section_name)); + + if (LLVMTargetMachineEmitToFile(m->target_machine, m->mod, cast(char *)filepath_obj.text, code_gen_file_type, &llvm_error)) { + gb_printf_err("LLVM Error: %s\n", llvm_error); + gb_exit(1); + return false; + } + debugf("Generated File: %.*s\n", LIT(filepath_obj)); + } + } + return true; +} + + + +gb_internal lbProcedure *lb_create_main_procedure(lbModule *m, lbProcedure *startup_runtime, lbProcedure *cleanup_runtime) { LLVMPassManagerRef default_function_pass_manager = LLVMCreateFunctionPassManagerForModule(m->mod); lb_populate_function_pass_manager(m, default_function_pass_manager, false, build_context.optimization_level); LLVMFinalizeFunctionPassManager(default_function_pass_manager); @@ -1193,7 +1722,7 @@ lbProcedure *lb_create_main_procedure(lbModule *m, lbProcedure *startup_runtime) Type *results = alloc_type_tuple(); Type *t_ptr_cstring = alloc_type_pointer(t_cstring); - + bool call_cleanup = true; bool has_args = false; @@ -1241,7 +1770,7 @@ lbProcedure *lb_create_main_procedure(lbModule *m, lbProcedure *startup_runtime) lbAddr args = lb_addr(lb_find_runtime_value(p->module, str_lit("args__"))); lb_fill_slice(p, args, argv, argc); } - + lbValue startup_runtime_value = {startup_runtime->value, startup_runtime->type}; lb_emit_call(p, startup_runtime_value, {}, ProcInlining_none); @@ -1255,8 +1784,8 @@ lbProcedure *lb_create_main_procedure(lbModule *m, lbProcedure *startup_runtime) LLVMValueRef indices[2] = {}; indices[0] = LLVMConstInt(lb_type(m, t_i32), 0, false); - for_array(i, m->info->testing_procedures) { - Entity *testing_proc = m->info->testing_procedures[i]; + isize testing_proc_index = 0; + for (Entity *testing_proc : m->info->testing_procedures) { String name = testing_proc->token.string; String pkg_name = {}; @@ -1267,7 +1796,7 @@ lbProcedure *lb_create_main_procedure(lbModule *m, lbProcedure *startup_runtime) lbValue v_name = lb_find_or_add_entity_string(m, name); lbValue v_proc = lb_find_procedure_value_from_entity(m, testing_proc); - indices[1] = LLVMConstInt(lb_type(m, t_int), i, false); + indices[1] = LLVMConstInt(lb_type(m, t_int), testing_proc_index++, false); LLVMValueRef vals[3] = {}; vals[0] = v_pkg.value; @@ -1291,7 +1820,8 @@ lbProcedure *lb_create_main_procedure(lbModule *m, lbProcedure *startup_runtime) lbValue runner = lb_find_package_value(m, str_lit("testing"), str_lit("runner")); - auto args = array_make(heap_allocator(), 1); + TEMPORARY_ALLOCATOR_GUARD(); + auto args = array_make(temporary_allocator(), 1); args[0] = lb_addr_load(p, all_tests_slice); lb_emit_call(p, runner, args); } else { @@ -1301,12 +1831,12 @@ lbProcedure *lb_create_main_procedure(lbModule *m, lbProcedure *startup_runtime) } } - + if (call_cleanup) { - lbValue cleanup_runtime_value = lb_find_runtime_value(m, str_lit("_cleanup_runtime")); + lbValue cleanup_runtime_value = {cleanup_runtime->value, cleanup_runtime->type}; lb_emit_call(p, cleanup_runtime_value, {}, ProcInlining_none); } - + if (is_dll_main) { LLVMBuildRet(p->builder, LLVMConstInt(lb_type(m, t_i32), 1, false)); @@ -1315,13 +1845,13 @@ lbProcedure *lb_create_main_procedure(lbModule *m, lbProcedure *startup_runtime) } lb_end_procedure_body(p); - + LLVMSetLinkage(p->value, LLVMExternalLinkage); if (is_arch_wasm()) { lb_set_wasm_export_attributes(p->value, p->name); } - + if (!m->debug_builder && LLVMVerifyFunction(p->value, LLVMReturnStatusAction)) { gb_printf_err("LLVM CODE GEN FAILED FOR PROCEDURE: %s\n", "main"); @@ -1330,217 +1860,11 @@ lbProcedure *lb_create_main_procedure(lbModule *m, lbProcedure *startup_runtime) LLVMVerifyFunction(p->value, LLVMAbortProcessAction); } - lb_run_function_pass_manager(default_function_pass_manager, p); + lb_run_function_pass_manager(default_function_pass_manager, p, lbFunctionPassManager_default); return p; } -String lb_filepath_ll_for_module(lbModule *m) { - String path = concatenate3_strings(permanent_allocator(), - build_context.build_paths[BuildPath_Output].basename, - STR_LIT("/"), - build_context.build_paths[BuildPath_Output].name - ); - - if (m->pkg) { - path = concatenate3_strings(permanent_allocator(), path, STR_LIT("-"), m->pkg->name); - } else if (USE_SEPARATE_MODULES) { - path = concatenate_strings(permanent_allocator(), path, STR_LIT("-builtin")); - } - path = concatenate_strings(permanent_allocator(), path, STR_LIT(".ll")); - - return path; -} -String lb_filepath_obj_for_module(lbModule *m) { - String path = concatenate3_strings(permanent_allocator(), - build_context.build_paths[BuildPath_Output].basename, - STR_LIT("/"), - build_context.build_paths[BuildPath_Output].name - ); - - if (m->pkg) { - path = concatenate3_strings(permanent_allocator(), path, STR_LIT("-"), m->pkg->name); - } - - String ext = {}; - - if (build_context.build_mode == BuildMode_Assembly) { - ext = STR_LIT(".S"); - } else { - if (is_arch_wasm()) { - ext = STR_LIT(".wasm.o"); - } else { - switch (build_context.metrics.os) { - case TargetOs_windows: - ext = STR_LIT(".obj"); - break; - default: - case TargetOs_darwin: - case TargetOs_linux: - case TargetOs_essence: - ext = STR_LIT(".o"); - break; - - case TargetOs_freestanding: - switch (build_context.metrics.abi) { - default: - case TargetABI_Default: - case TargetABI_SysV: - ext = STR_LIT(".o"); - break; - case TargetABI_Win64: - ext = STR_LIT(".obj"); - break; - } - break; - } - } - } - - return concatenate_strings(permanent_allocator(), path, ext); -} - - -bool lb_is_module_empty(lbModule *m) { - if (LLVMGetFirstFunction(m->mod) == nullptr && - LLVMGetFirstGlobal(m->mod) == nullptr) { - return true; - } - for (auto fn = LLVMGetFirstFunction(m->mod); fn != nullptr; fn = LLVMGetNextFunction(fn)) { - if (LLVMGetFirstBasicBlock(fn) != nullptr) { - return false; - } - } - - for (auto g = LLVMGetFirstGlobal(m->mod); g != nullptr; g = LLVMGetNextGlobal(g)) { - if (LLVMGetLinkage(g) == LLVMExternalLinkage) { - continue; - } - if (!LLVMIsExternallyInitialized(g)) { - return false; - } - } - return true; -} - -struct lbLLVMEmitWorker { - LLVMTargetMachineRef target_machine; - LLVMCodeGenFileType code_gen_file_type; - String filepath_obj; - lbModule *m; -}; - -WORKER_TASK_PROC(lb_llvm_emit_worker_proc) { - GB_ASSERT(MULTITHREAD_OBJECT_GENERATION); - - char *llvm_error = nullptr; - - auto wd = cast(lbLLVMEmitWorker *)data; - - if (LLVMTargetMachineEmitToFile(wd->target_machine, wd->m->mod, cast(char *)wd->filepath_obj.text, wd->code_gen_file_type, &llvm_error)) { - gb_printf_err("LLVM Error: %s\n", llvm_error); - gb_exit(1); - } - - return 0; -} - -WORKER_TASK_PROC(lb_llvm_function_pass_worker_proc) { - GB_ASSERT(MULTITHREAD_OBJECT_GENERATION); - - auto m = cast(lbModule *)data; - - LLVMPassManagerRef default_function_pass_manager = LLVMCreateFunctionPassManagerForModule(m->mod); - LLVMPassManagerRef function_pass_manager_minimal = LLVMCreateFunctionPassManagerForModule(m->mod); - LLVMPassManagerRef function_pass_manager_size = LLVMCreateFunctionPassManagerForModule(m->mod); - LLVMPassManagerRef function_pass_manager_speed = LLVMCreateFunctionPassManagerForModule(m->mod); - - LLVMInitializeFunctionPassManager(default_function_pass_manager); - LLVMInitializeFunctionPassManager(function_pass_manager_minimal); - LLVMInitializeFunctionPassManager(function_pass_manager_size); - LLVMInitializeFunctionPassManager(function_pass_manager_speed); - - lb_populate_function_pass_manager(m, default_function_pass_manager, false, build_context.optimization_level); - lb_populate_function_pass_manager_specific(m, function_pass_manager_minimal, 0); - lb_populate_function_pass_manager_specific(m, function_pass_manager_size, 1); - lb_populate_function_pass_manager_specific(m, function_pass_manager_speed, 2); - - LLVMFinalizeFunctionPassManager(default_function_pass_manager); - LLVMFinalizeFunctionPassManager(function_pass_manager_minimal); - LLVMFinalizeFunctionPassManager(function_pass_manager_size); - LLVMFinalizeFunctionPassManager(function_pass_manager_speed); - - - LLVMPassManagerRef default_function_pass_manager_without_memcpy = LLVMCreateFunctionPassManagerForModule(m->mod); - LLVMInitializeFunctionPassManager(default_function_pass_manager_without_memcpy); - lb_populate_function_pass_manager(m, default_function_pass_manager_without_memcpy, true, build_context.optimization_level); - LLVMFinalizeFunctionPassManager(default_function_pass_manager_without_memcpy); - - - for_array(i, m->procedures_to_generate) { - lbProcedure *p = m->procedures_to_generate[i]; - if (p->body != nullptr) { // Build Procedure - if (p->flags & lbProcedureFlag_WithoutMemcpyPass) { - lb_run_function_pass_manager(default_function_pass_manager_without_memcpy, p); - } else { - if (p->entity && p->entity->kind == Entity_Procedure) { - switch (p->entity->Procedure.optimization_mode) { - case ProcedureOptimizationMode_None: - case ProcedureOptimizationMode_Minimal: - lb_run_function_pass_manager(function_pass_manager_minimal, p); - break; - case ProcedureOptimizationMode_Size: - lb_run_function_pass_manager(function_pass_manager_size, p); - break; - case ProcedureOptimizationMode_Speed: - lb_run_function_pass_manager(function_pass_manager_speed, p); - break; - default: - lb_run_function_pass_manager(default_function_pass_manager, p); - break; - } - } else { - lb_run_function_pass_manager(default_function_pass_manager, p); - } - } - } - } - - for_array(i, m->equal_procs.entries) { - lbProcedure *p = m->equal_procs.entries[i].value; - lb_run_function_pass_manager(default_function_pass_manager, p); - } - for_array(i, m->hasher_procs.entries) { - lbProcedure *p = m->hasher_procs.entries[i].value; - lb_run_function_pass_manager(default_function_pass_manager, p); - } - for_array(i, m->map_get_procs.entries) { - lbProcedure *p = m->map_get_procs.entries[i].value; - lb_run_function_pass_manager(default_function_pass_manager, p); - } - for_array(i, m->map_set_procs.entries) { - lbProcedure *p = m->map_set_procs.entries[i].value; - lb_run_function_pass_manager(default_function_pass_manager, p); - } - - return 0; -} - - -struct lbLLVMModulePassWorkerData { - lbModule *m; - LLVMTargetMachineRef target_machine; -}; - -WORKER_TASK_PROC(lb_llvm_module_pass_worker_proc) { - auto wd = cast(lbLLVMModulePassWorkerData *)data; - LLVMPassManagerRef module_pass_manager = LLVMCreatePassManager(); - lb_populate_module_pass_manager(wd->target_machine, module_pass_manager, build_context.optimization_level); - LLVMRunPassManager(module_pass_manager, wd->m->mod); - return 0; -} - - -void lb_generate_procedure(lbModule *m, lbProcedure *p) { +gb_internal void lb_generate_procedure(lbModule *m, lbProcedure *p) { if (p->is_done) { return; } @@ -1580,13 +1904,13 @@ void lb_generate_procedure(lbModule *m, lbProcedure *p) { } -void lb_generate_code(lbGenerator *gen) { +gb_internal bool lb_generate_code(lbGenerator *gen) { TIME_SECTION("LLVM Initializtion"); isize thread_count = gb_max(build_context.thread_count, 1); isize worker_count = thread_count-1; - LLVMBool do_threading = (LLVMIsMultithreaded() && USE_SEPARATE_MODULES && MULTITHREAD_OBJECT_GENERATION && worker_count > 0); + bool do_threading = !!(LLVMIsMultithreaded() && USE_SEPARATE_MODULES && MULTITHREAD_OBJECT_GENERATION && worker_count > 0); lbModule *default_module = &gen->default_module; CheckerInfo *info = gen->info; @@ -1612,7 +1936,7 @@ void lb_generate_code(lbGenerator *gen) { LLVMInitializeAArch64Disassembler(); break; case TargetArch_wasm32: - case TargetArch_wasm64: + case TargetArch_wasm64p32: LLVMInitializeWebAssemblyTargetInfo(); LLVMInitializeWebAssemblyTarget(); LLVMInitializeWebAssemblyTargetMC(); @@ -1636,8 +1960,8 @@ void lb_generate_code(lbGenerator *gen) { } char const *target_triple = alloc_cstring(permanent_allocator(), build_context.metrics.target_triplet); - for_array(i, gen->modules.entries) { - LLVMSetTarget(gen->modules.entries[i].value->mod, target_triple); + for (auto const &entry : gen->modules) { + LLVMSetTarget(entry.value->mod, target_triple); } LLVMTargetRef target = {}; @@ -1701,7 +2025,7 @@ void lb_generate_code(lbGenerator *gen) { // NOTE(bill): Target Machine Creation // NOTE(bill, 2021-05-04): Target machines must be unique to each module because they are not thread safe - auto target_machines = array_make(permanent_allocator(), gen->modules.entries.count); + auto target_machines = array_make(permanent_allocator(), 0, gen->modules.count); // NOTE(dweiler): Dynamic libraries require position-independent code. LLVMRelocMode reloc_mode = LLVMRelocDefault; @@ -1727,31 +2051,33 @@ void lb_generate_code(lbGenerator *gen) { break; } - for_array(i, gen->modules.entries) { - target_machines[i] = LLVMCreateTargetMachine( + for (auto const &entry : gen->modules) { + LLVMTargetMachineRef target_machine = LLVMCreateTargetMachine( target, target_triple, llvm_cpu, llvm_features, code_gen_level, reloc_mode, code_mode); - LLVMSetModuleDataLayout(gen->modules.entries[i].value->mod, LLVMCreateTargetDataLayout(target_machines[i])); + lbModule *m = entry.value; + m->target_machine = target_machine; + LLVMSetModuleDataLayout(m->mod, LLVMCreateTargetDataLayout(target_machine)); + array_add(&target_machines, target_machine); } - for_array(i, gen->modules.entries) { - lbModule *m = gen->modules.entries[i].value; + for (auto const &entry : gen->modules) { + lbModule *m = entry.value; if (m->debug_builder) { // Debug Info - for_array(i, info->files.entries) { - AstFile *f = info->files.entries[i].value; - String fullpath = f->fullpath; - String filename = remove_directory_from_path(fullpath); - String directory = directory_from_path(fullpath); + for (auto const &file_entry : info->files) { + AstFile *f = file_entry.value; LLVMMetadataRef res = LLVMDIBuilderCreateFile(m->debug_builder, - cast(char const *)filename.text, filename.len, - cast(char const *)directory.text, directory.len); + cast(char const *)f->filename.text, f->filename.len, + cast(char const *)f->directory.text, f->directory.len); lb_set_llvm_metadata(m, f, res); } - gbString producer = gb_string_make(heap_allocator(), "odin"); + TEMPORARY_ALLOCATOR_GUARD(); + + gbString producer = gb_string_make(temporary_allocator(), "odin"); // producer = gb_string_append_fmt(producer, " version %.*s", LIT(ODIN_VERSION)); // #ifdef NIGHTLY // producer = gb_string_appendc(producer, "-nightly"); @@ -1760,7 +2086,7 @@ void lb_generate_code(lbGenerator *gen) { // producer = gb_string_append_fmt(producer, "-%s", GIT_SHA); // #endif - gbString split_name = gb_string_make(heap_allocator(), ""); + gbString split_name = gb_string_make(temporary_allocator(), ""); LLVMBool is_optimized = build_context.optimization_level > 0; AstFile *init_file = m->info->init_package->files[0]; @@ -1793,18 +2119,16 @@ void lb_generate_code(lbGenerator *gen) { TIME_SECTION("LLVM Global Variables"); - if (!build_context.disallow_rtti) { + if (!build_context.no_rtti) { lbModule *m = default_module; { // Add type info data - isize max_type_info_count = info->minimum_dependency_type_info_set.entries.count+1; + isize max_type_info_count = info->minimum_dependency_type_info_set.count+1; // gb_printf_err("max_type_info_count: %td\n", max_type_info_count); Type *t = alloc_type_array(t_type_info, max_type_info_count); LLVMValueRef g = LLVMAddGlobal(m->mod, lb_type(m, t), LB_TYPE_INFO_DATA_NAME); LLVMSetInitializer(g, LLVMConstNull(lb_type(m, t))); - if (!USE_SEPARATE_MODULES) { - LLVMSetLinkage(g, LLVMInternalLinkage); - } + LLVMSetLinkage(g, USE_SEPARATE_MODULES ? LLVMExternalLinkage : LLVMInternalLinkage); lbValue value = {}; value.value = g; @@ -1817,9 +2141,7 @@ void lb_generate_code(lbGenerator *gen) { // NOTE(bill): Removes need for heap allocation by making it global memory isize count = 0; - for_array(entry_index, m->info->type_info_types) { - Type *t = m->info->type_info_types[entry_index]; - + for (Type *t : m->info->type_info_types) { isize index = lb_type_info_index(m->info, t, false); if (index < 0) { continue; @@ -1890,8 +2212,7 @@ void lb_generate_code(lbGenerator *gen) { isize global_variable_max_count = 0; bool already_has_entry_point = false; - for_array(i, info->entities) { - Entity *e = info->entities[i]; + for (Entity *e : info->entities) { String name = e->token.string; if (e->kind == Entity_Variable) { @@ -1920,9 +2241,7 @@ void lb_generate_code(lbGenerator *gen) { auto global_variables = array_make(permanent_allocator(), 0, global_variable_max_count); - for_array(i, info->variable_init_order) { - DeclInfo *d = info->variable_init_order[i]; - + for (DeclInfo *d : info->variable_init_order) { Entity *e = d->entity; if ((e->scope->flags & ScopeFlag_File) == 0) { @@ -1932,6 +2251,7 @@ void lb_generate_code(lbGenerator *gen) { if (!ptr_set_exists(min_dep_set, e)) { continue; } + DeclInfo *decl = decl_info_of_entity(e); if (decl == nullptr) { continue; @@ -1980,11 +2300,7 @@ void lb_generate_code(lbGenerator *gen) { LLVMSetLinkage(g.value, LLVMDLLExportLinkage); LLVMSetDLLStorageClass(g.value, LLVMDLLExportStorageClass); } else if (!is_foreign) { - if (USE_SEPARATE_MODULES) { - LLVMSetLinkage(g.value, LLVMExternalLinkage); - } else { - LLVMSetLinkage(g.value, LLVMInternalLinkage); - } + LLVMSetLinkage(g.value, USE_SEPARATE_MODULES ? LLVMExternalLinkage : LLVMInternalLinkage); } lb_set_linkage_from_entity_flags(m, g.value, e->flags); @@ -2008,8 +2324,7 @@ void lb_generate_code(lbGenerator *gen) { } } } - if (!var.is_initialized && - (is_type_untyped_nil(tav.type) || is_type_untyped_undef(tav.type))) { + if (!var.is_initialized && is_type_untyped_nil(tav.type)) { var.is_initialized = true; } } @@ -2051,281 +2366,119 @@ void lb_generate_code(lbGenerator *gen) { } TIME_SECTION("LLVM Runtime Type Information Creation"); - lbProcedure *startup_type_info = lb_create_startup_type_info(default_module); + gen->startup_type_info = lb_create_startup_type_info(default_module); + gen->objc_names = lb_create_objc_names(default_module); - lbProcedure *objc_names = lb_create_objc_names(default_module); + TIME_SECTION("LLVM Runtime Startup Creation (Global Variables & @(init))"); + gen->startup_runtime = lb_create_startup_runtime(default_module, gen->startup_type_info, gen->objc_names, global_variables); + + TIME_SECTION("LLVM Runtime Cleanup Creation & @(fini)"); + gen->cleanup_runtime = lb_create_cleanup_runtime(default_module); - TIME_SECTION("LLVM Runtime Startup Creation (Global Variables)"); - lbProcedure *startup_runtime = lb_create_startup_runtime(default_module, startup_type_info, objc_names, global_variables); - gb_unused(startup_runtime); if (build_context.ODIN_DEBUG) { - for_array(i, builtin_pkg->scope->elements.entries) { - Entity *e = builtin_pkg->scope->elements.entries[i].value; + for (auto const &entry : builtin_pkg->scope->elements) { + Entity *e = entry.value; add_debug_info_for_global_constant_from_entity(gen, e); } } - TIME_SECTION("LLVM Global Procedures and Types"); - for_array(i, info->entities) { - Entity *e = info->entities[i]; - String name = e->token.string; - Scope * scope = e->scope; - - if ((scope->flags & ScopeFlag_File) == 0) { - continue; - } - - Scope *package_scope = scope->parent; - GB_ASSERT(package_scope->flags & ScopeFlag_Pkg); - - switch (e->kind) { - case Entity_Variable: - // NOTE(bill): Handled above as it requires a specific load order - continue; - case Entity_ProcGroup: - continue; - - case Entity_TypeName: - case Entity_Procedure: - break; - case Entity_Constant: - if (build_context.ODIN_DEBUG) { - add_debug_info_for_global_constant_from_entity(gen, e); - } - break; - } - - bool polymorphic_struct = false; - if (e->type != nullptr && e->kind == Entity_TypeName) { - Type *bt = base_type(e->type); - if (bt->kind == Type_Struct) { - polymorphic_struct = is_type_polymorphic(bt); - } - } - - if (!polymorphic_struct && !ptr_set_exists(min_dep_set, e)) { - // NOTE(bill): Nothing depends upon it so doesn't need to be built - continue; - } - - lbModule *m = &gen->default_module; - if (USE_SEPARATE_MODULES) { - m = lb_pkg_module(gen, e->pkg); - } - - String mangled_name = lb_get_entity_name(m, e); - - switch (e->kind) { - case Entity_TypeName: - lb_type(m, e->type); - break; - case Entity_Procedure: - { - lbProcedure *p = lb_create_procedure(m, e); - array_add(&m->procedures_to_generate, p); - } - break; - } + if (gen->modules.count <= 1) { + do_threading = false; } + TIME_SECTION("LLVM Global Procedures and Types"); + lb_create_global_procedures_and_types(gen, info, do_threading); + TIME_SECTION("LLVM Procedure Generation"); - for_array(j, gen->modules.entries) { - lbModule *m = gen->modules.entries[j].value; - for_array(i, m->procedures_to_generate) { - lbProcedure *p = m->procedures_to_generate[i]; - lb_generate_procedure(m, p); - } - } + lb_generate_procedures(gen, do_threading); if (build_context.command_kind == Command_test && !already_has_entry_point) { TIME_SECTION("LLVM main"); - lb_create_main_procedure(default_module, startup_runtime); + lb_create_main_procedure(default_module, gen->startup_runtime, gen->cleanup_runtime); } - for_array(j, gen->modules.entries) { - lbModule *m = gen->modules.entries[j].value; - for_array(i, m->missing_procedures_to_check) { - lbProcedure *p = m->missing_procedures_to_check[i]; - debugf("Generate missing procedure: %.*s\n", LIT(p->name)); - lb_generate_procedure(m, p); - } - } + TIME_SECTION("LLVM Procedure Generation (missing)"); + lb_generate_missing_procedures(gen, do_threading); - lb_finalize_objc_names(objc_names); + if (gen->objc_names) { + TIME_SECTION("Finalize objc names"); + lb_finalize_objc_names(gen->objc_names); + } if (build_context.ODIN_DEBUG) { - TIME_SECTION("LLVM Debug Info for global constant value declarations"); - { - // lbModule *m = default_module; - - - } - // if (gen->modules.entries.count == 1) { - // } else { - // for_array(j, gen->modules.entries) { - // lbModule *m = gen->modules.entries[j].value; - // if (m->debug_builder != nullptr) { - // } - // } - // } - TIME_SECTION("LLVM Debug Info Complete Types and Finalize"); - for_array(j, gen->modules.entries) { - lbModule *m = gen->modules.entries[j].value; - if (m->debug_builder != nullptr) { - lb_debug_complete_types(m); - LLVMDIBuilderFinalize(m->debug_builder); - } - } + lb_debug_info_complete_types_and_finalize(gen); } + if (do_threading) { + isize non_empty_module_count = 0; + for (auto const &entry : gen->modules) { + lbModule *m = entry.value; + if (!lb_is_module_empty(m)) { + non_empty_module_count += 1; + } + } + if (non_empty_module_count <= 1) { + do_threading = false; + } + } TIME_SECTION("LLVM Function Pass"); - for_array(i, gen->modules.entries) { - lbModule *m = gen->modules.entries[i].value; - - lb_llvm_function_pass_worker_proc(m); - } + lb_llvm_function_passes(gen, do_threading && !build_context.ODIN_DEBUG); TIME_SECTION("LLVM Module Pass"); + lb_llvm_module_passes(gen, do_threading); - for_array(i, gen->modules.entries) { - lbModule *m = gen->modules.entries[i].value; - - lb_run_remove_unused_function_pass(m); - lb_run_remove_unused_globals_pass(m); - auto wd = gb_alloc_item(permanent_allocator(), lbLLVMModulePassWorkerData); - wd->m = m; - wd->target_machine = target_machines[i]; + TIME_SECTION("LLVM Module Verification"); - lb_llvm_module_pass_worker_proc(wd); + + if (!lb_llvm_module_verification(gen, do_threading)) { + return false; } - llvm_error = nullptr; defer (LLVMDisposeMessage(llvm_error)); - LLVMCodeGenFileType code_gen_file_type = LLVMObjectFile; - if (build_context.build_mode == BuildMode_Assembly) { - code_gen_file_type = LLVMAssemblyFile; - } - - - for_array(j, gen->modules.entries) { - lbModule *m = gen->modules.entries[j].value; - if (LLVMVerifyModule(m->mod, LLVMReturnStatusAction, &llvm_error)) { - gb_printf_err("LLVM Error:\n%s\n", llvm_error); - if (build_context.keep_temp_files) { - TIME_SECTION("LLVM Print Module to File"); - String filepath_ll = lb_filepath_ll_for_module(m); - if (LLVMPrintModuleToFile(m->mod, cast(char const *)filepath_ll.text, &llvm_error)) { - gb_printf_err("LLVM Error: %s\n", llvm_error); - gb_exit(1); - return; - } - } - gb_exit(1); - return; - } - } - llvm_error = nullptr; if (build_context.keep_temp_files || build_context.build_mode == BuildMode_LLVM_IR) { TIME_SECTION("LLVM Print Module to File"); - for_array(j, gen->modules.entries) { - lbModule *m = gen->modules.entries[j].value; - + for (auto const &entry : gen->modules) { + lbModule *m = entry.value; if (lb_is_module_empty(m)) { continue; } - String filepath_ll = lb_filepath_ll_for_module(m); if (LLVMPrintModuleToFile(m->mod, cast(char const *)filepath_ll.text, &llvm_error)) { gb_printf_err("LLVM Error: %s\n", llvm_error); gb_exit(1); - return; + return false; } array_add(&gen->output_temp_paths, filepath_ll); } if (build_context.build_mode == BuildMode_LLVM_IR) { - gb_exit(0); - return; + return true; } } TIME_SECTION("LLVM Add Foreign Library Paths"); - - for_array(j, gen->modules.entries) { - lbModule *m = gen->modules.entries[j].value; - for_array(i, m->info->required_foreign_imports_through_force) { - Entity *e = m->info->required_foreign_imports_through_force[i]; - lb_add_foreign_library_path(m, e); - } - - if (lb_is_module_empty(m)) { - continue; - } - } + lb_add_foreign_library_paths(gen); TIME_SECTION("LLVM Object Generation"); - isize non_empty_module_count = 0; - for_array(j, gen->modules.entries) { - lbModule *m = gen->modules.entries[j].value; - if (!lb_is_module_empty(m)) { - non_empty_module_count += 1; - } + if (build_context.ignore_llvm_build) { + gb_printf_err("LLVM object generation has been ignored!\n"); + return false; } - - if (do_threading && non_empty_module_count > 1) { - for_array(j, gen->modules.entries) { - lbModule *m = gen->modules.entries[j].value; - if (lb_is_module_empty(m)) { - continue; - } - - String filepath_ll = lb_filepath_ll_for_module(m); - String filepath_obj = lb_filepath_obj_for_module(m); - array_add(&gen->output_object_paths, filepath_obj); - array_add(&gen->output_temp_paths, filepath_ll); - - auto *wd = gb_alloc_item(permanent_allocator(), lbLLVMEmitWorker); - wd->target_machine = target_machines[j]; - wd->code_gen_file_type = code_gen_file_type; - wd->filepath_obj = filepath_obj; - wd->m = m; - global_thread_pool_add_task(lb_llvm_emit_worker_proc, wd); - } - - thread_pool_wait(&global_thread_pool); - } else { - for_array(j, gen->modules.entries) { - lbModule *m = gen->modules.entries[j].value; - if (lb_is_module_empty(m)) { - continue; - } - - String filepath_obj = lb_filepath_obj_for_module(m); - array_add(&gen->output_object_paths, filepath_obj); - - String short_name = remove_directory_from_path(filepath_obj); - gbString section_name = gb_string_make(heap_allocator(), "LLVM Generate Object: "); - section_name = gb_string_append_length(section_name, short_name.text, short_name.len); - - TIME_SECTION_WITH_LEN(section_name, gb_string_length(section_name)); - - if (LLVMTargetMachineEmitToFile(target_machines[j], m->mod, cast(char *)filepath_obj.text, code_gen_file_type, &llvm_error)) { - gb_printf_err("LLVM Error: %s\n", llvm_error); - gb_exit(1); - return; - } - } + if (!lb_llvm_object_generation(gen, do_threading)) { + return false; } gb_sort_array(gen->foreign_libraries.data, gen->foreign_libraries.count, foreign_library_cmp); + + return true; } diff --git a/src/llvm_backend.hpp b/src/llvm_backend.hpp index 911c915a8..3aa13b488 100644 --- a/src/llvm_backend.hpp +++ b/src/llvm_backend.hpp @@ -117,20 +117,37 @@ struct lbIncompleteDebugType { typedef Slice lbStructFieldRemapping; +enum lbFunctionPassManagerKind { + lbFunctionPassManager_default, + lbFunctionPassManager_default_without_memcpy, + lbFunctionPassManager_none, + lbFunctionPassManager_minimal, + lbFunctionPassManager_size, + lbFunctionPassManager_speed, + + lbFunctionPassManager_COUNT +}; + struct lbModule { LLVMModuleRef mod; LLVMContextRef ctx; struct lbGenerator *gen; + LLVMTargetMachineRef target_machine; CheckerInfo *info; - AstPackage *pkg; // associated + AstPackage *pkg; // possibly associated + AstFile *file; // possibly associated - PtrMap types; - PtrMap func_raw_types; - PtrMap struct_field_remapping; // Key: LLVMTypeRef or Type * + PtrMap types; // mutex: types_mutex + PtrMap struct_field_remapping; // Key: LLVMTypeRef or Type *, mutex: types_mutex + PtrMap func_raw_types; // mutex: func_raw_types_mutex + RecursiveMutex types_mutex; + RecursiveMutex func_raw_types_mutex; i32 internal_type_level; + RwMutex values_mutex; + PtrMap values; PtrMap soa_values; StringMap members; @@ -147,14 +164,17 @@ struct lbModule { PtrMap map_get_procs; PtrMap map_set_procs; - u32 nested_type_name_guid; + std::atomic nested_type_name_guid; Array procedures_to_generate; + Array global_procedures_and_types_to_create; lbProcedure *curr_procedure; LLVMDIBuilderRef debug_builder; LLVMMetadataRef debug_compile_unit; + + RecursiveMutex debug_values_mutex; PtrMap debug_values; Array debug_incomplete_types; @@ -164,6 +184,10 @@ struct lbModule { PtrMap map_cell_info_map; // address of runtime.Map_Info PtrMap map_info_map; // address of runtime.Map_Cell_Info + + PtrMap exact_value_compound_literal_addr_map; // Key: Ast_CompoundLit + + LLVMPassManagerRef function_pass_managers[lbFunctionPassManager_COUNT]; }; struct lbGenerator { @@ -173,10 +197,11 @@ struct lbGenerator { Array output_temp_paths; String output_base; String output_name; - PtrMap modules; + PtrMap modules; // key is `AstPackage *` (`void *` is used for future use) PtrMap modules_through_ctx; lbModule default_module; + RecursiveMutex anonymous_proc_lits_mutex; PtrMap anonymous_proc_lits; BlockingMutex foreign_mutex; @@ -185,6 +210,11 @@ struct lbGenerator { std::atomic global_array_index; std::atomic global_generated_index; + + lbProcedure *startup_type_info; + lbProcedure *startup_runtime; + lbProcedure *cleanup_runtime; + lbProcedure *objc_names; }; @@ -300,6 +330,8 @@ struct lbProcedure { lbBlock * curr_block; lbTargetList * target_list; PtrMap direct_parameters; + bool in_multi_assignment; + Array raw_input_parameters; Ast *curr_stmt; @@ -321,199 +353,202 @@ struct lbProcedure { #define LLVMBuildPtrDiff2(Builder__, Ty__, LHS__, RHS__, Name__) LLVMBuildPtrDiff(Builder__, LHS__, RHS__, Name__) #endif -bool lb_init_generator(lbGenerator *gen, Checker *c); +gb_internal bool lb_init_generator(lbGenerator *gen, Checker *c); -String lb_mangle_name(lbModule *m, Entity *e); -String lb_get_entity_name(lbModule *m, Entity *e, String name = {}); +gb_internal String lb_mangle_name(lbModule *m, Entity *e); +gb_internal String lb_get_entity_name(lbModule *m, Entity *e, String name = {}); -LLVMAttributeRef lb_create_enum_attribute(LLVMContextRef ctx, char const *name, u64 value=0); -LLVMAttributeRef lb_create_enum_attribute_with_type(LLVMContextRef ctx, char const *name, LLVMTypeRef type); -void lb_add_proc_attribute_at_index(lbProcedure *p, isize index, char const *name, u64 value); -void lb_add_proc_attribute_at_index(lbProcedure *p, isize index, char const *name); -lbProcedure *lb_create_procedure(lbModule *module, Entity *entity, bool ignore_body=false); -void lb_end_procedure(lbProcedure *p); +gb_internal LLVMAttributeRef lb_create_enum_attribute(LLVMContextRef ctx, char const *name, u64 value=0); +gb_internal LLVMAttributeRef lb_create_enum_attribute_with_type(LLVMContextRef ctx, char const *name, LLVMTypeRef type); +gb_internal void lb_add_proc_attribute_at_index(lbProcedure *p, isize index, char const *name, u64 value); +gb_internal void lb_add_proc_attribute_at_index(lbProcedure *p, isize index, char const *name); +gb_internal lbProcedure *lb_create_procedure(lbModule *module, Entity *entity, bool ignore_body=false); +gb_internal void lb_end_procedure(lbProcedure *p); -LLVMTypeRef lb_type(lbModule *m, Type *type); -LLVMTypeRef llvm_get_element_type(LLVMTypeRef type); +gb_internal LLVMTypeRef lb_type(lbModule *m, Type *type); +gb_internal LLVMTypeRef llvm_get_element_type(LLVMTypeRef type); -lbBlock *lb_create_block(lbProcedure *p, char const *name, bool append=false); +gb_internal lbBlock *lb_create_block(lbProcedure *p, char const *name, bool append=false); -lbValue lb_const_nil(lbModule *m, Type *type); -lbValue lb_const_undef(lbModule *m, Type *type); -lbValue lb_const_value(lbModule *m, Type *type, ExactValue value, bool allow_local=true); -lbValue lb_const_bool(lbModule *m, Type *type, bool value); -lbValue lb_const_int(lbModule *m, Type *type, u64 value); +gb_internal lbValue lb_const_nil(lbModule *m, Type *type); +gb_internal lbValue lb_const_undef(lbModule *m, Type *type); +gb_internal lbValue lb_const_value(lbModule *m, Type *type, ExactValue value, bool allow_local=true); +gb_internal lbValue lb_const_bool(lbModule *m, Type *type, bool value); +gb_internal lbValue lb_const_int(lbModule *m, Type *type, u64 value); -lbAddr lb_addr(lbValue addr); -Type *lb_addr_type(lbAddr const &addr); -LLVMTypeRef llvm_addr_type(lbModule *module, lbValue addr_val); -void lb_addr_store(lbProcedure *p, lbAddr addr, lbValue value); -lbValue lb_addr_load(lbProcedure *p, lbAddr const &addr); -lbValue lb_emit_load(lbProcedure *p, lbValue v); -void lb_emit_store(lbProcedure *p, lbValue ptr, lbValue value); +gb_internal lbAddr lb_addr(lbValue addr); +gb_internal Type *lb_addr_type(lbAddr const &addr); +gb_internal LLVMTypeRef llvm_addr_type(lbModule *module, lbValue addr_val); +gb_internal void lb_addr_store(lbProcedure *p, lbAddr addr, lbValue value); +gb_internal lbValue lb_addr_load(lbProcedure *p, lbAddr const &addr); +gb_internal lbValue lb_emit_load(lbProcedure *p, lbValue v); +gb_internal void lb_emit_store(lbProcedure *p, lbValue ptr, lbValue value); -void lb_build_stmt(lbProcedure *p, Ast *stmt); -lbValue lb_build_expr(lbProcedure *p, Ast *expr); -lbAddr lb_build_addr(lbProcedure *p, Ast *expr); -void lb_build_stmt_list(lbProcedure *p, Array const &stmts); +gb_internal void lb_build_stmt(lbProcedure *p, Ast *stmt); +gb_internal lbValue lb_build_expr(lbProcedure *p, Ast *expr); +gb_internal lbAddr lb_build_addr(lbProcedure *p, Ast *expr); +gb_internal void lb_build_stmt_list(lbProcedure *p, Array const &stmts); -lbValue lb_emit_epi(lbProcedure *p, lbValue const &value, isize index); -lbValue lb_emit_epi(lbModule *m, lbValue const &value, isize index); -lbValue lb_emit_array_epi(lbModule *m, lbValue s, isize index); -lbValue lb_emit_struct_ep(lbProcedure *p, lbValue s, i32 index); -lbValue lb_emit_struct_ev(lbProcedure *p, lbValue s, i32 index); -lbValue lb_emit_tuple_ev(lbProcedure *p, lbValue value, i32 index); -lbValue lb_emit_array_epi(lbProcedure *p, lbValue value, isize index); -lbValue lb_emit_array_ep(lbProcedure *p, lbValue s, lbValue index); -lbValue lb_emit_deep_field_gep(lbProcedure *p, lbValue e, Selection sel); -lbValue lb_emit_deep_field_ev(lbProcedure *p, lbValue e, Selection sel); +gb_internal lbValue lb_emit_epi(lbProcedure *p, lbValue const &value, isize index); +gb_internal lbValue lb_emit_epi(lbModule *m, lbValue const &value, isize index); +gb_internal lbValue lb_emit_array_epi(lbModule *m, lbValue s, isize index); +gb_internal lbValue lb_emit_struct_ep(lbProcedure *p, lbValue s, i32 index); +gb_internal lbValue lb_emit_struct_ev(lbProcedure *p, lbValue s, i32 index); +gb_internal lbValue lb_emit_tuple_ev(lbProcedure *p, lbValue value, i32 index); +gb_internal lbValue lb_emit_array_epi(lbProcedure *p, lbValue value, isize index); +gb_internal lbValue lb_emit_array_ep(lbProcedure *p, lbValue s, lbValue index); +gb_internal lbValue lb_emit_deep_field_gep(lbProcedure *p, lbValue e, Selection sel); +gb_internal lbValue lb_emit_deep_field_ev(lbProcedure *p, lbValue e, Selection sel); -lbValue lb_emit_matrix_ep(lbProcedure *p, lbValue s, lbValue row, lbValue column); -lbValue lb_emit_matrix_epi(lbProcedure *p, lbValue s, isize row, isize column); -lbValue lb_emit_matrix_ev(lbProcedure *p, lbValue s, isize row, isize column); +gb_internal lbValue lb_emit_matrix_ep(lbProcedure *p, lbValue s, lbValue row, lbValue column); +gb_internal lbValue lb_emit_matrix_epi(lbProcedure *p, lbValue s, isize row, isize column); +gb_internal lbValue lb_emit_matrix_ev(lbProcedure *p, lbValue s, isize row, isize column); -lbValue lb_emit_arith(lbProcedure *p, TokenKind op, lbValue lhs, lbValue rhs, Type *type); -lbValue lb_emit_byte_swap(lbProcedure *p, lbValue value, Type *end_type); -void lb_emit_defer_stmts(lbProcedure *p, lbDeferExitKind kind, lbBlock *block); -lbValue lb_emit_transmute(lbProcedure *p, lbValue value, Type *t); -lbValue lb_emit_comp(lbProcedure *p, TokenKind op_kind, lbValue left, lbValue right); -lbValue lb_emit_call(lbProcedure *p, lbValue value, Array const &args, ProcInlining inlining = ProcInlining_none); -lbValue lb_emit_conv(lbProcedure *p, lbValue value, Type *t); -lbValue lb_emit_comp_against_nil(lbProcedure *p, TokenKind op_kind, lbValue x); +gb_internal lbValue lb_emit_arith(lbProcedure *p, TokenKind op, lbValue lhs, lbValue rhs, Type *type); +gb_internal lbValue lb_emit_byte_swap(lbProcedure *p, lbValue value, Type *end_type); +gb_internal void lb_emit_defer_stmts(lbProcedure *p, lbDeferExitKind kind, lbBlock *block); +gb_internal lbValue lb_emit_transmute(lbProcedure *p, lbValue value, Type *t); +gb_internal lbValue lb_emit_comp(lbProcedure *p, TokenKind op_kind, lbValue left, lbValue right); +gb_internal lbValue lb_emit_call(lbProcedure *p, lbValue value, Array const &args, ProcInlining inlining = ProcInlining_none); +gb_internal lbValue lb_emit_conv(lbProcedure *p, lbValue value, Type *t); +gb_internal lbValue lb_emit_comp_against_nil(lbProcedure *p, TokenKind op_kind, lbValue x); -void lb_emit_jump(lbProcedure *p, lbBlock *target_block); -void lb_emit_if(lbProcedure *p, lbValue cond, lbBlock *true_block, lbBlock *false_block); -void lb_start_block(lbProcedure *p, lbBlock *b); +gb_internal void lb_emit_jump(lbProcedure *p, lbBlock *target_block); +gb_internal void lb_emit_if(lbProcedure *p, lbValue cond, lbBlock *true_block, lbBlock *false_block); +gb_internal void lb_start_block(lbProcedure *p, lbBlock *b); -lbValue lb_build_call_expr(lbProcedure *p, Ast *expr); +gb_internal lbValue lb_build_call_expr(lbProcedure *p, Ast *expr); -lbAddr lb_find_or_generate_context_ptr(lbProcedure *p); -lbContextData *lb_push_context_onto_stack(lbProcedure *p, lbAddr ctx); -lbContextData *lb_push_context_onto_stack_from_implicit_parameter(lbProcedure *p); +gb_internal lbAddr lb_find_or_generate_context_ptr(lbProcedure *p); +gb_internal lbContextData *lb_push_context_onto_stack(lbProcedure *p, lbAddr ctx); +gb_internal lbContextData *lb_push_context_onto_stack_from_implicit_parameter(lbProcedure *p); -lbAddr lb_add_global_generated(lbModule *m, Type *type, lbValue value={}, Entity **entity_=nullptr); -lbAddr lb_add_local(lbProcedure *p, Type *type, Entity *e=nullptr, bool zero_init=true, bool force_no_init=false); +gb_internal lbAddr lb_add_global_generated(lbModule *m, Type *type, lbValue value={}, Entity **entity_=nullptr); +gb_internal lbAddr lb_add_local(lbProcedure *p, Type *type, Entity *e=nullptr, bool zero_init=true, bool force_no_init=false); -void lb_add_foreign_library_path(lbModule *m, Entity *e); +gb_internal void lb_add_foreign_library_path(lbModule *m, Entity *e); -lbValue lb_typeid(lbModule *m, Type *type); +gb_internal lbValue lb_typeid(lbModule *m, Type *type); -lbValue lb_address_from_load_or_generate_local(lbProcedure *p, lbValue value); -lbValue lb_address_from_load(lbProcedure *p, lbValue value); -void lb_add_defer_node(lbProcedure *p, isize scope_index, Ast *stmt); -lbAddr lb_add_local_generated(lbProcedure *p, Type *type, bool zero_init); +gb_internal lbValue lb_address_from_load_or_generate_local(lbProcedure *p, lbValue value); +gb_internal lbValue lb_address_from_load(lbProcedure *p, lbValue value); +gb_internal void lb_add_defer_node(lbProcedure *p, isize scope_index, Ast *stmt); +gb_internal lbAddr lb_add_local_generated(lbProcedure *p, Type *type, bool zero_init); -lbValue lb_emit_runtime_call(lbProcedure *p, char const *c_name, Array const &args); +gb_internal lbValue lb_emit_runtime_call(lbProcedure *p, char const *c_name, Array const &args); -lbValue lb_emit_ptr_offset(lbProcedure *p, lbValue ptr, lbValue index); -lbValue lb_string_elem(lbProcedure *p, lbValue string); -lbValue lb_string_len(lbProcedure *p, lbValue string); -lbValue lb_cstring_len(lbProcedure *p, lbValue value); -lbValue lb_array_elem(lbProcedure *p, lbValue array_ptr); -lbValue lb_slice_elem(lbProcedure *p, lbValue slice); -lbValue lb_slice_len(lbProcedure *p, lbValue slice); -lbValue lb_dynamic_array_elem(lbProcedure *p, lbValue da); -lbValue lb_dynamic_array_len(lbProcedure *p, lbValue da); -lbValue lb_dynamic_array_cap(lbProcedure *p, lbValue da); -lbValue lb_dynamic_array_allocator(lbProcedure *p, lbValue da); -lbValue lb_map_len(lbProcedure *p, lbValue value); -lbValue lb_map_cap(lbProcedure *p, lbValue value); -lbValue lb_soa_struct_len(lbProcedure *p, lbValue value); -void lb_emit_increment(lbProcedure *p, lbValue addr); -lbValue lb_emit_select(lbProcedure *p, lbValue cond, lbValue x, lbValue y); +gb_internal lbValue lb_emit_ptr_offset(lbProcedure *p, lbValue ptr, lbValue index); +gb_internal lbValue lb_string_elem(lbProcedure *p, lbValue string); +gb_internal lbValue lb_string_len(lbProcedure *p, lbValue string); +gb_internal lbValue lb_cstring_len(lbProcedure *p, lbValue value); +gb_internal lbValue lb_array_elem(lbProcedure *p, lbValue array_ptr); +gb_internal lbValue lb_slice_elem(lbProcedure *p, lbValue slice); +gb_internal lbValue lb_slice_len(lbProcedure *p, lbValue slice); +gb_internal lbValue lb_dynamic_array_elem(lbProcedure *p, lbValue da); +gb_internal lbValue lb_dynamic_array_len(lbProcedure *p, lbValue da); +gb_internal lbValue lb_dynamic_array_cap(lbProcedure *p, lbValue da); +gb_internal lbValue lb_dynamic_array_allocator(lbProcedure *p, lbValue da); +gb_internal lbValue lb_map_len(lbProcedure *p, lbValue value); +gb_internal lbValue lb_map_cap(lbProcedure *p, lbValue value); +gb_internal lbValue lb_soa_struct_len(lbProcedure *p, lbValue value); +gb_internal void lb_emit_increment(lbProcedure *p, lbValue addr); +gb_internal lbValue lb_emit_select(lbProcedure *p, lbValue cond, lbValue x, lbValue y); -lbValue lb_emit_mul_add(lbProcedure *p, lbValue a, lbValue b, lbValue c, Type *t); +gb_internal lbValue lb_emit_mul_add(lbProcedure *p, lbValue a, lbValue b, lbValue c, Type *t); -void lb_fill_slice(lbProcedure *p, lbAddr const &slice, lbValue base_elem, lbValue len); +gb_internal void lb_fill_slice(lbProcedure *p, lbAddr const &slice, lbValue base_elem, lbValue len); -lbValue lb_type_info(lbModule *m, Type *type); +gb_internal lbValue lb_type_info(lbModule *m, Type *type); -lbValue lb_find_or_add_entity_string(lbModule *m, String const &str); -lbValue lb_generate_anonymous_proc_lit(lbModule *m, String const &prefix_name, Ast *expr, lbProcedure *parent = nullptr); +gb_internal lbValue lb_find_or_add_entity_string(lbModule *m, String const &str); +gb_internal lbValue lb_generate_anonymous_proc_lit(lbModule *m, String const &prefix_name, Ast *expr, lbProcedure *parent = nullptr); -bool lb_is_const(lbValue value); -bool lb_is_const_or_global(lbValue value); -bool lb_is_const_nil(lbValue value); -String lb_get_const_string(lbModule *m, lbValue value); +gb_internal bool lb_is_const(lbValue value); +gb_internal bool lb_is_const_or_global(lbValue value); +gb_internal bool lb_is_const_nil(lbValue value); +gb_internal String lb_get_const_string(lbModule *m, lbValue value); -lbValue lb_generate_local_array(lbProcedure *p, Type *elem_type, i64 count, bool zero_init=true); -lbValue lb_generate_global_array(lbModule *m, Type *elem_type, i64 count, String prefix, i64 id); -lbValue lb_gen_map_key_hash(lbProcedure *p, lbValue key, Type *key_type, lbValue *key_ptr_); -lbValue lb_gen_map_cell_info_ptr(lbModule *m, Type *type); -lbValue lb_gen_map_info_ptr(lbModule *m, Type *map_type); +gb_internal lbValue lb_generate_local_array(lbProcedure *p, Type *elem_type, i64 count, bool zero_init=true); +gb_internal lbValue lb_generate_global_array(lbModule *m, Type *elem_type, i64 count, String prefix, i64 id); +gb_internal lbValue lb_gen_map_key_hash(lbProcedure *p, lbValue const &map_ptr, lbValue key, lbValue *key_ptr_); +gb_internal lbValue lb_gen_map_cell_info_ptr(lbModule *m, Type *type); +gb_internal lbValue lb_gen_map_info_ptr(lbModule *m, Type *map_type); -lbValue lb_internal_dynamic_map_get_ptr(lbProcedure *p, lbValue const &map_ptr, lbValue const &key); -void lb_internal_dynamic_map_set(lbProcedure *p, lbValue const &map_ptr, Type *map_type, lbValue const &map_key, lbValue const &map_value, Ast *node); -lbValue lb_dynamic_map_reserve(lbProcedure *p, lbValue const &map_ptr, isize const capacity, TokenPos const &pos); +gb_internal lbValue lb_internal_dynamic_map_get_ptr(lbProcedure *p, lbValue const &map_ptr, lbValue const &key); +gb_internal void lb_internal_dynamic_map_set(lbProcedure *p, lbValue const &map_ptr, Type *map_type, lbValue const &map_key, lbValue const &map_value, Ast *node); +gb_internal lbValue lb_dynamic_map_reserve(lbProcedure *p, lbValue const &map_ptr, isize const capacity, TokenPos const &pos); -lbValue lb_find_procedure_value_from_entity(lbModule *m, Entity *e); -lbValue lb_find_value_from_entity(lbModule *m, Entity *e); +gb_internal lbValue lb_find_procedure_value_from_entity(lbModule *m, Entity *e); +gb_internal lbValue lb_find_value_from_entity(lbModule *m, Entity *e); -void lb_store_type_case_implicit(lbProcedure *p, Ast *clause, lbValue value); -lbAddr lb_store_range_stmt_val(lbProcedure *p, Ast *stmt_val, lbValue value); -lbValue lb_emit_source_code_location_const(lbProcedure *p, String const &procedure, TokenPos const &pos); +gb_internal void lb_store_type_case_implicit(lbProcedure *p, Ast *clause, lbValue value); +gb_internal lbAddr lb_store_range_stmt_val(lbProcedure *p, Ast *stmt_val, lbValue value); +gb_internal lbValue lb_emit_source_code_location_const(lbProcedure *p, String const &procedure, TokenPos const &pos); -lbValue lb_handle_param_value(lbProcedure *p, Type *parameter_type, ParameterValue const ¶m_value, TokenPos const &pos); +gb_internal lbValue lb_handle_param_value(lbProcedure *p, Type *parameter_type, ParameterValue const ¶m_value, TokenPos const &pos); -lbValue lb_equal_proc_for_type(lbModule *m, Type *type); -lbValue lb_hasher_proc_for_type(lbModule *m, Type *type); -lbValue lb_emit_conv(lbProcedure *p, lbValue value, Type *t); +gb_internal lbValue lb_equal_proc_for_type(lbModule *m, Type *type); +gb_internal lbValue lb_hasher_proc_for_type(lbModule *m, Type *type); +gb_internal lbValue lb_emit_conv(lbProcedure *p, lbValue value, Type *t); -LLVMMetadataRef lb_debug_type(lbModule *m, Type *type); +gb_internal LLVMMetadataRef lb_debug_type(lbModule *m, Type *type); -lbValue lb_emit_count_ones(lbProcedure *p, lbValue x, Type *type); -lbValue lb_emit_count_zeros(lbProcedure *p, lbValue x, Type *type); -lbValue lb_emit_count_trailing_zeros(lbProcedure *p, lbValue x, Type *type); -lbValue lb_emit_count_leading_zeros(lbProcedure *p, lbValue x, Type *type); -lbValue lb_emit_reverse_bits(lbProcedure *p, lbValue x, Type *type); +gb_internal lbValue lb_emit_count_ones(lbProcedure *p, lbValue x, Type *type); +gb_internal lbValue lb_emit_count_zeros(lbProcedure *p, lbValue x, Type *type); +gb_internal lbValue lb_emit_count_trailing_zeros(lbProcedure *p, lbValue x, Type *type); +gb_internal lbValue lb_emit_count_leading_zeros(lbProcedure *p, lbValue x, Type *type); +gb_internal lbValue lb_emit_reverse_bits(lbProcedure *p, lbValue x, Type *type); -lbValue lb_emit_bit_set_card(lbProcedure *p, lbValue x); +gb_internal lbValue lb_emit_bit_set_card(lbProcedure *p, lbValue x); -void lb_mem_zero_addr(lbProcedure *p, LLVMValueRef ptr, Type *type); +gb_internal void lb_mem_zero_addr(lbProcedure *p, LLVMValueRef ptr, Type *type); -void lb_build_nested_proc(lbProcedure *p, AstProcLit *pd, Entity *e); -lbValue lb_emit_logical_binary_expr(lbProcedure *p, TokenKind op, Ast *left, Ast *right, Type *type); -lbValue lb_build_cond(lbProcedure *p, Ast *cond, lbBlock *true_block, lbBlock *false_block); +gb_internal void lb_build_nested_proc(lbProcedure *p, AstProcLit *pd, Entity *e); +gb_internal lbValue lb_emit_logical_binary_expr(lbProcedure *p, TokenKind op, Ast *left, Ast *right, Type *type); +gb_internal lbValue lb_build_cond(lbProcedure *p, Ast *cond, lbBlock *true_block, lbBlock *false_block); -LLVMValueRef llvm_const_named_struct(lbModule *m, Type *t, LLVMValueRef *values, isize value_count_); -LLVMValueRef llvm_const_named_struct_internal(LLVMTypeRef t, LLVMValueRef *values, isize value_count_); -void lb_set_entity_from_other_modules_linkage_correctly(lbModule *other_module, Entity *e, String const &name); +gb_internal LLVMValueRef llvm_const_named_struct(lbModule *m, Type *t, LLVMValueRef *values, isize value_count_); +gb_internal LLVMValueRef llvm_const_named_struct_internal(LLVMTypeRef t, LLVMValueRef *values, isize value_count_); +gb_internal void lb_set_entity_from_other_modules_linkage_correctly(lbModule *other_module, Entity *e, String const &name); -lbValue lb_expr_untyped_const_to_typed(lbModule *m, Ast *expr, Type *t); -bool lb_is_expr_untyped_const(Ast *expr); +gb_internal lbValue lb_expr_untyped_const_to_typed(lbModule *m, Ast *expr, Type *t); +gb_internal bool lb_is_expr_untyped_const(Ast *expr); -LLVMValueRef llvm_alloca(lbProcedure *p, LLVMTypeRef llvm_type, isize alignment, char const *name = ""); +gb_internal LLVMValueRef llvm_alloca(lbProcedure *p, LLVMTypeRef llvm_type, isize alignment, char const *name = ""); -void lb_mem_zero_ptr(lbProcedure *p, LLVMValueRef ptr, Type *type, unsigned alignment); +gb_internal void lb_mem_zero_ptr(lbProcedure *p, LLVMValueRef ptr, Type *type, unsigned alignment); -void lb_emit_init_context(lbProcedure *p, lbAddr addr); +gb_internal void lb_emit_init_context(lbProcedure *p, lbAddr addr); -lbStructFieldRemapping lb_get_struct_remapping(lbModule *m, Type *t); -LLVMTypeRef lb_type_padding_filler(lbModule *m, i64 padding, i64 padding_align); +gb_internal lbStructFieldRemapping lb_get_struct_remapping(lbModule *m, Type *t); +gb_internal LLVMTypeRef lb_type_padding_filler(lbModule *m, i64 padding, i64 padding_align); -LLVMValueRef llvm_basic_shuffle(lbProcedure *p, LLVMValueRef vector, LLVMValueRef mask); +gb_internal LLVMValueRef llvm_basic_shuffle(lbProcedure *p, LLVMValueRef vector, LLVMValueRef mask); -LLVMValueRef lb_call_intrinsic(lbProcedure *p, const char *name, LLVMValueRef* args, unsigned arg_count, LLVMTypeRef* types, unsigned type_count); -void lb_mem_copy_overlapping(lbProcedure *p, lbValue dst, lbValue src, lbValue len, bool is_volatile=false); -void lb_mem_copy_non_overlapping(lbProcedure *p, lbValue dst, lbValue src, lbValue len, bool is_volatile=false); -LLVMValueRef lb_mem_zero_ptr_internal(lbProcedure *p, LLVMValueRef ptr, LLVMValueRef len, unsigned alignment, bool is_volatile); +gb_internal LLVMValueRef lb_call_intrinsic(lbProcedure *p, const char *name, LLVMValueRef* args, unsigned arg_count, LLVMTypeRef* types, unsigned type_count); +gb_internal void lb_mem_copy_overlapping(lbProcedure *p, lbValue dst, lbValue src, lbValue len, bool is_volatile=false); +gb_internal void lb_mem_copy_non_overlapping(lbProcedure *p, lbValue dst, lbValue src, lbValue len, bool is_volatile=false); +gb_internal LLVMValueRef lb_mem_zero_ptr_internal(lbProcedure *p, LLVMValueRef ptr, LLVMValueRef len, unsigned alignment, bool is_volatile); -i64 lb_max_zero_init_size(void) { - return cast(i64)(4*build_context.word_size); +gb_internal gb_inline i64 lb_max_zero_init_size(void) { + return cast(i64)(4*build_context.int_size); } -LLVMTypeRef OdinLLVMGetArrayElementType(LLVMTypeRef type); -LLVMTypeRef OdinLLVMGetVectorElementType(LLVMTypeRef type); +gb_internal LLVMTypeRef OdinLLVMGetArrayElementType(LLVMTypeRef type); +gb_internal LLVMTypeRef OdinLLVMGetVectorElementType(LLVMTypeRef type); + +gb_internal String lb_filepath_ll_for_module(lbModule *m); #define LB_STARTUP_RUNTIME_PROC_NAME "__$startup_runtime" +#define LB_CLEANUP_RUNTIME_PROC_NAME "__$cleanup_runtime" #define LB_STARTUP_TYPE_INFO_PROC_NAME "__$startup_type_info" #define LB_TYPE_INFO_DATA_NAME "__$type_info_data" #define LB_TYPE_INFO_TYPES_NAME "__$type_info_types_data" @@ -631,7 +666,7 @@ enum : LLVMAttributeIndex { }; -char const *llvm_linkage_strings[] = { +gb_global char const *llvm_linkage_strings[] = { "external linkage", "available externally linkage", "link once any linkage", diff --git a/src/llvm_backend_const.cpp b/src/llvm_backend_const.cpp index dff5298c5..efe1e4d45 100644 --- a/src/llvm_backend_const.cpp +++ b/src/llvm_backend_const.cpp @@ -1,6 +1,6 @@ -bool lb_is_const(lbValue value) { +gb_internal bool lb_is_const(lbValue value) { LLVMValueRef v = value.value; - if (is_type_untyped_nil(value.type) || is_type_untyped_undef(value.type)) { + if (is_type_untyped_nil(value.type)) { // TODO(bill): Is this correct behaviour? return true; } @@ -10,7 +10,7 @@ bool lb_is_const(lbValue value) { return false; } -bool lb_is_const_or_global(lbValue value) { +gb_internal bool lb_is_const_or_global(lbValue value) { if (lb_is_const(value)) { return true; } @@ -29,7 +29,7 @@ bool lb_is_const_or_global(lbValue value) { } -bool lb_is_elem_const(Ast *elem, Type *elem_type) { +gb_internal bool lb_is_elem_const(Ast *elem, Type *elem_type) { if (!elem_type_can_be_constant(elem_type)) { return false; } @@ -42,7 +42,7 @@ bool lb_is_elem_const(Ast *elem, Type *elem_type) { } -bool lb_is_const_nil(lbValue value) { +gb_internal bool lb_is_const_nil(lbValue value) { LLVMValueRef v = value.value; if (LLVMIsConstant(v)) { if (LLVMIsAConstantAggregateZero(v)) { @@ -55,7 +55,7 @@ bool lb_is_const_nil(lbValue value) { } -bool lb_is_expr_constant_zero(Ast *expr) { +gb_internal bool lb_is_expr_constant_zero(Ast *expr) { GB_ASSERT(expr != nullptr); auto v = exact_value_to_integer(expr->tav.value); if (v.kind == ExactValue_Integer) { @@ -64,7 +64,7 @@ bool lb_is_expr_constant_zero(Ast *expr) { return false; } -String lb_get_const_string(lbModule *m, lbValue value) { +gb_internal String lb_get_const_string(lbModule *m, lbValue value) { GB_ASSERT(lb_is_const(value)); GB_ASSERT(LLVMIsConstant(value.value)); @@ -92,7 +92,7 @@ String lb_get_const_string(lbModule *m, lbValue value) { } -LLVMValueRef llvm_const_cast(LLVMValueRef val, LLVMTypeRef dst) { +gb_internal LLVMValueRef llvm_const_cast(LLVMValueRef val, LLVMTypeRef dst) { LLVMTypeRef src = LLVMTypeOf(val); if (src == dst) { return val; @@ -107,7 +107,11 @@ LLVMValueRef llvm_const_cast(LLVMValueRef val, LLVMTypeRef dst) { case LLVMPointerTypeKind: return LLVMConstPointerCast(val, dst); case LLVMStructTypeKind: - return LLVMConstBitCast(val, dst); + // GB_PANIC("%s -> %s", LLVMPrintValueToString(val), LLVMPrintTypeToString(dst)); + // NOTE(bill): It's not possible to do a bit cast on a struct, why was this code even here in the first place? + // It seems mostly to exist to get around the "anonymous -> named" struct assignments + // return LLVMConstBitCast(val, dst); + return val; default: GB_PANIC("Unhandled const cast %s to %s", LLVMPrintTypeToString(src), LLVMPrintTypeToString(dst)); } @@ -116,7 +120,7 @@ LLVMValueRef llvm_const_cast(LLVMValueRef val, LLVMTypeRef dst) { } -lbValue lb_const_ptr_cast(lbModule *m, lbValue value, Type *t) { +gb_internal lbValue lb_const_ptr_cast(lbModule *m, lbValue value, Type *t) { GB_ASSERT(is_type_internally_pointer_like(value.type)); GB_ASSERT(is_type_internally_pointer_like(t)); GB_ASSERT(lb_is_const(value)); @@ -127,7 +131,26 @@ lbValue lb_const_ptr_cast(lbModule *m, lbValue value, Type *t) { return res; } -LLVMValueRef llvm_const_named_struct(lbModule *m, Type *t, LLVMValueRef *values, isize value_count_) { + +gb_internal LLVMValueRef llvm_const_string_internal(lbModule *m, Type *t, LLVMValueRef data, LLVMValueRef len) { + if (build_context.metrics.ptr_size < build_context.metrics.int_size) { + LLVMValueRef values[3] = { + data, + LLVMConstNull(lb_type(m, t_i32)), + len, + }; + return llvm_const_named_struct_internal(lb_type(m, t), values, 3); + } else { + LLVMValueRef values[2] = { + data, + len, + }; + return llvm_const_named_struct_internal(lb_type(m, t), values, 2); + } +} + + +gb_internal LLVMValueRef llvm_const_named_struct(lbModule *m, Type *t, LLVMValueRef *values, isize value_count_) { LLVMTypeRef struct_type = lb_type(m, t); GB_ASSERT(LLVMGetTypeKind(struct_type) == LLVMStructTypeKind); @@ -157,7 +180,7 @@ LLVMValueRef llvm_const_named_struct(lbModule *m, Type *t, LLVMValueRef *values, return llvm_const_named_struct_internal(struct_type, values_with_padding, values_with_padding_count); } -LLVMValueRef llvm_const_named_struct_internal(LLVMTypeRef t, LLVMValueRef *values, isize value_count_) { +gb_internal LLVMValueRef llvm_const_named_struct_internal(LLVMTypeRef t, LLVMValueRef *values, isize value_count_) { unsigned value_count = cast(unsigned)value_count_; unsigned elem_count = LLVMCountStructElementTypes(t); GB_ASSERT_MSG(value_count == elem_count, "%s %u %u", LLVMPrintTypeToString(t), value_count, elem_count); @@ -168,7 +191,7 @@ LLVMValueRef llvm_const_named_struct_internal(LLVMTypeRef t, LLVMValueRef *value return LLVMConstNamedStruct(t, values, value_count); } -LLVMValueRef llvm_const_array(LLVMTypeRef elem_type, LLVMValueRef *values, isize value_count_) { +gb_internal LLVMValueRef llvm_const_array(LLVMTypeRef elem_type, LLVMValueRef *values, isize value_count_) { unsigned value_count = cast(unsigned)value_count_; for (unsigned i = 0; i < value_count; i++) { values[i] = llvm_const_cast(values[i], elem_type); @@ -176,49 +199,65 @@ LLVMValueRef llvm_const_array(LLVMTypeRef elem_type, LLVMValueRef *values, isize return LLVMConstArray(elem_type, values, value_count); } -LLVMValueRef llvm_const_slice(lbModule *m, lbValue data, lbValue len) { +gb_internal LLVMValueRef llvm_const_slice_internal(lbModule *m, LLVMValueRef data, LLVMValueRef len) { + if (build_context.metrics.ptr_size < build_context.metrics.int_size) { + GB_ASSERT(build_context.metrics.ptr_size == 4); + GB_ASSERT(build_context.metrics.int_size == 8); + LLVMValueRef vals[3] = { + data, + LLVMConstNull(lb_type(m, t_u32)), + len, + }; + return LLVMConstStructInContext(m->ctx, vals, gb_count_of(vals), false); + } else { + LLVMValueRef vals[2] = { + data, + len, + }; + return LLVMConstStructInContext(m->ctx, vals, gb_count_of(vals), false); + } +} +gb_internal LLVMValueRef llvm_const_slice(lbModule *m, lbValue data, lbValue len) { GB_ASSERT(is_type_pointer(data.type) || is_type_multi_pointer(data.type)); GB_ASSERT(are_types_identical(len.type, t_int)); - LLVMValueRef vals[2] = { - data.value, - len.value, - }; - return LLVMConstStructInContext(m->ctx, vals, gb_count_of(vals), false); + + return llvm_const_slice_internal(m, data.value, len.value); } -lbValue lb_const_nil(lbModule *m, Type *type) { + +gb_internal lbValue lb_const_nil(lbModule *m, Type *type) { LLVMValueRef v = LLVMConstNull(lb_type(m, type)); return lbValue{v, type}; } -lbValue lb_const_undef(lbModule *m, Type *type) { +gb_internal lbValue lb_const_undef(lbModule *m, Type *type) { LLVMValueRef v = LLVMGetUndef(lb_type(m, type)); return lbValue{v, type}; } -lbValue lb_const_int(lbModule *m, Type *type, u64 value) { +gb_internal lbValue lb_const_int(lbModule *m, Type *type, u64 value) { lbValue res = {}; res.value = LLVMConstInt(lb_type(m, type), cast(unsigned long long)value, !is_type_unsigned(type)); res.type = type; return res; } -lbValue lb_const_string(lbModule *m, String const &value) { +gb_internal lbValue lb_const_string(lbModule *m, String const &value) { return lb_const_value(m, t_string, exact_value_string(value)); } -lbValue lb_const_bool(lbModule *m, Type *type, bool value) { +gb_internal lbValue lb_const_bool(lbModule *m, Type *type, bool value) { lbValue res = {}; res.value = LLVMConstInt(lb_type(m, type), value, false); res.type = type; return res; } -LLVMValueRef lb_const_f16(lbModule *m, f32 f, Type *type=t_f16) { +gb_internal LLVMValueRef lb_const_f16(lbModule *m, f32 f, Type *type=t_f16) { GB_ASSERT(type_size_of(type) == 2); u16 u = f32_to_f16(f); @@ -229,7 +268,7 @@ LLVMValueRef lb_const_f16(lbModule *m, f32 f, Type *type=t_f16) { return LLVMConstBitCast(i, lb_type(m, type)); } -LLVMValueRef lb_const_f32(lbModule *m, f32 f, Type *type=t_f32) { +gb_internal LLVMValueRef lb_const_f32(lbModule *m, f32 f, Type *type=t_f32) { GB_ASSERT(type_size_of(type) == 4); u32 u = bit_cast(f); if (is_type_different_to_arch_endianness(type)) { @@ -241,7 +280,7 @@ LLVMValueRef lb_const_f32(lbModule *m, f32 f, Type *type=t_f32) { -bool lb_is_expr_untyped_const(Ast *expr) { +gb_internal bool lb_is_expr_untyped_const(Ast *expr) { auto const &tv = type_and_value_of_expr(expr); if (is_type_untyped(tv.type)) { return tv.value.kind != ExactValue_Invalid; @@ -250,13 +289,13 @@ bool lb_is_expr_untyped_const(Ast *expr) { } -lbValue lb_expr_untyped_const_to_typed(lbModule *m, Ast *expr, Type *t) { +gb_internal lbValue lb_expr_untyped_const_to_typed(lbModule *m, Ast *expr, Type *t) { GB_ASSERT(is_type_typed(t)); auto const &tv = type_and_value_of_expr(expr); return lb_const_value(m, t, tv.value); } -lbValue lb_emit_source_code_location_const(lbProcedure *p, String const &procedure, TokenPos const &pos) { +gb_internal lbValue lb_emit_source_code_location_const(lbProcedure *p, String const &procedure, TokenPos const &pos) { lbModule *m = p->module; LLVMValueRef fields[4] = {}; @@ -271,7 +310,7 @@ lbValue lb_emit_source_code_location_const(lbProcedure *p, String const &procedu return res; } -lbValue lb_emit_source_code_location_const(lbProcedure *p, Ast *node) { +gb_internal lbValue lb_emit_source_code_location_const(lbProcedure *p, Ast *node) { String proc_name = {}; if (p->entity) { proc_name = p->entity->token.string; @@ -284,7 +323,7 @@ lbValue lb_emit_source_code_location_const(lbProcedure *p, Ast *node) { } -lbValue lb_emit_source_code_location_as_global_ptr(lbProcedure *p, String const &procedure, TokenPos const &pos) { +gb_internal lbValue lb_emit_source_code_location_as_global_ptr(lbProcedure *p, String const &procedure, TokenPos const &pos) { lbValue loc = lb_emit_source_code_location_const(p, procedure, pos); lbAddr addr = lb_add_global_generated(p->module, loc.type, loc, nullptr); lb_make_global_private_const(addr); @@ -292,24 +331,24 @@ lbValue lb_emit_source_code_location_as_global_ptr(lbProcedure *p, String const } -lbValue lb_emit_source_code_location_as_global_ptr(lbProcedure *p, Ast *node) { +gb_internal lbValue lb_emit_source_code_location_as_global_ptr(lbProcedure *p, Ast *node) { lbValue loc = lb_emit_source_code_location_const(p, node); lbAddr addr = lb_add_global_generated(p->module, loc.type, loc, nullptr); lb_make_global_private_const(addr); return addr.addr; } -lbValue lb_emit_source_code_location_as_global(lbProcedure *p, String const &procedure, TokenPos const &pos) { +gb_internal lbValue lb_emit_source_code_location_as_global(lbProcedure *p, String const &procedure, TokenPos const &pos) { return lb_emit_load(p, lb_emit_source_code_location_as_global_ptr(p, procedure, pos)); } -lbValue lb_emit_source_code_location_as_global(lbProcedure *p, Ast *node) { +gb_internal lbValue lb_emit_source_code_location_as_global(lbProcedure *p, Ast *node) { return lb_emit_load(p, lb_emit_source_code_location_as_global_ptr(p, node)); } -LLVMValueRef lb_build_constant_array_values(lbModule *m, Type *type, Type *elem_type, isize count, LLVMValueRef *values, bool allow_local) { +gb_internal LLVMValueRef lb_build_constant_array_values(lbModule *m, Type *type, Type *elem_type, isize count, LLVMValueRef *values, bool allow_local) { bool is_local = allow_local && m->curr_procedure != nullptr; bool is_const = true; if (is_local) { @@ -341,7 +380,7 @@ LLVMValueRef lb_build_constant_array_values(lbModule *m, Type *type, Type *elem_ return llvm_const_array(lb_type(m, elem_type), values, cast(unsigned int)count); } -LLVMValueRef lb_big_int_to_llvm(lbModule *m, Type *original_type, BigInt const *a) { +gb_internal LLVMValueRef lb_big_int_to_llvm(lbModule *m, Type *original_type, BigInt const *a) { if (big_int_is_zero(a)) { return LLVMConstNull(lb_type(m, original_type)); } @@ -386,8 +425,33 @@ LLVMValueRef lb_big_int_to_llvm(lbModule *m, Type *original_type, BigInt const * return value; } +gb_internal bool lb_is_nested_possibly_constant(Type *ft, Selection const &sel, Ast *elem) { + GB_ASSERT(!sel.indirect); + for (i32 index : sel.index) { + Type *bt = base_type(ft); + switch (bt->kind) { + case Type_Struct: + if (bt->Struct.is_raw_union) { + return false; + } + ft = bt->Struct.fields[index]->type; + break; + case Type_Array: + ft = bt->Array.elem; + break; + default: + return false; + } + } -lbValue lb_const_value(lbModule *m, Type *type, ExactValue value, bool allow_local) { + + if (is_type_raw_union(ft) || is_type_typeid(ft)) { + return false; + } + return lb_is_elem_const(elem, ft); +} + +gb_internal lbValue lb_const_value(lbModule *m, Type *type, ExactValue value, bool allow_local) { LLVMContextRef ctx = m->ctx; type = default_type(type); @@ -409,9 +473,9 @@ lbValue lb_const_value(lbModule *m, Type *type, ExactValue value, bool allow_loc if (value.kind == ExactValue_Procedure) { lbValue res = {}; Ast *expr = unparen_expr(value.value_procedure); + GB_ASSERT(expr != nullptr); if (expr->kind == Ast_ProcLit) { res = lb_generate_anonymous_proc_lit(m, str_lit("_proclit"), expr); - } else { Entity *e = entity_from_expr(expr); res = lb_find_procedure_value_from_entity(m, e); @@ -460,7 +524,10 @@ lbValue lb_const_value(lbModule *m, Type *type, ExactValue value, bool allow_loc LLVMValueRef indices[2] = {llvm_zero(m), llvm_zero(m)}; LLVMValueRef ptr = LLVMBuildInBoundsGEP2(p->builder, llvm_type, array_data, indices, 2, ""); LLVMValueRef len = LLVMConstInt(lb_type(m, t_int), count, true); + lbAddr slice = lb_add_local_generated(p, type, false); + map_set(&m->exact_value_compound_literal_addr_map, value.value_compound, slice); + lb_fill_slice(p, slice, {ptr, alloc_type_pointer(elem)}, {len, t_int}); return lb_addr_load(p, slice); } @@ -612,10 +679,9 @@ lbValue lb_const_value(lbModule *m, Type *type, ExactValue value, bool allow_loc ptr = LLVMConstNull(lb_type(m, t_u8_ptr)); } LLVMValueRef str_len = LLVMConstInt(lb_type(m, t_int), value.value_string.len, true); - LLVMValueRef values[2] = {ptr, str_len}; GB_ASSERT(is_type_string(original_type)); - res.value = llvm_const_named_struct(m, original_type, values, 2); + res.value = llvm_const_string_internal(m, original_type, ptr, str_len); } return res; @@ -978,12 +1044,59 @@ lbValue lb_const_value(lbModule *m, Type *type, ExactValue value, bool allow_loc GB_ASSERT(tav.mode != Addressing_Invalid); Selection sel = lookup_field(type, name, false); + GB_ASSERT(!sel.indirect); + Entity *f = type->Struct.fields[sel.index[0]]; - i32 index = field_remapping[f->Variable.field_index]; if (elem_type_can_be_constant(f->type)) { - values[index] = lb_const_value(m, f->type, tav.value, allow_local).value; - visited[index] = true; + if (sel.index.count == 1) { + values[index] = lb_const_value(m, f->type, tav.value, allow_local).value; + visited[index] = true; + } else { + if (!visited[index]) { + values[index] = lb_const_value(m, f->type, {}, false).value; + visited[index] = true; + } + unsigned idx_list_len = cast(unsigned)sel.index.count-1; + unsigned *idx_list = gb_alloc_array(temporary_allocator(), unsigned, idx_list_len); + + if (lb_is_nested_possibly_constant(type, sel, fv->value)) { + bool is_constant = true; + Type *cv_type = f->type; + for (isize j = 1; j < sel.index.count; j++) { + i32 index = sel.index[j]; + Type *cvt = base_type(cv_type); + + if (cvt->kind == Type_Struct) { + if (cvt->Struct.is_raw_union) { + // sanity check which should have been caught by `lb_is_nested_possibly_constant` + is_constant = false; + break; + } + cv_type = cvt->Struct.fields[index]->type; + + if (is_type_struct(cvt)) { + auto cv_field_remapping = lb_get_struct_remapping(m, cvt); + unsigned remapped_index = cast(unsigned)cv_field_remapping[index]; + idx_list[j-1] = remapped_index; + } else { + idx_list[j-1] = cast(unsigned)index; + } + } else if (cvt->kind == Type_Array) { + cv_type = cvt->Array.elem; + + idx_list[j-1] = cast(unsigned)index; + } else { + GB_PANIC("UNKNOWN TYPE: %s", type_to_string(cv_type)); + } + } + if (is_constant) { + LLVMValueRef elem_value = lb_const_value(m, tav.type, tav.value, allow_local).value; + GB_ASSERT(LLVMIsConstant(elem_value)); + values[index] = LLVMConstInsertValue(values[index], elem_value, idx_list, idx_list_len); + } + } + } } } } else { @@ -1043,6 +1156,8 @@ lbValue lb_const_value(lbModule *m, Type *type, ExactValue value, bool allow_loc GB_ASSERT(is_local); lbProcedure *p = m->curr_procedure; lbAddr v = lb_add_local_generated(p, res.type, true); + map_set(&m->exact_value_compound_literal_addr_map, value.value_compound, v); + LLVMBuildStore(p->builder, constant_value, v.addr.value); for (isize i = 0; i < value_count; i++) { LLVMValueRef val = old_values[i]; diff --git a/src/llvm_backend_debug.cpp b/src/llvm_backend_debug.cpp index 65cefcd39..b9c6c606e 100644 --- a/src/llvm_backend_debug.cpp +++ b/src/llvm_backend_debug.cpp @@ -1,27 +1,25 @@ -LLVMMetadataRef lb_get_llvm_metadata(lbModule *m, void *key) { +gb_internal LLVMMetadataRef lb_get_llvm_metadata(lbModule *m, void *key) { if (key == nullptr) { return nullptr; } + mutex_lock(&m->debug_values_mutex); auto found = map_get(&m->debug_values, key); + mutex_unlock(&m->debug_values_mutex); if (found) { return *found; } return nullptr; } -void lb_set_llvm_metadata(lbModule *m, void *key, LLVMMetadataRef value) { +gb_internal void lb_set_llvm_metadata(lbModule *m, void *key, LLVMMetadataRef value) { if (key != nullptr) { + mutex_lock(&m->debug_values_mutex); map_set(&m->debug_values, key, value); + mutex_unlock(&m->debug_values_mutex); } } -LLVMMetadataRef lb_get_llvm_file_metadata_from_node(lbModule *m, Ast *node) { - if (node == nullptr) { - return nullptr; - } - return lb_get_llvm_metadata(m, node->file()); -} -LLVMMetadataRef lb_get_current_debug_scope(lbProcedure *p) { +gb_internal LLVMMetadataRef lb_get_current_debug_scope(lbProcedure *p) { GB_ASSERT_MSG(p->debug_info != nullptr, "missing debug information for %.*s", LIT(p->name)); for (isize i = p->scope_stack.count-1; i >= 0; i--) { @@ -34,28 +32,28 @@ LLVMMetadataRef lb_get_current_debug_scope(lbProcedure *p) { return p->debug_info; } -LLVMMetadataRef lb_debug_location_from_token_pos(lbProcedure *p, TokenPos pos) { +gb_internal LLVMMetadataRef lb_debug_location_from_token_pos(lbProcedure *p, TokenPos pos) { LLVMMetadataRef scope = lb_get_current_debug_scope(p); GB_ASSERT_MSG(scope != nullptr, "%.*s", LIT(p->name)); return LLVMDIBuilderCreateDebugLocation(p->module->ctx, cast(unsigned)pos.line, cast(unsigned)pos.column, scope, nullptr); } -LLVMMetadataRef lb_debug_location_from_ast(lbProcedure *p, Ast *node) { +gb_internal LLVMMetadataRef lb_debug_location_from_ast(lbProcedure *p, Ast *node) { GB_ASSERT(node != nullptr); return lb_debug_location_from_token_pos(p, ast_token(node).pos); } -LLVMMetadataRef lb_debug_end_location_from_ast(lbProcedure *p, Ast *node) { +gb_internal LLVMMetadataRef lb_debug_end_location_from_ast(lbProcedure *p, Ast *node) { GB_ASSERT(node != nullptr); return lb_debug_location_from_token_pos(p, ast_end_token(node).pos); } -LLVMMetadataRef lb_debug_type_internal_proc(lbModule *m, Type *type) { +gb_internal LLVMMetadataRef lb_debug_type_internal_proc(lbModule *m, Type *type) { i64 size = type_size_of(type); // Check size gb_unused(size); GB_ASSERT(type != t_invalid); - /* unsigned const word_size = cast(unsigned)build_context.word_size; - unsigned const word_bits = cast(unsigned)(8*build_context.word_size); */ + /* unsigned const ptr_size = cast(unsigned)build_context.ptr_size; + unsigned const ptr_bits = cast(unsigned)(8*build_context.ptr_size); */ GB_ASSERT(type->kind == Type_Proc); unsigned parameter_count = 1; @@ -93,7 +91,7 @@ LLVMMetadataRef lb_debug_type_internal_proc(lbModule *m, Type *type) { return LLVMDIBuilderCreateSubroutineType(m->debug_builder, file, parameters, parameter_count, flags); } -LLVMMetadataRef lb_debug_struct_field(lbModule *m, String const &name, Type *type, u64 offset_in_bits) { +gb_internal LLVMMetadataRef lb_debug_struct_field(lbModule *m, String const &name, Type *type, u64 offset_in_bits) { unsigned field_line = 1; LLVMDIFlags field_flags = LLVMDIFlagZero; @@ -107,7 +105,7 @@ LLVMMetadataRef lb_debug_struct_field(lbModule *m, String const &name, Type *typ field_flags, lb_debug_type(m, type) ); } -LLVMMetadataRef lb_debug_basic_struct(lbModule *m, String const &name, u64 size_in_bits, u32 align_in_bits, LLVMMetadataRef *elements, unsigned element_count) { +gb_internal LLVMMetadataRef lb_debug_basic_struct(lbModule *m, String const &name, u64 size_in_bits, u32 align_in_bits, LLVMMetadataRef *elements, unsigned element_count) { AstPackage *pkg = m->info->runtime_package; GB_ASSERT(pkg->files.count != 0); LLVMMetadataRef file = lb_get_llvm_metadata(m, pkg->files[0]); @@ -117,7 +115,7 @@ LLVMMetadataRef lb_debug_basic_struct(lbModule *m, String const &name, u64 size_ } -LLVMMetadataRef lb_debug_type_basic_type(lbModule *m, String const &name, u64 size_in_bits, LLVMDWARFTypeEncoding encoding, LLVMDIFlags flags = LLVMDIFlagZero) { +gb_internal LLVMMetadataRef lb_debug_type_basic_type(lbModule *m, String const &name, u64 size_in_bits, LLVMDWARFTypeEncoding encoding, LLVMDIFlags flags = LLVMDIFlagZero) { LLVMMetadataRef basic_type = LLVMDIBuilderCreateBasicType(m->debug_builder, cast(char const *)name.text, name.len, size_in_bits, encoding, flags); #if 1 LLVMMetadataRef final_decl = LLVMDIBuilderCreateTypedef(m->debug_builder, basic_type, cast(char const *)name.text, name.len, nullptr, 0, nullptr, cast(u32)size_in_bits); @@ -127,14 +125,15 @@ LLVMMetadataRef lb_debug_type_basic_type(lbModule *m, String const &name, u64 si #endif } -LLVMMetadataRef lb_debug_type_internal(lbModule *m, Type *type) { +gb_internal LLVMMetadataRef lb_debug_type_internal(lbModule *m, Type *type) { i64 size = type_size_of(type); // Check size gb_unused(size); GB_ASSERT(type != t_invalid); - /* unsigned const word_size = cast(unsigned)build_context.word_size; */ - unsigned const word_bits = cast(unsigned)(8*build_context.word_size); + /* unsigned const ptr_size = cast(unsigned)build_context.ptr_size; */ + unsigned const int_bits = cast(unsigned)(8*build_context.int_size); + unsigned const ptr_bits = cast(unsigned)(8*build_context.ptr_size); switch (type->kind) { case Type_Basic: @@ -164,12 +163,12 @@ LLVMMetadataRef lb_debug_type_internal(lbModule *m, Type *type) { case Basic_f32: return lb_debug_type_basic_type(m, str_lit("f32"), 32, LLVMDWARFTypeEncoding_Float); case Basic_f64: return lb_debug_type_basic_type(m, str_lit("f64"), 64, LLVMDWARFTypeEncoding_Float); - case Basic_int: return lb_debug_type_basic_type(m, str_lit("int"), word_bits, LLVMDWARFTypeEncoding_Signed); - case Basic_uint: return lb_debug_type_basic_type(m, str_lit("uint"), word_bits, LLVMDWARFTypeEncoding_Unsigned); - case Basic_uintptr: return lb_debug_type_basic_type(m, str_lit("uintptr"), word_bits, LLVMDWARFTypeEncoding_Unsigned); + case Basic_int: return lb_debug_type_basic_type(m, str_lit("int"), int_bits, LLVMDWARFTypeEncoding_Signed); + case Basic_uint: return lb_debug_type_basic_type(m, str_lit("uint"), int_bits, LLVMDWARFTypeEncoding_Unsigned); + case Basic_uintptr: return lb_debug_type_basic_type(m, str_lit("uintptr"), ptr_bits, LLVMDWARFTypeEncoding_Unsigned); case Basic_typeid: - return lb_debug_type_basic_type(m, str_lit("typeid"), word_bits, LLVMDWARFTypeEncoding_Unsigned); + return lb_debug_type_basic_type(m, str_lit("typeid"), ptr_bits, LLVMDWARFTypeEncoding_Unsigned); // Endian Specific Types case Basic_i16le: return lb_debug_type_basic_type(m, str_lit("i16le"), 16, LLVMDWARFTypeEncoding_Signed, LLVMDIFlagLittleEndian); @@ -253,26 +252,26 @@ LLVMMetadataRef lb_debug_type_internal(lbModule *m, Type *type) { case Basic_rawptr: { LLVMMetadataRef void_type = lb_debug_type_basic_type(m, str_lit("void"), 8, LLVMDWARFTypeEncoding_Unsigned); - return LLVMDIBuilderCreatePointerType(m->debug_builder, void_type, word_bits, word_bits, LLVMDWARFTypeEncoding_Address, "rawptr", 6); + return LLVMDIBuilderCreatePointerType(m->debug_builder, void_type, ptr_bits, ptr_bits, LLVMDWARFTypeEncoding_Address, "rawptr", 6); } case Basic_string: { LLVMMetadataRef elements[2] = {}; elements[0] = lb_debug_struct_field(m, str_lit("data"), t_u8_ptr, 0); - elements[1] = lb_debug_struct_field(m, str_lit("len"), t_int, word_bits); - return lb_debug_basic_struct(m, str_lit("string"), 2*word_bits, word_bits, elements, gb_count_of(elements)); + elements[1] = lb_debug_struct_field(m, str_lit("len"), t_int, int_bits); + return lb_debug_basic_struct(m, str_lit("string"), 2*int_bits, int_bits, elements, gb_count_of(elements)); } case Basic_cstring: { LLVMMetadataRef char_type = lb_debug_type_basic_type(m, str_lit("char"), 8, LLVMDWARFTypeEncoding_Unsigned); - return LLVMDIBuilderCreatePointerType(m->debug_builder, char_type, word_bits, word_bits, 0, "cstring", 7); + return LLVMDIBuilderCreatePointerType(m->debug_builder, char_type, ptr_bits, ptr_bits, 0, "cstring", 7); } case Basic_any: { LLVMMetadataRef elements[2] = {}; elements[0] = lb_debug_struct_field(m, str_lit("data"), t_rawptr, 0); - elements[1] = lb_debug_struct_field(m, str_lit("id"), t_typeid, word_bits); - return lb_debug_basic_struct(m, str_lit("any"), 2*word_bits, word_bits, elements, gb_count_of(elements)); + elements[1] = lb_debug_struct_field(m, str_lit("id"), t_typeid, ptr_bits); + return lb_debug_basic_struct(m, str_lit("any"), 2*ptr_bits, ptr_bits, elements, gb_count_of(elements)); } // Untyped types @@ -284,7 +283,7 @@ LLVMMetadataRef lb_debug_type_internal(lbModule *m, Type *type) { case Basic_UntypedString: GB_PANIC("Basic_UntypedString"); break; case Basic_UntypedRune: GB_PANIC("Basic_UntypedRune"); break; case Basic_UntypedNil: GB_PANIC("Basic_UntypedNil"); break; - case Basic_UntypedUndef: GB_PANIC("Basic_UntypedUndef"); break; + case Basic_UntypedUninit: GB_PANIC("Basic_UntypedUninit"); break; default: GB_PANIC("Basic Unhandled"); break; } @@ -294,11 +293,11 @@ LLVMMetadataRef lb_debug_type_internal(lbModule *m, Type *type) { GB_PANIC("Type_Named should be handled in lb_debug_type separately"); case Type_SoaPointer: - return LLVMDIBuilderCreatePointerType(m->debug_builder, lb_debug_type(m, type->SoaPointer.elem), word_bits, word_bits, 0, nullptr, 0); + return LLVMDIBuilderCreatePointerType(m->debug_builder, lb_debug_type(m, type->SoaPointer.elem), int_bits, int_bits, 0, nullptr, 0); case Type_Pointer: - return LLVMDIBuilderCreatePointerType(m->debug_builder, lb_debug_type(m, type->Pointer.elem), word_bits, word_bits, 0, nullptr, 0); + return LLVMDIBuilderCreatePointerType(m->debug_builder, lb_debug_type(m, type->Pointer.elem), ptr_bits, ptr_bits, 0, nullptr, 0); case Type_MultiPointer: - return LLVMDIBuilderCreatePointerType(m->debug_builder, lb_debug_type(m, type->MultiPointer.elem), word_bits, word_bits, 0, nullptr, 0); + return LLVMDIBuilderCreatePointerType(m->debug_builder, lb_debug_type(m, type->MultiPointer.elem), ptr_bits, ptr_bits, 0, nullptr, 0); case Type_Array: { LLVMMetadataRef subscripts[1] = {}; @@ -418,7 +417,7 @@ LLVMMetadataRef lb_debug_type_internal(lbModule *m, Type *type) { case Type_Proc: { LLVMMetadataRef proc_underlying_type = lb_debug_type_internal_proc(m, type); - LLVMMetadataRef pointer_type = LLVMDIBuilderCreatePointerType(m->debug_builder, proc_underlying_type, word_bits, word_bits, 0, nullptr, 0); + LLVMMetadataRef pointer_type = LLVMDIBuilderCreatePointerType(m->debug_builder, proc_underlying_type, ptr_bits, ptr_bits, 0, nullptr, 0); gbString name = type_to_string(type, temporary_allocator()); return LLVMDIBuilderCreateTypedef(m->debug_builder, pointer_type, name, gb_string_length(name), nullptr, 0, nullptr, cast(u32)(8*type_align_of(type))); } @@ -449,10 +448,11 @@ LLVMMetadataRef lb_debug_type_internal(lbModule *m, Type *type) { unsigned element_count = 0; LLVMMetadataRef elements[2] = {}; Type *base_integer = type->RelativeSlice.base_integer; + unsigned base_bits = cast(unsigned)(8*type_size_of(base_integer)); elements[0] = lb_debug_struct_field(m, str_lit("data_offset"), base_integer, 0); - elements[1] = lb_debug_struct_field(m, str_lit("len"), base_integer, 8*type_size_of(base_integer)); + elements[1] = lb_debug_struct_field(m, str_lit("len"), base_integer, base_bits); gbString name = type_to_string(type, temporary_allocator()); - return LLVMDIBuilderCreateStructType(m->debug_builder, nullptr, name, gb_string_length(name), nullptr, 0, 2*word_bits, word_bits, LLVMDIFlagZero, nullptr, elements, element_count, 0, nullptr, "", 0); + return LLVMDIBuilderCreateStructType(m->debug_builder, nullptr, name, gb_string_length(name), nullptr, 0, 2*base_bits, base_bits, LLVMDIFlagZero, nullptr, elements, element_count, 0, nullptr, "", 0); } case Type_Matrix: { @@ -474,7 +474,7 @@ LLVMMetadataRef lb_debug_type_internal(lbModule *m, Type *type) { return nullptr; } -LLVMMetadataRef lb_get_base_scope_metadata(lbModule *m, Scope *scope) { +gb_internal LLVMMetadataRef lb_get_base_scope_metadata(lbModule *m, Scope *scope) { LLVMMetadataRef found = nullptr; for (;;) { if (scope == nullptr) { @@ -496,13 +496,15 @@ LLVMMetadataRef lb_get_base_scope_metadata(lbModule *m, Scope *scope) { } } -LLVMMetadataRef lb_debug_type(lbModule *m, Type *type) { +gb_internal LLVMMetadataRef lb_debug_type(lbModule *m, Type *type) { GB_ASSERT(type != nullptr); LLVMMetadataRef found = lb_get_llvm_metadata(m, type); if (found != nullptr) { return found; } + MUTEX_GUARD(&m->debug_values_mutex); + if (type->kind == Type_Named) { LLVMMetadataRef file = nullptr; unsigned line = 0; @@ -615,11 +617,12 @@ LLVMMetadataRef lb_debug_type(lbModule *m, Type *type) { return dt; } -void lb_debug_complete_types(lbModule *m) { - /* unsigned const word_size = cast(unsigned)build_context.word_size; */ - unsigned const word_bits = cast(unsigned)(8*build_context.word_size); +gb_internal void lb_debug_complete_types(lbModule *m) { + unsigned const int_bits = cast(unsigned)(8*build_context.int_size); for_array(debug_incomplete_type_index, m->debug_incomplete_types) { + TEMPORARY_ALLOCATOR_GUARD(); + auto const &idt = m->debug_incomplete_types[debug_incomplete_type_index]; GB_ASSERT(idt.type != nullptr); GB_ASSERT(idt.metadata != nullptr); @@ -689,27 +692,27 @@ void lb_debug_complete_types(lbModule *m) { element_count = 2; elements = gb_alloc_array(temporary_allocator(), LLVMMetadataRef, element_count); #if defined(GB_SYSTEM_WINDOWS) - elements[0] = lb_debug_struct_field(m, str_lit("data"), alloc_type_pointer(bt->Slice.elem), 0*word_bits); + elements[0] = lb_debug_struct_field(m, str_lit("data"), alloc_type_pointer(bt->Slice.elem), 0*int_bits); #else // FIX HACK TODO(bill): For some reason this causes a crash in *nix systems due to the reference counting // of the debug type information - elements[0] = lb_debug_struct_field(m, str_lit("data"), t_rawptr, 0*word_bits); + elements[0] = lb_debug_struct_field(m, str_lit("data"), t_rawptr, 0*int_bits); #endif - elements[1] = lb_debug_struct_field(m, str_lit("len"), t_int, 1*word_bits); + elements[1] = lb_debug_struct_field(m, str_lit("len"), t_int, 1*int_bits); break; case Type_DynamicArray: element_count = 4; elements = gb_alloc_array(temporary_allocator(), LLVMMetadataRef, element_count); #if defined(GB_SYSTEM_WINDOWS) - elements[0] = lb_debug_struct_field(m, str_lit("data"), alloc_type_pointer(bt->DynamicArray.elem), 0*word_bits); + elements[0] = lb_debug_struct_field(m, str_lit("data"), alloc_type_pointer(bt->DynamicArray.elem), 0*int_bits); #else // FIX HACK TODO(bill): For some reason this causes a crash in *nix systems due to the reference counting // of the debug type information - elements[0] = lb_debug_struct_field(m, str_lit("data"), t_rawptr, 0*word_bits); + elements[0] = lb_debug_struct_field(m, str_lit("data"), t_rawptr, 0*int_bits); #endif - elements[1] = lb_debug_struct_field(m, str_lit("len"), t_int, 1*word_bits); - elements[2] = lb_debug_struct_field(m, str_lit("cap"), t_int, 2*word_bits); - elements[3] = lb_debug_struct_field(m, str_lit("allocator"), t_allocator, 3*word_bits); + elements[1] = lb_debug_struct_field(m, str_lit("len"), t_int, 1*int_bits); + elements[2] = lb_debug_struct_field(m, str_lit("cap"), t_int, 2*int_bits); + elements[3] = lb_debug_struct_field(m, str_lit("allocator"), t_allocator, 3*int_bits); break; case Type_Map: @@ -735,7 +738,7 @@ void lb_debug_complete_types(lbModule *m) { element_count = cast(unsigned)(bt->Struct.fields.count + element_offset); elements = gb_alloc_array(temporary_allocator(), LLVMMetadataRef, element_count); - isize field_size_bits = 8*type_size_of(bt) - element_offset*word_bits; + isize field_size_bits = 8*type_size_of(bt) - element_offset*int_bits; switch (bt->Struct.soa_kind) { case StructSoa_Slice: @@ -754,7 +757,7 @@ void lb_debug_complete_types(lbModule *m) { ".len", 4, file, 0, 8*cast(u64)type_size_of(t_int), 8*cast(u32)type_align_of(t_int), - field_size_bits + 0*word_bits, + field_size_bits + 0*int_bits, LLVMDIFlagZero, lb_debug_type(m, t_int) ); elements[1] = LLVMDIBuilderCreateMemberType( @@ -762,7 +765,7 @@ void lb_debug_complete_types(lbModule *m) { ".cap", 4, file, 0, 8*cast(u64)type_size_of(t_int), 8*cast(u32)type_align_of(t_int), - field_size_bits + 1*word_bits, + field_size_bits + 1*int_bits, LLVMDIFlagZero, lb_debug_type(m, t_int) ); elements[2] = LLVMDIBuilderCreateMemberType( @@ -770,7 +773,7 @@ void lb_debug_complete_types(lbModule *m) { ".allocator", 10, file, 0, 8*cast(u64)type_size_of(t_int), 8*cast(u32)type_align_of(t_int), - field_size_bits + 2*word_bits, + field_size_bits + 2*int_bits, LLVMDIFlagZero, lb_debug_type(m, t_allocator) ); break; @@ -962,7 +965,7 @@ void lb_debug_complete_types(lbModule *m) { -void lb_add_debug_local_variable(lbProcedure *p, LLVMValueRef ptr, Type *type, Token const &token) { +gb_internal void lb_add_debug_local_variable(lbProcedure *p, LLVMValueRef ptr, Type *type, Token const &token) { if (p->debug_info == nullptr) { return; } @@ -987,7 +990,6 @@ void lb_add_debug_local_variable(lbProcedure *p, LLVMValueRef ptr, Type *type, T return; } - AstFile *file = p->body->file(); LLVMMetadataRef llvm_scope = lb_get_current_debug_scope(p); @@ -1024,7 +1026,7 @@ void lb_add_debug_local_variable(lbProcedure *p, LLVMValueRef ptr, Type *type, T LLVMDIBuilderInsertDeclareAtEnd(m->debug_builder, storage, var_info, llvm_expr, llvm_debug_loc, block); } -void lb_add_debug_param_variable(lbProcedure *p, LLVMValueRef ptr, Type *type, Token const &token, unsigned arg_number, lbBlock *block, lbArgKind arg_kind) { +gb_internal void lb_add_debug_param_variable(lbProcedure *p, LLVMValueRef ptr, Type *type, Token const &token, unsigned arg_number, lbBlock *block, lbArgKind arg_kind) { if (p->debug_info == nullptr) { return; } @@ -1097,7 +1099,7 @@ void lb_add_debug_param_variable(lbProcedure *p, LLVMValueRef ptr, Type *type, T } -void lb_add_debug_context_variable(lbProcedure *p, lbAddr const &ctx) { +gb_internal void lb_add_debug_context_variable(lbProcedure *p, lbAddr const &ctx) { if (!p->debug_info || !p->body) { return; } @@ -1125,17 +1127,17 @@ void lb_add_debug_context_variable(lbProcedure *p, lbAddr const &ctx) { } -String debug_info_mangle_constant_name(Entity *e, bool *did_allocate_) { +gb_internal String debug_info_mangle_constant_name(Entity *e, gbAllocator const &allocator, bool *did_allocate_) { String name = e->token.string; if (e->pkg && e->pkg->name.len > 0) { // NOTE(bill): C++ NONSENSE FOR DEBUG SHITE! - name = concatenate3_strings(heap_allocator(), e->pkg->name, str_lit("::"), name); + name = concatenate3_strings(allocator, e->pkg->name, str_lit("::"), name); if (did_allocate_) *did_allocate_ = true; } return name; } -void add_debug_info_global_variable_expr(lbModule *m, String const &name, LLVMMetadataRef dtype, LLVMMetadataRef expr) { +gb_internal void add_debug_info_global_variable_expr(lbModule *m, String const &name, LLVMMetadataRef dtype, LLVMMetadataRef expr) { LLVMMetadataRef scope = nullptr; LLVMMetadataRef file = nullptr; unsigned line = 0; @@ -1151,14 +1153,11 @@ void add_debug_info_global_variable_expr(lbModule *m, String const &name, LLVMMe expr, decl, 8/*AlignInBits*/); } -void add_debug_info_for_global_constant_internal_i64(lbModule *m, Entity *e, LLVMMetadataRef dtype, i64 v) { +gb_internal void add_debug_info_for_global_constant_internal_i64(lbModule *m, Entity *e, LLVMMetadataRef dtype, i64 v) { LLVMMetadataRef expr = LLVMDIBuilderCreateConstantValueExpression(m->debug_builder, v); - bool did_allocate = false; - String name = debug_info_mangle_constant_name(e, &did_allocate); - defer (if (did_allocate) { - gb_free(heap_allocator(), name.text); - }); + TEMPORARY_ALLOCATOR_GUARD(); + String name = debug_info_mangle_constant_name(e, temporary_allocator(), nullptr); add_debug_info_global_variable_expr(m, name, dtype, expr); if ((e->pkg && e->pkg->kind == Package_Init) || @@ -1167,7 +1166,7 @@ void add_debug_info_for_global_constant_internal_i64(lbModule *m, Entity *e, LLV } } -void add_debug_info_for_global_constant_from_entity(lbGenerator *gen, Entity *e) { +gb_internal void add_debug_info_for_global_constant_from_entity(lbGenerator *gen, Entity *e) { if (e == nullptr || e->kind != Entity_Constant) { return; } @@ -1176,7 +1175,7 @@ void add_debug_info_for_global_constant_from_entity(lbGenerator *gen, Entity *e) } lbModule *m = &gen->default_module; if (USE_SEPARATE_MODULES) { - m = lb_pkg_module(gen, e->pkg); + m = lb_module_of_entity(gen, e); } if (is_type_integer(e->type)) { diff --git a/src/llvm_backend_expr.cpp b/src/llvm_backend_expr.cpp index 2c1bfecd6..68ad9e6e0 100644 --- a/src/llvm_backend_expr.cpp +++ b/src/llvm_backend_expr.cpp @@ -1,20 +1,18 @@ -lbValue lb_emit_arith_matrix(lbProcedure *p, TokenKind op, lbValue lhs, lbValue rhs, Type *type, bool component_wise); +gb_internal lbValue lb_emit_arith_matrix(lbProcedure *p, TokenKind op, lbValue lhs, lbValue rhs, Type *type, bool component_wise); -lbValue lb_emit_logical_binary_expr(lbProcedure *p, TokenKind op, Ast *left, Ast *right, Type *type) { +gb_internal lbValue lb_emit_logical_binary_expr(lbProcedure *p, TokenKind op, Ast *left, Ast *right, Type *final_type) { lbModule *m = p->module; lbBlock *rhs = lb_create_block(p, "logical.cmp.rhs"); lbBlock *done = lb_create_block(p, "logical.cmp.done"); - type = default_type(type); - lbValue short_circuit = {}; if (op == Token_CmpAnd) { lb_build_cond(p, left, rhs, done); - short_circuit = lb_const_bool(m, type, false); + short_circuit = lb_const_bool(m, t_llvm_bool, false); } else if (op == Token_CmpOr) { lb_build_cond(p, left, done, rhs); - short_circuit = lb_const_bool(m, type, true); + short_circuit = lb_const_bool(m, t_llvm_bool, true); } if (rhs->preds.count == 0) { @@ -25,7 +23,7 @@ lbValue lb_emit_logical_binary_expr(lbProcedure *p, TokenKind op, Ast *left, Ast if (done->preds.count == 0) { lb_start_block(p, rhs); if (lb_is_expr_untyped_const(right)) { - return lb_expr_untyped_const_to_typed(m, right, type); + return lb_expr_untyped_const_to_typed(m, right, default_type(final_type)); } return lb_build_expr(p, right); } @@ -43,10 +41,11 @@ lbValue lb_emit_logical_binary_expr(lbProcedure *p, TokenKind op, Ast *left, Ast lb_start_block(p, rhs); lbValue edge = {}; if (lb_is_expr_untyped_const(right)) { - edge = lb_expr_untyped_const_to_typed(m, right, type); + edge = lb_expr_untyped_const_to_typed(m, right, t_llvm_bool); } else { - edge = lb_build_expr(p, right); + edge = lb_emit_conv(p, lb_build_expr(p, right), t_llvm_bool); } + GB_ASSERT(edge.type == t_llvm_bool); incoming_values[done->preds.count] = edge.value; incoming_blocks[done->preds.count] = p->curr_block->block; @@ -54,66 +53,53 @@ lbValue lb_emit_logical_binary_expr(lbProcedure *p, TokenKind op, Ast *left, Ast lb_emit_jump(p, done); lb_start_block(p, done); - LLVMTypeRef dst_type = lb_type(m, type); + LLVMTypeRef dst_type = lb_type(m, t_llvm_bool); LLVMValueRef phi = nullptr; GB_ASSERT(incoming_values.count == incoming_blocks.count); GB_ASSERT(incoming_values.count > 0); LLVMTypeRef phi_type = nullptr; - for_array(i, incoming_values) { - LLVMValueRef incoming_value = incoming_values[i]; + for (LLVMValueRef incoming_value : incoming_values) { if (!LLVMIsConstant(incoming_value)) { phi_type = LLVMTypeOf(incoming_value); break; } } + + lbValue res = {}; if (phi_type == nullptr) { phi = LLVMBuildPhi(p->builder, dst_type, ""); LLVMAddIncoming(phi, incoming_values.data, incoming_blocks.data, cast(unsigned)incoming_values.count); - lbValue res = {}; - res.type = type; res.value = phi; - return res; - } - - for_array(i, incoming_values) { - LLVMValueRef incoming_value = incoming_values[i]; - LLVMTypeRef incoming_type = LLVMTypeOf(incoming_value); - - if (phi_type != incoming_type) { - GB_ASSERT_MSG(LLVMIsConstant(incoming_value), "%s vs %s", LLVMPrintTypeToString(phi_type), LLVMPrintTypeToString(incoming_type)); - bool ok = !!LLVMConstIntGetZExtValue(incoming_value); - incoming_values[i] = LLVMConstInt(phi_type, ok, false); - } - - } - - phi = LLVMBuildPhi(p->builder, phi_type, ""); - LLVMAddIncoming(phi, incoming_values.data, incoming_blocks.data, cast(unsigned)incoming_values.count); - - LLVMTypeRef i1 = LLVMInt1TypeInContext(m->ctx); - if ((phi_type == i1) ^ (dst_type == i1)) { - if (phi_type == i1) { - phi = LLVMBuildZExt(p->builder, phi, dst_type, ""); - } else { - phi = LLVMBuildTruncOrBitCast(p->builder, phi, dst_type, ""); - } - } else if (lb_sizeof(phi_type) < lb_sizeof(dst_type)) { - phi = LLVMBuildZExt(p->builder, phi, dst_type, ""); + res.type = t_llvm_bool; } else { - phi = LLVMBuildTruncOrBitCast(p->builder, phi, dst_type, ""); - } - - lbValue res = {}; - res.type = type; - res.value = phi; - return res; + for_array(i, incoming_values) { + LLVMValueRef incoming_value = incoming_values[i]; + LLVMTypeRef incoming_type = LLVMTypeOf(incoming_value); + + if (phi_type != incoming_type) { + GB_ASSERT_MSG(LLVMIsConstant(incoming_value), "%s vs %s", LLVMPrintTypeToString(phi_type), LLVMPrintTypeToString(incoming_type)); + bool ok = !!LLVMConstIntGetZExtValue(incoming_value); + incoming_values[i] = LLVMConstInt(phi_type, ok, false); + } + + } + + // NOTE(bill): this now only uses i1 for the logic to prevent issues with corrupted booleans which are not of value 0 or 1 (e.g. 2) + // Doing this may produce slightly worse code as a result but it will be correct behaviour + + phi = LLVMBuildPhi(p->builder, phi_type, ""); + LLVMAddIncoming(phi, incoming_values.data, incoming_blocks.data, cast(unsigned)incoming_values.count); + res.value = phi; + res.type = t_llvm_bool; + } + return lb_emit_conv(p, res, default_type(final_type)); } -lbValue lb_emit_unary_arith(lbProcedure *p, TokenKind op, lbValue x, Type *type) { +gb_internal lbValue lb_emit_unary_arith(lbProcedure *p, TokenKind op, lbValue x, Type *type) { switch (op) { case Token_Add: return x; @@ -283,7 +269,7 @@ lbValue lb_emit_unary_arith(lbProcedure *p, TokenKind op, lbValue x, Type *type) return res; } -bool lb_try_direct_vector_arith(lbProcedure *p, TokenKind op, lbValue lhs, lbValue rhs, Type *type, lbValue *res_) { +gb_internal bool lb_try_direct_vector_arith(lbProcedure *p, TokenKind op, lbValue lhs, lbValue rhs, Type *type, lbValue *res_) { GB_ASSERT(is_type_array_like(type)); Type *elem_type = base_array_type(type); @@ -418,7 +404,7 @@ bool lb_try_direct_vector_arith(lbProcedure *p, TokenKind op, lbValue lhs, lbVal } -lbValue lb_emit_arith_array(lbProcedure *p, TokenKind op, lbValue lhs, lbValue rhs, Type *type) { +gb_internal lbValue lb_emit_arith_array(lbProcedure *p, TokenKind op, lbValue lhs, lbValue rhs, Type *type) { GB_ASSERT(is_type_array_like(lhs.type) || is_type_array_like(rhs.type)); lhs = lb_emit_conv(p, lhs, type); @@ -490,7 +476,7 @@ lbValue lb_emit_arith_array(lbProcedure *p, TokenKind op, lbValue lhs, lbValue r } } -bool lb_is_matrix_simdable(Type *t) { +gb_internal bool lb_is_matrix_simdable(Type *t) { Type *mt = base_type(t); GB_ASSERT(mt->kind == Type_Matrix); @@ -510,6 +496,14 @@ bool lb_is_matrix_simdable(Type *t) { case TargetArch_arm64: break; } + + if (type_align_of(t) < 16) { + // it's not aligned well enough to use the vector instructions + return false; + } + if ((mt->Matrix.row_count & 1) ^ (mt->Matrix.column_count & 1)) { + return false; + } if (elem->kind == Type_Basic) { switch (elem->Basic.kind) { @@ -524,7 +518,7 @@ bool lb_is_matrix_simdable(Type *t) { return true; case TargetArch_i386: case TargetArch_wasm32: - case TargetArch_wasm64: + case TargetArch_wasm64p32: return false; } } @@ -534,7 +528,7 @@ bool lb_is_matrix_simdable(Type *t) { } -LLVMValueRef lb_matrix_to_vector(lbProcedure *p, lbValue matrix) { +gb_internal LLVMValueRef lb_matrix_to_vector(lbProcedure *p, lbValue matrix) { Type *mt = base_type(matrix.type); GB_ASSERT(mt->kind == Type_Matrix); LLVMTypeRef elem_type = lb_type(p->module, mt->Matrix.elem); @@ -554,7 +548,7 @@ LLVMValueRef lb_matrix_to_vector(lbProcedure *p, lbValue matrix) { #endif } -LLVMValueRef lb_matrix_trimmed_vector_mask(lbProcedure *p, Type *mt) { +gb_internal LLVMValueRef lb_matrix_trimmed_vector_mask(lbProcedure *p, Type *mt) { mt = base_type(mt); GB_ASSERT(mt->kind == Type_Matrix); @@ -574,7 +568,7 @@ LLVMValueRef lb_matrix_trimmed_vector_mask(lbProcedure *p, Type *mt) { return mask; } -LLVMValueRef lb_matrix_to_trimmed_vector(lbProcedure *p, lbValue m) { +gb_internal LLVMValueRef lb_matrix_to_trimmed_vector(lbProcedure *p, lbValue m) { LLVMValueRef vector = lb_matrix_to_vector(p, m); Type *mt = base_type(m.type); @@ -592,7 +586,7 @@ LLVMValueRef lb_matrix_to_trimmed_vector(lbProcedure *p, lbValue m) { } -lbValue lb_emit_matrix_tranpose(lbProcedure *p, lbValue m, Type *type) { +gb_internal lbValue lb_emit_matrix_tranpose(lbProcedure *p, lbValue m, Type *type) { if (is_type_array(m.type)) { i32 rank = type_math_rank(m.type); if (rank == 2) { @@ -669,7 +663,7 @@ lbValue lb_emit_matrix_tranpose(lbProcedure *p, lbValue m, Type *type) { return lb_addr_load(p, res); } -lbValue lb_matrix_cast_vector_to_type(lbProcedure *p, LLVMValueRef vector, Type *type) { +gb_internal lbValue lb_matrix_cast_vector_to_type(lbProcedure *p, LLVMValueRef vector, Type *type) { lbAddr res = lb_add_local_generated(p, type, true); LLVMValueRef res_ptr = res.addr.value; unsigned alignment = cast(unsigned)gb_max(type_align_of(type), lb_alignof(LLVMTypeOf(vector))); @@ -681,7 +675,7 @@ lbValue lb_matrix_cast_vector_to_type(lbProcedure *p, LLVMValueRef vector, Type return lb_addr_load(p, res); } -lbValue lb_emit_matrix_flatten(lbProcedure *p, lbValue m, Type *type) { +gb_internal lbValue lb_emit_matrix_flatten(lbProcedure *p, lbValue m, Type *type) { if (is_type_array(m.type)) { // no-op m.type = type; @@ -710,7 +704,7 @@ lbValue lb_emit_matrix_flatten(lbProcedure *p, lbValue m, Type *type) { } -lbValue lb_emit_outer_product(lbProcedure *p, lbValue a, lbValue b, Type *type) { +gb_internal lbValue lb_emit_outer_product(lbProcedure *p, lbValue a, lbValue b, Type *type) { Type *mt = base_type(type); Type *at = base_type(a.type); Type *bt = base_type(b.type); @@ -741,7 +735,7 @@ lbValue lb_emit_outer_product(lbProcedure *p, lbValue a, lbValue b, Type *type) } -lbValue lb_emit_matrix_mul(lbProcedure *p, lbValue lhs, lbValue rhs, Type *type) { +gb_internal lbValue lb_emit_matrix_mul(lbProcedure *p, lbValue lhs, lbValue rhs, Type *type) { // TODO(bill): Handle edge case for f16 types on x86(-64) platforms Type *xt = base_type(lhs.type); @@ -828,7 +822,7 @@ lbValue lb_emit_matrix_mul(lbProcedure *p, lbValue lhs, lbValue rhs, Type *type) } } -lbValue lb_emit_matrix_mul_vector(lbProcedure *p, lbValue lhs, lbValue rhs, Type *type) { +gb_internal lbValue lb_emit_matrix_mul_vector(lbProcedure *p, lbValue lhs, lbValue rhs, Type *type) { // TODO(bill): Handle edge case for f16 types on x86(-64) platforms Type *mt = base_type(lhs.type); @@ -897,7 +891,7 @@ lbValue lb_emit_matrix_mul_vector(lbProcedure *p, lbValue lhs, lbValue rhs, Type return lb_addr_load(p, res); } -lbValue lb_emit_vector_mul_matrix(lbProcedure *p, lbValue lhs, lbValue rhs, Type *type) { +gb_internal lbValue lb_emit_vector_mul_matrix(lbProcedure *p, lbValue lhs, lbValue rhs, Type *type) { // TODO(bill): Handle edge case for f16 types on x86(-64) platforms Type *mt = base_type(rhs.type); @@ -984,7 +978,7 @@ lbValue lb_emit_vector_mul_matrix(lbProcedure *p, lbValue lhs, lbValue rhs, Type -lbValue lb_emit_arith_matrix(lbProcedure *p, TokenKind op, lbValue lhs, lbValue rhs, Type *type, bool component_wise) { +gb_internal lbValue lb_emit_arith_matrix(lbProcedure *p, TokenKind op, lbValue lhs, lbValue rhs, Type *type, bool component_wise) { GB_ASSERT(is_type_matrix(lhs.type) || is_type_matrix(rhs.type)); if (op == Token_Mul && !component_wise) { @@ -1056,7 +1050,7 @@ lbValue lb_emit_arith_matrix(lbProcedure *p, TokenKind op, lbValue lhs, lbValue -lbValue lb_emit_arith(lbProcedure *p, TokenKind op, lbValue lhs, lbValue rhs, Type *type) { +gb_internal lbValue lb_emit_arith(lbProcedure *p, TokenKind op, lbValue lhs, lbValue rhs, Type *type) { if (is_type_array_like(lhs.type) || is_type_array_like(rhs.type)) { return lb_emit_arith_array(p, op, lhs, rhs, type); } else if (is_type_matrix(lhs.type) || is_type_matrix(rhs.type)) { @@ -1068,7 +1062,9 @@ lbValue lb_emit_arith(lbProcedure *p, TokenKind op, lbValue lhs, lbValue rhs, Ty Type *ft = base_complex_elem_type(type); if (op == Token_Quo) { - auto args = array_make(permanent_allocator(), 2); + TEMPORARY_ALLOCATOR_GUARD(); + + auto args = array_make(temporary_allocator(), 2); args[0] = lhs; args[1] = rhs; @@ -1142,7 +1138,9 @@ lbValue lb_emit_arith(lbProcedure *p, TokenKind op, lbValue lhs, lbValue rhs, Ty return lb_addr_load(p, res); } else if (op == Token_Mul) { - auto args = array_make(permanent_allocator(), 2); + TEMPORARY_ALLOCATOR_GUARD(); + + auto args = array_make(temporary_allocator(), 2); args[0] = lhs; args[1] = rhs; @@ -1152,7 +1150,9 @@ lbValue lb_emit_arith(lbProcedure *p, TokenKind op, lbValue lhs, lbValue rhs, Ty default: GB_PANIC("Unknown float type"); break; } } else if (op == Token_Quo) { - auto args = array_make(permanent_allocator(), 2); + TEMPORARY_ALLOCATOR_GUARD(); + + auto args = array_make(temporary_allocator(), 2); args[0] = lhs; args[1] = rhs; @@ -1164,6 +1164,9 @@ lbValue lb_emit_arith(lbProcedure *p, TokenKind op, lbValue lhs, lbValue rhs, Ty } } + lhs = lb_emit_conv(p, lhs, type); + rhs = lb_emit_conv(p, rhs, type); + if (is_type_integer(type) && is_type_different_to_arch_endianness(type)) { switch (op) { case Token_AndNot: @@ -1192,10 +1195,7 @@ lbValue lb_emit_arith(lbProcedure *p, TokenKind op, lbValue lhs, lbValue rhs, Ty return lb_emit_byte_swap(p, res, type); } -handle_op: - lhs = lb_emit_conv(p, lhs, type); - rhs = lb_emit_conv(p, rhs, type); - +handle_op:; lbValue res = {}; res.type = type; @@ -1325,7 +1325,16 @@ handle_op: return {}; } -lbValue lb_build_binary_expr(lbProcedure *p, Ast *expr) { +gb_internal bool lb_is_empty_string_constant(Ast *expr) { + if (expr->tav.value.kind == ExactValue_String && + is_type_string(expr->tav.type)) { + String s = expr->tav.value.value_string; + return s.len == 0; + } + return false; +} + +gb_internal lbValue lb_build_binary_expr(lbProcedure *p, Ast *expr) { ast_node(be, BinaryExpr, expr); TypeAndValue tv = type_and_value_of_expr(expr); @@ -1373,15 +1382,29 @@ lbValue lb_build_binary_expr(lbProcedure *p, Ast *expr) { case Token_CmpEq: case Token_NotEq: if (is_type_untyped_nil(be->right->tav.type)) { + // `x == nil` or `x != nil` lbValue left = lb_build_expr(p, be->left); lbValue cmp = lb_emit_comp_against_nil(p, be->op.kind, left); Type *type = default_type(tv.type); return lb_emit_conv(p, cmp, type); } else if (is_type_untyped_nil(be->left->tav.type)) { + // `nil == x` or `nil != x` lbValue right = lb_build_expr(p, be->right); lbValue cmp = lb_emit_comp_against_nil(p, be->op.kind, right); Type *type = default_type(tv.type); return lb_emit_conv(p, cmp, type); + } else if (lb_is_empty_string_constant(be->right)) { + // `x == ""` or `x != ""` + lbValue len = lb_string_len(p, lb_build_expr(p, be->left)); + lbValue cmp = lb_emit_comp(p, be->op.kind, len, lb_const_int(p->module, t_int, 0)); + Type *type = default_type(tv.type); + return lb_emit_conv(p, cmp, type); + } else if (lb_is_empty_string_constant(be->left)) { + // `"" == x` or `"" != x` + lbValue len = lb_string_len(p, lb_build_expr(p, be->right)); + lbValue cmp = lb_emit_comp(p, be->op.kind, len, lb_const_int(p->module, t_int, 0)); + Type *type = default_type(tv.type); + return lb_emit_conv(p, cmp, type); } /*fallthrough*/ case Token_Lt: @@ -1472,7 +1495,7 @@ lbValue lb_build_binary_expr(lbProcedure *p, Ast *expr) { return {}; } -lbValue lb_emit_conv(lbProcedure *p, lbValue value, Type *t) { +gb_internal lbValue lb_emit_conv(lbProcedure *p, lbValue value, Type *t) { lbModule *m = p->module; t = reduce_tuple_to_single_type(t); @@ -1486,12 +1509,12 @@ lbValue lb_emit_conv(lbProcedure *p, lbValue value, Type *t) { GB_ASSERT(src != nullptr); GB_ASSERT(dst != nullptr); + if (is_type_untyped_uninit(src)) { + return lb_const_undef(m, t); + } if (is_type_untyped_nil(src)) { return lb_const_nil(m, t); } - if (is_type_untyped_undef(src)) { - return lb_const_undef(m, t); - } if (LLVMIsConstant(value.value)) { if (is_type_any(dst)) { @@ -1553,14 +1576,14 @@ lbValue lb_emit_conv(lbProcedure *p, lbValue value, Type *t) { // bool <-> llvm bool if (is_type_boolean(src) && dst == t_llvm_bool) { lbValue res = {}; - res.value = LLVMBuildTrunc(p->builder, value.value, lb_type(m, dst), ""); - res.type = dst; + res.value = LLVMBuildICmp(p->builder, LLVMIntNE, value.value, LLVMConstNull(lb_type(m, src)), ""); + res.type = t; return res; } if (src == t_llvm_bool && is_type_boolean(dst)) { lbValue res = {}; res.value = LLVMBuildZExt(p->builder, value.value, lb_type(m, dst), ""); - res.type = dst; + res.type = t; return res; } @@ -1643,8 +1666,10 @@ lbValue lb_emit_conv(lbProcedure *p, lbValue value, Type *t) { } if (are_types_identical(src, t_cstring) && are_types_identical(dst, t_string)) { + TEMPORARY_ALLOCATOR_GUARD(); + lbValue c = lb_emit_conv(p, value, t_cstring); - auto args = array_make(permanent_allocator(), 1); + auto args = array_make(temporary_allocator(), 1); args[0] = c; lbValue s = lb_emit_runtime_call(p, "cstring_to_string", args); return lb_emit_conv(p, s, dst); @@ -1788,6 +1813,8 @@ lbValue lb_emit_conv(lbProcedure *p, lbValue value, Type *t) { } if (is_type_integer_128bit(dst)) { + TEMPORARY_ALLOCATOR_GUARD(); + auto args = array_make(temporary_allocator(), 1); args[0] = value; char const *call = "fixunsdfdi"; @@ -1821,6 +1848,8 @@ lbValue lb_emit_conv(lbProcedure *p, lbValue value, Type *t) { } if (is_type_integer_128bit(src)) { + TEMPORARY_ALLOCATOR_GUARD(); + auto args = array_make(temporary_allocator(), 1); args[0] = value; char const *call = "floattidf"; @@ -1921,8 +1950,7 @@ lbValue lb_emit_conv(lbProcedure *p, lbValue value, Type *t) { } if (is_type_union(dst)) { - for_array(i, dst->Union.variants) { - Type *vt = dst->Union.variants[i]; + for (Type *vt : dst->Union.variants) { if (are_types_identical(vt, src_type)) { lbAddr parent = lb_add_local_generated(p, t, true); lb_emit_store_union_variant(p, parent.addr, value, vt); @@ -2065,10 +2093,12 @@ lbValue lb_emit_conv(lbProcedure *p, lbValue value, Type *t) { Type *elem = base_array_type(dst); lbValue e = lb_emit_conv(p, value, elem); lbAddr v = lb_add_local_generated(p, t, false); - for (i64 i = 0; i < dst->Matrix.row_count; i++) { - isize j = cast(isize)i; - lbValue ptr = lb_emit_matrix_epi(p, v.addr, j, j); - lb_emit_store(p, ptr, e); + lbValue zero = lb_const_value(p->module, elem, exact_value_i64(0), true); + for (i64 j = 0; j < dst->Matrix.column_count; j++) { + for (i64 i = 0; i < dst->Matrix.row_count; i++) { + lbValue ptr = lb_emit_matrix_epi(p, v.addr, i, j); + lb_emit_store(p, ptr, i == j ? e : zero); + } } @@ -2125,12 +2155,12 @@ lbValue lb_emit_conv(lbProcedure *p, lbValue value, Type *t) { if (is_type_any(dst)) { + if (is_type_untyped_uninit(src)) { + return lb_const_undef(p->module, t); + } if (is_type_untyped_nil(src)) { return lb_const_nil(p->module, t); } - if (is_type_untyped_undef(src)) { - return lb_const_undef(p->module, t); - } lbAddr result = lb_add_local_generated(p, t, true); @@ -2159,7 +2189,7 @@ lbValue lb_emit_conv(lbProcedure *p, lbValue value, Type *t) { // bit_set <-> integer if (is_type_integer(src) && is_type_bit_set(dst)) { lbValue res = lb_emit_conv(p, value, bit_set_to_int(dst)); - res.type = dst; + res.type = t; return res; } if (is_type_bit_set(src) && is_type_integer(dst)) { @@ -2202,21 +2232,31 @@ lbValue lb_emit_conv(lbProcedure *p, lbValue value, Type *t) { return {}; } -lbValue lb_compare_records(lbProcedure *p, TokenKind op_kind, lbValue left, lbValue right, Type *type) { +gb_internal lbValue lb_compare_records(lbProcedure *p, TokenKind op_kind, lbValue left, lbValue right, Type *type) { GB_ASSERT((is_type_struct(type) || is_type_union(type)) && is_type_comparable(type)); lbValue left_ptr = lb_address_from_load_or_generate_local(p, left); lbValue right_ptr = lb_address_from_load_or_generate_local(p, right); lbValue res = {}; + if (type_size_of(type) == 0) { + switch (op_kind) { + case Token_CmpEq: + return lb_const_bool(p->module, t_bool, true); + case Token_NotEq: + return lb_const_bool(p->module, t_bool, false); + } + GB_PANIC("invalid operator"); + } + TEMPORARY_ALLOCATOR_GUARD(); if (is_type_simple_compare(type)) { // TODO(bill): Test to see if this is actually faster!!!! - auto args = array_make(permanent_allocator(), 3); + auto args = array_make(temporary_allocator(), 3); args[0] = lb_emit_conv(p, left_ptr, t_rawptr); args[1] = lb_emit_conv(p, right_ptr, t_rawptr); args[2] = lb_const_int(p->module, t_int, type_size_of(type)); res = lb_emit_runtime_call(p, "memory_equal", args); } else { lbValue value = lb_equal_proc_for_type(p->module, type); - auto args = array_make(permanent_allocator(), 2); + auto args = array_make(temporary_allocator(), 2); args[0] = lb_emit_conv(p, left_ptr, t_rawptr); args[1] = lb_emit_conv(p, right_ptr, t_rawptr); res = lb_emit_call(p, value, args); @@ -2229,8 +2269,7 @@ lbValue lb_compare_records(lbProcedure *p, TokenKind op_kind, lbValue left, lbVa - -lbValue lb_emit_comp(lbProcedure *p, TokenKind op_kind, lbValue left, lbValue right) { +gb_internal lbValue lb_emit_comp(lbProcedure *p, TokenKind op_kind, lbValue left, lbValue right) { Type *a = core_type(left.type); Type *b = core_type(right.type); @@ -2642,7 +2681,7 @@ lbValue lb_emit_comp(lbProcedure *p, TokenKind op_kind, lbValue left, lbValue ri -lbValue lb_emit_comp_against_nil(lbProcedure *p, TokenKind op_kind, lbValue x) { +gb_internal lbValue lb_emit_comp_against_nil(lbProcedure *p, TokenKind op_kind, lbValue x) { lbValue res = {}; res.type = t_llvm_bool; Type *t = x.type; @@ -2803,17 +2842,17 @@ lbValue lb_emit_comp_against_nil(lbProcedure *p, TokenKind op_kind, lbValue x) { return {}; } -lbValue lb_make_soa_pointer(lbProcedure *p, Type *type, lbValue const &addr, lbValue const &index) { +gb_internal lbValue lb_make_soa_pointer(lbProcedure *p, Type *type, lbValue const &addr, lbValue const &index) { lbAddr v = lb_add_local_generated(p, type, false); lbValue ptr = lb_emit_struct_ep(p, v.addr, 0); lbValue idx = lb_emit_struct_ep(p, v.addr, 1); lb_emit_store(p, ptr, addr); - lb_emit_store(p, idx, index); + lb_emit_store(p, idx, lb_emit_conv(p, index, t_int)); return lb_addr_load(p, v); } -lbValue lb_build_unary_and(lbProcedure *p, Ast *expr) { +gb_internal lbValue lb_build_unary_and(lbProcedure *p, Ast *expr) { ast_node(ue, UnaryExpr, expr); auto tv = type_and_value_of_expr(expr); @@ -2967,7 +3006,7 @@ lbValue lb_build_unary_and(lbProcedure *p, Ast *expr) { isize arg_count = 6; - if (build_context.disallow_rtti) { + if (build_context.no_rtti) { arg_count = 4; } @@ -2979,7 +3018,7 @@ lbValue lb_build_unary_and(lbProcedure *p, Ast *expr) { args[2] = lb_const_int(p->module, t_i32, pos.line); args[3] = lb_const_int(p->module, t_i32, pos.column); - if (!build_context.disallow_rtti) { + if (!build_context.no_rtti) { args[4] = lb_typeid(p->module, src_type); args[5] = lb_typeid(p->module, dst_type); } @@ -2995,7 +3034,7 @@ lbValue lb_build_unary_and(lbProcedure *p, Ast *expr) { } lbValue data_ptr = lb_emit_struct_ev(p, v, 0); if ((p->state_flags & StateFlag_no_type_assert) == 0) { - GB_ASSERT(!build_context.disallow_rtti); + GB_ASSERT(!build_context.no_rtti); lbValue any_id = lb_emit_struct_ev(p, v, 1); @@ -3023,8 +3062,8 @@ lbValue lb_build_unary_and(lbProcedure *p, Ast *expr) { return lb_build_addr_ptr(p, ue->expr); } -lbValue lb_build_expr_internal(lbProcedure *p, Ast *expr); -lbValue lb_build_expr(lbProcedure *p, Ast *expr) { +gb_internal lbValue lb_build_expr_internal(lbProcedure *p, Ast *expr); +gb_internal lbValue lb_build_expr(lbProcedure *p, Ast *expr) { u16 prev_state_flags = p->state_flags; defer (p->state_flags = prev_state_flags); @@ -3080,7 +3119,7 @@ lbValue lb_build_expr(lbProcedure *p, Ast *expr) { return res; } -lbValue lb_build_expr_internal(lbProcedure *p, Ast *expr) { +gb_internal lbValue lb_build_expr_internal(lbProcedure *p, Ast *expr) { lbModule *m = p->module; expr = unparen_expr(expr); @@ -3099,6 +3138,9 @@ lbValue lb_build_expr_internal(lbProcedure *p, Ast *expr) { // NOTE(bill): Short on constant values return lb_const_value(p->module, type, tv.value); + } else if (tv.mode == Addressing_Type) { + // NOTE(bill, 2023-01-16): is this correct? I hope so at least + return lb_typeid(m, tv.type); } switch (expr->kind) { @@ -3116,11 +3158,11 @@ lbValue lb_build_expr_internal(lbProcedure *p, Ast *expr) { return lb_addr_load(p, lb_build_addr(p, expr)); case_end; - case_ast_node(u, Undef, expr) + case_ast_node(u, Uninit, expr) lbValue res = {}; if (is_type_untyped(type)) { res.value = nullptr; - res.type = t_untyped_undef; + res.type = t_untyped_uninit; } else { res.value = LLVMGetUndef(lb_type(m, type)); res.type = type; @@ -3132,7 +3174,7 @@ lbValue lb_build_expr_internal(lbProcedure *p, Ast *expr) { Entity *e = entity_from_expr(expr); e = strip_entity_wrapping(e); - GB_ASSERT_MSG(e != nullptr, "%s", expr_to_string(expr)); + GB_ASSERT_MSG(e != nullptr, "%s in %.*s %p", expr_to_string(expr), LIT(p->name), expr); if (e->kind == Entity_Builtin) { Token token = ast_token(expr); GB_PANIC("TODO(bill): lb_build_expr Entity_Builtin '%.*s'\n" @@ -3355,10 +3397,10 @@ lbValue lb_build_expr_internal(lbProcedure *p, Ast *expr) { return {}; } -lbAddr lb_get_soa_variable_addr(lbProcedure *p, Entity *e) { +gb_internal lbAddr lb_get_soa_variable_addr(lbProcedure *p, Entity *e) { return map_must_get(&p->module->soa_values, e); } -lbValue lb_get_using_variable(lbProcedure *p, Entity *e) { +gb_internal lbValue lb_get_using_variable(lbProcedure *p, Entity *e) { GB_ASSERT(e->kind == Entity_Variable && e->flags & EntityFlag_Using); String name = e->token.string; Entity *parent = e->using_parent; @@ -3393,7 +3435,7 @@ lbValue lb_get_using_variable(lbProcedure *p, Entity *e) { -lbAddr lb_build_addr_from_entity(lbProcedure *p, Entity *e, Ast *expr) { +gb_internal lbAddr lb_build_addr_from_entity(lbProcedure *p, Entity *e, Ast *expr) { GB_ASSERT(e != nullptr); if (e->kind == Entity_Constant) { Type *t = default_type(type_of_expr(expr)); @@ -3427,7 +3469,7 @@ lbAddr lb_build_addr_from_entity(lbProcedure *p, Entity *e, Ast *expr) { return lb_addr(v); } -lbAddr lb_build_array_swizzle_addr(lbProcedure *p, AstCallExpr *ce, TypeAndValue const &tv) { +gb_internal lbAddr lb_build_array_swizzle_addr(lbProcedure *p, AstCallExpr *ce, TypeAndValue const &tv) { isize index_count = ce->args.count-1; lbAddr addr = lb_build_addr(p, ce->args[0]); if (index_count == 0) { @@ -3463,8 +3505,8 @@ lbAddr lb_build_array_swizzle_addr(lbProcedure *p, AstCallExpr *ce, TypeAndValue } -lbAddr lb_build_addr_internal(lbProcedure *p, Ast *expr); -lbAddr lb_build_addr(lbProcedure *p, Ast *expr) { +gb_internal lbAddr lb_build_addr_internal(lbProcedure *p, Ast *expr); +gb_internal lbAddr lb_build_addr(lbProcedure *p, Ast *expr) { expr = unparen_expr(expr); // IMPORTANT NOTE(bill): @@ -3489,7 +3531,7 @@ lbAddr lb_build_addr(lbProcedure *p, Ast *expr) { return addr; } -void lb_build_addr_compound_lit_populate(lbProcedure *p, Slice const &elems, Array *temp_data, Type *compound_type) { +gb_internal void lb_build_addr_compound_lit_populate(lbProcedure *p, Slice const &elems, Array *temp_data, Type *compound_type) { Type *bt = base_type(compound_type); Type *et = nullptr; switch (bt->kind) { @@ -3595,9 +3637,8 @@ void lb_build_addr_compound_lit_populate(lbProcedure *p, Slice const &ele } } } -void lb_build_addr_compound_lit_assign_array(lbProcedure *p, Array const &temp_data) { - for_array(i, temp_data) { - auto td = temp_data[i]; +gb_internal void lb_build_addr_compound_lit_assign_array(lbProcedure *p, Array const &temp_data) { + for (auto const &td : temp_data) { if (td.value.value != nullptr) { if (td.elem_length > 0) { auto loop_data = lb_loop_start(p, cast(isize)td.elem_length, t_i32); @@ -3614,7 +3655,7 @@ void lb_build_addr_compound_lit_assign_array(lbProcedure *p, Arrayexpr)); @@ -3751,6 +3792,7 @@ lbAddr lb_build_addr_index_expr(lbProcedure *p, Ast *expr) { multi_ptr = lb_emit_load(p, multi_ptr); } lbValue index = lb_build_expr(p, ie->index); + index = lb_emit_conv(p, index, t_int); lbValue v = {}; LLVMValueRef indices[1] = {index.value}; @@ -3833,7 +3875,7 @@ lbAddr lb_build_addr_index_expr(lbProcedure *p, Ast *expr) { } -lbAddr lb_build_addr_slice_expr(lbProcedure *p, Ast *expr) { +gb_internal lbAddr lb_build_addr_slice_expr(lbProcedure *p, Ast *expr) { ast_node(se, SliceExpr, expr); lbValue low = lb_const_int(p->module, t_int, 0); @@ -4030,8 +4072,7 @@ lbAddr lb_build_addr_slice_expr(lbProcedure *p, Ast *expr) { return {}; } - -lbAddr lb_build_addr_compound_lit(lbProcedure *p, Ast *expr) { +gb_internal lbAddr lb_build_addr_compound_lit(lbProcedure *p, Ast *expr) { ast_node(cl, CompoundLit, expr); Type *type = type_of_expr(expr); @@ -4039,6 +4080,8 @@ lbAddr lb_build_addr_compound_lit(lbProcedure *p, Ast *expr) { lbAddr v = lb_add_local_generated(p, type, true); + TEMPORARY_ALLOCATOR_GUARD(); + Type *et = nullptr; switch (bt->kind) { case Type_Array: et = bt->Array.elem; break; @@ -4079,12 +4122,25 @@ lbAddr lb_build_addr_compound_lit(lbProcedure *p, Ast *expr) { ast_node(fv, FieldValue, elem); String name = fv->field->Ident.token.string; Selection sel = lookup_field(bt, name, false); - index = sel.index[0]; + GB_ASSERT(!sel.indirect); + elem = fv->value; - TypeAndValue tav = type_and_value_of_expr(elem); + if (sel.index.count > 1) { + if (lb_is_nested_possibly_constant(type, sel, elem)) { + continue; + } + lbValue dst = lb_emit_deep_field_gep(p, comp_lit_ptr, sel); + field_expr = lb_build_expr(p, elem); + field_expr = lb_emit_conv(p, field_expr, sel.entity->type); + lb_emit_store(p, dst, field_expr); + continue; + } + + index = sel.index[0]; } else { - TypeAndValue tav = type_and_value_of_expr(elem); Selection sel = lookup_field_from_index(bt, st->fields[field_index]->Variable.field_index); + GB_ASSERT(sel.index.count == 1); + GB_ASSERT(!sel.indirect); index = sel.index[0]; } @@ -4129,8 +4185,7 @@ lbAddr lb_build_addr_compound_lit(lbProcedure *p, Ast *expr) { lbValue err = lb_dynamic_map_reserve(p, v.addr, 2*cl->elems.count, pos); gb_unused(err); - for_array(field_index, cl->elems) { - Ast *elem = cl->elems[field_index]; + for (Ast *elem : cl->elems) { ast_node(fv, FieldValue, elem); lbValue key = lb_build_expr(p, fv->field); @@ -4197,11 +4252,12 @@ lbAddr lb_build_addr_compound_lit(lbProcedure *p, Ast *expr) { lbValue count = {}; count.type = t_int; + unsigned len_index = lb_convert_struct_index(p->module, type, 1); if (lb_is_const(slice)) { - unsigned indices[1] = {1}; + unsigned indices[1] = {len_index}; count.value = LLVMConstExtractValue(slice.value, indices, gb_count_of(indices)); } else { - count.value = LLVMBuildExtractValue(p->builder, slice.value, 1, ""); + count.value = LLVMBuildExtractValue(p->builder, slice.value, len_index, ""); } lb_fill_slice(p, v, data, count); } @@ -4222,7 +4278,7 @@ lbAddr lb_build_addr_compound_lit(lbProcedure *p, Ast *expr) { i64 item_count = gb_max(cl->max_count, cl->elems.count); { - auto args = array_make(permanent_allocator(), 5); + auto args = array_make(temporary_allocator(), 5); args[0] = lb_emit_conv(p, lb_addr_get_ptr(p, v), t_rawptr); args[1] = size; args[2] = align; @@ -4242,7 +4298,7 @@ lbAddr lb_build_addr_compound_lit(lbProcedure *p, Ast *expr) { lb_build_addr_compound_lit_assign_array(p, temp_data); { - auto args = array_make(permanent_allocator(), 6); + auto args = array_make(temporary_allocator(), 6); args[0] = lb_emit_conv(p, v.addr, t_rawptr); args[1] = size; args[2] = align; @@ -4304,8 +4360,7 @@ lbAddr lb_build_addr_compound_lit(lbProcedure *p, Ast *expr) { lb_addr_store(p, v, lb_const_value(p->module, type, exact_value_compound(expr))); lbValue lower = lb_const_value(p->module, t_int, exact_value_i64(bt->BitSet.lower)); - for_array(i, cl->elems) { - Ast *elem = cl->elems[i]; + for (Ast *elem : cl->elems) { GB_ASSERT(elem->kind != Ast_FieldValue); if (lb_is_elem_const(elem, et)) { @@ -4359,8 +4414,7 @@ lbAddr lb_build_addr_compound_lit(lbProcedure *p, Ast *expr) { // TODO(bill): reduce the need for individual `insertelement` if a `shufflevector` // might be a better option - for_array(i, temp_data) { - auto td = temp_data[i]; + for (auto const &td : temp_data) { if (td.value.value != nullptr) { if (td.elem_length > 0) { for (i64 k = 0; k < td.elem_length; k++) { @@ -4383,7 +4437,7 @@ lbAddr lb_build_addr_compound_lit(lbProcedure *p, Ast *expr) { } -lbAddr lb_build_addr_internal(lbProcedure *p, Ast *expr) { +gb_internal lbAddr lb_build_addr_internal(lbProcedure *p, Ast *expr) { switch (expr->kind) { case_ast_node(i, Implicit, expr); lbAddr v = {}; diff --git a/src/llvm_backend_general.cpp b/src/llvm_backend_general.cpp index 777755794..9333f13a4 100644 --- a/src/llvm_backend_general.cpp +++ b/src/llvm_backend_general.cpp @@ -1,4 +1,5 @@ -void lb_add_debug_local_variable(lbProcedure *p, LLVMValueRef ptr, Type *type, Token const &token); +gb_internal void lb_add_debug_local_variable(lbProcedure *p, LLVMValueRef ptr, Type *type, Token const &token); +gb_internal LLVMValueRef llvm_const_string_internal(lbModule *m, Type *t, LLVMValueRef data, LLVMValueRef len); gb_global Entity *lb_global_type_info_data_entity = {}; gb_global lbAddr lb_global_type_info_member_types = {}; @@ -15,11 +16,13 @@ gb_global isize lb_global_type_info_member_usings_index = 0; gb_global isize lb_global_type_info_member_tags_index = 0; -void lb_init_module(lbModule *m, Checker *c) { +gb_internal void lb_init_module(lbModule *m, Checker *c) { m->info = &c->info; gbString module_name = gb_string_make(heap_allocator(), "odin_package"); - if (m->pkg) { + if (m->file) { + module_name = gb_string_append_fmt(module_name, "-%u", m->file->id+1); + } else if (m->pkg) { module_name = gb_string_appendc(module_name, "-"); module_name = gb_string_append_length(module_name, m->pkg->name.text, m->pkg->name.len); } else if (USE_SEPARATE_MODULES) { @@ -55,34 +58,41 @@ void lb_init_module(lbModule *m, Checker *c) { } gbAllocator a = heap_allocator(); - map_init(&m->types, a); - map_init(&m->func_raw_types, a); - map_init(&m->struct_field_remapping, a); - map_init(&m->values, a); - map_init(&m->soa_values, a); - string_map_init(&m->members, a); - map_init(&m->procedure_values, a); - string_map_init(&m->procedures, a); - string_map_init(&m->const_strings, a); - map_init(&m->function_type_map, a); - map_init(&m->equal_procs, a); - map_init(&m->hasher_procs, a); - map_init(&m->map_get_procs, a); - map_init(&m->map_set_procs, a); - array_init(&m->procedures_to_generate, a, 0, 1024); + map_init(&m->types); + map_init(&m->func_raw_types); + map_init(&m->struct_field_remapping); + map_init(&m->values); + map_init(&m->soa_values); + string_map_init(&m->members); + string_map_init(&m->procedures); + string_map_init(&m->const_strings); + map_init(&m->function_type_map); + map_init(&m->equal_procs); + map_init(&m->hasher_procs); + map_init(&m->map_get_procs); + map_init(&m->map_set_procs); + if (build_context.use_separate_modules) { + array_init(&m->procedures_to_generate, a, 0, 1<<10); + map_init(&m->procedure_values, 1<<11); + } else { + array_init(&m->procedures_to_generate, a, 0, c->info.all_procedures.count); + map_init(&m->procedure_values, c->info.all_procedures.count*2); + } + array_init(&m->global_procedures_and_types_to_create, a, 0, 1024); array_init(&m->missing_procedures_to_check, a, 0, 16); - map_init(&m->debug_values, a); + map_init(&m->debug_values); array_init(&m->debug_incomplete_types, a, 0, 1024); - string_map_init(&m->objc_classes, a); - string_map_init(&m->objc_selectors, a); + string_map_init(&m->objc_classes); + string_map_init(&m->objc_selectors); - map_init(&m->map_info_map, a, 0); - map_init(&m->map_cell_info_map, a, 0); + map_init(&m->map_info_map, 0); + map_init(&m->map_cell_info_map, 0); + map_init(&m->exact_value_compound_literal_addr_map, 1024); } -bool lb_init_generator(lbGenerator *gen, Checker *c) { +gb_internal bool lb_init_generator(lbGenerator *gen, Checker *c) { if (global_error_collector.count != 0) { return false; } @@ -127,34 +137,44 @@ bool lb_init_generator(lbGenerator *gen, Checker *c) { gen->info = &c->info; - map_init(&gen->modules, permanent_allocator(), gen->info->packages.entries.count*2); - map_init(&gen->modules_through_ctx, permanent_allocator(), gen->info->packages.entries.count*2); - map_init(&gen->anonymous_proc_lits, heap_allocator(), 1024); + map_init(&gen->modules, gen->info->packages.count*2); + map_init(&gen->modules_through_ctx, gen->info->packages.count*2); + map_init(&gen->anonymous_proc_lits, 1024); - mutex_init(&gen->foreign_mutex); array_init(&gen->foreign_libraries, heap_allocator(), 0, 1024); - ptr_set_init(&gen->foreign_libraries_set, heap_allocator(), 1024); + ptr_set_init(&gen->foreign_libraries_set, 1024); if (USE_SEPARATE_MODULES) { - for_array(i, gen->info->packages.entries) { - AstPackage *pkg = gen->info->packages.entries[i].value; - + for (auto const &entry : gen->info->packages) { + AstPackage *pkg = entry.value; + #if 1 auto m = gb_alloc_item(permanent_allocator(), lbModule); m->pkg = pkg; m->gen = gen; - map_set(&gen->modules, pkg, m); + map_set(&gen->modules, cast(void *)pkg, m); lb_init_module(m, c); + #else + // NOTE(bill): Probably per file is not a good idea, so leave this for later + for (AstFile *file : pkg->files) { + auto m = gb_alloc_item(permanent_allocator(), lbModule); + m->file = file; + m->pkg = pkg; + m->gen = gen; + map_set(&gen->modules, cast(void *)file, m); + lb_init_module(m, c); + } + #endif } } gen->default_module.gen = gen; - map_set(&gen->modules, cast(AstPackage *)nullptr, &gen->default_module); + map_set(&gen->modules, cast(void *)nullptr, &gen->default_module); lb_init_module(&gen->default_module, c); - for_array(i, gen->modules.entries) { - lbModule *m = gen->modules.entries[i].value; + for (auto const &entry : gen->modules) { + lbModule *m = entry.value; LLVMContextRef ctx = LLVMGetModuleContext(m->mod); map_set(&gen->modules_through_ctx, ctx, m); } @@ -164,7 +184,7 @@ bool lb_init_generator(lbGenerator *gen, Checker *c) { -lbValue lb_global_type_info_data_ptr(lbModule *m) { +gb_internal lbValue lb_global_type_info_data_ptr(lbModule *m) { lbValue v = lb_find_value_from_entity(m, lb_global_type_info_data_entity); return v; } @@ -187,7 +207,7 @@ struct lbCompoundLitElemTempData { }; -lbLoopData lb_loop_start(lbProcedure *p, isize count, Type *index_type=t_i32) { +gb_internal lbLoopData lb_loop_start(lbProcedure *p, isize count, Type *index_type=t_i32) { lbLoopData data = {}; lbValue max = lb_const_int(p->module, t_int, count); @@ -210,7 +230,7 @@ lbLoopData lb_loop_start(lbProcedure *p, isize count, Type *index_type=t_i32) { return data; } -void lb_loop_end(lbProcedure *p, lbLoopData const &data) { +gb_internal void lb_loop_end(lbProcedure *p, lbLoopData const &data) { if (data.idx_addr.addr.value != nullptr) { lb_emit_increment(p, data.idx_addr.addr); lb_emit_jump(p, data.loop); @@ -219,19 +239,19 @@ void lb_loop_end(lbProcedure *p, lbLoopData const &data) { } -void lb_make_global_private_const(LLVMValueRef global_data) { +gb_internal void lb_make_global_private_const(LLVMValueRef global_data) { LLVMSetLinkage(global_data, LLVMPrivateLinkage); LLVMSetUnnamedAddress(global_data, LLVMGlobalUnnamedAddr); LLVMSetGlobalConstant(global_data, true); } -void lb_make_global_private_const(lbAddr const &addr) { +gb_internal void lb_make_global_private_const(lbAddr const &addr) { lb_make_global_private_const(addr.addr.value); } // This emits a GEP at 0, index -lbValue lb_emit_epi(lbProcedure *p, lbValue const &value, isize index) { +gb_internal lbValue lb_emit_epi(lbProcedure *p, lbValue const &value, isize index) { GB_ASSERT(is_type_pointer(value.type)); Type *type = type_deref(value.type); @@ -251,7 +271,7 @@ lbValue lb_emit_epi(lbProcedure *p, lbValue const &value, isize index) { return res; } // This emits a GEP at 0, index -lbValue lb_emit_epi(lbModule *m, lbValue const &value, isize index) { +gb_internal lbValue lb_emit_epi(lbModule *m, lbValue const &value, isize index) { GB_ASSERT(is_type_pointer(value.type)); GB_ASSERT(LLVMIsConstant(value.value)); Type *type = type_deref(value.type); @@ -269,17 +289,11 @@ lbValue lb_emit_epi(lbModule *m, lbValue const &value, isize index) { -LLVMValueRef llvm_zero(lbModule *m) { +gb_internal LLVMValueRef llvm_zero(lbModule *m) { return LLVMConstInt(lb_type(m, t_int), 0, false); } -LLVMValueRef llvm_zero32(lbModule *m) { - return LLVMConstInt(lb_type(m, t_i32), 0, false); -} -LLVMValueRef llvm_one(lbModule *m) { - return LLVMConstInt(lb_type(m, t_i32), 1, false); -} -LLVMValueRef llvm_alloca(lbProcedure *p, LLVMTypeRef llvm_type, isize alignment, char const *name) { +gb_internal LLVMValueRef llvm_alloca(lbProcedure *p, LLVMTypeRef llvm_type, isize alignment, char const *name) { LLVMPositionBuilderAtEnd(p->builder, p->decl_block->block); LLVMValueRef val = LLVMBuildAlloca(p->builder, llvm_type, name); @@ -290,20 +304,20 @@ LLVMValueRef llvm_alloca(lbProcedure *p, LLVMTypeRef llvm_type, isize alignment, return val; } -lbValue lb_zero(lbModule *m, Type *t) { +gb_internal lbValue lb_zero(lbModule *m, Type *t) { lbValue v = {}; v.value = LLVMConstInt(lb_type(m, t), 0, false); v.type = t; return v; } -LLVMValueRef llvm_cstring(lbModule *m, String const &str) { +gb_internal LLVMValueRef llvm_cstring(lbModule *m, String const &str) { lbValue v = lb_find_or_add_entity_string(m, str); unsigned indices[1] = {0}; return LLVMConstExtractValue(v.value, indices, gb_count_of(indices)); } -bool lb_is_instr_terminating(LLVMValueRef instr) { +gb_internal bool lb_is_instr_terminating(LLVMValueRef instr) { if (instr != nullptr) { LLVMOpcode op = LLVMGetInstructionOpcode(instr); switch (op) { @@ -320,18 +334,51 @@ bool lb_is_instr_terminating(LLVMValueRef instr) { return false; } +gb_internal lbModule *lb_module_of_expr(lbGenerator *gen, Ast *expr) { + GB_ASSERT(expr != nullptr); + lbModule **found = nullptr; + AstFile *file = expr->file(); + if (file) { + found = map_get(&gen->modules, cast(void *)file); + if (found) { + return *found; + } + if (file->pkg) { + found = map_get(&gen->modules, cast(void *)file->pkg); + if (found) { + return *found; + } + } + } -lbModule *lb_pkg_module(lbGenerator *gen, AstPackage *pkg) { - auto *found = map_get(&gen->modules, pkg); - if (found) { - return *found; + return &gen->default_module; +} + +gb_internal lbModule *lb_module_of_entity(lbGenerator *gen, Entity *e) { + GB_ASSERT(e != nullptr); + lbModule **found = nullptr; + if (e->kind == Entity_Procedure && + e->decl_info && + e->decl_info->code_gen_module) { + return e->decl_info->code_gen_module; + } + if (e->file) { + found = map_get(&gen->modules, cast(void *)e->file); + if (found) { + return *found; + } + } + if (e->pkg) { + found = map_get(&gen->modules, cast(void *)e->pkg); + if (found) { + return *found; + } } return &gen->default_module; } - -lbAddr lb_addr(lbValue addr) { +gb_internal lbAddr lb_addr(lbValue addr) { lbAddr v = {lbAddr_Default, addr}; if (addr.type != nullptr && is_type_relative_pointer(type_deref(addr.type))) { GB_ASSERT(is_type_pointer(addr.type)); @@ -344,7 +391,7 @@ lbAddr lb_addr(lbValue addr) { } -lbAddr lb_addr_map(lbValue addr, lbValue map_key, Type *map_type, Type *map_result) { +gb_internal lbAddr lb_addr_map(lbValue addr, lbValue map_key, Type *map_type, Type *map_result) { GB_ASSERT(is_type_pointer(addr.type)); Type *mt = type_deref(addr.type); GB_ASSERT(is_type_map(mt)); @@ -357,14 +404,14 @@ lbAddr lb_addr_map(lbValue addr, lbValue map_key, Type *map_type, Type *map_resu } -lbAddr lb_addr_soa_variable(lbValue addr, lbValue index, Ast *index_expr) { +gb_internal lbAddr lb_addr_soa_variable(lbValue addr, lbValue index, Ast *index_expr) { lbAddr v = {lbAddr_SoaVariable, addr}; v.soa.index = index; v.soa.index_expr = index_expr; return v; } -lbAddr lb_addr_swizzle(lbValue addr, Type *array_type, u8 swizzle_count, u8 swizzle_indices[4]) { +gb_internal lbAddr lb_addr_swizzle(lbValue addr, Type *array_type, u8 swizzle_count, u8 swizzle_indices[4]) { GB_ASSERT(is_type_array(array_type)); GB_ASSERT(1 < swizzle_count && swizzle_count <= 4); lbAddr v = {lbAddr_Swizzle, addr}; @@ -374,7 +421,7 @@ lbAddr lb_addr_swizzle(lbValue addr, Type *array_type, u8 swizzle_count, u8 swiz return v; } -lbAddr lb_addr_swizzle_large(lbValue addr, Type *array_type, Slice const &swizzle_indices) { +gb_internal lbAddr lb_addr_swizzle_large(lbValue addr, Type *array_type, Slice const &swizzle_indices) { GB_ASSERT_MSG(is_type_array(array_type), "%s", type_to_string(array_type)); lbAddr v = {lbAddr_SwizzleLarge, addr}; v.swizzle_large.type = array_type; @@ -382,7 +429,7 @@ lbAddr lb_addr_swizzle_large(lbValue addr, Type *array_type, Slice const &s return v; } -Type *lb_addr_type(lbAddr const &addr) { +gb_internal Type *lb_addr_type(lbAddr const &addr) { if (addr.addr.value == nullptr) { return nullptr; } @@ -411,7 +458,7 @@ Type *lb_addr_type(lbAddr const &addr) { return type_deref(addr.addr.type); } -lbValue lb_addr_get_ptr(lbProcedure *p, lbAddr const &addr) { +gb_internal lbValue lb_addr_get_ptr(lbProcedure *p, lbAddr const &addr) { if (addr.addr.value == nullptr) { GB_PANIC("Illegal addr -> nullptr"); return {}; @@ -462,12 +509,12 @@ lbValue lb_addr_get_ptr(lbProcedure *p, lbAddr const &addr) { } -lbValue lb_build_addr_ptr(lbProcedure *p, Ast *expr) { +gb_internal lbValue lb_build_addr_ptr(lbProcedure *p, Ast *expr) { lbAddr addr = lb_build_addr(p, expr); return lb_addr_get_ptr(p, addr); } -void lb_emit_bounds_check(lbProcedure *p, Token token, lbValue index, lbValue len) { +gb_internal void lb_emit_bounds_check(lbProcedure *p, Token token, lbValue index, lbValue len) { if (build_context.no_bounds_check) { return; } @@ -475,6 +522,8 @@ void lb_emit_bounds_check(lbProcedure *p, Token token, lbValue index, lbValue le return; } + TEMPORARY_ALLOCATOR_GUARD(); + index = lb_emit_conv(p, index, t_int); len = lb_emit_conv(p, len, t_int); @@ -482,7 +531,7 @@ void lb_emit_bounds_check(lbProcedure *p, Token token, lbValue index, lbValue le lbValue line = lb_const_int(p->module, t_i32, token.pos.line); lbValue column = lb_const_int(p->module, t_i32, token.pos.column); - auto args = array_make(permanent_allocator(), 5); + auto args = array_make(temporary_allocator(), 5); args[0] = file; args[1] = line; args[2] = column; @@ -492,7 +541,7 @@ void lb_emit_bounds_check(lbProcedure *p, Token token, lbValue index, lbValue le lb_emit_runtime_call(p, "bounds_check_error", args); } -void lb_emit_matrix_bounds_check(lbProcedure *p, Token token, lbValue row_index, lbValue column_index, lbValue row_count, lbValue column_count) { +gb_internal void lb_emit_matrix_bounds_check(lbProcedure *p, Token token, lbValue row_index, lbValue column_index, lbValue row_count, lbValue column_count) { if (build_context.no_bounds_check) { return; } @@ -500,6 +549,8 @@ void lb_emit_matrix_bounds_check(lbProcedure *p, Token token, lbValue row_index, return; } + TEMPORARY_ALLOCATOR_GUARD(); + row_index = lb_emit_conv(p, row_index, t_int); column_index = lb_emit_conv(p, column_index, t_int); row_count = lb_emit_conv(p, row_count, t_int); @@ -509,7 +560,7 @@ void lb_emit_matrix_bounds_check(lbProcedure *p, Token token, lbValue row_index, lbValue line = lb_const_int(p->module, t_i32, token.pos.line); lbValue column = lb_const_int(p->module, t_i32, token.pos.column); - auto args = array_make(permanent_allocator(), 7); + auto args = array_make(temporary_allocator(), 7); args[0] = file; args[1] = line; args[2] = column; @@ -522,7 +573,7 @@ void lb_emit_matrix_bounds_check(lbProcedure *p, Token token, lbValue row_index, } -void lb_emit_multi_pointer_slice_bounds_check(lbProcedure *p, Token token, lbValue low, lbValue high) { +gb_internal void lb_emit_multi_pointer_slice_bounds_check(lbProcedure *p, Token token, lbValue low, lbValue high) { if (build_context.no_bounds_check) { return; } @@ -547,7 +598,7 @@ void lb_emit_multi_pointer_slice_bounds_check(lbProcedure *p, Token token, lbVal lb_emit_runtime_call(p, "multi_pointer_slice_expr_error", args); } -void lb_emit_slice_bounds_check(lbProcedure *p, Token token, lbValue low, lbValue high, lbValue len, bool lower_value_used) { +gb_internal void lb_emit_slice_bounds_check(lbProcedure *p, Token token, lbValue low, lbValue high, lbValue len, bool lower_value_used) { if (build_context.no_bounds_check) { return; } @@ -585,14 +636,14 @@ void lb_emit_slice_bounds_check(lbProcedure *p, Token token, lbValue low, lbValu } } -unsigned lb_try_get_alignment(LLVMValueRef addr_ptr, unsigned default_alignment) { +gb_internal unsigned lb_try_get_alignment(LLVMValueRef addr_ptr, unsigned default_alignment) { if (LLVMIsAGlobalValue(addr_ptr) || LLVMIsAAllocaInst(addr_ptr) || LLVMIsALoadInst(addr_ptr)) { return LLVMGetAlignment(addr_ptr); } return default_alignment; } -bool lb_try_update_alignment(LLVMValueRef addr_ptr, unsigned alignment) { +gb_internal bool lb_try_update_alignment(LLVMValueRef addr_ptr, unsigned alignment) { if (LLVMIsAGlobalValue(addr_ptr) || LLVMIsAAllocaInst(addr_ptr) || LLVMIsALoadInst(addr_ptr)) { if (LLVMGetAlignment(addr_ptr) < alignment) { if (LLVMIsAAllocaInst(addr_ptr) || LLVMIsAGlobalValue(addr_ptr)) { @@ -604,15 +655,15 @@ bool lb_try_update_alignment(LLVMValueRef addr_ptr, unsigned alignment) { return false; } -bool lb_try_update_alignment(lbValue ptr, unsigned alignment) { +gb_internal bool lb_try_update_alignment(lbValue ptr, unsigned alignment) { return lb_try_update_alignment(ptr.value, alignment); } -bool lb_can_try_to_inline_array_arith(Type *t) { +gb_internal bool lb_can_try_to_inline_array_arith(Type *t) { return type_size_of(t) <= build_context.max_simd_align; } -bool lb_try_vector_cast(lbModule *m, lbValue ptr, LLVMTypeRef *vector_type_) { +gb_internal bool lb_try_vector_cast(lbModule *m, lbValue ptr, LLVMTypeRef *vector_type_) { Type *array_type = base_type(type_deref(ptr.type)); GB_ASSERT(is_type_array_like(array_type)); i64 count = get_array_type_count(array_type); @@ -647,12 +698,12 @@ bool lb_try_vector_cast(lbModule *m, lbValue ptr, LLVMTypeRef *vector_type_) { return false; } -void lb_addr_store(lbProcedure *p, lbAddr addr, lbValue value) { +gb_internal void lb_addr_store(lbProcedure *p, lbAddr addr, lbValue value) { if (addr.addr.value == nullptr) { return; } GB_ASSERT(value.type != nullptr); - if (is_type_untyped_undef(value.type)) { + if (is_type_untyped_uninit(value.type)) { Type *t = lb_addr_type(addr); value.type = t; value.value = LLVMGetUndef(lb_type(p->module, t)); @@ -874,15 +925,7 @@ void lb_addr_store(lbProcedure *p, lbAddr addr, lbValue value) { lb_emit_store(p, addr.addr, value); } -void lb_const_store(lbValue ptr, lbValue value) { - GB_ASSERT(lb_is_const(ptr)); - GB_ASSERT(lb_is_const(value)); - GB_ASSERT(is_type_pointer(ptr.type)); - LLVMSetInitializer(ptr.value, value.value); -} - - -bool lb_is_type_proc_recursive(Type *t) { +gb_internal bool lb_is_type_proc_recursive(Type *t) { for (;;) { if (t == nullptr) { return false; @@ -902,7 +945,7 @@ bool lb_is_type_proc_recursive(Type *t) { } } -void lb_emit_store(lbProcedure *p, lbValue ptr, lbValue value) { +gb_internal void lb_emit_store(lbProcedure *p, lbValue ptr, lbValue value) { GB_ASSERT(value.value != nullptr); Type *a = type_deref(ptr.type); @@ -931,7 +974,7 @@ void lb_emit_store(lbProcedure *p, lbValue ptr, lbValue value) { enum {MAX_STORE_SIZE = 64}; if (lb_sizeof(LLVMTypeOf(value.value)) > MAX_STORE_SIZE) { - if (LLVMIsALoadInst(value.value)) { + if (!p->in_multi_assignment && LLVMIsALoadInst(value.value)) { LLVMValueRef dst_ptr = ptr.value; LLVMValueRef src_ptr_original = LLVMGetOperand(value.value, 0); LLVMValueRef src_ptr = LLVMBuildPointerCast(p->builder, src_ptr_original, LLVMTypeOf(dst_ptr), ""); @@ -957,15 +1000,16 @@ void lb_emit_store(lbProcedure *p, lbValue ptr, lbValue value) { } } + LLVMValueRef instr = nullptr; if (lb_is_type_proc_recursive(a)) { // NOTE(bill, 2020-11-11): Because of certain LLVM rules, a procedure value may be // stored as regular pointer with no procedure information LLVMTypeRef rawptr_type = lb_type(p->module, t_rawptr); LLVMTypeRef rawptr_ptr_type = LLVMPointerType(rawptr_type, 0); - LLVMBuildStore(p->builder, - LLVMBuildPointerCast(p->builder, value.value, rawptr_type, ""), - LLVMBuildPointerCast(p->builder, ptr.value, rawptr_ptr_type, "")); + instr = LLVMBuildStore(p->builder, + LLVMBuildPointerCast(p->builder, value.value, rawptr_type, ""), + LLVMBuildPointerCast(p->builder, ptr.value, rawptr_ptr_type, "")); } else { Type *ca = core_type(a); if (ca->kind == Type_Basic || ca->kind == Type_Proc) { @@ -974,15 +1018,16 @@ void lb_emit_store(lbProcedure *p, lbValue ptr, lbValue value) { GB_ASSERT_MSG(are_types_identical(a, value.type), "%s != %s", type_to_string(a), type_to_string(value.type)); } - LLVMBuildStore(p->builder, value.value, ptr.value); + instr = LLVMBuildStore(p->builder, value.value, ptr.value); } + // LLVMSetVolatile(instr, p->in_multi_assignment); } -LLVMTypeRef llvm_addr_type(lbModule *module, lbValue addr_val) { +gb_internal LLVMTypeRef llvm_addr_type(lbModule *module, lbValue addr_val) { return lb_type(module, type_deref(addr_val.type)); } -lbValue lb_emit_load(lbProcedure *p, lbValue value) { +gb_internal lbValue lb_emit_load(lbProcedure *p, lbValue value) { GB_ASSERT(value.value != nullptr); if (is_type_multi_pointer(value.type)) { Type *vt = base_type(value.type); @@ -1003,7 +1048,7 @@ lbValue lb_emit_load(lbProcedure *p, lbValue value) { return lbValue{v, t}; } -lbValue lb_addr_load(lbProcedure *p, lbAddr const &addr) { +gb_internal lbValue lb_addr_load(lbProcedure *p, lbAddr const &addr) { GB_ASSERT(addr.addr.value != nullptr); @@ -1243,11 +1288,11 @@ lbValue lb_addr_load(lbProcedure *p, lbAddr const &addr) { return lb_emit_load(p, addr.addr); } -lbValue lb_const_union_tag(lbModule *m, Type *u, Type *v) { +gb_internal lbValue lb_const_union_tag(lbModule *m, Type *u, Type *v) { return lb_const_value(m, union_tag_type(u), exact_value_i64(union_variant_index(u, v))); } -lbValue lb_emit_union_tag_ptr(lbProcedure *p, lbValue u) { +gb_internal lbValue lb_emit_union_tag_ptr(lbProcedure *p, lbValue u) { Type *t = u.type; GB_ASSERT_MSG(is_type_pointer(t) && is_type_union(type_deref(t)), "%s", type_to_string(t)); @@ -1269,14 +1314,14 @@ lbValue lb_emit_union_tag_ptr(lbProcedure *p, lbValue u) { return tag_ptr; } -lbValue lb_emit_union_tag_value(lbProcedure *p, lbValue u) { +gb_internal lbValue lb_emit_union_tag_value(lbProcedure *p, lbValue u) { lbValue ptr = lb_address_from_load_or_generate_local(p, u); lbValue tag_ptr = lb_emit_union_tag_ptr(p, ptr); return lb_emit_load(p, tag_ptr); } -void lb_emit_store_union_variant_tag(lbProcedure *p, lbValue parent, Type *variant_type) { +gb_internal void lb_emit_store_union_variant_tag(lbProcedure *p, lbValue parent, Type *variant_type) { Type *t = type_deref(parent.type); if (is_type_union_maybe_pointer(t) || type_size_of(t) == 0) { @@ -1287,7 +1332,7 @@ void lb_emit_store_union_variant_tag(lbProcedure *p, lbValue parent, Type *varia } } -void lb_emit_store_union_variant(lbProcedure *p, lbValue parent, lbValue variant, Type *variant_type) { +gb_internal void lb_emit_store_union_variant(lbProcedure *p, lbValue parent, lbValue variant, Type *variant_type) { Type *pt = base_type(type_deref(parent.type)); GB_ASSERT(pt->kind == Type_Union); if (pt->Union.kind == UnionType_shared_nil) { @@ -1320,29 +1365,15 @@ void lb_emit_store_union_variant(lbProcedure *p, lbValue parent, lbValue variant } -void lb_clone_struct_type(LLVMTypeRef dst, LLVMTypeRef src) { +gb_internal void lb_clone_struct_type(LLVMTypeRef dst, LLVMTypeRef src) { + TEMPORARY_ALLOCATOR_GUARD(); unsigned field_count = LLVMCountStructElementTypes(src); LLVMTypeRef *fields = gb_alloc_array(temporary_allocator(), LLVMTypeRef, field_count); LLVMGetStructElementTypes(src, fields); LLVMStructSetBody(dst, fields, field_count, LLVMIsPackedStruct(src)); } -LLVMTypeRef lb_alignment_prefix_type_hack(lbModule *m, i64 alignment) { - switch (alignment) { - case 1: - return LLVMArrayType(lb_type(m, t_u8), 0); - case 2: - return LLVMArrayType(lb_type(m, t_u16), 0); - case 4: - return LLVMArrayType(lb_type(m, t_u32), 0); - case 8: - return LLVMArrayType(lb_type(m, t_u64), 0); - default: case 16: - return LLVMArrayType(LLVMVectorType(lb_type(m, t_u32), 4), 0); - } -} - -String lb_mangle_name(lbModule *m, Entity *e) { +gb_internal String lb_mangle_name(lbModule *m, Entity *e) { String name = e->token.string; AstPackage *pkg = e->pkg; @@ -1384,7 +1415,7 @@ String lb_mangle_name(lbModule *m, Entity *e) { return mangled_name; } -String lb_set_nested_type_name_ir_mangled_name(Entity *e, lbProcedure *p) { +gb_internal String lb_set_nested_type_name_ir_mangled_name(Entity *e, lbProcedure *p, lbModule *module) { // NOTE(bill, 2020-03-08): A polymorphic procedure may take a nested type declaration // and as a result, the declaration does not have time to determine what it should be @@ -1420,7 +1451,7 @@ String lb_set_nested_type_name_ir_mangled_name(Entity *e, lbProcedure *p) { if (p != nullptr) { isize name_len = p->name.len + 1 + ts_name.len + 1 + 10 + 1; char *name_text = gb_alloc_array(permanent_allocator(), char, name_len); - u32 guid = ++p->module->nested_type_name_guid; + u32 guid = 1+p->module->nested_type_name_guid.fetch_add(1); name_len = gb_snprintf(name_text, name_len, "%.*s.%.*s-%u", LIT(p->name), LIT(ts_name), guid); String name = make_string(cast(u8 *)name_text, name_len-1); @@ -1430,9 +1461,8 @@ String lb_set_nested_type_name_ir_mangled_name(Entity *e, lbProcedure *p) { // NOTE(bill): a nested type be required before its parameter procedure exists. Just give it a temp name for now isize name_len = 9 + 1 + ts_name.len + 1 + 10 + 1; char *name_text = gb_alloc_array(permanent_allocator(), char, name_len); - static u32 guid = 0; - guid += 1; - name_len = gb_snprintf(name_text, name_len, "_internal.%.*s-%u", LIT(ts_name), guid); + static std::atomic guid; + name_len = gb_snprintf(name_text, name_len, "_internal.%.*s-%u", LIT(ts_name), 1+guid.fetch_add(1)); String name = make_string(cast(u8 *)name_text, name_len-1); e->TypeName.ir_mangled_name = name; @@ -1440,7 +1470,7 @@ String lb_set_nested_type_name_ir_mangled_name(Entity *e, lbProcedure *p) { } } -String lb_get_entity_name(lbModule *m, Entity *e, String default_name) { +gb_internal String lb_get_entity_name(lbModule *m, Entity *e, String default_name) { if (e != nullptr && e->kind == Entity_TypeName && e->TypeName.ir_mangled_name.len != 0) { return e->TypeName.ir_mangled_name; } @@ -1451,7 +1481,7 @@ String lb_get_entity_name(lbModule *m, Entity *e, String default_name) { } if (e->kind == Entity_TypeName && (e->scope->flags & ScopeFlag_File) == 0) { - return lb_set_nested_type_name_ir_mangled_name(e, nullptr); + return lb_set_nested_type_name_ir_mangled_name(e, nullptr, m); } String name = {}; @@ -1488,11 +1518,14 @@ String lb_get_entity_name(lbModule *m, Entity *e, String default_name) { } -LLVMTypeRef lb_type_internal_for_procedures_raw(lbModule *m, Type *type) { +gb_internal LLVMTypeRef lb_type_internal_for_procedures_raw(lbModule *m, Type *type) { Type *original_type = type; type = base_type(original_type); GB_ASSERT(type->kind == Type_Proc); + mutex_lock(&m->func_raw_types_mutex); + defer (mutex_unlock(&m->func_raw_types_mutex)); + LLVMTypeRef *found = map_get(&m->func_raw_types, type); if (found) { return *found; @@ -1571,7 +1604,7 @@ LLVMTypeRef lb_type_internal_for_procedures_raw(lbModule *m, Type *type) { } } GB_ASSERT(param_index == param_count); - lbFunctionType *ft = lb_get_abi_info(m->ctx, params, param_count, ret, ret != nullptr, return_is_tuple, type->Proc.calling_convention); + lbFunctionType *ft = lb_get_abi_info(m->ctx, params, param_count, ret, ret != nullptr, return_is_tuple, type->Proc.calling_convention, type); { for_array(j, ft->args) { auto arg = ft->args[j]; @@ -1592,6 +1625,10 @@ LLVMTypeRef lb_type_internal_for_procedures_raw(lbModule *m, Type *type) { if (params_by_ptr[i]) { // NOTE(bill): The parameter needs to be passed "indirectly", override it ft->args[i].kind = lbArg_Indirect; + ft->args[i].attribute = nullptr; + ft->args[i].align_attribute = nullptr; + ft->args[i].byval_alignment = 0; + ft->args[i].is_byval = false; } } @@ -1607,13 +1644,15 @@ LLVMTypeRef lb_type_internal_for_procedures_raw(lbModule *m, Type *type) { return new_abi_fn_type; } -LLVMTypeRef lb_type_internal(lbModule *m, Type *type) { +gb_internal LLVMTypeRef lb_type_internal(lbModule *m, Type *type) { LLVMContextRef ctx = m->ctx; i64 size = type_size_of(type); // Check size gb_unused(size); GB_ASSERT(type != t_invalid); + bool bigger_int = build_context.ptr_size != build_context.int_size; + switch (type->kind) { case Type_Basic: switch (type->Basic.kind) { @@ -1748,10 +1787,10 @@ LLVMTypeRef lb_type_internal(lbModule *m, Type *type) { return type; } - case Basic_int: return LLVMIntTypeInContext(ctx, 8*cast(unsigned)build_context.word_size); - case Basic_uint: return LLVMIntTypeInContext(ctx, 8*cast(unsigned)build_context.word_size); + case Basic_int: return LLVMIntTypeInContext(ctx, 8*cast(unsigned)build_context.int_size); + case Basic_uint: return LLVMIntTypeInContext(ctx, 8*cast(unsigned)build_context.int_size); - case Basic_uintptr: return LLVMIntTypeInContext(ctx, 8*cast(unsigned)build_context.word_size); + case Basic_uintptr: return LLVMIntTypeInContext(ctx, 8*cast(unsigned)build_context.ptr_size); case Basic_rawptr: return LLVMPointerType(LLVMInt8TypeInContext(ctx), 0); case Basic_string: @@ -1762,11 +1801,23 @@ LLVMTypeRef lb_type_internal(lbModule *m, Type *type) { return type; } type = LLVMStructCreateNamed(ctx, name); - LLVMTypeRef fields[2] = { - LLVMPointerType(lb_type(m, t_u8), 0), - lb_type(m, t_int), - }; - LLVMStructSetBody(type, fields, 2, false); + + if (build_context.metrics.ptr_size < build_context.metrics.int_size) { + GB_ASSERT(build_context.metrics.ptr_size == 4); + GB_ASSERT(build_context.metrics.int_size == 8); + LLVMTypeRef fields[3] = { + LLVMPointerType(lb_type(m, t_u8), 0), + lb_type(m, t_i32), + lb_type(m, t_int), + }; + LLVMStructSetBody(type, fields, 3, false); + } else { + LLVMTypeRef fields[2] = { + LLVMPointerType(lb_type(m, t_u8), 0), + lb_type(m, t_int), + }; + LLVMStructSetBody(type, fields, 2, false); + } return type; } case Basic_cstring: return LLVMPointerType(LLVMInt8TypeInContext(ctx), 0); @@ -1786,7 +1837,7 @@ LLVMTypeRef lb_type_internal(lbModule *m, Type *type) { return type; } - case Basic_typeid: return LLVMIntTypeInContext(m->ctx, 8*cast(unsigned)build_context.word_size); + case Basic_typeid: return LLVMIntTypeInContext(m->ctx, 8*cast(unsigned)build_context.ptr_size); // Endian Specific Types case Basic_i16le: return LLVMInt16TypeInContext(ctx); @@ -1816,7 +1867,7 @@ LLVMTypeRef lb_type_internal(lbModule *m, Type *type) { case Basic_UntypedString: GB_PANIC("Basic_UntypedString"); break; case Basic_UntypedRune: GB_PANIC("Basic_UntypedRune"); break; case Basic_UntypedNil: GB_PANIC("Basic_UntypedNil"); break; - case Basic_UntypedUndef: GB_PANIC("Basic_UntypedUndef"); break; + case Basic_UntypedUninit: GB_PANIC("Basic_UntypedUninit"); break; } break; case Type_Named: @@ -1910,23 +1961,43 @@ LLVMTypeRef lb_type_internal(lbModule *m, Type *type) { case Type_Slice: { - LLVMTypeRef fields[2] = { - LLVMPointerType(lb_type(m, type->Slice.elem), 0), // data - lb_type(m, t_int), // len - }; - return LLVMStructTypeInContext(ctx, fields, 2, false); + if (bigger_int) { + LLVMTypeRef fields[3] = { + LLVMPointerType(lb_type(m, type->Slice.elem), 0), // data + lb_type_padding_filler(m, build_context.ptr_size, build_context.ptr_size), // padding + lb_type(m, t_int), // len + }; + return LLVMStructTypeInContext(ctx, fields, gb_count_of(fields), false); + } else { + LLVMTypeRef fields[2] = { + LLVMPointerType(lb_type(m, type->Slice.elem), 0), // data + lb_type(m, t_int), // len + }; + return LLVMStructTypeInContext(ctx, fields, gb_count_of(fields), false); + } } break; case Type_DynamicArray: { - LLVMTypeRef fields[4] = { - LLVMPointerType(lb_type(m, type->DynamicArray.elem), 0), // data - lb_type(m, t_int), // len - lb_type(m, t_int), // cap - lb_type(m, t_allocator), // allocator - }; - return LLVMStructTypeInContext(ctx, fields, 4, false); + if (bigger_int) { + LLVMTypeRef fields[5] = { + LLVMPointerType(lb_type(m, type->DynamicArray.elem), 0), // data + lb_type_padding_filler(m, build_context.ptr_size, build_context.ptr_size), // padding + lb_type(m, t_int), // len + lb_type(m, t_int), // cap + lb_type(m, t_allocator), // allocator + }; + return LLVMStructTypeInContext(ctx, fields, gb_count_of(fields), false); + } else { + LLVMTypeRef fields[4] = { + LLVMPointerType(lb_type(m, type->DynamicArray.elem), 0), // data + lb_type(m, t_int), // len + lb_type(m, t_int), // cap + lb_type(m, t_allocator), // allocator + }; + return LLVMStructTypeInContext(ctx, fields, gb_count_of(fields), false); + } } break; @@ -2133,9 +2204,17 @@ LLVMTypeRef lb_type_internal(lbModule *m, Type *type) { case Type_SoaPointer: { unsigned field_count = 2; + if (bigger_int) { + field_count = 3; + } LLVMTypeRef *fields = gb_alloc_array(permanent_allocator(), LLVMTypeRef, field_count); fields[0] = LLVMPointerType(lb_type(m, type->Pointer.elem), 0); - fields[1] = LLVMIntTypeInContext(ctx, 8*cast(unsigned)build_context.word_size); + if (bigger_int) { + fields[1] = lb_type_padding_filler(m, build_context.ptr_size, build_context.ptr_size); + fields[2] = LLVMIntTypeInContext(ctx, 8*cast(unsigned)build_context.int_size); + } else { + fields[1] = LLVMIntTypeInContext(ctx, 8*cast(unsigned)build_context.int_size); + } return LLVMStructTypeInContext(ctx, fields, field_count, false); } @@ -2145,9 +2224,12 @@ LLVMTypeRef lb_type_internal(lbModule *m, Type *type) { return LLVMInt32TypeInContext(ctx); } -LLVMTypeRef lb_type(lbModule *m, Type *type) { +gb_internal LLVMTypeRef lb_type(lbModule *m, Type *type) { type = default_type(type); + mutex_lock(&m->types_mutex); + defer (mutex_unlock(&m->types_mutex)); + LLVMTypeRef *found = map_get(&m->types, type); if (found) { return *found; @@ -2164,7 +2246,7 @@ LLVMTypeRef lb_type(lbModule *m, Type *type) { return llvm_type; } -lbFunctionType *lb_get_function_type(lbModule *m, Type *pt) { +gb_internal lbFunctionType *lb_get_function_type(lbModule *m, Type *pt) { lbFunctionType **ft_found = nullptr; ft_found = map_get(&m->function_type_map, pt); if (!ft_found) { @@ -2177,7 +2259,7 @@ lbFunctionType *lb_get_function_type(lbModule *m, Type *pt) { return *ft_found; } -void lb_ensure_abi_function_type(lbModule *m, lbProcedure *p) { +gb_internal void lb_ensure_abi_function_type(lbModule *m, lbProcedure *p) { if (p->abi_function_type != nullptr) { return; } @@ -2192,29 +2274,32 @@ void lb_ensure_abi_function_type(lbModule *m, lbProcedure *p) { GB_ASSERT(p->abi_function_type != nullptr); } -void lb_add_entity(lbModule *m, Entity *e, lbValue val) { +gb_internal void lb_add_entity(lbModule *m, Entity *e, lbValue val) { if (e != nullptr) { + rw_mutex_lock(&m->values_mutex); map_set(&m->values, e, val); + rw_mutex_unlock(&m->values_mutex); } } -void lb_add_member(lbModule *m, String const &name, lbValue val) { +gb_internal void lb_add_member(lbModule *m, String const &name, lbValue val) { if (name.len > 0) { + rw_mutex_lock(&m->values_mutex); string_map_set(&m->members, name, val); + rw_mutex_unlock(&m->values_mutex); } } -void lb_add_member(lbModule *m, StringHashKey const &key, lbValue val) { - string_map_set(&m->members, key, val); -} -void lb_add_procedure_value(lbModule *m, lbProcedure *p) { +gb_internal void lb_add_procedure_value(lbModule *m, lbProcedure *p) { + rw_mutex_lock(&m->values_mutex); if (p->entity != nullptr) { map_set(&m->procedure_values, p->value, p->entity); } string_map_set(&m->procedures, p->name, p); + rw_mutex_unlock(&m->values_mutex); } -LLVMAttributeRef lb_create_enum_attribute_with_type(LLVMContextRef ctx, char const *name, LLVMTypeRef type) { +gb_internal LLVMAttributeRef lb_create_enum_attribute_with_type(LLVMContextRef ctx, char const *name, LLVMTypeRef type) { unsigned kind = 0; String s = make_string_c(name); @@ -2243,7 +2328,7 @@ LLVMAttributeRef lb_create_enum_attribute_with_type(LLVMContextRef ctx, char con #endif } -LLVMAttributeRef lb_create_enum_attribute(LLVMContextRef ctx, char const *name, u64 value) { +gb_internal LLVMAttributeRef lb_create_enum_attribute(LLVMContextRef ctx, char const *name, u64 value) { String s = make_string_c(name); // NOTE(2021-02-25, bill); All this attributes require a type associated with them @@ -2264,23 +2349,23 @@ LLVMAttributeRef lb_create_enum_attribute(LLVMContextRef ctx, char const *name, return LLVMCreateEnumAttribute(ctx, kind, value); } -void lb_add_proc_attribute_at_index(lbProcedure *p, isize index, char const *name, u64 value) { +gb_internal void lb_add_proc_attribute_at_index(lbProcedure *p, isize index, char const *name, u64 value) { LLVMAttributeRef attr = lb_create_enum_attribute(p->module->ctx, name, value); GB_ASSERT(attr != nullptr); LLVMAddAttributeAtIndex(p->value, cast(unsigned)index, attr); } -void lb_add_proc_attribute_at_index(lbProcedure *p, isize index, char const *name) { +gb_internal void lb_add_proc_attribute_at_index(lbProcedure *p, isize index, char const *name) { lb_add_proc_attribute_at_index(p, index, name, 0); } -void lb_add_attribute_to_proc(lbModule *m, LLVMValueRef proc_value, char const *name, u64 value=0) { +gb_internal void lb_add_attribute_to_proc(lbModule *m, LLVMValueRef proc_value, char const *name, u64 value=0) { LLVMAddAttributeAtIndex(proc_value, LLVMAttributeIndex_FunctionIndex, lb_create_enum_attribute(m->ctx, name, value)); } -void lb_add_edge(lbBlock *from, lbBlock *to) { +gb_internal void lb_add_edge(lbBlock *from, lbBlock *to) { LLVMValueRef instr = LLVMGetLastInstruction(from->block); if (instr == nullptr || !LLVMIsATerminatorInst(instr)) { array_add(&from->succs, to); @@ -2289,7 +2374,7 @@ void lb_add_edge(lbBlock *from, lbBlock *to) { } -lbBlock *lb_create_block(lbProcedure *p, char const *name, bool append) { +gb_internal lbBlock *lb_create_block(lbProcedure *p, char const *name, bool append) { lbBlock *b = gb_alloc_item(permanent_allocator(), lbBlock); b->block = LLVMCreateBasicBlockInContext(p->module->ctx, name); b->appended = false; @@ -2309,7 +2394,7 @@ lbBlock *lb_create_block(lbProcedure *p, char const *name, bool append) { return b; } -void lb_emit_jump(lbProcedure *p, lbBlock *target_block) { +gb_internal void lb_emit_jump(lbProcedure *p, lbBlock *target_block) { if (p->curr_block == nullptr) { return; } @@ -2323,7 +2408,7 @@ void lb_emit_jump(lbProcedure *p, lbBlock *target_block) { p->curr_block = nullptr; } -void lb_emit_if(lbProcedure *p, lbValue cond, lbBlock *true_block, lbBlock *false_block) { +gb_internal void lb_emit_if(lbProcedure *p, lbValue cond, lbBlock *true_block, lbBlock *false_block) { lbBlock *b = p->curr_block; if (b == nullptr) { return; @@ -2342,20 +2427,20 @@ void lb_emit_if(lbProcedure *p, lbValue cond, lbBlock *true_block, lbBlock *fals } -gb_inline LLVMTypeRef OdinLLVMGetInternalElementType(LLVMTypeRef type) { +gb_internal gb_inline LLVMTypeRef OdinLLVMGetInternalElementType(LLVMTypeRef type) { return LLVMGetElementType(type); } -LLVMTypeRef OdinLLVMGetArrayElementType(LLVMTypeRef type) { +gb_internal LLVMTypeRef OdinLLVMGetArrayElementType(LLVMTypeRef type) { GB_ASSERT(lb_is_type_kind(type, LLVMArrayTypeKind)); return OdinLLVMGetInternalElementType(type); } -LLVMTypeRef OdinLLVMGetVectorElementType(LLVMTypeRef type) { +gb_internal LLVMTypeRef OdinLLVMGetVectorElementType(LLVMTypeRef type) { GB_ASSERT(lb_is_type_kind(type, LLVMVectorTypeKind)); return OdinLLVMGetInternalElementType(type); } -LLVMValueRef OdinLLVMBuildTransmute(lbProcedure *p, LLVMValueRef val, LLVMTypeRef dst_type) { +gb_internal LLVMValueRef OdinLLVMBuildTransmute(lbProcedure *p, LLVMValueRef val, LLVMTypeRef dst_type) { LLVMContextRef ctx = p->module->ctx; LLVMTypeRef src_type = LLVMTypeOf(val); @@ -2445,7 +2530,7 @@ general_end:; -LLVMValueRef lb_find_or_add_entity_string_ptr(lbModule *m, String const &str) { +gb_internal LLVMValueRef lb_find_or_add_entity_string_ptr(lbModule *m, String const &str) { StringHashKey key = string_hash_string(str); LLVMValueRef *found = string_map_get(&m->const_strings, key); if (found != nullptr) { @@ -2477,7 +2562,7 @@ LLVMValueRef lb_find_or_add_entity_string_ptr(lbModule *m, String const &str) { } } -lbValue lb_find_or_add_entity_string(lbModule *m, String const &str) { +gb_internal lbValue lb_find_or_add_entity_string(lbModule *m, String const &str) { LLVMValueRef ptr = nullptr; if (str.len != 0) { ptr = lb_find_or_add_entity_string_ptr(m, str); @@ -2485,51 +2570,14 @@ lbValue lb_find_or_add_entity_string(lbModule *m, String const &str) { ptr = LLVMConstNull(lb_type(m, t_u8_ptr)); } LLVMValueRef str_len = LLVMConstInt(lb_type(m, t_int), str.len, true); - LLVMValueRef values[2] = {ptr, str_len}; lbValue res = {}; - res.value = llvm_const_named_struct(m, t_string, values, 2); + res.value = llvm_const_string_internal(m, t_string, ptr, str_len); res.type = t_string; return res; } -lbValue lb_find_or_add_entity_string_byte_slice(lbModule *m, String const &str) { - LLVMValueRef indices[2] = {llvm_zero(m), llvm_zero(m)}; - LLVMValueRef data = LLVMConstStringInContext(m->ctx, - cast(char const *)str.text, - cast(unsigned)str.len, - false); - - - char *name = nullptr; - { - isize max_len = 7+8+1; - name = gb_alloc_array(permanent_allocator(), char, max_len); - u32 id = m->gen->global_array_index.fetch_add(1); - isize len = gb_snprintf(name, max_len, "csbs$%x", id); - len -= 1; - } - LLVMTypeRef type = LLVMTypeOf(data); - LLVMValueRef global_data = LLVMAddGlobal(m->mod, type, name); - LLVMSetInitializer(global_data, data); - lb_make_global_private_const(global_data); - LLVMSetAlignment(global_data, 1); - - LLVMValueRef ptr = nullptr; - if (str.len != 0) { - ptr = LLVMConstInBoundsGEP2(type, global_data, indices, 2); - } else { - ptr = LLVMConstNull(lb_type(m, t_u8_ptr)); - } - LLVMValueRef len = LLVMConstInt(lb_type(m, t_int), str.len, true); - LLVMValueRef values[2] = {ptr, len}; - - lbValue res = {}; - res.value = llvm_const_named_struct(m, t_u8_slice, values, 2); - res.type = t_u8_slice; - return res; -} -lbValue lb_find_or_add_entity_string_byte_slice_with_type(lbModule *m, String const &str, Type *slice_type) { +gb_internal lbValue lb_find_or_add_entity_string_byte_slice_with_type(lbModule *m, String const &str, Type *slice_type) { GB_ASSERT(is_type_slice(slice_type)); LLVMValueRef indices[2] = {llvm_zero(m), llvm_zero(m)}; LLVMValueRef data = LLVMConstStringInContext(m->ctx, @@ -2579,7 +2627,7 @@ lbValue lb_find_or_add_entity_string_byte_slice_with_type(lbModule *m, String co -lbValue lb_find_ident(lbProcedure *p, lbModule *m, Entity *e, Ast *expr) { +gb_internal lbValue lb_find_ident(lbProcedure *p, lbModule *m, Entity *e, Ast *expr) { if (e->flags & EntityFlag_Param) { // NOTE(bill): Bypass the stack copied variable for // direct parameters as there is no need for the direct load @@ -2589,8 +2637,13 @@ lbValue lb_find_ident(lbProcedure *p, lbModule *m, Entity *e, Ast *expr) { } } - auto *found = map_get(&m->values, e); + lbValue *found = nullptr; + rw_mutex_shared_lock(&m->values_mutex); + found = map_get(&m->values, e); + rw_mutex_shared_unlock(&m->values_mutex); + if (found) { + auto v = *found; // NOTE(bill): This is because pointers are already pointers in LLVM if (is_type_proc(v.type)) { @@ -2605,9 +2658,8 @@ lbValue lb_find_ident(lbProcedure *p, lbModule *m, Entity *e, Ast *expr) { return lb_find_procedure_value_from_entity(m, e); } if (USE_SEPARATE_MODULES) { - lbModule *other_module = lb_pkg_module(m->gen, e->pkg); + lbModule *other_module = lb_module_of_entity(m->gen, e); if (other_module != m) { - String name = lb_get_entity_name(other_module, e); lb_set_entity_from_other_modules_linkage_correctly(other_module, e, name); @@ -2633,12 +2685,18 @@ lbValue lb_find_ident(lbProcedure *p, lbModule *m, Entity *e, Ast *expr) { } -lbValue lb_find_procedure_value_from_entity(lbModule *m, Entity *e) { +gb_internal lbValue lb_find_procedure_value_from_entity(lbModule *m, Entity *e) { + lbGenerator *gen = m->gen; + GB_ASSERT(is_type_proc(e->type)); e = strip_entity_wrapping(e); GB_ASSERT(e != nullptr); + GB_ASSERT(e->kind == Entity_Procedure); - auto *found = map_get(&m->values, e); + lbValue *found = nullptr; + rw_mutex_shared_lock(&m->values_mutex); + found = map_get(&m->values, e); + rw_mutex_shared_unlock(&m->values_mutex); if (found) { return *found; } @@ -2647,15 +2705,28 @@ lbValue lb_find_procedure_value_from_entity(lbModule *m, Entity *e) { lbModule *other_module = m; if (USE_SEPARATE_MODULES) { - other_module = lb_pkg_module(m->gen, e->pkg); + other_module = lb_module_of_entity(gen, e); } if (other_module == m) { - debugf("Missing Procedure (lb_find_procedure_value_from_entity): %.*s\n", LIT(e->token.string)); + debugf("Missing Procedure (lb_find_procedure_value_from_entity): %.*s module %p\n", LIT(e->token.string), m); } ignore_body = other_module != m; lbProcedure *missing_proc = lb_create_procedure(m, e, ignore_body); - if (!ignore_body) { + if (ignore_body) { + mutex_lock(&gen->anonymous_proc_lits_mutex); + defer (mutex_unlock(&gen->anonymous_proc_lits_mutex)); + + GB_ASSERT(other_module != nullptr); + rw_mutex_shared_lock(&other_module->values_mutex); + auto *found = map_get(&other_module->values, e); + rw_mutex_shared_unlock(&other_module->values_mutex); + if (found == nullptr) { + // THIS IS THE RACE CONDITION + lbProcedure *missing_proc_in_other_module = lb_create_procedure(other_module, e, false); + array_add(&other_module->missing_procedures_to_check, missing_proc_in_other_module); + } + } else { array_add(&m->missing_procedures_to_check, missing_proc); } found = map_get(&m->values, e); @@ -2668,7 +2739,64 @@ lbValue lb_find_procedure_value_from_entity(lbModule *m, Entity *e) { } -lbAddr lb_add_global_generated(lbModule *m, Type *type, lbValue value, Entity **entity_) { + +gb_internal lbValue lb_generate_anonymous_proc_lit(lbModule *m, String const &prefix_name, Ast *expr, lbProcedure *parent) { + lbGenerator *gen = m->gen; + + mutex_lock(&gen->anonymous_proc_lits_mutex); + defer (mutex_unlock(&gen->anonymous_proc_lits_mutex)); + + TokenPos pos = ast_token(expr).pos; + lbProcedure **found = map_get(&gen->anonymous_proc_lits, expr); + if (found) { + return lb_find_procedure_value_from_entity(m, (*found)->entity); + } + + ast_node(pl, ProcLit, expr); + + // NOTE(bill): Generate a new name + // parent$count + isize name_len = prefix_name.len + 6 + 11; + char *name_text = gb_alloc_array(permanent_allocator(), char, name_len); + static std::atomic name_id; + name_len = gb_snprintf(name_text, name_len, "%.*s$anon-%d", LIT(prefix_name), 1+name_id.fetch_add(1)); + String name = make_string((u8 *)name_text, name_len-1); + + Type *type = type_of_expr(expr); + + GB_ASSERT(pl->decl->entity == nullptr); + Token token = {}; + token.pos = ast_token(expr).pos; + token.kind = Token_Ident; + token.string = name; + Entity *e = alloc_entity_procedure(nullptr, token, type, pl->tags); + e->file = expr->file(); + + // NOTE(bill): this is to prevent a race condition since these procedure literals can be created anywhere at any time + pl->decl->code_gen_module = m; + e->decl_info = pl->decl; + pl->decl->entity = e; + e->flags |= EntityFlag_ProcBodyChecked; + + lbProcedure *p = lb_create_procedure(m, e); + GB_ASSERT(e->code_gen_module == m); + + lbValue value = {}; + value.value = p->value; + value.type = p->type; + + map_set(&gen->anonymous_proc_lits, expr, p); + array_add(&m->procedures_to_generate, p); + if (parent != nullptr) { + array_add(&parent->children, p); + } else { + string_map_set(&m->members, name, value); + } + return value; +} + + +gb_internal lbAddr lb_add_global_generated(lbModule *m, Type *type, lbValue value, Entity **entity_) { GB_ASSERT(type != nullptr); type = default_type(type); @@ -2700,23 +2828,23 @@ lbAddr lb_add_global_generated(lbModule *m, Type *type, lbValue value, Entity ** return lb_addr(g); } -lbValue lb_find_runtime_value(lbModule *m, String const &name) { +gb_internal lbValue lb_find_runtime_value(lbModule *m, String const &name) { AstPackage *p = m->info->runtime_package; Entity *e = scope_lookup_current(p->scope, name); return lb_find_value_from_entity(m, e); } -lbValue lb_find_package_value(lbModule *m, String const &pkg, String const &name) { +gb_internal lbValue lb_find_package_value(lbModule *m, String const &pkg, String const &name) { Entity *e = find_entity_in_pkg(m->info, pkg, name); return lb_find_value_from_entity(m, e); } -lbValue lb_generate_local_array(lbProcedure *p, Type *elem_type, i64 count, bool zero_init) { +gb_internal lbValue lb_generate_local_array(lbProcedure *p, Type *elem_type, i64 count, bool zero_init) { lbAddr addr = lb_add_local_generated(p, alloc_type_array(elem_type, count), zero_init); return lb_addr_get_ptr(p, addr); } -lbValue lb_find_value_from_entity(lbModule *m, Entity *e) { +gb_internal lbValue lb_find_value_from_entity(lbModule *m, Entity *e) { e = strip_entity_wrapping(e); GB_ASSERT(e != nullptr); @@ -2726,13 +2854,16 @@ lbValue lb_find_value_from_entity(lbModule *m, Entity *e) { return lb_find_procedure_value_from_entity(m, e); } - auto *found = map_get(&m->values, e); + lbValue *found = nullptr; + rw_mutex_shared_lock(&m->values_mutex); + found = map_get(&m->values, e); + rw_mutex_shared_unlock(&m->values_mutex); if (found) { return *found; } if (USE_SEPARATE_MODULES) { - lbModule *other_module = lb_pkg_module(m->gen, e->pkg); + lbModule *other_module = lb_module_of_entity(m->gen, e); // TODO(bill): correct this logic bool is_external = other_module != m; @@ -2783,12 +2914,11 @@ lbValue lb_find_value_from_entity(lbModule *m, Entity *e) { return g; } } - GB_PANIC("\n\tError in: %s, missing value '%.*s'\n", token_pos_to_string(e->token.pos), LIT(e->token.string)); return {}; } -lbValue lb_generate_global_array(lbModule *m, Type *elem_type, i64 count, String prefix, i64 id) { +gb_internal lbValue lb_generate_global_array(lbModule *m, Type *elem_type, i64 count, String prefix, i64 id) { Token token = {Token_Ident}; isize name_len = prefix.len + 1 + 20; @@ -2813,7 +2943,7 @@ lbValue lb_generate_global_array(lbModule *m, Type *elem_type, i64 count, String -lbValue lb_build_cond(lbProcedure *p, Ast *cond, lbBlock *true_block, lbBlock *false_block) { +gb_internal lbValue lb_build_cond(lbProcedure *p, Ast *cond, lbBlock *true_block, lbBlock *false_block) { GB_ASSERT(cond != nullptr); GB_ASSERT(true_block != nullptr); GB_ASSERT(false_block != nullptr); @@ -2868,7 +2998,7 @@ lbValue lb_build_cond(lbProcedure *p, Ast *cond, lbBlock *true_block, lbBlock *f } -lbAddr lb_add_local(lbProcedure *p, Type *type, Entity *e, bool zero_init, bool force_no_init) { +gb_internal lbAddr lb_add_local(lbProcedure *p, Type *type, Entity *e, bool zero_init, bool force_no_init) { GB_ASSERT(p->decl_block != p->curr_block); LLVMPositionBuilderAtEnd(p->builder, p->decl_block->block); @@ -2917,18 +3047,18 @@ lbAddr lb_add_local(lbProcedure *p, Type *type, Entity *e, bool zero_init, bool return lb_addr(val); } -lbAddr lb_add_local_generated(lbProcedure *p, Type *type, bool zero_init) { +gb_internal lbAddr lb_add_local_generated(lbProcedure *p, Type *type, bool zero_init) { return lb_add_local(p, type, nullptr, zero_init); } -lbAddr lb_add_local_generated_temp(lbProcedure *p, Type *type, i64 min_alignment) { +gb_internal lbAddr lb_add_local_generated_temp(lbProcedure *p, Type *type, i64 min_alignment) { lbAddr res = lb_add_local(p, type, nullptr, false, true); lb_try_update_alignment(res.addr, cast(unsigned)min_alignment); return res; } -void lb_set_linkage_from_entity_flags(lbModule *m, LLVMValueRef value, u64 flags) { +gb_internal void lb_set_linkage_from_entity_flags(lbModule *m, LLVMValueRef value, u64 flags) { if (flags & EntityFlag_CustomLinkage_Internal) { LLVMSetLinkage(value, LLVMInternalLinkage); } else if (flags & EntityFlag_CustomLinkage_Strong) { diff --git a/src/llvm_backend_opt.cpp b/src/llvm_backend_opt.cpp index e2f51b868..141ee88c7 100644 --- a/src/llvm_backend_opt.cpp +++ b/src/llvm_backend_opt.cpp @@ -32,21 +32,21 @@ **************************************************************************/ -void lb_populate_function_pass_manager(lbModule *m, LLVMPassManagerRef fpm, bool ignore_memcpy_pass, i32 optimization_level); -void lb_add_function_simplifcation_passes(LLVMPassManagerRef mpm, i32 optimization_level); -void lb_populate_module_pass_manager(LLVMTargetMachineRef target_machine, LLVMPassManagerRef mpm, i32 optimization_level); -void lb_populate_function_pass_manager_specific(lbModule *m, LLVMPassManagerRef fpm, i32 optimization_level); +gb_internal void lb_populate_function_pass_manager(lbModule *m, LLVMPassManagerRef fpm, bool ignore_memcpy_pass, i32 optimization_level); +gb_internal void lb_add_function_simplifcation_passes(LLVMPassManagerRef mpm, i32 optimization_level); +gb_internal void lb_populate_module_pass_manager(LLVMTargetMachineRef target_machine, LLVMPassManagerRef mpm, i32 optimization_level); +gb_internal void lb_populate_function_pass_manager_specific(lbModule *m, LLVMPassManagerRef fpm, i32 optimization_level); -LLVMBool lb_must_preserve_predicate_callback(LLVMValueRef value, void *user_data) { - lbModule *m = cast(lbModule *)user_data; - if (m == nullptr) { - return false; - } - if (value == nullptr) { - return false; - } - return LLVMIsAAllocaInst(value) != nullptr; -} +// gb_internal LLVMBool lb_must_preserve_predicate_callback(LLVMValueRef value, void *user_data) { +// lbModule *m = cast(lbModule *)user_data; +// if (m == nullptr) { +// return false; +// } +// if (value == nullptr) { +// return false; +// } +// return LLVMIsAAllocaInst(value) != nullptr; +// } #if LLVM_VERSION_MAJOR < 12 @@ -55,8 +55,17 @@ LLVMBool lb_must_preserve_predicate_callback(LLVMValueRef value, void *user_data #define LLVM_ADD_CONSTANT_VALUE_PASS(fpm) #endif -void lb_basic_populate_function_pass_manager(LLVMPassManagerRef fpm, i32 optimization_level) { - if (false && optimization_level == 0 && build_context.ODIN_DEBUG) { +gb_internal bool lb_opt_ignore(i32 optimization_level) { + optimization_level = gb_clamp(optimization_level, -1, 2); + return optimization_level == -1; +} + +gb_internal void lb_basic_populate_function_pass_manager(LLVMPassManagerRef fpm, i32 optimization_level) { + if (lb_opt_ignore(optimization_level)) { + return; + } + + if (false && optimization_level <= 0 && build_context.ODIN_DEBUG) { LLVMAddMergedLoadStoreMotionPass(fpm); } else { LLVMAddPromoteMemoryToRegisterPass(fpm); @@ -68,15 +77,15 @@ void lb_basic_populate_function_pass_manager(LLVMPassManagerRef fpm, i32 optimiz } } -void lb_populate_function_pass_manager(lbModule *m, LLVMPassManagerRef fpm, bool ignore_memcpy_pass, i32 optimization_level) { - // NOTE(bill): Treat -opt:3 as if it was -opt:2 - // TODO(bill): Determine which opt definitions should exist in the first place - optimization_level = gb_clamp(optimization_level, 0, 2); +gb_internal void lb_populate_function_pass_manager(lbModule *m, LLVMPassManagerRef fpm, bool ignore_memcpy_pass, i32 optimization_level) { + if (lb_opt_ignore(optimization_level)) { + return; + } if (ignore_memcpy_pass) { lb_basic_populate_function_pass_manager(fpm, optimization_level); return; - } else if (optimization_level == 0) { + } else if (optimization_level <= 0) { LLVMAddMemCpyOptPass(fpm); lb_basic_populate_function_pass_manager(fpm, optimization_level); return; @@ -102,12 +111,12 @@ void lb_populate_function_pass_manager(lbModule *m, LLVMPassManagerRef fpm, bool #endif } -void lb_populate_function_pass_manager_specific(lbModule *m, LLVMPassManagerRef fpm, i32 optimization_level) { - // NOTE(bill): Treat -opt:3 as if it was -opt:2 - // TODO(bill): Determine which opt definitions should exist in the first place - optimization_level = gb_clamp(optimization_level, 0, 2); +gb_internal void lb_populate_function_pass_manager_specific(lbModule *m, LLVMPassManagerRef fpm, i32 optimization_level) { + if (lb_opt_ignore(optimization_level)) { + return; + } - if (optimization_level == 0) { + if (optimization_level <= 0) { LLVMAddMemCpyOptPass(fpm); lb_basic_populate_function_pass_manager(fpm, optimization_level); return; @@ -141,7 +150,7 @@ void lb_populate_function_pass_manager_specific(lbModule *m, LLVMPassManagerRef #endif } -void lb_add_function_simplifcation_passes(LLVMPassManagerRef mpm, i32 optimization_level) { +gb_internal void lb_add_function_simplifcation_passes(LLVMPassManagerRef mpm, i32 optimization_level) { LLVMAddCFGSimplificationPass(mpm); LLVMAddJumpThreadingPass(mpm); @@ -177,12 +186,11 @@ void lb_add_function_simplifcation_passes(LLVMPassManagerRef mpm, i32 optimizati } -void lb_populate_module_pass_manager(LLVMTargetMachineRef target_machine, LLVMPassManagerRef mpm, i32 optimization_level) { +gb_internal void lb_populate_module_pass_manager(LLVMTargetMachineRef target_machine, LLVMPassManagerRef mpm, i32 optimization_level) { // NOTE(bill): Treat -opt:3 as if it was -opt:2 // TODO(bill): Determine which opt definitions should exist in the first place - optimization_level = gb_clamp(optimization_level, 0, 2); - if (optimization_level == 0 && build_context.ODIN_DEBUG) { + if (optimization_level <= 0 && build_context.ODIN_DEBUG) { return; } @@ -190,7 +198,7 @@ void lb_populate_module_pass_manager(LLVMTargetMachineRef target_machine, LLVMPa LLVMAddStripDeadPrototypesPass(mpm); LLVMAddAnalysisPasses(target_machine, mpm); LLVMAddPruneEHPass(mpm); - if (optimization_level == 0) { + if (optimization_level <= 0) { return; } @@ -266,7 +274,10 @@ void lb_populate_module_pass_manager(LLVMTargetMachineRef target_machine, LLVMPa optimization of Odin programs **************************************************************************/ -void lb_run_remove_dead_instruction_pass(lbProcedure *p) { +gb_internal void lb_run_remove_dead_instruction_pass(lbProcedure *p) { + unsigned debug_declare_id = LLVMLookupIntrinsicID("llvm.dbg.declare", 16); + GB_ASSERT(debug_declare_id != 0); + isize removal_count = 0; isize pass_count = 0; isize const max_pass_count = 10; @@ -302,6 +313,8 @@ void lb_run_remove_dead_instruction_pass(lbProcedure *p) { // NOTE(bill): Explicit instructions are set here because some instructions could have side effects switch (LLVMGetInstructionOpcode(curr_instr)) { + // case LLVMAlloca: + case LLVMFNeg: case LLVMAdd: case LLVMFAdd: @@ -321,7 +334,6 @@ void lb_run_remove_dead_instruction_pass(lbProcedure *p) { case LLVMAnd: case LLVMOr: case LLVMXor: - case LLVMAlloca: case LLVMLoad: case LLVMGetElementPtr: case LLVMTrunc: @@ -358,8 +370,21 @@ void lb_run_remove_dead_instruction_pass(lbProcedure *p) { } -void lb_run_function_pass_manager(LLVMPassManagerRef fpm, lbProcedure *p) { +gb_internal void lb_run_function_pass_manager(LLVMPassManagerRef fpm, lbProcedure *p, lbFunctionPassManagerKind pass_manager_kind) { + if (p == nullptr) { + return; + } LLVMRunFunctionPassManager(fpm, p->value); + switch (pass_manager_kind) { + case lbFunctionPassManager_none: + return; + case lbFunctionPassManager_default: + case lbFunctionPassManager_default_without_memcpy: + if (build_context.optimization_level < 0) { + return; + } + break; + } // NOTE(bill): LLVMAddDCEPass doesn't seem to be exported in the official DLL's for LLVM // which means we cannot rely upon it // This is also useful for read the .ll for debug purposes because a lot of instructions @@ -367,7 +392,7 @@ void lb_run_function_pass_manager(LLVMPassManagerRef fpm, lbProcedure *p) { lb_run_remove_dead_instruction_pass(p); } -void llvm_delete_function(LLVMValueRef func) { +gb_internal void llvm_delete_function(LLVMValueRef func) { // for (LLVMBasicBlockRef block = LLVMGetFirstBasicBlock(func); block != nullptr; /**/) { // LLVMBasicBlockRef curr_block = block; // block = LLVMGetNextBasicBlock(block); @@ -382,7 +407,7 @@ void llvm_delete_function(LLVMValueRef func) { LLVMDeleteFunction(func); } -void lb_append_to_compiler_used(lbModule *m, LLVMValueRef func) { +gb_internal void lb_append_to_compiler_used(lbModule *m, LLVMValueRef func) { LLVMValueRef global = LLVMGetNamedGlobal(m->mod, "llvm.compiler.used"); LLVMValueRef *constants; @@ -419,7 +444,7 @@ void lb_append_to_compiler_used(lbModule *m, LLVMValueRef func) { LLVMSetInitializer(global, initializer); } -void lb_run_remove_unused_function_pass(lbModule *m) { +gb_internal void lb_run_remove_unused_function_pass(lbModule *m) { isize removal_count = 0; isize pass_count = 0; isize const max_pass_count = 10; @@ -470,7 +495,7 @@ void lb_run_remove_unused_function_pass(lbModule *m) { } -void lb_run_remove_unused_globals_pass(lbModule *m) { +gb_internal void lb_run_remove_unused_globals_pass(lbModule *m) { isize removal_count = 0; isize pass_count = 0; isize const max_pass_count = 10; diff --git a/src/llvm_backend_proc.cpp b/src/llvm_backend_proc.cpp index 597efb0ba..47137c540 100644 --- a/src/llvm_backend_proc.cpp +++ b/src/llvm_backend_proc.cpp @@ -1,5 +1,4 @@ -LLVMValueRef lb_call_intrinsic(lbProcedure *p, const char *name, LLVMValueRef* args, unsigned arg_count, LLVMTypeRef* types, unsigned type_count) -{ +gb_internal LLVMValueRef lb_call_intrinsic(lbProcedure *p, const char *name, LLVMValueRef* args, unsigned arg_count, LLVMTypeRef* types, unsigned type_count) { unsigned id = LLVMLookupIntrinsicID(name, gb_strlen(name)); GB_ASSERT_MSG(id != 0, "Unable to find %s", name); LLVMValueRef ip = LLVMGetIntrinsicDeclaration(p->module->mod, id, types, type_count); @@ -7,7 +6,7 @@ LLVMValueRef lb_call_intrinsic(lbProcedure *p, const char *name, LLVMValueRef* a return LLVMBuildCall2(p->builder, call_type, ip, args, arg_count, ""); } -void lb_mem_copy_overlapping(lbProcedure *p, lbValue dst, lbValue src, lbValue len, bool is_volatile) { +gb_internal void lb_mem_copy_overlapping(lbProcedure *p, lbValue dst, lbValue src, lbValue len, bool is_volatile) { dst = lb_emit_conv(p, dst, t_rawptr); src = lb_emit_conv(p, src, t_rawptr); len = lb_emit_conv(p, len, t_int); @@ -15,7 +14,7 @@ void lb_mem_copy_overlapping(lbProcedure *p, lbValue dst, lbValue src, lbValue l char const *name = "llvm.memmove"; if (LLVMIsConstant(len.value)) { i64 const_len = cast(i64)LLVMConstIntGetSExtValue(len.value); - if (const_len <= 4*build_context.word_size) { + if (const_len <= 4*build_context.int_size) { name = "llvm.memmove.inline"; } } @@ -36,7 +35,7 @@ void lb_mem_copy_overlapping(lbProcedure *p, lbValue dst, lbValue src, lbValue l -void lb_mem_copy_non_overlapping(lbProcedure *p, lbValue dst, lbValue src, lbValue len, bool is_volatile) { +gb_internal void lb_mem_copy_non_overlapping(lbProcedure *p, lbValue dst, lbValue src, lbValue len, bool is_volatile) { dst = lb_emit_conv(p, dst, t_rawptr); src = lb_emit_conv(p, src, t_rawptr); len = lb_emit_conv(p, len, t_int); @@ -44,7 +43,7 @@ void lb_mem_copy_non_overlapping(lbProcedure *p, lbValue dst, lbValue src, lbVal char const *name = "llvm.memcpy"; if (LLVMIsConstant(len.value)) { i64 const_len = cast(i64)LLVMConstIntGetSExtValue(len.value); - if (const_len <= 4*build_context.word_size) { + if (const_len <= 4*build_context.int_size) { name = "llvm.memcpy.inline"; } } @@ -65,17 +64,19 @@ void lb_mem_copy_non_overlapping(lbProcedure *p, lbValue dst, lbValue src, lbVal } -lbProcedure *lb_create_procedure(lbModule *m, Entity *entity, bool ignore_body) { +gb_internal lbProcedure *lb_create_procedure(lbModule *m, Entity *entity, bool ignore_body) { GB_ASSERT(entity != nullptr); GB_ASSERT(entity->kind == Entity_Procedure); if (!entity->Procedure.is_foreign) { - GB_ASSERT_MSG(entity->flags & EntityFlag_ProcBodyChecked, "%.*s :: %s", LIT(entity->token.string), type_to_string(entity->type)); + if ((entity->flags & EntityFlag_ProcBodyChecked) == 0) { + GB_PANIC("%.*s :: %s (was parapoly: %d %d)", LIT(entity->token.string), type_to_string(entity->type), is_type_polymorphic(entity->type, true), is_type_polymorphic(entity->type, false)); + } } String link_name = {}; if (ignore_body) { - lbModule *other_module = lb_pkg_module(m->gen, entity->pkg); + lbModule *other_module = lb_module_of_entity(m->gen, entity); link_name = lb_get_entity_name(other_module, entity); } else { link_name = lb_get_entity_name(m, entity); @@ -120,18 +121,21 @@ lbProcedure *lb_create_procedure(lbModule *m, Entity *entity, bool ignore_body) p->branch_blocks.allocator = a; p->context_stack.allocator = a; p->scope_stack.allocator = a; - map_init(&p->selector_values, a, 0); - map_init(&p->selector_addr, a, 0); - map_init(&p->tuple_fix_map, a, 0); + // map_init(&p->selector_values, 0); + // map_init(&p->selector_addr, 0); + // map_init(&p->tuple_fix_map, 0); if (p->is_foreign) { lb_add_foreign_library_path(p->module, entity->Procedure.foreign_library); } - char *c_link_name = alloc_cstring(permanent_allocator(), p->name); LLVMTypeRef func_type = lb_get_procedure_raw_type(m, p->type); - p->value = LLVMAddFunction(m->mod, c_link_name, func_type); + { + TEMPORARY_ALLOCATOR_GUARD(); + char *c_link_name = alloc_cstring(temporary_allocator(), p->name); + p->value = LLVMAddFunction(m->mod, c_link_name, func_type); + } lb_ensure_abi_function_type(m, p); lb_add_function_type_attributes(p->value, p->abi_function_type, p->abi_function_type->calling_convention); @@ -191,11 +195,6 @@ lbProcedure *lb_create_procedure(lbModule *m, Entity *entity, bool ignore_body) lb_add_attribute_to_proc(m, p->value, "cold"); } - lbValue proc_value = {p->value, p->type}; - lb_add_entity(m, entity, proc_value); - lb_add_member(m, p->name, proc_value); - lb_add_procedure_value(m, p); - if (p->is_export) { LLVMSetLinkage(p->value, LLVMDLLExportLinkage); LLVMSetDLLStorageClass(p->value, LLVMDLLExportStorageClass); @@ -203,7 +202,9 @@ lbProcedure *lb_create_procedure(lbModule *m, Entity *entity, bool ignore_body) lb_set_wasm_export_attributes(p->value, p->name); } else if (!p->is_foreign) { - if (!USE_SEPARATE_MODULES) { + if (USE_SEPARATE_MODULES) { + LLVMSetLinkage(p->value, LLVMExternalLinkage); + } else { LLVMSetLinkage(p->value, LLVMInternalLinkage); // NOTE(bill): if a procedure is defined in package runtime and uses a custom link name, @@ -317,10 +318,15 @@ lbProcedure *lb_create_procedure(lbModule *m, Entity *entity, bool ignore_body) } } + lbValue proc_value = {p->value, p->type}; + lb_add_entity(m, entity, proc_value); + lb_add_member(m, p->name, proc_value); + lb_add_procedure_value(m, p); + return p; } -lbProcedure *lb_create_dummy_procedure(lbModule *m, String link_name, Type *type) { +gb_internal lbProcedure *lb_create_dummy_procedure(lbModule *m, String link_name, Type *type) { { lbValue *found = string_map_get(&m->members, link_name); GB_ASSERT_MSG(found == nullptr, "failed to create dummy procedure for: %.*s", LIT(link_name)); @@ -346,7 +352,7 @@ lbProcedure *lb_create_dummy_procedure(lbModule *m, String link_name, Type *type p->blocks.allocator = a; p->branch_blocks.allocator = a; p->context_stack.allocator = a; - map_init(&p->tuple_fix_map, a, 0); + map_init(&p->tuple_fix_map, 0); char *c_link_name = alloc_cstring(permanent_allocator(), p->name); @@ -384,50 +390,50 @@ lbProcedure *lb_create_dummy_procedure(lbModule *m, String link_name, Type *type } -lbValue lb_value_param(lbProcedure *p, Entity *e, Type *abi_type, i32 index, lbParamPasskind *kind_) { - lbParamPasskind kind = lbParamPass_Value; +// gb_internal lbValue lb_value_param(lbProcedure *p, Entity *e, Type *abi_type, i32 index, lbParamPasskind *kind_) { +// lbParamPasskind kind = lbParamPass_Value; - if (e != nullptr && !are_types_identical(abi_type, e->type)) { - if (is_type_pointer(abi_type)) { - GB_ASSERT(e->kind == Entity_Variable); - Type *av = core_type(type_deref(abi_type)); - if (are_types_identical(av, core_type(e->type))) { - kind = lbParamPass_Pointer; - if (e->flags&EntityFlag_Value) { - kind = lbParamPass_ConstRef; - } - } else { - kind = lbParamPass_BitCast; - } - } else if (is_type_integer(abi_type)) { - kind = lbParamPass_Integer; - } else if (abi_type == t_llvm_bool) { - kind = lbParamPass_Value; - } else if (is_type_boolean(abi_type)) { - kind = lbParamPass_Integer; - } else if (is_type_simd_vector(abi_type)) { - kind = lbParamPass_BitCast; - } else if (is_type_float(abi_type)) { - kind = lbParamPass_BitCast; - } else if (is_type_tuple(abi_type)) { - kind = lbParamPass_Tuple; - } else if (is_type_proc(abi_type)) { - kind = lbParamPass_Value; - } else { - GB_PANIC("Invalid abi type pass kind %s", type_to_string(abi_type)); - } - } +// if (e != nullptr && !are_types_identical(abi_type, e->type)) { +// if (is_type_pointer(abi_type)) { +// GB_ASSERT(e->kind == Entity_Variable); +// Type *av = core_type(type_deref(abi_type)); +// if (are_types_identical(av, core_type(e->type))) { +// kind = lbParamPass_Pointer; +// if (e->flags&EntityFlag_Value) { +// kind = lbParamPass_ConstRef; +// } +// } else { +// kind = lbParamPass_BitCast; +// } +// } else if (is_type_integer(abi_type)) { +// kind = lbParamPass_Integer; +// } else if (abi_type == t_llvm_bool) { +// kind = lbParamPass_Value; +// } else if (is_type_boolean(abi_type)) { +// kind = lbParamPass_Integer; +// } else if (is_type_simd_vector(abi_type)) { +// kind = lbParamPass_BitCast; +// } else if (is_type_float(abi_type)) { +// kind = lbParamPass_BitCast; +// } else if (is_type_tuple(abi_type)) { +// kind = lbParamPass_Tuple; +// } else if (is_type_proc(abi_type)) { +// kind = lbParamPass_Value; +// } else { +// GB_PANIC("Invalid abi type pass kind %s", type_to_string(abi_type)); +// } +// } - if (kind_) *kind_ = kind; - lbValue res = {}; - res.value = LLVMGetParam(p->value, cast(unsigned)index); - res.type = abi_type; - return res; -} +// if (kind_) *kind_ = kind; +// lbValue res = {}; +// res.value = LLVMGetParam(p->value, cast(unsigned)index); +// res.type = abi_type; +// return res; +// } -void lb_start_block(lbProcedure *p, lbBlock *b) { +gb_internal void lb_start_block(lbProcedure *p, lbBlock *b) { GB_ASSERT(b != nullptr); if (!b->appended) { b->appended = true; @@ -437,7 +443,7 @@ void lb_start_block(lbProcedure *p, lbBlock *b) { p->curr_block = b; } -void lb_set_debug_position_to_procedure_begin(lbProcedure *p) { +gb_internal void lb_set_debug_position_to_procedure_begin(lbProcedure *p) { if (p->debug_info == nullptr) { return; } @@ -454,7 +460,7 @@ void lb_set_debug_position_to_procedure_begin(lbProcedure *p) { } } -void lb_set_debug_position_to_procedure_end(lbProcedure *p) { +gb_internal void lb_set_debug_position_to_procedure_end(lbProcedure *p) { if (p->debug_info == nullptr) { return; } @@ -471,7 +477,7 @@ void lb_set_debug_position_to_procedure_end(lbProcedure *p) { } } -void lb_begin_procedure_body(lbProcedure *p) { +gb_internal void lb_begin_procedure_body(lbProcedure *p) { DeclInfo *decl = decl_info_of_entity(p->entity); if (decl != nullptr) { for_array(i, decl->labels) { @@ -487,7 +493,7 @@ void lb_begin_procedure_body(lbProcedure *p) { p->entry_block = lb_create_block(p, "entry", true); lb_start_block(p, p->entry_block); - map_init(&p->direct_parameters, heap_allocator()); + map_init(&p->direct_parameters); GB_ASSERT(p->type != nullptr); @@ -535,6 +541,10 @@ void lb_begin_procedure_body(lbProcedure *p) { if (p->type->Proc.params != nullptr) { TypeTuple *params = &p->type->Proc.params->Tuple; + unsigned raw_input_parameters_count = LLVMCountParams(p->value); + p->raw_input_parameters = array_make(permanent_allocator(), raw_input_parameters_count); + LLVMGetParams(p->value, p->raw_input_parameters.data); + unsigned param_index = 0; for_array(i, params->variables) { Entity *e = params->variables[i]; @@ -686,7 +696,7 @@ void lb_begin_procedure_body(lbProcedure *p) { lb_start_block(p, p->entry_block); } -void lb_end_procedure_body(lbProcedure *p) { +gb_internal void lb_end_procedure_body(lbProcedure *p) { lb_set_debug_position_to_procedure_begin(p); LLVMPositionBuilderAtEnd(p->builder, p->decl_block->block); @@ -720,11 +730,11 @@ void lb_end_procedure_body(lbProcedure *p) { p->curr_block = nullptr; p->state_flags = 0; } -void lb_end_procedure(lbProcedure *p) { +gb_internal void lb_end_procedure(lbProcedure *p) { LLVMDisposeBuilder(p->builder); } -void lb_build_nested_proc(lbProcedure *p, AstProcLit *pd, Entity *e) { +gb_internal void lb_build_nested_proc(lbProcedure *p, AstProcLit *pd, Entity *e) { GB_ASSERT(pd->body != nullptr); lbModule *m = p->module; auto *min_dep_set = &m->info->minimum_dependency_set; @@ -766,16 +776,16 @@ void lb_build_nested_proc(lbProcedure *p, AstProcLit *pd, Entity *e) { -Array lb_value_to_array(lbProcedure *p, lbValue value) { +gb_internal Array lb_value_to_array(lbProcedure *p, gbAllocator const &allocator, lbValue value) { Array array = {}; Type *t = base_type(value.type); if (t == nullptr) { // Do nothing } else if (is_type_tuple(t)) { - array = array_make(permanent_allocator(), 0, t->Tuple.variables.count); + array = array_make(allocator, 0, t->Tuple.variables.count); lb_append_tuple_values(p, &array, value); } else { - array = array_make(permanent_allocator(), 1); + array = array_make(allocator, 1); array[0] = value; } return array; @@ -783,7 +793,7 @@ Array lb_value_to_array(lbProcedure *p, lbValue value) { -lbValue lb_emit_call_internal(lbProcedure *p, lbValue value, lbValue return_ptr, Array const &processed_args, Type *abi_rt, lbAddr context_ptr, ProcInlining inlining) { +gb_internal lbValue lb_emit_call_internal(lbProcedure *p, lbValue value, lbValue return_ptr, Array const &processed_args, Type *abi_rt, lbAddr context_ptr, ProcInlining inlining) { GB_ASSERT(p->module->ctx == LLVMGetTypeContext(LLVMTypeOf(value.value))); unsigned arg_count = cast(unsigned)processed_args.count; @@ -892,20 +902,20 @@ lbValue lb_emit_call_internal(lbProcedure *p, lbValue value, lbValue return_ptr, } -lbValue lb_lookup_runtime_procedure(lbModule *m, String const &name) { +gb_internal lbValue lb_lookup_runtime_procedure(lbModule *m, String const &name) { AstPackage *pkg = m->info->runtime_package; Entity *e = scope_lookup_current(pkg->scope, name); return lb_find_procedure_value_from_entity(m, e); } -lbValue lb_emit_runtime_call(lbProcedure *p, char const *c_name, Array const &args) { +gb_internal lbValue lb_emit_runtime_call(lbProcedure *p, char const *c_name, Array const &args) { String name = make_string_c(c_name); lbValue proc = lb_lookup_runtime_procedure(p->module, name); return lb_emit_call(p, proc, args); } -lbValue lb_emit_conjugate(lbProcedure *p, lbValue val, Type *type) { +gb_internal lbValue lb_emit_conjugate(lbProcedure *p, lbValue val, Type *type) { lbValue res = {}; Type *t = val.type; if (is_type_complex(t)) { @@ -956,7 +966,7 @@ lbValue lb_emit_conjugate(lbProcedure *p, lbValue val, Type *type) { return lb_emit_load(p, res); } -lbValue lb_emit_call(lbProcedure *p, lbValue value, Array const &args, ProcInlining inlining) { +gb_internal lbValue lb_emit_call(lbProcedure *p, lbValue value, Array const &args, ProcInlining inlining) { lbModule *m = p->module; Type *pt = base_type(value.type); @@ -1025,17 +1035,38 @@ lbValue lb_emit_call(lbProcedure *p, lbValue value, Array const &args, } else if (arg->kind == lbArg_Indirect) { lbValue ptr = {}; if (arg->is_byval) { - if (is_odin_cc && are_types_identical(original_type, t_source_code_location)) { - ptr = lb_address_from_load_or_generate_local(p, x); - } else { + if (is_odin_cc) { + if (are_types_identical(original_type, t_source_code_location)) { + ptr = lb_address_from_load_or_generate_local(p, x); + // } else { + // ptr = lb_address_from_load_if_readonly_parameter(p, x); + } + } + if (ptr.value == nullptr) { ptr = lb_copy_value_to_ptr(p, x, original_type, arg->byval_alignment); } } else if (is_odin_cc) { // NOTE(bill): Odin parameters are immutable so the original value can be passed if possible // i.e. `T const &` in C++ - ptr = lb_address_from_load_or_generate_local(p, x); + if (LLVMIsConstant(x.value)) { + // NOTE(bill): if the value is already constant, then just it as a global variable + // and pass it by pointer + lbAddr addr = lb_add_global_generated(p->module, original_type, x); + lb_make_global_private_const(addr); + ptr = addr.addr; + } else { + ptr = lb_address_from_load_or_generate_local(p, x); + } } else { - ptr = lb_copy_value_to_ptr(p, x, original_type, 16); + if (LLVMIsConstant(x.value)) { + // NOTE(bill): if the value is already constant, then just it as a global variable + // and pass it by pointer + lbAddr addr = lb_add_global_generated(p->module, original_type, x); + lb_make_global_private_const(addr); + ptr = addr.addr; + } else { + ptr = lb_copy_value_to_ptr(p, x, original_type, 16); + } } array_add(&processed_args, ptr); } @@ -1129,7 +1160,13 @@ lbValue lb_emit_call(lbProcedure *p, lbValue value, Array const &args, } - Entity **found = map_get(&p->module->procedure_values, value.value); + LLVMValueRef the_proc_value = value.value; + + if (LLVMIsAConstantExpr(the_proc_value)) { + // NOTE(bill): it's a bit cast + the_proc_value = LLVMGetOperand(the_proc_value, 0); + } + Entity **found = map_get(&p->module->procedure_values, the_proc_value); if (found != nullptr) { Entity *e = *found; if (e != nullptr && entity_has_deferred_procedure(e)) { @@ -1138,26 +1175,42 @@ lbValue lb_emit_call(lbProcedure *p, lbValue value, Array const &args, lbValue deferred = lb_find_procedure_value_from_entity(p->module, deferred_entity); + bool by_ptr = false; auto in_args = args; Array result_as_args = {}; switch (kind) { case DeferredProcedure_none: break; + case DeferredProcedure_in_by_ptr: + by_ptr = true; + /*fallthrough*/ case DeferredProcedure_in: - result_as_args = in_args; + result_as_args = array_clone(heap_allocator(), in_args); break; + case DeferredProcedure_out_by_ptr: + by_ptr = true; + /*fallthrough*/ case DeferredProcedure_out: - result_as_args = lb_value_to_array(p, result); + result_as_args = lb_value_to_array(p, heap_allocator(), result); break; + case DeferredProcedure_in_out_by_ptr: + by_ptr = true; + /*fallthrough*/ case DeferredProcedure_in_out: { - auto out_args = lb_value_to_array(p, result); - array_init(&result_as_args, permanent_allocator(), in_args.count + out_args.count); + auto out_args = lb_value_to_array(p, heap_allocator(), result); + array_init(&result_as_args, heap_allocator(), in_args.count + out_args.count); array_copy(&result_as_args, in_args, 0); array_copy(&result_as_args, out_args, in_args.count); } break; } + if (by_ptr) { + for_array(i, result_as_args) { + lbValue arg_ptr = lb_address_from_load_or_generate_local(p, result_as_args[i]); + result_as_args[i] = arg_ptr; + } + } lb_add_defer_proc(p, p->scope_index, deferred, result_as_args); } @@ -1166,15 +1219,7 @@ lbValue lb_emit_call(lbProcedure *p, lbValue value, Array const &args, return result; } -LLVMValueRef llvm_splat_float(i64 count, LLVMTypeRef type, f64 value) { - LLVMValueRef v = LLVMConstReal(type, value); - LLVMValueRef *values = gb_alloc_array(temporary_allocator(), LLVMValueRef, count); - for (i64 i = 0; i < count; i++) { - values[i] = v; - } - return LLVMConstVector(values, cast(unsigned)count); -} -LLVMValueRef llvm_splat_int(i64 count, LLVMTypeRef type, i64 value, bool is_signed=false) { +gb_internal LLVMValueRef llvm_splat_int(i64 count, LLVMTypeRef type, i64 value, bool is_signed=false) { LLVMValueRef v = LLVMConstInt(type, value, is_signed); LLVMValueRef *values = gb_alloc_array(temporary_allocator(), LLVMValueRef, count); for (i64 i = 0; i < count; i++) { @@ -1184,7 +1229,7 @@ LLVMValueRef llvm_splat_int(i64 count, LLVMTypeRef type, i64 value, bool is_sign } -lbValue lb_build_builtin_simd_proc(lbProcedure *p, Ast *expr, TypeAndValue const &tv, BuiltinProcId builtin_id) { +gb_internal lbValue lb_build_builtin_simd_proc(lbProcedure *p, Ast *expr, TypeAndValue const &tv, BuiltinProcId builtin_id) { ast_node(ce, CallExpr, expr); lbModule *m = p->module; @@ -1600,7 +1645,7 @@ lbValue lb_build_builtin_simd_proc(lbProcedure *p, Ast *expr, TypeAndValue const } -lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValue const &tv, BuiltinProcId id) { +gb_internal lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValue const &tv, BuiltinProcId id) { ast_node(ce, CallExpr, expr); if (BuiltinProc__simd_begin < id && id < BuiltinProc__simd_end) { @@ -1832,7 +1877,7 @@ lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValue const &tv, return lb_emit_conjugate(p, val, tv.type); } - case BuiltinProc_expand_to_tuple: { + case BuiltinProc_expand_values: { lbValue val = lb_build_expr(p, ce->args[0]); Type *t = base_type(val.type); @@ -1844,7 +1889,7 @@ lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValue const &tv, GB_ASSERT(t->Array.count == 1); return lb_emit_struct_ev(p, val, 0); } else { - GB_PANIC("Unknown type of expand_to_tuple"); + GB_PANIC("Unknown type of expand_values"); } } @@ -1870,7 +1915,7 @@ lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValue const &tv, lb_emit_store(p, ep, f); } } else { - GB_PANIC("Unknown type of expand_to_tuple"); + GB_PANIC("Unknown type of expand_values"); } return lb_emit_load(p, tuple); } @@ -2019,7 +2064,7 @@ lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValue const &tv, i64 al = exact_value_to_i64(type_and_value_of_expr(ce->args[1]).value); lbValue res = {}; - res.type = t_u8_ptr; + res.type = alloc_type_multi_pointer(t_u8); res.value = LLVMBuildArrayAlloca(p->builder, lb_type(p->module, t_u8), sz.value, ""); LLVMSetAlignment(res.value, cast(unsigned)al); return res; @@ -2284,7 +2329,15 @@ lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValue const &tv, break; case BuiltinProc_volatile_store: LLVMSetVolatile(instr, true); break; case BuiltinProc_atomic_store: LLVMSetOrdering(instr, LLVMAtomicOrderingSequentiallyConsistent); break; - case BuiltinProc_atomic_store_explicit: LLVMSetOrdering(instr, llvm_atomic_ordering_from_odin(ce->args[2])); break; + case BuiltinProc_atomic_store_explicit: + { + auto ordering = llvm_atomic_ordering_from_odin(ce->args[2]); + LLVMSetOrdering(instr, ordering); + if (ordering == LLVMAtomicOrderingUnordered) { + LLVMSetVolatile(instr, true); + } + } + break; } LLVMSetAlignment(instr, cast(unsigned)type_align_of(type_deref(dst.type))); @@ -2310,7 +2363,15 @@ lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValue const &tv, break; case BuiltinProc_volatile_load: LLVMSetVolatile(instr, true); break; case BuiltinProc_atomic_load: LLVMSetOrdering(instr, LLVMAtomicOrderingSequentiallyConsistent); break; - case BuiltinProc_atomic_load_explicit: LLVMSetOrdering(instr, llvm_atomic_ordering_from_odin(ce->args[1])); break; + case BuiltinProc_atomic_load_explicit: + { + auto ordering = llvm_atomic_ordering_from_odin(ce->args[1]); + LLVMSetOrdering(instr, ordering); + if (ordering == LLVMAtomicOrderingUnordered) { + LLVMSetVolatile(instr, true); + } + } + break; } LLVMSetAlignment(instr, cast(unsigned)type_align_of(type_deref(dst.type))); @@ -2324,9 +2385,15 @@ lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValue const &tv, { lbValue dst = lb_build_expr(p, ce->args[0]); lbValue src = lb_build_expr(p, ce->args[1]); - src = lb_address_from_load_or_generate_local(p, src); Type *t = type_deref(dst.type); - lb_mem_copy_non_overlapping(p, dst, src, lb_const_int(p->module, t_int, type_size_of(t)), false); + + if (is_type_simd_vector(t)) { + LLVMValueRef store = LLVMBuildStore(p->builder, src.value, dst.value); + LLVMSetAlignment(store, 1); + } else { + src = lb_address_from_load_or_generate_local(p, src); + lb_mem_copy_non_overlapping(p, dst, src, lb_const_int(p->module, t_int, type_size_of(t)), false); + } return {}; } @@ -2334,9 +2401,17 @@ lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValue const &tv, { lbValue src = lb_build_expr(p, ce->args[0]); Type *t = type_deref(src.type); - lbAddr dst = lb_add_local_generated(p, t, false); - lb_mem_copy_non_overlapping(p, dst.addr, src, lb_const_int(p->module, t_int, type_size_of(t)), false); - return lb_addr_load(p, dst); + if (is_type_simd_vector(t)) { + lbValue res = {}; + res.type = t; + res.value = LLVMBuildLoad2(p->builder, lb_type(p->module, t), src.value, ""); + LLVMSetAlignment(res.value, 1); + return res; + } else { + lbAddr dst = lb_add_local_generated(p, t, false); + lb_mem_copy_non_overlapping(p, dst.addr, src, lb_const_int(p->module, t_int, type_size_of(t)), false); + return lb_addr_load(p, dst); + } } case BuiltinProc_atomic_add: @@ -2380,6 +2455,9 @@ lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValue const &tv, lbValue res = {}; res.value = LLVMBuildAtomicRMW(p->builder, op, dst.value, val.value, ordering, false); res.type = tv.type; + if (ordering == LLVMAtomicOrderingUnordered) { + LLVMSetVolatile(res.value, true); + } return res; } @@ -2405,7 +2483,6 @@ lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValue const &tv, case BuiltinProc_atomic_compare_exchange_weak_explicit: success_ordering = llvm_atomic_ordering_from_odin(ce->args[3]); failure_ordering = llvm_atomic_ordering_from_odin(ce->args[4]); weak = true; break; } - // TODO(bill): Figure out how to make it weak LLVMBool single_threaded = false; LLVMValueRef value = LLVMBuildAtomicCmpXchg( @@ -2416,6 +2493,9 @@ lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValue const &tv, single_threaded ); LLVMSetWeak(value, weak); + if (success_ordering == LLVMAtomicOrderingUnordered || failure_ordering == LLVMAtomicOrderingUnordered) { + LLVMSetVolatile(value, true); + } if (is_type_tuple(tv.type)) { Type *fix_typed = alloc_type_tuple(); @@ -2586,10 +2666,26 @@ lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValue const &tv, { GB_ASSERT(arg_count <= 7); + // FreeBSD additionally clobbers r8, r9, r10, but they + // can also be used to pass in arguments, so this needs + // to be handled in two parts. + bool clobber_arg_regs[7] = { + false, false, false, false, false, false, false + }; + if (build_context.metrics.os == TargetOs_freebsd) { + clobber_arg_regs[4] = true; // r10 + clobber_arg_regs[5] = true; // r8 + clobber_arg_regs[6] = true; // r9 + } + char asm_string[] = "syscall"; gbString constraints = gb_string_make(heap_allocator(), "={rax}"); for (unsigned i = 0; i < arg_count; i++) { - constraints = gb_string_appendc(constraints, ",{"); + if (!clobber_arg_regs[i]) { + constraints = gb_string_appendc(constraints, ",{"); + } else { + constraints = gb_string_appendc(constraints, ",+{"); + } static char const *regs[] = { "rax", "rdi", @@ -2613,10 +2709,35 @@ lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValue const &tv, // Some but not all system calls will additionally // clobber memory. // - // TODO: FreeBSD is different and will also clobber - // R8, R9, and R10. Additionally CF is used to - // indicate an error instead of -errno. + // As a fix for CVE-2019-5595, FreeBSD started + // clobbering R8, R9, and R10, instead of restoring + // them. Additionally unlike Linux, instead of + // returning negative errno, positive errno is + // returned and CF is set. + // + // TODO: + // * Figure out what Darwin does. + // * Add some extra handling to propagate CF back + // up to the caller on FreeBSD systems so that + // the caller knows that the return value is + // positive errno. constraints = gb_string_appendc(constraints, ",~{rcx},~{r11},~{memory}"); + if (build_context.metrics.os == TargetOs_freebsd) { + // Second half of dealing with FreeBSD's system + // call semantics. Explicitly clobber the registers + // that were not used to pass in arguments, and + // then clobber RFLAGS. + if (arg_count < 5) { + constraints = gb_string_appendc(constraints, ",~{r10}"); + } + if (arg_count < 6) { + constraints = gb_string_appendc(constraints, ",~{r8}"); + } + if (arg_count < 7) { + constraints = gb_string_appendc(constraints, ",~{r9}"); + } + constraints = gb_string_appendc(constraints, ",~{cc}"); + } inline_asm = llvm_get_inline_asm(func_type, make_string_c(asm_string), make_string_c(constraints)); } @@ -2816,7 +2937,7 @@ lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValue const &tv, { char const *name = "llvm.wasm.memory.grow"; LLVMTypeRef types[1] = { - lb_type(p->module, t_uintptr), + lb_type(p->module, t_i32), }; LLVMValueRef args[2] = {}; @@ -2824,24 +2945,24 @@ lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValue const &tv, args[1] = lb_emit_conv(p, lb_build_expr(p, ce->args[1]), t_uintptr).value; lbValue res = {}; - res.type = tv.type; + res.type = t_i32; res.value = lb_call_intrinsic(p, name, args, gb_count_of(args), types, gb_count_of(types)); - return res; + return lb_emit_conv(p, res, tv.type); } case BuiltinProc_wasm_memory_size: { char const *name = "llvm.wasm.memory.size"; LLVMTypeRef types[1] = { - lb_type(p->module, t_uintptr), + lb_type(p->module, t_i32), }; LLVMValueRef args[1] = {}; args[0] = lb_emit_conv(p, lb_build_expr(p, ce->args[0]), t_uintptr).value; lbValue res = {}; - res.type = tv.type; + res.type = t_i32; res.value = lb_call_intrinsic(p, name, args, gb_count_of(args), types, gb_count_of(types)); - return res; + return lb_emit_conv(p, res, tv.type); } case BuiltinProc_wasm_memory_atomic_wait32: @@ -2951,8 +3072,8 @@ lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValue const &tv, LLVMTypeRef func_type = lb_get_procedure_raw_type(p->module, type); LLVMValueRef the_asm = llvm_get_inline_asm( func_type, - str_lit("rolq $3, %rdi; rolq $13, %rdi\n rolq $61, %rdi; rolq $51, %rdi\n xchgq %rbx, %rbx"), - str_lit("={rdx},{rdx},{rax},cc,memory"), + str_lit("rolq $$3, %rdi; rolq $$13, %rdi\n rolq $$61, %rdi; rolq $$51, %rdi\n xchgq %rbx, %rbx"), + str_lit("={rdx},{rdx},{rax},~{cc},~{memory}"), true ); @@ -2980,7 +3101,7 @@ lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValue const &tv, } -lbValue lb_handle_param_value(lbProcedure *p, Type *parameter_type, ParameterValue const ¶m_value, TokenPos const &pos) { +gb_internal lbValue lb_handle_param_value(lbProcedure *p, Type *parameter_type, ParameterValue const ¶m_value, TokenPos const &pos) { switch (param_value.kind) { case ParameterValue_Constant: if (is_type_constant_type(parameter_type)) { @@ -3015,9 +3136,9 @@ lbValue lb_handle_param_value(lbProcedure *p, Type *parameter_type, ParameterVal } -lbValue lb_build_call_expr_internal(lbProcedure *p, Ast *expr); +gb_internal lbValue lb_build_call_expr_internal(lbProcedure *p, Ast *expr); -lbValue lb_build_call_expr(lbProcedure *p, Ast *expr) { +gb_internal lbValue lb_build_call_expr(lbProcedure *p, Ast *expr) { expr = unparen_expr(expr); ast_node(ce, CallExpr, expr); @@ -3030,7 +3151,19 @@ lbValue lb_build_call_expr(lbProcedure *p, Ast *expr) { } return res; } -lbValue lb_build_call_expr_internal(lbProcedure *p, Ast *expr) { + +gb_internal void lb_add_values_to_array(lbProcedure *p, Array *args, lbValue value) { + if (is_type_tuple(value.type)) { + for_array(i, value.type->Tuple.variables) { + lbValue sub_value = lb_emit_struct_ev(p, value, cast(i32)i); + array_add(args, sub_value); + } + } else { + array_add(args, value); + } +} + +gb_internal lbValue lb_build_call_expr_internal(lbProcedure *p, Ast *expr) { lbModule *m = p->module; TypeAndValue tv = type_and_value_of_expr(expr); @@ -3104,238 +3237,143 @@ lbValue lb_build_call_expr_internal(lbProcedure *p, Ast *expr) { GB_ASSERT(proc_type_->kind == Type_Proc); TypeProc *pt = &proc_type_->Proc; - if (is_call_expr_field_value(ce)) { - auto args = array_make(permanent_allocator(), pt->param_count); + GB_ASSERT(ce->split_args != nullptr); - for_array(arg_index, ce->args) { - Ast *arg = ce->args[arg_index]; - ast_node(fv, FieldValue, arg); - GB_ASSERT(fv->field->kind == Ast_Ident); - String name = fv->field->Ident.token.string; - isize index = lookup_procedure_parameter(pt, name); - GB_ASSERT(index >= 0); - TypeAndValue tav = type_and_value_of_expr(fv->value); - if (tav.mode == Addressing_Type) { - args[index] = lb_const_nil(m, tav.type); - } else { - args[index] = lb_build_expr(p, fv->value); - } - } - TypeTuple *params = &pt->params->Tuple; - for (isize i = 0; i < args.count; i++) { - Entity *e = params->variables[i]; - if (e->kind == Entity_TypeName) { - args[i] = lb_const_nil(m, e->type); - } else if (e->kind == Entity_Constant) { - continue; - } else { - GB_ASSERT(e->kind == Entity_Variable); - if (args[i].value == nullptr) { - args[i] = lb_handle_param_value(p, e->type, e->Variable.param_value, ast_token(expr).pos); - } else { - args[i] = lb_emit_conv(p, args[i], e->type); - } - } - } + auto args = array_make(permanent_allocator(), 0, pt->param_count); - for (isize i = 0; i < args.count; i++) { - Entity *e = params->variables[i]; - if (args[i].type == nullptr) { - continue; - } else if (is_type_untyped_nil(args[i].type)) { - args[i] = lb_const_nil(m, e->type); - } else if (is_type_untyped_undef(args[i].type)) { - args[i] = lb_const_undef(m, e->type); - } - } - - return lb_emit_call(p, value, args, ce->inlining); - } - - isize arg_index = 0; - - isize arg_count = 0; - for_array(i, ce->args) { - Ast *arg = ce->args[i]; - TypeAndValue tav = type_and_value_of_expr(arg); - GB_ASSERT_MSG(tav.mode != Addressing_Invalid, "%s %s %d", expr_to_string(arg), expr_to_string(expr), tav.mode); - GB_ASSERT_MSG(tav.mode != Addressing_ProcGroup, "%s", expr_to_string(arg)); - Type *at = tav.type; - if (is_type_tuple(at)) { - arg_count += at->Tuple.variables.count; - } else { - arg_count++; - } - } - - isize param_count = 0; - if (pt->params) { - GB_ASSERT(pt->params->kind == Type_Tuple); - param_count = pt->params->Tuple.variables.count; - } - - auto args = array_make(permanent_allocator(), cast(isize)gb_max(param_count, arg_count)); - isize variadic_index = pt->variadic_index; - bool variadic = pt->variadic && variadic_index >= 0; - bool vari_expand = ce->ellipsis.pos.line != 0; + bool vari_expand = (ce->ellipsis.pos.line != 0); bool is_c_vararg = pt->c_vararg; - String proc_name = {}; - if (p->entity != nullptr) { - proc_name = p->entity->token.string; + for_array(i, ce->split_args->positional) { + Entity *e = pt->params->Tuple.variables[i]; + if (e->kind == Entity_TypeName) { + array_add(&args, lb_const_nil(p->module, e->type)); + continue; + } else if (e->kind == Entity_Constant) { + array_add(&args, lb_const_value(p->module, e->type, e->Constant.value)); + continue; + } + + GB_ASSERT(e->kind == Entity_Variable); + + if (pt->variadic && pt->variadic_index == i) { + lbValue variadic_args = lb_const_nil(p->module, e->type); + auto variadic = slice(ce->split_args->positional, pt->variadic_index, ce->split_args->positional.count); + if (variadic.count != 0) { + // variadic call argument generation + Type *slice_type = e->type; + GB_ASSERT(slice_type->kind == Type_Slice); + + if (is_c_vararg) { + GB_ASSERT(!vari_expand); + + Type *elem_type = slice_type->Slice.elem; + + for (Ast *var_arg : variadic) { + lbValue arg = lb_build_expr(p, var_arg); + if (is_type_any(elem_type)) { + array_add(&args, lb_emit_conv(p, arg, default_type(arg.type))); + } else { + array_add(&args, lb_emit_conv(p, arg, elem_type)); + } + } + break; + } else if (vari_expand) { + GB_ASSERT(variadic.count == 1); + variadic_args = lb_build_expr(p, variadic[0]); + variadic_args = lb_emit_conv(p, variadic_args, slice_type); + } else { + Type *elem_type = slice_type->Slice.elem; + + auto var_args = array_make(heap_allocator(), 0, variadic.count); + defer (array_free(&var_args)); + for (Ast *var_arg : variadic) { + lbValue v = lb_build_expr(p, var_arg); + lb_add_values_to_array(p, &var_args, v); + } + isize slice_len = var_args.count; + if (slice_len > 0) { + lbAddr slice = lb_add_local_generated(p, slice_type, true); + lbAddr base_array = lb_add_local_generated(p, alloc_type_array(elem_type, slice_len), true); + + for (isize i = 0; i < var_args.count; i++) { + lbValue addr = lb_emit_array_epi(p, base_array.addr, cast(i32)i); + lbValue var_arg = var_args[i]; + var_arg = lb_emit_conv(p, var_arg, elem_type); + lb_emit_store(p, addr, var_arg); + } + + lbValue base_elem = lb_emit_array_epi(p, base_array.addr, 0); + lbValue len = lb_const_int(p->module, t_int, slice_len); + lb_fill_slice(p, slice, base_elem, len); + + variadic_args = lb_addr_load(p, slice); + } + } + } + array_add(&args, variadic_args); + + break; + } else { + lbValue value = lb_build_expr(p, ce->split_args->positional[i]); + lb_add_values_to_array(p, &args, value); + } } + + if (!is_c_vararg) { + array_resize(&args, pt->param_count); + } + + for (Ast *arg : ce->split_args->named) { + ast_node(fv, FieldValue, arg); + GB_ASSERT(fv->field->kind == Ast_Ident); + String name = fv->field->Ident.token.string; + gb_unused(name); + isize param_index = lookup_procedure_parameter(pt, name); + GB_ASSERT(param_index >= 0); + + lbValue value = lb_build_expr(p, fv->value); + GB_ASSERT(!is_type_tuple(value.type)); + args[param_index] = value; + } + TokenPos pos = ast_token(ce->proc).pos; - TypeTuple *param_tuple = nullptr; - if (pt->params) { - GB_ASSERT(pt->params->kind == Type_Tuple); - param_tuple = &pt->params->Tuple; - } - for_array(i, ce->args) { - Ast *arg = ce->args[i]; - TypeAndValue arg_tv = type_and_value_of_expr(arg); - if (arg_tv.mode == Addressing_Type) { - args[arg_index++] = lb_const_nil(m, arg_tv.type); - } else { - lbValue a = lb_build_expr(p, arg); - Type *at = a.type; - if (at->kind == Type_Tuple) { - lbTupleFix *tf = map_get(&p->tuple_fix_map, a.value); - if (tf) { - for_array(j, tf->values) { - args[arg_index++] = tf->values[j]; - } - } else { - for_array(j, at->Tuple.variables) { - lbValue v = lb_emit_struct_ev(p, a, cast(i32)j); - args[arg_index++] = v; - } + if (pt->params != nullptr) { + GB_ASSERT(args.count >= pt->params->Tuple.variables.count); + for_array(arg_index, pt->params->Tuple.variables) { + Entity *e = pt->params->Tuple.variables[arg_index]; + if (pt->variadic && arg_index == pt->variadic_index) { + if (!is_c_vararg && args[arg_index].value == 0) { + args[arg_index] = lb_const_nil(p->module, e->type); } - } else { - args[arg_index++] = a; - } - } - } - - - if (param_count > 0) { - GB_ASSERT_MSG(pt->params != nullptr, "%s %td", expr_to_string(expr), pt->param_count); - GB_ASSERT(param_count < 1000000); - - if (arg_count < param_count) { - isize end = cast(isize)param_count; - if (variadic) { - end = variadic_index; - } - while (arg_index < end) { - Entity *e = param_tuple->variables[arg_index]; - GB_ASSERT(e->kind == Entity_Variable); - args[arg_index++] = lb_handle_param_value(p, e->type, e->Variable.param_value, ast_token(expr).pos); - } - } - - if (is_c_vararg) { - GB_ASSERT(variadic); - GB_ASSERT(!vari_expand); - isize i = 0; - for (; i < variadic_index; i++) { - Entity *e = param_tuple->variables[i]; - if (e->kind == Entity_Variable) { - args[i] = lb_emit_conv(p, args[i], e->type); - } - } - Type *variadic_type = param_tuple->variables[i]->type; - GB_ASSERT(is_type_slice(variadic_type)); - variadic_type = base_type(variadic_type)->Slice.elem; - if (!is_type_any(variadic_type)) { - for (; i < arg_count; i++) { - args[i] = lb_emit_conv(p, args[i], variadic_type); - } - } else { - for (; i < arg_count; i++) { - args[i] = lb_emit_conv(p, args[i], default_type(args[i].type)); - } - } - } else if (variadic) { - isize i = 0; - for (; i < variadic_index; i++) { - Entity *e = param_tuple->variables[i]; - if (e->kind == Entity_Variable) { - args[i] = lb_emit_conv(p, args[i], e->type); - } - } - if (!vari_expand) { - Type *variadic_type = param_tuple->variables[i]->type; - GB_ASSERT(is_type_slice(variadic_type)); - variadic_type = base_type(variadic_type)->Slice.elem; - for (; i < arg_count; i++) { - args[i] = lb_emit_conv(p, args[i], variadic_type); - } - } - } else { - for (isize i = 0; i < param_count; i++) { - Entity *e = param_tuple->variables[i]; - if (e->kind == Entity_Variable) { - if (args[i].value == nullptr) { - continue; - } - GB_ASSERT_MSG(args[i].value != nullptr, "%.*s", LIT(e->token.string)); - args[i] = lb_emit_conv(p, args[i], e->type); - } - } - } - - if (variadic && !vari_expand && !is_c_vararg) { - // variadic call argument generation - Type *slice_type = param_tuple->variables[variadic_index]->type; - Type *elem_type = base_type(slice_type)->Slice.elem; - lbAddr slice = lb_add_local_generated(p, slice_type, true); - isize slice_len = arg_count+1 - (variadic_index+1); - - if (slice_len > 0) { - lbAddr base_array = lb_add_local_generated(p, alloc_type_array(elem_type, slice_len), true); - - for (isize i = variadic_index, j = 0; i < arg_count; i++, j++) { - lbValue addr = lb_emit_array_epi(p, base_array.addr, cast(i32)j); - lb_emit_store(p, addr, args[i]); - } - - lbValue base_elem = lb_emit_array_epi(p, base_array.addr, 0); - lbValue len = lb_const_int(m, t_int, slice_len); - lb_fill_slice(p, slice, base_elem, len); - } - - arg_count = param_count; - args[variadic_index] = lb_addr_load(p, slice); - } - } - - if (variadic && variadic_index+1 < param_count) { - for (isize i = variadic_index+1; i < param_count; i++) { - Entity *e = param_tuple->variables[i]; - args[i] = lb_handle_param_value(p, e->type, e->Variable.param_value, ast_token(expr).pos); - } - } - - isize final_count = param_count; - if (is_c_vararg) { - final_count = arg_count; - } - - if (param_tuple != nullptr) { - for (isize i = 0; i < gb_min(args.count, param_tuple->variables.count); i++) { - Entity *e = param_tuple->variables[i]; - if (args[i].type == nullptr) { continue; - } else if (is_type_untyped_nil(args[i].type)) { - args[i] = lb_const_nil(m, e->type); - } else if (is_type_untyped_undef(args[i].type)) { - args[i] = lb_const_undef(m, e->type); + } + + lbValue arg = args[arg_index]; + if (arg.value == nullptr) { + switch (e->kind) { + case Entity_TypeName: + args[arg_index] = lb_const_nil(p->module, e->type); + break; + case Entity_Variable: + args[arg_index] = lb_handle_param_value(p, e->type, e->Variable.param_value, pos); + break; + + case Entity_Constant: + args[arg_index] = lb_const_value(p->module, e->type, e->Constant.value); + break; + default: + GB_PANIC("Unknown entity kind %.*s\n", LIT(entity_strings[e->kind])); + } + } else { + args[arg_index] = lb_emit_conv(p, arg, e->type); } } } + isize final_count = is_c_vararg ? args.count : pt->param_count; auto call_args = array_slice(args, 0, final_count); return lb_emit_call(p, value, call_args, ce->inlining); } diff --git a/src/llvm_backend_stmt.cpp b/src/llvm_backend_stmt.cpp index 46144aa00..0702af42e 100644 --- a/src/llvm_backend_stmt.cpp +++ b/src/llvm_backend_stmt.cpp @@ -1,4 +1,4 @@ -void lb_build_constant_value_decl(lbProcedure *p, AstValueDecl *vd) { +gb_internal void lb_build_constant_value_decl(lbProcedure *p, AstValueDecl *vd) { if (vd == nullptr || vd->is_mutable) { return; } @@ -7,8 +7,7 @@ void lb_build_constant_value_decl(lbProcedure *p, AstValueDecl *vd) { static i32 global_guid = 0; - for_array(i, vd->names) { - Ast *ident = vd->names[i]; + for (Ast *ident : vd->names) { GB_ASSERT(ident->kind == Ast_Ident); Entity *e = entity_of_node(ident); GB_ASSERT(e != nullptr); @@ -33,7 +32,7 @@ void lb_build_constant_value_decl(lbProcedure *p, AstValueDecl *vd) { continue; } - lb_set_nested_type_name_ir_mangled_name(e, p); + lb_set_nested_type_name_ir_mangled_name(e, p, p->module); } for_array(i, vd->names) { @@ -51,21 +50,20 @@ void lb_build_constant_value_decl(lbProcedure *p, AstValueDecl *vd) { continue; // It's an alias } - CheckerInfo *info = p->module->info; DeclInfo *decl = decl_info_of_entity(e); ast_node(pl, ProcLit, decl->proc_lit); if (pl->body != nullptr) { - auto *found = map_get(&info->gen_procs, ident); - if (found) { - auto procs = *found; - for_array(i, procs) { - Entity *e = procs[i]; + GenProcsData *gpd = e->Procedure.gen_procs; + if (gpd) { + rw_mutex_shared_lock(&gpd->mutex); + for (Entity *e : gpd->procs) { if (!ptr_set_exists(min_dep_set, e)) { continue; } DeclInfo *d = decl_info_of_entity(e); lb_build_nested_proc(p, &d->proc_lit->ProcLit, e); } + rw_mutex_shared_unlock(&gpd->mutex); } else { lb_build_nested_proc(p, pl, e); } @@ -105,9 +103,8 @@ void lb_build_constant_value_decl(lbProcedure *p, AstValueDecl *vd) { } -void lb_build_stmt_list(lbProcedure *p, Slice const &stmts) { - for_array(i, stmts) { - Ast *stmt = stmts[i]; +gb_internal void lb_build_stmt_list(lbProcedure *p, Slice const &stmts) { + for (Ast *stmt : stmts) { switch (stmt->kind) { case_ast_node(vd, ValueDecl, stmt); lb_build_constant_value_decl(p, vd); @@ -118,21 +115,20 @@ void lb_build_stmt_list(lbProcedure *p, Slice const &stmts) { case_end; } } - for_array(i, stmts) { - lb_build_stmt(p, stmts[i]); + for (Ast *stmt : stmts) { + lb_build_stmt(p, stmt); } } -lbBranchBlocks lb_lookup_branch_blocks(lbProcedure *p, Ast *ident) { +gb_internal lbBranchBlocks lb_lookup_branch_blocks(lbProcedure *p, Ast *ident) { GB_ASSERT(ident->kind == Ast_Ident); Entity *e = entity_of_node(ident); GB_ASSERT(e->kind == Entity_Label); - for_array(i, p->branch_blocks) { - lbBranchBlocks *b = &p->branch_blocks[i]; - if (b->label == e->Label.node) { - return *b; + for (lbBranchBlocks const &b : p->branch_blocks) { + if (b.label == e->Label.node) { + return b; } } @@ -142,7 +138,7 @@ lbBranchBlocks lb_lookup_branch_blocks(lbProcedure *p, Ast *ident) { } -lbTargetList *lb_push_target_list(lbProcedure *p, Ast *label, lbBlock *break_, lbBlock *continue_, lbBlock *fallthrough_) { +gb_internal lbTargetList *lb_push_target_list(lbProcedure *p, Ast *label, lbBlock *break_, lbBlock *continue_, lbBlock *fallthrough_) { lbTargetList *tl = gb_alloc_item(permanent_allocator(), lbTargetList); tl->prev = p->target_list; tl->break_ = break_; @@ -153,13 +149,12 @@ lbTargetList *lb_push_target_list(lbProcedure *p, Ast *label, lbBlock *break_, l if (label != nullptr) { // Set label blocks GB_ASSERT(label->kind == Ast_Label); - for_array(i, p->branch_blocks) { - lbBranchBlocks *b = &p->branch_blocks[i]; - GB_ASSERT(b->label != nullptr && label != nullptr); - GB_ASSERT(b->label->kind == Ast_Label); - if (b->label == label) { - b->break_ = break_; - b->continue_ = continue_; + for (lbBranchBlocks &b : p->branch_blocks) { + GB_ASSERT(b.label != nullptr && label != nullptr); + GB_ASSERT(b.label->kind == Ast_Label); + if (b.label == label) { + b.break_ = break_; + b.continue_ = continue_; return tl; } } @@ -170,11 +165,11 @@ lbTargetList *lb_push_target_list(lbProcedure *p, Ast *label, lbBlock *break_, l return tl; } -void lb_pop_target_list(lbProcedure *p) { +gb_internal void lb_pop_target_list(lbProcedure *p) { p->target_list = p->target_list->prev; } -void lb_open_scope(lbProcedure *p, Scope *s) { +gb_internal void lb_open_scope(lbProcedure *p, Scope *s) { lbModule *m = p->module; if (m->debug_builder) { LLVMMetadataRef curr_metadata = lb_get_llvm_metadata(m, s); @@ -211,7 +206,7 @@ void lb_open_scope(lbProcedure *p, Scope *s) { } -void lb_close_scope(lbProcedure *p, lbDeferExitKind kind, lbBlock *block, bool pop_stack=true) { +gb_internal void lb_close_scope(lbProcedure *p, lbDeferExitKind kind, lbBlock *block, bool pop_stack=true) { lb_emit_defer_stmts(p, kind, block); GB_ASSERT(p->scope_index > 0); @@ -230,7 +225,7 @@ void lb_close_scope(lbProcedure *p, lbDeferExitKind kind, lbBlock *block, bool p array_pop(&p->scope_stack); } -void lb_build_when_stmt(lbProcedure *p, AstWhenStmt *ws) { +gb_internal void lb_build_when_stmt(lbProcedure *p, AstWhenStmt *ws) { TypeAndValue tv = type_and_value_of_expr(ws->cond); GB_ASSERT(is_type_boolean(tv.type)); GB_ASSERT(tv.value.kind == ExactValue_Bool); @@ -253,8 +248,9 @@ void lb_build_when_stmt(lbProcedure *p, AstWhenStmt *ws) { -void lb_build_range_indexed(lbProcedure *p, lbValue expr, Type *val_type, lbValue count_ptr, - lbValue *val_, lbValue *idx_, lbBlock **loop_, lbBlock **done_) { +gb_internal void lb_build_range_indexed(lbProcedure *p, lbValue expr, Type *val_type, lbValue count_ptr, + lbValue *val_, lbValue *idx_, lbBlock **loop_, lbBlock **done_, + bool is_reverse) { lbModule *m = p->module; lbValue count = {}; @@ -271,25 +267,78 @@ void lb_build_range_indexed(lbProcedure *p, lbValue expr, Type *val_type, lbValu lbBlock *done = nullptr; lbBlock *body = nullptr; - - lbAddr index = lb_add_local_generated(p, t_int, false); - lb_addr_store(p, index, lb_const_int(m, t_int, cast(u64)-1)); - loop = lb_create_block(p, "for.index.loop"); - lb_emit_jump(p, loop); - lb_start_block(p, loop); - - lbValue incr = lb_emit_arith(p, Token_Add, lb_addr_load(p, index), lb_const_int(m, t_int, 1), t_int); - lb_addr_store(p, index, incr); - body = lb_create_block(p, "for.index.body"); done = lb_create_block(p, "for.index.done"); - if (count.value == nullptr) { - GB_ASSERT(count_ptr.value != nullptr); - count = lb_emit_load(p, count_ptr); + + lbAddr index = lb_add_local_generated(p, t_int, false); + + if (!is_reverse) { + /* + for x, i in array { + ... + } + + i := -1 + for { + i += 1 + if !(i < len(array)) { + break + } + #no_bounds_check x := array[i] + ... + } + */ + + lb_addr_store(p, index, lb_const_int(m, t_int, cast(u64)-1)); + + lb_emit_jump(p, loop); + lb_start_block(p, loop); + + lbValue incr = lb_emit_arith(p, Token_Add, lb_addr_load(p, index), lb_const_int(m, t_int, 1), t_int); + lb_addr_store(p, index, incr); + + if (count.value == nullptr) { + GB_ASSERT(count_ptr.value != nullptr); + count = lb_emit_load(p, count_ptr); + } + lbValue cond = lb_emit_comp(p, Token_Lt, incr, count); + lb_emit_if(p, cond, body, done); + } else { + // NOTE(bill): REVERSED LOGIC + /* + #reverse for x, i in array { + ... + } + + i := len(array) + for { + i -= 1 + if i < 0 { + break + } + #no_bounds_check x := array[i] + ... + } + */ + + if (count.value == nullptr) { + GB_ASSERT(count_ptr.value != nullptr); + count = lb_emit_load(p, count_ptr); + } + count = lb_emit_conv(p, count, t_int); + lb_addr_store(p, index, count); + + lb_emit_jump(p, loop); + lb_start_block(p, loop); + + lbValue incr = lb_emit_arith(p, Token_Sub, lb_addr_load(p, index), lb_const_int(m, t_int, 1), t_int); + lb_addr_store(p, index, incr); + + lbValue anti_cond = lb_emit_comp(p, Token_Lt, incr, lb_const_int(m, t_int, 0)); + lb_emit_if(p, anti_cond, done, body); } - lbValue cond = lb_emit_comp(p, Token_Lt, incr, count); - lb_emit_if(p, cond, body, done); + lb_start_block(p, body); idx = lb_addr_load(p, index); @@ -342,7 +391,7 @@ void lb_build_range_indexed(lbProcedure *p, lbValue expr, Type *val_type, lbValu if (done_) *done_ = done; } -lbValue lb_map_cell_index_static(lbProcedure *p, Type *type, lbValue cells_ptr, lbValue index) { +gb_internal lbValue lb_map_cell_index_static(lbProcedure *p, Type *type, lbValue cells_ptr, lbValue index) { i64 size, len; i64 elem_sz = type_size_of(type); map_cell_size_and_len(type, &size, &len); @@ -378,17 +427,7 @@ lbValue lb_map_cell_index_static(lbProcedure *p, Type *type, lbValue cells_ptr, return lb_emit_ptr_offset(p, elems_ptr, data_index); } -void lb_map_kvh_data_static(lbProcedure *p, lbValue map_value, lbValue *ks_, lbValue *vs_, lbValue *hs_) { - lbValue capacity = lb_map_cap(p, map_value); - lbValue ks = lb_map_data_uintptr(p, map_value); - lbValue vs = {}; - lbValue hs = {}; - if (ks_) *ks_ = ks; - if (vs_) *vs_ = vs; - if (hs_) *hs_ = hs; -} - -lbValue lb_map_hash_is_valid(lbProcedure *p, lbValue hash) { +gb_internal lbValue lb_map_hash_is_valid(lbProcedure *p, lbValue hash) { // N :: size_of(uintptr)*8 - 1 // (hash != 0) & (hash>>N == 0) @@ -404,8 +443,8 @@ lbValue lb_map_hash_is_valid(lbProcedure *p, lbValue hash) { return lb_emit_arith(p, Token_And, not_deleted, not_empty, t_uintptr); } -void lb_build_range_map(lbProcedure *p, lbValue expr, Type *val_type, - lbValue *val_, lbValue *key_, lbBlock **loop_, lbBlock **done_) { +gb_internal void lb_build_range_map(lbProcedure *p, lbValue expr, Type *val_type, + lbValue *val_, lbValue *key_, lbBlock **loop_, lbBlock **done_) { lbModule *m = p->module; Type *type = base_type(type_deref(expr.type)); @@ -466,8 +505,9 @@ void lb_build_range_map(lbProcedure *p, lbValue expr, Type *val_type, -void lb_build_range_string(lbProcedure *p, lbValue expr, Type *val_type, - lbValue *val_, lbValue *idx_, lbBlock **loop_, lbBlock **done_) { +gb_internal void lb_build_range_string(lbProcedure *p, lbValue expr, Type *val_type, + lbValue *val_, lbValue *idx_, lbBlock **loop_, lbBlock **done_, + bool is_reverse) { lbModule *m = p->module; lbValue count = lb_const_int(m, t_int, 0); Type *expr_type = base_type(expr.type); @@ -486,35 +526,88 @@ void lb_build_range_string(lbProcedure *p, lbValue expr, Type *val_type, lbBlock *done = nullptr; lbBlock *body = nullptr; - - lbAddr offset_ = lb_add_local_generated(p, t_int, false); - lb_addr_store(p, offset_, lb_const_int(m, t_int, 0)); - loop = lb_create_block(p, "for.string.loop"); - lb_emit_jump(p, loop); - lb_start_block(p, loop); - - - body = lb_create_block(p, "for.string.body"); done = lb_create_block(p, "for.string.done"); - lbValue offset = lb_addr_load(p, offset_); - lbValue cond = lb_emit_comp(p, Token_Lt, offset, count); + lbAddr offset_ = lb_add_local_generated(p, t_int, false); + lbValue offset = {}; + lbValue cond = {}; + + if (!is_reverse) { + /* + for c, offset in str { + ... + } + + offset := 0 + for offset < len(str) { + c, _w := string_decode_rune(str[offset:]) + ... + offset += _w + } + */ + lb_addr_store(p, offset_, lb_const_int(m, t_int, 0)); + + lb_emit_jump(p, loop); + lb_start_block(p, loop); + + + offset = lb_addr_load(p, offset_); + cond = lb_emit_comp(p, Token_Lt, offset, count); + } else { + // NOTE(bill): REVERSED LOGIC + /* + #reverse for c, offset in str { + ... + } + + offset := len(str) + for offset > 0 { + c, _w := string_decode_last_rune(str[:offset]) + offset -= _w + ... + } + */ + lb_addr_store(p, offset_, count); + + lb_emit_jump(p, loop); + lb_start_block(p, loop); + + offset = lb_addr_load(p, offset_); + cond = lb_emit_comp(p, Token_Gt, offset, lb_const_int(m, t_int, 0)); + } lb_emit_if(p, cond, body, done); lb_start_block(p, body); - lbValue str_elem = lb_emit_ptr_offset(p, lb_string_elem(p, expr), offset); - lbValue str_len = lb_emit_arith(p, Token_Sub, count, offset, t_int); - auto args = array_make(permanent_allocator(), 1); - args[0] = lb_emit_string(p, str_elem, str_len); - lbValue rune_and_len = lb_emit_runtime_call(p, "string_decode_rune", args); - lbValue len = lb_emit_struct_ev(p, rune_and_len, 1); - lb_addr_store(p, offset_, lb_emit_arith(p, Token_Add, offset, len, t_int)); + lbValue rune_and_len = {}; + if (!is_reverse) { + lbValue str_elem = lb_emit_ptr_offset(p, lb_string_elem(p, expr), offset); + lbValue str_len = lb_emit_arith(p, Token_Sub, count, offset, t_int); + auto args = array_make(permanent_allocator(), 1); + args[0] = lb_emit_string(p, str_elem, str_len); + + rune_and_len = lb_emit_runtime_call(p, "string_decode_rune", args); + lbValue len = lb_emit_struct_ev(p, rune_and_len, 1); + lb_addr_store(p, offset_, lb_emit_arith(p, Token_Add, offset, len, t_int)); + + idx = offset; + } else { + // NOTE(bill): REVERSED LOGIC + lbValue str_elem = lb_string_elem(p, expr); + lbValue str_len = offset; + auto args = array_make(permanent_allocator(), 1); + args[0] = lb_emit_string(p, str_elem, str_len); + + rune_and_len = lb_emit_runtime_call(p, "string_decode_last_rune", args); + lbValue len = lb_emit_struct_ev(p, rune_and_len, 1); + lb_addr_store(p, offset_, lb_emit_arith(p, Token_Sub, offset, len, t_int)); + + idx = lb_addr_load(p, offset_); + } - idx = offset; if (val_type != nullptr) { val = lb_emit_struct_ev(p, rune_and_len, 0); } @@ -526,8 +619,8 @@ void lb_build_range_string(lbProcedure *p, lbValue expr, Type *val_type, } -void lb_build_range_interval(lbProcedure *p, AstBinaryExpr *node, - AstRangeStmt *rs, Scope *scope) { +gb_internal void lb_build_range_interval(lbProcedure *p, AstBinaryExpr *node, + AstRangeStmt *rs, Scope *scope) { bool ADD_EXTRA_WRAPPING_CHECK = true; lbModule *m = p->module; @@ -630,7 +723,7 @@ void lb_build_range_interval(lbProcedure *p, AstBinaryExpr *node, lb_start_block(p, done); } -void lb_build_range_enum(lbProcedure *p, Type *enum_type, Type *val_type, lbValue *val_, lbValue *idx_, lbBlock **loop_, lbBlock **done_) { +gb_internal void lb_build_range_enum(lbProcedure *p, Type *enum_type, Type *val_type, lbValue *val_, lbValue *idx_, lbBlock **loop_, lbBlock **done_) { lbModule *m = p->module; Type *t = enum_type; @@ -683,8 +776,8 @@ void lb_build_range_enum(lbProcedure *p, Type *enum_type, Type *val_type, lbValu if (done_) *done_ = done; } -void lb_build_range_tuple(lbProcedure *p, Ast *expr, Type *val0_type, Type *val1_type, - lbValue *val0_, lbValue *val1_, lbBlock **loop_, lbBlock **done_) { +gb_internal void lb_build_range_tuple(lbProcedure *p, Ast *expr, Type *val0_type, Type *val1_type, + lbValue *val0_, lbValue *val1_, lbBlock **loop_, lbBlock **done_) { lbBlock *loop = lb_create_block(p, "for.tuple.loop"); lb_emit_jump(p, loop); lb_start_block(p, loop); @@ -709,7 +802,7 @@ void lb_build_range_tuple(lbProcedure *p, Ast *expr, Type *val0_type, Type *val1 if (done_) *done_ = done; } -void lb_build_range_stmt_struct_soa(lbProcedure *p, AstRangeStmt *rs, Scope *scope) { +gb_internal void lb_build_range_stmt_struct_soa(lbProcedure *p, AstRangeStmt *rs, Scope *scope) { Ast *expr = unparen_expr(rs->expr); TypeAndValue tav = type_and_value_of_expr(expr); @@ -717,6 +810,8 @@ void lb_build_range_stmt_struct_soa(lbProcedure *p, AstRangeStmt *rs, Scope *sco lbBlock *body = nullptr; lbBlock *done = nullptr; + bool is_reverse = rs->reverse; + lb_open_scope(p, scope); @@ -738,20 +833,70 @@ void lb_build_range_stmt_struct_soa(lbProcedure *p, AstRangeStmt *rs, Scope *sco lbAddr index = lb_add_local_generated(p, t_int, false); - lb_addr_store(p, index, lb_const_int(p->module, t_int, cast(u64)-1)); - loop = lb_create_block(p, "for.soa.loop"); - lb_emit_jump(p, loop); - lb_start_block(p, loop); + if (!is_reverse) { + /* + for x, i in array { + ... + } - lbValue incr = lb_emit_arith(p, Token_Add, lb_addr_load(p, index), lb_const_int(p->module, t_int, 1), t_int); - lb_addr_store(p, index, incr); + i := -1 + for { + i += 1 + if !(i < len(array)) { + break + } + x := array[i] // but #soa-ified + ... + } + */ - body = lb_create_block(p, "for.soa.body"); - done = lb_create_block(p, "for.soa.done"); + lb_addr_store(p, index, lb_const_int(p->module, t_int, cast(u64)-1)); - lbValue cond = lb_emit_comp(p, Token_Lt, incr, count); - lb_emit_if(p, cond, body, done); + loop = lb_create_block(p, "for.soa.loop"); + lb_emit_jump(p, loop); + lb_start_block(p, loop); + + lbValue incr = lb_emit_arith(p, Token_Add, lb_addr_load(p, index), lb_const_int(p->module, t_int, 1), t_int); + lb_addr_store(p, index, incr); + + body = lb_create_block(p, "for.soa.body"); + done = lb_create_block(p, "for.soa.done"); + + lbValue cond = lb_emit_comp(p, Token_Lt, incr, count); + lb_emit_if(p, cond, body, done); + } else { + // NOTE(bill): REVERSED LOGIC + /* + #reverse for x, i in array { + ... + } + + i := len(array) + for { + i -= 1 + if i < 0 { + break + } + #no_bounds_check x := array[i] // but #soa-ified + ... + } + */ + lb_addr_store(p, index, count); + + loop = lb_create_block(p, "for.soa.loop"); + lb_emit_jump(p, loop); + lb_start_block(p, loop); + + lbValue incr = lb_emit_arith(p, Token_Sub, lb_addr_load(p, index), lb_const_int(p->module, t_int, 1), t_int); + lb_addr_store(p, index, incr); + + body = lb_create_block(p, "for.soa.body"); + done = lb_create_block(p, "for.soa.done"); + + lbValue cond = lb_emit_comp(p, Token_Lt, incr, lb_const_int(p->module, t_int, 0)); + lb_emit_if(p, cond, done, body); + } lb_start_block(p, body); @@ -778,7 +923,7 @@ void lb_build_range_stmt_struct_soa(lbProcedure *p, AstRangeStmt *rs, Scope *sco } -void lb_build_range_stmt(lbProcedure *p, AstRangeStmt *rs, Scope *scope) { +gb_internal void lb_build_range_stmt(lbProcedure *p, AstRangeStmt *rs, Scope *scope) { Ast *expr = unparen_expr(rs->expr); if (is_ast_range(expr)) { @@ -806,15 +951,6 @@ void lb_build_range_stmt(lbProcedure *p, AstRangeStmt *rs, Scope *scope) { val1_type = type_of_expr(rs->vals[1]); } - if (val0_type != nullptr) { - Entity *e = entity_of_node(rs->vals[0]); - lb_add_local(p, e->type, e, true); - } - if (val1_type != nullptr) { - Entity *e = entity_of_node(rs->vals[1]); - lb_add_local(p, e->type, e, true); - } - lbValue val = {}; lbValue key = {}; lbBlock *loop = nullptr; @@ -844,7 +980,7 @@ void lb_build_range_stmt(lbProcedure *p, AstRangeStmt *rs, Scope *scope) { } lbAddr count_ptr = lb_add_local_generated(p, t_int, false); lb_addr_store(p, count_ptr, lb_const_int(p->module, t_int, et->Array.count)); - lb_build_range_indexed(p, array, val0_type, count_ptr.addr, &val, &key, &loop, &done); + lb_build_range_indexed(p, array, val0_type, count_ptr.addr, &val, &key, &loop, &done, rs->reverse); break; } case Type_EnumeratedArray: { @@ -854,7 +990,7 @@ void lb_build_range_stmt(lbProcedure *p, AstRangeStmt *rs, Scope *scope) { } lbAddr count_ptr = lb_add_local_generated(p, t_int, false); lb_addr_store(p, count_ptr, lb_const_int(p->module, t_int, et->EnumeratedArray.count)); - lb_build_range_indexed(p, array, val0_type, count_ptr.addr, &val, &key, &loop, &done); + lb_build_range_indexed(p, array, val0_type, count_ptr.addr, &val, &key, &loop, &done, rs->reverse); break; } case Type_DynamicArray: { @@ -864,7 +1000,7 @@ void lb_build_range_stmt(lbProcedure *p, AstRangeStmt *rs, Scope *scope) { array = lb_emit_load(p, array); } count_ptr = lb_emit_struct_ep(p, array, 1); - lb_build_range_indexed(p, array, val0_type, count_ptr, &val, &key, &loop, &done); + lb_build_range_indexed(p, array, val0_type, count_ptr, &val, &key, &loop, &done, rs->reverse); break; } case Type_Slice: { @@ -877,7 +1013,7 @@ void lb_build_range_stmt(lbProcedure *p, AstRangeStmt *rs, Scope *scope) { count_ptr = lb_add_local_generated(p, t_int, false).addr; lb_emit_store(p, count_ptr, lb_slice_len(p, slice)); } - lb_build_range_indexed(p, slice, val0_type, count_ptr, &val, &key, &loop, &done); + lb_build_range_indexed(p, slice, val0_type, count_ptr, &val, &key, &loop, &done, rs->reverse); break; } case Type_Basic: { @@ -892,7 +1028,7 @@ void lb_build_range_stmt(lbProcedure *p, AstRangeStmt *rs, Scope *scope) { } Type *t = base_type(string.type); GB_ASSERT(!is_type_cstring(t)); - lb_build_range_string(p, string, val0_type, &val, &key, &loop, &done); + lb_build_range_string(p, string, val0_type, &val, &key, &loop, &done, rs->reverse); break; } case Type_Tuple: @@ -923,7 +1059,7 @@ void lb_build_range_stmt(lbProcedure *p, AstRangeStmt *rs, Scope *scope) { lb_start_block(p, done); } -void lb_build_unroll_range_stmt(lbProcedure *p, AstUnrollRangeStmt *rs, Scope *scope) { +gb_internal void lb_build_unroll_range_stmt(lbProcedure *p, AstUnrollRangeStmt *rs, Scope *scope) { lbModule *m = p->module; lb_open_scope(p, scope); // Open scope here @@ -1089,7 +1225,7 @@ void lb_build_unroll_range_stmt(lbProcedure *p, AstUnrollRangeStmt *rs, Scope *s lb_close_scope(p, lbDeferExit_Default, nullptr); } -bool lb_switch_stmt_can_be_trivial_jump_table(AstSwitchStmt *ss, bool *default_found_) { +gb_internal bool lb_switch_stmt_can_be_trivial_jump_table(AstSwitchStmt *ss, bool *default_found_) { if (ss->tag == nullptr) { return false; } @@ -1105,8 +1241,7 @@ bool lb_switch_stmt_can_be_trivial_jump_table(AstSwitchStmt *ss, bool *default_f } ast_node(body, BlockStmt, ss->body); - for_array(i, body->stmts) { - Ast *clause = body->stmts[i]; + for (Ast *clause : body->stmts) { ast_node(cc, CaseClause, clause); if (cc->list.count == 0) { @@ -1114,8 +1249,8 @@ bool lb_switch_stmt_can_be_trivial_jump_table(AstSwitchStmt *ss, bool *default_f continue; } - for_array(j, cc->list) { - Ast *expr = unparen_expr(cc->list[j]); + for (Ast *expr : cc->list) { + expr = unparen_expr(expr); if (is_ast_range(expr)) { return false; } @@ -1138,7 +1273,7 @@ bool lb_switch_stmt_can_be_trivial_jump_table(AstSwitchStmt *ss, bool *default_f } -void lb_build_switch_stmt(lbProcedure *p, AstSwitchStmt *ss, Scope *scope) { +gb_internal void lb_build_switch_stmt(lbProcedure *p, AstSwitchStmt *ss, Scope *scope) { lb_open_scope(p, scope); if (ss->init != nullptr) { @@ -1176,8 +1311,7 @@ void lb_build_switch_stmt(lbProcedure *p, AstSwitchStmt *ss, Scope *scope) { LLVMValueRef switch_instr = nullptr; if (is_trivial) { isize num_cases = 0; - for_array(i, body->stmts) { - Ast *clause = body->stmts[i]; + for (Ast *clause : body->stmts) { ast_node(cc, CaseClause, clause); num_cases += cc->list.count; } @@ -1214,8 +1348,8 @@ void lb_build_switch_stmt(lbProcedure *p, AstSwitchStmt *ss, Scope *scope) { } lbBlock *next_cond = nullptr; - for_array(j, cc->list) { - Ast *expr = unparen_expr(cc->list[j]); + for (Ast *expr : cc->list) { + expr = unparen_expr(expr); if (switch_instr != nullptr) { lbValue on_val = {}; @@ -1300,7 +1434,7 @@ void lb_build_switch_stmt(lbProcedure *p, AstSwitchStmt *ss, Scope *scope) { lb_close_scope(p, lbDeferExit_Default, done); } -void lb_store_type_case_implicit(lbProcedure *p, Ast *clause, lbValue value) { +gb_internal void lb_store_type_case_implicit(lbProcedure *p, Ast *clause, lbValue value) { Entity *e = implicit_entity_of_node(clause); GB_ASSERT(e != nullptr); if (e->flags & EntityFlag_Value) { @@ -1315,7 +1449,7 @@ void lb_store_type_case_implicit(lbProcedure *p, Ast *clause, lbValue value) { } } -lbAddr lb_store_range_stmt_val(lbProcedure *p, Ast *stmt_val, lbValue value) { +gb_internal lbAddr lb_store_range_stmt_val(lbProcedure *p, Ast *stmt_val, lbValue value) { Entity *e = entity_of_node(stmt_val); if (e == nullptr) { return {}; @@ -1325,6 +1459,7 @@ lbAddr lb_store_range_stmt_val(lbProcedure *p, Ast *stmt_val, lbValue value) { if (LLVMIsALoadInst(value.value)) { lbValue ptr = lb_address_from_load_or_generate_local(p, value); lb_add_entity(p->module, e, ptr); + lb_add_debug_local_variable(p, ptr.value, e->type, e->token); return lb_addr(ptr); } } @@ -1335,7 +1470,7 @@ lbAddr lb_store_range_stmt_val(lbProcedure *p, Ast *stmt_val, lbValue value) { return addr; } -void lb_type_case_body(lbProcedure *p, Ast *label, Ast *clause, lbBlock *body, lbBlock *done) { +gb_internal void lb_type_case_body(lbProcedure *p, Ast *label, Ast *clause, lbBlock *body, lbBlock *done) { ast_node(cc, CaseClause, clause); lb_push_target_list(p, label, done, nullptr, nullptr); @@ -1346,7 +1481,7 @@ void lb_type_case_body(lbProcedure *p, Ast *label, Ast *clause, lbBlock *body, l lb_emit_jump(p, done); } -void lb_build_type_switch_stmt(lbProcedure *p, AstTypeSwitchStmt *ss) { +gb_internal void lb_build_type_switch_stmt(lbProcedure *p, AstTypeSwitchStmt *ss) { lbModule *m = p->module; lb_open_scope(p, ss->scope); @@ -1394,8 +1529,7 @@ void lb_build_type_switch_stmt(lbProcedure *p, AstTypeSwitchStmt *ss) { lbBlock *default_block = nullptr; isize num_cases = 0; - for_array(i, body->stmts) { - Ast *clause = body->stmts[i]; + for (Ast *clause : body->stmts) { ast_node(cc, CaseClause, clause); num_cases += cc->list.count; if (cc->list.count == 0) { @@ -1415,8 +1549,55 @@ void lb_build_type_switch_stmt(lbProcedure *p, AstTypeSwitchStmt *ss) { switch_instr = LLVMBuildSwitch(p->builder, tag.value, else_block->block, cast(unsigned)num_cases); } - for_array(i, body->stmts) { - Ast *clause = body->stmts[i]; + bool all_by_reference = false; + for (Ast *clause : body->stmts) { + ast_node(cc, CaseClause, clause); + if (cc->list.count != 1) { + continue; + } + Entity *case_entity = implicit_entity_of_node(clause); + all_by_reference |= (case_entity->flags & EntityFlag_Value) == 0; + break; + } + + // NOTE(bill, 2023-02-17): In the case of a pass by value, the value does need to be copied + // to prevent errors such as these: + // + // switch v in some_union { + // case i32: + // fmt.println(v) // 'i32' + // some_union = f32(123) + // fmt.println(v) // if `v` is an implicit reference, then the data is now completely corrupted + // case f32: + // fmt.println(v) + // } + // + lbAddr backing_data = {}; + if (!all_by_reference) { + bool variants_found = false; + i64 max_size = 0; + i64 max_align = 1; + for (Ast *clause : body->stmts) { + ast_node(cc, CaseClause, clause); + if (cc->list.count != 1) { + continue; + } + Entity *case_entity = implicit_entity_of_node(clause); + if (!is_type_untyped_nil(case_entity->type)) { + max_size = gb_max(max_size, type_size_of(case_entity->type)); + max_align = gb_max(max_align, type_align_of(case_entity->type)); + variants_found = true; + } + } + if (variants_found) { + Type *t = alloc_type_array(t_u8, max_size); + backing_data = lb_add_local(p, t, nullptr, false, true); + GB_ASSERT(lb_try_update_alignment(backing_data.addr, cast(unsigned)max_align)); + } + } + lbValue backing_ptr = backing_data.addr; + + for (Ast *clause : body->stmts) { ast_node(cc, CaseClause, clause); lb_open_scope(p, cc->scope); if (cc->list.count == 0) { @@ -1430,16 +1611,22 @@ void lb_build_type_switch_stmt(lbProcedure *p, AstTypeSwitchStmt *ss) { if (p->debug_info != nullptr) { LLVMSetCurrentDebugLocation2(p->builder, lb_debug_location_from_ast(p, clause)); } - Type *case_type = nullptr; - for_array(type_index, cc->list) { - case_type = type_of_expr(cc->list[type_index]); + + bool saw_nil = false; + for (Ast *type_expr : cc->list) { + Type *case_type = type_of_expr(type_expr); lbValue on_val = {}; if (switch_kind == TypeSwitch_Union) { Type *ut = base_type(type_deref(parent.type)); on_val = lb_const_union_tag(m, ut, case_type); } else if (switch_kind == TypeSwitch_Any) { - on_val = lb_typeid(m, case_type); + if (is_type_untyped_nil(case_type)) { + saw_nil = true; + on_val = lb_const_nil(m, t_typeid); + } else { + on_val = lb_typeid(m, case_type); + } } GB_ASSERT(on_val.value != nullptr); LLVMAddCase(switch_instr, on_val.value, body->block); @@ -1447,13 +1634,11 @@ void lb_build_type_switch_stmt(lbProcedure *p, AstTypeSwitchStmt *ss) { Entity *case_entity = implicit_entity_of_node(clause); - lbValue value = parent_value; - lb_start_block(p, body); bool by_reference = (case_entity->flags & EntityFlag_Value) == 0; - if (cc->list.count == 1) { + if (cc->list.count == 1 && !saw_nil) { lbValue data = {}; if (switch_kind == TypeSwitch_Union) { data = union_data; @@ -1464,13 +1649,29 @@ void lb_build_type_switch_stmt(lbProcedure *p, AstTypeSwitchStmt *ss) { Type *ct = case_entity->type; Type *ct_ptr = alloc_type_pointer(ct); - value = lb_emit_conv(p, data, ct_ptr); - if (!by_reference) { - value = lb_emit_load(p, value); + lbValue ptr = {}; + + if (backing_data.addr.value) { // by value + GB_ASSERT(!by_reference); + // make a copy of the case value + lb_mem_copy_non_overlapping(p, + backing_ptr, // dst + data, // src + lb_const_int(p->module, t_int, type_size_of(case_entity->type))); + ptr = lb_emit_conv(p, backing_ptr, ct_ptr); + + } else { // by reference + GB_ASSERT(by_reference); + ptr = lb_emit_conv(p, data, ct_ptr); } + GB_ASSERT(are_types_identical(case_entity->type, type_deref(ptr.type))); + lb_add_entity(p->module, case_entity, ptr); + lb_add_debug_local_variable(p, ptr.value, case_entity->type, case_entity->token); + } else { + // TODO(bill): is the correct expected behaviour? + lb_store_type_case_implicit(p, clause, parent_value); } - lb_store_type_case_implicit(p, clause, value); lb_type_case_body(p, ss->label, clause, body, done); } @@ -1480,7 +1681,7 @@ void lb_build_type_switch_stmt(lbProcedure *p, AstTypeSwitchStmt *ss) { } -void lb_build_static_variables(lbProcedure *p, AstValueDecl *vd) { +gb_internal void lb_build_static_variables(lbProcedure *p, AstValueDecl *vd) { for_array(i, vd->names) { lbValue value = {}; if (vd->values.count > 0) { @@ -1543,13 +1744,14 @@ void lb_build_static_variables(lbProcedure *p, AstValueDecl *vd) { lb_add_member(p->module, mangled_name, global_val); } } -void lb_append_tuple_values(lbProcedure *p, Array *dst_values, lbValue src_value) { +gb_internal isize lb_append_tuple_values(lbProcedure *p, Array *dst_values, lbValue src_value) { + isize init_count = dst_values->count; Type *t = src_value.type; if (t->kind == Type_Tuple) { lbTupleFix *tf = map_get(&p->tuple_fix_map, src_value.value); if (tf) { - for_array(j, tf->values) { - array_add(dst_values, tf->values[j]); + for (lbValue const &value : tf->values) { + array_add(dst_values, value); } } else { for_array(i, t->Tuple.variables) { @@ -1560,31 +1762,44 @@ void lb_append_tuple_values(lbProcedure *p, Array *dst_values, lbValue } else { array_add(dst_values, src_value); } + return dst_values->count - init_count; } -void lb_build_assignment(lbProcedure *p, Array &lvals, Slice const &values) { +gb_internal void lb_build_assignment(lbProcedure *p, Array &lvals, Slice const &values) { if (values.count == 0) { return; } auto inits = array_make(permanent_allocator(), 0, lvals.count); - for_array(i, values) { - Ast *rhs = values[i]; + for (Ast *rhs : values) { lbValue init = lb_build_expr(p, rhs); lb_append_tuple_values(p, &inits, init); } + bool prev_in_assignment = p->in_multi_assignment; + + isize lval_count = 0; + for (lbAddr const &lval : lvals) { + if (lval.addr.value != nullptr) { + // check if it is not a blank identifier + lval_count += 1; + } + } + p->in_multi_assignment = lval_count > 1; + GB_ASSERT(lvals.count == inits.count); for_array(i, inits) { lbAddr lval = lvals[i]; lbValue init = inits[i]; lb_addr_store(p, lval, init); } + + p->in_multi_assignment = prev_in_assignment; } -void lb_build_return_stmt_internal(lbProcedure *p, lbValue res) { +gb_internal void lb_build_return_stmt_internal(lbProcedure *p, lbValue res) { lbFunctionType *ft = lb_get_function_type(p->module, p->type); bool return_by_pointer = ft->ret.kind == lbArg_Indirect; bool split_returns = ft->multiple_return_original_type != nullptr; @@ -1597,7 +1812,7 @@ void lb_build_return_stmt_internal(lbProcedure *p, lbValue res) { if (res.value != nullptr) { LLVMValueRef res_val = res.value; i64 sz = type_size_of(res.type); - if (LLVMIsALoadInst(res_val) && sz > build_context.word_size) { + if (LLVMIsALoadInst(res_val) && sz > build_context.int_size) { lbValue ptr = lb_address_from_load_or_generate_local(p, res); lb_mem_copy_non_overlapping(p, p->return_ptr.addr, ptr, lb_const_int(p->module, t_int, sz)); } else { @@ -1621,7 +1836,7 @@ void lb_build_return_stmt_internal(lbProcedure *p, lbValue res) { LLVMBuildRet(p->builder, ret_val); } } -void lb_build_return_stmt(lbProcedure *p, Slice const &return_results) { +gb_internal void lb_build_return_stmt(lbProcedure *p, Slice const &return_results) { lb_ensure_abi_function_type(p->module, p); lbValue res = {}; @@ -1765,7 +1980,7 @@ void lb_build_return_stmt(lbProcedure *p, Slice const &return_results) { lb_build_return_stmt_internal(p, res); } -void lb_build_if_stmt(lbProcedure *p, Ast *node) { +gb_internal void lb_build_if_stmt(lbProcedure *p, Ast *node) { ast_node(is, IfStmt, node); lb_open_scope(p, is->scope); // Scope #1 defer (lb_close_scope(p, lbDeferExit_Default, nullptr)); @@ -1852,7 +2067,7 @@ void lb_build_if_stmt(lbProcedure *p, Ast *node) { lb_start_block(p, done); } -void lb_build_for_stmt(lbProcedure *p, Ast *node) { +gb_internal void lb_build_for_stmt(lbProcedure *p, Ast *node) { ast_node(fs, ForStmt, node); lb_open_scope(p, fs->scope); // Open Scope here @@ -1912,7 +2127,7 @@ void lb_build_for_stmt(lbProcedure *p, Ast *node) { lb_close_scope(p, lbDeferExit_Default, nullptr); } -void lb_build_assign_stmt_array(lbProcedure *p, TokenKind op, lbAddr const &lhs, lbValue const &value) { +gb_internal void lb_build_assign_stmt_array(lbProcedure *p, TokenKind op, lbAddr const &lhs, lbValue const &value) { GB_ASSERT(op != Token_Eq); Type *lhs_type = lb_addr_type(lhs); @@ -1981,8 +2196,7 @@ void lb_build_assign_stmt_array(lbProcedure *p, TokenKind op, lbAddr const &lhs, auto indices_handled = slice_make(temporary_allocator(), bt->Array.count); auto indices = slice_make(temporary_allocator(), bt->Array.count); i32 index_count = 0; - for_array(i, lhs.swizzle_large.indices) { - i32 index = lhs.swizzle_large.indices[i]; + for (i32 index : lhs.swizzle_large.indices) { if (indices_handled[index]) { continue; } @@ -2055,12 +2269,11 @@ void lb_build_assign_stmt_array(lbProcedure *p, TokenKind op, lbAddr const &lhs, lb_loop_end(p, loop_data); } } -void lb_build_assign_stmt(lbProcedure *p, AstAssignStmt *as) { +gb_internal void lb_build_assign_stmt(lbProcedure *p, AstAssignStmt *as) { if (as->op.kind == Token_Eq) { auto lvals = array_make(permanent_allocator(), 0, as->lhs.count); - for_array(i, as->lhs) { - Ast *lhs = as->lhs[i]; + for (Ast *lhs : as->lhs) { lbAddr lval = {}; if (!is_blank_ident(lhs)) { lval = lb_build_addr(p, lhs); @@ -2070,6 +2283,7 @@ void lb_build_assign_stmt(lbProcedure *p, AstAssignStmt *as) { lb_build_assignment(p, lvals, as->rhs); return; } + GB_ASSERT(as->lhs.count == 1); GB_ASSERT(as->rhs.count == 1); // NOTE(bill): Only 1 += 1 is allowed, no tuples @@ -2113,7 +2327,7 @@ void lb_build_assign_stmt(lbProcedure *p, AstAssignStmt *as) { } -void lb_build_stmt(lbProcedure *p, Ast *node) { +gb_internal void lb_build_stmt(lbProcedure *p, Ast *node) { Ast *prev_stmt = p->curr_stmt; defer (p->curr_stmt = prev_stmt); p->curr_stmt = node; @@ -2195,12 +2409,12 @@ void lb_build_stmt(lbProcedure *p, Ast *node) { bool is_static = false; if (vd->names.count > 0) { - for_array(i, vd->names) { - Ast *name = vd->names[i]; + for (Ast *name : vd->names) { if (!is_blank_ident(name)) { + GB_ASSERT(name->kind == Ast_Ident); Entity *e = entity_of_node(name); TokenPos pos = ast_token(name).pos; - GB_ASSERT_MSG(e != nullptr, "%s", token_pos_to_string(pos)); + GB_ASSERT_MSG(e != nullptr, "\n%s missing entity for %.*s", token_pos_to_string(pos), LIT(name->Ident.token.string)); if (e->flags & EntityFlag_Static) { // NOTE(bill): If one of the entities is static, they all are is_static = true; @@ -2215,20 +2429,66 @@ void lb_build_stmt(lbProcedure *p, Ast *node) { return; } - auto lvals = array_make(permanent_allocator(), 0, vd->names.count); + TEMPORARY_ALLOCATOR_GUARD(); - for_array(i, vd->names) { - Ast *name = vd->names[i]; - lbAddr lval = {}; - if (!is_blank_ident(name)) { - Entity *e = entity_of_node(name); - // bool zero_init = true; // Always do it - bool zero_init = vd->values.count == 0; - lval = lb_add_local(p, e->type, e, zero_init); + auto const &values = vd->values; + if (values.count == 0) { + auto lvals = slice_make(temporary_allocator(), vd->names.count); + for_array(i, vd->names) { + Ast *name = vd->names[i]; + if (!is_blank_ident(name)) { + Entity *e = entity_of_node(name); + // bool zero_init = true; // Always do it + bool zero_init = values.count == 0; + lvals[i] = lb_add_local(p, e->type, e, zero_init); + } + } + } else { + auto lvals_preused = slice_make(temporary_allocator(), vd->names.count); + auto lvals = slice_make(temporary_allocator(), vd->names.count); + auto inits = array_make(temporary_allocator(), 0, lvals.count); + + isize lval_index = 0; + for (Ast *rhs : values) { + rhs = unparen_expr(rhs); + lbValue init = lb_build_expr(p, rhs); + + if (rhs->kind == Ast_CompoundLit) { + // NOTE(bill, 2023-02-17): lb_const_value might produce a stack local variable for the + // compound literal, so reusing that variable should minimize the stack wastage + lbAddr *comp_lit_addr = map_get(&p->module->exact_value_compound_literal_addr_map, rhs); + if (comp_lit_addr) { + if (Entity *e = entity_of_node(vd->names[lval_index])) { + lbValue val = comp_lit_addr->addr; + lb_add_entity(p->module, e, val); + lb_add_debug_local_variable(p, val.value, e->type, e->token); + lvals_preused[lval_index] = true; + lvals[lval_index] = *comp_lit_addr; + } + } + } + + lval_index += lb_append_tuple_values(p, &inits, init); + } + GB_ASSERT(lval_index == lvals.count); + + + for_array(i, vd->names) { + Ast *name = vd->names[i]; + if (!is_blank_ident(name) && !lvals_preused[i]) { + Entity *e = entity_of_node(name); + bool zero_init = values.count == 0; + lvals[i] = lb_add_local(p, e->type, e, zero_init); + } + } + + GB_ASSERT(lvals.count == inits.count); + for_array(i, inits) { + lbAddr lval = lvals[i]; + lbValue init = inits[i]; + lb_addr_store(p, lval, init); } - array_add(&lvals, lval); } - lb_build_assignment(p, lvals, vd->values); case_end; case_ast_node(as, AssignStmt, node); @@ -2308,7 +2568,7 @@ void lb_build_stmt(lbProcedure *p, Ast *node) { -void lb_build_defer_stmt(lbProcedure *p, lbDefer const &d) { +gb_internal void lb_build_defer_stmt(lbProcedure *p, lbDefer const &d) { if (p->curr_block == nullptr) { return; } @@ -2337,7 +2597,7 @@ void lb_build_defer_stmt(lbProcedure *p, lbDefer const &d) { } } -void lb_emit_defer_stmts(lbProcedure *p, lbDeferExitKind kind, lbBlock *block) { +gb_internal void lb_emit_defer_stmts(lbProcedure *p, lbDeferExitKind kind, lbBlock *block) { isize count = p->defer_stmts.count; isize i = count; while (i --> 0) { @@ -2345,7 +2605,7 @@ void lb_emit_defer_stmts(lbProcedure *p, lbDeferExitKind kind, lbBlock *block) { if (kind == lbDeferExit_Default) { if (p->scope_index == d.scope_index && - d.scope_index > 0) { // TODO(bill): Which is correct: > 0 or > 1? + d.scope_index > 0) { lb_build_defer_stmt(p, d); array_pop(&p->defer_stmts); continue; @@ -2364,7 +2624,7 @@ void lb_emit_defer_stmts(lbProcedure *p, lbDeferExitKind kind, lbBlock *block) { } } -void lb_add_defer_node(lbProcedure *p, isize scope_index, Ast *stmt) { +gb_internal void lb_add_defer_node(lbProcedure *p, isize scope_index, Ast *stmt) { Type *pt = base_type(p->type); GB_ASSERT(pt->kind == Type_Proc); if (pt->Proc.calling_convention == ProcCC_Odin) { @@ -2379,7 +2639,7 @@ void lb_add_defer_node(lbProcedure *p, isize scope_index, Ast *stmt) { d->stmt = stmt; } -void lb_add_defer_proc(lbProcedure *p, isize scope_index, lbValue deferred, Array const &result_as_args) { +gb_internal void lb_add_defer_proc(lbProcedure *p, isize scope_index, lbValue deferred, Array const &result_as_args) { Type *pt = base_type(p->type); GB_ASSERT(pt->kind == Type_Proc); if (pt->Proc.calling_convention == ProcCC_Odin) { diff --git a/src/llvm_backend_type.cpp b/src/llvm_backend_type.cpp index 307d9304b..a54fde748 100644 --- a/src/llvm_backend_type.cpp +++ b/src/llvm_backend_type.cpp @@ -1,10 +1,11 @@ -isize lb_type_info_index(CheckerInfo *info, Type *type, bool err_on_not_found=true) { +gb_internal isize lb_type_info_index(CheckerInfo *info, Type *type, bool err_on_not_found=true) { auto *set = &info->minimum_dependency_type_info_set; isize index = type_info_index(info, type, err_on_not_found); if (index >= 0) { - isize i = ptr_entry_index(set, index); - if (i >= 0) { - return i+1; + auto *found = map_get(set, index); + if (found) { + GB_ASSERT(*found >= 0); + return *found + 1; } } if (err_on_not_found) { @@ -13,8 +14,8 @@ isize lb_type_info_index(CheckerInfo *info, Type *type, bool err_on_not_found=tr return -1; } -lbValue lb_typeid(lbModule *m, Type *type) { - GB_ASSERT(!build_context.disallow_rtti); +gb_internal lbValue lb_typeid(lbModule *m, Type *type) { + GB_ASSERT(!build_context.no_rtti); type = default_type(type); @@ -67,21 +68,21 @@ lbValue lb_typeid(lbModule *m, Type *type) { } u64 data = 0; - if (build_context.word_size == 4) { + if (build_context.ptr_size == 4) { GB_ASSERT(id <= (1u<<24u)); data |= (id &~ (1u<<24)) << 0u; // index data |= (kind &~ (1u<<5)) << 24u; // kind - data |= (named &~ (1u<<1)) << 29u; // kind - data |= (special &~ (1u<<1)) << 30u; // kind - data |= (reserved &~ (1u<<1)) << 31u; // kind + data |= (named &~ (1u<<1)) << 29u; // named + data |= (special &~ (1u<<1)) << 30u; // special + data |= (reserved &~ (1u<<1)) << 31u; // reserved } else { - GB_ASSERT(build_context.word_size == 8); + GB_ASSERT(build_context.ptr_size == 8); GB_ASSERT(id <= (1ull<<56u)); data |= (id &~ (1ull<<56)) << 0ul; // index data |= (kind &~ (1ull<<5)) << 56ull; // kind - data |= (named &~ (1ull<<1)) << 61ull; // kind - data |= (special &~ (1ull<<1)) << 62ull; // kind - data |= (reserved &~ (1ull<<1)) << 63ull; // kind + data |= (named &~ (1ull<<1)) << 61ull; // named + data |= (special &~ (1ull<<1)) << 62ull; // special + data |= (reserved &~ (1ull<<1)) << 63ull; // reserved } lbValue res = {}; @@ -90,8 +91,8 @@ lbValue lb_typeid(lbModule *m, Type *type) { return res; } -lbValue lb_type_info(lbModule *m, Type *type) { - GB_ASSERT(!build_context.disallow_rtti); +gb_internal lbValue lb_type_info(lbModule *m, Type *type) { + GB_ASSERT(!build_context.no_rtti); type = default_type(type); @@ -102,36 +103,36 @@ lbValue lb_type_info(lbModule *m, Type *type) { return lb_emit_array_epi(m, data, index); } -LLVMTypeRef lb_get_procedure_raw_type(lbModule *m, Type *type) { +gb_internal LLVMTypeRef lb_get_procedure_raw_type(lbModule *m, Type *type) { return lb_type_internal_for_procedures_raw(m, type); } -lbValue lb_type_info_member_types_offset(lbProcedure *p, isize count) { +gb_internal lbValue lb_type_info_member_types_offset(lbProcedure *p, isize count) { GB_ASSERT(p->module == &p->module->gen->default_module); lbValue offset = lb_emit_array_epi(p, lb_global_type_info_member_types.addr, lb_global_type_info_member_types_index); lb_global_type_info_member_types_index += cast(i32)count; return offset; } -lbValue lb_type_info_member_names_offset(lbProcedure *p, isize count) { +gb_internal lbValue lb_type_info_member_names_offset(lbProcedure *p, isize count) { GB_ASSERT(p->module == &p->module->gen->default_module); lbValue offset = lb_emit_array_epi(p, lb_global_type_info_member_names.addr, lb_global_type_info_member_names_index); lb_global_type_info_member_names_index += cast(i32)count; return offset; } -lbValue lb_type_info_member_offsets_offset(lbProcedure *p, isize count) { +gb_internal lbValue lb_type_info_member_offsets_offset(lbProcedure *p, isize count) { GB_ASSERT(p->module == &p->module->gen->default_module); lbValue offset = lb_emit_array_epi(p, lb_global_type_info_member_offsets.addr, lb_global_type_info_member_offsets_index); lb_global_type_info_member_offsets_index += cast(i32)count; return offset; } -lbValue lb_type_info_member_usings_offset(lbProcedure *p, isize count) { +gb_internal lbValue lb_type_info_member_usings_offset(lbProcedure *p, isize count) { GB_ASSERT(p->module == &p->module->gen->default_module); lbValue offset = lb_emit_array_epi(p, lb_global_type_info_member_usings.addr, lb_global_type_info_member_usings_index); lb_global_type_info_member_usings_index += cast(i32)count; return offset; } -lbValue lb_type_info_member_tags_offset(lbProcedure *p, isize count) { +gb_internal lbValue lb_type_info_member_tags_offset(lbProcedure *p, isize count) { GB_ASSERT(p->module == &p->module->gen->default_module); lbValue offset = lb_emit_array_epi(p, lb_global_type_info_member_tags.addr, lb_global_type_info_member_tags_index); lb_global_type_info_member_tags_index += cast(i32)count; @@ -139,8 +140,8 @@ lbValue lb_type_info_member_tags_offset(lbProcedure *p, isize count) { } -void lb_setup_type_info_data(lbProcedure *p) { // NOTE(bill): Setup type_info data - if (build_context.disallow_rtti) { +gb_internal void lb_setup_type_info_data(lbProcedure *p) { // NOTE(bill): Setup type_info data + if (build_context.no_rtti) { return; } @@ -156,11 +157,11 @@ void lb_setup_type_info_data(lbProcedure *p) { // NOTE(bill): Setup type_info da global_type_info_data_entity_count = type->Array.count; LLVMValueRef indices[2] = {llvm_zero(m), llvm_zero(m)}; - LLVMValueRef values[2] = { - LLVMConstInBoundsGEP2(lb_type(m, lb_global_type_info_data_entity->type), lb_global_type_info_data_ptr(m).value, indices, gb_count_of(indices)), - LLVMConstInt(lb_type(m, t_int), type->Array.count, true), - }; - LLVMValueRef slice = llvm_const_named_struct_internal(lb_type(m, type_deref(global_type_table.type)), values, gb_count_of(values)); + LLVMValueRef data = LLVMConstInBoundsGEP2(lb_type(m, lb_global_type_info_data_entity->type), lb_global_type_info_data_ptr(m).value, indices, gb_count_of(indices)); + LLVMValueRef len = LLVMConstInt(lb_type(m, t_int), type->Array.count, true); + Type *t = type_deref(global_type_table.type); + GB_ASSERT(is_type_slice(t)); + LLVMValueRef slice = llvm_const_slice_internal(m, data, len); LLVMSetInitializer(global_type_table.value, slice); } @@ -185,7 +186,7 @@ void lb_setup_type_info_data(lbProcedure *p) { // NOTE(bill): Setup type_info da if (entry_index <= 0) { continue; } - + if (entries_handled[entry_index]) { continue; } @@ -540,8 +541,7 @@ void lb_setup_type_info_data(lbProcedure *p) { // NOTE(bill): Setup type_info da break; } case Type_Tuple: { - tag = lb_const_ptr_cast(m, variant_ptr, t_type_info_tuple_ptr); - + tag = lb_const_ptr_cast(m, variant_ptr, t_type_info_parameters_ptr); lbValue memory_types = lb_type_info_member_types_offset(p, t->Tuple.variables.count); lbValue memory_names = lb_type_info_member_names_offset(p, t->Tuple.variables.count); @@ -691,32 +691,34 @@ void lb_setup_type_info_data(lbProcedure *p) { // NOTE(bill): Setup type_info da case Type_Struct: { tag = lb_const_ptr_cast(m, variant_ptr, t_type_info_struct_ptr); - LLVMValueRef vals[12] = {}; + LLVMValueRef vals[13] = {}; { lbValue is_packed = lb_const_bool(m, t_bool, t->Struct.is_packed); lbValue is_raw_union = lb_const_bool(m, t_bool, t->Struct.is_raw_union); + lbValue is_no_copy = lb_const_bool(m, t_bool, t->Struct.is_no_copy); lbValue is_custom_align = lb_const_bool(m, t_bool, t->Struct.custom_align != 0); vals[5] = is_packed.value; vals[6] = is_raw_union.value; - vals[7] = is_custom_align.value; + vals[7] = is_no_copy.value; + vals[8] = is_custom_align.value; if (is_type_comparable(t) && !is_type_simple_compare(t)) { - vals[8] = lb_equal_proc_for_type(m, t).value; + vals[9] = lb_equal_proc_for_type(m, t).value; } if (t->Struct.soa_kind != StructSoa_None) { - lbValue kind = lb_emit_struct_ep(p, tag, 9); + lbValue kind = lb_emit_struct_ep(p, tag, 10); Type *kind_type = type_deref(kind.type); lbValue soa_kind = lb_const_value(m, kind_type, exact_value_i64(t->Struct.soa_kind)); lbValue soa_type = lb_type_info(m, t->Struct.soa_elem); lbValue soa_len = lb_const_int(m, t_int, t->Struct.soa_count); - vals[9] = soa_kind.value; - vals[10] = soa_type.value; - vals[11] = soa_len.value; + vals[10] = soa_kind.value; + vals[11] = soa_type.value; + vals[12] = soa_len.value; } } diff --git a/src/llvm_backend_utility.cpp b/src/llvm_backend_utility.cpp index 3ae9aba8f..2ecad1703 100644 --- a/src/llvm_backend_utility.cpp +++ b/src/llvm_backend_utility.cpp @@ -1,6 +1,6 @@ -lbValue lb_lookup_runtime_procedure(lbModule *m, String const &name); +gb_internal lbValue lb_lookup_runtime_procedure(lbModule *m, String const &name); -bool lb_is_type_aggregate(Type *t) { +gb_internal bool lb_is_type_aggregate(Type *t) { t = base_type(t); switch (t->kind) { case Type_Basic: @@ -39,7 +39,7 @@ bool lb_is_type_aggregate(Type *t) { return false; } -void lb_emit_unreachable(lbProcedure *p) { +gb_internal void lb_emit_unreachable(lbProcedure *p) { LLVMValueRef instr = LLVMGetLastInstruction(p->curr_block->block); if (instr == nullptr || !lb_is_instr_terminating(instr)) { lb_call_intrinsic(p, "llvm.trap", nullptr, 0, nullptr, 0); @@ -47,7 +47,7 @@ void lb_emit_unreachable(lbProcedure *p) { } } -lbValue lb_correct_endianness(lbProcedure *p, lbValue value) { +gb_internal lbValue lb_correct_endianness(lbProcedure *p, lbValue value) { Type *src = core_type(value.type); GB_ASSERT(is_type_integer(src) || is_type_float(src)); if (is_type_different_to_arch_endianness(src)) { @@ -57,7 +57,7 @@ lbValue lb_correct_endianness(lbProcedure *p, lbValue value) { return value; } -LLVMValueRef lb_mem_zero_ptr_internal(lbProcedure *p, LLVMValueRef ptr, LLVMValueRef len, unsigned alignment, bool is_volatile) { +gb_internal LLVMValueRef lb_mem_zero_ptr_internal(lbProcedure *p, LLVMValueRef ptr, LLVMValueRef len, unsigned alignment, bool is_volatile) { bool is_inlinable = false; i64 const_len = 0; @@ -103,7 +103,7 @@ LLVMValueRef lb_mem_zero_ptr_internal(lbProcedure *p, LLVMValueRef ptr, LLVMValu } -void lb_mem_zero_ptr(lbProcedure *p, LLVMValueRef ptr, Type *type, unsigned alignment) { +gb_internal void lb_mem_zero_ptr(lbProcedure *p, LLVMValueRef ptr, Type *type, unsigned alignment) { LLVMTypeRef llvm_type = lb_type(p->module, type); LLVMTypeKind kind = LLVMGetTypeKind(llvm_type); @@ -123,7 +123,7 @@ void lb_mem_zero_ptr(lbProcedure *p, LLVMValueRef ptr, Type *type, unsigned alig } } -lbValue lb_emit_select(lbProcedure *p, lbValue cond, lbValue x, lbValue y) { +gb_internal lbValue lb_emit_select(lbProcedure *p, lbValue cond, lbValue x, lbValue y) { cond = lb_emit_conv(p, cond, t_llvm_bool); lbValue res = {}; res.value = LLVMBuildSelect(p->builder, cond.value, x.value, y.value, ""); @@ -131,19 +131,19 @@ lbValue lb_emit_select(lbProcedure *p, lbValue cond, lbValue x, lbValue y) { return res; } -lbValue lb_emit_min(lbProcedure *p, Type *t, lbValue x, lbValue y) { +gb_internal lbValue lb_emit_min(lbProcedure *p, Type *t, lbValue x, lbValue y) { x = lb_emit_conv(p, x, t); y = lb_emit_conv(p, y, t); return lb_emit_select(p, lb_emit_comp(p, Token_Lt, x, y), x, y); } -lbValue lb_emit_max(lbProcedure *p, Type *t, lbValue x, lbValue y) { +gb_internal lbValue lb_emit_max(lbProcedure *p, Type *t, lbValue x, lbValue y) { x = lb_emit_conv(p, x, t); y = lb_emit_conv(p, y, t); return lb_emit_select(p, lb_emit_comp(p, Token_Gt, x, y), x, y); } -lbValue lb_emit_clamp(lbProcedure *p, Type *t, lbValue x, lbValue min, lbValue max) { +gb_internal lbValue lb_emit_clamp(lbProcedure *p, Type *t, lbValue x, lbValue min, lbValue max) { lbValue z = {}; z = lb_emit_max(p, t, x, min); z = lb_emit_min(p, t, z, max); @@ -152,7 +152,7 @@ lbValue lb_emit_clamp(lbProcedure *p, Type *t, lbValue x, lbValue min, lbValue m -lbValue lb_emit_string(lbProcedure *p, lbValue str_elem, lbValue str_len) { +gb_internal lbValue lb_emit_string(lbProcedure *p, lbValue str_elem, lbValue str_len) { if (false && lb_is_const(str_elem) && lb_is_const(str_len)) { LLVMValueRef values[2] = { str_elem.value, @@ -171,7 +171,7 @@ lbValue lb_emit_string(lbProcedure *p, lbValue str_elem, lbValue str_len) { } -lbValue lb_emit_transmute(lbProcedure *p, lbValue value, Type *t) { +gb_internal lbValue lb_emit_transmute(lbProcedure *p, lbValue value, Type *t) { Type *src_type = value.type; if (are_types_identical(t, src_type)) { return value; @@ -259,7 +259,7 @@ lbValue lb_emit_transmute(lbProcedure *p, lbValue value, Type *t) { return res; } -lbValue lb_copy_value_to_ptr(lbProcedure *p, lbValue val, Type *new_type, i64 alignment) { +gb_internal lbValue lb_copy_value_to_ptr(lbProcedure *p, lbValue val, Type *new_type, i64 alignment) { i64 type_alignment = type_align_of(new_type); if (alignment < type_alignment) { alignment = type_alignment; @@ -274,7 +274,7 @@ lbValue lb_copy_value_to_ptr(lbProcedure *p, lbValue val, Type *new_type, i64 al } -lbValue lb_soa_zip(lbProcedure *p, AstCallExpr *ce, TypeAndValue const &tv) { +gb_internal lbValue lb_soa_zip(lbProcedure *p, AstCallExpr *ce, TypeAndValue const &tv) { GB_ASSERT(ce->args.count > 0); auto slices = slice_make(temporary_allocator(), ce->args.count); @@ -305,7 +305,7 @@ lbValue lb_soa_zip(lbProcedure *p, AstCallExpr *ce, TypeAndValue const &tv) { return lb_addr_load(p, res); } -lbValue lb_soa_unzip(lbProcedure *p, AstCallExpr *ce, TypeAndValue const &tv) { +gb_internal lbValue lb_soa_unzip(lbProcedure *p, AstCallExpr *ce, TypeAndValue const &tv) { GB_ASSERT(ce->args.count == 1); lbValue arg = lb_build_expr(p, ce->args[0]); @@ -331,7 +331,7 @@ lbValue lb_soa_unzip(lbProcedure *p, AstCallExpr *ce, TypeAndValue const &tv) { return lb_addr_load(p, res); } -void lb_emit_try_lhs_rhs(lbProcedure *p, Ast *arg, TypeAndValue const &tv, lbValue *lhs_, lbValue *rhs_) { +gb_internal void lb_emit_try_lhs_rhs(lbProcedure *p, Ast *arg, TypeAndValue const &tv, lbValue *lhs_, lbValue *rhs_) { lbValue lhs = {}; lbValue rhs = {}; @@ -360,7 +360,7 @@ void lb_emit_try_lhs_rhs(lbProcedure *p, Ast *arg, TypeAndValue const &tv, lbVal } -lbValue lb_emit_try_has_value(lbProcedure *p, lbValue rhs) { +gb_internal lbValue lb_emit_try_has_value(lbProcedure *p, lbValue rhs) { lbValue has_value = {}; if (is_type_boolean(rhs.type)) { has_value = rhs; @@ -373,7 +373,7 @@ lbValue lb_emit_try_has_value(lbProcedure *p, lbValue rhs) { } -lbValue lb_emit_or_else(lbProcedure *p, Ast *arg, Ast *else_expr, TypeAndValue const &tv) { +gb_internal lbValue lb_emit_or_else(lbProcedure *p, Ast *arg, Ast *else_expr, TypeAndValue const &tv) { if (arg->state_flags & StateFlag_DirectiveWasFalse) { return lb_build_expr(p, else_expr); } @@ -435,10 +435,10 @@ lbValue lb_emit_or_else(lbProcedure *p, Ast *arg, Ast *else_expr, TypeAndValue c } } -void lb_build_return_stmt(lbProcedure *p, Slice const &return_results); -void lb_build_return_stmt_internal(lbProcedure *p, lbValue res); +gb_internal void lb_build_return_stmt(lbProcedure *p, Slice const &return_results); +gb_internal void lb_build_return_stmt_internal(lbProcedure *p, lbValue res); -lbValue lb_emit_or_return(lbProcedure *p, Ast *arg, TypeAndValue const &tv) { +gb_internal lbValue lb_emit_or_return(lbProcedure *p, Ast *arg, TypeAndValue const &tv) { lbValue lhs = {}; lbValue rhs = {}; lb_emit_try_lhs_rhs(p, arg, tv, &lhs, &rhs); @@ -479,7 +479,7 @@ lbValue lb_emit_or_return(lbProcedure *p, Ast *arg, TypeAndValue const &tv) { } -void lb_emit_increment(lbProcedure *p, lbValue addr) { +gb_internal void lb_emit_increment(lbProcedure *p, lbValue addr) { GB_ASSERT(is_type_pointer(addr.type)); Type *type = type_deref(addr.type); lbValue v_one = lb_const_value(p->module, type, exact_value_i64(1)); @@ -487,7 +487,7 @@ void lb_emit_increment(lbProcedure *p, lbValue addr) { } -lbValue lb_emit_byte_swap(lbProcedure *p, lbValue value, Type *end_type) { +gb_internal lbValue lb_emit_byte_swap(lbProcedure *p, lbValue value, Type *end_type) { GB_ASSERT(type_size_of(value.type) == type_size_of(end_type)); if (type_size_of(value.type) < 2) { @@ -526,7 +526,7 @@ lbValue lb_emit_byte_swap(lbProcedure *p, lbValue value, Type *end_type) { -lbValue lb_emit_count_ones(lbProcedure *p, lbValue x, Type *type) { +gb_internal lbValue lb_emit_count_ones(lbProcedure *p, lbValue x, Type *type) { x = lb_emit_conv(p, x, type); char const *name = "llvm.ctpop"; @@ -539,7 +539,7 @@ lbValue lb_emit_count_ones(lbProcedure *p, lbValue x, Type *type) { return res; } -lbValue lb_emit_count_zeros(lbProcedure *p, lbValue x, Type *type) { +gb_internal lbValue lb_emit_count_zeros(lbProcedure *p, lbValue x, Type *type) { Type *elem = base_array_type(type); i64 sz = 8*type_size_of(elem); lbValue size = lb_const_int(p->module, elem, cast(u64)sz); @@ -550,7 +550,7 @@ lbValue lb_emit_count_zeros(lbProcedure *p, lbValue x, Type *type) { -lbValue lb_emit_count_trailing_zeros(lbProcedure *p, lbValue x, Type *type) { +gb_internal lbValue lb_emit_count_trailing_zeros(lbProcedure *p, lbValue x, Type *type) { x = lb_emit_conv(p, x, type); char const *name = "llvm.cttz"; @@ -566,7 +566,7 @@ lbValue lb_emit_count_trailing_zeros(lbProcedure *p, lbValue x, Type *type) { return res; } -lbValue lb_emit_count_leading_zeros(lbProcedure *p, lbValue x, Type *type) { +gb_internal lbValue lb_emit_count_leading_zeros(lbProcedure *p, lbValue x, Type *type) { x = lb_emit_conv(p, x, type); char const *name = "llvm.ctlz"; @@ -584,7 +584,7 @@ lbValue lb_emit_count_leading_zeros(lbProcedure *p, lbValue x, Type *type) { -lbValue lb_emit_reverse_bits(lbProcedure *p, lbValue x, Type *type) { +gb_internal lbValue lb_emit_reverse_bits(lbProcedure *p, lbValue x, Type *type) { x = lb_emit_conv(p, x, type); char const *name = "llvm.bitreverse"; @@ -599,15 +599,7 @@ lbValue lb_emit_reverse_bits(lbProcedure *p, lbValue x, Type *type) { } -lbValue lb_emit_bit_set_card(lbProcedure *p, lbValue x) { - GB_ASSERT(is_type_bit_set(x.type)); - Type *underlying = bit_set_to_int(x.type); - lbValue card = lb_emit_count_ones(p, x, underlying); - return lb_emit_conv(p, card, t_int); -} - - -lbValue lb_emit_union_cast_only_ok_check(lbProcedure *p, lbValue value, Type *type, TokenPos pos) { +gb_internal lbValue lb_emit_union_cast_only_ok_check(lbProcedure *p, lbValue value, Type *type, TokenPos pos) { GB_ASSERT(is_type_tuple(type)); lbModule *m = p->module; @@ -654,7 +646,7 @@ lbValue lb_emit_union_cast_only_ok_check(lbProcedure *p, lbValue value, Type *ty return lb_addr_load(p, v); } -lbValue lb_emit_union_cast(lbProcedure *p, lbValue value, Type *type, TokenPos pos) { +gb_internal lbValue lb_emit_union_cast(lbProcedure *p, lbValue value, Type *type, TokenPos pos) { lbModule *m = p->module; Type *src_type = value.type; @@ -729,7 +721,7 @@ lbValue lb_emit_union_cast(lbProcedure *p, lbValue value, Type *type, TokenPos p Type *dst_type = tuple->Tuple.variables[0]->type; isize arg_count = 7; - if (build_context.disallow_rtti) { + if (build_context.no_rtti) { arg_count = 4; } @@ -741,7 +733,7 @@ lbValue lb_emit_union_cast(lbProcedure *p, lbValue value, Type *type, TokenPos p args[2] = lb_const_int(m, t_i32, pos.line); args[3] = lb_const_int(m, t_i32, pos.column); - if (!build_context.disallow_rtti) { + if (!build_context.no_rtti) { args[4] = lb_typeid(m, src_type); args[5] = lb_typeid(m, dst_type); args[6] = lb_emit_conv(p, value_, t_rawptr); @@ -753,7 +745,7 @@ lbValue lb_emit_union_cast(lbProcedure *p, lbValue value, Type *type, TokenPos p return lb_addr_load(p, v); } -lbAddr lb_emit_any_cast_addr(lbProcedure *p, lbValue value, Type *type, TokenPos pos) { +gb_internal lbAddr lb_emit_any_cast_addr(lbProcedure *p, lbValue value, Type *type, TokenPos pos) { lbModule *m = p->module; Type *src_type = value.type; @@ -805,7 +797,7 @@ lbAddr lb_emit_any_cast_addr(lbProcedure *p, lbValue value, Type *type, TokenPos lbValue ok = lb_emit_load(p, lb_emit_struct_ep(p, v.addr, 1)); isize arg_count = 7; - if (build_context.disallow_rtti) { + if (build_context.no_rtti) { arg_count = 4; } auto args = array_make(permanent_allocator(), arg_count); @@ -815,7 +807,7 @@ lbAddr lb_emit_any_cast_addr(lbProcedure *p, lbValue value, Type *type, TokenPos args[2] = lb_const_int(m, t_i32, pos.line); args[3] = lb_const_int(m, t_i32, pos.column); - if (!build_context.disallow_rtti) { + if (!build_context.no_rtti) { args[4] = any_typeid; args[5] = dst_typeid; args[6] = lb_emit_struct_ev(p, value, 0); @@ -826,13 +818,13 @@ lbAddr lb_emit_any_cast_addr(lbProcedure *p, lbValue value, Type *type, TokenPos } return v; } -lbValue lb_emit_any_cast(lbProcedure *p, lbValue value, Type *type, TokenPos pos) { +gb_internal lbValue lb_emit_any_cast(lbProcedure *p, lbValue value, Type *type, TokenPos pos) { return lb_addr_load(p, lb_emit_any_cast_addr(p, value, type, pos)); } -lbAddr lb_find_or_generate_context_ptr(lbProcedure *p) { +gb_internal lbAddr lb_find_or_generate_context_ptr(lbProcedure *p) { if (p->context_stack.count > 0) { return p->context_stack[p->context_stack.count-1].ctx; } @@ -850,7 +842,7 @@ lbAddr lb_find_or_generate_context_ptr(lbProcedure *p) { return c; } -lbValue lb_address_from_load_or_generate_local(lbProcedure *p, lbValue value) { +gb_internal lbValue lb_address_from_load_or_generate_local(lbProcedure *p, lbValue value) { if (LLVMIsALoadInst(value.value)) { lbValue res = {}; res.value = LLVMGetOperand(value.value, 0); @@ -864,7 +856,7 @@ lbValue lb_address_from_load_or_generate_local(lbProcedure *p, lbValue value) { lb_addr_store(p, res, value); return res.addr; } -lbValue lb_address_from_load(lbProcedure *p, lbValue value) { +gb_internal lbValue lb_address_from_load(lbProcedure *p, lbValue value) { if (LLVMIsALoadInst(value.value)) { lbValue res = {}; res.value = LLVMGetOperand(value.value, 0); @@ -876,27 +868,104 @@ lbValue lb_address_from_load(lbProcedure *p, lbValue value) { return {}; } +gb_internal lbValue lb_address_from_load_if_readonly_parameter(lbProcedure *p, lbValue x) { + if (!LLVMIsALoadInst(x.value)) { + return {}; + } -lbStructFieldRemapping lb_get_struct_remapping(lbModule *m, Type *t) { + LLVMValueRef optr = LLVMGetOperand(x.value, 0); + while (optr && LLVMIsABitCastInst(optr)) { + optr = LLVMGetOperand(optr, 0); + } + LLVMAttributeIndex param_index = 1; + if (p->return_ptr.addr.value) { + param_index++; + } + + bool is_parameter = false; + for (LLVMValueRef param : p->raw_input_parameters) { + if (param == optr) { + is_parameter = true; + break; + } + param_index++; + } + if (is_parameter) { + unsigned readonly_attr_kind = LLVMGetEnumAttributeKindForName("readonly", 8); + unsigned n = LLVMGetAttributeCountAtIndex(p->value, param_index); + if (n) { + TEMPORARY_ALLOCATOR_GUARD(); + LLVMAttributeRef *attrs = gb_alloc_array(temporary_allocator(), LLVMAttributeRef, n); + LLVMGetAttributesAtIndex(p->value, param_index, attrs); + for (unsigned i = 0; i < n; i++) { + if (LLVMGetEnumAttributeKind(attrs[i]) == readonly_attr_kind) { + return lb_address_from_load_or_generate_local(p, x); + } + } + } + } + return {}; +} + + +gb_internal lbStructFieldRemapping lb_get_struct_remapping(lbModule *m, Type *t) { t = base_type(t); + LLVMTypeRef struct_type = lb_type(m, t); + + mutex_lock(&m->types_mutex); + auto *field_remapping = map_get(&m->struct_field_remapping, cast(void *)struct_type); if (field_remapping == nullptr) { field_remapping = map_get(&m->struct_field_remapping, cast(void *)t); } - GB_ASSERT(field_remapping != nullptr); + + mutex_unlock(&m->types_mutex); + + GB_ASSERT_MSG(field_remapping != nullptr, "%s", type_to_string(t)); return *field_remapping; } -i32 lb_convert_struct_index(lbModule *m, Type *t, i32 index) { +gb_internal i32 lb_convert_struct_index(lbModule *m, Type *t, i32 index) { if (t->kind == Type_Struct) { auto field_remapping = lb_get_struct_remapping(m, t); - index = field_remapping[index]; + return field_remapping[index]; + } else if (build_context.ptr_size != build_context.int_size) { + switch (t->kind) { + case Type_Basic: + if (t->Basic.kind != Basic_string) { + break; + } + /*fallthrough*/ + case Type_Slice: + GB_ASSERT(build_context.ptr_size*2 == build_context.int_size); + switch (index) { + case 0: return 0; // data + case 1: return 2; // len + } + break; + case Type_DynamicArray: + GB_ASSERT(build_context.ptr_size*2 == build_context.int_size); + switch (index) { + case 0: return 0; // data + case 1: return 2; // len + case 2: return 3; // cap + case 3: return 4; // allocator + } + break; + case Type_SoaPointer: + GB_ASSERT(build_context.ptr_size*2 == build_context.int_size); + switch (index) { + case 0: return 0; // data + case 1: return 2; // offset + } + break; + } } return index; } -LLVMTypeRef lb_type_padding_filler(lbModule *m, i64 padding, i64 padding_align) { +gb_internal LLVMTypeRef lb_type_padding_filler(lbModule *m, i64 padding, i64 padding_align) { // NOTE(bill): limit to `[N x u64]` to prevent ABI issues padding_align = gb_clamp(padding_align, 1, 8); if (padding % padding_align == 0) { @@ -921,7 +990,7 @@ LLVMTypeRef lb_type_padding_filler(lbModule *m, i64 padding, i64 padding_align) } -char const *llvm_type_kinds[] = { +gb_global char const *llvm_type_kinds[] = { "LLVMVoidTypeKind", "LLVMHalfTypeKind", "LLVMFloatTypeKind", @@ -973,7 +1042,7 @@ gb_internal lbValue lb_emit_struct_ep_internal(lbProcedure *p, lbValue s, i32 in } } -lbValue lb_emit_tuple_ep(lbProcedure *p, lbValue ptr, i32 index) { +gb_internal lbValue lb_emit_tuple_ep(lbProcedure *p, lbValue ptr, i32 index) { Type *t = type_deref(ptr.type); GB_ASSERT(is_type_tuple(t)); Type *result_type = t->Tuple.variables[index]->type; @@ -991,7 +1060,7 @@ lbValue lb_emit_tuple_ep(lbProcedure *p, lbValue ptr, i32 index) { } -lbValue lb_emit_struct_ep(lbProcedure *p, lbValue s, i32 index) { +gb_internal lbValue lb_emit_struct_ep(lbProcedure *p, lbValue s, i32 index) { GB_ASSERT(is_type_pointer(s.type)); Type *t = base_type(type_deref(s.type)); Type *result_type = nullptr; @@ -1074,7 +1143,7 @@ lbValue lb_emit_struct_ep(lbProcedure *p, lbValue s, i32 index) { return lb_emit_struct_ep_internal(p, s, index, result_type); } -lbValue lb_emit_tuple_ev(lbProcedure *p, lbValue value, i32 index) { +gb_internal lbValue lb_emit_tuple_ev(lbProcedure *p, lbValue value, i32 index) { Type *t = value.type; GB_ASSERT(is_type_tuple(t)); Type *result_type = t->Tuple.variables[index]->type; @@ -1104,7 +1173,7 @@ lbValue lb_emit_tuple_ev(lbProcedure *p, lbValue value, i32 index) { return res; } -lbValue lb_emit_struct_ev(lbProcedure *p, lbValue s, i32 index) { +gb_internal lbValue lb_emit_struct_ev(lbProcedure *p, lbValue s, i32 index) { Type *t = base_type(s.type); if (is_type_tuple(t)) { return lb_emit_tuple_ev(p, s, index); @@ -1223,7 +1292,7 @@ lbValue lb_emit_struct_ev(lbProcedure *p, lbValue s, i32 index) { return res; } -lbValue lb_emit_deep_field_gep(lbProcedure *p, lbValue e, Selection sel) { +gb_internal lbValue lb_emit_deep_field_gep(lbProcedure *p, lbValue e, Selection sel) { GB_ASSERT(sel.index.count > 0); Type *type = type_deref(e.type); @@ -1311,14 +1380,14 @@ lbValue lb_emit_deep_field_gep(lbProcedure *p, lbValue e, Selection sel) { } -lbValue lb_emit_deep_field_ev(lbProcedure *p, lbValue e, Selection sel) { +gb_internal lbValue lb_emit_deep_field_ev(lbProcedure *p, lbValue e, Selection sel) { lbValue ptr = lb_address_from_load_or_generate_local(p, e); lbValue res = lb_emit_deep_field_gep(p, ptr, sel); return lb_emit_load(p, res); } -lbValue lb_emit_array_ep(lbProcedure *p, lbValue s, lbValue index) { +gb_internal lbValue lb_emit_array_ep(lbProcedure *p, lbValue s, lbValue index) { Type *t = s.type; GB_ASSERT_MSG(is_type_pointer(t), "%s", type_to_string(t)); Type *st = base_type(type_deref(t)); @@ -1341,7 +1410,7 @@ lbValue lb_emit_array_ep(lbProcedure *p, lbValue s, lbValue index) { return res; } -lbValue lb_emit_array_epi(lbProcedure *p, lbValue s, isize index) { +gb_internal lbValue lb_emit_array_epi(lbProcedure *p, lbValue s, isize index) { Type *t = s.type; GB_ASSERT(is_type_pointer(t)); Type *st = base_type(type_deref(t)); @@ -1349,7 +1418,7 @@ lbValue lb_emit_array_epi(lbProcedure *p, lbValue s, isize index) { GB_ASSERT(0 <= index); return lb_emit_epi(p, s, index); } -lbValue lb_emit_array_epi(lbModule *m, lbValue s, isize index) { +gb_internal lbValue lb_emit_array_epi(lbModule *m, lbValue s, isize index) { Type *t = s.type; GB_ASSERT(is_type_pointer(t)); Type *st = base_type(type_deref(t)); @@ -1358,7 +1427,7 @@ lbValue lb_emit_array_epi(lbModule *m, lbValue s, isize index) { return lb_emit_epi(m, s, index); } -lbValue lb_emit_ptr_offset(lbProcedure *p, lbValue ptr, lbValue index) { +gb_internal lbValue lb_emit_ptr_offset(lbProcedure *p, lbValue ptr, lbValue index) { index = lb_emit_conv(p, index, t_int); LLVMValueRef indices[1] = {index.value}; lbValue res = {}; @@ -1373,7 +1442,7 @@ lbValue lb_emit_ptr_offset(lbProcedure *p, lbValue ptr, lbValue index) { return res; } -lbValue lb_emit_matrix_epi(lbProcedure *p, lbValue s, isize row, isize column) { +gb_internal lbValue lb_emit_matrix_epi(lbProcedure *p, lbValue s, isize row, isize column) { Type *t = s.type; GB_ASSERT(is_type_pointer(t)); Type *mt = base_type(type_deref(t)); @@ -1391,7 +1460,7 @@ lbValue lb_emit_matrix_epi(lbProcedure *p, lbValue s, isize row, isize column) { return lb_emit_epi(p, s, offset); } -lbValue lb_emit_matrix_ep(lbProcedure *p, lbValue s, lbValue row, lbValue column) { +gb_internal lbValue lb_emit_matrix_ep(lbProcedure *p, lbValue s, lbValue row, lbValue column) { Type *t = s.type; GB_ASSERT(is_type_pointer(t)); Type *mt = base_type(type_deref(t)); @@ -1423,7 +1492,7 @@ lbValue lb_emit_matrix_ep(lbProcedure *p, lbValue s, lbValue row, lbValue column } -lbValue lb_emit_matrix_ev(lbProcedure *p, lbValue s, isize row, isize column) { +gb_internal lbValue lb_emit_matrix_ev(lbProcedure *p, lbValue s, isize row, isize column) { Type *st = base_type(s.type); GB_ASSERT_MSG(is_type_matrix(st), "%s", type_to_string(st)); @@ -1433,14 +1502,14 @@ lbValue lb_emit_matrix_ev(lbProcedure *p, lbValue s, isize row, isize column) { } -void lb_fill_slice(lbProcedure *p, lbAddr const &slice, lbValue base_elem, lbValue len) { +gb_internal void lb_fill_slice(lbProcedure *p, lbAddr const &slice, lbValue base_elem, lbValue len) { Type *t = lb_addr_type(slice); GB_ASSERT(is_type_slice(t)); lbValue ptr = lb_addr_get_ptr(p, slice); lb_emit_store(p, lb_emit_struct_ep(p, ptr, 0), base_elem); lb_emit_store(p, lb_emit_struct_ep(p, ptr, 1), len); } -void lb_fill_string(lbProcedure *p, lbAddr const &string, lbValue base_elem, lbValue len) { +gb_internal void lb_fill_string(lbProcedure *p, lbAddr const &string, lbValue base_elem, lbValue len) { Type *t = lb_addr_type(string); GB_ASSERT(is_type_string(t)); lbValue ptr = lb_addr_get_ptr(p, string); @@ -1448,18 +1517,18 @@ void lb_fill_string(lbProcedure *p, lbAddr const &string, lbValue base_elem, lbV lb_emit_store(p, lb_emit_struct_ep(p, ptr, 1), len); } -lbValue lb_string_elem(lbProcedure *p, lbValue string) { +gb_internal lbValue lb_string_elem(lbProcedure *p, lbValue string) { Type *t = base_type(string.type); GB_ASSERT(t->kind == Type_Basic && t->Basic.kind == Basic_string); return lb_emit_struct_ev(p, string, 0); } -lbValue lb_string_len(lbProcedure *p, lbValue string) { +gb_internal lbValue lb_string_len(lbProcedure *p, lbValue string) { Type *t = base_type(string.type); GB_ASSERT_MSG(t->kind == Type_Basic && t->Basic.kind == Basic_string, "%s", type_to_string(t)); return lb_emit_struct_ev(p, string, 1); } -lbValue lb_cstring_len(lbProcedure *p, lbValue value) { +gb_internal lbValue lb_cstring_len(lbProcedure *p, lbValue value) { GB_ASSERT(is_type_cstring(value.type)); auto args = array_make(permanent_allocator(), 1); args[0] = lb_emit_conv(p, value, t_cstring); @@ -1467,43 +1536,39 @@ lbValue lb_cstring_len(lbProcedure *p, lbValue value) { } -lbValue lb_array_elem(lbProcedure *p, lbValue array_ptr) { +gb_internal lbValue lb_array_elem(lbProcedure *p, lbValue array_ptr) { Type *t = type_deref(array_ptr.type); GB_ASSERT(is_type_array(t)); return lb_emit_struct_ep(p, array_ptr, 0); } -lbValue lb_slice_elem(lbProcedure *p, lbValue slice) { +gb_internal lbValue lb_slice_elem(lbProcedure *p, lbValue slice) { GB_ASSERT(is_type_slice(slice.type)); return lb_emit_struct_ev(p, slice, 0); } -lbValue lb_slice_len(lbProcedure *p, lbValue slice) { +gb_internal lbValue lb_slice_len(lbProcedure *p, lbValue slice) { GB_ASSERT(is_type_slice(slice.type) || is_type_relative_slice(slice.type)); return lb_emit_struct_ev(p, slice, 1); } -lbValue lb_dynamic_array_elem(lbProcedure *p, lbValue da) { +gb_internal lbValue lb_dynamic_array_elem(lbProcedure *p, lbValue da) { GB_ASSERT(is_type_dynamic_array(da.type)); return lb_emit_struct_ev(p, da, 0); } -lbValue lb_dynamic_array_len(lbProcedure *p, lbValue da) { +gb_internal lbValue lb_dynamic_array_len(lbProcedure *p, lbValue da) { GB_ASSERT(is_type_dynamic_array(da.type)); return lb_emit_struct_ev(p, da, 1); } -lbValue lb_dynamic_array_cap(lbProcedure *p, lbValue da) { +gb_internal lbValue lb_dynamic_array_cap(lbProcedure *p, lbValue da) { GB_ASSERT(is_type_dynamic_array(da.type)); return lb_emit_struct_ev(p, da, 2); } -lbValue lb_dynamic_array_allocator(lbProcedure *p, lbValue da) { - GB_ASSERT(is_type_dynamic_array(da.type)); - return lb_emit_struct_ev(p, da, 3); -} -lbValue lb_map_len(lbProcedure *p, lbValue value) { +gb_internal lbValue lb_map_len(lbProcedure *p, lbValue value) { GB_ASSERT_MSG(is_type_map(value.type) || are_types_identical(value.type, t_raw_map), "%s", type_to_string(value.type)); lbValue len = lb_emit_struct_ev(p, value, 1); return lb_emit_conv(p, len, t_int); } -lbValue lb_map_len_ptr(lbProcedure *p, lbValue map_ptr) { +gb_internal lbValue lb_map_len_ptr(lbProcedure *p, lbValue map_ptr) { Type *type = map_ptr.type; GB_ASSERT(is_type_pointer(type)); type = type_deref(type); @@ -1511,7 +1576,7 @@ lbValue lb_map_len_ptr(lbProcedure *p, lbValue map_ptr) { return lb_emit_struct_ep(p, map_ptr, 1); } -lbValue lb_map_cap(lbProcedure *p, lbValue value) { +gb_internal lbValue lb_map_cap(lbProcedure *p, lbValue value) { GB_ASSERT_MSG(is_type_map(value.type) || are_types_identical(value.type, t_raw_map), "%s", type_to_string(value.type)); lbValue zero = lb_const_int(p->module, t_uintptr, 0); lbValue one = lb_const_int(p->module, t_uintptr, 1); @@ -1525,11 +1590,11 @@ lbValue lb_map_cap(lbProcedure *p, lbValue value) { return lb_emit_conv(p, lb_emit_select(p, cmp, zero, cap), t_int); } -lbValue lb_map_data_uintptr(lbProcedure *p, lbValue value) { +gb_internal lbValue lb_map_data_uintptr(lbProcedure *p, lbValue value) { GB_ASSERT(is_type_map(value.type) || are_types_identical(value.type, t_raw_map)); lbValue data = lb_emit_struct_ev(p, value, 0); u64 mask_value = 0; - if (build_context.word_size == 4) { + if (build_context.ptr_size == 4) { mask_value = 0xfffffffful & ~(MAP_CACHE_LINE_SIZE-1); } else { mask_value = 0xffffffffffffffffull & ~(MAP_CACHE_LINE_SIZE-1); @@ -1539,7 +1604,7 @@ lbValue lb_map_data_uintptr(lbProcedure *p, lbValue value) { } -lbValue lb_soa_struct_len(lbProcedure *p, lbValue value) { +gb_internal lbValue lb_soa_struct_len(lbProcedure *p, lbValue value) { Type *t = base_type(value.type); bool is_ptr = false; if (is_type_pointer(t)) { @@ -1572,7 +1637,7 @@ lbValue lb_soa_struct_len(lbProcedure *p, lbValue value) { return lb_emit_struct_ev(p, value, cast(i32)n); } -lbValue lb_soa_struct_cap(lbProcedure *p, lbValue value) { +gb_internal lbValue lb_soa_struct_cap(lbProcedure *p, lbValue value) { Type *t = base_type(value.type); bool is_ptr = false; @@ -1604,7 +1669,7 @@ lbValue lb_soa_struct_cap(lbProcedure *p, lbValue value) { return lb_emit_struct_ev(p, value, cast(i32)n); } -lbValue lb_emit_mul_add(lbProcedure *p, lbValue a, lbValue b, lbValue c, Type *t) { +gb_internal lbValue lb_emit_mul_add(lbProcedure *p, lbValue a, lbValue b, lbValue c, Type *t) { lbModule *m = p->module; a = lb_emit_conv(p, a, t); @@ -1625,7 +1690,7 @@ lbValue lb_emit_mul_add(lbProcedure *p, lbValue a, lbValue b, lbValue c, Type *t break; case TargetArch_i386: case TargetArch_wasm32: - case TargetArch_wasm64: + case TargetArch_wasm64p32: is_possible = false; break; } @@ -1647,7 +1712,7 @@ lbValue lb_emit_mul_add(lbProcedure *p, lbValue a, lbValue b, lbValue c, Type *t } } -LLVMValueRef llvm_mask_iota(lbModule *m, unsigned start, unsigned count) { +gb_internal LLVMValueRef llvm_mask_iota(lbModule *m, unsigned start, unsigned count) { auto iota = slice_make(temporary_allocator(), count); for (unsigned i = 0; i < count; i++) { iota[i] = lb_const_int(m, t_u32, start+i).value; @@ -1655,7 +1720,7 @@ LLVMValueRef llvm_mask_iota(lbModule *m, unsigned start, unsigned count) { return LLVMConstVector(iota.data, count); } -LLVMValueRef llvm_mask_zero(lbModule *m, unsigned count) { +gb_internal LLVMValueRef llvm_mask_zero(lbModule *m, unsigned count) { return LLVMConstNull(LLVMVectorType(lb_type(m, t_u32), count)); } @@ -1663,16 +1728,16 @@ LLVMValueRef llvm_mask_zero(lbModule *m, unsigned count) { // #define LLVM_VECTOR_DUMMY_VALUE(type) LLVMConstNull((type)) -LLVMValueRef llvm_basic_shuffle(lbProcedure *p, LLVMValueRef vector, LLVMValueRef mask) { +gb_internal LLVMValueRef llvm_basic_shuffle(lbProcedure *p, LLVMValueRef vector, LLVMValueRef mask) { return LLVMBuildShuffleVector(p->builder, vector, LLVM_VECTOR_DUMMY_VALUE(LLVMTypeOf(vector)), mask, ""); } -LLVMValueRef llvm_basic_const_shuffle(LLVMValueRef vector, LLVMValueRef mask) { +gb_internal LLVMValueRef llvm_basic_const_shuffle(LLVMValueRef vector, LLVMValueRef mask) { return LLVMConstShuffleVector(vector, LLVM_VECTOR_DUMMY_VALUE(LLVMTypeOf(vector)), mask); } -LLVMValueRef llvm_vector_broadcast(lbProcedure *p, LLVMValueRef value, unsigned count) { +gb_internal LLVMValueRef llvm_vector_broadcast(lbProcedure *p, LLVMValueRef value, unsigned count) { GB_ASSERT(count > 0); if (LLVMIsConstant(value)) { LLVMValueRef single = LLVMConstVector(&value, 1); @@ -1692,7 +1757,7 @@ LLVMValueRef llvm_vector_broadcast(lbProcedure *p, LLVMValueRef value, unsigned return llvm_basic_shuffle(p, single, mask); } -LLVMValueRef llvm_vector_shuffle_reduction(lbProcedure *p, LLVMValueRef value, LLVMOpcode op_code) { +gb_internal LLVMValueRef llvm_vector_shuffle_reduction(lbProcedure *p, LLVMValueRef value, LLVMOpcode op_code) { LLVMTypeRef original_vector_type = LLVMTypeOf(value); GB_ASSERT(LLVMGetTypeKind(original_vector_type) == LLVMVectorTypeKind); @@ -1719,7 +1784,7 @@ LLVMValueRef llvm_vector_shuffle_reduction(lbProcedure *p, LLVMValueRef value, L return LLVMBuildExtractElement(p->builder, value, v_zero32, ""); } -LLVMValueRef llvm_vector_expand_to_power_of_two(lbProcedure *p, LLVMValueRef value) { +gb_internal LLVMValueRef llvm_vector_expand_to_power_of_two(lbProcedure *p, LLVMValueRef value) { LLVMTypeRef vector_type = LLVMTypeOf(value); unsigned len = LLVMGetVectorSize(vector_type); if (len == 1) { @@ -1734,7 +1799,7 @@ LLVMValueRef llvm_vector_expand_to_power_of_two(lbProcedure *p, LLVMValueRef val return LLVMBuildShuffleVector(p->builder, value, LLVMConstNull(vector_type), mask, ""); } -LLVMValueRef llvm_vector_reduce_add(lbProcedure *p, LLVMValueRef value) { +gb_internal LLVMValueRef llvm_vector_reduce_add(lbProcedure *p, LLVMValueRef value) { LLVMTypeRef type = LLVMTypeOf(value); GB_ASSERT(LLVMGetTypeKind(type) == LLVMVectorTypeKind); LLVMTypeRef elem = OdinLLVMGetVectorElementType(type); @@ -1810,7 +1875,7 @@ LLVMValueRef llvm_vector_reduce_add(lbProcedure *p, LLVMValueRef value) { #endif } -LLVMValueRef llvm_vector_add(lbProcedure *p, LLVMValueRef a, LLVMValueRef b) { +gb_internal LLVMValueRef llvm_vector_add(lbProcedure *p, LLVMValueRef a, LLVMValueRef b) { GB_ASSERT(LLVMTypeOf(a) == LLVMTypeOf(b)); LLVMTypeRef elem = OdinLLVMGetVectorElementType(LLVMTypeOf(a)); @@ -1821,7 +1886,7 @@ LLVMValueRef llvm_vector_add(lbProcedure *p, LLVMValueRef a, LLVMValueRef b) { return LLVMBuildFAdd(p->builder, a, b, ""); } -LLVMValueRef llvm_vector_mul(lbProcedure *p, LLVMValueRef a, LLVMValueRef b) { +gb_internal LLVMValueRef llvm_vector_mul(lbProcedure *p, LLVMValueRef a, LLVMValueRef b) { GB_ASSERT(LLVMTypeOf(a) == LLVMTypeOf(b)); LLVMTypeRef elem = OdinLLVMGetVectorElementType(LLVMTypeOf(a)); @@ -1833,11 +1898,11 @@ LLVMValueRef llvm_vector_mul(lbProcedure *p, LLVMValueRef a, LLVMValueRef b) { } -LLVMValueRef llvm_vector_dot(lbProcedure *p, LLVMValueRef a, LLVMValueRef b) { +gb_internal LLVMValueRef llvm_vector_dot(lbProcedure *p, LLVMValueRef a, LLVMValueRef b) { return llvm_vector_reduce_add(p, llvm_vector_mul(p, a, b)); } -LLVMValueRef llvm_vector_mul_add(lbProcedure *p, LLVMValueRef a, LLVMValueRef b, LLVMValueRef c) { +gb_internal LLVMValueRef llvm_vector_mul_add(lbProcedure *p, LLVMValueRef a, LLVMValueRef b, LLVMValueRef c) { LLVMTypeRef t = LLVMTypeOf(a); GB_ASSERT(t == LLVMTypeOf(b)); @@ -1871,7 +1936,7 @@ LLVMValueRef llvm_vector_mul_add(lbProcedure *p, LLVMValueRef a, LLVMValueRef b, } } -LLVMValueRef llvm_get_inline_asm(LLVMTypeRef func_type, String const &str, String const &clobbers, bool has_side_effects=true, bool is_align_stack=false, LLVMInlineAsmDialect dialect=LLVMInlineAsmDialectATT) { +gb_internal LLVMValueRef llvm_get_inline_asm(LLVMTypeRef func_type, String const &str, String const &clobbers, bool has_side_effects=true, bool is_align_stack=false, LLVMInlineAsmDialect dialect=LLVMInlineAsmDialectATT) { return LLVMGetInlineAsm(func_type, cast(char *)str.text, cast(size_t)str.len, cast(char *)clobbers.text, cast(size_t)clobbers.len, @@ -1884,7 +1949,7 @@ LLVMValueRef llvm_get_inline_asm(LLVMTypeRef func_type, String const &str, Strin } -void lb_set_wasm_import_attributes(LLVMValueRef value, Entity *entity, String import_name) { +gb_internal void lb_set_wasm_import_attributes(LLVMValueRef value, Entity *entity, String import_name) { if (!is_arch_wasm()) { return; } @@ -1906,7 +1971,7 @@ void lb_set_wasm_import_attributes(LLVMValueRef value, Entity *entity, String im } -void lb_set_wasm_export_attributes(LLVMValueRef value, String export_name) { +gb_internal void lb_set_wasm_export_attributes(LLVMValueRef value, String export_name) { if (!is_arch_wasm()) { return; } @@ -1918,7 +1983,7 @@ void lb_set_wasm_export_attributes(LLVMValueRef value, String export_name) { -lbAddr lb_handle_objc_find_or_register_selector(lbProcedure *p, String const &name) { +gb_internal lbAddr lb_handle_objc_find_or_register_selector(lbProcedure *p, String const &name) { lbAddr *found = string_map_get(&p->module->objc_selectors, name); if (found) { return *found; @@ -1938,7 +2003,7 @@ lbAddr lb_handle_objc_find_or_register_selector(lbProcedure *p, String const &na } } -lbValue lb_handle_objc_find_selector(lbProcedure *p, Ast *expr) { +gb_internal lbValue lb_handle_objc_find_selector(lbProcedure *p, Ast *expr) { ast_node(ce, CallExpr, expr); auto tav = ce->args[0]->tav; @@ -1947,7 +2012,7 @@ lbValue lb_handle_objc_find_selector(lbProcedure *p, Ast *expr) { return lb_addr_load(p, lb_handle_objc_find_or_register_selector(p, name)); } -lbValue lb_handle_objc_register_selector(lbProcedure *p, Ast *expr) { +gb_internal lbValue lb_handle_objc_register_selector(lbProcedure *p, Ast *expr) { ast_node(ce, CallExpr, expr); lbModule *m = p->module; @@ -1964,7 +2029,7 @@ lbValue lb_handle_objc_register_selector(lbProcedure *p, Ast *expr) { return lb_addr_load(p, dst); } -lbAddr lb_handle_objc_find_or_register_class(lbProcedure *p, String const &name) { +gb_internal lbAddr lb_handle_objc_find_or_register_class(lbProcedure *p, String const &name) { lbAddr *found = string_map_get(&p->module->objc_classes, name); if (found) { return *found; @@ -1984,7 +2049,7 @@ lbAddr lb_handle_objc_find_or_register_class(lbProcedure *p, String const &name) } } -lbValue lb_handle_objc_find_class(lbProcedure *p, Ast *expr) { +gb_internal lbValue lb_handle_objc_find_class(lbProcedure *p, Ast *expr) { ast_node(ce, CallExpr, expr); auto tav = ce->args[0]->tav; @@ -1993,7 +2058,7 @@ lbValue lb_handle_objc_find_class(lbProcedure *p, Ast *expr) { return lb_addr_load(p, lb_handle_objc_find_or_register_class(p, name)); } -lbValue lb_handle_objc_register_class(lbProcedure *p, Ast *expr) { +gb_internal lbValue lb_handle_objc_register_class(lbProcedure *p, Ast *expr) { ast_node(ce, CallExpr, expr); lbModule *m = p->module; @@ -2013,7 +2078,7 @@ lbValue lb_handle_objc_register_class(lbProcedure *p, Ast *expr) { } -lbValue lb_handle_objc_id(lbProcedure *p, Ast *expr) { +gb_internal lbValue lb_handle_objc_id(lbProcedure *p, Ast *expr) { TypeAndValue const &tav = type_and_value_of_expr(expr); if (tav.mode == Addressing_Type) { Type *type = tav.type; @@ -2044,7 +2109,7 @@ lbValue lb_handle_objc_id(lbProcedure *p, Ast *expr) { return lb_build_expr(p, expr); } -lbValue lb_handle_objc_send(lbProcedure *p, Ast *expr) { +gb_internal lbValue lb_handle_objc_send(lbProcedure *p, Ast *expr) { ast_node(ce, CallExpr, expr); lbModule *m = p->module; @@ -2087,7 +2152,7 @@ lbValue lb_handle_objc_send(lbProcedure *p, Ast *expr) { -LLVMAtomicOrdering llvm_atomic_ordering_from_odin(ExactValue const &value) { +gb_internal LLVMAtomicOrdering llvm_atomic_ordering_from_odin(ExactValue const &value) { GB_ASSERT(value.kind == ExactValue_Integer); i64 v = exact_value_to_i64(value); switch (v) { @@ -2103,7 +2168,7 @@ LLVMAtomicOrdering llvm_atomic_ordering_from_odin(ExactValue const &value) { } -LLVMAtomicOrdering llvm_atomic_ordering_from_odin(Ast *expr) { +gb_internal LLVMAtomicOrdering llvm_atomic_ordering_from_odin(Ast *expr) { ExactValue value = type_and_value_of_expr(expr).value; return llvm_atomic_ordering_from_odin(value); } diff --git a/src/main.cpp b/src/main.cpp index e816906d6..2198b4536 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,31 +3,56 @@ #include "common.cpp" #include "timings.cpp" #include "tokenizer.cpp" +#if defined(GB_SYSTEM_WINDOWS) + #pragma warning(push) + #pragma warning(disable: 4505) +#endif #include "big_int.cpp" +#if defined(GB_SYSTEM_WINDOWS) + #pragma warning(pop) +#endif #include "exact_value.cpp" #include "build_settings.cpp" - gb_global ThreadPool global_thread_pool; -void init_global_thread_pool(void) { +gb_internal void init_global_thread_pool(void) { isize thread_count = gb_max(build_context.thread_count, 1); - isize worker_count = thread_count-1; // NOTE(bill): The main thread will also be used for work - thread_pool_init(&global_thread_pool, permanent_allocator(), worker_count, "ThreadPoolWorker"); + isize worker_count = thread_count; // +1 + thread_pool_init(&global_thread_pool, worker_count, "ThreadPoolWorker"); } -bool global_thread_pool_add_task(WorkerTaskProc *proc, void *data) { +gb_internal bool thread_pool_add_task(WorkerTaskProc *proc, void *data) { return thread_pool_add_task(&global_thread_pool, proc, data); } -void global_thread_pool_wait(void) { +gb_internal void thread_pool_wait(void) { thread_pool_wait(&global_thread_pool); } -void debugf(char const *fmt, ...) { +gb_internal i64 PRINT_PEAK_USAGE(void) { + if (build_context.show_more_timings) { + #if defined(GB_SYSTEM_WINDOWS) + PROCESS_MEMORY_COUNTERS p = {sizeof(p)}; + if (GetProcessMemoryInfo(GetCurrentProcess(), &p, sizeof(p))) { + gb_printf("\n"); + gb_printf("Peak Memory Size: %.3f MiB\n", (cast(f64)p.PeakWorkingSetSize) / cast(f64)(1024ull * 1024ull)); + return cast(i64)p.PeakWorkingSetSize; + } + #endif + } + return 0; +} + + +gb_global BlockingMutex debugf_mutex; + +gb_internal void debugf(char const *fmt, ...) { if (build_context.show_debug_messages) { + mutex_lock(&debugf_mutex); gb_printf_err("[DEBUG] "); va_list va; va_start(va, fmt); (void)gb_printf_err_va(fmt, va); va_end(va); + mutex_unlock(&debugf_mutex); } } @@ -58,11 +83,10 @@ gb_global Timings global_timings = {0}; #endif #endif -#include "query_data.cpp" #include "bug_report.cpp" // NOTE(bill): 'name' is used in debugging and profiling modes -i32 system_exec_command_line_app(char const *name, char const *fmt, ...) { +gb_internal i32 system_exec_command_line_app(char const *name, char const *fmt, ...) { isize const cmd_cap = 64<<20; // 64 MiB should be more than enough char *cmd_line = gb_alloc_array(gb_heap_allocator(), char, cmd_cap); isize cmd_len = 0; @@ -124,7 +148,7 @@ i32 system_exec_command_line_app(char const *name, char const *fmt, ...) { } -i32 linker_stage(lbGenerator *gen) { +gb_internal i32 linker_stage(lbGenerator *gen) { i32 result = 0; Timings *timings = &global_timings; @@ -207,15 +231,14 @@ i32 linker_stage(lbGenerator *gen) { StringSet libs = {}; - string_set_init(&libs, heap_allocator(), 64); + string_set_init(&libs, 64); defer (string_set_destroy(&libs)); StringSet asm_files = {}; - string_set_init(&asm_files, heap_allocator(), 64); + string_set_init(&asm_files, 64); defer (string_set_destroy(&asm_files)); - for_array(j, gen->foreign_libraries) { - Entity *e = gen->foreign_libraries[j]; + for (Entity *e : gen->foreign_libraries) { GB_ASSERT(e->kind == Entity_LibraryName); for_array(i, e->LibraryName.paths) { String lib = string_trim_whitespace(e->LibraryName.paths[i]); @@ -255,6 +278,13 @@ i32 linker_stage(lbGenerator *gen) { } } + for (Entity *e : gen->foreign_libraries) { + GB_ASSERT(e->kind == Entity_LibraryName); + if (e->LibraryName.extra_linker_flags.len != 0) { + lib_str = gb_string_append_fmt(lib_str, " %.*s", LIT(e->LibraryName.extra_linker_flags)); + } + } + if (build_context.build_mode == BuildMode_DynamicLibrary) { link_settings = gb_string_append_fmt(link_settings, " /DLL"); } else { @@ -278,8 +308,7 @@ i32 linker_stage(lbGenerator *gen) { gbString object_files = gb_string_make(heap_allocator(), ""); defer (gb_string_free(object_files)); - for_array(i, gen->output_object_paths) { - String object_path = gen->output_object_paths[i]; + for (String const &object_path : gen->output_object_paths) { object_files = gb_string_append_fmt(object_files, "\"%.*s\" ", LIT(object_path)); } @@ -313,12 +342,18 @@ i32 linker_stage(lbGenerator *gen) { } } + switch (build_context.build_mode) { + case BuildMode_Executable: + link_settings = gb_string_append_fmt(link_settings, " /NOIMPLIB /NOEXP"); + break; + } + result = system_exec_command_line_app("msvc-link", "\"%.*slink.exe\" %s %.*s -OUT:\"%.*s\" %s " "/nologo /incremental:no /opt:ref /subsystem:%s " - " %.*s " - " %.*s " - " %s " + "%.*s " + "%.*s " + "%s " "", LIT(vs_exe_path), object_files, LIT(res_path), LIT(output_filename), link_settings, @@ -334,9 +369,9 @@ i32 linker_stage(lbGenerator *gen) { result = system_exec_command_line_app("msvc-lld-link", "\"%.*s\\bin\\lld-link\" %s -OUT:\"%.*s\" %s " "/nologo /incremental:no /opt:ref /subsystem:%s " - " %.*s " - " %.*s " - " %s " + "%.*s " + "%.*s " + "%s " "", LIT(build_context.ODIN_ROOT), object_files, LIT(output_filename), link_settings, @@ -366,14 +401,13 @@ i32 linker_stage(lbGenerator *gen) { defer (gb_string_free(lib_str)); StringSet libs = {}; - string_set_init(&libs, heap_allocator(), 64); + string_set_init(&libs, 64); defer (string_set_destroy(&libs)); - for_array(j, gen->foreign_libraries) { - Entity *e = gen->foreign_libraries[j]; + for (Entity *e : gen->foreign_libraries) { GB_ASSERT(e->kind == Entity_LibraryName); - for_array(i, e->LibraryName.paths) { - String lib = string_trim_whitespace(e->LibraryName.paths[i]); + for (String lib : e->LibraryName.paths) { + lib = string_trim_whitespace(lib); if (lib.len == 0) { continue; } @@ -422,11 +456,16 @@ i32 linker_stage(lbGenerator *gen) { } } + for (Entity *e : gen->foreign_libraries) { + GB_ASSERT(e->kind == Entity_LibraryName); + if (e->LibraryName.extra_linker_flags.len != 0) { + lib_str = gb_string_append_fmt(lib_str, " %.*s", LIT(e->LibraryName.extra_linker_flags)); + } + } gbString object_files = gb_string_make(heap_allocator(), ""); defer (gb_string_free(object_files)); - for_array(i, gen->output_object_paths) { - String object_path = gen->output_object_paths[i]; + for (String object_path : gen->output_object_paths) { object_files = gb_string_append_fmt(object_files, "\"%.*s\" ", LIT(object_path)); } @@ -524,7 +563,7 @@ i32 linker_stage(lbGenerator *gen) { return result; } -Array setup_args(int argc, char const **argv) { +gb_internal Array setup_args(int argc, char const **argv) { gbAllocator a = heap_allocator(); #if defined(GB_SYSTEM_WINDOWS) @@ -553,18 +592,18 @@ Array setup_args(int argc, char const **argv) { #endif } -void print_usage_line(i32 indent, char const *fmt, ...) { +gb_internal void print_usage_line(i32 indent, char const *fmt, ...) { while (indent --> 0) { - gb_printf_err("\t"); + gb_printf("\t"); } va_list va; va_start(va, fmt); - gb_printf_err_va(fmt, va); + gb_printf_va(fmt, va); va_end(va); - gb_printf_err("\n"); + gb_printf("\n"); } -void usage(String argv0) { +gb_internal void usage(String argv0) { print_usage_line(0, "%.*s is a tool for managing Odin source code", LIT(argv0)); print_usage_line(0, "Usage:"); print_usage_line(1, "%.*s command [arguments]", LIT(argv0)); @@ -573,7 +612,6 @@ void usage(String argv0) { print_usage_line(1, " one must contain the program's entry point, all must be in the same package."); print_usage_line(1, "run same as 'build', but also then runs the newly compiled executable."); print_usage_line(1, "check parse, and type check a directory of .odin files"); - print_usage_line(1, "query parse, type check, and output a .json file containing information about the program"); print_usage_line(1, "strip-semicolon parse, type check, and remove unneeded semicolons from the entire program"); print_usage_line(1, "test build and runs procedures with the attribute @(test) in the initial package"); print_usage_line(1, "doc generate documentation on a directory of .odin files"); @@ -613,18 +651,17 @@ enum BuildFlagKind { BuildFlag_NoEntryPoint, BuildFlag_UseLLD, BuildFlag_UseSeparateModules, - BuildFlag_ThreadedChecker, BuildFlag_NoThreadedChecker, BuildFlag_ShowDebugMessages, BuildFlag_Vet, BuildFlag_VetExtra, - BuildFlag_UseLLVMApi, BuildFlag_IgnoreUnknownAttributes, BuildFlag_ExtraLinkerFlags, BuildFlag_ExtraAssemblerFlags, BuildFlag_Microarch, BuildFlag_TargetFeatures, BuildFlag_MinimumOSVersion, + BuildFlag_NoThreadLocal, BuildFlag_RelocMode, BuildFlag_DisableRedZone, @@ -633,12 +670,11 @@ enum BuildFlagKind { BuildFlag_DisallowDo, BuildFlag_DefaultToNilAllocator, - BuildFlag_InsertSemicolon, BuildFlag_StrictStyle, BuildFlag_StrictStyleInitOnly, BuildFlag_ForeignErrorProcedures, - BuildFlag_DisallowRTTI, - BuildFlag_UseStaticMapCalls, + BuildFlag_NoRTTI, + BuildFlag_DynamicMapCalls, BuildFlag_Compact, BuildFlag_GlobalDefinitions, @@ -650,11 +686,14 @@ enum BuildFlagKind { BuildFlag_IgnoreWarnings, BuildFlag_WarningsAsErrors, + BuildFlag_TerseErrors, BuildFlag_VerboseErrors, BuildFlag_ErrorPosStyle, + BuildFlag_MaxErrorCount, // internal use only BuildFlag_InternalIgnoreLazy, + BuildFlag_InternalIgnoreLLVMBuild, #if defined(GB_SYSTEM_WINDOWS) BuildFlag_IgnoreVsSearch, @@ -687,12 +726,12 @@ struct BuildFlag { }; -void add_flag(Array *build_flags, BuildFlagKind kind, String name, BuildFlagParamKind param_kind, u32 command_support, bool allow_mulitple=false) { +gb_internal void add_flag(Array *build_flags, BuildFlagKind kind, String name, BuildFlagParamKind param_kind, u32 command_support, bool allow_mulitple=false) { BuildFlag flag = {kind, name, param_kind, command_support, allow_mulitple}; array_add(build_flags, flag); } -ExactValue build_param_to_exact_value(String name, String param) { +gb_internal ExactValue build_param_to_exact_value(String name, String param) { ExactValue value = {}; /* @@ -747,7 +786,7 @@ ExactValue build_param_to_exact_value(String name, String param) { } // Writes a did-you-mean message for formerly deprecated flags. -void did_you_mean_flag(String flag) { +gb_internal void did_you_mean_flag(String flag) { gbAllocator a = heap_allocator(); String name = copy_string(a, flag); defer (gb_free(a, name.text)); @@ -760,7 +799,7 @@ void did_you_mean_flag(String flag) { gb_printf_err("Unknown flag: '%.*s'\n", LIT(flag)); } -bool parse_build_flags(Array args) { +gb_internal bool parse_build_flags(Array args) { auto build_flags = array_make(heap_allocator(), 0, BuildFlag_COUNT); add_flag(&build_flags, BuildFlag_Help, str_lit("help"), BuildFlagParam_None, Command_all); add_flag(&build_flags, BuildFlag_SingleFile, str_lit("file"), BuildFlagParam_None, Command__does_build | Command__does_check); @@ -783,17 +822,16 @@ bool parse_build_flags(Array args) { add_flag(&build_flags, BuildFlag_Debug, str_lit("debug"), BuildFlagParam_None, Command__does_check); add_flag(&build_flags, BuildFlag_DisableAssert, str_lit("disable-assert"), BuildFlagParam_None, Command__does_check); add_flag(&build_flags, BuildFlag_NoBoundsCheck, str_lit("no-bounds-check"), BuildFlagParam_None, Command__does_check); + add_flag(&build_flags, BuildFlag_NoThreadLocal, str_lit("no-thread-local"), BuildFlagParam_None, Command__does_check); add_flag(&build_flags, BuildFlag_NoDynamicLiterals, str_lit("no-dynamic-literals"), BuildFlagParam_None, Command__does_check); add_flag(&build_flags, BuildFlag_NoCRT, str_lit("no-crt"), BuildFlagParam_None, Command__does_build); add_flag(&build_flags, BuildFlag_NoEntryPoint, str_lit("no-entry-point"), BuildFlagParam_None, Command__does_check &~ Command_test); add_flag(&build_flags, BuildFlag_UseLLD, str_lit("lld"), BuildFlagParam_None, Command__does_build); add_flag(&build_flags, BuildFlag_UseSeparateModules, str_lit("use-separate-modules"), BuildFlagParam_None, Command__does_build); - add_flag(&build_flags, BuildFlag_ThreadedChecker, str_lit("threaded-checker"), BuildFlagParam_None, Command__does_check); add_flag(&build_flags, BuildFlag_NoThreadedChecker, str_lit("no-threaded-checker"), BuildFlagParam_None, Command__does_check); add_flag(&build_flags, BuildFlag_ShowDebugMessages, str_lit("show-debug-messages"), BuildFlagParam_None, Command_all); add_flag(&build_flags, BuildFlag_Vet, str_lit("vet"), BuildFlagParam_None, Command__does_check); add_flag(&build_flags, BuildFlag_VetExtra, str_lit("vet-extra"), BuildFlagParam_None, Command__does_check); - add_flag(&build_flags, BuildFlag_UseLLVMApi, str_lit("llvm-api"), BuildFlagParam_None, Command__does_build); add_flag(&build_flags, BuildFlag_IgnoreUnknownAttributes, str_lit("ignore-unknown-attributes"), BuildFlagParam_None, Command__does_check); add_flag(&build_flags, BuildFlag_ExtraLinkerFlags, str_lit("extra-linker-flags"), BuildFlagParam_String, Command__does_build); add_flag(&build_flags, BuildFlag_ExtraAssemblerFlags, str_lit("extra-assembler-flags"), BuildFlagParam_String, Command__does_build); @@ -808,20 +846,14 @@ bool parse_build_flags(Array args) { add_flag(&build_flags, BuildFlag_DisallowDo, str_lit("disallow-do"), BuildFlagParam_None, Command__does_check); add_flag(&build_flags, BuildFlag_DefaultToNilAllocator, str_lit("default-to-nil-allocator"), BuildFlagParam_None, Command__does_check); - add_flag(&build_flags, BuildFlag_InsertSemicolon, str_lit("insert-semicolon"), BuildFlagParam_None, Command__does_check); add_flag(&build_flags, BuildFlag_StrictStyle, str_lit("strict-style"), BuildFlagParam_None, Command__does_check); add_flag(&build_flags, BuildFlag_StrictStyleInitOnly, str_lit("strict-style-init-only"), BuildFlagParam_None, Command__does_check); add_flag(&build_flags, BuildFlag_ForeignErrorProcedures, str_lit("foreign-error-procedures"), BuildFlagParam_None, Command__does_check); - add_flag(&build_flags, BuildFlag_DisallowRTTI, str_lit("disallow-rtti"), BuildFlagParam_None, Command__does_check); - - add_flag(&build_flags, BuildFlag_UseStaticMapCalls, str_lit("use-static-map-calls"), BuildFlagParam_None, Command__does_check); - - - add_flag(&build_flags, BuildFlag_Compact, str_lit("compact"), BuildFlagParam_None, Command_query); - add_flag(&build_flags, BuildFlag_GlobalDefinitions, str_lit("global-definitions"), BuildFlagParam_None, Command_query); - add_flag(&build_flags, BuildFlag_GoToDefinitions, str_lit("go-to-definitions"), BuildFlagParam_None, Command_query); + add_flag(&build_flags, BuildFlag_NoRTTI, str_lit("no-rtti"), BuildFlagParam_None, Command__does_check); + add_flag(&build_flags, BuildFlag_NoRTTI, str_lit("disallow-rtti"), BuildFlagParam_None, Command__does_check); + add_flag(&build_flags, BuildFlag_DynamicMapCalls, str_lit("dynamic-map-calls"), BuildFlagParam_None, Command__does_check); add_flag(&build_flags, BuildFlag_Short, str_lit("short"), BuildFlagParam_None, Command_doc); add_flag(&build_flags, BuildFlag_AllPackages, str_lit("all-packages"), BuildFlagParam_None, Command_doc); @@ -829,10 +861,13 @@ bool parse_build_flags(Array args) { add_flag(&build_flags, BuildFlag_IgnoreWarnings, str_lit("ignore-warnings"), BuildFlagParam_None, Command_all); add_flag(&build_flags, BuildFlag_WarningsAsErrors, str_lit("warnings-as-errors"), BuildFlagParam_None, Command_all); + add_flag(&build_flags, BuildFlag_TerseErrors, str_lit("terse-errors"), BuildFlagParam_None, Command_all); add_flag(&build_flags, BuildFlag_VerboseErrors, str_lit("verbose-errors"), BuildFlagParam_None, Command_all); add_flag(&build_flags, BuildFlag_ErrorPosStyle, str_lit("error-pos-style"), BuildFlagParam_String, Command_all); + add_flag(&build_flags, BuildFlag_MaxErrorCount, str_lit("max-error-count"), BuildFlagParam_Integer, Command_all); add_flag(&build_flags, BuildFlag_InternalIgnoreLazy, str_lit("internal-ignore-lazy"), BuildFlagParam_None, Command_all); + add_flag(&build_flags, BuildFlag_InternalIgnoreLLVMBuild, str_lit("internal-ignore-llvm-build"),BuildFlagParam_None, Command_all); #if defined(GB_SYSTEM_WINDOWS) add_flag(&build_flags, BuildFlag_IgnoreVsSearch, str_lit("ignore-vs-search"), BuildFlagParam_None, Command__does_build); @@ -848,8 +883,7 @@ bool parse_build_flags(Array args) { bool set_flags[BuildFlag_COUNT] = {}; bool bad_flags = false; - for_array(i, flag_args) { - String flag = flag_args[i]; + for (String flag : flag_args) { if (flag[0] != '-') { gb_printf_err("Invalid flag: %.*s\n", LIT(flag)); continue; @@ -878,8 +912,7 @@ bool parse_build_flags(Array args) { bool found = false; BuildFlag found_bf = {}; - for_array(build_flag_index, build_flags) { - BuildFlag bf = build_flags[build_flag_index]; + for (BuildFlag const &bf : build_flags) { if (bf.name == name) { found = true; found_bf = bf; @@ -998,11 +1031,17 @@ bool parse_build_flags(Array args) { } case BuildFlag_OptimizationMode: { GB_ASSERT(value.kind == ExactValue_String); - if (value.value_string == "minimal") { + if (value.value_string == "none") { + build_context.custom_optimization_level = true; + build_context.optimization_level = -1; + } else if (value.value_string == "minimal") { + build_context.custom_optimization_level = true; build_context.optimization_level = 0; } else if (value.value_string == "size") { + build_context.custom_optimization_level = true; build_context.optimization_level = 1; } else if (value.value_string == "speed") { + build_context.custom_optimization_level = true; build_context.optimization_level = 2; } else { gb_printf_err("Invalid optimization mode for -o:, got %.*s\n", LIT(value.value_string)); @@ -1010,6 +1049,7 @@ bool parse_build_flags(Array args) { gb_printf_err("\tminimal\n"); gb_printf_err("\tsize\n"); gb_printf_err("\tspeed\n"); + gb_printf_err("\tnone (useful for -debug builds)\n"); bad_flags = true; } break; @@ -1305,26 +1345,17 @@ bool parse_build_flags(Array args) { case BuildFlag_NoEntryPoint: build_context.no_entry_point = true; break; + case BuildFlag_NoThreadLocal: + build_context.no_thread_local = true; + break; case BuildFlag_UseLLD: build_context.use_lld = true; break; case BuildFlag_UseSeparateModules: build_context.use_separate_modules = true; break; - case BuildFlag_ThreadedChecker: { - #if defined(DEFAULT_TO_THREADED_CHECKER) - gb_printf_err("-threaded-checker is the default on this platform\n"); - bad_flags = true; - #endif - build_context.threaded_checker = true; - break; - } case BuildFlag_NoThreadedChecker: { - #if !defined(DEFAULT_TO_THREADED_CHECKER) - gb_printf_err("-no-threaded-checker is the default on this platform\n"); - bad_flags = true; - #endif - build_context.threaded_checker = false; + build_context.no_threaded_checker = true; break; } case BuildFlag_ShowDebugMessages: @@ -1338,11 +1369,6 @@ bool parse_build_flags(Array args) { build_context.vet_extra = true; break; } - case BuildFlag_UseLLVMApi: { - gb_printf_err("-llvm-api flag is not required any more\n"); - bad_flags = true; - break; - } case BuildFlag_IgnoreUnknownAttributes: build_context.ignore_unknown_attributes = true; break; @@ -1414,11 +1440,15 @@ bool parse_build_flags(Array args) { case BuildFlag_DisallowDo: build_context.disallow_do = true; break; - case BuildFlag_DisallowRTTI: - build_context.disallow_rtti = true; + case BuildFlag_NoRTTI: + if (name == "disallow-rtti") { + gb_printf_err("'-disallow-rtti' has been replaced with '-no-rtti'\n"); + bad_flags = true; + } + build_context.no_rtti = true; break; - case BuildFlag_UseStaticMapCalls: - build_context.use_static_map_calls = true; + case BuildFlag_DynamicMapCalls: + build_context.dynamic_map_calls = true; break; case BuildFlag_DefaultToNilAllocator: build_context.ODIN_DEFAULT_TO_NIL_ALLOCATOR = true; @@ -1426,11 +1456,6 @@ bool parse_build_flags(Array args) { case BuildFlag_ForeignErrorProcedures: build_context.ODIN_FOREIGN_ERROR_PROCEDURES = true; break; - case BuildFlag_InsertSemicolon: { - gb_printf_err("-insert-semicolon flag is not required any more\n"); - bad_flags = true; - break; - } case BuildFlag_StrictStyle: { if (build_context.strict_style_init_only) { gb_printf_err("-strict-style and -strict-style-init-only cannot be used together\n"); @@ -1445,39 +1470,6 @@ bool parse_build_flags(Array args) { build_context.strict_style_init_only = true; break; } - case BuildFlag_Compact: { - if (!build_context.query_data_set_settings.ok) { - gb_printf_err("Invalid use of -compact flag, only allowed with 'odin query'\n"); - bad_flags = true; - } else { - build_context.query_data_set_settings.compact = true; - } - break; - } - case BuildFlag_GlobalDefinitions: { - if (!build_context.query_data_set_settings.ok) { - gb_printf_err("Invalid use of -global-definitions flag, only allowed with 'odin query'\n"); - bad_flags = true; - } else if (build_context.query_data_set_settings.kind != QueryDataSet_Invalid) { - gb_printf_err("Invalid use of -global-definitions flag, a previous flag for 'odin query' was set\n"); - bad_flags = true; - } else { - build_context.query_data_set_settings.kind = QueryDataSet_GlobalDefinitions; - } - break; - } - case BuildFlag_GoToDefinitions: { - if (!build_context.query_data_set_settings.ok) { - gb_printf_err("Invalid use of -go-to-definitions flag, only allowed with 'odin query'\n"); - bad_flags = true; - } else if (build_context.query_data_set_settings.kind != QueryDataSet_Invalid) { - gb_printf_err("Invalid use of -global-definitions flag, a previous flag for 'odin query' was set\n"); - bad_flags = true; - } else { - build_context.query_data_set_settings.kind = QueryDataSet_GoToDefinitions; - } - break; - } case BuildFlag_Short: build_context.cmd_doc_flags |= CmdDocFlag_Short; break; @@ -1505,8 +1497,13 @@ bool parse_build_flags(Array args) { } break; } + + case BuildFlag_TerseErrors: + build_context.hide_error_line = true; + break; case BuildFlag_VerboseErrors: - build_context.show_error_line = true; + gb_printf_err("-verbose-errors is not the default, -terse-errors can now disable it\n"); + build_context.hide_error_line = false; break; case BuildFlag_ErrorPosStyle: @@ -1522,9 +1519,23 @@ bool parse_build_flags(Array args) { } break; + case BuildFlag_MaxErrorCount: { + i64 count = big_int_to_i64(&value.value_integer); + if (count <= 0) { + gb_printf_err("-%.*s must be greater than 0", LIT(bf.name)); + bad_flags = true; + } else { + build_context.max_error_count = cast(isize)count; + } + break; + } + case BuildFlag_InternalIgnoreLazy: build_context.ignore_lazy = true; break; + case BuildFlag_InternalIgnoreLLVMBuild: + build_context.ignore_llvm_build = true; + break; #if defined(GB_SYSTEM_WINDOWS) case BuildFlag_IgnoreVsSearch: { GB_ASSERT(value.kind == ExactValue_Invalid); @@ -1638,20 +1649,10 @@ bool parse_build_flags(Array args) { gb_printf_err("`-export-timings:` requires `-show-timings` or `-show-more-timings` to be present\n"); bad_flags = true; } - - if (build_context.query_data_set_settings.ok) { - if (build_context.query_data_set_settings.kind == QueryDataSet_Invalid) { - gb_printf_err("'odin query' requires a flag determining the kind of query data set to be returned\n"); - gb_printf_err("\t-global-definitions : outputs a JSON file of global definitions\n"); - gb_printf_err("\t-go-to-definitions : outputs a OGTD binary file of go to definitions for identifiers within an Odin project\n"); - bad_flags = true; - } - } - return !bad_flags; } -void timings_export_all(Timings *t, Checker *c, bool timings_are_finalized = false) { +gb_internal void timings_export_all(Timings *t, Checker *c, bool timings_are_finalized = false) { GB_ASSERT((!(build_context.export_timings_format == TimingsExportUnspecified) && build_context.export_timings_file.len > 0)); /* @@ -1690,10 +1691,9 @@ void timings_export_all(Timings *t, Checker *c, bool timings_are_finalized = fal isize files = 0; isize packages = p->packages.count; isize total_file_size = 0; - for_array(i, p->packages) { - files += p->packages[i]->files.count; - for_array(j, p->packages[i]->files) { - AstFile *file = p->packages[i]->files[j]; + for (AstPackage *pkg : p->packages) { + files += pkg->files.count; + for (AstFile *file : pkg->files) { total_file_size += file->tokenizer.end - file->tokenizer.start; } } @@ -1717,8 +1717,7 @@ void timings_export_all(Timings *t, Checker *c, bool timings_are_finalized = fal gb_fprintf(&f, "\t\t{\"name\": \"%.*s\", \"millis\": %.3f},\n", LIT(t->total.label), total_time); - for_array(i, t->sections) { - TimeStamp ts = t->sections[i]; + for (TimeStamp const &ts : t->sections) { f64 section_time = time_stamp(ts, t->freq, unit); gb_fprintf(&f, "\t\t{\"name\": \"%.*s\", \"millis\": %.3f},\n", LIT(ts.label), section_time); @@ -1739,8 +1738,7 @@ void timings_export_all(Timings *t, Checker *c, bool timings_are_finalized = fal */ gb_fprintf(&f, "\"%.*s\", %d\n", LIT(t->total.label), int(total_time)); - for_array(i, t->sections) { - TimeStamp ts = t->sections[i]; + for (TimeStamp const &ts : t->sections) { f64 section_time = time_stamp(ts, t->freq, unit); gb_fprintf(&f, "\"%.*s\", %d\n", LIT(ts.label), int(section_time)); } @@ -1749,7 +1747,7 @@ void timings_export_all(Timings *t, Checker *c, bool timings_are_finalized = fal gb_printf("Done.\n"); } -void show_timings(Checker *c, Timings *t) { +gb_internal void show_timings(Checker *c, Timings *t) { Parser *p = c->parser; isize lines = p->total_line_count; isize tokens = p->total_token_count; @@ -1758,10 +1756,9 @@ void show_timings(Checker *c, Timings *t) { isize total_file_size = 0; f64 total_tokenizing_time = 0; f64 total_parsing_time = 0; - for_array(i, p->packages) { - files += p->packages[i]->files.count; - for_array(j, p->packages[i]->files) { - AstFile *file = p->packages[i]->files[j]; + for (AstPackage *pkg : p->packages) { + files += pkg->files.count; + for (AstFile *file : pkg->files) { total_tokenizing_time += file->time_to_tokenize; total_parsing_time += file->time_to_parse; total_file_size += file->tokenizer.end - file->tokenizer.start; @@ -1770,6 +1767,8 @@ void show_timings(Checker *c, Timings *t) { timings_print_all(t); + PRINT_PEAK_USAGE(); + if (!(build_context.export_timings_format == TimingsExportUnspecified)) { timings_export_all(t, c, true); } @@ -1812,8 +1811,7 @@ void show_timings(Checker *c, Timings *t) { } { TimeStamp ts = {}; - for_array(i, t->sections) { - TimeStamp s = t->sections[i]; + for (TimeStamp const &s : t->sections) { if (s.label == "parse files") { ts = s; break; @@ -1836,8 +1834,7 @@ void show_timings(Checker *c, Timings *t) { { TimeStamp ts = {}; TimeStamp ts_end = {}; - for_array(i, t->sections) { - TimeStamp s = t->sections[i]; + for (TimeStamp const &s : t->sections) { if (s.label == "type check") { ts = s; } @@ -1878,13 +1875,23 @@ void show_timings(Checker *c, Timings *t) { } } -void remove_temp_files(lbGenerator *gen) { +gb_internal void remove_temp_files(lbGenerator *gen) { if (build_context.keep_temp_files) return; + switch (build_context.build_mode) { + case BuildMode_Executable: + case BuildMode_DynamicLibrary: + break; + + case BuildMode_Object: + case BuildMode_Assembly: + case BuildMode_LLVM_IR: + return; + } + TIME_SECTION("remove keep temp files"); - for_array(i, gen->output_temp_paths) { - String path = gen->output_temp_paths[i]; + for (String const &path : gen->output_temp_paths) { gb_file_remove(cast(char const *)path.text); } @@ -1892,8 +1899,7 @@ void remove_temp_files(lbGenerator *gen) { switch (build_context.build_mode) { case BuildMode_Executable: case BuildMode_DynamicLibrary: - for_array(i, gen->output_object_paths) { - String path = gen->output_object_paths[i]; + for (String const &path : gen->output_object_paths) { gb_file_remove(cast(char const *)path.text); } break; @@ -1902,7 +1908,7 @@ void remove_temp_files(lbGenerator *gen) { } -void print_show_help(String const arg0, String const &command) { +gb_internal void print_show_help(String const arg0, String const &command) { print_usage_line(0, "%.*s is a tool for managing Odin source code", LIT(arg0)); print_usage_line(0, "Usage:"); print_usage_line(1, "%.*s %.*s [arguments]", LIT(arg0), LIT(command)); @@ -1931,8 +1937,6 @@ void print_show_help(String const arg0, String const &command) { print_usage_line(3, "odin check filename.odin -file # Type check single-file package, must contain entry point."); } else if (command == "test") { print_usage_line(1, "test Build and runs procedures with the attribute @(test) in the initial package"); - } else if (command == "query") { - print_usage_line(1, "query [experimental] Parse, type check, and output a .json file containing information about the program"); } else if (command == "doc") { print_usage_line(1, "doc generate documentation from a directory of .odin files"); print_usage_line(2, "Examples:"); @@ -1987,7 +1991,7 @@ void print_show_help(String const arg0, String const &command) { print_usage_line(1, "-o:"); print_usage_line(2, "Set the optimization mode for compilation"); - print_usage_line(2, "Accepted values: minimal, size, speed"); + print_usage_line(2, "Accepted values: minimal, size, speed, none"); print_usage_line(2, "Example: -o:speed"); print_usage_line(0, ""); } @@ -2093,6 +2097,10 @@ void print_show_help(String const arg0, String const &command) { print_usage_line(2, "Disables automatic linking with the C Run Time"); print_usage_line(0, ""); + print_usage_line(1, "-no-thread-local"); + print_usage_line(2, "Ignore @thread_local attribute, effectively treating the program as if it is single-threaded"); + print_usage_line(0, ""); + print_usage_line(1, "-lld"); print_usage_line(2, "Use the LLD linker rather than the default"); print_usage_line(0, ""); @@ -2180,6 +2188,11 @@ void print_show_help(String const arg0, String const &command) { print_usage_line(1, "-disable-red-zone"); print_usage_line(2, "Disable red zone on a supported freestanding target"); + print_usage_line(0, ""); + + print_usage_line(1, "-dynamic-map-calls"); + print_usage_line(2, "Use dynamic map calls to minimize code generation at the cost of runtime execution"); + print_usage_line(0, ""); } if (check) { @@ -2207,8 +2220,21 @@ void print_show_help(String const arg0, String const &command) { print_usage_line(2, "Treats warning messages as error messages"); print_usage_line(0, ""); - print_usage_line(1, "-verbose-errors"); - print_usage_line(2, "Prints verbose error messages showing the code on that line and the location in that line"); + print_usage_line(1, "-terse-errors"); + print_usage_line(2, "Prints a terse error message without showing the code on that line and the location in that line"); + print_usage_line(0, ""); + + print_usage_line(1, "-error-pos-style:"); + print_usage_line(2, "Options are 'unix', 'odin' and 'default' (odin)"); + print_usage_line(2, "'odin' file/path(45:3)"); + print_usage_line(2, "'unix' file/path:45:3:"); + print_usage_line(0, ""); + + + print_usage_line(1, "-max-error-count:"); + print_usage_line(2, "Set the maximum number of errors that can be displayed before the compiler terminates"); + print_usage_line(2, "Must be an integer >0"); + print_usage_line(2, "If not set, the default max error count is %d", DEFAULT_MAX_ERROR_COLLECTOR_COUNT); print_usage_line(0, ""); print_usage_line(1, "-foreign-error-procedures"); @@ -2248,12 +2274,11 @@ void print_show_help(String const arg0, String const &command) { } } -void print_show_unused(Checker *c) { +gb_internal void print_show_unused(Checker *c) { CheckerInfo *info = &c->info; auto unused = array_make(permanent_allocator(), 0, info->entities.count); - for_array(i, info->entities) { - Entity *e = info->entities[i]; + for (Entity *e : info->entities) { if (e == nullptr) { continue; } @@ -2300,8 +2325,7 @@ void print_show_unused(Checker *c) { AstPackage *curr_pkg = nullptr; EntityKind curr_entity_kind = Entity_Invalid; - for_array(i, unused) { - Entity *e = unused[i]; + for (Entity *e : unused) { if (curr_pkg != e->pkg) { curr_pkg = e->pkg; curr_entity_kind = Entity_Invalid; @@ -2322,7 +2346,7 @@ void print_show_unused(Checker *c) { print_usage_line(0, ""); } -bool check_env(void) { +gb_internal bool check_env(void) { gbAllocator a = heap_allocator(); char const *odin_root = gb_get_env("ODIN_ROOT", a); defer (gb_free(a, cast(void *)odin_root)); @@ -2348,25 +2372,24 @@ struct StripSemicolonFile { i64 written; }; -gbFileError write_file_with_stripped_tokens(gbFile *f, AstFile *file, i64 *written_) { +gb_internal gbFileError write_file_with_stripped_tokens(gbFile *f, AstFile *file, i64 *written_) { i64 written = 0; gbFileError err = gbFileError_None; u8 const *file_data = file->tokenizer.start; i32 prev_offset = 0; i32 const end_offset = cast(i32)(file->tokenizer.end - file->tokenizer.start); - for_array(i, file->tokens) { - Token *token = &file->tokens[i]; - if (token->flags & (TokenFlag_Remove|TokenFlag_Replace)) { - i32 offset = token->pos.offset; + for (Token const &token : file->tokens) { + if (token.flags & (TokenFlag_Remove|TokenFlag_Replace)) { + i32 offset = token.pos.offset; i32 to_write = offset-prev_offset; if (!gb_file_write(f, file_data+prev_offset, to_write)) { return gbFileError_Invalid; } written += to_write; - prev_offset = token_pos_end(*token).offset; + prev_offset = token_pos_end(token).offset; } - if (token->flags & TokenFlag_Replace) { - if (token->kind == Token_Ellipsis) { + if (token.flags & TokenFlag_Replace) { + if (token.kind == Token_Ellipsis) { if (!gb_file_write(f, "..=", 3)) { return gbFileError_Invalid; } @@ -2388,24 +2411,19 @@ gbFileError write_file_with_stripped_tokens(gbFile *f, AstFile *file, i64 *writt return err; } -int strip_semicolons(Parser *parser) { +gb_internal int strip_semicolons(Parser *parser) { isize file_count = 0; - for_array(i, parser->packages) { - AstPackage *pkg = parser->packages[i]; + for (AstPackage *pkg : parser->packages) { file_count += pkg->files.count; } auto generated_files = array_make(permanent_allocator(), 0, file_count); - for_array(i, parser->packages) { - AstPackage *pkg = parser->packages[i]; - for_array(j, pkg->files) { - AstFile *file = pkg->files[j]; - + for (AstPackage *pkg : parser->packages) { + for (AstFile *file : pkg->files) { bool nothing_to_change = true; - for_array(i, file->tokens) { - Token *token = &file->tokens[i]; - if (token->flags) { + for (Token const &token : file->tokens) { + if (token.flags) { nothing_to_change = false; break; } @@ -2433,9 +2451,8 @@ int strip_semicolons(Parser *parser) { isize generated_count = 0; bool failed = false; - for_array(i, generated_files) { - auto *file = &generated_files[i]; - char const *filename = cast(char const *)file->new_fullpath.text; + for (StripSemicolonFile &file : generated_files) { + char const *filename = cast(char const *)file.new_fullpath.text; gbFileError err = gbFileError_None; defer (if (err != gbFileError_None) { failed = true; @@ -2453,11 +2470,11 @@ int strip_semicolons(Parser *parser) { defer (err = gb_file_truncate(&f, written)); debugf("Write file with stripped tokens: %s\n", filename); - err = write_file_with_stripped_tokens(&f, file->file, &written); + err = write_file_with_stripped_tokens(&f, file.file, &written); if (err) { break; } - file->written = written; + file.written = written; } if (failed) { @@ -2472,12 +2489,10 @@ int strip_semicolons(Parser *parser) { isize overwritten_files = 0; - for_array(i, generated_files) { - auto *file = &generated_files[i]; - - char const *old_fullpath = cast(char const *)file->old_fullpath.text; - char const *old_fullpath_backup = cast(char const *)file->old_fullpath_backup.text; - char const *new_fullpath = cast(char const *)file->new_fullpath.text; + for (StripSemicolonFile const &file : generated_files) { + char const *old_fullpath = cast(char const *)file.old_fullpath.text; + char const *old_fullpath_backup = cast(char const *)file.old_fullpath_backup.text; + char const *new_fullpath = cast(char const *)file.new_fullpath.text; debugf("Copy '%s' to '%s'\n", old_fullpath, old_fullpath_backup); if (!gb_file_copy(old_fullpath, old_fullpath_backup, false)) { @@ -2532,27 +2547,46 @@ int strip_semicolons(Parser *parser) { return cast(int)failed; } +gb_internal void init_terminal(void) { + build_context.has_ansi_terminal_colours = false; +#if defined(GB_SYSTEM_WINDOWS) + HANDLE hnd = GetStdHandle(STD_ERROR_HANDLE); + DWORD mode = 0; + if (GetConsoleMode(hnd, &mode)) { + enum {FLAG_ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x0004}; + if (SetConsoleMode(hnd, mode|FLAG_ENABLE_VIRTUAL_TERMINAL_PROCESSING)) { + build_context.has_ansi_terminal_colours = true; + } + } +#endif + + if (!build_context.has_ansi_terminal_colours) { + gbAllocator a = heap_allocator(); + char const *odin_terminal_ = gb_get_env("ODIN_TERMINAL", a); + defer (gb_free(a, cast(void *)odin_terminal_)); + String odin_terminal = make_string_c(odin_terminal_); + if (str_eq_ignore_case(odin_terminal, str_lit("ansi"))) { + build_context.has_ansi_terminal_colours = true; + } + } +} + int main(int arg_count, char const **arg_ptr) { if (arg_count < 2) { usage(make_string_c(arg_ptr[0])); return 1; } + virtual_memory_init(); timings_init(&global_timings, str_lit("Total Time"), 2048); defer (timings_destroy(&global_timings)); MAIN_TIME_SECTION("initialization"); - virtual_memory_init(); - mutex_init(&fullpath_mutex); - mutex_init(&hash_exact_value_mutex); - mutex_init(&global_type_name_objc_metadata_mutex); - - init_string_buffer_memory(); init_string_interner(); init_global_error_collector(); init_keyword_hash_table(); - init_type_mutex(); + init_terminal(); if (!check_env()) { return 1; @@ -2563,9 +2597,9 @@ int main(int arg_count, char const **arg_ptr) { add_library_collection(str_lit("core"), get_fullpath_relative(heap_allocator(), odin_root_dir(), str_lit("core"))); add_library_collection(str_lit("vendor"), get_fullpath_relative(heap_allocator(), odin_root_dir(), str_lit("vendor"))); - map_init(&build_context.defined_values, heap_allocator()); + map_init(&build_context.defined_values); build_context.extra_packages.allocator = heap_allocator(); - string_set_init(&build_context.test_names, heap_allocator()); + string_set_init(&build_context.test_names); Array args = setup_args(arg_count, arg_ptr); @@ -2627,15 +2661,6 @@ int main(int arg_count, char const **arg_ptr) { build_context.command_kind = Command_strip_semicolon; build_context.no_output_files = true; init_filename = args[2]; - } else if (command == "query") { - if (args.count < 3) { - usage(args[0]); - return 1; - } - build_context.command_kind = Command_query; - build_context.no_output_files = true; - build_context.query_data_set_settings.ok = true; - init_filename = args[2]; } else if (command == "doc") { if (args.count < 3) { usage(args[0]); @@ -2824,12 +2849,8 @@ int main(int arg_count, char const **arg_ptr) { print_show_unused(checker); } - if (build_context.query_data_set_settings.ok) { - generate_and_print_query_data(checker, &global_timings); - } else { - if (build_context.show_timings) { - show_timings(checker, &global_timings); - } + if (build_context.show_timings) { + show_timings(checker, &global_timings); } if (global_error_collector.count != 0) { @@ -2844,19 +2865,19 @@ int main(int arg_count, char const **arg_ptr) { if (!lb_init_generator(gen, checker)) { return 1; } - lb_generate_code(gen); - - switch (build_context.build_mode) { - case BuildMode_Executable: - case BuildMode_DynamicLibrary: - i32 result = linker_stage(gen); - if (result) { - if (build_context.show_timings) { - show_timings(checker, &global_timings); + if (lb_generate_code(gen)) { + switch (build_context.build_mode) { + case BuildMode_Executable: + case BuildMode_DynamicLibrary: + i32 result = linker_stage(gen); + if (result) { + if (build_context.show_timings) { + show_timings(checker, &global_timings); + } + return result; } - return result; + break; } - break; } remove_temp_files(gen); diff --git a/src/microsoft_craziness.h b/src/microsoft_craziness.h index fc5f09904..899583143 100644 --- a/src/microsoft_craziness.h +++ b/src/microsoft_craziness.h @@ -45,7 +45,7 @@ // // Here is the API you need to know about: // -gb_global gbAllocator mc_allocator = heap_allocator(); +gb_global gbAllocator mc_allocator = permanent_allocator(); struct Find_Result { int windows_sdk_version; // Zero if no Windows SDK found. @@ -58,50 +58,46 @@ struct Find_Result { String vs_library_path; }; -String mc_wstring_to_string(wchar_t const *str) { +gb_internal String mc_wstring_to_string(wchar_t const *str) { return string16_to_string(mc_allocator, make_string16_c(str)); } -String16 mc_string_to_wstring(String str) { +gb_internal String16 mc_string_to_wstring(String str) { return string_to_string16(mc_allocator, str); } -String mc_concat(String a, String b) { +gb_internal String mc_concat(String a, String b) { return concatenate_strings(mc_allocator, a, b); } -String mc_concat(String a, String b, String c) { +gb_internal String mc_concat(String a, String b, String c) { return concatenate3_strings(mc_allocator, a, b, c); } -String mc_concat(String a, String b, String c, String d) { +gb_internal String mc_concat(String a, String b, String c, String d) { return concatenate4_strings(mc_allocator, a, b, c, d); } -String mc_get_env(String key) { +gb_internal String mc_get_env(String key) { char const * value = gb_get_env((char const *)key.text, mc_allocator); return make_string_c(value); } -void mc_free(String str) { +gb_internal void mc_free(String str) { if (str.len) gb_free(mc_allocator, str.text); } -void mc_free(String16 str) { +gb_internal void mc_free(String16 str) { if (str.len) gb_free(mc_allocator, str.text); } -void mc_free_all() { - gb_free_all(mc_allocator); -} - typedef struct _MC_Find_Data { DWORD file_attributes; String filename; } MC_Find_Data; -HANDLE mc_find_first(String wildcard, MC_Find_Data *find_data) { +gb_internal HANDLE mc_find_first(String wildcard, MC_Find_Data *find_data) { WIN32_FIND_DATAW _find_data; String16 wildcard_wide = mc_string_to_wstring(wildcard); @@ -115,7 +111,7 @@ HANDLE mc_find_first(String wildcard, MC_Find_Data *find_data) { return handle; } -bool mc_find_next(HANDLE handle, MC_Find_Data *find_data) { +gb_internal bool mc_find_next(HANDLE handle, MC_Find_Data *find_data) { WIN32_FIND_DATAW _find_data; bool success = !!FindNextFileW(handle, &_find_data); @@ -124,7 +120,7 @@ bool mc_find_next(HANDLE handle, MC_Find_Data *find_data) { return success; } -void mc_find_close(HANDLE handle) { +gb_internal void mc_find_close(HANDLE handle) { FindClose(handle); } @@ -216,7 +212,7 @@ struct Version_Data { }; typedef void (*MC_Visit_Proc)(String short_name, String full_name, Version_Data *data); -bool mc_visit_files(String dir_name, Version_Data *data, MC_Visit_Proc proc) { +gb_internal bool mc_visit_files(String dir_name, Version_Data *data, MC_Visit_Proc proc) { // Visit everything in one folder (non-recursively). If it's a directory // that doesn't start with ".", call the visit proc on it. The visit proc @@ -246,7 +242,7 @@ bool mc_visit_files(String dir_name, Version_Data *data, MC_Visit_Proc proc) { return true; } -String find_windows_kit_root(HKEY key, String const version) { +gb_internal String find_windows_kit_root(HKEY key, String const version) { // Given a key to an already opened registry entry, // get the value stored under the 'version' subkey. // If that's not the right terminology, hey, I never do registry stuff. @@ -275,7 +271,7 @@ String find_windows_kit_root(HKEY key, String const version) { return value; } -void win10_best(String short_name, String full_name, Version_Data *data) { +gb_internal void win10_best(String short_name, String full_name, Version_Data *data) { // Find the Windows 10 subdirectory with the highest version number. int i0, i1, i2, i3; @@ -307,7 +303,7 @@ void win10_best(String short_name, String full_name, Version_Data *data) { } } -void find_windows_kit_paths(Find_Result *result) { +gb_internal void find_windows_kit_paths(Find_Result *result) { bool sdk_found = false; HKEY main_key; @@ -355,7 +351,7 @@ void find_windows_kit_paths(Find_Result *result) { } } -bool find_visual_studio_by_fighting_through_microsoft_craziness(Find_Result *result) { +gb_internal bool find_visual_studio_by_fighting_through_microsoft_craziness(Find_Result *result) { // The name of this procedure is kind of cryptic. Its purpose is // to fight through Microsoft craziness. The things that the fine // Visual Studio team want you to do, JUST TO FIND A SINGLE FOLDER @@ -519,7 +515,7 @@ bool find_visual_studio_by_fighting_through_microsoft_craziness(Find_Result *res // NOTE(WalterPlinge): Environment variables can help to find Visual C++ and WinSDK paths for both // official and portable installations (like mmozeiko's portable msvc script). -void find_windows_kit_paths_from_env_vars(Find_Result *result) { +gb_internal void find_windows_kit_paths_from_env_vars(Find_Result *result) { if (build_context.metrics.arch != TargetArch_amd64 && build_context.metrics.arch != TargetArch_i386) { return; } @@ -669,7 +665,7 @@ void find_windows_kit_paths_from_env_vars(Find_Result *result) { // NOTE(WalterPlinge): Environment variables can help to find Visual C++ and WinSDK paths for both // official and portable installations (like mmozeiko's portable msvc script). This will only use // the first paths it finds, and won't overwrite any values that `result` already has. -void find_visual_studio_paths_from_env_vars(Find_Result *result) { +gb_internal void find_visual_studio_paths_from_env_vars(Find_Result *result) { if (build_context.metrics.arch != TargetArch_amd64 && build_context.metrics.arch != TargetArch_i386) { return; } @@ -756,7 +752,7 @@ void find_visual_studio_paths_from_env_vars(Find_Result *result) { } } -Find_Result find_visual_studio_and_windows_sdk() { +gb_internal Find_Result find_visual_studio_and_windows_sdk() { Find_Result r = {}; find_windows_kit_paths(&r); find_visual_studio_by_fighting_through_microsoft_craziness(&r); diff --git a/src/parser.cpp b/src/parser.cpp index 884ddefa2..b756412ff 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -3,7 +3,7 @@ // #undef at the bottom of this file #define ALLOW_NEWLINE (!build_context.strict_style) -Token token_end_of_line(AstFile *f, Token tok) { +gb_internal Token token_end_of_line(AstFile *f, Token tok) { u8 const *start = f->tokenizer.start + tok.pos.offset; u8 const *s = start; while (*s && *s != '\n' && s < f->tokenizer.end) { @@ -13,7 +13,7 @@ Token token_end_of_line(AstFile *f, Token tok) { return tok; } -gbString get_file_line_as_string(TokenPos const &pos, i32 *offset_) { +gb_internal gbString get_file_line_as_string(TokenPos const &pos, i32 *offset_) { AstFile *file = thread_safe_get_ast_file_from_id(pos.file_id); if (file == nullptr) { return nullptr; @@ -55,7 +55,7 @@ gbString get_file_line_as_string(TokenPos const &pos, i32 *offset_) { -isize ast_node_size(AstKind kind) { +gb_internal isize ast_node_size(AstKind kind) { return align_formula_isize(gb_size_of(AstCommonStuff) + ast_variant_sizes[kind], gb_align_of(void *)); } @@ -63,47 +63,47 @@ isize ast_node_size(AstKind kind) { gb_global std::atomic global_total_node_memory_allocated; // NOTE(bill): And this below is why is I/we need a new language! Discriminated unions are a pain in C/C++ -Ast *alloc_ast_node(AstFile *f, AstKind kind) { - gbAllocator a = ast_allocator(f); - +gb_internal Ast *alloc_ast_node(AstFile *f, AstKind kind) { isize size = ast_node_size(kind); - Ast *node = cast(Ast *)gb_alloc(a, size); + Ast *node = cast(Ast *)arena_alloc(&global_thread_local_ast_arena, size, 16); node->kind = kind; node->file_id = f ? f->id : 0; - global_total_node_memory_allocated += size; + global_total_node_memory_allocated.fetch_add(size); return node; } -Ast *clone_ast(Ast *node); -Array clone_ast_array(Array const &array) { +gb_internal Ast *clone_ast(Ast *node, AstFile *f = nullptr); +gb_internal Array clone_ast_array(Array const &array, AstFile *f) { Array result = {}; if (array.count > 0) { result = array_make(ast_allocator(nullptr), array.count); for_array(i, array) { - result[i] = clone_ast(array[i]); + result[i] = clone_ast(array[i], f); } } return result; } -Slice clone_ast_array(Slice const &array) { +gb_internal Slice clone_ast_array(Slice const &array, AstFile *f) { Slice result = {}; if (array.count > 0) { - result = slice_clone(permanent_allocator(), array); + result = slice_clone(ast_allocator(nullptr), array); for_array(i, array) { - result[i] = clone_ast(array[i]); + result[i] = clone_ast(array[i], f); } } return result; } -Ast *clone_ast(Ast *node) { +gb_internal Ast *clone_ast(Ast *node, AstFile *f) { if (node == nullptr) { return nullptr; } - AstFile *f = node->thread_safe_file(); + if (f == nullptr) { + f = node->thread_safe_file(); + } Ast *n = alloc_ast_node(f, node->kind); gb_memmove(n, node, ast_node_size(node->kind)); @@ -115,287 +115,284 @@ Ast *clone_ast(Ast *node) { n->Ident.entity = nullptr; break; case Ast_Implicit: break; - case Ast_Undef: break; + case Ast_Uninit: break; case Ast_BasicLit: break; case Ast_BasicDirective: break; case Ast_PolyType: - n->PolyType.type = clone_ast(n->PolyType.type); - n->PolyType.specialization = clone_ast(n->PolyType.specialization); + n->PolyType.type = clone_ast(n->PolyType.type, f); + n->PolyType.specialization = clone_ast(n->PolyType.specialization, f); break; case Ast_Ellipsis: - n->Ellipsis.expr = clone_ast(n->Ellipsis.expr); + n->Ellipsis.expr = clone_ast(n->Ellipsis.expr, f); break; case Ast_ProcGroup: - n->ProcGroup.args = clone_ast_array(n->ProcGroup.args); + n->ProcGroup.args = clone_ast_array(n->ProcGroup.args, f); break; case Ast_ProcLit: - n->ProcLit.type = clone_ast(n->ProcLit.type); - n->ProcLit.body = clone_ast(n->ProcLit.body); - n->ProcLit.where_clauses = clone_ast_array(n->ProcLit.where_clauses); + n->ProcLit.type = clone_ast(n->ProcLit.type, f); + n->ProcLit.body = clone_ast(n->ProcLit.body, f); + n->ProcLit.where_clauses = clone_ast_array(n->ProcLit.where_clauses, f); break; case Ast_CompoundLit: - n->CompoundLit.type = clone_ast(n->CompoundLit.type); - n->CompoundLit.elems = clone_ast_array(n->CompoundLit.elems); + n->CompoundLit.type = clone_ast(n->CompoundLit.type, f); + n->CompoundLit.elems = clone_ast_array(n->CompoundLit.elems, f); break; case Ast_BadExpr: break; case Ast_TagExpr: - n->TagExpr.expr = clone_ast(n->TagExpr.expr); + n->TagExpr.expr = clone_ast(n->TagExpr.expr, f); break; case Ast_UnaryExpr: - n->UnaryExpr.expr = clone_ast(n->UnaryExpr.expr); + n->UnaryExpr.expr = clone_ast(n->UnaryExpr.expr, f); break; case Ast_BinaryExpr: - n->BinaryExpr.left = clone_ast(n->BinaryExpr.left); - n->BinaryExpr.right = clone_ast(n->BinaryExpr.right); + n->BinaryExpr.left = clone_ast(n->BinaryExpr.left, f); + n->BinaryExpr.right = clone_ast(n->BinaryExpr.right, f); break; case Ast_ParenExpr: - n->ParenExpr.expr = clone_ast(n->ParenExpr.expr); + n->ParenExpr.expr = clone_ast(n->ParenExpr.expr, f); break; case Ast_SelectorExpr: - n->SelectorExpr.expr = clone_ast(n->SelectorExpr.expr); - n->SelectorExpr.selector = clone_ast(n->SelectorExpr.selector); + n->SelectorExpr.expr = clone_ast(n->SelectorExpr.expr, f); + n->SelectorExpr.selector = clone_ast(n->SelectorExpr.selector, f); break; case Ast_ImplicitSelectorExpr: - n->ImplicitSelectorExpr.selector = clone_ast(n->ImplicitSelectorExpr.selector); + n->ImplicitSelectorExpr.selector = clone_ast(n->ImplicitSelectorExpr.selector, f); break; case Ast_SelectorCallExpr: - n->SelectorCallExpr.expr = clone_ast(n->SelectorCallExpr.expr); - n->SelectorCallExpr.call = clone_ast(n->SelectorCallExpr.call); + n->SelectorCallExpr.expr = clone_ast(n->SelectorCallExpr.expr, f); + n->SelectorCallExpr.call = clone_ast(n->SelectorCallExpr.call, f); break; case Ast_IndexExpr: - n->IndexExpr.expr = clone_ast(n->IndexExpr.expr); - n->IndexExpr.index = clone_ast(n->IndexExpr.index); + n->IndexExpr.expr = clone_ast(n->IndexExpr.expr, f); + n->IndexExpr.index = clone_ast(n->IndexExpr.index, f); break; case Ast_MatrixIndexExpr: - n->MatrixIndexExpr.expr = clone_ast(n->MatrixIndexExpr.expr); - n->MatrixIndexExpr.row_index = clone_ast(n->MatrixIndexExpr.row_index); - n->MatrixIndexExpr.column_index = clone_ast(n->MatrixIndexExpr.column_index); + n->MatrixIndexExpr.expr = clone_ast(n->MatrixIndexExpr.expr, f); + n->MatrixIndexExpr.row_index = clone_ast(n->MatrixIndexExpr.row_index, f); + n->MatrixIndexExpr.column_index = clone_ast(n->MatrixIndexExpr.column_index, f); break; case Ast_DerefExpr: - n->DerefExpr.expr = clone_ast(n->DerefExpr.expr); + n->DerefExpr.expr = clone_ast(n->DerefExpr.expr, f); break; case Ast_SliceExpr: - n->SliceExpr.expr = clone_ast(n->SliceExpr.expr); - n->SliceExpr.low = clone_ast(n->SliceExpr.low); - n->SliceExpr.high = clone_ast(n->SliceExpr.high); + n->SliceExpr.expr = clone_ast(n->SliceExpr.expr, f); + n->SliceExpr.low = clone_ast(n->SliceExpr.low, f); + n->SliceExpr.high = clone_ast(n->SliceExpr.high, f); break; case Ast_CallExpr: - n->CallExpr.proc = clone_ast(n->CallExpr.proc); - n->CallExpr.args = clone_ast_array(n->CallExpr.args); + n->CallExpr.proc = clone_ast(n->CallExpr.proc, f); + n->CallExpr.args = clone_ast_array(n->CallExpr.args, f); break; case Ast_FieldValue: - n->FieldValue.field = clone_ast(n->FieldValue.field); - n->FieldValue.value = clone_ast(n->FieldValue.value); + n->FieldValue.field = clone_ast(n->FieldValue.field, f); + n->FieldValue.value = clone_ast(n->FieldValue.value, f); break; case Ast_EnumFieldValue: - n->EnumFieldValue.name = clone_ast(n->EnumFieldValue.name); - n->EnumFieldValue.value = clone_ast(n->EnumFieldValue.value); + n->EnumFieldValue.name = clone_ast(n->EnumFieldValue.name, f); + n->EnumFieldValue.value = clone_ast(n->EnumFieldValue.value, f); break; case Ast_TernaryIfExpr: - n->TernaryIfExpr.x = clone_ast(n->TernaryIfExpr.x); - n->TernaryIfExpr.cond = clone_ast(n->TernaryIfExpr.cond); - n->TernaryIfExpr.y = clone_ast(n->TernaryIfExpr.y); + n->TernaryIfExpr.x = clone_ast(n->TernaryIfExpr.x, f); + n->TernaryIfExpr.cond = clone_ast(n->TernaryIfExpr.cond, f); + n->TernaryIfExpr.y = clone_ast(n->TernaryIfExpr.y, f); break; case Ast_TernaryWhenExpr: - n->TernaryWhenExpr.x = clone_ast(n->TernaryWhenExpr.x); - n->TernaryWhenExpr.cond = clone_ast(n->TernaryWhenExpr.cond); - n->TernaryWhenExpr.y = clone_ast(n->TernaryWhenExpr.y); + n->TernaryWhenExpr.x = clone_ast(n->TernaryWhenExpr.x, f); + n->TernaryWhenExpr.cond = clone_ast(n->TernaryWhenExpr.cond, f); + n->TernaryWhenExpr.y = clone_ast(n->TernaryWhenExpr.y, f); break; case Ast_OrElseExpr: - n->OrElseExpr.x = clone_ast(n->OrElseExpr.x); - n->OrElseExpr.y = clone_ast(n->OrElseExpr.y); + n->OrElseExpr.x = clone_ast(n->OrElseExpr.x, f); + n->OrElseExpr.y = clone_ast(n->OrElseExpr.y, f); break; case Ast_OrReturnExpr: - n->OrReturnExpr.expr = clone_ast(n->OrReturnExpr.expr); + n->OrReturnExpr.expr = clone_ast(n->OrReturnExpr.expr, f); break; case Ast_TypeAssertion: - n->TypeAssertion.expr = clone_ast(n->TypeAssertion.expr); - n->TypeAssertion.type = clone_ast(n->TypeAssertion.type); + n->TypeAssertion.expr = clone_ast(n->TypeAssertion.expr, f); + n->TypeAssertion.type = clone_ast(n->TypeAssertion.type, f); break; case Ast_TypeCast: - n->TypeCast.type = clone_ast(n->TypeCast.type); - n->TypeCast.expr = clone_ast(n->TypeCast.expr); + n->TypeCast.type = clone_ast(n->TypeCast.type, f); + n->TypeCast.expr = clone_ast(n->TypeCast.expr, f); break; case Ast_AutoCast: - n->AutoCast.expr = clone_ast(n->AutoCast.expr); + n->AutoCast.expr = clone_ast(n->AutoCast.expr, f); break; case Ast_InlineAsmExpr: - n->InlineAsmExpr.param_types = clone_ast_array(n->InlineAsmExpr.param_types); - n->InlineAsmExpr.return_type = clone_ast(n->InlineAsmExpr.return_type); - n->InlineAsmExpr.asm_string = clone_ast(n->InlineAsmExpr.asm_string); - n->InlineAsmExpr.constraints_string = clone_ast(n->InlineAsmExpr.constraints_string); + n->InlineAsmExpr.param_types = clone_ast_array(n->InlineAsmExpr.param_types, f); + n->InlineAsmExpr.return_type = clone_ast(n->InlineAsmExpr.return_type, f); + n->InlineAsmExpr.asm_string = clone_ast(n->InlineAsmExpr.asm_string, f); + n->InlineAsmExpr.constraints_string = clone_ast(n->InlineAsmExpr.constraints_string, f); break; case Ast_BadStmt: break; case Ast_EmptyStmt: break; case Ast_ExprStmt: - n->ExprStmt.expr = clone_ast(n->ExprStmt.expr); - break; - case Ast_TagStmt: - n->TagStmt.stmt = clone_ast(n->TagStmt.stmt); + n->ExprStmt.expr = clone_ast(n->ExprStmt.expr, f); break; case Ast_AssignStmt: - n->AssignStmt.lhs = clone_ast_array(n->AssignStmt.lhs); - n->AssignStmt.rhs = clone_ast_array(n->AssignStmt.rhs); + n->AssignStmt.lhs = clone_ast_array(n->AssignStmt.lhs, f); + n->AssignStmt.rhs = clone_ast_array(n->AssignStmt.rhs, f); break; case Ast_BlockStmt: - n->BlockStmt.label = clone_ast(n->BlockStmt.label); - n->BlockStmt.stmts = clone_ast_array(n->BlockStmt.stmts); + n->BlockStmt.label = clone_ast(n->BlockStmt.label, f); + n->BlockStmt.stmts = clone_ast_array(n->BlockStmt.stmts, f); break; case Ast_IfStmt: - n->IfStmt.label = clone_ast(n->IfStmt.label); - n->IfStmt.init = clone_ast(n->IfStmt.init); - n->IfStmt.cond = clone_ast(n->IfStmt.cond); - n->IfStmt.body = clone_ast(n->IfStmt.body); - n->IfStmt.else_stmt = clone_ast(n->IfStmt.else_stmt); + n->IfStmt.label = clone_ast(n->IfStmt.label, f); + n->IfStmt.init = clone_ast(n->IfStmt.init, f); + n->IfStmt.cond = clone_ast(n->IfStmt.cond, f); + n->IfStmt.body = clone_ast(n->IfStmt.body, f); + n->IfStmt.else_stmt = clone_ast(n->IfStmt.else_stmt, f); break; case Ast_WhenStmt: - n->WhenStmt.cond = clone_ast(n->WhenStmt.cond); - n->WhenStmt.body = clone_ast(n->WhenStmt.body); - n->WhenStmt.else_stmt = clone_ast(n->WhenStmt.else_stmt); + n->WhenStmt.cond = clone_ast(n->WhenStmt.cond, f); + n->WhenStmt.body = clone_ast(n->WhenStmt.body, f); + n->WhenStmt.else_stmt = clone_ast(n->WhenStmt.else_stmt, f); break; case Ast_ReturnStmt: - n->ReturnStmt.results = clone_ast_array(n->ReturnStmt.results); + n->ReturnStmt.results = clone_ast_array(n->ReturnStmt.results, f); break; case Ast_ForStmt: - n->ForStmt.label = clone_ast(n->ForStmt.label); - n->ForStmt.init = clone_ast(n->ForStmt.init); - n->ForStmt.cond = clone_ast(n->ForStmt.cond); - n->ForStmt.post = clone_ast(n->ForStmt.post); - n->ForStmt.body = clone_ast(n->ForStmt.body); + n->ForStmt.label = clone_ast(n->ForStmt.label, f); + n->ForStmt.init = clone_ast(n->ForStmt.init, f); + n->ForStmt.cond = clone_ast(n->ForStmt.cond, f); + n->ForStmt.post = clone_ast(n->ForStmt.post, f); + n->ForStmt.body = clone_ast(n->ForStmt.body, f); break; case Ast_RangeStmt: - n->RangeStmt.label = clone_ast(n->RangeStmt.label); - n->RangeStmt.vals = clone_ast_array(n->RangeStmt.vals); - n->RangeStmt.expr = clone_ast(n->RangeStmt.expr); - n->RangeStmt.body = clone_ast(n->RangeStmt.body); + n->RangeStmt.label = clone_ast(n->RangeStmt.label, f); + n->RangeStmt.vals = clone_ast_array(n->RangeStmt.vals, f); + n->RangeStmt.expr = clone_ast(n->RangeStmt.expr, f); + n->RangeStmt.body = clone_ast(n->RangeStmt.body, f); break; case Ast_UnrollRangeStmt: - n->UnrollRangeStmt.val0 = clone_ast(n->UnrollRangeStmt.val0); - n->UnrollRangeStmt.val1 = clone_ast(n->UnrollRangeStmt.val1); - n->UnrollRangeStmt.expr = clone_ast(n->UnrollRangeStmt.expr); - n->UnrollRangeStmt.body = clone_ast(n->UnrollRangeStmt.body); + n->UnrollRangeStmt.val0 = clone_ast(n->UnrollRangeStmt.val0, f); + n->UnrollRangeStmt.val1 = clone_ast(n->UnrollRangeStmt.val1, f); + n->UnrollRangeStmt.expr = clone_ast(n->UnrollRangeStmt.expr, f); + n->UnrollRangeStmt.body = clone_ast(n->UnrollRangeStmt.body, f); break; case Ast_CaseClause: - n->CaseClause.list = clone_ast_array(n->CaseClause.list); - n->CaseClause.stmts = clone_ast_array(n->CaseClause.stmts); + n->CaseClause.list = clone_ast_array(n->CaseClause.list, f); + n->CaseClause.stmts = clone_ast_array(n->CaseClause.stmts, f); n->CaseClause.implicit_entity = nullptr; break; case Ast_SwitchStmt: - n->SwitchStmt.label = clone_ast(n->SwitchStmt.label); - n->SwitchStmt.init = clone_ast(n->SwitchStmt.init); - n->SwitchStmt.tag = clone_ast(n->SwitchStmt.tag); - n->SwitchStmt.body = clone_ast(n->SwitchStmt.body); + n->SwitchStmt.label = clone_ast(n->SwitchStmt.label, f); + n->SwitchStmt.init = clone_ast(n->SwitchStmt.init, f); + n->SwitchStmt.tag = clone_ast(n->SwitchStmt.tag, f); + n->SwitchStmt.body = clone_ast(n->SwitchStmt.body, f); break; case Ast_TypeSwitchStmt: - n->TypeSwitchStmt.label = clone_ast(n->TypeSwitchStmt.label); - n->TypeSwitchStmt.tag = clone_ast(n->TypeSwitchStmt.tag); - n->TypeSwitchStmt.body = clone_ast(n->TypeSwitchStmt.body); + n->TypeSwitchStmt.label = clone_ast(n->TypeSwitchStmt.label, f); + n->TypeSwitchStmt.tag = clone_ast(n->TypeSwitchStmt.tag, f); + n->TypeSwitchStmt.body = clone_ast(n->TypeSwitchStmt.body, f); break; case Ast_DeferStmt: - n->DeferStmt.stmt = clone_ast(n->DeferStmt.stmt); + n->DeferStmt.stmt = clone_ast(n->DeferStmt.stmt, f); break; case Ast_BranchStmt: - n->BranchStmt.label = clone_ast(n->BranchStmt.label); + n->BranchStmt.label = clone_ast(n->BranchStmt.label, f); break; case Ast_UsingStmt: - n->UsingStmt.list = clone_ast_array(n->UsingStmt.list); + n->UsingStmt.list = clone_ast_array(n->UsingStmt.list, f); break; case Ast_BadDecl: break; case Ast_ForeignBlockDecl: - n->ForeignBlockDecl.foreign_library = clone_ast(n->ForeignBlockDecl.foreign_library); - n->ForeignBlockDecl.body = clone_ast(n->ForeignBlockDecl.body); - n->ForeignBlockDecl.attributes = clone_ast_array(n->ForeignBlockDecl.attributes); + n->ForeignBlockDecl.foreign_library = clone_ast(n->ForeignBlockDecl.foreign_library, f); + n->ForeignBlockDecl.body = clone_ast(n->ForeignBlockDecl.body, f); + n->ForeignBlockDecl.attributes = clone_ast_array(n->ForeignBlockDecl.attributes, f); break; case Ast_Label: - n->Label.name = clone_ast(n->Label.name); + n->Label.name = clone_ast(n->Label.name, f); break; case Ast_ValueDecl: - n->ValueDecl.names = clone_ast_array(n->ValueDecl.names); - n->ValueDecl.type = clone_ast(n->ValueDecl.type); - n->ValueDecl.values = clone_ast_array(n->ValueDecl.values); - n->ValueDecl.attributes = clone_ast_array(n->ValueDecl.attributes); + n->ValueDecl.names = clone_ast_array(n->ValueDecl.names, f); + n->ValueDecl.type = clone_ast(n->ValueDecl.type, f); + n->ValueDecl.values = clone_ast_array(n->ValueDecl.values, f); + n->ValueDecl.attributes = clone_ast_array(n->ValueDecl.attributes, f); break; case Ast_Attribute: - n->Attribute.elems = clone_ast_array(n->Attribute.elems); + n->Attribute.elems = clone_ast_array(n->Attribute.elems, f); break; case Ast_Field: - n->Field.names = clone_ast_array(n->Field.names); - n->Field.type = clone_ast(n->Field.type); + n->Field.names = clone_ast_array(n->Field.names, f); + n->Field.type = clone_ast(n->Field.type, f); break; case Ast_FieldList: - n->FieldList.list = clone_ast_array(n->FieldList.list); + n->FieldList.list = clone_ast_array(n->FieldList.list, f); break; case Ast_TypeidType: - n->TypeidType.specialization = clone_ast(n->TypeidType.specialization); + n->TypeidType.specialization = clone_ast(n->TypeidType.specialization, f); break; case Ast_HelperType: - n->HelperType.type = clone_ast(n->HelperType.type); + n->HelperType.type = clone_ast(n->HelperType.type, f); break; case Ast_DistinctType: - n->DistinctType.type = clone_ast(n->DistinctType.type); + n->DistinctType.type = clone_ast(n->DistinctType.type, f); break; case Ast_ProcType: - n->ProcType.params = clone_ast(n->ProcType.params); - n->ProcType.results = clone_ast(n->ProcType.results); + n->ProcType.params = clone_ast(n->ProcType.params, f); + n->ProcType.results = clone_ast(n->ProcType.results, f); break; case Ast_RelativeType: - n->RelativeType.tag = clone_ast(n->RelativeType.tag); - n->RelativeType.type = clone_ast(n->RelativeType.type); + n->RelativeType.tag = clone_ast(n->RelativeType.tag, f); + n->RelativeType.type = clone_ast(n->RelativeType.type, f); break; case Ast_PointerType: - n->PointerType.type = clone_ast(n->PointerType.type); - n->PointerType.tag = clone_ast(n->PointerType.tag); + n->PointerType.type = clone_ast(n->PointerType.type, f); + n->PointerType.tag = clone_ast(n->PointerType.tag, f); break; case Ast_MultiPointerType: - n->MultiPointerType.type = clone_ast(n->MultiPointerType.type); + n->MultiPointerType.type = clone_ast(n->MultiPointerType.type, f); break; case Ast_ArrayType: - n->ArrayType.count = clone_ast(n->ArrayType.count); - n->ArrayType.elem = clone_ast(n->ArrayType.elem); - n->ArrayType.tag = clone_ast(n->ArrayType.tag); + n->ArrayType.count = clone_ast(n->ArrayType.count, f); + n->ArrayType.elem = clone_ast(n->ArrayType.elem, f); + n->ArrayType.tag = clone_ast(n->ArrayType.tag, f); break; case Ast_DynamicArrayType: - n->DynamicArrayType.elem = clone_ast(n->DynamicArrayType.elem); + n->DynamicArrayType.elem = clone_ast(n->DynamicArrayType.elem, f); break; case Ast_StructType: - n->StructType.fields = clone_ast_array(n->StructType.fields); - n->StructType.polymorphic_params = clone_ast(n->StructType.polymorphic_params); - n->StructType.align = clone_ast(n->StructType.align); - n->StructType.where_clauses = clone_ast_array(n->StructType.where_clauses); + n->StructType.fields = clone_ast_array(n->StructType.fields, f); + n->StructType.polymorphic_params = clone_ast(n->StructType.polymorphic_params, f); + n->StructType.align = clone_ast(n->StructType.align, f); + n->StructType.where_clauses = clone_ast_array(n->StructType.where_clauses, f); break; case Ast_UnionType: - n->UnionType.variants = clone_ast_array(n->UnionType.variants); - n->UnionType.polymorphic_params = clone_ast(n->UnionType.polymorphic_params); - n->UnionType.where_clauses = clone_ast_array(n->UnionType.where_clauses); + n->UnionType.variants = clone_ast_array(n->UnionType.variants, f); + n->UnionType.polymorphic_params = clone_ast(n->UnionType.polymorphic_params, f); + n->UnionType.where_clauses = clone_ast_array(n->UnionType.where_clauses, f); break; case Ast_EnumType: - n->EnumType.base_type = clone_ast(n->EnumType.base_type); - n->EnumType.fields = clone_ast_array(n->EnumType.fields); + n->EnumType.base_type = clone_ast(n->EnumType.base_type, f); + n->EnumType.fields = clone_ast_array(n->EnumType.fields, f); break; case Ast_BitSetType: - n->BitSetType.elem = clone_ast(n->BitSetType.elem); - n->BitSetType.underlying = clone_ast(n->BitSetType.underlying); + n->BitSetType.elem = clone_ast(n->BitSetType.elem, f); + n->BitSetType.underlying = clone_ast(n->BitSetType.underlying, f); break; case Ast_MapType: - n->MapType.count = clone_ast(n->MapType.count); - n->MapType.key = clone_ast(n->MapType.key); - n->MapType.value = clone_ast(n->MapType.value); + n->MapType.count = clone_ast(n->MapType.count, f); + n->MapType.key = clone_ast(n->MapType.key, f); + n->MapType.value = clone_ast(n->MapType.value, f); break; case Ast_MatrixType: - n->MatrixType.row_count = clone_ast(n->MatrixType.row_count); - n->MatrixType.column_count = clone_ast(n->MatrixType.column_count); - n->MatrixType.elem = clone_ast(n->MatrixType.elem); + n->MatrixType.row_count = clone_ast(n->MatrixType.row_count, f); + n->MatrixType.column_count = clone_ast(n->MatrixType.column_count, f); + n->MatrixType.elem = clone_ast(n->MatrixType.elem, f); break; } @@ -403,7 +400,7 @@ Ast *clone_ast(Ast *node) { } -void error(Ast *node, char const *fmt, ...) { +gb_internal void error(Ast *node, char const *fmt, ...) { Token token = {}; TokenPos end_pos = {}; if (node != nullptr) { @@ -421,7 +418,26 @@ void error(Ast *node, char const *fmt, ...) { } } -void error_no_newline(Ast *node, char const *fmt, ...) { +gb_internal void syntax_error_with_verbose(Ast *node, char const *fmt, ...) { + Token token = {}; + TokenPos end_pos = {}; + if (node != nullptr) { + token = ast_token(node); + end_pos = ast_end_pos(node); + } + + va_list va; + va_start(va, fmt); + syntax_error_with_verbose_va(token.pos, end_pos, fmt, va); + va_end(va); + if (node != nullptr && node->file_id != 0) { + AstFile *f = node->thread_safe_file(); + f->error_count += 1; + } +} + + +gb_internal void error_no_newline(Ast *node, char const *fmt, ...) { Token token = {}; if (node != nullptr) { token = ast_token(node); @@ -436,7 +452,7 @@ void error_no_newline(Ast *node, char const *fmt, ...) { } } -void warning(Ast *node, char const *fmt, ...) { +gb_internal void warning(Ast *node, char const *fmt, ...) { Token token = {}; TokenPos end_pos = {}; if (node != nullptr) { @@ -449,7 +465,7 @@ void warning(Ast *node, char const *fmt, ...) { va_end(va); } -void syntax_error(Ast *node, char const *fmt, ...) { +gb_internal void syntax_error(Ast *node, char const *fmt, ...) { Token token = {}; TokenPos end_pos = {}; if (node != nullptr) { @@ -467,14 +483,14 @@ void syntax_error(Ast *node, char const *fmt, ...) { } -bool ast_node_expect(Ast *node, AstKind kind) { +gb_internal bool ast_node_expect(Ast *node, AstKind kind) { if (node->kind != kind) { syntax_error(node, "Expected %.*s, got %.*s", LIT(ast_strings[kind]), LIT(ast_strings[node->kind])); return false; } return true; } -bool ast_node_expect2(Ast *node, AstKind kind0, AstKind kind1) { +gb_internal bool ast_node_expect2(Ast *node, AstKind kind0, AstKind kind1) { if (node->kind != kind0 && node->kind != kind1) { syntax_error(node, "Expected %.*s or %.*s, got %.*s", LIT(ast_strings[kind0]), LIT(ast_strings[kind1]), LIT(ast_strings[node->kind])); return false; @@ -482,14 +498,14 @@ bool ast_node_expect2(Ast *node, AstKind kind0, AstKind kind1) { return true; } -Ast *ast_bad_expr(AstFile *f, Token begin, Token end) { +gb_internal Ast *ast_bad_expr(AstFile *f, Token begin, Token end) { Ast *result = alloc_ast_node(f, Ast_BadExpr); result->BadExpr.begin = begin; result->BadExpr.end = end; return result; } -Ast *ast_tag_expr(AstFile *f, Token token, Token name, Ast *expr) { +gb_internal Ast *ast_tag_expr(AstFile *f, Token token, Token name, Ast *expr) { Ast *result = alloc_ast_node(f, Ast_TagExpr); result->TagExpr.token = token; result->TagExpr.name = name; @@ -497,22 +513,20 @@ Ast *ast_tag_expr(AstFile *f, Token token, Token name, Ast *expr) { return result; } -Ast *ast_tag_stmt(AstFile *f, Token token, Token name, Ast *stmt) { - Ast *result = alloc_ast_node(f, Ast_TagStmt); - result->TagStmt.token = token; - result->TagStmt.name = name; - result->TagStmt.stmt = stmt; - return result; -} - -Ast *ast_unary_expr(AstFile *f, Token op, Ast *expr) { +gb_internal Ast *ast_unary_expr(AstFile *f, Token op, Ast *expr) { Ast *result = alloc_ast_node(f, Ast_UnaryExpr); + + if (expr && expr->kind == Ast_OrReturnExpr) { + syntax_error_with_verbose(expr, "'or_return' within an unary expression not wrapped in parentheses (...)"); + } + result->UnaryExpr.op = op; result->UnaryExpr.expr = expr; return result; } -Ast *ast_binary_expr(AstFile *f, Token op, Ast *left, Ast *right) { + +gb_internal Ast *ast_binary_expr(AstFile *f, Token op, Ast *left, Ast *right) { Ast *result = alloc_ast_node(f, Ast_BinaryExpr); if (left == nullptr) { @@ -524,6 +538,13 @@ Ast *ast_binary_expr(AstFile *f, Token op, Ast *left, Ast *right) { right = ast_bad_expr(f, op, op); } + if (left->kind == Ast_OrReturnExpr) { + syntax_error_with_verbose(left, "'or_return' within a binary expression not wrapped in parentheses (...)"); + } + if (right->kind == Ast_OrReturnExpr) { + syntax_error_with_verbose(right, "'or_return' within a binary expression not wrapped in parentheses (...)"); + } + result->BinaryExpr.op = op; result->BinaryExpr.left = left; result->BinaryExpr.right = right; @@ -531,7 +552,7 @@ Ast *ast_binary_expr(AstFile *f, Token op, Ast *left, Ast *right) { return result; } -Ast *ast_paren_expr(AstFile *f, Ast *expr, Token open, Token close) { +gb_internal Ast *ast_paren_expr(AstFile *f, Ast *expr, Token open, Token close) { Ast *result = alloc_ast_node(f, Ast_ParenExpr); result->ParenExpr.expr = expr; result->ParenExpr.open = open; @@ -539,7 +560,7 @@ Ast *ast_paren_expr(AstFile *f, Ast *expr, Token open, Token close) { return result; } -Ast *ast_call_expr(AstFile *f, Ast *proc, Array const &args, Token open, Token close, Token ellipsis) { +gb_internal Ast *ast_call_expr(AstFile *f, Ast *proc, Array const &args, Token open, Token close, Token ellipsis) { Ast *result = alloc_ast_node(f, Ast_CallExpr); result->CallExpr.proc = proc; result->CallExpr.args = slice_from_array(args); @@ -550,7 +571,7 @@ Ast *ast_call_expr(AstFile *f, Ast *proc, Array const &args, Token open, } -Ast *ast_selector_expr(AstFile *f, Token token, Ast *expr, Ast *selector) { +gb_internal Ast *ast_selector_expr(AstFile *f, Token token, Ast *expr, Ast *selector) { Ast *result = alloc_ast_node(f, Ast_SelectorExpr); result->SelectorExpr.token = token; result->SelectorExpr.expr = expr; @@ -558,14 +579,14 @@ Ast *ast_selector_expr(AstFile *f, Token token, Ast *expr, Ast *selector) { return result; } -Ast *ast_implicit_selector_expr(AstFile *f, Token token, Ast *selector) { +gb_internal Ast *ast_implicit_selector_expr(AstFile *f, Token token, Ast *selector) { Ast *result = alloc_ast_node(f, Ast_ImplicitSelectorExpr); result->ImplicitSelectorExpr.token = token; result->ImplicitSelectorExpr.selector = selector; return result; } -Ast *ast_selector_call_expr(AstFile *f, Token token, Ast *expr, Ast *call) { +gb_internal Ast *ast_selector_call_expr(AstFile *f, Token token, Ast *expr, Ast *call) { Ast *result = alloc_ast_node(f, Ast_SelectorCallExpr); result->SelectorCallExpr.token = token; result->SelectorCallExpr.expr = expr; @@ -574,7 +595,7 @@ Ast *ast_selector_call_expr(AstFile *f, Token token, Ast *expr, Ast *call) { } -Ast *ast_index_expr(AstFile *f, Ast *expr, Ast *index, Token open, Token close) { +gb_internal Ast *ast_index_expr(AstFile *f, Ast *expr, Ast *index, Token open, Token close) { Ast *result = alloc_ast_node(f, Ast_IndexExpr); result->IndexExpr.expr = expr; result->IndexExpr.index = index; @@ -584,7 +605,7 @@ Ast *ast_index_expr(AstFile *f, Ast *expr, Ast *index, Token open, Token close) } -Ast *ast_slice_expr(AstFile *f, Ast *expr, Token open, Token close, Token interval, Ast *low, Ast *high) { +gb_internal Ast *ast_slice_expr(AstFile *f, Ast *expr, Token open, Token close, Token interval, Ast *low, Ast *high) { Ast *result = alloc_ast_node(f, Ast_SliceExpr); result->SliceExpr.expr = expr; result->SliceExpr.open = open; @@ -595,7 +616,7 @@ Ast *ast_slice_expr(AstFile *f, Ast *expr, Token open, Token close, Token interv return result; } -Ast *ast_deref_expr(AstFile *f, Ast *expr, Token op) { +gb_internal Ast *ast_deref_expr(AstFile *f, Ast *expr, Token op) { Ast *result = alloc_ast_node(f, Ast_DerefExpr); result->DerefExpr.expr = expr; result->DerefExpr.op = op; @@ -603,7 +624,7 @@ Ast *ast_deref_expr(AstFile *f, Ast *expr, Token op) { } -Ast *ast_matrix_index_expr(AstFile *f, Ast *expr, Token open, Token close, Token interval, Ast *row, Ast *column) { +gb_internal Ast *ast_matrix_index_expr(AstFile *f, Ast *expr, Token open, Token close, Token interval, Ast *row, Ast *column) { Ast *result = alloc_ast_node(f, Ast_MatrixIndexExpr); result->MatrixIndexExpr.expr = expr; result->MatrixIndexExpr.row_index = row; @@ -614,24 +635,24 @@ Ast *ast_matrix_index_expr(AstFile *f, Ast *expr, Token open, Token close, Token } -Ast *ast_ident(AstFile *f, Token token) { +gb_internal Ast *ast_ident(AstFile *f, Token token) { Ast *result = alloc_ast_node(f, Ast_Ident); result->Ident.token = token; return result; } -Ast *ast_implicit(AstFile *f, Token token) { +gb_internal Ast *ast_implicit(AstFile *f, Token token) { Ast *result = alloc_ast_node(f, Ast_Implicit); result->Implicit = token; return result; } -Ast *ast_undef(AstFile *f, Token token) { - Ast *result = alloc_ast_node(f, Ast_Undef); - result->Undef = token; +gb_internal Ast *ast_uninit(AstFile *f, Token token) { + Ast *result = alloc_ast_node(f, Ast_Uninit); + result->Uninit = token; return result; } -ExactValue exact_value_from_token(AstFile *f, Token const &token) { +gb_internal ExactValue exact_value_from_token(AstFile *f, Token const &token) { String s = token.string; switch (token.kind) { case Token_Rune: @@ -645,10 +666,14 @@ ExactValue exact_value_from_token(AstFile *f, Token const &token) { } break; } - return exact_value_from_basic_literal(token.kind, s); + ExactValue value = exact_value_from_basic_literal(token.kind, s); + if (value.kind == ExactValue_Invalid) { + syntax_error(token, "Invalid token literal"); + } + return value; } -String string_value_from_token(AstFile *f, Token const &token) { +gb_internal String string_value_from_token(AstFile *f, Token const &token) { ExactValue value = exact_value_from_token(f, token); String str = {}; if (value.kind == ExactValue_String) { @@ -658,7 +683,7 @@ String string_value_from_token(AstFile *f, Token const &token) { } -Ast *ast_basic_lit(AstFile *f, Token basic_lit) { +gb_internal Ast *ast_basic_lit(AstFile *f, Token basic_lit) { Ast *result = alloc_ast_node(f, Ast_BasicLit); result->BasicLit.token = basic_lit; result->tav.mode = Addressing_Constant; @@ -666,14 +691,14 @@ Ast *ast_basic_lit(AstFile *f, Token basic_lit) { return result; } -Ast *ast_basic_directive(AstFile *f, Token token, Token name) { +gb_internal Ast *ast_basic_directive(AstFile *f, Token token, Token name) { Ast *result = alloc_ast_node(f, Ast_BasicDirective); result->BasicDirective.token = token; result->BasicDirective.name = name; return result; } -Ast *ast_ellipsis(AstFile *f, Token token, Ast *expr) { +gb_internal Ast *ast_ellipsis(AstFile *f, Token token, Ast *expr) { Ast *result = alloc_ast_node(f, Ast_Ellipsis); result->Ellipsis.token = token; result->Ellipsis.expr = expr; @@ -681,7 +706,7 @@ Ast *ast_ellipsis(AstFile *f, Token token, Ast *expr) { } -Ast *ast_proc_group(AstFile *f, Token token, Token open, Token close, Array const &args) { +gb_internal Ast *ast_proc_group(AstFile *f, Token token, Token open, Token close, Array const &args) { Ast *result = alloc_ast_node(f, Ast_ProcGroup); result->ProcGroup.token = token; result->ProcGroup.open = open; @@ -690,7 +715,7 @@ Ast *ast_proc_group(AstFile *f, Token token, Token open, Token close, Array const &where_clauses) { +gb_internal Ast *ast_proc_lit(AstFile *f, Ast *type, Ast *body, u64 tags, Token where_token, Array const &where_clauses) { Ast *result = alloc_ast_node(f, Ast_ProcLit); result->ProcLit.type = type; result->ProcLit.body = body; @@ -700,7 +725,7 @@ Ast *ast_proc_lit(AstFile *f, Ast *type, Ast *body, u64 tags, Token where_token, return result; } -Ast *ast_field_value(AstFile *f, Ast *field, Ast *value, Token eq) { +gb_internal Ast *ast_field_value(AstFile *f, Ast *field, Ast *value, Token eq) { Ast *result = alloc_ast_node(f, Ast_FieldValue); result->FieldValue.field = field; result->FieldValue.value = value; @@ -709,7 +734,7 @@ Ast *ast_field_value(AstFile *f, Ast *field, Ast *value, Token eq) { } -Ast *ast_enum_field_value(AstFile *f, Ast *name, Ast *value, CommentGroup *docs, CommentGroup *comment) { +gb_internal Ast *ast_enum_field_value(AstFile *f, Ast *name, Ast *value, CommentGroup *docs, CommentGroup *comment) { Ast *result = alloc_ast_node(f, Ast_EnumFieldValue); result->EnumFieldValue.name = name; result->EnumFieldValue.value = value; @@ -718,7 +743,7 @@ Ast *ast_enum_field_value(AstFile *f, Ast *name, Ast *value, CommentGroup *docs, return result; } -Ast *ast_compound_lit(AstFile *f, Ast *type, Array const &elems, Token open, Token close) { +gb_internal Ast *ast_compound_lit(AstFile *f, Ast *type, Array const &elems, Token open, Token close) { Ast *result = alloc_ast_node(f, Ast_CompoundLit); result->CompoundLit.type = type; result->CompoundLit.elems = slice_from_array(elems); @@ -728,14 +753,14 @@ Ast *ast_compound_lit(AstFile *f, Ast *type, Array const &elems, Token op } -Ast *ast_ternary_if_expr(AstFile *f, Ast *x, Ast *cond, Ast *y) { +gb_internal Ast *ast_ternary_if_expr(AstFile *f, Ast *x, Ast *cond, Ast *y) { Ast *result = alloc_ast_node(f, Ast_TernaryIfExpr); result->TernaryIfExpr.x = x; result->TernaryIfExpr.cond = cond; result->TernaryIfExpr.y = y; return result; } -Ast *ast_ternary_when_expr(AstFile *f, Ast *x, Ast *cond, Ast *y) { +gb_internal Ast *ast_ternary_when_expr(AstFile *f, Ast *x, Ast *cond, Ast *y) { Ast *result = alloc_ast_node(f, Ast_TernaryWhenExpr); result->TernaryWhenExpr.x = x; result->TernaryWhenExpr.cond = cond; @@ -743,7 +768,7 @@ Ast *ast_ternary_when_expr(AstFile *f, Ast *x, Ast *cond, Ast *y) { return result; } -Ast *ast_or_else_expr(AstFile *f, Ast *x, Token const &token, Ast *y) { +gb_internal Ast *ast_or_else_expr(AstFile *f, Ast *x, Token const &token, Ast *y) { Ast *result = alloc_ast_node(f, Ast_OrElseExpr); result->OrElseExpr.x = x; result->OrElseExpr.token = token; @@ -751,28 +776,28 @@ Ast *ast_or_else_expr(AstFile *f, Ast *x, Token const &token, Ast *y) { return result; } -Ast *ast_or_return_expr(AstFile *f, Ast *expr, Token const &token) { +gb_internal Ast *ast_or_return_expr(AstFile *f, Ast *expr, Token const &token) { Ast *result = alloc_ast_node(f, Ast_OrReturnExpr); result->OrReturnExpr.expr = expr; result->OrReturnExpr.token = token; return result; } -Ast *ast_type_assertion(AstFile *f, Ast *expr, Token dot, Ast *type) { +gb_internal Ast *ast_type_assertion(AstFile *f, Ast *expr, Token dot, Ast *type) { Ast *result = alloc_ast_node(f, Ast_TypeAssertion); result->TypeAssertion.expr = expr; result->TypeAssertion.dot = dot; result->TypeAssertion.type = type; return result; } -Ast *ast_type_cast(AstFile *f, Token token, Ast *type, Ast *expr) { +gb_internal Ast *ast_type_cast(AstFile *f, Token token, Ast *type, Ast *expr) { Ast *result = alloc_ast_node(f, Ast_TypeCast); result->TypeCast.token = token; result->TypeCast.type = type; result->TypeCast.expr = expr; return result; } -Ast *ast_auto_cast(AstFile *f, Token token, Ast *expr) { +gb_internal Ast *ast_auto_cast(AstFile *f, Token token, Ast *expr) { Ast *result = alloc_ast_node(f, Ast_AutoCast); result->AutoCast.token = token; result->AutoCast.expr = expr; @@ -780,7 +805,7 @@ Ast *ast_auto_cast(AstFile *f, Token token, Ast *expr) { } -Ast *ast_inline_asm_expr(AstFile *f, Token token, Token open, Token close, +gb_internal Ast *ast_inline_asm_expr(AstFile *f, Token token, Token open, Token close, Array const ¶m_types, Ast *return_type, Ast *asm_string, @@ -806,26 +831,26 @@ Ast *ast_inline_asm_expr(AstFile *f, Token token, Token open, Token close, -Ast *ast_bad_stmt(AstFile *f, Token begin, Token end) { +gb_internal Ast *ast_bad_stmt(AstFile *f, Token begin, Token end) { Ast *result = alloc_ast_node(f, Ast_BadStmt); result->BadStmt.begin = begin; result->BadStmt.end = end; return result; } -Ast *ast_empty_stmt(AstFile *f, Token token) { +gb_internal Ast *ast_empty_stmt(AstFile *f, Token token) { Ast *result = alloc_ast_node(f, Ast_EmptyStmt); result->EmptyStmt.token = token; return result; } -Ast *ast_expr_stmt(AstFile *f, Ast *expr) { +gb_internal Ast *ast_expr_stmt(AstFile *f, Ast *expr) { Ast *result = alloc_ast_node(f, Ast_ExprStmt); result->ExprStmt.expr = expr; return result; } -Ast *ast_assign_stmt(AstFile *f, Token op, Array const &lhs, Array const &rhs) { +gb_internal Ast *ast_assign_stmt(AstFile *f, Token op, Array const &lhs, Array const &rhs) { Ast *result = alloc_ast_node(f, Ast_AssignStmt); result->AssignStmt.op = op; result->AssignStmt.lhs = slice_from_array(lhs); @@ -834,7 +859,7 @@ Ast *ast_assign_stmt(AstFile *f, Token op, Array const &lhs, Array } -Ast *ast_block_stmt(AstFile *f, Array const &stmts, Token open, Token close) { +gb_internal Ast *ast_block_stmt(AstFile *f, Array const &stmts, Token open, Token close) { Ast *result = alloc_ast_node(f, Ast_BlockStmt); result->BlockStmt.stmts = slice_from_array(stmts); result->BlockStmt.open = open; @@ -842,7 +867,7 @@ Ast *ast_block_stmt(AstFile *f, Array const &stmts, Token open, Token clo return result; } -Ast *ast_if_stmt(AstFile *f, Token token, Ast *init, Ast *cond, Ast *body, Ast *else_stmt) { +gb_internal Ast *ast_if_stmt(AstFile *f, Token token, Ast *init, Ast *cond, Ast *body, Ast *else_stmt) { Ast *result = alloc_ast_node(f, Ast_IfStmt); result->IfStmt.token = token; result->IfStmt.init = init; @@ -852,7 +877,7 @@ Ast *ast_if_stmt(AstFile *f, Token token, Ast *init, Ast *cond, Ast *body, Ast * return result; } -Ast *ast_when_stmt(AstFile *f, Token token, Ast *cond, Ast *body, Ast *else_stmt) { +gb_internal Ast *ast_when_stmt(AstFile *f, Token token, Ast *cond, Ast *body, Ast *else_stmt) { Ast *result = alloc_ast_node(f, Ast_WhenStmt); result->WhenStmt.token = token; result->WhenStmt.cond = cond; @@ -862,7 +887,7 @@ Ast *ast_when_stmt(AstFile *f, Token token, Ast *cond, Ast *body, Ast *else_stmt } -Ast *ast_return_stmt(AstFile *f, Token token, Array const &results) { +gb_internal Ast *ast_return_stmt(AstFile *f, Token token, Array const &results) { Ast *result = alloc_ast_node(f, Ast_ReturnStmt); result->ReturnStmt.token = token; result->ReturnStmt.results = slice_from_array(results); @@ -870,7 +895,7 @@ Ast *ast_return_stmt(AstFile *f, Token token, Array const &results) { } -Ast *ast_for_stmt(AstFile *f, Token token, Ast *init, Ast *cond, Ast *post, Ast *body) { +gb_internal Ast *ast_for_stmt(AstFile *f, Token token, Ast *init, Ast *cond, Ast *post, Ast *body) { Ast *result = alloc_ast_node(f, Ast_ForStmt); result->ForStmt.token = token; result->ForStmt.init = init; @@ -880,7 +905,7 @@ Ast *ast_for_stmt(AstFile *f, Token token, Ast *init, Ast *cond, Ast *post, Ast return result; } -Ast *ast_range_stmt(AstFile *f, Token token, Slice vals, Token in_token, Ast *expr, Ast *body) { +gb_internal Ast *ast_range_stmt(AstFile *f, Token token, Slice vals, Token in_token, Ast *expr, Ast *body) { Ast *result = alloc_ast_node(f, Ast_RangeStmt); result->RangeStmt.token = token; result->RangeStmt.vals = vals; @@ -890,7 +915,7 @@ Ast *ast_range_stmt(AstFile *f, Token token, Slice vals, Token in_token, return result; } -Ast *ast_unroll_range_stmt(AstFile *f, Token unroll_token, Token for_token, Ast *val0, Ast *val1, Token in_token, Ast *expr, Ast *body) { +gb_internal Ast *ast_unroll_range_stmt(AstFile *f, Token unroll_token, Token for_token, Ast *val0, Ast *val1, Token in_token, Ast *expr, Ast *body) { Ast *result = alloc_ast_node(f, Ast_UnrollRangeStmt); result->UnrollRangeStmt.unroll_token = unroll_token; result->UnrollRangeStmt.for_token = for_token; @@ -902,7 +927,7 @@ Ast *ast_unroll_range_stmt(AstFile *f, Token unroll_token, Token for_token, Ast return result; } -Ast *ast_switch_stmt(AstFile *f, Token token, Ast *init, Ast *tag, Ast *body) { +gb_internal Ast *ast_switch_stmt(AstFile *f, Token token, Ast *init, Ast *tag, Ast *body) { Ast *result = alloc_ast_node(f, Ast_SwitchStmt); result->SwitchStmt.token = token; result->SwitchStmt.init = init; @@ -913,7 +938,7 @@ Ast *ast_switch_stmt(AstFile *f, Token token, Ast *init, Ast *tag, Ast *body) { } -Ast *ast_type_switch_stmt(AstFile *f, Token token, Ast *tag, Ast *body) { +gb_internal Ast *ast_type_switch_stmt(AstFile *f, Token token, Ast *tag, Ast *body) { Ast *result = alloc_ast_node(f, Ast_TypeSwitchStmt); result->TypeSwitchStmt.token = token; result->TypeSwitchStmt.tag = tag; @@ -922,7 +947,7 @@ Ast *ast_type_switch_stmt(AstFile *f, Token token, Ast *tag, Ast *body) { return result; } -Ast *ast_case_clause(AstFile *f, Token token, Array const &list, Array const &stmts) { +gb_internal Ast *ast_case_clause(AstFile *f, Token token, Array const &list, Array const &stmts) { Ast *result = alloc_ast_node(f, Ast_CaseClause); result->CaseClause.token = token; result->CaseClause.list = slice_from_array(list); @@ -931,21 +956,21 @@ Ast *ast_case_clause(AstFile *f, Token token, Array const &list, ArrayDeferStmt.token = token; result->DeferStmt.stmt = stmt; return result; } -Ast *ast_branch_stmt(AstFile *f, Token token, Ast *label) { +gb_internal Ast *ast_branch_stmt(AstFile *f, Token token, Ast *label) { Ast *result = alloc_ast_node(f, Ast_BranchStmt); result->BranchStmt.token = token; result->BranchStmt.label = label; return result; } -Ast *ast_using_stmt(AstFile *f, Token token, Array const &list) { +gb_internal Ast *ast_using_stmt(AstFile *f, Token token, Array const &list) { Ast *result = alloc_ast_node(f, Ast_UsingStmt); result->UsingStmt.token = token; result->UsingStmt.list = slice_from_array(list); @@ -954,14 +979,14 @@ Ast *ast_using_stmt(AstFile *f, Token token, Array const &list) { -Ast *ast_bad_decl(AstFile *f, Token begin, Token end) { +gb_internal Ast *ast_bad_decl(AstFile *f, Token begin, Token end) { Ast *result = alloc_ast_node(f, Ast_BadDecl); result->BadDecl.begin = begin; result->BadDecl.end = end; return result; } -Ast *ast_field(AstFile *f, Array const &names, Ast *type, Ast *default_value, u32 flags, Token tag, +gb_internal Ast *ast_field(AstFile *f, Array const &names, Ast *type, Ast *default_value, u32 flags, Token tag, CommentGroup *docs, CommentGroup *comment) { Ast *result = alloc_ast_node(f, Ast_Field); result->Field.names = slice_from_array(names); @@ -974,28 +999,28 @@ Ast *ast_field(AstFile *f, Array const &names, Ast *type, Ast *default_va return result; } -Ast *ast_field_list(AstFile *f, Token token, Array const &list) { +gb_internal Ast *ast_field_list(AstFile *f, Token token, Array const &list) { Ast *result = alloc_ast_node(f, Ast_FieldList); result->FieldList.token = token; result->FieldList.list = slice_from_array(list); return result; } -Ast *ast_typeid_type(AstFile *f, Token token, Ast *specialization) { +gb_internal Ast *ast_typeid_type(AstFile *f, Token token, Ast *specialization) { Ast *result = alloc_ast_node(f, Ast_TypeidType); result->TypeidType.token = token; result->TypeidType.specialization = specialization; return result; } -Ast *ast_helper_type(AstFile *f, Token token, Ast *type) { +gb_internal Ast *ast_helper_type(AstFile *f, Token token, Ast *type) { Ast *result = alloc_ast_node(f, Ast_HelperType); result->HelperType.token = token; result->HelperType.type = type; return result; } -Ast *ast_distinct_type(AstFile *f, Token token, Ast *type) { +gb_internal Ast *ast_distinct_type(AstFile *f, Token token, Ast *type) { Ast *result = alloc_ast_node(f, Ast_DistinctType); result->DistinctType.token = token; result->DistinctType.type = type; @@ -1003,7 +1028,7 @@ Ast *ast_distinct_type(AstFile *f, Token token, Ast *type) { } -Ast *ast_poly_type(AstFile *f, Token token, Ast *type, Ast *specialization) { +gb_internal Ast *ast_poly_type(AstFile *f, Token token, Ast *type, Ast *specialization) { Ast *result = alloc_ast_node(f, Ast_PolyType); result->PolyType.token = token; result->PolyType.type = type; @@ -1012,7 +1037,7 @@ Ast *ast_poly_type(AstFile *f, Token token, Ast *type, Ast *specialization) { } -Ast *ast_proc_type(AstFile *f, Token token, Ast *params, Ast *results, u64 tags, ProcCallingConvention calling_convention, bool generic, bool diverging) { +gb_internal Ast *ast_proc_type(AstFile *f, Token token, Ast *params, Ast *results, u64 tags, ProcCallingConvention calling_convention, bool generic, bool diverging) { Ast *result = alloc_ast_node(f, Ast_ProcType); result->ProcType.token = token; result->ProcType.params = params; @@ -1024,25 +1049,25 @@ Ast *ast_proc_type(AstFile *f, Token token, Ast *params, Ast *results, u64 tags, return result; } -Ast *ast_relative_type(AstFile *f, Ast *tag, Ast *type) { +gb_internal Ast *ast_relative_type(AstFile *f, Ast *tag, Ast *type) { Ast *result = alloc_ast_node(f, Ast_RelativeType); result->RelativeType.tag = tag; result->RelativeType.type = type; return result; } -Ast *ast_pointer_type(AstFile *f, Token token, Ast *type) { +gb_internal Ast *ast_pointer_type(AstFile *f, Token token, Ast *type) { Ast *result = alloc_ast_node(f, Ast_PointerType); result->PointerType.token = token; result->PointerType.type = type; return result; } -Ast *ast_multi_pointer_type(AstFile *f, Token token, Ast *type) { +gb_internal Ast *ast_multi_pointer_type(AstFile *f, Token token, Ast *type) { Ast *result = alloc_ast_node(f, Ast_MultiPointerType); result->MultiPointerType.token = token; result->MultiPointerType.type = type; return result; } -Ast *ast_array_type(AstFile *f, Token token, Ast *count, Ast *elem) { +gb_internal Ast *ast_array_type(AstFile *f, Token token, Ast *count, Ast *elem) { Ast *result = alloc_ast_node(f, Ast_ArrayType); result->ArrayType.token = token; result->ArrayType.count = count; @@ -1050,15 +1075,15 @@ Ast *ast_array_type(AstFile *f, Token token, Ast *count, Ast *elem) { return result; } -Ast *ast_dynamic_array_type(AstFile *f, Token token, Ast *elem) { +gb_internal Ast *ast_dynamic_array_type(AstFile *f, Token token, Ast *elem) { Ast *result = alloc_ast_node(f, Ast_DynamicArrayType); result->DynamicArrayType.token = token; result->DynamicArrayType.elem = elem; return result; } -Ast *ast_struct_type(AstFile *f, Token token, Slice fields, isize field_count, - Ast *polymorphic_params, bool is_packed, bool is_raw_union, +gb_internal Ast *ast_struct_type(AstFile *f, Token token, Slice fields, isize field_count, + Ast *polymorphic_params, bool is_packed, bool is_raw_union, bool is_no_copy, Ast *align, Token where_token, Array const &where_clauses) { Ast *result = alloc_ast_node(f, Ast_StructType); @@ -1068,6 +1093,7 @@ Ast *ast_struct_type(AstFile *f, Token token, Slice fields, isize field_c result->StructType.polymorphic_params = polymorphic_params; result->StructType.is_packed = is_packed; result->StructType.is_raw_union = is_raw_union; + result->StructType.is_no_copy = is_no_copy; result->StructType.align = align; result->StructType.where_token = where_token; result->StructType.where_clauses = slice_from_array(where_clauses); @@ -1075,7 +1101,7 @@ Ast *ast_struct_type(AstFile *f, Token token, Slice fields, isize field_c } -Ast *ast_union_type(AstFile *f, Token token, Array const &variants, Ast *polymorphic_params, Ast *align, UnionTypeKind kind, +gb_internal Ast *ast_union_type(AstFile *f, Token token, Array const &variants, Ast *polymorphic_params, Ast *align, UnionTypeKind kind, Token where_token, Array const &where_clauses) { Ast *result = alloc_ast_node(f, Ast_UnionType); result->UnionType.token = token; @@ -1089,7 +1115,7 @@ Ast *ast_union_type(AstFile *f, Token token, Array const &variants, Ast * } -Ast *ast_enum_type(AstFile *f, Token token, Ast *base_type, Array const &fields) { +gb_internal Ast *ast_enum_type(AstFile *f, Token token, Ast *base_type, Array const &fields) { Ast *result = alloc_ast_node(f, Ast_EnumType); result->EnumType.token = token; result->EnumType.base_type = base_type; @@ -1097,7 +1123,7 @@ Ast *ast_enum_type(AstFile *f, Token token, Ast *base_type, Array const & return result; } -Ast *ast_bit_set_type(AstFile *f, Token token, Ast *elem, Ast *underlying) { +gb_internal Ast *ast_bit_set_type(AstFile *f, Token token, Ast *elem, Ast *underlying) { Ast *result = alloc_ast_node(f, Ast_BitSetType); result->BitSetType.token = token; result->BitSetType.elem = elem; @@ -1105,7 +1131,7 @@ Ast *ast_bit_set_type(AstFile *f, Token token, Ast *elem, Ast *underlying) { return result; } -Ast *ast_map_type(AstFile *f, Token token, Ast *key, Ast *value) { +gb_internal Ast *ast_map_type(AstFile *f, Token token, Ast *key, Ast *value) { Ast *result = alloc_ast_node(f, Ast_MapType); result->MapType.token = token; result->MapType.key = key; @@ -1113,7 +1139,7 @@ Ast *ast_map_type(AstFile *f, Token token, Ast *key, Ast *value) { return result; } -Ast *ast_matrix_type(AstFile *f, Token token, Ast *row_count, Ast *column_count, Ast *elem) { +gb_internal Ast *ast_matrix_type(AstFile *f, Token token, Ast *row_count, Ast *column_count, Ast *elem) { Ast *result = alloc_ast_node(f, Ast_MatrixType); result->MatrixType.token = token; result->MatrixType.row_count = row_count; @@ -1122,7 +1148,7 @@ Ast *ast_matrix_type(AstFile *f, Token token, Ast *row_count, Ast *column_count, return result; } -Ast *ast_foreign_block_decl(AstFile *f, Token token, Ast *foreign_library, Ast *body, +gb_internal Ast *ast_foreign_block_decl(AstFile *f, Token token, Ast *foreign_library, Ast *body, CommentGroup *docs) { Ast *result = alloc_ast_node(f, Ast_ForeignBlockDecl); result->ForeignBlockDecl.token = token; @@ -1134,14 +1160,14 @@ Ast *ast_foreign_block_decl(AstFile *f, Token token, Ast *foreign_library, Ast * return result; } -Ast *ast_label_decl(AstFile *f, Token token, Ast *name) { +gb_internal Ast *ast_label_decl(AstFile *f, Token token, Ast *name) { Ast *result = alloc_ast_node(f, Ast_Label); result->Label.token = token; result->Label.name = name; return result; } -Ast *ast_value_decl(AstFile *f, Array const &names, Ast *type, Array const &values, bool is_mutable, +gb_internal Ast *ast_value_decl(AstFile *f, Array const &names, Ast *type, Array const &values, bool is_mutable, CommentGroup *docs, CommentGroup *comment) { Ast *result = alloc_ast_node(f, Ast_ValueDecl); result->ValueDecl.names = slice_from_array(names); @@ -1155,7 +1181,7 @@ Ast *ast_value_decl(AstFile *f, Array const &names, Ast *type, ArrayPackageDecl.token = token; result->PackageDecl.name = name; @@ -1164,7 +1190,7 @@ Ast *ast_package_decl(AstFile *f, Token token, Token name, CommentGroup *docs, C return result; } -Ast *ast_import_decl(AstFile *f, Token token, Token relpath, Token import_name, +gb_internal Ast *ast_import_decl(AstFile *f, Token token, Token relpath, Token import_name, CommentGroup *docs, CommentGroup *comment) { Ast *result = alloc_ast_node(f, Ast_ImportDecl); result->ImportDecl.token = token; @@ -1175,7 +1201,7 @@ Ast *ast_import_decl(AstFile *f, Token token, Token relpath, Token import_name, return result; } -Ast *ast_foreign_import_decl(AstFile *f, Token token, Array filepaths, Token library_name, +gb_internal Ast *ast_foreign_import_decl(AstFile *f, Token token, Array filepaths, Token library_name, CommentGroup *docs, CommentGroup *comment) { Ast *result = alloc_ast_node(f, Ast_ForeignImportDecl); result->ForeignImportDecl.token = token; @@ -1189,7 +1215,7 @@ Ast *ast_foreign_import_decl(AstFile *f, Token token, Array filepaths, To } -Ast *ast_attribute(AstFile *f, Token token, Token open, Token close, Array const &elems) { +gb_internal Ast *ast_attribute(AstFile *f, Token token, Token open, Token close, Array const &elems) { Ast *result = alloc_ast_node(f, Ast_Attribute); result->Attribute.token = token; result->Attribute.open = open; @@ -1199,7 +1225,7 @@ Ast *ast_attribute(AstFile *f, Token token, Token open, Token close, Arraycurr_token_index+1 < f->tokens.count) { f->curr_token = f->tokens[++f->curr_token_index]; return true; @@ -1209,7 +1235,7 @@ bool next_token0(AstFile *f) { } -Token consume_comment(AstFile *f, isize *end_line_) { +gb_internal Token consume_comment(AstFile *f, isize *end_line_) { Token tok = f->curr_token; GB_ASSERT(tok.kind == Token_Comment); isize end_line = tok.pos.line; @@ -1231,7 +1257,7 @@ Token consume_comment(AstFile *f, isize *end_line_) { } -CommentGroup *consume_comment_group(AstFile *f, isize n, isize *end_line_) { +gb_internal CommentGroup *consume_comment_group(AstFile *f, isize n, isize *end_line_) { Array list = {}; list.allocator = heap_allocator(); isize end_line = f->curr_token.pos.line; @@ -1257,7 +1283,7 @@ CommentGroup *consume_comment_group(AstFile *f, isize n, isize *end_line_) { return comments; } -void consume_comment_groups(AstFile *f, Token prev) { +gb_internal void consume_comment_groups(AstFile *f, Token prev) { if (f->curr_token.kind == Token_Comment) { CommentGroup *comment = nullptr; isize end_line = 0; @@ -1281,11 +1307,11 @@ void consume_comment_groups(AstFile *f, Token prev) { } } -gb_inline bool ignore_newlines(AstFile *f) { +gb_internal gb_inline bool ignore_newlines(AstFile *f) { return f->expr_level > 0; } -Token advance_token(AstFile *f) { +gb_internal Token advance_token(AstFile *f) { f->lead_comment = nullptr; f->line_comment = nullptr; @@ -1308,18 +1334,8 @@ Token advance_token(AstFile *f) { return prev; } -bool peek_token_kind(AstFile *f, TokenKind kind) { - for (isize i = f->curr_token_index+1; i < f->tokens.count; i++) { - Token tok = f->tokens[i]; - if (kind != Token_Comment && tok.kind == Token_Comment) { - continue; - } - return tok.kind == kind; - } - return false; -} -Token peek_token(AstFile *f) { +gb_internal Token peek_token(AstFile *f) { for (isize i = f->curr_token_index+1; i < f->tokens.count; i++) { Token tok = f->tokens[i]; if (tok.kind == Token_Comment) { @@ -1330,7 +1346,7 @@ Token peek_token(AstFile *f) { return {}; } -bool skip_possible_newline(AstFile *f) { +gb_internal bool skip_possible_newline(AstFile *f) { if (token_is_newline(f->curr_token)) { advance_token(f); return true; @@ -1338,7 +1354,7 @@ bool skip_possible_newline(AstFile *f) { return false; } -bool skip_possible_newline_for_literal(AstFile *f) { +gb_internal bool skip_possible_newline_for_literal(AstFile *f) { Token curr = f->curr_token; if (token_is_newline(curr)) { Token next = peek_token(f); @@ -1356,7 +1372,7 @@ bool skip_possible_newline_for_literal(AstFile *f) { return false; } -String token_to_string(Token const &tok) { +gb_internal String token_to_string(Token const &tok) { String p = token_strings[tok.kind]; if (token_is_newline(tok)) { p = str_lit("newline"); @@ -1365,7 +1381,7 @@ String token_to_string(Token const &tok) { } -Token expect_token(AstFile *f, TokenKind kind) { +gb_internal Token expect_token(AstFile *f, TokenKind kind) { Token prev = f->curr_token; if (prev.kind != kind) { String c = token_strings[kind]; @@ -1380,7 +1396,7 @@ Token expect_token(AstFile *f, TokenKind kind) { return prev; } -Token expect_token_after(AstFile *f, TokenKind kind, char const *msg) { +gb_internal Token expect_token_after(AstFile *f, TokenKind kind, char const *msg) { Token prev = f->curr_token; if (prev.kind != kind) { String p = token_to_string(prev); @@ -1400,7 +1416,7 @@ Token expect_token_after(AstFile *f, TokenKind kind, char const *msg) { } -bool is_token_range(TokenKind kind) { +gb_internal bool is_token_range(TokenKind kind) { switch (kind) { case Token_Ellipsis: case Token_RangeFull: @@ -1409,12 +1425,12 @@ bool is_token_range(TokenKind kind) { } return false; } -bool is_token_range(Token tok) { +gb_internal bool is_token_range(Token tok) { return is_token_range(tok.kind); } -Token expect_operator(AstFile *f) { +gb_internal Token expect_operator(AstFile *f) { Token prev = f->curr_token; if ((prev.kind == Token_in || prev.kind == Token_not_in) && (f->expr_level >= 0 || f->allow_in_expr)) { // okay @@ -1432,7 +1448,7 @@ Token expect_operator(AstFile *f) { LIT(p)); } if (f->curr_token.kind == Token_Ellipsis) { - syntax_warning(f->curr_token, "'..' for ranges has now be deprecated, prefer '..='"); + syntax_warning(f->curr_token, "'..' for ranges has now been deprecated, prefer '..='"); f->tokens[f->curr_token_index].flags |= TokenFlag_Replace; } @@ -1440,18 +1456,7 @@ Token expect_operator(AstFile *f) { return prev; } -Token expect_keyword(AstFile *f) { - Token prev = f->curr_token; - if (!gb_is_between(prev.kind, Token__KeywordBegin+1, Token__KeywordEnd-1)) { - String p = token_to_string(prev); - syntax_error(f->curr_token, "Expected a keyword, got '%.*s'", - LIT(p)); - } - advance_token(f); - return prev; -} - -bool allow_token(AstFile *f, TokenKind kind) { +gb_internal bool allow_token(AstFile *f, TokenKind kind) { Token prev = f->curr_token; if (prev.kind == kind) { advance_token(f); @@ -1460,13 +1465,13 @@ bool allow_token(AstFile *f, TokenKind kind) { return false; } -Token expect_closing_brace_of_field_list(AstFile *f) { +gb_internal Token expect_closing_brace_of_field_list(AstFile *f) { Token token = f->curr_token; if (allow_token(f, Token_CloseBrace)) { return token; } bool ok = true; - if (!f->allow_newline) { + if (f->allow_newline) { ok = !skip_possible_newline(f); } if (ok && allow_token(f, Token_Semicolon)) { @@ -1476,19 +1481,19 @@ Token expect_closing_brace_of_field_list(AstFile *f) { return expect_token(f, Token_CloseBrace); } -bool is_blank_ident(String str) { +gb_internal bool is_blank_ident(String str) { if (str.len == 1) { return str[0] == '_'; } return false; } -bool is_blank_ident(Token token) { +gb_internal bool is_blank_ident(Token token) { if (token.kind == Token_Ident) { return is_blank_ident(token.string); } return false; } -bool is_blank_ident(Ast *node) { +gb_internal bool is_blank_ident(Ast *node) { if (node->kind == Ast_Ident) { ast_node(i, Ident, node); return is_blank_ident(i->token.string); @@ -1499,7 +1504,7 @@ bool is_blank_ident(Ast *node) { // NOTE(bill): Go to next statement to prevent numerous error messages popping up -void fix_advance_to_next_stmt(AstFile *f) { +gb_internal void fix_advance_to_next_stmt(AstFile *f) { for (;;) { Token t = f->curr_token; switch (t.kind) { @@ -1543,7 +1548,7 @@ void fix_advance_to_next_stmt(AstFile *f) { } } -Token expect_closing(AstFile *f, TokenKind kind, String const &context) { +gb_internal Token expect_closing(AstFile *f, TokenKind kind, String const &context) { if (f->curr_token.kind != kind && f->curr_token.kind == Token_Semicolon && (f->curr_token.string == "\n" || f->curr_token.kind == Token_EOF)) { @@ -1557,7 +1562,7 @@ Token expect_closing(AstFile *f, TokenKind kind, String const &context) { return expect_token(f, kind); } -void assign_removal_flag_to_semicolon(AstFile *f) { +gb_internal void assign_removal_flag_to_semicolon(AstFile *f) { // NOTE(bill): this is used for rewriting files to strip unneeded semicolons Token *prev_token = &f->tokens[f->prev_token_index]; Token *curr_token = &f->tokens[f->curr_token_index]; @@ -1587,7 +1592,7 @@ void assign_removal_flag_to_semicolon(AstFile *f) { } } -void expect_semicolon(AstFile *f) { +gb_internal void expect_semicolon(AstFile *f) { Token prev_token = {}; if (allow_token(f, Token_Semicolon)) { @@ -1626,17 +1631,17 @@ void expect_semicolon(AstFile *f) { } -Ast * parse_expr(AstFile *f, bool lhs); -Ast * parse_proc_type(AstFile *f, Token proc_token); -Array parse_stmt_list(AstFile *f); -Ast * parse_stmt(AstFile *f); -Ast * parse_body(AstFile *f); -Ast * parse_do_body(AstFile *f, Token const &token, char const *msg); -Ast * parse_block_stmt(AstFile *f, b32 is_when); +gb_internal Ast * parse_expr(AstFile *f, bool lhs); +gb_internal Ast * parse_proc_type(AstFile *f, Token proc_token); +gb_internal Array parse_stmt_list(AstFile *f); +gb_internal Ast * parse_stmt(AstFile *f); +gb_internal Ast * parse_body(AstFile *f); +gb_internal Ast * parse_do_body(AstFile *f, Token const &token, char const *msg); +gb_internal Ast * parse_block_stmt(AstFile *f, b32 is_when); -Ast *parse_ident(AstFile *f, bool allow_poly_names=false) { +gb_internal Ast *parse_ident(AstFile *f, bool allow_poly_names=false) { Token token = f->curr_token; if (token.kind == Token_Ident) { advance_token(f); @@ -1654,13 +1659,13 @@ Ast *parse_ident(AstFile *f, bool allow_poly_names=false) { return ast_ident(f, token); } -Ast *parse_tag_expr(AstFile *f, Ast *expression) { +gb_internal Ast *parse_tag_expr(AstFile *f, Ast *expression) { Token token = expect_token(f, Token_Hash); Token name = expect_token(f, Token_Ident); return ast_tag_expr(f, token, name, expression); } -Ast *unparen_expr(Ast *node) { +gb_internal Ast *unparen_expr(Ast *node) { for (;;) { if (node == nullptr) { return nullptr; @@ -1672,7 +1677,7 @@ Ast *unparen_expr(Ast *node) { } } -Ast *unselector_expr(Ast *node) { +gb_internal Ast *unselector_expr(Ast *node) { node = unparen_expr(node); if (node == nullptr) { return nullptr; @@ -1683,7 +1688,7 @@ Ast *unselector_expr(Ast *node) { return node; } -Ast *strip_or_return_expr(Ast *node) { +gb_internal Ast *strip_or_return_expr(Ast *node) { for (;;) { if (node == nullptr) { return node; @@ -1699,9 +1704,9 @@ Ast *strip_or_return_expr(Ast *node) { } -Ast *parse_value(AstFile *f); +gb_internal Ast *parse_value(AstFile *f); -Array parse_element_list(AstFile *f) { +gb_internal Array parse_element_list(AstFile *f) { auto elems = array_make(heap_allocator()); while (f->curr_token.kind != Token_CloseBrace && @@ -1722,7 +1727,7 @@ Array parse_element_list(AstFile *f) { return elems; } -CommentGroup *consume_line_comment(AstFile *f) { +gb_internal CommentGroup *consume_line_comment(AstFile *f) { CommentGroup *comment = f->line_comment; if (f->line_comment == f->lead_comment) { f->lead_comment = nullptr; @@ -1732,7 +1737,7 @@ CommentGroup *consume_line_comment(AstFile *f) { } -Array parse_enum_field_list(AstFile *f) { +gb_internal Array parse_enum_field_list(AstFile *f) { auto elems = array_make(heap_allocator()); while (f->curr_token.kind != Token_CloseBrace && @@ -1763,7 +1768,7 @@ Array parse_enum_field_list(AstFile *f) { return elems; } -Ast *parse_literal_value(AstFile *f, Ast *type) { +gb_internal Ast *parse_literal_value(AstFile *f, Ast *type) { Array elems = {}; Token open = expect_token(f, Token_OpenBrace); isize expr_level = f->expr_level; @@ -1777,7 +1782,7 @@ Ast *parse_literal_value(AstFile *f, Ast *type) { return ast_compound_lit(f, type, elems, open, close); } -Ast *parse_value(AstFile *f) { +gb_internal Ast *parse_value(AstFile *f) { if (f->curr_token.kind == Token_OpenBrace) { return parse_literal_value(f, nullptr); } @@ -1789,17 +1794,17 @@ Ast *parse_value(AstFile *f) { return value; } -Ast *parse_type_or_ident(AstFile *f); +gb_internal Ast *parse_type_or_ident(AstFile *f); -void check_proc_add_tag(AstFile *f, Ast *tag_expr, u64 *tags, ProcTag tag, String const &tag_name) { +gb_internal void check_proc_add_tag(AstFile *f, Ast *tag_expr, u64 *tags, ProcTag tag, String const &tag_name) { if (*tags & tag) { syntax_error(tag_expr, "Procedure tag already used: %.*s", LIT(tag_name)); } *tags |= tag; } -bool is_foreign_name_valid(String const &name) { +gb_internal bool is_foreign_name_valid(String const &name) { if (name.len == 0) { return false; } @@ -1847,7 +1852,7 @@ bool is_foreign_name_valid(String const &name) { return true; } -void parse_proc_tags(AstFile *f, u64 *tags) { +gb_internal void parse_proc_tags(AstFile *f, u64 *tags) { GB_ASSERT(tags != nullptr); while (f->curr_token.kind == Token_Hash) { @@ -1885,17 +1890,17 @@ void parse_proc_tags(AstFile *f, u64 *tags) { } -Array parse_lhs_expr_list (AstFile *f); -Array parse_rhs_expr_list (AstFile *f); -Ast * parse_simple_stmt (AstFile *f, u32 flags); -Ast * parse_type (AstFile *f); -Ast * parse_call_expr (AstFile *f, Ast *operand); -Ast * parse_struct_field_list(AstFile *f, isize *name_count_); -Ast *parse_field_list(AstFile *f, isize *name_count_, u32 allowed_flags, TokenKind follow, bool allow_default_parameters, bool allow_typeid_token); -Ast *parse_unary_expr(AstFile *f, bool lhs); +gb_internal Array parse_lhs_expr_list (AstFile *f); +gb_internal Array parse_rhs_expr_list (AstFile *f); +gb_internal Ast * parse_simple_stmt (AstFile *f, u32 flags); +gb_internal Ast * parse_type (AstFile *f); +gb_internal Ast * parse_call_expr (AstFile *f, Ast *operand); +gb_internal Ast * parse_struct_field_list(AstFile *f, isize *name_count_); +gb_internal Ast *parse_field_list(AstFile *f, isize *name_count_, u32 allowed_flags, TokenKind follow, bool allow_default_parameters, bool allow_typeid_token); +gb_internal Ast *parse_unary_expr(AstFile *f, bool lhs); -Ast *convert_stmt_to_expr(AstFile *f, Ast *statement, String const &kind) { +gb_internal Ast *convert_stmt_to_expr(AstFile *f, Ast *statement, String const &kind) { if (statement == nullptr) { return nullptr; } @@ -1912,7 +1917,7 @@ Ast *convert_stmt_to_expr(AstFile *f, Ast *statement, String const &kind) { return ast_bad_expr(f, f->curr_token, end); } -Ast *convert_stmt_to_body(AstFile *f, Ast *stmt) { +gb_internal Ast *convert_stmt_to_body(AstFile *f, Ast *stmt) { if (stmt->kind == Ast_BlockStmt) { syntax_error(stmt, "Expected a normal statement rather than a block statement"); return stmt; @@ -1929,7 +1934,7 @@ Ast *convert_stmt_to_body(AstFile *f, Ast *stmt) { } -void check_polymorphic_params_for_type(AstFile *f, Ast *polymorphic_params, Token token) { +gb_internal void check_polymorphic_params_for_type(AstFile *f, Ast *polymorphic_params, Token token) { if (polymorphic_params == nullptr) { return; } @@ -1937,13 +1942,11 @@ void check_polymorphic_params_for_type(AstFile *f, Ast *polymorphic_params, Toke return; } ast_node(fl, FieldList, polymorphic_params); - for_array(fi, fl->list) { - Ast *field = fl->list[fi]; + for (Ast *field : fl->list) { if (field->kind != Ast_Field) { continue; } - for_array(i, field->Field.names) { - Ast *name = field->Field.names[i]; + for (Ast *name : field->Field.names) { if (name->kind != field->Field.names[0]->kind) { syntax_error(name, "Mixture of polymorphic names using both $ and not for %.*s parameters", LIT(token.string)); return; @@ -1952,16 +1955,12 @@ void check_polymorphic_params_for_type(AstFile *f, Ast *polymorphic_params, Toke } } -bool ast_on_same_line(Token const &x, Ast *yp) { +gb_internal bool ast_on_same_line(Token const &x, Ast *yp) { Token y = ast_token(yp); return x.pos.line == y.pos.line; } -bool ast_on_same_line(Ast *x, Ast *y) { - return ast_on_same_line(ast_token(x), y); -} - -Ast *parse_force_inlining_operand(AstFile *f, Token token) { +gb_internal Ast *parse_force_inlining_operand(AstFile *f, Token token) { Ast *expr = parse_unary_expr(f, false); Ast *e = strip_or_return_expr(expr); if (e->kind != Ast_ProcLit && e->kind != Ast_CallExpr) { @@ -1997,7 +1996,7 @@ Ast *parse_force_inlining_operand(AstFile *f, Token token) { } -Ast *parse_check_directive_for_statement(Ast *s, Token const &tag_token, u16 state_flag) { +gb_internal Ast *parse_check_directive_for_statement(Ast *s, Token const &tag_token, u16 state_flag) { String name = tag_token.string; if (s == nullptr) { @@ -2076,7 +2075,7 @@ Ast *parse_check_directive_for_statement(Ast *s, Token const &tag_token, u16 sta return s; } -Array parse_union_variant_list(AstFile *f) { +gb_internal Array parse_union_variant_list(AstFile *f) { auto variants = array_make(heap_allocator()); while (f->curr_token.kind != Token_CloseBrace && f->curr_token.kind != Token_EOF) { @@ -2091,14 +2090,14 @@ Array parse_union_variant_list(AstFile *f) { return variants; } -Ast *parse_operand(AstFile *f, bool lhs) { +gb_internal Ast *parse_operand(AstFile *f, bool lhs) { Ast *operand = nullptr; // Operand switch (f->curr_token.kind) { case Token_Ident: return parse_ident(f); - case Token_Undef: - return ast_undef(f, expect_token(f, Token_Undef)); + case Token_Uninit: + return ast_uninit(f, expect_token(f, Token_Uninit)); case Token_context: return ast_implicit(f, expect_token(f, Token_context)); @@ -2297,7 +2296,7 @@ Ast *parse_operand(AstFile *f, bool lhs) { skip_possible_newline_for_literal(f); - if (allow_token(f, Token_Undef)) { + if (allow_token(f, Token_Uninit)) { if (where_token.kind != Token_Invalid) { syntax_error(where_token, "'where' clauses are not allowed on procedure literals without a defined body (replaced with ---)"); } @@ -2430,6 +2429,7 @@ Ast *parse_operand(AstFile *f, bool lhs) { Ast *polymorphic_params = nullptr; bool is_packed = false; bool is_raw_union = false; + bool no_copy = false; Ast *align = nullptr; if (allow_token(f, Token_OpenParen)) { @@ -2465,6 +2465,11 @@ Ast *parse_operand(AstFile *f, bool lhs) { syntax_error(tag, "Duplicate struct tag '#%.*s'", LIT(tag.string)); } is_raw_union = true; + } else if (tag.string == "no_copy") { + if (no_copy) { + syntax_error(tag, "Duplicate struct tag '#%.*s'", LIT(tag.string)); + } + no_copy = true; } else { syntax_error(tag, "Invalid struct tag '#%.*s'", LIT(tag.string)); } @@ -2503,7 +2508,7 @@ Ast *parse_operand(AstFile *f, bool lhs) { decls = fields->FieldList.list; } - return ast_struct_type(f, token, decls, name_count, polymorphic_params, is_packed, is_raw_union, align, where_token, where_clauses); + return ast_struct_type(f, token, decls, name_count, polymorphic_params, is_packed, is_raw_union, no_copy, align, where_token, where_clauses); } break; case Token_union: { @@ -2712,7 +2717,7 @@ Ast *parse_operand(AstFile *f, bool lhs) { return nullptr; } -bool is_literal_type(Ast *node) { +gb_internal bool is_literal_type(Ast *node) { node = unparen_expr(node); switch (node->kind) { case Ast_BadExpr: @@ -2735,7 +2740,7 @@ bool is_literal_type(Ast *node) { return false; } -Ast *parse_call_expr(AstFile *f, Ast *operand) { +gb_internal Ast *parse_call_expr(AstFile *f, Ast *operand) { auto args = array_make(heap_allocator()); Token open_paren, close_paren; Token ellipsis = {}; @@ -2747,9 +2752,9 @@ Ast *parse_call_expr(AstFile *f, Ast *operand) { open_paren = expect_token(f, Token_OpenParen); + bool seen_ellipsis = false; while (f->curr_token.kind != Token_CloseParen && - f->curr_token.kind != Token_EOF && - ellipsis.pos.line == 0) { + f->curr_token.kind != Token_EOF) { if (f->curr_token.kind == Token_Comma) { syntax_error(f->curr_token, "Expected an expression not ,"); } else if (f->curr_token.kind == Token_Eq) { @@ -2772,11 +2777,15 @@ Ast *parse_call_expr(AstFile *f, Ast *operand) { Ast *value = parse_value(f); arg = ast_field_value(f, arg, value, eq); - - + } else if (seen_ellipsis) { + syntax_error(arg, "Positional arguments are not allowed after '..'"); } array_add(&args, arg); + if (ellipsis.pos.line != 0) { + seen_ellipsis = true; + } + if (!allow_field_separator(f)) { break; } @@ -2796,7 +2805,13 @@ Ast *parse_call_expr(AstFile *f, Ast *operand) { return call; } -Ast *parse_atom_expr(AstFile *f, Ast *operand, bool lhs) { +gb_internal void parse_check_or_return(Ast *operand, char const *msg) { + if (operand && operand->kind == Ast_OrReturnExpr) { + syntax_error_with_verbose(operand, "'or_return' use within %s is not wrapped in parentheses (...)", msg); + } +} + +gb_internal Ast *parse_atom_expr(AstFile *f, Ast *operand, bool lhs) { if (operand == nullptr) { if (f->allow_type) return nullptr; Token begin = f->curr_token; @@ -2809,6 +2824,7 @@ Ast *parse_atom_expr(AstFile *f, Ast *operand, bool lhs) { while (loop) { switch (f->curr_token.kind) { case Token_OpenParen: + parse_check_or_return(operand, "call expression"); operand = parse_call_expr(f, operand); break; @@ -2816,12 +2832,11 @@ Ast *parse_atom_expr(AstFile *f, Ast *operand, bool lhs) { Token token = advance_token(f); switch (f->curr_token.kind) { case Token_Ident: + parse_check_or_return(operand, "selector expression"); operand = ast_selector_expr(f, token, operand, parse_ident(f)); break; - // case Token_Integer: - // operand = ast_selector_expr(f, token, operand, parse_expr(f, lhs)); - // break; case Token_OpenParen: { + parse_check_or_return(operand, "type assertion"); Token open = expect_token(f, Token_OpenParen); Ast *type = parse_type(f); Token close = expect_token(f, Token_CloseParen); @@ -2829,6 +2844,7 @@ Ast *parse_atom_expr(AstFile *f, Ast *operand, bool lhs) { } break; case Token_Question: { + parse_check_or_return(operand, ".? based type assertion"); Token question = expect_token(f, Token_Question); Ast *type = ast_unary_expr(f, question, nullptr); operand = ast_type_assertion(f, operand, token, type); @@ -2844,6 +2860,7 @@ Ast *parse_atom_expr(AstFile *f, Ast *operand, bool lhs) { } break; case Token_ArrowRight: { + parse_check_or_return(operand, "-> based call expression"); Token token = advance_token(f); operand = ast_selector_expr(f, token, operand, parse_ident(f)); @@ -2901,11 +2918,14 @@ Ast *parse_atom_expr(AstFile *f, Ast *operand, bool lhs) { if (indices[0] == nullptr || indices[1] == nullptr) { syntax_error(open, "Matrix index expressions require both row and column indices"); } + parse_check_or_return(operand, "matrix index expression"); operand = ast_matrix_index_expr(f, operand, open, close, interval, indices[0], indices[1]); } else { + parse_check_or_return(operand, "slice expression"); operand = ast_slice_expr(f, operand, open, close, interval, indices[0], indices[1]); } } else { + parse_check_or_return(operand, "index expression"); operand = ast_index_expr(f, operand, indices[0], open, close); } @@ -2913,6 +2933,7 @@ Ast *parse_atom_expr(AstFile *f, Ast *operand, bool lhs) { } break; case Token_Pointer: // Deference + parse_check_or_return(operand, "dereference"); operand = ast_deref_expr(f, operand, expect_token(f, Token_Pointer)); break; @@ -2950,7 +2971,7 @@ Ast *parse_atom_expr(AstFile *f, Ast *operand, bool lhs) { } -Ast *parse_unary_expr(AstFile *f, bool lhs) { +gb_internal Ast *parse_unary_expr(AstFile *f, bool lhs) { switch (f->curr_token.kind) { case Token_transmute: case Token_cast: { @@ -2997,7 +3018,7 @@ Ast *parse_unary_expr(AstFile *f, bool lhs) { return parse_atom_expr(f, parse_operand(f, lhs), lhs); } -bool is_ast_range(Ast *expr) { +gb_internal bool is_ast_range(Ast *expr) { if (expr == nullptr) { return false; } @@ -3008,7 +3029,7 @@ bool is_ast_range(Ast *expr) { } // NOTE(bill): result == priority -i32 token_precedence(AstFile *f, TokenKind t) { +gb_internal i32 token_precedence(AstFile *f, TokenKind t) { switch (t) { case Token_Question: case Token_if: @@ -3058,7 +3079,7 @@ i32 token_precedence(AstFile *f, TokenKind t) { return 0; } -Ast *parse_binary_expr(AstFile *f, bool lhs, i32 prec_in) { +gb_internal Ast *parse_binary_expr(AstFile *f, bool lhs, i32 prec_in) { Ast *expr = parse_unary_expr(f, lhs); for (;;) { Token op = f->curr_token; @@ -3119,12 +3140,12 @@ Ast *parse_binary_expr(AstFile *f, bool lhs, i32 prec_in) { return expr; } -Ast *parse_expr(AstFile *f, bool lhs) { +gb_internal Ast *parse_expr(AstFile *f, bool lhs) { return parse_binary_expr(f, lhs, 0+1); } -Array parse_expr_list(AstFile *f, bool lhs) { +gb_internal Array parse_expr_list(AstFile *f, bool lhs) { bool allow_newline = f->allow_newline; f->allow_newline = ALLOW_NEWLINE; @@ -3144,15 +3165,15 @@ Array parse_expr_list(AstFile *f, bool lhs) { return list; } -Array parse_lhs_expr_list(AstFile *f) { +gb_internal Array parse_lhs_expr_list(AstFile *f) { return parse_expr_list(f, true); } -Array parse_rhs_expr_list(AstFile *f) { +gb_internal Array parse_rhs_expr_list(AstFile *f) { return parse_expr_list(f, false); } -Array parse_ident_list(AstFile *f, bool allow_poly_names) { +gb_internal Array parse_ident_list(AstFile *f, bool allow_poly_names) { auto list = array_make(heap_allocator()); for (;;) { @@ -3167,7 +3188,7 @@ Array parse_ident_list(AstFile *f, bool allow_poly_names) { return list; } -Ast *parse_type(AstFile *f) { +gb_internal Ast *parse_type(AstFile *f) { Ast *type = parse_type_or_ident(f); if (type == nullptr) { Token token = advance_token(f); @@ -3177,7 +3198,7 @@ Ast *parse_type(AstFile *f) { return type; } -void parse_foreign_block_decl(AstFile *f, Array *decls) { +gb_internal void parse_foreign_block_decl(AstFile *f, Array *decls) { Ast *decl = parse_stmt(f); switch (decl->kind) { case Ast_EmptyStmt: @@ -3196,7 +3217,7 @@ void parse_foreign_block_decl(AstFile *f, Array *decls) { } } -Ast *parse_foreign_block(AstFile *f, Token token) { +gb_internal Ast *parse_foreign_block(AstFile *f, Token token) { CommentGroup *docs = f->lead_comment; Ast *foreign_library = nullptr; if (f->curr_token.kind == Token_OpenBrace) { @@ -3229,7 +3250,16 @@ Ast *parse_foreign_block(AstFile *f, Token token) { return decl; } -Ast *parse_value_decl(AstFile *f, Array names, CommentGroup *docs) { +gb_internal void print_comment_group(CommentGroup *group) { + if (group) { + for (Token const &token : group->list) { + gb_printf_err("%.*s\n", LIT(token.string)); + } + gb_printf_err("\n"); + } +} + +gb_internal Ast *parse_value_decl(AstFile *f, Array names, CommentGroup *docs) { bool is_mutable = true; Array values = {}; @@ -3270,6 +3300,8 @@ Ast *parse_value_decl(AstFile *f, Array names, CommentGroup *docs) { values.allocator = heap_allocator(); } + CommentGroup *end_comment = f->lead_comment; + if (f->expr_level >= 0) { if (f->curr_token.kind == Token_CloseBrace && f->curr_token.pos.line == f->prev_token.pos.line) { @@ -3290,10 +3322,10 @@ Ast *parse_value_decl(AstFile *f, Array names, CommentGroup *docs) { } } - return ast_value_decl(f, names, type, values, is_mutable, docs, f->line_comment); + return ast_value_decl(f, names, type, values, is_mutable, docs, end_comment); } -Ast *parse_simple_stmt(AstFile *f, u32 flags) { +gb_internal Ast *parse_simple_stmt(AstFile *f, u32 flags) { Token token = f->curr_token; CommentGroup *docs = f->lead_comment; @@ -3403,7 +3435,7 @@ Ast *parse_simple_stmt(AstFile *f, u32 flags) { -Ast *parse_block_stmt(AstFile *f, b32 is_when) { +gb_internal Ast *parse_block_stmt(AstFile *f, b32 is_when) { skip_possible_newline_for_literal(f); if (!is_when && f->curr_proc == nullptr) { syntax_error(f->curr_token, "You cannot use a block statement in the file scope"); @@ -3414,7 +3446,7 @@ Ast *parse_block_stmt(AstFile *f, b32 is_when) { -Ast *parse_results(AstFile *f, bool *diverging) { +gb_internal Ast *parse_results(AstFile *f, bool *diverging) { if (!allow_token(f, Token_ArrowRight)) { return nullptr; } @@ -3448,7 +3480,7 @@ Ast *parse_results(AstFile *f, bool *diverging) { } -ProcCallingConvention string_to_calling_convention(String const &s) { +gb_internal ProcCallingConvention string_to_calling_convention(String const &s) { if (s == "odin") return ProcCC_Odin; if (s == "contextless") return ProcCC_Contextless; if (s == "cdecl") return ProcCC_CDecl; @@ -3474,7 +3506,7 @@ ProcCallingConvention string_to_calling_convention(String const &s) { return ProcCC_Invalid; } -Ast *parse_proc_type(AstFile *f, Token proc_token) { +gb_internal Ast *parse_proc_type(AstFile *f, Token proc_token) { Ast *params = nullptr; Ast *results = nullptr; bool diverging = false; @@ -3509,16 +3541,14 @@ Ast *parse_proc_type(AstFile *f, Token proc_token) { u64 tags = 0; bool is_generic = false; - for_array(i, params->FieldList.list) { - Ast *param = params->FieldList.list[i]; + for (Ast *param : params->FieldList.list) { ast_node(field, Field, param); if (field->type != nullptr) { if (field->type->kind == Ast_PolyType) { is_generic = true; goto end; } - for_array(j, field->names) { - Ast *name = field->names[j]; + for (Ast *name : field->names) { if (name->kind == Ast_PolyType) { is_generic = true; goto end; @@ -3530,7 +3560,7 @@ end: return ast_proc_type(f, proc_token, params, results, tags, cc, is_generic, diverging); } -Ast *parse_var_type(AstFile *f, bool allow_ellipsis, bool allow_typeid_token) { +gb_internal Ast *parse_var_type(AstFile *f, bool allow_ellipsis, bool allow_typeid_token) { if (allow_ellipsis && f->curr_token.kind == Token_Ellipsis) { Token tok = advance_token(f); Ast *type = parse_type_or_ident(f); @@ -3564,7 +3594,6 @@ struct ParseFieldPrefixMapping { gb_global ParseFieldPrefixMapping parse_field_prefix_mappings[] = { {str_lit("using"), Token_using, FieldFlag_using}, - {str_lit("auto_cast"), Token_auto_cast, FieldFlag_auto_cast}, {str_lit("no_alias"), Token_Hash, FieldFlag_no_alias}, {str_lit("c_vararg"), Token_Hash, FieldFlag_c_vararg}, {str_lit("const"), Token_Hash, FieldFlag_const}, @@ -3574,7 +3603,7 @@ gb_global ParseFieldPrefixMapping parse_field_prefix_mappings[] = { }; -FieldFlag is_token_field_prefix(AstFile *f) { +gb_internal FieldFlag is_token_field_prefix(AstFile *f) { switch (f->curr_token.kind) { case Token_EOF: return FieldFlag_Invalid; @@ -3582,9 +3611,6 @@ FieldFlag is_token_field_prefix(AstFile *f) { case Token_using: return FieldFlag_using; - case Token_auto_cast: - return FieldFlag_auto_cast; - case Token_Hash: advance_token(f); switch (f->curr_token.kind) { @@ -3604,7 +3630,7 @@ FieldFlag is_token_field_prefix(AstFile *f) { return FieldFlag_Invalid; } -u32 parse_field_prefixes(AstFile *f) { +gb_internal u32 parse_field_prefixes(AstFile *f) { i32 counts[gb_count_of(parse_field_prefix_mappings)] = {}; for (;;) { @@ -3646,7 +3672,7 @@ u32 parse_field_prefixes(AstFile *f) { return field_flags; } -u32 check_field_prefixes(AstFile *f, isize name_count, u32 allowed_flags, u32 set_flags) { +gb_internal u32 check_field_prefixes(AstFile *f, isize name_count, u32 allowed_flags, u32 set_flags) { for (i32 i = 0; i < gb_count_of(parse_field_prefix_mappings); i++) { bool err = false; auto const &m = parse_field_prefix_mappings[i]; @@ -3679,11 +3705,12 @@ struct AstAndFlags { u32 flags; }; -Array convert_to_ident_list(AstFile *f, Array list, bool ignore_flags, bool allow_poly_names) { +gb_internal Array convert_to_ident_list(AstFile *f, Array list, bool ignore_flags, bool allow_poly_names) { auto idents = array_make(heap_allocator(), 0, list.count); // Convert to ident list - for_array(i, list) { - Ast *ident = list[i].node; + isize i = 0; + for (AstAndFlags const &item : list) { + Ast *ident = item.node; if (!ignore_flags) { if (i != 0) { @@ -3714,26 +3741,39 @@ Array convert_to_ident_list(AstFile *f, Array list, bool ign break; } array_add(&idents, ident); + i += 1; } return idents; } -bool allow_field_separator(AstFile *f) { +gb_internal bool allow_field_separator(AstFile *f) { Token token = f->curr_token; if (allow_token(f, Token_Comma)) { return true; } - if (ALLOW_NEWLINE && token.kind == Token_Semicolon && !token_is_newline(token)) { - String p = token_to_string(token); - syntax_error(token_end_of_line(f, f->prev_token), "Expected a comma, got a %.*s", LIT(p)); + if (token.kind == Token_Semicolon) { + bool ok = false; + if (ALLOW_NEWLINE && token_is_newline(token)) { + TokenKind next = peek_token(f).kind; + switch (next) { + case Token_CloseBrace: + case Token_CloseParen: + ok = true; + break; + } + } + if (!ok) { + String p = token_to_string(token); + syntax_error(token_end_of_line(f, f->prev_token), "Expected a comma, got a %.*s", LIT(p)); + } advance_token(f); return true; } return false; } -Ast *parse_struct_field_list(AstFile *f, isize *name_count_) { +gb_internal Ast *parse_struct_field_list(AstFile *f, isize *name_count_) { Token start_token = f->curr_token; auto decls = array_make(heap_allocator()); @@ -3747,7 +3787,7 @@ Ast *parse_struct_field_list(AstFile *f, isize *name_count_) { // Returns true if any are polymorphic names -bool check_procedure_name_list(Array const &names) { +gb_internal bool check_procedure_name_list(Array const &names) { if (names.count == 0) { return false; } @@ -3775,7 +3815,7 @@ bool check_procedure_name_list(Array const &names) { return any_polymorphic_names; } -Ast *parse_field_list(AstFile *f, isize *name_count_, u32 allowed_flags, TokenKind follow, bool allow_default_parameters, bool allow_typeid_token) { +gb_internal Ast *parse_field_list(AstFile *f, isize *name_count_, u32 allowed_flags, TokenKind follow, bool allow_default_parameters, bool allow_typeid_token) { bool prev_allow_newline = f->allow_newline; defer (f->allow_newline = prev_allow_newline); f->allow_newline = ALLOW_NEWLINE; @@ -3955,8 +3995,8 @@ Ast *parse_field_list(AstFile *f, isize *name_count_, u32 allowed_flags, TokenKi return ast_field_list(f, start_token, params); } - for_array(i, list) { - Ast *type = list[i].node; + for (AstAndFlags const &item : list) { + Ast *type = item.node; Token token = blank_token; if (allowed_flags&FieldFlag_Results) { // NOTE(bill): Make this nothing and not `_` @@ -3966,9 +4006,9 @@ Ast *parse_field_list(AstFile *f, isize *name_count_, u32 allowed_flags, TokenKi auto names = array_make(heap_allocator(), 1); token.pos = ast_token(type).pos; names[0] = ast_ident(f, token); - u32 flags = check_field_prefixes(f, list.count, allowed_flags, list[i].flags); + u32 flags = check_field_prefixes(f, list.count, allowed_flags, item.flags); Token tag = {}; - Ast *param = ast_field(f, names, list[i].node, nullptr, flags, tag, docs, f->line_comment); + Ast *param = ast_field(f, names, item.node, nullptr, flags, tag, docs, f->line_comment); array_add(¶ms, param); } @@ -3976,7 +4016,7 @@ Ast *parse_field_list(AstFile *f, isize *name_count_, u32 allowed_flags, TokenKi return ast_field_list(f, start_token, params); } -Ast *parse_type_or_ident(AstFile *f) { +gb_internal Ast *parse_type_or_ident(AstFile *f) { bool prev_allow_type = f->allow_type; isize prev_expr_level = f->expr_level; defer ({ @@ -3995,7 +4035,7 @@ Ast *parse_type_or_ident(AstFile *f) { -Ast *parse_body(AstFile *f) { +gb_internal Ast *parse_body(AstFile *f) { Array stmts = {}; Token open, close; isize prev_expr_level = f->expr_level; @@ -4013,7 +4053,7 @@ Ast *parse_body(AstFile *f) { return ast_block_stmt(f, stmts, open, close); } -Ast *parse_do_body(AstFile *f, Token const &token, char const *msg) { +gb_internal Ast *parse_do_body(AstFile *f, Token const &token, char const *msg) { Token open, close; isize prev_expr_level = f->expr_level; bool prev_allow_newline = f->allow_newline; @@ -4034,7 +4074,7 @@ Ast *parse_do_body(AstFile *f, Token const &token, char const *msg) { return body; } -bool parse_control_statement_semicolon_separator(AstFile *f) { +gb_internal bool parse_control_statement_semicolon_separator(AstFile *f) { Token tok = peek_token(f); if (tok.kind != Token_OpenBrace) { return allow_token(f, Token_Semicolon); @@ -4046,7 +4086,7 @@ bool parse_control_statement_semicolon_separator(AstFile *f) { } -Ast *parse_if_stmt(AstFile *f) { +gb_internal Ast *parse_if_stmt(AstFile *f) { if (f->curr_proc == nullptr) { syntax_error(f->curr_token, "You cannot use an if statement in the file scope"); return ast_bad_stmt(f, f->curr_token, f->curr_token); @@ -4112,7 +4152,7 @@ Ast *parse_if_stmt(AstFile *f) { return ast_if_stmt(f, token, init, cond, body, else_stmt); } -Ast *parse_when_stmt(AstFile *f) { +gb_internal Ast *parse_when_stmt(AstFile *f) { Token token = expect_token(f, Token_when); Ast *cond = nullptr; Ast *body = nullptr; @@ -4160,7 +4200,7 @@ Ast *parse_when_stmt(AstFile *f) { } -Ast *parse_return_stmt(AstFile *f) { +gb_internal Ast *parse_return_stmt(AstFile *f) { Token token = expect_token(f, Token_return); if (f->curr_proc == nullptr) { @@ -4188,7 +4228,7 @@ Ast *parse_return_stmt(AstFile *f) { return ast_return_stmt(f, token, results); } -Ast *parse_for_stmt(AstFile *f) { +gb_internal Ast *parse_for_stmt(AstFile *f) { if (f->curr_proc == nullptr) { syntax_error(f->curr_token, "You cannot use a for statement in the file scope"); return ast_bad_stmt(f, f->curr_token, f->curr_token); @@ -4279,7 +4319,7 @@ Ast *parse_for_stmt(AstFile *f) { } -Ast *parse_case_clause(AstFile *f, bool is_type) { +gb_internal Ast *parse_case_clause(AstFile *f, bool is_type) { Token token = f->curr_token; Array list = {}; expect_token(f, Token_case); @@ -4299,7 +4339,7 @@ Ast *parse_case_clause(AstFile *f, bool is_type) { } -Ast *parse_switch_stmt(AstFile *f) { +gb_internal Ast *parse_switch_stmt(AstFile *f) { if (f->curr_proc == nullptr) { syntax_error(f->curr_token, "You cannot use a switch statement in the file scope"); return ast_bad_stmt(f, f->curr_token, f->curr_token); @@ -4361,7 +4401,7 @@ Ast *parse_switch_stmt(AstFile *f) { return ast_switch_stmt(f, token, init, tag, body); } -Ast *parse_defer_stmt(AstFile *f) { +gb_internal Ast *parse_defer_stmt(AstFile *f) { if (f->curr_proc == nullptr) { syntax_error(f->curr_token, "You cannot use a defer statement in the file scope"); return ast_bad_stmt(f, f->curr_token, f->curr_token); @@ -4391,7 +4431,7 @@ enum ImportDeclKind { ImportDecl_Using, }; -Ast *parse_import_decl(AstFile *f, ImportDeclKind kind) { +gb_internal Ast *parse_import_decl(AstFile *f, ImportDeclKind kind) { CommentGroup *docs = f->lead_comment; Token token = expect_token(f, Token_import); Token import_name = {}; @@ -4424,7 +4464,7 @@ Ast *parse_import_decl(AstFile *f, ImportDeclKind kind) { return s; } -Ast *parse_foreign_decl(AstFile *f) { +gb_internal Ast *parse_foreign_decl(AstFile *f) { CommentGroup *docs = f->lead_comment; Token token = expect_token(f, Token_foreign); @@ -4487,7 +4527,7 @@ Ast *parse_foreign_decl(AstFile *f) { return ast_bad_decl(f, token, f->curr_token); } -Ast *parse_attribute(AstFile *f, Token token, TokenKind open_kind, TokenKind close_kind) { +gb_internal Ast *parse_attribute(AstFile *f, Token token, TokenKind open_kind, TokenKind close_kind, CommentGroup *docs) { Array elems = {}; Token open = {}; Token close = {}; @@ -4528,6 +4568,9 @@ Ast *parse_attribute(AstFile *f, Token token, TokenKind open_kind, TokenKind clo Ast *decl = parse_stmt(f); if (decl->kind == Ast_ValueDecl) { + if (decl->ValueDecl.docs == nullptr && docs != nullptr) { + decl->ValueDecl.docs = docs; + } array_add(&decl->ValueDecl.attributes, attribute); } else if (decl->kind == Ast_ForeignBlockDecl) { array_add(&decl->ForeignBlockDecl.attributes, attribute); @@ -4542,7 +4585,7 @@ Ast *parse_attribute(AstFile *f, Token token, TokenKind open_kind, TokenKind clo } -Ast *parse_unrolled_for_loop(AstFile *f, Token unroll_token) { +gb_internal Ast *parse_unrolled_for_loop(AstFile *f, Token unroll_token) { Token for_token = expect_token(f, Token_for); Ast *val0 = nullptr; Ast *val1 = nullptr; @@ -4589,7 +4632,7 @@ Ast *parse_unrolled_for_loop(AstFile *f, Token unroll_token) { return ast_unroll_range_stmt(f, unroll_token, for_token, val0, val1, in_token, expr, body); } -Ast *parse_stmt(AstFile *f) { +gb_internal Ast *parse_stmt(AstFile *f) { Ast *s = nullptr; Token token = f->curr_token; switch (token.kind) { @@ -4676,8 +4719,9 @@ Ast *parse_stmt(AstFile *f) { } break; case Token_At: { + CommentGroup *docs = f->lead_comment; Token token = expect_token(f, Token_At); - return parse_attribute(f, token, Token_OpenParen, Token_CloseParen); + return parse_attribute(f, token, Token_OpenParen, Token_CloseParen, docs); } case Token_Hash: { @@ -4727,6 +4771,17 @@ Ast *parse_stmt(AstFile *f) { return stmt; } else if (tag == "unroll") { return parse_unrolled_for_loop(f, name); + } else if (tag == "reverse") { + Ast *for_stmt = parse_for_stmt(f); + if (for_stmt->kind == Ast_RangeStmt) { + if (for_stmt->RangeStmt.reverse) { + syntax_error(token, "#reverse already applied to a 'for in' statement"); + } + for_stmt->RangeStmt.reverse = true; + } else { + syntax_error(token, "#reverse can only be applied to a 'for in' statement"); + } + return for_stmt; } else if (tag == "include") { syntax_error(token, "#include is not a valid import declaration kind. Did you mean 'import'?"); s = ast_bad_stmt(f, token, f->curr_token); @@ -4781,7 +4836,7 @@ Ast *parse_stmt(AstFile *f) { return ast_bad_stmt(f, token, f->curr_token); } -Array parse_stmt_list(AstFile *f) { +gb_internal Array parse_stmt_list(AstFile *f) { auto list = array_make(heap_allocator()); while (f->curr_token.kind != Token_case && @@ -4802,10 +4857,12 @@ Array parse_stmt_list(AstFile *f) { } -ParseFileError init_ast_file(AstFile *f, String const &fullpath, TokenPos *err_pos) { +gb_internal ParseFileError init_ast_file(AstFile *f, String const &fullpath, TokenPos *err_pos) { GB_ASSERT(f != nullptr); - f->fullpath = string_trim_whitespace(fullpath); // Just in case - set_file_path_string(f->id, fullpath); + f->fullpath = string_trim_whitespace(fullpath); // Just in case + f->filename = remove_directory_from_path(f->fullpath); + f->directory = directory_from_path(f->fullpath); + set_file_path_string(f->id, f->fullpath); thread_safe_set_ast_file_from_id(f->id, f); if (!string_ends_with(f->fullpath, str_lit(".odin"))) { return ParseFile_WrongExtension; @@ -4881,86 +4938,76 @@ ParseFileError init_ast_file(AstFile *f, String const &fullpath, TokenPos *err_p return ParseFile_None; } -void destroy_ast_file(AstFile *f) { +gb_internal void destroy_ast_file(AstFile *f) { GB_ASSERT(f != nullptr); array_free(&f->tokens); array_free(&f->comments); array_free(&f->imports); } -bool init_parser(Parser *p) { +gb_internal bool init_parser(Parser *p) { GB_ASSERT(p != nullptr); - string_set_init(&p->imported_files, heap_allocator()); + string_set_init(&p->imported_files); array_init(&p->packages, heap_allocator()); - array_init(&p->package_imports, heap_allocator()); - mutex_init(&p->wait_mutex); - mutex_init(&p->import_mutex); - mutex_init(&p->file_add_mutex); - mutex_init(&p->file_decl_mutex); - mutex_init(&p->packages_mutex); - mpmc_init(&p->file_error_queue, heap_allocator(), 1024); return true; } -void destroy_parser(Parser *p) { +gb_internal void destroy_parser(Parser *p) { GB_ASSERT(p != nullptr); // TODO(bill): Fix memory leak - for_array(i, p->packages) { - AstPackage *pkg = p->packages[i]; - for_array(j, pkg->files) { - destroy_ast_file(pkg->files[j]); + for (AstPackage *pkg : p->packages) { + for (AstFile *file : pkg->files) { + destroy_ast_file(file); } array_free(&pkg->files); array_free(&pkg->foreign_files); } -#if 0 - for_array(i, p->package_imports) { - // gb_free(heap_allocator(), p->package_imports[i].text); - } -#endif array_free(&p->packages); - array_free(&p->package_imports); string_set_destroy(&p->imported_files); - mutex_destroy(&p->wait_mutex); - mutex_destroy(&p->import_mutex); - mutex_destroy(&p->file_add_mutex); - mutex_destroy(&p->file_decl_mutex); - mutex_destroy(&p->packages_mutex); - mpmc_destroy(&p->file_error_queue); } -void parser_add_package(Parser *p, AstPackage *pkg) { - mutex_lock(&p->packages_mutex); - pkg->id = p->packages.count+1; - array_add(&p->packages, pkg); - mutex_unlock(&p->packages_mutex); +gb_internal void parser_add_package(Parser *p, AstPackage *pkg) { + MUTEX_GUARD_BLOCK(&p->packages_mutex) { + pkg->id = p->packages.count+1; + array_add(&p->packages, pkg); + } } -ParseFileError process_imported_file(Parser *p, ImportedFile imported_file); +gb_internal ParseFileError process_imported_file(Parser *p, ImportedFile imported_file); -WORKER_TASK_PROC(parser_worker_proc) { +gb_internal WORKER_TASK_PROC(parser_worker_proc) { ParserWorkerData *wd = cast(ParserWorkerData *)data; ParseFileError err = process_imported_file(wd->parser, wd->imported_file); if (err != ParseFile_None) { - mpmc_enqueue(&wd->parser->file_error_queue, err); + auto *node = gb_alloc_item(permanent_allocator(), ParseFileErrorNode); + node->err = err; + + MUTEX_GUARD_BLOCK(&wd->parser->file_error_mutex) { + if (wd->parser->file_error_tail != nullptr) { + wd->parser->file_error_tail->next = node; + } + wd->parser->file_error_tail = node; + if (wd->parser->file_error_head == nullptr) { + wd->parser->file_error_head = node; + } + } } return cast(isize)err; } -void parser_add_file_to_process(Parser *p, AstPackage *pkg, FileInfo fi, TokenPos pos) { +gb_internal void parser_add_file_to_process(Parser *p, AstPackage *pkg, FileInfo fi, TokenPos pos) { // TODO(bill): Use a better allocator ImportedFile f = {pkg, fi, pos, p->file_to_process_count++}; auto wd = gb_alloc_item(permanent_allocator(), ParserWorkerData); wd->parser = p; wd->imported_file = f; - global_thread_pool_add_task(parser_worker_proc, wd); + thread_pool_add_task(parser_worker_proc, wd); } -WORKER_TASK_PROC(foreign_file_worker_proc) { +gb_internal WORKER_TASK_PROC(foreign_file_worker_proc) { ForeignFileWorkerData *wd = cast(ForeignFileWorkerData *)data; - Parser *p = wd->parser; ImportedFile *imp = &wd->imported_file; AstPackage *pkg = imp->pkg; @@ -4980,36 +5027,35 @@ WORKER_TASK_PROC(foreign_file_worker_proc) { // TODO(bill): Actually do something with it break; } - mutex_lock(&p->file_add_mutex); - array_add(&pkg->foreign_files, foreign_file); - mutex_unlock(&p->file_add_mutex); + MUTEX_GUARD_BLOCK(&pkg->foreign_files_mutex) { + array_add(&pkg->foreign_files, foreign_file); + } return 0; } -void parser_add_foreign_file_to_process(Parser *p, AstPackage *pkg, AstForeignFileKind kind, FileInfo fi, TokenPos pos) { +gb_internal void parser_add_foreign_file_to_process(Parser *p, AstPackage *pkg, AstForeignFileKind kind, FileInfo fi, TokenPos pos) { // TODO(bill): Use a better allocator ImportedFile f = {pkg, fi, pos, p->file_to_process_count++}; auto wd = gb_alloc_item(permanent_allocator(), ForeignFileWorkerData); wd->parser = p; wd->imported_file = f; wd->foreign_kind = kind; - global_thread_pool_add_task(foreign_file_worker_proc, wd); + thread_pool_add_task(foreign_file_worker_proc, wd); } // NOTE(bill): Returns true if it's added -AstPackage *try_add_import_path(Parser *p, String const &path, String const &rel_path, TokenPos pos, PackageKind kind = Package_Normal) { +gb_internal AstPackage *try_add_import_path(Parser *p, String path, String const &rel_path, TokenPos pos, PackageKind kind = Package_Normal) { String const FILE_EXT = str_lit(".odin"); - mutex_lock(&p->import_mutex); - defer (mutex_unlock(&p->import_mutex)); - - if (string_set_exists(&p->imported_files, path)) { - return nullptr; + MUTEX_GUARD_BLOCK(&p->imported_files_mutex) { + if (string_set_update(&p->imported_files, path)) { + return nullptr; + } } - string_set_add(&p->imported_files, path); + path = copy_string(permanent_allocator(), path); AstPackage *pkg = gb_alloc_item(permanent_allocator(), AstPackage); pkg->kind = kind; @@ -5019,16 +5065,16 @@ AstPackage *try_add_import_path(Parser *p, String const &path, String const &rel // NOTE(bill): Single file initial package if (kind == Package_Init && string_ends_with(path, FILE_EXT)) { - FileInfo fi = {}; fi.name = filename_from_path(path); fi.fullpath = path; fi.size = get_file_size(path); fi.is_dir = false; + array_reserve(&pkg->files, 1); pkg->is_single_file = true; - parser_add_file_to_process(p, pkg, fi, pos); parser_add_package(p, pkg); + parser_add_file_to_process(p, pkg, fi, pos); return pkg; } @@ -5063,8 +5109,17 @@ AstPackage *try_add_import_path(Parser *p, String const &path, String const &rel return nullptr; } - for_array(list_index, list) { - FileInfo fi = list[list_index]; + isize files_to_reserve = 1; // always reserve 1 + for (FileInfo fi : list) { + String name = fi.name; + String ext = path_extension(name); + if (ext == FILE_EXT && !is_excluded_target_filename(name)) { + files_to_reserve += 1; + } + } + + array_reserve(&pkg->files, files_to_reserve); + for (FileInfo fi : list) { String name = fi.name; String ext = path_extension(name); if (ext == FILE_EXT) { @@ -5097,7 +5152,7 @@ gb_global Rune illegal_import_runes[] = { '|', ',', '<', '>', '?', }; -bool is_import_path_valid(String const &path) { +gb_internal bool is_import_path_valid(String const &path) { if (path.len > 0) { u8 *start = path.text; u8 *end = path.text + path.len; @@ -5129,7 +5184,7 @@ bool is_import_path_valid(String const &path) { return false; } -bool is_build_flag_path_valid(String const &path) { +gb_internal bool is_build_flag_path_valid(String const &path) { if (path.len > 0) { u8 *start = path.text; u8 *end = path.text + path.len; @@ -5171,7 +5226,7 @@ bool is_build_flag_path_valid(String const &path) { } -bool is_package_name_reserved(String const &name) { +gb_internal bool is_package_name_reserved(String const &name) { if (name == "builtin") { return true; } else if (name == "intrinsics") { @@ -5181,7 +5236,7 @@ bool is_package_name_reserved(String const &name) { } -bool determine_path_from_string(BlockingMutex *file_mutex, Ast *node, String base_dir, String const &original_string, String *path) { +gb_internal bool determine_path_from_string(BlockingMutex *file_mutex, Ast *node, String base_dir, String const &original_string, String *path) { GB_ASSERT(path != nullptr); // NOTE(bill): if file_mutex == nullptr, this means that the code is used within the semantics stage @@ -5295,9 +5350,9 @@ bool determine_path_from_string(BlockingMutex *file_mutex, Ast *node, String bas -void parse_setup_file_decls(Parser *p, AstFile *f, String const &base_dir, Slice &decls); +gb_internal void parse_setup_file_decls(Parser *p, AstFile *f, String const &base_dir, Slice &decls); -void parse_setup_file_when_stmt(Parser *p, AstFile *f, String const &base_dir, AstWhenStmt *ws) { +gb_internal void parse_setup_file_when_stmt(Parser *p, AstFile *f, String const &base_dir, AstWhenStmt *ws) { if (ws->body != nullptr) { auto stmts = ws->body->BlockStmt.stmts; parse_setup_file_decls(p, f, base_dir, stmts); @@ -5316,7 +5371,7 @@ void parse_setup_file_when_stmt(Parser *p, AstFile *f, String const &base_dir, A } } -void parse_setup_file_decls(Parser *p, AstFile *f, String const &base_dir, Slice &decls) { +gb_internal void parse_setup_file_decls(Parser *p, AstFile *f, String const &base_dir, Slice &decls) { for_array(i, decls) { Ast *node = decls[i]; if (!is_ast_decl(node) && @@ -5357,14 +5412,14 @@ void parse_setup_file_decls(Parser *p, AstFile *f, String const &base_dir, Slice auto fullpaths = array_make(permanent_allocator(), 0, fl->filepaths.count); - for_array(fp_idx, fl->filepaths) { - String file_str = string_trim_whitespace(string_value_from_token(f, fl->filepaths[fp_idx])); + for (Token const &fp : fl->filepaths) { + String file_str = string_trim_whitespace(string_value_from_token(f, fp)); String fullpath = file_str; if (allow_check_foreign_filepath()) { String foreign_path = {}; bool ok = determine_path_from_string(&p->file_decl_mutex, node, base_dir, file_str, &foreign_path); if (!ok) { - decls[i] = ast_bad_decl(f, fl->filepaths[fp_idx], fl->filepaths[fl->filepaths.count-1]); + decls[i] = ast_bad_decl(f, fp, fl->filepaths[fl->filepaths.count-1]); goto end; } fullpath = foreign_path; @@ -5389,7 +5444,7 @@ void parse_setup_file_decls(Parser *p, AstFile *f, String const &base_dir, Slice } } -String build_tag_get_token(String s, String *out) { +gb_internal String build_tag_get_token(String s, String *out) { s = string_trim_whitespace(s); isize n = 0; while (n < s.len) { @@ -5408,7 +5463,7 @@ String build_tag_get_token(String s, String *out) { return s; } -bool parse_build_tag(Token token_for_pos, String s) { +gb_internal bool parse_build_tag(Token token_for_pos, String s) { String const prefix = str_lit("+build"); GB_ASSERT(string_starts_with(s, prefix)); s = string_trim_whitespace(substring(s, prefix.len, s.len)); @@ -5473,7 +5528,7 @@ bool parse_build_tag(Token token_for_pos, String s) { return any_correct; } -String dir_from_path(String path) { +gb_internal String dir_from_path(String path) { String base_dir = path; for (isize i = path.len-1; i >= 0; i--) { if (base_dir[i] == '\\' || @@ -5485,12 +5540,12 @@ String dir_from_path(String path) { return base_dir; } -isize calc_decl_count(Ast *decl) { +gb_internal isize calc_decl_count(Ast *decl) { isize count = 0; switch (decl->kind) { case Ast_BlockStmt: - for_array(i, decl->BlockStmt.stmts) { - count += calc_decl_count(decl->BlockStmt.stmts.data[i]); + for (Ast *stmt : decl->BlockStmt.stmts) { + count += calc_decl_count(stmt); } break; case Ast_WhenStmt: @@ -5516,7 +5571,7 @@ isize calc_decl_count(Ast *decl) { return count; } -bool parse_build_project_directory_tag(Token token_for_pos, String s) { +gb_internal bool parse_build_project_directory_tag(Token token_for_pos, String s) { String const prefix = str_lit("+build-project-name"); GB_ASSERT(string_starts_with(s, prefix)); s = string_trim_whitespace(substring(s, prefix.len, s.len)); @@ -5561,7 +5616,7 @@ bool parse_build_project_directory_tag(Token token_for_pos, String s) { return any_correct; } -bool parse_file(Parser *p, AstFile *f) { +gb_internal bool parse_file(Parser *p, AstFile *f) { if (f->tokens.count == 0) { return true; } @@ -5610,8 +5665,8 @@ bool parse_file(Parser *p, AstFile *f) { f->package_name = package_name.string; if (!f->pkg->is_single_file && docs != nullptr && docs->list.count > 0) { - for_array(i, docs->list) { - Token tok = docs->list[i]; GB_ASSERT(tok.kind == Token_Comment); + for (Token const &tok : docs->list) { + GB_ASSERT(tok.kind == Token_Comment); String str = tok.string; if (string_starts_with(str, str_lit("//"))) { String lc = string_trim_whitespace(substring(str, 2, str.len)); @@ -5624,6 +5679,8 @@ bool parse_file(Parser *p, AstFile *f) { if (!parse_build_tag(tok, lc)) { return false; } + } else if (string_starts_with(lc, str_lit("+ignore"))) { + return false; } else if (string_starts_with(lc, str_lit("+private"))) { f->flags |= AstFile_IsPrivatePkg; String command = string_trim_starts_with(lc, str_lit("+private ")); @@ -5686,7 +5743,7 @@ bool parse_file(Parser *p, AstFile *f) { f->time_to_parse = cast(f64)(end-start)/cast(f64)time_stamp__freq(); for (int i = 0; i < AstDelayQueue_COUNT; i++) { - mpmc_init(f->delayed_decls_queues+i, heap_allocator(), f->delayed_decl_count); + array_init(f->delayed_decls_queues+i, heap_allocator(), 0, f->delayed_decl_count); } @@ -5694,7 +5751,7 @@ bool parse_file(Parser *p, AstFile *f) { } -ParseFileError process_imported_file(Parser *p, ImportedFile imported_file) { +gb_internal ParseFileError process_imported_file(Parser *p, ImportedFile imported_file) { AstPackage *pkg = imported_file.pkg; FileInfo fi = imported_file.fi; TokenPos pos = imported_file.pos; @@ -5753,11 +5810,11 @@ ParseFileError process_imported_file(Parser *p, ImportedFile imported_file) { } if (parse_file(p, file)) { - mutex_lock(&p->file_add_mutex); - defer (mutex_unlock(&p->file_add_mutex)); - - array_add(&pkg->files, file); + MUTEX_GUARD_BLOCK(&pkg->files_mutex) { + array_add(&pkg->files, file); + } + mutex_lock(&pkg->name_mutex); if (pkg->name.len == 0) { pkg->name = file->package_name; } else if (pkg->name != file->package_name) { @@ -5769,16 +5826,17 @@ ParseFileError process_imported_file(Parser *p, ImportedFile imported_file) { syntax_error(tok, "Different package name, expected '%.*s', got '%.*s'", LIT(pkg->name), LIT(file->package_name)); } } + mutex_unlock(&pkg->name_mutex); - p->total_line_count += file->tokenizer.line_count; - p->total_token_count += file->tokens.count; + p->total_line_count.fetch_add(file->tokenizer.line_count); + p->total_token_count.fetch_add(file->tokens.count); } return ParseFile_None; } -ParseFileError parse_packages(Parser *p, String init_filename) { +gb_internal ParseFileError parse_packages(Parser *p, String init_filename) { GB_ASSERT(init_filename.text[init_filename.len] == 0); String init_fullpath = path_to_full_path(heap_allocator(), init_filename); @@ -5808,9 +5866,6 @@ ParseFileError parse_packages(Parser *p, String init_filename) { { // Add these packages serially and then process them parallel - mutex_lock(&p->wait_mutex); - defer (mutex_unlock(&p->wait_mutex)); - TokenPos init_pos = {}; { String s = get_fullpath_core(heap_allocator(), str_lit("runtime")); @@ -5826,8 +5881,7 @@ ParseFileError parse_packages(Parser *p, String init_filename) { } - for_array(i, build_context.extra_packages) { - String path = build_context.extra_packages[i]; + for (String const &path : build_context.extra_packages) { String fullpath = path_to_full_path(heap_allocator(), path); // LEAK? if (!path_is_directory(fullpath)) { String const ext = str_lit(".odin"); @@ -5843,11 +5897,11 @@ ParseFileError parse_packages(Parser *p, String init_filename) { } } - global_thread_pool_wait(); + thread_pool_wait(); - for (ParseFileError err = ParseFile_None; mpmc_dequeue(&p->file_error_queue, &err); /**/) { - if (err != ParseFile_None) { - return err; + for (ParseFileErrorNode *node = p->file_error_head; node != nullptr; node = node->next) { + if (node->err != ParseFile_None) { + return node->err; } } diff --git a/src/parser.hpp b/src/parser.hpp index e384f1e7e..900fddbab 100644 --- a/src/parser.hpp +++ b/src/parser.hpp @@ -62,15 +62,6 @@ enum PackageKind { Package_Init, }; -struct ImportedPackage { - PackageKind kind; - String path; - String rel_path; - TokenPos pos; // import - isize index; -}; - - struct ImportedFile { AstPackage *pkg; FileInfo fi; @@ -99,7 +90,11 @@ struct AstFile { Scope * scope; Ast * pkg_decl; + String fullpath; + String filename; + String directory; + Tokenizer tokenizer; Array tokens; isize curr_token_index; @@ -109,6 +104,7 @@ struct AstFile { Token package_token; String package_name; + // >= 0: In Expression // < 0: In Control Clause // NOTE(bill): Used to prevent type literals in control clauses @@ -136,9 +132,8 @@ struct AstFile { CommentGroup *docs; // current docs Array comments; // All the comments! - // TODO(bill): make this a basic queue as it does not require - // any multiple thread capabilities - MPMCQueue delayed_decls_queues[AstDelayQueue_COUNT]; + // This is effectively a queue but does not require any multi-threading capabilities + Array delayed_decls_queues[AstDelayQueue_COUNT]; #define PARSER_MAX_FIX_COUNT 6 isize fix_count; @@ -177,6 +172,12 @@ struct AstPackage { bool is_single_file; isize order; + BlockingMutex files_mutex; + BlockingMutex foreign_files_mutex; + BlockingMutex type_and_value_mutex; + BlockingMutex name_mutex; + + // NOTE(bill): This must be a MPMCQueue MPMCQueue exported_entity_queue; // NOTE(bill): Created/set in checker @@ -186,20 +187,33 @@ struct AstPackage { }; +struct ParseFileErrorNode { + ParseFileErrorNode *next, *prev; + ParseFileError err; +}; + struct Parser { - String init_fullpath; - StringSet imported_files; // fullpath - Array packages; - Array package_imports; - isize file_to_process_count; - isize total_token_count; - isize total_line_count; - BlockingMutex wait_mutex; - BlockingMutex import_mutex; - BlockingMutex file_add_mutex; - BlockingMutex file_decl_mutex; - BlockingMutex packages_mutex; - MPMCQueue file_error_queue; + String init_fullpath; + + StringSet imported_files; // fullpath + BlockingMutex imported_files_mutex; + + Array packages; + BlockingMutex packages_mutex; + + std::atomic file_to_process_count; + std::atomic total_token_count; + std::atomic total_line_count; + + // TODO(bill): What should this mutex be per? + // * Parser + // * Package + // * File + BlockingMutex file_decl_mutex; + + BlockingMutex file_error_mutex; + ParseFileErrorNode * file_error_head; + ParseFileErrorNode * file_error_tail; }; struct ParserWorkerData { @@ -258,7 +272,7 @@ enum ProcCallingConvention : i32 { ProcCC_ForeignBlockDefault = -1, }; -char const *proc_calling_convention_strings[ProcCC_MAX] = { +gb_global char const *proc_calling_convention_strings[ProcCC_MAX] = { "", "odin", "contextless", @@ -272,7 +286,7 @@ char const *proc_calling_convention_strings[ProcCC_MAX] = { "sysv", }; -ProcCallingConvention default_calling_convention(void) { +gb_internal ProcCallingConvention default_calling_convention(void) { return ProcCC_Odin; } @@ -299,7 +313,7 @@ enum FieldFlag : u32 { FieldFlag_using = 1<<1, FieldFlag_no_alias = 1<<2, FieldFlag_c_vararg = 1<<3, - FieldFlag_auto_cast = 1<<4, + FieldFlag_const = 1<<5, FieldFlag_any_int = 1<<6, FieldFlag_subtype = 1<<7, @@ -314,7 +328,7 @@ enum FieldFlag : u32 { FieldFlag_Invalid = 1u<<31, // Parameter List Restrictions - FieldFlag_Signature = FieldFlag_ellipsis|FieldFlag_using|FieldFlag_no_alias|FieldFlag_c_vararg|FieldFlag_auto_cast|FieldFlag_const|FieldFlag_any_int|FieldFlag_by_ptr, + FieldFlag_Signature = FieldFlag_ellipsis|FieldFlag_using|FieldFlag_no_alias|FieldFlag_c_vararg|FieldFlag_const|FieldFlag_any_int|FieldFlag_by_ptr, FieldFlag_Struct = FieldFlag_using|FieldFlag_subtype|FieldFlag_Tags, }; @@ -332,7 +346,7 @@ enum InlineAsmDialectKind : u8 { InlineAsmDialect_COUNT, }; -char const *inline_asm_dialect_strings[InlineAsmDialect_COUNT] = { +gb_global char const *inline_asm_dialect_strings[InlineAsmDialect_COUNT] = { "", "att", "intel", @@ -342,6 +356,20 @@ enum UnionTypeKind : u8 { UnionType_Normal = 0, UnionType_no_nil = 2, UnionType_shared_nil = 3, + + UnionType_COUNT +}; + +gb_global char const *union_type_kind_strings[UnionType_COUNT] = { + "(normal)", + "#maybe", + "#no_nil", + "#shared_nil", +}; + +struct AstSplitArgs { + Slice positional; + Slice named; }; #define AST_KINDS \ @@ -350,7 +378,7 @@ enum UnionTypeKind : u8 { Entity *entity; \ }) \ AST_KIND(Implicit, "implicit", Token) \ - AST_KIND(Undef, "undef", Token) \ + AST_KIND(Uninit, "uninitialized value", Token) \ AST_KIND(BasicLit, "basic literal", struct { \ Token token; \ }) \ @@ -419,6 +447,7 @@ AST_KIND(_ExprBegin, "", bool) \ ProcInlining inlining; \ bool optional_ok_one; \ bool was_selector; \ + AstSplitArgs *split_args; \ }) \ AST_KIND(FieldValue, "field value", struct { Token eq; Ast *field, *value; }) \ AST_KIND(EnumFieldValue, "enum field value", struct { \ @@ -457,11 +486,6 @@ AST_KIND(_StmtBegin, "", bool) \ AST_KIND(BadStmt, "bad statement", struct { Token begin, end; }) \ AST_KIND(EmptyStmt, "empty statement", struct { Token token; }) \ AST_KIND(ExprStmt, "expression statement", struct { Ast *expr; } ) \ - AST_KIND(TagStmt, "tag statement", struct { \ - Token token; \ - Token name; \ - Ast * stmt; \ - }) \ AST_KIND(AssignStmt, "assign statement", struct { \ Token op; \ Slice lhs, rhs; \ @@ -511,6 +535,7 @@ AST_KIND(_ComplexStmtBegin, "", bool) \ Token in_token; \ Ast *expr; \ Ast *body; \ + bool reverse; \ }) \ AST_KIND(UnrollRangeStmt, "#unroll range statement", struct { \ Scope *scope; \ @@ -684,6 +709,7 @@ AST_KIND(_TypeBegin, "", bool) \ Slice where_clauses; \ bool is_packed; \ bool is_raw_union; \ + bool is_no_copy; \ }) \ AST_KIND(UnionType, "union type", struct { \ Scope *scope; \ @@ -729,7 +755,7 @@ enum AstKind : u16 { Ast_COUNT, }; -String const ast_strings[] = { +gb_global String const ast_strings[] = { {cast(u8 *)"invalid node", gb_size_of("invalid node")}, #define AST_KIND(_kind_name_, name, ...) {cast(u8 *)name, gb_size_of(name)-1}, AST_KINDS @@ -742,7 +768,7 @@ String const ast_strings[] = { #undef AST_KIND -isize const ast_variant_sizes[] = { +gb_global isize const ast_variant_sizes[] = { 0, #define AST_KIND(_kind_name_, name, ...) gb_size_of(GB_JOIN2(Ast, _kind_name_)), AST_KINDS @@ -754,7 +780,7 @@ struct AstCommonStuff { u8 state_flags; u8 viral_state_flags; i32 file_id; - TypeAndValue tav; // TODO(bill): Make this a pointer to minimize 'Ast' size + TypeAndValue tav; // NOTE(bill): Making this a pointer is slower }; struct Ast { @@ -762,7 +788,7 @@ struct Ast { u8 state_flags; u8 viral_state_flags; i32 file_id; - TypeAndValue tav; // TODO(bill): Make this a pointer to minimize 'Ast' size + TypeAndValue tav; // NOTE(bill): Making this a pointer is slower // IMPORTANT NOTE(bill): This must be at the end since the AST is allocated to be size of the variant union { @@ -793,33 +819,32 @@ struct Ast { #endif -gb_inline bool is_ast_expr(Ast *node) { +gb_internal gb_inline bool is_ast_expr(Ast *node) { return gb_is_between(node->kind, Ast__ExprBegin+1, Ast__ExprEnd-1); } -gb_inline bool is_ast_stmt(Ast *node) { +gb_internal gb_inline bool is_ast_stmt(Ast *node) { return gb_is_between(node->kind, Ast__StmtBegin+1, Ast__StmtEnd-1); } -gb_inline bool is_ast_complex_stmt(Ast *node) { +gb_internal gb_inline bool is_ast_complex_stmt(Ast *node) { return gb_is_between(node->kind, Ast__ComplexStmtBegin+1, Ast__ComplexStmtEnd-1); } -gb_inline bool is_ast_decl(Ast *node) { +gb_internal gb_inline bool is_ast_decl(Ast *node) { return gb_is_between(node->kind, Ast__DeclBegin+1, Ast__DeclEnd-1); } -gb_inline bool is_ast_type(Ast *node) { +gb_internal gb_inline bool is_ast_type(Ast *node) { return gb_is_between(node->kind, Ast__TypeBegin+1, Ast__TypeEnd-1); } -gb_inline bool is_ast_when_stmt(Ast *node) { +gb_internal gb_inline bool is_ast_when_stmt(Ast *node) { return node->kind == Ast_WhenStmt; } gb_global gb_thread_local Arena global_thread_local_ast_arena = {}; -gbAllocator ast_allocator(AstFile *f) { - Arena *arena = &global_thread_local_ast_arena; - return arena_allocator(arena); +gb_internal gb_inline gbAllocator ast_allocator(AstFile *f) { + return arena_allocator(&global_thread_local_ast_arena); } -Ast *alloc_ast_node(AstFile *f, AstKind kind); +gb_internal Ast *alloc_ast_node(AstFile *f, AstKind kind); -gbString expr_to_string(Ast *expression); -bool allow_field_separator(AstFile *f); \ No newline at end of file +gb_internal gbString expr_to_string(Ast *expression); +gb_internal bool allow_field_separator(AstFile *f); \ No newline at end of file diff --git a/src/parser_pos.cpp b/src/parser_pos.cpp index 54c3ec1f1..3d2e8f27d 100644 --- a/src/parser_pos.cpp +++ b/src/parser_pos.cpp @@ -1,8 +1,8 @@ -Token ast_token(Ast *node) { +gb_internal Token ast_token(Ast *node) { switch (node->kind) { case Ast_Ident: return node->Ident.token; case Ast_Implicit: return node->Implicit; - case Ast_Undef: return node->Undef; + case Ast_Uninit: return node->Uninit; case Ast_BasicLit: return node->BasicLit.token; case Ast_BasicDirective: return node->BasicDirective.token; case Ast_ProcGroup: return node->ProcGroup.token; @@ -20,6 +20,9 @@ Token ast_token(Ast *node) { case Ast_ParenExpr: return node->ParenExpr.open; case Ast_CallExpr: return ast_token(node->CallExpr.proc); case Ast_SelectorExpr: + if (node->SelectorExpr.expr != nullptr) { + return ast_token(node->SelectorExpr.expr); + } if (node->SelectorExpr.selector != nullptr) { return ast_token(node->SelectorExpr.selector); } @@ -34,11 +37,15 @@ Token ast_token(Ast *node) { return ast_token(node->ImplicitSelectorExpr.selector); } return node->ImplicitSelectorExpr.token; - case Ast_IndexExpr: return node->IndexExpr.open; - case Ast_MatrixIndexExpr: return node->MatrixIndexExpr.open; - case Ast_SliceExpr: return node->SliceExpr.open; + case Ast_IndexExpr: return ast_token(node->IndexExpr.expr); + case Ast_MatrixIndexExpr: return ast_token(node->MatrixIndexExpr.expr); + case Ast_SliceExpr: return ast_token(node->SliceExpr.expr); case Ast_Ellipsis: return node->Ellipsis.token; - case Ast_FieldValue: return node->FieldValue.eq; + case Ast_FieldValue: + if (node->FieldValue.field) { + return ast_token(node->FieldValue.field); + } + return node->FieldValue.eq; case Ast_EnumFieldValue: return ast_token(node->EnumFieldValue.name); case Ast_DerefExpr: return node->DerefExpr.op; case Ast_TernaryIfExpr: return ast_token(node->TernaryIfExpr.x); @@ -53,7 +60,6 @@ Token ast_token(Ast *node) { case Ast_BadStmt: return node->BadStmt.begin; case Ast_EmptyStmt: return node->EmptyStmt.token; case Ast_ExprStmt: return ast_token(node->ExprStmt.expr); - case Ast_TagStmt: return node->TagStmt.token; case Ast_AssignStmt: return node->AssignStmt.op; case Ast_BlockStmt: return node->BlockStmt.open; case Ast_IfStmt: return node->IfStmt.token; @@ -135,7 +141,7 @@ Token ast_end_token(Ast *node) { return empty_token; case Ast_Ident: return node->Ident.token; case Ast_Implicit: return node->Implicit; - case Ast_Undef: return node->Undef; + case Ast_Uninit: return node->Uninit; case Ast_BasicLit: return node->BasicLit.token; case Ast_BasicDirective: return node->BasicDirective.token; case Ast_ProcGroup: return node->ProcGroup.close; @@ -197,7 +203,6 @@ Token ast_end_token(Ast *node) { case Ast_BadStmt: return node->BadStmt.end; case Ast_EmptyStmt: return node->EmptyStmt.token; case Ast_ExprStmt: return ast_end_token(node->ExprStmt.expr); - case Ast_TagStmt: return ast_end_token(node->TagStmt.stmt); case Ast_AssignStmt: if (node->AssignStmt.rhs.count > 0) { return ast_end_token(node->AssignStmt.rhs[node->AssignStmt.rhs.count-1]); @@ -360,6 +365,6 @@ Token ast_end_token(Ast *node) { return empty_token; } -TokenPos ast_end_pos(Ast *node) { +gb_internal TokenPos ast_end_pos(Ast *node) { return token_pos_end(ast_end_token(node)); } diff --git a/src/path.cpp b/src/path.cpp index 6f83c39ea..de80c9def 100644 --- a/src/path.cpp +++ b/src/path.cpp @@ -1,7 +1,14 @@ /* Path handling utilities. */ -String remove_extension_from_path(String const &s) { +#if !defined(GB_SYSTEM_WINDOWS) +#include +#endif + +gb_internal String remove_extension_from_path(String const &s) { + if (s.len != 0 && s.text[s.len-1] == '.') { + return s; + } for (isize i = s.len-1; i >= 0; i--) { if (s[i] == '.') { return substring(s, 0, i); @@ -10,7 +17,7 @@ String remove_extension_from_path(String const &s) { return s; } -String remove_directory_from_path(String const &s) { +gb_internal String remove_directory_from_path(String const &s) { isize len = 0; for (isize i = s.len-1; i >= 0; i--) { if (s[i] == '/' || @@ -22,9 +29,32 @@ String remove_directory_from_path(String const &s) { return substring(s, s.len-len, s.len); } -bool path_is_directory(String path); -String directory_from_path(String const &s) { +// NOTE(Mark Naughton): getcwd as String +#if !defined(GB_SYSTEM_WINDOWS) +gb_internal String get_current_directory(void) { + char cwd[256]; + getcwd(cwd, 256); + + return make_string_c(cwd); +} + +#else +gb_internal String get_current_directory(void) { + gbAllocator a = heap_allocator(); + + wchar_t cwd[256]; + GetCurrentDirectoryW(256, cwd); + + String16 wstr = make_string16_c(cwd); + + return string16_to_string(a, wstr); +} +#endif + +gb_internal bool path_is_directory(String path); + +gb_internal String directory_from_path(String const &s) { if (path_is_directory(s)) { return s; } @@ -43,7 +73,7 @@ String directory_from_path(String const &s) { } #if defined(GB_SYSTEM_WINDOWS) - bool path_is_directory(String path) { + gb_internal bool path_is_directory(String path) { gbAllocator a = heap_allocator(); String16 wstr = string_to_string16(a, path); defer (gb_free(a, wstr.text)); @@ -55,7 +85,7 @@ String directory_from_path(String const &s) { } #else - bool path_is_directory(String path) { + gb_internal bool path_is_directory(String path) { gbAllocator a = heap_allocator(); char *copy = cast(char *)copy_string(a, path).text; defer (gb_free(a, copy)); @@ -69,7 +99,7 @@ String directory_from_path(String const &s) { #endif -String path_to_full_path(gbAllocator a, String path) { +gb_internal String path_to_full_path(gbAllocator a, String path) { gbAllocator ha = heap_allocator(); char *path_c = gb_alloc_str_len(ha, cast(char *)path.text, path.len); defer (gb_free(ha, path_c)); @@ -93,7 +123,7 @@ struct Path { }; // NOTE(Jeroen): Naively turns a Path into a string. -String path_to_string(gbAllocator a, Path path) { +gb_internal String path_to_string(gbAllocator a, Path path) { if (path.basename.len + path.name.len + path.ext.len == 0) { return make_string(nullptr, 0); } @@ -107,7 +137,9 @@ String path_to_string(gbAllocator a, Path path) { isize i = 0; gb_memmove(str+i, path.basename.text, path.basename.len); i += path.basename.len; + gb_memmove(str+i, "/", 1); i += 1; + gb_memmove(str+i, path.name.text, path.name.len); i += path.name.len; if (path.ext.len > 0) { gb_memmove(str+i, ".", 1); i += 1; @@ -121,7 +153,7 @@ String path_to_string(gbAllocator a, Path path) { } // NOTE(Jeroen): Naively turns a Path into a string, then normalizes it using `path_to_full_path`. -String path_to_full_path(gbAllocator a, Path path) { +gb_internal String path_to_full_path(gbAllocator a, Path path) { String temp = path_to_string(heap_allocator(), path); defer (gb_free(heap_allocator(), temp.text)); @@ -130,7 +162,7 @@ String path_to_full_path(gbAllocator a, Path path) { // NOTE(Jeroen): Takes a path like "odin" or "W:\Odin", turns it into a full path, // and then breaks it into its components to make a Path. -Path path_from_string(gbAllocator a, String const &path) { +gb_internal Path path_from_string(gbAllocator a, String const &path) { Path res = {}; if (path.len == 0) return res; @@ -150,6 +182,7 @@ Path path_from_string(gbAllocator a, String const &path) { return res; } + // Note(Dragos): Is the copy_string required if it's a substring? isize name_start = (res.basename.len > 0) ? res.basename.len + 1 : res.basename.len; res.name = substring(fullpath, name_start, fullpath.len); res.name = remove_extension_from_path(res.name); @@ -161,7 +194,7 @@ Path path_from_string(gbAllocator a, String const &path) { } // NOTE(Jeroen): Takes a path String and returns the last path element. -String last_path_element(String const &path) { +gb_internal String last_path_element(String const &path) { isize count = 0; u8 * start = (u8 *)(&path.text[path.len - 1]); for (isize length = path.len; length > 0 && path.text[length - 1] != '/'; length--) { @@ -177,7 +210,7 @@ String last_path_element(String const &path) { return STR_LIT(""); } -bool path_is_directory(Path path) { +gb_internal bool path_is_directory(Path path) { String path_string = path_to_full_path(heap_allocator(), path); defer (gb_free(heap_allocator(), path_string.text)); @@ -204,7 +237,7 @@ enum ReadDirectoryError { ReadDirectory_COUNT, }; -i64 get_file_size(String path) { +gb_internal i64 get_file_size(String path) { char *c_str = alloc_cstring(heap_allocator(), path); defer (gb_free(heap_allocator(), c_str)); @@ -219,10 +252,9 @@ i64 get_file_size(String path) { #if defined(GB_SYSTEM_WINDOWS) -ReadDirectoryError read_directory(String path, Array *fi) { +gb_internal ReadDirectoryError read_directory(String path, Array *fi) { GB_ASSERT(fi != nullptr); - gbAllocator a = heap_allocator(); while (path.len > 0) { Rune end = path[path.len-1]; @@ -239,9 +271,7 @@ ReadDirectoryError read_directory(String path, Array *fi) { return ReadDirectory_InvalidPath; } { - char *c_str = alloc_cstring(a, path); - defer (gb_free(a, c_str)); - + char *c_str = alloc_cstring(temporary_allocator(), path); gbFile f = {}; gbFileError file_err = gb_file_open(&f, c_str); defer (gb_file_close(&f)); @@ -258,6 +288,7 @@ ReadDirectoryError read_directory(String path, Array *fi) { } + gbAllocator a = heap_allocator(); char *new_path = gb_alloc_array(a, char, path.len+3); defer (gb_free(a, new_path)); @@ -280,8 +311,8 @@ ReadDirectoryError read_directory(String path, Array *fi) { do { wchar_t *filename_w = file_data.cFileName; - i64 size = cast(i64)file_data.nFileSizeLow; - size |= (cast(i64)file_data.nFileSizeHigh) << 32; + u64 size = cast(u64)file_data.nFileSizeLow; + size |= (cast(u64)file_data.nFileSizeHigh) << 32; String name = string16_to_string(a, make_string16_c(filename_w)); if (name == "." || name == "..") { gb_free(a, name.text); @@ -299,7 +330,7 @@ ReadDirectoryError read_directory(String path, Array *fi) { FileInfo info = {}; info.name = name; info.fullpath = path_to_full_path(a, filepath); - info.size = size; + info.size = cast(i64)size; info.is_dir = (file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; array_add(fi, info); } while (FindNextFileW(find_file, &file_data)); @@ -314,7 +345,7 @@ ReadDirectoryError read_directory(String path, Array *fi) { #include -ReadDirectoryError read_directory(String path, Array *fi) { +gb_internal ReadDirectoryError read_directory(String path, Array *fi) { GB_ASSERT(fi != nullptr); gbAllocator a = heap_allocator(); @@ -388,7 +419,43 @@ ReadDirectoryError read_directory(String path, Array *fi) { return ReadDirectory_None; } + + #else #error Implement read_directory #endif +#if !defined(GB_SYSTEM_WINDOWS) +gb_internal bool write_directory(String path) { + char const *pathname = (char *) path.text; + + if (access(pathname, W_OK) < 0) { + return false; + } + + return true; +} +#else +gb_internal bool write_directory(String path) { + String16 wstr = string_to_string16(heap_allocator(), path); + LPCWSTR wdirectory_name = wstr.text; + + HANDLE directory = CreateFileW(wdirectory_name, + GENERIC_WRITE, + 0, + NULL, + OPEN_EXISTING, + FILE_FLAG_BACKUP_SEMANTICS, + NULL); + + if (directory == INVALID_HANDLE_VALUE) { + DWORD error_code = GetLastError(); + if (error_code == ERROR_ACCESS_DENIED) { + return false; + } + } + + CloseHandle(directory); + return true; +} +#endif diff --git a/src/priority_queue.cpp b/src/priority_queue.cpp index aee2061b5..c0f1ddff0 100644 --- a/src/priority_queue.cpp +++ b/src/priority_queue.cpp @@ -7,7 +7,7 @@ struct PriorityQueue { }; template -bool priority_queue_shift_down(PriorityQueue *pq, isize i0, isize n) { +gb_internal bool priority_queue_shift_down(PriorityQueue *pq, isize i0, isize n) { // O(n log n) isize i = i0; isize j, j1, j2; @@ -29,7 +29,7 @@ bool priority_queue_shift_down(PriorityQueue *pq, isize i0, isize n) { } template -void priority_queue_shift_up(PriorityQueue *pq, isize j) { +gb_internal void priority_queue_shift_up(PriorityQueue *pq, isize j) { while (0 <= j && j < pq->queue.count) { isize i = (j-1)/2; if (i == j || pq->cmp(&pq->queue[0], j, i) >= 0) { @@ -43,20 +43,20 @@ void priority_queue_shift_up(PriorityQueue *pq, isize j) { // NOTE(bill): When an element at index `i0` has changed its value, this will fix the // the heap ordering. This using a basic "heapsort" with shift up and a shift down parts. template -void priority_queue_fix(PriorityQueue *pq, isize i) { +gb_internal void priority_queue_fix(PriorityQueue *pq, isize i) { if (!priority_queue_shift_down(pq, i, pq->queue.count)) { priority_queue_shift_up(pq, i); } } template -void priority_queue_push(PriorityQueue *pq, T const &value) { +gb_internal void priority_queue_push(PriorityQueue *pq, T const &value) { array_add(&pq->queue, value); priority_queue_shift_up(pq, pq->queue.count-1); } template -T priority_queue_pop(PriorityQueue *pq) { +gb_internal T priority_queue_pop(PriorityQueue *pq) { GB_ASSERT(pq->queue.count > 0); isize n = pq->queue.count - 1; @@ -67,7 +67,7 @@ T priority_queue_pop(PriorityQueue *pq) { template -T priority_queue_remove(PriorityQueue *pq, isize i) { +gb_internal T priority_queue_remove(PriorityQueue *pq, isize i) { GB_ASSERT(0 <= i && i < pq->queue.count); isize n = pq->queue.count - 1; if (n != i) { @@ -80,7 +80,7 @@ T priority_queue_remove(PriorityQueue *pq, isize i) { template -PriorityQueue priority_queue_create(Array queue, +gb_internal PriorityQueue priority_queue_create(Array queue, int (* cmp) (T *q, isize i, isize j), void (* swap)(T *q, isize i, isize j)) { PriorityQueue pq = {}; diff --git a/src/ptr_map.cpp b/src/ptr_map.cpp index 43e793b8a..23278014f 100644 --- a/src/ptr_map.cpp +++ b/src/ptr_map.cpp @@ -2,6 +2,13 @@ typedef u32 MapIndex; +enum { + MAP_CACHE_LINE_SIZE_POW = 6, + MAP_CACHE_LINE_SIZE = 1< struct PtrMap { - Slice hashes; - Array > entries; + MapIndex * hashes; + usize hashes_count; + PtrMapEntry *entries; + u32 count; + u32 entries_capacity; }; -u32 ptr_map_hash_key(uintptr key) { +gb_internal gb_inline u32 ptr_map_hash_key(uintptr key) { + u32 res; #if defined(GB_ARCH_64_BIT) key = (~key) + (key << 21); key = key ^ (key >> 24); @@ -34,80 +45,98 @@ u32 ptr_map_hash_key(uintptr key) { key = key ^ (key >> 14); key = (key + (key << 2)) + (key << 4); key = key ^ (key << 28); - return cast(u32)key; + res = cast(u32)key; #elif defined(GB_ARCH_32_BIT) - u32 state = ((u32)key) * 747796405u + 2891336453u; + u32 state = (cast(u32)key) * 747796405u + 2891336453u; u32 word = ((state >> ((state >> 28u) + 4u)) ^ state) * 277803737u; - return (word >> 22u) ^ word; + res = (word >> 22u) ^ word; #endif + return res; } -u32 ptr_map_hash_key(void const *key) { +gb_internal gb_inline u32 ptr_map_hash_key(void const *key) { return ptr_map_hash_key((uintptr)key); } -template void map_init (PtrMap *h, gbAllocator a, isize capacity = 16); -template void map_destroy (PtrMap *h); -template V * map_get (PtrMap *h, K key); -template void map_set (PtrMap *h, K key, V const &value); -template void map_remove (PtrMap *h, K key); -template void map_clear (PtrMap *h); -template void map_grow (PtrMap *h); -template void map_rehash (PtrMap *h, isize new_count); -template void map_reserve (PtrMap *h, isize cap); +template gb_internal void map_init (PtrMap *h, isize capacity = 16); +template gb_internal void map_destroy (PtrMap *h); +template gb_internal V * map_get (PtrMap *h, K key); +template gb_internal void map_set (PtrMap *h, K key, V const &value); +template gb_internal bool map_set_if_not_previously_exists(PtrMap *h, K key, V const &value); // returns true if it previously existed +template gb_internal void map_remove (PtrMap *h, K key); +template gb_internal void map_clear (PtrMap *h); +template gb_internal void map_grow (PtrMap *h); +template gb_internal void map_rehash (PtrMap *h, isize new_count); +template gb_internal void map_reserve (PtrMap *h, isize cap); #if PTR_MAP_ENABLE_MULTI_MAP // Mutlivalued map procedure -template PtrMapEntry * multi_map_find_first(PtrMap *h, K key); -template PtrMapEntry * multi_map_find_next (PtrMap *h, PtrMapEntry *e); +template gb_internal PtrMapEntry * multi_map_find_first(PtrMap *h, K key); +template gb_internal PtrMapEntry * multi_map_find_next (PtrMap *h, PtrMapEntry *e); -template isize multi_map_count (PtrMap *h, K key); -template void multi_map_get_all (PtrMap *h, K key, V *items); -template void multi_map_insert (PtrMap *h, K key, V const &value); -template void multi_map_remove (PtrMap *h, K key, PtrMapEntry *e); -template void multi_map_remove_all(PtrMap *h, K key); +template gb_internal isize multi_map_count (PtrMap *h, K key); +template gb_internal void multi_map_get_all (PtrMap *h, K key, V *items); +template gb_internal void multi_map_insert (PtrMap *h, K key, V const &value); +template gb_internal void multi_map_remove (PtrMap *h, K key, PtrMapEntry *e); +template gb_internal void multi_map_remove_all(PtrMap *h, K key); #endif -template -gb_inline void map_init(PtrMap *h, gbAllocator a, isize capacity) { - capacity = next_pow2_isize(capacity); - slice_init(&h->hashes, a, capacity); - array_init(&h->entries, a, 0, capacity); - for (isize i = 0; i < capacity; i++) { - h->hashes.data[i] = MAP_SENTINEL; - } +gb_internal gbAllocator map_allocator(void) { + return heap_allocator(); } template -gb_inline void map_destroy(PtrMap *h) { - slice_free(&h->hashes, h->entries.allocator); - array_free(&h->entries); +gb_internal gb_inline void map_init(PtrMap *h, isize capacity) { + capacity = next_pow2_isize(capacity); + map_reserve(h, capacity); } +template +gb_internal gb_inline void map_destroy(PtrMap *h) { + gbAllocator a = map_allocator(); + gb_free(a, h->hashes); + gb_free(a, h->entries); +} + +template +gb_internal void map__resize_hashes(PtrMap *h, usize count) { + h->hashes_count = cast(u32)resize_array_raw(&h->hashes, map_allocator(), h->hashes_count, count, MAP_CACHE_LINE_SIZE); +} + +template +gb_internal void map__reserve_entries(PtrMap *h, usize capacity) { + h->entries_capacity = cast(u32)resize_array_raw(&h->entries, map_allocator(), h->entries_capacity, capacity, MAP_CACHE_LINE_SIZE); +} + + template gb_internal MapIndex map__add_entry(PtrMap *h, K key) { PtrMapEntry e = {}; e.key = key; e.next = MAP_SENTINEL; - array_add(&h->entries, e); - return cast(MapIndex)(h->entries.count-1); + if (h->count+1 >= h->entries_capacity) { + map__reserve_entries(h, gb_max(h->entries_capacity*2, 4)); + } + h->entries[h->count++] = e; + return cast(MapIndex)(h->count-1); } template gb_internal MapFindResult map__find(PtrMap *h, K key) { MapFindResult fr = {MAP_SENTINEL, MAP_SENTINEL, MAP_SENTINEL}; - if (h->hashes.count == 0) { + if (h->hashes_count == 0) { return fr; } u32 hash = ptr_map_hash_key(key); - fr.hash_index = cast(MapIndex)(hash & (h->hashes.count-1)); - fr.entry_index = h->hashes.data[fr.hash_index]; + fr.hash_index = cast(MapIndex)(hash & (h->hashes_count-1)); + fr.entry_index = h->hashes[fr.hash_index]; while (fr.entry_index != MAP_SENTINEL) { - if (h->entries.data[fr.entry_index].key == key) { + auto *entry = &h->entries[fr.entry_index]; + if (entry->key == key) { return fr; } fr.entry_prev = fr.entry_index; - fr.entry_index = h->entries.data[fr.entry_index].next; + fr.entry_index = entry->next; } return fr; } @@ -115,41 +144,41 @@ gb_internal MapFindResult map__find(PtrMap *h, K key) { template gb_internal MapFindResult map__find_from_entry(PtrMap *h, PtrMapEntry *e) { MapFindResult fr = {MAP_SENTINEL, MAP_SENTINEL, MAP_SENTINEL}; - if (h->hashes.count == 0) { + if (h->hashes_count == 0) { return fr; } u32 hash = ptr_map_hash_key(e->key); - fr.hash_index = cast(MapIndex)(hash & (h->hashes.count-1)); - fr.entry_index = h->hashes.data[fr.hash_index]; + fr.hash_index = cast(MapIndex)(hash & (h->hashes_count-1)); + fr.entry_index = h->hashes[fr.hash_index]; while (fr.entry_index != MAP_SENTINEL) { - if (&h->entries.data[fr.entry_index] == e) { + if (&h->entries[fr.entry_index] == e) { return fr; } fr.entry_prev = fr.entry_index; - fr.entry_index = h->entries.data[fr.entry_index].next; + fr.entry_index = h->entries[fr.entry_index].next; } return fr; } template gb_internal b32 map__full(PtrMap *h) { - return 0.75f * h->hashes.count <= h->entries.count; + return 0.75f * h->hashes_count <= h->count; } template -gb_inline void map_grow(PtrMap *h) { - isize new_count = gb_max(h->hashes.count<<1, 16); +gb_internal gb_inline void map_grow(PtrMap *h) { + isize new_count = gb_max(h->hashes_count<<1, 16); map_rehash(h, new_count); } template -void map_reset_entries(PtrMap *h) { - for (isize i = 0; i < h->hashes.count; i++) { - h->hashes.data[i] = MAP_SENTINEL; +gb_internal void map_reset_entries(PtrMap *h) { + for (usize i = 0; i < h->hashes_count; i++) { + h->hashes[i] = MAP_SENTINEL; } - for (isize i = 0; i < h->entries.count; i++) { + for (usize i = 0; i < h->count; i++) { MapFindResult fr; - PtrMapEntry *e = &h->entries.data[i]; + PtrMapEntry *e = &h->entries[i]; e->next = MAP_SENTINEL; fr = map__find_from_entry(h, e); if (fr.entry_prev == MAP_SENTINEL) { @@ -161,42 +190,88 @@ void map_reset_entries(PtrMap *h) { } template -void map_reserve(PtrMap *h, isize cap) { - array_reserve(&h->entries, cap); - if (h->entries.count*2 < h->hashes.count) { +gb_internal void map_reserve(PtrMap *h, isize cap) { + if (h->count*2 < h->hashes_count) { return; } - slice_resize(&h->hashes, h->entries.allocator, cap*2); + map__reserve_entries(h, cap); + map__resize_hashes(h, cap*2); map_reset_entries(h); } template -void map_rehash(PtrMap *h, isize new_count) { +gb_internal void map_rehash(PtrMap *h, isize new_count) { map_reserve(h, new_count); } template -V *map_get(PtrMap *h, K key) { - MapIndex index = map__find(h, key).entry_index; - if (index != MAP_SENTINEL) { - return &h->entries.data[index].value; +gb_internal V *map_get(PtrMap *h, K key) { + MapIndex hash_index = MAP_SENTINEL; + MapIndex entry_prev = MAP_SENTINEL; + MapIndex entry_index = MAP_SENTINEL; + if (h->hashes_count != 0) { + u32 hash = ptr_map_hash_key(key); + hash_index = cast(MapIndex)(hash & (h->hashes_count-1)); + entry_index = h->hashes[hash_index]; + while (entry_index != MAP_SENTINEL) { + auto *entry = &h->entries[entry_index]; + if (entry->key == key) { + return &entry->value; + } + entry_prev = entry_index; + entry_index = entry->next; + } } return nullptr; } +template +gb_internal V *map_try_get(PtrMap *h, K key, MapFindResult *fr_) { + MapFindResult fr = {MAP_SENTINEL, MAP_SENTINEL, MAP_SENTINEL}; + if (h->hashes_count != 0) { + u32 hash = ptr_map_hash_key(key); + fr.hash_index = cast(MapIndex)(hash & (h->hashes_count-1)); + fr.entry_index = h->hashes[fr.hash_index]; + while (fr.entry_index != MAP_SENTINEL) { + auto *entry = &h->entries[fr.entry_index]; + if (entry->key == key) { + return &entry->value; + } + fr.entry_prev = fr.entry_index; + fr.entry_index = entry->next; + } + } + if (h->hashes_count == 0 || map__full(h)) { + map_grow(h); + } + if (fr_) *fr_ = fr; + return nullptr; +} + template -V &map_must_get(PtrMap *h, K key) { - MapIndex index = map__find(h, key).entry_index; - GB_ASSERT(index != MAP_SENTINEL); - return h->entries.data[index].value; +gb_internal void map_set_internal_from_try_get(PtrMap *h, K key, V const &value, MapFindResult const &fr) { + MapIndex index = map__add_entry(h, key); + if (fr.entry_prev != MAP_SENTINEL) { + h->entries[fr.entry_prev].next = index; + } else { + h->hashes[fr.hash_index] = index; + } + h->entries[index].value = value; } template -void map_set(PtrMap *h, K key, V const &value) { +gb_internal V &map_must_get(PtrMap *h, K key) { + V *ptr = map_get(h, key); + GB_ASSERT(ptr != nullptr); + return *ptr; +} + +template +gb_internal void map_set(PtrMap *h, K key, V const &value) { MapIndex index; MapFindResult fr; - if (h->hashes.count == 0) { + if (h->hashes_count == 0) { map_grow(h); } fr = map__find(h, key); @@ -205,44 +280,71 @@ void map_set(PtrMap *h, K key, V const &value) { } else { index = map__add_entry(h, key); if (fr.entry_prev != MAP_SENTINEL) { - h->entries.data[fr.entry_prev].next = index; + h->entries[fr.entry_prev].next = index; } else { - h->hashes.data[fr.hash_index] = index; + h->hashes[fr.hash_index] = index; } } - h->entries.data[index].value = value; + h->entries[index].value = value; if (map__full(h)) { map_grow(h); } } +// returns true if it previously existed +template +gb_internal bool map_set_if_not_previously_exists(PtrMap *h, K key, V const &value) { + MapIndex index; + MapFindResult fr; + if (h->hashes_count == 0) { + map_grow(h); + } + fr = map__find(h, key); + if (fr.entry_index != MAP_SENTINEL) { + return true; + } else { + index = map__add_entry(h, key); + if (fr.entry_prev != MAP_SENTINEL) { + h->entries[fr.entry_prev].next = index; + } else { + h->hashes[fr.hash_index] = index; + } + } + h->entries[index].value = value; + + if (map__full(h)) { + map_grow(h); + } + return false; +} + template -void map__erase(PtrMap *h, MapFindResult const &fr) { +gb_internal void map__erase(PtrMap *h, MapFindResult const &fr) { MapFindResult last; if (fr.entry_prev == MAP_SENTINEL) { - h->hashes.data[fr.hash_index] = h->entries.data[fr.entry_index].next; + h->hashes[fr.hash_index] = h->entries[fr.entry_index].next; } else { - h->entries.data[fr.entry_prev].next = h->entries.data[fr.entry_index].next; + h->entries[fr.entry_prev].next = h->entries[fr.entry_index].next; } - if (fr.entry_index == h->entries.count-1) { - array_pop(&h->entries); + if (fr.entry_index == h->count-1) { + h->count--; return; } - h->entries.data[fr.entry_index] = h->entries.data[h->entries.count-1]; - array_pop(&h->entries); + h->entries[fr.entry_index] = h->entries[h->count-1]; + h->count--; - last = map__find(h, h->entries.data[fr.entry_index].key); + last = map__find(h, h->entries[fr.entry_index].key); if (last.entry_prev != MAP_SENTINEL) { - h->entries.data[last.entry_prev].next = fr.entry_index; + h->entries[last.entry_prev].next = fr.entry_index; } else { - h->hashes.data[last.hash_index] = fr.entry_index; + h->hashes[last.hash_index] = fr.entry_index; } } template -void map_remove(PtrMap *h, K key) { +gb_internal void map_remove(PtrMap *h, K key) { MapFindResult fr = map__find(h, key); if (fr.entry_index != MAP_SENTINEL) { map__erase(h, fr); @@ -250,38 +352,38 @@ void map_remove(PtrMap *h, K key) { } template -gb_inline void map_clear(PtrMap *h) { - array_clear(&h->entries); - for (isize i = 0; i < h->hashes.count; i++) { - h->hashes.data[i] = MAP_SENTINEL; +gb_internal gb_inline void map_clear(PtrMap *h) { + h->count = 0; + for (usize i = 0; i < h->hashes_count; i++) { + h->hashes[i] = MAP_SENTINEL; } } #if PTR_MAP_ENABLE_MULTI_MAP template -PtrMapEntry *multi_map_find_first(PtrMap *h, K key) { +gb_internal PtrMapEntry *multi_map_find_first(PtrMap *h, K key) { MapIndex i = map__find(h, key).entry_index; if (i == MAP_SENTINEL) { return nullptr; } - return &h->entries.data[i]; + return &h->entries[i]; } template -PtrMapEntry *multi_map_find_next(PtrMap *h, PtrMapEntry *e) { +gb_internal PtrMapEntry *multi_map_find_next(PtrMap *h, PtrMapEntry *e) { MapIndex i = e->next; while (i != MAP_SENTINEL) { - if (h->entries.data[i].key == e->key) { - return &h->entries.data[i]; + if (h->entries[i].key == e->key) { + return &h->entries[i]; } - i = h->entries.data[i].next; + i = h->entries[i].next; } return nullptr; } template -isize multi_map_count(PtrMap *h, K key) { +gb_internal isize multi_map_count(PtrMap *h, K key) { isize count = 0; PtrMapEntry *e = multi_map_find_first(h, key); while (e != nullptr) { @@ -292,8 +394,8 @@ isize multi_map_count(PtrMap *h, K key) { } template -void multi_map_get_all(PtrMap *h, K key, V *items) { - isize i = 0; +gb_internal void multi_map_get_all(PtrMap *h, K key, V *items) { + usize i = 0; PtrMapEntry *e = multi_map_find_first(h, key); while (e != nullptr) { items[i++] = e->value; @@ -302,22 +404,22 @@ void multi_map_get_all(PtrMap *h, K key, V *items) { } template -void multi_map_insert(PtrMap *h, K key, V const &value) { +gb_internal void multi_map_insert(PtrMap *h, K key, V const &value) { MapFindResult fr; MapIndex i; - if (h->hashes.count == 0) { + if (h->hashes_count == 0) { map_grow(h); } // Make fr = map__find(h, key); i = map__add_entry(h, key); if (fr.entry_prev == MAP_SENTINEL) { - h->hashes.data[fr.hash_index] = i; + h->hashes[fr.hash_index] = i; } else { - h->entries.data[fr.entry_prev].next = i; + h->entries[fr.entry_prev].next = i; } - h->entries.data[i].next = fr.entry_index; - h->entries.data[i].value = value; + h->entries[i].next = fr.entry_index; + h->entries[i].value = value; // Grow if needed if (map__full(h)) { map_grow(h); @@ -325,7 +427,7 @@ void multi_map_insert(PtrMap *h, K key, V const &value) { } template -void multi_map_remove(PtrMap *h, K key, PtrMapEntry *e) { +gb_internal void multi_map_remove(PtrMap *h, K key, PtrMapEntry *e) { MapFindResult fr = map__find_from_entry(h, e); if (fr.entry_index != MAP_SENTINEL) { map__erase(h, fr); @@ -333,9 +435,30 @@ void multi_map_remove(PtrMap *h, K key, PtrMapEntry *e) { } template -void multi_map_remove_all(PtrMap *h, K key) { +gb_internal void multi_map_remove_all(PtrMap *h, K key) { while (map_get(h, key) != nullptr) { map_remove(h, key); } } #endif + + +template +gb_internal PtrMapEntry *begin(PtrMap &m) { + return m.entries; +} +template +gb_internal PtrMapEntry const *begin(PtrMap const &m) { + return m.entries; +} + + +template +gb_internal PtrMapEntry *end(PtrMap &m) { + return m.entries + m.count; +} + +template +gb_internal PtrMapEntry const *end(PtrMap const &m) { + return m.entries + m.count; +} diff --git a/src/ptr_set.cpp b/src/ptr_set.cpp index ffe48d69a..ff4befc37 100644 --- a/src/ptr_set.cpp +++ b/src/ptr_set.cpp @@ -1,235 +1,204 @@ -template -struct PtrSetEntry { - T ptr; - MapIndex next; -}; - template struct PtrSet { - Slice hashes; - Array> entries; + static_assert(TypeIsPointer::value || TypeIsPtrSizedInteger::value, "PtrSet::T must be a pointer"); + static constexpr uintptr TOMBSTONE = ~(uintptr)(0ull); + + T * keys; + usize count; + usize capacity; }; -template void ptr_set_init (PtrSet *s, gbAllocator a, isize capacity = 16); -template void ptr_set_destroy(PtrSet *s); -template T ptr_set_add (PtrSet *s, T ptr); -template bool ptr_set_update (PtrSet *s, T ptr); // returns true if it previously existed -template bool ptr_set_exists (PtrSet *s, T ptr); -template void ptr_set_remove (PtrSet *s, T ptr); -template void ptr_set_clear (PtrSet *s); -template void ptr_set_grow (PtrSet *s); -template void ptr_set_rehash (PtrSet *s, isize new_count); -template void ptr_set_reserve(PtrSet *h, isize cap); +template gb_internal void ptr_set_init (PtrSet *s, isize capacity = 16); +template gb_internal void ptr_set_destroy(PtrSet *s); +template gb_internal T ptr_set_add (PtrSet *s, T ptr); +template gb_internal bool ptr_set_update (PtrSet *s, T ptr); // returns true if it previously existed +template gb_internal bool ptr_set_exists (PtrSet *s, T ptr); +template gb_internal void ptr_set_remove (PtrSet *s, T ptr); +template gb_internal void ptr_set_clear (PtrSet *s); +gb_internal gbAllocator ptr_set_allocator(void) { + return heap_allocator(); +} template -void ptr_set_init(PtrSet *s, gbAllocator a, isize capacity) { +gb_internal void ptr_set_init(PtrSet *s, isize capacity) { + GB_ASSERT(s->keys == nullptr); if (capacity != 0) { capacity = next_pow2_isize(gb_max(16, capacity)); + s->keys = gb_alloc_array(ptr_set_allocator(), T, capacity); + // This memory will be zeroed, no need to explicitly zero it } - - slice_init(&s->hashes, a, capacity); - array_init(&s->entries, a, 0, capacity); - for (isize i = 0; i < capacity; i++) { - s->hashes.data[i] = MAP_SENTINEL; - } + s->count = 0; + s->capacity = capacity; } template -void ptr_set_destroy(PtrSet *s) { - slice_free(&s->hashes, s->entries.allocator); - array_free(&s->entries); +gb_internal void ptr_set_destroy(PtrSet *s) { + gb_free(ptr_set_allocator(), s->keys); + s->keys = nullptr; + s->count = 0; + s->capacity = 0; } template -gb_internal MapIndex ptr_set__add_entry(PtrSet *s, T ptr) { - PtrSetEntry e = {}; - e.ptr = ptr; - e.next = MAP_SENTINEL; - array_add(&s->entries, e); - return cast(MapIndex)(s->entries.count-1); -} - - -template -gb_internal MapFindResult ptr_set__find(PtrSet *s, T ptr) { - MapFindResult fr = {MAP_SENTINEL, MAP_SENTINEL, MAP_SENTINEL}; - if (s->hashes.count != 0) { +gb_internal isize ptr_set__find(PtrSet *s, T ptr) { + GB_ASSERT(ptr != nullptr); + if (s->count != 0) { + #if 0 + for (usize i = 0; i < s->capacity; i++) { + if (s->keys[i] == ptr) { + return i; + } + } + #else u32 hash = ptr_map_hash_key(ptr); - fr.hash_index = cast(MapIndex)(hash & (s->hashes.count-1)); - fr.entry_index = s->hashes.data[fr.hash_index]; - while (fr.entry_index != MAP_SENTINEL) { - if (s->entries.data[fr.entry_index].ptr == ptr) { - return fr; + usize mask = s->capacity-1; + usize hash_index = cast(usize)hash & mask; + for (usize i = 0; i < s->capacity; i++) { + T key = s->keys[hash_index]; + if (key == ptr) { + return hash_index; + } else if (key == nullptr) { + return -1; } - fr.entry_prev = fr.entry_index; - fr.entry_index = s->entries.data[fr.entry_index].next; + hash_index = (hash_index+1)&mask; } - } - return fr; -} - -template -gb_internal MapFindResult ptr_set__find_from_entry(PtrSet *s, PtrSetEntry *e) { - MapFindResult fr = {MAP_SENTINEL, MAP_SENTINEL, MAP_SENTINEL}; - if (s->hashes.count != 0) { - u32 hash = ptr_map_hash_key(e->ptr); - fr.hash_index = cast(MapIndex)(hash & (s->hashes.count-1)); - fr.entry_index = s->hashes.data[fr.hash_index]; - while (fr.entry_index != MAP_SENTINEL) { - if (&s->entries.data[fr.entry_index] == e) { - return fr; - } - fr.entry_prev = fr.entry_index; - fr.entry_index = s->entries.data[fr.entry_index].next; - } - } - return fr; -} - -template -gb_internal bool ptr_set__full(PtrSet *s) { - return 0.75f * s->hashes.count <= s->entries.count; -} - -template -gb_inline void ptr_set_grow(PtrSet *s) { - isize new_count = gb_max(s->hashes.count<<1, 16); - ptr_set_rehash(s, new_count); -} - -template -void ptr_set_reset_entries(PtrSet *s) { - for (isize i = 0; i < s->hashes.count; i++) { - s->hashes.data[i] = MAP_SENTINEL; - } - for (isize i = 0; i < s->entries.count; i++) { - MapFindResult fr; - PtrSetEntry *e = &s->entries.data[i]; - e->next = MAP_SENTINEL; - fr = ptr_set__find_from_entry(s, e); - if (fr.entry_prev == MAP_SENTINEL) { - s->hashes[fr.hash_index] = cast(MapIndex)i; - } else { - s->entries[fr.entry_prev].next = cast(MapIndex)i; - } - } -} - -template -void ptr_set_reserve(PtrSet *s, isize cap) { - array_reserve(&s->entries, cap); - if (s->entries.count*2 < s->hashes.count) { - return; - } - slice_resize(&s->hashes, s->entries.allocator, cap*2); - ptr_set_reset_entries(s); -} - - -template -void ptr_set_rehash(PtrSet *s, isize new_count) { - ptr_set_reserve(s, new_count); -} - -template -gb_inline bool ptr_set_exists(PtrSet *s, T ptr) { - isize index = ptr_set__find(s, ptr).entry_index; - return index != MAP_SENTINEL; -} - -template -gb_inline isize ptr_entry_index(PtrSet *s, T ptr) { - isize index = ptr_set__find(s, ptr).entry_index; - if (index != MAP_SENTINEL) { - return index; + #endif } return -1; } -// Returns true if it already exists template -T ptr_set_add(PtrSet *s, T ptr) { - MapIndex index; - MapFindResult fr; - if (s->hashes.count == 0) { +gb_internal bool ptr_set__full(PtrSet *s) { + return 0.75f * s->capacity <= s->count; +} + +template +gb_internal gb_inline void ptr_set_grow(PtrSet *old_set) { + if (old_set->capacity == 0) { + ptr_set_init(old_set); + return; + } + + PtrSet new_set = {}; + ptr_set_init(&new_set, gb_max(old_set->capacity<<1, 16)); + + for (T ptr : *old_set) { + bool was_new = ptr_set_update(&new_set, ptr); + GB_ASSERT(!was_new); + } + GB_ASSERT(old_set->count == new_set.count); + + ptr_set_destroy(old_set); + + *old_set = new_set; +} + + +template +gb_internal gb_inline bool ptr_set_exists(PtrSet *s, T ptr) { + return ptr_set__find(s, ptr) >= 0; +} + + +template +gb_internal bool ptr_set_update(PtrSet *s, T ptr) { // returns true if it previously existsed + if (ptr_set_exists(s, ptr)) { + return true; + } + + if (s->keys == nullptr) { + ptr_set_init(s); + } else if (ptr_set__full(s)) { ptr_set_grow(s); } - fr = ptr_set__find(s, ptr); - if (fr.entry_index == MAP_SENTINEL) { - index = ptr_set__add_entry(s, ptr); - if (fr.entry_prev != MAP_SENTINEL) { - s->entries.data[fr.entry_prev].next = index; - } else { - s->hashes.data[fr.hash_index] = index; + GB_ASSERT(s->count < s->capacity); + GB_ASSERT(s->capacity >= 0); + + usize mask = s->capacity-1; + u32 hash = ptr_map_hash_key(ptr); + usize hash_index = (cast(usize)hash) & mask; + GB_ASSERT(hash_index < s->capacity); + for (usize i = 0; i < s->capacity; i++) { + T *key = &s->keys[hash_index]; + GB_ASSERT(*key != ptr); + if (*key == (T)PtrSet::TOMBSTONE || *key == nullptr) { + *key = ptr; + s->count++; + return false; } + hash_index = (hash_index+1)&mask; } - if (ptr_set__full(s)) { - ptr_set_grow(s); - } + + GB_PANIC("ptr set out of memory"); + return false; +} + +template +gb_internal T ptr_set_add(PtrSet *s, T ptr) { + ptr_set_update(s, ptr); return ptr; } + template -bool ptr_set_update(PtrSet *s, T ptr) { // returns true if it previously existsed - bool exists = false; - MapIndex index; - MapFindResult fr; - if (s->hashes.count == 0) { - ptr_set_grow(s); +gb_internal void ptr_set_remove(PtrSet *s, T ptr) { + isize index = ptr_set__find(s, ptr); + if (index >= 0) { + GB_ASSERT(s->count > 0); + s->keys[index] = (T)PtrSet::TOMBSTONE; + s->count--; } - fr = ptr_set__find(s, ptr); - if (fr.entry_index != MAP_SENTINEL) { - exists = true; - } else { - index = ptr_set__add_entry(s, ptr); - if (fr.entry_prev != MAP_SENTINEL) { - s->entries.data[fr.entry_prev].next = index; - } else { - s->hashes.data[fr.hash_index] = index; +} + +template +gb_internal gb_inline void ptr_set_clear(PtrSet *s) { + s->count = 0; + gb_zero_size(s->keys, s->capacity*gb_size_of(T)); +} + +template +struct PtrSetIterator { + PtrSet *set; + usize index; + + PtrSetIterator &operator++() noexcept { + for (;;) { + ++index; + if (set->capacity == index) { + return *this; + } + T key = set->keys[index]; + if (key != nullptr && key != (T)PtrSet::TOMBSTONE) { + return *this; + } } } - if (ptr_set__full(s)) { - ptr_set_grow(s); - } - return exists; -} + bool operator==(PtrSetIterator const &other) const noexcept { + return this->set == other.set && this->index == other.index; + } + + + operator T *() const { + return &set->keys[index]; + } +}; template -void ptr_set__erase(PtrSet *s, MapFindResult fr) { - MapFindResult last; - if (fr.entry_prev == MAP_SENTINEL) { - s->hashes.data[fr.hash_index] = s->entries.data[fr.entry_index].next; - } else { - s->entries.data[fr.entry_prev].next = s->entries.data[fr.entry_index].next; - } - if (cast(isize)fr.entry_index == s->entries.count-1) { - array_pop(&s->entries); - return; - } - s->entries.data[fr.entry_index] = s->entries.data[s->entries.count-1]; - last = ptr_set__find(s, s->entries.data[fr.entry_index].ptr); - if (last.entry_prev != MAP_SENTINEL) { - s->entries.data[last.entry_prev].next = fr.entry_index; - } else { - s->hashes.data[last.hash_index] = fr.entry_index; +gb_internal PtrSetIterator begin(PtrSet &set) noexcept { + usize index = 0; + while (index < set.capacity) { + T key = set.keys[index]; + if (key != nullptr && key != (T)PtrSet::TOMBSTONE) { + break; + } + index++; } + return PtrSetIterator{&set, index}; } - template -void ptr_set_remove(PtrSet *s, T ptr) { - MapFindResult fr = ptr_set__find(s, ptr); - if (fr.entry_index != MAP_SENTINEL) { - ptr_set__erase(s, fr); - } -} - -template -gb_inline void ptr_set_clear(PtrSet *s) { - array_clear(&s->entries); - for (isize i = 0; i < s->hashes.count; i++) { - s->hashes.data[i] = MAP_SENTINEL; - } -} +gb_internal PtrSetIterator end(PtrSet &set) noexcept { + return PtrSetIterator{&set, set.capacity}; +} \ No newline at end of file diff --git a/src/query_data.cpp b/src/query_data.cpp deleted file mode 100644 index 71c21f2ba..000000000 --- a/src/query_data.cpp +++ /dev/null @@ -1,1030 +0,0 @@ -struct QueryValue; -struct QueryValuePair; - -gbAllocator query_value_allocator = {}; - -enum QueryKind { - Query_Invalid, - Query_String, - Query_Boolean, - Query_Integer, - Query_Float, - Query_Array, - Query_Map, -}; - -struct QueryValuePair { - String key; - QueryValue *value; -}; - - -struct QueryValue { - QueryKind kind; - bool packed; -}; - -struct QueryValueString : QueryValue { - QueryValueString(String const &v) { - kind = Query_String; - value = v; - packed = false; - } - String value; -}; - -struct QueryValueBoolean : QueryValue { - QueryValueBoolean(bool v) { - kind = Query_Boolean; - value = v; - packed = false; - } - bool value; -}; - -struct QueryValueInteger : QueryValue { - QueryValueInteger(i64 v) { - kind = Query_Integer; - value = v; - packed = false; - } - i64 value; -}; - -struct QueryValueFloat : QueryValue { - QueryValueFloat(f64 v) { - kind = Query_Float; - value = v; - packed = false; - } - f64 value; -}; - -struct QueryValueArray : QueryValue { - QueryValueArray() { - kind = Query_Array; - array_init(&value, query_value_allocator); - packed = false; - } - QueryValueArray(Array const &v) { - kind = Query_Array; - value = v; - packed = false; - } - Array value; - - void reserve(isize cap) { - array_reserve(&value, cap); - } - void add(QueryValue *v) { - array_add(&value, v); - } - void add(char const *v) { - add(make_string_c(cast(char *)v)); - } - void add(String const &v) { - auto val = gb_alloc_item(query_value_allocator, QueryValueString); - *val = QueryValueString(v); - add(val); - } - void add(bool v) { - auto val = gb_alloc_item(query_value_allocator, QueryValueBoolean); - *val = QueryValueBoolean(v); - add(val); - } - void add(i64 v) { - auto val = gb_alloc_item(query_value_allocator, QueryValueInteger); - *val = QueryValueInteger(v); - add(val); - } - void add(f64 v) { - auto val = gb_alloc_item(query_value_allocator, QueryValueFloat); - *val = QueryValueFloat(v); - add(val); - } -}; - -struct QueryValueMap : QueryValue { - QueryValueMap() { - kind = Query_Map; - array_init(&value, query_value_allocator); - packed = false; - } - QueryValueMap(Array const &v) { - kind = Query_Map; - value = v; - packed = false; - } - Array value; - - - void reserve(isize cap) { - array_reserve(&value, cap); - } - void add(char const *k, QueryValue *v) { - add(make_string_c(cast(char *)k), v); - } - void add(String const &k, QueryValue *v) { - QueryValuePair kv = {k, v}; - array_add(&value, kv); - } - - void add(char const *k, String const &v) { - auto val = gb_alloc_item(query_value_allocator, QueryValueString); - *val = QueryValueString(v); - add(k, val); - } - void add(char const *k, char const *v) { - add(k, make_string_c(cast(char *)v)); - } - void add(char const *k, bool v) { - auto val = gb_alloc_item(query_value_allocator, QueryValueBoolean); - *val = QueryValueBoolean(v); - add(k, val); - } - void add(char const *k, i64 v) { - auto val = gb_alloc_item(query_value_allocator, QueryValueInteger); - *val = QueryValueInteger(v); - add(k, val); - } - void add(char const *k, f64 v) { - auto val = gb_alloc_item(query_value_allocator, QueryValueFloat); - *val = QueryValueFloat(v); - add(k, val); - } - void add(String const &k, String const &v) { - auto val = gb_alloc_item(query_value_allocator, QueryValueString); - *val = QueryValueString(v); - add(k, val); - } - void add(String const &k, char const *v) { - add(k, make_string_c(cast(char *)v)); - } - void add(String const &k, bool v) { - auto val = gb_alloc_item(query_value_allocator, QueryValueBoolean); - *val = QueryValueBoolean(v); - add(k, val); - } - void add(String const &k, i64 v) { - auto val = gb_alloc_item(query_value_allocator, QueryValueInteger); - *val = QueryValueInteger(v); - add(k, val); - } - void add(String const &k, f64 v) { - auto val = gb_alloc_item(query_value_allocator, QueryValueFloat); - *val = QueryValueFloat(v); - add(k, val); - } -}; - - -#define DEF_QUERY_PROC(TYPE, VALUETYPE, NAME) TYPE *NAME(VALUETYPE value) { \ - auto v = gb_alloc_item(query_value_allocator, TYPE); \ - *v = TYPE(value); \ - return v; \ -} -#define DEF_QUERY_PROC0(TYPE, NAME) TYPE *NAME() { \ - auto v = gb_alloc_item(query_value_allocator, TYPE); \ - *v = TYPE(); \ - return v; \ -} - -DEF_QUERY_PROC(QueryValueString, String const &, query_value_string); -DEF_QUERY_PROC(QueryValueBoolean, bool, query_value_boolean); -DEF_QUERY_PROC(QueryValueInteger, i64, query_value_integer); -DEF_QUERY_PROC(QueryValueFloat, f64, query_value_float); -DEF_QUERY_PROC(QueryValueArray, Array const &, query_value_array); -DEF_QUERY_PROC(QueryValueMap, Array const &, query_value_map); -DEF_QUERY_PROC0(QueryValueArray, query_value_array); -DEF_QUERY_PROC0(QueryValueMap, query_value_map); - -isize qprintf(bool format, isize indent, char const *fmt, ...) { - if (format) while (indent --> 0) { - gb_printf("\t"); - } - va_list va; - va_start(va, fmt); - isize res = gb_printf_va(fmt, va); - va_end(va); - return res; -} - -bool qv_valid_char(u8 c) { - if (c >= 0x80) { - return false; - } - - switch (c) { - case '\"': - case '\n': - case '\r': - case '\t': - case '\v': - case '\f': - return false; - } - - return true; -} - -void print_query_data_as_json(QueryValue *value, bool format = true, isize indent = 0) { - if (value == nullptr) { - gb_printf("null"); - return; - } - switch (value->kind) { - case Query_String: { - auto v = cast(QueryValueString *)value; - String name = v->value; - isize extra = 0; - for (isize i = 0; i < name.len; i++) { - u8 c = name[i]; - if (!qv_valid_char(c)) { - extra += 5; - } - } - - if (extra == 0) { - gb_printf("\"%.*s\"", LIT(name)); - return; - } - - char const hex_table[] = "0123456789ABCDEF"; - isize buf_len = name.len + extra + 2 + 1; - - u8 *buf = gb_alloc_array(temporary_allocator(), u8, buf_len); - - isize j = 0; - - for (isize i = 0; i < name.len; i++) { - u8 c = name[i]; - if (qv_valid_char(c)) { - buf[j+0] = c; - j += 1; - } else if (c == '"') { - buf[j+0] = '\\'; - buf[j+1] = '\"'; - j += 2; - } else { - switch (c) { - case '\n': buf[j+0] = '\\'; buf[j+1] = 'n'; j += 2; break; - case '\r': buf[j+0] = '\\'; buf[j+1] = 'r'; j += 2; break; - case '\t': buf[j+0] = '\\'; buf[j+1] = 't'; j += 2; break; - case '\v': buf[j+0] = '\\'; buf[j+1] = 'v'; j += 2; break; - case '\f': - default: - buf[j+0] = '\\'; - buf[j+1] = hex_table[0]; - buf[j+2] = hex_table[0]; - buf[j+3] = hex_table[c >> 4]; - buf[j+4] = hex_table[c & 0x0f]; - j += 5; - break; - } - } - } - - gb_printf("\"%s\"", buf); - return; - } - case Query_Boolean: { - auto v = cast(QueryValueBoolean *)value; - if (v->value) { - gb_printf("true"); - } else { - gb_printf("false"); - } - return; - } - case Query_Integer: { - auto v = cast(QueryValueInteger *)value; - gb_printf("%lld", cast(long long)v->value); - return; - } - case Query_Float: { - auto v = cast(QueryValueFloat *)value; - gb_printf("%f", v->value); - return; - } - case Query_Array: { - auto v = cast(QueryValueArray *)value; - if (v->value.count > 0) { - bool ff = format && !v->packed; - gb_printf("["); - if (ff) gb_printf("\n"); - for_array(i, v->value) { - qprintf(ff, indent+1, ""); - print_query_data_as_json(v->value[i], ff, indent+1); - if (i < v->value.count-1) { - gb_printf(","); - if (!ff && format) { - gb_printf(" "); - } - } - if (ff) gb_printf("\n"); - } - qprintf(ff, indent, "]"); - } else { - gb_printf("[]"); - } - return; - } - case Query_Map: { - auto v = cast(QueryValueMap *)value; - if (v->value.count > 0) { - bool ff = format && !v->packed; - gb_printf("{"); - if (ff) gb_printf("\n"); - for_array(i, v->value) { - auto kv = v->value[i]; - qprintf(ff, indent+1, "\"%.*s\":", LIT(kv.key)); - if (format) gb_printf(" "); - print_query_data_as_json(kv.value, ff, indent+1); - if (i < v->value.count-1) { - gb_printf(","); - if (!ff && format) { - gb_printf(" "); - } - } - if (ff) gb_printf("\n"); - } - qprintf(ff, indent, "}"); - } else { - gb_printf("{}"); - } - return; - } - } -} - - - -int query_data_package_compare(void const *a, void const *b) { - AstPackage *x = *cast(AstPackage *const *)a; - AstPackage *y = *cast(AstPackage *const *)b; - - if (x == y) { - return 0; - } - - if (x != nullptr && y != nullptr) { - return string_compare(x->name, y->name); - } else if (x != nullptr && y == nullptr) { - return -1; - } else if (x == nullptr && y != nullptr) { - return +1; - } - return 0; -} - -int query_data_definition_compare(void const *a, void const *b) { - Entity *x = *cast(Entity *const *)a; - Entity *y = *cast(Entity *const *)b; - - if (x == y) { - return 0; - } else if (x != nullptr && y == nullptr) { - return -1; - } else if (x == nullptr && y != nullptr) { - return +1; - } - - if (x->pkg != y->pkg) { - i32 res = query_data_package_compare(&x->pkg, &y->pkg); - if (res != 0) { - return res; - } - } - - return string_compare(x->token.string, y->token.string); -} - -int entity_name_compare(void const *a, void const *b) { - Entity *x = *cast(Entity *const *)a; - Entity *y = *cast(Entity *const *)b; - if (x == y) { - return 0; - } else if (x != nullptr && y == nullptr) { - return -1; - } else if (x == nullptr && y != nullptr) { - return +1; - } - return string_compare(x->token.string, y->token.string); -} - - -void generate_and_print_query_data_global_definitions(Checker *c, Timings *timings); -void generate_and_print_query_data_go_to_definitions(Checker *c); - -void generate_and_print_query_data(Checker *c, Timings *timings) { - query_value_allocator = heap_allocator(); - switch (build_context.query_data_set_settings.kind) { - case QueryDataSet_GlobalDefinitions: - generate_and_print_query_data_global_definitions(c, timings); - return; - case QueryDataSet_GoToDefinitions: - generate_and_print_query_data_go_to_definitions(c); - return; - } -} - - -void generate_and_print_query_data_global_definitions(Checker *c, Timings *timings) { - auto *root = query_value_map(); - - if (global_error_collector.errors.count > 0) { - auto *errors = query_value_array(); - root->add("errors", errors); - for_array(i, global_error_collector.errors) { - String err = string_trim_whitespace(global_error_collector.errors[i]); - errors->add(err); - } - - } - - { // Packages - auto *packages = query_value_array(); - root->add("packages", packages); - - auto sorted_packages = array_make(query_value_allocator, 0, c->info.packages.entries.count); - defer (array_free(&sorted_packages)); - - for_array(i, c->info.packages.entries) { - AstPackage *pkg = c->info.packages.entries[i].value; - if (pkg != nullptr) { - array_add(&sorted_packages, pkg); - } - } - gb_sort_array(sorted_packages.data, sorted_packages.count, query_data_package_compare); - packages->reserve(sorted_packages.count); - - for_array(i, sorted_packages) { - AstPackage *pkg = sorted_packages[i]; - String name = pkg->name; - String fullpath = pkg->fullpath; - - auto *files = query_value_array(); - files->reserve(pkg->files.count); - for_array(j, pkg->files) { - AstFile *f = pkg->files[j]; - files->add(f->fullpath); - } - - auto *package = query_value_map(); - package->reserve(3); - packages->add(package); - - package->add("name", pkg->name); - package->add("fullpath", pkg->fullpath); - package->add("files", files); - } - } - - if (c->info.definitions.count > 0) { - auto *definitions = query_value_array(); - root->add("definitions", definitions); - - auto sorted_definitions = array_make(query_value_allocator, 0, c->info.definitions.count); - defer (array_free(&sorted_definitions)); - - for_array(i, c->info.definitions) { - Entity *e = c->info.definitions[i]; - String name = e->token.string; - if (is_blank_ident(name)) { - continue; - } - if ((e->scope->flags & (ScopeFlag_Pkg|ScopeFlag_File)) == 0) { - continue; - } - if (e->parent_proc_decl != nullptr) { - continue; - } - switch (e->kind) { - case Entity_Builtin: - case Entity_Nil: - case Entity_Label: - continue; - } - if (e->pkg == nullptr) { - continue; - } - if (e->token.pos.line == 0) { - continue; - } - if (e->kind == Entity_Procedure) { - Type *t = base_type(e->type); - if (t->kind != Type_Proc) { - continue; - } - if (t->Proc.is_poly_specialized) { - continue; - } - } - if (e->kind == Entity_TypeName) { - Type *t = base_type(e->type); - if (t->kind == Type_Struct) { - if (t->Struct.is_poly_specialized) { - continue; - } - } - if (t->kind == Type_Union) { - if (t->Union.is_poly_specialized) { - continue; - } - } - } - - array_add(&sorted_definitions, e); - } - - gb_sort_array(sorted_definitions.data, sorted_definitions.count, query_data_definition_compare); - definitions->reserve(sorted_definitions.count); - - for_array(i, sorted_definitions) { - Entity *e = sorted_definitions[i]; - String name = e->token.string; - - auto *def = query_value_map(); - def->reserve(16); - definitions->add(def); - - def->add("package", e->pkg->name); - def->add("name", name); - def->add("filepath", get_file_path_string(e->token.pos.file_id)); - def->add("line", cast(i64)e->token.pos.line); - def->add("column", cast(i64)e->token.pos.column); - def->add("file_offset", cast(i64)e->token.pos.offset); - - switch (e->kind) { - case Entity_Constant: def->add("kind", str_lit("constant")); break; - case Entity_Variable: def->add("kind", str_lit("variable")); break; - case Entity_TypeName: def->add("kind", str_lit("type name")); break; - case Entity_Procedure: def->add("kind", str_lit("procedure")); break; - case Entity_ProcGroup: def->add("kind", str_lit("procedure group")); break; - case Entity_ImportName: def->add("kind", str_lit("import name")); break; - case Entity_LibraryName: def->add("kind", str_lit("library name")); break; - default: GB_PANIC("Invalid entity kind to be added"); - } - - - if (e->type != nullptr && e->type != t_invalid) { - Type *t = e->type; - Type *bt = t; - - switch (e->kind) { - case Entity_TypeName: - if (!e->TypeName.is_type_alias) { - bt = base_type(t); - } - break; - } - - { - gbString str = type_to_string(t); - String type_str = make_string(cast(u8 *)str, gb_string_length(str)); - def->add("type", type_str); - } - if (t != bt) { - gbString str = type_to_string(bt); - String type_str = make_string(cast(u8 *)str, gb_string_length(str)); - def->add("base_type", type_str); - } - { - String type_kind = {}; - Type *bt = base_type(t); - switch (bt->kind) { - case Type_Pointer: type_kind = str_lit("pointer"); break; - case Type_Array: type_kind = str_lit("array"); break; - case Type_Slice: type_kind = str_lit("slice"); break; - case Type_DynamicArray: type_kind = str_lit("dynamic array"); break; - case Type_Map: type_kind = str_lit("map"); break; - case Type_Struct: type_kind = str_lit("struct"); break; - case Type_Union: type_kind = str_lit("union"); break; - case Type_Enum: type_kind = str_lit("enum"); break; - case Type_Proc: type_kind = str_lit("procedure"); break; - case Type_BitSet: type_kind = str_lit("bit set"); break; - case Type_SimdVector: type_kind = str_lit("simd vector"); break; - - case Type_Generic: - case Type_Tuple: - GB_PANIC("Invalid definition type"); - break; - } - if (type_kind.len > 0) { - def->add("type_kind", type_kind); - } - } - } - - if (e->kind == Entity_TypeName) { - def->add("size", type_size_of(e->type)); - def->add("align", type_align_of(e->type)); - - - if (is_type_struct(e->type)) { - auto *data = query_value_map(); - data->reserve(6); - - def->add("data", data); - - Type *t = base_type(e->type); - GB_ASSERT(t->kind == Type_Struct); - - if (t->Struct.is_polymorphic) { - data->add("polymorphic", cast(bool)t->Struct.is_polymorphic); - } - if (t->Struct.is_poly_specialized) { - data->add("polymorphic_specialized", cast(bool)t->Struct.is_poly_specialized); - } - if (t->Struct.is_packed) { - data->add("packed", cast(bool)t->Struct.is_packed); - } - if (t->Struct.is_raw_union) { - data->add("raw_union", cast(bool)t->Struct.is_raw_union); - } - - auto *fields = query_value_array(); - data->add("fields", fields); - fields->reserve(t->Struct.fields.count); - fields->packed = true; - - for_array(j, t->Struct.fields) { - Entity *e = t->Struct.fields[j]; - String name = e->token.string; - if (is_blank_ident(name)) { - continue; - } - - fields->add(name); - } - } else if (is_type_union(e->type)) { - auto *data = query_value_map(); - data->reserve(4); - - def->add("data", data); - Type *t = base_type(e->type); - GB_ASSERT(t->kind == Type_Union); - - if (t->Union.is_polymorphic) { - data->add("polymorphic", cast(bool)t->Union.is_polymorphic); - } - if (t->Union.is_poly_specialized) { - data->add("polymorphic_specialized", cast(bool)t->Union.is_poly_specialized); - } - - auto *variants = query_value_array(); - variants->reserve(t->Union.variants.count); - data->add("variants", variants); - - for_array(j, t->Union.variants) { - Type *vt = t->Union.variants[j]; - - gbString str = type_to_string(vt); - String type_str = make_string(cast(u8 *)str, gb_string_length(str)); - variants->add(type_str); - } - } - } - - if (e->kind == Entity_Procedure) { - Type *t = base_type(e->type); - GB_ASSERT(t->kind == Type_Proc); - - bool is_polymorphic = t->Proc.is_polymorphic; - bool is_poly_specialized = t->Proc.is_poly_specialized; - bool ok = is_polymorphic || is_poly_specialized; - if (ok) { - auto *data = query_value_map(); - data->reserve(4); - - def->add("data", data); - if (is_polymorphic) { - data->add("polymorphic", cast(bool)is_polymorphic); - } - if (is_poly_specialized) { - data->add("polymorphic_specialized", cast(bool)is_poly_specialized); - } - } - } - - if (e->kind == Entity_ProcGroup) { - auto *procedures = query_value_array(); - procedures->reserve(e->ProcGroup.entities.count); - - for_array(j, e->ProcGroup.entities) { - Entity *p = e->ProcGroup.entities[j]; - - auto *procedure = query_value_map(); - procedure->reserve(2); - procedure->packed = true; - - procedures->add(procedure); - - procedure->add("package", p->pkg->name); - procedure->add("name", p->token.string); - } - def->add("procedures", procedures); - } - - DeclInfo *di = e->decl_info; - if (di != nullptr) { - if (di->is_using) { - def->add("using", query_value_boolean(true)); - } - } - } - } - - if (build_context.show_timings) { - Timings *t = timings; - timings__stop_current_section(t); - t->total.finish = time_stamp_time_now(); - isize max_len = gb_min(36, t->total.label.len); - for_array(i, t->sections) { - TimeStamp ts = t->sections[i]; - max_len = gb_max(max_len, ts.label.len); - } - t->total_time_seconds = time_stamp_as_s(t->total, t->freq); - - auto *tims = query_value_map(); - tims->reserve(8); - root->add("timings", tims); - tims->add("time_unit", str_lit("s")); - - tims->add(t->total.label, cast(f64)t->total_time_seconds); - - - Parser *p = c->parser; - if (p != nullptr) { - isize lines = p->total_line_count; - isize tokens = p->total_token_count; - isize files = 0; - isize packages = p->packages.count; - isize total_file_size = 0; - for_array(i, p->packages) { - files += p->packages[i]->files.count; - for_array(j, p->packages[i]->files) { - AstFile *file = p->packages[i]->files[j]; - total_file_size += file->tokenizer.end - file->tokenizer.start; - } - } - - tims->add("total_lines", cast(i64)lines); - tims->add("total_tokens", cast(i64)tokens); - tims->add("total_files", cast(i64)files); - tims->add("total_packages", cast(i64)packages); - tims->add("total_file_size", cast(i64)total_file_size); - - auto *sections = query_value_map(); - sections->reserve(t->sections.count); - tims->add("sections", sections); - for_array(i, t->sections) { - TimeStamp ts = t->sections[i]; - f64 section_time = time_stamp_as_s(ts, t->freq); - - auto *section = query_value_map(); - section->reserve(2); - sections->add(ts.label, section); - section->add("time", cast(f64)section_time); - section->add("total_fraction", cast(f64)(section_time/t->total_time_seconds)); - } - } - } - - - print_query_data_as_json(root, !build_context.query_data_set_settings.compact); - gb_printf("\n"); -} - - - -template -struct BinaryArray { - u32 offset; // Offset in bytes from the top of the file - u32 length; // Number of elements in array of type T -}; - -template -Array binary_array_from_data(BinaryArray ba, void *data) { - Array res = {}; - res.data = cast(T *)(cast(u8 *)data + ba.offset); - res.count = ba.length; - res.capacity = ba.length; - return res; -} - -typedef BinaryArray BinaryString; - -struct GoToDefIdent { - u64 use_offset; // offset of identifier use in bytes from the start of the file that contains it - u32 len; // length in bytes of the identifier - u32 def_file_id; - u64 def_offset; // offset of entity definition in bytes from the start of the file that contains it -}; - -struct GoToDefFile { - u32 id; - BinaryString path; - BinaryArray idents; -}; - -struct GoToDefHeader { - u8 magic[4]; // ogtd (odin-go-to-definitions) - u32 version; // 1 - BinaryArray files; -}; - -struct GoToDefFileMap { - AstFile *f; - u32 id; - Array idents; -}; - - -int go_to_def_file_map_compare(void const *a, void const *b) { - GoToDefFileMap const *x = cast(GoToDefFileMap const *)a; - GoToDefFileMap const *y = cast(GoToDefFileMap const *)b; - if (x == y) { - return 0; - } else if (x != nullptr && y == nullptr) { - return -1; - } else if (x == nullptr && y != nullptr) { - return +1; - } - if (x->f->id < y->f->id) { - return -1; - } else if (x->f->id > y->f->id) { - return +1; - } - return 0; -} - -int quick_ident_compare(void const *a, void const *b) { - Ast *x = *cast(Ast **)a; - Ast *y = *cast(Ast **)b; - - // NOTE(bill): This assumes that the file is same - if (x->Ident.token.pos.offset < y->Ident.token.pos.offset) { - return -1; - } else if (x->Ident.token.pos.offset > y->Ident.token.pos.offset) { - return +1; - } - return 0; -} - - -void generate_and_print_query_data_go_to_definitions(Checker *c) { - GB_ASSERT(c->info.allow_identifier_uses); - - gbAllocator a = query_value_allocator; - - isize file_path_memory_needed = 0; - auto files = array_make(a, 0, c->info.files.entries.count); - for_array(i, c->info.files.entries) { - AstFile *f = c->info.files.entries[i].value; - file_path_memory_needed += f->fullpath.len+1; // add NUL terminator - - - GoToDefFileMap x = {}; - x.f = f; - array_init(&x.idents, a); - array_add(&files, x); - } - gb_sort_array(files.data, files.count, go_to_def_file_map_compare); - - auto file_id_map_to_index = array_make(a, files[files.count-1].f->id + 1); - for_array(i, file_id_map_to_index) { - file_id_map_to_index[i] = -1; - } - for_array(i, files) { - file_id_map_to_index[files[i].f->id] = i; - } - - - - for_array(i, c->info.identifier_uses) { - Ast *ast = c->info.identifier_uses[i]; - GB_ASSERT(ast->kind == Ast_Ident); - TokenPos pos = ast->Ident.token.pos; - Entity *e = ast->Ident.entity; - if (e == nullptr) { - continue; - } - - - AstFile **use_file_found = string_map_get(&c->info.files, get_file_path_string(pos.file_id)); - GB_ASSERT(use_file_found != nullptr); - AstFile *use_file = *use_file_found; - GB_ASSERT(use_file != nullptr); - - if (e->scope == nullptr) { - GB_ASSERT(e->flags & EntityFlag_Field); - continue; - } - if (e->scope->flags & ScopeFlag_Global) { - continue; - } - - isize idx = file_id_map_to_index[use_file->id]; - if (idx >= 0) { - array_add(&files[idx].idents, ast); - } else { - // TODO(bill): Handle invalid map case? - } - } - - for_array(i, files) { - GoToDefFileMap *f = &files[i]; - gb_sort_array(f->idents.data, f->idents.count, quick_ident_compare); - // gb_printf_err("%lld %.*s -> %lld\n", f->f->id, LIT(f->f->fullpath), f->idents.count); - } - - - - isize data_min_size = 0; - - u32 header_offset = cast(u32)data_min_size; gb_unused(header_offset); - data_min_size += gb_size_of(GoToDefHeader); - data_min_size = align_formula_isize(data_min_size, 8); - - u32 file_offset = cast(u32)data_min_size; - data_min_size += gb_size_of(GoToDefFile) * files.count; - data_min_size = align_formula_isize(data_min_size, 8); - - u32 file_path_offset = cast(u32)data_min_size; - data_min_size += file_path_memory_needed; - data_min_size = align_formula_isize(data_min_size, 8); - - u32 idents_offset = cast(u32)data_min_size; - data_min_size += gb_size_of(GoToDefIdent) * c->info.identifier_uses.count; - - - auto data = array_make(a, 0, data_min_size); - defer (array_free(&data)); - - GoToDefHeader header = {}; - gb_memmove(header.magic, "ogtd", 4); - header.version = 1; - header.files.length = cast(u32)files.count; - header.files.offset = file_offset; - - array_add_elems(&data, cast(u8 *)&header, gb_size_of(header)); - - array_resize(&data, data_min_size); - - auto binary_files = binary_array_from_data(header.files, data.data); - - u32 file_path_offset_index = file_path_offset; - u32 idents_offset_index = idents_offset; - for_array(i, files) { - GoToDefFileMap *f_map = &files[i]; - AstFile *f = f_map->f; - binary_files[i].id = cast(u32)f->id; - - binary_files[i].path.offset = file_path_offset_index; - binary_files[i].path.length = cast(u32)f->fullpath.len; - - binary_files[i].idents.offset = idents_offset_index; - binary_files[i].idents.length = cast(u32)f_map->idents.count; - - auto path = binary_array_from_data(binary_files[i].path, data.data); - gb_memmove(path.data, f->fullpath.text, f->fullpath.len); - path.data[f->fullpath.len] = 0; - - - auto idents = binary_array_from_data(binary_files[i].idents, data.data); - for_array(j, f_map->idents) { - Ast *ast = f_map->idents[j]; - GB_ASSERT(ast->kind == Ast_Ident); - - Entity *e = ast->Ident.entity; - TokenPos def = e->token.pos; - AstFile *def_file = e->file; - - if (def_file == nullptr) { - auto *def_file_found = string_map_get(&c->info.files, get_file_path_string(e->token.pos.file_id)); - if (def_file_found == nullptr) { - continue; - } - def_file = *def_file_found; - } - - isize file_index = file_id_map_to_index[def_file->id]; - GB_ASSERT(file_index >= 0); - - idents[j].use_offset = cast(u64)ast->Ident.token.pos.offset; - idents[j].len = cast(u32)ast->Ident.token.string.len; - idents[j].def_file_id = cast(u32)def_file->id; - idents[j].def_offset = cast(u64)e->token.pos.offset; - - // gb_printf_err("%llu %llu %llu %llu\n", idents[j].len, idents[j].use_offset, idents[j].def_file_id, idents[j].def_offset); - } - - file_path_offset_index += cast(u32)(f->fullpath.len + 1); - idents_offset_index += cast(u32)(f_map->idents.count * gb_size_of(GoToDefIdent)); - } - - - gb_file_write(gb_file_get_standard(gbFileStandard_Output), data.data, data.count*gb_size_of(*data.data)); -} - diff --git a/src/queue.cpp b/src/queue.cpp index ee8b1b086..2ad9cb29f 100644 --- a/src/queue.cpp +++ b/src/queue.cpp @@ -1,3 +1,86 @@ +template +struct MPSCNode { + std::atomic *> next; + T value; +}; + +// +// Multiple Producer Single Consumer Lockless Queue +// URL: https://www.1024cores.net +// +template +struct MPSCQueue { + MPSCNode sentinel; + std::atomic *> head; + std::atomic *> tail; + std::atomic count; +}; + +template gb_internal void mpsc_init (MPSCQueue *q); +template gb_internal void mpsc_destroy(MPSCQueue *q); +template gb_internal isize mpsc_enqueue(MPSCQueue *q, T const &value); +template gb_internal bool mpsc_dequeue(MPSCQueue *q, T *value_); + +template +gb_internal void mpsc_init(MPSCQueue *q, gbAllocator const &allocator) { + q->sentinel.next.store(nullptr, std::memory_order_relaxed); + q->head.store(&q->sentinel, std::memory_order_relaxed); + q->tail.store(&q->sentinel, std::memory_order_relaxed); + q->count.store(0, std::memory_order_relaxed); +} + +template +gb_internal void mpsc_destroy(MPSCQueue *q) { + GB_ASSERT(q->count.load() == 0); +} + +template +gb_internal MPSCNode *mpsc_alloc_node(MPSCQueue *q, T const &value) { + auto new_node = gb_alloc_item(heap_allocator(), MPSCNode); + new_node->value = value; + return new_node; +} + +template +gb_internal void mpsc_free_node(MPSCQueue *q, MPSCNode *node) { + // TODO(bill): determine a good way to handle the freed nodes rather than letting them leak +} + +template +gb_internal isize mpsc_enqueue(MPSCQueue *q, MPSCNode *node) { + node->next.store(nullptr, std::memory_order_relaxed); + auto prev = q->head.exchange(node, std::memory_order_acq_rel); + prev->next.store(node, std::memory_order_release); + isize count = 1 + q->count.fetch_add(1, std::memory_order_relaxed); + return count; +} + +template +gb_internal isize mpsc_enqueue(MPSCQueue *q, T const &value) { + auto node = mpsc_alloc_node(q, value); + return mpsc_enqueue(q, node); +} + + +template +gb_internal bool mpsc_dequeue(MPSCQueue *q, T *value_) { + auto tail = q->tail.load(std::memory_order_relaxed); + auto next = tail->next.load(std::memory_order_relaxed); + if (next) { + q->tail.store(next, std::memory_order_relaxed); + if (value_) *value_ = next->value; + q->count.fetch_sub(1, std::memory_order_relaxed); + mpsc_free_node(q, tail); + return true; + } + GB_ASSERT(q->count.load(std::memory_order_acquire) == 0); + return false; +} + +//////////////////////////// + + + #define MPMC_CACHE_LINE_SIZE 64 typedef std::atomic MPMCQueueAtomicIdx; @@ -9,7 +92,6 @@ struct MPMCQueue { T * nodes; MPMCQueueAtomicIdx *indices; - gbAllocator allocator; BlockingMutex mutex; MPMCQueueAtomicIdx count; i32 mask; // capacity-1, because capacity must be a power of 2 @@ -22,8 +104,11 @@ struct MPMCQueue { }; +gb_internal gbAllocator mpmc_allocator(void) { + return heap_allocator(); +} -void mpmc_internal_init_indices(MPMCQueueAtomicIdx *indices, i32 offset, i32 size) { +gb_internal void mpmc_internal_init_indices(MPMCQueueAtomicIdx *indices, i32 offset, i32 size) { GB_ASSERT(offset % 8 == 0); GB_ASSERT(size % 8 == 0); @@ -43,7 +128,7 @@ void mpmc_internal_init_indices(MPMCQueueAtomicIdx *indices, i32 offset, i32 siz template -void mpmc_init(MPMCQueue *q, gbAllocator a, isize size_i) { +gb_internal void mpmc_init(MPMCQueue *q, isize size_i) { if (size_i < 8) { size_i = 8; } @@ -52,9 +137,8 @@ void mpmc_init(MPMCQueue *q, gbAllocator a, isize size_i) { size = next_pow2(size); GB_ASSERT(gb_is_power_of_two(size)); - mutex_init(&q->mutex); q->mask = size-1; - q->allocator = a; + gbAllocator a = mpmc_allocator(); q->nodes = gb_alloc_array(a, T, size); q->indices = gb_alloc_array(a, MPMCQueueAtomicIdx, size); @@ -64,25 +148,26 @@ void mpmc_init(MPMCQueue *q, gbAllocator a, isize size_i) { template -void mpmc_destroy(MPMCQueue *q) { - mutex_destroy(&q->mutex); - gb_free(q->allocator, q->nodes); - gb_free(q->allocator, q->indices); +gb_internal void mpmc_destroy(MPMCQueue *q) { + gbAllocator a = mpmc_allocator(); + gb_free(a, q->nodes); + gb_free(a, q->indices); } template -bool mpmc_internal_grow(MPMCQueue *q) { +gb_internal bool mpmc_internal_grow(MPMCQueue *q) { + gbAllocator a = mpmc_allocator(); mutex_lock(&q->mutex); i32 old_size = q->mask+1; i32 new_size = old_size*2; - resize_array_raw(&q->nodes, q->allocator, old_size, new_size); + resize_array_raw(&q->nodes, a, old_size, new_size); if (q->nodes == nullptr) { GB_PANIC("Unable to resize enqueue: %td -> %td", old_size, new_size); mutex_unlock(&q->mutex); return false; } - resize_array_raw(&q->indices, q->allocator, old_size, new_size); + resize_array_raw(&q->indices, a, old_size, new_size); if (q->indices == nullptr) { GB_PANIC("Unable to resize enqueue: %td -> %td", old_size, new_size); mutex_unlock(&q->mutex); @@ -95,7 +180,7 @@ bool mpmc_internal_grow(MPMCQueue *q) { } template -i32 mpmc_enqueue(MPMCQueue *q, T const &data) { +gb_internal i32 mpmc_enqueue(MPMCQueue *q, T const &data) { GB_ASSERT(q->mask != 0); i32 head_idx = q->head_idx.load(std::memory_order_relaxed); @@ -125,7 +210,7 @@ i32 mpmc_enqueue(MPMCQueue *q, T const &data) { } template -bool mpmc_dequeue(MPMCQueue *q, T *data_) { +gb_internal bool mpmc_dequeue(MPMCQueue *q, T *data_) { if (q->mask == 0) { return false; } diff --git a/src/range_cache.cpp b/src/range_cache.cpp index 9701fb432..fc85e2a2e 100644 --- a/src/range_cache.cpp +++ b/src/range_cache.cpp @@ -10,17 +10,17 @@ struct RangeCache { }; -RangeCache range_cache_make(gbAllocator a) { +gb_internal RangeCache range_cache_make(gbAllocator a) { RangeCache cache = {}; array_init(&cache.ranges, a); return cache; } -void range_cache_destroy(RangeCache *c) { +gb_internal void range_cache_destroy(RangeCache *c) { array_free(&c->ranges); } -bool range_cache_add_index(RangeCache *c, i64 index) { +gb_internal bool range_cache_add_index(RangeCache *c, i64 index) { for_array(i, c->ranges) { RangeValue v = c->ranges[i]; if (v.lo <= index && index <= v.hi) { @@ -33,7 +33,7 @@ bool range_cache_add_index(RangeCache *c, i64 index) { } -bool range_cache_add_range(RangeCache *c, i64 lo, i64 hi) { +gb_internal bool range_cache_add_range(RangeCache *c, i64 lo, i64 hi) { GB_ASSERT(lo <= hi); for_array(i, c->ranges) { RangeValue v = c->ranges[i]; @@ -59,12 +59,12 @@ bool range_cache_add_range(RangeCache *c, i64 lo, i64 hi) { } -bool range_cache_index_exists(RangeCache *c, i64 index) { - for_array(i, c->ranges) { - RangeValue v = c->ranges[i]; - if (v.lo <= index && index <= v.hi) { - return true; - } - } - return false; -} +// gb_internal bool range_cache_index_exists(RangeCache *c, i64 index) { +// for_array(i, c->ranges) { +// RangeValue v = c->ranges[i]; +// if (v.lo <= index && index <= v.hi) { +// return true; +// } +// } +// return false; +// } diff --git a/src/string.cpp b/src/string.cpp index bc55e370c..6eac4f53b 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -1,10 +1,5 @@ gb_global BlockingMutex string_buffer_mutex = {}; -void init_string_buffer_memory(void) { - mutex_init(&string_buffer_mutex); -} - - // NOTE(bill): Used for UTF-8 strings struct String { u8 * text; @@ -36,7 +31,7 @@ struct String16 { }; -gb_inline String make_string(u8 const *text, isize len) { +gb_internal gb_inline String make_string(u8 const *text, isize len) { String s; s.text = cast(u8 *)text; if (len < 0) { @@ -47,14 +42,14 @@ gb_inline String make_string(u8 const *text, isize len) { } -gb_inline String16 make_string16(wchar_t const *text, isize len) { +gb_internal gb_inline String16 make_string16(wchar_t const *text, isize len) { String16 s; s.text = cast(wchar_t *)text; s.len = len; return s; } -isize string16_len(wchar_t const *s) { +gb_internal isize string16_len(wchar_t const *s) { if (s == nullptr) { return 0; } @@ -66,15 +61,15 @@ isize string16_len(wchar_t const *s) { } -gb_inline String make_string_c(char const *text) { +gb_internal gb_inline String make_string_c(char const *text) { return make_string(cast(u8 *)cast(void *)text, gb_strlen(text)); } -gb_inline String16 make_string16_c(wchar_t const *text) { +gb_internal gb_inline String16 make_string16_c(wchar_t const *text) { return make_string16(text, string16_len(text)); } -String substring(String const &s, isize lo, isize hi) { +gb_internal String substring(String const &s, isize lo, isize hi) { isize max = s.len; GB_ASSERT_MSG(lo <= hi && hi <= max, "%td..%td..%td", lo, hi, max); @@ -82,24 +77,16 @@ String substring(String const &s, isize lo, isize hi) { } -char *alloc_cstring(gbAllocator a, String s) { +gb_internal char *alloc_cstring(gbAllocator a, String s) { char *c_str = gb_alloc_array(a, char, s.len+1); gb_memmove(c_str, s.text, s.len); c_str[s.len] = '\0'; return c_str; } -char *cstring_duplicate(gbAllocator a, char const *s) { - isize len = gb_strlen(s); - char *c_str = gb_alloc_array(a, char, len+1); - gb_memmove(c_str, s, len); - c_str[len] = '\0'; - return c_str; -} - -gb_inline bool str_eq_ignore_case(String const &a, String const &b) { +gb_internal gb_inline bool str_eq_ignore_case(String const &a, String const &b) { if (a.len == b.len) { for (isize i = 0; i < a.len; i++) { char x = cast(char)a[i]; @@ -113,51 +100,32 @@ gb_inline bool str_eq_ignore_case(String const &a, String const &b) { return false; } -void string_to_lower(String *s) { +gb_internal void string_to_lower(String *s) { for (isize i = 0; i < s->len; i++) { s->text[i] = gb_char_to_lower(s->text[i]); } } -int string_compare(String const &x, String const &y) { - if (x.len != y.len || x.text != y.text) { - isize n, fast, offset, curr_block; - isize *la, *lb; - isize pos; - - n = gb_min(x.len, y.len); - - fast = n/gb_size_of(isize) + 1; - offset = (fast-1)*gb_size_of(isize); - curr_block = 0; - if (n <= gb_size_of(isize)) { - fast = 0; - } - - la = cast(isize *)x.text; - lb = cast(isize *)y.text; - - for (; curr_block < fast; curr_block++) { - if (la[curr_block] ^ lb[curr_block]) { - for (pos = curr_block*gb_size_of(isize); pos < n; pos++) { - if (x[pos] ^ y[pos]) { - return cast(int)x[pos] - cast(int)y[pos]; - } - } - } - } - - for (; offset < n; offset++) { - if (x[offset] ^ y[offset]) { - return cast(int)x[offset] - cast(int)y[offset]; - } - } - return cast(int)(x.len - y.len); +gb_internal int string_compare(String const &a, String const &b) { + if (a.text == b.text) { + return cast(int)(a.len - b.len); } - return 0; + if (a.text == nullptr) { + return -1; + } + if (b.text == nullptr) { + return +1; + } + + uintptr n = gb_min(a.len, b.len); + int res = memcmp(a.text, b.text, n); + if (res == 0) { + res = cast(int)(a.len - b.len); + } + return res; } -isize string_index_byte(String const &s, u8 x) { +gb_internal isize string_index_byte(String const &s, u8 x) { for (isize i = 0; i < s.len; i++) { if (s.text[i] == x) { return i; @@ -166,37 +134,31 @@ isize string_index_byte(String const &s, u8 x) { return -1; } -GB_COMPARE_PROC(string_cmp_proc) { - String x = *(String *)a; - String y = *(String *)b; - return string_compare(x, y); -} - -gb_inline bool str_eq(String const &a, String const &b) { +gb_internal gb_inline bool str_eq(String const &a, String const &b) { if (a.len != b.len) return false; return memcmp(a.text, b.text, a.len) == 0; } -gb_inline bool str_ne(String const &a, String const &b) { return !str_eq(a, b); } -gb_inline bool str_lt(String const &a, String const &b) { return string_compare(a, b) < 0; } -gb_inline bool str_gt(String const &a, String const &b) { return string_compare(a, b) > 0; } -gb_inline bool str_le(String const &a, String const &b) { return string_compare(a, b) <= 0; } -gb_inline bool str_ge(String const &a, String const &b) { return string_compare(a, b) >= 0; } +gb_internal gb_inline bool str_ne(String const &a, String const &b) { return !str_eq(a, b); } +gb_internal gb_inline bool str_lt(String const &a, String const &b) { return string_compare(a, b) < 0; } +gb_internal gb_inline bool str_gt(String const &a, String const &b) { return string_compare(a, b) > 0; } +gb_internal gb_inline bool str_le(String const &a, String const &b) { return string_compare(a, b) <= 0; } +gb_internal gb_inline bool str_ge(String const &a, String const &b) { return string_compare(a, b) >= 0; } -gb_inline bool operator == (String const &a, String const &b) { return str_eq(a, b); } -gb_inline bool operator != (String const &a, String const &b) { return str_ne(a, b); } -gb_inline bool operator < (String const &a, String const &b) { return str_lt(a, b); } -gb_inline bool operator > (String const &a, String const &b) { return str_gt(a, b); } -gb_inline bool operator <= (String const &a, String const &b) { return str_le(a, b); } -gb_inline bool operator >= (String const &a, String const &b) { return str_ge(a, b); } +gb_internal gb_inline bool operator == (String const &a, String const &b) { return str_eq(a, b); } +gb_internal gb_inline bool operator != (String const &a, String const &b) { return str_ne(a, b); } +gb_internal gb_inline bool operator < (String const &a, String const &b) { return str_lt(a, b); } +gb_internal gb_inline bool operator > (String const &a, String const &b) { return str_gt(a, b); } +gb_internal gb_inline bool operator <= (String const &a, String const &b) { return str_le(a, b); } +gb_internal gb_inline bool operator >= (String const &a, String const &b) { return str_ge(a, b); } -template bool operator == (String const &a, char const (&b)[N]) { return str_eq(a, make_string(cast(u8 *)b, N-1)); } -template bool operator != (String const &a, char const (&b)[N]) { return str_ne(a, make_string(cast(u8 *)b, N-1)); } -template bool operator < (String const &a, char const (&b)[N]) { return str_lt(a, make_string(cast(u8 *)b, N-1)); } -template bool operator > (String const &a, char const (&b)[N]) { return str_gt(a, make_string(cast(u8 *)b, N-1)); } -template bool operator <= (String const &a, char const (&b)[N]) { return str_le(a, make_string(cast(u8 *)b, N-1)); } -template bool operator >= (String const &a, char const (&b)[N]) { return str_ge(a, make_string(cast(u8 *)b, N-1)); } +template gb_internal bool operator == (String const &a, char const (&b)[N]) { return str_eq(a, make_string(cast(u8 *)b, N-1)); } +template gb_internal bool operator != (String const &a, char const (&b)[N]) { return str_ne(a, make_string(cast(u8 *)b, N-1)); } +template gb_internal bool operator < (String const &a, char const (&b)[N]) { return str_lt(a, make_string(cast(u8 *)b, N-1)); } +template gb_internal bool operator > (String const &a, char const (&b)[N]) { return str_gt(a, make_string(cast(u8 *)b, N-1)); } +template gb_internal bool operator <= (String const &a, char const (&b)[N]) { return str_le(a, make_string(cast(u8 *)b, N-1)); } +template gb_internal bool operator >= (String const &a, char const (&b)[N]) { return str_ge(a, make_string(cast(u8 *)b, N-1)); } -gb_inline bool string_starts_with(String const &s, String const &prefix) { +gb_internal gb_inline bool string_starts_with(String const &s, String const &prefix) { if (prefix.len > s.len) { return false; } @@ -204,7 +166,7 @@ gb_inline bool string_starts_with(String const &s, String const &prefix) { return substring(s, 0, prefix.len) == prefix; } -gb_inline bool string_ends_with(String const &s, String const &suffix) { +gb_internal gb_inline bool string_ends_with(String const &s, String const &suffix) { if (suffix.len > s.len) { return false; } @@ -212,7 +174,7 @@ gb_inline bool string_ends_with(String const &s, String const &suffix) { return substring(s, s.len-suffix.len, s.len) == suffix; } -gb_inline bool string_starts_with(String const &s, u8 prefix) { +gb_internal gb_inline bool string_starts_with(String const &s, u8 prefix) { if (1 > s.len) { return false; } @@ -221,7 +183,7 @@ gb_inline bool string_starts_with(String const &s, u8 prefix) { } -gb_inline bool string_ends_with(String const &s, u8 suffix) { +gb_internal gb_inline bool string_ends_with(String const &s, u8 suffix) { if (1 > s.len) { return false; } @@ -231,7 +193,7 @@ gb_inline bool string_ends_with(String const &s, u8 suffix) { -gb_inline String string_trim_starts_with(String const &s, String const &prefix) { +gb_internal gb_inline String string_trim_starts_with(String const &s, String const &prefix) { if (string_starts_with(s, prefix)) { return substring(s, prefix.len, s.len); } @@ -239,7 +201,7 @@ gb_inline String string_trim_starts_with(String const &s, String const &prefix) } -gb_inline isize string_extension_position(String const &str) { +gb_internal gb_inline isize string_extension_position(String const &str) { isize dot_pos = -1; isize i = str.len; while (i --> 0) { @@ -254,7 +216,7 @@ gb_inline isize string_extension_position(String const &str) { return dot_pos; } -String path_extension(String const &str, bool include_dot = true) { +gb_internal String path_extension(String const &str, bool include_dot = true) { isize pos = string_extension_position(str); if (pos < 0) { return make_string(nullptr, 0); @@ -262,7 +224,7 @@ String path_extension(String const &str, bool include_dot = true) { return substring(str, include_dot ? pos : pos + 1, str.len); } -String string_trim_whitespace(String str) { +gb_internal String string_trim_whitespace(String str) { while (str.len > 0 && rune_is_whitespace(str[str.len-1])) { str.len--; } @@ -279,7 +241,7 @@ String string_trim_whitespace(String str) { return str; } -bool string_contains_char(String const &s, u8 c) { +gb_internal bool string_contains_char(String const &s, u8 c) { isize i; for (i = 0; i < s.len; i++) { if (s[i] == c) @@ -288,7 +250,7 @@ bool string_contains_char(String const &s, u8 c) { return false; } -String filename_from_path(String s) { +gb_internal String filename_from_path(String s) { isize i = string_extension_position(s); if (i >= 0) { s = substring(s, 0, i); @@ -307,7 +269,7 @@ String filename_from_path(String s) { return make_string(nullptr, 0); } -String concatenate_strings(gbAllocator a, String const &x, String const &y) { +gb_internal String concatenate_strings(gbAllocator a, String const &x, String const &y) { isize len = x.len+y.len; u8 *data = gb_alloc_array(a, u8, len+1); gb_memmove(data, x.text, x.len); @@ -315,7 +277,7 @@ String concatenate_strings(gbAllocator a, String const &x, String const &y) { data[len] = 0; return make_string(data, len); } -String concatenate3_strings(gbAllocator a, String const &x, String const &y, String const &z) { +gb_internal String concatenate3_strings(gbAllocator a, String const &x, String const &y, String const &z) { isize len = x.len+y.len+z.len; u8 *data = gb_alloc_array(a, u8, len+1); gb_memmove(data, x.text, x.len); @@ -324,7 +286,7 @@ String concatenate3_strings(gbAllocator a, String const &x, String const &y, Str data[len] = 0; return make_string(data, len); } -String concatenate4_strings(gbAllocator a, String const &x, String const &y, String const &z, String const &w) { +gb_internal String concatenate4_strings(gbAllocator a, String const &x, String const &y, String const &z, String const &w) { isize len = x.len+y.len+z.len+w.len; u8 *data = gb_alloc_array(a, u8, len+1); gb_memmove(data, x.text, x.len); @@ -335,7 +297,7 @@ String concatenate4_strings(gbAllocator a, String const &x, String const &y, Str return make_string(data, len); } -String string_join_and_quote(gbAllocator a, Array strings) { +gb_internal String string_join_and_quote(gbAllocator a, Array strings) { if (!strings.count) { return make_string(nullptr, 0); } @@ -356,7 +318,7 @@ String string_join_and_quote(gbAllocator a, Array strings) { return make_string(cast(u8 *) s, gb_string_length(s)); } -String copy_string(gbAllocator a, String const &s) { +gb_internal String copy_string(gbAllocator a, String const &s) { u8 *data = gb_alloc_array(a, u8, s.len+1); gb_memmove(data, s.text, s.len); data[s.len] = 0; @@ -367,17 +329,17 @@ String copy_string(gbAllocator a, String const &s) { #if defined(GB_SYSTEM_WINDOWS) - int convert_multibyte_to_widechar(char const *multibyte_input, int input_length, wchar_t *output, int output_size) { + gb_internal int convert_multibyte_to_widechar(char const *multibyte_input, int input_length, wchar_t *output, int output_size) { return MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, multibyte_input, input_length, output, output_size); } - int convert_widechar_to_multibyte(wchar_t const *widechar_input, int input_length, char *output, int output_size) { + gb_internal int convert_widechar_to_multibyte(wchar_t const *widechar_input, int input_length, char *output, int output_size) { return WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, widechar_input, input_length, output, output_size, nullptr, nullptr); } #elif defined(GB_SYSTEM_UNIX) || defined(GB_SYSTEM_OSX) #include - int convert_multibyte_to_widechar(char const *multibyte_input, usize input_length, wchar_t *output, usize output_size) { + gb_internal int convert_multibyte_to_widechar(char const *multibyte_input, usize input_length, wchar_t *output, usize output_size) { iconv_t conv = iconv_open("WCHAR_T", "UTF-8"); size_t result = iconv(conv, cast(char **)&multibyte_input, &input_length, cast(char **)&output, &output_size); iconv_close(conv); @@ -385,7 +347,7 @@ String copy_string(gbAllocator a, String const &s) { return cast(int)result; } - int convert_widechar_to_multibyte(wchar_t const *widechar_input, usize input_length, char* output, usize output_size) { + gb_internal int convert_widechar_to_multibyte(wchar_t const *widechar_input, usize input_length, char* output, usize output_size) { iconv_t conv = iconv_open("UTF-8", "WCHAR_T"); size_t result = iconv(conv, cast(char**) &widechar_input, &input_length, cast(char **)&output, &output_size); iconv_close(conv); @@ -400,7 +362,7 @@ String copy_string(gbAllocator a, String const &s) { // TODO(bill): Make this non-windows specific -String16 string_to_string16(gbAllocator a, String s) { +gb_internal String16 string_to_string16(gbAllocator a, String s) { int len, len1; wchar_t *text; @@ -426,7 +388,7 @@ String16 string_to_string16(gbAllocator a, String s) { } -String string16_to_string(gbAllocator a, String16 s) { +gb_internal String string16_to_string(gbAllocator a, String16 s) { int len, len1; u8 *text; @@ -458,7 +420,7 @@ String string16_to_string(gbAllocator a, String16 s) { -bool is_printable(Rune r) { +gb_internal bool is_printable(Rune r) { if (r <= 0xff) { if (0x20 <= r && r <= 0x7e) { return true; @@ -473,7 +435,7 @@ bool is_printable(Rune r) { gb_global char const lower_hex[] = "0123456789abcdef"; -String quote_to_ascii(gbAllocator a, String str, u8 quote='"') { +gb_internal String quote_to_ascii(gbAllocator a, String str, u8 quote='"') { u8 *s = str.text; isize n = str.len; auto buf = array_make(a, 0, n); @@ -548,7 +510,7 @@ String quote_to_ascii(gbAllocator a, String str, u8 quote='"') { -bool unquote_char(String s, u8 quote, Rune *rune, bool *multiple_bytes, String *tail_string) { +gb_internal bool unquote_char(String s, u8 quote, Rune *rune, bool *multiple_bytes, String *tail_string) { u8 c; if (s[0] == quote && @@ -657,7 +619,7 @@ bool unquote_char(String s, u8 quote, Rune *rune, bool *multiple_bytes, String * } -String strip_carriage_return(gbAllocator a, String s) { +gb_internal String strip_carriage_return(gbAllocator a, String s) { isize buf_len = s.len; u8 *buf = gb_alloc_array(a, u8, buf_len); isize i = 0; @@ -675,7 +637,7 @@ String strip_carriage_return(gbAllocator a, String s) { // 0 == failure // 1 == original memory // 2 == new allocation -i32 unquote_string(gbAllocator a, String *s_, u8 quote=0, bool has_carriage_return=false) { +gb_internal i32 unquote_string(gbAllocator a, String *s_, u8 quote=0, bool has_carriage_return=false) { String s = *s_; isize n = s.len; if (quote == 0) { @@ -761,7 +723,7 @@ i32 unquote_string(gbAllocator a, String *s_, u8 quote=0, bool has_carriage_retu -bool string_is_valid_identifier(String str) { +gb_internal bool string_is_valid_identifier(String str) { if (str.len <= 0) return false; isize rune_count = 0; diff --git a/src/string_map.cpp b/src/string_map.cpp index 218a45482..f8b86a950 100644 --- a/src/string_map.cpp +++ b/src/string_map.cpp @@ -1,98 +1,121 @@ +GB_STATIC_ASSERT(sizeof(MapIndex) == sizeof(u32)); + + struct StringHashKey { u32 hash; String string; -}; -gb_inline StringHashKey string_hash_string(String const &s) { + operator String() const noexcept { + return this->string; + } + operator String const &() const noexcept { + return this->string; + } +}; +gb_internal gb_inline u32 string_hash(String const &s) { + return fnv32a(s.text, s.len) & 0x7fffffff; +} + +gb_internal gb_inline StringHashKey string_hash_string(String const &s) { StringHashKey hash_key = {}; - hash_key.hash = fnv32a(s.text, s.len); + hash_key.hash = string_hash(s); hash_key.string = s; return hash_key; } - -bool string_hash_key_equal(StringHashKey const &a, StringHashKey const &b) { - if (a.hash == b.hash) { - // NOTE(bill): If two string's hashes collide, compare the strings themselves - return a.string == b.string; - } - return false; -} -bool operator==(StringHashKey const &a, StringHashKey const &b) { return string_hash_key_equal(a, b); } -bool operator!=(StringHashKey const &a, StringHashKey const &b) { return !string_hash_key_equal(a, b); } - template struct StringMapEntry { - StringHashKey key; + String key; + u32 hash; MapIndex next; T value; }; template struct StringMap { - Slice hashes; - Array > entries; + MapIndex * hashes; + usize hashes_count; + StringMapEntry *entries; + u32 count; + u32 entries_capacity; }; -template void string_map_init (StringMap *h, gbAllocator a, isize capacity = 16); -template void string_map_destroy (StringMap *h); +template gb_internal void string_map_init (StringMap *h, usize capacity = 16); +template gb_internal void string_map_destroy (StringMap *h); -template T * string_map_get (StringMap *h, char const *key); -template T * string_map_get (StringMap *h, String const &key); -template T * string_map_get (StringMap *h, StringHashKey const &key); +template gb_internal T * string_map_get (StringMap *h, char const *key); +template gb_internal T * string_map_get (StringMap *h, String const &key); +template gb_internal T * string_map_get (StringMap *h, StringHashKey const &key); -template T & string_map_must_get (StringMap *h, char const *key); -template T & string_map_must_get (StringMap *h, String const &key); -template T & string_map_must_get (StringMap *h, StringHashKey const &key); +template gb_internal T & string_map_must_get(StringMap *h, char const *key); +template gb_internal T & string_map_must_get(StringMap *h, String const &key); +template gb_internal T & string_map_must_get(StringMap *h, StringHashKey const &key); -template void string_map_set (StringMap *h, StringHashKey const &key, T const &value); -template void string_map_set (StringMap *h, String const &key, T const &value); -template void string_map_set (StringMap *h, char const *key, T const &value); +template gb_internal void string_map_set (StringMap *h, char const *key, T const &value); +template gb_internal void string_map_set (StringMap *h, String const &key, T const &value); +template gb_internal void string_map_set (StringMap *h, StringHashKey const &key, T const &value); -template void string_map_remove (StringMap *h, StringHashKey const &key); -template void string_map_clear (StringMap *h); -template void string_map_grow (StringMap *h); -template void string_map_rehash (StringMap *h, isize new_count); -template void string_map_reserve (StringMap *h, isize cap); +// template gb_internal void string_map_remove (StringMap *h, StringHashKey const &key); +template gb_internal void string_map_clear (StringMap *h); +template gb_internal void string_map_grow (StringMap *h); +template gb_internal void string_map_reserve (StringMap *h, usize new_count); + +gb_internal gbAllocator string_map_allocator(void) { + return heap_allocator(); +} template -gb_inline void string_map_init(StringMap *h, gbAllocator a, isize capacity) { +gb_internal gb_inline void string_map_init(StringMap *h, usize capacity) { capacity = next_pow2_isize(capacity); - slice_init(&h->hashes, a, capacity); - array_init(&h->entries, a, 0, capacity); - for (isize i = 0; i < capacity; i++) { - h->hashes.data[i] = MAP_SENTINEL; - } + string_map_reserve(h, capacity); } template -gb_inline void string_map_destroy(StringMap *h) { - slice_free(&h->hashes, h->entries.allocator); - array_free(&h->entries); +gb_internal gb_inline void string_map_destroy(StringMap *h) { + gb_free(string_map_allocator(), h->hashes); + gb_free(string_map_allocator(), h->entries); } + template -gb_internal MapIndex string_map__add_entry(StringMap *h, StringHashKey const &key) { +gb_internal void string_map__resize_hashes(StringMap *h, usize count) { + h->hashes_count = cast(u32)resize_array_raw(&h->hashes, string_map_allocator(), h->hashes_count, count, MAP_CACHE_LINE_SIZE); +} + + +template +gb_internal void string_map__reserve_entries(StringMap *h, usize capacity) { + h->entries_capacity = cast(u32)resize_array_raw(&h->entries, string_map_allocator(), h->entries_capacity, capacity, MAP_CACHE_LINE_SIZE); +} + + +template +gb_internal MapIndex string_map__add_entry(StringMap *h, u32 hash, String const &key) { StringMapEntry e = {}; e.key = key; + e.hash = hash; e.next = MAP_SENTINEL; - array_add(&h->entries, e); - return cast(MapIndex)(h->entries.count-1); + if (h->count+1 >= h->entries_capacity) { + string_map__reserve_entries(h, gb_max(h->entries_capacity*2, 4)); + } + h->entries[h->count++] = e; + return cast(MapIndex)(h->count-1); } template -gb_internal MapFindResult string_map__find(StringMap *h, StringHashKey const &key) { +gb_internal MapFindResult string_map__find(StringMap *h, u32 hash, String const &key) { MapFindResult fr = {MAP_SENTINEL, MAP_SENTINEL, MAP_SENTINEL}; - if (h->hashes.count != 0) { - fr.hash_index = cast(MapIndex)(key.hash & (h->hashes.count-1)); - fr.entry_index = h->hashes.data[fr.hash_index]; + if (h->hashes_count != 0) { + fr.hash_index = cast(MapIndex)(hash & (h->hashes_count-1)); + fr.entry_index = h->hashes[fr.hash_index]; while (fr.entry_index != MAP_SENTINEL) { - if (string_hash_key_equal(h->entries.data[fr.entry_index].key, key)) { + auto *entry = &h->entries[fr.entry_index]; + if (entry->hash == hash && entry->key == key) { return fr; } fr.entry_prev = fr.entry_index; - fr.entry_index = h->entries.data[fr.entry_index].next; + fr.entry_index = entry->next; } } return fr; @@ -101,15 +124,16 @@ gb_internal MapFindResult string_map__find(StringMap *h, StringHashKey const template gb_internal MapFindResult string_map__find_from_entry(StringMap *h, StringMapEntry *e) { MapFindResult fr = {MAP_SENTINEL, MAP_SENTINEL, MAP_SENTINEL}; - if (h->hashes.count != 0) { - fr.hash_index = cast(MapIndex)(e->key.hash & (h->hashes.count-1)); - fr.entry_index = h->hashes.data[fr.hash_index]; + if (h->hashes_count != 0) { + fr.hash_index = cast(MapIndex)(e->hash & (h->hashes_count-1)); + fr.entry_index = h->hashes[fr.hash_index]; while (fr.entry_index != MAP_SENTINEL) { - if (&h->entries.data[fr.entry_index] == e) { + auto *entry = &h->entries[fr.entry_index]; + if (entry == e) { return fr; } fr.entry_prev = fr.entry_index; - fr.entry_index = h->entries.data[fr.entry_index].next; + fr.entry_index = entry->next; } } return fr; @@ -117,24 +141,24 @@ gb_internal MapFindResult string_map__find_from_entry(StringMap *h, StringMap template gb_internal b32 string_map__full(StringMap *h) { - return 0.75f * h->hashes.count <= h->entries.count; + return 0.75f * h->hashes_count <= h->count; } template gb_inline void string_map_grow(StringMap *h) { - isize new_count = gb_max(h->hashes.count<<1, 16); - string_map_rehash(h, new_count); + isize new_count = gb_max(h->hashes_count<<1, 16); + string_map_reserve(h, new_count); } template -void string_map_reset_entries(StringMap *h) { - for (isize i = 0; i < h->hashes.count; i++) { - h->hashes.data[i] = MAP_SENTINEL; +gb_internal void string_map_reset_entries(StringMap *h) { + for (u32 i = 0; i < h->hashes_count; i++) { + h->hashes[i] = MAP_SENTINEL; } - for (isize i = 0; i < h->entries.count; i++) { + for (isize i = 0; i < h->count; i++) { MapFindResult fr; - StringMapEntry *e = &h->entries.data[i]; + StringMapEntry *e = &h->entries[i]; e->next = MAP_SENTINEL; fr = string_map__find_from_entry(h, e); if (fr.entry_prev == MAP_SENTINEL) { @@ -146,76 +170,92 @@ void string_map_reset_entries(StringMap *h) { } template -void string_map_reserve(StringMap *h, isize cap) { - array_reserve(&h->entries, cap); - if (h->entries.count*2 < h->hashes.count) { +gb_internal void string_map_reserve(StringMap *h, usize cap) { + if (h->count*2 < h->hashes_count) { return; } - slice_resize(&h->hashes, h->entries.allocator, cap*2); + string_map__reserve_entries(h, cap); + string_map__resize_hashes(h, cap*2); string_map_reset_entries(h); } - template -void string_map_rehash(StringMap *h, isize new_count) { - string_map_reserve(h, new_count); -} - -template -T *string_map_get(StringMap *h, StringHashKey const &key) { - isize index = string_map__find(h, key).entry_index; - if (index != MAP_SENTINEL) { - return &h->entries.data[index].value; +gb_internal T *string_map_get(StringMap *h, u32 hash, String const &key) { + MapFindResult fr = {MAP_SENTINEL, MAP_SENTINEL, MAP_SENTINEL}; + if (h->hashes_count != 0) { + fr.hash_index = cast(MapIndex)(hash & (h->hashes_count-1)); + fr.entry_index = h->hashes[fr.hash_index]; + while (fr.entry_index != MAP_SENTINEL) { + auto *entry = &h->entries[fr.entry_index]; + if (entry->hash == hash && entry->key == key) { + return &entry->value; + } + fr.entry_prev = fr.entry_index; + fr.entry_index = entry->next; + } } return nullptr; } + template -gb_inline T *string_map_get(StringMap *h, String const &key) { - return string_map_get(h, string_hash_string(key)); +gb_internal gb_inline T *string_map_get(StringMap *h, StringHashKey const &key) { + return string_map_get(h, key.hash, key.string); } template -gb_inline T *string_map_get(StringMap *h, char const *key) { - return string_map_get(h, string_hash_string(make_string_c(key))); +gb_internal gb_inline T *string_map_get(StringMap *h, String const &key) { + return string_map_get(h, string_hash(key), key); } template -T &string_map_must_get(StringMap *h, StringHashKey const &key) { - isize index = string_map__find(h, key).entry_index; +gb_internal gb_inline T *string_map_get(StringMap *h, char const *key) { + String k = make_string_c(key); + return string_map_get(h, string_hash(k), k); +} + +template +gb_internal T &string_map_must_get(StringMap *h, u32 hash, String const &key) { + isize index = string_map__find(h, hash, key).entry_index; GB_ASSERT(index != MAP_SENTINEL); - return h->entries.data[index].value; + return h->entries[index].value; } template -gb_inline T &string_map_must_get(StringMap *h, String const &key) { - return string_map_must_get(h, string_hash_string(key)); +gb_internal T &string_map_must_get(StringMap *h, StringHashKey const &key) { + return string_map_must_get(h, key.hash, key.string); } template -gb_inline T &string_map_must_get(StringMap *h, char const *key) { - return string_map_must_get(h, string_hash_string(make_string_c(key))); +gb_internal gb_inline T &string_map_must_get(StringMap *h, String const &key) { + return string_map_must_get(h, string_hash(key), key); } template -void string_map_set(StringMap *h, StringHashKey const &key, T const &value) { +gb_internal gb_inline T &string_map_must_get(StringMap *h, char const *key) { + String k = make_string_c(key); + return string_map_must_get(h, string_hash(k), k); +} + +template +gb_internal void string_map_set(StringMap *h, u32 hash, String const &key, T const &value) { MapIndex index; MapFindResult fr; - if (h->hashes.count == 0) { + if (h->hashes_count == 0) { string_map_grow(h); } - fr = string_map__find(h, key); + fr = string_map__find(h, hash, key); if (fr.entry_index != MAP_SENTINEL) { index = fr.entry_index; } else { - index = string_map__add_entry(h, key); + index = string_map__add_entry(h, hash, key); if (fr.entry_prev != MAP_SENTINEL) { - h->entries.data[fr.entry_prev].next = index; + h->entries[fr.entry_prev].next = index; } else { - h->hashes.data[fr.hash_index] = index; + h->hashes[fr.hash_index] = index; } } - h->entries.data[index].value = value; + h->entries[index].value = value; if (string_map__full(h)) { string_map_grow(h); @@ -223,50 +263,77 @@ void string_map_set(StringMap *h, StringHashKey const &key, T const &value) { } template -gb_inline void string_map_set(StringMap *h, String const &key, T const &value) { +gb_internal gb_inline void string_map_set(StringMap *h, String const &key, T const &value) { string_map_set(h, string_hash_string(key), value); } template -gb_inline void string_map_set(StringMap *h, char const *key, T const &value) { +gb_internal gb_inline void string_map_set(StringMap *h, char const *key, T const &value) { string_map_set(h, string_hash_string(make_string_c(key)), value); } +template +gb_internal gb_inline void string_map_set(StringMap *h, StringHashKey const &key, T const &value) { + string_map_set(h, key.hash, key.string, value); +} + + + +// template +// gb_internal void string_map__erase(StringMap *h, MapFindResult const &fr) { +// MapFindResult last; +// if (fr.entry_prev == MAP_SENTINEL) { +// h->hashes[fr.hash_index] = h->entries[fr.entry_index].next; +// } else { +// h->entries[fr.entry_prev].next = h->entries[fr.entry_index].next; +// } +// if (fr.entry_index == h->count-1) { +// array_pop(&h->entries); +// return; +// } +// h->entries[fr.entry_index] = h->entries[h->count-1]; +// last = string_map__find(h, h->entries[fr.entry_index].key); +// if (last.entry_prev != MAP_SENTINEL) { +// h->entries[last.entry_prev].next = fr.entry_index; +// } else { +// h->hashes[last.hash_index] = fr.entry_index; +// } +// } + +// template +// gb_internal void string_map_remove(StringMap *h, StringHashKey const &key) { +// MapFindResult fr = string_map__find(h, key); +// if (fr.entry_index != MAP_SENTINEL) { +// string_map__erase(h, fr); +// } +// } template -void string_map__erase(StringMap *h, MapFindResult const &fr) { - MapFindResult last; - if (fr.entry_prev == MAP_SENTINEL) { - h->hashes.data[fr.hash_index] = h->entries.data[fr.entry_index].next; - } else { - h->entries.data[fr.entry_prev].next = h->entries.data[fr.entry_index].next; - } - if (fr.entry_index == h->entries.count-1) { - array_pop(&h->entries); - return; - } - h->entries.data[fr.entry_index] = h->entries.data[h->entries.count-1]; - last = string_map__find(h, h->entries.data[fr.entry_index].key); - if (last.entry_prev != MAP_SENTINEL) { - h->entries.data[last.entry_prev].next = fr.entry_index; - } else { - h->hashes.data[last.hash_index] = fr.entry_index; +gb_internal gb_inline void string_map_clear(StringMap *h) { + h->count = 0; + for (u32 i = 0; i < h->hashes_count; i++) { + h->hashes[i] = MAP_SENTINEL; } } + + template -void string_map_remove(StringMap *h, StringHashKey const &key) { - MapFindResult fr = string_map__find(h, key); - if (fr.entry_index != MAP_SENTINEL) { - string_map__erase(h, fr); - } +gb_internal StringMapEntry *begin(StringMap &m) noexcept { + return m.entries; +} +template +gb_internal StringMapEntry const *begin(StringMap const &m) noexcept { + return m.entries; +} + + +template +gb_internal StringMapEntry *end(StringMap &m) { + return m.entries + m.count; } template -gb_inline void string_map_clear(StringMap *h) { - array_clear(&h->entries); - for (isize i = 0; i < h->hashes.count; i++) { - h->hashes.data[i] = MAP_SENTINEL; - } -} - +gb_internal StringMapEntry const *end(StringMap const &m) noexcept { + return m.entries + m.count; +} \ No newline at end of file diff --git a/src/string_set.cpp b/src/string_set.cpp index 746ad9529..fb4640c20 100644 --- a/src/string_set.cpp +++ b/src/string_set.cpp @@ -2,6 +2,13 @@ struct StringSetEntry { u32 hash; MapIndex next; String value; + + operator String const() const noexcept { + return this->value; + } + operator String const &() const noexcept { + return this->value; + } }; struct StringSet { @@ -10,28 +17,34 @@ struct StringSet { }; -void string_set_init (StringSet *s, gbAllocator a, isize capacity = 16); -void string_set_destroy(StringSet *s); -void string_set_add (StringSet *s, String const &str); -bool string_set_update (StringSet *s, String const &str); // returns true if it previously existed -bool string_set_exists (StringSet *s, String const &str); -void string_set_remove (StringSet *s, String const &str); -void string_set_clear (StringSet *s); -void string_set_grow (StringSet *s); -void string_set_rehash (StringSet *s, isize new_count); +gb_internal void string_set_init (StringSet *s, isize capacity = 16); +gb_internal void string_set_destroy(StringSet *s); +gb_internal void string_set_add (StringSet *s, String const &str); +gb_internal bool string_set_update (StringSet *s, String const &str); // returns true if it previously existed +gb_internal bool string_set_exists (StringSet *s, String const &str); +gb_internal void string_set_remove (StringSet *s, String const &str); +gb_internal void string_set_clear (StringSet *s); +gb_internal void string_set_grow (StringSet *s); +gb_internal void string_set_rehash (StringSet *s, isize new_count); +gb_internal gbAllocator string_set_allocator(void) { + return heap_allocator(); +} -gb_inline void string_set_init(StringSet *s, gbAllocator a, isize capacity) { +gb_internal gb_inline void string_set_init(StringSet *s, isize capacity) { capacity = next_pow2_isize(gb_max(16, capacity)); - slice_init(&s->hashes, a, capacity); - array_init(&s->entries, a, 0, capacity); + slice_init(&s->hashes, string_set_allocator(), capacity); + array_init(&s->entries, string_set_allocator(), 0, capacity); for (isize i = 0; i < capacity; i++) { s->hashes.data[i] = MAP_SENTINEL; } } -gb_inline void string_set_destroy(StringSet *s) { +gb_internal gb_inline void string_set_destroy(StringSet *s) { + if (s->entries.allocator.proc == nullptr) { + s->entries.allocator = string_set_allocator(); + } slice_free(&s->hashes, s->entries.allocator); array_free(&s->entries); } @@ -82,13 +95,13 @@ gb_internal b32 string_set__full(StringSet *s) { return 0.75f * s->hashes.count <= s->entries.count; } -gb_inline void string_set_grow(StringSet *s) { +gb_internal gb_inline void string_set_grow(StringSet *s) { isize new_count = gb_max(s->hashes.count<<1, 16); string_set_rehash(s, new_count); } -void string_set_reset_entries(StringSet *s) { +gb_internal void string_set_reset_entries(StringSet *s) { for (isize i = 0; i < s->hashes.count; i++) { s->hashes.data[i] = MAP_SENTINEL; } @@ -105,7 +118,10 @@ void string_set_reset_entries(StringSet *s) { } } -void string_set_reserve(StringSet *s, isize cap) { +gb_internal void string_set_reserve(StringSet *s, isize cap) { + if (s->entries.allocator.proc == nullptr) { + s->entries.allocator = string_set_allocator(); + } array_reserve(&s->entries, cap); if (s->entries.count*2 < s->hashes.count) { return; @@ -115,7 +131,7 @@ void string_set_reserve(StringSet *s, isize cap) { } -void string_set_rehash(StringSet *s, isize new_count) { +gb_internal void string_set_rehash(StringSet *s, isize new_count) { string_set_reserve(s, new_count); } @@ -125,7 +141,7 @@ gb_inline bool string_set_exists(StringSet *s, String const &str) { return index != MAP_SENTINEL; } -void string_set_add(StringSet *s, String const &str) { +gb_internal void string_set_add(StringSet *s, String const &str) { MapIndex index; MapFindResult fr; StringHashKey key = string_hash_string(str); @@ -150,7 +166,7 @@ void string_set_add(StringSet *s, String const &str) { } } -bool string_set_update(StringSet *s, String const &str) { +gb_internal bool string_set_update(StringSet *s, String const &str) { bool exists = false; MapIndex index; MapFindResult fr; @@ -179,7 +195,7 @@ bool string_set_update(StringSet *s, String const &str) { } -void string_set__erase(StringSet *s, MapFindResult fr) { +gb_internal void string_set__erase(StringSet *s, MapFindResult fr) { MapFindResult last; if (fr.entry_prev == MAP_SENTINEL) { s->hashes[fr.hash_index] = s->entries[fr.entry_index].next; @@ -201,7 +217,7 @@ void string_set__erase(StringSet *s, MapFindResult fr) { } } -void string_set_remove(StringSet *s, String const &str) { +gb_internal void string_set_remove(StringSet *s, String const &str) { StringHashKey key = string_hash_string(str); MapFindResult fr = string_set__find(s, key); if (fr.entry_index != MAP_SENTINEL) { @@ -209,9 +225,26 @@ void string_set_remove(StringSet *s, String const &str) { } } -gb_inline void string_set_clear(StringSet *s) { +gb_internal gb_inline void string_set_clear(StringSet *s) { array_clear(&s->entries); for_array(i, s->hashes) { s->hashes.data[i] = MAP_SENTINEL; } } + + +gb_internal StringSetEntry *begin(StringSet &m) noexcept { + return m.entries.data; +} +gb_internal StringSetEntry const *begin(StringSet const &m) noexcept { + return m.entries.data; +} + + +gb_internal StringSetEntry *end(StringSet &m) noexcept { + return m.entries.data + m.entries.count; +} + +gb_internal StringSetEntry const *end(StringSet const &m) noexcept { + return m.entries.data + m.entries.count; +} \ No newline at end of file diff --git a/src/thread_pool.cpp b/src/thread_pool.cpp index 727cdcdda..5dbbe37c4 100644 --- a/src/thread_pool.cpp +++ b/src/thread_pool.cpp @@ -1,165 +1,191 @@ // thread_pool.cpp -#define WORKER_TASK_PROC(name) isize name(void *data) -typedef WORKER_TASK_PROC(WorkerTaskProc); +struct WorkerTask; +struct ThreadPool; -struct WorkerTask { - WorkerTask * next; - WorkerTaskProc *do_work; - void * data; -}; +gb_thread_local Thread *current_thread; + +gb_internal void thread_pool_init(ThreadPool *pool, isize worker_count, char const *worker_name); +gb_internal void thread_pool_destroy(ThreadPool *pool); +gb_internal bool thread_pool_add_task(ThreadPool *pool, WorkerTaskProc *proc, void *data); +gb_internal void thread_pool_wait(ThreadPool *pool); struct ThreadPool { - gbAllocator allocator; - BlockingMutex mutex; - Condition task_cond; - + gbAllocator threads_allocator; Slice threads; - - WorkerTask *task_queue; - - std::atomic ready; - std::atomic stop; - + std::atomic running; + + Futex tasks_available; + + Futex tasks_left; }; -THREAD_PROC(thread_pool_thread_proc); +gb_internal isize current_thread_index(void) { + return current_thread ? current_thread->idx : 0; +} -void thread_pool_init(ThreadPool *pool, gbAllocator const &a, isize thread_count, char const *worker_name) { - pool->allocator = a; - pool->stop = false; - mutex_init(&pool->mutex); - condition_init(&pool->task_cond); - - slice_init(&pool->threads, a, thread_count); - for_array(i, pool->threads) { +gb_internal void thread_pool_init(ThreadPool *pool, isize worker_count, char const *worker_name) { + pool->threads_allocator = permanent_allocator(); + slice_init(&pool->threads, pool->threads_allocator, worker_count + 1); + + // NOTE: this needs to be initialized before any thread starts + pool->running.store(true, std::memory_order_seq_cst); + + // setup the main thread + thread_init(pool, &pool->threads[0], 0); + current_thread = &pool->threads[0]; + + for_array_off(i, 1, pool->threads) { Thread *t = &pool->threads[i]; - thread_init(t); + thread_init_and_start(pool, t, i); } - - for_array(i, pool->threads) { +} + +gb_internal void thread_pool_destroy(ThreadPool *pool) { + pool->running.store(false, std::memory_order_seq_cst); + + for_array_off(i, 1, pool->threads) { Thread *t = &pool->threads[i]; - thread_start(t, thread_pool_thread_proc, pool); + pool->tasks_available.fetch_add(1, std::memory_order_relaxed); + futex_broadcast(&pool->tasks_available); + thread_join_and_destroy(t); } + + gb_free(pool->threads_allocator, pool->threads.data); } -void thread_pool_destroy(ThreadPool *pool) { - mutex_lock(&pool->mutex); - pool->stop = true; - condition_broadcast(&pool->task_cond); - mutex_unlock(&pool->mutex); +void thread_pool_queue_push(Thread *thread, WorkerTask task) { + u64 capture; + u64 new_capture; + do { + capture = thread->head_and_tail.load(); - for_array(i, pool->threads) { - Thread *t = &pool->threads[i]; - thread_join(t); - } - - for_array(i, pool->threads) { - Thread *t = &pool->threads[i]; - thread_destroy(t); - } - - gb_free(pool->allocator, pool->threads.data); - mutex_destroy(&pool->mutex); - condition_destroy(&pool->task_cond); + u64 mask = thread->capacity - 1; + u64 head = (capture >> 32) & mask; + u64 tail = ((u32)capture) & mask; + + u64 new_head = (head + 1) & mask; + GB_ASSERT_MSG(new_head != tail, "Thread Queue Full!"); + + // This *must* be done in here, to avoid a potential race condition where we no longer own the slot by the time we're assigning + thread->queue[head] = task; + new_capture = (new_head << 32) | tail; + } while (!thread->head_and_tail.compare_exchange_weak(capture, new_capture)); + + thread->pool->tasks_left.fetch_add(1, std::memory_order_release); + thread->pool->tasks_available.fetch_add(1, std::memory_order_relaxed); + futex_broadcast(&thread->pool->tasks_available); } -bool thread_pool_queue_empty(ThreadPool *pool) { - return pool->task_queue == nullptr; +bool thread_pool_queue_pop(Thread *thread, WorkerTask *task) { + u64 capture; + u64 new_capture; + do { + capture = thread->head_and_tail.load(std::memory_order_acquire); + + u64 mask = thread->capacity - 1; + u64 head = (capture >> 32) & mask; + u64 tail = ((u32)capture) & mask; + + u64 new_tail = (tail + 1) & mask; + if (tail == head) { + return false; + } + + // Making a copy of the task before we increment the tail, avoiding the same potential race condition as above + *task = thread->queue[tail]; + + new_capture = (head << 32) | new_tail; + } while (!thread->head_and_tail.compare_exchange_weak(capture, new_capture, std::memory_order_release)); + + return true; } -WorkerTask *thread_pool_queue_pop(ThreadPool *pool) { - GB_ASSERT(pool->task_queue != nullptr); - WorkerTask *task = pool->task_queue; - pool->task_queue = task->next; - return task; -} -void thread_pool_queue_push(ThreadPool *pool, WorkerTask *task) { - GB_ASSERT(task != nullptr); - task->next = pool->task_queue; - pool->task_queue = task; -} - -bool thread_pool_add_task(ThreadPool *pool, WorkerTaskProc *proc, void *data) { - GB_ASSERT(proc != nullptr); - mutex_lock(&pool->mutex); - WorkerTask *task = gb_alloc_item(permanent_allocator(), WorkerTask); - if (task == nullptr) { - mutex_unlock(&pool->mutex); - GB_PANIC("Out of memory"); - return false; - } - task->do_work = proc; - task->data = data; +gb_internal bool thread_pool_add_task(ThreadPool *pool, WorkerTaskProc *proc, void *data) { + WorkerTask task = {}; + task.do_work = proc; + task.data = data; - thread_pool_queue_push(pool, task); - GB_ASSERT(pool->ready >= 0); - pool->ready++; - condition_broadcast(&pool->task_cond); - mutex_unlock(&pool->mutex); + thread_pool_queue_push(current_thread, task); return true; } +gb_internal void thread_pool_wait(ThreadPool *pool) { + WorkerTask task; -void thread_pool_do_task(WorkerTask *task) { - task->do_work(task->data); -} - -void thread_pool_wait(ThreadPool *pool) { - if (pool->threads.count == 0) { - while (!thread_pool_queue_empty(pool)) { - thread_pool_do_task(thread_pool_queue_pop(pool)); - --pool->ready; + while (pool->tasks_left.load(std::memory_order_acquire)) { + // if we've got tasks on our queue, run them + while (thread_pool_queue_pop(current_thread, &task)) { + task.do_work(task.data); + pool->tasks_left.fetch_sub(1, std::memory_order_release); } - GB_ASSERT(pool->ready == 0); - return; - } - for (;;) { - mutex_lock(&pool->mutex); - while (!pool->stop && pool->ready > 0 && thread_pool_queue_empty(pool)) { - condition_wait(&pool->task_cond, &pool->mutex); - } - if ((pool->stop || pool->ready == 0) && thread_pool_queue_empty(pool)) { - mutex_unlock(&pool->mutex); + + // is this mem-barriered enough? + // This *must* be executed in this order, so the futex wakes immediately + // if rem_tasks has changed since we checked last, otherwise the program + // will permanently sleep + Footex rem_tasks = pool->tasks_left.load(std::memory_order_acquire); + if (rem_tasks == 0) { return; } - WorkerTask *task = thread_pool_queue_pop(pool); - mutex_unlock(&pool->mutex); - - thread_pool_do_task(task); - if (--pool->ready == 0) { - mutex_lock(&pool->mutex); - condition_broadcast(&pool->task_cond); - mutex_unlock(&pool->mutex); - } + futex_wait(&pool->tasks_left, rem_tasks); } } +gb_internal THREAD_PROC(thread_pool_thread_proc) { + WorkerTask task; + current_thread = thread; + ThreadPool *pool = current_thread->pool; + // debugf("worker id: %td\n", current_thread->idx); -THREAD_PROC(thread_pool_thread_proc) { - ThreadPool *pool = cast(ThreadPool *)thread->user_data; - - for (;;) { - mutex_lock(&pool->mutex); + while (pool->running.load(std::memory_order_seq_cst)) { + // If we've got tasks to process, work through them + usize finished_tasks = 0; + i32 state; - while (!pool->stop && thread_pool_queue_empty(pool)) { - condition_wait(&pool->task_cond, &pool->mutex); + while (thread_pool_queue_pop(current_thread, &task)) { + task.do_work(task.data); + pool->tasks_left.fetch_sub(1, std::memory_order_release); + + finished_tasks += 1; } - if (pool->stop && thread_pool_queue_empty(pool)) { - mutex_unlock(&pool->mutex); - return 0; + if (finished_tasks > 0 && pool->tasks_left.load(std::memory_order_acquire) == 0) { + futex_signal(&pool->tasks_left); } - WorkerTask *task = thread_pool_queue_pop(pool); - mutex_unlock(&pool->mutex); - - thread_pool_do_task(task); - if (--pool->ready == 0) { - mutex_lock(&pool->mutex); - condition_broadcast(&pool->task_cond); - mutex_unlock(&pool->mutex); + // If there's still work somewhere and we don't have it, steal it + if (pool->tasks_left.load(std::memory_order_acquire)) { + usize idx = cast(usize)current_thread->idx; + for_array(i, pool->threads) { + if (pool->tasks_left.load(std::memory_order_acquire) == 0) { + break; + } + + idx = (idx + 1) % cast(usize)pool->threads.count; + + Thread *thread = &pool->threads.data[idx]; + WorkerTask task; + if (thread_pool_queue_pop(thread, &task)) { + task.do_work(task.data); + pool->tasks_left.fetch_sub(1, std::memory_order_release); + + if (pool->tasks_left.load(std::memory_order_acquire) == 0) { + futex_signal(&pool->tasks_left); + } + + goto main_loop_continue; + } + } } + + // if we've done all our work, and there's nothing to steal, go to sleep + state = pool->tasks_available.load(std::memory_order_acquire); + futex_wait(&pool->tasks_available, state); + + main_loop_continue:; } -} \ No newline at end of file + + return 0; +} diff --git a/src/threading.cpp b/src/threading.cpp index 63e3415b2..61be371c3 100644 --- a/src/threading.cpp +++ b/src/threading.cpp @@ -1,90 +1,131 @@ #if defined(GB_SYSTEM_LINUX) #include +#if __has_include() +#include +#define HAS_VALGRIND +#endif +#endif +#if defined(GB_SYSTEM_WINDOWS) + #pragma warning(push) + #pragma warning(disable: 4505) +#endif + +#if defined(HAS_VALGRIND) +#define ANNOTATE_LOCK_PRE(m, t) VALGRIND_HG_MUTEX_LOCK_PRE(m, t) +#define ANNOTATE_LOCK_POST(m) VALGRIND_HG_MUTEX_LOCK_POST(m) +#define ANNOTATE_UNLOCK_PRE(m) VALGRIND_HG_MUTEX_UNLOCK_PRE(m) +#define ANNOTATE_UNLOCK_POST(m) VALGRIND_HG_MUTEX_UNLOCK_POST(m) +#define ANNOTATE_SEM_WAIT_POST(s) VALGRIND_HG_SEM_WAIT_POST(s) +#define ANNOTATE_SEM_POST_PRE(s) VALGRIND_HG_SEM_POST_PRE(s) +#else +#define ANNOTATE_LOCK_PRE(m, t) +#define ANNOTATE_LOCK_POST(m) +#define ANNOTATE_UNLOCK_PRE(m) +#define ANNOTATE_UNLOCK_POST(m) +#define ANNOTATE_SEM_WAIT_POST(s) +#define ANNOTATE_SEM_POST_PRE(s) #endif struct BlockingMutex; struct RecursiveMutex; +struct RwMutex; struct Semaphore; struct Condition; struct Thread; +struct ThreadPool; +struct Parker; #define THREAD_PROC(name) isize name(struct Thread *thread) -typedef THREAD_PROC(ThreadProc); +gb_internal THREAD_PROC(thread_pool_thread_proc); + +#define WORKER_TASK_PROC(name) isize name(void *data) +typedef WORKER_TASK_PROC(WorkerTaskProc); + +typedef struct WorkerTask { + WorkerTaskProc *do_work; + void *data; +} WorkerTask; struct Thread { #if defined(GB_SYSTEM_WINDOWS) - void * win32_handle; + void *win32_handle; #else - pthread_t posix_handle; + pthread_t posix_handle; #endif - ThreadProc * proc; - void * user_data; - isize user_index; - isize volatile return_value; + isize idx; - Semaphore * semaphore; - isize stack_size; - std::atomic is_running; + WorkerTask *queue; + size_t capacity; + std::atomic head_and_tail; + + isize stack_size; + struct ThreadPool *pool; }; +typedef std::atomic Futex; +typedef volatile i32 Footex; -void mutex_init (BlockingMutex *m); -void mutex_destroy (BlockingMutex *m); -void mutex_lock (BlockingMutex *m); -bool mutex_try_lock(BlockingMutex *m); -void mutex_unlock (BlockingMutex *m); -void mutex_init (RecursiveMutex *m); -void mutex_destroy (RecursiveMutex *m); -void mutex_lock (RecursiveMutex *m); -bool mutex_try_lock(RecursiveMutex *m); -void mutex_unlock (RecursiveMutex *m); +gb_internal void futex_wait(Futex *addr, Footex val); +gb_internal void futex_signal(Futex *addr); +gb_internal void futex_broadcast(Futex *addr); -void semaphore_init (Semaphore *s); -void semaphore_destroy(Semaphore *s); -void semaphore_post (Semaphore *s, i32 count); -void semaphore_wait (Semaphore *s); -void semaphore_release(Semaphore *s) { semaphore_post(s, 1); } +gb_internal void mutex_lock (BlockingMutex *m); +gb_internal bool mutex_try_lock(BlockingMutex *m); +gb_internal void mutex_unlock (BlockingMutex *m); + +gb_internal void mutex_lock (RecursiveMutex *m); +gb_internal bool mutex_try_lock(RecursiveMutex *m); +gb_internal void mutex_unlock (RecursiveMutex *m); + +gb_internal void rw_mutex_lock (RwMutex *m); +gb_internal bool rw_mutex_try_lock (RwMutex *m); +gb_internal void rw_mutex_unlock (RwMutex *m); +gb_internal void rw_mutex_shared_lock (RwMutex *m); +gb_internal bool rw_mutex_try_shared_lock(RwMutex *m); +gb_internal void rw_mutex_shared_unlock (RwMutex *m); + +gb_internal void semaphore_post(Semaphore *s, i32 count); +gb_internal void semaphore_wait(Semaphore *s); -void condition_init(Condition *c); -void condition_destroy(Condition *c); -void condition_broadcast(Condition *c); -void condition_signal(Condition *c); -void condition_wait(Condition *c, BlockingMutex *m); -void condition_wait_with_timeout(Condition *c, BlockingMutex *m, u32 timeout_in_ms); +gb_internal void condition_broadcast(Condition *c); +gb_internal void condition_signal(Condition *c); +gb_internal void condition_wait(Condition *c, BlockingMutex *m); -u32 thread_current_id(void); +gb_internal void park(Parker *p); +gb_internal void unpark_one(Parker *p); +gb_internal void unpark_all(Parker *p); -void thread_init (Thread *t); -void thread_destroy (Thread *t); -void thread_start (Thread *t, ThreadProc *proc, void *data); -void thread_start_with_stack(Thread *t, ThreadProc *proc, void *data, isize stack_size); -void thread_join (Thread *t); -bool thread_is_running (Thread const *t); -void thread_set_name (Thread *t, char const *name); +gb_internal u32 thread_current_id(void); -void yield_thread(void); -void yield_process(void); +gb_internal void thread_init (ThreadPool *pool, Thread *t, isize idx); +gb_internal void thread_init_and_start (ThreadPool *pool, Thread *t, isize idx); +gb_internal void thread_join_and_destroy(Thread *t); +gb_internal void thread_set_name (Thread *t, char const *name); + +gb_internal void yield_thread(void); +gb_internal void yield_process(void); struct MutexGuard { - MutexGuard() = delete; + MutexGuard() = delete; MutexGuard(MutexGuard const &) = delete; + MutexGuard(MutexGuard &&) = delete; - MutexGuard(BlockingMutex *bm) : bm{bm} { + explicit MutexGuard(BlockingMutex *bm) noexcept : bm{bm} { mutex_lock(this->bm); } - MutexGuard(RecursiveMutex *rm) : rm{rm} { + explicit MutexGuard(RecursiveMutex *rm) noexcept : rm{rm} { mutex_lock(this->rm); } - MutexGuard(BlockingMutex &bm) : bm{&bm} { + explicit MutexGuard(BlockingMutex &bm) noexcept : bm{&bm} { mutex_lock(this->bm); } - MutexGuard(RecursiveMutex &rm) : rm{&rm} { + explicit MutexGuard(RecursiveMutex &rm) noexcept : rm{&rm} { mutex_lock(this->rm); } - ~MutexGuard() { + ~MutexGuard() noexcept { if (this->bm) { mutex_unlock(this->bm); } else if (this->rm) { @@ -92,228 +133,321 @@ struct MutexGuard { } } - operator bool() const { return true; } + operator bool() const noexcept { return true; } BlockingMutex *bm; RecursiveMutex *rm; }; #define MUTEX_GUARD_BLOCK(m) if (MutexGuard GB_DEFER_3(_mutex_guard_){m}) -#define MUTEX_GUARD(m) MutexGuard GB_DEFER_3(_mutex_guard_){m} +#define MUTEX_GUARD(m) mutex_lock(m); defer (mutex_unlock(m)) +struct RecursiveMutex { + Futex owner; + i32 recursion; +}; + +gb_internal void mutex_lock(RecursiveMutex *m) { + Futex tid; + tid.store(cast(i32)thread_current_id()); + for (;;) { + i32 prev_owner = 0; + m->owner.compare_exchange_strong(prev_owner, tid, std::memory_order_acquire, std::memory_order_acquire); + if (prev_owner == 0 || prev_owner == tid) { + m->recursion++; + // inside the lock + return; + } + futex_wait(&m->owner, prev_owner); + } +} +gb_internal bool mutex_try_lock(RecursiveMutex *m) { + Futex tid; + tid.store(cast(i32)thread_current_id()); + i32 prev_owner = 0; + m->owner.compare_exchange_strong(prev_owner, tid, std::memory_order_acquire, std::memory_order_acquire); + if (prev_owner == 0 || prev_owner == tid) { + m->recursion++; + // inside the lock + return true; + } + return false; +} +gb_internal void mutex_unlock(RecursiveMutex *m) { + m->recursion--; + if (m->recursion != 0) { + return; + } + m->owner.exchange(0, std::memory_order_release); + futex_signal(&m->owner); + // outside the lock +} + +struct Semaphore { + Footex count_; + Futex &count() noexcept { + return *(Futex *)&this->count_; + } + Futex const &count() const noexcept { + return *(Futex *)&this->count_; + } +}; + +gb_internal void semaphore_post(Semaphore *s, i32 count) { + s->count().fetch_add(count, std::memory_order_release); + if (s->count().load() == 1) { + futex_signal(&s->count()); + } else { + futex_broadcast(&s->count()); + } +} +gb_internal void semaphore_wait(Semaphore *s) { + for (;;) { + i32 original_count = s->count().load(std::memory_order_relaxed); + while (original_count == 0) { + futex_wait(&s->count(), original_count); + original_count = s->count().load(std::memory_order_relaxed); + } + + if (!s->count().compare_exchange_strong(original_count, original_count-1, std::memory_order_acquire, std::memory_order_acquire)) { + return; + } + } +} + #if defined(GB_SYSTEM_WINDOWS) struct BlockingMutex { SRWLOCK srwlock; }; - void mutex_init(BlockingMutex *m) { - } - void mutex_destroy(BlockingMutex *m) { - } - void mutex_lock(BlockingMutex *m) { + gb_internal void mutex_lock(BlockingMutex *m) { AcquireSRWLockExclusive(&m->srwlock); } - bool mutex_try_lock(BlockingMutex *m) { + gb_internal bool mutex_try_lock(BlockingMutex *m) { return !!TryAcquireSRWLockExclusive(&m->srwlock); } - void mutex_unlock(BlockingMutex *m) { + gb_internal void mutex_unlock(BlockingMutex *m) { ReleaseSRWLockExclusive(&m->srwlock); } - struct RecursiveMutex { - CRITICAL_SECTION win32_critical_section; - }; - void mutex_init(RecursiveMutex *m) { - InitializeCriticalSection(&m->win32_critical_section); - } - void mutex_destroy(RecursiveMutex *m) { - DeleteCriticalSection(&m->win32_critical_section); - } - void mutex_lock(RecursiveMutex *m) { - EnterCriticalSection(&m->win32_critical_section); - } - bool mutex_try_lock(RecursiveMutex *m) { - return TryEnterCriticalSection(&m->win32_critical_section) != 0; - } - void mutex_unlock(RecursiveMutex *m) { - LeaveCriticalSection(&m->win32_critical_section); - } - - struct Semaphore { - void *win32_handle; - }; - - void semaphore_init(Semaphore *s) { - s->win32_handle = CreateSemaphoreA(NULL, 0, I32_MAX, NULL); - } - void semaphore_destroy(Semaphore *s) { - CloseHandle(s->win32_handle); - } - void semaphore_post(Semaphore *s, i32 count) { - ReleaseSemaphore(s->win32_handle, count, NULL); - } - void semaphore_wait(Semaphore *s) { - WaitForSingleObjectEx(s->win32_handle, INFINITE, FALSE); - } - struct Condition { CONDITION_VARIABLE cond; }; - - void condition_init(Condition *c) { - } - void condition_destroy(Condition *c) { - } - void condition_broadcast(Condition *c) { + + gb_internal void condition_broadcast(Condition *c) { WakeAllConditionVariable(&c->cond); } - void condition_signal(Condition *c) { + gb_internal void condition_signal(Condition *c) { WakeConditionVariable(&c->cond); } - void condition_wait(Condition *c, BlockingMutex *m) { + gb_internal void condition_wait(Condition *c, BlockingMutex *m) { SleepConditionVariableSRW(&c->cond, &m->srwlock, INFINITE, 0); } - void condition_wait_with_timeout(Condition *c, BlockingMutex *m, u32 timeout_in_ms) { - SleepConditionVariableSRW(&c->cond, &m->srwlock, timeout_in_ms, 0); + + struct RwMutex { + SRWLOCK srwlock; + }; + + gb_internal void rw_mutex_lock(RwMutex *m) { + AcquireSRWLockExclusive(&m->srwlock); + } + gb_internal bool rw_mutex_try_lock(RwMutex *m) { + return !!TryAcquireSRWLockExclusive(&m->srwlock); + } + gb_internal void rw_mutex_unlock(RwMutex *m) { + ReleaseSRWLockExclusive(&m->srwlock); } + gb_internal void rw_mutex_shared_lock(RwMutex *m) { + AcquireSRWLockShared(&m->srwlock); + } + gb_internal bool rw_mutex_try_shared_lock(RwMutex *m) { + return !!TryAcquireSRWLockShared(&m->srwlock); + } + gb_internal void rw_mutex_shared_unlock(RwMutex *m) { + ReleaseSRWLockShared(&m->srwlock); + } #else + enum Internal_Mutex_State : i32 { + Internal_Mutex_State_Unlocked = 0, + Internal_Mutex_State_Locked = 1, + Internal_Mutex_State_Waiting = 2, + }; + struct BlockingMutex { - pthread_mutex_t pthread_mutex; + #if defined(HAS_VALGRIND) + BlockingMutex() { + VALGRIND_HG_MUTEX_INIT_POST(this, 0); + } + ~BlockingMutex() { + VALGRIND_HG_MUTEX_DESTROY_PRE(this); + } + #endif + i32 state_; + + Futex &state() { + return *(Futex *)&this->state_; + } + Futex const &state() const { + return *(Futex const *)&this->state_; + } }; - void mutex_init(BlockingMutex *m) { - pthread_mutex_init(&m->pthread_mutex, nullptr); - } - void mutex_destroy(BlockingMutex *m) { - pthread_mutex_destroy(&m->pthread_mutex); - } - void mutex_lock(BlockingMutex *m) { - pthread_mutex_lock(&m->pthread_mutex); - } - bool mutex_try_lock(BlockingMutex *m) { - return pthread_mutex_trylock(&m->pthread_mutex) == 0; - } - void mutex_unlock(BlockingMutex *m) { - pthread_mutex_unlock(&m->pthread_mutex); + + gb_no_inline gb_internal void mutex_lock_slow(BlockingMutex *m, i32 curr_state) { + i32 new_state = curr_state; + for (i32 spin = 0; spin < 100; spin++) { + i32 state = Internal_Mutex_State_Unlocked; + bool ok = m->state().compare_exchange_weak(state, new_state, std::memory_order_acquire, std::memory_order_consume); + if (ok) { + return; + } + if (state == Internal_Mutex_State_Waiting) { + break; + } + for (i32 i = gb_min(spin+1, 32); i > 0; i--) { + yield_thread(); + } + } + + // Set just in case 100 iterations did not do it + new_state = Internal_Mutex_State_Waiting; + + for (;;) { + if (m->state().exchange(Internal_Mutex_State_Waiting, std::memory_order_acquire) == Internal_Mutex_State_Unlocked) { + return; + } + futex_wait(&m->state(), new_state); + yield_thread(); + } } - struct RecursiveMutex { - pthread_mutex_t pthread_mutex; - pthread_mutexattr_t pthread_mutexattr; - }; - void mutex_init(RecursiveMutex *m) { - pthread_mutexattr_init(&m->pthread_mutexattr); - pthread_mutexattr_settype(&m->pthread_mutexattr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&m->pthread_mutex, &m->pthread_mutexattr); + gb_internal void mutex_lock(BlockingMutex *m) { + ANNOTATE_LOCK_PRE(m, 0); + i32 v = m->state().exchange(Internal_Mutex_State_Locked, std::memory_order_acquire); + if (v != Internal_Mutex_State_Unlocked) { + mutex_lock_slow(m, v); + } + ANNOTATE_LOCK_POST(m); } - void mutex_destroy(RecursiveMutex *m) { - pthread_mutex_destroy(&m->pthread_mutex); - } - void mutex_lock(RecursiveMutex *m) { - pthread_mutex_lock(&m->pthread_mutex); - } - bool mutex_try_lock(RecursiveMutex *m) { - return pthread_mutex_trylock(&m->pthread_mutex) == 0; - } - void mutex_unlock(RecursiveMutex *m) { - pthread_mutex_unlock(&m->pthread_mutex); - } - - #if defined(GB_SYSTEM_OSX) - struct Semaphore { - semaphore_t osx_handle; - }; - - void semaphore_init (Semaphore *s) { semaphore_create(mach_task_self(), &s->osx_handle, SYNC_POLICY_FIFO, 0); } - void semaphore_destroy(Semaphore *s) { semaphore_destroy(mach_task_self(), s->osx_handle); } - void semaphore_post (Semaphore *s, i32 count) { while (count --> 0) semaphore_signal(s->osx_handle); } - void semaphore_wait (Semaphore *s) { semaphore_wait(s->osx_handle); } - #elif defined(GB_SYSTEM_UNIX) - struct Semaphore { - sem_t unix_handle; - }; - - void semaphore_init (Semaphore *s) { sem_init(&s->unix_handle, 0, 0); } - void semaphore_destroy(Semaphore *s) { sem_destroy(&s->unix_handle); } - void semaphore_post (Semaphore *s, i32 count) { while (count --> 0) sem_post(&s->unix_handle); } - void semaphore_wait (Semaphore *s) { int i; do { i = sem_wait(&s->unix_handle); } while (i == -1 && errno == EINTR); } - #else - #error Implement Semaphore for this platform - #endif - - - struct Condition { - pthread_cond_t pthread_cond; - }; - - void condition_init(Condition *c) { - pthread_cond_init(&c->pthread_cond, NULL); - } - void condition_destroy(Condition *c) { - pthread_cond_destroy(&c->pthread_cond); - } - void condition_broadcast(Condition *c) { - pthread_cond_broadcast(&c->pthread_cond); - } - void condition_signal(Condition *c) { - pthread_cond_signal(&c->pthread_cond); - } - void condition_wait(Condition *c, BlockingMutex *m) { - pthread_cond_wait(&c->pthread_cond, &m->pthread_mutex); - } - void condition_wait_with_timeout(Condition *c, BlockingMutex *m, u32 timeout_in_ms) { - struct timespec abstime = {}; - abstime.tv_sec = timeout_in_ms/1000; - abstime.tv_nsec = cast(long)(timeout_in_ms%1000)*1e6; - pthread_cond_timedwait(&c->pthread_cond, &m->pthread_mutex, &abstime); - - } -#endif - - -struct Barrier { - BlockingMutex mutex; - Condition cond; - isize index; - isize generation_id; - isize thread_count; -}; - -void barrier_init(Barrier *b, isize thread_count) { - mutex_init(&b->mutex); - condition_init(&b->cond); - b->index = 0; - b->generation_id = 0; - b->thread_count = 0; -} - -void barrier_destroy(Barrier *b) { - condition_destroy(&b->cond); - mutex_destroy(&b->mutex); -} - -// Returns true if it is the leader -bool barrier_wait(Barrier *b) { - mutex_lock(&b->mutex); - defer (mutex_unlock(&b->mutex)); - isize local_gen = b->generation_id; - b->index += 1; - if (b->index < b->thread_count) { - while (local_gen == b->generation_id && b->index < b->thread_count) { - condition_wait(&b->cond, &b->mutex); + gb_internal bool mutex_try_lock(BlockingMutex *m) { + ANNOTATE_LOCK_PRE(m, 1); + i32 v = m->state().exchange(Internal_Mutex_State_Locked, std::memory_order_acquire); + if (v == Internal_Mutex_State_Unlocked) { + ANNOTATE_LOCK_POST(m); + return true; } return false; } - b->index = 0; - b->generation_id += 1; - condition_broadcast(&b->cond); - return true; + + gb_no_inline gb_internal void mutex_unlock_slow(BlockingMutex *m) { + futex_signal(&m->state()); + } + + gb_internal void mutex_unlock(BlockingMutex *m) { + ANNOTATE_UNLOCK_PRE(m); + i32 v = m->state().exchange(Internal_Mutex_State_Unlocked, std::memory_order_release); + switch (v) { + case Internal_Mutex_State_Unlocked: + GB_PANIC("Unreachable"); + break; + case Internal_Mutex_State_Locked: + // Okay + break; + case Internal_Mutex_State_Waiting: + mutex_unlock_slow(m); + break; + } + ANNOTATE_UNLOCK_POST(m); + } + + struct Condition { + i32 state_; + + Futex &state() { + return *(Futex *)&this->state_; + } + Futex const &state() const { + return *(Futex const *)&this->state_; + } + }; + + gb_internal void condition_broadcast(Condition *c) { + c->state().fetch_add(1, std::memory_order_release); + futex_broadcast(&c->state()); + } + gb_internal void condition_signal(Condition *c) { + c->state().fetch_add(1, std::memory_order_release); + futex_signal(&c->state()); + } + gb_internal void condition_wait(Condition *c, BlockingMutex *m) { + i32 state = c->state().load(std::memory_order_relaxed); + mutex_unlock(m); + futex_wait(&c->state(), state); + mutex_lock(m); + } + + struct RwMutex { + // TODO(bill): make this a proper RW mutex + BlockingMutex mutex; + }; + + gb_internal void rw_mutex_lock(RwMutex *m) { + mutex_lock(&m->mutex); + } + gb_internal bool rw_mutex_try_lock(RwMutex *m) { + return mutex_try_lock(&m->mutex); + } + gb_internal void rw_mutex_unlock(RwMutex *m) { + mutex_unlock(&m->mutex); + } + + gb_internal void rw_mutex_shared_lock(RwMutex *m) { + mutex_lock(&m->mutex); + } + gb_internal bool rw_mutex_try_shared_lock(RwMutex *m) { + return mutex_try_lock(&m->mutex); + } + gb_internal void rw_mutex_shared_unlock(RwMutex *m) { + mutex_unlock(&m->mutex); + } +#endif + +struct Parker { + Futex state; +}; +enum ParkerState : u32 { + ParkerState_Empty = 0, + ParkerState_Notified = 1, + ParkerState_Parked = UINT32_MAX, +}; + +gb_internal void park(Parker *p) { + if (p->state.fetch_sub(1, std::memory_order_acquire) == ParkerState_Notified) { + return; + } + for (;;) { + futex_wait(&p->state, ParkerState_Parked); + i32 notified = ParkerState_Empty; + if (p->state.compare_exchange_strong(notified, ParkerState_Empty, std::memory_order_acquire, std::memory_order_acquire)) { + return; + } + } +} + +gb_internal void unpark_one(Parker *p) { + if (p->state.exchange(ParkerState_Notified, std::memory_order_release) == ParkerState_Parked) { + futex_signal(&p->state); + } +} + +gb_internal void unpark_all(Parker *p) { + if (p->state.exchange(ParkerState_Notified, std::memory_order_release) == ParkerState_Parked) { + futex_broadcast(&p->state); + } } - - -u32 thread_current_id(void) { +gb_internal u32 thread_current_id(void) { u32 thread_id; #if defined(GB_SYSTEM_WINDOWS) #if defined(GB_ARCH_32_BIT) && defined(GB_CPU_X86) @@ -340,7 +474,7 @@ u32 thread_current_id(void) { } -gb_inline void yield_thread(void) { +gb_internal gb_inline void yield_thread(void) { #if defined(GB_SYSTEM_WINDOWS) _mm_pause(); #elif defined(GB_SYSTEM_OSX) @@ -358,7 +492,7 @@ gb_inline void yield_thread(void) { #endif } -gb_inline void yield(void) { +gb_internal gb_inline void yield(void) { #if defined(GB_SYSTEM_WINDOWS) YieldProcessor(); #else @@ -366,61 +500,46 @@ gb_inline void yield(void) { #endif } +#if defined(GB_SYSTEM_WINDOWS) +gb_internal DWORD __stdcall internal_thread_proc(void *arg) { + Thread *t = cast(Thread *)arg; + thread_pool_thread_proc(t); + return 0; +} +#else +gb_internal void *internal_thread_proc(void *arg) { +#if (GB_SYSTEM_LINUX) + // NOTE: Don't permit any signal delivery to threads on Linux. + sigset_t mask = {}; + sigfillset(&mask); + GB_ASSERT_MSG(pthread_sigmask(SIG_BLOCK, &mask, nullptr) == 0, "failed to block signals"); +#endif -void thread_init(Thread *t) { + Thread *t = cast(Thread *)arg; + thread_pool_thread_proc(t); + return NULL; +} +#endif + +gb_internal void thread_init(ThreadPool *pool, Thread *t, isize idx) { gb_zero_item(t); #if defined(GB_SYSTEM_WINDOWS) t->win32_handle = INVALID_HANDLE_VALUE; #else t->posix_handle = 0; #endif - t->semaphore = gb_alloc_item(heap_allocator(), Semaphore); - semaphore_init(t->semaphore); -} -void thread_destroy(Thread *t) { - thread_join(t); - semaphore_destroy(t->semaphore); - gb_free(heap_allocator(), t->semaphore); + t->capacity = 1 << 14; // must be a power of 2 + t->queue = gb_alloc_array(heap_allocator(), WorkerTask, t->capacity); + t->head_and_tail = 0; + t->pool = pool; + t->idx = idx; } -void gb__thread_run(Thread *t) { - semaphore_release(t->semaphore); - t->return_value = t->proc(t); -} - -#if defined(GB_SYSTEM_WINDOWS) - DWORD __stdcall internal_thread_proc(void *arg) { - Thread *t = cast(Thread *)arg; - t->is_running.store(true); - gb__thread_run(t); - return 0; - } -#else - void *internal_thread_proc(void *arg) { - #if (GB_SYSTEM_LINUX) - // NOTE: Don't permit any signal delivery to threads on Linux. - sigset_t mask = {}; - sigfillset(&mask); - GB_ASSERT_MSG(pthread_sigmask(SIG_BLOCK, &mask, nullptr) == 0, "failed to block signals"); - #endif - - Thread *t = cast(Thread *)arg; - t->is_running.store(true); - gb__thread_run(t); - return NULL; - } -#endif - -void thread_start(Thread *t, ThreadProc *proc, void *user_data) { thread_start_with_stack(t, proc, user_data, 0); } - -void thread_start_with_stack(Thread *t, ThreadProc *proc, void *user_data, isize stack_size) { - GB_ASSERT(!t->is_running.load()); - GB_ASSERT(proc != NULL); - t->proc = proc; - t->user_data = user_data; - t->stack_size = stack_size; +gb_internal void thread_init_and_start(ThreadPool *pool, Thread *t, isize idx) { + thread_init(pool, t, idx); + isize stack_size = 0; #if defined(GB_SYSTEM_WINDOWS) t->win32_handle = CreateThread(NULL, stack_size, internal_thread_proc, t, 0, NULL); @@ -429,23 +548,17 @@ void thread_start_with_stack(Thread *t, ThreadProc *proc, void *user_data, isize { pthread_attr_t attr; pthread_attr_init(&attr); + defer (pthread_attr_destroy(&attr)); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); if (stack_size != 0) { pthread_attr_setstacksize(&attr, stack_size); } pthread_create(&t->posix_handle, &attr, internal_thread_proc, t); - pthread_attr_destroy(&attr); } #endif - - semaphore_wait(t->semaphore); } -void thread_join(Thread *t) { - if (!t->is_running.load()) { - return; - } - +gb_internal void thread_join_and_destroy(Thread *t) { #if defined(GB_SYSTEM_WINDOWS) WaitForSingleObject(t->win32_handle, INFINITE); CloseHandle(t->win32_handle); @@ -454,12 +567,11 @@ void thread_join(Thread *t) { pthread_join(t->posix_handle, NULL); t->posix_handle = 0; #endif - t->is_running.store(false); + + gb_free(heap_allocator(), t->queue); } -bool thread_is_running(Thread const *t) { return t->is_running.load(); } - -void thread_set_name(Thread *t, char const *name) { +gb_internal void thread_set_name(Thread *t, char const *name) { #if defined(GB_COMPILER_MSVC) #pragma pack(push, 8) typedef struct { @@ -494,3 +606,207 @@ void thread_set_name(Thread *t, char const *name) { #endif } +#if defined(GB_SYSTEM_LINUX) +#include +#include + +gb_internal void futex_signal(Futex *addr) { + int ret = syscall(SYS_futex, addr, FUTEX_WAKE | FUTEX_PRIVATE_FLAG, 1, NULL, NULL, 0); + if (ret == -1) { + perror("Futex wake"); + GB_PANIC("Failed in futex wake!\n"); + } +} + +gb_internal void futex_broadcast(Futex *addr) { + int ret = syscall(SYS_futex, addr, FUTEX_WAKE | FUTEX_PRIVATE_FLAG, INT32_MAX, NULL, NULL, 0); + if (ret == -1) { + perror("Futex wake"); + GB_PANIC("Failed in futex wake!\n"); + } +} + +gb_internal void futex_wait(Futex *addr, Footex val) { + for (;;) { + int ret = syscall(SYS_futex, addr, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, val, NULL, NULL, 0); + if (ret == -1) { + if (errno != EAGAIN) { + perror("Futex wait"); + GB_PANIC("Failed in futex wait!\n"); + } else { + return; + } + } else if (ret == 0) { + if (*addr != val) { + return; + } + } + } +} + +#elif defined(GB_SYSTEM_FREEBSD) + +#include +#include + +gb_internal void futex_signal(Futex *addr) { + _umtx_op(addr, UMTX_OP_WAKE, 1, 0, 0); +} + +gb_internal void futex_broadcast(Futex *addr) { + _umtx_op(addr, UMTX_OP_WAKE, INT32_MAX, 0, 0); +} + +gb_internal void futex_wait(Futex *addr, Footex val) { + for (;;) { + int ret = _umtx_op(addr, UMTX_OP_WAIT_UINT, val, 0, NULL); + if (ret == 0) { + if (errno == ETIMEDOUT || errno == EINTR) { + continue; + } + + perror("Futex wait"); + GB_PANIC("Failed in futex wait!\n"); + } else if (ret == 0) { + if (*addr != val) { + return; + } + } + } +} + +#elif defined(GB_SYSTEM_OPENBSD) + +#include + +gb_internal void futex_signal(Futex *f) { + for (;;) { + int ret = futex((volatile uint32_t *)f, FUTEX_WAKE | FUTEX_PRIVATE_FLAG, 1, NULL, NULL); + if (ret == -1) { + if (errno == ETIMEDOUT || errno == EINTR) { + continue; + } + + perror("Futex wake"); + GB_PANIC("futex wake fail"); + } else if (ret == 1) { + return; + } + } +} + + +gb_internal void futex_broadcast(Futex *f) { + for (;;) { + int ret = futex((volatile uint32_t *)f, FUTEX_WAKE | FUTEX_PRIVATE_FLAG, INT32_MAX, NULL, NULL); + if (ret == -1) { + if (errno == ETIMEDOUT || errno == EINTR) { + continue; + } + + perror("Futex wake"); + GB_PANIC("futex wake fail"); + } else if (ret == 1) { + return; + } + } +} + +gb_internal void futex_wait(Futex *f, Footex val) { + for (;;) { + int ret = futex((volatile uint32_t *)f, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, val, NULL, NULL); + if (ret == -1) { + if (*f != val) { + return; + } + + if (errno == ETIMEDOUT || errno == EINTR) { + continue; + } + + perror("Futex wait"); + GB_PANIC("Failed in futex wait!\n"); + } + } +} + +#elif defined(GB_SYSTEM_OSX) + +#define UL_COMPARE_AND_WAIT 0x00000001 +#define ULF_NO_ERRNO 0x01000000 + +extern "C" int __ulock_wait(uint32_t operation, void *addr, uint64_t value, uint32_t timeout); /* timeout is specified in microseconds */ +extern "C" int __ulock_wake(uint32_t operation, void *addr, uint64_t wake_value); + +gb_internal void futex_signal(Futex *f) { + for (;;) { + int ret = __ulock_wake(UL_COMPARE_AND_WAIT | ULF_NO_ERRNO, f, 0); + if (ret >= 0) { + return; + } + if (ret == -EINTR || ret == -EFAULT) { + continue; + } + if (ret == -ENOENT) { + return; + } + GB_PANIC("Failed in futex wake!\n"); + } +} + +gb_internal void futex_broadcast(Futex *f) { + for (;;) { + enum { ULF_WAKE_ALL = 0x00000100 }; + int ret = __ulock_wake(UL_COMPARE_AND_WAIT | ULF_NO_ERRNO | ULF_WAKE_ALL, f, 0); + if (ret == 0) { + return; + } + if (ret == -EINTR || ret == -EFAULT) { + continue; + } + if (ret == -ENOENT) { + return; + } + GB_PANIC("Failed in futex wake!\n"); + } +} + +gb_internal void futex_wait(Futex *f, Footex val) { + for (;;) { + int ret = __ulock_wait(UL_COMPARE_AND_WAIT | ULF_NO_ERRNO, f, val, 0); + if (ret >= 0) { + if (*f != val) { + return; + } + continue; + } + if (ret == -EINTR || ret == -EFAULT) {continue; + ret = -ret; + } + if (ret == -ENOENT) { + return; + } + + GB_PANIC("Failed in futex wait!\n"); + } +} +#elif defined(GB_SYSTEM_WINDOWS) + +gb_internal void futex_signal(Futex *f) { + WakeByAddressSingle(f); +} + +gb_internal void futex_broadcast(Futex *f) { + WakeByAddressAll(f); +} + +gb_internal void futex_wait(Futex *f, Footex val) { + do { + WaitOnAddress(f, (void *)&val, sizeof(val), INFINITE); + } while (f->load() == val); +} +#endif + +#if defined(GB_SYSTEM_WINDOWS) + #pragma warning(pop) +#endif \ No newline at end of file diff --git a/src/timings.cpp b/src/timings.cpp index 72abe7ea1..baa8b80da 100644 --- a/src/timings.cpp +++ b/src/timings.cpp @@ -13,13 +13,13 @@ struct Timings { #if defined(GB_SYSTEM_WINDOWS) -u64 win32_time_stamp_time_now(void) { +gb_internal u64 win32_time_stamp_time_now(void) { LARGE_INTEGER counter; QueryPerformanceCounter(&counter); return counter.QuadPart; } -u64 win32_time_stamp__freq(void) { +gb_internal u64 win32_time_stamp__freq(void) { gb_local_persist LARGE_INTEGER win32_perf_count_freq = {0}; if (!win32_perf_count_freq.QuadPart) { QueryPerformanceFrequency(&win32_perf_count_freq); @@ -33,11 +33,11 @@ u64 win32_time_stamp__freq(void) { #include -u64 osx_time_stamp_time_now(void) { +gb_internal u64 osx_time_stamp_time_now(void) { return mach_absolute_time(); } -u64 osx_time_stamp__freq(void) { +gb_internal u64 osx_time_stamp__freq(void) { mach_timebase_info_data_t data; data.numer = 0; data.denom = 0; @@ -55,14 +55,14 @@ u64 osx_time_stamp__freq(void) { #include -u64 unix_time_stamp_time_now(void) { +gb_internal u64 unix_time_stamp_time_now(void) { struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); return (ts.tv_sec * 1000000000) + ts.tv_nsec; } -u64 unix_time_stamp__freq(void) { +gb_internal u64 unix_time_stamp__freq(void) { gb_local_persist u64 freq = 0; if (freq == 0) { @@ -80,7 +80,7 @@ u64 unix_time_stamp__freq(void) { #error Implement system #endif -u64 time_stamp_time_now(void) { +gb_internal u64 time_stamp_time_now(void) { #if defined(GB_SYSTEM_WINDOWS) return win32_time_stamp_time_now(); #elif defined(GB_SYSTEM_OSX) @@ -92,7 +92,7 @@ u64 time_stamp_time_now(void) { #endif } -u64 time_stamp__freq(void) { +gb_internal u64 time_stamp__freq(void) { #if defined(GB_SYSTEM_WINDOWS) return win32_time_stamp__freq(); #elif defined(GB_SYSTEM_OSX) @@ -104,44 +104,44 @@ u64 time_stamp__freq(void) { #endif } -TimeStamp make_time_stamp(String const &label) { +gb_internal TimeStamp make_time_stamp(String const &label) { TimeStamp ts = {0}; ts.start = time_stamp_time_now(); ts.label = label; return ts; } -void timings_init(Timings *t, String const &label, isize buffer_size) { +gb_internal void timings_init(Timings *t, String const &label, isize buffer_size) { array_init(&t->sections, heap_allocator(), 0, buffer_size); t->total = make_time_stamp(label); t->freq = time_stamp__freq(); } -void timings_destroy(Timings *t) { +gb_internal void timings_destroy(Timings *t) { array_free(&t->sections); } -void timings__stop_current_section(Timings *t) { +gb_internal void timings__stop_current_section(Timings *t) { if (t->sections.count > 0) { t->sections[t->sections.count-1].finish = time_stamp_time_now(); } } -void timings_start_section(Timings *t, String const &label) { +gb_internal void timings_start_section(Timings *t, String const &label) { timings__stop_current_section(t); array_add(&t->sections, make_time_stamp(label)); } -f64 time_stamp_as_s(TimeStamp const &ts, u64 freq) { +gb_internal f64 time_stamp_as_s(TimeStamp const &ts, u64 freq) { GB_ASSERT_MSG(ts.finish >= ts.start, "time_stamp_as_ms - %.*s", LIT(ts.label)); return cast(f64)(ts.finish - ts.start) / cast(f64)freq; } -f64 time_stamp_as_ms(TimeStamp const &ts, u64 freq) { +gb_internal f64 time_stamp_as_ms(TimeStamp const &ts, u64 freq) { return 1000.0*time_stamp_as_s(ts, freq); } -f64 time_stamp_as_us(TimeStamp const &ts, u64 freq) { +gb_internal f64 time_stamp_as_us(TimeStamp const &ts, u64 freq) { return 1000000.0*time_stamp_as_s(ts, freq); } @@ -160,7 +160,7 @@ enum TimingUnit { char const *timing_unit_strings[TimingUnit_COUNT] = {"s", "ms", "us"}; -f64 time_stamp(TimeStamp const &ts, u64 freq, TimingUnit unit) { +gb_internal f64 time_stamp(TimeStamp const &ts, u64 freq, TimingUnit unit) { switch (unit) { case TimingUnit_Millisecond: return time_stamp_as_ms(ts, freq); case TimingUnit_Microsecond: return time_stamp_as_us(ts, freq); @@ -169,7 +169,7 @@ f64 time_stamp(TimeStamp const &ts, u64 freq, TimingUnit unit) { } } -void timings_print_all(Timings *t, TimingUnit unit = TimingUnit_Millisecond, bool timings_are_finalized = false) { +gb_internal void timings_print_all(Timings *t, TimingUnit unit = TimingUnit_Millisecond, bool timings_are_finalized = false) { isize const SPACES_LEN = 256; char SPACES[SPACES_LEN+1] = {0}; gb_memset(SPACES, ' ', SPACES_LEN); diff --git a/src/tokenizer.cpp b/src/tokenizer.cpp index 40bc5c220..17a396b9f 100644 --- a/src/tokenizer.cpp +++ b/src/tokenizer.cpp @@ -54,7 +54,7 @@ TOKEN_KIND(Token__AssignOpEnd, ""), \ TOKEN_KIND(Token_Increment, "++"), \ TOKEN_KIND(Token_Decrement, "--"), \ TOKEN_KIND(Token_ArrowRight,"->"), \ - TOKEN_KIND(Token_Undef, "---"), \ + TOKEN_KIND(Token_Uninit, "---"), \ \ TOKEN_KIND(Token__ComparisonBegin, ""), \ TOKEN_KIND(Token_CmpEq, "=="), \ @@ -151,10 +151,10 @@ gb_global isize max_keyword_size = 11; gb_global bool keyword_indices[16] = {}; -gb_inline u32 keyword_hash(u8 const *text, isize len) { +gb_internal gb_inline u32 keyword_hash(u8 const *text, isize len) { return fnv32a(text, len); } -void add_keyword_hash_entry(String const &s, TokenKind kind) { +gb_internal void add_keyword_hash_entry(String const &s, TokenKind kind) { max_keyword_size = gb_max(max_keyword_size, s.len); keyword_indices[s.len] = true; @@ -169,7 +169,7 @@ void add_keyword_hash_entry(String const &s, TokenKind kind) { entry->kind = kind; entry->text = s; } -void init_keyword_hash_table(void) { +gb_internal void init_keyword_hash_table(void) { for (i32 kind = Token__KeywordBegin+1; kind < Token__KeywordEnd; kind++) { add_keyword_hash_entry(token_strings[kind], cast(TokenKind)kind); } @@ -191,8 +191,8 @@ void init_keyword_hash_table(void) { gb_global Array global_file_path_strings; // index is file id gb_global Array global_files; // index is file id -String get_file_path_string(i32 index); -struct AstFile *thread_safe_get_ast_file_from_id(i32 index); +gb_internal String get_file_path_string(i32 index); +gb_internal struct AstFile *thread_safe_get_ast_file_from_id(i32 index); struct TokenPos { i32 file_id; @@ -201,7 +201,7 @@ struct TokenPos { i32 column; // starting at 1 }; -i32 token_pos_cmp(TokenPos const &a, TokenPos const &b) { +gb_internal i32 token_pos_cmp(TokenPos const &a, TokenPos const &b) { if (a.offset != b.offset) { return (a.offset < b.offset) ? -1 : +1; } @@ -214,12 +214,12 @@ i32 token_pos_cmp(TokenPos const &a, TokenPos const &b) { return string_compare(get_file_path_string(a.file_id), get_file_path_string(b.file_id)); } -bool operator==(TokenPos const &a, TokenPos const &b) { return token_pos_cmp(a, b) == 0; } -bool operator!=(TokenPos const &a, TokenPos const &b) { return token_pos_cmp(a, b) != 0; } -bool operator< (TokenPos const &a, TokenPos const &b) { return token_pos_cmp(a, b) < 0; } -bool operator<=(TokenPos const &a, TokenPos const &b) { return token_pos_cmp(a, b) <= 0; } -bool operator> (TokenPos const &a, TokenPos const &b) { return token_pos_cmp(a, b) > 0; } -bool operator>=(TokenPos const &a, TokenPos const &b) { return token_pos_cmp(a, b) >= 0; } +gb_internal gb_inline bool operator==(TokenPos const &a, TokenPos const &b) { return token_pos_cmp(a, b) == 0; } +gb_internal gb_inline bool operator!=(TokenPos const &a, TokenPos const &b) { return token_pos_cmp(a, b) != 0; } +gb_internal gb_inline bool operator< (TokenPos const &a, TokenPos const &b) { return token_pos_cmp(a, b) < 0; } +gb_internal gb_inline bool operator<=(TokenPos const &a, TokenPos const &b) { return token_pos_cmp(a, b) <= 0; } +gb_internal gb_inline bool operator> (TokenPos const &a, TokenPos const &b) { return token_pos_cmp(a, b) > 0; } +gb_internal gb_inline bool operator>=(TokenPos const &a, TokenPos const &b) { return token_pos_cmp(a, b) >= 0; } TokenPos token_pos_add_column(TokenPos pos) { @@ -243,36 +243,36 @@ struct Token { Token empty_token = {Token_Invalid}; Token blank_token = {Token_Ident, 0, {cast(u8 *)"_", 1}}; -Token make_token_ident(String s) { +gb_internal Token make_token_ident(String s) { Token t = {Token_Ident, 0, s}; return t; } -Token make_token_ident(char const *s) { +gb_internal Token make_token_ident(char const *s) { Token t = {Token_Ident, 0, make_string_c(s)}; return t; } -bool token_is_newline(Token const &tok) { +gb_internal bool token_is_newline(Token const &tok) { return tok.kind == Token_Semicolon && tok.string == "\n"; } -gb_inline bool token_is_literal(TokenKind t) { +gb_internal gb_inline bool token_is_literal(TokenKind t) { return gb_is_between(t, Token__LiteralBegin+1, Token__LiteralEnd-1); } -gb_inline bool token_is_operator(TokenKind t) { +gb_internal gb_inline bool token_is_operator(TokenKind t) { return gb_is_between(t, Token__OperatorBegin+1, Token__OperatorEnd-1); } -gb_inline bool token_is_keyword(TokenKind t) { +gb_internal gb_inline bool token_is_keyword(TokenKind t) { return gb_is_between(t, Token__KeywordBegin+1, Token__KeywordEnd-1); } -gb_inline bool token_is_comparison(TokenKind t) { +gb_internal gb_inline bool token_is_comparison(TokenKind t) { return gb_is_between(t, Token__ComparisonBegin+1, Token__ComparisonEnd-1); } -gb_inline bool token_is_shift(TokenKind t) { +gb_internal gb_inline bool token_is_shift(TokenKind t) { return t == Token_Shl || t == Token_Shr; } -gb_inline void print_token(Token t) { gb_printf("%.*s\n", LIT(t.string)); } +gb_internal gb_inline void print_token(Token t) { gb_printf("%.*s\n", LIT(t.string)); } #include "error.cpp" @@ -309,7 +309,7 @@ struct Tokenizer { }; -void tokenizer_err(Tokenizer *t, char const *msg, ...) { +gb_internal void tokenizer_err(Tokenizer *t, char const *msg, ...) { va_list va; i32 column = t->column_minus_one+1; if (column < 1) { @@ -328,7 +328,7 @@ void tokenizer_err(Tokenizer *t, char const *msg, ...) { t->error_count++; } -void tokenizer_err(Tokenizer *t, TokenPos const &pos, char const *msg, ...) { +gb_internal void tokenizer_err(Tokenizer *t, TokenPos const &pos, char const *msg, ...) { va_list va; i32 column = t->column_minus_one+1; if (column < 1) { @@ -342,7 +342,7 @@ void tokenizer_err(Tokenizer *t, TokenPos const &pos, char const *msg, ...) { t->error_count++; } -void advance_to_next_rune(Tokenizer *t) { +gb_internal void advance_to_next_rune(Tokenizer *t) { if (t->curr_rune == '\n') { t->column_minus_one = -1; t->line_count++; @@ -372,7 +372,7 @@ void advance_to_next_rune(Tokenizer *t) { } } -void init_tokenizer_with_data(Tokenizer *t, String const &fullpath, void const *data, isize size) { +gb_internal void init_tokenizer_with_data(Tokenizer *t, String const &fullpath, void const *data, isize size) { t->fullpath = fullpath; t->line_count = 1; @@ -386,7 +386,7 @@ void init_tokenizer_with_data(Tokenizer *t, String const &fullpath, void const * } } -TokenizerInitError loaded_file_error_map_to_tokenizer[LoadedFile_COUNT] = { +gb_global TokenizerInitError loaded_file_error_map_to_tokenizer[LoadedFile_COUNT] = { TokenizerInit_None, /*LoadedFile_None*/ TokenizerInit_Empty, /*LoadedFile_Empty*/ TokenizerInit_FileTooLarge, /*LoadedFile_FileTooLarge*/ @@ -395,7 +395,7 @@ TokenizerInitError loaded_file_error_map_to_tokenizer[LoadedFile_COUNT] = { TokenizerInit_Permission, /*LoadedFile_Permission*/ }; -TokenizerInitError init_tokenizer_from_fullpath(Tokenizer *t, String const &fullpath, bool copy_file_contents) { +gb_internal TokenizerInitError init_tokenizer_from_fullpath(Tokenizer *t, String const &fullpath, bool copy_file_contents) { LoadedFileError file_err = load_file_32( alloc_cstring(temporary_allocator(), fullpath), &t->loaded_file, @@ -416,7 +416,7 @@ TokenizerInitError init_tokenizer_from_fullpath(Tokenizer *t, String const &full return err; } -gb_inline i32 digit_value(Rune r) { +gb_internal gb_inline i32 digit_value(Rune r) { switch (r) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': return r - '0'; @@ -428,20 +428,20 @@ gb_inline i32 digit_value(Rune r) { return 16; // NOTE(bill): Larger than highest possible } -gb_inline void scan_mantissa(Tokenizer *t, i32 base) { +gb_internal gb_inline void scan_mantissa(Tokenizer *t, i32 base) { while (digit_value(t->curr_rune) < base || t->curr_rune == '_') { advance_to_next_rune(t); } } -u8 peek_byte(Tokenizer *t, isize offset=0) { +gb_internal u8 peek_byte(Tokenizer *t, isize offset=0) { if (t->read_curr+offset < t->end) { return t->read_curr[offset]; } return 0; } -void scan_number_to_token(Tokenizer *t, Token *token, bool seen_decimal_point) { +gb_internal void scan_number_to_token(Tokenizer *t, Token *token, bool seen_decimal_point) { token->kind = Token_Integer; token->string = {t->curr, 1}; token->pos.file_id = t->curr_file_id; @@ -566,7 +566,7 @@ end: } -bool scan_escape(Tokenizer *t) { +gb_internal bool scan_escape(Tokenizer *t) { isize len = 0; u32 base = 0, max = 0, x = 0; @@ -633,13 +633,13 @@ bool scan_escape(Tokenizer *t) { } -gb_inline void tokenizer_skip_line(Tokenizer *t) { +gb_internal gb_inline void tokenizer_skip_line(Tokenizer *t) { while (t->curr_rune != '\n' && t->curr_rune != GB_RUNE_EOF) { advance_to_next_rune(t); } } -gb_inline void tokenizer_skip_whitespace(Tokenizer *t, bool on_newline) { +gb_internal gb_inline void tokenizer_skip_whitespace(Tokenizer *t, bool on_newline) { if (on_newline) { for (;;) { switch (t->curr_rune) { @@ -666,7 +666,7 @@ gb_inline void tokenizer_skip_whitespace(Tokenizer *t, bool on_newline) { } } -void tokenizer_get_token(Tokenizer *t, Token *token, int repeat=0) { +gb_internal void tokenizer_get_token(Tokenizer *t, Token *token, int repeat=0) { tokenizer_skip_whitespace(t, t->insert_semicolon); token->kind = Token_Invalid; @@ -917,7 +917,7 @@ void tokenizer_get_token(Tokenizer *t, Token *token, int repeat=0) { token->kind = Token_Decrement; if (t->curr_rune == '-') { advance_to_next_rune(t); - token->kind = Token_Undef; + token->kind = Token_Uninit; } break; case '>': @@ -1078,7 +1078,7 @@ semicolon_check:; case Token_Imag: case Token_Rune: case Token_String: - case Token_Undef: + case Token_Uninit: /*fallthrough*/ case Token_Question: case Token_Pointer: diff --git a/src/types.cpp b/src/types.cpp index 28628fd97..385ca926d 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -83,7 +83,7 @@ enum BasicKind { Basic_UntypedString, Basic_UntypedRune, Basic_UntypedNil, - Basic_UntypedUndef, + Basic_UntypedUninit, Basic_COUNT, @@ -149,6 +149,7 @@ struct TypeStruct { bool are_offsets_being_processed : 1; bool is_packed : 1; bool is_raw_union : 1; + bool is_no_copy : 1; bool is_poly_specialized : 1; }; @@ -287,7 +288,7 @@ enum TypeKind { Type_Count, }; -String const type_strings[] = { +gb_global String const type_strings[] = { {cast(u8 *)"Invalid", gb_size_of("Invalid")}, #define TYPE_KIND(k, ...) {cast(u8 *)#k, gb_size_of(#k)-1}, TYPE_KINDS @@ -368,10 +369,10 @@ enum : int { }; -bool is_type_comparable(Type *t); -bool is_type_simple_compare(Type *t); +gb_internal bool is_type_comparable(Type *t); +gb_internal bool is_type_simple_compare(Type *t); -u32 type_info_flags_of_type(Type *type) { +gb_internal u32 type_info_flags_of_type(Type *type) { if (type == nullptr) { return 0; } @@ -396,14 +397,14 @@ struct Selection { u8 swizzle_indices; // 2 bits per component, representing which swizzle index bool pseudo_field; }; -Selection empty_selection = {0}; +gb_global Selection const empty_selection = {0}; -Selection make_selection(Entity *entity, Array index, bool indirect) { +gb_internal Selection make_selection(Entity *entity, Array index, bool indirect) { Selection s = {entity, index, indirect}; return s; } -void selection_add_index(Selection *s, isize index) { +gb_internal void selection_add_index(Selection *s, isize index) { // IMPORTANT NOTE(bill): this requires a stretchy buffer/dynamic array so it requires some form // of heap allocation // TODO(bill): Find a way to use a backing buffer for initial use as the general case is probably .count<3 @@ -413,7 +414,7 @@ void selection_add_index(Selection *s, isize index) { array_add(&s->index, cast(i32)index); } -Selection selection_combine(Selection const &lhs, Selection const &rhs) { +gb_internal Selection selection_combine(Selection const &lhs, Selection const &rhs) { Selection new_sel = lhs; new_sel.indirect = lhs.indirect || rhs.indirect; new_sel.index = array_make(heap_allocator(), lhs.index.count+rhs.index.count); @@ -422,7 +423,7 @@ Selection selection_combine(Selection const &lhs, Selection const &rhs) { return new_sel; } -Selection sub_selection(Selection const &sel, isize offset) { +gb_internal Selection sub_selection(Selection const &sel, isize offset) { Selection res = {}; res.index.data = sel.index.data + offset; res.index.count = gb_max(sel.index.count - offset, 0); @@ -430,16 +431,6 @@ Selection sub_selection(Selection const &sel, isize offset) { return res; } -Selection sub_selection_with_length(Selection const &sel, isize offset, isize len) { - Selection res = {}; - res.index.data = sel.index.data + offset; - res.index.count = gb_max(len, gb_max(sel.index.count - offset, 0)); - res.index.capacity = res.index.count; - return res; -} - - - gb_global Type basic_types[] = { {Type_Basic, {Basic_Invalid, 0, 0, STR_LIT("invalid type")}}, @@ -524,7 +515,7 @@ gb_global Type basic_types[] = { {Type_Basic, {Basic_UntypedString, BasicFlag_String | BasicFlag_Untyped, 0, STR_LIT("untyped string")}}, {Type_Basic, {Basic_UntypedRune, BasicFlag_Integer | BasicFlag_Untyped, 0, STR_LIT("untyped rune")}}, {Type_Basic, {Basic_UntypedNil, BasicFlag_Untyped, 0, STR_LIT("untyped nil")}}, - {Type_Basic, {Basic_UntypedUndef, BasicFlag_Untyped, 0, STR_LIT("untyped undefined")}}, + {Type_Basic, {Basic_UntypedUninit, BasicFlag_Untyped, 0, STR_LIT("untyped uninitialized")}}, }; // gb_global Type basic_type_aliases[] = { @@ -598,7 +589,7 @@ gb_global Type *t_untyped_quaternion = &basic_types[Basic_UntypedQuaternion]; gb_global Type *t_untyped_string = &basic_types[Basic_UntypedString]; gb_global Type *t_untyped_rune = &basic_types[Basic_UntypedRune]; gb_global Type *t_untyped_nil = &basic_types[Basic_UntypedNil]; -gb_global Type *t_untyped_undef = &basic_types[Basic_UntypedUndef]; +gb_global Type *t_untyped_uninit = &basic_types[Basic_UntypedUninit]; @@ -633,7 +624,7 @@ gb_global Type *t_type_info_array = nullptr; gb_global Type *t_type_info_enumerated_array = nullptr; gb_global Type *t_type_info_dynamic_array = nullptr; gb_global Type *t_type_info_slice = nullptr; -gb_global Type *t_type_info_tuple = nullptr; +gb_global Type *t_type_info_parameters = nullptr; gb_global Type *t_type_info_struct = nullptr; gb_global Type *t_type_info_union = nullptr; gb_global Type *t_type_info_enum = nullptr; @@ -662,7 +653,7 @@ gb_global Type *t_type_info_array_ptr = nullptr; gb_global Type *t_type_info_enumerated_array_ptr = nullptr; gb_global Type *t_type_info_dynamic_array_ptr = nullptr; gb_global Type *t_type_info_slice_ptr = nullptr; -gb_global Type *t_type_info_tuple_ptr = nullptr; +gb_global Type *t_type_info_parameters_ptr = nullptr; gb_global Type *t_type_info_struct_ptr = nullptr; gb_global Type *t_type_info_union_ptr = nullptr; gb_global Type *t_type_info_enum_ptr = nullptr; @@ -732,45 +723,48 @@ gb_global RecursiveMutex g_type_mutex; struct TypePath; -i64 type_size_of (Type *t); -i64 type_align_of (Type *t); -i64 type_offset_of (Type *t, i32 index); -gbString type_to_string (Type *type, bool shorthand=true); -gbString type_to_string (Type *type, gbAllocator allocator, bool shorthand=true); -i64 type_size_of_internal(Type *t, TypePath *path); -void init_map_internal_types(Type *type); -Type * bit_set_to_int(Type *t); -bool are_types_identical(Type *x, Type *y); +gb_internal i64 type_size_of (Type *t); +gb_internal i64 type_align_of (Type *t); +gb_internal i64 type_offset_of (Type *t, i32 index); +gb_internal gbString type_to_string (Type *type, bool shorthand=true); +gb_internal gbString type_to_string (Type *type, gbAllocator allocator, bool shorthand=true); +gb_internal i64 type_size_of_internal(Type *t, TypePath *path); +gb_internal void init_map_internal_types(Type *type); +gb_internal Type * bit_set_to_int(Type *t); +gb_internal bool are_types_identical(Type *x, Type *y); -bool is_type_pointer(Type *t); -bool is_type_soa_pointer(Type *t); -bool is_type_proc(Type *t); -bool is_type_slice(Type *t); -bool is_type_integer(Type *t); -bool type_set_offsets(Type *t); -Type *base_type(Type *t); +gb_internal bool is_type_pointer(Type *t); +gb_internal bool is_type_soa_pointer(Type *t); +gb_internal bool is_type_proc(Type *t); +gb_internal bool is_type_slice(Type *t); +gb_internal bool is_type_integer(Type *t); +gb_internal bool type_set_offsets(Type *t); +gb_internal Type *base_type(Type *t); -i64 type_size_of_internal(Type *t, TypePath *path); -i64 type_align_of_internal(Type *t, TypePath *path); +gb_internal i64 type_size_of_internal(Type *t, TypePath *path); +gb_internal i64 type_align_of_internal(Type *t, TypePath *path); // IMPORTANT TODO(bill): SHould this TypePath code be removed since type cycle checking is handled much earlier on? struct TypePath { + RecursiveMutex mutex; Array path; // Entity_TypeName; bool failure; }; -void type_path_init(TypePath *tp) { +gb_internal void type_path_init(TypePath *tp) { tp->path.allocator = heap_allocator(); } -void type_path_free(TypePath *tp) { +gb_internal void type_path_free(TypePath *tp) { + mutex_lock(&tp->mutex); array_free(&tp->path); + mutex_unlock(&tp->mutex); } -void type_path_print_illegal_cycle(TypePath *tp, isize start_index) { +gb_internal void type_path_print_illegal_cycle(TypePath *tp, isize start_index) { GB_ASSERT(tp != nullptr); GB_ASSERT(start_index < tp->path.count); @@ -789,13 +783,15 @@ void type_path_print_illegal_cycle(TypePath *tp, isize start_index) { base_type(e->type)->failure = true; } -bool type_path_push(TypePath *tp, Type *t) { +gb_internal bool type_path_push(TypePath *tp, Type *t) { GB_ASSERT(tp != nullptr); if (t->kind != Type_Named) { return false; } Entity *e = t->Named.type_name; + mutex_lock(&tp->mutex); + for (isize i = 0; i < tp->path.count; i++) { Entity *p = tp->path[i]; if (p == e) { @@ -804,12 +800,19 @@ bool type_path_push(TypePath *tp, Type *t) { } array_add(&tp->path, e); + + mutex_unlock(&tp->mutex); + return true; } -void type_path_pop(TypePath *tp) { - if (tp != nullptr && tp->path.count > 0) { - array_pop(&tp->path); +gb_internal void type_path_pop(TypePath *tp) { + if (tp != nullptr) { + mutex_lock(&tp->mutex); + if (tp->path.count > 0) { + array_pop(&tp->path); + } + mutex_unlock(&tp->mutex); } } @@ -817,19 +820,22 @@ void type_path_pop(TypePath *tp) { #define FAILURE_SIZE 0 #define FAILURE_ALIGNMENT 0 -void init_type_mutex(void) { - mutex_init(&g_type_mutex); +gb_internal bool type_ptr_set_update(PtrSet *s, Type *t) { + if (ptr_set_exists(s, t)) { + return true; + } + ptr_set_add(s, t); + return false; } -bool type_ptr_set_exists(PtrSet *s, Type *t) { +gb_internal bool type_ptr_set_exists(PtrSet *s, Type *t) { if (ptr_set_exists(s, t)) { return true; } // TODO(bill, 2019-10-05): This is very slow and it's probably a lot // faster to cache types correctly - for_array(i, s->entries) { - Type *f = s->entries[i].ptr; + for (Type *f : *s) { if (are_types_identical(t, f)) { ptr_set_add(s, t); return true; @@ -839,7 +845,7 @@ bool type_ptr_set_exists(PtrSet *s, Type *t) { return false; } -Type *base_type(Type *t) { +gb_internal Type *base_type(Type *t) { for (;;) { if (t == nullptr) { break; @@ -855,7 +861,7 @@ Type *base_type(Type *t) { return t; } -Type *base_enum_type(Type *t) { +gb_internal Type *base_enum_type(Type *t) { Type *bt = base_type(t); if (bt != nullptr && bt->kind == Type_Enum) { @@ -864,7 +870,7 @@ Type *base_enum_type(Type *t) { return t; } -Type *core_type(Type *t) { +gb_internal Type *core_type(Type *t) { for (;;) { if (t == nullptr) { break; @@ -886,14 +892,14 @@ Type *core_type(Type *t) { return t; } -void set_base_type(Type *t, Type *base) { +gb_internal void set_base_type(Type *t, Type *base) { if (t && t->kind == Type_Named) { t->Named.base = base; } } -Type *alloc_type(TypeKind kind) { +gb_internal Type *alloc_type(TypeKind kind) { // gbAllocator a = heap_allocator(); gbAllocator a = permanent_allocator(); Type *t = gb_alloc_item(a, Type); @@ -905,7 +911,7 @@ Type *alloc_type(TypeKind kind) { } -Type *alloc_type_generic(Scope *scope, i64 id, String name, Type *specialized) { +gb_internal Type *alloc_type_generic(Scope *scope, i64 id, String name, Type *specialized) { Type *t = alloc_type(Type_Generic); t->Generic.id = id; t->Generic.name = name; @@ -914,26 +920,26 @@ Type *alloc_type_generic(Scope *scope, i64 id, String name, Type *specialized) { return t; } -Type *alloc_type_pointer(Type *elem) { +gb_internal Type *alloc_type_pointer(Type *elem) { Type *t = alloc_type(Type_Pointer); t->Pointer.elem = elem; return t; } -Type *alloc_type_multi_pointer(Type *elem) { +gb_internal Type *alloc_type_multi_pointer(Type *elem) { Type *t = alloc_type(Type_MultiPointer); t->MultiPointer.elem = elem; return t; } -Type *alloc_type_soa_pointer(Type *elem) { +gb_internal Type *alloc_type_soa_pointer(Type *elem) { Type *t = alloc_type(Type_SoaPointer); t->SoaPointer.elem = elem; return t; } -Type *alloc_type_array(Type *elem, i64 count, Type *generic_count = nullptr) { +gb_internal Type *alloc_type_array(Type *elem, i64 count, Type *generic_count = nullptr) { if (generic_count != nullptr) { Type *t = alloc_type(Type_Array); t->Array.elem = elem; @@ -947,7 +953,7 @@ Type *alloc_type_array(Type *elem, i64 count, Type *generic_count = nullptr) { return t; } -Type *alloc_type_matrix(Type *elem, i64 row_count, i64 column_count, Type *generic_row_count = nullptr, Type *generic_column_count = nullptr) { +gb_internal Type *alloc_type_matrix(Type *elem, i64 row_count, i64 column_count, Type *generic_row_count = nullptr, Type *generic_column_count = nullptr) { if (generic_row_count != nullptr || generic_column_count != nullptr) { Type *t = alloc_type(Type_Matrix); t->Matrix.elem = elem; @@ -965,7 +971,7 @@ Type *alloc_type_matrix(Type *elem, i64 row_count, i64 column_count, Type *gener } -Type *alloc_type_enumerated_array(Type *elem, Type *index, ExactValue const *min_value, ExactValue const *max_value, TokenKind op) { +gb_internal Type *alloc_type_enumerated_array(Type *elem, Type *index, ExactValue const *min_value, ExactValue const *max_value, TokenKind op) { Type *t = alloc_type(Type_EnumeratedArray); t->EnumeratedArray.elem = elem; t->EnumeratedArray.index = index; @@ -980,37 +986,37 @@ Type *alloc_type_enumerated_array(Type *elem, Type *index, ExactValue const *min } -Type *alloc_type_slice(Type *elem) { +gb_internal Type *alloc_type_slice(Type *elem) { Type *t = alloc_type(Type_Slice); t->Array.elem = elem; return t; } -Type *alloc_type_dynamic_array(Type *elem) { +gb_internal Type *alloc_type_dynamic_array(Type *elem) { Type *t = alloc_type(Type_DynamicArray); t->DynamicArray.elem = elem; return t; } -Type *alloc_type_struct() { +gb_internal Type *alloc_type_struct() { Type *t = alloc_type(Type_Struct); return t; } -Type *alloc_type_union() { +gb_internal Type *alloc_type_union() { Type *t = alloc_type(Type_Union); return t; } -Type *alloc_type_enum() { +gb_internal Type *alloc_type_enum() { Type *t = alloc_type(Type_Enum); t->Enum.min_value = gb_alloc_item(permanent_allocator(), ExactValue); t->Enum.max_value = gb_alloc_item(permanent_allocator(), ExactValue); return t; } -Type *alloc_type_relative_pointer(Type *pointer_type, Type *base_integer) { +gb_internal Type *alloc_type_relative_pointer(Type *pointer_type, Type *base_integer) { GB_ASSERT(is_type_pointer(pointer_type)); GB_ASSERT(is_type_integer(base_integer)); Type *t = alloc_type(Type_RelativePointer); @@ -1019,7 +1025,7 @@ Type *alloc_type_relative_pointer(Type *pointer_type, Type *base_integer) { return t; } -Type *alloc_type_relative_slice(Type *slice_type, Type *base_integer) { +gb_internal Type *alloc_type_relative_slice(Type *slice_type, Type *base_integer) { GB_ASSERT(is_type_slice(slice_type)); GB_ASSERT(is_type_integer(base_integer)); Type *t = alloc_type(Type_RelativeSlice); @@ -1028,7 +1034,7 @@ Type *alloc_type_relative_slice(Type *slice_type, Type *base_integer) { return t; } -Type *alloc_type_named(String name, Type *base, Entity *type_name) { +gb_internal Type *alloc_type_named(String name, Type *base, Entity *type_name) { Type *t = alloc_type(Type_Named); t->Named.name = name; t->Named.base = base; @@ -1039,7 +1045,7 @@ Type *alloc_type_named(String name, Type *base, Entity *type_name) { return t; } -bool is_calling_convention_none(ProcCallingConvention calling_convention) { +gb_internal bool is_calling_convention_none(ProcCallingConvention calling_convention) { switch (calling_convention) { case ProcCC_None: case ProcCC_InlineAsm: @@ -1048,7 +1054,7 @@ bool is_calling_convention_none(ProcCallingConvention calling_convention) { return false; } -bool is_calling_convention_odin(ProcCallingConvention calling_convention) { +gb_internal bool is_calling_convention_odin(ProcCallingConvention calling_convention) { switch (calling_convention) { case ProcCC_Odin: case ProcCC_Contextless: @@ -1057,12 +1063,12 @@ bool is_calling_convention_odin(ProcCallingConvention calling_convention) { return false; } -Type *alloc_type_tuple() { +gb_internal Type *alloc_type_tuple() { Type *t = alloc_type(Type_Tuple); return t; } -Type *alloc_type_proc(Scope *scope, Type *params, isize param_count, Type *results, isize result_count, bool variadic, ProcCallingConvention calling_convention) { +gb_internal Type *alloc_type_proc(Scope *scope, Type *params, isize param_count, Type *results, isize result_count, bool variadic, ProcCallingConvention calling_convention) { Type *t = alloc_type(Type_Proc); if (variadic) { @@ -1087,26 +1093,17 @@ Type *alloc_type_proc(Scope *scope, Type *params, isize param_count, Type *resul return t; } -bool is_type_valid_for_keys(Type *t); +gb_internal bool is_type_valid_for_keys(Type *t); -Type *alloc_type_map(i64 count, Type *key, Type *value) { - if (key != nullptr) { - GB_ASSERT(value != nullptr); - } - Type *t = alloc_type(Type_Map); - t->Map.key = key; - t->Map.value = value; - return t; -} -Type *alloc_type_bit_set() { +gb_internal Type *alloc_type_bit_set() { Type *t = alloc_type(Type_BitSet); return t; } -Type *alloc_type_simd_vector(i64 count, Type *elem, Type *generic_count=nullptr) { +gb_internal Type *alloc_type_simd_vector(i64 count, Type *elem, Type *generic_count=nullptr) { Type *t = alloc_type(Type_SimdVector); t->SimdVector.count = count; t->SimdVector.elem = elem; @@ -1119,7 +1116,7 @@ Type *alloc_type_simd_vector(i64 count, Type *elem, Type *generic_count=nullptr) //////////////////////////////////////////////////////////////// -Type *type_deref(Type *t, bool allow_multi_pointer=false) { +gb_internal Type *type_deref(Type *t, bool allow_multi_pointer=false) { if (t != nullptr) { Type *bt = base_type(t); if (bt == nullptr) { @@ -1146,27 +1143,14 @@ Type *type_deref(Type *t, bool allow_multi_pointer=false) { return t; } -bool is_type_named(Type *t) { +gb_internal bool is_type_named(Type *t) { if (t->kind == Type_Basic) { return true; } return t->kind == Type_Named; } -bool is_type_named_alias(Type *t) { - if (!is_type_named(t)) { - return false; - } - Entity *e = t->Named.type_name; - if (e == nullptr) { - return false; - } - if (e->kind != Entity_TypeName) { - return false; - } - return e->TypeName.is_type_alias; -} -bool is_type_boolean(Type *t) { +gb_internal bool is_type_boolean(Type *t) { // t = core_type(t); t = base_type(t); if (t->kind == Type_Basic) { @@ -1174,7 +1158,7 @@ bool is_type_boolean(Type *t) { } return false; } -bool is_type_integer(Type *t) { +gb_internal bool is_type_integer(Type *t) { // t = core_type(t); t = base_type(t); if (t->kind == Type_Basic) { @@ -1182,7 +1166,7 @@ bool is_type_integer(Type *t) { } return false; } -bool is_type_integer_like(Type *t) { +gb_internal bool is_type_integer_like(Type *t) { t = core_type(t); if (t->kind == Type_Basic) { return (t->Basic.flags & (BasicFlag_Integer|BasicFlag_Boolean)) != 0; @@ -1196,7 +1180,7 @@ bool is_type_integer_like(Type *t) { return false; } -bool is_type_unsigned(Type *t) { +gb_internal bool is_type_unsigned(Type *t) { t = base_type(t); // t = core_type(t); if (t->kind == Type_Basic) { @@ -1204,7 +1188,7 @@ bool is_type_unsigned(Type *t) { } return false; } -bool is_type_integer_128bit(Type *t) { +gb_internal bool is_type_integer_128bit(Type *t) { // t = core_type(t); t = base_type(t); if (t->kind == Type_Basic) { @@ -1212,7 +1196,7 @@ bool is_type_integer_128bit(Type *t) { } return false; } -bool is_type_rune(Type *t) { +gb_internal bool is_type_rune(Type *t) { // t = core_type(t); t = base_type(t); if (t->kind == Type_Basic) { @@ -1220,7 +1204,7 @@ bool is_type_rune(Type *t) { } return false; } -bool is_type_numeric(Type *t) { +gb_internal bool is_type_numeric(Type *t) { // t = core_type(t); t = base_type(t); if (t->kind == Type_Basic) { @@ -1234,21 +1218,21 @@ bool is_type_numeric(Type *t) { } return false; } -bool is_type_string(Type *t) { +gb_internal bool is_type_string(Type *t) { t = base_type(t); if (t->kind == Type_Basic) { return (t->Basic.flags & BasicFlag_String) != 0; } return false; } -bool is_type_cstring(Type *t) { +gb_internal bool is_type_cstring(Type *t) { t = base_type(t); if (t->kind == Type_Basic) { return t->Basic.kind == Basic_cstring; } return false; } -bool is_type_typed(Type *t) { +gb_internal bool is_type_typed(Type *t) { t = base_type(t); if (t == nullptr) { return false; @@ -1258,7 +1242,7 @@ bool is_type_typed(Type *t) { } return true; } -bool is_type_untyped(Type *t) { +gb_internal bool is_type_untyped(Type *t) { t = base_type(t); if (t == nullptr) { return false; @@ -1268,7 +1252,7 @@ bool is_type_untyped(Type *t) { } return false; } -bool is_type_ordered(Type *t) { +gb_internal bool is_type_ordered(Type *t) { t = core_type(t); switch (t->kind) { case Type_Basic: @@ -1280,7 +1264,7 @@ bool is_type_ordered(Type *t) { } return false; } -bool is_type_ordered_numeric(Type *t) { +gb_internal bool is_type_ordered_numeric(Type *t) { t = core_type(t); switch (t->kind) { case Type_Basic: @@ -1288,7 +1272,7 @@ bool is_type_ordered_numeric(Type *t) { } return false; } -bool is_type_constant_type(Type *t) { +gb_internal bool is_type_constant_type(Type *t) { t = core_type(t); if (t->kind == Type_Basic) { return (t->Basic.flags & BasicFlag_ConstantType) != 0; @@ -1301,110 +1285,89 @@ bool is_type_constant_type(Type *t) { } return false; } -bool is_type_float(Type *t) { +gb_internal bool is_type_float(Type *t) { t = core_type(t); if (t->kind == Type_Basic) { return (t->Basic.flags & BasicFlag_Float) != 0; } return false; } -bool is_type_complex(Type *t) { +gb_internal bool is_type_complex(Type *t) { t = core_type(t); if (t->kind == Type_Basic) { return (t->Basic.flags & BasicFlag_Complex) != 0; } return false; } -bool is_type_quaternion(Type *t) { +gb_internal bool is_type_quaternion(Type *t) { t = core_type(t); if (t->kind == Type_Basic) { return (t->Basic.flags & BasicFlag_Quaternion) != 0; } return false; } -bool is_type_complex_or_quaternion(Type *t) { +gb_internal bool is_type_complex_or_quaternion(Type *t) { t = core_type(t); if (t->kind == Type_Basic) { return (t->Basic.flags & (BasicFlag_Complex|BasicFlag_Quaternion)) != 0; } return false; } -bool is_type_f16(Type *t) { - t = core_type(t); - if (t->kind == Type_Basic) { - return t->Basic.kind == Basic_f16; - } - return false; -} -bool is_type_f32(Type *t) { - t = core_type(t); - if (t->kind == Type_Basic) { - return t->Basic.kind == Basic_f32; - } - return false; -} -bool is_type_f64(Type *t) { - t = core_type(t); - if (t->kind == Type_Basic) { - return t->Basic.kind == Basic_f64; - } - return false; -} -bool is_type_pointer(Type *t) { +gb_internal bool is_type_pointer(Type *t) { t = base_type(t); if (t->kind == Type_Basic) { return (t->Basic.flags & BasicFlag_Pointer) != 0; } return t->kind == Type_Pointer; } -bool is_type_soa_pointer(Type *t) { +gb_internal bool is_type_soa_pointer(Type *t) { t = base_type(t); return t->kind == Type_SoaPointer; } -bool is_type_multi_pointer(Type *t) { +gb_internal bool is_type_multi_pointer(Type *t) { t = base_type(t); return t->kind == Type_MultiPointer; } -bool is_type_internally_pointer_like(Type *t) { +gb_internal bool is_type_internally_pointer_like(Type *t) { return is_type_pointer(t) || is_type_multi_pointer(t) || is_type_cstring(t) || is_type_proc(t); } -bool is_type_tuple(Type *t) { +gb_internal bool is_type_tuple(Type *t) { t = base_type(t); return t->kind == Type_Tuple; } -bool is_type_uintptr(Type *t) { +gb_internal bool is_type_uintptr(Type *t) { if (t->kind == Type_Basic) { return (t->Basic.kind == Basic_uintptr); } return false; } -bool is_type_rawptr(Type *t) { +gb_internal bool is_type_rawptr(Type *t) { if (t->kind == Type_Basic) { return t->Basic.kind == Basic_rawptr; } return false; } -bool is_type_u8(Type *t) { +gb_internal bool is_type_u8(Type *t) { if (t->kind == Type_Basic) { return t->Basic.kind == Basic_u8; } return false; } -bool is_type_array(Type *t) { +gb_internal bool is_type_array(Type *t) { t = base_type(t); return t->kind == Type_Array; } -bool is_type_enumerated_array(Type *t) { +gb_internal bool is_type_enumerated_array(Type *t) { t = base_type(t); return t->kind == Type_EnumeratedArray; } -bool is_type_matrix(Type *t) { +gb_internal bool is_type_matrix(Type *t) { t = base_type(t); return t->kind == Type_Matrix; } -i64 matrix_align_of(Type *t, struct TypePath *tp) { +gb_internal i64 matrix_align_of(Type *t, struct TypePath *tp) { t = base_type(t); GB_ASSERT(t->kind == Type_Matrix); @@ -1440,7 +1403,7 @@ i64 matrix_align_of(Type *t, struct TypePath *tp) { } -i64 matrix_type_stride_in_bytes(Type *t, struct TypePath *tp) { +gb_internal i64 matrix_type_stride_in_bytes(Type *t, struct TypePath *tp) { t = base_type(t); GB_ASSERT(t->kind == Type_Matrix); if (t->Matrix.stride_in_bytes != 0) { @@ -1469,7 +1432,7 @@ i64 matrix_type_stride_in_bytes(Type *t, struct TypePath *tp) { return stride_in_bytes; } -i64 matrix_type_stride_in_elems(Type *t) { +gb_internal i64 matrix_type_stride_in_elems(Type *t) { t = base_type(t); GB_ASSERT(t->kind == Type_Matrix); i64 stride = matrix_type_stride_in_bytes(t, nullptr); @@ -1477,7 +1440,7 @@ i64 matrix_type_stride_in_elems(Type *t) { } -i64 matrix_type_total_internal_elems(Type *t) { +gb_internal i64 matrix_type_total_internal_elems(Type *t) { t = base_type(t); GB_ASSERT(t->kind == Type_Matrix); i64 size = type_size_of(t); @@ -1485,7 +1448,7 @@ i64 matrix_type_total_internal_elems(Type *t) { return size/gb_max(elem_size, 1); } -i64 matrix_indices_to_offset(Type *t, i64 row_index, i64 column_index) { +gb_internal i64 matrix_indices_to_offset(Type *t, i64 row_index, i64 column_index) { t = base_type(t); GB_ASSERT(t->kind == Type_Matrix); GB_ASSERT(0 <= row_index && row_index < t->Matrix.row_count); @@ -1495,7 +1458,7 @@ i64 matrix_indices_to_offset(Type *t, i64 row_index, i64 column_index) { return row_index + stride_elems*column_index; } -i64 matrix_row_major_index_to_offset(Type *t, i64 index) { +gb_internal i64 matrix_row_major_index_to_offset(Type *t, i64 index) { t = base_type(t); GB_ASSERT(t->kind == Type_Matrix); @@ -1503,7 +1466,7 @@ i64 matrix_row_major_index_to_offset(Type *t, i64 index) { i64 column_index = index%t->Matrix.column_count; return matrix_indices_to_offset(t, row_index, column_index); } -i64 matrix_column_major_index_to_offset(Type *t, i64 index) { +gb_internal i64 matrix_column_major_index_to_offset(Type *t, i64 index) { t = base_type(t); GB_ASSERT(t->kind == Type_Matrix); @@ -1513,13 +1476,13 @@ i64 matrix_column_major_index_to_offset(Type *t, i64 index) { } -bool is_matrix_square(Type *t) { +gb_internal bool is_matrix_square(Type *t) { t = base_type(t); GB_ASSERT(t->kind == Type_Matrix); return t->Matrix.row_count == t->Matrix.column_count; } -bool is_type_valid_for_matrix_elems(Type *t) { +gb_internal bool is_type_valid_for_matrix_elems(Type *t) { t = base_type(t); if (is_type_integer(t)) { return true; @@ -1534,32 +1497,28 @@ bool is_type_valid_for_matrix_elems(Type *t) { return false; } -bool is_type_dynamic_array(Type *t) { +gb_internal bool is_type_dynamic_array(Type *t) { t = base_type(t); return t->kind == Type_DynamicArray; } -bool is_type_slice(Type *t) { +gb_internal bool is_type_slice(Type *t) { t = base_type(t); return t->kind == Type_Slice; } -bool is_type_proc(Type *t) { +gb_internal bool is_type_proc(Type *t) { t = base_type(t); return t->kind == Type_Proc; } -bool is_type_asm_proc(Type *t) { +gb_internal bool is_type_asm_proc(Type *t) { t = base_type(t); return t->kind == Type_Proc && t->Proc.calling_convention == ProcCC_InlineAsm; } -bool is_type_poly_proc(Type *t) { - t = base_type(t); - return t->kind == Type_Proc && t->Proc.is_polymorphic; -} -bool is_type_simd_vector(Type *t) { +gb_internal bool is_type_simd_vector(Type *t) { t = base_type(t); return t->kind == Type_SimdVector; } -Type *base_array_type(Type *t) { +gb_internal Type *base_array_type(Type *t) { Type *bt = base_type(t); if (is_type_array(bt)) { return bt->Array.elem; @@ -1573,49 +1532,49 @@ Type *base_array_type(Type *t) { return t; } -bool is_type_generic(Type *t) { +gb_internal bool is_type_generic(Type *t) { t = base_type(t); return t->kind == Type_Generic; } -bool is_type_relative_pointer(Type *t) { +gb_internal bool is_type_relative_pointer(Type *t) { t = base_type(t); return t->kind == Type_RelativePointer; } -bool is_type_relative_slice(Type *t) { +gb_internal bool is_type_relative_slice(Type *t) { t = base_type(t); return t->kind == Type_RelativeSlice; } -bool is_type_u8_slice(Type *t) { +gb_internal bool is_type_u8_slice(Type *t) { t = base_type(t); if (t->kind == Type_Slice) { return is_type_u8(t->Slice.elem); } return false; } -bool is_type_u8_array(Type *t) { +gb_internal bool is_type_u8_array(Type *t) { t = base_type(t); if (t->kind == Type_Array) { return is_type_u8(t->Array.elem); } return false; } -bool is_type_u8_ptr(Type *t) { +gb_internal bool is_type_u8_ptr(Type *t) { t = base_type(t); if (t->kind == Type_Pointer) { return is_type_u8(t->Slice.elem); } return false; } -bool is_type_u8_multi_ptr(Type *t) { +gb_internal bool is_type_u8_multi_ptr(Type *t) { t = base_type(t); if (t->kind == Type_MultiPointer) { return is_type_u8(t->Slice.elem); } return false; } -bool is_type_rune_array(Type *t) { +gb_internal bool is_type_rune_array(Type *t) { t = base_type(t); if (t->kind == Type_Array) { return is_type_rune(t->Array.elem); @@ -1624,10 +1583,10 @@ bool is_type_rune_array(Type *t) { } -bool is_type_array_like(Type *t) { +gb_internal bool is_type_array_like(Type *t) { return is_type_array(t) || is_type_enumerated_array(t); } -i64 get_array_type_count(Type *t) { +gb_internal i64 get_array_type_count(Type *t) { Type *bt = base_type(t); if (bt->kind == Type_Array) { return bt->Array.count; @@ -1642,7 +1601,7 @@ i64 get_array_type_count(Type *t) { -Type *core_array_type(Type *t) { +gb_internal Type *core_array_type(Type *t) { for (;;) { t = base_array_type(t); switch (t->kind) { @@ -1657,7 +1616,7 @@ Type *core_array_type(Type *t) { } } -i32 type_math_rank(Type *t) { +gb_internal i32 type_math_rank(Type *t) { i32 rank = 0; for (;;) { t = base_type(t); @@ -1677,7 +1636,7 @@ i32 type_math_rank(Type *t) { } -Type *base_complex_elem_type(Type *t) { +gb_internal Type *base_complex_elem_type(Type *t) { t = core_type(t); if (t->kind == Type_Basic) { switch (t->Basic.kind) { @@ -1695,37 +1654,41 @@ Type *base_complex_elem_type(Type *t) { return t_invalid; } -bool is_type_struct(Type *t) { +gb_internal bool is_type_struct(Type *t) { t = base_type(t); return t->kind == Type_Struct; } -bool is_type_union(Type *t) { +gb_internal bool is_type_union(Type *t) { t = base_type(t); return t->kind == Type_Union; } -bool is_type_soa_struct(Type *t) { +gb_internal bool is_type_soa_struct(Type *t) { t = base_type(t); return t->kind == Type_Struct && t->Struct.soa_kind != StructSoa_None; } -bool is_type_raw_union(Type *t) { +gb_internal bool is_type_raw_union(Type *t) { t = base_type(t); return (t->kind == Type_Struct && t->Struct.is_raw_union); } -bool is_type_enum(Type *t) { +gb_internal bool is_type_no_copy(Type *t) { + t = base_type(t); + return (t->kind == Type_Struct && t->Struct.is_no_copy); +} +gb_internal bool is_type_enum(Type *t) { t = base_type(t); return (t->kind == Type_Enum); } -bool is_type_bit_set(Type *t) { +gb_internal bool is_type_bit_set(Type *t) { t = base_type(t); return (t->kind == Type_BitSet); } -bool is_type_map(Type *t) { +gb_internal bool is_type_map(Type *t) { t = base_type(t); return t->kind == Type_Map; } -bool is_type_union_maybe_pointer(Type *t) { +gb_internal bool is_type_union_maybe_pointer(Type *t) { t = base_type(t); if (t->kind == Type_Union && t->Union.variants.count == 1) { Type *v = t->Union.variants[0]; @@ -1735,7 +1698,7 @@ bool is_type_union_maybe_pointer(Type *t) { } -bool is_type_union_maybe_pointer_original_alignment(Type *t) { +gb_internal bool is_type_union_maybe_pointer_original_alignment(Type *t) { t = base_type(t); if (t->kind == Type_Union && t->Union.variants.count == 1) { Type *v = t->Union.variants[0]; @@ -1748,7 +1711,7 @@ bool is_type_union_maybe_pointer_original_alignment(Type *t) { -bool is_type_endian_big(Type *t) { +gb_internal bool is_type_endian_big(Type *t) { t = core_type(t); if (t->kind == Type_Basic) { if (t->Basic.flags & BasicFlag_EndianBig) { @@ -1764,7 +1727,7 @@ bool is_type_endian_big(Type *t) { } return build_context.endian_kind == TargetEndian_Big; } -bool is_type_endian_little(Type *t) { +gb_internal bool is_type_endian_little(Type *t) { t = core_type(t); if (t->kind == Type_Basic) { if (t->Basic.flags & BasicFlag_EndianLittle) { @@ -1781,7 +1744,7 @@ bool is_type_endian_little(Type *t) { return build_context.endian_kind == TargetEndian_Little; } -bool is_type_endian_platform(Type *t) { +gb_internal bool is_type_endian_platform(Type *t) { t = core_type(t); if (t->kind == Type_Basic) { return (t->Basic.flags & (BasicFlag_EndianLittle|BasicFlag_EndianBig)) == 0; @@ -1793,10 +1756,10 @@ bool is_type_endian_platform(Type *t) { return false; } -bool types_have_same_internal_endian(Type *a, Type *b) { +gb_internal bool types_have_same_internal_endian(Type *a, Type *b) { return is_type_endian_little(a) == is_type_endian_little(b); } -bool is_type_endian_specific(Type *t) { +gb_internal bool is_type_endian_specific(Type *t) { t = core_type(t); if (t->kind == Type_BitSet) { t = bit_set_to_int(t); @@ -1834,7 +1797,7 @@ bool is_type_endian_specific(Type *t) { return false; } -bool is_type_dereferenceable(Type *t) { +gb_internal bool is_type_dereferenceable(Type *t) { if (is_type_rawptr(t)) { return false; } @@ -1843,7 +1806,7 @@ bool is_type_dereferenceable(Type *t) { -bool is_type_different_to_arch_endianness(Type *t) { +gb_internal bool is_type_different_to_arch_endianness(Type *t) { switch (build_context.endian_kind) { case TargetEndian_Little: return !is_type_endian_little(t); @@ -1853,7 +1816,7 @@ bool is_type_different_to_arch_endianness(Type *t) { return false; } -Type *integer_endian_type_to_platform_type(Type *t) { +gb_internal Type *integer_endian_type_to_platform_type(Type *t) { t = core_type(t); if (t->kind == Type_BitSet) { t = bit_set_to_int(t); @@ -1893,35 +1856,31 @@ Type *integer_endian_type_to_platform_type(Type *t) { -bool is_type_any(Type *t) { +gb_internal bool is_type_any(Type *t) { t = base_type(t); return (t->kind == Type_Basic && t->Basic.kind == Basic_any); } -bool is_type_typeid(Type *t) { +gb_internal bool is_type_typeid(Type *t) { t = base_type(t); return (t->kind == Type_Basic && t->Basic.kind == Basic_typeid); } -bool is_type_untyped_nil(Type *t) { +gb_internal bool is_type_untyped_nil(Type *t) { t = base_type(t); - return (t->kind == Type_Basic && t->Basic.kind == Basic_UntypedNil); + // NOTE(bill): checking for `nil` or `---` at once is just to improve the error handling + return (t->kind == Type_Basic && (t->Basic.kind == Basic_UntypedNil || t->Basic.kind == Basic_UntypedUninit)); } -bool is_type_untyped_undef(Type *t) { +gb_internal bool is_type_untyped_uninit(Type *t) { t = base_type(t); - return (t->kind == Type_Basic && t->Basic.kind == Basic_UntypedUndef); + // NOTE(bill): checking for `nil` or `---` at once is just to improve the error handling + return (t->kind == Type_Basic && t->Basic.kind == Basic_UntypedUninit); } - -bool is_type_empty_union(Type *t) { +gb_internal bool is_type_empty_union(Type *t) { t = base_type(t); return t->kind == Type_Union && t->Union.variants.count == 0; } -bool is_type_empty_struct(Type *t) { - t = base_type(t); - return t->kind == Type_Struct && !t->Struct.is_raw_union && t->Struct.fields.count == 0; -} - -bool is_type_valid_for_keys(Type *t) { +gb_internal bool is_type_valid_for_keys(Type *t) { t = core_type(t); if (t->kind == Type_Generic) { return true; @@ -1932,7 +1891,7 @@ bool is_type_valid_for_keys(Type *t) { return type_size_of(t) > 0 && is_type_comparable(t); } -bool is_type_valid_bit_set_elem(Type *t) { +gb_internal bool is_type_valid_bit_set_elem(Type *t) { if (is_type_enum(t)) { return true; } @@ -1943,7 +1902,7 @@ bool is_type_valid_bit_set_elem(Type *t) { return false; } -Type *bit_set_to_int(Type *t) { +gb_internal Type *bit_set_to_int(Type *t) { GB_ASSERT(is_type_bit_set(t)); Type *bt = base_type(t); Type *underlying = bt->BitSet.underlying; @@ -1964,7 +1923,7 @@ Type *bit_set_to_int(Type *t) { return nullptr; } -bool is_type_valid_vector_elem(Type *t) { +gb_internal bool is_type_valid_vector_elem(Type *t) { t = base_type(t); if (t->kind == Type_Basic) { if (t->Basic.flags & BasicFlag_EndianLittle) { @@ -1987,7 +1946,7 @@ bool is_type_valid_vector_elem(Type *t) { } -bool is_type_indexable(Type *t) { +gb_internal bool is_type_indexable(Type *t) { Type *bt = base_type(t); switch (bt->kind) { case Type_Basic: @@ -2009,7 +1968,7 @@ bool is_type_indexable(Type *t) { return false; } -bool is_type_sliceable(Type *t) { +gb_internal bool is_type_sliceable(Type *t) { Type *bt = base_type(t); switch (bt->kind) { case Type_Basic: @@ -2029,7 +1988,7 @@ bool is_type_sliceable(Type *t) { } -bool is_type_polymorphic_record(Type *t) { +gb_internal bool is_type_polymorphic_record(Type *t) { t = base_type(t); if (t->kind == Type_Struct) { return t->Struct.is_polymorphic; @@ -2039,7 +1998,7 @@ bool is_type_polymorphic_record(Type *t) { return false; } -Scope *polymorphic_record_parent_scope(Type *t) { +gb_internal Scope *polymorphic_record_parent_scope(Type *t) { t = base_type(t); if (is_type_polymorphic_record(t)) { if (t->kind == Type_Struct) { @@ -2051,7 +2010,7 @@ Scope *polymorphic_record_parent_scope(Type *t) { return nullptr; } -bool is_type_polymorphic_record_specialized(Type *t) { +gb_internal bool is_type_polymorphic_record_specialized(Type *t) { t = base_type(t); if (t->kind == Type_Struct) { return t->Struct.is_poly_specialized; @@ -2061,7 +2020,7 @@ bool is_type_polymorphic_record_specialized(Type *t) { return false; } -bool is_type_polymorphic_record_unspecialized(Type *t) { +gb_internal bool is_type_polymorphic_record_unspecialized(Type *t) { t = base_type(t); if (t->kind == Type_Struct) { return t->Struct.is_polymorphic && !t->Struct.is_poly_specialized; @@ -2071,7 +2030,7 @@ bool is_type_polymorphic_record_unspecialized(Type *t) { return false; } -TypeTuple *get_record_polymorphic_params(Type *t) { +gb_internal TypeTuple *get_record_polymorphic_params(Type *t) { t = base_type(t); switch (t->kind) { case Type_Struct: @@ -2089,7 +2048,7 @@ TypeTuple *get_record_polymorphic_params(Type *t) { } -bool is_type_polymorphic(Type *t, bool or_specialized=false) { +gb_internal bool is_type_polymorphic(Type *t, bool or_specialized=false) { if (t == nullptr) { return false; } @@ -2149,8 +2108,12 @@ bool is_type_polymorphic(Type *t, bool or_specialized=false) { return is_type_polymorphic(t->Matrix.elem, or_specialized); case Type_Tuple: - for_array(i, t->Tuple.variables) { - if (is_type_polymorphic(t->Tuple.variables[i]->type, or_specialized)) { + for (Entity *e : t->Tuple.variables) { + if (e->kind == Entity_Constant) { + if (e->Constant.value.kind != ExactValue_Invalid) { + return or_specialized; + } + } else if (is_type_polymorphic(e->type, or_specialized)) { return true; } } @@ -2160,7 +2123,6 @@ bool is_type_polymorphic(Type *t, bool or_specialized=false) { if (t->Proc.is_polymorphic) { return true; } - #if 1 if (t->Proc.param_count > 0 && is_type_polymorphic(t->Proc.params, or_specialized)) { return true; @@ -2169,7 +2131,6 @@ bool is_type_polymorphic(Type *t, bool or_specialized=false) { is_type_polymorphic(t->Proc.results, or_specialized)) { return true; } - #endif break; case Type_Enum: @@ -2248,11 +2209,7 @@ bool is_type_polymorphic(Type *t, bool or_specialized=false) { } -bool type_has_undef(Type *t) { - return true; -} - -bool type_has_nil(Type *t) { +gb_internal bool type_has_nil(Type *t) { t = base_type(t); switch (t->kind) { case Type_Basic: { @@ -2297,7 +2254,7 @@ bool type_has_nil(Type *t) { return false; } -bool elem_type_can_be_constant(Type *t) { +gb_internal bool elem_type_can_be_constant(Type *t) { t = base_type(t); if (t == t_invalid) { return false; @@ -2308,7 +2265,7 @@ bool elem_type_can_be_constant(Type *t) { return true; } -bool is_type_lock_free(Type *t) { +gb_internal bool is_type_lock_free(Type *t) { t = core_type(t); if (t == t_invalid) { return false; @@ -2320,7 +2277,7 @@ bool is_type_lock_free(Type *t) { -bool is_type_comparable(Type *t) { +gb_internal bool is_type_comparable(Type *t) { t = base_type(t); switch (t->kind) { case Type_Basic: @@ -2359,9 +2316,6 @@ bool is_type_comparable(Type *t) { return true; case Type_Struct: - if (type_size_of(t) == 0) { - return false; - } if (t->Struct.soa_kind != StructSoa_None) { return false; } @@ -2377,9 +2331,6 @@ bool is_type_comparable(Type *t) { return true; case Type_Union: - if (type_size_of(t) == 0) { - return false; - } for_array(i, t->Union.variants) { Type *v = t->Union.variants[i]; if (!is_type_comparable(v)) { @@ -2395,7 +2346,7 @@ bool is_type_comparable(Type *t) { } // NOTE(bill): type can be easily compared using memcmp -bool is_type_simple_compare(Type *t) { +gb_internal bool is_type_simple_compare(Type *t) { t = core_type(t); switch (t->kind) { case Type_Array: @@ -2450,7 +2401,7 @@ bool is_type_simple_compare(Type *t) { return false; } -bool is_type_load_safe(Type *type) { +gb_internal bool is_type_load_safe(Type *type) { GB_ASSERT(type != nullptr); type = core_type(core_array_type(type)); switch (type->kind) { @@ -2501,7 +2452,7 @@ bool is_type_load_safe(Type *type) { return false; } -String lookup_subtype_polymorphic_field(Type *dst, Type *src) { +gb_internal String lookup_subtype_polymorphic_field(Type *dst, Type *src) { Type *prev_src = src; // Type *prev_dst = dst; src = base_type(type_deref(src)); @@ -2532,7 +2483,7 @@ String lookup_subtype_polymorphic_field(Type *dst, Type *src) { return str_lit(""); } -bool lookup_subtype_polymorphic_selection(Type *dst, Type *src, Selection *sel) { +gb_internal bool lookup_subtype_polymorphic_selection(Type *dst, Type *src, Selection *sel) { Type *prev_src = src; // Type *prev_dst = dst; src = base_type(type_deref(src)); @@ -2571,31 +2522,9 @@ bool lookup_subtype_polymorphic_selection(Type *dst, Type *src, Selection *sel) +gb_internal bool are_types_identical_internal(Type *x, Type *y, bool check_tuple_names); -Type *strip_type_aliasing(Type *x) { - if (x == nullptr) { - return x; - } - if (x->kind == Type_Named) { - Entity *e = x->Named.type_name; - if (e != nullptr && e->kind == Entity_TypeName && e->TypeName.is_type_alias) { - return x->Named.base; - } - } - return x; -} - -bool are_types_identical_internal(Type *x, Type *y, bool check_tuple_names); - -bool are_types_identical(Type *x, Type *y) { - return are_types_identical_internal(x, y, false); -} -bool are_types_identical_unique_tuples(Type *x, Type *y) { - return are_types_identical_internal(x, y, true); -} - - -bool are_types_identical_internal(Type *x, Type *y, bool check_tuple_names) { +gb_internal bool are_types_identical(Type *x, Type *y) { if (x == y) { return true; } @@ -2605,193 +2534,215 @@ bool are_types_identical_internal(Type *x, Type *y, bool check_tuple_names) { return false; } - x = strip_type_aliasing(x); - y = strip_type_aliasing(y); + if (x->kind == Type_Named) { + Entity *e = x->Named.type_name; + if (e->TypeName.is_type_alias) { + x = x->Named.base; + } + } + if (y->kind == Type_Named) { + Entity *e = y->Named.type_name; + if (e->TypeName.is_type_alias) { + y = y->Named.base; + } + } + if (x->kind != y->kind) { + return false; + } + + return are_types_identical_internal(x, y, false); +} +gb_internal bool are_types_identical_unique_tuples(Type *x, Type *y) { + if (x == y) { + return true; + } + + if (!x | !y) { + return false; + } + + if (x->kind == Type_Named) { + Entity *e = x->Named.type_name; + if (e->TypeName.is_type_alias) { + x = x->Named.base; + } + } + if (y->kind == Type_Named) { + Entity *e = y->Named.type_name; + if (e->TypeName.is_type_alias) { + y = y->Named.base; + } + } + if (x->kind != y->kind) { + return false; + } + + return are_types_identical_internal(x, y, true); +} + + +gb_internal bool are_types_identical_internal(Type *x, Type *y, bool check_tuple_names) { + if (x == y) { + return true; + } + + if (!x | !y) { + return false; + } + + #if 0 + if (x->kind == Type_Named) { + Entity *e = x->Named.type_name; + if (e->TypeName.is_type_alias) { + x = x->Named.base; + } + } + if (y->kind == Type_Named) { + Entity *e = y->Named.type_name; + if (e->TypeName.is_type_alias) { + y = y->Named.base; + } + } + if (x->kind != y->kind) { + return false; + } + #endif switch (x->kind) { case Type_Generic: - if (y->kind == Type_Generic) { - return are_types_identical(x->Generic.specialized, y->Generic.specialized); - } - break; + return are_types_identical(x->Generic.specialized, y->Generic.specialized); case Type_Basic: - if (y->kind == Type_Basic) { - return x->Basic.kind == y->Basic.kind; - } - break; + return x->Basic.kind == y->Basic.kind; case Type_EnumeratedArray: - if (y->kind == Type_EnumeratedArray) { - return are_types_identical(x->EnumeratedArray.index, y->EnumeratedArray.index) && - are_types_identical(x->EnumeratedArray.elem, y->EnumeratedArray.elem); - } - break; + return are_types_identical(x->EnumeratedArray.index, y->EnumeratedArray.index) && + are_types_identical(x->EnumeratedArray.elem, y->EnumeratedArray.elem); case Type_Array: - if (y->kind == Type_Array) { - return (x->Array.count == y->Array.count) && are_types_identical(x->Array.elem, y->Array.elem); - } - break; + return (x->Array.count == y->Array.count) && are_types_identical(x->Array.elem, y->Array.elem); case Type_Matrix: - if (y->kind == Type_Matrix) { - return x->Matrix.row_count == y->Matrix.row_count && - x->Matrix.column_count == y->Matrix.column_count && - are_types_identical(x->Matrix.elem, y->Matrix.elem); - } - break; + return x->Matrix.row_count == y->Matrix.row_count && + x->Matrix.column_count == y->Matrix.column_count && + are_types_identical(x->Matrix.elem, y->Matrix.elem); case Type_DynamicArray: - if (y->kind == Type_DynamicArray) { - return are_types_identical(x->DynamicArray.elem, y->DynamicArray.elem); - } - break; + return are_types_identical(x->DynamicArray.elem, y->DynamicArray.elem); case Type_Slice: - if (y->kind == Type_Slice) { - return are_types_identical(x->Slice.elem, y->Slice.elem); - } - break; + return are_types_identical(x->Slice.elem, y->Slice.elem); case Type_BitSet: - if (y->kind == Type_BitSet) { - return are_types_identical(x->BitSet.elem, y->BitSet.elem) && - are_types_identical(x->BitSet.underlying, y->BitSet.underlying) && - x->BitSet.lower == y->BitSet.lower && - x->BitSet.upper == y->BitSet.upper; - } - break; + return are_types_identical(x->BitSet.elem, y->BitSet.elem) && + are_types_identical(x->BitSet.underlying, y->BitSet.underlying) && + x->BitSet.lower == y->BitSet.lower && + x->BitSet.upper == y->BitSet.upper; case Type_Enum: return x == y; // NOTE(bill): All enums are unique case Type_Union: - if (y->kind == Type_Union) { - if (x->Union.variants.count == y->Union.variants.count && - x->Union.custom_align == y->Union.custom_align && - x->Union.kind == y->Union.kind) { - // NOTE(bill): zeroth variant is nullptr - for_array(i, x->Union.variants) { - if (!are_types_identical(x->Union.variants[i], y->Union.variants[i])) { - return false; - } + if (x->Union.variants.count == y->Union.variants.count && + x->Union.custom_align == y->Union.custom_align && + x->Union.kind == y->Union.kind) { + // NOTE(bill): zeroth variant is nullptr + for_array(i, x->Union.variants) { + if (!are_types_identical(x->Union.variants[i], y->Union.variants[i])) { + return false; } - return true; } + return true; } break; case Type_Struct: - if (y->kind == Type_Struct) { - if (x->Struct.is_raw_union == y->Struct.is_raw_union && - x->Struct.fields.count == y->Struct.fields.count && - x->Struct.is_packed == y->Struct.is_packed && - x->Struct.custom_align == y->Struct.custom_align && - x->Struct.soa_kind == y->Struct.soa_kind && - x->Struct.soa_count == y->Struct.soa_count && - are_types_identical(x->Struct.soa_elem, y->Struct.soa_elem)) { - // TODO(bill); Fix the custom alignment rule - for_array(i, x->Struct.fields) { - Entity *xf = x->Struct.fields[i]; - Entity *yf = y->Struct.fields[i]; - if (xf->kind != yf->kind) { - return false; - } - if (!are_types_identical(xf->type, yf->type)) { - return false; - } - if (xf->token.string != yf->token.string) { - return false; - } - if (x->Struct.tags[i] != y->Struct.tags[i]) { - return false; - } - u64 xf_flags = (xf->flags&EntityFlags_IsSubtype); - u64 yf_flags = (yf->flags&EntityFlags_IsSubtype); - if (xf_flags != yf_flags) { - return false; - } + if (x->Struct.is_raw_union == y->Struct.is_raw_union && + x->Struct.is_no_copy == y->Struct.is_no_copy && + x->Struct.fields.count == y->Struct.fields.count && + x->Struct.is_packed == y->Struct.is_packed && + x->Struct.custom_align == y->Struct.custom_align && + x->Struct.soa_kind == y->Struct.soa_kind && + x->Struct.soa_count == y->Struct.soa_count && + are_types_identical(x->Struct.soa_elem, y->Struct.soa_elem)) { + // TODO(bill); Fix the custom alignment rule + for_array(i, x->Struct.fields) { + Entity *xf = x->Struct.fields[i]; + Entity *yf = y->Struct.fields[i]; + if (xf->kind != yf->kind) { + return false; + } + if (!are_types_identical(xf->type, yf->type)) { + return false; + } + if (xf->token.string != yf->token.string) { + return false; + } + if (x->Struct.tags[i] != y->Struct.tags[i]) { + return false; + } + u64 xf_flags = (xf->flags&EntityFlags_IsSubtype); + u64 yf_flags = (yf->flags&EntityFlags_IsSubtype); + if (xf_flags != yf_flags) { + return false; } - return true; } + return are_types_identical(x->Struct.polymorphic_params, y->Struct.polymorphic_params); } break; case Type_Pointer: - if (y->kind == Type_Pointer) { - return are_types_identical(x->Pointer.elem, y->Pointer.elem); - } - break; + return are_types_identical(x->Pointer.elem, y->Pointer.elem); case Type_MultiPointer: - if (y->kind == Type_MultiPointer) { - return are_types_identical(x->MultiPointer.elem, y->MultiPointer.elem); - } - break; + return are_types_identical(x->MultiPointer.elem, y->MultiPointer.elem); case Type_SoaPointer: - if (y->kind == Type_SoaPointer) { - return are_types_identical(x->SoaPointer.elem, y->SoaPointer.elem); - } - break; + return are_types_identical(x->SoaPointer.elem, y->SoaPointer.elem); case Type_Named: - if (y->kind == Type_Named) { - return x->Named.type_name == y->Named.type_name; - } - break; + return x->Named.type_name == y->Named.type_name; case Type_Tuple: - if (y->kind == Type_Tuple) { - if (x->Tuple.variables.count == y->Tuple.variables.count && - x->Tuple.is_packed == y->Tuple.is_packed) { - for_array(i, x->Tuple.variables) { - Entity *xe = x->Tuple.variables[i]; - Entity *ye = y->Tuple.variables[i]; - if (xe->kind != ye->kind || !are_types_identical(xe->type, ye->type)) { - return false; - } - if (check_tuple_names) { - if (xe->token.string != ye->token.string) { - return false; - } - } - if (xe->kind == Entity_Constant && !compare_exact_values(Token_CmpEq, xe->Constant.value, ye->Constant.value)) { - // NOTE(bill): This is needed for polymorphic procedures + if (x->Tuple.variables.count == y->Tuple.variables.count && + x->Tuple.is_packed == y->Tuple.is_packed) { + for_array(i, x->Tuple.variables) { + Entity *xe = x->Tuple.variables[i]; + Entity *ye = y->Tuple.variables[i]; + if (xe->kind != ye->kind || !are_types_identical(xe->type, ye->type)) { + return false; + } + if (check_tuple_names) { + if (xe->token.string != ye->token.string) { return false; } } - return true; + if (xe->kind == Entity_Constant && !compare_exact_values(Token_CmpEq, xe->Constant.value, ye->Constant.value)) { + // NOTE(bill): This is needed for polymorphic procedures + return false; + } } + return true; } break; case Type_Proc: - if (y->kind == Type_Proc) { - return x->Proc.calling_convention == y->Proc.calling_convention && - x->Proc.c_vararg == y->Proc.c_vararg && - x->Proc.variadic == y->Proc.variadic && - x->Proc.diverging == y->Proc.diverging && - x->Proc.optional_ok == y->Proc.optional_ok && - are_types_identical(x->Proc.params, y->Proc.params) && - are_types_identical(x->Proc.results, y->Proc.results); - } - break; + return x->Proc.calling_convention == y->Proc.calling_convention && + x->Proc.c_vararg == y->Proc.c_vararg && + x->Proc.variadic == y->Proc.variadic && + x->Proc.diverging == y->Proc.diverging && + x->Proc.optional_ok == y->Proc.optional_ok && + are_types_identical_internal(x->Proc.params, y->Proc.params, check_tuple_names) && + are_types_identical_internal(x->Proc.results, y->Proc.results, check_tuple_names); case Type_Map: - if (y->kind == Type_Map) { - return are_types_identical(x->Map.key, y->Map.key) && - are_types_identical(x->Map.value, y->Map.value); - } - break; + return are_types_identical(x->Map.key, y->Map.key) && + are_types_identical(x->Map.value, y->Map.value); case Type_SimdVector: - if (y->kind == Type_SimdVector) { - if (x->SimdVector.count == y->SimdVector.count) { - return are_types_identical(x->SimdVector.elem, y->SimdVector.elem); - } + if (x->SimdVector.count == y->SimdVector.count) { + return are_types_identical(x->SimdVector.elem, y->SimdVector.elem); } break; } @@ -2799,7 +2750,7 @@ bool are_types_identical_internal(Type *x, Type *y, bool check_tuple_names) { return false; } -Type *default_type(Type *type) { +gb_internal Type *default_type(Type *type) { if (type == nullptr) { return t_invalid; } @@ -2817,13 +2768,23 @@ Type *default_type(Type *type) { return type; } -i64 union_variant_index(Type *u, Type *v) { +gb_internal bool union_variant_index_types_equal(Type *v, Type *vt) { + if (are_types_identical(v, vt)) { + return true; + } + if (is_type_proc(v) && is_type_proc(vt)) { + return are_types_identical(base_type(v), base_type(vt)); + } + return false; +} + +gb_internal i64 union_variant_index(Type *u, Type *v) { u = base_type(u); GB_ASSERT(u->kind == Type_Union); for_array(i, u->Union.variants) { Type *vt = u->Union.variants[i]; - if (are_types_identical(v, vt)) { + if (union_variant_index_types_equal(v, vt)) { if (u->Union.kind == UnionType_no_nil) { return cast(i64)(i+0); } else { @@ -2834,7 +2795,7 @@ i64 union_variant_index(Type *u, Type *v) { return 0; } -i64 union_tag_size(Type *u) { +gb_internal i64 union_tag_size(Type *u) { u = base_type(u); GB_ASSERT(u->kind == Type_Union); if (u->Union.tag_size > 0) { @@ -2871,7 +2832,7 @@ i64 union_tag_size(Type *u) { return u->Union.tag_size; } -Type *union_tag_type(Type *u) { +gb_internal Type *union_tag_type(Type *u) { i64 s = union_tag_size(u); switch (s) { case 0: return t_u8; @@ -2901,7 +2862,7 @@ enum ProcTypeOverloadKind { }; -ProcTypeOverloadKind are_proc_types_overload_safe(Type *x, Type *y) { +gb_internal ProcTypeOverloadKind are_proc_types_overload_safe(Type *x, Type *y) { if (x == nullptr && y == nullptr) return ProcOverload_NotProcedure; if (x == nullptr && y != nullptr) return ProcOverload_NotProcedure; if (x != nullptr && y == nullptr) return ProcOverload_NotProcedure; @@ -2968,13 +2929,13 @@ ProcTypeOverloadKind are_proc_types_overload_safe(Type *x, Type *y) { -Selection lookup_field_with_selection(Type *type_, String field_name, bool is_type, Selection sel, bool allow_blank_ident=false); +gb_internal Selection lookup_field_with_selection(Type *type_, String field_name, bool is_type, Selection sel, bool allow_blank_ident=false); -Selection lookup_field(Type *type_, String field_name, bool is_type, bool allow_blank_ident=false) { +gb_internal Selection lookup_field(Type *type_, String field_name, bool is_type, bool allow_blank_ident=false) { return lookup_field_with_selection(type_, field_name, is_type, empty_selection, allow_blank_ident); } -Selection lookup_field_from_index(Type *type, i64 index) { +gb_internal Selection lookup_field_from_index(Type *type, i64 index) { GB_ASSERT(is_type_struct(type) || is_type_union(type) || is_type_tuple(type)); type = base_type(type); @@ -3018,10 +2979,10 @@ Selection lookup_field_from_index(Type *type, i64 index) { return empty_selection; } -Entity *scope_lookup_current(Scope *s, String const &name); -bool has_type_got_objc_class_attribute(Type *t); +gb_internal Entity *scope_lookup_current(Scope *s, String const &name); +gb_internal bool has_type_got_objc_class_attribute(Type *t); -Selection lookup_field_with_selection(Type *type_, String field_name, bool is_type, Selection sel, bool allow_blank_ident) { +gb_internal Selection lookup_field_with_selection(Type *type_, String field_name, bool is_type, Selection sel, bool allow_blank_ident) { GB_ASSERT(type_ != nullptr); if (!allow_blank_ident && is_blank_ident(field_name)) { @@ -3363,10 +3324,13 @@ Selection lookup_field_with_selection(Type *type_, String field_name, bool is_ty return sel; } -bool are_struct_fields_reordered(Type *type) { +gb_internal bool are_struct_fields_reordered(Type *type) { type = base_type(type); GB_ASSERT(type->kind == Type_Struct); type_set_offsets(type); + if (type->Struct.fields.count == 0) { + return false; + } GB_ASSERT(type->Struct.offsets != nullptr); i64 prev_offset = 0; @@ -3381,10 +3345,13 @@ bool are_struct_fields_reordered(Type *type) { return false; } -Slice struct_fields_index_by_increasing_offset(gbAllocator allocator, Type *type) { +gb_internal Slice struct_fields_index_by_increasing_offset(gbAllocator allocator, Type *type) { type = base_type(type); GB_ASSERT(type->kind == Type_Struct); type_set_offsets(type); + if (type->Struct.fields.count == 0) { + return {}; + } GB_ASSERT(type->Struct.offsets != nullptr); auto indices = slice_make(allocator, type->Struct.fields.count); @@ -3416,12 +3383,12 @@ Slice struct_fields_index_by_increasing_offset(gbAllocator allocator, Type -i64 type_size_of_internal (Type *t, TypePath *path); -i64 type_align_of_internal(Type *t, TypePath *path); -i64 type_size_of(Type *t); -i64 type_align_of(Type *t); +gb_internal i64 type_size_of_internal (Type *t, TypePath *path); +gb_internal i64 type_align_of_internal(Type *t, TypePath *path); +gb_internal i64 type_size_of(Type *t); +gb_internal i64 type_align_of(Type *t); -i64 type_size_of_struct_pretend_is_packed(Type *ot) { +gb_internal i64 type_size_of_struct_pretend_is_packed(Type *ot) { if (ot == nullptr) { return 0; } @@ -3450,49 +3417,70 @@ i64 type_size_of_struct_pretend_is_packed(Type *ot) { } -i64 type_size_of(Type *t) { +gb_internal i64 type_size_of(Type *t) { if (t == nullptr) { return 0; } - // NOTE(bill): Always calculate the size when it is a Type_Basic - if (t->kind == Type_Named && t->cached_size >= 0) { + i64 size = -1; + if (t->kind == Type_Basic) { + GB_ASSERT_MSG(is_type_typed(t), "%s", type_to_string(t)); + switch (t->Basic.kind) { + case Basic_string: size = 2*build_context.int_size; break; + case Basic_cstring: size = build_context.ptr_size; break; + case Basic_any: size = 2*build_context.ptr_size; break; + case Basic_typeid: size = build_context.ptr_size; break; - } else if (t->kind != Type_Basic && t->cached_size >= 0) { - return t->cached_size; + case Basic_int: case Basic_uint: + size = build_context.int_size; + break; + case Basic_uintptr: case Basic_rawptr: + size = build_context.ptr_size; + break; + default: + size = t->Basic.size; + break; + } + t->cached_size.store(size); + return size; + } else if (t->kind != Type_Named && t->cached_size >= 0) { + return t->cached_size.load(); + } else { + TypePath path{}; + type_path_init(&path); + { + MUTEX_GUARD(&g_type_mutex); + size = type_size_of_internal(t, &path); + t->cached_size.store(size); + } + type_path_free(&path); + return size; } - TypePath path = {0}; - type_path_init(&path); - t->cached_size = type_size_of_internal(t, &path); - type_path_free(&path); - return t->cached_size; } -i64 type_align_of(Type *t) { +gb_internal i64 type_align_of(Type *t) { if (t == nullptr) { return 1; } - // NOTE(bill): Always calculate the size when it is a Type_Basic - if (t->kind == Type_Named && t->cached_align >= 0) { - - } if (t->kind != Type_Basic && t->cached_align > 0) { - return t->cached_align; + if (t->kind != Type_Named && t->cached_align > 0) { + return t->cached_align.load(); } - TypePath path = {0}; + TypePath path{}; type_path_init(&path); - t->cached_align = type_align_of_internal(t, &path); + { + MUTEX_GUARD(&g_type_mutex); + t->cached_align.store(type_align_of_internal(t, &path)); + } type_path_free(&path); - return t->cached_align; + return t->cached_align.load(); } -i64 type_align_of_internal(Type *t, TypePath *path) { +gb_internal i64 type_align_of_internal(Type *t, TypePath *path) { GB_ASSERT(path != nullptr); if (t->failure) { return FAILURE_ALIGNMENT; } - mutex_lock(&g_type_mutex); - defer (mutex_unlock(&g_type_mutex)); t = base_type(t); @@ -3500,13 +3488,15 @@ i64 type_align_of_internal(Type *t, TypePath *path) { case Type_Basic: { GB_ASSERT(is_type_typed(t)); switch (t->Basic.kind) { - case Basic_string: return build_context.word_size; - case Basic_cstring: return build_context.word_size; - case Basic_any: return build_context.word_size; - case Basic_typeid: return build_context.word_size; + case Basic_string: return build_context.int_size; + case Basic_cstring: return build_context.ptr_size; + case Basic_any: return build_context.ptr_size; + case Basic_typeid: return build_context.ptr_size; - case Basic_int: case Basic_uint: case Basic_uintptr: case Basic_rawptr: - return build_context.word_size; + case Basic_int: case Basic_uint: + return build_context.int_size; + case Basic_uintptr: case Basic_rawptr: + return build_context.ptr_size; case Basic_complex32: case Basic_complex64: case Basic_complex128: return type_size_of_internal(t, path) / 2; @@ -3539,10 +3529,10 @@ i64 type_align_of_internal(Type *t, TypePath *path) { case Type_DynamicArray: // data, count, capacity, allocator - return build_context.word_size; + return build_context.int_size; case Type_Slice: - return build_context.word_size; + return build_context.int_size; case Type_Tuple: { @@ -3557,7 +3547,7 @@ i64 type_align_of_internal(Type *t, TypePath *path) { } break; case Type_Map: - return build_context.word_size; + return build_context.ptr_size; case Type_Enum: return type_align_of_internal(t->Enum.base_type, path); @@ -3589,39 +3579,25 @@ i64 type_align_of_internal(Type *t, TypePath *path) { if (t->Struct.custom_align > 0) { return gb_max(t->Struct.custom_align, 1); } - if (t->Struct.is_raw_union) { - i64 max = 1; - for_array(i, t->Struct.fields) { - Type *field_type = t->Struct.fields[i]->type; - bool pop = type_path_push(path, field_type); - if (path->failure) { - return FAILURE_ALIGNMENT; - } - i64 align = type_align_of_internal(field_type, path); - if (pop) type_path_pop(path); - if (max < align) { - max = align; - } - } - return max; - } else if (t->Struct.fields.count > 0) { - i64 max = 1; - // NOTE(bill): Check the fields to check for cyclic definitions - for_array(i, t->Struct.fields) { - Type *field_type = t->Struct.fields[i]->type; - bool pop = type_path_push(path, field_type); - if (path->failure) return FAILURE_ALIGNMENT; - i64 align = type_align_of_internal(field_type, path); - if (pop) type_path_pop(path); - if (max < align) { - max = align; - } - } - if (t->Struct.is_packed) { - return 1; - } - return max; + + if (t->Struct.is_packed) { + return 1; } + + i64 max = 1; + for_array(i, t->Struct.fields) { + Type *field_type = t->Struct.fields[i]->type; + bool pop = type_path_push(path, field_type); + if (path->failure) { + return FAILURE_ALIGNMENT; + } + i64 align = type_align_of_internal(field_type, path); + if (pop) type_path_pop(path); + if (max < align) { + max = align; + } + } + return max; } break; case Type_BitSet: { @@ -3651,15 +3627,15 @@ i64 type_align_of_internal(Type *t, TypePath *path) { return type_align_of_internal(t->RelativeSlice.base_integer, path); case Type_SoaPointer: - return build_context.word_size; + return build_context.int_size; } - // NOTE(bill): Things that are bigger than build_context.word_size, are actually comprised of smaller types + // NOTE(bill): Things that are bigger than build_context.ptr_size, are actually comprised of smaller types // TODO(bill): Is this correct for 128-bit types (integers)? return gb_clamp(next_pow2(type_size_of_internal(t, path)), 1, build_context.max_align); } -i64 *type_set_offsets_of(Slice const &fields, bool is_packed, bool is_raw_union) { +gb_internal i64 *type_set_offsets_of(Slice const &fields, bool is_packed, bool is_raw_union) { gbAllocator a = permanent_allocator(); auto offsets = gb_alloc_array(a, i64, fields.count); i64 curr_offset = 0; @@ -3686,9 +3662,8 @@ i64 *type_set_offsets_of(Slice const &fields, bool is_packed, bool is_ return offsets; } -bool type_set_offsets(Type *t) { - mutex_lock(&g_type_mutex); - defer (mutex_unlock(&g_type_mutex)); +gb_internal bool type_set_offsets(Type *t) { + MUTEX_GUARD(&g_type_mutex); // TODO(bill): only per struct t = base_type(t); if (t->kind == Type_Struct) { @@ -3713,13 +3688,10 @@ bool type_set_offsets(Type *t) { return false; } -i64 type_size_of_internal(Type *t, TypePath *path) { +gb_internal i64 type_size_of_internal(Type *t, TypePath *path) { if (t->failure) { return FAILURE_SIZE; } - mutex_lock(&g_type_mutex); - defer (mutex_unlock(&g_type_mutex)); - switch (t->kind) { case Type_Named: { @@ -3740,24 +3712,26 @@ i64 type_size_of_internal(Type *t, TypePath *path) { return size; } switch (kind) { - case Basic_string: return 2*build_context.word_size; - case Basic_cstring: return build_context.word_size; - case Basic_any: return 2*build_context.word_size; - case Basic_typeid: return build_context.word_size; + case Basic_string: return 2*build_context.int_size; + case Basic_cstring: return build_context.ptr_size; + case Basic_any: return 2*build_context.ptr_size; + case Basic_typeid: return build_context.ptr_size; - case Basic_int: case Basic_uint: case Basic_uintptr: case Basic_rawptr: - return build_context.word_size; + case Basic_int: case Basic_uint: + return build_context.int_size; + case Basic_uintptr: case Basic_rawptr: + return build_context.ptr_size; } } break; case Type_Pointer: - return build_context.word_size; + return build_context.ptr_size; case Type_MultiPointer: - return build_context.word_size; + return build_context.ptr_size; case Type_SoaPointer: - return build_context.word_size*2; + return build_context.int_size*2; case Type_Array: { i64 count, align, size, alignment; @@ -3790,11 +3764,11 @@ i64 type_size_of_internal(Type *t, TypePath *path) { } break; case Type_Slice: // ptr + len - return 2 * build_context.word_size; + return 2 * build_context.int_size; case Type_DynamicArray: // data + len + cap + allocator(procedure+data) - return (3 + 2)*build_context.word_size; + return 3*build_context.int_size + 2*build_context.ptr_size; case Type_Map: /* @@ -3804,7 +3778,7 @@ i64 type_size_of_internal(Type *t, TypePath *path) { allocator: runtime.Allocator, // 2 words } */ - return (1 + 1 + 2)*build_context.word_size; + return (1 + 1 + 2)*build_context.ptr_size; case Type_Tuple: { i64 count, align, size; @@ -3930,10 +3904,10 @@ i64 type_size_of_internal(Type *t, TypePath *path) { } // Catch all - return build_context.word_size; + return build_context.ptr_size; } -i64 type_offset_of(Type *t, i32 index) { +gb_internal i64 type_offset_of(Type *t, i32 index) { t = base_type(t); if (t->kind == Type_Struct) { type_set_offsets(t); @@ -3950,39 +3924,39 @@ i64 type_offset_of(Type *t, i32 index) { } else if (t->kind == Type_Basic) { if (t->Basic.kind == Basic_string) { switch (index) { - case 0: return 0; // data - case 1: return build_context.word_size; // len + case 0: return 0; // data + case 1: return build_context.int_size; // len } } else if (t->Basic.kind == Basic_any) { switch (index) { - case 0: return 0; // type_info - case 1: return build_context.word_size; // data + case 0: return 0; // type_info + case 1: return build_context.ptr_size; // data } } } else if (t->kind == Type_Slice) { switch (index) { - case 0: return 0; // data - case 1: return 1*build_context.word_size; // len - case 2: return 2*build_context.word_size; // cap + case 0: return 0; // data + case 1: return 1*build_context.int_size; // len + case 2: return 2*build_context.int_size; // cap } } else if (t->kind == Type_DynamicArray) { switch (index) { - case 0: return 0; // data - case 1: return 1*build_context.word_size; // len - case 2: return 2*build_context.word_size; // cap - case 3: return 3*build_context.word_size; // allocator + case 0: return 0; // data + case 1: return 1*build_context.int_size; // len + case 2: return 2*build_context.int_size; // cap + case 3: return 3*build_context.int_size; // allocator } } else if (t->kind == Type_Union) { /* i64 s = */ type_size_of(t); switch (index) { - case -1: return align_formula(t->Union.variant_block_size, build_context.word_size); // __type_info + case -1: return align_formula(t->Union.variant_block_size, build_context.ptr_size); // __type_info } } return 0; } -i64 type_offset_of_from_selection(Type *type, Selection sel) { +gb_internal i64 type_offset_of_from_selection(Type *type, Selection sel) { GB_ASSERT(sel.indirect == false); Type *t = type; @@ -4030,7 +4004,7 @@ i64 type_offset_of_from_selection(Type *type, Selection sel) { return offset; } -isize check_is_assignable_to_using_subtype(Type *src, Type *dst, isize level = 0, bool src_is_ptr = false) { +gb_internal isize check_is_assignable_to_using_subtype(Type *src, Type *dst, isize level = 0, bool src_is_ptr = false) { Type *prev_src = src; src = type_deref(src); if (!src_is_ptr) { @@ -4065,7 +4039,7 @@ isize check_is_assignable_to_using_subtype(Type *src, Type *dst, isize level = 0 return 0; } -bool is_type_subtype_of(Type *src, Type *dst) { +gb_internal bool is_type_subtype_of(Type *src, Type *dst) { if (are_types_identical(src, dst)) { return true; } @@ -4074,26 +4048,25 @@ bool is_type_subtype_of(Type *src, Type *dst) { } -bool has_type_got_objc_class_attribute(Type *t) { +gb_internal bool has_type_got_objc_class_attribute(Type *t) { return t->kind == Type_Named && t->Named.type_name != nullptr && t->Named.type_name->TypeName.objc_class_name != ""; } -bool is_type_objc_object(Type *t) { - bool internal_check_is_assignable_to(Type *src, Type *dst); - +gb_internal bool internal_check_is_assignable_to(Type *src, Type *dst); +gb_internal bool is_type_objc_object(Type *t) { return internal_check_is_assignable_to(t, t_objc_object); } -Type *get_struct_field_type(Type *t, isize index) { +gb_internal Type *get_struct_field_type(Type *t, isize index) { t = base_type(type_deref(t)); GB_ASSERT(t->kind == Type_Struct); return t->Struct.fields[index]->type; } -Type *reduce_tuple_to_single_type(Type *original_type) { +gb_internal Type *reduce_tuple_to_single_type(Type *original_type) { if (original_type != nullptr) { Type *t = core_type(original_type); if (t->kind == Type_Tuple && t->Tuple.variables.count == 1) { @@ -4103,21 +4076,7 @@ Type *reduce_tuple_to_single_type(Type *original_type) { return original_type; } - -Type *alloc_type_struct_from_field_types(Type **field_types, isize field_count, bool is_packed) { - Type *t = alloc_type_struct(); - t->Struct.fields = slice_make(heap_allocator(), field_count); - - Scope *scope = nullptr; - for_array(i, t->Struct.fields) { - t->Struct.fields[i] = alloc_entity_field(scope, blank_token, field_types[i], false, cast(i32)i, EntityState_Resolved); - } - t->Struct.is_packed = is_packed; - - return t; -} - -Type *alloc_type_tuple_from_field_types(Type **field_types, isize field_count, bool is_packed, bool must_be_tuple) { +gb_internal Type *alloc_type_tuple_from_field_types(Type **field_types, isize field_count, bool is_packed, bool must_be_tuple) { if (field_count == 0) { return nullptr; } @@ -4137,7 +4096,7 @@ Type *alloc_type_tuple_from_field_types(Type **field_types, isize field_count, b return t; } -Type *alloc_type_proc_from_types(Type **param_types, unsigned param_count, Type *results, bool is_c_vararg, ProcCallingConvention calling_convention) { +gb_internal Type *alloc_type_proc_from_types(Type **param_types, unsigned param_count, Type *results, bool is_c_vararg, ProcCallingConvention calling_convention) { Type *params = alloc_type_tuple_from_field_types(param_types, param_count, false, true); isize results_count = 0; @@ -4156,7 +4115,7 @@ Type *alloc_type_proc_from_types(Type **param_types, unsigned param_count, Type -gbString write_type_to_string(gbString str, Type *type, bool shorthand=false) { +gb_internal gbString write_type_to_string(gbString str, Type *type, bool shorthand=false) { if (type == nullptr) { return gb_string_appendc(str, ""); } @@ -4276,6 +4235,7 @@ gbString write_type_to_string(gbString str, Type *type, bool shorthand=false) { str = gb_string_appendc(str, "struct"); if (type->Struct.is_packed) str = gb_string_appendc(str, " #packed"); if (type->Struct.is_raw_union) str = gb_string_appendc(str, " #raw_union"); + if (type->Struct.is_no_copy) str = gb_string_appendc(str, " #no_copy"); if (type->Struct.custom_align != 0) str = gb_string_append_fmt(str, " #align %d", cast(int)type->Struct.custom_align); str = gb_string_appendc(str, " {"); @@ -4321,6 +4281,10 @@ gbString write_type_to_string(gbString str, Type *type, bool shorthand=false) { if (var == nullptr) { continue; } + if (comma_index++ > 0) { + str = gb_string_appendc(str, ", "); + } + String name = var->token.string; if (var->kind == Entity_Constant) { str = gb_string_appendc(str, "$"); @@ -4337,10 +4301,6 @@ gbString write_type_to_string(gbString str, Type *type, bool shorthand=false) { continue; } - if (comma_index++ > 0) { - str = gb_string_appendc(str, ", "); - } - if (var->kind == Entity_Variable) { if (var->flags&EntityFlag_CVarArg) { str = gb_string_appendc(str, "#c_vararg "); @@ -4467,14 +4427,14 @@ gbString write_type_to_string(gbString str, Type *type, bool shorthand=false) { } -gbString type_to_string(Type *type, gbAllocator allocator, bool shorthand) { +gb_internal gbString type_to_string(Type *type, gbAllocator allocator, bool shorthand) { return write_type_to_string(gb_string_make(allocator, ""), type, shorthand); } -gbString type_to_string(Type *type, bool shorthand) { +gb_internal gbString type_to_string(Type *type, bool shorthand) { return write_type_to_string(gb_string_make(heap_allocator(), ""), type, shorthand); } -gbString type_to_string_shorthand(Type *type) { +gb_internal gbString type_to_string_shorthand(Type *type) { return type_to_string(type, true); } diff --git a/src/unicode.cpp b/src/unicode.cpp index e33fb793b..c244a323c 100644 --- a/src/unicode.cpp +++ b/src/unicode.cpp @@ -7,7 +7,7 @@ extern "C" { #pragma warning(pop) -bool rune_is_letter(Rune r) { +gb_internal bool rune_is_letter(Rune r) { if (r < 0x80) { if (r == '_') { return true; @@ -25,14 +25,14 @@ bool rune_is_letter(Rune r) { return false; } -bool rune_is_digit(Rune r) { +gb_internal bool rune_is_digit(Rune r) { if (r < 0x80) { return (cast(u32)r - '0') < 10; } return utf8proc_category(r) == UTF8PROC_CATEGORY_ND; } -bool rune_is_letter_or_digit(Rune r) { +gb_internal bool rune_is_letter_or_digit(Rune r) { if (r < 0x80) { if (r == '_') { return true; @@ -55,7 +55,7 @@ bool rune_is_letter_or_digit(Rune r) { return false; } -bool rune_is_whitespace(Rune r) { +gb_internal bool rune_is_whitespace(Rune r) { switch (r) { case ' ': case '\t': @@ -99,7 +99,7 @@ gb_global Utf8AcceptRange const global__utf8_accept_ranges[] = { }; -isize utf8_decode(u8 const *str, isize str_len, Rune *codepoint_out) { +gb_internal isize utf8_decode(u8 const *str, isize str_len, Rune *codepoint_out) { isize width = 0; Rune codepoint = GB_RUNE_INVALID; diff --git a/tests/core/Makefile b/tests/core/Makefile index 478d6ae2c..77d4b85a0 100644 --- a/tests/core/Makefile +++ b/tests/core/Makefile @@ -2,7 +2,7 @@ ODIN=../../odin PYTHON=$(shell which python3) all: download_test_assets image_test compress_test strings_test hash_test crypto_test noise_test encoding_test \ - math_test linalg_glsl_math_test filepath_test reflect_test os_exit_test i18n_test match_test c_libc_test + math_test linalg_glsl_math_test filepath_test reflect_test os_exit_test i18n_test match_test c_libc_test net_test download_test_assets: $(PYTHON) download_assets.py @@ -54,3 +54,6 @@ match_test: c_libc_test: $(ODIN) run c/libc -out:test_core_libc + +net_test: + $(ODIN) run net -out:test_core_net diff --git a/tests/core/build.bat b/tests/core/build.bat index e4e146588..1d146c8a4 100644 --- a/tests/core/build.bat +++ b/tests/core/build.bat @@ -6,82 +6,82 @@ python3 download_assets.py echo --- echo Running core:image tests echo --- -%PATH_TO_ODIN% run image %COMMON% -out:test_core_image.exe +%PATH_TO_ODIN% run image %COMMON% -out:test_core_image.exe || exit /b echo --- echo Running core:compress tests echo --- -%PATH_TO_ODIN% run compress %COMMON% -out:test_core_compress.exe +%PATH_TO_ODIN% run compress %COMMON% -out:test_core_compress.exe || exit /b echo --- echo Running core:strings tests echo --- -%PATH_TO_ODIN% run strings %COMMON% -out:test_core_strings.exe +%PATH_TO_ODIN% run strings %COMMON% -out:test_core_strings.exe || exit /b echo --- echo Running core:hash tests echo --- -%PATH_TO_ODIN% run hash %COMMON% -o:size -out:test_core_hash.exe +%PATH_TO_ODIN% run hash %COMMON% -o:size -out:test_core_hash.exe || exit /b echo --- echo Running core:odin tests echo --- -%PATH_TO_ODIN% run odin %COMMON% -o:size -out:test_core_odin.exe +%PATH_TO_ODIN% run odin %COMMON% -o:size -out:test_core_odin.exe || exit /b echo --- echo Running core:crypto hash tests echo --- -%PATH_TO_ODIN% run crypto %COMMON% -out:test_crypto_hash.exe +%PATH_TO_ODIN% run crypto %COMMON% -out:test_crypto_hash.exe || exit /b echo --- echo Running core:encoding tests echo --- -%PATH_TO_ODIN% run encoding/hxa %COMMON% %COLLECTION% -out:test_hxa.exe -%PATH_TO_ODIN% run encoding/json %COMMON% -out:test_json.exe -%PATH_TO_ODIN% run encoding/varint %COMMON% -out:test_varint.exe -%PATH_TO_ODIN% run encoding/xml %COMMON% -out:test_xml.exe +%PATH_TO_ODIN% run encoding/hxa %COMMON% %COLLECTION% -out:test_hxa.exe || exit /b +%PATH_TO_ODIN% run encoding/json %COMMON% -out:test_json.exe || exit /b +%PATH_TO_ODIN% run encoding/varint %COMMON% -out:test_varint.exe || exit /b +%PATH_TO_ODIN% run encoding/xml %COMMON% -out:test_xml.exe || exit /b echo --- echo Running core:math/noise tests echo --- -%PATH_TO_ODIN% run math/noise %COMMON% -out:test_noise.exe +%PATH_TO_ODIN% run math/noise %COMMON% -out:test_noise.exe || exit /b echo --- echo Running core:math tests echo --- -%PATH_TO_ODIN% run math %COMMON% %COLLECTION% -out:test_core_math.exe +%PATH_TO_ODIN% run math %COMMON% %COLLECTION% -out:test_core_math.exe || exit /b echo --- echo Running core:math/linalg/glsl tests echo --- -%PATH_TO_ODIN% run math/linalg/glsl %COMMON% %COLLECTION% -out:test_linalg_glsl.exe +%PATH_TO_ODIN% run math/linalg/glsl %COMMON% %COLLECTION% -out:test_linalg_glsl.exe || exit /b echo --- echo Running core:path/filepath tests echo --- -%PATH_TO_ODIN% run path/filepath %COMMON% %COLLECTION% -out:test_core_filepath.exe +%PATH_TO_ODIN% run path/filepath %COMMON% %COLLECTION% -out:test_core_filepath.exe || exit /b echo --- echo Running core:reflect tests echo --- -%PATH_TO_ODIN% run reflect %COMMON% %COLLECTION% -out:test_core_reflect.exe +%PATH_TO_ODIN% run reflect %COMMON% %COLLECTION% -out:test_core_reflect.exe || exit /b echo --- echo Running core:text/i18n tests echo --- -%PATH_TO_ODIN% run text\i18n %COMMON% -out:test_core_i18n.exe +%PATH_TO_ODIN% run text\i18n %COMMON% -out:test_core_i18n.exe || exit /b echo --- -echo Running core:text/lua tests +echo Running core:net echo --- -%PATH_TO_ODIN% run text\lua %COMMON% -out:test_core_lua_strlib.exe +%PATH_TO_ODIN% run net %COMMON% -out:test_core_net.exe || exit /b echo --- echo Running core:slice tests echo --- -%PATH_TO_ODIN% run slice %COMMON% -out:test_core_slice.exe +%PATH_TO_ODIN% run slice %COMMON% -out:test_core_slice.exe || exit /b echo --- echo Running core:container tests echo --- -%PATH_TO_ODIN% run container %COMMON% %COLLECTION% -out:test_core_container.exe +%PATH_TO_ODIN% run container %COMMON% %COLLECTION% -out:test_core_container.exe || exit /b diff --git a/tests/core/compress/test_core_compress.odin b/tests/core/compress/test_core_compress.odin index ee7233e52..ac7555e9a 100644 --- a/tests/core/compress/test_core_compress.odin +++ b/tests/core/compress/test_core_compress.odin @@ -151,6 +151,13 @@ shoco_test :: proc(t: ^testing.T) { } for v in Shoco_Tests { + when ODIN_OS == .Windows { + v := v + // Compressed source files are not encoded with carriage returns but git replaces raw files lf with crlf on commit (on windows only) + // So replace crlf with lf on windows + v.raw, _ = bytes.replace_all(v.raw, { 0xD, 0xA }, { 0xA }) + } + expected_raw := len(v.raw) expected_compressed := len(v.compressed) diff --git a/tests/core/crypto/test_core_crypto_modern.odin b/tests/core/crypto/test_core_crypto_modern.odin index 6d1ae0047..8f7abb5e8 100644 --- a/tests/core/crypto/test_core_crypto_modern.odin +++ b/tests/core/crypto/test_core_crypto_modern.odin @@ -269,6 +269,12 @@ TestECDH :: struct { test_x25519 :: proc(t: ^testing.T) { log(t, "Testing X25519") + // Local copy of this so that the base point doesn't need to be exported. + _BASE_POINT: [32]byte = { + 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + } + test_vectors := [?]TestECDH { // Test vectors from RFC 7748 TestECDH{ @@ -295,7 +301,7 @@ test_x25519 :: proc(t: ^testing.T) { // Abuse the test vectors to sanity-check the scalar-basepoint multiply. p1, p2: [x25519.POINT_SIZE]byte x25519.scalarmult_basepoint(p1[:], scalar[:]) - x25519.scalarmult(p2[:], scalar[:], x25519._BASE_POINT[:]) + x25519.scalarmult(p2[:], scalar[:], _BASE_POINT[:]) p1_str, p2_str := hex_string(p1[:]), hex_string(p2[:]) expect(t, p1_str == p2_str, fmt.tprintf("Expected %s for %s * basepoint, but got %s instead", p2_str, v.scalar, p1_str)) } diff --git a/tests/core/encoding/hex/test_core_hex.odin b/tests/core/encoding/hex/test_core_hex.odin new file mode 100644 index 000000000..a5daa206e --- /dev/null +++ b/tests/core/encoding/hex/test_core_hex.odin @@ -0,0 +1,93 @@ +package test_core_hex + +import "core:encoding/hex" +import "core:testing" +import "core:fmt" +import "core:os" +import "core:bytes" + +TEST_count := 0 +TEST_fail := 0 + +when ODIN_TEST { + expect :: testing.expect + log :: testing.log +} else { + expect :: proc(t: ^testing.T, condition: bool, message: string, loc := #caller_location) { + TEST_count += 1 + if !condition { + TEST_fail += 1 + fmt.printf("[%v] %v\n", loc, message) + return + } + } + log :: proc(t: ^testing.T, v: any, loc := #caller_location) { + fmt.printf("[%v] ", loc) + fmt.printf("log: %v\n", v) + } +} + +main :: proc() { + t := testing.T{} + + hex_encode(&t) + hex_decode(&t) + hex_decode_sequence(&t) + + fmt.printf("%v/%v tests successful.\n", TEST_count - TEST_fail, TEST_count) + if TEST_fail > 0 { + os.exit(1) + } +} + +CASES :: [][2]string{ + {"11", "3131"}, + {"g", "67"}, + {"Hello", "48656c6c6f"}, +} + +@(test) +hex_encode :: proc(t: ^testing.T) { + for test in CASES { + encoded := string(hex.encode(transmute([]byte)test[0])) + expect( + t, + encoded == test[1], + fmt.tprintf("encode: %q -> %q (should be: %q)", test[0], encoded, test[1]), + ) + } +} + +@(test) +hex_decode :: proc(t: ^testing.T) { + for test in CASES { + decoded, ok := hex.decode(transmute([]byte)test[1]) + expect(t, ok, fmt.tprintf("decode: %q not ok", test[1])) + expect( + t, + string(decoded) == test[0], + fmt.tprintf("decode: %q -> %q (should be: %q)", test[1], string(decoded), test[0]), + ) + } +} + +@(test) +hex_decode_sequence :: proc(t: ^testing.T) { + b, ok := hex.decode_sequence("0x23") + expect(t, ok, "decode_sequence: 0x23 not ok") + expect(t, b == '#', fmt.tprintf("decode_sequence: 0x23 -> %c (should be: %c)", b, '#')) + + b, ok = hex.decode_sequence("0X3F") + expect(t, ok, "decode_sequence: 0X3F not ok") + expect(t, b == '?', fmt.tprintf("decode_sequence: 0X3F -> %c (should be: %c)", b, '?')) + + b, ok = hex.decode_sequence("2a") + expect(t, ok, "decode_sequence: 2a not ok") + expect(t, b == '*', fmt.tprintf("decode_sequence: 2a -> %c (should be: %c)", b, '*')) + + _, ok = hex.decode_sequence("1") + expect(t, !ok, "decode_sequence: 1 should be too short") + + _, ok = hex.decode_sequence("123") + expect(t, !ok, "decode_sequence: 123 should be too long") +} diff --git a/tests/core/encoding/json/test_core_json.odin b/tests/core/encoding/json/test_core_json.odin index 0e6a6412f..937d1c738 100644 --- a/tests/core/encoding/json/test_core_json.odin +++ b/tests/core/encoding/json/test_core_json.odin @@ -32,6 +32,7 @@ main :: proc() { parse_json(&t) marshal_json(&t) unmarshal_json(&t) + surrogate(&t) fmt.printf("%v/%v tests successful.\n", TEST_count - TEST_fail, TEST_count) if TEST_fail > 0 { @@ -344,4 +345,17 @@ unmarshal_json :: proc(t: ^testing.T) { for p, i in g.products { expect(t, p == original_data.products[i], "Producted unmarshaled improperly") } -} \ No newline at end of file +} + +@test +surrogate :: proc(t: ^testing.T) { + input := `+ + * 😃 - /` + + out, err := json.marshal(input) + expect(t, err == nil, fmt.tprintf("Expected `json.marshal(%q)` to return a nil error, got %v", input, err)) + + back: string + uerr := json.unmarshal(out, &back) + expect(t, uerr == nil, fmt.tprintf("Expected `json.unmarshal(%q)` to return a nil error, got %v", string(out), uerr)) + expect(t, back == input, fmt.tprintf("Expected `json.unmarshal(%q)` to return %q, got %v", string(out), input, uerr)) +} diff --git a/tests/core/net/test_core_net.odin b/tests/core/net/test_core_net.odin new file mode 100644 index 000000000..14e1cbb17 --- /dev/null +++ b/tests/core/net/test_core_net.odin @@ -0,0 +1,585 @@ +/* + Copyright 2021 Jeroen van Rijn . + Made available under Odin's BSD-3 license. + + List of contributors: + Jeroen van Rijn: Initial implementation. + graphitemaster: pton/ntop IANA test vectors + + A test suite for `core:net` +*/ +package test_core_net + +import "core:testing" +import "core:mem" +import "core:fmt" +import "core:net" +import "core:strconv" +import "core:time" +import "core:thread" + +_, _ :: time, thread + +TEST_count := 0 +TEST_fail := 0 + +t := &testing.T{} + +when ODIN_TEST { + expect :: testing.expect + log :: testing.log +} else { + expect :: proc(t: ^testing.T, condition: bool, message: string, loc := #caller_location) { + TEST_count += 1 + if !condition { + TEST_fail += 1 + fmt.printf("[%v] %v\n", loc, message) + return + } + } + log :: proc(t: ^testing.T, v: any, loc := #caller_location) { + fmt.printf("[%v] ", loc) + fmt.printf("log: %v\n", v) + } +} + +_tracking_allocator := mem.Tracking_Allocator{} + +print_tracking_allocator_report :: proc() { + for _, leak in _tracking_allocator.allocation_map { + fmt.printf("%v leaked %v bytes\n", leak.location, leak.size) + } + + for bf in _tracking_allocator.bad_free_array { + fmt.printf("%v allocation %p was freed badly\n", bf.location, bf.memory) + } +} + +main :: proc() { + mem.tracking_allocator_init(&_tracking_allocator, context.allocator) + context.allocator = mem.tracking_allocator(&_tracking_allocator) + + address_parsing_test(t) + + when ODIN_OS != .Windows { + fmt.printf("IMPORTANT: `core:thread` seems to still be a bit wonky on Linux and MacOS, so we can't run tests relying on them.\n", ODIN_OS) + } else { + tcp_tests(t) + } + + split_url_test(t) + join_url_test(t) + + fmt.printf("%v/%v tests successful.\n", TEST_count - TEST_fail, TEST_count) + + print_tracking_allocator_report() +} + +@test +address_parsing_test :: proc(t: ^testing.T) { + for vector in IP_Address_Parsing_Test_Vectors { + kind := "" + switch vector.family { + case .IP4: kind = "[IPv4]" + case .IP4_Alt: kind = "[IPv4 Non-Decimal]" + case .IP6: kind = "[IPv6]" + case: panic("Add support to the test for this type.") + } + + valid := len(vector.binstr) > 0 + + fmt.printf("%v %v\n", kind, vector.input) + + msg := "-set a proper message-" + switch vector.family { + case .IP4, .IP4_Alt: + /* + Does `net.parse_ip4_address` think we parsed the address properly? + */ + non_decimal := vector.family == .IP4_Alt + + any_addr := net.parse_address(vector.input, non_decimal) + parsed_ok := any_addr != nil + parsed: net.IP4_Address + + /* + Ensure that `parse_address` doesn't parse IPv4 addresses into IPv6 addreses by mistake. + */ + switch addr in any_addr { + case net.IP4_Address: + parsed = addr + case net.IP6_Address: + parsed_ok = false + msg = fmt.tprintf("parse_address mistook %v as IPv6 address %04x", vector.input, addr) + expect(t, false, msg) + } + + if !parsed_ok && valid { + msg = fmt.tprintf("parse_ip4_address failed to parse %v, expected %v", vector.input, binstr_to_address(vector.binstr)) + + } else if parsed_ok && !valid { + msg = fmt.tprintf("parse_ip4_address parsed %v into %v, expected failure", vector.input, parsed) + } + expect(t, parsed_ok == valid, msg) + + if valid && parsed_ok { + actual_binary := address_to_binstr(parsed) + msg = fmt.tprintf("parse_ip4_address parsed %v into %v, expected %v", vector.input, actual_binary, vector.binstr) + expect(t, actual_binary == vector.binstr, msg) + + /* + Do we turn an address back into the same string properly? + No point in testing the roundtrip if the first part failed. + */ + if len(vector.output) > 0 && actual_binary == vector.binstr { + stringified := net.address_to_string(parsed) + msg = fmt.tprintf("address_to_string turned %v into %v, expected %v", parsed, stringified, vector.output) + expect(t, stringified == vector.output, msg) + } + } + + case .IP6: + /* + Do we parse the address properly? + */ + parsed, parsed_ok := net.parse_ip6_address(vector.input) + + if !parsed_ok && valid { + msg = fmt.tprintf("parse_ip6_address failed to parse %v, expected %04x", vector.input, binstr_to_address(vector.binstr)) + + } else if parsed_ok && !valid { + msg = fmt.tprintf("parse_ip6_address parsed %v into %04x, expected failure", vector.input, parsed) + } + expect(t, parsed_ok == valid, msg) + + if valid && parsed_ok { + actual_binary := address_to_binstr(parsed) + msg = fmt.tprintf("parse_ip6_address parsed %v into %v, expected %v", vector.input, actual_binary, vector.binstr) + expect(t, actual_binary == vector.binstr, msg) + + /* + Do we turn an address back into the same string properly? + No point in testing the roundtrip if the first part failed. + */ + if len(vector.output) > 0 && actual_binary == vector.binstr { + stringified := net.address_to_string(parsed) + msg = fmt.tprintf("address_to_string turned %v into %v, expected %v", parsed, stringified, vector.output) + expect(t, stringified == vector.output, msg) + } + } + } + } +} + +address_to_binstr :: proc(address: net.Address) -> (binstr: string) { + switch t in address { + case net.IP4_Address: + b := transmute(u32be)t + return fmt.tprintf("%08x", b) + case net.IP6_Address: + b := transmute(u128be)t + return fmt.tprintf("%32x", b) + case: + return "" + } + unreachable() +} + +binstr_to_address :: proc(binstr: string) -> (address: net.Address) { + switch len(binstr) { + case 8: // IPv4 + a, ok := strconv.parse_u64_of_base(binstr, 16) + expect(t, ok, "failed to parse test case bin string") + + ipv4 := u32be(a) + return net.IP4_Address(transmute([4]u8)ipv4) + + + case 32: // IPv6 + a, ok := strconv.parse_u128_of_base(binstr, 16) + expect(t, ok, "failed to parse test case bin string") + + ipv4 := u128be(a) + return net.IP6_Address(transmute([8]u16be)ipv4) + + case 0: + return nil + } + panic("Invalid test case") +} + +Kind :: enum { + IP4, // Decimal IPv4 + IP4_Alt, // Non-decimal address + IP6, // Hex IPv6 or mixed IPv4/IPv6. +} + +IP_Address_Parsing_Test_Vector :: struct { + // Give it to the IPv4 or IPv6 parser? + family: Kind, + + // Input address to try and parse. + input: string, + + /* + Hexadecimal representation of the expected numeric value of the address. + Zero length means input is invalid and the parser should report failure. + */ + binstr: string, + + // Expected `address_to_string` output, if a valid input and this string is non-empty. + output: string, +} + +IP_Address_Parsing_Test_Vectors :: []IP_Address_Parsing_Test_Vector{ + // dotted-decimal notation + { .IP4, "0.0.0.0", "00000000", "0.0.0.0" }, + { .IP4, "127.0.0.1", "7f000001", "127.0.0.1" }, + { .IP4, "10.0.128.31", "0a00801f", "10.0.128.31" }, + { .IP4, "255.255.255.255", "ffffffff", "255.255.255.255"}, + + // Odin custom: Address + port, valid + { .IP4, "0.0.0.0:80", "00000000", "0.0.0.0" }, + { .IP4, "127.0.0.1:80", "7f000001", "127.0.0.1" }, + { .IP4, "10.0.128.31:80", "0a00801f", "10.0.128.31" }, + { .IP4, "255.255.255.255:80", "ffffffff", "255.255.255.255"}, + + { .IP4, "[0.0.0.0]:80", "00000000", "0.0.0.0" }, + { .IP4, "[127.0.0.1]:80", "7f000001", "127.0.0.1" }, + { .IP4, "[10.0.128.31]:80", "0a00801f", "10.0.128.31" }, + { .IP4, "[255.255.255.255]:80", "ffffffff", "255.255.255.255"}, + + // Odin custom: Address + port, invalid + { .IP4, "[]:80", "", ""}, + { .IP4, "[0.0.0.0]", "", ""}, + { .IP4, "[127.0.0.1]:", "", ""}, + { .IP4, "[10.0.128.31] :80", "", ""}, + { .IP4, "[255.255.255.255]:65536", "", ""}, + + + // numbers-and-dots notation, but not dotted-decimal + { .IP4_Alt, "1.2.03.4", "01020304", ""}, + { .IP4_Alt, "1.2.0x33.4", "01023304", ""}, + { .IP4_Alt, "1.2.0XAB.4", "0102ab04", ""}, + { .IP4_Alt, "1.2.0xabcd", "0102abcd", ""}, + { .IP4_Alt, "1.0xabcdef", "01abcdef", ""}, + { .IP4_Alt, "0x01abcdef", "01abcdef", ""}, + { .IP4_Alt, "00377.0x0ff.65534", "fffffffe", ""}, + + // invalid as decimal address + { .IP4, "", "", ""}, + { .IP4, ".1.2.3", "", ""}, + { .IP4, "1..2.3", "", ""}, + { .IP4, "1.2.3.", "", ""}, + { .IP4, "1.2.3.4.5", "", ""}, + { .IP4, "1.2.3.a", "", ""}, + { .IP4, "1.256.2.3", "", ""}, + { .IP4, "1.2.4294967296.3", "", ""}, + { .IP4, "1.2.-4294967295.3", "", ""}, + { .IP4, "1.2. 3.4", "", ""}, + + // invalid as non-decimal address + { .IP4_Alt, "", "", ""}, + { .IP4_Alt, ".1.2.3", "", ""}, + { .IP4_Alt, "1..2.3", "", ""}, + { .IP4_Alt, "1.2.3.", "", ""}, + { .IP4_Alt, "1.2.3.4.5", "", ""}, + { .IP4_Alt, "1.2.3.a", "", ""}, + { .IP4_Alt, "1.256.2.3", "", ""}, + { .IP4_Alt, "1.2.4294967296.3", "", ""}, + { .IP4_Alt, "1.2.-4294967295.3", "", ""}, + { .IP4_Alt, "1.2. 3.4", "", ""}, + + // Valid IPv6 addresses + { .IP6, "::", "00000000000000000000000000000000", "::"}, + { .IP6, "::1", "00000000000000000000000000000001", "::1"}, + { .IP6, "::192.168.1.1", "000000000000000000000000c0a80101", "::c0a8:101"}, + { .IP6, "0000:0000:0000:0000:0000:ffff:255.255.255.255", "00000000000000000000ffffffffffff", "::ffff:ffff:ffff"}, + + { .IP6, "0:0:0:0:0:0:192.168.1.1", "000000000000000000000000c0a80101", "::c0a8:101"}, + { .IP6, "0:0::0:0:0:192.168.1.1", "000000000000000000000000c0a80101", "::c0a8:101"}, + { .IP6, "::ffff:192.168.1.1", "00000000000000000000ffffc0a80101", "::ffff:c0a8:101"}, + { .IP6, "a:0b:00c:000d:E:F::", "000a000b000c000d000e000f00000000", "a:b:c:d:e:f::"}, + { .IP6, "1:2:3:4:5:6::", "00010002000300040005000600000000", "1:2:3:4:5:6::"}, + { .IP6, "1:2:3:4:5:6:7::", "00010002000300040005000600070000", "1:2:3:4:5:6:7:0"}, + { .IP6, "::1:2:3:4:5:6", "00000000000100020003000400050006", "::1:2:3:4:5:6"}, + { .IP6, "::1:2:3:4:5:6:7", "00000001000200030004000500060007", "0:1:2:3:4:5:6:7"}, + { .IP6, "a:b::c:d:e:f", "000a000b00000000000c000d000e000f", "a:b::c:d:e:f"}, + { .IP6, "0:0:0:0:0:ffff:c0a8:5e4", "00000000000000000000ffffc0a805e4", "::ffff:c0a8:5e4"}, + { .IP6, "0::ffff:c0a8:5e4", "00000000000000000000ffffc0a805e4", "::ffff:c0a8:5e4"}, + + + // If multiple zero runs are present, shorten the longest one. + { .IP6, "1:0:0:2:0:0:0:3", "00010000000000020000000000000003", "1:0:0:2::3"}, + + // Invalid IPv6 addresses + { .IP6, "", "", ""}, + { .IP6, ":", "", ""}, + { .IP6, ":::", "", ""}, + { .IP6, "192.168.1.1", "", ""}, + { .IP6, ":192.168.1.1", "", ""}, + { .IP6, "::012.34.56.78", "", ""}, + { .IP6, ":ffff:192.168.1.1", "", ""}, + { .IP6, ".192.168.1.1", "", ""}, + { .IP6, ":.192.168.1.1", "", ""}, + { .IP6, "a:0b:00c:000d:0000e:f::", "", ""}, + { .IP6, "1:2:3:4:5:6:7:8::", "", ""}, + { .IP6, "1:2:3:4:5:6:7::9", "", ""}, + { .IP6, "::1:2:3:4:5:6:7:8", "", ""}, + { .IP6, "ffff:c0a8:5e4", "", ""}, + { .IP6, ":ffff:c0a8:5e4", "", ""}, + { .IP6, "0:0:0:0:ffff:c0a8:5e4", "", ""}, + { .IP6, "::0::ffff:c0a8:5e4", "", ""}, + { .IP6, "c0a8", "", ""}, +} + + +ENDPOINT := net.Endpoint{ + net.IP4_Address{127, 0, 0, 1}, + 9999, +} + +CONTENT := "Hellope!" + +SEND_TIMEOUT :: time.Duration(1 * time.Second) +RECV_TIMEOUT :: time.Duration(1 * time.Second) + +Thread_Data :: struct { + skt: net.Any_Socket, + err: net.Network_Error, + tid: ^thread.Thread, + + no_accept: bool, // Tell the server proc not to accept. + + data: [1024]u8, // Received data and its length + length: int, +} + +thread_data := [3]Thread_Data{} + +/* + This runs a bunch of socket tests using threads: + - two servers trying to bind the same endpoint + - client trying to connect to closed port + - client trying to connect to an open port with a non-accepting server + - client sending server data and server sending client data + - etc. +*/ +tcp_tests :: proc(t: ^testing.T) { + fmt.println("Testing two servers trying to bind to the same endpoint...") + two_servers_binding_same_endpoint(t) + fmt.println("Testing client connecting to a closed port...") + client_connects_to_closed_port(t) + fmt.println("Testing client connecting to port that doesn't accept...") + client_connects_to_open_but_non_accepting_port(t) + fmt.println("Testing client sending server data...") + client_sends_server_data(t) +} + +tcp_client :: proc(retval: rawptr) { + send :: proc(content: []u8) -> (err: net.Network_Error) { + skt := net.dial_tcp(ENDPOINT) or_return + defer net.close(skt) + + net.set_option(skt, .Send_Timeout, SEND_TIMEOUT) + net.set_option(skt, .Receive_Timeout, RECV_TIMEOUT) + + _, err = net.send(skt, content) + return + } + + r := transmute(^Thread_Data)retval + r.err = send(transmute([]u8)CONTENT) + return +} + +tcp_server :: proc(retval: rawptr) { + r := transmute(^Thread_Data)retval + + if r.skt, r.err = net.listen_tcp(ENDPOINT); r.err != nil { + return + } + defer net.close(r.skt) + + if r.no_accept { + // Don't accept any connections, just listen. + return + } + + client: net.TCP_Socket + if client, _, r.err = net.accept_tcp(r.skt.(net.TCP_Socket)); r.err != nil { + return + } + defer net.close(client) + + + r.length, r.err = net.recv_tcp(client, r.data[:]) + return +} + +cleanup_thread :: proc(data: Thread_Data) { + net.close(data.skt) + + thread.terminate(data.tid, 1) + thread.destroy(data.tid) +} + +two_servers_binding_same_endpoint :: proc(t: ^testing.T) { + thread_data = {} + + thread_data[0].tid = thread.create_and_start_with_data(&thread_data[0], tcp_server, context) + thread_data[1].tid = thread.create_and_start_with_data(&thread_data[1], tcp_server, context) + + defer { + cleanup_thread(thread_data[0]) + cleanup_thread(thread_data[1]) + } + + // Give the two servers enough time to try and bind the same endpoint + time.sleep(1 * time.Second) + + first_won := thread_data[0].err == nil && thread_data[1].err == net.Bind_Error.Address_In_Use + second_won := thread_data[1].err == nil && thread_data[0].err == net.Bind_Error.Address_In_Use + + okay := first_won || second_won + msg := fmt.tprintf("Expected servers to return `nil` and `Address_In_Use`, got %v and %v", thread_data[0].err, thread_data[1].err) + expect(t, okay, msg) +} + +client_connects_to_closed_port :: proc(t: ^testing.T) { + thread_data = {} + + thread_data[0].tid = thread.create_and_start_with_data(&thread_data[0], tcp_client, context) + + defer { + cleanup_thread(thread_data[0]) + } + + // Give the socket enough time to return `Refused` + time.sleep(4 * time.Second) + + okay := thread_data[0].err == net.Dial_Error.Refused + msg := fmt.tprintf("Expected client to return `Refused` connecting to closed port, got %v", thread_data[0].err) + expect(t, okay, msg) +} + +client_connects_to_open_but_non_accepting_port :: proc(t: ^testing.T) { + thread_data = {} + + // Tell server proc not to accept + thread_data[0].no_accept = true + + thread_data[0].tid = thread.create_and_start_with_data(&thread_data[0], tcp_server, context) + thread_data[1].tid = thread.create_and_start_with_data(&thread_data[1], tcp_client, context) + + defer { + cleanup_thread(thread_data[0]) + cleanup_thread(thread_data[1]) + } + + // Give the two servers enough time to try and bind the same endpoint + time.sleep(4 * time.Second) + + okay := thread_data[0].err == nil && thread_data[1].err == net.Dial_Error.Refused + msg := fmt.tprintf("Expected server and client to return `nil` and `Refused`, got %v and %v", thread_data[0].err, thread_data[1].err) + expect(t, okay, msg) +} + +client_sends_server_data :: proc(t: ^testing.T) { + thread_data = {} + + // Tell server proc not to accept + // thread_data[0].no_accept = true + + thread_data[0].tid = thread.create_and_start_with_data(&thread_data[0], tcp_server, context) + thread_data[1].tid = thread.create_and_start_with_data(&thread_data[1], tcp_client, context) + + defer { + cleanup_thread(thread_data[0]) + cleanup_thread(thread_data[1]) + } + + // Give the two servers enough time to try and bind the same endpoint + time.sleep(1 * time.Second) + + okay := thread_data[0].err == nil && thread_data[1].err == nil + msg := fmt.tprintf("Expected client and server to return `nil`, got %v and %v", thread_data[0].err, thread_data[1].err) + expect(t, okay, msg) + + received := string(thread_data[0].data[:thread_data[0].length]) + + okay = received == CONTENT + msg = fmt.tprintf("Expected client to send \"{}\", got \"{}\"", CONTENT, received) + expect(t, okay, msg) +} + +URL_Test :: struct { + scheme, host, path: string, + queries: map[string]string, + url: string, +} + +@test +split_url_test :: proc(t: ^testing.T) { + test_cases := []URL_Test{ + { "http", "example.com", "/", {}, "http://example.com" }, + { "https", "odin-lang.org", "/", {}, "https://odin-lang.org" }, + { "https", "odin-lang.org", "/docs/", {}, "https://odin-lang.org/docs/" }, + { "https", "odin-lang.org", "/docs/overview", {}, "https://odin-lang.org/docs/overview" }, + { "http", "example.com", "/", {"a" = "b"}, "http://example.com?a=b" }, + { "http", "example.com", "/", {"a" = ""}, "http://example.com?a" }, + { "http", "example.com", "/", {"a" = "b", "c" = "d"}, "http://example.com?a=b&c=d" }, + { "http", "example.com", "/", {"a" = "", "c" = "d"}, "http://example.com?a&c=d" }, + { "http", "example.com", "/example", {"a" = "", "b" = ""}, "http://example.com/example?a&b" }, + } + + for test in test_cases { + scheme, host, path, queries := net.split_url(test.url) + defer { + delete(queries) + delete(test.queries) + } + + msg := fmt.tprintf("Expected `net.split_url` to return %s, got %s", test.scheme, scheme) + expect(t, scheme == test.scheme, msg) + msg = fmt.tprintf("Expected `net.split_url` to return %s, got %s", test.host, host) + expect(t, host == test.host, msg) + msg = fmt.tprintf("Expected `net.split_url` to return %s, got %s", test.path, path) + expect(t, path == test.path, msg) + msg = fmt.tprintf("Expected `net.split_url` to return %d queries, got %d queries", len(test.queries), len(queries)) + expect(t, len(queries) == len(test.queries), msg) + for k, v in queries { + expected := test.queries[k] + msg = fmt.tprintf("Expected `net.split_url` to return %s, got %s", expected, v) + expect(t, v == expected, msg) + } + } +} + + +@test +join_url_test :: proc(t: ^testing.T) { + test_cases := []URL_Test{ + { "http", "example.com", "", {}, "http://example.com" }, + { "https", "odin-lang.org", "", {}, "https://odin-lang.org" }, + { "https", "odin-lang.org", "docs/", {}, "https://odin-lang.org/docs/" }, + { "https", "odin-lang.org", "/docs/overview", {}, "https://odin-lang.org/docs/overview" }, + { "http", "example.com", "", {"a" = "b"}, "http://example.com?a=b" }, + { "http", "example.com", "", {"a" = ""}, "http://example.com?a" }, + { "http", "example.com", "", {"a" = "b", "c" = "d"}, "http://example.com?a=b&c=d" }, + { "http", "example.com", "", {"a" = "", "c" = "d"}, "http://example.com?a&c=d" }, + { "http", "example.com", "example", {"a" = "", "b" = ""}, "http://example.com/example?a&b" }, + } + + for test in test_cases { + url := net.join_url(test.scheme, test.host, test.path, test.queries) + defer { + delete(url) + delete(test.queries) + } + + okay := url == test.url + msg := fmt.tprintf("Expected `net.join_url` to return %s, got %s", test.url, url) + expect(t, okay, msg) + } +} diff --git a/tests/core/strings/test_core_strings.odin b/tests/core/strings/test_core_strings.odin index e97734dda..fdaf3af28 100644 --- a/tests/core/strings/test_core_strings.odin +++ b/tests/core/strings/test_core_strings.odin @@ -4,6 +4,8 @@ import "core:strings" import "core:testing" import "core:fmt" import "core:os" +import "core:runtime" +import "core:mem" TEST_count := 0 TEST_fail := 0 @@ -33,6 +35,7 @@ main :: proc() { test_index_any_small_string_found(&t) test_index_any_larger_string_found(&t) test_cut(&t) + test_case_conversion(&t) fmt.printf("%v/%v tests successful.\n", TEST_count - TEST_fail, TEST_count) if TEST_fail > 0 { @@ -89,4 +92,61 @@ test_cut :: proc(t: ^testing.T) { test.input, test.offset, test.length, test.output, res) expect(t, res == test.output, msg) } +} + +Case_Kind :: enum { + Lower_Space_Case, + Upper_Space_Case, + Lower_Snake_Case, + Upper_Snake_Case, + Lower_Kebab_Case, + Upper_Kebab_Case, + Camel_Case, + Pascal_Case, + Ada_Case, +} + +Case_Proc :: proc(r: string, allocator: runtime.Allocator) -> (string, mem.Allocator_Error) + +test_cases := [Case_Kind]struct{s: string, p: Case_Proc}{ + .Lower_Space_Case = {"hellope world", to_lower_space_case}, + .Upper_Space_Case = {"HELLOPE WORLD", to_upper_space_case}, + .Lower_Snake_Case = {"hellope_world", to_snake_case}, + .Upper_Snake_Case = {"HELLOPE_WORLD", to_upper_snake_case}, + .Lower_Kebab_Case = {"hellope-world", to_kebab_case}, + .Upper_Kebab_Case = {"HELLOPE-WORLD", to_upper_kebab_case}, + .Camel_Case = {"hellopeWorld", to_camel_case}, + .Pascal_Case = {"HellopeWorld", to_pascal_case}, + .Ada_Case = {"Hellope_World", to_ada_case}, +} + +to_lower_space_case :: proc(r: string, allocator: runtime.Allocator) -> (string, mem.Allocator_Error) { + return strings.to_delimiter_case(r, ' ', false, allocator) +} +to_upper_space_case :: proc(r: string, allocator: runtime.Allocator) -> (string, mem.Allocator_Error) { + return strings.to_delimiter_case(r, ' ', true, allocator) +} + +// NOTE: we have these wrappers as having #optional_allocator_error changes the type to not be equivalent +to_snake_case :: proc(r: string, allocator: runtime.Allocator) -> (string, mem.Allocator_Error) { return strings.to_snake_case(r, allocator) } +to_upper_snake_case :: proc(r: string, allocator: runtime.Allocator) -> (string, mem.Allocator_Error) { return strings.to_upper_snake_case(r, allocator) } +to_kebab_case :: proc(r: string, allocator: runtime.Allocator) -> (string, mem.Allocator_Error) { return strings.to_kebab_case(r, allocator) } +to_upper_kebab_case :: proc(r: string, allocator: runtime.Allocator) -> (string, mem.Allocator_Error) { return strings.to_upper_kebab_case(r, allocator) } +to_camel_case :: proc(r: string, allocator: runtime.Allocator) -> (string, mem.Allocator_Error) { return strings.to_camel_case(r, allocator) } +to_pascal_case :: proc(r: string, allocator: runtime.Allocator) -> (string, mem.Allocator_Error) { return strings.to_pascal_case(r, allocator) } +to_ada_case :: proc(r: string, allocator: runtime.Allocator) -> (string, mem.Allocator_Error) { return strings.to_ada_case(r, allocator) } + +@test +test_case_conversion :: proc(t: ^testing.T) { + for entry in test_cases { + for test_case, case_kind in test_cases { + result, err := entry.p(test_case.s, context.allocator) + msg := fmt.tprintf("ERROR: We got the allocation error '{}'\n", err) + expect(t, err == nil, msg) + defer delete(result) + + msg = fmt.tprintf("ERROR: Input `{}` to converter {} does not match `{}`, got `{}`.\n", test_case.s, case_kind, entry.s, result) + expect(t, result == entry.s, msg) + } + } } \ No newline at end of file diff --git a/tests/documentation/build.bat b/tests/documentation/build.bat new file mode 100644 index 000000000..6ca90fbad --- /dev/null +++ b/tests/documentation/build.bat @@ -0,0 +1,13 @@ +@echo off +set PATH_TO_ODIN==..\..\odin + +echo --- +echo Building Documentation File +echo --- +%PATH_TO_ODIN% doc ..\..\examples\all -all-packages -doc-format || exit /b + + +echo --- +echo Running Documentation Tester +echo --- +%PATH_TO_ODIN% run documentation_tester.odin -file -vet -strict-style -- %PATH_TO_ODIN% || exit /b diff --git a/tests/documentation/documentation_tester.odin b/tests/documentation/documentation_tester.odin new file mode 100644 index 000000000..a4d18d1eb --- /dev/null +++ b/tests/documentation/documentation_tester.odin @@ -0,0 +1,470 @@ +package documentation_tester + +import "core:os" +import "core:io" +import "core:fmt" +import "core:strings" +import "core:odin/ast" +import "core:odin/parser" +import "core:c/libc" +import doc "core:odin/doc-format" + +Example_Test :: struct { + entity_name: string, + package_name: string, + example_code: []string, + expected_output: []string, + skip_output_check: bool, +} + +g_header: ^doc.Header +g_bad_doc: bool +g_examples_to_verify: [dynamic]Example_Test +g_path_to_odin: string + +array :: proc(a: $A/doc.Array($T)) -> []T { + return doc.from_array(g_header, a) +} + +str :: proc(s: $A/doc.String) -> string { + return doc.from_string(g_header, s) +} + +common_prefix :: proc(strs: []string) -> string { + if len(strs) == 0 { + return "" + } + n := max(int) + for str in strs { + n = min(n, len(str)) + } + + prefix := strs[0][:n] + for str in strs[1:] { + for len(prefix) != 0 && str[:len(prefix)] != prefix { + prefix = prefix[:len(prefix)-1] + } + if len(prefix) == 0 { + break + } + } + return prefix +} + +errorf :: proc(format: string, args: ..any) -> ! { + fmt.eprintf("%s ", os.args[0]) + fmt.eprintf(format, ..args) + fmt.eprintln() + os.exit(1) +} + +main :: proc() { + if len(os.args) != 2 { + errorf("expected path to odin executable") + } + g_path_to_odin = os.args[1] + data, ok := os.read_entire_file("all.odin-doc") + if !ok { + errorf("unable to read file: all.odin-doc") + } + err: doc.Reader_Error + g_header, err = doc.read_from_bytes(data) + switch err { + case .None: + case .Header_Too_Small: + errorf("file is too small for the file format") + case .Invalid_Magic: + errorf("invalid magic for the file format") + case .Data_Too_Small: + errorf("data is too small for the file format") + case .Invalid_Version: + errorf("invalid file format version") + } + pkgs := array(g_header.pkgs) + entities := array(g_header.entities) + + path_prefix: string + { + fullpaths: [dynamic]string + defer delete(fullpaths) + + for pkg in pkgs[1:] { + append(&fullpaths, str(pkg.fullpath)) + } + path_prefix = common_prefix(fullpaths[:]) + } + + for pkg in pkgs[1:] { + entries_array := array(pkg.entries) + fullpath := str(pkg.fullpath) + path := strings.trim_prefix(fullpath, path_prefix) + if ! strings.has_prefix(path, "core/") { + continue + } + trimmed_path := strings.trim_prefix(path, "core/") + if strings.has_prefix(trimmed_path, "sys") { + continue + } + if strings.contains(trimmed_path, "/_") { + continue + } + for entry in entries_array { + entity := entities[entry.entity] + find_and_add_examples( + docs = str(entity.docs), + package_name = str(pkg.name), + entity_name = str(entity.name), + ) + } + } + write_test_suite(g_examples_to_verify[:]) + if g_bad_doc { + errorf("We created bad documentation!") + } + + if ! run_test_suite() { + errorf("Test suite failed!") + } + fmt.println("Examples verified") +} + +// NOTE: this is a pretty close copy paste from the website pkg documentation on parsing the docs +find_and_add_examples :: proc(docs: string, package_name: string, entity_name: string) { + if docs == "" { + return + } + Block_Kind :: enum { + Other, + Example, + Output, + } + Block :: struct { + kind: Block_Kind, + lines: []string, + } + lines := strings.split_lines(docs) + curr_block_kind := Block_Kind.Other + start := 0 + + found_possible_output: bool + example_block: Block // when set the kind should be Example + output_block: Block // when set the kind should be Output + // rely on zii that the kinds have not been set + assert(example_block.kind != .Example) + assert(output_block.kind != .Output) + + insert_block :: proc(block: Block, example: ^Block, output: ^Block, name: string) { + switch block.kind { + case .Other: + case .Example: + if example.kind == .Example { + fmt.eprintf("The documentation for %q has multiple examples which is not allowed\n", name) + g_bad_doc = true + } + example^ = block + case .Output: output^ = block + if example.kind == .Output { + fmt.eprintf("The documentation for %q has multiple output which is not allowed\n", name) + g_bad_doc = true + } + output^ = block + } + } + + for line, i in lines { + text := strings.trim_space(line) + next_block_kind := curr_block_kind + + switch curr_block_kind { + case .Other: + switch { + case strings.has_prefix(line, "Example:"): next_block_kind = .Example + case strings.has_prefix(line, "Output:"): next_block_kind = .Output + case strings.has_prefix(line, "Possible Output:"): + next_block_kind = .Output + found_possible_output = true + } + case .Example: + switch { + case strings.has_prefix(line, "Output:"): next_block_kind = .Output + case strings.has_prefix(line, "Possible Output:"): + next_block_kind = .Output + found_possible_output = true + case ! (text == "" || strings.has_prefix(line, "\t")): next_block_kind = .Other + } + case .Output: + switch { + case strings.has_prefix(line, "Example:"): next_block_kind = .Example + case ! (text == "" || strings.has_prefix(line, "\t")): next_block_kind = .Other + } + } + + if i-start > 0 && (curr_block_kind != next_block_kind) { + insert_block(Block{curr_block_kind, lines[start:i]}, &example_block, &output_block, entity_name) + curr_block_kind, start = next_block_kind, i + } + } + + if start < len(lines) { + insert_block(Block{curr_block_kind, lines[start:]}, &example_block, &output_block, entity_name) + } + + if output_block.kind == .Output && example_block.kind != .Example { + fmt.eprintf("The documentation for %q has an output block but no example\n", entity_name) + g_bad_doc = true + } + + // Write example and output block if they're both present + if example_block.kind == .Example && output_block.kind == .Output { + { + // Example block starts with + // `Example:` and a number of white spaces, + lines := &example_block.lines + for len(lines) > 0 && (strings.trim_space(lines[0]) == "" || strings.has_prefix(lines[0], "Example:")) { + lines^ = lines[1:] + } + } + { + // Output block starts with + // `Output:` and a number of white spaces, + // `Possible Output:` and a number of white spaces, + lines := &output_block.lines + for len(lines) > 0 && (strings.trim_space(lines[0]) == "" || strings.has_prefix(lines[0], "Output:") || strings.has_prefix(lines[0], "Possible Output:")) { + lines^ = lines[1:] + } + // Additionally we need to strip all empty lines at the end of output to not include those in the expected output + for len(lines) > 0 && (strings.trim_space(lines[len(lines) - 1]) == "") { + lines^ = lines[:len(lines) - 1] + } + } + // Remove first layer of tabs which are always present + for line in &example_block.lines { + line = strings.trim_prefix(line, "\t") + } + for line in &output_block.lines { + line = strings.trim_prefix(line, "\t") + } + append(&g_examples_to_verify, Example_Test { + entity_name = entity_name, + package_name = package_name, + example_code = example_block.lines, + expected_output = output_block.lines, + skip_output_check = found_possible_output, + }) + } +} + + +write_test_suite :: proc(example_tests: []Example_Test) { + TEST_SUITE_DIRECTORY :: "verify" + os.remove_directory(TEST_SUITE_DIRECTORY) + os.make_directory(TEST_SUITE_DIRECTORY) + + example_build := strings.builder_make() + test_runner := strings.builder_make() + + strings.write_string(&test_runner, +`//+private +package documentation_verification + +import "core:os" +import "core:mem" +import "core:io" +import "core:fmt" +import "core:thread" +import "core:sync" +import "core:intrinsics" + +@(private="file") +_read_pipe: os.Handle +@(private="file") +_write_pipe: os.Handle +@(private="file") +_pipe_reader_semaphore: sync.Sema +@(private="file") +_out_data: string +@(private="file") +_out_buffer: [mem.Megabyte]byte +@(private="file") +_bad_test_found: bool + +@(private="file") +_spawn_pipe_reader :: proc() { + thread.run(proc() { + stream := os.stream_from_handle(_read_pipe) + reader := io.to_reader(stream) + sync.post(&_pipe_reader_semaphore) // notify thread is ready + for { + n_read := 0 + read_to_null_byte := 0 + finished_reading := false + for ! finished_reading { + just_read, err := io.read(reader, _out_buffer[n_read:], &n_read); if err != .None { + panic("We got an IO error!") + } + for b in _out_buffer[n_read - just_read: n_read] { + if b == 0 { + finished_reading = true + break + } + read_to_null_byte += 1 + } + } + intrinsics.volatile_store(&_out_data, transmute(string)_out_buffer[:read_to_null_byte]) + sync.post(&_pipe_reader_semaphore) // notify we read the null byte + } + }) + + sync.wait(&_pipe_reader_semaphore) // wait for thread to be ready +} + +@(private="file") +_check :: proc(test_name: string, expected: string) { + null_byte: [1]byte + os.write(_write_pipe, null_byte[:]) + os.flush(_write_pipe) + sync.wait(&_pipe_reader_semaphore) + output := intrinsics.volatile_load(&_out_data) // wait for thread to read null byte + if expected != output { + fmt.eprintf("Test %q got unexpected output:\n%q\n", test_name, output) + fmt.eprintf("Expected:\n%q\n", expected) + _bad_test_found = true + } +} + +main :: proc() { + _read_pipe, _write_pipe, _ = os.pipe() + os.stdout = _write_pipe + _spawn_pipe_reader() +`) + + Found_Proc :: struct { + name: string, + type: string, + } + found_procedures_for_error_msg: [dynamic]Found_Proc + + for test in example_tests { + fmt.printf("--- Generating documentation test for \"%v.%v\"\n", test.package_name, test.entity_name) + clear(&found_procedures_for_error_msg) + strings.builder_reset(&example_build) + strings.write_string(&example_build, "package documentation_verification\n\n") + for line in test.example_code { + strings.write_string(&example_build, line) + strings.write_byte(&example_build, '\n') + } + + code_string := strings.to_string(example_build) + + example_ast := ast.File { src = code_string } + odin_parser := parser.default_parser() + + if ! parser.parse_file(&odin_parser, &example_ast) { + g_bad_doc = true + continue + } + if odin_parser.error_count > 0 { + fmt.eprintf("Errors on the following code generated for %q:\n%v\n", test.entity_name, code_string) + g_bad_doc = true + continue + } + + enforced_name := fmt.tprintf("%v_example", test.entity_name) + index_of_proc_name: int + code_test_name: string + + for d in example_ast.decls { + value_decl, is_value := d.derived.(^ast.Value_Decl); if ! is_value { + continue + } + if len(value_decl.values) != 1 { + continue + } + proc_lit, is_proc_lit := value_decl.values[0].derived_expr.(^ast.Proc_Lit); if ! is_proc_lit { + continue + } + append(&found_procedures_for_error_msg, Found_Proc { + name = code_string[value_decl.names[0].pos.offset:value_decl.names[0].end.offset], + type = code_string[proc_lit.type.pos.offset:proc_lit.type.end.offset], + }) + if len(proc_lit.type.params.list) > 0 { + continue + } + this_procedure_name := code_string[value_decl.names[0].pos.offset:value_decl.names[0].end.offset] + if this_procedure_name != enforced_name { + continue + } + index_of_proc_name = value_decl.names[0].pos.offset + code_test_name = this_procedure_name + break + } + + if code_test_name == "" { + fmt.eprintf("We could not find the procedure \"%s :: proc()\" needed to test the example created for \"%s.%s\"\n", enforced_name, test.package_name, test.entity_name) + if len(found_procedures_for_error_msg) > 0{ + fmt.eprint("The following procedures were found:\n") + for procedure in found_procedures_for_error_msg { + fmt.eprintf("\t%s :: %s\n", procedure.name, procedure.type) + } + } else { + fmt.eprint("No procedures were found?\n") + } + // NOTE: we don't want to fail the CI in this case, just put the error in the log and test everything else + // g_bad_doc = true + continue + } + + // NOTE: packages like 'rand' are random by nature, in these cases we cannot verify against the output string + // in these cases we just mark the output as 'Possible Output' and we simply skip checking against the output + if ! test.skip_output_check { + fmt.sbprintf(&test_runner, "\t%v_%v()\n", test.package_name, code_test_name) + fmt.sbprintf(&test_runner, "\t_check(%q, `", code_test_name) + had_line_error: bool + for line in test.expected_output { + // NOTE: this will escape the multiline string. Even with a backslash it still escapes due to the semantics of ` + // I don't think any examples would really need this specific character so let's just make it forbidden and change + // in the future if we really need to + if strings.contains_rune(line, '`') { + fmt.eprintf("The line %q in the output for \"%s.%s\" contains a ` which is not allowed\n", line, test.package_name, test.entity_name) + g_bad_doc = true + had_line_error = true + } + strings.write_string(&test_runner, line) + strings.write_string(&test_runner, "\n") + } + if had_line_error { + continue + } + strings.write_string(&test_runner, "`)\n") + } + save_path := fmt.tprintf("verify/test_%v_%v.odin", test.package_name, code_test_name) + + test_file_handle, err := os.open(save_path, os.O_WRONLY | os.O_CREATE); if err != 0 { + fmt.eprintf("We could not open the file to the path %q for writing\n", save_path) + g_bad_doc = true + continue + } + defer os.close(test_file_handle) + stream := os.stream_from_handle(test_file_handle) + writer, ok := io.to_writer(stream); if ! ok { + fmt.eprintf("We could not make the writer for the path %q\n", save_path) + g_bad_doc = true + continue + } + fmt.wprintf(writer, "%v%v_%v", code_string[:index_of_proc_name], test.package_name, code_string[index_of_proc_name:]) + fmt.println("Done") + } + + strings.write_string(&test_runner, +` + if _bad_test_found { + fmt.eprintln("One or more tests failed") + os.exit(1) + } +}`) + os.write_entire_file("verify/main.odin", transmute([]byte)strings.to_string(test_runner)) +} + +run_test_suite :: proc() -> bool { + return libc.system(fmt.caprintf("%v run verify", g_path_to_odin)) == 0 +} diff --git a/tests/internal/build.bat b/tests/internal/build.bat index 313e1dbb5..995086523 100644 --- a/tests/internal/build.bat +++ b/tests/internal/build.bat @@ -1,4 +1,4 @@ @echo off set PATH_TO_ODIN==..\..\odin -%PATH_TO_ODIN% run test_map.odin -file -vet -strict-style -o:minimal +%PATH_TO_ODIN% run test_map.odin -file -vet -strict-style -o:minimal || exit /b rem -define:SEED=42 \ No newline at end of file diff --git a/tests/issues/run.bat b/tests/issues/run.bat index c526fd472..bf49bc85b 100644 --- a/tests/issues/run.bat +++ b/tests/issues/run.bat @@ -5,19 +5,16 @@ pushd build set COMMON=-collection:tests=..\.. -set ERROR_DID_OCCUR=0 - @echo on -..\..\..\odin test ..\test_issue_829.odin %COMMON% -file -..\..\..\odin test ..\test_issue_1592.odin %COMMON% -file -..\..\..\odin test ..\test_issue_2087.odin %COMMON% -file -..\..\..\odin build ..\test_issue_2113.odin %COMMON% -file -debug +..\..\..\odin test ..\test_issue_829.odin %COMMON% -file || exit /b +..\..\..\odin test ..\test_issue_1592.odin %COMMON% -file || exit /b +..\..\..\odin test ..\test_issue_2056.odin %COMMON% -file || exit /b +..\..\..\odin test ..\test_issue_2087.odin %COMMON% -file || exit /b +..\..\..\odin build ..\test_issue_2113.odin %COMMON% -file -debug || exit /b +..\..\..\odin test ..\test_issue_2466.odin %COMMON% -file || exit /b @echo off -if %ERRORLEVEL% NEQ 0 set ERROR_DID_OCCUR=1 - popd rmdir /S /Q build -if %ERROR_DID_OCCUR% NEQ 0 EXIT /B 1 diff --git a/tests/issues/run.sh b/tests/issues/run.sh index 440c953d9..b0c43572f 100755 --- a/tests/issues/run.sh +++ b/tests/issues/run.sh @@ -6,12 +6,21 @@ pushd build ODIN=../../../odin COMMON="-collection:tests=../.." +NO_NIL_ERR="Error: " + set -x $ODIN test ../test_issue_829.odin $COMMON -file $ODIN test ../test_issue_1592.odin $COMMON -file +$ODIN test ../test_issue_2056.odin $COMMON -file $ODIN test ../test_issue_2087.odin $COMMON -file $ODIN build ../test_issue_2113.odin $COMMON -file -debug +$ODIN test ../test_issue_2466.odin $COMMON -file +if [[ $($ODIN build ../test_issue_2395.odin $COMMON -file 2>&1 >/dev/null | grep -c "$NO_NIL_ERR") -eq 2 ]] ; then + echo "SUCCESSFUL 1/1" +else + echo "SUCCESSFUL 0/1" +fi set +x diff --git a/tests/issues/test_issue_2056.odin b/tests/issues/test_issue_2056.odin new file mode 100644 index 000000000..4869b557e --- /dev/null +++ b/tests/issues/test_issue_2056.odin @@ -0,0 +1,22 @@ +// Tests issue #2056 https://github.com/odin-lang/Odin/issues/2056 +package test_issues + +import "core:fmt" +import "core:testing" + +@test +test_scalar_matrix_conversion :: proc(t: ^testing.T) { + l := f32(1.0) + m := (matrix[4,4]f32)(l) + + for i in 0..<4 { + for j in 0..<4 { + if i == j { + testing.expect(t, m[i,j] == 1, fmt.tprintf("expected 1 at m[%d,%d], found %f\n", i, j, m[i,j])) + } else { + testing.expect(t, m[i,j] == 0, fmt.tprintf("expected 0 at m[%d,%d], found %f\n", i, j, m[i,j])) + } + } + } +} + diff --git a/tests/issues/test_issue_2395.odin b/tests/issues/test_issue_2395.odin new file mode 100644 index 000000000..48e1ee516 --- /dev/null +++ b/tests/issues/test_issue_2395.odin @@ -0,0 +1,29 @@ +// Tests issue #2395 https://github.com/odin-lang/Odin/issues/2395 + +// Ensures that we no longer raise the faulty error for #no_nil unions when +// then are 2 variants with the polymorphic type. Also ensure that we raise +// exactly 2 errors from the invalid unions +package test_issues + +import "core:testing" + +ValidUnion :: union($T: typeid) #no_nil { + T, + f32, +} + +OtherValidUnion :: union($T: typeid, $S: typeid) #no_nil { + T, + S, +} + +InvalidUnion :: union($T: typeid) #no_nil { + T, +} + +OtherInvalidUnion :: union($T: typeid) #no_nil { + u8, +} + +main :: proc() { +} diff --git a/tests/issues/test_issue_2466.odin b/tests/issues/test_issue_2466.odin new file mode 100644 index 000000000..4810cfea9 --- /dev/null +++ b/tests/issues/test_issue_2466.odin @@ -0,0 +1,22 @@ +// Tests issue #2466 https://github.com/odin-lang/Odin/issues/2466 +package test_issues + +import "core:fmt" +import "core:testing" + +Bug :: struct { + val: int, + arr: []int, +} + +@test +test_compound_literal_local_reuse :: proc(t: ^testing.T) { + v: int = 123 + bug := Bug { + val = v, + arr = {42}, + } + testing.expect(t, bug.val == 123, fmt.tprintf("expected 123, found %d", bug.val)) + testing.expect(t, bug.arr[0] == 42, fmt.tprintf("expected 42, found %d", bug.arr[0])) +} + diff --git a/tests/vendor/botan-3.dll b/tests/vendor/botan-3.dll new file mode 100644 index 000000000..d8f04720b Binary files /dev/null and b/tests/vendor/botan-3.dll differ diff --git a/tests/vendor/botan.dll b/tests/vendor/botan.dll deleted file mode 100644 index 423231d86..000000000 Binary files a/tests/vendor/botan.dll and /dev/null differ diff --git a/tests/vendor/botan/test_vendor_botan.odin b/tests/vendor/botan/test_vendor_botan.odin index 0a93723c8..51043d813 100644 --- a/tests/vendor/botan/test_vendor_botan.odin +++ b/tests/vendor/botan/test_vendor_botan.odin @@ -70,8 +70,8 @@ main :: proc() { test_sha3_256(&t) test_sha3_384(&t) test_sha3_512(&t) - test_shake_128(&t) - test_shake_256(&t) + // test_shake_128(&t) + // test_shake_256(&t) test_keccak_512(&t) test_whirlpool(&t) test_gost(&t) @@ -79,9 +79,9 @@ main :: proc() { test_streebog_512(&t) test_blake2b(&t) test_ripemd_160(&t) - test_tiger_128(&t) - test_tiger_160(&t) - test_tiger_192(&t) + // test_tiger_128(&t) + // test_tiger_160(&t) + // test_tiger_192(&t) test_sm3(&t) test_skein512_256(&t) test_skein512_512(&t) diff --git a/tests/vendor/build.bat b/tests/vendor/build.bat index d92a5eaea..09754fc40 100644 --- a/tests/vendor/build.bat +++ b/tests/vendor/build.bat @@ -5,9 +5,9 @@ set PATH_TO_ODIN==..\..\odin echo --- echo Running vendor:botan tests echo --- -%PATH_TO_ODIN% run botan %COMMON% -out:vendor_botan.exe +%PATH_TO_ODIN% run botan %COMMON% -out:vendor_botan.exe || exit /b echo --- echo Running vendor:glfw tests echo --- -%PATH_TO_ODIN% run glfw %COMMON% -out:vendor_glfw.exe \ No newline at end of file +%PATH_TO_ODIN% run glfw %COMMON% -out:vendor_glfw.exe || exit /b \ No newline at end of file diff --git a/tools/odinfmt/flag/flag.odin b/tools/odinfmt/flag/flag.odin deleted file mode 100644 index 6b2525717..000000000 --- a/tools/odinfmt/flag/flag.odin +++ /dev/null @@ -1,211 +0,0 @@ -package flag - -import "core:runtime" -import "core:strings" -import "core:reflect" -import "core:fmt" -import "core:mem" -import "core:strconv" - -Flag_Error :: enum { - None, - No_Base_Struct, - Arg_Error, - Arg_Unsupported_Field_Type, - Arg_Not_Defined, - Arg_Non_Optional, - Value_Parse_Error, - Tag_Error, -} - -Flag :: struct { - optional: bool, - type: ^runtime.Type_Info, - data: rawptr, - tag_ptr: rawptr, - parsed: bool, -} - -Flag_Context :: struct { - seen_flags: map[string]Flag, -} - -parse_args :: proc(ctx: ^Flag_Context, args: []string) -> Flag_Error { - - using runtime; - - args := args; - - for { - if len(args) == 0 { - return .None; - } - - arg := args[0]; - - if len(arg) < 2 || arg[0] != '-' { - return .Arg_Error; - } - - minus_count := 1; - - if arg[1] == '-' { - minus_count += 1; - - if len(arg) == 2 { - return .Arg_Error; - } - } - - name := arg[minus_count:]; - - if len(name) == 0 { - return .Arg_Error; - } - - args = args[1:]; - - assign_index := strings.index(name, "="); - - value := ""; - - if assign_index > 0 { - value = name[assign_index + 1:]; - name = name[0:assign_index]; - } - - flag := &ctx.seen_flags[name]; - - if flag == nil { - return .Arg_Not_Defined; - } - - if reflect.is_boolean(flag.type) { - tmp: b64 = true; - mem.copy(flag.data, &tmp, flag.type.size); - flag.parsed = true; - continue; - } else if value == "" { // must be in the next argument - if len(args) == 0 { - return .Arg_Error; - } - - value = args[0]; - args = args[1:]; - } - - #partial switch _ in flag.type.variant { - case Type_Info_Integer: - if v, ok := strconv.parse_int(value); ok { - mem.copy(flag.data, &v, flag.type.size); - } else { - return .Value_Parse_Error; - } - case Type_Info_String: - raw_string := cast(^mem.Raw_String)flag.data; - raw_string.data = strings.ptr_from_string(value); - raw_string.len = len(value); - case Type_Info_Float: - switch flag.type.size { - case 32: - if v, ok := strconv.parse_f32(value); ok { - mem.copy(flag.data, &v, flag.type.size); - } else { - return .Value_Parse_Error; - } - case 64: - if v, ok := strconv.parse_f64(value); ok { - mem.copy(flag.data, &v, flag.type.size); - } else { - return .Value_Parse_Error; - } - } - } - - flag.parsed = true; - } - - return .None; -} - -reflect_args_structure :: proc(ctx: ^Flag_Context, v: any) -> Flag_Error { - using runtime; - - if !reflect.is_struct(type_info_of(v.id)) { - return .No_Base_Struct; - } - - names := reflect.struct_field_names(v.id); - types := reflect.struct_field_types(v.id); - offsets := reflect.struct_field_offsets(v.id); - tags := reflect.struct_field_tags(v.id); - - for name, i in names { - flag: Flag; - - type := types[i]; - - if named_type, ok := type.variant.(Type_Info_Named); ok { - if union_type, ok := named_type.base.variant.(Type_Info_Union); ok && len(union_type.variants) == 1 { - flag.optional = true; - flag.tag_ptr = rawptr(uintptr(union_type.tag_offset) + uintptr(v.data) + uintptr(offsets[i])); - type = union_type.variants[0]; - } else { - return .Arg_Unsupported_Field_Type; - } - } - - #partial switch _ in type.variant { - case Type_Info_Integer, Type_Info_String, Type_Info_Boolean, Type_Info_Float: - flag.type = type; - flag.data = rawptr(uintptr(v.data) + uintptr(offsets[i])); - case: - return .Arg_Unsupported_Field_Type; - } - - flag_name: string; - - if value, ok := reflect.struct_tag_lookup(tags[i], "flag"); ok { - flag_name = cast(string)value; - } else { - return .Tag_Error; - } - - ctx.seen_flags[flag_name] = flag; - } - - return .None; -} - -parse :: proc(v: any, args: []string) -> Flag_Error { - - if v == nil { - return .None; - } - - ctx: Flag_Context; - - if res := reflect_args_structure(&ctx, v); res != .None { - return res; - } - - if res := parse_args(&ctx, args); res != .None { - return res; - } - - //validate that the required flags were actually set - for k, v in ctx.seen_flags { - if v.optional && v.parsed { - tag_value: i32 = 1; - mem.copy(v.tag_ptr, &tag_value, 4); //4 constant is probably not portable, but it works for me currently - } else if !v.parsed && !v.optional { - return .Arg_Non_Optional; - } - } - - return .None; -} - -usage :: proc(v: any) -> string { - return "failed"; -} diff --git a/tools/odinfmt/main.odin b/tools/odinfmt/main.odin deleted file mode 100644 index 9b9cbac0b..000000000 --- a/tools/odinfmt/main.odin +++ /dev/null @@ -1,145 +0,0 @@ -package odinfmt - -import "core:os" -import "core:odin/tokenizer" -import "core:odin/format" -import "core:fmt" -import "core:strings" -import "core:path/filepath" -import "core:time" -import "core:mem" - -import "flag" - -Args :: struct { - write: Maybe(bool) `flag:"w" usage:"write the new format to file"`, -} - -print_help :: proc(args: []string) { - if len(args) == 0 { - fmt.eprint("odinfmt "); - } else { - fmt.eprintf("%s ", args[0]); - } - fmt.eprintln(); -} - -print_arg_error :: proc(args: []string, error: flag.Flag_Error) { - switch error { - case .None: - print_help(args); - case .No_Base_Struct: - fmt.eprintln(args[0], "no base struct"); - case .Arg_Error: - fmt.eprintln(args[0], "argument error"); - case .Arg_Unsupported_Field_Type: - fmt.eprintln(args[0], "argument: unsupported field type"); - case .Arg_Not_Defined: - fmt.eprintln(args[0], "argument: no defined"); - case .Arg_Non_Optional: - fmt.eprintln(args[0], "argument: non optional"); - case .Value_Parse_Error: - fmt.eprintln(args[0], "argument: value parse error"); - case .Tag_Error: - fmt.eprintln(args[0], "argument: tag error"); - } -} - -format_file :: proc(filepath: string) -> (string, bool) { - if data, ok := os.read_entire_file(filepath); ok { - return format.format(filepath, string(data), format.default_style); - } else { - return "", false; - } -} - -files: [dynamic]string; - -walk_files :: proc(info: os.File_Info, in_err: os.Errno, user_data: rawptr) -> (err: os.Errno, skip_dir: bool) { - if info.is_dir { - return 0, false; - } - - if filepath.ext(info.name) != ".odin" { - return 0, false; - } - - append(&files, strings.clone(info.fullpath)); - - return 0, false; -} - -main :: proc() { - init_global_temporary_allocator(mem.Megabyte * 100) - - args: Args; - - if len(os.args) < 2 { - print_help(os.args); - os.exit(1); - } - - if res := flag.parse(args, os.args[1:len(os.args) - 1]); res != .None { - print_arg_error(os.args, res); - os.exit(1); - } - - path := os.args[len(os.args) - 1]; - - tick_time := time.tick_now(); - - write_failure := false; - - if os.is_file(path) { - if _, ok := args.write.(bool); ok { - backup_path := strings.concatenate({path, "_bk"}); - defer delete(backup_path); - - if data, ok := format_file(path); ok { - os.rename(path, backup_path); - - if os.write_entire_file(path, transmute([]byte)data) { - os.remove(backup_path); - } - } else { - fmt.eprintf("failed to write %v", path); - write_failure = true; - } - } else { - if data, ok := format_file(path); ok { - fmt.println(data); - } - } - } else if os.is_dir(path) { - filepath.walk(path, walk_files, nil); - - for file in files { - - backup_path := strings.concatenate({file, "_bk"}); - defer delete(backup_path); - - if data, ok := format_file(file); ok { - - if _, ok := args.write.(bool); ok { - os.rename(file, backup_path); - - if os.write_entire_file(file, transmute([]byte)data) { - os.remove(backup_path); - } - } else { - fmt.println(data); - } - } else { - fmt.eprintf("failed to format %v", file); - write_failure = true; - } - } - - fmt.printf("formatted %v files in %vms", len(files), time.duration_milliseconds(time.tick_lap_time(&tick_time))); - } else { - fmt.eprintf("%v is neither a directory nor a file \n", path); - os.exit(1); - } - - os.exit(1 if write_failure else 0); -} diff --git a/vendor/ENet/enet.odin b/vendor/ENet/enet.odin index 37e65b497..0e4493a17 100644 --- a/vendor/ENet/enet.odin +++ b/vendor/ENet/enet.odin @@ -343,58 +343,58 @@ foreign ENet { deinitialize :: proc() --- linked_version :: proc() -> Version --- time_get :: proc() -> u32 --- - time_set :: proc(u32) --- + time_set :: proc(newTimeBase: u32) --- socket_create :: proc(SocketType) -> Socket --- - socket_bind :: proc(Socket, ^Address) -> i32 --- - socket_get_address :: proc(Socket, ^Address) -> i32 --- - socket_listen :: proc(Socket, i32) -> i32 --- - socket_accept :: proc(Socket, ^Address) -> Socket --- - socket_connect :: proc(Socket, ^Address) -> i32 --- - socket_send :: proc(Socket, ^Address, ^Buffer, uint) -> i32 --- - socket_receive :: proc(Socket, ^Address, ^Buffer, uint) -> i32 --- - socket_wait :: proc(Socket, ^u32, u32) -> i32 --- - socket_set_option :: proc(Socket, SocketOption, i32) -> i32 --- - socket_get_option :: proc(Socket, SocketOption, ^i32) -> i32 --- - socket_shutdown :: proc(Socket, SocketShutdown) -> i32 --- - socket_destroy :: proc(Socket) --- - socketset_select :: proc(Socket, ^SocketSet, ^SocketSet, u32) -> i32 --- + socket_bind :: proc(socket: Socket, address: ^Address) -> i32 --- + socket_get_address :: proc(socket: Socket, address: ^Address) -> i32 --- + socket_listen :: proc(socket: Socket, backlog: i32) -> i32 --- + socket_accept :: proc(socket: Socket, address: ^Address) -> Socket --- + socket_connect :: proc(socket: Socket, address: ^Address) -> i32 --- + socket_send :: proc(socket: Socket, address: ^Address, buffers: [^]Buffer, bufferCount: uint) -> i32 --- + socket_receive :: proc(socket: Socket, address: ^Address, buffers: [^]Buffer, bufferCount: uint) -> i32 --- + socket_wait :: proc(socket: Socket, condition: ^u32, timeout: u32) -> i32 --- + socket_set_option :: proc(socket: Socket, option: SocketOption, value: i32) -> i32 --- + socket_get_option :: proc(socket: Socket, option: SocketOption, value: ^i32) -> i32 --- + socket_shutdown :: proc(socket: Socket, how: SocketShutdown) -> i32 --- + socket_destroy :: proc(socket: Socket) --- + socketset_select :: proc(socket: Socket, readSet: ^SocketSet, writeSet: ^SocketSet, timeout: u32) -> i32 --- address_set_host_ip :: proc(address: ^Address, hostName: cstring) -> i32 --- address_set_host :: proc(address: ^Address, hostName: cstring) -> i32 --- address_get_host_ip :: proc(address: ^Address, hostName: [^]u8, nameLength: uint) -> i32 --- address_get_host :: proc(address: ^Address, hostName: [^]u8, nameLength: uint) -> i32 --- - packet_create :: proc(rawptr, uint, u32) -> ^Packet --- - packet_destroy :: proc(^Packet) --- - packet_resize :: proc(^Packet, uint) -> i32 --- - crc32 :: proc(^Buffer, uint) -> u32 --- + packet_create :: proc(data: rawptr, dataLength: uint, flags: PacketFlag) -> ^Packet --- + packet_destroy :: proc(packet: ^Packet) --- + packet_resize :: proc(packet: ^Packet, dataLength: uint) -> i32 --- + crc32 :: proc(buffers: [^]Buffer, bufferCount: uint) -> u32 --- - host_create :: proc(^Address, uint, uint, u32, u32) -> ^Host --- - host_destroy :: proc(^Host) --- - host_connect :: proc(^Host, ^Address, uint, u32) -> ^Peer --- - host_check_events :: proc(^Host, ^Event) -> i32 --- - host_service :: proc(^Host, ^Event, u32) -> i32 --- - host_flush :: proc(^Host) --- - host_broadcast :: proc(^Host, u8, ^Packet) --- - host_compress :: proc(^Host, ^Compressor) --- - host_compress_with_range_coder :: proc(^Host) -> i32 --- - host_channel_limit :: proc(^Host, uint) --- - host_bandwidth_limit :: proc(^Host, u32, u32) --- + host_create :: proc(address: ^Address, peerCount: uint, channelLimit: uint, incomingBandwidth: u32, outgoingBandwidth: u32) -> ^Host --- + host_destroy :: proc(host: ^Host) --- + host_connect :: proc(host: ^Host, address: ^Address, channelCount: uint, data: u32) -> ^Peer --- + host_check_events :: proc(host: ^Host, event: ^Event) -> i32 --- + host_service :: proc(host: ^Host, event: ^Event, timeout: u32) -> i32 --- + host_flush :: proc(host: ^Host) --- + host_broadcast :: proc(host: ^Host, channelID: u8, packet: ^Packet) --- + host_compress :: proc(host: ^Host, compressor: ^Compressor) --- + host_compress_with_range_coder :: proc(host: ^Host) -> i32 --- + host_channel_limit :: proc(host: ^Host, channelLimit: uint) --- + host_bandwidth_limit :: proc(host: ^Host, incomingBandwidth: u32, outgoingBandwidth: u32) --- - peer_send :: proc(^Peer, u8, ^Packet) -> i32 --- - peer_receive :: proc(^Peer, ^u8) -> ^Packet --- - peer_ping :: proc(^Peer) --- - peer_ping_interval :: proc(^Peer, u32) --- - peer_timeout :: proc(^Peer, u32, u32, u32) --- - peer_reset :: proc(^Peer) --- - peer_disconnect :: proc(^Peer, u32) --- - peer_disconnect_now :: proc(^Peer, u32) --- - peer_disconnect_later :: proc(^Peer, u32) --- - peer_throttle_configure :: proc(^Peer, u32, u32, u32) --- + peer_send :: proc(peer: ^Peer, channelID: u8, packet: ^Packet) -> i32 --- + peer_receive :: proc(peer: ^Peer, channelID: ^u8) -> ^Packet --- + peer_ping :: proc(peer: ^Peer) --- + peer_ping_interval :: proc(peer: ^Peer, pingInterval: u32) --- + peer_timeout :: proc(peer: ^Peer, timoutLimit: u32, timeoutMinimum: u32, timeoutMaximum: u32) --- + peer_reset :: proc(peer: ^Peer) --- + peer_disconnect :: proc(peer: ^Peer, data: u32) --- + peer_disconnect_now :: proc(peer: ^Peer, data: u32) --- + peer_disconnect_later :: proc(peer: ^Peer, data: u32) --- + peer_throttle_configure :: proc(peer: ^Peer, interval: u32, acceleration: u32, deceleration: u32) --- range_coder_create :: proc() -> rawptr --- - range_coder_destroy :: proc(rawptr) --- - range_coder_compress :: proc(rawptr, [^]Buffer, uint, uint, [^]u8, uint) -> uint --- - range_coder_decompress :: proc(rawptr, [^]u8, uint, [^]u8, uint) -> uint --- + range_coder_destroy :: proc(ctx: rawptr) --- + range_coder_compress :: proc(ctx: rawptr, inBuffers: [^]Buffer, inBufferCount: uint, inLimit: uint, outData: [^]u8, outLimit: uint) -> uint --- + range_coder_decompress :: proc(ctx: rawptr, inData: [^]u8, inLimit: uint, outData: [^]u8, outLimit: uint) -> uint --- } \ No newline at end of file diff --git a/vendor/README.md b/vendor/README.md index bf64933c3..4e44d0970 100644 --- a/vendor/README.md +++ b/vendor/README.md @@ -143,7 +143,7 @@ Includes full bindings as well as wrappers to match the `core:crypto` API. See also LICENSE in the `commonmark` directory itself. Includes full bindings and Windows `.lib` and `.dll`. -## CommonMark +## zlib [zlib](https://github.com/madler/zlib) data compression library diff --git a/vendor/botan/bindings/botan-3.lib b/vendor/botan/bindings/botan-3.lib new file mode 100644 index 000000000..a3b94e3f6 Binary files /dev/null and b/vendor/botan/bindings/botan-3.lib differ diff --git a/vendor/botan/bindings/botan.lib b/vendor/botan/bindings/botan.lib deleted file mode 100644 index 5731855cb..000000000 Binary files a/vendor/botan/bindings/botan.lib and /dev/null differ diff --git a/vendor/botan/bindings/botan.odin b/vendor/botan/bindings/botan.odin index 2217eda5a..7c8b0997a 100644 --- a/vendor/botan/bindings/botan.odin +++ b/vendor/botan/bindings/botan.odin @@ -62,7 +62,7 @@ CRL_SIGN :: x509_cert_key_constraints(512) ENCIPHER_ONLY :: x509_cert_key_constraints(256) DECIPHER_ONLY :: x509_cert_key_constraints(128) -HASH_SHA1 :: "SHA1" +HASH_SHA1 :: "SHA-1" HASH_SHA_224 :: "SHA-224" HASH_SHA_256 :: "SHA-256" HASH_SHA_384 :: "SHA-384" @@ -141,10 +141,12 @@ fpe_struct :: struct{} fpe_t :: ^fpe_struct when ODIN_OS == .Windows { - foreign import botan_lib "botan.lib" + foreign import botan_lib "botan-3.lib" +} else when ODIN_OS == .Darwin { + foreign import botan_lib "system:botan-3" } else { foreign import botan_lib "system:botan-2" -} +} @(default_calling_convention="c") @(link_prefix="botan_") diff --git a/vendor/botan/blake2b/blake2b.odin b/vendor/botan/blake2b/blake2b.odin index 18fd89bd8..6cc828caf 100644 --- a/vendor/botan/blake2b/blake2b.odin +++ b/vendor/botan/blake2b/blake2b.odin @@ -69,7 +69,7 @@ hash_stream :: proc(s: io.Stream) -> ([DIGEST_SIZE]byte, bool) { defer delete(buf) i := 1 for i > 0 { - i, _ = s->impl_read(buf) + i, _ = io.read(s, buf) if i > 0 { botan.hash_update(ctx, len(buf) == 0 ? nil : &buf[0], uint(i)) } diff --git a/vendor/botan/gost/gost.odin b/vendor/botan/gost/gost.odin index bccc4d463..5b3db31fe 100644 --- a/vendor/botan/gost/gost.odin +++ b/vendor/botan/gost/gost.odin @@ -69,7 +69,7 @@ hash_stream :: proc(s: io.Stream) -> ([DIGEST_SIZE]byte, bool) { defer delete(buf) i := 1 for i > 0 { - i, _ = s->impl_read(buf) + i, _ = io.read(s, buf) if i > 0 { botan.hash_update(ctx, len(buf) == 0 ? nil : &buf[0], uint(i)) } diff --git a/vendor/botan/keccak/keccak.odin b/vendor/botan/keccak/keccak.odin index 4c82edc92..c08eaf598 100644 --- a/vendor/botan/keccak/keccak.odin +++ b/vendor/botan/keccak/keccak.odin @@ -69,7 +69,7 @@ hash_stream_512 :: proc(s: io.Stream) -> ([DIGEST_SIZE_512]byte, bool) { defer delete(buf) i := 1 for i > 0 { - i, _ = s->impl_read(buf) + i, _ = io.read(s, buf) if i > 0 { botan.hash_update(ctx, len(buf) == 0 ? nil : &buf[0], uint(i)) } diff --git a/vendor/botan/md4/md4.odin b/vendor/botan/md4/md4.odin index ddb7d5940..02c33dde9 100644 --- a/vendor/botan/md4/md4.odin +++ b/vendor/botan/md4/md4.odin @@ -69,7 +69,7 @@ hash_stream :: proc(s: io.Stream) -> ([DIGEST_SIZE]byte, bool) { defer delete(buf) i := 1 for i > 0 { - i, _ = s->impl_read(buf) + i, _ = io.read(s, buf) if i > 0 { botan.hash_update(ctx, len(buf) == 0 ? nil : &buf[0], uint(i)) } diff --git a/vendor/botan/md5/md5.odin b/vendor/botan/md5/md5.odin index 9ea489669..9aaf96d27 100644 --- a/vendor/botan/md5/md5.odin +++ b/vendor/botan/md5/md5.odin @@ -69,7 +69,7 @@ hash_stream :: proc(s: io.Stream) -> ([DIGEST_SIZE]byte, bool) { defer delete(buf) i := 1 for i > 0 { - i, _ = s->impl_read(buf) + i, _ = io.read(s, buf) if i > 0 { botan.hash_update(ctx, len(buf) == 0 ? nil : &buf[0], uint(i)) } diff --git a/vendor/botan/ripemd/ripemd.odin b/vendor/botan/ripemd/ripemd.odin index 33f0ba692..ddb549350 100644 --- a/vendor/botan/ripemd/ripemd.odin +++ b/vendor/botan/ripemd/ripemd.odin @@ -69,7 +69,7 @@ hash_stream_160 :: proc(s: io.Stream) -> ([DIGEST_SIZE_160]byte, bool) { defer delete(buf) i := 1 for i > 0 { - i, _ = s->impl_read(buf) + i, _ = io.read(s, buf) if i > 0 { botan.hash_update(ctx, len(buf) == 0 ? nil : &buf[0], uint(i)) } diff --git a/vendor/botan/sha1/sha1.odin b/vendor/botan/sha1/sha1.odin index 96520f09e..c39a41d0a 100644 --- a/vendor/botan/sha1/sha1.odin +++ b/vendor/botan/sha1/sha1.odin @@ -69,7 +69,7 @@ hash_stream :: proc(s: io.Stream) -> ([DIGEST_SIZE]byte, bool) { defer delete(buf) i := 1 for i > 0 { - i, _ = s->impl_read(buf) + i, _ = io.read(s, buf) if i > 0 { botan.hash_update(ctx, len(buf) == 0 ? nil : &buf[0], uint(i)) } diff --git a/vendor/botan/sha2/sha2.odin b/vendor/botan/sha2/sha2.odin index d583298ee..4ce001a75 100644 --- a/vendor/botan/sha2/sha2.odin +++ b/vendor/botan/sha2/sha2.odin @@ -72,7 +72,7 @@ hash_stream_224 :: proc(s: io.Stream) -> ([DIGEST_SIZE_224]byte, bool) { defer delete(buf) i := 1 for i > 0 { - i, _ = s->impl_read(buf) + i, _ = io.read(s, buf) if i > 0 { botan.hash_update(ctx, len(buf) == 0 ? nil : &buf[0], uint(i)) } @@ -151,7 +151,7 @@ hash_stream_256 :: proc(s: io.Stream) -> ([DIGEST_SIZE_256]byte, bool) { defer delete(buf) i := 1 for i > 0 { - i, _ = s->impl_read(buf) + i, _ = io.read(s, buf) if i > 0 { botan.hash_update(ctx, len(buf) == 0 ? nil : &buf[0], uint(i)) } @@ -230,7 +230,7 @@ hash_stream_384 :: proc(s: io.Stream) -> ([DIGEST_SIZE_384]byte, bool) { defer delete(buf) i := 1 for i > 0 { - i, _ = s->impl_read(buf) + i, _ = io.read(s, buf) if i > 0 { botan.hash_update(ctx, len(buf) == 0 ? nil : &buf[0], uint(i)) } @@ -309,7 +309,7 @@ hash_stream_512 :: proc(s: io.Stream) -> ([DIGEST_SIZE_512]byte, bool) { defer delete(buf) i := 1 for i > 0 { - i, _ = s->impl_read(buf) + i, _ = io.read(s, buf) if i > 0 { botan.hash_update(ctx, len(buf) == 0 ? nil : &buf[0], uint(i)) } diff --git a/vendor/botan/sha3/sha3.odin b/vendor/botan/sha3/sha3.odin index 5f82be49c..5dcb008ce 100644 --- a/vendor/botan/sha3/sha3.odin +++ b/vendor/botan/sha3/sha3.odin @@ -72,7 +72,7 @@ hash_stream_224 :: proc(s: io.Stream) -> ([DIGEST_SIZE_224]byte, bool) { defer delete(buf) i := 1 for i > 0 { - i, _ = s->impl_read(buf) + i, _ = io.read(s, buf) if i > 0 { botan.hash_update(ctx, len(buf) == 0 ? nil : &buf[0], uint(i)) } @@ -151,7 +151,7 @@ hash_stream_256 :: proc(s: io.Stream) -> ([DIGEST_SIZE_256]byte, bool) { defer delete(buf) i := 1 for i > 0 { - i, _ = s->impl_read(buf) + i, _ = io.read(s, buf) if i > 0 { botan.hash_update(ctx, len(buf) == 0 ? nil : &buf[0], uint(i)) } @@ -230,7 +230,7 @@ hash_stream_384 :: proc(s: io.Stream) -> ([DIGEST_SIZE_384]byte, bool) { defer delete(buf) i := 1 for i > 0 { - i, _ = s->impl_read(buf) + i, _ = io.read(s, buf) if i > 0 { botan.hash_update(ctx, len(buf) == 0 ? nil : &buf[0], uint(i)) } @@ -309,7 +309,7 @@ hash_stream_512 :: proc(s: io.Stream) -> ([DIGEST_SIZE_512]byte, bool) { defer delete(buf) i := 1 for i > 0 { - i, _ = s->impl_read(buf) + i, _ = io.read(s, buf) if i > 0 { botan.hash_update(ctx, len(buf) == 0 ? nil : &buf[0], uint(i)) } diff --git a/vendor/botan/shake/shake.odin b/vendor/botan/shake/shake.odin index b973fee24..af577f316 100644 --- a/vendor/botan/shake/shake.odin +++ b/vendor/botan/shake/shake.odin @@ -70,7 +70,7 @@ hash_stream_128 :: proc(s: io.Stream) -> ([DIGEST_SIZE_128]byte, bool) { defer delete(buf) i := 1 for i > 0 { - i, _ = s->impl_read(buf) + i, _ = io.read(s, buf) if i > 0 { botan.hash_update(ctx, len(buf) == 0 ? nil : &buf[0], uint(i)) } @@ -149,7 +149,7 @@ hash_stream_256 :: proc(s: io.Stream) -> ([DIGEST_SIZE_256]byte, bool) { defer delete(buf) i := 1 for i > 0 { - i, _ = s->impl_read(buf) + i, _ = io.read(s, buf) if i > 0 { botan.hash_update(ctx, len(buf) == 0 ? nil : &buf[0], uint(i)) } diff --git a/vendor/botan/skein512/skein512.odin b/vendor/botan/skein512/skein512.odin index 41ffaefff..47529bc44 100644 --- a/vendor/botan/skein512/skein512.odin +++ b/vendor/botan/skein512/skein512.odin @@ -72,7 +72,7 @@ hash_stream_256 :: proc(s: io.Stream) -> ([DIGEST_SIZE_256]byte, bool) { defer delete(buf) i := 1 for i > 0 { - i, _ = s->impl_read(buf) + i, _ = io.read(s, buf) if i > 0 { botan.hash_update(ctx, len(buf) == 0 ? nil : &buf[0], uint(i)) } @@ -151,7 +151,7 @@ hash_stream_512 :: proc(s: io.Stream) -> ([DIGEST_SIZE_512]byte, bool) { defer delete(buf) i := 1 for i > 0 { - i, _ = s->impl_read(buf) + i, _ = io.read(s, buf) if i > 0 { botan.hash_update(ctx, len(buf) == 0 ? nil : &buf[0], uint(i)) } @@ -230,7 +230,7 @@ hash_stream_slice :: proc(s: io.Stream, bit_size: int, allocator := context.allo defer delete(buf) i := 1 for i > 0 { - i, _ = s->impl_read(buf) + i, _ = io.read(s, buf) if i > 0 { botan.hash_update(ctx, len(buf) == 0 ? nil : &buf[0], uint(i)) } diff --git a/vendor/botan/sm3/sm3.odin b/vendor/botan/sm3/sm3.odin index 52fe9a488..dd6da9e63 100644 --- a/vendor/botan/sm3/sm3.odin +++ b/vendor/botan/sm3/sm3.odin @@ -69,7 +69,7 @@ hash_stream :: proc(s: io.Stream) -> ([DIGEST_SIZE]byte, bool) { defer delete(buf) i := 1 for i > 0 { - i, _ = s->impl_read(buf) + i, _ = io.read(s, buf) if i > 0 { botan.hash_update(ctx, len(buf) == 0 ? nil : &buf[0], uint(i)) } diff --git a/vendor/botan/streebog/streebog.odin b/vendor/botan/streebog/streebog.odin index fdc07923f..07c39684a 100644 --- a/vendor/botan/streebog/streebog.odin +++ b/vendor/botan/streebog/streebog.odin @@ -70,7 +70,7 @@ hash_stream_256 :: proc(s: io.Stream) -> ([DIGEST_SIZE_256]byte, bool) { defer delete(buf) i := 1 for i > 0 { - i, _ = s->impl_read(buf) + i, _ = io.read(s, buf) if i > 0 { botan.hash_update(ctx, len(buf) == 0 ? nil : &buf[0], uint(i)) } @@ -149,7 +149,7 @@ hash_stream_512 :: proc(s: io.Stream) -> ([DIGEST_SIZE_512]byte, bool) { defer delete(buf) i := 1 for i > 0 { - i, _ = s->impl_read(buf) + i, _ = io.read(s, buf) if i > 0 { botan.hash_update(ctx, len(buf) == 0 ? nil : &buf[0], uint(i)) } diff --git a/vendor/botan/tiger/tiger.odin b/vendor/botan/tiger/tiger.odin index 3d7e064d0..960d4694b 100644 --- a/vendor/botan/tiger/tiger.odin +++ b/vendor/botan/tiger/tiger.odin @@ -71,7 +71,7 @@ hash_stream_128 :: proc(s: io.Stream) -> ([DIGEST_SIZE_128]byte, bool) { defer delete(buf) i := 1 for i > 0 { - i, _ = s->impl_read(buf) + i, _ = io.read(s, buf) if i > 0 { botan.hash_update(ctx, len(buf) == 0 ? nil : &buf[0], uint(i)) } @@ -150,7 +150,7 @@ hash_stream_160 :: proc(s: io.Stream) -> ([DIGEST_SIZE_160]byte, bool) { defer delete(buf) i := 1 for i > 0 { - i, _ = s->impl_read(buf) + i, _ = io.read(s, buf) if i > 0 { botan.hash_update(ctx, len(buf) == 0 ? nil : &buf[0], uint(i)) } @@ -229,7 +229,7 @@ hash_stream_192 :: proc(s: io.Stream) -> ([DIGEST_SIZE_192]byte, bool) { defer delete(buf) i := 1 for i > 0 { - i, _ = s->impl_read(buf) + i, _ = io.read(s, buf) if i > 0 { botan.hash_update(ctx, len(buf) == 0 ? nil : &buf[0], uint(i)) } diff --git a/vendor/botan/whirlpool/whirlpool.odin b/vendor/botan/whirlpool/whirlpool.odin index c32ff20c0..76d4d25d4 100644 --- a/vendor/botan/whirlpool/whirlpool.odin +++ b/vendor/botan/whirlpool/whirlpool.odin @@ -69,7 +69,7 @@ hash_stream :: proc(s: io.Stream) -> ([DIGEST_SIZE]byte, bool) { defer delete(buf) i := 1 for i > 0 { - i, _ = s->impl_read(buf) + i, _ = io.read(s, buf) if i > 0 { botan.hash_update(ctx, len(buf) == 0 ? nil : &buf[0], uint(i)) } diff --git a/vendor/cgltf/lib/cgltf.lib b/vendor/cgltf/lib/cgltf.lib new file mode 100644 index 000000000..0d7ea6f9b Binary files /dev/null and b/vendor/cgltf/lib/cgltf.lib differ diff --git a/vendor/darwin/Foundation/NSApplication.odin b/vendor/darwin/Foundation/NSApplication.odin index 0b62687b7..48682aef7 100644 --- a/vendor/darwin/Foundation/NSApplication.odin +++ b/vendor/darwin/Foundation/NSApplication.odin @@ -1,6 +1,8 @@ package objc_Foundation import "core:intrinsics" +import "core:runtime" +import "core:strings" ActivationPolicy :: enum UInteger { Regular = 0, @@ -8,74 +10,86 @@ ActivationPolicy :: enum UInteger { Prohibited = 2, } -ApplicationDelegate :: struct { - willFinishLaunching: proc "c" (self: ^ApplicationDelegate, notification: ^Notification), - didFinishLaunching: proc "c" (self: ^ApplicationDelegate, notification: ^Notification), - shouldTerminateAfterLastWindowClosed: proc "c" (self: ^ApplicationDelegate, sender: ^Application) -> BOOL, - - user_data: rawptr, +ApplicationTerminateReply :: enum UInteger { + TerminateCancel = 0, + TerminateNow = 1, + TerminateLater = 2, } +ApplicationPrintReply :: enum UInteger { + PrintingCancelled = 0, + PrintingSuccess = 1, + PrintingReplyLater = 2, + PrintingFailure = 3, +} + +ApplicationPresentationOptionFlag :: enum UInteger { + AutoHideDock = 0, + HideDock = 1, + AutoHideMenuBar = 2, + HideMenuBar = 3, + DisableAppleMenu = 4, + DisableProcessSwitching = 5, + DisableForceQuit = 6, + DisableSessionTermination = 7, + DisableHideApplication = 8, + DisableMenuBarTransparency = 9, + FullScreen = 10, + AutoHideToolbar = 11, + DisableCursorLocationAssistance = 12, +} +ApplicationPresentationOptions :: distinct bit_set[ApplicationPresentationOptionFlag; UInteger] +ApplicationPresentationOptionsDefault :: ApplicationPresentationOptions {} +ApplicationPresentationOptionsAutoHideDock :: ApplicationPresentationOptions {.AutoHideDock} +ApplicationPresentationOptionsHideDock :: ApplicationPresentationOptions {.HideDock} +ApplicationPresentationOptionsAutoHideMenuBar :: ApplicationPresentationOptions {.AutoHideMenuBar} +ApplicationPresentationOptionsHideMenuBar :: ApplicationPresentationOptions {.HideMenuBar} +ApplicationPresentationOptionsDisableAppleMenu :: ApplicationPresentationOptions {.DisableAppleMenu} +ApplicationPresentationOptionsDisableProcessSwitching :: ApplicationPresentationOptions {.DisableProcessSwitching} +ApplicationPresentationOptionsDisableForceQuit :: ApplicationPresentationOptions {.DisableForceQuit} +ApplicationPresentationOptionsDisableSessionTermination :: ApplicationPresentationOptions {.DisableSessionTermination} +ApplicationPresentationOptionsDisableHideApplication :: ApplicationPresentationOptions {.DisableHideApplication} +ApplicationPresentationOptionsDisableMenuBarTransparency :: ApplicationPresentationOptions {.DisableMenuBarTransparency} +ApplicationPresentationOptionsFullScreen :: ApplicationPresentationOptions {.FullScreen} +ApplicationPresentationOptionsAutoHideToolbar :: ApplicationPresentationOptions {.AutoHideToolbar} +ApplicationPresentationOptionsDisableCursorLocationAssistance :: ApplicationPresentationOptions {.DisableCursorLocationAssistance} + @(objc_class="NSApplication") Application :: struct {using _: Object} @(objc_type=Application, objc_name="sharedApplication", objc_is_class_method=true) -Application_sharedApplication :: proc() -> ^Application { +Application_sharedApplication :: proc "c" () -> ^Application { return msgSend(^Application, Application, "sharedApplication") } -@(objc_type=Application, objc_name="setDelegate") -Application_setDelegate :: proc(self: ^Application, delegate: ^ApplicationDelegate) { - willFinishLaunching :: proc "c" (self: ^Value, _: SEL, notification: ^Notification) { - del := (^ApplicationDelegate)(self->pointerValue()) - del->willFinishLaunching(notification) - } - didFinishLaunching :: proc "c" (self: ^Value, _: SEL, notification: ^Notification) { - del := (^ApplicationDelegate)(self->pointerValue()) - del->didFinishLaunching(notification) - } - shouldTerminateAfterLastWindowClosed :: proc "c" (self: ^Value, _: SEL, application: ^Application) -> BOOL { - del := (^ApplicationDelegate)(self->pointerValue()) - return del->shouldTerminateAfterLastWindowClosed(application) - } - - wrapper := Value.valueWithPointer(delegate) - - class_addMethod(intrinsics.objc_find_class("NSValue"), intrinsics.objc_find_selector("applicationWillFinishLaunching:"), auto_cast willFinishLaunching, "v@:@") - class_addMethod(intrinsics.objc_find_class("NSValue"), intrinsics.objc_find_selector("applicationDidFinishLaunching:"), auto_cast didFinishLaunching, "v@:@") - class_addMethod(intrinsics.objc_find_class("NSValue"), intrinsics.objc_find_selector("applicationShouldTerminateAfterLastWindowClosed:"), auto_cast shouldTerminateAfterLastWindowClosed, "B@:@") - - msgSend(nil, self, "setDelegate:", wrapper) -} - @(objc_type=Application, objc_name="setActivationPolicy") -Application_setActivationPolicy :: proc(self: ^Application, activationPolicy: ActivationPolicy) -> BOOL { +Application_setActivationPolicy :: proc "c" (self: ^Application, activationPolicy: ActivationPolicy) -> BOOL { return msgSend(BOOL, self, "setActivationPolicy:", activationPolicy) } @(objc_type=Application, objc_name="activateIgnoringOtherApps") -Application_activateIgnoringOtherApps :: proc(self: ^Application, ignoreOtherApps: BOOL) { +Application_activateIgnoringOtherApps :: proc "c" (self: ^Application, ignoreOtherApps: BOOL) { msgSend(nil, self, "activateIgnoringOtherApps:", ignoreOtherApps) } @(objc_type=Application, objc_name="setMainMenu") -Application_setMainMenu :: proc(self: ^Application, menu: ^Menu) { +Application_setMainMenu :: proc "c" (self: ^Application, menu: ^Menu) { msgSend(nil, self, "setMainMenu:", menu) } @(objc_type=Application, objc_name="windows") -Application_windows :: proc(self: ^Application) -> ^Array { +Application_windows :: proc "c" (self: ^Application) -> ^Array { return msgSend(^Array, self, "windows") } @(objc_type=Application, objc_name="run") -Application_run :: proc(self: ^Application) { +Application_run :: proc "c" (self: ^Application) { msgSend(nil, self, "run") } @(objc_type=Application, objc_name="terminate") -Application_terminate :: proc(self: ^Application, sender: ^Object) { +Application_terminate :: proc "c" (self: ^Application, sender: ^Object) { msgSend(nil, self, "terminate:", sender) } @@ -85,11 +99,466 @@ Application_terminate :: proc(self: ^Application, sender: ^Object) { RunningApplication :: struct {using _: Object} @(objc_type=RunningApplication, objc_name="currentApplication", objc_is_class_method=true) -RunningApplication_currentApplication :: proc() -> ^RunningApplication { +RunningApplication_currentApplication :: proc "c" () -> ^RunningApplication { return msgSend(^RunningApplication, RunningApplication, "currentApplication") } @(objc_type=RunningApplication, objc_name="localizedName") -RunningApplication_localizedName :: proc(self: ^RunningApplication) -> ^String { +RunningApplication_localizedName :: proc "c" (self: ^RunningApplication) -> ^String { return msgSend(^String, self, "localizedName") -} \ No newline at end of file +} + +ApplicationDelegateTemplate :: struct { + // Launching Applications + applicationWillFinishLaunching: proc(notification: ^Notification), + applicationDidFinishLaunching: proc(notification: ^Notification), + // Managing Active Status + applicationWillBecomeActive: proc(notification: ^Notification), + applicationDidBecomeActive: proc(notification: ^Notification), + applicationWillResignActive: proc(notification: ^Notification), + applicationDidResignActive: proc(notification: ^Notification), + // Terminating Applications + applicationShouldTerminate: proc(sender: ^Application) -> ApplicationTerminateReply, + applicationShouldTerminateAfterLastWindowClosed: proc(sender: ^Application) -> BOOL, + applicationWillTerminate: proc(notification: ^Notification), + // Hiding Applications + applicationWillHide: proc(notification: ^Notification), + applicationDidHide: proc(notification: ^Notification), + applicationWillUnhide: proc(notification: ^Notification), + applicationDidUnhide: proc(notification: ^Notification), + // Managing Windows + applicationWillUpdate: proc(notification: ^Notification), + applicationDidUpdate: proc(notification: ^Notification), + applicationShouldHandleReopenHasVisibleWindows: proc(sender: ^Application, flag: BOOL) -> BOOL, + // Managing the Dock Menu + applicationDockMenu: proc(sender: ^Application) -> ^Menu, + // Localizing Keyboard Shortcuts + applicationShouldAutomaticallyLocalizeKeyEquivalents: proc(application: ^Application) -> BOOL, + // Displaying Errors + applicationWillPresentError: proc(application: ^Application, error: ^Error) -> ^Error, + // Managing the Screen + applicationDidChangeScreenParameters: proc(notification: ^Notification), + // Continuing User Activities + applicationWillContinueUserActivityWithType: proc(application: ^Application, userActivityType: ^String) -> BOOL, + applicationContinueUserActivityRestorationHandler: proc(application: ^Application, userActivity: ^UserActivity, restorationHandler: ^Block) -> BOOL, + applicationDidFailToContinueUserActivityWithTypeError: proc(application: ^Application, userActivityType: ^String, error: ^Error), + applicationDidUpdateUserActivity: proc(application: ^Application, userActivity: ^UserActivity), + // Handling Push Notifications + applicationDidRegisterForRemoteNotificationsWithDeviceToken: proc(application: ^Application, deviceToken: ^Data), + applicationDidFailToRegisterForRemoteNotificationsWithError: proc(application: ^Application, error: ^Error), + applicationDidReceiveRemoteNotification: proc(application: ^Application, userInfo: ^Dictionary), + // Handling CloudKit Invitations + // TODO: if/when we have cloud kit bindings implement + // applicationUserDidAcceptCloudKitShareWithMetadata: proc(application: ^Application, metadata: ^CKShareMetadata), + // Handling SiriKit Intents + // TODO: if/when we have siri kit bindings implement + // applicationHandlerForIntent: proc(application: ^Application, intent: ^INIntent) -> id, + // Opening Files + applicationOpenURLs: proc(application: ^Application, urls: ^Array), + applicationOpenFile: proc(sender: ^Application, filename: ^String) -> BOOL, + applicationOpenFileWithoutUI: proc(sender: id, filename: ^String) -> BOOL, + applicationOpenTempFile: proc(sender: ^Application, filename: ^String) -> BOOL, + applicationOpenFiles: proc(sender: ^Application, filenames: ^Array), + applicationShouldOpenUntitledFile: proc(sender: ^Application) -> BOOL, + applicationOpenUntitledFile: proc(sender: ^Application) -> BOOL, + // Printing + applicationPrintFile: proc(sender: ^Application, filename: ^String) -> BOOL, + applicationPrintFilesWithSettingsShowPrintPanels: proc(application: ^Application, fileNames: ^Array, printSettings: ^Dictionary, showPrintPanels: BOOL) -> ApplicationPrintReply, + // Restoring Application State + applicationSupportsSecureRestorableState: proc(app: ^Application) -> BOOL, + applicationProtectedDataDidBecomeAvailable: proc(notification: ^Notification), + applicationProtectedDataWillBecomeUnavailable: proc(notification: ^Notification), + applicationWillEncodeRestorableState: proc(app: ^Application, coder: ^Coder), + applicationDidDecodeRestorableState: proc(app: ^Application, coder: ^Coder), + // Handling Changes to the Occlusion State + applicationDidChangeOcclusionState: proc(notification: ^Notification), + // Scripting Your App + applicationDelegateHandlesKey: proc(sender: ^Application, key: ^String) -> BOOL, +} + +ApplicationDelegate :: struct { using _: Object } +_ApplicationDelegateInternal :: struct { + using _: ApplicationDelegateTemplate, + _context: runtime.Context, +} + +application_delegate_register_and_alloc :: proc(template: ApplicationDelegateTemplate, class_name: string, delegate_context: Maybe(runtime.Context)) -> ^ApplicationDelegate { + class := objc_allocateClassPair(intrinsics.objc_find_class("NSObject"), strings.clone_to_cstring(class_name, context.temp_allocator), 0); if class == nil { + // Class already registered + return nil + } + if template.applicationWillFinishLaunching != nil { + applicationWillFinishLaunching :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.applicationWillFinishLaunching(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("applicationWillFinishLaunching:"), auto_cast applicationWillFinishLaunching, "v@:@") + } + if template.applicationDidFinishLaunching != nil { + applicationDidFinishLaunching :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.applicationDidFinishLaunching(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("applicationDidFinishLaunching:"), auto_cast applicationDidFinishLaunching, "v@:@") + } + if template.applicationWillBecomeActive != nil { + applicationWillBecomeActive :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.applicationWillBecomeActive(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("applicationWillBecomeActive:"), auto_cast applicationWillBecomeActive, "v@:@") + } + if template.applicationDidBecomeActive != nil { + applicationDidBecomeActive :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.applicationDidBecomeActive(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("applicationDidBecomeActive:"), auto_cast applicationDidBecomeActive, "v@:@") + } + if template.applicationWillResignActive != nil { + applicationWillResignActive :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.applicationWillResignActive(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("applicationWillResignActive:"), auto_cast applicationWillResignActive, "v@:@") + } + if template.applicationDidResignActive != nil { + applicationDidResignActive :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.applicationDidResignActive(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("applicationDidResignActive:"), auto_cast applicationDidResignActive, "v@:@") + } + if template.applicationShouldTerminate != nil { + applicationShouldTerminate :: proc "c" (self: id, sender: ^Application) -> ApplicationTerminateReply { + del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + context = del._context + return del.applicationShouldTerminate(sender) + } + class_addMethod(class, intrinsics.objc_find_selector("applicationShouldTerminate:"), auto_cast applicationShouldTerminate, _UINTEGER_ENCODING+"@:@") + } + if template.applicationShouldTerminateAfterLastWindowClosed != nil { + applicationShouldTerminateAfterLastWindowClosed :: proc "c" (self: id, sender: ^Application) -> BOOL { + del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + context = del._context + return del.applicationShouldTerminateAfterLastWindowClosed(sender) + } + class_addMethod(class, intrinsics.objc_find_selector("applicationShouldTerminateAfterLastWindowClosed:"), auto_cast applicationShouldTerminateAfterLastWindowClosed, "B@:@") + } + if template.applicationWillTerminate != nil { + applicationWillTerminate :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.applicationWillTerminate(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("applicationWillTerminate:"), auto_cast applicationWillTerminate, "v@:@") + } + if template.applicationWillHide != nil { + applicationWillHide :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.applicationWillHide(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("applicationWillHide:"), auto_cast applicationWillHide, "v@:@") + } + if template.applicationDidHide != nil { + applicationDidHide :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.applicationDidHide(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("applicationDidHide:"), auto_cast applicationDidHide, "v@:@") + } + if template.applicationWillUnhide != nil { + applicationWillUnhide :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.applicationWillUnhide(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("applicationWillUnhide:"), auto_cast applicationWillUnhide, "v@:@") + } + if template.applicationDidUnhide != nil { + applicationDidUnhide :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.applicationDidUnhide(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("applicationDidUnhide:"), auto_cast applicationDidUnhide, "v@:@") + } + if template.applicationWillUpdate != nil { + applicationWillUpdate :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.applicationWillUpdate(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("applicationWillUpdate:"), auto_cast applicationWillUpdate, "v@:@") + } + if template.applicationDidUpdate != nil { + applicationDidUpdate :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.applicationDidUpdate(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("applicationDidUpdate:"), auto_cast applicationDidUpdate, "v@:@") + } + if template.applicationShouldHandleReopenHasVisibleWindows != nil { + applicationShouldHandleReopenHasVisibleWindows :: proc "c" (self: id, sender: ^Application, flag: BOOL) -> BOOL { + del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + context = del._context + return del.applicationShouldHandleReopenHasVisibleWindows(sender, flag) + } + class_addMethod(class, intrinsics.objc_find_selector("applicationShouldHandleReopen:hasVisibleWindows:"), auto_cast applicationShouldHandleReopenHasVisibleWindows, "B@:@B") + } + if template.applicationDockMenu != nil { + applicationDockMenu :: proc "c" (self: id, sender: ^Application) -> ^Menu { + del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + context = del._context + return del.applicationDockMenu(sender) + } + class_addMethod(class, intrinsics.objc_find_selector("applicationDockMenu:"), auto_cast applicationDockMenu, "@@:@") + } + if template.applicationShouldAutomaticallyLocalizeKeyEquivalents != nil { + applicationShouldAutomaticallyLocalizeKeyEquivalents :: proc "c" (self: id, application: ^Application) -> BOOL { + del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + context = del._context + return del.applicationShouldAutomaticallyLocalizeKeyEquivalents(application) + } + class_addMethod(class, intrinsics.objc_find_selector("applicationShouldAutomaticallyLocalizeKeyEquivalents:"), auto_cast applicationShouldAutomaticallyLocalizeKeyEquivalents, "B@:@") + } + if template.applicationWillPresentError != nil { + applicationWillPresentError :: proc "c" (self: id, application: ^Application, error: ^Error) -> ^Error { + del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + context = del._context + return del.applicationWillPresentError(application, error) + } + class_addMethod(class, intrinsics.objc_find_selector("application:willPresentError:"), auto_cast applicationWillPresentError, "@@:@@") + } + if template.applicationDidChangeScreenParameters != nil { + applicationDidChangeScreenParameters :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.applicationDidChangeScreenParameters(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("applicationDidChangeScreenParameters:"), auto_cast applicationDidChangeScreenParameters, "v@:@") + } + if template.applicationWillContinueUserActivityWithType != nil { + applicationWillContinueUserActivityWithType :: proc "c" (self: id, application: ^Application, userActivityType: ^String) -> BOOL { + del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + context = del._context + return del.applicationWillContinueUserActivityWithType(application, userActivityType) + } + class_addMethod(class, intrinsics.objc_find_selector("application:willContinueUserActivityWithType:"), auto_cast applicationWillContinueUserActivityWithType, "B@:@@") + } + if template.applicationContinueUserActivityRestorationHandler != nil { + applicationContinueUserActivityRestorationHandler :: proc "c" (self: id, application: ^Application, userActivity: ^UserActivity, restorationHandler: ^Block) -> BOOL { + del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + context = del._context + return del.applicationContinueUserActivityRestorationHandler(application, userActivity, restorationHandler) + } + class_addMethod(class, intrinsics.objc_find_selector("application:continueUserActivity:restorationHandler:"), auto_cast applicationContinueUserActivityRestorationHandler, "B@:@@?") + } + if template.applicationDidFailToContinueUserActivityWithTypeError != nil { + applicationDidFailToContinueUserActivityWithTypeError :: proc "c" (self: id, application: ^Application, userActivityType: ^String, error: ^Error) { + del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.applicationDidFailToContinueUserActivityWithTypeError(application, userActivityType, error) + } + class_addMethod(class, intrinsics.objc_find_selector("application:didFailToContinueUserActivityWithType:error:"), auto_cast applicationDidFailToContinueUserActivityWithTypeError, "v@:@@@") + } + if template.applicationDidUpdateUserActivity != nil { + applicationDidUpdateUserActivity :: proc "c" (self: id, application: ^Application, userActivity: ^UserActivity) { + del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.applicationDidUpdateUserActivity(application, userActivity) + } + class_addMethod(class, intrinsics.objc_find_selector("application:didUpdateUserActivity:"), auto_cast applicationDidUpdateUserActivity, "v@:@@") + } + if template.applicationDidRegisterForRemoteNotificationsWithDeviceToken != nil { + applicationDidRegisterForRemoteNotificationsWithDeviceToken :: proc "c" (self: id, application: ^Application, deviceToken: ^Data) { + del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.applicationDidRegisterForRemoteNotificationsWithDeviceToken(application, deviceToken) + } + class_addMethod(class, intrinsics.objc_find_selector("application:didRegisterForRemoteNotificationsWithDeviceToken:"), auto_cast applicationDidRegisterForRemoteNotificationsWithDeviceToken, "v@:@@") + } + if template.applicationDidFailToRegisterForRemoteNotificationsWithError != nil { + applicationDidFailToRegisterForRemoteNotificationsWithError :: proc "c" (self: id, application: ^Application, error: ^Error) { + del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.applicationDidFailToRegisterForRemoteNotificationsWithError(application, error) + } + class_addMethod(class, intrinsics.objc_find_selector("application:didFailToRegisterForRemoteNotificationsWithError:"), auto_cast applicationDidFailToRegisterForRemoteNotificationsWithError, "v@:@@") + } + if template.applicationDidReceiveRemoteNotification != nil { + applicationDidReceiveRemoteNotification :: proc "c" (self: id, application: ^Application, userInfo: ^Dictionary) { + del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.applicationDidReceiveRemoteNotification(application, userInfo) + } + class_addMethod(class, intrinsics.objc_find_selector("application:didReceiveRemoteNotification:"), auto_cast applicationDidReceiveRemoteNotification, "v@:@@") + } + // if template.applicationUserDidAcceptCloudKitShareWithMetadata != nil { + // applicationUserDidAcceptCloudKitShareWithMetadata :: proc "c" (self: id, application: ^Application, metadata: ^CKShareMetadata) { + // del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + // context = del._context + // del.applicationUserDidAcceptCloudKitShareWithMetadata(application, metadata) + // } + // class_addMethod(class, intrinsics.objc_find_selector("application:userDidAcceptCloudKitShareWithMetadata:"), auto_cast applicationUserDidAcceptCloudKitShareWithMetadata, "v@:@@") + // } + // if template.applicationHandlerForIntent != nil { + // applicationHandlerForIntent :: proc "c" (self: id, application: ^Application, intent: ^INIntent) -> id { + // del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + // context = del._context + // return del.applicationHandlerForIntent(application, intent) + // } + // class_addMethod(class, intrinsics.objc_find_selector("application:handlerForIntent:"), auto_cast applicationHandlerForIntent, "@@:@@") + // } + if template.applicationOpenURLs != nil { + applicationOpenURLs :: proc "c" (self: id, application: ^Application, urls: ^Array) { + del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.applicationOpenURLs(application, urls) + } + class_addMethod(class, intrinsics.objc_find_selector("application:openURLs:"), auto_cast applicationOpenURLs, "v@:@@") + } + if template.applicationOpenFile != nil { + applicationOpenFile :: proc "c" (self: id, sender: ^Application, filename: ^String) -> BOOL { + del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + context = del._context + return del.applicationOpenFile(sender, filename) + } + class_addMethod(class, intrinsics.objc_find_selector("application:openFile:"), auto_cast applicationOpenFile, "B@:@@") + } + if template.applicationOpenFileWithoutUI != nil { + applicationOpenFileWithoutUI :: proc "c" (self: id, sender: id, filename: ^String) -> BOOL { + del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + context = del._context + return del.applicationOpenFileWithoutUI(sender, filename) + } + class_addMethod(class, intrinsics.objc_find_selector("application:openFileWithoutUI:"), auto_cast applicationOpenFileWithoutUI, "B@:@@") + } + if template.applicationOpenTempFile != nil { + applicationOpenTempFile :: proc "c" (self: id, sender: ^Application, filename: ^String) -> BOOL { + del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + context = del._context + return del.applicationOpenTempFile(sender, filename) + } + class_addMethod(class, intrinsics.objc_find_selector("application:openTempFile:"), auto_cast applicationOpenTempFile, "B@:@@") + } + if template.applicationOpenFiles != nil { + applicationOpenFiles :: proc "c" (self: id, sender: ^Application, filenames: ^Array) { + del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.applicationOpenFiles(sender, filenames) + } + class_addMethod(class, intrinsics.objc_find_selector("application:openFiles:"), auto_cast applicationOpenFiles, "v@:@@") + } + if template.applicationShouldOpenUntitledFile != nil { + applicationShouldOpenUntitledFile :: proc "c" (self: id, sender: ^Application) -> BOOL { + del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + context = del._context + return del.applicationShouldOpenUntitledFile(sender) + } + class_addMethod(class, intrinsics.objc_find_selector("applicationShouldOpenUntitledFile:"), auto_cast applicationShouldOpenUntitledFile, "B@:@") + } + if template.applicationOpenUntitledFile != nil { + applicationOpenUntitledFile :: proc "c" (self: id, sender: ^Application) -> BOOL { + del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + context = del._context + return del.applicationOpenUntitledFile(sender) + } + class_addMethod(class, intrinsics.objc_find_selector("applicationOpenUntitledFile:"), auto_cast applicationOpenUntitledFile, "B@:@") + } + if template.applicationPrintFile != nil { + applicationPrintFile :: proc "c" (self: id, sender: ^Application, filename: ^String) -> BOOL { + del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + context = del._context + return del.applicationPrintFile(sender, filename) + } + class_addMethod(class, intrinsics.objc_find_selector("application:printFile:"), auto_cast applicationPrintFile, "B@:@@") + } + if template.applicationPrintFilesWithSettingsShowPrintPanels != nil { + applicationPrintFilesWithSettingsShowPrintPanels :: proc "c" (self: id, application: ^Application, fileNames: ^Array, printSettings: ^Dictionary, showPrintPanels: BOOL) -> ApplicationPrintReply { + del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + context = del._context + return del.applicationPrintFilesWithSettingsShowPrintPanels(application, fileNames, printSettings, showPrintPanels) + } + class_addMethod(class, intrinsics.objc_find_selector("application:printFiles:withSettings:showPrintPanels:"), auto_cast applicationPrintFilesWithSettingsShowPrintPanels, _UINTEGER_ENCODING+"@:@@@B") + } + if template.applicationSupportsSecureRestorableState != nil { + applicationSupportsSecureRestorableState :: proc "c" (self: id, app: ^Application) -> BOOL { + del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + context = del._context + return del.applicationSupportsSecureRestorableState(app) + } + class_addMethod(class, intrinsics.objc_find_selector("applicationSupportsSecureRestorableState:"), auto_cast applicationSupportsSecureRestorableState, "B@:@") + } + if template.applicationProtectedDataDidBecomeAvailable != nil { + applicationProtectedDataDidBecomeAvailable :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.applicationProtectedDataDidBecomeAvailable(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("applicationProtectedDataDidBecomeAvailable:"), auto_cast applicationProtectedDataDidBecomeAvailable, "v@:@") + } + if template.applicationProtectedDataWillBecomeUnavailable != nil { + applicationProtectedDataWillBecomeUnavailable :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.applicationProtectedDataWillBecomeUnavailable(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("applicationProtectedDataWillBecomeUnavailable:"), auto_cast applicationProtectedDataWillBecomeUnavailable, "v@:@") + } + if template.applicationWillEncodeRestorableState != nil { + applicationWillEncodeRestorableState :: proc "c" (self: id, app: ^Application, coder: ^Coder) { + del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.applicationWillEncodeRestorableState(app, coder) + } + class_addMethod(class, intrinsics.objc_find_selector("application:willEncodeRestorableState:"), auto_cast applicationWillEncodeRestorableState, "v@:@@") + } + if template.applicationDidDecodeRestorableState != nil { + applicationDidDecodeRestorableState :: proc "c" (self: id, app: ^Application, coder: ^Coder) { + del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.applicationDidDecodeRestorableState(app, coder) + } + class_addMethod(class, intrinsics.objc_find_selector("application:didDecodeRestorableState:"), auto_cast applicationDidDecodeRestorableState, "v@:@@") + } + if template.applicationDidChangeOcclusionState != nil { + applicationDidChangeOcclusionState :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.applicationDidChangeOcclusionState(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("applicationDidChangeOcclusionState:"), auto_cast applicationDidChangeOcclusionState, "v@:@") + } + if template.applicationDelegateHandlesKey != nil { + applicationDelegateHandlesKey :: proc "c" (self: id, sender: ^Application, key: ^String) -> BOOL { + del := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(self) + context = del._context + return del.applicationDelegateHandlesKey(sender, key) + } + class_addMethod(class, intrinsics.objc_find_selector("application:delegateHandlesKey:"), auto_cast applicationDelegateHandlesKey, "B@:@@") + } + + objc_registerClassPair(class) + del := class_createInstance(class, size_of(_ApplicationDelegateInternal)) + del_internal := cast(^_ApplicationDelegateInternal)object_getIndexedIvars(del) + del_internal^ = { + template, + delegate_context.(runtime.Context) or_else runtime.default_context(), + } + return cast(^ApplicationDelegate)del +} + +@(objc_type=Application, objc_name="setDelegate") +Application_setDelegate :: proc "c" (self: ^Application, delegate: ^ApplicationDelegate) { + msgSend(nil, self, "setDelegate:", delegate) +} diff --git a/vendor/darwin/Foundation/NSArray.odin b/vendor/darwin/Foundation/NSArray.odin index d6021838b..3e6520c0d 100644 --- a/vendor/darwin/Foundation/NSArray.odin +++ b/vendor/darwin/Foundation/NSArray.odin @@ -8,35 +8,35 @@ Array :: struct { } @(objc_type=Array, objc_name="alloc", objc_is_class_method=true) -Array_alloc :: proc() -> ^Array { +Array_alloc :: proc "c" () -> ^Array { return msgSend(^Array, Array, "alloc") } @(objc_type=Array, objc_name="init") -Array_init :: proc(self: ^Array) -> ^Array { +Array_init :: proc "c" (self: ^Array) -> ^Array { return msgSend(^Array, self, "init") } @(objc_type=Array, objc_name="initWithObjects") -Array_initWithObjects :: proc(self: ^Array, objects: [^]^Object, count: UInteger) -> ^Array { +Array_initWithObjects :: proc "c" (self: ^Array, objects: [^]^Object, count: UInteger) -> ^Array { return msgSend(^Array, self, "initWithObjects:count:", objects, count) } @(objc_type=Array, objc_name="initWithCoder") -Array_initWithCoder :: proc(self: ^Array, coder: ^Coder) -> ^Array { +Array_initWithCoder :: proc "c" (self: ^Array, coder: ^Coder) -> ^Array { return msgSend(^Array, self, "initWithCoder:", coder) } @(objc_type=Array, objc_name="object") -Array_object :: proc(self: ^Array, index: UInteger) -> ^Object { +Array_object :: proc "c" (self: ^Array, index: UInteger) -> ^Object { return msgSend(^Object, self, "objectAtIndex:", index) } @(objc_type=Array, objc_name="objectAs") -Array_objectAs :: proc(self: ^Array, index: UInteger, $T: typeid) -> T where intrinsics.type_is_pointer(T), intrinsics.type_is_subtype_of(T, ^Object) { +Array_objectAs :: proc "c" (self: ^Array, index: UInteger, $T: typeid) -> T where intrinsics.type_is_pointer(T), intrinsics.type_is_subtype_of(T, ^Object) { return (T)(Array_object(self, index)) } @(objc_type=Array, objc_name="count") -Array_count :: proc(self: ^Array) -> UInteger { +Array_count :: proc "c" (self: ^Array) -> UInteger { return msgSend(UInteger, self, "count") } diff --git a/vendor/darwin/Foundation/NSAutoreleasePool.odin b/vendor/darwin/Foundation/NSAutoreleasePool.odin index a388a7146..8eb3657b6 100644 --- a/vendor/darwin/Foundation/NSAutoreleasePool.odin +++ b/vendor/darwin/Foundation/NSAutoreleasePool.odin @@ -4,30 +4,30 @@ package objc_Foundation AutoreleasePool :: struct {using _: Object} @(objc_type=AutoreleasePool, objc_name="alloc", objc_is_class_method=true) -AutoreleasePool_alloc :: proc() -> ^AutoreleasePool { +AutoreleasePool_alloc :: proc "c" () -> ^AutoreleasePool { return msgSend(^AutoreleasePool, AutoreleasePool, "alloc") } @(objc_type=AutoreleasePool, objc_name="init") -AutoreleasePool_init :: proc(self: ^AutoreleasePool) -> ^AutoreleasePool { +AutoreleasePool_init :: proc "c" (self: ^AutoreleasePool) -> ^AutoreleasePool { return msgSend(^AutoreleasePool, self, "init") } @(objc_type=AutoreleasePool, objc_name="drain") -AutoreleasePool_drain :: proc(self: ^AutoreleasePool) { +AutoreleasePool_drain :: proc "c" (self: ^AutoreleasePool) { msgSend(nil, self, "drain") } @(objc_type=AutoreleasePool, objc_name="addObject") -AutoreleasePool_addObject :: proc(self: ^AutoreleasePool, obj: ^Object) { +AutoreleasePool_addObject :: proc "c" (self: ^AutoreleasePool, obj: ^Object) { msgSend(nil, self, "addObject:", obj) } @(objc_type=AutoreleasePool, objc_name="showPools") -AutoreleasePool_showPools :: proc(self: ^AutoreleasePool, obj: ^Object) { +AutoreleasePool_showPools :: proc "c" (self: ^AutoreleasePool, obj: ^Object) { msgSend(nil, self, "showPools") } @(deferred_out=AutoreleasePool_drain) -scoped_autoreleasepool :: proc() -> ^AutoreleasePool { +scoped_autoreleasepool :: proc "c" () -> ^AutoreleasePool { return AutoreleasePool.alloc()->init() } \ No newline at end of file diff --git a/vendor/darwin/Foundation/NSBundle.odin b/vendor/darwin/Foundation/NSBundle.odin index 5e136378b..25fc8df32 100644 --- a/vendor/darwin/Foundation/NSBundle.odin +++ b/vendor/darwin/Foundation/NSBundle.odin @@ -4,188 +4,188 @@ package objc_Foundation Bundle :: struct { using _: Object } @(objc_type=Bundle, objc_name="mainBundle", objc_is_class_method=true) -Bundle_mainBundle :: proc() -> ^Bundle { +Bundle_mainBundle :: proc "c" () -> ^Bundle { return msgSend(^Bundle, Bundle, "mainBundle") } @(objc_type=Bundle, objc_name="bundleWithPath", objc_is_class_method=true) -Bundle_bundleWithPath :: proc(path: ^String) -> ^Bundle { +Bundle_bundleWithPath :: proc "c" (path: ^String) -> ^Bundle { return msgSend(^Bundle, Bundle, "bundleWithPath:", path) } @(objc_type=Bundle, objc_name="bundleWithURL", objc_is_class_method=true) -Bundle_bundleWithURL :: proc(url: ^URL) -> ^Bundle { +Bundle_bundleWithURL :: proc "c" (url: ^URL) -> ^Bundle { return msgSend(^Bundle, Bundle, "bundleWithUrl:", url) } @(objc_type=Bundle, objc_name="alloc", objc_is_class_method=true) -Bundle_alloc :: proc() -> ^Bundle { +Bundle_alloc :: proc "c" () -> ^Bundle { return msgSend(^Bundle, Bundle, "alloc") } @(objc_type=Bundle, objc_name="init") -Bundle_init :: proc(self: ^Bundle) -> ^Bundle { +Bundle_init :: proc "c" (self: ^Bundle) -> ^Bundle { return msgSend(^Bundle, self, "init") } @(objc_type=Bundle, objc_name="initWithPath") -Bundle_initWithPath :: proc(self: ^Bundle, path: ^String) -> ^Bundle { +Bundle_initWithPath :: proc "c" (self: ^Bundle, path: ^String) -> ^Bundle { return msgSend(^Bundle, self, "initWithPath:", path) } @(objc_type=Bundle, objc_name="initWithURL") -Bundle_initWithURL :: proc(self: ^Bundle, url: ^URL) -> ^Bundle { +Bundle_initWithURL :: proc "c" (self: ^Bundle, url: ^URL) -> ^Bundle { return msgSend(^Bundle, self, "initWithUrl:", url) } @(objc_type=Bundle, objc_name="allBundles") -Bundle_allBundles :: proc() -> (all: ^Array) { +Bundle_allBundles :: proc "c" () -> (all: ^Array) { return msgSend(type_of(all), Bundle, "allBundles") } @(objc_type=Bundle, objc_name="allFrameworks") -Bundle_allFrameworks :: proc() -> (all: ^Array) { +Bundle_allFrameworks :: proc "c" () -> (all: ^Array) { return msgSend(type_of(all), Bundle, "allFrameworks") } @(objc_type=Bundle, objc_name="load") -Bundle_load :: proc(self: ^Bundle) -> BOOL { +Bundle_load :: proc "c" (self: ^Bundle) -> BOOL { return msgSend(BOOL, self, "load") } @(objc_type=Bundle, objc_name="unload") -Bundle_unload :: proc(self: ^Bundle) -> BOOL { +Bundle_unload :: proc "c" (self: ^Bundle) -> BOOL { return msgSend(BOOL, self, "unload") } @(objc_type=Bundle, objc_name="isLoaded") -Bundle_isLoaded :: proc(self: ^Bundle) -> BOOL { +Bundle_isLoaded :: proc "c" (self: ^Bundle) -> BOOL { return msgSend(BOOL, self, "isLoaded") } @(objc_type=Bundle, objc_name="preflightAndReturnError") -Bundle_preflightAndReturnError :: proc(self: ^Bundle) -> (ok: BOOL, error: ^Error) { +Bundle_preflightAndReturnError :: proc "contextless" (self: ^Bundle) -> (ok: BOOL, error: ^Error) { ok = msgSend(BOOL, self, "preflightAndReturnError:", &error) return } @(objc_type=Bundle, objc_name="loadAndReturnError") -Bundle_loadAndReturnError :: proc(self: ^Bundle) -> (ok: BOOL, error: ^Error) { +Bundle_loadAndReturnError :: proc "contextless" (self: ^Bundle) -> (ok: BOOL, error: ^Error) { ok = msgSend(BOOL, self, "loadAndReturnError:", &error) return } @(objc_type=Bundle, objc_name="bundleURL") -Bundle_bundleURL :: proc(self: ^Bundle) -> ^URL { +Bundle_bundleURL :: proc "c" (self: ^Bundle) -> ^URL { return msgSend(^URL, self, "bundleURL") } @(objc_type=Bundle, objc_name="resourceURL") -Bundle_resourceURL :: proc(self: ^Bundle) -> ^URL { +Bundle_resourceURL :: proc "c" (self: ^Bundle) -> ^URL { return msgSend(^URL, self, "resourceURL") } @(objc_type=Bundle, objc_name="executableURL") -Bundle_executableURL :: proc(self: ^Bundle) -> ^URL { +Bundle_executableURL :: proc "c" (self: ^Bundle) -> ^URL { return msgSend(^URL, self, "executableURL") } @(objc_type=Bundle, objc_name="URLForAuxiliaryExecutable") -Bundle_URLForAuxiliaryExecutable :: proc(self: ^Bundle, executableName: ^String) -> ^URL { +Bundle_URLForAuxiliaryExecutable :: proc "c" (self: ^Bundle, executableName: ^String) -> ^URL { return msgSend(^URL, self, "URLForAuxiliaryExecutable:", executableName) } @(objc_type=Bundle, objc_name="privateFrameworksURL") -Bundle_privateFrameworksURL :: proc(self: ^Bundle) -> ^URL { +Bundle_privateFrameworksURL :: proc "c" (self: ^Bundle) -> ^URL { return msgSend(^URL, self, "privateFrameworksURL") } @(objc_type=Bundle, objc_name="sharedFrameworksURL") -Bundle_sharedFrameworksURL :: proc(self: ^Bundle) -> ^URL { +Bundle_sharedFrameworksURL :: proc "c" (self: ^Bundle) -> ^URL { return msgSend(^URL, self, "sharedFrameworksURL") } @(objc_type=Bundle, objc_name="sharedSupportURL") -Bundle_sharedSupportURL :: proc(self: ^Bundle) -> ^URL { +Bundle_sharedSupportURL :: proc "c" (self: ^Bundle) -> ^URL { return msgSend(^URL, self, "sharedSupportURL") } @(objc_type=Bundle, objc_name="builtInPlugInsURL") -Bundle_builtInPlugInsURL :: proc(self: ^Bundle) -> ^URL { +Bundle_builtInPlugInsURL :: proc "c" (self: ^Bundle) -> ^URL { return msgSend(^URL, self, "builtInPlugInsURL") } @(objc_type=Bundle, objc_name="appStoreReceiptURL") -Bundle_appStoreReceiptURL :: proc(self: ^Bundle) -> ^URL { +Bundle_appStoreReceiptURL :: proc "c" (self: ^Bundle) -> ^URL { return msgSend(^URL, self, "appStoreReceiptURL") } @(objc_type=Bundle, objc_name="bundlePath") -Bundle_bundlePath :: proc(self: ^Bundle) -> ^String { +Bundle_bundlePath :: proc "c" (self: ^Bundle) -> ^String { return msgSend(^String, self, "bundlePath") } @(objc_type=Bundle, objc_name="resourcePath") -Bundle_resourcePath :: proc(self: ^Bundle) -> ^String { +Bundle_resourcePath :: proc "c" (self: ^Bundle) -> ^String { return msgSend(^String, self, "resourcePath") } @(objc_type=Bundle, objc_name="executablePath") -Bundle_executablePath :: proc(self: ^Bundle) -> ^String { +Bundle_executablePath :: proc "c" (self: ^Bundle) -> ^String { return msgSend(^String, self, "executablePath") } @(objc_type=Bundle, objc_name="PathForAuxiliaryExecutable") -Bundle_PathForAuxiliaryExecutable :: proc(self: ^Bundle, executableName: ^String) -> ^String { +Bundle_PathForAuxiliaryExecutable :: proc "c" (self: ^Bundle, executableName: ^String) -> ^String { return msgSend(^String, self, "PathForAuxiliaryExecutable:", executableName) } @(objc_type=Bundle, objc_name="privateFrameworksPath") -Bundle_privateFrameworksPath :: proc(self: ^Bundle) -> ^String { +Bundle_privateFrameworksPath :: proc "c" (self: ^Bundle) -> ^String { return msgSend(^String, self, "privateFrameworksPath") } @(objc_type=Bundle, objc_name="sharedFrameworksPath") -Bundle_sharedFrameworksPath :: proc(self: ^Bundle) -> ^String { +Bundle_sharedFrameworksPath :: proc "c" (self: ^Bundle) -> ^String { return msgSend(^String, self, "sharedFrameworksPath") } @(objc_type=Bundle, objc_name="sharedSupportPath") -Bundle_sharedSupportPath :: proc(self: ^Bundle) -> ^String { +Bundle_sharedSupportPath :: proc "c" (self: ^Bundle) -> ^String { return msgSend(^String, self, "sharedSupportPath") } @(objc_type=Bundle, objc_name="builtInPlugInsPath") -Bundle_builtInPlugInsPath :: proc(self: ^Bundle) -> ^String { +Bundle_builtInPlugInsPath :: proc "c" (self: ^Bundle) -> ^String { return msgSend(^String, self, "builtInPlugInsPath") } @(objc_type=Bundle, objc_name="appStoreReceiptPath") -Bundle_appStoreReceiptPath :: proc(self: ^Bundle) -> ^String { +Bundle_appStoreReceiptPath :: proc "c" (self: ^Bundle) -> ^String { return msgSend(^String, self, "appStoreReceiptPath") } @(objc_type=Bundle, objc_name="bundleIdentifier") -Bundle_bundleIdentifier :: proc(self: ^Bundle) -> ^String { +Bundle_bundleIdentifier :: proc "c" (self: ^Bundle) -> ^String { return msgSend(^String, self, "bundleIdentifier") } @(objc_type=Bundle, objc_name="infoDictionary") -Bundle_infoDictionary :: proc(self: ^Bundle) -> ^Dictionary { +Bundle_infoDictionary :: proc "c" (self: ^Bundle) -> ^Dictionary { return msgSend(^Dictionary, self, "infoDictionary") } @(objc_type=Bundle, objc_name="localizedInfoDictionary") -Bundle_localizedInfoDictionary :: proc(self: ^Bundle) -> ^Dictionary { +Bundle_localizedInfoDictionary :: proc "c" (self: ^Bundle) -> ^Dictionary { return msgSend(^Dictionary, self, "localizedInfoDictionary") } @(objc_type=Bundle, objc_name="objectForInfoDictionaryKey") -Bundle_objectForInfoDictionaryKey :: proc(self: ^Bundle, key: ^String) -> ^Object { +Bundle_objectForInfoDictionaryKey :: proc "c" (self: ^Bundle, key: ^String) -> ^Object { return msgSend(^Object, self, "objectForInfoDictionaryKey:", key) } @(objc_type=Bundle, objc_name="localizedStringForKey") -Bundle_localizedStringForKey :: proc(self: ^Bundle, key: ^String, value: ^String = nil, tableName: ^String = nil) -> ^String { +Bundle_localizedStringForKey :: proc "c" (self: ^Bundle, key: ^String, value: ^String = nil, tableName: ^String = nil) -> ^String { return msgSend(^String, self, "localizedStringForKey:value:table:", key, value, tableName) } diff --git a/vendor/darwin/Foundation/NSData.odin b/vendor/darwin/Foundation/NSData.odin index 3c6369e86..04c1ce25d 100644 --- a/vendor/darwin/Foundation/NSData.odin +++ b/vendor/darwin/Foundation/NSData.odin @@ -4,21 +4,21 @@ package objc_Foundation Data :: struct {using _: Copying(Data)} @(objc_type=Data, objc_name="alloc", objc_is_class_method=true) -Data_alloc :: proc() -> ^Data { +Data_alloc :: proc "c" () -> ^Data { return msgSend(^Data, Data, "alloc") } @(objc_type=Data, objc_name="init") -Data_init :: proc(self: ^Data) -> ^Data { +Data_init :: proc "c" (self: ^Data) -> ^Data { return msgSend(^Data, self, "init") } @(objc_type=Data, objc_name="mutableBytes") -Data_mutableBytes :: proc(self: ^Data) -> rawptr { +Data_mutableBytes :: proc "c" (self: ^Data) -> rawptr { return msgSend(rawptr, self, "mutableBytes") } @(objc_type=Data, objc_name="length") -Data_length :: proc(self: ^Data) -> UInteger { +Data_length :: proc "c" (self: ^Data) -> UInteger { return msgSend(UInteger, self, "length") } \ No newline at end of file diff --git a/vendor/darwin/Foundation/NSDate.odin b/vendor/darwin/Foundation/NSDate.odin index e30cb07d0..f8096c698 100644 --- a/vendor/darwin/Foundation/NSDate.odin +++ b/vendor/darwin/Foundation/NSDate.odin @@ -4,16 +4,16 @@ package objc_Foundation Date :: struct {using _: Copying(Date)} @(objc_type=Date, objc_name="alloc", objc_is_class_method=true) -Date_alloc :: proc() -> ^Date { +Date_alloc :: proc "c" () -> ^Date { return msgSend(^Date, Date, "alloc") } @(objc_type=Date, objc_name="init") -Date_init :: proc(self: ^Date) -> ^Date { +Date_init :: proc "c" (self: ^Date) -> ^Date { return msgSend(^Date, self, "init") } @(objc_type=Date, objc_name="dateWithTimeIntervalSinceNow") -Date_dateWithTimeIntervalSinceNow :: proc(secs: TimeInterval) -> ^Date { +Date_dateWithTimeIntervalSinceNow :: proc "c" (secs: TimeInterval) -> ^Date { return msgSend(^Date, Date, "dateWithTimeIntervalSinceNow:", secs) } \ No newline at end of file diff --git a/vendor/darwin/Foundation/NSDictionary.odin b/vendor/darwin/Foundation/NSDictionary.odin index 3832c05f1..8af58cf62 100644 --- a/vendor/darwin/Foundation/NSDictionary.odin +++ b/vendor/darwin/Foundation/NSDictionary.odin @@ -4,47 +4,47 @@ package objc_Foundation Dictionary :: struct {using _: Copying(Dictionary)} @(objc_type=Dictionary, objc_name="dictionary", objc_is_class_method=true) -Dictionary_dictionary :: proc() -> ^Dictionary { +Dictionary_dictionary :: proc "c" () -> ^Dictionary { return msgSend(^Dictionary, Dictionary, "dictionary") } @(objc_type=Dictionary, objc_name="dictionaryWithObject", objc_is_class_method=true) -Dictionary_dictionaryWithObject :: proc(object: ^Object, forKey: ^Object) -> ^Dictionary { +Dictionary_dictionaryWithObject :: proc "c" (object: ^Object, forKey: ^Object) -> ^Dictionary { return msgSend(^Dictionary, Dictionary, "dictionaryWithObject:forKey:", object, forKey) } @(objc_type=Dictionary, objc_name="dictionaryWithObjects", objc_is_class_method=true) -Dictionary_dictionaryWithObjects :: proc(objects: [^]^Object, forKeys: [^]^Object, count: UInteger) -> ^Dictionary { +Dictionary_dictionaryWithObjects :: proc "c" (objects: [^]^Object, forKeys: [^]^Object, count: UInteger) -> ^Dictionary { return msgSend(^Dictionary, Dictionary, "dictionaryWithObjects:forKeys:count", objects, forKeys, count) } @(objc_type=Dictionary, objc_name="alloc", objc_is_class_method=true) -Dictionary_alloc :: proc() -> ^Dictionary { +Dictionary_alloc :: proc "c" () -> ^Dictionary { return msgSend(^Dictionary, Dictionary, "alloc") } @(objc_type=Dictionary, objc_name="init") -Dictionary_init :: proc(self: ^Dictionary) -> ^Dictionary { +Dictionary_init :: proc "c" (self: ^Dictionary) -> ^Dictionary { return msgSend(^Dictionary, self, "init") } @(objc_type=Dictionary, objc_name="initWithObjects") -Dictionary_initWithObjects :: proc(self: ^Dictionary, objects: [^]^Object, forKeys: [^]^Object, count: UInteger) -> ^Dictionary { +Dictionary_initWithObjects :: proc "c" (self: ^Dictionary, objects: [^]^Object, forKeys: [^]^Object, count: UInteger) -> ^Dictionary { return msgSend(^Dictionary, self, "initWithObjects:forKeys:count", objects, forKeys, count) } @(objc_type=Dictionary, objc_name="objectForKey") -Dictionary_objectForKey :: proc(self: ^Dictionary, key: ^Object) -> ^Object { +Dictionary_objectForKey :: proc "c" (self: ^Dictionary, key: ^Object) -> ^Object { return msgSend(^Dictionary, self, "objectForKey:", key) } @(objc_type=Dictionary, objc_name="count") -Dictionary_count :: proc(self: ^Dictionary) -> UInteger { +Dictionary_count :: proc "c" (self: ^Dictionary) -> UInteger { return msgSend(UInteger, self, "count") } @(objc_type=Dictionary, objc_name="keyEnumerator") -Dictionary_keyEnumerator :: proc(self: ^Dictionary, $KeyType: typeid) -> (enumerator: ^Enumerator(KeyType)) { +Dictionary_keyEnumerator :: proc "c" (self: ^Dictionary, $KeyType: typeid) -> (enumerator: ^Enumerator(KeyType)) { return msgSend(type_of(enumerator), self, "keyEnumerator") } diff --git a/vendor/darwin/Foundation/NSEnumerator.odin b/vendor/darwin/Foundation/NSEnumerator.odin index 1c7ddeed2..555e58141 100644 --- a/vendor/darwin/Foundation/NSEnumerator.odin +++ b/vendor/darwin/Foundation/NSEnumerator.odin @@ -20,30 +20,30 @@ Enumerator :: struct($T: typeid) where intrinsics.type_is_pointer(T), intrinsics @(objc_type=FastEnumeration, objc_name="alloc", objc_is_class_method=true) -FastEnumeration_alloc :: proc() -> ^FastEnumeration { +FastEnumeration_alloc :: proc "c" () -> ^FastEnumeration { return msgSend(^FastEnumeration, FastEnumeration, "alloc") } @(objc_type=FastEnumeration, objc_name="init") -FastEnumeration_init :: proc(self: ^FastEnumeration) -> ^FastEnumeration { +FastEnumeration_init :: proc "c" (self: ^FastEnumeration) -> ^FastEnumeration { return msgSend(^FastEnumeration, self, "init") } @(objc_type=FastEnumeration, objc_name="countByEnumerating") -FastEnumeration_countByEnumerating :: proc(self: ^FastEnumeration, state: ^FastEnumerationState, buffer: [^]^Object, len: UInteger) -> UInteger { +FastEnumeration_countByEnumerating :: proc "c" (self: ^FastEnumeration, state: ^FastEnumerationState, buffer: [^]^Object, len: UInteger) -> UInteger { return msgSend(UInteger, self, "countByEnumeratingWithState:objects:count:", state, buffer, len) } -Enumerator_nextObject :: proc(self: ^$E/Enumerator($T)) -> T { +Enumerator_nextObject :: proc "c" (self: ^$E/Enumerator($T)) -> T { return msgSend(T, self, "nextObject") } -Enumerator_allObjects :: proc(self: ^$E/Enumerator($T)) -> (all: ^Array) { +Enumerator_allObjects :: proc "c" (self: ^$E/Enumerator($T)) -> (all: ^Array) { return msgSend(type_of(all), self, "allObjects") } -Enumerator_iterator :: proc(self: ^$E/Enumerator($T)) -> (obj: T, ok: bool) { +Enumerator_iterator :: proc "contextless" (self: ^$E/Enumerator($T)) -> (obj: T, ok: bool) { obj = msgSend(T, self, "nextObject") ok = obj != nil return diff --git a/vendor/darwin/Foundation/NSError.odin b/vendor/darwin/Foundation/NSError.odin index 23e6eaba7..1657befe2 100644 --- a/vendor/darwin/Foundation/NSError.odin +++ b/vendor/darwin/Foundation/NSError.odin @@ -33,56 +33,56 @@ Error :: struct { using _: Copying(Error) } @(objc_type=Error, objc_name="alloc", objc_is_class_method=true) -Error_alloc :: proc() -> ^Error { +Error_alloc :: proc "c" () -> ^Error { return msgSend(^Error, Error, "alloc") } @(objc_type=Error, objc_name="init") -Error_init :: proc(self: ^Error) -> ^Error { +Error_init :: proc "c" (self: ^Error) -> ^Error { return msgSend(^Error, self, "init") } @(objc_type=Error, objc_name="errorWithDomain", objc_is_class_method=true) -Error_errorWithDomain :: proc(domain: ErrorDomain, code: Integer, userInfo: ^Dictionary) -> ^Error { +Error_errorWithDomain :: proc "c" (domain: ErrorDomain, code: Integer, userInfo: ^Dictionary) -> ^Error { return msgSend(^Error, Error, "errorWithDomain:code:userInfo:", domain, code, userInfo) } @(objc_type=Error, objc_name="initWithDomain") -Error_initWithDomain :: proc(self: ^Error, domain: ErrorDomain, code: Integer, userInfo: ^Dictionary) -> ^Error { +Error_initWithDomain :: proc "c" (self: ^Error, domain: ErrorDomain, code: Integer, userInfo: ^Dictionary) -> ^Error { return msgSend(^Error, self, "initWithDomain:code:userInfo:", domain, code, userInfo) } @(objc_type=Error, objc_name="code") -Error_code :: proc(self: ^Error) -> Integer { +Error_code :: proc "c" (self: ^Error) -> Integer { return msgSend(Integer, self, "code") } @(objc_type=Error, objc_name="domain") -Error_domain :: proc(self: ^Error) -> ErrorDomain { +Error_domain :: proc "c" (self: ^Error) -> ErrorDomain { return msgSend(ErrorDomain, self, "domain") } @(objc_type=Error, objc_name="userInfo") -Error_userInfo :: proc(self: ^Error) -> ^Dictionary { +Error_userInfo :: proc "c" (self: ^Error) -> ^Dictionary { return msgSend(^Dictionary, self, "userInfo") } @(objc_type=Error, objc_name="localizedDescription") -Error_localizedDescription :: proc(self: ^Error) -> ^String { +Error_localizedDescription :: proc "c" (self: ^Error) -> ^String { return msgSend(^String, self, "localizedDescription") } @(objc_type=Error, objc_name="localizedRecoveryOptions") -Error_localizedRecoveryOptions :: proc(self: ^Error) -> (options: ^Array) { +Error_localizedRecoveryOptions :: proc "c" (self: ^Error) -> (options: ^Array) { return msgSend(type_of(options), self, "localizedRecoveryOptions") } @(objc_type=Error, objc_name="localizedRecoverySuggestion") -Error_localizedRecoverySuggestion :: proc(self: ^Error) -> ^String { +Error_localizedRecoverySuggestion :: proc "c" (self: ^Error) -> ^String { return msgSend(^String, self, "localizedRecoverySuggestion") } @(objc_type=Error, objc_name="localizedFailureReason") -Error_localizedFailureReason :: proc(self: ^Error) -> ^String { +Error_localizedFailureReason :: proc "c" (self: ^Error) -> ^String { return msgSend(^String, self, "localizedFailureReason") } \ No newline at end of file diff --git a/vendor/darwin/Foundation/NSEvent.odin b/vendor/darwin/Foundation/NSEvent.odin new file mode 100644 index 000000000..900f05a6c --- /dev/null +++ b/vendor/darwin/Foundation/NSEvent.odin @@ -0,0 +1,5 @@ +package objc_Foundation + +@(objc_class="NSEvent") +Event :: struct {using _: Object} +// TODO: implement NSEvent diff --git a/vendor/darwin/Foundation/NSLock.odin b/vendor/darwin/Foundation/NSLock.odin index c48b5dbad..168380669 100644 --- a/vendor/darwin/Foundation/NSLock.odin +++ b/vendor/darwin/Foundation/NSLock.odin @@ -2,10 +2,10 @@ package objc_Foundation Locking :: struct($T: typeid) {using _: Object} -Locking_lock :: proc(self: ^Locking($T)) { +Locking_lock :: proc "c" (self: ^Locking($T)) { msgSend(nil, self, "lock") } -Locking_unlock :: proc(self: ^Locking($T)) { +Locking_unlock :: proc "c" (self: ^Locking($T)) { msgSend(nil, self, "unlock") } @@ -14,40 +14,40 @@ Condition :: struct {using _: Locking(Condition) } @(objc_type=Condition, objc_name="alloc", objc_is_class_method=true) -Condition_alloc :: proc() -> ^Condition { +Condition_alloc :: proc "c" () -> ^Condition { return msgSend(^Condition, Condition, "alloc") } @(objc_type=Condition, objc_name="init") -Condition_init :: proc(self: ^Condition) -> ^Condition { +Condition_init :: proc "c" (self: ^Condition) -> ^Condition { return msgSend(^Condition, self, "init") } @(objc_type=Condition, objc_name="wait") -Condition_wait :: proc(self: ^Condition) { +Condition_wait :: proc "c" (self: ^Condition) { msgSend(nil, self, "wait") } @(objc_type=Condition, objc_name="waitUntilDate") -Condition_waitUntilDate :: proc(self: ^Condition, limit: ^Date) -> BOOL { +Condition_waitUntilDate :: proc "c" (self: ^Condition, limit: ^Date) -> BOOL { return msgSend(BOOL, self, "waitUntilDate:", limit) } @(objc_type=Condition, objc_name="signal") -Condition_signal :: proc(self: ^Condition) { +Condition_signal :: proc "c" (self: ^Condition) { msgSend(nil, self, "signal") } @(objc_type=Condition, objc_name="broadcast") -Condition_broadcast :: proc(self: ^Condition) { +Condition_broadcast :: proc "c" (self: ^Condition) { msgSend(nil, self, "broadcast") } @(objc_type=Condition, objc_name="lock") -Condition_lock :: proc(self: ^Condition) { +Condition_lock :: proc "c" (self: ^Condition) { msgSend(nil, self, "lock") } @(objc_type=Condition, objc_name="unlock") -Condition_unlock :: proc(self: ^Condition) { +Condition_unlock :: proc "c" (self: ^Condition) { msgSend(nil, self, "unlock") } \ No newline at end of file diff --git a/vendor/darwin/Foundation/NSMenu.odin b/vendor/darwin/Foundation/NSMenu.odin index 964e3061d..6ed9b9918 100644 --- a/vendor/darwin/Foundation/NSMenu.odin +++ b/vendor/darwin/Foundation/NSMenu.odin @@ -27,11 +27,11 @@ MenuItemCallback :: proc "c" (unused: rawptr, name: SEL, sender: ^Object) MenuItem :: struct {using _: Object} @(objc_type=MenuItem, objc_name="alloc", objc_is_class_method=true) -MenuItem_alloc :: proc() -> ^MenuItem { +MenuItem_alloc :: proc "c" () -> ^MenuItem { return msgSend(^MenuItem, MenuItem, "alloc") } @(objc_type=MenuItem, objc_name="registerActionCallback", objc_is_class_method=true) -MenuItem_registerActionCallback :: proc(name: cstring, callback: MenuItemCallback) -> SEL { +MenuItem_registerActionCallback :: proc "c" (name: cstring, callback: MenuItemCallback) -> SEL { s := string(name) n := len(s) sel: SEL @@ -51,22 +51,22 @@ MenuItem_registerActionCallback :: proc(name: cstring, callback: MenuItemCallbac } @(objc_type=MenuItem, objc_name="init") -MenuItem_init :: proc(self: ^MenuItem) -> ^MenuItem { +MenuItem_init :: proc "c" (self: ^MenuItem) -> ^MenuItem { return msgSend(^MenuItem, self, "init") } @(objc_type=MenuItem, objc_name="setKeyEquivalentModifierMask") -MenuItem_setKeyEquivalentModifierMask :: proc(self: ^MenuItem, modifierMask: KeyEquivalentModifierMask) { +MenuItem_setKeyEquivalentModifierMask :: proc "c" (self: ^MenuItem, modifierMask: KeyEquivalentModifierMask) { msgSend(nil, self, "setKeyEquivalentModifierMask:", modifierMask) } @(objc_type=MenuItem, objc_name="keyEquivalentModifierMask") -MenuItem_keyEquivalentModifierMask :: proc(self: ^MenuItem) -> KeyEquivalentModifierMask { +MenuItem_keyEquivalentModifierMask :: proc "c" (self: ^MenuItem) -> KeyEquivalentModifierMask { return msgSend(KeyEquivalentModifierMask, self, "keyEquivalentModifierMask") } @(objc_type=MenuItem, objc_name="setSubmenu") -MenuItem_setSubmenu :: proc(self: ^MenuItem, submenu: ^Menu) { +MenuItem_setSubmenu :: proc "c" (self: ^MenuItem, submenu: ^Menu) { msgSend(nil, self, "setSubmenu:", submenu) } @@ -77,27 +77,27 @@ MenuItem_setSubmenu :: proc(self: ^MenuItem, submenu: ^Menu) { Menu :: struct {using _: Object} @(objc_type=Menu, objc_name="alloc", objc_is_class_method=true) -Menu_alloc :: proc() -> ^Menu { +Menu_alloc :: proc "c" () -> ^Menu { return msgSend(^Menu, Menu, "alloc") } @(objc_type=Menu, objc_name="init") -Menu_init :: proc(self: ^Menu) -> ^Menu { +Menu_init :: proc "c" (self: ^Menu) -> ^Menu { return msgSend(^Menu, self, "init") } @(objc_type=Menu, objc_name="initWithTitle") -Menu_initWithTitle :: proc(self: ^Menu, title: ^String) -> ^Menu { +Menu_initWithTitle :: proc "c" (self: ^Menu, title: ^String) -> ^Menu { return msgSend(^Menu, self, "initWithTitle:", title) } @(objc_type=Menu, objc_name="addItem") -Menu_addItem :: proc(self: ^Menu, item: ^MenuItem) { +Menu_addItem :: proc "c" (self: ^Menu, item: ^MenuItem) { msgSend(nil, self, "addItem:", item) } @(objc_type=Menu, objc_name="addItemWithTitle") -Menu_addItemWithTitle :: proc(self: ^Menu, title: ^String, selector: SEL, keyEquivalent: ^String) -> ^MenuItem { +Menu_addItemWithTitle :: proc "c" (self: ^Menu, title: ^String, selector: SEL, keyEquivalent: ^String) -> ^MenuItem { return msgSend(^MenuItem, self, "addItemWithTitle:action:keyEquivalent:", title, selector, keyEquivalent) } \ No newline at end of file diff --git a/vendor/darwin/Foundation/NSNotification.odin b/vendor/darwin/Foundation/NSNotification.odin index ec8dddab7..f766d0cab 100644 --- a/vendor/darwin/Foundation/NSNotification.odin +++ b/vendor/darwin/Foundation/NSNotification.odin @@ -5,26 +5,56 @@ Notification :: struct{using _: Object} @(objc_type=Notification, objc_name="alloc", objc_is_class_method=true) -Notification_alloc :: proc() -> ^Notification { +Notification_alloc :: proc "c" () -> ^Notification { return msgSend(^Notification, Notification, "alloc") } @(objc_type=Notification, objc_name="init") -Notification_init :: proc(self: ^Notification) -> ^Notification { +Notification_init :: proc "c" (self: ^Notification) -> ^Notification { return msgSend(^Notification, self, "init") } @(objc_type=Notification, objc_name="name") -Notification_name :: proc(self: ^Notification) -> ^String { +Notification_name :: proc "c" (self: ^Notification) -> ^String { return msgSend(^String, self, "name") } @(objc_type=Notification, objc_name="object") -Notification_object :: proc(self: ^Notification) -> ^Object { +Notification_object :: proc "c" (self: ^Notification) -> ^Object { return msgSend(^Object, self, "object") } @(objc_type=Notification, objc_name="userInfo") -Notification_userInfo :: proc(self: ^Notification) -> ^Dictionary { +Notification_userInfo :: proc "c" (self: ^Notification) -> ^Dictionary { return msgSend(^Dictionary, self, "userInfo") +} + +NotificationName :: ^String + +@(objc_class="NSNotificationCenter") +NotificationCenter :: struct{using _: Object} + + +@(objc_type=NotificationCenter, objc_name="alloc", objc_is_class_method=true) +NotificationCenter_alloc :: proc "c" () -> ^NotificationCenter { + return msgSend(^NotificationCenter, NotificationCenter, "alloc") +} + +@(objc_type=NotificationCenter, objc_name="init") +NotificationCenter_init :: proc "c" (self: ^NotificationCenter) -> ^NotificationCenter { + return msgSend(^NotificationCenter, self, "init") +} + +@(objc_type=NotificationCenter, objc_name="defaultCenter", objc_is_class_method=true) +NotificationCenter_defaultCenter :: proc "c" () -> ^NotificationCenter { + return msgSend(^NotificationCenter, NotificationCenter, "defaultCenter") +} + +@(objc_type=NotificationCenter, objc_name="addObserver") +NotificationCenter_addObserverName :: proc "c" (self: ^NotificationCenter, name: NotificationName, pObj: ^Object, pQueue: rawptr, block: ^Block) -> ^Object { + return msgSend(^Object, self, "addObserverName:object:queue:block:", name, pObj, pQueue, block) +} +@(objc_type=NotificationCenter, objc_name="removeObserver") +NotificationCenter_removeObserver :: proc "c" (self: ^NotificationCenter, pObserver: ^Object) { + msgSend(nil, self, "removeObserver:", pObserver) } \ No newline at end of file diff --git a/vendor/darwin/Foundation/NSNumber.odin b/vendor/darwin/Foundation/NSNumber.odin index d459e673f..99b281307 100644 --- a/vendor/darwin/Foundation/NSNumber.odin +++ b/vendor/darwin/Foundation/NSNumber.odin @@ -12,37 +12,37 @@ when ODIN_OS == .Darwin { Value :: struct{using _: Copying(Value)} @(objc_type=Value, objc_name="alloc", objc_is_class_method=true) -Value_alloc :: proc() -> ^Value { +Value_alloc :: proc "c" () -> ^Value { return msgSend(^Value, Value, "alloc") } @(objc_type=Value, objc_name="init") -Value_init :: proc(self: ^Value) -> ^Value { +Value_init :: proc "c" (self: ^Value) -> ^Value { return msgSend(^Value, self, "init") } @(objc_type=Value, objc_name="valueWithBytes", objc_is_class_method=true) -Value_valueWithBytes :: proc(value: rawptr, type: cstring) -> ^Value { +Value_valueWithBytes :: proc "c" (value: rawptr, type: cstring) -> ^Value { return msgSend(^Value, Value, "valueWithBytes:objCType:", value, type) } @(objc_type=Value, objc_name="valueWithPointer", objc_is_class_method=true) -Value_valueWithPointer :: proc(pointer: rawptr) -> ^Value { +Value_valueWithPointer :: proc "c" (pointer: rawptr) -> ^Value { return msgSend(^Value, Value, "valueWithPointer:", pointer) } @(objc_type=Value, objc_name="initWithBytes") -Value_initWithBytes :: proc(self: ^Value, value: rawptr, type: cstring) -> ^Value { +Value_initWithBytes :: proc "c" (self: ^Value, value: rawptr, type: cstring) -> ^Value { return msgSend(^Value, self, "initWithBytes:objCType:", value, type) } @(objc_type=Value, objc_name="initWithCoder") -Value_initWithCoder :: proc(self: ^Value, coder: ^Coder) -> ^Value { +Value_initWithCoder :: proc "c" (self: ^Value, coder: ^Coder) -> ^Value { return msgSend(^Value, self, "initWithCoder:", coder) } @(objc_type=Value, objc_name="getValue") -Value_getValue :: proc(self: ^Value, value: rawptr, size: UInteger) { +Value_getValue :: proc "c" (self: ^Value, value: rawptr, size: UInteger) { msgSend(nil, self, "getValue:size:", value, size) } @@ -67,29 +67,30 @@ Value_pointerValue :: proc "c" (self: ^Value) -> rawptr { Number :: struct{using _: Copying(Number), using _: Value} @(objc_type=Number, objc_name="alloc", objc_is_class_method=true) -Number_alloc :: proc() -> ^Number { +Number_alloc :: proc "c" () -> ^Number { return msgSend(^Number, Number, "alloc") } @(objc_type=Number, objc_name="init") -Number_init :: proc(self: ^Number) -> ^Number { +Number_init :: proc "c" (self: ^Number) -> ^Number { return msgSend(^Number, self, "init") } -@(objc_type=Number, objc_name="numberWithI8", objc_is_class_method=true) Number_numberWithI8 :: proc(value: i8) -> ^Number { return msgSend(^Number, Number, "numberWithChar:", value) } -@(objc_type=Number, objc_name="numberWithU8", objc_is_class_method=true) Number_numberWithU8 :: proc(value: u8) -> ^Number { return msgSend(^Number, Number, "numberWithUnsignedChar:", value) } -@(objc_type=Number, objc_name="numberWithI16", objc_is_class_method=true) Number_numberWithI16 :: proc(value: i16) -> ^Number { return msgSend(^Number, Number, "numberWithShort:", value) } -@(objc_type=Number, objc_name="numberWithU16", objc_is_class_method=true) Number_numberWithU16 :: proc(value: u16) -> ^Number { return msgSend(^Number, Number, "numberWithUnsignedShort:", value) } -@(objc_type=Number, objc_name="numberWithI32", objc_is_class_method=true) Number_numberWithI32 :: proc(value: i32) -> ^Number { return msgSend(^Number, Number, "numberWithInt:", value) } -@(objc_type=Number, objc_name="numberWithU32", objc_is_class_method=true) Number_numberWithU32 :: proc(value: u32) -> ^Number { return msgSend(^Number, Number, "numberWithUnsignedInt:", value) } -@(objc_type=Number, objc_name="numberWithInt", objc_is_class_method=true) Number_numberWithInt :: proc(value: int) -> ^Number { return msgSend(^Number, Number, "numberWithLong:", value) } -@(objc_type=Number, objc_name="numberWithUint", objc_is_class_method=true) Number_numberWithUint :: proc(value: uint) -> ^Number { return msgSend(^Number, Number, "numberWithUnsignedLong:", value) } -@(objc_type=Number, objc_name="numberWithU64", objc_is_class_method=true) Number_numberWithU64 :: proc(value: u64) -> ^Number { return msgSend(^Number, Number, "numberWithLongLong:", value) } -@(objc_type=Number, objc_name="numberWithI64", objc_is_class_method=true) Number_numberWithI64 :: proc(value: i64) -> ^Number { return msgSend(^Number, Number, "numberWithUnsignedLongLong:", value) } -@(objc_type=Number, objc_name="numberWithF32", objc_is_class_method=true) Number_numberWithF32 :: proc(value: f32) -> ^Number { return msgSend(^Number, Number, "numberWithFloat:", value) } -@(objc_type=Number, objc_name="numberWithF64", objc_is_class_method=true) Number_numberWithF64 :: proc(value: f64) -> ^Number { return msgSend(^Number, Number, "numberWithDouble:", value) } -@(objc_type=Number, objc_name="numberWithBool", objc_is_class_method=true) Number_numberWithBool :: proc(value: BOOL) -> ^Number { return msgSend(^Number, Number, "numberWithBool:", value) } +@(objc_type=Number, objc_name="numberWithI8", objc_is_class_method=true) Number_numberWithI8 :: proc "c" (value: i8) -> ^Number { return msgSend(^Number, Number, "numberWithChar:", value) } +@(objc_type=Number, objc_name="numberWithU8", objc_is_class_method=true) Number_numberWithU8 :: proc "c" (value: u8) -> ^Number { return msgSend(^Number, Number, "numberWithUnsignedChar:", value) } +@(objc_type=Number, objc_name="numberWithI16", objc_is_class_method=true) Number_numberWithI16 :: proc "c" (value: i16) -> ^Number { return msgSend(^Number, Number, "numberWithShort:", value) } +@(objc_type=Number, objc_name="numberWithU16", objc_is_class_method=true) Number_numberWithU16 :: proc "c" (value: u16) -> ^Number { return msgSend(^Number, Number, "numberWithUnsignedShort:", value) } +@(objc_type=Number, objc_name="numberWithI32", objc_is_class_method=true) Number_numberWithI32 :: proc "c" (value: i32) -> ^Number { return msgSend(^Number, Number, "numberWithInt:", value) } +@(objc_type=Number, objc_name="numberWithU32", objc_is_class_method=true) Number_numberWithU32 :: proc "c" (value: u32) -> ^Number { return msgSend(^Number, Number, "numberWithUnsignedInt:", value) } +@(objc_type=Number, objc_name="numberWithInt", objc_is_class_method=true) Number_numberWithInt :: proc "c" (value: int) -> ^Number { return msgSend(^Number, Number, "numberWithLong:", value) } +@(objc_type=Number, objc_name="numberWithUint", objc_is_class_method=true) Number_numberWithUint :: proc "c" (value: uint) -> ^Number { return msgSend(^Number, Number, "numberWithUnsignedLong:", value) } +@(objc_type=Number, objc_name="numberWithU64", objc_is_class_method=true) Number_numberWithU64 :: proc "c" (value: u64) -> ^Number { return msgSend(^Number, Number, "numberWithLongLong:", value) } +@(objc_type=Number, objc_name="numberWithI64", objc_is_class_method=true) Number_numberWithI64 :: proc "c" (value: i64) -> ^Number { return msgSend(^Number, Number, "numberWithUnsignedLongLong:", value) } +@(objc_type=Number, objc_name="numberWithF32", objc_is_class_method=true) Number_numberWithF32 :: proc "c" (value: f32) -> ^Number { return msgSend(^Number, Number, "numberWithFloat:", value) } +@(objc_type=Number, objc_name="numberWithF64", objc_is_class_method=true) Number_numberWithF64 :: proc "c" (value: f64) -> ^Number { return msgSend(^Number, Number, "numberWithDouble:", value) } +@(objc_type=Number, objc_name="numberWithBool", objc_is_class_method=true) Number_numberWithBool :: proc "c" (value: BOOL) -> ^Number { return msgSend(^Number, Number, "numberWithBool:", value) } +@(objc_type=Number, objc_name="number", objc_is_class_method=true) Number_number :: proc{ Number_numberWithI8, Number_numberWithU8, @@ -106,49 +107,49 @@ Number_number :: proc{ Number_numberWithBool, } -@(objc_type=Number, objc_name="initWithI8") Number_initWithI8 :: proc(self: ^Number, value: i8) -> ^Number { return msgSend(^Number, self, "initWithChar:", value) } -@(objc_type=Number, objc_name="initWithU8") Number_initWithU8 :: proc(self: ^Number, value: u8) -> ^Number { return msgSend(^Number, self, "initWithUnsignedChar:", value) } -@(objc_type=Number, objc_name="initWithI16") Number_initWithI16 :: proc(self: ^Number, value: i16) -> ^Number { return msgSend(^Number, self, "initWithShort:", value) } -@(objc_type=Number, objc_name="initWithU16") Number_initWithU16 :: proc(self: ^Number, value: u16) -> ^Number { return msgSend(^Number, self, "initWithUnsignedShort:", value) } -@(objc_type=Number, objc_name="initWithI32") Number_initWithI32 :: proc(self: ^Number, value: i32) -> ^Number { return msgSend(^Number, self, "initWithInt:", value) } -@(objc_type=Number, objc_name="initWithU32") Number_initWithU32 :: proc(self: ^Number, value: u32) -> ^Number { return msgSend(^Number, self, "initWithUnsignedInt:", value) } -@(objc_type=Number, objc_name="initWithInt") Number_initWithInt :: proc(self: ^Number, value: int) -> ^Number { return msgSend(^Number, self, "initWithLong:", value) } -@(objc_type=Number, objc_name="initWithUint") Number_initWithUint :: proc(self: ^Number, value: uint) -> ^Number { return msgSend(^Number, self, "initWithUnsignedLong:", value) } -@(objc_type=Number, objc_name="initWithU64") Number_initWithU64 :: proc(self: ^Number, value: u64) -> ^Number { return msgSend(^Number, self, "initWithLongLong:", value) } -@(objc_type=Number, objc_name="initWithI64") Number_initWithI64 :: proc(self: ^Number, value: i64) -> ^Number { return msgSend(^Number, self, "initWithUnsignedLongLong:", value) } -@(objc_type=Number, objc_name="initWithF32") Number_initWithF32 :: proc(self: ^Number, value: f32) -> ^Number { return msgSend(^Number, self, "initWithFloat:", value) } -@(objc_type=Number, objc_name="initWithF64") Number_initWithF64 :: proc(self: ^Number, value: f64) -> ^Number { return msgSend(^Number, self, "initWithDouble:", value) } -@(objc_type=Number, objc_name="initWithBool") Number_initWithBool :: proc(self: ^Number, value: BOOL) -> ^Number { return msgSend(^Number, self, "initWithBool:", value) } +@(objc_type=Number, objc_name="initWithI8") Number_initWithI8 :: proc "c" (self: ^Number, value: i8) -> ^Number { return msgSend(^Number, self, "initWithChar:", value) } +@(objc_type=Number, objc_name="initWithU8") Number_initWithU8 :: proc "c" (self: ^Number, value: u8) -> ^Number { return msgSend(^Number, self, "initWithUnsignedChar:", value) } +@(objc_type=Number, objc_name="initWithI16") Number_initWithI16 :: proc "c" (self: ^Number, value: i16) -> ^Number { return msgSend(^Number, self, "initWithShort:", value) } +@(objc_type=Number, objc_name="initWithU16") Number_initWithU16 :: proc "c" (self: ^Number, value: u16) -> ^Number { return msgSend(^Number, self, "initWithUnsignedShort:", value) } +@(objc_type=Number, objc_name="initWithI32") Number_initWithI32 :: proc "c" (self: ^Number, value: i32) -> ^Number { return msgSend(^Number, self, "initWithInt:", value) } +@(objc_type=Number, objc_name="initWithU32") Number_initWithU32 :: proc "c" (self: ^Number, value: u32) -> ^Number { return msgSend(^Number, self, "initWithUnsignedInt:", value) } +@(objc_type=Number, objc_name="initWithInt") Number_initWithInt :: proc "c" (self: ^Number, value: int) -> ^Number { return msgSend(^Number, self, "initWithLong:", value) } +@(objc_type=Number, objc_name="initWithUint") Number_initWithUint :: proc "c" (self: ^Number, value: uint) -> ^Number { return msgSend(^Number, self, "initWithUnsignedLong:", value) } +@(objc_type=Number, objc_name="initWithU64") Number_initWithU64 :: proc "c" (self: ^Number, value: u64) -> ^Number { return msgSend(^Number, self, "initWithLongLong:", value) } +@(objc_type=Number, objc_name="initWithI64") Number_initWithI64 :: proc "c" (self: ^Number, value: i64) -> ^Number { return msgSend(^Number, self, "initWithUnsignedLongLong:", value) } +@(objc_type=Number, objc_name="initWithF32") Number_initWithF32 :: proc "c" (self: ^Number, value: f32) -> ^Number { return msgSend(^Number, self, "initWithFloat:", value) } +@(objc_type=Number, objc_name="initWithF64") Number_initWithF64 :: proc "c" (self: ^Number, value: f64) -> ^Number { return msgSend(^Number, self, "initWithDouble:", value) } +@(objc_type=Number, objc_name="initWithBool") Number_initWithBool :: proc "c" (self: ^Number, value: BOOL) -> ^Number { return msgSend(^Number, self, "initWithBool:", value) } -@(objc_type=Number, objc_name="i8Value") Number_i8Value :: proc(self: ^Number) -> i8 { return msgSend(i8, self, "charValue") } -@(objc_type=Number, objc_name="u8Value") Number_u8Value :: proc(self: ^Number) -> u8 { return msgSend(u8, self, "unsignedCharValue") } -@(objc_type=Number, objc_name="i16Value") Number_i16Value :: proc(self: ^Number) -> i16 { return msgSend(i16, self, "shortValue") } -@(objc_type=Number, objc_name="u16Value") Number_u16Value :: proc(self: ^Number) -> u16 { return msgSend(u16, self, "unsignedShortValue") } -@(objc_type=Number, objc_name="i32Value") Number_i32Value :: proc(self: ^Number) -> i32 { return msgSend(i32, self, "intValue") } -@(objc_type=Number, objc_name="u32Value") Number_u32Value :: proc(self: ^Number) -> u32 { return msgSend(u32, self, "unsignedIntValue") } -@(objc_type=Number, objc_name="intValue") Number_intValue :: proc(self: ^Number) -> int { return msgSend(int, self, "longValue") } -@(objc_type=Number, objc_name="uintValue") Number_uintValue :: proc(self: ^Number) -> uint { return msgSend(uint, self, "unsignedLongValue") } -@(objc_type=Number, objc_name="u64Value") Number_u64Value :: proc(self: ^Number) -> u64 { return msgSend(u64, self, "longLongValue") } -@(objc_type=Number, objc_name="i64Value") Number_i64Value :: proc(self: ^Number) -> i64 { return msgSend(i64, self, "unsignedLongLongValue") } -@(objc_type=Number, objc_name="f32Value") Number_f32Value :: proc(self: ^Number) -> f32 { return msgSend(f32, self, "floatValue") } -@(objc_type=Number, objc_name="f64Value") Number_f64Value :: proc(self: ^Number) -> f64 { return msgSend(f64, self, "doubleValue") } -@(objc_type=Number, objc_name="boolValue") Number_boolValue :: proc(self: ^Number) -> BOOL { return msgSend(BOOL, self, "boolValue") } -@(objc_type=Number, objc_name="integerValue") Number_integerValue :: proc(self: ^Number) -> Integer { return msgSend(Integer, self, "integerValue") } -@(objc_type=Number, objc_name="uintegerValue") Number_uintegerValue :: proc(self: ^Number) -> UInteger { return msgSend(UInteger, self, "unsignedIntegerValue") } -@(objc_type=Number, objc_name="stringValue") Number_stringValue :: proc(self: ^Number) -> ^String { return msgSend(^String, self, "stringValue") } +@(objc_type=Number, objc_name="i8Value") Number_i8Value :: proc "c" (self: ^Number) -> i8 { return msgSend(i8, self, "charValue") } +@(objc_type=Number, objc_name="u8Value") Number_u8Value :: proc "c" (self: ^Number) -> u8 { return msgSend(u8, self, "unsignedCharValue") } +@(objc_type=Number, objc_name="i16Value") Number_i16Value :: proc "c" (self: ^Number) -> i16 { return msgSend(i16, self, "shortValue") } +@(objc_type=Number, objc_name="u16Value") Number_u16Value :: proc "c" (self: ^Number) -> u16 { return msgSend(u16, self, "unsignedShortValue") } +@(objc_type=Number, objc_name="i32Value") Number_i32Value :: proc "c" (self: ^Number) -> i32 { return msgSend(i32, self, "intValue") } +@(objc_type=Number, objc_name="u32Value") Number_u32Value :: proc "c" (self: ^Number) -> u32 { return msgSend(u32, self, "unsignedIntValue") } +@(objc_type=Number, objc_name="intValue") Number_intValue :: proc "c" (self: ^Number) -> int { return msgSend(int, self, "longValue") } +@(objc_type=Number, objc_name="uintValue") Number_uintValue :: proc "c" (self: ^Number) -> uint { return msgSend(uint, self, "unsignedLongValue") } +@(objc_type=Number, objc_name="u64Value") Number_u64Value :: proc "c" (self: ^Number) -> u64 { return msgSend(u64, self, "longLongValue") } +@(objc_type=Number, objc_name="i64Value") Number_i64Value :: proc "c" (self: ^Number) -> i64 { return msgSend(i64, self, "unsignedLongLongValue") } +@(objc_type=Number, objc_name="f32Value") Number_f32Value :: proc "c" (self: ^Number) -> f32 { return msgSend(f32, self, "floatValue") } +@(objc_type=Number, objc_name="f64Value") Number_f64Value :: proc "c" (self: ^Number) -> f64 { return msgSend(f64, self, "doubleValue") } +@(objc_type=Number, objc_name="boolValue") Number_boolValue :: proc "c" (self: ^Number) -> BOOL { return msgSend(BOOL, self, "boolValue") } +@(objc_type=Number, objc_name="integerValue") Number_integerValue :: proc "c" (self: ^Number) -> Integer { return msgSend(Integer, self, "integerValue") } +@(objc_type=Number, objc_name="uintegerValue") Number_uintegerValue :: proc "c" (self: ^Number) -> UInteger { return msgSend(UInteger, self, "unsignedIntegerValue") } +@(objc_type=Number, objc_name="stringValue") Number_stringValue :: proc "c" (self: ^Number) -> ^String { return msgSend(^String, self, "stringValue") } @(objc_type=Number, objc_name="compare") -Number_compare :: proc(self, other: ^Number) -> ComparisonResult { +Number_compare :: proc "c" (self, other: ^Number) -> ComparisonResult { return msgSend(ComparisonResult, self, "compare:", other) } @(objc_type=Number, objc_name="isEqualToNumber") -Number_isEqualToNumber :: proc(self, other: ^Number) -> BOOL { +Number_isEqualToNumber :: proc "c" (self, other: ^Number) -> BOOL { return msgSend(BOOL, self, "isEqualToNumber:", other) } @(objc_type=Number, objc_name="descriptionWithLocale") -Number_descriptionWithLocale :: proc(self: ^Number, locale: ^Object) -> ^String { +Number_descriptionWithLocale :: proc "c" (self: ^Number, locale: ^Object) -> ^String { return msgSend(^String, self, "descriptionWithLocale:", locale) } \ No newline at end of file diff --git a/vendor/darwin/Foundation/NSObject.odin b/vendor/darwin/Foundation/NSObject.odin index 6ec5939ee..fdcf05880 100644 --- a/vendor/darwin/Foundation/NSObject.odin +++ b/vendor/darwin/Foundation/NSObject.odin @@ -21,67 +21,67 @@ Object :: struct {using _: intrinsics.objc_object} @(objc_class="NSObject") Copying :: struct($T: typeid) {using _: Object} -alloc :: proc($T: typeid) -> ^T where intrinsics.type_is_subtype_of(T, Object) { +alloc :: proc "c" ($T: typeid) -> ^T where intrinsics.type_is_subtype_of(T, Object) { return msgSend(^T, T, "alloc") } @(objc_type=Object, objc_name="init") -init :: proc(self: ^$T) -> ^T where intrinsics.type_is_subtype_of(T, Object) { +init :: proc "c" (self: ^$T) -> ^T where intrinsics.type_is_subtype_of(T, Object) { return msgSend(^T, self, "init") } @(objc_type=Object, objc_name="copy") -copy :: proc(self: ^Copying($T)) -> ^T where intrinsics.type_is_subtype_of(T, Object) { +copy :: proc "c" (self: ^Copying($T)) -> ^T where intrinsics.type_is_subtype_of(T, Object) { return msgSend(^T, self, "copy") } -new :: proc($T: typeid) -> ^T where intrinsics.type_is_subtype_of(T, Object) { +new :: proc "c" ($T: typeid) -> ^T where intrinsics.type_is_subtype_of(T, Object) { return init(alloc(T)) } @(objc_type=Object, objc_name="retain") -retain :: proc(self: ^Object) { +retain :: proc "c" (self: ^Object) { _ = msgSend(^Object, self, "retain") } @(objc_type=Object, objc_name="release") -release :: proc(self: ^Object) { +release :: proc "c" (self: ^Object) { msgSend(nil, self, "release") } @(objc_type=Object, objc_name="autorelease") -autorelease :: proc(self: ^Object) { +autorelease :: proc "c" (self: ^Object) { msgSend(nil, self, "autorelease") } @(objc_type=Object, objc_name="retainCount") -retainCount :: proc(self: ^Object) -> UInteger { +retainCount :: proc "c" (self: ^Object) -> UInteger { return msgSend(UInteger, self, "retainCount") } @(objc_type=Object, objc_name="class") -class :: proc(self: ^Object) -> Class { +class :: proc "c" (self: ^Object) -> Class { return msgSend(Class, self, "class") } @(objc_type=Object, objc_name="hash") -hash :: proc(self: ^Object) -> UInteger { +hash :: proc "c" (self: ^Object) -> UInteger { return msgSend(UInteger, self, "hash") } @(objc_type=Object, objc_name="isEqual") -isEqual :: proc(self, pObject: ^Object) -> BOOL { +isEqual :: proc "c" (self, pObject: ^Object) -> BOOL { return msgSend(BOOL, self, "isEqual:", pObject) } @(objc_type=Object, objc_name="description") -description :: proc(self: ^Object) -> ^String { +description :: proc "c" (self: ^Object) -> ^String { return msgSend(^String, self, "description") } @(objc_type=Object, objc_name="debugDescription") -debugDescription :: proc(self: ^Object) -> ^String { +debugDescription :: proc "c" (self: ^Object) -> ^String { if msgSendSafeCheck(self, intrinsics.objc_find_selector("debugDescription")) { return msgSend(^String, self, "debugDescription") } return nil } -bridgingCast :: proc($T: typeid, obj: ^Object) where intrinsics.type_is_pointer(T), intrinsics.type_is_subtype_of(T, ^Object) { +bridgingCast :: proc "c" ($T: typeid, obj: ^Object) where intrinsics.type_is_pointer(T), intrinsics.type_is_subtype_of(T, ^Object) { return (T)(obj) } diff --git a/vendor/darwin/Foundation/NSOpenPanel.odin b/vendor/darwin/Foundation/NSOpenPanel.odin new file mode 100644 index 000000000..ac5f9674e --- /dev/null +++ b/vendor/darwin/Foundation/NSOpenPanel.odin @@ -0,0 +1,31 @@ +package objc_Foundation + +@(objc_class="NSOpenPanel") +OpenPanel :: struct{ using _: SavePanel } + +@(objc_type=OpenPanel, objc_name="openPanel", objc_is_class_method=true) +OpenPanel_openPanel :: proc "c" () -> ^OpenPanel { + return msgSend(^OpenPanel, OpenPanel, "openPanel") +} + +@(objc_type=OpenPanel, objc_name="URLs") +OpenPanel_URLs :: proc "c" (self: ^OpenPanel) -> ^Array { + return msgSend(^Array, self, "URLs") +} + +@(objc_type=OpenPanel, objc_name="setCanChooseFiles") +OpenPanel_setCanChooseFiles :: proc "c" (self: ^OpenPanel, setting: BOOL) { + msgSend(nil, self, "setCanChooseFiles:", setting) +} +@(objc_type=OpenPanel, objc_name="setCanChooseDirectories") +OpenPanel_setCanChooseDirectories :: proc "c" (self: ^OpenPanel, setting: BOOL) { + msgSend(nil, self, "setCanChooseDirectories:", setting) +} +@(objc_type=OpenPanel, objc_name="setResolvesAliases") +OpenPanel_setResolvesAliases :: proc "c" (self: ^OpenPanel, setting: BOOL) { + msgSend(nil, self, "setResolvesAliases:", setting) +} +@(objc_type=OpenPanel, objc_name="setAllowsMultipleSelection") +OpenPanel_setAllowsMultipleSelection :: proc "c" (self: ^OpenPanel, setting: BOOL) { + msgSend(nil, self, "setAllowsMultipleSelection:", setting) +} diff --git a/vendor/darwin/Foundation/NSPanel.odin b/vendor/darwin/Foundation/NSPanel.odin new file mode 100644 index 000000000..4bdf08cdb --- /dev/null +++ b/vendor/darwin/Foundation/NSPanel.odin @@ -0,0 +1,9 @@ +package objc_Foundation + +ModalResponse :: enum UInteger { + Cancel = 0, + OK = 1, +} + +@(objc_class="NSPanel") +Panel :: struct{ using _: Window } diff --git a/vendor/darwin/Foundation/NSPasteboard.odin b/vendor/darwin/Foundation/NSPasteboard.odin new file mode 100644 index 000000000..74cf7d172 --- /dev/null +++ b/vendor/darwin/Foundation/NSPasteboard.odin @@ -0,0 +1,5 @@ +package objc_Foundation + +@(objc_class="NSPasteboard") +Pasteboard :: struct {using _: Object} +// TODO: implement NSPasteboard diff --git a/vendor/darwin/Foundation/NSRange.odin b/vendor/darwin/Foundation/NSRange.odin index 74ce595a3..dcb100e91 100644 --- a/vendor/darwin/Foundation/NSRange.odin +++ b/vendor/darwin/Foundation/NSRange.odin @@ -5,18 +5,18 @@ Range :: struct { length: UInteger, } -Range_Make :: proc(loc, len: UInteger) -> Range { +Range_Make :: proc "c" (loc, len: UInteger) -> Range { return Range{loc, len} } -Range_Equal :: proc(a, b: Range) -> BOOL { +Range_Equal :: proc "c" (a, b: Range) -> BOOL { return a == b } -Range_LocationInRange :: proc(self: Range, loc: UInteger) -> BOOL { +Range_LocationInRange :: proc "c" (self: Range, loc: UInteger) -> BOOL { return !((loc < self.location) && ((loc - self.location) < self.length)) } -Range_Max :: proc(self: Range) -> UInteger { +Range_Max :: proc "c" (self: Range) -> UInteger { return self.location + self.length } \ No newline at end of file diff --git a/vendor/darwin/Foundation/NSSavePanel.odin b/vendor/darwin/Foundation/NSSavePanel.odin new file mode 100644 index 000000000..8e4d7a07b --- /dev/null +++ b/vendor/darwin/Foundation/NSSavePanel.odin @@ -0,0 +1,9 @@ +package objc_Foundation + +@(objc_class="NSSavePanel") +SavePanel :: struct{ using _: Panel } + +@(objc_type=SavePanel, objc_name="runModal") +SavePanel_runModal :: proc "c" (self: ^SavePanel) -> ModalResponse { + return msgSend(ModalResponse, self, "runModal") +} diff --git a/vendor/darwin/Foundation/NSScreen.odin b/vendor/darwin/Foundation/NSScreen.odin new file mode 100644 index 000000000..f1f7b84b8 --- /dev/null +++ b/vendor/darwin/Foundation/NSScreen.odin @@ -0,0 +1,5 @@ +package objc_Foundation + +@(objc_class="NSScreen") +Screen :: struct {using _: Object} +// TODO: implement NSScreen diff --git a/vendor/darwin/Foundation/NSString.odin b/vendor/darwin/Foundation/NSString.odin index 18e392415..d3c6c454d 100644 --- a/vendor/darwin/Foundation/NSString.odin +++ b/vendor/darwin/Foundation/NSString.odin @@ -64,77 +64,77 @@ MakeConstantString :: proc "c" (#const c: cstring) -> ^String { @(objc_type=String, objc_name="alloc", objc_is_class_method=true) -String_alloc :: proc() -> ^String { +String_alloc :: proc "c" () -> ^String { return msgSend(^String, String, "alloc") } @(objc_type=String, objc_name="init") -String_init :: proc(self: ^String) -> ^String { +String_init :: proc "c" (self: ^String) -> ^String { return msgSend(^String, self, "init") } @(objc_type=String, objc_name="initWithString") -String_initWithString :: proc(self: ^String, other: ^String) -> ^String { +String_initWithString :: proc "c" (self: ^String, other: ^String) -> ^String { return msgSend(^String, self, "initWithString:", other) } @(objc_type=String, objc_name="initWithCString") -String_initWithCString :: proc(self: ^String, pString: cstring, encoding: StringEncoding) -> ^String { +String_initWithCString :: proc "c" (self: ^String, pString: cstring, encoding: StringEncoding) -> ^String { return msgSend(^String, self, "initWithCstring:encoding:", pString, encoding) } @(objc_type=String, objc_name="initWithBytesNoCopy") -String_initWithBytesNoCopy :: proc(self: ^String, pBytes: rawptr, length: UInteger, encoding: StringEncoding, freeWhenDone: bool) -> ^String { +String_initWithBytesNoCopy :: proc "c" (self: ^String, pBytes: rawptr, length: UInteger, encoding: StringEncoding, freeWhenDone: bool) -> ^String { return msgSend(^String, self, "initWithBytesNoCopy:length:encoding:freeWhenDone:", pBytes, length, encoding, freeWhenDone) } @(objc_type=String, objc_name="initWithOdinString") -String_initWithOdinString :: proc(self: ^String, str: string) -> ^String { +String_initWithOdinString :: proc "c" (self: ^String, str: string) -> ^String { return String_initWithBytesNoCopy(self, raw_data(str), UInteger(len(str)), .UTF8, false) } @(objc_type=String, objc_name="characterAtIndex") -String_characterAtIndex :: proc(self: ^String, index: UInteger) -> unichar { +String_characterAtIndex :: proc "c" (self: ^String, index: UInteger) -> unichar { return msgSend(unichar, self, "characterAtIndex:", index) } @(objc_type=String, objc_name="length") -String_length :: proc(self: ^String) -> UInteger { +String_length :: proc "c" (self: ^String) -> UInteger { return msgSend(UInteger, self, "length") } @(objc_type=String, objc_name="cstringUsingEncoding") -String_cstringUsingEncoding :: proc(self: ^String, encoding: StringEncoding) -> cstring { +String_cstringUsingEncoding :: proc "c" (self: ^String, encoding: StringEncoding) -> cstring { return msgSend(cstring, self, "cStringUsingEncoding:", encoding) } @(objc_type=String, objc_name="UTF8String") -String_UTF8String :: proc(self: ^String) -> cstring { +String_UTF8String :: proc "c" (self: ^String) -> cstring { return msgSend(cstring, self, "UTF8String") } @(objc_type=String, objc_name="odinString") -String_odinString :: proc(self: ^String) -> string { +String_odinString :: proc "c" (self: ^String) -> string { return string(String_UTF8String(self)) } @(objc_type=String, objc_name="maximumLengthOfBytesUsingEncoding") -String_maximumLengthOfBytesUsingEncoding :: proc(self: ^String, encoding: StringEncoding) -> UInteger { +String_maximumLengthOfBytesUsingEncoding :: proc "c" (self: ^String, encoding: StringEncoding) -> UInteger { return msgSend(UInteger, self, "maximumLengthOfBytesUsingEncoding:", encoding) } @(objc_type=String, objc_name="lengthOfBytesUsingEncoding") -String_lengthOfBytesUsingEncoding :: proc(self: ^String, encoding: StringEncoding) -> UInteger { +String_lengthOfBytesUsingEncoding :: proc "c" (self: ^String, encoding: StringEncoding) -> UInteger { return msgSend(UInteger, self, "lengthOfBytesUsingEncoding:", encoding) } @(objc_type=String, objc_name="isEqualToString") -String_isEqualToString :: proc(self, other: ^String) -> BOOL { +String_isEqualToString :: proc "c" (self, other: ^String) -> BOOL { return msgSend(BOOL, self, "isEqualToString:", other) } @(objc_type=String, objc_name="rangeOfString") -String_rangeOfString :: proc(self, other: ^String, options: StringCompareOptions) -> Range { +String_rangeOfString :: proc "c" (self, other: ^String, options: StringCompareOptions) -> Range { return msgSend(Range, self, "rangeOfString:options:", other, options) } \ No newline at end of file diff --git a/vendor/darwin/Foundation/NSTypes.odin b/vendor/darwin/Foundation/NSTypes.odin index 0c1239710..671832a2d 100644 --- a/vendor/darwin/Foundation/NSTypes.odin +++ b/vendor/darwin/Foundation/NSTypes.odin @@ -45,3 +45,17 @@ Size :: struct { width: Float, height: Float, } + +when size_of(UInteger) == 8 { + _UINTEGER_ENCODING :: "Q" +} else { + _UINTEGER_ENCODING :: "I" +} + +when size_of(Float) == 8 { + _POINT_ENCODING :: "{CGPoint=dd}" + _SIZE_ENCODING :: "{CGSize=dd}" +} else { + _POINT_ENCODING :: "{NSPoint=ff}" + _SIZE_ENCODING :: "{NSSize=ff}" +} \ No newline at end of file diff --git a/vendor/darwin/Foundation/NSURL.odin b/vendor/darwin/Foundation/NSURL.odin index 72e5fc906..9e9081219 100644 --- a/vendor/darwin/Foundation/NSURL.odin +++ b/vendor/darwin/Foundation/NSURL.odin @@ -5,26 +5,26 @@ URL :: struct{using _: Copying(URL)} @(objc_type=URL, objc_name="alloc", objc_is_class_method=true) -URL_alloc :: proc() -> ^URL { +URL_alloc :: proc "c" () -> ^URL { return msgSend(^URL, URL, "alloc") } @(objc_type=URL, objc_name="init") -URL_init :: proc(self: ^URL) -> ^URL { +URL_init :: proc "c" (self: ^URL) -> ^URL { return msgSend(^URL, self, "init") } @(objc_type=URL, objc_name="initWithString") -URL_initWithString :: proc(self: ^URL, value: ^String) -> ^URL { +URL_initWithString :: proc "c" (self: ^URL, value: ^String) -> ^URL { return msgSend(^URL, self, "initWithString:", value) } @(objc_type=URL, objc_name="initFileURLWithPath") -URL_initFileURLWithPath :: proc(self: ^URL, path: ^String) -> ^URL { +URL_initFileURLWithPath :: proc "c" (self: ^URL, path: ^String) -> ^URL { return msgSend(^URL, self, "initFileURLWithPath:", path) } @(objc_type=URL, objc_name="fileSystemRepresentation") -URL_fileSystemRepresentation :: proc(self: ^URL) -> ^String { - return msgSend(^String, self, "fileSystemRepresentation") -} \ No newline at end of file +URL_fileSystemRepresentation :: proc "c" (self: ^URL) -> cstring { + return msgSend(cstring, self, "fileSystemRepresentation") +} diff --git a/vendor/darwin/Foundation/NSUndoManager.odin b/vendor/darwin/Foundation/NSUndoManager.odin new file mode 100644 index 000000000..16411dcb4 --- /dev/null +++ b/vendor/darwin/Foundation/NSUndoManager.odin @@ -0,0 +1,5 @@ +package objc_Foundation + +@(objc_class="NSUndoManager") +UndoManager :: struct {using _: Object} +// TODO: implement NSUndoManager diff --git a/vendor/darwin/Foundation/NSUserActivity.odin b/vendor/darwin/Foundation/NSUserActivity.odin new file mode 100644 index 000000000..3b2f956ee --- /dev/null +++ b/vendor/darwin/Foundation/NSUserActivity.odin @@ -0,0 +1,5 @@ +package objc_Foundation + +@(objc_class="NSUserActivity") +UserActivity :: struct {using _: Object} +// TODO: implement NSUserActivity diff --git a/vendor/darwin/Foundation/NSUserDefaults.odin b/vendor/darwin/Foundation/NSUserDefaults.odin new file mode 100644 index 000000000..a8a6d7545 --- /dev/null +++ b/vendor/darwin/Foundation/NSUserDefaults.odin @@ -0,0 +1,14 @@ +package objc_Foundation + +@(objc_class="NSUserDefaults") +UserDefaults :: struct { using _: Object } + +@(objc_type=UserDefaults, objc_name="standardUserDefaults", objc_is_class_method=true) +UserDefaults_standardUserDefaults :: proc "c" () -> ^UserDefaults { + return msgSend(^UserDefaults, UserDefaults, "standardUserDefaults") +} + +@(objc_type=UserDefaults, objc_name="setBoolForKey") +UserDefaults_setBoolForKey :: proc "c" (self: ^UserDefaults, value: BOOL, name: ^String) { + msgSend(nil, self, "setBool:forKey:", value, name) +} diff --git a/vendor/darwin/Foundation/NSWindow.odin b/vendor/darwin/Foundation/NSWindow.odin index f164a474a..0a7382921 100644 --- a/vendor/darwin/Foundation/NSWindow.odin +++ b/vendor/darwin/Foundation/NSWindow.odin @@ -1,5 +1,8 @@ package objc_Foundation +import "core:strings" +import "core:runtime" +import "core:intrinsics" import NS "vendor:darwin/Foundation" Rect :: struct { @@ -7,6 +10,12 @@ Rect :: struct { using size: Size, } +when size_of(Float) == 8 { + _RECT_ENCODING :: "{CGRect="+_POINT_ENCODING+_SIZE_ENCODING+"}" +} else { + _RECT_ENCODING :: "{NSRect="+_POINT_ENCODING+_SIZE_ENCODING+"}" +} + WindowStyleFlag :: enum NS.UInteger { Titled = 0, Closable = 1, @@ -42,6 +51,510 @@ BackingStoreType :: enum NS.UInteger { Buffered = 2, } +WindowDelegateTemplate :: struct { + // Managing Sheets + windowWillPositionSheetUsingRect: proc(window: ^Window, sheet: ^Window, rect: Rect) -> Rect, + windowWillBeginSheet: proc(notification: ^Notification), + windowDidEndSheet: proc(notification: ^Notification), + // Sizing Windows + windowWillResizeToSize: proc(sender: ^Window, frameSize: Size) -> Size, + windowDidResize: proc(notification: ^Notification), + windowWillStartLiveResize: proc(noitifcation: ^Notification), + windowDidEndLiveResize: proc(notification: ^Notification), + // Minimizing Windows + windowWillMiniaturize: proc(notification: ^Notification), + windowDidMiniaturize: proc(notification: ^Notification), + windowDidDeminiaturize: proc(notification: ^Notification), + // Zooming window + windowWillUseStandardFrameDefaultFrame: proc(window: ^Window, newFrame: Rect) -> Rect, + windowShouldZoomToFrame: proc(window: ^Window, newFrame: Rect) -> BOOL, + // Managing Full-Screen Presentation + windowWillUseFullScreenContentSize: proc(window: ^Window, proposedSize: Size) -> Size, + windowWillUseFullScreenPresentationOptions: proc(window: ^Window, proposedOptions: ApplicationPresentationOptions) -> ApplicationPresentationOptions, + windowWillEnterFullScreen: proc(notification: ^Notification), + windowDidEnterFullScreen: proc(notification: ^Notification), + windowWillExitFullScreen: proc(notification: ^Notification), + windowDidExitFullScreen: proc(notification: ^Notification), + // Custom Full-Screen Presentation Animations + customWindowsToEnterFullScreenForWindow: proc(window: ^Window) -> ^Array, + customWindowsToEnterFullScreenForWindowOnScreen: proc(window: ^Window, screen: ^Screen) -> ^Array, + windowStartCustomAnimationToEnterFullScreenWithDuration: proc(window: ^Window, duration: TimeInterval), + windowStartCustomAnimationToEnterFullScreenOnScreenWithDuration: proc(window: ^Window, screen: ^Screen, duration: TimeInterval), + windowDidFailToEnterFullScreen: proc(window: ^Window), + customWindowsToExitFullScreenForWindow: proc(window: ^Window) -> ^Array, + windowStartCustomAnimationToExitFullScreenWithDuration: proc(window: ^Window, duration: TimeInterval), + windowDidFailToExitFullScreen: proc(window: ^Window), + // Moving Windows + windowWillMove: proc(notification: ^Notification), + windowDidMove: proc(notification: ^Notification), + windowDidChangeScreen: proc(notification: ^Notification), + windowDidChangeScreenProfile: proc(notification: ^Notification), + windowDidChangeBackingProperties: proc(notification: ^Notification), + // Closing Windows + windowShouldClose: proc(sender: ^Window) -> BOOL, + windowWillClose: proc(notification: ^Notification), + // Managing Key Status + windowDidBecomeKey: proc(notification: ^Notification), + windowDidResignKey: proc(notification: ^Notification), + // Managing Main Status + windowDidBecomeMain: proc(notification: ^Notification), + windowDidResignMain: proc(notification: ^Notification), + // Managing Field Editors + windowWillReturnFieldEditorToObject: proc(sender: ^Window, client: id) -> id, + // Updating Windows + windowDidUpdate: proc (notification: ^Notification), + // Exposing Windows + windowDidExpose: proc (notification: ^Notification), + // Managing Occlusion State + windowDidChangeOcclusionState: proc(notification: ^Notification), + // Dragging Windows + windowShouldDragDocumentWithEventFromWithPasteboard: proc(window: ^Window, event: ^Event, dragImageLocation: Point, pasteboard: ^Pasteboard) -> BOOL, + // Getting the Undo Manager + windowWillReturnUndoManager: proc(window: ^Window) -> ^UndoManager, + // Managing Titles + windowShouldPopUpDocumentPathMenu: proc(window: ^Window, menu: ^Menu) -> BOOL, + // Managing Restorable State + windowWillEncodeRestorableState: proc(window: ^Window, state: ^Coder), + windowDidEncodeRestorableState: proc(window: ^Window, state: ^Coder), + // Managing Presentation in Version Browsers + windowWillResizeForVersionBrowserWithMaxPreferredSizeMaxAllowedSize: proc(window: ^Window, maxPreferredFrameSize: Size, maxAllowedFrameSize: Size) -> Size, + windowWillEnterVersionBrowser: proc(notification: ^Notification), + windowDidEnterVersionBrowser: proc(notification: ^Notification), + windowWillExitVersionBrowser: proc(notification: ^Notification), + windowDidExitVersionBrowser: proc(notification: ^Notification), +} + +WindowDelegate :: struct { using _: Object } +_WindowDelegateInternal :: struct { + using _: WindowDelegateTemplate, + _context: runtime.Context, +} + +window_delegate_register_and_alloc :: proc(template: WindowDelegateTemplate, class_name: string, delegate_context: Maybe(runtime.Context)) -> ^WindowDelegate { + class := objc_allocateClassPair(intrinsics.objc_find_class("NSObject"), strings.clone_to_cstring(class_name, context.temp_allocator), 0); if class == nil { + // Class already registered + return nil + } + if template.windowWillPositionSheetUsingRect != nil { + windowWillPositionSheetUsingRect :: proc "c" (self: id, window: ^Window, sheet: ^Window, rect: Rect) -> Rect { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + return del.windowWillPositionSheetUsingRect(window, sheet, rect) + } + class_addMethod(class, intrinsics.objc_find_selector("window:willPositionSheet:usingRect:"), auto_cast windowWillPositionSheetUsingRect, _RECT_ENCODING+"@:@@"+_RECT_ENCODING) + } + if template.windowWillBeginSheet != nil { + windowWillBeginSheet :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.windowWillBeginSheet(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("windowWillBeginSheet:"), auto_cast windowWillBeginSheet, "v@:@") + } + if template.windowDidEndSheet != nil { + windowDidEndSheet :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.windowDidEndSheet(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("windowDidEndSheet:"), auto_cast windowDidEndSheet, "v@:@") + } + if template.windowWillResizeToSize != nil { + windowWillResizeToSize :: proc "c" (self: id, sender: ^Window, frameSize: Size) -> Size { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + return del.windowWillResizeToSize(sender, frameSize) + } + class_addMethod(class, intrinsics.objc_find_selector("windowWillResize:toSize:"), auto_cast windowWillResizeToSize, _SIZE_ENCODING+"@:@"+_SIZE_ENCODING) + } + if template.windowDidResize != nil { + windowDidResize :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.windowDidResize(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("windowDidResize:"), auto_cast windowDidResize, "v@:@") + } + if template.windowWillStartLiveResize != nil { + windowWillStartLiveResize :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.windowWillStartLiveResize(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("windowWillStartLiveResize:"), auto_cast windowWillStartLiveResize, "v@:@") + } + if template.windowDidEndLiveResize != nil { + windowDidEndLiveResize :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.windowDidEndLiveResize(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("windowDidEndLiveResize:"), auto_cast windowDidEndLiveResize, "v@:@") + } + if template.windowWillMiniaturize != nil { + windowWillMiniaturize :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.windowWillMiniaturize(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("windowWillMiniaturize:"), auto_cast windowWillMiniaturize, "v@:@") + } + if template.windowDidMiniaturize != nil { + windowDidMiniaturize :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.windowDidMiniaturize(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("windowDidMiniaturize:"), auto_cast windowDidMiniaturize, "v@:@") + } + if template.windowDidDeminiaturize != nil { + windowDidDeminiaturize :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.windowDidDeminiaturize(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("windowDidDeminiaturize:"), auto_cast windowDidDeminiaturize, "v@:@") + } + if template.windowWillUseStandardFrameDefaultFrame != nil { + windowWillUseStandardFrameDefaultFrame :: proc(self: id, window: ^Window, newFrame: Rect) -> Rect { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + return del.windowWillUseStandardFrameDefaultFrame(window, newFrame) + } + class_addMethod(class, intrinsics.objc_find_selector("windowWillUseStandardFrame:defaultFrame:"), auto_cast windowWillUseStandardFrameDefaultFrame, _RECT_ENCODING+"@:@"+_RECT_ENCODING) + } + if template.windowShouldZoomToFrame != nil { + windowShouldZoomToFrame :: proc "c" (self: id, window: ^Window, newFrame: Rect) -> BOOL { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + return del.windowShouldZoomToFrame(window, newFrame) + } + class_addMethod(class, intrinsics.objc_find_selector("windowShouldZoom:toFrame:"), auto_cast windowShouldZoomToFrame, "B@:@"+_RECT_ENCODING) + } + if template.windowWillUseFullScreenContentSize != nil { + windowWillUseFullScreenContentSize :: proc "c" (self: id, window: ^Window, proposedSize: Size) -> Size { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + return del.windowWillUseFullScreenContentSize(window, proposedSize) + } + class_addMethod(class, intrinsics.objc_find_selector("window:willUseFullScreenContentSize:"), auto_cast windowWillUseFullScreenContentSize, _SIZE_ENCODING+"@:@"+_SIZE_ENCODING) + } + if template.windowWillUseFullScreenPresentationOptions != nil { + windowWillUseFullScreenPresentationOptions :: proc(self: id, window: ^Window, proposedOptions: ApplicationPresentationOptions) -> ApplicationPresentationOptions { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + return del.windowWillUseFullScreenPresentationOptions(window, proposedOptions) + } + class_addMethod(class, intrinsics.objc_find_selector("window:willUseFullScreenPresentationOptions:"), auto_cast windowWillUseFullScreenPresentationOptions, _UINTEGER_ENCODING+"@:@"+_UINTEGER_ENCODING) + } + if template.windowWillEnterFullScreen != nil { + windowWillEnterFullScreen :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.windowWillEnterFullScreen(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("windowWillEnterFullScreen:"), auto_cast windowWillEnterFullScreen, "v@:@") + } + if template.windowDidEnterFullScreen != nil { + windowDidEnterFullScreen :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.windowDidEnterFullScreen(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("windowDidEnterFullScreen:"), auto_cast windowDidEnterFullScreen, "v@:@") + } + if template.windowWillExitFullScreen != nil { + windowWillExitFullScreen :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.windowWillExitFullScreen(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("windowWillExitFullScreen:"), auto_cast windowWillExitFullScreen, "v@:@") + } + if template.windowDidExitFullScreen != nil { + windowDidExitFullScreen :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.windowDidExitFullScreen(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("windowDidExitFullScreen:"), auto_cast windowDidExitFullScreen, "v@:@") + } + if template.customWindowsToEnterFullScreenForWindow != nil { + customWindowsToEnterFullScreenForWindow :: proc "c" (self: id, window: ^Window) -> ^Array { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + return del.customWindowsToEnterFullScreenForWindow(window) + } + class_addMethod(class, intrinsics.objc_find_selector("customWindowsToEnterFullScreenForWindow:"), auto_cast customWindowsToEnterFullScreenForWindow, "@@:@") + } + if template.customWindowsToEnterFullScreenForWindowOnScreen != nil { + customWindowsToEnterFullScreenForWindowOnScreen :: proc(self: id, window: ^Window, screen: ^Screen) -> ^Array { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + return del.customWindowsToEnterFullScreenForWindowOnScreen(window, screen) + } + class_addMethod(class, intrinsics.objc_find_selector("customWindowsToEnterFullScreenForWindow:onScreen:"), auto_cast customWindowsToEnterFullScreenForWindowOnScreen, "@@:@@") + } + if template.windowStartCustomAnimationToEnterFullScreenWithDuration != nil { + windowStartCustomAnimationToEnterFullScreenWithDuration :: proc "c" (self: id, window: ^Window, duration: TimeInterval) { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.windowStartCustomAnimationToEnterFullScreenWithDuration(window, duration) + } + class_addMethod(class, intrinsics.objc_find_selector("window:startCustomAnimationToEnterFullScreenWithDuration:"), auto_cast windowStartCustomAnimationToEnterFullScreenWithDuration, "v@:@@") + } + if template.windowStartCustomAnimationToEnterFullScreenOnScreenWithDuration != nil { + windowStartCustomAnimationToEnterFullScreenOnScreenWithDuration :: proc(self: id, window: ^Window, screen: ^Screen, duration: TimeInterval) { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.windowStartCustomAnimationToEnterFullScreenOnScreenWithDuration(window, screen, duration) + } + class_addMethod(class, intrinsics.objc_find_selector("window:startCustomAnimationToEnterFullScreenOnScreen:withDuration:"), auto_cast windowStartCustomAnimationToEnterFullScreenOnScreenWithDuration, "v@:@@d") + } + if template.windowDidFailToEnterFullScreen != nil { + windowDidFailToEnterFullScreen :: proc "c" (self: id, window: ^Window) { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.windowDidFailToEnterFullScreen(window) + } + class_addMethod(class, intrinsics.objc_find_selector("windowDidFailToEnterFullScreen:"), auto_cast windowDidFailToEnterFullScreen, "v@:@") + } + if template.customWindowsToExitFullScreenForWindow != nil { + customWindowsToExitFullScreenForWindow :: proc "c" (self: id, window: ^Window) -> ^Array { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + return del.customWindowsToExitFullScreenForWindow(window) + } + class_addMethod(class, intrinsics.objc_find_selector("customWindowsToExitFullScreenForWindow:"), auto_cast customWindowsToExitFullScreenForWindow, "@@:@") + } + if template.windowStartCustomAnimationToExitFullScreenWithDuration != nil { + windowStartCustomAnimationToExitFullScreenWithDuration :: proc "c" (self: id, window: ^Window, duration: TimeInterval) { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.windowStartCustomAnimationToExitFullScreenWithDuration(window, duration) + } + class_addMethod(class, intrinsics.objc_find_selector("window:startCustomAnimationToExitFullScreenWithDuration:"), auto_cast windowStartCustomAnimationToExitFullScreenWithDuration, "v@:@d") + } + if template.windowDidFailToExitFullScreen != nil { + windowDidFailToExitFullScreen :: proc "c" (self: id, window: ^Window) { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.windowDidFailToExitFullScreen(window) + } + class_addMethod(class, intrinsics.objc_find_selector("windowDidFailToExitFullScreen:"), auto_cast windowDidFailToExitFullScreen, "v@:@") + } + if template.windowWillMove != nil { + windowWillMove :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.windowWillMove(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("windowWillMove:"), auto_cast windowWillMove, "v@:@") + } + if template.windowDidMove != nil { + windowDidMove :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.windowDidMove(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("windowDidMove:"), auto_cast windowDidMove, "v@:@") + } + if template.windowDidChangeScreen != nil { + windowDidChangeScreen :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.windowDidChangeScreen(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("windowDidChangeScreen:"), auto_cast windowDidChangeScreen, "v@:@") + } + if template.windowDidChangeScreenProfile != nil { + windowDidChangeScreenProfile :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.windowDidChangeScreenProfile(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("windowDidChangeScreenProfile:"), auto_cast windowDidChangeScreenProfile, "v@:@") + } + if template.windowDidChangeBackingProperties != nil { + windowDidChangeBackingProperties :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.windowDidChangeBackingProperties(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("windowDidChangeBackingProperties:"), auto_cast windowDidChangeBackingProperties, "v@:@") + } + if template.windowShouldClose != nil { + windowShouldClose :: proc "c" (self:id, sender: ^Window) -> BOOL { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + return del.windowShouldClose(sender) + } + class_addMethod(class, intrinsics.objc_find_selector("windowShouldClose:"), auto_cast windowShouldClose, "B@:@") + } + if template.windowWillClose != nil { + windowWillClose :: proc "c" (self:id, notification: ^Notification) { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.windowWillClose(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("windowWillClose:"), auto_cast windowWillClose, "v@:@") + } + if template.windowDidBecomeKey != nil { + windowDidBecomeKey :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.windowDidBecomeKey(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("windowDidBecomeKey:"), auto_cast windowDidBecomeKey, "v@:@") + } + if template.windowDidResignKey != nil { + windowDidResignKey :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.windowDidResignKey(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("windowDidResignKey:"), auto_cast windowDidResignKey, "v@:@") + } + if template.windowDidBecomeMain != nil { + windowDidBecomeMain :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.windowDidBecomeMain(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("windowDidBecomeMain:"), auto_cast windowDidBecomeMain, "v@:@") + } + if template.windowDidResignMain != nil { + windowDidResignMain :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.windowDidResignMain(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("windowDidResignMain:"), auto_cast windowDidResignMain, "v@:@") + } + if template.windowWillReturnFieldEditorToObject != nil { + windowWillReturnFieldEditorToObject :: proc "c" (self:id, sender: ^Window, client: id) -> id { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + return del.windowWillReturnFieldEditorToObject(sender, client) + } + class_addMethod(class, intrinsics.objc_find_selector("windowWillReturnFieldEditor:toObject:"), auto_cast windowWillReturnFieldEditorToObject, "@@:@@") + } + if template.windowDidUpdate != nil { + windowDidUpdate :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.windowDidUpdate(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("windowDidUpdate:"), auto_cast windowDidUpdate, "v@:@") + } + if template.windowDidExpose != nil { + windowDidExpose :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.windowDidExpose(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("windowDidExpose:"), auto_cast windowDidExpose, "v@:@") + } + if template.windowDidChangeOcclusionState != nil { + windowDidChangeOcclusionState :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.windowDidChangeOcclusionState(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("windowDidChangeOcclusionState:"), auto_cast windowDidChangeOcclusionState, "v@:@") + } + if template.windowShouldDragDocumentWithEventFromWithPasteboard != nil { + windowShouldDragDocumentWithEventFromWithPasteboard :: proc "c" (self: id, window: ^Window, event: ^Event, dragImageLocation: Point, pasteboard: ^Pasteboard) -> BOOL { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + return del.windowShouldDragDocumentWithEventFromWithPasteboard(window, event, dragImageLocation, pasteboard) + } + class_addMethod(class, intrinsics.objc_find_selector("window:shouldDragDocumentWithEvent:from:withPasteboard:"), auto_cast windowShouldDragDocumentWithEventFromWithPasteboard, "B@:@@"+_POINT_ENCODING+"@") + } + if template.windowWillReturnUndoManager != nil { + windowWillReturnUndoManager :: proc "c" (self: id, window: ^Window) -> ^UndoManager { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + return del.windowWillReturnUndoManager(window) + } + class_addMethod(class, intrinsics.objc_find_selector("windowWillReturnUndoManager:"), auto_cast windowWillReturnUndoManager, "@@:@") + } + if template.windowShouldPopUpDocumentPathMenu != nil { + windowShouldPopUpDocumentPathMenu :: proc "c" (self: id, window: ^Window, menu: ^Menu) -> BOOL { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + return del.windowShouldPopUpDocumentPathMenu(window, menu) + } + class_addMethod(class, intrinsics.objc_find_selector("window:shouldPopUpDocumentPathMenu:"), auto_cast windowShouldPopUpDocumentPathMenu, "B@:@@") + } + if template.windowWillEncodeRestorableState != nil { + windowWillEncodeRestorableState :: proc "c" (self: id, window: ^Window, state: ^Coder) { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.windowWillEncodeRestorableState(window, state) + } + class_addMethod(class, intrinsics.objc_find_selector("window:willEncodeRestorableState:"), auto_cast windowWillEncodeRestorableState, "v@:@@") + } + if template.windowDidEncodeRestorableState != nil { + windowDidEncodeRestorableState :: proc "c" (self: id, window: ^Window, state: ^Coder) { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.windowDidEncodeRestorableState(window, state) + } + class_addMethod(class, intrinsics.objc_find_selector("window:didDecodeRestorableState:"), auto_cast windowDidEncodeRestorableState, "v@:@@") + } + if template.windowWillResizeForVersionBrowserWithMaxPreferredSizeMaxAllowedSize != nil { + windowWillResizeForVersionBrowserWithMaxPreferredSizeMaxAllowedSize :: proc "c" (self: id, window: ^Window, maxPreferredFrameSize: Size, maxAllowedFrameSize: Size) -> Size { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + return del.windowWillResizeForVersionBrowserWithMaxPreferredSizeMaxAllowedSize(window, maxPreferredFrameSize, maxPreferredFrameSize) + } + class_addMethod(class, intrinsics.objc_find_selector("window:willResizeForVersionBrowserWithMaxPreferredSize:maxAllowedSize:"), auto_cast windowWillResizeForVersionBrowserWithMaxPreferredSizeMaxAllowedSize, _SIZE_ENCODING+"@:@"+_SIZE_ENCODING+_SIZE_ENCODING) + } + if template.windowWillEnterVersionBrowser != nil { + windowWillEnterVersionBrowser :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.windowWillEnterVersionBrowser(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("windowWillEnterVersionBrowser:"), auto_cast windowWillEnterVersionBrowser, "v@:@") + } + if template.windowDidEnterVersionBrowser != nil { + windowDidEnterVersionBrowser :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.windowDidEnterVersionBrowser(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("windowDidEnterVersionBrowser:"), auto_cast windowDidEnterVersionBrowser, "v@:@") + } + if template.windowWillExitVersionBrowser != nil { + windowWillExitVersionBrowser :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.windowWillExitVersionBrowser(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("windowWillExitVersionBrowser:"), auto_cast windowWillExitVersionBrowser, "v@:@") + } + if template.windowDidExitVersionBrowser != nil { + windowDidExitVersionBrowser :: proc "c" (self: id, notification: ^Notification) { + del := cast(^_WindowDelegateInternal)object_getIndexedIvars(self) + context = del._context + del.windowDidExitVersionBrowser(notification) + } + class_addMethod(class, intrinsics.objc_find_selector("windowDidExitVersionBrowser:"), auto_cast windowDidExitVersionBrowser, "v@:@") + } + + objc_registerClassPair(class) + del := class_createInstance(class, size_of(_WindowDelegateInternal)) + del_internal := cast(^_WindowDelegateInternal)object_getIndexedIvars(del) + del_internal^ = { + template, + delegate_context.(runtime.Context) or_else runtime.default_context(), + } + + return cast(^WindowDelegate)del +} + @(objc_class="NSColor") Color :: struct {using _: Object} @@ -49,19 +562,19 @@ Color :: struct {using _: Object} Layer :: struct { using _: NS.Object } @(objc_type=Layer, objc_name="contentsScale") -Layer_contentsScale :: proc(self: ^Layer) -> Float { +Layer_contentsScale :: proc "c" (self: ^Layer) -> Float { return msgSend(Float, self, "contentsScale") } @(objc_type=Layer, objc_name="setContentsScale") -Layer_setContentsScale :: proc(self: ^Layer, scale: Float) { +Layer_setContentsScale :: proc "c" (self: ^Layer, scale: Float) { msgSend(nil, self, "setContentsScale:", scale) } @(objc_type=Layer, objc_name="frame") -Layer_frame :: proc(self: ^Layer) -> Rect { +Layer_frame :: proc "c" (self: ^Layer) -> Rect { return msgSend(Rect, self, "frame") } @(objc_type=Layer, objc_name="addSublayer") -Layer_addSublayer :: proc(self: ^Layer, layer: ^Layer) { +Layer_addSublayer :: proc "c" (self: ^Layer, layer: ^Layer) { msgSend(nil, self, "addSublayer:", layer) } @@ -73,23 +586,23 @@ View :: struct {using _: Responder} @(objc_type=View, objc_name="initWithFrame") -View_initWithFrame :: proc(self: ^View, frame: Rect) -> ^View { +View_initWithFrame :: proc "c" (self: ^View, frame: Rect) -> ^View { return msgSend(^View, self, "initWithFrame:", frame) } @(objc_type=View, objc_name="layer") -View_layer :: proc(self: ^View) -> ^Layer { +View_layer :: proc "c" (self: ^View) -> ^Layer { return msgSend(^Layer, self, "layer") } @(objc_type=View, objc_name="setLayer") -View_setLayer :: proc(self: ^View, layer: ^Layer) { +View_setLayer :: proc "c" (self: ^View, layer: ^Layer) { msgSend(nil, self, "setLayer:", layer) } @(objc_type=View, objc_name="wantsLayer") -View_wantsLayer :: proc(self: ^View) -> BOOL { +View_wantsLayer :: proc "c" (self: ^View) -> BOOL { return msgSend(BOOL, self, "wantsLayer") } @(objc_type=View, objc_name="setWantsLayer") -View_setWantsLayer :: proc(self: ^View, wantsLayer: BOOL) { +View_setWantsLayer :: proc "c" (self: ^View, wantsLayer: BOOL) { msgSend(nil, self, "setWantsLayer:", wantsLayer) } @@ -97,7 +610,7 @@ View_setWantsLayer :: proc(self: ^View, wantsLayer: BOOL) { Window :: struct {using _: Responder} @(objc_type=Window, objc_name="alloc", objc_is_class_method=true) -Window_alloc :: proc() -> ^Window { +Window_alloc :: proc "c" () -> ^Window { return msgSend(^Window, Window, "alloc") } @@ -117,66 +630,70 @@ Window_initWithContentRect :: proc (self: ^Window, contentRect: Rect, styleMask: return self } @(objc_type=Window, objc_name="contentView") -Window_contentView :: proc(self: ^Window) -> ^View { +Window_contentView :: proc "c" (self: ^Window) -> ^View { return msgSend(^View, self, "contentView") } @(objc_type=Window, objc_name="setContentView") -Window_setContentView :: proc(self: ^Window, content_view: ^View) { +Window_setContentView :: proc "c" (self: ^Window, content_view: ^View) { msgSend(nil, self, "setContentView:", content_view) } @(objc_type=Window, objc_name="contentLayoutRect") -Window_contentLayoutRect :: proc(self: ^Window) -> Rect { +Window_contentLayoutRect :: proc "c" (self: ^Window) -> Rect { return msgSend(Rect, self, "contentLayoutRect") } @(objc_type=Window, objc_name="frame") -Window_frame :: proc(self: ^Window) -> Rect { +Window_frame :: proc "c" (self: ^Window) -> Rect { return msgSend(Rect, self, "frame") } @(objc_type=Window, objc_name="setFrame") -Window_setFrame :: proc(self: ^Window, frame: Rect) { +Window_setFrame :: proc "c" (self: ^Window, frame: Rect) { msgSend(nil, self, "setFrame:", frame) } @(objc_type=Window, objc_name="opaque") -Window_opaque :: proc(self: ^Window) -> NS.BOOL { +Window_opaque :: proc "c" (self: ^Window) -> NS.BOOL { return msgSend(NS.BOOL, self, "opaque") } @(objc_type=Window, objc_name="setOpaque") -Window_setOpaque :: proc(self: ^Window, ok: NS.BOOL) { +Window_setOpaque :: proc "c" (self: ^Window, ok: NS.BOOL) { msgSend(nil, self, "setOpaque:", ok) } @(objc_type=Window, objc_name="backgroundColor") -Window_backgroundColor :: proc(self: ^Window) -> ^NS.Color { +Window_backgroundColor :: proc "c" (self: ^Window) -> ^NS.Color { return msgSend(^NS.Color, self, "backgroundColor") } @(objc_type=Window, objc_name="setBackgroundColor") -Window_setBackgroundColor :: proc(self: ^Window, color: ^NS.Color) { +Window_setBackgroundColor :: proc "c" (self: ^Window, color: ^NS.Color) { msgSend(nil, self, "setBackgroundColor:", color) } @(objc_type=Window, objc_name="makeKeyAndOrderFront") -Window_makeKeyAndOrderFront :: proc(self: ^Window, key: ^NS.Object) { +Window_makeKeyAndOrderFront :: proc "c" (self: ^Window, key: ^NS.Object) { msgSend(nil, self, "makeKeyAndOrderFront:", key) } @(objc_type=Window, objc_name="setTitle") -Window_setTitle :: proc(self: ^Window, title: ^NS.String) { +Window_setTitle :: proc "c" (self: ^Window, title: ^NS.String) { msgSend(nil, self, "setTitle:", title) } @(objc_type=Window, objc_name="setTitlebarAppearsTransparent") -Window_setTitlebarAppearsTransparent :: proc(self: ^Window, ok: NS.BOOL) { +Window_setTitlebarAppearsTransparent :: proc "c" (self: ^Window, ok: NS.BOOL) { msgSend(nil, self, "setTitlebarAppearsTransparent:", ok) } @(objc_type=Window, objc_name="setMovable") -Window_setMovable :: proc(self: ^Window, ok: NS.BOOL) { +Window_setMovable :: proc "c" (self: ^Window, ok: NS.BOOL) { msgSend(nil, self, "setMovable:", ok) } @(objc_type=Window, objc_name="setMovableByWindowBackground") -Window_setMovableByWindowBackground :: proc(self: ^Window, ok: NS.BOOL) { +Window_setMovableByWindowBackground :: proc "c" (self: ^Window, ok: NS.BOOL) { msgSend(nil, self, "setMovableByWindowBackground:", ok) } @(objc_type=Window, objc_name="setStyleMask") -Window_setStyleMask :: proc(self: ^Window, style_mask: WindowStyleMask) { +Window_setStyleMask :: proc "c" (self: ^Window, style_mask: WindowStyleMask) { msgSend(nil, self, "setStyleMask:", style_mask) } @(objc_type=Window, objc_name="close") -Window_close :: proc(self: ^Window) { +Window_close :: proc "c" (self: ^Window) { msgSend(nil, self, "close") } +@(objc_type=Window, objc_name="setDelegate") +Window_setDelegate :: proc "c" (self: ^Window, delegate: ^WindowDelegate) { + msgSend(nil, self, "setDelegate:", delegate) +} \ No newline at end of file diff --git a/vendor/darwin/Foundation/objc.odin b/vendor/darwin/Foundation/objc.odin index 722065564..ac3aeb6ef 100644 --- a/vendor/darwin/Foundation/objc.odin +++ b/vendor/darwin/Foundation/objc.odin @@ -13,10 +13,12 @@ foreign Foundation { objc_allocateClassPair :: proc "c" (superclass : Class, name : cstring, extraBytes : c.size_t) -> Class --- objc_registerClassPair :: proc "c" (cls : Class) --- - class_addMethod :: proc "c" (cls: Class, name: SEL, imp: IMP, types: cstring) -> BOOL --- + class_addMethod :: proc "c" (cls: Class, name: SEL, imp: IMP, types: cstring) -> BOOL --- class_getInstanceMethod :: proc "c" (cls: Class, name: SEL) -> Method --- + class_createInstance :: proc "c" (cls: Class, extraBytes: c.size_t) -> id --- method_setImplementation :: proc "c" (method: Method, imp: IMP) --- + object_getIndexedIvars :: proc(obj: id) -> rawptr --- } diff --git a/vendor/darwin/Metal/MetalClasses.odin b/vendor/darwin/Metal/MetalClasses.odin index 075aae545..17f22e1d3 100644 --- a/vendor/darwin/Metal/MetalClasses.odin +++ b/vendor/darwin/Metal/MetalClasses.odin @@ -6,242 +6,233 @@ _ :: mem //////////////////////////////////////////////////////////////////////////////// -/* -Class: - AccelerationStructureBoundingBoxGeometryDescriptor -Class Methods: - alloc - descriptor -Methods: - init - boundingBoxBuffer - boundingBoxBufferOffset - boundingBoxCount - boundingBoxStride - setBoundingBoxBuffer - setBoundingBoxBufferOffset - setBoundingBoxCount - setBoundingBoxStride -*/ + @(objc_class="MTLAccelerationStructureBoundingBoxGeometryDescriptor") AccelerationStructureBoundingBoxGeometryDescriptor :: struct { using _: NS.Copying(AccelerationStructureBoundingBoxGeometryDescriptor), using _: AccelerationStructureDescriptor } @(objc_type=AccelerationStructureBoundingBoxGeometryDescriptor, objc_name="alloc", objc_is_class_method=true) -AccelerationStructureBoundingBoxGeometryDescriptor_alloc :: #force_inline proc() -> ^AccelerationStructureBoundingBoxGeometryDescriptor { +AccelerationStructureBoundingBoxGeometryDescriptor_alloc :: #force_inline proc "c" () -> ^AccelerationStructureBoundingBoxGeometryDescriptor { return msgSend(^AccelerationStructureBoundingBoxGeometryDescriptor, AccelerationStructureBoundingBoxGeometryDescriptor, "alloc") } @(objc_type=AccelerationStructureBoundingBoxGeometryDescriptor, objc_name="init") -AccelerationStructureBoundingBoxGeometryDescriptor_init :: #force_inline proc(self: ^AccelerationStructureBoundingBoxGeometryDescriptor) -> ^AccelerationStructureBoundingBoxGeometryDescriptor { +AccelerationStructureBoundingBoxGeometryDescriptor_init :: #force_inline proc "c" (self: ^AccelerationStructureBoundingBoxGeometryDescriptor) -> ^AccelerationStructureBoundingBoxGeometryDescriptor { return msgSend(^AccelerationStructureBoundingBoxGeometryDescriptor, self, "init") } @(objc_type=AccelerationStructureBoundingBoxGeometryDescriptor, objc_name="boundingBoxBuffer") -AccelerationStructureBoundingBoxGeometryDescriptor_boundingBoxBuffer :: #force_inline proc(self: ^AccelerationStructureBoundingBoxGeometryDescriptor) -> ^Buffer { +AccelerationStructureBoundingBoxGeometryDescriptor_boundingBoxBuffer :: #force_inline proc "c" (self: ^AccelerationStructureBoundingBoxGeometryDescriptor) -> ^Buffer { return msgSend(^Buffer, self, "boundingBoxBuffer") } @(objc_type=AccelerationStructureBoundingBoxGeometryDescriptor, objc_name="boundingBoxBufferOffset") -AccelerationStructureBoundingBoxGeometryDescriptor_boundingBoxBufferOffset :: #force_inline proc(self: ^AccelerationStructureBoundingBoxGeometryDescriptor) -> NS.UInteger { +AccelerationStructureBoundingBoxGeometryDescriptor_boundingBoxBufferOffset :: #force_inline proc "c" (self: ^AccelerationStructureBoundingBoxGeometryDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "boundingBoxBufferOffset") } @(objc_type=AccelerationStructureBoundingBoxGeometryDescriptor, objc_name="boundingBoxCount") -AccelerationStructureBoundingBoxGeometryDescriptor_boundingBoxCount :: #force_inline proc(self: ^AccelerationStructureBoundingBoxGeometryDescriptor) -> NS.UInteger { +AccelerationStructureBoundingBoxGeometryDescriptor_boundingBoxCount :: #force_inline proc "c" (self: ^AccelerationStructureBoundingBoxGeometryDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "boundingBoxCount") } @(objc_type=AccelerationStructureBoundingBoxGeometryDescriptor, objc_name="boundingBoxStride") -AccelerationStructureBoundingBoxGeometryDescriptor_boundingBoxStride :: #force_inline proc(self: ^AccelerationStructureBoundingBoxGeometryDescriptor) -> NS.UInteger { +AccelerationStructureBoundingBoxGeometryDescriptor_boundingBoxStride :: #force_inline proc "c" (self: ^AccelerationStructureBoundingBoxGeometryDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "boundingBoxStride") } @(objc_type=AccelerationStructureBoundingBoxGeometryDescriptor, objc_name="descriptor", objc_is_class_method=true) -AccelerationStructureBoundingBoxGeometryDescriptor_descriptor :: #force_inline proc() -> ^AccelerationStructureBoundingBoxGeometryDescriptor { +AccelerationStructureBoundingBoxGeometryDescriptor_descriptor :: #force_inline proc "c" () -> ^AccelerationStructureBoundingBoxGeometryDescriptor { return msgSend(^AccelerationStructureBoundingBoxGeometryDescriptor, AccelerationStructureBoundingBoxGeometryDescriptor, "descriptor") } @(objc_type=AccelerationStructureBoundingBoxGeometryDescriptor, objc_name="setBoundingBoxBuffer") -AccelerationStructureBoundingBoxGeometryDescriptor_setBoundingBoxBuffer :: #force_inline proc(self: ^AccelerationStructureBoundingBoxGeometryDescriptor, boundingBoxBuffer: ^Buffer) { +AccelerationStructureBoundingBoxGeometryDescriptor_setBoundingBoxBuffer :: #force_inline proc "c" (self: ^AccelerationStructureBoundingBoxGeometryDescriptor, boundingBoxBuffer: ^Buffer) { msgSend(nil, self, "setBoundingBoxBuffer:", boundingBoxBuffer) } @(objc_type=AccelerationStructureBoundingBoxGeometryDescriptor, objc_name="setBoundingBoxBufferOffset") -AccelerationStructureBoundingBoxGeometryDescriptor_setBoundingBoxBufferOffset :: #force_inline proc(self: ^AccelerationStructureBoundingBoxGeometryDescriptor, boundingBoxBufferOffset: NS.UInteger) { +AccelerationStructureBoundingBoxGeometryDescriptor_setBoundingBoxBufferOffset :: #force_inline proc "c" (self: ^AccelerationStructureBoundingBoxGeometryDescriptor, boundingBoxBufferOffset: NS.UInteger) { msgSend(nil, self, "setBoundingBoxBufferOffset:", boundingBoxBufferOffset) } @(objc_type=AccelerationStructureBoundingBoxGeometryDescriptor, objc_name="setBoundingBoxCount") -AccelerationStructureBoundingBoxGeometryDescriptor_setBoundingBoxCount :: #force_inline proc(self: ^AccelerationStructureBoundingBoxGeometryDescriptor, boundingBoxCount: NS.UInteger) { +AccelerationStructureBoundingBoxGeometryDescriptor_setBoundingBoxCount :: #force_inline proc "c" (self: ^AccelerationStructureBoundingBoxGeometryDescriptor, boundingBoxCount: NS.UInteger) { msgSend(nil, self, "setBoundingBoxCount:", boundingBoxCount) } @(objc_type=AccelerationStructureBoundingBoxGeometryDescriptor, objc_name="setBoundingBoxStride") -AccelerationStructureBoundingBoxGeometryDescriptor_setBoundingBoxStride :: #force_inline proc(self: ^AccelerationStructureBoundingBoxGeometryDescriptor, boundingBoxStride: NS.UInteger) { +AccelerationStructureBoundingBoxGeometryDescriptor_setBoundingBoxStride :: #force_inline proc "c" (self: ^AccelerationStructureBoundingBoxGeometryDescriptor, boundingBoxStride: NS.UInteger) { msgSend(nil, self, "setBoundingBoxStride:", boundingBoxStride) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - MotionKeyframeData -Class Methods: - alloc - data -Methods: - init - buffer - setBuffer - offset - setOffset -*/ @(objc_class="MTLMotionKeyframeData") MotionKeyframeData :: struct { using _: NS.Object } @(objc_type=MotionKeyframeData, objc_name="alloc", objc_is_class_method=true) -MotionKeyframeData_alloc :: #force_inline proc() -> ^MotionKeyframeData { +MotionKeyframeData_alloc :: #force_inline proc "c" () -> ^MotionKeyframeData { return msgSend(^MotionKeyframeData, MotionKeyframeData, "alloc") } @(objc_type=MotionKeyframeData, objc_name="data", objc_is_class_method=true) -MotionKeyframeData_data :: #force_inline proc() -> ^MotionKeyframeData { +MotionKeyframeData_data :: #force_inline proc "c" () -> ^MotionKeyframeData { return msgSend(^MotionKeyframeData, MotionKeyframeData, "data") } @(objc_type=MotionKeyframeData, objc_name="init", objc_is_class_method=true) -MotionKeyframeData_init :: #force_inline proc(self: ^MotionKeyframeData) -> ^MotionKeyframeData { +MotionKeyframeData_init :: #force_inline proc "c" (self: ^MotionKeyframeData) -> ^MotionKeyframeData { return msgSend(^MotionKeyframeData, self, "init") } @(objc_type=MotionKeyframeData, objc_name="buffer", objc_is_class_method=true) -MotionKeyframeData_buffer :: #force_inline proc(self: ^MotionKeyframeData) -> ^Buffer { +MotionKeyframeData_buffer :: #force_inline proc "c" (self: ^MotionKeyframeData) -> ^Buffer { return msgSend(^Buffer, self, "buffer") } @(objc_type=MotionKeyframeData, objc_name="setBuffer", objc_is_class_method=true) -MotionKeyframeData_setBuffer :: #force_inline proc(self: ^MotionKeyframeData, buffer: ^Buffer) { +MotionKeyframeData_setBuffer :: #force_inline proc "c" (self: ^MotionKeyframeData, buffer: ^Buffer) { msgSend(nil, self, "setBuffer:", buffer) } @(objc_type=MotionKeyframeData, objc_name="offset", objc_is_class_method=true) -MotionKeyframeData_offset :: #force_inline proc(self: ^MotionKeyframeData) -> NS.UInteger { +MotionKeyframeData_offset :: #force_inline proc "c" (self: ^MotionKeyframeData) -> NS.UInteger { return msgSend(NS.UInteger, self, "offset") } @(objc_type=MotionKeyframeData, objc_name="setOffset", objc_is_class_method=true) -MotionKeyframeData_setOffset :: #force_inline proc(self: ^MotionKeyframeData, offset: NS.UInteger) { +MotionKeyframeData_setOffset :: #force_inline proc "c" (self: ^MotionKeyframeData, offset: NS.UInteger) { msgSend(nil, self, "setOffset:", offset) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - AccelerationStructureMotionTriangleGeometryDescriptor -*/ + @(objc_class="MTLAccelerationStructureMotionTriangleGeometryDescriptor") AccelerationStructureMotionTriangleGeometryDescriptor :: struct { using _: NS.Copying(AccelerationStructureMotionTriangleGeometryDescriptor), using _: AccelerationStructureGeometryDescriptor } @(objc_type=AccelerationStructureMotionTriangleGeometryDescriptor, objc_name="alloc", objc_is_class_method=true) -AccelerationStructureMotionTriangleGeometryDescriptor_alloc :: #force_inline proc() -> ^AccelerationStructureMotionTriangleGeometryDescriptor { +AccelerationStructureMotionTriangleGeometryDescriptor_alloc :: #force_inline proc "c" () -> ^AccelerationStructureMotionTriangleGeometryDescriptor { return msgSend(^AccelerationStructureMotionTriangleGeometryDescriptor, AccelerationStructureMotionTriangleGeometryDescriptor, "alloc") } @(objc_type=AccelerationStructureMotionTriangleGeometryDescriptor, objc_name="init") -AccelerationStructureMotionTriangleGeometryDescriptor_init :: #force_inline proc(self: ^AccelerationStructureMotionTriangleGeometryDescriptor) -> ^AccelerationStructureMotionTriangleGeometryDescriptor { +AccelerationStructureMotionTriangleGeometryDescriptor_init :: #force_inline proc "c" (self: ^AccelerationStructureMotionTriangleGeometryDescriptor) -> ^AccelerationStructureMotionTriangleGeometryDescriptor { return msgSend(^AccelerationStructureMotionTriangleGeometryDescriptor, self, "init") } @(objc_type=AccelerationStructureMotionTriangleGeometryDescriptor, objc_name="vertexBuffers") -AccelerationStructureMotionTriangleGeometryDescriptor_vertexBuffers :: #force_inline proc(self: ^AccelerationStructureMotionTriangleGeometryDescriptor) -> ^NS.Array { +AccelerationStructureMotionTriangleGeometryDescriptor_vertexBuffers :: #force_inline proc "c" (self: ^AccelerationStructureMotionTriangleGeometryDescriptor) -> ^NS.Array { return msgSend(^NS.Array, self, "vertexBuffers") } @(objc_type=AccelerationStructureMotionTriangleGeometryDescriptor, objc_name="setVertexBuffers") -AccelerationStructureMotionTriangleGeometryDescriptor_setVertexBuffers :: #force_inline proc(self: ^AccelerationStructureMotionTriangleGeometryDescriptor, buffers: ^NS.Array) { +AccelerationStructureMotionTriangleGeometryDescriptor_setVertexBuffers :: #force_inline proc "c" (self: ^AccelerationStructureMotionTriangleGeometryDescriptor, buffers: ^NS.Array) { msgSend(nil, self, "setVertexBuffers:", buffers) } @(objc_type=AccelerationStructureMotionTriangleGeometryDescriptor, objc_name="vertexStride") -AccelerationStructureMotionTriangleGeometryDescriptor_vertexStride :: #force_inline proc(self: ^AccelerationStructureMotionTriangleGeometryDescriptor) -> NS.UInteger { +AccelerationStructureMotionTriangleGeometryDescriptor_vertexStride :: #force_inline proc "c" (self: ^AccelerationStructureMotionTriangleGeometryDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "vertexStride") } @(objc_type=AccelerationStructureMotionTriangleGeometryDescriptor, objc_name="setVertexStride") -AccelerationStructureMotionTriangleGeometryDescriptor_setVertexStride :: #force_inline proc(self: ^AccelerationStructureMotionTriangleGeometryDescriptor, stride: NS.UInteger) { +AccelerationStructureMotionTriangleGeometryDescriptor_setVertexStride :: #force_inline proc "c" (self: ^AccelerationStructureMotionTriangleGeometryDescriptor, stride: NS.UInteger) { msgSend(nil, self, "setVertexStride:", stride) } @(objc_type=AccelerationStructureMotionTriangleGeometryDescriptor, objc_name="indexBuffer") -AccelerationStructureMotionTriangleGeometryDescriptor_indexBuffer :: #force_inline proc(self: ^AccelerationStructureMotionTriangleGeometryDescriptor) -> ^Buffer { +AccelerationStructureMotionTriangleGeometryDescriptor_indexBuffer :: #force_inline proc "c" (self: ^AccelerationStructureMotionTriangleGeometryDescriptor) -> ^Buffer { return msgSend(^Buffer, self, "indexBuffer") } @(objc_type=AccelerationStructureMotionTriangleGeometryDescriptor, objc_name="setIndexBuffer") -AccelerationStructureMotionTriangleGeometryDescriptor_setIndexBuffer :: #force_inline proc(self: ^AccelerationStructureMotionTriangleGeometryDescriptor, buffer: ^Buffer) { +AccelerationStructureMotionTriangleGeometryDescriptor_setIndexBuffer :: #force_inline proc "c" (self: ^AccelerationStructureMotionTriangleGeometryDescriptor, buffer: ^Buffer) { msgSend(nil, self, "setIndexBuffer:", buffer) } @(objc_type=AccelerationStructureMotionTriangleGeometryDescriptor, objc_name="indexBufferOffset") -AccelerationStructureMotionTriangleGeometryDescriptor_indexBufferOffset :: #force_inline proc(self: ^AccelerationStructureMotionTriangleGeometryDescriptor) -> NS.UInteger { +AccelerationStructureMotionTriangleGeometryDescriptor_indexBufferOffset :: #force_inline proc "c" (self: ^AccelerationStructureMotionTriangleGeometryDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "indexBufferOffset") } @(objc_type=AccelerationStructureMotionTriangleGeometryDescriptor, objc_name="setIndexBufferOffset") -AccelerationStructureMotionTriangleGeometryDescriptor_setIndexBufferOffset :: #force_inline proc(self: ^AccelerationStructureMotionTriangleGeometryDescriptor, offset: NS.UInteger) { +AccelerationStructureMotionTriangleGeometryDescriptor_setIndexBufferOffset :: #force_inline proc "c" (self: ^AccelerationStructureMotionTriangleGeometryDescriptor, offset: NS.UInteger) { msgSend(nil, self, "setIndexBufferOffset:", offset) } @(objc_type=AccelerationStructureMotionTriangleGeometryDescriptor, objc_name="indexType") -AccelerationStructureMotionTriangleGeometryDescriptor_indexType :: #force_inline proc(self: ^AccelerationStructureMotionTriangleGeometryDescriptor) -> IndexType { +AccelerationStructureMotionTriangleGeometryDescriptor_indexType :: #force_inline proc "c" (self: ^AccelerationStructureMotionTriangleGeometryDescriptor) -> IndexType { return msgSend(IndexType, self, "indexType") } @(objc_type=AccelerationStructureMotionTriangleGeometryDescriptor, objc_name="setIndexType") -AccelerationStructureMotionTriangleGeometryDescriptor_setIndexType :: #force_inline proc(self: ^AccelerationStructureMotionTriangleGeometryDescriptor, indexType: IndexType) { +AccelerationStructureMotionTriangleGeometryDescriptor_setIndexType :: #force_inline proc "c" (self: ^AccelerationStructureMotionTriangleGeometryDescriptor, indexType: IndexType) { msgSend(nil, self, "setIndexType:", indexType) } @(objc_type=AccelerationStructureMotionTriangleGeometryDescriptor, objc_name="triangleCount") -AccelerationStructureMotionTriangleGeometryDescriptor_triangleCount :: #force_inline proc(self: ^AccelerationStructureMotionTriangleGeometryDescriptor) -> NS.UInteger { +AccelerationStructureMotionTriangleGeometryDescriptor_triangleCount :: #force_inline proc "c" (self: ^AccelerationStructureMotionTriangleGeometryDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "triangleCount") } @(objc_type=AccelerationStructureMotionTriangleGeometryDescriptor, objc_name="setTriangleCount") -AccelerationStructureMotionTriangleGeometryDescriptor_setTriangleCount :: #force_inline proc(self: ^AccelerationStructureMotionTriangleGeometryDescriptor, count: NS.UInteger) { +AccelerationStructureMotionTriangleGeometryDescriptor_setTriangleCount :: #force_inline proc "c" (self: ^AccelerationStructureMotionTriangleGeometryDescriptor, count: NS.UInteger) { msgSend(nil, self, "setTriangleCount:", count) } +@(objc_type=AccelerationStructureMotionTriangleGeometryDescriptor, objc_name="vertexFormat") +AccelerationStructureMotionTriangleGeometryDescriptor_vertexFormat :: #force_inline proc "c" (self: ^AccelerationStructureMotionTriangleGeometryDescriptor) -> AttributeFormat { + return msgSend(AttributeFormat, self, "vertexFormat") +} +@(objc_type=AccelerationStructureMotionTriangleGeometryDescriptor, objc_name="setVertexFormat") +AccelerationStructureMotionTriangleGeometryDescriptor_setVertexFormat :: #force_inline proc "c" (self: ^AccelerationStructureMotionTriangleGeometryDescriptor, vertexFormat: AttributeFormat) { + msgSend(nil, self, "setVertexFormat:", vertexFormat) +} + +@(objc_type=AccelerationStructureMotionTriangleGeometryDescriptor, objc_name="transformationMatrixBuffer") +AccelerationStructureMotionTriangleGeometryDescriptor_transformationMatrixBuffer :: #force_inline proc "c" (self: ^AccelerationStructureMotionTriangleGeometryDescriptor) -> ^Buffer { + return msgSend(^Buffer, self, "transformationMatrixBuffer") +} +@(objc_type=AccelerationStructureMotionTriangleGeometryDescriptor, objc_name="setTransformationMatrixBuffer") +AccelerationStructureMotionTriangleGeometryDescriptor_setTransformationMatrixBuffer :: #force_inline proc "c" (self: ^AccelerationStructureMotionTriangleGeometryDescriptor, transformationMatrixBuffer: ^Buffer) { + msgSend(nil, self, "setTransformationMatrixBuffer:", transformationMatrixBuffer) +} +@(objc_type=AccelerationStructureMotionTriangleGeometryDescriptor, objc_name="transformationMatrixBufferOffset") +AccelerationStructureMotionTriangleGeometryDescriptor_transformationMatrixBufferOffset :: #force_inline proc "c" (self: ^AccelerationStructureMotionTriangleGeometryDescriptor) -> NS.UInteger { + return msgSend(NS.UInteger, self, "transformationMatrixBufferOffset") +} +@(objc_type=AccelerationStructureMotionTriangleGeometryDescriptor, objc_name="setTransformationMatrixBufferOffset") +AccelerationStructureMotionTriangleGeometryDescriptor_setTransformationMatrixBufferOffset :: #force_inline proc "c" (self: ^AccelerationStructureMotionTriangleGeometryDescriptor, transformationMatrixBufferOffset: NS.UInteger) { + msgSend(nil, self, "setTransformationMatrixBufferOffset:", transformationMatrixBufferOffset) +} + //////////////////////////////////////////////////////////////////////////////// -/* -Class: - AccelerationStructureMotionBoundingBoxGeometryDescriptor -*/ + @(objc_class="MTLAccelerationStructureMotionBoundingBoxGeometryDescriptor") AccelerationStructureMotionBoundingBoxGeometryDescriptor :: struct { using _: NS.Copying(AccelerationStructureMotionBoundingBoxGeometryDescriptor), using _: AccelerationStructureGeometryDescriptor } @(objc_type=AccelerationStructureMotionBoundingBoxGeometryDescriptor, objc_name="alloc", objc_is_class_method=true) -AccelerationStructureMotionBoundingBoxGeometryDescriptor_alloc :: #force_inline proc() -> ^AccelerationStructureMotionBoundingBoxGeometryDescriptor { +AccelerationStructureMotionBoundingBoxGeometryDescriptor_alloc :: #force_inline proc "c" () -> ^AccelerationStructureMotionBoundingBoxGeometryDescriptor { return msgSend(^AccelerationStructureMotionBoundingBoxGeometryDescriptor, AccelerationStructureMotionBoundingBoxGeometryDescriptor, "alloc") } @(objc_type=AccelerationStructureMotionBoundingBoxGeometryDescriptor, objc_name="init") -AccelerationStructureMotionBoundingBoxGeometryDescriptor_init :: #force_inline proc(self: ^AccelerationStructureMotionBoundingBoxGeometryDescriptor) -> ^AccelerationStructureMotionBoundingBoxGeometryDescriptor { +AccelerationStructureMotionBoundingBoxGeometryDescriptor_init :: #force_inline proc "c" (self: ^AccelerationStructureMotionBoundingBoxGeometryDescriptor) -> ^AccelerationStructureMotionBoundingBoxGeometryDescriptor { return msgSend(^AccelerationStructureMotionBoundingBoxGeometryDescriptor, self, "init") } @(objc_type=AccelerationStructureMotionBoundingBoxGeometryDescriptor, objc_name="descriptor", objc_is_class_method=true) -AccelerationStructureMotionBoundingBoxGeometryDescriptor_descriptor :: #force_inline proc() -> ^AccelerationStructureMotionBoundingBoxGeometryDescriptor { +AccelerationStructureMotionBoundingBoxGeometryDescriptor_descriptor :: #force_inline proc "c" () -> ^AccelerationStructureMotionBoundingBoxGeometryDescriptor { return msgSend(^AccelerationStructureMotionBoundingBoxGeometryDescriptor, AccelerationStructureMotionBoundingBoxGeometryDescriptor, "descriptor") } @(objc_type=AccelerationStructureMotionBoundingBoxGeometryDescriptor, objc_name="boundingBoxBuffers") -AccelerationStructureMotionBoundingBoxGeometryDescriptor_boundingBoxBuffers :: #force_inline proc(self: ^AccelerationStructureMotionBoundingBoxGeometryDescriptor) -> ^NS.Array { +AccelerationStructureMotionBoundingBoxGeometryDescriptor_boundingBoxBuffers :: #force_inline proc "c" (self: ^AccelerationStructureMotionBoundingBoxGeometryDescriptor) -> ^NS.Array { return msgSend(^NS.Array, self, "boundingBoxBuffers") } @(objc_type=AccelerationStructureMotionBoundingBoxGeometryDescriptor, objc_name="setBoundBoxBuffers") -AccelerationStructureMotionBoundingBoxGeometryDescriptor_setBoundBoxBuffers :: #force_inline proc(self: ^AccelerationStructureMotionBoundingBoxGeometryDescriptor, buffers: ^NS.Array) { +AccelerationStructureMotionBoundingBoxGeometryDescriptor_setBoundBoxBuffers :: #force_inline proc "c" (self: ^AccelerationStructureMotionBoundingBoxGeometryDescriptor, buffers: ^NS.Array) { msgSend(nil, self, "setBoundBoxBuffers:", buffers) } @(objc_type=AccelerationStructureMotionBoundingBoxGeometryDescriptor, objc_name="boundingBoxStride") -AccelerationStructureMotionBoundingBoxGeometryDescriptor_boundingBoxStride :: #force_inline proc(self: ^AccelerationStructureMotionBoundingBoxGeometryDescriptor) -> NS.UInteger { +AccelerationStructureMotionBoundingBoxGeometryDescriptor_boundingBoxStride :: #force_inline proc "c" (self: ^AccelerationStructureMotionBoundingBoxGeometryDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "boundingBoxStride") } @(objc_type=AccelerationStructureMotionBoundingBoxGeometryDescriptor, objc_name="setBoundingBoxStride") -AccelerationStructureMotionBoundingBoxGeometryDescriptor_setBoundingBoxStride :: #force_inline proc(self: ^AccelerationStructureMotionBoundingBoxGeometryDescriptor, stride: NS.UInteger) { +AccelerationStructureMotionBoundingBoxGeometryDescriptor_setBoundingBoxStride :: #force_inline proc "c" (self: ^AccelerationStructureMotionBoundingBoxGeometryDescriptor, stride: NS.UInteger) { msgSend(nil, self, "setBoundingBoxStride:", stride) } @(objc_type=AccelerationStructureMotionBoundingBoxGeometryDescriptor, objc_name="boundingBoxCount") -AccelerationStructureMotionBoundingBoxGeometryDescriptor_boundingBoxCount :: #force_inline proc(self: ^AccelerationStructureMotionBoundingBoxGeometryDescriptor) -> NS.UInteger { +AccelerationStructureMotionBoundingBoxGeometryDescriptor_boundingBoxCount :: #force_inline proc "c" (self: ^AccelerationStructureMotionBoundingBoxGeometryDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "boundingBoxCount") } @(objc_type=AccelerationStructureMotionBoundingBoxGeometryDescriptor, objc_name="setBoundingBoxCount") -AccelerationStructureMotionBoundingBoxGeometryDescriptor_setBoundingBoxCount :: #force_inline proc(self: ^AccelerationStructureMotionBoundingBoxGeometryDescriptor, offset: NS.UInteger) { +AccelerationStructureMotionBoundingBoxGeometryDescriptor_setBoundingBoxCount :: #force_inline proc "c" (self: ^AccelerationStructureMotionBoundingBoxGeometryDescriptor, offset: NS.UInteger) { msgSend(nil, self, "setBoundingBoxCount:", offset) } @@ -253,903 +244,732 @@ AccelerationStructureMotionBoundingBoxGeometryDescriptor_setBoundingBoxCount :: //////////////////////////////////////////////////////////////////////////////// -/* -Class: - AccelerationStructureDescriptor -Class Methods: - alloc -Methods: - init - setUsage - usage -*/ + @(objc_class="MTLAccelerationStructureDescriptor") AccelerationStructureDescriptor :: struct { using _: NS.Copying(AccelerationStructureDescriptor) } @(objc_type=AccelerationStructureDescriptor, objc_name="alloc", objc_is_class_method=true) -AccelerationStructureDescriptor_alloc :: #force_inline proc() -> ^AccelerationStructureDescriptor { +AccelerationStructureDescriptor_alloc :: #force_inline proc "c" () -> ^AccelerationStructureDescriptor { return msgSend(^AccelerationStructureDescriptor, AccelerationStructureDescriptor, "alloc") } @(objc_type=AccelerationStructureDescriptor, objc_name="init") -AccelerationStructureDescriptor_init :: #force_inline proc(self: ^AccelerationStructureDescriptor) -> ^AccelerationStructureDescriptor { +AccelerationStructureDescriptor_init :: #force_inline proc "c" (self: ^AccelerationStructureDescriptor) -> ^AccelerationStructureDescriptor { return msgSend(^AccelerationStructureDescriptor, self, "init") } @(objc_type=AccelerationStructureDescriptor, objc_name="setUsage") -AccelerationStructureDescriptor_setUsage :: #force_inline proc(self: ^AccelerationStructureDescriptor, usage: AccelerationStructureUsage) { +AccelerationStructureDescriptor_setUsage :: #force_inline proc "c" (self: ^AccelerationStructureDescriptor, usage: AccelerationStructureUsage) { msgSend(nil, self, "setUsage:", usage) } @(objc_type=AccelerationStructureDescriptor, objc_name="usage") -AccelerationStructureDescriptor_usage :: #force_inline proc(self: ^AccelerationStructureDescriptor) -> AccelerationStructureUsage { +AccelerationStructureDescriptor_usage :: #force_inline proc "c" (self: ^AccelerationStructureDescriptor) -> AccelerationStructureUsage { return msgSend(AccelerationStructureUsage, self, "usage") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - AccelerationStructureGeometryDescriptor -Class Methods: - alloc -Methods: - init - allowDuplicateIntersectionFunctionInvocation - intersectionFunctionTableOffset - opaque - setAllowDuplicateIntersectionFunctionInvocation - setIntersectionFunctionTableOffset - setOpaque -*/ + @(objc_class="MTLAccelerationStructureGeometryDescriptor") AccelerationStructureGeometryDescriptor :: struct { using _: NS.Copying(AccelerationStructureGeometryDescriptor) } @(objc_type=AccelerationStructureGeometryDescriptor, objc_name="alloc", objc_is_class_method=true) -AccelerationStructureGeometryDescriptor_alloc :: #force_inline proc() -> ^AccelerationStructureGeometryDescriptor { +AccelerationStructureGeometryDescriptor_alloc :: #force_inline proc "c" () -> ^AccelerationStructureGeometryDescriptor { return msgSend(^AccelerationStructureGeometryDescriptor, AccelerationStructureGeometryDescriptor, "alloc") } @(objc_type=AccelerationStructureGeometryDescriptor, objc_name="init") -AccelerationStructureGeometryDescriptor_init :: #force_inline proc(self: ^AccelerationStructureGeometryDescriptor) -> ^AccelerationStructureGeometryDescriptor { +AccelerationStructureGeometryDescriptor_init :: #force_inline proc "c" (self: ^AccelerationStructureGeometryDescriptor) -> ^AccelerationStructureGeometryDescriptor { return msgSend(^AccelerationStructureGeometryDescriptor, self, "init") } @(objc_type=AccelerationStructureGeometryDescriptor, objc_name="allowDuplicateIntersectionFunctionInvocation") -AccelerationStructureGeometryDescriptor_allowDuplicateIntersectionFunctionInvocation :: #force_inline proc(self: ^AccelerationStructureGeometryDescriptor) -> BOOL { +AccelerationStructureGeometryDescriptor_allowDuplicateIntersectionFunctionInvocation :: #force_inline proc "c" (self: ^AccelerationStructureGeometryDescriptor) -> BOOL { return msgSend(BOOL, self, "allowDuplicateIntersectionFunctionInvocation") } @(objc_type=AccelerationStructureGeometryDescriptor, objc_name="intersectionFunctionTableOffset") -AccelerationStructureGeometryDescriptor_intersectionFunctionTableOffset :: #force_inline proc(self: ^AccelerationStructureGeometryDescriptor) -> NS.UInteger { +AccelerationStructureGeometryDescriptor_intersectionFunctionTableOffset :: #force_inline proc "c" (self: ^AccelerationStructureGeometryDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "intersectionFunctionTableOffset") } @(objc_type=AccelerationStructureGeometryDescriptor, objc_name="opaque") -AccelerationStructureGeometryDescriptor_opaque :: #force_inline proc(self: ^AccelerationStructureGeometryDescriptor) -> BOOL { +AccelerationStructureGeometryDescriptor_opaque :: #force_inline proc "c" (self: ^AccelerationStructureGeometryDescriptor) -> BOOL { return msgSend(BOOL, self, "opaque") } @(objc_type=AccelerationStructureGeometryDescriptor, objc_name="setAllowDuplicateIntersectionFunctionInvocation") -AccelerationStructureGeometryDescriptor_setAllowDuplicateIntersectionFunctionInvocation :: #force_inline proc(self: ^AccelerationStructureGeometryDescriptor, allowDuplicateIntersectionFunctionInvocation: BOOL) { +AccelerationStructureGeometryDescriptor_setAllowDuplicateIntersectionFunctionInvocation :: #force_inline proc "c" (self: ^AccelerationStructureGeometryDescriptor, allowDuplicateIntersectionFunctionInvocation: BOOL) { msgSend(nil, self, "setAllowDuplicateIntersectionFunctionInvocation:", allowDuplicateIntersectionFunctionInvocation) } @(objc_type=AccelerationStructureGeometryDescriptor, objc_name="setIntersectionFunctionTableOffset") -AccelerationStructureGeometryDescriptor_setIntersectionFunctionTableOffset :: #force_inline proc(self: ^AccelerationStructureGeometryDescriptor, intersectionFunctionTableOffset: NS.UInteger) { +AccelerationStructureGeometryDescriptor_setIntersectionFunctionTableOffset :: #force_inline proc "c" (self: ^AccelerationStructureGeometryDescriptor, intersectionFunctionTableOffset: NS.UInteger) { msgSend(nil, self, "setIntersectionFunctionTableOffset:", intersectionFunctionTableOffset) } @(objc_type=AccelerationStructureGeometryDescriptor, objc_name="setOpaque") -AccelerationStructureGeometryDescriptor_setOpaque :: #force_inline proc(self: ^AccelerationStructureGeometryDescriptor, opaque: BOOL) { +AccelerationStructureGeometryDescriptor_setOpaque :: #force_inline proc "c" (self: ^AccelerationStructureGeometryDescriptor, opaque: BOOL) { msgSend(nil, self, "setOpaque:", opaque) } +@(objc_type=AccelerationStructureGeometryDescriptor, objc_name="primitiveDataBuffer") +AccelerationStructureGeometryDescriptor_primitiveDataBuffer :: #force_inline proc "c" (self: ^AccelerationStructureGeometryDescriptor) -> ^Buffer { + return msgSend(^Buffer, self, "primitiveDataBuffer") +} +@(objc_type=AccelerationStructureGeometryDescriptor, objc_name="setPrimitiveDataBuffer") +AccelerationStructureGeometryDescriptor_setPrimitiveDataBuffer :: #force_inline proc "c" (self: ^AccelerationStructureGeometryDescriptor, primitiveDataBuffer: ^Buffer) { + msgSend(nil, self, "setPrimitiveDataBuffer:", primitiveDataBuffer) +} +@(objc_type=AccelerationStructureGeometryDescriptor, objc_name="primitiveDataBufferOffset") +AccelerationStructureGeometryDescriptor_primitiveDataBufferOffset :: #force_inline proc "c" (self: ^AccelerationStructureGeometryDescriptor) -> NS.UInteger { + return msgSend(NS.UInteger, self, "primitiveDataBufferOffset") +} +@(objc_type=AccelerationStructureGeometryDescriptor, objc_name="setPrimitiveDataBufferOffset") +AccelerationStructureGeometryDescriptor_setPrimitiveDataBufferOffset :: #force_inline proc "c" (self: ^AccelerationStructureGeometryDescriptor, offset: NS.UInteger) { + msgSend(nil, self, "setPrimitiveDataBufferOffset:", offset) +} +@(objc_type=AccelerationStructureGeometryDescriptor, objc_name="primitiveDataStride") +AccelerationStructureGeometryDescriptor_primitiveDataStride :: #force_inline proc "c" (self: ^AccelerationStructureGeometryDescriptor) -> NS.UInteger { + return msgSend(NS.UInteger, self, "primitiveDataStride") +} +@(objc_type=AccelerationStructureGeometryDescriptor, objc_name="setPrimitiveDataStride") +AccelerationStructureGeometryDescriptor_setPrimitiveDataStride :: #force_inline proc "c" (self: ^AccelerationStructureGeometryDescriptor, stride: NS.UInteger) { + msgSend(nil, self, "setPrimitiveDataStride:", stride) +} +@(objc_type=AccelerationStructureGeometryDescriptor, objc_name="primitiveDataElementSize") +AccelerationStructureGeometryDescriptor_primitiveDataElementSize :: #force_inline proc "c" (self: ^AccelerationStructureGeometryDescriptor) -> NS.UInteger { + return msgSend(NS.UInteger, self, "primitiveDataElementSize") +} +@(objc_type=AccelerationStructureGeometryDescriptor, objc_name="setPrimitiveDataElementSize") +AccelerationStructureGeometryDescriptor_setPrimitiveDataElementSize :: #force_inline proc "c" (self: ^AccelerationStructureGeometryDescriptor, elementSize: NS.UInteger) { + msgSend(nil, self, "setPrimitiveDataElementSize:", elementSize) +} + + //////////////////////////////////////////////////////////////////////////////// -/* -Class: - AccelerationStructureTriangleGeometryDescriptor -Class Methods: - alloc - descriptor -Methods: - init - indexBuffer - indexBufferOffset - indexType - setIndexBuffer - setIndexBufferOffset - setIndexType - setTriangleCount - setVertexBuffer - setVertexBufferOffset - setVertexStride - triangleCount - vertexBuffer - vertexBufferOffset - vertexStride -*/ + @(objc_class="MTLAccelerationStructureTriangleGeometryDescriptor") AccelerationStructureTriangleGeometryDescriptor :: struct { using _: NS.Copying(AccelerationStructureTriangleGeometryDescriptor), using _: AccelerationStructureDescriptor } @(objc_type=AccelerationStructureTriangleGeometryDescriptor, objc_name="alloc", objc_is_class_method=true) -AccelerationStructureTriangleGeometryDescriptor_alloc :: #force_inline proc() -> ^AccelerationStructureTriangleGeometryDescriptor { +AccelerationStructureTriangleGeometryDescriptor_alloc :: #force_inline proc "c" () -> ^AccelerationStructureTriangleGeometryDescriptor { return msgSend(^AccelerationStructureTriangleGeometryDescriptor, AccelerationStructureTriangleGeometryDescriptor, "alloc") } @(objc_type=AccelerationStructureTriangleGeometryDescriptor, objc_name="init") -AccelerationStructureTriangleGeometryDescriptor_init :: #force_inline proc(self: ^AccelerationStructureTriangleGeometryDescriptor) -> ^AccelerationStructureTriangleGeometryDescriptor { +AccelerationStructureTriangleGeometryDescriptor_init :: #force_inline proc "c" (self: ^AccelerationStructureTriangleGeometryDescriptor) -> ^AccelerationStructureTriangleGeometryDescriptor { return msgSend(^AccelerationStructureTriangleGeometryDescriptor, self, "init") } @(objc_type=AccelerationStructureTriangleGeometryDescriptor, objc_name="descriptor", objc_is_class_method=true) -AccelerationStructureTriangleGeometryDescriptor_descriptor :: #force_inline proc() -> ^AccelerationStructureTriangleGeometryDescriptor { +AccelerationStructureTriangleGeometryDescriptor_descriptor :: #force_inline proc "c" () -> ^AccelerationStructureTriangleGeometryDescriptor { return msgSend(^AccelerationStructureTriangleGeometryDescriptor, AccelerationStructureTriangleGeometryDescriptor, "descriptor") } @(objc_type=AccelerationStructureTriangleGeometryDescriptor, objc_name="indexBuffer") -AccelerationStructureTriangleGeometryDescriptor_indexBuffer :: #force_inline proc(self: ^AccelerationStructureTriangleGeometryDescriptor) -> ^Buffer { +AccelerationStructureTriangleGeometryDescriptor_indexBuffer :: #force_inline proc "c" (self: ^AccelerationStructureTriangleGeometryDescriptor) -> ^Buffer { return msgSend(^Buffer, self, "indexBuffer") } @(objc_type=AccelerationStructureTriangleGeometryDescriptor, objc_name="indexBufferOffset") -AccelerationStructureTriangleGeometryDescriptor_indexBufferOffset :: #force_inline proc(self: ^AccelerationStructureTriangleGeometryDescriptor) -> NS.UInteger { +AccelerationStructureTriangleGeometryDescriptor_indexBufferOffset :: #force_inline proc "c" (self: ^AccelerationStructureTriangleGeometryDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "indexBufferOffset") } @(objc_type=AccelerationStructureTriangleGeometryDescriptor, objc_name="indexType") -AccelerationStructureTriangleGeometryDescriptor_indexType :: #force_inline proc(self: ^AccelerationStructureTriangleGeometryDescriptor) -> IndexType { +AccelerationStructureTriangleGeometryDescriptor_indexType :: #force_inline proc "c" (self: ^AccelerationStructureTriangleGeometryDescriptor) -> IndexType { return msgSend(IndexType, self, "indexType") } @(objc_type=AccelerationStructureTriangleGeometryDescriptor, objc_name="setIndexBuffer") -AccelerationStructureTriangleGeometryDescriptor_setIndexBuffer :: #force_inline proc(self: ^AccelerationStructureTriangleGeometryDescriptor, indexBuffer: ^Buffer) { +AccelerationStructureTriangleGeometryDescriptor_setIndexBuffer :: #force_inline proc "c" (self: ^AccelerationStructureTriangleGeometryDescriptor, indexBuffer: ^Buffer) { msgSend(nil, self, "setIndexBuffer:", indexBuffer) } @(objc_type=AccelerationStructureTriangleGeometryDescriptor, objc_name="setIndexBufferOffset") -AccelerationStructureTriangleGeometryDescriptor_setIndexBufferOffset :: #force_inline proc(self: ^AccelerationStructureTriangleGeometryDescriptor, indexBufferOffset: NS.UInteger) { +AccelerationStructureTriangleGeometryDescriptor_setIndexBufferOffset :: #force_inline proc "c" (self: ^AccelerationStructureTriangleGeometryDescriptor, indexBufferOffset: NS.UInteger) { msgSend(nil, self, "setIndexBufferOffset:", indexBufferOffset) } @(objc_type=AccelerationStructureTriangleGeometryDescriptor, objc_name="setIndexType") -AccelerationStructureTriangleGeometryDescriptor_setIndexType :: #force_inline proc(self: ^AccelerationStructureTriangleGeometryDescriptor, indexType: IndexType) { +AccelerationStructureTriangleGeometryDescriptor_setIndexType :: #force_inline proc "c" (self: ^AccelerationStructureTriangleGeometryDescriptor, indexType: IndexType) { msgSend(nil, self, "setIndexType:", indexType) } @(objc_type=AccelerationStructureTriangleGeometryDescriptor, objc_name="setTriangleCount") -AccelerationStructureTriangleGeometryDescriptor_setTriangleCount :: #force_inline proc(self: ^AccelerationStructureTriangleGeometryDescriptor, triangleCount: NS.UInteger) { +AccelerationStructureTriangleGeometryDescriptor_setTriangleCount :: #force_inline proc "c" (self: ^AccelerationStructureTriangleGeometryDescriptor, triangleCount: NS.UInteger) { msgSend(nil, self, "setTriangleCount:", triangleCount) } @(objc_type=AccelerationStructureTriangleGeometryDescriptor, objc_name="setVertexBuffer") -AccelerationStructureTriangleGeometryDescriptor_setVertexBuffer :: #force_inline proc(self: ^AccelerationStructureTriangleGeometryDescriptor, vertexBuffer: ^Buffer) { +AccelerationStructureTriangleGeometryDescriptor_setVertexBuffer :: #force_inline proc "c" (self: ^AccelerationStructureTriangleGeometryDescriptor, vertexBuffer: ^Buffer) { msgSend(nil, self, "setVertexBuffer:", vertexBuffer) } @(objc_type=AccelerationStructureTriangleGeometryDescriptor, objc_name="setVertexBufferOffset") -AccelerationStructureTriangleGeometryDescriptor_setVertexBufferOffset :: #force_inline proc(self: ^AccelerationStructureTriangleGeometryDescriptor, vertexBufferOffset: NS.UInteger) { +AccelerationStructureTriangleGeometryDescriptor_setVertexBufferOffset :: #force_inline proc "c" (self: ^AccelerationStructureTriangleGeometryDescriptor, vertexBufferOffset: NS.UInteger) { msgSend(nil, self, "setVertexBufferOffset:", vertexBufferOffset) } @(objc_type=AccelerationStructureTriangleGeometryDescriptor, objc_name="setVertexStride") -AccelerationStructureTriangleGeometryDescriptor_setVertexStride :: #force_inline proc(self: ^AccelerationStructureTriangleGeometryDescriptor, vertexStride: NS.UInteger) { +AccelerationStructureTriangleGeometryDescriptor_setVertexStride :: #force_inline proc "c" (self: ^AccelerationStructureTriangleGeometryDescriptor, vertexStride: NS.UInteger) { msgSend(nil, self, "setVertexStride:", vertexStride) } @(objc_type=AccelerationStructureTriangleGeometryDescriptor, objc_name="triangleCount") -AccelerationStructureTriangleGeometryDescriptor_triangleCount :: #force_inline proc(self: ^AccelerationStructureTriangleGeometryDescriptor) -> NS.UInteger { +AccelerationStructureTriangleGeometryDescriptor_triangleCount :: #force_inline proc "c" (self: ^AccelerationStructureTriangleGeometryDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "triangleCount") } @(objc_type=AccelerationStructureTriangleGeometryDescriptor, objc_name="vertexBuffer") -AccelerationStructureTriangleGeometryDescriptor_vertexBuffer :: #force_inline proc(self: ^AccelerationStructureTriangleGeometryDescriptor) -> ^Buffer { +AccelerationStructureTriangleGeometryDescriptor_vertexBuffer :: #force_inline proc "c" (self: ^AccelerationStructureTriangleGeometryDescriptor) -> ^Buffer { return msgSend(^Buffer, self, "vertexBuffer") } @(objc_type=AccelerationStructureTriangleGeometryDescriptor, objc_name="vertexBufferOffset") -AccelerationStructureTriangleGeometryDescriptor_vertexBufferOffset :: #force_inline proc(self: ^AccelerationStructureTriangleGeometryDescriptor) -> NS.UInteger { +AccelerationStructureTriangleGeometryDescriptor_vertexBufferOffset :: #force_inline proc "c" (self: ^AccelerationStructureTriangleGeometryDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "vertexBufferOffset") } @(objc_type=AccelerationStructureTriangleGeometryDescriptor, objc_name="vertexStride") -AccelerationStructureTriangleGeometryDescriptor_vertexStride :: #force_inline proc(self: ^AccelerationStructureTriangleGeometryDescriptor) -> NS.UInteger { +AccelerationStructureTriangleGeometryDescriptor_vertexStride :: #force_inline proc "c" (self: ^AccelerationStructureTriangleGeometryDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "vertexStride") } +@(objc_type=AccelerationStructureTriangleGeometryDescriptor, objc_name="vertexFormat") +AccelerationStructureTriangleGeometryDescriptor_vertexFormat :: #force_inline proc "c" (self: ^AccelerationStructureTriangleGeometryDescriptor) -> AttributeFormat { + return msgSend(AttributeFormat, self, "vertexFormat") +} +@(objc_type=AccelerationStructureTriangleGeometryDescriptor, objc_name="setVertexFormat") +AccelerationStructureTriangleGeometryDescriptor_setVertexFormat :: #force_inline proc "c" (self: ^AccelerationStructureTriangleGeometryDescriptor, vertexFormat: AttributeFormat) { + msgSend(nil, self, "setVertexFormat:", vertexFormat) +} + +@(objc_type=AccelerationStructureTriangleGeometryDescriptor, objc_name="transformationMatrixBuffer") +AccelerationStructureTriangleGeometryDescriptor_transformationMatrixBuffer :: #force_inline proc "c" (self: ^AccelerationStructureTriangleGeometryDescriptor) -> ^Buffer { + return msgSend(^Buffer, self, "transformationMatrixBuffer") +} +@(objc_type=AccelerationStructureTriangleGeometryDescriptor, objc_name="setTransformationMatrixBuffer") +AccelerationStructureTriangleGeometryDescriptor_setTransformationMatrixBuffer :: #force_inline proc "c" (self: ^AccelerationStructureTriangleGeometryDescriptor, transformationMatrixBuffer: ^Buffer) { + msgSend(nil, self, "setTransformationMatrixBuffer:", transformationMatrixBuffer) +} +@(objc_type=AccelerationStructureTriangleGeometryDescriptor, objc_name="transformationMatrixBufferOffset") +AccelerationStructureTriangleGeometryDescriptor_transformationMatrixBufferOffset :: #force_inline proc "c" (self: ^AccelerationStructureTriangleGeometryDescriptor) -> NS.UInteger { + return msgSend(NS.UInteger, self, "transformationMatrixBufferOffset") +} +@(objc_type=AccelerationStructureTriangleGeometryDescriptor, objc_name="setTransformationMatrixBufferOffset") +AccelerationStructureTriangleGeometryDescriptor_setTransformationMatrixBufferOffset :: #force_inline proc "c" (self: ^AccelerationStructureTriangleGeometryDescriptor, transformationMatrixBufferOffset: NS.UInteger) { + msgSend(nil, self, "setTransformationMatrixBufferOffset:", transformationMatrixBufferOffset) +} + //////////////////////////////////////////////////////////////////////////////// -/* -Class: - Argument -Class Methods: - alloc -Methods: - init - access - arrayLength - bufferAlignment - bufferDataSize - bufferDataType - bufferPointerType - bufferStructType - index - isActive - isDepthTexture - name - textureDataType - textureType - threadgroupMemoryAlignment - threadgroupMemoryDataSize - type -*/ + @(objc_class="MTLArgument") Argument :: struct { using _: NS.Object } @(objc_type=Argument, objc_name="alloc", objc_is_class_method=true) -Argument_alloc :: #force_inline proc() -> ^Argument { +Argument_alloc :: #force_inline proc "c" () -> ^Argument { return msgSend(^Argument, Argument, "alloc") } @(objc_type=Argument, objc_name="init") -Argument_init :: #force_inline proc(self: ^Argument) -> ^Argument { +Argument_init :: #force_inline proc "c" (self: ^Argument) -> ^Argument { return msgSend(^Argument, self, "init") } @(objc_type=Argument, objc_name="access") -Argument_access :: #force_inline proc(self: ^Argument) -> ArgumentAccess { +Argument_access :: #force_inline proc "c" (self: ^Argument) -> ArgumentAccess { return msgSend(ArgumentAccess, self, "access") } @(objc_type=Argument, objc_name="arrayLength") -Argument_arrayLength :: #force_inline proc(self: ^Argument) -> NS.UInteger { +Argument_arrayLength :: #force_inline proc "c" (self: ^Argument) -> NS.UInteger { return msgSend(NS.UInteger, self, "arrayLength") } @(objc_type=Argument, objc_name="bufferAlignment") -Argument_bufferAlignment :: #force_inline proc(self: ^Argument) -> NS.UInteger { +Argument_bufferAlignment :: #force_inline proc "c" (self: ^Argument) -> NS.UInteger { return msgSend(NS.UInteger, self, "bufferAlignment") } @(objc_type=Argument, objc_name="bufferDataSize") -Argument_bufferDataSize :: #force_inline proc(self: ^Argument) -> NS.UInteger { +Argument_bufferDataSize :: #force_inline proc "c" (self: ^Argument) -> NS.UInteger { return msgSend(NS.UInteger, self, "bufferDataSize") } @(objc_type=Argument, objc_name="bufferDataType") -Argument_bufferDataType :: #force_inline proc(self: ^Argument) -> DataType { +Argument_bufferDataType :: #force_inline proc "c" (self: ^Argument) -> DataType { return msgSend(DataType, self, "bufferDataType") } @(objc_type=Argument, objc_name="bufferPointerType") -Argument_bufferPointerType :: #force_inline proc(self: ^Argument) -> ^PointerType { +Argument_bufferPointerType :: #force_inline proc "c" (self: ^Argument) -> ^PointerType { return msgSend(^PointerType, self, "bufferPointerType") } @(objc_type=Argument, objc_name="bufferStructType") -Argument_bufferStructType :: #force_inline proc(self: ^Argument) -> ^StructType { +Argument_bufferStructType :: #force_inline proc "c" (self: ^Argument) -> ^StructType { return msgSend(^StructType, self, "bufferStructType") } @(objc_type=Argument, objc_name="index") -Argument_index :: #force_inline proc(self: ^Argument) -> NS.UInteger { +Argument_index :: #force_inline proc "c" (self: ^Argument) -> NS.UInteger { return msgSend(NS.UInteger, self, "index") } @(objc_type=Argument, objc_name="isActive") -Argument_isActive :: #force_inline proc(self: ^Argument) -> BOOL { +Argument_isActive :: #force_inline proc "c" (self: ^Argument) -> BOOL { return msgSend(BOOL, self, "isActive") } @(objc_type=Argument, objc_name="isDepthTexture") -Argument_isDepthTexture :: #force_inline proc(self: ^Argument) -> BOOL { +Argument_isDepthTexture :: #force_inline proc "c" (self: ^Argument) -> BOOL { return msgSend(BOOL, self, "isDepthTexture") } @(objc_type=Argument, objc_name="name") -Argument_name :: #force_inline proc(self: ^Argument) -> ^NS.String { +Argument_name :: #force_inline proc "c" (self: ^Argument) -> ^NS.String { return msgSend(^NS.String, self, "name") } @(objc_type=Argument, objc_name="textureDataType") -Argument_textureDataType :: #force_inline proc(self: ^Argument) -> DataType { +Argument_textureDataType :: #force_inline proc "c" (self: ^Argument) -> DataType { return msgSend(DataType, self, "textureDataType") } @(objc_type=Argument, objc_name="textureType") -Argument_textureType :: #force_inline proc(self: ^Argument) -> TextureType { +Argument_textureType :: #force_inline proc "c" (self: ^Argument) -> TextureType { return msgSend(TextureType, self, "textureType") } @(objc_type=Argument, objc_name="threadgroupMemoryAlignment") -Argument_threadgroupMemoryAlignment :: #force_inline proc(self: ^Argument) -> NS.UInteger { +Argument_threadgroupMemoryAlignment :: #force_inline proc "c" (self: ^Argument) -> NS.UInteger { return msgSend(NS.UInteger, self, "threadgroupMemoryAlignment") } @(objc_type=Argument, objc_name="threadgroupMemoryDataSize") -Argument_threadgroupMemoryDataSize :: #force_inline proc(self: ^Argument) -> NS.UInteger { +Argument_threadgroupMemoryDataSize :: #force_inline proc "c" (self: ^Argument) -> NS.UInteger { return msgSend(NS.UInteger, self, "threadgroupMemoryDataSize") } @(objc_type=Argument, objc_name="type") -Argument_type :: #force_inline proc(self: ^Argument) -> ArgumentType { +Argument_type :: #force_inline proc "c" (self: ^Argument) -> ArgumentType { return msgSend(ArgumentType, self, "type") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - ArgumentDescriptor -Class Methods: - alloc - argumentDescriptor -Methods: - init - access - arrayLength - constantBlockAlignment - dataType - index - setAccess - setArrayLength - setConstantBlockAlignment - setDataType - setIndex - setTextureType - textureType -*/ + @(objc_class="MTLArgumentDescriptor") ArgumentDescriptor :: struct { using _: NS.Copying(ArgumentDescriptor) } @(objc_type=ArgumentDescriptor, objc_name="alloc", objc_is_class_method=true) -ArgumentDescriptor_alloc :: #force_inline proc() -> ^ArgumentDescriptor { +ArgumentDescriptor_alloc :: #force_inline proc "c" () -> ^ArgumentDescriptor { return msgSend(^ArgumentDescriptor, ArgumentDescriptor, "alloc") } @(objc_type=ArgumentDescriptor, objc_name="init") -ArgumentDescriptor_init :: #force_inline proc(self: ^ArgumentDescriptor) -> ^ArgumentDescriptor { +ArgumentDescriptor_init :: #force_inline proc "c" (self: ^ArgumentDescriptor) -> ^ArgumentDescriptor { return msgSend(^ArgumentDescriptor, self, "init") } @(objc_type=ArgumentDescriptor, objc_name="access") -ArgumentDescriptor_access :: #force_inline proc(self: ^ArgumentDescriptor) -> ArgumentAccess { +ArgumentDescriptor_access :: #force_inline proc "c" (self: ^ArgumentDescriptor) -> ArgumentAccess { return msgSend(ArgumentAccess, self, "access") } @(objc_type=ArgumentDescriptor, objc_name="argumentDescriptor", objc_is_class_method=true) -ArgumentDescriptor_argumentDescriptor :: #force_inline proc() -> ^ArgumentDescriptor { +ArgumentDescriptor_argumentDescriptor :: #force_inline proc "c" () -> ^ArgumentDescriptor { return msgSend(^ArgumentDescriptor, ArgumentDescriptor, "argumentDescriptor") } @(objc_type=ArgumentDescriptor, objc_name="arrayLength") -ArgumentDescriptor_arrayLength :: #force_inline proc(self: ^ArgumentDescriptor) -> NS.UInteger { +ArgumentDescriptor_arrayLength :: #force_inline proc "c" (self: ^ArgumentDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "arrayLength") } @(objc_type=ArgumentDescriptor, objc_name="constantBlockAlignment") -ArgumentDescriptor_constantBlockAlignment :: #force_inline proc(self: ^ArgumentDescriptor) -> NS.UInteger { +ArgumentDescriptor_constantBlockAlignment :: #force_inline proc "c" (self: ^ArgumentDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "constantBlockAlignment") } @(objc_type=ArgumentDescriptor, objc_name="dataType") -ArgumentDescriptor_dataType :: #force_inline proc(self: ^ArgumentDescriptor) -> DataType { +ArgumentDescriptor_dataType :: #force_inline proc "c" (self: ^ArgumentDescriptor) -> DataType { return msgSend(DataType, self, "dataType") } @(objc_type=ArgumentDescriptor, objc_name="index") -ArgumentDescriptor_index :: #force_inline proc(self: ^ArgumentDescriptor) -> NS.UInteger { +ArgumentDescriptor_index :: #force_inline proc "c" (self: ^ArgumentDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "index") } @(objc_type=ArgumentDescriptor, objc_name="setAccess") -ArgumentDescriptor_setAccess :: #force_inline proc(self: ^ArgumentDescriptor, access: ArgumentAccess) { +ArgumentDescriptor_setAccess :: #force_inline proc "c" (self: ^ArgumentDescriptor, access: ArgumentAccess) { msgSend(nil, self, "setAccess:", access) } @(objc_type=ArgumentDescriptor, objc_name="setArrayLength") -ArgumentDescriptor_setArrayLength :: #force_inline proc(self: ^ArgumentDescriptor, arrayLength: NS.UInteger) { +ArgumentDescriptor_setArrayLength :: #force_inline proc "c" (self: ^ArgumentDescriptor, arrayLength: NS.UInteger) { msgSend(nil, self, "setArrayLength:", arrayLength) } @(objc_type=ArgumentDescriptor, objc_name="setConstantBlockAlignment") -ArgumentDescriptor_setConstantBlockAlignment :: #force_inline proc(self: ^ArgumentDescriptor, constantBlockAlignment: NS.UInteger) { +ArgumentDescriptor_setConstantBlockAlignment :: #force_inline proc "c" (self: ^ArgumentDescriptor, constantBlockAlignment: NS.UInteger) { msgSend(nil, self, "setConstantBlockAlignment:", constantBlockAlignment) } @(objc_type=ArgumentDescriptor, objc_name="setDataType") -ArgumentDescriptor_setDataType :: #force_inline proc(self: ^ArgumentDescriptor, dataType: DataType) { +ArgumentDescriptor_setDataType :: #force_inline proc "c" (self: ^ArgumentDescriptor, dataType: DataType) { msgSend(nil, self, "setDataType:", dataType) } @(objc_type=ArgumentDescriptor, objc_name="setIndex") -ArgumentDescriptor_setIndex :: #force_inline proc(self: ^ArgumentDescriptor, index: NS.UInteger) { +ArgumentDescriptor_setIndex :: #force_inline proc "c" (self: ^ArgumentDescriptor, index: NS.UInteger) { msgSend(nil, self, "setIndex:", index) } @(objc_type=ArgumentDescriptor, objc_name="setTextureType") -ArgumentDescriptor_setTextureType :: #force_inline proc(self: ^ArgumentDescriptor, textureType: TextureType) { +ArgumentDescriptor_setTextureType :: #force_inline proc "c" (self: ^ArgumentDescriptor, textureType: TextureType) { msgSend(nil, self, "setTextureType:", textureType) } @(objc_type=ArgumentDescriptor, objc_name="textureType") -ArgumentDescriptor_textureType :: #force_inline proc(self: ^ArgumentDescriptor) -> TextureType { +ArgumentDescriptor_textureType :: #force_inline proc "c" (self: ^ArgumentDescriptor) -> TextureType { return msgSend(TextureType, self, "textureType") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - ArrayType -Class Methods: - alloc -Methods: - init - argumentIndexStride - arrayLength - elementArrayType - elementPointerType - elementStructType - elementTextureReferenceType - elementType - stride -*/ + @(objc_class="MTLArrayType") ArrayType :: struct { using _: Type } @(objc_type=ArrayType, objc_name="alloc", objc_is_class_method=true) -ArrayType_alloc :: #force_inline proc() -> ^ArrayType { +ArrayType_alloc :: #force_inline proc "c" () -> ^ArrayType { return msgSend(^ArrayType, ArrayType, "alloc") } @(objc_type=ArrayType, objc_name="init") -ArrayType_init :: #force_inline proc(self: ^ArrayType) -> ^ArrayType { +ArrayType_init :: #force_inline proc "c" (self: ^ArrayType) -> ^ArrayType { return msgSend(^ArrayType, self, "init") } @(objc_type=ArrayType, objc_name="argumentIndexStride") -ArrayType_argumentIndexStride :: #force_inline proc(self: ^ArrayType) -> NS.UInteger { +ArrayType_argumentIndexStride :: #force_inline proc "c" (self: ^ArrayType) -> NS.UInteger { return msgSend(NS.UInteger, self, "argumentIndexStride") } @(objc_type=ArrayType, objc_name="arrayLength") -ArrayType_arrayLength :: #force_inline proc(self: ^ArrayType) -> NS.UInteger { +ArrayType_arrayLength :: #force_inline proc "c" (self: ^ArrayType) -> NS.UInteger { return msgSend(NS.UInteger, self, "arrayLength") } @(objc_type=ArrayType, objc_name="elementArrayType") -ArrayType_elementArrayType :: #force_inline proc(self: ^ArrayType) -> ^ArrayType { +ArrayType_elementArrayType :: #force_inline proc "c" (self: ^ArrayType) -> ^ArrayType { return msgSend(^ArrayType, self, "elementArrayType") } @(objc_type=ArrayType, objc_name="elementPointerType") -ArrayType_elementPointerType :: #force_inline proc(self: ^ArrayType) -> ^PointerType { +ArrayType_elementPointerType :: #force_inline proc "c" (self: ^ArrayType) -> ^PointerType { return msgSend(^PointerType, self, "elementPointerType") } @(objc_type=ArrayType, objc_name="elementStructType") -ArrayType_elementStructType :: #force_inline proc(self: ^ArrayType) -> ^StructType { +ArrayType_elementStructType :: #force_inline proc "c" (self: ^ArrayType) -> ^StructType { return msgSend(^StructType, self, "elementStructType") } @(objc_type=ArrayType, objc_name="elementTextureReferenceType") -ArrayType_elementTextureReferenceType :: #force_inline proc(self: ^ArrayType) -> ^TextureReferenceType { +ArrayType_elementTextureReferenceType :: #force_inline proc "c" (self: ^ArrayType) -> ^TextureReferenceType { return msgSend(^TextureReferenceType, self, "elementTextureReferenceType") } @(objc_type=ArrayType, objc_name="elementType") -ArrayType_elementType :: #force_inline proc(self: ^ArrayType) -> DataType { +ArrayType_elementType :: #force_inline proc "c" (self: ^ArrayType) -> DataType { return msgSend(DataType, self, "elementType") } @(objc_type=ArrayType, objc_name="stride") -ArrayType_stride :: #force_inline proc(self: ^ArrayType) -> NS.UInteger { +ArrayType_stride :: #force_inline proc "c" (self: ^ArrayType) -> NS.UInteger { return msgSend(NS.UInteger, self, "stride") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - Attribute -Class Methods: - alloc -Methods: - init - attributeIndex - attributeType - isActive - isPatchControlPointData - isPatchData - name -*/ + @(objc_class="MTLAttribute") Attribute :: struct { using _: NS.Object } @(objc_type=Attribute, objc_name="alloc", objc_is_class_method=true) -Attribute_alloc :: #force_inline proc() -> ^Attribute { +Attribute_alloc :: #force_inline proc "c" () -> ^Attribute { return msgSend(^Attribute, Attribute, "alloc") } @(objc_type=Attribute, objc_name="init") -Attribute_init :: #force_inline proc(self: ^Attribute) -> ^Attribute { +Attribute_init :: #force_inline proc "c" (self: ^Attribute) -> ^Attribute { return msgSend(^Attribute, self, "init") } @(objc_type=Attribute, objc_name="attributeIndex") -Attribute_attributeIndex :: #force_inline proc(self: ^Attribute) -> NS.UInteger { +Attribute_attributeIndex :: #force_inline proc "c" (self: ^Attribute) -> NS.UInteger { return msgSend(NS.UInteger, self, "attributeIndex") } @(objc_type=Attribute, objc_name="attributeType") -Attribute_attributeType :: #force_inline proc(self: ^Attribute) -> DataType { +Attribute_attributeType :: #force_inline proc "c" (self: ^Attribute) -> DataType { return msgSend(DataType, self, "attributeType") } @(objc_type=Attribute, objc_name="isActive") -Attribute_isActive :: #force_inline proc(self: ^Attribute) -> BOOL { +Attribute_isActive :: #force_inline proc "c" (self: ^Attribute) -> BOOL { return msgSend(BOOL, self, "isActive") } @(objc_type=Attribute, objc_name="isPatchControlPointData") -Attribute_isPatchControlPointData :: #force_inline proc(self: ^Attribute) -> BOOL { +Attribute_isPatchControlPointData :: #force_inline proc "c" (self: ^Attribute) -> BOOL { return msgSend(BOOL, self, "isPatchControlPointData") } @(objc_type=Attribute, objc_name="isPatchData") -Attribute_isPatchData :: #force_inline proc(self: ^Attribute) -> BOOL { +Attribute_isPatchData :: #force_inline proc "c" (self: ^Attribute) -> BOOL { return msgSend(BOOL, self, "isPatchData") } @(objc_type=Attribute, objc_name="name") -Attribute_name :: #force_inline proc(self: ^Attribute) -> ^NS.String { +Attribute_name :: #force_inline proc "c" (self: ^Attribute) -> ^NS.String { return msgSend(^NS.String, self, "name") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - AttributeDescriptor -Class Methods: - alloc -Methods: - init - bufferIndex - format - offset - setBufferIndex - setFormat - setOffset -*/ + @(objc_class="MTLAttributeDescriptor") AttributeDescriptor :: struct { using _: NS.Copying(AttributeDescriptor) } @(objc_type=AttributeDescriptor, objc_name="alloc", objc_is_class_method=true) -AttributeDescriptor_alloc :: #force_inline proc() -> ^AttributeDescriptor { +AttributeDescriptor_alloc :: #force_inline proc "c" () -> ^AttributeDescriptor { return msgSend(^AttributeDescriptor, AttributeDescriptor, "alloc") } @(objc_type=AttributeDescriptor, objc_name="init") -AttributeDescriptor_init :: #force_inline proc(self: ^AttributeDescriptor) -> ^AttributeDescriptor { +AttributeDescriptor_init :: #force_inline proc "c" (self: ^AttributeDescriptor) -> ^AttributeDescriptor { return msgSend(^AttributeDescriptor, self, "init") } @(objc_type=AttributeDescriptor, objc_name="bufferIndex") -AttributeDescriptor_bufferIndex :: #force_inline proc(self: ^AttributeDescriptor) -> NS.UInteger { +AttributeDescriptor_bufferIndex :: #force_inline proc "c" (self: ^AttributeDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "bufferIndex") } @(objc_type=AttributeDescriptor, objc_name="format") -AttributeDescriptor_format :: #force_inline proc(self: ^AttributeDescriptor) -> AttributeFormat { +AttributeDescriptor_format :: #force_inline proc "c" (self: ^AttributeDescriptor) -> AttributeFormat { return msgSend(AttributeFormat, self, "format") } @(objc_type=AttributeDescriptor, objc_name="offset") -AttributeDescriptor_offset :: #force_inline proc(self: ^AttributeDescriptor) -> NS.UInteger { +AttributeDescriptor_offset :: #force_inline proc "c" (self: ^AttributeDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "offset") } @(objc_type=AttributeDescriptor, objc_name="setBufferIndex") -AttributeDescriptor_setBufferIndex :: #force_inline proc(self: ^AttributeDescriptor, bufferIndex: NS.UInteger) { +AttributeDescriptor_setBufferIndex :: #force_inline proc "c" (self: ^AttributeDescriptor, bufferIndex: NS.UInteger) { msgSend(nil, self, "setBufferIndex:", bufferIndex) } @(objc_type=AttributeDescriptor, objc_name="setFormat") -AttributeDescriptor_setFormat :: #force_inline proc(self: ^AttributeDescriptor, format: AttributeFormat) { +AttributeDescriptor_setFormat :: #force_inline proc "c" (self: ^AttributeDescriptor, format: AttributeFormat) { msgSend(nil, self, "setFormat:", format) } @(objc_type=AttributeDescriptor, objc_name="setOffset") -AttributeDescriptor_setOffset :: #force_inline proc(self: ^AttributeDescriptor, offset: NS.UInteger) { +AttributeDescriptor_setOffset :: #force_inline proc "c" (self: ^AttributeDescriptor, offset: NS.UInteger) { msgSend(nil, self, "setOffset:", offset) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - AttributeDescriptorArray -Class Methods: - alloc -Methods: - init - objectAtIndexedSubscript - setObject -*/ + @(objc_class="MTLAttributeDescriptorArray") AttributeDescriptorArray :: struct { using _: NS.Object } @(objc_type=AttributeDescriptorArray, objc_name="alloc", objc_is_class_method=true) -AttributeDescriptorArray_alloc :: #force_inline proc() -> ^AttributeDescriptorArray { +AttributeDescriptorArray_alloc :: #force_inline proc "c" () -> ^AttributeDescriptorArray { return msgSend(^AttributeDescriptorArray, AttributeDescriptorArray, "alloc") } @(objc_type=AttributeDescriptorArray, objc_name="init") -AttributeDescriptorArray_init :: #force_inline proc(self: ^AttributeDescriptorArray) -> ^AttributeDescriptorArray { +AttributeDescriptorArray_init :: #force_inline proc "c" (self: ^AttributeDescriptorArray) -> ^AttributeDescriptorArray { return msgSend(^AttributeDescriptorArray, self, "init") } @(objc_type=AttributeDescriptorArray, objc_name="object") -AttributeDescriptorArray_object :: #force_inline proc(self: ^AttributeDescriptorArray, index: NS.UInteger) -> ^AttributeDescriptor { +AttributeDescriptorArray_object :: #force_inline proc "c" (self: ^AttributeDescriptorArray, index: NS.UInteger) -> ^AttributeDescriptor { return msgSend(^AttributeDescriptor, self, "objectAtIndexedSubscript:", index) } @(objc_type=AttributeDescriptorArray, objc_name="setObject") -AttributeDescriptorArray_setObject :: #force_inline proc(self: ^AttributeDescriptorArray, attributeDesc: ^AttributeDescriptor, index: NS.UInteger) { +AttributeDescriptorArray_setObject :: #force_inline proc "c" (self: ^AttributeDescriptorArray, attributeDesc: ^AttributeDescriptor, index: NS.UInteger) { msgSend(nil, self, "setObject:atIndexedSubscript:", attributeDesc, index) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - BinaryArchiveDescriptor -Class Methods: - alloc -Methods: - init - setUrl - url -*/ + @(objc_class="MTLBinaryArchiveDescriptor") BinaryArchiveDescriptor :: struct { using _: NS.Copying(BinaryArchiveDescriptor) } @(objc_type=BinaryArchiveDescriptor, objc_name="alloc", objc_is_class_method=true) -BinaryArchiveDescriptor_alloc :: #force_inline proc() -> ^BinaryArchiveDescriptor { +BinaryArchiveDescriptor_alloc :: #force_inline proc "c" () -> ^BinaryArchiveDescriptor { return msgSend(^BinaryArchiveDescriptor, BinaryArchiveDescriptor, "alloc") } @(objc_type=BinaryArchiveDescriptor, objc_name="init") -BinaryArchiveDescriptor_init :: #force_inline proc(self: ^BinaryArchiveDescriptor) -> ^BinaryArchiveDescriptor { +BinaryArchiveDescriptor_init :: #force_inline proc "c" (self: ^BinaryArchiveDescriptor) -> ^BinaryArchiveDescriptor { return msgSend(^BinaryArchiveDescriptor, self, "init") } @(objc_type=BinaryArchiveDescriptor, objc_name="setUrl") -BinaryArchiveDescriptor_setUrl :: #force_inline proc(self: ^BinaryArchiveDescriptor, url: ^NS.URL) { +BinaryArchiveDescriptor_setUrl :: #force_inline proc "c" (self: ^BinaryArchiveDescriptor, url: ^NS.URL) { msgSend(nil, self, "setUrl:", url) } @(objc_type=BinaryArchiveDescriptor, objc_name="url") -BinaryArchiveDescriptor_url :: #force_inline proc(self: ^BinaryArchiveDescriptor) -> ^NS.URL { +BinaryArchiveDescriptor_url :: #force_inline proc "c" (self: ^BinaryArchiveDescriptor) -> ^NS.URL { return msgSend(^NS.URL, self, "url") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - BlitPassDescriptor -Class Methods: - alloc - blitPassDescriptor -Methods: - init - sampleBufferAttachments -*/ + @(objc_class="MTLBlitPassDescriptor") BlitPassDescriptor :: struct { using _: NS.Copying(BlitPassDescriptor) } @(objc_type=BlitPassDescriptor, objc_name="alloc", objc_is_class_method=true) -BlitPassDescriptor_alloc :: #force_inline proc() -> ^BlitPassDescriptor { +BlitPassDescriptor_alloc :: #force_inline proc "c" () -> ^BlitPassDescriptor { return msgSend(^BlitPassDescriptor, BlitPassDescriptor, "alloc") } @(objc_type=BlitPassDescriptor, objc_name="init") -BlitPassDescriptor_init :: #force_inline proc(self: ^BlitPassDescriptor) -> ^BlitPassDescriptor { +BlitPassDescriptor_init :: #force_inline proc "c" (self: ^BlitPassDescriptor) -> ^BlitPassDescriptor { return msgSend(^BlitPassDescriptor, self, "init") } @(objc_type=BlitPassDescriptor, objc_name="blitPassDescriptor", objc_is_class_method=true) -BlitPassDescriptor_blitPassDescriptor :: #force_inline proc() -> ^BlitPassDescriptor { +BlitPassDescriptor_blitPassDescriptor :: #force_inline proc "c" () -> ^BlitPassDescriptor { return msgSend(^BlitPassDescriptor, BlitPassDescriptor, "blitPassDescriptor") } @(objc_type=BlitPassDescriptor, objc_name="sampleBufferAttachments") -BlitPassDescriptor_sampleBufferAttachments :: #force_inline proc(self: ^BlitPassDescriptor) -> ^BlitPassSampleBufferAttachmentDescriptorArray { +BlitPassDescriptor_sampleBufferAttachments :: #force_inline proc "c" (self: ^BlitPassDescriptor) -> ^BlitPassSampleBufferAttachmentDescriptorArray { return msgSend(^BlitPassSampleBufferAttachmentDescriptorArray, self, "sampleBufferAttachments") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - BlitPassSampleBufferAttachmentDescriptor -Class Methods: - alloc -Methods: - init - endOfEncoderSampleIndex - sampleBuffer - setEndOfEncoderSampleIndex - setSampleBuffer - setStartOfEncoderSampleIndex - startOfEncoderSampleIndex -*/ + @(objc_class="MTLBlitPassSampleBufferAttachmentDescriptor") BlitPassSampleBufferAttachmentDescriptor :: struct { using _: NS.Copying(BlitPassSampleBufferAttachmentDescriptor) } @(objc_type=BlitPassSampleBufferAttachmentDescriptor, objc_name="alloc", objc_is_class_method=true) -BlitPassSampleBufferAttachmentDescriptor_alloc :: #force_inline proc() -> ^BlitPassSampleBufferAttachmentDescriptor { +BlitPassSampleBufferAttachmentDescriptor_alloc :: #force_inline proc "c" () -> ^BlitPassSampleBufferAttachmentDescriptor { return msgSend(^BlitPassSampleBufferAttachmentDescriptor, BlitPassSampleBufferAttachmentDescriptor, "alloc") } @(objc_type=BlitPassSampleBufferAttachmentDescriptor, objc_name="init") -BlitPassSampleBufferAttachmentDescriptor_init :: #force_inline proc(self: ^BlitPassSampleBufferAttachmentDescriptor) -> ^BlitPassSampleBufferAttachmentDescriptor { +BlitPassSampleBufferAttachmentDescriptor_init :: #force_inline proc "c" (self: ^BlitPassSampleBufferAttachmentDescriptor) -> ^BlitPassSampleBufferAttachmentDescriptor { return msgSend(^BlitPassSampleBufferAttachmentDescriptor, self, "init") } @(objc_type=BlitPassSampleBufferAttachmentDescriptor, objc_name="endOfEncoderSampleIndex") -BlitPassSampleBufferAttachmentDescriptor_endOfEncoderSampleIndex :: #force_inline proc(self: ^BlitPassSampleBufferAttachmentDescriptor) -> NS.UInteger { +BlitPassSampleBufferAttachmentDescriptor_endOfEncoderSampleIndex :: #force_inline proc "c" (self: ^BlitPassSampleBufferAttachmentDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "endOfEncoderSampleIndex") } @(objc_type=BlitPassSampleBufferAttachmentDescriptor, objc_name="sampleBuffer") -BlitPassSampleBufferAttachmentDescriptor_sampleBuffer :: #force_inline proc(self: ^BlitPassSampleBufferAttachmentDescriptor) -> ^CounterSampleBuffer { +BlitPassSampleBufferAttachmentDescriptor_sampleBuffer :: #force_inline proc "c" (self: ^BlitPassSampleBufferAttachmentDescriptor) -> ^CounterSampleBuffer { return msgSend(^CounterSampleBuffer, self, "sampleBuffer") } @(objc_type=BlitPassSampleBufferAttachmentDescriptor, objc_name="setEndOfEncoderSampleIndex") -BlitPassSampleBufferAttachmentDescriptor_setEndOfEncoderSampleIndex :: #force_inline proc(self: ^BlitPassSampleBufferAttachmentDescriptor, endOfEncoderSampleIndex: NS.UInteger) { +BlitPassSampleBufferAttachmentDescriptor_setEndOfEncoderSampleIndex :: #force_inline proc "c" (self: ^BlitPassSampleBufferAttachmentDescriptor, endOfEncoderSampleIndex: NS.UInteger) { msgSend(nil, self, "setEndOfEncoderSampleIndex:", endOfEncoderSampleIndex) } @(objc_type=BlitPassSampleBufferAttachmentDescriptor, objc_name="setSampleBuffer") -BlitPassSampleBufferAttachmentDescriptor_setSampleBuffer :: #force_inline proc(self: ^BlitPassSampleBufferAttachmentDescriptor, sampleBuffer: ^CounterSampleBuffer) { +BlitPassSampleBufferAttachmentDescriptor_setSampleBuffer :: #force_inline proc "c" (self: ^BlitPassSampleBufferAttachmentDescriptor, sampleBuffer: ^CounterSampleBuffer) { msgSend(nil, self, "setSampleBuffer:", sampleBuffer) } @(objc_type=BlitPassSampleBufferAttachmentDescriptor, objc_name="setStartOfEncoderSampleIndex") -BlitPassSampleBufferAttachmentDescriptor_setStartOfEncoderSampleIndex :: #force_inline proc(self: ^BlitPassSampleBufferAttachmentDescriptor, startOfEncoderSampleIndex: NS.UInteger) { +BlitPassSampleBufferAttachmentDescriptor_setStartOfEncoderSampleIndex :: #force_inline proc "c" (self: ^BlitPassSampleBufferAttachmentDescriptor, startOfEncoderSampleIndex: NS.UInteger) { msgSend(nil, self, "setStartOfEncoderSampleIndex:", startOfEncoderSampleIndex) } @(objc_type=BlitPassSampleBufferAttachmentDescriptor, objc_name="startOfEncoderSampleIndex") -BlitPassSampleBufferAttachmentDescriptor_startOfEncoderSampleIndex :: #force_inline proc(self: ^BlitPassSampleBufferAttachmentDescriptor) -> NS.UInteger { +BlitPassSampleBufferAttachmentDescriptor_startOfEncoderSampleIndex :: #force_inline proc "c" (self: ^BlitPassSampleBufferAttachmentDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "startOfEncoderSampleIndex") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - BlitPassSampleBufferAttachmentDescriptorArray -Class Methods: - alloc -Methods: - init - objectAtIndexedSubscript - setObject -*/ + @(objc_class="MTLBlitPassSampleBufferAttachmentDescriptorArray") BlitPassSampleBufferAttachmentDescriptorArray :: struct { using _: NS.Object } @(objc_type=BlitPassSampleBufferAttachmentDescriptorArray, objc_name="alloc", objc_is_class_method=true) -BlitPassSampleBufferAttachmentDescriptorArray_alloc :: #force_inline proc() -> ^BlitPassSampleBufferAttachmentDescriptorArray { +BlitPassSampleBufferAttachmentDescriptorArray_alloc :: #force_inline proc "c" () -> ^BlitPassSampleBufferAttachmentDescriptorArray { return msgSend(^BlitPassSampleBufferAttachmentDescriptorArray, BlitPassSampleBufferAttachmentDescriptorArray, "alloc") } @(objc_type=BlitPassSampleBufferAttachmentDescriptorArray, objc_name="init") -BlitPassSampleBufferAttachmentDescriptorArray_init :: #force_inline proc(self: ^BlitPassSampleBufferAttachmentDescriptorArray) -> ^BlitPassSampleBufferAttachmentDescriptorArray { +BlitPassSampleBufferAttachmentDescriptorArray_init :: #force_inline proc "c" (self: ^BlitPassSampleBufferAttachmentDescriptorArray) -> ^BlitPassSampleBufferAttachmentDescriptorArray { return msgSend(^BlitPassSampleBufferAttachmentDescriptorArray, self, "init") } @(objc_type=BlitPassSampleBufferAttachmentDescriptorArray, objc_name="object") -BlitPassSampleBufferAttachmentDescriptorArray_object :: #force_inline proc(self: ^BlitPassSampleBufferAttachmentDescriptorArray, attachmentIndex: NS.UInteger) -> ^BlitPassSampleBufferAttachmentDescriptor { +BlitPassSampleBufferAttachmentDescriptorArray_object :: #force_inline proc "c" (self: ^BlitPassSampleBufferAttachmentDescriptorArray, attachmentIndex: NS.UInteger) -> ^BlitPassSampleBufferAttachmentDescriptor { return msgSend(^BlitPassSampleBufferAttachmentDescriptor, self, "objectAtIndexedSubscript:", attachmentIndex) } @(objc_type=BlitPassSampleBufferAttachmentDescriptorArray, objc_name="setObject") -BlitPassSampleBufferAttachmentDescriptorArray_setObject :: #force_inline proc(self: ^BlitPassSampleBufferAttachmentDescriptorArray, attachment: ^BlitPassSampleBufferAttachmentDescriptor, attachmentIndex: NS.UInteger) { +BlitPassSampleBufferAttachmentDescriptorArray_setObject :: #force_inline proc "c" (self: ^BlitPassSampleBufferAttachmentDescriptorArray, attachment: ^BlitPassSampleBufferAttachmentDescriptor, attachmentIndex: NS.UInteger) { msgSend(nil, self, "setObject:atIndexedSubscript:", attachment, attachmentIndex) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - BufferLayoutDescriptor -Class Methods: - alloc -Methods: - init - setStepFunction - setStepRate - setStride - stepFunction - stepRate - stride -*/ + @(objc_class="MTLBufferLayoutDescriptor") BufferLayoutDescriptor :: struct { using _: NS.Copying(BufferLayoutDescriptor) } @(objc_type=BufferLayoutDescriptor, objc_name="alloc", objc_is_class_method=true) -BufferLayoutDescriptor_alloc :: #force_inline proc() -> ^BufferLayoutDescriptor { +BufferLayoutDescriptor_alloc :: #force_inline proc "c" () -> ^BufferLayoutDescriptor { return msgSend(^BufferLayoutDescriptor, BufferLayoutDescriptor, "alloc") } @(objc_type=BufferLayoutDescriptor, objc_name="init") -BufferLayoutDescriptor_init :: #force_inline proc(self: ^BufferLayoutDescriptor) -> ^BufferLayoutDescriptor { +BufferLayoutDescriptor_init :: #force_inline proc "c" (self: ^BufferLayoutDescriptor) -> ^BufferLayoutDescriptor { return msgSend(^BufferLayoutDescriptor, self, "init") } @(objc_type=BufferLayoutDescriptor, objc_name="setStepFunction") -BufferLayoutDescriptor_setStepFunction :: #force_inline proc(self: ^BufferLayoutDescriptor, stepFunction: StepFunction) { +BufferLayoutDescriptor_setStepFunction :: #force_inline proc "c" (self: ^BufferLayoutDescriptor, stepFunction: StepFunction) { msgSend(nil, self, "setStepFunction:", stepFunction) } @(objc_type=BufferLayoutDescriptor, objc_name="setStepRate") -BufferLayoutDescriptor_setStepRate :: #force_inline proc(self: ^BufferLayoutDescriptor, stepRate: NS.UInteger) { +BufferLayoutDescriptor_setStepRate :: #force_inline proc "c" (self: ^BufferLayoutDescriptor, stepRate: NS.UInteger) { msgSend(nil, self, "setStepRate:", stepRate) } @(objc_type=BufferLayoutDescriptor, objc_name="setStride") -BufferLayoutDescriptor_setStride :: #force_inline proc(self: ^BufferLayoutDescriptor, stride: NS.UInteger) { +BufferLayoutDescriptor_setStride :: #force_inline proc "c" (self: ^BufferLayoutDescriptor, stride: NS.UInteger) { msgSend(nil, self, "setStride:", stride) } @(objc_type=BufferLayoutDescriptor, objc_name="stepFunction") -BufferLayoutDescriptor_stepFunction :: #force_inline proc(self: ^BufferLayoutDescriptor) -> StepFunction { +BufferLayoutDescriptor_stepFunction :: #force_inline proc "c" (self: ^BufferLayoutDescriptor) -> StepFunction { return msgSend(StepFunction, self, "stepFunction") } @(objc_type=BufferLayoutDescriptor, objc_name="stepRate") -BufferLayoutDescriptor_stepRate :: #force_inline proc(self: ^BufferLayoutDescriptor) -> NS.UInteger { +BufferLayoutDescriptor_stepRate :: #force_inline proc "c" (self: ^BufferLayoutDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "stepRate") } @(objc_type=BufferLayoutDescriptor, objc_name="stride") -BufferLayoutDescriptor_stride :: #force_inline proc(self: ^BufferLayoutDescriptor) -> NS.UInteger { +BufferLayoutDescriptor_stride :: #force_inline proc "c" (self: ^BufferLayoutDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "stride") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - BufferLayoutDescriptorArray -Class Methods: - alloc -Methods: - init - objectAtIndexedSubscript - setObject -*/ + @(objc_class="MTLBufferLayoutDescriptorArray") BufferLayoutDescriptorArray :: struct { using _: NS.Object } @(objc_type=BufferLayoutDescriptorArray, objc_name="alloc", objc_is_class_method=true) -BufferLayoutDescriptorArray_alloc :: #force_inline proc() -> ^BufferLayoutDescriptorArray { +BufferLayoutDescriptorArray_alloc :: #force_inline proc "c" () -> ^BufferLayoutDescriptorArray { return msgSend(^BufferLayoutDescriptorArray, BufferLayoutDescriptorArray, "alloc") } @(objc_type=BufferLayoutDescriptorArray, objc_name="init") -BufferLayoutDescriptorArray_init :: #force_inline proc(self: ^BufferLayoutDescriptorArray) -> ^BufferLayoutDescriptorArray { +BufferLayoutDescriptorArray_init :: #force_inline proc "c" (self: ^BufferLayoutDescriptorArray) -> ^BufferLayoutDescriptorArray { return msgSend(^BufferLayoutDescriptorArray, self, "init") } @(objc_type=BufferLayoutDescriptorArray, objc_name="object") -BufferLayoutDescriptorArray_object :: #force_inline proc(self: ^BufferLayoutDescriptorArray, index: NS.UInteger) -> ^BufferLayoutDescriptor { +BufferLayoutDescriptorArray_object :: #force_inline proc "c" (self: ^BufferLayoutDescriptorArray, index: NS.UInteger) -> ^BufferLayoutDescriptor { return msgSend(^BufferLayoutDescriptor, self, "objectAtIndexedSubscript:", index) } @(objc_type=BufferLayoutDescriptorArray, objc_name="setObject") -BufferLayoutDescriptorArray_setObject :: #force_inline proc(self: ^BufferLayoutDescriptorArray, bufferDesc: ^BufferLayoutDescriptor, index: NS.UInteger) { +BufferLayoutDescriptorArray_setObject :: #force_inline proc "c" (self: ^BufferLayoutDescriptorArray, bufferDesc: ^BufferLayoutDescriptor, index: NS.UInteger) { msgSend(nil, self, "setObject:atIndexedSubscript:", bufferDesc, index) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - CaptureDescriptor -Class Methods: - alloc -Methods: - init - captureObject - destination - outputURL - setCaptureObject - setDestination - setOutputURL -*/ + @(objc_class="MTLCaptureDescriptor") CaptureDescriptor :: struct { using _: NS.Copying(CaptureDescriptor) } @(objc_type=CaptureDescriptor, objc_name="alloc", objc_is_class_method=true) -CaptureDescriptor_alloc :: #force_inline proc() -> ^CaptureDescriptor { +CaptureDescriptor_alloc :: #force_inline proc "c" () -> ^CaptureDescriptor { return msgSend(^CaptureDescriptor, CaptureDescriptor, "alloc") } @(objc_type=CaptureDescriptor, objc_name="init") -CaptureDescriptor_init :: #force_inline proc(self: ^CaptureDescriptor) -> ^CaptureDescriptor { +CaptureDescriptor_init :: #force_inline proc "c" (self: ^CaptureDescriptor) -> ^CaptureDescriptor { return msgSend(^CaptureDescriptor, self, "init") } @(objc_type=CaptureDescriptor, objc_name="captureObject") -CaptureDescriptor_captureObject :: #force_inline proc(self: ^CaptureDescriptor) -> id { +CaptureDescriptor_captureObject :: #force_inline proc "c" (self: ^CaptureDescriptor) -> id { return msgSend(id, self, "captureObject") } @(objc_type=CaptureDescriptor, objc_name="destination") -CaptureDescriptor_destination :: #force_inline proc(self: ^CaptureDescriptor) -> CaptureDestination { +CaptureDescriptor_destination :: #force_inline proc "c" (self: ^CaptureDescriptor) -> CaptureDestination { return msgSend(CaptureDestination, self, "destination") } @(objc_type=CaptureDescriptor, objc_name="outputURL") -CaptureDescriptor_outputURL :: #force_inline proc(self: ^CaptureDescriptor) -> ^NS.URL { +CaptureDescriptor_outputURL :: #force_inline proc "c" (self: ^CaptureDescriptor) -> ^NS.URL { return msgSend(^NS.URL, self, "outputURL") } @(objc_type=CaptureDescriptor, objc_name="setCaptureObject") -CaptureDescriptor_setCaptureObject :: #force_inline proc(self: ^CaptureDescriptor, captureObject: id) { +CaptureDescriptor_setCaptureObject :: #force_inline proc "c" (self: ^CaptureDescriptor, captureObject: id) { msgSend(nil, self, "setCaptureObject:", captureObject) } @(objc_type=CaptureDescriptor, objc_name="setDestination") -CaptureDescriptor_setDestination :: #force_inline proc(self: ^CaptureDescriptor, destination: CaptureDestination) { +CaptureDescriptor_setDestination :: #force_inline proc "c" (self: ^CaptureDescriptor, destination: CaptureDestination) { msgSend(nil, self, "setDestination:", destination) } @(objc_type=CaptureDescriptor, objc_name="setOutputURL") -CaptureDescriptor_setOutputURL :: #force_inline proc(self: ^CaptureDescriptor, outputURL: ^NS.URL) { +CaptureDescriptor_setOutputURL :: #force_inline proc "c" (self: ^CaptureDescriptor, outputURL: ^NS.URL) { msgSend(nil, self, "setOutputURL:", outputURL) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - CaptureManager -Class Methods: - alloc - sharedCaptureManager -Methods: - defaultCaptureScope - init - isCapturing - newCaptureScopeWithCommandQueue - newCaptureScopeWithDevice - setDefaultCaptureScope - startCaptureWithCommandQueue - startCaptureWithDescriptor - startCaptureWithDevice - startCaptureWithScope - stopCapture - supportsDestination -*/ + @(objc_class="MTLCaptureManager") CaptureManager :: struct { using _: NS.Object } @(objc_type=CaptureManager, objc_name="alloc", objc_is_class_method=true) -CaptureManager_alloc :: #force_inline proc() -> ^CaptureManager { +CaptureManager_alloc :: #force_inline proc "c" () -> ^CaptureManager { return msgSend(^CaptureManager, CaptureManager, "alloc") } @(objc_type=CaptureManager, objc_name="defaultCaptureScope") -CaptureManager_defaultCaptureScope :: #force_inline proc(self: ^CaptureManager) -> ^CaptureManager { +CaptureManager_defaultCaptureScope :: #force_inline proc "c" (self: ^CaptureManager) -> ^CaptureManager { return msgSend(^CaptureManager, self, "defaultCaptureScope") } @(objc_type=CaptureManager, objc_name="init") -CaptureManager_init :: #force_inline proc(self: ^CaptureManager) -> ^CaptureManager { +CaptureManager_init :: #force_inline proc "c" (self: ^CaptureManager) -> ^CaptureManager { return msgSend(^CaptureManager, self, "init") } @(objc_type=CaptureManager, objc_name="isCapturing") -CaptureManager_isCapturing :: #force_inline proc(self: ^CaptureManager) -> BOOL { +CaptureManager_isCapturing :: #force_inline proc "c" (self: ^CaptureManager) -> BOOL { return msgSend(BOOL, self, "isCapturing") } @(objc_type=CaptureManager, objc_name="newCaptureScopeWithCommandQueue") -CaptureManager_newCaptureScopeWithCommandQueue :: #force_inline proc(self: ^CaptureManager, commandQueue: ^CommandQueue) -> ^CaptureScope { +CaptureManager_newCaptureScopeWithCommandQueue :: #force_inline proc "c" (self: ^CaptureManager, commandQueue: ^CommandQueue) -> ^CaptureScope { return msgSend(^CaptureScope, self, "newCaptureScopeWithCommandQueue:", commandQueue) } @(objc_type=CaptureManager, objc_name="newCaptureScopeWithDevice") -CaptureManager_newCaptureScopeWithDevice :: #force_inline proc(self: ^CaptureManager, device: ^Device) -> ^CaptureScope { +CaptureManager_newCaptureScopeWithDevice :: #force_inline proc "c" (self: ^CaptureManager, device: ^Device) -> ^CaptureScope { return msgSend(^CaptureScope, self, "newCaptureScopeWithDevice:", device) } @(objc_type=CaptureManager, objc_name="newCaptureScope") @@ -1159,1051 +979,842 @@ CaptureManager_newCaptureScope :: proc{ } @(objc_type=CaptureManager, objc_name="setDefaultCaptureScope") -CaptureManager_setDefaultCaptureScope :: #force_inline proc(self: ^CaptureManager, defaultCaptureScope: ^CaptureScope) { +CaptureManager_setDefaultCaptureScope :: #force_inline proc "c" (self: ^CaptureManager, defaultCaptureScope: ^CaptureScope) { msgSend(nil, self, "setDefaultCaptureScope:", defaultCaptureScope) } @(objc_type=CaptureManager, objc_name="sharedCaptureManager", objc_is_class_method=true) -CaptureManager_sharedCaptureManager :: #force_inline proc() -> ^CaptureManager { +CaptureManager_sharedCaptureManager :: #force_inline proc "c" () -> ^CaptureManager { return msgSend(^CaptureManager, CaptureManager, "sharedCaptureManager") } @(objc_type=CaptureManager, objc_name="startCaptureWithCommandQueue") -CaptureManager_startCaptureWithCommandQueue :: #force_inline proc(self: ^CaptureManager, commandQueue: ^CommandQueue) { +CaptureManager_startCaptureWithCommandQueue :: #force_inline proc "c" (self: ^CaptureManager, commandQueue: ^CommandQueue) { msgSend(nil, self, "startCaptureWithCommandQueue:", commandQueue) } @(objc_type=CaptureManager, objc_name="startCaptureWithDescriptor") -CaptureManager_startCaptureWithDescriptor :: #force_inline proc(self: ^CaptureManager, descriptor: ^CaptureDescriptor) -> (ok: BOOL, error: ^NS.Error) { +CaptureManager_startCaptureWithDescriptor :: #force_inline proc "contextless" (self: ^CaptureManager, descriptor: ^CaptureDescriptor) -> (ok: BOOL, error: ^NS.Error) { ok = msgSend(BOOL, self, "startCaptureWithDescriptor:error:", descriptor, &error) return } @(objc_type=CaptureManager, objc_name="startCaptureWithDevice") -CaptureManager_startCaptureWithDevice :: #force_inline proc(self: ^CaptureManager, device: ^Device) { +CaptureManager_startCaptureWithDevice :: #force_inline proc "c" (self: ^CaptureManager, device: ^Device) { msgSend(nil, self, "startCaptureWithDevice:", device) } @(objc_type=CaptureManager, objc_name="startCaptureWithScope") -CaptureManager_startCaptureWithScope :: #force_inline proc(self: ^CaptureManager, captureScope: ^CaptureScope) { +CaptureManager_startCaptureWithScope :: #force_inline proc "c" (self: ^CaptureManager, captureScope: ^CaptureScope) { msgSend(nil, self, "startCaptureWithScope:", captureScope) } @(objc_type=CaptureManager, objc_name="stopCapture") -CaptureManager_stopCapture :: #force_inline proc(self: ^CaptureManager) { +CaptureManager_stopCapture :: #force_inline proc "c" (self: ^CaptureManager) { msgSend(nil, self, "stopCapture") } @(objc_type=CaptureManager, objc_name="supportsDestination") -CaptureManager_supportsDestination :: #force_inline proc(self: ^CaptureManager, destination: CaptureDestination) -> BOOL { +CaptureManager_supportsDestination :: #force_inline proc "c" (self: ^CaptureManager, destination: CaptureDestination) -> BOOL { return msgSend(BOOL, self, "supportsDestination:", destination) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - CommandBufferDescriptor -Class Methods: - alloc -Methods: - init - errorOptions - retainedReferences - setErrorOptions - setRetainedReferences -*/ + @(objc_class="MTLCommandBufferDescriptor") CommandBufferDescriptor :: struct { using _: NS.Copying(CommandBufferDescriptor) } @(objc_type=CommandBufferDescriptor, objc_name="alloc", objc_is_class_method=true) -CommandBufferDescriptor_alloc :: #force_inline proc() -> ^CommandBufferDescriptor { +CommandBufferDescriptor_alloc :: #force_inline proc "c" () -> ^CommandBufferDescriptor { return msgSend(^CommandBufferDescriptor, CommandBufferDescriptor, "alloc") } @(objc_type=CommandBufferDescriptor, objc_name="init") -CommandBufferDescriptor_init :: #force_inline proc(self: ^CommandBufferDescriptor) -> ^CommandBufferDescriptor { +CommandBufferDescriptor_init :: #force_inline proc "c" (self: ^CommandBufferDescriptor) -> ^CommandBufferDescriptor { return msgSend(^CommandBufferDescriptor, self, "init") } @(objc_type=CommandBufferDescriptor, objc_name="errorOptions") -CommandBufferDescriptor_errorOptions :: #force_inline proc(self: ^CommandBufferDescriptor) -> CommandBufferErrorOption { +CommandBufferDescriptor_errorOptions :: #force_inline proc "c" (self: ^CommandBufferDescriptor) -> CommandBufferErrorOption { return msgSend(CommandBufferErrorOption, self, "errorOptions") } @(objc_type=CommandBufferDescriptor, objc_name="retainedReferences") -CommandBufferDescriptor_retainedReferences :: #force_inline proc(self: ^CommandBufferDescriptor) -> BOOL { +CommandBufferDescriptor_retainedReferences :: #force_inline proc "c" (self: ^CommandBufferDescriptor) -> BOOL { return msgSend(BOOL, self, "retainedReferences") } @(objc_type=CommandBufferDescriptor, objc_name="setErrorOptions") -CommandBufferDescriptor_setErrorOptions :: #force_inline proc(self: ^CommandBufferDescriptor, errorOptions: CommandBufferErrorOption) { +CommandBufferDescriptor_setErrorOptions :: #force_inline proc "c" (self: ^CommandBufferDescriptor, errorOptions: CommandBufferErrorOption) { msgSend(nil, self, "setErrorOptions:", errorOptions) } @(objc_type=CommandBufferDescriptor, objc_name="setRetainedReferences") -CommandBufferDescriptor_setRetainedReferences :: #force_inline proc(self: ^CommandBufferDescriptor, retainedReferences: BOOL) { +CommandBufferDescriptor_setRetainedReferences :: #force_inline proc "c" (self: ^CommandBufferDescriptor, retainedReferences: BOOL) { msgSend(nil, self, "setRetainedReferences:", retainedReferences) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - CompileOptions -Class Methods: - alloc -Methods: - init - fastMathEnabled - installName - languageVersion - libraries - libraryType - preprocessorMacros - preserveInvariance - setFastMathEnabled - setInstallName - setLanguageVersion - setLibraries - setLibraryType - setPreprocessorMacros - setPreserveInvariance -*/ + @(objc_class="MTLCompileOptions") CompileOptions :: struct { using _: NS.Copying(CompileOptions) } @(objc_type=CompileOptions, objc_name="alloc", objc_is_class_method=true) -CompileOptions_alloc :: #force_inline proc() -> ^CompileOptions { +CompileOptions_alloc :: #force_inline proc "c" () -> ^CompileOptions { return msgSend(^CompileOptions, CompileOptions, "alloc") } @(objc_type=CompileOptions, objc_name="init") -CompileOptions_init :: #force_inline proc(self: ^CompileOptions) -> ^CompileOptions { +CompileOptions_init :: #force_inline proc "c" (self: ^CompileOptions) -> ^CompileOptions { return msgSend(^CompileOptions, self, "init") } @(objc_type=CompileOptions, objc_name="fastMathEnabled") -CompileOptions_fastMathEnabled :: #force_inline proc(self: ^CompileOptions) -> BOOL { +CompileOptions_fastMathEnabled :: #force_inline proc "c" (self: ^CompileOptions) -> BOOL { return msgSend(BOOL, self, "fastMathEnabled") } @(objc_type=CompileOptions, objc_name="installName") -CompileOptions_installName :: #force_inline proc(self: ^CompileOptions) -> ^NS.String { +CompileOptions_installName :: #force_inline proc "c" (self: ^CompileOptions) -> ^NS.String { return msgSend(^NS.String, self, "installName") } @(objc_type=CompileOptions, objc_name="languageVersion") -CompileOptions_languageVersion :: #force_inline proc(self: ^CompileOptions) -> LanguageVersion { +CompileOptions_languageVersion :: #force_inline proc "c" (self: ^CompileOptions) -> LanguageVersion { return msgSend(LanguageVersion, self, "languageVersion") } @(objc_type=CompileOptions, objc_name="libraries") -CompileOptions_libraries :: #force_inline proc(self: ^CompileOptions) -> ^NS.Array { +CompileOptions_libraries :: #force_inline proc "c" (self: ^CompileOptions) -> ^NS.Array { return msgSend(^NS.Array, self, "libraries") } @(objc_type=CompileOptions, objc_name="libraryType") -CompileOptions_libraryType :: #force_inline proc(self: ^CompileOptions) -> LibraryType { +CompileOptions_libraryType :: #force_inline proc "c" (self: ^CompileOptions) -> LibraryType { return msgSend(LibraryType, self, "libraryType") } @(objc_type=CompileOptions, objc_name="preprocessorMacros") -CompileOptions_preprocessorMacros :: #force_inline proc(self: ^CompileOptions) -> ^NS.Dictionary { +CompileOptions_preprocessorMacros :: #force_inline proc "c" (self: ^CompileOptions) -> ^NS.Dictionary { return msgSend(^NS.Dictionary, self, "preprocessorMacros") } @(objc_type=CompileOptions, objc_name="preserveInvariance") -CompileOptions_preserveInvariance :: #force_inline proc(self: ^CompileOptions) -> BOOL { +CompileOptions_preserveInvariance :: #force_inline proc "c" (self: ^CompileOptions) -> BOOL { return msgSend(BOOL, self, "preserveInvariance") } @(objc_type=CompileOptions, objc_name="setFastMathEnabled") -CompileOptions_setFastMathEnabled :: #force_inline proc(self: ^CompileOptions, fastMathEnabled: BOOL) { +CompileOptions_setFastMathEnabled :: #force_inline proc "c" (self: ^CompileOptions, fastMathEnabled: BOOL) { msgSend(nil, self, "setFastMathEnabled:", fastMathEnabled) } @(objc_type=CompileOptions, objc_name="setInstallName") -CompileOptions_setInstallName :: #force_inline proc(self: ^CompileOptions, installName: ^NS.String) { +CompileOptions_setInstallName :: #force_inline proc "c" (self: ^CompileOptions, installName: ^NS.String) { msgSend(nil, self, "setInstallName:", installName) } @(objc_type=CompileOptions, objc_name="setLanguageVersion") -CompileOptions_setLanguageVersion :: #force_inline proc(self: ^CompileOptions, languageVersion: LanguageVersion) { +CompileOptions_setLanguageVersion :: #force_inline proc "c" (self: ^CompileOptions, languageVersion: LanguageVersion) { msgSend(nil, self, "setLanguageVersion:", languageVersion) } @(objc_type=CompileOptions, objc_name="setLibraries") -CompileOptions_setLibraries :: #force_inline proc(self: ^CompileOptions, libraries: ^NS.Array) { +CompileOptions_setLibraries :: #force_inline proc "c" (self: ^CompileOptions, libraries: ^NS.Array) { msgSend(nil, self, "setLibraries:", libraries) } @(objc_type=CompileOptions, objc_name="setLibraryType") -CompileOptions_setLibraryType :: #force_inline proc(self: ^CompileOptions, libraryType: LibraryType) { +CompileOptions_setLibraryType :: #force_inline proc "c" (self: ^CompileOptions, libraryType: LibraryType) { msgSend(nil, self, "setLibraryType:", libraryType) } @(objc_type=CompileOptions, objc_name="setPreprocessorMacros") -CompileOptions_setPreprocessorMacros :: #force_inline proc(self: ^CompileOptions, preprocessorMacros: ^NS.Dictionary) { +CompileOptions_setPreprocessorMacros :: #force_inline proc "c" (self: ^CompileOptions, preprocessorMacros: ^NS.Dictionary) { msgSend(nil, self, "setPreprocessorMacros:", preprocessorMacros) } @(objc_type=CompileOptions, objc_name="setPreserveInvariance") -CompileOptions_setPreserveInvariance :: #force_inline proc(self: ^CompileOptions, preserveInvariance: BOOL) { +CompileOptions_setPreserveInvariance :: #force_inline proc "c" (self: ^CompileOptions, preserveInvariance: BOOL) { msgSend(nil, self, "setPreserveInvariance:", preserveInvariance) } +@(objc_type=CompileOptions, objc_name="optimizationLevel") +CompileOptions_optimizationLevel :: #force_inline proc "c" (self: ^CompileOptions) -> LibraryOptimizationLevel { + return msgSend(LibraryOptimizationLevel, self, "optimizationLevel") +} +@(objc_type=CompileOptions, objc_name="setOptimizationLevel") +CompileOptions_setOptimizationLevel :: #force_inline proc "c" (self: ^CompileOptions, optimizationLevel: LibraryOptimizationLevel) { + msgSend(nil, self, "setOptimizationLevel:", optimizationLevel) +} + //////////////////////////////////////////////////////////////////////////////// -/* -Class: - ComputePassDescriptor -Class Methods: - alloc - computePassDescriptor -Methods: - init - dispatchType - sampleBufferAttachments - setDispatchType -*/ + @(objc_class="MTLComputePassDescriptor") ComputePassDescriptor :: struct { using _: NS.Copying(ComputePassDescriptor) } @(objc_type=ComputePassDescriptor, objc_name="alloc", objc_is_class_method=true) -ComputePassDescriptor_alloc :: #force_inline proc() -> ^ComputePassDescriptor { +ComputePassDescriptor_alloc :: #force_inline proc "c" () -> ^ComputePassDescriptor { return msgSend(^ComputePassDescriptor, ComputePassDescriptor, "alloc") } @(objc_type=ComputePassDescriptor, objc_name="init") -ComputePassDescriptor_init :: #force_inline proc(self: ^ComputePassDescriptor) -> ^ComputePassDescriptor { +ComputePassDescriptor_init :: #force_inline proc "c" (self: ^ComputePassDescriptor) -> ^ComputePassDescriptor { return msgSend(^ComputePassDescriptor, self, "init") } @(objc_type=ComputePassDescriptor, objc_name="computePassDescriptor", objc_is_class_method=true) -ComputePassDescriptor_computePassDescriptor :: #force_inline proc() -> ^ComputePassDescriptor { +ComputePassDescriptor_computePassDescriptor :: #force_inline proc "c" () -> ^ComputePassDescriptor { return msgSend(^ComputePassDescriptor, ComputePassDescriptor, "computePassDescriptor") } @(objc_type=ComputePassDescriptor, objc_name="dispatchType") -ComputePassDescriptor_dispatchType :: #force_inline proc(self: ^ComputePassDescriptor) -> DispatchType { +ComputePassDescriptor_dispatchType :: #force_inline proc "c" (self: ^ComputePassDescriptor) -> DispatchType { return msgSend(DispatchType, self, "dispatchType") } @(objc_type=ComputePassDescriptor, objc_name="sampleBufferAttachments") -ComputePassDescriptor_sampleBufferAttachments :: #force_inline proc(self: ^ComputePassDescriptor) -> ^ComputePassSampleBufferAttachmentDescriptorArray { +ComputePassDescriptor_sampleBufferAttachments :: #force_inline proc "c" (self: ^ComputePassDescriptor) -> ^ComputePassSampleBufferAttachmentDescriptorArray { return msgSend(^ComputePassSampleBufferAttachmentDescriptorArray, self, "sampleBufferAttachments") } @(objc_type=ComputePassDescriptor, objc_name="setDispatchType") -ComputePassDescriptor_setDispatchType :: #force_inline proc(self: ^ComputePassDescriptor, dispatchType: DispatchType) { +ComputePassDescriptor_setDispatchType :: #force_inline proc "c" (self: ^ComputePassDescriptor, dispatchType: DispatchType) { msgSend(nil, self, "setDispatchType:", dispatchType) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - ComputePassSampleBufferAttachmentDescriptor -Class Methods: - alloc -Methods: - init - endOfEncoderSampleIndex - sampleBuffer - setEndOfEncoderSampleIndex - setSampleBuffer - setStartOfEncoderSampleIndex - startOfEncoderSampleIndex -*/ + @(objc_class="MTLComputePassSampleBufferAttachmentDescriptor") ComputePassSampleBufferAttachmentDescriptor :: struct { using _: NS.Copying(ComputePassSampleBufferAttachmentDescriptor) } @(objc_type=ComputePassSampleBufferAttachmentDescriptor, objc_name="alloc", objc_is_class_method=true) -ComputePassSampleBufferAttachmentDescriptor_alloc :: #force_inline proc() -> ^ComputePassSampleBufferAttachmentDescriptor { +ComputePassSampleBufferAttachmentDescriptor_alloc :: #force_inline proc "c" () -> ^ComputePassSampleBufferAttachmentDescriptor { return msgSend(^ComputePassSampleBufferAttachmentDescriptor, ComputePassSampleBufferAttachmentDescriptor, "alloc") } @(objc_type=ComputePassSampleBufferAttachmentDescriptor, objc_name="init") -ComputePassSampleBufferAttachmentDescriptor_init :: #force_inline proc(self: ^ComputePassSampleBufferAttachmentDescriptor) -> ^ComputePassSampleBufferAttachmentDescriptor { +ComputePassSampleBufferAttachmentDescriptor_init :: #force_inline proc "c" (self: ^ComputePassSampleBufferAttachmentDescriptor) -> ^ComputePassSampleBufferAttachmentDescriptor { return msgSend(^ComputePassSampleBufferAttachmentDescriptor, self, "init") } @(objc_type=ComputePassSampleBufferAttachmentDescriptor, objc_name="endOfEncoderSampleIndex") -ComputePassSampleBufferAttachmentDescriptor_endOfEncoderSampleIndex :: #force_inline proc(self: ^ComputePassSampleBufferAttachmentDescriptor) -> NS.UInteger { +ComputePassSampleBufferAttachmentDescriptor_endOfEncoderSampleIndex :: #force_inline proc "c" (self: ^ComputePassSampleBufferAttachmentDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "endOfEncoderSampleIndex") } @(objc_type=ComputePassSampleBufferAttachmentDescriptor, objc_name="sampleBuffer") -ComputePassSampleBufferAttachmentDescriptor_sampleBuffer :: #force_inline proc(self: ^ComputePassSampleBufferAttachmentDescriptor) -> ^CounterSampleBuffer { +ComputePassSampleBufferAttachmentDescriptor_sampleBuffer :: #force_inline proc "c" (self: ^ComputePassSampleBufferAttachmentDescriptor) -> ^CounterSampleBuffer { return msgSend(^CounterSampleBuffer, self, "sampleBuffer") } @(objc_type=ComputePassSampleBufferAttachmentDescriptor, objc_name="setEndOfEncoderSampleIndex") -ComputePassSampleBufferAttachmentDescriptor_setEndOfEncoderSampleIndex :: #force_inline proc(self: ^ComputePassSampleBufferAttachmentDescriptor, endOfEncoderSampleIndex: NS.UInteger) { +ComputePassSampleBufferAttachmentDescriptor_setEndOfEncoderSampleIndex :: #force_inline proc "c" (self: ^ComputePassSampleBufferAttachmentDescriptor, endOfEncoderSampleIndex: NS.UInteger) { msgSend(nil, self, "setEndOfEncoderSampleIndex:", endOfEncoderSampleIndex) } @(objc_type=ComputePassSampleBufferAttachmentDescriptor, objc_name="setSampleBuffer") -ComputePassSampleBufferAttachmentDescriptor_setSampleBuffer :: #force_inline proc(self: ^ComputePassSampleBufferAttachmentDescriptor, sampleBuffer: ^Buffer) { +ComputePassSampleBufferAttachmentDescriptor_setSampleBuffer :: #force_inline proc "c" (self: ^ComputePassSampleBufferAttachmentDescriptor, sampleBuffer: ^Buffer) { msgSend(nil, self, "setSampleBuffer:", sampleBuffer) } @(objc_type=ComputePassSampleBufferAttachmentDescriptor, objc_name="setStartOfEncoderSampleIndex") -ComputePassSampleBufferAttachmentDescriptor_setStartOfEncoderSampleIndex :: #force_inline proc(self: ^ComputePassSampleBufferAttachmentDescriptor, startOfEncoderSampleIndex: NS.UInteger) { +ComputePassSampleBufferAttachmentDescriptor_setStartOfEncoderSampleIndex :: #force_inline proc "c" (self: ^ComputePassSampleBufferAttachmentDescriptor, startOfEncoderSampleIndex: NS.UInteger) { msgSend(nil, self, "setStartOfEncoderSampleIndex:", startOfEncoderSampleIndex) } @(objc_type=ComputePassSampleBufferAttachmentDescriptor, objc_name="startOfEncoderSampleIndex") -ComputePassSampleBufferAttachmentDescriptor_startOfEncoderSampleIndex :: #force_inline proc(self: ^ComputePassSampleBufferAttachmentDescriptor) -> NS.UInteger { +ComputePassSampleBufferAttachmentDescriptor_startOfEncoderSampleIndex :: #force_inline proc "c" (self: ^ComputePassSampleBufferAttachmentDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "startOfEncoderSampleIndex") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - ComputePassSampleBufferAttachmentDescriptorArray -Class Methods: - alloc -Methods: - init - objectAtIndexedSubscript - setObject -*/ + @(objc_class="MTLComputePassSampleBufferAttachmentDescriptorArray") ComputePassSampleBufferAttachmentDescriptorArray :: struct { using _: NS.Object } @(objc_type=ComputePassSampleBufferAttachmentDescriptorArray, objc_name="alloc", objc_is_class_method=true) -ComputePassSampleBufferAttachmentDescriptorArray_alloc :: #force_inline proc() -> ^ComputePassSampleBufferAttachmentDescriptorArray { +ComputePassSampleBufferAttachmentDescriptorArray_alloc :: #force_inline proc "c" () -> ^ComputePassSampleBufferAttachmentDescriptorArray { return msgSend(^ComputePassSampleBufferAttachmentDescriptorArray, ComputePassSampleBufferAttachmentDescriptorArray, "alloc") } @(objc_type=ComputePassSampleBufferAttachmentDescriptorArray, objc_name="init") -ComputePassSampleBufferAttachmentDescriptorArray_init :: #force_inline proc(self: ^ComputePassSampleBufferAttachmentDescriptorArray) -> ^ComputePassSampleBufferAttachmentDescriptorArray { +ComputePassSampleBufferAttachmentDescriptorArray_init :: #force_inline proc "c" (self: ^ComputePassSampleBufferAttachmentDescriptorArray) -> ^ComputePassSampleBufferAttachmentDescriptorArray { return msgSend(^ComputePassSampleBufferAttachmentDescriptorArray, self, "init") } @(objc_type=ComputePassSampleBufferAttachmentDescriptorArray, objc_name="object") -ComputePassSampleBufferAttachmentDescriptorArray_object :: #force_inline proc(self: ^ComputePassSampleBufferAttachmentDescriptorArray, attachmentIndex: NS.UInteger) -> ^ComputePassSampleBufferAttachmentDescriptor { +ComputePassSampleBufferAttachmentDescriptorArray_object :: #force_inline proc "c" (self: ^ComputePassSampleBufferAttachmentDescriptorArray, attachmentIndex: NS.UInteger) -> ^ComputePassSampleBufferAttachmentDescriptor { return msgSend(^ComputePassSampleBufferAttachmentDescriptor, self, "objectAtIndexedSubscript:", attachmentIndex) } @(objc_type=ComputePassSampleBufferAttachmentDescriptorArray, objc_name="setObject") -ComputePassSampleBufferAttachmentDescriptorArray_setObject :: #force_inline proc(self: ^ComputePassSampleBufferAttachmentDescriptorArray, attachment: ^ComputePassSampleBufferAttachmentDescriptor, attachmentIndex: NS.UInteger) { +ComputePassSampleBufferAttachmentDescriptorArray_setObject :: #force_inline proc "c" (self: ^ComputePassSampleBufferAttachmentDescriptorArray, attachment: ^ComputePassSampleBufferAttachmentDescriptor, attachmentIndex: NS.UInteger) { msgSend(nil, self, "setObject:atIndexedSubscript:", attachment, attachmentIndex) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - ComputePipelineDescriptor -Class Methods: - alloc -Methods: - init - binaryArchives - buffers - computeFunction - insertLibraries - label - linkedFunctions - maxCallStackDepth - maxTotalThreadsPerThreadgroup - reset - setBinaryArchives - setComputeFunction - setInsertLibraries - setLabel - setLinkedFunctions - setMaxCallStackDepth - setMaxTotalThreadsPerThreadgroup - setStageInputDescriptor - setSupportAddingBinaryFunctions - setSupportIndirectCommandBuffers - setThreadGroupSizeIsMultipleOfThreadExecutionWidth - stageInputDescriptor - supportAddingBinaryFunctions - supportIndirectCommandBuffers - threadGroupSizeIsMultipleOfThreadExecutionWidth -*/ + @(objc_class="MTLComputePipelineDescriptor") ComputePipelineDescriptor :: struct { using _: NS.Copying(ComputePipelineDescriptor) } @(objc_type=ComputePipelineDescriptor, objc_name="alloc", objc_is_class_method=true) -ComputePipelineDescriptor_alloc :: #force_inline proc() -> ^ComputePipelineDescriptor { +ComputePipelineDescriptor_alloc :: #force_inline proc "c" () -> ^ComputePipelineDescriptor { return msgSend(^ComputePipelineDescriptor, ComputePipelineDescriptor, "alloc") } @(objc_type=ComputePipelineDescriptor, objc_name="init") -ComputePipelineDescriptor_init :: #force_inline proc(self: ^ComputePipelineDescriptor) -> ^ComputePipelineDescriptor { +ComputePipelineDescriptor_init :: #force_inline proc "c" (self: ^ComputePipelineDescriptor) -> ^ComputePipelineDescriptor { return msgSend(^ComputePipelineDescriptor, self, "init") } @(objc_type=ComputePipelineDescriptor, objc_name="binaryArchives") -ComputePipelineDescriptor_binaryArchives :: #force_inline proc(self: ^ComputePipelineDescriptor) -> ^NS.Array { +ComputePipelineDescriptor_binaryArchives :: #force_inline proc "c" (self: ^ComputePipelineDescriptor) -> ^NS.Array { return msgSend(^NS.Array, self, "binaryArchives") } @(objc_type=ComputePipelineDescriptor, objc_name="buffers") -ComputePipelineDescriptor_buffers :: #force_inline proc(self: ^ComputePipelineDescriptor) -> ^PipelineBufferDescriptorArray { +ComputePipelineDescriptor_buffers :: #force_inline proc "c" (self: ^ComputePipelineDescriptor) -> ^PipelineBufferDescriptorArray { return msgSend(^PipelineBufferDescriptorArray, self, "buffers") } @(objc_type=ComputePipelineDescriptor, objc_name="computeFunction") -ComputePipelineDescriptor_computeFunction :: #force_inline proc(self: ^ComputePipelineDescriptor) -> ^Function { +ComputePipelineDescriptor_computeFunction :: #force_inline proc "c" (self: ^ComputePipelineDescriptor) -> ^Function { return msgSend(^Function, self, "computeFunction") } @(objc_type=ComputePipelineDescriptor, objc_name="insertLibraries") -ComputePipelineDescriptor_insertLibraries :: #force_inline proc(self: ^ComputePipelineDescriptor) -> ^NS.Array { +ComputePipelineDescriptor_insertLibraries :: #force_inline proc "c" (self: ^ComputePipelineDescriptor) -> ^NS.Array { return msgSend(^NS.Array, self, "insertLibraries") } @(objc_type=ComputePipelineDescriptor, objc_name="label") -ComputePipelineDescriptor_label :: #force_inline proc(self: ^ComputePipelineDescriptor) -> ^NS.String { +ComputePipelineDescriptor_label :: #force_inline proc "c" (self: ^ComputePipelineDescriptor) -> ^NS.String { return msgSend(^NS.String, self, "label") } @(objc_type=ComputePipelineDescriptor, objc_name="linkedFunctions") -ComputePipelineDescriptor_linkedFunctions :: #force_inline proc(self: ^ComputePipelineDescriptor) -> ^LinkedFunctions { +ComputePipelineDescriptor_linkedFunctions :: #force_inline proc "c" (self: ^ComputePipelineDescriptor) -> ^LinkedFunctions { return msgSend(^LinkedFunctions, self, "linkedFunctions") } @(objc_type=ComputePipelineDescriptor, objc_name="maxCallStackDepth") -ComputePipelineDescriptor_maxCallStackDepth :: #force_inline proc(self: ^ComputePipelineDescriptor) -> NS.UInteger { +ComputePipelineDescriptor_maxCallStackDepth :: #force_inline proc "c" (self: ^ComputePipelineDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "maxCallStackDepth") } @(objc_type=ComputePipelineDescriptor, objc_name="maxTotalThreadsPerThreadgroup") -ComputePipelineDescriptor_maxTotalThreadsPerThreadgroup :: #force_inline proc(self: ^ComputePipelineDescriptor) -> NS.UInteger { +ComputePipelineDescriptor_maxTotalThreadsPerThreadgroup :: #force_inline proc "c" (self: ^ComputePipelineDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "maxTotalThreadsPerThreadgroup") } @(objc_type=ComputePipelineDescriptor, objc_name="reset") -ComputePipelineDescriptor_reset :: #force_inline proc(self: ^ComputePipelineDescriptor) { +ComputePipelineDescriptor_reset :: #force_inline proc "c" (self: ^ComputePipelineDescriptor) { msgSend(nil, self, "reset") } @(objc_type=ComputePipelineDescriptor, objc_name="setBinaryArchives") -ComputePipelineDescriptor_setBinaryArchives :: #force_inline proc(self: ^ComputePipelineDescriptor, binaryArchives: ^NS.Array) { +ComputePipelineDescriptor_setBinaryArchives :: #force_inline proc "c" (self: ^ComputePipelineDescriptor, binaryArchives: ^NS.Array) { msgSend(nil, self, "setBinaryArchives:", binaryArchives) } @(objc_type=ComputePipelineDescriptor, objc_name="setComputeFunction") -ComputePipelineDescriptor_setComputeFunction :: #force_inline proc(self: ^ComputePipelineDescriptor, computeFunction: ^Function) { +ComputePipelineDescriptor_setComputeFunction :: #force_inline proc "c" (self: ^ComputePipelineDescriptor, computeFunction: ^Function) { msgSend(nil, self, "setComputeFunction:", computeFunction) } @(objc_type=ComputePipelineDescriptor, objc_name="setInsertLibraries") -ComputePipelineDescriptor_setInsertLibraries :: #force_inline proc(self: ^ComputePipelineDescriptor, insertLibraries: ^NS.Array) { +ComputePipelineDescriptor_setInsertLibraries :: #force_inline proc "c" (self: ^ComputePipelineDescriptor, insertLibraries: ^NS.Array) { msgSend(nil, self, "setInsertLibraries:", insertLibraries) } @(objc_type=ComputePipelineDescriptor, objc_name="setLabel") -ComputePipelineDescriptor_setLabel :: #force_inline proc(self: ^ComputePipelineDescriptor, label: ^NS.String) { +ComputePipelineDescriptor_setLabel :: #force_inline proc "c" (self: ^ComputePipelineDescriptor, label: ^NS.String) { msgSend(nil, self, "setLabel:", label) } @(objc_type=ComputePipelineDescriptor, objc_name="setLinkedFunctions") -ComputePipelineDescriptor_setLinkedFunctions :: #force_inline proc(self: ^ComputePipelineDescriptor, linkedFunctions: ^LinkedFunctions) { +ComputePipelineDescriptor_setLinkedFunctions :: #force_inline proc "c" (self: ^ComputePipelineDescriptor, linkedFunctions: ^LinkedFunctions) { msgSend(nil, self, "setLinkedFunctions:", linkedFunctions) } @(objc_type=ComputePipelineDescriptor, objc_name="setMaxCallStackDepth") -ComputePipelineDescriptor_setMaxCallStackDepth :: #force_inline proc(self: ^ComputePipelineDescriptor, maxCallStackDepth: NS.UInteger) { +ComputePipelineDescriptor_setMaxCallStackDepth :: #force_inline proc "c" (self: ^ComputePipelineDescriptor, maxCallStackDepth: NS.UInteger) { msgSend(nil, self, "setMaxCallStackDepth:", maxCallStackDepth) } @(objc_type=ComputePipelineDescriptor, objc_name="setMaxTotalThreadsPerThreadgroup") -ComputePipelineDescriptor_setMaxTotalThreadsPerThreadgroup :: #force_inline proc(self: ^ComputePipelineDescriptor, maxTotalThreadsPerThreadgroup: NS.UInteger) { +ComputePipelineDescriptor_setMaxTotalThreadsPerThreadgroup :: #force_inline proc "c" (self: ^ComputePipelineDescriptor, maxTotalThreadsPerThreadgroup: NS.UInteger) { msgSend(nil, self, "setMaxTotalThreadsPerThreadgroup:", maxTotalThreadsPerThreadgroup) } @(objc_type=ComputePipelineDescriptor, objc_name="setStageInputDescriptor") -ComputePipelineDescriptor_setStageInputDescriptor :: #force_inline proc(self: ^ComputePipelineDescriptor, stageInputDescriptor: ^StageInputOutputDescriptor) { +ComputePipelineDescriptor_setStageInputDescriptor :: #force_inline proc "c" (self: ^ComputePipelineDescriptor, stageInputDescriptor: ^StageInputOutputDescriptor) { msgSend(nil, self, "setStageInputDescriptor:", stageInputDescriptor) } @(objc_type=ComputePipelineDescriptor, objc_name="setSupportAddingBinaryFunctions") -ComputePipelineDescriptor_setSupportAddingBinaryFunctions :: #force_inline proc(self: ^ComputePipelineDescriptor, supportAddingBinaryFunctions: BOOL) { +ComputePipelineDescriptor_setSupportAddingBinaryFunctions :: #force_inline proc "c" (self: ^ComputePipelineDescriptor, supportAddingBinaryFunctions: BOOL) { msgSend(nil, self, "setSupportAddingBinaryFunctions:", supportAddingBinaryFunctions) } @(objc_type=ComputePipelineDescriptor, objc_name="setSupportIndirectCommandBuffers") -ComputePipelineDescriptor_setSupportIndirectCommandBuffers :: #force_inline proc(self: ^ComputePipelineDescriptor, supportIndirectCommandBuffers: BOOL) { +ComputePipelineDescriptor_setSupportIndirectCommandBuffers :: #force_inline proc "c" (self: ^ComputePipelineDescriptor, supportIndirectCommandBuffers: BOOL) { msgSend(nil, self, "setSupportIndirectCommandBuffers:", supportIndirectCommandBuffers) } @(objc_type=ComputePipelineDescriptor, objc_name="setThreadGroupSizeIsMultipleOfThreadExecutionWidth") -ComputePipelineDescriptor_setThreadGroupSizeIsMultipleOfThreadExecutionWidth :: #force_inline proc(self: ^ComputePipelineDescriptor, threadGroupSizeIsMultipleOfThreadExecutionWidth: BOOL) { +ComputePipelineDescriptor_setThreadGroupSizeIsMultipleOfThreadExecutionWidth :: #force_inline proc "c" (self: ^ComputePipelineDescriptor, threadGroupSizeIsMultipleOfThreadExecutionWidth: BOOL) { msgSend(nil, self, "setThreadGroupSizeIsMultipleOfThreadExecutionWidth:", threadGroupSizeIsMultipleOfThreadExecutionWidth) } @(objc_type=ComputePipelineDescriptor, objc_name="stageInputDescriptor") -ComputePipelineDescriptor_stageInputDescriptor :: #force_inline proc(self: ^ComputePipelineDescriptor) -> ^StageInputOutputDescriptor { +ComputePipelineDescriptor_stageInputDescriptor :: #force_inline proc "c" (self: ^ComputePipelineDescriptor) -> ^StageInputOutputDescriptor { return msgSend(^StageInputOutputDescriptor, self, "stageInputDescriptor") } @(objc_type=ComputePipelineDescriptor, objc_name="supportAddingBinaryFunctions") -ComputePipelineDescriptor_supportAddingBinaryFunctions :: #force_inline proc(self: ^ComputePipelineDescriptor) -> BOOL { +ComputePipelineDescriptor_supportAddingBinaryFunctions :: #force_inline proc "c" (self: ^ComputePipelineDescriptor) -> BOOL { return msgSend(BOOL, self, "supportAddingBinaryFunctions") } @(objc_type=ComputePipelineDescriptor, objc_name="supportIndirectCommandBuffers") -ComputePipelineDescriptor_supportIndirectCommandBuffers :: #force_inline proc(self: ^ComputePipelineDescriptor) -> BOOL { +ComputePipelineDescriptor_supportIndirectCommandBuffers :: #force_inline proc "c" (self: ^ComputePipelineDescriptor) -> BOOL { return msgSend(BOOL, self, "supportIndirectCommandBuffers") } @(objc_type=ComputePipelineDescriptor, objc_name="threadGroupSizeIsMultipleOfThreadExecutionWidth") -ComputePipelineDescriptor_threadGroupSizeIsMultipleOfThreadExecutionWidth :: #force_inline proc(self: ^ComputePipelineDescriptor) -> BOOL { +ComputePipelineDescriptor_threadGroupSizeIsMultipleOfThreadExecutionWidth :: #force_inline proc "c" (self: ^ComputePipelineDescriptor) -> BOOL { return msgSend(BOOL, self, "threadGroupSizeIsMultipleOfThreadExecutionWidth") } +@(objc_type=ComputePipelineDescriptor, objc_name="gpuResourceID") +ComputePipelineDescriptor_gpuResourceID :: #force_inline proc "c" (self: ^ComputePipelineDescriptor) -> ResourceID { + return msgSend(ResourceID, self, "gpuResourceID") +} + //////////////////////////////////////////////////////////////////////////////// -/* -Class: - ComputePipelineReflection -Class Methods: - alloc -Methods: - init - arguments -*/ + @(objc_class="MTLComputePipelineReflection") ComputePipelineReflection :: struct { using _: NS.Object } @(objc_type=ComputePipelineReflection, objc_name="alloc", objc_is_class_method=true) -ComputePipelineReflection_alloc :: #force_inline proc() -> ^ComputePipelineReflection { +ComputePipelineReflection_alloc :: #force_inline proc "c" () -> ^ComputePipelineReflection { return msgSend(^ComputePipelineReflection, ComputePipelineReflection, "alloc") } @(objc_type=ComputePipelineReflection, objc_name="init") -ComputePipelineReflection_init :: #force_inline proc(self: ^ComputePipelineReflection) -> ^ComputePipelineReflection { +ComputePipelineReflection_init :: #force_inline proc "c" (self: ^ComputePipelineReflection) -> ^ComputePipelineReflection { return msgSend(^ComputePipelineReflection, self, "init") } +@(objc_type=ComputePipelineReflection, objc_name="bindings") +ComputePipelineReflection_bindings :: #force_inline proc "c" (self: ^ComputePipelineReflection) -> ^NS.Array { + return msgSend(^NS.Array, self, "bindings") +} @(objc_type=ComputePipelineReflection, objc_name="arguments") -ComputePipelineReflection_arguments :: #force_inline proc(self: ^ComputePipelineReflection) -> ^NS.Array { +ComputePipelineReflection_arguments :: #force_inline proc "c" (self: ^ComputePipelineReflection) -> ^NS.Array { return msgSend(^NS.Array, self, "arguments") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - CounterSampleBufferDescriptor -Class Methods: - alloc -Methods: - init - counterSet - label - sampleCount - setCounterSet - setLabel - setSampleCount - setStorageMode - storageMode -*/ + @(objc_class="MTLCounterSampleBufferDescriptor") CounterSampleBufferDescriptor :: struct { using _: NS.Copying(CounterSampleBufferDescriptor) } @(objc_type=CounterSampleBufferDescriptor, objc_name="alloc", objc_is_class_method=true) -CounterSampleBufferDescriptor_alloc :: #force_inline proc() -> ^CounterSampleBufferDescriptor { +CounterSampleBufferDescriptor_alloc :: #force_inline proc "c" () -> ^CounterSampleBufferDescriptor { return msgSend(^CounterSampleBufferDescriptor, CounterSampleBufferDescriptor, "alloc") } @(objc_type=CounterSampleBufferDescriptor, objc_name="init") -CounterSampleBufferDescriptor_init :: #force_inline proc(self: ^CounterSampleBufferDescriptor) -> ^CounterSampleBufferDescriptor { +CounterSampleBufferDescriptor_init :: #force_inline proc "c" (self: ^CounterSampleBufferDescriptor) -> ^CounterSampleBufferDescriptor { return msgSend(^CounterSampleBufferDescriptor, self, "init") } @(objc_type=CounterSampleBufferDescriptor, objc_name="counterSet") -CounterSampleBufferDescriptor_counterSet :: #force_inline proc(self: ^CounterSampleBufferDescriptor) -> ^CounterSet { +CounterSampleBufferDescriptor_counterSet :: #force_inline proc "c" (self: ^CounterSampleBufferDescriptor) -> ^CounterSet { return msgSend(^CounterSet, self, "counterSet") } @(objc_type=CounterSampleBufferDescriptor, objc_name="label") -CounterSampleBufferDescriptor_label :: #force_inline proc(self: ^CounterSampleBufferDescriptor) -> ^NS.String { +CounterSampleBufferDescriptor_label :: #force_inline proc "c" (self: ^CounterSampleBufferDescriptor) -> ^NS.String { return msgSend(^NS.String, self, "label") } @(objc_type=CounterSampleBufferDescriptor, objc_name="sampleCount") -CounterSampleBufferDescriptor_sampleCount :: #force_inline proc(self: ^CounterSampleBufferDescriptor) -> NS.UInteger { +CounterSampleBufferDescriptor_sampleCount :: #force_inline proc "c" (self: ^CounterSampleBufferDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "sampleCount") } @(objc_type=CounterSampleBufferDescriptor, objc_name="setCounterSet") -CounterSampleBufferDescriptor_setCounterSet :: #force_inline proc(self: ^CounterSampleBufferDescriptor, counterSet: ^CounterSet) { +CounterSampleBufferDescriptor_setCounterSet :: #force_inline proc "c" (self: ^CounterSampleBufferDescriptor, counterSet: ^CounterSet) { msgSend(nil, self, "setCounterSet:", counterSet) } @(objc_type=CounterSampleBufferDescriptor, objc_name="setLabel") -CounterSampleBufferDescriptor_setLabel :: #force_inline proc(self: ^CounterSampleBufferDescriptor, label: ^NS.String) { +CounterSampleBufferDescriptor_setLabel :: #force_inline proc "c" (self: ^CounterSampleBufferDescriptor, label: ^NS.String) { msgSend(nil, self, "setLabel:", label) } @(objc_type=CounterSampleBufferDescriptor, objc_name="setSampleCount") -CounterSampleBufferDescriptor_setSampleCount :: #force_inline proc(self: ^CounterSampleBufferDescriptor, sampleCount: NS.UInteger) { +CounterSampleBufferDescriptor_setSampleCount :: #force_inline proc "c" (self: ^CounterSampleBufferDescriptor, sampleCount: NS.UInteger) { msgSend(nil, self, "setSampleCount:", sampleCount) } @(objc_type=CounterSampleBufferDescriptor, objc_name="setStorageMode") -CounterSampleBufferDescriptor_setStorageMode :: #force_inline proc(self: ^CounterSampleBufferDescriptor, storageMode: StorageMode) { +CounterSampleBufferDescriptor_setStorageMode :: #force_inline proc "c" (self: ^CounterSampleBufferDescriptor, storageMode: StorageMode) { msgSend(nil, self, "setStorageMode:", storageMode) } @(objc_type=CounterSampleBufferDescriptor, objc_name="storageMode") -CounterSampleBufferDescriptor_storageMode :: #force_inline proc(self: ^CounterSampleBufferDescriptor) -> StorageMode { +CounterSampleBufferDescriptor_storageMode :: #force_inline proc "c" (self: ^CounterSampleBufferDescriptor) -> StorageMode { return msgSend(StorageMode, self, "storageMode") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - DepthStencilDescriptor -Class Methods: - alloc -Methods: - init - backFaceStencil - depthCompareFunction - frontFaceStencil - isDepthWriteEnabled - label - setBackFaceStencil - setDepthCompareFunction - setDepthWriteEnabled - setFrontFaceStencil - setLabel -*/ + @(objc_class="MTLDepthStencilDescriptor") DepthStencilDescriptor :: struct { using _: NS.Copying(DepthStencilDescriptor) } @(objc_type=DepthStencilDescriptor, objc_name="alloc", objc_is_class_method=true) -DepthStencilDescriptor_alloc :: #force_inline proc() -> ^DepthStencilDescriptor { +DepthStencilDescriptor_alloc :: #force_inline proc "c" () -> ^DepthStencilDescriptor { return msgSend(^DepthStencilDescriptor, DepthStencilDescriptor, "alloc") } @(objc_type=DepthStencilDescriptor, objc_name="init") -DepthStencilDescriptor_init :: #force_inline proc(self: ^DepthStencilDescriptor) -> ^DepthStencilDescriptor { +DepthStencilDescriptor_init :: #force_inline proc "c" (self: ^DepthStencilDescriptor) -> ^DepthStencilDescriptor { return msgSend(^DepthStencilDescriptor, self, "init") } @(objc_type=DepthStencilDescriptor, objc_name="backFaceStencil") -DepthStencilDescriptor_backFaceStencil :: #force_inline proc(self: ^DepthStencilDescriptor) -> ^StencilDescriptor { +DepthStencilDescriptor_backFaceStencil :: #force_inline proc "c" (self: ^DepthStencilDescriptor) -> ^StencilDescriptor { return msgSend(^StencilDescriptor, self, "backFaceStencil") } @(objc_type=DepthStencilDescriptor, objc_name="depthCompareFunction") -DepthStencilDescriptor_depthCompareFunction :: #force_inline proc(self: ^DepthStencilDescriptor) -> CompareFunction { +DepthStencilDescriptor_depthCompareFunction :: #force_inline proc "c" (self: ^DepthStencilDescriptor) -> CompareFunction { return msgSend(CompareFunction, self, "depthCompareFunction") } @(objc_type=DepthStencilDescriptor, objc_name="frontFaceStencil") -DepthStencilDescriptor_frontFaceStencil :: #force_inline proc(self: ^DepthStencilDescriptor) -> ^StencilDescriptor { +DepthStencilDescriptor_frontFaceStencil :: #force_inline proc "c" (self: ^DepthStencilDescriptor) -> ^StencilDescriptor { return msgSend(^StencilDescriptor, self, "frontFaceStencil") } @(objc_type=DepthStencilDescriptor, objc_name="isDepthWriteEnabled") -DepthStencilDescriptor_isDepthWriteEnabled :: #force_inline proc(self: ^DepthStencilDescriptor) -> BOOL { +DepthStencilDescriptor_isDepthWriteEnabled :: #force_inline proc "c" (self: ^DepthStencilDescriptor) -> BOOL { return msgSend(BOOL, self, "isDepthWriteEnabled") } @(objc_type=DepthStencilDescriptor, objc_name="label") -DepthStencilDescriptor_label :: #force_inline proc(self: ^DepthStencilDescriptor) -> ^NS.String { +DepthStencilDescriptor_label :: #force_inline proc "c" (self: ^DepthStencilDescriptor) -> ^NS.String { return msgSend(^NS.String, self, "label") } @(objc_type=DepthStencilDescriptor, objc_name="setBackFaceStencil") -DepthStencilDescriptor_setBackFaceStencil :: #force_inline proc(self: ^DepthStencilDescriptor, backFaceStencil: ^StencilDescriptor) { +DepthStencilDescriptor_setBackFaceStencil :: #force_inline proc "c" (self: ^DepthStencilDescriptor, backFaceStencil: ^StencilDescriptor) { msgSend(nil, self, "setBackFaceStencil:", backFaceStencil) } @(objc_type=DepthStencilDescriptor, objc_name="setDepthCompareFunction") -DepthStencilDescriptor_setDepthCompareFunction :: #force_inline proc(self: ^DepthStencilDescriptor, depthCompareFunction: CompareFunction) { +DepthStencilDescriptor_setDepthCompareFunction :: #force_inline proc "c" (self: ^DepthStencilDescriptor, depthCompareFunction: CompareFunction) { msgSend(nil, self, "setDepthCompareFunction:", depthCompareFunction) } @(objc_type=DepthStencilDescriptor, objc_name="setDepthWriteEnabled") -DepthStencilDescriptor_setDepthWriteEnabled :: #force_inline proc(self: ^DepthStencilDescriptor, depthWriteEnabled: BOOL) { +DepthStencilDescriptor_setDepthWriteEnabled :: #force_inline proc "c" (self: ^DepthStencilDescriptor, depthWriteEnabled: BOOL) { msgSend(nil, self, "setDepthWriteEnabled:", depthWriteEnabled) } @(objc_type=DepthStencilDescriptor, objc_name="setFrontFaceStencil") -DepthStencilDescriptor_setFrontFaceStencil :: #force_inline proc(self: ^DepthStencilDescriptor, frontFaceStencil: ^StencilDescriptor) { +DepthStencilDescriptor_setFrontFaceStencil :: #force_inline proc "c" (self: ^DepthStencilDescriptor, frontFaceStencil: ^StencilDescriptor) { msgSend(nil, self, "setFrontFaceStencil:", frontFaceStencil) } @(objc_type=DepthStencilDescriptor, objc_name="setLabel") -DepthStencilDescriptor_setLabel :: #force_inline proc(self: ^DepthStencilDescriptor, label: ^NS.String) { +DepthStencilDescriptor_setLabel :: #force_inline proc "c" (self: ^DepthStencilDescriptor, label: ^NS.String) { msgSend(nil, self, "setLabel:", label) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - FunctionConstant -Class Methods: - alloc -Methods: - init - index - name - required - type -*/ + @(objc_class="MTLFunctionConstant") FunctionConstant :: struct { using _: NS.Copying(FunctionConstant) } @(objc_type=FunctionConstant, objc_name="alloc", objc_is_class_method=true) -FunctionConstant_alloc :: #force_inline proc() -> ^FunctionConstant { +FunctionConstant_alloc :: #force_inline proc "c" () -> ^FunctionConstant { return msgSend(^FunctionConstant, FunctionConstant, "alloc") } @(objc_type=FunctionConstant, objc_name="init") -FunctionConstant_init :: #force_inline proc(self: ^FunctionConstant) -> ^FunctionConstant { +FunctionConstant_init :: #force_inline proc "c" (self: ^FunctionConstant) -> ^FunctionConstant { return msgSend(^FunctionConstant, self, "init") } @(objc_type=FunctionConstant, objc_name="index") -FunctionConstant_index :: #force_inline proc(self: ^FunctionConstant) -> NS.UInteger { +FunctionConstant_index :: #force_inline proc "c" (self: ^FunctionConstant) -> NS.UInteger { return msgSend(NS.UInteger, self, "index") } @(objc_type=FunctionConstant, objc_name="name") -FunctionConstant_name :: #force_inline proc(self: ^FunctionConstant) -> ^NS.String { +FunctionConstant_name :: #force_inline proc "c" (self: ^FunctionConstant) -> ^NS.String { return msgSend(^NS.String, self, "name") } @(objc_type=FunctionConstant, objc_name="required") -FunctionConstant_required :: #force_inline proc(self: ^FunctionConstant) -> BOOL { +FunctionConstant_required :: #force_inline proc "c" (self: ^FunctionConstant) -> BOOL { return msgSend(BOOL, self, "required") } @(objc_type=FunctionConstant, objc_name="type") -FunctionConstant_type :: #force_inline proc(self: ^FunctionConstant) -> DataType { +FunctionConstant_type :: #force_inline proc "c" (self: ^FunctionConstant) -> DataType { return msgSend(DataType, self, "type") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - FunctionConstantValues -Class Methods: - alloc -Methods: - init - reset - setConstantValue - setConstantValue - setConstantValues -*/ + @(objc_class="MTLFunctionConstantValues") FunctionConstantValues :: struct { using _: NS.Copying(FunctionConstantValues) } @(objc_type=FunctionConstantValues, objc_name="alloc", objc_is_class_method=true) -FunctionConstantValues_alloc :: #force_inline proc() -> ^FunctionConstantValues { +FunctionConstantValues_alloc :: #force_inline proc "c" () -> ^FunctionConstantValues { return msgSend(^FunctionConstantValues, FunctionConstantValues, "alloc") } @(objc_type=FunctionConstantValues, objc_name="init") -FunctionConstantValues_init :: #force_inline proc(self: ^FunctionConstantValues) -> ^FunctionConstantValues { +FunctionConstantValues_init :: #force_inline proc "c" (self: ^FunctionConstantValues) -> ^FunctionConstantValues { return msgSend(^FunctionConstantValues, self, "init") } @(objc_type=FunctionConstantValues, objc_name="reset") -FunctionConstantValues_reset :: #force_inline proc(self: ^FunctionConstantValues) { +FunctionConstantValues_reset :: #force_inline proc "c" (self: ^FunctionConstantValues) { msgSend(nil, self, "reset") } @(objc_type=FunctionConstantValues, objc_name="setConstantValue") -FunctionConstantValues_setConstantValue :: #force_inline proc(self: ^FunctionConstantValues, value: rawptr, type: DataType, index: NS.UInteger) { +FunctionConstantValues_setConstantValue :: #force_inline proc "c" (self: ^FunctionConstantValues, value: rawptr, type: DataType, index: NS.UInteger) { msgSend(nil, self, "setConstantValue:type:atIndex:", value, type, index) } @(objc_type=FunctionConstantValues, objc_name="setConstantValueWithName") -FunctionConstantValues_setConstantValueWithName :: #force_inline proc(self: ^FunctionConstantValues, value: rawptr, type: DataType, name: ^NS.String) { +FunctionConstantValues_setConstantValueWithName :: #force_inline proc "c" (self: ^FunctionConstantValues, value: rawptr, type: DataType, name: ^NS.String) { msgSend(nil, self, "setConstantValue:type:withName:", value, type, name) } @(objc_type=FunctionConstantValues, objc_name="setConstantValues") -FunctionConstantValues_setConstantValues :: #force_inline proc(self: ^FunctionConstantValues, values: rawptr, type: DataType, range: NS.Range) { +FunctionConstantValues_setConstantValues :: #force_inline proc "c" (self: ^FunctionConstantValues, values: rawptr, type: DataType, range: NS.Range) { msgSend(nil, self, "setConstantValues:type:withRange:", values, type, range) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - FunctionDescriptor -Class Methods: - alloc - functionDescriptor -Methods: - init - constantValues - name - options - setConstantValues - setName - setOptions - setSpecializedName - specializedName -*/ + @(objc_class="MTLFunctionDescriptor") FunctionDescriptor :: struct { using _: NS.Copying(FunctionDescriptor) } @(objc_type=FunctionDescriptor, objc_name="alloc", objc_is_class_method=true) -FunctionDescriptor_alloc :: #force_inline proc() -> ^FunctionDescriptor { +FunctionDescriptor_alloc :: #force_inline proc "c" () -> ^FunctionDescriptor { return msgSend(^FunctionDescriptor, FunctionDescriptor, "alloc") } @(objc_type=FunctionDescriptor, objc_name="init") -FunctionDescriptor_init :: #force_inline proc(self: ^FunctionDescriptor) -> ^FunctionDescriptor { +FunctionDescriptor_init :: #force_inline proc "c" (self: ^FunctionDescriptor) -> ^FunctionDescriptor { return msgSend(^FunctionDescriptor, self, "init") } @(objc_type=FunctionDescriptor, objc_name="constantValues") -FunctionDescriptor_constantValues :: #force_inline proc(self: ^FunctionDescriptor) -> ^FunctionConstantValues { +FunctionDescriptor_constantValues :: #force_inline proc "c" (self: ^FunctionDescriptor) -> ^FunctionConstantValues { return msgSend(^FunctionConstantValues, self, "constantValues") } @(objc_type=FunctionDescriptor, objc_name="functionDescriptor", objc_is_class_method=true) -FunctionDescriptor_functionDescriptor :: #force_inline proc() -> ^FunctionDescriptor { +FunctionDescriptor_functionDescriptor :: #force_inline proc "c" () -> ^FunctionDescriptor { return msgSend(^FunctionDescriptor, FunctionDescriptor, "functionDescriptor") } @(objc_type=FunctionDescriptor, objc_name="name") -FunctionDescriptor_name :: #force_inline proc(self: ^FunctionDescriptor) -> ^NS.String { +FunctionDescriptor_name :: #force_inline proc "c" (self: ^FunctionDescriptor) -> ^NS.String { return msgSend(^NS.String, self, "name") } @(objc_type=FunctionDescriptor, objc_name="options") -FunctionDescriptor_options :: #force_inline proc(self: ^FunctionDescriptor) -> FunctionOptions { +FunctionDescriptor_options :: #force_inline proc "c" (self: ^FunctionDescriptor) -> FunctionOptions { return msgSend(FunctionOptions, self, "options") } @(objc_type=FunctionDescriptor, objc_name="setConstantValues") -FunctionDescriptor_setConstantValues :: #force_inline proc(self: ^FunctionDescriptor, constantValues: ^FunctionConstantValues) { +FunctionDescriptor_setConstantValues :: #force_inline proc "c" (self: ^FunctionDescriptor, constantValues: ^FunctionConstantValues) { msgSend(nil, self, "setConstantValues:", constantValues) } @(objc_type=FunctionDescriptor, objc_name="setName") -FunctionDescriptor_setName :: #force_inline proc(self: ^FunctionDescriptor, name: ^NS.String) { +FunctionDescriptor_setName :: #force_inline proc "c" (self: ^FunctionDescriptor, name: ^NS.String) { msgSend(nil, self, "setName:", name) } @(objc_type=FunctionDescriptor, objc_name="setOptions") -FunctionDescriptor_setOptions :: #force_inline proc(self: ^FunctionDescriptor, options: FunctionOptions) { +FunctionDescriptor_setOptions :: #force_inline proc "c" (self: ^FunctionDescriptor, options: FunctionOptions) { msgSend(nil, self, "setOptions:", options) } @(objc_type=FunctionDescriptor, objc_name="setSpecializedName") -FunctionDescriptor_setSpecializedName :: #force_inline proc(self: ^FunctionDescriptor, specializedName: ^NS.String) { +FunctionDescriptor_setSpecializedName :: #force_inline proc "c" (self: ^FunctionDescriptor, specializedName: ^NS.String) { msgSend(nil, self, "setSpecializedName:", specializedName) } @(objc_type=FunctionDescriptor, objc_name="specializedName") -FunctionDescriptor_specializedName :: #force_inline proc(self: ^FunctionDescriptor) -> ^NS.String { +FunctionDescriptor_specializedName :: #force_inline proc "c" (self: ^FunctionDescriptor) -> ^NS.String { return msgSend(^NS.String, self, "specializedName") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - IntersectionFunctionDescriptor -Class Methods: - alloc -Methods: - init -*/ + @(objc_class="MTLIntersectionFunctionDescriptor") IntersectionFunctionDescriptor :: struct { using _: NS.Copying(IntersectionFunctionDescriptor) } @(objc_type=IntersectionFunctionDescriptor, objc_name="alloc", objc_is_class_method=true) -IntersectionFunctionDescriptor_alloc :: #force_inline proc() -> ^IntersectionFunctionDescriptor { +IntersectionFunctionDescriptor_alloc :: #force_inline proc "c" () -> ^IntersectionFunctionDescriptor { return msgSend(^IntersectionFunctionDescriptor, IntersectionFunctionDescriptor, "alloc") } @(objc_type=IntersectionFunctionDescriptor, objc_name="init") -IntersectionFunctionDescriptor_init :: #force_inline proc(self: ^IntersectionFunctionDescriptor) -> ^IntersectionFunctionDescriptor { +IntersectionFunctionDescriptor_init :: #force_inline proc "c" (self: ^IntersectionFunctionDescriptor) -> ^IntersectionFunctionDescriptor { return msgSend(^IntersectionFunctionDescriptor, self, "init") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - HeapDescriptor -Class Methods: - alloc -Methods: - init - cpuCacheMode - hazardTrackingMode - resourceOptions - setCpuCacheMode - setHazardTrackingMode - setResourceOptions - setSize - setStorageMode - setType - size - storageMode - type -*/ + @(objc_class="MTLHeapDescriptor") HeapDescriptor :: struct { using _: NS.Copying(HeapDescriptor) } @(objc_type=HeapDescriptor, objc_name="alloc", objc_is_class_method=true) -HeapDescriptor_alloc :: #force_inline proc() -> ^HeapDescriptor { +HeapDescriptor_alloc :: #force_inline proc "c" () -> ^HeapDescriptor { return msgSend(^HeapDescriptor, HeapDescriptor, "alloc") } @(objc_type=HeapDescriptor, objc_name="init") -HeapDescriptor_init :: #force_inline proc(self: ^HeapDescriptor) -> ^HeapDescriptor { +HeapDescriptor_init :: #force_inline proc "c" (self: ^HeapDescriptor) -> ^HeapDescriptor { return msgSend(^HeapDescriptor, self, "init") } @(objc_type=HeapDescriptor, objc_name="cpuCacheMode") -HeapDescriptor_cpuCacheMode :: #force_inline proc(self: ^HeapDescriptor) -> CPUCacheMode { +HeapDescriptor_cpuCacheMode :: #force_inline proc "c" (self: ^HeapDescriptor) -> CPUCacheMode { return msgSend(CPUCacheMode, self, "cpuCacheMode") } @(objc_type=HeapDescriptor, objc_name="hazardTrackingMode") -HeapDescriptor_hazardTrackingMode :: #force_inline proc(self: ^HeapDescriptor) -> HazardTrackingMode { +HeapDescriptor_hazardTrackingMode :: #force_inline proc "c" (self: ^HeapDescriptor) -> HazardTrackingMode { return msgSend(HazardTrackingMode, self, "hazardTrackingMode") } @(objc_type=HeapDescriptor, objc_name="resourceOptions") -HeapDescriptor_resourceOptions :: #force_inline proc(self: ^HeapDescriptor) -> ResourceOptions { +HeapDescriptor_resourceOptions :: #force_inline proc "c" (self: ^HeapDescriptor) -> ResourceOptions { return msgSend(ResourceOptions, self, "resourceOptions") } @(objc_type=HeapDescriptor, objc_name="setCpuCacheMode") -HeapDescriptor_setCpuCacheMode :: #force_inline proc(self: ^HeapDescriptor, cpuCacheMode: CPUCacheMode) { +HeapDescriptor_setCpuCacheMode :: #force_inline proc "c" (self: ^HeapDescriptor, cpuCacheMode: CPUCacheMode) { msgSend(nil, self, "setCpuCacheMode:", cpuCacheMode) } + +@(objc_type=HeapDescriptor, objc_name="sparsePageSize") +HeapDescriptor_sparsePageSize :: #force_inline proc "c" (self: ^HeapDescriptor) -> SparsePageSize { + return msgSend(SparsePageSize, self, "sparsePageSize") +} +@(objc_type=HeapDescriptor, objc_name="setSparsePageSize") +HeapDescriptor_setSparsePageSize :: #force_inline proc "c" (self: ^HeapDescriptor, sparsePageSize: SparsePageSize) { + msgSend(nil, self, "setSparsePageSize:", sparsePageSize) +} + @(objc_type=HeapDescriptor, objc_name="setHazardTrackingMode") -HeapDescriptor_setHazardTrackingMode :: #force_inline proc(self: ^HeapDescriptor, hazardTrackingMode: HazardTrackingMode) { +HeapDescriptor_setHazardTrackingMode :: #force_inline proc "c" (self: ^HeapDescriptor, hazardTrackingMode: HazardTrackingMode) { msgSend(nil, self, "setHazardTrackingMode:", hazardTrackingMode) } @(objc_type=HeapDescriptor, objc_name="setResourceOptions") -HeapDescriptor_setResourceOptions :: #force_inline proc(self: ^HeapDescriptor, resourceOptions: ResourceOptions) { +HeapDescriptor_setResourceOptions :: #force_inline proc "c" (self: ^HeapDescriptor, resourceOptions: ResourceOptions) { msgSend(nil, self, "setResourceOptions:", resourceOptions) } @(objc_type=HeapDescriptor, objc_name="setSize") -HeapDescriptor_setSize :: #force_inline proc(self: ^HeapDescriptor, size: NS.UInteger) { +HeapDescriptor_setSize :: #force_inline proc "c" (self: ^HeapDescriptor, size: NS.UInteger) { msgSend(nil, self, "setSize:", size) } @(objc_type=HeapDescriptor, objc_name="setStorageMode") -HeapDescriptor_setStorageMode :: #force_inline proc(self: ^HeapDescriptor, storageMode: StorageMode) { +HeapDescriptor_setStorageMode :: #force_inline proc "c" (self: ^HeapDescriptor, storageMode: StorageMode) { msgSend(nil, self, "setStorageMode:", storageMode) } @(objc_type=HeapDescriptor, objc_name="setType") -HeapDescriptor_setType :: #force_inline proc(self: ^HeapDescriptor, type: HeapType) { +HeapDescriptor_setType :: #force_inline proc "c" (self: ^HeapDescriptor, type: HeapType) { msgSend(nil, self, "setType:", type) } @(objc_type=HeapDescriptor, objc_name="size") -HeapDescriptor_size :: #force_inline proc(self: ^HeapDescriptor) -> NS.UInteger { +HeapDescriptor_size :: #force_inline proc "c" (self: ^HeapDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "size") } @(objc_type=HeapDescriptor, objc_name="storageMode") -HeapDescriptor_storageMode :: #force_inline proc(self: ^HeapDescriptor) -> StorageMode { +HeapDescriptor_storageMode :: #force_inline proc "c" (self: ^HeapDescriptor) -> StorageMode { return msgSend(StorageMode, self, "storageMode") } @(objc_type=HeapDescriptor, objc_name="type") -HeapDescriptor_type :: #force_inline proc(self: ^HeapDescriptor) -> HeapType { +HeapDescriptor_type :: #force_inline proc "c" (self: ^HeapDescriptor) -> HeapType { return msgSend(HeapType, self, "type") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - IndirectCommandBufferDescriptor -Class Methods: - alloc -Methods: - init - commandTypes - inheritBuffers - inheritPipelineState - maxFragmentBufferBindCount - maxKernelBufferBindCount - maxVertexBufferBindCount - setCommandTypes - setInheritBuffers - setInheritPipelineState - setMaxFragmentBufferBindCount - setMaxKernelBufferBindCount - setMaxVertexBufferBindCount -*/ + @(objc_class="MTLIndirectCommandBufferDescriptor") IndirectCommandBufferDescriptor :: struct { using _: NS.Copying(IndirectCommandBufferDescriptor) } @(objc_type=IndirectCommandBufferDescriptor, objc_name="alloc", objc_is_class_method=true) -IndirectCommandBufferDescriptor_alloc :: #force_inline proc() -> ^IndirectCommandBufferDescriptor { +IndirectCommandBufferDescriptor_alloc :: #force_inline proc "c" () -> ^IndirectCommandBufferDescriptor { return msgSend(^IndirectCommandBufferDescriptor, IndirectCommandBufferDescriptor, "alloc") } @(objc_type=IndirectCommandBufferDescriptor, objc_name="init") -IndirectCommandBufferDescriptor_init :: #force_inline proc(self: ^IndirectCommandBufferDescriptor) -> ^IndirectCommandBufferDescriptor { +IndirectCommandBufferDescriptor_init :: #force_inline proc "c" (self: ^IndirectCommandBufferDescriptor) -> ^IndirectCommandBufferDescriptor { return msgSend(^IndirectCommandBufferDescriptor, self, "init") } @(objc_type=IndirectCommandBufferDescriptor, objc_name="commandTypes") -IndirectCommandBufferDescriptor_commandTypes :: #force_inline proc(self: ^IndirectCommandBufferDescriptor) -> IndirectCommandType { +IndirectCommandBufferDescriptor_commandTypes :: #force_inline proc "c" (self: ^IndirectCommandBufferDescriptor) -> IndirectCommandType { return msgSend(IndirectCommandType, self, "commandTypes") } @(objc_type=IndirectCommandBufferDescriptor, objc_name="inheritBuffers") -IndirectCommandBufferDescriptor_inheritBuffers :: #force_inline proc(self: ^IndirectCommandBufferDescriptor) -> BOOL { +IndirectCommandBufferDescriptor_inheritBuffers :: #force_inline proc "c" (self: ^IndirectCommandBufferDescriptor) -> BOOL { return msgSend(BOOL, self, "inheritBuffers") } @(objc_type=IndirectCommandBufferDescriptor, objc_name="inheritPipelineState") -IndirectCommandBufferDescriptor_inheritPipelineState :: #force_inline proc(self: ^IndirectCommandBufferDescriptor) -> BOOL { +IndirectCommandBufferDescriptor_inheritPipelineState :: #force_inline proc "c" (self: ^IndirectCommandBufferDescriptor) -> BOOL { return msgSend(BOOL, self, "inheritPipelineState") } @(objc_type=IndirectCommandBufferDescriptor, objc_name="maxFragmentBufferBindCount") -IndirectCommandBufferDescriptor_maxFragmentBufferBindCount :: #force_inline proc(self: ^IndirectCommandBufferDescriptor) -> NS.UInteger { +IndirectCommandBufferDescriptor_maxFragmentBufferBindCount :: #force_inline proc "c" (self: ^IndirectCommandBufferDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "maxFragmentBufferBindCount") } @(objc_type=IndirectCommandBufferDescriptor, objc_name="maxKernelBufferBindCount") -IndirectCommandBufferDescriptor_maxKernelBufferBindCount :: #force_inline proc(self: ^IndirectCommandBufferDescriptor) -> NS.UInteger { +IndirectCommandBufferDescriptor_maxKernelBufferBindCount :: #force_inline proc "c" (self: ^IndirectCommandBufferDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "maxKernelBufferBindCount") } @(objc_type=IndirectCommandBufferDescriptor, objc_name="maxVertexBufferBindCount") -IndirectCommandBufferDescriptor_maxVertexBufferBindCount :: #force_inline proc(self: ^IndirectCommandBufferDescriptor) -> NS.UInteger { +IndirectCommandBufferDescriptor_maxVertexBufferBindCount :: #force_inline proc "c" (self: ^IndirectCommandBufferDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "maxVertexBufferBindCount") } @(objc_type=IndirectCommandBufferDescriptor, objc_name="setCommandTypes") -IndirectCommandBufferDescriptor_setCommandTypes :: #force_inline proc(self: ^IndirectCommandBufferDescriptor, commandTypes: IndirectCommandType) { +IndirectCommandBufferDescriptor_setCommandTypes :: #force_inline proc "c" (self: ^IndirectCommandBufferDescriptor, commandTypes: IndirectCommandType) { msgSend(nil, self, "setCommandTypes:", commandTypes) } @(objc_type=IndirectCommandBufferDescriptor, objc_name="setInheritBuffers") -IndirectCommandBufferDescriptor_setInheritBuffers :: #force_inline proc(self: ^IndirectCommandBufferDescriptor, inheritBuffers: BOOL) { +IndirectCommandBufferDescriptor_setInheritBuffers :: #force_inline proc "c" (self: ^IndirectCommandBufferDescriptor, inheritBuffers: BOOL) { msgSend(nil, self, "setInheritBuffers:", inheritBuffers) } @(objc_type=IndirectCommandBufferDescriptor, objc_name="setInheritPipelineState") -IndirectCommandBufferDescriptor_setInheritPipelineState :: #force_inline proc(self: ^IndirectCommandBufferDescriptor, inheritPipelineState: BOOL) { +IndirectCommandBufferDescriptor_setInheritPipelineState :: #force_inline proc "c" (self: ^IndirectCommandBufferDescriptor, inheritPipelineState: BOOL) { msgSend(nil, self, "setInheritPipelineState:", inheritPipelineState) } @(objc_type=IndirectCommandBufferDescriptor, objc_name="setMaxFragmentBufferBindCount") -IndirectCommandBufferDescriptor_setMaxFragmentBufferBindCount :: #force_inline proc(self: ^IndirectCommandBufferDescriptor, maxFragmentBufferBindCount: NS.UInteger) { +IndirectCommandBufferDescriptor_setMaxFragmentBufferBindCount :: #force_inline proc "c" (self: ^IndirectCommandBufferDescriptor, maxFragmentBufferBindCount: NS.UInteger) { msgSend(nil, self, "setMaxFragmentBufferBindCount:", maxFragmentBufferBindCount) } @(objc_type=IndirectCommandBufferDescriptor, objc_name="setMaxKernelBufferBindCount") -IndirectCommandBufferDescriptor_setMaxKernelBufferBindCount :: #force_inline proc(self: ^IndirectCommandBufferDescriptor, maxKernelBufferBindCount: NS.UInteger) { +IndirectCommandBufferDescriptor_setMaxKernelBufferBindCount :: #force_inline proc "c" (self: ^IndirectCommandBufferDescriptor, maxKernelBufferBindCount: NS.UInteger) { msgSend(nil, self, "setMaxKernelBufferBindCount:", maxKernelBufferBindCount) } @(objc_type=IndirectCommandBufferDescriptor, objc_name="setMaxVertexBufferBindCount") -IndirectCommandBufferDescriptor_setMaxVertexBufferBindCount :: #force_inline proc(self: ^IndirectCommandBufferDescriptor, maxVertexBufferBindCount: NS.UInteger) { +IndirectCommandBufferDescriptor_setMaxVertexBufferBindCount :: #force_inline proc "c" (self: ^IndirectCommandBufferDescriptor, maxVertexBufferBindCount: NS.UInteger) { msgSend(nil, self, "setMaxVertexBufferBindCount:", maxVertexBufferBindCount) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - InstanceAccelerationStructureDescriptor -Class Methods: - alloc - descriptor -Methods: - init - instanceCount - instanceDescriptorBuffer - instanceDescriptorBufferOffset - instanceDescriptorStride - instancedAccelerationStructures - setInstanceCount - setInstanceDescriptorBuffer - setInstanceDescriptorBufferOffset - setInstanceDescriptorStride - setInstancedAccelerationStructures -*/ + @(objc_class="MTLInstanceAccelerationStructureDescriptor") InstanceAccelerationStructureDescriptor :: struct { using _: NS.Copying(InstanceAccelerationStructureDescriptor), using _: AccelerationStructureDescriptor } @(objc_type=InstanceAccelerationStructureDescriptor, objc_name="alloc", objc_is_class_method=true) -InstanceAccelerationStructureDescriptor_alloc :: #force_inline proc() -> ^InstanceAccelerationStructureDescriptor { +InstanceAccelerationStructureDescriptor_alloc :: #force_inline proc "c" () -> ^InstanceAccelerationStructureDescriptor { return msgSend(^InstanceAccelerationStructureDescriptor, InstanceAccelerationStructureDescriptor, "alloc") } @(objc_type=InstanceAccelerationStructureDescriptor, objc_name="init") -InstanceAccelerationStructureDescriptor_init :: #force_inline proc(self: ^InstanceAccelerationStructureDescriptor) -> ^InstanceAccelerationStructureDescriptor { +InstanceAccelerationStructureDescriptor_init :: #force_inline proc "c" (self: ^InstanceAccelerationStructureDescriptor) -> ^InstanceAccelerationStructureDescriptor { return msgSend(^InstanceAccelerationStructureDescriptor, self, "init") } @(objc_type=InstanceAccelerationStructureDescriptor, objc_name="descriptor", objc_is_class_method=true) -InstanceAccelerationStructureDescriptor_descriptor :: #force_inline proc() -> ^InstanceAccelerationStructureDescriptor { +InstanceAccelerationStructureDescriptor_descriptor :: #force_inline proc "c" () -> ^InstanceAccelerationStructureDescriptor { return msgSend(^InstanceAccelerationStructureDescriptor, InstanceAccelerationStructureDescriptor, "descriptor") } @(objc_type=InstanceAccelerationStructureDescriptor, objc_name="instanceCount") -InstanceAccelerationStructureDescriptor_instanceCount :: #force_inline proc(self: ^InstanceAccelerationStructureDescriptor) -> NS.UInteger { +InstanceAccelerationStructureDescriptor_instanceCount :: #force_inline proc "c" (self: ^InstanceAccelerationStructureDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "instanceCount") } @(objc_type=InstanceAccelerationStructureDescriptor, objc_name="instanceDescriptorBuffer") -InstanceAccelerationStructureDescriptor_instanceDescriptorBuffer :: #force_inline proc(self: ^InstanceAccelerationStructureDescriptor) -> ^Buffer { +InstanceAccelerationStructureDescriptor_instanceDescriptorBuffer :: #force_inline proc "c" (self: ^InstanceAccelerationStructureDescriptor) -> ^Buffer { return msgSend(^Buffer, self, "instanceDescriptorBuffer") } @(objc_type=InstanceAccelerationStructureDescriptor, objc_name="instanceDescriptorBufferOffset") -InstanceAccelerationStructureDescriptor_instanceDescriptorBufferOffset :: #force_inline proc(self: ^InstanceAccelerationStructureDescriptor) -> NS.UInteger { +InstanceAccelerationStructureDescriptor_instanceDescriptorBufferOffset :: #force_inline proc "c" (self: ^InstanceAccelerationStructureDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "instanceDescriptorBufferOffset") } @(objc_type=InstanceAccelerationStructureDescriptor, objc_name="instanceDescriptorStride") -InstanceAccelerationStructureDescriptor_instanceDescriptorStride :: #force_inline proc(self: ^InstanceAccelerationStructureDescriptor) -> NS.UInteger { +InstanceAccelerationStructureDescriptor_instanceDescriptorStride :: #force_inline proc "c" (self: ^InstanceAccelerationStructureDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "instanceDescriptorStride") } @(objc_type=InstanceAccelerationStructureDescriptor, objc_name="instancedAccelerationStructures") -InstanceAccelerationStructureDescriptor_instancedAccelerationStructures :: #force_inline proc(self: ^InstanceAccelerationStructureDescriptor) -> ^NS.Array { +InstanceAccelerationStructureDescriptor_instancedAccelerationStructures :: #force_inline proc "c" (self: ^InstanceAccelerationStructureDescriptor) -> ^NS.Array { return msgSend(^NS.Array, self, "instancedAccelerationStructures") } @(objc_type=InstanceAccelerationStructureDescriptor, objc_name="setInstanceCount") -InstanceAccelerationStructureDescriptor_setInstanceCount :: #force_inline proc(self: ^InstanceAccelerationStructureDescriptor, instanceCount: NS.UInteger) { +InstanceAccelerationStructureDescriptor_setInstanceCount :: #force_inline proc "c" (self: ^InstanceAccelerationStructureDescriptor, instanceCount: NS.UInteger) { msgSend(nil, self, "setInstanceCount:", instanceCount) } @(objc_type=InstanceAccelerationStructureDescriptor, objc_name="setInstanceDescriptorBuffer") -InstanceAccelerationStructureDescriptor_setInstanceDescriptorBuffer :: #force_inline proc(self: ^InstanceAccelerationStructureDescriptor, instanceDescriptorBuffer: ^Buffer) { +InstanceAccelerationStructureDescriptor_setInstanceDescriptorBuffer :: #force_inline proc "c" (self: ^InstanceAccelerationStructureDescriptor, instanceDescriptorBuffer: ^Buffer) { msgSend(nil, self, "setInstanceDescriptorBuffer:", instanceDescriptorBuffer) } @(objc_type=InstanceAccelerationStructureDescriptor, objc_name="setInstanceDescriptorBufferOffset") -InstanceAccelerationStructureDescriptor_setInstanceDescriptorBufferOffset :: #force_inline proc(self: ^InstanceAccelerationStructureDescriptor, instanceDescriptorBufferOffset: NS.UInteger) { +InstanceAccelerationStructureDescriptor_setInstanceDescriptorBufferOffset :: #force_inline proc "c" (self: ^InstanceAccelerationStructureDescriptor, instanceDescriptorBufferOffset: NS.UInteger) { msgSend(nil, self, "setInstanceDescriptorBufferOffset:", instanceDescriptorBufferOffset) } @(objc_type=InstanceAccelerationStructureDescriptor, objc_name="setInstanceDescriptorStride") -InstanceAccelerationStructureDescriptor_setInstanceDescriptorStride :: #force_inline proc(self: ^InstanceAccelerationStructureDescriptor, instanceDescriptorStride: NS.UInteger) { +InstanceAccelerationStructureDescriptor_setInstanceDescriptorStride :: #force_inline proc "c" (self: ^InstanceAccelerationStructureDescriptor, instanceDescriptorStride: NS.UInteger) { msgSend(nil, self, "setInstanceDescriptorStride:", instanceDescriptorStride) } @(objc_type=InstanceAccelerationStructureDescriptor, objc_name="setInstancedAccelerationStructures") -InstanceAccelerationStructureDescriptor_setInstancedAccelerationStructures :: #force_inline proc(self: ^InstanceAccelerationStructureDescriptor, instancedAccelerationStructures: ^NS.Array) { +InstanceAccelerationStructureDescriptor_setInstancedAccelerationStructures :: #force_inline proc "c" (self: ^InstanceAccelerationStructureDescriptor, instancedAccelerationStructures: ^NS.Array) { msgSend(nil, self, "setInstancedAccelerationStructures:", instancedAccelerationStructures) } @(objc_type=InstanceAccelerationStructureDescriptor, objc_name="instanceDescriptorType") -InstanceAccelerationStructureDescriptor_instanceDescriptorType :: #force_inline proc(self: ^InstanceAccelerationStructureDescriptor) -> AccelerationStructureInstanceDescriptorType { +InstanceAccelerationStructureDescriptor_instanceDescriptorType :: #force_inline proc "c" (self: ^InstanceAccelerationStructureDescriptor) -> AccelerationStructureInstanceDescriptorType { return msgSend(AccelerationStructureInstanceDescriptorType, self, "instanceDescriptorType") } @(objc_type=InstanceAccelerationStructureDescriptor, objc_name="setInstanceDescriptorType") -InstanceAccelerationStructureDescriptor_setInstanceDescriptorType :: #force_inline proc(self: ^InstanceAccelerationStructureDescriptor, buffer: AccelerationStructureInstanceDescriptorType) { +InstanceAccelerationStructureDescriptor_setInstanceDescriptorType :: #force_inline proc "c" (self: ^InstanceAccelerationStructureDescriptor, buffer: AccelerationStructureInstanceDescriptorType) { msgSend(nil, self, "setInstanceDescriptorType:", buffer) } @(objc_type=InstanceAccelerationStructureDescriptor, objc_name="motionTransformBuffer") -InstanceAccelerationStructureDescriptor_motionTransformBuffer :: #force_inline proc(self: ^InstanceAccelerationStructureDescriptor) -> ^Buffer { +InstanceAccelerationStructureDescriptor_motionTransformBuffer :: #force_inline proc "c" (self: ^InstanceAccelerationStructureDescriptor) -> ^Buffer { return msgSend(^Buffer, self, "motionTransformBuffer") } @(objc_type=InstanceAccelerationStructureDescriptor, objc_name="setMotionTransformBuffer") -InstanceAccelerationStructureDescriptor_setMotionTransformBuffer :: #force_inline proc(self: ^InstanceAccelerationStructureDescriptor, buffer: ^Buffer) { +InstanceAccelerationStructureDescriptor_setMotionTransformBuffer :: #force_inline proc "c" (self: ^InstanceAccelerationStructureDescriptor, buffer: ^Buffer) { msgSend(nil, self, "setMotionTransformBuffer:", buffer) } @(objc_type=InstanceAccelerationStructureDescriptor, objc_name="motionTransformBufferOffset") -InstanceAccelerationStructureDescriptor_motionTransformBufferOffset :: #force_inline proc(self: ^InstanceAccelerationStructureDescriptor) -> NS.UInteger { +InstanceAccelerationStructureDescriptor_motionTransformBufferOffset :: #force_inline proc "c" (self: ^InstanceAccelerationStructureDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "motionTransformBufferOffset") } @(objc_type=InstanceAccelerationStructureDescriptor, objc_name="setMotionTransformBufferOffset") -InstanceAccelerationStructureDescriptor_setMotionTransformBufferOffset :: #force_inline proc(self: ^InstanceAccelerationStructureDescriptor, offset: NS.UInteger) { +InstanceAccelerationStructureDescriptor_setMotionTransformBufferOffset :: #force_inline proc "c" (self: ^InstanceAccelerationStructureDescriptor, offset: NS.UInteger) { msgSend(nil, self, "setMotionTransformBufferOffset:", offset) } @(objc_type=InstanceAccelerationStructureDescriptor, objc_name="motionTransformCount") -InstanceAccelerationStructureDescriptor_motionTransformCount :: #force_inline proc(self: ^InstanceAccelerationStructureDescriptor) -> NS.UInteger { +InstanceAccelerationStructureDescriptor_motionTransformCount :: #force_inline proc "c" (self: ^InstanceAccelerationStructureDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "motionTransformCount") } @(objc_type=InstanceAccelerationStructureDescriptor, objc_name="setMotionTransformCount") -InstanceAccelerationStructureDescriptor_setMotionTransformCount :: #force_inline proc(self: ^InstanceAccelerationStructureDescriptor, offset: NS.UInteger) { +InstanceAccelerationStructureDescriptor_setMotionTransformCount :: #force_inline proc "c" (self: ^InstanceAccelerationStructureDescriptor, offset: NS.UInteger) { msgSend(nil, self, "setMotionTransformCount:", offset) } @@ -2211,299 +1822,233 @@ InstanceAccelerationStructureDescriptor_setMotionTransformCount :: #force_inline //////////////////////////////////////////////////////////////////////////////// -/* -Class: - IntersectionFunctionTableDescriptor -Class Methods: - alloc - intersectionFunctionTableDescriptor -Methods: - init - functionCount - setFunctionCount -*/ + @(objc_class="MTLIntersectionFunctionTableDescriptor") IntersectionFunctionTableDescriptor :: struct { using _: NS.Copying(IntersectionFunctionTableDescriptor) } @(objc_type=IntersectionFunctionTableDescriptor, objc_name="alloc", objc_is_class_method=true) -IntersectionFunctionTableDescriptor_alloc :: #force_inline proc() -> ^IntersectionFunctionTableDescriptor { +IntersectionFunctionTableDescriptor_alloc :: #force_inline proc "c" () -> ^IntersectionFunctionTableDescriptor { return msgSend(^IntersectionFunctionTableDescriptor, IntersectionFunctionTableDescriptor, "alloc") } @(objc_type=IntersectionFunctionTableDescriptor, objc_name="init") -IntersectionFunctionTableDescriptor_init :: #force_inline proc(self: ^IntersectionFunctionTableDescriptor) -> ^IntersectionFunctionTableDescriptor { +IntersectionFunctionTableDescriptor_init :: #force_inline proc "c" (self: ^IntersectionFunctionTableDescriptor) -> ^IntersectionFunctionTableDescriptor { return msgSend(^IntersectionFunctionTableDescriptor, self, "init") } @(objc_type=IntersectionFunctionTableDescriptor, objc_name="functionCount") -IntersectionFunctionTableDescriptor_functionCount :: #force_inline proc(self: ^IntersectionFunctionTableDescriptor) -> NS.UInteger { +IntersectionFunctionTableDescriptor_functionCount :: #force_inline proc "c" (self: ^IntersectionFunctionTableDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "functionCount") } @(objc_type=IntersectionFunctionTableDescriptor, objc_name="intersectionFunctionTableDescriptor", objc_is_class_method=true) -IntersectionFunctionTableDescriptor_intersectionFunctionTableDescriptor :: #force_inline proc() -> ^IntersectionFunctionTableDescriptor { +IntersectionFunctionTableDescriptor_intersectionFunctionTableDescriptor :: #force_inline proc "c" () -> ^IntersectionFunctionTableDescriptor { return msgSend(^IntersectionFunctionTableDescriptor, IntersectionFunctionTableDescriptor, "intersectionFunctionTableDescriptor") } @(objc_type=IntersectionFunctionTableDescriptor, objc_name="setFunctionCount") -IntersectionFunctionTableDescriptor_setFunctionCount :: #force_inline proc(self: ^IntersectionFunctionTableDescriptor, functionCount: NS.UInteger) { +IntersectionFunctionTableDescriptor_setFunctionCount :: #force_inline proc "c" (self: ^IntersectionFunctionTableDescriptor, functionCount: NS.UInteger) { msgSend(nil, self, "setFunctionCount:", functionCount) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - LinkedFunctions -Class Methods: - alloc - linkedFunctions -Methods: - init - binaryFunctions - functions - groups - setBinaryFunctions - setFunctions - setGroups -*/ + @(objc_class="MTLLinkedFunctions") LinkedFunctions :: struct { using _: NS.Copying(LinkedFunctions) } @(objc_type=LinkedFunctions, objc_name="alloc", objc_is_class_method=true) -LinkedFunctions_alloc :: #force_inline proc() -> ^LinkedFunctions { +LinkedFunctions_alloc :: #force_inline proc "c" () -> ^LinkedFunctions { return msgSend(^LinkedFunctions, LinkedFunctions, "alloc") } @(objc_type=LinkedFunctions, objc_name="init") -LinkedFunctions_init :: #force_inline proc(self: ^LinkedFunctions) -> ^LinkedFunctions { +LinkedFunctions_init :: #force_inline proc "c" (self: ^LinkedFunctions) -> ^LinkedFunctions { return msgSend(^LinkedFunctions, self, "init") } @(objc_type=LinkedFunctions, objc_name="binaryFunctions") -LinkedFunctions_binaryFunctions :: #force_inline proc(self: ^LinkedFunctions) -> ^NS.Array { +LinkedFunctions_binaryFunctions :: #force_inline proc "c" (self: ^LinkedFunctions) -> ^NS.Array { return msgSend(^NS.Array, self, "binaryFunctions") } @(objc_type=LinkedFunctions, objc_name="functions") -LinkedFunctions_functions :: #force_inline proc(self: ^LinkedFunctions) -> ^NS.Array { +LinkedFunctions_functions :: #force_inline proc "c" (self: ^LinkedFunctions) -> ^NS.Array { return msgSend(^NS.Array, self, "functions") } @(objc_type=LinkedFunctions, objc_name="groups") -LinkedFunctions_groups :: #force_inline proc(self: ^LinkedFunctions) -> ^NS.Dictionary { +LinkedFunctions_groups :: #force_inline proc "c" (self: ^LinkedFunctions) -> ^NS.Dictionary { return msgSend(^NS.Dictionary, self, "groups") } @(objc_type=LinkedFunctions, objc_name="linkedFunctions", objc_is_class_method=true) -LinkedFunctions_linkedFunctions :: #force_inline proc() -> ^LinkedFunctions { +LinkedFunctions_linkedFunctions :: #force_inline proc "c" () -> ^LinkedFunctions { return msgSend(^LinkedFunctions, LinkedFunctions, "linkedFunctions") } @(objc_type=LinkedFunctions, objc_name="setBinaryFunctions") -LinkedFunctions_setBinaryFunctions :: #force_inline proc(self: ^LinkedFunctions, binaryFunctions: ^NS.Array) { +LinkedFunctions_setBinaryFunctions :: #force_inline proc "c" (self: ^LinkedFunctions, binaryFunctions: ^NS.Array) { msgSend(nil, self, "setBinaryFunctions:", binaryFunctions) } @(objc_type=LinkedFunctions, objc_name="setFunctions") -LinkedFunctions_setFunctions :: #force_inline proc(self: ^LinkedFunctions, functions: ^NS.Array) { +LinkedFunctions_setFunctions :: #force_inline proc "c" (self: ^LinkedFunctions, functions: ^NS.Array) { msgSend(nil, self, "setFunctions:", functions) } @(objc_type=LinkedFunctions, objc_name="setGroups") -LinkedFunctions_setGroups :: #force_inline proc(self: ^LinkedFunctions, groups: ^NS.Dictionary) { +LinkedFunctions_setGroups :: #force_inline proc "c" (self: ^LinkedFunctions, groups: ^NS.Dictionary) { msgSend(nil, self, "setGroups:", groups) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - PipelineBufferDescriptor -Class Methods: - alloc -Methods: - init - mutability - setMutability -*/ + @(objc_class="MTLPipelineBufferDescriptor") PipelineBufferDescriptor :: struct { using _: NS.Copying(PipelineBufferDescriptor) } @(objc_type=PipelineBufferDescriptor, objc_name="alloc", objc_is_class_method=true) -PipelineBufferDescriptor_alloc :: #force_inline proc() -> ^PipelineBufferDescriptor { +PipelineBufferDescriptor_alloc :: #force_inline proc "c" () -> ^PipelineBufferDescriptor { return msgSend(^PipelineBufferDescriptor, PipelineBufferDescriptor, "alloc") } @(objc_type=PipelineBufferDescriptor, objc_name="init") -PipelineBufferDescriptor_init :: #force_inline proc(self: ^PipelineBufferDescriptor) -> ^PipelineBufferDescriptor { +PipelineBufferDescriptor_init :: #force_inline proc "c" (self: ^PipelineBufferDescriptor) -> ^PipelineBufferDescriptor { return msgSend(^PipelineBufferDescriptor, self, "init") } @(objc_type=PipelineBufferDescriptor, objc_name="mutability") -PipelineBufferDescriptor_mutability :: #force_inline proc(self: ^PipelineBufferDescriptor) -> Mutability { +PipelineBufferDescriptor_mutability :: #force_inline proc "c" (self: ^PipelineBufferDescriptor) -> Mutability { return msgSend(Mutability, self, "mutability") } @(objc_type=PipelineBufferDescriptor, objc_name="setMutability") -PipelineBufferDescriptor_setMutability :: #force_inline proc(self: ^PipelineBufferDescriptor, mutability: Mutability) { +PipelineBufferDescriptor_setMutability :: #force_inline proc "c" (self: ^PipelineBufferDescriptor, mutability: Mutability) { msgSend(nil, self, "setMutability:", mutability) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - PipelineBufferDescriptorArray -Class Methods: - alloc -Methods: - init - objectAtIndexedSubscript - setObject -*/ + @(objc_class="MTLPipelineBufferDescriptorArray") PipelineBufferDescriptorArray :: struct { using _: NS.Object } @(objc_type=PipelineBufferDescriptorArray, objc_name="alloc", objc_is_class_method=true) -PipelineBufferDescriptorArray_alloc :: #force_inline proc() -> ^PipelineBufferDescriptorArray { +PipelineBufferDescriptorArray_alloc :: #force_inline proc "c" () -> ^PipelineBufferDescriptorArray { return msgSend(^PipelineBufferDescriptorArray, PipelineBufferDescriptorArray, "alloc") } @(objc_type=PipelineBufferDescriptorArray, objc_name="init") -PipelineBufferDescriptorArray_init :: #force_inline proc(self: ^PipelineBufferDescriptorArray) -> ^PipelineBufferDescriptorArray { +PipelineBufferDescriptorArray_init :: #force_inline proc "c" (self: ^PipelineBufferDescriptorArray) -> ^PipelineBufferDescriptorArray { return msgSend(^PipelineBufferDescriptorArray, self, "init") } @(objc_type=PipelineBufferDescriptorArray, objc_name="object") -PipelineBufferDescriptorArray_object :: #force_inline proc(self: ^PipelineBufferDescriptorArray, bufferIndex: NS.UInteger) -> ^PipelineBufferDescriptor { +PipelineBufferDescriptorArray_object :: #force_inline proc "c" (self: ^PipelineBufferDescriptorArray, bufferIndex: NS.UInteger) -> ^PipelineBufferDescriptor { return msgSend(^PipelineBufferDescriptor, self, "objectAtIndexedSubscript:", bufferIndex) } @(objc_type=PipelineBufferDescriptorArray, objc_name="setObject") -PipelineBufferDescriptorArray_setObject :: #force_inline proc(self: ^PipelineBufferDescriptorArray, buffer: ^PipelineBufferDescriptor, bufferIndex: NS.UInteger) { +PipelineBufferDescriptorArray_setObject :: #force_inline proc "c" (self: ^PipelineBufferDescriptorArray, buffer: ^PipelineBufferDescriptor, bufferIndex: NS.UInteger) { msgSend(nil, self, "setObject:atIndexedSubscript:", buffer, bufferIndex) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - PointerType -Class Methods: - alloc -Methods: - init - access - alignment - dataSize - elementArrayType - elementIsArgumentBuffer - elementStructType - elementType -*/ + @(objc_class="MTLPointerType") PointerType :: struct { using _: Type } @(objc_type=PointerType, objc_name="alloc", objc_is_class_method=true) -PointerType_alloc :: #force_inline proc() -> ^PointerType { +PointerType_alloc :: #force_inline proc "c" () -> ^PointerType { return msgSend(^PointerType, PointerType, "alloc") } @(objc_type=PointerType, objc_name="init") -PointerType_init :: #force_inline proc(self: ^PointerType) -> ^PointerType { +PointerType_init :: #force_inline proc "c" (self: ^PointerType) -> ^PointerType { return msgSend(^PointerType, self, "init") } @(objc_type=PointerType, objc_name="access") -PointerType_access :: #force_inline proc(self: ^PointerType) -> ArgumentAccess { +PointerType_access :: #force_inline proc "c" (self: ^PointerType) -> ArgumentAccess { return msgSend(ArgumentAccess, self, "access") } @(objc_type=PointerType, objc_name="alignment") -PointerType_alignment :: #force_inline proc(self: ^PointerType) -> NS.UInteger { +PointerType_alignment :: #force_inline proc "c" (self: ^PointerType) -> NS.UInteger { return msgSend(NS.UInteger, self, "alignment") } @(objc_type=PointerType, objc_name="dataSize") -PointerType_dataSize :: #force_inline proc(self: ^PointerType) -> NS.UInteger { +PointerType_dataSize :: #force_inline proc "c" (self: ^PointerType) -> NS.UInteger { return msgSend(NS.UInteger, self, "dataSize") } @(objc_type=PointerType, objc_name="elementArrayType") -PointerType_elementArrayType :: #force_inline proc(self: ^PointerType) -> ^ArrayType { +PointerType_elementArrayType :: #force_inline proc "c" (self: ^PointerType) -> ^ArrayType { return msgSend(^ArrayType, self, "elementArrayType") } @(objc_type=PointerType, objc_name="elementIsArgumentBuffer") -PointerType_elementIsArgumentBuffer :: #force_inline proc(self: ^PointerType) -> BOOL { +PointerType_elementIsArgumentBuffer :: #force_inline proc "c" (self: ^PointerType) -> BOOL { return msgSend(BOOL, self, "elementIsArgumentBuffer") } @(objc_type=PointerType, objc_name="elementStructType") -PointerType_elementStructType :: #force_inline proc(self: ^PointerType) -> ^StructType { +PointerType_elementStructType :: #force_inline proc "c" (self: ^PointerType) -> ^StructType { return msgSend(^StructType, self, "elementStructType") } @(objc_type=PointerType, objc_name="elementType") -PointerType_elementType :: #force_inline proc(self: ^PointerType) -> DataType { +PointerType_elementType :: #force_inline proc "c" (self: ^PointerType) -> DataType { return msgSend(DataType, self, "elementType") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - PrimitiveAccelerationStructureDescriptor -Class Methods: - alloc - descriptor -Methods: - init - geometryDescriptors - setGeometryDescriptors -*/ + @(objc_class="MTLPrimitiveAccelerationStructureDescriptor") PrimitiveAccelerationStructureDescriptor :: struct { using _: NS.Copying(PrimitiveAccelerationStructureDescriptor), using _: AccelerationStructureDescriptor } @(objc_type=PrimitiveAccelerationStructureDescriptor, objc_name="alloc", objc_is_class_method=true) -PrimitiveAccelerationStructureDescriptor_alloc :: #force_inline proc() -> ^PrimitiveAccelerationStructureDescriptor { +PrimitiveAccelerationStructureDescriptor_alloc :: #force_inline proc "c" () -> ^PrimitiveAccelerationStructureDescriptor { return msgSend(^PrimitiveAccelerationStructureDescriptor, PrimitiveAccelerationStructureDescriptor, "alloc") } @(objc_type=PrimitiveAccelerationStructureDescriptor, objc_name="init") -PrimitiveAccelerationStructureDescriptor_init :: #force_inline proc(self: ^PrimitiveAccelerationStructureDescriptor) -> ^PrimitiveAccelerationStructureDescriptor { +PrimitiveAccelerationStructureDescriptor_init :: #force_inline proc "c" (self: ^PrimitiveAccelerationStructureDescriptor) -> ^PrimitiveAccelerationStructureDescriptor { return msgSend(^PrimitiveAccelerationStructureDescriptor, self, "init") } @(objc_type=PrimitiveAccelerationStructureDescriptor, objc_name="descriptor", objc_is_class_method=true) -PrimitiveAccelerationStructureDescriptor_descriptor :: #force_inline proc() -> ^PrimitiveAccelerationStructureDescriptor { +PrimitiveAccelerationStructureDescriptor_descriptor :: #force_inline proc "c" () -> ^PrimitiveAccelerationStructureDescriptor { return msgSend(^PrimitiveAccelerationStructureDescriptor, PrimitiveAccelerationStructureDescriptor, "descriptor") } @(objc_type=PrimitiveAccelerationStructureDescriptor, objc_name="geometryDescriptors") -PrimitiveAccelerationStructureDescriptor_geometryDescriptors :: #force_inline proc(self: ^PrimitiveAccelerationStructureDescriptor) -> ^NS.Array { +PrimitiveAccelerationStructureDescriptor_geometryDescriptors :: #force_inline proc "c" (self: ^PrimitiveAccelerationStructureDescriptor) -> ^NS.Array { return msgSend(^NS.Array, self, "geometryDescriptors") } @(objc_type=PrimitiveAccelerationStructureDescriptor, objc_name="setGeometryDescriptors") -PrimitiveAccelerationStructureDescriptor_setGeometryDescriptors :: #force_inline proc(self: ^PrimitiveAccelerationStructureDescriptor, geometryDescriptors: ^NS.Array) { +PrimitiveAccelerationStructureDescriptor_setGeometryDescriptors :: #force_inline proc "c" (self: ^PrimitiveAccelerationStructureDescriptor, geometryDescriptors: ^NS.Array) { msgSend(nil, self, "setGeometryDescriptors:", geometryDescriptors) } @(objc_type=PrimitiveAccelerationStructureDescriptor, objc_name="motionStartBorderMode") -PrimitiveAccelerationStructureDescriptor_motionStartBorderMode :: #force_inline proc(self: ^PrimitiveAccelerationStructureDescriptor) -> MotionBorderMode { +PrimitiveAccelerationStructureDescriptor_motionStartBorderMode :: #force_inline proc "c" (self: ^PrimitiveAccelerationStructureDescriptor) -> MotionBorderMode { return msgSend(MotionBorderMode, self, "motionStartBorderMode") } @(objc_type=PrimitiveAccelerationStructureDescriptor, objc_name="setMotionStartBorderMode") -PrimitiveAccelerationStructureDescriptor_setMotionStartBorderMode :: #force_inline proc(self: ^PrimitiveAccelerationStructureDescriptor, motionStartBorderMode: MotionBorderMode) { +PrimitiveAccelerationStructureDescriptor_setMotionStartBorderMode :: #force_inline proc "c" (self: ^PrimitiveAccelerationStructureDescriptor, motionStartBorderMode: MotionBorderMode) { msgSend(nil, self, "setMotionStartBorderMode:", motionStartBorderMode) } @(objc_type=PrimitiveAccelerationStructureDescriptor, objc_name="motionEndBorderMode") -PrimitiveAccelerationStructureDescriptor_motionEndBorderMode :: #force_inline proc(self: ^PrimitiveAccelerationStructureDescriptor) -> MotionBorderMode { +PrimitiveAccelerationStructureDescriptor_motionEndBorderMode :: #force_inline proc "c" (self: ^PrimitiveAccelerationStructureDescriptor) -> MotionBorderMode { return msgSend(MotionBorderMode, self, "motionEndBorderMode") } @(objc_type=PrimitiveAccelerationStructureDescriptor, objc_name="setMotionEndBorderMode") -PrimitiveAccelerationStructureDescriptor_setMotionEndBorderMode :: #force_inline proc(self: ^PrimitiveAccelerationStructureDescriptor, motionEndBorderMode: MotionBorderMode) { +PrimitiveAccelerationStructureDescriptor_setMotionEndBorderMode :: #force_inline proc "c" (self: ^PrimitiveAccelerationStructureDescriptor, motionEndBorderMode: MotionBorderMode) { msgSend(nil, self, "setMotionEndBorderMode:", motionEndBorderMode) } @(objc_type=PrimitiveAccelerationStructureDescriptor, objc_name="motionStartTime") -PrimitiveAccelerationStructureDescriptor_motionStartTime :: #force_inline proc(self: ^PrimitiveAccelerationStructureDescriptor) -> f32 { +PrimitiveAccelerationStructureDescriptor_motionStartTime :: #force_inline proc "c" (self: ^PrimitiveAccelerationStructureDescriptor) -> f32 { return msgSend(f32, self, "motionStartTime") } @(objc_type=PrimitiveAccelerationStructureDescriptor, objc_name="setMotionStartTime") -PrimitiveAccelerationStructureDescriptor_setMotionStartTime :: #force_inline proc(self: ^PrimitiveAccelerationStructureDescriptor, motionStartTime: f32) { +PrimitiveAccelerationStructureDescriptor_setMotionStartTime :: #force_inline proc "c" (self: ^PrimitiveAccelerationStructureDescriptor, motionStartTime: f32) { msgSend(nil, self, "setMotionStartTime:", motionStartTime) } @(objc_type=PrimitiveAccelerationStructureDescriptor, objc_name="motionEndTime") -PrimitiveAccelerationStructureDescriptor_motionEndTime :: #force_inline proc(self: ^PrimitiveAccelerationStructureDescriptor) -> f32 { +PrimitiveAccelerationStructureDescriptor_motionEndTime :: #force_inline proc "c" (self: ^PrimitiveAccelerationStructureDescriptor) -> f32 { return msgSend(f32, self, "motionEndTime") } @(objc_type=PrimitiveAccelerationStructureDescriptor, objc_name="setMotionEndTime") -PrimitiveAccelerationStructureDescriptor_setMotionEndTime :: #force_inline proc(self: ^PrimitiveAccelerationStructureDescriptor, motionEndTime: f32) { +PrimitiveAccelerationStructureDescriptor_setMotionEndTime :: #force_inline proc "c" (self: ^PrimitiveAccelerationStructureDescriptor, motionEndTime: f32) { msgSend(nil, self, "setMotionEndTime:", motionEndTime) } @(objc_type=PrimitiveAccelerationStructureDescriptor, objc_name="motionKeyframeCount") -PrimitiveAccelerationStructureDescriptor_motionKeyframeCount :: #force_inline proc(self: ^PrimitiveAccelerationStructureDescriptor) -> NS.UInteger { +PrimitiveAccelerationStructureDescriptor_motionKeyframeCount :: #force_inline proc "c" (self: ^PrimitiveAccelerationStructureDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "motionKeyframeCount") } @(objc_type=PrimitiveAccelerationStructureDescriptor, objc_name="setMotionKeyframeCount") -PrimitiveAccelerationStructureDescriptor_setMotionKeyframeCount :: #force_inline proc(self: ^PrimitiveAccelerationStructureDescriptor, motionKeyframeCount: NS.UInteger) { +PrimitiveAccelerationStructureDescriptor_setMotionKeyframeCount :: #force_inline proc "c" (self: ^PrimitiveAccelerationStructureDescriptor, motionKeyframeCount: NS.UInteger) { msgSend(nil, self, "setMotionKeyframeCount:", motionKeyframeCount) } @@ -2511,4025 +2056,3377 @@ PrimitiveAccelerationStructureDescriptor_setMotionKeyframeCount :: #force_inline //////////////////////////////////////////////////////////////////////////////// -/* -Class: - RasterizationRateLayerArray -Class Methods: - alloc -Methods: - init - objectAtIndexedSubscript - setObject -*/ + @(objc_class="MTLRasterizationRateLayerArray") RasterizationRateLayerArray :: struct { using _: NS.Object } @(objc_type=RasterizationRateLayerArray, objc_name="alloc", objc_is_class_method=true) -RasterizationRateLayerArray_alloc :: #force_inline proc() -> ^RasterizationRateLayerArray { +RasterizationRateLayerArray_alloc :: #force_inline proc "c" () -> ^RasterizationRateLayerArray { return msgSend(^RasterizationRateLayerArray, RasterizationRateLayerArray, "alloc") } @(objc_type=RasterizationRateLayerArray, objc_name="init") -RasterizationRateLayerArray_init :: #force_inline proc(self: ^RasterizationRateLayerArray) -> ^RasterizationRateLayerArray { +RasterizationRateLayerArray_init :: #force_inline proc "c" (self: ^RasterizationRateLayerArray) -> ^RasterizationRateLayerArray { return msgSend(^RasterizationRateLayerArray, self, "init") } @(objc_type=RasterizationRateLayerArray, objc_name="object") -RasterizationRateLayerArray_object :: #force_inline proc(self: ^RasterizationRateLayerArray, layerIndex: NS.UInteger) -> ^RasterizationRateLayerDescriptor { +RasterizationRateLayerArray_object :: #force_inline proc "c" (self: ^RasterizationRateLayerArray, layerIndex: NS.UInteger) -> ^RasterizationRateLayerDescriptor { return msgSend(^RasterizationRateLayerDescriptor, self, "objectAtIndexedSubscript:", layerIndex) } @(objc_type=RasterizationRateLayerArray, objc_name="setObject") -RasterizationRateLayerArray_setObject :: #force_inline proc(self: ^RasterizationRateLayerArray, layer: ^RasterizationRateLayerDescriptor, layerIndex: NS.UInteger) { +RasterizationRateLayerArray_setObject :: #force_inline proc "c" (self: ^RasterizationRateLayerArray, layer: ^RasterizationRateLayerDescriptor, layerIndex: NS.UInteger) { msgSend(nil, self, "setObject:atIndexedSubscript:", layer, layerIndex) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - RasterizationRateLayerDescriptor -Class Methods: - alloc -Methods: - horizontal - horizontalSampleStorage - init - initWithSampleCount - initWithSampleCount - sampleCount - vertical - verticalSampleStorage -*/ + @(objc_class="MTLRasterizationRateLayerDescriptor") RasterizationRateLayerDescriptor :: struct { using _: NS.Copying(RasterizationRateLayerDescriptor) } @(objc_type=RasterizationRateLayerDescriptor, objc_name="alloc", objc_is_class_method=true) -RasterizationRateLayerDescriptor_alloc :: #force_inline proc() -> ^RasterizationRateLayerDescriptor { +RasterizationRateLayerDescriptor_alloc :: #force_inline proc "c" () -> ^RasterizationRateLayerDescriptor { return msgSend(^RasterizationRateLayerDescriptor, RasterizationRateLayerDescriptor, "alloc") } @(objc_type=RasterizationRateLayerDescriptor, objc_name="horizontal") -RasterizationRateLayerDescriptor_horizontal :: #force_inline proc(self: ^RasterizationRateLayerDescriptor) -> ^RasterizationRateSampleArray { +RasterizationRateLayerDescriptor_horizontal :: #force_inline proc "c" (self: ^RasterizationRateLayerDescriptor) -> ^RasterizationRateSampleArray { return msgSend(^RasterizationRateSampleArray, self, "horizontal") } @(objc_type=RasterizationRateLayerDescriptor, objc_name="horizontalSampleStorage") -RasterizationRateLayerDescriptor_horizontalSampleStorage :: #force_inline proc(self: ^RasterizationRateLayerDescriptor) -> [^]f32 { // TODO: how could this be made into a slice? +RasterizationRateLayerDescriptor_horizontalSampleStorage :: #force_inline proc "c" (self: ^RasterizationRateLayerDescriptor) -> [^]f32 { // TODO: how could this be made into a slice? return msgSend([^]f32, self, "horizontalSampleStorage") } @(objc_type=RasterizationRateLayerDescriptor, objc_name="init") -RasterizationRateLayerDescriptor_init :: #force_inline proc(self: ^RasterizationRateLayerDescriptor) -> ^RasterizationRateLayerDescriptor { +RasterizationRateLayerDescriptor_init :: #force_inline proc "c" (self: ^RasterizationRateLayerDescriptor) -> ^RasterizationRateLayerDescriptor { return msgSend(^RasterizationRateLayerDescriptor, self, "init") } @(objc_type=RasterizationRateLayerDescriptor, objc_name="initWithSampleCount") -RasterizationRateLayerDescriptor_initWithSampleCount :: #force_inline proc(self: ^RasterizationRateLayerDescriptor, sampleCount: Size) -> ^RasterizationRateLayerDescriptor { +RasterizationRateLayerDescriptor_initWithSampleCount :: #force_inline proc "c" (self: ^RasterizationRateLayerDescriptor, sampleCount: Size) -> ^RasterizationRateLayerDescriptor { return msgSend(^RasterizationRateLayerDescriptor, self, "initWithSampleCount:", sampleCount) } @(objc_type=RasterizationRateLayerDescriptor, objc_name="initWithSampleCountWithDimensions") -RasterizationRateLayerDescriptor_initWithSampleCountWithDimensions :: #force_inline proc(self: ^RasterizationRateLayerDescriptor, sampleCount: Size, horizontal: []f32, vertical: []f32) -> ^RasterizationRateLayerDescriptor { +RasterizationRateLayerDescriptor_initWithSampleCountWithDimensions :: #force_inline proc "c" (self: ^RasterizationRateLayerDescriptor, sampleCount: Size, horizontal: []f32, vertical: []f32) -> ^RasterizationRateLayerDescriptor { return msgSend(^RasterizationRateLayerDescriptor, self, "initWithSampleCount:horizontal:vertical:", sampleCount, raw_data(horizontal), raw_data(vertical)) } @(objc_type=RasterizationRateLayerDescriptor, objc_name="sampleCount") -RasterizationRateLayerDescriptor_sampleCount :: #force_inline proc(self: ^RasterizationRateLayerDescriptor) -> Size { +RasterizationRateLayerDescriptor_sampleCount :: #force_inline proc "c" (self: ^RasterizationRateLayerDescriptor) -> Size { return msgSend(Size, self, "sampleCount") } @(objc_type=RasterizationRateLayerDescriptor, objc_name="vertical") -RasterizationRateLayerDescriptor_vertical :: #force_inline proc(self: ^RasterizationRateLayerDescriptor) -> ^RasterizationRateSampleArray { +RasterizationRateLayerDescriptor_vertical :: #force_inline proc "c" (self: ^RasterizationRateLayerDescriptor) -> ^RasterizationRateSampleArray { return msgSend(^RasterizationRateSampleArray, self, "vertical") } @(objc_type=RasterizationRateLayerDescriptor, objc_name="verticalSampleStorage") -RasterizationRateLayerDescriptor_verticalSampleStorage :: #force_inline proc(self: ^RasterizationRateLayerDescriptor) -> [^]f32 { // TODO: how could this be made into a slice? +RasterizationRateLayerDescriptor_verticalSampleStorage :: #force_inline proc "c" (self: ^RasterizationRateLayerDescriptor) -> [^]f32 { // TODO: how could this be made into a slice? return msgSend([^]f32, self, "verticalSampleStorage") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - RasterizationRateMapDescriptor -Class Methods: - alloc - rasterizationRateMapDescriptorWithScreenSize - rasterizationRateMapDescriptorWithScreenSize - rasterizationRateMapDescriptorWithScreenSize -Methods: - init - label - layerAtIndex - layerCount - layers - screenSize - setLabel - setLayer - setScreenSize -*/ + @(objc_class="MTLRasterizationRateMapDescriptor") RasterizationRateMapDescriptor :: struct { using _: NS.Copying(RasterizationRateMapDescriptor) } @(objc_type=RasterizationRateMapDescriptor, objc_name="alloc", objc_is_class_method=true) -RasterizationRateMapDescriptor_alloc :: #force_inline proc() -> ^RasterizationRateMapDescriptor { +RasterizationRateMapDescriptor_alloc :: #force_inline proc "c" () -> ^RasterizationRateMapDescriptor { return msgSend(^RasterizationRateMapDescriptor, RasterizationRateMapDescriptor, "alloc") } @(objc_type=RasterizationRateMapDescriptor, objc_name="init") -RasterizationRateMapDescriptor_init :: #force_inline proc(self: ^RasterizationRateMapDescriptor) -> ^RasterizationRateMapDescriptor { +RasterizationRateMapDescriptor_init :: #force_inline proc "c" (self: ^RasterizationRateMapDescriptor) -> ^RasterizationRateMapDescriptor { return msgSend(^RasterizationRateMapDescriptor, self, "init") } @(objc_type=RasterizationRateMapDescriptor, objc_name="label") -RasterizationRateMapDescriptor_label :: #force_inline proc(self: ^RasterizationRateMapDescriptor) -> ^NS.String { +RasterizationRateMapDescriptor_label :: #force_inline proc "c" (self: ^RasterizationRateMapDescriptor) -> ^NS.String { return msgSend(^NS.String, self, "label") } @(objc_type=RasterizationRateMapDescriptor, objc_name="layer") -RasterizationRateMapDescriptor_layer :: #force_inline proc(self: ^RasterizationRateMapDescriptor, layerIndex: NS.UInteger) -> ^RasterizationRateLayerDescriptor { +RasterizationRateMapDescriptor_layer :: #force_inline proc "c" (self: ^RasterizationRateMapDescriptor, layerIndex: NS.UInteger) -> ^RasterizationRateLayerDescriptor { return msgSend(^RasterizationRateLayerDescriptor, self, "layerAtIndex:", layerIndex) } @(objc_type=RasterizationRateMapDescriptor, objc_name="layerCount") -RasterizationRateMapDescriptor_layerCount :: #force_inline proc(self: ^RasterizationRateMapDescriptor) -> NS.UInteger { +RasterizationRateMapDescriptor_layerCount :: #force_inline proc "c" (self: ^RasterizationRateMapDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "layerCount") } @(objc_type=RasterizationRateMapDescriptor, objc_name="layers") -RasterizationRateMapDescriptor_layers :: #force_inline proc(self: ^RasterizationRateMapDescriptor) -> ^RasterizationRateLayerArray { +RasterizationRateMapDescriptor_layers :: #force_inline proc "c" (self: ^RasterizationRateMapDescriptor) -> ^RasterizationRateLayerArray { return msgSend(^RasterizationRateLayerArray, self, "layers") } @(objc_type=RasterizationRateMapDescriptor, objc_name="rasterizationRateMapDescriptorWithScreenSize", objc_is_class_method=true) -RasterizationRateMapDescriptor_rasterizationRateMapDescriptorWithScreenSize :: #force_inline proc(screenSize: Size) -> ^RasterizationRateMapDescriptor { +RasterizationRateMapDescriptor_rasterizationRateMapDescriptorWithScreenSize :: #force_inline proc "c" (screenSize: Size) -> ^RasterizationRateMapDescriptor { return msgSend(^RasterizationRateMapDescriptor, RasterizationRateMapDescriptor, "rasterizationRateMapDescriptorWithScreenSize:", screenSize) } @(objc_type=RasterizationRateMapDescriptor, objc_name="rasterizationRateMapDescriptorWithScreenSizeWithLayer", objc_is_class_method=true) -RasterizationRateMapDescriptor_rasterizationRateMapDescriptorWithScreenSizeWithLayer :: #force_inline proc(screenSize: Size, layer: ^RasterizationRateLayerDescriptor) -> ^RasterizationRateMapDescriptor { +RasterizationRateMapDescriptor_rasterizationRateMapDescriptorWithScreenSizeWithLayer :: #force_inline proc "c" (screenSize: Size, layer: ^RasterizationRateLayerDescriptor) -> ^RasterizationRateMapDescriptor { return msgSend(^RasterizationRateMapDescriptor, RasterizationRateMapDescriptor, "rasterizationRateMapDescriptorWithScreenSize:layer:", screenSize, layer) } @(objc_type=RasterizationRateMapDescriptor, objc_name="rasterizationRateMapDescriptorWithScreenSizeWithLayers", objc_is_class_method=true) -RasterizationRateMapDescriptor_rasterizationRateMapDescriptorWithScreenSizeWithLayers :: #force_inline proc(screenSize: Size, layers: []^RasterizationRateLayerDescriptor) -> ^RasterizationRateMapDescriptor { +RasterizationRateMapDescriptor_rasterizationRateMapDescriptorWithScreenSizeWithLayers :: #force_inline proc "c" (screenSize: Size, layers: []^RasterizationRateLayerDescriptor) -> ^RasterizationRateMapDescriptor { return msgSend(^RasterizationRateMapDescriptor, RasterizationRateMapDescriptor, "rasterizationRateMapDescriptorWithScreenSize:layerCount:layers:", screenSize, NS.UInteger(len(layers)), layers) } @(objc_type=RasterizationRateMapDescriptor, objc_name="screenSize") -RasterizationRateMapDescriptor_screenSize :: #force_inline proc(self: ^RasterizationRateMapDescriptor) -> Size { +RasterizationRateMapDescriptor_screenSize :: #force_inline proc "c" (self: ^RasterizationRateMapDescriptor) -> Size { return msgSend(Size, self, "screenSize") } @(objc_type=RasterizationRateMapDescriptor, objc_name="setLabel") -RasterizationRateMapDescriptor_setLabel :: #force_inline proc(self: ^RasterizationRateMapDescriptor, label: ^NS.String) { +RasterizationRateMapDescriptor_setLabel :: #force_inline proc "c" (self: ^RasterizationRateMapDescriptor, label: ^NS.String) { msgSend(nil, self, "setLabel:", label) } @(objc_type=RasterizationRateMapDescriptor, objc_name="setLayer") -RasterizationRateMapDescriptor_setLayer :: #force_inline proc(self: ^RasterizationRateMapDescriptor, layer: ^RasterizationRateLayerDescriptor, layerIndex: NS.UInteger) { +RasterizationRateMapDescriptor_setLayer :: #force_inline proc "c" (self: ^RasterizationRateMapDescriptor, layer: ^RasterizationRateLayerDescriptor, layerIndex: NS.UInteger) { msgSend(nil, self, "setLayer:atIndex:", layer, layerIndex) } @(objc_type=RasterizationRateMapDescriptor, objc_name="setScreenSize") -RasterizationRateMapDescriptor_setScreenSize :: #force_inline proc(self: ^RasterizationRateMapDescriptor, screenSize: Size) { +RasterizationRateMapDescriptor_setScreenSize :: #force_inline proc "c" (self: ^RasterizationRateMapDescriptor, screenSize: Size) { msgSend(nil, self, "setScreenSize:", screenSize) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - RasterizationRateSampleArray -Class Methods: - alloc -Methods: - init - objectAtIndexedSubscript - setObject -*/ + @(objc_class="MTLRasterizationRateSampleArray") RasterizationRateSampleArray :: struct { using _: NS.Object } @(objc_type=RasterizationRateSampleArray, objc_name="alloc", objc_is_class_method=true) -RasterizationRateSampleArray_alloc :: #force_inline proc() -> ^RasterizationRateSampleArray { +RasterizationRateSampleArray_alloc :: #force_inline proc "c" () -> ^RasterizationRateSampleArray { return msgSend(^RasterizationRateSampleArray, RasterizationRateSampleArray, "alloc") } @(objc_type=RasterizationRateSampleArray, objc_name="init") -RasterizationRateSampleArray_init :: #force_inline proc(self: ^RasterizationRateSampleArray) -> ^RasterizationRateSampleArray { +RasterizationRateSampleArray_init :: #force_inline proc "c" (self: ^RasterizationRateSampleArray) -> ^RasterizationRateSampleArray { return msgSend(^RasterizationRateSampleArray, self, "init") } @(objc_type=RasterizationRateSampleArray, objc_name="object") -RasterizationRateSampleArray_object :: #force_inline proc(self: ^RasterizationRateSampleArray, index: NS.UInteger) -> ^NS.Number { +RasterizationRateSampleArray_object :: #force_inline proc "c" (self: ^RasterizationRateSampleArray, index: NS.UInteger) -> ^NS.Number { return msgSend(^NS.Number, self, "objectAtIndexedSubscript:", index) } @(objc_type=RasterizationRateSampleArray, objc_name="setObject") -RasterizationRateSampleArray_setObject :: #force_inline proc(self: ^RasterizationRateSampleArray, value: ^NS.Number, index: NS.UInteger) { +RasterizationRateSampleArray_setObject :: #force_inline proc "c" (self: ^RasterizationRateSampleArray, value: ^NS.Number, index: NS.UInteger) { msgSend(nil, self, "setObject:atIndexedSubscript:", value, index) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - RenderPassAttachmentDescriptor -Class Methods: - alloc -Methods: - init - depthPlane - level - loadAction - resolveDepthPlane - resolveLevel - resolveSlice - resolveTexture - setDepthPlane - setLevel - setLoadAction - setResolveDepthPlane - setResolveLevel - setResolveSlice - setResolveTexture - setSlice - setStoreAction - setStoreActionOptions - setTexture - slice - storeAction - storeActionOptions - texture -*/ + @(objc_class="MTLRenderPassAttachmentDescriptor") RenderPassAttachmentDescriptor :: struct { using _: NS.Copying(RenderPassAttachmentDescriptor) } @(objc_type=RenderPassAttachmentDescriptor, objc_name="alloc", objc_is_class_method=true) -RenderPassAttachmentDescriptor_alloc :: #force_inline proc() -> ^RenderPassAttachmentDescriptor { +RenderPassAttachmentDescriptor_alloc :: #force_inline proc "c" () -> ^RenderPassAttachmentDescriptor { return msgSend(^RenderPassAttachmentDescriptor, RenderPassAttachmentDescriptor, "alloc") } @(objc_type=RenderPassAttachmentDescriptor, objc_name="init") -RenderPassAttachmentDescriptor_init :: #force_inline proc(self: ^RenderPassAttachmentDescriptor) -> ^RenderPassAttachmentDescriptor { +RenderPassAttachmentDescriptor_init :: #force_inline proc "c" (self: ^RenderPassAttachmentDescriptor) -> ^RenderPassAttachmentDescriptor { return msgSend(^RenderPassAttachmentDescriptor, self, "init") } @(objc_type=RenderPassAttachmentDescriptor, objc_name="depthPlane") -RenderPassAttachmentDescriptor_depthPlane :: #force_inline proc(self: ^RenderPassAttachmentDescriptor) -> NS.UInteger { +RenderPassAttachmentDescriptor_depthPlane :: #force_inline proc "c" (self: ^RenderPassAttachmentDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "depthPlane") } @(objc_type=RenderPassAttachmentDescriptor, objc_name="level") -RenderPassAttachmentDescriptor_level :: #force_inline proc(self: ^RenderPassAttachmentDescriptor) -> NS.UInteger { +RenderPassAttachmentDescriptor_level :: #force_inline proc "c" (self: ^RenderPassAttachmentDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "level") } @(objc_type=RenderPassAttachmentDescriptor, objc_name="loadAction") -RenderPassAttachmentDescriptor_loadAction :: #force_inline proc(self: ^RenderPassAttachmentDescriptor) -> LoadAction { +RenderPassAttachmentDescriptor_loadAction :: #force_inline proc "c" (self: ^RenderPassAttachmentDescriptor) -> LoadAction { return msgSend(LoadAction, self, "loadAction") } @(objc_type=RenderPassAttachmentDescriptor, objc_name="resolveDepthPlane") -RenderPassAttachmentDescriptor_resolveDepthPlane :: #force_inline proc(self: ^RenderPassAttachmentDescriptor) -> NS.UInteger { +RenderPassAttachmentDescriptor_resolveDepthPlane :: #force_inline proc "c" (self: ^RenderPassAttachmentDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "resolveDepthPlane") } @(objc_type=RenderPassAttachmentDescriptor, objc_name="resolveLevel") -RenderPassAttachmentDescriptor_resolveLevel :: #force_inline proc(self: ^RenderPassAttachmentDescriptor) -> NS.UInteger { +RenderPassAttachmentDescriptor_resolveLevel :: #force_inline proc "c" (self: ^RenderPassAttachmentDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "resolveLevel") } @(objc_type=RenderPassAttachmentDescriptor, objc_name="resolveSlice") -RenderPassAttachmentDescriptor_resolveSlice :: #force_inline proc(self: ^RenderPassAttachmentDescriptor) -> NS.UInteger { +RenderPassAttachmentDescriptor_resolveSlice :: #force_inline proc "c" (self: ^RenderPassAttachmentDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "resolveSlice") } @(objc_type=RenderPassAttachmentDescriptor, objc_name="resolveTexture") -RenderPassAttachmentDescriptor_resolveTexture :: #force_inline proc(self: ^RenderPassAttachmentDescriptor) -> ^Texture { +RenderPassAttachmentDescriptor_resolveTexture :: #force_inline proc "c" (self: ^RenderPassAttachmentDescriptor) -> ^Texture { return msgSend(^Texture, self, "resolveTexture") } @(objc_type=RenderPassAttachmentDescriptor, objc_name="setDepthPlane") -RenderPassAttachmentDescriptor_setDepthPlane :: #force_inline proc(self: ^RenderPassAttachmentDescriptor, depthPlane: NS.UInteger) { +RenderPassAttachmentDescriptor_setDepthPlane :: #force_inline proc "c" (self: ^RenderPassAttachmentDescriptor, depthPlane: NS.UInteger) { msgSend(nil, self, "setDepthPlane:", depthPlane) } @(objc_type=RenderPassAttachmentDescriptor, objc_name="setLevel") -RenderPassAttachmentDescriptor_setLevel :: #force_inline proc(self: ^RenderPassAttachmentDescriptor, level: NS.UInteger) { +RenderPassAttachmentDescriptor_setLevel :: #force_inline proc "c" (self: ^RenderPassAttachmentDescriptor, level: NS.UInteger) { msgSend(nil, self, "setLevel:", level) } @(objc_type=RenderPassAttachmentDescriptor, objc_name="setLoadAction") -RenderPassAttachmentDescriptor_setLoadAction :: #force_inline proc(self: ^RenderPassAttachmentDescriptor, loadAction: LoadAction) { +RenderPassAttachmentDescriptor_setLoadAction :: #force_inline proc "c" (self: ^RenderPassAttachmentDescriptor, loadAction: LoadAction) { msgSend(nil, self, "setLoadAction:", loadAction) } @(objc_type=RenderPassAttachmentDescriptor, objc_name="setResolveDepthPlane") -RenderPassAttachmentDescriptor_setResolveDepthPlane :: #force_inline proc(self: ^RenderPassAttachmentDescriptor, resolveDepthPlane: NS.UInteger) { +RenderPassAttachmentDescriptor_setResolveDepthPlane :: #force_inline proc "c" (self: ^RenderPassAttachmentDescriptor, resolveDepthPlane: NS.UInteger) { msgSend(nil, self, "setResolveDepthPlane:", resolveDepthPlane) } @(objc_type=RenderPassAttachmentDescriptor, objc_name="setResolveLevel") -RenderPassAttachmentDescriptor_setResolveLevel :: #force_inline proc(self: ^RenderPassAttachmentDescriptor, resolveLevel: NS.UInteger) { +RenderPassAttachmentDescriptor_setResolveLevel :: #force_inline proc "c" (self: ^RenderPassAttachmentDescriptor, resolveLevel: NS.UInteger) { msgSend(nil, self, "setResolveLevel:", resolveLevel) } @(objc_type=RenderPassAttachmentDescriptor, objc_name="setResolveSlice") -RenderPassAttachmentDescriptor_setResolveSlice :: #force_inline proc(self: ^RenderPassAttachmentDescriptor, resolveSlice: NS.UInteger) { +RenderPassAttachmentDescriptor_setResolveSlice :: #force_inline proc "c" (self: ^RenderPassAttachmentDescriptor, resolveSlice: NS.UInteger) { msgSend(nil, self, "setResolveSlice:", resolveSlice) } @(objc_type=RenderPassAttachmentDescriptor, objc_name="setResolveTexture") -RenderPassAttachmentDescriptor_setResolveTexture :: #force_inline proc(self: ^RenderPassAttachmentDescriptor, resolveTexture: ^Texture) { +RenderPassAttachmentDescriptor_setResolveTexture :: #force_inline proc "c" (self: ^RenderPassAttachmentDescriptor, resolveTexture: ^Texture) { msgSend(nil, self, "setResolveTexture:", resolveTexture) } @(objc_type=RenderPassAttachmentDescriptor, objc_name="setSlice") -RenderPassAttachmentDescriptor_setSlice :: #force_inline proc(self: ^RenderPassAttachmentDescriptor, slice: NS.UInteger) { +RenderPassAttachmentDescriptor_setSlice :: #force_inline proc "c" (self: ^RenderPassAttachmentDescriptor, slice: NS.UInteger) { msgSend(nil, self, "setSlice:", slice) } @(objc_type=RenderPassAttachmentDescriptor, objc_name="setStoreAction") -RenderPassAttachmentDescriptor_setStoreAction :: #force_inline proc(self: ^RenderPassAttachmentDescriptor, storeAction: StoreAction) { +RenderPassAttachmentDescriptor_setStoreAction :: #force_inline proc "c" (self: ^RenderPassAttachmentDescriptor, storeAction: StoreAction) { msgSend(nil, self, "setStoreAction:", storeAction) } @(objc_type=RenderPassAttachmentDescriptor, objc_name="setStoreActionOptions") -RenderPassAttachmentDescriptor_setStoreActionOptions :: #force_inline proc(self: ^RenderPassAttachmentDescriptor, storeActionOptions: StoreActionOptions) { +RenderPassAttachmentDescriptor_setStoreActionOptions :: #force_inline proc "c" (self: ^RenderPassAttachmentDescriptor, storeActionOptions: StoreActionOptions) { msgSend(nil, self, "setStoreActionOptions:", storeActionOptions) } @(objc_type=RenderPassAttachmentDescriptor, objc_name="setTexture") -RenderPassAttachmentDescriptor_setTexture :: #force_inline proc(self: ^RenderPassAttachmentDescriptor, texture: ^Texture) { +RenderPassAttachmentDescriptor_setTexture :: #force_inline proc "c" (self: ^RenderPassAttachmentDescriptor, texture: ^Texture) { msgSend(nil, self, "setTexture:", texture) } @(objc_type=RenderPassAttachmentDescriptor, objc_name="slice") -RenderPassAttachmentDescriptor_slice :: #force_inline proc(self: ^RenderPassAttachmentDescriptor) -> NS.UInteger { +RenderPassAttachmentDescriptor_slice :: #force_inline proc "c" (self: ^RenderPassAttachmentDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "slice") } @(objc_type=RenderPassAttachmentDescriptor, objc_name="storeAction") -RenderPassAttachmentDescriptor_storeAction :: #force_inline proc(self: ^RenderPassAttachmentDescriptor) -> StoreAction { +RenderPassAttachmentDescriptor_storeAction :: #force_inline proc "c" (self: ^RenderPassAttachmentDescriptor) -> StoreAction { return msgSend(StoreAction, self, "storeAction") } @(objc_type=RenderPassAttachmentDescriptor, objc_name="storeActionOptions") -RenderPassAttachmentDescriptor_storeActionOptions :: #force_inline proc(self: ^RenderPassAttachmentDescriptor) -> StoreActionOptions { +RenderPassAttachmentDescriptor_storeActionOptions :: #force_inline proc "c" (self: ^RenderPassAttachmentDescriptor) -> StoreActionOptions { return msgSend(StoreActionOptions, self, "storeActionOptions") } @(objc_type=RenderPassAttachmentDescriptor, objc_name="texture") -RenderPassAttachmentDescriptor_texture :: #force_inline proc(self: ^RenderPassAttachmentDescriptor) -> ^Texture { +RenderPassAttachmentDescriptor_texture :: #force_inline proc "c" (self: ^RenderPassAttachmentDescriptor) -> ^Texture { return msgSend(^Texture, self, "texture") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - RenderPassColorAttachmentDescriptor -Class Methods: - alloc -Methods: - init - clearColor - setClearColor -*/ + @(objc_class="MTLRenderPassColorAttachmentDescriptor") RenderPassColorAttachmentDescriptor :: struct { using _: NS.Copying(RenderPassColorAttachmentDescriptor), using _: RenderPassAttachmentDescriptor } @(objc_type=RenderPassColorAttachmentDescriptor, objc_name="alloc", objc_is_class_method=true) -RenderPassColorAttachmentDescriptor_alloc :: #force_inline proc() -> ^RenderPassColorAttachmentDescriptor { +RenderPassColorAttachmentDescriptor_alloc :: #force_inline proc "c" () -> ^RenderPassColorAttachmentDescriptor { return msgSend(^RenderPassColorAttachmentDescriptor, RenderPassColorAttachmentDescriptor, "alloc") } @(objc_type=RenderPassColorAttachmentDescriptor, objc_name="init") -RenderPassColorAttachmentDescriptor_init :: #force_inline proc(self: ^RenderPassColorAttachmentDescriptor) -> ^RenderPassColorAttachmentDescriptor { +RenderPassColorAttachmentDescriptor_init :: #force_inline proc "c" (self: ^RenderPassColorAttachmentDescriptor) -> ^RenderPassColorAttachmentDescriptor { return msgSend(^RenderPassColorAttachmentDescriptor, self, "init") } @(objc_type=RenderPassColorAttachmentDescriptor, objc_name="clearColor") -RenderPassColorAttachmentDescriptor_clearColor :: #force_inline proc(self: ^RenderPassColorAttachmentDescriptor) -> ClearColor { +RenderPassColorAttachmentDescriptor_clearColor :: #force_inline proc "c" (self: ^RenderPassColorAttachmentDescriptor) -> ClearColor { return msgSend(ClearColor, self, "clearColor") } @(objc_type=RenderPassColorAttachmentDescriptor, objc_name="setClearColor") -RenderPassColorAttachmentDescriptor_setClearColor :: #force_inline proc(self: ^RenderPassColorAttachmentDescriptor, clearColor: ClearColor) { +RenderPassColorAttachmentDescriptor_setClearColor :: #force_inline proc "c" (self: ^RenderPassColorAttachmentDescriptor, clearColor: ClearColor) { msgSend(nil, self, "setClearColor:", clearColor) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - RenderPassColorAttachmentDescriptorArray -Class Methods: - alloc -Methods: - init - objectAtIndexedSubscript - setObject -*/ + @(objc_class="MTLRenderPassColorAttachmentDescriptorArray") RenderPassColorAttachmentDescriptorArray :: struct { using _: NS.Object } @(objc_type=RenderPassColorAttachmentDescriptorArray, objc_name="alloc", objc_is_class_method=true) -RenderPassColorAttachmentDescriptorArray_alloc :: #force_inline proc() -> ^RenderPassColorAttachmentDescriptorArray { +RenderPassColorAttachmentDescriptorArray_alloc :: #force_inline proc "c" () -> ^RenderPassColorAttachmentDescriptorArray { return msgSend(^RenderPassColorAttachmentDescriptorArray, RenderPassColorAttachmentDescriptorArray, "alloc") } @(objc_type=RenderPassColorAttachmentDescriptorArray, objc_name="init") -RenderPassColorAttachmentDescriptorArray_init :: #force_inline proc(self: ^RenderPassColorAttachmentDescriptorArray) -> ^RenderPassColorAttachmentDescriptorArray { +RenderPassColorAttachmentDescriptorArray_init :: #force_inline proc "c" (self: ^RenderPassColorAttachmentDescriptorArray) -> ^RenderPassColorAttachmentDescriptorArray { return msgSend(^RenderPassColorAttachmentDescriptorArray, self, "init") } @(objc_type=RenderPassColorAttachmentDescriptorArray, objc_name="object") -RenderPassColorAttachmentDescriptorArray_object :: #force_inline proc(self: ^RenderPassColorAttachmentDescriptorArray, attachmentIndex: NS.UInteger) -> ^RenderPassColorAttachmentDescriptor { +RenderPassColorAttachmentDescriptorArray_object :: #force_inline proc "c" (self: ^RenderPassColorAttachmentDescriptorArray, attachmentIndex: NS.UInteger) -> ^RenderPassColorAttachmentDescriptor { return msgSend(^RenderPassColorAttachmentDescriptor, self, "objectAtIndexedSubscript:", attachmentIndex) } @(objc_type=RenderPassColorAttachmentDescriptorArray, objc_name="setObject") -RenderPassColorAttachmentDescriptorArray_setObject :: #force_inline proc(self: ^RenderPassColorAttachmentDescriptorArray, attachment: ^RenderPassColorAttachmentDescriptor, attachmentIndex: NS.UInteger) { +RenderPassColorAttachmentDescriptorArray_setObject :: #force_inline proc "c" (self: ^RenderPassColorAttachmentDescriptorArray, attachment: ^RenderPassColorAttachmentDescriptor, attachmentIndex: NS.UInteger) { msgSend(nil, self, "setObject:atIndexedSubscript:", attachment, attachmentIndex) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - RenderPassDepthAttachmentDescriptor -Class Methods: - alloc -Methods: - init - clearDepth - depthResolveFilter - setClearDepth - setDepthResolveFilter -*/ + @(objc_class="MTLRenderPassDepthAttachmentDescriptor") RenderPassDepthAttachmentDescriptor :: struct { using _: NS.Copying(RenderPassDepthAttachmentDescriptor), using _: RenderPassAttachmentDescriptor } @(objc_type=RenderPassDepthAttachmentDescriptor, objc_name="alloc", objc_is_class_method=true) -RenderPassDepthAttachmentDescriptor_alloc :: #force_inline proc() -> ^RenderPassDepthAttachmentDescriptor { +RenderPassDepthAttachmentDescriptor_alloc :: #force_inline proc "c" () -> ^RenderPassDepthAttachmentDescriptor { return msgSend(^RenderPassDepthAttachmentDescriptor, RenderPassDepthAttachmentDescriptor, "alloc") } @(objc_type=RenderPassDepthAttachmentDescriptor, objc_name="init") -RenderPassDepthAttachmentDescriptor_init :: #force_inline proc(self: ^RenderPassDepthAttachmentDescriptor) -> ^RenderPassDepthAttachmentDescriptor { +RenderPassDepthAttachmentDescriptor_init :: #force_inline proc "c" (self: ^RenderPassDepthAttachmentDescriptor) -> ^RenderPassDepthAttachmentDescriptor { return msgSend(^RenderPassDepthAttachmentDescriptor, self, "init") } @(objc_type=RenderPassDepthAttachmentDescriptor, objc_name="clearDepth") -RenderPassDepthAttachmentDescriptor_clearDepth :: #force_inline proc(self: ^RenderPassDepthAttachmentDescriptor) -> f64 { +RenderPassDepthAttachmentDescriptor_clearDepth :: #force_inline proc "c" (self: ^RenderPassDepthAttachmentDescriptor) -> f64 { return msgSend(f64, self, "clearDepth") } @(objc_type=RenderPassDepthAttachmentDescriptor, objc_name="depthResolveFilter") -RenderPassDepthAttachmentDescriptor_depthResolveFilter :: #force_inline proc(self: ^RenderPassDepthAttachmentDescriptor) -> MultisampleDepthResolveFilter { +RenderPassDepthAttachmentDescriptor_depthResolveFilter :: #force_inline proc "c" (self: ^RenderPassDepthAttachmentDescriptor) -> MultisampleDepthResolveFilter { return msgSend(MultisampleDepthResolveFilter, self, "depthResolveFilter") } @(objc_type=RenderPassDepthAttachmentDescriptor, objc_name="setClearDepth") -RenderPassDepthAttachmentDescriptor_setClearDepth :: #force_inline proc(self: ^RenderPassDepthAttachmentDescriptor, clearDepth: f64) { +RenderPassDepthAttachmentDescriptor_setClearDepth :: #force_inline proc "c" (self: ^RenderPassDepthAttachmentDescriptor, clearDepth: f64) { msgSend(nil, self, "setClearDepth:", clearDepth) } @(objc_type=RenderPassDepthAttachmentDescriptor, objc_name="setDepthResolveFilter") -RenderPassDepthAttachmentDescriptor_setDepthResolveFilter :: #force_inline proc(self: ^RenderPassDepthAttachmentDescriptor, depthResolveFilter: MultisampleDepthResolveFilter) { +RenderPassDepthAttachmentDescriptor_setDepthResolveFilter :: #force_inline proc "c" (self: ^RenderPassDepthAttachmentDescriptor, depthResolveFilter: MultisampleDepthResolveFilter) { msgSend(nil, self, "setDepthResolveFilter:", depthResolveFilter) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - RenderPassDescriptor -Class Methods: - alloc - renderPassDescriptor -Methods: - init - colorAttachments - defaultRasterSampleCount - depthAttachment - getSamplePositions - imageblockSampleLength - rasterizationRateMap - renderTargetArrayLength - renderTargetHeight - renderTargetWidth - sampleBufferAttachments - setDefaultRasterSampleCount - setDepthAttachment - setImageblockSampleLength - setRasterizationRateMap - setRenderTargetArrayLength - setRenderTargetHeight - setRenderTargetWidth - setSamplePositions - setStencilAttachment - setThreadgroupMemoryLength - setTileHeight - setTileWidth - setVisibilityResultBuffer - stencilAttachment - threadgroupMemoryLength - tileHeight - tileWidth - visibilityResultBuffer -*/ + @(objc_class="MTLRenderPassDescriptor") RenderPassDescriptor :: struct { using _: NS.Copying(RenderPassDescriptor), using _: AccelerationStructureDescriptor } @(objc_type=RenderPassDescriptor, objc_name="alloc", objc_is_class_method=true) -RenderPassDescriptor_alloc :: #force_inline proc() -> ^RenderPassDescriptor { +RenderPassDescriptor_alloc :: #force_inline proc "c" () -> ^RenderPassDescriptor { return msgSend(^RenderPassDescriptor, RenderPassDescriptor, "alloc") } @(objc_type=RenderPassDescriptor, objc_name="init") -RenderPassDescriptor_init :: #force_inline proc(self: ^RenderPassDescriptor) -> ^RenderPassDescriptor { +RenderPassDescriptor_init :: #force_inline proc "c" (self: ^RenderPassDescriptor) -> ^RenderPassDescriptor { return msgSend(^RenderPassDescriptor, self, "init") } @(objc_type=RenderPassDescriptor, objc_name="colorAttachments") -RenderPassDescriptor_colorAttachments :: #force_inline proc(self: ^RenderPassDescriptor) -> ^RenderPassColorAttachmentDescriptorArray { +RenderPassDescriptor_colorAttachments :: #force_inline proc "c" (self: ^RenderPassDescriptor) -> ^RenderPassColorAttachmentDescriptorArray { return msgSend(^RenderPassColorAttachmentDescriptorArray, self, "colorAttachments") } @(objc_type=RenderPassDescriptor, objc_name="defaultRasterSampleCount") -RenderPassDescriptor_defaultRasterSampleCount :: #force_inline proc(self: ^RenderPassDescriptor) -> NS.UInteger { +RenderPassDescriptor_defaultRasterSampleCount :: #force_inline proc "c" (self: ^RenderPassDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "defaultRasterSampleCount") } @(objc_type=RenderPassDescriptor, objc_name="depthAttachment") -RenderPassDescriptor_depthAttachment :: #force_inline proc(self: ^RenderPassDescriptor) -> ^RenderPassDepthAttachmentDescriptor { +RenderPassDescriptor_depthAttachment :: #force_inline proc "c" (self: ^RenderPassDescriptor) -> ^RenderPassDepthAttachmentDescriptor { return msgSend(^RenderPassDepthAttachmentDescriptor, self, "depthAttachment") } @(objc_type=RenderPassDescriptor, objc_name="getSamplePositions") -RenderPassDescriptor_getSamplePositions :: #force_inline proc(self: ^RenderPassDescriptor, positions: []SamplePosition) -> NS.UInteger { +RenderPassDescriptor_getSamplePositions :: #force_inline proc "c" (self: ^RenderPassDescriptor, positions: []SamplePosition) -> NS.UInteger { return msgSend(NS.UInteger, self, "getSamplePositions:count:", raw_data(positions), NS.UInteger(len(positions))) } @(objc_type=RenderPassDescriptor, objc_name="imageblockSampleLength") -RenderPassDescriptor_imageblockSampleLength :: #force_inline proc(self: ^RenderPassDescriptor) -> NS.UInteger { +RenderPassDescriptor_imageblockSampleLength :: #force_inline proc "c" (self: ^RenderPassDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "imageblockSampleLength") } @(objc_type=RenderPassDescriptor, objc_name="rasterizationRateMap") -RenderPassDescriptor_rasterizationRateMap :: #force_inline proc(self: ^RenderPassDescriptor) -> ^RasterizationRateMap { +RenderPassDescriptor_rasterizationRateMap :: #force_inline proc "c" (self: ^RenderPassDescriptor) -> ^RasterizationRateMap { return msgSend(^RasterizationRateMap, self, "rasterizationRateMap") } @(objc_type=RenderPassDescriptor, objc_name="renderPassDescriptor", objc_is_class_method=true) -RenderPassDescriptor_renderPassDescriptor :: #force_inline proc() -> ^RenderPassDescriptor { +RenderPassDescriptor_renderPassDescriptor :: #force_inline proc "c" () -> ^RenderPassDescriptor { return msgSend(^RenderPassDescriptor, RenderPassDescriptor, "renderPassDescriptor") } @(objc_type=RenderPassDescriptor, objc_name="renderTargetArrayLength") -RenderPassDescriptor_renderTargetArrayLength :: #force_inline proc(self: ^RenderPassDescriptor) -> NS.UInteger { +RenderPassDescriptor_renderTargetArrayLength :: #force_inline proc "c" (self: ^RenderPassDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "renderTargetArrayLength") } @(objc_type=RenderPassDescriptor, objc_name="renderTargetHeight") -RenderPassDescriptor_renderTargetHeight :: #force_inline proc(self: ^RenderPassDescriptor) -> NS.UInteger { +RenderPassDescriptor_renderTargetHeight :: #force_inline proc "c" (self: ^RenderPassDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "renderTargetHeight") } @(objc_type=RenderPassDescriptor, objc_name="renderTargetWidth") -RenderPassDescriptor_renderTargetWidth :: #force_inline proc(self: ^RenderPassDescriptor) -> NS.UInteger { +RenderPassDescriptor_renderTargetWidth :: #force_inline proc "c" (self: ^RenderPassDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "renderTargetWidth") } @(objc_type=RenderPassDescriptor, objc_name="sampleBufferAttachments") -RenderPassDescriptor_sampleBufferAttachments :: #force_inline proc(self: ^RenderPassDescriptor) -> ^RenderPassSampleBufferAttachmentDescriptorArray { +RenderPassDescriptor_sampleBufferAttachments :: #force_inline proc "c" (self: ^RenderPassDescriptor) -> ^RenderPassSampleBufferAttachmentDescriptorArray { return msgSend(^RenderPassSampleBufferAttachmentDescriptorArray, self, "sampleBufferAttachments") } @(objc_type=RenderPassDescriptor, objc_name="setDefaultRasterSampleCount") -RenderPassDescriptor_setDefaultRasterSampleCount :: #force_inline proc(self: ^RenderPassDescriptor, defaultRasterSampleCount: NS.UInteger) { +RenderPassDescriptor_setDefaultRasterSampleCount :: #force_inline proc "c" (self: ^RenderPassDescriptor, defaultRasterSampleCount: NS.UInteger) { msgSend(nil, self, "setDefaultRasterSampleCount:", defaultRasterSampleCount) } @(objc_type=RenderPassDescriptor, objc_name="setDepthAttachment") -RenderPassDescriptor_setDepthAttachment :: #force_inline proc(self: ^RenderPassDescriptor, depthAttachment: ^RenderPassDepthAttachmentDescriptor) { +RenderPassDescriptor_setDepthAttachment :: #force_inline proc "c" (self: ^RenderPassDescriptor, depthAttachment: ^RenderPassDepthAttachmentDescriptor) { msgSend(nil, self, "setDepthAttachment:", depthAttachment) } @(objc_type=RenderPassDescriptor, objc_name="setImageblockSampleLength") -RenderPassDescriptor_setImageblockSampleLength :: #force_inline proc(self: ^RenderPassDescriptor, imageblockSampleLength: NS.UInteger) { +RenderPassDescriptor_setImageblockSampleLength :: #force_inline proc "c" (self: ^RenderPassDescriptor, imageblockSampleLength: NS.UInteger) { msgSend(nil, self, "setImageblockSampleLength:", imageblockSampleLength) } @(objc_type=RenderPassDescriptor, objc_name="setRasterizationRateMap") -RenderPassDescriptor_setRasterizationRateMap :: #force_inline proc(self: ^RenderPassDescriptor, rasterizationRateMap: ^RasterizationRateMap) { +RenderPassDescriptor_setRasterizationRateMap :: #force_inline proc "c" (self: ^RenderPassDescriptor, rasterizationRateMap: ^RasterizationRateMap) { msgSend(nil, self, "setRasterizationRateMap:", rasterizationRateMap) } @(objc_type=RenderPassDescriptor, objc_name="setRenderTargetArrayLength") -RenderPassDescriptor_setRenderTargetArrayLength :: #force_inline proc(self: ^RenderPassDescriptor, renderTargetArrayLength: NS.UInteger) { +RenderPassDescriptor_setRenderTargetArrayLength :: #force_inline proc "c" (self: ^RenderPassDescriptor, renderTargetArrayLength: NS.UInteger) { msgSend(nil, self, "setRenderTargetArrayLength:", renderTargetArrayLength) } @(objc_type=RenderPassDescriptor, objc_name="setRenderTargetHeight") -RenderPassDescriptor_setRenderTargetHeight :: #force_inline proc(self: ^RenderPassDescriptor, renderTargetHeight: NS.UInteger) { +RenderPassDescriptor_setRenderTargetHeight :: #force_inline proc "c" (self: ^RenderPassDescriptor, renderTargetHeight: NS.UInteger) { msgSend(nil, self, "setRenderTargetHeight:", renderTargetHeight) } @(objc_type=RenderPassDescriptor, objc_name="setRenderTargetWidth") -RenderPassDescriptor_setRenderTargetWidth :: #force_inline proc(self: ^RenderPassDescriptor, renderTargetWidth: NS.UInteger) { +RenderPassDescriptor_setRenderTargetWidth :: #force_inline proc "c" (self: ^RenderPassDescriptor, renderTargetWidth: NS.UInteger) { msgSend(nil, self, "setRenderTargetWidth:", renderTargetWidth) } @(objc_type=RenderPassDescriptor, objc_name="setSamplePositions") -RenderPassDescriptor_setSamplePositions :: #force_inline proc(self: ^RenderPassDescriptor, positions: []SamplePosition) { +RenderPassDescriptor_setSamplePositions :: #force_inline proc "c" (self: ^RenderPassDescriptor, positions: []SamplePosition) { msgSend(nil, self, "setSamplePositions:count:", raw_data(positions), NS.UInteger(len(positions))) } @(objc_type=RenderPassDescriptor, objc_name="setStencilAttachment") -RenderPassDescriptor_setStencilAttachment :: #force_inline proc(self: ^RenderPassDescriptor, stencilAttachment: ^RenderPassStencilAttachmentDescriptor) { +RenderPassDescriptor_setStencilAttachment :: #force_inline proc "c" (self: ^RenderPassDescriptor, stencilAttachment: ^RenderPassStencilAttachmentDescriptor) { msgSend(nil, self, "setStencilAttachment:", stencilAttachment) } @(objc_type=RenderPassDescriptor, objc_name="setThreadgroupMemoryLength") -RenderPassDescriptor_setThreadgroupMemoryLength :: #force_inline proc(self: ^RenderPassDescriptor, threadgroupMemoryLength: NS.UInteger) { +RenderPassDescriptor_setThreadgroupMemoryLength :: #force_inline proc "c" (self: ^RenderPassDescriptor, threadgroupMemoryLength: NS.UInteger) { msgSend(nil, self, "setThreadgroupMemoryLength:", threadgroupMemoryLength) } @(objc_type=RenderPassDescriptor, objc_name="setTileHeight") -RenderPassDescriptor_setTileHeight :: #force_inline proc(self: ^RenderPassDescriptor, tileHeight: NS.UInteger) { +RenderPassDescriptor_setTileHeight :: #force_inline proc "c" (self: ^RenderPassDescriptor, tileHeight: NS.UInteger) { msgSend(nil, self, "setTileHeight:", tileHeight) } @(objc_type=RenderPassDescriptor, objc_name="setTileWidth") -RenderPassDescriptor_setTileWidth :: #force_inline proc(self: ^RenderPassDescriptor, tileWidth: NS.UInteger) { +RenderPassDescriptor_setTileWidth :: #force_inline proc "c" (self: ^RenderPassDescriptor, tileWidth: NS.UInteger) { msgSend(nil, self, "setTileWidth:", tileWidth) } @(objc_type=RenderPassDescriptor, objc_name="setVisibilityResultBuffer") -RenderPassDescriptor_setVisibilityResultBuffer :: #force_inline proc(self: ^RenderPassDescriptor, visibilityResultBuffer: ^Buffer) { +RenderPassDescriptor_setVisibilityResultBuffer :: #force_inline proc "c" (self: ^RenderPassDescriptor, visibilityResultBuffer: ^Buffer) { msgSend(nil, self, "setVisibilityResultBuffer:", visibilityResultBuffer) } @(objc_type=RenderPassDescriptor, objc_name="stencilAttachment") -RenderPassDescriptor_stencilAttachment :: #force_inline proc(self: ^RenderPassDescriptor) -> ^RenderPassStencilAttachmentDescriptor { +RenderPassDescriptor_stencilAttachment :: #force_inline proc "c" (self: ^RenderPassDescriptor) -> ^RenderPassStencilAttachmentDescriptor { return msgSend(^RenderPassStencilAttachmentDescriptor, self, "stencilAttachment") } @(objc_type=RenderPassDescriptor, objc_name="threadgroupMemoryLength") -RenderPassDescriptor_threadgroupMemoryLength :: #force_inline proc(self: ^RenderPassDescriptor) -> NS.UInteger { +RenderPassDescriptor_threadgroupMemoryLength :: #force_inline proc "c" (self: ^RenderPassDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "threadgroupMemoryLength") } @(objc_type=RenderPassDescriptor, objc_name="tileHeight") -RenderPassDescriptor_tileHeight :: #force_inline proc(self: ^RenderPassDescriptor) -> NS.UInteger { +RenderPassDescriptor_tileHeight :: #force_inline proc "c" (self: ^RenderPassDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "tileHeight") } @(objc_type=RenderPassDescriptor, objc_name="tileWidth") -RenderPassDescriptor_tileWidth :: #force_inline proc(self: ^RenderPassDescriptor) -> NS.UInteger { +RenderPassDescriptor_tileWidth :: #force_inline proc "c" (self: ^RenderPassDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "tileWidth") } @(objc_type=RenderPassDescriptor, objc_name="visibilityResultBuffer") -RenderPassDescriptor_visibilityResultBuffer :: #force_inline proc(self: ^RenderPassDescriptor) -> ^Buffer { +RenderPassDescriptor_visibilityResultBuffer :: #force_inline proc "c" (self: ^RenderPassDescriptor) -> ^Buffer { return msgSend(^Buffer, self, "visibilityResultBuffer") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - RenderPassSampleBufferAttachmentDescriptor -Class Methods: - alloc -Methods: - init - endOfFragmentSampleIndex - endOfVertexSampleIndex - sampleBuffer - setEndOfFragmentSampleIndex - setEndOfVertexSampleIndex - setSampleBuffer - setStartOfFragmentSampleIndex - setStartOfVertexSampleIndex - startOfFragmentSampleIndex - startOfVertexSampleIndex -*/ + + @(objc_class="MTLRenderPassSampleBufferAttachmentDescriptor") RenderPassSampleBufferAttachmentDescriptor :: struct { using _: NS.Copying(RenderPassSampleBufferAttachmentDescriptor) } @(objc_type=RenderPassSampleBufferAttachmentDescriptor, objc_name="alloc", objc_is_class_method=true) -RenderPassSampleBufferAttachmentDescriptor_alloc :: #force_inline proc() -> ^RenderPassSampleBufferAttachmentDescriptor { +RenderPassSampleBufferAttachmentDescriptor_alloc :: #force_inline proc "c" () -> ^RenderPassSampleBufferAttachmentDescriptor { return msgSend(^RenderPassSampleBufferAttachmentDescriptor, RenderPassSampleBufferAttachmentDescriptor, "alloc") } @(objc_type=RenderPassSampleBufferAttachmentDescriptor, objc_name="init") -RenderPassSampleBufferAttachmentDescriptor_init :: #force_inline proc(self: ^RenderPassSampleBufferAttachmentDescriptor) -> ^RenderPassSampleBufferAttachmentDescriptor { +RenderPassSampleBufferAttachmentDescriptor_init :: #force_inline proc "c" (self: ^RenderPassSampleBufferAttachmentDescriptor) -> ^RenderPassSampleBufferAttachmentDescriptor { return msgSend(^RenderPassSampleBufferAttachmentDescriptor, self, "init") } @(objc_type=RenderPassSampleBufferAttachmentDescriptor, objc_name="endOfFragmentSampleIndex") -RenderPassSampleBufferAttachmentDescriptor_endOfFragmentSampleIndex :: #force_inline proc(self: ^RenderPassSampleBufferAttachmentDescriptor) -> NS.UInteger { +RenderPassSampleBufferAttachmentDescriptor_endOfFragmentSampleIndex :: #force_inline proc "c" (self: ^RenderPassSampleBufferAttachmentDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "endOfFragmentSampleIndex") } @(objc_type=RenderPassSampleBufferAttachmentDescriptor, objc_name="endOfVertexSampleIndex") -RenderPassSampleBufferAttachmentDescriptor_endOfVertexSampleIndex :: #force_inline proc(self: ^RenderPassSampleBufferAttachmentDescriptor) -> NS.UInteger { +RenderPassSampleBufferAttachmentDescriptor_endOfVertexSampleIndex :: #force_inline proc "c" (self: ^RenderPassSampleBufferAttachmentDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "endOfVertexSampleIndex") } @(objc_type=RenderPassSampleBufferAttachmentDescriptor, objc_name="sampleBuffer") -RenderPassSampleBufferAttachmentDescriptor_sampleBuffer :: #force_inline proc(self: ^RenderPassSampleBufferAttachmentDescriptor) -> ^CounterSampleBuffer { +RenderPassSampleBufferAttachmentDescriptor_sampleBuffer :: #force_inline proc "c" (self: ^RenderPassSampleBufferAttachmentDescriptor) -> ^CounterSampleBuffer { return msgSend(^CounterSampleBuffer, self, "sampleBuffer") } @(objc_type=RenderPassSampleBufferAttachmentDescriptor, objc_name="setEndOfFragmentSampleIndex") -RenderPassSampleBufferAttachmentDescriptor_setEndOfFragmentSampleIndex :: #force_inline proc(self: ^RenderPassSampleBufferAttachmentDescriptor, endOfFragmentSampleIndex: NS.UInteger) { +RenderPassSampleBufferAttachmentDescriptor_setEndOfFragmentSampleIndex :: #force_inline proc "c" (self: ^RenderPassSampleBufferAttachmentDescriptor, endOfFragmentSampleIndex: NS.UInteger) { msgSend(nil, self, "setEndOfFragmentSampleIndex:", endOfFragmentSampleIndex) } @(objc_type=RenderPassSampleBufferAttachmentDescriptor, objc_name="setEndOfVertexSampleIndex") -RenderPassSampleBufferAttachmentDescriptor_setEndOfVertexSampleIndex :: #force_inline proc(self: ^RenderPassSampleBufferAttachmentDescriptor, endOfVertexSampleIndex: NS.UInteger) { +RenderPassSampleBufferAttachmentDescriptor_setEndOfVertexSampleIndex :: #force_inline proc "c" (self: ^RenderPassSampleBufferAttachmentDescriptor, endOfVertexSampleIndex: NS.UInteger) { msgSend(nil, self, "setEndOfVertexSampleIndex:", endOfVertexSampleIndex) } @(objc_type=RenderPassSampleBufferAttachmentDescriptor, objc_name="setSampleBuffer") -RenderPassSampleBufferAttachmentDescriptor_setSampleBuffer :: #force_inline proc(self: ^RenderPassSampleBufferAttachmentDescriptor, sampleBuffer: ^CounterSampleBuffer) { +RenderPassSampleBufferAttachmentDescriptor_setSampleBuffer :: #force_inline proc "c" (self: ^RenderPassSampleBufferAttachmentDescriptor, sampleBuffer: ^CounterSampleBuffer) { msgSend(nil, self, "setSampleBuffer:", sampleBuffer) } @(objc_type=RenderPassSampleBufferAttachmentDescriptor, objc_name="setStartOfFragmentSampleIndex") -RenderPassSampleBufferAttachmentDescriptor_setStartOfFragmentSampleIndex :: #force_inline proc(self: ^RenderPassSampleBufferAttachmentDescriptor, startOfFragmentSampleIndex: NS.UInteger) { +RenderPassSampleBufferAttachmentDescriptor_setStartOfFragmentSampleIndex :: #force_inline proc "c" (self: ^RenderPassSampleBufferAttachmentDescriptor, startOfFragmentSampleIndex: NS.UInteger) { msgSend(nil, self, "setStartOfFragmentSampleIndex:", startOfFragmentSampleIndex) } @(objc_type=RenderPassSampleBufferAttachmentDescriptor, objc_name="setStartOfVertexSampleIndex") -RenderPassSampleBufferAttachmentDescriptor_setStartOfVertexSampleIndex :: #force_inline proc(self: ^RenderPassSampleBufferAttachmentDescriptor, startOfVertexSampleIndex: NS.UInteger) { +RenderPassSampleBufferAttachmentDescriptor_setStartOfVertexSampleIndex :: #force_inline proc "c" (self: ^RenderPassSampleBufferAttachmentDescriptor, startOfVertexSampleIndex: NS.UInteger) { msgSend(nil, self, "setStartOfVertexSampleIndex:", startOfVertexSampleIndex) } @(objc_type=RenderPassSampleBufferAttachmentDescriptor, objc_name="startOfFragmentSampleIndex") -RenderPassSampleBufferAttachmentDescriptor_startOfFragmentSampleIndex :: #force_inline proc(self: ^RenderPassSampleBufferAttachmentDescriptor) -> NS.UInteger { +RenderPassSampleBufferAttachmentDescriptor_startOfFragmentSampleIndex :: #force_inline proc "c" (self: ^RenderPassSampleBufferAttachmentDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "startOfFragmentSampleIndex") } @(objc_type=RenderPassSampleBufferAttachmentDescriptor, objc_name="startOfVertexSampleIndex") -RenderPassSampleBufferAttachmentDescriptor_startOfVertexSampleIndex :: #force_inline proc(self: ^RenderPassSampleBufferAttachmentDescriptor) -> NS.UInteger { +RenderPassSampleBufferAttachmentDescriptor_startOfVertexSampleIndex :: #force_inline proc "c" (self: ^RenderPassSampleBufferAttachmentDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "startOfVertexSampleIndex") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - RenderPassSampleBufferAttachmentDescriptorArray -Class Methods: - alloc -Methods: - init - objectAtIndexedSubscript - setObject -*/ + @(objc_class="MTLRenderPassSampleBufferAttachmentDescriptorArray") RenderPassSampleBufferAttachmentDescriptorArray :: struct { using _: NS.Object } @(objc_type=RenderPassSampleBufferAttachmentDescriptorArray, objc_name="alloc", objc_is_class_method=true) -RenderPassSampleBufferAttachmentDescriptorArray_alloc :: #force_inline proc() -> ^RenderPassSampleBufferAttachmentDescriptorArray { +RenderPassSampleBufferAttachmentDescriptorArray_alloc :: #force_inline proc "c" () -> ^RenderPassSampleBufferAttachmentDescriptorArray { return msgSend(^RenderPassSampleBufferAttachmentDescriptorArray, RenderPassSampleBufferAttachmentDescriptorArray, "alloc") } @(objc_type=RenderPassSampleBufferAttachmentDescriptorArray, objc_name="init") -RenderPassSampleBufferAttachmentDescriptorArray_init :: #force_inline proc(self: ^RenderPassSampleBufferAttachmentDescriptorArray) -> ^RenderPassSampleBufferAttachmentDescriptorArray { +RenderPassSampleBufferAttachmentDescriptorArray_init :: #force_inline proc "c" (self: ^RenderPassSampleBufferAttachmentDescriptorArray) -> ^RenderPassSampleBufferAttachmentDescriptorArray { return msgSend(^RenderPassSampleBufferAttachmentDescriptorArray, self, "init") } @(objc_type=RenderPassSampleBufferAttachmentDescriptorArray, objc_name="object") -RenderPassSampleBufferAttachmentDescriptorArray_object :: #force_inline proc(self: ^RenderPassSampleBufferAttachmentDescriptorArray, attachmentIndex: NS.UInteger) -> ^RenderPassSampleBufferAttachmentDescriptor { +RenderPassSampleBufferAttachmentDescriptorArray_object :: #force_inline proc "c" (self: ^RenderPassSampleBufferAttachmentDescriptorArray, attachmentIndex: NS.UInteger) -> ^RenderPassSampleBufferAttachmentDescriptor { return msgSend(^RenderPassSampleBufferAttachmentDescriptor, self, "objectAtIndexedSubscript:", attachmentIndex) } @(objc_type=RenderPassSampleBufferAttachmentDescriptorArray, objc_name="setObject") -RenderPassSampleBufferAttachmentDescriptorArray_setObject :: #force_inline proc(self: ^RenderPassSampleBufferAttachmentDescriptorArray, attachment: ^RenderPassSampleBufferAttachmentDescriptor, attachmentIndex: NS.UInteger) { +RenderPassSampleBufferAttachmentDescriptorArray_setObject :: #force_inline proc "c" (self: ^RenderPassSampleBufferAttachmentDescriptorArray, attachment: ^RenderPassSampleBufferAttachmentDescriptor, attachmentIndex: NS.UInteger) { msgSend(nil, self, "setObject:atIndexedSubscript:", attachment, attachmentIndex) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - RenderPassStencilAttachmentDescriptor -Class Methods: - alloc -Methods: - init - clearStencil - setClearStencil - setStencilResolveFilter - stencilResolveFilter -*/ + @(objc_class="MTLRenderPassStencilAttachmentDescriptor") RenderPassStencilAttachmentDescriptor :: struct { using _: NS.Copying(RenderPassStencilAttachmentDescriptor) } @(objc_type=RenderPassStencilAttachmentDescriptor, objc_name="alloc", objc_is_class_method=true) -RenderPassStencilAttachmentDescriptor_alloc :: #force_inline proc() -> ^RenderPassStencilAttachmentDescriptor { +RenderPassStencilAttachmentDescriptor_alloc :: #force_inline proc "c" () -> ^RenderPassStencilAttachmentDescriptor { return msgSend(^RenderPassStencilAttachmentDescriptor, RenderPassStencilAttachmentDescriptor, "alloc") } @(objc_type=RenderPassStencilAttachmentDescriptor, objc_name="init") -RenderPassStencilAttachmentDescriptor_init :: #force_inline proc(self: ^RenderPassStencilAttachmentDescriptor) -> ^RenderPassStencilAttachmentDescriptor { +RenderPassStencilAttachmentDescriptor_init :: #force_inline proc "c" (self: ^RenderPassStencilAttachmentDescriptor) -> ^RenderPassStencilAttachmentDescriptor { return msgSend(^RenderPassStencilAttachmentDescriptor, self, "init") } @(objc_type=RenderPassStencilAttachmentDescriptor, objc_name="clearStencil") -RenderPassStencilAttachmentDescriptor_clearStencil :: #force_inline proc(self: ^RenderPassStencilAttachmentDescriptor) -> u32 { +RenderPassStencilAttachmentDescriptor_clearStencil :: #force_inline proc "c" (self: ^RenderPassStencilAttachmentDescriptor) -> u32 { return msgSend(u32, self, "clearStencil") } @(objc_type=RenderPassStencilAttachmentDescriptor, objc_name="setClearStencil") -RenderPassStencilAttachmentDescriptor_setClearStencil :: #force_inline proc(self: ^RenderPassStencilAttachmentDescriptor, clearStencil: u32) { +RenderPassStencilAttachmentDescriptor_setClearStencil :: #force_inline proc "c" (self: ^RenderPassStencilAttachmentDescriptor, clearStencil: u32) { msgSend(nil, self, "setClearStencil:", clearStencil) } @(objc_type=RenderPassStencilAttachmentDescriptor, objc_name="setStencilResolveFilter") -RenderPassStencilAttachmentDescriptor_setStencilResolveFilter :: #force_inline proc(self: ^RenderPassStencilAttachmentDescriptor, stencilResolveFilter: MultisampleStencilResolveFilter) { +RenderPassStencilAttachmentDescriptor_setStencilResolveFilter :: #force_inline proc "c" (self: ^RenderPassStencilAttachmentDescriptor, stencilResolveFilter: MultisampleStencilResolveFilter) { msgSend(nil, self, "setStencilResolveFilter:", stencilResolveFilter) } @(objc_type=RenderPassStencilAttachmentDescriptor, objc_name="stencilResolveFilter") -RenderPassStencilAttachmentDescriptor_stencilResolveFilter :: #force_inline proc(self: ^RenderPassStencilAttachmentDescriptor) -> MultisampleStencilResolveFilter { +RenderPassStencilAttachmentDescriptor_stencilResolveFilter :: #force_inline proc "c" (self: ^RenderPassStencilAttachmentDescriptor) -> MultisampleStencilResolveFilter { return msgSend(MultisampleStencilResolveFilter, self, "stencilResolveFilter") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - RenderPipelineColorAttachmentDescriptor -Class Methods: - alloc -Methods: - init - alphaBlendOperation - destinationAlphaBlendFactor - destinationRGBBlendFactor - isBlendingEnabled - pixelFormat - rgbBlendOperation - setAlphaBlendOperation - setBlendingEnabled - setDestinationAlphaBlendFactor - setDestinationRGBBlendFactor - setPixelFormat - setRgbBlendOperation - setSourceAlphaBlendFactor - setSourceRGBBlendFactor - setWriteMask - sourceAlphaBlendFactor - sourceRGBBlendFactor - writeMask -*/ + @(objc_class="MTLRenderPipelineColorAttachmentDescriptor") RenderPipelineColorAttachmentDescriptor :: struct { using _: NS.Copying(RenderPipelineColorAttachmentDescriptor), using _: RenderPassAttachmentDescriptor } @(objc_type=RenderPipelineColorAttachmentDescriptor, objc_name="alloc", objc_is_class_method=true) -RenderPipelineColorAttachmentDescriptor_alloc :: #force_inline proc() -> ^RenderPipelineColorAttachmentDescriptor { +RenderPipelineColorAttachmentDescriptor_alloc :: #force_inline proc "c" () -> ^RenderPipelineColorAttachmentDescriptor { return msgSend(^RenderPipelineColorAttachmentDescriptor, RenderPipelineColorAttachmentDescriptor, "alloc") } @(objc_type=RenderPipelineColorAttachmentDescriptor, objc_name="init") -RenderPipelineColorAttachmentDescriptor_init :: #force_inline proc(self: ^RenderPipelineColorAttachmentDescriptor) -> ^RenderPipelineColorAttachmentDescriptor { +RenderPipelineColorAttachmentDescriptor_init :: #force_inline proc "c" (self: ^RenderPipelineColorAttachmentDescriptor) -> ^RenderPipelineColorAttachmentDescriptor { return msgSend(^RenderPipelineColorAttachmentDescriptor, self, "init") } @(objc_type=RenderPipelineColorAttachmentDescriptor, objc_name="alphaBlendOperation") -RenderPipelineColorAttachmentDescriptor_alphaBlendOperation :: #force_inline proc(self: ^RenderPipelineColorAttachmentDescriptor) -> BlendOperation { +RenderPipelineColorAttachmentDescriptor_alphaBlendOperation :: #force_inline proc "c" (self: ^RenderPipelineColorAttachmentDescriptor) -> BlendOperation { return msgSend(BlendOperation, self, "alphaBlendOperation") } @(objc_type=RenderPipelineColorAttachmentDescriptor, objc_name="destinationAlphaBlendFactor") -RenderPipelineColorAttachmentDescriptor_destinationAlphaBlendFactor :: #force_inline proc(self: ^RenderPipelineColorAttachmentDescriptor) -> BlendFactor { +RenderPipelineColorAttachmentDescriptor_destinationAlphaBlendFactor :: #force_inline proc "c" (self: ^RenderPipelineColorAttachmentDescriptor) -> BlendFactor { return msgSend(BlendFactor, self, "destinationAlphaBlendFactor") } @(objc_type=RenderPipelineColorAttachmentDescriptor, objc_name="destinationRGBBlendFactor") -RenderPipelineColorAttachmentDescriptor_destinationRGBBlendFactor :: #force_inline proc(self: ^RenderPipelineColorAttachmentDescriptor) -> BlendFactor { +RenderPipelineColorAttachmentDescriptor_destinationRGBBlendFactor :: #force_inline proc "c" (self: ^RenderPipelineColorAttachmentDescriptor) -> BlendFactor { return msgSend(BlendFactor, self, "destinationRGBBlendFactor") } @(objc_type=RenderPipelineColorAttachmentDescriptor, objc_name="isBlendingEnabled") -RenderPipelineColorAttachmentDescriptor_isBlendingEnabled :: #force_inline proc(self: ^RenderPipelineColorAttachmentDescriptor) -> BOOL { +RenderPipelineColorAttachmentDescriptor_isBlendingEnabled :: #force_inline proc "c" (self: ^RenderPipelineColorAttachmentDescriptor) -> BOOL { return msgSend(BOOL, self, "isBlendingEnabled") } @(objc_type=RenderPipelineColorAttachmentDescriptor, objc_name="pixelFormat") -RenderPipelineColorAttachmentDescriptor_pixelFormat :: #force_inline proc(self: ^RenderPipelineColorAttachmentDescriptor) -> PixelFormat { +RenderPipelineColorAttachmentDescriptor_pixelFormat :: #force_inline proc "c" (self: ^RenderPipelineColorAttachmentDescriptor) -> PixelFormat { return msgSend(PixelFormat, self, "pixelFormat") } @(objc_type=RenderPipelineColorAttachmentDescriptor, objc_name="rgbBlendOperation") -RenderPipelineColorAttachmentDescriptor_rgbBlendOperation :: #force_inline proc(self: ^RenderPipelineColorAttachmentDescriptor) -> BlendOperation { +RenderPipelineColorAttachmentDescriptor_rgbBlendOperation :: #force_inline proc "c" (self: ^RenderPipelineColorAttachmentDescriptor) -> BlendOperation { return msgSend(BlendOperation, self, "rgbBlendOperation") } @(objc_type=RenderPipelineColorAttachmentDescriptor, objc_name="setAlphaBlendOperation") -RenderPipelineColorAttachmentDescriptor_setAlphaBlendOperation :: #force_inline proc(self: ^RenderPipelineColorAttachmentDescriptor, alphaBlendOperation: BlendOperation) { +RenderPipelineColorAttachmentDescriptor_setAlphaBlendOperation :: #force_inline proc "c" (self: ^RenderPipelineColorAttachmentDescriptor, alphaBlendOperation: BlendOperation) { msgSend(nil, self, "setAlphaBlendOperation:", alphaBlendOperation) } @(objc_type=RenderPipelineColorAttachmentDescriptor, objc_name="setBlendingEnabled") -RenderPipelineColorAttachmentDescriptor_setBlendingEnabled :: #force_inline proc(self: ^RenderPipelineColorAttachmentDescriptor, blendingEnabled: BOOL) { +RenderPipelineColorAttachmentDescriptor_setBlendingEnabled :: #force_inline proc "c" (self: ^RenderPipelineColorAttachmentDescriptor, blendingEnabled: BOOL) { msgSend(nil, self, "setBlendingEnabled:", blendingEnabled) } @(objc_type=RenderPipelineColorAttachmentDescriptor, objc_name="setDestinationAlphaBlendFactor") -RenderPipelineColorAttachmentDescriptor_setDestinationAlphaBlendFactor :: #force_inline proc(self: ^RenderPipelineColorAttachmentDescriptor, destinationAlphaBlendFactor: BlendFactor) { +RenderPipelineColorAttachmentDescriptor_setDestinationAlphaBlendFactor :: #force_inline proc "c" (self: ^RenderPipelineColorAttachmentDescriptor, destinationAlphaBlendFactor: BlendFactor) { msgSend(nil, self, "setDestinationAlphaBlendFactor:", destinationAlphaBlendFactor) } @(objc_type=RenderPipelineColorAttachmentDescriptor, objc_name="setDestinationRGBBlendFactor") -RenderPipelineColorAttachmentDescriptor_setDestinationRGBBlendFactor :: #force_inline proc(self: ^RenderPipelineColorAttachmentDescriptor, destinationRGBBlendFactor: BlendFactor) { +RenderPipelineColorAttachmentDescriptor_setDestinationRGBBlendFactor :: #force_inline proc "c" (self: ^RenderPipelineColorAttachmentDescriptor, destinationRGBBlendFactor: BlendFactor) { msgSend(nil, self, "setDestinationRGBBlendFactor:", destinationRGBBlendFactor) } @(objc_type=RenderPipelineColorAttachmentDescriptor, objc_name="setPixelFormat") -RenderPipelineColorAttachmentDescriptor_setPixelFormat :: #force_inline proc(self: ^RenderPipelineColorAttachmentDescriptor, pixelFormat: PixelFormat) { +RenderPipelineColorAttachmentDescriptor_setPixelFormat :: #force_inline proc "c" (self: ^RenderPipelineColorAttachmentDescriptor, pixelFormat: PixelFormat) { msgSend(nil, self, "setPixelFormat:", pixelFormat) } @(objc_type=RenderPipelineColorAttachmentDescriptor, objc_name="setRgbBlendOperation") -RenderPipelineColorAttachmentDescriptor_setRgbBlendOperation :: #force_inline proc(self: ^RenderPipelineColorAttachmentDescriptor, rgbBlendOperation: BlendOperation) { +RenderPipelineColorAttachmentDescriptor_setRgbBlendOperation :: #force_inline proc "c" (self: ^RenderPipelineColorAttachmentDescriptor, rgbBlendOperation: BlendOperation) { msgSend(nil, self, "setRgbBlendOperation:", rgbBlendOperation) } @(objc_type=RenderPipelineColorAttachmentDescriptor, objc_name="setSourceAlphaBlendFactor") -RenderPipelineColorAttachmentDescriptor_setSourceAlphaBlendFactor :: #force_inline proc(self: ^RenderPipelineColorAttachmentDescriptor, sourceAlphaBlendFactor: BlendFactor) { +RenderPipelineColorAttachmentDescriptor_setSourceAlphaBlendFactor :: #force_inline proc "c" (self: ^RenderPipelineColorAttachmentDescriptor, sourceAlphaBlendFactor: BlendFactor) { msgSend(nil, self, "setSourceAlphaBlendFactor:", sourceAlphaBlendFactor) } @(objc_type=RenderPipelineColorAttachmentDescriptor, objc_name="setSourceRGBBlendFactor") -RenderPipelineColorAttachmentDescriptor_setSourceRGBBlendFactor :: #force_inline proc(self: ^RenderPipelineColorAttachmentDescriptor, sourceRGBBlendFactor: BlendFactor) { +RenderPipelineColorAttachmentDescriptor_setSourceRGBBlendFactor :: #force_inline proc "c" (self: ^RenderPipelineColorAttachmentDescriptor, sourceRGBBlendFactor: BlendFactor) { msgSend(nil, self, "setSourceRGBBlendFactor:", sourceRGBBlendFactor) } @(objc_type=RenderPipelineColorAttachmentDescriptor, objc_name="setWriteMask") -RenderPipelineColorAttachmentDescriptor_setWriteMask :: #force_inline proc(self: ^RenderPipelineColorAttachmentDescriptor, writeMask: ColorWriteMask) { +RenderPipelineColorAttachmentDescriptor_setWriteMask :: #force_inline proc "c" (self: ^RenderPipelineColorAttachmentDescriptor, writeMask: ColorWriteMask) { msgSend(nil, self, "setWriteMask:", writeMask) } @(objc_type=RenderPipelineColorAttachmentDescriptor, objc_name="sourceAlphaBlendFactor") -RenderPipelineColorAttachmentDescriptor_sourceAlphaBlendFactor :: #force_inline proc(self: ^RenderPipelineColorAttachmentDescriptor) -> BlendFactor { +RenderPipelineColorAttachmentDescriptor_sourceAlphaBlendFactor :: #force_inline proc "c" (self: ^RenderPipelineColorAttachmentDescriptor) -> BlendFactor { return msgSend(BlendFactor, self, "sourceAlphaBlendFactor") } @(objc_type=RenderPipelineColorAttachmentDescriptor, objc_name="sourceRGBBlendFactor") -RenderPipelineColorAttachmentDescriptor_sourceRGBBlendFactor :: #force_inline proc(self: ^RenderPipelineColorAttachmentDescriptor) -> BlendFactor { +RenderPipelineColorAttachmentDescriptor_sourceRGBBlendFactor :: #force_inline proc "c" (self: ^RenderPipelineColorAttachmentDescriptor) -> BlendFactor { return msgSend(BlendFactor, self, "sourceRGBBlendFactor") } @(objc_type=RenderPipelineColorAttachmentDescriptor, objc_name="writeMask") -RenderPipelineColorAttachmentDescriptor_writeMask :: #force_inline proc(self: ^RenderPipelineColorAttachmentDescriptor) -> ColorWriteMask { +RenderPipelineColorAttachmentDescriptor_writeMask :: #force_inline proc "c" (self: ^RenderPipelineColorAttachmentDescriptor) -> ColorWriteMask { return msgSend(ColorWriteMask, self, "writeMask") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - RenderPipelineColorAttachmentDescriptorArray -Class Methods: - alloc -Methods: - init - objectAtIndexedSubscript - setObject -*/ + @(objc_class="MTLRenderPipelineColorAttachmentDescriptorArray") RenderPipelineColorAttachmentDescriptorArray :: struct { using _: NS.Object } @(objc_type=RenderPipelineColorAttachmentDescriptorArray, objc_name="alloc", objc_is_class_method=true) -RenderPipelineColorAttachmentDescriptorArray_alloc :: #force_inline proc() -> ^RenderPipelineColorAttachmentDescriptorArray { +RenderPipelineColorAttachmentDescriptorArray_alloc :: #force_inline proc "c" () -> ^RenderPipelineColorAttachmentDescriptorArray { return msgSend(^RenderPipelineColorAttachmentDescriptorArray, RenderPipelineColorAttachmentDescriptorArray, "alloc") } @(objc_type=RenderPipelineColorAttachmentDescriptorArray, objc_name="init") -RenderPipelineColorAttachmentDescriptorArray_init :: #force_inline proc(self: ^RenderPipelineColorAttachmentDescriptorArray) -> ^RenderPipelineColorAttachmentDescriptorArray { +RenderPipelineColorAttachmentDescriptorArray_init :: #force_inline proc "c" (self: ^RenderPipelineColorAttachmentDescriptorArray) -> ^RenderPipelineColorAttachmentDescriptorArray { return msgSend(^RenderPipelineColorAttachmentDescriptorArray, self, "init") } @(objc_type=RenderPipelineColorAttachmentDescriptorArray, objc_name="object") -RenderPipelineColorAttachmentDescriptorArray_object :: #force_inline proc(self: ^RenderPipelineColorAttachmentDescriptorArray, attachmentIndex: NS.UInteger) -> ^RenderPipelineColorAttachmentDescriptor { +RenderPipelineColorAttachmentDescriptorArray_object :: #force_inline proc "c" (self: ^RenderPipelineColorAttachmentDescriptorArray, attachmentIndex: NS.UInteger) -> ^RenderPipelineColorAttachmentDescriptor { return msgSend(^RenderPipelineColorAttachmentDescriptor, self, "objectAtIndexedSubscript:", attachmentIndex) } @(objc_type=RenderPipelineColorAttachmentDescriptorArray, objc_name="setObject") -RenderPipelineColorAttachmentDescriptorArray_setObject :: #force_inline proc(self: ^RenderPipelineColorAttachmentDescriptorArray, attachment: ^RenderPipelineColorAttachmentDescriptor, attachmentIndex: NS.UInteger) { +RenderPipelineColorAttachmentDescriptorArray_setObject :: #force_inline proc "c" (self: ^RenderPipelineColorAttachmentDescriptorArray, attachment: ^RenderPipelineColorAttachmentDescriptor, attachmentIndex: NS.UInteger) { msgSend(nil, self, "setObject:atIndexedSubscript:", attachment, attachmentIndex) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - RenderPipelineDescriptor -Class Methods: - alloc -Methods: - init - binaryArchives - colorAttachments - depthAttachmentPixelFormat - fragmentBuffers - fragmentFunction - inputPrimitiveTopology - isAlphaToCoverageEnabled - isAlphaToOneEnabled - isRasterizationEnabled - isTessellationFactorScaleEnabled - label - maxTessellationFactor - maxVertexAmplificationCount - rasterSampleCount - reset - sampleCount - setAlphaToCoverageEnabled - setAlphaToOneEnabled - setBinaryArchives - setDepthAttachmentPixelFormat - setFragmentFunction - setInputPrimitiveTopology - setLabel - setMaxTessellationFactor - setMaxVertexAmplificationCount - setRasterSampleCount - setRasterizationEnabled - setSampleCount - setStencilAttachmentPixelFormat - setSupportIndirectCommandBuffers - setTessellationControlPointIndexType - setTessellationFactorFormat - setTessellationFactorScaleEnabled - setTessellationFactorStepFunction - setTessellationOutputWindingOrder - setTessellationPartitionMode - setVertexDescriptor - setVertexFunction - stencilAttachmentPixelFormat - supportIndirectCommandBuffers - tessellationControlPointIndexType - tessellationFactorFormat - tessellationFactorStepFunction - tessellationOutputWindingOrder - tessellationPartitionMode - vertexBuffers - vertexDescriptor - vertexFunction -*/ + @(objc_class="MTLRenderPipelineDescriptor") RenderPipelineDescriptor :: struct { using _: NS.Copying(RenderPipelineDescriptor) } @(objc_type=RenderPipelineDescriptor, objc_name="alloc", objc_is_class_method=true) -RenderPipelineDescriptor_alloc :: #force_inline proc() -> ^RenderPipelineDescriptor { +RenderPipelineDescriptor_alloc :: #force_inline proc "c" () -> ^RenderPipelineDescriptor { return msgSend(^RenderPipelineDescriptor, RenderPipelineDescriptor, "alloc") } @(objc_type=RenderPipelineDescriptor, objc_name="init") -RenderPipelineDescriptor_init :: #force_inline proc(self: ^RenderPipelineDescriptor) -> ^RenderPipelineDescriptor { +RenderPipelineDescriptor_init :: #force_inline proc "c" (self: ^RenderPipelineDescriptor) -> ^RenderPipelineDescriptor { return msgSend(^RenderPipelineDescriptor, self, "init") } @(objc_type=RenderPipelineDescriptor, objc_name="binaryArchives") -RenderPipelineDescriptor_binaryArchives :: #force_inline proc(self: ^RenderPipelineDescriptor) -> ^NS.Array { +RenderPipelineDescriptor_binaryArchives :: #force_inline proc "c" (self: ^RenderPipelineDescriptor) -> ^NS.Array { return msgSend(^NS.Array, self, "binaryArchives") } @(objc_type=RenderPipelineDescriptor, objc_name="colorAttachments") -RenderPipelineDescriptor_colorAttachments :: #force_inline proc(self: ^RenderPipelineDescriptor) -> ^RenderPipelineColorAttachmentDescriptorArray { +RenderPipelineDescriptor_colorAttachments :: #force_inline proc "c" (self: ^RenderPipelineDescriptor) -> ^RenderPipelineColorAttachmentDescriptorArray { return msgSend(^RenderPipelineColorAttachmentDescriptorArray, self, "colorAttachments") } @(objc_type=RenderPipelineDescriptor, objc_name="depthAttachmentPixelFormat") -RenderPipelineDescriptor_depthAttachmentPixelFormat :: #force_inline proc(self: ^RenderPipelineDescriptor) -> PixelFormat { +RenderPipelineDescriptor_depthAttachmentPixelFormat :: #force_inline proc "c" (self: ^RenderPipelineDescriptor) -> PixelFormat { return msgSend(PixelFormat, self, "depthAttachmentPixelFormat") } @(objc_type=RenderPipelineDescriptor, objc_name="fragmentBuffers") -RenderPipelineDescriptor_fragmentBuffers :: #force_inline proc(self: ^RenderPipelineDescriptor) -> ^PipelineBufferDescriptorArray { +RenderPipelineDescriptor_fragmentBuffers :: #force_inline proc "c" (self: ^RenderPipelineDescriptor) -> ^PipelineBufferDescriptorArray { return msgSend(^PipelineBufferDescriptorArray, self, "fragmentBuffers") } @(objc_type=RenderPipelineDescriptor, objc_name="fragmentFunction") -RenderPipelineDescriptor_fragmentFunction :: #force_inline proc(self: ^RenderPipelineDescriptor) -> ^Function { +RenderPipelineDescriptor_fragmentFunction :: #force_inline proc "c" (self: ^RenderPipelineDescriptor) -> ^Function { return msgSend(^Function, self, "fragmentFunction") } @(objc_type=RenderPipelineDescriptor, objc_name="inputPrimitiveTopology") -RenderPipelineDescriptor_inputPrimitiveTopology :: #force_inline proc(self: ^RenderPipelineDescriptor) -> PrimitiveTopologyClass { +RenderPipelineDescriptor_inputPrimitiveTopology :: #force_inline proc "c" (self: ^RenderPipelineDescriptor) -> PrimitiveTopologyClass { return msgSend(PrimitiveTopologyClass, self, "inputPrimitiveTopology") } @(objc_type=RenderPipelineDescriptor, objc_name="isAlphaToCoverageEnabled") -RenderPipelineDescriptor_isAlphaToCoverageEnabled :: #force_inline proc(self: ^RenderPipelineDescriptor) -> BOOL { +RenderPipelineDescriptor_isAlphaToCoverageEnabled :: #force_inline proc "c" (self: ^RenderPipelineDescriptor) -> BOOL { return msgSend(BOOL, self, "isAlphaToCoverageEnabled") } @(objc_type=RenderPipelineDescriptor, objc_name="isAlphaToOneEnabled") -RenderPipelineDescriptor_isAlphaToOneEnabled :: #force_inline proc(self: ^RenderPipelineDescriptor) -> BOOL { +RenderPipelineDescriptor_isAlphaToOneEnabled :: #force_inline proc "c" (self: ^RenderPipelineDescriptor) -> BOOL { return msgSend(BOOL, self, "isAlphaToOneEnabled") } @(objc_type=RenderPipelineDescriptor, objc_name="isRasterizationEnabled") -RenderPipelineDescriptor_isRasterizationEnabled :: #force_inline proc(self: ^RenderPipelineDescriptor) -> BOOL { +RenderPipelineDescriptor_isRasterizationEnabled :: #force_inline proc "c" (self: ^RenderPipelineDescriptor) -> BOOL { return msgSend(BOOL, self, "isRasterizationEnabled") } @(objc_type=RenderPipelineDescriptor, objc_name="isTessellationFactorScaleEnabled") -RenderPipelineDescriptor_isTessellationFactorScaleEnabled :: #force_inline proc(self: ^RenderPipelineDescriptor) -> BOOL { +RenderPipelineDescriptor_isTessellationFactorScaleEnabled :: #force_inline proc "c" (self: ^RenderPipelineDescriptor) -> BOOL { return msgSend(BOOL, self, "isTessellationFactorScaleEnabled") } @(objc_type=RenderPipelineDescriptor, objc_name="label") -RenderPipelineDescriptor_label :: #force_inline proc(self: ^RenderPipelineDescriptor) -> ^NS.String { +RenderPipelineDescriptor_label :: #force_inline proc "c" (self: ^RenderPipelineDescriptor) -> ^NS.String { return msgSend(^NS.String, self, "label") } @(objc_type=RenderPipelineDescriptor, objc_name="maxTessellationFactor") -RenderPipelineDescriptor_maxTessellationFactor :: #force_inline proc(self: ^RenderPipelineDescriptor) -> NS.UInteger { +RenderPipelineDescriptor_maxTessellationFactor :: #force_inline proc "c" (self: ^RenderPipelineDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "maxTessellationFactor") } @(objc_type=RenderPipelineDescriptor, objc_name="maxVertexAmplificationCount") -RenderPipelineDescriptor_maxVertexAmplificationCount :: #force_inline proc(self: ^RenderPipelineDescriptor) -> NS.UInteger { +RenderPipelineDescriptor_maxVertexAmplificationCount :: #force_inline proc "c" (self: ^RenderPipelineDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "maxVertexAmplificationCount") } @(objc_type=RenderPipelineDescriptor, objc_name="rasterSampleCount") -RenderPipelineDescriptor_rasterSampleCount :: #force_inline proc(self: ^RenderPipelineDescriptor) -> NS.UInteger { +RenderPipelineDescriptor_rasterSampleCount :: #force_inline proc "c" (self: ^RenderPipelineDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "rasterSampleCount") } @(objc_type=RenderPipelineDescriptor, objc_name="reset") -RenderPipelineDescriptor_reset :: #force_inline proc(self: ^RenderPipelineDescriptor) { +RenderPipelineDescriptor_reset :: #force_inline proc "c" (self: ^RenderPipelineDescriptor) { msgSend(nil, self, "reset") } @(objc_type=RenderPipelineDescriptor, objc_name="sampleCount") -RenderPipelineDescriptor_sampleCount :: #force_inline proc(self: ^RenderPipelineDescriptor) -> NS.UInteger { +RenderPipelineDescriptor_sampleCount :: #force_inline proc "c" (self: ^RenderPipelineDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "sampleCount") } @(objc_type=RenderPipelineDescriptor, objc_name="setAlphaToCoverageEnabled") -RenderPipelineDescriptor_setAlphaToCoverageEnabled :: #force_inline proc(self: ^RenderPipelineDescriptor, alphaToCoverageEnabled: BOOL) { +RenderPipelineDescriptor_setAlphaToCoverageEnabled :: #force_inline proc "c" (self: ^RenderPipelineDescriptor, alphaToCoverageEnabled: BOOL) { msgSend(nil, self, "setAlphaToCoverageEnabled:", alphaToCoverageEnabled) } @(objc_type=RenderPipelineDescriptor, objc_name="setAlphaToOneEnabled") -RenderPipelineDescriptor_setAlphaToOneEnabled :: #force_inline proc(self: ^RenderPipelineDescriptor, alphaToOneEnabled: BOOL) { +RenderPipelineDescriptor_setAlphaToOneEnabled :: #force_inline proc "c" (self: ^RenderPipelineDescriptor, alphaToOneEnabled: BOOL) { msgSend(nil, self, "setAlphaToOneEnabled:", alphaToOneEnabled) } @(objc_type=RenderPipelineDescriptor, objc_name="setBinaryArchives") -RenderPipelineDescriptor_setBinaryArchives :: #force_inline proc(self: ^RenderPipelineDescriptor, binaryArchives: ^NS.Array) { +RenderPipelineDescriptor_setBinaryArchives :: #force_inline proc "c" (self: ^RenderPipelineDescriptor, binaryArchives: ^NS.Array) { msgSend(nil, self, "setBinaryArchives:", binaryArchives) } @(objc_type=RenderPipelineDescriptor, objc_name="setDepthAttachmentPixelFormat") -RenderPipelineDescriptor_setDepthAttachmentPixelFormat :: #force_inline proc(self: ^RenderPipelineDescriptor, depthAttachmentPixelFormat: PixelFormat) { +RenderPipelineDescriptor_setDepthAttachmentPixelFormat :: #force_inline proc "c" (self: ^RenderPipelineDescriptor, depthAttachmentPixelFormat: PixelFormat) { msgSend(nil, self, "setDepthAttachmentPixelFormat:", depthAttachmentPixelFormat) } @(objc_type=RenderPipelineDescriptor, objc_name="setFragmentFunction") -RenderPipelineDescriptor_setFragmentFunction :: #force_inline proc(self: ^RenderPipelineDescriptor, fragmentFunction: ^Function) { +RenderPipelineDescriptor_setFragmentFunction :: #force_inline proc "c" (self: ^RenderPipelineDescriptor, fragmentFunction: ^Function) { msgSend(nil, self, "setFragmentFunction:", fragmentFunction) } @(objc_type=RenderPipelineDescriptor, objc_name="setInputPrimitiveTopology") -RenderPipelineDescriptor_setInputPrimitiveTopology :: #force_inline proc(self: ^RenderPipelineDescriptor, inputPrimitiveTopology: PrimitiveTopologyClass) { +RenderPipelineDescriptor_setInputPrimitiveTopology :: #force_inline proc "c" (self: ^RenderPipelineDescriptor, inputPrimitiveTopology: PrimitiveTopologyClass) { msgSend(nil, self, "setInputPrimitiveTopology:", inputPrimitiveTopology) } @(objc_type=RenderPipelineDescriptor, objc_name="setLabel") -RenderPipelineDescriptor_setLabel :: #force_inline proc(self: ^RenderPipelineDescriptor, label: ^NS.String) { +RenderPipelineDescriptor_setLabel :: #force_inline proc "c" (self: ^RenderPipelineDescriptor, label: ^NS.String) { msgSend(nil, self, "setLabel:", label) } @(objc_type=RenderPipelineDescriptor, objc_name="setMaxTessellationFactor") -RenderPipelineDescriptor_setMaxTessellationFactor :: #force_inline proc(self: ^RenderPipelineDescriptor, maxTessellationFactor: NS.UInteger) { +RenderPipelineDescriptor_setMaxTessellationFactor :: #force_inline proc "c" (self: ^RenderPipelineDescriptor, maxTessellationFactor: NS.UInteger) { msgSend(nil, self, "setMaxTessellationFactor:", maxTessellationFactor) } @(objc_type=RenderPipelineDescriptor, objc_name="setMaxVertexAmplificationCount") -RenderPipelineDescriptor_setMaxVertexAmplificationCount :: #force_inline proc(self: ^RenderPipelineDescriptor, maxVertexAmplificationCount: NS.UInteger) { +RenderPipelineDescriptor_setMaxVertexAmplificationCount :: #force_inline proc "c" (self: ^RenderPipelineDescriptor, maxVertexAmplificationCount: NS.UInteger) { msgSend(nil, self, "setMaxVertexAmplificationCount:", maxVertexAmplificationCount) } @(objc_type=RenderPipelineDescriptor, objc_name="setRasterSampleCount") -RenderPipelineDescriptor_setRasterSampleCount :: #force_inline proc(self: ^RenderPipelineDescriptor, rasterSampleCount: NS.UInteger) { +RenderPipelineDescriptor_setRasterSampleCount :: #force_inline proc "c" (self: ^RenderPipelineDescriptor, rasterSampleCount: NS.UInteger) { msgSend(nil, self, "setRasterSampleCount:", rasterSampleCount) } @(objc_type=RenderPipelineDescriptor, objc_name="setRasterizationEnabled") -RenderPipelineDescriptor_setRasterizationEnabled :: #force_inline proc(self: ^RenderPipelineDescriptor, rasterizationEnabled: BOOL) { +RenderPipelineDescriptor_setRasterizationEnabled :: #force_inline proc "c" (self: ^RenderPipelineDescriptor, rasterizationEnabled: BOOL) { msgSend(nil, self, "setRasterizationEnabled:", rasterizationEnabled) } @(objc_type=RenderPipelineDescriptor, objc_name="setSampleCount") -RenderPipelineDescriptor_setSampleCount :: #force_inline proc(self: ^RenderPipelineDescriptor, sampleCount: NS.UInteger) { +RenderPipelineDescriptor_setSampleCount :: #force_inline proc "c" (self: ^RenderPipelineDescriptor, sampleCount: NS.UInteger) { msgSend(nil, self, "setSampleCount:", sampleCount) } @(objc_type=RenderPipelineDescriptor, objc_name="setStencilAttachmentPixelFormat") -RenderPipelineDescriptor_setStencilAttachmentPixelFormat :: #force_inline proc(self: ^RenderPipelineDescriptor, stencilAttachmentPixelFormat: PixelFormat) { +RenderPipelineDescriptor_setStencilAttachmentPixelFormat :: #force_inline proc "c" (self: ^RenderPipelineDescriptor, stencilAttachmentPixelFormat: PixelFormat) { msgSend(nil, self, "setStencilAttachmentPixelFormat:", stencilAttachmentPixelFormat) } @(objc_type=RenderPipelineDescriptor, objc_name="setSupportIndirectCommandBuffers") -RenderPipelineDescriptor_setSupportIndirectCommandBuffers :: #force_inline proc(self: ^RenderPipelineDescriptor, supportIndirectCommandBuffers: BOOL) { +RenderPipelineDescriptor_setSupportIndirectCommandBuffers :: #force_inline proc "c" (self: ^RenderPipelineDescriptor, supportIndirectCommandBuffers: BOOL) { msgSend(nil, self, "setSupportIndirectCommandBuffers:", supportIndirectCommandBuffers) } @(objc_type=RenderPipelineDescriptor, objc_name="setTessellationControlPointIndexType") -RenderPipelineDescriptor_setTessellationControlPointIndexType :: #force_inline proc(self: ^RenderPipelineDescriptor, tessellationControlPointIndexType: TessellationControlPointIndexType) { +RenderPipelineDescriptor_setTessellationControlPointIndexType :: #force_inline proc "c" (self: ^RenderPipelineDescriptor, tessellationControlPointIndexType: TessellationControlPointIndexType) { msgSend(nil, self, "setTessellationControlPointIndexType:", tessellationControlPointIndexType) } @(objc_type=RenderPipelineDescriptor, objc_name="setTessellationFactorFormat") -RenderPipelineDescriptor_setTessellationFactorFormat :: #force_inline proc(self: ^RenderPipelineDescriptor, tessellationFactorFormat: TessellationFactorFormat) { +RenderPipelineDescriptor_setTessellationFactorFormat :: #force_inline proc "c" (self: ^RenderPipelineDescriptor, tessellationFactorFormat: TessellationFactorFormat) { msgSend(nil, self, "setTessellationFactorFormat:", tessellationFactorFormat) } @(objc_type=RenderPipelineDescriptor, objc_name="setTessellationFactorScaleEnabled") -RenderPipelineDescriptor_setTessellationFactorScaleEnabled :: #force_inline proc(self: ^RenderPipelineDescriptor, tessellationFactorScaleEnabled: BOOL) { +RenderPipelineDescriptor_setTessellationFactorScaleEnabled :: #force_inline proc "c" (self: ^RenderPipelineDescriptor, tessellationFactorScaleEnabled: BOOL) { msgSend(nil, self, "setTessellationFactorScaleEnabled:", tessellationFactorScaleEnabled) } @(objc_type=RenderPipelineDescriptor, objc_name="setTessellationFactorStepFunction") -RenderPipelineDescriptor_setTessellationFactorStepFunction :: #force_inline proc(self: ^RenderPipelineDescriptor, tessellationFactorStepFunction: TessellationFactorStepFunction) { +RenderPipelineDescriptor_setTessellationFactorStepFunction :: #force_inline proc "c" (self: ^RenderPipelineDescriptor, tessellationFactorStepFunction: TessellationFactorStepFunction) { msgSend(nil, self, "setTessellationFactorStepFunction:", tessellationFactorStepFunction) } @(objc_type=RenderPipelineDescriptor, objc_name="setTessellationOutputWindingOrder") -RenderPipelineDescriptor_setTessellationOutputWindingOrder :: #force_inline proc(self: ^RenderPipelineDescriptor, tessellationOutputWindingOrder: Winding) { +RenderPipelineDescriptor_setTessellationOutputWindingOrder :: #force_inline proc "c" (self: ^RenderPipelineDescriptor, tessellationOutputWindingOrder: Winding) { msgSend(nil, self, "setTessellationOutputWindingOrder:", tessellationOutputWindingOrder) } @(objc_type=RenderPipelineDescriptor, objc_name="setTessellationPartitionMode") -RenderPipelineDescriptor_setTessellationPartitionMode :: #force_inline proc(self: ^RenderPipelineDescriptor, tessellationPartitionMode: TessellationPartitionMode) { +RenderPipelineDescriptor_setTessellationPartitionMode :: #force_inline proc "c" (self: ^RenderPipelineDescriptor, tessellationPartitionMode: TessellationPartitionMode) { msgSend(nil, self, "setTessellationPartitionMode:", tessellationPartitionMode) } @(objc_type=RenderPipelineDescriptor, objc_name="setVertexDescriptor") -RenderPipelineDescriptor_setVertexDescriptor :: #force_inline proc(self: ^RenderPipelineDescriptor, vertexDescriptor: ^VertexDescriptor) { +RenderPipelineDescriptor_setVertexDescriptor :: #force_inline proc "c" (self: ^RenderPipelineDescriptor, vertexDescriptor: ^VertexDescriptor) { msgSend(nil, self, "setVertexDescriptor:", vertexDescriptor) } @(objc_type=RenderPipelineDescriptor, objc_name="setVertexFunction") -RenderPipelineDescriptor_setVertexFunction :: #force_inline proc(self: ^RenderPipelineDescriptor, vertexFunction: ^Function) { +RenderPipelineDescriptor_setVertexFunction :: #force_inline proc "c" (self: ^RenderPipelineDescriptor, vertexFunction: ^Function) { msgSend(nil, self, "setVertexFunction:", vertexFunction) } @(objc_type=RenderPipelineDescriptor, objc_name="stencilAttachmentPixelFormat") -RenderPipelineDescriptor_stencilAttachmentPixelFormat :: #force_inline proc(self: ^RenderPipelineDescriptor) -> PixelFormat { +RenderPipelineDescriptor_stencilAttachmentPixelFormat :: #force_inline proc "c" (self: ^RenderPipelineDescriptor) -> PixelFormat { return msgSend(PixelFormat, self, "stencilAttachmentPixelFormat") } @(objc_type=RenderPipelineDescriptor, objc_name="supportIndirectCommandBuffers") -RenderPipelineDescriptor_supportIndirectCommandBuffers :: #force_inline proc(self: ^RenderPipelineDescriptor) -> BOOL { +RenderPipelineDescriptor_supportIndirectCommandBuffers :: #force_inline proc "c" (self: ^RenderPipelineDescriptor) -> BOOL { return msgSend(BOOL, self, "supportIndirectCommandBuffers") } @(objc_type=RenderPipelineDescriptor, objc_name="tessellationControlPointIndexType") -RenderPipelineDescriptor_tessellationControlPointIndexType :: #force_inline proc(self: ^RenderPipelineDescriptor) -> TessellationControlPointIndexType { +RenderPipelineDescriptor_tessellationControlPointIndexType :: #force_inline proc "c" (self: ^RenderPipelineDescriptor) -> TessellationControlPointIndexType { return msgSend(TessellationControlPointIndexType, self, "tessellationControlPointIndexType") } @(objc_type=RenderPipelineDescriptor, objc_name="tessellationFactorFormat") -RenderPipelineDescriptor_tessellationFactorFormat :: #force_inline proc(self: ^RenderPipelineDescriptor) -> TessellationFactorFormat { +RenderPipelineDescriptor_tessellationFactorFormat :: #force_inline proc "c" (self: ^RenderPipelineDescriptor) -> TessellationFactorFormat { return msgSend(TessellationFactorFormat, self, "tessellationFactorFormat") } @(objc_type=RenderPipelineDescriptor, objc_name="tessellationFactorStepFunction") -RenderPipelineDescriptor_tessellationFactorStepFunction :: #force_inline proc(self: ^RenderPipelineDescriptor) -> TessellationFactorStepFunction { +RenderPipelineDescriptor_tessellationFactorStepFunction :: #force_inline proc "c" (self: ^RenderPipelineDescriptor) -> TessellationFactorStepFunction { return msgSend(TessellationFactorStepFunction, self, "tessellationFactorStepFunction") } @(objc_type=RenderPipelineDescriptor, objc_name="tessellationOutputWindingOrder") -RenderPipelineDescriptor_tessellationOutputWindingOrder :: #force_inline proc(self: ^RenderPipelineDescriptor) -> Winding { +RenderPipelineDescriptor_tessellationOutputWindingOrder :: #force_inline proc "c" (self: ^RenderPipelineDescriptor) -> Winding { return msgSend(Winding, self, "tessellationOutputWindingOrder") } @(objc_type=RenderPipelineDescriptor, objc_name="tessellationPartitionMode") -RenderPipelineDescriptor_tessellationPartitionMode :: #force_inline proc(self: ^RenderPipelineDescriptor) -> TessellationPartitionMode { +RenderPipelineDescriptor_tessellationPartitionMode :: #force_inline proc "c" (self: ^RenderPipelineDescriptor) -> TessellationPartitionMode { return msgSend(TessellationPartitionMode, self, "tessellationPartitionMode") } @(objc_type=RenderPipelineDescriptor, objc_name="vertexBuffers") -RenderPipelineDescriptor_vertexBuffers :: #force_inline proc(self: ^RenderPipelineDescriptor) -> ^PipelineBufferDescriptorArray { +RenderPipelineDescriptor_vertexBuffers :: #force_inline proc "c" (self: ^RenderPipelineDescriptor) -> ^PipelineBufferDescriptorArray { return msgSend(^PipelineBufferDescriptorArray, self, "vertexBuffers") } @(objc_type=RenderPipelineDescriptor, objc_name="vertexDescriptor") -RenderPipelineDescriptor_vertexDescriptor :: #force_inline proc(self: ^RenderPipelineDescriptor) -> ^VertexDescriptor { +RenderPipelineDescriptor_vertexDescriptor :: #force_inline proc "c" (self: ^RenderPipelineDescriptor) -> ^VertexDescriptor { return msgSend(^VertexDescriptor, self, "vertexDescriptor") } @(objc_type=RenderPipelineDescriptor, objc_name="vertexFunction") -RenderPipelineDescriptor_vertexFunction :: #force_inline proc(self: ^RenderPipelineDescriptor) -> ^Function { +RenderPipelineDescriptor_vertexFunction :: #force_inline proc "c" (self: ^RenderPipelineDescriptor) -> ^Function { return msgSend(^Function, self, "vertexFunction") } +@(objc_type=RenderPipelineDescriptor, objc_name="objectFunction") +RenderPipelineDescriptor_objectFunction :: #force_inline proc "c" (self: ^RenderPipelineDescriptor) -> ^Function { + return msgSend(^Function, self, "objectFunction") +} +@(objc_type=RenderPipelineDescriptor, objc_name="setObjectFunction") +RenderPipelineDescriptor_setObjectFunction :: #force_inline proc "c" (self: ^RenderPipelineDescriptor, objectFunction: ^Function) { + msgSend(nil, self, "setObjectFunction:", objectFunction) +} +@(objc_type=RenderPipelineDescriptor, objc_name="meshFunction") +RenderPipelineDescriptor_meshFunction :: #force_inline proc "c" (self: ^RenderPipelineDescriptor) -> ^Function { + return msgSend(^Function, self, "meshFunction") +} +@(objc_type=RenderPipelineDescriptor, objc_name="setMeshFunction") +RenderPipelineDescriptor_setMeshFunction :: #force_inline proc "c" (self: ^RenderPipelineDescriptor, meshFunction: ^Function) { + msgSend(nil, self, "setMeshFunction:", meshFunction) +} + +@(objc_type=RenderPipelineDescriptor, objc_name="maxTotalThreadsPerObjectThreadgroup") +RenderPipelineDescriptor_maxTotalThreadsPerObjectThreadgroup :: #force_inline proc "c" (self: ^RenderPipelineDescriptor) -> NS.UInteger { + return msgSend(NS.UInteger, self, "maxTotalThreadsPerObjectThreadgroup") +} +@(objc_type=RenderPipelineDescriptor, objc_name="setMaxTotalThreadsPerObjectThreadgroup") +RenderPipelineDescriptor_setMaxTotalThreadsPerObjectThreadgroup :: #force_inline proc "c" (self: ^RenderPipelineDescriptor, maxTotalThreadsPerObjectThreadgroup: NS.UInteger) { + msgSend(nil, self, "setMaxTotalThreadsPerObjectThreadgroup:", maxTotalThreadsPerObjectThreadgroup) +} +@(objc_type=RenderPipelineDescriptor, objc_name="maxTotalThreadsPerMeshThreadgroup") +RenderPipelineDescriptor_maxTotalThreadsPerMeshThreadgroup :: #force_inline proc "c" (self: ^RenderPipelineDescriptor) -> NS.UInteger { + return msgSend(NS.UInteger, self, "maxTotalThreadsPerMeshThreadgroup") +} +@(objc_type=RenderPipelineDescriptor, objc_name="setMaxTotalThreadsPerMeshThreadgroup") +RenderPipelineDescriptor_setMaxTotalThreadsPerMeshThreadgroup :: #force_inline proc "c" (self: ^RenderPipelineDescriptor, maxTotalThreadsPerMeshThreadgroup: NS.UInteger) { + msgSend(nil, self, "setMaxTotalThreadsPerMeshThreadgroup:", maxTotalThreadsPerMeshThreadgroup) +} +@(objc_type=RenderPipelineDescriptor, objc_name="objectThreadgroupSizeIsMultipleOfThreadExecutionWidth") +RenderPipelineDescriptor_objectThreadgroupSizeIsMultipleOfThreadExecutionWidth :: #force_inline proc "c" (self: ^RenderPipelineDescriptor) -> NS.UInteger { + return msgSend(NS.UInteger, self, "objectThreadgroupSizeIsMultipleOfThreadExecutionWidth") +} +@(objc_type=RenderPipelineDescriptor, objc_name="setObjectThreadgroupSizeIsMultipleOfThreadExecutionWidth") +RenderPipelineDescriptor_setObjectThreadgroupSizeIsMultipleOfThreadExecutionWidth :: #force_inline proc "c" (self: ^RenderPipelineDescriptor, objectThreadgroupSizeIsMultipleOfThreadExecutionWidth: NS.UInteger) { + msgSend(nil, self, "setObjectThreadgroupSizeIsMultipleOfThreadExecutionWidth:", objectThreadgroupSizeIsMultipleOfThreadExecutionWidth) +} + +@(objc_type=RenderPipelineDescriptor, objc_name="meshThreadgroupSizeIsMultipleOfThreadExecutionWidth") +RenderPipelineDescriptor_meshThreadgroupSizeIsMultipleOfThreadExecutionWidth :: #force_inline proc "c" (self: ^RenderPipelineDescriptor) -> BOOL { + return msgSend(BOOL, self, "meshThreadgroupSizeIsMultipleOfThreadExecutionWidth") +} +@(objc_type=RenderPipelineDescriptor, objc_name="setMeshThreadgroupSizeIsMultipleOfThreadExecutionWidth") +RenderPipelineDescriptor_setMeshThreadgroupSizeIsMultipleOfThreadExecutionWidth :: #force_inline proc "c" (self: ^RenderPipelineDescriptor, meshThreadgroupSizeIsMultipleOfThreadExecutionWidth: BOOL) { + msgSend(nil, self, "setMeshThreadgroupSizeIsMultipleOfThreadExecutionWidth:", meshThreadgroupSizeIsMultipleOfThreadExecutionWidth) +} + + +@(objc_type=RenderPipelineDescriptor, objc_name="payloadMemoryLength") +RenderPipelineDescriptor_payloadMemoryLength :: #force_inline proc "c" (self: ^RenderPipelineDescriptor) -> NS.UInteger { + return msgSend(NS.UInteger, self, "payloadMemoryLength") +} +@(objc_type=RenderPipelineDescriptor, objc_name="setPayloadMemoryLength") +RenderPipelineDescriptor_setPayloadMemoryLength :: #force_inline proc "c" (self: ^RenderPipelineDescriptor, payloadMemoryLength: NS.UInteger) { + msgSend(nil, self, "setPayloadMemoryLength:", payloadMemoryLength) +} +@(objc_type=RenderPipelineDescriptor, objc_name="maxTotalThreadgroupsPerMeshGrid") +RenderPipelineDescriptor_maxTotalThreadgroupsPerMeshGrid :: #force_inline proc "c" (self: ^RenderPipelineDescriptor) -> NS.UInteger { + return msgSend(NS.UInteger, self, "maxTotalThreadgroupsPerMeshGrid") +} +@(objc_type=RenderPipelineDescriptor, objc_name="setMaxTotalThreadgroupsPerMeshGrid") +RenderPipelineDescriptor_setMaxTotalThreadgroupsPerMeshGrid :: #force_inline proc "c" (self: ^RenderPipelineDescriptor, maxTotalThreadgroupsPerMeshGrid: NS.UInteger) { + msgSend(nil, self, "setMaxTotalThreadgroupsPerMeshGrid:", maxTotalThreadgroupsPerMeshGrid) +} + +@(objc_type=RenderPipelineDescriptor, objc_name="objectBuffers") +RenderPipelineDescriptor_objectBuffers :: #force_inline proc "c" (self: ^RenderPipelineDescriptor) -> ^PipelineBufferDescriptorArray { + return msgSend(^PipelineBufferDescriptorArray, self, "objectBuffers") +} +@(objc_type=RenderPipelineDescriptor, objc_name="meshBuffers") +RenderPipelineDescriptor_meshBuffers :: #force_inline proc "c" (self: ^RenderPipelineDescriptor) -> ^PipelineBufferDescriptorArray { + return msgSend(^PipelineBufferDescriptorArray, self, "meshBuffers") +} + + + +@(objc_type=RenderPipelineDescriptor, objc_name="alphaToCoverageEnabled") +RenderPipelineDescriptor_alphaToCoverageEnabled :: #force_inline proc "c" (self: ^RenderPipelineDescriptor) -> BOOL { + return msgSend(BOOL, self, "alphaToCoverageEnabled") +} +@(objc_type=RenderPipelineDescriptor, objc_name="alphaToOneEnabled") +RenderPipelineDescriptor_alphaToOneEnabled :: #force_inline proc "c" (self: ^RenderPipelineDescriptor) -> BOOL { + return msgSend(BOOL, self, "alphaToOneEnabled") +} + +@(objc_type=RenderPipelineDescriptor, objc_name="rasterizationEnabled") +RenderPipelineDescriptor_rasterizationEnabled :: #force_inline proc "c" (self: ^RenderPipelineDescriptor) -> BOOL { + return msgSend(BOOL, self, "rasterizationEnabled") +} + + //////////////////////////////////////////////////////////////////////////////// -/* -Class: - RenderPipelineReflection -Class Methods: - alloc -Methods: - init - fragmentArguments - tileArguments - vertexArguments -*/ + @(objc_class="MTLRenderPipelineReflection") RenderPipelineReflection :: struct { using _: NS.Object } @(objc_type=RenderPipelineReflection, objc_name="alloc", objc_is_class_method=true) -RenderPipelineReflection_alloc :: #force_inline proc() -> ^RenderPipelineReflection { +RenderPipelineReflection_alloc :: #force_inline proc "c" () -> ^RenderPipelineReflection { return msgSend(^RenderPipelineReflection, RenderPipelineReflection, "alloc") } @(objc_type=RenderPipelineReflection, objc_name="init") -RenderPipelineReflection_init :: #force_inline proc(self: ^RenderPipelineReflection) -> ^RenderPipelineReflection { +RenderPipelineReflection_init :: #force_inline proc "c" (self: ^RenderPipelineReflection) -> ^RenderPipelineReflection { return msgSend(^RenderPipelineReflection, self, "init") } @(objc_type=RenderPipelineReflection, objc_name="fragmentArguments") -RenderPipelineReflection_fragmentArguments :: #force_inline proc(self: ^RenderPipelineReflection) -> ^NS.Array { +RenderPipelineReflection_fragmentArguments :: #force_inline proc "c" (self: ^RenderPipelineReflection) -> ^NS.Array { return msgSend(^NS.Array, self, "fragmentArguments") } @(objc_type=RenderPipelineReflection, objc_name="tileArguments") -RenderPipelineReflection_tileArguments :: #force_inline proc(self: ^RenderPipelineReflection) -> ^NS.Array { +RenderPipelineReflection_tileArguments :: #force_inline proc "c" (self: ^RenderPipelineReflection) -> ^NS.Array { return msgSend(^NS.Array, self, "tileArguments") } @(objc_type=RenderPipelineReflection, objc_name="vertexArguments") -RenderPipelineReflection_vertexArguments :: #force_inline proc(self: ^RenderPipelineReflection) -> ^NS.Array { +RenderPipelineReflection_vertexArguments :: #force_inline proc "c" (self: ^RenderPipelineReflection) -> ^NS.Array { return msgSend(^NS.Array, self, "vertexArguments") } +@(objc_type=RenderPipelineReflection, objc_name="vertexBindings") +RenderPipelineReflection_vertexBindings :: #force_inline proc "c" (self: ^RenderPipelineReflection) -> ^NS.Array { + return msgSend(^NS.Array, self, "vertexBindings") +} +@(objc_type=RenderPipelineReflection, objc_name="fragmentBindings") +RenderPipelineReflection_fragmentBindings :: #force_inline proc "c" (self: ^RenderPipelineReflection) -> ^NS.Array { + return msgSend(^NS.Array, self, "fragmentBindings") +} +@(objc_type=RenderPipelineReflection, objc_name="tileBindings") +RenderPipelineReflection_tileBindings :: #force_inline proc "c" (self: ^RenderPipelineReflection) -> ^NS.Array { + return msgSend(^NS.Array, self, "tileBindings") +} +@(objc_type=RenderPipelineReflection, objc_name="objectBindings") +RenderPipelineReflection_objectBindings :: #force_inline proc "c" (self: ^RenderPipelineReflection) -> ^NS.Array { + return msgSend(^NS.Array, self, "objectBindings") +} +@(objc_type=RenderPipelineReflection, objc_name="meshBindings") +RenderPipelineReflection_meshBindings :: #force_inline proc "c" (self: ^RenderPipelineReflection) -> ^NS.Array { + return msgSend(^NS.Array, self, "meshBindings") +} + //////////////////////////////////////////////////////////////////////////////// -/* -Class: - ResourceStatePassDescriptor -Class Methods: - alloc - resourceStatePassDescriptor -Methods: - init - sampleBufferAttachments -*/ + @(objc_class="MTLResourceStatePassDescriptor") ResourceStatePassDescriptor :: struct { using _: NS.Copying(ResourceStatePassDescriptor) } @(objc_type=ResourceStatePassDescriptor, objc_name="alloc", objc_is_class_method=true) -ResourceStatePassDescriptor_alloc :: #force_inline proc() -> ^ResourceStatePassDescriptor { +ResourceStatePassDescriptor_alloc :: #force_inline proc "c" () -> ^ResourceStatePassDescriptor { return msgSend(^ResourceStatePassDescriptor, ResourceStatePassDescriptor, "alloc") } @(objc_type=ResourceStatePassDescriptor, objc_name="init") -ResourceStatePassDescriptor_init :: #force_inline proc(self: ^ResourceStatePassDescriptor) -> ^ResourceStatePassDescriptor { +ResourceStatePassDescriptor_init :: #force_inline proc "c" (self: ^ResourceStatePassDescriptor) -> ^ResourceStatePassDescriptor { return msgSend(^ResourceStatePassDescriptor, self, "init") } @(objc_type=ResourceStatePassDescriptor, objc_name="resourceStatePassDescriptor", objc_is_class_method=true) -ResourceStatePassDescriptor_resourceStatePassDescriptor :: #force_inline proc() -> ^ResourceStatePassDescriptor { +ResourceStatePassDescriptor_resourceStatePassDescriptor :: #force_inline proc "c" () -> ^ResourceStatePassDescriptor { return msgSend(^ResourceStatePassDescriptor, ResourceStatePassDescriptor, "resourceStatePassDescriptor") } @(objc_type=ResourceStatePassDescriptor, objc_name="sampleBufferAttachments") -ResourceStatePassDescriptor_sampleBufferAttachments :: #force_inline proc(self: ^ResourceStatePassDescriptor) -> ^ResourceStatePassSampleBufferAttachmentDescriptorArray { +ResourceStatePassDescriptor_sampleBufferAttachments :: #force_inline proc "c" (self: ^ResourceStatePassDescriptor) -> ^ResourceStatePassSampleBufferAttachmentDescriptorArray { return msgSend(^ResourceStatePassSampleBufferAttachmentDescriptorArray, self, "sampleBufferAttachments") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - ResourceStatePassSampleBufferAttachmentDescriptor -Class Methods: - alloc -Methods: - init - endOfEncoderSampleIndex - sampleBuffer - setEndOfEncoderSampleIndex - setSampleBuffer - setStartOfEncoderSampleIndex - startOfEncoderSampleIndex -*/ + @(objc_class="MTLResourceStatePassSampleBufferAttachmentDescriptor") ResourceStatePassSampleBufferAttachmentDescriptor :: struct { using _: NS.Copying(ResourceStatePassSampleBufferAttachmentDescriptor) } @(objc_type=ResourceStatePassSampleBufferAttachmentDescriptor, objc_name="alloc", objc_is_class_method=true) -ResourceStatePassSampleBufferAttachmentDescriptor_alloc :: #force_inline proc() -> ^ResourceStatePassSampleBufferAttachmentDescriptor { +ResourceStatePassSampleBufferAttachmentDescriptor_alloc :: #force_inline proc "c" () -> ^ResourceStatePassSampleBufferAttachmentDescriptor { return msgSend(^ResourceStatePassSampleBufferAttachmentDescriptor, ResourceStatePassSampleBufferAttachmentDescriptor, "alloc") } @(objc_type=ResourceStatePassSampleBufferAttachmentDescriptor, objc_name="init") -ResourceStatePassSampleBufferAttachmentDescriptor_init :: #force_inline proc(self: ^ResourceStatePassSampleBufferAttachmentDescriptor) -> ^ResourceStatePassSampleBufferAttachmentDescriptor { +ResourceStatePassSampleBufferAttachmentDescriptor_init :: #force_inline proc "c" (self: ^ResourceStatePassSampleBufferAttachmentDescriptor) -> ^ResourceStatePassSampleBufferAttachmentDescriptor { return msgSend(^ResourceStatePassSampleBufferAttachmentDescriptor, self, "init") } @(objc_type=ResourceStatePassSampleBufferAttachmentDescriptor, objc_name="endOfEncoderSampleIndex") -ResourceStatePassSampleBufferAttachmentDescriptor_endOfEncoderSampleIndex :: #force_inline proc(self: ^ResourceStatePassSampleBufferAttachmentDescriptor) -> NS.UInteger { +ResourceStatePassSampleBufferAttachmentDescriptor_endOfEncoderSampleIndex :: #force_inline proc "c" (self: ^ResourceStatePassSampleBufferAttachmentDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "endOfEncoderSampleIndex") } @(objc_type=ResourceStatePassSampleBufferAttachmentDescriptor, objc_name="sampleBuffer") -ResourceStatePassSampleBufferAttachmentDescriptor_sampleBuffer :: #force_inline proc(self: ^ResourceStatePassSampleBufferAttachmentDescriptor) -> ^CounterSampleBuffer { +ResourceStatePassSampleBufferAttachmentDescriptor_sampleBuffer :: #force_inline proc "c" (self: ^ResourceStatePassSampleBufferAttachmentDescriptor) -> ^CounterSampleBuffer { return msgSend(^CounterSampleBuffer, self, "sampleBuffer") } @(objc_type=ResourceStatePassSampleBufferAttachmentDescriptor, objc_name="setEndOfEncoderSampleIndex") -ResourceStatePassSampleBufferAttachmentDescriptor_setEndOfEncoderSampleIndex :: #force_inline proc(self: ^ResourceStatePassSampleBufferAttachmentDescriptor, endOfEncoderSampleIndex: NS.UInteger) { +ResourceStatePassSampleBufferAttachmentDescriptor_setEndOfEncoderSampleIndex :: #force_inline proc "c" (self: ^ResourceStatePassSampleBufferAttachmentDescriptor, endOfEncoderSampleIndex: NS.UInteger) { msgSend(nil, self, "setEndOfEncoderSampleIndex:", endOfEncoderSampleIndex) } @(objc_type=ResourceStatePassSampleBufferAttachmentDescriptor, objc_name="setSampleBuffer") -ResourceStatePassSampleBufferAttachmentDescriptor_setSampleBuffer :: #force_inline proc(self: ^ResourceStatePassSampleBufferAttachmentDescriptor, sampleBuffer: ^CounterSampleBuffer) { +ResourceStatePassSampleBufferAttachmentDescriptor_setSampleBuffer :: #force_inline proc "c" (self: ^ResourceStatePassSampleBufferAttachmentDescriptor, sampleBuffer: ^CounterSampleBuffer) { msgSend(nil, self, "setSampleBuffer:", sampleBuffer) } @(objc_type=ResourceStatePassSampleBufferAttachmentDescriptor, objc_name="setStartOfEncoderSampleIndex") -ResourceStatePassSampleBufferAttachmentDescriptor_setStartOfEncoderSampleIndex :: #force_inline proc(self: ^ResourceStatePassSampleBufferAttachmentDescriptor, startOfEncoderSampleIndex: NS.UInteger) { +ResourceStatePassSampleBufferAttachmentDescriptor_setStartOfEncoderSampleIndex :: #force_inline proc "c" (self: ^ResourceStatePassSampleBufferAttachmentDescriptor, startOfEncoderSampleIndex: NS.UInteger) { msgSend(nil, self, "setStartOfEncoderSampleIndex:", startOfEncoderSampleIndex) } @(objc_type=ResourceStatePassSampleBufferAttachmentDescriptor, objc_name="startOfEncoderSampleIndex") -ResourceStatePassSampleBufferAttachmentDescriptor_startOfEncoderSampleIndex :: #force_inline proc(self: ^ResourceStatePassSampleBufferAttachmentDescriptor) -> NS.UInteger { +ResourceStatePassSampleBufferAttachmentDescriptor_startOfEncoderSampleIndex :: #force_inline proc "c" (self: ^ResourceStatePassSampleBufferAttachmentDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "startOfEncoderSampleIndex") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - ResourceStatePassSampleBufferAttachmentDescriptorArray -Class Methods: - alloc -Methods: - init - objectAtIndexedSubscript - setObject -*/ + @(objc_class="MTLResourceStatePassSampleBufferAttachmentDescriptorArray") ResourceStatePassSampleBufferAttachmentDescriptorArray :: struct { using _: NS.Object } @(objc_type=ResourceStatePassSampleBufferAttachmentDescriptorArray, objc_name="alloc", objc_is_class_method=true) -ResourceStatePassSampleBufferAttachmentDescriptorArray_alloc :: #force_inline proc() -> ^ResourceStatePassSampleBufferAttachmentDescriptorArray { +ResourceStatePassSampleBufferAttachmentDescriptorArray_alloc :: #force_inline proc "c" () -> ^ResourceStatePassSampleBufferAttachmentDescriptorArray { return msgSend(^ResourceStatePassSampleBufferAttachmentDescriptorArray, ResourceStatePassSampleBufferAttachmentDescriptorArray, "alloc") } @(objc_type=ResourceStatePassSampleBufferAttachmentDescriptorArray, objc_name="init") -ResourceStatePassSampleBufferAttachmentDescriptorArray_init :: #force_inline proc(self: ^ResourceStatePassSampleBufferAttachmentDescriptorArray) -> ^ResourceStatePassSampleBufferAttachmentDescriptorArray { +ResourceStatePassSampleBufferAttachmentDescriptorArray_init :: #force_inline proc "c" (self: ^ResourceStatePassSampleBufferAttachmentDescriptorArray) -> ^ResourceStatePassSampleBufferAttachmentDescriptorArray { return msgSend(^ResourceStatePassSampleBufferAttachmentDescriptorArray, self, "init") } @(objc_type=ResourceStatePassSampleBufferAttachmentDescriptorArray, objc_name="object") -ResourceStatePassSampleBufferAttachmentDescriptorArray_object :: #force_inline proc(self: ^ResourceStatePassSampleBufferAttachmentDescriptorArray, attachmentIndex: NS.UInteger) -> ^ResourceStatePassSampleBufferAttachmentDescriptor { +ResourceStatePassSampleBufferAttachmentDescriptorArray_object :: #force_inline proc "c" (self: ^ResourceStatePassSampleBufferAttachmentDescriptorArray, attachmentIndex: NS.UInteger) -> ^ResourceStatePassSampleBufferAttachmentDescriptor { return msgSend(^ResourceStatePassSampleBufferAttachmentDescriptor, self, "objectAtIndexedSubscript:", attachmentIndex) } @(objc_type=ResourceStatePassSampleBufferAttachmentDescriptorArray, objc_name="setObject") -ResourceStatePassSampleBufferAttachmentDescriptorArray_setObject :: #force_inline proc(self: ^ResourceStatePassSampleBufferAttachmentDescriptorArray, attachment: ^ResourceStatePassSampleBufferAttachmentDescriptor, attachmentIndex: NS.UInteger) { +ResourceStatePassSampleBufferAttachmentDescriptorArray_setObject :: #force_inline proc "c" (self: ^ResourceStatePassSampleBufferAttachmentDescriptorArray, attachment: ^ResourceStatePassSampleBufferAttachmentDescriptor, attachmentIndex: NS.UInteger) { msgSend(nil, self, "setObject:atIndexedSubscript:", attachment, attachmentIndex) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - SamplerDescriptor -Class Methods: - alloc -Methods: - init - borderColor - compareFunction - label - lodAverage - lodMaxClamp - lodMinClamp - magFilter - maxAnisotropy - minFilter - mipFilter - normalizedCoordinates - rAddressMode - sAddressMode - setBorderColor - setCompareFunction - setLabel - setLodAverage - setLodMaxClamp - setLodMinClamp - setMagFilter - setMaxAnisotropy - setMinFilter - setMipFilter - setNormalizedCoordinates - setRAddressMode - setSAddressMode - setSupportArgumentBuffers - setTAddressMode - supportArgumentBuffers - tAddressMode -*/ + @(objc_class="MTLSamplerDescriptor") SamplerDescriptor :: struct { using _: NS.Copying(SamplerDescriptor) } @(objc_type=SamplerDescriptor, objc_name="alloc", objc_is_class_method=true) -SamplerDescriptor_alloc :: #force_inline proc() -> ^SamplerDescriptor { +SamplerDescriptor_alloc :: #force_inline proc "c" () -> ^SamplerDescriptor { return msgSend(^SamplerDescriptor, SamplerDescriptor, "alloc") } @(objc_type=SamplerDescriptor, objc_name="init") -SamplerDescriptor_init :: #force_inline proc(self: ^SamplerDescriptor) -> ^SamplerDescriptor { +SamplerDescriptor_init :: #force_inline proc "c" (self: ^SamplerDescriptor) -> ^SamplerDescriptor { return msgSend(^SamplerDescriptor, self, "init") } @(objc_type=SamplerDescriptor, objc_name="borderColor") -SamplerDescriptor_borderColor :: #force_inline proc(self: ^SamplerDescriptor) -> SamplerBorderColor { +SamplerDescriptor_borderColor :: #force_inline proc "c" (self: ^SamplerDescriptor) -> SamplerBorderColor { return msgSend(SamplerBorderColor, self, "borderColor") } @(objc_type=SamplerDescriptor, objc_name="compareFunction") -SamplerDescriptor_compareFunction :: #force_inline proc(self: ^SamplerDescriptor) -> CompareFunction { +SamplerDescriptor_compareFunction :: #force_inline proc "c" (self: ^SamplerDescriptor) -> CompareFunction { return msgSend(CompareFunction, self, "compareFunction") } @(objc_type=SamplerDescriptor, objc_name="label") -SamplerDescriptor_label :: #force_inline proc(self: ^SamplerDescriptor) -> ^NS.String { +SamplerDescriptor_label :: #force_inline proc "c" (self: ^SamplerDescriptor) -> ^NS.String { return msgSend(^NS.String, self, "label") } @(objc_type=SamplerDescriptor, objc_name="lodAverage") -SamplerDescriptor_lodAverage :: #force_inline proc(self: ^SamplerDescriptor) -> BOOL { +SamplerDescriptor_lodAverage :: #force_inline proc "c" (self: ^SamplerDescriptor) -> BOOL { return msgSend(BOOL, self, "lodAverage") } @(objc_type=SamplerDescriptor, objc_name="lodMaxClamp") -SamplerDescriptor_lodMaxClamp :: #force_inline proc(self: ^SamplerDescriptor) -> f32 { +SamplerDescriptor_lodMaxClamp :: #force_inline proc "c" (self: ^SamplerDescriptor) -> f32 { return msgSend(f32, self, "lodMaxClamp") } @(objc_type=SamplerDescriptor, objc_name="lodMinClamp") -SamplerDescriptor_lodMinClamp :: #force_inline proc(self: ^SamplerDescriptor) -> f32 { +SamplerDescriptor_lodMinClamp :: #force_inline proc "c" (self: ^SamplerDescriptor) -> f32 { return msgSend(f32, self, "lodMinClamp") } @(objc_type=SamplerDescriptor, objc_name="magFilter") -SamplerDescriptor_magFilter :: #force_inline proc(self: ^SamplerDescriptor) -> SamplerMinMagFilter { +SamplerDescriptor_magFilter :: #force_inline proc "c" (self: ^SamplerDescriptor) -> SamplerMinMagFilter { return msgSend(SamplerMinMagFilter, self, "magFilter") } @(objc_type=SamplerDescriptor, objc_name="maxAnisotropy") -SamplerDescriptor_maxAnisotropy :: #force_inline proc(self: ^SamplerDescriptor) -> NS.UInteger { +SamplerDescriptor_maxAnisotropy :: #force_inline proc "c" (self: ^SamplerDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "maxAnisotropy") } @(objc_type=SamplerDescriptor, objc_name="minFilter") -SamplerDescriptor_minFilter :: #force_inline proc(self: ^SamplerDescriptor) -> SamplerMinMagFilter { +SamplerDescriptor_minFilter :: #force_inline proc "c" (self: ^SamplerDescriptor) -> SamplerMinMagFilter { return msgSend(SamplerMinMagFilter, self, "minFilter") } @(objc_type=SamplerDescriptor, objc_name="mipFilter") -SamplerDescriptor_mipFilter :: #force_inline proc(self: ^SamplerDescriptor) -> SamplerMipFilter { +SamplerDescriptor_mipFilter :: #force_inline proc "c" (self: ^SamplerDescriptor) -> SamplerMipFilter { return msgSend(SamplerMipFilter, self, "mipFilter") } @(objc_type=SamplerDescriptor, objc_name="normalizedCoordinates") -SamplerDescriptor_normalizedCoordinates :: #force_inline proc(self: ^SamplerDescriptor) -> BOOL { +SamplerDescriptor_normalizedCoordinates :: #force_inline proc "c" (self: ^SamplerDescriptor) -> BOOL { return msgSend(BOOL, self, "normalizedCoordinates") } @(objc_type=SamplerDescriptor, objc_name="rAddressMode") -SamplerDescriptor_rAddressMode :: #force_inline proc(self: ^SamplerDescriptor) -> SamplerAddressMode { +SamplerDescriptor_rAddressMode :: #force_inline proc "c" (self: ^SamplerDescriptor) -> SamplerAddressMode { return msgSend(SamplerAddressMode, self, "rAddressMode") } @(objc_type=SamplerDescriptor, objc_name="sAddressMode") -SamplerDescriptor_sAddressMode :: #force_inline proc(self: ^SamplerDescriptor) -> SamplerAddressMode { +SamplerDescriptor_sAddressMode :: #force_inline proc "c" (self: ^SamplerDescriptor) -> SamplerAddressMode { return msgSend(SamplerAddressMode, self, "sAddressMode") } @(objc_type=SamplerDescriptor, objc_name="setBorderColor") -SamplerDescriptor_setBorderColor :: #force_inline proc(self: ^SamplerDescriptor, borderColor: SamplerBorderColor) { +SamplerDescriptor_setBorderColor :: #force_inline proc "c" (self: ^SamplerDescriptor, borderColor: SamplerBorderColor) { msgSend(nil, self, "setBorderColor:", borderColor) } @(objc_type=SamplerDescriptor, objc_name="setCompareFunction") -SamplerDescriptor_setCompareFunction :: #force_inline proc(self: ^SamplerDescriptor, compareFunction: CompareFunction) { +SamplerDescriptor_setCompareFunction :: #force_inline proc "c" (self: ^SamplerDescriptor, compareFunction: CompareFunction) { msgSend(nil, self, "setCompareFunction:", compareFunction) } @(objc_type=SamplerDescriptor, objc_name="setLabel") -SamplerDescriptor_setLabel :: #force_inline proc(self: ^SamplerDescriptor, label: ^NS.String) { +SamplerDescriptor_setLabel :: #force_inline proc "c" (self: ^SamplerDescriptor, label: ^NS.String) { msgSend(nil, self, "setLabel:", label) } @(objc_type=SamplerDescriptor, objc_name="setLodAverage") -SamplerDescriptor_setLodAverage :: #force_inline proc(self: ^SamplerDescriptor, lodAverage: BOOL) { +SamplerDescriptor_setLodAverage :: #force_inline proc "c" (self: ^SamplerDescriptor, lodAverage: BOOL) { msgSend(nil, self, "setLodAverage:", lodAverage) } @(objc_type=SamplerDescriptor, objc_name="setLodMaxClamp") -SamplerDescriptor_setLodMaxClamp :: #force_inline proc(self: ^SamplerDescriptor, lodMaxClamp: f32) { +SamplerDescriptor_setLodMaxClamp :: #force_inline proc "c" (self: ^SamplerDescriptor, lodMaxClamp: f32) { msgSend(nil, self, "setLodMaxClamp:", lodMaxClamp) } @(objc_type=SamplerDescriptor, objc_name="setLodMinClamp") -SamplerDescriptor_setLodMinClamp :: #force_inline proc(self: ^SamplerDescriptor, lodMinClamp: f32) { +SamplerDescriptor_setLodMinClamp :: #force_inline proc "c" (self: ^SamplerDescriptor, lodMinClamp: f32) { msgSend(nil, self, "setLodMinClamp:", lodMinClamp) } @(objc_type=SamplerDescriptor, objc_name="setMagFilter") -SamplerDescriptor_setMagFilter :: #force_inline proc(self: ^SamplerDescriptor, magFilter: SamplerMinMagFilter) { +SamplerDescriptor_setMagFilter :: #force_inline proc "c" (self: ^SamplerDescriptor, magFilter: SamplerMinMagFilter) { msgSend(nil, self, "setMagFilter:", magFilter) } @(objc_type=SamplerDescriptor, objc_name="setMaxAnisotropy") -SamplerDescriptor_setMaxAnisotropy :: #force_inline proc(self: ^SamplerDescriptor, maxAnisotropy: NS.UInteger) { +SamplerDescriptor_setMaxAnisotropy :: #force_inline proc "c" (self: ^SamplerDescriptor, maxAnisotropy: NS.UInteger) { msgSend(nil, self, "setMaxAnisotropy:", maxAnisotropy) } @(objc_type=SamplerDescriptor, objc_name="setMinFilter") -SamplerDescriptor_setMinFilter :: #force_inline proc(self: ^SamplerDescriptor, minFilter: SamplerMinMagFilter) { +SamplerDescriptor_setMinFilter :: #force_inline proc "c" (self: ^SamplerDescriptor, minFilter: SamplerMinMagFilter) { msgSend(nil, self, "setMinFilter:", minFilter) } @(objc_type=SamplerDescriptor, objc_name="setMipFilter") -SamplerDescriptor_setMipFilter :: #force_inline proc(self: ^SamplerDescriptor, mipFilter: SamplerMipFilter) { +SamplerDescriptor_setMipFilter :: #force_inline proc "c" (self: ^SamplerDescriptor, mipFilter: SamplerMipFilter) { msgSend(nil, self, "setMipFilter:", mipFilter) } @(objc_type=SamplerDescriptor, objc_name="setNormalizedCoordinates") -SamplerDescriptor_setNormalizedCoordinates :: #force_inline proc(self: ^SamplerDescriptor, normalizedCoordinates: BOOL) { +SamplerDescriptor_setNormalizedCoordinates :: #force_inline proc "c" (self: ^SamplerDescriptor, normalizedCoordinates: BOOL) { msgSend(nil, self, "setNormalizedCoordinates:", normalizedCoordinates) } @(objc_type=SamplerDescriptor, objc_name="setRAddressMode") -SamplerDescriptor_setRAddressMode :: #force_inline proc(self: ^SamplerDescriptor, rAddressMode: SamplerAddressMode) { +SamplerDescriptor_setRAddressMode :: #force_inline proc "c" (self: ^SamplerDescriptor, rAddressMode: SamplerAddressMode) { msgSend(nil, self, "setRAddressMode:", rAddressMode) } @(objc_type=SamplerDescriptor, objc_name="setSAddressMode") -SamplerDescriptor_setSAddressMode :: #force_inline proc(self: ^SamplerDescriptor, sAddressMode: SamplerAddressMode) { +SamplerDescriptor_setSAddressMode :: #force_inline proc "c" (self: ^SamplerDescriptor, sAddressMode: SamplerAddressMode) { msgSend(nil, self, "setSAddressMode:", sAddressMode) } @(objc_type=SamplerDescriptor, objc_name="setSupportArgumentBuffers") -SamplerDescriptor_setSupportArgumentBuffers :: #force_inline proc(self: ^SamplerDescriptor, supportArgumentBuffers: BOOL) { +SamplerDescriptor_setSupportArgumentBuffers :: #force_inline proc "c" (self: ^SamplerDescriptor, supportArgumentBuffers: BOOL) { msgSend(nil, self, "setSupportArgumentBuffers:", supportArgumentBuffers) } @(objc_type=SamplerDescriptor, objc_name="setTAddressMode") -SamplerDescriptor_setTAddressMode :: #force_inline proc(self: ^SamplerDescriptor, tAddressMode: SamplerAddressMode) { +SamplerDescriptor_setTAddressMode :: #force_inline proc "c" (self: ^SamplerDescriptor, tAddressMode: SamplerAddressMode) { msgSend(nil, self, "setTAddressMode:", tAddressMode) } @(objc_type=SamplerDescriptor, objc_name="supportArgumentBuffers") -SamplerDescriptor_supportArgumentBuffers :: #force_inline proc(self: ^SamplerDescriptor) -> BOOL { +SamplerDescriptor_supportArgumentBuffers :: #force_inline proc "c" (self: ^SamplerDescriptor) -> BOOL { return msgSend(BOOL, self, "supportArgumentBuffers") } @(objc_type=SamplerDescriptor, objc_name="tAddressMode") -SamplerDescriptor_tAddressMode :: #force_inline proc(self: ^SamplerDescriptor) -> SamplerAddressMode { +SamplerDescriptor_tAddressMode :: #force_inline proc "c" (self: ^SamplerDescriptor) -> SamplerAddressMode { return msgSend(SamplerAddressMode, self, "tAddressMode") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - SharedEventHandle -Class Methods: - alloc -Methods: - init - label -*/ + @(objc_class="MTLSharedEventHandle") SharedEventHandle :: struct { using _: NS.Object } @(objc_type=SharedEventHandle, objc_name="alloc", objc_is_class_method=true) -SharedEventHandle_alloc :: #force_inline proc() -> ^SharedEventHandle { +SharedEventHandle_alloc :: #force_inline proc "c" () -> ^SharedEventHandle { return msgSend(^SharedEventHandle, SharedEventHandle, "alloc") } @(objc_type=SharedEventHandle, objc_name="init") -SharedEventHandle_init :: #force_inline proc(self: ^SharedEventHandle) -> ^SharedEventHandle { +SharedEventHandle_init :: #force_inline proc "c" (self: ^SharedEventHandle) -> ^SharedEventHandle { return msgSend(^SharedEventHandle, self, "init") } @(objc_type=SharedEventHandle, objc_name="label") -SharedEventHandle_label :: #force_inline proc(self: ^SharedEventHandle) -> ^NS.String { +SharedEventHandle_label :: #force_inline proc "c" (self: ^SharedEventHandle) -> ^NS.String { return msgSend(^NS.String, self, "label") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - SharedEventListener -Class Methods: - alloc -Methods: - dispatchQueue - init - initWithDispatchQueue -*/ + @(objc_class="MTLSharedEventListener") SharedEventListener :: struct { using _: NS.Object } @(objc_type=SharedEventListener, objc_name="alloc", objc_is_class_method=true) -SharedEventListener_alloc :: #force_inline proc() -> ^SharedEventListener { +SharedEventListener_alloc :: #force_inline proc "c" () -> ^SharedEventListener { return msgSend(^SharedEventListener, SharedEventListener, "alloc") } @(objc_type=SharedEventListener, objc_name="dispatchQueue") -SharedEventListener_dispatchQueue :: #force_inline proc(self: ^SharedEventListener) -> dispatch_queue_t { +SharedEventListener_dispatchQueue :: #force_inline proc "c" (self: ^SharedEventListener) -> dispatch_queue_t { return msgSend(dispatch_queue_t, self, "dispatchQueue") } @(objc_type=SharedEventListener, objc_name="init") -SharedEventListener_init :: #force_inline proc(self: ^SharedEventListener) -> ^SharedEventListener { +SharedEventListener_init :: #force_inline proc "c" (self: ^SharedEventListener) -> ^SharedEventListener { return msgSend(^SharedEventListener, self, "init") } @(objc_type=SharedEventListener, objc_name="initWithDispatchQueue") -SharedEventListener_initWithDispatchQueue :: #force_inline proc(self: ^SharedEventListener, dispatchQueue: dispatch_queue_t) -> ^SharedEventListener { +SharedEventListener_initWithDispatchQueue :: #force_inline proc "c" (self: ^SharedEventListener, dispatchQueue: dispatch_queue_t) -> ^SharedEventListener { return msgSend(^SharedEventListener, self, "initWithDispatchQueue:", dispatchQueue) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - SharedTextureHandle -Class Methods: - alloc -Methods: - init - device - label -*/ + @(objc_class="MTLSharedTextureHandle") SharedTextureHandle :: struct { using _: NS.Object } @(objc_type=SharedTextureHandle, objc_name="alloc", objc_is_class_method=true) -SharedTextureHandle_alloc :: #force_inline proc() -> ^SharedTextureHandle { +SharedTextureHandle_alloc :: #force_inline proc "c" () -> ^SharedTextureHandle { return msgSend(^SharedTextureHandle, SharedTextureHandle, "alloc") } @(objc_type=SharedTextureHandle, objc_name="init") -SharedTextureHandle_init :: #force_inline proc(self: ^SharedTextureHandle) -> ^SharedTextureHandle { +SharedTextureHandle_init :: #force_inline proc "c" (self: ^SharedTextureHandle) -> ^SharedTextureHandle { return msgSend(^SharedTextureHandle, self, "init") } @(objc_type=SharedTextureHandle, objc_name="device") -SharedTextureHandle_device :: #force_inline proc(self: ^SharedTextureHandle) -> ^Device { +SharedTextureHandle_device :: #force_inline proc "c" (self: ^SharedTextureHandle) -> ^Device { return msgSend(^Device, self, "device") } @(objc_type=SharedTextureHandle, objc_name="label") -SharedTextureHandle_label :: #force_inline proc(self: ^SharedTextureHandle) -> ^NS.String { +SharedTextureHandle_label :: #force_inline proc "c" (self: ^SharedTextureHandle) -> ^NS.String { return msgSend(^NS.String, self, "label") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - StageInputOutputDescriptor -Class Methods: - alloc - stageInputOutputDescriptor -Methods: - init - attributes - indexBufferIndex - indexType - layouts - reset - setIndexBufferIndex - setIndexType -*/ + @(objc_class="MTLStageInputOutputDescriptor") StageInputOutputDescriptor :: struct { using _: NS.Copying(StageInputOutputDescriptor) } @(objc_type=StageInputOutputDescriptor, objc_name="alloc", objc_is_class_method=true) -StageInputOutputDescriptor_alloc :: #force_inline proc() -> ^StageInputOutputDescriptor { +StageInputOutputDescriptor_alloc :: #force_inline proc "c" () -> ^StageInputOutputDescriptor { return msgSend(^StageInputOutputDescriptor, StageInputOutputDescriptor, "alloc") } @(objc_type=StageInputOutputDescriptor, objc_name="init") -StageInputOutputDescriptor_init :: #force_inline proc(self: ^StageInputOutputDescriptor) -> ^StageInputOutputDescriptor { +StageInputOutputDescriptor_init :: #force_inline proc "c" (self: ^StageInputOutputDescriptor) -> ^StageInputOutputDescriptor { return msgSend(^StageInputOutputDescriptor, self, "init") } @(objc_type=StageInputOutputDescriptor, objc_name="attributes") -StageInputOutputDescriptor_attributes :: #force_inline proc(self: ^StageInputOutputDescriptor) -> ^AttributeDescriptorArray { +StageInputOutputDescriptor_attributes :: #force_inline proc "c" (self: ^StageInputOutputDescriptor) -> ^AttributeDescriptorArray { return msgSend(^AttributeDescriptorArray, self, "attributes") } @(objc_type=StageInputOutputDescriptor, objc_name="indexBufferIndex") -StageInputOutputDescriptor_indexBufferIndex :: #force_inline proc(self: ^StageInputOutputDescriptor) -> NS.UInteger { +StageInputOutputDescriptor_indexBufferIndex :: #force_inline proc "c" (self: ^StageInputOutputDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "indexBufferIndex") } @(objc_type=StageInputOutputDescriptor, objc_name="indexType") -StageInputOutputDescriptor_indexType :: #force_inline proc(self: ^StageInputOutputDescriptor) -> IndexType { +StageInputOutputDescriptor_indexType :: #force_inline proc "c" (self: ^StageInputOutputDescriptor) -> IndexType { return msgSend(IndexType, self, "indexType") } @(objc_type=StageInputOutputDescriptor, objc_name="layouts") -StageInputOutputDescriptor_layouts :: #force_inline proc(self: ^StageInputOutputDescriptor) -> ^BufferLayoutDescriptorArray { +StageInputOutputDescriptor_layouts :: #force_inline proc "c" (self: ^StageInputOutputDescriptor) -> ^BufferLayoutDescriptorArray { return msgSend(^BufferLayoutDescriptorArray, self, "layouts") } @(objc_type=StageInputOutputDescriptor, objc_name="reset") -StageInputOutputDescriptor_reset :: #force_inline proc(self: ^StageInputOutputDescriptor) { +StageInputOutputDescriptor_reset :: #force_inline proc "c" (self: ^StageInputOutputDescriptor) { msgSend(nil, self, "reset") } @(objc_type=StageInputOutputDescriptor, objc_name="setIndexBufferIndex") -StageInputOutputDescriptor_setIndexBufferIndex :: #force_inline proc(self: ^StageInputOutputDescriptor, indexBufferIndex: NS.UInteger) { +StageInputOutputDescriptor_setIndexBufferIndex :: #force_inline proc "c" (self: ^StageInputOutputDescriptor, indexBufferIndex: NS.UInteger) { msgSend(nil, self, "setIndexBufferIndex:", indexBufferIndex) } @(objc_type=StageInputOutputDescriptor, objc_name="setIndexType") -StageInputOutputDescriptor_setIndexType :: #force_inline proc(self: ^StageInputOutputDescriptor, indexType: IndexType) { +StageInputOutputDescriptor_setIndexType :: #force_inline proc "c" (self: ^StageInputOutputDescriptor, indexType: IndexType) { msgSend(nil, self, "setIndexType:", indexType) } @(objc_type=StageInputOutputDescriptor, objc_name="stageInputOutputDescriptor", objc_is_class_method=true) -StageInputOutputDescriptor_stageInputOutputDescriptor :: #force_inline proc() -> ^StageInputOutputDescriptor { +StageInputOutputDescriptor_stageInputOutputDescriptor :: #force_inline proc "c" () -> ^StageInputOutputDescriptor { return msgSend(^StageInputOutputDescriptor, StageInputOutputDescriptor, "stageInputOutputDescriptor") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - StencilDescriptor -Class Methods: - alloc -Methods: - init - depthFailureOperation - depthStencilPassOperation - readMask - setDepthFailureOperation - setDepthStencilPassOperation - setReadMask - setStencilCompareFunction - setStencilFailureOperation - setWriteMask - stencilCompareFunction - stencilFailureOperation - writeMask -*/ + @(objc_class="MTLStencilDescriptor") StencilDescriptor :: struct { using _: NS.Copying(StencilDescriptor) } @(objc_type=StencilDescriptor, objc_name="alloc", objc_is_class_method=true) -StencilDescriptor_alloc :: #force_inline proc() -> ^StencilDescriptor { +StencilDescriptor_alloc :: #force_inline proc "c" () -> ^StencilDescriptor { return msgSend(^StencilDescriptor, StencilDescriptor, "alloc") } @(objc_type=StencilDescriptor, objc_name="init") -StencilDescriptor_init :: #force_inline proc(self: ^StencilDescriptor) -> ^StencilDescriptor { +StencilDescriptor_init :: #force_inline proc "c" (self: ^StencilDescriptor) -> ^StencilDescriptor { return msgSend(^StencilDescriptor, self, "init") } @(objc_type=StencilDescriptor, objc_name="depthFailureOperation") -StencilDescriptor_depthFailureOperation :: #force_inline proc(self: ^StencilDescriptor) -> StencilOperation { +StencilDescriptor_depthFailureOperation :: #force_inline proc "c" (self: ^StencilDescriptor) -> StencilOperation { return msgSend(StencilOperation, self, "depthFailureOperation") } @(objc_type=StencilDescriptor, objc_name="depthStencilPassOperation") -StencilDescriptor_depthStencilPassOperation :: #force_inline proc(self: ^StencilDescriptor) -> StencilOperation { +StencilDescriptor_depthStencilPassOperation :: #force_inline proc "c" (self: ^StencilDescriptor) -> StencilOperation { return msgSend(StencilOperation, self, "depthStencilPassOperation") } @(objc_type=StencilDescriptor, objc_name="readMask") -StencilDescriptor_readMask :: #force_inline proc(self: ^StencilDescriptor) -> u32 { +StencilDescriptor_readMask :: #force_inline proc "c" (self: ^StencilDescriptor) -> u32 { return msgSend(u32, self, "readMask") } @(objc_type=StencilDescriptor, objc_name="setDepthFailureOperation") -StencilDescriptor_setDepthFailureOperation :: #force_inline proc(self: ^StencilDescriptor, depthFailureOperation: StencilOperation) { +StencilDescriptor_setDepthFailureOperation :: #force_inline proc "c" (self: ^StencilDescriptor, depthFailureOperation: StencilOperation) { msgSend(nil, self, "setDepthFailureOperation:", depthFailureOperation) } @(objc_type=StencilDescriptor, objc_name="setDepthStencilPassOperation") -StencilDescriptor_setDepthStencilPassOperation :: #force_inline proc(self: ^StencilDescriptor, depthStencilPassOperation: StencilOperation) { +StencilDescriptor_setDepthStencilPassOperation :: #force_inline proc "c" (self: ^StencilDescriptor, depthStencilPassOperation: StencilOperation) { msgSend(nil, self, "setDepthStencilPassOperation:", depthStencilPassOperation) } @(objc_type=StencilDescriptor, objc_name="setReadMask") -StencilDescriptor_setReadMask :: #force_inline proc(self: ^StencilDescriptor, readMask: u32) { +StencilDescriptor_setReadMask :: #force_inline proc "c" (self: ^StencilDescriptor, readMask: u32) { msgSend(nil, self, "setReadMask:", readMask) } @(objc_type=StencilDescriptor, objc_name="setStencilCompareFunction") -StencilDescriptor_setStencilCompareFunction :: #force_inline proc(self: ^StencilDescriptor, stencilCompareFunction: CompareFunction) { +StencilDescriptor_setStencilCompareFunction :: #force_inline proc "c" (self: ^StencilDescriptor, stencilCompareFunction: CompareFunction) { msgSend(nil, self, "setStencilCompareFunction:", stencilCompareFunction) } @(objc_type=StencilDescriptor, objc_name="setStencilFailureOperation") -StencilDescriptor_setStencilFailureOperation :: #force_inline proc(self: ^StencilDescriptor, stencilFailureOperation: StencilOperation) { +StencilDescriptor_setStencilFailureOperation :: #force_inline proc "c" (self: ^StencilDescriptor, stencilFailureOperation: StencilOperation) { msgSend(nil, self, "setStencilFailureOperation:", stencilFailureOperation) } @(objc_type=StencilDescriptor, objc_name="setWriteMask") -StencilDescriptor_setWriteMask :: #force_inline proc(self: ^StencilDescriptor, writeMask: u32) { +StencilDescriptor_setWriteMask :: #force_inline proc "c" (self: ^StencilDescriptor, writeMask: u32) { msgSend(nil, self, "setWriteMask:", writeMask) } @(objc_type=StencilDescriptor, objc_name="stencilCompareFunction") -StencilDescriptor_stencilCompareFunction :: #force_inline proc(self: ^StencilDescriptor) -> CompareFunction { +StencilDescriptor_stencilCompareFunction :: #force_inline proc "c" (self: ^StencilDescriptor) -> CompareFunction { return msgSend(CompareFunction, self, "stencilCompareFunction") } @(objc_type=StencilDescriptor, objc_name="stencilFailureOperation") -StencilDescriptor_stencilFailureOperation :: #force_inline proc(self: ^StencilDescriptor) -> StencilOperation { +StencilDescriptor_stencilFailureOperation :: #force_inline proc "c" (self: ^StencilDescriptor) -> StencilOperation { return msgSend(StencilOperation, self, "stencilFailureOperation") } @(objc_type=StencilDescriptor, objc_name="writeMask") -StencilDescriptor_writeMask :: #force_inline proc(self: ^StencilDescriptor) -> u32 { +StencilDescriptor_writeMask :: #force_inline proc "c" (self: ^StencilDescriptor) -> u32 { return msgSend(u32, self, "writeMask") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - StructMember -Class Methods: - alloc -Methods: - init - argumentIndex - arrayType - dataType - name - offset - pointerType - structType - textureReferenceType -*/ + @(objc_class="MTLStructMember") StructMember :: struct { using _: NS.Object } @(objc_type=StructMember, objc_name="alloc", objc_is_class_method=true) -StructMember_alloc :: #force_inline proc() -> ^StructMember { +StructMember_alloc :: #force_inline proc "c" () -> ^StructMember { return msgSend(^StructMember, StructMember, "alloc") } @(objc_type=StructMember, objc_name="init") -StructMember_init :: #force_inline proc(self: ^StructMember) -> ^StructMember { +StructMember_init :: #force_inline proc "c" (self: ^StructMember) -> ^StructMember { return msgSend(^StructMember, self, "init") } @(objc_type=StructMember, objc_name="argumentIndex") -StructMember_argumentIndex :: #force_inline proc(self: ^StructMember) -> NS.UInteger { +StructMember_argumentIndex :: #force_inline proc "c" (self: ^StructMember) -> NS.UInteger { return msgSend(NS.UInteger, self, "argumentIndex") } @(objc_type=StructMember, objc_name="arrayType") -StructMember_arrayType :: #force_inline proc(self: ^StructMember) -> ^ArrayType { +StructMember_arrayType :: #force_inline proc "c" (self: ^StructMember) -> ^ArrayType { return msgSend(^ArrayType, self, "arrayType") } @(objc_type=StructMember, objc_name="dataType") -StructMember_dataType :: #force_inline proc(self: ^StructMember) -> DataType { +StructMember_dataType :: #force_inline proc "c" (self: ^StructMember) -> DataType { return msgSend(DataType, self, "dataType") } @(objc_type=StructMember, objc_name="name") -StructMember_name :: #force_inline proc(self: ^StructMember) -> ^NS.String { +StructMember_name :: #force_inline proc "c" (self: ^StructMember) -> ^NS.String { return msgSend(^NS.String, self, "name") } @(objc_type=StructMember, objc_name="offset") -StructMember_offset :: #force_inline proc(self: ^StructMember) -> NS.UInteger { +StructMember_offset :: #force_inline proc "c" (self: ^StructMember) -> NS.UInteger { return msgSend(NS.UInteger, self, "offset") } @(objc_type=StructMember, objc_name="pointerType") -StructMember_pointerType :: #force_inline proc(self: ^StructMember) -> ^PointerType { +StructMember_pointerType :: #force_inline proc "c" (self: ^StructMember) -> ^PointerType { return msgSend(^PointerType, self, "pointerType") } @(objc_type=StructMember, objc_name="structType") -StructMember_structType :: #force_inline proc(self: ^StructMember) -> ^StructType { +StructMember_structType :: #force_inline proc "c" (self: ^StructMember) -> ^StructType { return msgSend(^StructType, self, "structType") } @(objc_type=StructMember, objc_name="textureReferenceType") -StructMember_textureReferenceType :: #force_inline proc(self: ^StructMember) -> ^TextureReferenceType { +StructMember_textureReferenceType :: #force_inline proc "c" (self: ^StructMember) -> ^TextureReferenceType { return msgSend(^TextureReferenceType, self, "textureReferenceType") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - StructType -Class Methods: - alloc -Methods: - init - memberByName - members -*/ + @(objc_class="MTLStructType") StructType :: struct { using _: Type } @(objc_type=StructType, objc_name="alloc", objc_is_class_method=true) -StructType_alloc :: #force_inline proc() -> ^StructType { +StructType_alloc :: #force_inline proc "c" () -> ^StructType { return msgSend(^StructType, StructType, "alloc") } @(objc_type=StructType, objc_name="init") -StructType_init :: #force_inline proc(self: ^StructType) -> ^StructType { +StructType_init :: #force_inline proc "c" (self: ^StructType) -> ^StructType { return msgSend(^StructType, self, "init") } @(objc_type=StructType, objc_name="memberByName") -StructType_memberByName :: #force_inline proc(self: ^StructType, name: ^NS.String) -> ^StructMember { +StructType_memberByName :: #force_inline proc "c" (self: ^StructType, name: ^NS.String) -> ^StructMember { return msgSend(^StructMember, self, "memberByName:", name) } @(objc_type=StructType, objc_name="members") -StructType_members :: #force_inline proc(self: ^StructType) -> ^NS.Array { +StructType_members :: #force_inline proc "c" (self: ^StructType) -> ^NS.Array { return msgSend(^NS.Array, self, "members") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - TextureDescriptor -Class Methods: - alloc - texture2DDescriptorWithPixelFormat - textureBufferDescriptorWithPixelFormat - textureCubeDescriptorWithPixelFormat -Methods: - init - allowGPUOptimizedContents - arrayLength - cpuCacheMode - depth - hazardTrackingMode - height - mipmapLevelCount - pixelFormat - resourceOptions - sampleCount - setAllowGPUOptimizedContents - setArrayLength - setCpuCacheMode - setDepth - setHazardTrackingMode - setHeight - setMipmapLevelCount - setPixelFormat - setResourceOptions - setSampleCount - setStorageMode - setSwizzle - setTextureType - setUsage - setWidth - storageMode - swizzle - textureType - usage - width -*/ + @(objc_class="MTLTextureDescriptor") TextureDescriptor :: struct { using _: NS.Copying(TextureDescriptor) } @(objc_type=TextureDescriptor, objc_name="alloc", objc_is_class_method=true) -TextureDescriptor_alloc :: #force_inline proc() -> ^TextureDescriptor { +TextureDescriptor_alloc :: #force_inline proc "c" () -> ^TextureDescriptor { return msgSend(^TextureDescriptor, TextureDescriptor, "alloc") } @(objc_type=TextureDescriptor, objc_name="init") -TextureDescriptor_init :: #force_inline proc(self: ^TextureDescriptor) -> ^TextureDescriptor { +TextureDescriptor_init :: #force_inline proc "c" (self: ^TextureDescriptor) -> ^TextureDescriptor { return msgSend(^TextureDescriptor, self, "init") } @(objc_type=TextureDescriptor, objc_name="allowGPUOptimizedContents") -TextureDescriptor_allowGPUOptimizedContents :: #force_inline proc(self: ^TextureDescriptor) -> BOOL { +TextureDescriptor_allowGPUOptimizedContents :: #force_inline proc "c" (self: ^TextureDescriptor) -> BOOL { return msgSend(BOOL, self, "allowGPUOptimizedContents") } @(objc_type=TextureDescriptor, objc_name="arrayLength") -TextureDescriptor_arrayLength :: #force_inline proc(self: ^TextureDescriptor) -> NS.UInteger { +TextureDescriptor_arrayLength :: #force_inline proc "c" (self: ^TextureDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "arrayLength") } @(objc_type=TextureDescriptor, objc_name="cpuCacheMode") -TextureDescriptor_cpuCacheMode :: #force_inline proc(self: ^TextureDescriptor) -> CPUCacheMode { +TextureDescriptor_cpuCacheMode :: #force_inline proc "c" (self: ^TextureDescriptor) -> CPUCacheMode { return msgSend(CPUCacheMode, self, "cpuCacheMode") } @(objc_type=TextureDescriptor, objc_name="depth") -TextureDescriptor_depth :: #force_inline proc(self: ^TextureDescriptor) -> NS.UInteger { +TextureDescriptor_depth :: #force_inline proc "c" (self: ^TextureDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "depth") } @(objc_type=TextureDescriptor, objc_name="hazardTrackingMode") -TextureDescriptor_hazardTrackingMode :: #force_inline proc(self: ^TextureDescriptor) -> HazardTrackingMode { +TextureDescriptor_hazardTrackingMode :: #force_inline proc "c" (self: ^TextureDescriptor) -> HazardTrackingMode { return msgSend(HazardTrackingMode, self, "hazardTrackingMode") } @(objc_type=TextureDescriptor, objc_name="height") -TextureDescriptor_height :: #force_inline proc(self: ^TextureDescriptor) -> NS.UInteger { +TextureDescriptor_height :: #force_inline proc "c" (self: ^TextureDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "height") } @(objc_type=TextureDescriptor, objc_name="mipmapLevelCount") -TextureDescriptor_mipmapLevelCount :: #force_inline proc(self: ^TextureDescriptor) -> NS.UInteger { +TextureDescriptor_mipmapLevelCount :: #force_inline proc "c" (self: ^TextureDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "mipmapLevelCount") } @(objc_type=TextureDescriptor, objc_name="pixelFormat") -TextureDescriptor_pixelFormat :: #force_inline proc(self: ^TextureDescriptor) -> PixelFormat { +TextureDescriptor_pixelFormat :: #force_inline proc "c" (self: ^TextureDescriptor) -> PixelFormat { return msgSend(PixelFormat, self, "pixelFormat") } @(objc_type=TextureDescriptor, objc_name="resourceOptions") -TextureDescriptor_resourceOptions :: #force_inline proc(self: ^TextureDescriptor) -> ResourceOptions { +TextureDescriptor_resourceOptions :: #force_inline proc "c" (self: ^TextureDescriptor) -> ResourceOptions { return msgSend(ResourceOptions, self, "resourceOptions") } @(objc_type=TextureDescriptor, objc_name="sampleCount") -TextureDescriptor_sampleCount :: #force_inline proc(self: ^TextureDescriptor) -> NS.UInteger { +TextureDescriptor_sampleCount :: #force_inline proc "c" (self: ^TextureDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "sampleCount") } @(objc_type=TextureDescriptor, objc_name="setAllowGPUOptimizedContents") -TextureDescriptor_setAllowGPUOptimizedContents :: #force_inline proc(self: ^TextureDescriptor, allowGPUOptimizedContents: BOOL) { +TextureDescriptor_setAllowGPUOptimizedContents :: #force_inline proc "c" (self: ^TextureDescriptor, allowGPUOptimizedContents: BOOL) { msgSend(nil, self, "setAllowGPUOptimizedContents:", allowGPUOptimizedContents) } @(objc_type=TextureDescriptor, objc_name="setArrayLength") -TextureDescriptor_setArrayLength :: #force_inline proc(self: ^TextureDescriptor, arrayLength: NS.UInteger) { +TextureDescriptor_setArrayLength :: #force_inline proc "c" (self: ^TextureDescriptor, arrayLength: NS.UInteger) { msgSend(nil, self, "setArrayLength:", arrayLength) } @(objc_type=TextureDescriptor, objc_name="setCpuCacheMode") -TextureDescriptor_setCpuCacheMode :: #force_inline proc(self: ^TextureDescriptor, cpuCacheMode: CPUCacheMode) { +TextureDescriptor_setCpuCacheMode :: #force_inline proc "c" (self: ^TextureDescriptor, cpuCacheMode: CPUCacheMode) { msgSend(nil, self, "setCpuCacheMode:", cpuCacheMode) } @(objc_type=TextureDescriptor, objc_name="setDepth") -TextureDescriptor_setDepth :: #force_inline proc(self: ^TextureDescriptor, depth: NS.UInteger) { +TextureDescriptor_setDepth :: #force_inline proc "c" (self: ^TextureDescriptor, depth: NS.UInteger) { msgSend(nil, self, "setDepth:", depth) } @(objc_type=TextureDescriptor, objc_name="setHazardTrackingMode") -TextureDescriptor_setHazardTrackingMode :: #force_inline proc(self: ^TextureDescriptor, hazardTrackingMode: HazardTrackingMode) { +TextureDescriptor_setHazardTrackingMode :: #force_inline proc "c" (self: ^TextureDescriptor, hazardTrackingMode: HazardTrackingMode) { msgSend(nil, self, "setHazardTrackingMode:", hazardTrackingMode) } @(objc_type=TextureDescriptor, objc_name="setHeight") -TextureDescriptor_setHeight :: #force_inline proc(self: ^TextureDescriptor, height: NS.UInteger) { +TextureDescriptor_setHeight :: #force_inline proc "c" (self: ^TextureDescriptor, height: NS.UInteger) { msgSend(nil, self, "setHeight:", height) } @(objc_type=TextureDescriptor, objc_name="setMipmapLevelCount") -TextureDescriptor_setMipmapLevelCount :: #force_inline proc(self: ^TextureDescriptor, mipmapLevelCount: NS.UInteger) { +TextureDescriptor_setMipmapLevelCount :: #force_inline proc "c" (self: ^TextureDescriptor, mipmapLevelCount: NS.UInteger) { msgSend(nil, self, "setMipmapLevelCount:", mipmapLevelCount) } @(objc_type=TextureDescriptor, objc_name="setPixelFormat") -TextureDescriptor_setPixelFormat :: #force_inline proc(self: ^TextureDescriptor, pixelFormat: PixelFormat) { +TextureDescriptor_setPixelFormat :: #force_inline proc "c" (self: ^TextureDescriptor, pixelFormat: PixelFormat) { msgSend(nil, self, "setPixelFormat:", pixelFormat) } @(objc_type=TextureDescriptor, objc_name="setResourceOptions") -TextureDescriptor_setResourceOptions :: #force_inline proc(self: ^TextureDescriptor, resourceOptions: ResourceOptions) { +TextureDescriptor_setResourceOptions :: #force_inline proc "c" (self: ^TextureDescriptor, resourceOptions: ResourceOptions) { msgSend(nil, self, "setResourceOptions:", resourceOptions) } @(objc_type=TextureDescriptor, objc_name="setSampleCount") -TextureDescriptor_setSampleCount :: #force_inline proc(self: ^TextureDescriptor, sampleCount: NS.UInteger) { +TextureDescriptor_setSampleCount :: #force_inline proc "c" (self: ^TextureDescriptor, sampleCount: NS.UInteger) { msgSend(nil, self, "setSampleCount:", sampleCount) } @(objc_type=TextureDescriptor, objc_name="setStorageMode") -TextureDescriptor_setStorageMode :: #force_inline proc(self: ^TextureDescriptor, storageMode: StorageMode) { +TextureDescriptor_setStorageMode :: #force_inline proc "c" (self: ^TextureDescriptor, storageMode: StorageMode) { msgSend(nil, self, "setStorageMode:", storageMode) } @(objc_type=TextureDescriptor, objc_name="setSwizzle") -TextureDescriptor_setSwizzle :: #force_inline proc(self: ^TextureDescriptor, swizzle: TextureSwizzleChannels) { +TextureDescriptor_setSwizzle :: #force_inline proc "c" (self: ^TextureDescriptor, swizzle: TextureSwizzleChannels) { msgSend(nil, self, "setSwizzle:", swizzle) } @(objc_type=TextureDescriptor, objc_name="setTextureType") -TextureDescriptor_setTextureType :: #force_inline proc(self: ^TextureDescriptor, textureType: TextureType) { +TextureDescriptor_setTextureType :: #force_inline proc "c" (self: ^TextureDescriptor, textureType: TextureType) { msgSend(nil, self, "setTextureType:", textureType) } @(objc_type=TextureDescriptor, objc_name="setUsage") -TextureDescriptor_setUsage :: #force_inline proc(self: ^TextureDescriptor, usage: TextureUsage) { +TextureDescriptor_setUsage :: #force_inline proc "c" (self: ^TextureDescriptor, usage: TextureUsage) { msgSend(nil, self, "setUsage:", usage) } @(objc_type=TextureDescriptor, objc_name="setWidth") -TextureDescriptor_setWidth :: #force_inline proc(self: ^TextureDescriptor, width: NS.UInteger) { +TextureDescriptor_setWidth :: #force_inline proc "c" (self: ^TextureDescriptor, width: NS.UInteger) { msgSend(nil, self, "setWidth:", width) } @(objc_type=TextureDescriptor, objc_name="storageMode") -TextureDescriptor_storageMode :: #force_inline proc(self: ^TextureDescriptor) -> StorageMode { +TextureDescriptor_storageMode :: #force_inline proc "c" (self: ^TextureDescriptor) -> StorageMode { return msgSend(StorageMode, self, "storageMode") } @(objc_type=TextureDescriptor, objc_name="swizzle") -TextureDescriptor_swizzle :: #force_inline proc(self: ^TextureDescriptor) -> TextureSwizzleChannels { +TextureDescriptor_swizzle :: #force_inline proc "c" (self: ^TextureDescriptor) -> TextureSwizzleChannels { return msgSend(TextureSwizzleChannels, self, "swizzle") } @(objc_type=TextureDescriptor, objc_name="texture2DDescriptorWithPixelFormat", objc_is_class_method=true) -TextureDescriptor_texture2DDescriptorWithPixelFormat :: #force_inline proc(pixelFormat: PixelFormat, width: NS.UInteger, height: NS.UInteger, mipmapped: BOOL) -> ^TextureDescriptor { +TextureDescriptor_texture2DDescriptorWithPixelFormat :: #force_inline proc "c" (pixelFormat: PixelFormat, width: NS.UInteger, height: NS.UInteger, mipmapped: BOOL) -> ^TextureDescriptor { return msgSend(^TextureDescriptor, TextureDescriptor, "texture2DDescriptorWithPixelFormat:width:height:mipmapped:", pixelFormat, width, height, mipmapped) } @(objc_type=TextureDescriptor, objc_name="textureBufferDescriptorWithPixelFormat", objc_is_class_method=true) -TextureDescriptor_textureBufferDescriptorWithPixelFormat :: #force_inline proc(pixelFormat: PixelFormat, width: NS.UInteger, resourceOptions: ResourceOptions, usage: TextureUsage) -> ^TextureDescriptor { +TextureDescriptor_textureBufferDescriptorWithPixelFormat :: #force_inline proc "c" (pixelFormat: PixelFormat, width: NS.UInteger, resourceOptions: ResourceOptions, usage: TextureUsage) -> ^TextureDescriptor { return msgSend(^TextureDescriptor, TextureDescriptor, "textureBufferDescriptorWithPixelFormat:width:resourceOptions:usage:", pixelFormat, width, resourceOptions, usage) } @(objc_type=TextureDescriptor, objc_name="textureCubeDescriptorWithPixelFormat", objc_is_class_method=true) -TextureDescriptor_textureCubeDescriptorWithPixelFormat :: #force_inline proc(pixelFormat: PixelFormat, size: NS.UInteger, mipmapped: BOOL) -> ^TextureDescriptor { +TextureDescriptor_textureCubeDescriptorWithPixelFormat :: #force_inline proc "c" (pixelFormat: PixelFormat, size: NS.UInteger, mipmapped: BOOL) -> ^TextureDescriptor { return msgSend(^TextureDescriptor, TextureDescriptor, "textureCubeDescriptorWithPixelFormat:size:mipmapped:", pixelFormat, size, mipmapped) } @(objc_type=TextureDescriptor, objc_name="textureType") -TextureDescriptor_textureType :: #force_inline proc(self: ^TextureDescriptor) -> TextureType { +TextureDescriptor_textureType :: #force_inline proc "c" (self: ^TextureDescriptor) -> TextureType { return msgSend(TextureType, self, "textureType") } @(objc_type=TextureDescriptor, objc_name="usage") -TextureDescriptor_usage :: #force_inline proc(self: ^TextureDescriptor) -> TextureUsage { +TextureDescriptor_usage :: #force_inline proc "c" (self: ^TextureDescriptor) -> TextureUsage { return msgSend(TextureUsage, self, "usage") } @(objc_type=TextureDescriptor, objc_name="width") -TextureDescriptor_width :: #force_inline proc(self: ^TextureDescriptor) -> NS.UInteger { +TextureDescriptor_width :: #force_inline proc "c" (self: ^TextureDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "width") } +@(objc_type=TextureDescriptor, objc_name="compressionType") +TextureDescriptor_compressionType :: #force_inline proc "c" (self: ^TextureDescriptor) -> TextureCompressionType { + return msgSend(TextureCompressionType, self, "compressionType") +} +@(objc_type=TextureDescriptor, objc_name="setCompressionType") +TextureDescriptor_setCompressionType :: #force_inline proc "c" (self: ^TextureDescriptor, compressionType: TextureCompressionType) { + msgSend(nil, self, "setCompressionType:", compressionType) +} + //////////////////////////////////////////////////////////////////////////////// -/* -Class: - TextureReferenceType -Class Methods: - alloc -Methods: - init - access - isDepthTexture - textureDataType - textureType -*/ + @(objc_class="MTLTextureReferenceType") TextureReferenceType :: struct { using _: Type } @(objc_type=TextureReferenceType, objc_name="alloc", objc_is_class_method=true) -TextureReferenceType_alloc :: #force_inline proc() -> ^TextureReferenceType { +TextureReferenceType_alloc :: #force_inline proc "c" () -> ^TextureReferenceType { return msgSend(^TextureReferenceType, TextureReferenceType, "alloc") } @(objc_type=TextureReferenceType, objc_name="init") -TextureReferenceType_init :: #force_inline proc(self: ^TextureReferenceType) -> ^TextureReferenceType { +TextureReferenceType_init :: #force_inline proc "c" (self: ^TextureReferenceType) -> ^TextureReferenceType { return msgSend(^TextureReferenceType, self, "init") } @(objc_type=TextureReferenceType, objc_name="access") -TextureReferenceType_access :: #force_inline proc(self: ^TextureReferenceType) -> ArgumentAccess { +TextureReferenceType_access :: #force_inline proc "c" (self: ^TextureReferenceType) -> ArgumentAccess { return msgSend(ArgumentAccess, self, "access") } @(objc_type=TextureReferenceType, objc_name="isDepthTexture") -TextureReferenceType_isDepthTexture :: #force_inline proc(self: ^TextureReferenceType) -> BOOL { +TextureReferenceType_isDepthTexture :: #force_inline proc "c" (self: ^TextureReferenceType) -> BOOL { return msgSend(BOOL, self, "isDepthTexture") } @(objc_type=TextureReferenceType, objc_name="textureDataType") -TextureReferenceType_textureDataType :: #force_inline proc(self: ^TextureReferenceType) -> DataType { +TextureReferenceType_textureDataType :: #force_inline proc "c" (self: ^TextureReferenceType) -> DataType { return msgSend(DataType, self, "textureDataType") } @(objc_type=TextureReferenceType, objc_name="textureType") -TextureReferenceType_textureType :: #force_inline proc(self: ^TextureReferenceType) -> TextureType { +TextureReferenceType_textureType :: #force_inline proc "c" (self: ^TextureReferenceType) -> TextureType { return msgSend(TextureType, self, "textureType") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - TileRenderPipelineColorAttachmentDescriptor -Class Methods: - alloc -Methods: - init - pixelFormat - setPixelFormat -*/ + @(objc_class="MTLTileRenderPipelineColorAttachmentDescriptor") TileRenderPipelineColorAttachmentDescriptor :: struct { using _: NS.Copying(TileRenderPipelineColorAttachmentDescriptor) } @(objc_type=TileRenderPipelineColorAttachmentDescriptor, objc_name="alloc", objc_is_class_method=true) -TileRenderPipelineColorAttachmentDescriptor_alloc :: #force_inline proc() -> ^TileRenderPipelineColorAttachmentDescriptor { +TileRenderPipelineColorAttachmentDescriptor_alloc :: #force_inline proc "c" () -> ^TileRenderPipelineColorAttachmentDescriptor { return msgSend(^TileRenderPipelineColorAttachmentDescriptor, TileRenderPipelineColorAttachmentDescriptor, "alloc") } @(objc_type=TileRenderPipelineColorAttachmentDescriptor, objc_name="init") -TileRenderPipelineColorAttachmentDescriptor_init :: #force_inline proc(self: ^TileRenderPipelineColorAttachmentDescriptor) -> ^TileRenderPipelineColorAttachmentDescriptor { +TileRenderPipelineColorAttachmentDescriptor_init :: #force_inline proc "c" (self: ^TileRenderPipelineColorAttachmentDescriptor) -> ^TileRenderPipelineColorAttachmentDescriptor { return msgSend(^TileRenderPipelineColorAttachmentDescriptor, self, "init") } @(objc_type=TileRenderPipelineColorAttachmentDescriptor, objc_name="pixelFormat") -TileRenderPipelineColorAttachmentDescriptor_pixelFormat :: #force_inline proc(self: ^TileRenderPipelineColorAttachmentDescriptor) -> PixelFormat { +TileRenderPipelineColorAttachmentDescriptor_pixelFormat :: #force_inline proc "c" (self: ^TileRenderPipelineColorAttachmentDescriptor) -> PixelFormat { return msgSend(PixelFormat, self, "pixelFormat") } @(objc_type=TileRenderPipelineColorAttachmentDescriptor, objc_name="setPixelFormat") -TileRenderPipelineColorAttachmentDescriptor_setPixelFormat :: #force_inline proc(self: ^TileRenderPipelineColorAttachmentDescriptor, pixelFormat: PixelFormat) { +TileRenderPipelineColorAttachmentDescriptor_setPixelFormat :: #force_inline proc "c" (self: ^TileRenderPipelineColorAttachmentDescriptor, pixelFormat: PixelFormat) { msgSend(nil, self, "setPixelFormat:", pixelFormat) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - TileRenderPipelineColorAttachmentDescriptorArray -Class Methods: - alloc -Methods: - init - objectAtIndexedSubscript - setObject -*/ + @(objc_class="MTLTileRenderPipelineColorAttachmentDescriptorArray") TileRenderPipelineColorAttachmentDescriptorArray :: struct { using _: NS.Object } @(objc_type=TileRenderPipelineColorAttachmentDescriptorArray, objc_name="alloc", objc_is_class_method=true) -TileRenderPipelineColorAttachmentDescriptorArray_alloc :: #force_inline proc() -> ^TileRenderPipelineColorAttachmentDescriptorArray { +TileRenderPipelineColorAttachmentDescriptorArray_alloc :: #force_inline proc "c" () -> ^TileRenderPipelineColorAttachmentDescriptorArray { return msgSend(^TileRenderPipelineColorAttachmentDescriptorArray, TileRenderPipelineColorAttachmentDescriptorArray, "alloc") } @(objc_type=TileRenderPipelineColorAttachmentDescriptorArray, objc_name="init") -TileRenderPipelineColorAttachmentDescriptorArray_init :: #force_inline proc(self: ^TileRenderPipelineColorAttachmentDescriptorArray) -> ^TileRenderPipelineColorAttachmentDescriptorArray { +TileRenderPipelineColorAttachmentDescriptorArray_init :: #force_inline proc "c" (self: ^TileRenderPipelineColorAttachmentDescriptorArray) -> ^TileRenderPipelineColorAttachmentDescriptorArray { return msgSend(^TileRenderPipelineColorAttachmentDescriptorArray, self, "init") } @(objc_type=TileRenderPipelineColorAttachmentDescriptorArray, objc_name="object") -TileRenderPipelineColorAttachmentDescriptorArray_object :: #force_inline proc(self: ^TileRenderPipelineColorAttachmentDescriptorArray, attachmentIndex: NS.UInteger) -> ^TileRenderPipelineColorAttachmentDescriptor { +TileRenderPipelineColorAttachmentDescriptorArray_object :: #force_inline proc "c" (self: ^TileRenderPipelineColorAttachmentDescriptorArray, attachmentIndex: NS.UInteger) -> ^TileRenderPipelineColorAttachmentDescriptor { return msgSend(^TileRenderPipelineColorAttachmentDescriptor, self, "objectAtIndexedSubscript:", attachmentIndex) } @(objc_type=TileRenderPipelineColorAttachmentDescriptorArray, objc_name="setObject") -TileRenderPipelineColorAttachmentDescriptorArray_setObject :: #force_inline proc(self: ^TileRenderPipelineColorAttachmentDescriptorArray, attachment: ^TileRenderPipelineColorAttachmentDescriptor, attachmentIndex: NS.UInteger) { +TileRenderPipelineColorAttachmentDescriptorArray_setObject :: #force_inline proc "c" (self: ^TileRenderPipelineColorAttachmentDescriptorArray, attachment: ^TileRenderPipelineColorAttachmentDescriptor, attachmentIndex: NS.UInteger) { msgSend(nil, self, "setObject:atIndexedSubscript:", attachment, attachmentIndex) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - TileRenderPipelineDescriptor -Class Methods: - alloc -Methods: - init - binaryArchives - colorAttachments - label - maxTotalThreadsPerThreadgroup - rasterSampleCount - reset - setBinaryArchives - setLabel - setMaxTotalThreadsPerThreadgroup - setRasterSampleCount - setThreadgroupSizeMatchesTileSize - setTileFunction - threadgroupSizeMatchesTileSize - tileBuffers - tileFunction -*/ + @(objc_class="MTLTileRenderPipelineDescriptor") TileRenderPipelineDescriptor :: struct { using _: NS.Copying(TileRenderPipelineDescriptor) } @(objc_type=TileRenderPipelineDescriptor, objc_name="alloc", objc_is_class_method=true) -TileRenderPipelineDescriptor_alloc :: #force_inline proc() -> ^TileRenderPipelineDescriptor { +TileRenderPipelineDescriptor_alloc :: #force_inline proc "c" () -> ^TileRenderPipelineDescriptor { return msgSend(^TileRenderPipelineDescriptor, TileRenderPipelineDescriptor, "alloc") } @(objc_type=TileRenderPipelineDescriptor, objc_name="init") -TileRenderPipelineDescriptor_init :: #force_inline proc(self: ^TileRenderPipelineDescriptor) -> ^TileRenderPipelineDescriptor { +TileRenderPipelineDescriptor_init :: #force_inline proc "c" (self: ^TileRenderPipelineDescriptor) -> ^TileRenderPipelineDescriptor { return msgSend(^TileRenderPipelineDescriptor, self, "init") } @(objc_type=TileRenderPipelineDescriptor, objc_name="binaryArchives") -TileRenderPipelineDescriptor_binaryArchives :: #force_inline proc(self: ^TileRenderPipelineDescriptor) -> ^NS.Array { +TileRenderPipelineDescriptor_binaryArchives :: #force_inline proc "c" (self: ^TileRenderPipelineDescriptor) -> ^NS.Array { return msgSend(^NS.Array, self, "binaryArchives") } @(objc_type=TileRenderPipelineDescriptor, objc_name="colorAttachments") -TileRenderPipelineDescriptor_colorAttachments :: #force_inline proc(self: ^TileRenderPipelineDescriptor) -> ^TileRenderPipelineColorAttachmentDescriptorArray { +TileRenderPipelineDescriptor_colorAttachments :: #force_inline proc "c" (self: ^TileRenderPipelineDescriptor) -> ^TileRenderPipelineColorAttachmentDescriptorArray { return msgSend(^TileRenderPipelineColorAttachmentDescriptorArray, self, "colorAttachments") } @(objc_type=TileRenderPipelineDescriptor, objc_name="label") -TileRenderPipelineDescriptor_label :: #force_inline proc(self: ^TileRenderPipelineDescriptor) -> ^NS.String { +TileRenderPipelineDescriptor_label :: #force_inline proc "c" (self: ^TileRenderPipelineDescriptor) -> ^NS.String { return msgSend(^NS.String, self, "label") } @(objc_type=TileRenderPipelineDescriptor, objc_name="maxTotalThreadsPerThreadgroup") -TileRenderPipelineDescriptor_maxTotalThreadsPerThreadgroup :: #force_inline proc(self: ^TileRenderPipelineDescriptor) -> NS.UInteger { +TileRenderPipelineDescriptor_maxTotalThreadsPerThreadgroup :: #force_inline proc "c" (self: ^TileRenderPipelineDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "maxTotalThreadsPerThreadgroup") } @(objc_type=TileRenderPipelineDescriptor, objc_name="rasterSampleCount") -TileRenderPipelineDescriptor_rasterSampleCount :: #force_inline proc(self: ^TileRenderPipelineDescriptor) -> NS.UInteger { +TileRenderPipelineDescriptor_rasterSampleCount :: #force_inline proc "c" (self: ^TileRenderPipelineDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "rasterSampleCount") } @(objc_type=TileRenderPipelineDescriptor, objc_name="reset") -TileRenderPipelineDescriptor_reset :: #force_inline proc(self: ^TileRenderPipelineDescriptor) { +TileRenderPipelineDescriptor_reset :: #force_inline proc "c" (self: ^TileRenderPipelineDescriptor) { msgSend(nil, self, "reset") } @(objc_type=TileRenderPipelineDescriptor, objc_name="setBinaryArchives") -TileRenderPipelineDescriptor_setBinaryArchives :: #force_inline proc(self: ^TileRenderPipelineDescriptor, binaryArchives: ^NS.Array) { +TileRenderPipelineDescriptor_setBinaryArchives :: #force_inline proc "c" (self: ^TileRenderPipelineDescriptor, binaryArchives: ^NS.Array) { msgSend(nil, self, "setBinaryArchives:", binaryArchives) } @(objc_type=TileRenderPipelineDescriptor, objc_name="setLabel") -TileRenderPipelineDescriptor_setLabel :: #force_inline proc(self: ^TileRenderPipelineDescriptor, label: ^NS.String) { +TileRenderPipelineDescriptor_setLabel :: #force_inline proc "c" (self: ^TileRenderPipelineDescriptor, label: ^NS.String) { msgSend(nil, self, "setLabel:", label) } @(objc_type=TileRenderPipelineDescriptor, objc_name="setMaxTotalThreadsPerThreadgroup") -TileRenderPipelineDescriptor_setMaxTotalThreadsPerThreadgroup :: #force_inline proc(self: ^TileRenderPipelineDescriptor, maxTotalThreadsPerThreadgroup: NS.UInteger) { +TileRenderPipelineDescriptor_setMaxTotalThreadsPerThreadgroup :: #force_inline proc "c" (self: ^TileRenderPipelineDescriptor, maxTotalThreadsPerThreadgroup: NS.UInteger) { msgSend(nil, self, "setMaxTotalThreadsPerThreadgroup:", maxTotalThreadsPerThreadgroup) } @(objc_type=TileRenderPipelineDescriptor, objc_name="setRasterSampleCount") -TileRenderPipelineDescriptor_setRasterSampleCount :: #force_inline proc(self: ^TileRenderPipelineDescriptor, rasterSampleCount: NS.UInteger) { +TileRenderPipelineDescriptor_setRasterSampleCount :: #force_inline proc "c" (self: ^TileRenderPipelineDescriptor, rasterSampleCount: NS.UInteger) { msgSend(nil, self, "setRasterSampleCount:", rasterSampleCount) } @(objc_type=TileRenderPipelineDescriptor, objc_name="setThreadgroupSizeMatchesTileSize") -TileRenderPipelineDescriptor_setThreadgroupSizeMatchesTileSize :: #force_inline proc(self: ^TileRenderPipelineDescriptor, threadgroupSizeMatchesTileSize: BOOL) { +TileRenderPipelineDescriptor_setThreadgroupSizeMatchesTileSize :: #force_inline proc "c" (self: ^TileRenderPipelineDescriptor, threadgroupSizeMatchesTileSize: BOOL) { msgSend(nil, self, "setThreadgroupSizeMatchesTileSize:", threadgroupSizeMatchesTileSize) } @(objc_type=TileRenderPipelineDescriptor, objc_name="setTileFunction") -TileRenderPipelineDescriptor_setTileFunction :: #force_inline proc(self: ^TileRenderPipelineDescriptor, tileFunction: ^Function) { +TileRenderPipelineDescriptor_setTileFunction :: #force_inline proc "c" (self: ^TileRenderPipelineDescriptor, tileFunction: ^Function) { msgSend(nil, self, "setTileFunction:", tileFunction) } @(objc_type=TileRenderPipelineDescriptor, objc_name="threadgroupSizeMatchesTileSize") -TileRenderPipelineDescriptor_threadgroupSizeMatchesTileSize :: #force_inline proc(self: ^TileRenderPipelineDescriptor) -> BOOL { +TileRenderPipelineDescriptor_threadgroupSizeMatchesTileSize :: #force_inline proc "c" (self: ^TileRenderPipelineDescriptor) -> BOOL { return msgSend(BOOL, self, "threadgroupSizeMatchesTileSize") } @(objc_type=TileRenderPipelineDescriptor, objc_name="tileBuffers") -TileRenderPipelineDescriptor_tileBuffers :: #force_inline proc(self: ^TileRenderPipelineDescriptor) -> ^PipelineBufferDescriptorArray { +TileRenderPipelineDescriptor_tileBuffers :: #force_inline proc "c" (self: ^TileRenderPipelineDescriptor) -> ^PipelineBufferDescriptorArray { return msgSend(^PipelineBufferDescriptorArray, self, "tileBuffers") } @(objc_type=TileRenderPipelineDescriptor, objc_name="tileFunction") -TileRenderPipelineDescriptor_tileFunction :: #force_inline proc(self: ^TileRenderPipelineDescriptor) -> ^Function { +TileRenderPipelineDescriptor_tileFunction :: #force_inline proc "c" (self: ^TileRenderPipelineDescriptor) -> ^Function { return msgSend(^Function, self, "tileFunction") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - Type -Class Methods: - alloc -Methods: - init - dataType -*/ + @(objc_class="MTLType") Type :: struct { using _: NS.Object } @(objc_type=Type, objc_name="alloc", objc_is_class_method=true) -Type_alloc :: #force_inline proc() -> ^Type { +Type_alloc :: #force_inline proc "c" () -> ^Type { return msgSend(^Type, Type, "alloc") } @(objc_type=Type, objc_name="init") -Type_init :: #force_inline proc(self: ^Type) -> ^Type { +Type_init :: #force_inline proc "c" (self: ^Type) -> ^Type { return msgSend(^Type, self, "init") } @(objc_type=Type, objc_name="dataType") -Type_dataType :: #force_inline proc(self: ^Type) -> DataType { +Type_dataType :: #force_inline proc "c" (self: ^Type) -> DataType { return msgSend(DataType, self, "dataType") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - VertexAttribute -Class Methods: - alloc -Methods: - init - attributeIndex - attributeType - isActive - isPatchControlPointData - isPatchData - name -*/ + @(objc_class="MTLVertexAttribute") VertexAttribute :: struct { using _: NS.Object } @(objc_type=VertexAttribute, objc_name="alloc", objc_is_class_method=true) -VertexAttribute_alloc :: #force_inline proc() -> ^VertexAttribute { +VertexAttribute_alloc :: #force_inline proc "c" () -> ^VertexAttribute { return msgSend(^VertexAttribute, VertexAttribute, "alloc") } @(objc_type=VertexAttribute, objc_name="init") -VertexAttribute_init :: #force_inline proc(self: ^VertexAttribute) -> ^VertexAttribute { +VertexAttribute_init :: #force_inline proc "c" (self: ^VertexAttribute) -> ^VertexAttribute { return msgSend(^VertexAttribute, self, "init") } @(objc_type=VertexAttribute, objc_name="attributeIndex") -VertexAttribute_attributeIndex :: #force_inline proc(self: ^VertexAttribute) -> NS.UInteger { +VertexAttribute_attributeIndex :: #force_inline proc "c" (self: ^VertexAttribute) -> NS.UInteger { return msgSend(NS.UInteger, self, "attributeIndex") } @(objc_type=VertexAttribute, objc_name="attributeType") -VertexAttribute_attributeType :: #force_inline proc(self: ^VertexAttribute) -> DataType { +VertexAttribute_attributeType :: #force_inline proc "c" (self: ^VertexAttribute) -> DataType { return msgSend(DataType, self, "attributeType") } @(objc_type=VertexAttribute, objc_name="isActive") -VertexAttribute_isActive :: #force_inline proc(self: ^VertexAttribute) -> BOOL { +VertexAttribute_isActive :: #force_inline proc "c" (self: ^VertexAttribute) -> BOOL { return msgSend(BOOL, self, "isActive") } @(objc_type=VertexAttribute, objc_name="isPatchControlPointData") -VertexAttribute_isPatchControlPointData :: #force_inline proc(self: ^VertexAttribute) -> BOOL { +VertexAttribute_isPatchControlPointData :: #force_inline proc "c" (self: ^VertexAttribute) -> BOOL { return msgSend(BOOL, self, "isPatchControlPointData") } @(objc_type=VertexAttribute, objc_name="isPatchData") -VertexAttribute_isPatchData :: #force_inline proc(self: ^VertexAttribute) -> BOOL { +VertexAttribute_isPatchData :: #force_inline proc "c" (self: ^VertexAttribute) -> BOOL { return msgSend(BOOL, self, "isPatchData") } @(objc_type=VertexAttribute, objc_name="name") -VertexAttribute_name :: #force_inline proc(self: ^VertexAttribute) -> ^NS.String { +VertexAttribute_name :: #force_inline proc "c" (self: ^VertexAttribute) -> ^NS.String { return msgSend(^NS.String, self, "name") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - VertexAttributeDescriptor -Class Methods: - alloc -Methods: - init - bufferIndex - format - offset - setBufferIndex - setFormat - setOffset -*/ + @(objc_class="MTLVertexAttributeDescriptor") VertexAttributeDescriptor :: struct { using _: NS.Copying(VertexAttributeDescriptor) } @(objc_type=VertexAttributeDescriptor, objc_name="alloc", objc_is_class_method=true) -VertexAttributeDescriptor_alloc :: #force_inline proc() -> ^VertexAttributeDescriptor { +VertexAttributeDescriptor_alloc :: #force_inline proc "c" () -> ^VertexAttributeDescriptor { return msgSend(^VertexAttributeDescriptor, VertexAttributeDescriptor, "alloc") } @(objc_type=VertexAttributeDescriptor, objc_name="init") -VertexAttributeDescriptor_init :: #force_inline proc(self: ^VertexAttributeDescriptor) -> ^VertexAttributeDescriptor { +VertexAttributeDescriptor_init :: #force_inline proc "c" (self: ^VertexAttributeDescriptor) -> ^VertexAttributeDescriptor { return msgSend(^VertexAttributeDescriptor, self, "init") } @(objc_type=VertexAttributeDescriptor, objc_name="bufferIndex") -VertexAttributeDescriptor_bufferIndex :: #force_inline proc(self: ^VertexAttributeDescriptor) -> NS.UInteger { +VertexAttributeDescriptor_bufferIndex :: #force_inline proc "c" (self: ^VertexAttributeDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "bufferIndex") } @(objc_type=VertexAttributeDescriptor, objc_name="format") -VertexAttributeDescriptor_format :: #force_inline proc(self: ^VertexAttributeDescriptor) -> VertexFormat { +VertexAttributeDescriptor_format :: #force_inline proc "c" (self: ^VertexAttributeDescriptor) -> VertexFormat { return msgSend(VertexFormat, self, "format") } @(objc_type=VertexAttributeDescriptor, objc_name="offset") -VertexAttributeDescriptor_offset :: #force_inline proc(self: ^VertexAttributeDescriptor) -> NS.UInteger { +VertexAttributeDescriptor_offset :: #force_inline proc "c" (self: ^VertexAttributeDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "offset") } @(objc_type=VertexAttributeDescriptor, objc_name="setBufferIndex") -VertexAttributeDescriptor_setBufferIndex :: #force_inline proc(self: ^VertexAttributeDescriptor, bufferIndex: NS.UInteger) { +VertexAttributeDescriptor_setBufferIndex :: #force_inline proc "c" (self: ^VertexAttributeDescriptor, bufferIndex: NS.UInteger) { msgSend(nil, self, "setBufferIndex:", bufferIndex) } @(objc_type=VertexAttributeDescriptor, objc_name="setFormat") -VertexAttributeDescriptor_setFormat :: #force_inline proc(self: ^VertexAttributeDescriptor, format: VertexFormat) { +VertexAttributeDescriptor_setFormat :: #force_inline proc "c" (self: ^VertexAttributeDescriptor, format: VertexFormat) { msgSend(nil, self, "setFormat:", format) } @(objc_type=VertexAttributeDescriptor, objc_name="setOffset") -VertexAttributeDescriptor_setOffset :: #force_inline proc(self: ^VertexAttributeDescriptor, offset: NS.UInteger) { +VertexAttributeDescriptor_setOffset :: #force_inline proc "c" (self: ^VertexAttributeDescriptor, offset: NS.UInteger) { msgSend(nil, self, "setOffset:", offset) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - VertexAttributeDescriptorArray -Class Methods: - alloc -Methods: - init - objectAtIndexedSubscript - setObject -*/ + @(objc_class="MTLVertexAttributeDescriptorArray") VertexAttributeDescriptorArray :: struct { using _: NS.Object } @(objc_type=VertexAttributeDescriptorArray, objc_name="alloc", objc_is_class_method=true) -VertexAttributeDescriptorArray_alloc :: #force_inline proc() -> ^VertexAttributeDescriptorArray { +VertexAttributeDescriptorArray_alloc :: #force_inline proc "c" () -> ^VertexAttributeDescriptorArray { return msgSend(^VertexAttributeDescriptorArray, VertexAttributeDescriptorArray, "alloc") } @(objc_type=VertexAttributeDescriptorArray, objc_name="init") -VertexAttributeDescriptorArray_init :: #force_inline proc(self: ^VertexAttributeDescriptorArray) -> ^VertexAttributeDescriptorArray { +VertexAttributeDescriptorArray_init :: #force_inline proc "c" (self: ^VertexAttributeDescriptorArray) -> ^VertexAttributeDescriptorArray { return msgSend(^VertexAttributeDescriptorArray, self, "init") } @(objc_type=VertexAttributeDescriptorArray, objc_name="object") -VertexAttributeDescriptorArray_object :: #force_inline proc(self: ^VertexAttributeDescriptorArray, index: NS.UInteger) -> ^VertexAttributeDescriptor { +VertexAttributeDescriptorArray_object :: #force_inline proc "c" (self: ^VertexAttributeDescriptorArray, index: NS.UInteger) -> ^VertexAttributeDescriptor { return msgSend(^VertexAttributeDescriptor, self, "objectAtIndexedSubscript:", index) } @(objc_type=VertexAttributeDescriptorArray, objc_name="setObject") -VertexAttributeDescriptorArray_setObject :: #force_inline proc(self: ^VertexAttributeDescriptorArray, attributeDesc: ^VertexAttributeDescriptor, index: NS.UInteger) { +VertexAttributeDescriptorArray_setObject :: #force_inline proc "c" (self: ^VertexAttributeDescriptorArray, attributeDesc: ^VertexAttributeDescriptor, index: NS.UInteger) { msgSend(nil, self, "setObject:atIndexedSubscript:", attributeDesc, index) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - VertexBufferLayoutDescriptor -Class Methods: - alloc -Methods: - init - setStepFunction - setStepRate - setStride - stepFunction - stepRate - stride -*/ + @(objc_class="MTLVertexBufferLayoutDescriptor") VertexBufferLayoutDescriptor :: struct { using _: NS.Copying(VertexBufferLayoutDescriptor) } @(objc_type=VertexBufferLayoutDescriptor, objc_name="alloc", objc_is_class_method=true) -VertexBufferLayoutDescriptor_alloc :: #force_inline proc() -> ^VertexBufferLayoutDescriptor { +VertexBufferLayoutDescriptor_alloc :: #force_inline proc "c" () -> ^VertexBufferLayoutDescriptor { return msgSend(^VertexBufferLayoutDescriptor, VertexBufferLayoutDescriptor, "alloc") } @(objc_type=VertexBufferLayoutDescriptor, objc_name="init") -VertexBufferLayoutDescriptor_init :: #force_inline proc(self: ^VertexBufferLayoutDescriptor) -> ^VertexBufferLayoutDescriptor { +VertexBufferLayoutDescriptor_init :: #force_inline proc "c" (self: ^VertexBufferLayoutDescriptor) -> ^VertexBufferLayoutDescriptor { return msgSend(^VertexBufferLayoutDescriptor, self, "init") } @(objc_type=VertexBufferLayoutDescriptor, objc_name="setStepFunction") -VertexBufferLayoutDescriptor_setStepFunction :: #force_inline proc(self: ^VertexBufferLayoutDescriptor, stepFunction: VertexStepFunction) { +VertexBufferLayoutDescriptor_setStepFunction :: #force_inline proc "c" (self: ^VertexBufferLayoutDescriptor, stepFunction: VertexStepFunction) { msgSend(nil, self, "setStepFunction:", stepFunction) } @(objc_type=VertexBufferLayoutDescriptor, objc_name="setStepRate") -VertexBufferLayoutDescriptor_setStepRate :: #force_inline proc(self: ^VertexBufferLayoutDescriptor, stepRate: NS.UInteger) { +VertexBufferLayoutDescriptor_setStepRate :: #force_inline proc "c" (self: ^VertexBufferLayoutDescriptor, stepRate: NS.UInteger) { msgSend(nil, self, "setStepRate:", stepRate) } @(objc_type=VertexBufferLayoutDescriptor, objc_name="setStride") -VertexBufferLayoutDescriptor_setStride :: #force_inline proc(self: ^VertexBufferLayoutDescriptor, stride: NS.UInteger) { +VertexBufferLayoutDescriptor_setStride :: #force_inline proc "c" (self: ^VertexBufferLayoutDescriptor, stride: NS.UInteger) { msgSend(nil, self, "setStride:", stride) } @(objc_type=VertexBufferLayoutDescriptor, objc_name="stepFunction") -VertexBufferLayoutDescriptor_stepFunction :: #force_inline proc(self: ^VertexBufferLayoutDescriptor) -> VertexStepFunction { +VertexBufferLayoutDescriptor_stepFunction :: #force_inline proc "c" (self: ^VertexBufferLayoutDescriptor) -> VertexStepFunction { return msgSend(VertexStepFunction, self, "stepFunction") } @(objc_type=VertexBufferLayoutDescriptor, objc_name="stepRate") -VertexBufferLayoutDescriptor_stepRate :: #force_inline proc(self: ^VertexBufferLayoutDescriptor) -> NS.UInteger { +VertexBufferLayoutDescriptor_stepRate :: #force_inline proc "c" (self: ^VertexBufferLayoutDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "stepRate") } @(objc_type=VertexBufferLayoutDescriptor, objc_name="stride") -VertexBufferLayoutDescriptor_stride :: #force_inline proc(self: ^VertexBufferLayoutDescriptor) -> NS.UInteger { +VertexBufferLayoutDescriptor_stride :: #force_inline proc "c" (self: ^VertexBufferLayoutDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "stride") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - VertexBufferLayoutDescriptorArray -Class Methods: - alloc -Methods: - init - objectAtIndexedSubscript - setObject -*/ @(objc_class="MTLVertexBufferLayoutDescriptorArray") VertexBufferLayoutDescriptorArray :: struct { using _: NS.Object } @(objc_type=VertexBufferLayoutDescriptorArray, objc_name="alloc", objc_is_class_method=true) -VertexBufferLayoutDescriptorArray_alloc :: #force_inline proc() -> ^VertexBufferLayoutDescriptorArray { +VertexBufferLayoutDescriptorArray_alloc :: #force_inline proc "c" () -> ^VertexBufferLayoutDescriptorArray { return msgSend(^VertexBufferLayoutDescriptorArray, VertexBufferLayoutDescriptorArray, "alloc") } @(objc_type=VertexBufferLayoutDescriptorArray, objc_name="init") -VertexBufferLayoutDescriptorArray_init :: #force_inline proc(self: ^VertexBufferLayoutDescriptorArray) -> ^VertexBufferLayoutDescriptorArray { +VertexBufferLayoutDescriptorArray_init :: #force_inline proc "c" (self: ^VertexBufferLayoutDescriptorArray) -> ^VertexBufferLayoutDescriptorArray { return msgSend(^VertexBufferLayoutDescriptorArray, self, "init") } @(objc_type=VertexBufferLayoutDescriptorArray, objc_name="object") -VertexBufferLayoutDescriptorArray_object :: #force_inline proc(self: ^VertexBufferLayoutDescriptorArray, index: NS.UInteger) -> ^VertexBufferLayoutDescriptor { +VertexBufferLayoutDescriptorArray_object :: #force_inline proc "c" (self: ^VertexBufferLayoutDescriptorArray, index: NS.UInteger) -> ^VertexBufferLayoutDescriptor { return msgSend(^VertexBufferLayoutDescriptor, self, "objectAtIndexedSubscript:", index) } @(objc_type=VertexBufferLayoutDescriptorArray, objc_name="setObject") -VertexBufferLayoutDescriptorArray_setObject :: #force_inline proc(self: ^VertexBufferLayoutDescriptorArray, bufferDesc: ^VertexBufferLayoutDescriptor, index: NS.UInteger) { +VertexBufferLayoutDescriptorArray_setObject :: #force_inline proc "c" (self: ^VertexBufferLayoutDescriptorArray, bufferDesc: ^VertexBufferLayoutDescriptor, index: NS.UInteger) { msgSend(nil, self, "setObject:atIndexedSubscript:", bufferDesc, index) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - VertexDescriptor -Class Methods: - alloc - vertexDescriptor -Methods: - init - attributes - layouts - reset -*/ @(objc_class="MTLVertexDescriptor") VertexDescriptor :: struct { using _: NS.Copying(VertexDescriptor) } @(objc_type=VertexDescriptor, objc_name="alloc", objc_is_class_method=true) -VertexDescriptor_alloc :: #force_inline proc() -> ^VertexDescriptor { +VertexDescriptor_alloc :: #force_inline proc "c" () -> ^VertexDescriptor { return msgSend(^VertexDescriptor, VertexDescriptor, "alloc") } @(objc_type=VertexDescriptor, objc_name="init") -VertexDescriptor_init :: #force_inline proc(self: ^VertexDescriptor) -> ^VertexDescriptor { +VertexDescriptor_init :: #force_inline proc "c" (self: ^VertexDescriptor) -> ^VertexDescriptor { return msgSend(^VertexDescriptor, self, "init") } @(objc_type=VertexDescriptor, objc_name="attributes") -VertexDescriptor_attributes :: #force_inline proc(self: ^VertexDescriptor) -> ^VertexAttributeDescriptorArray { +VertexDescriptor_attributes :: #force_inline proc "c" (self: ^VertexDescriptor) -> ^VertexAttributeDescriptorArray { return msgSend(^VertexAttributeDescriptorArray, self, "attributes") } @(objc_type=VertexDescriptor, objc_name="layouts") -VertexDescriptor_layouts :: #force_inline proc(self: ^VertexDescriptor) -> ^VertexBufferLayoutDescriptorArray { +VertexDescriptor_layouts :: #force_inline proc "c" (self: ^VertexDescriptor) -> ^VertexBufferLayoutDescriptorArray { return msgSend(^VertexBufferLayoutDescriptorArray, self, "layouts") } @(objc_type=VertexDescriptor, objc_name="reset") -VertexDescriptor_reset :: #force_inline proc(self: ^VertexDescriptor) { +VertexDescriptor_reset :: #force_inline proc "c" (self: ^VertexDescriptor) { msgSend(nil, self, "reset") } @(objc_type=VertexDescriptor, objc_name="vertexDescriptor", objc_is_class_method=true) -VertexDescriptor_vertexDescriptor :: #force_inline proc() -> ^VertexDescriptor { +VertexDescriptor_vertexDescriptor :: #force_inline proc "c" () -> ^VertexDescriptor { return msgSend(^VertexDescriptor, VertexDescriptor, "vertexDescriptor") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - VisibleFunctionTableDescriptor -Class Methods: - alloc - visibleFunctionTableDescriptor -Methods: - init - functionCount - setFunctionCount -*/ + @(objc_class="MTLVisibleFunctionTableDescriptor") VisibleFunctionTableDescriptor :: struct { using _: NS.Copying(VisibleFunctionTableDescriptor) } @(objc_type=VisibleFunctionTableDescriptor, objc_name="alloc", objc_is_class_method=true) -VisibleFunctionTableDescriptor_alloc :: #force_inline proc() -> ^VisibleFunctionTableDescriptor { +VisibleFunctionTableDescriptor_alloc :: #force_inline proc "c" () -> ^VisibleFunctionTableDescriptor { return msgSend(^VisibleFunctionTableDescriptor, VisibleFunctionTableDescriptor, "alloc") } @(objc_type=VisibleFunctionTableDescriptor, objc_name="init") -VisibleFunctionTableDescriptor_init :: #force_inline proc(self: ^VisibleFunctionTableDescriptor) -> ^VisibleFunctionTableDescriptor { +VisibleFunctionTableDescriptor_init :: #force_inline proc "c" (self: ^VisibleFunctionTableDescriptor) -> ^VisibleFunctionTableDescriptor { return msgSend(^VisibleFunctionTableDescriptor, self, "init") } @(objc_type=VisibleFunctionTableDescriptor, objc_name="functionCount") -VisibleFunctionTableDescriptor_functionCount :: #force_inline proc(self: ^VisibleFunctionTableDescriptor) -> NS.UInteger { +VisibleFunctionTableDescriptor_functionCount :: #force_inline proc "c" (self: ^VisibleFunctionTableDescriptor) -> NS.UInteger { return msgSend(NS.UInteger, self, "functionCount") } @(objc_type=VisibleFunctionTableDescriptor, objc_name="setFunctionCount") -VisibleFunctionTableDescriptor_setFunctionCount :: #force_inline proc(self: ^VisibleFunctionTableDescriptor, functionCount: NS.UInteger) { +VisibleFunctionTableDescriptor_setFunctionCount :: #force_inline proc "c" (self: ^VisibleFunctionTableDescriptor, functionCount: NS.UInteger) { msgSend(nil, self, "setFunctionCount:", functionCount) } @(objc_type=VisibleFunctionTableDescriptor, objc_name="visibleFunctionTableDescriptor", objc_is_class_method=true) -VisibleFunctionTableDescriptor_visibleFunctionTableDescriptor :: #force_inline proc() -> ^VisibleFunctionTableDescriptor { +VisibleFunctionTableDescriptor_visibleFunctionTableDescriptor :: #force_inline proc "c" () -> ^VisibleFunctionTableDescriptor { return msgSend(^VisibleFunctionTableDescriptor, VisibleFunctionTableDescriptor, "visibleFunctionTableDescriptor") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - AccelerationStructure -Class Methods: -Methods: - size -*/ + @(objc_class="MTLAccelerationStructure") AccelerationStructure :: struct { using _: Resource } @(objc_type=AccelerationStructure, objc_name="size") -AccelerationStructure_size :: #force_inline proc(self: ^AccelerationStructure) -> NS.UInteger { +AccelerationStructure_size :: #force_inline proc "c" (self: ^AccelerationStructure) -> NS.UInteger { return msgSend(NS.UInteger, self, "size") } +@(objc_type=AccelerationStructure, objc_name="getResourceID") +AccelerationStructure_getResourceID :: #force_inline proc "c" (self: ^AccelerationStructure) -> ResourceID { + return msgSend(ResourceID, self, "getResourceID") +} + //////////////////////////////////////////////////////////////////////////////// -/* -Class: - AccelerationStructureCommandEncoder -Class Methods: -Methods: - buildAccelerationStructure - copyAccelerationStructure - copyAndCompactAccelerationStructure - refitAccelerationStructure - sampleCountersInBuffer - updateFence - useHeap - useHeaps - useResource - useResources - waitForFence - writeCompactedAccelerationStructureSize -*/ + @(objc_class="MTLAccelerationStructureCommandEncoder") AccelerationStructureCommandEncoder :: struct { using _: CommandEncoder } @(objc_type=AccelerationStructureCommandEncoder, objc_name="buildAccelerationStructure") -AccelerationStructureCommandEncoder_buildAccelerationStructure :: #force_inline proc(self: ^AccelerationStructureCommandEncoder, accelerationStructure: ^AccelerationStructure, descriptor: ^AccelerationStructureDescriptor, scratchBuffer: ^Buffer, scratchBufferOffset: NS.UInteger) { +AccelerationStructureCommandEncoder_buildAccelerationStructure :: #force_inline proc "c" (self: ^AccelerationStructureCommandEncoder, accelerationStructure: ^AccelerationStructure, descriptor: ^AccelerationStructureDescriptor, scratchBuffer: ^Buffer, scratchBufferOffset: NS.UInteger) { msgSend(nil, self, "buildAccelerationStructure:descriptor:scratchBuffer:scratchBufferOffset:", accelerationStructure, descriptor, scratchBuffer, scratchBufferOffset) } @(objc_type=AccelerationStructureCommandEncoder, objc_name="copyAccelerationStructure") -AccelerationStructureCommandEncoder_copyAccelerationStructure :: #force_inline proc(self: ^AccelerationStructureCommandEncoder, sourceAccelerationStructure, destinationAccelerationStructure: ^AccelerationStructure) { +AccelerationStructureCommandEncoder_copyAccelerationStructure :: #force_inline proc "c" (self: ^AccelerationStructureCommandEncoder, sourceAccelerationStructure, destinationAccelerationStructure: ^AccelerationStructure) { msgSend(nil, self, "copyAccelerationStructure:toAccelerationStructure:", sourceAccelerationStructure, destinationAccelerationStructure) } @(objc_type=AccelerationStructureCommandEncoder, objc_name="copyAndCompactAccelerationStructure") -AccelerationStructureCommandEncoder_copyAndCompactAccelerationStructure :: #force_inline proc(self: ^AccelerationStructureCommandEncoder, sourceAccelerationStructure, destinationAccelerationStructure: ^AccelerationStructure) { +AccelerationStructureCommandEncoder_copyAndCompactAccelerationStructure :: #force_inline proc "c" (self: ^AccelerationStructureCommandEncoder, sourceAccelerationStructure, destinationAccelerationStructure: ^AccelerationStructure) { msgSend(nil, self, "copyAndCompactAccelerationStructure:toAccelerationStructure:", sourceAccelerationStructure, destinationAccelerationStructure) } @(objc_type=AccelerationStructureCommandEncoder, objc_name="refitAccelerationStructure") -AccelerationStructureCommandEncoder_refitAccelerationStructure :: #force_inline proc(self: ^AccelerationStructureCommandEncoder, sourceAccelerationStructure: ^AccelerationStructure, descriptor: ^AccelerationStructureDescriptor, destinationAccelerationStructure: ^AccelerationStructure, scratchBuffer: ^Buffer, scratchBufferOffset: NS.UInteger) { +AccelerationStructureCommandEncoder_refitAccelerationStructure :: #force_inline proc "c" (self: ^AccelerationStructureCommandEncoder, sourceAccelerationStructure: ^AccelerationStructure, descriptor: ^AccelerationStructureDescriptor, destinationAccelerationStructure: ^AccelerationStructure, scratchBuffer: ^Buffer, scratchBufferOffset: NS.UInteger) { msgSend(nil, self, "refitAccelerationStructure:descriptor:destination:scratchBuffer:scratchBufferOffset:", sourceAccelerationStructure, descriptor, destinationAccelerationStructure, scratchBuffer, scratchBufferOffset) } +@(objc_type=AccelerationStructureCommandEncoder, objc_name="refitAccelerationStructureWithOptions") +AccelerationStructureCommandEncoder_refitAccelerationStructureWithOptions :: #force_inline proc "c" (self: ^AccelerationStructureCommandEncoder, sourceAccelerationStructure: ^AccelerationStructure, descriptor: ^AccelerationStructureDescriptor, destinationAccelerationStructure: ^AccelerationStructure, scratchBuffer: ^Buffer, scratchBufferOffset: NS.UInteger, options: AccelerationStructureRefitOptions) { + msgSend(nil, self, "refitAccelerationStructure:descriptor:destination:scratchBuffer:scratchBufferOffset:options:", sourceAccelerationStructure, descriptor, destinationAccelerationStructure, scratchBuffer, scratchBufferOffset, options) +} @(objc_type=AccelerationStructureCommandEncoder, objc_name="sampleCountersInBuffer") -AccelerationStructureCommandEncoder_sampleCountersInBuffer :: #force_inline proc(self: ^AccelerationStructureCommandEncoder, sampleBuffer: ^Buffer, sampleIndex: NS.UInteger, barrier: BOOL) { +AccelerationStructureCommandEncoder_sampleCountersInBuffer :: #force_inline proc "c" (self: ^AccelerationStructureCommandEncoder, sampleBuffer: ^Buffer, sampleIndex: NS.UInteger, barrier: BOOL) { msgSend(nil, self, "sampleCountersInBuffer:atSampleIndex:withBarrier:", sampleBuffer, sampleIndex, barrier) } @(objc_type=AccelerationStructureCommandEncoder, objc_name="updateFence") -AccelerationStructureCommandEncoder_updateFence :: #force_inline proc(self: ^AccelerationStructureCommandEncoder, fence: ^Fence) { +AccelerationStructureCommandEncoder_updateFence :: #force_inline proc "c" (self: ^AccelerationStructureCommandEncoder, fence: ^Fence) { msgSend(nil, self, "updateFence:", fence) } @(objc_type=AccelerationStructureCommandEncoder, objc_name="useHeap") -AccelerationStructureCommandEncoder_useHeap :: #force_inline proc(self: ^AccelerationStructureCommandEncoder, heap: ^Heap) { +AccelerationStructureCommandEncoder_useHeap :: #force_inline proc "c" (self: ^AccelerationStructureCommandEncoder, heap: ^Heap) { msgSend(nil, self, "useHeap:", heap) } @(objc_type=AccelerationStructureCommandEncoder, objc_name="useHeaps") -AccelerationStructureCommandEncoder_useHeaps :: #force_inline proc(self: ^AccelerationStructureCommandEncoder, heaps: []^Heap) { +AccelerationStructureCommandEncoder_useHeaps :: #force_inline proc "c" (self: ^AccelerationStructureCommandEncoder, heaps: []^Heap) { msgSend(nil, self, "useHeaps:count:", raw_data(heaps), NS.UInteger(len(heaps))) } @(objc_type=AccelerationStructureCommandEncoder, objc_name="useResource") -AccelerationStructureCommandEncoder_useResource :: #force_inline proc(self: ^AccelerationStructureCommandEncoder, resource: ^Resource, usage: ResourceUsage) { +AccelerationStructureCommandEncoder_useResource :: #force_inline proc "c" (self: ^AccelerationStructureCommandEncoder, resource: ^Resource, usage: ResourceUsage) { msgSend(nil, self, "useResource:usage:", resource, usage) } @(objc_type=AccelerationStructureCommandEncoder, objc_name="useResources") -AccelerationStructureCommandEncoder_useResources :: #force_inline proc(self: ^AccelerationStructureCommandEncoder, resources: []^Resource, usage: ResourceUsage) { +AccelerationStructureCommandEncoder_useResources :: #force_inline proc "c" (self: ^AccelerationStructureCommandEncoder, resources: []^Resource, usage: ResourceUsage) { msgSend(nil, self, "useResources:count:usage:", resources, NS.UInteger(len(resources)), usage) } @(objc_type=AccelerationStructureCommandEncoder, objc_name="waitForFence") -AccelerationStructureCommandEncoder_waitForFence :: #force_inline proc(self: ^AccelerationStructureCommandEncoder, fence: ^Fence) { +AccelerationStructureCommandEncoder_waitForFence :: #force_inline proc "c" (self: ^AccelerationStructureCommandEncoder, fence: ^Fence) { msgSend(nil, self, "waitForFence:", fence) } @(objc_type=AccelerationStructureCommandEncoder, objc_name="writeCompactedAccelerationStructureSize") -AccelerationStructureCommandEncoder_writeCompactedAccelerationStructureSize :: #force_inline proc(self: ^AccelerationStructureCommandEncoder, accelerationStructure: ^AccelerationStructure, buffer: ^Buffer, offset: NS.UInteger) { +AccelerationStructureCommandEncoder_writeCompactedAccelerationStructureSize :: #force_inline proc "c" (self: ^AccelerationStructureCommandEncoder, accelerationStructure: ^AccelerationStructure, buffer: ^Buffer, offset: NS.UInteger) { msgSend(nil, self, "writeCompactedAccelerationStructureSize:toBuffer:offset:", accelerationStructure, buffer, offset) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - ArgumentEncoder -Class Methods: -Methods: - alignment - constantDataAtIndex - device - encodedLength - label - newArgumentEncoderForBufferAtIndex - setAccelerationStructure - setArgumentBuffer - setArgumentBuffer - setBuffer - setBuffers - setComputePipelineState - setComputePipelineStates - setIndirectCommandBuffer - setIndirectCommandBuffers - setIntersectionFunctionTable - setIntersectionFunctionTables - setLabel - setRenderPipelineState - setRenderPipelineStates - setSamplerState - setSamplerStates - setTexture - setTextures - setVisibleFunctionTable - setVisibleFunctionTables -*/ + +@(objc_class="MTLAccelerationStructurePassSampleBufferAttachmentDescriptor") +AccelerationStructurePassSampleBufferAttachmentDescriptor :: struct { using _: NS.Copying(AccelerationStructurePassSampleBufferAttachmentDescriptor) } + +@(objc_type=AccelerationStructurePassSampleBufferAttachmentDescriptor, objc_name="alloc", objc_is_class_method=true) +AccelerationStructurePassSampleBufferAttachmentDescriptor_alloc :: #force_inline proc "c" () -> ^AccelerationStructurePassSampleBufferAttachmentDescriptor { + return msgSend(^AccelerationStructurePassSampleBufferAttachmentDescriptor, AccelerationStructurePassSampleBufferAttachmentDescriptor, "alloc") +} +@(objc_type=AccelerationStructurePassSampleBufferAttachmentDescriptor, objc_name="init") +AccelerationStructurePassSampleBufferAttachmentDescriptor_init :: #force_inline proc "c" (self: ^AccelerationStructurePassSampleBufferAttachmentDescriptor) -> ^AccelerationStructurePassSampleBufferAttachmentDescriptor { + return msgSend(^AccelerationStructurePassSampleBufferAttachmentDescriptor, self, "init") +} + + +@(objc_type=AccelerationStructurePassSampleBufferAttachmentDescriptor, objc_name="sampleBuffer") +AccelerationStructurePassSampleBufferAttachmentDescriptor_sampleBuffer :: #force_inline proc "c" (self: ^AccelerationStructurePassSampleBufferAttachmentDescriptor) -> ^CounterSampleBuffer { + return msgSend(^CounterSampleBuffer, self, "sampleBuffer") +} +@(objc_type=AccelerationStructurePassSampleBufferAttachmentDescriptor, objc_name="setSampleBuffer") +AccelerationStructurePassSampleBufferAttachmentDescriptor_setSampleBuffer :: #force_inline proc "c" (self: ^AccelerationStructurePassSampleBufferAttachmentDescriptor, sampleBuffer: ^CounterSampleBuffer) { + msgSend(nil, self, "setSampleBuffer:", sampleBuffer) +} + + +@(objc_type=AccelerationStructurePassSampleBufferAttachmentDescriptor, objc_name="startOfEncoderSampleIndex") +AccelerationStructurePassSampleBufferAttachmentDescriptor_startOfEncoderSampleIndex :: #force_inline proc "c" (self: ^AccelerationStructurePassSampleBufferAttachmentDescriptor) -> NS.UInteger { + return msgSend(NS.UInteger, self, "startOfEncoderSampleIndex") +} +@(objc_type=AccelerationStructurePassSampleBufferAttachmentDescriptor, objc_name="setStartOfEncoderSampleIndex") +AccelerationStructurePassSampleBufferAttachmentDescriptor_setStartOfEncoderSampleIndex :: #force_inline proc "c" (self: ^AccelerationStructurePassSampleBufferAttachmentDescriptor, startOfEncoderSampleIndex: NS.UInteger) { + msgSend(nil, self, "setStartOfEncoderSampleIndex:", startOfEncoderSampleIndex) +} + + +@(objc_type=AccelerationStructurePassSampleBufferAttachmentDescriptor, objc_name="endOfEncoderSampleIndex") +AccelerationStructurePassSampleBufferAttachmentDescriptor_endOfEncoderSampleIndex :: #force_inline proc "c" (self: ^AccelerationStructurePassSampleBufferAttachmentDescriptor) -> NS.UInteger { + return msgSend(NS.UInteger, self, "endOfEncoderSampleIndex") +} +@(objc_type=AccelerationStructurePassSampleBufferAttachmentDescriptor, objc_name="setEndOfEncoderSampleIndex") +AccelerationStructurePassSampleBufferAttachmentDescriptor_setEndOfEncoderSampleIndex :: #force_inline proc "c" (self: ^AccelerationStructurePassSampleBufferAttachmentDescriptor, endOfEncoderSampleIndex: NS.UInteger) { + msgSend(nil, self, "setEndOfEncoderSampleIndex:", endOfEncoderSampleIndex) +} + +//////////////////////////////////////////////////////////////////////////////// + +@(objc_class="MTLAccelerationStructurePassSampleBufferAttachmentDescriptorArray") +AccelerationStructurePassSampleBufferAttachmentDescriptorArray :: struct { using _: NS.Object } + +@(objc_type=AccelerationStructurePassSampleBufferAttachmentDescriptorArray, objc_name="alloc", objc_is_class_method=true) +AccelerationStructurePassSampleBufferAttachmentDescriptorArray_alloc :: #force_inline proc "c" () -> ^AccelerationStructurePassSampleBufferAttachmentDescriptorArray { + return msgSend(^AccelerationStructurePassSampleBufferAttachmentDescriptorArray, AccelerationStructurePassSampleBufferAttachmentDescriptorArray, "alloc") +} +@(objc_type=AccelerationStructurePassSampleBufferAttachmentDescriptorArray, objc_name="init") +AccelerationStructurePassSampleBufferAttachmentDescriptorArray_init :: #force_inline proc "c" (self: ^AccelerationStructurePassSampleBufferAttachmentDescriptorArray) -> ^AccelerationStructurePassSampleBufferAttachmentDescriptorArray { + return msgSend(^AccelerationStructurePassSampleBufferAttachmentDescriptorArray, self, "init") +} + +@(objc_type=AccelerationStructurePassSampleBufferAttachmentDescriptorArray, objc_name="object") +AccelerationStructurePassSampleBufferAttachmentDescriptorArray_object :: #force_inline proc "c" (self: ^AccelerationStructurePassSampleBufferAttachmentDescriptorArray, attachmentIndex: NS.UInteger) -> ^AccelerationStructurePassSampleBufferAttachmentDescriptor { + return msgSend(^AccelerationStructurePassSampleBufferAttachmentDescriptor, self, "objectAtIndexedSubscript:", attachmentIndex) +} + +@(objc_type=AccelerationStructurePassSampleBufferAttachmentDescriptorArray, objc_name="setObject") +AccelerationStructurePassSampleBufferAttachmentDescriptorArray_setObject :: #force_inline proc "c" (self: ^AccelerationStructurePassSampleBufferAttachmentDescriptorArray, attachment: ^AccelerationStructurePassSampleBufferAttachmentDescriptor, attachmentIndex: NS.UInteger) { + msgSend(nil, self, "setObject:atIndexedSubscript:", attachment, attachmentIndex) +} + +//////////////////////////////////////////////////////////////////////////////// + +@(objc_class="MTLAccelerationStructurePassDescriptor") +AccelerationStructurePassDescriptor :: struct { using _: NS.Copying(AccelerationStructurePassDescriptor) } + + +@(objc_type=AccelerationStructurePassDescriptor, objc_name="alloc", objc_is_class_method=true) +AccelerationStructurePassDescriptor_alloc :: #force_inline proc "c" () -> ^AccelerationStructurePassDescriptor { + return msgSend(^AccelerationStructurePassDescriptor, AccelerationStructurePassDescriptor, "alloc") +} +@(objc_type=AccelerationStructurePassDescriptor, objc_name="init") +AccelerationStructurePassDescriptor_init :: #force_inline proc "c" (self: ^AccelerationStructurePassDescriptor) -> ^AccelerationStructurePassDescriptor { + return msgSend(^AccelerationStructurePassDescriptor, self, "init") +} + + +@(objc_type=AccelerationStructurePassDescriptor, objc_name="accelerationStructurePassDescriptor", objc_is_class_method=true) +AccelerationStructurePassDescriptor_accelerationStructurePassDescriptor :: #force_inline proc "c" () -> ^AccelerationStructurePassDescriptor { + return msgSend(^AccelerationStructurePassDescriptor, AccelerationStructurePassDescriptor, "accelerationStructurePassDescriptor") +} +@(objc_type=AccelerationStructurePassDescriptor, objc_name="sampleBufferAttachments") +AccelerationStructurePassDescriptor_sampleBufferAttachments :: #force_inline proc "c" (self: ^AccelerationStructurePassDescriptor) -> ^AccelerationStructurePassSampleBufferAttachmentDescriptorArray { + return msgSend(^AccelerationStructurePassSampleBufferAttachmentDescriptorArray, self, "sampleBufferAttachments") +} + + +//////////////////////////////////////////////////////////////////////////////// + +@(objc_class="MTLBinding") +Binding :: struct { using _: NS.Object } + +@(objc_type=Binding, objc_name="name") +Binding_name :: #force_inline proc "c" (self: ^Binding) -> ^NS.String { + return msgSend(^NS.String, self, "name") +} +@(objc_type=Binding, objc_name="type") +Binding_type :: #force_inline proc "c" (self: ^Binding) -> BindingType { + return msgSend(BindingType, self, "type") +} +@(objc_type=Binding, objc_name="access") +Binding_access :: #force_inline proc "c" (self: ^Binding) -> ArgumentAccess { + return msgSend(ArgumentAccess, self, "access") +} +@(objc_type=Binding, objc_name="index") +Binding_index :: #force_inline proc "c" (self: ^Binding) -> NS.UInteger { + return msgSend(NS.UInteger, self, "index") +} +@(objc_type=Binding, objc_name="isUsed") +Binding_isUsed :: #force_inline proc "c" (self: ^Binding) -> BOOL { + return msgSend(BOOL, self, "isUsed") +} +@(objc_type=Binding, objc_name="isArgument") +Binding_isArgument :: #force_inline proc "c" (self: ^Binding) -> BOOL { + return msgSend(BOOL, self, "isArgument") +} + +//////////////////////////////////////////////////////////////////////////////// + +@(objc_class="MTLBufferBinding") +BufferBinding :: struct { using _: Binding } + +@(objc_type=BufferBinding, objc_name="bufferAlignment") +BufferBinding_bufferAlignment :: #force_inline proc "c" (self: ^BufferBinding) -> NS.UInteger { + return msgSend(NS.UInteger, self, "bufferAlignment") +} +@(objc_type=BufferBinding, objc_name="bufferDataSize") +BufferBinding_bufferDataSize :: #force_inline proc "c" (self: ^BufferBinding) -> NS.UInteger { + return msgSend(NS.UInteger, self, "bufferDataSize") +} +@(objc_type=BufferBinding, objc_name="bufferDataType") +BufferBinding_bufferDataType :: #force_inline proc "c" (self: ^BufferBinding) -> DataType { + return msgSend(DataType, self, "bufferDataType") +} +@(objc_type=BufferBinding, objc_name="bufferStructType") +BufferBinding_bufferStructType :: #force_inline proc "c" (self: ^BufferBinding) -> ^StructType { + return msgSend(^StructType, self, "bufferStructType") +} +@(objc_type=BufferBinding, objc_name="bufferPointerType") +BufferBinding_bufferPointerType :: #force_inline proc "c" (self: ^BufferBinding) -> ^PointerType { + return msgSend(^PointerType, self, "bufferPointerType") +} + +//////////////////////////////////////////////////////////////////////////////// + +@(objc_class="MTLThreadgroupBinding") +ThreadgroupBinding :: struct { using _: Binding } + +@(objc_type=ThreadgroupBinding, objc_name="threadgroupMemoryAlignment") +ThreadgroupBinding_threadgroupMemoryAlignment :: #force_inline proc "c" (self: ^ThreadgroupBinding) -> NS.UInteger { + return msgSend(NS.UInteger, self, "threadgroupMemoryAlignment") +} +@(objc_type=ThreadgroupBinding, objc_name="threadgroupMemoryDataSize") +ThreadgroupBinding_threadgroupMemoryDataSize :: #force_inline proc "c" (self: ^ThreadgroupBinding) -> NS.UInteger { + return msgSend(NS.UInteger, self, "threadgroupMemoryDataSize") +} + +//////////////////////////////////////////////////////////////////////////////// + +@(objc_class="MTLTextureBinding") +TextureBinding :: struct { using _: Binding } + +@(objc_type=TextureBinding, objc_name="textureType") +TextureBinding_textureType :: #force_inline proc "c" (self: ^TextureBinding) -> TextureType { + return msgSend(TextureType, self, "textureType") +} +@(objc_type=TextureBinding, objc_name="textureDataType") +TextureBinding_textureDataType :: #force_inline proc "c" (self: ^TextureBinding) -> DataType { + return msgSend(DataType, self, "textureDataType") +} +@(objc_type=TextureBinding, objc_name="isDepthTexture") +TextureBinding_isDepthTexture :: #force_inline proc "c" (self: ^TextureBinding) -> BOOL { + return msgSend(BOOL, self, "isDepthTexture") +} +@(objc_type=TextureBinding, objc_name="arrayLength") +TextureBinding_arrayLength :: #force_inline proc "c" (self: ^TextureBinding) -> NS.UInteger { + return msgSend(NS.UInteger, self, "arrayLength") +} + +//////////////////////////////////////////////////////////////////////////////// + +@(objc_class="MTLObjectPayloadBinding") +ObjectPayloadBinding :: struct { using _: Binding } + +@(objc_type=ObjectPayloadBinding, objc_name="objectPayloadAlignment") +ObjectPayloadBinding_objectPayloadAlignment :: #force_inline proc "c" (self: ^ObjectPayloadBinding) -> NS.UInteger { + return msgSend(NS.UInteger, self, "objectPayloadAlignment") +} +@(objc_type=ObjectPayloadBinding, objc_name="objectPayloadDataSize") +ObjectPayloadBinding_objectPayloadDataSize :: #force_inline proc "c" (self: ^ObjectPayloadBinding) -> NS.UInteger { + return msgSend(NS.UInteger, self, "objectPayloadDataSize") +} + +//////////////////////////////////////////////////////////////////////////////// + @(objc_class="MTLArgumentEncoder") ArgumentEncoder :: struct { using _: NS.Object } @(objc_type=ArgumentEncoder, objc_name="alignment") -ArgumentEncoder_alignment :: #force_inline proc(self: ^ArgumentEncoder) -> NS.UInteger { +ArgumentEncoder_alignment :: #force_inline proc "c" (self: ^ArgumentEncoder) -> NS.UInteger { return msgSend(NS.UInteger, self, "alignment") } @(objc_type=ArgumentEncoder, objc_name="constantData") -ArgumentEncoder_constantData :: #force_inline proc(self: ^ArgumentEncoder, index: NS.UInteger) -> rawptr { +ArgumentEncoder_constantData :: #force_inline proc "c" (self: ^ArgumentEncoder, index: NS.UInteger) -> rawptr { return msgSend(rawptr, self, "constantDataAtIndex:", index) } @(objc_type=ArgumentEncoder, objc_name="device") -ArgumentEncoder_device :: #force_inline proc(self: ^ArgumentEncoder) -> ^Device { +ArgumentEncoder_device :: #force_inline proc "c" (self: ^ArgumentEncoder) -> ^Device { return msgSend(^Device, self, "device") } @(objc_type=ArgumentEncoder, objc_name="encodedLength") -ArgumentEncoder_encodedLength :: #force_inline proc(self: ^ArgumentEncoder) -> NS.UInteger { +ArgumentEncoder_encodedLength :: #force_inline proc "c" (self: ^ArgumentEncoder) -> NS.UInteger { return msgSend(NS.UInteger, self, "encodedLength") } @(objc_type=ArgumentEncoder, objc_name="label") -ArgumentEncoder_label :: #force_inline proc(self: ^ArgumentEncoder) -> ^NS.String { +ArgumentEncoder_label :: #force_inline proc "c" (self: ^ArgumentEncoder) -> ^NS.String { return msgSend(^NS.String, self, "label") } @(objc_type=ArgumentEncoder, objc_name="newArgumentEncoderForBuffer") -ArgumentEncoder_newArgumentEncoderForBuffer :: #force_inline proc(self: ^ArgumentEncoder, index: NS.UInteger) -> ^ArgumentEncoder { +ArgumentEncoder_newArgumentEncoderForBuffer :: #force_inline proc "c" (self: ^ArgumentEncoder, index: NS.UInteger) -> ^ArgumentEncoder { return msgSend(^ArgumentEncoder, self, "newArgumentEncoderForBufferAtIndex:", index) } @(objc_type=ArgumentEncoder, objc_name="setAccelerationStructure") -ArgumentEncoder_setAccelerationStructure :: #force_inline proc(self: ^ArgumentEncoder, accelerationStructure: ^AccelerationStructure, index: NS.UInteger) { +ArgumentEncoder_setAccelerationStructure :: #force_inline proc "c" (self: ^ArgumentEncoder, accelerationStructure: ^AccelerationStructure, index: NS.UInteger) { msgSend(nil, self, "setAccelerationStructure:atIndex:", accelerationStructure, index) } @(objc_type=ArgumentEncoder, objc_name="setArgumentBufferWithOffset") -ArgumentEncoder_setArgumentBufferWithOffset :: #force_inline proc(self: ^ArgumentEncoder, argumentBuffer: ^Buffer, offset: NS.UInteger) { +ArgumentEncoder_setArgumentBufferWithOffset :: #force_inline proc "c" (self: ^ArgumentEncoder, argumentBuffer: ^Buffer, offset: NS.UInteger) { msgSend(nil, self, "setArgumentBuffer:offset:", argumentBuffer, offset) } @(objc_type=ArgumentEncoder, objc_name="setArgumentBufferWithStartOffset") -ArgumentEncoder_setArgumentBuffer_startOffsetWithStartOffset :: #force_inline proc(self: ^ArgumentEncoder, argumentBuffer: ^Buffer, startOffset: NS.UInteger, arrayElement: NS.UInteger) { +ArgumentEncoder_setArgumentBuffer_startOffsetWithStartOffset :: #force_inline proc "c" (self: ^ArgumentEncoder, argumentBuffer: ^Buffer, startOffset: NS.UInteger, arrayElement: NS.UInteger) { msgSend(nil, self, "setArgumentBuffer:startOffset:arrayElement:", argumentBuffer, startOffset, arrayElement) } @(objc_type=ArgumentEncoder, objc_name="setBuffer") -ArgumentEncoder_setBuffer :: #force_inline proc(self: ^ArgumentEncoder, buffer: ^Buffer, offset: NS.UInteger, index: NS.UInteger) { +ArgumentEncoder_setBuffer :: #force_inline proc "c" (self: ^ArgumentEncoder, buffer: ^Buffer, offset: NS.UInteger, index: NS.UInteger) { msgSend(nil, self, "setBuffer:offset:atIndex:", buffer, offset, index) } @(objc_type=ArgumentEncoder, objc_name="setBuffers") -ArgumentEncoder_setBuffers :: #force_inline proc(self: ^ArgumentEncoder, buffers: []^Buffer, offsets: []NS.UInteger, range: NS.Range) { +ArgumentEncoder_setBuffers :: #force_inline proc "odin" (self: ^ArgumentEncoder, buffers: []^Buffer, offsets: []NS.UInteger, range: NS.Range) { assert(len(buffers) == len(offsets)) msgSend(nil, self, "setBuffers:offsets:withRange:", raw_data(buffers), raw_data(offsets), range) } @(objc_type=ArgumentEncoder, objc_name="setComputePipelineState") -ArgumentEncoder_setComputePipelineState :: #force_inline proc(self: ^ArgumentEncoder, pipeline: ^ComputePipelineState, index: NS.UInteger) { +ArgumentEncoder_setComputePipelineState :: #force_inline proc "c" (self: ^ArgumentEncoder, pipeline: ^ComputePipelineState, index: NS.UInteger) { msgSend(nil, self, "setComputePipelineState:atIndex:", pipeline, index) } @(objc_type=ArgumentEncoder, objc_name="setComputePipelineStates") -ArgumentEncoder_setComputePipelineStates :: #force_inline proc(self: ^ArgumentEncoder, pipelines: []^ComputePipelineState, range: NS.Range) { +ArgumentEncoder_setComputePipelineStates :: #force_inline proc "odin" (self: ^ArgumentEncoder, pipelines: []^ComputePipelineState, range: NS.Range) { assert(range.length <= NS.UInteger(len(pipelines))) msgSend(nil, self, "setComputePipelineStates:withRange:", raw_data(pipelines), range) } @(objc_type=ArgumentEncoder, objc_name="setIndirectCommandBuffer") -ArgumentEncoder_setIndirectCommandBuffer :: #force_inline proc(self: ^ArgumentEncoder, indirectCommandBuffer: ^IndirectCommandBuffer, index: NS.UInteger) { +ArgumentEncoder_setIndirectCommandBuffer :: #force_inline proc "c" (self: ^ArgumentEncoder, indirectCommandBuffer: ^IndirectCommandBuffer, index: NS.UInteger) { msgSend(nil, self, "setIndirectCommandBuffer:atIndex:", indirectCommandBuffer, index) } @(objc_type=ArgumentEncoder, objc_name="setIndirectCommandBuffers") -ArgumentEncoder_setIndirectCommandBuffers :: #force_inline proc(self: ^ArgumentEncoder, buffers: []^IndirectCommandBuffer, range: NS.Range) { +ArgumentEncoder_setIndirectCommandBuffers :: #force_inline proc "odin" (self: ^ArgumentEncoder, buffers: []^IndirectCommandBuffer, range: NS.Range) { assert(range.length <= NS.UInteger(len(buffers))) msgSend(nil, self, "setIndirectCommandBuffers:withRange:", raw_data(buffers), range) } @(objc_type=ArgumentEncoder, objc_name="setIntersectionFunctionTable") -ArgumentEncoder_setIntersectionFunctionTable :: #force_inline proc(self: ^ArgumentEncoder, intersectionFunctionTable: ^IntersectionFunctionTable, index: NS.UInteger) { +ArgumentEncoder_setIntersectionFunctionTable :: #force_inline proc "c" (self: ^ArgumentEncoder, intersectionFunctionTable: ^IntersectionFunctionTable, index: NS.UInteger) { msgSend(nil, self, "setIntersectionFunctionTable:atIndex:", intersectionFunctionTable, index) } @(objc_type=ArgumentEncoder, objc_name="setIntersectionFunctionTables") -ArgumentEncoder_setIntersectionFunctionTables :: #force_inline proc(self: ^ArgumentEncoder, intersectionFunctionTables: []^IntersectionFunctionTable, range: NS.Range) { +ArgumentEncoder_setIntersectionFunctionTables :: #force_inline proc "odin" (self: ^ArgumentEncoder, intersectionFunctionTables: []^IntersectionFunctionTable, range: NS.Range) { assert(range.length <= NS.UInteger(len(intersectionFunctionTables))) msgSend(nil, self, "setIntersectionFunctionTables:withRange:", raw_data(intersectionFunctionTables), range) } @(objc_type=ArgumentEncoder, objc_name="setLabel") -ArgumentEncoder_setLabel :: #force_inline proc(self: ^ArgumentEncoder, label: ^NS.String) { +ArgumentEncoder_setLabel :: #force_inline proc "c" (self: ^ArgumentEncoder, label: ^NS.String) { msgSend(nil, self, "setLabel:", label) } @(objc_type=ArgumentEncoder, objc_name="setRenderPipelineState") -ArgumentEncoder_setRenderPipelineState :: #force_inline proc(self: ^ArgumentEncoder, pipeline: ^RenderPipelineState, index: NS.UInteger) { +ArgumentEncoder_setRenderPipelineState :: #force_inline proc "c" (self: ^ArgumentEncoder, pipeline: ^RenderPipelineState, index: NS.UInteger) { msgSend(nil, self, "setRenderPipelineState:atIndex:", pipeline, index) } @(objc_type=ArgumentEncoder, objc_name="setRenderPipelineStates") -ArgumentEncoder_setRenderPipelineStates :: #force_inline proc(self: ^ArgumentEncoder, pipelines: []^RenderPipelineState, range: NS.Range) { +ArgumentEncoder_setRenderPipelineStates :: #force_inline proc "odin" (self: ^ArgumentEncoder, pipelines: []^RenderPipelineState, range: NS.Range) { assert(range.length <= NS.UInteger(len(pipelines))) msgSend(nil, self, "setRenderPipelineStates:withRange:", raw_data(pipelines), range) } @(objc_type=ArgumentEncoder, objc_name="setSamplerState") -ArgumentEncoder_setSamplerState :: #force_inline proc(self: ^ArgumentEncoder, sampler: ^SamplerState, index: NS.UInteger) { +ArgumentEncoder_setSamplerState :: #force_inline proc "c" (self: ^ArgumentEncoder, sampler: ^SamplerState, index: NS.UInteger) { msgSend(nil, self, "setSamplerState:atIndex:", sampler, index) } @(objc_type=ArgumentEncoder, objc_name="setSamplerStates") -ArgumentEncoder_setSamplerStates :: #force_inline proc(self: ^ArgumentEncoder, samplers: []^SamplerState, range: NS.Range) { +ArgumentEncoder_setSamplerStates :: #force_inline proc "odin" (self: ^ArgumentEncoder, samplers: []^SamplerState, range: NS.Range) { assert(range.length <= NS.UInteger(len(samplers))) msgSend(nil, self, "setSamplerStates:withRange:", raw_data(samplers), range) } @(objc_type=ArgumentEncoder, objc_name="setTexture") -ArgumentEncoder_setTexture :: #force_inline proc(self: ^ArgumentEncoder, texture: ^Texture, index: NS.UInteger) { +ArgumentEncoder_setTexture :: #force_inline proc "c" (self: ^ArgumentEncoder, texture: ^Texture, index: NS.UInteger) { msgSend(nil, self, "setTexture:atIndex:", texture, index) } @(objc_type=ArgumentEncoder, objc_name="setTextures") -ArgumentEncoder_setTextures :: #force_inline proc(self: ^ArgumentEncoder, textures: []^Texture, range: NS.Range) { +ArgumentEncoder_setTextures :: #force_inline proc "odin" (self: ^ArgumentEncoder, textures: []^Texture, range: NS.Range) { assert(range.length <= NS.UInteger(len(textures))) msgSend(nil, self, "setTextures:withRange:", raw_data(textures), range) } @(objc_type=ArgumentEncoder, objc_name="setVisibleFunctionTable") -ArgumentEncoder_setVisibleFunctionTable :: #force_inline proc(self: ^ArgumentEncoder, visibleFunctionTable: ^VisibleFunctionTable, index: NS.UInteger) { +ArgumentEncoder_setVisibleFunctionTable :: #force_inline proc "c" (self: ^ArgumentEncoder, visibleFunctionTable: ^VisibleFunctionTable, index: NS.UInteger) { msgSend(nil, self, "setVisibleFunctionTable:atIndex:", visibleFunctionTable, index) } @(objc_type=ArgumentEncoder, objc_name="setVisibleFunctionTables") -ArgumentEncoder_setVisibleFunctionTables :: #force_inline proc(self: ^ArgumentEncoder, visibleFunctionTables: []^VisibleFunctionTable, range: NS.Range) { +ArgumentEncoder_setVisibleFunctionTables :: #force_inline proc "odin" (self: ^ArgumentEncoder, visibleFunctionTables: []^VisibleFunctionTable, range: NS.Range) { assert(range.length <= NS.UInteger(len(visibleFunctionTables))) msgSend(nil, self, "setVisibleFunctionTables:withRange:", raw_data(visibleFunctionTables), range) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - BinaryArchive -Class Methods: -Methods: - addComputePipelineFunctionsWithDescriptor - addRenderPipelineFunctionsWithDescriptor - addTileRenderPipelineFunctionsWithDescriptor - device - label - serializeToURL - setLabel -*/ @(objc_class="MTLBinaryArchive") BinaryArchive :: struct { using _: NS.Copying(BinaryArchive) } @(objc_type=BinaryArchive, objc_name="addComputePipelineFunctions") -BinaryArchive_addComputePipelineFunctions :: #force_inline proc(self: ^BinaryArchive, descriptor: ^ComputePipelineDescriptor) -> (ok: BOOL, error: ^NS.Error) { +BinaryArchive_addComputePipelineFunctions :: #force_inline proc "contextless" (self: ^BinaryArchive, descriptor: ^ComputePipelineDescriptor) -> (ok: BOOL, error: ^NS.Error) { ok = msgSend(BOOL, self, "addComputePipelineFunctionsWithDescriptor:error:", descriptor, &error) return } @(objc_type=BinaryArchive, objc_name="addRenderPipelineFunctions") -BinaryArchive_addRenderPipelineFunctions :: #force_inline proc(self: ^BinaryArchive, descriptor: ^RenderPipelineDescriptor) -> (ok: BOOL, error: ^NS.Error) { +BinaryArchive_addRenderPipelineFunctions :: #force_inline proc "contextless" (self: ^BinaryArchive, descriptor: ^RenderPipelineDescriptor) -> (ok: BOOL, error: ^NS.Error) { ok = msgSend(BOOL, self, "addRenderPipelineFunctionsWithDescriptor:error:", descriptor, &error) return } @(objc_type=BinaryArchive, objc_name="addTileRenderPipelineFunctions") -BinaryArchive_addTileRenderPipelineFunctions :: #force_inline proc(self: ^BinaryArchive, descriptor: ^TileRenderPipelineDescriptor) -> (ok: BOOL, error: ^NS.Error) { +BinaryArchive_addTileRenderPipelineFunctions :: #force_inline proc "contextless" (self: ^BinaryArchive, descriptor: ^TileRenderPipelineDescriptor) -> (ok: BOOL, error: ^NS.Error) { ok = msgSend(BOOL, self, "addTileRenderPipelineFunctionsWithDescriptor:error:", descriptor, &error) return } @(objc_type=BinaryArchive, objc_name="device") -BinaryArchive_device :: #force_inline proc(self: ^BinaryArchive) -> ^Device { +BinaryArchive_device :: #force_inline proc "c" (self: ^BinaryArchive) -> ^Device { return msgSend(^Device, self, "device") } @(objc_type=BinaryArchive, objc_name="label") -BinaryArchive_label :: #force_inline proc(self: ^BinaryArchive) -> ^NS.String { +BinaryArchive_label :: #force_inline proc "c" (self: ^BinaryArchive) -> ^NS.String { return msgSend(^NS.String, self, "label") } @(objc_type=BinaryArchive, objc_name="serializeToURL") -BinaryArchive_serializeToURL :: #force_inline proc(self: ^BinaryArchive, url: ^NS.URL) -> (ok: BOOL, error: ^NS.Error) { +BinaryArchive_serializeToURL :: #force_inline proc "contextless" (self: ^BinaryArchive, url: ^NS.URL) -> (ok: BOOL, error: ^NS.Error) { ok = msgSend(BOOL, self, "serializeToURL:error:", url, &error) return } @(objc_type=BinaryArchive, objc_name="setLabel") -BinaryArchive_setLabel :: #force_inline proc(self: ^BinaryArchive, label: ^NS.String) { +BinaryArchive_setLabel :: #force_inline proc "c" (self: ^BinaryArchive, label: ^NS.String) { msgSend(nil, self, "setLabel:", label) } @(objc_type=BinaryArchive, objc_name="addFunction") -BinaryArchive_addFunction :: #force_inline proc(self: ^BinaryArchive, descriptor: ^FunctionDescriptor, library: ^Library) -> (ok: BOOL, error: ^NS.Error) { +BinaryArchive_addFunction :: #force_inline proc "contextless" (self: ^BinaryArchive, descriptor: ^FunctionDescriptor, library: ^Library) -> (ok: BOOL, error: ^NS.Error) { ok = msgSend(BOOL, self, "addFunction:", descriptor, library, &error) return } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - BlitCommandEncoder -Class Methods: -Methods: - copyFromBuffer - copyFromBuffer - copyFromBuffer - copyFromTexture - copyFromTexture - copyFromTexture - copyFromTexture - copyFromTexture - copyIndirectCommandBuffer - fillBuffer - generateMipmapsForTexture - getTextureAccessCounters - optimizeContentsForCPUAccess - optimizeContentsForCPUAccess - optimizeContentsForGPUAccess - optimizeContentsForGPUAccess - optimizeIndirectCommandBuffer - resetCommandsInBuffer - resetTextureAccessCounters - resolveCounters - sampleCountersInBuffer - synchronizeResource - synchronizeTexture - updateFence - waitForFence -*/ @(objc_class="MTLBlitCommandEncoder") BlitCommandEncoder :: struct { using _: CommandEncoder } @(objc_type=BlitCommandEncoder, objc_name="copyFromBufferEx") -BlitCommandEncoder_copyFromBufferEx :: #force_inline proc(self: ^BlitCommandEncoder, sourceBuffer: ^Buffer, sourceOffset: NS.UInteger, sourceBytesPerRow: NS.UInteger, sourceBytesPerImage: NS.UInteger, sourceSize: Size, destinationTexture: ^Texture, destinationSlice: NS.UInteger, destinationLevel: NS.UInteger, destinationOrigin: Origin) { +BlitCommandEncoder_copyFromBufferEx :: #force_inline proc "c" (self: ^BlitCommandEncoder, sourceBuffer: ^Buffer, sourceOffset: NS.UInteger, sourceBytesPerRow: NS.UInteger, sourceBytesPerImage: NS.UInteger, sourceSize: Size, destinationTexture: ^Texture, destinationSlice: NS.UInteger, destinationLevel: NS.UInteger, destinationOrigin: Origin) { msgSend(nil, self, "copyFromBuffer:sourceOffset:sourceBytesPerRow:sourceBytesPerImage:sourceSize:toTexture:destinationSlice:destinationLevel:destinationOrigin:", sourceBuffer, sourceOffset, sourceBytesPerRow, sourceBytesPerImage, sourceSize, destinationTexture, destinationSlice, destinationLevel, destinationOrigin) } @(objc_type=BlitCommandEncoder, objc_name="copyFromBufferExWithOptions") -BlitCommandEncoder_copyFromBufferExWithOptions :: #force_inline proc(self: ^BlitCommandEncoder, sourceBuffer: ^Buffer, sourceOffset: NS.UInteger, sourceBytesPerRow: NS.UInteger, sourceBytesPerImage: NS.UInteger, sourceSize: Size, destinationTexture: ^Texture, destinationSlice: NS.UInteger, destinationLevel: NS.UInteger, destinationOrigin: Origin, options: BlitOption) { +BlitCommandEncoder_copyFromBufferExWithOptions :: #force_inline proc "c" (self: ^BlitCommandEncoder, sourceBuffer: ^Buffer, sourceOffset: NS.UInteger, sourceBytesPerRow: NS.UInteger, sourceBytesPerImage: NS.UInteger, sourceSize: Size, destinationTexture: ^Texture, destinationSlice: NS.UInteger, destinationLevel: NS.UInteger, destinationOrigin: Origin, options: BlitOption) { msgSend(nil, self, "copyFromBuffer:sourceOffset:sourceBytesPerRow:sourceBytesPerImage:sourceSize:toTexture:destinationSlice:destinationLevel:destinationOrigin:options:", sourceBuffer, sourceOffset, sourceBytesPerRow, sourceBytesPerImage, sourceSize, destinationTexture, destinationSlice, destinationLevel, destinationOrigin, options) } @(objc_type=BlitCommandEncoder, objc_name="copyFromBuffer") -BlitCommandEncoder_copyFromBuffer :: #force_inline proc(self: ^BlitCommandEncoder, sourceBuffer: ^Buffer, sourceOffset: NS.UInteger, destinationBuffer: ^Buffer, destinationOffset: NS.UInteger, size: NS.UInteger) { +BlitCommandEncoder_copyFromBuffer :: #force_inline proc "c" (self: ^BlitCommandEncoder, sourceBuffer: ^Buffer, sourceOffset: NS.UInteger, destinationBuffer: ^Buffer, destinationOffset: NS.UInteger, size: NS.UInteger) { msgSend(nil, self, "copyFromBuffer:sourceOffset:toBuffer:destinationOffset:size:", sourceBuffer, sourceOffset, destinationBuffer, destinationOffset, size) } @(objc_type=BlitCommandEncoder, objc_name="copyFromTextureEx") -BlitCommandEncoder_copyFromTextureEx :: #force_inline proc(self: ^BlitCommandEncoder, sourceTexture: ^Texture, sourceSlice: NS.UInteger, sourceLevel: NS.UInteger, sourceOrigin: Origin, sourceSize: Size, destinationBuffer: ^Buffer, destinationOffset: NS.UInteger, destinationBytesPerRow: NS.UInteger, destinationBytesPerImage: NS.UInteger) { +BlitCommandEncoder_copyFromTextureEx :: #force_inline proc "c" (self: ^BlitCommandEncoder, sourceTexture: ^Texture, sourceSlice: NS.UInteger, sourceLevel: NS.UInteger, sourceOrigin: Origin, sourceSize: Size, destinationBuffer: ^Buffer, destinationOffset: NS.UInteger, destinationBytesPerRow: NS.UInteger, destinationBytesPerImage: NS.UInteger) { msgSend(nil, self, "copyFromTexture:sourceSlice:sourceLevel:sourceOrigin:sourceSize:toBuffer:destinationOffset:destinationBytesPerRow:destinationBytesPerImage:", sourceTexture, sourceSlice, sourceLevel, sourceOrigin, sourceSize, destinationBuffer, destinationOffset, destinationBytesPerRow, destinationBytesPerImage) } @(objc_type=BlitCommandEncoder, objc_name="copyFromTextureExWithOptions") -BlitCommandEncoder_copyFromTextureExWithOptions :: #force_inline proc(self: ^BlitCommandEncoder, sourceTexture: ^Texture, sourceSlice: NS.UInteger, sourceLevel: NS.UInteger, sourceOrigin: Origin, sourceSize: Size, destinationBuffer: ^Buffer, destinationOffset: NS.UInteger, destinationBytesPerRow: NS.UInteger, destinationBytesPerImage: NS.UInteger, options: BlitOption) { +BlitCommandEncoder_copyFromTextureExWithOptions :: #force_inline proc "c" (self: ^BlitCommandEncoder, sourceTexture: ^Texture, sourceSlice: NS.UInteger, sourceLevel: NS.UInteger, sourceOrigin: Origin, sourceSize: Size, destinationBuffer: ^Buffer, destinationOffset: NS.UInteger, destinationBytesPerRow: NS.UInteger, destinationBytesPerImage: NS.UInteger, options: BlitOption) { msgSend(nil, self, "copyFromTexture:sourceSlice:sourceLevel:sourceOrigin:sourceSize:toBuffer:destinationOffset:destinationBytesPerRow:destinationBytesPerImage:options:", sourceTexture, sourceSlice, sourceLevel, sourceOrigin, sourceSize, destinationBuffer, destinationOffset, destinationBytesPerRow, destinationBytesPerImage, options) } @(objc_type=BlitCommandEncoder, objc_name="copyFromTextureWithDestinationOrigin") -BlitCommandEncoder_copyFromTextureWithDestinationOrigin :: #force_inline proc(self: ^BlitCommandEncoder, sourceTexture: ^Texture, sourceSlice: NS.UInteger, sourceLevel: NS.UInteger, sourceOrigin: Origin, sourceSize: Size, destinationTexture: ^Texture, destinationSlice: NS.UInteger, destinationLevel: NS.UInteger, destinationOrigin: Origin) { +BlitCommandEncoder_copyFromTextureWithDestinationOrigin :: #force_inline proc "c" (self: ^BlitCommandEncoder, sourceTexture: ^Texture, sourceSlice: NS.UInteger, sourceLevel: NS.UInteger, sourceOrigin: Origin, sourceSize: Size, destinationTexture: ^Texture, destinationSlice: NS.UInteger, destinationLevel: NS.UInteger, destinationOrigin: Origin) { msgSend(nil, self, "copyFromTexture:sourceSlice:sourceLevel:sourceOrigin:sourceSize:toTexture:destinationSlice:destinationLevel:destinationOrigin:", sourceTexture, sourceSlice, sourceLevel, sourceOrigin, sourceSize, destinationTexture, destinationSlice, destinationLevel, destinationOrigin) } @(objc_type=BlitCommandEncoder, objc_name="copyFromTextureWithCounts") -BlitCommandEncoder_copyFromTextureWithCounts :: #force_inline proc(self: ^BlitCommandEncoder, sourceTexture: ^Texture, sourceSlice: NS.UInteger, sourceLevel: NS.UInteger, destinationTexture: ^Texture, destinationSlice: NS.UInteger, destinationLevel: NS.UInteger, sliceCount: NS.UInteger, levelCount: NS.UInteger) { +BlitCommandEncoder_copyFromTextureWithCounts :: #force_inline proc "c" (self: ^BlitCommandEncoder, sourceTexture: ^Texture, sourceSlice: NS.UInteger, sourceLevel: NS.UInteger, destinationTexture: ^Texture, destinationSlice: NS.UInteger, destinationLevel: NS.UInteger, sliceCount: NS.UInteger, levelCount: NS.UInteger) { msgSend(nil, self, "copyFromTexture:sourceSlice:sourceLevel:toTexture:destinationSlice:destinationLevel:sliceCount:levelCount:", sourceTexture, sourceSlice, sourceLevel, destinationTexture, destinationSlice, destinationLevel, sliceCount, levelCount) } @(objc_type=BlitCommandEncoder, objc_name="copyFromTexture") -BlitCommandEncoder_copyFromTexture :: #force_inline proc(self: ^BlitCommandEncoder, sourceTexture: ^Texture, destinationTexture: ^Texture) { +BlitCommandEncoder_copyFromTexture :: #force_inline proc "c" (self: ^BlitCommandEncoder, sourceTexture: ^Texture, destinationTexture: ^Texture) { msgSend(nil, self, "copyFromTexture:toTexture:", sourceTexture, destinationTexture) } @(objc_type=BlitCommandEncoder, objc_name="copyIndirectCommandBuffer") -BlitCommandEncoder_copyIndirectCommandBuffer :: #force_inline proc(self: ^BlitCommandEncoder, source: ^IndirectCommandBuffer, sourceRange: NS.Range, destination: ^IndirectCommandBuffer, destinationIndex: NS.UInteger) { +BlitCommandEncoder_copyIndirectCommandBuffer :: #force_inline proc "c" (self: ^BlitCommandEncoder, source: ^IndirectCommandBuffer, sourceRange: NS.Range, destination: ^IndirectCommandBuffer, destinationIndex: NS.UInteger) { msgSend(nil, self, "copyIndirectCommandBuffer:sourceRange:destination:destinationIndex:", source, sourceRange, destination, destinationIndex) } @(objc_type=BlitCommandEncoder, objc_name="fillBuffer") -BlitCommandEncoder_fillBuffer :: #force_inline proc(self: ^BlitCommandEncoder, buffer: ^Buffer, range: NS.Range, value: u8) { +BlitCommandEncoder_fillBuffer :: #force_inline proc "c" (self: ^BlitCommandEncoder, buffer: ^Buffer, range: NS.Range, value: u8) { msgSend(nil, self, "fillBuffer:range:value:", buffer, range, value) } @(objc_type=BlitCommandEncoder, objc_name="generateMipmapsForTexture") -BlitCommandEncoder_generateMipmapsForTexture :: #force_inline proc(self: ^BlitCommandEncoder, texture: ^Texture) { +BlitCommandEncoder_generateMipmapsForTexture :: #force_inline proc "c" (self: ^BlitCommandEncoder, texture: ^Texture) { msgSend(nil, self, "generateMipmapsForTexture:", texture) } @(objc_type=BlitCommandEncoder, objc_name="getTextureAccessCounters") -BlitCommandEncoder_getTextureAccessCounters :: #force_inline proc(self: ^BlitCommandEncoder, texture: ^Texture, region: Region, mipLevel: NS.UInteger, slice: NS.UInteger, resetCounters: BOOL, countersBuffer: ^Buffer, countersBufferOffset: NS.UInteger) { +BlitCommandEncoder_getTextureAccessCounters :: #force_inline proc "c" (self: ^BlitCommandEncoder, texture: ^Texture, region: Region, mipLevel: NS.UInteger, slice: NS.UInteger, resetCounters: BOOL, countersBuffer: ^Buffer, countersBufferOffset: NS.UInteger) { msgSend(nil, self, "getTextureAccessCounters:region:mipLevel:slice:resetCounters:countersBuffer:countersBufferOffset:", texture, region, mipLevel, slice, resetCounters, countersBuffer, countersBufferOffset) } @(objc_type=BlitCommandEncoder, objc_name="optimizeContentsForCPUAccess") -BlitCommandEncoder_optimizeContentsForCPUAccess :: #force_inline proc(self: ^BlitCommandEncoder, texture: ^Texture) { +BlitCommandEncoder_optimizeContentsForCPUAccess :: #force_inline proc "c" (self: ^BlitCommandEncoder, texture: ^Texture) { msgSend(nil, self, "optimizeContentsForCPUAccess:", texture) } @(objc_type=BlitCommandEncoder, objc_name="optimizeContentsForCPUAccessWithSliceAndLevel") -BlitCommandEncoder_optimizeContentsForCPUAccessWithSliceAndLevel :: #force_inline proc(self: ^BlitCommandEncoder, texture: ^Texture, slice: NS.UInteger, level: NS.UInteger) { +BlitCommandEncoder_optimizeContentsForCPUAccessWithSliceAndLevel :: #force_inline proc "c" (self: ^BlitCommandEncoder, texture: ^Texture, slice: NS.UInteger, level: NS.UInteger) { msgSend(nil, self, "optimizeContentsForCPUAccess:slice:level:", texture, slice, level) } @(objc_type=BlitCommandEncoder, objc_name="optimizeContentsForGPUAccess") -BlitCommandEncoder_optimizeContentsForGPUAccess :: #force_inline proc(self: ^BlitCommandEncoder, texture: ^Texture) { +BlitCommandEncoder_optimizeContentsForGPUAccess :: #force_inline proc "c" (self: ^BlitCommandEncoder, texture: ^Texture) { msgSend(nil, self, "optimizeContentsForGPUAccess:", texture) } @(objc_type=BlitCommandEncoder, objc_name="optimizeContentsForGPUAccessWithSliceAndLevel") -BlitCommandEncoder_optimizeContentsForGPUAccessWithSliceAndLevel :: #force_inline proc(self: ^BlitCommandEncoder, texture: ^Texture, slice: NS.UInteger, level: NS.UInteger) { +BlitCommandEncoder_optimizeContentsForGPUAccessWithSliceAndLevel :: #force_inline proc "c" (self: ^BlitCommandEncoder, texture: ^Texture, slice: NS.UInteger, level: NS.UInteger) { msgSend(nil, self, "optimizeContentsForGPUAccess:slice:level:", texture, slice, level) } @(objc_type=BlitCommandEncoder, objc_name="optimizeIndirectCommandBuffer") -BlitCommandEncoder_optimizeIndirectCommandBuffer :: #force_inline proc(self: ^BlitCommandEncoder, indirectCommandBuffer: ^Buffer, range: NS.Range) { +BlitCommandEncoder_optimizeIndirectCommandBuffer :: #force_inline proc "c" (self: ^BlitCommandEncoder, indirectCommandBuffer: ^Buffer, range: NS.Range) { msgSend(nil, self, "optimizeIndirectCommandBuffer:withRange:", indirectCommandBuffer, range) } @(objc_type=BlitCommandEncoder, objc_name="resetCommandsInBuffer") -BlitCommandEncoder_resetCommandsInBuffer :: #force_inline proc(self: ^BlitCommandEncoder, buffer: ^Buffer, range: NS.Range) { +BlitCommandEncoder_resetCommandsInBuffer :: #force_inline proc "c" (self: ^BlitCommandEncoder, buffer: ^Buffer, range: NS.Range) { msgSend(nil, self, "resetCommandsInBuffer:withRange:", buffer, range) } @(objc_type=BlitCommandEncoder, objc_name="resetTextureAccessCounters") -BlitCommandEncoder_resetTextureAccessCounters :: #force_inline proc(self: ^BlitCommandEncoder, texture: ^Texture, region: Region, mipLevel: NS.UInteger, slice: NS.UInteger) { +BlitCommandEncoder_resetTextureAccessCounters :: #force_inline proc "c" (self: ^BlitCommandEncoder, texture: ^Texture, region: Region, mipLevel: NS.UInteger, slice: NS.UInteger) { msgSend(nil, self, "resetTextureAccessCounters:region:mipLevel:slice:", texture, region, mipLevel, slice) } @(objc_type=BlitCommandEncoder, objc_name="resolveCounters") -BlitCommandEncoder_resolveCounters :: #force_inline proc(self: ^BlitCommandEncoder, sampleBuffer: ^Buffer, range: NS.Range, destinationBuffer: ^Buffer, destinationOffset: NS.UInteger) { +BlitCommandEncoder_resolveCounters :: #force_inline proc "c" (self: ^BlitCommandEncoder, sampleBuffer: ^Buffer, range: NS.Range, destinationBuffer: ^Buffer, destinationOffset: NS.UInteger) { msgSend(nil, self, "resolveCounters:inRange:destinationBuffer:destinationOffset:", sampleBuffer, range, destinationBuffer, destinationOffset) } @(objc_type=BlitCommandEncoder, objc_name="sampleCountersInBuffer") -BlitCommandEncoder_sampleCountersInBuffer :: #force_inline proc(self: ^BlitCommandEncoder, sampleBuffer: ^Buffer, sampleIndex: NS.UInteger, barrier: BOOL) { +BlitCommandEncoder_sampleCountersInBuffer :: #force_inline proc "c" (self: ^BlitCommandEncoder, sampleBuffer: ^Buffer, sampleIndex: NS.UInteger, barrier: BOOL) { msgSend(nil, self, "sampleCountersInBuffer:atSampleIndex:withBarrier:", sampleBuffer, sampleIndex, barrier) } @(objc_type=BlitCommandEncoder, objc_name="synchronizeResource") -BlitCommandEncoder_synchronizeResource :: #force_inline proc(self: ^BlitCommandEncoder, resource: ^Resource) { +BlitCommandEncoder_synchronizeResource :: #force_inline proc "c" (self: ^BlitCommandEncoder, resource: ^Resource) { msgSend(nil, self, "synchronizeResource:", resource) } @(objc_type=BlitCommandEncoder, objc_name="synchronizeTexture") -BlitCommandEncoder_synchronizeTexture :: #force_inline proc(self: ^BlitCommandEncoder, texture: ^Texture, slice: NS.UInteger, level: NS.UInteger) { +BlitCommandEncoder_synchronizeTexture :: #force_inline proc "c" (self: ^BlitCommandEncoder, texture: ^Texture, slice: NS.UInteger, level: NS.UInteger) { msgSend(nil, self, "synchronizeTexture:slice:level:", texture, slice, level) } @(objc_type=BlitCommandEncoder, objc_name="updateFence") -BlitCommandEncoder_updateFence :: #force_inline proc(self: ^BlitCommandEncoder, fence: ^Fence) { +BlitCommandEncoder_updateFence :: #force_inline proc "c" (self: ^BlitCommandEncoder, fence: ^Fence) { msgSend(nil, self, "updateFence:", fence) } @(objc_type=BlitCommandEncoder, objc_name="waitForFence") -BlitCommandEncoder_waitForFence :: #force_inline proc(self: ^BlitCommandEncoder, fence: ^Fence) { +BlitCommandEncoder_waitForFence :: #force_inline proc "c" (self: ^BlitCommandEncoder, fence: ^Fence) { msgSend(nil, self, "waitForFence:", fence) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - Buffer -Class Methods: -Methods: - addDebugMarker - contents - didModifyRange - length - newRemoteBufferViewForDevice - newTextureWithDescriptor - remoteStorageBuffer - removeAllDebugMarkers -*/ @(objc_class="MTLBuffer") Buffer :: struct { using _: Resource } @(objc_type=Buffer, objc_name="addDebugMarker") -Buffer_addDebugMarker :: #force_inline proc(self: ^Buffer, marker: ^NS.String, range: NS.Range) { +Buffer_addDebugMarker :: #force_inline proc "c" (self: ^Buffer, marker: ^NS.String, range: NS.Range) { msgSend(nil, self, "addDebugMarker:range:", marker, range) } @(objc_type=Buffer, objc_name="contents") -Buffer_contents :: #force_inline proc(self: ^Buffer) -> []byte { +Buffer_contents :: #force_inline proc "c" (self: ^Buffer) -> []byte { contents := msgSend([^]byte, self, "contents") length := Buffer_length(self) return contents[:length] } @(objc_type=Buffer, objc_name="contentsPointer") -Buffer_contentsPointer :: #force_inline proc(self: ^Buffer) -> rawptr { +Buffer_contentsPointer :: #force_inline proc "c" (self: ^Buffer) -> rawptr { return msgSend(rawptr, self, "contents") } @(objc_type=Buffer, objc_name="contentsAsSlice") -Buffer_contentsAsSlice :: #force_inline proc(self: ^Buffer, $T: typeid/[]$E) -> T { +Buffer_contentsAsSlice :: #force_inline proc "c" (self: ^Buffer, $T: typeid/[]$E) -> T { contents := msgSend([^]byte, self, "contents") length := Buffer_length(self) return mem.slice_data_cast(T, contents[:length]) } @(objc_type=Buffer, objc_name="contentsAsType") -Buffer_contentsAsType :: #force_inline proc(self: ^Buffer, $T: typeid, offset: uintptr = 0) -> ^T { +Buffer_contentsAsType :: #force_inline proc "c" (self: ^Buffer, $T: typeid, offset: uintptr = 0) -> ^T { ptr := msgSend(rawptr, self, "contents") return (^T)(uintptr(ptr) + offset) } @(objc_type=Buffer, objc_name="didModifyRange") -Buffer_didModifyRange :: #force_inline proc(self: ^Buffer, range: NS.Range) { +Buffer_didModifyRange :: #force_inline proc "c" (self: ^Buffer, range: NS.Range) { msgSend(nil, self, "didModifyRange:", range) } @(objc_type=Buffer, objc_name="length") -Buffer_length :: #force_inline proc(self: ^Buffer) -> NS.UInteger { +Buffer_length :: #force_inline proc "c" (self: ^Buffer) -> NS.UInteger { return msgSend(NS.UInteger, self, "length") } @(objc_type=Buffer, objc_name="newRemoteBufferViewForDevice") -Buffer_newRemoteBufferViewForDevice :: #force_inline proc(self: ^Buffer, device: ^Device) -> ^Buffer { +Buffer_newRemoteBufferViewForDevice :: #force_inline proc "c" (self: ^Buffer, device: ^Device) -> ^Buffer { return msgSend(^Buffer, self, "newRemoteBufferViewForDevice:", device) } @(objc_type=Buffer, objc_name="newTexture") -Buffer_newTexture :: #force_inline proc(self: ^Buffer, descriptor: ^TextureDescriptor, offset: NS.UInteger, bytesPerRow: NS.UInteger) -> ^Texture { +Buffer_newTexture :: #force_inline proc "c" (self: ^Buffer, descriptor: ^TextureDescriptor, offset: NS.UInteger, bytesPerRow: NS.UInteger) -> ^Texture { return msgSend(^Texture, self, "newTextureWithDescriptor:offset:bytesPerRow:", descriptor, offset, bytesPerRow) } @(objc_type=Buffer, objc_name="remoteStorageBuffer") -Buffer_remoteStorageBuffer :: #force_inline proc(self: ^Buffer) -> ^Buffer { +Buffer_remoteStorageBuffer :: #force_inline proc "c" (self: ^Buffer) -> ^Buffer { return msgSend(^Buffer, self, "remoteStorageBuffer") } @(objc_type=Buffer, objc_name="removeAllDebugMarkers") -Buffer_removeAllDebugMarkers :: #force_inline proc(self: ^Buffer) { +Buffer_removeAllDebugMarkers :: #force_inline proc "c" (self: ^Buffer) { msgSend(nil, self, "removeAllDebugMarkers") } +@(objc_type=Buffer, objc_name="newRemoveBufferViewForDevice") +Buffer_newRemoveBufferViewForDevice :: #force_inline proc "c" (self: ^Buffer, device: ^Device) -> ^Buffer { + return msgSend(^Buffer, self, "newRemoteBufferViewForDevice:", device) +} +@(objc_type=Buffer, objc_name="gpuAddress") +Buffer_gpuAddress :: #force_inline proc "c" (self: ^Buffer) -> u64 { + return msgSend(u64, self, "gpuAddress") +} + //////////////////////////////////////////////////////////////////////////////// -/* -Class: - CaptureScope -Class Methods: -Methods: - beginScope - commandQueue - device - endScope - label - setLabel -*/ @(objc_class="MTLCaptureScope") CaptureScope :: struct { using _: NS.Object } @(objc_type=CaptureScope, objc_name="beginScope") -CaptureScope_beginScope :: #force_inline proc(self: ^CaptureScope) { +CaptureScope_beginScope :: #force_inline proc "c" (self: ^CaptureScope) { msgSend(nil, self, "beginScope") } @(objc_type=CaptureScope, objc_name="commandQueue") -CaptureScope_commandQueue :: #force_inline proc(self: ^CaptureScope) -> ^CommandQueue { +CaptureScope_commandQueue :: #force_inline proc "c" (self: ^CaptureScope) -> ^CommandQueue { return msgSend(^CommandQueue, self, "commandQueue") } @(objc_type=CaptureScope, objc_name="device") -CaptureScope_device :: #force_inline proc(self: ^CaptureScope) -> ^Device { +CaptureScope_device :: #force_inline proc "c" (self: ^CaptureScope) -> ^Device { return msgSend(^Device, self, "device") } @(objc_type=CaptureScope, objc_name="endScope") -CaptureScope_endScope :: #force_inline proc(self: ^CaptureScope) { +CaptureScope_endScope :: #force_inline proc "c" (self: ^CaptureScope) { msgSend(nil, self, "endScope") } @(objc_type=CaptureScope, objc_name="label") -CaptureScope_label :: #force_inline proc(self: ^CaptureScope) -> ^NS.String { +CaptureScope_label :: #force_inline proc "c" (self: ^CaptureScope) -> ^NS.String { return msgSend(^NS.String, self, "label") } @(objc_type=CaptureScope, objc_name="setLabel") -CaptureScope_setLabel :: #force_inline proc(self: ^CaptureScope, label: ^NS.String) { +CaptureScope_setLabel :: #force_inline proc "c" (self: ^CaptureScope, label: ^NS.String) { msgSend(nil, self, "setLabel:", label) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - CommandBuffer -Class Methods: -Methods: - GPUEndTime - GPUStartTime - accelerationStructureCommandEncoder - addCompletedHandler - addScheduledHandler - blitCommandEncoder - blitCommandEncoderWithDescriptor - commandQueue - commit - computeCommandEncoder - computeCommandEncoderWithDescriptor - computeCommandEncoderWithDispatchType - device - encodeSignalEvent - encodeWaitForEvent - enqueue - error - errorOptions - kernelEndTime - kernelStartTime - label - logs - parallelRenderCommandEncoderWithDescriptor - popDebugGroup - presentDrawable - presentDrawable - presentDrawable - pushDebugGroup - renderCommandEncoderWithDescriptor - resourceStateCommandEncoder - resourceStateCommandEncoderWithDescriptor - retainedReferences - setLabel - status - waitUntilCompleted - waitUntilScheduled -*/ @(objc_class="MTLCommandBuffer") CommandBuffer :: struct { using _: NS.Object } @(objc_type=CommandBuffer, objc_name="GPUEndTime") -CommandBuffer_GPUEndTime :: #force_inline proc(self: ^CommandBuffer) -> CFTimeInterval { +CommandBuffer_GPUEndTime :: #force_inline proc "c" (self: ^CommandBuffer) -> CFTimeInterval { return msgSend(CFTimeInterval, self, "GPUEndTime") } @(objc_type=CommandBuffer, objc_name="GPUStartTime") -CommandBuffer_GPUStartTime :: #force_inline proc(self: ^CommandBuffer) -> CFTimeInterval { +CommandBuffer_GPUStartTime :: #force_inline proc "c" (self: ^CommandBuffer) -> CFTimeInterval { return msgSend(CFTimeInterval, self, "GPUStartTime") } @(objc_type=CommandBuffer, objc_name="accelerationStructureCommandEncoder") -CommandBuffer_accelerationStructureCommandEncoder :: #force_inline proc(self: ^CommandBuffer) -> ^AccelerationStructureCommandEncoder { +CommandBuffer_accelerationStructureCommandEncoder :: #force_inline proc "c" (self: ^CommandBuffer) -> ^AccelerationStructureCommandEncoder { return msgSend(^AccelerationStructureCommandEncoder, self, "accelerationStructureCommandEncoder") } +@(objc_type=CommandBuffer, objc_name="accelerationStructureCommandEncoderWithDescriptor") +CommandBuffer_accelerationStructureCommandEncoderWithDescriptor :: #force_inline proc "c" (self: ^CommandBuffer, descriptor: ^AccelerationStructurePassDescriptor) -> ^AccelerationStructureCommandEncoder { + return msgSend(^AccelerationStructureCommandEncoder, self, "accelerationStructureCommandEncoderWithDescriptor:", descriptor) +} @(objc_type=CommandBuffer, objc_name="addCompletedHandler") -CommandBuffer_addCompletedHandler :: #force_inline proc(self: ^CommandBuffer, block: CommandBufferHandler) { +CommandBuffer_addCompletedHandler :: #force_inline proc "c" (self: ^CommandBuffer, block: CommandBufferHandler) { msgSend(nil, self, "addCompletedHandler:", block) } @(objc_type=CommandBuffer, objc_name="addScheduledHandler") -CommandBuffer_addScheduledHandler :: #force_inline proc(self: ^CommandBuffer, block: CommandBufferHandler) { +CommandBuffer_addScheduledHandler :: #force_inline proc "c" (self: ^CommandBuffer, block: CommandBufferHandler) { msgSend(nil, self, "addScheduledHandler:", block) } @(objc_type=CommandBuffer, objc_name="blitCommandEncoder") -CommandBuffer_blitCommandEncoder :: #force_inline proc(self: ^CommandBuffer) -> ^BlitCommandEncoder { +CommandBuffer_blitCommandEncoder :: #force_inline proc "c" (self: ^CommandBuffer) -> ^BlitCommandEncoder { return msgSend(^BlitCommandEncoder, self, "blitCommandEncoder") } @(objc_type=CommandBuffer, objc_name="blitCommandEncoderWithDescriptor") -CommandBuffer_blitCommandEncoderWithDescriptor :: #force_inline proc(self: ^CommandBuffer, blitPassDescriptor: ^BlitPassDescriptor) -> ^BlitCommandEncoder { +CommandBuffer_blitCommandEncoderWithDescriptor :: #force_inline proc "c" (self: ^CommandBuffer, blitPassDescriptor: ^BlitPassDescriptor) -> ^BlitCommandEncoder { return msgSend(^BlitCommandEncoder, self, "blitCommandEncoderWithDescriptor:", blitPassDescriptor) } @(objc_type=CommandBuffer, objc_name="commandQueue") -CommandBuffer_commandQueue :: #force_inline proc(self: ^CommandBuffer) -> ^CommandQueue { +CommandBuffer_commandQueue :: #force_inline proc "c" (self: ^CommandBuffer) -> ^CommandQueue { return msgSend(^CommandQueue, self, "commandQueue") } @(objc_type=CommandBuffer, objc_name="commit") -CommandBuffer_commit :: #force_inline proc(self: ^CommandBuffer) { +CommandBuffer_commit :: #force_inline proc "c" (self: ^CommandBuffer) { msgSend(nil, self, "commit") } @(objc_type=CommandBuffer, objc_name="computeCommandEncoder") -CommandBuffer_computeCommandEncoder :: #force_inline proc(self: ^CommandBuffer) -> ^ComputeCommandEncoder { +CommandBuffer_computeCommandEncoder :: #force_inline proc "c" (self: ^CommandBuffer) -> ^ComputeCommandEncoder { return msgSend(^ComputeCommandEncoder, self, "computeCommandEncoder") } @(objc_type=CommandBuffer, objc_name="computeCommandEncoderWithDescriptor") -CommandBuffer_computeCommandEncoderWithDescriptor :: #force_inline proc(self: ^CommandBuffer, computePassDescriptor: ^ComputePassDescriptor) -> ^ComputeCommandEncoder { +CommandBuffer_computeCommandEncoderWithDescriptor :: #force_inline proc "c" (self: ^CommandBuffer, computePassDescriptor: ^ComputePassDescriptor) -> ^ComputeCommandEncoder { return msgSend(^ComputeCommandEncoder, self, "computeCommandEncoderWithDescriptor:", computePassDescriptor) } @(objc_type=CommandBuffer, objc_name="computeCommandEncoderWithDispatchType") -CommandBuffer_computeCommandEncoderWithDispatchType :: #force_inline proc(self: ^CommandBuffer, dispatchType: DispatchType) -> ^ComputeCommandEncoder { +CommandBuffer_computeCommandEncoderWithDispatchType :: #force_inline proc "c" (self: ^CommandBuffer, dispatchType: DispatchType) -> ^ComputeCommandEncoder { return msgSend(^ComputeCommandEncoder, self, "computeCommandEncoderWithDispatchType:", dispatchType) } @(objc_type=CommandBuffer, objc_name="device") -CommandBuffer_device :: #force_inline proc(self: ^CommandBuffer) -> ^Device { +CommandBuffer_device :: #force_inline proc "c" (self: ^CommandBuffer) -> ^Device { return msgSend(^Device, self, "device") } @(objc_type=CommandBuffer, objc_name="encodeSignalEvent") -CommandBuffer_encodeSignalEvent :: #force_inline proc(self: ^CommandBuffer, event: ^Event, value: u64) { +CommandBuffer_encodeSignalEvent :: #force_inline proc "c" (self: ^CommandBuffer, event: ^Event, value: u64) { msgSend(nil, self, "encodeSignalEvent:value:", event, value) } @(objc_type=CommandBuffer, objc_name="encodeWaitForEvent") -CommandBuffer_encodeWaitForEvent :: #force_inline proc(self: ^CommandBuffer, event: ^Event, value: u64) { +CommandBuffer_encodeWaitForEvent :: #force_inline proc "c" (self: ^CommandBuffer, event: ^Event, value: u64) { msgSend(nil, self, "encodeWaitForEvent:value:", event, value) } @(objc_type=CommandBuffer, objc_name="enqueue") -CommandBuffer_enqueue :: #force_inline proc(self: ^CommandBuffer) { +CommandBuffer_enqueue :: #force_inline proc "c" (self: ^CommandBuffer) { msgSend(nil, self, "enqueue") } @(objc_type=CommandBuffer, objc_name="error") -CommandBuffer_error :: #force_inline proc(self: ^CommandBuffer) -> ^NS.Error { +CommandBuffer_error :: #force_inline proc "c" (self: ^CommandBuffer) -> ^NS.Error { return msgSend(^NS.Error, self, "error") } @(objc_type=CommandBuffer, objc_name="errorOptions") -CommandBuffer_errorOptions :: #force_inline proc(self: ^CommandBuffer) -> CommandBufferErrorOption { +CommandBuffer_errorOptions :: #force_inline proc "c" (self: ^CommandBuffer) -> CommandBufferErrorOption { return msgSend(CommandBufferErrorOption, self, "errorOptions") } @(objc_type=CommandBuffer, objc_name="kernelEndTime") -CommandBuffer_kernelEndTime :: #force_inline proc(self: ^CommandBuffer) -> CFTimeInterval { +CommandBuffer_kernelEndTime :: #force_inline proc "c" (self: ^CommandBuffer) -> CFTimeInterval { return msgSend(CFTimeInterval, self, "kernelEndTime") } @(objc_type=CommandBuffer, objc_name="kernelStartTime") -CommandBuffer_kernelStartTime :: #force_inline proc(self: ^CommandBuffer) -> CFTimeInterval { +CommandBuffer_kernelStartTime :: #force_inline proc "c" (self: ^CommandBuffer) -> CFTimeInterval { return msgSend(CFTimeInterval, self, "kernelStartTime") } @(objc_type=CommandBuffer, objc_name="label") -CommandBuffer_label :: #force_inline proc(self: ^CommandBuffer) -> ^NS.String { +CommandBuffer_label :: #force_inline proc "c" (self: ^CommandBuffer) -> ^NS.String { return msgSend(^NS.String, self, "label") } @(objc_type=CommandBuffer, objc_name="logs") -CommandBuffer_logs :: #force_inline proc(self: ^CommandBuffer) -> ^LogContainer { +CommandBuffer_logs :: #force_inline proc "c" (self: ^CommandBuffer) -> ^LogContainer { return msgSend(^LogContainer, self, "logs") } @(objc_type=CommandBuffer, objc_name="parallelRenderCommandEncoder") -CommandBuffer_parallelRenderCommandEncoder :: #force_inline proc(self: ^CommandBuffer, renderPassDescriptor: ^RenderPassDescriptor) -> ^ParallelRenderCommandEncoder { +CommandBuffer_parallelRenderCommandEncoder :: #force_inline proc "c" (self: ^CommandBuffer, renderPassDescriptor: ^RenderPassDescriptor) -> ^ParallelRenderCommandEncoder { return msgSend(^ParallelRenderCommandEncoder, self, "parallelRenderCommandEncoderWithDescriptor:", renderPassDescriptor) } @(objc_type=CommandBuffer, objc_name="popDebugGroup") -CommandBuffer_popDebugGroup :: #force_inline proc(self: ^CommandBuffer) { +CommandBuffer_popDebugGroup :: #force_inline proc "c" (self: ^CommandBuffer) { msgSend(nil, self, "popDebugGroup") } @(objc_type=CommandBuffer, objc_name="presentDrawable") -CommandBuffer_presentDrawable :: #force_inline proc(self: ^CommandBuffer, drawable: ^Drawable) { +CommandBuffer_presentDrawable :: #force_inline proc "c" (self: ^CommandBuffer, drawable: ^Drawable) { msgSend(nil, self, "presentDrawable:", drawable) } @(objc_type=CommandBuffer, objc_name="presentDrawableAfterMinimumDuration") -CommandBuffer_presentDrawableAfterMinimumDuration :: #force_inline proc(self: ^CommandBuffer, drawable: ^Drawable, duration: CFTimeInterval) { +CommandBuffer_presentDrawableAfterMinimumDuration :: #force_inline proc "c" (self: ^CommandBuffer, drawable: ^Drawable, duration: CFTimeInterval) { msgSend(nil, self, "presentDrawable:afterMinimumDuration:", drawable, duration) } @(objc_type=CommandBuffer, objc_name="presentDrawableAtTime") -CommandBuffer_presentDrawableAtTime :: #force_inline proc(self: ^CommandBuffer, drawable: ^Drawable, presentationTime: CFTimeInterval) { +CommandBuffer_presentDrawableAtTime :: #force_inline proc "c" (self: ^CommandBuffer, drawable: ^Drawable, presentationTime: CFTimeInterval) { msgSend(nil, self, "presentDrawable:atTime:", drawable, presentationTime) } @(objc_type=CommandBuffer, objc_name="pushDebugGroup") -CommandBuffer_pushDebugGroup :: #force_inline proc(self: ^CommandBuffer, string: ^NS.String) { +CommandBuffer_pushDebugGroup :: #force_inline proc "c" (self: ^CommandBuffer, string: ^NS.String) { msgSend(nil, self, "pushDebugGroup:", string) } @(objc_type=CommandBuffer, objc_name="renderCommandEncoderWithDescriptor") -CommandBuffer_renderCommandEncoderWithDescriptor :: #force_inline proc(self: ^CommandBuffer, renderPassDescriptor: ^RenderPassDescriptor) -> ^RenderCommandEncoder { +CommandBuffer_renderCommandEncoderWithDescriptor :: #force_inline proc "c" (self: ^CommandBuffer, renderPassDescriptor: ^RenderPassDescriptor) -> ^RenderCommandEncoder { return msgSend(^RenderCommandEncoder, self, "renderCommandEncoderWithDescriptor:", renderPassDescriptor) } @(objc_type=CommandBuffer, objc_name="resourceStateCommandEncoder") -CommandBuffer_resourceStateCommandEncoder :: #force_inline proc(self: ^CommandBuffer) -> ^CommandBuffer { +CommandBuffer_resourceStateCommandEncoder :: #force_inline proc "c" (self: ^CommandBuffer) -> ^CommandBuffer { return msgSend(^CommandBuffer, self, "resourceStateCommandEncoder") } @(objc_type=CommandBuffer, objc_name="resourceStateCommandEncoderWithDescriptor") -CommandBuffer_resourceStateCommandEncoderWithDescriptor :: #force_inline proc(self: ^CommandBuffer, resourceStatePassDescriptor: ^ResourceStatePassDescriptor) -> ^ResourceStateCommandEncoder { +CommandBuffer_resourceStateCommandEncoderWithDescriptor :: #force_inline proc "c" (self: ^CommandBuffer, resourceStatePassDescriptor: ^ResourceStatePassDescriptor) -> ^ResourceStateCommandEncoder { return msgSend(^ResourceStateCommandEncoder, self, "resourceStateCommandEncoderWithDescriptor:", resourceStatePassDescriptor) } @(objc_type=CommandBuffer, objc_name="retainedReferences") -CommandBuffer_retainedReferences :: #force_inline proc(self: ^CommandBuffer) -> BOOL { +CommandBuffer_retainedReferences :: #force_inline proc "c" (self: ^CommandBuffer) -> BOOL { return msgSend(BOOL, self, "retainedReferences") } @(objc_type=CommandBuffer, objc_name="setLabel") -CommandBuffer_setLabel :: #force_inline proc(self: ^CommandBuffer, label: ^NS.String) { +CommandBuffer_setLabel :: #force_inline proc "c" (self: ^CommandBuffer, label: ^NS.String) { msgSend(nil, self, "setLabel:", label) } @(objc_type=CommandBuffer, objc_name="status") -CommandBuffer_status :: #force_inline proc(self: ^CommandBuffer) -> CommandBufferStatus { +CommandBuffer_status :: #force_inline proc "c" (self: ^CommandBuffer) -> CommandBufferStatus { return msgSend(CommandBufferStatus, self, "status") } @(objc_type=CommandBuffer, objc_name="waitUntilCompleted") -CommandBuffer_waitUntilCompleted :: #force_inline proc(self: ^CommandBuffer) { +CommandBuffer_waitUntilCompleted :: #force_inline proc "c" (self: ^CommandBuffer) { msgSend(nil, self, "waitUntilCompleted") } @(objc_type=CommandBuffer, objc_name="waitUntilScheduled") -CommandBuffer_waitUntilScheduled :: #force_inline proc(self: ^CommandBuffer) { +CommandBuffer_waitUntilScheduled :: #force_inline proc "c" (self: ^CommandBuffer) { msgSend(nil, self, "waitUntilScheduled") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - CommandBufferEncoderInfo -Class Methods: -Methods: - debugSignposts - errorState - label -*/ @(objc_class="MTLCommandBufferEncoderInfo") CommandBufferEncoderInfo :: struct { using _: NS.Object } @(objc_type=CommandBufferEncoderInfo, objc_name="debugSignposts") -CommandBufferEncoderInfo_debugSignposts :: #force_inline proc(self: ^CommandBufferEncoderInfo) -> ^NS.Array { +CommandBufferEncoderInfo_debugSignposts :: #force_inline proc "c" (self: ^CommandBufferEncoderInfo) -> ^NS.Array { return msgSend(^NS.Array, self, "debugSignposts") } @(objc_type=CommandBufferEncoderInfo, objc_name="errorState") -CommandBufferEncoderInfo_errorState :: #force_inline proc(self: ^CommandBufferEncoderInfo) -> CommandEncoderErrorState { +CommandBufferEncoderInfo_errorState :: #force_inline proc "c" (self: ^CommandBufferEncoderInfo) -> CommandEncoderErrorState { return msgSend(CommandEncoderErrorState, self, "errorState") } @(objc_type=CommandBufferEncoderInfo, objc_name="label") -CommandBufferEncoderInfo_label :: #force_inline proc(self: ^CommandBufferEncoderInfo) -> ^NS.String { +CommandBufferEncoderInfo_label :: #force_inline proc "c" (self: ^CommandBufferEncoderInfo) -> ^NS.String { return msgSend(^NS.String, self, "label") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - CommandEncoder -Class Methods: -Methods: - device - endEncoding - insertDebugSignpost - label - popDebugGroup - pushDebugGroup - setLabel -*/ @(objc_class="MTLCommandEncoder") CommandEncoder :: struct { using _: NS.Object } @(objc_type=CommandEncoder, objc_name="device") -CommandEncoder_device :: #force_inline proc(self: ^CommandEncoder) -> ^Device { +CommandEncoder_device :: #force_inline proc "c" (self: ^CommandEncoder) -> ^Device { return msgSend(^Device, self, "device") } @(objc_type=CommandEncoder, objc_name="endEncoding") -CommandEncoder_endEncoding :: #force_inline proc(self: ^CommandEncoder) { +CommandEncoder_endEncoding :: #force_inline proc "c" (self: ^CommandEncoder) { msgSend(nil, self, "endEncoding") } @(objc_type=CommandEncoder, objc_name="insertDebugSignpost") -CommandEncoder_insertDebugSignpost :: #force_inline proc(self: ^CommandEncoder, string: ^NS.String) { +CommandEncoder_insertDebugSignpost :: #force_inline proc "c" (self: ^CommandEncoder, string: ^NS.String) { msgSend(nil, self, "insertDebugSignpost:", string) } @(objc_type=CommandEncoder, objc_name="label") -CommandEncoder_label :: #force_inline proc(self: ^CommandEncoder) -> ^NS.String { +CommandEncoder_label :: #force_inline proc "c" (self: ^CommandEncoder) -> ^NS.String { return msgSend(^NS.String, self, "label") } @(objc_type=CommandEncoder, objc_name="popDebugGroup") -CommandEncoder_popDebugGroup :: #force_inline proc(self: ^CommandEncoder) { +CommandEncoder_popDebugGroup :: #force_inline proc "c" (self: ^CommandEncoder) { msgSend(nil, self, "popDebugGroup") } @(objc_type=CommandEncoder, objc_name="pushDebugGroup") -CommandEncoder_pushDebugGroup :: #force_inline proc(self: ^CommandEncoder, string: ^NS.String) { +CommandEncoder_pushDebugGroup :: #force_inline proc "c" (self: ^CommandEncoder, string: ^NS.String) { msgSend(nil, self, "pushDebugGroup:", string) } @(objc_type=CommandEncoder, objc_name="setLabel") -CommandEncoder_setLabel :: #force_inline proc(self: ^CommandEncoder, label: ^NS.String) { +CommandEncoder_setLabel :: #force_inline proc "c" (self: ^CommandEncoder, label: ^NS.String) { msgSend(nil, self, "setLabel:", label) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - CommandQueue -Class Methods: -Methods: - commandBuffer - commandBufferWithDescriptor - commandBufferWithUnretainedReferences - device - insertDebugCaptureBoundary - label - setLabel -*/ @(objc_class="MTLCommandQueue") CommandQueue :: struct { using _: NS.Object } @(objc_type=CommandQueue, objc_name="commandBuffer") -CommandQueue_commandBuffer :: #force_inline proc(self: ^CommandQueue) -> ^CommandBuffer { +CommandQueue_commandBuffer :: #force_inline proc "c" (self: ^CommandQueue) -> ^CommandBuffer { return msgSend(^CommandBuffer, self, "commandBuffer") } @(objc_type=CommandQueue, objc_name="commandBufferWithDescriptor") -CommandQueue_commandBufferWithDescriptor :: #force_inline proc(self: ^CommandQueue, descriptor: ^CommandBufferDescriptor) -> ^CommandQueue { +CommandQueue_commandBufferWithDescriptor :: #force_inline proc "c" (self: ^CommandQueue, descriptor: ^CommandBufferDescriptor) -> ^CommandQueue { return msgSend(^CommandQueue, self, "commandBufferWithDescriptor:", descriptor) } @(objc_type=CommandQueue, objc_name="commandBufferWithUnretainedReferences") -CommandQueue_commandBufferWithUnretainedReferences :: #force_inline proc(self: ^CommandQueue) -> ^CommandQueue { +CommandQueue_commandBufferWithUnretainedReferences :: #force_inline proc "c" (self: ^CommandQueue) -> ^CommandQueue { return msgSend(^CommandQueue, self, "commandBufferWithUnretainedReferences") } @(objc_type=CommandQueue, objc_name="device") -CommandQueue_device :: #force_inline proc(self: ^CommandQueue) -> ^Device { +CommandQueue_device :: #force_inline proc "c" (self: ^CommandQueue) -> ^Device { return msgSend(^Device, self, "device") } @(objc_type=CommandQueue, objc_name="insertDebugCaptureBoundary") -CommandQueue_insertDebugCaptureBoundary :: #force_inline proc(self: ^CommandQueue) { +CommandQueue_insertDebugCaptureBoundary :: #force_inline proc "c" (self: ^CommandQueue) { msgSend(nil, self, "insertDebugCaptureBoundary") } @(objc_type=CommandQueue, objc_name="label") -CommandQueue_label :: #force_inline proc(self: ^CommandQueue) -> ^NS.String { +CommandQueue_label :: #force_inline proc "c" (self: ^CommandQueue) -> ^NS.String { return msgSend(^NS.String, self, "label") } @(objc_type=CommandQueue, objc_name="setLabel") -CommandQueue_setLabel :: #force_inline proc(self: ^CommandQueue, label: ^NS.String) { +CommandQueue_setLabel :: #force_inline proc "c" (self: ^CommandQueue, label: ^NS.String) { msgSend(nil, self, "setLabel:", label) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - ComputeCommandEncoder -Class Methods: -Methods: - dispatchThreadgroups - dispatchThreadgroupsWithIndirectBuffer - dispatchThreads - dispatchType - executeCommandsInBuffer - executeCommandsInBuffer - memoryBarrierWithResources - memoryBarrierWithScope - sampleCountersInBuffer - setAccelerationStructure - setBuffer - setBufferOffset - setBuffers - setBytes - setComputePipelineState - setImageblockWidth - setIntersectionFunctionTable - setIntersectionFunctionTables - setSamplerState - setSamplerState - setSamplerStates - setSamplerStates - setStageInRegion - setStageInRegionWithIndirectBuffer - setTexture - setTextures - setThreadgroupMemoryLength - setVisibleFunctionTable - setVisibleFunctionTables - updateFence - useHeap - useHeaps - useResource - useResources - waitForFence -*/ @(objc_class="MTLComputeCommandEncoder") ComputeCommandEncoder :: struct { using _: CommandEncoder } @(objc_type=ComputeCommandEncoder, objc_name="dispatchThreadgroups") -ComputeCommandEncoder_dispatchThreadgroups :: #force_inline proc(self: ^ComputeCommandEncoder, threadgroupsPerGrid: Size, threadsPerThreadgroup: Size) { +ComputeCommandEncoder_dispatchThreadgroups :: #force_inline proc "c" (self: ^ComputeCommandEncoder, threadgroupsPerGrid: Size, threadsPerThreadgroup: Size) { msgSend(nil, self, "dispatchThreadgroups:threadsPerThreadgroup:", threadgroupsPerGrid, threadsPerThreadgroup) } @(objc_type=ComputeCommandEncoder, objc_name="dispatchThreadgroupsWithIndirectBuffer") -ComputeCommandEncoder_dispatchThreadgroupsWithIndirectBuffer :: #force_inline proc(self: ^ComputeCommandEncoder, indirectBuffer: ^Buffer, indirectBufferOffset: NS.UInteger, threadsPerThreadgroup: Size) { +ComputeCommandEncoder_dispatchThreadgroupsWithIndirectBuffer :: #force_inline proc "c" (self: ^ComputeCommandEncoder, indirectBuffer: ^Buffer, indirectBufferOffset: NS.UInteger, threadsPerThreadgroup: Size) { msgSend(nil, self, "dispatchThreadgroupsWithIndirectBuffer:indirectBufferOffset:threadsPerThreadgroup:", indirectBuffer, indirectBufferOffset, threadsPerThreadgroup) } @(objc_type=ComputeCommandEncoder, objc_name="dispatchThreads") -ComputeCommandEncoder_dispatchThreads :: #force_inline proc(self: ^ComputeCommandEncoder, threadsPerGrid: Size, threadsPerThreadgroup: Size) { +ComputeCommandEncoder_dispatchThreads :: #force_inline proc "c" (self: ^ComputeCommandEncoder, threadsPerGrid: Size, threadsPerThreadgroup: Size) { msgSend(nil, self, "dispatchThreads:threadsPerThreadgroup:", threadsPerGrid, threadsPerThreadgroup) } @(objc_type=ComputeCommandEncoder, objc_name="dispatchType") -ComputeCommandEncoder_dispatchType :: #force_inline proc(self: ^ComputeCommandEncoder) -> DispatchType { +ComputeCommandEncoder_dispatchType :: #force_inline proc "c" (self: ^ComputeCommandEncoder) -> DispatchType { return msgSend(DispatchType, self, "dispatchType") } @(objc_type=ComputeCommandEncoder, objc_name="executeCommandsInBuffer") -ComputeCommandEncoder_executeCommandsInBuffer :: #force_inline proc(self: ^ComputeCommandEncoder, indirectCommandbuffer: ^Buffer, indirectRangeBuffer: ^Buffer, indirectBufferOffset: NS.UInteger) { +ComputeCommandEncoder_executeCommandsInBuffer :: #force_inline proc "c" (self: ^ComputeCommandEncoder, indirectCommandbuffer: ^Buffer, indirectRangeBuffer: ^Buffer, indirectBufferOffset: NS.UInteger) { msgSend(nil, self, "executeCommandsInBuffer:indirectBuffer:indirectBufferOffset:", indirectCommandbuffer, indirectRangeBuffer, indirectBufferOffset) } @(objc_type=ComputeCommandEncoder, objc_name="executeCommandsInBufferWithRange") -ComputeCommandEncoder_executeCommandsInBufferWithRange :: #force_inline proc(self: ^ComputeCommandEncoder, indirectCommandBuffer: ^Buffer, executionRange: NS.Range) { +ComputeCommandEncoder_executeCommandsInBufferWithRange :: #force_inline proc "c" (self: ^ComputeCommandEncoder, indirectCommandBuffer: ^Buffer, executionRange: NS.Range) { msgSend(nil, self, "executeCommandsInBuffer:withRange:", indirectCommandBuffer, executionRange) } @(objc_type=ComputeCommandEncoder, objc_name="memoryBarrierWithResources") -ComputeCommandEncoder_memoryBarrierWithResources :: #force_inline proc(self: ^ComputeCommandEncoder, resources: []^Resource) { +ComputeCommandEncoder_memoryBarrierWithResources :: #force_inline proc "c" (self: ^ComputeCommandEncoder, resources: []^Resource) { msgSend(nil, self, "memoryBarrierWithResources:count:", raw_data(resources), NS.UInteger(len(resources))) } @(objc_type=ComputeCommandEncoder, objc_name="memoryBarrierWithScope") -ComputeCommandEncoder_memoryBarrierWithScope :: #force_inline proc(self: ^ComputeCommandEncoder, scope: BarrierScope) { +ComputeCommandEncoder_memoryBarrierWithScope :: #force_inline proc "c" (self: ^ComputeCommandEncoder, scope: BarrierScope) { msgSend(nil, self, "memoryBarrierWithScope:", scope) } @(objc_type=ComputeCommandEncoder, objc_name="sampleCountersInBuffer") -ComputeCommandEncoder_sampleCountersInBuffer :: #force_inline proc(self: ^ComputeCommandEncoder, sampleBuffer: ^Buffer, sampleIndex: NS.UInteger, barrier: BOOL) { +ComputeCommandEncoder_sampleCountersInBuffer :: #force_inline proc "c" (self: ^ComputeCommandEncoder, sampleBuffer: ^Buffer, sampleIndex: NS.UInteger, barrier: BOOL) { msgSend(nil, self, "sampleCountersInBuffer:atSampleIndex:withBarrier:", sampleBuffer, sampleIndex, barrier) } @(objc_type=ComputeCommandEncoder, objc_name="setAccelerationStructure") -ComputeCommandEncoder_setAccelerationStructure :: #force_inline proc(self: ^ComputeCommandEncoder, accelerationStructure: ^AccelerationStructure, bufferIndex: NS.UInteger) { +ComputeCommandEncoder_setAccelerationStructure :: #force_inline proc "c" (self: ^ComputeCommandEncoder, accelerationStructure: ^AccelerationStructure, bufferIndex: NS.UInteger) { msgSend(nil, self, "setAccelerationStructure:atBufferIndex:", accelerationStructure, bufferIndex) } @(objc_type=ComputeCommandEncoder, objc_name="setBuffer") -ComputeCommandEncoder_setBuffer :: #force_inline proc(self: ^ComputeCommandEncoder, buffer: ^Buffer, offset: NS.UInteger, index: NS.UInteger) { +ComputeCommandEncoder_setBuffer :: #force_inline proc "c" (self: ^ComputeCommandEncoder, buffer: ^Buffer, offset: NS.UInteger, index: NS.UInteger) { msgSend(nil, self, "setBuffer:offset:atIndex:", buffer, offset, index) } @(objc_type=ComputeCommandEncoder, objc_name="setBufferOffset") -ComputeCommandEncoder_setBufferOffset :: #force_inline proc(self: ^ComputeCommandEncoder, offset: NS.UInteger, index: NS.UInteger) { +ComputeCommandEncoder_setBufferOffset :: #force_inline proc "c" (self: ^ComputeCommandEncoder, offset: NS.UInteger, index: NS.UInteger) { msgSend(nil, self, "setBufferOffset:atIndex:", offset, index) } @(objc_type=ComputeCommandEncoder, objc_name="setBuffers") -ComputeCommandEncoder_setBuffers :: #force_inline proc(self: ^ComputeCommandEncoder, buffers: []^Buffer, offsets: []NS.UInteger, range: NS.Range) { +ComputeCommandEncoder_setBuffers :: #force_inline proc "odin" (self: ^ComputeCommandEncoder, buffers: []^Buffer, offsets: []NS.UInteger, range: NS.Range) { assert(len(buffers) == len(offsets)) assert(range.length <= NS.UInteger(len(buffers))) msgSend(nil, self, "setBuffers:offsets:withRange:", raw_data(buffers), raw_data(offsets), range) } @(objc_type=ComputeCommandEncoder, objc_name="setBytes") -ComputeCommandEncoder_setBytes :: #force_inline proc(self: ^ComputeCommandEncoder, bytes: []byte, index: NS.UInteger) { +ComputeCommandEncoder_setBytes :: #force_inline proc "c" (self: ^ComputeCommandEncoder, bytes: []byte, index: NS.UInteger) { msgSend(nil, self, "setBytes:length:atIndex:", raw_data(bytes), NS.UInteger(len(bytes)), index) } @(objc_type=ComputeCommandEncoder, objc_name="setComputePipelineState") -ComputeCommandEncoder_setComputePipelineState :: #force_inline proc(self: ^ComputeCommandEncoder, pipelineState: ^ComputePipelineState) { +ComputeCommandEncoder_setComputePipelineState :: #force_inline proc "c" (self: ^ComputeCommandEncoder, pipelineState: ^ComputePipelineState) { msgSend(nil, self, "setComputePipelineState:", pipelineState) } @(objc_type=ComputeCommandEncoder, objc_name="setImageblockWidth") -ComputeCommandEncoder_setImageblockWidth :: #force_inline proc(self: ^ComputeCommandEncoder, width: NS.UInteger, height: NS.UInteger) { +ComputeCommandEncoder_setImageblockWidth :: #force_inline proc "c" (self: ^ComputeCommandEncoder, width: NS.UInteger, height: NS.UInteger) { msgSend(nil, self, "setImageblockWidth:height:", width, height) } @(objc_type=ComputeCommandEncoder, objc_name="setIntersectionFunctionTable") -ComputeCommandEncoder_setIntersectionFunctionTable :: #force_inline proc(self: ^ComputeCommandEncoder, intersectionFunctionTable: ^IntersectionFunctionTable, bufferIndex: NS.UInteger) { +ComputeCommandEncoder_setIntersectionFunctionTable :: #force_inline proc "c" (self: ^ComputeCommandEncoder, intersectionFunctionTable: ^IntersectionFunctionTable, bufferIndex: NS.UInteger) { msgSend(nil, self, "setIntersectionFunctionTable:atBufferIndex:", intersectionFunctionTable, bufferIndex) } @(objc_type=ComputeCommandEncoder, objc_name="setIntersectionFunctionTables") -ComputeCommandEncoder_setIntersectionFunctionTables :: #force_inline proc(self: ^ComputeCommandEncoder, intersectionFunctionTables: []^IntersectionFunctionTable, range: NS.Range) { +ComputeCommandEncoder_setIntersectionFunctionTables :: #force_inline proc "odin" (self: ^ComputeCommandEncoder, intersectionFunctionTables: []^IntersectionFunctionTable, range: NS.Range) { assert(range.length <= NS.UInteger(len(intersectionFunctionTables))) msgSend(nil, self, "setIntersectionFunctionTables:withBufferRange:", raw_data(intersectionFunctionTables), range) } @(objc_type=ComputeCommandEncoder, objc_name="setSamplerState") -ComputeCommandEncoder_setSamplerState :: #force_inline proc(self: ^ComputeCommandEncoder, sampler: ^SamplerState, index: NS.UInteger) { +ComputeCommandEncoder_setSamplerState :: #force_inline proc "c" (self: ^ComputeCommandEncoder, sampler: ^SamplerState, index: NS.UInteger) { msgSend(nil, self, "setSamplerState:atIndex:", sampler, index) } @(objc_type=ComputeCommandEncoder, objc_name="setSamplerStateWithLod") -ComputeCommandEncoder_setSamplerState_lodMinClamp_lodMaxClamp :: #force_inline proc(self: ^ComputeCommandEncoder, sampler: ^SamplerState, lodMinClamp: f32, lodMaxClamp: f32, index: NS.UInteger) { +ComputeCommandEncoder_setSamplerState_lodMinClamp_lodMaxClamp :: #force_inline proc "c" (self: ^ComputeCommandEncoder, sampler: ^SamplerState, lodMinClamp: f32, lodMaxClamp: f32, index: NS.UInteger) { msgSend(nil, self, "setSamplerState:lodMinClamp:lodMaxClamp:atIndex:", sampler, lodMinClamp, lodMaxClamp, index) } @(objc_type=ComputeCommandEncoder, objc_name="setSamplerStatesWithLod") -ComputeCommandEncoder_setSamplerStatesWithLod :: #force_inline proc(self: ^ComputeCommandEncoder, samplers: []^SamplerState, lodMinClamps, lodMaxClamps: []f32, range: NS.Range) { +ComputeCommandEncoder_setSamplerStatesWithLod :: #force_inline proc "c" (self: ^ComputeCommandEncoder, samplers: []^SamplerState, lodMinClamps, lodMaxClamps: []f32, range: NS.Range) { msgSend(nil, self, "setSamplerStates:lodMinClamps:lodMaxClamps:withRange:", raw_data(samplers), raw_data(lodMinClamps), raw_data(lodMaxClamps), range) } @(objc_type=ComputeCommandEncoder, objc_name="setSamplerStatesWithRange") -ComputeCommandEncoder_setSamplerStatesWithRange :: #force_inline proc(self: ^ComputeCommandEncoder, samplers: []^SamplerState, range: NS.Range) { +ComputeCommandEncoder_setSamplerStatesWithRange :: #force_inline proc "c" (self: ^ComputeCommandEncoder, samplers: []^SamplerState, range: NS.Range) { msgSend(nil, self, "setSamplerStates:withRange:", raw_data(samplers), range) } @(objc_type=ComputeCommandEncoder, objc_name="setStageInRegion") -ComputeCommandEncoder_setStageInRegion :: #force_inline proc(self: ^ComputeCommandEncoder, region: Region) { +ComputeCommandEncoder_setStageInRegion :: #force_inline proc "c" (self: ^ComputeCommandEncoder, region: Region) { msgSend(nil, self, "setStageInRegion:", region) } @(objc_type=ComputeCommandEncoder, objc_name="setStageInRegionWithIndirectBuffer") -ComputeCommandEncoder_setStageInRegionWithIndirectBuffer :: #force_inline proc(self: ^ComputeCommandEncoder, indirectBuffer: ^Buffer, indirectBufferOffset: NS.UInteger) { +ComputeCommandEncoder_setStageInRegionWithIndirectBuffer :: #force_inline proc "c" (self: ^ComputeCommandEncoder, indirectBuffer: ^Buffer, indirectBufferOffset: NS.UInteger) { msgSend(nil, self, "setStageInRegionWithIndirectBuffer:indirectBufferOffset:", indirectBuffer, indirectBufferOffset) } @(objc_type=ComputeCommandEncoder, objc_name="setTexture") -ComputeCommandEncoder_setTexture :: #force_inline proc(self: ^ComputeCommandEncoder, texture: ^Texture, index: NS.UInteger) { +ComputeCommandEncoder_setTexture :: #force_inline proc "c" (self: ^ComputeCommandEncoder, texture: ^Texture, index: NS.UInteger) { msgSend(nil, self, "setTexture:atIndex:", texture, index) } @(objc_type=ComputeCommandEncoder, objc_name="setTextures") -ComputeCommandEncoder_setTextures :: #force_inline proc(self: ^ComputeCommandEncoder, textures: []^Texture, range: NS.Range) { +ComputeCommandEncoder_setTextures :: #force_inline proc "c" (self: ^ComputeCommandEncoder, textures: []^Texture, range: NS.Range) { msgSend(nil, self, "setTextures:withRange:", raw_data(textures), range) } @(objc_type=ComputeCommandEncoder, objc_name="setThreadgroupMemoryLength") -ComputeCommandEncoder_setThreadgroupMemoryLength :: #force_inline proc(self: ^ComputeCommandEncoder, length: NS.UInteger, index: NS.UInteger) { +ComputeCommandEncoder_setThreadgroupMemoryLength :: #force_inline proc "c" (self: ^ComputeCommandEncoder, length: NS.UInteger, index: NS.UInteger) { msgSend(nil, self, "setThreadgroupMemoryLength:atIndex:", length, index) } @(objc_type=ComputeCommandEncoder, objc_name="setVisibleFunctionTable") -ComputeCommandEncoder_setVisibleFunctionTable :: #force_inline proc(self: ^ComputeCommandEncoder, visibleFunctionTable: ^VisibleFunctionTable, bufferIndex: NS.UInteger) { +ComputeCommandEncoder_setVisibleFunctionTable :: #force_inline proc "c" (self: ^ComputeCommandEncoder, visibleFunctionTable: ^VisibleFunctionTable, bufferIndex: NS.UInteger) { msgSend(nil, self, "setVisibleFunctionTable:atBufferIndex:", visibleFunctionTable, bufferIndex) } @(objc_type=ComputeCommandEncoder, objc_name="setVisibleFunctionTables") -ComputeCommandEncoder_setVisibleFunctionTables :: #force_inline proc(self: ^ComputeCommandEncoder, visibleFunctionTables: []^VisibleFunctionTable, range: NS.Range) { +ComputeCommandEncoder_setVisibleFunctionTables :: #force_inline proc "c" (self: ^ComputeCommandEncoder, visibleFunctionTables: []^VisibleFunctionTable, range: NS.Range) { msgSend(nil, self, "setVisibleFunctionTables:withBufferRange:", raw_data(visibleFunctionTables), range) } @(objc_type=ComputeCommandEncoder, objc_name="updateFence") -ComputeCommandEncoder_updateFence :: #force_inline proc(self: ^ComputeCommandEncoder, fence: ^Fence) { +ComputeCommandEncoder_updateFence :: #force_inline proc "c" (self: ^ComputeCommandEncoder, fence: ^Fence) { msgSend(nil, self, "updateFence:", fence) } @(objc_type=ComputeCommandEncoder, objc_name="useHeap") -ComputeCommandEncoder_useHeap :: #force_inline proc(self: ^ComputeCommandEncoder, heap: ^Heap) { +ComputeCommandEncoder_useHeap :: #force_inline proc "c" (self: ^ComputeCommandEncoder, heap: ^Heap) { msgSend(nil, self, "useHeap:", heap) } @(objc_type=ComputeCommandEncoder, objc_name="useHeaps") -ComputeCommandEncoder_useHeaps :: #force_inline proc(self: ^ComputeCommandEncoder, heaps: []^Heap) { +ComputeCommandEncoder_useHeaps :: #force_inline proc "c" (self: ^ComputeCommandEncoder, heaps: []^Heap) { msgSend(nil, self, "useHeaps:count:", raw_data(heaps), NS.UInteger(len(heaps))) } @(objc_type=ComputeCommandEncoder, objc_name="useResource") -ComputeCommandEncoder_useResource :: #force_inline proc(self: ^ComputeCommandEncoder, resource: ^Resource, usage: ResourceUsage) { +ComputeCommandEncoder_useResource :: #force_inline proc "c" (self: ^ComputeCommandEncoder, resource: ^Resource, usage: ResourceUsage) { msgSend(nil, self, "useResource:usage:", resource, usage) } @(objc_type=ComputeCommandEncoder, objc_name="useResources") -ComputeCommandEncoder_useResources :: #force_inline proc(self: ^ComputeCommandEncoder, resources: []^Resource, usage: ResourceUsage) { +ComputeCommandEncoder_useResources :: #force_inline proc "c" (self: ^ComputeCommandEncoder, resources: []^Resource, usage: ResourceUsage) { msgSend(nil, self, "useResources:count:usage:", raw_data(resources), NS.UInteger(len(resources)), usage) } @(objc_type=ComputeCommandEncoder, objc_name="waitForFence") -ComputeCommandEncoder_waitForFence :: #force_inline proc(self: ^ComputeCommandEncoder, fence: ^Fence) { +ComputeCommandEncoder_waitForFence :: #force_inline proc "c" (self: ^ComputeCommandEncoder, fence: ^Fence) { msgSend(nil, self, "waitForFence:", fence) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - ComputePipelineState -Class Methods: -Methods: - device - functionHandleWithFunction - imageblockMemoryLengthForDimensions - label - maxTotalThreadsPerThreadgroup - newComputePipelineStateWithAdditionalBinaryFunctions - newIntersectionFunctionTableWithDescriptor - newVisibleFunctionTableWithDescriptor - staticThreadgroupMemoryLength - supportIndirectCommandBuffers - threadExecutionWidth -*/ @(objc_class="MTLComputePipelineState") ComputePipelineState :: struct { using _: NS.Object } @(objc_type=ComputePipelineState, objc_name="device") -ComputePipelineState_device :: #force_inline proc(self: ^ComputePipelineState) -> ^Device { +ComputePipelineState_device :: #force_inline proc "c" (self: ^ComputePipelineState) -> ^Device { return msgSend(^Device, self, "device") } @(objc_type=ComputePipelineState, objc_name="functionHandleWithFunction") -ComputePipelineState_functionHandleWithFunction :: #force_inline proc(self: ^ComputePipelineState, function: ^Function) -> ^FunctionHandle { +ComputePipelineState_functionHandleWithFunction :: #force_inline proc "c" (self: ^ComputePipelineState, function: ^Function) -> ^FunctionHandle { return msgSend(^FunctionHandle, self, "functionHandleWithFunction:", function) } @(objc_type=ComputePipelineState, objc_name="imageblockMemoryLengthForDimensions") -ComputePipelineState_imageblockMemoryLengthForDimensions :: #force_inline proc(self: ^ComputePipelineState, imageblockDimensions: Size) -> ^ComputePipelineState { +ComputePipelineState_imageblockMemoryLengthForDimensions :: #force_inline proc "c" (self: ^ComputePipelineState, imageblockDimensions: Size) -> ^ComputePipelineState { return msgSend(^ComputePipelineState, self, "imageblockMemoryLengthForDimensions:", imageblockDimensions) } @(objc_type=ComputePipelineState, objc_name="label") -ComputePipelineState_label :: #force_inline proc(self: ^ComputePipelineState) -> ^NS.String { +ComputePipelineState_label :: #force_inline proc "c" (self: ^ComputePipelineState) -> ^NS.String { return msgSend(^NS.String, self, "label") } @(objc_type=ComputePipelineState, objc_name="maxTotalThreadsPerThreadgroup") -ComputePipelineState_maxTotalThreadsPerThreadgroup :: #force_inline proc(self: ^ComputePipelineState) -> NS.UInteger { +ComputePipelineState_maxTotalThreadsPerThreadgroup :: #force_inline proc "c" (self: ^ComputePipelineState) -> NS.UInteger { return msgSend(NS.UInteger, self, "maxTotalThreadsPerThreadgroup") } @(objc_type=ComputePipelineState, objc_name="newComputePipelineState") -ComputePipelineState_newComputePipelineState :: #force_inline proc(self: ^ComputePipelineState, functions: ^NS.Array) -> (state: ^ComputePipelineState, error: ^NS.Error) { +ComputePipelineState_newComputePipelineState :: #force_inline proc "contextless" (self: ^ComputePipelineState, functions: ^NS.Array) -> (state: ^ComputePipelineState, error: ^NS.Error) { state = msgSend(^ComputePipelineState, self, "newComputePipelineStateWithAdditionalBinaryFunctions:error:", functions, &error) return } @(objc_type=ComputePipelineState, objc_name="newIntersectionFunctionTable") -ComputePipelineState_newIntersectionFunctionTable :: #force_inline proc(self: ^ComputePipelineState, descriptor: ^IntersectionFunctionTableDescriptor) -> ^IntersectionFunctionTable { +ComputePipelineState_newIntersectionFunctionTable :: #force_inline proc "c" (self: ^ComputePipelineState, descriptor: ^IntersectionFunctionTableDescriptor) -> ^IntersectionFunctionTable { return msgSend(^IntersectionFunctionTable, self, "newIntersectionFunctionTableWithDescriptor:", descriptor) } @(objc_type=ComputePipelineState, objc_name="newVisibleFunctionTable") -ComputePipelineState_newVisibleFunctionTable :: #force_inline proc(self: ^ComputePipelineState, descriptor: ^VisibleFunctionTableDescriptor) -> ^VisibleFunctionTable { +ComputePipelineState_newVisibleFunctionTable :: #force_inline proc "c" (self: ^ComputePipelineState, descriptor: ^VisibleFunctionTableDescriptor) -> ^VisibleFunctionTable { return msgSend(^VisibleFunctionTable, self, "newVisibleFunctionTableWithDescriptor:", descriptor) } @(objc_type=ComputePipelineState, objc_name="staticThreadgroupMemoryLength") -ComputePipelineState_staticThreadgroupMemoryLength :: #force_inline proc(self: ^ComputePipelineState) -> NS.UInteger { +ComputePipelineState_staticThreadgroupMemoryLength :: #force_inline proc "c" (self: ^ComputePipelineState) -> NS.UInteger { return msgSend(NS.UInteger, self, "staticThreadgroupMemoryLength") } @(objc_type=ComputePipelineState, objc_name="supportIndirectCommandBuffers") -ComputePipelineState_supportIndirectCommandBuffers :: #force_inline proc(self: ^ComputePipelineState) -> BOOL { +ComputePipelineState_supportIndirectCommandBuffers :: #force_inline proc "c" (self: ^ComputePipelineState) -> BOOL { return msgSend(BOOL, self, "supportIndirectCommandBuffers") } @(objc_type=ComputePipelineState, objc_name="threadExecutionWidth") -ComputePipelineState_threadExecutionWidth :: #force_inline proc(self: ^ComputePipelineState) -> NS.UInteger { +ComputePipelineState_threadExecutionWidth :: #force_inline proc "c" (self: ^ComputePipelineState) -> NS.UInteger { return msgSend(NS.UInteger, self, "threadExecutionWidth") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - Counter -Class Methods: -Methods: - name -*/ @(objc_class="MTLCounter") Counter :: struct { using _: NS.Object } @(objc_type=Counter, objc_name="name") -Counter_name :: #force_inline proc(self: ^Counter) -> ^NS.String { +Counter_name :: #force_inline proc "c" (self: ^Counter) -> ^NS.String { return msgSend(^NS.String, self, "name") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - CounterSampleBuffer -Class Methods: -Methods: - device - label - resolveCounterRange - sampleCount -*/ @(objc_class="MTLCounterSampleBuffer") CounterSampleBuffer :: struct { using _: NS.Object } @(objc_type=CounterSampleBuffer, objc_name="device") -CounterSampleBuffer_device :: #force_inline proc(self: ^CounterSampleBuffer) -> ^Device { +CounterSampleBuffer_device :: #force_inline proc "c" (self: ^CounterSampleBuffer) -> ^Device { return msgSend(^Device, self, "device") } @(objc_type=CounterSampleBuffer, objc_name="label") -CounterSampleBuffer_label :: #force_inline proc(self: ^CounterSampleBuffer) -> ^NS.String { +CounterSampleBuffer_label :: #force_inline proc "c" (self: ^CounterSampleBuffer) -> ^NS.String { return msgSend(^NS.String, self, "label") } @(objc_type=CounterSampleBuffer, objc_name="resolveCounterRange") -CounterSampleBuffer_resolveCounterRange :: #force_inline proc(self: ^CounterSampleBuffer, range: NS.Range) -> ^NS.Data { +CounterSampleBuffer_resolveCounterRange :: #force_inline proc "c" (self: ^CounterSampleBuffer, range: NS.Range) -> ^NS.Data { return msgSend(^NS.Data, self, "resolveCounterRange:", range) } @(objc_type=CounterSampleBuffer, objc_name="sampleCount") -CounterSampleBuffer_sampleCount :: #force_inline proc(self: ^CounterSampleBuffer) -> NS.UInteger { +CounterSampleBuffer_sampleCount :: #force_inline proc "c" (self: ^CounterSampleBuffer) -> NS.UInteger { return msgSend(NS.UInteger, self, "sampleCount") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - CounterSet -Class Methods: -Methods: - counters - name -*/ @(objc_class="MTLCounterSet") CounterSet :: struct { using _: NS.Object } @(objc_type=CounterSet, objc_name="counters") -CounterSet_counters :: #force_inline proc(self: ^CounterSet) -> ^NS.Array { +CounterSet_counters :: #force_inline proc "c" (self: ^CounterSet) -> ^NS.Array { return msgSend(^NS.Array, self, "counters") } @(objc_type=CounterSet, objc_name="name") -CounterSet_name :: #force_inline proc(self: ^CounterSet) -> ^NS.String { +CounterSet_name :: #force_inline proc "c" (self: ^CounterSet) -> ^NS.String { return msgSend(^NS.String, self, "name") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - DepthStencilState -Class Methods: -Methods: - device - label -*/ @(objc_class="MTLDepthStencilState") DepthStencilState :: struct { using _: NS.Object } @(objc_type=DepthStencilState, objc_name="device") -DepthStencilState_device :: #force_inline proc(self: ^DepthStencilState) -> ^Device { +DepthStencilState_device :: #force_inline proc "c" (self: ^DepthStencilState) -> ^Device { return msgSend(^Device, self, "device") } @(objc_type=DepthStencilState, objc_name="label") -DepthStencilState_label :: #force_inline proc(self: ^DepthStencilState) -> ^NS.String { +DepthStencilState_label :: #force_inline proc "c" (self: ^DepthStencilState) -> ^NS.String { return msgSend(^NS.String, self, "label") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - Device -Class Methods: -Methods: - accelerationStructureSizesWithDescriptor - areBarycentricCoordsSupported - areProgrammableSamplePositionsSupported - areRasterOrderGroupsSupported - argumentBuffersSupport - convertSparsePixelRegions - convertSparseTileRegions - counterSets - currentAllocatedSize - getDefaultSamplePositions - hasUnifiedMemory - heapBufferSizeAndAlignWithLength - heapTextureSizeAndAlignWithDescriptor - isDepth24Stencil8PixelFormatSupported - isHeadless - isLowPower - isRemovable - location - locationNumber - maxArgumentBufferSamplerCount - maxBufferLength - maxThreadgroupMemoryLength - maxThreadsPerThreadgroup - maxTransferRate - minimumLinearTextureAlignmentForPixelFormat - minimumTextureBufferAlignmentForPixelFormat - name - newAccelerationStructureWithDescriptor - newAccelerationStructureWithSize - newArgumentEncoderWithArguments - newBinaryArchiveWithDescriptor - newBufferWithBytes - newBufferWithBytesNoCopy - newBufferWithLength - newCommandQueue - newCommandQueueWithMaxCommandBufferCount - newComputePipelineStateWithDescriptor - newComputePipelineStateWithDescriptor - newComputePipelineStateWithFunction - newComputePipelineStateWithFunction - newComputePipelineStateWithFunction - newComputePipelineStateWithFunction - newCounterSampleBufferWithDescriptor - newDefaultLibrary - newDefaultLibraryWithBundle - newDepthStencilStateWithDescriptor - newDynamicLibrary - newDynamicLibraryWithURL - newEvent - newFence - newHeapWithDescriptor - newIndirectCommandBufferWithDescriptor - newLibraryWithData - newLibraryWithFile - newLibraryWithSource - newLibraryWithSource - newLibraryWithURL - newRasterizationRateMapWithDescriptor - newRenderPipelineStateWithDescriptor - newRenderPipelineStateWithDescriptor - newRenderPipelineStateWithDescriptor - newRenderPipelineStateWithDescriptor - newRenderPipelineStateWithTileDescriptor - newRenderPipelineStateWithTileDescriptor - newSamplerState - newSharedEvent - newSharedEventWithHandle - newSharedTextureWithDescriptor - newSharedTextureWithHandle - newTextureWithDescriptor - newTextureWithDescriptor - peerCount - peerGroupID - peerIndex - readWriteTextureSupport - recommendedMaxWorkingSetSize - registryID - sampleTimestamps - sparseTileSizeInBytes - sparseTileSizeWithTextureType - supports32BitFloatFiltering - supports32BitMSAA - supportsBCTextureCompression - supportsCounterSampling - supportsDynamicLibraries - supportsFamily - supportsFeatureSet - supportsFunctionPointers - supportsPullModelInterpolation - supportsQueryTextureLOD - supportsRasterizationRateMapWithLayerCount - supportsRaytracing - supportsShaderBarycentricCoordinates - supportsTextureSampleCount - supportsVertexAmplificationCount -*/ @(objc_class="MTLDevice") Device :: struct { using _: NS.Object } @(objc_type=Device, objc_name="accelerationStructureSizesWithDescriptor") -Device_accelerationStructureSizesWithDescriptor :: #force_inline proc(self: ^Device, descriptor: ^AccelerationStructureDescriptor) -> AccelerationStructureSizes { +Device_accelerationStructureSizesWithDescriptor :: #force_inline proc "c" (self: ^Device, descriptor: ^AccelerationStructureDescriptor) -> AccelerationStructureSizes { return msgSend(AccelerationStructureSizes, self, "accelerationStructureSizesWithDescriptor:", descriptor) } @(objc_type=Device, objc_name="areBarycentricCoordsSupported") -Device_areBarycentricCoordsSupported :: #force_inline proc(self: ^Device) -> BOOL { +Device_areBarycentricCoordsSupported :: #force_inline proc "c" (self: ^Device) -> BOOL { return msgSend(BOOL, self, "areBarycentricCoordsSupported") } @(objc_type=Device, objc_name="areProgrammableSamplePositionsSupported") -Device_areProgrammableSamplePositionsSupported :: #force_inline proc(self: ^Device) -> BOOL { +Device_areProgrammableSamplePositionsSupported :: #force_inline proc "c" (self: ^Device) -> BOOL { return msgSend(BOOL, self, "areProgrammableSamplePositionsSupported") } @(objc_type=Device, objc_name="areRasterOrderGroupsSupported") -Device_areRasterOrderGroupsSupported :: #force_inline proc(self: ^Device) -> BOOL { +Device_areRasterOrderGroupsSupported :: #force_inline proc "c" (self: ^Device) -> BOOL { return msgSend(BOOL, self, "areRasterOrderGroupsSupported") } @(objc_type=Device, objc_name="argumentBuffersSupport") -Device_argumentBuffersSupport :: #force_inline proc(self: ^Device) -> ArgumentBuffersTier { +Device_argumentBuffersSupport :: #force_inline proc "c" (self: ^Device) -> ArgumentBuffersTier { return msgSend(ArgumentBuffersTier, self, "argumentBuffersSupport") } @(objc_type=Device, objc_name="convertSparsePixelRegions") -Device_convertSparsePixelRegions :: #force_inline proc(self: ^Device, pixelRegions, tileRegions: ^Region, tileSize: Size, mode: SparseTextureRegionAlignmentMode, numRegions: NS.UInteger) { +Device_convertSparsePixelRegions :: #force_inline proc "c" (self: ^Device, pixelRegions, tileRegions: ^Region, tileSize: Size, mode: SparseTextureRegionAlignmentMode, numRegions: NS.UInteger) { msgSend(nil, self, "convertSparsePixelRegions:toTileRegions:withTileSize:alignmentMode:numRegions:", pixelRegions, tileRegions, tileSize, mode, numRegions) } @(objc_type=Device, objc_name="convertSparseTileRegions") -Device_convertSparseTileRegions :: #force_inline proc(self: ^Device, tileRegions, pixelRegions: ^Region, tileSize: Size, numRegions: NS.UInteger) { +Device_convertSparseTileRegions :: #force_inline proc "c" (self: ^Device, tileRegions, pixelRegions: ^Region, tileSize: Size, numRegions: NS.UInteger) { msgSend(nil, self, "convertSparseTileRegions:toPixelRegions:withTileSize:numRegions:", tileRegions, pixelRegions, tileSize, numRegions) } @(objc_type=Device, objc_name="counterSets") -Device_counterSets :: #force_inline proc(self: ^Device) -> ^NS.Array { +Device_counterSets :: #force_inline proc "c" (self: ^Device) -> ^NS.Array { return msgSend(^NS.Array, self, "counterSets") } @(objc_type=Device, objc_name="currentAllocatedSize") -Device_currentAllocatedSize :: #force_inline proc(self: ^Device) -> NS.UInteger { +Device_currentAllocatedSize :: #force_inline proc "c" (self: ^Device) -> NS.UInteger { return msgSend(NS.UInteger, self, "currentAllocatedSize") } @(objc_type=Device, objc_name="getDefaultSamplePositions") -Device_getDefaultSamplePositions :: #force_inline proc(self: ^Device, positions: []SamplePosition) { +Device_getDefaultSamplePositions :: #force_inline proc "c" (self: ^Device, positions: []SamplePosition) { msgSend(nil, self, "getDefaultSamplePositions:count:", raw_data(positions), NS.UInteger(len(positions))) } @(objc_type=Device, objc_name="hasUnifiedMemory") -Device_hasUnifiedMemory :: #force_inline proc(self: ^Device) -> BOOL { +Device_hasUnifiedMemory :: #force_inline proc "c" (self: ^Device) -> BOOL { return msgSend(BOOL, self, "hasUnifiedMemory") } @(objc_type=Device, objc_name="heapBufferSizeAndAlignWithLength") -Device_heapBufferSizeAndAlignWithLength :: #force_inline proc(self: ^Device, length: NS.UInteger, options: ResourceOptions) -> (size, align: NS.UInteger) { +Device_heapBufferSizeAndAlignWithLength :: #force_inline proc "c" (self: ^Device, length: NS.UInteger, options: ResourceOptions) -> (size, align: NS.UInteger) { res := msgSend(SizeAndAlign, self, "heapBufferSizeAndAlignWithLength:options:", length, options) return res.size, res.align } @(objc_type=Device, objc_name="heapTextureSizeAndAlignWithDescriptor") -Device_heapTextureSizeAndAlignWithDescriptor :: #force_inline proc(self: ^Device, desc: ^TextureDescriptor) -> (size, align: NS.UInteger) { +Device_heapTextureSizeAndAlignWithDescriptor :: #force_inline proc "c" (self: ^Device, desc: ^TextureDescriptor) -> (size, align: NS.UInteger) { res := msgSend(SizeAndAlign, self, "heapTextureSizeAndAlignWithDescriptor:", desc) return res.size, res.align } @(objc_type=Device, objc_name="isDepth24Stencil8PixelFormatSupported") -Device_isDepth24Stencil8PixelFormatSupported :: #force_inline proc(self: ^Device) -> BOOL { +Device_isDepth24Stencil8PixelFormatSupported :: #force_inline proc "c" (self: ^Device) -> BOOL { return msgSend(BOOL, self, "isDepth24Stencil8PixelFormatSupported") } @(objc_type=Device, objc_name="isHeadless") -Device_isHeadless :: #force_inline proc(self: ^Device) -> BOOL { +Device_isHeadless :: #force_inline proc "c" (self: ^Device) -> BOOL { return msgSend(BOOL, self, "isHeadless") } @(objc_type=Device, objc_name="isLowPower") -Device_isLowPower :: #force_inline proc(self: ^Device) -> BOOL { +Device_isLowPower :: #force_inline proc "c" (self: ^Device) -> BOOL { return msgSend(BOOL, self, "isLowPower") } @(objc_type=Device, objc_name="isRemovable") -Device_isRemovable :: #force_inline proc(self: ^Device) -> BOOL { +Device_isRemovable :: #force_inline proc "c" (self: ^Device) -> BOOL { return msgSend(BOOL, self, "isRemovable") } @(objc_type=Device, objc_name="location") -Device_location :: #force_inline proc(self: ^Device) -> DeviceLocation { +Device_location :: #force_inline proc "c" (self: ^Device) -> DeviceLocation { return msgSend(DeviceLocation, self, "location") } @(objc_type=Device, objc_name="locationNumber") -Device_locationNumber :: #force_inline proc(self: ^Device) -> NS.UInteger { +Device_locationNumber :: #force_inline proc "c" (self: ^Device) -> NS.UInteger { return msgSend(NS.UInteger, self, "locationNumber") } @(objc_type=Device, objc_name="maxArgumentBufferSamplerCount") -Device_maxArgumentBufferSamplerCount :: #force_inline proc(self: ^Device) -> NS.UInteger { +Device_maxArgumentBufferSamplerCount :: #force_inline proc "c" (self: ^Device) -> NS.UInteger { return msgSend(NS.UInteger, self, "maxArgumentBufferSamplerCount") } @(objc_type=Device, objc_name="maxBufferLength") -Device_maxBufferLength :: #force_inline proc(self: ^Device) -> NS.UInteger { +Device_maxBufferLength :: #force_inline proc "c" (self: ^Device) -> NS.UInteger { return msgSend(NS.UInteger, self, "maxBufferLength") } @(objc_type=Device, objc_name="maxThreadgroupMemoryLength") -Device_maxThreadgroupMemoryLength :: #force_inline proc(self: ^Device) -> NS.UInteger { +Device_maxThreadgroupMemoryLength :: #force_inline proc "c" (self: ^Device) -> NS.UInteger { return msgSend(NS.UInteger, self, "maxThreadgroupMemoryLength") } @(objc_type=Device, objc_name="maxThreadsPerThreadgroup") -Device_maxThreadsPerThreadgroup :: #force_inline proc(self: ^Device) -> Size { +Device_maxThreadsPerThreadgroup :: #force_inline proc "c" (self: ^Device) -> Size { return msgSend(Size, self, "maxThreadsPerThreadgroup") } @(objc_type=Device, objc_name="maxTransferRate") -Device_maxTransferRate :: #force_inline proc(self: ^Device) -> u64 { +Device_maxTransferRate :: #force_inline proc "c" (self: ^Device) -> u64 { return msgSend(u64, self, "maxTransferRate") } @(objc_type=Device, objc_name="minimumLinearTextureAlignmentForPixelFormat") -Device_minimumLinearTextureAlignmentForPixelFormat :: #force_inline proc(self: ^Device, format: PixelFormat) -> NS.UInteger { +Device_minimumLinearTextureAlignmentForPixelFormat :: #force_inline proc "c" (self: ^Device, format: PixelFormat) -> NS.UInteger { return msgSend(NS.UInteger, self, "minimumLinearTextureAlignmentForPixelFormat:", format) } @(objc_type=Device, objc_name="minimumTextureBufferAlignmentForPixelFormat") -Device_minimumTextureBufferAlignmentForPixelFormat :: #force_inline proc(self: ^Device, format: PixelFormat) -> NS.UInteger { +Device_minimumTextureBufferAlignmentForPixelFormat :: #force_inline proc "c" (self: ^Device, format: PixelFormat) -> NS.UInteger { return msgSend(NS.UInteger, self, "minimumTextureBufferAlignmentForPixelFormat:", format) } @(objc_type=Device, objc_name="name") -Device_name :: #force_inline proc(self: ^Device) -> ^NS.String { +Device_name :: #force_inline proc "c" (self: ^Device) -> ^NS.String { return msgSend(^NS.String, self, "name") } @(objc_type=Device, objc_name="newAccelerationStructureWithDescriptor") -Device_newAccelerationStructureWithDescriptor :: #force_inline proc(self: ^Device, descriptor: ^AccelerationStructureDescriptor) -> ^AccelerationStructure { +Device_newAccelerationStructureWithDescriptor :: #force_inline proc "c" (self: ^Device, descriptor: ^AccelerationStructureDescriptor) -> ^AccelerationStructure { return msgSend(^AccelerationStructure, self, "newAccelerationStructureWithDescriptor:", descriptor) } @(objc_type=Device, objc_name="newAccelerationStructureWithSize") -Device_newAccelerationStructureWithSize :: #force_inline proc(self: ^Device, size: NS.UInteger) -> ^AccelerationStructure { +Device_newAccelerationStructureWithSize :: #force_inline proc "c" (self: ^Device, size: NS.UInteger) -> ^AccelerationStructure { return msgSend(^AccelerationStructure, self, "newAccelerationStructureWithSize:", size) } @(objc_type=Device, objc_name="newArgumentEncoderWithArguments") -Device_newArgumentEncoderWithArguments :: #force_inline proc(self: ^Device, arguments: ^NS.Array) -> ^ArgumentEncoder { +Device_newArgumentEncoderWithArguments :: #force_inline proc "c" (self: ^Device, arguments: ^NS.Array) -> ^ArgumentEncoder { return msgSend(^ArgumentEncoder, self, "newArgumentEncoderWithArguments:", arguments) } @(objc_type=Device, objc_name="newBinaryArchive") -Device_newBinaryArchive :: #force_inline proc(self: ^Device, descriptor: ^BinaryArchiveDescriptor) -> (res: ^BinaryArchive, error: ^NS.Error) { +Device_newBinaryArchive :: #force_inline proc "contextless" (self: ^Device, descriptor: ^BinaryArchiveDescriptor) -> (res: ^BinaryArchive, error: ^NS.Error) { res = msgSend(^BinaryArchive, self, "newBinaryArchiveWithDescriptor:error:", descriptor, &error) return } @(objc_type=Device, objc_name="newBufferWithBytes") -Device_newBufferWithBytes :: #force_inline proc(self: ^Device, bytes: []byte, options: ResourceOptions) -> ^Buffer { +Device_newBufferWithBytes :: #force_inline proc "c" (self: ^Device, bytes: []byte, options: ResourceOptions) -> ^Buffer { return msgSend(^Buffer, self, "newBufferWithBytes:length:options:", raw_data(bytes), NS.UInteger(len(bytes)), options) } @(objc_type=Device, objc_name="newBufferWithBytesNoCopy") -Device_newBufferWithBytesNoCopy :: #force_inline proc(self: ^Device, bytes: []byte, options: ResourceOptions, deallocator: rawptr) -> ^Buffer { +Device_newBufferWithBytesNoCopy :: #force_inline proc "c" (self: ^Device, bytes: []byte, options: ResourceOptions, deallocator: rawptr) -> ^Buffer { return msgSend(^Buffer, self, "newBufferWithBytesNoCopy:length:options:deallocator:", raw_data(bytes), NS.UInteger(len(bytes)), options, deallocator) } - @(objc_type=Device, objc_name="newBufferWithSlice") -Device_newBufferWithSlice :: #force_inline proc(self: ^Device, slice: $S/[]$E, options: ResourceOptions) -> ^Buffer { +Device_newBufferWithSlice :: #force_inline proc "c" (self: ^Device, slice: $S/[]$E, options: ResourceOptions) -> ^Buffer { return Device_newBufferWithBytes(self, mem.slice_to_bytes(slice), options) } @(objc_type=Device, objc_name="newBufferWithSliceNoCopy") -Device_newBufferWithSliceNoCopy :: #force_inline proc(self: ^Device, slice: $S/[]$E, options: ResourceOptions, deallocator: rawptr) -> ^Buffer { +Device_newBufferWithSliceNoCopy :: #force_inline proc "c" (self: ^Device, slice: $S/[]$E, options: ResourceOptions, deallocator: rawptr) -> ^Buffer { return Device_newBufferWithBytesNotCopy(self, mem.slice_to_bytes(slice), options, deallocator) } +@(objc_type=Device, objc_name="newBufferWithLength") +Device_newBufferWithLength :: #force_inline proc "c" (self: ^Device, length: NS.UInteger, options: ResourceOptions) -> ^Buffer { + return msgSend(^Buffer, self, "newBufferWithLength:options:", length, options) +} @(objc_type=Device, objc_name="newBuffer") -Device_newBuffer :: #force_inline proc(self: ^Device, length: NS.UInteger, options: ResourceOptions) -> ^Buffer { - return msgSend(^Buffer, self, "newBufferWithLength:options:", length, options) +Device_newBuffer :: proc{ + Device_newBufferWithBytes, + Device_newBufferWithBytesNoCopy, + Device_newBufferWithSlice, + Device_newBufferWithSliceNoCopy, + Device_newBufferWithLength, } + @(objc_type=Device, objc_name="newCommandQueue") -Device_newCommandQueue :: #force_inline proc(self: ^Device) -> ^CommandQueue { +Device_newCommandQueue :: #force_inline proc "c" (self: ^Device) -> ^CommandQueue { return msgSend(^CommandQueue, self, "newCommandQueue") } @(objc_type=Device, objc_name="newCommandQueueWithMaxCommandBufferCount") -Device_newCommandQueueWithMaxCommandBufferCount :: #force_inline proc(self: ^Device, maxCommandBufferCount: NS.UInteger) -> ^CommandQueue { +Device_newCommandQueueWithMaxCommandBufferCount :: #force_inline proc "c" (self: ^Device, maxCommandBufferCount: NS.UInteger) -> ^CommandQueue { return msgSend(^CommandQueue, self, "newCommandQueueWithMaxCommandBufferCount:", maxCommandBufferCount) } @(objc_type=Device, objc_name="newComputePipelineStateWithDescriptorWithCompletionHandler") -Device_newComputePipelineStateWithDescriptorWithCompletionHandler :: #force_inline proc(self: ^Device, descriptor: ^ComputePipelineDescriptor, options: PipelineOption, completionHandler: NewComputePipelineStateWithReflectionCompletionHandler) -> ^ComputePipelineState { +Device_newComputePipelineStateWithDescriptorWithCompletionHandler :: #force_inline proc "c" (self: ^Device, descriptor: ^ComputePipelineDescriptor, options: PipelineOption, completionHandler: NewComputePipelineStateWithReflectionCompletionHandler) -> ^ComputePipelineState { return msgSend(^ComputePipelineState, self, "newComputePipelineStateWithDescriptor:options:completionHandler:", descriptor, options, completionHandler) } @(objc_type=Device, objc_name="newComputePipelineStateWithDescriptorWithReflection") -Device_newComputePipelineStateWithDescriptorWithReflection :: #force_inline proc(self: ^Device, descriptor: ^ComputePipelineDescriptor, options: PipelineOption, reflection: ^AutoreleasedComputePipelineReflection) -> (res: ^ComputePipelineState, error: ^NS.Error) { +Device_newComputePipelineStateWithDescriptorWithReflection :: #force_inline proc "contextless" (self: ^Device, descriptor: ^ComputePipelineDescriptor, options: PipelineOption, reflection: ^AutoreleasedComputePipelineReflection) -> (res: ^ComputePipelineState, error: ^NS.Error) { res = msgSend(^ComputePipelineState, self, "newComputePipelineStateWithDescriptor:options:reflection:error:", descriptor, options, reflection, &error) return } @(objc_type=Device, objc_name="newComputePipelineStateWithFunctionWithCompletionHandler") -Device_newComputePipelineStateWithFunctionWithCompletionHandler :: #force_inline proc(self: ^Device, computeFunction: ^Function, completionHandler: NewComputePipelineStateCompletionHandler) -> ^ComputePipelineState { +Device_newComputePipelineStateWithFunctionWithCompletionHandler :: #force_inline proc "c" (self: ^Device, computeFunction: ^Function, completionHandler: NewComputePipelineStateCompletionHandler) -> ^ComputePipelineState { return msgSend(^ComputePipelineState, self, "newComputePipelineStateWithFunction:completionHandler:", computeFunction, completionHandler) } @(objc_type=Device, objc_name="newComputePipelineStateWithFunction") -Device_newComputePipelineStateWithFunction :: #force_inline proc(self: ^Device, computeFunction: ^Function) -> (res: ^ComputePipelineState, error: ^NS.Error) { +Device_newComputePipelineStateWithFunction :: #force_inline proc "contextless" (self: ^Device, computeFunction: ^Function) -> (res: ^ComputePipelineState, error: ^NS.Error) { res = msgSend(^ComputePipelineState, self, "newComputePipelineStateWithFunction:error:", computeFunction, &error) return } @(objc_type=Device, objc_name="newComputePipelineStateWithFunctionWithOptionsAndCompletionHandler") -Device_newComputePipelineStateWithFunctionWithOptionsAndCompletionHandler :: #force_inline proc(self: ^Device, computeFunction: ^Function, options: PipelineOption, completionHandler: NewComputePipelineStateWithReflectionCompletionHandler) -> (res: ^ComputePipelineState) { +Device_newComputePipelineStateWithFunctionWithOptionsAndCompletionHandler :: #force_inline proc "c" (self: ^Device, computeFunction: ^Function, options: PipelineOption, completionHandler: NewComputePipelineStateWithReflectionCompletionHandler) -> (res: ^ComputePipelineState) { return msgSend(^ComputePipelineState, self, "newComputePipelineStateWithFunction:options:completionHandler:", computeFunction, options, completionHandler) } @(objc_type=Device, objc_name="newComputePipelineStateWithFunctionWithReflection") -Device_newComputePipelineStateWithFunctionWithReflection :: #force_inline proc(self: ^Device, computeFunction: ^Function, options: PipelineOption, reflection: ^AutoreleasedComputePipelineReflection) -> (res: ^ComputePipelineState, error: ^NS.Error) { +Device_newComputePipelineStateWithFunctionWithReflection :: #force_inline proc "contextless" (self: ^Device, computeFunction: ^Function, options: PipelineOption, reflection: ^AutoreleasedComputePipelineReflection) -> (res: ^ComputePipelineState, error: ^NS.Error) { res = msgSend(^ComputePipelineState, self, "newComputePipelineStateWithFunction:options:reflection:error:", computeFunction, options, reflection, &error) return } @@ -6545,71 +5442,71 @@ Device_newComputePipelineState :: proc{ } @(objc_type=Device, objc_name="newCounterSampleBuffer") -Device_newCounterSampleBuffer :: #force_inline proc(self: ^Device, descriptor: ^CounterSampleBufferDescriptor) -> (counter: ^Counter, error: ^NS.Error) { +Device_newCounterSampleBuffer :: #force_inline proc "contextless" (self: ^Device, descriptor: ^CounterSampleBufferDescriptor) -> (counter: ^Counter, error: ^NS.Error) { counter = msgSend(^Counter, self, "newCounterSampleBufferWithDescriptor:error:", descriptor, &error) return } @(objc_type=Device, objc_name="newDefaultLibrary") -Device_newDefaultLibrary :: #force_inline proc(self: ^Device) -> ^Library { +Device_newDefaultLibrary :: #force_inline proc "c" (self: ^Device) -> ^Library { return msgSend(^Library, self, "newDefaultLibrary") } @(objc_type=Device, objc_name="newDefaultLibraryWithBundle") -Device_newDefaultLibraryWithBundle :: #force_inline proc(self: ^Device, bundle: ^NS.Bundle) -> (library: ^Library, error: ^NS.Error) { +Device_newDefaultLibraryWithBundle :: #force_inline proc "contextless" (self: ^Device, bundle: ^NS.Bundle) -> (library: ^Library, error: ^NS.Error) { library = msgSend(^Library, self, "newDefaultLibraryWithBundle:error:", bundle, &error) return } @(objc_type=Device, objc_name="newDepthStencilState") -Device_newDepthStencilState :: #force_inline proc(self: ^Device, descriptor: ^DepthStencilDescriptor) -> ^DepthStencilState { +Device_newDepthStencilState :: #force_inline proc "c" (self: ^Device, descriptor: ^DepthStencilDescriptor) -> ^DepthStencilState { return msgSend(^DepthStencilState, self, "newDepthStencilStateWithDescriptor:", descriptor) } @(objc_type=Device, objc_name="newDynamicLibrary") -Device_newDynamicLibrary :: #force_inline proc(self: ^Device, library: ^Library) -> (dyn_library: ^DynamicLibrary, error: ^NS.Error) { +Device_newDynamicLibrary :: #force_inline proc "contextless" (self: ^Device, library: ^Library) -> (dyn_library: ^DynamicLibrary, error: ^NS.Error) { dyn_library = msgSend(^DynamicLibrary, self, "newDynamicLibrary:error:", library, &error) return } @(objc_type=Device, objc_name="newDynamicLibraryWithURL") -Device_newDynamicLibraryWithURL :: #force_inline proc(self: ^Device, url: ^NS.URL) -> (dyn_library: ^DynamicLibrary, error: ^NS.Error) { +Device_newDynamicLibraryWithURL :: #force_inline proc "contextless" (self: ^Device, url: ^NS.URL) -> (dyn_library: ^DynamicLibrary, error: ^NS.Error) { dyn_library = msgSend(^DynamicLibrary, self, "newDynamicLibraryWithURL:error:", url, &error) return } @(objc_type=Device, objc_name="newEvent") -Device_newEvent :: #force_inline proc(self: ^Device) -> ^Event { +Device_newEvent :: #force_inline proc "c" (self: ^Device) -> ^Event { return msgSend(^Event, self, "newEvent") } @(objc_type=Device, objc_name="newFence") -Device_newFence :: #force_inline proc(self: ^Device) -> ^Fence { +Device_newFence :: #force_inline proc "c" (self: ^Device) -> ^Fence { return msgSend(^Fence, self, "newFence") } @(objc_type=Device, objc_name="newHeap") -Device_newHeap :: #force_inline proc(self: ^Device, descriptor: ^HeapDescriptor) -> ^Heap { +Device_newHeap :: #force_inline proc "c" (self: ^Device, descriptor: ^HeapDescriptor) -> ^Heap { return msgSend(^Heap, self, "newHeapWithDescriptor:", descriptor) } @(objc_type=Device, objc_name="newIndirectCommandBuffer") -Device_newIndirectCommandBuffer :: #force_inline proc(self: ^Device, descriptor: ^IndirectCommandBufferDescriptor, maxCount: NS.UInteger, options: ResourceOptions) -> ^IndirectCommandBuffer { +Device_newIndirectCommandBuffer :: #force_inline proc "c" (self: ^Device, descriptor: ^IndirectCommandBufferDescriptor, maxCount: NS.UInteger, options: ResourceOptions) -> ^IndirectCommandBuffer { return msgSend(^IndirectCommandBuffer, self, "newIndirectCommandBufferWithDescriptor:maxCommandCount:options:", descriptor, maxCount, options) } @(objc_type=Device, objc_name="newLibraryWithData") -Device_newLibraryWithData :: #force_inline proc(self: ^Device, data: dispatch_data_t) -> (library: ^Library, error: ^NS.Error) { +Device_newLibraryWithData :: #force_inline proc "contextless" (self: ^Device, data: dispatch_data_t) -> (library: ^Library, error: ^NS.Error) { library = msgSend(^Library, self, "newLibraryWithData:error:", data, &error) return } @(objc_type=Device, objc_name="newLibraryWithFile") -Device_newLibraryWithFile :: #force_inline proc(self: ^Device, filepath: ^NS.String) -> (library: ^Library, error: ^NS.Error) { +Device_newLibraryWithFile :: #force_inline proc "contextless" (self: ^Device, filepath: ^NS.String) -> (library: ^Library, error: ^NS.Error) { library = msgSend(^Library, self, "newLibraryWithFile:error:", filepath, &error) return } @(objc_type=Device, objc_name="newLibraryWithSourceWithCompletionHandler") -Device_newLibraryWithSourceWithCompletionHandler :: #force_inline proc(self: ^Device, source: ^NS.String, options: ^CompileOptions, completionHandler: NewLibraryCompletionHandler) -> ^Library { +Device_newLibraryWithSourceWithCompletionHandler :: #force_inline proc "c" (self: ^Device, source: ^NS.String, options: ^CompileOptions, completionHandler: NewLibraryCompletionHandler) -> ^Library { return msgSend(^Library, self, "newLibraryWithSource:options:completionHandler:", source, options, completionHandler) } @(objc_type=Device, objc_name="newLibraryWithSource") -Device_newLibraryWithSource :: #force_inline proc(self: ^Device, source: ^NS.String, options: ^CompileOptions) -> (library: ^Library, error: ^NS.Error) { +Device_newLibraryWithSource :: #force_inline proc "contextless" (self: ^Device, source: ^NS.String, options: ^CompileOptions) -> (library: ^Library, error: ^NS.Error) { library = msgSend(^Library, self, "newLibraryWithSource:options:error:", source, options, &error) return } @(objc_type=Device, objc_name="newLibraryWithURL") -Device_newLibraryWithURL :: #force_inline proc(self: ^Device, url: ^NS.URL) -> (library: ^Library, error: ^NS.Error) { +Device_newLibraryWithURL :: #force_inline proc "contextless" (self: ^Device, url: ^NS.URL) -> (library: ^Library, error: ^NS.Error) { library = msgSend(^Library, self, "newLibraryWithURL:error:", url, &error) return } @@ -6624,34 +5521,34 @@ Device_newLibrary :: proc{ @(objc_type=Device, objc_name="newRasterizationRateMap") -Device_newRasterizationRateMap :: #force_inline proc(self: ^Device, descriptor: ^RasterizationRateMapDescriptor) -> ^RasterizationRateMap { +Device_newRasterizationRateMap :: #force_inline proc "c" (self: ^Device, descriptor: ^RasterizationRateMapDescriptor) -> ^RasterizationRateMap { return msgSend(^RasterizationRateMap, self, "newRasterizationRateMapWithDescriptor:", descriptor) } @(objc_type=Device, objc_name="newRenderPipelineStateWithDescriptorWithCompletionHandler") -Device_newRenderPipelineStateWithDescriptorWithCompletionHandler :: #force_inline proc(self: ^Device, descriptor: ^RenderPipelineDescriptor, completionHandler: NewRenderPipelineStateCompletionHandler) -> ^RenderPipelineState { +Device_newRenderPipelineStateWithDescriptorWithCompletionHandler :: #force_inline proc "c" (self: ^Device, descriptor: ^RenderPipelineDescriptor, completionHandler: NewRenderPipelineStateCompletionHandler) -> ^RenderPipelineState { return msgSend(^RenderPipelineState, self, "newRenderPipelineStateWithDescriptor:completionHandler:", descriptor, completionHandler) } @(objc_type=Device, objc_name="newRenderPipelineStateWithDescriptor") -Device_newRenderPipelineStateWithDescriptor :: #force_inline proc(self: ^Device, descriptor: ^RenderPipelineDescriptor) -> (pipeline: ^RenderPipelineState, error: ^NS.Error) { +Device_newRenderPipelineStateWithDescriptor :: #force_inline proc "contextless" (self: ^Device, descriptor: ^RenderPipelineDescriptor) -> (pipeline: ^RenderPipelineState, error: ^NS.Error) { pipeline = msgSend(^RenderPipelineState, self, "newRenderPipelineStateWithDescriptor:error:", descriptor, &error) return } @(objc_type=Device, objc_name="newRenderPipelineStateWithDescriptorWithOptionsAndCompletionHandler") -Device_newRenderPipelineStateWithDescriptorWithOptionsAndCompletionHandler :: #force_inline proc(self: ^Device, descriptor: ^RenderPipelineDescriptor, options: PipelineOption, completionHandler: NewRenderPipelineStateWithReflectionCompletionHandler) -> ^RenderPipelineState { +Device_newRenderPipelineStateWithDescriptorWithOptionsAndCompletionHandler :: #force_inline proc "c" (self: ^Device, descriptor: ^RenderPipelineDescriptor, options: PipelineOption, completionHandler: NewRenderPipelineStateWithReflectionCompletionHandler) -> ^RenderPipelineState { return msgSend(^RenderPipelineState, self, "newRenderPipelineStateWithDescriptor:options:completionHandler:", descriptor, options, completionHandler) } @(objc_type=Device, objc_name="newRenderPipelineStateWithDescriptorWithReflection") -Device_newRenderPipelineStateWithDescriptorWithReflection :: #force_inline proc(self: ^Device, descriptor: ^RenderPipelineDescriptor, options: PipelineOption, reflection: ^AutoreleasedRenderPipelineReflection) -> (pipeline: ^RenderPipelineState, error: ^NS.Error) { +Device_newRenderPipelineStateWithDescriptorWithReflection :: #force_inline proc "contextless" (self: ^Device, descriptor: ^RenderPipelineDescriptor, options: PipelineOption, reflection: ^AutoreleasedRenderPipelineReflection) -> (pipeline: ^RenderPipelineState, error: ^NS.Error) { pipeline = msgSend(^RenderPipelineState, self, "newRenderPipelineStateWithDescriptor:options:reflection:error:", descriptor, options, reflection, &error) return } @(objc_type=Device, objc_name="newRenderPipelineStateWithTileDescriptorWithCompletionHandler") -Device_newRenderPipelineStateWithTileDescriptorWithCompletionHandler :: #force_inline proc(self: ^Device, descriptor: ^TileRenderPipelineDescriptor, options: PipelineOption, completionHandler: NewRenderPipelineStateWithReflectionCompletionHandler) -> ^RenderPipelineState { +Device_newRenderPipelineStateWithTileDescriptorWithCompletionHandler :: #force_inline proc "c" (self: ^Device, descriptor: ^TileRenderPipelineDescriptor, options: PipelineOption, completionHandler: NewRenderPipelineStateWithReflectionCompletionHandler) -> ^RenderPipelineState { return msgSend(^RenderPipelineState, self, "newRenderPipelineStateWithTileDescriptor:options:completionHandler:", descriptor, options, completionHandler) } @(objc_type=Device, objc_name="newRenderPipelineStateWithTileDescriptorWithReflection") -Device_newRenderPipelineStateWithTileDescriptorWithReflection :: #force_inline proc(self: ^Device, descriptor: ^TileRenderPipelineDescriptor, options: PipelineOption, reflection: ^AutoreleasedRenderPipelineReflection) -> (pipeline: ^RenderPipelineState, error: ^NS.Error) { +Device_newRenderPipelineStateWithTileDescriptorWithReflection :: #force_inline proc "contextless" (self: ^Device, descriptor: ^TileRenderPipelineDescriptor, options: PipelineOption, reflection: ^AutoreleasedRenderPipelineReflection) -> (pipeline: ^RenderPipelineState, error: ^NS.Error) { pipeline = msgSend(^RenderPipelineState, self, "newRenderPipelineStateWithTileDescriptor:options:reflection:error:", descriptor, options, reflection, &error) return } @@ -6667,23 +5564,23 @@ Device_newRenderPipelineState :: proc{ @(objc_type=Device, objc_name="newSamplerState") -Device_newSamplerState :: #force_inline proc(self: ^Device, descriptor: ^SamplerDescriptor) -> ^SamplerState { +Device_newSamplerState :: #force_inline proc "c" (self: ^Device, descriptor: ^SamplerDescriptor) -> ^SamplerState { return msgSend(^SamplerState, self, "newSamplerStateWithDescriptor:", descriptor) } @(objc_type=Device, objc_name="newSharedEvent") -Device_newSharedEvent :: #force_inline proc(self: ^Device) -> ^SharedEvent { +Device_newSharedEvent :: #force_inline proc "c" (self: ^Device) -> ^SharedEvent { return msgSend(^SharedEvent, self, "newSharedEvent") } @(objc_type=Device, objc_name="newSharedEventWithHandle") -Device_newSharedEventWithHandle :: #force_inline proc(self: ^Device, sharedEventHandle: ^SharedEventHandle) -> ^SharedEvent { +Device_newSharedEventWithHandle :: #force_inline proc "c" (self: ^Device, sharedEventHandle: ^SharedEventHandle) -> ^SharedEvent { return msgSend(^SharedEvent, self, "newSharedEventWithHandle:", sharedEventHandle) } @(objc_type=Device, objc_name="newSharedTextureWithDescriptor") -Device_newSharedTextureWithDescriptor :: #force_inline proc(self: ^Device, descriptor: ^TextureDescriptor) -> ^SharedEvent { +Device_newSharedTextureWithDescriptor :: #force_inline proc "c" (self: ^Device, descriptor: ^TextureDescriptor) -> ^SharedEvent { return msgSend(^SharedEvent, self, "newSharedTextureWithDescriptor:", descriptor) } @(objc_type=Device, objc_name="newSharedTextureWithHandle") -Device_newSharedTextureWithHandle :: #force_inline proc(self: ^Device, sharedHandle: ^SharedTextureHandle) -> ^SharedEvent { +Device_newSharedTextureWithHandle :: #force_inline proc "c" (self: ^Device, sharedHandle: ^SharedTextureHandle) -> ^SharedEvent { return msgSend(^SharedEvent, self, "newSharedTextureWithHandle:", sharedHandle) } @(objc_type=Device, objc_name="newSharedTexture") @@ -6693,11 +5590,11 @@ Device_newSharedTexture :: proc{ } @(objc_type=Device, objc_name="newTextureWithDescriptor") -Device_newTextureWithDescriptor :: #force_inline proc(self: ^Device, desc: ^TextureDescriptor) -> ^Texture { +Device_newTextureWithDescriptor :: #force_inline proc "c" (self: ^Device, desc: ^TextureDescriptor) -> ^Texture { return msgSend(^Texture, self, "newTextureWithDescriptor:", desc) } @(objc_type=Device, objc_name="newTextureWithIOSurface") -Device_newTextureWithIOSurface :: #force_inline proc(self: ^Device, descriptor: ^TextureDescriptor, iosurface: IOSurfaceRef, plane: NS.UInteger) -> ^Texture { +Device_newTextureWithIOSurface :: #force_inline proc "c" (self: ^Device, descriptor: ^TextureDescriptor, iosurface: IOSurfaceRef, plane: NS.UInteger) -> ^Texture { return msgSend(^Texture, self, "newTextureWithDescriptor:iosurface:plane:", descriptor, iosurface, plane) } @(objc_type=Device, objc_name="newTexture") @@ -6707,472 +5604,386 @@ Device_newTexture :: proc{ } @(objc_type=Device, objc_name="peerCount") -Device_peerCount :: #force_inline proc(self: ^Device) -> u32 { +Device_peerCount :: #force_inline proc "c" (self: ^Device) -> u32 { return msgSend(u32, self, "peerCount") } @(objc_type=Device, objc_name="peerGroupID") -Device_peerGroupID :: #force_inline proc(self: ^Device) -> u64 { +Device_peerGroupID :: #force_inline proc "c" (self: ^Device) -> u64 { return msgSend(u64, self, "peerGroupID") } @(objc_type=Device, objc_name="peerIndex") -Device_peerIndex :: #force_inline proc(self: ^Device) -> u32 { +Device_peerIndex :: #force_inline proc "c" (self: ^Device) -> u32 { return msgSend(u32, self, "peerIndex") } @(objc_type=Device, objc_name="readWriteTextureSupport") -Device_readWriteTextureSupport :: #force_inline proc(self: ^Device) -> ReadWriteTextureTier { +Device_readWriteTextureSupport :: #force_inline proc "c" (self: ^Device) -> ReadWriteTextureTier { return msgSend(ReadWriteTextureTier, self, "readWriteTextureSupport") } @(objc_type=Device, objc_name="recommendedMaxWorkingSetSize") -Device_recommendedMaxWorkingSetSize :: #force_inline proc(self: ^Device) -> u64 { +Device_recommendedMaxWorkingSetSize :: #force_inline proc "c" (self: ^Device) -> u64 { return msgSend(u64, self, "recommendedMaxWorkingSetSize") } @(objc_type=Device, objc_name="registryID") -Device_registryID :: #force_inline proc(self: ^Device) -> u64 { +Device_registryID :: #force_inline proc "c" (self: ^Device) -> u64 { return msgSend(u64, self, "registryID") } @(objc_type=Device, objc_name="sampleTimestamps") -Device_sampleTimestamps :: #force_inline proc(self: ^Device, cpuTimestamp: ^Timestamp, gpuTimestamp: ^Timestamp) { +Device_sampleTimestamps :: #force_inline proc "c" (self: ^Device, cpuTimestamp: ^Timestamp, gpuTimestamp: ^Timestamp) { msgSend(nil, self, "sampleTimestamps:gpuTimestamp:", cpuTimestamp, gpuTimestamp) } @(objc_type=Device, objc_name="sparseTileSizeInBytes") -Device_sparseTileSizeInBytes :: #force_inline proc(self: ^Device) -> NS.UInteger { +Device_sparseTileSizeInBytes :: #force_inline proc "c" (self: ^Device) -> NS.UInteger { return msgSend(NS.UInteger, self, "sparseTileSizeInBytes") } @(objc_type=Device, objc_name="sparseTileSizeWithTextureType") -Device_sparseTileSizeWithTextureType :: #force_inline proc(self: ^Device, textureType: TextureType, pixelFormat: PixelFormat, sampleCount: NS.UInteger) -> Size { +Device_sparseTileSizeWithTextureType :: #force_inline proc "c" (self: ^Device, textureType: TextureType, pixelFormat: PixelFormat, sampleCount: NS.UInteger) -> Size { return msgSend(Size, self, "sparseTileSizeWithTextureType:pixelFormat:sampleCount:", textureType, pixelFormat, sampleCount) } @(objc_type=Device, objc_name="supports32BitFloatFiltering") -Device_supports32BitFloatFiltering :: #force_inline proc(self: ^Device) -> BOOL { +Device_supports32BitFloatFiltering :: #force_inline proc "c" (self: ^Device) -> BOOL { return msgSend(BOOL, self, "supports32BitFloatFiltering") } @(objc_type=Device, objc_name="supports32BitMSAA") -Device_supports32BitMSAA :: #force_inline proc(self: ^Device) -> BOOL { +Device_supports32BitMSAA :: #force_inline proc "c" (self: ^Device) -> BOOL { return msgSend(BOOL, self, "supports32BitMSAA") } @(objc_type=Device, objc_name="supportsBCTextureCompression") -Device_supportsBCTextureCompression :: #force_inline proc(self: ^Device) -> BOOL { +Device_supportsBCTextureCompression :: #force_inline proc "c" (self: ^Device) -> BOOL { return msgSend(BOOL, self, "supportsBCTextureCompression") } @(objc_type=Device, objc_name="supportsCounterSampling") -Device_supportsCounterSampling :: #force_inline proc(self: ^Device, samplingPoint: CounterSamplingPoint) -> BOOL { +Device_supportsCounterSampling :: #force_inline proc "c" (self: ^Device, samplingPoint: CounterSamplingPoint) -> BOOL { return msgSend(BOOL, self, "supportsCounterSampling:", samplingPoint) } @(objc_type=Device, objc_name="supportsDynamicLibraries") -Device_supportsDynamicLibraries :: #force_inline proc(self: ^Device) -> BOOL { +Device_supportsDynamicLibraries :: #force_inline proc "c" (self: ^Device) -> BOOL { return msgSend(BOOL, self, "supportsDynamicLibraries") } @(objc_type=Device, objc_name="supportsFamily") -Device_supportsFamily :: #force_inline proc(self: ^Device, gpuFamily: GPUFamily) -> BOOL { +Device_supportsFamily :: #force_inline proc "c" (self: ^Device, gpuFamily: GPUFamily) -> BOOL { return msgSend(BOOL, self, "supportsFamily:", gpuFamily) } @(objc_type=Device, objc_name="supportsFeatureSet") -Device_supportsFeatureSet :: #force_inline proc(self: ^Device, featureSet: FeatureSet) -> BOOL { +Device_supportsFeatureSet :: #force_inline proc "c" (self: ^Device, featureSet: FeatureSet) -> BOOL { return msgSend(BOOL, self, "supportsFeatureSet:", featureSet) } @(objc_type=Device, objc_name="supportsFunctionPointers") -Device_supportsFunctionPointers :: #force_inline proc(self: ^Device) -> BOOL { +Device_supportsFunctionPointers :: #force_inline proc "c" (self: ^Device) -> BOOL { return msgSend(BOOL, self, "supportsFunctionPointers") } @(objc_type=Device, objc_name="supportsPullModelInterpolation") -Device_supportsPullModelInterpolation :: #force_inline proc(self: ^Device) -> BOOL { +Device_supportsPullModelInterpolation :: #force_inline proc "c" (self: ^Device) -> BOOL { return msgSend(BOOL, self, "supportsPullModelInterpolation") } @(objc_type=Device, objc_name="supportsQueryTextureLOD") -Device_supportsQueryTextureLOD :: #force_inline proc(self: ^Device) -> BOOL { +Device_supportsQueryTextureLOD :: #force_inline proc "c" (self: ^Device) -> BOOL { return msgSend(BOOL, self, "supportsQueryTextureLOD") } @(objc_type=Device, objc_name="supportsRasterizationRateMapWithLayerCount") -Device_supportsRasterizationRateMapWithLayerCount :: #force_inline proc(self: ^Device, layerCount: NS.UInteger) -> BOOL { +Device_supportsRasterizationRateMapWithLayerCount :: #force_inline proc "c" (self: ^Device, layerCount: NS.UInteger) -> BOOL { return msgSend(BOOL, self, "supportsRasterizationRateMapWithLayerCount:", layerCount) } @(objc_type=Device, objc_name="supportsRaytracing") -Device_supportsRaytracing :: #force_inline proc(self: ^Device) -> BOOL { +Device_supportsRaytracing :: #force_inline proc "c" (self: ^Device) -> BOOL { return msgSend(BOOL, self, "supportsRaytracing") } @(objc_type=Device, objc_name="supportsShaderBarycentricCoordinates") -Device_supportsShaderBarycentricCoordinates :: #force_inline proc(self: ^Device) -> BOOL { +Device_supportsShaderBarycentricCoordinates :: #force_inline proc "c" (self: ^Device) -> BOOL { return msgSend(BOOL, self, "supportsShaderBarycentricCoordinates") } @(objc_type=Device, objc_name="supportsTextureSampleCount") -Device_supportsTextureSampleCount :: #force_inline proc(self: ^Device, sampleCount: NS.UInteger) -> BOOL { +Device_supportsTextureSampleCount :: #force_inline proc "c" (self: ^Device, sampleCount: NS.UInteger) -> BOOL { return msgSend(BOOL, self, "supportsTextureSampleCount:", sampleCount) } @(objc_type=Device, objc_name="supportsVertexAmplificationCount") -Device_supportsVertexAmplificationCount :: #force_inline proc(self: ^Device, count: NS.UInteger) -> BOOL { +Device_supportsVertexAmplificationCount :: #force_inline proc "c" (self: ^Device, count: NS.UInteger) -> BOOL { return msgSend(BOOL, self, "supportsVertexAmplificationCount:", count) } + +@(objc_type=Device, objc_name="newRenderPipelineStateWithMeshDescriptor") +Device_newRenderPipelineStateWithMeshDescriptor :: #force_inline proc "contextless" (self: ^Device, options: PipelineOption, reflection: ^AutoreleasedRenderPipelineReflection) -> (state: ^RenderPipelineState, error: ^NS.Error) { + state = msgSend(^RenderPipelineState, self, "newRenderPipelineStateWithMeshDescriptor:options:reflection:error:", options, reflection, &error) + return +} +@(objc_type=Device, objc_name="newRenderPipelineStateWithMeshDescriptorAndCompletionHandler") +Device_newRenderPipelineStateWithMeshDescriptorAndCompletionHandler :: #force_inline proc "c" (self: ^Device, options: PipelineOption, completionHandler: ^NewRenderPipelineStateWithReflectionCompletionHandler) -> (state: ^RenderPipelineState) { + state = msgSend(^RenderPipelineState, self, "newRenderPipelineStateWithMeshDescriptor:options:completionHandler:", options, completionHandler) + return +} + +@(objc_type=Device, objc_name="newIOHandle") +Device_newIOHandle :: #force_inline proc "contextless" (self: ^Device, url: ^NS.URL) -> (handle: ^IOFileHandle, err: ^NS.Error) { + handle = msgSend(^IOFileHandle, self, "newIOHandleWithURL:error:", url, &err) + return +} +@(objc_type=Device, objc_name="newIOHandleWithCompressionMethod") +Device_newIOHandleWithCompressionMethod :: #force_inline proc "contextless" (self: ^Device, url: ^NS.URL, compressionMethod: IOCompressionMethod) -> (handle: ^IOFileHandle, err: ^NS.Error) { + handle = msgSend(^IOFileHandle, self, "newIOHandleWithURL:compressionMethod:error:", url, compressionMethod, &err) + return +} +@(objc_type=Device, objc_name="newIOCommandQueue") +Device_newIOCommandQueue :: #force_inline proc "contextless" (self: ^Device, descriptor: ^IOCommandQueueDescriptor) -> (handle: ^IOCommandQueue, err: ^NS.Error) { + handle = msgSend(^IOCommandQueue, self, "newIOCommandQueueWithDescriptor:error:", descriptor, &err) + return +} + //////////////////////////////////////////////////////////////////////////////// -/* -Class: - Drawable -Class Methods: -Methods: - addPresentedHandler - drawableID - present - presentAfterMinimumDuration - presentAtTime - presentedTime -*/ @(objc_class="MTLDrawable") Drawable :: struct { using _: NS.Object } @(objc_type=Drawable, objc_name="addPresentedHandler") -Drawable_addPresentedHandler :: #force_inline proc(self: ^Drawable, block: DrawablePresentedHandler) { +Drawable_addPresentedHandler :: #force_inline proc "c" (self: ^Drawable, block: DrawablePresentedHandler) { msgSend(nil, self, "addPresentedHandler:", block) } @(objc_type=Drawable, objc_name="drawableID") -Drawable_drawableID :: #force_inline proc(self: ^Drawable) -> NS.UInteger { +Drawable_drawableID :: #force_inline proc "c" (self: ^Drawable) -> NS.UInteger { return msgSend(NS.UInteger, self, "drawableID") } @(objc_type=Drawable, objc_name="present") -Drawable_present :: #force_inline proc(self: ^Drawable) { +Drawable_present :: #force_inline proc "c" (self: ^Drawable) { msgSend(nil, self, "present") } @(objc_type=Drawable, objc_name="presentAfterMinimumDuration") -Drawable_presentAfterMinimumDuration :: #force_inline proc(self: ^Drawable, duration: CFTimeInterval) { +Drawable_presentAfterMinimumDuration :: #force_inline proc "c" (self: ^Drawable, duration: CFTimeInterval) { msgSend(nil, self, "presentAfterMinimumDuration:", duration) } @(objc_type=Drawable, objc_name="presentAtTime") -Drawable_presentAtTime :: #force_inline proc(self: ^Drawable, presentationTime: CFTimeInterval) { +Drawable_presentAtTime :: #force_inline proc "c" (self: ^Drawable, presentationTime: CFTimeInterval) { msgSend(nil, self, "presentAtTime:", presentationTime) } @(objc_type=Drawable, objc_name="presentedTime") -Drawable_presentedTime :: #force_inline proc(self: ^Drawable) -> CFTimeInterval { +Drawable_presentedTime :: #force_inline proc "c" (self: ^Drawable) -> CFTimeInterval { return msgSend(CFTimeInterval, self, "presentedTime") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - DynamicLibrary -Class Methods: -Methods: - device - installName - label - serializeToURL - setLabel -*/ @(objc_class="MTLDynamicLibrary") DynamicLibrary :: struct { using _: NS.Object } @(objc_type=DynamicLibrary, objc_name="device") -DynamicLibrary_device :: #force_inline proc(self: ^DynamicLibrary) -> ^Device { +DynamicLibrary_device :: #force_inline proc "c" (self: ^DynamicLibrary) -> ^Device { return msgSend(^Device, self, "device") } @(objc_type=DynamicLibrary, objc_name="installName") -DynamicLibrary_installName :: #force_inline proc(self: ^DynamicLibrary) -> ^NS.String { +DynamicLibrary_installName :: #force_inline proc "c" (self: ^DynamicLibrary) -> ^NS.String { return msgSend(^NS.String, self, "installName") } @(objc_type=DynamicLibrary, objc_name="label") -DynamicLibrary_label :: #force_inline proc(self: ^DynamicLibrary) -> ^NS.String { +DynamicLibrary_label :: #force_inline proc "c" (self: ^DynamicLibrary) -> ^NS.String { return msgSend(^NS.String, self, "label") } @(objc_type=DynamicLibrary, objc_name="serializeToURL") -DynamicLibrary_serializeToURL :: #force_inline proc(self: ^DynamicLibrary, url: ^NS.URL) -> (ok: BOOL, error: ^NS.Error) { +DynamicLibrary_serializeToURL :: #force_inline proc "contextless" (self: ^DynamicLibrary, url: ^NS.URL) -> (ok: BOOL, error: ^NS.Error) { ok = msgSend(BOOL, self, "serializeToURL:error:", url, &error) return } @(objc_type=DynamicLibrary, objc_name="setLabel") -DynamicLibrary_setLabel :: #force_inline proc(self: ^DynamicLibrary, label: ^NS.String) { +DynamicLibrary_setLabel :: #force_inline proc "c" (self: ^DynamicLibrary, label: ^NS.String) { msgSend(nil, self, "setLabel:", label) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - Event -Class Methods: -Methods: - device - label - setLabel -*/ @(objc_class="MTLEvent") Event :: struct { using _: NS.Object } @(objc_type=Event, objc_name="device") -Event_device :: #force_inline proc(self: ^Event) -> ^Device { +Event_device :: #force_inline proc "c" (self: ^Event) -> ^Device { return msgSend(^Device, self, "device") } @(objc_type=Event, objc_name="label") -Event_label :: #force_inline proc(self: ^Event) -> ^NS.String { +Event_label :: #force_inline proc "c" (self: ^Event) -> ^NS.String { return msgSend(^NS.String, self, "label") } @(objc_type=Event, objc_name="setLabel") -Event_setLabel :: #force_inline proc(self: ^Event, label: ^NS.String) { +Event_setLabel :: #force_inline proc "c" (self: ^Event, label: ^NS.String) { msgSend(nil, self, "setLabel:", label) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - Fence -Class Methods: -Methods: - device - label - setLabel -*/ @(objc_class="MTLFence") Fence :: struct { using _: NS.Object } @(objc_type=Fence, objc_name="device") -Fence_device :: #force_inline proc(self: ^Fence) -> ^Device { +Fence_device :: #force_inline proc "c" (self: ^Fence) -> ^Device { return msgSend(^Device, self, "device") } @(objc_type=Fence, objc_name="label") -Fence_label :: #force_inline proc(self: ^Fence) -> ^NS.String { +Fence_label :: #force_inline proc "c" (self: ^Fence) -> ^NS.String { return msgSend(^NS.String, self, "label") } @(objc_type=Fence, objc_name="setLabel") -Fence_setLabel :: #force_inline proc(self: ^Fence, label: ^NS.String) { +Fence_setLabel :: #force_inline proc "c" (self: ^Fence, label: ^NS.String) { msgSend(nil, self, "setLabel:", label) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - Function -Class Methods: -Methods: - device - functionConstantsDictionary - functionType - label - name - newArgumentEncoderWithBufferIndex - newArgumentEncoderWithBufferIndex - options - patchControlPointCount - patchType - setLabel - stageInputAttributes - vertexAttributes -*/ @(objc_class="MTLFunction") Function :: struct { using _: NS.Object } @(objc_type=Function, objc_name="device") -Function_device :: #force_inline proc(self: ^Function) -> ^Device { +Function_device :: #force_inline proc "c" (self: ^Function) -> ^Device { return msgSend(^Device, self, "device") } @(objc_type=Function, objc_name="functionConstantsDictionary") -Function_functionConstantsDictionary :: #force_inline proc(self: ^Function) -> ^NS.Dictionary { +Function_functionConstantsDictionary :: #force_inline proc "c" (self: ^Function) -> ^NS.Dictionary { return msgSend(^NS.Dictionary, self, "functionConstantsDictionary") } @(objc_type=Function, objc_name="functionType") -Function_functionType :: #force_inline proc(self: ^Function) -> FunctionType { +Function_functionType :: #force_inline proc "c" (self: ^Function) -> FunctionType { return msgSend(FunctionType, self, "functionType") } @(objc_type=Function, objc_name="label") -Function_label :: #force_inline proc(self: ^Function) -> ^NS.String { +Function_label :: #force_inline proc "c" (self: ^Function) -> ^NS.String { return msgSend(^NS.String, self, "label") } @(objc_type=Function, objc_name="name") -Function_name :: #force_inline proc(self: ^Function) -> ^NS.String { +Function_name :: #force_inline proc "c" (self: ^Function) -> ^NS.String { return msgSend(^NS.String, self, "name") } @(objc_type=Function, objc_name="newArgumentEncoder") -Function_newArgumentEncoder :: #force_inline proc(self: ^Function, bufferIndex: NS.UInteger) -> ^ArgumentEncoder { +Function_newArgumentEncoder :: #force_inline proc "c" (self: ^Function, bufferIndex: NS.UInteger) -> ^ArgumentEncoder { return msgSend(^ArgumentEncoder, self, "newArgumentEncoderWithBufferIndex:", bufferIndex) } @(objc_type=Function, objc_name="newArgumentEncoderWithReflection") -Function_newArgumentEncoderWithReflection :: #force_inline proc(self: ^Function, bufferIndex: NS.UInteger, reflection: ^AutoreleasedArgument) -> ^ArgumentEncoder { +Function_newArgumentEncoderWithReflection :: #force_inline proc "c" (self: ^Function, bufferIndex: NS.UInteger, reflection: ^AutoreleasedArgument) -> ^ArgumentEncoder { return msgSend(^ArgumentEncoder, self, "newArgumentEncoderWithBufferIndex:reflection:", bufferIndex, reflection) } @(objc_type=Function, objc_name="options") -Function_options :: #force_inline proc(self: ^Function) -> FunctionOptions { +Function_options :: #force_inline proc "c" (self: ^Function) -> FunctionOptions { return msgSend(FunctionOptions, self, "options") } @(objc_type=Function, objc_name="patchControlPointCount") -Function_patchControlPointCount :: #force_inline proc(self: ^Function) -> NS.UInteger { +Function_patchControlPointCount :: #force_inline proc "c" (self: ^Function) -> NS.UInteger { return msgSend(NS.UInteger, self, "patchControlPointCount") } @(objc_type=Function, objc_name="patchType") -Function_patchType :: #force_inline proc(self: ^Function) -> PatchType { +Function_patchType :: #force_inline proc "c" (self: ^Function) -> PatchType { return msgSend(PatchType, self, "patchType") } @(objc_type=Function, objc_name="setLabel") -Function_setLabel :: #force_inline proc(self: ^Function, label: ^NS.String) { +Function_setLabel :: #force_inline proc "c" (self: ^Function, label: ^NS.String) { msgSend(nil, self, "setLabel:", label) } @(objc_type=Function, objc_name="stageInputAttributes") -Function_stageInputAttributes :: #force_inline proc(self: ^Function) -> ^NS.Array { +Function_stageInputAttributes :: #force_inline proc "c" (self: ^Function) -> ^NS.Array { return msgSend(^NS.Array, self, "stageInputAttributes") } @(objc_type=Function, objc_name="vertexAttributes") -Function_vertexAttributes :: #force_inline proc(self: ^Function) -> ^NS.Array { +Function_vertexAttributes :: #force_inline proc "c" (self: ^Function) -> ^NS.Array { return msgSend(^NS.Array, self, "vertexAttributes") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - FunctionHandle -Class Methods: -Methods: - device - functionType - name -*/ @(objc_class="MTLFunctionHandle") FunctionHandle :: struct { using _: NS.Object } @(objc_type=FunctionHandle, objc_name="device") -FunctionHandle_device :: #force_inline proc(self: ^FunctionHandle) -> ^Device { +FunctionHandle_device :: #force_inline proc "c" (self: ^FunctionHandle) -> ^Device { return msgSend(^Device, self, "device") } @(objc_type=FunctionHandle, objc_name="functionType") -FunctionHandle_functionType :: #force_inline proc(self: ^FunctionHandle) -> FunctionType { +FunctionHandle_functionType :: #force_inline proc "c" (self: ^FunctionHandle) -> FunctionType { return msgSend(FunctionType, self, "functionType") } @(objc_type=FunctionHandle, objc_name="name") -FunctionHandle_name :: #force_inline proc(self: ^FunctionHandle) -> ^NS.String { +FunctionHandle_name :: #force_inline proc "c" (self: ^FunctionHandle) -> ^NS.String { return msgSend(^NS.String, self, "name") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - LogContainer -*/ @(objc_class="MTLLogContainer") LogContainer :: struct { using _: NS.FastEnumeration } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - FunctionLog -Class Methods: -Methods: - debugLocation - encoderLabel - function - type -*/ + @(objc_class="MTLFunctionLog") FunctionLog :: struct { using _: NS.Object } @(objc_type=FunctionLog, objc_name="debugLocation") -FunctionLog_debugLocation :: #force_inline proc(self: ^FunctionLog) -> ^FunctionLog { +FunctionLog_debugLocation :: #force_inline proc "c" (self: ^FunctionLog) -> ^FunctionLog { return msgSend(^FunctionLog, self, "debugLocation") } @(objc_type=FunctionLog, objc_name="encoderLabel") -FunctionLog_encoderLabel :: #force_inline proc(self: ^FunctionLog) -> ^NS.String { +FunctionLog_encoderLabel :: #force_inline proc "c" (self: ^FunctionLog) -> ^NS.String { return msgSend(^NS.String, self, "encoderLabel") } @(objc_type=FunctionLog, objc_name="function") -FunctionLog_function :: #force_inline proc(self: ^FunctionLog) -> ^FunctionLog { +FunctionLog_function :: #force_inline proc "c" (self: ^FunctionLog) -> ^FunctionLog { return msgSend(^FunctionLog, self, "function") } @(objc_type=FunctionLog, objc_name="type") -FunctionLog_type :: #force_inline proc(self: ^FunctionLog) -> FunctionLogType { +FunctionLog_type :: #force_inline proc "c" (self: ^FunctionLog) -> FunctionLogType { return msgSend(FunctionLogType, self, "type") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - FunctionLogDebugLocation -Class Methods: -Methods: - URL - column - functionName - line -*/ @(objc_class="MTLFunctionLogDebugLocation") FunctionLogDebugLocation :: struct { using _: NS.Object } @(objc_type=FunctionLogDebugLocation, objc_name="URL") -FunctionLogDebugLocation_URL :: #force_inline proc(self: ^FunctionLogDebugLocation) -> ^NS.URL { +FunctionLogDebugLocation_URL :: #force_inline proc "c" (self: ^FunctionLogDebugLocation) -> ^NS.URL { return msgSend(^NS.URL, self, "URL") } @(objc_type=FunctionLogDebugLocation, objc_name="column") -FunctionLogDebugLocation_column :: #force_inline proc(self: ^FunctionLogDebugLocation) -> NS.UInteger { +FunctionLogDebugLocation_column :: #force_inline proc "c" (self: ^FunctionLogDebugLocation) -> NS.UInteger { return msgSend(NS.UInteger, self, "column") } @(objc_type=FunctionLogDebugLocation, objc_name="functionName") -FunctionLogDebugLocation_functionName :: #force_inline proc(self: ^FunctionLogDebugLocation) -> ^NS.String { +FunctionLogDebugLocation_functionName :: #force_inline proc "c" (self: ^FunctionLogDebugLocation) -> ^NS.String { return msgSend(^NS.String, self, "functionName") } @(objc_type=FunctionLogDebugLocation, objc_name="line") -FunctionLogDebugLocation_line :: #force_inline proc(self: ^FunctionLogDebugLocation) -> NS.UInteger { +FunctionLogDebugLocation_line :: #force_inline proc "c" (self: ^FunctionLogDebugLocation) -> NS.UInteger { return msgSend(NS.UInteger, self, "line") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - Heap -Class Methods: -Methods: - cpuCacheMode - currentAllocatedSize - device - hazardTrackingMode - label - maxAvailableSizeWithAlignment - newBufferWithLength - newBufferWithLength - newTextureWithDescriptor - newTextureWithDescriptor - resourceOptions - setLabel - setPurgeableState - size - storageMode - type - usedSize -*/ + @(objc_class="MTLHeap") Heap :: struct { using _: NS.Object } @(objc_type=Heap, objc_name="cpuCacheMode") -Heap_cpuCacheMode :: #force_inline proc(self: ^Heap) -> CPUCacheMode { +Heap_cpuCacheMode :: #force_inline proc "c" (self: ^Heap) -> CPUCacheMode { return msgSend(CPUCacheMode, self, "cpuCacheMode") } @(objc_type=Heap, objc_name="currentAllocatedSize") -Heap_currentAllocatedSize :: #force_inline proc(self: ^Heap) -> NS.UInteger { +Heap_currentAllocatedSize :: #force_inline proc "c" (self: ^Heap) -> NS.UInteger { return msgSend(NS.UInteger, self, "currentAllocatedSize") } @(objc_type=Heap, objc_name="device") -Heap_device :: #force_inline proc(self: ^Heap) -> ^Device { +Heap_device :: #force_inline proc "c" (self: ^Heap) -> ^Device { return msgSend(^Device, self, "device") } @(objc_type=Heap, objc_name="hazardTrackingMode") -Heap_hazardTrackingMode :: #force_inline proc(self: ^Heap) -> HazardTrackingMode { +Heap_hazardTrackingMode :: #force_inline proc "c" (self: ^Heap) -> HazardTrackingMode { return msgSend(HazardTrackingMode, self, "hazardTrackingMode") } @(objc_type=Heap, objc_name="label") -Heap_label :: #force_inline proc(self: ^Heap) -> ^NS.String { +Heap_label :: #force_inline proc "c" (self: ^Heap) -> ^NS.String { return msgSend(^NS.String, self, "label") } @(objc_type=Heap, objc_name="maxAvailableSizeWithAlignment") -Heap_maxAvailableSizeWithAlignment :: #force_inline proc(self: ^Heap, alignment: NS.UInteger) -> NS.UInteger { +Heap_maxAvailableSizeWithAlignment :: #force_inline proc "c" (self: ^Heap, alignment: NS.UInteger) -> NS.UInteger { return msgSend(NS.UInteger, self, "maxAvailableSizeWithAlignment:", alignment) } @(objc_type=Heap, objc_name="newBufferWithLength") -Heap_newBufferWithLength :: #force_inline proc(self: ^Heap, length: NS.UInteger, options: ResourceOptions) -> ^Buffer { +Heap_newBufferWithLength :: #force_inline proc "c" (self: ^Heap, length: NS.UInteger, options: ResourceOptions) -> ^Buffer { return msgSend(^Buffer, self, "newBufferWithLength:options:", length, options) } @(objc_type=Heap, objc_name="newBufferWithOptions") -Heap_newBufferWithOptions :: #force_inline proc(self: ^Heap, length: NS.UInteger, options: ResourceOptions, offset: NS.UInteger) -> ^Buffer { +Heap_newBufferWithOptions :: #force_inline proc "c" (self: ^Heap, length: NS.UInteger, options: ResourceOptions, offset: NS.UInteger) -> ^Buffer { return msgSend(^Buffer, self, "newBufferWithLength:options:offset:", length, options, offset) } @(objc_type=Heap, objc_name="newBuffer") @@ -7182,11 +5993,11 @@ Heap_newBuffer :: proc{ } @(objc_type=Heap, objc_name="newTextureWithDescriptor") -Heap_newTextureWithDescriptor :: #force_inline proc(self: ^Heap, desc: ^TextureDescriptor) -> ^Texture { +Heap_newTextureWithDescriptor :: #force_inline proc "c" (self: ^Heap, desc: ^TextureDescriptor) -> ^Texture { return msgSend(^Texture, self, "newTextureWithDescriptor:", desc) } @(objc_type=Heap, objc_name="newTextureWithDescriptorAndOffset") -Heap_newTextureWithDescriptorAndOffset :: #force_inline proc(self: ^Heap, descriptor: ^TextureDescriptor, offset: NS.UInteger) -> ^Texture { +Heap_newTextureWithDescriptorAndOffset :: #force_inline proc "c" (self: ^Heap, descriptor: ^TextureDescriptor, offset: NS.UInteger) -> ^Texture { return msgSend(^Texture, self, "newTextureWithDescriptor:offset:", descriptor, offset) } @(objc_type=Heap, objc_name="newTexture") @@ -7195,292 +6006,423 @@ Heap_newTexture :: proc{ Heap_newTextureWithDescriptorAndOffset, } +@(objc_type=Heap, objc_name="newAccelerationStructureWithSize") +Heap_newAccelerationStructureWithSize :: #force_inline proc "c" (self: ^Heap, size: NS.UInteger) -> ^AccelerationStructure { + return msgSend(^AccelerationStructure, self, "newAccelerationStructureWithSize:", size) +} +@(objc_type=Heap, objc_name="newAccelerationStructureWithDescriptor") +Heap_newAccelerationStructureWithDescriptor :: #force_inline proc "c" (self: ^Heap, descriptor: ^AccelerationStructureDescriptor) -> ^AccelerationStructure { + return msgSend(^AccelerationStructure, self, "newAccelerationStructureWithDescriptor:", descriptor) +} +@(objc_type=Heap, objc_name="newAccelerationStructureWithSizeAndOffset") +Heap_newAccelerationStructureWithSizeAndOffset :: #force_inline proc "c" (self: ^Heap, size, offset: NS.UInteger) -> ^AccelerationStructure { + return msgSend(^AccelerationStructure, self, "newAccelerationStructureWithSize:offset:", size, offset) +} +@(objc_type=Heap, objc_name="newAccelerationStructureWithDescriptorAndOffset") +Heap_newAccelerationStructureWithDescriptorAndOffset :: #force_inline proc "c" (self: ^Heap, descriptor: ^AccelerationStructureDescriptor, offset: NS.UInteger) -> ^AccelerationStructure { + return msgSend(^AccelerationStructure, self, "newAccelerationStructureWithDescriptor:offset:", descriptor, offset) +} +@(objc_type=Heap, objc_name="newAccelerationStructure") +Heap_newAccelerationStructure :: proc{ + Heap_newAccelerationStructureWithSize, + Heap_newAccelerationStructureWithDescriptor, + Heap_newAccelerationStructureWithSizeAndOffset, + Heap_newAccelerationStructureWithDescriptorAndOffset, +} + @(objc_type=Heap, objc_name="resourceOptions") -Heap_resourceOptions :: #force_inline proc(self: ^Heap) -> ResourceOptions { +Heap_resourceOptions :: #force_inline proc "c" (self: ^Heap) -> ResourceOptions { return msgSend(ResourceOptions, self, "resourceOptions") } @(objc_type=Heap, objc_name="setLabel") -Heap_setLabel :: #force_inline proc(self: ^Heap, label: ^NS.String) { +Heap_setLabel :: #force_inline proc "c" (self: ^Heap, label: ^NS.String) { msgSend(nil, self, "setLabel:", label) } @(objc_type=Heap, objc_name="setPurgeableState") -Heap_setPurgeableState :: #force_inline proc(self: ^Heap, state: PurgeableState) -> PurgeableState { +Heap_setPurgeableState :: #force_inline proc "c" (self: ^Heap, state: PurgeableState) -> PurgeableState { return msgSend(PurgeableState, self, "setPurgeableState:", state) } @(objc_type=Heap, objc_name="size") -Heap_size :: #force_inline proc(self: ^Heap) -> NS.UInteger { +Heap_size :: #force_inline proc "c" (self: ^Heap) -> NS.UInteger { return msgSend(NS.UInteger, self, "size") } @(objc_type=Heap, objc_name="storageMode") -Heap_storageMode :: #force_inline proc(self: ^Heap) -> StorageMode { +Heap_storageMode :: #force_inline proc "c" (self: ^Heap) -> StorageMode { return msgSend(StorageMode, self, "storageMode") } @(objc_type=Heap, objc_name="type") -Heap_type :: #force_inline proc(self: ^Heap) -> FunctionLogType { +Heap_type :: #force_inline proc "c" (self: ^Heap) -> FunctionLogType { return msgSend(FunctionLogType, self, "type") } @(objc_type=Heap, objc_name="usedSize") -Heap_usedSize :: #force_inline proc(self: ^Heap) -> NS.UInteger { +Heap_usedSize :: #force_inline proc "c" (self: ^Heap) -> NS.UInteger { return msgSend(NS.UInteger, self, "usedSize") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - IndirectCommandBuffer -Class Methods: -Methods: - indirectComputeCommandAtIndex - indirectRenderCommandAtIndex - resetWithRange - size -*/ @(objc_class="MTLIndirectCommandBuffer") IndirectCommandBuffer :: struct { using _: Resource } @(objc_type=IndirectCommandBuffer, objc_name="indirectComputeCommand") -IndirectCommandBuffer_indirectComputeCommand :: #force_inline proc(self: ^IndirectCommandBuffer, commandIndex: NS.UInteger) -> ^IndirectComputeCommand { +IndirectCommandBuffer_indirectComputeCommand :: #force_inline proc "c" (self: ^IndirectCommandBuffer, commandIndex: NS.UInteger) -> ^IndirectComputeCommand { return msgSend(^IndirectComputeCommand, self, "indirectComputeCommandAtIndex:", commandIndex) } @(objc_type=IndirectCommandBuffer, objc_name="indirectRenderCommand") -IndirectCommandBuffer_indirectRenderCommand :: #force_inline proc(self: ^IndirectCommandBuffer, commandIndex: NS.UInteger) -> ^IndirectRenderCommand { +IndirectCommandBuffer_indirectRenderCommand :: #force_inline proc "c" (self: ^IndirectCommandBuffer, commandIndex: NS.UInteger) -> ^IndirectRenderCommand { return msgSend(^IndirectRenderCommand, self, "indirectRenderCommandAtIndex:", commandIndex) } @(objc_type=IndirectCommandBuffer, objc_name="resetWithRange") -IndirectCommandBuffer_resetWithRange :: #force_inline proc(self: ^IndirectCommandBuffer, range: NS.Range) { +IndirectCommandBuffer_resetWithRange :: #force_inline proc "c" (self: ^IndirectCommandBuffer, range: NS.Range) { msgSend(nil, self, "resetWithRange:", range) } @(objc_type=IndirectCommandBuffer, objc_name="size") -IndirectCommandBuffer_size :: #force_inline proc(self: ^IndirectCommandBuffer) -> NS.UInteger { +IndirectCommandBuffer_size :: #force_inline proc "c" (self: ^IndirectCommandBuffer) -> NS.UInteger { return msgSend(NS.UInteger, self, "size") } +@(objc_type=IndirectCommandBuffer, objc_name="supportRayTracing") +IndirectCommandBuffer_supportRayTracing :: #force_inline proc "c" (self: ^IndirectCommandBuffer) -> BOOL { + return msgSend(BOOL, self, "supportRayTracing") +} +@(objc_type=IndirectCommandBuffer, objc_name="setSupportRayTracing") +IndirectCommandBuffer_setSupportRayTracing :: #force_inline proc "c" (self: ^IndirectCommandBuffer, supportRayTracing: BOOL) { + msgSend(nil, self, "setSupportRayTracing:", supportRayTracing) +} + +@(objc_type=IndirectCommandBuffer, objc_name="gpuResourceID") +IndirectCommandBuffer_gpuResourceID :: #force_inline proc "c" (self: ^IndirectCommandBuffer) -> ResourceID { + return msgSend(ResourceID, self, "gpuResourceID") +} + + //////////////////////////////////////////////////////////////////////////////// -/* -Class: - IndirectComputeCommand -Class Methods: -Methods: - clearBarrier - concurrentDispatchThreadgroups - concurrentDispatchThreads - reset - setBarrier - setComputePipelineState - setImageblockWidth - setKernelBuffer - setStageInRegion - setThreadgroupMemoryLength -*/ @(objc_class="MTLIndirectComputeCommand") IndirectComputeCommand :: struct { using _: NS.Object } @(objc_type=IndirectComputeCommand, objc_name="clearBarrier") -IndirectComputeCommand_clearBarrier :: #force_inline proc(self: ^IndirectComputeCommand) { +IndirectComputeCommand_clearBarrier :: #force_inline proc "c" (self: ^IndirectComputeCommand) { msgSend(nil, self, "clearBarrier") } @(objc_type=IndirectComputeCommand, objc_name="concurrentDispatchThreadgroups") -IndirectComputeCommand_concurrentDispatchThreadgroups :: #force_inline proc(self: ^IndirectComputeCommand, threadgroupsPerGrid: Size, threadsPerThreadgroup: Size) { +IndirectComputeCommand_concurrentDispatchThreadgroups :: #force_inline proc "c" (self: ^IndirectComputeCommand, threadgroupsPerGrid: Size, threadsPerThreadgroup: Size) { msgSend(nil, self, "concurrentDispatchThreadgroups:threadsPerThreadgroup:", threadgroupsPerGrid, threadsPerThreadgroup) } @(objc_type=IndirectComputeCommand, objc_name="concurrentDispatchThreads") -IndirectComputeCommand_concurrentDispatchThreads :: #force_inline proc(self: ^IndirectComputeCommand, threadsPerGrid: Size, threadsPerThreadgroup: Size) { +IndirectComputeCommand_concurrentDispatchThreads :: #force_inline proc "c" (self: ^IndirectComputeCommand, threadsPerGrid: Size, threadsPerThreadgroup: Size) { msgSend(nil, self, "concurrentDispatchThreads:threadsPerThreadgroup:", threadsPerGrid, threadsPerThreadgroup) } @(objc_type=IndirectComputeCommand, objc_name="reset") -IndirectComputeCommand_reset :: #force_inline proc(self: ^IndirectComputeCommand) { +IndirectComputeCommand_reset :: #force_inline proc "c" (self: ^IndirectComputeCommand) { msgSend(nil, self, "reset") } @(objc_type=IndirectComputeCommand, objc_name="setBarrier") -IndirectComputeCommand_setBarrier :: #force_inline proc(self: ^IndirectComputeCommand) { +IndirectComputeCommand_setBarrier :: #force_inline proc "c" (self: ^IndirectComputeCommand) { msgSend(nil, self, "setBarrier") } @(objc_type=IndirectComputeCommand, objc_name="setComputePipelineState") -IndirectComputeCommand_setComputePipelineState :: #force_inline proc(self: ^IndirectComputeCommand, pipelineState: ^ComputePipelineState) { +IndirectComputeCommand_setComputePipelineState :: #force_inline proc "c" (self: ^IndirectComputeCommand, pipelineState: ^ComputePipelineState) { msgSend(nil, self, "setComputePipelineState:", pipelineState) } @(objc_type=IndirectComputeCommand, objc_name="setImageblockWidth") -IndirectComputeCommand_setImageblockWidth :: #force_inline proc(self: ^IndirectComputeCommand, width: NS.UInteger, height: NS.UInteger) { +IndirectComputeCommand_setImageblockWidth :: #force_inline proc "c" (self: ^IndirectComputeCommand, width: NS.UInteger, height: NS.UInteger) { msgSend(nil, self, "setImageblockWidth:height:", width, height) } @(objc_type=IndirectComputeCommand, objc_name="setKernelBuffer") -IndirectComputeCommand_setKernelBuffer :: #force_inline proc(self: ^IndirectComputeCommand, buffer: ^Buffer, offset: NS.UInteger, index: NS.UInteger) { +IndirectComputeCommand_setKernelBuffer :: #force_inline proc "c" (self: ^IndirectComputeCommand, buffer: ^Buffer, offset: NS.UInteger, index: NS.UInteger) { msgSend(nil, self, "setKernelBuffer:offset:atIndex:", buffer, offset, index) } @(objc_type=IndirectComputeCommand, objc_name="setStageInRegion") -IndirectComputeCommand_setStageInRegion :: #force_inline proc(self: ^IndirectComputeCommand, region: Region) { +IndirectComputeCommand_setStageInRegion :: #force_inline proc "c" (self: ^IndirectComputeCommand, region: Region) { msgSend(nil, self, "setStageInRegion:", region) } @(objc_type=IndirectComputeCommand, objc_name="setThreadgroupMemoryLength") -IndirectComputeCommand_setThreadgroupMemoryLength :: #force_inline proc(self: ^IndirectComputeCommand, length: NS.UInteger, index: NS.UInteger) { +IndirectComputeCommand_setThreadgroupMemoryLength :: #force_inline proc "c" (self: ^IndirectComputeCommand, length: NS.UInteger, index: NS.UInteger) { msgSend(nil, self, "setThreadgroupMemoryLength:atIndex:", length, index) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - IndirectRenderCommand -Class Methods: -Methods: - drawIndexedPatches - drawIndexedPrimitives - drawPatches - drawPrimitives - reset - setFragmentBuffer - setRenderPipelineState - setVertexBuffer -*/ @(objc_class="MTLIndirectRenderCommand") IndirectRenderCommand :: struct { using _: NS.Object } @(objc_type=IndirectRenderCommand, objc_name="drawIndexedPatches") -IndirectRenderCommand_drawIndexedPatches :: #force_inline proc(self: ^IndirectRenderCommand, numberOfPatchControlPoints: NS.UInteger, patchStart, patchCount: NS.UInteger, patchIndexBuffer: ^Buffer, patchIndexBufferOffset: NS.UInteger, controlPointIndexBuffer: ^Buffer, controlPointIndexBufferOffset: NS.UInteger, instanceCount: NS.UInteger, baseInstance: NS.UInteger, buffer: ^Buffer, offset: NS.UInteger, instanceStride: NS.UInteger) { +IndirectRenderCommand_drawIndexedPatches :: #force_inline proc "c" (self: ^IndirectRenderCommand, numberOfPatchControlPoints: NS.UInteger, patchStart, patchCount: NS.UInteger, patchIndexBuffer: ^Buffer, patchIndexBufferOffset: NS.UInteger, controlPointIndexBuffer: ^Buffer, controlPointIndexBufferOffset: NS.UInteger, instanceCount: NS.UInteger, baseInstance: NS.UInteger, buffer: ^Buffer, offset: NS.UInteger, instanceStride: NS.UInteger) { msgSend(nil, self, "drawIndexedPatches:patchStart:patchCount:patchIndexBuffer:patchIndexBufferOffset:controlPointIndexBuffer:controlPointIndexBufferOffset:instanceCount:baseInstance:tessellationFactorBuffer:tessellationFactorBufferOffset:tessellationFactorBufferInstanceStride:", numberOfPatchControlPoints, patchStart, patchCount, patchIndexBuffer, patchIndexBufferOffset, controlPointIndexBuffer, controlPointIndexBufferOffset, instanceCount, baseInstance, buffer, offset, instanceStride) } @(objc_type=IndirectRenderCommand, objc_name="drawIndexedPrimitives") -IndirectRenderCommand_drawIndexedPrimitives :: #force_inline proc(self: ^IndirectRenderCommand, primitiveType: PrimitiveType, indexCount: NS.UInteger, indexType: IndexType, indexBuffer: ^Buffer, indexBufferOffset: NS.UInteger, instanceCount: NS.UInteger, baseVertex: NS.Integer, baseInstance: NS.UInteger) { +IndirectRenderCommand_drawIndexedPrimitives :: #force_inline proc "c" (self: ^IndirectRenderCommand, primitiveType: PrimitiveType, indexCount: NS.UInteger, indexType: IndexType, indexBuffer: ^Buffer, indexBufferOffset: NS.UInteger, instanceCount: NS.UInteger, baseVertex: NS.Integer, baseInstance: NS.UInteger) { msgSend(nil, self, "drawIndexedPrimitives:indexCount:indexType:indexBuffer:indexBufferOffset:instanceCount:baseVertex:baseInstance:", primitiveType, indexCount, indexType, indexBuffer, indexBufferOffset, instanceCount, baseVertex, baseInstance) } @(objc_type=IndirectRenderCommand, objc_name="drawPatches") -IndirectRenderCommand_drawPatches :: #force_inline proc(self: ^IndirectRenderCommand, numberOfPatchControlPoints: NS.UInteger, patchStart, patchCount: NS.UInteger, patchIndexBuffer: ^Buffer, patchIndexBufferOffset: NS.UInteger, instanceCount: NS.UInteger, baseInstance: NS.UInteger, buffer: ^Buffer, offset: NS.UInteger, instanceStride: NS.UInteger) { +IndirectRenderCommand_drawPatches :: #force_inline proc "c" (self: ^IndirectRenderCommand, numberOfPatchControlPoints: NS.UInteger, patchStart, patchCount: NS.UInteger, patchIndexBuffer: ^Buffer, patchIndexBufferOffset: NS.UInteger, instanceCount: NS.UInteger, baseInstance: NS.UInteger, buffer: ^Buffer, offset: NS.UInteger, instanceStride: NS.UInteger) { msgSend(nil, self, "drawPatches:patchStart:patchCount:patchIndexBuffer:patchIndexBufferOffset:instanceCount:baseInstance:tessellationFactorBuffer:tessellationFactorBufferOffset:tessellationFactorBufferInstanceStride:", numberOfPatchControlPoints, patchStart, patchCount, patchIndexBuffer, patchIndexBufferOffset, instanceCount, baseInstance, buffer, offset, instanceStride) } @(objc_type=IndirectRenderCommand, objc_name="drawPrimitives") -IndirectRenderCommand_drawPrimitives :: #force_inline proc(self: ^IndirectRenderCommand, primitiveType: PrimitiveType, vertexStart: NS.UInteger, vertexCount: NS.UInteger, instanceCount: NS.UInteger, baseInstance: NS.UInteger = 0) { +IndirectRenderCommand_drawPrimitives :: #force_inline proc "c" (self: ^IndirectRenderCommand, primitiveType: PrimitiveType, vertexStart: NS.UInteger, vertexCount: NS.UInteger, instanceCount: NS.UInteger, baseInstance: NS.UInteger = 0) { msgSend(nil, self, "drawPrimitives:vertexStart:vertexCount:instanceCount:baseInstance:", primitiveType, vertexStart, vertexCount, instanceCount, baseInstance) } @(objc_type=IndirectRenderCommand, objc_name="reset") -IndirectRenderCommand_reset :: #force_inline proc(self: ^IndirectRenderCommand) { +IndirectRenderCommand_reset :: #force_inline proc "c" (self: ^IndirectRenderCommand) { msgSend(nil, self, "reset") } @(objc_type=IndirectRenderCommand, objc_name="setFragmentBuffer") -IndirectRenderCommand_setFragmentBuffer :: #force_inline proc(self: ^IndirectRenderCommand, buffer: ^Buffer, offset: NS.UInteger, index: NS.UInteger) { +IndirectRenderCommand_setFragmentBuffer :: #force_inline proc "c" (self: ^IndirectRenderCommand, buffer: ^Buffer, offset: NS.UInteger, index: NS.UInteger) { msgSend(nil, self, "setFragmentBuffer:offset:atIndex:", buffer, offset, index) } @(objc_type=IndirectRenderCommand, objc_name="setRenderPipelineState") -IndirectRenderCommand_setRenderPipelineState :: #force_inline proc(self: ^IndirectRenderCommand, pipelineState: ^RenderPipelineState) { +IndirectRenderCommand_setRenderPipelineState :: #force_inline proc "c" (self: ^IndirectRenderCommand, pipelineState: ^RenderPipelineState) { msgSend(nil, self, "setRenderPipelineState:", pipelineState) } @(objc_type=IndirectRenderCommand, objc_name="setVertexBuffer") -IndirectRenderCommand_setVertexBuffer :: #force_inline proc(self: ^IndirectRenderCommand, buffer: ^Buffer, offset: NS.UInteger, index: NS.UInteger) { +IndirectRenderCommand_setVertexBuffer :: #force_inline proc "c" (self: ^IndirectRenderCommand, buffer: ^Buffer, offset: NS.UInteger, index: NS.UInteger) { msgSend(nil, self, "setVertexBuffer:offset:atIndex:", buffer, offset, index) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - IntersectionFunctionTable -Class Methods: -Methods: - setBuffer - setBuffers - setFunction - setFunctions - setOpaqueTriangleIntersectionFunctionWithSignature - setOpaqueTriangleIntersectionFunctionWithSignature - setVisibleFunctionTable - setVisibleFunctionTables -*/ @(objc_class="MTLIntersectionFunctionTable") IntersectionFunctionTable :: struct { using _: Resource } @(objc_type=IntersectionFunctionTable, objc_name="setBuffer") -IntersectionFunctionTable_setBuffer :: #force_inline proc(self: ^IntersectionFunctionTable, buffer: ^Buffer, offset: NS.UInteger, index: NS.UInteger) { +IntersectionFunctionTable_setBuffer :: #force_inline proc "c" (self: ^IntersectionFunctionTable, buffer: ^Buffer, offset: NS.UInteger, index: NS.UInteger) { msgSend(nil, self, "setBuffer:offset:atIndex:", buffer, offset, index) } @(objc_type=IntersectionFunctionTable, objc_name="setBuffers") -IntersectionFunctionTable_setBuffers :: #force_inline proc(self: ^IntersectionFunctionTable, buffers: []^Buffer, offsets: []NS.UInteger, range: NS.Range) { +IntersectionFunctionTable_setBuffers :: #force_inline proc "c" (self: ^IntersectionFunctionTable, buffers: []^Buffer, offsets: []NS.UInteger, range: NS.Range) { msgSend(nil, self, "setBuffers:offsets:withRange:", raw_data(buffers), raw_data(offsets), range) } @(objc_type=IntersectionFunctionTable, objc_name="setFunction") -IntersectionFunctionTable_setFunction :: #force_inline proc(self: ^IntersectionFunctionTable, function: ^FunctionHandle, index: NS.UInteger) { +IntersectionFunctionTable_setFunction :: #force_inline proc "c" (self: ^IntersectionFunctionTable, function: ^FunctionHandle, index: NS.UInteger) { msgSend(nil, self, "setFunction:atIndex:", function, index) } @(objc_type=IntersectionFunctionTable, objc_name="setFunctions") -IntersectionFunctionTable_setFunctions :: #force_inline proc(self: ^IntersectionFunctionTable, functions: []^FunctionHandle, range: NS.Range) { +IntersectionFunctionTable_setFunctions :: #force_inline proc "c" (self: ^IntersectionFunctionTable, functions: []^FunctionHandle, range: NS.Range) { msgSend(nil, self, "setFunctions:withRange:", raw_data(functions), range) } @(objc_type=IntersectionFunctionTable, objc_name="setOpaqueTriangleIntersectionFunctionWithSignature") -IntersectionFunctionTable_setOpaqueTriangleIntersectionFunctionWithSignature :: #force_inline proc(self: ^IntersectionFunctionTable, signature: IntersectionFunctionSignature, index: NS.UInteger) { +IntersectionFunctionTable_setOpaqueTriangleIntersectionFunctionWithSignature :: #force_inline proc "c" (self: ^IntersectionFunctionTable, signature: IntersectionFunctionSignature, index: NS.UInteger) { msgSend(nil, self, "setOpaqueTriangleIntersectionFunctionWithSignature:atIndex:", signature, index) } @(objc_type=IntersectionFunctionTable, objc_name="setOpaqueTriangleIntersectionFunctionWithSignatureWithRange") -IntersectionFunctionTable_setOpaqueTriangleIntersectionFunctionWithSignatureWithRange :: #force_inline proc(self: ^IntersectionFunctionTable, signature: IntersectionFunctionSignature, range: NS.Range) { +IntersectionFunctionTable_setOpaqueTriangleIntersectionFunctionWithSignatureWithRange :: #force_inline proc "c" (self: ^IntersectionFunctionTable, signature: IntersectionFunctionSignature, range: NS.Range) { msgSend(nil, self, "setOpaqueTriangleIntersectionFunctionWithSignature:withRange:", signature, range) } @(objc_type=IntersectionFunctionTable, objc_name="setVisibleFunctionTable") -IntersectionFunctionTable_setVisibleFunctionTable :: #force_inline proc(self: ^IntersectionFunctionTable, visibleFunctionTable: ^VisibleFunctionTable, bufferIndex: NS.UInteger) { +IntersectionFunctionTable_setVisibleFunctionTable :: #force_inline proc "c" (self: ^IntersectionFunctionTable, visibleFunctionTable: ^VisibleFunctionTable, bufferIndex: NS.UInteger) { msgSend(nil, self, "setVisibleFunctionTable:atBufferIndex:", visibleFunctionTable, bufferIndex) } @(objc_type=IntersectionFunctionTable, objc_name="setVisibleFunctionTables") -IntersectionFunctionTable_setVisibleFunctionTables :: #force_inline proc(self: ^IntersectionFunctionTable, visibleFunctionTables: []^VisibleFunctionTable, range: NS.Range) { +IntersectionFunctionTable_setVisibleFunctionTables :: #force_inline proc "c" (self: ^IntersectionFunctionTable, visibleFunctionTables: []^VisibleFunctionTable, range: NS.Range) { msgSend(nil, self, "setVisibleFunctionTables:withBufferRange:", raw_data(visibleFunctionTables), range) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - Library -Class Methods: -Methods: - device - functionNames - installName - label - newFunctionWithDescriptor - newFunctionWithDescriptor - newFunctionWithName - newFunctionWithName - newFunctionWithName - newIntersectionFunctionWithDescriptor - newIntersectionFunctionWithDescriptor - setLabel - type -*/ +@(objc_class="MTLIOCommandQueue") +IOCommandQueue :: struct { using _: NS.Object } + +@(objc_type=IOCommandQueue, objc_name="enqueueBarrier") +IOCommandQueue_enqueueBarrier :: #force_inline proc "c" (self: ^IOCommandQueue) { + msgSend(nil, self, "enqueueBarrier") +} +@(objc_type=IOCommandQueue, objc_name="commandBuffer") +IOCommandQueue_commandBuffer :: #force_inline proc "c" (self: ^IOCommandQueue) -> ^IOCommandBuffer { + return msgSend(^IOCommandBuffer, self, "commandBuffer") +} +@(objc_type=IOCommandQueue, objc_name="commandBufferWithUnretainedReferences") +IOCommandQueue_commandBufferWithUnretainedReferences :: #force_inline proc "c" (self: ^IOCommandQueue) -> ^IOCommandBuffer { + return msgSend(^IOCommandBuffer, self, "commandBufferWithUnretainedReferences") +} +@(objc_type=IOCommandQueue, objc_name="label") +IOCommandQueue_label :: #force_inline proc "c" (self: ^IOCommandQueue) -> ^NS.String { + return msgSend(^NS.String, self, "label") +} +@(objc_type=IOCommandQueue, objc_name="setLabel") +IOCommandQueue_setLabel :: #force_inline proc "c" (self: ^IOCommandQueue, label: ^NS.String) { + msgSend(nil, self, "setLabel:", label) +} + +//////////////////////////////////////////////////////////////////////////////// + +@(objc_class="MTLIOScratchBuffer") +IOScratchBuffer :: struct { using _: NS.Object } + +@(objc_type=IOScratchBuffer, objc_name="buffer") +IOScratchBuffer_buffer :: #force_inline proc "c" (self: ^IOCommandQueue) -> ^Buffer { + return msgSend(^Buffer, self, "buffer") +} + +//////////////////////////////////////////////////////////////////////////////// + +@(objc_class="MTLIOScratchBufferAllocator") +IOScratchBufferAllocator :: struct { using _: NS.Object } + +@(objc_type=IOScratchBufferAllocator, objc_name="newScratchBuffer") +IOScratchBufferAllocator_newScratchBuffer :: #force_inline proc "c" (self: ^IOCommandQueue, minimumSize: NS.UInteger) -> ^IOScratchBuffer { + return msgSend(^IOScratchBuffer, self, "newScratchBufferWithMinimumSize:", minimumSize) +} + +//////////////////////////////////////////////////////////////////////////////// + +@(objc_class="MTLIOCommandQueueDescriptor") +IOCommandQueueDescriptor :: struct { using _: NS.Copying(IOCommandQueueDescriptor) } + + +@(objc_type=IOCommandQueueDescriptor, objc_name="alloc", objc_is_class_method=true) +IOCommandQueueDescriptor_alloc :: #force_inline proc "c" () -> ^IOCommandQueueDescriptor { + return msgSend(^IOCommandQueueDescriptor, IOCommandQueueDescriptor, "alloc") +} +@(objc_type=IOCommandQueueDescriptor, objc_name="init") +IOCommandQueueDescriptor_init :: #force_inline proc "c" (self: ^IOCommandQueueDescriptor) -> ^IOCommandQueueDescriptor { + return msgSend(^IOCommandQueueDescriptor, self, "init") +} + +@(objc_type=IOCommandQueueDescriptor, objc_name="maxCommandBufferCount") +IOCommandQueueDescriptor_maxCommandBufferCount :: #force_inline proc "c" (self: ^IOCommandQueueDescriptor) -> NS.UInteger { + return msgSend(NS.UInteger, self, "maxCommandBufferCount") +} + +//////////////////////////////////////////////////////////////////////////////// + +@(objc_class="MTLIOFileHandle") +IOFileHandle :: struct { using _: NS.Object } + +@(objc_type=IOFileHandle, objc_name="label") +IOFileHandle_label :: #force_inline proc "c" (self: ^IOFileHandle) -> ^NS.String { + return msgSend(^NS.String, self, "label") +} +@(objc_type=IOFileHandle, objc_name="setLabel") +IOFileHandle_setLabel :: #force_inline proc "c" (self: ^IOFileHandle, label: ^NS.String) { + msgSend(nil, self, "setLabel:", label) +} + +//////////////////////////////////////////////////////////////////////////////// + +@(objc_class="MTLIOCommandBuffer") +IOCommandBuffer :: struct { using _: NS.Object } + +@(objc_type=IOCommandBuffer, objc_name="addCompletedHandler") +IOCommandBuffer_addCompletedHandler :: #force_inline proc "c" (self: ^IOCommandBuffer, block: ^NS.Block) { + msgSend(nil, self, "addCompletedHandler:", block) +} +@(objc_type=IOCommandBuffer, objc_name="loadBytes") +IOCommandBuffer_loadBytes :: #force_inline proc "c" (self: ^IOCommandBuffer, pointer: rawptr, size: NS.UInteger, sourceHandle: ^IOFileHandle, sourceHandleOffset: NS.UInteger) { + msgSend(nil, self, "loadBytes:size:sourceHandle:sourceHandleOffset:", pointer, size, sourceHandle, sourceHandleOffset) +} +@(objc_type=IOCommandBuffer, objc_name="loadBuffer") +IOCommandBuffer_loadBuffer :: #force_inline proc "c" (self: ^IOCommandBuffer, buffer: ^Buffer, offset: NS.UInteger, size: NS.UInteger, sourceHandle: ^IOFileHandle, sourceHandleOffset: NS.UInteger) { + msgSend(nil, self, "loadBuffer:offset:sourceHandle:sourceHandleOffset:", buffer, offset, size, sourceHandle, sourceHandleOffset) +} +@(objc_type=IOCommandBuffer, objc_name="loadTexture") +IOCommandBuffer_loadTexture :: #force_inline proc "c" (self: ^IOCommandBuffer, texture: ^Texture, slice: NS.UInteger, level, size, sourceBytesPerRow, sourceBytesPerImage: NS.UInteger, destinationOrigin: Origin, sourceHandle: ^IOFileHandle, sourceHandleOffset: NS.UInteger) { + msgSend(nil, self, "loadTexture:slice:level:size:sourceBytesPerRow:sourceBytesPerImage:destinationOrigin:sourceHandle:sourceHandleOffset:", texture, slice, level, size, sourceBytesPerRow, sourceBytesPerImage, destinationOrigin, sourceHandle, sourceHandleOffset) +} + +@(objc_type=IOCommandBuffer, objc_name="copyStatusToBuffer") +IOCommandBuffer_copyStatusToBuffer :: #force_inline proc "c" (self: ^IOCommandBuffer, buffer: ^Buffer, offset: NS.UInteger) { + msgSend(nil, self, "copyStatusToBuffer:offset:", buffer, offset) +} + +@(objc_type=IOCommandBuffer, objc_name="commit") +IOCommandBuffer_commit :: #force_inline proc "c" (self: ^IOCommandBuffer) { + msgSend(nil, self, "commit") +} +@(objc_type=IOCommandBuffer, objc_name="waitUntilCompleted") +IOCommandBuffer_waitUntilCompleted :: #force_inline proc "c" (self: ^IOCommandBuffer) { + msgSend(nil, self, "waitUntilCompleted") +} +@(objc_type=IOCommandBuffer, objc_name="tryCancel") +IOCommandBuffer_tryCancel :: #force_inline proc "c" (self: ^IOCommandBuffer) { + msgSend(nil, self, "tryCancel") +} +@(objc_type=IOCommandBuffer, objc_name="addBarrier") +IOCommandBuffer_addBarrier :: #force_inline proc "c" (self: ^IOCommandBuffer) { + msgSend(nil, self, "addBarrier") +} +@(objc_type=IOCommandBuffer, objc_name="enqueue") +IOCommandBuffer_enqueue :: #force_inline proc "c" (self: ^IOCommandBuffer) { + msgSend(nil, self, "enqueue") +} +@(objc_type=IOCommandBuffer, objc_name="waitForEvent") +IOCommandBuffer_waitForEvent :: #force_inline proc "c" (self: ^IOCommandBuffer, event: ^SharedEvent, value: u64) { + msgSend(nil, self, "waitForEvent:value", event, value) +} +@(objc_type=IOCommandBuffer, objc_name="signalEvent") +IOCommandBuffer_signalEvent :: #force_inline proc "c" (self: ^IOCommandBuffer, event: ^SharedEvent, value: u64) { + msgSend(nil, self, "signalEvent:value", event, value) +} + + +@(objc_type=IOCommandBuffer, objc_name="pushDebugGroup") +IOCommandBuffer_pushDebugGroup :: #force_inline proc "c" (self: ^IOCommandBuffer, name: ^NS.String) { + msgSend(nil, self, "pushDebugGroup:", name) +} +@(objc_type=IOCommandBuffer, objc_name="popDebugGroup") +IOCommandBuffer_popDebugGroup :: #force_inline proc "c" (self: ^IOCommandBuffer) { + msgSend(nil, self, "popDebugGroup") +} + + +@(objc_type=IOCommandBuffer, objc_name="label") +IOCommandBuffer_label :: #force_inline proc "c" (self: ^IOCommandBuffer) -> ^NS.String { + return msgSend(^NS.String, self, "label") +} +@(objc_type=IOCommandBuffer, objc_name="setLabel") +IOCommandBuffer_setLabel :: #force_inline proc "c" (self: ^IOCommandBuffer, label: ^NS.String) { + msgSend(nil, self, "setLabel:", label) +} + +@(objc_type=IOCommandBuffer, objc_name="status") +IOCommandBuffer_status :: #force_inline proc "c" (self: ^IOCommandBuffer) -> IOStatus { + return msgSend(IOStatus, self, "status") +} +@(objc_type=IOCommandBuffer, objc_name="error") +IOCommandBuffer_error :: #force_inline proc "c" (self: ^IOCommandBuffer) -> ^NS.Error { + return msgSend(^NS.Error, self, "error") +} + +//////////////////////////////////////////////////////////////////////////////// + @(objc_class="MTLLibrary") Library :: struct { using _: NS.Object } @(objc_type=Library, objc_name="device") -Library_device :: #force_inline proc(self: ^Library) -> ^Device { +Library_device :: #force_inline proc "c" (self: ^Library) -> ^Device { return msgSend(^Device, self, "device") } @(objc_type=Library, objc_name="functionNames") -Library_functionNames :: #force_inline proc(self: ^Library) -> ^NS.Array { +Library_functionNames :: #force_inline proc "c" (self: ^Library) -> ^NS.Array { return msgSend(^NS.Array, self, "functionNames") } @(objc_type=Library, objc_name="installName") -Library_installName :: #force_inline proc(self: ^Library) -> ^NS.String { +Library_installName :: #force_inline proc "c" (self: ^Library) -> ^NS.String { return msgSend(^NS.String, self, "installName") } @(objc_type=Library, objc_name="label") -Library_label :: #force_inline proc(self: ^Library) -> ^NS.String { +Library_label :: #force_inline proc "c" (self: ^Library) -> ^NS.String { return msgSend(^NS.String, self, "label") } @(objc_type=Library, objc_name="newFunctionWithCompletionHandler") -Library_newFunctionWithCompletionHandler :: #force_inline proc(self: ^Library, descriptor: ^FunctionDescriptor, completionHandler: ^NS.Block) -> ^Function { +Library_newFunctionWithCompletionHandler :: #force_inline proc "c" (self: ^Library, descriptor: ^FunctionDescriptor, completionHandler: ^NS.Block) -> ^Function { return msgSend(^Function, self, "newFunctionWithDescriptor:completionHandler:", descriptor, completionHandler) } @(objc_type=Library, objc_name="newFunctionWithDescriptor") -Library_newFunctionWithDescriptor :: #force_inline proc(self: ^Library, descriptor: ^FunctionDescriptor) -> (function: ^Function, error: ^NS.Error) { +Library_newFunctionWithDescriptor :: #force_inline proc "contextless" (self: ^Library, descriptor: ^FunctionDescriptor) -> (function: ^Function, error: ^NS.Error) { function = msgSend(^Function, self, "newFunctionWithDescriptor:error:", descriptor, &error) return } @(objc_type=Library, objc_name="newFunctionWithName") -Library_newFunctionWithName :: #force_inline proc(self: ^Library, functionName: ^NS.String) -> ^Function { +Library_newFunctionWithName :: #force_inline proc "c" (self: ^Library, functionName: ^NS.String) -> ^Function { return msgSend(^Function, self, "newFunctionWithName:", functionName) } @(objc_type=Library, objc_name="newFunctionWithConstantValuesAndCompletionHandler") -Library_newFunctionWithConstantValuesAndCompletionHandler :: #force_inline proc(self: ^Library, name: ^NS.String, constantValues: ^FunctionConstantValues, completionHandler: ^NS.Block) -> ^Function { +Library_newFunctionWithConstantValuesAndCompletionHandler :: #force_inline proc "c" (self: ^Library, name: ^NS.String, constantValues: ^FunctionConstantValues, completionHandler: ^NS.Block) -> ^Function { return msgSend(^Function, self, "newFunctionWithName:constantValues:completionHandler:", name, constantValues, completionHandler) } @(objc_type=Library, objc_name="newFunctionWithConstantValues") -Library_newFunctionWithConstantValues :: #force_inline proc(self: ^Library, name: ^NS.String, constantValues: ^FunctionConstantValues) -> (function: ^Function, error: ^NS.Error) { +Library_newFunctionWithConstantValues :: #force_inline proc "contextless" (self: ^Library, name: ^NS.String, constantValues: ^FunctionConstantValues) -> (function: ^Function, error: ^NS.Error) { function = msgSend(^Function, self, "newFunctionWithName:constantValues:error:", name, constantValues, &error) return } @@ -7494,1068 +6436,998 @@ Library_newFunction :: proc{ } @(objc_type=Library, objc_name="newIntersectionFunctionWithCompletionHandler") -Library_newIntersectionFunctionWithCompletionHandler :: #force_inline proc(self: ^Library, descriptor: ^IntersectionFunctionDescriptor, completionHandler: ^NS.Block) -> ^Function { +Library_newIntersectionFunctionWithCompletionHandler :: #force_inline proc "c" (self: ^Library, descriptor: ^IntersectionFunctionDescriptor, completionHandler: ^NS.Block) -> ^Function { return msgSend(^Function, self, "newIntersectionFunctionWithDescriptor:completionHandler:", descriptor, completionHandler) } @(objc_type=Library, objc_name="newIntersectionFunction") -Library_newIntersectionFunction :: #force_inline proc(self: ^Library, descriptor: ^IntersectionFunctionDescriptor) -> (function: ^Function, error: ^NS.Error) { +Library_newIntersectionFunction :: #force_inline proc "contextless" (self: ^Library, descriptor: ^IntersectionFunctionDescriptor) -> (function: ^Function, error: ^NS.Error) { function = msgSend(^Function, self, "newIntersectionFunctionWithDescriptor:error:", descriptor, &error) return } @(objc_type=Library, objc_name="setLabel") -Library_setLabel :: #force_inline proc(self: ^Library, label: ^NS.String) { +Library_setLabel :: #force_inline proc "c" (self: ^Library, label: ^NS.String) { msgSend(nil, self, "setLabel:", label) } @(objc_type=Library, objc_name="type") -Library_type :: #force_inline proc(self: ^Library) -> LibraryType { +Library_type :: #force_inline proc "c" (self: ^Library) -> LibraryType { return msgSend(LibraryType, self, "type") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - ParallelRenderCommandEncoder -Class Methods: -Methods: - renderCommandEncoder - setColorStoreAction - setColorStoreActionOptions - setDepthStoreAction - setDepthStoreActionOptions - setStencilStoreAction - setStencilStoreActionOptions -*/ @(objc_class="MTLParallelRenderCommandEncoder") ParallelRenderCommandEncoder :: struct { using _: CommandEncoder } @(objc_type=ParallelRenderCommandEncoder, objc_name="renderCommandEncoder") -ParallelRenderCommandEncoder_renderCommandEncoder :: #force_inline proc(self: ^ParallelRenderCommandEncoder) -> ^RenderCommandEncoder { +ParallelRenderCommandEncoder_renderCommandEncoder :: #force_inline proc "c" (self: ^ParallelRenderCommandEncoder) -> ^RenderCommandEncoder { return msgSend(^RenderCommandEncoder, self, "renderCommandEncoder") } @(objc_type=ParallelRenderCommandEncoder, objc_name="setColorStoreAction") -ParallelRenderCommandEncoder_setColorStoreAction :: #force_inline proc(self: ^ParallelRenderCommandEncoder, storeAction: StoreAction, colorAttachmentIndex: NS.UInteger) { +ParallelRenderCommandEncoder_setColorStoreAction :: #force_inline proc "c" (self: ^ParallelRenderCommandEncoder, storeAction: StoreAction, colorAttachmentIndex: NS.UInteger) { msgSend(nil, self, "setColorStoreAction:atIndex:", storeAction, colorAttachmentIndex) } @(objc_type=ParallelRenderCommandEncoder, objc_name="setColorStoreActionOptions") -ParallelRenderCommandEncoder_setColorStoreActionOptions :: #force_inline proc(self: ^ParallelRenderCommandEncoder, storeActionOptions: StoreActionOptions, colorAttachmentIndex: NS.UInteger) { +ParallelRenderCommandEncoder_setColorStoreActionOptions :: #force_inline proc "c" (self: ^ParallelRenderCommandEncoder, storeActionOptions: StoreActionOptions, colorAttachmentIndex: NS.UInteger) { msgSend(nil, self, "setColorStoreActionOptions:atIndex:", storeActionOptions, colorAttachmentIndex) } @(objc_type=ParallelRenderCommandEncoder, objc_name="setDepthStoreAction") -ParallelRenderCommandEncoder_setDepthStoreAction :: #force_inline proc(self: ^ParallelRenderCommandEncoder, storeAction: StoreAction) { +ParallelRenderCommandEncoder_setDepthStoreAction :: #force_inline proc "c" (self: ^ParallelRenderCommandEncoder, storeAction: StoreAction) { msgSend(nil, self, "setDepthStoreAction:", storeAction) } @(objc_type=ParallelRenderCommandEncoder, objc_name="setDepthStoreActionOptions") -ParallelRenderCommandEncoder_setDepthStoreActionOptions :: #force_inline proc(self: ^ParallelRenderCommandEncoder, storeActionOptions: StoreActionOptions) { +ParallelRenderCommandEncoder_setDepthStoreActionOptions :: #force_inline proc "c" (self: ^ParallelRenderCommandEncoder, storeActionOptions: StoreActionOptions) { msgSend(nil, self, "setDepthStoreActionOptions:", storeActionOptions) } @(objc_type=ParallelRenderCommandEncoder, objc_name="setStencilStoreAction") -ParallelRenderCommandEncoder_setStencilStoreAction :: #force_inline proc(self: ^ParallelRenderCommandEncoder, storeAction: StoreAction) { +ParallelRenderCommandEncoder_setStencilStoreAction :: #force_inline proc "c" (self: ^ParallelRenderCommandEncoder, storeAction: StoreAction) { msgSend(nil, self, "setStencilStoreAction:", storeAction) } @(objc_type=ParallelRenderCommandEncoder, objc_name="setStencilStoreActionOptions") -ParallelRenderCommandEncoder_setStencilStoreActionOptions :: #force_inline proc(self: ^ParallelRenderCommandEncoder, storeActionOptions: StoreActionOptions) { +ParallelRenderCommandEncoder_setStencilStoreActionOptions :: #force_inline proc "c" (self: ^ParallelRenderCommandEncoder, storeActionOptions: StoreActionOptions) { msgSend(nil, self, "setStencilStoreActionOptions:", storeActionOptions) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - RasterizationRateMap -Class Methods: -Methods: - copyParameterDataToBuffer - device - label - layerCount - mapPhysicalToScreenCoordinates - mapScreenToPhysicalCoordinates - parameterBufferSizeAndAlign - physicalGranularity - physicalSizeForLayer - screenSize -*/ @(objc_class="MTLRasterizationRateMap") RasterizationRateMap :: struct { using _: NS.Object } @(objc_type=RasterizationRateMap, objc_name="copyParameterDataToBuffer") -RasterizationRateMap_copyParameterDataToBuffer :: #force_inline proc(self: ^RasterizationRateMap, buffer: ^Buffer, offset: NS.UInteger) { +RasterizationRateMap_copyParameterDataToBuffer :: #force_inline proc "c" (self: ^RasterizationRateMap, buffer: ^Buffer, offset: NS.UInteger) { msgSend(nil, self, "copyParameterDataToBuffer:offset:", buffer, offset) } @(objc_type=RasterizationRateMap, objc_name="device") -RasterizationRateMap_device :: #force_inline proc(self: ^RasterizationRateMap) -> ^Device { +RasterizationRateMap_device :: #force_inline proc "c" (self: ^RasterizationRateMap) -> ^Device { return msgSend(^Device, self, "device") } @(objc_type=RasterizationRateMap, objc_name="label") -RasterizationRateMap_label :: #force_inline proc(self: ^RasterizationRateMap) -> ^NS.String { +RasterizationRateMap_label :: #force_inline proc "c" (self: ^RasterizationRateMap) -> ^NS.String { return msgSend(^NS.String, self, "label") } @(objc_type=RasterizationRateMap, objc_name="layerCount") -RasterizationRateMap_layerCount :: #force_inline proc(self: ^RasterizationRateMap) -> NS.UInteger { +RasterizationRateMap_layerCount :: #force_inline proc "c" (self: ^RasterizationRateMap) -> NS.UInteger { return msgSend(NS.UInteger, self, "layerCount") } @(objc_type=RasterizationRateMap, objc_name="mapPhysicalToScreenCoordinates") -RasterizationRateMap_mapPhysicalToScreenCoordinates :: #force_inline proc(self: ^RasterizationRateMap, physicalCoordinates: Coordinate2D, layerIndex: NS.UInteger) -> Coordinate2D { +RasterizationRateMap_mapPhysicalToScreenCoordinates :: #force_inline proc "c" (self: ^RasterizationRateMap, physicalCoordinates: Coordinate2D, layerIndex: NS.UInteger) -> Coordinate2D { return msgSend(Coordinate2D, self, "mapPhysicalToScreenCoordinates:forLayer:", physicalCoordinates, layerIndex) } @(objc_type=RasterizationRateMap, objc_name="mapScreenToPhysicalCoordinates") -RasterizationRateMap_mapScreenToPhysicalCoordinates :: #force_inline proc(self: ^RasterizationRateMap, screenCoordinates: Coordinate2D, layerIndex: NS.UInteger) -> Coordinate2D { +RasterizationRateMap_mapScreenToPhysicalCoordinates :: #force_inline proc "c" (self: ^RasterizationRateMap, screenCoordinates: Coordinate2D, layerIndex: NS.UInteger) -> Coordinate2D { return msgSend(Coordinate2D, self, "mapScreenToPhysicalCoordinates:forLayer:", screenCoordinates, layerIndex) } @(objc_type=RasterizationRateMap, objc_name="parameterBufferSizeAndAlign") -RasterizationRateMap_parameterBufferSizeAndAlign :: #force_inline proc(self: ^RasterizationRateMap) -> (size, align: NS.UInteger) { +RasterizationRateMap_parameterBufferSizeAndAlign :: #force_inline proc "c" (self: ^RasterizationRateMap) -> (size, align: NS.UInteger) { res := msgSend(SizeAndAlign, self, "parameterBufferSizeAndAlign") return res.size, res.align } @(objc_type=RasterizationRateMap, objc_name="physicalGranularity") -RasterizationRateMap_physicalGranularity :: #force_inline proc(self: ^RasterizationRateMap) -> Size { +RasterizationRateMap_physicalGranularity :: #force_inline proc "c" (self: ^RasterizationRateMap) -> Size { return msgSend(Size, self, "physicalGranularity") } @(objc_type=RasterizationRateMap, objc_name="physicalSizeForLayer") -RasterizationRateMap_physicalSizeForLayer :: #force_inline proc(self: ^RasterizationRateMap, layerIndex: NS.UInteger) -> Size { +RasterizationRateMap_physicalSizeForLayer :: #force_inline proc "c" (self: ^RasterizationRateMap, layerIndex: NS.UInteger) -> Size { return msgSend(Size, self, "physicalSizeForLayer:", layerIndex) } @(objc_type=RasterizationRateMap, objc_name="screenSize") -RasterizationRateMap_screenSize :: #force_inline proc(self: ^RasterizationRateMap) -> Size { +RasterizationRateMap_screenSize :: #force_inline proc "c" (self: ^RasterizationRateMap) -> Size { return msgSend(Size, self, "screenSize") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - RenderCommandEncoder -Class Methods: -Methods: - dispatchThreadsPerTile - drawIndexedPatches - drawIndexedPatches - drawIndexedPrimitives - drawIndexedPrimitives - drawIndexedPrimitives - drawIndexedPrimitives - drawPatches - drawPatches - drawPrimitives - drawPrimitives - drawPrimitives - drawPrimitives - executeCommandsInBuffer - executeCommandsInBuffer - memoryBarrierWithResources - memoryBarrierWithScope - sampleCountersInBuffer - setBlendColorRed - setColorStoreAction - setColorStoreActionOptions - setCullMode - setDepthBias - setDepthClipMode - setDepthStencilState - setDepthStoreAction - setDepthStoreActionOptions - setFragmentBuffer - setFragmentBufferOffset - setFragmentBuffers - setFragmentBytes - setFragmentSamplerState - setFragmentSamplerState - setFragmentSamplerStates - setFragmentSamplerStates - setFragmentTexture - setFragmentTextures - setFrontFacingWinding - setRenderPipelineState - setScissorRect - setScissorRects - setStencilFrontReferenceValue - setStencilReferenceValue - setStencilStoreAction - setStencilStoreActionOptions - setTessellationFactorBuffer - setTessellationFactorScale - setThreadgroupMemoryLength - setTileBuffer - setTileBufferOffset - setTileBuffers - setTileBytes - setTileSamplerState - setTileSamplerState - setTileSamplerStates - setTileSamplerStates - setTileTexture - setTileTextures - setTriangleFillMode - setVertexAmplificationCount - setVertexBuffer - setVertexBufferOffset - setVertexBuffers - setVertexBytes - setVertexSamplerState - setVertexSamplerState - setVertexSamplerStates - setVertexSamplerStates - setVertexTexture - setVertexTextures - setViewport - setViewports - setVisibilityResultMode - textureBarrier - tileHeight - tileWidth - updateFence - useHeap - useHeap - useHeaps - useHeaps - useResource - useResource - useResources - useResources - waitForFence -*/ @(objc_class="MTLRenderCommandEncoder") RenderCommandEncoder :: struct { using _: CommandEncoder } @(objc_type=RenderCommandEncoder, objc_name="dispatchThreadsPerTile") -RenderCommandEncoder_dispatchThreadsPerTile :: #force_inline proc(self: ^RenderCommandEncoder, threadsPerTile: Size) { +RenderCommandEncoder_dispatchThreadsPerTile :: #force_inline proc "c" (self: ^RenderCommandEncoder, threadsPerTile: Size) { msgSend(nil, self, "dispatchThreadsPerTile:", threadsPerTile) } @(objc_type=RenderCommandEncoder, objc_name="drawIndexedPatchesWihtIndirect") -RenderCommandEncoder_drawIndexedPatchesWihtIndirect :: #force_inline proc(self: ^RenderCommandEncoder, numberOfPatchControlPoints: NS.UInteger, patchIndexBuffer: ^Buffer, patchIndexBufferOffset: NS.UInteger, controlPointIndexBuffer: ^Buffer, controlPointIndexBufferOffset: NS.UInteger, indirectBuffer: ^Buffer, indirectBufferOffset: NS.UInteger) { +RenderCommandEncoder_drawIndexedPatchesWihtIndirect :: #force_inline proc "c" (self: ^RenderCommandEncoder, numberOfPatchControlPoints: NS.UInteger, patchIndexBuffer: ^Buffer, patchIndexBufferOffset: NS.UInteger, controlPointIndexBuffer: ^Buffer, controlPointIndexBufferOffset: NS.UInteger, indirectBuffer: ^Buffer, indirectBufferOffset: NS.UInteger) { msgSend(nil, self, "drawIndexedPatches:patchIndexBuffer:patchIndexBufferOffset:controlPointIndexBuffer:controlPointIndexBufferOffset:indirectBuffer:indirectBufferOffset:", numberOfPatchControlPoints, patchIndexBuffer, patchIndexBufferOffset, controlPointIndexBuffer, controlPointIndexBufferOffset, indirectBuffer, indirectBufferOffset) } @(objc_type=RenderCommandEncoder, objc_name="drawIndexPatchesWithInstances") -RenderCommandEncoder_drawIndexPatchesWithInstance :: #force_inline proc(self: ^RenderCommandEncoder, numberOfPatchControlPoints: NS.UInteger, patchStart, patchCount: NS.UInteger, patchIndexBuffer: ^Buffer, patchIndexBufferOffset: NS.UInteger, controlPointIndexBuffer: ^Buffer, controlPointIndexBufferOffset: NS.UInteger, instanceCount: NS.UInteger, baseInstance: NS.UInteger) { +RenderCommandEncoder_drawIndexPatchesWithInstance :: #force_inline proc "c" (self: ^RenderCommandEncoder, numberOfPatchControlPoints: NS.UInteger, patchStart, patchCount: NS.UInteger, patchIndexBuffer: ^Buffer, patchIndexBufferOffset: NS.UInteger, controlPointIndexBuffer: ^Buffer, controlPointIndexBufferOffset: NS.UInteger, instanceCount: NS.UInteger, baseInstance: NS.UInteger) { msgSend(nil, self, "drawIndexedPatches:patchStart:patchCount:patchIndexBuffer:patchIndexBufferOffset:controlPointIndexBuffer:controlPointIndexBufferOffset:instanceCount:baseInstance:", numberOfPatchControlPoints, patchStart, patchCount, patchIndexBuffer, patchIndexBufferOffset, controlPointIndexBuffer, controlPointIndexBufferOffset, instanceCount, baseInstance) } @(objc_type=RenderCommandEncoder, objc_name="drawIndexedPrimitives") -RenderCommandEncoder_drawIndexedPrimitives :: #force_inline proc(self: ^RenderCommandEncoder, primitiveType: PrimitiveType, indexCount: NS.UInteger, indexType: IndexType, indexBuffer: ^Buffer, indexBufferOffset: NS.UInteger) { +RenderCommandEncoder_drawIndexedPrimitives :: #force_inline proc "c" (self: ^RenderCommandEncoder, primitiveType: PrimitiveType, indexCount: NS.UInteger, indexType: IndexType, indexBuffer: ^Buffer, indexBufferOffset: NS.UInteger) { msgSend(nil, self, "drawIndexedPrimitives:indexCount:indexType:indexBuffer:indexBufferOffset:", primitiveType, indexCount, indexType, indexBuffer, indexBufferOffset) } @(objc_type=RenderCommandEncoder, objc_name="drawIndexedPrimitivesWithInstanceCount") -RenderCommandEncoder_drawIndexedPrimitivesWithInstanceCount :: #force_inline proc(self: ^RenderCommandEncoder, primitiveType: PrimitiveType, indexCount: NS.UInteger, indexType: IndexType, indexBuffer: ^Buffer, indexBufferOffset: NS.UInteger, instanceCount: NS.UInteger) { +RenderCommandEncoder_drawIndexedPrimitivesWithInstanceCount :: #force_inline proc "c" (self: ^RenderCommandEncoder, primitiveType: PrimitiveType, indexCount: NS.UInteger, indexType: IndexType, indexBuffer: ^Buffer, indexBufferOffset: NS.UInteger, instanceCount: NS.UInteger) { msgSend(nil, self, "drawIndexedPrimitives:indexCount:indexType:indexBuffer:indexBufferOffset:instanceCount:", primitiveType, indexCount, indexType, indexBuffer, indexBufferOffset, instanceCount) } @(objc_type=RenderCommandEncoder, objc_name="drawIndexPrimitivesWithBaseVertex") -RenderCommandEncoder_drawIndexPrimitivesWithBaseVertex :: #force_inline proc(self: ^RenderCommandEncoder, primitiveType: PrimitiveType, indexCount: NS.UInteger, indexType: IndexType, indexBuffer: ^Buffer, indexBufferOffset: NS.UInteger, instanceCount: NS.UInteger, baseVertex: NS.Integer, baseInstance: NS.UInteger) { +RenderCommandEncoder_drawIndexPrimitivesWithBaseVertex :: #force_inline proc "c" (self: ^RenderCommandEncoder, primitiveType: PrimitiveType, indexCount: NS.UInteger, indexType: IndexType, indexBuffer: ^Buffer, indexBufferOffset: NS.UInteger, instanceCount: NS.UInteger, baseVertex: NS.Integer, baseInstance: NS.UInteger) { msgSend(nil, self, "drawIndexedPrimitives:indexCount:indexType:indexBuffer:indexBufferOffset:instanceCount:baseVertex:baseInstance:", primitiveType, indexCount, indexType, indexBuffer, indexBufferOffset, instanceCount, baseVertex, baseInstance) } @(objc_type=RenderCommandEncoder, objc_name="drawIndexPrimitivesWithIndirect") -RenderCommandEncoder_drawIndexPrimitivesWithIndirect :: #force_inline proc(self: ^RenderCommandEncoder, primitiveType: PrimitiveType, indexType: IndexType, indexBuffer: ^Buffer, indexBufferOffset: NS.UInteger, indirectBuffer: ^Buffer, indirectBufferOffset: NS.UInteger) { +RenderCommandEncoder_drawIndexPrimitivesWithIndirect :: #force_inline proc "c" (self: ^RenderCommandEncoder, primitiveType: PrimitiveType, indexType: IndexType, indexBuffer: ^Buffer, indexBufferOffset: NS.UInteger, indirectBuffer: ^Buffer, indirectBufferOffset: NS.UInteger) { msgSend(nil, self, "drawIndexedPrimitives:indexType:indexBuffer:indexBufferOffset:indirectBuffer:indirectBufferOffset:", primitiveType, indexType, indexBuffer, indexBufferOffset, indirectBuffer, indirectBufferOffset) } @(objc_type=RenderCommandEncoder, objc_name="drawPatches") -RenderCommandEncoder_drawPatches :: #force_inline proc(self: ^RenderCommandEncoder, numberOfPatchControlPoints: NS.UInteger, patchIndexBuffer: ^Buffer, patchIndexBufferOffset: NS.UInteger, indirectBuffer: ^Buffer, indirectBufferOffset: NS.UInteger) { +RenderCommandEncoder_drawPatches :: #force_inline proc "c" (self: ^RenderCommandEncoder, numberOfPatchControlPoints: NS.UInteger, patchIndexBuffer: ^Buffer, patchIndexBufferOffset: NS.UInteger, indirectBuffer: ^Buffer, indirectBufferOffset: NS.UInteger) { msgSend(nil, self, "drawPatches:patchIndexBuffer:patchIndexBufferOffset:indirectBuffer:indirectBufferOffset:", numberOfPatchControlPoints, patchIndexBuffer, patchIndexBufferOffset, indirectBuffer, indirectBufferOffset) } @(objc_type=RenderCommandEncoder, objc_name="drawPatchesWithInstances") -RenderCommandEncoder_drawPatchesWithInstance :: #force_inline proc(self: ^RenderCommandEncoder, numberOfPatchControlPoints: NS.UInteger, patchStart, patchCount: NS.UInteger, patchIndexBuffer: ^Buffer, patchIndexBufferOffset: NS.UInteger, instanceCount: NS.UInteger, baseInstance: NS.UInteger) { +RenderCommandEncoder_drawPatchesWithInstance :: #force_inline proc "c" (self: ^RenderCommandEncoder, numberOfPatchControlPoints: NS.UInteger, patchStart, patchCount: NS.UInteger, patchIndexBuffer: ^Buffer, patchIndexBufferOffset: NS.UInteger, instanceCount: NS.UInteger, baseInstance: NS.UInteger) { msgSend(nil, self, "drawPatches:patchStart:patchCount:patchIndexBuffer:patchIndexBufferOffset:instanceCount:baseInstance:", numberOfPatchControlPoints, patchStart, patchCount, patchIndexBuffer, patchIndexBufferOffset, instanceCount, baseInstance) } @(objc_type=RenderCommandEncoder, objc_name="drawPrimitivesWithIndirect") -RenderCommandEncoder_drawPrimitivesWithIndirect :: #force_inline proc(self: ^RenderCommandEncoder, primitiveType: PrimitiveType, indirectBuffer: ^Buffer, indirectBufferOffset: NS.UInteger) { +RenderCommandEncoder_drawPrimitivesWithIndirect :: #force_inline proc "c" (self: ^RenderCommandEncoder, primitiveType: PrimitiveType, indirectBuffer: ^Buffer, indirectBufferOffset: NS.UInteger) { msgSend(nil, self, "drawPrimitives:indirectBuffer:indirectBufferOffset:", primitiveType, indirectBuffer, indirectBufferOffset) } @(objc_type=RenderCommandEncoder, objc_name="drawPrimitives") -RenderCommandEncoder_drawPrimitives :: #force_inline proc(self: ^RenderCommandEncoder, primitiveType: PrimitiveType, vertexStart: NS.UInteger, vertexCount: NS.UInteger) { +RenderCommandEncoder_drawPrimitives :: #force_inline proc "c" (self: ^RenderCommandEncoder, primitiveType: PrimitiveType, vertexStart: NS.UInteger, vertexCount: NS.UInteger) { msgSend(nil, self, "drawPrimitives:vertexStart:vertexCount:", primitiveType, vertexStart, vertexCount) } @(objc_type=RenderCommandEncoder, objc_name="drawPrimitivesWithInstanceCount") -RenderCommandEncoder_drawPrimitivesWithInstanceCount :: #force_inline proc(self: ^RenderCommandEncoder, primitiveType: PrimitiveType, vertexStart: NS.UInteger, vertexCount: NS.UInteger, instanceCount: NS.UInteger) { +RenderCommandEncoder_drawPrimitivesWithInstanceCount :: #force_inline proc "c" (self: ^RenderCommandEncoder, primitiveType: PrimitiveType, vertexStart: NS.UInteger, vertexCount: NS.UInteger, instanceCount: NS.UInteger) { msgSend(nil, self, "drawPrimitives:vertexStart:vertexCount:instanceCount:", primitiveType, vertexStart, vertexCount, instanceCount) } @(objc_type=RenderCommandEncoder, objc_name="drawPrimitivesWithInstances") -RenderCommandEncoder_drawPrimitivesWithInstances :: #force_inline proc(self: ^RenderCommandEncoder, primitiveType: PrimitiveType, vertexStart: NS.UInteger, vertexCount: NS.UInteger, instanceCount: NS.UInteger, baseInstance: NS.UInteger) { +RenderCommandEncoder_drawPrimitivesWithInstances :: #force_inline proc "c" (self: ^RenderCommandEncoder, primitiveType: PrimitiveType, vertexStart: NS.UInteger, vertexCount: NS.UInteger, instanceCount: NS.UInteger, baseInstance: NS.UInteger) { msgSend(nil, self, "drawPrimitives:vertexStart:vertexCount:instanceCount:baseInstance:", primitiveType, vertexStart, vertexCount, instanceCount, baseInstance) } @(objc_type=RenderCommandEncoder, objc_name="executeCommandsInBuffer") -RenderCommandEncoder_executeCommandsInBuffer :: #force_inline proc(self: ^RenderCommandEncoder, indirectCommandbuffer: ^Buffer, indirectRangeBuffer: ^Buffer, indirectBufferOffset: NS.UInteger) { +RenderCommandEncoder_executeCommandsInBuffer :: #force_inline proc "c" (self: ^RenderCommandEncoder, indirectCommandbuffer: ^Buffer, indirectRangeBuffer: ^Buffer, indirectBufferOffset: NS.UInteger) { msgSend(nil, self, "executeCommandsInBuffer:indirectBuffer:indirectBufferOffset:", indirectCommandbuffer, indirectRangeBuffer, indirectBufferOffset) } @(objc_type=RenderCommandEncoder, objc_name="executeCommandsInBufferWithRange") -RenderCommandEncoder_executeCommandsInBufferWithRange :: #force_inline proc(self: ^RenderCommandEncoder, indirectCommandBuffer: ^Buffer, executionRange: NS.Range) { +RenderCommandEncoder_executeCommandsInBufferWithRange :: #force_inline proc "c" (self: ^RenderCommandEncoder, indirectCommandBuffer: ^Buffer, executionRange: NS.Range) { msgSend(nil, self, "executeCommandsInBuffer:withRange:", indirectCommandBuffer, executionRange) } @(objc_type=RenderCommandEncoder, objc_name="memoryBarrierWithResources") -RenderCommandEncoder_memoryBarrierWithResources :: #force_inline proc(self: ^RenderCommandEncoder, resources: []^Resource, after: RenderStages, before: RenderStages) { +RenderCommandEncoder_memoryBarrierWithResources :: #force_inline proc "c" (self: ^RenderCommandEncoder, resources: []^Resource, after: RenderStages, before: RenderStages) { msgSend(nil, self, "memoryBarrierWithResources:count:afterStages:beforeStages:", raw_data(resources), NS.UInteger(len(resources)), after, before) } @(objc_type=RenderCommandEncoder, objc_name="memoryBarrierWithScope") -RenderCommandEncoder_memoryBarrierWithScope :: #force_inline proc(self: ^RenderCommandEncoder, scope: BarrierScope, after: RenderStages, before: RenderStages) { +RenderCommandEncoder_memoryBarrierWithScope :: #force_inline proc "c" (self: ^RenderCommandEncoder, scope: BarrierScope, after: RenderStages, before: RenderStages) { msgSend(nil, self, "memoryBarrierWithScope:afterStages:beforeStages:", scope, after, before) } @(objc_type=RenderCommandEncoder, objc_name="sampleCountersInBuffer") -RenderCommandEncoder_sampleCountersInBuffer :: #force_inline proc(self: ^RenderCommandEncoder, sampleBuffer: ^Buffer, sampleIndex: NS.UInteger, barrier: BOOL) { +RenderCommandEncoder_sampleCountersInBuffer :: #force_inline proc "c" (self: ^RenderCommandEncoder, sampleBuffer: ^Buffer, sampleIndex: NS.UInteger, barrier: BOOL) { msgSend(nil, self, "sampleCountersInBuffer:atSampleIndex:withBarrier:", sampleBuffer, sampleIndex, barrier) } @(objc_type=RenderCommandEncoder, objc_name="setBlendColorRed") -RenderCommandEncoder_setBlendColorRed :: #force_inline proc(self: ^RenderCommandEncoder, red: f32, green: f32, blue: f32, alpha: f32) { +RenderCommandEncoder_setBlendColorRed :: #force_inline proc "c" (self: ^RenderCommandEncoder, red: f32, green: f32, blue: f32, alpha: f32) { msgSend(nil, self, "setBlendColorRed:green:blue:alpha:", red, green, blue, alpha) } @(objc_type=RenderCommandEncoder, objc_name="setColorStoreAction") -RenderCommandEncoder_setColorStoreAction :: #force_inline proc(self: ^RenderCommandEncoder, storeAction: StoreAction, colorAttachmentIndex: NS.UInteger) { +RenderCommandEncoder_setColorStoreAction :: #force_inline proc "c" (self: ^RenderCommandEncoder, storeAction: StoreAction, colorAttachmentIndex: NS.UInteger) { msgSend(nil, self, "setColorStoreAction:atIndex:", storeAction, colorAttachmentIndex) } @(objc_type=RenderCommandEncoder, objc_name="setColorStoreActionOptions") -RenderCommandEncoder_setColorStoreActionOptions :: #force_inline proc(self: ^RenderCommandEncoder, storeActionOptions: StoreActionOptions, colorAttachmentIndex: NS.UInteger) { +RenderCommandEncoder_setColorStoreActionOptions :: #force_inline proc "c" (self: ^RenderCommandEncoder, storeActionOptions: StoreActionOptions, colorAttachmentIndex: NS.UInteger) { msgSend(nil, self, "setColorStoreActionOptions:atIndex:", storeActionOptions, colorAttachmentIndex) } @(objc_type=RenderCommandEncoder, objc_name="setCullMode") -RenderCommandEncoder_setCullMode :: #force_inline proc(self: ^RenderCommandEncoder, cullMode: CullMode) { +RenderCommandEncoder_setCullMode :: #force_inline proc "c" (self: ^RenderCommandEncoder, cullMode: CullMode) { msgSend(nil, self, "setCullMode:", cullMode) } @(objc_type=RenderCommandEncoder, objc_name="setDepthBias") -RenderCommandEncoder_setDepthBias :: #force_inline proc(self: ^RenderCommandEncoder, depthBias: f32, slopeScale: f32, clamp: f32) { +RenderCommandEncoder_setDepthBias :: #force_inline proc "c" (self: ^RenderCommandEncoder, depthBias: f32, slopeScale: f32, clamp: f32) { msgSend(nil, self, "setDepthBias:slopeScale:clamp:", depthBias, slopeScale, clamp) } @(objc_type=RenderCommandEncoder, objc_name="setDepthClipMode") -RenderCommandEncoder_setDepthClipMode :: #force_inline proc(self: ^RenderCommandEncoder, depthClipMode: DepthClipMode) { +RenderCommandEncoder_setDepthClipMode :: #force_inline proc "c" (self: ^RenderCommandEncoder, depthClipMode: DepthClipMode) { msgSend(nil, self, "setDepthClipMode:", depthClipMode) } @(objc_type=RenderCommandEncoder, objc_name="setDepthStencilState") -RenderCommandEncoder_setDepthStencilState :: #force_inline proc(self: ^RenderCommandEncoder, depthStencilState: ^DepthStencilState) { +RenderCommandEncoder_setDepthStencilState :: #force_inline proc "c" (self: ^RenderCommandEncoder, depthStencilState: ^DepthStencilState) { msgSend(nil, self, "setDepthStencilState:", depthStencilState) } @(objc_type=RenderCommandEncoder, objc_name="setDepthStoreAction") -RenderCommandEncoder_setDepthStoreAction :: #force_inline proc(self: ^RenderCommandEncoder, storeAction: StoreAction) { +RenderCommandEncoder_setDepthStoreAction :: #force_inline proc "c" (self: ^RenderCommandEncoder, storeAction: StoreAction) { msgSend(nil, self, "setDepthStoreAction:", storeAction) } @(objc_type=RenderCommandEncoder, objc_name="setDepthStoreActionOptions") -RenderCommandEncoder_setDepthStoreActionOptions :: #force_inline proc(self: ^RenderCommandEncoder, storeActionOptions: StoreActionOptions) { +RenderCommandEncoder_setDepthStoreActionOptions :: #force_inline proc "c" (self: ^RenderCommandEncoder, storeActionOptions: StoreActionOptions) { msgSend(nil, self, "setDepthStoreActionOptions:", storeActionOptions) } @(objc_type=RenderCommandEncoder, objc_name="setFragmentBuffer") -RenderCommandEncoder_setFragmentBuffer :: #force_inline proc(self: ^RenderCommandEncoder, buffer: ^Buffer, offset: NS.UInteger, index: NS.UInteger) { +RenderCommandEncoder_setFragmentBuffer :: #force_inline proc "c" (self: ^RenderCommandEncoder, buffer: ^Buffer, offset: NS.UInteger, index: NS.UInteger) { msgSend(nil, self, "setFragmentBuffer:offset:atIndex:", buffer, offset, index) } @(objc_type=RenderCommandEncoder, objc_name="setFragmentBufferOffset") -RenderCommandEncoder_setFragmentBufferOffset :: #force_inline proc(self: ^RenderCommandEncoder, offset: NS.UInteger, index: NS.UInteger) { +RenderCommandEncoder_setFragmentBufferOffset :: #force_inline proc "c" (self: ^RenderCommandEncoder, offset: NS.UInteger, index: NS.UInteger) { msgSend(nil, self, "setFragmentBufferOffset:atIndex:", offset, index) } @(objc_type=RenderCommandEncoder, objc_name="setFragmentBuffers") -RenderCommandEncoder_setFragmentBuffers :: #force_inline proc(self: ^RenderCommandEncoder, buffers: []^Buffer, offsets: []NS.UInteger, range: NS.Range) { +RenderCommandEncoder_setFragmentBuffers :: #force_inline proc "c" (self: ^RenderCommandEncoder, buffers: []^Buffer, offsets: []NS.UInteger, range: NS.Range) { msgSend(nil, self, "setFragmentBuffers:offsets:withRange:", raw_data(buffers), raw_data(offsets), range) } @(objc_type=RenderCommandEncoder, objc_name="setFragmentBytes") -RenderCommandEncoder_setFragmentBytes :: #force_inline proc(self: ^RenderCommandEncoder, bytes: []byte, index: NS.UInteger) { +RenderCommandEncoder_setFragmentBytes :: #force_inline proc "c" (self: ^RenderCommandEncoder, bytes: []byte, index: NS.UInteger) { msgSend(nil, self, "setFragmentBytes:length:atIndex:", raw_data(bytes), NS.UInteger(len(bytes)), index) } @(objc_type=RenderCommandEncoder, objc_name="setFragmentSamplerState") -RenderCommandEncoder_setFragmentSamplerState :: #force_inline proc(self: ^RenderCommandEncoder, sampler: ^SamplerState, index: NS.UInteger) { +RenderCommandEncoder_setFragmentSamplerState :: #force_inline proc "c" (self: ^RenderCommandEncoder, sampler: ^SamplerState, index: NS.UInteger) { msgSend(nil, self, "setFragmentSamplerState:atIndex:", sampler, index) } @(objc_type=RenderCommandEncoder, objc_name="setFragmentSamplerStateWithLod") -RenderCommandEncoder_setFragmentSamplerStateWithLod :: #force_inline proc(self: ^RenderCommandEncoder, sampler: ^SamplerState, lodMinClamp: f32, lodMaxClamp: f32, index: NS.UInteger) { +RenderCommandEncoder_setFragmentSamplerStateWithLod :: #force_inline proc "c" (self: ^RenderCommandEncoder, sampler: ^SamplerState, lodMinClamp: f32, lodMaxClamp: f32, index: NS.UInteger) { msgSend(nil, self, "setFragmentSamplerState:lodMinClamp:lodMaxClamp:atIndex:", sampler, lodMinClamp, lodMaxClamp, index) } @(objc_type=RenderCommandEncoder, objc_name="setFragmentSamplerStatesWithLod") -RenderCommandEncoder_setFragmentSamplerStatesWithLod :: #force_inline proc(self: ^RenderCommandEncoder, samplers: []^SamplerState, lodMinClamps, lodMaxClamps: []f32, range: NS.Range) { +RenderCommandEncoder_setFragmentSamplerStatesWithLod :: #force_inline proc "c" (self: ^RenderCommandEncoder, samplers: []^SamplerState, lodMinClamps, lodMaxClamps: []f32, range: NS.Range) { msgSend(nil, self, "setFragmentSamplerStates:lodMinClamps:lodMaxClamps:withRange:", raw_data(samplers), raw_data(lodMinClamps), raw_data(lodMaxClamps), range) } @(objc_type=RenderCommandEncoder, objc_name="setFragmentSamplerStatesWithRange") -RenderCommandEncoder_setFragmentSamplerStatesWithRange :: #force_inline proc(self: ^RenderCommandEncoder, samplers: []^SamplerState, range: NS.Range) { +RenderCommandEncoder_setFragmentSamplerStatesWithRange :: #force_inline proc "c" (self: ^RenderCommandEncoder, samplers: []^SamplerState, range: NS.Range) { msgSend(nil, self, "setFragmentSamplerStates:withRange:", raw_data(samplers), range) } @(objc_type=RenderCommandEncoder, objc_name="setFragmentTexture") -RenderCommandEncoder_setFragmentTexture :: #force_inline proc(self: ^RenderCommandEncoder, texture: ^Texture, index: NS.UInteger) { +RenderCommandEncoder_setFragmentTexture :: #force_inline proc "c" (self: ^RenderCommandEncoder, texture: ^Texture, index: NS.UInteger) { msgSend(nil, self, "setFragmentTexture:atIndex:", texture, index) } @(objc_type=RenderCommandEncoder, objc_name="setFragmentTextures") -RenderCommandEncoder_setFragmentTextures :: #force_inline proc(self: ^RenderCommandEncoder, textures: []^Texture, range: NS.Range) { +RenderCommandEncoder_setFragmentTextures :: #force_inline proc "c" (self: ^RenderCommandEncoder, textures: []^Texture, range: NS.Range) { msgSend(nil, self, "setFragmentTextures:withRange:", raw_data(textures), range) } @(objc_type=RenderCommandEncoder, objc_name="setFrontFacingWinding") -RenderCommandEncoder_setFrontFacingWinding :: #force_inline proc(self: ^RenderCommandEncoder, frontFacingWinding: Winding) { +RenderCommandEncoder_setFrontFacingWinding :: #force_inline proc "c" (self: ^RenderCommandEncoder, frontFacingWinding: Winding) { msgSend(nil, self, "setFrontFacingWinding:", frontFacingWinding) } @(objc_type=RenderCommandEncoder, objc_name="setRenderPipelineState") -RenderCommandEncoder_setRenderPipelineState :: #force_inline proc(self: ^RenderCommandEncoder, pipelineState: ^RenderPipelineState) { +RenderCommandEncoder_setRenderPipelineState :: #force_inline proc "c" (self: ^RenderCommandEncoder, pipelineState: ^RenderPipelineState) { msgSend(nil, self, "setRenderPipelineState:", pipelineState) } @(objc_type=RenderCommandEncoder, objc_name="setScissorRect") -RenderCommandEncoder_setScissorRect :: #force_inline proc(self: ^RenderCommandEncoder, rect: ScissorRect) { +RenderCommandEncoder_setScissorRect :: #force_inline proc "c" (self: ^RenderCommandEncoder, rect: ScissorRect) { msgSend(nil, self, "setScissorRect:", rect) } @(objc_type=RenderCommandEncoder, objc_name="setScissorRects") -RenderCommandEncoder_setScissorRects :: #force_inline proc(self: ^RenderCommandEncoder, scissorRects: []ScissorRect) { +RenderCommandEncoder_setScissorRects :: #force_inline proc "c" (self: ^RenderCommandEncoder, scissorRects: []ScissorRect) { msgSend(nil, self, "setScissorRects:count:", raw_data(scissorRects), NS.UInteger(len(scissorRects))) } @(objc_type=RenderCommandEncoder, objc_name="setStencilFrontReferenceValue") -RenderCommandEncoder_setStencilFrontReferenceValue :: #force_inline proc(self: ^RenderCommandEncoder, frontReferenceValue: u32, backReferenceValue: u32) { +RenderCommandEncoder_setStencilFrontReferenceValue :: #force_inline proc "c" (self: ^RenderCommandEncoder, frontReferenceValue: u32, backReferenceValue: u32) { msgSend(nil, self, "setStencilFrontReferenceValue:backReferenceValue:", frontReferenceValue, backReferenceValue) } @(objc_type=RenderCommandEncoder, objc_name="setStencilReferenceValue") -RenderCommandEncoder_setStencilReferenceValue :: #force_inline proc(self: ^RenderCommandEncoder, referenceValue: u32) { +RenderCommandEncoder_setStencilReferenceValue :: #force_inline proc "c" (self: ^RenderCommandEncoder, referenceValue: u32) { msgSend(nil, self, "setStencilReferenceValue:", referenceValue) } @(objc_type=RenderCommandEncoder, objc_name="setStencilStoreAction") -RenderCommandEncoder_setStencilStoreAction :: #force_inline proc(self: ^RenderCommandEncoder, storeAction: StoreAction) { +RenderCommandEncoder_setStencilStoreAction :: #force_inline proc "c" (self: ^RenderCommandEncoder, storeAction: StoreAction) { msgSend(nil, self, "setStencilStoreAction:", storeAction) } @(objc_type=RenderCommandEncoder, objc_name="setStencilStoreActionOptions") -RenderCommandEncoder_setStencilStoreActionOptions :: #force_inline proc(self: ^RenderCommandEncoder, storeActionOptions: StoreActionOptions) { +RenderCommandEncoder_setStencilStoreActionOptions :: #force_inline proc "c" (self: ^RenderCommandEncoder, storeActionOptions: StoreActionOptions) { msgSend(nil, self, "setStencilStoreActionOptions:", storeActionOptions) } @(objc_type=RenderCommandEncoder, objc_name="setTessellationFactorBuffer") -RenderCommandEncoder_setTessellationFactorBuffer :: #force_inline proc(self: ^RenderCommandEncoder, buffer: ^Buffer, offset: NS.UInteger, instanceStride: NS.UInteger) { +RenderCommandEncoder_setTessellationFactorBuffer :: #force_inline proc "c" (self: ^RenderCommandEncoder, buffer: ^Buffer, offset: NS.UInteger, instanceStride: NS.UInteger) { msgSend(nil, self, "setTessellationFactorBuffer:offset:instanceStride:", buffer, offset, instanceStride) } @(objc_type=RenderCommandEncoder, objc_name="setTessellationFactorScale") -RenderCommandEncoder_setTessellationFactorScale :: #force_inline proc(self: ^RenderCommandEncoder, scale: f32) { +RenderCommandEncoder_setTessellationFactorScale :: #force_inline proc "c" (self: ^RenderCommandEncoder, scale: f32) { msgSend(nil, self, "setTessellationFactorScale:", scale) } @(objc_type=RenderCommandEncoder, objc_name="setThreadgroupMemoryLength") -RenderCommandEncoder_setThreadgroupMemoryLength :: #force_inline proc(self: ^RenderCommandEncoder, length: NS.UInteger, offset: NS.UInteger, index: NS.UInteger) { +RenderCommandEncoder_setThreadgroupMemoryLength :: #force_inline proc "c" (self: ^RenderCommandEncoder, length: NS.UInteger, offset: NS.UInteger, index: NS.UInteger) { msgSend(nil, self, "setThreadgroupMemoryLength:offset:atIndex:", length, offset, index) } @(objc_type=RenderCommandEncoder, objc_name="setTileBuffer") -RenderCommandEncoder_setTileBuffer :: #force_inline proc(self: ^RenderCommandEncoder, buffer: ^Buffer, offset: NS.UInteger, index: NS.UInteger) { +RenderCommandEncoder_setTileBuffer :: #force_inline proc "c" (self: ^RenderCommandEncoder, buffer: ^Buffer, offset: NS.UInteger, index: NS.UInteger) { msgSend(nil, self, "setTileBuffer:offset:atIndex:", buffer, offset, index) } @(objc_type=RenderCommandEncoder, objc_name="setTileBufferOffset") -RenderCommandEncoder_setTileBufferOffset :: #force_inline proc(self: ^RenderCommandEncoder, offset: NS.UInteger, index: NS.UInteger) { +RenderCommandEncoder_setTileBufferOffset :: #force_inline proc "c" (self: ^RenderCommandEncoder, offset: NS.UInteger, index: NS.UInteger) { msgSend(nil, self, "setTileBufferOffset:atIndex:", offset, index) } @(objc_type=RenderCommandEncoder, objc_name="setTileBuffers") -RenderCommandEncoder_setTileBuffers :: #force_inline proc(self: ^RenderCommandEncoder, buffers: []^Buffer, offsets: []NS.UInteger, range: NS.Range) { +RenderCommandEncoder_setTileBuffers :: #force_inline proc "c" (self: ^RenderCommandEncoder, buffers: []^Buffer, offsets: []NS.UInteger, range: NS.Range) { msgSend(nil, self, "setTileBuffers:offsets:withRange:", raw_data(buffers), raw_data(offsets), range) } @(objc_type=RenderCommandEncoder, objc_name="setTileBytes") -RenderCommandEncoder_setTileBytes :: #force_inline proc(self: ^RenderCommandEncoder, bytes: []byte, index: NS.UInteger) { +RenderCommandEncoder_setTileBytes :: #force_inline proc "c" (self: ^RenderCommandEncoder, bytes: []byte, index: NS.UInteger) { msgSend(nil, self, "setTileBytes:length:atIndex:", raw_data(bytes), NS.UInteger(len(bytes)), index) } @(objc_type=RenderCommandEncoder, objc_name="setTileSamplerState") -RenderCommandEncoder_setTileSamplerState :: #force_inline proc(self: ^RenderCommandEncoder, sampler: ^SamplerState, index: NS.UInteger) { +RenderCommandEncoder_setTileSamplerState :: #force_inline proc "c" (self: ^RenderCommandEncoder, sampler: ^SamplerState, index: NS.UInteger) { msgSend(nil, self, "setTileSamplerState:atIndex:", sampler, index) } @(objc_type=RenderCommandEncoder, objc_name="setTileSamplerStateWithLod") -RenderCommandEncoder_setTileSamplerStateWithLod :: #force_inline proc(self: ^RenderCommandEncoder, sampler: ^SamplerState, lodMinClamp: f32, lodMaxClamp: f32, index: NS.UInteger) { +RenderCommandEncoder_setTileSamplerStateWithLod :: #force_inline proc "c" (self: ^RenderCommandEncoder, sampler: ^SamplerState, lodMinClamp: f32, lodMaxClamp: f32, index: NS.UInteger) { msgSend(nil, self, "setTileSamplerState:lodMinClamp:lodMaxClamp:atIndex:", sampler, lodMinClamp, lodMaxClamp, index) } @(objc_type=RenderCommandEncoder, objc_name="setTileSamplerStatesWithLod") -RenderCommandEncoder_setTileSamplerStatesWithLod :: #force_inline proc(self: ^RenderCommandEncoder, samplers: []^SamplerState, lodMinClamps, lodMaxClamps: []f32, range: NS.Range) { +RenderCommandEncoder_setTileSamplerStatesWithLod :: #force_inline proc "c" (self: ^RenderCommandEncoder, samplers: []^SamplerState, lodMinClamps, lodMaxClamps: []f32, range: NS.Range) { msgSend(nil, self, "setTileSamplerStates:lodMinClamps:lodMaxClamps:withRange:", raw_data(samplers), raw_data(lodMinClamps), raw_data(lodMaxClamps), range) } @(objc_type=RenderCommandEncoder, objc_name="setTileSamplerStatesWithRange") -RenderCommandEncoder_setTileSamplerStatesWithRange :: #force_inline proc(self: ^RenderCommandEncoder, samplers: []^SamplerState, range: NS.Range) { +RenderCommandEncoder_setTileSamplerStatesWithRange :: #force_inline proc "c" (self: ^RenderCommandEncoder, samplers: []^SamplerState, range: NS.Range) { msgSend(nil, self, "setTileSamplerStates:withRange:", raw_data(samplers), range) } @(objc_type=RenderCommandEncoder, objc_name="setTileTexture") -RenderCommandEncoder_setTileTexture :: #force_inline proc(self: ^RenderCommandEncoder, texture: ^Texture, index: NS.UInteger) { +RenderCommandEncoder_setTileTexture :: #force_inline proc "c" (self: ^RenderCommandEncoder, texture: ^Texture, index: NS.UInteger) { msgSend(nil, self, "setTileTexture:atIndex:", texture, index) } @(objc_type=RenderCommandEncoder, objc_name="setTileTextures") -RenderCommandEncoder_setTileTextures :: #force_inline proc(self: ^RenderCommandEncoder, textures: []^Texture, range: NS.Range) { +RenderCommandEncoder_setTileTextures :: #force_inline proc "c" (self: ^RenderCommandEncoder, textures: []^Texture, range: NS.Range) { msgSend(nil, self, "setTileTextures:withRange:", raw_data(textures), range) } @(objc_type=RenderCommandEncoder, objc_name="setTriangleFillMode") -RenderCommandEncoder_setTriangleFillMode :: #force_inline proc(self: ^RenderCommandEncoder, fillMode: TriangleFillMode) { +RenderCommandEncoder_setTriangleFillMode :: #force_inline proc "c" (self: ^RenderCommandEncoder, fillMode: TriangleFillMode) { msgSend(nil, self, "setTriangleFillMode:", fillMode) } @(objc_type=RenderCommandEncoder, objc_name="setVertexAmplificationCount") -RenderCommandEncoder_setVertexAmplificationCount :: #force_inline proc(self: ^RenderCommandEncoder, viewMappings: []VertexAmplificationViewMapping) { +RenderCommandEncoder_setVertexAmplificationCount :: #force_inline proc "c" (self: ^RenderCommandEncoder, viewMappings: []VertexAmplificationViewMapping) { msgSend(nil, self, "setVertexAmplificationCount:viewMappings:", NS.UInteger(len(viewMappings)), raw_data(viewMappings)) } @(objc_type=RenderCommandEncoder, objc_name="setVertexBuffer") -RenderCommandEncoder_setVertexBuffer :: #force_inline proc(self: ^RenderCommandEncoder, buffer: ^Buffer, offset: NS.UInteger, index: NS.UInteger) { +RenderCommandEncoder_setVertexBuffer :: #force_inline proc "c" (self: ^RenderCommandEncoder, buffer: ^Buffer, offset: NS.UInteger, index: NS.UInteger) { msgSend(nil, self, "setVertexBuffer:offset:atIndex:", buffer, offset, index) } @(objc_type=RenderCommandEncoder, objc_name="setVertexBufferOffset") -RenderCommandEncoder_setVertexBufferOffset :: #force_inline proc(self: ^RenderCommandEncoder, offset: NS.UInteger, index: NS.UInteger) { +RenderCommandEncoder_setVertexBufferOffset :: #force_inline proc "c" (self: ^RenderCommandEncoder, offset: NS.UInteger, index: NS.UInteger) { msgSend(nil, self, "setVertexBufferOffset:atIndex:", offset, index) } @(objc_type=RenderCommandEncoder, objc_name="setVertexBuffers") -RenderCommandEncoder_setVertexBuffers :: #force_inline proc(self: ^RenderCommandEncoder, buffers: []^Buffer, offsets: []NS.UInteger, range: NS.Range) { +RenderCommandEncoder_setVertexBuffers :: #force_inline proc "c" (self: ^RenderCommandEncoder, buffers: []^Buffer, offsets: []NS.UInteger, range: NS.Range) { msgSend(nil, self, "setVertexBuffers:offsets:withRange:", raw_data(buffers), raw_data(offsets), range) } @(objc_type=RenderCommandEncoder, objc_name="setVertexBytes") -RenderCommandEncoder_setVertexBytes :: #force_inline proc(self: ^RenderCommandEncoder, bytes: []byte, index: NS.UInteger) { +RenderCommandEncoder_setVertexBytes :: #force_inline proc "c" (self: ^RenderCommandEncoder, bytes: []byte, index: NS.UInteger) { msgSend(nil, self, "setVertexBytes:length:atIndex:", raw_data(bytes), NS.UInteger(len(bytes)), index) } @(objc_type=RenderCommandEncoder, objc_name="setVertexSamplerState") -RenderCommandEncoder_setVertexSamplerState :: #force_inline proc(self: ^RenderCommandEncoder, sampler: ^SamplerState, index: NS.UInteger) { +RenderCommandEncoder_setVertexSamplerState :: #force_inline proc "c" (self: ^RenderCommandEncoder, sampler: ^SamplerState, index: NS.UInteger) { msgSend(nil, self, "setVertexSamplerState:atIndex:", sampler, index) } @(objc_type=RenderCommandEncoder, objc_name="setVertexSamplerStateWithLod") -RenderCommandEncoder_setVertexSamplerStateWithLod :: #force_inline proc(self: ^RenderCommandEncoder, sampler: ^SamplerState, lodMinClamp: f32, lodMaxClamp: f32, index: NS.UInteger) { +RenderCommandEncoder_setVertexSamplerStateWithLod :: #force_inline proc "c" (self: ^RenderCommandEncoder, sampler: ^SamplerState, lodMinClamp: f32, lodMaxClamp: f32, index: NS.UInteger) { msgSend(nil, self, "setVertexSamplerState:lodMinClamp:lodMaxClamp:atIndex:", sampler, lodMinClamp, lodMaxClamp, index) } @(objc_type=RenderCommandEncoder, objc_name="setVertexSamplerStatesWithLod") -RenderCommandEncoder_setVertexSamplerStatesWithLod :: #force_inline proc(self: ^RenderCommandEncoder, samplers: []^SamplerState, lodMinClamps, lodMaxClamps: []f32, range: NS.Range) { +RenderCommandEncoder_setVertexSamplerStatesWithLod :: #force_inline proc "c" (self: ^RenderCommandEncoder, samplers: []^SamplerState, lodMinClamps, lodMaxClamps: []f32, range: NS.Range) { msgSend(nil, self, "setVertexSamplerStates:lodMinClamps:lodMaxClamps:withRange:", raw_data(samplers), raw_data(lodMinClamps), raw_data(lodMaxClamps), range) } @(objc_type=RenderCommandEncoder, objc_name="setVertexSamplerStatesWithRange") -RenderCommandEncoder_setVertexSamplerStatesWithRange :: #force_inline proc(self: ^RenderCommandEncoder, samplers: []^SamplerState, range: NS.Range) { +RenderCommandEncoder_setVertexSamplerStatesWithRange :: #force_inline proc "c" (self: ^RenderCommandEncoder, samplers: []^SamplerState, range: NS.Range) { msgSend(nil, self, "setVertexSamplerStates:withRange:", raw_data(samplers), range) } @(objc_type=RenderCommandEncoder, objc_name="setVertexTexture") -RenderCommandEncoder_setVertexTexture :: #force_inline proc(self: ^RenderCommandEncoder, texture: ^Texture, index: NS.UInteger) { +RenderCommandEncoder_setVertexTexture :: #force_inline proc "c" (self: ^RenderCommandEncoder, texture: ^Texture, index: NS.UInteger) { msgSend(nil, self, "setVertexTexture:atIndex:", texture, index) } @(objc_type=RenderCommandEncoder, objc_name="setVertexTextures") -RenderCommandEncoder_setVertexTextures :: #force_inline proc(self: ^RenderCommandEncoder, textures: []^Texture, range: NS.Range) { +RenderCommandEncoder_setVertexTextures :: #force_inline proc "c" (self: ^RenderCommandEncoder, textures: []^Texture, range: NS.Range) { msgSend(nil, self, "setVertexTextures:withRange:", raw_data(textures), range) } @(objc_type=RenderCommandEncoder, objc_name="setViewport") -RenderCommandEncoder_setViewport :: #force_inline proc(self: ^RenderCommandEncoder, viewport: Viewport) { +RenderCommandEncoder_setViewport :: #force_inline proc "c" (self: ^RenderCommandEncoder, viewport: Viewport) { msgSend(nil, self, "setViewport:", viewport) } @(objc_type=RenderCommandEncoder, objc_name="setViewports") -RenderCommandEncoder_setViewports :: #force_inline proc(self: ^RenderCommandEncoder, viewports: []Viewport) { +RenderCommandEncoder_setViewports :: #force_inline proc "c" (self: ^RenderCommandEncoder, viewports: []Viewport) { msgSend(nil, self, "setViewports:count:", raw_data(viewports), NS.UInteger(len(viewports))) } @(objc_type=RenderCommandEncoder, objc_name="setVisibilityResultMode") -RenderCommandEncoder_setVisibilityResultMode :: #force_inline proc(self: ^RenderCommandEncoder, mode: VisibilityResultMode, offset: NS.UInteger) { +RenderCommandEncoder_setVisibilityResultMode :: #force_inline proc "c" (self: ^RenderCommandEncoder, mode: VisibilityResultMode, offset: NS.UInteger) { msgSend(nil, self, "setVisibilityResultMode:offset:", mode, offset) } @(objc_type=RenderCommandEncoder, objc_name="textureBarrier") -RenderCommandEncoder_textureBarrier :: #force_inline proc(self: ^RenderCommandEncoder) { +RenderCommandEncoder_textureBarrier :: #force_inline proc "c" (self: ^RenderCommandEncoder) { msgSend(nil, self, "textureBarrier") } @(objc_type=RenderCommandEncoder, objc_name="tileHeight") -RenderCommandEncoder_tileHeight :: #force_inline proc(self: ^RenderCommandEncoder) -> NS.UInteger { +RenderCommandEncoder_tileHeight :: #force_inline proc "c" (self: ^RenderCommandEncoder) -> NS.UInteger { return msgSend(NS.UInteger, self, "tileHeight") } @(objc_type=RenderCommandEncoder, objc_name="tileWidth") -RenderCommandEncoder_tileWidth :: #force_inline proc(self: ^RenderCommandEncoder) -> NS.UInteger { +RenderCommandEncoder_tileWidth :: #force_inline proc "c" (self: ^RenderCommandEncoder) -> NS.UInteger { return msgSend(NS.UInteger, self, "tileWidth") } @(objc_type=RenderCommandEncoder, objc_name="updateFence") -RenderCommandEncoder_updateFence :: #force_inline proc(self: ^RenderCommandEncoder, fence: ^Fence, stages: RenderStages) { +RenderCommandEncoder_updateFence :: #force_inline proc "c" (self: ^RenderCommandEncoder, fence: ^Fence, stages: RenderStages) { msgSend(nil, self, "updateFence:afterStages:", fence, stages) } @(objc_type=RenderCommandEncoder, objc_name="useHeap") -RenderCommandEncoder_useHeap :: #force_inline proc(self: ^RenderCommandEncoder, heap: ^Heap) { +RenderCommandEncoder_useHeap :: #force_inline proc "c" (self: ^RenderCommandEncoder, heap: ^Heap) { msgSend(nil, self, "useHeap:", heap) } @(objc_type=RenderCommandEncoder, objc_name="useHeapWithStages") -RenderCommandEncoder_useHeapWithStages :: #force_inline proc(self: ^RenderCommandEncoder, heap: ^Heap, stages: RenderStages) { +RenderCommandEncoder_useHeapWithStages :: #force_inline proc "c" (self: ^RenderCommandEncoder, heap: ^Heap, stages: RenderStages) { msgSend(nil, self, "useHeap:stages:", heap, stages) } @(objc_type=RenderCommandEncoder, objc_name="useHeaps") -RenderCommandEncoder_useHeaps :: #force_inline proc(self: ^RenderCommandEncoder, heaps: []^Heap) { +RenderCommandEncoder_useHeaps :: #force_inline proc "c" (self: ^RenderCommandEncoder, heaps: []^Heap) { msgSend(nil, self, "useHeaps:count:", raw_data(heaps), NS.UInteger(len(heaps))) } @(objc_type=RenderCommandEncoder, objc_name="useHeapsWithStages") -RenderCommandEncoder_useHeapsWithStages :: #force_inline proc(self: ^RenderCommandEncoder, heaps: []^Heap, stages: RenderStages) { +RenderCommandEncoder_useHeapsWithStages :: #force_inline proc "c" (self: ^RenderCommandEncoder, heaps: []^Heap, stages: RenderStages) { msgSend(nil, self, "useHeaps:count:stages:", raw_data(heaps), NS.UInteger(len(heaps)), stages) } @(objc_type=RenderCommandEncoder, objc_name="useResource") -RenderCommandEncoder_useResource :: #force_inline proc(self: ^RenderCommandEncoder, resource: ^Resource, usage: ResourceUsage) { +RenderCommandEncoder_useResource :: #force_inline proc "c" (self: ^RenderCommandEncoder, resource: ^Resource, usage: ResourceUsage) { msgSend(nil, self, "useResource:usage:", resource, usage) } @(objc_type=RenderCommandEncoder, objc_name="useResourceWithStages") -RenderCommandEncoder_useResourceWithStages :: #force_inline proc(self: ^RenderCommandEncoder, resource: ^Resource, usage: ResourceUsage, stages: RenderStages) { +RenderCommandEncoder_useResourceWithStages :: #force_inline proc "c" (self: ^RenderCommandEncoder, resource: ^Resource, usage: ResourceUsage, stages: RenderStages) { msgSend(nil, self, "useResource:usage:stages:", resource, usage, stages) } @(objc_type=RenderCommandEncoder, objc_name="useResources") -RenderCommandEncoder_useResources :: #force_inline proc(self: ^RenderCommandEncoder, resources: []^Resource, usage: ResourceUsage) { +RenderCommandEncoder_useResources :: #force_inline proc "c" (self: ^RenderCommandEncoder, resources: []^Resource, usage: ResourceUsage) { msgSend(nil, self, "useResources:count:usage:", raw_data(resources), NS.UInteger(len(resources)), usage) } @(objc_type=RenderCommandEncoder, objc_name="useResourcesStages") -RenderCommandEncoder_useResourcesStages :: #force_inline proc(self: ^RenderCommandEncoder, resources: []^Resource, usage: ResourceUsage, stages: RenderStages) { +RenderCommandEncoder_useResourcesStages :: #force_inline proc "c" (self: ^RenderCommandEncoder, resources: []^Resource, usage: ResourceUsage, stages: RenderStages) { msgSend(nil, self, "useResources:count:usage:stages:", raw_data(resources), NS.UInteger(len(resources)), usage, stages) } @(objc_type=RenderCommandEncoder, objc_name="waitForFence") -RenderCommandEncoder_waitForFence :: #force_inline proc(self: ^RenderCommandEncoder, fence: ^Fence, stages: RenderStages) { +RenderCommandEncoder_waitForFence :: #force_inline proc "c" (self: ^RenderCommandEncoder, fence: ^Fence, stages: RenderStages) { msgSend(nil, self, "waitForFence:beforeStages:", fence, stages) } +@(objc_type=RenderCommandEncoder, objc_name="setObjectBytes") +RenderCommandEncoder_setObjectBytes :: #force_inline proc "c" (self: ^RenderCommandEncoder, bytes: rawptr, length: NS.UInteger, index: NS.UInteger) { + msgSend(nil, self, "setObjectBytes:length:atIndex:", bytes, length, index) +} +@(objc_type=RenderCommandEncoder, objc_name="setObjectBuffer") +RenderCommandEncoder_setObjectBuffer :: #force_inline proc "c" (self: ^RenderCommandEncoder, buffer: ^Buffer, offset: NS.UInteger, index: NS.UInteger) { + msgSend(nil, self, "setObjectBuffer:offset:atIndex:", buffer, offset, index) +} +@(objc_type=RenderCommandEncoder, objc_name="setObjectBufferOffset") +RenderCommandEncoder_setObjectBufferOffset :: #force_inline proc "c" (self: ^RenderCommandEncoder, offset: NS.UInteger, index: NS.UInteger) { + msgSend(nil, self, "setObjectBufferOffset:atIndex:", offset, index) +} +@(objc_type=RenderCommandEncoder, objc_name="setObjectBuffers") +RenderCommandEncoder_setObjectBuffers :: #force_inline proc "c" (self: ^RenderCommandEncoder, buffers: [^]^Buffer, offsets: [^]NS.UInteger, range: NS.Range) { + msgSend(nil, self, "setObjectBuffers:offsets:withRange:", buffers, offsets, range) +} +@(objc_type=RenderCommandEncoder, objc_name="setObjectTexture") +RenderCommandEncoder_setObjectTexture :: #force_inline proc "c" (self: ^RenderCommandEncoder, texture: ^Texture, index: NS.UInteger) { + msgSend(nil, self, "setObjectTexture:atIndex:", texture, index) +} +@(objc_type=RenderCommandEncoder, objc_name="setObjectTextures") +RenderCommandEncoder_setObjectTextures :: #force_inline proc "c" (self: ^RenderCommandEncoder, textures: [^]^Texture, range: NS.Range) { + msgSend(nil, self, "setObjectTextures:withRange:", textures, range) +} +@(objc_type=RenderCommandEncoder, objc_name="setObjectSamplerState") +RenderCommandEncoder_setObjectSamplerState :: #force_inline proc "c" (self: ^RenderCommandEncoder, sampler: ^SamplerState, index: NS.UInteger) { + msgSend(nil, self, "setObjectSamplerState:atIndex:", sampler, index) +} +@(objc_type=RenderCommandEncoder, objc_name="setObjectSamplerStates") +RenderCommandEncoder_setObjectSamplerStates :: #force_inline proc "c" (self: ^RenderCommandEncoder, samplers: [^]^SamplerState, range: NS.Range) { + msgSend(nil, self, "setObjectSamplerStates:withRange:", samplers, range) +} +@(objc_type=RenderCommandEncoder, objc_name="setObjectSamplerStateWithLod") +RenderCommandEncoder_setObjectSamplerStateWithLod :: #force_inline proc "c" (self: ^RenderCommandEncoder, sampler: ^SamplerState, lodMinClamp, lodMaxClamp: f32, index: NS.UInteger) { + msgSend(nil, self, "setObjectSamplerState:lodMinClamp:lodMaxClamp:atIndex:", sampler, lodMinClamp, lodMaxClamp, index) +} +@(objc_type=RenderCommandEncoder, objc_name="setObjectSamplerStatesWithLod") +RenderCommandEncoder_setObjectSamplerStatesWithLod :: #force_inline proc "c" (self: ^RenderCommandEncoder, samplers: [^]^SamplerState, lodMinClamps, lodMaxClamps: [^]f32, range: NS.Range) { + msgSend(nil, self, "setObjectSamplerStates:lodMinClamps:lodMaxClamps:withRange:", samplers, lodMinClamps, lodMaxClamps, range) +} + +@(objc_type=RenderCommandEncoder, objc_name="setObjectThreadgroupMemoryLength") +RenderCommandEncoder_setObjectThreadgroupMemoryLength :: #force_inline proc "c" (self: ^RenderCommandEncoder, length: NS.UInteger, index: NS.UInteger) { + msgSend(nil, self, "setObjectThreadgroupMemoryLength:atIndex:", length, index) +} + +@(objc_type=RenderCommandEncoder, objc_name="setMeshBytes") +RenderCommandEncoder_setMeshBytes :: #force_inline proc "c" (self: ^RenderCommandEncoder, bytes: rawptr, length: NS.UInteger, index: NS.UInteger) { + msgSend(nil, self, "setMeshBytes:atIndex:", bytes, length, index) +} +@(objc_type=RenderCommandEncoder, objc_name="setMeshBuffer") +RenderCommandEncoder_setMeshBuffer :: #force_inline proc "c" (self: ^RenderCommandEncoder, buffer: ^Buffer, offset: NS.UInteger, index: NS.UInteger) { + msgSend(nil, self, "setMeshBuffer:offset:atIndex:", buffer, offset, index) +} +@(objc_type=RenderCommandEncoder, objc_name="setMeshBufferOffset") +RenderCommandEncoder_setMeshBufferOffset :: #force_inline proc "c" (self: ^RenderCommandEncoder, offset: NS.UInteger, index: NS.UInteger) { + msgSend(nil, self, "setMeshBufferOffset:atIndex:", offset, index) +} +@(objc_type=RenderCommandEncoder, objc_name="setMeshBuffers") +RenderCommandEncoder_setMeshBuffers :: #force_inline proc "c" (self: ^RenderCommandEncoder, buffers: [^]^Buffer, offsets: [^]NS.UInteger, range: NS.Range) { + msgSend(nil, self, "setMeshBuffers:offsets:withRange:", buffers, offsets, range) +} +@(objc_type=RenderCommandEncoder, objc_name="setMeshTexture") +RenderCommandEncoder_setMeshTexture :: #force_inline proc "c" (self: ^RenderCommandEncoder, texture: ^Texture, index: NS.UInteger) { + msgSend(nil, self, "setMeshTexture:atIndex:", texture, index) +} +@(objc_type=RenderCommandEncoder, objc_name="setMeshTextures") +RenderCommandEncoder_setMeshTextures :: #force_inline proc "c" (self: ^RenderCommandEncoder, textures: [^]^Texture, range: NS.Range) { + msgSend(nil, self, "setMeshTextures:withRange:", textures, range) +} +@(objc_type=RenderCommandEncoder, objc_name="setMeshSamplerState") +RenderCommandEncoder_setMeshSamplerState :: #force_inline proc "c" (self: ^RenderCommandEncoder, sampler: ^SamplerState, index: NS.UInteger) { + msgSend(nil, self, "setMeshSamplerState:atIndex:", sampler, index) +} +@(objc_type=RenderCommandEncoder, objc_name="setMeshSamplerStates") +RenderCommandEncoder_setMeshSamplerStates :: #force_inline proc "c" (self: ^RenderCommandEncoder, samplers: [^]^SamplerState, range: NS.Range) { + msgSend(nil, self, "setMeshSamplerStates:withRange:", samplers, range) +} +@(objc_type=RenderCommandEncoder, objc_name="setMeshSamplerStateWithLod") +RenderCommandEncoder_setMeshSamplerStateWithLod :: #force_inline proc "c" (self: ^RenderCommandEncoder, sampler: ^SamplerState, lodMinClamp, lodMaxClamp: f32, index: NS.UInteger) { + msgSend(nil, self, "setMeshSamplerState:lodMinClamp:lodMaxClamp:atIndex:", sampler, lodMinClamp, lodMaxClamp, index) +} +@(objc_type=RenderCommandEncoder, objc_name="setMeshSamplerStatesWithLod") +RenderCommandEncoder_setMeshSamplerStatesWithLod :: #force_inline proc "c" (self: ^RenderCommandEncoder, samplers: [^]^SamplerState, lodMinClamps, lodMaxClamps: [^]f32, range: NS.Range) { + msgSend(nil, self, "setMeshSamplerStates:lodMinClamps:lodMaxClamps:withRange:", samplers, lodMinClamps, lodMaxClamps, range) +} + +@(objc_type=RenderCommandEncoder, objc_name="drawMeshThreadgroups") +RenderCommandEncoder_drawMeshThreadgroups :: #force_inline proc "c" (self: ^RenderCommandEncoder, threadgroupsPerGrid, threadPerObjectThreadgroup, threadsPerMeshThreadgroup: Size) { + msgSend(nil, self, "drawMeshThreadgroups:threadsPerObjectThreadgroup:threadsPerMeshThreadgroup:", threadgroupsPerGrid, threadPerObjectThreadgroup, threadsPerMeshThreadgroup) +} +@(objc_type=RenderCommandEncoder, objc_name="drawMeshThreads") +RenderCommandEncoder_drawMeshThreads :: #force_inline proc "c" (self: ^RenderCommandEncoder, threadsPerGrid, threadPerObjectThreadgroup, threadsPerMeshThreadgroup: Size) { + msgSend(nil, self, "drawMeshThreads:threadsPerObjectThreadgroup:threadsPerMeshThreadgroup:", threadsPerGrid, threadPerObjectThreadgroup, threadsPerMeshThreadgroup) +} +@(objc_type=RenderCommandEncoder, objc_name="drawMeshThreadgroupsWithIndirectBuffer") +RenderCommandEncoder_drawMeshThreadgroupsWithIndirectBuffer :: #force_inline proc "c" (self: ^RenderCommandEncoder, indirectBuffer: ^Buffer, indirectBufferOffset, threadPerObjectThreadgroup, threadsPerMeshThreadgroup: Size) { + msgSend(nil, self, "drawMeshThreadgroupsWithIndirectBuffer:indirectBufferOffset:threadsPerObjectThreadgroup:threadsPerMeshThreadgroup:", indirectBuffer, indirectBufferOffset, threadPerObjectThreadgroup, threadsPerMeshThreadgroup) +} + + + //////////////////////////////////////////////////////////////////////////////// -/* -Class: - RenderPipelineFunctionsDescriptor -*/ @(objc_class="MTLRenderPipelineFunctionsDescriptor") RenderPipelineFunctionsDescriptor :: struct { using _: NS.Copying(RenderPipelineFunctionsDescriptor) } @(objc_type=RenderPipelineFunctionsDescriptor, objc_name="alloc", objc_is_class_method=true) -RenderPipelineFunctionsDescriptor_alloc :: #force_inline proc() -> ^RenderPipelineFunctionsDescriptor { +RenderPipelineFunctionsDescriptor_alloc :: #force_inline proc "c" () -> ^RenderPipelineFunctionsDescriptor { return msgSend(^RenderPipelineFunctionsDescriptor, RenderPipelineFunctionsDescriptor, "alloc") } @(objc_type=RenderPipelineFunctionsDescriptor, objc_name="init") -RenderPipelineFunctionsDescriptor_init :: #force_inline proc(self: ^RenderPipelineFunctionsDescriptor) -> ^RenderPipelineFunctionsDescriptor { +RenderPipelineFunctionsDescriptor_init :: #force_inline proc "c" (self: ^RenderPipelineFunctionsDescriptor) -> ^RenderPipelineFunctionsDescriptor { return msgSend(^RenderPipelineFunctionsDescriptor, self, "init") } @(objc_type=RenderPipelineFunctionsDescriptor, objc_name="vertexAdditionalBinaryFunctions") -RenderPipelineFunctionsDescriptor_vertexAdditionalBinaryFunctions :: #force_inline proc(self: ^RenderPipelineFunctionsDescriptor) -> ^NS.Array { +RenderPipelineFunctionsDescriptor_vertexAdditionalBinaryFunctions :: #force_inline proc "c" (self: ^RenderPipelineFunctionsDescriptor) -> ^NS.Array { return msgSend(^NS.Array, self, "vertexAdditionalBinaryFunctions") } @(objc_type=RenderPipelineFunctionsDescriptor, objc_name="fragmentAdditionalBinaryFunctions") -RenderPipelineFunctionsDescriptor_fragmentAdditionalBinaryFunctions :: #force_inline proc(self: ^RenderPipelineFunctionsDescriptor) -> ^NS.Array { +RenderPipelineFunctionsDescriptor_fragmentAdditionalBinaryFunctions :: #force_inline proc "c" (self: ^RenderPipelineFunctionsDescriptor) -> ^NS.Array { return msgSend(^NS.Array, self, "fragmentAdditionalBinaryFunctions") } @(objc_type=RenderPipelineFunctionsDescriptor, objc_name="tileAdditionalBinaryFunctions") -RenderPipelineFunctionsDescriptor_tileAdditionalBinaryFunctions :: #force_inline proc(self: ^RenderPipelineFunctionsDescriptor) -> ^NS.Array { +RenderPipelineFunctionsDescriptor_tileAdditionalBinaryFunctions :: #force_inline proc "c" (self: ^RenderPipelineFunctionsDescriptor) -> ^NS.Array { return msgSend(^NS.Array, self, "tileAdditionalBinaryFunctions") } @(objc_type=RenderPipelineFunctionsDescriptor, objc_name="setVertexAdditionalBinaryFunctions") -RenderPipelineFunctionsDescriptor_setVertexAdditionalBinaryFunctions :: #force_inline proc(self: ^RenderPipelineFunctionsDescriptor, binaryFunctions: ^NS.Array) { +RenderPipelineFunctionsDescriptor_setVertexAdditionalBinaryFunctions :: #force_inline proc "c" (self: ^RenderPipelineFunctionsDescriptor, binaryFunctions: ^NS.Array) { msgSend(nil, self, "setVertexAdditionalBinaryFunctions:", binaryFunctions) } @(objc_type=RenderPipelineFunctionsDescriptor, objc_name="setFragmentAdditionalBinaryFunctions") -RenderPipelineFunctionsDescriptor_setFragmentAdditionalBinaryFunctions :: #force_inline proc(self: ^RenderPipelineFunctionsDescriptor, binaryFunctions: ^NS.Array) { +RenderPipelineFunctionsDescriptor_setFragmentAdditionalBinaryFunctions :: #force_inline proc "c" (self: ^RenderPipelineFunctionsDescriptor, binaryFunctions: ^NS.Array) { msgSend(nil, self, "setFragmentAdditionalBinaryFunctions:", binaryFunctions) } @(objc_type=RenderPipelineFunctionsDescriptor, objc_name="setTileAdditionalBinaryFunctions") -RenderPipelineFunctionsDescriptor_setTileAdditionalBinaryFunctions :: #force_inline proc(self: ^RenderPipelineFunctionsDescriptor, binaryFunctions: ^NS.Array) { +RenderPipelineFunctionsDescriptor_setTileAdditionalBinaryFunctions :: #force_inline proc "c" (self: ^RenderPipelineFunctionsDescriptor, binaryFunctions: ^NS.Array) { msgSend(nil, self, "tileAdditionalBinaryFunctions:", binaryFunctions) } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - RenderPipelineState -Class Methods: -Methods: - device - imageblockMemoryLengthForDimensions - imageblockSampleLength - label - maxTotalThreadsPerThreadgroup - supportIndirectCommandBuffers - threadgroupSizeMatchesTileSize -*/ @(objc_class="MTLRenderPipelineState") RenderPipelineState :: struct { using _: NS.Object } @(objc_type=RenderPipelineState, objc_name="device") -RenderPipelineState_device :: #force_inline proc(self: ^RenderPipelineState) -> ^Device { +RenderPipelineState_device :: #force_inline proc "c" (self: ^RenderPipelineState) -> ^Device { return msgSend(^Device, self, "device") } @(objc_type=RenderPipelineState, objc_name="imageblockMemoryLengthForDimensions") -RenderPipelineState_imageblockMemoryLengthForDimensions :: #force_inline proc(self: ^RenderPipelineState, imageblockDimensions: Size) -> NS.UInteger { +RenderPipelineState_imageblockMemoryLengthForDimensions :: #force_inline proc "c" (self: ^RenderPipelineState, imageblockDimensions: Size) -> NS.UInteger { return msgSend(NS.UInteger, self, "imageblockMemoryLengthForDimensions:", imageblockDimensions) } @(objc_type=RenderPipelineState, objc_name="imageblockSampleLength") -RenderPipelineState_imageblockSampleLength :: #force_inline proc(self: ^RenderPipelineState) -> NS.UInteger { +RenderPipelineState_imageblockSampleLength :: #force_inline proc "c" (self: ^RenderPipelineState) -> NS.UInteger { return msgSend(NS.UInteger, self, "imageblockSampleLength") } @(objc_type=RenderPipelineState, objc_name="label") -RenderPipelineState_label :: #force_inline proc(self: ^RenderPipelineState) -> ^NS.String { +RenderPipelineState_label :: #force_inline proc "c" (self: ^RenderPipelineState) -> ^NS.String { return msgSend(^NS.String, self, "label") } @(objc_type=RenderPipelineState, objc_name="maxTotalThreadsPerThreadgroup") -RenderPipelineState_maxTotalThreadsPerThreadgroup :: #force_inline proc(self: ^RenderPipelineState) -> NS.UInteger { +RenderPipelineState_maxTotalThreadsPerThreadgroup :: #force_inline proc "c" (self: ^RenderPipelineState) -> NS.UInteger { return msgSend(NS.UInteger, self, "maxTotalThreadsPerThreadgroup") } @(objc_type=RenderPipelineState, objc_name="supportIndirectCommandBuffers") -RenderPipelineState_supportIndirectCommandBuffers :: #force_inline proc(self: ^RenderPipelineState) -> BOOL { +RenderPipelineState_supportIndirectCommandBuffers :: #force_inline proc "c" (self: ^RenderPipelineState) -> BOOL { return msgSend(BOOL, self, "supportIndirectCommandBuffers") } @(objc_type=RenderPipelineState, objc_name="threadgroupSizeMatchesTileSize") -RenderPipelineState_threadgroupSizeMatchesTileSize :: #force_inline proc(self: ^RenderPipelineState) -> BOOL { +RenderPipelineState_threadgroupSizeMatchesTileSize :: #force_inline proc "c" (self: ^RenderPipelineState) -> BOOL { return msgSend(BOOL, self, "threadgroupSizeMatchesTileSize") } @(objc_type=RenderPipelineState, objc_name="functionHandle") -RenderPipelineState_functionHandle :: #force_inline proc(self: ^RenderPipelineState, function: ^Function, stage: RenderStages) -> ^FunctionHandle { +RenderPipelineState_functionHandle :: #force_inline proc "c" (self: ^RenderPipelineState, function: ^Function, stage: RenderStages) -> ^FunctionHandle { return msgSend(^FunctionHandle, self, "functionHandleWithFunction:stage:", function, stage) } @(objc_type=RenderPipelineState, objc_name="newVisibleFunctionTable") -RenderPipelineState_newVisibleFunctionTable :: #force_inline proc(self: ^RenderPipelineState, descriptor: ^VisibleFunctionTableDescriptor, stage: RenderStages) -> ^VisibleFunctionTable { +RenderPipelineState_newVisibleFunctionTable :: #force_inline proc "c" (self: ^RenderPipelineState, descriptor: ^VisibleFunctionTableDescriptor, stage: RenderStages) -> ^VisibleFunctionTable { return msgSend(^VisibleFunctionTable, self, "newVisibleFunctionTableWithDescriptor:stage:", descriptor, stage) } @(objc_type=RenderPipelineState, objc_name="newIntersectionFunctionTable") -RenderPipelineState_newIntersectionFunctionTable :: #force_inline proc(self: ^RenderPipelineState, descriptor: ^IntersectionFunctionTableDescriptor, stage: RenderStages) -> ^IntersectionFunctionTable { +RenderPipelineState_newIntersectionFunctionTable :: #force_inline proc "c" (self: ^RenderPipelineState, descriptor: ^IntersectionFunctionTableDescriptor, stage: RenderStages) -> ^IntersectionFunctionTable { return msgSend(^IntersectionFunctionTable, self, "newIntersectionFunctionTable:stage:", descriptor, stage) } @(objc_type=RenderPipelineState, objc_name="newRenderPipelineState") -RenderPipelineState_newRenderPipelineState :: #force_inline proc(self: ^RenderPipelineState, additionalBinaryFunctions: ^RenderPipelineFunctionsDescriptor) -> (state: ^RenderPipelineState, error: ^NS.Error) { +RenderPipelineState_newRenderPipelineState :: #force_inline proc "contextless" (self: ^RenderPipelineState, additionalBinaryFunctions: ^RenderPipelineFunctionsDescriptor) -> (state: ^RenderPipelineState, error: ^NS.Error) { state = msgSend(^RenderPipelineState, self, "newRenderPipelineStateWithAdditionalBinaryFunctions:error:", additionalBinaryFunctions, &error) return } + +@(objc_type=RenderPipelineState, objc_name="maxTotalThreadsPerObjectThreadgroup") +RenderPipelineState_maxTotalThreadsPerObjectThreadgroup :: #force_inline proc "c" (self: ^RenderPipelineState) -> NS.UInteger { + return msgSend(NS.UInteger, self, "maxTotalThreadsPerObjectThreadgroup") +} +@(objc_type=RenderPipelineState, objc_name="maxTotalThreadsPerMeshThreadgroup") +RenderPipelineState_maxTotalThreadsPerMeshThreadgroup :: #force_inline proc "c" (self: ^RenderPipelineState) -> NS.UInteger { + return msgSend(NS.UInteger, self, "maxTotalThreadsPerMeshThreadgroup") +} +@(objc_type=RenderPipelineState, objc_name="objectThreadExecutionWidth") +RenderPipelineState_objectThreadExecutionWidth :: #force_inline proc "c" (self: ^RenderPipelineState) -> NS.UInteger { + return msgSend(NS.UInteger, self, "objectThreadExecutionWidth") +} +@(objc_type=RenderPipelineState, objc_name="meshThreadExecutionWidth") +RenderPipelineState_meshThreadExecutionWidth :: #force_inline proc "c" (self: ^RenderPipelineState) -> NS.UInteger { + return msgSend(NS.UInteger, self, "meshThreadExecutionWidth") +} +@(objc_type=RenderPipelineState, objc_name="maxTotalThreadgroupsPerMeshGrid") +RenderPipelineState_maxTotalThreadgroupsPerMeshGrid :: #force_inline proc "c" (self: ^RenderPipelineState) -> NS.UInteger { + return msgSend(NS.UInteger, self, "maxTotalThreadgroupsPerMeshGrid") +} +@(objc_type=RenderPipelineState, objc_name="gpuResourceID") +RenderPipelineState_gpuResourceID :: #force_inline proc "c" (self: ^RenderPipelineState) -> ResourceID { + return msgSend(ResourceID, self, "gpuResourceID") +} + + + //////////////////////////////////////////////////////////////////////////////// -/* -Class: - Resource -Class Methods: -Methods: - allocatedSize - cpuCacheMode - device - hazardTrackingMode - heap - heapOffset - isAliasable - label - makeAliasable - resourceOptions - setLabel - setPurgeableState - storageMode -*/ @(objc_class="MTLResource") Resource :: struct { using _: NS.Object } @(objc_type=Resource, objc_name="allocatedSize") -Resource_allocatedSize :: #force_inline proc(self: ^Resource) -> NS.UInteger { +Resource_allocatedSize :: #force_inline proc "c" (self: ^Resource) -> NS.UInteger { return msgSend(NS.UInteger, self, "allocatedSize") } @(objc_type=Resource, objc_name="cpuCacheMode") -Resource_cpuCacheMode :: #force_inline proc(self: ^Resource) -> CPUCacheMode { +Resource_cpuCacheMode :: #force_inline proc "c" (self: ^Resource) -> CPUCacheMode { return msgSend(CPUCacheMode, self, "cpuCacheMode") } @(objc_type=Resource, objc_name="device") -Resource_device :: #force_inline proc(self: ^Resource) -> ^Device { +Resource_device :: #force_inline proc "c" (self: ^Resource) -> ^Device { return msgSend(^Device, self, "device") } @(objc_type=Resource, objc_name="hazardTrackingMode") -Resource_hazardTrackingMode :: #force_inline proc(self: ^Resource) -> HazardTrackingMode { +Resource_hazardTrackingMode :: #force_inline proc "c" (self: ^Resource) -> HazardTrackingMode { return msgSend(HazardTrackingMode, self, "hazardTrackingMode") } @(objc_type=Resource, objc_name="heap") -Resource_heap :: #force_inline proc(self: ^Resource) -> ^Heap { +Resource_heap :: #force_inline proc "c" (self: ^Resource) -> ^Heap { return msgSend(^Heap, self, "heap") } @(objc_type=Resource, objc_name="heapOffset") -Resource_heapOffset :: #force_inline proc(self: ^Resource) -> NS.UInteger { +Resource_heapOffset :: #force_inline proc "c" (self: ^Resource) -> NS.UInteger { return msgSend(NS.UInteger, self, "heapOffset") } @(objc_type=Resource, objc_name="isAliasable") -Resource_isAliasable :: #force_inline proc(self: ^Resource) -> BOOL { +Resource_isAliasable :: #force_inline proc "c" (self: ^Resource) -> BOOL { return msgSend(BOOL, self, "isAliasable") } @(objc_type=Resource, objc_name="label") -Resource_label :: #force_inline proc(self: ^Resource) -> ^NS.String { +Resource_label :: #force_inline proc "c" (self: ^Resource) -> ^NS.String { return msgSend(^NS.String, self, "label") } @(objc_type=Resource, objc_name="makeAliasable") -Resource_makeAliasable :: #force_inline proc(self: ^Resource) { +Resource_makeAliasable :: #force_inline proc "c" (self: ^Resource) { msgSend(nil, self, "makeAliasable") } @(objc_type=Resource, objc_name="resourceOptions") -Resource_resourceOptions :: #force_inline proc(self: ^Resource) -> ResourceOptions { +Resource_resourceOptions :: #force_inline proc "c" (self: ^Resource) -> ResourceOptions { return msgSend(ResourceOptions, self, "resourceOptions") } @(objc_type=Resource, objc_name="setLabel") -Resource_setLabel :: #force_inline proc(self: ^Resource, label: ^NS.String) { +Resource_setLabel :: #force_inline proc "c" (self: ^Resource, label: ^NS.String) { msgSend(nil, self, "setLabel:", label) } @(objc_type=Resource, objc_name="setPurgeableState") -Resource_setPurgeableState :: #force_inline proc(self: ^Resource, state: PurgeableState) -> PurgeableState { +Resource_setPurgeableState :: #force_inline proc "c" (self: ^Resource, state: PurgeableState) -> PurgeableState { return msgSend(PurgeableState, self, "setPurgeableState:", state) } @(objc_type=Resource, objc_name="storageMode") -Resource_storageMode :: #force_inline proc(self: ^Resource) -> StorageMode { +Resource_storageMode :: #force_inline proc "c" (self: ^Resource) -> StorageMode { return msgSend(StorageMode, self, "storageMode") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - ResourceStateCommandEncoder -Class Methods: -Methods: - updateFence - updateTextureMapping - updateTextureMapping - updateTextureMappings - waitForFence -*/ @(objc_class="MTLResourceStateCommandEncoder") ResourceStateCommandEncoder :: struct { using _: CommandEncoder } @(objc_type=ResourceStateCommandEncoder, objc_name="updateFence") -ResourceStateCommandEncoder_updateFence :: #force_inline proc(self: ^ResourceStateCommandEncoder, fence: ^Fence) { +ResourceStateCommandEncoder_updateFence :: #force_inline proc "c" (self: ^ResourceStateCommandEncoder, fence: ^Fence) { msgSend(nil, self, "updateFence:", fence) } @(objc_type=ResourceStateCommandEncoder, objc_name="updateTextureMappingIndirect") -ResourceStateCommandEncoder_updateTextureMappingIndirect :: #force_inline proc(self: ^ResourceStateCommandEncoder, texture: ^Texture, mode: SparseTextureMappingMode, indirectBuffer: ^Buffer, indirectBufferOffset: NS.UInteger) { +ResourceStateCommandEncoder_updateTextureMappingIndirect :: #force_inline proc "c" (self: ^ResourceStateCommandEncoder, texture: ^Texture, mode: SparseTextureMappingMode, indirectBuffer: ^Buffer, indirectBufferOffset: NS.UInteger) { msgSend(nil, self, "updateTextureMapping:mode:indirectBuffer:indirectBufferOffset:", texture, mode, indirectBuffer, indirectBufferOffset) } @(objc_type=ResourceStateCommandEncoder, objc_name="updateTextureMapping") -ResourceStateCommandEncoder_updateTextureMapping :: #force_inline proc(self: ^ResourceStateCommandEncoder, texture: ^Texture, mode: SparseTextureMappingMode, region: Region, mipLevel: NS.UInteger, slice: NS.UInteger) { +ResourceStateCommandEncoder_updateTextureMapping :: #force_inline proc "c" (self: ^ResourceStateCommandEncoder, texture: ^Texture, mode: SparseTextureMappingMode, region: Region, mipLevel: NS.UInteger, slice: NS.UInteger) { msgSend(nil, self, "updateTextureMapping:mode:region:mipLevel:slice:", texture, mode, region, mipLevel, slice) } @(objc_type=ResourceStateCommandEncoder, objc_name="updateTextureMappings") -ResourceStateCommandEncoder_updateTextureMappings :: #force_inline proc(self: ^ResourceStateCommandEncoder, texture: ^Texture, mode: SparseTextureMappingMode, regions: []Region, mipLevels: []NS.UInteger, slices: NS.UInteger) { +ResourceStateCommandEncoder_updateTextureMappings :: #force_inline proc "c" (self: ^ResourceStateCommandEncoder, texture: ^Texture, mode: SparseTextureMappingMode, regions: []Region, mipLevels: []NS.UInteger, slices: NS.UInteger) { msgSend(nil, self, "updateTextureMappings:mode:regions:mipLevels:slices:numRegions:", texture, mode, raw_data(regions), raw_data(mipLevels), slices, NS.UInteger(len(regions))) } @(objc_type=ResourceStateCommandEncoder, objc_name="waitForFence") -ResourceStateCommandEncoder_waitForFence :: #force_inline proc(self: ^ResourceStateCommandEncoder, fence: ^Fence) { +ResourceStateCommandEncoder_waitForFence :: #force_inline proc "c" (self: ^ResourceStateCommandEncoder, fence: ^Fence) { msgSend(nil, self, "waitForFence:", fence) } +@(objc_type=ResourceStateCommandEncoder, objc_name="moveTextureMappingsFromTexture") +ResourceStateCommandEncoder_moveTextureMappingsFromTexture :: #force_inline proc "c" (self: ^ResourceStateCommandEncoder, + sourceTexture: ^Texture, sourceSlice, sourceLevel: NS.UInteger, sourceOrigin: Origin, sourceSize: Size, + destinationTexture: ^Texture, destinationSlice, destinationLevel: NS.UInteger, destinationOrigin: Origin, +) { + msgSend(nil, self, "moveTextureMappingsFromTexture:sourceSlice:sourceLevel:sourceOrigin:sourceSize:toTexture:destinationSlice:destinationLevel:destinationOrigin:", + sourceTexture, sourceSlice, sourceLevel, sourceOrigin, sourceSize, + destinationTexture, destinationSlice, destinationLevel, destinationOrigin, + ) +} + + //////////////////////////////////////////////////////////////////////////////// -/* -Class: - SamplerState -Class Methods: -Methods: - device - label -*/ @(objc_class="MTLSamplerState") SamplerState :: struct { using _: NS.Object } @(objc_type=SamplerState, objc_name="device") -SamplerState_device :: #force_inline proc(self: ^SamplerState) -> ^Device { +SamplerState_device :: #force_inline proc "c" (self: ^SamplerState) -> ^Device { return msgSend(^Device, self, "device") } @(objc_type=SamplerState, objc_name="label") -SamplerState_label :: #force_inline proc(self: ^SamplerState) -> ^NS.String { +SamplerState_label :: #force_inline proc "c" (self: ^SamplerState) -> ^NS.String { return msgSend(^NS.String, self, "label") } +@(objc_type=SamplerState, objc_name="gpuResourceID") +SamplerState_gpuResourceID :: #force_inline proc "c" (self: ^SamplerState) -> ResourceID { + return msgSend(ResourceID, self, "gpuResourceID") +} //////////////////////////////////////////////////////////////////////////////// -/* -Class: - SharedEvent -Class Methods: -Methods: - newSharedEventHandle - notifyListener - setSignaledValue - signaledValue -*/ @(objc_class="MTLSharedEvent") SharedEvent :: struct { using _: Event } @(objc_type=SharedEvent, objc_name="newSharedEventHandle") -SharedEvent_newSharedEventHandle :: #force_inline proc(self: ^SharedEvent) -> ^SharedEventHandle { +SharedEvent_newSharedEventHandle :: #force_inline proc "c" (self: ^SharedEvent) -> ^SharedEventHandle { return msgSend(^SharedEventHandle, self, "newSharedEventHandle") } @(objc_type=SharedEvent, objc_name="notifyListener") -SharedEvent_notifyListener :: #force_inline proc(self: ^SharedEvent, listener: ^SharedEventListener, value: u64, block: SharedEventNotificationBlock) { +SharedEvent_notifyListener :: #force_inline proc "c" (self: ^SharedEvent, listener: ^SharedEventListener, value: u64, block: SharedEventNotificationBlock) { msgSend(nil, self, "notifyListener:atValue:block:", listener, value, block) } @(objc_type=SharedEvent, objc_name="setSignaledValue") -SharedEvent_setSignaledValue :: #force_inline proc(self: ^SharedEvent, signaledValue: u64) { +SharedEvent_setSignaledValue :: #force_inline proc "c" (self: ^SharedEvent, signaledValue: u64) { msgSend(nil, self, "setSignaledValue:", signaledValue) } @(objc_type=SharedEvent, objc_name="signaledValue") -SharedEvent_signaledValue :: #force_inline proc(self: ^SharedEvent) -> u64 { +SharedEvent_signaledValue :: #force_inline proc "c" (self: ^SharedEvent) -> u64 { return msgSend(u64, self, "signaledValue") } //////////////////////////////////////////////////////////////////////////////// -/* -Class: - Texture -Class Methods: -Methods: - allowGPUOptimizedContents - arrayLength - buffer - bufferBytesPerRow - bufferOffset - depth - firstMipmapInTail - getBytes - getBytes - height - iosurface - iosurfacePlane - isFramebufferOnly - isShareable - isSparse - mipmapLevelCount - newRemoteTextureViewForDevice - newSharedTextureHandle - newTextureViewWithPixelFormat - newTextureViewWithPixelFormat - newTextureViewWithPixelFormat - parentRelativeLevel - parentRelativeSlice - parentTexture - pixelFormat - remoteStorageTexture - replaceRegion - replaceRegion - rootResource - sampleCount - swizzle - tailSizeInBytes - textureType - usage - width -*/ @(objc_class="MTLTexture") Texture :: struct { using _: Resource } @(objc_type=Texture, objc_name="allowGPUOptimizedContents") -Texture_allowGPUOptimizedContents :: #force_inline proc(self: ^Texture) -> BOOL { +Texture_allowGPUOptimizedContents :: #force_inline proc "c" (self: ^Texture) -> BOOL { return msgSend(BOOL, self, "allowGPUOptimizedContents") } @(objc_type=Texture, objc_name="arrayLength") -Texture_arrayLength :: #force_inline proc(self: ^Texture) -> NS.UInteger { +Texture_arrayLength :: #force_inline proc "c" (self: ^Texture) -> NS.UInteger { return msgSend(NS.UInteger, self, "arrayLength") } @(objc_type=Texture, objc_name="buffer") -Texture_buffer :: #force_inline proc(self: ^Texture) -> ^Buffer { +Texture_buffer :: #force_inline proc "c" (self: ^Texture) -> ^Buffer { return msgSend(^Buffer, self, "buffer") } @(objc_type=Texture, objc_name="bufferBytesPerRow") -Texture_bufferBytesPerRow :: #force_inline proc(self: ^Texture) -> NS.UInteger { +Texture_bufferBytesPerRow :: #force_inline proc "c" (self: ^Texture) -> NS.UInteger { return msgSend(NS.UInteger, self, "bufferBytesPerRow") } @(objc_type=Texture, objc_name="bufferOffset") -Texture_bufferOffset :: #force_inline proc(self: ^Texture) -> NS.UInteger { +Texture_bufferOffset :: #force_inline proc "c" (self: ^Texture) -> NS.UInteger { return msgSend(NS.UInteger, self, "bufferOffset") } @(objc_type=Texture, objc_name="depth") -Texture_depth :: #force_inline proc(self: ^Texture) -> NS.UInteger { +Texture_depth :: #force_inline proc "c" (self: ^Texture) -> NS.UInteger { return msgSend(NS.UInteger, self, "depth") } @(objc_type=Texture, objc_name="firstMipmapInTail") -Texture_firstMipmapInTail :: #force_inline proc(self: ^Texture) -> NS.UInteger { +Texture_firstMipmapInTail :: #force_inline proc "c" (self: ^Texture) -> NS.UInteger { return msgSend(NS.UInteger, self, "firstMipmapInTail") } @(objc_type=Texture, objc_name="getBytesWithLevel") -Texture_getBytesWithLevel :: #force_inline proc(self: ^Texture, pixelBytes: rawptr, bytesPerRow: NS.UInteger, bytesPerImage: NS.UInteger, region: Region, level: NS.UInteger, slice: NS.UInteger) { +Texture_getBytesWithLevel :: #force_inline proc "c" (self: ^Texture, pixelBytes: rawptr, bytesPerRow: NS.UInteger, bytesPerImage: NS.UInteger, region: Region, level: NS.UInteger, slice: NS.UInteger) { msgSend(nil, self, "getBytes:bytesPerRow:bytesPerImage:fromRegion:mipmapLevel:slice:", pixelBytes, bytesPerRow, bytesPerImage, region, level, slice) } @(objc_type=Texture, objc_name="getBytes") -Texture_getBytes :: #force_inline proc(self: ^Texture, pixelBytes: rawptr, bytesPerRow: NS.UInteger, region: Region, level: NS.UInteger) { +Texture_getBytes :: #force_inline proc "c" (self: ^Texture, pixelBytes: rawptr, bytesPerRow: NS.UInteger, region: Region, level: NS.UInteger) { msgSend(nil, self, "getBytes:bytesPerRow:fromRegion:mipmapLevel:", pixelBytes, bytesPerRow, region, level) } @(objc_type=Texture, objc_name="height") -Texture_height :: #force_inline proc(self: ^Texture) -> NS.UInteger { +Texture_height :: #force_inline proc "c" (self: ^Texture) -> NS.UInteger { return msgSend(NS.UInteger, self, "height") } @(objc_type=Texture, objc_name="iosurface") -Texture_iosurface :: #force_inline proc(self: ^Texture) -> IOSurfaceRef { +Texture_iosurface :: #force_inline proc "c" (self: ^Texture) -> IOSurfaceRef { return msgSend(IOSurfaceRef, self, "iosurface") } @(objc_type=Texture, objc_name="iosurfacePlane") -Texture_iosurfacePlane :: #force_inline proc(self: ^Texture) -> NS.UInteger { +Texture_iosurfacePlane :: #force_inline proc "c" (self: ^Texture) -> NS.UInteger { return msgSend(NS.UInteger, self, "iosurfacePlane") } @(objc_type=Texture, objc_name="isFramebufferOnly") -Texture_isFramebufferOnly :: #force_inline proc(self: ^Texture) -> BOOL { +Texture_isFramebufferOnly :: #force_inline proc "c" (self: ^Texture) -> BOOL { return msgSend(BOOL, self, "isFramebufferOnly") } @(objc_type=Texture, objc_name="isShareable") -Texture_isShareable :: #force_inline proc(self: ^Texture) -> BOOL { +Texture_isShareable :: #force_inline proc "c" (self: ^Texture) -> BOOL { return msgSend(BOOL, self, "isShareable") } @(objc_type=Texture, objc_name="isSparse") -Texture_isSparse :: #force_inline proc(self: ^Texture) -> BOOL { +Texture_isSparse :: #force_inline proc "c" (self: ^Texture) -> BOOL { return msgSend(BOOL, self, "isSparse") } @(objc_type=Texture, objc_name="mipmapLevelCount") -Texture_mipmapLevelCount :: #force_inline proc(self: ^Texture) -> NS.UInteger { +Texture_mipmapLevelCount :: #force_inline proc "c" (self: ^Texture) -> NS.UInteger { return msgSend(NS.UInteger, self, "mipmapLevelCount") } @(objc_type=Texture, objc_name="newRemoteTextureViewForDevice") -Texture_newRemoteTextureViewForDevice :: #force_inline proc(self: ^Texture, device: ^Device) -> ^Texture { +Texture_newRemoteTextureViewForDevice :: #force_inline proc "c" (self: ^Texture, device: ^Device) -> ^Texture { return msgSend(^Texture, self, "newRemoteTextureViewForDevice:", device) } @(objc_type=Texture, objc_name="newSharedTextureHandle") -Texture_newSharedTextureHandle :: #force_inline proc(self: ^Texture) -> ^SharedTextureHandle { +Texture_newSharedTextureHandle :: #force_inline proc "c" (self: ^Texture) -> ^SharedTextureHandle { return msgSend(^SharedTextureHandle, self, "newSharedTextureHandle") } -@(objc_type=Texture, objc_name="newTextureView") -Texture_newTextureView :: #force_inline proc(self: ^Texture, pixelFormat: PixelFormat) -> ^Texture { + +@(objc_type=Texture, objc_name="newTextureViewWithPixelFormat") +Texture_newTextureViewWithPixelFormat :: #force_inline proc "c" (self: ^Texture, pixelFormat: PixelFormat) -> ^Texture { return msgSend(^Texture, self, "newTextureViewWithPixelFormat:", pixelFormat) } @(objc_type=Texture, objc_name="newTextureViewWithLevels") -Texture_newTextureViewWithLevels :: #force_inline proc(self: ^Texture, pixelFormat: PixelFormat, textureType: TextureType, levelRange: NS.Range, sliceRange: NS.Range) -> ^Texture { +Texture_newTextureViewWithLevels :: #force_inline proc "c" (self: ^Texture, pixelFormat: PixelFormat, textureType: TextureType, levelRange: NS.Range, sliceRange: NS.Range) -> ^Texture { return msgSend(^Texture, self, "newTextureViewWithPixelFormat:textureType:levels:slices:", pixelFormat, textureType, levelRange, sliceRange) } @(objc_type=Texture, objc_name="newTextureViewWithLevelsAndSwizzle") -Texture_newTextureViewWithLevelsAndSwizzle :: #force_inline proc(self: ^Texture, pixelFormat: PixelFormat, textureType: TextureType, levelRange: NS.Range, sliceRange: NS.Range, swizzle: TextureSwizzleChannels) -> ^Texture { +Texture_newTextureViewWithLevelsAndSwizzle :: #force_inline proc "c" (self: ^Texture, pixelFormat: PixelFormat, textureType: TextureType, levelRange: NS.Range, sliceRange: NS.Range, swizzle: TextureSwizzleChannels) -> ^Texture { return msgSend(^Texture, self, "newTextureViewWithPixelFormat:textureType:levels:slices:swizzle:", pixelFormat, textureType, levelRange, sliceRange, swizzle) } +@(objc_type=Texture, objc_name="newTextureView") +Texture_newTextureView :: proc{ + Texture_newTextureViewWithPixelFormat, + Texture_newTextureViewWithLevels, + Texture_newTextureViewWithLevelsAndSwizzle, +} + @(objc_type=Texture, objc_name="parentRelativeLevel") -Texture_parentRelativeLevel :: #force_inline proc(self: ^Texture) -> NS.UInteger { +Texture_parentRelativeLevel :: #force_inline proc "c" (self: ^Texture) -> NS.UInteger { return msgSend(NS.UInteger, self, "parentRelativeLevel") } @(objc_type=Texture, objc_name="parentRelativeSlice") -Texture_parentRelativeSlice :: #force_inline proc(self: ^Texture) -> NS.UInteger { +Texture_parentRelativeSlice :: #force_inline proc "c" (self: ^Texture) -> NS.UInteger { return msgSend(NS.UInteger, self, "parentRelativeSlice") } @(objc_type=Texture, objc_name="parentTexture") -Texture_parentTexture :: #force_inline proc(self: ^Texture) -> ^Texture { +Texture_parentTexture :: #force_inline proc "c" (self: ^Texture) -> ^Texture { return msgSend(^Texture, self, "parentTexture") } @(objc_type=Texture, objc_name="pixelFormat") -Texture_pixelFormat :: #force_inline proc(self: ^Texture) -> PixelFormat { +Texture_pixelFormat :: #force_inline proc "c" (self: ^Texture) -> PixelFormat { return msgSend(PixelFormat, self, "pixelFormat") } @(objc_type=Texture, objc_name="remoteStorageTexture") -Texture_remoteStorageTexture :: #force_inline proc(self: ^Texture) -> ^Texture { +Texture_remoteStorageTexture :: #force_inline proc "c" (self: ^Texture) -> ^Texture { return msgSend(^Texture, self, "remoteStorageTexture") } @(objc_type=Texture, objc_name="replaceRegionWithLevel") -Texture_replaceRegionWithLevel :: #force_inline proc(self: ^Texture, region: Region, level: NS.UInteger, slice: NS.UInteger, pixelBytes: rawptr, bytesPerRow: NS.UInteger, bytesPerImage: NS.UInteger) { +Texture_replaceRegionWithLevel :: #force_inline proc "c" (self: ^Texture, region: Region, level: NS.UInteger, slice: NS.UInteger, pixelBytes: rawptr, bytesPerRow: NS.UInteger, bytesPerImage: NS.UInteger) { msgSend(nil, self, "replaceRegion:mipmapLevel:slice:withBytes:bytesPerRow:bytesPerImage:", region, level, slice, pixelBytes, bytesPerRow, bytesPerImage) } @(objc_type=Texture, objc_name="replaceRegion") -Texture_replaceRegion :: #force_inline proc(self: ^Texture, region: Region, level: NS.UInteger, pixelBytes: rawptr, bytesPerRow: NS.UInteger) { +Texture_replaceRegion :: #force_inline proc "c" (self: ^Texture, region: Region, level: NS.UInteger, pixelBytes: rawptr, bytesPerRow: NS.UInteger) { msgSend(nil, self, "replaceRegion:mipmapLevel:withBytes:bytesPerRow:", region, level, pixelBytes, bytesPerRow) } @(objc_type=Texture, objc_name="rootResource") -Texture_rootResource :: #force_inline proc(self: ^Texture) -> ^Resource { +Texture_rootResource :: #force_inline proc "c" (self: ^Texture) -> ^Resource { return msgSend(^Resource, self, "rootResource") } @(objc_type=Texture, objc_name="sampleCount") -Texture_sampleCount :: #force_inline proc(self: ^Texture) -> NS.UInteger { +Texture_sampleCount :: #force_inline proc "c" (self: ^Texture) -> NS.UInteger { return msgSend(NS.UInteger, self, "sampleCount") } @(objc_type=Texture, objc_name="swizzle") -Texture_swizzle :: #force_inline proc(self: ^Texture) -> TextureSwizzleChannels { +Texture_swizzle :: #force_inline proc "c" (self: ^Texture) -> TextureSwizzleChannels { return msgSend(TextureSwizzleChannels, self, "swizzle") } @(objc_type=Texture, objc_name="tailSizeInBytes") -Texture_tailSizeInBytes :: #force_inline proc(self: ^Texture) -> NS.UInteger { +Texture_tailSizeInBytes :: #force_inline proc "c" (self: ^Texture) -> NS.UInteger { return msgSend(NS.UInteger, self, "tailSizeInBytes") } @(objc_type=Texture, objc_name="textureType") -Texture_textureType :: #force_inline proc(self: ^Texture) -> TextureType { +Texture_textureType :: #force_inline proc "c" (self: ^Texture) -> TextureType { return msgSend(TextureType, self, "textureType") } @(objc_type=Texture, objc_name="usage") -Texture_usage :: #force_inline proc(self: ^Texture) -> TextureUsage { +Texture_usage :: #force_inline proc "c" (self: ^Texture) -> TextureUsage { return msgSend(TextureUsage, self, "usage") } @(objc_type=Texture, objc_name="width") -Texture_width :: #force_inline proc(self: ^Texture) -> NS.UInteger { +Texture_width :: #force_inline proc "c" (self: ^Texture) -> NS.UInteger { return msgSend(NS.UInteger, self, "width") } +@(objc_type=Texture, objc_name="compressionType") +Texture_compressionType :: #force_inline proc "c" (self: ^Texture) -> TextureCompressionType { + return msgSend(TextureCompressionType, self, "compressionType") +} +@(objc_type=Texture, objc_name="gpuResourceID") +Texture_gpuResourceID :: #force_inline proc "c" (self: ^Texture) -> ResourceID { + return msgSend(ResourceID, self, "gpuResourceID") +} + //////////////////////////////////////////////////////////////////////////////// -/* -Class: - VisibleFunctionTable -Class Methods: -Methods: - setFunction - setFunctions -*/ @(objc_class="MTLVisibleFunctionTable") VisibleFunctionTable :: struct { using _: Resource } @(objc_type=VisibleFunctionTable, objc_name="setFunction") -VisibleFunctionTable_setFunction :: #force_inline proc(self: ^VisibleFunctionTable, function: ^FunctionHandle, index: NS.UInteger) { +VisibleFunctionTable_setFunction :: #force_inline proc "c" (self: ^VisibleFunctionTable, function: ^FunctionHandle, index: NS.UInteger) { msgSend(nil, self, "setFunction:atIndex:", function, index) } @(objc_type=VisibleFunctionTable, objc_name="setFunctions") -VisibleFunctionTable_setFunctions :: #force_inline proc(self: ^VisibleFunctionTable, functions: []^FunctionHandle, range: NS.Range) { +VisibleFunctionTable_setFunctions :: #force_inline proc "c" (self: ^VisibleFunctionTable, functions: []^FunctionHandle, range: NS.Range) { msgSend(nil, self, "setFunctions:withRange:", raw_data(functions), range) } +@(objc_type=VisibleFunctionTable, objc_name="gpuResourceID") +VisibleFunctionTable_gpuResourceID :: #force_inline proc "c" (self: ^VisibleFunctionTable) -> ResourceID { + return msgSend(ResourceID, self, "gpuResourceID") +} + -// TODO: Entire FunctionStitching API (which appears not to be in been missed from the generator) - - diff --git a/vendor/darwin/Metal/MetalEnums.odin b/vendor/darwin/Metal/MetalEnums.odin index 7d72483ff..ab4782da4 100644 --- a/vendor/darwin/Metal/MetalEnums.odin +++ b/vendor/darwin/Metal/MetalEnums.odin @@ -17,6 +17,14 @@ AccelerationStructureInstanceOption :: enum u32 { NonOpaque = 3, } + +AccelerationStructureRefitOptions :: distinct bit_set[AccelerationStructureRefitOption; NS.UInteger] +AccelerationStructureRefitOption :: enum NS.UInteger { + VertexData = 0, + PerPrimitiveData = 1, +} + + MotionBorderMode :: enum u32 { Clamp = 0, Vanish = 1, @@ -148,6 +156,21 @@ BinaryArchiveError :: enum NS.UInteger { InvalidFile = 1, UnexpectedElement = 2, CompilationFailure = 3, + InternalError = 4, +} + +BindingType :: enum NS.Integer { + Buffer = 0, + ThreadgroupMemory = 1, + Texture = 2, + Sampler = 3, + ImageblockData = 16, + Imageblock = 17, + VisibleFunctionTable = 24, + PrimitiveAccelerationStructure = 25, + InstanceAccelerationStructure = 26, + IntersectionFunctionTable = 27, + ObjectPayload = 34, } BlitOptionFlag :: enum NS.UInteger { @@ -171,15 +194,16 @@ CaptureDestination :: enum NS.Integer { CommandBufferStatus :: enum NS.UInteger { NotEnqueued = 0, - Enqueued = 1, - Committed = 2, - Scheduled = 3, - Completed = 4, - Error = 5, + Enqueued = 1, + Committed = 2, + Scheduled = 3, + Completed = 4, + Error = 5, } CommandBufferError :: enum NS.UInteger { None = 0, + Internal = 1, Timeout = 2, PageFault = 3, AccessRevoked = 4, @@ -232,6 +256,7 @@ BarrierScope :: distinct bit_set[BarrierScopeFlag; NS.UInteger] CounterSampleBufferError :: enum NS.Integer { OutOfMemory = 0, Invalid = 1, + Internal = 2, } CompareFunction :: enum NS.UInteger { @@ -312,6 +337,13 @@ GPUFamily :: enum NS.Integer { Common3 = 3003, MacCatalyst1 = 4001, MacCatalyst2 = 4002, + Metal3 = 5001, +} + +SparsePageSize :: enum NS.Integer { + Size16 = 101, + Size64 = 102, + Size256 = 103, } DeviceLocation :: enum NS.UInteger { @@ -409,6 +441,9 @@ FunctionType :: enum NS.UInteger { Kernel = 3, Visible = 5, Intersection = 6, + Mesh = 7, + Object = 8, + } @@ -421,15 +456,22 @@ LanguageVersion :: enum NS.UInteger { Version2_2 = 131074, Version2_3 = 131075, Version2_4 = 131076, + Version3_0 = 196608, } LibraryType :: enum NS.Integer { Executable = 0, - Dynamic = 1, + Dynamic = 1, +} + +LibraryOptimizationLevel :: enum NS.Integer { + Default = 0, + Size = 1, } LibraryError :: enum NS.UInteger { Unsupported = 1, + Internal = 2, CompileFailure = 3, CompileWarning = 4, FunctionNotFound = 5, @@ -624,6 +666,8 @@ RenderStage :: enum NS.UInteger { Vertex = 0, Fragment = 1, Tile = 2, + Object = 3, + Mesh = 4, } RenderStages :: distinct bit_set[RenderStage; NS.UInteger] @@ -861,6 +905,42 @@ IndexType :: enum NS.UInteger { UInt32 = 1, } +IOPriority :: enum NS.Integer { + High = 0, + Normal = 1, + Low = 2, +} + +IOCommandQueueType :: enum NS.Integer { + Concurrent = 0, + Serial = 1, +} + +IOError :: enum NS.Integer { + URLInvalid = 1, + Internal = 2, +} + +IOStatus :: enum NS.Integer { + Pending = 0, + Cancelled = 1, + Error = 2, + Complete = 3, +} + +IOCompressionMethod :: enum NS.Integer { + Zlib = 0, + LZFSE = 1, + LZ4 = 2, + LZMA = 3, + LZBitmap = 4, +} + +IOCompressionStatus :: enum NS.Integer { + Complete = 0, + Error = 1, +} + StepFunction :: enum NS.UInteger { Constant = 0, PerVertex = 1, diff --git a/vendor/darwin/Metal/MetalErrors.odin b/vendor/darwin/Metal/MetalErrors.odin index f214466e5..8bc851e33 100644 --- a/vendor/darwin/Metal/MetalErrors.odin +++ b/vendor/darwin/Metal/MetalErrors.odin @@ -4,9 +4,11 @@ import NS "vendor:darwin/Foundation" foreign import "system:Metal.framework" -CommonCounter :: ^NS.String -CommonCounterSet :: ^NS.String +CommonCounter :: ^NS.String +CommonCounterSet :: ^NS.String DeviceNotificationName :: ^NS.String +ErrorUserInfoKey :: ^NS.ErrorUserInfoKey +ErrorDomain :: ^NS.ErrorDomain foreign Metal { @(linkage="weak") CommonCounterTimestamp: CommonCounter @@ -36,4 +38,12 @@ foreign Metal { @(linkage="weak") DeviceWasAddedNotification: DeviceNotificationName @(linkage="weak") DeviceRemovalRequestedNotification: DeviceNotificationName @(linkage="weak") DeviceWasRemovedNotification: DeviceNotificationName +} + +foreign Metal { + @(linkage="weak") CommandBufferEncoderInfoErrorKey: ErrorUserInfoKey +} + +foreign Metal { + @(linkage="weak") IOErrorDomain: ErrorDomain } \ No newline at end of file diff --git a/vendor/darwin/Metal/MetalProcedures.odin b/vendor/darwin/Metal/MetalProcedures.odin index ca8fb1aea..dd90bd3e9 100644 --- a/vendor/darwin/Metal/MetalProcedures.odin +++ b/vendor/darwin/Metal/MetalProcedures.odin @@ -1,6 +1,7 @@ package objc_Metal import NS "vendor:darwin/Foundation" +import "core:c" @(require) foreign import "system:Metal.framework" @@ -11,6 +12,12 @@ foreign Metal { CopyAllDevicesWithObserver :: proc(observer: ^id, handler: DeviceNotificationHandler) -> ^NS.Array --- CreateSystemDefaultDevice :: proc() -> ^Device --- RemoveDeviceObserver :: proc(observer: id) --- + + + IOCompressionContextDefaultChunkSize :: proc() -> c.size_t --- + IOCreateCompressionContext :: proc(path: cstring, type: IOCompressionMethod, chuckSize: c.size_t) -> rawptr --- + IOCompressionContextAppendData :: proc(ctx: rawptr, data: rawptr, size: c.size_t) --- + IOFlushAndDestroyCompressionContext :: proc(ctx: rawptr) -> IOCompressionStatus --- } diff --git a/vendor/darwin/Metal/MetalTypes.odin b/vendor/darwin/Metal/MetalTypes.odin index cc9d25ca0..b14fe2886 100644 --- a/vendor/darwin/Metal/MetalTypes.odin +++ b/vendor/darwin/Metal/MetalTypes.odin @@ -133,6 +133,8 @@ Region :: struct { SamplePosition :: distinct [2]f32 +ResourceID :: distinct u64 + ScissorRect :: struct { x: NS.Integer, y: NS.Integer, diff --git a/vendor/darwin/MetalKit/MetalKit.odin b/vendor/darwin/MetalKit/MetalKit.odin index 90d147983..eb09410d1 100644 --- a/vendor/darwin/MetalKit/MetalKit.odin +++ b/vendor/darwin/MetalKit/MetalKit.odin @@ -24,34 +24,34 @@ ViewDelegate :: struct { View :: struct {using _: NS.View} @(objc_type=View, objc_name="alloc", objc_is_class_method=true) -View_alloc :: proc() -> ^View { +View_alloc :: proc "c" () -> ^View { return msgSend(^View, View, "alloc") } @(objc_type=View, objc_name="initWithFrame") -View_initWithFrame :: proc(self: ^View, frame: NS.Rect, device: ^MTL.Device) -> ^View { +View_initWithFrame :: proc "c" (self: ^View, frame: NS.Rect, device: ^MTL.Device) -> ^View { return msgSend(^View, self, "initWithFrame:device:", frame, device) } @(objc_type=View, objc_name="initWithCoder") -View_initWithCoder :: proc(self: ^View, coder: ^NS.Coder) -> ^View { +View_initWithCoder :: proc "c" (self: ^View, coder: ^NS.Coder) -> ^View { return msgSend(^View, self, "initWithCoder:", coder) } @(objc_type=View, objc_name="setDevice") -View_setDevice :: proc(self: ^View, device: ^MTL.Device) { +View_setDevice :: proc "c" (self: ^View, device: ^MTL.Device) { msgSend(nil, self, "setDevice:", device) } @(objc_type=View, objc_name="device") -View_device :: proc(self: ^View) -> ^MTL.Device { +View_device :: proc "c" (self: ^View) -> ^MTL.Device { return msgSend(^MTL.Device, self, "device") } @(objc_type=View, objc_name="draw") -View_draw :: proc(self: ^View) { +View_draw :: proc "c" (self: ^View) { msgSend(nil, self, "draw") } @(objc_type=View, objc_name="setDelegate") -View_setDelegate :: proc(self: ^View, delegate: ^ViewDelegate) { +View_setDelegate :: proc "c" (self: ^View, delegate: ^ViewDelegate) { drawDispatch :: proc "c" (self: ^NS.Value, cmd: NS.SEL, view: ^View) { del := (^ViewDelegate)(self->pointerValue()) del->drawInMTKView(view) @@ -72,7 +72,7 @@ View_setDelegate :: proc(self: ^View, delegate: ^ViewDelegate) { } @(objc_type=View, objc_name="delegate") -View_delegate :: proc(self: ^View) -> ^ViewDelegate { +View_delegate :: proc "c" (self: ^View) -> ^ViewDelegate { wrapper := msgSend(^NS.Value, self, "delegate") if wrapper != nil { return (^ViewDelegate)(wrapper->pointerValue()) @@ -81,179 +81,179 @@ View_delegate :: proc(self: ^View) -> ^ViewDelegate { } @(objc_type=View, objc_name="currentDrawable") -View_currentDrawable :: proc(self: ^View) -> ^CA.MetalDrawable { +View_currentDrawable :: proc "c" (self: ^View) -> ^CA.MetalDrawable { return msgSend(^CA.MetalDrawable, self, "currentDrawable") } @(objc_type=View, objc_name="setFramebufferOnly") -View_setFramebufferOnly :: proc(self: ^View, framebufferOnly: bool) { +View_setFramebufferOnly :: proc "c" (self: ^View, framebufferOnly: bool) { msgSend(nil, self, "setFramebufferOnly:", framebufferOnly) } @(objc_type=View, objc_name="framebufferOnly") -View_framebufferOnly :: proc(self: ^View) -> bool { +View_framebufferOnly :: proc "c" (self: ^View) -> bool { return msgSend(bool, self, "framebufferOnly") } @(objc_type=View, objc_name="setDepthStencilAttachmentTextureUsage") -View_setDepthStencilAttachmentTextureUsage :: proc(self: ^View, textureUsage: MTL.TextureUsage) { +View_setDepthStencilAttachmentTextureUsage :: proc "c" (self: ^View, textureUsage: MTL.TextureUsage) { msgSend(nil, self, "setDepthStencilAttachmentTextureUsage:", textureUsage) } @(objc_type=View, objc_name="depthStencilAttachmentTextureUsage") -View_depthStencilAttachmentTextureUsage :: proc(self: ^View) -> MTL.TextureUsage { +View_depthStencilAttachmentTextureUsage :: proc "c" (self: ^View) -> MTL.TextureUsage { return msgSend(MTL.TextureUsage, self, "depthStencilAttachmentTextureUsage") } @(objc_type=View, objc_name="setMultisampleColorAttachmentTextureUsage") -View_setMultisampleColorAttachmentTextureUsage :: proc(self: ^View, textureUsage: MTL.TextureUsage) { +View_setMultisampleColorAttachmentTextureUsage :: proc "c" (self: ^View, textureUsage: MTL.TextureUsage) { msgSend(nil, self, "setMultisampleColorAttachmentTextureUsage:", textureUsage) } @(objc_type=View, objc_name="multisampleColorAttachmentTextureUsage") -View_multisampleColorAttachmentTextureUsage :: proc(self: ^View) -> MTL.TextureUsage { +View_multisampleColorAttachmentTextureUsage :: proc "c" (self: ^View) -> MTL.TextureUsage { return msgSend(MTL.TextureUsage, self, "multisampleColorAttachmentTextureUsage") } @(objc_type=View, objc_name="setPresentsWithTransaction") -View_setPresentsWithTransaction :: proc(self: ^View, presentsWithTransaction: bool) { +View_setPresentsWithTransaction :: proc "c" (self: ^View, presentsWithTransaction: bool) { msgSend(nil, self, "setPresentsWithTransaction:", presentsWithTransaction) } @(objc_type=View, objc_name="presentsWithTransaction") -View_presentsWithTransaction :: proc(self: ^View) -> bool { +View_presentsWithTransaction :: proc "c" (self: ^View) -> bool { return msgSend(bool, self, "presentsWithTransaction") } @(objc_type=View, objc_name="setColorPixelFormat") -View_setColorPixelFormat :: proc(self: ^View, colorPixelFormat: MTL.PixelFormat) { +View_setColorPixelFormat :: proc "c" (self: ^View, colorPixelFormat: MTL.PixelFormat) { msgSend(nil, self, "setColorPixelFormat:", colorPixelFormat) } @(objc_type=View, objc_name="colorPixelFormat") -View_colorPixelFormat :: proc(self: ^View) -> MTL.PixelFormat { +View_colorPixelFormat :: proc "c" (self: ^View) -> MTL.PixelFormat { return msgSend(MTL.PixelFormat, self, "colorPixelFormat") } @(objc_type=View, objc_name="setDepthStencilPixelFormat") -View_setDepthStencilPixelFormat :: proc(self: ^View, colorPixelFormat: MTL.PixelFormat) { +View_setDepthStencilPixelFormat :: proc "c" (self: ^View, colorPixelFormat: MTL.PixelFormat) { msgSend(nil, self, "setDepthStencilPixelFormat:", colorPixelFormat) } @(objc_type=View, objc_name="depthStencilPixelFormat") -View_depthStencilPixelFormat :: proc(self: ^View) -> MTL.PixelFormat { +View_depthStencilPixelFormat :: proc "c" (self: ^View) -> MTL.PixelFormat { return msgSend(MTL.PixelFormat, self, "depthStencilPixelFormat") } @(objc_type=View, objc_name="setSampleCount") -View_setSampleCount :: proc(self: ^View, sampleCount: NS.UInteger) { +View_setSampleCount :: proc "c" (self: ^View, sampleCount: NS.UInteger) { msgSend(nil, self, "setSampleCount:", sampleCount) } @(objc_type=View, objc_name="sampleCount") -View_sampleCount :: proc(self: ^View) -> NS.UInteger { +View_sampleCount :: proc "c" (self: ^View) -> NS.UInteger { return msgSend(NS.UInteger, self, "sampleCount") } @(objc_type=View, objc_name="setClearColor") -View_setClearColor :: proc(self: ^View, clearColor: MTL.ClearColor) { +View_setClearColor :: proc "c" (self: ^View, clearColor: MTL.ClearColor) { msgSend(nil, self, "setClearColor:", clearColor) } @(objc_type=View, objc_name="clearColor") -View_clearColor :: proc(self: ^View) -> MTL.ClearColor { +View_clearColor :: proc "c" (self: ^View) -> MTL.ClearColor { return msgSend(MTL.ClearColor, self, "clearColor") } @(objc_type=View, objc_name="setClearDepth") -View_setClearDepth :: proc(self: ^View, clearDepth: f64) { +View_setClearDepth :: proc "c" (self: ^View, clearDepth: f64) { msgSend(nil, self, "setClearDepth:", clearDepth) } @(objc_type=View, objc_name="clearDepth") -View_clearDepth :: proc(self: ^View) -> f64 { +View_clearDepth :: proc "c" (self: ^View) -> f64 { return msgSend(f64, self, "clearDepth") } @(objc_type=View, objc_name="setClearStencil") -View_setClearStencil :: proc(self: ^View, clearStencil: u32) { +View_setClearStencil :: proc "c" (self: ^View, clearStencil: u32) { msgSend(nil, self, "setClearStencil:", clearStencil) } @(objc_type=View, objc_name="clearStencil") -View_clearStencil :: proc(self: ^View) -> u32 { +View_clearStencil :: proc "c" (self: ^View) -> u32 { return msgSend(u32, self, "clearStencil") } @(objc_type=View, objc_name="depthStencilTexture") -View_depthStencilTexture :: proc(self: ^View) -> ^MTL.Texture { +View_depthStencilTexture :: proc "c" (self: ^View) -> ^MTL.Texture { return msgSend(^MTL.Texture, self, "depthStencilTexture") } @(objc_type=View, objc_name="multisampleColorTexture") -View_multisampleColorTexture :: proc(self: ^View) -> ^MTL.Texture { +View_multisampleColorTexture :: proc "c" (self: ^View) -> ^MTL.Texture { return msgSend(^MTL.Texture, self, "multisampleColorTexture") } @(objc_type=View, objc_name="releaseDrawables") -View_releaseDrawables :: proc(self: ^View) { +View_releaseDrawables :: proc "c" (self: ^View) { msgSend(nil, self, "releaseDrawables") } @(objc_type=View, objc_name="currentRenderPassDescriptor") -View_currentRenderPassDescriptor :: proc(self: ^View) -> ^MTL.RenderPassDescriptor { +View_currentRenderPassDescriptor :: proc "c" (self: ^View) -> ^MTL.RenderPassDescriptor { return msgSend(^MTL.RenderPassDescriptor, self, "currentRenderPassDescriptor") } @(objc_type=View, objc_name="setPreferredFramesPerSecond") -View_setPreferredFramesPerSecond :: proc(self: ^View, preferredFramesPerSecond: NS.Integer) { +View_setPreferredFramesPerSecond :: proc "c" (self: ^View, preferredFramesPerSecond: NS.Integer) { msgSend(nil, self, "setPreferredFramesPerSecond:", preferredFramesPerSecond) } @(objc_type=View, objc_name="preferredFramesPerSecond") -View_preferredFramesPerSecond :: proc(self: ^View) -> NS.Integer { +View_preferredFramesPerSecond :: proc "c" (self: ^View) -> NS.Integer { return msgSend(NS.Integer, self, "preferredFramesPerSecond") } @(objc_type=View, objc_name="setEnableSetNeedsDisplay") -View_setEnableSetNeedsDisplay :: proc(self: ^View, enableSetNeedsDisplay: bool) { +View_setEnableSetNeedsDisplay :: proc "c" (self: ^View, enableSetNeedsDisplay: bool) { msgSend(nil, self, "setEnableSetNeedsDisplay:", enableSetNeedsDisplay) } @(objc_type=View, objc_name="enableSetNeedsDisplay") -View_enableSetNeedsDisplay :: proc(self: ^View) -> bool { +View_enableSetNeedsDisplay :: proc "c" (self: ^View) -> bool { return msgSend(bool, self, "enableSetNeedsDisplay") } @(objc_type=View, objc_name="setAutoresizeDrawable") -View_setAutoresizeDrawable :: proc(self: ^View, autoresizeDrawable: bool) { +View_setAutoresizeDrawable :: proc "c" (self: ^View, autoresizeDrawable: bool) { msgSend(nil, self, "setAutoresizeDrawable:", autoresizeDrawable) } @(objc_type=View, objc_name="autoresizeDrawable") -View_autoresizeDrawable :: proc(self: ^View) -> bool { +View_autoresizeDrawable :: proc "c" (self: ^View) -> bool { return msgSend(bool, self, "autoresizeDrawable") } @(objc_type=View, objc_name="setDrawableSize") -View_setDrawableSize :: proc(self: ^View, drawableSize: NS.Size) { +View_setDrawableSize :: proc "c" (self: ^View, drawableSize: NS.Size) { msgSend(nil, self, "setDrawableSize:", drawableSize) } @(objc_type=View, objc_name="drawableSize") -View_drawableSize :: proc(self: ^View) -> NS.Size { +View_drawableSize :: proc "c" (self: ^View) -> NS.Size { return msgSend(NS.Size, self, "drawableSize") } @(objc_type=View, objc_name="preferredDrawableSize") -View_preferredDrawableSize :: proc(self: ^View) -> NS.Size { +View_preferredDrawableSize :: proc "c" (self: ^View) -> NS.Size { return msgSend(NS.Size, self, "preferredDrawableSize") } @(objc_type=View, objc_name="preferredDevice") -View_preferredDevice :: proc(self: ^View) -> ^MTL.Device { +View_preferredDevice :: proc "c" (self: ^View) -> ^MTL.Device { return msgSend(^MTL.Device, self, "preferredDevice") } @(objc_type=View, objc_name="setPaused") -View_setPaused :: proc(self: ^View, isPaused: bool) { +View_setPaused :: proc "c" (self: ^View, isPaused: bool) { msgSend(nil, self, "setPaused:", isPaused) } @(objc_type=View, objc_name="isPaused") -View_isPaused :: proc(self: ^View) -> bool { +View_isPaused :: proc "c" (self: ^View) -> bool { return msgSend(bool, self, "isPaused") } @(objc_type=View, objc_name="setColorSpace") -View_setColorSpace :: proc(self: ^View, colorSpace: ColorSpaceRef) { +View_setColorSpace :: proc "c" (self: ^View, colorSpace: ColorSpaceRef) { msgSend(nil, self, "setColorSpace:", colorSpace) } @(objc_type=View, objc_name="colorSpace") -View_colorSpace :: proc(self: ^View) -> ColorSpaceRef { +View_colorSpace :: proc "c" (self: ^View) -> ColorSpaceRef { return msgSend(ColorSpaceRef, self, "colorSpace") } diff --git a/vendor/darwin/QuartzCore/QuartzCore.odin b/vendor/darwin/QuartzCore/QuartzCore.odin index fb6e04b07..53dde3e94 100644 --- a/vendor/darwin/QuartzCore/QuartzCore.odin +++ b/vendor/darwin/QuartzCore/QuartzCore.odin @@ -11,63 +11,74 @@ msgSend :: intrinsics.objc_send MetalLayer :: struct{ using _: NS.Layer} @(objc_type=MetalLayer, objc_name="layer", objc_is_class_method=true) -MetalLayer_layer :: proc() -> ^MetalLayer { +MetalLayer_layer :: proc "c" () -> ^MetalLayer { return msgSend(^MetalLayer, MetalLayer, "layer") } @(objc_type=MetalLayer, objc_name="device") -MetalLayer_device :: proc(self: ^MetalLayer) -> ^MTL.Device { +MetalLayer_device :: proc "c" (self: ^MetalLayer) -> ^MTL.Device { return msgSend(^MTL.Device, self, "device") } @(objc_type=MetalLayer, objc_name="setDevice") -MetalLayer_setDevice :: proc(self: ^MetalLayer, device: ^MTL.Device) { +MetalLayer_setDevice :: proc "c" (self: ^MetalLayer, device: ^MTL.Device) { msgSend(nil, self, "setDevice:", device) } @(objc_type=MetalLayer, objc_name="opaque") -MetalLayer_opaque :: proc(self: ^MetalLayer) -> NS.BOOL { +MetalLayer_opaque :: proc "c" (self: ^MetalLayer) -> NS.BOOL { return msgSend(NS.BOOL, self, "opaque") } @(objc_type=MetalLayer, objc_name="setOpaque") -MetalLayer_setOpaque :: proc(self: ^MetalLayer, opaque: NS.BOOL) { +MetalLayer_setOpaque :: proc "c" (self: ^MetalLayer, opaque: NS.BOOL) { msgSend(nil, self, "setOpaque:", opaque) } @(objc_type=MetalLayer, objc_name="preferredDevice") -MetalLayer_preferredDevice :: proc(self: ^MetalLayer) -> ^MTL.Device { +MetalLayer_preferredDevice :: proc "c" (self: ^MetalLayer) -> ^MTL.Device { return msgSend(^MTL.Device, self, "preferredDevice") } @(objc_type=MetalLayer, objc_name="pixelFormat") -MetalLayer_pixelFormat :: proc(self: ^MetalLayer) -> MTL.PixelFormat { +MetalLayer_pixelFormat :: proc "c" (self: ^MetalLayer) -> MTL.PixelFormat { return msgSend(MTL.PixelFormat, self, "pixelFormat") } @(objc_type=MetalLayer, objc_name="setPixelFormat") -MetalLayer_setPixelFormat :: proc(self: ^MetalLayer, pixelFormat: MTL.PixelFormat) { +MetalLayer_setPixelFormat :: proc "c" (self: ^MetalLayer, pixelFormat: MTL.PixelFormat) { msgSend(nil, self, "setPixelFormat:", pixelFormat) } @(objc_type=MetalLayer, objc_name="framebufferOnly") -MetalLayer_framebufferOnly :: proc(self: ^MetalLayer) -> NS.BOOL { +MetalLayer_framebufferOnly :: proc "c" (self: ^MetalLayer) -> NS.BOOL { return msgSend(NS.BOOL, self, "framebufferOnly") } @(objc_type=MetalLayer, objc_name="setFramebufferOnly") -MetalLayer_setFramebufferOnly :: proc(self: ^MetalLayer, ok: NS.BOOL) { +MetalLayer_setFramebufferOnly :: proc "c" (self: ^MetalLayer, ok: NS.BOOL) { msgSend(nil, self, "setFramebufferOnly:", ok) } + +@(objc_type=MetalLayer, objc_name="drawableSize") +MetalLayer_drawableSize :: proc "c" (self: ^MetalLayer) -> NS.Size { + return msgSend(NS.Size, self, "drawableSize") +} +@(objc_type=MetalLayer, objc_name="setDrawableSize") +MetalLayer_setDrawableSize :: proc "c" (self: ^MetalLayer, drawableSize: NS.Size) { + msgSend(nil, self, "setDrawableSize:", drawableSize) +} + + @(objc_type=MetalLayer, objc_name="frame") -MetalLayer_frame :: proc(self: ^MetalLayer) -> NS.Rect { +MetalLayer_frame :: proc "c" (self: ^MetalLayer) -> NS.Rect { return msgSend(NS.Rect, self, "frame") } @(objc_type=MetalLayer, objc_name="setFrame") -MetalLayer_setFrame :: proc(self: ^MetalLayer, frame: NS.Rect) { +MetalLayer_setFrame :: proc "c" (self: ^MetalLayer, frame: NS.Rect) { msgSend(nil, self, "setFrame:", frame) } @(objc_type=MetalLayer, objc_name="nextDrawable") -MetalLayer_nextDrawable :: proc(self: ^MetalLayer) -> ^MetalDrawable { +MetalLayer_nextDrawable :: proc "c" (self: ^MetalLayer) -> ^MetalDrawable { return msgSend(^MetalDrawable, self, "nextDrawable") } @@ -77,11 +88,11 @@ MetalLayer_nextDrawable :: proc(self: ^MetalLayer) -> ^MetalDrawable { MetalDrawable :: struct { using _: MTL.Drawable } @(objc_type=MetalDrawable, objc_name="layer") -MetalDrawable_layer :: proc(self: ^MetalDrawable) -> ^MetalLayer { +MetalDrawable_layer :: proc "c" (self: ^MetalDrawable) -> ^MetalLayer { return msgSend(^MetalLayer, self, "layer") } @(objc_type=MetalDrawable, objc_name="texture") -MetalDrawable_texture :: proc(self: ^MetalDrawable) -> ^MTL.Texture { +MetalDrawable_texture :: proc "c" (self: ^MetalDrawable) -> ^MTL.Texture { return msgSend(^MTL.Texture, self, "texture") } \ No newline at end of file diff --git a/vendor/directx/ThirdPartyNotices.txt b/vendor/directx/ThirdPartyNotices.txt new file mode 100644 index 000000000..be895839b --- /dev/null +++ b/vendor/directx/ThirdPartyNotices.txt @@ -0,0 +1,248 @@ +Microsoft/DirectXShaderCompiler + +THIRD-PARTY SOFTWARE NOTICES AND INFORMATION + +Do Not Translate or Localize + +This project incorporates components from the projects listed below. The +original copyright notices and the licenses under which Microsoft received +such components are set forth below. Microsoft reserves all rights not +expressly granted herein, whether by implication, estoppel or otherwise. + + +* LLVM + +============================================================================== +LLVM Release License +============================================================================== +University of Illinois/NCSA +Open Source License + +Copyright (c) 2003-2015 University of Illinois at Urbana-Champaign. +All rights reserved. + +Developed by: + + LLVM Team + + University of Illinois at Urbana-Champaign + + http://llvm.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal with +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimers. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimers in the + documentation and/or other materials provided with the distribution. + + * Neither the names of the LLVM Team, University of Illinois at + Urbana-Champaign, nor the names of its contributors may be used to + endorse or promote products derived from this Software without specific + prior written permission. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE +SOFTWARE. + +============================================================================== +Copyrights and Licenses for Third Party Software Distributed with LLVM: +============================================================================== +The LLVM software contains code written by third parties. Such software will +have its own individual LICENSE.TXT file in the directory in which it appears. +This file will describe the copyrights, license, and restrictions which apply +to that code. + +The disclaimer of warranty in the University of Illinois Open Source License +applies to all code in the LLVM Distribution, and nothing in any of the +other licenses gives permission to use the names of the LLVM Team or the +University of Illinois to endorse or promote products derived from this +Software. + +The following pieces of software have additional or alternate copyrights, +licenses, and/or restrictions: + +Program Directory +------- --------- +OpenBSD regex llvm/lib/Support/{reg*, COPYRIGHT.regex} +pyyaml tests llvm/test/YAMLParser/{*.data, LICENSE.TXT} +md5 contributions llvm/lib/Support/MD5.cpp llvm/include/llvm/Support/MD5.h + + +* tools\clang + +============================================================================== +LLVM Release License +============================================================================== +University of Illinois/NCSA +Open Source License + +Copyright (c) 2007-2015 University of Illinois at Urbana-Champaign. +All rights reserved. + +Developed by: + + LLVM Team + + University of Illinois at Urbana-Champaign + + http://llvm.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal with +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimers. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimers in the + documentation and/or other materials provided with the distribution. + + * Neither the names of the LLVM Team, University of Illinois at + Urbana-Champaign, nor the names of its contributors may be used to + endorse or promote products derived from this Software without specific + prior written permission. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE +SOFTWARE. + +============================================================================== +The LLVM software contains code written by third parties. Such software will +have its own individual LICENSE.TXT file in the directory in which it appears. +This file will describe the copyrights, license, and restrictions which apply +to that code. + +The disclaimer of warranty in the University of Illinois Open Source License +applies to all code in the LLVM Distribution, and nothing in any of the +other licenses gives permission to use the names of the LLVM Team or the +University of Illinois to endorse or promote products derived from this +Software. + + +* test\YAMLParser + +Copyright (c) 2006 Kirill Simonov + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +* include\llvm\Support + +LLVM System Interface Library +------------------------------------------------------------------------------- +The LLVM System Interface Library is licensed under the Illinois Open Source +License and has the following additional copyright: + +Copyright (C) 2004 eXtensible Systems, Inc. + +* OpenBSD regex + +$OpenBSD: COPYRIGHT,v 1.3 2003/06/02 20:18:36 millert Exp $ + +Copyright 1992, 1993, 1994 Henry Spencer. All rights reserved. +This software is not subject to any license of the American Telephone +and Telegraph Company or of the Regents of the University of California. + +Permission is granted to anyone to use this software for any purpose on +any computer system, and to alter it and redistribute it, subject +to the following restrictions: + +1. The author is not responsible for the consequences of use of this + software, no matter how awful, even if they arise from flaws in it. + +2. The origin of this software must not be misrepresented, either by + explicit claim or by omission. Since few users ever read sources, + credits must appear in the documentation. + +3. Altered versions must be plainly marked as such, and must not be + misrepresented as being the original software. Since few users + ever read sources, credits must appear in the documentation. + +4. This notice may not be removed or altered. + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +/*- + * Copyright (c) 1994 + * The Regents of the University of California. 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 University 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 REGENTS 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 REGENTS 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. + * + * @(#)COPYRIGHT 8.1 (Berkeley) 3/16/94 + */ + +* lib\Headers Files + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/vendor/directx/d3d11/d3d11.odin b/vendor/directx/d3d11/d3d11.odin index fe8671b63..fd2824d23 100644 --- a/vendor/directx/d3d11/d3d11.odin +++ b/vendor/directx/d3d11/d3d11.odin @@ -2384,7 +2384,7 @@ IDeviceContext_VTable :: struct { GSSetSamplers: proc "stdcall" (this: ^IDeviceContext, StartSlot: u32, NumSamplers: u32, ppSamplers: ^^ISamplerState), OMSetRenderTargets: proc "stdcall" (this: ^IDeviceContext, NumViews: u32, ppRenderTargetViews: ^^IRenderTargetView, pDepthStencilView: ^IDepthStencilView), OMSetRenderTargetsAndUnorderedAccessViews: proc "stdcall" (this: ^IDeviceContext, NumRTVs: u32, ppRenderTargetViews: ^^IRenderTargetView, pDepthStencilView: ^IDepthStencilView, UAVStartSlot: u32, NumUAVs: u32, ppUnorderedAccessViews: ^^IUnorderedAccessView, pUAVInitialCounts: ^u32), - OMSetBlendState: proc "stdcall" (this: ^IDeviceContext, pBlendState: ^IBlendState, BlendFactor: ^[4]f32, SampleMask: COLOR_WRITE_ENABLE_MASK), + OMSetBlendState: proc "stdcall" (this: ^IDeviceContext, pBlendState: ^IBlendState, BlendFactor: ^[4]f32, SampleMask: u32), OMSetDepthStencilState: proc "stdcall" (this: ^IDeviceContext, pDepthStencilState: ^IDepthStencilState, StencilRef: u32), SOSetTargets: proc "stdcall" (this: ^IDeviceContext, NumBuffers: u32, ppSOTargets: ^^IBuffer, pOffsets: ^u32), DrawAuto: proc "stdcall" (this: ^IDeviceContext), @@ -5131,4 +5131,4 @@ MESSAGE_ID :: enum u32 { END_TRACKED_WORKLOAD_INVALID_ARG, TRACKED_WORKLOAD_DISJOINT_FAILURE, D3D11_5_MESSAGES_END, -} \ No newline at end of file +} diff --git a/vendor/directx/d3d12/d3d12.odin b/vendor/directx/d3d12/d3d12.odin index b2e2d52df..9c61aacbe 100644 --- a/vendor/directx/d3d12/d3d12.odin +++ b/vendor/directx/d3d12/d3d12.odin @@ -1226,7 +1226,7 @@ HEAP_FLAG :: enum u32 { } HEAP_FLAG_ALLOW_ALL_BUFFERS_AND_TEXTURES :: HEAP_FLAGS{} -HEAP_FLAG_ALLOW_ONLY_BUFFERS :: HEAP_FLAGS{.DENY_BUFFERS, .ALLOW_DISPLAY} +HEAP_FLAG_ALLOW_ONLY_BUFFERS :: HEAP_FLAGS{.DENY_RT_DS_TEXTURES, .DENY_NON_RT_DS_TEXTURES} HEAP_FLAG_ALLOW_ONLY_NON_RT_DS_TEXTURES :: HEAP_FLAGS{.DENY_BUFFERS, .DENY_RT_DS_TEXTURES} HEAP_FLAG_ALLOW_ONLY_RT_DS_TEXTURES :: HEAP_FLAGS{.DENY_BUFFERS, .DENY_NON_RT_DS_TEXTURES} @@ -1992,6 +1992,8 @@ ROOT_SIGNATURE_FLAG :: enum u32 { LOCAL_ROOT_SIGNATURE = 7, DENY_AMPLIFICATION_SHADER_ROOT_ACCESS = 8, DENY_MESH_SHADER_ROOT_ACCESS = 9, + CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED = 10, + SAMPLER_HEAP_DIRECTLY_INDEXED = 11, } STATIC_BORDER_COLOR :: enum i32 { @@ -2543,7 +2545,7 @@ IDevice_VTable :: struct { CreateSampler: proc "stdcall" (this: ^IDevice, pDesc: ^SAMPLER_DESC, DestDescriptor: CPU_DESCRIPTOR_HANDLE), CopyDescriptors: proc "stdcall" (this: ^IDevice, NumDestDescriptorRanges: u32, pDestDescriptorRangeStarts: ^CPU_DESCRIPTOR_HANDLE, pDestDescriptorRangeSizes: ^u32, NumSrcDescriptorRanges: u32, pSrcDescriptorRangeStarts: ^CPU_DESCRIPTOR_HANDLE, pSrcDescriptorRangeSizes: ^u32, DescriptorHeapsType: DESCRIPTOR_HEAP_TYPE), CopyDescriptorsSimple: proc "stdcall" (this: ^IDevice, NumDescriptors: u32, DestDescriptorRangeStart: CPU_DESCRIPTOR_HANDLE, SrcDescriptorRangeStart: CPU_DESCRIPTOR_HANDLE, DescriptorHeapsType: DESCRIPTOR_HEAP_TYPE), - GetResourceAllocationInfo: proc "stdcall" (this: ^IDevice, visibleMask: u32, numResourceDescs: u32, pResourceDescs: ^RESOURCE_DESC) -> RESOURCE_ALLOCATION_INFO, + GetResourceAllocationInfo: proc "stdcall" (this: ^IDevice, RetVal: ^RESOURCE_ALLOCATION_INFO, visibleMask: u32, numResourceDescs: u32, pResourceDescs: ^RESOURCE_DESC), GetCustomHeapProperties: proc "stdcall" (this: ^IDevice, nodeMask: u32, heapType: HEAP_TYPE) -> HEAP_PROPERTIES, CreateCommittedResource: proc "stdcall" (this: ^IDevice, pHeapProperties: ^HEAP_PROPERTIES, HeapFlags: HEAP_FLAGS, pDesc: ^RESOURCE_DESC, InitialResourceState: RESOURCE_STATES, pOptimizedClearValue: ^CLEAR_VALUE, riidResource: ^IID, ppvResource: ^rawptr) -> HRESULT, CreateHeap: proc "stdcall" (this: ^IDevice, pDesc: ^HEAP_DESC, riid: ^IID, ppvHeap: ^rawptr) -> HRESULT, @@ -2728,7 +2730,7 @@ IDevice4_VTable :: struct { CreateCommittedResource1: proc "stdcall" (this: ^IDevice4, pHeapProperties: ^HEAP_PROPERTIES, HeapFlags: HEAP_FLAGS, pDesc: ^RESOURCE_DESC, InitialResourceState: RESOURCE_STATES, pOptimizedClearValue: ^CLEAR_VALUE, pProtectedSession: ^IProtectedResourceSession, riidResource: ^IID, ppvResource: ^rawptr) -> HRESULT, CreateHeap1: proc "stdcall" (this: ^IDevice4, pDesc: ^HEAP_DESC, pProtectedSession: ^IProtectedResourceSession, riid: ^IID, ppvHeap: ^rawptr) -> HRESULT, CreateReservedResource1: proc "stdcall" (this: ^IDevice4, pDesc: ^RESOURCE_DESC, InitialState: RESOURCE_STATES, pOptimizedClearValue: ^CLEAR_VALUE, pProtectedSession: ^IProtectedResourceSession, riid: ^IID, ppvResource: ^rawptr) -> HRESULT, - GetResourceAllocationInfo1: proc "stdcall" (this: ^IDevice4, visibleMask: u32, numResourceDescs: u32, pResourceDescs: ^RESOURCE_DESC, pResourceAllocationInfo1: ^RESOURCE_ALLOCATION_INFO1) -> RESOURCE_ALLOCATION_INFO, + GetResourceAllocationInfo1: proc "stdcall" (this: ^IDevice4, RetVal: ^RESOURCE_ALLOCATION_INFO, visibleMask: u32, numResourceDescs: u32, pResourceDescs: ^RESOURCE_DESC, pResourceAllocationInfo1: ^RESOURCE_ALLOCATION_INFO1), } LIFETIME_STATE :: enum i32 { @@ -3516,7 +3518,7 @@ IDevice8 :: struct #raw_union { } IDevice8_VTable :: struct { using id3d12device7_vtable: IDevice7_VTable, - GetResourceAllocationInfo2: proc "stdcall" (this: ^IDevice8, visibleMask: u32, numResourceDescs: u32, pResourceDescs: ^RESOURCE_DESC1, pResourceAllocationInfo1: ^RESOURCE_ALLOCATION_INFO1) -> RESOURCE_ALLOCATION_INFO, + GetResourceAllocationInfo2: proc "stdcall" (this: ^IDevice8, RetVal: ^RESOURCE_ALLOCATION_INFO, visibleMask: u32, numResourceDescs: u32, pResourceDescs: ^RESOURCE_DESC1, pResourceAllocationInfo1: ^RESOURCE_ALLOCATION_INFO1), CreateCommittedResource2: proc "stdcall" (this: ^IDevice8, pHeapProperties: ^HEAP_PROPERTIES, HeapFlags: HEAP_FLAGS, pDesc: ^RESOURCE_DESC1, InitialResourceState: RESOURCE_STATES, pOptimizedClearValue: ^CLEAR_VALUE, pProtectedSession: ^IProtectedResourceSession, riidResource: ^IID, ppvResource: ^rawptr) -> HRESULT, CreatePlacedResource1: proc "stdcall" (this: ^IDevice8, pHeap: ^IHeap, HeapOffset: u64, pDesc: ^RESOURCE_DESC1, InitialState: RESOURCE_STATES, pOptimizedClearValue: ^CLEAR_VALUE, riid: ^IID, ppvResource: ^rawptr) -> HRESULT, CreateSamplerFeedbackUnorderedAccessView: proc "stdcall" (this: ^IDevice8, pTargetedResource: ^IResource, pFeedbackResource: ^IResource, DestDescriptor: CPU_DESCRIPTOR_HANDLE), @@ -4870,6 +4872,25 @@ IInfoQueue_VTable :: struct { GetMuteDebugOutput: proc "stdcall" (this: ^IInfoQueue) -> BOOL, } +MESSAGE_CALLBACK_FLAGS :: distinct bit_set[MESSAGE_CALLBACK_FLAG; u32] +MESSAGE_CALLBACK_FLAG :: enum { + IGNORE_FILTERS = 0, +} + +PFN_MESSAGE_CALLBACK :: #type proc "c" (Category: MESSAGE_CATEGORY, Severity: MESSAGE_SEVERITY, ID: MESSAGE_ID, pDescription: cstring, pContext: rawptr) + +IInfoQueue1_UUID_STRING :: "2852dd88-b484-4c0c-b6b1-67168500e600" +IInfoQueue1_UUID := &IID{0x2852dd88, 0xb484, 0x4c0c, {0xb6, 0xb1, 0x67, 0x16, 0x85, 0x00, 0xe6, 0x00}} +IInfoQueue1 :: struct #raw_union { + #subtype iinfo_queue: IInfoQueue, + using idxgiinfoqueue1_vtable: ^IInfoQueue1_VTable, +} +IInfoQueue1_VTable :: struct { + using idxgiinfoqueue_vtable: IInfoQueue_VTable, + RegisterMessageCallback: proc "stdcall" (this: ^IInfoQueue1, CallbackFunc: PFN_MESSAGE_CALLBACK, CallbackFilterFlags: MESSAGE_CALLBACK_FLAGS, pContext: rawptr, pCallbackCookie: ^u32) -> HRESULT, + UnregisterMessageCallback: proc "stdcall" (this: ^IInfoQueue1, pCallbackCookie: u32) -> HRESULT, +} + PFN_CREATE_DEVICE :: #type proc "c" (a0: ^IUnknown, a1: FEATURE_LEVEL, a2: ^IID, a3: ^rawptr) -> HRESULT PFN_GET_DEBUG_INTERFACE :: #type proc "c" (a0: ^IID, a1: ^rawptr) -> HRESULT @@ -4928,16 +4949,40 @@ IGraphicsCommandList6_VTable :: struct { DispatchMesh: proc "stdcall" (this: ^IGraphicsCommandList6, ThreadGroupCountX: u32, ThreadGroupCountY: u32, ThreadGroupCountZ: u32), } -SHADER_VERSION_TYPE :: enum i32 { - PIXEL_SHADER = 0, - VERTEX_SHADER = 1, - GEOMETRY_SHADER = 2, +SHADER_VERSION_TYPE :: enum u32 { + PIXEL_SHADER = 0, + VERTEX_SHADER = 1, + GEOMETRY_SHADER = 2, - HULL_SHADER = 3, - DOMAIN_SHADER = 4, - COMPUTE_SHADER = 5, + HULL_SHADER = 3, + DOMAIN_SHADER = 4, + COMPUTE_SHADER = 5, - RESERVED0 = 65520, + LIBRARY = 6, + + RAY_GENERATION_SHADER = 7, + INTERSECTION_SHADER = 8, + ANY_HIT_SHADER = 9, + CLOSEST_HIT_SHADER = 10, + MISS_SHADER = 11, + CALLABLE_SHADER = 12, + + MESH_SHADER = 13, + AMPLIFICATION_SHADER = 14, + + RESERVED0 = 0xFFF0, +} + +shver_get_type :: proc "contextless" (version: u32) -> SHADER_VERSION_TYPE { + return SHADER_VERSION_TYPE((version >> 16) & 0xffff) +} + +shver_get_major :: proc "contextless" (version: u32) -> u8 { + return u8((version >> 4) & 0xf) +} + +shver_get_minor :: proc "contextless" (version: u32) -> u8 { + return u8((version >> 0) & 0xf) } SIGNATURE_PARAMETER_DESC :: struct { @@ -4984,6 +5029,7 @@ SHADER_TYPE_DESC :: struct { Offset: u32, Name: cstring, } + SHADER_DESC :: struct { Version: u32, Creator: cstring, @@ -5042,6 +5088,39 @@ SHADER_INPUT_BIND_DESC :: struct { uID: u32, } +SHADER_REQUIRES_FLAGS :: distinct bit_set[SHADER_REQUIRES; u64] +SHADER_REQUIRES :: enum u64 { + DOUBLES = 0, + EARLY_DEPTH_STENCIL = 1, + UAVS_AT_EVERY_STAGE = 2, + _64_UAVS = 3, + MINIMUM_PRECISION = 4, + _11_1_DOUBLE_EXTENSIONS = 5, + _11_1_SHADER_EXTENSIONS = 6, + LEVEL_9_COMPARISON_FILTERING = 7, + TILED_RESOURCES = 8, + STENCIL_REF = 9, + INNER_COVERAGE = 10, + TYPED_UAV_LOAD_ADDITIONAL_FORMATS = 11, + ROVS = 12, + VIEWPORT_AND_RT_ARRAY_INDEX_FROM_ANY_SHADER_FEEDING_RASTERIZER = 13, + WAVE_OPS = 14, + INT64_OPS = 15, + VIEW_ID = 16, + BARYCENTRICS = 17, + NATIVE_16BIT_OPS = 18, + SHADING_RATE = 19, + RAYTRACING_TIER_1_1 = 20, + SAMPLER_FEEDBACK = 21, + ATOMIC_INT64_ON_TYPED_RESOURCE = 22, + ATOMIC_INT64_ON_GROUP_SHARED = 23, + DERIVATIVES_IN_MESH_AND_AMPLIFICATION_SHADERS = 24, + RESOURCE_DESCRIPTOR_HEAP_INDEXING = 25, + SAMPLER_DESCRIPTOR_HEAP_INDEXING = 26, + WAVE_MMA = 27, + ATOMIC_INT64_ON_DESCRIPTOR_HEAP_RESOURCE = 28, +} + LIBRARY_DESC :: struct { Creator: cstring, Flags: u32, @@ -5103,8 +5182,10 @@ PARAMETER_DESC :: struct { FirstOutComponent: u32, } +IShaderReflectionType_UUID_STRING :: "E913C351-783D-48CA-A1D1-4F306284AD56" +IShaderReflectionType_UUID := &IID{0xE913C351, 0x783D, 0x48CA, {0xA1, 0xD1, 0x4F, 0x30, 0x62, 0x84, 0xAD, 0x56}} IShaderReflectionType :: struct { - vtable: ^IShaderReflectionType_VTable, + using id3d12shaderreflectiontype_vtable: ^IShaderReflectionType_VTable, } IShaderReflectionType_VTable :: struct { GetDesc: proc "stdcall" (this: ^IShaderReflectionType, pDesc: ^SHADER_TYPE_DESC) -> HRESULT, @@ -5120,8 +5201,10 @@ IShaderReflectionType_VTable :: struct { ImplementsInterface: proc "stdcall" (this: ^IShaderReflectionType, pBase: ^IShaderReflectionType) -> HRESULT, } +IShaderReflectionVariable_UUID_STRING :: "8337A8A6-A216-444A-B2F4-314733A73AEA" +IShaderReflectionVariable_UUID := &IID{0x8337A8A6, 0xA216, 0x444A, {0xB2, 0xF4, 0x31, 0x47, 0x33, 0xA7, 0x3A, 0xEA}} IShaderReflectionVariable :: struct { - vtable: ^IShaderReflectionVariable_VTable, + using id3d12shaderreflectionvariable_vtable: ^IShaderReflectionVariable_VTable, } IShaderReflectionVariable_VTable :: struct { GetDesc: proc "stdcall" (this: ^IShaderReflectionVariable, pDesc: ^SHADER_VARIABLE_DESC) -> HRESULT, @@ -5130,8 +5213,10 @@ IShaderReflectionVariable_VTable :: struct { GetInterfaceSlot: proc "stdcall" (this: ^IShaderReflectionVariable, uArrayIndex: u32) -> u32, } +IShaderReflectionConstantBuffer_UUID_STRING :: "C59598B4-48B3-4869-B9B1-B1618B14A8B7" +IShaderReflectionConstantBuffer_UUID := &IID{0xC59598B4, 0x48B3, 0x4869, {0xB9, 0xB1, 0xB1, 0x61, 0x8B, 0x14, 0xA8, 0xB7}} IShaderReflectionConstantBuffer :: struct { - vtable: ^IShaderReflectionConstantBuffer_VTable, + using id3d12shaderreflectionconstantbuffer_vtable: ^IShaderReflectionConstantBuffer_VTable, } IShaderReflectionConstantBuffer_VTable :: struct { GetDesc: proc "stdcall" (this: ^IShaderReflectionConstantBuffer, pDesc: ^SHADER_BUFFER_DESC) -> HRESULT, @@ -5139,6 +5224,8 @@ IShaderReflectionConstantBuffer_VTable :: struct { GetVariableByName: proc "stdcall" (this: ^IShaderReflectionConstantBuffer, Name: cstring) -> ^IShaderReflectionVariable, } +IShaderReflection_UUID_STRING :: "5A58797D-A72C-478D-8BA2-EFC6B0EFE88E" +IShaderReflection_UUID := &IID{0x5A58797D, 0xA72C, 0x478D, {0x8B, 0xA2, 0xEF, 0xC6, 0xB0, 0xEF, 0xE8, 0x8E}} IShaderReflection :: struct #raw_union { #subtype iunknown: IUnknown, using id3d12shaderreflection_vtable: ^IShaderReflection_VTable, @@ -5163,9 +5250,11 @@ IShaderReflection_VTable :: struct { GetNumInterfaceSlots: proc "stdcall" (this: ^IShaderReflection) -> u32, GetMinFeatureLevel: proc "stdcall" (this: ^IShaderReflection, pLevel: ^FEATURE_LEVEL) -> HRESULT, GetThreadGroupSize: proc "stdcall" (this: ^IShaderReflection, pSizeX: ^u32, pSizeY: ^u32, pSizeZ: ^u32) -> u32, - GetRequiresFlags: proc "stdcall" (this: ^IShaderReflection) -> u64, + GetRequiresFlags: proc "stdcall" (this: ^IShaderReflection) -> SHADER_REQUIRES_FLAGS, } +ILibraryReflection_UUID_STRING :: "8E349D19-54DB-4A56-9DC9-119D87BDB804" +ILibraryReflection_UUID := &IID{0x8E349D19, 0x54DB, 0x4A56, {0x9D, 0xC9, 0x11, 0x9D, 0x87, 0xBD, 0xB8, 0x04}} ILibraryReflection :: struct #raw_union { #subtype iunknown: IUnknown, using id3d12libraryreflection_vtable: ^ILibraryReflection_VTable, @@ -5176,8 +5265,10 @@ ILibraryReflection_VTable :: struct { GetFunctionByIndex: proc "stdcall" (this: ^ILibraryReflection, FunctionIndex: i32) -> ^IFunctionReflection, } +IFunctionReflection_UUID_STRING :: "1108795C-2772-4BA9-B2A8-D464DC7E2799" +IFunctionReflection_UUID := &IID{0x1108795C, 0x2772, 0x4BA9, {0xB2, 0xA8, 0xD4, 0x64, 0xDC, 0x7E, 0x27, 0x99}} IFunctionReflection :: struct { - vtable: ^IFunctionReflection_VTable, + using id3d12functionreflection_vtable: ^IFunctionReflection_VTable, } IFunctionReflection_VTable :: struct { GetDesc: proc "stdcall" (this: ^IFunctionReflection, pDesc: ^FUNCTION_DESC) -> HRESULT, @@ -5189,8 +5280,10 @@ IFunctionReflection_VTable :: struct { GetFunctionParameter: proc "stdcall" (this: ^IFunctionReflection, ParameterIndex: i32) -> ^IFunctionParameterReflection, } +IFunctionParameterReflection_UUID_STRING :: "EC25F42D-7006-4F2B-B33E-02CC3375733F" +IFunctionParameterReflection_UUID := &IID{0xEC25F42D, 0x7006, 0x4F2B, {0xB3, 0x3E, 0x2, 0xCC, 0x33, 0x75, 0x73, 0x3F}} IFunctionParameterReflection :: struct { - vtable: ^IFunctionParameterReflection_VTable, + using id3d12functionparameterreflection_vtable: ^IFunctionParameterReflection_VTable, } IFunctionParameterReflection_VTable :: struct { GetDesc: proc "stdcall" (this: ^IFunctionParameterReflection, pDesc: ^PARAMETER_DESC) -> HRESULT, diff --git a/vendor/directx/dxc/dxcapi.odin b/vendor/directx/dxc/dxcapi.odin new file mode 100644 index 000000000..aa0bb8443 --- /dev/null +++ b/vendor/directx/dxc/dxcapi.odin @@ -0,0 +1,603 @@ +package directx_dxc +import win32 "core:sys/windows" +import dxgi "vendor:directx/dxgi" +foreign import "dxcompiler.lib" + +BOOL :: dxgi.BOOL +SIZE_T :: dxgi.SIZE_T +ULONG :: dxgi.ULONG +CLSID :: dxgi.GUID +IID :: dxgi.IID +HRESULT :: dxgi.HRESULT +IUnknown :: dxgi.IUnknown +IUnknown_VTable :: dxgi.IUnknown_VTable +wstring :: win32.wstring +FILETIME :: win32.FILETIME +BSTR :: wstring + +@(default_calling_convention="c", link_prefix="Dxc") +foreign dxcompiler { + CreateInstance :: proc (rclsid: ^CLSID, riid: ^IID, ppv: rawptr) -> HRESULT --- + CreateInstance2 :: proc (pMalloc: ^IMalloc, rclsid: ^CLSID, riid: ^IID, ppv: rawptr) -> HRESULT --- +} + +pCreateInstanceProc :: #type proc "c" (rclsid: ^CLSID, riid: ^IID, ppv: rawptr) -> HRESULT +pCreateInstance2Proc :: #type proc "c" (pMalloc: ^IMalloc, rclsid: ^CLSID, riid: ^IID, ppv: rawptr) -> HRESULT + +CreateInstance_ProcName :: "DxcCreateInstance" +CreateInstance2_ProcName :: "DxcCreateInstance2" + +IMalloc :: struct #raw_union { + #subtype iunknown: IUnknown, + using imalloc_vtable: ^IMalloc_VTable, +} +IMalloc_VTable :: struct { + using iunknown_vtable: IUnknown_VTable, + Alloc: proc "stdcall" (this: ^IMalloc, cb: SIZE_T) -> rawptr, + Realloc: proc "stdcall" (this: ^IMalloc, pv: rawptr, cb: SIZE_T) -> rawptr, + Free: proc "stdcall" (this: ^IMalloc, pv: rawptr), + GetSize: proc "stdcall" (this: ^IMalloc, pv: rawptr) -> SIZE_T, + DidAlloc: proc "stdcall" (this: ^IMalloc, pv: rawptr) -> i32, + HeapMinimize: proc "stdcall" (this: ^IMalloc), +} + +ISequentialStream :: struct #raw_union { + #subtype iunknown: IUnknown, + using isequentialstream_vtable: ^ISequentialStream_VTable, +} +ISequentialStream_VTable :: struct { + using iunknown_vtable: IUnknown_VTable, + Read: proc "stdcall" (this: ^ISequentialStream, pv: rawptr, cb: ULONG, pcbRead: ^ULONG) -> HRESULT, + Write: proc "stdcall" (this: ^ISequentialStream, pv: rawptr, cb: ULONG, pcbWritten: ^ULONG) -> HRESULT, +} + +STATSTG :: struct { + pwcsName: wstring, + type: u32, + cbSize: u64, + mtime: FILETIME, + ctime: FILETIME, + atime: FILETIME, + grfMode: u32, + grfLocksSupported: u32, + clsid: CLSID, + grfStateBits: u32, + reserved: u32, +} + +IStream :: struct #raw_union { + #subtype isequentialstream: ISequentialStream, + using istream_vtable: ^IStream_VTable, +} +IStream_VTable :: struct { + using isequentialstream_vtable: ISequentialStream_VTable, + Seek: proc "stdcall" (this: ^IStream, dlibMove: i64, dwOrigin: u32, plibNewPosition: ^u64) -> HRESULT, + SetSize: proc "stdcall" (this: ^IStream, libNewSize: u64) -> HRESULT, + CopyTo: proc "stdcall" (this: ^IStream, pstm: ^IStream, cb: u64, pcbRead: ^u64, pcbWritten: ^u64) -> HRESULT, + Commit: proc "stdcall" (this: ^IStream, grfCommitFlags: u32) -> HRESULT, + Revert: proc "stdcall" (this: ^IStream) -> HRESULT, + LockRegion: proc "stdcall" (this: ^IStream, libOffset: u64, cb: u64, dwLockType: u32) -> HRESULT, + UnlockRegion: proc "stdcall" (this: ^IStream, libOffset: u64, cb: u64, dwLockType: u32) -> HRESULT, + Stat: proc "stdcall" (this: ^IStream, pstatstg: ^STATSTG, grfStatFlag: u32) -> HRESULT, + Clone: proc "stdcall" (this: ^IStream, ppstm: ^^IStream) -> HRESULT, +} + +IBlob_UUID_STRING :: "8BA5FB08-5195-40E2-AC58-0D989C3A0102" +IBlob_UUID := &IID{0x8BA5FB08, 0x5195, 0x40E2, {0xAC, 0x58, 0x0D, 0x98, 0x9C, 0x3A, 0x01, 0x02}} +IBlob :: struct #raw_union { + #subtype iunknown: IUnknown, + using id3d10blob_vtable: ^IBlob_VTable, +} +IBlob_VTable :: struct { + using iunknown_vtable: IUnknown_VTable, + GetBufferPointer: proc "stdcall" (this: ^IBlob) -> rawptr, + GetBufferSize: proc "stdcall" (this: ^IBlob) -> SIZE_T, +} + +IBlobEncoding_UUID_STRRING :: "7241D424-2646-4191-97C0-98E96E42FC68" +IBlobEncoding_UUID := &IID{0x7241D424, 0x2646, 0x4191, {0x97, 0xC0, 0x98, 0xE9, 0x6E, 0x42, 0xFC, 0x68}} +IBlobEncoding :: struct #raw_union { + #subtype idxcblob: IBlob, + using idxcblobencoding_vtable: ^IBlobEncoding_VTable, +} +IBlobEncoding_VTable :: struct { + using idxcblob_vtable: IBlob_VTable, + GetEncoding: proc "stdcall" (this: ^IBlobEncoding, pKnown: ^BOOL, pCodePage: ^u32) -> HRESULT, +} + +IBlobUtf16_UUID_STRING :: "A3F84EAB-0FAA-497E-A39C-EE6ED60B2D84" +IBlobUtf16_UUID := &IID{0xA3F84EAB, 0x0FAA, 0x497E, {0xA3, 0x9C, 0xEE, 0x6E, 0xD6, 0x0B, 0x2D, 0x84}} +IBlobUtf16 :: struct #raw_union { + #subtype idxcblobencoding: IBlobEncoding, + using idxcblobutf16_vtable : ^IBlobUtf16_VTable, +} +IBlobUtf16_VTable :: struct { + using idxcblobencoding_vtable: IBlobEncoding_VTable, + GetStringPointer: proc "stdcall" (this: ^IBlobUtf16) -> wstring, + GetStringLength: proc "stdcall" (this: ^IBlobUtf16) -> SIZE_T, +} + +IBlobUtf8_UUID_STRING :: "3DA636C9-BA71-4024-A301-30CBF125305B" +IBlobUtf8_UUID := &IID{0x3DA636C9, 0xBA71, 0x4024, {0xA3, 0x01, 0x30, 0xCB, 0xF1, 0x25, 0x30, 0x5B}} +IBlobUtf8 :: struct #raw_union { + #subtype idxcblobencoding: IBlobEncoding, + using idxcblobutf8_vtable : ^IBlobUtf8_VTable, +} +IBlobUtf8_VTable :: struct { + using idxcblobencoding_vtable: IBlobEncoding_VTable, + GetStringPointer: proc "stdcall" (this: ^IBlobUtf8) -> cstring, + GetStringLength: proc "stdcall" (this: ^IBlobUtf8) -> SIZE_T, +} + +IIncludeHandler_UUID_STRING :: "7F61FC7D-950D-467F-B3E3-3C02FB49187C" +IIncludeHandler_UUID := &IID{0x7F61FC7D, 0x950D, 0x467F, {0xB3, 0xE3, 0x3C, 0x02, 0xFB, 0x49, 0x18, 0x7C}} +IIncludeHandler :: struct #raw_union { + #subtype iunknown: IUnknown, + using idxcincludehandler_vtable: ^IIncludeHandler_VTable, +} +IIncludeHandler_VTable :: struct { + using iunknown_vtable: IUnknown_VTable, + LoadSource: proc "stdcall" (this: ^IIncludeHandler, pFilename: wstring, ppIncludeSource: ^^IBlob) -> HRESULT, +} + +Define :: struct { + Name: wstring, + Value: wstring, +} + +ICompilerArgs_UUID_STRING :: "73EFFE2A-70DC-45F8-9690-EFF64C02429D" +ICompilerArgs_UUID := &IID{0x73EFFE2A, 0x70DC, 0x45F8, {0x96, 0x90, 0xEF, 0xF6, 0x4C, 0x02, 0x42, 0x9D}} +ICompilerArgs :: struct #raw_union { + #subtype iunknown: IUnknown, + using idxccompilerargs_vtable: ^ICompilerArgs_VTable, +} +ICompilerArgs_VTable :: struct { + using iunknown_vtable: IUnknown_VTable, + GetArguments: proc "stdcall" (this: ^ICompilerArgs) -> [^]wstring, + GetCount: proc "stdcall" (this: ^ICompilerArgs) -> u32, + AddArguments: proc "stdcall" (this: ^ICompilerArgs, pArguments: [^]wstring, argCount: u32) -> HRESULT, + AddArgumentsUTF8: proc "stdcall" (this: ^ICompilerArgs, pArguments: [^]cstring, argCount: u32) -> HRESULT, + AddDefines: proc "stdcall" (this: ^ICompilerArgs, pDefines: [^]Define, defineCount: u32) -> HRESULT, +} + +ILibrary_UUID_STRING :: "E5204DC7-D18C-4C3C-BDFB-851673980FE7" +ILibrary_UUID := &IID{0xE5204DC7, 0xD18C, 0x4C3C, {0xBD, 0xFB, 0x85, 0x16, 0x73, 0x98, 0x0F, 0xE7}} +ILibrary :: struct #raw_union { + #subtype iunknown: IUnknown, + using idxclibrary_vtable: ^ILibrary_VTable, +} +ILibrary_VTable :: struct { + using iunknown_vtable: IUnknown_VTable, + SetMalloc: proc "stdcall" (this: ^ILibrary, pMalloc: ^IMalloc) -> HRESULT, + CreateBlobFromBlob: proc "stdcall" (this: ^ILibrary, pBlob: ^IBlob, offset: u32, length: u32, ppResult: ^^IBlob) -> HRESULT, + CreateBlobFromFile: proc "stdcall" (this: ^ILibrary, pFileName: wstring, codePage: ^u32, pBlobEncoding: ^^IBlobEncoding) -> HRESULT, + CreateBlobWithEncodingFromPinned: proc "stdcall" (this: ^ILibrary, pText: rawptr, size: u32, codePage: u32, pBlobEncoding: ^^IBlobEncoding) -> HRESULT, + CreateBlobWithEncodingOnHeapCopy: proc "stdcall" (this: ^ILibrary, pText: rawptr, size: u32, codePage: u32, pBlobEncoding: ^^IBlobEncoding) -> HRESULT, + CreateBlobWithEncodingOnMalloc: proc "stdcall" (this: ^ILibrary, pText: rawptr, pIMalloc: ^IMalloc, size: u32, codePage: u32, pBlobEncoding: ^^IBlobEncoding) -> HRESULT, + CreateIncludeHandler: proc "stdcall" (this: ^ILibrary, ppResult: ^^IIncludeHandler) -> HRESULT, + CreateStreamFromBlobReadOnly: proc "stdcall" (this: ^ILibrary, pBlob: ^IBlob, ppStream: ^^IStream) -> HRESULT, + GetBlobAsUtf8: proc "stdcall" (this: ^ILibrary, pBlob: ^IBlob, pBlobEncoding: ^^IBlobEncoding) -> HRESULT, + GetBlobAsUtf16: proc "stdcall" (this: ^ILibrary, pBlob: ^IBlob, pBlobEncoding: ^^IBlobEncoding) -> HRESULT, +} + +IOperationResult_UUID_STRING :: "CEDB484A-D4E9-445A-B991-CA21CA157DC2" +IOperationResult_UUID := &IID{0xCEDB484A, 0xD4E9, 0x445A, {0xB9, 0x91, 0xCA, 0x21, 0xCA, 0x15, 0x7D, 0xC2}} +IOperationResult :: struct #raw_union { + #subtype iunknown: IUnknown, + using idxcoperationresult_vtable: ^IOperationResult_VTable, +} +IOperationResult_VTable :: struct { + using iunknown_vtable: IUnknown_VTable, + GetStatus: proc "stdcall" (this: ^IOperationResult, pStatus: ^HRESULT) -> HRESULT, + GetResult: proc "stdcall" (this: ^IOperationResult, ppResult: ^^IBlob) -> HRESULT, + GetErrorBuffer: proc "stdcall" (this: ^IOperationResult, ppErrors: ^^IBlobEncoding) -> HRESULT, +} + +ICompiler_UUID_STRING :: "8C210BF3-011F-4422-8D70-6F9ACB8DB617" +ICompiler_UUID := &IID{0x8C210BF3, 0x011F, 0x4422, {0x8D, 0x70, 0x6F, 0x9A, 0xCB, 0x8D, 0xB6, 0x17}} +ICompiler :: struct #raw_union { + #subtype iunknown: IUnknown, + using idxccompiler_vtable: ^ICompiler_VTable, +} +ICompiler_VTable :: struct { + using iunknown_vtable: IUnknown_VTable, + Compile: proc "stdcall" ( + this: ^ICompiler, + pSource: ^Buffer, + pSourceName: wstring, + pEntryPoint: wstring, + pTargetProfile: wstring, + pArguments: [^]wstring, + argCount: u32, + pDefines: [^]Define, + defineCount: u32, + pIncludeHandler: ^IIncludeHandler, + ppResult: ^^IOperationResult) -> HRESULT, + Preprocess: proc "stdcall" ( + this: ^ICompiler, + pSource: ^Buffer, + pSourceName: wstring, + pArguments: [^]wstring, + argCount: u32, + pDefines: [^]Define, + defineCount: u32, + pIncludeHandler: ^IIncludeHandler, + ppResult: ^^IOperationResult) -> HRESULT, + Disassemble: proc "stdcall" (this: ^ICompiler, pSource: ^Buffer, ppDisassembly: ^IBlobEncoding) -> HRESULT, +} + +ICompiler2_UUID_STRING :: "A005A9D9-B8BB-4594-B5C9-0E633BEC4D37" +ICompiler2_UUID := &IID{0xA005A9D9, 0xB8BB, 0x4594, {0xB5, 0xC9, 0x0E, 0x63, 0x3B, 0xEC, 0x4D, 0x37}} +ICompiler2 :: struct #raw_union { + #subtype icompiler: ICompiler, + using idxccompiler2_vtable: ^ICompiler2_VTable, +} +ICompiler2_VTable :: struct { + using idxccompiler_vtable: ^ICompiler_VTable, + CompileWithDebug: proc "stdcall" ( + this: ^ICompiler2, + pSource: ^Buffer, + pSourceName: wstring, + pEntryPoint: wstring, + pTargetProfile: wstring, + pArguments: [^]wstring, + argCount: u32, + pDefines: [^]Define, + defineCount: u32, + pIncludeHandler: ^IIncludeHandler, + ppResult: ^^IOperationResult, + ppDebugBlobName: ^wstring, + ppDebugBlob: ^^IBlob) -> HRESULT, +} + +ILinker_UUID_STRING :: "F1B5BE2A-62DD-4327-A1C2-42AC1E1E78E6" +ILinker_UUID := &IID{0xF1B5BE2A, 0x62DD, 0x4327, {0xA1, 0xC2, 0x42, 0xAC, 0x1E, 0x1E, 0x78, 0xE6}} +ILinker :: struct #raw_union { + #subtype iunknown: IUnknown, + using idxclinker_vtable: ^ILinker_VTable, +} +ILinker_VTable :: struct { + using iunknown_vtable: IUnknown_VTable, + RegisterLibrary: proc "stdcall" (this: ^ILinker, pLibName: ^IBlob) -> HRESULT, + Link: proc "stdcall" ( + this: ^ILinker, + pEntryName: wstring, + pTargetProfile: wstring, + pLibNames: [^]wstring, + libCount: u32, + pArguments: [^]wstring, + argCount: u32, + ppResult: ^^IOperationResult) -> HRESULT, +} + +Buffer :: struct { + Ptr: rawptr, + Size: SIZE_T, + Encoding: u32, +} + +IUtils_UUID_STRING :: "4605C4CB-2019-492A-ADA4-65F20BB7D67F" +IUtils_UUID := &IID{0x4605C4CB, 0x2019, 0x492A, {0xAD, 0xA4, 0x65, 0xF2, 0x0B, 0xB7, 0xD6, 0x7F}} +IUtils :: struct #raw_union { + #subtype iunknown: IUnknown, + using idxcutils_vtable: ^IUtils_VTable, +} +IUtils_VTable :: struct { + using iunknown_vtable: IUnknown_VTable, + CreateBlobFromBlob: proc "stdcall" (this: ^IUtils, pBlob: ^IBlob, offset: u32, length: u32, ppResult: ^^IBlob) -> HRESULT, + CreateBlobFromPinned: proc "stdcall" (this: ^IUtils, pData: rawptr, size: u32, codePage: u32, pBlobEncoding: ^^IBlobEncoding) -> HRESULT, + MoveToBlob: proc "stdcall" (this: ^IUtils, pData: rawptr, pIMalloc: ^IMalloc, size: u32, codePage: u32, pBlobEncoding: ^^IBlobEncoding) -> HRESULT, + CreateBlob: proc "stdcall" (this: ^IUtils, pData: rawptr, size: u32, codePage: u32, pBlobEncoding: ^^IBlobEncoding) -> HRESULT, + LoadFile: proc "stdcall" (this: ^IUtils, pFileName: wstring, pCodePage: ^u32, pBlobEncoding: ^^IBlobEncoding) -> HRESULT, + CreateReadOnlyStreamFromBlob: proc "stdcall" (this: ^IUtils, pBlob: ^IBlob, ppStream: ^^IStream) -> HRESULT, + CreateDefaultIncludeHandler: proc "stdcall" (this: ^IUtils, ppResult: ^^IIncludeHandler) -> HRESULT, + GetBlobAsUtf8: proc "stdcall" (this: ^IUtils, pBlob: ^IBlob, pBlobEncoding: ^^IBlobUtf8) -> HRESULT, + GetBlobAsUtf16: proc "stdcall" (this: ^IUtils, pBlob: ^IBlob, pBlobEncoding: ^^IBlobUtf16) -> HRESULT, + GetDxilContainerPart: proc "stdcall" (this: ^IUtils, pShader: ^Buffer, Part: u32, ppPartData: rawptr, pPartSizeInBytes: ^u32) -> HRESULT, + CreateReflection: proc "stdcall" (this: ^IUtils, pData: ^Buffer, iid: ^IID, ppvReflection: rawptr) -> HRESULT, + BuildArguments: proc "stdcall" (this: ^IUtils, pSourceName: wstring, pEntryPoint: wstring, pTargetProfile: wstring, pArguments: [^]wstring, argCount: u32, pDefines: [^]Define, defineCount: u32, ppArgs: ^[^]ICompilerArgs) -> HRESULT, + GetPDBContents: proc "stdcall" (this: ^IUtils, pPDBBlob: ^IBlob, ppHash: ^^IBlob, ppContainer: ^^IBlob) -> HRESULT, +} + +DXC_OUT_KIND :: enum u32 { + NONE = 0, + OBJECT = 1, + ERRORS = 2, + PDB = 3, + SHADER_HASH = 4, + DISASSEMBLY = 5, + HLSL = 6, + TEXT = 7, + REFLECTION = 8, + ROOT_SIGNATURE = 9, + EXTRA_OUTPUTS = 10, + FORCE_DWORD = 0xFFFFFFFF, +} + +IResult_UUID_STRING :: "58346CDA-DDE7-4497-9461-6F87AF5E0659" +IResult_UUID := &IID{0x58346CDA, 0xDDE7, 0x4497, {0x94, 0x61, 0x6F, 0x87, 0xAF, 0x5E, 0x06, 0x59}} +IResult :: struct #raw_union { + #subtype idxcoperationresult: IOperationResult, + using idxcresult_vtable: ^IResult_VTable, +} +IResult_VTable :: struct { + using idxcoperationresult_vtable: IOperationResult_VTable, + HasOutput: proc "stdcall" (this: ^IResult, dxcOutKind: DXC_OUT_KIND) -> BOOL, + GetOutput: proc "stdcall" (this: ^IResult, dxcOutKind: DXC_OUT_KIND, iid: ^IID, ppvObject: rawptr, ppOutputName: ^^IBlobUtf16) -> HRESULT, + GetNumOutputs: proc "stdcall" (this: ^IResult) -> u32, + GetOutputByIndex: proc "stdcall" (this: ^IResult, Index: u32) -> DXC_OUT_KIND, + PrimaryOutput: proc "stdcall" (this: ^IResult) -> DXC_OUT_KIND, +} + +IExtraOutputs_UUID_STRING :: "319B37A2-A5C2-494A-A5DE-4801B2FAF989" +IExtraOutputs_UUID := &IID{0x319B37A2, 0xA5C2, 0x494A, {0xA5, 0xDE, 0x48, 0x01, 0xB2, 0xFA, 0xF9, 0x89}} +IExtraOutputs :: struct #raw_union { + #subtype iunknown: IUnknown, + using idxcextraoutputs_vtable: ^IExtraOutputs_VTable, +} +IExtraOutputs_VTable :: struct { + using iunknown_vtable: IUnknown_VTable, + GetOutputCount: proc "stdcall" (this: ^IExtraOutputs) -> u32, + GetOutput: proc "stdcall" (this: ^IExtraOutputs, uIndex: u32, iid: ^IID, ppvObject: rawptr, ppOutputType: ^^IBlobUtf16, ppOutputName: ^^IBlobUtf16) -> HRESULT, +} + +ICompiler3_UUID_STRING :: "228B4687-5A6A-4730-900C-9702B2203F54" +ICompiler3_UUID := &IID{0x228B4687, 0x5A6A, 0x4730, {0x90, 0x0C, 0x97, 0x02, 0xB2, 0x20, 0x3F, 0x54}} +ICompiler3 :: struct #raw_union { + #subtype iunknown: IUnknown, + using idxccompiler3_vtable: ^ICompiler3_VTable, +} +ICompiler3_VTable :: struct { + using iunknown_vtable: IUnknown_VTable, + Compile: proc "stdcall" (this: ^ICompiler3, pSource: ^Buffer, pArguments: [^]wstring, argCount: u32, pIncludeHandler: ^IIncludeHandler, riid: ^IID, ppResult: rawptr) -> HRESULT, + Disassemble: proc "stdcall" (this: ^ICompiler3, pObject: ^Buffer, riid: ^IID, ppResult: rawptr) -> HRESULT, +} + +IValidator_UUID_STRING :: "A6E82BD2-1FD7-4826-9811-2857E797F49A" +IValidator_UUID := &IID{0xA6E82BD2, 0x1FD7, 0x4826, {0x98, 0x11, 0x28, 0x57, 0xE7, 0x97, 0xF4, 0x9A}} +IValidator :: struct #raw_union { + #subtype iunknown: IUnknown, + using idxcvalidator_vtable: ^IValidator_VTable, +} +IValidator_VTable :: struct { + using iunknown_vtable: IUnknown_VTable, + Validate: proc "stdcall" (this: ^IValidator, pShader: ^IBlob, Flags: u32, ppResult: ^^IOperationResult) -> HRESULT, +} + +IValidator2_UUID_STRING :: "458E1FD1-B1B2-4750-A6E1-9C10F03BED92" +IValidator2_UUID := &IID{0x458E1FD1, 0xB1B2, 0x4750, {0xA6, 0xE1, 0x9C, 0x10, 0xF0, 0x3B, 0xED, 0x92}} +IValidator2 :: struct #raw_union { + #subtype idxcvalidator: IValidator, + using idxcvalidator2_vtable: ^IValidator2_VTable, +} +IValidator2_VTable :: struct { + using idxcvalidator_vtable: IValidator_VTable, + ValidateWithDebug: proc "stdcall" (this: ^IValidator2, pShader: ^IBlob, Flags: u32, pOptDebugBitcode: ^Buffer, ppResult: ^^IOperationResult) -> HRESULT, +} + +IContainerBuilder_UUID_STRING :: "334B1F50-2292-4B35-99A1-25588D8C17FE" +IContainerBuilder_UUID := &IID{0x334B1F50, 0x2292, 0x4B35, {0x99, 0xA1, 0x25, 0x58, 0x8D, 0x8C, 0x17, 0xFE}} +IContainerBuilder :: struct #raw_union { + #subtype iunknown: IUnknown, + using idxccontainerbuilder_vtable: ^IContainerBuilder_VTable, +} +IContainerBuilder_VTable :: struct { + using iunknown_vtable: IUnknown_VTable, + Load: proc "stdcall" (this: ^IContainerBuilder, pDxilContainerHeader: ^IBlob) -> HRESULT, + AddPart: proc "stdcall" (this: ^IContainerBuilder, fourCC: u32, pSource: ^IBlob) -> HRESULT, + RemovePart: proc "stdcall" (this: ^IContainerBuilder, fourCC: u32) -> HRESULT, + SerializeContainer: proc "stdcall" (this: ^IContainerBuilder, ppResult: ^^IOperationResult) -> HRESULT, +} + +IAssembler_UUID_STRING :: "091F7A26-1C1F-4948-904B-E6E3A8A771D5" +IAssembler_UUID := &IID{0x091F7A26, 0x1C1F, 0x4948, {0x90, 0x4B, 0xE6, 0xE3, 0xA8, 0xA7, 0x71, 0xD5}} +IAssembler :: struct #raw_union { + #subtype iunknown: IUnknown, + using idxcassembler_vtable: ^IAssembler_VTable, +} +IAssembler_VTable :: struct { + using iunknown_vtable: IUnknown_VTable, + AssembleToContainer: proc "stdcall" (this: ^IAssembler, pShader: ^IBlob, ppResult: ^^IOperationResult) -> HRESULT, +} + +IContainerReflection_UUID_STRING :: "D2C21B26-8350-4BDC-976A-331CE6F4C54C" +IContainerReflection_UUID := &IID{0xD2C21B26, 0x8350, 0x4BDC, {0x97, 0x6A, 0x33, 0x1C, 0xE6, 0xF4, 0xC5, 0x4C}} +IContainerReflection :: struct #raw_union { + #subtype iunknown: IUnknown, + using idxccontainerreflection_vtable: ^IContainerReflection_VTable, +} +IContainerReflection_VTable :: struct { + using iunknown_vtable: IUnknown_VTable, + Load: proc "stdcall" (this: ^IContainerReflection, pContainer: ^IBlob) -> HRESULT, + GetPartCount: proc "stdcall" (this: ^IContainerReflection, pResult: ^u32) -> HRESULT, + GetPartKind: proc "stdcall" (this: ^IContainerReflection, idx: u32, pResult: ^u32) -> HRESULT, + GetPartContent: proc "stdcall" (this: ^IContainerReflection, idx: u32, ppResult: ^^IBlob) -> HRESULT, + FindFirstPartKind: proc "stdcall" (this: ^IContainerReflection, kind: u32, pResult: ^u32) -> HRESULT, + GetPartReflection: proc "stdcall" (this: ^IContainerReflection, idx: u32, iid: ^IID, ppvObject: rawptr) -> HRESULT, +} + +IOptimizerPass_UUID_STRING :: "AE2CD79F-CC22-453F-9B6B-B124E7A5204C" +IOptimizerPass_UUID := &IID{0xAE2CD79F, 0xCC22, 0x453F, {0x9B, 0x6B, 0xB1, 0x24, 0xE7, 0xA5, 0x20, 0x4C}} +IOptimizerPass :: struct #raw_union { + #subtype iunknown: IUnknown, + using idxcoptimizerpass_vtable: ^IOptimizerPass_VTable, +} +IOptimizerPass_VTable :: struct { + using iunknown_vtable: IUnknown_VTable, + GetOptionName: proc "stdcall" (this: ^IOptimizerPass, ppResult: ^wstring) -> HRESULT, + GetDescription: proc "stdcall" (this: ^IOptimizerPass, ppResult: ^wstring) -> HRESULT, + GetOptionArgCount: proc "stdcall" (this: ^IOptimizerPass, pCount: ^u32) -> HRESULT, + GetOptionArgName: proc "stdcall" (this: ^IOptimizerPass, argIndex: u32, ppResult: ^wstring) -> HRESULT, + GetOptionArgDescription: proc "stdcall" (this: ^IOptimizerPass, argIndex: u32, ppResult: ^wstring) -> HRESULT, +} + +IOptimizer_UUID_STRING :: "25740E2E-9CBA-401B-9119-4FB42F39F270" +IOptimizer_UUID := &IID{0x25740E2E, 0x9CBA, 0x401B, {0x91, 0x19, 0x4F, 0xB4, 0x2F, 0x39, 0xF2, 0x70}} +IOptimizer :: struct #raw_union { + #subtype iunknown: IUnknown, + using idxcoptimizer_vtable: ^IOptimizer_VTable, +} +IOptimizer_VTable :: struct { + using iunknown_vtable: IUnknown_VTable, + GetAvailablePassCount: proc "stdcall" (this: ^IOptimizer, pCount: ^u32) -> HRESULT, + GetAvailablePass: proc "stdcall" (this: ^IOptimizer, index: u32, ppResult: ^^IOptimizerPass) -> HRESULT, + RunOptimizer: proc "stdcall" (this: ^IOptimizer, pBlob: ^IBlob, ppOptions: [^]wstring, optionCount: u32, pOutputModule: ^^IBlob, ppOutputText: ^^IBlobEncoding) -> HRESULT, +} + +VersionInfoFlags :: enum u32 { + None = 0, + Debug = 1, + Internal = 2, +} + +IVersionInfo_UUID_STRING :: "B04F5B50-2059-4F12-A8FF-A1E0CDE1CC7E" +IVersionInfo_UUID := &IID{0xB04F5B50, 0x2059, 0x4F12, {0xA8, 0xFF, 0xA1, 0xE0, 0xCD, 0xE1, 0xCC, 0x7E}} +IVersionInfo :: struct #raw_union { + #subtype iunknown: IUnknown, + using idxcversioninfo_vtable: ^IVersionInfo_VTable, +} +IVersionInfo_VTable :: struct { + using iunknown_vtable: IUnknown_VTable, + GetVersion: proc "stdcall" (this: ^IVersionInfo, pMajor: ^u32, pMinor: ^u32) -> HRESULT, + GetFlags: proc "stdcall" (this: ^IVersionInfo, pFlags: ^VersionInfoFlags) -> HRESULT, +} + +IVersionInfo2_UUID_STRING :: "FB6904C4-42F0-4B62-9C46-983AF7DA7C83" +IVersionInfo2_UUID := &IID{0xFB6904C4, 0x42F0, 0x4B62, {0x9C, 0x46, 0x98, 0x3A, 0xF7, 0xDA, 0x7C, 0x83}} +IVersionInfo2 :: struct #raw_union { + #subtype idxcversioninfo: IVersionInfo, + using idxcversioninfo2_vtable: ^IVersionInfo2_VTable, +} +IVersionInfo2_VTable :: struct { + using idxcversioninfo_vtable: IVersionInfo_VTable, + GetCommitInfo: proc "stdcall" (this: ^IVersionInfo2, pCommitCount: ^u32, pCommitHash: ^[^]byte) -> HRESULT, +} + +IVersionInfo3_UUID_STRING :: "5E13E843-9D25-473C-9AD2-03B2D0B44B1E" +IVersionInfo3_UUID := &IID{0x5E13E843, 0x9D25, 0x473C, {0x9A, 0xD2, 0x03, 0xB2, 0xD0, 0xB4, 0x4B, 0x1E}} +IVersionInfo3 :: struct #raw_union { + #subtype iunknown: IUnknown, + using idxcversioninfo3_vtable: ^IVersionInfo3_VTable, +} +IVersionInfo3_VTable :: struct { + using iunknown_vtable: IUnknown_VTable, + GetCustomVersionString: proc "stdcall" (this: ^IVersionInfo3, pVersionString: ^cstring) -> HRESULT, +} + +ArgPair :: struct { + pName: wstring, + pValue: wstring, +} + +IPdbUtils_UUID_STRING :: "E6C9647E-9D6A-4C3B-B94C-524B5A6C343D" +IPdbUtils_UUID := &IID{0xE6C9647E, 0x9D6A, 0x4C3B, {0xB9, 0x4C, 0x52, 0x4B, 0x5A, 0x6C, 0x34, 0x3D}} +IPdbUtils :: struct #raw_union { + #subtype iunknown: IUnknown, + using idxcpdbutils_vtable: ^IPdbUtils_VTable, +} +IPdbUtils_VTable :: struct { + using iunknown_vtable: IUnknown_VTable, + Load: proc "stdcall" (this: ^IPdbUtils, pPdbOrDxil: ^IBlob) -> HRESULT, + GetSourceCount: proc "stdcall" (this: ^IPdbUtils, pCount: ^u32) -> HRESULT, + GetSource: proc "stdcall" (this: ^IPdbUtils, uIndex: u32, ppResult: ^^IBlobEncoding) -> HRESULT, + GetSourceName: proc "stdcall" (this: ^IPdbUtils, uIndex: u32, pResult: ^BSTR) -> HRESULT, + GetFlagCount: proc "stdcall" (this: ^IPdbUtils, pCount: ^u32) -> HRESULT, + GetFlag: proc "stdcall" (this: ^IPdbUtils, uIndex: u32, pResult: ^BSTR) -> HRESULT, + GetArgCount: proc "stdcall" (this: ^IPdbUtils, pCount: ^u32) -> HRESULT, + GetArg: proc "stdcall" (this: ^IPdbUtils, uIndex: u32, pResult: ^BSTR) -> HRESULT, + GetArgPairCount: proc "stdcall" (this: ^IPdbUtils, pCount: ^u32) -> HRESULT, + GetArgPair: proc "stdcall" (this: ^IPdbUtils, uIndex: u32, pName: ^BSTR, pValue: ^BSTR) -> HRESULT, + GetDefineCount: proc "stdcall" (this: ^IPdbUtils, pCount: ^u32) -> HRESULT, + GetDefine: proc "stdcall" (this: ^IPdbUtils, uIndex: u32, pResult: ^BSTR) -> HRESULT, + GetTargetProfile: proc "stdcall" (this: ^IPdbUtils, pResult: ^BSTR) -> HRESULT, + GetEntryPoint: proc "stdcall" (this: ^IPdbUtils, pResult: ^BSTR) -> HRESULT, + GetMainFileName: proc "stdcall" (this: ^IPdbUtils, pResult: ^BSTR) -> HRESULT, + GetHash: proc "stdcall" (this: ^IPdbUtils, ppResult: ^^IBlob) -> HRESULT, + GetName: proc "stdcall" (this: ^IPdbUtils, pResult: ^BSTR) -> HRESULT, + IsFullPDB: proc "stdcall" (this: ^IPdbUtils) -> BOOL, + GetFullPDB: proc "stdcall" (this: ^IPdbUtils, ppFullPDB: ^^IBlob) -> HRESULT, + GetVersionInfo: proc "stdcall" (this: ^IPdbUtils, ppVersionInfo: ^^IVersionInfo) -> HRESULT, + SetCompiler: proc "stdcall" (this: ^IPdbUtils, pCompiler: ^ICompiler3) -> HRESULT, + CompileForFullPDB: proc "stdcall" (this: ^IPdbUtils, ppResult: ^^IResult) -> HRESULT, + OverrideArgs: proc "stdcall" (this: ^IPdbUtils, pArgPairs: ^ArgPair, uNumArgPairs: u32) -> HRESULT, + OverrideRootSignature: proc "stdcall" (this: ^IPdbUtils, pRootSignature: wstring) -> HRESULT, +} + + +Compiler_CLSID_STRING :: "73E22D93-E6CE-47F3-B5BF-F0664F39C1B0" +Compiler_CLSID := &CLSID{0x73E22D93, 0xE6CE, 0x47F3, {0xB5, 0xBF, 0xF0, 0x66, 0x4F, 0x39, 0xC1, 0xB0}} + +Linker_CLSID_STRING :: "EF6A8087-B0EA-4D56-9E45-D07E1A8B7806" +Linker_CLSID := &CLSID{0xEF6A8087, 0xB0EA, 0x4D56, {0x9E, 0x45, 0xD0, 0x7E, 0x1A, 0x8B, 0x78, 0x6}} + +DiaDataSource_CLSID_STRING :: "CD1F6B73-2AB0-484D-8EDC-EBE7A43CA09F" +DiaDataSource_CLSID := &CLSID{0xCD1F6B73, 0x2AB0, 0x484D, {0x8E, 0xDC, 0xEB, 0xE7, 0xA4, 0x3C, 0xA0, 0x9F}} + +CompilerArgs_CLSID_STRING :: "3E56AE82-224D-470F-A1A1-FE3016EE9F9D" +CompilerArgs_CLSID := &CLSID{0x3E56AE82, 0x224D, 0x470F, {0xA1, 0xA1, 0xFE, 0x30, 0x16, 0xEE, 0x9F, 0x9D}} + +Library_CLSID_STRING :: "6245D6AF-66E0-48FD-80B4-4D271796748C" +Library_CLSID := &CLSID{0x6245D6AF, 0x66E0, 0x48FD, {0x80, 0xB4, 0x4D, 0x27, 0x17, 0x96, 0x74, 0x8C}} + +Utils_CLSID_STRING :: Library_CLSID_STRING +Utils_CLSID := Library_CLSID + +Validator_CLSID_STRING :: "8CA3E215-F728-4CF3-8CDD-88AF917587A1" +Validator_CLSID := &CLSID{0x8CA3E215, 0xF728, 0x4CF3, {0x8C, 0xDD, 0x88, 0xAF, 0x91, 0x75, 0x87, 0xA1}} + +Assembler_CLSID_STRING :: "D728DB68-F903-4F80-94CD-DCCF76EC7151" +Assembler_CLSID := &CLSID{0xD728DB68, 0xF903, 0x4F80, {0x94, 0xCD, 0xDC, 0xCF, 0x76, 0xEC, 0x71, 0x51}} + +ContainerReflection_CLSID_STRING :: "b9f54489-55b8-400c-ba3a-1675e4728b91" +ContainerReflection_CLSID := &CLSID{0xB9F54489, 0x55B8, 0x400C, {0xBA, 0x3A, 0x16, 0x75, 0xE4, 0x72, 0x8B, 0x91}} + +Optimizer_CLSID_STRING :: "AE2CD79F-CC22-453F-9B6B-B124E7A5204C" +Optimizer_CLSID := &CLSID{0xAE2CD79F, 0xCC22, 0x453F, {0x9B, 0x6B, 0xB1, 0x24, 0xE7, 0xA5, 0x20, 0x4C}} + +ContainerBuilder_CLSID_STRING :: "94134294-411f-4574-b4d0-8741e25240d2" +ContainerBuilder_CLSID := &CLSID{0x94134294, 0x411F, 0x4574, {0xB4, 0xD0, 0x87, 0x41, 0xE2, 0x52, 0x40, 0xD2}} + +PdbUtils_CLSID_STRING :: "54621dfb-f2ce-457e-ae8c-ec355faeec7c" +PdbUtils_CLSID := &CLSID{0x54621DFB, 0xF2CE, 0x457E, {0xAE, 0x8C, 0xEC, 0x35, 0x5F, 0xAE, 0xEC, 0x7C}} + +CP_UTF8 :: 65001 +CP_UTF16 :: 1200 +CP_ACP :: 0 + +make_fourcc :: proc "contextless" (ch0, ch1, ch2, ch3: u32) -> u32 { + return ch0 | (ch1 << 8) | (ch2 << 16) | (ch3 << 24) +} + +PART_PDB :: u32('I') | (u32('L')<<8) | (u32('D')<<16) | (u32('B')<<24) +PART_PDB_NAME :: u32('I') | (u32('L')<<8) | (u32('D')<<16) | (u32('N')<<24) +PART_PRIVATE_DATA :: u32('P') | (u32('R')<<8) | (u32('I')<<16) | (u32('V')<<24) +PART_ROOT_SIGNATURE :: u32('R') | (u32('T')<<8) | (u32('S')<<16) | (u32('0')<<24) +PART_DXIL :: u32('D') | (u32('X')<<8) | (u32('I')<<16) | (u32('L')<<24) +PART_REFLECTION_DATA :: u32('S') | (u32('T')<<8) | (u32('A')<<16) | (u32('T')<<24) +PART_SHADER_HASH :: u32('H') | (u32('A')<<8) | (u32('S')<<16) | (u32('H')<<24) +PART_INPUT_SIGNATURE :: u32('I') | (u32('S')<<8) | (u32('G')<<16) | (u32('1')<<24) +PART_OUTPUT_SIGNATURE :: u32('O') | (u32('S')<<8) | (u32('G')<<16) | (u32('1')<<24) +PART_PATCH_CONSTANT_SIGNATURE :: u32('P') | (u32('S')<<8) | (u32('G')<<16) | (u32('1')<<24) + +ARG_DEBUG :: "-Zi" +ARG_SKIP_VALIDATION :: "-Vd" +ARG_SKIP_OPTIMIZATIONS :: "-Od" +ARG_PACK_MATRIX_ROW_MAJOR :: "-Zpr" +ARG_PACK_MATRIX_COLUMN_MAJOR :: "-Zpc" +ARG_AVOID_FLOW_CONTROL :: "-Gfa" +ARG_PREFER_FLOW_CONTROL :: "-Gfp" +ARG_ENABLE_STRICTNESS :: "-Ges" +ARG_ENABLE_BACKWARDS_COMPATIBILITY :: "-Gec" +ARG_IEEE_STRICTNESS :: "-Gis" +ARG_OPTIMIZATION_LEVEL0 :: "-O0" +ARG_OPTIMIZATION_LEVEL1 :: "-O1" +ARG_OPTIMIZATION_LEVEL2 :: "-O2" +ARG_OPTIMIZATION_LEVEL3 :: "-O3" +ARG_WARNINGS_ARE_ERRORS :: "-WX" +ARG_RESOURCES_MAY_ALIAS :: "-res_may_alias" +ARG_ALL_RESOURCES_BOUND :: "-all_resources_bound" +ARG_DEBUG_NAME_FOR_SOURCE :: "-Zss" +ARG_DEBUG_NAME_FOR_BINARY :: "-Zsb" + +EXTRA_OUTPUT_NAME_STDOUT :: "*stdout*" +EXTRA_OUTPUT_NAME_STDERR :: "*stderr*" diff --git a/vendor/directx/dxc/dxcompiler.dll b/vendor/directx/dxc/dxcompiler.dll new file mode 100644 index 000000000..ccd7dd283 Binary files /dev/null and b/vendor/directx/dxc/dxcompiler.dll differ diff --git a/vendor/directx/dxc/dxcompiler.lib b/vendor/directx/dxc/dxcompiler.lib new file mode 100644 index 000000000..6adf6c2a1 Binary files /dev/null and b/vendor/directx/dxc/dxcompiler.lib differ diff --git a/vendor/directx/dxc/dxil.dll b/vendor/directx/dxc/dxil.dll new file mode 100644 index 000000000..cee03dc63 Binary files /dev/null and b/vendor/directx/dxc/dxil.dll differ diff --git a/vendor/directx/dxgi/dxgi.odin b/vendor/directx/dxgi/dxgi.odin index 5ad938ba0..c2117f637 100644 --- a/vendor/directx/dxgi/dxgi.odin +++ b/vendor/directx/dxgi/dxgi.odin @@ -375,7 +375,7 @@ MAPPED_RECT :: struct { } ADAPTER_DESC :: struct { - Description: [128]i16, + Description: [128]u16 `fmt:"s,0"`, VendorId: u32, DeviceId: u32, SubSysId: u32, @@ -387,7 +387,7 @@ ADAPTER_DESC :: struct { } OUTPUT_DESC :: struct { - DeviceName: [32]i16, + DeviceName: [32]u16 `fmt:"s,0"`, DesktopCoordinates: RECT, AttachedToDesktop: BOOL, Rotation: MODE_ROTATION, @@ -613,7 +613,7 @@ ADAPTER_FLAG :: enum u32 { // TODO: convert to bit_set } ADAPTER_DESC1 :: struct { - Description: [128]i16, + Description: [128]u16 `fmt:"s,0"`, VendorId: u32, DeviceId: u32, SubSysId: u32, @@ -890,7 +890,7 @@ COMPUTE_PREEMPTION_GRANULARITY :: enum i32 { } ADAPTER_DESC2 :: struct { - Description: [128]i16, + Description: [128]u16 `fmt:"s,0"`, VendorId: u32, DeviceId: u32, SubSysId: u32, diff --git a/vendor/directx/dxgi/dxgidebug.odin b/vendor/directx/dxgi/dxgidebug.odin new file mode 100644 index 000000000..1dea396a7 --- /dev/null +++ b/vendor/directx/dxgi/dxgidebug.odin @@ -0,0 +1,141 @@ +package directx_dxgi + +import win32 "core:sys/windows" +import "core:c" + +DEBUG_RLO_FLAGS :: enum u32 { // TODO: convert to bit_set + SUMMARY = 0x1, + DETAIL = 0x2, + IGNORE_INTERNAL = 0x4, + ALL = 0x7, +} + +UINT :: win32.UINT +UINT64 :: win32.UINT64 +LPCSTR :: win32.LPCSTR +DEBUG_ID :: win32.GUID +INFO_QUEUE_MESSAGE_ID :: i32 + +DEBUG_ALL := DEBUG_ID{0xe48ae283, 0xda80, 0x490b, {0x87, 0xe6, 0x43, 0xe9, 0xa9, 0xcf, 0xda, 0x8}} +DEBUG_DX := DEBUG_ID{0x35cdd7fc, 0x13b2, 0x421d, {0xa5, 0xd7, 0x7e, 0x44, 0x51, 0x28, 0x7d, 0x64}} +DEBUG_DXGI := DEBUG_ID{0x25cddaa4, 0xb1c6, 0x47e1, {0xac, 0x3e, 0x98, 0x87, 0x5b, 0x5a, 0x2e, 0x2a}} +DEBUG_APP := DEBUG_ID{0x6cd6e01, 0x4219, 0x4ebd, {0x87, 0x9, 0x27, 0xed, 0x23, 0x36, 0xc, 0x62}} + +INFO_QUEUE_MESSAGE_CATEGORY :: enum u32 { + UNKNOWN = 0, + MISCELLANEOUS = UNKNOWN + 1, + INITIALIZATION = MISCELLANEOUS + 1, + CLEANUP = INITIALIZATION + 1, + COMPILATION = CLEANUP + 1, + STATE_CREATION = COMPILATION + 1, + STATE_SETTING = STATE_CREATION + 1, + STATE_GETTING = STATE_SETTING + 1, + RESOURCE_MANIPULATION = STATE_GETTING + 1, + EXECUTION = RESOURCE_MANIPULATION + 1, + SHADER = EXECUTION + 1, +} + +INFO_QUEUE_MESSAGE_SEVERITY :: enum u32 { + CORRUPTION = 0, + ERROR = CORRUPTION + 1, + WARNING = ERROR + 1, + INFO = WARNING + 1, + MESSAGE = INFO + 1, +} + +INFO_QUEUE_MESSAGE :: struct { + Producer: DEBUG_ID, + Category: INFO_QUEUE_MESSAGE_CATEGORY, + Severity: INFO_QUEUE_MESSAGE_SEVERITY, + ID: INFO_QUEUE_MESSAGE_ID, + pDescription: [^]c.char, + DescriptionByteLength: SIZE_T, +} + +INFO_QUEUE_FILTER_DESC :: struct { + NumCategories: UINT, + pCategoryList: [^]INFO_QUEUE_MESSAGE_CATEGORY, + NumSeverities: UINT, + pSeverityList: [^]INFO_QUEUE_MESSAGE_SEVERITY, + NumIDs: UINT, + pIDList: [^]INFO_QUEUE_MESSAGE_ID, +} + +INFO_QUEUE_FILTER :: struct { + AllowList: INFO_QUEUE_FILTER_DESC, + DenyList: INFO_QUEUE_FILTER_DESC, +} + +INFO_QUEUE_DEFAULT_MESSAGE_COUNT_LIMIT :: 1024 + + +IInfoQueue_UUID_STRING :: "D67441C7-672A-476f-9E82-CD55B44949CE" +IInfoQueue_UUID := &IID{0xD67441C7, 0x672A, 0x476f, {0x9E, 0x82, 0xCD, 0x55, 0xB4, 0x49, 0x49, 0xCE}} +IInfoQueue :: struct #raw_union { + #subtype iunknown: IUnknown, + using idxgiinfoqueue_vtable: ^IInfoQueue_VTable, +} +IInfoQueue_VTable :: struct { + using iunknown_vtable: IUnknown_VTable, + SetMessageCountLimit: proc "stdcall" (this: ^IInfoQueue, Producer: DEBUG_ID, MessageCountLimit: UINT64) -> HRESULT, + ClearStoredMessages: proc "stdcall" (this: ^IInfoQueue, Producer: DEBUG_ID), + GetMessage: proc "stdcall" (this: ^IInfoQueue, Producer: DEBUG_ID, MessageIndex: UINT64, pMessage: ^INFO_QUEUE_MESSAGE, pMessageByteLength: ^SIZE_T) -> HRESULT, + GetNumStoredMessagesAllowedByRetrievalFilters: proc "stdcall" (this: ^IInfoQueue, Producer: DEBUG_ID) -> UINT64, + GetNumStoredMessages: proc "stdcall" (this: ^IInfoQueue, Producer: DEBUG_ID) -> UINT64, + GetNumMessagesDiscardedByMessageCountLimit: proc "stdcall" (this: ^IInfoQueue, Producer: DEBUG_ID) -> UINT64, + GetMessageCountLimit: proc "stdcall" (this: ^IInfoQueue, Producer: DEBUG_ID) -> UINT64, + GetNumMessagesAllowedByStorageFilter: proc "stdcall" (this: ^IInfoQueue, Producer: DEBUG_ID) -> UINT64, + GetNumMessagesDeniedByStorageFilter: proc "stdcall" (this: ^IInfoQueue, Producer: DEBUG_ID) -> UINT64, + AddStorageFilterEntries: proc "stdcall" (this: ^IInfoQueue, Producer: DEBUG_ID, pFilter: INFO_QUEUE_FILTER) -> HRESULT, + GetStorageFilter: proc "stdcall" (this: ^IInfoQueue, Producer: DEBUG_ID, pFilter: ^INFO_QUEUE_FILTER, pFilterByteLength: ^SIZE_T) -> HRESULT, + ClearStorageFilter: proc "stdcall" (this: ^IInfoQueue, Producer: DEBUG_ID), + PushEmptyStorageFilter: proc "stdcall" (this: ^IInfoQueue, Producer: DEBUG_ID) -> HRESULT, + PushDenyAllStorageFilter: proc "stdcall" (this: ^IInfoQueue, Producer: DEBUG_ID) -> HRESULT, + PushCopyOfStorageFilter: proc "stdcall" (this: ^IInfoQueue, Producer: DEBUG_ID) -> HRESULT, + PushStorageFilter: proc "stdcall" (this: ^IInfoQueue, Producer: DEBUG_ID, pFilter: ^INFO_QUEUE_FILTER) -> HRESULT, + PopStorageFilter: proc "stdcall" (this: ^IInfoQueue, Producer: DEBUG_ID), + GetStorageFilterStackSize: proc "stdcall" (this: ^IInfoQueue, Producer: DEBUG_ID) -> UINT, + AddRetrievalFilterEntries: proc "stdcall" (this: ^IInfoQueue, Producer: DEBUG_ID, pFilter: ^INFO_QUEUE_FILTER) -> HRESULT, + GetRetrievalFilter: proc "stdcall" (this: ^IInfoQueue, Producer: DEBUG_ID, pFilter: ^INFO_QUEUE_FILTER, pFilterByteLength: ^SIZE_T) -> HRESULT, + ClearRetrievalFilter: proc "stdcall" (this: ^IInfoQueue, Producer: DEBUG_ID), + PushEmptyRetrievalFilter: proc "stdcall" (this: ^IInfoQueue, Producer: DEBUG_ID) -> HRESULT, + PushDenyAllRetrievalFilter: proc "stdcall" (this: ^IInfoQueue, Producer: DEBUG_ID) -> HRESULT, + PushCopyOfRetrievalFilter: proc "stdcall" (this: ^IInfoQueue, Producer: DEBUG_ID) -> HRESULT, + PushRetrievalFilter: proc "stdcall" (this: ^IInfoQueue, Producer: DEBUG_ID, pFilter: ^INFO_QUEUE_FILTER) -> HRESULT, + PopRetrievalFilter: proc "stdcall" (this: ^IInfoQueue, Producer: DEBUG_ID), + GetRetrievalFilterStackSize: proc "stdcall" (this: ^IInfoQueue, Producer: DEBUG_ID) -> UINT, + AddMessage: proc "stdcall" (this: ^IInfoQueue, Producer: DEBUG_ID, Category: INFO_QUEUE_MESSAGE_CATEGORY, Severity: INFO_QUEUE_MESSAGE_SEVERITY, ID: INFO_QUEUE_MESSAGE_ID, pDescription: LPCSTR) -> HRESULT, + AddApplicationMessage: proc "stdcall" (this: ^IInfoQueue, Severity: INFO_QUEUE_MESSAGE_SEVERITY, pDescription: LPCSTR) -> HRESULT, + SetBreakOnCategory: proc "stdcall" (this: ^IInfoQueue, Producer: DEBUG_ID, Category: INFO_QUEUE_MESSAGE_CATEGORY, bEnable: BOOL) -> HRESULT, + SetBreakOnSeverity: proc "stdcall" (this: ^IInfoQueue, Producer: DEBUG_ID, Severity: INFO_QUEUE_MESSAGE_SEVERITY, bEnable: BOOL) -> HRESULT, + SetBreakOnID: proc "stdcall" (this: ^IInfoQueue, Producer: DEBUG_ID, ID: INFO_QUEUE_MESSAGE_ID, bEnable: BOOL) -> HRESULT, + GetBreakOnCategory: proc "stdcall" (this: ^IInfoQueue, Producer: DEBUG_ID, Category: INFO_QUEUE_MESSAGE_CATEGORY) -> BOOL, + GetBreakOnSeverity: proc "stdcall" (this: ^IInfoQueue, Producer: DEBUG_ID, Severity: INFO_QUEUE_MESSAGE_SEVERITY) -> BOOL, + GetBreakOnID: proc "stdcall" (this: ^IInfoQueue, Producer: DEBUG_ID, ID: INFO_QUEUE_MESSAGE_ID) -> BOOL, + SetMuteDebugOutput: proc "stdcall" (this: ^IInfoQueue, Producer: DEBUG_ID, bMute: BOOL), + GetMuteDebugOutput: proc "stdcall" (this: ^IInfoQueue, Producer: DEBUG_ID) -> BOOL, +} + +IDebug_UUID_STRING :: "119E7452-DE9E-40fe-8806-88F90C12B441" +IDebug_UUID := &IID{0x119E7452, 0xDE9E, 0x40fe, {0x88, 0x06, 0x88, 0xF9, 0x0C, 0x12, 0xB4, 0x41}} +IDebug :: struct #raw_union { + #subtype iunknown: IUnknown, + using idxgidebug_vtable: ^IDebug_VTable, +} +IDebug_VTable :: struct { + using iunknown_vtable: IUnknown_VTable, + ReportLiveObjects: proc "stdcall" (this: ^IDebug, apiid: GUID, flags: DEBUG_RLO_FLAGS), +} + +IDebug1_UUID_STRING :: "c5a05f0c-16f2-4adf-9f4d-a8c4d58ac550" +IDebug1_UUID := &IID{0xc5a05f0c, 0x16f2, 0x4adf, {0x9f, 0x4d, 0xa8, 0xc4, 0xd5, 0x8a, 0xc5, 0x50}} +IDebug1 :: struct #raw_union { + #subtype idxgidebug: IDebug, + using idxgidebug1_vtable: ^IDebug1_VTable, +} +IDebug1_VTable :: struct { + using idxgidebug_vtable: IDebug_VTable, + EnableLeakTrackingForThread: proc "stdcall" (this: ^IDebug1), + DisableLeakTrackingForThread: proc "stdcall" (this: ^IDebug1), + IsLeakTrackingEnabledForThread: proc "stdcall" (this: ^IDebug1) -> BOOL, +} diff --git a/vendor/glfw/bindings/bindings.odin b/vendor/glfw/bindings/bindings.odin index e7287e316..96a70db85 100644 --- a/vendor/glfw/bindings/bindings.odin +++ b/vendor/glfw/bindings/bindings.odin @@ -3,13 +3,24 @@ package glfw_bindings import "core:c" import vk "vendor:vulkan" +GLFW_DYNAMIC :: #config(GLFW_DYNAMIC, false) + when ODIN_OS == .Windows { - foreign import glfw { - "../lib/glfw3_mt.lib", - "system:user32.lib", - "system:gdi32.lib", - "system:shell32.lib", - } + when GLFW_DYNAMIC { + foreign import glfw { + "../lib/glfw3dll.lib", + "system:user32.lib", + "system:gdi32.lib", + "system:shell32.lib", + } + } else { + foreign import glfw { + "../lib/glfw3_mt.lib", + "system:user32.lib", + "system:gdi32.lib", + "system:shell32.lib", + } + } } else when ODIN_OS == .Linux { // TODO: Add the billion-or-so static libs to link to in linux foreign import glfw "system:glfw" diff --git a/vendor/glfw/constants.odin b/vendor/glfw/constants.odin index ec1364e07..160642bfb 100644 --- a/vendor/glfw/constants.odin +++ b/vendor/glfw/constants.odin @@ -1,5 +1,8 @@ package glfw +/* Config */ +GLFW_DYNAMIC :: #config(GLFW_DYNAMIC, false) + /*** Constants ***/ /* Versions */ VERSION_MAJOR :: 3 diff --git a/vendor/glfw/native_windows.odin b/vendor/glfw/native_windows.odin index 1d9c3af86..26f75845c 100644 --- a/vendor/glfw/native_windows.odin +++ b/vendor/glfw/native_windows.odin @@ -4,7 +4,11 @@ package glfw import win32 "core:sys/windows" -foreign import glfw { "lib/glfw3_mt.lib", "system:user32.lib", "system:gdi32.lib", "system:shell32.lib" } +when GLFW_DYNAMIC { + foreign import glfw { "lib/glfw3dll.lib", "system:user32.lib", "system:gdi32.lib", "system:shell32.lib" } +} else { + foreign import glfw { "lib/glfw3_mt.lib", "system:user32.lib", "system:gdi32.lib", "system:shell32.lib" } +} @(default_calling_convention="c", link_prefix="glfw") foreign glfw { diff --git a/vendor/lua/5.1/include/lauxlib.h b/vendor/lua/5.1/include/lauxlib.h new file mode 100644 index 000000000..34258235d --- /dev/null +++ b/vendor/lua/5.1/include/lauxlib.h @@ -0,0 +1,174 @@ +/* +** $Id: lauxlib.h,v 1.88.1.1 2007/12/27 13:02:25 roberto Exp $ +** Auxiliary functions for building Lua libraries +** See Copyright Notice in lua.h +*/ + + +#ifndef lauxlib_h +#define lauxlib_h + + +#include +#include + +#include "lua.h" + + +#if defined(LUA_COMPAT_GETN) +LUALIB_API int (luaL_getn) (lua_State *L, int t); +LUALIB_API void (luaL_setn) (lua_State *L, int t, int n); +#else +#define luaL_getn(L,i) ((int)lua_objlen(L, i)) +#define luaL_setn(L,i,j) ((void)0) /* no op! */ +#endif + +#if defined(LUA_COMPAT_OPENLIB) +#define luaI_openlib luaL_openlib +#endif + + +/* extra error code for `luaL_load' */ +#define LUA_ERRFILE (LUA_ERRERR+1) + + +typedef struct luaL_Reg { + const char *name; + lua_CFunction func; +} luaL_Reg; + + + +LUALIB_API void (luaI_openlib) (lua_State *L, const char *libname, + const luaL_Reg *l, int nup); +LUALIB_API void (luaL_register) (lua_State *L, const char *libname, + const luaL_Reg *l); +LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e); +LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e); +LUALIB_API int (luaL_typerror) (lua_State *L, int narg, const char *tname); +LUALIB_API int (luaL_argerror) (lua_State *L, int numarg, const char *extramsg); +LUALIB_API const char *(luaL_checklstring) (lua_State *L, int numArg, + size_t *l); +LUALIB_API const char *(luaL_optlstring) (lua_State *L, int numArg, + const char *def, size_t *l); +LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int numArg); +LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int nArg, lua_Number def); + +LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int numArg); +LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int nArg, + lua_Integer def); + +LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg); +LUALIB_API void (luaL_checktype) (lua_State *L, int narg, int t); +LUALIB_API void (luaL_checkany) (lua_State *L, int narg); + +LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname); +LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname); + +LUALIB_API void (luaL_where) (lua_State *L, int lvl); +LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...); + +LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def, + const char *const lst[]); + +LUALIB_API int (luaL_ref) (lua_State *L, int t); +LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref); + +LUALIB_API int (luaL_loadfile) (lua_State *L, const char *filename); +LUALIB_API int (luaL_loadbuffer) (lua_State *L, const char *buff, size_t sz, + const char *name); +LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s); + +LUALIB_API lua_State *(luaL_newstate) (void); + + +LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p, + const char *r); + +LUALIB_API const char *(luaL_findtable) (lua_State *L, int idx, + const char *fname, int szhint); + + + + +/* +** =============================================================== +** some useful macros +** =============================================================== +*/ + +#define luaL_argcheck(L, cond,numarg,extramsg) \ + ((void)((cond) || luaL_argerror(L, (numarg), (extramsg)))) +#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL)) +#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL)) +#define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n))) +#define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d))) +#define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n))) +#define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d))) + +#define luaL_typename(L,i) lua_typename(L, lua_type(L,(i))) + +#define luaL_dofile(L, fn) \ + (luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0)) + +#define luaL_dostring(L, s) \ + (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0)) + +#define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n))) + +#define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n))) + +/* +** {====================================================== +** Generic Buffer manipulation +** ======================================================= +*/ + + + +typedef struct luaL_Buffer { + char *p; /* current position in buffer */ + int lvl; /* number of strings in the stack (level) */ + lua_State *L; + char buffer[LUAL_BUFFERSIZE]; +} luaL_Buffer; + +#define luaL_addchar(B,c) \ + ((void)((B)->p < ((B)->buffer+LUAL_BUFFERSIZE) || luaL_prepbuffer(B)), \ + (*(B)->p++ = (char)(c))) + +/* compatibility only */ +#define luaL_putchar(B,c) luaL_addchar(B,c) + +#define luaL_addsize(B,n) ((B)->p += (n)) + +LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B); +LUALIB_API char *(luaL_prepbuffer) (luaL_Buffer *B); +LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l); +LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s); +LUALIB_API void (luaL_addvalue) (luaL_Buffer *B); +LUALIB_API void (luaL_pushresult) (luaL_Buffer *B); + + +/* }====================================================== */ + + +/* compatibility with ref system */ + +/* pre-defined references */ +#define LUA_NOREF (-2) +#define LUA_REFNIL (-1) + +#define lua_ref(L,lock) ((lock) ? luaL_ref(L, LUA_REGISTRYINDEX) : \ + (lua_pushstring(L, "unlocked references are obsolete"), lua_error(L), 0)) + +#define lua_unref(L,ref) luaL_unref(L, LUA_REGISTRYINDEX, (ref)) + +#define lua_getref(L,ref) lua_rawgeti(L, LUA_REGISTRYINDEX, (ref)) + + +#define luaL_reg luaL_Reg + +#endif + + diff --git a/vendor/lua/5.1/include/lua.h b/vendor/lua/5.1/include/lua.h new file mode 100644 index 000000000..a4b73e743 --- /dev/null +++ b/vendor/lua/5.1/include/lua.h @@ -0,0 +1,388 @@ +/* +** $Id: lua.h,v 1.218.1.7 2012/01/13 20:36:20 roberto Exp $ +** Lua - An Extensible Extension Language +** Lua.org, PUC-Rio, Brazil (http://www.lua.org) +** See Copyright Notice at the end of this file +*/ + + +#ifndef lua_h +#define lua_h + +#include +#include + + +#include "luaconf.h" + + +#define LUA_VERSION "Lua 5.1" +#define LUA_RELEASE "Lua 5.1.5" +#define LUA_VERSION_NUM 501 +#define LUA_COPYRIGHT "Copyright (C) 1994-2012 Lua.org, PUC-Rio" +#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes" + + +/* mark for precompiled code (`Lua') */ +#define LUA_SIGNATURE "\033Lua" + +/* option for multiple returns in `lua_pcall' and `lua_call' */ +#define LUA_MULTRET (-1) + + +/* +** pseudo-indices +*/ +#define LUA_REGISTRYINDEX (-10000) +#define LUA_ENVIRONINDEX (-10001) +#define LUA_GLOBALSINDEX (-10002) +#define lua_upvalueindex(i) (LUA_GLOBALSINDEX-(i)) + + +/* thread status; 0 is OK */ +#define LUA_YIELD 1 +#define LUA_ERRRUN 2 +#define LUA_ERRSYNTAX 3 +#define LUA_ERRMEM 4 +#define LUA_ERRERR 5 + + +typedef struct lua_State lua_State; + +typedef int (*lua_CFunction) (lua_State *L); + + +/* +** functions that read/write blocks when loading/dumping Lua chunks +*/ +typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz); + +typedef int (*lua_Writer) (lua_State *L, const void* p, size_t sz, void* ud); + + +/* +** prototype for memory-allocation functions +*/ +typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize); + + +/* +** basic types +*/ +#define LUA_TNONE (-1) + +#define LUA_TNIL 0 +#define LUA_TBOOLEAN 1 +#define LUA_TLIGHTUSERDATA 2 +#define LUA_TNUMBER 3 +#define LUA_TSTRING 4 +#define LUA_TTABLE 5 +#define LUA_TFUNCTION 6 +#define LUA_TUSERDATA 7 +#define LUA_TTHREAD 8 + + + +/* minimum Lua stack available to a C function */ +#define LUA_MINSTACK 20 + + +/* +** generic extra include file +*/ +#if defined(LUA_USER_H) +#include LUA_USER_H +#endif + + +/* type of numbers in Lua */ +typedef LUA_NUMBER lua_Number; + + +/* type for integer functions */ +typedef LUA_INTEGER lua_Integer; + + + +/* +** state manipulation +*/ +LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud); +LUA_API void (lua_close) (lua_State *L); +LUA_API lua_State *(lua_newthread) (lua_State *L); + +LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf); + + +/* +** basic stack manipulation +*/ +LUA_API int (lua_gettop) (lua_State *L); +LUA_API void (lua_settop) (lua_State *L, int idx); +LUA_API void (lua_pushvalue) (lua_State *L, int idx); +LUA_API void (lua_remove) (lua_State *L, int idx); +LUA_API void (lua_insert) (lua_State *L, int idx); +LUA_API void (lua_replace) (lua_State *L, int idx); +LUA_API int (lua_checkstack) (lua_State *L, int sz); + +LUA_API void (lua_xmove) (lua_State *from, lua_State *to, int n); + + +/* +** access functions (stack -> C) +*/ + +LUA_API int (lua_isnumber) (lua_State *L, int idx); +LUA_API int (lua_isstring) (lua_State *L, int idx); +LUA_API int (lua_iscfunction) (lua_State *L, int idx); +LUA_API int (lua_isuserdata) (lua_State *L, int idx); +LUA_API int (lua_type) (lua_State *L, int idx); +LUA_API const char *(lua_typename) (lua_State *L, int tp); + +LUA_API int (lua_equal) (lua_State *L, int idx1, int idx2); +LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2); +LUA_API int (lua_lessthan) (lua_State *L, int idx1, int idx2); + +LUA_API lua_Number (lua_tonumber) (lua_State *L, int idx); +LUA_API lua_Integer (lua_tointeger) (lua_State *L, int idx); +LUA_API int (lua_toboolean) (lua_State *L, int idx); +LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len); +LUA_API size_t (lua_objlen) (lua_State *L, int idx); +LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx); +LUA_API void *(lua_touserdata) (lua_State *L, int idx); +LUA_API lua_State *(lua_tothread) (lua_State *L, int idx); +LUA_API const void *(lua_topointer) (lua_State *L, int idx); + + +/* +** push functions (C -> stack) +*/ +LUA_API void (lua_pushnil) (lua_State *L); +LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n); +LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n); +LUA_API void (lua_pushlstring) (lua_State *L, const char *s, size_t l); +LUA_API void (lua_pushstring) (lua_State *L, const char *s); +LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt, + va_list argp); +LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...); +LUA_API void (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n); +LUA_API void (lua_pushboolean) (lua_State *L, int b); +LUA_API void (lua_pushlightuserdata) (lua_State *L, void *p); +LUA_API int (lua_pushthread) (lua_State *L); + + +/* +** get functions (Lua -> stack) +*/ +LUA_API void (lua_gettable) (lua_State *L, int idx); +LUA_API void (lua_getfield) (lua_State *L, int idx, const char *k); +LUA_API void (lua_rawget) (lua_State *L, int idx); +LUA_API void (lua_rawgeti) (lua_State *L, int idx, int n); +LUA_API void (lua_createtable) (lua_State *L, int narr, int nrec); +LUA_API void *(lua_newuserdata) (lua_State *L, size_t sz); +LUA_API int (lua_getmetatable) (lua_State *L, int objindex); +LUA_API void (lua_getfenv) (lua_State *L, int idx); + + +/* +** set functions (stack -> Lua) +*/ +LUA_API void (lua_settable) (lua_State *L, int idx); +LUA_API void (lua_setfield) (lua_State *L, int idx, const char *k); +LUA_API void (lua_rawset) (lua_State *L, int idx); +LUA_API void (lua_rawseti) (lua_State *L, int idx, int n); +LUA_API int (lua_setmetatable) (lua_State *L, int objindex); +LUA_API int (lua_setfenv) (lua_State *L, int idx); + + +/* +** `load' and `call' functions (load and run Lua code) +*/ +LUA_API void (lua_call) (lua_State *L, int nargs, int nresults); +LUA_API int (lua_pcall) (lua_State *L, int nargs, int nresults, int errfunc); +LUA_API int (lua_cpcall) (lua_State *L, lua_CFunction func, void *ud); +LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt, + const char *chunkname); + +LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data); + + +/* +** coroutine functions +*/ +LUA_API int (lua_yield) (lua_State *L, int nresults); +LUA_API int (lua_resume) (lua_State *L, int narg); +LUA_API int (lua_status) (lua_State *L); + +/* +** garbage-collection function and options +*/ + +#define LUA_GCSTOP 0 +#define LUA_GCRESTART 1 +#define LUA_GCCOLLECT 2 +#define LUA_GCCOUNT 3 +#define LUA_GCCOUNTB 4 +#define LUA_GCSTEP 5 +#define LUA_GCSETPAUSE 6 +#define LUA_GCSETSTEPMUL 7 + +LUA_API int (lua_gc) (lua_State *L, int what, int data); + + +/* +** miscellaneous functions +*/ + +LUA_API int (lua_error) (lua_State *L); + +LUA_API int (lua_next) (lua_State *L, int idx); + +LUA_API void (lua_concat) (lua_State *L, int n); + +LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud); +LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud); + + + +/* +** =============================================================== +** some useful macros +** =============================================================== +*/ + +#define lua_pop(L,n) lua_settop(L, -(n)-1) + +#define lua_newtable(L) lua_createtable(L, 0, 0) + +#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n))) + +#define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0) + +#define lua_strlen(L,i) lua_objlen(L, (i)) + +#define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION) +#define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE) +#define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA) +#define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL) +#define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN) +#define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD) +#define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE) +#define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0) + +#define lua_pushliteral(L, s) \ + lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1) + +#define lua_setglobal(L,s) lua_setfield(L, LUA_GLOBALSINDEX, (s)) +#define lua_getglobal(L,s) lua_getfield(L, LUA_GLOBALSINDEX, (s)) + +#define lua_tostring(L,i) lua_tolstring(L, (i), NULL) + + + +/* +** compatibility macros and functions +*/ + +#define lua_open() luaL_newstate() + +#define lua_getregistry(L) lua_pushvalue(L, LUA_REGISTRYINDEX) + +#define lua_getgccount(L) lua_gc(L, LUA_GCCOUNT, 0) + +#define lua_Chunkreader lua_Reader +#define lua_Chunkwriter lua_Writer + + +/* hack */ +LUA_API void lua_setlevel (lua_State *from, lua_State *to); + + +/* +** {====================================================================== +** Debug API +** ======================================================================= +*/ + + +/* +** Event codes +*/ +#define LUA_HOOKCALL 0 +#define LUA_HOOKRET 1 +#define LUA_HOOKLINE 2 +#define LUA_HOOKCOUNT 3 +#define LUA_HOOKTAILRET 4 + + +/* +** Event masks +*/ +#define LUA_MASKCALL (1 << LUA_HOOKCALL) +#define LUA_MASKRET (1 << LUA_HOOKRET) +#define LUA_MASKLINE (1 << LUA_HOOKLINE) +#define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT) + +typedef struct lua_Debug lua_Debug; /* activation record */ + + +/* Functions to be called by the debuger in specific events */ +typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar); + + +LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar); +LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar); +LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n); +LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n); +LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n); +LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n); + +LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count); +LUA_API lua_Hook lua_gethook (lua_State *L); +LUA_API int lua_gethookmask (lua_State *L); +LUA_API int lua_gethookcount (lua_State *L); + + +struct lua_Debug { + int event; + const char *name; /* (n) */ + const char *namewhat; /* (n) `global', `local', `field', `method' */ + const char *what; /* (S) `Lua', `C', `main', `tail' */ + const char *source; /* (S) */ + int currentline; /* (l) */ + int nups; /* (u) number of upvalues */ + int linedefined; /* (S) */ + int lastlinedefined; /* (S) */ + char short_src[LUA_IDSIZE]; /* (S) */ + /* private part */ + int i_ci; /* active function */ +}; + +/* }====================================================================== */ + + +/****************************************************************************** +* Copyright (C) 1994-2012 Lua.org, PUC-Rio. All rights reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining +* a copy of this software and associated documentation files (the +* "Software"), to deal in the Software without restriction, including +* without limitation the rights to use, copy, modify, merge, publish, +* distribute, sublicense, and/or sell copies of the Software, and to +* permit persons to whom the Software is furnished to do so, subject to +* the following conditions: +* +* The above copyright notice and this permission notice shall be +* included in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ + + +#endif diff --git a/vendor/lua/5.1/include/lua.hpp b/vendor/lua/5.1/include/lua.hpp new file mode 100644 index 000000000..ec417f594 --- /dev/null +++ b/vendor/lua/5.1/include/lua.hpp @@ -0,0 +1,9 @@ +// lua.hpp +// Lua header files for C++ +// <> not supplied automatically because Lua also compiles as C++ + +extern "C" { +#include "lua.h" +#include "lualib.h" +#include "lauxlib.h" +} diff --git a/vendor/lua/5.1/include/luaconf.h b/vendor/lua/5.1/include/luaconf.h new file mode 100644 index 000000000..05354175b --- /dev/null +++ b/vendor/lua/5.1/include/luaconf.h @@ -0,0 +1,766 @@ +/* +** $Id: luaconf.h,v 1.82.1.7 2008/02/11 16:25:08 roberto Exp $ +** Configuration file for Lua +** See Copyright Notice in lua.h +*/ + + +#ifndef lconfig_h +#define lconfig_h + +#include +#include + + +/* +** ================================================================== +** Search for "@@" to find all configurable definitions. +** =================================================================== +*/ + + +/* +@@ LUA_ANSI controls the use of non-ansi features. +** CHANGE it (define it) if you want Lua to avoid the use of any +** non-ansi feature or library. +*/ +#if defined(__STRICT_ANSI__) +#define LUA_ANSI +#endif + + +#if !defined(LUA_ANSI) && defined(_WIN32) +#define LUA_WIN +#endif + +#if defined(LUA_USE_LINUX) +#define LUA_USE_POSIX +#define LUA_USE_DLOPEN /* needs an extra library: -ldl */ +#define LUA_USE_READLINE /* needs some extra libraries */ +#endif + +#if defined(LUA_USE_MACOSX) +#define LUA_USE_POSIX +#define LUA_DL_DYLD /* does not need extra library */ +#endif + + + +/* +@@ LUA_USE_POSIX includes all functionallity listed as X/Open System +@* Interfaces Extension (XSI). +** CHANGE it (define it) if your system is XSI compatible. +*/ +#if defined(LUA_USE_POSIX) +#define LUA_USE_MKSTEMP +#define LUA_USE_ISATTY +#define LUA_USE_POPEN +#define LUA_USE_ULONGJMP +#endif + + +/* +@@ LUA_PATH and LUA_CPATH are the names of the environment variables that +@* Lua check to set its paths. +@@ LUA_INIT is the name of the environment variable that Lua +@* checks for initialization code. +** CHANGE them if you want different names. +*/ +#define LUA_PATH "LUA_PATH" +#define LUA_CPATH "LUA_CPATH" +#define LUA_INIT "LUA_INIT" + + +/* +@@ LUA_PATH_DEFAULT is the default path that Lua uses to look for +@* Lua libraries. +@@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for +@* C libraries. +** CHANGE them if your machine has a non-conventional directory +** hierarchy or if you want to install your libraries in +** non-conventional directories. +*/ +#if defined(_WIN32) +/* +** In Windows, any exclamation mark ('!') in the path is replaced by the +** path of the directory of the executable file of the current process. +*/ +#define LUA_LDIR "!\\lua\\" +#define LUA_CDIR "!\\" +#define LUA_PATH_DEFAULT \ + ".\\?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \ + LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua" +#define LUA_CPATH_DEFAULT \ + ".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll;" \ + LUA_CDIR"clibs\\?.dll;" LUA_CDIR"clibs\\loadall.dll;" \ + ".\\?51.dll;" LUA_CDIR"?51.dll;" LUA_CDIR"clibs\\?51.dll" + +#else +#define LUA_ROOT "/usr/local/" +#define LUA_LDIR LUA_ROOT "share/lua/5.1/" +#define LUA_CDIR LUA_ROOT "lib/lua/5.1/" +#define LUA_PATH_DEFAULT \ + "./?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ + LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua" +#define LUA_CPATH_DEFAULT \ + "./?.so;" LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" \ + "./lib?51.so;" LUA_CDIR"lib?51.so" +#endif + + +/* +@@ LUA_DIRSEP is the directory separator (for submodules). +** CHANGE it if your machine does not use "/" as the directory separator +** and is not Windows. (On Windows Lua automatically uses "\".) +*/ +#if defined(_WIN32) +#define LUA_DIRSEP "\\" +#else +#define LUA_DIRSEP "/" +#endif + + +/* +@@ LUA_PATHSEP is the character that separates templates in a path. +@@ LUA_PATH_MARK is the string that marks the substitution points in a +@* template. +@@ LUA_EXECDIR in a Windows path is replaced by the executable's +@* directory. +@@ LUA_IGMARK is a mark to ignore all before it when bulding the +@* luaopen_ function name. +** CHANGE them if for some reason your system cannot use those +** characters. (E.g., if one of those characters is a common character +** in file/directory names.) Probably you do not need to change them. +*/ +#define LUA_PATHSEP ";" +#define LUA_PATH_MARK "?" +#define LUA_EXECDIR "!" +#define LUA_IGMARK "-" + + +/* +@@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger. +** CHANGE that if ptrdiff_t is not adequate on your machine. (On most +** machines, ptrdiff_t gives a good choice between int or long.) +*/ +#define LUA_INTEGER ptrdiff_t + + +/* +@@ LUA_API is a mark for all core API functions. +@@ LUALIB_API is a mark for all standard library functions. +** CHANGE them if you need to define those functions in some special way. +** For instance, if you want to create one Windows DLL with the core and +** the libraries, you may want to use the following definition (define +** LUA_BUILD_AS_DLL to get it). +*/ +#if defined(LUA_BUILD_AS_DLL) + +#if defined(LUA_CORE) || defined(LUA_LIB) +#define LUA_API __declspec(dllexport) +#else +#define LUA_API __declspec(dllimport) +#endif + +#else + +#define LUA_API extern + +#endif + +/* more often than not the libs go together with the core */ +#define LUALIB_API LUA_API + + +/* +@@ LUAI_FUNC is a mark for all extern functions that are not to be +@* exported to outside modules. +@@ LUAI_DATA is a mark for all extern (const) variables that are not to +@* be exported to outside modules. +** CHANGE them if you need to mark them in some special way. Elf/gcc +** (versions 3.2 and later) mark them as "hidden" to optimize access +** when Lua is compiled as a shared library. +*/ +#if defined(luaall_c) +#define LUAI_FUNC static +#define LUAI_DATA /* empty */ + +#elif defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \ + defined(__ELF__) +#define LUAI_FUNC __attribute__((visibility("hidden"))) extern +#define LUAI_DATA LUAI_FUNC + +#else +#define LUAI_FUNC extern +#define LUAI_DATA extern +#endif + + + +/* +@@ LUA_QL describes how error messages quote program elements. +** CHANGE it if you want a different appearance. +*/ +#define LUA_QL(x) "'" x "'" +#define LUA_QS LUA_QL("%s") + + +/* +@@ LUA_IDSIZE gives the maximum size for the description of the source +@* of a function in debug information. +** CHANGE it if you want a different size. +*/ +#define LUA_IDSIZE 60 + + +/* +** {================================================================== +** Stand-alone configuration +** =================================================================== +*/ + +#if defined(lua_c) || defined(luaall_c) + +/* +@@ lua_stdin_is_tty detects whether the standard input is a 'tty' (that +@* is, whether we're running lua interactively). +** CHANGE it if you have a better definition for non-POSIX/non-Windows +** systems. +*/ +#if defined(LUA_USE_ISATTY) +#include +#define lua_stdin_is_tty() isatty(0) +#elif defined(LUA_WIN) +#include +#include +#define lua_stdin_is_tty() _isatty(_fileno(stdin)) +#else +#define lua_stdin_is_tty() 1 /* assume stdin is a tty */ +#endif + + +/* +@@ LUA_PROMPT is the default prompt used by stand-alone Lua. +@@ LUA_PROMPT2 is the default continuation prompt used by stand-alone Lua. +** CHANGE them if you want different prompts. (You can also change the +** prompts dynamically, assigning to globals _PROMPT/_PROMPT2.) +*/ +#define LUA_PROMPT "> " +#define LUA_PROMPT2 ">> " + + +/* +@@ LUA_PROGNAME is the default name for the stand-alone Lua program. +** CHANGE it if your stand-alone interpreter has a different name and +** your system is not able to detect that name automatically. +*/ +#define LUA_PROGNAME "lua" + + +/* +@@ LUA_MAXINPUT is the maximum length for an input line in the +@* stand-alone interpreter. +** CHANGE it if you need longer lines. +*/ +#define LUA_MAXINPUT 512 + + +/* +@@ lua_readline defines how to show a prompt and then read a line from +@* the standard input. +@@ lua_saveline defines how to "save" a read line in a "history". +@@ lua_freeline defines how to free a line read by lua_readline. +** CHANGE them if you want to improve this functionality (e.g., by using +** GNU readline and history facilities). +*/ +#if defined(LUA_USE_READLINE) +#include +#include +#include +#define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL) +#define lua_saveline(L,idx) \ + if (lua_strlen(L,idx) > 0) /* non-empty line? */ \ + add_history(lua_tostring(L, idx)); /* add it to history */ +#define lua_freeline(L,b) ((void)L, free(b)) +#else +#define lua_readline(L,b,p) \ + ((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \ + fgets(b, LUA_MAXINPUT, stdin) != NULL) /* get line */ +#define lua_saveline(L,idx) { (void)L; (void)idx; } +#define lua_freeline(L,b) { (void)L; (void)b; } +#endif + +#endif + +/* }================================================================== */ + + +/* +@@ LUAI_GCPAUSE defines the default pause between garbage-collector cycles +@* as a percentage. +** CHANGE it if you want the GC to run faster or slower (higher values +** mean larger pauses which mean slower collection.) You can also change +** this value dynamically. +*/ +#define LUAI_GCPAUSE 200 /* 200% (wait memory to double before next GC) */ + + +/* +@@ LUAI_GCMUL defines the default speed of garbage collection relative to +@* memory allocation as a percentage. +** CHANGE it if you want to change the granularity of the garbage +** collection. (Higher values mean coarser collections. 0 represents +** infinity, where each step performs a full collection.) You can also +** change this value dynamically. +*/ +#define LUAI_GCMUL 200 /* GC runs 'twice the speed' of memory allocation */ + + + +/* +@@ LUA_COMPAT_GETN controls compatibility with old getn behavior. +** CHANGE it (define it) if you want exact compatibility with the +** behavior of setn/getn in Lua 5.0. +*/ +#undef LUA_COMPAT_GETN + +/* +@@ LUA_COMPAT_LOADLIB controls compatibility about global loadlib. +** CHANGE it to undefined as soon as you do not need a global 'loadlib' +** function (the function is still available as 'package.loadlib'). +*/ +#undef LUA_COMPAT_LOADLIB + +/* +@@ LUA_COMPAT_VARARG controls compatibility with old vararg feature. +** CHANGE it to undefined as soon as your programs use only '...' to +** access vararg parameters (instead of the old 'arg' table). +*/ +#define LUA_COMPAT_VARARG + +/* +@@ LUA_COMPAT_MOD controls compatibility with old math.mod function. +** CHANGE it to undefined as soon as your programs use 'math.fmod' or +** the new '%' operator instead of 'math.mod'. +*/ +#define LUA_COMPAT_MOD + +/* +@@ LUA_COMPAT_LSTR controls compatibility with old long string nesting +@* facility. +** CHANGE it to 2 if you want the old behaviour, or undefine it to turn +** off the advisory error when nesting [[...]]. +*/ +#define LUA_COMPAT_LSTR 1 + +/* +@@ LUA_COMPAT_GFIND controls compatibility with old 'string.gfind' name. +** CHANGE it to undefined as soon as you rename 'string.gfind' to +** 'string.gmatch'. +*/ +#define LUA_COMPAT_GFIND + +/* +@@ LUA_COMPAT_OPENLIB controls compatibility with old 'luaL_openlib' +@* behavior. +** CHANGE it to undefined as soon as you replace to 'luaL_register' +** your uses of 'luaL_openlib' +*/ +#define LUA_COMPAT_OPENLIB + + + +/* +@@ luai_apicheck is the assert macro used by the Lua-C API. +** CHANGE luai_apicheck if you want Lua to perform some checks in the +** parameters it gets from API calls. This may slow down the interpreter +** a bit, but may be quite useful when debugging C code that interfaces +** with Lua. A useful redefinition is to use assert.h. +*/ +#if defined(LUA_USE_APICHECK) +#include +#define luai_apicheck(L,o) { (void)L; assert(o); } +#else +#define luai_apicheck(L,o) { (void)L; } +#endif + + +/* +@@ LUAI_BITSINT defines the number of bits in an int. +** CHANGE here if Lua cannot automatically detect the number of bits of +** your machine. Probably you do not need to change this. +*/ +/* avoid overflows in comparison */ +#if INT_MAX-20 < 32760 +#define LUAI_BITSINT 16 +#elif INT_MAX > 2147483640L +/* int has at least 32 bits */ +#define LUAI_BITSINT 32 +#else +#error "you must define LUA_BITSINT with number of bits in an integer" +#endif + + +/* +@@ LUAI_UINT32 is an unsigned integer with at least 32 bits. +@@ LUAI_INT32 is an signed integer with at least 32 bits. +@@ LUAI_UMEM is an unsigned integer big enough to count the total +@* memory used by Lua. +@@ LUAI_MEM is a signed integer big enough to count the total memory +@* used by Lua. +** CHANGE here if for some weird reason the default definitions are not +** good enough for your machine. (The definitions in the 'else' +** part always works, but may waste space on machines with 64-bit +** longs.) Probably you do not need to change this. +*/ +#if LUAI_BITSINT >= 32 +#define LUAI_UINT32 unsigned int +#define LUAI_INT32 int +#define LUAI_MAXINT32 INT_MAX +#define LUAI_UMEM size_t +#define LUAI_MEM ptrdiff_t +#else +/* 16-bit ints */ +#define LUAI_UINT32 unsigned long +#define LUAI_INT32 long +#define LUAI_MAXINT32 LONG_MAX +#define LUAI_UMEM unsigned long +#define LUAI_MEM long +#endif + + +/* +@@ LUAI_MAXCALLS limits the number of nested calls. +** CHANGE it if you need really deep recursive calls. This limit is +** arbitrary; its only purpose is to stop infinite recursion before +** exhausting memory. +*/ +#define LUAI_MAXCALLS 20000 + + +/* +@@ LUAI_MAXCSTACK limits the number of Lua stack slots that a C function +@* can use. +** CHANGE it if you need lots of (Lua) stack space for your C +** functions. This limit is arbitrary; its only purpose is to stop C +** functions to consume unlimited stack space. (must be smaller than +** -LUA_REGISTRYINDEX) +*/ +#define LUAI_MAXCSTACK 8000 + + + +/* +** {================================================================== +** CHANGE (to smaller values) the following definitions if your system +** has a small C stack. (Or you may want to change them to larger +** values if your system has a large C stack and these limits are +** too rigid for you.) Some of these constants control the size of +** stack-allocated arrays used by the compiler or the interpreter, while +** others limit the maximum number of recursive calls that the compiler +** or the interpreter can perform. Values too large may cause a C stack +** overflow for some forms of deep constructs. +** =================================================================== +*/ + + +/* +@@ LUAI_MAXCCALLS is the maximum depth for nested C calls (short) and +@* syntactical nested non-terminals in a program. +*/ +#define LUAI_MAXCCALLS 200 + + +/* +@@ LUAI_MAXVARS is the maximum number of local variables per function +@* (must be smaller than 250). +*/ +#define LUAI_MAXVARS 200 + + +/* +@@ LUAI_MAXUPVALUES is the maximum number of upvalues per function +@* (must be smaller than 250). +*/ +#define LUAI_MAXUPVALUES 60 + + +/* +@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. +*/ +#define LUAL_BUFFERSIZE BUFSIZ + +/* }================================================================== */ + + + + +/* +** {================================================================== +@@ LUA_NUMBER is the type of numbers in Lua. +** CHANGE the following definitions only if you want to build Lua +** with a number type different from double. You may also need to +** change lua_number2int & lua_number2integer. +** =================================================================== +*/ + +#define LUA_NUMBER_DOUBLE +#define LUA_NUMBER double + +/* +@@ LUAI_UACNUMBER is the result of an 'usual argument conversion' +@* over a number. +*/ +#define LUAI_UACNUMBER double + + +/* +@@ LUA_NUMBER_SCAN is the format for reading numbers. +@@ LUA_NUMBER_FMT is the format for writing numbers. +@@ lua_number2str converts a number to a string. +@@ LUAI_MAXNUMBER2STR is maximum size of previous conversion. +@@ lua_str2number converts a string to a number. +*/ +#define LUA_NUMBER_SCAN "%lf" +#define LUA_NUMBER_FMT "%.14g" +#define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n)) +#define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */ +#define lua_str2number(s,p) strtod((s), (p)) + + +/* +@@ The luai_num* macros define the primitive operations over numbers. +*/ +#if defined(LUA_CORE) +#include +#define luai_numadd(a,b) ((a)+(b)) +#define luai_numsub(a,b) ((a)-(b)) +#define luai_nummul(a,b) ((a)*(b)) +#define luai_numdiv(a,b) ((a)/(b)) +#define luai_nummod(a,b) ((a) - floor((a)/(b))*(b)) +#define luai_numpow(a,b) (pow(a,b)) +#define luai_numunm(a) (-(a)) +#define luai_numeq(a,b) ((a)==(b)) +#define luai_numlt(a,b) ((a)<(b)) +#define luai_numle(a,b) ((a)<=(b)) +#define luai_numisnan(a) (!luai_numeq((a), (a))) +#endif + + +/* +@@ lua_number2int is a macro to convert lua_Number to int. +@@ lua_number2integer is a macro to convert lua_Number to lua_Integer. +** CHANGE them if you know a faster way to convert a lua_Number to +** int (with any rounding method and without throwing errors) in your +** system. In Pentium machines, a naive typecast from double to int +** in C is extremely slow, so any alternative is worth trying. +*/ + +/* On a Pentium, resort to a trick */ +#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \ + (defined(__i386) || defined (_M_IX86) || defined(__i386__)) + +/* On a Microsoft compiler, use assembler */ +#if defined(_MSC_VER) + +#define lua_number2int(i,d) __asm fld d __asm fistp i +#define lua_number2integer(i,n) lua_number2int(i, n) + +/* the next trick should work on any Pentium, but sometimes clashes + with a DirectX idiosyncrasy */ +#else + +union luai_Cast { double l_d; long l_l; }; +#define lua_number2int(i,d) \ + { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; } +#define lua_number2integer(i,n) lua_number2int(i, n) + +#endif + + +/* this option always works, but may be slow */ +#else +#define lua_number2int(i,d) ((i)=(int)(d)) +#define lua_number2integer(i,d) ((i)=(lua_Integer)(d)) + +#endif + +/* }================================================================== */ + + +/* +@@ LUAI_USER_ALIGNMENT_T is a type that requires maximum alignment. +** CHANGE it if your system requires alignments larger than double. (For +** instance, if your system supports long doubles and they must be +** aligned in 16-byte boundaries, then you should add long double in the +** union.) Probably you do not need to change this. +*/ +#define LUAI_USER_ALIGNMENT_T union { double u; void *s; long l; } + + +/* +@@ LUAI_THROW/LUAI_TRY define how Lua does exception handling. +** CHANGE them if you prefer to use longjmp/setjmp even with C++ +** or if want/don't to use _longjmp/_setjmp instead of regular +** longjmp/setjmp. By default, Lua handles errors with exceptions when +** compiling as C++ code, with _longjmp/_setjmp when asked to use them, +** and with longjmp/setjmp otherwise. +*/ +#if defined(__cplusplus) +/* C++ exceptions */ +#define LUAI_THROW(L,c) throw(c) +#define LUAI_TRY(L,c,a) try { a } catch(...) \ + { if ((c)->status == 0) (c)->status = -1; } +#define luai_jmpbuf int /* dummy variable */ + +#elif defined(LUA_USE_ULONGJMP) +/* in Unix, try _longjmp/_setjmp (more efficient) */ +#define LUAI_THROW(L,c) _longjmp((c)->b, 1) +#define LUAI_TRY(L,c,a) if (_setjmp((c)->b) == 0) { a } +#define luai_jmpbuf jmp_buf + +#else +/* default handling with long jumps */ +#define LUAI_THROW(L,c) longjmp((c)->b, 1) +#define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a } +#define luai_jmpbuf jmp_buf + +#endif + + +/* +@@ LUA_MAXCAPTURES is the maximum number of captures that a pattern +@* can do during pattern-matching. +** CHANGE it if you need more captures. This limit is arbitrary. +*/ +#define LUA_MAXCAPTURES 32 + + +/* +@@ lua_tmpnam is the function that the OS library uses to create a +@* temporary name. +@@ LUA_TMPNAMBUFSIZE is the maximum size of a name created by lua_tmpnam. +** CHANGE them if you have an alternative to tmpnam (which is considered +** insecure) or if you want the original tmpnam anyway. By default, Lua +** uses tmpnam except when POSIX is available, where it uses mkstemp. +*/ +#if defined(loslib_c) || defined(luaall_c) + +#if defined(LUA_USE_MKSTEMP) +#include +#define LUA_TMPNAMBUFSIZE 32 +#define lua_tmpnam(b,e) { \ + strcpy(b, "/tmp/lua_XXXXXX"); \ + e = mkstemp(b); \ + if (e != -1) close(e); \ + e = (e == -1); } + +#else +#define LUA_TMPNAMBUFSIZE L_tmpnam +#define lua_tmpnam(b,e) { e = (tmpnam(b) == NULL); } +#endif + +#endif + + +/* +@@ lua_popen spawns a new process connected to the current one through +@* the file streams. +** CHANGE it if you have a way to implement it in your system. +*/ +#if defined(LUA_USE_POPEN) + +#define lua_popen(L,c,m) ((void)L, fflush(NULL), popen(c,m)) +#define lua_pclose(L,file) ((void)L, (pclose(file) != -1)) + +#elif defined(LUA_WIN) + +#define lua_popen(L,c,m) ((void)L, _popen(c,m)) +#define lua_pclose(L,file) ((void)L, (_pclose(file) != -1)) + +#else + +#define lua_popen(L,c,m) ((void)((void)c, m), \ + luaL_error(L, LUA_QL("popen") " not supported"), (FILE*)0) +#define lua_pclose(L,file) ((void)((void)L, file), 0) + +#endif + +/* +@@ LUA_DL_* define which dynamic-library system Lua should use. +** CHANGE here if Lua has problems choosing the appropriate +** dynamic-library system for your platform (either Windows' DLL, Mac's +** dyld, or Unix's dlopen). If your system is some kind of Unix, there +** is a good chance that it has dlopen, so LUA_DL_DLOPEN will work for +** it. To use dlopen you also need to adapt the src/Makefile (probably +** adding -ldl to the linker options), so Lua does not select it +** automatically. (When you change the makefile to add -ldl, you must +** also add -DLUA_USE_DLOPEN.) +** If you do not want any kind of dynamic library, undefine all these +** options. +** By default, _WIN32 gets LUA_DL_DLL and MAC OS X gets LUA_DL_DYLD. +*/ +#if defined(LUA_USE_DLOPEN) +#define LUA_DL_DLOPEN +#endif + +#if defined(LUA_WIN) +#define LUA_DL_DLL +#endif + + +/* +@@ LUAI_EXTRASPACE allows you to add user-specific data in a lua_State +@* (the data goes just *before* the lua_State pointer). +** CHANGE (define) this if you really need that. This value must be +** a multiple of the maximum alignment required for your machine. +*/ +#define LUAI_EXTRASPACE 0 + + +/* +@@ luai_userstate* allow user-specific actions on threads. +** CHANGE them if you defined LUAI_EXTRASPACE and need to do something +** extra when a thread is created/deleted/resumed/yielded. +*/ +#define luai_userstateopen(L) ((void)L) +#define luai_userstateclose(L) ((void)L) +#define luai_userstatethread(L,L1) ((void)L) +#define luai_userstatefree(L) ((void)L) +#define luai_userstateresume(L,n) ((void)L) +#define luai_userstateyield(L,n) ((void)L) + + +/* +@@ LUA_INTFRMLEN is the length modifier for integer conversions +@* in 'string.format'. +@@ LUA_INTFRM_T is the integer type correspoding to the previous length +@* modifier. +** CHANGE them if your system supports long long or does not support long. +*/ + +#if defined(LUA_USELONGLONG) + +#define LUA_INTFRMLEN "ll" +#define LUA_INTFRM_T long long + +#else + +#define LUA_INTFRMLEN "l" +#define LUA_INTFRM_T long + +#endif + + + +/* =================================================================== */ + +/* +** Local configuration. You can use this space to add your redefinitions +** without modifying the main part of the file. +*/ + + + +#endif + diff --git a/vendor/lua/5.1/include/lualib.h b/vendor/lua/5.1/include/lualib.h new file mode 100644 index 000000000..469417f67 --- /dev/null +++ b/vendor/lua/5.1/include/lualib.h @@ -0,0 +1,53 @@ +/* +** $Id: lualib.h,v 1.36.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lua standard libraries +** See Copyright Notice in lua.h +*/ + + +#ifndef lualib_h +#define lualib_h + +#include "lua.h" + + +/* Key to file-handle type */ +#define LUA_FILEHANDLE "FILE*" + + +#define LUA_COLIBNAME "coroutine" +LUALIB_API int (luaopen_base) (lua_State *L); + +#define LUA_TABLIBNAME "table" +LUALIB_API int (luaopen_table) (lua_State *L); + +#define LUA_IOLIBNAME "io" +LUALIB_API int (luaopen_io) (lua_State *L); + +#define LUA_OSLIBNAME "os" +LUALIB_API int (luaopen_os) (lua_State *L); + +#define LUA_STRLIBNAME "string" +LUALIB_API int (luaopen_string) (lua_State *L); + +#define LUA_MATHLIBNAME "math" +LUALIB_API int (luaopen_math) (lua_State *L); + +#define LUA_DBLIBNAME "debug" +LUALIB_API int (luaopen_debug) (lua_State *L); + +#define LUA_LOADLIBNAME "package" +LUALIB_API int (luaopen_package) (lua_State *L); + + +/* open all previous libraries */ +LUALIB_API void (luaL_openlibs) (lua_State *L); + + + +#ifndef lua_assert +#define lua_assert(x) ((void)0) +#endif + + +#endif diff --git a/vendor/lua/5.1/linux/liblua5.1.a b/vendor/lua/5.1/linux/liblua5.1.a new file mode 100644 index 000000000..ce7e09844 Binary files /dev/null and b/vendor/lua/5.1/linux/liblua5.1.a differ diff --git a/vendor/lua/5.1/linux/liblua5.1.so b/vendor/lua/5.1/linux/liblua5.1.so new file mode 100644 index 000000000..2db7f6f67 Binary files /dev/null and b/vendor/lua/5.1/linux/liblua5.1.so differ diff --git a/vendor/lua/5.1/lua.odin b/vendor/lua/5.1/lua.odin new file mode 100644 index 000000000..5a0ae5bc7 --- /dev/null +++ b/vendor/lua/5.1/lua.odin @@ -0,0 +1,659 @@ +package lua_5_1 + +import "core:intrinsics" +import "core:builtin" + +import c "core:c/libc" + +#assert(size_of(c.int) == size_of(b32)) + +when ODIN_OS == .Windows { + foreign import lib "windows/lua5.1.dll.lib" +} else when ODIN_OS == .Linux { + foreign import lib "linux/liblua5.1.a" +} else { + foreign import lib "system:liblua5.1.a" +} + +VERSION :: "Lua 5.1" +RELEASE :: "Lua 5.1.5" +VERSION_NUM :: 501 +COPYRIGHT :: "Copyright (C) 1994-2012 Lua.org, PUC-Rio" +AUTHORS :: "R. Ierusalimschy, L. H. de Figueiredo & W. Celes" + +/* mark for precompiled code ('Lua') */ +SIGNATURE :: "\x1bLua" + +/* option for multiple returns in 'lua_pcall' and 'lua_call' */ +MULTRET :: -1 + +REGISTRYINDEX :: -10000 +ENVIRONINDEX :: -10001 +GLOBALSINDEX :: -10002 + +/* +@@ LUAI_MAXSTACK limits the size of the Lua stack. +** CHANGE it if you need a different limit. This limit is arbitrary; +** its only purpose is to stop Lua from consuming unlimited stack +** space (and to reserve some numbers for pseudo-indices). +** (It must fit into max(size_t)/32.) +*/ +MAXSTACK :: 1000000 + + +/* +@@ LUA_EXTRASPACE defines the size of a raw memory area associated with +** a Lua state with very fast access. +** CHANGE it if you need a different size. +*/ +EXTRASPACE :: size_of(rawptr) + + + +/* +@@ LUA_IDSIZE gives the maximum size for the description of the source +@@ of a function in debug information. +** CHANGE it if you want a different size. +*/ +IDSIZE :: 60 + + +/* +@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. +*/ +L_BUFFERSIZE :: c.int(16 * size_of(rawptr) * size_of(Number)) + + +MAXALIGNVAL :: max(align_of(Number), align_of(f64), align_of(rawptr), align_of(Integer), align_of(c.long)) + + +Status :: enum c.int { + OK = 0, + YIELD = 1, + ERRRUN = 2, + ERRSYNTAX = 3, + ERRMEM = 4, + ERRERR = 5, + ERRFILE = 6, +} + +/* thread status */ +OK :: Status.OK +YIELD :: Status.YIELD +ERRRUN :: Status.ERRRUN +ERRSYNTAX :: Status.ERRSYNTAX +ERRMEM :: Status.ERRMEM +ERRERR :: Status.ERRERR +ERRFILE :: Status.ERRFILE + +/* +** basic types +*/ + + +Type :: enum c.int { + NONE = -1, + + NIL = 0, + BOOLEAN = 1, + LIGHTUSERDATA = 2, + NUMBER = 3, + STRING = 4, + TABLE = 5, + FUNCTION = 6, + USERDATA = 7, + THREAD = 8, +} + +TNONE :: Type.NONE +TNIL :: Type.NIL +TBOOLEAN :: Type.BOOLEAN +TLIGHTUSERDATA :: Type.LIGHTUSERDATA +TNUMBER :: Type.NUMBER +TSTRING :: Type.STRING +TTABLE :: Type.TABLE +TFUNCTION :: Type.FUNCTION +TUSERDATA :: Type.USERDATA +TTHREAD :: Type.THREAD +NUMTYPES :: 9 + + +CompareOp :: enum c.int { + EQ = 0, + LT = 1, + LE = 2, +} + +OPEQ :: CompareOp.EQ +OPLT :: CompareOp.LT +OPLE :: CompareOp.LE + + +/* minimum Lua stack available to a C function */ +MINSTACK :: 20 + + +/* type of numbers in Lua */ +Number :: distinct (f32 when size_of(uintptr) == 4 else f64) + + +/* type for integer functions */ +Integer :: distinct (i32 when size_of(uintptr) == 4 else i64) + + +/* +** Type for C functions registered with Lua +*/ +CFunction :: #type proc "c" (L: ^State) -> c.int + + + +/* +** Type for functions that read/write blocks when loading/dumping Lua chunks +*/ +Reader :: #type proc "c" (L: ^State, ud: rawptr, sz: ^c.size_t) -> cstring +Writer :: #type proc "c" (L: ^State, p: rawptr, sz: ^c.size_t, ud: rawptr) -> c.int + + +/* +** Type for memory-allocation functions +*/ +Alloc :: #type proc "c" (ud: rawptr, ptr: rawptr, osize, nsize: c.size_t) -> rawptr + + +GCWhat :: enum c.int { + STOP = 0, + RESTART = 1, + COLLECT = 2, + COUNT = 3, + COUNTB = 4, + STEP = 5, + SETPAUSE = 6, + SETSTEPMUL = 7, +} +GCSTOP :: GCWhat.STOP +GCRESTART :: GCWhat.RESTART +GCCOLLECT :: GCWhat.COLLECT +GCCOUNT :: GCWhat.COUNT +GCCOUNTB :: GCWhat.COUNTB +GCSTEP :: GCWhat.STEP +GCSETPAUSE :: GCWhat.SETPAUSE +GCSETSTEPMUL :: GCWhat.SETSTEPMUL + + +/* +** Event codes +*/ + +HookEvent :: enum c.int { + CALL = 0, + RET = 1, + LINE = 2, + COUNT = 3, + TAILRET = 4, +} +HOOKCALL :: HookEvent.CALL +HOOKRET :: HookEvent.RET +HOOKLINE :: HookEvent.LINE +HOOKCOUNT :: HookEvent.COUNT +HOOKTAILRET :: HookEvent.TAILRET + + +/* +** Event masks +*/ +HookMask :: distinct bit_set[HookEvent; c.int] +MASKCALL :: HookMask{.CALL} +MASKRET :: HookMask{.RET} +MASKLINE :: HookMask{.LINE} +MASKCOUNT :: HookMask{.COUNT} + +/* activation record */ +Debug :: struct { + event: HookEvent, + name: cstring, /* (n) */ + namewhat: cstring, /* (n) 'global', 'local', 'field', 'method' */ + what: cstring, /* (S) 'Lua', 'C', 'main', 'tail' */ + source: cstring, /* (S) */ + currentline: c.int, /* (l) */ + nups: c.int, /* (u) number of upvalues */ + linedefined: c.int, /* (S) */ + lastlinedefined: c.int, /* (S) */ + short_src: [IDSIZE]u8 `fmt:"s"`, /* (S) */ + /* private part */ + i_ci: c.int, /* active function */ +} + + +/* Functions to be called by the debugger in specific events */ +Hook :: #type proc "c" (L: ^State, ar: ^Debug) + + +State :: struct {} // opaque data type + + +@(link_prefix="lua_") +@(default_calling_convention="c") +foreign lib { + /* + ** RCS ident string + */ + + ident: [^]u8 // TODO(bill): is this correct? + + + /* + ** state manipulation + */ + + newstate :: proc(f: Alloc, ud: rawptr) -> ^State --- + close :: proc(L: ^State) --- + newthread :: proc(L: ^State) -> ^State --- + + atpanic :: proc(L: ^State, panicf: CFunction) -> CFunction --- + + + /* + ** basic stack manipulation + */ + + gettop :: proc (L: ^State) -> c.int --- + settop :: proc (L: ^State, idx: c.int) --- + pushvalue :: proc (L: ^State, idx: c.int) --- + remove :: proc (L: ^State, idx: c.int) --- + insert :: proc (L: ^State, idx: c.int) --- + replace :: proc (L: ^State, idx: c.int) --- + checkstack :: proc (L: ^State, sz: c.int) -> c.int --- + + xmove :: proc(from, to: ^State, n: c.int) --- + + + /* + ** access functions (stack -> C) + */ + + isnumber :: proc(L: ^State, idx: c.int) -> b32 --- + isstring :: proc(L: ^State, idx: c.int) -> b32 --- + iscfunction :: proc(L: ^State, idx: c.int) -> b32 --- + isinteger :: proc(L: ^State, idx: c.int) -> b32 --- + isuserdata :: proc(L: ^State, idx: c.int) -> b32 --- + type :: proc(L: ^State, idx: c.int) -> Type --- + typename :: proc(L: ^State, tp: Type) -> cstring --- + + equal :: proc(L: ^State, idx1, idx2: c.int) -> b32 --- + rawequal :: proc(L: ^State, idx1, idx2: c.int) -> b32 --- + lessthan :: proc(L: ^State, idx1, idx2: c.int) -> b32 --- + + toboolean :: proc(L: ^State, idx: c.int) -> b32 --- + tolstring :: proc(L: ^State, idx: c.int, len: ^c.size_t) -> cstring --- + objlen :: proc(L: ^State, idx: c.int) -> c.size_t --- + tocfunction :: proc(L: ^State, idx: c.int) -> CFunction --- + touserdata :: proc(L: ^State, idx: c.int) -> rawptr --- + tothread :: proc(L: ^State, idx: c.int) -> ^State --- + topointer :: proc(L: ^State, idx: c.int) -> rawptr --- + + /* + ** push functions (C -> stack) + */ + + pushnil :: proc(L: ^State) --- + pushnumber :: proc(L: ^State, n: Number) --- + pushinteger :: proc(L: ^State, n: Integer) --- + pushlstring :: proc(L: ^State, s: cstring, l: c.size_t) --- + pushstring :: proc(L: ^State, s: cstring) --- + pushvfstring :: proc(L: ^State, fmt: cstring, argp: c.va_list) -> cstring --- + pushfstring :: proc(L: ^State, fmt: cstring, #c_vararg args: ..any) -> cstring --- + pushcclosure :: proc(L: ^State, fn: CFunction, n: c.int) --- + pushboolean :: proc(L: ^State, b: b32) --- + pushlightuserdata :: proc(L: ^State, p: rawptr) --- + pushthread :: proc(L: ^State) -> Status --- + + /* + ** get functions (Lua -> stack) + */ + + gettable :: proc(L: ^State, idx: c.int) --- + getfield :: proc(L: ^State, idx: c.int, k: cstring) --- + geti :: proc(L: ^State, idx: c.int, n: Integer) --- + rawget :: proc(L: ^State, idx: c.int) --- + rawgeti :: proc(L: ^State, idx: c.int, n: Integer) --- + rawgetp :: proc(L: ^State, idx: c.int, p: rawptr) --- + + createtable :: proc(L: ^State, narr, nrec: c.int) --- + newuserdata :: proc(L: ^State, sz: c.size_t) -> rawptr --- + getmetatable :: proc(L: ^State, objindex: c.int) -> c.int --- + getfenv :: proc(L: ^State, idx: c.int) --- + + + /* + ** set functions (stack -> Lua) + */ + + settable :: proc(L: ^State, idx: c.int) --- + setfield :: proc(L: ^State, idx: c.int, k: cstring) --- + rawset :: proc(L: ^State, idx: c.int) --- + rawseti :: proc(L: ^State, idx: c.int, n: c.int) --- + rawsetp :: proc(L: ^State, idx: c.int, p: rawptr) --- + setmetatable :: proc(L: ^State, objindex: c.int) -> c.int --- + setfenv :: proc(L: ^State, idx: c.int) -> c.int --- + + + /* + ** 'load' and 'call' functions (load and run Lua code) + */ + + call :: proc(L: ^State, nargs, nresults: c.int) --- + + getctx :: proc(L: ^State, ctx: ^c.int) -> c.int --- + + pcall :: proc(L: ^State, nargs, nresults: c.int, errfunc: c.int) -> c.int --- + cpcall :: proc(L: ^State, func: CFunction, ud: rawptr) -> c.int --- + + load :: proc(L: ^State, reader: Reader, dt: rawptr, + chunkname: cstring) -> Status --- + + dump :: proc(L: ^State, writer: Writer, data: rawptr) -> Status --- + + + /* + ** coroutine functions + */ + + yield :: proc(L: ^State, nresults: c.int) -> Status --- + resume :: proc(L: ^State, narg: c.int) -> Status --- + status :: proc(L: ^State) -> Status --- + + + /* + ** garbage-collection function and options + */ + + + + gc :: proc(L: ^State, what: GCWhat, data: c.int) -> c.int --- + + + /* + ** miscellaneous functions + */ + + error :: proc(L: ^State) -> Status --- + + next :: proc(L: ^State, idx: c.int) -> c.int --- + + concat :: proc(L: ^State, n: c.int) --- + len :: proc(L: ^State, idx: c.int) --- + + getallocf :: proc(L: State, ud: ^rawptr) -> Alloc --- + setallocf :: proc(L: ^State, f: Alloc, ud: rawptr) --- + + /* + ** {====================================================================== + ** Debug API + ** ======================================================================= + */ + + getstack :: proc(L: ^State, level: c.int, ar: ^Debug) -> c.int --- + getinfo :: proc(L: ^State, what: cstring, ar: ^Debug) -> c.int --- + getlocal :: proc(L: ^State, ar: ^Debug, n: c.int) -> cstring --- + setlocal :: proc(L: ^State, ar: ^Debug, n: c.int) -> cstring --- + getupvalue :: proc(L: ^State, funcindex: c.int, n: c.int) -> cstring --- + setupvalue :: proc(L: ^State, funcindex: c.int, n: c.int) -> cstring --- + + sethook :: proc(L: ^State, func: Hook, mask: HookMask, count: c.int) -> c.int --- + gethook :: proc(L: ^State) -> Hook --- + gethookmask :: proc(L: ^State) -> HookMask --- + gethookcount :: proc(L: ^State) -> c.int --- + + /* }============================================================== */ +} + + + +COLIBNAME :: "coroutine" +TABLIBNAME :: "table" +IOLIBNAME :: "io" +OSLIBNAME :: "os" +STRLIBNAME :: "string" +UTF8LIBNAME :: "utf8" +MATHLIBNAME :: "math" +DBLIBNAME :: "debug" +LOADLIBNAME :: "package" + +@(link_prefix="lua") +@(default_calling_convention="c") +foreign lib { + open_base :: proc(L: ^State) -> c.int --- + open_table :: proc(L: ^State) -> c.int --- + open_io :: proc(L: ^State) -> c.int --- + open_os :: proc(L: ^State) -> c.int --- + open_string :: proc(L: ^State) -> c.int --- + open_utf8 :: proc(L: ^State) -> c.int --- + open_math :: proc(L: ^State) -> c.int --- + open_debug :: proc(L: ^State) -> c.int --- + open_package :: proc(L: ^State) -> c.int --- + + /* open all previous libraries */ + + L_openlibs :: proc(L: ^State) --- +} + + + +GNAME :: "_G" + +L_Reg :: struct { + name: cstring, + func: CFunction, +} + +/* predefined references */ +NOREF :: -2 +REFNIL :: -1 + +@(link_prefix="lua") +@(default_calling_convention="c") +foreign lib { + L_openlib :: proc(L: ^State, libname: cstring, l: [^]L_Reg, nup: c.int) --- + L_register :: proc(L: ^State, libname: cstring, l: ^L_Reg) --- + L_getmetafield :: proc(L: ^State, obj: c.int, e: cstring) -> c.int --- + L_callmeta :: proc(L: ^State, obj: c.int, e: cstring) -> c.int --- + L_typeerror :: proc(L: ^State, narg: c.int, tname: cstring) -> c.int --- + L_argerror :: proc(L: ^State, numarg: c.int, extramsg: cstring) -> c.int --- + @(link_name="luaL_checklstring") + L_checkstring :: proc(L: ^State, numArg: c.int, l: ^c.size_t = nil) -> cstring --- + @(link_name="luaL_optlstring") + L_optstring :: proc(L: ^State, numArg: c.int, def: cstring, l: ^c.size_t = nil) -> cstring --- + L_checknumber :: proc(L: ^State, numArg: c.int) -> Number --- + L_optnumber :: proc(L: ^State, nArg: c.int, def: Number) -> Number --- + + L_checkinteger :: proc(L: ^State, numArg: c.int) -> Integer --- + L_optinteger :: proc(L: ^State, nArg: c.int, def: Integer) -> Integer --- + + + L_checkstack :: proc(L: ^State, sz: c.int, msg: cstring) --- + L_checktype :: proc(L: ^State, narg: c.int, t: c.int) --- + L_checkany :: proc(L: ^State, narg: c.int) --- + + L_newmetatable :: proc(L: ^State, tname: cstring) -> c.int --- + L_checkudata :: proc(L: ^State, ud: c.int, tname: cstring) -> rawptr --- + + L_where :: proc(L: ^State, lvl: c.int) --- + L_error :: proc(L: ^State, fmt: cstring, #c_vararg args: ..any) -> Status --- + + L_checkoption :: proc(L: ^State, narg: c.int, def: cstring, lst: [^]cstring) -> c.int --- + + + L_ref :: proc(L: ^State, t: c.int) -> c.int --- + L_unref :: proc(L: ^State, t: c.int, ref: c.int) --- + + L_loadfile :: proc (L: ^State, filename: cstring) -> Status --- + + L_loadbuffer :: proc(L: ^State, buff: [^]byte, sz: c.size_t, name: cstring) -> Status --- + L_loadstring :: proc(L: ^State, s: cstring) -> Status --- + + L_newstate :: proc() -> ^State --- + + L_gsub :: proc(L: ^State, s, p, r: cstring) -> cstring --- + + L_findtable :: proc(L: ^State, idx: c.int, fname: cstring, szhint: c.int) -> cstring --- +} +/* +** {====================================================== +** Generic Buffer manipulation +** ======================================================= +*/ + + +L_Buffer :: struct { + p: [^]byte, /* buffer address */ + lvl: c.int, /* number of strings in the stack (level) */ + L: ^State, + buffer: [L_BUFFERSIZE]byte, /* initial buffer */ +} + +L_addchar :: #force_inline proc "c" (B: ^L_Buffer, c: byte) { + end := ([^]byte)(&B.buffer)[L_BUFFERSIZE:] + if B.p < end { + L_prepbuffer(B) + } + B.p[0] = c + B.p = B.p[1:] +} +L_putchar :: L_addchar + +L_addsize :: #force_inline proc "c" (B: ^L_Buffer, s: c.size_t) -> [^]byte { + B.p = B.p[s:] + return B.p +} + + +@(link_prefix="lua") +@(default_calling_convention="c") +foreign lib { + L_buffinit :: proc(L: ^State, B: ^L_Buffer) --- + L_prepbuffer :: proc(B: ^L_Buffer) -> [^]byte --- + L_addlstring :: proc(B: ^L_Buffer, s: cstring, l: c.size_t) --- + L_addstring :: proc(B: ^L_Buffer, s: cstring) --- + L_addvalue :: proc(B: ^L_Buffer) --- + L_pushresult :: proc(B: ^L_Buffer) --- + L_pushresultsize :: proc(B: ^L_Buffer, sz: c.size_t) --- + L_buffinitsize :: proc(L: ^State, B: ^L_Buffer, sz: c.size_t) -> [^]byte --- +} + +@(link_prefix="lua_") +@(default_calling_convention="c") +foreign lib { + /* hack */ + setlevel :: proc(from, to: ^State) --- +} + + +/* }====================================================== */ + + + + +/* +** {============================================================== +** some useful macros +** =============================================================== +*/ + +pop :: #force_inline proc "c" (L: ^State, n: c.int) { + settop(L, -n-1) +} +newtable :: #force_inline proc "c" (L: ^State) { + createtable(L, 0, 0) +} +register :: #force_inline proc "c" (L: ^State, n: cstring, f: CFunction) { + pushcfunction(L, f) + setglobal(L, n) +} + +pushcfunction :: #force_inline proc "c" (L: ^State, f: CFunction) { + pushcclosure(L, f, 0) +} + +strlen :: #force_inline proc "c" (L: ^State, i: c.int) -> c.size_t { + return objlen(L, i) +} + + +isfunction :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .FUNCTION } +istable :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .TABLE } +islightuserdata :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .LIGHTUSERDATA } +isnil :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .NIL } +isboolean :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .BOOLEAN } +isthread :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .THREAD } +isnone :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .NONE } +isnoneornil :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) <= .NIL } + + +pushliteral :: pushstring +setglobal :: #force_inline proc "c" (L: ^State, s: cstring) { + setfield(L, GLOBALSINDEX, s) +} +getglobal :: #force_inline proc "c" (L: ^State, s: cstring) { + getfield(L, GLOBALSINDEX, s) +} +tostring :: #force_inline proc "c" (L: ^State, i: c.int) -> cstring { + return tolstring(L, i, nil) +} + +open :: newstate +getregistry :: #force_inline proc "c" (L: ^State) { + pushvalue(L, REGISTRYINDEX) +} + +getgccount :: #force_inline proc "c" (L: ^State) -> c.int { + return gc(L, .COUNT, 0) +} + +Chunkreader :: Reader +Chunkwriter :: Writer + + +L_argcheck :: #force_inline proc "c" (L: ^State, cond: bool, numarg: c.int, extramsg: cstring) { + if cond { + L_argerror(L, numarg, extramsg) + } +} + +L_typename :: #force_inline proc "c" (L: ^State, i: c.int) -> cstring { + return typename(L, type(L, i)) +} +L_dofile :: #force_inline proc "c" (L: ^State, s: cstring) -> c.int { + err := L_loadfile(L, s) + return pcall(L, 0, MULTRET, 0) if err == nil else c.int(err) +} +L_dostring :: #force_inline proc "c" (L: ^State, s: cstring) -> c.int { + err := L_loadstring(L, s) + return pcall(L, 0, MULTRET, 0) if err == nil else c.int(err) +} +L_getmetatable :: #force_inline proc "c" (L: ^State, n: cstring) { + getfield(L, REGISTRYINDEX, n) +} +L_opt :: #force_inline proc "c" (L: ^State, f: $F, n: c.int, d: $T) -> T where intrinsics.type_is_proc(F) { + return d if isnoneornil(L, n) else f(L, n) +} + + + +ref :: #force_inline proc "c" (L: ^State, lock: bool) -> c.int { + if lock { + return L_ref(L, REGISTRYINDEX) + } + pushstring(L, "unlocked references are obsolete") + error(L) + return 0 +} +unref :: #force_inline proc "c" (L: ^State, ref: c.int) { + L_unref(L,REGISTRYINDEX, ref) +} +getref :: #force_inline proc "c" (L: ^State, ref: Integer) { + rawgeti(L, REGISTRYINDEX, ref) +} + + +/* }============================================================== */ diff --git a/vendor/lua/5.1/windows/lua5.1.dll b/vendor/lua/5.1/windows/lua5.1.dll new file mode 100644 index 000000000..353c21940 Binary files /dev/null and b/vendor/lua/5.1/windows/lua5.1.dll differ diff --git a/vendor/lua/5.1/windows/lua5.1.dll.lib b/vendor/lua/5.1/windows/lua5.1.dll.lib new file mode 100644 index 000000000..6e1497cc1 Binary files /dev/null and b/vendor/lua/5.1/windows/lua5.1.dll.lib differ diff --git a/vendor/lua/5.2/include/lauxlib.h b/vendor/lua/5.2/include/lauxlib.h new file mode 100644 index 000000000..0fb023b8e --- /dev/null +++ b/vendor/lua/5.2/include/lauxlib.h @@ -0,0 +1,212 @@ +/* +** $Id: lauxlib.h,v 1.120.1.1 2013/04/12 18:48:47 roberto Exp $ +** Auxiliary functions for building Lua libraries +** See Copyright Notice in lua.h +*/ + + +#ifndef lauxlib_h +#define lauxlib_h + + +#include +#include + +#include "lua.h" + + + +/* extra error code for `luaL_load' */ +#define LUA_ERRFILE (LUA_ERRERR+1) + + +typedef struct luaL_Reg { + const char *name; + lua_CFunction func; +} luaL_Reg; + + +LUALIB_API void (luaL_checkversion_) (lua_State *L, lua_Number ver); +#define luaL_checkversion(L) luaL_checkversion_(L, LUA_VERSION_NUM) + +LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e); +LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e); +LUALIB_API const char *(luaL_tolstring) (lua_State *L, int idx, size_t *len); +LUALIB_API int (luaL_argerror) (lua_State *L, int numarg, const char *extramsg); +LUALIB_API const char *(luaL_checklstring) (lua_State *L, int numArg, + size_t *l); +LUALIB_API const char *(luaL_optlstring) (lua_State *L, int numArg, + const char *def, size_t *l); +LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int numArg); +LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int nArg, lua_Number def); + +LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int numArg); +LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int nArg, + lua_Integer def); +LUALIB_API lua_Unsigned (luaL_checkunsigned) (lua_State *L, int numArg); +LUALIB_API lua_Unsigned (luaL_optunsigned) (lua_State *L, int numArg, + lua_Unsigned def); + +LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg); +LUALIB_API void (luaL_checktype) (lua_State *L, int narg, int t); +LUALIB_API void (luaL_checkany) (lua_State *L, int narg); + +LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname); +LUALIB_API void (luaL_setmetatable) (lua_State *L, const char *tname); +LUALIB_API void *(luaL_testudata) (lua_State *L, int ud, const char *tname); +LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname); + +LUALIB_API void (luaL_where) (lua_State *L, int lvl); +LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...); + +LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def, + const char *const lst[]); + +LUALIB_API int (luaL_fileresult) (lua_State *L, int stat, const char *fname); +LUALIB_API int (luaL_execresult) (lua_State *L, int stat); + +/* pre-defined references */ +#define LUA_NOREF (-2) +#define LUA_REFNIL (-1) + +LUALIB_API int (luaL_ref) (lua_State *L, int t); +LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref); + +LUALIB_API int (luaL_loadfilex) (lua_State *L, const char *filename, + const char *mode); + +#define luaL_loadfile(L,f) luaL_loadfilex(L,f,NULL) + +LUALIB_API int (luaL_loadbufferx) (lua_State *L, const char *buff, size_t sz, + const char *name, const char *mode); +LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s); + +LUALIB_API lua_State *(luaL_newstate) (void); + +LUALIB_API int (luaL_len) (lua_State *L, int idx); + +LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p, + const char *r); + +LUALIB_API void (luaL_setfuncs) (lua_State *L, const luaL_Reg *l, int nup); + +LUALIB_API int (luaL_getsubtable) (lua_State *L, int idx, const char *fname); + +LUALIB_API void (luaL_traceback) (lua_State *L, lua_State *L1, + const char *msg, int level); + +LUALIB_API void (luaL_requiref) (lua_State *L, const char *modname, + lua_CFunction openf, int glb); + +/* +** =============================================================== +** some useful macros +** =============================================================== +*/ + + +#define luaL_newlibtable(L,l) \ + lua_createtable(L, 0, sizeof(l)/sizeof((l)[0]) - 1) + +#define luaL_newlib(L,l) (luaL_newlibtable(L,l), luaL_setfuncs(L,l,0)) + +#define luaL_argcheck(L, cond,numarg,extramsg) \ + ((void)((cond) || luaL_argerror(L, (numarg), (extramsg)))) +#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL)) +#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL)) +#define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n))) +#define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d))) +#define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n))) +#define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d))) + +#define luaL_typename(L,i) lua_typename(L, lua_type(L,(i))) + +#define luaL_dofile(L, fn) \ + (luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0)) + +#define luaL_dostring(L, s) \ + (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0)) + +#define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n))) + +#define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n))) + +#define luaL_loadbuffer(L,s,sz,n) luaL_loadbufferx(L,s,sz,n,NULL) + + +/* +** {====================================================== +** Generic Buffer manipulation +** ======================================================= +*/ + +typedef struct luaL_Buffer { + char *b; /* buffer address */ + size_t size; /* buffer size */ + size_t n; /* number of characters in buffer */ + lua_State *L; + char initb[LUAL_BUFFERSIZE]; /* initial buffer */ +} luaL_Buffer; + + +#define luaL_addchar(B,c) \ + ((void)((B)->n < (B)->size || luaL_prepbuffsize((B), 1)), \ + ((B)->b[(B)->n++] = (c))) + +#define luaL_addsize(B,s) ((B)->n += (s)) + +LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B); +LUALIB_API char *(luaL_prepbuffsize) (luaL_Buffer *B, size_t sz); +LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l); +LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s); +LUALIB_API void (luaL_addvalue) (luaL_Buffer *B); +LUALIB_API void (luaL_pushresult) (luaL_Buffer *B); +LUALIB_API void (luaL_pushresultsize) (luaL_Buffer *B, size_t sz); +LUALIB_API char *(luaL_buffinitsize) (lua_State *L, luaL_Buffer *B, size_t sz); + +#define luaL_prepbuffer(B) luaL_prepbuffsize(B, LUAL_BUFFERSIZE) + +/* }====================================================== */ + + + +/* +** {====================================================== +** File handles for IO library +** ======================================================= +*/ + +/* +** A file handle is a userdata with metatable 'LUA_FILEHANDLE' and +** initial structure 'luaL_Stream' (it may contain other fields +** after that initial structure). +*/ + +#define LUA_FILEHANDLE "FILE*" + + +typedef struct luaL_Stream { + FILE *f; /* stream (NULL for incompletely created streams) */ + lua_CFunction closef; /* to close stream (NULL for closed streams) */ +} luaL_Stream; + +/* }====================================================== */ + + + +/* compatibility with old module system */ +#if defined(LUA_COMPAT_MODULE) + +LUALIB_API void (luaL_pushmodule) (lua_State *L, const char *modname, + int sizehint); +LUALIB_API void (luaL_openlib) (lua_State *L, const char *libname, + const luaL_Reg *l, int nup); + +#define luaL_register(L,n,l) (luaL_openlib(L,(n),(l),0)) + +#endif + + +#endif + + diff --git a/vendor/lua/5.2/include/lua.h b/vendor/lua/5.2/include/lua.h new file mode 100644 index 000000000..ff4a10861 --- /dev/null +++ b/vendor/lua/5.2/include/lua.h @@ -0,0 +1,444 @@ +/* +** $Id: lua.h,v 1.285.1.4 2015/02/21 14:04:50 roberto Exp $ +** Lua - A Scripting Language +** Lua.org, PUC-Rio, Brazil (http://www.lua.org) +** See Copyright Notice at the end of this file +*/ + + +#ifndef lua_h +#define lua_h + +#include +#include + + +#include "luaconf.h" + + +#define LUA_VERSION_MAJOR "5" +#define LUA_VERSION_MINOR "2" +#define LUA_VERSION_NUM 502 +#define LUA_VERSION_RELEASE "4" + +#define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR +#define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE +#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2015 Lua.org, PUC-Rio" +#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo, W. Celes" + + +/* mark for precompiled code ('Lua') */ +#define LUA_SIGNATURE "\033Lua" + +/* option for multiple returns in 'lua_pcall' and 'lua_call' */ +#define LUA_MULTRET (-1) + + +/* +** pseudo-indices +*/ +#define LUA_REGISTRYINDEX LUAI_FIRSTPSEUDOIDX +#define lua_upvalueindex(i) (LUA_REGISTRYINDEX - (i)) + + +/* thread status */ +#define LUA_OK 0 +#define LUA_YIELD 1 +#define LUA_ERRRUN 2 +#define LUA_ERRSYNTAX 3 +#define LUA_ERRMEM 4 +#define LUA_ERRGCMM 5 +#define LUA_ERRERR 6 + + +typedef struct lua_State lua_State; + +typedef int (*lua_CFunction) (lua_State *L); + + +/* +** functions that read/write blocks when loading/dumping Lua chunks +*/ +typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz); + +typedef int (*lua_Writer) (lua_State *L, const void* p, size_t sz, void* ud); + + +/* +** prototype for memory-allocation functions +*/ +typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize); + + +/* +** basic types +*/ +#define LUA_TNONE (-1) + +#define LUA_TNIL 0 +#define LUA_TBOOLEAN 1 +#define LUA_TLIGHTUSERDATA 2 +#define LUA_TNUMBER 3 +#define LUA_TSTRING 4 +#define LUA_TTABLE 5 +#define LUA_TFUNCTION 6 +#define LUA_TUSERDATA 7 +#define LUA_TTHREAD 8 + +#define LUA_NUMTAGS 9 + + + +/* minimum Lua stack available to a C function */ +#define LUA_MINSTACK 20 + + +/* predefined values in the registry */ +#define LUA_RIDX_MAINTHREAD 1 +#define LUA_RIDX_GLOBALS 2 +#define LUA_RIDX_LAST LUA_RIDX_GLOBALS + + +/* type of numbers in Lua */ +typedef LUA_NUMBER lua_Number; + + +/* type for integer functions */ +typedef LUA_INTEGER lua_Integer; + +/* unsigned integer type */ +typedef LUA_UNSIGNED lua_Unsigned; + + + +/* +** generic extra include file +*/ +#if defined(LUA_USER_H) +#include LUA_USER_H +#endif + + +/* +** RCS ident string +*/ +extern const char lua_ident[]; + + +/* +** state manipulation +*/ +LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud); +LUA_API void (lua_close) (lua_State *L); +LUA_API lua_State *(lua_newthread) (lua_State *L); + +LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf); + + +LUA_API const lua_Number *(lua_version) (lua_State *L); + + +/* +** basic stack manipulation +*/ +LUA_API int (lua_absindex) (lua_State *L, int idx); +LUA_API int (lua_gettop) (lua_State *L); +LUA_API void (lua_settop) (lua_State *L, int idx); +LUA_API void (lua_pushvalue) (lua_State *L, int idx); +LUA_API void (lua_remove) (lua_State *L, int idx); +LUA_API void (lua_insert) (lua_State *L, int idx); +LUA_API void (lua_replace) (lua_State *L, int idx); +LUA_API void (lua_copy) (lua_State *L, int fromidx, int toidx); +LUA_API int (lua_checkstack) (lua_State *L, int sz); + +LUA_API void (lua_xmove) (lua_State *from, lua_State *to, int n); + + +/* +** access functions (stack -> C) +*/ + +LUA_API int (lua_isnumber) (lua_State *L, int idx); +LUA_API int (lua_isstring) (lua_State *L, int idx); +LUA_API int (lua_iscfunction) (lua_State *L, int idx); +LUA_API int (lua_isuserdata) (lua_State *L, int idx); +LUA_API int (lua_type) (lua_State *L, int idx); +LUA_API const char *(lua_typename) (lua_State *L, int tp); + +LUA_API lua_Number (lua_tonumberx) (lua_State *L, int idx, int *isnum); +LUA_API lua_Integer (lua_tointegerx) (lua_State *L, int idx, int *isnum); +LUA_API lua_Unsigned (lua_tounsignedx) (lua_State *L, int idx, int *isnum); +LUA_API int (lua_toboolean) (lua_State *L, int idx); +LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len); +LUA_API size_t (lua_rawlen) (lua_State *L, int idx); +LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx); +LUA_API void *(lua_touserdata) (lua_State *L, int idx); +LUA_API lua_State *(lua_tothread) (lua_State *L, int idx); +LUA_API const void *(lua_topointer) (lua_State *L, int idx); + + +/* +** Comparison and arithmetic functions +*/ + +#define LUA_OPADD 0 /* ORDER TM */ +#define LUA_OPSUB 1 +#define LUA_OPMUL 2 +#define LUA_OPDIV 3 +#define LUA_OPMOD 4 +#define LUA_OPPOW 5 +#define LUA_OPUNM 6 + +LUA_API void (lua_arith) (lua_State *L, int op); + +#define LUA_OPEQ 0 +#define LUA_OPLT 1 +#define LUA_OPLE 2 + +LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2); +LUA_API int (lua_compare) (lua_State *L, int idx1, int idx2, int op); + + +/* +** push functions (C -> stack) +*/ +LUA_API void (lua_pushnil) (lua_State *L); +LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n); +LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n); +LUA_API void (lua_pushunsigned) (lua_State *L, lua_Unsigned n); +LUA_API const char *(lua_pushlstring) (lua_State *L, const char *s, size_t l); +LUA_API const char *(lua_pushstring) (lua_State *L, const char *s); +LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt, + va_list argp); +LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...); +LUA_API void (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n); +LUA_API void (lua_pushboolean) (lua_State *L, int b); +LUA_API void (lua_pushlightuserdata) (lua_State *L, void *p); +LUA_API int (lua_pushthread) (lua_State *L); + + +/* +** get functions (Lua -> stack) +*/ +LUA_API void (lua_getglobal) (lua_State *L, const char *var); +LUA_API void (lua_gettable) (lua_State *L, int idx); +LUA_API void (lua_getfield) (lua_State *L, int idx, const char *k); +LUA_API void (lua_rawget) (lua_State *L, int idx); +LUA_API void (lua_rawgeti) (lua_State *L, int idx, int n); +LUA_API void (lua_rawgetp) (lua_State *L, int idx, const void *p); +LUA_API void (lua_createtable) (lua_State *L, int narr, int nrec); +LUA_API void *(lua_newuserdata) (lua_State *L, size_t sz); +LUA_API int (lua_getmetatable) (lua_State *L, int objindex); +LUA_API void (lua_getuservalue) (lua_State *L, int idx); + + +/* +** set functions (stack -> Lua) +*/ +LUA_API void (lua_setglobal) (lua_State *L, const char *var); +LUA_API void (lua_settable) (lua_State *L, int idx); +LUA_API void (lua_setfield) (lua_State *L, int idx, const char *k); +LUA_API void (lua_rawset) (lua_State *L, int idx); +LUA_API void (lua_rawseti) (lua_State *L, int idx, int n); +LUA_API void (lua_rawsetp) (lua_State *L, int idx, const void *p); +LUA_API int (lua_setmetatable) (lua_State *L, int objindex); +LUA_API void (lua_setuservalue) (lua_State *L, int idx); + + +/* +** 'load' and 'call' functions (load and run Lua code) +*/ +LUA_API void (lua_callk) (lua_State *L, int nargs, int nresults, int ctx, + lua_CFunction k); +#define lua_call(L,n,r) lua_callk(L, (n), (r), 0, NULL) + +LUA_API int (lua_getctx) (lua_State *L, int *ctx); + +LUA_API int (lua_pcallk) (lua_State *L, int nargs, int nresults, int errfunc, + int ctx, lua_CFunction k); +#define lua_pcall(L,n,r,f) lua_pcallk(L, (n), (r), (f), 0, NULL) + +LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt, + const char *chunkname, + const char *mode); + +LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data); + + +/* +** coroutine functions +*/ +LUA_API int (lua_yieldk) (lua_State *L, int nresults, int ctx, + lua_CFunction k); +#define lua_yield(L,n) lua_yieldk(L, (n), 0, NULL) +LUA_API int (lua_resume) (lua_State *L, lua_State *from, int narg); +LUA_API int (lua_status) (lua_State *L); + +/* +** garbage-collection function and options +*/ + +#define LUA_GCSTOP 0 +#define LUA_GCRESTART 1 +#define LUA_GCCOLLECT 2 +#define LUA_GCCOUNT 3 +#define LUA_GCCOUNTB 4 +#define LUA_GCSTEP 5 +#define LUA_GCSETPAUSE 6 +#define LUA_GCSETSTEPMUL 7 +#define LUA_GCSETMAJORINC 8 +#define LUA_GCISRUNNING 9 +#define LUA_GCGEN 10 +#define LUA_GCINC 11 + +LUA_API int (lua_gc) (lua_State *L, int what, int data); + + +/* +** miscellaneous functions +*/ + +LUA_API int (lua_error) (lua_State *L); + +LUA_API int (lua_next) (lua_State *L, int idx); + +LUA_API void (lua_concat) (lua_State *L, int n); +LUA_API void (lua_len) (lua_State *L, int idx); + +LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud); +LUA_API void (lua_setallocf) (lua_State *L, lua_Alloc f, void *ud); + + + +/* +** =============================================================== +** some useful macros +** =============================================================== +*/ + +#define lua_tonumber(L,i) lua_tonumberx(L,i,NULL) +#define lua_tointeger(L,i) lua_tointegerx(L,i,NULL) +#define lua_tounsigned(L,i) lua_tounsignedx(L,i,NULL) + +#define lua_pop(L,n) lua_settop(L, -(n)-1) + +#define lua_newtable(L) lua_createtable(L, 0, 0) + +#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n))) + +#define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0) + +#define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION) +#define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE) +#define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA) +#define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL) +#define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN) +#define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD) +#define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE) +#define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0) + +#define lua_pushliteral(L, s) \ + lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1) + +#define lua_pushglobaltable(L) \ + lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS) + +#define lua_tostring(L,i) lua_tolstring(L, (i), NULL) + + + +/* +** {====================================================================== +** Debug API +** ======================================================================= +*/ + + +/* +** Event codes +*/ +#define LUA_HOOKCALL 0 +#define LUA_HOOKRET 1 +#define LUA_HOOKLINE 2 +#define LUA_HOOKCOUNT 3 +#define LUA_HOOKTAILCALL 4 + + +/* +** Event masks +*/ +#define LUA_MASKCALL (1 << LUA_HOOKCALL) +#define LUA_MASKRET (1 << LUA_HOOKRET) +#define LUA_MASKLINE (1 << LUA_HOOKLINE) +#define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT) + +typedef struct lua_Debug lua_Debug; /* activation record */ + + +/* Functions to be called by the debugger in specific events */ +typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar); + + +LUA_API int (lua_getstack) (lua_State *L, int level, lua_Debug *ar); +LUA_API int (lua_getinfo) (lua_State *L, const char *what, lua_Debug *ar); +LUA_API const char *(lua_getlocal) (lua_State *L, const lua_Debug *ar, int n); +LUA_API const char *(lua_setlocal) (lua_State *L, const lua_Debug *ar, int n); +LUA_API const char *(lua_getupvalue) (lua_State *L, int funcindex, int n); +LUA_API const char *(lua_setupvalue) (lua_State *L, int funcindex, int n); + +LUA_API void *(lua_upvalueid) (lua_State *L, int fidx, int n); +LUA_API void (lua_upvaluejoin) (lua_State *L, int fidx1, int n1, + int fidx2, int n2); + +LUA_API int (lua_sethook) (lua_State *L, lua_Hook func, int mask, int count); +LUA_API lua_Hook (lua_gethook) (lua_State *L); +LUA_API int (lua_gethookmask) (lua_State *L); +LUA_API int (lua_gethookcount) (lua_State *L); + + +struct lua_Debug { + int event; + const char *name; /* (n) */ + const char *namewhat; /* (n) 'global', 'local', 'field', 'method' */ + const char *what; /* (S) 'Lua', 'C', 'main', 'tail' */ + const char *source; /* (S) */ + int currentline; /* (l) */ + int linedefined; /* (S) */ + int lastlinedefined; /* (S) */ + unsigned char nups; /* (u) number of upvalues */ + unsigned char nparams;/* (u) number of parameters */ + char isvararg; /* (u) */ + char istailcall; /* (t) */ + char short_src[LUA_IDSIZE]; /* (S) */ + /* private part */ + struct CallInfo *i_ci; /* active function */ +}; + +/* }====================================================================== */ + + +/****************************************************************************** +* Copyright (C) 1994-2015 Lua.org, PUC-Rio. +* +* Permission is hereby granted, free of charge, to any person obtaining +* a copy of this software and associated documentation files (the +* "Software"), to deal in the Software without restriction, including +* without limitation the rights to use, copy, modify, merge, publish, +* distribute, sublicense, and/or sell copies of the Software, and to +* permit persons to whom the Software is furnished to do so, subject to +* the following conditions: +* +* The above copyright notice and this permission notice shall be +* included in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ + + +#endif diff --git a/vendor/lua/5.2/include/lua.hpp b/vendor/lua/5.2/include/lua.hpp new file mode 100644 index 000000000..ec417f594 --- /dev/null +++ b/vendor/lua/5.2/include/lua.hpp @@ -0,0 +1,9 @@ +// lua.hpp +// Lua header files for C++ +// <> not supplied automatically because Lua also compiles as C++ + +extern "C" { +#include "lua.h" +#include "lualib.h" +#include "lauxlib.h" +} diff --git a/vendor/lua/5.2/include/luaconf.h b/vendor/lua/5.2/include/luaconf.h new file mode 100644 index 000000000..03db8542d --- /dev/null +++ b/vendor/lua/5.2/include/luaconf.h @@ -0,0 +1,553 @@ +/* +** $Id: luaconf.h,v 1.176.1.2 2013/11/21 17:26:16 roberto Exp $ +** Configuration file for Lua +** See Copyright Notice in lua.h +*/ + + +#ifndef lconfig_h +#define lconfig_h + +#include +#include + + +/* +** ================================================================== +** Search for "@@" to find all configurable definitions. +** =================================================================== +*/ + + +/* +@@ LUA_ANSI controls the use of non-ansi features. +** CHANGE it (define it) if you want Lua to avoid the use of any +** non-ansi feature or library. +*/ +#if !defined(LUA_ANSI) && defined(__STRICT_ANSI__) +#define LUA_ANSI +#endif + + +#if !defined(LUA_ANSI) && defined(_WIN32) && !defined(_WIN32_WCE) +#define LUA_WIN /* enable goodies for regular Windows platforms */ +#endif + +#if defined(LUA_WIN) +#define LUA_DL_DLL +#define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */ +#endif + + + +#if defined(LUA_USE_LINUX) +#define LUA_USE_POSIX +#define LUA_USE_DLOPEN /* needs an extra library: -ldl */ +#define LUA_USE_READLINE /* needs some extra libraries */ +#define LUA_USE_STRTODHEX /* assume 'strtod' handles hex formats */ +#define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */ +#define LUA_USE_LONGLONG /* assume support for long long */ +#endif + +#if defined(LUA_USE_MACOSX) +#define LUA_USE_POSIX +#define LUA_USE_DLOPEN /* does not need -ldl */ +#define LUA_USE_READLINE /* needs an extra library: -lreadline */ +#define LUA_USE_STRTODHEX /* assume 'strtod' handles hex formats */ +#define LUA_USE_AFORMAT /* assume 'printf' handles 'aA' specifiers */ +#define LUA_USE_LONGLONG /* assume support for long long */ +#endif + + + +/* +@@ LUA_USE_POSIX includes all functionality listed as X/Open System +@* Interfaces Extension (XSI). +** CHANGE it (define it) if your system is XSI compatible. +*/ +#if defined(LUA_USE_POSIX) +#define LUA_USE_MKSTEMP +#define LUA_USE_ISATTY +#define LUA_USE_POPEN +#define LUA_USE_ULONGJMP +#define LUA_USE_GMTIME_R +#endif + + + +/* +@@ LUA_PATH_DEFAULT is the default path that Lua uses to look for +@* Lua libraries. +@@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for +@* C libraries. +** CHANGE them if your machine has a non-conventional directory +** hierarchy or if you want to install your libraries in +** non-conventional directories. +*/ +#if defined(_WIN32) /* { */ +/* +** In Windows, any exclamation mark ('!') in the path is replaced by the +** path of the directory of the executable file of the current process. +*/ +#define LUA_LDIR "!\\lua\\" +#define LUA_CDIR "!\\" +#define LUA_PATH_DEFAULT \ + LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \ + LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua;" ".\\?.lua" +#define LUA_CPATH_DEFAULT \ + LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll;" ".\\?.dll;" \ + LUA_CDIR"?52.dll;" ".\\?52.dll" + +#else /* }{ */ + +#define LUA_VDIR LUA_VERSION_MAJOR "." LUA_VERSION_MINOR "/" +#define LUA_ROOT "/usr/local/" +#define LUA_LDIR LUA_ROOT "share/lua/" LUA_VDIR +#define LUA_CDIR LUA_ROOT "lib/lua/" LUA_VDIR +#define LUA_PATH_DEFAULT \ + LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ + LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" "./?.lua" +#define LUA_CPATH_DEFAULT \ + LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so;" \ + LUA_CDIR"lib?52.so;" "./lib?52.so" +#endif /* } */ + + +/* +@@ LUA_DIRSEP is the directory separator (for submodules). +** CHANGE it if your machine does not use "/" as the directory separator +** and is not Windows. (On Windows Lua automatically uses "\".) +*/ +#if defined(_WIN32) +#define LUA_DIRSEP "\\" +#else +#define LUA_DIRSEP "/" +#endif + + +/* +@@ LUA_ENV is the name of the variable that holds the current +@@ environment, used to access global names. +** CHANGE it if you do not like this name. +*/ +#define LUA_ENV "_ENV" + + +/* +@@ LUA_API is a mark for all core API functions. +@@ LUALIB_API is a mark for all auxiliary library functions. +@@ LUAMOD_API is a mark for all standard library opening functions. +** CHANGE them if you need to define those functions in some special way. +** For instance, if you want to create one Windows DLL with the core and +** the libraries, you may want to use the following definition (define +** LUA_BUILD_AS_DLL to get it). +*/ +#if defined(LUA_BUILD_AS_DLL) /* { */ + +#if defined(LUA_CORE) || defined(LUA_LIB) /* { */ +#define LUA_API __declspec(dllexport) +#else /* }{ */ +#define LUA_API __declspec(dllimport) +#endif /* } */ + +#else /* }{ */ + +#define LUA_API extern + +#endif /* } */ + + +/* more often than not the libs go together with the core */ +#define LUALIB_API LUA_API +#define LUAMOD_API LUALIB_API + + +/* +@@ LUAI_FUNC is a mark for all extern functions that are not to be +@* exported to outside modules. +@@ LUAI_DDEF and LUAI_DDEC are marks for all extern (const) variables +@* that are not to be exported to outside modules (LUAI_DDEF for +@* definitions and LUAI_DDEC for declarations). +** CHANGE them if you need to mark them in some special way. Elf/gcc +** (versions 3.2 and later) mark them as "hidden" to optimize access +** when Lua is compiled as a shared library. Not all elf targets support +** this attribute. Unfortunately, gcc does not offer a way to check +** whether the target offers that support, and those without support +** give a warning about it. To avoid these warnings, change to the +** default definition. +*/ +#if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \ + defined(__ELF__) /* { */ +#define LUAI_FUNC __attribute__((visibility("hidden"))) extern +#define LUAI_DDEC LUAI_FUNC +#define LUAI_DDEF /* empty */ + +#else /* }{ */ +#define LUAI_FUNC extern +#define LUAI_DDEC extern +#define LUAI_DDEF /* empty */ +#endif /* } */ + + + +/* +@@ LUA_QL describes how error messages quote program elements. +** CHANGE it if you want a different appearance. +*/ +#define LUA_QL(x) "'" x "'" +#define LUA_QS LUA_QL("%s") + + +/* +@@ LUA_IDSIZE gives the maximum size for the description of the source +@* of a function in debug information. +** CHANGE it if you want a different size. +*/ +#define LUA_IDSIZE 60 + + +/* +@@ luai_writestring/luai_writeline define how 'print' prints its results. +** They are only used in libraries and the stand-alone program. (The #if +** avoids including 'stdio.h' everywhere.) +*/ +#if defined(LUA_LIB) || defined(lua_c) +#include +#define luai_writestring(s,l) fwrite((s), sizeof(char), (l), stdout) +#define luai_writeline() (luai_writestring("\n", 1), fflush(stdout)) +#endif + +/* +@@ luai_writestringerror defines how to print error messages. +** (A format string with one argument is enough for Lua...) +*/ +#define luai_writestringerror(s,p) \ + (fprintf(stderr, (s), (p)), fflush(stderr)) + + +/* +@@ LUAI_MAXSHORTLEN is the maximum length for short strings, that is, +** strings that are internalized. (Cannot be smaller than reserved words +** or tags for metamethods, as these strings must be internalized; +** #("function") = 8, #("__newindex") = 10.) +*/ +#define LUAI_MAXSHORTLEN 40 + + + +/* +** {================================================================== +** Compatibility with previous versions +** =================================================================== +*/ + +/* +@@ LUA_COMPAT_ALL controls all compatibility options. +** You can define it to get all options, or change specific options +** to fit your specific needs. +*/ +#if defined(LUA_COMPAT_ALL) /* { */ + +/* +@@ LUA_COMPAT_UNPACK controls the presence of global 'unpack'. +** You can replace it with 'table.unpack'. +*/ +#define LUA_COMPAT_UNPACK + +/* +@@ LUA_COMPAT_LOADERS controls the presence of table 'package.loaders'. +** You can replace it with 'package.searchers'. +*/ +#define LUA_COMPAT_LOADERS + +/* +@@ macro 'lua_cpcall' emulates deprecated function lua_cpcall. +** You can call your C function directly (with light C functions). +*/ +#define lua_cpcall(L,f,u) \ + (lua_pushcfunction(L, (f)), \ + lua_pushlightuserdata(L,(u)), \ + lua_pcall(L,1,0,0)) + + +/* +@@ LUA_COMPAT_LOG10 defines the function 'log10' in the math library. +** You can rewrite 'log10(x)' as 'log(x, 10)'. +*/ +#define LUA_COMPAT_LOG10 + +/* +@@ LUA_COMPAT_LOADSTRING defines the function 'loadstring' in the base +** library. You can rewrite 'loadstring(s)' as 'load(s)'. +*/ +#define LUA_COMPAT_LOADSTRING + +/* +@@ LUA_COMPAT_MAXN defines the function 'maxn' in the table library. +*/ +#define LUA_COMPAT_MAXN + +/* +@@ The following macros supply trivial compatibility for some +** changes in the API. The macros themselves document how to +** change your code to avoid using them. +*/ +#define lua_strlen(L,i) lua_rawlen(L, (i)) + +#define lua_objlen(L,i) lua_rawlen(L, (i)) + +#define lua_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ) +#define lua_lessthan(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPLT) + +/* +@@ LUA_COMPAT_MODULE controls compatibility with previous +** module functions 'module' (Lua) and 'luaL_register' (C). +*/ +#define LUA_COMPAT_MODULE + +#endif /* } */ + +/* }================================================================== */ + + + +/* +@@ LUAI_BITSINT defines the number of bits in an int. +** CHANGE here if Lua cannot automatically detect the number of bits of +** your machine. Probably you do not need to change this. +*/ +/* avoid overflows in comparison */ +#if INT_MAX-20 < 32760 /* { */ +#define LUAI_BITSINT 16 +#elif INT_MAX > 2147483640L /* }{ */ +/* int has at least 32 bits */ +#define LUAI_BITSINT 32 +#else /* }{ */ +#error "you must define LUA_BITSINT with number of bits in an integer" +#endif /* } */ + + +/* +@@ LUA_INT32 is a signed integer with exactly 32 bits. +@@ LUAI_UMEM is an unsigned integer big enough to count the total +@* memory used by Lua. +@@ LUAI_MEM is a signed integer big enough to count the total memory +@* used by Lua. +** CHANGE here if for some weird reason the default definitions are not +** good enough for your machine. Probably you do not need to change +** this. +*/ +#if LUAI_BITSINT >= 32 /* { */ +#define LUA_INT32 int +#define LUAI_UMEM size_t +#define LUAI_MEM ptrdiff_t +#else /* }{ */ +/* 16-bit ints */ +#define LUA_INT32 long +#define LUAI_UMEM unsigned long +#define LUAI_MEM long +#endif /* } */ + + +/* +@@ LUAI_MAXSTACK limits the size of the Lua stack. +** CHANGE it if you need a different limit. This limit is arbitrary; +** its only purpose is to stop Lua from consuming unlimited stack +** space (and to reserve some numbers for pseudo-indices). +*/ +#if LUAI_BITSINT >= 32 +#define LUAI_MAXSTACK 1000000 +#else +#define LUAI_MAXSTACK 15000 +#endif + +/* reserve some space for error handling */ +#define LUAI_FIRSTPSEUDOIDX (-LUAI_MAXSTACK - 1000) + + + + +/* +@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. +** CHANGE it if it uses too much C-stack space. +*/ +#define LUAL_BUFFERSIZE BUFSIZ + + + + +/* +** {================================================================== +@@ LUA_NUMBER is the type of numbers in Lua. +** CHANGE the following definitions only if you want to build Lua +** with a number type different from double. You may also need to +** change lua_number2int & lua_number2integer. +** =================================================================== +*/ + +#define LUA_NUMBER_DOUBLE +#define LUA_NUMBER double + +/* +@@ LUAI_UACNUMBER is the result of an 'usual argument conversion' +@* over a number. +*/ +#define LUAI_UACNUMBER double + + +/* +@@ LUA_NUMBER_SCAN is the format for reading numbers. +@@ LUA_NUMBER_FMT is the format for writing numbers. +@@ lua_number2str converts a number to a string. +@@ LUAI_MAXNUMBER2STR is maximum size of previous conversion. +*/ +#define LUA_NUMBER_SCAN "%lf" +#define LUA_NUMBER_FMT "%.14g" +#define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n)) +#define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */ + + +/* +@@ l_mathop allows the addition of an 'l' or 'f' to all math operations +*/ +#define l_mathop(x) (x) + + +/* +@@ lua_str2number converts a decimal numeric string to a number. +@@ lua_strx2number converts an hexadecimal numeric string to a number. +** In C99, 'strtod' does both conversions. C89, however, has no function +** to convert floating hexadecimal strings to numbers. For these +** systems, you can leave 'lua_strx2number' undefined and Lua will +** provide its own implementation. +*/ +#define lua_str2number(s,p) strtod((s), (p)) + +#if defined(LUA_USE_STRTODHEX) +#define lua_strx2number(s,p) strtod((s), (p)) +#endif + + +/* +@@ The luai_num* macros define the primitive operations over numbers. +*/ + +/* the following operations need the math library */ +#if defined(lobject_c) || defined(lvm_c) +#include +#define luai_nummod(L,a,b) ((a) - l_mathop(floor)((a)/(b))*(b)) +#define luai_numpow(L,a,b) (l_mathop(pow)(a,b)) +#endif + +/* these are quite standard operations */ +#if defined(LUA_CORE) +#define luai_numadd(L,a,b) ((a)+(b)) +#define luai_numsub(L,a,b) ((a)-(b)) +#define luai_nummul(L,a,b) ((a)*(b)) +#define luai_numdiv(L,a,b) ((a)/(b)) +#define luai_numunm(L,a) (-(a)) +#define luai_numeq(a,b) ((a)==(b)) +#define luai_numlt(L,a,b) ((a)<(b)) +#define luai_numle(L,a,b) ((a)<=(b)) +#define luai_numisnan(L,a) (!luai_numeq((a), (a))) +#endif + + + +/* +@@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger. +** CHANGE that if ptrdiff_t is not adequate on your machine. (On most +** machines, ptrdiff_t gives a good choice between int or long.) +*/ +#define LUA_INTEGER ptrdiff_t + +/* +@@ LUA_UNSIGNED is the integral type used by lua_pushunsigned/lua_tounsigned. +** It must have at least 32 bits. +*/ +#define LUA_UNSIGNED unsigned LUA_INT32 + + + +/* +** Some tricks with doubles +*/ + +#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) /* { */ +/* +** The next definitions activate some tricks to speed up the +** conversion from doubles to integer types, mainly to LUA_UNSIGNED. +** +@@ LUA_MSASMTRICK uses Microsoft assembler to avoid clashes with a +** DirectX idiosyncrasy. +** +@@ LUA_IEEE754TRICK uses a trick that should work on any machine +** using IEEE754 with a 32-bit integer type. +** +@@ LUA_IEEELL extends the trick to LUA_INTEGER; should only be +** defined when LUA_INTEGER is a 32-bit integer. +** +@@ LUA_IEEEENDIAN is the endianness of doubles in your machine +** (0 for little endian, 1 for big endian); if not defined, Lua will +** check it dynamically for LUA_IEEE754TRICK (but not for LUA_NANTRICK). +** +@@ LUA_NANTRICK controls the use of a trick to pack all types into +** a single double value, using NaN values to represent non-number +** values. The trick only works on 32-bit machines (ints and pointers +** are 32-bit values) with numbers represented as IEEE 754-2008 doubles +** with conventional endianess (12345678 or 87654321), in CPUs that do +** not produce signaling NaN values (all NaNs are quiet). +*/ + +/* Microsoft compiler on a Pentium (32 bit) ? */ +#if defined(LUA_WIN) && defined(_MSC_VER) && defined(_M_IX86) /* { */ + +#define LUA_MSASMTRICK +#define LUA_IEEEENDIAN 0 +#define LUA_NANTRICK + + +/* pentium 32 bits? */ +#elif defined(__i386__) || defined(__i386) || defined(__X86__) /* }{ */ + +#define LUA_IEEE754TRICK +#define LUA_IEEELL +#define LUA_IEEEENDIAN 0 +#define LUA_NANTRICK + +/* pentium 64 bits? */ +#elif defined(__x86_64) /* }{ */ + +#define LUA_IEEE754TRICK +#define LUA_IEEEENDIAN 0 + +#elif defined(__POWERPC__) || defined(__ppc__) /* }{ */ + +#define LUA_IEEE754TRICK +#define LUA_IEEEENDIAN 1 + +#else /* }{ */ + +/* assume IEEE754 and a 32-bit integer type */ +#define LUA_IEEE754TRICK + +#endif /* } */ + +#endif /* } */ + +/* }================================================================== */ + + + + +/* =================================================================== */ + +/* +** Local configuration. You can use this space to add your redefinitions +** without modifying the main part of the file. +*/ + + + +#endif + diff --git a/vendor/lua/5.2/include/lualib.h b/vendor/lua/5.2/include/lualib.h new file mode 100644 index 000000000..da82005c9 --- /dev/null +++ b/vendor/lua/5.2/include/lualib.h @@ -0,0 +1,55 @@ +/* +** $Id: lualib.h,v 1.43.1.1 2013/04/12 18:48:47 roberto Exp $ +** Lua standard libraries +** See Copyright Notice in lua.h +*/ + + +#ifndef lualib_h +#define lualib_h + +#include "lua.h" + + + +LUAMOD_API int (luaopen_base) (lua_State *L); + +#define LUA_COLIBNAME "coroutine" +LUAMOD_API int (luaopen_coroutine) (lua_State *L); + +#define LUA_TABLIBNAME "table" +LUAMOD_API int (luaopen_table) (lua_State *L); + +#define LUA_IOLIBNAME "io" +LUAMOD_API int (luaopen_io) (lua_State *L); + +#define LUA_OSLIBNAME "os" +LUAMOD_API int (luaopen_os) (lua_State *L); + +#define LUA_STRLIBNAME "string" +LUAMOD_API int (luaopen_string) (lua_State *L); + +#define LUA_BITLIBNAME "bit32" +LUAMOD_API int (luaopen_bit32) (lua_State *L); + +#define LUA_MATHLIBNAME "math" +LUAMOD_API int (luaopen_math) (lua_State *L); + +#define LUA_DBLIBNAME "debug" +LUAMOD_API int (luaopen_debug) (lua_State *L); + +#define LUA_LOADLIBNAME "package" +LUAMOD_API int (luaopen_package) (lua_State *L); + + +/* open all previous libraries */ +LUALIB_API void (luaL_openlibs) (lua_State *L); + + + +#if !defined(lua_assert) +#define lua_assert(x) ((void)0) +#endif + + +#endif diff --git a/vendor/lua/5.2/linux/liblua52.a b/vendor/lua/5.2/linux/liblua52.a new file mode 100644 index 000000000..828b775c8 Binary files /dev/null and b/vendor/lua/5.2/linux/liblua52.a differ diff --git a/vendor/lua/5.2/linux/liblua52.so b/vendor/lua/5.2/linux/liblua52.so new file mode 100644 index 000000000..e2c474192 Binary files /dev/null and b/vendor/lua/5.2/linux/liblua52.so differ diff --git a/vendor/lua/5.2/lua.odin b/vendor/lua/5.2/lua.odin new file mode 100644 index 000000000..9770e95b9 --- /dev/null +++ b/vendor/lua/5.2/lua.odin @@ -0,0 +1,728 @@ +package lua_5_2 + +import "core:intrinsics" +import "core:builtin" + +import c "core:c/libc" + +#assert(size_of(c.int) == size_of(b32)) + +when ODIN_OS == .Windows { + foreign import lib "windows/lua52dll.lib" +} else when ODIN_OS == .Linux { + foreign import lib "linux/liblua52.a" +} else { + foreign import lib "system:liblua52.a" +} + +VERSION_MAJOR :: "5" +VERSION_MINOR :: "2" +VERSION_NUM :: 502 +VERSION_RELEASE :: "4" + +VERSION :: "Lua " + VERSION_MAJOR + "." + VERSION_MINOR +RELEASE :: VERSION + "." + VERSION_RELEASE +COPYRIGHT :: RELEASE + " Copyright (C) 1994-2015 Lua.org, PUC-Rio" +AUTHORS :: "R. Ierusalimschy, L. H. de Figueiredo, W. Celes" + + +/* mark for precompiled code ('Lua') */ +SIGNATURE :: "\x1bLua" + +/* option for multiple returns in 'lua_pcall' and 'lua_call' */ +MULTRET :: -1 + +FIRSTPSEUDOIDX :: -MAXSTACK - 1000 + +REGISTRYINDEX :: -FIRSTPSEUDOIDX + + +/* +@@ LUAI_MAXSTACK limits the size of the Lua stack. +** CHANGE it if you need a different limit. This limit is arbitrary; +** its only purpose is to stop Lua from consuming unlimited stack +** space (and to reserve some numbers for pseudo-indices). +** (It must fit into max(size_t)/32.) +*/ +MAXSTACK :: 1000000 + + +/* +@@ LUA_EXTRASPACE defines the size of a raw memory area associated with +** a Lua state with very fast access. +** CHANGE it if you need a different size. +*/ +EXTRASPACE :: size_of(rawptr) + + + +/* +@@ LUA_IDSIZE gives the maximum size for the description of the source +@@ of a function in debug information. +** CHANGE it if you want a different size. +*/ +IDSIZE :: 60 + + +/* +@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. +*/ +L_BUFFERSIZE :: c.int(16 * size_of(rawptr) * size_of(Number)) + + +MAXALIGNVAL :: max(align_of(Number), align_of(f64), align_of(rawptr), align_of(Integer), align_of(c.long)) + + +Status :: enum c.int { + OK = 0, + YIELD = 1, + ERRRUN = 2, + ERRSYNTAX = 3, + ERRMEM = 4, + ERRERR = 5, + ERRGCMM = 6, + ERRFILE = 7, +} + +/* thread status */ +OK :: Status.OK +YIELD :: Status.YIELD +ERRRUN :: Status.ERRRUN +ERRSYNTAX :: Status.ERRSYNTAX +ERRMEM :: Status.ERRMEM +ERRERR :: Status.ERRERR +ERRFILE :: Status.ERRFILE + +/* +** basic types +*/ + + +Type :: enum c.int { + NONE = -1, + + NIL = 0, + BOOLEAN = 1, + LIGHTUSERDATA = 2, + NUMBER = 3, + STRING = 4, + TABLE = 5, + FUNCTION = 6, + USERDATA = 7, + THREAD = 8, +} + +TNONE :: Type.NONE +TNIL :: Type.NIL +TBOOLEAN :: Type.BOOLEAN +TLIGHTUSERDATA :: Type.LIGHTUSERDATA +TNUMBER :: Type.NUMBER +TSTRING :: Type.STRING +TTABLE :: Type.TABLE +TFUNCTION :: Type.FUNCTION +TUSERDATA :: Type.USERDATA +TTHREAD :: Type.THREAD +NUMTYPES :: 9 + + + +ArithOp :: enum c.int { + ADD = 0, /* ORDER TM, ORDER OP */ + SUB = 1, + MUL = 2, + DIV = 3, + MOD = 4, + POW = 5, + UNM = 6, +} + +CompareOp :: enum c.int { + EQ = 0, + LT = 1, + LE = 2, +} + +OPADD :: ArithOp.ADD +OPSUB :: ArithOp.SUB +OPMUL :: ArithOp.MUL +OPDIV :: ArithOp.DIV +OPMOD :: ArithOp.MOD +OPPOW :: ArithOp.POW +OPUNM :: ArithOp.UNM + +OPEQ :: CompareOp.EQ +OPLT :: CompareOp.LT +OPLE :: CompareOp.LE + + +/* minimum Lua stack available to a C function */ +MINSTACK :: 20 + + +/* predefined values in the registry */ +RIDX_MAINTHREAD :: 1 +RIDX_GLOBALS :: 2 +RIDX_LAST :: RIDX_GLOBALS + + +/* type of numbers in Lua */ +Number :: distinct (f32 when size_of(uintptr) == 4 else f64) + + +/* type for integer functions */ +Integer :: distinct (i32 when size_of(uintptr) == 4 else i64) + +/* unsigned integer type */ +Unsigned :: distinct (u32 when size_of(uintptr) == 4 else u64) + + +/* +** Type for C functions registered with Lua +*/ +CFunction :: #type proc "c" (L: ^State) -> c.int + + + +/* +** Type for functions that read/write blocks when loading/dumping Lua chunks +*/ +Reader :: #type proc "c" (L: ^State, ud: rawptr, sz: ^c.size_t) -> cstring +Writer :: #type proc "c" (L: ^State, p: rawptr, sz: ^c.size_t, ud: rawptr) -> c.int + + +/* +** Type for memory-allocation functions +*/ +Alloc :: #type proc "c" (ud: rawptr, ptr: rawptr, osize, nsize: c.size_t) -> rawptr + + +GCWhat :: enum c.int { + STOP = 0, + RESTART = 1, + COLLECT = 2, + COUNT = 3, + COUNTB = 4, + STEP = 5, + SETPAUSE = 6, + SETSTEPMUL = 7, + SETMAJORINC = 8, + ISRUNNING = 9, + GEN = 10, + INC = 11, +} +GCSTOP :: GCWhat.STOP +GCRESTART :: GCWhat.RESTART +GCCOLLECT :: GCWhat.COLLECT +GCCOUNT :: GCWhat.COUNT +GCCOUNTB :: GCWhat.COUNTB +GCSTEP :: GCWhat.STEP +GCSETPAUSE :: GCWhat.SETPAUSE +GCSETSTEPMUL :: GCWhat.SETSTEPMUL +GCSETMAJORINC :: GCWhat.SETMAJORINC +GCISRUNNING :: GCWhat.ISRUNNING +GCGEN :: GCWhat.GEN +GCINC :: GCWhat.INC + + + +/* +** Event codes +*/ + +HookEvent :: enum c.int { + CALL = 0, + RET = 1, + LINE = 2, + COUNT = 3, + TAILCALL = 4, +} +HOOKCALL :: HookEvent.CALL +HOOKRET :: HookEvent.RET +HOOKLINE :: HookEvent.LINE +HOOKCOUNT :: HookEvent.COUNT +HOOKTAILCALL :: HookEvent.TAILCALL + + +/* +** Event masks +*/ +HookMask :: distinct bit_set[HookEvent; c.int] +MASKCALL :: HookMask{.CALL} +MASKRET :: HookMask{.RET} +MASKLINE :: HookMask{.LINE} +MASKCOUNT :: HookMask{.COUNT} + +/* activation record */ +Debug :: struct { + event: HookEvent, + name: cstring, /* (n) */ + namewhat: cstring, /* (n) 'global', 'local', 'field', 'method' */ + what: cstring, /* (S) 'Lua', 'C', 'main', 'tail' */ + source: cstring, /* (S) */ + currentline: c.int, /* (l) */ + linedefined: c.int, /* (S) */ + lastlinedefined: c.int, /* (S) */ + nups: u8, /* (u) number of upvalues */ + nparams: u8, /* (u) number of parameters */ + isvararg: bool, /* (u) */ + istailcall: bool, /* (t) */ + short_src: [IDSIZE]u8 `fmt:"s"`, /* (S) */ + /* private part */ + i_ci: rawptr, /* active function */ +} + + +/* Functions to be called by the debugger in specific events */ +Hook :: #type proc "c" (L: ^State, ar: ^Debug) + + +State :: struct {} // opaque data type + + +@(link_prefix="lua_") +@(default_calling_convention="c") +foreign lib { + /* + ** RCS ident string + */ + + ident: [^]u8 // TODO(bill): is this correct? + + + /* + ** state manipulation + */ + + newstate :: proc(f: Alloc, ud: rawptr) -> ^State --- + close :: proc(L: ^State) --- + newthread :: proc(L: ^State) -> ^State --- + + atpanic :: proc(L: ^State, panicf: CFunction) -> CFunction --- + + version :: proc(L: ^State) -> ^Number --- + + + /* + ** basic stack manipulation + */ + + absindex :: proc (L: ^State, idx: c.int) -> c.int --- + gettop :: proc (L: ^State) -> c.int --- + settop :: proc (L: ^State, idx: c.int) --- + pushvalue :: proc (L: ^State, idx: c.int) --- + remove :: proc (L: ^State, idx: c.int) --- + insert :: proc (L: ^State, idx: c.int) --- + replace :: proc (L: ^State, idx: c.int) --- + copy :: proc (L: ^State, fromidx, toidx: c.int) --- + checkstack :: proc (L: ^State, sz: c.int) -> c.int --- + + xmove :: proc(from, to: ^State, n: c.int) --- + + + /* + ** access functions (stack -> C) + */ + + isnumber :: proc(L: ^State, idx: c.int) -> b32 --- + isstring :: proc(L: ^State, idx: c.int) -> b32 --- + iscfunction :: proc(L: ^State, idx: c.int) -> b32 --- + isinteger :: proc(L: ^State, idx: c.int) -> b32 --- + isuserdata :: proc(L: ^State, idx: c.int) -> b32 --- + type :: proc(L: ^State, idx: c.int) -> Type --- + typename :: proc(L: ^State, tp: Type) -> cstring --- + + @(link_name="lua_tonumberx") + tonumber :: proc(L: ^State, idx: c.int, isnum: ^b32 = nil) -> Number --- + @(link_name="lua_tointegerx") + tointeger :: proc(L: ^State, idx: c.int, isnum: ^b32 = nil) -> Integer --- + @(link_name="lua_tounsignedx") + tounsigned :: proc(L: ^State, idx: c.int, isnum: ^b32 = nil) -> Unsigned --- + toboolean :: proc(L: ^State, idx: c.int) -> b32 --- + tolstring :: proc(L: ^State, idx: c.int, len: ^c.size_t) -> cstring --- + rawlen :: proc(L: ^State, idx: c.int) -> c.size_t --- + tocfunction :: proc(L: ^State, idx: c.int) -> CFunction --- + touserdata :: proc(L: ^State, idx: c.int) -> rawptr --- + tothread :: proc(L: ^State, idx: c.int) -> ^State --- + topointer :: proc(L: ^State, idx: c.int) -> rawptr --- + + /* + ** Comparison and arithmetic functions + */ + + arith :: proc(L: ^State, op: ArithOp) --- + rawequal :: proc(L: ^State, idx1, idx2: c.int) -> b32 --- + compare :: proc(L: ^State, idx1, idx2: c.int, op: CompareOp) -> b32 --- + + /* + ** push functions (C -> stack) + */ + + pushnil :: proc(L: ^State) --- + pushnumber :: proc(L: ^State, n: Number) --- + pushinteger :: proc(L: ^State, n: Integer) --- + pushunsigned :: proc(L: ^State, n: Unsigned) --- + pushlstring :: proc(L: ^State, s: cstring, l: c.size_t) -> cstring --- + pushstring :: proc(L: ^State, s: cstring) -> cstring --- + pushvfstring :: proc(L: ^State, fmt: cstring, argp: c.va_list) -> cstring --- + pushfstring :: proc(L: ^State, fmt: cstring, #c_vararg args: ..any) -> cstring --- + pushcclosure :: proc(L: ^State, fn: CFunction, n: c.int) --- + pushboolean :: proc(L: ^State, b: b32) --- + pushlightuserdata :: proc(L: ^State, p: rawptr) --- + pushthread :: proc(L: ^State) -> Status --- + + /* + ** get functions (Lua -> stack) + */ + + getglobal :: proc(L: ^State, name: cstring) --- + gettable :: proc(L: ^State, idx: c.int) --- + getfield :: proc(L: ^State, idx: c.int, k: cstring) --- + geti :: proc(L: ^State, idx: c.int, n: Integer) --- + rawget :: proc(L: ^State, idx: c.int) --- + rawgeti :: proc(L: ^State, idx: c.int, n: Integer) --- + rawgetp :: proc(L: ^State, idx: c.int, p: rawptr) --- + + createtable :: proc(L: ^State, narr, nrec: c.int) --- + newuserdata :: proc(L: ^State, sz: c.size_t) -> rawptr --- + getmetatable :: proc(L: ^State, objindex: c.int) -> c.int --- + getuservalue :: proc(L: ^State, idx: c.int) --- + + + /* + ** set functions (stack -> Lua) + */ + + setglobal :: proc(L: ^State, var: cstring) --- + settable :: proc(L: ^State, idx: c.int) --- + setfield :: proc(L: ^State, idx: c.int, k: cstring) --- + rawset :: proc(L: ^State, idx: c.int) --- + rawseti :: proc(L: ^State, idx: c.int, n: c.int) --- + rawsetp :: proc(L: ^State, idx: c.int, p: rawptr) --- + setmetatable :: proc(L: ^State, objindex: c.int) -> c.int --- + setuservalue :: proc(L: ^State, idx: c.int) -> c.int --- + + + /* + ** 'load' and 'call' functions (load and run Lua code) + */ + + @(link_name="lua_callk") + call :: proc(L: ^State, nargs, nresults: c.int, ctx: c.int = 0, + k: CFunction = nil) --- + + getctx :: proc(L: ^State, ctx: ^c.int) -> c.int --- + + @(link_name="lua_pcallk") + pcall :: proc(L: ^State, nargs, nresults: c.int, errfunc: c.int, + ctx: c.int = 0, k: CFunction = nil) -> c.int --- + + load :: proc(L: ^State, reader: Reader, dt: rawptr, + chunkname, mode: cstring) -> Status --- + + dump :: proc(L: ^State, writer: Writer, data: rawptr) -> Status --- + + + /* + ** coroutine functions + */ + + @(link_name="lua_yieldk") + yield :: proc(L: ^State, nresults: c.int, ctx: c.int = 0, k: CFunction = nil) -> Status --- + resume :: proc(L: ^State, from: ^State, narg: c.int) -> Status --- + status :: proc(L: ^State) -> Status --- + + + /* + ** garbage-collection function and options + */ + + + + gc :: proc(L: ^State, what: GCWhat, data: c.int) -> c.int --- + + + /* + ** miscellaneous functions + */ + + error :: proc(L: ^State) -> Status --- + + next :: proc(L: ^State, idx: c.int) -> c.int --- + + concat :: proc(L: ^State, n: c.int) --- + len :: proc(L: ^State, idx: c.int) --- + + getallocf :: proc(L: State, ud: ^rawptr) -> Alloc --- + setallocf :: proc(L: ^State, f: Alloc, ud: rawptr) --- + + /* + ** {====================================================================== + ** Debug API + ** ======================================================================= + */ + + getstack :: proc(L: ^State, level: c.int, ar: ^Debug) -> c.int --- + getinfo :: proc(L: ^State, what: cstring, ar: ^Debug) -> c.int --- + getlocal :: proc(L: ^State, ar: ^Debug, n: c.int) -> cstring --- + setlocal :: proc(L: ^State, ar: ^Debug, n: c.int) -> cstring --- + getupvalue :: proc(L: ^State, funcindex: c.int, n: c.int) -> cstring --- + setupvalue :: proc(L: ^State, funcindex: c.int, n: c.int) -> cstring --- + + upvalueid :: proc(L: ^State, fidx, n: c.int) -> rawptr --- + upvaluejoin :: proc(L: ^State, fidx1, n1, fidx2, n2: c.int) --- + + sethook :: proc(L: ^State, func: Hook, mask: HookMask, count: c.int) -> c.int --- + gethook :: proc(L: ^State) -> Hook --- + gethookmask :: proc(L: ^State) -> HookMask --- + gethookcount :: proc(L: ^State) -> c.int --- + + /* }============================================================== */ +} + + + +/* version suffix for environment variable names */ +VERSUFFIX :: "_" + VERSION_MAJOR + "_" + VERSION_MINOR + +COLIBNAME :: "coroutine" +TABLIBNAME :: "table" +IOLIBNAME :: "io" +OSLIBNAME :: "os" +STRLIBNAME :: "string" +UTF8LIBNAME :: "utf8" +BITLIBNAME :: "bit32" +MATHLIBNAME :: "math" +DBLIBNAME :: "debug" +LOADLIBNAME :: "package" + +@(link_prefix="lua") +@(default_calling_convention="c") +foreign lib { + open_base :: proc(L: ^State) -> c.int --- + open_coroutine :: proc(L: ^State) -> c.int --- + open_table :: proc(L: ^State) -> c.int --- + open_io :: proc(L: ^State) -> c.int --- + open_os :: proc(L: ^State) -> c.int --- + open_string :: proc(L: ^State) -> c.int --- + open_utf8 :: proc(L: ^State) -> c.int --- + open_bit32 :: proc(L: ^State) -> c.int --- + open_math :: proc(L: ^State) -> c.int --- + open_debug :: proc(L: ^State) -> c.int --- + open_package :: proc(L: ^State) -> c.int --- + + /* open all previous libraries */ + + L_openlibs :: proc(L: ^State) --- +} + + + +GNAME :: "_G" + +L_Reg :: struct { + name: cstring, + func: CFunction, +} + + +/* predefined references */ +NOREF :: -2 +REFNIL :: -1 + + +@(link_prefix="lua") +@(default_calling_convention="c") +foreign lib { + @(link_name="luaL_checkversion_") + L_checkversion :: proc(L: ^State, ver: Number = VERSION_NUM) --- + + + L_getmetafield :: proc(L: ^State, obj: c.int, e: cstring) -> c.int --- + L_callmeta :: proc(L: ^State, obj: c.int, e: cstring) -> c.int --- + @(link_name="luaL_tolstring") + L_tostring :: proc(L: ^State, idx: c.int, len: ^c.size_t = nil) -> cstring --- + L_argerror :: proc(L: ^State, numarg: c.int, extramsg: cstring) -> c.int --- + @(link_name="luaL_checklstring") + L_checkstring :: proc(L: ^State, numArg: c.int, l: ^c.size_t = nil) -> cstring --- + @(link_name="luaL_optlstring") + L_optstring :: proc(L: ^State, numArg: c.int, def: cstring, l: ^c.size_t = nil) -> cstring --- + L_checknumber :: proc(L: ^State, numArg: c.int) -> Number --- + L_optnumber :: proc(L: ^State, nArg: c.int, def: Number) -> Number --- + + L_checkinteger :: proc(L: ^State, numArg: c.int) -> Integer --- + L_optinteger :: proc(L: ^State, nArg: c.int, def: Integer) -> Integer --- + L_checkunsigned :: proc(L: ^State, numArg: c.int) -> Unsigned --- + L_optunsigned :: proc(L: ^State, nArg: c.int, def: Unsigned) -> Unsigned --- + + + L_checkstack :: proc(L: ^State, sz: c.int, msg: cstring) --- + L_checktype :: proc(L: ^State, narg: c.int, t: c.int) --- + L_checkany :: proc(L: ^State, narg: c.int) --- + + L_newmetatable :: proc(L: ^State, tname: cstring) -> c.int --- + L_setmetatable :: proc(L: ^State, tname: cstring) --- + L_testudata :: proc(L: ^State, ud: c.int, tname: cstring) -> rawptr --- + L_checkudata :: proc(L: ^State, ud: c.int, tname: cstring) -> rawptr --- + + L_where :: proc(L: ^State, lvl: c.int) --- + L_error :: proc(L: ^State, fmt: cstring, #c_vararg args: ..any) -> Status --- + + L_checkoption :: proc(L: ^State, narg: c.int, def: cstring, lst: [^]cstring) -> c.int --- + + L_fileresult :: proc(L: ^State, stat: c.int, fname: cstring) -> c.int --- + L_execresult :: proc(L: ^State, stat: c.int) -> c.int --- + + + L_ref :: proc(L: ^State, t: c.int) -> c.int --- + L_unref :: proc(L: ^State, t: c.int, ref: c.int) --- + + @(link_name="luaL_loadfilex") + L_loadfile :: proc (L: ^State, filename: cstring, mode: cstring = nil) -> Status --- + + @(link_name="luaL_loadbufferx") + L_loadbuffer :: proc(L: ^State, buff: [^]byte, sz: c.size_t, name: cstring, mode: cstring = nil) -> Status --- + L_loadstring :: proc(L: ^State, s: cstring) -> Status --- + + L_newstate :: proc() -> ^State --- + + L_len :: proc(L: ^State, idx: c.int) -> c.int --- + + L_gsub :: proc(L: ^State, s, p, r: cstring) -> cstring --- + + L_setfuncs :: proc(L: ^State, l: [^]L_Reg, nup: c.int) --- + + L_getsubtable :: proc(L: ^State, idx: c.int, fname: cstring) -> c.int --- + + L_traceback :: proc(L: ^State, L1: ^State, msg: cstring, level: c.int) --- + + L_requiref :: proc(L: ^State, modname: cstring, openf: CFunction, glb: c.int) --- + +} +/* +** {====================================================== +** Generic Buffer manipulation +** ======================================================= +*/ + + +L_Buffer :: struct { + b: [^]byte, /* buffer address */ + size: c.size_t, /* buffer size */ + n: c.size_t, /* number of characters in buffer */ + L: ^State, + initb: [L_BUFFERSIZE]byte, /* initial buffer */ +} + +L_addchar :: #force_inline proc "c" (B: ^L_Buffer, c: byte) { + if B.n < B.size { + L_prepbuffsize(B, 1) + } + B.b[B.n] = c + B.n += 1 +} + +L_addsize :: #force_inline proc "c" (B: ^L_Buffer, s: c.size_t) -> c.size_t { + B.n += s + return B.n +} + +L_prepbuffer :: #force_inline proc "c" (B: ^L_Buffer) -> [^]byte { + return L_prepbuffsize(B, c.size_t(L_BUFFERSIZE)) +} + + +@(link_prefix="lua") +@(default_calling_convention="c") +foreign lib { + L_buffinit :: proc(L: ^State, B: ^L_Buffer) --- + L_prepbuffsize :: proc(B: ^L_Buffer, sz: c.size_t) -> [^]byte --- + L_addlstring :: proc(B: ^L_Buffer, s: cstring, l: c.size_t) --- + L_addstring :: proc(B: ^L_Buffer, s: cstring) --- + L_addvalue :: proc(B: ^L_Buffer) --- + L_pushresult :: proc(B: ^L_Buffer) --- + L_pushresultsize :: proc(B: ^L_Buffer, sz: c.size_t) --- + L_buffinitsize :: proc(L: ^State, B: ^L_Buffer, sz: c.size_t) -> [^]byte --- +} + + +/* }====================================================== */ + + + + +/* +** {============================================================== +** some useful macros +** =============================================================== +*/ + +pop :: #force_inline proc "c" (L: ^State, n: c.int) { + settop(L, -n-1) +} +newtable :: #force_inline proc "c" (L: ^State) { + createtable(L, 0, 0) +} +register :: #force_inline proc "c" (L: ^State, n: cstring, f: CFunction) { + pushcfunction(L, f) + setglobal(L, n) +} + +pushcfunction :: #force_inline proc "c" (L: ^State, f: CFunction) { + pushcclosure(L, f, 0) +} + + +isfunction :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .FUNCTION } +istable :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .TABLE } +islightuserdata :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .LIGHTUSERDATA } +isnil :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .NIL } +isboolean :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .BOOLEAN } +isthread :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .THREAD } +isnone :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .NONE } +isnoneornil :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) <= .NIL } + + +pushliteral :: pushstring +pushglobaltable :: #force_inline proc "c" (L: ^State) { + rawgeti(L, REGISTRYINDEX, RIDX_GLOBALS) +} +tostring :: #force_inline proc "c" (L: ^State, i: c.int) -> cstring { + return tolstring(L, i, nil) +} + +L_newlibtable :: #force_inline proc "c" (L: ^State, l: []L_Reg) { + createtable(L, 0, c.int(builtin.len(l) - 1)) +} + +L_newlib :: proc(L: ^State, l: []L_Reg) { + L_newlibtable(L, l) + L_setfuncs(L, raw_data(l), 0) +} + +L_argcheck :: #force_inline proc "c" (L: ^State, cond: bool, numarg: c.int, extramsg: cstring) { + if cond { + L_argerror(L, numarg, extramsg) + } +} + +L_typename :: #force_inline proc "c" (L: ^State, i: c.int) -> cstring { + return typename(L, type(L, i)) +} +L_dofile :: #force_inline proc "c" (L: ^State, s: cstring) -> c.int { + err := L_loadfile(L, s) + return pcall(L, 0, MULTRET, 0) if err == nil else c.int(err) +} +L_dostring :: #force_inline proc "c" (L: ^State, s: cstring) -> c.int { + err := L_loadstring(L, s) + return pcall(L, 0, MULTRET, 0) if err == nil else c.int(err) +} +L_getmetatable :: #force_inline proc "c" (L: ^State, n: cstring) { + getfield(L, REGISTRYINDEX, n) +} +L_opt :: #force_inline proc "c" (L: ^State, f: $F, n: c.int, d: $T) -> T where intrinsics.type_is_proc(F) { + return d if isnoneornil(L, n) else f(L, n) +} + + + +/* }============================================================== */ diff --git a/vendor/lua/5.2/windows/lua52.dll b/vendor/lua/5.2/windows/lua52.dll new file mode 100644 index 000000000..b7e15d585 Binary files /dev/null and b/vendor/lua/5.2/windows/lua52.dll differ diff --git a/vendor/lua/5.2/windows/lua52dll.lib b/vendor/lua/5.2/windows/lua52dll.lib new file mode 100644 index 000000000..0d6ffb751 Binary files /dev/null and b/vendor/lua/5.2/windows/lua52dll.lib differ diff --git a/vendor/lua/5.3/include/lauxlib.h b/vendor/lua/5.3/include/lauxlib.h new file mode 100644 index 000000000..9857d3a83 --- /dev/null +++ b/vendor/lua/5.3/include/lauxlib.h @@ -0,0 +1,264 @@ +/* +** $Id: lauxlib.h,v 1.131.1.1 2017/04/19 17:20:42 roberto Exp $ +** Auxiliary functions for building Lua libraries +** See Copyright Notice in lua.h +*/ + + +#ifndef lauxlib_h +#define lauxlib_h + + +#include +#include + +#include "lua.h" + + + +/* extra error code for 'luaL_loadfilex' */ +#define LUA_ERRFILE (LUA_ERRERR+1) + + +/* key, in the registry, for table of loaded modules */ +#define LUA_LOADED_TABLE "_LOADED" + + +/* key, in the registry, for table of preloaded loaders */ +#define LUA_PRELOAD_TABLE "_PRELOAD" + + +typedef struct luaL_Reg { + const char *name; + lua_CFunction func; +} luaL_Reg; + + +#define LUAL_NUMSIZES (sizeof(lua_Integer)*16 + sizeof(lua_Number)) + +LUALIB_API void (luaL_checkversion_) (lua_State *L, lua_Number ver, size_t sz); +#define luaL_checkversion(L) \ + luaL_checkversion_(L, LUA_VERSION_NUM, LUAL_NUMSIZES) + +LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e); +LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e); +LUALIB_API const char *(luaL_tolstring) (lua_State *L, int idx, size_t *len); +LUALIB_API int (luaL_argerror) (lua_State *L, int arg, const char *extramsg); +LUALIB_API const char *(luaL_checklstring) (lua_State *L, int arg, + size_t *l); +LUALIB_API const char *(luaL_optlstring) (lua_State *L, int arg, + const char *def, size_t *l); +LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int arg); +LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int arg, lua_Number def); + +LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int arg); +LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int arg, + lua_Integer def); + +LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg); +LUALIB_API void (luaL_checktype) (lua_State *L, int arg, int t); +LUALIB_API void (luaL_checkany) (lua_State *L, int arg); + +LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname); +LUALIB_API void (luaL_setmetatable) (lua_State *L, const char *tname); +LUALIB_API void *(luaL_testudata) (lua_State *L, int ud, const char *tname); +LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname); + +LUALIB_API void (luaL_where) (lua_State *L, int lvl); +LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...); + +LUALIB_API int (luaL_checkoption) (lua_State *L, int arg, const char *def, + const char *const lst[]); + +LUALIB_API int (luaL_fileresult) (lua_State *L, int stat, const char *fname); +LUALIB_API int (luaL_execresult) (lua_State *L, int stat); + +/* predefined references */ +#define LUA_NOREF (-2) +#define LUA_REFNIL (-1) + +LUALIB_API int (luaL_ref) (lua_State *L, int t); +LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref); + +LUALIB_API int (luaL_loadfilex) (lua_State *L, const char *filename, + const char *mode); + +#define luaL_loadfile(L,f) luaL_loadfilex(L,f,NULL) + +LUALIB_API int (luaL_loadbufferx) (lua_State *L, const char *buff, size_t sz, + const char *name, const char *mode); +LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s); + +LUALIB_API lua_State *(luaL_newstate) (void); + +LUALIB_API lua_Integer (luaL_len) (lua_State *L, int idx); + +LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p, + const char *r); + +LUALIB_API void (luaL_setfuncs) (lua_State *L, const luaL_Reg *l, int nup); + +LUALIB_API int (luaL_getsubtable) (lua_State *L, int idx, const char *fname); + +LUALIB_API void (luaL_traceback) (lua_State *L, lua_State *L1, + const char *msg, int level); + +LUALIB_API void (luaL_requiref) (lua_State *L, const char *modname, + lua_CFunction openf, int glb); + +/* +** =============================================================== +** some useful macros +** =============================================================== +*/ + + +#define luaL_newlibtable(L,l) \ + lua_createtable(L, 0, sizeof(l)/sizeof((l)[0]) - 1) + +#define luaL_newlib(L,l) \ + (luaL_checkversion(L), luaL_newlibtable(L,l), luaL_setfuncs(L,l,0)) + +#define luaL_argcheck(L, cond,arg,extramsg) \ + ((void)((cond) || luaL_argerror(L, (arg), (extramsg)))) +#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL)) +#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL)) + +#define luaL_typename(L,i) lua_typename(L, lua_type(L,(i))) + +#define luaL_dofile(L, fn) \ + (luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0)) + +#define luaL_dostring(L, s) \ + (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0)) + +#define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n))) + +#define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n))) + +#define luaL_loadbuffer(L,s,sz,n) luaL_loadbufferx(L,s,sz,n,NULL) + + +/* +** {====================================================== +** Generic Buffer manipulation +** ======================================================= +*/ + +typedef struct luaL_Buffer { + char *b; /* buffer address */ + size_t size; /* buffer size */ + size_t n; /* number of characters in buffer */ + lua_State *L; + char initb[LUAL_BUFFERSIZE]; /* initial buffer */ +} luaL_Buffer; + + +#define luaL_addchar(B,c) \ + ((void)((B)->n < (B)->size || luaL_prepbuffsize((B), 1)), \ + ((B)->b[(B)->n++] = (c))) + +#define luaL_addsize(B,s) ((B)->n += (s)) + +LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B); +LUALIB_API char *(luaL_prepbuffsize) (luaL_Buffer *B, size_t sz); +LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l); +LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s); +LUALIB_API void (luaL_addvalue) (luaL_Buffer *B); +LUALIB_API void (luaL_pushresult) (luaL_Buffer *B); +LUALIB_API void (luaL_pushresultsize) (luaL_Buffer *B, size_t sz); +LUALIB_API char *(luaL_buffinitsize) (lua_State *L, luaL_Buffer *B, size_t sz); + +#define luaL_prepbuffer(B) luaL_prepbuffsize(B, LUAL_BUFFERSIZE) + +/* }====================================================== */ + + + +/* +** {====================================================== +** File handles for IO library +** ======================================================= +*/ + +/* +** A file handle is a userdata with metatable 'LUA_FILEHANDLE' and +** initial structure 'luaL_Stream' (it may contain other fields +** after that initial structure). +*/ + +#define LUA_FILEHANDLE "FILE*" + + +typedef struct luaL_Stream { + FILE *f; /* stream (NULL for incompletely created streams) */ + lua_CFunction closef; /* to close stream (NULL for closed streams) */ +} luaL_Stream; + +/* }====================================================== */ + + + +/* compatibility with old module system */ +#if defined(LUA_COMPAT_MODULE) + +LUALIB_API void (luaL_pushmodule) (lua_State *L, const char *modname, + int sizehint); +LUALIB_API void (luaL_openlib) (lua_State *L, const char *libname, + const luaL_Reg *l, int nup); + +#define luaL_register(L,n,l) (luaL_openlib(L,(n),(l),0)) + +#endif + + +/* +** {================================================================== +** "Abstraction Layer" for basic report of messages and errors +** =================================================================== +*/ + +/* print a string */ +#if !defined(lua_writestring) +#define lua_writestring(s,l) fwrite((s), sizeof(char), (l), stdout) +#endif + +/* print a newline and flush the output */ +#if !defined(lua_writeline) +#define lua_writeline() (lua_writestring("\n", 1), fflush(stdout)) +#endif + +/* print an error message */ +#if !defined(lua_writestringerror) +#define lua_writestringerror(s,p) \ + (fprintf(stderr, (s), (p)), fflush(stderr)) +#endif + +/* }================================================================== */ + + +/* +** {============================================================ +** Compatibility with deprecated conversions +** ============================================================= +*/ +#if defined(LUA_COMPAT_APIINTCASTS) + +#define luaL_checkunsigned(L,a) ((lua_Unsigned)luaL_checkinteger(L,a)) +#define luaL_optunsigned(L,a,d) \ + ((lua_Unsigned)luaL_optinteger(L,a,(lua_Integer)(d))) + +#define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n))) +#define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d))) + +#define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n))) +#define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d))) + +#endif +/* }============================================================ */ + + + +#endif + + diff --git a/vendor/lua/5.3/include/lua.h b/vendor/lua/5.3/include/lua.h new file mode 100644 index 000000000..9394c5ef8 --- /dev/null +++ b/vendor/lua/5.3/include/lua.h @@ -0,0 +1,485 @@ +/* +** Lua - A Scripting Language +** Lua.org, PUC-Rio, Brazil (http://www.lua.org) +** See Copyright Notice at the end of this file +*/ + + +#ifndef lua_h +#define lua_h + +#include +#include + + +#include "luaconf.h" + + +#define LUA_VERSION_MAJOR "5" +#define LUA_VERSION_MINOR "3" +#define LUA_VERSION_NUM 503 +#define LUA_VERSION_RELEASE "6" + +#define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR +#define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE +#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2020 Lua.org, PUC-Rio" +#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo, W. Celes" + + +/* mark for precompiled code ('Lua') */ +#define LUA_SIGNATURE "\x1bLua" + +/* option for multiple returns in 'lua_pcall' and 'lua_call' */ +#define LUA_MULTRET (-1) + + +/* +** Pseudo-indices +** (-LUAI_MAXSTACK is the minimum valid index; we keep some free empty +** space after that to help overflow detection) +*/ +#define LUA_REGISTRYINDEX (-LUAI_MAXSTACK - 1000) +#define lua_upvalueindex(i) (LUA_REGISTRYINDEX - (i)) + + +/* thread status */ +#define LUA_OK 0 +#define LUA_YIELD 1 +#define LUA_ERRRUN 2 +#define LUA_ERRSYNTAX 3 +#define LUA_ERRMEM 4 +#define LUA_ERRGCMM 5 +#define LUA_ERRERR 6 + + +typedef struct lua_State lua_State; + + +/* +** basic types +*/ +#define LUA_TNONE (-1) + +#define LUA_TNIL 0 +#define LUA_TBOOLEAN 1 +#define LUA_TLIGHTUSERDATA 2 +#define LUA_TNUMBER 3 +#define LUA_TSTRING 4 +#define LUA_TTABLE 5 +#define LUA_TFUNCTION 6 +#define LUA_TUSERDATA 7 +#define LUA_TTHREAD 8 + +#define LUA_NUMTAGS 9 + + + +/* minimum Lua stack available to a C function */ +#define LUA_MINSTACK 20 + + +/* predefined values in the registry */ +#define LUA_RIDX_MAINTHREAD 1 +#define LUA_RIDX_GLOBALS 2 +#define LUA_RIDX_LAST LUA_RIDX_GLOBALS + + +/* type of numbers in Lua */ +typedef LUA_NUMBER lua_Number; + + +/* type for integer functions */ +typedef LUA_INTEGER lua_Integer; + +/* unsigned integer type */ +typedef LUA_UNSIGNED lua_Unsigned; + +/* type for continuation-function contexts */ +typedef LUA_KCONTEXT lua_KContext; + + +/* +** Type for C functions registered with Lua +*/ +typedef int (*lua_CFunction) (lua_State *L); + +/* +** Type for continuation functions +*/ +typedef int (*lua_KFunction) (lua_State *L, int status, lua_KContext ctx); + + +/* +** Type for functions that read/write blocks when loading/dumping Lua chunks +*/ +typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz); + +typedef int (*lua_Writer) (lua_State *L, const void *p, size_t sz, void *ud); + + +/* +** Type for memory-allocation functions +*/ +typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize); + + + +/* +** generic extra include file +*/ +#if defined(LUA_USER_H) +#include LUA_USER_H +#endif + + +/* +** RCS ident string +*/ +extern const char lua_ident[]; + + +/* +** state manipulation +*/ +LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud); +LUA_API void (lua_close) (lua_State *L); +LUA_API lua_State *(lua_newthread) (lua_State *L); + +LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf); + + +LUA_API const lua_Number *(lua_version) (lua_State *L); + + +/* +** basic stack manipulation +*/ +LUA_API int (lua_absindex) (lua_State *L, int idx); +LUA_API int (lua_gettop) (lua_State *L); +LUA_API void (lua_settop) (lua_State *L, int idx); +LUA_API void (lua_pushvalue) (lua_State *L, int idx); +LUA_API void (lua_rotate) (lua_State *L, int idx, int n); +LUA_API void (lua_copy) (lua_State *L, int fromidx, int toidx); +LUA_API int (lua_checkstack) (lua_State *L, int n); + +LUA_API void (lua_xmove) (lua_State *from, lua_State *to, int n); + + +/* +** access functions (stack -> C) +*/ + +LUA_API int (lua_isnumber) (lua_State *L, int idx); +LUA_API int (lua_isstring) (lua_State *L, int idx); +LUA_API int (lua_iscfunction) (lua_State *L, int idx); +LUA_API int (lua_isinteger) (lua_State *L, int idx); +LUA_API int (lua_isuserdata) (lua_State *L, int idx); +LUA_API int (lua_type) (lua_State *L, int idx); +LUA_API const char *(lua_typename) (lua_State *L, int tp); + +LUA_API lua_Number (lua_tonumberx) (lua_State *L, int idx, int *isnum); +LUA_API lua_Integer (lua_tointegerx) (lua_State *L, int idx, int *isnum); +LUA_API int (lua_toboolean) (lua_State *L, int idx); +LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len); +LUA_API size_t (lua_rawlen) (lua_State *L, int idx); +LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx); +LUA_API void *(lua_touserdata) (lua_State *L, int idx); +LUA_API lua_State *(lua_tothread) (lua_State *L, int idx); +LUA_API const void *(lua_topointer) (lua_State *L, int idx); + + +/* +** Comparison and arithmetic functions +*/ + +#define LUA_OPADD 0 /* ORDER TM, ORDER OP */ +#define LUA_OPSUB 1 +#define LUA_OPMUL 2 +#define LUA_OPMOD 3 +#define LUA_OPPOW 4 +#define LUA_OPDIV 5 +#define LUA_OPIDIV 6 +#define LUA_OPBAND 7 +#define LUA_OPBOR 8 +#define LUA_OPBXOR 9 +#define LUA_OPSHL 10 +#define LUA_OPSHR 11 +#define LUA_OPUNM 12 +#define LUA_OPBNOT 13 + +LUA_API void (lua_arith) (lua_State *L, int op); + +#define LUA_OPEQ 0 +#define LUA_OPLT 1 +#define LUA_OPLE 2 + +LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2); +LUA_API int (lua_compare) (lua_State *L, int idx1, int idx2, int op); + + +/* +** push functions (C -> stack) +*/ +LUA_API void (lua_pushnil) (lua_State *L); +LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n); +LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n); +LUA_API const char *(lua_pushlstring) (lua_State *L, const char *s, size_t len); +LUA_API const char *(lua_pushstring) (lua_State *L, const char *s); +LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt, + va_list argp); +LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...); +LUA_API void (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n); +LUA_API void (lua_pushboolean) (lua_State *L, int b); +LUA_API void (lua_pushlightuserdata) (lua_State *L, void *p); +LUA_API int (lua_pushthread) (lua_State *L); + + +/* +** get functions (Lua -> stack) +*/ +LUA_API int (lua_getglobal) (lua_State *L, const char *name); +LUA_API int (lua_gettable) (lua_State *L, int idx); +LUA_API int (lua_getfield) (lua_State *L, int idx, const char *k); +LUA_API int (lua_geti) (lua_State *L, int idx, lua_Integer n); +LUA_API int (lua_rawget) (lua_State *L, int idx); +LUA_API int (lua_rawgeti) (lua_State *L, int idx, lua_Integer n); +LUA_API int (lua_rawgetp) (lua_State *L, int idx, const void *p); + +LUA_API void (lua_createtable) (lua_State *L, int narr, int nrec); +LUA_API void *(lua_newuserdata) (lua_State *L, size_t sz); +LUA_API int (lua_getmetatable) (lua_State *L, int objindex); +LUA_API int (lua_getuservalue) (lua_State *L, int idx); + + +/* +** set functions (stack -> Lua) +*/ +LUA_API void (lua_setglobal) (lua_State *L, const char *name); +LUA_API void (lua_settable) (lua_State *L, int idx); +LUA_API void (lua_setfield) (lua_State *L, int idx, const char *k); +LUA_API void (lua_seti) (lua_State *L, int idx, lua_Integer n); +LUA_API void (lua_rawset) (lua_State *L, int idx); +LUA_API void (lua_rawseti) (lua_State *L, int idx, lua_Integer n); +LUA_API void (lua_rawsetp) (lua_State *L, int idx, const void *p); +LUA_API int (lua_setmetatable) (lua_State *L, int objindex); +LUA_API void (lua_setuservalue) (lua_State *L, int idx); + + +/* +** 'load' and 'call' functions (load and run Lua code) +*/ +LUA_API void (lua_callk) (lua_State *L, int nargs, int nresults, + lua_KContext ctx, lua_KFunction k); +#define lua_call(L,n,r) lua_callk(L, (n), (r), 0, NULL) + +LUA_API int (lua_pcallk) (lua_State *L, int nargs, int nresults, int errfunc, + lua_KContext ctx, lua_KFunction k); +#define lua_pcall(L,n,r,f) lua_pcallk(L, (n), (r), (f), 0, NULL) + +LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt, + const char *chunkname, const char *mode); + +LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data, int strip); + + +/* +** coroutine functions +*/ +LUA_API int (lua_yieldk) (lua_State *L, int nresults, lua_KContext ctx, + lua_KFunction k); +LUA_API int (lua_resume) (lua_State *L, lua_State *from, int narg); +LUA_API int (lua_status) (lua_State *L); +LUA_API int (lua_isyieldable) (lua_State *L); + +#define lua_yield(L,n) lua_yieldk(L, (n), 0, NULL) + + +/* +** garbage-collection function and options +*/ + +#define LUA_GCSTOP 0 +#define LUA_GCRESTART 1 +#define LUA_GCCOLLECT 2 +#define LUA_GCCOUNT 3 +#define LUA_GCCOUNTB 4 +#define LUA_GCSTEP 5 +#define LUA_GCSETPAUSE 6 +#define LUA_GCSETSTEPMUL 7 +#define LUA_GCISRUNNING 9 + +LUA_API int (lua_gc) (lua_State *L, int what, int data); + + +/* +** miscellaneous functions +*/ + +LUA_API int (lua_error) (lua_State *L); + +LUA_API int (lua_next) (lua_State *L, int idx); + +LUA_API void (lua_concat) (lua_State *L, int n); +LUA_API void (lua_len) (lua_State *L, int idx); + +LUA_API size_t (lua_stringtonumber) (lua_State *L, const char *s); + +LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud); +LUA_API void (lua_setallocf) (lua_State *L, lua_Alloc f, void *ud); + + + +/* +** {============================================================== +** some useful macros +** =============================================================== +*/ + +#define lua_getextraspace(L) ((void *)((char *)(L) - LUA_EXTRASPACE)) + +#define lua_tonumber(L,i) lua_tonumberx(L,(i),NULL) +#define lua_tointeger(L,i) lua_tointegerx(L,(i),NULL) + +#define lua_pop(L,n) lua_settop(L, -(n)-1) + +#define lua_newtable(L) lua_createtable(L, 0, 0) + +#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n))) + +#define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0) + +#define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION) +#define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE) +#define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA) +#define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL) +#define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN) +#define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD) +#define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE) +#define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0) + +#define lua_pushliteral(L, s) lua_pushstring(L, "" s) + +#define lua_pushglobaltable(L) \ + ((void)lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS)) + +#define lua_tostring(L,i) lua_tolstring(L, (i), NULL) + + +#define lua_insert(L,idx) lua_rotate(L, (idx), 1) + +#define lua_remove(L,idx) (lua_rotate(L, (idx), -1), lua_pop(L, 1)) + +#define lua_replace(L,idx) (lua_copy(L, -1, (idx)), lua_pop(L, 1)) + +/* }============================================================== */ + + +/* +** {============================================================== +** compatibility macros for unsigned conversions +** =============================================================== +*/ +#if defined(LUA_COMPAT_APIINTCASTS) + +#define lua_pushunsigned(L,n) lua_pushinteger(L, (lua_Integer)(n)) +#define lua_tounsignedx(L,i,is) ((lua_Unsigned)lua_tointegerx(L,i,is)) +#define lua_tounsigned(L,i) lua_tounsignedx(L,(i),NULL) + +#endif +/* }============================================================== */ + +/* +** {====================================================================== +** Debug API +** ======================================================================= +*/ + + +/* +** Event codes +*/ +#define LUA_HOOKCALL 0 +#define LUA_HOOKRET 1 +#define LUA_HOOKLINE 2 +#define LUA_HOOKCOUNT 3 +#define LUA_HOOKTAILCALL 4 + + +/* +** Event masks +*/ +#define LUA_MASKCALL (1 << LUA_HOOKCALL) +#define LUA_MASKRET (1 << LUA_HOOKRET) +#define LUA_MASKLINE (1 << LUA_HOOKLINE) +#define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT) + +typedef struct lua_Debug lua_Debug; /* activation record */ + + +/* Functions to be called by the debugger in specific events */ +typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar); + + +LUA_API int (lua_getstack) (lua_State *L, int level, lua_Debug *ar); +LUA_API int (lua_getinfo) (lua_State *L, const char *what, lua_Debug *ar); +LUA_API const char *(lua_getlocal) (lua_State *L, const lua_Debug *ar, int n); +LUA_API const char *(lua_setlocal) (lua_State *L, const lua_Debug *ar, int n); +LUA_API const char *(lua_getupvalue) (lua_State *L, int funcindex, int n); +LUA_API const char *(lua_setupvalue) (lua_State *L, int funcindex, int n); + +LUA_API void *(lua_upvalueid) (lua_State *L, int fidx, int n); +LUA_API void (lua_upvaluejoin) (lua_State *L, int fidx1, int n1, + int fidx2, int n2); + +LUA_API void (lua_sethook) (lua_State *L, lua_Hook func, int mask, int count); +LUA_API lua_Hook (lua_gethook) (lua_State *L); +LUA_API int (lua_gethookmask) (lua_State *L); +LUA_API int (lua_gethookcount) (lua_State *L); + + +struct lua_Debug { + int event; + const char *name; /* (n) */ + const char *namewhat; /* (n) 'global', 'local', 'field', 'method' */ + const char *what; /* (S) 'Lua', 'C', 'main', 'tail' */ + const char *source; /* (S) */ + int currentline; /* (l) */ + int linedefined; /* (S) */ + int lastlinedefined; /* (S) */ + unsigned char nups; /* (u) number of upvalues */ + unsigned char nparams;/* (u) number of parameters */ + char isvararg; /* (u) */ + char istailcall; /* (t) */ + char short_src[LUA_IDSIZE]; /* (S) */ + /* private part */ + struct CallInfo *i_ci; /* active function */ +}; + +/* }====================================================================== */ + + +/****************************************************************************** +* Copyright (C) 1994-2020 Lua.org, PUC-Rio. +* +* Permission is hereby granted, free of charge, to any person obtaining +* a copy of this software and associated documentation files (the +* "Software"), to deal in the Software without restriction, including +* without limitation the rights to use, copy, modify, merge, publish, +* distribute, sublicense, and/or sell copies of the Software, and to +* permit persons to whom the Software is furnished to do so, subject to +* the following conditions: +* +* The above copyright notice and this permission notice shall be +* included in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ + + +#endif diff --git a/vendor/lua/5.3/include/lua.hpp b/vendor/lua/5.3/include/lua.hpp new file mode 100644 index 000000000..ec417f594 --- /dev/null +++ b/vendor/lua/5.3/include/lua.hpp @@ -0,0 +1,9 @@ +// lua.hpp +// Lua header files for C++ +// <> not supplied automatically because Lua also compiles as C++ + +extern "C" { +#include "lua.h" +#include "lualib.h" +#include "lauxlib.h" +} diff --git a/vendor/lua/5.3/include/luaconf.h b/vendor/lua/5.3/include/luaconf.h new file mode 100644 index 000000000..f95555689 --- /dev/null +++ b/vendor/lua/5.3/include/luaconf.h @@ -0,0 +1,792 @@ +/* +** $Id: luaconf.h,v 1.259.1.1 2017/04/19 17:29:57 roberto Exp $ +** Configuration file for Lua +** See Copyright Notice in lua.h +*/ + + +#ifndef luaconf_h +#define luaconf_h + +#include +#include + + +/* +** =================================================================== +** Search for "@@" to find all configurable definitions. +** =================================================================== +*/ + + +/* +** {==================================================================== +** System Configuration: macros to adapt (if needed) Lua to some +** particular platform, for instance compiling it with 32-bit numbers or +** restricting it to C89. +** ===================================================================== +*/ + +/* +@@ LUA_32BITS enables Lua with 32-bit integers and 32-bit floats. You +** can also define LUA_32BITS in the make file, but changing here you +** ensure that all software connected to Lua will be compiled with the +** same configuration. +*/ +/* #define LUA_32BITS */ + + +/* +@@ LUA_USE_C89 controls the use of non-ISO-C89 features. +** Define it if you want Lua to avoid the use of a few C99 features +** or Windows-specific features on Windows. +*/ +/* #define LUA_USE_C89 */ + + +/* +** By default, Lua on Windows use (some) specific Windows features +*/ +#if !defined(LUA_USE_C89) && defined(_WIN32) && !defined(_WIN32_WCE) +#define LUA_USE_WINDOWS /* enable goodies for regular Windows */ +#endif + + +#if defined(LUA_USE_WINDOWS) +#define LUA_DL_DLL /* enable support for DLL */ +#define LUA_USE_C89 /* broadly, Windows is C89 */ +#endif + + +#if defined(LUA_USE_LINUX) +#define LUA_USE_POSIX +#define LUA_USE_DLOPEN /* needs an extra library: -ldl */ +#define LUA_USE_READLINE /* needs some extra libraries */ +#endif + + +#if defined(LUA_USE_MACOSX) +#define LUA_USE_POSIX +#define LUA_USE_DLOPEN /* MacOS does not need -ldl */ +#define LUA_USE_READLINE /* needs an extra library: -lreadline */ +#endif + + +/* +@@ LUA_C89_NUMBERS ensures that Lua uses the largest types available for +** C89 ('long' and 'double'); Windows always has '__int64', so it does +** not need to use this case. +*/ +#if defined(LUA_USE_C89) && !defined(LUA_USE_WINDOWS) +#define LUA_C89_NUMBERS +#endif + + + +/* +@@ LUAI_BITSINT defines the (minimum) number of bits in an 'int'. +*/ +/* avoid undefined shifts */ +#if ((INT_MAX >> 15) >> 15) >= 1 +#define LUAI_BITSINT 32 +#else +/* 'int' always must have at least 16 bits */ +#define LUAI_BITSINT 16 +#endif + + +/* +@@ LUA_INT_TYPE defines the type for Lua integers. +@@ LUA_FLOAT_TYPE defines the type for Lua floats. +** Lua should work fine with any mix of these options (if supported +** by your C compiler). The usual configurations are 64-bit integers +** and 'double' (the default), 32-bit integers and 'float' (for +** restricted platforms), and 'long'/'double' (for C compilers not +** compliant with C99, which may not have support for 'long long'). +*/ + +/* predefined options for LUA_INT_TYPE */ +#define LUA_INT_INT 1 +#define LUA_INT_LONG 2 +#define LUA_INT_LONGLONG 3 + +/* predefined options for LUA_FLOAT_TYPE */ +#define LUA_FLOAT_FLOAT 1 +#define LUA_FLOAT_DOUBLE 2 +#define LUA_FLOAT_LONGDOUBLE 3 + +#if defined(LUA_32BITS) /* { */ +/* +** 32-bit integers and 'float' +*/ +#if LUAI_BITSINT >= 32 /* use 'int' if big enough */ +#define LUA_INT_TYPE LUA_INT_INT +#else /* otherwise use 'long' */ +#define LUA_INT_TYPE LUA_INT_LONG +#endif +#define LUA_FLOAT_TYPE LUA_FLOAT_FLOAT + +#elif defined(LUA_C89_NUMBERS) /* }{ */ +/* +** largest types available for C89 ('long' and 'double') +*/ +#define LUA_INT_TYPE LUA_INT_LONG +#define LUA_FLOAT_TYPE LUA_FLOAT_DOUBLE + +#endif /* } */ + + +/* +** default configuration for 64-bit Lua ('long long' and 'double') +*/ +#if !defined(LUA_INT_TYPE) +#define LUA_INT_TYPE LUA_INT_LONGLONG +#endif + +#if !defined(LUA_FLOAT_TYPE) +#define LUA_FLOAT_TYPE LUA_FLOAT_DOUBLE +#endif + +/* }================================================================== */ + + + + +/* +** {================================================================== +** Configuration for Paths. +** =================================================================== +*/ + +/* +** LUA_PATH_SEP is the character that separates templates in a path. +** LUA_PATH_MARK is the string that marks the substitution points in a +** template. +** LUA_EXEC_DIR in a Windows path is replaced by the executable's +** directory. +*/ +#define LUA_PATH_SEP ";" +#define LUA_PATH_MARK "?" +#define LUA_EXEC_DIR "!" + + +/* +@@ LUA_PATH_DEFAULT is the default path that Lua uses to look for +** Lua libraries. +@@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for +** C libraries. +** CHANGE them if your machine has a non-conventional directory +** hierarchy or if you want to install your libraries in +** non-conventional directories. +*/ +#define LUA_VDIR LUA_VERSION_MAJOR "." LUA_VERSION_MINOR +#if defined(_WIN32) /* { */ +/* +** In Windows, any exclamation mark ('!') in the path is replaced by the +** path of the directory of the executable file of the current process. +*/ +#define LUA_LDIR "!\\lua\\" +#define LUA_CDIR "!\\" +#define LUA_SHRDIR "!\\..\\share\\lua\\" LUA_VDIR "\\" +#define LUA_PATH_DEFAULT \ + LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \ + LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua;" \ + LUA_SHRDIR"?.lua;" LUA_SHRDIR"?\\init.lua;" \ + ".\\?.lua;" ".\\?\\init.lua" +#define LUA_CPATH_DEFAULT \ + LUA_CDIR"?.dll;" \ + LUA_CDIR"..\\lib\\lua\\" LUA_VDIR "\\?.dll;" \ + LUA_CDIR"loadall.dll;" ".\\?.dll;" \ + LUA_CDIR"?53.dll;" ".\\?53.dll" + +#else /* }{ */ + +#define LUA_ROOT "/usr/local/" +#define LUA_LDIR LUA_ROOT "share/lua/" LUA_VDIR "/" +#define LUA_CDIR LUA_ROOT "lib/lua/" LUA_VDIR "/" +#define LUA_PATH_DEFAULT \ + LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ + LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" \ + "./?.lua;" "./?/init.lua" +#define LUA_CPATH_DEFAULT \ + LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so;" \ + LUA_CDIR"lib?53.so;" "./lib?53.so" +#endif /* } */ + + +/* +@@ LUA_DIRSEP is the directory separator (for submodules). +** CHANGE it if your machine does not use "/" as the directory separator +** and is not Windows. (On Windows Lua automatically uses "\".) +*/ +#if defined(_WIN32) +#define LUA_DIRSEP "\\" +#else +#define LUA_DIRSEP "/" +#endif + +/* }================================================================== */ + + +/* +** {================================================================== +** Marks for exported symbols in the C code +** =================================================================== +*/ + +/* +@@ LUA_API is a mark for all core API functions. +@@ LUALIB_API is a mark for all auxiliary library functions. +@@ LUAMOD_API is a mark for all standard library opening functions. +** CHANGE them if you need to define those functions in some special way. +** For instance, if you want to create one Windows DLL with the core and +** the libraries, you may want to use the following definition (define +** LUA_BUILD_AS_DLL to get it). +*/ +#if defined(LUA_BUILD_AS_DLL) /* { */ + +#if defined(LUA_CORE) || defined(LUA_LIB) /* { */ +#define LUA_API __declspec(dllexport) +#else /* }{ */ +#define LUA_API __declspec(dllimport) +#endif /* } */ + +#else /* }{ */ + +#define LUA_API extern + +#endif /* } */ + + +/* more often than not the libs go together with the core */ +#define LUALIB_API LUA_API +#define LUAMOD_API LUALIB_API + + +/* +@@ LUAI_FUNC is a mark for all extern functions that are not to be +** exported to outside modules. +@@ LUAI_DDEF and LUAI_DDEC are marks for all extern (const) variables +** that are not to be exported to outside modules (LUAI_DDEF for +** definitions and LUAI_DDEC for declarations). +** CHANGE them if you need to mark them in some special way. Elf/gcc +** (versions 3.2 and later) mark them as "hidden" to optimize access +** when Lua is compiled as a shared library. Not all elf targets support +** this attribute. Unfortunately, gcc does not offer a way to check +** whether the target offers that support, and those without support +** give a warning about it. To avoid these warnings, change to the +** default definition. +*/ +#if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \ + defined(__ELF__) /* { */ +#define LUAI_FUNC __attribute__((visibility("hidden"))) extern +#else /* }{ */ +#define LUAI_FUNC extern +#endif /* } */ + +#define LUAI_DDEC LUAI_FUNC +#define LUAI_DDEF /* empty */ + +/* }================================================================== */ + + +/* +** {================================================================== +** Compatibility with previous versions +** =================================================================== +*/ + +/* +@@ LUA_COMPAT_5_2 controls other macros for compatibility with Lua 5.2. +@@ LUA_COMPAT_5_1 controls other macros for compatibility with Lua 5.1. +** You can define it to get all options, or change specific options +** to fit your specific needs. +*/ +#if defined(LUA_COMPAT_5_2) /* { */ + +/* +@@ LUA_COMPAT_MATHLIB controls the presence of several deprecated +** functions in the mathematical library. +*/ +#define LUA_COMPAT_MATHLIB + +/* +@@ LUA_COMPAT_BITLIB controls the presence of library 'bit32'. +*/ +#define LUA_COMPAT_BITLIB + +/* +@@ LUA_COMPAT_IPAIRS controls the effectiveness of the __ipairs metamethod. +*/ +#define LUA_COMPAT_IPAIRS + +/* +@@ LUA_COMPAT_APIINTCASTS controls the presence of macros for +** manipulating other integer types (lua_pushunsigned, lua_tounsigned, +** luaL_checkint, luaL_checklong, etc.) +*/ +#define LUA_COMPAT_APIINTCASTS + +#endif /* } */ + + +#if defined(LUA_COMPAT_5_1) /* { */ + +/* Incompatibilities from 5.2 -> 5.3 */ +#define LUA_COMPAT_MATHLIB +#define LUA_COMPAT_APIINTCASTS + +/* +@@ LUA_COMPAT_UNPACK controls the presence of global 'unpack'. +** You can replace it with 'table.unpack'. +*/ +#define LUA_COMPAT_UNPACK + +/* +@@ LUA_COMPAT_LOADERS controls the presence of table 'package.loaders'. +** You can replace it with 'package.searchers'. +*/ +#define LUA_COMPAT_LOADERS + +/* +@@ macro 'lua_cpcall' emulates deprecated function lua_cpcall. +** You can call your C function directly (with light C functions). +*/ +#define lua_cpcall(L,f,u) \ + (lua_pushcfunction(L, (f)), \ + lua_pushlightuserdata(L,(u)), \ + lua_pcall(L,1,0,0)) + + +/* +@@ LUA_COMPAT_LOG10 defines the function 'log10' in the math library. +** You can rewrite 'log10(x)' as 'log(x, 10)'. +*/ +#define LUA_COMPAT_LOG10 + +/* +@@ LUA_COMPAT_LOADSTRING defines the function 'loadstring' in the base +** library. You can rewrite 'loadstring(s)' as 'load(s)'. +*/ +#define LUA_COMPAT_LOADSTRING + +/* +@@ LUA_COMPAT_MAXN defines the function 'maxn' in the table library. +*/ +#define LUA_COMPAT_MAXN + +/* +@@ The following macros supply trivial compatibility for some +** changes in the API. The macros themselves document how to +** change your code to avoid using them. +*/ +#define lua_strlen(L,i) lua_rawlen(L, (i)) + +#define lua_objlen(L,i) lua_rawlen(L, (i)) + +#define lua_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ) +#define lua_lessthan(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPLT) + +/* +@@ LUA_COMPAT_MODULE controls compatibility with previous +** module functions 'module' (Lua) and 'luaL_register' (C). +*/ +#define LUA_COMPAT_MODULE + +#endif /* } */ + + +/* +@@ LUA_COMPAT_FLOATSTRING makes Lua format integral floats without a +@@ a float mark ('.0'). +** This macro is not on by default even in compatibility mode, +** because this is not really an incompatibility. +*/ +/* #define LUA_COMPAT_FLOATSTRING */ + +/* }================================================================== */ + + + +/* +** {================================================================== +** Configuration for Numbers. +** Change these definitions if no predefined LUA_FLOAT_* / LUA_INT_* +** satisfy your needs. +** =================================================================== +*/ + +/* +@@ LUA_NUMBER is the floating-point type used by Lua. +@@ LUAI_UACNUMBER is the result of a 'default argument promotion' +@@ over a floating number. +@@ l_mathlim(x) corrects limit name 'x' to the proper float type +** by prefixing it with one of FLT/DBL/LDBL. +@@ LUA_NUMBER_FRMLEN is the length modifier for writing floats. +@@ LUA_NUMBER_FMT is the format for writing floats. +@@ lua_number2str converts a float to a string. +@@ l_mathop allows the addition of an 'l' or 'f' to all math operations. +@@ l_floor takes the floor of a float. +@@ lua_str2number converts a decimal numeric string to a number. +*/ + + +/* The following definitions are good for most cases here */ + +#define l_floor(x) (l_mathop(floor)(x)) + +#define lua_number2str(s,sz,n) \ + l_sprintf((s), sz, LUA_NUMBER_FMT, (LUAI_UACNUMBER)(n)) + +/* +@@ lua_numbertointeger converts a float number to an integer, or +** returns 0 if float is not within the range of a lua_Integer. +** (The range comparisons are tricky because of rounding. The tests +** here assume a two-complement representation, where MININTEGER always +** has an exact representation as a float; MAXINTEGER may not have one, +** and therefore its conversion to float may have an ill-defined value.) +*/ +#define lua_numbertointeger(n,p) \ + ((n) >= (LUA_NUMBER)(LUA_MININTEGER) && \ + (n) < -(LUA_NUMBER)(LUA_MININTEGER) && \ + (*(p) = (LUA_INTEGER)(n), 1)) + + +/* now the variable definitions */ + +#if LUA_FLOAT_TYPE == LUA_FLOAT_FLOAT /* { single float */ + +#define LUA_NUMBER float + +#define l_mathlim(n) (FLT_##n) + +#define LUAI_UACNUMBER double + +#define LUA_NUMBER_FRMLEN "" +#define LUA_NUMBER_FMT "%.7g" + +#define l_mathop(op) op##f + +#define lua_str2number(s,p) strtof((s), (p)) + + +#elif LUA_FLOAT_TYPE == LUA_FLOAT_LONGDOUBLE /* }{ long double */ + +#define LUA_NUMBER long double + +#define l_mathlim(n) (LDBL_##n) + +#define LUAI_UACNUMBER long double + +#define LUA_NUMBER_FRMLEN "L" +#define LUA_NUMBER_FMT "%.19Lg" + +#define l_mathop(op) op##l + +#define lua_str2number(s,p) strtold((s), (p)) + +#elif LUA_FLOAT_TYPE == LUA_FLOAT_DOUBLE /* }{ double */ + +#define LUA_NUMBER double + +#define l_mathlim(n) (DBL_##n) + +#define LUAI_UACNUMBER double + +#define LUA_NUMBER_FRMLEN "" +#define LUA_NUMBER_FMT "%.14g" + +#define l_mathop(op) op + +#define lua_str2number(s,p) strtod((s), (p)) + +#else /* }{ */ + +#error "numeric float type not defined" + +#endif /* } */ + + + +/* +@@ LUA_INTEGER is the integer type used by Lua. +** +@@ LUA_UNSIGNED is the unsigned version of LUA_INTEGER. +** +@@ LUAI_UACINT is the result of a 'default argument promotion' +@@ over a lUA_INTEGER. +@@ LUA_INTEGER_FRMLEN is the length modifier for reading/writing integers. +@@ LUA_INTEGER_FMT is the format for writing integers. +@@ LUA_MAXINTEGER is the maximum value for a LUA_INTEGER. +@@ LUA_MININTEGER is the minimum value for a LUA_INTEGER. +@@ lua_integer2str converts an integer to a string. +*/ + + +/* The following definitions are good for most cases here */ + +#define LUA_INTEGER_FMT "%" LUA_INTEGER_FRMLEN "d" + +#define LUAI_UACINT LUA_INTEGER + +#define lua_integer2str(s,sz,n) \ + l_sprintf((s), sz, LUA_INTEGER_FMT, (LUAI_UACINT)(n)) + +/* +** use LUAI_UACINT here to avoid problems with promotions (which +** can turn a comparison between unsigneds into a signed comparison) +*/ +#define LUA_UNSIGNED unsigned LUAI_UACINT + + +/* now the variable definitions */ + +#if LUA_INT_TYPE == LUA_INT_INT /* { int */ + +#define LUA_INTEGER int +#define LUA_INTEGER_FRMLEN "" + +#define LUA_MAXINTEGER INT_MAX +#define LUA_MININTEGER INT_MIN + +#elif LUA_INT_TYPE == LUA_INT_LONG /* }{ long */ + +#define LUA_INTEGER long +#define LUA_INTEGER_FRMLEN "l" + +#define LUA_MAXINTEGER LONG_MAX +#define LUA_MININTEGER LONG_MIN + +#elif LUA_INT_TYPE == LUA_INT_LONGLONG /* }{ long long */ + +/* use presence of macro LLONG_MAX as proxy for C99 compliance */ +#if defined(LLONG_MAX) /* { */ +/* use ISO C99 stuff */ + +#define LUA_INTEGER long long +#define LUA_INTEGER_FRMLEN "ll" + +#define LUA_MAXINTEGER LLONG_MAX +#define LUA_MININTEGER LLONG_MIN + +#elif defined(LUA_USE_WINDOWS) /* }{ */ +/* in Windows, can use specific Windows types */ + +#define LUA_INTEGER __int64 +#define LUA_INTEGER_FRMLEN "I64" + +#define LUA_MAXINTEGER _I64_MAX +#define LUA_MININTEGER _I64_MIN + +#else /* }{ */ + +#error "Compiler does not support 'long long'. Use option '-DLUA_32BITS' \ + or '-DLUA_C89_NUMBERS' (see file 'luaconf.h' for details)" + +#endif /* } */ + +#else /* }{ */ + +#error "numeric integer type not defined" + +#endif /* } */ + +/* }================================================================== */ + + +/* +** {================================================================== +** Dependencies with C99 and other C details +** =================================================================== +*/ + +/* +@@ l_sprintf is equivalent to 'snprintf' or 'sprintf' in C89. +** (All uses in Lua have only one format item.) +*/ +#if !defined(LUA_USE_C89) +#define l_sprintf(s,sz,f,i) snprintf(s,sz,f,i) +#else +#define l_sprintf(s,sz,f,i) ((void)(sz), sprintf(s,f,i)) +#endif + + +/* +@@ lua_strx2number converts an hexadecimal numeric string to a number. +** In C99, 'strtod' does that conversion. Otherwise, you can +** leave 'lua_strx2number' undefined and Lua will provide its own +** implementation. +*/ +#if !defined(LUA_USE_C89) +#define lua_strx2number(s,p) lua_str2number(s,p) +#endif + + +/* +@@ lua_pointer2str converts a pointer to a readable string in a +** non-specified way. +*/ +#define lua_pointer2str(buff,sz,p) l_sprintf(buff,sz,"%p",p) + + +/* +@@ lua_number2strx converts a float to an hexadecimal numeric string. +** In C99, 'sprintf' (with format specifiers '%a'/'%A') does that. +** Otherwise, you can leave 'lua_number2strx' undefined and Lua will +** provide its own implementation. +*/ +#if !defined(LUA_USE_C89) +#define lua_number2strx(L,b,sz,f,n) \ + ((void)L, l_sprintf(b,sz,f,(LUAI_UACNUMBER)(n))) +#endif + + +/* +** 'strtof' and 'opf' variants for math functions are not valid in +** C89. Otherwise, the macro 'HUGE_VALF' is a good proxy for testing the +** availability of these variants. ('math.h' is already included in +** all files that use these macros.) +*/ +#if defined(LUA_USE_C89) || (defined(HUGE_VAL) && !defined(HUGE_VALF)) +#undef l_mathop /* variants not available */ +#undef lua_str2number +#define l_mathop(op) (lua_Number)op /* no variant */ +#define lua_str2number(s,p) ((lua_Number)strtod((s), (p))) +#endif + + +/* +@@ LUA_KCONTEXT is the type of the context ('ctx') for continuation +** functions. It must be a numerical type; Lua will use 'intptr_t' if +** available, otherwise it will use 'ptrdiff_t' (the nearest thing to +** 'intptr_t' in C89) +*/ +#define LUA_KCONTEXT ptrdiff_t + +#if !defined(LUA_USE_C89) && defined(__STDC_VERSION__) && \ + __STDC_VERSION__ >= 199901L +#include +#if defined(INTPTR_MAX) /* even in C99 this type is optional */ +#undef LUA_KCONTEXT +#define LUA_KCONTEXT intptr_t +#endif +#endif + + +/* +@@ lua_getlocaledecpoint gets the locale "radix character" (decimal point). +** Change that if you do not want to use C locales. (Code using this +** macro must include header 'locale.h'.) +*/ +#if !defined(lua_getlocaledecpoint) +#define lua_getlocaledecpoint() (localeconv()->decimal_point[0]) +#endif + +/* }================================================================== */ + + +/* +** {================================================================== +** Language Variations +** ===================================================================== +*/ + +/* +@@ LUA_NOCVTN2S/LUA_NOCVTS2N control how Lua performs some +** coercions. Define LUA_NOCVTN2S to turn off automatic coercion from +** numbers to strings. Define LUA_NOCVTS2N to turn off automatic +** coercion from strings to numbers. +*/ +/* #define LUA_NOCVTN2S */ +/* #define LUA_NOCVTS2N */ + + +/* +@@ LUA_USE_APICHECK turns on several consistency checks on the C API. +** Define it as a help when debugging C code. +*/ +#if defined(LUA_USE_APICHECK) +#include +#define luai_apicheck(l,e) assert(e) +#endif + +/* }================================================================== */ + + +/* +** {================================================================== +** Macros that affect the API and must be stable (that is, must be the +** same when you compile Lua and when you compile code that links to +** Lua). You probably do not want/need to change them. +** ===================================================================== +*/ + +/* +@@ LUAI_MAXSTACK limits the size of the Lua stack. +** CHANGE it if you need a different limit. This limit is arbitrary; +** its only purpose is to stop Lua from consuming unlimited stack +** space (and to reserve some numbers for pseudo-indices). +*/ +#if LUAI_BITSINT >= 32 +#define LUAI_MAXSTACK 1000000 +#else +#define LUAI_MAXSTACK 15000 +#endif + + +/* +@@ LUA_EXTRASPACE defines the size of a raw memory area associated with +** a Lua state with very fast access. +** CHANGE it if you need a different size. +*/ +#define LUA_EXTRASPACE (sizeof(void *)) + + +/* +@@ LUA_IDSIZE gives the maximum size for the description of the source +@@ of a function in debug information. +** CHANGE it if you want a different size. +*/ +#define LUA_IDSIZE 60 + + +/* +@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. +** CHANGE it if it uses too much C-stack space. (For long double, +** 'string.format("%.99f", -1e4932)' needs 5034 bytes, so a +** smaller buffer would force a memory allocation for each call to +** 'string.format'.) +*/ +#if LUA_FLOAT_TYPE == LUA_FLOAT_LONGDOUBLE +#define LUAL_BUFFERSIZE 8192 +#else +#define LUAL_BUFFERSIZE ((int)(0x80 * sizeof(void*) * sizeof(lua_Integer))) +#endif + +/* }================================================================== */ + + +/* +@@ LUA_QL describes how error messages quote program elements. +** Lua does not use these macros anymore; they are here for +** compatibility only. +*/ +#define LUA_QL(x) "'" x "'" +#define LUA_QS LUA_QL("%s") + + + + +/* =================================================================== */ + +/* +** Local configuration. You can use this space to add your redefinitions +** without modifying the main part of the file. +*/ + + + + + +#endif + diff --git a/vendor/lua/5.3/include/lualib.h b/vendor/lua/5.3/include/lualib.h new file mode 100644 index 000000000..f5304aa0d --- /dev/null +++ b/vendor/lua/5.3/include/lualib.h @@ -0,0 +1,61 @@ +/* +** $Id: lualib.h,v 1.45.1.1 2017/04/19 17:20:42 roberto Exp $ +** Lua standard libraries +** See Copyright Notice in lua.h +*/ + + +#ifndef lualib_h +#define lualib_h + +#include "lua.h" + + +/* version suffix for environment variable names */ +#define LUA_VERSUFFIX "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR + + +LUAMOD_API int (luaopen_base) (lua_State *L); + +#define LUA_COLIBNAME "coroutine" +LUAMOD_API int (luaopen_coroutine) (lua_State *L); + +#define LUA_TABLIBNAME "table" +LUAMOD_API int (luaopen_table) (lua_State *L); + +#define LUA_IOLIBNAME "io" +LUAMOD_API int (luaopen_io) (lua_State *L); + +#define LUA_OSLIBNAME "os" +LUAMOD_API int (luaopen_os) (lua_State *L); + +#define LUA_STRLIBNAME "string" +LUAMOD_API int (luaopen_string) (lua_State *L); + +#define LUA_UTF8LIBNAME "utf8" +LUAMOD_API int (luaopen_utf8) (lua_State *L); + +#define LUA_BITLIBNAME "bit32" +LUAMOD_API int (luaopen_bit32) (lua_State *L); + +#define LUA_MATHLIBNAME "math" +LUAMOD_API int (luaopen_math) (lua_State *L); + +#define LUA_DBLIBNAME "debug" +LUAMOD_API int (luaopen_debug) (lua_State *L); + +#define LUA_LOADLIBNAME "package" +LUAMOD_API int (luaopen_package) (lua_State *L); + + +/* open all previous libraries */ +LUALIB_API void (luaL_openlibs) (lua_State *L); + + + +#if !defined(lua_assert) +#define lua_assert(x) ((void)0) +#endif + + +#endif diff --git a/vendor/lua/5.3/linux/liblua53.a b/vendor/lua/5.3/linux/liblua53.a new file mode 100644 index 000000000..67b462b1b Binary files /dev/null and b/vendor/lua/5.3/linux/liblua53.a differ diff --git a/vendor/lua/5.3/linux/liblua53.so b/vendor/lua/5.3/linux/liblua53.so new file mode 100644 index 000000000..83c5fbd68 Binary files /dev/null and b/vendor/lua/5.3/linux/liblua53.so differ diff --git a/vendor/lua/5.3/lua.odin b/vendor/lua/5.3/lua.odin new file mode 100644 index 000000000..db7419d15 --- /dev/null +++ b/vendor/lua/5.3/lua.odin @@ -0,0 +1,759 @@ +package lua_5_3 + +import "core:intrinsics" +import "core:builtin" + +import c "core:c/libc" + +#assert(size_of(c.int) == size_of(b32)) + +when ODIN_OS == .Windows { + foreign import lib "windows/lua53dll.lib" +} else when ODIN_OS == .Linux { + foreign import lib "linux/liblua53.a" +} else { + foreign import lib "system:liblua53.a" +} + +VERSION_MAJOR :: "5" +VERSION_MINOR :: "3" +VERSION_NUM :: 503 +VERSION_RELEASE :: "6" + +VERSION :: "Lua " + VERSION_MAJOR + "." + VERSION_MINOR +RELEASE :: VERSION + "." + VERSION_RELEASE +COPYRIGHT :: RELEASE + " Copyright (C) 1994-2020 Lua.org, PUC-Rio" +AUTHORS :: "R. Ierusalimschy, L. H. de Figueiredo, W. Celes" + + +/* mark for precompiled code ('Lua') */ +SIGNATURE :: "\x1bLua" + +/* option for multiple returns in 'lua_pcall' and 'lua_call' */ +MULTRET :: -1 + +REGISTRYINDEX :: -MAXSTACK - 1000 + + +/* +@@ LUAI_MAXSTACK limits the size of the Lua stack. +** CHANGE it if you need a different limit. This limit is arbitrary; +** its only purpose is to stop Lua from consuming unlimited stack +** space (and to reserve some numbers for pseudo-indices). +** (It must fit into max(size_t)/32.) +*/ +MAXSTACK :: 1000000 + + +/* +@@ LUA_EXTRASPACE defines the size of a raw memory area associated with +** a Lua state with very fast access. +** CHANGE it if you need a different size. +*/ +EXTRASPACE :: size_of(rawptr) + + + +/* +@@ LUA_IDSIZE gives the maximum size for the description of the source +@@ of a function in debug information. +** CHANGE it if you want a different size. +*/ +IDSIZE :: 60 + + +/* +@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. +*/ +L_BUFFERSIZE :: c.int(16 * size_of(rawptr) * size_of(Number)) + + +MAXALIGNVAL :: max(align_of(Number), align_of(f64), align_of(rawptr), align_of(Integer), align_of(c.long)) + + +Status :: enum c.int { + OK = 0, + YIELD = 1, + ERRRUN = 2, + ERRSYNTAX = 3, + ERRMEM = 4, + ERRERR = 5, + ERRGCMM = 6, + ERRFILE = 7, +} + +/* thread status */ +OK :: Status.OK +YIELD :: Status.YIELD +ERRRUN :: Status.ERRRUN +ERRSYNTAX :: Status.ERRSYNTAX +ERRMEM :: Status.ERRMEM +ERRERR :: Status.ERRERR +ERRFILE :: Status.ERRFILE + +/* +** basic types +*/ + + +Type :: enum c.int { + NONE = -1, + + NIL = 0, + BOOLEAN = 1, + LIGHTUSERDATA = 2, + NUMBER = 3, + STRING = 4, + TABLE = 5, + FUNCTION = 6, + USERDATA = 7, + THREAD = 8, +} + +TNONE :: Type.NONE +TNIL :: Type.NIL +TBOOLEAN :: Type.BOOLEAN +TLIGHTUSERDATA :: Type.LIGHTUSERDATA +TNUMBER :: Type.NUMBER +TSTRING :: Type.STRING +TTABLE :: Type.TABLE +TFUNCTION :: Type.FUNCTION +TUSERDATA :: Type.USERDATA +TTHREAD :: Type.THREAD +NUMTYPES :: 9 + + + +ArithOp :: enum c.int { + ADD = 0, /* ORDER TM, ORDER OP */ + SUB = 1, + MUL = 2, + MOD = 3, + POW = 4, + DIV = 5, + IDIV = 6, + BAND = 7, + BOR = 8, + BXOR = 9, + SHL = 10, + SHR = 11, + UNM = 12, + BNOT = 13, +} + +CompareOp :: enum c.int { + EQ = 0, + LT = 1, + LE = 2, +} + +OPADD :: ArithOp.ADD +OPSUB :: ArithOp.SUB +OPMUL :: ArithOp.MUL +OPMOD :: ArithOp.MOD +OPPOW :: ArithOp.POW +OPDIV :: ArithOp.DIV +OPIDIV :: ArithOp.IDIV +OPBAND :: ArithOp.BAND +OPBOR :: ArithOp.BOR +OPBXOR :: ArithOp.BXOR +OPSHL :: ArithOp.SHL +OPSHR :: ArithOp.SHR +OPUNM :: ArithOp.UNM +OPBNOT :: ArithOp.BNOT + +OPEQ :: CompareOp.EQ +OPLT :: CompareOp.LT +OPLE :: CompareOp.LE + + +/* minimum Lua stack available to a C function */ +MINSTACK :: 20 + + +/* predefined values in the registry */ +RIDX_MAINTHREAD :: 1 +RIDX_GLOBALS :: 2 +RIDX_LAST :: RIDX_GLOBALS + + +/* type of numbers in Lua */ +Number :: distinct (f32 when size_of(uintptr) == 4 else f64) + + +/* type for integer functions */ +Integer :: distinct (i32 when size_of(uintptr) == 4 else i64) + +/* unsigned integer type */ +Unsigned :: distinct (u32 when size_of(uintptr) == 4 else u64) + +/* type for continuation-function contexts */ +KContext :: distinct int + + +/* +** Type for C functions registered with Lua +*/ +CFunction :: #type proc "c" (L: ^State) -> c.int + +/* +** Type for continuation functions +*/ +KFunction :: #type proc "c" (L: ^State, status: c.int, ctx: KContext) -> c.int + + +/* +** Type for functions that read/write blocks when loading/dumping Lua chunks +*/ +Reader :: #type proc "c" (L: ^State, ud: rawptr, sz: ^c.size_t) -> cstring +Writer :: #type proc "c" (L: ^State, p: rawptr, sz: ^c.size_t, ud: rawptr) -> c.int + + +/* +** Type for memory-allocation functions +*/ +Alloc :: #type proc "c" (ud: rawptr, ptr: rawptr, osize, nsize: c.size_t) -> rawptr + + +GCWhat :: enum c.int { + STOP = 0, + RESTART = 1, + COLLECT = 2, + COUNT = 3, + COUNTB = 4, + STEP = 5, + SETPAUSE = 6, + SETSTEPMUL = 7, + ISRUNNING = 9, +} +GCSTOP :: GCWhat.STOP +GCRESTART :: GCWhat.RESTART +GCCOLLECT :: GCWhat.COLLECT +GCCOUNT :: GCWhat.COUNT +GCCOUNTB :: GCWhat.COUNTB +GCSTEP :: GCWhat.STEP +GCSETPAUSE :: GCWhat.SETPAUSE +GCSETSTEPMUL :: GCWhat.SETSTEPMUL +GCISRUNNING :: GCWhat.ISRUNNING + + + +/* +** Event codes +*/ + +HookEvent :: enum c.int { + CALL = 0, + RET = 1, + LINE = 2, + COUNT = 3, + TAILCALL = 4, +} +HOOKCALL :: HookEvent.CALL +HOOKRET :: HookEvent.RET +HOOKLINE :: HookEvent.LINE +HOOKCOUNT :: HookEvent.COUNT +HOOKTAILCALL :: HookEvent.TAILCALL + + +/* +** Event masks +*/ +HookMask :: distinct bit_set[HookEvent; c.int] +MASKCALL :: HookMask{.CALL} +MASKRET :: HookMask{.RET} +MASKLINE :: HookMask{.LINE} +MASKCOUNT :: HookMask{.COUNT} + +/* activation record */ +Debug :: struct { + event: HookEvent, + name: cstring, /* (n) */ + namewhat: cstring, /* (n) 'global', 'local', 'field', 'method' */ + what: cstring, /* (S) 'Lua', 'C', 'main', 'tail' */ + source: cstring, /* (S) */ + currentline: c.int, /* (l) */ + linedefined: c.int, /* (S) */ + lastlinedefined: c.int, /* (S) */ + nups: u8, /* (u) number of upvalues */ + nparams: u8, /* (u) number of parameters */ + isvararg: bool, /* (u) */ + istailcall: bool, /* (t) */ + short_src: [IDSIZE]u8 `fmt:"s"`, /* (S) */ + /* private part */ + i_ci: rawptr, /* active function */ +} + + +/* Functions to be called by the debugger in specific events */ +Hook :: #type proc "c" (L: ^State, ar: ^Debug) + + +State :: struct {} // opaque data type + + +@(link_prefix="lua_") +@(default_calling_convention="c") +foreign lib { + /* + ** RCS ident string + */ + + ident: [^]u8 // TODO(bill): is this correct? + + + /* + ** state manipulation + */ + + newstate :: proc(f: Alloc, ud: rawptr) -> ^State --- + close :: proc(L: ^State) --- + newthread :: proc(L: ^State) -> ^State --- + + atpanic :: proc(L: ^State, panicf: CFunction) -> CFunction --- + + version :: proc(L: ^State) -> ^Number --- + + + /* + ** basic stack manipulation + */ + + absindex :: proc (L: ^State, idx: c.int) -> c.int --- + gettop :: proc (L: ^State) -> c.int --- + settop :: proc (L: ^State, idx: c.int) --- + pushvalue :: proc (L: ^State, idx: c.int) --- + rotate :: proc (L: ^State, idx: c.int, n: c.int) --- + copy :: proc (L: ^State, fromidx, toidx: c.int) --- + checkstack :: proc (L: ^State, n: c.int) -> c.int --- + + xmove :: proc(from, to: ^State, n: c.int) --- + + + /* + ** access functions (stack -> C) + */ + + isnumber :: proc(L: ^State, idx: c.int) -> b32 --- + isstring :: proc(L: ^State, idx: c.int) -> b32 --- + iscfunction :: proc(L: ^State, idx: c.int) -> b32 --- + isinteger :: proc(L: ^State, idx: c.int) -> b32 --- + isuserdata :: proc(L: ^State, idx: c.int) -> b32 --- + type :: proc(L: ^State, idx: c.int) -> Type --- + typename :: proc(L: ^State, tp: Type) -> cstring --- + + @(link_name="lua_tonumberx") + tonumber :: proc(L: ^State, idx: c.int, isnum: ^b32 = nil) -> Number --- + @(link_name="lua_tointegerx") + tointeger :: proc(L: ^State, idx: c.int, isnum: ^b32 = nil) -> Integer --- + toboolean :: proc(L: ^State, idx: c.int) -> b32 --- + tolstring :: proc(L: ^State, idx: c.int, len: ^c.size_t) -> cstring --- + rawlen :: proc(L: ^State, idx: c.int) -> c.size_t --- + tocfunction :: proc(L: ^State, idx: c.int) -> CFunction --- + touserdata :: proc(L: ^State, idx: c.int) -> rawptr --- + tothread :: proc(L: ^State, idx: c.int) -> ^State --- + topointer :: proc(L: ^State, idx: c.int) -> rawptr --- + + /* + ** Comparison and arithmetic functions + */ + + arith :: proc(L: ^State, op: ArithOp) --- + rawequal :: proc(L: ^State, idx1, idx2: c.int) -> b32 --- + compare :: proc(L: ^State, idx1, idx2: c.int, op: CompareOp) -> b32 --- + + /* + ** push functions (C -> stack) + */ + + pushnil :: proc(L: ^State) --- + pushnumber :: proc(L: ^State, n: Number) --- + pushinteger :: proc(L: ^State, n: Integer) --- + pushlstring :: proc(L: ^State, s: cstring, len: c.size_t) -> cstring --- + pushstring :: proc(L: ^State, s: cstring) -> cstring --- + pushvfstring :: proc(L: ^State, fmt: cstring, argp: c.va_list) -> cstring --- + pushfstring :: proc(L: ^State, fmt: cstring, #c_vararg args: ..any) -> cstring --- + pushcclosure :: proc(L: ^State, fn: CFunction, n: c.int) --- + pushboolean :: proc(L: ^State, b: b32) --- + pushlightuserdata :: proc(L: ^State, p: rawptr) --- + pushthread :: proc(L: ^State) -> Status --- + + /* + ** get functions (Lua -> stack) + */ + + getglobal :: proc(L: ^State, name: cstring) -> c.int --- + gettable :: proc(L: ^State, idx: c.int) -> c.int --- + getfield :: proc(L: ^State, idx: c.int, k: cstring) -> c.int --- + geti :: proc(L: ^State, idx: c.int, n: Integer) -> c.int --- + rawget :: proc(L: ^State, idx: c.int) -> c.int --- + rawgeti :: proc(L: ^State, idx: c.int, n: Integer) -> c.int --- + rawgetp :: proc(L: ^State, idx: c.int, p: rawptr) -> c.int --- + + createtable :: proc(L: ^State, narr, nrec: c.int) --- + newuserdata :: proc(L: ^State, sz: c.size_t) -> rawptr --- + getmetatable :: proc(L: ^State, objindex: c.int) -> c.int --- + getuservalue :: proc(L: ^State, idx: c.int) -> c.int --- + + + /* + ** set functions (stack -> Lua) + */ + + setglobal :: proc(L: ^State, name: cstring) --- + settable :: proc(L: ^State, idx: c.int) --- + setfield :: proc(L: ^State, idx: c.int, k: cstring) --- + seti :: proc(L: ^State, idx: c.int, n: Integer) --- + rawset :: proc(L: ^State, idx: c.int) --- + rawseti :: proc(L: ^State, idx: c.int, n: Integer) --- + rawsetp :: proc(L: ^State, idx: c.int, p: rawptr) --- + setmetatable :: proc(L: ^State, objindex: c.int) -> c.int --- + setuservalue :: proc(L: ^State, idx: c.int) -> c.int --- + + + /* + ** 'load' and 'call' functions (load and run Lua code) + */ + + @(link_name="lua_callk") + call :: proc(L: ^State, nargs, nresults: c.int, + ctx: KContext = 0, k: KFunction = nil) --- + + @(link_name="lua_pcallk") + pcall :: proc(L: ^State, nargs, nresults: c.int, errfunc: c.int, + ctx: KContext = 0, k: KFunction = nil) -> c.int --- + + load :: proc(L: ^State, reader: Reader, dt: rawptr, + chunkname, mode: cstring) -> Status --- + + dump :: proc(L: ^State, writer: Writer, data: rawptr, strip: b32) -> Status --- + + + /* + ** coroutine functions + */ + + @(link_name="lua_yieldk") + yield :: proc(L: ^State, nresults: c.int, ctx: KContext = 0, k: KFunction = nil) -> Status --- + resume :: proc(L: ^State, from: ^State, narg: c.int) -> Status --- + status :: proc(L: ^State) -> Status --- + isyieldable :: proc(L: ^State) -> b32 --- + + + /* + ** garbage-collection function and options + */ + + + + gc :: proc(L: ^State, what: GCWhat, data: c.int) -> c.int --- + + + /* + ** miscellaneous functions + */ + + error :: proc(L: ^State) -> Status --- + + next :: proc(L: ^State, idx: c.int) -> c.int --- + + concat :: proc(L: ^State, n: c.int) --- + len :: proc(L: ^State, idx: c.int) --- + + stringtonumber :: proc(L: ^State, s: cstring) -> c.size_t --- + + getallocf :: proc(L: State, ud: ^rawptr) -> Alloc --- + setallocf :: proc(L: ^State, f: Alloc, ud: rawptr) --- + + /* + ** {====================================================================== + ** Debug API + ** ======================================================================= + */ + + getstack :: proc(L: ^State, level: c.int, ar: ^Debug) -> c.int --- + getinfo :: proc(L: ^State, what: cstring, ar: ^Debug) -> c.int --- + getlocal :: proc(L: ^State, ar: ^Debug, n: c.int) -> cstring --- + setlocal :: proc(L: ^State, ar: ^Debug, n: c.int) -> cstring --- + getupvalue :: proc(L: ^State, funcindex: c.int, n: c.int) -> cstring --- + setupvalue :: proc(L: ^State, funcindex: c.int, n: c.int) -> cstring --- + + upvalueid :: proc(L: ^State, fidx, n: c.int) -> rawptr --- + upvaluejoin :: proc(L: ^State, fidx1, n1, fidx2, n2: c.int) --- + + sethook :: proc(L: ^State, func: Hook, mask: HookMask, count: c.int) --- + gethook :: proc(L: ^State) -> Hook --- + gethookmask :: proc(L: ^State) -> HookMask --- + gethookcount :: proc(L: ^State) -> c.int --- + + /* }============================================================== */ +} + + + +/* version suffix for environment variable names */ +VERSUFFIX :: "_" + VERSION_MAJOR + "_" + VERSION_MINOR + +COLIBNAME :: "coroutine" +TABLIBNAME :: "table" +IOLIBNAME :: "io" +OSLIBNAME :: "os" +STRLIBNAME :: "string" +UTF8LIBNAME :: "utf8" +BITLIBNAME :: "bit32" +MATHLIBNAME :: "math" +DBLIBNAME :: "debug" +LOADLIBNAME :: "package" + +@(link_prefix="lua") +@(default_calling_convention="c") +foreign lib { + open_base :: proc(L: ^State) -> c.int --- + open_coroutine :: proc(L: ^State) -> c.int --- + open_table :: proc(L: ^State) -> c.int --- + open_io :: proc(L: ^State) -> c.int --- + open_os :: proc(L: ^State) -> c.int --- + open_string :: proc(L: ^State) -> c.int --- + open_utf8 :: proc(L: ^State) -> c.int --- + open_bit32 :: proc(L: ^State) -> c.int --- + open_math :: proc(L: ^State) -> c.int --- + open_debug :: proc(L: ^State) -> c.int --- + open_package :: proc(L: ^State) -> c.int --- + + /* open all previous libraries */ + + L_openlibs :: proc(L: ^State) --- +} + + + +GNAME :: "_G" + +/* key, in the registry, for table of loaded modules */ +LOADED_TABLE :: "_LOADED" + + +/* key, in the registry, for table of preloaded loaders */ +PRELOAD_TABLE :: "_PRELOAD" + +L_Reg :: struct { + name: cstring, + func: CFunction, +} + +L_NUMSIZES :: size_of(Integer)*16 + size_of(Number) + + +/* predefined references */ +NOREF :: -2 +REFNIL :: -1 + + +@(link_prefix="lua") +@(default_calling_convention="c") +foreign lib { + @(link_name="luaL_checkversion_") + L_checkversion :: proc(L: ^State, ver: Number = VERSION_NUM, sz: c.size_t = L_NUMSIZES) --- + + + L_getmetafield :: proc(L: ^State, obj: c.int, e: cstring) -> c.int --- + L_callmeta :: proc(L: ^State, obj: c.int, e: cstring) -> c.int --- + @(link_name="luaL_tolstring") + L_tostring :: proc(L: ^State, idx: c.int, len: ^c.size_t = nil) -> cstring --- + L_argerror :: proc(L: ^State, arg: c.int, extramsg: cstring) -> c.int --- + @(link_name="luaL_checklstring") + L_checkstring :: proc(L: ^State, arg: c.int, l: ^c.size_t = nil) -> cstring --- + @(link_name="luaL_optlstring") + L_optstring :: proc(L: ^State, arg: c.int, def: cstring, l: ^c.size_t = nil) -> cstring --- + L_checknumber :: proc(L: ^State, arg: c.int) -> Number --- + L_optnumber :: proc(L: ^State, arg: c.int, def: Number) -> Number --- + + L_checkinteger :: proc(L: ^State, arg: c.int) -> Integer --- + L_optinteger :: proc(L: ^State, arg: c.int, def: Integer) -> Integer --- + + L_checkstack :: proc(L: ^State, sz: c.int, msg: cstring) --- + L_checktype :: proc(L: ^State, arg: c.int, t: c.int) --- + L_checkany :: proc(L: ^State, arg: c.int) --- + + L_newmetatable :: proc(L: ^State, tname: cstring) -> c.int --- + L_setmetatable :: proc(L: ^State, tname: cstring) --- + L_testudata :: proc(L: ^State, ud: c.int, tname: cstring) -> rawptr --- + L_checkudata :: proc(L: ^State, ud: c.int, tname: cstring) -> rawptr --- + + L_where :: proc(L: ^State, lvl: c.int) --- + L_error :: proc(L: ^State, fmt: cstring, #c_vararg args: ..any) -> Status --- + + L_checkoption :: proc(L: ^State, arg: c.int, def: cstring, lst: [^]cstring) -> c.int --- + + L_fileresult :: proc(L: ^State, stat: c.int, fname: cstring) -> c.int --- + L_execresult :: proc(L: ^State, stat: c.int) -> c.int --- + + + L_ref :: proc(L: ^State, t: c.int) -> c.int --- + L_unref :: proc(L: ^State, t: c.int, ref: c.int) --- + + @(link_name="luaL_loadfilex") + L_loadfile :: proc (L: ^State, filename: cstring, mode: cstring = nil) -> Status --- + + @(link_name="luaL_loadbufferx") + L_loadbuffer :: proc(L: ^State, buff: [^]byte, sz: c.size_t, name: cstring, mode: cstring = nil) -> Status --- + L_loadstring :: proc(L: ^State, s: cstring) -> Status --- + + L_newstate :: proc() -> ^State --- + + L_len :: proc(L: ^State, idx: c.int) -> Integer --- + + L_gsub :: proc(L: ^State, s, p, r: cstring) -> cstring --- + + L_setfuncs :: proc(L: ^State, l: [^]L_Reg, nup: c.int) --- + + L_getsubtable :: proc(L: ^State, idx: c.int, fname: cstring) -> c.int --- + + L_traceback :: proc(L: ^State, L1: ^State, msg: cstring, level: c.int) --- + + L_requiref :: proc(L: ^State, modname: cstring, openf: CFunction, glb: c.int) --- + +} +/* +** {====================================================== +** Generic Buffer manipulation +** ======================================================= +*/ + + +L_Buffer :: struct { + b: [^]byte, /* buffer address */ + size: c.size_t, /* buffer size */ + n: c.size_t, /* number of characters in buffer */ + L: ^State, + initb: [L_BUFFERSIZE]byte, /* initial buffer */ +} + +L_addchar :: #force_inline proc "c" (B: ^L_Buffer, c: byte) { + if B.n < B.size { + L_prepbuffsize(B, 1) + } + B.b[B.n] = c + B.n += 1 +} + +L_addsize :: #force_inline proc "c" (B: ^L_Buffer, s: c.size_t) -> c.size_t { + B.n += s + return B.n +} + +L_prepbuffer :: #force_inline proc "c" (B: ^L_Buffer) -> [^]byte { + return L_prepbuffsize(B, c.size_t(L_BUFFERSIZE)) +} + + +@(link_prefix="lua") +@(default_calling_convention="c") +foreign lib { + L_buffinit :: proc(L: ^State, B: ^L_Buffer) --- + L_prepbuffsize :: proc(B: ^L_Buffer, sz: c.size_t) -> [^]byte --- + L_addlstring :: proc(B: ^L_Buffer, s: cstring, l: c.size_t) --- + L_addstring :: proc(B: ^L_Buffer, s: cstring) --- + L_addvalue :: proc(B: ^L_Buffer) --- + L_pushresult :: proc(B: ^L_Buffer) --- + L_pushresultsize :: proc(B: ^L_Buffer, sz: c.size_t) --- + L_buffinitsize :: proc(L: ^State, B: ^L_Buffer, sz: c.size_t) -> [^]byte --- +} + + +/* }====================================================== */ + + + + +/* +** {============================================================== +** some useful macros +** =============================================================== +*/ + +getextraspace :: #force_inline proc "c" (L: ^State) -> rawptr { + return rawptr(([^]byte)(L)[-EXTRASPACE:]) +} +pop :: #force_inline proc "c" (L: ^State, n: c.int) { + settop(L, -n-1) +} +newtable :: #force_inline proc "c" (L: ^State) { + createtable(L, 0, 0) +} +register :: #force_inline proc "c" (L: ^State, n: cstring, f: CFunction) { + pushcfunction(L, f) + setglobal(L, n) +} + +pushcfunction :: #force_inline proc "c" (L: ^State, f: CFunction) { + pushcclosure(L, f, 0) +} + + +isfunction :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .FUNCTION } +istable :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .TABLE } +islightuserdata :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .LIGHTUSERDATA } +isnil :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .NIL } +isboolean :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .BOOLEAN } +isthread :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .THREAD } +isnone :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .NONE } +isnoneornil :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) <= .NIL } + + +pushliteral :: pushstring +pushglobaltable :: #force_inline proc "c" (L: ^State) { + rawgeti(L, REGISTRYINDEX, RIDX_GLOBALS) +} +tostring :: #force_inline proc "c" (L: ^State, i: c.int) -> cstring { + return tolstring(L, i, nil) +} +insert :: #force_inline proc "c" (L: ^State, idx: c.int) { + rotate(L, idx, 1) +} +remove :: #force_inline proc "c" (L: ^State, idx: c.int) { + rotate(L, idx, -1) + pop(L, 1) +} +replace :: #force_inline proc "c" (L: ^State, idx: c.int) { + copy(L, -1, idx) + pop(L, 1) +} + +L_newlibtable :: #force_inline proc "c" (L: ^State, l: []L_Reg) { + createtable(L, 0, c.int(builtin.len(l) - 1)) +} + +L_newlib :: proc(L: ^State, l: []L_Reg) { + L_checkversion(L) + L_newlibtable(L, l) + L_setfuncs(L, raw_data(l), 0) +} + +L_argcheck :: #force_inline proc "c" (L: ^State, cond: bool, arg: c.int, extramsg: cstring) { + if cond { + L_argerror(L, arg, extramsg) + } +} + +L_typename :: #force_inline proc "c" (L: ^State, i: c.int) -> cstring { + return typename(L, type(L, i)) +} +L_dofile :: #force_inline proc "c" (L: ^State, s: cstring) -> c.int { + err := L_loadfile(L, s) + return pcall(L, 0, MULTRET, 0) if err == nil else c.int(err) +} +L_dostring :: #force_inline proc "c" (L: ^State, s: cstring) -> c.int { + err := L_loadstring(L, s) + return pcall(L, 0, MULTRET, 0) if err == nil else c.int(err) +} +L_getmetatable :: #force_inline proc "c" (L: ^State, n: cstring) -> c.int { + return getfield(L, REGISTRYINDEX, n) +} +L_opt :: #force_inline proc "c" (L: ^State, f: $F, n: c.int, d: $T) -> T where intrinsics.type_is_proc(F) { + return d if isnoneornil(L, n) else f(L, n) +} + + + +/* }============================================================== */ diff --git a/vendor/lua/5.3/windows/lua53.dll b/vendor/lua/5.3/windows/lua53.dll new file mode 100644 index 000000000..fca1529ee Binary files /dev/null and b/vendor/lua/5.3/windows/lua53.dll differ diff --git a/vendor/lua/5.3/windows/lua53dll.lib b/vendor/lua/5.3/windows/lua53dll.lib new file mode 100644 index 000000000..5d204d37f Binary files /dev/null and b/vendor/lua/5.3/windows/lua53dll.lib differ diff --git a/vendor/lua/5.4/include/lauxlib.h b/vendor/lua/5.4/include/lauxlib.h new file mode 100644 index 000000000..59fef6af1 --- /dev/null +++ b/vendor/lua/5.4/include/lauxlib.h @@ -0,0 +1,276 @@ +/* +** $Id: lauxlib.h $ +** Auxiliary functions for building Lua libraries +** See Copyright Notice in lua.h +*/ + + +#ifndef lauxlib_h +#define lauxlib_h + + +#include +#include + +#include "lua.h" + + +/* global table */ +#define LUA_GNAME "_G" + + +typedef struct luaL_Buffer luaL_Buffer; + + +/* extra error code for 'luaL_loadfilex' */ +#define LUA_ERRFILE (LUA_ERRERR+1) + + +/* key, in the registry, for table of loaded modules */ +#define LUA_LOADED_TABLE "_LOADED" + + +/* key, in the registry, for table of preloaded loaders */ +#define LUA_PRELOAD_TABLE "_PRELOAD" + + +typedef struct luaL_Reg { + const char *name; + lua_CFunction func; +} luaL_Reg; + + +#define LUAL_NUMSIZES (sizeof(lua_Integer)*16 + sizeof(lua_Number)) + +LUALIB_API void (luaL_checkversion_) (lua_State *L, lua_Number ver, size_t sz); +#define luaL_checkversion(L) \ + luaL_checkversion_(L, LUA_VERSION_NUM, LUAL_NUMSIZES) + +LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e); +LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e); +LUALIB_API const char *(luaL_tolstring) (lua_State *L, int idx, size_t *len); +LUALIB_API int (luaL_argerror) (lua_State *L, int arg, const char *extramsg); +LUALIB_API int (luaL_typeerror) (lua_State *L, int arg, const char *tname); +LUALIB_API const char *(luaL_checklstring) (lua_State *L, int arg, + size_t *l); +LUALIB_API const char *(luaL_optlstring) (lua_State *L, int arg, + const char *def, size_t *l); +LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int arg); +LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int arg, lua_Number def); + +LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int arg); +LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int arg, + lua_Integer def); + +LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg); +LUALIB_API void (luaL_checktype) (lua_State *L, int arg, int t); +LUALIB_API void (luaL_checkany) (lua_State *L, int arg); + +LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname); +LUALIB_API void (luaL_setmetatable) (lua_State *L, const char *tname); +LUALIB_API void *(luaL_testudata) (lua_State *L, int ud, const char *tname); +LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname); + +LUALIB_API void (luaL_where) (lua_State *L, int lvl); +LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...); + +LUALIB_API int (luaL_checkoption) (lua_State *L, int arg, const char *def, + const char *const lst[]); + +LUALIB_API int (luaL_fileresult) (lua_State *L, int stat, const char *fname); +LUALIB_API int (luaL_execresult) (lua_State *L, int stat); + + +/* predefined references */ +#define LUA_NOREF (-2) +#define LUA_REFNIL (-1) + +LUALIB_API int (luaL_ref) (lua_State *L, int t); +LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref); + +LUALIB_API int (luaL_loadfilex) (lua_State *L, const char *filename, + const char *mode); + +#define luaL_loadfile(L,f) luaL_loadfilex(L,f,NULL) + +LUALIB_API int (luaL_loadbufferx) (lua_State *L, const char *buff, size_t sz, + const char *name, const char *mode); +LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s); + +LUALIB_API lua_State *(luaL_newstate) (void); + +LUALIB_API lua_Integer (luaL_len) (lua_State *L, int idx); + +LUALIB_API void luaL_addgsub (luaL_Buffer *b, const char *s, + const char *p, const char *r); +LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, + const char *p, const char *r); + +LUALIB_API void (luaL_setfuncs) (lua_State *L, const luaL_Reg *l, int nup); + +LUALIB_API int (luaL_getsubtable) (lua_State *L, int idx, const char *fname); + +LUALIB_API void (luaL_traceback) (lua_State *L, lua_State *L1, + const char *msg, int level); + +LUALIB_API void (luaL_requiref) (lua_State *L, const char *modname, + lua_CFunction openf, int glb); + +/* +** =============================================================== +** some useful macros +** =============================================================== +*/ + + +#define luaL_newlibtable(L,l) \ + lua_createtable(L, 0, sizeof(l)/sizeof((l)[0]) - 1) + +#define luaL_newlib(L,l) \ + (luaL_checkversion(L), luaL_newlibtable(L,l), luaL_setfuncs(L,l,0)) + +#define luaL_argcheck(L, cond,arg,extramsg) \ + ((void)((cond) || luaL_argerror(L, (arg), (extramsg)))) + +#define luaL_argexpected(L,cond,arg,tname) \ + ((void)((cond) || luaL_typeerror(L, (arg), (tname)))) + +#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL)) +#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL)) + +#define luaL_typename(L,i) lua_typename(L, lua_type(L,(i))) + +#define luaL_dofile(L, fn) \ + (luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0)) + +#define luaL_dostring(L, s) \ + (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0)) + +#define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n))) + +#define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n))) + +#define luaL_loadbuffer(L,s,sz,n) luaL_loadbufferx(L,s,sz,n,NULL) + + +/* push the value used to represent failure/error */ +#define luaL_pushfail(L) lua_pushnil(L) + + +/* +** {====================================================== +** Generic Buffer manipulation +** ======================================================= +*/ + +struct luaL_Buffer { + char *b; /* buffer address */ + size_t size; /* buffer size */ + size_t n; /* number of characters in buffer */ + lua_State *L; + union { + LUAI_MAXALIGN; /* ensure maximum alignment for buffer */ + char b[LUAL_BUFFERSIZE]; /* initial buffer */ + } init; +}; + + +#define luaL_bufflen(bf) ((bf)->n) +#define luaL_buffaddr(bf) ((bf)->b) + + +#define luaL_addchar(B,c) \ + ((void)((B)->n < (B)->size || luaL_prepbuffsize((B), 1)), \ + ((B)->b[(B)->n++] = (c))) + +#define luaL_addsize(B,s) ((B)->n += (s)) + +#define luaL_buffsub(B,s) ((B)->n -= (s)) + +LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B); +LUALIB_API char *(luaL_prepbuffsize) (luaL_Buffer *B, size_t sz); +LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l); +LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s); +LUALIB_API void (luaL_addvalue) (luaL_Buffer *B); +LUALIB_API void (luaL_pushresult) (luaL_Buffer *B); +LUALIB_API void (luaL_pushresultsize) (luaL_Buffer *B, size_t sz); +LUALIB_API char *(luaL_buffinitsize) (lua_State *L, luaL_Buffer *B, size_t sz); + +#define luaL_prepbuffer(B) luaL_prepbuffsize(B, LUAL_BUFFERSIZE) + +/* }====================================================== */ + + + +/* +** {====================================================== +** File handles for IO library +** ======================================================= +*/ + +/* +** A file handle is a userdata with metatable 'LUA_FILEHANDLE' and +** initial structure 'luaL_Stream' (it may contain other fields +** after that initial structure). +*/ + +#define LUA_FILEHANDLE "FILE*" + + +typedef struct luaL_Stream { + FILE *f; /* stream (NULL for incompletely created streams) */ + lua_CFunction closef; /* to close stream (NULL for closed streams) */ +} luaL_Stream; + +/* }====================================================== */ + +/* +** {================================================================== +** "Abstraction Layer" for basic report of messages and errors +** =================================================================== +*/ + +/* print a string */ +#if !defined(lua_writestring) +#define lua_writestring(s,l) fwrite((s), sizeof(char), (l), stdout) +#endif + +/* print a newline and flush the output */ +#if !defined(lua_writeline) +#define lua_writeline() (lua_writestring("\n", 1), fflush(stdout)) +#endif + +/* print an error message */ +#if !defined(lua_writestringerror) +#define lua_writestringerror(s,p) \ + (fprintf(stderr, (s), (p)), fflush(stderr)) +#endif + +/* }================================================================== */ + + +/* +** {============================================================ +** Compatibility with deprecated conversions +** ============================================================= +*/ +#if defined(LUA_COMPAT_APIINTCASTS) + +#define luaL_checkunsigned(L,a) ((lua_Unsigned)luaL_checkinteger(L,a)) +#define luaL_optunsigned(L,a,d) \ + ((lua_Unsigned)luaL_optinteger(L,a,(lua_Integer)(d))) + +#define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n))) +#define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d))) + +#define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n))) +#define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d))) + +#endif +/* }============================================================ */ + + + +#endif + + diff --git a/vendor/lua/5.4/include/lua.h b/vendor/lua/5.4/include/lua.h new file mode 100644 index 000000000..c9d64d7f2 --- /dev/null +++ b/vendor/lua/5.4/include/lua.h @@ -0,0 +1,517 @@ +/* +** $Id: lua.h $ +** Lua - A Scripting Language +** Lua.org, PUC-Rio, Brazil (http://www.lua.org) +** See Copyright Notice at the end of this file +*/ + + +#ifndef lua_h +#define lua_h + +#include +#include + + +#include "luaconf.h" + + +#define LUA_VERSION_MAJOR "5" +#define LUA_VERSION_MINOR "4" +#define LUA_VERSION_RELEASE "2" + +#define LUA_VERSION_NUM 504 +#define LUA_VERSION_RELEASE_NUM (LUA_VERSION_NUM * 100 + 0) + +#define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR +#define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE +#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2020 Lua.org, PUC-Rio" +#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo, W. Celes" + + +/* mark for precompiled code ('Lua') */ +#define LUA_SIGNATURE "\x1bLua" + +/* option for multiple returns in 'lua_pcall' and 'lua_call' */ +#define LUA_MULTRET (-1) + + +/* +** Pseudo-indices +** (-LUAI_MAXSTACK is the minimum valid index; we keep some free empty +** space after that to help overflow detection) +*/ +#define LUA_REGISTRYINDEX (-LUAI_MAXSTACK - 1000) +#define lua_upvalueindex(i) (LUA_REGISTRYINDEX - (i)) + + +/* thread status */ +#define LUA_OK 0 +#define LUA_YIELD 1 +#define LUA_ERRRUN 2 +#define LUA_ERRSYNTAX 3 +#define LUA_ERRMEM 4 +#define LUA_ERRERR 5 + + +typedef struct lua_State lua_State; + + +/* +** basic types +*/ +#define LUA_TNONE (-1) + +#define LUA_TNIL 0 +#define LUA_TBOOLEAN 1 +#define LUA_TLIGHTUSERDATA 2 +#define LUA_TNUMBER 3 +#define LUA_TSTRING 4 +#define LUA_TTABLE 5 +#define LUA_TFUNCTION 6 +#define LUA_TUSERDATA 7 +#define LUA_TTHREAD 8 + +#define LUA_NUMTYPES 9 + + + +/* minimum Lua stack available to a C function */ +#define LUA_MINSTACK 20 + + +/* predefined values in the registry */ +#define LUA_RIDX_MAINTHREAD 1 +#define LUA_RIDX_GLOBALS 2 +#define LUA_RIDX_LAST LUA_RIDX_GLOBALS + + +/* type of numbers in Lua */ +typedef LUA_NUMBER lua_Number; + + +/* type for integer functions */ +typedef LUA_INTEGER lua_Integer; + +/* unsigned integer type */ +typedef LUA_UNSIGNED lua_Unsigned; + +/* type for continuation-function contexts */ +typedef LUA_KCONTEXT lua_KContext; + + +/* +** Type for C functions registered with Lua +*/ +typedef int (*lua_CFunction) (lua_State *L); + +/* +** Type for continuation functions +*/ +typedef int (*lua_KFunction) (lua_State *L, int status, lua_KContext ctx); + + +/* +** Type for functions that read/write blocks when loading/dumping Lua chunks +*/ +typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz); + +typedef int (*lua_Writer) (lua_State *L, const void *p, size_t sz, void *ud); + + +/* +** Type for memory-allocation functions +*/ +typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize); + + +/* +** Type for warning functions +*/ +typedef void (*lua_WarnFunction) (void *ud, const char *msg, int tocont); + + + + +/* +** generic extra include file +*/ +#if defined(LUA_USER_H) +#include LUA_USER_H +#endif + + +/* +** RCS ident string +*/ +extern const char lua_ident[]; + + +/* +** state manipulation +*/ +LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud); +LUA_API void (lua_close) (lua_State *L); +LUA_API lua_State *(lua_newthread) (lua_State *L); +LUA_API int (lua_resetthread) (lua_State *L); + +LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf); + + +LUA_API lua_Number (lua_version) (lua_State *L); + + +/* +** basic stack manipulation +*/ +LUA_API int (lua_absindex) (lua_State *L, int idx); +LUA_API int (lua_gettop) (lua_State *L); +LUA_API void (lua_settop) (lua_State *L, int idx); +LUA_API void (lua_pushvalue) (lua_State *L, int idx); +LUA_API void (lua_rotate) (lua_State *L, int idx, int n); +LUA_API void (lua_copy) (lua_State *L, int fromidx, int toidx); +LUA_API int (lua_checkstack) (lua_State *L, int n); + +LUA_API void (lua_xmove) (lua_State *from, lua_State *to, int n); + + +/* +** access functions (stack -> C) +*/ + +LUA_API int (lua_isnumber) (lua_State *L, int idx); +LUA_API int (lua_isstring) (lua_State *L, int idx); +LUA_API int (lua_iscfunction) (lua_State *L, int idx); +LUA_API int (lua_isinteger) (lua_State *L, int idx); +LUA_API int (lua_isuserdata) (lua_State *L, int idx); +LUA_API int (lua_type) (lua_State *L, int idx); +LUA_API const char *(lua_typename) (lua_State *L, int tp); + +LUA_API lua_Number (lua_tonumberx) (lua_State *L, int idx, int *isnum); +LUA_API lua_Integer (lua_tointegerx) (lua_State *L, int idx, int *isnum); +LUA_API int (lua_toboolean) (lua_State *L, int idx); +LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len); +LUA_API lua_Unsigned (lua_rawlen) (lua_State *L, int idx); +LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx); +LUA_API void *(lua_touserdata) (lua_State *L, int idx); +LUA_API lua_State *(lua_tothread) (lua_State *L, int idx); +LUA_API const void *(lua_topointer) (lua_State *L, int idx); + + +/* +** Comparison and arithmetic functions +*/ + +#define LUA_OPADD 0 /* ORDER TM, ORDER OP */ +#define LUA_OPSUB 1 +#define LUA_OPMUL 2 +#define LUA_OPMOD 3 +#define LUA_OPPOW 4 +#define LUA_OPDIV 5 +#define LUA_OPIDIV 6 +#define LUA_OPBAND 7 +#define LUA_OPBOR 8 +#define LUA_OPBXOR 9 +#define LUA_OPSHL 10 +#define LUA_OPSHR 11 +#define LUA_OPUNM 12 +#define LUA_OPBNOT 13 + +LUA_API void (lua_arith) (lua_State *L, int op); + +#define LUA_OPEQ 0 +#define LUA_OPLT 1 +#define LUA_OPLE 2 + +LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2); +LUA_API int (lua_compare) (lua_State *L, int idx1, int idx2, int op); + + +/* +** push functions (C -> stack) +*/ +LUA_API void (lua_pushnil) (lua_State *L); +LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n); +LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n); +LUA_API const char *(lua_pushlstring) (lua_State *L, const char *s, size_t len); +LUA_API const char *(lua_pushstring) (lua_State *L, const char *s); +LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt, + va_list argp); +LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...); +LUA_API void (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n); +LUA_API void (lua_pushboolean) (lua_State *L, int b); +LUA_API void (lua_pushlightuserdata) (lua_State *L, void *p); +LUA_API int (lua_pushthread) (lua_State *L); + + +/* +** get functions (Lua -> stack) +*/ +LUA_API int (lua_getglobal) (lua_State *L, const char *name); +LUA_API int (lua_gettable) (lua_State *L, int idx); +LUA_API int (lua_getfield) (lua_State *L, int idx, const char *k); +LUA_API int (lua_geti) (lua_State *L, int idx, lua_Integer n); +LUA_API int (lua_rawget) (lua_State *L, int idx); +LUA_API int (lua_rawgeti) (lua_State *L, int idx, lua_Integer n); +LUA_API int (lua_rawgetp) (lua_State *L, int idx, const void *p); + +LUA_API void (lua_createtable) (lua_State *L, int narr, int nrec); +LUA_API void *(lua_newuserdatauv) (lua_State *L, size_t sz, int nuvalue); +LUA_API int (lua_getmetatable) (lua_State *L, int objindex); +LUA_API int (lua_getiuservalue) (lua_State *L, int idx, int n); + + +/* +** set functions (stack -> Lua) +*/ +LUA_API void (lua_setglobal) (lua_State *L, const char *name); +LUA_API void (lua_settable) (lua_State *L, int idx); +LUA_API void (lua_setfield) (lua_State *L, int idx, const char *k); +LUA_API void (lua_seti) (lua_State *L, int idx, lua_Integer n); +LUA_API void (lua_rawset) (lua_State *L, int idx); +LUA_API void (lua_rawseti) (lua_State *L, int idx, lua_Integer n); +LUA_API void (lua_rawsetp) (lua_State *L, int idx, const void *p); +LUA_API int (lua_setmetatable) (lua_State *L, int objindex); +LUA_API int (lua_setiuservalue) (lua_State *L, int idx, int n); + + +/* +** 'load' and 'call' functions (load and run Lua code) +*/ +LUA_API void (lua_callk) (lua_State *L, int nargs, int nresults, + lua_KContext ctx, lua_KFunction k); +#define lua_call(L,n,r) lua_callk(L, (n), (r), 0, NULL) + +LUA_API int (lua_pcallk) (lua_State *L, int nargs, int nresults, int errfunc, + lua_KContext ctx, lua_KFunction k); +#define lua_pcall(L,n,r,f) lua_pcallk(L, (n), (r), (f), 0, NULL) + +LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt, + const char *chunkname, const char *mode); + +LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data, int strip); + + +/* +** coroutine functions +*/ +LUA_API int (lua_yieldk) (lua_State *L, int nresults, lua_KContext ctx, + lua_KFunction k); +LUA_API int (lua_resume) (lua_State *L, lua_State *from, int narg, + int *nres); +LUA_API int (lua_status) (lua_State *L); +LUA_API int (lua_isyieldable) (lua_State *L); + +#define lua_yield(L,n) lua_yieldk(L, (n), 0, NULL) + + +/* +** Warning-related functions +*/ +LUA_API void (lua_setwarnf) (lua_State *L, lua_WarnFunction f, void *ud); +LUA_API void (lua_warning) (lua_State *L, const char *msg, int tocont); + + +/* +** garbage-collection function and options +*/ + +#define LUA_GCSTOP 0 +#define LUA_GCRESTART 1 +#define LUA_GCCOLLECT 2 +#define LUA_GCCOUNT 3 +#define LUA_GCCOUNTB 4 +#define LUA_GCSTEP 5 +#define LUA_GCSETPAUSE 6 +#define LUA_GCSETSTEPMUL 7 +#define LUA_GCISRUNNING 9 +#define LUA_GCGEN 10 +#define LUA_GCINC 11 + +LUA_API int (lua_gc) (lua_State *L, int what, ...); + + +/* +** miscellaneous functions +*/ + +LUA_API int (lua_error) (lua_State *L); + +LUA_API int (lua_next) (lua_State *L, int idx); + +LUA_API void (lua_concat) (lua_State *L, int n); +LUA_API void (lua_len) (lua_State *L, int idx); + +LUA_API size_t (lua_stringtonumber) (lua_State *L, const char *s); + +LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud); +LUA_API void (lua_setallocf) (lua_State *L, lua_Alloc f, void *ud); + +LUA_API void (lua_toclose) (lua_State *L, int idx); + + +/* +** {============================================================== +** some useful macros +** =============================================================== +*/ + +#define lua_getextraspace(L) ((void *)((char *)(L) - LUA_EXTRASPACE)) + +#define lua_tonumber(L,i) lua_tonumberx(L,(i),NULL) +#define lua_tointeger(L,i) lua_tointegerx(L,(i),NULL) + +#define lua_pop(L,n) lua_settop(L, -(n)-1) + +#define lua_newtable(L) lua_createtable(L, 0, 0) + +#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n))) + +#define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0) + +#define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION) +#define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE) +#define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA) +#define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL) +#define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN) +#define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD) +#define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE) +#define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0) + +#define lua_pushliteral(L, s) lua_pushstring(L, "" s) + +#define lua_pushglobaltable(L) \ + ((void)lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS)) + +#define lua_tostring(L,i) lua_tolstring(L, (i), NULL) + + +#define lua_insert(L,idx) lua_rotate(L, (idx), 1) + +#define lua_remove(L,idx) (lua_rotate(L, (idx), -1), lua_pop(L, 1)) + +#define lua_replace(L,idx) (lua_copy(L, -1, (idx)), lua_pop(L, 1)) + +/* }============================================================== */ + + +/* +** {============================================================== +** compatibility macros +** =============================================================== +*/ +#if defined(LUA_COMPAT_APIINTCASTS) + +#define lua_pushunsigned(L,n) lua_pushinteger(L, (lua_Integer)(n)) +#define lua_tounsignedx(L,i,is) ((lua_Unsigned)lua_tointegerx(L,i,is)) +#define lua_tounsigned(L,i) lua_tounsignedx(L,(i),NULL) + +#endif + +#define lua_newuserdata(L,s) lua_newuserdatauv(L,s,1) +#define lua_getuservalue(L,idx) lua_getiuservalue(L,idx,1) +#define lua_setuservalue(L,idx) lua_setiuservalue(L,idx,1) + +#define LUA_NUMTAGS LUA_NUMTYPES + +/* }============================================================== */ + +/* +** {====================================================================== +** Debug API +** ======================================================================= +*/ + + +/* +** Event codes +*/ +#define LUA_HOOKCALL 0 +#define LUA_HOOKRET 1 +#define LUA_HOOKLINE 2 +#define LUA_HOOKCOUNT 3 +#define LUA_HOOKTAILCALL 4 + + +/* +** Event masks +*/ +#define LUA_MASKCALL (1 << LUA_HOOKCALL) +#define LUA_MASKRET (1 << LUA_HOOKRET) +#define LUA_MASKLINE (1 << LUA_HOOKLINE) +#define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT) + +typedef struct lua_Debug lua_Debug; /* activation record */ + + +/* Functions to be called by the debugger in specific events */ +typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar); + + +LUA_API int (lua_getstack) (lua_State *L, int level, lua_Debug *ar); +LUA_API int (lua_getinfo) (lua_State *L, const char *what, lua_Debug *ar); +LUA_API const char *(lua_getlocal) (lua_State *L, const lua_Debug *ar, int n); +LUA_API const char *(lua_setlocal) (lua_State *L, const lua_Debug *ar, int n); +LUA_API const char *(lua_getupvalue) (lua_State *L, int funcindex, int n); +LUA_API const char *(lua_setupvalue) (lua_State *L, int funcindex, int n); + +LUA_API void *(lua_upvalueid) (lua_State *L, int fidx, int n); +LUA_API void (lua_upvaluejoin) (lua_State *L, int fidx1, int n1, + int fidx2, int n2); + +LUA_API void (lua_sethook) (lua_State *L, lua_Hook func, int mask, int count); +LUA_API lua_Hook (lua_gethook) (lua_State *L); +LUA_API int (lua_gethookmask) (lua_State *L); +LUA_API int (lua_gethookcount) (lua_State *L); + +LUA_API int (lua_setcstacklimit) (lua_State *L, unsigned int limit); + +struct lua_Debug { + int event; + const char *name; /* (n) */ + const char *namewhat; /* (n) 'global', 'local', 'field', 'method' */ + const char *what; /* (S) 'Lua', 'C', 'main', 'tail' */ + const char *source; /* (S) */ + size_t srclen; /* (S) */ + int currentline; /* (l) */ + int linedefined; /* (S) */ + int lastlinedefined; /* (S) */ + unsigned char nups; /* (u) number of upvalues */ + unsigned char nparams;/* (u) number of parameters */ + char isvararg; /* (u) */ + char istailcall; /* (t) */ + unsigned short ftransfer; /* (r) index of first value transferred */ + unsigned short ntransfer; /* (r) number of transferred values */ + char short_src[LUA_IDSIZE]; /* (S) */ + /* private part */ + struct CallInfo *i_ci; /* active function */ +}; + +/* }====================================================================== */ + + +/****************************************************************************** +* Copyright (C) 1994-2020 Lua.org, PUC-Rio. +* +* Permission is hereby granted, free of charge, to any person obtaining +* a copy of this software and associated documentation files (the +* "Software"), to deal in the Software without restriction, including +* without limitation the rights to use, copy, modify, merge, publish, +* distribute, sublicense, and/or sell copies of the Software, and to +* permit persons to whom the Software is furnished to do so, subject to +* the following conditions: +* +* The above copyright notice and this permission notice shall be +* included in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ + + +#endif diff --git a/vendor/lua/5.4/include/lua.hpp b/vendor/lua/5.4/include/lua.hpp new file mode 100644 index 000000000..ec417f594 --- /dev/null +++ b/vendor/lua/5.4/include/lua.hpp @@ -0,0 +1,9 @@ +// lua.hpp +// Lua header files for C++ +// <> not supplied automatically because Lua also compiles as C++ + +extern "C" { +#include "lua.h" +#include "lualib.h" +#include "lauxlib.h" +} diff --git a/vendor/lua/5.4/include/luaconf.h b/vendor/lua/5.4/include/luaconf.h new file mode 100644 index 000000000..3ad294e4f --- /dev/null +++ b/vendor/lua/5.4/include/luaconf.h @@ -0,0 +1,763 @@ +/* +** $Id: luaconf.h $ +** Configuration file for Lua +** See Copyright Notice in lua.h +*/ + + +#ifndef luaconf_h +#define luaconf_h + +#include +#include + + +/* +** =================================================================== +** General Configuration File for Lua +** +** Some definitions here can be changed externally, through the +** compiler (e.g., with '-D' options). Those are protected by +** '#if !defined' guards. However, several other definitions should +** be changed directly here, either because they affect the Lua +** ABI (by making the changes here, you ensure that all software +** connected to Lua, such as C libraries, will be compiled with the +** same configuration); or because they are seldom changed. +** +** Search for "@@" to find all configurable definitions. +** =================================================================== +*/ + + +/* +** {==================================================================== +** System Configuration: macros to adapt (if needed) Lua to some +** particular platform, for instance restricting it to C89. +** ===================================================================== +*/ + +/* +@@ LUA_USE_C89 controls the use of non-ISO-C89 features. +** Define it if you want Lua to avoid the use of a few C99 features +** or Windows-specific features on Windows. +*/ +/* #define LUA_USE_C89 */ + + +/* +** By default, Lua on Windows use (some) specific Windows features +*/ +#if !defined(LUA_USE_C89) && defined(_WIN32) && !defined(_WIN32_WCE) +#define LUA_USE_WINDOWS /* enable goodies for regular Windows */ +#endif + + +#if defined(LUA_USE_WINDOWS) +#define LUA_DL_DLL /* enable support for DLL */ +#define LUA_USE_C89 /* broadly, Windows is C89 */ +#endif + + +#if defined(LUA_USE_LINUX) +#define LUA_USE_POSIX +#define LUA_USE_DLOPEN /* needs an extra library: -ldl */ +#endif + + +#if defined(LUA_USE_MACOSX) +#define LUA_USE_POSIX +#define LUA_USE_DLOPEN /* MacOS does not need -ldl */ +#endif + + +/* +@@ LUAI_IS32INT is true iff 'int' has (at least) 32 bits. +*/ +#define LUAI_IS32INT ((UINT_MAX >> 30) >= 3) + +/* }================================================================== */ + + + +/* +** {================================================================== +** Configuration for Number types. +** =================================================================== +*/ + +/* +@@ LUA_32BITS enables Lua with 32-bit integers and 32-bit floats. +*/ +/* #define LUA_32BITS */ + + +/* +@@ LUA_C89_NUMBERS ensures that Lua uses the largest types available for +** C89 ('long' and 'double'); Windows always has '__int64', so it does +** not need to use this case. +*/ +#if defined(LUA_USE_C89) && !defined(LUA_USE_WINDOWS) +#define LUA_C89_NUMBERS +#endif + + +/* +@@ LUA_INT_TYPE defines the type for Lua integers. +@@ LUA_FLOAT_TYPE defines the type for Lua floats. +** Lua should work fine with any mix of these options supported +** by your C compiler. The usual configurations are 64-bit integers +** and 'double' (the default), 32-bit integers and 'float' (for +** restricted platforms), and 'long'/'double' (for C compilers not +** compliant with C99, which may not have support for 'long long'). +*/ + +/* predefined options for LUA_INT_TYPE */ +#define LUA_INT_INT 1 +#define LUA_INT_LONG 2 +#define LUA_INT_LONGLONG 3 + +/* predefined options for LUA_FLOAT_TYPE */ +#define LUA_FLOAT_FLOAT 1 +#define LUA_FLOAT_DOUBLE 2 +#define LUA_FLOAT_LONGDOUBLE 3 + +#if defined(LUA_32BITS) /* { */ +/* +** 32-bit integers and 'float' +*/ +#if LUAI_IS32INT /* use 'int' if big enough */ +#define LUA_INT_TYPE LUA_INT_INT +#else /* otherwise use 'long' */ +#define LUA_INT_TYPE LUA_INT_LONG +#endif +#define LUA_FLOAT_TYPE LUA_FLOAT_FLOAT + +#elif defined(LUA_C89_NUMBERS) /* }{ */ +/* +** largest types available for C89 ('long' and 'double') +*/ +#define LUA_INT_TYPE LUA_INT_LONG +#define LUA_FLOAT_TYPE LUA_FLOAT_DOUBLE + +#endif /* } */ + + +/* +** default configuration for 64-bit Lua ('long long' and 'double') +*/ +#if !defined(LUA_INT_TYPE) +#define LUA_INT_TYPE LUA_INT_LONGLONG +#endif + +#if !defined(LUA_FLOAT_TYPE) +#define LUA_FLOAT_TYPE LUA_FLOAT_DOUBLE +#endif + +/* }================================================================== */ + + + +/* +** {================================================================== +** Configuration for Paths. +** =================================================================== +*/ + +/* +** LUA_PATH_SEP is the character that separates templates in a path. +** LUA_PATH_MARK is the string that marks the substitution points in a +** template. +** LUA_EXEC_DIR in a Windows path is replaced by the executable's +** directory. +*/ +#define LUA_PATH_SEP ";" +#define LUA_PATH_MARK "?" +#define LUA_EXEC_DIR "!" + + +/* +@@ LUA_PATH_DEFAULT is the default path that Lua uses to look for +** Lua libraries. +@@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for +** C libraries. +** CHANGE them if your machine has a non-conventional directory +** hierarchy or if you want to install your libraries in +** non-conventional directories. +*/ + +#define LUA_VDIR LUA_VERSION_MAJOR "." LUA_VERSION_MINOR +#if defined(_WIN32) /* { */ +/* +** In Windows, any exclamation mark ('!') in the path is replaced by the +** path of the directory of the executable file of the current process. +*/ +#define LUA_LDIR "!\\lua\\" +#define LUA_CDIR "!\\" +#define LUA_SHRDIR "!\\..\\share\\lua\\" LUA_VDIR "\\" + +#if !defined(LUA_PATH_DEFAULT) +#define LUA_PATH_DEFAULT \ + LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \ + LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua;" \ + LUA_SHRDIR"?.lua;" LUA_SHRDIR"?\\init.lua;" \ + ".\\?.lua;" ".\\?\\init.lua" +#endif + +#if !defined(LUA_CPATH_DEFAULT) +#define LUA_CPATH_DEFAULT \ + LUA_CDIR"?.dll;" \ + LUA_CDIR"..\\lib\\lua\\" LUA_VDIR "\\?.dll;" \ + LUA_CDIR"loadall.dll;" ".\\?.dll;" \ + LUA_CDIR"?54.dll;" ".\\?54.dll" +#endif + +#else /* }{ */ + +#define LUA_ROOT "/usr/local/" +#define LUA_LDIR LUA_ROOT "share/lua/" LUA_VDIR "/" +#define LUA_CDIR LUA_ROOT "lib/lua/" LUA_VDIR "/" + +#if !defined(LUA_PATH_DEFAULT) +#define LUA_PATH_DEFAULT \ + LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ + LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" \ + "./?.lua;" "./?/init.lua" +#endif + +#if !defined(LUA_CPATH_DEFAULT) +#define LUA_CPATH_DEFAULT \ + LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so;" \ + LUA_CDIR"lib?54.so;" "./lib?54.so" +#endif + +#endif /* } */ + + +/* +@@ LUA_DIRSEP is the directory separator (for submodules). +** CHANGE it if your machine does not use "/" as the directory separator +** and is not Windows. (On Windows Lua automatically uses "\".) +*/ +#if !defined(LUA_DIRSEP) + +#if defined(_WIN32) +#define LUA_DIRSEP "\\" +#else +#define LUA_DIRSEP "/" +#endif + +#endif + +/* }================================================================== */ + + +/* +** {================================================================== +** Marks for exported symbols in the C code +** =================================================================== +*/ + +/* +@@ LUA_API is a mark for all core API functions. +@@ LUALIB_API is a mark for all auxiliary library functions. +@@ LUAMOD_API is a mark for all standard library opening functions. +** CHANGE them if you need to define those functions in some special way. +** For instance, if you want to create one Windows DLL with the core and +** the libraries, you may want to use the following definition (define +** LUA_BUILD_AS_DLL to get it). +*/ +#if defined(LUA_BUILD_AS_DLL) /* { */ + +#if defined(LUA_CORE) || defined(LUA_LIB) /* { */ +#define LUA_API __declspec(dllexport) +#else /* }{ */ +#define LUA_API __declspec(dllimport) +#endif /* } */ + +#else /* }{ */ + +#define LUA_API extern + +#endif /* } */ + + +/* +** More often than not the libs go together with the core. +*/ +#define LUALIB_API LUA_API +#define LUAMOD_API LUA_API + + +/* +@@ LUAI_FUNC is a mark for all extern functions that are not to be +** exported to outside modules. +@@ LUAI_DDEF and LUAI_DDEC are marks for all extern (const) variables, +** none of which to be exported to outside modules (LUAI_DDEF for +** definitions and LUAI_DDEC for declarations). +** CHANGE them if you need to mark them in some special way. Elf/gcc +** (versions 3.2 and later) mark them as "hidden" to optimize access +** when Lua is compiled as a shared library. Not all elf targets support +** this attribute. Unfortunately, gcc does not offer a way to check +** whether the target offers that support, and those without support +** give a warning about it. To avoid these warnings, change to the +** default definition. +*/ +#if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \ + defined(__ELF__) /* { */ +#define LUAI_FUNC __attribute__((visibility("internal"))) extern +#else /* }{ */ +#define LUAI_FUNC extern +#endif /* } */ + +#define LUAI_DDEC(dec) LUAI_FUNC dec +#define LUAI_DDEF /* empty */ + +/* }================================================================== */ + + +/* +** {================================================================== +** Compatibility with previous versions +** =================================================================== +*/ + +/* +@@ LUA_COMPAT_5_3 controls other macros for compatibility with Lua 5.3. +** You can define it to get all options, or change specific options +** to fit your specific needs. +*/ +#if defined(LUA_COMPAT_5_3) /* { */ + +/* +@@ LUA_COMPAT_MATHLIB controls the presence of several deprecated +** functions in the mathematical library. +** (These functions were already officially removed in 5.3; +** nevertheless they are still available here.) +*/ +#define LUA_COMPAT_MATHLIB + +/* +@@ LUA_COMPAT_APIINTCASTS controls the presence of macros for +** manipulating other integer types (lua_pushunsigned, lua_tounsigned, +** luaL_checkint, luaL_checklong, etc.) +** (These macros were also officially removed in 5.3, but they are still +** available here.) +*/ +#define LUA_COMPAT_APIINTCASTS + + +/* +@@ LUA_COMPAT_LT_LE controls the emulation of the '__le' metamethod +** using '__lt'. +*/ +#define LUA_COMPAT_LT_LE + + +/* +@@ The following macros supply trivial compatibility for some +** changes in the API. The macros themselves document how to +** change your code to avoid using them. +** (Once more, these macros were officially removed in 5.3, but they are +** still available here.) +*/ +#define lua_strlen(L,i) lua_rawlen(L, (i)) + +#define lua_objlen(L,i) lua_rawlen(L, (i)) + +#define lua_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ) +#define lua_lessthan(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPLT) + +#endif /* } */ + +/* }================================================================== */ + + + +/* +** {================================================================== +** Configuration for Numbers. +** Change these definitions if no predefined LUA_FLOAT_* / LUA_INT_* +** satisfy your needs. +** =================================================================== +*/ + +/* +@@ LUA_NUMBER is the floating-point type used by Lua. +@@ LUAI_UACNUMBER is the result of a 'default argument promotion' +@@ over a floating number. +@@ l_floatatt(x) corrects float attribute 'x' to the proper float type +** by prefixing it with one of FLT/DBL/LDBL. +@@ LUA_NUMBER_FRMLEN is the length modifier for writing floats. +@@ LUA_NUMBER_FMT is the format for writing floats. +@@ lua_number2str converts a float to a string. +@@ l_mathop allows the addition of an 'l' or 'f' to all math operations. +@@ l_floor takes the floor of a float. +@@ lua_str2number converts a decimal numeral to a number. +*/ + + +/* The following definitions are good for most cases here */ + +#define l_floor(x) (l_mathop(floor)(x)) + +#define lua_number2str(s,sz,n) \ + l_sprintf((s), sz, LUA_NUMBER_FMT, (LUAI_UACNUMBER)(n)) + +/* +@@ lua_numbertointeger converts a float number with an integral value +** to an integer, or returns 0 if float is not within the range of +** a lua_Integer. (The range comparisons are tricky because of +** rounding. The tests here assume a two-complement representation, +** where MININTEGER always has an exact representation as a float; +** MAXINTEGER may not have one, and therefore its conversion to float +** may have an ill-defined value.) +*/ +#define lua_numbertointeger(n,p) \ + ((n) >= (LUA_NUMBER)(LUA_MININTEGER) && \ + (n) < -(LUA_NUMBER)(LUA_MININTEGER) && \ + (*(p) = (LUA_INTEGER)(n), 1)) + + +/* now the variable definitions */ + +#if LUA_FLOAT_TYPE == LUA_FLOAT_FLOAT /* { single float */ + +#define LUA_NUMBER float + +#define l_floatatt(n) (FLT_##n) + +#define LUAI_UACNUMBER double + +#define LUA_NUMBER_FRMLEN "" +#define LUA_NUMBER_FMT "%.7g" + +#define l_mathop(op) op##f + +#define lua_str2number(s,p) strtof((s), (p)) + + +#elif LUA_FLOAT_TYPE == LUA_FLOAT_LONGDOUBLE /* }{ long double */ + +#define LUA_NUMBER long double + +#define l_floatatt(n) (LDBL_##n) + +#define LUAI_UACNUMBER long double + +#define LUA_NUMBER_FRMLEN "L" +#define LUA_NUMBER_FMT "%.19Lg" + +#define l_mathop(op) op##l + +#define lua_str2number(s,p) strtold((s), (p)) + +#elif LUA_FLOAT_TYPE == LUA_FLOAT_DOUBLE /* }{ double */ + +#define LUA_NUMBER double + +#define l_floatatt(n) (DBL_##n) + +#define LUAI_UACNUMBER double + +#define LUA_NUMBER_FRMLEN "" +#define LUA_NUMBER_FMT "%.14g" + +#define l_mathop(op) op + +#define lua_str2number(s,p) strtod((s), (p)) + +#else /* }{ */ + +#error "numeric float type not defined" + +#endif /* } */ + + + +/* +@@ LUA_INTEGER is the integer type used by Lua. +** +@@ LUA_UNSIGNED is the unsigned version of LUA_INTEGER. +** +@@ LUAI_UACINT is the result of a 'default argument promotion' +@@ over a LUA_INTEGER. +@@ LUA_INTEGER_FRMLEN is the length modifier for reading/writing integers. +@@ LUA_INTEGER_FMT is the format for writing integers. +@@ LUA_MAXINTEGER is the maximum value for a LUA_INTEGER. +@@ LUA_MININTEGER is the minimum value for a LUA_INTEGER. +@@ LUA_MAXUNSIGNED is the maximum value for a LUA_UNSIGNED. +@@ LUA_UNSIGNEDBITS is the number of bits in a LUA_UNSIGNED. +@@ lua_integer2str converts an integer to a string. +*/ + + +/* The following definitions are good for most cases here */ + +#define LUA_INTEGER_FMT "%" LUA_INTEGER_FRMLEN "d" + +#define LUAI_UACINT LUA_INTEGER + +#define lua_integer2str(s,sz,n) \ + l_sprintf((s), sz, LUA_INTEGER_FMT, (LUAI_UACINT)(n)) + +/* +** use LUAI_UACINT here to avoid problems with promotions (which +** can turn a comparison between unsigneds into a signed comparison) +*/ +#define LUA_UNSIGNED unsigned LUAI_UACINT + + +#define LUA_UNSIGNEDBITS (sizeof(LUA_UNSIGNED) * CHAR_BIT) + + +/* now the variable definitions */ + +#if LUA_INT_TYPE == LUA_INT_INT /* { int */ + +#define LUA_INTEGER int +#define LUA_INTEGER_FRMLEN "" + +#define LUA_MAXINTEGER INT_MAX +#define LUA_MININTEGER INT_MIN + +#define LUA_MAXUNSIGNED UINT_MAX + +#elif LUA_INT_TYPE == LUA_INT_LONG /* }{ long */ + +#define LUA_INTEGER long +#define LUA_INTEGER_FRMLEN "l" + +#define LUA_MAXINTEGER LONG_MAX +#define LUA_MININTEGER LONG_MIN + +#define LUA_MAXUNSIGNED ULONG_MAX + +#elif LUA_INT_TYPE == LUA_INT_LONGLONG /* }{ long long */ + +/* use presence of macro LLONG_MAX as proxy for C99 compliance */ +#if defined(LLONG_MAX) /* { */ +/* use ISO C99 stuff */ + +#define LUA_INTEGER long long +#define LUA_INTEGER_FRMLEN "ll" + +#define LUA_MAXINTEGER LLONG_MAX +#define LUA_MININTEGER LLONG_MIN + +#define LUA_MAXUNSIGNED ULLONG_MAX + +#elif defined(LUA_USE_WINDOWS) /* }{ */ +/* in Windows, can use specific Windows types */ + +#define LUA_INTEGER __int64 +#define LUA_INTEGER_FRMLEN "I64" + +#define LUA_MAXINTEGER _I64_MAX +#define LUA_MININTEGER _I64_MIN + +#define LUA_MAXUNSIGNED _UI64_MAX + +#else /* }{ */ + +#error "Compiler does not support 'long long'. Use option '-DLUA_32BITS' \ + or '-DLUA_C89_NUMBERS' (see file 'luaconf.h' for details)" + +#endif /* } */ + +#else /* }{ */ + +#error "numeric integer type not defined" + +#endif /* } */ + +/* }================================================================== */ + + +/* +** {================================================================== +** Dependencies with C99 and other C details +** =================================================================== +*/ + +/* +@@ l_sprintf is equivalent to 'snprintf' or 'sprintf' in C89. +** (All uses in Lua have only one format item.) +*/ +#if !defined(LUA_USE_C89) +#define l_sprintf(s,sz,f,i) snprintf(s,sz,f,i) +#else +#define l_sprintf(s,sz,f,i) ((void)(sz), sprintf(s,f,i)) +#endif + + +/* +@@ lua_strx2number converts a hexadecimal numeral to a number. +** In C99, 'strtod' does that conversion. Otherwise, you can +** leave 'lua_strx2number' undefined and Lua will provide its own +** implementation. +*/ +#if !defined(LUA_USE_C89) +#define lua_strx2number(s,p) lua_str2number(s,p) +#endif + + +/* +@@ lua_pointer2str converts a pointer to a readable string in a +** non-specified way. +*/ +#define lua_pointer2str(buff,sz,p) l_sprintf(buff,sz,"%p",p) + + +/* +@@ lua_number2strx converts a float to a hexadecimal numeral. +** In C99, 'sprintf' (with format specifiers '%a'/'%A') does that. +** Otherwise, you can leave 'lua_number2strx' undefined and Lua will +** provide its own implementation. +*/ +#if !defined(LUA_USE_C89) +#define lua_number2strx(L,b,sz,f,n) \ + ((void)L, l_sprintf(b,sz,f,(LUAI_UACNUMBER)(n))) +#endif + + +/* +** 'strtof' and 'opf' variants for math functions are not valid in +** C89. Otherwise, the macro 'HUGE_VALF' is a good proxy for testing the +** availability of these variants. ('math.h' is already included in +** all files that use these macros.) +*/ +#if defined(LUA_USE_C89) || (defined(HUGE_VAL) && !defined(HUGE_VALF)) +#undef l_mathop /* variants not available */ +#undef lua_str2number +#define l_mathop(op) (lua_Number)op /* no variant */ +#define lua_str2number(s,p) ((lua_Number)strtod((s), (p))) +#endif + + +/* +@@ LUA_KCONTEXT is the type of the context ('ctx') for continuation +** functions. It must be a numerical type; Lua will use 'intptr_t' if +** available, otherwise it will use 'ptrdiff_t' (the nearest thing to +** 'intptr_t' in C89) +*/ +#define LUA_KCONTEXT ptrdiff_t + +#if !defined(LUA_USE_C89) && defined(__STDC_VERSION__) && \ + __STDC_VERSION__ >= 199901L +#include +#if defined(INTPTR_MAX) /* even in C99 this type is optional */ +#undef LUA_KCONTEXT +#define LUA_KCONTEXT intptr_t +#endif +#endif + + +/* +@@ lua_getlocaledecpoint gets the locale "radix character" (decimal point). +** Change that if you do not want to use C locales. (Code using this +** macro must include the header 'locale.h'.) +*/ +#if !defined(lua_getlocaledecpoint) +#define lua_getlocaledecpoint() (localeconv()->decimal_point[0]) +#endif + +/* }================================================================== */ + + +/* +** {================================================================== +** Language Variations +** ===================================================================== +*/ + +/* +@@ LUA_NOCVTN2S/LUA_NOCVTS2N control how Lua performs some +** coercions. Define LUA_NOCVTN2S to turn off automatic coercion from +** numbers to strings. Define LUA_NOCVTS2N to turn off automatic +** coercion from strings to numbers. +*/ +/* #define LUA_NOCVTN2S */ +/* #define LUA_NOCVTS2N */ + + +/* +@@ LUA_USE_APICHECK turns on several consistency checks on the C API. +** Define it as a help when debugging C code. +*/ +#if defined(LUA_USE_APICHECK) +#include +#define luai_apicheck(l,e) assert(e) +#endif + +/* }================================================================== */ + + +/* +** {================================================================== +** Macros that affect the API and must be stable (that is, must be the +** same when you compile Lua and when you compile code that links to +** Lua). +** ===================================================================== +*/ + +/* +@@ LUAI_MAXSTACK limits the size of the Lua stack. +** CHANGE it if you need a different limit. This limit is arbitrary; +** its only purpose is to stop Lua from consuming unlimited stack +** space (and to reserve some numbers for pseudo-indices). +** (It must fit into max(size_t)/32.) +*/ +#if LUAI_IS32INT +#define LUAI_MAXSTACK 1000000 +#else +#define LUAI_MAXSTACK 15000 +#endif + + +/* +@@ LUA_EXTRASPACE defines the size of a raw memory area associated with +** a Lua state with very fast access. +** CHANGE it if you need a different size. +*/ +#define LUA_EXTRASPACE (sizeof(void *)) + + +/* +@@ LUA_IDSIZE gives the maximum size for the description of the source +@@ of a function in debug information. +** CHANGE it if you want a different size. +*/ +#define LUA_IDSIZE 60 + + +/* +@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. +*/ +#define LUAL_BUFFERSIZE ((int)(16 * sizeof(void*) * sizeof(lua_Number))) + + +/* +@@ LUAI_MAXALIGN defines fields that, when used in a union, ensure +** maximum alignment for the other items in that union. +*/ +#define LUAI_MAXALIGN lua_Number n; double u; void *s; lua_Integer i; long l + +/* }================================================================== */ + + + + + +/* =================================================================== */ + +/* +** Local configuration. You can use this space to add your redefinitions +** without modifying the main part of the file. +*/ + + + + + +#endif + diff --git a/vendor/lua/5.4/include/lualib.h b/vendor/lua/5.4/include/lualib.h new file mode 100644 index 000000000..eb08b530a --- /dev/null +++ b/vendor/lua/5.4/include/lualib.h @@ -0,0 +1,58 @@ +/* +** $Id: lualib.h $ +** Lua standard libraries +** See Copyright Notice in lua.h +*/ + + +#ifndef lualib_h +#define lualib_h + +#include "lua.h" + + +/* version suffix for environment variable names */ +#define LUA_VERSUFFIX "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR + + +LUAMOD_API int (luaopen_base) (lua_State *L); + +#define LUA_COLIBNAME "coroutine" +LUAMOD_API int (luaopen_coroutine) (lua_State *L); + +#define LUA_TABLIBNAME "table" +LUAMOD_API int (luaopen_table) (lua_State *L); + +#define LUA_IOLIBNAME "io" +LUAMOD_API int (luaopen_io) (lua_State *L); + +#define LUA_OSLIBNAME "os" +LUAMOD_API int (luaopen_os) (lua_State *L); + +#define LUA_STRLIBNAME "string" +LUAMOD_API int (luaopen_string) (lua_State *L); + +#define LUA_UTF8LIBNAME "utf8" +LUAMOD_API int (luaopen_utf8) (lua_State *L); + +#define LUA_MATHLIBNAME "math" +LUAMOD_API int (luaopen_math) (lua_State *L); + +#define LUA_DBLIBNAME "debug" +LUAMOD_API int (luaopen_debug) (lua_State *L); + +#define LUA_LOADLIBNAME "package" +LUAMOD_API int (luaopen_package) (lua_State *L); + + +/* open all previous libraries */ +LUALIB_API void (luaL_openlibs) (lua_State *L); + + + +#if !defined(lua_assert) +#define lua_assert(x) ((void)0) +#endif + + +#endif diff --git a/vendor/lua/5.4/linux/liblua54.a b/vendor/lua/5.4/linux/liblua54.a new file mode 100644 index 000000000..479aa3322 Binary files /dev/null and b/vendor/lua/5.4/linux/liblua54.a differ diff --git a/vendor/lua/5.4/linux/liblua54.so b/vendor/lua/5.4/linux/liblua54.so new file mode 100644 index 000000000..d7a0cf075 Binary files /dev/null and b/vendor/lua/5.4/linux/liblua54.so differ diff --git a/vendor/lua/5.4/lua.odin b/vendor/lua/5.4/lua.odin new file mode 100644 index 000000000..495786eb1 --- /dev/null +++ b/vendor/lua/5.4/lua.odin @@ -0,0 +1,826 @@ +package lua_5_4 + +import "core:intrinsics" +import "core:builtin" + +import c "core:c/libc" + +#assert(size_of(c.int) == size_of(b32)) + +when ODIN_OS == .Windows { + foreign import lib "windows/lua54dll.lib" +} else when ODIN_OS == .Linux { + foreign import lib "linux/liblua54.a" +} else { + foreign import lib "system:liblua54.a" +} + +VERSION_MAJOR :: "5" +VERSION_MINOR :: "4" +VERSION_RELEASE :: "2" + +VERSION_NUM :: 504 +VERSION_RELEASE_NUM :: VERSION_NUM * 100 + 0 + +VERSION :: "Lua " + VERSION_MAJOR + "." + VERSION_MINOR +RELEASE :: VERSION + "." + VERSION_RELEASE +COPYRIGHT :: RELEASE + " Copyright (C) 1994-2020 Lua.org, PUC-Rio" +AUTHORS :: "R. Ierusalimschy, L. H. de Figueiredo, W. Celes" + + +/* mark for precompiled code ('Lua') */ +SIGNATURE :: "\x1bLua" + +/* option for multiple returns in 'lua_pcall' and 'lua_call' */ +MULTRET :: -1 + +REGISTRYINDEX :: -MAXSTACK - 1000 + + +/* +@@ LUAI_MAXSTACK limits the size of the Lua stack. +** CHANGE it if you need a different limit. This limit is arbitrary; +** its only purpose is to stop Lua from consuming unlimited stack +** space (and to reserve some numbers for pseudo-indices). +** (It must fit into max(size_t)/32.) +*/ +MAXSTACK :: 1000000 + + +/* +@@ LUA_EXTRASPACE defines the size of a raw memory area associated with +** a Lua state with very fast access. +** CHANGE it if you need a different size. +*/ +EXTRASPACE :: size_of(rawptr) + + + +/* +@@ LUA_IDSIZE gives the maximum size for the description of the source +@@ of a function in debug information. +** CHANGE it if you want a different size. +*/ +IDSIZE :: 60 + + +/* +@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. +*/ +L_BUFFERSIZE :: c.int(16 * size_of(rawptr) * size_of(Number)) + + +MAXALIGNVAL :: max(align_of(Number), align_of(f64), align_of(rawptr), align_of(Integer), align_of(c.long)) + + +Status :: enum c.int { + OK = 0, + YIELD = 1, + ERRRUN = 2, + ERRSYNTAX = 3, + ERRMEM = 4, + ERRERR = 5, + ERRFILE = 6, +} + +/* thread status */ +OK :: Status.OK +YIELD :: Status.YIELD +ERRRUN :: Status.ERRRUN +ERRSYNTAX :: Status.ERRSYNTAX +ERRMEM :: Status.ERRMEM +ERRERR :: Status.ERRERR +ERRFILE :: Status.ERRFILE + +/* +** basic types +*/ + + +Type :: enum c.int { + NONE = -1, + + NIL = 0, + BOOLEAN = 1, + LIGHTUSERDATA = 2, + NUMBER = 3, + STRING = 4, + TABLE = 5, + FUNCTION = 6, + USERDATA = 7, + THREAD = 8, +} + +TNONE :: Type.NONE +TNIL :: Type.NIL +TBOOLEAN :: Type.BOOLEAN +TLIGHTUSERDATA :: Type.LIGHTUSERDATA +TNUMBER :: Type.NUMBER +TSTRING :: Type.STRING +TTABLE :: Type.TABLE +TFUNCTION :: Type.FUNCTION +TUSERDATA :: Type.USERDATA +TTHREAD :: Type.THREAD +NUMTYPES :: 9 + + + +ArithOp :: enum c.int { + ADD = 0, /* ORDER TM, ORDER OP */ + SUB = 1, + MUL = 2, + MOD = 3, + POW = 4, + DIV = 5, + IDIV = 6, + BAND = 7, + BOR = 8, + BXOR = 9, + SHL = 10, + SHR = 11, + UNM = 12, + BNOT = 13, +} + +CompareOp :: enum c.int { + EQ = 0, + LT = 1, + LE = 2, +} + +OPADD :: ArithOp.ADD +OPSUB :: ArithOp.SUB +OPMUL :: ArithOp.MUL +OPMOD :: ArithOp.MOD +OPPOW :: ArithOp.POW +OPDIV :: ArithOp.DIV +OPIDIV :: ArithOp.IDIV +OPBAND :: ArithOp.BAND +OPBOR :: ArithOp.BOR +OPBXOR :: ArithOp.BXOR +OPSHL :: ArithOp.SHL +OPSHR :: ArithOp.SHR +OPUNM :: ArithOp.UNM +OPBNOT :: ArithOp.BNOT + +OPEQ :: CompareOp.EQ +OPLT :: CompareOp.LT +OPLE :: CompareOp.LE + + +/* minimum Lua stack available to a C function */ +MINSTACK :: 20 + + +/* predefined values in the registry */ +RIDX_MAINTHREAD :: 1 +RIDX_GLOBALS :: 2 +RIDX_LAST :: RIDX_GLOBALS + + +/* type of numbers in Lua */ +Number :: distinct (f32 when size_of(uintptr) == 4 else f64) + + +/* type for integer functions */ +Integer :: distinct (i32 when size_of(uintptr) == 4 else i64) + +/* unsigned integer type */ +Unsigned :: distinct (u32 when size_of(uintptr) == 4 else u64) + +/* type for continuation-function contexts */ +KContext :: distinct int + + +/* +** Type for C functions registered with Lua +*/ +CFunction :: #type proc "c" (L: ^State) -> c.int + +/* +** Type for continuation functions +*/ +KFunction :: #type proc "c" (L: ^State, status: c.int, ctx: KContext) -> c.int + + +/* +** Type for functions that read/write blocks when loading/dumping Lua chunks +*/ +Reader :: #type proc "c" (L: ^State, ud: rawptr, sz: ^c.size_t) -> cstring +Writer :: #type proc "c" (L: ^State, p: rawptr, sz: ^c.size_t, ud: rawptr) -> c.int + + +/* +** Type for memory-allocation functions +*/ +Alloc :: #type proc "c" (ud: rawptr, ptr: rawptr, osize, nsize: c.size_t) -> rawptr + + +/* +** Type for warning functions +*/ +WarnFunction :: #type proc "c" (ud: rawptr, msg: rawptr, tocont: c.int) + +GCWhat :: enum c.int { + STOP = 0, + RESTART = 1, + COLLECT = 2, + COUNT = 3, + COUNTB = 4, + STEP = 5, + SETPAUSE = 6, + SETSTEPMUL = 7, + ISRUNNING = 9, + GEN = 10, + INC = 11, +} +GCSTOP :: GCWhat.STOP +GCRESTART :: GCWhat.RESTART +GCCOLLECT :: GCWhat.COLLECT +GCCOUNT :: GCWhat.COUNT +GCCOUNTB :: GCWhat.COUNTB +GCSTEP :: GCWhat.STEP +GCSETPAUSE :: GCWhat.SETPAUSE +GCSETSTEPMUL :: GCWhat.SETSTEPMUL +GCISRUNNING :: GCWhat.ISRUNNING +GCGEN :: GCWhat.GEN +GCINC :: GCWhat.INC + + + +/* +** Event codes +*/ + +HookEvent :: enum c.int { + CALL = 0, + RET = 1, + LINE = 2, + COUNT = 3, + TAILCALL = 4, +} +HOOKCALL :: HookEvent.CALL +HOOKRET :: HookEvent.RET +HOOKLINE :: HookEvent.LINE +HOOKCOUNT :: HookEvent.COUNT +HOOKTAILCALL :: HookEvent.TAILCALL + + +/* +** Event masks +*/ +HookMask :: distinct bit_set[HookEvent; c.int] +MASKCALL :: HookMask{.CALL} +MASKRET :: HookMask{.RET} +MASKLINE :: HookMask{.LINE} +MASKCOUNT :: HookMask{.COUNT} + +/* activation record */ +Debug :: struct { + event: HookEvent, + name: cstring, /* (n) */ + namewhat: cstring, /* (n) 'global', 'local', 'field', 'method' */ + what: cstring, /* (S) 'Lua', 'C', 'main', 'tail' */ + source: cstring, /* (S) */ + srclen: c.size_t, /* (S) */ + currentline: c.int, /* (l) */ + linedefined: c.int, /* (S) */ + lastlinedefined: c.int, /* (S) */ + nups: u8, /* (u) number of upvalues */ + nparams: u8, /* (u) number of parameters */ + isvararg: bool, /* (u) */ + istailcall: bool, /* (t) */ + ftransfer: u16, /* (r) index of first value transferred */ + ntransfer: u16, /* (r) number of transferred values */ + short_src: [IDSIZE]u8 `fmt:"s"`, /* (S) */ + /* private part */ + i_ci: rawptr, /* active function */ +} + + +/* Functions to be called by the debugger in specific events */ +Hook :: #type proc "c" (L: ^State, ar: ^Debug) + + +State :: struct {} // opaque data type + + +@(link_prefix="lua_") +@(default_calling_convention="c") +foreign lib { + /* + ** RCS ident string + */ + + ident: [^]u8 // TODO(bill): is this correct? + + + /* + ** state manipulation + */ + + newstate :: proc(f: Alloc, ud: rawptr) -> ^State --- + close :: proc(L: ^State) --- + newthread :: proc(L: ^State) -> ^State --- + resetthread :: proc(L: ^State) -> Status --- + + atpanic :: proc(L: ^State, panicf: CFunction) -> CFunction --- + + version :: proc(L: ^State) -> Number --- + + + /* + ** basic stack manipulation + */ + + absindex :: proc (L: ^State, idx: c.int) -> c.int --- + gettop :: proc (L: ^State) -> c.int --- + settop :: proc (L: ^State, idx: c.int) --- + pushvalue :: proc (L: ^State, idx: c.int) --- + rotate :: proc (L: ^State, idx: c.int, n: c.int) --- + copy :: proc (L: ^State, fromidx, toidx: c.int) --- + checkstack :: proc (L: ^State, n: c.int) -> c.int --- + + xmove :: proc(from, to: ^State, n: c.int) --- + + + /* + ** access functions (stack -> C) + */ + + isnumber :: proc(L: ^State, idx: c.int) -> b32 --- + isstring :: proc(L: ^State, idx: c.int) -> b32 --- + iscfunction :: proc(L: ^State, idx: c.int) -> b32 --- + isinteger :: proc(L: ^State, idx: c.int) -> b32 --- + isuserdata :: proc(L: ^State, idx: c.int) -> b32 --- + type :: proc(L: ^State, idx: c.int) -> Type --- + typename :: proc(L: ^State, tp: Type) -> cstring --- + + @(link_name="lua_tonumberx") + tonumber :: proc(L: ^State, idx: c.int, isnum: ^b32 = nil) -> Number --- + @(link_name="lua_tointegerx") + tointeger :: proc(L: ^State, idx: c.int, isnum: ^b32 = nil) -> Integer --- + toboolean :: proc(L: ^State, idx: c.int) -> b32 --- + tolstring :: proc(L: ^State, idx: c.int, len: ^c.size_t) -> cstring --- + rawlen :: proc(L: ^State, idx: c.int) -> Unsigned --- + tocfunction :: proc(L: ^State, idx: c.int) -> CFunction --- + touserdata :: proc(L: ^State, idx: c.int) -> rawptr --- + tothread :: proc(L: ^State, idx: c.int) -> ^State --- + topointer :: proc(L: ^State, idx: c.int) -> rawptr --- + + /* + ** Comparison and arithmetic functions + */ + + arith :: proc(L: ^State, op: ArithOp) --- + rawequal :: proc(L: ^State, idx1, idx2: c.int) -> b32 --- + compare :: proc(L: ^State, idx1, idx2: c.int, op: CompareOp) -> b32 --- + + /* + ** push functions (C -> stack) + */ + + pushnil :: proc(L: ^State) --- + pushnumber :: proc(L: ^State, n: Number) --- + pushinteger :: proc(L: ^State, n: Integer) --- + pushlstring :: proc(L: ^State, s: cstring, len: c.size_t) -> cstring --- + pushstring :: proc(L: ^State, s: cstring) -> cstring --- + pushvfstring :: proc(L: ^State, fmt: cstring, argp: c.va_list) -> cstring --- + pushfstring :: proc(L: ^State, fmt: cstring, #c_vararg args: ..any) -> cstring --- + pushcclosure :: proc(L: ^State, fn: CFunction, n: c.int) --- + pushboolean :: proc(L: ^State, b: b32) --- + pushlightuserdata :: proc(L: ^State, p: rawptr) --- + pushthread :: proc(L: ^State) -> Status --- + + /* + ** get functions (Lua -> stack) + */ + + getglobal :: proc(L: ^State, name: cstring) -> c.int --- + gettable :: proc(L: ^State, idx: c.int) -> c.int --- + getfield :: proc(L: ^State, idx: c.int, k: cstring) -> c.int --- + geti :: proc(L: ^State, idx: c.int, n: Integer) -> c.int --- + rawget :: proc(L: ^State, idx: c.int) -> c.int --- + rawgeti :: proc(L: ^State, idx: c.int, n: Integer) -> c.int --- + rawgetp :: proc(L: ^State, idx: c.int, p: rawptr) -> c.int --- + + createtable :: proc(L: ^State, narr, nrec: c.int) --- + newuserdatauv :: proc(L: ^State, sz: c.size_t, nuvalue: c.int) -> rawptr --- + getmetatable :: proc(L: ^State, objindex: c.int) -> c.int --- + getiuservalue :: proc(L: ^State, idx: c.int, n: c.int) -> c.int --- + + + /* + ** set functions (stack -> Lua) + */ + + setglobal :: proc(L: ^State, name: cstring) --- + settable :: proc(L: ^State, idx: c.int) --- + setfield :: proc(L: ^State, idx: c.int, k: cstring) --- + seti :: proc(L: ^State, idx: c.int, n: Integer) --- + rawset :: proc(L: ^State, idx: c.int) --- + rawseti :: proc(L: ^State, idx: c.int, n: Integer) --- + rawsetp :: proc(L: ^State, idx: c.int, p: rawptr) --- + setmetatable :: proc(L: ^State, objindex: c.int) -> c.int --- + setiuservalue :: proc(L: ^State, idx: c.int, n: c.int) -> c.int --- + + + /* + ** 'load' and 'call' functions (load and run Lua code) + */ + + @(link_name="lua_callk") + call :: proc(L: ^State, nargs, nresults: c.int, + ctx: KContext = 0, k: KFunction = nil) --- + + @(link_name="lua_pcallk") + pcall :: proc(L: ^State, nargs, nresults: c.int, errfunc: c.int, + ctx: KContext = 0, k: KFunction = nil) -> c.int --- + + load :: proc(L: ^State, reader: Reader, dt: rawptr, + chunkname, mode: cstring) -> Status --- + + dump :: proc(L: ^State, writer: Writer, data: rawptr, strip: b32) -> Status --- + + + /* + ** coroutine functions + */ + + @(link_name="lua_yieldk") + yield :: proc(L: ^State, nresults: c.int, ctx: KContext = 0, k: KFunction = nil) -> Status --- + resume :: proc(L: ^State, from: ^State, narg: c.int, nres: ^c.int) -> Status --- + status :: proc(L: ^State) -> Status --- + isyieldable :: proc(L: ^State) -> b32 --- + + + /* + ** Warning-related functions + */ + + setwarnf :: proc(L: ^State, f: WarnFunction, ud: rawptr) --- + warning :: proc(L: ^State, msg: string, tocont: b32) --- + + + /* + ** garbage-collection function and options + */ + + + + gc :: proc(L: ^State, what: GCWhat, #c_vararg args: ..any) -> c.int --- + + + /* + ** miscellaneous functions + */ + + error :: proc(L: ^State) -> Status --- + + next :: proc(L: ^State, idx: c.int) -> c.int --- + + concat :: proc(L: ^State, n: c.int) --- + len :: proc(L: ^State, idx: c.int) --- + + stringtonumber :: proc(L: ^State, s: cstring) -> c.size_t --- + + getallocf :: proc(L: State, ud: ^rawptr) -> Alloc --- + setallocf :: proc(L: ^State, f: Alloc, ud: rawptr) --- + + toclose :: proc(L: ^State, idx: c.int) --- + + /* + ** {====================================================================== + ** Debug API + ** ======================================================================= + */ + + getstack :: proc(L: ^State, level: c.int, ar: ^Debug) -> c.int --- + getinfo :: proc(L: ^State, what: cstring, ar: ^Debug) -> c.int --- + getlocal :: proc(L: ^State, ar: ^Debug, n: c.int) -> cstring --- + setlocal :: proc(L: ^State, ar: ^Debug, n: c.int) -> cstring --- + getupvalue :: proc(L: ^State, funcindex: c.int, n: c.int) -> cstring --- + setupvalue :: proc(L: ^State, funcindex: c.int, n: c.int) -> cstring --- + + upvalueid :: proc(L: ^State, fidx, n: c.int) -> rawptr --- + upvaluejoin :: proc(L: ^State, fidx1, n1, fidx2, n2: c.int) --- + + sethook :: proc(L: ^State, func: Hook, mask: HookMask, count: c.int) --- + gethook :: proc(L: ^State) -> Hook --- + gethookmask :: proc(L: ^State) -> HookMask --- + gethookcount :: proc(L: ^State) -> c.int --- + + setcstacklimit :: proc(L: ^State, limit: c.uint) -> c.int --- + + /* }============================================================== */ +} + + + +/* version suffix for environment variable names */ +VERSUFFIX :: "_" + VERSION_MAJOR + "_" + VERSION_MINOR + +COLIBNAME :: "coroutine" +TABLIBNAME :: "table" +IOLIBNAME :: "io" +OSLIBNAME :: "os" +STRLIBNAME :: "string" +UTF8LIBNAME :: "utf8" +MATHLIBNAME :: "math" +DBLIBNAME :: "debug" +LOADLIBNAME :: "package" + +@(link_prefix="lua") +@(default_calling_convention="c") +foreign lib { + open_base :: proc(L: ^State) -> c.int --- + open_coroutine :: proc(L: ^State) -> c.int --- + open_table :: proc(L: ^State) -> c.int --- + open_io :: proc(L: ^State) -> c.int --- + open_os :: proc(L: ^State) -> c.int --- + open_string :: proc(L: ^State) -> c.int --- + open_utf8 :: proc(L: ^State) -> c.int --- + open_math :: proc(L: ^State) -> c.int --- + open_debug :: proc(L: ^State) -> c.int --- + open_package :: proc(L: ^State) -> c.int --- + + /* open all previous libraries */ + + L_openlibs :: proc(L: ^State) --- +} + + + +GNAME :: "_G" + +/* key, in the registry, for table of loaded modules */ +LOADED_TABLE :: "_LOADED" + + +/* key, in the registry, for table of preloaded loaders */ +PRELOAD_TABLE :: "_PRELOAD" + +L_Reg :: struct { + name: cstring, + func: CFunction, +} + +L_NUMSIZES :: size_of(Integer)*16 + size_of(Number) + + +/* predefined references */ +NOREF :: -2 +REFNIL :: -1 + + +@(link_prefix="lua") +@(default_calling_convention="c") +foreign lib { + @(link_name="luaL_checkversion_") + L_checkversion :: proc(L: ^State, ver: Number = VERSION_NUM, sz: c.size_t = L_NUMSIZES) --- + + + L_getmetafield :: proc(L: ^State, obj: c.int, e: cstring) -> c.int --- + L_callmeta :: proc(L: ^State, obj: c.int, e: cstring) -> c.int --- + @(link_name="luaL_tolstring") + L_tostring :: proc(L: ^State, idx: c.int, len: ^c.size_t = nil) -> cstring --- + L_argerror :: proc(L: ^State, arg: c.int, extramsg: cstring) -> c.int --- + L_typeerror :: proc(L: ^State, arg: c.int, tname: cstring) -> c.int --- + @(link_name="luaL_checklstring") + L_checkstring :: proc(L: ^State, arg: c.int, l: ^c.size_t = nil) -> cstring --- + @(link_name="luaL_optlstring") + L_optstring :: proc(L: ^State, arg: c.int, def: cstring, l: ^c.size_t = nil) -> cstring --- + L_checknumber :: proc(L: ^State, arg: c.int) -> Number --- + L_optnumber :: proc(L: ^State, arg: c.int, def: Number) -> Number --- + + L_checkinteger :: proc(L: ^State, arg: c.int) -> Integer --- + L_optinteger :: proc(L: ^State, arg: c.int, def: Integer) -> Integer --- + + L_checkstack :: proc(L: ^State, sz: c.int, msg: cstring) --- + L_checktype :: proc(L: ^State, arg: c.int, t: c.int) --- + L_checkany :: proc(L: ^State, arg: c.int) --- + + L_newmetatable :: proc(L: ^State, tname: cstring) -> c.int --- + L_setmetatable :: proc(L: ^State, tname: cstring) --- + L_testudata :: proc(L: ^State, ud: c.int, tname: cstring) -> rawptr --- + L_checkudata :: proc(L: ^State, ud: c.int, tname: cstring) -> rawptr --- + + L_where :: proc(L: ^State, lvl: c.int) --- + L_error :: proc(L: ^State, fmt: cstring, #c_vararg args: ..any) -> Status --- + + L_checkoption :: proc(L: ^State, arg: c.int, def: cstring, lst: [^]cstring) -> c.int --- + + L_fileresult :: proc(L: ^State, stat: c.int, fname: cstring) -> c.int --- + L_execresult :: proc(L: ^State, stat: c.int) -> c.int --- + + + L_ref :: proc(L: ^State, t: c.int) -> c.int --- + L_unref :: proc(L: ^State, t: c.int, ref: c.int) --- + + @(link_name="luaL_loadfilex") + L_loadfile :: proc (L: ^State, filename: cstring, mode: cstring = nil) -> Status --- + + @(link_name="luaL_loadbufferx") + L_loadbuffer :: proc(L: ^State, buff: [^]byte, sz: c.size_t, name: cstring, mode: cstring = nil) -> Status --- + L_loadstring :: proc(L: ^State, s: cstring) -> Status --- + + L_newstate :: proc() -> ^State --- + + L_len :: proc(L: ^State, idx: c.int) -> Integer --- + + L_addgsub :: proc(b: ^L_Buffer, s, p, r: cstring) --- + L_gsub :: proc(L: ^State, s, p, r: cstring) -> cstring --- + + L_setfuncs :: proc(L: ^State, l: [^]L_Reg, nup: c.int) --- + + L_getsubtable :: proc(L: ^State, idx: c.int, fname: cstring) -> c.int --- + + L_traceback :: proc(L: ^State, L1: ^State, msg: cstring, level: c.int) --- + + L_requiref :: proc(L: ^State, modname: cstring, openf: CFunction, glb: c.int) --- + +} +/* +** {====================================================== +** Generic Buffer manipulation +** ======================================================= +*/ + + +L_Buffer :: struct { + b: [^]byte, /* buffer address */ + size: c.size_t, /* buffer size */ + n: c.size_t, /* number of characters in buffer */ + L: ^State, + init: struct #raw_union { + n: Number, u: f64, s: rawptr, i: Integer, l: c.long, + b: [L_BUFFERSIZE]byte, /* initial buffer */ + }, +} +L_bufflen :: #force_inline proc "c" (bf: ^L_Buffer) -> c.size_t { + return bf.n +} +L_buffaddr :: #force_inline proc "c" (bf: ^L_Buffer) -> [^]byte { + return bf.b +} + +L_addchar :: #force_inline proc "c" (B: ^L_Buffer, c: byte) { + if B.n < B.size { + L_prepbuffsize(B, 1) + } + B.b[B.n] = c + B.n += 1 +} + +L_addsize :: #force_inline proc "c" (B: ^L_Buffer, s: c.size_t) -> c.size_t { + B.n += s + return B.n +} + +L_buffsub :: #force_inline proc "c" (B: ^L_Buffer, s: c.size_t) -> c.size_t { + B.n -= s + return B.n +} + +L_prepbuffer :: #force_inline proc "c" (B: ^L_Buffer) -> [^]byte { + return L_prepbuffsize(B, c.size_t(L_BUFFERSIZE)) +} + + +@(link_prefix="lua") +@(default_calling_convention="c") +foreign lib { + L_buffinit :: proc(L: ^State, B: ^L_Buffer) --- + L_prepbuffsize :: proc(B: ^L_Buffer, sz: c.size_t) -> [^]byte --- + L_addlstring :: proc(B: ^L_Buffer, s: cstring, l: c.size_t) --- + L_addstring :: proc(B: ^L_Buffer, s: cstring) --- + L_addvalue :: proc(B: ^L_Buffer) --- + L_pushresult :: proc(B: ^L_Buffer) --- + L_pushresultsize :: proc(B: ^L_Buffer, sz: c.size_t) --- + L_buffinitsize :: proc(L: ^State, B: ^L_Buffer, sz: c.size_t) -> [^]byte --- +} + + +/* }====================================================== */ + + + + +/* +** {============================================================== +** some useful macros +** =============================================================== +*/ + +getextraspace :: #force_inline proc "c" (L: ^State) -> rawptr { + return rawptr(([^]byte)(L)[-EXTRASPACE:]) +} +pop :: #force_inline proc "c" (L: ^State, n: c.int) { + settop(L, -n-1) +} +newtable :: #force_inline proc "c" (L: ^State) { + createtable(L, 0, 0) +} +register :: #force_inline proc "c" (L: ^State, n: cstring, f: CFunction) { + pushcfunction(L, f) + setglobal(L, n) +} + +pushcfunction :: #force_inline proc "c" (L: ^State, f: CFunction) { + pushcclosure(L, f, 0) +} + + +isfunction :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .FUNCTION } +istable :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .TABLE } +islightuserdata :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .LIGHTUSERDATA } +isnil :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .NIL } +isboolean :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .BOOLEAN } +isthread :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .THREAD } +isnone :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) == .NONE } +isnoneornil :: #force_inline proc "c" (L: ^State, n: c.int) -> bool { return type(L, n) <= .NIL } + + +pushliteral :: pushstring +pushglobaltable :: #force_inline proc "c" (L: ^State) { + rawgeti(L, REGISTRYINDEX, RIDX_GLOBALS) +} +tostring :: #force_inline proc "c" (L: ^State, i: c.int) -> cstring { + return tolstring(L, i, nil) +} +insert :: #force_inline proc "c" (L: ^State, idx: c.int) { + rotate(L, idx, 1) +} +remove :: #force_inline proc "c" (L: ^State, idx: c.int) { + rotate(L, idx, -1) + pop(L, 1) +} +replace :: #force_inline proc "c" (L: ^State, idx: c.int) { + copy(L, -1, idx) + pop(L, 1) +} + +L_newlibtable :: #force_inline proc "c" (L: ^State, l: []L_Reg) { + createtable(L, 0, c.int(builtin.len(l) - 1)) +} + +L_newlib :: proc(L: ^State, l: []L_Reg) { + L_checkversion(L) + L_newlibtable(L, l) + L_setfuncs(L, raw_data(l), 0) +} + +L_argcheck :: #force_inline proc "c" (L: ^State, cond: bool, arg: c.int, extramsg: cstring) { + if cond { + L_argerror(L, arg, extramsg) + } +} + +L_argexpected :: #force_inline proc "c" (L: ^State, cond: bool, arg: c.int, tname: cstring) { + if cond { + L_typeerror(L, arg, tname) + } +} + +L_typename :: #force_inline proc "c" (L: ^State, i: c.int) -> cstring { + return typename(L, type(L, i)) +} +L_dofile :: #force_inline proc "c" (L: ^State, s: cstring) -> c.int { + err := L_loadfile(L, s) + return pcall(L, 0, MULTRET, 0) if err == nil else c.int(err) +} +L_dostring :: #force_inline proc "c" (L: ^State, s: cstring) -> c.int { + err := L_loadstring(L, s) + return pcall(L, 0, MULTRET, 0) if err == nil else c.int(err) +} +L_getmetatable :: #force_inline proc "c" (L: ^State, n: cstring) -> c.int { + return getfield(L, REGISTRYINDEX, n) +} +L_opt :: #force_inline proc "c" (L: ^State, f: $F, n: c.int, d: $T) -> T where intrinsics.type_is_proc(F) { + return d if isnoneornil(L, n) else f(L, n) +} + + + +/* push the value used to represent failure/error */ +pushfail :: pushnil + + +/* }============================================================== */ + + +/* +** {============================================================== +** compatibility macros +** =============================================================== +*/ + +newuserdata :: #force_inline proc "c" (L: ^State, s: c.size_t) -> rawptr { + return newuserdatauv(L, s, 1) +} +getuservalue :: #force_inline proc "c" (L: ^State, idx: c.int) -> c.int { + return getiuservalue(L, idx, 1) +} +setuservalue :: #force_inline proc "c" (L: ^State, idx: c.int) -> c.int { + return setiuservalue(L, idx, 1) +} diff --git a/vendor/lua/5.4/windows/lua54.dll b/vendor/lua/5.4/windows/lua54.dll new file mode 100644 index 000000000..44130fad2 Binary files /dev/null and b/vendor/lua/5.4/windows/lua54.dll differ diff --git a/vendor/lua/5.4/windows/lua54dll.lib b/vendor/lua/5.4/windows/lua54dll.lib new file mode 100644 index 000000000..21bdd6ebd Binary files /dev/null and b/vendor/lua/5.4/windows/lua54dll.lib differ diff --git a/vendor/lua/LICENSE b/vendor/lua/LICENSE new file mode 100644 index 000000000..4a17a5230 --- /dev/null +++ b/vendor/lua/LICENSE @@ -0,0 +1,6 @@ +Copyright Ā© 1994–2023 Lua.org, PUC-Rio. +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/vendor/lua/README.md b/vendor/lua/README.md new file mode 100644 index 000000000..8f4b0f5a5 --- /dev/null +++ b/vendor/lua/README.md @@ -0,0 +1,12 @@ +# Lua in Odin + +```odin +import lua "vendor:lua/5.4" // or whatever version you want +``` + +Lua packages + +* `vendor:lua/5.1` (version 5.1.5) +* `vendor:lua/5.2` (version 5.2.4) +* `vendor:lua/5.3` (version 5.3.6) +* `vendor:lua/5.4` (version 5.4.2) \ No newline at end of file diff --git a/vendor/miniaudio/synchronization.odin b/vendor/miniaudio/synchronization.odin index 7615e8f45..2f0b41f5d 100644 --- a/vendor/miniaudio/synchronization.odin +++ b/vendor/miniaudio/synchronization.odin @@ -25,7 +25,7 @@ foreign lib { */ spinlock_unlock :: proc(/*volatile*/ pSpinlock: ^spinlock) -> result --- -when NO_THREADING { +when !NO_THREADING { /* Creates a mutex. diff --git a/vendor/raylib/LICENSE b/vendor/raylib/LICENSE index d7d866436..91da62ed9 100644 --- a/vendor/raylib/LICENSE +++ b/vendor/raylib/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2013-2021 Ramon Santamaria (@raysan5) +Copyright (c) 2013-2023 Ramon Santamaria (@raysan5) This software is provided "as-is", without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. diff --git a/vendor/raylib/README.md b/vendor/raylib/README.md index cbfdf22f4..11b4bda48 100644 --- a/vendor/raylib/README.md +++ b/vendor/raylib/README.md @@ -12,15 +12,17 @@ Ready to learn? Jump to [code examples!](https://www.raylib.com/examples.html)
-[![GitHub contributors](https://img.shields.io/github/contributors/raysan5/raylib)](https://github.com/raysan5/raylib/graphs/contributors) -[![GitHub All Releases](https://img.shields.io/github/downloads/raysan5/raylib/total)](https://github.com/raysan5/raylib/releases) -[![GitHub commits since tagged version](https://img.shields.io/github/commits-since/raysan5/raylib/4.0.0)](https://github.com/raysan5/raylib/commits/master) +[![GitHub Releases Downloads](https://img.shields.io/github/downloads/raysan5/raylib/total)](https://github.com/raysan5/raylib/releases) +[![GitHub Stars](https://img.shields.io/github/stars/raysan5/raylib?style=flat&label=stars)](https://github.com/raysan5/raylib/stargazers) +[![GitHub commits since tagged version](https://img.shields.io/github/commits-since/raysan5/raylib/4.2.0)](https://github.com/raysan5/raylib/commits/master) +[![GitHub Sponsors](https://img.shields.io/github/sponsors/raysan5?label=sponsors)](https://github.com/sponsors/raysan5) +[![Packaging Status](https://repology.org/badge/tiny-repos/raylib.svg)](https://repology.org/project/raylib/versions) [![License](https://img.shields.io/badge/license-zlib%2Flibpng-blue.svg)](LICENSE) -[![Chat on Discord](https://img.shields.io/discord/426912293134270465.svg?logo=discord)](https://discord.gg/raylib) -[![GitHub stars](https://img.shields.io/github/stars/raysan5/raylib?style=social)](https://github.com/raysan5/raylib/stargazers) -[![Twitter Follow](https://img.shields.io/twitter/follow/raysan5?style=social)](https://twitter.com/raysan5) -[![Subreddit subscribers](https://img.shields.io/reddit/subreddit-subscribers/raylib?style=social)](https://www.reddit.com/r/raylib/) +[![Discord Members](https://img.shields.io/discord/426912293134270465.svg?label=Discord&logo=discord)](https://discord.gg/raylib) +[![Subreddit Subscribers](https://img.shields.io/reddit/subreddit-subscribers/raylib?label=reddit%20r%2Fraylib&logo=reddit)](https://www.reddit.com/r/raylib/) +[![Youtube Subscribers](https://img.shields.io/youtube/channel/subscribers/UC8WIBkhYb5sBNqXO1mZ7WSQ?style=flat&label=Youtube&logo=youtube)](https://www.youtube.com/c/raylib) +[![Twitch Status](https://img.shields.io/twitch/status/raysan5?style=flat&label=Twitch&logo=twitch)](https://www.twitch.tv/raysan5) [![Windows](https://github.com/raysan5/raylib/workflows/Windows/badge.svg)](https://github.com/raysan5/raylib/actions?query=workflow%3AWindows) [![Linux](https://github.com/raysan5/raylib/workflows/Linux/badge.svg)](https://github.com/raysan5/raylib/actions?query=workflow%3ALinux) @@ -36,10 +38,10 @@ features -------- - **NO external dependencies**, all required libraries are [bundled into raylib](https://github.com/raysan5/raylib/tree/master/src/external) - Multiple platforms supported: **Windows, Linux, MacOS, RPI, Android, HTML5... and more!** - - Written in plain C code (C99) in PascalCase/camelCase notation + - Written in plain C code (C99) using PascalCase/camelCase notation - Hardware accelerated with OpenGL (**1.1, 2.1, 3.3, 4.3 or ES 2.0**) - **Unique OpenGL abstraction layer** (usable as standalone module): [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.h) - - Multiple **Fonts** formats supported (TTF, XNA fonts, AngelCode fonts) + - Multiple **Fonts** formats supported (TTF, Image fonts, AngelCode fonts) - Multiple texture formats supported, including **compressed formats** (DXT, ETC, ASTC) - **Full 3D support**, including 3D Shapes, Models, Billboards, Heightmaps and more! - Flexible Materials system, supporting classic maps and **PBR maps** @@ -49,7 +51,7 @@ features - Audio loading and playing with streaming support (WAV, OGG, MP3, FLAC, XM, MOD) - **VR stereo rendering** support with configurable HMD device parameters - Huge examples collection with [+120 code examples](https://github.com/raysan5/raylib/tree/master/examples)! - - Bindings to [+50 programming languages](https://github.com/raysan5/raylib/blob/master/BINDINGS.md)! + - Bindings to [+60 programming languages](https://github.com/raysan5/raylib/blob/master/BINDINGS.md)! - **Free and open source**. basic example @@ -61,25 +63,57 @@ package example import rl "vendor:raylib" main :: proc() { - rl.InitWindow(800, 450, "raylib [core] example - basic window") + rl.InitWindow(800, 450, "raylib [core] example - basic window") - for !rl.WindowShouldClose() { - rl.BeginDrawing() - rl.ClearBackground(rl.RAYWHITE) - rl.DrawText("Congrats! You created your first window!", 190, 200, 20, rl.LIGHTGRAY) - rl.EndDrawing() - } + for !rl.WindowShouldClose() { + rl.BeginDrawing() + rl.ClearBackground(rl.RAYWHITE) + rl.DrawText("Congrats! You created your first window!", 190, 200, 20, rl.LIGHTGRAY) + rl.EndDrawing() + } - rl.CloseWindow() + rl.CloseWindow() } ``` + +build and installation +---------------------- + +raylib binary releases for Windows, Linux, macOS, Android and HTML5 are available at the [Github Releases page](https://github.com/raysan5/raylib/releases). + +raylib is also available via multiple [package managers](https://github.com/raysan5/raylib/issues/613) on multiple OS distributions. + +#### Installing and building raylib on multiple platforms + +[raylib Wiki](https://github.com/raysan5/raylib/wiki#development-platforms) contains detailed instructions on building and usage on multiple platforms. + + - [Working on Windows](https://github.com/raysan5/raylib/wiki/Working-on-Windows) + - [Working on macOS](https://github.com/raysan5/raylib/wiki/Working-on-macOS) + - [Working on GNU Linux](https://github.com/raysan5/raylib/wiki/Working-on-GNU-Linux) + - [Working on Chrome OS](https://github.com/raysan5/raylib/wiki/Working-on-Chrome-OS) + - [Working on FreeBSD](https://github.com/raysan5/raylib/wiki/Working-on-FreeBSD) + - [Working on Raspberry Pi](https://github.com/raysan5/raylib/wiki/Working-on-Raspberry-Pi) + - [Working for Android](https://github.com/raysan5/raylib/wiki/Working-for-Android) + - [Working for Web (HTML5)](https://github.com/raysan5/raylib/wiki/Working-for-Web-(HTML5)) + - [Working anywhere with CMake](https://github.com/raysan5/raylib/wiki/Working-with-CMake) + +*Note that the Wiki is open for edit, if you find some issues while building raylib for your target platform, feel free to edit the Wiki or open an issue related to it.* + +#### Setup raylib with multiple IDEs + +raylib has been developed on Windows platform using [Notepad++](https://notepad-plus-plus.org/) and [MinGW GCC](https://www.mingw-w64.org/) compiler but it can be used with other IDEs on multiple platforms. + +[Projects directory](https://github.com/raysan5/raylib/tree/master/projects) contains several ready-to-use **project templates** to build raylib and code examples with multiple IDEs. + +*Note that there are lots of IDEs supported, some of the provided templates could require some review, so please, if you find some issue with a template or you think they could be improved, feel free to send a PR or open a related issue.* + learning and docs ------------------ -raylib is designed to be learned using [the examples](https://github.com/raysan5/raylib/tree/master/examples) as the main reference. There is no standard API documentation but there is a [**cheatsheet**](https://www.raylib.com/cheatsheet/cheatsheet.html) containing all the functions available on the library and a short description of each one of them, input parameters and result value names should be intuitive enough to understand how each function works. +raylib is designed to be learned using [the examples](https://github.com/raysan5/raylib/tree/master/examples) as the main reference. There is no standard API documentation but there is a [**cheatsheet**](https://www.raylib.com/cheatsheet/cheatsheet.html) containing all the functions available on the library a short description of each one of them, input parameters and result value names should be intuitive enough to understand how each function works. -Some additional documentation about raylib design can be found in raylib GitHub Wiki. Here the more relevant links: +Some additional documentation about raylib design can be found in raylib GitHub Wiki. Here are the relevant links: - [raylib cheatsheet](https://www.raylib.com/cheatsheet/cheatsheet.html) - [raylib architecture](https://github.com/raysan5/raylib/wiki/raylib-architecture) @@ -106,4 +140,4 @@ license raylib is licensed under an unmodified zlib/libpng license, which is an OSI-certified, BSD-like license that allows static linking with closed source software. Check [LICENSE](LICENSE) for further details. -raylib uses internally some libraries for window/graphics/inputs management and also to support different fileformats loading, all those libraries are embedded with and are available in [src/external](https://github.com/raysan5/raylib/tree/master/src/external) directory. Check [raylib dependencies LICENSES](https://github.com/raysan5/raylib/wiki/raylib-dependencies) on raylib Wiki for details. \ No newline at end of file +raylib uses internally some libraries for window/graphics/inputs management and also to support different file formats loading, all those libraries are embedded with and are available in [src/external](https://github.com/raysan5/raylib/tree/master/src/external) directory. Check [raylib dependencies LICENSES](https://github.com/raysan5/raylib/wiki/raylib-dependencies) on raylib Wiki for details. diff --git a/vendor/raylib/linux/libraylib.a b/vendor/raylib/linux/libraylib.a index 1c97be57b..7de8b292c 100644 Binary files a/vendor/raylib/linux/libraylib.a and b/vendor/raylib/linux/libraylib.a differ diff --git a/vendor/raylib/linux/libraylib.so b/vendor/raylib/linux/libraylib.so index 134f573c8..80d5c6ae7 100644 Binary files a/vendor/raylib/linux/libraylib.so and b/vendor/raylib/linux/libraylib.so differ diff --git a/vendor/raylib/linux/libraylib.so.4.0.0 b/vendor/raylib/linux/libraylib.so.4.0.0 deleted file mode 100644 index 134f573c8..000000000 Binary files a/vendor/raylib/linux/libraylib.so.4.0.0 and /dev/null differ diff --git a/vendor/raylib/linux/libraylib.so.4.5.0 b/vendor/raylib/linux/libraylib.so.4.5.0 new file mode 100644 index 000000000..80d5c6ae7 Binary files /dev/null and b/vendor/raylib/linux/libraylib.so.4.5.0 differ diff --git a/vendor/raylib/linux/libraylib.so.400 b/vendor/raylib/linux/libraylib.so.400 deleted file mode 100644 index 134f573c8..000000000 Binary files a/vendor/raylib/linux/libraylib.so.400 and /dev/null differ diff --git a/vendor/raylib/linux/libraylib.so.450 b/vendor/raylib/linux/libraylib.so.450 new file mode 100644 index 000000000..80d5c6ae7 Binary files /dev/null and b/vendor/raylib/linux/libraylib.so.450 differ diff --git a/vendor/raylib/macos-arm64/libraylib.4.0.0.dylib b/vendor/raylib/macos-arm64/libraylib.4.0.0.dylib deleted file mode 100644 index a40219baa..000000000 Binary files a/vendor/raylib/macos-arm64/libraylib.4.0.0.dylib and /dev/null differ diff --git a/vendor/raylib/macos-arm64/libraylib.4.5.0.dylib b/vendor/raylib/macos-arm64/libraylib.4.5.0.dylib new file mode 100644 index 000000000..3a3c76982 Binary files /dev/null and b/vendor/raylib/macos-arm64/libraylib.4.5.0.dylib differ diff --git a/vendor/raylib/macos-arm64/libraylib.400.dylib b/vendor/raylib/macos-arm64/libraylib.400.dylib deleted file mode 100644 index a40219baa..000000000 Binary files a/vendor/raylib/macos-arm64/libraylib.400.dylib and /dev/null differ diff --git a/vendor/raylib/macos-arm64/libraylib.450.dylib b/vendor/raylib/macos-arm64/libraylib.450.dylib new file mode 100644 index 000000000..3a3c76982 Binary files /dev/null and b/vendor/raylib/macos-arm64/libraylib.450.dylib differ diff --git a/vendor/raylib/macos-arm64/libraylib.a b/vendor/raylib/macos-arm64/libraylib.a index 5eddcb8fa..4814819b9 100644 Binary files a/vendor/raylib/macos-arm64/libraylib.a and b/vendor/raylib/macos-arm64/libraylib.a differ diff --git a/vendor/raylib/macos-arm64/libraylib.dylib b/vendor/raylib/macos-arm64/libraylib.dylib index a40219baa..3a3c76982 100644 Binary files a/vendor/raylib/macos-arm64/libraylib.dylib and b/vendor/raylib/macos-arm64/libraylib.dylib differ diff --git a/vendor/raylib/macos/libraylib.4.0.0.dylib b/vendor/raylib/macos/libraylib.4.0.0.dylib deleted file mode 100644 index 42da76800..000000000 Binary files a/vendor/raylib/macos/libraylib.4.0.0.dylib and /dev/null differ diff --git a/vendor/raylib/macos/libraylib.4.5.0.dylib b/vendor/raylib/macos/libraylib.4.5.0.dylib new file mode 100644 index 000000000..3a3c76982 Binary files /dev/null and b/vendor/raylib/macos/libraylib.4.5.0.dylib differ diff --git a/vendor/raylib/macos/libraylib.400.dylib b/vendor/raylib/macos/libraylib.400.dylib deleted file mode 100644 index 42da76800..000000000 Binary files a/vendor/raylib/macos/libraylib.400.dylib and /dev/null differ diff --git a/vendor/raylib/macos/libraylib.450.dylib b/vendor/raylib/macos/libraylib.450.dylib new file mode 100644 index 000000000..3a3c76982 Binary files /dev/null and b/vendor/raylib/macos/libraylib.450.dylib differ diff --git a/vendor/raylib/macos/libraylib.a b/vendor/raylib/macos/libraylib.a index 2ef3e490f..4814819b9 100644 Binary files a/vendor/raylib/macos/libraylib.a and b/vendor/raylib/macos/libraylib.a differ diff --git a/vendor/raylib/macos/libraylib.dylib b/vendor/raylib/macos/libraylib.dylib index 42da76800..3a3c76982 100644 Binary files a/vendor/raylib/macos/libraylib.dylib and b/vendor/raylib/macos/libraylib.dylib differ diff --git a/vendor/raylib/raylib.lib b/vendor/raylib/raylib.lib deleted file mode 100644 index a3c99a25e..000000000 Binary files a/vendor/raylib/raylib.lib and /dev/null differ diff --git a/vendor/raylib/raylib.odin b/vendor/raylib/raylib.odin index 97e800392..2bedf77c4 100644 --- a/vendor/raylib/raylib.odin +++ b/vendor/raylib/raylib.odin @@ -1,79 +1,84 @@ -/********************************************************************************************** -* -* raylib v4.0 - A simple and easy-to-use library to enjoy videogames programming (www.raylib.com) -* -* FEATURES: -* - NO external dependencies, all required libraries included with raylib -* - Multiplatform: Windows, Linux, FreeBSD, OpenBSD, NetBSD, DragonFly, -* MacOS, Haiku, Android, Raspberry Pi, DRM native, HTML5. -* - Written in plain C code (C99) in PascalCase/camelCase notation -* - Hardware accelerated with OpenGL (1.1, 2.1, 3.3, 4.3 or ES2 - choose at compile) -* - Unique OpenGL abstraction layer (usable as standalone module): [rlgl] -* - Multiple Fonts formats supported (TTF, XNA fonts, AngelCode fonts) -* - Outstanding texture formats support, including compressed formats (DXT, ETC, ASTC) -* - Full 3d support for 3d Shapes, Models, Billboards, Heightmaps and more! -* - Flexible Materials system, supporting classic maps and PBR maps -* - Animated 3D models supported (skeletal bones animation) (IQM) -* - Shaders support, including Model shaders and Postprocessing shaders -* - Powerful math module for Vector, Matrix and Quaternion operations: [raymath] -* - Audio loading and playing with streaming support (WAV, OGG, MP3, FLAC, XM, MOD) -* - VR stereo rendering with configurable HMD device parameters -* - Bindings to multiple programming languages available! -* -* NOTES: -* - One default Font is loaded on InitWindow()->LoadFontDefault() [core, text] -* - One default Texture2D is loaded on rlglInit(), 1x1 white pixel R8G8B8A8 [rlgl] (OpenGL 3.3 or ES2) -* - One default Shader is loaded on rlglInit()->rlLoadShaderDefault() [rlgl] (OpenGL 3.3 or ES2) -* - One default RenderBatch is loaded on rlglInit()->rlLoadRenderBatch() [rlgl] (OpenGL 3.3 or ES2) -* -* DEPENDENCIES (included): -* [rcore] rglfw (Camilla Lƶwy - github.com/glfw/glfw) for window/context management and input (PLATFORM_DESKTOP) -* [rlgl] glad (David Herberth - github.com/Dav1dde/glad) for OpenGL 3.3 extensions loading (PLATFORM_DESKTOP) -* [raudio] miniaudio (David Reid - github.com/mackron/miniaudio) for audio device/context management -* -* OPTIONAL DEPENDENCIES (included): -* [rcore] msf_gif (Miles Fogle) for GIF recording -* [rcore] sinfl (Micha Mettke) for DEFLATE decompression algorythm -* [rcore] sdefl (Micha Mettke) for DEFLATE compression algorythm -* [rtextures] stb_image (Sean Barret) for images loading (BMP, TGA, PNG, JPEG, HDR...) -* [rtextures] stb_image_write (Sean Barret) for image writing (BMP, TGA, PNG, JPG) -* [rtextures] stb_image_resize (Sean Barret) for image resizing algorithms -* [rtext] stb_truetype (Sean Barret) for ttf fonts loading -* [rtext] stb_rect_pack (Sean Barret) for rectangles packing -* [rmodels] par_shapes (Philip Rideout) for parametric 3d shapes generation -* [rmodels] tinyobj_loader_c (Syoyo Fujita) for models loading (OBJ, MTL) -* [rmodels] cgltf (Johannes Kuhlmann) for models loading (glTF) -* [raudio] dr_wav (David Reid) for WAV audio file loading -* [raudio] dr_flac (David Reid) for FLAC audio file loading -* [raudio] dr_mp3 (David Reid) for MP3 audio file loading -* [raudio] stb_vorbis (Sean Barret) for OGG audio loading -* [raudio] jar_xm (Joshua Reisenauer) for XM audio module loading -* [raudio] jar_mod (Joshua Reisenauer) for MOD audio module loading -* -* -* LICENSE: zlib/libpng -* -* raylib is licensed under an unmodified zlib/libpng license, which is an OSI-certified, -* BSD-like license that allows static linking with closed source software: -* -* Copyright (c) 2013-2021 Ramon Santamaria (@raysan5) -* -* This software is provided "as-is", without any express or implied warranty. In no event -* will the authors be held liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, including commercial -* applications, and to alter it and redistribute it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not claim that you -* wrote the original software. If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but is not required. -* -* 2. Altered source versions must be plainly marked as such, and must not be misrepresented -* as being the original software. -* -* 3. This notice may not be removed or altered from any source distribution. -* -**********************************************************************************************/ +/* +Package vendor:raylib implements bindings for version 4.5 of the raylib library (https://www.raylib.com/) + + ********************************************************************************************* + * + * raylib v4.5 - A simple and easy-to-use library to enjoy videogames programming (www.raylib.com) + * + * FEATURES: + * - NO external dependencies, all required libraries included with raylib + * - Multiplatform: Windows, Linux, FreeBSD, OpenBSD, NetBSD, DragonFly, + * MacOS, Haiku, Android, Raspberry Pi, DRM native, HTML5. + * - Written in plain C code (C99) in PascalCase/camelCase notation + * - Hardware accelerated with OpenGL (1.1, 2.1, 3.3, 4.3 or ES2 - choose at compile) + * - Unique OpenGL abstraction layer (usable as standalone module): [rlgl] + * - Multiple Fonts formats supported (TTF, XNA fonts, AngelCode fonts) + * - Outstanding texture formats support, including compressed formats (DXT, ETC, ASTC) + * - Full 3d support for 3d Shapes, Models, Billboards, Heightmaps and more! + * - Flexible Materials system, supporting classic maps and PBR maps + * - Animated 3D models supported (skeletal bones animation) (IQM) + * - Shaders support, including Model shaders and Postprocessing shaders + * - Powerful math module for Vector, Matrix and Quaternion operations: [raymath] + * - Audio loading and playing with streaming support (WAV, OGG, MP3, FLAC, XM, MOD) + * - VR stereo rendering with configurable HMD device parameters + * - Bindings to multiple programming languages available! + * + * NOTES: + * - One default Font is loaded on InitWindow()->LoadFontDefault() [core, text] + * - One default Texture2D is loaded on rlglInit(), 1x1 white pixel R8G8B8A8 [rlgl] (OpenGL 3.3 or ES2) + * - One default Shader is loaded on rlglInit()->rlLoadShaderDefault() [rlgl] (OpenGL 3.3 or ES2) + * - One default RenderBatch is loaded on rlglInit()->rlLoadRenderBatch() [rlgl] (OpenGL 3.3 or ES2) + * + * DEPENDENCIES (included): + * [rcore] rglfw (Camilla Lƶwy - github.com/glfw/glfw) for window/context management and input (PLATFORM_DESKTOP) + * [rlgl] glad (David Herberth - github.com/Dav1dde/glad) for OpenGL 3.3 extensions loading (PLATFORM_DESKTOP) + * [raudio] miniaudio (David Reid - github.com/mackron/miniaudio) for audio device/context management + * + * OPTIONAL DEPENDENCIES (included): + * [rcore] msf_gif (Miles Fogle) for GIF recording + * [rcore] sinfl (Micha Mettke) for DEFLATE decompression algorithm + * [rcore] sdefl (Micha Mettke) for DEFLATE compression algorithm + * [rtextures] stb_image (Sean Barret) for images loading (BMP, TGA, PNG, JPEG, HDR...) + * [rtextures] stb_image_write (Sean Barret) for image writing (BMP, TGA, PNG, JPG) + * [rtextures] stb_image_resize (Sean Barret) for image resizing algorithms + * [rtext] stb_truetype (Sean Barret) for ttf fonts loading + * [rtext] stb_rect_pack (Sean Barret) for rectangles packing + * [rmodels] par_shapes (Philip Rideout) for parametric 3d shapes generation + * [rmodels] tinyobj_loader_c (Syoyo Fujita) for models loading (OBJ, MTL) + * [rmodels] cgltf (Johannes Kuhlmann) for models loading (glTF) + * [rmodels] Model3D (bzt) for models loading (M3D, https://bztsrc.gitlab.io/model3d) + * [raudio] dr_wav (David Reid) for WAV audio file loading + * [raudio] dr_flac (David Reid) for FLAC audio file loading + * [raudio] dr_mp3 (David Reid) for MP3 audio file loading + * [raudio] stb_vorbis (Sean Barret) for OGG audio loading + * [raudio] jar_xm (Joshua Reisenauer) for XM audio module loading + * [raudio] jar_mod (Joshua Reisenauer) for MOD audio module loading + * + * + * LICENSE: zlib/libpng + * + * raylib is licensed under an unmodified zlib/libpng license, which is an OSI-certified, + * BSD-like license that allows static linking with closed source software: + * + * Copyright (c) 2013-2023 Ramon Santamaria (@raysan5) + * + * This software is provided "as-is", without any express or implied warranty. In no event + * will the authors be held liable for any damages arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, including commercial + * applications, and to alter it and redistribute it freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not claim that you + * wrote the original software. If you use this software in a product, an acknowledgment + * in the product documentation would be appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be misrepresented + * as being the original software. + * + * 3. This notice may not be removed or altered from any source distribution. + * + ********************************************************************************************* +*/ package raylib import c "core:c/libc" @@ -92,8 +97,9 @@ MAX_TEXT_BUFFER_LENGTH :: #config(RAYLIB_MAX_TEXT_BUFFER_LENGTH, 1024) #assert(size_of(rune) == size_of(c.int)) when ODIN_OS == .Windows { + @(extra_linker_flags="/NODEFAULTLIB:libcmt") foreign import lib { - "raylib.lib", + "windows/raylib.lib", "system:Winmm.lib", "system:Gdi32.lib", "system:User32.lib", @@ -125,7 +131,7 @@ when ODIN_OS == .Windows { foreign import lib "system:raylib" } -VERSION :: "4.0" +VERSION :: "4.5" PI :: 3.14159265358979323846 DEG2RAD :: PI/180.0 @@ -277,8 +283,6 @@ Font :: struct { chars: [^]GlyphInfo, // Characters info data } -SpriteFont :: Font // SpriteFont type fallback, defaults to Font - // Camera type, defines a camera position/orientation in 3d space Camera3D :: struct { position: Vector3, // Camera position @@ -316,7 +320,7 @@ Mesh :: struct { // Animation vertex data animVertices: [^]f32, // Animated vertex positions (after bones transformations) animNormals: [^]f32, // Animated normals (after bones transformations) - boneIds: [^]c.int, // Vertex bone ids, up to 4 bones influence by vertex (skinning) + boneIds: [^]u8, // Vertex bone ids, up to 4 bones influence by vertex (skinning) boneWeights: [^]f32, // Vertex bone weight, up to 4 bones influence by vertex (skinning) // OpenGL identifiers @@ -327,7 +331,7 @@ Mesh :: struct { // Shader type (generic) Shader :: struct { id: c.uint, // Shader program id - locs: [^]i32, // Shader locations array (MAX_SHADER_LOCATIONS) + locs: [^]c.int, // Shader locations array (MAX_SHADER_LOCATIONS) } // Material texture map @@ -353,7 +357,7 @@ Transform :: struct { // Bone information BoneInfo :: struct { - name: [32]byte, // Bone name + name: [32]byte `fmt:"s,0"`, // Bone name parent: c.int, // Bone parent } @@ -378,7 +382,7 @@ ModelAnimation :: struct { boneCount: c.int, // Number of bones frameCount: c.int, // Number of animation frames bones: [^]BoneInfo, // Bones information (skeleton) - framePoses: [^]^Transform, // Poses array by frame + framePoses: [^][^]Transform, // Poses array by frame } // Ray type (useful for raycast) @@ -403,7 +407,7 @@ BoundingBox :: struct { // Wave type, defines audio wave data Wave :: struct { - sampleCount: c.uint, // Total number of samples + frameCount: c.uint, // Total number of frames (considering channels) sampleRate: c.uint, // Frequency (samples per second) sampleSize: c.uint, // Bit depth (bits per sample): 8, 16, 32 (24 not supported) channels: c.uint, // Number of channels (1-mono, 2-stereo) @@ -411,9 +415,10 @@ Wave :: struct { } // Audio stream type -// NOTE: Useful to create custom audio streams not bound to a specific file +// NOTE: Actual structs are defined internally in raudio module AudioStream :: struct { buffer: rawptr, // Pointer to internal data used by the audio system + processor: rawptr, // Pointer to internal data processor, useful for audio effects sampleRate: c.uint, // Frequency (samples per second) sampleSize: c.uint, // Bit depth (bits per sample): 8, 16, 32 (24 not supported) @@ -423,14 +428,14 @@ AudioStream :: struct { // Sound source type Sound :: struct { using stream: AudioStream, // Audio stream - sampleCount: c.uint, // Total number of samples + frameCount: c.uint, // Total number of frames (considering channels) } // Music stream type (audio file streaming from memory) // NOTE: Anything longer than ~10 seconds should be streamed Music :: struct { using stream: AudioStream, // Audio stream - sampleCount: c.uint, // Total number of samples + frameCount: c.uint, // Total number of frames (considering channels) looping: bool, // Music looping enable ctxType: c.int, // Type of music context (audio filetype) @@ -463,6 +468,13 @@ VrStereoConfig :: struct { scaleIn: [2]f32, // VR distortion scale in } +// File path list +FilePathList :: struct { + capacity: c.uint, // Filepaths max entries + count: c.uint, // Filepaths entries count + paths: [^]cstring, // Filepaths entries +} + //---------------------------------------------------------------------------------- // Enumerators Definition @@ -471,403 +483,380 @@ VrStereoConfig :: struct { // NOTE: Every bit registers one state (use it with bit masks) // By default all flags are set to 0 ConfigFlag :: enum c.int { - VSYNC_HINT = 6, // Set to try enabling V-Sync on GPU - FULLSCREEN_MODE = 1, // Set to run program in fullscreen - WINDOW_RESIZABLE = 2, // Set to allow resizable window - WINDOW_UNDECORATED = 3, // Set to disable window decoration (frame and buttons) - WINDOW_HIDDEN = 7, // Set to hide window - WINDOW_MINIMIZED = 9, // Set to minimize window (iconify) - WINDOW_MAXIMIZED = 10, // Set to maximize window (expanded to monitor) - WINDOW_UNFOCUSED = 11, // Set to window non focused - WINDOW_TOPMOST = 12, // Set to window always on top - WINDOW_ALWAYS_RUN = 8, // Set to allow windows running while minimized - WINDOW_TRANSPARENT = 4, // Set to allow transparent framebuffer - WINDOW_HIGHDPI = 13, // Set to support HighDPI - MSAA_4X_HINT = 5, // Set to try enabling MSAA 4X - INTERLACED_HINT = 16, // Set to try enabling interlaced video format (for V3D) + VSYNC_HINT = 6, // Set to try enabling V-Sync on GPU + FULLSCREEN_MODE = 1, // Set to run program in fullscreen + WINDOW_RESIZABLE = 2, // Set to allow resizable window + WINDOW_UNDECORATED = 3, // Set to disable window decoration (frame and buttons) + WINDOW_HIDDEN = 7, // Set to hide window + WINDOW_MINIMIZED = 9, // Set to minimize window (iconify) + WINDOW_MAXIMIZED = 10, // Set to maximize window (expanded to monitor) + WINDOW_UNFOCUSED = 11, // Set to window non focused + WINDOW_TOPMOST = 12, // Set to window always on top + WINDOW_ALWAYS_RUN = 8, // Set to allow windows running while minimized + WINDOW_TRANSPARENT = 4, // Set to allow transparent framebuffer + WINDOW_HIGHDPI = 13, // Set to support HighDPI + WINDOW_MOUSE_PASSTHROUGH = 14, // Set to support mouse passthrough, only supported when FLAG_WINDOW_UNDECORATED + MSAA_4X_HINT = 5, // Set to try enabling MSAA 4X + INTERLACED_HINT = 16, // Set to try enabling interlaced video format (for V3D) } ConfigFlags :: distinct bit_set[ConfigFlag; c.int] // Trace log level TraceLogLevel :: enum c.int { - ALL = 0, // Display all logs - TRACE, - DEBUG, - INFO, - WARNING, - ERROR, - FATAL, - NONE, // Disable logging + ALL = 0, // Display all logs + TRACE, // Trace logging, intended for internal use only + DEBUG, // Debug logging, used for internal debugging, it should be disabled on release builds + INFO, // Info logging, used for program execution info + WARNING, // Warning logging, used on recoverable failures + ERROR, // Error logging, used on unrecoverable failures + FATAL, // Fatal logging, used to abort program: exit(EXIT_FAILURE) + NONE, // Disable logging } // Keyboard keys (US keyboard layout) // NOTE: Use GetKeyPressed() to allow redefining // required keys for alternative layouts KeyboardKey :: enum c.int { - NULL = 0, + KEY_NULL = 0, // Key: NULL, used for no key pressed // Alphanumeric keys - APOSTROPHE = 39, - COMMA = 44, - MINUS = 45, - PERIOD = 46, - SLASH = 47, - ZERO = 48, - ONE = 49, - TWO = 50, - THREE = 51, - FOUR = 52, - FIVE = 53, - SIX = 54, - SEVEN = 55, - EIGHT = 56, - NINE = 57, - SEMICOLON = 59, - EQUAL = 61, - A = 65, - B = 66, - C = 67, - D = 68, - E = 69, - F = 70, - G = 71, - H = 72, - I = 73, - J = 74, - K = 75, - L = 76, - M = 77, - N = 78, - O = 79, - P = 80, - Q = 81, - R = 82, - S = 83, - T = 84, - U = 85, - V = 86, - W = 87, - X = 88, - Y = 89, - Z = 90, - + APOSTROPHE = 39, // Key: ' + COMMA = 44, // Key: , + MINUS = 45, // Key: - + PERIOD = 46, // Key: . + SLASH = 47, // Key: / + ZERO = 48, // Key: 0 + ONE = 49, // Key: 1 + TWO = 50, // Key: 2 + THREE = 51, // Key: 3 + FOUR = 52, // Key: 4 + FIVE = 53, // Key: 5 + SIX = 54, // Key: 6 + SEVEN = 55, // Key: 7 + EIGHT = 56, // Key: 8 + NINE = 57, // Key: 9 + SEMICOLON = 59, // Key: ; + EQUAL = 61, // Key: = + A = 65, // Key: A | a + B = 66, // Key: B | b + C = 67, // Key: C | c + D = 68, // Key: D | d + E = 69, // Key: E | e + F = 70, // Key: F | f + G = 71, // Key: G | g + H = 72, // Key: H | h + I = 73, // Key: I | i + J = 74, // Key: J | j + K = 75, // Key: K | k + L = 76, // Key: L | l + M = 77, // Key: M | m + N = 78, // Key: N | n + O = 79, // Key: O | o + P = 80, // Key: P | p + Q = 81, // Key: Q | q + R = 82, // Key: R | r + S = 83, // Key: S | s + T = 84, // Key: T | t + U = 85, // Key: U | u + V = 86, // Key: V | v + W = 87, // Key: W | w + X = 88, // Key: X | x + Y = 89, // Key: Y | y + Z = 90, // Key: Z | z + LEFT_BRACKET = 91, // Key: [ + BACKSLASH = 92, // Key: '\' + RIGHT_BRACKET = 93, // Key: ] + GRAVE = 96, // Key: ` // Function keys - SPACE = 32, - ESCAPE = 256, - ENTER = 257, - TAB = 258, - BACKSPACE = 259, - INSERT = 260, - DELETE = 261, - RIGHT = 262, - LEFT = 263, - DOWN = 264, - UP = 265, - PAGE_UP = 266, - PAGE_DOWN = 267, - HOME = 268, - END = 269, - CAPS_LOCK = 280, - SCROLL_LOCK = 281, - NUM_LOCK = 282, - PRINT_SCREEN = 283, - PAUSE = 284, - F1 = 290, - F2 = 291, - F3 = 292, - F4 = 293, - F5 = 294, - F6 = 295, - F7 = 296, - F8 = 297, - F9 = 298, - F10 = 299, - F11 = 300, - F12 = 301, - LEFT_SHIFT = 340, - LEFT_CONTROL = 341, - LEFT_ALT = 342, - LEFT_SUPER = 343, - RIGHT_SHIFT = 344, - RIGHT_CONTROL = 345, - RIGHT_ALT = 346, - RIGHT_SUPER = 347, - KB_MENU = 348, - LEFT_BRACKET = 91, - BACKSLASH = 92, - RIGHT_BRACKET = 93, - GRAVE = 96, - + SPACE = 32, // Key: Space + ESCAPE = 256, // Key: Esc + ENTER = 257, // Key: Enter + TAB = 258, // Key: Tab + BACKSPACE = 259, // Key: Backspace + INSERT = 260, // Key: Ins + DELETE = 261, // Key: Del + RIGHT = 262, // Key: Cursor right + LEFT = 263, // Key: Cursor left + DOWN = 264, // Key: Cursor down + UP = 265, // Key: Cursor up + PAGE_UP = 266, // Key: Page up + PAGE_DOWN = 267, // Key: Page down + HOME = 268, // Key: Home + END = 269, // Key: End + CAPS_LOCK = 280, // Key: Caps lock + SCROLL_LOCK = 281, // Key: Scroll down + NUM_LOCK = 282, // Key: Num lock + PRINT_SCREEN = 283, // Key: Print screen + PAUSE = 284, // Key: Pause + F1 = 290, // Key: F1 + F2 = 291, // Key: F2 + F3 = 292, // Key: F3 + F4 = 293, // Key: F4 + F5 = 294, // Key: F5 + F6 = 295, // Key: F6 + F7 = 296, // Key: F7 + F8 = 297, // Key: F8 + F9 = 298, // Key: F9 + F10 = 299, // Key: F10 + F11 = 300, // Key: F11 + F12 = 301, // Key: F12 + LEFT_SHIFT = 340, // Key: Shift left + LEFT_CONTROL = 341, // Key: Control left + LEFT_ALT = 342, // Key: Alt left + LEFT_SUPER = 343, // Key: Super left + RIGHT_SHIFT = 344, // Key: Shift right + RIGHT_CONTROL = 345, // Key: Control right + RIGHT_ALT = 346, // Key: Alt right + RIGHT_SUPER = 347, // Key: Super right + KB_MENU = 348, // Key: KB menu // Keypad keys - KP_0 = 320, - KP_1 = 321, - KP_2 = 322, - KP_3 = 323, - KP_4 = 324, - KP_5 = 325, - KP_6 = 326, - KP_7 = 327, - KP_8 = 328, - KP_9 = 329, - KP_DECIMAL = 330, - KP_DIVIDE = 331, - KP_MULTIPLY = 332, - KP_SUBTRACT = 333, - KP_ADD = 334, - KP_ENTER = 335, - KP_EQUAL = 336, + KP_0 = 320, // Key: Keypad 0 + KP_1 = 321, // Key: Keypad 1 + KP_2 = 322, // Key: Keypad 2 + KP_3 = 323, // Key: Keypad 3 + KP_4 = 324, // Key: Keypad 4 + KP_5 = 325, // Key: Keypad 5 + KP_6 = 326, // Key: Keypad 6 + KP_7 = 327, // Key: Keypad 7 + KP_8 = 328, // Key: Keypad 8 + KP_9 = 329, // Key: Keypad 9 + KP_DECIMAL = 330, // Key: Keypad . + KP_DIVIDE = 331, // Key: Keypad / + KP_MULTIPLY = 332, // Key: Keypad * + KP_SUBTRACT = 333, // Key: Keypad - + KP_ADD = 334, // Key: Keypad + + KP_ENTER = 335, // Key: Keypad Enter + KP_EQUAL = 336, // Key: Keypad = // Android key buttons - BACK = 4, - MENU = 82, - VOLUME_UP = 24, - VOLUME_DOWN = 25, + BACK = 4, // Key: Android back button + MENU = 82, // Key: Android menu button + VOLUME_UP = 24, // Key: Android volume up button + VOLUME_DOWN = 25, // Key: Android volume down button } // Mouse buttons MouseButton :: enum c.int { - LEFT = 0, // Mouse button left - RIGHT = 1, // Mouse button right - MIDDLE = 2, // Mouse button middle (pressed wheel) - SIDE = 3, // Mouse button side (advanced mouse device) - EXTRA = 4, // Mouse button extra (advanced mouse device) - FORWARD = 5, // Mouse button fordward (advanced mouse device) - BACK = 6, // Mouse button back (advanced mouse device) + LEFT = 0, // Mouse button left + RIGHT = 1, // Mouse button right + MIDDLE = 2, // Mouse button middle (pressed wheel) + SIDE = 3, // Mouse button side (advanced mouse device) + EXTRA = 4, // Mouse button extra (advanced mouse device) + FORWARD = 5, // Mouse button fordward (advanced mouse device) + BACK = 6, // Mouse button back (advanced mouse device) } // Mouse cursor MouseCursor :: enum c.int { - DEFAULT = 0, - ARROW = 1, - IBEAM = 2, - CROSSHAIR = 3, - POINTING_HAND = 4, - RESIZE_EW = 5, // The horizontal resize/move arrow shape - RESIZE_NS = 6, // The vertical resize/move arrow shape - RESIZE_NWSE = 7, // The top-left to bottom-right diagonal resize/move arrow shape - RESIZE_NESW = 8, // The top-right to bottom-left diagonal resize/move arrow shape - RESIZE_ALL = 9, // The omni-directional resize/move cursor shape - NOT_ALLOWED = 10, // The operation-not-allowed shape + DEFAULT = 0, // Default pointer shape + ARROW = 1, // Arrow shape + IBEAM = 2, // Text writing cursor shape + CROSSHAIR = 3, // Cross shape + POINTING_HAND = 4, // Pointing hand cursor + RESIZE_EW = 5, // Horizontal resize/move arrow shape + RESIZE_NS = 6, // Vertical resize/move arrow shape + RESIZE_NWSE = 7, // Top-left to bottom-right diagonal resize/move arrow shape + RESIZE_NESW = 8, // The top-right to bottom-left diagonal resize/move arrow shape + RESIZE_ALL = 9, // The omnidirectional resize/move cursor shape + NOT_ALLOWED = 10, // The operation-not-allowed shape } // Gamepad buttons GamepadButton :: enum c.int { - // This is here just for error checking - UNKNOWN = 0, - - // This is normally a DPAD - LEFT_FACE_UP, - LEFT_FACE_RIGHT, - LEFT_FACE_DOWN, - LEFT_FACE_LEFT, - - // This normally corresponds with PlayStation and Xbox controllers - // XBOX: [Y,X,A,B] - // PS3: [Triangle,Square,Cross,Circle] - // No support for 6 button controllers though.. - RIGHT_FACE_UP, - RIGHT_FACE_RIGHT, - RIGHT_FACE_DOWN, - RIGHT_FACE_LEFT, - - // Triggers - LEFT_TRIGGER_1, - LEFT_TRIGGER_2, - RIGHT_TRIGGER_1, - RIGHT_TRIGGER_2, - - // These are buttons in the center of the gamepad - MIDDLE_LEFT, // PS3 Select - MIDDLE, // PS Button/XBOX Button - MIDDLE_RIGHT, // PS3 Start - - // These are the joystick press in buttons - LEFT_THUMB, - RIGHT_THUMB, + UNKNOWN = 0, // Unknown button, just for error checking + LEFT_FACE_UP, // Gamepad left DPAD up button + LEFT_FACE_RIGHT, // Gamepad left DPAD right button + LEFT_FACE_DOWN, // Gamepad left DPAD down button + LEFT_FACE_LEFT, // Gamepad left DPAD left button + RIGHT_FACE_UP, // Gamepad right button up (i.e. PS3: Triangle, Xbox: Y) + RIGHT_FACE_RIGHT, // Gamepad right button right (i.e. PS3: Square, Xbox: X) + RIGHT_FACE_DOWN, // Gamepad right button down (i.e. PS3: Cross, Xbox: A) + RIGHT_FACE_LEFT, // Gamepad right button left (i.e. PS3: Circle, Xbox: B) + LEFT_TRIGGER_1, // Gamepad top/back trigger left (first), it could be a trailing button + LEFT_TRIGGER_2, // Gamepad top/back trigger left (second), it could be a trailing button + RIGHT_TRIGGER_1, // Gamepad top/back trigger right (one), it could be a trailing button + RIGHT_TRIGGER_2, // Gamepad top/back trigger right (second), it could be a trailing button + MIDDLE_LEFT, // Gamepad center buttons, left one (i.e. PS3: Select) + MIDDLE, // Gamepad center buttons, middle one (i.e. PS3: PS, Xbox: XBOX) + MIDDLE_RIGHT, // Gamepad center buttons, right one (i.e. PS3: Start) + LEFT_THUMB, // Gamepad joystick pressed button left + RIGHT_THUMB, // Gamepad joystick pressed button right } // Gamepad axis GamepadAxis :: enum c.int { - // Left stick - LEFT_X = 0, - LEFT_Y = 1, - - // Right stick - RIGHT_X = 2, - RIGHT_Y = 3, - - // Pressure levels for the back triggers - LEFT_TRIGGER = 4, // [1..-1] (pressure-level) - RIGHT_TRIGGER = 5, // [1..-1] (pressure-level) + LEFT_X = 0, // Gamepad left stick X axis + LEFT_Y = 1, // Gamepad left stick Y axis + RIGHT_X = 2, // Gamepad right stick X axis + RIGHT_Y = 3, // Gamepad right stick Y axis + LEFT_TRIGGER = 4, // Gamepad back trigger left, pressure level: [1..-1] + RIGHT_TRIGGER = 5, // Gamepad back trigger right, pressure level: [1..-1] } // Material map index MaterialMapIndex :: enum c.int { - ALBEDO = 0, // MATERIAL_MAP_DIFFUSE - METALNESS = 1, // MATERIAL_MAP_SPECULAR - NORMAL = 2, - ROUGHNESS = 3, - OCCLUSION, - EMISSION, - HEIGHT, - BRDG, - CUBEMAP, // NOTE: Uses GL_TEXTURE_CUBE_MAP - IRRADIANCE, // NOTE: Uses GL_TEXTURE_CUBE_MAP - PREFILTER, // NOTE: Uses GL_TEXTURE_CUBE_MAP - - DIFFUSE = ALBEDO, - SPECULAR = METALNESS, + ALBEDO = 0, // Albedo material (same as: MATERIAL_MAP_DIFFUSE) + METALNESS, // Metalness material (same as: MATERIAL_MAP_SPECULAR) + NORMAL, // Normal material + ROUGHNESS, // Roughness material + OCCLUSION, // Ambient occlusion material + EMISSION, // Emission material + HEIGHT, // Heightmap material + CUBEMAP, // Cubemap material (NOTE: Uses GL_TEXTURE_CUBE_MAP) + IRRADIANCE, // Irradiance material (NOTE: Uses GL_TEXTURE_CUBE_MAP) + PREFILTER, // Prefilter material (NOTE: Uses GL_TEXTURE_CUBE_MAP) + BRDF, // Brdf material } // Shader location index ShaderLocationIndex :: enum c.int { - VERTEX_POSITION = 0, - VERTEX_TEXCOORD01, - VERTEX_TEXCOORD02, - VERTEX_NORMAL, - VERTEX_TANGENT, - VERTEX_COLOR, - MATRIX_MVP, - MATRIX_VIEW, - MATRIX_PROJECTION, - MATRIX_MODEL, - MATRIX_NORMAL, - VECTOR_VIEW, - COLOR_DIFFUSE, - COLOR_SPECULAR, - COLOR_AMBIENT, - MAP_ALBEDO, - MAP_METALNESS, - MAP_NORMAL, - MAP_ROUGHNESS, - MAP_OCCLUSION, - MAP_EMISSION, - MAP_HEIGHT, - MAP_CUBEMAP, - MAP_IRRADIANCE, - MAP_PREFILTER, - MAP_BRDF, - - MAP_DIFFUSE = MAP_ALBEDO, - MAP_SPECULAR = MAP_METALNESS, + VERTEX_POSITION = 0, // Shader location: vertex attribute: position + VERTEX_TEXCOORD01, // Shader location: vertex attribute: texcoord01 + VERTEX_TEXCOORD02, // Shader location: vertex attribute: texcoord02 + VERTEX_NORMAL, // Shader location: vertex attribute: normal + VERTEX_TANGENT, // Shader location: vertex attribute: tangent + VERTEX_COLOR, // Shader location: vertex attribute: color + MATRIX_MVP, // Shader location: matrix uniform: model-view-projection + MATRIX_VIEW, // Shader location: matrix uniform: view (camera transform) + MATRIX_PROJECTION, // Shader location: matrix uniform: projection + MATRIX_MODEL, // Shader location: matrix uniform: model (transform) + MATRIX_NORMAL, // Shader location: matrix uniform: normal + VECTOR_VIEW, // Shader location: vector uniform: view + COLOR_DIFFUSE, // Shader location: vector uniform: diffuse color + COLOR_SPECULAR, // Shader location: vector uniform: specular color + COLOR_AMBIENT, // Shader location: vector uniform: ambient color + MAP_ALBEDO, // Shader location: sampler2d texture: albedo (same as: SHADER_LOC_MAP_DIFFUSE) + MAP_METALNESS, // Shader location: sampler2d texture: metalness (same as: SHADER_LOC_MAP_SPECULAR) + MAP_NORMAL, // Shader location: sampler2d texture: normal + MAP_ROUGHNESS, // Shader location: sampler2d texture: roughness + MAP_OCCLUSION, // Shader location: sampler2d texture: occlusion + MAP_EMISSION, // Shader location: sampler2d texture: emission + MAP_HEIGHT, // Shader location: sampler2d texture: height + MAP_CUBEMAP, // Shader location: samplerCube texture: cubemap + MAP_IRRADIANCE, // Shader location: samplerCube texture: irradiance + MAP_PREFILTER, // Shader location: samplerCube texture: prefilter + MAP_BRDF, // Shader location: sampler2d texture: brdf } // Shader uniform data type ShaderUniformDataType :: enum c.int { - FLOAT = 0, - VEC2, - VEC3, - VEC4, - INT, - IVEC2, - IVEC3, - IVEC4, - SAMPLER2D, + FLOAT = 0, // Shader uniform type: float + VEC2, // Shader uniform type: vec2 (2 float) + VEC3, // Shader uniform type: vec3 (3 float) + VEC4, // Shader uniform type: vec4 (4 float) + INT, // Shader uniform type: int + IVEC2, // Shader uniform type: ivec2 (2 int) + IVEC3, // Shader uniform type: ivec3 (3 int) + IVEC4, // Shader uniform type: ivec4 (4 int) + SAMPLER2D, // Shader uniform type: sampler2d } // Pixel formats // NOTE: Support depends on OpenGL version and platform PixelFormat :: enum c.int { - UNCOMPRESSED_GRAYSCALE = 1, // 8 bit per pixel (no alpha) - UNCOMPRESSED_GRAY_ALPHA, // 8*2 bpp (2 channels) - UNCOMPRESSED_R5G6B5, // 16 bpp - UNCOMPRESSED_R8G8B8, // 24 bpp - UNCOMPRESSED_R5G5B5A1, // 16 bpp (1 bit alpha) - UNCOMPRESSED_R4G4B4A4, // 16 bpp (4 bit alpha) - UNCOMPRESSED_R8G8B8A8, // 32 bpp - UNCOMPRESSED_R32, // 32 bpp (1 channel - float) - UNCOMPRESSED_R32G32B32, // 32*3 bpp (3 channels - float) - UNCOMPRESSED_R32G32B32A32, // 32*4 bpp (4 channels - float) - COMPRESSED_DXT1_RGB, // 4 bpp (no alpha) - COMPRESSED_DXT1_RGBA, // 4 bpp (1 bit alpha) - COMPRESSED_DXT3_RGBA, // 8 bpp - COMPRESSED_DXT5_RGBA, // 8 bpp - COMPRESSED_ETC1_RGB, // 4 bpp - COMPRESSED_ETC2_RGB, // 4 bpp - COMPRESSED_ETC2_EAC_RGBA, // 8 bpp - COMPRESSED_PVRT_RGB, // 4 bpp - COMPRESSED_PVRT_RGBA, // 4 bpp - COMPRESSED_ASTC_4x4_RGBA, // 8 bpp - COMPRESSED_ASTC_8x8_RGBA, // 2 bpp + UNKNOWN = 0, + UNCOMPRESSED_GRAYSCALE = 1, // 8 bit per pixel (no alpha) + UNCOMPRESSED_GRAY_ALPHA, // 8*2 bpp (2 channels) + UNCOMPRESSED_R5G6B5, // 16 bpp + UNCOMPRESSED_R8G8B8, // 24 bpp + UNCOMPRESSED_R5G5B5A1, // 16 bpp (1 bit alpha) + UNCOMPRESSED_R4G4B4A4, // 16 bpp (4 bit alpha) + UNCOMPRESSED_R8G8B8A8, // 32 bpp + UNCOMPRESSED_R32, // 32 bpp (1 channel - float) + UNCOMPRESSED_R32G32B32, // 32*3 bpp (3 channels - float) + UNCOMPRESSED_R32G32B32A32, // 32*4 bpp (4 channels - float) + COMPRESSED_DXT1_RGB, // 4 bpp (no alpha) + COMPRESSED_DXT1_RGBA, // 4 bpp (1 bit alpha) + COMPRESSED_DXT3_RGBA, // 8 bpp + COMPRESSED_DXT5_RGBA, // 8 bpp + COMPRESSED_ETC1_RGB, // 4 bpp + COMPRESSED_ETC2_RGB, // 4 bpp + COMPRESSED_ETC2_EAC_RGBA, // 8 bpp + COMPRESSED_PVRT_RGB, // 4 bpp + COMPRESSED_PVRT_RGBA, // 4 bpp + COMPRESSED_ASTC_4x4_RGBA, // 8 bpp + COMPRESSED_ASTC_8x8_RGBA, // 2 bpp } // Texture parameters: filter mode // NOTE 1: Filtering considers mipmaps if available in the texture // NOTE 2: Filter is accordingly set for minification and magnification TextureFilter :: enum c.int { - POINT = 0, // No filter, just pixel aproximation - BILINEAR, // Linear filtering - TRILINEAR, // Trilinear filtering (linear with mipmaps) - ANISOTROPIC_4X, // Anisotropic filtering 4x - ANISOTROPIC_8X, // Anisotropic filtering 8x - ANISOTROPIC_16X, // Anisotropic filtering 16x + POINT = 0, // No filter, just pixel approximation + BILINEAR, // Linear filtering + TRILINEAR, // Trilinear filtering (linear with mipmaps) + ANISOTROPIC_4X, // Anisotropic filtering 4x + ANISOTROPIC_8X, // Anisotropic filtering 8x + ANISOTROPIC_16X, // Anisotropic filtering 16x } // Texture parameters: wrap mode TextureWrap :: enum c.int { - REPEAT = 0, // Repeats texture in tiled mode - CLAMP, // Clamps texture to edge pixel in tiled mode - MIRROR_REPEAT, // Mirrors and repeats the texture in tiled mode - MIRROR_CLAMP, // Mirrors and clamps to border the texture in tiled mode + REPEAT = 0, // Repeats texture in tiled mode + CLAMP, // Clamps texture to edge pixel in tiled mode + MIRROR_REPEAT, // Mirrors and repeats the texture in tiled mode + MIRROR_CLAMP, // Mirrors and clamps to border the texture in tiled mode } // Cubemap layouts CubemapLayout :: enum c.int { - AUTO_DETECT = 0, // Automatically detect layout type - LINE_VERTICAL, // Layout is defined by a vertical line with faces - LINE_HORIZONTAL, // Layout is defined by an horizontal line with faces - CROSS_THREE_BY_FOUR, // Layout is defined by a 3x4 cross with cubemap faces - CROSS_FOUR_BY_THREE, // Layout is defined by a 4x3 cross with cubemap faces - PANORAMA, // Layout is defined by a panorama image (equirectangular map) + AUTO_DETECT = 0, // Automatically detect layout type + LINE_VERTICAL, // Layout is defined by a vertical line with faces + LINE_HORIZONTAL, // Layout is defined by an horizontal line with faces + CROSS_THREE_BY_FOUR, // Layout is defined by a 3x4 cross with cubemap faces + CROSS_FOUR_BY_THREE, // Layout is defined by a 4x3 cross with cubemap faces + PANORAMA, // Layout is defined by a panorama image (equirectangular map) } // Font type, defines generation method FontType :: enum c.int { - DEFAULT = 0, // Default font generation, anti-aliased - BITMAP, // Bitmap font generation, no anti-aliasing - SDF, // SDF font generation, requires external shader + DEFAULT = 0, // Default font generation, anti-aliased + BITMAP, // Bitmap font generation, no anti-aliasing + SDF, // SDF font generation, requires external shader } // Color blending modes (pre-defined) BlendMode :: enum c.int { - ALPHA = 0, // Blend textures considering alpha (default) - ADDITIVE, // Blend textures adding colors - MULTIPLIED, // Blend textures multiplying colors - ADD_COLORS, // Blend textures adding colors (alternative) - SUBTRACT_COLORS, // Blend textures subtracting colors (alternative) - CUSTOM, // Belnd textures using custom src/dst factors (use rlSetBlendMode()) + ALPHA = 0, // Blend textures considering alpha (default) + ADDITIVE, // Blend textures adding colors + MULTIPLIED, // Blend textures multiplying colors + ADD_COLORS, // Blend textures adding colors (alternative) + SUBTRACT_COLORS, // Blend textures subtracting colors (alternative) + ALPHA_PREMULTIPLY, // Blend premultiplied textures considering alpha + CUSTOM, // Blend textures using custom src/dst factors (use rlSetBlendFactors()) + CUSTOM_SEPARATE, // Blend textures using custom rgb/alpha separate src/dst factors (use rlSetBlendFactorsSeparate()) } // Gestures // NOTE: It could be used as flags to enable only some gestures Gesture :: enum c.int { - TAP = 0, - DOUBLETAP = 1, - HOLD = 2, - DRAG = 3, - SWIPE_RIGHT = 4, - SWIPE_LEFT = 5, - SWIPE_UP = 6, - SWIPE_DOWN = 7, - PINCH_IN = 8, - PINCH_OUT = 9, + TAP = 0, // Tap gesture + DOUBLETAP = 1, // Double tap gesture + HOLD = 2, // Hold gesture + DRAG = 3, // Drag gesture + SWIPE_RIGHT = 4, // Swipe right gesture + SWIPE_LEFT = 5, // Swipe left gesture + SWIPE_UP = 6, // Swipe up gesture + SWIPE_DOWN = 7, // Swipe down gesture + PINCH_IN = 8, // Pinch in gesture + PINCH_OUT = 9, // Pinch out gesture } Gestures :: distinct bit_set[Gesture; c.int] // Camera system modes CameraMode :: enum c.int { - CUSTOM = 0, - FREE, - ORBITAL, - FIRST_PERSON, - THIRD_PERSON, + CUSTOM = 0, // Custom camera + FREE, // Free camera + ORBITAL, // Orbital camera + FIRST_PERSON, // First person camera + THIRD_PERSON, // Third person camera } // Camera projection CameraProjection :: enum c.int { - PERSPECTIVE = 0, - ORTHOGRAPHIC, + PERSPECTIVE = 0, // Perspective projection + ORTHOGRAPHIC, // Orthographic projection } // N-patch layout @@ -881,12 +870,14 @@ NPatchLayout :: enum c.int { // Callbacks to hook some internal functions // WARNING: This callbacks are intended for advance users -TraceLogCallback :: #type proc "c" (logLevel: TraceLogLevel, text: cstring, args: c.va_list) // Logging: Redirect trace log messages +TraceLogCallback :: #type proc "c" (logLevel: TraceLogLevel, text: cstring, args: c.va_list) // Logging: Redirect trace log messages LoadFileDataCallback :: #type proc "c"(fileName: cstring, bytesRead: ^c.uint) -> [^]u8 // FileIO: Load binary data SaveFileDataCallback :: #type proc "c" (fileName: cstring, data: rawptr, bytesToWrite: c.uint) -> bool // FileIO: Save binary data LoadFileTextCallback :: #type proc "c" (fileName: cstring) -> [^]u8 // FileIO: Load text data SaveFileTextCallback :: #type proc "c" (fileName: cstring, text: cstring) -> bool // FileIO: Save text data +AudioCallback :: #type proc "c" (bufferData: rawptr, frames: c.uint) + @(default_calling_convention="c") foreign lib { @@ -900,37 +891,42 @@ foreign lib { //------------------------------------------------------------------------------------ // Window-related functions + InitWindow :: proc(width, height: c.int, title: cstring) --- // Initialize window and OpenGL context - WindowShouldClose :: proc() -> bool --- // Check if KEY_ESCAPE pressed or Close icon pressed + WindowShouldClose :: proc() -> bool --- // Check if KEY_ESCAPE pressed or Close icon pressed CloseWindow :: proc() --- // Close window and unload OpenGL context - IsWindowReady :: proc() -> bool --- // Check if window has been initialized successfully - IsWindowFullscreen :: proc() -> bool --- // Check if window is currently fullscreen - IsWindowHidden :: proc() -> bool --- // Check if window is currently hidden (only PLATFORM_DESKTOP) - IsWindowMinimized :: proc() -> bool --- // Check if window is currently minimized (only PLATFORM_DESKTOP) - IsWindowMaximized :: proc() -> bool --- // Check if window is currently maximized (only PLATFORM_DESKTOP) - IsWindowFocused :: proc() -> bool --- // Check if window is currently focused (only PLATFORM_DESKTOP) - IsWindowResized :: proc() -> bool --- // Check if window has been resized last frame - IsWindowState :: proc(flag: ConfigFlags) -> bool --- // Check if one specific window flag is enabled - SetWindowState :: proc(flags: ConfigFlags) --- // Set window configuration state using flags + IsWindowReady :: proc() -> bool --- // Check if window has been initialized successfully + IsWindowFullscreen :: proc() -> bool --- // Check if window is currently fullscreen + IsWindowHidden :: proc() -> bool --- // Check if window is currently hidden (only PLATFORM_DESKTOP) + IsWindowMinimized :: proc() -> bool --- // Check if window is currently minimized (only PLATFORM_DESKTOP) + IsWindowMaximized :: proc() -> bool --- // Check if window is currently maximized (only PLATFORM_DESKTOP) + IsWindowFocused :: proc() -> bool --- // Check if window is currently focused (only PLATFORM_DESKTOP) + IsWindowResized :: proc() -> bool --- // Check if window has been resized last frame + IsWindowState :: proc(flag: ConfigFlag) -> bool --- // Check if one specific window flag is enabled + SetWindowState :: proc(flags: ConfigFlags) --- // Set window configuration state using flags (only PLATFORM_DESKTOP) ClearWindowState :: proc(flags: ConfigFlags) --- // Clear window configuration state flags ToggleFullscreen :: proc() --- // Toggle window state: fullscreen/windowed (only PLATFORM_DESKTOP) MaximizeWindow :: proc() --- // Set window state: maximized, if resizable (only PLATFORM_DESKTOP) MinimizeWindow :: proc() --- // Set window state: minimized, if resizable (only PLATFORM_DESKTOP) RestoreWindow :: proc() --- // Set window state: not minimized/maximized (only PLATFORM_DESKTOP) - SetWindowIcon :: proc(image: Image) --- // Set icon for window (only PLATFORM_DESKTOP) + SetWindowIcon :: proc(image: Image) --- // Set icon for window (single image, RGBA 32bit, only PLATFORM_DESKTOP) + SetWindowIcons :: proc(images: [^]Image, count: c.int) --- // Set icon for window (multiple images, RGBA 32bit, only PLATFORM_DESKTOP) SetWindowTitle :: proc(title: cstring) --- // Set title for window (only PLATFORM_DESKTOP) SetWindowPosition :: proc(x, y: c.int) --- // Set window position on screen (only PLATFORM_DESKTOP) SetWindowMonitor :: proc(monitor: c.int) --- // Set monitor for the current window (fullscreen mode) SetWindowMinSize :: proc(width, height: c.int) --- // Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE) SetWindowSize :: proc(width, height: c.int) --- // Set window dimensions + SetWindowOpacity :: proc(opacity: f32) --- // Set window opacity [0.0f..1.0f] (only PLATFORM_DESKTOP) GetWindowHandle :: proc() -> rawptr --- // Get native window handle GetScreenWidth :: proc() -> c.int --- // Get current screen width GetScreenHeight :: proc() -> c.int --- // Get current screen height + GetRenderWidth :: proc() -> c.int --- // Get current render width (it considers HiDPI) + GetRenderHeight :: proc() -> c.int --- // Get current render height (it considers HiDPI) GetMonitorCount :: proc() -> c.int --- // Get number of connected monitors GetCurrentMonitor :: proc() -> c.int --- // Get current connected monitor GetMonitorPosition :: proc(monitor: c.int) -> Vector2 --- // Get specified monitor position - GetMonitorWidth :: proc(monitor: c.int) -> c.int --- // Get specified monitor width (max available by monitor) - GetMonitorHeight :: proc(monitor: c.int) -> c.int --- // Get specified monitor height (max available by monitor) + GetMonitorWidth :: proc(monitor: c.int) -> c.int --- // Get specified monitor width (current video mode used by monitor) + GetMonitorHeight :: proc(monitor: c.int) -> c.int --- // Get specified monitor height (current video mode used by monitor) GetMonitorPhysicalWidth :: proc(monitor: c.int) -> c.int --- // Get specified monitor physical width in millimetres GetMonitorPhysicalHeight :: proc(monitor: c.int) -> c.int --- // Get specified monitor physical height in millimetres GetMonitorRefreshRate :: proc(monitor: c.int) -> c.int --- // Get specified monitor refresh rate @@ -939,26 +935,31 @@ foreign lib { GetMonitorName :: proc(monitor: c.int) -> cstring --- // Get the human-readable, UTF-8 encoded name of the primary monitor SetClipboardText :: proc(text: cstring) --- // Set clipboard text content GetClipboardText :: proc() -> cstring --- // Get clipboard text content + EnableEventWaiting :: proc() --- // Enable waiting for events on EndDrawing(), no automatic event polling + DisableEventWaiting :: proc() --- // Disable waiting for events on EndDrawing(), automatic events polling + - // Custom frame control functions // NOTE: Those functions are intended for advance users that want full control over the frame processing // By default EndDrawing() does this job: draws everything + SwapScreenBuffer() + manage frame timming + PollInputEvents() // To avoid that behaviour and control frame processes manually, enable in config.h: SUPPORT_CUSTOM_FRAME_CONTROL - SwapScreenBuffer :: proc() --- // Swap back buffer with front buffer (screen drawing) - PollInputEvents :: proc() --- // Register all input events - WaitTime :: proc(ms: f32) --- // Wait for some milliseconds (halt program execution) + + SwapScreenBuffer :: proc() --- // Swap back buffer with front buffer (screen drawing) + PollInputEvents :: proc() --- // Register all input events + WaitTime :: proc(seconds: f64) --- // Wait for some time (halt program execution) // Cursor-related functions - ShowCursor :: proc() --- // Shows cursor - HideCursor :: proc() --- // Hides cursor - IsCursorHidden :: proc() -> bool --- // Check if cursor is not visible - EnableCursor :: proc() --- // Enables cursor (unlock cursor) - DisableCursor :: proc() --- // Disables cursor (lock cursor) - IsCursorOnScreen :: proc() -> bool --- // Check if cursor is on the current screen. + + ShowCursor :: proc() --- // Shows cursor + HideCursor :: proc() --- // Hides cursor + IsCursorHidden :: proc() -> bool --- // Check if cursor is not visible + EnableCursor :: proc() --- // Enables cursor (unlock cursor) + DisableCursor :: proc() --- // Disables cursor (lock cursor) + IsCursorOnScreen :: proc() -> bool --- // Check if cursor is on the current screen. // Drawing-related functions + ClearBackground :: proc(color: Color) --- // Set background color (framebuffer clear color) BeginDrawing :: proc() --- // Setup canvas (framebuffer) to start drawing EndDrawing :: proc() --- // End canvas drawing and swap buffers (double buffering) @@ -978,13 +979,16 @@ foreign lib { EndVrStereoMode :: proc() --- // End stereo rendering (requires VR simulator) // VR stereo config functions for VR simulator + LoadVrStereoConfig :: proc(device: VrDeviceInfo) -> VrStereoConfig --- // Load VR stereo config for VR simulator device parameters UnloadVrStereoConfig :: proc(config: VrStereoConfig) --- // Unload VR stereo config // Shader management functions // NOTE: Shader functionality is not available on OpenGL 1.1 + LoadShader :: proc(vsFileName, fsFileName: cstring) -> Shader --- // Load shader from files and bind default locations LoadShaderFromMemory :: proc(vsCode, fsCode: cstring) -> Shader --- // Load shader from code strings and bind default locations + IsShaderReady :: proc(shader: Shader) -> bool --- // Check if a shader is ready GetShaderLocation :: proc(shader: Shader, uniformName: cstring) -> c.int --- // Get shader uniform location GetShaderLocationAttrib :: proc(shader: Shader, attribName: cstring) -> c.int --- // Get shader attribute location SetShaderValue :: proc(shader: Shader, locIndex: ShaderLocationIndex, value: rawptr, uniformType: ShaderUniformDataType) --- // Set shader uniform value @@ -994,21 +998,24 @@ foreign lib { UnloadShader :: proc(shader: Shader) --- // Unload shader from GPU memory (VRAM) // Screen-space-related functions - GetMouseRay :: proc(mousePosition: Vector2, camera: Camera) -> Ray --- // Returns a ray trace from mouse position - GetCameraMatrix :: proc(camera: Camera) -> Matrix --- // Returns camera transform matrix (view matrix) - GetCameraMatrix2D :: proc(camera: Camera2D) -> Matrix --- // Returns camera 2d transform matrix - GetWorldToScreen :: proc(position: Vector3, camera: Camera) -> Vector2 --- // Returns the screen space position for a 3d world space position - GetWorldToScreenEx :: proc(position: Vector3, camera: Camera, width, height: c.int) -> Vector2 --- // Returns size position for a 3d world space position - GetWorldToScreen2D :: proc(position: Vector2, camera: Camera2D) -> Vector2 --- // Returns the screen space position for a 2d camera world space position - GetScreenToWorld2D :: proc(position: Vector2, camera: Camera2D) -> Vector2 --- // Returns the world space position for a 2d camera screen space position + + GetMouseRay :: proc(mousePosition: Vector2, camera: Camera) -> Ray --- // Get a ray trace from mouse position + GetCameraMatrix :: proc(camera: Camera) -> Matrix --- // Get camera transform matrix (view matrix) + GetCameraMatrix2D :: proc(camera: Camera2D) -> Matrix --- // Get camera 2d transform matrix + GetWorldToScreen :: proc(position: Vector3, camera: Camera) -> Vector2 --- // Get the screen space position for a 3d world space position + GetScreenToWorld2D :: proc(position: Vector2, camera: Camera2D) -> Vector2 --- // Get the world space position for a 2d camera screen space position + GetWorldToScreenEx :: proc(position: Vector3, camera: Camera, width, height: c.int) -> Vector2 --- // Get size position for a 3d world space position + GetWorldToScreen2D :: proc(position: Vector2, camera: Camera2D) -> Vector2 --- // Get the screen space position for a 2d camera world space position // Timing-related functions + SetTargetFPS :: proc(fps: c.int) --- // Set target FPS (maximum) GetFPS :: proc() -> c.int --- // Returns current FPS GetFrameTime :: proc() -> f32 --- // Returns time in seconds for last frame drawn (delta time) GetTime :: proc() -> f64 --- // Returns elapsed time in seconds since InitWindow() // Misc. functions + GetRandomValue :: proc(min, max: c.int) -> c.int --- // Returns a random value between min and max (both included) SetRandomSeed :: proc(seed: c.uint) --- // Set the seed for the random number generator TakeScreenshot :: proc(fileName: cstring) --- // Takes a screenshot of current screen (filename extension defines format) @@ -1016,12 +1023,15 @@ foreign lib { TraceLog :: proc(logLevel: TraceLogLevel, text: cstring, #c_vararg args: ..any) --- // Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR) SetTraceLogLevel :: proc(logLevel: TraceLogLevel) --- // Set the current threshold (minimum) log level - MemAlloc :: proc(size: c.int) -> rawptr --- // Internal memory allocator - MemRealloc :: proc(ptr: rawptr, size: c.int) -> rawptr --- // Internal memory reallocator - MemFree :: proc(ptr: rawptr) --- // Internal memory free + MemAlloc :: proc(size: c.uint) -> rawptr --- // Internal memory allocator + MemRealloc :: proc(ptr: rawptr, size: c.uint) -> rawptr --- // Internal memory reallocator + MemFree :: proc(ptr: rawptr) --- // Internal memory free + + OpenURL :: proc(url: cstring) --- // Open URL with default system browser (if available) // Set custom callbacks // WARNING: Callbacks setup is intended for advance users + SetTraceLogCallback :: proc(callback: TraceLogCallback) --- // Set custom trace log SetLoadFileDataCallback :: proc(callback: LoadFileDataCallback) --- // Set custom file binary data loader SetSaveFileDataCallback :: proc(callback: SaveFileDataCallback) --- // Set custom file binary data saver @@ -1029,45 +1039,48 @@ foreign lib { SetSaveFileTextCallback :: proc(callback: SaveFileTextCallback) --- // Set custom file text data saver // Files management functions - LoadFileData :: proc(fileName: cstring, bytesRead: ^c.uint) -> [^]u8 --- // Load file data as byte array (read) - UnloadFileData :: proc(data: [^]u8) --- // Unload file data allocated by LoadFileData() - SaveFileData :: proc(fileName: cstring, data: rawptr, bytesToWrite: c.uint) -> bool --- // Save data to file from byte array (write), returns true on success - LoadFileText :: proc(fileName: cstring) -> [^]u8 --- // Load text data from file (read), returns a '\0' terminated string - UnloadFileText :: proc(text: cstring) --- // Unload file text data allocated by LoadFileText() - SaveFileText :: proc(fileName: cstring, text: cstring) -> bool --- // Save text data to file (write), string must be '\0' terminated, returns true on success - FileExists :: proc(fileName: cstring) -> bool --- // Check if file exists - DirectoryExists :: proc(dirPath: cstring) -> bool --- // Check if a directory path exists - IsFileExtension :: proc(fileName: cstring, ext: cstring) -> bool --- // Check file extension (including point: .png, .wav) - GetFileExtension :: proc(fileName: cstring) -> cstring --- // Get pointer to extension for a filename string (includes dot: ".png") - GetFileName :: proc(filePath: cstring) -> cstring --- // Get pointer to filename for a path string - GetFileNameWithoutExt :: proc(filePath: cstring) -> cstring --- // Get filename string without extension (uses static string) - GetDirectoryPath :: proc(filePath: cstring) -> cstring --- // Get full path for a given fileName with path (uses static string) - GetPrevDirectoryPath :: proc(dirPath: cstring) -> cstring --- // Get previous directory path for a given path (uses static string) - GetWorkingDirectory :: proc() -> cstring --- // Get current working directory (uses static string) - GetDirectoryFiles :: proc(dirPath: cstring, count: ^c.int) -> [^]cstring --- // Get filenames in a directory path (memory should be freed) - ClearDirectoryFiles :: proc() --- // Clear directory files paths buffers (free memory) - ChangeDirectory :: proc(dir: cstring) -> bool --- // Change working directory, return true on success - IsFileDropped :: proc() -> bool --- // Check if a file has been dropped into window - GetDroppedFiles :: proc(count: ^c.int) -> [^]cstring --- // Get dropped files names (memory should be freed) - ClearDroppedFiles :: proc() --- // Clear dropped files paths buffer (free memory) - GetFileModTime :: proc(fileName: cstring) -> c.long --- // Get file modification time (last write time) - CompressData :: proc(data: [^]u8, dataLength: c.int, compDataLength: ^c.int) -> [^]u8 --- // Compress data (DEFLATE algorithm) - DecompressData :: proc(compData: [^]u8, compDataLength: c.int, dataLength: ^c.int) -> [^]u8 --- // Decompress data (DEFLATE algorithm) - EncodeDataBase64 :: proc(data: [^]u8, dataLength: c.int, outputLength: ^c.int) -> [^]u8 --- // Encode data to Base64 string - DecodeDataBase64 :: proc(data: [^]u8, outputLength: ^c.int) -> [^]u8 --- // Decode Base64 string data + LoadFileData :: proc(fileName: cstring, bytesRead: ^c.uint) -> [^]byte --- // Load file data as byte array (read) + UnloadFileData :: proc(data: [^]byte) --- // Unload file data allocated by LoadFileData() + SaveFileData :: proc(fileName: cstring, data: rawptr, bytesToWrite: c.uint) -> bool --- // Save data to file from byte array (write), returns true on success + ExportDataAsCode :: proc(data: rawptr, size: c.uint, fileName: cstring) -> bool --- // Export data to code (.h), returns true on success + LoadFileText :: proc(fileName: cstring) -> [^]byte --- // Load text data from file (read), returns a '\0' terminated string + UnloadFileText :: proc(text: [^]byte) --- // Unload file text data allocated by LoadFileText() + SaveFileText :: proc(fileName: cstring, text: [^]byte) -> bool --- // Save text data to file (write), string must be '\0' terminated, returns true on success + FileExists :: proc(fileName: cstring) -> bool --- // Check if file exists + DirectoryExists :: proc(dirPath: cstring) -> bool --- // Check if a directory path exists + IsFileExtension :: proc(fileName, ext: cstring) -> bool --- // Check file extension (including point: .png, .wav) + GetFileLength :: proc(fileName: cstring) -> c.int --- // Get file length in bytes (NOTE: GetFileSize() conflicts with windows.h) + GetFileExtension :: proc(fileName: cstring) -> cstring --- // Get pointer to extension for a filename string (includes dot: '.png') + GetFileName :: proc(filePath: cstring) -> cstring --- // Get pointer to filename for a path string + GetFileNameWithoutExt :: proc(filePath: cstring) -> cstring --- // Get filename string without extension (uses static string) + GetDirectoryPath :: proc(filePath: cstring) -> cstring --- // Get full path for a given fileName with path (uses static string) + GetPrevDirectoryPath :: proc(dirPath: cstring) -> cstring --- // Get previous directory path for a given path (uses static string) + GetWorkingDirectory :: proc() -> cstring --- // Get current working directory (uses static string) + GetApplicationDirectory :: proc() -> cstring --- // Get the directory if the running application (uses static string) + ChangeDirectory :: proc(dir: cstring) -> bool --- // Change working directory, return true on success + IsPathFile :: proc(path: cstring) -> bool --- // Check if a given path is a file or a directory + LoadDirectoryFiles :: proc(dirPath: cstring) -> FilePathList --- // Load directory filepaths + LoadDirectoryFilesEx :: proc(basePath: cstring, filter: cstring, scanSubdirs: bool) -> FilePathList --- // Load directory filepaths with extension filtering and recursive directory scan + UnloadDirectoryFiles :: proc(files: FilePathList) --- // Unload filepaths + IsFileDropped :: proc() -> bool --- // Check if a file has been dropped into window + LoadDroppedFiles :: proc() -> FilePathList --- // Load dropped filepaths + UnloadDroppedFiles :: proc(files: FilePathList) --- // Unload dropped filepaths + GetFileModTime :: proc(fileName: cstring) -> c.long --- // Get file modification time (last write time) - // Persistent storage management - SaveStorageValue :: proc(position: c.uint, value: c.int) -> bool --- // Save integer value to storage file (to defined position), returns true on success - LoadStorageValue :: proc(position: c.uint) -> c.int --- // Load integer value from storage file (from defined position) + // Compression/Encoding functionality - OpenURL :: proc(url: cstring) --- // Open URL with default system browser (if available) + CompressData :: proc(data: rawptr, dataSize: c.int, compDataSize: ^c.int) -> [^]byte --- // Compress data (DEFLATE algorithm), memory must be MemFree() + DecompressData :: proc(compData: rawptr, compDataSize: c.int, dataSize: ^c.int) -> [^]byte --- // Decompress data (DEFLATE algorithm), memory must be MemFree() + EncodeDataBase64 :: proc(data: rawptr, dataSize: c.int, outputSize: ^c.int) -> [^]byte --- // Encode data to Base64 string, memory must be MemFree() + DecodeDataBase64 :: proc(data: rawptr, outputSize: ^c.int) -> [^]byte --- // Decode Base64 string data, memory must be MemFree() //------------------------------------------------------------------------------------ // Input Handling Functions (Module: core) //------------------------------------------------------------------------------------ // Input-related functions: keyboard + IsKeyPressed :: proc(key: KeyboardKey) -> bool --- // Detect if a key has been pressed once IsKeyDown :: proc(key: KeyboardKey) -> bool --- // Detect if a key is being pressed IsKeyReleased :: proc(key: KeyboardKey) -> bool --- // Detect if a key has been released once @@ -1077,19 +1090,20 @@ foreign lib { GetCharPressed :: proc() -> rune --- // Get char pressed (unicode), call it multiple times for chars queued // Input-related functions: gamepads - IsGamepadAvailable :: proc(gamepad: c.int) -> bool --- // Detect if a gamepad is available - IsGamepadName :: proc(gamepad: c.int, name: cstring) -> bool --- // Check gamepad name (if available) - GetGamepadName :: proc(gamepad: c.int) -> cstring --- // Return gamepad internal name id - IsGamepadButtonPressed :: proc(gamepad: c.int, button: GamepadButton) -> bool --- // Detect if a gamepad button has been pressed once - IsGamepadButtonDown :: proc(gamepad: c.int, button: GamepadButton) -> bool --- // Detect if a gamepad button is being pressed - IsGamepadButtonReleased :: proc(gamepad: c.int, button: GamepadButton) -> bool --- // Detect if a gamepad button has been released once - IsGamepadButtonUp :: proc(gamepad: c.int, button: GamepadButton) -> bool --- // Detect if a gamepad button is NOT being pressed - GetGamepadButtonPressed :: proc() -> c.int --- // Get the last gamepad button pressed - GetGamepadAxisCount :: proc(gamepad: c.int) -> c.int --- // Return gamepad axis count for a gamepad - GetGamepadAxisMovement :: proc(gamepad: c.int, axis: GamepadAxis) -> f32 --- // Return axis movement value for a gamepad axis - SetGamepadMappings :: proc(mappings: cstring) -> c.int --- // Set internal gamepad mappings (SDL_GameControllerDB) + + IsGamepadAvailable :: proc(gamepad: c.int) -> bool --- // Check if a gamepad is available + GetGamepadName :: proc(gamepad: c.int) -> cstring --- // Get gamepad internal name id + IsGamepadButtonPressed :: proc(gamepad: c.int, button: GamepadButton) -> bool --- // Check if a gamepad button has been pressed once + IsGamepadButtonDown :: proc(gamepad: c.int, button: GamepadButton) -> bool --- // Check if a gamepad button is being pressed + IsGamepadButtonReleased :: proc(gamepad: c.int, button: GamepadButton) -> bool --- // Check if a gamepad button has been released once + IsGamepadButtonUp :: proc(gamepad: c.int, button: GamepadButton) -> bool --- // Check if a gamepad button is NOT being pressed + GetGamepadButtonPressed :: proc() -> GamepadButton --- // Get the last gamepad button pressed + GetGamepadAxisCount :: proc(gamepad: c.int) -> c.int --- // Get gamepad axis count for a gamepad + GetGamepadAxisMovement :: proc(gamepad: c.int, axis: GamepadAxis) -> f32 --- // Get axis movement value for a gamepad axis + SetGamepadMappings :: proc(mappings: cstring) -> c.int --- // Set internal gamepad mappings (SDL_GameControllerDB) // Input-related functions: mouse + IsMouseButtonPressed :: proc(button: MouseButton) -> bool --- // Detect if a mouse button has been pressed once IsMouseButtonDown :: proc(button: MouseButton) -> bool --- // Detect if a mouse button is being pressed IsMouseButtonReleased :: proc(button: MouseButton) -> bool --- // Detect if a mouse button has been released once @@ -1102,9 +1116,11 @@ foreign lib { SetMouseOffset :: proc(offsetX, offsetY: c.int) --- // Set mouse offset SetMouseScale :: proc(scaleX, scaleY: f32) --- // Set mouse scaling GetMouseWheelMove :: proc() -> f32 --- // Returns mouse wheel movement Y + GetMouseWheelMoveV :: proc() -> Vector2 --- // Get mouse wheel movement for both X and Y SetMouseCursor :: proc(cursor: MouseCursor) --- // Set mouse cursor // Input-related functions: touch + GetTouchX :: proc() -> c.int --- // Returns touch position X for touch point 0 (relative to screen size) GetTouchY :: proc() -> c.int --- // Returns touch position Y for touch point 0 (relative to screen size) GetTouchPosition :: proc(index: c.int) -> Vector2 --- // Returns touch position XY for a touch point index (relative to screen size) @@ -1112,8 +1128,9 @@ foreign lib { GetTouchPointCount :: proc() -> c.int --- // Get number of touch points //------------------------------------------------------------------------------------ - // Gestures and Touch Handling Functions (Module: gestures) + // Gestures and Touch Handling Functions (Module: rgestures) //------------------------------------------------------------------------------------ + SetGesturesEnabled :: proc(flags: Gestures) --- // Enable a set of gestures using flags IsGestureDetected :: proc(gesture: Gesture) -> bool --- // Check if a gesture have been detected GetGestureDetected :: proc() -> Gesture --- // Get latest detected gesture @@ -1126,13 +1143,9 @@ foreign lib { //------------------------------------------------------------------------------------ // Camera System Functions (Module: camera) //------------------------------------------------------------------------------------ - SetCameraMode :: proc(camera: Camera, mode: CameraMode) --- // Set camera mode (multiple camera modes available) - UpdateCamera :: proc(camera: ^Camera) --- // Update camera position for selected mode - SetCameraPanControl :: proc(keyPan: KeyboardKey) --- // Set camera pan key to combine with mouse movement (free camera) - SetCameraAltControl :: proc(keyAlt: KeyboardKey) --- // Set camera alt key to combine with mouse movement (free camera) - SetCameraSmoothZoomControl :: proc(keySmoothZoom: KeyboardKey) --- // Set camera smooth zoom key to combine with mouse (free camera) - SetCameraMoveControls :: proc(keyFront, keyBack, keyRight, keyLeft, keyUp, keyDown: KeyboardKey) --- // Set camera move controls (1st person and 3rd person cameras) + UpdateCamera :: proc(camera: ^Camera, mode: CameraMode) --- // Set camera mode (multiple camera modes available) + UpdateCameraPro :: proc(camera: ^Camera, movement: Vector3, rotation: Vector3, zoom: f32) --- // Update camera movement/rotation //------------------------------------------------------------------------------------ // Basic Shapes Drawing Functions (Module: shapes) @@ -1140,369 +1153,413 @@ foreign lib { // Set texture and rectangle to be used on shapes drawing // NOTE: It can be useful when using basic shapes and one single font, // defining a font char white rectangle would allow drawing everything in a single draw call + SetShapesTexture :: proc(texture: Texture2D, source: Rectangle) --- // Basic shapes drawing functions - DrawPixel :: proc(posX, posY: c.int, color: Color) --- // Draw a pixel - DrawPixelV :: proc(position: Vector2 , color: Color) --- // Draw a pixel (Vector version) - DrawLine :: proc(startPosX, startPosY, endPosX, endPosY: c.int, color: Color) --- // Draw a line - DrawLineV :: proc(startPos, endPos: Vector2, color: Color) --- // Draw a line (Vector version) - DrawLineEx :: proc(startPos, endPos: Vector2, thick: f32, color: Color) --- // Draw a line defining thickness - DrawLineBezier :: proc(startPos, endPos: Vector2, thick: f32, color: Color) --- // Draw a line using cubic-bezier curves in-out - DrawLineBezierQuad :: proc(startPos, endPos: Vector2, controlPos: Vector2, thick: f32, color: Color) --- // Draw line using quadratic bezier curves with a control point - DrawLineBezierCubic :: proc(startPos, endPos: Vector2, startControlPos, endControlPos: Vector2, thick: f32, color: Color) --- // Draw line using cubic bezier curves with 2 control points - DrawLineStrip :: proc(points: [^]Vector2, pointsCount: c.int, color: Color) --- // Draw lines sequence - DrawCircle :: proc(centerX, centerY: c.int, radius: f32, color: Color) --- // Draw a color-filled circle - DrawCircleSector :: proc(center: Vector2, radius: f32, startAngle, endAngle: f32, segments: c.int, color: Color) --- // Draw a piece of a circle - DrawCircleSectorLines :: proc(center: Vector2, radius: f32, startAngle, endAngle: f32, segments: c.int, color: Color) --- // Draw circle sector outline - DrawCircleGradient :: proc(centerX, centerY: c.int, radius: f32, color1: Color, color2: Color) --- // Draw a gradient-filled circle - DrawCircleV :: proc(center: Vector2, radius: f32, color: Color) --- // Draw a color-filled circle (Vector version) - DrawCircleLines :: proc(centerX, centerY: c.int, radius: f32, color: Color) --- // Draw circle outline - DrawEllipse :: proc(centerX, centerY: c.int, radiusH: f32, radiusV: f32, color: Color) --- // Draw ellipse - DrawEllipseLines :: proc(centerX, centerY: c.int, radiusH: f32, radiusV: f32, color: Color) --- // Draw ellipse outline - DrawRing :: proc(center: Vector2, innerRadius, outerRadius: f32, startAngle, endAngle: f32, segments: c.int, color: Color) --- // Draw ring - DrawRingLines :: proc(center: Vector2, innerRadius, outerRadius: f32, startAngle, endAngle: f32, segments: c.int, color: Color) --- // Draw ring outline - DrawRectangle :: proc(posX, posY, width, height: c.int, color: Color) --- // Draw a color-filled rectangle - DrawRectangleV :: proc(position, size: Vector2, color: Color) --- // Draw a color-filled rectangle (Vector version) - DrawRectangleRec :: proc(rec: Rectangle, color: Color) --- // Draw a color-filled rectangle - DrawRectanglePro :: proc(rec: Rectangle, origin: Vector2, rotation: f32, color: Color) --- // Draw a color-filled rectangle with pro parameters - DrawRectangleGradientV :: proc(posX, posY, width, height: c.int, color1: Color, color2: Color) --- // Draw a vertical-gradient-filled rectangle - DrawRectangleGradientH :: proc(posX, posY, width, height: c.int, color1: Color, color2: Color) --- // Draw a horizontal-gradient-filled rectangle - DrawRectangleGradientEx :: proc(rec: Rectangle, col1, col2, col3, col4: Color) --- // Draw a gradient-filled rectangle with custom vertex colors - DrawRectangleLines :: proc(posX, posY, width, height: c.int, color: Color) --- // Draw rectangle outline - DrawRectangleLinesEx :: proc(rec: Rectangle, lineThick: f32, color: Color) --- // Draw rectangle outline with extended parameters - DrawRectangleRounded :: proc(rec: Rectangle, roundness: f32, segments: c.int, color: Color) --- // Draw rectangle with rounded edges - DrawRectangleRoundedLines :: proc(rec: Rectangle, roundness: f32, segments: c.int, lineThick: f32, color: Color) --- // Draw rectangle with rounded edges outline - DrawTriangle :: proc(v1, v2, v3: Vector2, color: Color) --- // Draw a color-filled triangle (vertex in counter-clockwise order!) - DrawTriangleLines :: proc(v1, v2, v3: Vector2, color: Color) --- // Draw triangle outline (vertex in counter-clockwise order!) - DrawTriangleFan :: proc(points: [^]Vector2, pointsCount: c.int, color: Color) --- // Draw a triangle fan defined by points (first vertex is the center) - DrawTriangleStrip :: proc(points: [^]Vector2, pointsCount: c.int, color: Color) --- // Draw a triangle strip defined by points - DrawPoly :: proc(center: Vector2, sides: c.int, radius: f32, rotation: f32, color: Color) --- // Draw a regular polygon (Vector version) - DrawPolyLines :: proc(center: Vector2, sides: c.int, radius: f32, rotation: f32, color: Color) --- // Draw a polygon outline of n sides - DrawPolyLinesEx :: proc(center: Vector2, sides: c.int, radius: f32, rotation: f32, lineThick: f32, color: Color) --- // Draw a polygon outline of n sides with extended parameters - // Basic shapes collision detection functions - CheckCollisionRecs :: proc(rec1, rec2: Rectangle) -> bool --- // Check collision between two rectangles - CheckCollisionCircles :: proc(center1: Vector2, radius1: f32, center2: Vector2, radius2: f32) -> bool --- // Check collision between two circles - CheckCollisionCircleRec :: proc(center: Vector2, radius: f32, rec: Rectangle) -> bool --- // Check collision between circle and rectangle - CheckCollisionPointRec :: proc(point: Vector2, rec: Rectangle) -> bool --- // Check if point is inside rectangle - CheckCollisionPointCircle :: proc(point: Vector2, center: Vector2, radius: f32) -> bool --- // Check if point is inside circle - CheckCollisionPointTriangle :: proc(point, p1, p2, p3: Vector2) -> bool --- // Check if point is inside a triangle - CheckCollisionLines :: proc(startPos1, endPos1, startPos2, endPos2: Vector2, collisionPoint: ^Vector2) -> bool --- // Check the collision between two lines defined by two points each, returns collision point by reference - CheckCollisionPointLine :: proc(point, p1, p2: Vector2, threshold: c.int) -> bool --- // Check if point belongs to line created between two points [p1] and [p2] with defined margin in pixels [threshold] - GetCollisionRec :: proc(rec1, rec2: Rectangle) -> Rectangle --- // Get collision rectangle for two rectangles collision + DrawPixel :: proc(posX, posY: c.int, color: Color) --- // Draw a pixel + DrawPixelV :: proc(position: Vector2, color: Color) --- // Draw a pixel (Vector version) + DrawLine :: proc(startPosX, startPosY, endPosX, endPosY: c.int, color: Color) --- // Draw a line + DrawLineV :: proc(startPos, endPos: Vector2, color: Color) --- // Draw a line (Vector version) + DrawLineEx :: proc(startPos, endPos: Vector2, thick: f32, color: Color) --- // Draw a line defining thickness + DrawLineBezier :: proc(startPos, endPos: Vector2, thick: f32, color: Color) --- // Draw a line using cubic-bezier curves in-out + DrawLineBezierQuad :: proc(startPos, endPos: Vector2, controlPos: Vector2, thick: f32, color: Color) --- // Draw line using quadratic bezier curves with a control point + DrawLineBezierCubic :: proc(startPos, endPos: Vector2, startControlPos, endControlPos: Vector2, thick: f32, color: Color) --- // Draw line using cubic bezier curves with 2 control points + DrawLineStrip :: proc(points: [^]Vector2, pointCount: c.int, color: Color) --- // Draw lines sequence + DrawCircle :: proc(centerX, centerY: c.int, radius: f32, color: Color) --- // Draw a color-filled circle + DrawCircleSector :: proc(center: Vector2, radius: f32, startAngle, endAngle: f32, segments: c.int, color: Color) --- // Draw a piece of a circle + DrawCircleSectorLines :: proc(center: Vector2, radius: f32, startAngle, endAngle: f32, segments: c.int, color: Color) --- // Draw circle sector outline + DrawCircleGradient :: proc(centerX, centerY: c.int, radius: f32, color1, color2: Color) --- // Draw a gradient-filled circle + DrawCircleV :: proc(center: Vector2, radius: f32, color: Color) --- // Draw a color-filled circle (Vector version) + DrawCircleLines :: proc(centerX, centerY: c.int, radius: f32, color: Color) --- // Draw circle outline + DrawEllipse :: proc(centerX, centerY: c.int, radiusH, radiusV: f32, color: Color) --- // Draw ellipse + DrawEllipseLines :: proc(centerX, centerY: c.int, radiusH, radiusV: f32, color: Color) --- // Draw ellipse outline + DrawRing :: proc(center: Vector2, innerRadius, outerRadius: f32, startAngle, endAngle: f32, segments: c.int, color: Color) --- // Draw ring + DrawRingLines :: proc(center: Vector2, innerRadius, outerRadius: f32, startAngle, endAngle: f32, segments: c.int, color: Color) --- // Draw ring outline + DrawRectangle :: proc(posX, posY: c.int, width, height: c.int, color: Color) --- // Draw a color-filled rectangle + DrawRectangleV :: proc(position: Vector2, size: Vector2, color: Color) --- // Draw a color-filled rectangle (Vector version) + DrawRectangleRec :: proc(rec: Rectangle, color: Color) --- // Draw a color-filled rectangle + DrawRectanglePro :: proc(rec: Rectangle, origin: Vector2, rotation: f32, color: Color) --- // Draw a color-filled rectangle with pro parameters + DrawRectangleGradientV :: proc(posX, posY: c.int, width, height: c.int, color1, color2: Color) --- // Draw a vertical-gradient-filled rectangle + DrawRectangleGradientH :: proc(posX, posY: c.int, width, height: c.int, color1, color2: Color) --- // Draw a horizontal-gradient-filled rectangle + DrawRectangleGradientEx :: proc(rec: Rectangle, col1, col2, col3, col4: Color) --- // Draw a gradient-filled rectangle with custom vertex colors + DrawRectangleLines :: proc(posX, posY: c.int, width, height: c.int, color: Color) --- // Draw rectangle outline + DrawRectangleLinesEx :: proc(rec: Rectangle, lineThick: f32, color: Color) --- // Draw rectangle outline with extended parameters + DrawRectangleRounded :: proc(rec: Rectangle, roundness: f32, segments: c.int, color: Color) --- // Draw rectangle with rounded edges + DrawRectangleRoundedLines :: proc(rec: Rectangle, roundness: f32, segments: c.int, lineThick: f32, color: Color) --- // Draw rectangle with rounded edges outline + DrawTriangle :: proc(v1, v2, v3: Vector2, color: Color) --- // Draw a color-filled triangle (vertex in counter-clockwise order!) + DrawTriangleLines :: proc(v1, v2, v3: Vector2, color: Color) --- // Draw triangle outline (vertex in counter-clockwise order!) + DrawTriangleFan :: proc(points: [^]Vector2, pointCount: c.int, color: Color) --- // Draw a triangle fan defined by points (first vertex is the center) + DrawTriangleStrip :: proc(points: [^]Vector2, pointCount: c.int, color: Color) --- // Draw a triangle strip defined by points + DrawPoly :: proc(center: Vector2, sides: c.int, radius: f32, rotation: f32, color: Color) --- // Draw a regular polygon (Vector version) + DrawPolyLines :: proc(center: Vector2, sides: c.int, radius: f32, rotation: f32, color: Color) --- // Draw a polygon outline of n sides + DrawPolyLinesEx :: proc(center: Vector2, sides: c.int, radius: f32, rotation: f32, lineThick: f32, color: Color) --- // Draw a polygon outline of n sides with extended parameters + + // Basic shapes collision detection functions + CheckCollisionRecs :: proc(rec1, rec2: Rectangle) -> bool --- // Check collision between two rectangles + CheckCollisionCircles :: proc(center1: Vector2, radius1: f32, center2: Vector2, radius2: f32) -> bool --- // Check collision between two circles + CheckCollisionCircleRec :: proc(center: Vector2, radius: f32, rec: Rectangle) -> bool --- // Check collision between circle and rectangle + CheckCollisionPointRec :: proc(point: Vector2, rec: Rectangle) -> bool --- // Check if point is inside rectangle + CheckCollisionPointCircle :: proc(point, center: Vector2, radius: f32) -> bool --- // Check if point is inside circle + CheckCollisionPointTriangle :: proc(point: Vector2, p1, p2, p3: Vector2) -> bool --- // Check if point is inside a triangle + CheckCollisionPointPoly :: proc(point: Vector2, points: [^]Vector2, pointCount: c.int) -> bool --- // Check if point is within a polygon described by array of vertices + CheckCollisionLines :: proc(startPos1, endPos1, startPos2, endPos2: Vector2, collisionPoint: [^]Vector2) -> bool --- // Check the collision between two lines defined by two points each, returns collision point by reference + CheckCollisionPointLine :: proc(point: Vector2, p1, p2: Vector2, threshold: c.int) -> bool --- // Check if point belongs to line created between two points [p1] and [p2] with defined margin in pixels [threshold] + GetCollisionRec :: proc(rec1, rec2: Rectangle) -> Rectangle --- // Get collision rectangle for two rectangles collision + - //------------------------------------------------------------------------------------ - // Texture Loading and Drawing Functions (Module: textures) - //------------------------------------------------------------------------------------ // Image loading functions - // NOTE: This functions do not require GPU access + // NOTE: These functions do not require GPU access + LoadImage :: proc(fileName: cstring) -> Image --- // Load image from file into CPU memory (RAM) LoadImageRaw :: proc(fileName: cstring, width, height: c.int, format: PixelFormat, headerSize: c.int) -> Image --- // Load image from RAW file data - LoadImageAnim :: proc(fileName: cstring, frames: ^c.int) -> Image --- // Load image sequence from file (frames appended to image.data) - LoadImageFromMemory :: proc(fileType: cstring, fileData: rawptr, dataSize: c.int) -> Image --- // Load image from memory buffer, fileType refers to extension: i.e. ".png" + LoadImageAnim :: proc(fileName: cstring, frames: [^]c.int) -> Image --- // Load image sequence from file (frames appended to image.data) + LoadImageFromMemory :: proc(fileType: cstring, fileData: rawptr, dataSize: c.int) -> Image --- // Load image from memory buffer, fileType refers to extension: i.e. '.png' LoadImageFromTexture :: proc(texture: Texture2D) -> Image --- // Load image from GPU texture data + LoadImageFromScreen :: proc() -> Image --- // Load image from screen buffer and (screenshot) + IsImageReady :: proc(image: Image) -> bool --- // Check if an image is ready UnloadImage :: proc(image: Image) --- // Unload image from CPU memory (RAM) ExportImage :: proc(image: Image, fileName: cstring) -> bool --- // Export image data to file, returns true on success ExportImageAsCode :: proc(image: Image, fileName: cstring) -> bool --- // Export image as code file defining an array of bytes, returns true on success // Image generation functions - GenImageColor :: proc(width, height: c.int, color: Color) -> Image --- // Generate image: plain color - GenImageGradientV :: proc(width, height: c.int, top, bottom: Color) -> Image --- // Generate image: vertical gradient - GenImageGradientH :: proc(width, height: c.int, left, right: Color) -> Image --- // Generate image: horizontal gradient - GenImageGradientRadial :: proc(width, height: c.int, density: f32, inner, outer: Color) -> Image --- // Generate image: radial gradient - GenImageChecked :: proc(width, height: c.int, checksX, checksY: c.int, col1, col2: Color) -> Image --- // Generate image: checked - GenImageWhiteNoise :: proc(width, height: c.int, factor: f32) -> Image --- // Generate image: white noise - GenImageCellular :: proc(width, height: c.int, tileSize: c.int) -> Image --- // Generate image: cellular algorithm. Bigger tileSize means bigger cells + + GenImageColor :: proc(width, height: c.int, color: Color) -> Image --- // Generate image: plain color + GenImageGradientV :: proc(width, height: c.int, top, bottom: Color) -> Image --- // Generate image: vertical gradient + GenImageGradientH :: proc(width, height: c.int, left, right: Color) -> Image --- // Generate image: horizontal gradient + GenImageGradientRadial :: proc(width, height: c.int, density: f32, inner, outer: Color) -> Image --- // Generate image: radial gradient + GenImageChecked :: proc(width, height: c.int, checksX, checksY: c.int, col1, col2: Color) -> Image --- // Generate image: checked + GenImageWhiteNoise :: proc(width, height: c.int, factor: f32) -> Image --- // Generate image: white noise + GenImagePerlinNoise :: proc(width, height: c.int, offsetX, offsetY: c.int, scale: f32) -> Image --- // Generate image: perlin noise + GenImageCellular :: proc(width, height: c.int, tileSize: c.int) -> Image --- // Generate image: cellular algorithm, bigger tileSize means bigger cells + GenImageText :: proc(width, height: c.int, text: cstring) -> Image --- // Generate image: grayscale image from text data // Image manipulation functions - ImageCopy :: proc(image: Image) -> Image --- // Create an image duplicate (useful for transformations) - ImageFromImage :: proc(image: Image, rec: Rectangle) -> Image --- // Create an image from another image piece - ImageText :: proc(text: cstring, fontSize: c.int, color: Color) -> Image --- // Create an image from text (default font) - ImageTextEx :: proc(font: Font, text: cstring, fontSize, spacing: f32, tint: Color) -> Image --- // Create an image from text (custom sprite font) - ImageFormat :: proc(image: ^Image, newFormat: PixelFormat) --- // Convert image data to desired format - ImageToPOT :: proc(image: ^Image, fill: Color) --- // Convert image to POT (power-of-two) - ImageCrop :: proc(image: ^Image, crop: Rectangle) --- // Crop an image to a defined rectangle - ImageAlphaCrop :: proc(image: ^Image, threshold: f32) --- // Crop image depending on alpha value - ImageAlphaClear :: proc(image: ^Image, color: Color, threshold: f32) --- // Clear alpha channel to desired color - ImageAlphaMask :: proc(image: ^Image, alphaMask: Image) --- // Apply alpha mask to image - ImageAlphaPremultiply :: proc(image: ^Image) --- // Premultiply alpha channel - ImageResize :: proc(image: ^Image, newWidth, newHeight: c.int) --- // Resize image (Bicubic scaling algorithm) - ImageResizeNN :: proc(image: ^Image, newWidth, newHeight: c.int) --- // Resize image (Nearest-Neighbor scaling algorithm) - ImageResizeCanvas :: proc(image: ^Image, newWidth, newHeight: c.int, offsetX, offsetY: c.int, fill: Color) --- // Resize canvas and fill with color - ImageMipmaps :: proc(image: ^Image) --- // Generate all mipmap levels for a provided image - ImageDither :: proc(image: ^Image, rBpp, gBpp, bBpp, aBpp: c.int) --- // Dither image data to 16bpp or lower (Floyd-Steinberg dithering) - ImageFlipVertical :: proc(image: ^Image) --- // Flip image vertically - ImageFlipHorizontal :: proc(image: ^Image) --- // Flip image horizontally - ImageRotateCW :: proc(image: ^Image) --- // Rotate image clockwise 90deg - ImageRotateCCW :: proc(image: ^Image) --- // Rotate image counter-clockwise 90deg - ImageColorTint :: proc(image: ^Image, color: Color) --- // Modify image color: tint - ImageColorInvert :: proc(image: ^Image) --- // Modify image color: invert - ImageColorGrayscale :: proc(image: ^Image) --- // Modify image color: grayscale - ImageColorContrast :: proc(image: ^Image, contrast: f32) --- // Modify image color: contrast (-100 to 100) - ImageColorBrightness :: proc(image: ^Image, brightness: c.int) --- // Modify image color: brightness (-255 to 255) - ImageColorReplace :: proc(image: ^Image, color, replace: Color) --- // Modify image color: replace color - LoadImageColors :: proc(image: Image) -> [^]Color --- // Load color data from image as a Color array (RGBA - 32bit) - LoadImagePalette :: proc(image: Image, maxPaletteSize: c.int, colorsCount: [^]c.int) -> [^]Color --- // Load colors palette from image as a Color array (RGBA - 32bit) - UnloadImageColors :: proc(colors: [^]Color) --- // Unload color data loaded with LoadImageColors() - UnloadImagePalette :: proc(colors: [^]Color) --- // Unload colors palette loaded with LoadImagePalette() - GetImageAlphaBorder :: proc(image: Image, threshold: f32) -> Rectangle --- // Get image alpha border rectangle - GetImageColor :: proc(image: Image, x, y: c.int) -> Color --- // Get image pixel color at (x, y) position + + ImageCopy :: proc(image: Image) -> Image --- // Create an image duplicate (useful for transformations) + ImageFromImage :: proc(image: Image, rec: Rectangle) -> Image --- // Create an image from another image piece + ImageText :: proc(text: cstring, fontSize: c.int, color: Color) -> Image --- // Create an image from text (default font) + ImageTextEx :: proc(font: Font, text: cstring, fontSize: f32, spacing: f32, tint: Color) -> Image --- // Create an image from text (custom sprite font) + ImageFormat :: proc(image: ^Image, newFormat: PixelFormat) --- // Convert image data to desired format + ImageToPOT :: proc(image: ^Image, fill: Color) --- // Convert image to POT (power-of-two) + ImageCrop :: proc(image: ^Image, crop: Rectangle) --- // Crop an image to a defined rectangle + ImageAlphaCrop :: proc(image: ^Image, threshold: f32) --- // Crop image depending on alpha value + ImageAlphaClear :: proc(image: ^Image, color: Color, threshold: f32) --- // Clear alpha channel to desired color + ImageAlphaMask :: proc(image: ^Image, alphaMask: Image) --- // Apply alpha mask to image + ImageAlphaPremultiply :: proc(image: ^Image) --- // Premultiply alpha channel + ImageBlurGaussian :: proc(image: ^Image, blurSize: c.int) --- // Apply Gaussian blur using a box blur approximation + ImageResize :: proc(image: ^Image, newWidth, newHeight: c.int) --- // Resize image (Bicubic scaling algorithm) + ImageResizeNN :: proc(image: ^Image, newWidth, newHeight: c.int) --- // Resize image (Nearest-Neighbor scaling algorithm) + ImageResizeCanvas :: proc(image: ^Image, newWidth, newHeight: c.int, offsetX, offsetY: c.int, fill: Color) --- // Resize canvas and fill with color + ImageMipmaps :: proc(image: ^Image) --- // Compute all mipmap levels for a provided image + ImageDither :: proc(image: ^Image, rBpp, gBpp, bBpp, aBpp: c.int) --- // Dither image data to 16bpp or lower (Floyd-Steinberg dithering) + ImageFlipVertical :: proc(image: ^Image) --- // Flip image vertically + ImageFlipHorizontal :: proc(image: ^Image) --- // Flip image horizontally + ImageRotateCW :: proc(image: ^Image) --- // Rotate image clockwise 90deg + ImageRotateCCW :: proc(image: ^Image) --- // Rotate image counter-clockwise 90deg + ImageColorTint :: proc(image: ^Image, color: Color) --- // Modify image color: tint + ImageColorInvert :: proc(image: ^Image) --- // Modify image color: invert + ImageColorGrayscale :: proc(image: ^Image) --- // Modify image color: grayscale + ImageColorContrast :: proc(image: ^Image, contrast: f32) --- // Modify image color: contrast (-100 to 100) + ImageColorBrightness :: proc(image: ^Image, brightness: c.int) --- // Modify image color: brightness (-255 to 255) + ImageColorReplace :: proc(image: ^Image, color, replace: Color) --- // Modify image color: replace color + LoadImageColors :: proc(image: Image) -> [^]Color --- // Load color data from image as a Color array (RGBA - 32bit) + LoadImagePalette :: proc(image: Image, maxPaletteSize: c.int, colorCount: ^c.int) -> [^]Color --- // Load colors palette from image as a Color array (RGBA - 32bit) + UnloadImageColors :: proc(colors: [^]Color) --- // Unload color data loaded with LoadImageColors() + UnloadImagePalette :: proc(colors: [^]Color) --- // Unload colors palette loaded with LoadImagePalette() + GetImageAlphaBorder :: proc(image: Image, threshold: f32) -> Rectangle --- // Get image alpha border rectangle + GetImageColor :: proc(image: Image, x, y: c.int) -> Color --- // Get image pixel color at (x, y) position // Image drawing functions // NOTE: Image software-rendering functions (CPU) - ImageClearBackground :: proc(dst: ^Image, color: Color) --- // Clear image background with given color - ImageDrawPixel :: proc(dst: ^Image, posX, posY: c.int, color: Color) --- // Draw pixel within an image - ImageDrawPixelV :: proc(dst: ^Image, position: Vector2, color: Color) --- // Draw pixel within an image (Vector version) - ImageDrawLine :: proc(dst: ^Image, startPosX, startPosY, endPosX, endPosY: c.int, color: Color) --- // Draw line within an image - ImageDrawLineV :: proc(dst: ^Image, start, end: Vector2, color: Color) --- // Draw line within an image (Vector version) - ImageDrawCircle :: proc(dst: ^Image, centerX, centerY, radius: c.int, color: Color) --- // Draw circle within an image - ImageDrawCircleV :: proc(dst: ^Image, center: Vector2, radius: c.int, color: Color) --- // Draw circle within an image (Vector version) - ImageDrawRectangle :: proc(dst: ^Image, posX, posY, width, height: c.int, color: Color) --- // Draw rectangle within an image - ImageDrawRectangleV :: proc(dst: ^Image, position, size: Vector2, color: Color) --- // Draw rectangle within an image (Vector version) - ImageDrawRectangleRec :: proc(dst: ^Image, rec: Rectangle, color: Color) --- // Draw rectangle within an image - ImageDrawRectangleLines :: proc(dst: ^Image, rec: Rectangle, thick: c.int, color: Color) --- // Draw rectangle lines within an image - ImageDraw :: proc(dst: ^Image, src: Image, srcRec, dstRec: Rectangle, tint: Color) --- // Draw a source image within a destination image (tint applied to source) - ImageDrawText :: proc(dst: ^Image, text: cstring, posX, posY: c.int, fontSize: c.int, color: Color) --- // Draw text (using default font) within an image (destination) - ImageDrawTextEx :: proc(dst: ^Image, font: Font, text: cstring, position: Vector2, fontSize, spacing: f32, tint: Color) --- // Draw text (custom sprite font) within an image (destination) + + ImageClearBackground :: proc(dst: ^Image, color: Color) --- // Clear image background with given color + ImageDrawPixel :: proc(dst: ^Image, posX, posY: c.int, color: Color) --- // Draw pixel within an image + ImageDrawPixelV :: proc(dst: ^Image, position: Vector2, color: Color) --- // Draw pixel within an image (Vector version) + ImageDrawLine :: proc(dst: ^Image, startPosX, startPosY, endPosX, endPosY: c.int, color: Color) --- // Draw line within an image + ImageDrawLineV :: proc(dst: ^Image, start, end: Vector2, color: Color) --- // Draw line within an image (Vector version) + ImageDrawCircle :: proc(dst: ^Image, centerX, centerY: c.int, radius: c.int, color: Color) --- // Draw a filled circle within an image + ImageDrawCircleV :: proc(dst: ^Image, center: Vector2, radius: c.int, color: Color) --- // Draw a filled circle within an image (Vector version) + ImageDrawCircleLines :: proc(dst: ^Image, centerX, centerY: c.int, radius: c.int, color: Color) --- // Draw circle outline within an image + ImageDrawCircleLinesV :: proc(dst: ^Image, center: Vector2, radius: c.int, color: Color) --- // Draw circle outline within an image (Vector version) + ImageDrawRectangle :: proc(dst: ^Image, posX, posY: c.int, width, height: c.int, color: Color) --- // Draw rectangle within an image + ImageDrawRectangleV :: proc(dst: ^Image, position, size: Vector2, color: Color) --- // Draw rectangle within an image (Vector version) + ImageDrawRectangleRec :: proc(dst: ^Image, rec: Rectangle, color: Color) --- // Draw rectangle within an image + ImageDrawRectangleLines :: proc(dst: ^Image, rec: Rectangle, thick: c.int, color: Color) --- // Draw rectangle lines within an image + ImageDraw :: proc(dst: ^Image, src: Image, srcRec, dstRec: Rectangle, tint: Color) --- // Draw a source image within a destination image (tint applied to source) + ImageDrawText :: proc(dst: ^Image, text: cstring, posX, posY: c.int, fontSize: c.int, color: Color) --- // Draw text (using default font) within an image (destination) + ImageDrawTextEx :: proc(dst: ^Image, font: Font, text: cstring, position: Vector2, fontSize: f32, spacing: f32, tint: Color) --- // Draw text (custom sprite font) within an image (destination) // Texture loading functions // NOTE: These functions require GPU access + LoadTexture :: proc(fileName: cstring) -> Texture2D --- // Load texture from file into GPU memory (VRAM) LoadTextureFromImage :: proc(image: Image) -> Texture2D --- // Load texture from image data LoadTextureCubemap :: proc(image: Image, layout: CubemapLayout) -> TextureCubemap --- // Load cubemap from image, multiple image cubemap layouts supported LoadRenderTexture :: proc(width, height: c.int) -> RenderTexture2D --- // Load texture for rendering (framebuffer) + IsTextureReady :: proc(texture: Texture2D) -> bool --- // Check if a texture is ready UnloadTexture :: proc(texture: Texture2D) --- // Unload texture from GPU memory (VRAM) + IsRenderTextureReady :: proc(target: RenderTexture2D) -> bool --- // Check if a render texture is ready UnloadRenderTexture :: proc(target: RenderTexture2D) --- // Unload render texture from GPU memory (VRAM) UpdateTexture :: proc(texture: Texture2D, pixels: rawptr) --- // Update GPU texture with new data UpdateTextureRec :: proc(texture: Texture2D, rec: Rectangle, pixels: rawptr) --- // Update GPU texture rectangle with new data // Texture configuration functions - GenTextureMipmaps :: proc(texture: ^Texture2D) --- // Generate GPU mipmaps for a texture - SetTextureFilter :: proc(texture: Texture2D, filter: TextureFilter) --- // Set texture scaling filter mode - SetTextureWrap :: proc(texture: Texture2D, wrap: TextureWrap) --- // Set texture wrapping mode - // Texture drawing functions - DrawTexture :: proc(texture: Texture2D, posX, posY: c.int, tint: Color) --- // Draw a Texture2D - DrawTextureV :: proc(texture: Texture2D, position: Vector2, tint: Color) --- // Draw a Texture2D with position defined as Vector2 - DrawTextureEx :: proc(texture: Texture2D, position: Vector2, rotation, scale: f32, tint: Color) --- // Draw a Texture2D with extended parameters - DrawTextureRec :: proc(texture: Texture2D, source: Rectangle, position: Vector2, tint: Color) --- // Draw a part of a texture defined by a rectangle - DrawTextureQuad :: proc(texture: Texture2D, tiling: Vector2, offset: Vector2, quad: Rectangle, tint: Color) --- // Draw texture quad with tiling and offset parameters - DrawTextureTiled :: proc(texture: Texture2D, source, dest: Rectangle, origin: Vector2, rotation, scale: f32, tint: Color) --- // Draw part of a texture (defined by a rectangle) with rotation and scale tiled into dest. - DrawTexturePro :: proc(texture: Texture2D, source, dest: Rectangle, origin: Vector2, rotation: f32, tint: Color) --- // Draw a part of a texture defined by a rectangle with 'pro' parameters - DrawTextureNPatch :: proc(texture: Texture2D, nPatchInfo: NPatchInfo, dest: Rectangle, origin: Vector2, rotation: f32, tint: Color) --- // Draws a texture (or part of it) that stretches or shrinks nicely - DrawTexturePoly :: proc(texture: Texture2D, center: Vector2, points: [^]Vector2, texcoords: [^]Vector2, pointsCount: c.int, tint: Color) --- // Draw a textured polygon + GenTextureMipmaps :: proc(texture: ^Texture2D) --- // Generate GPU mipmaps for a texture + SetTextureFilter :: proc(texture: Texture2D, filter: TextureFilter) --- // Set texture scaling filter mode + SetTextureWrap :: proc(texture: Texture2D, wrap: TextureWrap) --- // Set texture wrapping mode + + // Texture drawing functions + DrawTexture :: proc(texture: Texture2D, posX, posY: c.int, tint: Color) --- // Draw a Texture2D + DrawTextureV :: proc(texture: Texture2D, position: Vector2, tint: Color) --- // Draw a Texture2D with position defined as Vector2 + DrawTextureEx :: proc(texture: Texture2D, position: Vector2, rotation: f32, scale: f32, tint: Color) --- // Draw a Texture2D with extended parameters + DrawTextureRec :: proc(texture: Texture2D, source: Rectangle, position: Vector2, tint: Color) --- // Draw a part of a texture defined by a rectangle + DrawTexturePro :: proc(texture: Texture2D, source, dest: Rectangle, origin: Vector2, rotation: f32, tint: Color) --- // Draw a part of a texture defined by a rectangle with 'pro' parameters + DrawTextureNPatch :: proc(texture: Texture2D, nPatchInfo: NPatchInfo, dest: Rectangle, origin: Vector2, rotation: f32, tint: Color) --- // Draws a texture (or part of it) that stretches or shrinks nicely // Color/pixel related functions - Fade :: proc(color: Color, alpha: f32) -> Color --- // Returns color with alpha applied, alpha goes from 0.0f to 1.0f - ColorToInt :: proc(color: Color) -> c.int --- // Returns hexadecimal value for a Color - ColorNormalize :: proc(color: Color) -> Vector4 --- // Returns Color normalized as float [0..1] - ColorFromNormalized :: proc(normalized: Vector4) -> Color --- // Returns Color from normalized values [0..1] - ColorToHSV :: proc(color: Color) -> Vector3 --- // Returns HSV values for a Color, hue [0..360], saturation/value [0..1] - ColorFromHSV :: proc(hue, saturation, value: f32) -> Color --- // Returns a Color from HSV values, hue [0..360], saturation/value [0..1] - ColorAlpha :: proc(color: Color, alpha: f32) -> Color --- // Returns color with alpha applied, alpha goes from 0.0f to 1.0f - ColorAlphaBlend :: proc(dst, src, tint: Color) -> Color --- // Returns src alpha-blended into dst color with tint - GetColor :: proc(hexValue: c.int) -> Color --- // Get Color structure from hexadecimal value + + Fade :: proc(color: Color, alpha: f32) -> Color --- // Get color with alpha applied, alpha goes from 0.0f to 1.0f + ColorToInt :: proc(color: Color) -> c.uint --- // Get hexadecimal value for a Color + ColorNormalize :: proc(color: Color) -> Vector4 --- // Get Color normalized as float [0..1] + ColorFromNormalized :: proc(normalized: Vector4) -> Color --- // Get Color from normalized values [0..1] + ColorToHSV :: proc(color: Color) -> Vector3 --- // Get HSV values for a Color, hue [0..360], saturation/value [0..1] + ColorFromHSV :: proc(hue, saturation, value: f32) -> Color --- // Get a Color from HSV values, hue [0..360], saturation/value [0..1] + ColorTint :: proc(color, tint: Color) -> Color --- // Get color multiplied with another color + ColorBrightness :: proc(color: Color, factor: f32) -> Color --- // Get color with brightness correction, brightness factor goes from -1.0f to 1.0f + ColorContrast :: proc(color: Color, contrast: f32) -> Color --- // Get color with contrast correction, contrast values between -1.0f and 1.0f + ColorAlpha :: proc(color: Color, alpha: f32) -> Color --- // Get color with alpha applied, alpha goes from 0.0f to 1.0f + ColorAlphaBlend :: proc(dst, src, tint: Color) -> Color --- // Get src alpha-blended into dst color with tint + GetColor :: proc(hexValue: c.uint) -> Color --- // Get Color structure from hexadecimal value GetPixelColor :: proc(srcPtr: rawptr, format: PixelFormat) -> Color --- // Get Color from a source pixel pointer of certain format SetPixelColor :: proc(dstPtr: rawptr, color: Color, format: PixelFormat) --- // Set color formatted into destination pixel pointer GetPixelDataSize :: proc(width, height: c.int, format: PixelFormat) -> c.int --- // Get pixel data size in bytes for certain format + + + //------------------------------------------------------------------------------------ // Font Loading and Text Drawing Functions (Module: text) //------------------------------------------------------------------------------------ // Font loading/unloading functions - GetFontDefault :: proc() -> Font --- // Get the default Font - LoadFont :: proc(fileName: cstring) -> Font --- // Load font from file into GPU memory (VRAM) - LoadFontEx :: proc(fileName: cstring, fontSize: c.int, fontChars: [^]rune, charsCount: c.int) -> Font --- // Load font from file with extended parameters - LoadFontFromImage :: proc(image: Image, key: Color, firstChar: rune) -> Font --- // Load font from Image (XNA style) - LoadFontFromMemory :: proc(fileType: cstring, fileData: rawptr, dataSize: c.int, fontSize: c.int, fontChars: [^]rune, charsCount: c.int) -> Font --- // Load font from memory buffer, fileType refers to extension: i.e. ".ttf" - LoadFontData :: proc(fileData: rawptr, dataSize: c.int, fontSize: c.int, fontChars: [^]rune, charsCount: c.int, type: FontType) -> [^]GlyphInfo --- // Load font data for further use - GenImageFontAtlas :: proc(chars: [^]GlyphInfo, recs: ^[^]Rectangle, charsCount: c.int, fontSize: c.int, padding: c.int, packMethod: c.int) -> Image --- // Generate image font atlas using chars info - UnloadFontData :: proc(chars: [^]GlyphInfo, charsCount: c.int) --- // Unload font chars info data (RAM) - UnloadFont :: proc(font: Font) --- // Unload Font from GPU memory (VRAM) + + GetFontDefault :: proc() -> Font --- // Get the default Font + LoadFont :: proc(fileName: cstring) -> Font --- // Load font from file into GPU memory (VRAM) + LoadFontEx :: proc(fileName: cstring, fontSize: c.int, fontChars: [^]rune, glyphCount: c.int) -> Font --- // Load font from file with extended parameters, use NULL for fontChars and 0 for glyphCount to load the default character set + LoadFontFromImage :: proc(image: Image, key: Color, firstChar: rune) -> Font --- // Load font from Image (XNA style) + LoadFontFromMemory :: proc(fileType: cstring, fileData: rawptr, dataSize: c.int, fontSize: c.int, fontChars: [^]rune, glyphCount: c.int) -> Font --- // Load font from memory buffer, fileType refers to extension: i.e. '.ttf' + IsFontReady :: proc(font: Font) -> bool --- // Check if a font is ready + LoadFontData :: proc(fileData: rawptr, dataSize: c.int, fontSize: c.int, fontChars: [^]rune, glyphCount: c.int, type: FontType) -> [^]GlyphInfo --- // Load font data for further use + GenImageFontAtlas :: proc(chars: [^]GlyphInfo, recs: ^[^]Rectangle, glyphCount: c.int, fontSize: c.int, padding: c.int, packMethod: c.int) -> Image --- // Generate image font atlas using chars info + UnloadFontData :: proc(chars: [^]GlyphInfo, glyphCount: c.int) --- // Unload font chars info data (RAM) + UnloadFont :: proc(font: Font) --- // Unload font from GPU memory (VRAM) + ExportFontAsCode :: proc(font: Font, fileName: cstring) -> bool --- // Export font as code file, returns true on success // Text drawing functions - DrawFPS :: proc(posX, posY: c.int) --- // Draw current FPS - DrawText :: proc(text: cstring, posX, posY: c.int, fontSize: c.int, color: Color) --- // Draw text (using default font) - DrawTextEx :: proc(font: Font, text: cstring, position: Vector2, fontSize: f32, spacing: f32, tint: Color) --- // Draw text using font and additional parameters - DrawTextPro :: proc(font: Font, text: cstring, position, origin: Vector2, - rotation: f32, fontSize: f32, spacing: f32, tint: Color) --- // Draw text using Font and pro parameters (rotation) - DrawTextCodepoint :: proc(font: Font, codepoint: rune, position: Vector2, fontSize: f32, tint: Color) --- // Draw one character (codepoint) - // Text misc. functions - MeasureText :: proc(text: cstring, fontSize: c.int) -> c.int --- // Measure string width for default font - MeasureTextEx :: proc(font: Font, text: cstring, fontSize, spacing: f32) -> Vector2 --- // Measure string size for Font - GetGlyphIndex :: proc(font: Font, codepoint: rune) -> c.int --- // Get index position for a unicode character on font - GetGlyphInfo :: proc(font: Font, codepoint: rune) -> GlyphInfo --- // Get glyph font info data for a codepoint (unicode character), fallback to '?' if not found - GetGlyphAtlasRec :: proc(font: Font, codepoint: rune) -> Rectangle --- // Get glyph rectangle in font atlas for a codepoint (unicode character), fallback to '?' if not found + DrawFPS :: proc(posX, posY: c.int) --- // Draw current FPS + DrawText :: proc(text: cstring, posX, posY: c.int, fontSize: c.int, color: Color) --- // Draw text (using default font) + DrawTextEx :: proc(font: Font, text: cstring, position: Vector2, fontSize: f32, spacing: f32, tint: Color) --- // Draw text using font and additional parameters + DrawTextPro :: proc(font: Font, text: cstring, position, origin: Vector2, rotation: f32, fontSize: f32, spacing: f32, tint: Color) --- // Draw text using Font and pro parameters (rotation) + DrawTextCodepoint :: proc(font: Font, codepoint: rune, position: Vector2, fontSize: f32, tint: Color) --- // Draw one character (codepoint) + DrawTextCodepoints :: proc(font: Font, codepoints: [^]rune, count: c.int, position: Vector2, fontSize: f32, spacing: f32, tint: Color) --- // Draw multiple character (codepoint) + + // Text font info functions + + MeasureText :: proc(text: cstring, fontSize: c.int) -> c.int --- // Measure string width for default font + MeasureTextEx :: proc(font: Font, text: cstring, fontSize: f32, spacing: f32) -> Vector2 --- // Measure string size for Font + GetGlyphIndex :: proc(font: Font, codepoint: rune) -> c.int --- // Get glyph index position in font for a codepoint (unicode character), fallback to '?' if not found + GetGlyphInfo :: proc(font: Font, codepoint: rune) -> GlyphInfo --- // Get glyph font info data for a codepoint (unicode character), fallback to '?' if not found + GetGlyphAtlasRec :: proc(font: Font, codepoint: rune) -> Rectangle --- // Get glyph rectangle in font atlas for a codepoint (unicode character), fallback to '?' if not found // Text codepoints management functions (unicode characters) - LoadCodepoints :: proc(text: cstring, count: ^c.int) -> [^]rune --- // Load all codepoints from a UTF-8 text string, codepoints count returned by parameter - UnloadCodepoints :: proc(codepoints: [^]rune) --- // Unload codepoints data from memory - GetCodepointCount :: proc(text: cstring) -> c.int --- // Get total number of codepoints in a UTF-8 encoded string - GetCodepoint :: proc(text: cstring, bytesProcessed: ^c.int) -> c.int --- // Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure - CodepointToUTF8 :: proc(codepoint: rune, byteSize: ^c.int) -> cstring --- // Encode one codepoint into UTF-8 byte array (array length returned as parameter) - TextCodepointsToUTF8 :: proc(codepoints: [^]rune, length: c.int) -> cstring --- // Encode text as codepoints array into UTF-8 text string (WARNING: memory must be freed!) + LoadUTF8 :: proc(codepoints: [^]rune, length: c.int) -> [^]byte --- // Load UTF-8 text encoded from codepoints array + UnloadUTF8 :: proc(text: [^]byte) --- // Unload UTF-8 text encoded from codepoints array + LoadCodepoints :: proc(text: rawptr, count: ^c.int) -> [^]rune --- // Load all codepoints from a UTF-8 text string, codepoints count returned by parameter + UnloadCodepoints :: proc(codepoints: [^]rune) --- // Unload codepoints data from memory + GetCodepointCount :: proc(text : cstring) -> c.int --- // Get total number of codepoints in a UTF-8 encoded string + GetCodepoint :: proc(text: cstring, codepointSize: ^c.int) -> rune --- // Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure + GetCodepointNext :: proc(text: cstring, codepointSize: ^c.int) -> rune --- // Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure + GetCodepointPrevious :: proc(text: cstring, codepointSize: ^c.int) -> rune --- // Get previous codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure + CodepointToUTF8 :: proc(codepoint: rune, utf8Size: ^c.int) -> cstring --- // Encode one codepoint into UTF-8 byte array (array length returned as parameter) - // Text strings management functions (no utf8 strings, only byte chars) + // Text strings management functions (no UTF-8 strings, only byte chars) // NOTE: Some strings allocate memory internally for returned strings, just be careful! - TextCopy :: proc(dst: [^]u8, src: cstring) -> c.int --- // Copy one string to another, returns bytes copied - TextIsEqual :: proc(text1, text2: cstring) -> bool --- // Check if two text string are equal - TextLength :: proc(text: cstring) -> c.uint --- // Get text length, checks for '\0' ending - TextSubtext :: proc(text: cstring, position: c.int, length: c.int) -> cstring --- // Get a piece of a text string - TextReplace :: proc(text: [^]byte, replace, by: cstring) -> cstring --- // Replace text string (memory must be freed!) - TextInsert :: proc(text, insert: cstring, position: c.int) -> cstring --- // Insert text in a position (memory must be freed!) - TextJoin :: proc(textList: [^]cstring, count: c.int, delimiter: cstring) -> cstring --- // Join text strings with delimiter - TextSplit :: proc(text: cstring, delimiter: byte, count: ^c.int) -> [^]cstring --- // Split text into multiple strings - TextAppend :: proc(text: [^]byte, append: cstring, position: ^c.int) --- // Append text at specific position and move cursor! - TextFindIndex :: proc(text: cstring, find: cstring) -> c.int --- // Find first text occurrence within a string - TextToUpper :: proc(text: cstring) -> cstring --- // Get upper case version of provided string - TextToLower :: proc(text: cstring) -> cstring --- // Get lower case version of provided string - TextToPascal :: proc(text: cstring) -> cstring --- // Get Pascal case notation version of provided string - TextToInteger :: proc(text: cstring) -> c.int --- // Get integer value from text (negative values not supported) + + TextCopy :: proc(dst: [^]byte, src: cstring) -> c.int --- // Copy one string to another, returns bytes copied + TextIsEqual :: proc(text1, text2: cstring) -> bool --- // Check if two text string are equal + TextLength :: proc(text: cstring) -> c.uint --- // Get text length, checks for '\0' ending + + // TextFormat is defined at the bottom of this file + + TextSubtext :: proc(text: cstring, position: c.int, length: c.int) -> cstring --- // Get a piece of a text string + TextReplace :: proc(text: [^]byte, replace, by: cstring) -> [^]byte --- // Replace text string (WARNING: memory must be freed!) + TextInsert :: proc(text, insert: cstring, position: c.int) -> [^]byte --- // Insert text in a position (WARNING: memory must be freed!) + TextJoin :: proc(textList: [^]cstring, count: c.int, delimiter: cstring) -> cstring --- // Join text strings with delimiter + TextSplit :: proc(text: cstring, delimiter: byte, count: ^c.int) -> [^]cstring --- // Split text into multiple strings + TextAppend :: proc(text: [^]byte, append: cstring, position: ^c.int) --- // Append text at specific position and move cursor! + TextFindIndex :: proc(text, find: cstring) -> c.int --- // Find first text occurrence within a string + TextToUpper :: proc(text: cstring) -> cstring --- // Get upper case version of provided string + TextToLower :: proc(text: cstring) -> cstring --- // Get lower case version of provided string + TextToPascal :: proc(text: cstring) -> cstring --- // Get Pascal case notation version of provided string + TextToInteger :: proc(text: cstring) -> c.int --- // Get integer value from text (negative values not supported) + //------------------------------------------------------------------------------------ // Basic 3d Shapes Drawing Functions (Module: models) //------------------------------------------------------------------------------------ // Basic geometric 3D shapes drawing functions - DrawLine3D :: proc(startPos, endPos: Vector3, color: Color) --- // Draw a line in 3D world space - DrawPoint3D :: proc(position: Vector3, color: Color) --- // Draw a point in 3D space, actually a small line - DrawCircle3D :: proc(center: Vector3, radius: f32, rotationAxis: Vector3, rotationAngle: f32, color: Color) --- // Draw a circle in 3D world space - DrawTriangle3D :: proc(v1, v2, v3: Vector3, color: Color) --- // Draw a color-filled triangle (vertex in counter-clockwise order!) - DrawTriangleStrip3D :: proc(points: [^]Vector3, pointsCount: c.int, color: Color) --- // Draw a triangle strip defined by points - DrawCube :: proc(position: Vector3, width, height, length: f32, color: Color) --- // Draw cube - DrawCubeV :: proc(position: Vector3, size: Vector3, color: Color) --- // Draw cube (Vector version) - DrawCubeWires :: proc(position: Vector3, width, height, length: f32, color: Color) --- // Draw cube wires - DrawCubeWiresV :: proc(position: Vector3, size: Vector3, color: Color) --- // Draw cube wires (Vector version) - DrawCubeTexture :: proc(texture: Texture2D, position: Vector3, width, height, length: f32, color: Color) --- // Draw cube textured - DrawCubeTextureRec :: proc(texture: Texture2D, source: Rectangle, position: Vector3, width, height, length: f32, color: Color) --- // Draw cube with a region of a texture - DrawSphere :: proc(centerPos: Vector3, radius: f32, color: Color) --- // Draw sphere - DrawSphereEx :: proc(centerPos: Vector3, radius: f32, rings, slices: c.int, color: Color) --- // Draw sphere with extended parameters - DrawSphereWires :: proc(centerPos: Vector3, radius: f32, rings, slices: c.int, color: Color) --- // Draw sphere wires - DrawCylinder :: proc(position: Vector3, radiusTop, radiusBottom: f32, height: f32, slices: c.int, color: Color) --- // Draw a cylinder/cone - DrawCylinderEx :: proc(startPos, endPos: Vector3, startRadius, endRadius: f32, sides: c.int, color: Color) --- // Draw a cylinder with base at startPos and top at endPos - DrawCylinderWires :: proc(position: Vector3, radiusTop, radiusBottom: f32, height: f32, slices: c.int, color: Color) --- // Draw a cylinder/cone wires - DrawCylinderWiresEx :: proc(startPos, endPos: Vector3, startRadius, endRadius: f32, sides: c.int, color: Color) --- // Draw a cylinder wires with base at startPos and top at endPos - DrawPlane :: proc(centerPos: Vector3, size: Vector2, color: Color) --- // Draw a plane XZ - DrawRay :: proc(ray: Ray, color: Color) --- // Draw a ray line - DrawGrid :: proc(slices: c.int, spacing: f32) --- // Draw a grid (centered at (0, 0, 0)) + + DrawLine3D :: proc(startPos, endPos: Vector3, color: Color) --- // Draw a line in 3D world space + DrawPoint3D :: proc(position: Vector3, color: Color) --- // Draw a point in 3D space, actually a small line + DrawCircle3D :: proc(center: Vector3, radius: f32, rotationAxis: Vector3, rotationAngle: f32, color: Color) --- // Draw a circle in 3D world space + DrawTriangle3D :: proc(v1, v2, v3: Vector3, color: Color) --- // Draw a color-filled triangle (vertex in counter-clockwise order!) + DrawTriangleStrip3D :: proc(points: [^]Vector3, pointCount: c.int, color: Color) --- // Draw a triangle strip defined by points + DrawCube :: proc(position: Vector3, width, height, length: f32, color: Color) --- // Draw cube + DrawCubeV :: proc(position: Vector3, size: Vector3, color: Color) --- // Draw cube (Vector version) + DrawCubeWires :: proc(position: Vector3, width, height, length: f32, color: Color) --- // Draw cube wires + DrawCubeWiresV :: proc(position, size: Vector3, color: Color) --- // Draw cube wires (Vector version) + DrawSphere :: proc(centerPos: Vector3, radius: f32, color: Color) --- // Draw sphere + DrawSphereEx :: proc(centerPos: Vector3, radius: f32, rings, slices: c.int, color: Color) --- // Draw sphere with extended parameters + DrawSphereWires :: proc(centerPos: Vector3, radius: f32, rings, slices: c.int, color: Color) --- // Draw sphere wires + DrawCylinder :: proc(position: Vector3, radiusTop, radiusBottom: f32, height: f32, slices: c.int, color: Color) --- // Draw a cylinder/cone + DrawCylinderEx :: proc(startPos, endPos: Vector3, startRadius, endRadius: f32, sides: c.int, color: Color) --- // Draw a cylinder with base at startPos and top at endPos + DrawCylinderWires :: proc(position: Vector3, radiusTop, radiusBottom, height: f32, slices: c.int, color: Color) --- // Draw a cylinder/cone wires + DrawCylinderWiresEx :: proc(startPos, endPos: Vector3, startRadius, endRadius: f32, sides: c.int, color: Color) --- // Draw a cylinder wires with base at startPos and top at endPos + DrawCapsule :: proc(startPos, endPos: Vector3, radius: f32, slices, rings: c.int, color: Color) --- // Draw a capsule with the center of its sphere caps at startPos and endPos + DrawCapsuleWires :: proc(startPos, endPos: Vector3, radius: f32, slices, rings: c.int, color: Color) --- // Draw capsule wireframe with the center of its sphere caps at startPos and endPos + DrawPlane :: proc(centerPos: Vector3, size: Vector2, color: Color) --- // Draw a plane XZ + DrawRay :: proc(ray: Ray, color: Color) --- // Draw a ray line + DrawGrid :: proc(slices: c.int, spacing: f32) --- // Draw a grid (centered at (0, 0, 0)) //------------------------------------------------------------------------------------ // Model 3d Loading and Drawing Functions (Module: models) //------------------------------------------------------------------------------------ - // Model loading/unloading functions - LoadModel :: proc(fileName: cstring) -> Model --- // Load model from files (meshes and materials) - LoadModelFromMesh :: proc(mesh: Mesh) -> Model --- // Load model from generated mesh (default material) - UnloadModel :: proc(model: Model) --- // Unload model (including meshes) from memory (RAM and/or VRAM) - UnloadModelKeepMeshes :: proc(model: Model) --- // Unload model (but not meshes) from memory (RAM and/or VRAM) - GetModelBoundingBox :: proc(model: Model) -> BoundingBox --- // Compute model bounding box limits (considers all meshes) + // Model management functions + + LoadModel :: proc(fileName: cstring) -> Model --- // Load model from files (meshes and materials) + LoadModelFromMesh :: proc(mesh: Mesh) -> Model --- // Load model from generated mesh (default material) + IsModelReady :: proc(model: Model) -> bool --- // Check if a model is ready + UnloadModel :: proc(model: Model) --- // Unload model (including meshes) from memory (RAM and/or VRAM) + GetModelBoundingBox :: proc(model: Model) -> BoundingBox --- // Compute model bounding box limits (considers all meshes) // Model drawing functions - DrawModel :: proc(model: Model, position: Vector3, scale: f32, tint: Color) --- // Draw a model (with texture if set) - DrawModelEx :: proc(model: Model, position: Vector3, rotationAxis: Vector3, rotationAngle: f32, scale: Vector3, tint: Color) --- // Draw a model with extended parameters - DrawModelWires :: proc(model: Model, position: Vector3, scale: f32, tint: Color) --- // Draw a model wires (with texture if set) - DrawModelWiresEx :: proc(model: Model, position: Vector3, rotationAxis: Vector3, rotationAngle: f32, scale: Vector3, tint: Color) --- // Draw a model wires (with texture if set) with extended parameters - DrawBoundingBox :: proc(box: BoundingBox, color: Color) --- // Draw bounding box (wires) - DrawBillboard :: proc(camera: Camera, texture: Texture2D, center: Vector3, size: f32, tint: Color) --- // Draw a billboard texture - DrawBillboardRec :: proc(camera: Camera, texture: Texture2D, source: Rectangle, center: Vector3, size: f32, tint: Color) --- // Draw a billboard texture defined by source - DrawBillboardPro :: proc(camera: Camera, texture: Texture2D, source: Rectangle, - position, up: Vector3, size, origin: Vector2, rotation: f32, tint: Color) --- // Draw a billboard texture defined by source and rotation + + DrawModel :: proc(model: Model, position: Vector3, scale: f32, tint: Color) --- // Draw a model (with texture if set) + DrawModelEx :: proc(model: Model, position: Vector3, rotationAxis: Vector3, rotationAngle: f32, scale: Vector3, tint: Color) --- // Draw a model with extended parameters + DrawModelWires :: proc(model: Model, position: Vector3, scale: f32, tint: Color) --- // Draw a model wires (with texture if set) + DrawModelWiresEx :: proc(model: Model, position: Vector3, rotationAxis: Vector3, rotationAngle: f32, scale: Vector3, tint: Color) --- // Draw a model wires (with texture if set) with extended parameters + DrawBoundingBox :: proc(box: BoundingBox, color: Color) --- // Draw bounding box (wires) + DrawBillboard :: proc(camera: Camera, texture: Texture2D, position: Vector3, size: f32, tint: Color) --- // Draw a billboard texture + DrawBillboardRec :: proc(camera: Camera, texture: Texture2D, source: Rectangle, position: Vector3, size: Vector2, tint: Color) --- // Draw a billboard texture defined by source + DrawBillboardPro :: proc(camera: Camera, texture: Texture2D, source: Rectangle, position: Vector3, up: Vector3, size: Vector2, origin: Vector2, rotation: f32, tint: Color) --- // Draw a billboard texture defined by source and rotation // Mesh management functions - UploadMesh :: proc(mesh: ^Mesh, is_dynamic: bool) --- // Upload mesh vertex data in GPU and provide VAO/VBO ids - UpdateMeshBuffer :: proc(mesh: Mesh, index: c.int, data: rawptr, dataSize: c.int, offset: c.int) --- // Update mesh vertex data in GPU for a specific buffer index - UnloadMesh :: proc(mesh: Mesh) --- // Unload mesh data from CPU and GPU - DrawMesh :: proc(mesh: Mesh, material: Material, transform: Matrix) --- // Draw a 3d mesh with material and transform - DrawMeshInstanced :: proc(mesh: Mesh, material: Material, transforms: [^]Matrix, instances: c.int) --- // Draw multiple mesh instances with material and different transforms - ExportMesh :: proc(mesh: Mesh, fileName: cstring) -> bool --- // Export mesh data to file, returns true on success - GetMeshBoundingBox :: proc(mesh: Mesh) -> BoundingBox --- // Compute mesh bounding box limits - GenMeshTangents :: proc(mesh: ^Mesh) --- // Compute mesh tangents - GenMeshBinormals :: proc(mesh: ^Mesh) --- - + + UploadMesh :: proc(mesh: ^Mesh, is_dynamic: bool) --- // Upload mesh vertex data in GPU and provide VAO/VBO ids + UpdateMeshBuffer :: proc(mesh: Mesh, index: c.int, data: rawptr, dataSize: c.int, offset: c.int) --- // Update mesh vertex data in GPU for a specific buffer index + UnloadMesh :: proc(mesh: Mesh) --- // Unload mesh data from CPU and GPU + DrawMesh :: proc(mesh: Mesh, material: Material, transform: Matrix) --- // Draw a 3d mesh with material and transform + DrawMeshInstanced :: proc(mesh: Mesh, material: Material, transforms: [^]Matrix, instances: c.int) --- // Draw multiple mesh instances with material and different transforms + ExportMesh :: proc(mesh: Mesh, fileName: cstring) -> bool --- // Export mesh data to file, returns true on success + GetMeshBoundingBox :: proc(mesh: Mesh) -> BoundingBox --- // Compute mesh bounding box limits + GenMeshTangents :: proc(mesh: ^Mesh) --- // Compute mesh tangents + // Mesh generation functions - GenMeshPoly :: proc(sides: c.int, radius: f32) -> Mesh --- // Generate polygonal mesh - GenMeshPlane :: proc(width, length: f32, resX, resZ: c.int) -> Mesh --- // Generate plane mesh (with subdivisions) - GenMeshCube :: proc(width, height, length: f32) -> Mesh --- // Generate cuboid mesh - GenMeshSphere :: proc(radius: f32, rings, slices: c.int) -> Mesh --- // Generate sphere mesh (standard sphere) - GenMeshHemiSphere :: proc(radius: f32, rings, slices: c.int) -> Mesh --- // Generate half-sphere mesh (no bottom cap) - GenMeshCylinder :: proc(radius: f32, height: f32, slices: c.int) -> Mesh --- // Generate cylinder mesh - GenMeshCone :: proc(radius: f32, height: f32, slices: c.int) -> Mesh --- // Generate cone/pyramid mesh - GenMeshTorus :: proc(radius: f32, size: f32, radSeg: c.int, sides: c.int) -> Mesh --- // Generate torus mesh - GenMeshKnot :: proc(radius: f32, size: f32, radSeg: c.int, sides: c.int) -> Mesh --- // Generate trefoil knot mesh - GenMeshHeightmap :: proc(heightmap: Image, size: Vector3) -> Mesh --- // Generate heightmap mesh from image data - GenMeshCubicmap :: proc(cubicmap: Image, cubeSize: Vector3) -> Mesh --- // Generate cubes-based map mesh from image data + + GenMeshPoly :: proc(sides: c.int, radius: f32) -> Mesh --- // Generate polygonal mesh + GenMeshPlane :: proc(width, lengthL: f32, resX, resZ: c.int) -> Mesh --- // Generate plane mesh (with subdivisions) + GenMeshCube :: proc(width, height, length: f32) -> Mesh --- // Generate cuboid mesh + GenMeshSphere :: proc(radius: f32, rings, slices: c.int) -> Mesh --- // Generate sphere mesh (standard sphere) + GenMeshHemiSphere :: proc(radius: f32, rings, slices: c.int) -> Mesh --- // Generate half-sphere mesh (no bottom cap) + GenMeshCylinder :: proc(radius, height: f32, slices: c.int) -> Mesh --- // Generate cylinder mesh + GenMeshCone :: proc(radius, height: f32, slices: c.int) -> Mesh --- // Generate cone/pyramid mesh + GenMeshTorus :: proc(radius, size: f32, radSeg, sides: c.int) -> Mesh --- // Generate torus mesh + GenMeshKnot :: proc(radius, size: f32, radSeg, sides: c.int) -> Mesh --- // Generate trefoil knot mesh + GenMeshHeightmap :: proc(heightmap: Image, size: Vector3) -> Mesh --- // Generate heightmap mesh from image data + GenMeshCubicmap :: proc(cubicmap: Image, cubeSize: Vector3) -> Mesh --- // Generate cubes-based map mesh from image data // Material loading/unloading functions - LoadMaterials :: proc(fileName: cstring, materialCount: ^c.int) -> [^]Material --- // Load materials from model file - LoadMaterialDefault :: proc() -> Material --- // Load default material (Supports: DIFFUSE, SPECULAR, NORMAL maps) - UnloadMaterial :: proc(material: Material) --- // Unload material from GPU memory (VRAM) - SetMaterialTexture :: proc(material: ^Material, mapType: MaterialMapIndex, texture: Texture2D) --- // Set texture for a material map type (MATERIAL_MAP_DIFFUSE, MATERIAL_MAP_SPECULAR...) - SetModelMeshMaterial :: proc(model: ^Model, meshId: c.int, materialId: c.int) --- // Set material for a mesh + + LoadMaterials :: proc(fileName: cstring, materialCount: ^c.int) -> [^]Material --- // Load materials from model file + LoadMaterialDefault :: proc() -> Material --- // Load default material (Supports: DIFFUSE, SPECULAR, NORMAL maps) + IsMaterialReady :: proc(material: Material) -> bool --- // Check if a material is ready + UnloadMaterial :: proc(material: Material) --- // Unload material from GPU memory (VRAM) + SetMaterialTexture :: proc(material: ^Material, mapType: MaterialMapIndex, texture: Texture2D) --- // Set texture for a material map type (MATERIAL_MAP_DIFFUSE, MATERIAL_MAP_SPECULAR...) + SetModelMeshMaterial :: proc(model: ^Model, meshId: c.int, materialId: c.int) --- // Set material for a mesh // Model animations loading/unloading functions - LoadModelAnimations :: proc(fileName: cstring, animsCount: ^c.int) -> [^]ModelAnimation --- // Load model animations from file - UpdateModelAnimation :: proc(model: Model, anim: ModelAnimation, frame: c.int) --- // Update model animation pose - UnloadModelAnimation :: proc(anim: ModelAnimation) --- // Unload animation data - UnloadModelAnimations :: proc(animations: [^]ModelAnimation, count: c.uint) --- // Unload animation array data - IsModelAnimationValid :: proc(model: Model, anim: ModelAnimation) -> bool --- // Check model animation skeleton match - + + LoadModelAnimations :: proc(fileName: cstring, animCount: ^c.uint) -> [^]ModelAnimation --- // Load model animations from file + UpdateModelAnimation :: proc(model: Model, anim: ModelAnimation, frame: c.int) --- // Update model animation pose + UnloadModelAnimation :: proc(anim: ModelAnimation) --- // Unload animation data + UnloadModelAnimations :: proc(animations: [^]ModelAnimation, count: c.uint) --- // Unload animation array data + IsModelAnimationValid :: proc(model: Model, anim: ModelAnimation) -> bool --- // Check model animation skeleton match + // Collision detection functions + CheckCollisionSpheres :: proc(center1: Vector3, radius1: f32, center2: Vector3, radius2: f32) -> bool --- // Check collision between two spheres CheckCollisionBoxes :: proc(box1, box2: BoundingBox) -> bool --- // Check collision between two bounding boxes CheckCollisionBoxSphere :: proc(box: BoundingBox, center: Vector3, radius: f32) -> bool --- // Check collision between box and sphere - GetRayCollisionSphere :: proc(ray: Ray, center: Vector3, radius: f32) -> RayCollision --- // Get collision info between ray and sphere - GetRayCollisionBox :: proc(ray: Ray, box: BoundingBox) -> RayCollision --- // Get collision info between ray and box - GetRayCollisionModel :: proc(ray: Ray, model: Model) -> RayCollision --- // Get collision info between ray and model - GetRayCollisionMesh :: proc(ray: Ray, mesh: Mesh, transform: Matrix) -> RayCollision --- // Get collision info between ray and mesh - GetRayCollisionTriangle :: proc(ray: Ray, p1, p2, p3: Vector3) -> RayCollision --- // Get collision info between ray and triangle - GetRayCollisionQuad :: proc(ray: Ray, p1, p2, p3, p4: Vector3) -> RayCollision --- // Get collision info between ray and quad + GetRayCollisionSphere :: proc(ray: Ray, center: Vector3, radius: f32) -> RayCollision --- // Get collision info between ray and sphere + GetRayCollisionBox :: proc(ray: Ray, box: BoundingBox) -> RayCollision --- // Get collision info between ray and box + GetRayCollisionMesh :: proc(ray: Ray, mesh: Mesh, transform: Matrix) -> RayCollision --- // Get collision info between ray and mesh + GetRayCollisionTriangle :: proc(ray: Ray, p1, p2, p3: Vector3) -> RayCollision --- // Get collision info between ray and triangle + GetRayCollisionQuad :: proc(ray: Ray, p1, p2, p3, p4: Vector3) -> RayCollision --- // Get collision info between ray and quad //------------------------------------------------------------------------------------ // Audio Loading and Playing Functions (Module: audio) //------------------------------------------------------------------------------------ // Audio device management functions - InitAudioDevice :: proc() --- // Initialize audio device and context - CloseAudioDevice :: proc() --- // Close the audio device and context - IsAudioDeviceReady :: proc() -> bool --- // Check if audio device has been initialized successfully - SetMasterVolume :: proc(volume: f32) --- // Set master volume (listener) + + InitAudioDevice :: proc() --- // Initialize audio device and context + CloseAudioDevice :: proc() --- // Close the audio device and context + IsAudioDeviceReady :: proc() -> bool --- // Check if audio device has been initialized successfully + SetMasterVolume :: proc(volume: f32) --- // Set master volume (listener) // Wave/Sound loading/unloading functions - LoadWave :: proc(fileName: cstring) -> Wave --- // Load wave data from file - LoadWaveFromMemory :: proc(fileType: cstring, fileData: rawptr, dataSize: c.int) -> Wave --- // Load wave from memory buffer, fileType refers to extension: i.e. ".wav" - LoadSound :: proc(fileName: cstring) -> Sound --- // Load sound from file - LoadSoundFromWave :: proc(wave: Wave) -> Sound --- // Load sound from wave data - UpdateSound :: proc(sound: Sound, data: rawptr, samplesCount: c.int) --- // Update sound buffer with new data - UnloadWave :: proc(wave: Wave) --- // Unload wave data - UnloadSound :: proc(sound: Sound) --- // Unload sound - ExportWave :: proc(wave: Wave, fileName: cstring) -> bool --- // Export wave data to file, returns true on success - ExportWaveAsCode :: proc(wave: Wave, fileName: cstring) -> bool --- // Export wave sample data to code (.h), returns true on success + + LoadWave :: proc(fileName: cstring) -> Wave --- // Load wave data from file + LoadWaveFromMemory :: proc(fileType: cstring, fileData: rawptr, dataSize: c.int) -> Wave --- // Load wave from memory buffer, fileType refers to extension: i.e. '.wav' + IsWaveReady :: proc(wave: Wave) -> bool --- // Checks if wave data is ready + LoadSound :: proc(fileName: cstring) -> Sound --- // Load sound from file + LoadSoundFromWave :: proc(wave: Wave) -> Sound --- // Load sound from wave data + IsSoundReady :: proc(sound: Sound) -> bool --- // Checks if a sound is ready + UpdateSound :: proc(sound: Sound, data: rawptr, sampleCount: c.int) --- // Update sound buffer with new data + UnloadWave :: proc(wave: Wave) --- // Unload wave data + UnloadSound :: proc(sound: Sound) --- // Unload sound + ExportWave :: proc(wave: Wave, fileName: cstring) -> bool --- // Export wave data to file, returns true on success + ExportWaveAsCode :: proc(wave: Wave, fileName: cstring) -> bool --- // Export wave sample data to code (.h), returns true on success // Wave/Sound management functions + PlaySound :: proc(sound: Sound) --- // Play a sound StopSound :: proc(sound: Sound) --- // Stop playing a sound PauseSound :: proc(sound: Sound) --- // Pause a sound ResumeSound :: proc(sound: Sound) --- // Resume a paused sound - PlaySoundMulti :: proc(sound: Sound) --- // Play a sound (using multichannel buffer pool) - StopSoundMulti :: proc() --- // Stop any sound playing (using multichannel buffer pool) - GetSoundsPlaying :: proc() -> c.int --- // Get number of sounds playing in the multichannel IsSoundPlaying :: proc(sound: Sound) -> bool --- // Check if a sound is currently playing SetSoundVolume :: proc(sound: Sound, volume: f32) --- // Set volume for a sound (1.0 is max level) SetSoundPitch :: proc(sound: Sound, pitch: f32) --- // Set pitch for a sound (1.0 is base level) - WaveFormat :: proc(wave: ^Wave, sampleRate, sampleSize: c.int, channels: c.int) --- // Convert wave data to desired format + SetSoundPan :: proc(sound: Sound, pan: f32) --- // Set pan for a sound (0.5 is center) WaveCopy :: proc(wave: Wave) -> Wave --- // Copy a wave to a new wave WaveCrop :: proc(wave: ^Wave, initSample, finalSample: c.int) --- // Crop a wave to defined samples range - LoadWaveSamples :: proc(wave: Wave) -> [^]f32 --- // Load samples data from wave as a floats array + WaveFormat :: proc(wave: ^Wave, sampleRate, sampleSize: c.int, channels: c.int) --- // Convert wave data to desired format + LoadWaveSamples :: proc(wave: Wave) -> [^]f32 --- // Load samples data from wave as a 32bit float data array UnloadWaveSamples :: proc(samples: [^]f32) --- // Unload samples data loaded with LoadWaveSamples() // Music management functions + LoadMusicStream :: proc(fileName: cstring) -> Music --- // Load music stream from file LoadMusicStreamFromMemory :: proc(fileType: cstring, data: rawptr, dataSize: c.int) -> Music --- // Load music stream from data + IsMusicReady :: proc(music: Music) -> bool --- // Checks if a music stream is ready UnloadMusicStream :: proc(music: Music) --- // Unload music stream PlayMusicStream :: proc(music: Music) --- // Start music playing IsMusicStreamPlaying :: proc(music: Music) -> bool --- // Check if music is playing @@ -1513,22 +1570,33 @@ foreign lib { SeekMusicStream :: proc(music: Music, position: f32) --- // Seek music to a position (in seconds) SetMusicVolume :: proc(music: Music, volume: f32) --- // Set volume for music (1.0 is max level) SetMusicPitch :: proc(music: Music, pitch: f32) --- // Set pitch for a music (1.0 is base level) + SetMusicPan :: proc(music: Music, pan: f32) --- // Set pan for a music (0.5 is center) GetMusicTimeLength :: proc(music: Music) -> f32 --- // Get music time length (in seconds) GetMusicTimePlayed :: proc(music: Music) -> f32 --- // Get current music time played (in seconds) // AudioStream management functions - LoadAudioStream :: proc(sampleRate, sampleSize, channels: c.uint) -> AudioStream --- // Load audio stream (to stream raw audio pcm data) - UnloadAudioStream :: proc(stream: AudioStream) --- // Unload audio stream and free memory - UpdateAudioStream :: proc(stream: AudioStream, data: rawptr, frameCount: c.int) --- // Update audio stream buffers with data - IsAudioStreamProcessed :: proc(stream: AudioStream) -> bool --- // Check if any audio stream buffers requires refill - PlayAudioStream :: proc(stream: AudioStream) --- // Play audio stream - PauseAudioStream :: proc(stream: AudioStream) --- // Pause audio stream - ResumeAudioStream :: proc(stream: AudioStream) --- // Resume audio stream - IsAudioStreamPlaying :: proc(stream: AudioStream) -> bool --- // Check if audio stream is playing - StopAudioStream :: proc(stream: AudioStream) --- // Stop audio stream - SetAudioStreamVolume :: proc(stream: AudioStream, volume: f32) --- // Set volume for audio stream (1.0 is max level) - SetAudioStreamPitch :: proc(stream: AudioStream, pitch: f32) --- // Set pitch for audio stream (1.0 is base level) - SetAudioStreamBufferSizeDefault :: proc(size: c.int) --- // Default size for new audio streams + + LoadAudioStream :: proc(sampleRate, sampleSize: c.uint, channels: c.uint) -> AudioStream --- // Load audio stream (to stream raw audio pcm data) + IsAudioStreamReady :: proc(stream: AudioStream) -> bool --- // Checks if an audio stream is ready + UnloadAudioStream :: proc(stream: AudioStream) --- // Unload audio stream and free memory + UpdateAudioStream :: proc(stream: AudioStream, data: rawptr, frameCount: c.int) --- // Update audio stream buffers with data + IsAudioStreamProcessed :: proc(stream: AudioStream) -> bool --- // Check if any audio stream buffers requires refill + PlayAudioStream :: proc(stream: AudioStream) --- // Play audio stream + PauseAudioStream :: proc(stream: AudioStream) --- // Pause audio stream + ResumeAudioStream :: proc(stream: AudioStream) --- // Resume audio stream + IsAudioStreamPlaying :: proc(stream: AudioStream) -> bool --- // Check if audio stream is playing + StopAudioStream :: proc(stream: AudioStream) --- // Stop audio stream + SetAudioStreamVolume :: proc(stream: AudioStream, volume: f32) --- // Set volume for audio stream (1.0 is max level) + SetAudioStreamPitch :: proc(stream: AudioStream, pitch: f32) --- // Set pitch for audio stream (1.0 is base level) + SetAudioStreamPan :: proc(stream: AudioStream, pan: f32) --- // Set pan for audio stream (0.5 is centered) + SetAudioStreamBufferSizeDefault :: proc(size: c.int) --- // Default size for new audio streams + SetAudioStreamCallback :: proc(stream: AudioStream, callback: AudioCallback) --- // Audio thread callback to request new data + + AttachAudioStreamProcessor :: proc(stream: AudioStream, processor: AudioCallback) --- // Attach audio stream processor to stream + DetachAudioStreamProcessor :: proc(stream: AudioStream, processor: AudioCallback) --- // Detach audio stream processor from stream + + AttachAudioMixedProcessor :: proc(processor: AudioCallback) --- // Attach audio stream processor to the entire audio pipeline + DetachAudioMixedProcessor :: proc(processor: AudioCallback) --- // Detach audio stream processor from the entire audio pipeline } @@ -1565,7 +1633,7 @@ MemAllocatorProc :: proc(allocator_data: rawptr, mode: mem.Allocator_Mode, old_memory: rawptr, old_size: int, location := #caller_location) -> (data: []byte, err: mem.Allocator_Error) { switch mode { case .Alloc, .Alloc_Non_Zeroed: - ptr := MemAlloc(c.int(size)) + ptr := MemAlloc(c.uint(size)) if ptr == nil { err = .Out_Of_Memory return @@ -1577,7 +1645,7 @@ MemAllocatorProc :: proc(allocator_data: rawptr, mode: mem.Allocator_Mode, return nil, nil case .Resize: - ptr := MemRealloc(old_memory, c.int(size)) + ptr := MemRealloc(old_memory, c.uint(size)) if ptr == nil { err = .Out_Of_Memory return diff --git a/vendor/raylib/rlgl.odin b/vendor/raylib/rlgl.odin index 7e7f2feea..5ef340e3f 100644 --- a/vendor/raylib/rlgl.odin +++ b/vendor/raylib/rlgl.odin @@ -1,10 +1,116 @@ +/********************************************************************************************** +* +* rlgl v4.5 - A multi-OpenGL abstraction layer with an immediate-mode style API +* +* An abstraction layer for multiple OpenGL versions (1.1, 2.1, 3.3 Core, 4.3 Core, ES 2.0) +* that provides a pseudo-OpenGL 1.1 immediate-mode style API (rlVertex, rlTranslate, rlRotate...) +* +* When choosing an OpenGL backend different than OpenGL 1.1, some internal buffer are +* initialized on rlglInit() to accumulate vertex data. +* +* When an internal state change is required all the stored vertex data is renderer in batch, +* additionally, rlDrawRenderBatchActive() could be called to force flushing of the batch. +* +* Some additional resources are also loaded for convenience, here the complete list: +* - Default batch (RLGL.defaultBatch): RenderBatch system to accumulate vertex data +* - Default texture (RLGL.defaultTextureId): 1x1 white pixel R8G8B8A8 +* - Default shader (RLGL.State.defaultShaderId, RLGL.State.defaultShaderLocs) +* +* Internal buffer (and additional resources) must be manually unloaded calling rlglClose(). +* +* +* CONFIGURATION: +* +* #define GRAPHICS_API_OPENGL_11 +* #define GRAPHICS_API_OPENGL_21 +* #define GRAPHICS_API_OPENGL_33 +* #define GRAPHICS_API_OPENGL_43 +* #define GRAPHICS_API_OPENGL_ES2 +* Use selected OpenGL graphics backend, should be supported by platform +* Those preprocessor defines are only used on rlgl module, if OpenGL version is +* required by any other module, use rlGetVersion() to check it +* +* #define RLGL_IMPLEMENTATION +* Generates the implementation of the library into the included file. +* If not defined, the library is in header only mode and can be included in other headers +* or source files without problems. But only ONE file should hold the implementation. +* +* #define RLGL_RENDER_TEXTURES_HINT +* Enable framebuffer objects (fbo) support (enabled by default) +* Some GPUs could not support them despite the OpenGL version +* +* #define RLGL_SHOW_GL_DETAILS_INFO +* Show OpenGL extensions and capabilities detailed logs on init +* +* #define RLGL_ENABLE_OPENGL_DEBUG_CONTEXT +* Enable debug context (only available on OpenGL 4.3) +* +* rlgl capabilities could be customized just defining some internal +* values before library inclusion (default values listed): +* +* #define RL_DEFAULT_BATCH_BUFFER_ELEMENTS 8192 // Default internal render batch elements limits +* #define RL_DEFAULT_BATCH_BUFFERS 1 // Default number of batch buffers (multi-buffering) +* #define RL_DEFAULT_BATCH_DRAWCALLS 256 // Default number of batch draw calls (by state changes: mode, texture) +* #define RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS 4 // Maximum number of textures units that can be activated on batch drawing (SetShaderValueTexture()) +* +* #define RL_MAX_MATRIX_STACK_SIZE 32 // Maximum size of internal Matrix stack +* #define RL_MAX_SHADER_LOCATIONS 32 // Maximum number of shader locations supported +* #define RL_CULL_DISTANCE_NEAR 0.01 // Default projection matrix near cull distance +* #define RL_CULL_DISTANCE_FAR 1000.0 // Default projection matrix far cull distance +* +* When loading a shader, the following vertex attribute and uniform +* location names are tried to be set automatically: +* +* #define RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION "vertexPosition" // Bound by default to shader location: 0 +* #define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD "vertexTexCoord" // Bound by default to shader location: 1 +* #define RL_DEFAULT_SHADER_ATTRIB_NAME_NORMAL "vertexNormal" // Bound by default to shader location: 2 +* #define RL_DEFAULT_SHADER_ATTRIB_NAME_COLOR "vertexColor" // Bound by default to shader location: 3 +* #define RL_DEFAULT_SHADER_ATTRIB_NAME_TANGENT "vertexTangent" // Bound by default to shader location: 4 +* #define RL_DEFAULT_SHADER_UNIFORM_NAME_MVP "mvp" // model-view-projection matrix +* #define RL_DEFAULT_SHADER_UNIFORM_NAME_VIEW "matView" // view matrix +* #define RL_DEFAULT_SHADER_UNIFORM_NAME_PROJECTION "matProjection" // projection matrix +* #define RL_DEFAULT_SHADER_UNIFORM_NAME_MODEL "matModel" // model matrix +* #define RL_DEFAULT_SHADER_UNIFORM_NAME_NORMAL "matNormal" // normal matrix (transpose(inverse(matModelView)) +* #define RL_DEFAULT_SHADER_UNIFORM_NAME_COLOR "colDiffuse" // color diffuse (base tint color, multiplied by texture color) +* #define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE0 "texture0" // texture0 (texture slot active 0) +* #define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE1 "texture1" // texture1 (texture slot active 1) +* #define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE2 "texture2" // texture2 (texture slot active 2) +* +* DEPENDENCIES: +* +* - OpenGL libraries (depending on platform and OpenGL version selected) +* - GLAD OpenGL extensions loading library (only for OpenGL 3.3 Core, 4.3 Core) +* +* +* LICENSE: zlib/libpng +* +* Copyright (c) 2014-2023 Ramon Santamaria (@raysan5) +* +* This software is provided "as-is", without any express or implied warranty. In no event +* will the authors be held liable for any damages arising from the use of this software. +* +* Permission is granted to anyone to use this software for any purpose, including commercial +* applications, and to alter it and redistribute it freely, subject to the following restrictions: +* +* 1. The origin of this software must not be misrepresented; you must not claim that you +* wrote the original software. If you use this software in a product, an acknowledgment +* in the product documentation would be appreciated but is not required. +* +* 2. Altered source versions must be plainly marked as such, and must not be misrepresented +* as being the original software. +* +* 3. This notice may not be removed or altered from any source distribution. +* +**********************************************************************************************/ + + package raylib import "core:c" when ODIN_OS == .Windows { foreign import lib { - "raylib.lib", + "windows/raylib.lib", "system:Winmm.lib", "system:Gdi32.lib", "system:User32.lib", @@ -13,37 +119,51 @@ when ODIN_OS == .Windows { } else when ODIN_OS == .Linux { foreign import lib "linux/libraylib.a" } else when ODIN_OS == .Darwin { - foreign import lib "macos/libraylib.a" + when ODIN_ARCH == .arm64 { + foreign import lib { + "macos-arm64/libraylib.a", + "system:Cocoa.framework", + "system:OpenGL.framework", + "system:IOKit.framework", + } + } else { + foreign import lib { + "macos/libraylib.a", + "system:Cocoa.framework", + "system:OpenGL.framework", + "system:IOKit.framework", + } + } } else { foreign import lib "system:raylib" } -GRAPHICS_API_OPENGL_11 :: false -GRAPHICS_API_OPENGL_21 :: true -GRAPHICS_API_OPENGL_33 :: GRAPHICS_API_OPENGL_21 -GRAPHICS_API_OPENGL_ES2 :: false -GRAPHICS_API_OPENGL_43 :: false +RL_GRAPHICS_API_OPENGL_11 :: false +RL_GRAPHICS_API_OPENGL_21 :: true +RL_GRAPHICS_API_OPENGL_33 :: RL_GRAPHICS_API_OPENGL_21 // default currently +RL_GRAPHICS_API_OPENGL_ES2 :: false +RL_GRAPHICS_API_OPENGL_43 :: false -when !GRAPHICS_API_OPENGL_ES2 { +when !RL_GRAPHICS_API_OPENGL_ES2 { // This is the maximum amount of elements (quads) per batch // NOTE: Be careful with text, every letter maps to a quad - DEFAULT_BATCH_BUFFER_ELEMENTS :: 8192 + RL_DEFAULT_BATCH_BUFFER_ELEMENTS :: 8192 } else { // We reduce memory sizes for embedded systems (RPI and HTML5) // NOTE: On HTML5 (emscripten) this is allocated on heap, // by default it's only 16MB!...just take care... - DEFAULT_BATCH_BUFFER_ELEMENTS :: 2048 + RL_DEFAULT_BATCH_BUFFER_ELEMENTS :: 2048 } -DEFAULT_BATCH_BUFFERS :: 1 // Default number of batch buffers (multi-buffering) -DEFAULT_BATCH_DRAWCALLS :: 256 // Default number of batch draw calls (by state changes: mode, texture) -MAX_BATCH_ACTIVE_TEXTURES :: 4 // Maximum number of additional textures that can be activated on batch drawing (SetShaderValueTexture()) +RL_DEFAULT_BATCH_BUFFERS :: 1 // Default number of batch buffers (multi-buffering) +RL_DEFAULT_BATCH_DRAWCALLS :: 256 // Default number of batch draw calls (by state changes: mode, texture) +RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS :: 4 // Maximum number of additional textures that can be activated on batch drawing (SetShaderValueTexture()) // Internal Matrix stack -MAX_MATRIX_STACK_SIZE :: 32 // Maximum size of Matrix stack +RL_MAX_MATRIX_STACK_SIZE :: 32 // Maximum size of Matrix stack // Shader limits -MAX_SHADER_LOCATIONS :: 32 // Maximum number of shader locations supported +RL_MAX_SHADER_LOCATIONS :: 32 // Maximum number of shader locations supported // Projection matrix culling RL_CULL_DISTANCE_NEAR :: 0.01 // Default near cull distance @@ -98,87 +218,129 @@ RL_FRAGMENT_SHADER :: 0x8B30 // GL_FRAGMENT_SHADER RL_VERTEX_SHADER :: 0x8B31 // GL_VERTEX_SHADER RL_COMPUTE_SHADER :: 0x91B9 // GL_COMPUTE_SHADER +// GL blending factors +RL_ZERO :: 0 // GL_ZERO +RL_ONE :: 1 // GL_ONE +RL_SRC_COLOR :: 0x0300 // GL_SRC_COLOR +RL_ONE_MINUS_SRC_COLOR :: 0x0301 // GL_ONE_MINUS_SRC_COLOR +RL_SRC_ALPHA :: 0x0302 // GL_SRC_ALPHA +RL_ONE_MINUS_SRC_ALPHA :: 0x0303 // GL_ONE_MINUS_SRC_ALPHA +RL_DST_ALPHA :: 0x0304 // GL_DST_ALPHA +RL_ONE_MINUS_DST_ALPHA :: 0x0305 // GL_ONE_MINUS_DST_ALPHA +RL_DST_COLOR :: 0x0306 // GL_DST_COLOR +RL_ONE_MINUS_DST_COLOR :: 0x0307 // GL_ONE_MINUS_DST_COLOR +RL_SRC_ALPHA_SATURATE :: 0x0308 // GL_SRC_ALPHA_SATURATE +RL_CONSTANT_COLOR :: 0x8001 // GL_CONSTANT_COLOR +RL_ONE_MINUS_CONSTANT_COLOR :: 0x8002 // GL_ONE_MINUS_CONSTANT_COLOR +RL_CONSTANT_ALPHA :: 0x8003 // GL_CONSTANT_ALPHA +RL_ONE_MINUS_CONSTANT_ALPHA :: 0x8004 // GL_ONE_MINUS_CONSTANT_ALPHA + +// GL blending functions/equations +RL_FUNC_ADD :: 0x8006 // GL_FUNC_ADD +RL_MIN :: 0x8007 // GL_MIN +RL_MAX :: 0x8008 // GL_MAX +RL_FUNC_SUBTRACT :: 0x800A // GL_FUNC_SUBTRACT +RL_FUNC_REVERSE_SUBTRACT :: 0x800B // GL_FUNC_REVERSE_SUBTRACT +RL_BLEND_EQUATION :: 0x8009 // GL_BLEND_EQUATION +RL_BLEND_EQUATION_RGB :: 0x8009 // GL_BLEND_EQUATION_RGB // (Same as BLEND_EQUATION) +RL_BLEND_EQUATION_ALPHA :: 0x883D // GL_BLEND_EQUATION_ALPHA +RL_BLEND_DST_RGB :: 0x80C8 // GL_BLEND_DST_RGB +RL_BLEND_SRC_RGB :: 0x80C9 // GL_BLEND_SRC_RGB +RL_BLEND_DST_ALPHA :: 0x80CA // GL_BLEND_DST_ALPHA +RL_BLEND_SRC_ALPHA :: 0x80CB // GL_BLEND_SRC_ALPHA +RL_BLEND_COLOR :: 0x8005 // GL_BLEND_COLOR + //---------------------------------------------------------------------------------- // Types and Structures Definition //---------------------------------------------------------------------------------- -GlVersion :: enum c.int { OPENGL_11 = 1, OPENGL_21, OPENGL_33, OPENGL_ES_20 } -FramebufferAttachType :: enum c. int { - COLOR_CHANNEL0 = 0, - COLOR_CHANNEL1, - COLOR_CHANNEL2, - COLOR_CHANNEL3, - COLOR_CHANNEL4, - COLOR_CHANNEL5, - COLOR_CHANNEL6, - COLOR_CHANNEL7, - DEPTH = 100, - STENCIL = 200, -} -FramebufferAttachTextureType :: enum c.int { - CUBEMAP_POSITIVE_X = 0, - CUBEMAP_NEGATIVE_X, - CUBEMAP_POSITIVE_Y, - CUBEMAP_NEGATIVE_Y, - CUBEMAP_POSITIVE_Z, - CUBEMAP_NEGATIVE_Z, - TEXTURE2D = 100, - RENDERBUFFER = 200, -} - -VertexBufferIndexType :: c.ushort when GRAPHICS_API_OPENGL_ES2 else c.uint +VertexBufferIndexType :: c.ushort when RL_GRAPHICS_API_OPENGL_ES2 else c.uint // Dynamic vertex buffers (position + texcoords + colors + indices arrays) VertexBuffer :: struct { - elementsCount: c.int, // Number of elements in the buffer (QUADS) + elementCount: c.int, // Number of elements in the buffer (QUADS) - vCounter: c.int, // Vertex position counter to process (and draw) from full buffer - tcCounter: c.int, // Vertex texcoord counter to process (and draw) from full buffer - cCounter: c.int, // Vertex color counter to process (and draw) from full buffer - - vertices: [^]f32, // Vertex position (XYZ - 3 components per vertex) (shader-location = 0) - texcoords: [^]f32, // Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1) - colors: [^]u8, // Vertex colors (RGBA - 4 components per vertex) (shader-location = 3) - indices: [^]VertexBufferIndexType, // Vertex indices (in case vertex data comes indexed) (6 indices per quad) - vaoId: u32, // OpenGL Vertex Array Object id - vboId: [4]u32, // OpenGL Vertex Buffer Objects id (4 types of vertex data) -} + vertices: [^]f32, // Vertex position (XYZ - 3 components per vertex) (shader-location = 0) + texcoords: [^]f32, // Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1) + colors: [^]u8, // Vertex colors (RGBA - 4 components per vertex) (shader-location = 3) + indices: [^]VertexBufferIndexType, // Vertex indices (in case vertex data comes indexed) (6 indices per quad) + vaoId: c.uint, // OpenGL Vertex Array Object id + vboId: [4]c.uint, // OpenGL Vertex Buffer Objects id (4 types of vertex data) +} // Draw call type // NOTE: Only texture changes register a new draw, other state-change-related elements are not // used at this moment (vaoId, shaderId, matrices), raylib just forces a batch draw call if any // of those state-change happens (this is done in core module) DrawCall :: struct { - mode: c.int, // Drawing mode: LINES, TRIANGLES, QUADS - vertexCount: c.int, // Number of vertex of the draw - vertexAlignment: c.int, // Number of vertex required for index alignment (LINES, TRIANGLES) - //vaoId: u32, // Vertex array id to be used on the draw -> Using RLGL.currentBatch->vertexBuffer.vaoId - //shaderId: u32, // Shader id to be used on the draw -> Using RLGL.currentShader.id - textureId: u32, // Texture id to be used on the draw -> Use to create new draw call if changes - - //projection: Matrix, // Projection matrix for this draw -> Using RLGL.projection by default - //modelview: Matrix, // Modelview matrix for this draw -> Using RLGL.modelview by default -} + mode: c.int, // Drawing mode: LINES, TRIANGLES, QUADS + vertexCount: c.int, // Number of vertex of the draw + vertexAlignment: c.int, // Number of vertex required for index alignment (LINES, TRIANGLES) + textureId: c.uint, // Texture id to be used on the draw -> Use to create new draw call if changes +} // RenderBatch type RenderBatch :: struct { - buffersCount: c.int, // Number of vertex buffers (multi-buffering support) + bufferCount: c.int, // Number of vertex buffers (multi-buffering support) currentBuffer: c.int, // Current buffer tracking in case of multi-buffering vertexBuffer: [^]VertexBuffer, // Dynamic buffer(s) for vertex data - draws: [^]DrawCall, // Draw calls array, depends on textureId - drawsCounter: c.int, // Draw calls counter - currentDepth: f32, // Current depth value for next draw + draws: [^]DrawCall, // Draw calls array, depends on textureId + drawCounter: c.int, // Draw calls counter + currentDepth: f32, // Current depth value for next draw } + +// OpenGL version +GlVersion :: enum c.int { + OPENGL_11 = 1, // OpenGL 1.1 + OPENGL_21, // OpenGL 2.1 (GLSL 120) + OPENGL_33, // OpenGL 3.3 (GLSL 330) + OPENGL_43, // OpenGL 4.3 (using GLSL 330) + OPENGL_ES_20, // OpenGL ES 2.0 (GLSL 100) +} + + // Shader attribute data types ShaderAttributeDataType :: enum c.int { - FLOAT = 0, - VEC2, - VEC3, - VEC4, + FLOAT = 0, // Shader attribute type: float + VEC2, // Shader attribute type: vec2 (2 float) + VEC3, // Shader attribute type: vec3 (3 float) + VEC4, // Shader attribute type: vec4 (4 float) +} + +// Framebuffer attachment type +// NOTE: By default up to 8 color channels defined, but it can be more +FramebufferAttachType :: enum c.int { + COLOR_CHANNEL0 = 0, // Framebuffer attachment type: color 0 + COLOR_CHANNEL1, // Framebuffer attachment type: color 1 + COLOR_CHANNEL2, // Framebuffer attachment type: color 2 + COLOR_CHANNEL3, // Framebuffer attachment type: color 3 + COLOR_CHANNEL4, // Framebuffer attachment type: color 4 + COLOR_CHANNEL5, // Framebuffer attachment type: color 5 + COLOR_CHANNEL6, // Framebuffer attachment type: color 6 + COLOR_CHANNEL7, // Framebuffer attachment type: color 7 + DEPTH = 100, // Framebuffer attachment type: depth + STENCIL = 200, // Framebuffer attachment type: stencil +} + +// Framebuffer texture attachment type +FramebufferAttachTextureType :: enum c.int { + CUBEMAP_POSITIVE_X = 0, // Framebuffer texture attachment type: cubemap, +X side + CUBEMAP_NEGATIVE_X, // Framebuffer texture attachment type: cubemap, -X side + CUBEMAP_POSITIVE_Y, // Framebuffer texture attachment type: cubemap, +Y side + CUBEMAP_NEGATIVE_Y, // Framebuffer texture attachment type: cubemap, -Y side + CUBEMAP_POSITIVE_Z, // Framebuffer texture attachment type: cubemap, +Z side + CUBEMAP_NEGATIVE_Z, // Framebuffer texture attachment type: cubemap, -Z side + TEXTURE2D = 100, // Framebuffer texture attachment type: texture2d + RENDERBUFFER = 200, // Framebuffer texture attachment type: renderbuffer +} + +CullMode :: enum c.int { + FRONT = 0, + BACK, } @(default_calling_convention="c") @@ -219,38 +381,38 @@ foreign lib { //------------------------------------------------------------------------------------ // Vertex buffers state - rlEnableVertexArray :: proc(vaoId: u32) -> bool --- // Enable vertex array (VAO, if supported) - rlDisableVertexArray :: proc() --- // Disable vertex array (VAO, if supported) - rlEnableVertexBuffer :: proc(id: u32) --- // Enable vertex buffer (VBO) - rlDisableVertexBuffer :: proc() --- // Disable vertex buffer (VBO) - rlEnableVertexBufferElement :: proc(id: u32) --- // Enable vertex buffer element (VBO element) - rlDisableVertexBufferElement :: proc() --- // Disable vertex buffer element (VBO element) - rlEnableVertexAttribute :: proc(index: u32) --- // Enable vertex attribute index - rlDisableVertexAttribute :: proc(index: u32) --- // Disable vertex attribute index - when GRAPHICS_API_OPENGL_11 { + rlEnableVertexArray :: proc(vaoId: c.uint) -> bool --- // Enable vertex array (VAO, if supported) + rlDisableVertexArray :: proc() --- // Disable vertex array (VAO, if supported) + rlEnableVertexBuffer :: proc(id: c.uint) --- // Enable vertex buffer (VBO) + rlDisableVertexBuffer :: proc() --- // Disable vertex buffer (VBO) + rlEnableVertexBufferElement :: proc(id: c.uint) --- // Enable vertex buffer element (VBO element) + rlDisableVertexBufferElement :: proc() --- // Disable vertex buffer element (VBO element) + rlEnableVertexAttribute :: proc(index: c.uint) --- // Enable vertex attribute index + rlDisableVertexAttribute :: proc(index: c.uint) --- // Disable vertex attribute index + when RL_GRAPHICS_API_OPENGL_11 { rlEnableStatePointer :: proc(vertexAttribType: c.int, buffer: rawptr) --- rlDisableStatePointer :: proc(vertexAttribType: c.int) --- } // Textures state - rlActiveTextureSlot :: proc(slot: c.int) --- // Select and active a texture slot - rlEnableTexture :: proc(id: u32) --- // Enable texture - rlDisableTexture :: proc() --- // Disable texture - rlEnableTextureCubemap :: proc(id: u32) --- // Enable texture cubemap - rlDisableTextureCubemap :: proc() --- // Disable texture cubemap - rlTextureParameters :: proc(id: u32, param: c.int, value: c.int) --- // Set texture parameters (filter, wrap) + rlActiveTextureSlot :: proc(slot: c.int) --- // Select and active a texture slot + rlEnableTexture :: proc(id: c.uint) --- // Enable texture + rlDisableTexture :: proc() --- // Disable texture + rlEnableTextureCubemap :: proc(id: c.uint) --- // Enable texture cubemap + rlDisableTextureCubemap :: proc() --- // Disable texture cubemap + rlTextureParameters :: proc(id: c.uint, param: c.int, value: c.int) --- // Set texture parameters (filter, wrap) + rlCubemapParameters :: proc(id: i32, param: c.int, value: c.int) --- // Set cubemap parameters (filter, wrap) // Shader state - rlEnableShader :: proc(id: u32) --- // Enable shader program + rlEnableShader :: proc(id: c.uint) --- // Enable shader program rlDisableShader :: proc() --- // Disable shader program // Framebuffer state - rlEnableFramebuffer :: proc(id: u32) --- // Enable render texture (fbo) + rlEnableFramebuffer :: proc(id: c.uint) --- // Enable render texture (fbo) rlDisableFramebuffer :: proc() --- // Disable render texture (fbo), return to default framebuffer rlActiveDrawBuffers :: proc(count: c.int) --- // Activate multiple draw color buffers // General render state - rlEnableColorBlend :: proc() --- // Enable color blending rlDisableColorBlend :: proc() --- // Disable color blending rlEnableDepthTest :: proc() --- // Enable depth test rlDisableDepthTest :: proc() --- // Disable depth test @@ -258,6 +420,7 @@ foreign lib { rlDisableDepthMask :: proc() --- // Disable depth write rlEnableBackfaceCulling :: proc() --- // Enable backface culling rlDisableBackfaceCulling :: proc() --- // Disable backface culling + rlSetCullFace :: proc(mode: CullMode) --- // Set face culling mode rlEnableScissorTest :: proc() --- // Enable scissor test rlDisableScissorTest :: proc() --- // Disable scissor test rlScissor :: proc(x, y, width, height: c.int) --- // Scissor test @@ -271,102 +434,107 @@ foreign lib { rlDisableStereoRender :: proc() --- // Disable stereo rendering rlIsStereoRenderEnabled :: proc() -> bool --- // Check if stereo render is enabled - rlClearColor :: proc(r, g, b, a: u8) --- // Clear color buffer with color - rlClearScreenBuffers :: proc() --- // Clear used screen buffers (color and depth) - rlCheckErrors :: proc() --- // Check and log OpenGL error codes - rlSetBlendMode :: proc(mode: c.int) --- // Set blending mode - rlSetBlendFactors :: proc(glSrcFactor, glDstFactor, glEquation: c.int) --- // Set blending mode factor and equation (using OpenGL factors) + + rlClearColor :: proc(r, g, b, a: u8) --- // Clear color buffer with color + rlClearScreenBuffers :: proc() --- // Clear used screen buffers (color and depth) + rlCheckErrors :: proc() --- // Check and log OpenGL error codes + rlSetBlendMode :: proc(mode: c.int) --- // Set blending mode + rlSetBlendFactors :: proc(glSrcFactor, glDstFactor, glEquation: c.int) --- // Set blending mode factor and equation (using OpenGL factors) + rlSetBlendFactorsSeparate :: proc(glSrcRGB, glDstRGB, glSrcAlpha, glDstAlpha, glEqRGB, glEqAlpha: c.int) --- // Set blending mode factors and equations separately (using OpenGL factors) //------------------------------------------------------------------------------------ // Functions Declaration - rlgl functionality //------------------------------------------------------------------------------------ // rlgl initialization functions - rlglInit :: proc(width, height: c.int) --- // Initialize rlgl (buffers, shaders, textures, states) - rlglClose :: proc() --- // De-inititialize rlgl (buffers, shaders, textures) - rlLoadExtensions :: proc(loader: rawptr) --- // Load OpenGL extensions (loader function pointer required) - rlGetVersion :: proc() -> GlVersion --- // Returns current OpenGL version - rlGetFramebufferWidth :: proc() -> c.int --- // Get default framebuffer width - rlGetFramebufferHeight :: proc() -> c.int --- // Get default framebuffer height + rlglInit :: proc(width, height: c.int) --- // Initialize rlgl (buffers, shaders, textures, states) + rlglClose :: proc() --- // De-initialize rlgl (buffers, shaders, textures) + rlLoadExtensions :: proc(loader: rawptr) --- // Load OpenGL extensions (loader function required) + rlGetVersion :: proc() -> GlVersion --- // Get current OpenGL version + rlSetFramebufferWidth :: proc(width: c.int) --- // Set current framebuffer width + rlGetFramebufferWidth :: proc() -> c.int --- // Get default framebuffer width + rlSetFramebufferHeight :: proc(height: c.int) --- // Set current framebuffer height + rlGetFramebufferHeight :: proc() -> c.int --- // Get default framebuffer height - rlGetTextureIdDefault :: proc() -> u32 --- // Get default texture id - rlGetShaderIdDefault :: proc() -> u32 --- // Get default shader id - rlGetShaderLocsDefault :: proc() -> [^]i32 --- // Get default shader locations + + rlGetTextureIdDefault :: proc() -> c.uint --- // Get default texture id + rlGetShaderIdDefault :: proc() -> c.uint --- // Get default shader id + rlGetShaderLocsDefault :: proc() -> [^]c.int --- // Get default shader locations // Render batch management // NOTE: rlgl provides a default render batch to behave like OpenGL 1.1 immediate mode // but this render batch API is exposed in case of custom batches are required - rlLoadRenderBatch :: proc(numBuffers, bufferElements: c.int) -> RenderBatch --- // Load a render batch system - rlUnloadRenderBatch :: proc(batch: RenderBatch) --- // Unload render batch system - rlDrawRenderBatch :: proc(batch: ^RenderBatch) --- // Draw render batch data (Update->Draw->Reset) - rlSetRenderBatchActive :: proc(batch: ^RenderBatch) --- // Set the active render batch for rlgl (NULL for default internal) - rlDrawRenderBatchActive :: proc() --- // Update and draw internal render batch - rlCheckRenderBatchLimit :: proc(vCount: c.int) -> bool --- // Check internal buffer overflow for a given number of vertex - rlSetTexture :: proc(id: u32) --- // Set current texture for render batch and check buffers limits + rlLoadRenderBatch :: proc(numBuffers, bufferElements: c.int) -> RenderBatch --- // Load a render batch system + rlUnloadRenderBatch :: proc(batch: RenderBatch) --- // Unload render batch system + rlDrawRenderBatch :: proc(batch: ^RenderBatch) --- // Draw render batch data (Update->Draw->Reset) + rlSetRenderBatchActive :: proc(batch: ^RenderBatch) --- // Set the active render batch for rlgl (NULL for default internal) + rlDrawRenderBatchActive :: proc() --- // Update and draw internal render batch + rlCheckRenderBatchLimit :: proc(vCount: c.int) -> c.int --- // Check internal buffer overflow for a given number of vertex + + rlSetTexture :: proc(id: c.uint) --- // Set current texture for render batch and check buffers limits //------------------------------------------------------------------------------------------------------------------------ // Vertex buffers management - rlLoadVertexArray :: proc() -> u32 --- // Load vertex array (vao) if supported - rlLoadVertexBuffer :: proc(buffer: rawptr, size: c.int, is_dynamic: bool) -> u32 --- // Load a vertex buffer attribute - rlLoadVertexBufferElement :: proc(buffer: rawptr, size: c.int, is_dynamic: bool) -> u32 --- // Load a new attributes element buffer - rlUpdateVertexBuffer :: proc(bufferId: c.int, data: rawptr, dataSize: c.int, offset: c.int) -> u32 --- // Update GPU buffer with new data - rlUnloadVertexArray :: proc(vaoId: u32) --- - rlUnloadVertexBuffer :: proc(vboId: u32) --- - rlSetVertexAttribute :: proc(index: u32, compSize: c.int, type: c.int, normalized: bool, stride: c.int, pointer: uintptr) --- - rlSetVertexAttributeDivisor :: proc(index: u32, divisor: c.int) --- - rlSetVertexAttributeDefault :: proc(locIndex: c.int, value: rawptr, attribType: c.int, count: c.int) --- // Set vertex attribute default value + rlLoadVertexArray :: proc() -> c.uint --- // Load vertex array (vao) if supported + rlLoadVertexBuffer :: proc(buffer: rawptr, size: c.int, is_dynamic: bool) -> c.uint --- // Load a vertex buffer attribute + rlLoadVertexBufferElement :: proc(buffer: rawptr, size: c.int, is_dynamic: bool) -> c.uint --- // Load a new attributes element buffer + rlUpdateVertexBuffer :: proc(bufferId: c.uint, data: rawptr, dataSize: c.int, offset: c.int) --- // Update GPU buffer with new data + rlUpdateVertexBufferElements :: proc(id: c.uint, data: rawptr, dataSize: c.int, offset: c.int) --- // Update vertex buffer elements with new data + rlUnloadVertexArray :: proc(vaoId: c.uint) --- + rlUnloadVertexBuffer :: proc(vboId: c.uint) --- + rlSetVertexAttribute :: proc(index: c.uint, compSize: c.int, type: c.int, normalized: bool, stride: c.int, pointer: rawptr) --- + rlSetVertexAttributeDivisor :: proc(index: c.uint, divisor: c.int) --- + rlSetVertexAttributeDefault :: proc(locIndex: c.int, value: rawptr, attribType: c.int, count: c.int) --- // Set vertex attribute default value rlDrawVertexArray :: proc(offset: c.int, count: c.int) --- rlDrawVertexArrayElements :: proc(offset: c.int, count: c.int, buffer: rawptr) --- rlDrawVertexArrayInstanced :: proc(offset: c.int, count: c.int, instances: c.int) --- rlDrawVertexArrayElementsInstanced :: proc(offset: c.int, count: c.int, buffer: rawptr, instances: c.int) --- // Textures management - rlLoadTexture :: proc(data: rawptr, width, height: c.int, format: c.int, mipmapCount: c.int) -> u32 --- // Load texture in GPU - rlLoadTextureDepth :: proc(width, height: c.int, useRenderBuffer: bool) -> u32 --- // Load depth texture/renderbuffer (to be attached to fbo) - rlLoadTextureCubemap :: proc(data: rawptr, size: c.int, format: c.int) -> u32 --- // Load texture cubemap - rlUpdateTexture :: proc(id: u32, offsetX, offsetY, width, height: c.int, format: c.int, data: rawptr) --- // Update GPU texture with new data - rlGetGlTextureFormats :: proc(format: c.int, glInternalFormat: ^u32, glFormat: ^u32, glType: ^u32) --- // Get OpenGL internal formats - rlGetPixelFormatName :: proc(format: PixelFormat) -> cstring --- // Get name string for pixel format - rlUnloadTexture :: proc(id: u32) --- // Unload texture from GPU memory - rlGenerateMipmaps :: proc(texture: ^Texture2D) --- // Generate mipmap data for selected texture - rlReadTexturePixels :: proc(texture: Texture2D) -> rawptr --- // Read texture pixel data - rlReadScreenPixels :: proc(width, height: c.int) -> [^]u8 --- // Read screen pixel data (color buffer) + rlLoadTexture :: proc(data: rawptr, width, height: c.int, format: c.int, mipmapCount: c.int) -> c.uint --- // Load texture in GPU + rlLoadTextureDepth :: proc(width, height: c.int, useRenderBuffer: bool) -> c.uint --- // Load depth texture/renderbuffer (to be attached to fbo) + rlLoadTextureCubemap :: proc(data: rawptr, size: c.int, format: c.int) -> c.uint --- // Load texture cubemap + rlUpdateTexture :: proc(id: c.uint, offsetX, offsetY: c.int, width, height: c.int, format: c.int, data: rawptr) --- // Update GPU texture with new data + rlGetGlTextureFormats :: proc(format: c.int, glInternalFormat, glFormat, glType: ^c.uint) --- // Get OpenGL internal formats + rlGetPixelFormatName :: proc(format: c.uint) -> cstring --- // Get name string for pixel format + rlUnloadTexture :: proc(id: c.uint) --- // Unload texture from GPU memory + rlGenTextureMipmaps :: proc(id: c.uint, width, height: c.int, format: c.int, mipmaps: ^c.int) --- // Generate mipmap data for selected texture + rlReadTexturePixels :: proc(id: c.uint, width, height: c.int, format: c.int) -> rawptr --- // Read texture pixel data + rlReadScreenPixels :: proc(width, height: c.int) -> [^]byte --- // Read screen pixel data (color buffer) // Framebuffer management (fbo) - rlLoadFramebuffer :: proc(width, height: c.int) -> u32 --- // Load an empty framebuffer - rlFramebufferAttach :: proc(fboId: u32, texId: u32, attachType: c.int, texType: c.int, mipLevel: c.int) --- // Attach texture/renderbuffer to a framebuffer - rlFramebufferComplete :: proc(id: u32) -> bool --- // Verify framebuffer is complete - rlUnloadFramebuffer :: proc(id: u32) --- // Delete framebuffer from GPU + rlLoadFramebuffer :: proc(width, height: c.int) -> c.uint --- // Load an empty framebuffer + rlFramebufferAttach :: proc(fboId, texId: c.uint, attachType: c.int, texType: c.int, mipLevel: c.int) --- // Attach texture/renderbuffer to a framebuffer + rlFramebufferComplete :: proc(id: c.uint) -> bool --- // Verify framebuffer is complete + rlUnloadFramebuffer :: proc(id: c.uint) --- // Delete framebuffer from GPU // Shaders management - rlLoadShaderCode :: proc(vsCode, fsCode: cstring) -> u32 --- // Load shader from code strings - rlCompileShader :: proc(shaderCode: cstring, type: c.int) -> u32 --- // Compile custom shader and return shader id (type: GL_VERTEX_SHADER, GL_FRAGMENT_SHADER) - rlLoadShaderProgram :: proc(vShaderId, fShaderId: u32) -> u32 --- // Load custom shader program - rlUnloadShaderProgram :: proc(id: u32) --- // Unload shader program - rlGetLocationUniform :: proc(shaderId: u32, uniformName: cstring) -> c.int --- // Get shader location uniform - rlGetLocationAttrib :: proc(shaderId: u32, attribName: cstring) -> c.int --- // Get shader location attribute + rlLoadShaderCode :: proc(vsCode, fsCode: cstring) -> c.uint --- // Load shader from code strings + rlCompileShader :: proc(shaderCode: cstring, type: c.int) -> c.uint --- // Compile custom shader and return shader id (type: RL_VERTEX_SHADER, RL_FRAGMENT_SHADER, RL_COMPUTE_SHADER) + rlLoadShaderProgram :: proc(vShaderId, fShaderId: c.uint) -> c.uint --- // Load custom shader program + rlUnloadShaderProgram :: proc(id: c.uint) --- // Unload shader program + rlGetLocationUniform :: proc(shaderId: c.uint, uniformName: cstring) -> c.int --- // Get shader location uniform + rlGetLocationAttrib :: proc(shaderId: c.uint, attribName: cstring) -> c.int --- // Get shader location attribute rlSetUniform :: proc(locIndex: c.int, value: rawptr, uniformType: c.int, count: c.int) --- // Set shader value uniform rlSetUniformMatrix :: proc(locIndex: c.int, mat: Matrix) --- // Set shader value matrix - rlSetUniformSampler :: proc(locIndex: c.int, textureId: u32) --- // Set shader value sampler - rlSetShader :: proc(shader: Shader) --- // Set shader currently active + rlSetUniformSampler :: proc(locIndex: c.int, textureId: c.uint) --- // Set shader value sampler + rlSetShader :: proc(id: c.uint, locs: [^]c.int) --- // Set shader currently active (id and locations) // Compute shader management - rlLoadComputeShaderProgram :: proc(shaderId: u32) -> u32 --- // Load compute shader program - rlComputeShaderDispatch :: proc(groupX, groupY, groupZ: u32) --- // Dispatch compute shader (equivalent to *draw* for graphics pilepine) + rlLoadComputeShaderProgram :: proc(shaderId: c.uint) -> c.uint --- // Load compute shader program + rlComputeShaderDispatch :: proc(groupX, groupY, groupZ: c.uint) --- // Dispatch compute shader (equivalent to *draw* for graphics pipeline) - // Shader buffer storage object management (ssbo) - rlLoadShaderBuffer :: proc(size: u64, data: rawptr, usageHint: c.int) -> u32 --- // Load shader storage buffer object (SSBO) - rlUnloadShaderBuffer :: proc(ssboId: u32) --- // Unload shader storage buffer object (SSBO) - rlUpdateShaderBufferElements :: proc(id: u32, data: rawptr, dataSize: u64, offset: u64) --- // Update SSBO buffer data - rlGetShaderBufferSize :: proc(id: u32) -> u64 --- // Get SSBO buffer size - rlReadShaderBufferElements :: proc(id: u32, dest: rawptr, count: u64, offset: u64) --- // Bind SSBO buffer - rlBindShaderBuffer :: proc(id: u32, index: u32) --- // Copy SSBO buffer data + rlLoadShaderBuffer :: proc(size: c.uint, data: rawptr, usageHint: c.int) -> c.uint --- // Load shader storage buffer object (SSBO) + rlUnloadShaderBuffer :: proc(ssboId: c.uint) --- // Unload shader storage buffer object (SSBO) + rlUpdateShaderBuffer :: proc(id: c.uint, data: rawptr, dataSize: c.uint, offset: c.uint) --- // Update SSBO buffer data + rlBindShaderBuffer :: proc(id: c.uint, index: c.uint) --- // Bind SSBO buffer + rlReadShaderBuffer :: proc(id: c.uint, dest: rawptr, count: c.uint, offset: c.uint) --- // Read SSBO buffer data (GPU->CPU) + rlCopyShaderBuffer :: proc(destId, srcId: c.uint, destOffset, srcOffset: c.uint, count: c.uint) --- // Copy SSBO data between buffers + rlGetShaderBufferSize :: proc(id: c.uint) -> c.uint --- // Get SSBO buffer size // Buffer management - rlCopyBuffersElements :: proc(destId, srcId: u32, destOffset, srcOffset: u64, count: u64) --- // Copy SSBO buffer data - rlBindImageTexture :: proc(id: u32, index: u32, format: u32, readonly: b32) --- // Bind image texture - + rlBindImageTexture :: proc(id: c.uint, index: c.uint, format: c.int, readonly: bool) --- // Bind image texture // Matrix state management rlGetMatrixModelview :: proc() -> Matrix --- // Get internal modelview matrix diff --git a/vendor/raylib/windows/raylib.dll b/vendor/raylib/windows/raylib.dll new file mode 100644 index 000000000..df58566c0 Binary files /dev/null and b/vendor/raylib/windows/raylib.dll differ diff --git a/vendor/raylib/windows/raylib.lib b/vendor/raylib/windows/raylib.lib new file mode 100644 index 000000000..f42f4714a Binary files /dev/null and b/vendor/raylib/windows/raylib.lib differ diff --git a/vendor/raylib/windows/raylibdll.lib b/vendor/raylib/windows/raylibdll.lib new file mode 100644 index 000000000..d4546131e Binary files /dev/null and b/vendor/raylib/windows/raylibdll.lib differ diff --git a/vendor/sdl2/sdl2.odin b/vendor/sdl2/sdl2.odin index a89394d4b..adf6dbd49 100644 --- a/vendor/sdl2/sdl2.odin +++ b/vendor/sdl2/sdl2.odin @@ -294,7 +294,7 @@ WindowShapeModeEnum :: enum c.int { ColorKey, } -SDL_SHAPEMODEALPHA :: #force_inline proc "c" (mode: WindowShapeModeEnum) -> bool { +SHAPEMODEALPHA :: #force_inline proc "c" (mode: WindowShapeModeEnum) -> bool { return bool(mode == .Default || mode == .BinarizeAlpha || mode == .ReverseBinarizeAlpha) } diff --git a/vendor/sdl2/sdl_mouse.odin b/vendor/sdl2/sdl_mouse.odin index 13220c94b..0243b6623 100644 --- a/vendor/sdl2/sdl_mouse.odin +++ b/vendor/sdl2/sdl_mouse.odin @@ -38,7 +38,7 @@ SystemCursor :: enum c.int { NUM_SYSTEM_CURSORS, } -SDL_MouseWheelDirection :: enum c.int { +MouseWheelDirection :: enum c.int { NORMAL, /**< The scroll direction is normal */ FLIPPED, /**< The scroll direction is flipped / natural */ } diff --git a/vendor/sdl2/sdl_render.odin b/vendor/sdl2/sdl_render.odin index 57845235b..f948b39b0 100644 --- a/vendor/sdl2/sdl_render.odin +++ b/vendor/sdl2/sdl_render.odin @@ -49,9 +49,9 @@ TextureAccess :: enum c.int { TARGET, /**< Texture can be used as a render target */ } -SDL_TEXTUREMODULATE_NONE :: 0x00000000 /**< No modulation */ -SDL_TEXTUREMODULATE_COLOR :: 0x00000001 /**< srcC = srcC * color */ -SDL_TEXTUREMODULATE_ALPHA :: 0x00000002 /**< srcA = srcA * alpha */ +TEXTUREMODULATE_NONE :: 0x00000000 /**< No modulation */ +TEXTUREMODULATE_COLOR :: 0x00000001 /**< srcC = srcC * color */ +TEXTUREMODULATE_ALPHA :: 0x00000002 /**< srcA = srcA * alpha */ /** * Flip constants for SDL_RenderCopyEx diff --git a/vendor/stb/lib/darwin/stb_image.a b/vendor/stb/lib/darwin/stb_image.a index 1379d6f9e..8c37d5d7a 100644 Binary files a/vendor/stb/lib/darwin/stb_image.a and b/vendor/stb/lib/darwin/stb_image.a differ diff --git a/vendor/stb/lib/darwin/stb_image_resize.a b/vendor/stb/lib/darwin/stb_image_resize.a index f39c507a6..adbe1b2f3 100644 Binary files a/vendor/stb/lib/darwin/stb_image_resize.a and b/vendor/stb/lib/darwin/stb_image_resize.a differ diff --git a/vendor/stb/lib/darwin/stb_image_write.a b/vendor/stb/lib/darwin/stb_image_write.a index bce02b33d..5d0620f58 100644 Binary files a/vendor/stb/lib/darwin/stb_image_write.a and b/vendor/stb/lib/darwin/stb_image_write.a differ diff --git a/vendor/stb/lib/darwin/stb_rect_pack.a b/vendor/stb/lib/darwin/stb_rect_pack.a index 3b55ab802..17c6c66bb 100644 Binary files a/vendor/stb/lib/darwin/stb_rect_pack.a and b/vendor/stb/lib/darwin/stb_rect_pack.a differ diff --git a/vendor/stb/lib/darwin/stb_truetype.a b/vendor/stb/lib/darwin/stb_truetype.a index c4a895b54..f871693d0 100644 Binary files a/vendor/stb/lib/darwin/stb_truetype.a and b/vendor/stb/lib/darwin/stb_truetype.a differ diff --git a/vendor/stb/lib/darwin/stb_vorbis.a b/vendor/stb/lib/darwin/stb_vorbis.a new file mode 100644 index 000000000..9deb10237 Binary files /dev/null and b/vendor/stb/lib/darwin/stb_vorbis.a differ diff --git a/vendor/stb/src/Makefile b/vendor/stb/src/Makefile index 5504fede9..a6db3e297 100644 --- a/vendor/stb/src/Makefile +++ b/vendor/stb/src/Makefile @@ -1,4 +1,12 @@ -all: +OS=$(shell uname) + +ifeq ($(OS), Darwin) +all: darwin +else +all: unix +endif + +unix: mkdir -p ../lib $(CC) -c -O2 -Os -fPIC stb_image.c stb_image_write.c stb_image_resize.c stb_truetype.c stb_rect_pack.c stb_vorbis.c $(AR) rcs ../lib/stb_image.a stb_image.o @@ -14,3 +22,25 @@ all: #$(CC) -fPIC -shared -Wl,-soname=stb_rect_pack.so -o ../lib/stb_rect_pack.so stb_rect_packl.o #$(CC) -fPIC -shared -Wl,-soname=stb_vorbis.so -o ../lib/stb_vorbis.so stb_vorbisl.o rm *.o + +darwin: + mkdir -p ../lib + $(CC) -arch x86_64 -c -O2 -Os -fPIC stb_image.c -o stb_image-x86_64.o -mmacosx-version-min=10.12 + $(CC) -arch arm64 -c -O2 -Os -fPIC stb_image.c -o stb_image-arm64.o -mmacosx-version-min=10.12 + lipo -create stb_image-x86_64.o stb_image-arm64.o -output ../lib/darwin/stb_image.a + $(CC) -arch x86_64 -c -O2 -Os -fPIC stb_image_write.c -o stb_image_write-x86_64.o -mmacosx-version-min=10.12 + $(CC) -arch arm64 -c -O2 -Os -fPIC stb_image_write.c -o stb_image_write-arm64.o -mmacosx-version-min=10.12 + lipo -create stb_image_write-x86_64.o stb_image_write-arm64.o -output ../lib/darwin/stb_image_write.a + $(CC) -arch x86_64 -c -O2 -Os -fPIC stb_image_resize.c -o stb_image_resize-x86_64.o -mmacosx-version-min=10.12 + $(CC) -arch arm64 -c -O2 -Os -fPIC stb_image_resize.c -o stb_image_resize-arm64.o -mmacosx-version-min=10.12 + lipo -create stb_image_resize-x86_64.o stb_image_resize-arm64.o -output ../lib/darwin/stb_image_resize.a + $(CC) -arch x86_64 -c -O2 -Os -fPIC stb_truetype.c -o stb_truetype-x86_64.o -mmacosx-version-min=10.12 + $(CC) -arch arm64 -c -O2 -Os -fPIC stb_truetype.c -o stb_truetype-arm64.o -mmacosx-version-min=10.12 + lipo -create stb_truetype-x86_64.o stb_truetype-arm64.o -output ../lib/darwin/stb_truetype.a + $(CC) -arch x86_64 -c -O2 -Os -fPIC stb_rect_pack.c -o stb_rect_pack-x86_64.o -mmacosx-version-min=10.12 + $(CC) -arch arm64 -c -O2 -Os -fPIC stb_rect_pack.c -o stb_rect_pack-arm64.o -mmacosx-version-min=10.12 + lipo -create stb_rect_pack-x86_64.o stb_rect_pack-arm64.o -output ../lib/darwin/stb_rect_pack.a + $(CC) -arch x86_64 -c -O2 -Os -fPIC stb_vorbis.c -o stb_vorbis-x86_64.o -mmacosx-version-min=10.12 + $(CC) -arch arm64 -c -O2 -Os -fPIC stb_vorbis.c -o stb_vorbis-arm64.o -mmacosx-version-min=10.12 + lipo -create stb_vorbis-x86_64.o stb_vorbis-arm64.o -output ../lib/darwin/stb_vorbis.a + rm *.o diff --git a/vendor/stb/truetype/stb_truetype.odin b/vendor/stb/truetype/stb_truetype.odin index 56bb0667a..5b0022da2 100644 --- a/vendor/stb/truetype/stb_truetype.odin +++ b/vendor/stb/truetype/stb_truetype.odin @@ -200,7 +200,7 @@ fontinfo :: struct { numGlyphs: c.int, - loca, head, glyf, hhea, hmtx, kern: c.int, + loca, head, glyf, hhea, hmtx, kern, gpos, svg: c.int, index_map: c.int, indexToLocFormat: c.int, diff --git a/vendor/vulkan/_gen/create_vulkan_odin_wrapper.py b/vendor/vulkan/_gen/create_vulkan_odin_wrapper.py index 1dbac58d8..26bfc0a82 100644 --- a/vendor/vulkan/_gen/create_vulkan_odin_wrapper.py +++ b/vendor/vulkan/_gen/create_vulkan_odin_wrapper.py @@ -7,14 +7,20 @@ import os.path import math file_and_urls = [ - ("vk_platform.h", 'https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/main/include/vulkan/vk_platform.h', True), - ("vulkan_core.h", 'https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/main/include/vulkan/vulkan_core.h', False), - ("vk_layer.h", 'https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/main/include/vulkan/vk_layer.h', True), - ("vk_icd.h", 'https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/main/include/vulkan/vk_icd.h', True), - ("vulkan_win32.h", 'https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/main/include/vulkan/vulkan_win32.h', False), - ("vulkan_metal.h", 'https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/main/include/vulkan/vulkan_metal.h', False), - ("vulkan_macos.h", 'https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/main/include/vulkan/vulkan_macos.h', False), - ("vulkan_ios.h", 'https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/main/include/vulkan/vulkan_ios.h', False), + ("vk_platform.h", 'https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/main/include/vulkan/vk_platform.h', True), + ("vulkan_core.h", 'https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/main/include/vulkan/vulkan_core.h', False), + ("vk_layer.h", 'https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/main/include/vulkan/vk_layer.h', True), + ("vk_icd.h", 'https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/main/include/vulkan/vk_icd.h', True), + ("vulkan_win32.h", 'https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/main/include/vulkan/vulkan_win32.h', False), + ("vulkan_metal.h", 'https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/main/include/vulkan/vulkan_metal.h', False), + ("vulkan_macos.h", 'https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/main/include/vulkan/vulkan_macos.h', False), + ("vulkan_ios.h", 'https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/main/include/vulkan/vulkan_ios.h', False), + ("vulkan_wayland.h", 'https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/main/include/vulkan/vulkan_wayland.h', False), + # Vulkan Video + ("vulkan_video_codec_h264std.h", 'https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/main/include/vk_video/vulkan_video_codec_h264std.h', False), + ("vulkan_video_codec_h265std.h", 'https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/main/include/vk_video/vulkan_video_codec_h265std.h', False), + ("vulkan_video_codec_h264std_decode.h", 'https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/main/include/vk_video/vulkan_video_codec_h264std_decode.h', False), + ("vulkan_video_codec_h265std_decode.h", 'https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/main/include/vk_video/vulkan_video_codec_h265std_decode.h', False), ] for file, url, _ in file_and_urls: @@ -36,8 +42,17 @@ def no_vk(t): t = t.replace('PFN_', 'Proc') t = t.replace('PFN_', 'Proc') t = t.replace('VK_', '') + # Vulkan Video + t = t.replace('STD_', '') + t = t.replace('Std', '') return t +OPAQUE_STRUCTS = """ +wl_surface :: struct {} // Opaque struct defined by Wayland +wl_display :: struct {} // Opaque struct defined by Wayland +IOSurfaceRef :: struct {} // Opaque struct defined by Apple’s CoreGraphics framework +""" + def convert_type(t, prev_name, curr_name): table = { "Bool32": 'b32', @@ -50,6 +65,7 @@ def convert_type(t, prev_name, curr_name): 'int64_t': 'i64', 'int': 'c.int', 'uint8_t': 'u8', + 'int8_t': 'i8', "uint16_t": 'u16', "char": "byte", "void": "void", @@ -64,10 +80,13 @@ def convert_type(t, prev_name, curr_name): "const void* const *": "[^]rawptr", "const AccelerationStructureGeometryKHR* const*": "^[^]AccelerationStructureGeometryKHR", "const AccelerationStructureBuildRangeInfoKHR* const*": "^[^]AccelerationStructureBuildRangeInfoKHR", + "const MicromapUsageEXT* const*": "^[^]MicromapUsageEXT", "struct BaseOutStructure": "BaseOutStructure", "struct BaseInStructure": "BaseInStructure", + "struct wl_display": "wl_display", + "struct wl_surface": "wl_surface", 'v': '', - } + } if t in table.keys(): return table[t] @@ -253,6 +272,12 @@ def parse_constants(f): for name, value in allowed_data: f.write("{}{} :: {}\n".format(name, "".rjust(max_len-len(name)), value)) + f.write("\n// Vulkan Video Constants\n") + vulkan_video_data = re.findall(r"#define STD_(\w+)\s*(.*?)U?\n", src, re.S) + max_len = max(len(name) for name, value in vulkan_video_data) + for name, value in vulkan_video_data: + f.write("{}{} :: {}\n".format(name, "".rjust(max_len-len(name)), value)) + f.write("\n// Vendor Constants\n") fixes = '|'.join(ext_suffixes) inner = r"((?:(?:" + fixes + r")\w+)|(?:\w+" + fixes + r"))" @@ -276,6 +301,7 @@ def parse_enums(f): f.write("// Enums\n") data = re.findall(r"typedef enum Vk(\w+) {(.+?)} \w+;", src, re.S) + data += re.findall(r"typedef enum Std(\w+) {(.+?)} \w+;", src, re.S) data.sort(key=lambda x: x[0]) @@ -376,7 +402,16 @@ def parse_enums(f): used_flags.append('.'+flags[i]) else: used_flags.append('{}({})'.format(enum_name, i)) - s = "{enum_name}s_{n} :: {enum_name}s{{".format(enum_name=enum_name, n=n) + # Make sure the 's' is after Flags and not the extension name. + ext_suffix = '' + for suffix in ext_suffixes: + if not enum_name.endswith(suffix): + continue + + ext_suffix = suffix + enum_name = remove_suffix(enum_name, ext_suffix) + break + s = "{enum_name}s{ext_suffix}_{n} :: {enum_name}s{ext_suffix}{{".format(enum_name=enum_name, ext_suffix=ext_suffix, n=n) s += ', '.join(used_flags) s += "}\n" f.write(s) @@ -398,6 +433,7 @@ def parse_enums(f): def parse_structs(f): data = re.findall(r"typedef (struct|union) Vk(\w+?) {(.+?)} \w+?;", src, re.S) + data += re.findall(r"typedef (struct|union) Std(\w+?) {(.+?)} \w+?;", src, re.S) for _type, name, fields in data: fields = re.findall(r"\s+(.+?)\s+([_a-zA-Z0-9[\]]+);", fields) @@ -409,6 +445,18 @@ def parse_structs(f): prev_name = "" ffields = [] for type_, fname in fields: + + # If the typename has a colon in it, then it is a C bit field. + if ":" in type_: + bit_field = type_.split(' ') + # Get rid of empty spaces + bit_field = list(filter(bool, bit_field)) + # [type, typename, :] + assert len(bit_field) == 3, "Failed to parse the bit field!" + bit_field_type = do_type(bit_field[0], prev_name, fname) + f.write("\tbit_field: {},{}\n".format(bit_field_type, comment or "")) + break + if '[' in fname: fname, type_ = parse_array(fname, type_) comment = None @@ -422,7 +470,7 @@ def parse_structs(f): ffields.append(tuple([n, t, comment])) prev_name = fname - max_len = max(len(n) for n, _, _ in ffields) + max_len = max([len(n) for n, _, _ in ffields], default=0) for n, t, comment in ffields: k = max_len-len(n)+len(t) @@ -431,6 +479,8 @@ def parse_structs(f): f.write("}\n\n") + f.write("// Opaque structs\n") + f.write(OPAQUE_STRUCTS) f.write("// Aliases\n") data = re.findall(r"typedef Vk(\w+?) Vk(\w+?);", src, re.S) @@ -650,27 +700,28 @@ SetProcAddressType :: #type proc(p: rawptr, name: cstring) RemoteAddressNV :: distinct rawptr // Declared inline before MemoryGetRemoteAddressInfoNV // Base constants -LOD_CLAMP_NONE :: 1000.0 -REMAINING_MIP_LEVELS :: ~u32(0) -REMAINING_ARRAY_LAYERS :: ~u32(0) -WHOLE_SIZE :: ~u64(0) -ATTACHMENT_UNUSED :: ~u32(0) -TRUE :: 1 -FALSE :: 0 -QUEUE_FAMILY_IGNORED :: ~u32(0) -SUBPASS_EXTERNAL :: ~u32(0) -MAX_PHYSICAL_DEVICE_NAME_SIZE :: 256 -UUID_SIZE :: 16 -MAX_MEMORY_TYPES :: 32 -MAX_MEMORY_HEAPS :: 16 -MAX_EXTENSION_NAME_SIZE :: 256 -MAX_DESCRIPTION_SIZE :: 256 -MAX_DEVICE_GROUP_SIZE :: 32 -LUID_SIZE_KHX :: 8 -LUID_SIZE :: 8 -MAX_QUEUE_FAMILY_EXTERNAL :: ~u32(1) -MAX_GLOBAL_PRIORITY_SIZE_EXT :: 16 -QUEUE_FAMILY_EXTERNAL :: MAX_QUEUE_FAMILY_EXTERNAL +LOD_CLAMP_NONE :: 1000.0 +REMAINING_MIP_LEVELS :: ~u32(0) +REMAINING_ARRAY_LAYERS :: ~u32(0) +WHOLE_SIZE :: ~u64(0) +ATTACHMENT_UNUSED :: ~u32(0) +TRUE :: 1 +FALSE :: 0 +QUEUE_FAMILY_IGNORED :: ~u32(0) +SUBPASS_EXTERNAL :: ~u32(0) +MAX_PHYSICAL_DEVICE_NAME_SIZE :: 256 +MAX_SHADER_MODULE_IDENTIFIER_SIZE_EXT :: 32 +UUID_SIZE :: 16 +MAX_MEMORY_TYPES :: 32 +MAX_MEMORY_HEAPS :: 16 +MAX_EXTENSION_NAME_SIZE :: 256 +MAX_DESCRIPTION_SIZE :: 256 +MAX_DEVICE_GROUP_SIZE :: 32 +LUID_SIZE_KHX :: 8 +LUID_SIZE :: 8 +MAX_QUEUE_FAMILY_EXTERNAL :: ~u32(1) +MAX_GLOBAL_PRIORITY_SIZE_EXT :: 16 +QUEUE_FAMILY_EXTERNAL :: MAX_QUEUE_FAMILY_EXTERNAL """[1::]) parse_constants(f) @@ -716,6 +767,12 @@ when ODIN_OS == .Windows { CAMetalLayer :: struct {} +MTLBuffer_id :: rawptr +MTLTexture_id :: rawptr +MTLSharedEvent_id :: rawptr +MTLDevice_id :: rawptr +MTLCommandQueue_id :: rawptr + /********************************/ """) f.write("\n") diff --git a/vendor/vulkan/_gen/vk_icd.h b/vendor/vulkan/_gen/vk_icd.h index 41989ee35..2cd6c3d33 100644 --- a/vendor/vulkan/_gen/vk_icd.h +++ b/vendor/vulkan/_gen/vk_icd.h @@ -2,9 +2,9 @@ // File: vk_icd.h // /* - * Copyright (c) 2015-2016 The Khronos Group Inc. - * Copyright (c) 2015-2016 Valve Corporation - * Copyright (c) 2015-2016 LunarG, Inc. + * Copyright (c) 2015-2023 LunarG, Inc. + * Copyright (c) 2015-2023 The Khronos Group Inc. + * Copyright (c) 2015-2023 Valve Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,9 +19,7 @@ * limitations under the License. * */ - -#ifndef VKICD_H -#define VKICD_H +#pragma once #include "vulkan.h" #include @@ -42,7 +40,17 @@ // call for any API version > 1.0. Otherwise, the loader will // manually determine if it can support the expected version. // Version 6 - Add support for vk_icdEnumerateAdapterPhysicalDevices. -#define CURRENT_LOADER_ICD_INTERFACE_VERSION 6 +// Version 7 - If an ICD supports any of the following functions, they must be +// queryable with vk_icdGetInstanceProcAddr: +// vk_icdNegotiateLoaderICDInterfaceVersion +// vk_icdGetPhysicalDeviceProcAddr +// vk_icdEnumerateAdapterPhysicalDevices (Windows only) +// In addition, these functions no longer need to be exported directly. +// This version allows drivers provided through the extension +// VK_LUNARG_direct_driver_loading be able to support the entire +// Driver-Loader interface. + +#define CURRENT_LOADER_ICD_INTERFACE_VERSION 7 #define MIN_SUPPORTED_LOADER_ICD_INTERFACE_VERSION 0 #define MIN_PHYS_DEV_EXTENSION_ICD_INTERFACE_VERSION 4 @@ -70,7 +78,7 @@ extern "C" { #endif VKAPI_ATTR VkResult VKAPI_CALL vk_icdNegotiateLoaderICDInterfaceVersion(uint32_t* pVersion); VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetInstanceProcAddr(VkInstance instance, const char* pName); - VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetPhysicalDeviceProcAddr(VkInstance isntance, const char* pName); + VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetPhysicalDeviceProcAddr(VkInstance instance, const char* pName); #if defined(VK_USE_PLATFORM_WIN32_KHR) VKAPI_ATTR VkResult VKAPI_CALL vk_icdEnumerateAdapterPhysicalDevices(VkInstance instance, LUID adapterLUID, uint32_t* pPhysicalDeviceCount, VkPhysicalDevice* pPhysicalDevices); @@ -123,6 +131,7 @@ typedef enum { VK_ICD_WSI_PLATFORM_VI, VK_ICD_WSI_PLATFORM_GGP, VK_ICD_WSI_PLATFORM_SCREEN, + VK_ICD_WSI_PLATFORM_FUCHSIA, } VkIcdWsiPlatform; typedef struct { @@ -242,4 +251,8 @@ typedef struct { } VkIcdSurfaceScreen; #endif // VK_USE_PLATFORM_SCREEN_QNX -#endif // VKICD_H +#ifdef VK_USE_PLATFORM_FUCHSIA +typedef struct { + VkIcdSurfaceBase base; +} VkIcdSurfaceImagePipe; +#endif // VK_USE_PLATFORM_FUCHSIA diff --git a/vendor/vulkan/_gen/vk_layer.h b/vendor/vulkan/_gen/vk_layer.h index 0651870c7..7954f71d8 100644 --- a/vendor/vulkan/_gen/vk_layer.h +++ b/vendor/vulkan/_gen/vk_layer.h @@ -2,9 +2,9 @@ // File: vk_layer.h // /* - * Copyright (c) 2015-2017 The Khronos Group Inc. - * Copyright (c) 2015-2017 Valve Corporation - * Copyright (c) 2015-2017 LunarG, Inc. + * Copyright (c) 2015-2023 LunarG, Inc. + * Copyright (c) 2015-2023 The Khronos Group Inc. + * Copyright (c) 2015-2023 Valve Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,21 +19,14 @@ * limitations under the License. * */ +#pragma once /* Need to define dispatch table * Core struct can then have ptr to dispatch table at the top * Along with object ptrs for current and next OBJ */ -#pragma once -#include "vulkan.h" -#if defined(__GNUC__) && __GNUC__ >= 4 -#define VK_LAYER_EXPORT __attribute__((visibility("default"))) -#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590) -#define VK_LAYER_EXPORT __attribute__((visibility("default"))) -#else -#define VK_LAYER_EXPORT -#endif +#include "vulkan_core.h" #define MAX_NUM_UNKNOWN_EXTS 250 diff --git a/vendor/vulkan/_gen/vk_platform.h b/vendor/vulkan/_gen/vk_platform.h index 3ff8c5d14..ed67a6004 100644 --- a/vendor/vulkan/_gen/vk_platform.h +++ b/vendor/vulkan/_gen/vk_platform.h @@ -2,7 +2,7 @@ // File: vk_platform.h // /* -** Copyright 2014-2022 The Khronos Group Inc. +** Copyright 2014-2023 The Khronos Group Inc. ** ** SPDX-License-Identifier: Apache-2.0 */ diff --git a/vendor/vulkan/_gen/vulkan_core.h b/vendor/vulkan/_gen/vulkan_core.h index 5c8b8461f..a2e7ed3cb 100644 --- a/vendor/vulkan/_gen/vulkan_core.h +++ b/vendor/vulkan/_gen/vulkan_core.h @@ -2,7 +2,7 @@ #define VULKAN_CORE_H_ 1 /* -** Copyright 2015-2022 The Khronos Group Inc. +** Copyright 2015-2023 The Khronos Group Inc. ** ** SPDX-License-Identifier: Apache-2.0 */ @@ -58,37 +58,37 @@ extern "C" { #endif #endif -// DEPRECATED: This define is deprecated. VK_MAKE_API_VERSION should be used instead. -#define VK_MAKE_VERSION(major, minor, patch) \ - ((((uint32_t)(major)) << 22) | (((uint32_t)(minor)) << 12) | ((uint32_t)(patch))) +#define VK_MAKE_API_VERSION(variant, major, minor, patch) \ + ((((uint32_t)(variant)) << 29U) | (((uint32_t)(major)) << 22U) | (((uint32_t)(minor)) << 12U) | ((uint32_t)(patch))) // DEPRECATED: This define has been removed. Specific version defines (e.g. VK_API_VERSION_1_0), or the VK_MAKE_VERSION macro, should be used instead. -//#define VK_API_VERSION VK_MAKE_VERSION(1, 0, 0) // Patch version should always be set to 0 - -#define VK_MAKE_API_VERSION(variant, major, minor, patch) \ - ((((uint32_t)(variant)) << 29) | (((uint32_t)(major)) << 22) | (((uint32_t)(minor)) << 12) | ((uint32_t)(patch))) +//#define VK_API_VERSION VK_MAKE_API_VERSION(0, 1, 0, 0) // Patch version should always be set to 0 // Vulkan 1.0 version number #define VK_API_VERSION_1_0 VK_MAKE_API_VERSION(0, 1, 0, 0)// Patch version should always be set to 0 // Version of this file -#define VK_HEADER_VERSION 211 +#define VK_HEADER_VERSION 250 // Complete version of this file #define VK_HEADER_VERSION_COMPLETE VK_MAKE_API_VERSION(0, 1, 3, VK_HEADER_VERSION) +// DEPRECATED: This define is deprecated. VK_MAKE_API_VERSION should be used instead. +#define VK_MAKE_VERSION(major, minor, patch) \ + ((((uint32_t)(major)) << 22U) | (((uint32_t)(minor)) << 12U) | ((uint32_t)(patch))) + // DEPRECATED: This define is deprecated. VK_API_VERSION_MAJOR should be used instead. -#define VK_VERSION_MAJOR(version) ((uint32_t)(version) >> 22) +#define VK_VERSION_MAJOR(version) ((uint32_t)(version) >> 22U) // DEPRECATED: This define is deprecated. VK_API_VERSION_MINOR should be used instead. -#define VK_VERSION_MINOR(version) (((uint32_t)(version) >> 12) & 0x3FFU) +#define VK_VERSION_MINOR(version) (((uint32_t)(version) >> 12U) & 0x3FFU) // DEPRECATED: This define is deprecated. VK_API_VERSION_PATCH should be used instead. #define VK_VERSION_PATCH(version) ((uint32_t)(version) & 0xFFFU) -#define VK_API_VERSION_VARIANT(version) ((uint32_t)(version) >> 29) -#define VK_API_VERSION_MAJOR(version) (((uint32_t)(version) >> 22) & 0x7FU) -#define VK_API_VERSION_MINOR(version) (((uint32_t)(version) >> 12) & 0x3FFU) +#define VK_API_VERSION_VARIANT(version) ((uint32_t)(version) >> 29U) +#define VK_API_VERSION_MAJOR(version) (((uint32_t)(version) >> 22U) & 0x7FU) +#define VK_API_VERSION_MINOR(version) (((uint32_t)(version) >> 12U) & 0x3FFU) #define VK_API_VERSION_PATCH(version) ((uint32_t)(version) & 0xFFFU) typedef uint32_t VkBool32; typedef uint64_t VkDeviceAddress; @@ -120,7 +120,6 @@ VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDescriptorSet) VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDescriptorPool) VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkFramebuffer) VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkCommandPool) -#define VK_UUID_SIZE 16U #define VK_ATTACHMENT_UNUSED (~0U) #define VK_FALSE 0U #define VK_LOD_CLAMP_NONE 1000.0F @@ -131,10 +130,11 @@ VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkCommandPool) #define VK_TRUE 1U #define VK_WHOLE_SIZE (~0ULL) #define VK_MAX_MEMORY_TYPES 32U -#define VK_MAX_MEMORY_HEAPS 16U #define VK_MAX_PHYSICAL_DEVICE_NAME_SIZE 256U +#define VK_UUID_SIZE 16U #define VK_MAX_EXTENSION_NAME_SIZE 256U #define VK_MAX_DESCRIPTION_SIZE 256U +#define VK_MAX_MEMORY_HEAPS 16U typedef enum VkResult { VK_SUCCESS = 0, @@ -168,6 +168,12 @@ typedef enum VkResult { VK_ERROR_INCOMPATIBLE_DISPLAY_KHR = -1000003001, VK_ERROR_VALIDATION_FAILED_EXT = -1000011001, VK_ERROR_INVALID_SHADER_NV = -1000012000, + VK_ERROR_IMAGE_USAGE_NOT_SUPPORTED_KHR = -1000023000, + VK_ERROR_VIDEO_PICTURE_LAYOUT_NOT_SUPPORTED_KHR = -1000023001, + VK_ERROR_VIDEO_PROFILE_OPERATION_NOT_SUPPORTED_KHR = -1000023002, + VK_ERROR_VIDEO_PROFILE_FORMAT_NOT_SUPPORTED_KHR = -1000023003, + VK_ERROR_VIDEO_PROFILE_CODEC_NOT_SUPPORTED_KHR = -1000023004, + VK_ERROR_VIDEO_STD_VERSION_NOT_SUPPORTED_KHR = -1000023005, VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT = -1000158000, VK_ERROR_NOT_PERMITTED_KHR = -1000174001, VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT = -1000255000, @@ -175,6 +181,11 @@ typedef enum VkResult { VK_THREAD_DONE_KHR = 1000268001, VK_OPERATION_DEFERRED_KHR = 1000268002, VK_OPERATION_NOT_DEFERRED_KHR = 1000268003, +#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_ERROR_INVALID_VIDEO_STD_PARAMETERS_KHR = -1000299000, +#endif + VK_ERROR_COMPRESSION_EXHAUSTED_EXT = -1000338000, + VK_ERROR_INCOMPATIBLE_SHADER_BINARY_EXT = 1000482000, VK_ERROR_OUT_OF_POOL_MEMORY_KHR = VK_ERROR_OUT_OF_POOL_MEMORY, VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR = VK_ERROR_INVALID_EXTERNAL_HANDLE, VK_ERROR_FRAGMENTATION_EXT = VK_ERROR_FRAGMENTATION, @@ -424,63 +435,26 @@ typedef enum VkStructureType { VK_STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_NAME_INFO_EXT = 1000022000, VK_STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_TAG_INFO_EXT = 1000022001, VK_STRUCTURE_TYPE_DEBUG_MARKER_MARKER_INFO_EXT = 1000022002, -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_PROFILE_KHR = 1000023000, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_STRUCTURE_TYPE_VIDEO_PROFILE_INFO_KHR = 1000023000, VK_STRUCTURE_TYPE_VIDEO_CAPABILITIES_KHR = 1000023001, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_PICTURE_RESOURCE_KHR = 1000023002, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_GET_MEMORY_PROPERTIES_KHR = 1000023003, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_BIND_MEMORY_KHR = 1000023004, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_STRUCTURE_TYPE_VIDEO_PICTURE_RESOURCE_INFO_KHR = 1000023002, + VK_STRUCTURE_TYPE_VIDEO_SESSION_MEMORY_REQUIREMENTS_KHR = 1000023003, + VK_STRUCTURE_TYPE_BIND_VIDEO_SESSION_MEMORY_INFO_KHR = 1000023004, VK_STRUCTURE_TYPE_VIDEO_SESSION_CREATE_INFO_KHR = 1000023005, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_STRUCTURE_TYPE_VIDEO_SESSION_PARAMETERS_CREATE_INFO_KHR = 1000023006, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_STRUCTURE_TYPE_VIDEO_SESSION_PARAMETERS_UPDATE_INFO_KHR = 1000023007, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_STRUCTURE_TYPE_VIDEO_BEGIN_CODING_INFO_KHR = 1000023008, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_STRUCTURE_TYPE_VIDEO_END_CODING_INFO_KHR = 1000023009, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_STRUCTURE_TYPE_VIDEO_CODING_CONTROL_INFO_KHR = 1000023010, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_REFERENCE_SLOT_KHR = 1000023011, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_QUEUE_FAMILY_PROPERTIES_2_KHR = 1000023012, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_PROFILES_KHR = 1000023013, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_STRUCTURE_TYPE_VIDEO_REFERENCE_SLOT_INFO_KHR = 1000023011, + VK_STRUCTURE_TYPE_QUEUE_FAMILY_VIDEO_PROPERTIES_KHR = 1000023012, + VK_STRUCTURE_TYPE_VIDEO_PROFILE_LIST_INFO_KHR = 1000023013, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VIDEO_FORMAT_INFO_KHR = 1000023014, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_STRUCTURE_TYPE_VIDEO_FORMAT_PROPERTIES_KHR = 1000023015, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_QUEUE_FAMILY_QUERY_RESULT_STATUS_PROPERTIES_2_KHR = 1000023016, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_STRUCTURE_TYPE_QUEUE_FAMILY_QUERY_RESULT_STATUS_PROPERTIES_KHR = 1000023016, VK_STRUCTURE_TYPE_VIDEO_DECODE_INFO_KHR = 1000024000, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_STRUCTURE_TYPE_VIDEO_DECODE_CAPABILITIES_KHR = 1000024001, -#endif + VK_STRUCTURE_TYPE_VIDEO_DECODE_USAGE_INFO_KHR = 1000024002, VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_IMAGE_CREATE_INFO_NV = 1000026000, VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_BUFFER_CREATE_INFO_NV = 1000026001, VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_MEMORY_ALLOCATE_INFO_NV = 1000026002, @@ -508,13 +482,10 @@ typedef enum VkStructureType { VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_DPB_SLOT_INFO_EXT = 1000038004, #endif #ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_NALU_SLICE_EXT = 1000038005, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_NALU_SLICE_INFO_EXT = 1000038005, #endif #ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_EMIT_PICTURE_PARAMETERS_EXT = 1000038006, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_PROFILE_EXT = 1000038007, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_PROFILE_INFO_EXT = 1000038007, #endif #ifdef VK_ENABLE_BETA_EXTENSIONS VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_RATE_CONTROL_INFO_EXT = 1000038008, @@ -522,9 +493,6 @@ typedef enum VkStructureType { #ifdef VK_ENABLE_BETA_EXTENSIONS VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_RATE_CONTROL_LAYER_INFO_EXT = 1000038009, #endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_REFERENCE_LISTS_EXT = 1000038010, -#endif #ifdef VK_ENABLE_BETA_EXTENSIONS VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_CAPABILITIES_EXT = 1000039000, #endif @@ -541,16 +509,10 @@ typedef enum VkStructureType { VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_DPB_SLOT_INFO_EXT = 1000039004, #endif #ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_NALU_SLICE_SEGMENT_EXT = 1000039005, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_NALU_SLICE_SEGMENT_INFO_EXT = 1000039005, #endif #ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_EMIT_PICTURE_PARAMETERS_EXT = 1000039006, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_PROFILE_EXT = 1000039007, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_REFERENCE_LISTS_EXT = 1000039008, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_PROFILE_INFO_EXT = 1000039007, #endif #ifdef VK_ENABLE_BETA_EXTENSIONS VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_RATE_CONTROL_INFO_EXT = 1000039009, @@ -558,27 +520,12 @@ typedef enum VkStructureType { #ifdef VK_ENABLE_BETA_EXTENSIONS VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_RATE_CONTROL_LAYER_INFO_EXT = 1000039010, #endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_CAPABILITIES_EXT = 1000040000, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_PICTURE_INFO_EXT = 1000040001, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_MVC_EXT = 1000040002, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_PROFILE_EXT = 1000040003, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_SESSION_PARAMETERS_CREATE_INFO_EXT = 1000040004, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_SESSION_PARAMETERS_ADD_INFO_EXT = 1000040005, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_DPB_SLOT_INFO_EXT = 1000040006, -#endif + VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_CAPABILITIES_KHR = 1000040000, + VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_PICTURE_INFO_KHR = 1000040001, + VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_PROFILE_INFO_KHR = 1000040003, + VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_SESSION_PARAMETERS_CREATE_INFO_KHR = 1000040004, + VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_SESSION_PARAMETERS_ADD_INFO_KHR = 1000040005, + VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_DPB_SLOT_INFO_KHR = 1000040006, VK_STRUCTURE_TYPE_TEXTURE_LOD_GATHER_FORMAT_PROPERTIES_AMD = 1000041000, VK_STRUCTURE_TYPE_RENDERING_FRAGMENT_SHADING_RATE_ATTACHMENT_INFO_KHR = 1000044006, VK_STRUCTURE_TYPE_RENDERING_FRAGMENT_DENSITY_MAP_ATTACHMENT_INFO_EXT = 1000044007, @@ -595,6 +542,9 @@ typedef enum VkStructureType { VK_STRUCTURE_TYPE_VI_SURFACE_CREATE_INFO_NN = 1000062000, VK_STRUCTURE_TYPE_IMAGE_VIEW_ASTC_DECODE_MODE_EXT = 1000067000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ASTC_DECODE_FEATURES_EXT = 1000067001, + VK_STRUCTURE_TYPE_PIPELINE_ROBUSTNESS_CREATE_INFO_EXT = 1000068000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_ROBUSTNESS_FEATURES_EXT = 1000068001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_ROBUSTNESS_PROPERTIES_EXT = 1000068002, VK_STRUCTURE_TYPE_IMPORT_MEMORY_WIN32_HANDLE_INFO_KHR = 1000073000, VK_STRUCTURE_TYPE_EXPORT_MEMORY_WIN32_HANDLE_INFO_KHR = 1000073001, VK_STRUCTURE_TYPE_MEMORY_WIN32_HANDLE_PROPERTIES_KHR = 1000073002, @@ -738,24 +688,12 @@ typedef enum VkStructureType { VK_STRUCTURE_TYPE_PIPELINE_COMPILER_CONTROL_CREATE_INFO_AMD = 1000183000, VK_STRUCTURE_TYPE_CALIBRATED_TIMESTAMP_INFO_EXT = 1000184000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_CORE_PROPERTIES_AMD = 1000185000, -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_CAPABILITIES_EXT = 1000187000, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_SESSION_PARAMETERS_CREATE_INFO_EXT = 1000187001, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_SESSION_PARAMETERS_ADD_INFO_EXT = 1000187002, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_PROFILE_EXT = 1000187003, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_PICTURE_INFO_EXT = 1000187004, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_DPB_SLOT_INFO_EXT = 1000187005, -#endif + VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_CAPABILITIES_KHR = 1000187000, + VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_SESSION_PARAMETERS_CREATE_INFO_KHR = 1000187001, + VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_SESSION_PARAMETERS_ADD_INFO_KHR = 1000187002, + VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_PROFILE_INFO_KHR = 1000187003, + VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_PICTURE_INFO_KHR = 1000187004, + VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_DPB_SLOT_INFO_KHR = 1000187005, VK_STRUCTURE_TYPE_DEVICE_QUEUE_GLOBAL_PRIORITY_CREATE_INFO_KHR = 1000174000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GLOBAL_PRIORITY_QUERY_FEATURES_KHR = 1000388000, VK_STRUCTURE_TYPE_QUEUE_FAMILY_GLOBAL_PRIORITY_PROPERTIES_KHR = 1000388001, @@ -767,7 +705,6 @@ typedef enum VkStructureType { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COMPUTE_SHADER_DERIVATIVES_FEATURES_NV = 1000201000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MESH_SHADER_FEATURES_NV = 1000202000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MESH_SHADER_PROPERTIES_NV = 1000202001, - VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADER_BARYCENTRIC_FEATURES_NV = 1000203000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_IMAGE_FOOTPRINT_FEATURES_NV = 1000204000, VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV = 1000205000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXCLUSIVE_SCISSOR_FEATURES_NV = 1000205002, @@ -832,7 +769,18 @@ typedef enum VkStructureType { VK_STRUCTURE_TYPE_PIPELINE_EXECUTABLE_INFO_KHR = 1000269003, VK_STRUCTURE_TYPE_PIPELINE_EXECUTABLE_STATISTIC_KHR = 1000269004, VK_STRUCTURE_TYPE_PIPELINE_EXECUTABLE_INTERNAL_REPRESENTATION_KHR = 1000269005, + VK_STRUCTURE_TYPE_MEMORY_MAP_INFO_KHR = 1000271000, + VK_STRUCTURE_TYPE_MEMORY_UNMAP_INFO_KHR = 1000271001, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_FLOAT_2_FEATURES_EXT = 1000273000, + VK_STRUCTURE_TYPE_SURFACE_PRESENT_MODE_EXT = 1000274000, + VK_STRUCTURE_TYPE_SURFACE_PRESENT_SCALING_CAPABILITIES_EXT = 1000274001, + VK_STRUCTURE_TYPE_SURFACE_PRESENT_MODE_COMPATIBILITY_EXT = 1000274002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SWAPCHAIN_MAINTENANCE_1_FEATURES_EXT = 1000275000, + VK_STRUCTURE_TYPE_SWAPCHAIN_PRESENT_FENCE_INFO_EXT = 1000275001, + VK_STRUCTURE_TYPE_SWAPCHAIN_PRESENT_MODES_CREATE_INFO_EXT = 1000275002, + VK_STRUCTURE_TYPE_SWAPCHAIN_PRESENT_MODE_INFO_EXT = 1000275003, + VK_STRUCTURE_TYPE_SWAPCHAIN_PRESENT_SCALING_CREATE_INFO_EXT = 1000275004, + VK_STRUCTURE_TYPE_RELEASE_SWAPCHAIN_IMAGES_INFO_EXT = 1000275005, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEVICE_GENERATED_COMMANDS_PROPERTIES_NV = 1000277000, VK_STRUCTURE_TYPE_GRAPHICS_SHADER_GROUP_CREATE_INFO_NV = 1000277001, VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_SHADER_GROUPS_CREATE_INFO_NV = 1000277002, @@ -855,6 +803,9 @@ typedef enum VkStructureType { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CUSTOM_BORDER_COLOR_PROPERTIES_EXT = 1000287001, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CUSTOM_BORDER_COLOR_FEATURES_EXT = 1000287002, VK_STRUCTURE_TYPE_PIPELINE_LIBRARY_CREATE_INFO_KHR = 1000290000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENT_BARRIER_FEATURES_NV = 1000292000, + VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_PRESENT_BARRIER_NV = 1000292001, + VK_STRUCTURE_TYPE_SWAPCHAIN_PRESENT_BARRIER_CREATE_INFO_NV = 1000292002, VK_STRUCTURE_TYPE_PRESENT_ID_KHR = 1000294000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENT_ID_FEATURES_KHR = 1000294001, #ifdef VK_ENABLE_BETA_EXTENSIONS @@ -868,14 +819,49 @@ typedef enum VkStructureType { #endif #ifdef VK_ENABLE_BETA_EXTENSIONS VK_STRUCTURE_TYPE_VIDEO_ENCODE_CAPABILITIES_KHR = 1000299003, +#endif +#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_STRUCTURE_TYPE_VIDEO_ENCODE_USAGE_INFO_KHR = 1000299004, +#endif +#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_STRUCTURE_TYPE_QUERY_POOL_VIDEO_ENCODE_FEEDBACK_CREATE_INFO_KHR = 1000299005, #endif VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DIAGNOSTICS_CONFIG_FEATURES_NV = 1000300000, VK_STRUCTURE_TYPE_DEVICE_DIAGNOSTICS_CONFIG_CREATE_INFO_NV = 1000300001, + VK_STRUCTURE_TYPE_QUERY_LOW_LATENCY_SUPPORT_NV = 1000310000, + VK_STRUCTURE_TYPE_EXPORT_METAL_OBJECT_CREATE_INFO_EXT = 1000311000, + VK_STRUCTURE_TYPE_EXPORT_METAL_OBJECTS_INFO_EXT = 1000311001, + VK_STRUCTURE_TYPE_EXPORT_METAL_DEVICE_INFO_EXT = 1000311002, + VK_STRUCTURE_TYPE_EXPORT_METAL_COMMAND_QUEUE_INFO_EXT = 1000311003, + VK_STRUCTURE_TYPE_EXPORT_METAL_BUFFER_INFO_EXT = 1000311004, + VK_STRUCTURE_TYPE_IMPORT_METAL_BUFFER_INFO_EXT = 1000311005, + VK_STRUCTURE_TYPE_EXPORT_METAL_TEXTURE_INFO_EXT = 1000311006, + VK_STRUCTURE_TYPE_IMPORT_METAL_TEXTURE_INFO_EXT = 1000311007, + VK_STRUCTURE_TYPE_EXPORT_METAL_IO_SURFACE_INFO_EXT = 1000311008, + VK_STRUCTURE_TYPE_IMPORT_METAL_IO_SURFACE_INFO_EXT = 1000311009, + VK_STRUCTURE_TYPE_EXPORT_METAL_SHARED_EVENT_INFO_EXT = 1000311010, + VK_STRUCTURE_TYPE_IMPORT_METAL_SHARED_EVENT_INFO_EXT = 1000311011, VK_STRUCTURE_TYPE_QUEUE_FAMILY_CHECKPOINT_PROPERTIES_2_NV = 1000314008, VK_STRUCTURE_TYPE_CHECKPOINT_DATA_2_NV = 1000314009, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_BUFFER_PROPERTIES_EXT = 1000316000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_BUFFER_DENSITY_MAP_PROPERTIES_EXT = 1000316001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_BUFFER_FEATURES_EXT = 1000316002, + VK_STRUCTURE_TYPE_DESCRIPTOR_ADDRESS_INFO_EXT = 1000316003, + VK_STRUCTURE_TYPE_DESCRIPTOR_GET_INFO_EXT = 1000316004, + VK_STRUCTURE_TYPE_BUFFER_CAPTURE_DESCRIPTOR_DATA_INFO_EXT = 1000316005, + VK_STRUCTURE_TYPE_IMAGE_CAPTURE_DESCRIPTOR_DATA_INFO_EXT = 1000316006, + VK_STRUCTURE_TYPE_IMAGE_VIEW_CAPTURE_DESCRIPTOR_DATA_INFO_EXT = 1000316007, + VK_STRUCTURE_TYPE_SAMPLER_CAPTURE_DESCRIPTOR_DATA_INFO_EXT = 1000316008, + VK_STRUCTURE_TYPE_OPAQUE_CAPTURE_DESCRIPTOR_DATA_CREATE_INFO_EXT = 1000316010, + VK_STRUCTURE_TYPE_DESCRIPTOR_BUFFER_BINDING_INFO_EXT = 1000316011, + VK_STRUCTURE_TYPE_DESCRIPTOR_BUFFER_BINDING_PUSH_DESCRIPTOR_BUFFER_HANDLE_EXT = 1000316012, + VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_CAPTURE_DESCRIPTOR_DATA_INFO_EXT = 1000316009, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GRAPHICS_PIPELINE_LIBRARY_FEATURES_EXT = 1000320000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GRAPHICS_PIPELINE_LIBRARY_PROPERTIES_EXT = 1000320001, VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_LIBRARY_CREATE_INFO_EXT = 1000320002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_EARLY_AND_LATE_FRAGMENT_TESTS_FEATURES_AMD = 1000321000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADER_BARYCENTRIC_FEATURES_KHR = 1000203000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADER_BARYCENTRIC_PROPERTIES_KHR = 1000322000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_UNIFORM_CONTROL_FLOW_FEATURES_KHR = 1000323000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_ENUMS_PROPERTIES_NV = 1000326000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_ENUMS_FEATURES_NV = 1000326001, @@ -883,21 +869,31 @@ typedef enum VkStructureType { VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_MOTION_TRIANGLES_DATA_NV = 1000327000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_MOTION_BLUR_FEATURES_NV = 1000327001, VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_MOTION_INFO_NV = 1000327002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MESH_SHADER_FEATURES_EXT = 1000328000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MESH_SHADER_PROPERTIES_EXT = 1000328001, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_YCBCR_2_PLANE_444_FORMATS_FEATURES_EXT = 1000330000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_2_FEATURES_EXT = 1000332000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_2_PROPERTIES_EXT = 1000332001, VK_STRUCTURE_TYPE_COPY_COMMAND_TRANSFORM_INFO_QCOM = 1000333000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_WORKGROUP_MEMORY_EXPLICIT_LAYOUT_FEATURES_KHR = 1000336000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_COMPRESSION_CONTROL_FEATURES_EXT = 1000338000, + VK_STRUCTURE_TYPE_IMAGE_COMPRESSION_CONTROL_EXT = 1000338001, + VK_STRUCTURE_TYPE_SUBRESOURCE_LAYOUT_2_EXT = 1000338002, + VK_STRUCTURE_TYPE_IMAGE_SUBRESOURCE_2_EXT = 1000338003, + VK_STRUCTURE_TYPE_IMAGE_COMPRESSION_PROPERTIES_EXT = 1000338004, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ATTACHMENT_FEEDBACK_LOOP_LAYOUT_FEATURES_EXT = 1000339000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_4444_FORMATS_FEATURES_EXT = 1000340000, - VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_FEATURES_ARM = 1000342000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FAULT_FEATURES_EXT = 1000341000, + VK_STRUCTURE_TYPE_DEVICE_FAULT_COUNTS_EXT = 1000341001, + VK_STRUCTURE_TYPE_DEVICE_FAULT_INFO_EXT = 1000341002, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RGBA10X6_FORMATS_FEATURES_EXT = 1000344000, VK_STRUCTURE_TYPE_DIRECTFB_SURFACE_CREATE_INFO_EXT = 1000346000, - VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MUTABLE_DESCRIPTOR_TYPE_FEATURES_VALVE = 1000351000, - VK_STRUCTURE_TYPE_MUTABLE_DESCRIPTOR_TYPE_CREATE_INFO_VALVE = 1000351002, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_INPUT_DYNAMIC_STATE_FEATURES_EXT = 1000352000, VK_STRUCTURE_TYPE_VERTEX_INPUT_BINDING_DESCRIPTION_2_EXT = 1000352001, VK_STRUCTURE_TYPE_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION_2_EXT = 1000352002, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRM_PROPERTIES_EXT = 1000353000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ADDRESS_BINDING_REPORT_FEATURES_EXT = 1000354000, + VK_STRUCTURE_TYPE_DEVICE_ADDRESS_BINDING_CALLBACK_DATA_EXT = 1000354001, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_CLIP_CONTROL_FEATURES_EXT = 1000355000, VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_DEPTH_CLIP_CONTROL_CREATE_INFO_EXT = 1000355001, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRIMITIVE_TOPOLOGY_LIST_RESTART_FEATURES_EXT = 1000356000, @@ -922,26 +918,109 @@ typedef enum VkStructureType { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INVOCATION_MASK_FEATURES_HUAWEI = 1000370000, VK_STRUCTURE_TYPE_MEMORY_GET_REMOTE_ADDRESS_INFO_NV = 1000371000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_MEMORY_RDMA_FEATURES_NV = 1000371001, + VK_STRUCTURE_TYPE_PIPELINE_PROPERTIES_IDENTIFIER_EXT = 1000372000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_PROPERTIES_FEATURES_EXT = 1000372001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTISAMPLED_RENDER_TO_SINGLE_SAMPLED_FEATURES_EXT = 1000376000, + VK_STRUCTURE_TYPE_SUBPASS_RESOLVE_PERFORMANCE_QUERY_EXT = 1000376001, + VK_STRUCTURE_TYPE_MULTISAMPLED_RENDER_TO_SINGLE_SAMPLED_INFO_EXT = 1000376002, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_2_FEATURES_EXT = 1000377000, VK_STRUCTURE_TYPE_SCREEN_SURFACE_CREATE_INFO_QNX = 1000378000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COLOR_WRITE_ENABLE_FEATURES_EXT = 1000381000, VK_STRUCTURE_TYPE_PIPELINE_COLOR_WRITE_CREATE_INFO_EXT = 1000381001, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRIMITIVES_GENERATED_QUERY_FEATURES_EXT = 1000382000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_MAINTENANCE_1_FEATURES_KHR = 1000386000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_VIEW_MIN_LOD_FEATURES_EXT = 1000391000, VK_STRUCTURE_TYPE_IMAGE_VIEW_MIN_LOD_CREATE_INFO_EXT = 1000391001, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTI_DRAW_FEATURES_EXT = 1000392000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTI_DRAW_PROPERTIES_EXT = 1000392001, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_2D_VIEW_OF_3D_FEATURES_EXT = 1000393000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_TILE_IMAGE_FEATURES_EXT = 1000395000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_TILE_IMAGE_PROPERTIES_EXT = 1000395001, + VK_STRUCTURE_TYPE_MICROMAP_BUILD_INFO_EXT = 1000396000, + VK_STRUCTURE_TYPE_MICROMAP_VERSION_INFO_EXT = 1000396001, + VK_STRUCTURE_TYPE_COPY_MICROMAP_INFO_EXT = 1000396002, + VK_STRUCTURE_TYPE_COPY_MICROMAP_TO_MEMORY_INFO_EXT = 1000396003, + VK_STRUCTURE_TYPE_COPY_MEMORY_TO_MICROMAP_INFO_EXT = 1000396004, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_OPACITY_MICROMAP_FEATURES_EXT = 1000396005, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_OPACITY_MICROMAP_PROPERTIES_EXT = 1000396006, + VK_STRUCTURE_TYPE_MICROMAP_CREATE_INFO_EXT = 1000396007, + VK_STRUCTURE_TYPE_MICROMAP_BUILD_SIZES_INFO_EXT = 1000396008, + VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_TRIANGLES_OPACITY_MICROMAP_EXT = 1000396009, +#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DISPLACEMENT_MICROMAP_FEATURES_NV = 1000397000, +#endif +#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DISPLACEMENT_MICROMAP_PROPERTIES_NV = 1000397001, +#endif +#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_TRIANGLES_DISPLACEMENT_MICROMAP_NV = 1000397002, +#endif + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CLUSTER_CULLING_SHADER_FEATURES_HUAWEI = 1000404000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CLUSTER_CULLING_SHADER_PROPERTIES_HUAWEI = 1000404001, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BORDER_COLOR_SWIZZLE_FEATURES_EXT = 1000411000, VK_STRUCTURE_TYPE_SAMPLER_BORDER_COLOR_COMPONENT_MAPPING_CREATE_INFO_EXT = 1000411001, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PAGEABLE_DEVICE_LOCAL_MEMORY_FEATURES_EXT = 1000412000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_CORE_PROPERTIES_ARM = 1000415000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_SLICED_VIEW_OF_3D_FEATURES_EXT = 1000418000, + VK_STRUCTURE_TYPE_IMAGE_VIEW_SLICED_CREATE_INFO_EXT = 1000418001, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_SET_HOST_MAPPING_FEATURES_VALVE = 1000420000, VK_STRUCTURE_TYPE_DESCRIPTOR_SET_BINDING_REFERENCE_VALVE = 1000420001, VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_HOST_MAPPING_INFO_VALVE = 1000420002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_CLAMP_ZERO_ONE_FEATURES_EXT = 1000421000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_NON_SEAMLESS_CUBE_MAP_FEATURES_EXT = 1000422000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_OFFSET_FEATURES_QCOM = 1000425000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_OFFSET_PROPERTIES_QCOM = 1000425001, VK_STRUCTURE_TYPE_SUBPASS_FRAGMENT_DENSITY_MAP_OFFSET_END_INFO_QCOM = 1000425002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COPY_MEMORY_INDIRECT_FEATURES_NV = 1000426000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COPY_MEMORY_INDIRECT_PROPERTIES_NV = 1000426001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_DECOMPRESSION_FEATURES_NV = 1000427000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_DECOMPRESSION_PROPERTIES_NV = 1000427001, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LINEAR_COLOR_ATTACHMENT_FEATURES_NV = 1000430000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_COMPRESSION_CONTROL_SWAPCHAIN_FEATURES_EXT = 1000437000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_PROCESSING_FEATURES_QCOM = 1000440000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_PROCESSING_PROPERTIES_QCOM = 1000440001, + VK_STRUCTURE_TYPE_IMAGE_VIEW_SAMPLE_WEIGHT_CREATE_INFO_QCOM = 1000440002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_3_FEATURES_EXT = 1000455000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_3_PROPERTIES_EXT = 1000455001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBPASS_MERGE_FEEDBACK_FEATURES_EXT = 1000458000, + VK_STRUCTURE_TYPE_RENDER_PASS_CREATION_CONTROL_EXT = 1000458001, + VK_STRUCTURE_TYPE_RENDER_PASS_CREATION_FEEDBACK_CREATE_INFO_EXT = 1000458002, + VK_STRUCTURE_TYPE_RENDER_PASS_SUBPASS_FEEDBACK_CREATE_INFO_EXT = 1000458003, + VK_STRUCTURE_TYPE_DIRECT_DRIVER_LOADING_INFO_LUNARG = 1000459000, + VK_STRUCTURE_TYPE_DIRECT_DRIVER_LOADING_LIST_LUNARG = 1000459001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_MODULE_IDENTIFIER_FEATURES_EXT = 1000462000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_MODULE_IDENTIFIER_PROPERTIES_EXT = 1000462001, + VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_MODULE_IDENTIFIER_CREATE_INFO_EXT = 1000462002, + VK_STRUCTURE_TYPE_SHADER_MODULE_IDENTIFIER_EXT = 1000462003, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_FEATURES_EXT = 1000342000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_OPTICAL_FLOW_FEATURES_NV = 1000464000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_OPTICAL_FLOW_PROPERTIES_NV = 1000464001, + VK_STRUCTURE_TYPE_OPTICAL_FLOW_IMAGE_FORMAT_INFO_NV = 1000464002, + VK_STRUCTURE_TYPE_OPTICAL_FLOW_IMAGE_FORMAT_PROPERTIES_NV = 1000464003, + VK_STRUCTURE_TYPE_OPTICAL_FLOW_SESSION_CREATE_INFO_NV = 1000464004, + VK_STRUCTURE_TYPE_OPTICAL_FLOW_EXECUTE_INFO_NV = 1000464005, + VK_STRUCTURE_TYPE_OPTICAL_FLOW_SESSION_CREATE_PRIVATE_DATA_INFO_NV = 1000464010, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LEGACY_DITHERING_FEATURES_EXT = 1000465000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_PROTECTED_ACCESS_FEATURES_EXT = 1000466000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_POSITION_FETCH_FEATURES_KHR = 1000481000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_OBJECT_FEATURES_EXT = 1000482000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_OBJECT_PROPERTIES_EXT = 1000482001, + VK_STRUCTURE_TYPE_SHADER_CREATE_INFO_EXT = 1000482002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TILE_PROPERTIES_FEATURES_QCOM = 1000484000, + VK_STRUCTURE_TYPE_TILE_PROPERTIES_QCOM = 1000484001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_AMIGO_PROFILING_FEATURES_SEC = 1000485000, + VK_STRUCTURE_TYPE_AMIGO_PROFILING_SUBMIT_INFO_SEC = 1000485001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PER_VIEW_VIEWPORTS_FEATURES_QCOM = 1000488000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_INVOCATION_REORDER_FEATURES_NV = 1000490000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_INVOCATION_REORDER_PROPERTIES_NV = 1000490001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MUTABLE_DESCRIPTOR_TYPE_FEATURES_EXT = 1000351000, + VK_STRUCTURE_TYPE_MUTABLE_DESCRIPTOR_TYPE_CREATE_INFO_EXT = 1000351002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_CORE_BUILTINS_FEATURES_ARM = 1000497000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_CORE_BUILTINS_PROPERTIES_ARM = 1000497001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_LIBRARY_GROUP_HANDLES_FEATURES_EXT = 1000498000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PER_VIEW_RENDER_AREAS_FEATURES_QCOM = 1000510000, + VK_STRUCTURE_TYPE_MULTIVIEW_PER_VIEW_RENDER_AREAS_RENDER_PASS_BEGIN_INFO_QCOM = 1000510001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ATTACHMENT_FEEDBACK_LOOP_DYNAMIC_STATE_FEATURES_EXT = 1000524000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTER_FEATURES = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETER_FEATURES = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES, VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT, @@ -1047,6 +1126,7 @@ typedef enum VkStructureType { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FLOAT_CONTROLS_PROPERTIES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FLOAT_CONTROLS_PROPERTIES, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_STENCIL_RESOLVE_PROPERTIES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_STENCIL_RESOLVE_PROPERTIES, VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_DEPTH_STENCIL_RESOLVE_KHR = VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_DEPTH_STENCIL_RESOLVE, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADER_BARYCENTRIC_FEATURES_NV = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADER_BARYCENTRIC_FEATURES_KHR, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_PROPERTIES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_PROPERTIES, VK_STRUCTURE_TYPE_SEMAPHORE_TYPE_CREATE_INFO_KHR = VK_STRUCTURE_TYPE_SEMAPHORE_TYPE_CREATE_INFO, @@ -1103,16 +1183,26 @@ typedef enum VkStructureType { VK_STRUCTURE_TYPE_IMAGE_BLIT_2_KHR = VK_STRUCTURE_TYPE_IMAGE_BLIT_2, VK_STRUCTURE_TYPE_BUFFER_IMAGE_COPY_2_KHR = VK_STRUCTURE_TYPE_BUFFER_IMAGE_COPY_2, VK_STRUCTURE_TYPE_IMAGE_RESOLVE_2_KHR = VK_STRUCTURE_TYPE_IMAGE_RESOLVE_2, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_FEATURES_ARM = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_FEATURES_EXT, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MUTABLE_DESCRIPTOR_TYPE_FEATURES_VALVE = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MUTABLE_DESCRIPTOR_TYPE_FEATURES_EXT, + VK_STRUCTURE_TYPE_MUTABLE_DESCRIPTOR_TYPE_CREATE_INFO_VALVE = VK_STRUCTURE_TYPE_MUTABLE_DESCRIPTOR_TYPE_CREATE_INFO_EXT, VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_3_KHR = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_3, + VK_STRUCTURE_TYPE_PIPELINE_INFO_EXT = VK_STRUCTURE_TYPE_PIPELINE_INFO_KHR, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GLOBAL_PRIORITY_QUERY_FEATURES_EXT = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GLOBAL_PRIORITY_QUERY_FEATURES_KHR, VK_STRUCTURE_TYPE_QUEUE_FAMILY_GLOBAL_PRIORITY_PROPERTIES_EXT = VK_STRUCTURE_TYPE_QUEUE_FAMILY_GLOBAL_PRIORITY_PROPERTIES_KHR, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_4_FEATURES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_4_FEATURES, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_4_PROPERTIES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_4_PROPERTIES, VK_STRUCTURE_TYPE_DEVICE_BUFFER_MEMORY_REQUIREMENTS_KHR = VK_STRUCTURE_TYPE_DEVICE_BUFFER_MEMORY_REQUIREMENTS, VK_STRUCTURE_TYPE_DEVICE_IMAGE_MEMORY_REQUIREMENTS_KHR = VK_STRUCTURE_TYPE_DEVICE_IMAGE_MEMORY_REQUIREMENTS, + VK_STRUCTURE_TYPE_SHADER_REQUIRED_SUBGROUP_SIZE_CREATE_INFO_EXT = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_REQUIRED_SUBGROUP_SIZE_CREATE_INFO, VK_STRUCTURE_TYPE_MAX_ENUM = 0x7FFFFFFF } VkStructureType; +typedef enum VkPipelineCacheHeaderVersion { + VK_PIPELINE_CACHE_HEADER_VERSION_ONE = 1, + VK_PIPELINE_CACHE_HEADER_VERSION_MAX_ENUM = 0x7FFFFFFF +} VkPipelineCacheHeaderVersion; + typedef enum VkImageLayout { VK_IMAGE_LAYOUT_UNDEFINED = 0, VK_IMAGE_LAYOUT_GENERAL = 1, @@ -1132,15 +1222,9 @@ typedef enum VkImageLayout { VK_IMAGE_LAYOUT_READ_ONLY_OPTIMAL = 1000314000, VK_IMAGE_LAYOUT_ATTACHMENT_OPTIMAL = 1000314001, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR = 1000001002, -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_IMAGE_LAYOUT_VIDEO_DECODE_DST_KHR = 1000024000, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_IMAGE_LAYOUT_VIDEO_DECODE_SRC_KHR = 1000024001, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_IMAGE_LAYOUT_VIDEO_DECODE_DPB_KHR = 1000024002, -#endif VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR = 1000111000, VK_IMAGE_LAYOUT_FRAGMENT_DENSITY_MAP_OPTIMAL_EXT = 1000218000, VK_IMAGE_LAYOUT_FRAGMENT_SHADING_RATE_ATTACHMENT_OPTIMAL_KHR = 1000164003, @@ -1153,6 +1237,7 @@ typedef enum VkImageLayout { #ifdef VK_ENABLE_BETA_EXTENSIONS VK_IMAGE_LAYOUT_VIDEO_ENCODE_DPB_KHR = 1000299002, #endif + VK_IMAGE_LAYOUT_ATTACHMENT_FEEDBACK_LOOP_OPTIMAL_EXT = 1000339000, VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR = VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL, VK_IMAGE_LAYOUT_SHADING_RATE_OPTIMAL_NV = VK_IMAGE_LAYOUT_FRAGMENT_SHADING_RATE_ATTACHMENT_OPTIMAL_KHR, @@ -1200,12 +1285,8 @@ typedef enum VkObjectType { VK_OBJECT_TYPE_DISPLAY_KHR = 1000002000, VK_OBJECT_TYPE_DISPLAY_MODE_KHR = 1000002001, VK_OBJECT_TYPE_DEBUG_REPORT_CALLBACK_EXT = 1000011000, -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_OBJECT_TYPE_VIDEO_SESSION_KHR = 1000023000, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_OBJECT_TYPE_VIDEO_SESSION_PARAMETERS_KHR = 1000023001, -#endif VK_OBJECT_TYPE_CU_MODULE_NVX = 1000029000, VK_OBJECT_TYPE_CU_FUNCTION_NVX = 1000029001, VK_OBJECT_TYPE_DEBUG_UTILS_MESSENGER_EXT = 1000128000, @@ -1216,17 +1297,15 @@ typedef enum VkObjectType { VK_OBJECT_TYPE_DEFERRED_OPERATION_KHR = 1000268000, VK_OBJECT_TYPE_INDIRECT_COMMANDS_LAYOUT_NV = 1000277000, VK_OBJECT_TYPE_BUFFER_COLLECTION_FUCHSIA = 1000366000, + VK_OBJECT_TYPE_MICROMAP_EXT = 1000396000, + VK_OBJECT_TYPE_OPTICAL_FLOW_SESSION_NV = 1000464000, + VK_OBJECT_TYPE_SHADER_EXT = 1000482000, VK_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_KHR = VK_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE, VK_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION_KHR = VK_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION, VK_OBJECT_TYPE_PRIVATE_DATA_SLOT_EXT = VK_OBJECT_TYPE_PRIVATE_DATA_SLOT, VK_OBJECT_TYPE_MAX_ENUM = 0x7FFFFFFF } VkObjectType; -typedef enum VkPipelineCacheHeaderVersion { - VK_PIPELINE_CACHE_HEADER_VERSION_ONE = 1, - VK_PIPELINE_CACHE_HEADER_VERSION_MAX_ENUM = 0x7FFFFFFF -} VkPipelineCacheHeaderVersion; - typedef enum VkVendorId { VK_VENDOR_ID_VIV = 0x10001, VK_VENDOR_ID_VSI = 0x10002, @@ -1234,6 +1313,7 @@ typedef enum VkVendorId { VK_VENDOR_ID_CODEPLAY = 0x10004, VK_VENDOR_ID_MESA = 0x10005, VK_VENDOR_ID_POCL = 0x10006, + VK_VENDOR_ID_MOBILEYE = 0x10007, VK_VENDOR_ID_MAX_ENUM = 0x7FFFFFFF } VkVendorId; @@ -1499,6 +1579,7 @@ typedef enum VkFormat { VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG = 1000054005, VK_FORMAT_PVRTC2_2BPP_SRGB_BLOCK_IMG = 1000054006, VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG = 1000054007, + VK_FORMAT_R16G16_S10_5_NV = 1000464000, VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK_EXT = VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK, VK_FORMAT_ASTC_5x4_SFLOAT_BLOCK_EXT = VK_FORMAT_ASTC_5x4_SFLOAT_BLOCK, VK_FORMAT_ASTC_5x5_SFLOAT_BLOCK_EXT = VK_FORMAT_ASTC_5x5_SFLOAT_BLOCK, @@ -1583,9 +1664,7 @@ typedef enum VkQueryType { VK_QUERY_TYPE_OCCLUSION = 0, VK_QUERY_TYPE_PIPELINE_STATISTICS = 1, VK_QUERY_TYPE_TIMESTAMP = 2, -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_QUERY_TYPE_RESULT_STATUS_ONLY_KHR = 1000023000, -#endif VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT = 1000028004, VK_QUERY_TYPE_PERFORMANCE_QUERY_KHR = 1000116000, VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR = 1000150000, @@ -1593,9 +1672,14 @@ typedef enum VkQueryType { VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV = 1000165000, VK_QUERY_TYPE_PERFORMANCE_QUERY_INTEL = 1000210000, #ifdef VK_ENABLE_BETA_EXTENSIONS - VK_QUERY_TYPE_VIDEO_ENCODE_BITSTREAM_BUFFER_RANGE_KHR = 1000299000, + VK_QUERY_TYPE_VIDEO_ENCODE_FEEDBACK_KHR = 1000299000, #endif + VK_QUERY_TYPE_MESH_PRIMITIVES_GENERATED_EXT = 1000328000, VK_QUERY_TYPE_PRIMITIVES_GENERATED_EXT = 1000382000, + VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR = 1000386000, + VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR = 1000386001, + VK_QUERY_TYPE_MICROMAP_SERIALIZATION_SIZE_EXT = 1000396000, + VK_QUERY_TYPE_MICROMAP_COMPACTED_SIZE_EXT = 1000396001, VK_QUERY_TYPE_MAX_ENUM = 0x7FFFFFFF } VkQueryType; @@ -1744,10 +1828,13 @@ typedef enum VkDynamicState { VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE = 1000377004, VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV = 1000087000, VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT = 1000099000, + VK_DYNAMIC_STATE_DISCARD_RECTANGLE_ENABLE_EXT = 1000099001, + VK_DYNAMIC_STATE_DISCARD_RECTANGLE_MODE_EXT = 1000099002, VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT = 1000143000, VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR = 1000347000, VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV = 1000164004, VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV = 1000164006, + VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_ENABLE_NV = 1000205000, VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV = 1000205001, VK_DYNAMIC_STATE_FRAGMENT_SHADING_RATE_KHR = 1000226000, VK_DYNAMIC_STATE_LINE_STIPPLE_EXT = 1000259000, @@ -1755,6 +1842,38 @@ typedef enum VkDynamicState { VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT = 1000377000, VK_DYNAMIC_STATE_LOGIC_OP_EXT = 1000377003, VK_DYNAMIC_STATE_COLOR_WRITE_ENABLE_EXT = 1000381000, + VK_DYNAMIC_STATE_TESSELLATION_DOMAIN_ORIGIN_EXT = 1000455002, + VK_DYNAMIC_STATE_DEPTH_CLAMP_ENABLE_EXT = 1000455003, + VK_DYNAMIC_STATE_POLYGON_MODE_EXT = 1000455004, + VK_DYNAMIC_STATE_RASTERIZATION_SAMPLES_EXT = 1000455005, + VK_DYNAMIC_STATE_SAMPLE_MASK_EXT = 1000455006, + VK_DYNAMIC_STATE_ALPHA_TO_COVERAGE_ENABLE_EXT = 1000455007, + VK_DYNAMIC_STATE_ALPHA_TO_ONE_ENABLE_EXT = 1000455008, + VK_DYNAMIC_STATE_LOGIC_OP_ENABLE_EXT = 1000455009, + VK_DYNAMIC_STATE_COLOR_BLEND_ENABLE_EXT = 1000455010, + VK_DYNAMIC_STATE_COLOR_BLEND_EQUATION_EXT = 1000455011, + VK_DYNAMIC_STATE_COLOR_WRITE_MASK_EXT = 1000455012, + VK_DYNAMIC_STATE_RASTERIZATION_STREAM_EXT = 1000455013, + VK_DYNAMIC_STATE_CONSERVATIVE_RASTERIZATION_MODE_EXT = 1000455014, + VK_DYNAMIC_STATE_EXTRA_PRIMITIVE_OVERESTIMATION_SIZE_EXT = 1000455015, + VK_DYNAMIC_STATE_DEPTH_CLIP_ENABLE_EXT = 1000455016, + VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_ENABLE_EXT = 1000455017, + VK_DYNAMIC_STATE_COLOR_BLEND_ADVANCED_EXT = 1000455018, + VK_DYNAMIC_STATE_PROVOKING_VERTEX_MODE_EXT = 1000455019, + VK_DYNAMIC_STATE_LINE_RASTERIZATION_MODE_EXT = 1000455020, + VK_DYNAMIC_STATE_LINE_STIPPLE_ENABLE_EXT = 1000455021, + VK_DYNAMIC_STATE_DEPTH_CLIP_NEGATIVE_ONE_TO_ONE_EXT = 1000455022, + VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_ENABLE_NV = 1000455023, + VK_DYNAMIC_STATE_VIEWPORT_SWIZZLE_NV = 1000455024, + VK_DYNAMIC_STATE_COVERAGE_TO_COLOR_ENABLE_NV = 1000455025, + VK_DYNAMIC_STATE_COVERAGE_TO_COLOR_LOCATION_NV = 1000455026, + VK_DYNAMIC_STATE_COVERAGE_MODULATION_MODE_NV = 1000455027, + VK_DYNAMIC_STATE_COVERAGE_MODULATION_TABLE_ENABLE_NV = 1000455028, + VK_DYNAMIC_STATE_COVERAGE_MODULATION_TABLE_NV = 1000455029, + VK_DYNAMIC_STATE_SHADING_RATE_IMAGE_ENABLE_NV = 1000455030, + VK_DYNAMIC_STATE_REPRESENTATIVE_FRAGMENT_TEST_ENABLE_NV = 1000455031, + VK_DYNAMIC_STATE_COVERAGE_REDUCTION_MODE_NV = 1000455032, + VK_DYNAMIC_STATE_ATTACHMENT_FEEDBACK_LOOP_ENABLE_EXT = 1000524000, VK_DYNAMIC_STATE_CULL_MODE_EXT = VK_DYNAMIC_STATE_CULL_MODE, VK_DYNAMIC_STATE_FRONT_FACE_EXT = VK_DYNAMIC_STATE_FRONT_FACE, VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT = VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY, @@ -1855,8 +1974,8 @@ typedef enum VkBorderColor { typedef enum VkFilter { VK_FILTER_NEAREST = 0, VK_FILTER_LINEAR = 1, - VK_FILTER_CUBIC_IMG = 1000015000, - VK_FILTER_CUBIC_EXT = VK_FILTER_CUBIC_IMG, + VK_FILTER_CUBIC_EXT = 1000015000, + VK_FILTER_CUBIC_IMG = VK_FILTER_CUBIC_EXT, VK_FILTER_MAX_ENUM = 0x7FFFFFFF } VkFilter; @@ -1891,8 +2010,11 @@ typedef enum VkDescriptorType { VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK = 1000138000, VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR = 1000150000, VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV = 1000165000, - VK_DESCRIPTOR_TYPE_MUTABLE_VALVE = 1000351000, + VK_DESCRIPTOR_TYPE_SAMPLE_WEIGHT_IMAGE_QCOM = 1000440000, + VK_DESCRIPTOR_TYPE_BLOCK_MATCH_IMAGE_QCOM = 1000440001, + VK_DESCRIPTOR_TYPE_MUTABLE_EXT = 1000351000, VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT = VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK, + VK_DESCRIPTOR_TYPE_MUTABLE_VALVE = VK_DESCRIPTOR_TYPE_MUTABLE_EXT, VK_DESCRIPTOR_TYPE_MAX_ENUM = 0x7FFFFFFF } VkDescriptorType; @@ -2027,14 +2149,10 @@ typedef enum VkFormatFeatureFlagBits { VK_FORMAT_FEATURE_DISJOINT_BIT = 0x00400000, VK_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT = 0x00800000, VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_MINMAX_BIT = 0x00010000, - VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_IMG = 0x00002000, -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_FORMAT_FEATURE_VIDEO_DECODE_OUTPUT_BIT_KHR = 0x02000000, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_FORMAT_FEATURE_VIDEO_DECODE_DPB_BIT_KHR = 0x04000000, -#endif VK_FORMAT_FEATURE_ACCELERATION_STRUCTURE_VERTEX_BUFFER_BIT_KHR = 0x20000000, + VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_EXT = 0x00002000, VK_FORMAT_FEATURE_FRAGMENT_DENSITY_MAP_BIT_EXT = 0x01000000, VK_FORMAT_FEATURE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR = 0x40000000, #ifdef VK_ENABLE_BETA_EXTENSIONS @@ -2043,6 +2161,7 @@ typedef enum VkFormatFeatureFlagBits { #ifdef VK_ENABLE_BETA_EXTENSIONS VK_FORMAT_FEATURE_VIDEO_ENCODE_DPB_BIT_KHR = 0x10000000, #endif + VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_IMG = VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_EXT, VK_FORMAT_FEATURE_TRANSFER_SRC_BIT_KHR = VK_FORMAT_FEATURE_TRANSFER_SRC_BIT, VK_FORMAT_FEATURE_TRANSFER_DST_BIT_KHR = VK_FORMAT_FEATURE_TRANSFER_DST_BIT, VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_MINMAX_BIT_EXT = VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_MINMAX_BIT, @@ -2053,7 +2172,6 @@ typedef enum VkFormatFeatureFlagBits { VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_FORCEABLE_BIT_KHR = VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_FORCEABLE_BIT, VK_FORMAT_FEATURE_DISJOINT_BIT_KHR = VK_FORMAT_FEATURE_DISJOINT_BIT, VK_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT_KHR = VK_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT, - VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_EXT = VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_IMG, VK_FORMAT_FEATURE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF } VkFormatFeatureFlagBits; typedef VkFlags VkFormatFeatureFlags; @@ -2074,6 +2192,8 @@ typedef enum VkImageCreateFlagBits { VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV = 0x00002000, VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT = 0x00001000, VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT = 0x00004000, + VK_IMAGE_CREATE_DESCRIPTOR_BUFFER_CAPTURE_REPLAY_BIT_EXT = 0x00010000, + VK_IMAGE_CREATE_MULTISAMPLED_RENDER_TO_SINGLE_SAMPLED_BIT_EXT = 0x00040000, VK_IMAGE_CREATE_2D_VIEW_COMPATIBLE_BIT_EXT = 0x00020000, VK_IMAGE_CREATE_FRAGMENT_DENSITY_MAP_OFFSET_BIT_QCOM = 0x00008000, VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT_KHR = VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT, @@ -2107,15 +2227,9 @@ typedef enum VkImageUsageFlagBits { VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT = 0x00000020, VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT = 0x00000040, VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT = 0x00000080, -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR = 0x00000400, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_IMAGE_USAGE_VIDEO_DECODE_SRC_BIT_KHR = 0x00000800, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR = 0x00001000, -#endif VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT = 0x00000200, VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR = 0x00000100, #ifdef VK_ENABLE_BETA_EXTENSIONS @@ -2127,7 +2241,10 @@ typedef enum VkImageUsageFlagBits { #ifdef VK_ENABLE_BETA_EXTENSIONS VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR = 0x00008000, #endif + VK_IMAGE_USAGE_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT = 0x00080000, VK_IMAGE_USAGE_INVOCATION_MASK_BIT_HUAWEI = 0x00040000, + VK_IMAGE_USAGE_SAMPLE_WEIGHT_BIT_QCOM = 0x00100000, + VK_IMAGE_USAGE_SAMPLE_BLOCK_MATCH_BIT_QCOM = 0x00200000, VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV = VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR, VK_IMAGE_USAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF } VkImageUsageFlagBits; @@ -2167,12 +2284,11 @@ typedef enum VkQueueFlagBits { VK_QUEUE_TRANSFER_BIT = 0x00000004, VK_QUEUE_SPARSE_BINDING_BIT = 0x00000008, VK_QUEUE_PROTECTED_BIT = 0x00000010, -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_QUEUE_VIDEO_DECODE_BIT_KHR = 0x00000020, -#endif #ifdef VK_ENABLE_BETA_EXTENSIONS VK_QUEUE_VIDEO_ENCODE_BIT_KHR = 0x00000040, #endif + VK_QUEUE_OPTICAL_FLOW_BIT_NV = 0x00000100, VK_QUEUE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF } VkQueueFlagBits; typedef VkFlags VkQueueFlags; @@ -2207,14 +2323,16 @@ typedef enum VkPipelineStageFlagBits { VK_PIPELINE_STAGE_CONDITIONAL_RENDERING_BIT_EXT = 0x00040000, VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_KHR = 0x02000000, VK_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR = 0x00200000, - VK_PIPELINE_STAGE_TASK_SHADER_BIT_NV = 0x00080000, - VK_PIPELINE_STAGE_MESH_SHADER_BIT_NV = 0x00100000, VK_PIPELINE_STAGE_FRAGMENT_DENSITY_PROCESS_BIT_EXT = 0x00800000, VK_PIPELINE_STAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR = 0x00400000, VK_PIPELINE_STAGE_COMMAND_PREPROCESS_BIT_NV = 0x00020000, + VK_PIPELINE_STAGE_TASK_SHADER_BIT_EXT = 0x00080000, + VK_PIPELINE_STAGE_MESH_SHADER_BIT_EXT = 0x00100000, VK_PIPELINE_STAGE_SHADING_RATE_IMAGE_BIT_NV = VK_PIPELINE_STAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR, VK_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_NV = VK_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR, VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_NV = VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_KHR, + VK_PIPELINE_STAGE_TASK_SHADER_BIT_NV = VK_PIPELINE_STAGE_TASK_SHADER_BIT_EXT, + VK_PIPELINE_STAGE_MESH_SHADER_BIT_NV = VK_PIPELINE_STAGE_MESH_SHADER_BIT_EXT, VK_PIPELINE_STAGE_NONE_KHR = VK_PIPELINE_STAGE_NONE, VK_PIPELINE_STAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF } VkPipelineStageFlagBits; @@ -2261,6 +2379,9 @@ typedef enum VkQueryPipelineStatisticFlagBits { VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_CONTROL_SHADER_PATCHES_BIT = 0x00000100, VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_EVALUATION_SHADER_INVOCATIONS_BIT = 0x00000200, VK_QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT = 0x00000400, + VK_QUERY_PIPELINE_STATISTIC_TASK_SHADER_INVOCATIONS_BIT_EXT = 0x00000800, + VK_QUERY_PIPELINE_STATISTIC_MESH_SHADER_INVOCATIONS_BIT_EXT = 0x00001000, + VK_QUERY_PIPELINE_STATISTIC_CLUSTER_CULLING_SHADER_INVOCATIONS_BIT_HUAWEI = 0x00002000, VK_QUERY_PIPELINE_STATISTIC_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF } VkQueryPipelineStatisticFlagBits; typedef VkFlags VkQueryPipelineStatisticFlags; @@ -2271,9 +2392,7 @@ typedef enum VkQueryResultFlagBits { VK_QUERY_RESULT_WAIT_BIT = 0x00000002, VK_QUERY_RESULT_WITH_AVAILABILITY_BIT = 0x00000004, VK_QUERY_RESULT_PARTIAL_BIT = 0x00000008, -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_QUERY_RESULT_WITH_STATUS_BIT_KHR = 0x00000010, -#endif VK_QUERY_RESULT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF } VkQueryResultFlagBits; typedef VkFlags VkQueryResultFlags; @@ -2284,6 +2403,7 @@ typedef enum VkBufferCreateFlagBits { VK_BUFFER_CREATE_SPARSE_ALIASED_BIT = 0x00000004, VK_BUFFER_CREATE_PROTECTED_BIT = 0x00000008, VK_BUFFER_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT = 0x00000010, + VK_BUFFER_CREATE_DESCRIPTOR_BUFFER_CAPTURE_REPLAY_BIT_EXT = 0x00000020, VK_BUFFER_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_EXT = VK_BUFFER_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT, VK_BUFFER_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR = VK_BUFFER_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT, VK_BUFFER_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF @@ -2301,12 +2421,8 @@ typedef enum VkBufferUsageFlagBits { VK_BUFFER_USAGE_VERTEX_BUFFER_BIT = 0x00000080, VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT = 0x00000100, VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT = 0x00020000, -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_BUFFER_USAGE_VIDEO_DECODE_SRC_BIT_KHR = 0x00002000, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_BUFFER_USAGE_VIDEO_DECODE_DST_BIT_KHR = 0x00004000, -#endif VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_BUFFER_BIT_EXT = 0x00000800, VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_COUNTER_BUFFER_BIT_EXT = 0x00001000, VK_BUFFER_USAGE_CONDITIONAL_RENDERING_BIT_EXT = 0x00000200, @@ -2319,6 +2435,11 @@ typedef enum VkBufferUsageFlagBits { #ifdef VK_ENABLE_BETA_EXTENSIONS VK_BUFFER_USAGE_VIDEO_ENCODE_SRC_BIT_KHR = 0x00010000, #endif + VK_BUFFER_USAGE_SAMPLER_DESCRIPTOR_BUFFER_BIT_EXT = 0x00200000, + VK_BUFFER_USAGE_RESOURCE_DESCRIPTOR_BUFFER_BIT_EXT = 0x00400000, + VK_BUFFER_USAGE_PUSH_DESCRIPTORS_DESCRIPTOR_BUFFER_BIT_EXT = 0x04000000, + VK_BUFFER_USAGE_MICROMAP_BUILD_INPUT_READ_ONLY_BIT_EXT = 0x00800000, + VK_BUFFER_USAGE_MICROMAP_STORAGE_BIT_EXT = 0x01000000, VK_BUFFER_USAGE_RAY_TRACING_BIT_NV = VK_BUFFER_USAGE_SHADER_BINDING_TABLE_BIT_KHR, VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT_EXT = VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT, VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT_KHR = VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT, @@ -2329,6 +2450,7 @@ typedef VkFlags VkBufferViewCreateFlags; typedef enum VkImageViewCreateFlagBits { VK_IMAGE_VIEW_CREATE_FRAGMENT_DENSITY_MAP_DYNAMIC_BIT_EXT = 0x00000001, + VK_IMAGE_VIEW_CREATE_DESCRIPTOR_BUFFER_CAPTURE_REPLAY_BIT_EXT = 0x00000004, VK_IMAGE_VIEW_CREATE_FRAGMENT_DENSITY_MAP_DEFERRED_BIT_EXT = 0x00000002, VK_IMAGE_VIEW_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF } VkImageViewCreateFlagBits; @@ -2373,9 +2495,18 @@ typedef enum VkPipelineCreateFlagBits { VK_PIPELINE_CREATE_CAPTURE_INTERNAL_REPRESENTATIONS_BIT_KHR = 0x00000080, VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV = 0x00040000, VK_PIPELINE_CREATE_LIBRARY_BIT_KHR = 0x00000800, + VK_PIPELINE_CREATE_DESCRIPTOR_BUFFER_BIT_EXT = 0x20000000, VK_PIPELINE_CREATE_RETAIN_LINK_TIME_OPTIMIZATION_INFO_BIT_EXT = 0x00800000, VK_PIPELINE_CREATE_LINK_TIME_OPTIMIZATION_BIT_EXT = 0x00000400, VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV = 0x00100000, + VK_PIPELINE_CREATE_COLOR_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT = 0x02000000, + VK_PIPELINE_CREATE_DEPTH_STENCIL_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT = 0x04000000, + VK_PIPELINE_CREATE_RAY_TRACING_OPACITY_MICROMAP_BIT_EXT = 0x01000000, +#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_PIPELINE_CREATE_RAY_TRACING_DISPLACEMENT_MICROMAP_BIT_NV = 0x10000000, +#endif + VK_PIPELINE_CREATE_NO_PROTECTED_ACCESS_BIT_EXT = 0x08000000, + VK_PIPELINE_CREATE_PROTECTED_ACCESS_ONLY_BIT_EXT = 0x40000000, VK_PIPELINE_CREATE_DISPATCH_BASE = VK_PIPELINE_CREATE_DISPATCH_BASE_BIT, VK_PIPELINE_RASTERIZATION_STATE_CREATE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR = VK_PIPELINE_CREATE_RENDERING_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR, VK_PIPELINE_RASTERIZATION_STATE_CREATE_FRAGMENT_DENSITY_MAP_ATTACHMENT_BIT_EXT = VK_PIPELINE_CREATE_RENDERING_FRAGMENT_DENSITY_MAP_ATTACHMENT_BIT_EXT, @@ -2411,15 +2542,18 @@ typedef enum VkShaderStageFlagBits { VK_SHADER_STAGE_MISS_BIT_KHR = 0x00000800, VK_SHADER_STAGE_INTERSECTION_BIT_KHR = 0x00001000, VK_SHADER_STAGE_CALLABLE_BIT_KHR = 0x00002000, - VK_SHADER_STAGE_TASK_BIT_NV = 0x00000040, - VK_SHADER_STAGE_MESH_BIT_NV = 0x00000080, + VK_SHADER_STAGE_TASK_BIT_EXT = 0x00000040, + VK_SHADER_STAGE_MESH_BIT_EXT = 0x00000080, VK_SHADER_STAGE_SUBPASS_SHADING_BIT_HUAWEI = 0x00004000, + VK_SHADER_STAGE_CLUSTER_CULLING_BIT_HUAWEI = 0x00080000, VK_SHADER_STAGE_RAYGEN_BIT_NV = VK_SHADER_STAGE_RAYGEN_BIT_KHR, VK_SHADER_STAGE_ANY_HIT_BIT_NV = VK_SHADER_STAGE_ANY_HIT_BIT_KHR, VK_SHADER_STAGE_CLOSEST_HIT_BIT_NV = VK_SHADER_STAGE_CLOSEST_HIT_BIT_KHR, VK_SHADER_STAGE_MISS_BIT_NV = VK_SHADER_STAGE_MISS_BIT_KHR, VK_SHADER_STAGE_INTERSECTION_BIT_NV = VK_SHADER_STAGE_INTERSECTION_BIT_KHR, VK_SHADER_STAGE_CALLABLE_BIT_NV = VK_SHADER_STAGE_CALLABLE_BIT_KHR, + VK_SHADER_STAGE_TASK_BIT_NV = VK_SHADER_STAGE_TASK_BIT_EXT, + VK_SHADER_STAGE_MESH_BIT_NV = VK_SHADER_STAGE_MESH_BIT_EXT, VK_SHADER_STAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF } VkShaderStageFlagBits; @@ -2439,14 +2573,17 @@ typedef VkFlags VkPipelineRasterizationStateCreateFlags; typedef VkFlags VkPipelineMultisampleStateCreateFlags; typedef enum VkPipelineDepthStencilStateCreateFlagBits { - VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM = 0x00000001, - VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_ARM = 0x00000002, + VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_EXT = 0x00000001, + VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_EXT = 0x00000002, + VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM = VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_EXT, + VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_ARM = VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_EXT, VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF } VkPipelineDepthStencilStateCreateFlagBits; typedef VkFlags VkPipelineDepthStencilStateCreateFlags; typedef enum VkPipelineColorBlendStateCreateFlagBits { - VK_PIPELINE_COLOR_BLEND_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_BIT_ARM = 0x00000001, + VK_PIPELINE_COLOR_BLEND_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_BIT_EXT = 0x00000001, + VK_PIPELINE_COLOR_BLEND_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_BIT_ARM = VK_PIPELINE_COLOR_BLEND_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_BIT_EXT, VK_PIPELINE_COLOR_BLEND_STATE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF } VkPipelineColorBlendStateCreateFlagBits; typedef VkFlags VkPipelineColorBlendStateCreateFlags; @@ -2462,6 +2599,9 @@ typedef VkFlags VkShaderStageFlags; typedef enum VkSamplerCreateFlagBits { VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT = 0x00000001, VK_SAMPLER_CREATE_SUBSAMPLED_COARSE_RECONSTRUCTION_BIT_EXT = 0x00000002, + VK_SAMPLER_CREATE_DESCRIPTOR_BUFFER_CAPTURE_REPLAY_BIT_EXT = 0x00000008, + VK_SAMPLER_CREATE_NON_SEAMLESS_CUBE_MAP_BIT_EXT = 0x00000004, + VK_SAMPLER_CREATE_IMAGE_PROCESSING_BIT_QCOM = 0x00000010, VK_SAMPLER_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF } VkSamplerCreateFlagBits; typedef VkFlags VkSamplerCreateFlags; @@ -2469,8 +2609,9 @@ typedef VkFlags VkSamplerCreateFlags; typedef enum VkDescriptorPoolCreateFlagBits { VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT = 0x00000001, VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT = 0x00000002, - VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE = 0x00000004, + VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_EXT = 0x00000004, VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT_EXT = VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT, + VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE = VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_EXT, VK_DESCRIPTOR_POOL_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF } VkDescriptorPoolCreateFlagBits; typedef VkFlags VkDescriptorPoolCreateFlags; @@ -2479,8 +2620,11 @@ typedef VkFlags VkDescriptorPoolResetFlags; typedef enum VkDescriptorSetLayoutCreateFlagBits { VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT = 0x00000002, VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR = 0x00000001, - VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE = 0x00000004, + VK_DESCRIPTOR_SET_LAYOUT_CREATE_DESCRIPTOR_BUFFER_BIT_EXT = 0x00000010, + VK_DESCRIPTOR_SET_LAYOUT_CREATE_EMBEDDED_IMMUTABLE_SAMPLERS_BIT_EXT = 0x00000020, + VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_EXT = 0x00000004, VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT_EXT = VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT, + VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE = VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_EXT, VK_DESCRIPTOR_SET_LAYOUT_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF } VkDescriptorSetLayoutCreateFlagBits; typedef VkFlags VkDescriptorSetLayoutCreateFlags; @@ -2495,6 +2639,7 @@ typedef enum VkDependencyFlagBits { VK_DEPENDENCY_BY_REGION_BIT = 0x00000001, VK_DEPENDENCY_DEVICE_GROUP_BIT = 0x00000004, VK_DEPENDENCY_VIEW_LOCAL_BIT = 0x00000002, + VK_DEPENDENCY_FEEDBACK_LOOP_BIT_EXT = 0x00000008, VK_DEPENDENCY_VIEW_LOCAL_BIT_KHR = VK_DEPENDENCY_VIEW_LOCAL_BIT, VK_DEPENDENCY_DEVICE_GROUP_BIT_KHR = VK_DEPENDENCY_DEVICE_GROUP_BIT, VK_DEPENDENCY_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF @@ -2519,9 +2664,13 @@ typedef enum VkSubpassDescriptionFlagBits { VK_SUBPASS_DESCRIPTION_PER_VIEW_POSITION_X_ONLY_BIT_NVX = 0x00000002, VK_SUBPASS_DESCRIPTION_FRAGMENT_REGION_BIT_QCOM = 0x00000004, VK_SUBPASS_DESCRIPTION_SHADER_RESOLVE_BIT_QCOM = 0x00000008, - VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_COLOR_ACCESS_BIT_ARM = 0x00000010, - VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM = 0x00000020, - VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_ARM = 0x00000040, + VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_COLOR_ACCESS_BIT_EXT = 0x00000010, + VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_EXT = 0x00000020, + VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_EXT = 0x00000040, + VK_SUBPASS_DESCRIPTION_ENABLE_LEGACY_DITHERING_BIT_EXT = 0x00000080, + VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_COLOR_ACCESS_BIT_ARM = VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_COLOR_ACCESS_BIT_EXT, + VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM = VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_EXT, + VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_ARM = VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_EXT, VK_SUBPASS_DESCRIPTION_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF } VkSubpassDescriptionFlagBits; typedef VkFlags VkSubpassDescriptionFlags; @@ -5524,6 +5673,9 @@ typedef enum VkDriverId { VK_DRIVER_ID_MESA_PANVK = 20, VK_DRIVER_ID_SAMSUNG_PROPRIETARY = 21, VK_DRIVER_ID_MESA_VENUS = 22, + VK_DRIVER_ID_MESA_DOZEN = 23, + VK_DRIVER_ID_MESA_NVK = 24, + VK_DRIVER_ID_IMAGINATION_OPEN_SOURCE_MESA = 25, VK_DRIVER_ID_AMD_PROPRIETARY_KHR = VK_DRIVER_ID_AMD_PROPRIETARY, VK_DRIVER_ID_AMD_OPEN_SOURCE_KHR = VK_DRIVER_ID_AMD_OPEN_SOURCE, VK_DRIVER_ID_MESA_RADV_KHR = VK_DRIVER_ID_MESA_RADV, @@ -6336,9 +6488,7 @@ static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_VERTEX_ATTRIBUTE_INPUT static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_VERTEX_ATTRIBUTE_INPUT_BIT_KHR = 0x2000000000ULL; static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_PRE_RASTERIZATION_SHADERS_BIT = 0x4000000000ULL; static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_PRE_RASTERIZATION_SHADERS_BIT_KHR = 0x4000000000ULL; -#ifdef VK_ENABLE_BETA_EXTENSIONS static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR = 0x04000000ULL; -#endif #ifdef VK_ENABLE_BETA_EXTENSIONS static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_VIDEO_ENCODE_BIT_KHR = 0x08000000ULL; #endif @@ -6354,8 +6504,14 @@ static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_ACCELERATION_STRUCTURE static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_FRAGMENT_DENSITY_PROCESS_BIT_EXT = 0x00800000ULL; static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_TASK_SHADER_BIT_NV = 0x00080000ULL; static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_MESH_SHADER_BIT_NV = 0x00100000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_TASK_SHADER_BIT_EXT = 0x00080000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_MESH_SHADER_BIT_EXT = 0x00100000ULL; static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_SUBPASS_SHADING_BIT_HUAWEI = 0x8000000000ULL; static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_INVOCATION_MASK_BIT_HUAWEI = 0x10000000000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_ACCELERATION_STRUCTURE_COPY_BIT_KHR = 0x10000000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_MICROMAP_BUILD_BIT_EXT = 0x40000000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_CLUSTER_CULLING_SHADER_BIT_HUAWEI = 0x20000000000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_OPTICAL_FLOW_BIT_NV = 0x20000000ULL; typedef VkFlags64 VkAccessFlags2; @@ -6403,12 +6559,8 @@ static const VkAccessFlagBits2 VK_ACCESS_2_SHADER_STORAGE_READ_BIT = 0x200000000 static const VkAccessFlagBits2 VK_ACCESS_2_SHADER_STORAGE_READ_BIT_KHR = 0x200000000ULL; static const VkAccessFlagBits2 VK_ACCESS_2_SHADER_STORAGE_WRITE_BIT = 0x400000000ULL; static const VkAccessFlagBits2 VK_ACCESS_2_SHADER_STORAGE_WRITE_BIT_KHR = 0x400000000ULL; -#ifdef VK_ENABLE_BETA_EXTENSIONS static const VkAccessFlagBits2 VK_ACCESS_2_VIDEO_DECODE_READ_BIT_KHR = 0x800000000ULL; -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS static const VkAccessFlagBits2 VK_ACCESS_2_VIDEO_DECODE_WRITE_BIT_KHR = 0x1000000000ULL; -#endif #ifdef VK_ENABLE_BETA_EXTENSIONS static const VkAccessFlagBits2 VK_ACCESS_2_VIDEO_ENCODE_READ_BIT_KHR = 0x2000000000ULL; #endif @@ -6429,7 +6581,13 @@ static const VkAccessFlagBits2 VK_ACCESS_2_ACCELERATION_STRUCTURE_READ_BIT_NV = static const VkAccessFlagBits2 VK_ACCESS_2_ACCELERATION_STRUCTURE_WRITE_BIT_NV = 0x00400000ULL; static const VkAccessFlagBits2 VK_ACCESS_2_FRAGMENT_DENSITY_MAP_READ_BIT_EXT = 0x01000000ULL; static const VkAccessFlagBits2 VK_ACCESS_2_COLOR_ATTACHMENT_READ_NONCOHERENT_BIT_EXT = 0x00080000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_DESCRIPTOR_BUFFER_READ_BIT_EXT = 0x20000000000ULL; static const VkAccessFlagBits2 VK_ACCESS_2_INVOCATION_MASK_READ_BIT_HUAWEI = 0x8000000000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_SHADER_BINDING_TABLE_READ_BIT_KHR = 0x10000000000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_MICROMAP_READ_BIT_EXT = 0x100000000000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_MICROMAP_WRITE_BIT_EXT = 0x200000000000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_OPTICAL_FLOW_READ_BIT_NV = 0x40000000000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_OPTICAL_FLOW_WRITE_BIT_NV = 0x80000000000ULL; typedef enum VkSubmitFlagBits { @@ -6443,6 +6601,7 @@ typedef enum VkRenderingFlagBits { VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT = 0x00000001, VK_RENDERING_SUSPENDING_BIT = 0x00000002, VK_RENDERING_RESUMING_BIT = 0x00000004, + VK_RENDERING_ENABLE_LEGACY_DITHERING_BIT_EXT = 0x00000008, VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT_KHR = VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT, VK_RENDERING_SUSPENDING_BIT_KHR = VK_RENDERING_SUSPENDING_BIT, VK_RENDERING_RESUMING_BIT_KHR = VK_RENDERING_RESUMING_BIT, @@ -6507,12 +6666,8 @@ static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_STORAGE_WRITE_WITHOUT_ static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_STORAGE_WRITE_WITHOUT_FORMAT_BIT_KHR = 0x100000000ULL; static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_DEPTH_COMPARISON_BIT = 0x200000000ULL; static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_DEPTH_COMPARISON_BIT_KHR = 0x200000000ULL; -#ifdef VK_ENABLE_BETA_EXTENSIONS static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_VIDEO_DECODE_OUTPUT_BIT_KHR = 0x02000000ULL; -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_VIDEO_DECODE_DPB_BIT_KHR = 0x04000000ULL; -#endif static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_ACCELERATION_STRUCTURE_VERTEX_BUFFER_BIT_KHR = 0x20000000ULL; static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_FRAGMENT_DENSITY_MAP_BIT_EXT = 0x01000000ULL; static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR = 0x40000000ULL; @@ -6523,6 +6678,13 @@ static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_VIDEO_ENCODE_INPUT_BIT static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_VIDEO_ENCODE_DPB_BIT_KHR = 0x10000000ULL; #endif static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_LINEAR_COLOR_ATTACHMENT_BIT_NV = 0x4000000000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_WEIGHT_IMAGE_BIT_QCOM = 0x400000000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_WEIGHT_SAMPLED_IMAGE_BIT_QCOM = 0x800000000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_BLOCK_MATCHING_BIT_QCOM = 0x1000000000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_BOX_FILTER_SAMPLED_BIT_QCOM = 0x2000000000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_OPTICAL_FLOW_IMAGE_BIT_NV = 0x10000000000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_OPTICAL_FLOW_VECTOR_BIT_NV = 0x20000000000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_OPTICAL_FLOW_COST_BIT_NV = 0x40000000000ULL; typedef struct VkPhysicalDeviceVulkan13Features { VkStructureType sType; @@ -7399,6 +7561,7 @@ typedef enum VkSwapchainCreateFlagBitsKHR { VK_SWAPCHAIN_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT_KHR = 0x00000001, VK_SWAPCHAIN_CREATE_PROTECTED_BIT_KHR = 0x00000002, VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR = 0x00000004, + VK_SWAPCHAIN_CREATE_DEFERRED_MEMORY_ALLOCATION_BIT_EXT = 0x00000008, VK_SWAPCHAIN_CREATE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF } VkSwapchainCreateFlagBitsKHR; typedef VkFlags VkSwapchainCreateFlagsKHR; @@ -7702,6 +7865,412 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateSharedSwapchainsKHR( #define VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME "VK_KHR_sampler_mirror_clamp_to_edge" +#define VK_KHR_video_queue 1 +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkVideoSessionKHR) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkVideoSessionParametersKHR) +#define VK_KHR_VIDEO_QUEUE_SPEC_VERSION 8 +#define VK_KHR_VIDEO_QUEUE_EXTENSION_NAME "VK_KHR_video_queue" + +typedef enum VkQueryResultStatusKHR { + VK_QUERY_RESULT_STATUS_ERROR_KHR = -1, + VK_QUERY_RESULT_STATUS_NOT_READY_KHR = 0, + VK_QUERY_RESULT_STATUS_COMPLETE_KHR = 1, + VK_QUERY_RESULT_STATUS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkQueryResultStatusKHR; + +typedef enum VkVideoCodecOperationFlagBitsKHR { + VK_VIDEO_CODEC_OPERATION_NONE_KHR = 0, +#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_EXT = 0x00010000, +#endif +#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_VIDEO_CODEC_OPERATION_ENCODE_H265_BIT_EXT = 0x00020000, +#endif + VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR = 0x00000001, + VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR = 0x00000002, + VK_VIDEO_CODEC_OPERATION_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoCodecOperationFlagBitsKHR; +typedef VkFlags VkVideoCodecOperationFlagsKHR; + +typedef enum VkVideoChromaSubsamplingFlagBitsKHR { + VK_VIDEO_CHROMA_SUBSAMPLING_INVALID_KHR = 0, + VK_VIDEO_CHROMA_SUBSAMPLING_MONOCHROME_BIT_KHR = 0x00000001, + VK_VIDEO_CHROMA_SUBSAMPLING_420_BIT_KHR = 0x00000002, + VK_VIDEO_CHROMA_SUBSAMPLING_422_BIT_KHR = 0x00000004, + VK_VIDEO_CHROMA_SUBSAMPLING_444_BIT_KHR = 0x00000008, + VK_VIDEO_CHROMA_SUBSAMPLING_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoChromaSubsamplingFlagBitsKHR; +typedef VkFlags VkVideoChromaSubsamplingFlagsKHR; + +typedef enum VkVideoComponentBitDepthFlagBitsKHR { + VK_VIDEO_COMPONENT_BIT_DEPTH_INVALID_KHR = 0, + VK_VIDEO_COMPONENT_BIT_DEPTH_8_BIT_KHR = 0x00000001, + VK_VIDEO_COMPONENT_BIT_DEPTH_10_BIT_KHR = 0x00000004, + VK_VIDEO_COMPONENT_BIT_DEPTH_12_BIT_KHR = 0x00000010, + VK_VIDEO_COMPONENT_BIT_DEPTH_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoComponentBitDepthFlagBitsKHR; +typedef VkFlags VkVideoComponentBitDepthFlagsKHR; + +typedef enum VkVideoCapabilityFlagBitsKHR { + VK_VIDEO_CAPABILITY_PROTECTED_CONTENT_BIT_KHR = 0x00000001, + VK_VIDEO_CAPABILITY_SEPARATE_REFERENCE_IMAGES_BIT_KHR = 0x00000002, + VK_VIDEO_CAPABILITY_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoCapabilityFlagBitsKHR; +typedef VkFlags VkVideoCapabilityFlagsKHR; + +typedef enum VkVideoSessionCreateFlagBitsKHR { + VK_VIDEO_SESSION_CREATE_PROTECTED_CONTENT_BIT_KHR = 0x00000001, + VK_VIDEO_SESSION_CREATE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoSessionCreateFlagBitsKHR; +typedef VkFlags VkVideoSessionCreateFlagsKHR; +typedef VkFlags VkVideoSessionParametersCreateFlagsKHR; +typedef VkFlags VkVideoBeginCodingFlagsKHR; +typedef VkFlags VkVideoEndCodingFlagsKHR; + +typedef enum VkVideoCodingControlFlagBitsKHR { + VK_VIDEO_CODING_CONTROL_RESET_BIT_KHR = 0x00000001, +#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_VIDEO_CODING_CONTROL_ENCODE_RATE_CONTROL_BIT_KHR = 0x00000002, +#endif +#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_VIDEO_CODING_CONTROL_ENCODE_RATE_CONTROL_LAYER_BIT_KHR = 0x00000004, +#endif + VK_VIDEO_CODING_CONTROL_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoCodingControlFlagBitsKHR; +typedef VkFlags VkVideoCodingControlFlagsKHR; +typedef struct VkQueueFamilyQueryResultStatusPropertiesKHR { + VkStructureType sType; + void* pNext; + VkBool32 queryResultStatusSupport; +} VkQueueFamilyQueryResultStatusPropertiesKHR; + +typedef struct VkQueueFamilyVideoPropertiesKHR { + VkStructureType sType; + void* pNext; + VkVideoCodecOperationFlagsKHR videoCodecOperations; +} VkQueueFamilyVideoPropertiesKHR; + +typedef struct VkVideoProfileInfoKHR { + VkStructureType sType; + const void* pNext; + VkVideoCodecOperationFlagBitsKHR videoCodecOperation; + VkVideoChromaSubsamplingFlagsKHR chromaSubsampling; + VkVideoComponentBitDepthFlagsKHR lumaBitDepth; + VkVideoComponentBitDepthFlagsKHR chromaBitDepth; +} VkVideoProfileInfoKHR; + +typedef struct VkVideoProfileListInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t profileCount; + const VkVideoProfileInfoKHR* pProfiles; +} VkVideoProfileListInfoKHR; + +typedef struct VkVideoCapabilitiesKHR { + VkStructureType sType; + void* pNext; + VkVideoCapabilityFlagsKHR flags; + VkDeviceSize minBitstreamBufferOffsetAlignment; + VkDeviceSize minBitstreamBufferSizeAlignment; + VkExtent2D pictureAccessGranularity; + VkExtent2D minCodedExtent; + VkExtent2D maxCodedExtent; + uint32_t maxDpbSlots; + uint32_t maxActiveReferencePictures; + VkExtensionProperties stdHeaderVersion; +} VkVideoCapabilitiesKHR; + +typedef struct VkPhysicalDeviceVideoFormatInfoKHR { + VkStructureType sType; + const void* pNext; + VkImageUsageFlags imageUsage; +} VkPhysicalDeviceVideoFormatInfoKHR; + +typedef struct VkVideoFormatPropertiesKHR { + VkStructureType sType; + void* pNext; + VkFormat format; + VkComponentMapping componentMapping; + VkImageCreateFlags imageCreateFlags; + VkImageType imageType; + VkImageTiling imageTiling; + VkImageUsageFlags imageUsageFlags; +} VkVideoFormatPropertiesKHR; + +typedef struct VkVideoPictureResourceInfoKHR { + VkStructureType sType; + const void* pNext; + VkOffset2D codedOffset; + VkExtent2D codedExtent; + uint32_t baseArrayLayer; + VkImageView imageViewBinding; +} VkVideoPictureResourceInfoKHR; + +typedef struct VkVideoReferenceSlotInfoKHR { + VkStructureType sType; + const void* pNext; + int32_t slotIndex; + const VkVideoPictureResourceInfoKHR* pPictureResource; +} VkVideoReferenceSlotInfoKHR; + +typedef struct VkVideoSessionMemoryRequirementsKHR { + VkStructureType sType; + void* pNext; + uint32_t memoryBindIndex; + VkMemoryRequirements memoryRequirements; +} VkVideoSessionMemoryRequirementsKHR; + +typedef struct VkBindVideoSessionMemoryInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t memoryBindIndex; + VkDeviceMemory memory; + VkDeviceSize memoryOffset; + VkDeviceSize memorySize; +} VkBindVideoSessionMemoryInfoKHR; + +typedef struct VkVideoSessionCreateInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t queueFamilyIndex; + VkVideoSessionCreateFlagsKHR flags; + const VkVideoProfileInfoKHR* pVideoProfile; + VkFormat pictureFormat; + VkExtent2D maxCodedExtent; + VkFormat referencePictureFormat; + uint32_t maxDpbSlots; + uint32_t maxActiveReferencePictures; + const VkExtensionProperties* pStdHeaderVersion; +} VkVideoSessionCreateInfoKHR; + +typedef struct VkVideoSessionParametersCreateInfoKHR { + VkStructureType sType; + const void* pNext; + VkVideoSessionParametersCreateFlagsKHR flags; + VkVideoSessionParametersKHR videoSessionParametersTemplate; + VkVideoSessionKHR videoSession; +} VkVideoSessionParametersCreateInfoKHR; + +typedef struct VkVideoSessionParametersUpdateInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t updateSequenceCount; +} VkVideoSessionParametersUpdateInfoKHR; + +typedef struct VkVideoBeginCodingInfoKHR { + VkStructureType sType; + const void* pNext; + VkVideoBeginCodingFlagsKHR flags; + VkVideoSessionKHR videoSession; + VkVideoSessionParametersKHR videoSessionParameters; + uint32_t referenceSlotCount; + const VkVideoReferenceSlotInfoKHR* pReferenceSlots; +} VkVideoBeginCodingInfoKHR; + +typedef struct VkVideoEndCodingInfoKHR { + VkStructureType sType; + const void* pNext; + VkVideoEndCodingFlagsKHR flags; +} VkVideoEndCodingInfoKHR; + +typedef struct VkVideoCodingControlInfoKHR { + VkStructureType sType; + const void* pNext; + VkVideoCodingControlFlagsKHR flags; +} VkVideoCodingControlInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceVideoCapabilitiesKHR)(VkPhysicalDevice physicalDevice, const VkVideoProfileInfoKHR* pVideoProfile, VkVideoCapabilitiesKHR* pCapabilities); +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceVideoFormatPropertiesKHR)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceVideoFormatInfoKHR* pVideoFormatInfo, uint32_t* pVideoFormatPropertyCount, VkVideoFormatPropertiesKHR* pVideoFormatProperties); +typedef VkResult (VKAPI_PTR *PFN_vkCreateVideoSessionKHR)(VkDevice device, const VkVideoSessionCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkVideoSessionKHR* pVideoSession); +typedef void (VKAPI_PTR *PFN_vkDestroyVideoSessionKHR)(VkDevice device, VkVideoSessionKHR videoSession, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkGetVideoSessionMemoryRequirementsKHR)(VkDevice device, VkVideoSessionKHR videoSession, uint32_t* pMemoryRequirementsCount, VkVideoSessionMemoryRequirementsKHR* pMemoryRequirements); +typedef VkResult (VKAPI_PTR *PFN_vkBindVideoSessionMemoryKHR)(VkDevice device, VkVideoSessionKHR videoSession, uint32_t bindSessionMemoryInfoCount, const VkBindVideoSessionMemoryInfoKHR* pBindSessionMemoryInfos); +typedef VkResult (VKAPI_PTR *PFN_vkCreateVideoSessionParametersKHR)(VkDevice device, const VkVideoSessionParametersCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkVideoSessionParametersKHR* pVideoSessionParameters); +typedef VkResult (VKAPI_PTR *PFN_vkUpdateVideoSessionParametersKHR)(VkDevice device, VkVideoSessionParametersKHR videoSessionParameters, const VkVideoSessionParametersUpdateInfoKHR* pUpdateInfo); +typedef void (VKAPI_PTR *PFN_vkDestroyVideoSessionParametersKHR)(VkDevice device, VkVideoSessionParametersKHR videoSessionParameters, const VkAllocationCallbacks* pAllocator); +typedef void (VKAPI_PTR *PFN_vkCmdBeginVideoCodingKHR)(VkCommandBuffer commandBuffer, const VkVideoBeginCodingInfoKHR* pBeginInfo); +typedef void (VKAPI_PTR *PFN_vkCmdEndVideoCodingKHR)(VkCommandBuffer commandBuffer, const VkVideoEndCodingInfoKHR* pEndCodingInfo); +typedef void (VKAPI_PTR *PFN_vkCmdControlVideoCodingKHR)(VkCommandBuffer commandBuffer, const VkVideoCodingControlInfoKHR* pCodingControlInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceVideoCapabilitiesKHR( + VkPhysicalDevice physicalDevice, + const VkVideoProfileInfoKHR* pVideoProfile, + VkVideoCapabilitiesKHR* pCapabilities); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceVideoFormatPropertiesKHR( + VkPhysicalDevice physicalDevice, + const VkPhysicalDeviceVideoFormatInfoKHR* pVideoFormatInfo, + uint32_t* pVideoFormatPropertyCount, + VkVideoFormatPropertiesKHR* pVideoFormatProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateVideoSessionKHR( + VkDevice device, + const VkVideoSessionCreateInfoKHR* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkVideoSessionKHR* pVideoSession); + +VKAPI_ATTR void VKAPI_CALL vkDestroyVideoSessionKHR( + VkDevice device, + VkVideoSessionKHR videoSession, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetVideoSessionMemoryRequirementsKHR( + VkDevice device, + VkVideoSessionKHR videoSession, + uint32_t* pMemoryRequirementsCount, + VkVideoSessionMemoryRequirementsKHR* pMemoryRequirements); + +VKAPI_ATTR VkResult VKAPI_CALL vkBindVideoSessionMemoryKHR( + VkDevice device, + VkVideoSessionKHR videoSession, + uint32_t bindSessionMemoryInfoCount, + const VkBindVideoSessionMemoryInfoKHR* pBindSessionMemoryInfos); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateVideoSessionParametersKHR( + VkDevice device, + const VkVideoSessionParametersCreateInfoKHR* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkVideoSessionParametersKHR* pVideoSessionParameters); + +VKAPI_ATTR VkResult VKAPI_CALL vkUpdateVideoSessionParametersKHR( + VkDevice device, + VkVideoSessionParametersKHR videoSessionParameters, + const VkVideoSessionParametersUpdateInfoKHR* pUpdateInfo); + +VKAPI_ATTR void VKAPI_CALL vkDestroyVideoSessionParametersKHR( + VkDevice device, + VkVideoSessionParametersKHR videoSessionParameters, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR void VKAPI_CALL vkCmdBeginVideoCodingKHR( + VkCommandBuffer commandBuffer, + const VkVideoBeginCodingInfoKHR* pBeginInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdEndVideoCodingKHR( + VkCommandBuffer commandBuffer, + const VkVideoEndCodingInfoKHR* pEndCodingInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdControlVideoCodingKHR( + VkCommandBuffer commandBuffer, + const VkVideoCodingControlInfoKHR* pCodingControlInfo); +#endif + + +#define VK_KHR_video_decode_queue 1 +#define VK_KHR_VIDEO_DECODE_QUEUE_SPEC_VERSION 7 +#define VK_KHR_VIDEO_DECODE_QUEUE_EXTENSION_NAME "VK_KHR_video_decode_queue" + +typedef enum VkVideoDecodeCapabilityFlagBitsKHR { + VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR = 0x00000001, + VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_DISTINCT_BIT_KHR = 0x00000002, + VK_VIDEO_DECODE_CAPABILITY_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoDecodeCapabilityFlagBitsKHR; +typedef VkFlags VkVideoDecodeCapabilityFlagsKHR; + +typedef enum VkVideoDecodeUsageFlagBitsKHR { + VK_VIDEO_DECODE_USAGE_DEFAULT_KHR = 0, + VK_VIDEO_DECODE_USAGE_TRANSCODING_BIT_KHR = 0x00000001, + VK_VIDEO_DECODE_USAGE_OFFLINE_BIT_KHR = 0x00000002, + VK_VIDEO_DECODE_USAGE_STREAMING_BIT_KHR = 0x00000004, + VK_VIDEO_DECODE_USAGE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoDecodeUsageFlagBitsKHR; +typedef VkFlags VkVideoDecodeUsageFlagsKHR; +typedef VkFlags VkVideoDecodeFlagsKHR; +typedef struct VkVideoDecodeCapabilitiesKHR { + VkStructureType sType; + void* pNext; + VkVideoDecodeCapabilityFlagsKHR flags; +} VkVideoDecodeCapabilitiesKHR; + +typedef struct VkVideoDecodeUsageInfoKHR { + VkStructureType sType; + const void* pNext; + VkVideoDecodeUsageFlagsKHR videoUsageHints; +} VkVideoDecodeUsageInfoKHR; + +typedef struct VkVideoDecodeInfoKHR { + VkStructureType sType; + const void* pNext; + VkVideoDecodeFlagsKHR flags; + VkBuffer srcBuffer; + VkDeviceSize srcBufferOffset; + VkDeviceSize srcBufferRange; + VkVideoPictureResourceInfoKHR dstPictureResource; + const VkVideoReferenceSlotInfoKHR* pSetupReferenceSlot; + uint32_t referenceSlotCount; + const VkVideoReferenceSlotInfoKHR* pReferenceSlots; +} VkVideoDecodeInfoKHR; + +typedef void (VKAPI_PTR *PFN_vkCmdDecodeVideoKHR)(VkCommandBuffer commandBuffer, const VkVideoDecodeInfoKHR* pDecodeInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdDecodeVideoKHR( + VkCommandBuffer commandBuffer, + const VkVideoDecodeInfoKHR* pDecodeInfo); +#endif + + +#define VK_KHR_video_decode_h264 1 +#include "vk_video/vulkan_video_codec_h264std.h" +#include "vk_video/vulkan_video_codec_h264std_decode.h" +#define VK_KHR_VIDEO_DECODE_H264_SPEC_VERSION 8 +#define VK_KHR_VIDEO_DECODE_H264_EXTENSION_NAME "VK_KHR_video_decode_h264" + +typedef enum VkVideoDecodeH264PictureLayoutFlagBitsKHR { + VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_PROGRESSIVE_KHR = 0, + VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_INTERLACED_INTERLEAVED_LINES_BIT_KHR = 0x00000001, + VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_INTERLACED_SEPARATE_PLANES_BIT_KHR = 0x00000002, + VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoDecodeH264PictureLayoutFlagBitsKHR; +typedef VkFlags VkVideoDecodeH264PictureLayoutFlagsKHR; +typedef struct VkVideoDecodeH264ProfileInfoKHR { + VkStructureType sType; + const void* pNext; + StdVideoH264ProfileIdc stdProfileIdc; + VkVideoDecodeH264PictureLayoutFlagBitsKHR pictureLayout; +} VkVideoDecodeH264ProfileInfoKHR; + +typedef struct VkVideoDecodeH264CapabilitiesKHR { + VkStructureType sType; + void* pNext; + StdVideoH264LevelIdc maxLevelIdc; + VkOffset2D fieldOffsetGranularity; +} VkVideoDecodeH264CapabilitiesKHR; + +typedef struct VkVideoDecodeH264SessionParametersAddInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t stdSPSCount; + const StdVideoH264SequenceParameterSet* pStdSPSs; + uint32_t stdPPSCount; + const StdVideoH264PictureParameterSet* pStdPPSs; +} VkVideoDecodeH264SessionParametersAddInfoKHR; + +typedef struct VkVideoDecodeH264SessionParametersCreateInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t maxStdSPSCount; + uint32_t maxStdPPSCount; + const VkVideoDecodeH264SessionParametersAddInfoKHR* pParametersAddInfo; +} VkVideoDecodeH264SessionParametersCreateInfoKHR; + +typedef struct VkVideoDecodeH264PictureInfoKHR { + VkStructureType sType; + const void* pNext; + const StdVideoDecodeH264PictureInfo* pStdPictureInfo; + uint32_t sliceCount; + const uint32_t* pSliceOffsets; +} VkVideoDecodeH264PictureInfoKHR; + +typedef struct VkVideoDecodeH264DpbSlotInfoKHR { + VkStructureType sType; + const void* pNext; + const StdVideoDecodeH264ReferenceInfo* pStdReferenceInfo; +} VkVideoDecodeH264DpbSlotInfoKHR; + + + #define VK_KHR_dynamic_rendering 1 #define VK_KHR_DYNAMIC_RENDERING_SPEC_VERSION 1 #define VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME "VK_KHR_dynamic_rendering" @@ -8815,6 +9384,59 @@ typedef struct VkPhysicalDeviceShaderClockFeaturesKHR { +#define VK_KHR_video_decode_h265 1 +#include "vk_video/vulkan_video_codec_h265std.h" +#include "vk_video/vulkan_video_codec_h265std_decode.h" +#define VK_KHR_VIDEO_DECODE_H265_SPEC_VERSION 7 +#define VK_KHR_VIDEO_DECODE_H265_EXTENSION_NAME "VK_KHR_video_decode_h265" +typedef struct VkVideoDecodeH265ProfileInfoKHR { + VkStructureType sType; + const void* pNext; + StdVideoH265ProfileIdc stdProfileIdc; +} VkVideoDecodeH265ProfileInfoKHR; + +typedef struct VkVideoDecodeH265CapabilitiesKHR { + VkStructureType sType; + void* pNext; + StdVideoH265LevelIdc maxLevelIdc; +} VkVideoDecodeH265CapabilitiesKHR; + +typedef struct VkVideoDecodeH265SessionParametersAddInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t stdVPSCount; + const StdVideoH265VideoParameterSet* pStdVPSs; + uint32_t stdSPSCount; + const StdVideoH265SequenceParameterSet* pStdSPSs; + uint32_t stdPPSCount; + const StdVideoH265PictureParameterSet* pStdPPSs; +} VkVideoDecodeH265SessionParametersAddInfoKHR; + +typedef struct VkVideoDecodeH265SessionParametersCreateInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t maxStdVPSCount; + uint32_t maxStdSPSCount; + uint32_t maxStdPPSCount; + const VkVideoDecodeH265SessionParametersAddInfoKHR* pParametersAddInfo; +} VkVideoDecodeH265SessionParametersCreateInfoKHR; + +typedef struct VkVideoDecodeH265PictureInfoKHR { + VkStructureType sType; + const void* pNext; + const StdVideoDecodeH265PictureInfo* pStdPictureInfo; + uint32_t sliceSegmentCount; + const uint32_t* pSliceSegmentOffsets; +} VkVideoDecodeH265PictureInfoKHR; + +typedef struct VkVideoDecodeH265DpbSlotInfoKHR { + VkStructureType sType; + const void* pNext; + const StdVideoDecodeH265ReferenceInfo* pStdReferenceInfo; +} VkVideoDecodeH265DpbSlotInfoKHR; + + + #define VK_KHR_global_priority 1 #define VK_MAX_GLOBAL_PRIORITY_SIZE_KHR 16U #define VK_KHR_GLOBAL_PRIORITY_SPEC_VERSION 1 @@ -9238,6 +9860,41 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetPipelineExecutableInternalRepresentationsKHR #endif +#define VK_KHR_map_memory2 1 +#define VK_KHR_MAP_MEMORY_2_SPEC_VERSION 1 +#define VK_KHR_MAP_MEMORY_2_EXTENSION_NAME "VK_KHR_map_memory2" +typedef VkFlags VkMemoryUnmapFlagsKHR; +typedef struct VkMemoryMapInfoKHR { + VkStructureType sType; + const void* pNext; + VkMemoryMapFlags flags; + VkDeviceMemory memory; + VkDeviceSize offset; + VkDeviceSize size; +} VkMemoryMapInfoKHR; + +typedef struct VkMemoryUnmapInfoKHR { + VkStructureType sType; + const void* pNext; + VkMemoryUnmapFlagsKHR flags; + VkDeviceMemory memory; +} VkMemoryUnmapInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkMapMemory2KHR)(VkDevice device, const VkMemoryMapInfoKHR* pMemoryMapInfo, void** ppData); +typedef VkResult (VKAPI_PTR *PFN_vkUnmapMemory2KHR)(VkDevice device, const VkMemoryUnmapInfoKHR* pMemoryUnmapInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkMapMemory2KHR( + VkDevice device, + const VkMemoryMapInfoKHR* pMemoryMapInfo, + void** ppData); + +VKAPI_ATTR VkResult VKAPI_CALL vkUnmapMemory2KHR( + VkDevice device, + const VkMemoryUnmapInfoKHR* pMemoryUnmapInfo); +#endif + + #define VK_KHR_shader_integer_dot_product 1 #define VK_KHR_SHADER_INTEGER_DOT_PRODUCT_SPEC_VERSION 1 #define VK_KHR_SHADER_INTEGER_DOT_PRODUCT_EXTENSION_NAME "VK_KHR_shader_integer_dot_product" @@ -9382,6 +10039,23 @@ VKAPI_ATTR void VKAPI_CALL vkGetQueueCheckpointData2NV( #endif +#define VK_KHR_fragment_shader_barycentric 1 +#define VK_KHR_FRAGMENT_SHADER_BARYCENTRIC_SPEC_VERSION 1 +#define VK_KHR_FRAGMENT_SHADER_BARYCENTRIC_EXTENSION_NAME "VK_KHR_fragment_shader_barycentric" +typedef struct VkPhysicalDeviceFragmentShaderBarycentricFeaturesKHR { + VkStructureType sType; + void* pNext; + VkBool32 fragmentShaderBarycentric; +} VkPhysicalDeviceFragmentShaderBarycentricFeaturesKHR; + +typedef struct VkPhysicalDeviceFragmentShaderBarycentricPropertiesKHR { + VkStructureType sType; + void* pNext; + VkBool32 triStripVertexOrderIndependentOfProvokingVertex; +} VkPhysicalDeviceFragmentShaderBarycentricPropertiesKHR; + + + #define VK_KHR_shader_subgroup_uniform_control_flow 1 #define VK_KHR_SHADER_SUBGROUP_UNIFORM_CONTROL_FLOW_SPEC_VERSION 1 #define VK_KHR_SHADER_SUBGROUP_UNIFORM_CONTROL_FLOW_EXTENSION_NAME "VK_KHR_shader_subgroup_uniform_control_flow" @@ -9474,7 +10148,7 @@ VKAPI_ATTR void VKAPI_CALL vkCmdResolveImage2KHR( #define VK_KHR_format_feature_flags2 1 -#define VK_KHR_FORMAT_FEATURE_FLAGS_2_SPEC_VERSION 1 +#define VK_KHR_FORMAT_FEATURE_FLAGS_2_SPEC_VERSION 2 #define VK_KHR_FORMAT_FEATURE_FLAGS_2_EXTENSION_NAME "VK_KHR_format_feature_flags2" typedef VkFormatFeatureFlags2 VkFormatFeatureFlags2KHR; @@ -9484,6 +10158,42 @@ typedef VkFormatProperties3 VkFormatProperties3KHR; +#define VK_KHR_ray_tracing_maintenance1 1 +#define VK_KHR_RAY_TRACING_MAINTENANCE_1_SPEC_VERSION 1 +#define VK_KHR_RAY_TRACING_MAINTENANCE_1_EXTENSION_NAME "VK_KHR_ray_tracing_maintenance1" +typedef struct VkPhysicalDeviceRayTracingMaintenance1FeaturesKHR { + VkStructureType sType; + void* pNext; + VkBool32 rayTracingMaintenance1; + VkBool32 rayTracingPipelineTraceRaysIndirect2; +} VkPhysicalDeviceRayTracingMaintenance1FeaturesKHR; + +typedef struct VkTraceRaysIndirectCommand2KHR { + VkDeviceAddress raygenShaderRecordAddress; + VkDeviceSize raygenShaderRecordSize; + VkDeviceAddress missShaderBindingTableAddress; + VkDeviceSize missShaderBindingTableSize; + VkDeviceSize missShaderBindingTableStride; + VkDeviceAddress hitShaderBindingTableAddress; + VkDeviceSize hitShaderBindingTableSize; + VkDeviceSize hitShaderBindingTableStride; + VkDeviceAddress callableShaderBindingTableAddress; + VkDeviceSize callableShaderBindingTableSize; + VkDeviceSize callableShaderBindingTableStride; + uint32_t width; + uint32_t height; + uint32_t depth; +} VkTraceRaysIndirectCommand2KHR; + +typedef void (VKAPI_PTR *PFN_vkCmdTraceRaysIndirect2KHR)(VkCommandBuffer commandBuffer, VkDeviceAddress indirectDeviceAddress); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdTraceRaysIndirect2KHR( + VkCommandBuffer commandBuffer, + VkDeviceAddress indirectDeviceAddress); +#endif + + #define VK_KHR_portability_enumeration 1 #define VK_KHR_PORTABILITY_ENUMERATION_SPEC_VERSION 1 #define VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME "VK_KHR_portability_enumeration" @@ -9523,6 +10233,17 @@ VKAPI_ATTR void VKAPI_CALL vkGetDeviceImageSparseMemoryRequirementsKHR( #endif +#define VK_KHR_ray_tracing_position_fetch 1 +#define VK_KHR_RAY_TRACING_POSITION_FETCH_SPEC_VERSION 1 +#define VK_KHR_RAY_TRACING_POSITION_FETCH_EXTENSION_NAME "VK_KHR_ray_tracing_position_fetch" +typedef struct VkPhysicalDeviceRayTracingPositionFetchFeaturesKHR { + VkStructureType sType; + void* pNext; + VkBool32 rayTracingPositionFetch; +} VkPhysicalDeviceRayTracingPositionFetchFeaturesKHR; + + + #define VK_EXT_debug_report 1 VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDebugReportCallbackEXT) #define VK_EXT_DEBUG_REPORT_SPEC_VERSION 10 @@ -10174,6 +10895,51 @@ typedef struct VkPhysicalDeviceASTCDecodeFeaturesEXT { +#define VK_EXT_pipeline_robustness 1 +#define VK_EXT_PIPELINE_ROBUSTNESS_SPEC_VERSION 1 +#define VK_EXT_PIPELINE_ROBUSTNESS_EXTENSION_NAME "VK_EXT_pipeline_robustness" + +typedef enum VkPipelineRobustnessBufferBehaviorEXT { + VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_DEVICE_DEFAULT_EXT = 0, + VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_DISABLED_EXT = 1, + VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_ROBUST_BUFFER_ACCESS_EXT = 2, + VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_ROBUST_BUFFER_ACCESS_2_EXT = 3, + VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_MAX_ENUM_EXT = 0x7FFFFFFF +} VkPipelineRobustnessBufferBehaviorEXT; + +typedef enum VkPipelineRobustnessImageBehaviorEXT { + VK_PIPELINE_ROBUSTNESS_IMAGE_BEHAVIOR_DEVICE_DEFAULT_EXT = 0, + VK_PIPELINE_ROBUSTNESS_IMAGE_BEHAVIOR_DISABLED_EXT = 1, + VK_PIPELINE_ROBUSTNESS_IMAGE_BEHAVIOR_ROBUST_IMAGE_ACCESS_EXT = 2, + VK_PIPELINE_ROBUSTNESS_IMAGE_BEHAVIOR_ROBUST_IMAGE_ACCESS_2_EXT = 3, + VK_PIPELINE_ROBUSTNESS_IMAGE_BEHAVIOR_MAX_ENUM_EXT = 0x7FFFFFFF +} VkPipelineRobustnessImageBehaviorEXT; +typedef struct VkPhysicalDevicePipelineRobustnessFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 pipelineRobustness; +} VkPhysicalDevicePipelineRobustnessFeaturesEXT; + +typedef struct VkPhysicalDevicePipelineRobustnessPropertiesEXT { + VkStructureType sType; + void* pNext; + VkPipelineRobustnessBufferBehaviorEXT defaultRobustnessStorageBuffers; + VkPipelineRobustnessBufferBehaviorEXT defaultRobustnessUniformBuffers; + VkPipelineRobustnessBufferBehaviorEXT defaultRobustnessVertexInputs; + VkPipelineRobustnessImageBehaviorEXT defaultRobustnessImages; +} VkPhysicalDevicePipelineRobustnessPropertiesEXT; + +typedef struct VkPipelineRobustnessCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkPipelineRobustnessBufferBehaviorEXT storageBuffers; + VkPipelineRobustnessBufferBehaviorEXT uniformBuffers; + VkPipelineRobustnessBufferBehaviorEXT vertexInputs; + VkPipelineRobustnessImageBehaviorEXT images; +} VkPipelineRobustnessCreateInfoEXT; + + + #define VK_EXT_conditional_rendering 1 #define VK_EXT_CONDITIONAL_RENDERING_SPEC_VERSION 2 #define VK_EXT_CONDITIONAL_RENDERING_EXTENSION_NAME "VK_EXT_conditional_rendering" @@ -10474,7 +11240,7 @@ typedef struct VkPipelineViewportSwizzleStateCreateInfoNV { #define VK_EXT_discard_rectangles 1 -#define VK_EXT_DISCARD_RECTANGLES_SPEC_VERSION 1 +#define VK_EXT_DISCARD_RECTANGLES_SPEC_VERSION 2 #define VK_EXT_DISCARD_RECTANGLES_EXTENSION_NAME "VK_EXT_discard_rectangles" typedef enum VkDiscardRectangleModeEXT { @@ -10499,6 +11265,8 @@ typedef struct VkPipelineDiscardRectangleStateCreateInfoEXT { } VkPipelineDiscardRectangleStateCreateInfoEXT; typedef void (VKAPI_PTR *PFN_vkCmdSetDiscardRectangleEXT)(VkCommandBuffer commandBuffer, uint32_t firstDiscardRectangle, uint32_t discardRectangleCount, const VkRect2D* pDiscardRectangles); +typedef void (VKAPI_PTR *PFN_vkCmdSetDiscardRectangleEnableEXT)(VkCommandBuffer commandBuffer, VkBool32 discardRectangleEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetDiscardRectangleModeEXT)(VkCommandBuffer commandBuffer, VkDiscardRectangleModeEXT discardRectangleMode); #ifndef VK_NO_PROTOTYPES VKAPI_ATTR void VKAPI_CALL vkCmdSetDiscardRectangleEXT( @@ -10506,6 +11274,14 @@ VKAPI_ATTR void VKAPI_CALL vkCmdSetDiscardRectangleEXT( uint32_t firstDiscardRectangle, uint32_t discardRectangleCount, const VkRect2D* pDiscardRectangles); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetDiscardRectangleEnableEXT( + VkCommandBuffer commandBuffer, + VkBool32 discardRectangleEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetDiscardRectangleModeEXT( + VkCommandBuffer commandBuffer, + VkDiscardRectangleModeEXT discardRectangleMode); #endif @@ -10629,6 +11405,7 @@ typedef enum VkDebugUtilsMessageTypeFlagBitsEXT { VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT = 0x00000001, VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT = 0x00000002, VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT = 0x00000004, + VK_DEBUG_UTILS_MESSAGE_TYPE_DEVICE_ADDRESS_BINDING_BIT_EXT = 0x00000008, VK_DEBUG_UTILS_MESSAGE_TYPE_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF } VkDebugUtilsMessageTypeFlagBitsEXT; typedef VkFlags VkDebugUtilsMessageTypeFlagsEXT; @@ -11299,6 +12076,8 @@ typedef enum VkGeometryInstanceFlagBitsKHR { VK_GEOMETRY_INSTANCE_TRIANGLE_FLIP_FACING_BIT_KHR = 0x00000002, VK_GEOMETRY_INSTANCE_FORCE_OPAQUE_BIT_KHR = 0x00000004, VK_GEOMETRY_INSTANCE_FORCE_NO_OPAQUE_BIT_KHR = 0x00000008, + VK_GEOMETRY_INSTANCE_FORCE_OPACITY_MICROMAP_2_STATE_EXT = 0x00000010, + VK_GEOMETRY_INSTANCE_DISABLE_OPACITY_MICROMAPS_EXT = 0x00000020, VK_GEOMETRY_INSTANCE_TRIANGLE_FRONT_COUNTERCLOCKWISE_BIT_KHR = VK_GEOMETRY_INSTANCE_TRIANGLE_FLIP_FACING_BIT_KHR, VK_GEOMETRY_INSTANCE_TRIANGLE_CULL_DISABLE_BIT_NV = VK_GEOMETRY_INSTANCE_TRIANGLE_FACING_CULL_DISABLE_BIT_KHR, VK_GEOMETRY_INSTANCE_TRIANGLE_FRONT_COUNTERCLOCKWISE_BIT_NV = VK_GEOMETRY_INSTANCE_TRIANGLE_FRONT_COUNTERCLOCKWISE_BIT_KHR, @@ -11319,6 +12098,13 @@ typedef enum VkBuildAccelerationStructureFlagBitsKHR { VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR = 0x00000008, VK_BUILD_ACCELERATION_STRUCTURE_LOW_MEMORY_BIT_KHR = 0x00000010, VK_BUILD_ACCELERATION_STRUCTURE_MOTION_BIT_NV = 0x00000020, + VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_OPACITY_MICROMAP_UPDATE_EXT = 0x00000040, + VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_DISABLE_OPACITY_MICROMAPS_EXT = 0x00000080, + VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_OPACITY_MICROMAP_DATA_UPDATE_EXT = 0x00000100, +#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_DISPLACEMENT_MICROMAP_UPDATE_NV = 0x00000200, +#endif + VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_DATA_ACCESS_KHR = 0x00000800, VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_UPDATE_BIT_NV = VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_UPDATE_BIT_KHR, VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_COMPACTION_BIT_NV = VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_COMPACTION_BIT_KHR, VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV = VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR, @@ -11904,11 +12690,7 @@ VKAPI_ATTR void VKAPI_CALL vkCmdDrawMeshTasksIndirectCountNV( #define VK_NV_fragment_shader_barycentric 1 #define VK_NV_FRAGMENT_SHADER_BARYCENTRIC_SPEC_VERSION 1 #define VK_NV_FRAGMENT_SHADER_BARYCENTRIC_EXTENSION_NAME "VK_NV_fragment_shader_barycentric" -typedef struct VkPhysicalDeviceFragmentShaderBarycentricFeaturesNV { - VkStructureType sType; - void* pNext; - VkBool32 fragmentShaderBarycentric; -} VkPhysicalDeviceFragmentShaderBarycentricFeaturesNV; +typedef VkPhysicalDeviceFragmentShaderBarycentricFeaturesKHR VkPhysicalDeviceFragmentShaderBarycentricFeaturesNV; @@ -11924,7 +12706,7 @@ typedef struct VkPhysicalDeviceShaderImageFootprintFeaturesNV { #define VK_NV_scissor_exclusive 1 -#define VK_NV_SCISSOR_EXCLUSIVE_SPEC_VERSION 1 +#define VK_NV_SCISSOR_EXCLUSIVE_SPEC_VERSION 2 #define VK_NV_SCISSOR_EXCLUSIVE_EXTENSION_NAME "VK_NV_scissor_exclusive" typedef struct VkPipelineViewportExclusiveScissorStateCreateInfoNV { VkStructureType sType; @@ -11939,9 +12721,16 @@ typedef struct VkPhysicalDeviceExclusiveScissorFeaturesNV { VkBool32 exclusiveScissor; } VkPhysicalDeviceExclusiveScissorFeaturesNV; +typedef void (VKAPI_PTR *PFN_vkCmdSetExclusiveScissorEnableNV)(VkCommandBuffer commandBuffer, uint32_t firstExclusiveScissor, uint32_t exclusiveScissorCount, const VkBool32* pExclusiveScissorEnables); typedef void (VKAPI_PTR *PFN_vkCmdSetExclusiveScissorNV)(VkCommandBuffer commandBuffer, uint32_t firstExclusiveScissor, uint32_t exclusiveScissorCount, const VkRect2D* pExclusiveScissors); #ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdSetExclusiveScissorEnableNV( + VkCommandBuffer commandBuffer, + uint32_t firstExclusiveScissor, + uint32_t exclusiveScissorCount, + const VkBool32* pExclusiveScissorEnables); + VKAPI_ATTR void VKAPI_CALL vkCmdSetExclusiveScissorNV( VkCommandBuffer commandBuffer, uint32_t firstExclusiveScissor, @@ -12779,6 +13568,105 @@ typedef struct VkPhysicalDeviceShaderAtomicFloat2FeaturesEXT { +#define VK_EXT_surface_maintenance1 1 +#define VK_EXT_SURFACE_MAINTENANCE_1_SPEC_VERSION 1 +#define VK_EXT_SURFACE_MAINTENANCE_1_EXTENSION_NAME "VK_EXT_surface_maintenance1" + +typedef enum VkPresentScalingFlagBitsEXT { + VK_PRESENT_SCALING_ONE_TO_ONE_BIT_EXT = 0x00000001, + VK_PRESENT_SCALING_ASPECT_RATIO_STRETCH_BIT_EXT = 0x00000002, + VK_PRESENT_SCALING_STRETCH_BIT_EXT = 0x00000004, + VK_PRESENT_SCALING_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkPresentScalingFlagBitsEXT; +typedef VkFlags VkPresentScalingFlagsEXT; + +typedef enum VkPresentGravityFlagBitsEXT { + VK_PRESENT_GRAVITY_MIN_BIT_EXT = 0x00000001, + VK_PRESENT_GRAVITY_MAX_BIT_EXT = 0x00000002, + VK_PRESENT_GRAVITY_CENTERED_BIT_EXT = 0x00000004, + VK_PRESENT_GRAVITY_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkPresentGravityFlagBitsEXT; +typedef VkFlags VkPresentGravityFlagsEXT; +typedef struct VkSurfacePresentModeEXT { + VkStructureType sType; + void* pNext; + VkPresentModeKHR presentMode; +} VkSurfacePresentModeEXT; + +typedef struct VkSurfacePresentScalingCapabilitiesEXT { + VkStructureType sType; + void* pNext; + VkPresentScalingFlagsEXT supportedPresentScaling; + VkPresentGravityFlagsEXT supportedPresentGravityX; + VkPresentGravityFlagsEXT supportedPresentGravityY; + VkExtent2D minScaledImageExtent; + VkExtent2D maxScaledImageExtent; +} VkSurfacePresentScalingCapabilitiesEXT; + +typedef struct VkSurfacePresentModeCompatibilityEXT { + VkStructureType sType; + void* pNext; + uint32_t presentModeCount; + VkPresentModeKHR* pPresentModes; +} VkSurfacePresentModeCompatibilityEXT; + + + +#define VK_EXT_swapchain_maintenance1 1 +#define VK_EXT_SWAPCHAIN_MAINTENANCE_1_SPEC_VERSION 1 +#define VK_EXT_SWAPCHAIN_MAINTENANCE_1_EXTENSION_NAME "VK_EXT_swapchain_maintenance1" +typedef struct VkPhysicalDeviceSwapchainMaintenance1FeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 swapchainMaintenance1; +} VkPhysicalDeviceSwapchainMaintenance1FeaturesEXT; + +typedef struct VkSwapchainPresentFenceInfoEXT { + VkStructureType sType; + const void* pNext; + uint32_t swapchainCount; + const VkFence* pFences; +} VkSwapchainPresentFenceInfoEXT; + +typedef struct VkSwapchainPresentModesCreateInfoEXT { + VkStructureType sType; + const void* pNext; + uint32_t presentModeCount; + const VkPresentModeKHR* pPresentModes; +} VkSwapchainPresentModesCreateInfoEXT; + +typedef struct VkSwapchainPresentModeInfoEXT { + VkStructureType sType; + const void* pNext; + uint32_t swapchainCount; + const VkPresentModeKHR* pPresentModes; +} VkSwapchainPresentModeInfoEXT; + +typedef struct VkSwapchainPresentScalingCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkPresentScalingFlagsEXT scalingBehavior; + VkPresentGravityFlagsEXT presentGravityX; + VkPresentGravityFlagsEXT presentGravityY; +} VkSwapchainPresentScalingCreateInfoEXT; + +typedef struct VkReleaseSwapchainImagesInfoEXT { + VkStructureType sType; + const void* pNext; + VkSwapchainKHR swapchain; + uint32_t imageIndexCount; + const uint32_t* pImageIndices; +} VkReleaseSwapchainImagesInfoEXT; + +typedef VkResult (VKAPI_PTR *PFN_vkReleaseSwapchainImagesEXT)(VkDevice device, const VkReleaseSwapchainImagesInfoEXT* pReleaseInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkReleaseSwapchainImagesEXT( + VkDevice device, + const VkReleaseSwapchainImagesInfoEXT* pReleaseInfo); +#endif + + #define VK_EXT_shader_demote_to_helper_invocation 1 #define VK_EXT_SHADER_DEMOTE_TO_HELPER_INVOCATION_SPEC_VERSION 1 #define VK_EXT_SHADER_DEMOTE_TO_HELPER_INVOCATION_EXTENSION_NAME "VK_EXT_shader_demote_to_helper_invocation" @@ -12800,6 +13688,7 @@ typedef enum VkIndirectCommandsTokenTypeNV { VK_INDIRECT_COMMANDS_TOKEN_TYPE_DRAW_INDEXED_NV = 5, VK_INDIRECT_COMMANDS_TOKEN_TYPE_DRAW_NV = 6, VK_INDIRECT_COMMANDS_TOKEN_TYPE_DRAW_TASKS_NV = 7, + VK_INDIRECT_COMMANDS_TOKEN_TYPE_DRAW_MESH_TASKS_NV = 1000328000, VK_INDIRECT_COMMANDS_TOKEN_TYPE_MAX_ENUM_NV = 0x7FFFFFFF } VkIndirectCommandsTokenTypeNV; @@ -13009,7 +13898,7 @@ typedef VkPhysicalDeviceTexelBufferAlignmentProperties VkPhysicalDeviceTexelBuff #define VK_QCOM_render_pass_transform 1 -#define VK_QCOM_RENDER_PASS_TRANSFORM_SPEC_VERSION 2 +#define VK_QCOM_RENDER_PASS_TRANSFORM_SPEC_VERSION 3 #define VK_QCOM_RENDER_PASS_TRANSFORM_EXTENSION_NAME "VK_QCOM_render_pass_transform" typedef struct VkRenderPassTransformBeginInfoQCOM { VkStructureType sType; @@ -13141,6 +14030,29 @@ typedef struct VkPhysicalDeviceCustomBorderColorFeaturesEXT { #define VK_GOOGLE_USER_TYPE_EXTENSION_NAME "VK_GOOGLE_user_type" +#define VK_NV_present_barrier 1 +#define VK_NV_PRESENT_BARRIER_SPEC_VERSION 1 +#define VK_NV_PRESENT_BARRIER_EXTENSION_NAME "VK_NV_present_barrier" +typedef struct VkPhysicalDevicePresentBarrierFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 presentBarrier; +} VkPhysicalDevicePresentBarrierFeaturesNV; + +typedef struct VkSurfaceCapabilitiesPresentBarrierNV { + VkStructureType sType; + void* pNext; + VkBool32 presentBarrierSupported; +} VkSurfaceCapabilitiesPresentBarrierNV; + +typedef struct VkSwapchainPresentBarrierCreateInfoNV { + VkStructureType sType; + void* pNext; + VkBool32 presentBarrierEnable; +} VkSwapchainPresentBarrierCreateInfoNV; + + + #define VK_EXT_private_data 1 typedef VkPrivateDataSlot VkPrivateDataSlotEXT; @@ -13195,13 +14107,14 @@ typedef VkPhysicalDevicePipelineCreationCacheControlFeatures VkPhysicalDevicePip #define VK_NV_device_diagnostics_config 1 -#define VK_NV_DEVICE_DIAGNOSTICS_CONFIG_SPEC_VERSION 1 +#define VK_NV_DEVICE_DIAGNOSTICS_CONFIG_SPEC_VERSION 2 #define VK_NV_DEVICE_DIAGNOSTICS_CONFIG_EXTENSION_NAME "VK_NV_device_diagnostics_config" typedef enum VkDeviceDiagnosticsConfigFlagBitsNV { VK_DEVICE_DIAGNOSTICS_CONFIG_ENABLE_SHADER_DEBUG_INFO_BIT_NV = 0x00000001, VK_DEVICE_DIAGNOSTICS_CONFIG_ENABLE_RESOURCE_TRACKING_BIT_NV = 0x00000002, VK_DEVICE_DIAGNOSTICS_CONFIG_ENABLE_AUTOMATIC_CHECKPOINTS_BIT_NV = 0x00000004, + VK_DEVICE_DIAGNOSTICS_CONFIG_ENABLE_SHADER_ERROR_REPORTING_BIT_NV = 0x00000008, VK_DEVICE_DIAGNOSTICS_CONFIG_FLAG_BITS_MAX_ENUM_NV = 0x7FFFFFFF } VkDeviceDiagnosticsConfigFlagBitsNV; typedef VkFlags VkDeviceDiagnosticsConfigFlagsNV; @@ -13224,6 +14137,229 @@ typedef struct VkDeviceDiagnosticsConfigCreateInfoNV { #define VK_QCOM_RENDER_PASS_STORE_OPS_EXTENSION_NAME "VK_QCOM_render_pass_store_ops" +#define VK_NV_low_latency 1 +#define VK_NV_LOW_LATENCY_SPEC_VERSION 1 +#define VK_NV_LOW_LATENCY_EXTENSION_NAME "VK_NV_low_latency" +typedef struct VkQueryLowLatencySupportNV { + VkStructureType sType; + const void* pNext; + void* pQueriedLowLatencyData; +} VkQueryLowLatencySupportNV; + + + +#define VK_EXT_descriptor_buffer 1 +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkAccelerationStructureKHR) +#define VK_EXT_DESCRIPTOR_BUFFER_SPEC_VERSION 1 +#define VK_EXT_DESCRIPTOR_BUFFER_EXTENSION_NAME "VK_EXT_descriptor_buffer" +typedef struct VkPhysicalDeviceDescriptorBufferPropertiesEXT { + VkStructureType sType; + void* pNext; + VkBool32 combinedImageSamplerDescriptorSingleArray; + VkBool32 bufferlessPushDescriptors; + VkBool32 allowSamplerImageViewPostSubmitCreation; + VkDeviceSize descriptorBufferOffsetAlignment; + uint32_t maxDescriptorBufferBindings; + uint32_t maxResourceDescriptorBufferBindings; + uint32_t maxSamplerDescriptorBufferBindings; + uint32_t maxEmbeddedImmutableSamplerBindings; + uint32_t maxEmbeddedImmutableSamplers; + size_t bufferCaptureReplayDescriptorDataSize; + size_t imageCaptureReplayDescriptorDataSize; + size_t imageViewCaptureReplayDescriptorDataSize; + size_t samplerCaptureReplayDescriptorDataSize; + size_t accelerationStructureCaptureReplayDescriptorDataSize; + size_t samplerDescriptorSize; + size_t combinedImageSamplerDescriptorSize; + size_t sampledImageDescriptorSize; + size_t storageImageDescriptorSize; + size_t uniformTexelBufferDescriptorSize; + size_t robustUniformTexelBufferDescriptorSize; + size_t storageTexelBufferDescriptorSize; + size_t robustStorageTexelBufferDescriptorSize; + size_t uniformBufferDescriptorSize; + size_t robustUniformBufferDescriptorSize; + size_t storageBufferDescriptorSize; + size_t robustStorageBufferDescriptorSize; + size_t inputAttachmentDescriptorSize; + size_t accelerationStructureDescriptorSize; + VkDeviceSize maxSamplerDescriptorBufferRange; + VkDeviceSize maxResourceDescriptorBufferRange; + VkDeviceSize samplerDescriptorBufferAddressSpaceSize; + VkDeviceSize resourceDescriptorBufferAddressSpaceSize; + VkDeviceSize descriptorBufferAddressSpaceSize; +} VkPhysicalDeviceDescriptorBufferPropertiesEXT; + +typedef struct VkPhysicalDeviceDescriptorBufferDensityMapPropertiesEXT { + VkStructureType sType; + void* pNext; + size_t combinedImageSamplerDensityMapDescriptorSize; +} VkPhysicalDeviceDescriptorBufferDensityMapPropertiesEXT; + +typedef struct VkPhysicalDeviceDescriptorBufferFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 descriptorBuffer; + VkBool32 descriptorBufferCaptureReplay; + VkBool32 descriptorBufferImageLayoutIgnored; + VkBool32 descriptorBufferPushDescriptors; +} VkPhysicalDeviceDescriptorBufferFeaturesEXT; + +typedef struct VkDescriptorAddressInfoEXT { + VkStructureType sType; + void* pNext; + VkDeviceAddress address; + VkDeviceSize range; + VkFormat format; +} VkDescriptorAddressInfoEXT; + +typedef struct VkDescriptorBufferBindingInfoEXT { + VkStructureType sType; + void* pNext; + VkDeviceAddress address; + VkBufferUsageFlags usage; +} VkDescriptorBufferBindingInfoEXT; + +typedef struct VkDescriptorBufferBindingPushDescriptorBufferHandleEXT { + VkStructureType sType; + void* pNext; + VkBuffer buffer; +} VkDescriptorBufferBindingPushDescriptorBufferHandleEXT; + +typedef union VkDescriptorDataEXT { + const VkSampler* pSampler; + const VkDescriptorImageInfo* pCombinedImageSampler; + const VkDescriptorImageInfo* pInputAttachmentImage; + const VkDescriptorImageInfo* pSampledImage; + const VkDescriptorImageInfo* pStorageImage; + const VkDescriptorAddressInfoEXT* pUniformTexelBuffer; + const VkDescriptorAddressInfoEXT* pStorageTexelBuffer; + const VkDescriptorAddressInfoEXT* pUniformBuffer; + const VkDescriptorAddressInfoEXT* pStorageBuffer; + VkDeviceAddress accelerationStructure; +} VkDescriptorDataEXT; + +typedef struct VkDescriptorGetInfoEXT { + VkStructureType sType; + const void* pNext; + VkDescriptorType type; + VkDescriptorDataEXT data; +} VkDescriptorGetInfoEXT; + +typedef struct VkBufferCaptureDescriptorDataInfoEXT { + VkStructureType sType; + const void* pNext; + VkBuffer buffer; +} VkBufferCaptureDescriptorDataInfoEXT; + +typedef struct VkImageCaptureDescriptorDataInfoEXT { + VkStructureType sType; + const void* pNext; + VkImage image; +} VkImageCaptureDescriptorDataInfoEXT; + +typedef struct VkImageViewCaptureDescriptorDataInfoEXT { + VkStructureType sType; + const void* pNext; + VkImageView imageView; +} VkImageViewCaptureDescriptorDataInfoEXT; + +typedef struct VkSamplerCaptureDescriptorDataInfoEXT { + VkStructureType sType; + const void* pNext; + VkSampler sampler; +} VkSamplerCaptureDescriptorDataInfoEXT; + +typedef struct VkOpaqueCaptureDescriptorDataCreateInfoEXT { + VkStructureType sType; + const void* pNext; + const void* opaqueCaptureDescriptorData; +} VkOpaqueCaptureDescriptorDataCreateInfoEXT; + +typedef struct VkAccelerationStructureCaptureDescriptorDataInfoEXT { + VkStructureType sType; + const void* pNext; + VkAccelerationStructureKHR accelerationStructure; + VkAccelerationStructureNV accelerationStructureNV; +} VkAccelerationStructureCaptureDescriptorDataInfoEXT; + +typedef void (VKAPI_PTR *PFN_vkGetDescriptorSetLayoutSizeEXT)(VkDevice device, VkDescriptorSetLayout layout, VkDeviceSize* pLayoutSizeInBytes); +typedef void (VKAPI_PTR *PFN_vkGetDescriptorSetLayoutBindingOffsetEXT)(VkDevice device, VkDescriptorSetLayout layout, uint32_t binding, VkDeviceSize* pOffset); +typedef void (VKAPI_PTR *PFN_vkGetDescriptorEXT)(VkDevice device, const VkDescriptorGetInfoEXT* pDescriptorInfo, size_t dataSize, void* pDescriptor); +typedef void (VKAPI_PTR *PFN_vkCmdBindDescriptorBuffersEXT)(VkCommandBuffer commandBuffer, uint32_t bufferCount, const VkDescriptorBufferBindingInfoEXT* pBindingInfos); +typedef void (VKAPI_PTR *PFN_vkCmdSetDescriptorBufferOffsetsEXT)(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, uint32_t firstSet, uint32_t setCount, const uint32_t* pBufferIndices, const VkDeviceSize* pOffsets); +typedef void (VKAPI_PTR *PFN_vkCmdBindDescriptorBufferEmbeddedSamplersEXT)(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, uint32_t set); +typedef VkResult (VKAPI_PTR *PFN_vkGetBufferOpaqueCaptureDescriptorDataEXT)(VkDevice device, const VkBufferCaptureDescriptorDataInfoEXT* pInfo, void* pData); +typedef VkResult (VKAPI_PTR *PFN_vkGetImageOpaqueCaptureDescriptorDataEXT)(VkDevice device, const VkImageCaptureDescriptorDataInfoEXT* pInfo, void* pData); +typedef VkResult (VKAPI_PTR *PFN_vkGetImageViewOpaqueCaptureDescriptorDataEXT)(VkDevice device, const VkImageViewCaptureDescriptorDataInfoEXT* pInfo, void* pData); +typedef VkResult (VKAPI_PTR *PFN_vkGetSamplerOpaqueCaptureDescriptorDataEXT)(VkDevice device, const VkSamplerCaptureDescriptorDataInfoEXT* pInfo, void* pData); +typedef VkResult (VKAPI_PTR *PFN_vkGetAccelerationStructureOpaqueCaptureDescriptorDataEXT)(VkDevice device, const VkAccelerationStructureCaptureDescriptorDataInfoEXT* pInfo, void* pData); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkGetDescriptorSetLayoutSizeEXT( + VkDevice device, + VkDescriptorSetLayout layout, + VkDeviceSize* pLayoutSizeInBytes); + +VKAPI_ATTR void VKAPI_CALL vkGetDescriptorSetLayoutBindingOffsetEXT( + VkDevice device, + VkDescriptorSetLayout layout, + uint32_t binding, + VkDeviceSize* pOffset); + +VKAPI_ATTR void VKAPI_CALL vkGetDescriptorEXT( + VkDevice device, + const VkDescriptorGetInfoEXT* pDescriptorInfo, + size_t dataSize, + void* pDescriptor); + +VKAPI_ATTR void VKAPI_CALL vkCmdBindDescriptorBuffersEXT( + VkCommandBuffer commandBuffer, + uint32_t bufferCount, + const VkDescriptorBufferBindingInfoEXT* pBindingInfos); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetDescriptorBufferOffsetsEXT( + VkCommandBuffer commandBuffer, + VkPipelineBindPoint pipelineBindPoint, + VkPipelineLayout layout, + uint32_t firstSet, + uint32_t setCount, + const uint32_t* pBufferIndices, + const VkDeviceSize* pOffsets); + +VKAPI_ATTR void VKAPI_CALL vkCmdBindDescriptorBufferEmbeddedSamplersEXT( + VkCommandBuffer commandBuffer, + VkPipelineBindPoint pipelineBindPoint, + VkPipelineLayout layout, + uint32_t set); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetBufferOpaqueCaptureDescriptorDataEXT( + VkDevice device, + const VkBufferCaptureDescriptorDataInfoEXT* pInfo, + void* pData); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetImageOpaqueCaptureDescriptorDataEXT( + VkDevice device, + const VkImageCaptureDescriptorDataInfoEXT* pInfo, + void* pData); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetImageViewOpaqueCaptureDescriptorDataEXT( + VkDevice device, + const VkImageViewCaptureDescriptorDataInfoEXT* pInfo, + void* pData); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetSamplerOpaqueCaptureDescriptorDataEXT( + VkDevice device, + const VkSamplerCaptureDescriptorDataInfoEXT* pInfo, + void* pData); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetAccelerationStructureOpaqueCaptureDescriptorDataEXT( + VkDevice device, + const VkAccelerationStructureCaptureDescriptorDataInfoEXT* pInfo, + void* pData); +#endif + + #define VK_EXT_graphics_pipeline_library 1 #define VK_EXT_GRAPHICS_PIPELINE_LIBRARY_SPEC_VERSION 1 #define VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME "VK_EXT_graphics_pipeline_library" @@ -13257,6 +14393,17 @@ typedef struct VkGraphicsPipelineLibraryCreateInfoEXT { +#define VK_AMD_shader_early_and_late_fragment_tests 1 +#define VK_AMD_SHADER_EARLY_AND_LATE_FRAGMENT_TESTS_SPEC_VERSION 1 +#define VK_AMD_SHADER_EARLY_AND_LATE_FRAGMENT_TESTS_EXTENSION_NAME "VK_AMD_shader_early_and_late_fragment_tests" +typedef struct VkPhysicalDeviceShaderEarlyAndLateFragmentTestsFeaturesAMD { + VkStructureType sType; + void* pNext; + VkBool32 shaderEarlyAndLateFragmentTests; +} VkPhysicalDeviceShaderEarlyAndLateFragmentTestsFeaturesAMD; + + + #define VK_NV_fragment_shading_rate_enums 1 #define VK_NV_FRAGMENT_SHADING_RATE_ENUMS_SPEC_VERSION 1 #define VK_NV_FRAGMENT_SHADING_RATE_ENUMS_EXTENSION_NAME "VK_NV_fragment_shading_rate_enums" @@ -13453,6 +14600,103 @@ typedef VkPhysicalDeviceImageRobustnessFeatures VkPhysicalDeviceImageRobustnessF +#define VK_EXT_image_compression_control 1 +#define VK_EXT_IMAGE_COMPRESSION_CONTROL_SPEC_VERSION 1 +#define VK_EXT_IMAGE_COMPRESSION_CONTROL_EXTENSION_NAME "VK_EXT_image_compression_control" + +typedef enum VkImageCompressionFlagBitsEXT { + VK_IMAGE_COMPRESSION_DEFAULT_EXT = 0, + VK_IMAGE_COMPRESSION_FIXED_RATE_DEFAULT_EXT = 0x00000001, + VK_IMAGE_COMPRESSION_FIXED_RATE_EXPLICIT_EXT = 0x00000002, + VK_IMAGE_COMPRESSION_DISABLED_EXT = 0x00000004, + VK_IMAGE_COMPRESSION_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkImageCompressionFlagBitsEXT; +typedef VkFlags VkImageCompressionFlagsEXT; + +typedef enum VkImageCompressionFixedRateFlagBitsEXT { + VK_IMAGE_COMPRESSION_FIXED_RATE_NONE_EXT = 0, + VK_IMAGE_COMPRESSION_FIXED_RATE_1BPC_BIT_EXT = 0x00000001, + VK_IMAGE_COMPRESSION_FIXED_RATE_2BPC_BIT_EXT = 0x00000002, + VK_IMAGE_COMPRESSION_FIXED_RATE_3BPC_BIT_EXT = 0x00000004, + VK_IMAGE_COMPRESSION_FIXED_RATE_4BPC_BIT_EXT = 0x00000008, + VK_IMAGE_COMPRESSION_FIXED_RATE_5BPC_BIT_EXT = 0x00000010, + VK_IMAGE_COMPRESSION_FIXED_RATE_6BPC_BIT_EXT = 0x00000020, + VK_IMAGE_COMPRESSION_FIXED_RATE_7BPC_BIT_EXT = 0x00000040, + VK_IMAGE_COMPRESSION_FIXED_RATE_8BPC_BIT_EXT = 0x00000080, + VK_IMAGE_COMPRESSION_FIXED_RATE_9BPC_BIT_EXT = 0x00000100, + VK_IMAGE_COMPRESSION_FIXED_RATE_10BPC_BIT_EXT = 0x00000200, + VK_IMAGE_COMPRESSION_FIXED_RATE_11BPC_BIT_EXT = 0x00000400, + VK_IMAGE_COMPRESSION_FIXED_RATE_12BPC_BIT_EXT = 0x00000800, + VK_IMAGE_COMPRESSION_FIXED_RATE_13BPC_BIT_EXT = 0x00001000, + VK_IMAGE_COMPRESSION_FIXED_RATE_14BPC_BIT_EXT = 0x00002000, + VK_IMAGE_COMPRESSION_FIXED_RATE_15BPC_BIT_EXT = 0x00004000, + VK_IMAGE_COMPRESSION_FIXED_RATE_16BPC_BIT_EXT = 0x00008000, + VK_IMAGE_COMPRESSION_FIXED_RATE_17BPC_BIT_EXT = 0x00010000, + VK_IMAGE_COMPRESSION_FIXED_RATE_18BPC_BIT_EXT = 0x00020000, + VK_IMAGE_COMPRESSION_FIXED_RATE_19BPC_BIT_EXT = 0x00040000, + VK_IMAGE_COMPRESSION_FIXED_RATE_20BPC_BIT_EXT = 0x00080000, + VK_IMAGE_COMPRESSION_FIXED_RATE_21BPC_BIT_EXT = 0x00100000, + VK_IMAGE_COMPRESSION_FIXED_RATE_22BPC_BIT_EXT = 0x00200000, + VK_IMAGE_COMPRESSION_FIXED_RATE_23BPC_BIT_EXT = 0x00400000, + VK_IMAGE_COMPRESSION_FIXED_RATE_24BPC_BIT_EXT = 0x00800000, + VK_IMAGE_COMPRESSION_FIXED_RATE_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkImageCompressionFixedRateFlagBitsEXT; +typedef VkFlags VkImageCompressionFixedRateFlagsEXT; +typedef struct VkPhysicalDeviceImageCompressionControlFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 imageCompressionControl; +} VkPhysicalDeviceImageCompressionControlFeaturesEXT; + +typedef struct VkImageCompressionControlEXT { + VkStructureType sType; + const void* pNext; + VkImageCompressionFlagsEXT flags; + uint32_t compressionControlPlaneCount; + VkImageCompressionFixedRateFlagsEXT* pFixedRateFlags; +} VkImageCompressionControlEXT; + +typedef struct VkSubresourceLayout2EXT { + VkStructureType sType; + void* pNext; + VkSubresourceLayout subresourceLayout; +} VkSubresourceLayout2EXT; + +typedef struct VkImageSubresource2EXT { + VkStructureType sType; + void* pNext; + VkImageSubresource imageSubresource; +} VkImageSubresource2EXT; + +typedef struct VkImageCompressionPropertiesEXT { + VkStructureType sType; + void* pNext; + VkImageCompressionFlagsEXT imageCompressionFlags; + VkImageCompressionFixedRateFlagsEXT imageCompressionFixedRateFlags; +} VkImageCompressionPropertiesEXT; + +typedef void (VKAPI_PTR *PFN_vkGetImageSubresourceLayout2EXT)(VkDevice device, VkImage image, const VkImageSubresource2EXT* pSubresource, VkSubresourceLayout2EXT* pLayout); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkGetImageSubresourceLayout2EXT( + VkDevice device, + VkImage image, + const VkImageSubresource2EXT* pSubresource, + VkSubresourceLayout2EXT* pLayout); +#endif + + +#define VK_EXT_attachment_feedback_loop_layout 1 +#define VK_EXT_ATTACHMENT_FEEDBACK_LOOP_LAYOUT_SPEC_VERSION 2 +#define VK_EXT_ATTACHMENT_FEEDBACK_LOOP_LAYOUT_EXTENSION_NAME "VK_EXT_attachment_feedback_loop_layout" +typedef struct VkPhysicalDeviceAttachmentFeedbackLoopLayoutFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 attachmentFeedbackLoopLayout; +} VkPhysicalDeviceAttachmentFeedbackLoopLayoutFeaturesEXT; + + + #define VK_EXT_4444_formats 1 #define VK_EXT_4444_FORMATS_SPEC_VERSION 1 #define VK_EXT_4444_FORMATS_EXTENSION_NAME "VK_EXT_4444_formats" @@ -13465,16 +14709,97 @@ typedef struct VkPhysicalDevice4444FormatsFeaturesEXT { +#define VK_EXT_device_fault 1 +#define VK_EXT_DEVICE_FAULT_SPEC_VERSION 2 +#define VK_EXT_DEVICE_FAULT_EXTENSION_NAME "VK_EXT_device_fault" + +typedef enum VkDeviceFaultAddressTypeEXT { + VK_DEVICE_FAULT_ADDRESS_TYPE_NONE_EXT = 0, + VK_DEVICE_FAULT_ADDRESS_TYPE_READ_INVALID_EXT = 1, + VK_DEVICE_FAULT_ADDRESS_TYPE_WRITE_INVALID_EXT = 2, + VK_DEVICE_FAULT_ADDRESS_TYPE_EXECUTE_INVALID_EXT = 3, + VK_DEVICE_FAULT_ADDRESS_TYPE_INSTRUCTION_POINTER_UNKNOWN_EXT = 4, + VK_DEVICE_FAULT_ADDRESS_TYPE_INSTRUCTION_POINTER_INVALID_EXT = 5, + VK_DEVICE_FAULT_ADDRESS_TYPE_INSTRUCTION_POINTER_FAULT_EXT = 6, + VK_DEVICE_FAULT_ADDRESS_TYPE_MAX_ENUM_EXT = 0x7FFFFFFF +} VkDeviceFaultAddressTypeEXT; + +typedef enum VkDeviceFaultVendorBinaryHeaderVersionEXT { + VK_DEVICE_FAULT_VENDOR_BINARY_HEADER_VERSION_ONE_EXT = 1, + VK_DEVICE_FAULT_VENDOR_BINARY_HEADER_VERSION_MAX_ENUM_EXT = 0x7FFFFFFF +} VkDeviceFaultVendorBinaryHeaderVersionEXT; +typedef struct VkPhysicalDeviceFaultFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 deviceFault; + VkBool32 deviceFaultVendorBinary; +} VkPhysicalDeviceFaultFeaturesEXT; + +typedef struct VkDeviceFaultCountsEXT { + VkStructureType sType; + void* pNext; + uint32_t addressInfoCount; + uint32_t vendorInfoCount; + VkDeviceSize vendorBinarySize; +} VkDeviceFaultCountsEXT; + +typedef struct VkDeviceFaultAddressInfoEXT { + VkDeviceFaultAddressTypeEXT addressType; + VkDeviceAddress reportedAddress; + VkDeviceSize addressPrecision; +} VkDeviceFaultAddressInfoEXT; + +typedef struct VkDeviceFaultVendorInfoEXT { + char description[VK_MAX_DESCRIPTION_SIZE]; + uint64_t vendorFaultCode; + uint64_t vendorFaultData; +} VkDeviceFaultVendorInfoEXT; + +typedef struct VkDeviceFaultInfoEXT { + VkStructureType sType; + void* pNext; + char description[VK_MAX_DESCRIPTION_SIZE]; + VkDeviceFaultAddressInfoEXT* pAddressInfos; + VkDeviceFaultVendorInfoEXT* pVendorInfos; + void* pVendorBinaryData; +} VkDeviceFaultInfoEXT; + +typedef struct VkDeviceFaultVendorBinaryHeaderVersionOneEXT { + uint32_t headerSize; + VkDeviceFaultVendorBinaryHeaderVersionEXT headerVersion; + uint32_t vendorID; + uint32_t deviceID; + uint32_t driverVersion; + uint8_t pipelineCacheUUID[VK_UUID_SIZE]; + uint32_t applicationNameOffset; + uint32_t applicationVersion; + uint32_t engineNameOffset; + uint32_t engineVersion; + uint32_t apiVersion; +} VkDeviceFaultVendorBinaryHeaderVersionOneEXT; + +typedef VkResult (VKAPI_PTR *PFN_vkGetDeviceFaultInfoEXT)(VkDevice device, VkDeviceFaultCountsEXT* pFaultCounts, VkDeviceFaultInfoEXT* pFaultInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetDeviceFaultInfoEXT( + VkDevice device, + VkDeviceFaultCountsEXT* pFaultCounts, + VkDeviceFaultInfoEXT* pFaultInfo); +#endif + + #define VK_ARM_rasterization_order_attachment_access 1 #define VK_ARM_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_SPEC_VERSION 1 #define VK_ARM_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_EXTENSION_NAME "VK_ARM_rasterization_order_attachment_access" -typedef struct VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM { +typedef struct VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesEXT { VkStructureType sType; void* pNext; VkBool32 rasterizationOrderColorAttachmentAccess; VkBool32 rasterizationOrderDepthAttachmentAccess; VkBool32 rasterizationOrderStencilAttachmentAccess; -} VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM; +} VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesEXT; + +typedef VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesEXT VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM; @@ -13489,44 +14814,32 @@ typedef struct VkPhysicalDeviceRGBA10X6FormatsFeaturesEXT { -#define VK_NV_acquire_winrt_display 1 -#define VK_NV_ACQUIRE_WINRT_DISPLAY_SPEC_VERSION 1 -#define VK_NV_ACQUIRE_WINRT_DISPLAY_EXTENSION_NAME "VK_NV_acquire_winrt_display" -typedef VkResult (VKAPI_PTR *PFN_vkAcquireWinrtDisplayNV)(VkPhysicalDevice physicalDevice, VkDisplayKHR display); -typedef VkResult (VKAPI_PTR *PFN_vkGetWinrtDisplayNV)(VkPhysicalDevice physicalDevice, uint32_t deviceRelativeId, VkDisplayKHR* pDisplay); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR VkResult VKAPI_CALL vkAcquireWinrtDisplayNV( - VkPhysicalDevice physicalDevice, - VkDisplayKHR display); - -VKAPI_ATTR VkResult VKAPI_CALL vkGetWinrtDisplayNV( - VkPhysicalDevice physicalDevice, - uint32_t deviceRelativeId, - VkDisplayKHR* pDisplay); -#endif - - #define VK_VALVE_mutable_descriptor_type 1 #define VK_VALVE_MUTABLE_DESCRIPTOR_TYPE_SPEC_VERSION 1 #define VK_VALVE_MUTABLE_DESCRIPTOR_TYPE_EXTENSION_NAME "VK_VALVE_mutable_descriptor_type" -typedef struct VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE { +typedef struct VkPhysicalDeviceMutableDescriptorTypeFeaturesEXT { VkStructureType sType; void* pNext; VkBool32 mutableDescriptorType; -} VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE; +} VkPhysicalDeviceMutableDescriptorTypeFeaturesEXT; -typedef struct VkMutableDescriptorTypeListVALVE { +typedef VkPhysicalDeviceMutableDescriptorTypeFeaturesEXT VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE; + +typedef struct VkMutableDescriptorTypeListEXT { uint32_t descriptorTypeCount; const VkDescriptorType* pDescriptorTypes; -} VkMutableDescriptorTypeListVALVE; +} VkMutableDescriptorTypeListEXT; -typedef struct VkMutableDescriptorTypeCreateInfoVALVE { - VkStructureType sType; - const void* pNext; - uint32_t mutableDescriptorTypeListCount; - const VkMutableDescriptorTypeListVALVE* pMutableDescriptorTypeLists; -} VkMutableDescriptorTypeCreateInfoVALVE; +typedef VkMutableDescriptorTypeListEXT VkMutableDescriptorTypeListVALVE; + +typedef struct VkMutableDescriptorTypeCreateInfoEXT { + VkStructureType sType; + const void* pNext; + uint32_t mutableDescriptorTypeListCount; + const VkMutableDescriptorTypeListEXT* pMutableDescriptorTypeLists; +} VkMutableDescriptorTypeCreateInfoEXT; + +typedef VkMutableDescriptorTypeCreateInfoEXT VkMutableDescriptorTypeCreateInfoVALVE; @@ -13585,6 +14898,38 @@ typedef struct VkPhysicalDeviceDrmPropertiesEXT { +#define VK_EXT_device_address_binding_report 1 +#define VK_EXT_DEVICE_ADDRESS_BINDING_REPORT_SPEC_VERSION 1 +#define VK_EXT_DEVICE_ADDRESS_BINDING_REPORT_EXTENSION_NAME "VK_EXT_device_address_binding_report" + +typedef enum VkDeviceAddressBindingTypeEXT { + VK_DEVICE_ADDRESS_BINDING_TYPE_BIND_EXT = 0, + VK_DEVICE_ADDRESS_BINDING_TYPE_UNBIND_EXT = 1, + VK_DEVICE_ADDRESS_BINDING_TYPE_MAX_ENUM_EXT = 0x7FFFFFFF +} VkDeviceAddressBindingTypeEXT; + +typedef enum VkDeviceAddressBindingFlagBitsEXT { + VK_DEVICE_ADDRESS_BINDING_INTERNAL_OBJECT_BIT_EXT = 0x00000001, + VK_DEVICE_ADDRESS_BINDING_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkDeviceAddressBindingFlagBitsEXT; +typedef VkFlags VkDeviceAddressBindingFlagsEXT; +typedef struct VkPhysicalDeviceAddressBindingReportFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 reportAddressBinding; +} VkPhysicalDeviceAddressBindingReportFeaturesEXT; + +typedef struct VkDeviceAddressBindingCallbackDataEXT { + VkStructureType sType; + void* pNext; + VkDeviceAddressBindingFlagsEXT flags; + VkDeviceAddress baseAddress; + VkDeviceSize size; + VkDeviceAddressBindingTypeEXT bindingType; +} VkDeviceAddressBindingCallbackDataEXT; + + + #define VK_EXT_depth_clip_control 1 #define VK_EXT_DEPTH_CLIP_CONTROL_SPEC_VERSION 1 #define VK_EXT_DEPTH_CLIP_CONTROL_EXTENSION_NAME "VK_EXT_depth_clip_control" @@ -13696,6 +15041,57 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryRemoteAddressNV( #endif +#define VK_EXT_pipeline_properties 1 +#define VK_EXT_PIPELINE_PROPERTIES_SPEC_VERSION 1 +#define VK_EXT_PIPELINE_PROPERTIES_EXTENSION_NAME "VK_EXT_pipeline_properties" +typedef VkPipelineInfoKHR VkPipelineInfoEXT; + +typedef struct VkPipelinePropertiesIdentifierEXT { + VkStructureType sType; + void* pNext; + uint8_t pipelineIdentifier[VK_UUID_SIZE]; +} VkPipelinePropertiesIdentifierEXT; + +typedef struct VkPhysicalDevicePipelinePropertiesFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 pipelinePropertiesIdentifier; +} VkPhysicalDevicePipelinePropertiesFeaturesEXT; + +typedef VkResult (VKAPI_PTR *PFN_vkGetPipelinePropertiesEXT)(VkDevice device, const VkPipelineInfoEXT* pPipelineInfo, VkBaseOutStructure* pPipelineProperties); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetPipelinePropertiesEXT( + VkDevice device, + const VkPipelineInfoEXT* pPipelineInfo, + VkBaseOutStructure* pPipelineProperties); +#endif + + +#define VK_EXT_multisampled_render_to_single_sampled 1 +#define VK_EXT_MULTISAMPLED_RENDER_TO_SINGLE_SAMPLED_SPEC_VERSION 1 +#define VK_EXT_MULTISAMPLED_RENDER_TO_SINGLE_SAMPLED_EXTENSION_NAME "VK_EXT_multisampled_render_to_single_sampled" +typedef struct VkPhysicalDeviceMultisampledRenderToSingleSampledFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 multisampledRenderToSingleSampled; +} VkPhysicalDeviceMultisampledRenderToSingleSampledFeaturesEXT; + +typedef struct VkSubpassResolvePerformanceQueryEXT { + VkStructureType sType; + void* pNext; + VkBool32 optimal; +} VkSubpassResolvePerformanceQueryEXT; + +typedef struct VkMultisampledRenderToSingleSampledInfoEXT { + VkStructureType sType; + const void* pNext; + VkBool32 multisampledRenderToSingleSampledEnable; + VkSampleCountFlagBits rasterizationSamples; +} VkMultisampledRenderToSingleSampledInfoEXT; + + + #define VK_EXT_extended_dynamic_state2 1 #define VK_EXT_EXTENDED_DYNAMIC_STATE_2_SPEC_VERSION 1 #define VK_EXT_EXTENDED_DYNAMIC_STATE_2_EXTENSION_NAME "VK_EXT_extended_dynamic_state2" @@ -13863,11 +15259,339 @@ typedef struct VkPhysicalDeviceImage2DViewOf3DFeaturesEXT { +#define VK_EXT_shader_tile_image 1 +#define VK_EXT_SHADER_TILE_IMAGE_SPEC_VERSION 1 +#define VK_EXT_SHADER_TILE_IMAGE_EXTENSION_NAME "VK_EXT_shader_tile_image" +typedef struct VkPhysicalDeviceShaderTileImageFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 shaderTileImageColorReadAccess; + VkBool32 shaderTileImageDepthReadAccess; + VkBool32 shaderTileImageStencilReadAccess; +} VkPhysicalDeviceShaderTileImageFeaturesEXT; + +typedef struct VkPhysicalDeviceShaderTileImagePropertiesEXT { + VkStructureType sType; + void* pNext; + VkBool32 shaderTileImageCoherentReadAccelerated; + VkBool32 shaderTileImageReadSampleFromPixelRateInvocation; + VkBool32 shaderTileImageReadFromHelperInvocation; +} VkPhysicalDeviceShaderTileImagePropertiesEXT; + + + +#define VK_EXT_opacity_micromap 1 +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkMicromapEXT) +#define VK_EXT_OPACITY_MICROMAP_SPEC_VERSION 2 +#define VK_EXT_OPACITY_MICROMAP_EXTENSION_NAME "VK_EXT_opacity_micromap" + +typedef enum VkMicromapTypeEXT { + VK_MICROMAP_TYPE_OPACITY_MICROMAP_EXT = 0, +#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_MICROMAP_TYPE_DISPLACEMENT_MICROMAP_NV = 1000397000, +#endif + VK_MICROMAP_TYPE_MAX_ENUM_EXT = 0x7FFFFFFF +} VkMicromapTypeEXT; + +typedef enum VkBuildMicromapModeEXT { + VK_BUILD_MICROMAP_MODE_BUILD_EXT = 0, + VK_BUILD_MICROMAP_MODE_MAX_ENUM_EXT = 0x7FFFFFFF +} VkBuildMicromapModeEXT; + +typedef enum VkCopyMicromapModeEXT { + VK_COPY_MICROMAP_MODE_CLONE_EXT = 0, + VK_COPY_MICROMAP_MODE_SERIALIZE_EXT = 1, + VK_COPY_MICROMAP_MODE_DESERIALIZE_EXT = 2, + VK_COPY_MICROMAP_MODE_COMPACT_EXT = 3, + VK_COPY_MICROMAP_MODE_MAX_ENUM_EXT = 0x7FFFFFFF +} VkCopyMicromapModeEXT; + +typedef enum VkOpacityMicromapFormatEXT { + VK_OPACITY_MICROMAP_FORMAT_2_STATE_EXT = 1, + VK_OPACITY_MICROMAP_FORMAT_4_STATE_EXT = 2, + VK_OPACITY_MICROMAP_FORMAT_MAX_ENUM_EXT = 0x7FFFFFFF +} VkOpacityMicromapFormatEXT; + +typedef enum VkOpacityMicromapSpecialIndexEXT { + VK_OPACITY_MICROMAP_SPECIAL_INDEX_FULLY_TRANSPARENT_EXT = -1, + VK_OPACITY_MICROMAP_SPECIAL_INDEX_FULLY_OPAQUE_EXT = -2, + VK_OPACITY_MICROMAP_SPECIAL_INDEX_FULLY_UNKNOWN_TRANSPARENT_EXT = -3, + VK_OPACITY_MICROMAP_SPECIAL_INDEX_FULLY_UNKNOWN_OPAQUE_EXT = -4, + VK_OPACITY_MICROMAP_SPECIAL_INDEX_MAX_ENUM_EXT = 0x7FFFFFFF +} VkOpacityMicromapSpecialIndexEXT; + +typedef enum VkAccelerationStructureCompatibilityKHR { + VK_ACCELERATION_STRUCTURE_COMPATIBILITY_COMPATIBLE_KHR = 0, + VK_ACCELERATION_STRUCTURE_COMPATIBILITY_INCOMPATIBLE_KHR = 1, + VK_ACCELERATION_STRUCTURE_COMPATIBILITY_MAX_ENUM_KHR = 0x7FFFFFFF +} VkAccelerationStructureCompatibilityKHR; + +typedef enum VkAccelerationStructureBuildTypeKHR { + VK_ACCELERATION_STRUCTURE_BUILD_TYPE_HOST_KHR = 0, + VK_ACCELERATION_STRUCTURE_BUILD_TYPE_DEVICE_KHR = 1, + VK_ACCELERATION_STRUCTURE_BUILD_TYPE_HOST_OR_DEVICE_KHR = 2, + VK_ACCELERATION_STRUCTURE_BUILD_TYPE_MAX_ENUM_KHR = 0x7FFFFFFF +} VkAccelerationStructureBuildTypeKHR; + +typedef enum VkBuildMicromapFlagBitsEXT { + VK_BUILD_MICROMAP_PREFER_FAST_TRACE_BIT_EXT = 0x00000001, + VK_BUILD_MICROMAP_PREFER_FAST_BUILD_BIT_EXT = 0x00000002, + VK_BUILD_MICROMAP_ALLOW_COMPACTION_BIT_EXT = 0x00000004, + VK_BUILD_MICROMAP_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkBuildMicromapFlagBitsEXT; +typedef VkFlags VkBuildMicromapFlagsEXT; + +typedef enum VkMicromapCreateFlagBitsEXT { + VK_MICROMAP_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_EXT = 0x00000001, + VK_MICROMAP_CREATE_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkMicromapCreateFlagBitsEXT; +typedef VkFlags VkMicromapCreateFlagsEXT; +typedef struct VkMicromapUsageEXT { + uint32_t count; + uint32_t subdivisionLevel; + uint32_t format; +} VkMicromapUsageEXT; + +typedef union VkDeviceOrHostAddressKHR { + VkDeviceAddress deviceAddress; + void* hostAddress; +} VkDeviceOrHostAddressKHR; + +typedef struct VkMicromapBuildInfoEXT { + VkStructureType sType; + const void* pNext; + VkMicromapTypeEXT type; + VkBuildMicromapFlagsEXT flags; + VkBuildMicromapModeEXT mode; + VkMicromapEXT dstMicromap; + uint32_t usageCountsCount; + const VkMicromapUsageEXT* pUsageCounts; + const VkMicromapUsageEXT* const* ppUsageCounts; + VkDeviceOrHostAddressConstKHR data; + VkDeviceOrHostAddressKHR scratchData; + VkDeviceOrHostAddressConstKHR triangleArray; + VkDeviceSize triangleArrayStride; +} VkMicromapBuildInfoEXT; + +typedef struct VkMicromapCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkMicromapCreateFlagsEXT createFlags; + VkBuffer buffer; + VkDeviceSize offset; + VkDeviceSize size; + VkMicromapTypeEXT type; + VkDeviceAddress deviceAddress; +} VkMicromapCreateInfoEXT; + +typedef struct VkPhysicalDeviceOpacityMicromapFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 micromap; + VkBool32 micromapCaptureReplay; + VkBool32 micromapHostCommands; +} VkPhysicalDeviceOpacityMicromapFeaturesEXT; + +typedef struct VkPhysicalDeviceOpacityMicromapPropertiesEXT { + VkStructureType sType; + void* pNext; + uint32_t maxOpacity2StateSubdivisionLevel; + uint32_t maxOpacity4StateSubdivisionLevel; +} VkPhysicalDeviceOpacityMicromapPropertiesEXT; + +typedef struct VkMicromapVersionInfoEXT { + VkStructureType sType; + const void* pNext; + const uint8_t* pVersionData; +} VkMicromapVersionInfoEXT; + +typedef struct VkCopyMicromapToMemoryInfoEXT { + VkStructureType sType; + const void* pNext; + VkMicromapEXT src; + VkDeviceOrHostAddressKHR dst; + VkCopyMicromapModeEXT mode; +} VkCopyMicromapToMemoryInfoEXT; + +typedef struct VkCopyMemoryToMicromapInfoEXT { + VkStructureType sType; + const void* pNext; + VkDeviceOrHostAddressConstKHR src; + VkMicromapEXT dst; + VkCopyMicromapModeEXT mode; +} VkCopyMemoryToMicromapInfoEXT; + +typedef struct VkCopyMicromapInfoEXT { + VkStructureType sType; + const void* pNext; + VkMicromapEXT src; + VkMicromapEXT dst; + VkCopyMicromapModeEXT mode; +} VkCopyMicromapInfoEXT; + +typedef struct VkMicromapBuildSizesInfoEXT { + VkStructureType sType; + const void* pNext; + VkDeviceSize micromapSize; + VkDeviceSize buildScratchSize; + VkBool32 discardable; +} VkMicromapBuildSizesInfoEXT; + +typedef struct VkAccelerationStructureTrianglesOpacityMicromapEXT { + VkStructureType sType; + void* pNext; + VkIndexType indexType; + VkDeviceOrHostAddressConstKHR indexBuffer; + VkDeviceSize indexStride; + uint32_t baseTriangle; + uint32_t usageCountsCount; + const VkMicromapUsageEXT* pUsageCounts; + const VkMicromapUsageEXT* const* ppUsageCounts; + VkMicromapEXT micromap; +} VkAccelerationStructureTrianglesOpacityMicromapEXT; + +typedef struct VkMicromapTriangleEXT { + uint32_t dataOffset; + uint16_t subdivisionLevel; + uint16_t format; +} VkMicromapTriangleEXT; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateMicromapEXT)(VkDevice device, const VkMicromapCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkMicromapEXT* pMicromap); +typedef void (VKAPI_PTR *PFN_vkDestroyMicromapEXT)(VkDevice device, VkMicromapEXT micromap, const VkAllocationCallbacks* pAllocator); +typedef void (VKAPI_PTR *PFN_vkCmdBuildMicromapsEXT)(VkCommandBuffer commandBuffer, uint32_t infoCount, const VkMicromapBuildInfoEXT* pInfos); +typedef VkResult (VKAPI_PTR *PFN_vkBuildMicromapsEXT)(VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount, const VkMicromapBuildInfoEXT* pInfos); +typedef VkResult (VKAPI_PTR *PFN_vkCopyMicromapEXT)(VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMicromapInfoEXT* pInfo); +typedef VkResult (VKAPI_PTR *PFN_vkCopyMicromapToMemoryEXT)(VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMicromapToMemoryInfoEXT* pInfo); +typedef VkResult (VKAPI_PTR *PFN_vkCopyMemoryToMicromapEXT)(VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToMicromapInfoEXT* pInfo); +typedef VkResult (VKAPI_PTR *PFN_vkWriteMicromapsPropertiesEXT)(VkDevice device, uint32_t micromapCount, const VkMicromapEXT* pMicromaps, VkQueryType queryType, size_t dataSize, void* pData, size_t stride); +typedef void (VKAPI_PTR *PFN_vkCmdCopyMicromapEXT)(VkCommandBuffer commandBuffer, const VkCopyMicromapInfoEXT* pInfo); +typedef void (VKAPI_PTR *PFN_vkCmdCopyMicromapToMemoryEXT)(VkCommandBuffer commandBuffer, const VkCopyMicromapToMemoryInfoEXT* pInfo); +typedef void (VKAPI_PTR *PFN_vkCmdCopyMemoryToMicromapEXT)(VkCommandBuffer commandBuffer, const VkCopyMemoryToMicromapInfoEXT* pInfo); +typedef void (VKAPI_PTR *PFN_vkCmdWriteMicromapsPropertiesEXT)(VkCommandBuffer commandBuffer, uint32_t micromapCount, const VkMicromapEXT* pMicromaps, VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery); +typedef void (VKAPI_PTR *PFN_vkGetDeviceMicromapCompatibilityEXT)(VkDevice device, const VkMicromapVersionInfoEXT* pVersionInfo, VkAccelerationStructureCompatibilityKHR* pCompatibility); +typedef void (VKAPI_PTR *PFN_vkGetMicromapBuildSizesEXT)(VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkMicromapBuildInfoEXT* pBuildInfo, VkMicromapBuildSizesInfoEXT* pSizeInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateMicromapEXT( + VkDevice device, + const VkMicromapCreateInfoEXT* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkMicromapEXT* pMicromap); + +VKAPI_ATTR void VKAPI_CALL vkDestroyMicromapEXT( + VkDevice device, + VkMicromapEXT micromap, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR void VKAPI_CALL vkCmdBuildMicromapsEXT( + VkCommandBuffer commandBuffer, + uint32_t infoCount, + const VkMicromapBuildInfoEXT* pInfos); + +VKAPI_ATTR VkResult VKAPI_CALL vkBuildMicromapsEXT( + VkDevice device, + VkDeferredOperationKHR deferredOperation, + uint32_t infoCount, + const VkMicromapBuildInfoEXT* pInfos); + +VKAPI_ATTR VkResult VKAPI_CALL vkCopyMicromapEXT( + VkDevice device, + VkDeferredOperationKHR deferredOperation, + const VkCopyMicromapInfoEXT* pInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkCopyMicromapToMemoryEXT( + VkDevice device, + VkDeferredOperationKHR deferredOperation, + const VkCopyMicromapToMemoryInfoEXT* pInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkCopyMemoryToMicromapEXT( + VkDevice device, + VkDeferredOperationKHR deferredOperation, + const VkCopyMemoryToMicromapInfoEXT* pInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkWriteMicromapsPropertiesEXT( + VkDevice device, + uint32_t micromapCount, + const VkMicromapEXT* pMicromaps, + VkQueryType queryType, + size_t dataSize, + void* pData, + size_t stride); + +VKAPI_ATTR void VKAPI_CALL vkCmdCopyMicromapEXT( + VkCommandBuffer commandBuffer, + const VkCopyMicromapInfoEXT* pInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdCopyMicromapToMemoryEXT( + VkCommandBuffer commandBuffer, + const VkCopyMicromapToMemoryInfoEXT* pInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdCopyMemoryToMicromapEXT( + VkCommandBuffer commandBuffer, + const VkCopyMemoryToMicromapInfoEXT* pInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdWriteMicromapsPropertiesEXT( + VkCommandBuffer commandBuffer, + uint32_t micromapCount, + const VkMicromapEXT* pMicromaps, + VkQueryType queryType, + VkQueryPool queryPool, + uint32_t firstQuery); + +VKAPI_ATTR void VKAPI_CALL vkGetDeviceMicromapCompatibilityEXT( + VkDevice device, + const VkMicromapVersionInfoEXT* pVersionInfo, + VkAccelerationStructureCompatibilityKHR* pCompatibility); + +VKAPI_ATTR void VKAPI_CALL vkGetMicromapBuildSizesEXT( + VkDevice device, + VkAccelerationStructureBuildTypeKHR buildType, + const VkMicromapBuildInfoEXT* pBuildInfo, + VkMicromapBuildSizesInfoEXT* pSizeInfo); +#endif + + #define VK_EXT_load_store_op_none 1 #define VK_EXT_LOAD_STORE_OP_NONE_SPEC_VERSION 1 #define VK_EXT_LOAD_STORE_OP_NONE_EXTENSION_NAME "VK_EXT_load_store_op_none" +#define VK_HUAWEI_cluster_culling_shader 1 +#define VK_HUAWEI_CLUSTER_CULLING_SHADER_SPEC_VERSION 2 +#define VK_HUAWEI_CLUSTER_CULLING_SHADER_EXTENSION_NAME "VK_HUAWEI_cluster_culling_shader" +typedef struct VkPhysicalDeviceClusterCullingShaderFeaturesHUAWEI { + VkStructureType sType; + void* pNext; + VkBool32 clustercullingShader; + VkBool32 multiviewClusterCullingShader; +} VkPhysicalDeviceClusterCullingShaderFeaturesHUAWEI; + +typedef struct VkPhysicalDeviceClusterCullingShaderPropertiesHUAWEI { + VkStructureType sType; + void* pNext; + uint32_t maxWorkGroupCount[3]; + uint32_t maxWorkGroupSize[3]; + uint32_t maxOutputClusterCount; + VkDeviceSize indirectBufferOffsetAlignment; +} VkPhysicalDeviceClusterCullingShaderPropertiesHUAWEI; + +typedef void (VKAPI_PTR *PFN_vkCmdDrawClusterHUAWEI)(VkCommandBuffer commandBuffer, uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ); +typedef void (VKAPI_PTR *PFN_vkCmdDrawClusterIndirectHUAWEI)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdDrawClusterHUAWEI( + VkCommandBuffer commandBuffer, + uint32_t groupCountX, + uint32_t groupCountY, + uint32_t groupCountZ); + +VKAPI_ATTR void VKAPI_CALL vkCmdDrawClusterIndirectHUAWEI( + VkCommandBuffer commandBuffer, + VkBuffer buffer, + VkDeviceSize offset); +#endif + + #define VK_EXT_border_color_swizzle 1 #define VK_EXT_BORDER_COLOR_SWIZZLE_SPEC_VERSION 1 #define VK_EXT_BORDER_COLOR_SWIZZLE_EXTENSION_NAME "VK_EXT_border_color_swizzle" @@ -13906,6 +15630,38 @@ VKAPI_ATTR void VKAPI_CALL vkSetDeviceMemoryPriorityEXT( #endif +#define VK_ARM_shader_core_properties 1 +#define VK_ARM_SHADER_CORE_PROPERTIES_SPEC_VERSION 1 +#define VK_ARM_SHADER_CORE_PROPERTIES_EXTENSION_NAME "VK_ARM_shader_core_properties" +typedef struct VkPhysicalDeviceShaderCorePropertiesARM { + VkStructureType sType; + void* pNext; + uint32_t pixelRate; + uint32_t texelRate; + uint32_t fmaRate; +} VkPhysicalDeviceShaderCorePropertiesARM; + + + +#define VK_EXT_image_sliced_view_of_3d 1 +#define VK_EXT_IMAGE_SLICED_VIEW_OF_3D_SPEC_VERSION 1 +#define VK_EXT_IMAGE_SLICED_VIEW_OF_3D_EXTENSION_NAME "VK_EXT_image_sliced_view_of_3d" +#define VK_REMAINING_3D_SLICES_EXT (~0U) +typedef struct VkPhysicalDeviceImageSlicedViewOf3DFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 imageSlicedViewOf3D; +} VkPhysicalDeviceImageSlicedViewOf3DFeaturesEXT; + +typedef struct VkImageViewSlicedCreateInfoEXT { + VkStructureType sType; + const void* pNext; + uint32_t sliceOffset; + uint32_t sliceCount; +} VkImageViewSlicedCreateInfoEXT; + + + #define VK_VALVE_descriptor_set_host_mapping 1 #define VK_VALVE_DESCRIPTOR_SET_HOST_MAPPING_SPEC_VERSION 1 #define VK_VALVE_DESCRIPTOR_SET_HOST_MAPPING_EXTENSION_NAME "VK_VALVE_descriptor_set_host_mapping" @@ -13945,6 +15701,28 @@ VKAPI_ATTR void VKAPI_CALL vkGetDescriptorSetHostMappingVALVE( #endif +#define VK_EXT_depth_clamp_zero_one 1 +#define VK_EXT_DEPTH_CLAMP_ZERO_ONE_SPEC_VERSION 1 +#define VK_EXT_DEPTH_CLAMP_ZERO_ONE_EXTENSION_NAME "VK_EXT_depth_clamp_zero_one" +typedef struct VkPhysicalDeviceDepthClampZeroOneFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 depthClampZeroOne; +} VkPhysicalDeviceDepthClampZeroOneFeaturesEXT; + + + +#define VK_EXT_non_seamless_cube_map 1 +#define VK_EXT_NON_SEAMLESS_CUBE_MAP_SPEC_VERSION 1 +#define VK_EXT_NON_SEAMLESS_CUBE_MAP_EXTENSION_NAME "VK_EXT_non_seamless_cube_map" +typedef struct VkPhysicalDeviceNonSeamlessCubeMapFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 nonSeamlessCubeMap; +} VkPhysicalDeviceNonSeamlessCubeMapFeaturesEXT; + + + #define VK_QCOM_fragment_density_map_offset 1 #define VK_QCOM_FRAGMENT_DENSITY_MAP_OFFSET_SPEC_VERSION 1 #define VK_QCOM_FRAGMENT_DENSITY_MAP_OFFSET_EXTENSION_NAME "VK_QCOM_fragment_density_map_offset" @@ -13969,6 +15747,104 @@ typedef struct VkSubpassFragmentDensityMapOffsetEndInfoQCOM { +#define VK_NV_copy_memory_indirect 1 +#define VK_NV_COPY_MEMORY_INDIRECT_SPEC_VERSION 1 +#define VK_NV_COPY_MEMORY_INDIRECT_EXTENSION_NAME "VK_NV_copy_memory_indirect" +typedef struct VkCopyMemoryIndirectCommandNV { + VkDeviceAddress srcAddress; + VkDeviceAddress dstAddress; + VkDeviceSize size; +} VkCopyMemoryIndirectCommandNV; + +typedef struct VkCopyMemoryToImageIndirectCommandNV { + VkDeviceAddress srcAddress; + uint32_t bufferRowLength; + uint32_t bufferImageHeight; + VkImageSubresourceLayers imageSubresource; + VkOffset3D imageOffset; + VkExtent3D imageExtent; +} VkCopyMemoryToImageIndirectCommandNV; + +typedef struct VkPhysicalDeviceCopyMemoryIndirectFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 indirectCopy; +} VkPhysicalDeviceCopyMemoryIndirectFeaturesNV; + +typedef struct VkPhysicalDeviceCopyMemoryIndirectPropertiesNV { + VkStructureType sType; + void* pNext; + VkQueueFlags supportedQueues; +} VkPhysicalDeviceCopyMemoryIndirectPropertiesNV; + +typedef void (VKAPI_PTR *PFN_vkCmdCopyMemoryIndirectNV)(VkCommandBuffer commandBuffer, VkDeviceAddress copyBufferAddress, uint32_t copyCount, uint32_t stride); +typedef void (VKAPI_PTR *PFN_vkCmdCopyMemoryToImageIndirectNV)(VkCommandBuffer commandBuffer, VkDeviceAddress copyBufferAddress, uint32_t copyCount, uint32_t stride, VkImage dstImage, VkImageLayout dstImageLayout, const VkImageSubresourceLayers* pImageSubresources); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdCopyMemoryIndirectNV( + VkCommandBuffer commandBuffer, + VkDeviceAddress copyBufferAddress, + uint32_t copyCount, + uint32_t stride); + +VKAPI_ATTR void VKAPI_CALL vkCmdCopyMemoryToImageIndirectNV( + VkCommandBuffer commandBuffer, + VkDeviceAddress copyBufferAddress, + uint32_t copyCount, + uint32_t stride, + VkImage dstImage, + VkImageLayout dstImageLayout, + const VkImageSubresourceLayers* pImageSubresources); +#endif + + +#define VK_NV_memory_decompression 1 +#define VK_NV_MEMORY_DECOMPRESSION_SPEC_VERSION 1 +#define VK_NV_MEMORY_DECOMPRESSION_EXTENSION_NAME "VK_NV_memory_decompression" + +// Flag bits for VkMemoryDecompressionMethodFlagBitsNV +typedef VkFlags64 VkMemoryDecompressionMethodFlagBitsNV; +static const VkMemoryDecompressionMethodFlagBitsNV VK_MEMORY_DECOMPRESSION_METHOD_GDEFLATE_1_0_BIT_NV = 0x00000001ULL; + +typedef VkFlags64 VkMemoryDecompressionMethodFlagsNV; +typedef struct VkDecompressMemoryRegionNV { + VkDeviceAddress srcAddress; + VkDeviceAddress dstAddress; + VkDeviceSize compressedSize; + VkDeviceSize decompressedSize; + VkMemoryDecompressionMethodFlagsNV decompressionMethod; +} VkDecompressMemoryRegionNV; + +typedef struct VkPhysicalDeviceMemoryDecompressionFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 memoryDecompression; +} VkPhysicalDeviceMemoryDecompressionFeaturesNV; + +typedef struct VkPhysicalDeviceMemoryDecompressionPropertiesNV { + VkStructureType sType; + void* pNext; + VkMemoryDecompressionMethodFlagsNV decompressionMethods; + uint64_t maxDecompressionIndirectCount; +} VkPhysicalDeviceMemoryDecompressionPropertiesNV; + +typedef void (VKAPI_PTR *PFN_vkCmdDecompressMemoryNV)(VkCommandBuffer commandBuffer, uint32_t decompressRegionCount, const VkDecompressMemoryRegionNV* pDecompressMemoryRegions); +typedef void (VKAPI_PTR *PFN_vkCmdDecompressMemoryIndirectCountNV)(VkCommandBuffer commandBuffer, VkDeviceAddress indirectCommandsAddress, VkDeviceAddress indirectCommandsCountAddress, uint32_t stride); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdDecompressMemoryNV( + VkCommandBuffer commandBuffer, + uint32_t decompressRegionCount, + const VkDecompressMemoryRegionNV* pDecompressMemoryRegions); + +VKAPI_ATTR void VKAPI_CALL vkCmdDecompressMemoryIndirectCountNV( + VkCommandBuffer commandBuffer, + VkDeviceAddress indirectCommandsAddress, + VkDeviceAddress indirectCommandsCountAddress, + uint32_t stride); +#endif + + #define VK_NV_linear_color_attachment 1 #define VK_NV_LINEAR_COLOR_ATTACHMENT_SPEC_VERSION 1 #define VK_NV_LINEAR_COLOR_ATTACHMENT_EXTENSION_NAME "VK_NV_linear_color_attachment" @@ -13981,12 +15857,852 @@ typedef struct VkPhysicalDeviceLinearColorAttachmentFeaturesNV { #define VK_GOOGLE_surfaceless_query 1 -#define VK_GOOGLE_SURFACELESS_QUERY_SPEC_VERSION 1 +#define VK_GOOGLE_SURFACELESS_QUERY_SPEC_VERSION 2 #define VK_GOOGLE_SURFACELESS_QUERY_EXTENSION_NAME "VK_GOOGLE_surfaceless_query" +#define VK_EXT_image_compression_control_swapchain 1 +#define VK_EXT_IMAGE_COMPRESSION_CONTROL_SWAPCHAIN_SPEC_VERSION 1 +#define VK_EXT_IMAGE_COMPRESSION_CONTROL_SWAPCHAIN_EXTENSION_NAME "VK_EXT_image_compression_control_swapchain" +typedef struct VkPhysicalDeviceImageCompressionControlSwapchainFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 imageCompressionControlSwapchain; +} VkPhysicalDeviceImageCompressionControlSwapchainFeaturesEXT; + + + +#define VK_QCOM_image_processing 1 +#define VK_QCOM_IMAGE_PROCESSING_SPEC_VERSION 1 +#define VK_QCOM_IMAGE_PROCESSING_EXTENSION_NAME "VK_QCOM_image_processing" +typedef struct VkImageViewSampleWeightCreateInfoQCOM { + VkStructureType sType; + const void* pNext; + VkOffset2D filterCenter; + VkExtent2D filterSize; + uint32_t numPhases; +} VkImageViewSampleWeightCreateInfoQCOM; + +typedef struct VkPhysicalDeviceImageProcessingFeaturesQCOM { + VkStructureType sType; + void* pNext; + VkBool32 textureSampleWeighted; + VkBool32 textureBoxFilter; + VkBool32 textureBlockMatch; +} VkPhysicalDeviceImageProcessingFeaturesQCOM; + +typedef struct VkPhysicalDeviceImageProcessingPropertiesQCOM { + VkStructureType sType; + void* pNext; + uint32_t maxWeightFilterPhases; + VkExtent2D maxWeightFilterDimension; + VkExtent2D maxBlockMatchRegion; + VkExtent2D maxBoxFilterBlockSize; +} VkPhysicalDeviceImageProcessingPropertiesQCOM; + + + +#define VK_EXT_extended_dynamic_state3 1 +#define VK_EXT_EXTENDED_DYNAMIC_STATE_3_SPEC_VERSION 2 +#define VK_EXT_EXTENDED_DYNAMIC_STATE_3_EXTENSION_NAME "VK_EXT_extended_dynamic_state3" +typedef struct VkPhysicalDeviceExtendedDynamicState3FeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 extendedDynamicState3TessellationDomainOrigin; + VkBool32 extendedDynamicState3DepthClampEnable; + VkBool32 extendedDynamicState3PolygonMode; + VkBool32 extendedDynamicState3RasterizationSamples; + VkBool32 extendedDynamicState3SampleMask; + VkBool32 extendedDynamicState3AlphaToCoverageEnable; + VkBool32 extendedDynamicState3AlphaToOneEnable; + VkBool32 extendedDynamicState3LogicOpEnable; + VkBool32 extendedDynamicState3ColorBlendEnable; + VkBool32 extendedDynamicState3ColorBlendEquation; + VkBool32 extendedDynamicState3ColorWriteMask; + VkBool32 extendedDynamicState3RasterizationStream; + VkBool32 extendedDynamicState3ConservativeRasterizationMode; + VkBool32 extendedDynamicState3ExtraPrimitiveOverestimationSize; + VkBool32 extendedDynamicState3DepthClipEnable; + VkBool32 extendedDynamicState3SampleLocationsEnable; + VkBool32 extendedDynamicState3ColorBlendAdvanced; + VkBool32 extendedDynamicState3ProvokingVertexMode; + VkBool32 extendedDynamicState3LineRasterizationMode; + VkBool32 extendedDynamicState3LineStippleEnable; + VkBool32 extendedDynamicState3DepthClipNegativeOneToOne; + VkBool32 extendedDynamicState3ViewportWScalingEnable; + VkBool32 extendedDynamicState3ViewportSwizzle; + VkBool32 extendedDynamicState3CoverageToColorEnable; + VkBool32 extendedDynamicState3CoverageToColorLocation; + VkBool32 extendedDynamicState3CoverageModulationMode; + VkBool32 extendedDynamicState3CoverageModulationTableEnable; + VkBool32 extendedDynamicState3CoverageModulationTable; + VkBool32 extendedDynamicState3CoverageReductionMode; + VkBool32 extendedDynamicState3RepresentativeFragmentTestEnable; + VkBool32 extendedDynamicState3ShadingRateImageEnable; +} VkPhysicalDeviceExtendedDynamicState3FeaturesEXT; + +typedef struct VkPhysicalDeviceExtendedDynamicState3PropertiesEXT { + VkStructureType sType; + void* pNext; + VkBool32 dynamicPrimitiveTopologyUnrestricted; +} VkPhysicalDeviceExtendedDynamicState3PropertiesEXT; + +typedef struct VkColorBlendEquationEXT { + VkBlendFactor srcColorBlendFactor; + VkBlendFactor dstColorBlendFactor; + VkBlendOp colorBlendOp; + VkBlendFactor srcAlphaBlendFactor; + VkBlendFactor dstAlphaBlendFactor; + VkBlendOp alphaBlendOp; +} VkColorBlendEquationEXT; + +typedef struct VkColorBlendAdvancedEXT { + VkBlendOp advancedBlendOp; + VkBool32 srcPremultiplied; + VkBool32 dstPremultiplied; + VkBlendOverlapEXT blendOverlap; + VkBool32 clampResults; +} VkColorBlendAdvancedEXT; + +typedef void (VKAPI_PTR *PFN_vkCmdSetTessellationDomainOriginEXT)(VkCommandBuffer commandBuffer, VkTessellationDomainOrigin domainOrigin); +typedef void (VKAPI_PTR *PFN_vkCmdSetDepthClampEnableEXT)(VkCommandBuffer commandBuffer, VkBool32 depthClampEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetPolygonModeEXT)(VkCommandBuffer commandBuffer, VkPolygonMode polygonMode); +typedef void (VKAPI_PTR *PFN_vkCmdSetRasterizationSamplesEXT)(VkCommandBuffer commandBuffer, VkSampleCountFlagBits rasterizationSamples); +typedef void (VKAPI_PTR *PFN_vkCmdSetSampleMaskEXT)(VkCommandBuffer commandBuffer, VkSampleCountFlagBits samples, const VkSampleMask* pSampleMask); +typedef void (VKAPI_PTR *PFN_vkCmdSetAlphaToCoverageEnableEXT)(VkCommandBuffer commandBuffer, VkBool32 alphaToCoverageEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetAlphaToOneEnableEXT)(VkCommandBuffer commandBuffer, VkBool32 alphaToOneEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetLogicOpEnableEXT)(VkCommandBuffer commandBuffer, VkBool32 logicOpEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetColorBlendEnableEXT)(VkCommandBuffer commandBuffer, uint32_t firstAttachment, uint32_t attachmentCount, const VkBool32* pColorBlendEnables); +typedef void (VKAPI_PTR *PFN_vkCmdSetColorBlendEquationEXT)(VkCommandBuffer commandBuffer, uint32_t firstAttachment, uint32_t attachmentCount, const VkColorBlendEquationEXT* pColorBlendEquations); +typedef void (VKAPI_PTR *PFN_vkCmdSetColorWriteMaskEXT)(VkCommandBuffer commandBuffer, uint32_t firstAttachment, uint32_t attachmentCount, const VkColorComponentFlags* pColorWriteMasks); +typedef void (VKAPI_PTR *PFN_vkCmdSetRasterizationStreamEXT)(VkCommandBuffer commandBuffer, uint32_t rasterizationStream); +typedef void (VKAPI_PTR *PFN_vkCmdSetConservativeRasterizationModeEXT)(VkCommandBuffer commandBuffer, VkConservativeRasterizationModeEXT conservativeRasterizationMode); +typedef void (VKAPI_PTR *PFN_vkCmdSetExtraPrimitiveOverestimationSizeEXT)(VkCommandBuffer commandBuffer, float extraPrimitiveOverestimationSize); +typedef void (VKAPI_PTR *PFN_vkCmdSetDepthClipEnableEXT)(VkCommandBuffer commandBuffer, VkBool32 depthClipEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetSampleLocationsEnableEXT)(VkCommandBuffer commandBuffer, VkBool32 sampleLocationsEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetColorBlendAdvancedEXT)(VkCommandBuffer commandBuffer, uint32_t firstAttachment, uint32_t attachmentCount, const VkColorBlendAdvancedEXT* pColorBlendAdvanced); +typedef void (VKAPI_PTR *PFN_vkCmdSetProvokingVertexModeEXT)(VkCommandBuffer commandBuffer, VkProvokingVertexModeEXT provokingVertexMode); +typedef void (VKAPI_PTR *PFN_vkCmdSetLineRasterizationModeEXT)(VkCommandBuffer commandBuffer, VkLineRasterizationModeEXT lineRasterizationMode); +typedef void (VKAPI_PTR *PFN_vkCmdSetLineStippleEnableEXT)(VkCommandBuffer commandBuffer, VkBool32 stippledLineEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetDepthClipNegativeOneToOneEXT)(VkCommandBuffer commandBuffer, VkBool32 negativeOneToOne); +typedef void (VKAPI_PTR *PFN_vkCmdSetViewportWScalingEnableNV)(VkCommandBuffer commandBuffer, VkBool32 viewportWScalingEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetViewportSwizzleNV)(VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount, const VkViewportSwizzleNV* pViewportSwizzles); +typedef void (VKAPI_PTR *PFN_vkCmdSetCoverageToColorEnableNV)(VkCommandBuffer commandBuffer, VkBool32 coverageToColorEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetCoverageToColorLocationNV)(VkCommandBuffer commandBuffer, uint32_t coverageToColorLocation); +typedef void (VKAPI_PTR *PFN_vkCmdSetCoverageModulationModeNV)(VkCommandBuffer commandBuffer, VkCoverageModulationModeNV coverageModulationMode); +typedef void (VKAPI_PTR *PFN_vkCmdSetCoverageModulationTableEnableNV)(VkCommandBuffer commandBuffer, VkBool32 coverageModulationTableEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetCoverageModulationTableNV)(VkCommandBuffer commandBuffer, uint32_t coverageModulationTableCount, const float* pCoverageModulationTable); +typedef void (VKAPI_PTR *PFN_vkCmdSetShadingRateImageEnableNV)(VkCommandBuffer commandBuffer, VkBool32 shadingRateImageEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetRepresentativeFragmentTestEnableNV)(VkCommandBuffer commandBuffer, VkBool32 representativeFragmentTestEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetCoverageReductionModeNV)(VkCommandBuffer commandBuffer, VkCoverageReductionModeNV coverageReductionMode); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdSetTessellationDomainOriginEXT( + VkCommandBuffer commandBuffer, + VkTessellationDomainOrigin domainOrigin); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthClampEnableEXT( + VkCommandBuffer commandBuffer, + VkBool32 depthClampEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetPolygonModeEXT( + VkCommandBuffer commandBuffer, + VkPolygonMode polygonMode); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetRasterizationSamplesEXT( + VkCommandBuffer commandBuffer, + VkSampleCountFlagBits rasterizationSamples); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetSampleMaskEXT( + VkCommandBuffer commandBuffer, + VkSampleCountFlagBits samples, + const VkSampleMask* pSampleMask); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetAlphaToCoverageEnableEXT( + VkCommandBuffer commandBuffer, + VkBool32 alphaToCoverageEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetAlphaToOneEnableEXT( + VkCommandBuffer commandBuffer, + VkBool32 alphaToOneEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetLogicOpEnableEXT( + VkCommandBuffer commandBuffer, + VkBool32 logicOpEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetColorBlendEnableEXT( + VkCommandBuffer commandBuffer, + uint32_t firstAttachment, + uint32_t attachmentCount, + const VkBool32* pColorBlendEnables); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetColorBlendEquationEXT( + VkCommandBuffer commandBuffer, + uint32_t firstAttachment, + uint32_t attachmentCount, + const VkColorBlendEquationEXT* pColorBlendEquations); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetColorWriteMaskEXT( + VkCommandBuffer commandBuffer, + uint32_t firstAttachment, + uint32_t attachmentCount, + const VkColorComponentFlags* pColorWriteMasks); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetRasterizationStreamEXT( + VkCommandBuffer commandBuffer, + uint32_t rasterizationStream); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetConservativeRasterizationModeEXT( + VkCommandBuffer commandBuffer, + VkConservativeRasterizationModeEXT conservativeRasterizationMode); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetExtraPrimitiveOverestimationSizeEXT( + VkCommandBuffer commandBuffer, + float extraPrimitiveOverestimationSize); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthClipEnableEXT( + VkCommandBuffer commandBuffer, + VkBool32 depthClipEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetSampleLocationsEnableEXT( + VkCommandBuffer commandBuffer, + VkBool32 sampleLocationsEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetColorBlendAdvancedEXT( + VkCommandBuffer commandBuffer, + uint32_t firstAttachment, + uint32_t attachmentCount, + const VkColorBlendAdvancedEXT* pColorBlendAdvanced); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetProvokingVertexModeEXT( + VkCommandBuffer commandBuffer, + VkProvokingVertexModeEXT provokingVertexMode); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetLineRasterizationModeEXT( + VkCommandBuffer commandBuffer, + VkLineRasterizationModeEXT lineRasterizationMode); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetLineStippleEnableEXT( + VkCommandBuffer commandBuffer, + VkBool32 stippledLineEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthClipNegativeOneToOneEXT( + VkCommandBuffer commandBuffer, + VkBool32 negativeOneToOne); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetViewportWScalingEnableNV( + VkCommandBuffer commandBuffer, + VkBool32 viewportWScalingEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetViewportSwizzleNV( + VkCommandBuffer commandBuffer, + uint32_t firstViewport, + uint32_t viewportCount, + const VkViewportSwizzleNV* pViewportSwizzles); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetCoverageToColorEnableNV( + VkCommandBuffer commandBuffer, + VkBool32 coverageToColorEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetCoverageToColorLocationNV( + VkCommandBuffer commandBuffer, + uint32_t coverageToColorLocation); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetCoverageModulationModeNV( + VkCommandBuffer commandBuffer, + VkCoverageModulationModeNV coverageModulationMode); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetCoverageModulationTableEnableNV( + VkCommandBuffer commandBuffer, + VkBool32 coverageModulationTableEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetCoverageModulationTableNV( + VkCommandBuffer commandBuffer, + uint32_t coverageModulationTableCount, + const float* pCoverageModulationTable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetShadingRateImageEnableNV( + VkCommandBuffer commandBuffer, + VkBool32 shadingRateImageEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetRepresentativeFragmentTestEnableNV( + VkCommandBuffer commandBuffer, + VkBool32 representativeFragmentTestEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetCoverageReductionModeNV( + VkCommandBuffer commandBuffer, + VkCoverageReductionModeNV coverageReductionMode); +#endif + + +#define VK_EXT_subpass_merge_feedback 1 +#define VK_EXT_SUBPASS_MERGE_FEEDBACK_SPEC_VERSION 2 +#define VK_EXT_SUBPASS_MERGE_FEEDBACK_EXTENSION_NAME "VK_EXT_subpass_merge_feedback" + +typedef enum VkSubpassMergeStatusEXT { + VK_SUBPASS_MERGE_STATUS_MERGED_EXT = 0, + VK_SUBPASS_MERGE_STATUS_DISALLOWED_EXT = 1, + VK_SUBPASS_MERGE_STATUS_NOT_MERGED_SIDE_EFFECTS_EXT = 2, + VK_SUBPASS_MERGE_STATUS_NOT_MERGED_SAMPLES_MISMATCH_EXT = 3, + VK_SUBPASS_MERGE_STATUS_NOT_MERGED_VIEWS_MISMATCH_EXT = 4, + VK_SUBPASS_MERGE_STATUS_NOT_MERGED_ALIASING_EXT = 5, + VK_SUBPASS_MERGE_STATUS_NOT_MERGED_DEPENDENCIES_EXT = 6, + VK_SUBPASS_MERGE_STATUS_NOT_MERGED_INCOMPATIBLE_INPUT_ATTACHMENT_EXT = 7, + VK_SUBPASS_MERGE_STATUS_NOT_MERGED_TOO_MANY_ATTACHMENTS_EXT = 8, + VK_SUBPASS_MERGE_STATUS_NOT_MERGED_INSUFFICIENT_STORAGE_EXT = 9, + VK_SUBPASS_MERGE_STATUS_NOT_MERGED_DEPTH_STENCIL_COUNT_EXT = 10, + VK_SUBPASS_MERGE_STATUS_NOT_MERGED_RESOLVE_ATTACHMENT_REUSE_EXT = 11, + VK_SUBPASS_MERGE_STATUS_NOT_MERGED_SINGLE_SUBPASS_EXT = 12, + VK_SUBPASS_MERGE_STATUS_NOT_MERGED_UNSPECIFIED_EXT = 13, + VK_SUBPASS_MERGE_STATUS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkSubpassMergeStatusEXT; +typedef struct VkPhysicalDeviceSubpassMergeFeedbackFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 subpassMergeFeedback; +} VkPhysicalDeviceSubpassMergeFeedbackFeaturesEXT; + +typedef struct VkRenderPassCreationControlEXT { + VkStructureType sType; + const void* pNext; + VkBool32 disallowMerging; +} VkRenderPassCreationControlEXT; + +typedef struct VkRenderPassCreationFeedbackInfoEXT { + uint32_t postMergeSubpassCount; +} VkRenderPassCreationFeedbackInfoEXT; + +typedef struct VkRenderPassCreationFeedbackCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkRenderPassCreationFeedbackInfoEXT* pRenderPassFeedback; +} VkRenderPassCreationFeedbackCreateInfoEXT; + +typedef struct VkRenderPassSubpassFeedbackInfoEXT { + VkSubpassMergeStatusEXT subpassMergeStatus; + char description[VK_MAX_DESCRIPTION_SIZE]; + uint32_t postMergeIndex; +} VkRenderPassSubpassFeedbackInfoEXT; + +typedef struct VkRenderPassSubpassFeedbackCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkRenderPassSubpassFeedbackInfoEXT* pSubpassFeedback; +} VkRenderPassSubpassFeedbackCreateInfoEXT; + + + +#define VK_LUNARG_direct_driver_loading 1 +#define VK_LUNARG_DIRECT_DRIVER_LOADING_SPEC_VERSION 1 +#define VK_LUNARG_DIRECT_DRIVER_LOADING_EXTENSION_NAME "VK_LUNARG_direct_driver_loading" + +typedef enum VkDirectDriverLoadingModeLUNARG { + VK_DIRECT_DRIVER_LOADING_MODE_EXCLUSIVE_LUNARG = 0, + VK_DIRECT_DRIVER_LOADING_MODE_INCLUSIVE_LUNARG = 1, + VK_DIRECT_DRIVER_LOADING_MODE_MAX_ENUM_LUNARG = 0x7FFFFFFF +} VkDirectDriverLoadingModeLUNARG; +typedef VkFlags VkDirectDriverLoadingFlagsLUNARG; +typedef PFN_vkVoidFunction (VKAPI_PTR *PFN_vkGetInstanceProcAddrLUNARG)( + VkInstance instance, const char* pName); + +typedef struct VkDirectDriverLoadingInfoLUNARG { + VkStructureType sType; + void* pNext; + VkDirectDriverLoadingFlagsLUNARG flags; + PFN_vkGetInstanceProcAddrLUNARG pfnGetInstanceProcAddr; +} VkDirectDriverLoadingInfoLUNARG; + +typedef struct VkDirectDriverLoadingListLUNARG { + VkStructureType sType; + void* pNext; + VkDirectDriverLoadingModeLUNARG mode; + uint32_t driverCount; + const VkDirectDriverLoadingInfoLUNARG* pDrivers; +} VkDirectDriverLoadingListLUNARG; + + + +#define VK_EXT_shader_module_identifier 1 +#define VK_MAX_SHADER_MODULE_IDENTIFIER_SIZE_EXT 32U +#define VK_EXT_SHADER_MODULE_IDENTIFIER_SPEC_VERSION 1 +#define VK_EXT_SHADER_MODULE_IDENTIFIER_EXTENSION_NAME "VK_EXT_shader_module_identifier" +typedef struct VkPhysicalDeviceShaderModuleIdentifierFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 shaderModuleIdentifier; +} VkPhysicalDeviceShaderModuleIdentifierFeaturesEXT; + +typedef struct VkPhysicalDeviceShaderModuleIdentifierPropertiesEXT { + VkStructureType sType; + void* pNext; + uint8_t shaderModuleIdentifierAlgorithmUUID[VK_UUID_SIZE]; +} VkPhysicalDeviceShaderModuleIdentifierPropertiesEXT; + +typedef struct VkPipelineShaderStageModuleIdentifierCreateInfoEXT { + VkStructureType sType; + const void* pNext; + uint32_t identifierSize; + const uint8_t* pIdentifier; +} VkPipelineShaderStageModuleIdentifierCreateInfoEXT; + +typedef struct VkShaderModuleIdentifierEXT { + VkStructureType sType; + void* pNext; + uint32_t identifierSize; + uint8_t identifier[VK_MAX_SHADER_MODULE_IDENTIFIER_SIZE_EXT]; +} VkShaderModuleIdentifierEXT; + +typedef void (VKAPI_PTR *PFN_vkGetShaderModuleIdentifierEXT)(VkDevice device, VkShaderModule shaderModule, VkShaderModuleIdentifierEXT* pIdentifier); +typedef void (VKAPI_PTR *PFN_vkGetShaderModuleCreateInfoIdentifierEXT)(VkDevice device, const VkShaderModuleCreateInfo* pCreateInfo, VkShaderModuleIdentifierEXT* pIdentifier); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkGetShaderModuleIdentifierEXT( + VkDevice device, + VkShaderModule shaderModule, + VkShaderModuleIdentifierEXT* pIdentifier); + +VKAPI_ATTR void VKAPI_CALL vkGetShaderModuleCreateInfoIdentifierEXT( + VkDevice device, + const VkShaderModuleCreateInfo* pCreateInfo, + VkShaderModuleIdentifierEXT* pIdentifier); +#endif + + +#define VK_EXT_rasterization_order_attachment_access 1 +#define VK_EXT_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_SPEC_VERSION 1 +#define VK_EXT_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_EXTENSION_NAME "VK_EXT_rasterization_order_attachment_access" + + +#define VK_NV_optical_flow 1 +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkOpticalFlowSessionNV) +#define VK_NV_OPTICAL_FLOW_SPEC_VERSION 1 +#define VK_NV_OPTICAL_FLOW_EXTENSION_NAME "VK_NV_optical_flow" + +typedef enum VkOpticalFlowPerformanceLevelNV { + VK_OPTICAL_FLOW_PERFORMANCE_LEVEL_UNKNOWN_NV = 0, + VK_OPTICAL_FLOW_PERFORMANCE_LEVEL_SLOW_NV = 1, + VK_OPTICAL_FLOW_PERFORMANCE_LEVEL_MEDIUM_NV = 2, + VK_OPTICAL_FLOW_PERFORMANCE_LEVEL_FAST_NV = 3, + VK_OPTICAL_FLOW_PERFORMANCE_LEVEL_MAX_ENUM_NV = 0x7FFFFFFF +} VkOpticalFlowPerformanceLevelNV; + +typedef enum VkOpticalFlowSessionBindingPointNV { + VK_OPTICAL_FLOW_SESSION_BINDING_POINT_UNKNOWN_NV = 0, + VK_OPTICAL_FLOW_SESSION_BINDING_POINT_INPUT_NV = 1, + VK_OPTICAL_FLOW_SESSION_BINDING_POINT_REFERENCE_NV = 2, + VK_OPTICAL_FLOW_SESSION_BINDING_POINT_HINT_NV = 3, + VK_OPTICAL_FLOW_SESSION_BINDING_POINT_FLOW_VECTOR_NV = 4, + VK_OPTICAL_FLOW_SESSION_BINDING_POINT_BACKWARD_FLOW_VECTOR_NV = 5, + VK_OPTICAL_FLOW_SESSION_BINDING_POINT_COST_NV = 6, + VK_OPTICAL_FLOW_SESSION_BINDING_POINT_BACKWARD_COST_NV = 7, + VK_OPTICAL_FLOW_SESSION_BINDING_POINT_GLOBAL_FLOW_NV = 8, + VK_OPTICAL_FLOW_SESSION_BINDING_POINT_MAX_ENUM_NV = 0x7FFFFFFF +} VkOpticalFlowSessionBindingPointNV; + +typedef enum VkOpticalFlowGridSizeFlagBitsNV { + VK_OPTICAL_FLOW_GRID_SIZE_UNKNOWN_NV = 0, + VK_OPTICAL_FLOW_GRID_SIZE_1X1_BIT_NV = 0x00000001, + VK_OPTICAL_FLOW_GRID_SIZE_2X2_BIT_NV = 0x00000002, + VK_OPTICAL_FLOW_GRID_SIZE_4X4_BIT_NV = 0x00000004, + VK_OPTICAL_FLOW_GRID_SIZE_8X8_BIT_NV = 0x00000008, + VK_OPTICAL_FLOW_GRID_SIZE_FLAG_BITS_MAX_ENUM_NV = 0x7FFFFFFF +} VkOpticalFlowGridSizeFlagBitsNV; +typedef VkFlags VkOpticalFlowGridSizeFlagsNV; + +typedef enum VkOpticalFlowUsageFlagBitsNV { + VK_OPTICAL_FLOW_USAGE_UNKNOWN_NV = 0, + VK_OPTICAL_FLOW_USAGE_INPUT_BIT_NV = 0x00000001, + VK_OPTICAL_FLOW_USAGE_OUTPUT_BIT_NV = 0x00000002, + VK_OPTICAL_FLOW_USAGE_HINT_BIT_NV = 0x00000004, + VK_OPTICAL_FLOW_USAGE_COST_BIT_NV = 0x00000008, + VK_OPTICAL_FLOW_USAGE_GLOBAL_FLOW_BIT_NV = 0x00000010, + VK_OPTICAL_FLOW_USAGE_FLAG_BITS_MAX_ENUM_NV = 0x7FFFFFFF +} VkOpticalFlowUsageFlagBitsNV; +typedef VkFlags VkOpticalFlowUsageFlagsNV; + +typedef enum VkOpticalFlowSessionCreateFlagBitsNV { + VK_OPTICAL_FLOW_SESSION_CREATE_ENABLE_HINT_BIT_NV = 0x00000001, + VK_OPTICAL_FLOW_SESSION_CREATE_ENABLE_COST_BIT_NV = 0x00000002, + VK_OPTICAL_FLOW_SESSION_CREATE_ENABLE_GLOBAL_FLOW_BIT_NV = 0x00000004, + VK_OPTICAL_FLOW_SESSION_CREATE_ALLOW_REGIONS_BIT_NV = 0x00000008, + VK_OPTICAL_FLOW_SESSION_CREATE_BOTH_DIRECTIONS_BIT_NV = 0x00000010, + VK_OPTICAL_FLOW_SESSION_CREATE_FLAG_BITS_MAX_ENUM_NV = 0x7FFFFFFF +} VkOpticalFlowSessionCreateFlagBitsNV; +typedef VkFlags VkOpticalFlowSessionCreateFlagsNV; + +typedef enum VkOpticalFlowExecuteFlagBitsNV { + VK_OPTICAL_FLOW_EXECUTE_DISABLE_TEMPORAL_HINTS_BIT_NV = 0x00000001, + VK_OPTICAL_FLOW_EXECUTE_FLAG_BITS_MAX_ENUM_NV = 0x7FFFFFFF +} VkOpticalFlowExecuteFlagBitsNV; +typedef VkFlags VkOpticalFlowExecuteFlagsNV; +typedef struct VkPhysicalDeviceOpticalFlowFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 opticalFlow; +} VkPhysicalDeviceOpticalFlowFeaturesNV; + +typedef struct VkPhysicalDeviceOpticalFlowPropertiesNV { + VkStructureType sType; + void* pNext; + VkOpticalFlowGridSizeFlagsNV supportedOutputGridSizes; + VkOpticalFlowGridSizeFlagsNV supportedHintGridSizes; + VkBool32 hintSupported; + VkBool32 costSupported; + VkBool32 bidirectionalFlowSupported; + VkBool32 globalFlowSupported; + uint32_t minWidth; + uint32_t minHeight; + uint32_t maxWidth; + uint32_t maxHeight; + uint32_t maxNumRegionsOfInterest; +} VkPhysicalDeviceOpticalFlowPropertiesNV; + +typedef struct VkOpticalFlowImageFormatInfoNV { + VkStructureType sType; + const void* pNext; + VkOpticalFlowUsageFlagsNV usage; +} VkOpticalFlowImageFormatInfoNV; + +typedef struct VkOpticalFlowImageFormatPropertiesNV { + VkStructureType sType; + const void* pNext; + VkFormat format; +} VkOpticalFlowImageFormatPropertiesNV; + +typedef struct VkOpticalFlowSessionCreateInfoNV { + VkStructureType sType; + void* pNext; + uint32_t width; + uint32_t height; + VkFormat imageFormat; + VkFormat flowVectorFormat; + VkFormat costFormat; + VkOpticalFlowGridSizeFlagsNV outputGridSize; + VkOpticalFlowGridSizeFlagsNV hintGridSize; + VkOpticalFlowPerformanceLevelNV performanceLevel; + VkOpticalFlowSessionCreateFlagsNV flags; +} VkOpticalFlowSessionCreateInfoNV; + +typedef struct VkOpticalFlowSessionCreatePrivateDataInfoNV { + VkStructureType sType; + void* pNext; + uint32_t id; + uint32_t size; + const void* pPrivateData; +} VkOpticalFlowSessionCreatePrivateDataInfoNV; + +typedef struct VkOpticalFlowExecuteInfoNV { + VkStructureType sType; + void* pNext; + VkOpticalFlowExecuteFlagsNV flags; + uint32_t regionCount; + const VkRect2D* pRegions; +} VkOpticalFlowExecuteInfoNV; + +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceOpticalFlowImageFormatsNV)(VkPhysicalDevice physicalDevice, const VkOpticalFlowImageFormatInfoNV* pOpticalFlowImageFormatInfo, uint32_t* pFormatCount, VkOpticalFlowImageFormatPropertiesNV* pImageFormatProperties); +typedef VkResult (VKAPI_PTR *PFN_vkCreateOpticalFlowSessionNV)(VkDevice device, const VkOpticalFlowSessionCreateInfoNV* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkOpticalFlowSessionNV* pSession); +typedef void (VKAPI_PTR *PFN_vkDestroyOpticalFlowSessionNV)(VkDevice device, VkOpticalFlowSessionNV session, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkBindOpticalFlowSessionImageNV)(VkDevice device, VkOpticalFlowSessionNV session, VkOpticalFlowSessionBindingPointNV bindingPoint, VkImageView view, VkImageLayout layout); +typedef void (VKAPI_PTR *PFN_vkCmdOpticalFlowExecuteNV)(VkCommandBuffer commandBuffer, VkOpticalFlowSessionNV session, const VkOpticalFlowExecuteInfoNV* pExecuteInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceOpticalFlowImageFormatsNV( + VkPhysicalDevice physicalDevice, + const VkOpticalFlowImageFormatInfoNV* pOpticalFlowImageFormatInfo, + uint32_t* pFormatCount, + VkOpticalFlowImageFormatPropertiesNV* pImageFormatProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateOpticalFlowSessionNV( + VkDevice device, + const VkOpticalFlowSessionCreateInfoNV* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkOpticalFlowSessionNV* pSession); + +VKAPI_ATTR void VKAPI_CALL vkDestroyOpticalFlowSessionNV( + VkDevice device, + VkOpticalFlowSessionNV session, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkBindOpticalFlowSessionImageNV( + VkDevice device, + VkOpticalFlowSessionNV session, + VkOpticalFlowSessionBindingPointNV bindingPoint, + VkImageView view, + VkImageLayout layout); + +VKAPI_ATTR void VKAPI_CALL vkCmdOpticalFlowExecuteNV( + VkCommandBuffer commandBuffer, + VkOpticalFlowSessionNV session, + const VkOpticalFlowExecuteInfoNV* pExecuteInfo); +#endif + + +#define VK_EXT_legacy_dithering 1 +#define VK_EXT_LEGACY_DITHERING_SPEC_VERSION 1 +#define VK_EXT_LEGACY_DITHERING_EXTENSION_NAME "VK_EXT_legacy_dithering" +typedef struct VkPhysicalDeviceLegacyDitheringFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 legacyDithering; +} VkPhysicalDeviceLegacyDitheringFeaturesEXT; + + + +#define VK_EXT_pipeline_protected_access 1 +#define VK_EXT_PIPELINE_PROTECTED_ACCESS_SPEC_VERSION 1 +#define VK_EXT_PIPELINE_PROTECTED_ACCESS_EXTENSION_NAME "VK_EXT_pipeline_protected_access" +typedef struct VkPhysicalDevicePipelineProtectedAccessFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 pipelineProtectedAccess; +} VkPhysicalDevicePipelineProtectedAccessFeaturesEXT; + + + +#define VK_EXT_shader_object 1 +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkShaderEXT) +#define VK_EXT_SHADER_OBJECT_SPEC_VERSION 1 +#define VK_EXT_SHADER_OBJECT_EXTENSION_NAME "VK_EXT_shader_object" + +typedef enum VkShaderCodeTypeEXT { + VK_SHADER_CODE_TYPE_BINARY_EXT = 0, + VK_SHADER_CODE_TYPE_SPIRV_EXT = 1, + VK_SHADER_CODE_TYPE_MAX_ENUM_EXT = 0x7FFFFFFF +} VkShaderCodeTypeEXT; + +typedef enum VkShaderCreateFlagBitsEXT { + VK_SHADER_CREATE_LINK_STAGE_BIT_EXT = 0x00000001, + VK_SHADER_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT = 0x00000002, + VK_SHADER_CREATE_REQUIRE_FULL_SUBGROUPS_BIT_EXT = 0x00000004, + VK_SHADER_CREATE_NO_TASK_SHADER_BIT_EXT = 0x00000008, + VK_SHADER_CREATE_DISPATCH_BASE_BIT_EXT = 0x00000010, + VK_SHADER_CREATE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_EXT = 0x00000020, + VK_SHADER_CREATE_FRAGMENT_DENSITY_MAP_ATTACHMENT_BIT_EXT = 0x00000040, + VK_SHADER_CREATE_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkShaderCreateFlagBitsEXT; +typedef VkFlags VkShaderCreateFlagsEXT; +typedef struct VkPhysicalDeviceShaderObjectFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 shaderObject; +} VkPhysicalDeviceShaderObjectFeaturesEXT; + +typedef struct VkPhysicalDeviceShaderObjectPropertiesEXT { + VkStructureType sType; + void* pNext; + uint8_t shaderBinaryUUID[VK_UUID_SIZE]; + uint32_t shaderBinaryVersion; +} VkPhysicalDeviceShaderObjectPropertiesEXT; + +typedef struct VkShaderCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkShaderCreateFlagsEXT flags; + VkShaderStageFlagBits stage; + VkShaderStageFlags nextStage; + VkShaderCodeTypeEXT codeType; + size_t codeSize; + const void* pCode; + const char* pName; + uint32_t setLayoutCount; + const VkDescriptorSetLayout* pSetLayouts; + uint32_t pushConstantRangeCount; + const VkPushConstantRange* pPushConstantRanges; + const VkSpecializationInfo* pSpecializationInfo; +} VkShaderCreateInfoEXT; + +typedef VkPipelineShaderStageRequiredSubgroupSizeCreateInfo VkShaderRequiredSubgroupSizeCreateInfoEXT; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateShadersEXT)(VkDevice device, uint32_t createInfoCount, const VkShaderCreateInfoEXT* pCreateInfos, const VkAllocationCallbacks* pAllocator, VkShaderEXT* pShaders); +typedef void (VKAPI_PTR *PFN_vkDestroyShaderEXT)(VkDevice device, VkShaderEXT shader, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkGetShaderBinaryDataEXT)(VkDevice device, VkShaderEXT shader, size_t* pDataSize, void* pData); +typedef void (VKAPI_PTR *PFN_vkCmdBindShadersEXT)(VkCommandBuffer commandBuffer, uint32_t stageCount, const VkShaderStageFlagBits* pStages, const VkShaderEXT* pShaders); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateShadersEXT( + VkDevice device, + uint32_t createInfoCount, + const VkShaderCreateInfoEXT* pCreateInfos, + const VkAllocationCallbacks* pAllocator, + VkShaderEXT* pShaders); + +VKAPI_ATTR void VKAPI_CALL vkDestroyShaderEXT( + VkDevice device, + VkShaderEXT shader, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetShaderBinaryDataEXT( + VkDevice device, + VkShaderEXT shader, + size_t* pDataSize, + void* pData); + +VKAPI_ATTR void VKAPI_CALL vkCmdBindShadersEXT( + VkCommandBuffer commandBuffer, + uint32_t stageCount, + const VkShaderStageFlagBits* pStages, + const VkShaderEXT* pShaders); +#endif + + +#define VK_QCOM_tile_properties 1 +#define VK_QCOM_TILE_PROPERTIES_SPEC_VERSION 1 +#define VK_QCOM_TILE_PROPERTIES_EXTENSION_NAME "VK_QCOM_tile_properties" +typedef struct VkPhysicalDeviceTilePropertiesFeaturesQCOM { + VkStructureType sType; + void* pNext; + VkBool32 tileProperties; +} VkPhysicalDeviceTilePropertiesFeaturesQCOM; + +typedef struct VkTilePropertiesQCOM { + VkStructureType sType; + void* pNext; + VkExtent3D tileSize; + VkExtent2D apronSize; + VkOffset2D origin; +} VkTilePropertiesQCOM; + +typedef VkResult (VKAPI_PTR *PFN_vkGetFramebufferTilePropertiesQCOM)(VkDevice device, VkFramebuffer framebuffer, uint32_t* pPropertiesCount, VkTilePropertiesQCOM* pProperties); +typedef VkResult (VKAPI_PTR *PFN_vkGetDynamicRenderingTilePropertiesQCOM)(VkDevice device, const VkRenderingInfo* pRenderingInfo, VkTilePropertiesQCOM* pProperties); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetFramebufferTilePropertiesQCOM( + VkDevice device, + VkFramebuffer framebuffer, + uint32_t* pPropertiesCount, + VkTilePropertiesQCOM* pProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetDynamicRenderingTilePropertiesQCOM( + VkDevice device, + const VkRenderingInfo* pRenderingInfo, + VkTilePropertiesQCOM* pProperties); +#endif + + +#define VK_SEC_amigo_profiling 1 +#define VK_SEC_AMIGO_PROFILING_SPEC_VERSION 1 +#define VK_SEC_AMIGO_PROFILING_EXTENSION_NAME "VK_SEC_amigo_profiling" +typedef struct VkPhysicalDeviceAmigoProfilingFeaturesSEC { + VkStructureType sType; + void* pNext; + VkBool32 amigoProfiling; +} VkPhysicalDeviceAmigoProfilingFeaturesSEC; + +typedef struct VkAmigoProfilingSubmitInfoSEC { + VkStructureType sType; + const void* pNext; + uint64_t firstDrawTimestamp; + uint64_t swapBufferTimestamp; +} VkAmigoProfilingSubmitInfoSEC; + + + +#define VK_QCOM_multiview_per_view_viewports 1 +#define VK_QCOM_MULTIVIEW_PER_VIEW_VIEWPORTS_SPEC_VERSION 1 +#define VK_QCOM_MULTIVIEW_PER_VIEW_VIEWPORTS_EXTENSION_NAME "VK_QCOM_multiview_per_view_viewports" +typedef struct VkPhysicalDeviceMultiviewPerViewViewportsFeaturesQCOM { + VkStructureType sType; + void* pNext; + VkBool32 multiviewPerViewViewports; +} VkPhysicalDeviceMultiviewPerViewViewportsFeaturesQCOM; + + + +#define VK_NV_ray_tracing_invocation_reorder 1 +#define VK_NV_RAY_TRACING_INVOCATION_REORDER_SPEC_VERSION 1 +#define VK_NV_RAY_TRACING_INVOCATION_REORDER_EXTENSION_NAME "VK_NV_ray_tracing_invocation_reorder" + +typedef enum VkRayTracingInvocationReorderModeNV { + VK_RAY_TRACING_INVOCATION_REORDER_MODE_NONE_NV = 0, + VK_RAY_TRACING_INVOCATION_REORDER_MODE_REORDER_NV = 1, + VK_RAY_TRACING_INVOCATION_REORDER_MODE_MAX_ENUM_NV = 0x7FFFFFFF +} VkRayTracingInvocationReorderModeNV; +typedef struct VkPhysicalDeviceRayTracingInvocationReorderPropertiesNV { + VkStructureType sType; + void* pNext; + VkRayTracingInvocationReorderModeNV rayTracingInvocationReorderReorderingHint; +} VkPhysicalDeviceRayTracingInvocationReorderPropertiesNV; + +typedef struct VkPhysicalDeviceRayTracingInvocationReorderFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 rayTracingInvocationReorder; +} VkPhysicalDeviceRayTracingInvocationReorderFeaturesNV; + + + +#define VK_EXT_mutable_descriptor_type 1 +#define VK_EXT_MUTABLE_DESCRIPTOR_TYPE_SPEC_VERSION 1 +#define VK_EXT_MUTABLE_DESCRIPTOR_TYPE_EXTENSION_NAME "VK_EXT_mutable_descriptor_type" + + +#define VK_ARM_shader_core_builtins 1 +#define VK_ARM_SHADER_CORE_BUILTINS_SPEC_VERSION 2 +#define VK_ARM_SHADER_CORE_BUILTINS_EXTENSION_NAME "VK_ARM_shader_core_builtins" +typedef struct VkPhysicalDeviceShaderCoreBuiltinsFeaturesARM { + VkStructureType sType; + void* pNext; + VkBool32 shaderCoreBuiltins; +} VkPhysicalDeviceShaderCoreBuiltinsFeaturesARM; + +typedef struct VkPhysicalDeviceShaderCoreBuiltinsPropertiesARM { + VkStructureType sType; + void* pNext; + uint64_t shaderCoreMask; + uint32_t shaderCoreCount; + uint32_t shaderWarpsPerCore; +} VkPhysicalDeviceShaderCoreBuiltinsPropertiesARM; + + + +#define VK_EXT_pipeline_library_group_handles 1 +#define VK_EXT_PIPELINE_LIBRARY_GROUP_HANDLES_SPEC_VERSION 1 +#define VK_EXT_PIPELINE_LIBRARY_GROUP_HANDLES_EXTENSION_NAME "VK_EXT_pipeline_library_group_handles" +typedef struct VkPhysicalDevicePipelineLibraryGroupHandlesFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 pipelineLibraryGroupHandles; +} VkPhysicalDevicePipelineLibraryGroupHandlesFeaturesEXT; + + + +#define VK_QCOM_multiview_per_view_render_areas 1 +#define VK_QCOM_MULTIVIEW_PER_VIEW_RENDER_AREAS_SPEC_VERSION 1 +#define VK_QCOM_MULTIVIEW_PER_VIEW_RENDER_AREAS_EXTENSION_NAME "VK_QCOM_multiview_per_view_render_areas" +typedef struct VkPhysicalDeviceMultiviewPerViewRenderAreasFeaturesQCOM { + VkStructureType sType; + void* pNext; + VkBool32 multiviewPerViewRenderAreas; +} VkPhysicalDeviceMultiviewPerViewRenderAreasFeaturesQCOM; + +typedef struct VkMultiviewPerViewRenderAreasRenderPassBeginInfoQCOM { + VkStructureType sType; + const void* pNext; + uint32_t perViewRenderAreaCount; + const VkRect2D* pPerViewRenderAreas; +} VkMultiviewPerViewRenderAreasRenderPassBeginInfoQCOM; + + + +#define VK_EXT_attachment_feedback_loop_dynamic_state 1 +#define VK_EXT_ATTACHMENT_FEEDBACK_LOOP_DYNAMIC_STATE_SPEC_VERSION 1 +#define VK_EXT_ATTACHMENT_FEEDBACK_LOOP_DYNAMIC_STATE_EXTENSION_NAME "VK_EXT_attachment_feedback_loop_dynamic_state" +typedef struct VkPhysicalDeviceAttachmentFeedbackLoopDynamicStateFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 attachmentFeedbackLoopDynamicState; +} VkPhysicalDeviceAttachmentFeedbackLoopDynamicStateFeaturesEXT; + +typedef void (VKAPI_PTR *PFN_vkCmdSetAttachmentFeedbackLoopEnableEXT)(VkCommandBuffer commandBuffer, VkImageAspectFlags aspectMask); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdSetAttachmentFeedbackLoopEnableEXT( + VkCommandBuffer commandBuffer, + VkImageAspectFlags aspectMask); +#endif + + #define VK_KHR_acceleration_structure 1 -VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkAccelerationStructureKHR) #define VK_KHR_ACCELERATION_STRUCTURE_SPEC_VERSION 13 #define VK_KHR_ACCELERATION_STRUCTURE_EXTENSION_NAME "VK_KHR_acceleration_structure" @@ -13996,30 +16712,13 @@ typedef enum VkBuildAccelerationStructureModeKHR { VK_BUILD_ACCELERATION_STRUCTURE_MODE_MAX_ENUM_KHR = 0x7FFFFFFF } VkBuildAccelerationStructureModeKHR; -typedef enum VkAccelerationStructureBuildTypeKHR { - VK_ACCELERATION_STRUCTURE_BUILD_TYPE_HOST_KHR = 0, - VK_ACCELERATION_STRUCTURE_BUILD_TYPE_DEVICE_KHR = 1, - VK_ACCELERATION_STRUCTURE_BUILD_TYPE_HOST_OR_DEVICE_KHR = 2, - VK_ACCELERATION_STRUCTURE_BUILD_TYPE_MAX_ENUM_KHR = 0x7FFFFFFF -} VkAccelerationStructureBuildTypeKHR; - -typedef enum VkAccelerationStructureCompatibilityKHR { - VK_ACCELERATION_STRUCTURE_COMPATIBILITY_COMPATIBLE_KHR = 0, - VK_ACCELERATION_STRUCTURE_COMPATIBILITY_INCOMPATIBLE_KHR = 1, - VK_ACCELERATION_STRUCTURE_COMPATIBILITY_MAX_ENUM_KHR = 0x7FFFFFFF -} VkAccelerationStructureCompatibilityKHR; - typedef enum VkAccelerationStructureCreateFlagBitsKHR { VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR = 0x00000001, + VK_ACCELERATION_STRUCTURE_CREATE_DESCRIPTOR_BUFFER_CAPTURE_REPLAY_BIT_EXT = 0x00000008, VK_ACCELERATION_STRUCTURE_CREATE_MOTION_BIT_NV = 0x00000004, VK_ACCELERATION_STRUCTURE_CREATE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF } VkAccelerationStructureCreateFlagBitsKHR; typedef VkFlags VkAccelerationStructureCreateFlagsKHR; -typedef union VkDeviceOrHostAddressKHR { - VkDeviceAddress deviceAddress; - void* hostAddress; -} VkDeviceOrHostAddressKHR; - typedef struct VkAccelerationStructureBuildRangeInfoKHR { uint32_t primitiveCount; uint32_t primitiveOffset; @@ -14424,6 +17123,87 @@ typedef struct VkPhysicalDeviceRayQueryFeaturesKHR { } VkPhysicalDeviceRayQueryFeaturesKHR; + +#define VK_EXT_mesh_shader 1 +#define VK_EXT_MESH_SHADER_SPEC_VERSION 1 +#define VK_EXT_MESH_SHADER_EXTENSION_NAME "VK_EXT_mesh_shader" +typedef struct VkPhysicalDeviceMeshShaderFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 taskShader; + VkBool32 meshShader; + VkBool32 multiviewMeshShader; + VkBool32 primitiveFragmentShadingRateMeshShader; + VkBool32 meshShaderQueries; +} VkPhysicalDeviceMeshShaderFeaturesEXT; + +typedef struct VkPhysicalDeviceMeshShaderPropertiesEXT { + VkStructureType sType; + void* pNext; + uint32_t maxTaskWorkGroupTotalCount; + uint32_t maxTaskWorkGroupCount[3]; + uint32_t maxTaskWorkGroupInvocations; + uint32_t maxTaskWorkGroupSize[3]; + uint32_t maxTaskPayloadSize; + uint32_t maxTaskSharedMemorySize; + uint32_t maxTaskPayloadAndSharedMemorySize; + uint32_t maxMeshWorkGroupTotalCount; + uint32_t maxMeshWorkGroupCount[3]; + uint32_t maxMeshWorkGroupInvocations; + uint32_t maxMeshWorkGroupSize[3]; + uint32_t maxMeshSharedMemorySize; + uint32_t maxMeshPayloadAndSharedMemorySize; + uint32_t maxMeshOutputMemorySize; + uint32_t maxMeshPayloadAndOutputMemorySize; + uint32_t maxMeshOutputComponents; + uint32_t maxMeshOutputVertices; + uint32_t maxMeshOutputPrimitives; + uint32_t maxMeshOutputLayers; + uint32_t maxMeshMultiviewViewCount; + uint32_t meshOutputPerVertexGranularity; + uint32_t meshOutputPerPrimitiveGranularity; + uint32_t maxPreferredTaskWorkGroupInvocations; + uint32_t maxPreferredMeshWorkGroupInvocations; + VkBool32 prefersLocalInvocationVertexOutput; + VkBool32 prefersLocalInvocationPrimitiveOutput; + VkBool32 prefersCompactVertexOutput; + VkBool32 prefersCompactPrimitiveOutput; +} VkPhysicalDeviceMeshShaderPropertiesEXT; + +typedef struct VkDrawMeshTasksIndirectCommandEXT { + uint32_t groupCountX; + uint32_t groupCountY; + uint32_t groupCountZ; +} VkDrawMeshTasksIndirectCommandEXT; + +typedef void (VKAPI_PTR *PFN_vkCmdDrawMeshTasksEXT)(VkCommandBuffer commandBuffer, uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ); +typedef void (VKAPI_PTR *PFN_vkCmdDrawMeshTasksIndirectEXT)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride); +typedef void (VKAPI_PTR *PFN_vkCmdDrawMeshTasksIndirectCountEXT)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, uint32_t stride); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdDrawMeshTasksEXT( + VkCommandBuffer commandBuffer, + uint32_t groupCountX, + uint32_t groupCountY, + uint32_t groupCountZ); + +VKAPI_ATTR void VKAPI_CALL vkCmdDrawMeshTasksIndirectEXT( + VkCommandBuffer commandBuffer, + VkBuffer buffer, + VkDeviceSize offset, + uint32_t drawCount, + uint32_t stride); + +VKAPI_ATTR void VKAPI_CALL vkCmdDrawMeshTasksIndirectCountEXT( + VkCommandBuffer commandBuffer, + VkBuffer buffer, + VkDeviceSize offset, + VkBuffer countBuffer, + VkDeviceSize countBufferOffset, + uint32_t maxDrawCount, + uint32_t stride); +#endif + #ifdef __cplusplus } #endif diff --git a/vendor/vulkan/_gen/vulkan_ios.h b/vendor/vulkan/_gen/vulkan_ios.h index 579220543..8c6d9e72a 100644 --- a/vendor/vulkan/_gen/vulkan_ios.h +++ b/vendor/vulkan/_gen/vulkan_ios.h @@ -2,7 +2,7 @@ #define VULKAN_IOS_H_ 1 /* -** Copyright 2015-2022 The Khronos Group Inc. +** Copyright 2015-2023 The Khronos Group Inc. ** ** SPDX-License-Identifier: Apache-2.0 */ diff --git a/vendor/vulkan/_gen/vulkan_macos.h b/vendor/vulkan/_gen/vulkan_macos.h index 8e197c7cf..3310e11ab 100644 --- a/vendor/vulkan/_gen/vulkan_macos.h +++ b/vendor/vulkan/_gen/vulkan_macos.h @@ -2,7 +2,7 @@ #define VULKAN_MACOS_H_ 1 /* -** Copyright 2015-2022 The Khronos Group Inc. +** Copyright 2015-2023 The Khronos Group Inc. ** ** SPDX-License-Identifier: Apache-2.0 */ diff --git a/vendor/vulkan/_gen/vulkan_metal.h b/vendor/vulkan/_gen/vulkan_metal.h index 3631f1200..7127651c1 100644 --- a/vendor/vulkan/_gen/vulkan_metal.h +++ b/vendor/vulkan/_gen/vulkan_metal.h @@ -2,7 +2,7 @@ #define VULKAN_METAL_H_ 1 /* -** Copyright 2015-2022 The Khronos Group Inc. +** Copyright 2015-2023 The Khronos Group Inc. ** ** SPDX-License-Identifier: Apache-2.0 */ @@ -20,7 +20,6 @@ extern "C" { #define VK_EXT_metal_surface 1 - #ifdef __OBJC__ @class CAMetalLayer; #else @@ -47,6 +46,146 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateMetalSurfaceEXT( VkSurfaceKHR* pSurface); #endif + +#define VK_EXT_metal_objects 1 +#ifdef __OBJC__ +@protocol MTLDevice; +typedef id MTLDevice_id; +#else +typedef void* MTLDevice_id; +#endif + +#ifdef __OBJC__ +@protocol MTLCommandQueue; +typedef id MTLCommandQueue_id; +#else +typedef void* MTLCommandQueue_id; +#endif + +#ifdef __OBJC__ +@protocol MTLBuffer; +typedef id MTLBuffer_id; +#else +typedef void* MTLBuffer_id; +#endif + +#ifdef __OBJC__ +@protocol MTLTexture; +typedef id MTLTexture_id; +#else +typedef void* MTLTexture_id; +#endif + +typedef struct __IOSurface* IOSurfaceRef; +#ifdef __OBJC__ +@protocol MTLSharedEvent; +typedef id MTLSharedEvent_id; +#else +typedef void* MTLSharedEvent_id; +#endif + +#define VK_EXT_METAL_OBJECTS_SPEC_VERSION 1 +#define VK_EXT_METAL_OBJECTS_EXTENSION_NAME "VK_EXT_metal_objects" + +typedef enum VkExportMetalObjectTypeFlagBitsEXT { + VK_EXPORT_METAL_OBJECT_TYPE_METAL_DEVICE_BIT_EXT = 0x00000001, + VK_EXPORT_METAL_OBJECT_TYPE_METAL_COMMAND_QUEUE_BIT_EXT = 0x00000002, + VK_EXPORT_METAL_OBJECT_TYPE_METAL_BUFFER_BIT_EXT = 0x00000004, + VK_EXPORT_METAL_OBJECT_TYPE_METAL_TEXTURE_BIT_EXT = 0x00000008, + VK_EXPORT_METAL_OBJECT_TYPE_METAL_IOSURFACE_BIT_EXT = 0x00000010, + VK_EXPORT_METAL_OBJECT_TYPE_METAL_SHARED_EVENT_BIT_EXT = 0x00000020, + VK_EXPORT_METAL_OBJECT_TYPE_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkExportMetalObjectTypeFlagBitsEXT; +typedef VkFlags VkExportMetalObjectTypeFlagsEXT; +typedef struct VkExportMetalObjectCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkExportMetalObjectTypeFlagBitsEXT exportObjectType; +} VkExportMetalObjectCreateInfoEXT; + +typedef struct VkExportMetalObjectsInfoEXT { + VkStructureType sType; + const void* pNext; +} VkExportMetalObjectsInfoEXT; + +typedef struct VkExportMetalDeviceInfoEXT { + VkStructureType sType; + const void* pNext; + MTLDevice_id mtlDevice; +} VkExportMetalDeviceInfoEXT; + +typedef struct VkExportMetalCommandQueueInfoEXT { + VkStructureType sType; + const void* pNext; + VkQueue queue; + MTLCommandQueue_id mtlCommandQueue; +} VkExportMetalCommandQueueInfoEXT; + +typedef struct VkExportMetalBufferInfoEXT { + VkStructureType sType; + const void* pNext; + VkDeviceMemory memory; + MTLBuffer_id mtlBuffer; +} VkExportMetalBufferInfoEXT; + +typedef struct VkImportMetalBufferInfoEXT { + VkStructureType sType; + const void* pNext; + MTLBuffer_id mtlBuffer; +} VkImportMetalBufferInfoEXT; + +typedef struct VkExportMetalTextureInfoEXT { + VkStructureType sType; + const void* pNext; + VkImage image; + VkImageView imageView; + VkBufferView bufferView; + VkImageAspectFlagBits plane; + MTLTexture_id mtlTexture; +} VkExportMetalTextureInfoEXT; + +typedef struct VkImportMetalTextureInfoEXT { + VkStructureType sType; + const void* pNext; + VkImageAspectFlagBits plane; + MTLTexture_id mtlTexture; +} VkImportMetalTextureInfoEXT; + +typedef struct VkExportMetalIOSurfaceInfoEXT { + VkStructureType sType; + const void* pNext; + VkImage image; + IOSurfaceRef ioSurface; +} VkExportMetalIOSurfaceInfoEXT; + +typedef struct VkImportMetalIOSurfaceInfoEXT { + VkStructureType sType; + const void* pNext; + IOSurfaceRef ioSurface; +} VkImportMetalIOSurfaceInfoEXT; + +typedef struct VkExportMetalSharedEventInfoEXT { + VkStructureType sType; + const void* pNext; + VkSemaphore semaphore; + VkEvent event; + MTLSharedEvent_id mtlSharedEvent; +} VkExportMetalSharedEventInfoEXT; + +typedef struct VkImportMetalSharedEventInfoEXT { + VkStructureType sType; + const void* pNext; + MTLSharedEvent_id mtlSharedEvent; +} VkImportMetalSharedEventInfoEXT; + +typedef void (VKAPI_PTR *PFN_vkExportMetalObjectsEXT)(VkDevice device, VkExportMetalObjectsInfoEXT* pMetalObjectsInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkExportMetalObjectsEXT( + VkDevice device, + VkExportMetalObjectsInfoEXT* pMetalObjectsInfo); +#endif + #ifdef __cplusplus } #endif diff --git a/vendor/vulkan/_gen/vulkan_video_codec_h264std.h b/vendor/vulkan/_gen/vulkan_video_codec_h264std.h new file mode 100644 index 000000000..21c7b667f --- /dev/null +++ b/vendor/vulkan/_gen/vulkan_video_codec_h264std.h @@ -0,0 +1,310 @@ +#ifndef VULKAN_VIDEO_CODEC_H264STD_H_ +#define VULKAN_VIDEO_CODEC_H264STD_H_ 1 + +/* +** Copyright 2015-2023 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +#define vulkan_video_codec_h264std 1 +#include +#define STD_VIDEO_H264_CPB_CNT_LIST_SIZE 32 +#define STD_VIDEO_H264_SCALING_LIST_4X4_NUM_LISTS 6 +#define STD_VIDEO_H264_SCALING_LIST_4X4_NUM_ELEMENTS 16 +#define STD_VIDEO_H264_SCALING_LIST_8X8_NUM_LISTS 6 +#define STD_VIDEO_H264_SCALING_LIST_8X8_NUM_ELEMENTS 64 +#define STD_VIDEO_H264_MAX_NUM_LIST_REF 32 +#define STD_VIDEO_H264_MAX_CHROMA_PLANES 2 + +typedef enum StdVideoH264ChromaFormatIdc { + STD_VIDEO_H264_CHROMA_FORMAT_IDC_MONOCHROME = 0, + STD_VIDEO_H264_CHROMA_FORMAT_IDC_420 = 1, + STD_VIDEO_H264_CHROMA_FORMAT_IDC_422 = 2, + STD_VIDEO_H264_CHROMA_FORMAT_IDC_444 = 3, + STD_VIDEO_H264_CHROMA_FORMAT_IDC_INVALID = 0x7FFFFFFF, + STD_VIDEO_H264_CHROMA_FORMAT_IDC_MAX_ENUM = 0x7FFFFFFF +} StdVideoH264ChromaFormatIdc; + +typedef enum StdVideoH264ProfileIdc { + STD_VIDEO_H264_PROFILE_IDC_BASELINE = 66, + STD_VIDEO_H264_PROFILE_IDC_MAIN = 77, + STD_VIDEO_H264_PROFILE_IDC_HIGH = 100, + STD_VIDEO_H264_PROFILE_IDC_HIGH_444_PREDICTIVE = 244, + STD_VIDEO_H264_PROFILE_IDC_INVALID = 0x7FFFFFFF, + STD_VIDEO_H264_PROFILE_IDC_MAX_ENUM = 0x7FFFFFFF +} StdVideoH264ProfileIdc; + +typedef enum StdVideoH264LevelIdc { + STD_VIDEO_H264_LEVEL_IDC_1_0 = 0, + STD_VIDEO_H264_LEVEL_IDC_1_1 = 1, + STD_VIDEO_H264_LEVEL_IDC_1_2 = 2, + STD_VIDEO_H264_LEVEL_IDC_1_3 = 3, + STD_VIDEO_H264_LEVEL_IDC_2_0 = 4, + STD_VIDEO_H264_LEVEL_IDC_2_1 = 5, + STD_VIDEO_H264_LEVEL_IDC_2_2 = 6, + STD_VIDEO_H264_LEVEL_IDC_3_0 = 7, + STD_VIDEO_H264_LEVEL_IDC_3_1 = 8, + STD_VIDEO_H264_LEVEL_IDC_3_2 = 9, + STD_VIDEO_H264_LEVEL_IDC_4_0 = 10, + STD_VIDEO_H264_LEVEL_IDC_4_1 = 11, + STD_VIDEO_H264_LEVEL_IDC_4_2 = 12, + STD_VIDEO_H264_LEVEL_IDC_5_0 = 13, + STD_VIDEO_H264_LEVEL_IDC_5_1 = 14, + STD_VIDEO_H264_LEVEL_IDC_5_2 = 15, + STD_VIDEO_H264_LEVEL_IDC_6_0 = 16, + STD_VIDEO_H264_LEVEL_IDC_6_1 = 17, + STD_VIDEO_H264_LEVEL_IDC_6_2 = 18, + STD_VIDEO_H264_LEVEL_IDC_INVALID = 0x7FFFFFFF, + STD_VIDEO_H264_LEVEL_IDC_MAX_ENUM = 0x7FFFFFFF +} StdVideoH264LevelIdc; + +typedef enum StdVideoH264PocType { + STD_VIDEO_H264_POC_TYPE_0 = 0, + STD_VIDEO_H264_POC_TYPE_1 = 1, + STD_VIDEO_H264_POC_TYPE_2 = 2, + STD_VIDEO_H264_POC_TYPE_INVALID = 0x7FFFFFFF, + STD_VIDEO_H264_POC_TYPE_MAX_ENUM = 0x7FFFFFFF +} StdVideoH264PocType; + +typedef enum StdVideoH264AspectRatioIdc { + STD_VIDEO_H264_ASPECT_RATIO_IDC_UNSPECIFIED = 0, + STD_VIDEO_H264_ASPECT_RATIO_IDC_SQUARE = 1, + STD_VIDEO_H264_ASPECT_RATIO_IDC_12_11 = 2, + STD_VIDEO_H264_ASPECT_RATIO_IDC_10_11 = 3, + STD_VIDEO_H264_ASPECT_RATIO_IDC_16_11 = 4, + STD_VIDEO_H264_ASPECT_RATIO_IDC_40_33 = 5, + STD_VIDEO_H264_ASPECT_RATIO_IDC_24_11 = 6, + STD_VIDEO_H264_ASPECT_RATIO_IDC_20_11 = 7, + STD_VIDEO_H264_ASPECT_RATIO_IDC_32_11 = 8, + STD_VIDEO_H264_ASPECT_RATIO_IDC_80_33 = 9, + STD_VIDEO_H264_ASPECT_RATIO_IDC_18_11 = 10, + STD_VIDEO_H264_ASPECT_RATIO_IDC_15_11 = 11, + STD_VIDEO_H264_ASPECT_RATIO_IDC_64_33 = 12, + STD_VIDEO_H264_ASPECT_RATIO_IDC_160_99 = 13, + STD_VIDEO_H264_ASPECT_RATIO_IDC_4_3 = 14, + STD_VIDEO_H264_ASPECT_RATIO_IDC_3_2 = 15, + STD_VIDEO_H264_ASPECT_RATIO_IDC_2_1 = 16, + STD_VIDEO_H264_ASPECT_RATIO_IDC_EXTENDED_SAR = 255, + STD_VIDEO_H264_ASPECT_RATIO_IDC_INVALID = 0x7FFFFFFF, + STD_VIDEO_H264_ASPECT_RATIO_IDC_MAX_ENUM = 0x7FFFFFFF +} StdVideoH264AspectRatioIdc; + +typedef enum StdVideoH264WeightedBipredIdc { + STD_VIDEO_H264_WEIGHTED_BIPRED_IDC_DEFAULT = 0, + STD_VIDEO_H264_WEIGHTED_BIPRED_IDC_EXPLICIT = 1, + STD_VIDEO_H264_WEIGHTED_BIPRED_IDC_IMPLICIT = 2, + STD_VIDEO_H264_WEIGHTED_BIPRED_IDC_INVALID = 0x7FFFFFFF, + STD_VIDEO_H264_WEIGHTED_BIPRED_IDC_MAX_ENUM = 0x7FFFFFFF +} StdVideoH264WeightedBipredIdc; + +typedef enum StdVideoH264ModificationOfPicNumsIdc { + STD_VIDEO_H264_MODIFICATION_OF_PIC_NUMS_IDC_SHORT_TERM_SUBTRACT = 0, + STD_VIDEO_H264_MODIFICATION_OF_PIC_NUMS_IDC_SHORT_TERM_ADD = 1, + STD_VIDEO_H264_MODIFICATION_OF_PIC_NUMS_IDC_LONG_TERM = 2, + STD_VIDEO_H264_MODIFICATION_OF_PIC_NUMS_IDC_END = 3, + STD_VIDEO_H264_MODIFICATION_OF_PIC_NUMS_IDC_INVALID = 0x7FFFFFFF, + STD_VIDEO_H264_MODIFICATION_OF_PIC_NUMS_IDC_MAX_ENUM = 0x7FFFFFFF +} StdVideoH264ModificationOfPicNumsIdc; + +typedef enum StdVideoH264MemMgmtControlOp { + STD_VIDEO_H264_MEM_MGMT_CONTROL_OP_END = 0, + STD_VIDEO_H264_MEM_MGMT_CONTROL_OP_UNMARK_SHORT_TERM = 1, + STD_VIDEO_H264_MEM_MGMT_CONTROL_OP_UNMARK_LONG_TERM = 2, + STD_VIDEO_H264_MEM_MGMT_CONTROL_OP_MARK_LONG_TERM = 3, + STD_VIDEO_H264_MEM_MGMT_CONTROL_OP_SET_MAX_LONG_TERM_INDEX = 4, + STD_VIDEO_H264_MEM_MGMT_CONTROL_OP_UNMARK_ALL = 5, + STD_VIDEO_H264_MEM_MGMT_CONTROL_OP_MARK_CURRENT_AS_LONG_TERM = 6, + STD_VIDEO_H264_MEM_MGMT_CONTROL_OP_INVALID = 0x7FFFFFFF, + STD_VIDEO_H264_MEM_MGMT_CONTROL_OP_MAX_ENUM = 0x7FFFFFFF +} StdVideoH264MemMgmtControlOp; + +typedef enum StdVideoH264CabacInitIdc { + STD_VIDEO_H264_CABAC_INIT_IDC_0 = 0, + STD_VIDEO_H264_CABAC_INIT_IDC_1 = 1, + STD_VIDEO_H264_CABAC_INIT_IDC_2 = 2, + STD_VIDEO_H264_CABAC_INIT_IDC_INVALID = 0x7FFFFFFF, + STD_VIDEO_H264_CABAC_INIT_IDC_MAX_ENUM = 0x7FFFFFFF +} StdVideoH264CabacInitIdc; + +typedef enum StdVideoH264DisableDeblockingFilterIdc { + STD_VIDEO_H264_DISABLE_DEBLOCKING_FILTER_IDC_DISABLED = 0, + STD_VIDEO_H264_DISABLE_DEBLOCKING_FILTER_IDC_ENABLED = 1, + STD_VIDEO_H264_DISABLE_DEBLOCKING_FILTER_IDC_PARTIAL = 2, + STD_VIDEO_H264_DISABLE_DEBLOCKING_FILTER_IDC_INVALID = 0x7FFFFFFF, + STD_VIDEO_H264_DISABLE_DEBLOCKING_FILTER_IDC_MAX_ENUM = 0x7FFFFFFF +} StdVideoH264DisableDeblockingFilterIdc; + +typedef enum StdVideoH264SliceType { + STD_VIDEO_H264_SLICE_TYPE_P = 0, + STD_VIDEO_H264_SLICE_TYPE_B = 1, + STD_VIDEO_H264_SLICE_TYPE_I = 2, + STD_VIDEO_H264_SLICE_TYPE_INVALID = 0x7FFFFFFF, + STD_VIDEO_H264_SLICE_TYPE_MAX_ENUM = 0x7FFFFFFF +} StdVideoH264SliceType; + +typedef enum StdVideoH264PictureType { + STD_VIDEO_H264_PICTURE_TYPE_P = 0, + STD_VIDEO_H264_PICTURE_TYPE_B = 1, + STD_VIDEO_H264_PICTURE_TYPE_I = 2, + STD_VIDEO_H264_PICTURE_TYPE_IDR = 5, + STD_VIDEO_H264_PICTURE_TYPE_INVALID = 0x7FFFFFFF, + STD_VIDEO_H264_PICTURE_TYPE_MAX_ENUM = 0x7FFFFFFF +} StdVideoH264PictureType; + +typedef enum StdVideoH264NonVclNaluType { + STD_VIDEO_H264_NON_VCL_NALU_TYPE_SPS = 0, + STD_VIDEO_H264_NON_VCL_NALU_TYPE_PPS = 1, + STD_VIDEO_H264_NON_VCL_NALU_TYPE_AUD = 2, + STD_VIDEO_H264_NON_VCL_NALU_TYPE_PREFIX = 3, + STD_VIDEO_H264_NON_VCL_NALU_TYPE_END_OF_SEQUENCE = 4, + STD_VIDEO_H264_NON_VCL_NALU_TYPE_END_OF_STREAM = 5, + STD_VIDEO_H264_NON_VCL_NALU_TYPE_PRECODED = 6, + STD_VIDEO_H264_NON_VCL_NALU_TYPE_INVALID = 0x7FFFFFFF, + STD_VIDEO_H264_NON_VCL_NALU_TYPE_MAX_ENUM = 0x7FFFFFFF +} StdVideoH264NonVclNaluType; +typedef struct StdVideoH264SpsVuiFlags { + uint32_t aspect_ratio_info_present_flag : 1; + uint32_t overscan_info_present_flag : 1; + uint32_t overscan_appropriate_flag : 1; + uint32_t video_signal_type_present_flag : 1; + uint32_t video_full_range_flag : 1; + uint32_t color_description_present_flag : 1; + uint32_t chroma_loc_info_present_flag : 1; + uint32_t timing_info_present_flag : 1; + uint32_t fixed_frame_rate_flag : 1; + uint32_t bitstream_restriction_flag : 1; + uint32_t nal_hrd_parameters_present_flag : 1; + uint32_t vcl_hrd_parameters_present_flag : 1; +} StdVideoH264SpsVuiFlags; + +typedef struct StdVideoH264HrdParameters { + uint8_t cpb_cnt_minus1; + uint8_t bit_rate_scale; + uint8_t cpb_size_scale; + uint8_t reserved1; + uint32_t bit_rate_value_minus1[STD_VIDEO_H264_CPB_CNT_LIST_SIZE]; + uint32_t cpb_size_value_minus1[STD_VIDEO_H264_CPB_CNT_LIST_SIZE]; + uint8_t cbr_flag[STD_VIDEO_H264_CPB_CNT_LIST_SIZE]; + uint32_t initial_cpb_removal_delay_length_minus1; + uint32_t cpb_removal_delay_length_minus1; + uint32_t dpb_output_delay_length_minus1; + uint32_t time_offset_length; +} StdVideoH264HrdParameters; + +typedef struct StdVideoH264SequenceParameterSetVui { + StdVideoH264SpsVuiFlags flags; + StdVideoH264AspectRatioIdc aspect_ratio_idc; + uint16_t sar_width; + uint16_t sar_height; + uint8_t video_format; + uint8_t colour_primaries; + uint8_t transfer_characteristics; + uint8_t matrix_coefficients; + uint32_t num_units_in_tick; + uint32_t time_scale; + uint8_t max_num_reorder_frames; + uint8_t max_dec_frame_buffering; + uint8_t chroma_sample_loc_type_top_field; + uint8_t chroma_sample_loc_type_bottom_field; + uint32_t reserved1; + const StdVideoH264HrdParameters* pHrdParameters; +} StdVideoH264SequenceParameterSetVui; + +typedef struct StdVideoH264SpsFlags { + uint32_t constraint_set0_flag : 1; + uint32_t constraint_set1_flag : 1; + uint32_t constraint_set2_flag : 1; + uint32_t constraint_set3_flag : 1; + uint32_t constraint_set4_flag : 1; + uint32_t constraint_set5_flag : 1; + uint32_t direct_8x8_inference_flag : 1; + uint32_t mb_adaptive_frame_field_flag : 1; + uint32_t frame_mbs_only_flag : 1; + uint32_t delta_pic_order_always_zero_flag : 1; + uint32_t separate_colour_plane_flag : 1; + uint32_t gaps_in_frame_num_value_allowed_flag : 1; + uint32_t qpprime_y_zero_transform_bypass_flag : 1; + uint32_t frame_cropping_flag : 1; + uint32_t seq_scaling_matrix_present_flag : 1; + uint32_t vui_parameters_present_flag : 1; +} StdVideoH264SpsFlags; + +typedef struct StdVideoH264ScalingLists { + uint16_t scaling_list_present_mask; + uint16_t use_default_scaling_matrix_mask; + uint8_t ScalingList4x4[STD_VIDEO_H264_SCALING_LIST_4X4_NUM_LISTS][STD_VIDEO_H264_SCALING_LIST_4X4_NUM_ELEMENTS]; + uint8_t ScalingList8x8[STD_VIDEO_H264_SCALING_LIST_8X8_NUM_LISTS][STD_VIDEO_H264_SCALING_LIST_8X8_NUM_ELEMENTS]; +} StdVideoH264ScalingLists; + +typedef struct StdVideoH264SequenceParameterSet { + StdVideoH264SpsFlags flags; + StdVideoH264ProfileIdc profile_idc; + StdVideoH264LevelIdc level_idc; + StdVideoH264ChromaFormatIdc chroma_format_idc; + uint8_t seq_parameter_set_id; + uint8_t bit_depth_luma_minus8; + uint8_t bit_depth_chroma_minus8; + uint8_t log2_max_frame_num_minus4; + StdVideoH264PocType pic_order_cnt_type; + int32_t offset_for_non_ref_pic; + int32_t offset_for_top_to_bottom_field; + uint8_t log2_max_pic_order_cnt_lsb_minus4; + uint8_t num_ref_frames_in_pic_order_cnt_cycle; + uint8_t max_num_ref_frames; + uint8_t reserved1; + uint32_t pic_width_in_mbs_minus1; + uint32_t pic_height_in_map_units_minus1; + uint32_t frame_crop_left_offset; + uint32_t frame_crop_right_offset; + uint32_t frame_crop_top_offset; + uint32_t frame_crop_bottom_offset; + uint32_t reserved2; + const int32_t* pOffsetForRefFrame; + const StdVideoH264ScalingLists* pScalingLists; + const StdVideoH264SequenceParameterSetVui* pSequenceParameterSetVui; +} StdVideoH264SequenceParameterSet; + +typedef struct StdVideoH264PpsFlags { + uint32_t transform_8x8_mode_flag : 1; + uint32_t redundant_pic_cnt_present_flag : 1; + uint32_t constrained_intra_pred_flag : 1; + uint32_t deblocking_filter_control_present_flag : 1; + uint32_t weighted_pred_flag : 1; + uint32_t bottom_field_pic_order_in_frame_present_flag : 1; + uint32_t entropy_coding_mode_flag : 1; + uint32_t pic_scaling_matrix_present_flag : 1; +} StdVideoH264PpsFlags; + +typedef struct StdVideoH264PictureParameterSet { + StdVideoH264PpsFlags flags; + uint8_t seq_parameter_set_id; + uint8_t pic_parameter_set_id; + uint8_t num_ref_idx_l0_default_active_minus1; + uint8_t num_ref_idx_l1_default_active_minus1; + StdVideoH264WeightedBipredIdc weighted_bipred_idc; + int8_t pic_init_qp_minus26; + int8_t pic_init_qs_minus26; + int8_t chroma_qp_index_offset; + int8_t second_chroma_qp_index_offset; + const StdVideoH264ScalingLists* pScalingLists; +} StdVideoH264PictureParameterSet; + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/vendor/vulkan/_gen/vulkan_video_codec_h264std_decode.h b/vendor/vulkan/_gen/vulkan_video_codec_h264std_decode.h new file mode 100644 index 000000000..f7eb8edbd --- /dev/null +++ b/vendor/vulkan/_gen/vulkan_video_codec_h264std_decode.h @@ -0,0 +1,75 @@ +#ifndef VULKAN_VIDEO_CODEC_H264STD_DECODE_H_ +#define VULKAN_VIDEO_CODEC_H264STD_DECODE_H_ 1 + +/* +** Copyright 2015-2023 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +#define vulkan_video_codec_h264std_decode 1 + +#define VK_STD_VULKAN_VIDEO_CODEC_H264_DECODE_API_VERSION_1_0_0 VK_MAKE_VIDEO_STD_VERSION(1, 0, 0) + +#define STD_VIDEO_DECODE_H264_FIELD_ORDER_COUNT_LIST_SIZE 2 +#define VK_STD_VULKAN_VIDEO_CODEC_H264_DECODE_SPEC_VERSION VK_STD_VULKAN_VIDEO_CODEC_H264_DECODE_API_VERSION_1_0_0 +#define VK_STD_VULKAN_VIDEO_CODEC_H264_DECODE_EXTENSION_NAME "VK_STD_vulkan_video_codec_h264_decode" + +typedef enum StdVideoDecodeH264FieldOrderCount { + STD_VIDEO_DECODE_H264_FIELD_ORDER_COUNT_TOP = 0, + STD_VIDEO_DECODE_H264_FIELD_ORDER_COUNT_BOTTOM = 1, + STD_VIDEO_DECODE_H264_FIELD_ORDER_COUNT_INVALID = 0x7FFFFFFF, + STD_VIDEO_DECODE_H264_FIELD_ORDER_COUNT_MAX_ENUM = 0x7FFFFFFF +} StdVideoDecodeH264FieldOrderCount; +typedef struct StdVideoDecodeH264PictureInfoFlags { + uint32_t field_pic_flag : 1; + uint32_t is_intra : 1; + uint32_t IdrPicFlag : 1; + uint32_t bottom_field_flag : 1; + uint32_t is_reference : 1; + uint32_t complementary_field_pair : 1; +} StdVideoDecodeH264PictureInfoFlags; + +typedef struct StdVideoDecodeH264PictureInfo { + StdVideoDecodeH264PictureInfoFlags flags; + uint8_t seq_parameter_set_id; + uint8_t pic_parameter_set_id; + uint8_t reserved1; + uint8_t reserved2; + uint16_t frame_num; + uint16_t idr_pic_id; + int32_t PicOrderCnt[STD_VIDEO_DECODE_H264_FIELD_ORDER_COUNT_LIST_SIZE]; +} StdVideoDecodeH264PictureInfo; + +typedef struct StdVideoDecodeH264ReferenceInfoFlags { + uint32_t top_field_flag : 1; + uint32_t bottom_field_flag : 1; + uint32_t used_for_long_term_reference : 1; + uint32_t is_non_existing : 1; +} StdVideoDecodeH264ReferenceInfoFlags; + +typedef struct StdVideoDecodeH264ReferenceInfo { + StdVideoDecodeH264ReferenceInfoFlags flags; + uint16_t FrameNum; + uint16_t reserved; + int32_t PicOrderCnt[STD_VIDEO_DECODE_H264_FIELD_ORDER_COUNT_LIST_SIZE]; +} StdVideoDecodeH264ReferenceInfo; + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/vendor/vulkan/_gen/vulkan_video_codec_h265std.h b/vendor/vulkan/_gen/vulkan_video_codec_h265std.h new file mode 100644 index 000000000..4233bdc89 --- /dev/null +++ b/vendor/vulkan/_gen/vulkan_video_codec_h265std.h @@ -0,0 +1,443 @@ +#ifndef VULKAN_VIDEO_CODEC_H265STD_H_ +#define VULKAN_VIDEO_CODEC_H265STD_H_ 1 + +/* +** Copyright 2015-2023 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +#define vulkan_video_codec_h265std 1 +#define STD_VIDEO_H265_SUBLAYERS_LIST_SIZE 7 +#define STD_VIDEO_H265_CPB_CNT_LIST_SIZE 32 +#define STD_VIDEO_H265_SCALING_LIST_4X4_NUM_LISTS 6 +#define STD_VIDEO_H265_SCALING_LIST_4X4_NUM_ELEMENTS 16 +#define STD_VIDEO_H265_SCALING_LIST_8X8_NUM_LISTS 6 +#define STD_VIDEO_H265_SCALING_LIST_8X8_NUM_ELEMENTS 64 +#define STD_VIDEO_H265_SCALING_LIST_16X16_NUM_LISTS 6 +#define STD_VIDEO_H265_SCALING_LIST_16X16_NUM_ELEMENTS 64 +#define STD_VIDEO_H265_SCALING_LIST_32X32_NUM_LISTS 2 +#define STD_VIDEO_H265_SCALING_LIST_32X32_NUM_ELEMENTS 64 +#define STD_VIDEO_H265_PREDICTOR_PALETTE_COMPONENTS_LIST_SIZE 3 +#define STD_VIDEO_H265_PREDICTOR_PALETTE_COMP_ENTRIES_LIST_SIZE 128 +#define STD_VIDEO_H265_MAX_DPB_SIZE 16 +#define STD_VIDEO_H265_MAX_LONG_TERM_REF_PICS_SPS 32 +#define STD_VIDEO_H265_CHROMA_QP_OFFSET_LIST_SIZE 6 +#define STD_VIDEO_H265_CHROMA_QP_OFFSET_TILE_COLS_LIST_SIZE 19 +#define STD_VIDEO_H265_CHROMA_QP_OFFSET_TILE_ROWS_LIST_SIZE 21 +#define STD_VIDEO_H265_MAX_NUM_LIST_REF 15 +#define STD_VIDEO_H265_MAX_CHROMA_PLANES 2 +#define STD_VIDEO_H265_MAX_SHORT_TERM_REF_PIC_SETS 64 +#define STD_VIDEO_H265_MAX_LONG_TERM_PICS 16 +#define STD_VIDEO_H265_MAX_DELTA_POC 48 + +typedef enum StdVideoH265ChromaFormatIdc { + STD_VIDEO_H265_CHROMA_FORMAT_IDC_MONOCHROME = 0, + STD_VIDEO_H265_CHROMA_FORMAT_IDC_420 = 1, + STD_VIDEO_H265_CHROMA_FORMAT_IDC_422 = 2, + STD_VIDEO_H265_CHROMA_FORMAT_IDC_444 = 3, + STD_VIDEO_H265_CHROMA_FORMAT_IDC_INVALID = 0x7FFFFFFF, + STD_VIDEO_H265_CHROMA_FORMAT_IDC_MAX_ENUM = 0x7FFFFFFF +} StdVideoH265ChromaFormatIdc; + +typedef enum StdVideoH265ProfileIdc { + STD_VIDEO_H265_PROFILE_IDC_MAIN = 1, + STD_VIDEO_H265_PROFILE_IDC_MAIN_10 = 2, + STD_VIDEO_H265_PROFILE_IDC_MAIN_STILL_PICTURE = 3, + STD_VIDEO_H265_PROFILE_IDC_FORMAT_RANGE_EXTENSIONS = 4, + STD_VIDEO_H265_PROFILE_IDC_SCC_EXTENSIONS = 9, + STD_VIDEO_H265_PROFILE_IDC_INVALID = 0x7FFFFFFF, + STD_VIDEO_H265_PROFILE_IDC_MAX_ENUM = 0x7FFFFFFF +} StdVideoH265ProfileIdc; + +typedef enum StdVideoH265LevelIdc { + STD_VIDEO_H265_LEVEL_IDC_1_0 = 0, + STD_VIDEO_H265_LEVEL_IDC_2_0 = 1, + STD_VIDEO_H265_LEVEL_IDC_2_1 = 2, + STD_VIDEO_H265_LEVEL_IDC_3_0 = 3, + STD_VIDEO_H265_LEVEL_IDC_3_1 = 4, + STD_VIDEO_H265_LEVEL_IDC_4_0 = 5, + STD_VIDEO_H265_LEVEL_IDC_4_1 = 6, + STD_VIDEO_H265_LEVEL_IDC_5_0 = 7, + STD_VIDEO_H265_LEVEL_IDC_5_1 = 8, + STD_VIDEO_H265_LEVEL_IDC_5_2 = 9, + STD_VIDEO_H265_LEVEL_IDC_6_0 = 10, + STD_VIDEO_H265_LEVEL_IDC_6_1 = 11, + STD_VIDEO_H265_LEVEL_IDC_6_2 = 12, + STD_VIDEO_H265_LEVEL_IDC_INVALID = 0x7FFFFFFF, + STD_VIDEO_H265_LEVEL_IDC_MAX_ENUM = 0x7FFFFFFF +} StdVideoH265LevelIdc; + +typedef enum StdVideoH265SliceType { + STD_VIDEO_H265_SLICE_TYPE_B = 0, + STD_VIDEO_H265_SLICE_TYPE_P = 1, + STD_VIDEO_H265_SLICE_TYPE_I = 2, + STD_VIDEO_H265_SLICE_TYPE_INVALID = 0x7FFFFFFF, + STD_VIDEO_H265_SLICE_TYPE_MAX_ENUM = 0x7FFFFFFF +} StdVideoH265SliceType; + +typedef enum StdVideoH265PictureType { + STD_VIDEO_H265_PICTURE_TYPE_P = 0, + STD_VIDEO_H265_PICTURE_TYPE_B = 1, + STD_VIDEO_H265_PICTURE_TYPE_I = 2, + STD_VIDEO_H265_PICTURE_TYPE_IDR = 3, + STD_VIDEO_H265_PICTURE_TYPE_INVALID = 0x7FFFFFFF, + STD_VIDEO_H265_PICTURE_TYPE_MAX_ENUM = 0x7FFFFFFF +} StdVideoH265PictureType; + +typedef enum StdVideoH265AspectRatioIdc { + STD_VIDEO_H265_ASPECT_RATIO_IDC_UNSPECIFIED = 0, + STD_VIDEO_H265_ASPECT_RATIO_IDC_SQUARE = 1, + STD_VIDEO_H265_ASPECT_RATIO_IDC_12_11 = 2, + STD_VIDEO_H265_ASPECT_RATIO_IDC_10_11 = 3, + STD_VIDEO_H265_ASPECT_RATIO_IDC_16_11 = 4, + STD_VIDEO_H265_ASPECT_RATIO_IDC_40_33 = 5, + STD_VIDEO_H265_ASPECT_RATIO_IDC_24_11 = 6, + STD_VIDEO_H265_ASPECT_RATIO_IDC_20_11 = 7, + STD_VIDEO_H265_ASPECT_RATIO_IDC_32_11 = 8, + STD_VIDEO_H265_ASPECT_RATIO_IDC_80_33 = 9, + STD_VIDEO_H265_ASPECT_RATIO_IDC_18_11 = 10, + STD_VIDEO_H265_ASPECT_RATIO_IDC_15_11 = 11, + STD_VIDEO_H265_ASPECT_RATIO_IDC_64_33 = 12, + STD_VIDEO_H265_ASPECT_RATIO_IDC_160_99 = 13, + STD_VIDEO_H265_ASPECT_RATIO_IDC_4_3 = 14, + STD_VIDEO_H265_ASPECT_RATIO_IDC_3_2 = 15, + STD_VIDEO_H265_ASPECT_RATIO_IDC_2_1 = 16, + STD_VIDEO_H265_ASPECT_RATIO_IDC_EXTENDED_SAR = 255, + STD_VIDEO_H265_ASPECT_RATIO_IDC_INVALID = 0x7FFFFFFF, + STD_VIDEO_H265_ASPECT_RATIO_IDC_MAX_ENUM = 0x7FFFFFFF +} StdVideoH265AspectRatioIdc; +typedef struct StdVideoH265DecPicBufMgr { + uint32_t max_latency_increase_plus1[STD_VIDEO_H265_SUBLAYERS_LIST_SIZE]; + uint8_t max_dec_pic_buffering_minus1[STD_VIDEO_H265_SUBLAYERS_LIST_SIZE]; + uint8_t max_num_reorder_pics[STD_VIDEO_H265_SUBLAYERS_LIST_SIZE]; +} StdVideoH265DecPicBufMgr; + +typedef struct StdVideoH265SubLayerHrdParameters { + uint32_t bit_rate_value_minus1[STD_VIDEO_H265_CPB_CNT_LIST_SIZE]; + uint32_t cpb_size_value_minus1[STD_VIDEO_H265_CPB_CNT_LIST_SIZE]; + uint32_t cpb_size_du_value_minus1[STD_VIDEO_H265_CPB_CNT_LIST_SIZE]; + uint32_t bit_rate_du_value_minus1[STD_VIDEO_H265_CPB_CNT_LIST_SIZE]; + uint32_t cbr_flag; +} StdVideoH265SubLayerHrdParameters; + +typedef struct StdVideoH265HrdFlags { + uint32_t nal_hrd_parameters_present_flag : 1; + uint32_t vcl_hrd_parameters_present_flag : 1; + uint32_t sub_pic_hrd_params_present_flag : 1; + uint32_t sub_pic_cpb_params_in_pic_timing_sei_flag : 1; + uint32_t fixed_pic_rate_general_flag : 8; + uint32_t fixed_pic_rate_within_cvs_flag : 8; + uint32_t low_delay_hrd_flag : 8; +} StdVideoH265HrdFlags; + +typedef struct StdVideoH265HrdParameters { + StdVideoH265HrdFlags flags; + uint8_t tick_divisor_minus2; + uint8_t du_cpb_removal_delay_increment_length_minus1; + uint8_t dpb_output_delay_du_length_minus1; + uint8_t bit_rate_scale; + uint8_t cpb_size_scale; + uint8_t cpb_size_du_scale; + uint8_t initial_cpb_removal_delay_length_minus1; + uint8_t au_cpb_removal_delay_length_minus1; + uint8_t dpb_output_delay_length_minus1; + uint8_t cpb_cnt_minus1[STD_VIDEO_H265_SUBLAYERS_LIST_SIZE]; + uint16_t elemental_duration_in_tc_minus1[STD_VIDEO_H265_SUBLAYERS_LIST_SIZE]; + uint16_t reserved[3]; + const StdVideoH265SubLayerHrdParameters* pSubLayerHrdParametersNal; + const StdVideoH265SubLayerHrdParameters* pSubLayerHrdParametersVcl; +} StdVideoH265HrdParameters; + +typedef struct StdVideoH265VpsFlags { + uint32_t vps_temporal_id_nesting_flag : 1; + uint32_t vps_sub_layer_ordering_info_present_flag : 1; + uint32_t vps_timing_info_present_flag : 1; + uint32_t vps_poc_proportional_to_timing_flag : 1; +} StdVideoH265VpsFlags; + +typedef struct StdVideoH265ProfileTierLevelFlags { + uint32_t general_tier_flag : 1; + uint32_t general_progressive_source_flag : 1; + uint32_t general_interlaced_source_flag : 1; + uint32_t general_non_packed_constraint_flag : 1; + uint32_t general_frame_only_constraint_flag : 1; +} StdVideoH265ProfileTierLevelFlags; + +typedef struct StdVideoH265ProfileTierLevel { + StdVideoH265ProfileTierLevelFlags flags; + StdVideoH265ProfileIdc general_profile_idc; + StdVideoH265LevelIdc general_level_idc; +} StdVideoH265ProfileTierLevel; + +typedef struct StdVideoH265VideoParameterSet { + StdVideoH265VpsFlags flags; + uint8_t vps_video_parameter_set_id; + uint8_t vps_max_sub_layers_minus1; + uint8_t reserved1; + uint8_t reserved2; + uint32_t vps_num_units_in_tick; + uint32_t vps_time_scale; + uint32_t vps_num_ticks_poc_diff_one_minus1; + uint32_t reserved3; + const StdVideoH265DecPicBufMgr* pDecPicBufMgr; + const StdVideoH265HrdParameters* pHrdParameters; + const StdVideoH265ProfileTierLevel* pProfileTierLevel; +} StdVideoH265VideoParameterSet; + +typedef struct StdVideoH265ScalingLists { + uint8_t ScalingList4x4[STD_VIDEO_H265_SCALING_LIST_4X4_NUM_LISTS][STD_VIDEO_H265_SCALING_LIST_4X4_NUM_ELEMENTS]; + uint8_t ScalingList8x8[STD_VIDEO_H265_SCALING_LIST_8X8_NUM_LISTS][STD_VIDEO_H265_SCALING_LIST_8X8_NUM_ELEMENTS]; + uint8_t ScalingList16x16[STD_VIDEO_H265_SCALING_LIST_16X16_NUM_LISTS][STD_VIDEO_H265_SCALING_LIST_16X16_NUM_ELEMENTS]; + uint8_t ScalingList32x32[STD_VIDEO_H265_SCALING_LIST_32X32_NUM_LISTS][STD_VIDEO_H265_SCALING_LIST_32X32_NUM_ELEMENTS]; + uint8_t ScalingListDCCoef16x16[STD_VIDEO_H265_SCALING_LIST_16X16_NUM_LISTS]; + uint8_t ScalingListDCCoef32x32[STD_VIDEO_H265_SCALING_LIST_32X32_NUM_LISTS]; +} StdVideoH265ScalingLists; + +typedef struct StdVideoH265SpsVuiFlags { + uint32_t aspect_ratio_info_present_flag : 1; + uint32_t overscan_info_present_flag : 1; + uint32_t overscan_appropriate_flag : 1; + uint32_t video_signal_type_present_flag : 1; + uint32_t video_full_range_flag : 1; + uint32_t colour_description_present_flag : 1; + uint32_t chroma_loc_info_present_flag : 1; + uint32_t neutral_chroma_indication_flag : 1; + uint32_t field_seq_flag : 1; + uint32_t frame_field_info_present_flag : 1; + uint32_t default_display_window_flag : 1; + uint32_t vui_timing_info_present_flag : 1; + uint32_t vui_poc_proportional_to_timing_flag : 1; + uint32_t vui_hrd_parameters_present_flag : 1; + uint32_t bitstream_restriction_flag : 1; + uint32_t tiles_fixed_structure_flag : 1; + uint32_t motion_vectors_over_pic_boundaries_flag : 1; + uint32_t restricted_ref_pic_lists_flag : 1; +} StdVideoH265SpsVuiFlags; + +typedef struct StdVideoH265SequenceParameterSetVui { + StdVideoH265SpsVuiFlags flags; + StdVideoH265AspectRatioIdc aspect_ratio_idc; + uint16_t sar_width; + uint16_t sar_height; + uint8_t video_format; + uint8_t colour_primaries; + uint8_t transfer_characteristics; + uint8_t matrix_coeffs; + uint8_t chroma_sample_loc_type_top_field; + uint8_t chroma_sample_loc_type_bottom_field; + uint8_t reserved1; + uint8_t reserved2; + uint16_t def_disp_win_left_offset; + uint16_t def_disp_win_right_offset; + uint16_t def_disp_win_top_offset; + uint16_t def_disp_win_bottom_offset; + uint32_t vui_num_units_in_tick; + uint32_t vui_time_scale; + uint32_t vui_num_ticks_poc_diff_one_minus1; + uint16_t min_spatial_segmentation_idc; + uint16_t reserved3; + uint8_t max_bytes_per_pic_denom; + uint8_t max_bits_per_min_cu_denom; + uint8_t log2_max_mv_length_horizontal; + uint8_t log2_max_mv_length_vertical; + const StdVideoH265HrdParameters* pHrdParameters; +} StdVideoH265SequenceParameterSetVui; + +typedef struct StdVideoH265PredictorPaletteEntries { + uint16_t PredictorPaletteEntries[STD_VIDEO_H265_PREDICTOR_PALETTE_COMPONENTS_LIST_SIZE][STD_VIDEO_H265_PREDICTOR_PALETTE_COMP_ENTRIES_LIST_SIZE]; +} StdVideoH265PredictorPaletteEntries; + +typedef struct StdVideoH265SpsFlags { + uint32_t sps_temporal_id_nesting_flag : 1; + uint32_t separate_colour_plane_flag : 1; + uint32_t conformance_window_flag : 1; + uint32_t sps_sub_layer_ordering_info_present_flag : 1; + uint32_t scaling_list_enabled_flag : 1; + uint32_t sps_scaling_list_data_present_flag : 1; + uint32_t amp_enabled_flag : 1; + uint32_t sample_adaptive_offset_enabled_flag : 1; + uint32_t pcm_enabled_flag : 1; + uint32_t pcm_loop_filter_disabled_flag : 1; + uint32_t long_term_ref_pics_present_flag : 1; + uint32_t sps_temporal_mvp_enabled_flag : 1; + uint32_t strong_intra_smoothing_enabled_flag : 1; + uint32_t vui_parameters_present_flag : 1; + uint32_t sps_extension_present_flag : 1; + uint32_t sps_range_extension_flag : 1; + uint32_t transform_skip_rotation_enabled_flag : 1; + uint32_t transform_skip_context_enabled_flag : 1; + uint32_t implicit_rdpcm_enabled_flag : 1; + uint32_t explicit_rdpcm_enabled_flag : 1; + uint32_t extended_precision_processing_flag : 1; + uint32_t intra_smoothing_disabled_flag : 1; + uint32_t high_precision_offsets_enabled_flag : 1; + uint32_t persistent_rice_adaptation_enabled_flag : 1; + uint32_t cabac_bypass_alignment_enabled_flag : 1; + uint32_t sps_scc_extension_flag : 1; + uint32_t sps_curr_pic_ref_enabled_flag : 1; + uint32_t palette_mode_enabled_flag : 1; + uint32_t sps_palette_predictor_initializers_present_flag : 1; + uint32_t intra_boundary_filtering_disabled_flag : 1; +} StdVideoH265SpsFlags; + +typedef struct StdVideoH265ShortTermRefPicSetFlags { + uint32_t inter_ref_pic_set_prediction_flag : 1; + uint32_t delta_rps_sign : 1; +} StdVideoH265ShortTermRefPicSetFlags; + +typedef struct StdVideoH265ShortTermRefPicSet { + StdVideoH265ShortTermRefPicSetFlags flags; + uint32_t delta_idx_minus1; + uint16_t use_delta_flag; + uint16_t abs_delta_rps_minus1; + uint16_t used_by_curr_pic_flag; + uint16_t used_by_curr_pic_s0_flag; + uint16_t used_by_curr_pic_s1_flag; + uint16_t reserved1; + uint8_t reserved2; + uint8_t reserved3; + uint8_t num_negative_pics; + uint8_t num_positive_pics; + uint16_t delta_poc_s0_minus1[STD_VIDEO_H265_MAX_DPB_SIZE]; + uint16_t delta_poc_s1_minus1[STD_VIDEO_H265_MAX_DPB_SIZE]; +} StdVideoH265ShortTermRefPicSet; + +typedef struct StdVideoH265LongTermRefPicsSps { + uint32_t used_by_curr_pic_lt_sps_flag; + uint32_t lt_ref_pic_poc_lsb_sps[STD_VIDEO_H265_MAX_LONG_TERM_REF_PICS_SPS]; +} StdVideoH265LongTermRefPicsSps; + +typedef struct StdVideoH265SequenceParameterSet { + StdVideoH265SpsFlags flags; + StdVideoH265ChromaFormatIdc chroma_format_idc; + uint32_t pic_width_in_luma_samples; + uint32_t pic_height_in_luma_samples; + uint8_t sps_video_parameter_set_id; + uint8_t sps_max_sub_layers_minus1; + uint8_t sps_seq_parameter_set_id; + uint8_t bit_depth_luma_minus8; + uint8_t bit_depth_chroma_minus8; + uint8_t log2_max_pic_order_cnt_lsb_minus4; + uint8_t log2_min_luma_coding_block_size_minus3; + uint8_t log2_diff_max_min_luma_coding_block_size; + uint8_t log2_min_luma_transform_block_size_minus2; + uint8_t log2_diff_max_min_luma_transform_block_size; + uint8_t max_transform_hierarchy_depth_inter; + uint8_t max_transform_hierarchy_depth_intra; + uint8_t num_short_term_ref_pic_sets; + uint8_t num_long_term_ref_pics_sps; + uint8_t pcm_sample_bit_depth_luma_minus1; + uint8_t pcm_sample_bit_depth_chroma_minus1; + uint8_t log2_min_pcm_luma_coding_block_size_minus3; + uint8_t log2_diff_max_min_pcm_luma_coding_block_size; + uint8_t reserved1; + uint8_t reserved2; + uint8_t palette_max_size; + uint8_t delta_palette_max_predictor_size; + uint8_t motion_vector_resolution_control_idc; + uint8_t sps_num_palette_predictor_initializers_minus1; + uint32_t conf_win_left_offset; + uint32_t conf_win_right_offset; + uint32_t conf_win_top_offset; + uint32_t conf_win_bottom_offset; + const StdVideoH265ProfileTierLevel* pProfileTierLevel; + const StdVideoH265DecPicBufMgr* pDecPicBufMgr; + const StdVideoH265ScalingLists* pScalingLists; + const StdVideoH265ShortTermRefPicSet* pShortTermRefPicSet; + const StdVideoH265LongTermRefPicsSps* pLongTermRefPicsSps; + const StdVideoH265SequenceParameterSetVui* pSequenceParameterSetVui; + const StdVideoH265PredictorPaletteEntries* pPredictorPaletteEntries; +} StdVideoH265SequenceParameterSet; + +typedef struct StdVideoH265PpsFlags { + uint32_t dependent_slice_segments_enabled_flag : 1; + uint32_t output_flag_present_flag : 1; + uint32_t sign_data_hiding_enabled_flag : 1; + uint32_t cabac_init_present_flag : 1; + uint32_t constrained_intra_pred_flag : 1; + uint32_t transform_skip_enabled_flag : 1; + uint32_t cu_qp_delta_enabled_flag : 1; + uint32_t pps_slice_chroma_qp_offsets_present_flag : 1; + uint32_t weighted_pred_flag : 1; + uint32_t weighted_bipred_flag : 1; + uint32_t transquant_bypass_enabled_flag : 1; + uint32_t tiles_enabled_flag : 1; + uint32_t entropy_coding_sync_enabled_flag : 1; + uint32_t uniform_spacing_flag : 1; + uint32_t loop_filter_across_tiles_enabled_flag : 1; + uint32_t pps_loop_filter_across_slices_enabled_flag : 1; + uint32_t deblocking_filter_control_present_flag : 1; + uint32_t deblocking_filter_override_enabled_flag : 1; + uint32_t pps_deblocking_filter_disabled_flag : 1; + uint32_t pps_scaling_list_data_present_flag : 1; + uint32_t lists_modification_present_flag : 1; + uint32_t slice_segment_header_extension_present_flag : 1; + uint32_t pps_extension_present_flag : 1; + uint32_t cross_component_prediction_enabled_flag : 1; + uint32_t chroma_qp_offset_list_enabled_flag : 1; + uint32_t pps_curr_pic_ref_enabled_flag : 1; + uint32_t residual_adaptive_colour_transform_enabled_flag : 1; + uint32_t pps_slice_act_qp_offsets_present_flag : 1; + uint32_t pps_palette_predictor_initializers_present_flag : 1; + uint32_t monochrome_palette_flag : 1; + uint32_t pps_range_extension_flag : 1; +} StdVideoH265PpsFlags; + +typedef struct StdVideoH265PictureParameterSet { + StdVideoH265PpsFlags flags; + uint8_t pps_pic_parameter_set_id; + uint8_t pps_seq_parameter_set_id; + uint8_t sps_video_parameter_set_id; + uint8_t num_extra_slice_header_bits; + uint8_t num_ref_idx_l0_default_active_minus1; + uint8_t num_ref_idx_l1_default_active_minus1; + int8_t init_qp_minus26; + uint8_t diff_cu_qp_delta_depth; + int8_t pps_cb_qp_offset; + int8_t pps_cr_qp_offset; + int8_t pps_beta_offset_div2; + int8_t pps_tc_offset_div2; + uint8_t log2_parallel_merge_level_minus2; + uint8_t log2_max_transform_skip_block_size_minus2; + uint8_t diff_cu_chroma_qp_offset_depth; + uint8_t chroma_qp_offset_list_len_minus1; + int8_t cb_qp_offset_list[STD_VIDEO_H265_CHROMA_QP_OFFSET_LIST_SIZE]; + int8_t cr_qp_offset_list[STD_VIDEO_H265_CHROMA_QP_OFFSET_LIST_SIZE]; + uint8_t log2_sao_offset_scale_luma; + uint8_t log2_sao_offset_scale_chroma; + int8_t pps_act_y_qp_offset_plus5; + int8_t pps_act_cb_qp_offset_plus5; + int8_t pps_act_cr_qp_offset_plus3; + uint8_t pps_num_palette_predictor_initializers; + uint8_t luma_bit_depth_entry_minus8; + uint8_t chroma_bit_depth_entry_minus8; + uint8_t num_tile_columns_minus1; + uint8_t num_tile_rows_minus1; + uint8_t reserved1; + uint8_t reserved2; + uint16_t column_width_minus1[STD_VIDEO_H265_CHROMA_QP_OFFSET_TILE_COLS_LIST_SIZE]; + uint16_t row_height_minus1[STD_VIDEO_H265_CHROMA_QP_OFFSET_TILE_ROWS_LIST_SIZE]; + uint32_t reserved3; + const StdVideoH265ScalingLists* pScalingLists; + const StdVideoH265PredictorPaletteEntries* pPredictorPaletteEntries; +} StdVideoH265PictureParameterSet; + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/vendor/vulkan/_gen/vulkan_video_codec_h265std_decode.h b/vendor/vulkan/_gen/vulkan_video_codec_h265std_decode.h new file mode 100644 index 000000000..7eee9b389 --- /dev/null +++ b/vendor/vulkan/_gen/vulkan_video_codec_h265std_decode.h @@ -0,0 +1,65 @@ +#ifndef VULKAN_VIDEO_CODEC_H265STD_DECODE_H_ +#define VULKAN_VIDEO_CODEC_H265STD_DECODE_H_ 1 + +/* +** Copyright 2015-2023 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +#define vulkan_video_codec_h265std_decode 1 + +#define VK_STD_VULKAN_VIDEO_CODEC_H265_DECODE_API_VERSION_1_0_0 VK_MAKE_VIDEO_STD_VERSION(1, 0, 0) + +#define STD_VIDEO_DECODE_H265_REF_PIC_SET_LIST_SIZE 8 +#define VK_STD_VULKAN_VIDEO_CODEC_H265_DECODE_SPEC_VERSION VK_STD_VULKAN_VIDEO_CODEC_H265_DECODE_API_VERSION_1_0_0 +#define VK_STD_VULKAN_VIDEO_CODEC_H265_DECODE_EXTENSION_NAME "VK_STD_vulkan_video_codec_h265_decode" +typedef struct StdVideoDecodeH265PictureInfoFlags { + uint32_t IrapPicFlag : 1; + uint32_t IdrPicFlag : 1; + uint32_t IsReference : 1; + uint32_t short_term_ref_pic_set_sps_flag : 1; +} StdVideoDecodeH265PictureInfoFlags; + +typedef struct StdVideoDecodeH265PictureInfo { + StdVideoDecodeH265PictureInfoFlags flags; + uint8_t sps_video_parameter_set_id; + uint8_t pps_seq_parameter_set_id; + uint8_t pps_pic_parameter_set_id; + uint8_t NumDeltaPocsOfRefRpsIdx; + int32_t PicOrderCntVal; + uint16_t NumBitsForSTRefPicSetInSlice; + uint16_t reserved; + uint8_t RefPicSetStCurrBefore[STD_VIDEO_DECODE_H265_REF_PIC_SET_LIST_SIZE]; + uint8_t RefPicSetStCurrAfter[STD_VIDEO_DECODE_H265_REF_PIC_SET_LIST_SIZE]; + uint8_t RefPicSetLtCurr[STD_VIDEO_DECODE_H265_REF_PIC_SET_LIST_SIZE]; +} StdVideoDecodeH265PictureInfo; + +typedef struct StdVideoDecodeH265ReferenceInfoFlags { + uint32_t used_for_long_term_reference : 1; + uint32_t unused_for_reference : 1; +} StdVideoDecodeH265ReferenceInfoFlags; + +typedef struct StdVideoDecodeH265ReferenceInfo { + StdVideoDecodeH265ReferenceInfoFlags flags; + int32_t PicOrderCntVal; +} StdVideoDecodeH265ReferenceInfo; + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/vendor/vulkan/_gen/vulkan_wayland.h b/vendor/vulkan/_gen/vulkan_wayland.h new file mode 100644 index 000000000..bdf4fdfad --- /dev/null +++ b/vendor/vulkan/_gen/vulkan_wayland.h @@ -0,0 +1,54 @@ +#ifndef VULKAN_WAYLAND_H_ +#define VULKAN_WAYLAND_H_ 1 + +/* +** Copyright 2015-2023 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +#define VK_KHR_wayland_surface 1 +#define VK_KHR_WAYLAND_SURFACE_SPEC_VERSION 6 +#define VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME "VK_KHR_wayland_surface" +typedef VkFlags VkWaylandSurfaceCreateFlagsKHR; +typedef struct VkWaylandSurfaceCreateInfoKHR { + VkStructureType sType; + const void* pNext; + VkWaylandSurfaceCreateFlagsKHR flags; + struct wl_display* display; + struct wl_surface* surface; +} VkWaylandSurfaceCreateInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateWaylandSurfaceKHR)(VkInstance instance, const VkWaylandSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); +typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, struct wl_display* display); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateWaylandSurfaceKHR( + VkInstance instance, + const VkWaylandSurfaceCreateInfoKHR* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkSurfaceKHR* pSurface); + +VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWaylandPresentationSupportKHR( + VkPhysicalDevice physicalDevice, + uint32_t queueFamilyIndex, + struct wl_display* display); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/vendor/vulkan/_gen/vulkan_win32.h b/vendor/vulkan/_gen/vulkan_win32.h index affe0c02a..5b65a36a6 100644 --- a/vendor/vulkan/_gen/vulkan_win32.h +++ b/vendor/vulkan/_gen/vulkan_win32.h @@ -2,7 +2,7 @@ #define VULKAN_WIN32_H_ 1 /* -** Copyright 2015-2022 The Khronos Group Inc. +** Copyright 2015-2023 The Khronos Group Inc. ** ** SPDX-License-Identifier: Apache-2.0 */ @@ -308,6 +308,24 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetDeviceGroupSurfacePresentModes2EXT( VkDeviceGroupPresentModeFlagsKHR* pModes); #endif + +#define VK_NV_acquire_winrt_display 1 +#define VK_NV_ACQUIRE_WINRT_DISPLAY_SPEC_VERSION 1 +#define VK_NV_ACQUIRE_WINRT_DISPLAY_EXTENSION_NAME "VK_NV_acquire_winrt_display" +typedef VkResult (VKAPI_PTR *PFN_vkAcquireWinrtDisplayNV)(VkPhysicalDevice physicalDevice, VkDisplayKHR display); +typedef VkResult (VKAPI_PTR *PFN_vkGetWinrtDisplayNV)(VkPhysicalDevice physicalDevice, uint32_t deviceRelativeId, VkDisplayKHR* pDisplay); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkAcquireWinrtDisplayNV( + VkPhysicalDevice physicalDevice, + VkDisplayKHR display); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetWinrtDisplayNV( + VkPhysicalDevice physicalDevice, + uint32_t deviceRelativeId, + VkDisplayKHR* pDisplay); +#endif + #ifdef __cplusplus } #endif diff --git a/vendor/vulkan/core.odin b/vendor/vulkan/core.odin index b90bfad17..7ad114266 100644 --- a/vendor/vulkan/core.odin +++ b/vendor/vulkan/core.odin @@ -1,834 +1,1005 @@ -// -// Vulkan wrapper generated from "https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/master/include/vulkan/vulkan_core.h" -// -package vulkan -API_VERSION_1_0 :: (1<<22) | (0<<12) | (0) -API_VERSION_1_1 :: (1<<22) | (1<<12) | (0) -API_VERSION_1_2 :: (1<<22) | (2<<12) | (0) -API_VERSION_1_3 :: (1<<22) | (3<<12) | (0) - -MAKE_VERSION :: proc(major, minor, patch: u32) -> u32 { - return (major<<22) | (minor<<12) | (patch) -} - -// Base types -Flags :: distinct u32 -Flags64 :: distinct u64 -DeviceSize :: distinct u64 -DeviceAddress :: distinct u64 -SampleMask :: distinct u32 - -Handle :: distinct rawptr -NonDispatchableHandle :: distinct u64 - -SetProcAddressType :: #type proc(p: rawptr, name: cstring) - - -RemoteAddressNV :: distinct rawptr // Declared inline before MemoryGetRemoteAddressInfoNV - -// Base constants -LOD_CLAMP_NONE :: 1000.0 -REMAINING_MIP_LEVELS :: ~u32(0) -REMAINING_ARRAY_LAYERS :: ~u32(0) -WHOLE_SIZE :: ~u64(0) -ATTACHMENT_UNUSED :: ~u32(0) -TRUE :: 1 -FALSE :: 0 -QUEUE_FAMILY_IGNORED :: ~u32(0) -SUBPASS_EXTERNAL :: ~u32(0) -MAX_PHYSICAL_DEVICE_NAME_SIZE :: 256 -UUID_SIZE :: 16 -MAX_MEMORY_TYPES :: 32 -MAX_MEMORY_HEAPS :: 16 -MAX_EXTENSION_NAME_SIZE :: 256 -MAX_DESCRIPTION_SIZE :: 256 -MAX_DEVICE_GROUP_SIZE :: 32 -LUID_SIZE_KHX :: 8 -LUID_SIZE :: 8 -MAX_QUEUE_FAMILY_EXTERNAL :: ~u32(1) -MAX_GLOBAL_PRIORITY_SIZE_EXT :: 16 -QUEUE_FAMILY_EXTERNAL :: MAX_QUEUE_FAMILY_EXTERNAL - -// General Constants -HEADER_VERSION :: 211 -MAX_DRIVER_NAME_SIZE :: 256 -MAX_DRIVER_INFO_SIZE :: 256 - -// Vendor Constants -KHR_surface :: 1 -KHR_SURFACE_SPEC_VERSION :: 25 -KHR_SURFACE_EXTENSION_NAME :: "VK_KHR_surface" -KHR_swapchain :: 1 -KHR_SWAPCHAIN_SPEC_VERSION :: 70 -KHR_SWAPCHAIN_EXTENSION_NAME :: "VK_KHR_swapchain" -KHR_display :: 1 -KHR_DISPLAY_SPEC_VERSION :: 23 -KHR_DISPLAY_EXTENSION_NAME :: "VK_KHR_display" -KHR_display_swapchain :: 1 -KHR_DISPLAY_SWAPCHAIN_SPEC_VERSION :: 10 -KHR_DISPLAY_SWAPCHAIN_EXTENSION_NAME :: "VK_KHR_display_swapchain" -KHR_sampler_mirror_clamp_to_edge :: 1 -KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_SPEC_VERSION :: 3 -KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME :: "VK_KHR_sampler_mirror_clamp_to_edge" -KHR_dynamic_rendering :: 1 -KHR_DYNAMIC_RENDERING_SPEC_VERSION :: 1 -KHR_DYNAMIC_RENDERING_EXTENSION_NAME :: "VK_KHR_dynamic_rendering" -KHR_multiview :: 1 -KHR_MULTIVIEW_SPEC_VERSION :: 1 -KHR_MULTIVIEW_EXTENSION_NAME :: "VK_KHR_multiview" -KHR_get_physical_device_properties2 :: 1 -KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_SPEC_VERSION :: 2 -KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME :: "VK_KHR_get_physical_device_properties2" -KHR_device_group :: 1 -KHR_DEVICE_GROUP_SPEC_VERSION :: 4 -KHR_DEVICE_GROUP_EXTENSION_NAME :: "VK_KHR_device_group" -KHR_shader_draw_parameters :: 1 -KHR_SHADER_DRAW_PARAMETERS_SPEC_VERSION :: 1 -KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME :: "VK_KHR_shader_draw_parameters" -KHR_maintenance1 :: 1 -KHR_MAINTENANCE_1_SPEC_VERSION :: 2 -KHR_MAINTENANCE_1_EXTENSION_NAME :: "VK_KHR_maintenance1" -KHR_MAINTENANCE1_SPEC_VERSION :: KHR_MAINTENANCE_1_SPEC_VERSION -KHR_MAINTENANCE1_EXTENSION_NAME :: KHR_MAINTENANCE_1_EXTENSION_NAME -KHR_device_group_creation :: 1 -KHR_DEVICE_GROUP_CREATION_SPEC_VERSION :: 1 -KHR_DEVICE_GROUP_CREATION_EXTENSION_NAME :: "VK_KHR_device_group_creation" -MAX_DEVICE_GROUP_SIZE_KHR :: MAX_DEVICE_GROUP_SIZE -KHR_external_memory_capabilities :: 1 -KHR_EXTERNAL_MEMORY_CAPABILITIES_SPEC_VERSION :: 1 -KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME :: "VK_KHR_external_memory_capabilities" -LUID_SIZE_KHR :: LUID_SIZE -KHR_external_memory :: 1 -KHR_EXTERNAL_MEMORY_SPEC_VERSION :: 1 -KHR_EXTERNAL_MEMORY_EXTENSION_NAME :: "VK_KHR_external_memory" -QUEUE_FAMILY_EXTERNAL_KHR :: QUEUE_FAMILY_EXTERNAL -KHR_external_memory_fd :: 1 -KHR_EXTERNAL_MEMORY_FD_SPEC_VERSION :: 1 -KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME :: "VK_KHR_external_memory_fd" -KHR_external_semaphore_capabilities :: 1 -KHR_EXTERNAL_SEMAPHORE_CAPABILITIES_SPEC_VERSION :: 1 -KHR_EXTERNAL_SEMAPHORE_CAPABILITIES_EXTENSION_NAME :: "VK_KHR_external_semaphore_capabilities" -KHR_external_semaphore :: 1 -KHR_EXTERNAL_SEMAPHORE_SPEC_VERSION :: 1 -KHR_EXTERNAL_SEMAPHORE_EXTENSION_NAME :: "VK_KHR_external_semaphore" -KHR_external_semaphore_fd :: 1 -KHR_EXTERNAL_SEMAPHORE_FD_SPEC_VERSION :: 1 -KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME :: "VK_KHR_external_semaphore_fd" -KHR_push_descriptor :: 1 -KHR_PUSH_DESCRIPTOR_SPEC_VERSION :: 2 -KHR_PUSH_DESCRIPTOR_EXTENSION_NAME :: "VK_KHR_push_descriptor" -KHR_shader_float16_int8 :: 1 -KHR_SHADER_FLOAT16_INT8_SPEC_VERSION :: 1 -KHR_SHADER_FLOAT16_INT8_EXTENSION_NAME :: "VK_KHR_shader_float16_int8" -KHR_16bit_storage :: 1 -KHR_16BIT_STORAGE_SPEC_VERSION :: 1 -KHR_16BIT_STORAGE_EXTENSION_NAME :: "VK_KHR_16bit_storage" -KHR_incremental_present :: 1 -KHR_INCREMENTAL_PRESENT_SPEC_VERSION :: 2 -KHR_INCREMENTAL_PRESENT_EXTENSION_NAME :: "VK_KHR_incremental_present" -KHR_descriptor_update_template :: 1 -KHR_DESCRIPTOR_UPDATE_TEMPLATE_SPEC_VERSION :: 1 -KHR_DESCRIPTOR_UPDATE_TEMPLATE_EXTENSION_NAME :: "VK_KHR_descriptor_update_template" -KHR_imageless_framebuffer :: 1 -KHR_IMAGELESS_FRAMEBUFFER_SPEC_VERSION :: 1 -KHR_IMAGELESS_FRAMEBUFFER_EXTENSION_NAME :: "VK_KHR_imageless_framebuffer" -KHR_create_renderpass2 :: 1 -KHR_CREATE_RENDERPASS_2_SPEC_VERSION :: 1 -KHR_CREATE_RENDERPASS_2_EXTENSION_NAME :: "VK_KHR_create_renderpass2" -KHR_shared_presentable_image :: 1 -KHR_SHARED_PRESENTABLE_IMAGE_SPEC_VERSION :: 1 -KHR_SHARED_PRESENTABLE_IMAGE_EXTENSION_NAME :: "VK_KHR_shared_presentable_image" -KHR_external_fence_capabilities :: 1 -KHR_EXTERNAL_FENCE_CAPABILITIES_SPEC_VERSION :: 1 -KHR_EXTERNAL_FENCE_CAPABILITIES_EXTENSION_NAME :: "VK_KHR_external_fence_capabilities" -KHR_external_fence :: 1 -KHR_EXTERNAL_FENCE_SPEC_VERSION :: 1 -KHR_EXTERNAL_FENCE_EXTENSION_NAME :: "VK_KHR_external_fence" -KHR_external_fence_fd :: 1 -KHR_EXTERNAL_FENCE_FD_SPEC_VERSION :: 1 -KHR_EXTERNAL_FENCE_FD_EXTENSION_NAME :: "VK_KHR_external_fence_fd" -KHR_performance_query :: 1 -KHR_PERFORMANCE_QUERY_SPEC_VERSION :: 1 -KHR_PERFORMANCE_QUERY_EXTENSION_NAME :: "VK_KHR_performance_query" -KHR_maintenance2 :: 1 -KHR_MAINTENANCE_2_SPEC_VERSION :: 1 -KHR_MAINTENANCE_2_EXTENSION_NAME :: "VK_KHR_maintenance2" -KHR_MAINTENANCE2_SPEC_VERSION :: KHR_MAINTENANCE_2_SPEC_VERSION -KHR_MAINTENANCE2_EXTENSION_NAME :: KHR_MAINTENANCE_2_EXTENSION_NAME -KHR_get_surface_capabilities2 :: 1 -KHR_GET_SURFACE_CAPABILITIES_2_SPEC_VERSION :: 1 -KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME :: "VK_KHR_get_surface_capabilities2" -KHR_variable_pointers :: 1 -KHR_VARIABLE_POINTERS_SPEC_VERSION :: 1 -KHR_VARIABLE_POINTERS_EXTENSION_NAME :: "VK_KHR_variable_pointers" -KHR_get_display_properties2 :: 1 -KHR_GET_DISPLAY_PROPERTIES_2_SPEC_VERSION :: 1 -KHR_GET_DISPLAY_PROPERTIES_2_EXTENSION_NAME :: "VK_KHR_get_display_properties2" -KHR_dedicated_allocation :: 1 -KHR_DEDICATED_ALLOCATION_SPEC_VERSION :: 3 -KHR_DEDICATED_ALLOCATION_EXTENSION_NAME :: "VK_KHR_dedicated_allocation" -KHR_storage_buffer_storage_class :: 1 -KHR_STORAGE_BUFFER_STORAGE_CLASS_SPEC_VERSION :: 1 -KHR_STORAGE_BUFFER_STORAGE_CLASS_EXTENSION_NAME :: "VK_KHR_storage_buffer_storage_class" -KHR_relaxed_block_layout :: 1 -KHR_RELAXED_BLOCK_LAYOUT_SPEC_VERSION :: 1 -KHR_RELAXED_BLOCK_LAYOUT_EXTENSION_NAME :: "VK_KHR_relaxed_block_layout" -KHR_get_memory_requirements2 :: 1 -KHR_GET_MEMORY_REQUIREMENTS_2_SPEC_VERSION :: 1 -KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME :: "VK_KHR_get_memory_requirements2" -KHR_image_format_list :: 1 -KHR_IMAGE_FORMAT_LIST_SPEC_VERSION :: 1 -KHR_IMAGE_FORMAT_LIST_EXTENSION_NAME :: "VK_KHR_image_format_list" -KHR_sampler_ycbcr_conversion :: 1 -KHR_SAMPLER_YCBCR_CONVERSION_SPEC_VERSION :: 14 -KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME :: "VK_KHR_sampler_ycbcr_conversion" -KHR_bind_memory2 :: 1 -KHR_BIND_MEMORY_2_SPEC_VERSION :: 1 -KHR_BIND_MEMORY_2_EXTENSION_NAME :: "VK_KHR_bind_memory2" -KHR_maintenance3 :: 1 -KHR_MAINTENANCE_3_SPEC_VERSION :: 1 -KHR_MAINTENANCE_3_EXTENSION_NAME :: "VK_KHR_maintenance3" -KHR_MAINTENANCE3_SPEC_VERSION :: KHR_MAINTENANCE_3_SPEC_VERSION -KHR_MAINTENANCE3_EXTENSION_NAME :: KHR_MAINTENANCE_3_EXTENSION_NAME -KHR_draw_indirect_count :: 1 -KHR_DRAW_INDIRECT_COUNT_SPEC_VERSION :: 1 -KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME :: "VK_KHR_draw_indirect_count" -KHR_shader_subgroup_extended_types :: 1 -KHR_SHADER_SUBGROUP_EXTENDED_TYPES_SPEC_VERSION :: 1 -KHR_SHADER_SUBGROUP_EXTENDED_TYPES_EXTENSION_NAME :: "VK_KHR_shader_subgroup_extended_types" -KHR_8bit_storage :: 1 -KHR_8BIT_STORAGE_SPEC_VERSION :: 1 -KHR_8BIT_STORAGE_EXTENSION_NAME :: "VK_KHR_8bit_storage" -KHR_shader_atomic_int64 :: 1 -KHR_SHADER_ATOMIC_INT64_SPEC_VERSION :: 1 -KHR_SHADER_ATOMIC_INT64_EXTENSION_NAME :: "VK_KHR_shader_atomic_int64" -KHR_shader_clock :: 1 -KHR_SHADER_CLOCK_SPEC_VERSION :: 1 -KHR_SHADER_CLOCK_EXTENSION_NAME :: "VK_KHR_shader_clock" -KHR_global_priority :: 1 -MAX_GLOBAL_PRIORITY_SIZE_KHR :: 16 -KHR_GLOBAL_PRIORITY_SPEC_VERSION :: 1 -KHR_GLOBAL_PRIORITY_EXTENSION_NAME :: "VK_KHR_global_priority" -KHR_driver_properties :: 1 -KHR_DRIVER_PROPERTIES_SPEC_VERSION :: 1 -KHR_DRIVER_PROPERTIES_EXTENSION_NAME :: "VK_KHR_driver_properties" -MAX_DRIVER_NAME_SIZE_KHR :: MAX_DRIVER_NAME_SIZE -MAX_DRIVER_INFO_SIZE_KHR :: MAX_DRIVER_INFO_SIZE -KHR_shader_float_controls :: 1 -KHR_SHADER_FLOAT_CONTROLS_SPEC_VERSION :: 4 -KHR_SHADER_FLOAT_CONTROLS_EXTENSION_NAME :: "VK_KHR_shader_float_controls" -KHR_depth_stencil_resolve :: 1 -KHR_DEPTH_STENCIL_RESOLVE_SPEC_VERSION :: 1 -KHR_DEPTH_STENCIL_RESOLVE_EXTENSION_NAME :: "VK_KHR_depth_stencil_resolve" -KHR_swapchain_mutable_format :: 1 -KHR_SWAPCHAIN_MUTABLE_FORMAT_SPEC_VERSION :: 1 -KHR_SWAPCHAIN_MUTABLE_FORMAT_EXTENSION_NAME :: "VK_KHR_swapchain_mutable_format" -KHR_timeline_semaphore :: 1 -KHR_TIMELINE_SEMAPHORE_SPEC_VERSION :: 2 -KHR_TIMELINE_SEMAPHORE_EXTENSION_NAME :: "VK_KHR_timeline_semaphore" -KHR_vulkan_memory_model :: 1 -KHR_VULKAN_MEMORY_MODEL_SPEC_VERSION :: 3 -KHR_VULKAN_MEMORY_MODEL_EXTENSION_NAME :: "VK_KHR_vulkan_memory_model" -KHR_shader_terminate_invocation :: 1 -KHR_SHADER_TERMINATE_INVOCATION_SPEC_VERSION :: 1 -KHR_SHADER_TERMINATE_INVOCATION_EXTENSION_NAME :: "VK_KHR_shader_terminate_invocation" -KHR_fragment_shading_rate :: 1 -KHR_FRAGMENT_SHADING_RATE_SPEC_VERSION :: 2 -KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME :: "VK_KHR_fragment_shading_rate" -KHR_spirv_1_4 :: 1 -KHR_SPIRV_1_4_SPEC_VERSION :: 1 -KHR_SPIRV_1_4_EXTENSION_NAME :: "VK_KHR_spirv_1_4" -KHR_surface_protected_capabilities :: 1 -KHR_SURFACE_PROTECTED_CAPABILITIES_SPEC_VERSION :: 1 -KHR_SURFACE_PROTECTED_CAPABILITIES_EXTENSION_NAME :: "VK_KHR_surface_protected_capabilities" -KHR_separate_depth_stencil_layouts :: 1 -KHR_SEPARATE_DEPTH_STENCIL_LAYOUTS_SPEC_VERSION :: 1 -KHR_SEPARATE_DEPTH_STENCIL_LAYOUTS_EXTENSION_NAME :: "VK_KHR_separate_depth_stencil_layouts" -KHR_present_wait :: 1 -KHR_PRESENT_WAIT_SPEC_VERSION :: 1 -KHR_PRESENT_WAIT_EXTENSION_NAME :: "VK_KHR_present_wait" -KHR_uniform_buffer_standard_layout :: 1 -KHR_UNIFORM_BUFFER_STANDARD_LAYOUT_SPEC_VERSION :: 1 -KHR_UNIFORM_BUFFER_STANDARD_LAYOUT_EXTENSION_NAME :: "VK_KHR_uniform_buffer_standard_layout" -KHR_buffer_device_address :: 1 -KHR_BUFFER_DEVICE_ADDRESS_SPEC_VERSION :: 1 -KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME :: "VK_KHR_buffer_device_address" -KHR_deferred_host_operations :: 1 -KHR_DEFERRED_HOST_OPERATIONS_SPEC_VERSION :: 4 -KHR_DEFERRED_HOST_OPERATIONS_EXTENSION_NAME :: "VK_KHR_deferred_host_operations" -KHR_pipeline_executable_properties :: 1 -KHR_PIPELINE_EXECUTABLE_PROPERTIES_SPEC_VERSION :: 1 -KHR_PIPELINE_EXECUTABLE_PROPERTIES_EXTENSION_NAME :: "VK_KHR_pipeline_executable_properties" -KHR_shader_integer_dot_product :: 1 -KHR_SHADER_INTEGER_DOT_PRODUCT_SPEC_VERSION :: 1 -KHR_SHADER_INTEGER_DOT_PRODUCT_EXTENSION_NAME :: "VK_KHR_shader_integer_dot_product" -KHR_pipeline_library :: 1 -KHR_PIPELINE_LIBRARY_SPEC_VERSION :: 1 -KHR_PIPELINE_LIBRARY_EXTENSION_NAME :: "VK_KHR_pipeline_library" -KHR_shader_non_semantic_info :: 1 -KHR_SHADER_NON_SEMANTIC_INFO_SPEC_VERSION :: 1 -KHR_SHADER_NON_SEMANTIC_INFO_EXTENSION_NAME :: "VK_KHR_shader_non_semantic_info" -KHR_present_id :: 1 -KHR_PRESENT_ID_SPEC_VERSION :: 1 -KHR_PRESENT_ID_EXTENSION_NAME :: "VK_KHR_present_id" -KHR_synchronization2 :: 1 -KHR_SYNCHRONIZATION_2_SPEC_VERSION :: 1 -KHR_SYNCHRONIZATION_2_EXTENSION_NAME :: "VK_KHR_synchronization2" -KHR_shader_subgroup_uniform_control_flow :: 1 -KHR_SHADER_SUBGROUP_UNIFORM_CONTROL_FLOW_SPEC_VERSION :: 1 -KHR_SHADER_SUBGROUP_UNIFORM_CONTROL_FLOW_EXTENSION_NAME :: "VK_KHR_shader_subgroup_uniform_control_flow" -KHR_zero_initialize_workgroup_memory :: 1 -KHR_ZERO_INITIALIZE_WORKGROUP_MEMORY_SPEC_VERSION :: 1 -KHR_ZERO_INITIALIZE_WORKGROUP_MEMORY_EXTENSION_NAME :: "VK_KHR_zero_initialize_workgroup_memory" -KHR_workgroup_memory_explicit_layout :: 1 -KHR_WORKGROUP_MEMORY_EXPLICIT_LAYOUT_SPEC_VERSION :: 1 -KHR_WORKGROUP_MEMORY_EXPLICIT_LAYOUT_EXTENSION_NAME :: "VK_KHR_workgroup_memory_explicit_layout" -KHR_copy_commands2 :: 1 -KHR_COPY_COMMANDS_2_SPEC_VERSION :: 1 -KHR_COPY_COMMANDS_2_EXTENSION_NAME :: "VK_KHR_copy_commands2" -KHR_format_feature_flags2 :: 1 -KHR_FORMAT_FEATURE_FLAGS_2_SPEC_VERSION :: 1 -KHR_FORMAT_FEATURE_FLAGS_2_EXTENSION_NAME :: "VK_KHR_format_feature_flags2" -KHR_portability_enumeration :: 1 -KHR_PORTABILITY_ENUMERATION_SPEC_VERSION :: 1 -KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME :: "VK_KHR_portability_enumeration" -KHR_maintenance4 :: 1 -KHR_MAINTENANCE_4_SPEC_VERSION :: 2 -KHR_MAINTENANCE_4_EXTENSION_NAME :: "VK_KHR_maintenance4" -EXT_debug_report :: 1 -EXT_DEBUG_REPORT_SPEC_VERSION :: 10 -EXT_DEBUG_REPORT_EXTENSION_NAME :: "VK_EXT_debug_report" -NV_glsl_shader :: 1 -NV_GLSL_SHADER_SPEC_VERSION :: 1 -NV_GLSL_SHADER_EXTENSION_NAME :: "VK_NV_glsl_shader" -EXT_depth_range_unrestricted :: 1 -EXT_DEPTH_RANGE_UNRESTRICTED_SPEC_VERSION :: 1 -EXT_DEPTH_RANGE_UNRESTRICTED_EXTENSION_NAME :: "VK_EXT_depth_range_unrestricted" -AMD_rasterization_order :: 1 -AMD_RASTERIZATION_ORDER_SPEC_VERSION :: 1 -AMD_RASTERIZATION_ORDER_EXTENSION_NAME :: "VK_AMD_rasterization_order" -AMD_shader_trinary_minmax :: 1 -AMD_SHADER_TRINARY_MINMAX_SPEC_VERSION :: 1 -AMD_SHADER_TRINARY_MINMAX_EXTENSION_NAME :: "VK_AMD_shader_trinary_minmax" -AMD_shader_explicit_vertex_parameter :: 1 -AMD_SHADER_EXPLICIT_VERTEX_PARAMETER_SPEC_VERSION :: 1 -AMD_SHADER_EXPLICIT_VERTEX_PARAMETER_EXTENSION_NAME :: "VK_AMD_shader_explicit_vertex_parameter" -EXT_debug_marker :: 1 -EXT_DEBUG_MARKER_SPEC_VERSION :: 4 -EXT_DEBUG_MARKER_EXTENSION_NAME :: "VK_EXT_debug_marker" -AMD_gcn_shader :: 1 -AMD_GCN_SHADER_SPEC_VERSION :: 1 -AMD_GCN_SHADER_EXTENSION_NAME :: "VK_AMD_gcn_shader" -NV_dedicated_allocation :: 1 -NV_DEDICATED_ALLOCATION_SPEC_VERSION :: 1 -NV_DEDICATED_ALLOCATION_EXTENSION_NAME :: "VK_NV_dedicated_allocation" -EXT_transform_feedback :: 1 -EXT_TRANSFORM_FEEDBACK_SPEC_VERSION :: 1 -EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME :: "VK_EXT_transform_feedback" -NVX_binary_import :: 1 -NVX_BINARY_IMPORT_SPEC_VERSION :: 1 -NVX_BINARY_IMPORT_EXTENSION_NAME :: "VK_NVX_binary_import" -NVX_image_view_handle :: 1 -NVX_IMAGE_VIEW_HANDLE_SPEC_VERSION :: 2 -NVX_IMAGE_VIEW_HANDLE_EXTENSION_NAME :: "VK_NVX_image_view_handle" -AMD_draw_indirect_count :: 1 -AMD_DRAW_INDIRECT_COUNT_SPEC_VERSION :: 2 -AMD_DRAW_INDIRECT_COUNT_EXTENSION_NAME :: "VK_AMD_draw_indirect_count" -AMD_negative_viewport_height :: 1 -AMD_NEGATIVE_VIEWPORT_HEIGHT_SPEC_VERSION :: 1 -AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME :: "VK_AMD_negative_viewport_height" -AMD_gpu_shader_half_float :: 1 -AMD_GPU_SHADER_HALF_FLOAT_SPEC_VERSION :: 2 -AMD_GPU_SHADER_HALF_FLOAT_EXTENSION_NAME :: "VK_AMD_gpu_shader_half_float" -AMD_shader_ballot :: 1 -AMD_SHADER_BALLOT_SPEC_VERSION :: 1 -AMD_SHADER_BALLOT_EXTENSION_NAME :: "VK_AMD_shader_ballot" -AMD_texture_gather_bias_lod :: 1 -AMD_TEXTURE_GATHER_BIAS_LOD_SPEC_VERSION :: 1 -AMD_TEXTURE_GATHER_BIAS_LOD_EXTENSION_NAME :: "VK_AMD_texture_gather_bias_lod" -AMD_shader_info :: 1 -AMD_SHADER_INFO_SPEC_VERSION :: 1 -AMD_SHADER_INFO_EXTENSION_NAME :: "VK_AMD_shader_info" -AMD_shader_image_load_store_lod :: 1 -AMD_SHADER_IMAGE_LOAD_STORE_LOD_SPEC_VERSION :: 1 -AMD_SHADER_IMAGE_LOAD_STORE_LOD_EXTENSION_NAME :: "VK_AMD_shader_image_load_store_lod" -NV_corner_sampled_image :: 1 -NV_CORNER_SAMPLED_IMAGE_SPEC_VERSION :: 2 -NV_CORNER_SAMPLED_IMAGE_EXTENSION_NAME :: "VK_NV_corner_sampled_image" -NV_external_memory_capabilities :: 1 -NV_EXTERNAL_MEMORY_CAPABILITIES_SPEC_VERSION :: 1 -NV_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME :: "VK_NV_external_memory_capabilities" -NV_external_memory :: 1 -NV_EXTERNAL_MEMORY_SPEC_VERSION :: 1 -NV_EXTERNAL_MEMORY_EXTENSION_NAME :: "VK_NV_external_memory" -EXT_validation_flags :: 1 -EXT_VALIDATION_FLAGS_SPEC_VERSION :: 2 -EXT_VALIDATION_FLAGS_EXTENSION_NAME :: "VK_EXT_validation_flags" -EXT_shader_subgroup_ballot :: 1 -EXT_SHADER_SUBGROUP_BALLOT_SPEC_VERSION :: 1 -EXT_SHADER_SUBGROUP_BALLOT_EXTENSION_NAME :: "VK_EXT_shader_subgroup_ballot" -EXT_shader_subgroup_vote :: 1 -EXT_SHADER_SUBGROUP_VOTE_SPEC_VERSION :: 1 -EXT_SHADER_SUBGROUP_VOTE_EXTENSION_NAME :: "VK_EXT_shader_subgroup_vote" -EXT_texture_compression_astc_hdr :: 1 -EXT_TEXTURE_COMPRESSION_ASTC_HDR_SPEC_VERSION :: 1 -EXT_TEXTURE_COMPRESSION_ASTC_HDR_EXTENSION_NAME :: "VK_EXT_texture_compression_astc_hdr" -EXT_astc_decode_mode :: 1 -EXT_ASTC_DECODE_MODE_SPEC_VERSION :: 1 -EXT_ASTC_DECODE_MODE_EXTENSION_NAME :: "VK_EXT_astc_decode_mode" -EXT_conditional_rendering :: 1 -EXT_CONDITIONAL_RENDERING_SPEC_VERSION :: 2 -EXT_CONDITIONAL_RENDERING_EXTENSION_NAME :: "VK_EXT_conditional_rendering" -NV_clip_space_w_scaling :: 1 -NV_CLIP_SPACE_W_SCALING_SPEC_VERSION :: 1 -NV_CLIP_SPACE_W_SCALING_EXTENSION_NAME :: "VK_NV_clip_space_w_scaling" -EXT_direct_mode_display :: 1 -EXT_DIRECT_MODE_DISPLAY_SPEC_VERSION :: 1 -EXT_DIRECT_MODE_DISPLAY_EXTENSION_NAME :: "VK_EXT_direct_mode_display" -EXT_display_surface_counter :: 1 -EXT_DISPLAY_SURFACE_COUNTER_SPEC_VERSION :: 1 -EXT_DISPLAY_SURFACE_COUNTER_EXTENSION_NAME :: "VK_EXT_display_surface_counter" -EXT_display_control :: 1 -EXT_DISPLAY_CONTROL_SPEC_VERSION :: 1 -EXT_DISPLAY_CONTROL_EXTENSION_NAME :: "VK_EXT_display_control" -GOOGLE_display_timing :: 1 -GOOGLE_DISPLAY_TIMING_SPEC_VERSION :: 1 -GOOGLE_DISPLAY_TIMING_EXTENSION_NAME :: "VK_GOOGLE_display_timing" -NV_sample_mask_override_coverage :: 1 -NV_SAMPLE_MASK_OVERRIDE_COVERAGE_SPEC_VERSION :: 1 -NV_SAMPLE_MASK_OVERRIDE_COVERAGE_EXTENSION_NAME :: "VK_NV_sample_mask_override_coverage" -NV_geometry_shader_passthrough :: 1 -NV_GEOMETRY_SHADER_PASSTHROUGH_SPEC_VERSION :: 1 -NV_GEOMETRY_SHADER_PASSTHROUGH_EXTENSION_NAME :: "VK_NV_geometry_shader_passthrough" -NV_viewport_array2 :: 1 -NV_VIEWPORT_ARRAY_2_SPEC_VERSION :: 1 -NV_VIEWPORT_ARRAY_2_EXTENSION_NAME :: "VK_NV_viewport_array2" -NV_VIEWPORT_ARRAY2_SPEC_VERSION :: NV_VIEWPORT_ARRAY_2_SPEC_VERSION -NV_VIEWPORT_ARRAY2_EXTENSION_NAME :: NV_VIEWPORT_ARRAY_2_EXTENSION_NAME -NVX_multiview_per_view_attributes :: 1 -NVX_MULTIVIEW_PER_VIEW_ATTRIBUTES_SPEC_VERSION :: 1 -NVX_MULTIVIEW_PER_VIEW_ATTRIBUTES_EXTENSION_NAME :: "VK_NVX_multiview_per_view_attributes" -NV_viewport_swizzle :: 1 -NV_VIEWPORT_SWIZZLE_SPEC_VERSION :: 1 -NV_VIEWPORT_SWIZZLE_EXTENSION_NAME :: "VK_NV_viewport_swizzle" -EXT_discard_rectangles :: 1 -EXT_DISCARD_RECTANGLES_SPEC_VERSION :: 1 -EXT_DISCARD_RECTANGLES_EXTENSION_NAME :: "VK_EXT_discard_rectangles" -EXT_conservative_rasterization :: 1 -EXT_CONSERVATIVE_RASTERIZATION_SPEC_VERSION :: 1 -EXT_CONSERVATIVE_RASTERIZATION_EXTENSION_NAME :: "VK_EXT_conservative_rasterization" -EXT_depth_clip_enable :: 1 -EXT_DEPTH_CLIP_ENABLE_SPEC_VERSION :: 1 -EXT_DEPTH_CLIP_ENABLE_EXTENSION_NAME :: "VK_EXT_depth_clip_enable" -EXT_swapchain_colorspace :: 1 -EXT_SWAPCHAIN_COLOR_SPACE_SPEC_VERSION :: 4 -EXT_SWAPCHAIN_COLOR_SPACE_EXTENSION_NAME :: "VK_EXT_swapchain_colorspace" -EXT_hdr_metadata :: 1 -EXT_HDR_METADATA_SPEC_VERSION :: 2 -EXT_HDR_METADATA_EXTENSION_NAME :: "VK_EXT_hdr_metadata" -EXT_external_memory_dma_buf :: 1 -EXT_EXTERNAL_MEMORY_DMA_BUF_SPEC_VERSION :: 1 -EXT_EXTERNAL_MEMORY_DMA_BUF_EXTENSION_NAME :: "VK_EXT_external_memory_dma_buf" -EXT_queue_family_foreign :: 1 -EXT_QUEUE_FAMILY_FOREIGN_SPEC_VERSION :: 1 -EXT_QUEUE_FAMILY_FOREIGN_EXTENSION_NAME :: "VK_EXT_queue_family_foreign" -EXT_debug_utils :: 1 -EXT_DEBUG_UTILS_SPEC_VERSION :: 2 -EXT_DEBUG_UTILS_EXTENSION_NAME :: "VK_EXT_debug_utils" -EXT_sampler_filter_minmax :: 1 -EXT_SAMPLER_FILTER_MINMAX_SPEC_VERSION :: 2 -EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME :: "VK_EXT_sampler_filter_minmax" -AMD_gpu_shader_int16 :: 1 -AMD_GPU_SHADER_INT16_SPEC_VERSION :: 2 -AMD_GPU_SHADER_INT16_EXTENSION_NAME :: "VK_AMD_gpu_shader_int16" -AMD_mixed_attachment_samples :: 1 -AMD_MIXED_ATTACHMENT_SAMPLES_SPEC_VERSION :: 1 -AMD_MIXED_ATTACHMENT_SAMPLES_EXTENSION_NAME :: "VK_AMD_mixed_attachment_samples" -AMD_shader_fragment_mask :: 1 -AMD_SHADER_FRAGMENT_MASK_SPEC_VERSION :: 1 -AMD_SHADER_FRAGMENT_MASK_EXTENSION_NAME :: "VK_AMD_shader_fragment_mask" -EXT_inline_uniform_block :: 1 -EXT_INLINE_UNIFORM_BLOCK_SPEC_VERSION :: 1 -EXT_INLINE_UNIFORM_BLOCK_EXTENSION_NAME :: "VK_EXT_inline_uniform_block" -EXT_shader_stencil_export :: 1 -EXT_SHADER_STENCIL_EXPORT_SPEC_VERSION :: 1 -EXT_SHADER_STENCIL_EXPORT_EXTENSION_NAME :: "VK_EXT_shader_stencil_export" -EXT_sample_locations :: 1 -EXT_SAMPLE_LOCATIONS_SPEC_VERSION :: 1 -EXT_SAMPLE_LOCATIONS_EXTENSION_NAME :: "VK_EXT_sample_locations" -EXT_blend_operation_advanced :: 1 -EXT_BLEND_OPERATION_ADVANCED_SPEC_VERSION :: 2 -EXT_BLEND_OPERATION_ADVANCED_EXTENSION_NAME :: "VK_EXT_blend_operation_advanced" -NV_fragment_coverage_to_color :: 1 -NV_FRAGMENT_COVERAGE_TO_COLOR_SPEC_VERSION :: 1 -NV_FRAGMENT_COVERAGE_TO_COLOR_EXTENSION_NAME :: "VK_NV_fragment_coverage_to_color" -NV_framebuffer_mixed_samples :: 1 -NV_FRAMEBUFFER_MIXED_SAMPLES_SPEC_VERSION :: 1 -NV_FRAMEBUFFER_MIXED_SAMPLES_EXTENSION_NAME :: "VK_NV_framebuffer_mixed_samples" -NV_fill_rectangle :: 1 -NV_FILL_RECTANGLE_SPEC_VERSION :: 1 -NV_FILL_RECTANGLE_EXTENSION_NAME :: "VK_NV_fill_rectangle" -NV_shader_sm_builtins :: 1 -NV_SHADER_SM_BUILTINS_SPEC_VERSION :: 1 -NV_SHADER_SM_BUILTINS_EXTENSION_NAME :: "VK_NV_shader_sm_builtins" -EXT_post_depth_coverage :: 1 -EXT_POST_DEPTH_COVERAGE_SPEC_VERSION :: 1 -EXT_POST_DEPTH_COVERAGE_EXTENSION_NAME :: "VK_EXT_post_depth_coverage" -EXT_image_drm_format_modifier :: 1 -EXT_IMAGE_DRM_FORMAT_MODIFIER_SPEC_VERSION :: 2 -EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME :: "VK_EXT_image_drm_format_modifier" -EXT_validation_cache :: 1 -EXT_VALIDATION_CACHE_SPEC_VERSION :: 1 -EXT_VALIDATION_CACHE_EXTENSION_NAME :: "VK_EXT_validation_cache" -EXT_descriptor_indexing :: 1 -EXT_DESCRIPTOR_INDEXING_SPEC_VERSION :: 2 -EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME :: "VK_EXT_descriptor_indexing" -EXT_shader_viewport_index_layer :: 1 -EXT_SHADER_VIEWPORT_INDEX_LAYER_SPEC_VERSION :: 1 -EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME :: "VK_EXT_shader_viewport_index_layer" -NV_shading_rate_image :: 1 -NV_SHADING_RATE_IMAGE_SPEC_VERSION :: 3 -NV_SHADING_RATE_IMAGE_EXTENSION_NAME :: "VK_NV_shading_rate_image" -NV_ray_tracing :: 1 -NV_RAY_TRACING_SPEC_VERSION :: 3 -NV_RAY_TRACING_EXTENSION_NAME :: "VK_NV_ray_tracing" -SHADER_UNUSED_KHR :: 0 -NV_representative_fragment_test :: 1 -NV_REPRESENTATIVE_FRAGMENT_TEST_SPEC_VERSION :: 2 -NV_REPRESENTATIVE_FRAGMENT_TEST_EXTENSION_NAME :: "VK_NV_representative_fragment_test" -EXT_filter_cubic :: 1 -EXT_FILTER_CUBIC_SPEC_VERSION :: 3 -EXT_FILTER_CUBIC_EXTENSION_NAME :: "VK_EXT_filter_cubic" -EXT_global_priority :: 1 -EXT_GLOBAL_PRIORITY_SPEC_VERSION :: 2 -EXT_GLOBAL_PRIORITY_EXTENSION_NAME :: "VK_EXT_global_priority" -EXT_external_memory_host :: 1 -EXT_EXTERNAL_MEMORY_HOST_SPEC_VERSION :: 1 -EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME :: "VK_EXT_external_memory_host" -AMD_buffer_marker :: 1 -AMD_BUFFER_MARKER_SPEC_VERSION :: 1 -AMD_BUFFER_MARKER_EXTENSION_NAME :: "VK_AMD_buffer_marker" -AMD_pipeline_compiler_control :: 1 -AMD_PIPELINE_COMPILER_CONTROL_SPEC_VERSION :: 1 -AMD_PIPELINE_COMPILER_CONTROL_EXTENSION_NAME :: "VK_AMD_pipeline_compiler_control" -EXT_calibrated_timestamps :: 1 -EXT_CALIBRATED_TIMESTAMPS_SPEC_VERSION :: 2 -EXT_CALIBRATED_TIMESTAMPS_EXTENSION_NAME :: "VK_EXT_calibrated_timestamps" -AMD_shader_core_properties :: 1 -AMD_SHADER_CORE_PROPERTIES_SPEC_VERSION :: 2 -AMD_SHADER_CORE_PROPERTIES_EXTENSION_NAME :: "VK_AMD_shader_core_properties" -AMD_memory_overallocation_behavior :: 1 -AMD_MEMORY_OVERALLOCATION_BEHAVIOR_SPEC_VERSION :: 1 -AMD_MEMORY_OVERALLOCATION_BEHAVIOR_EXTENSION_NAME :: "VK_AMD_memory_overallocation_behavior" -EXT_vertex_attribute_divisor :: 1 -EXT_VERTEX_ATTRIBUTE_DIVISOR_SPEC_VERSION :: 3 -EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME :: "VK_EXT_vertex_attribute_divisor" -EXT_pipeline_creation_feedback :: 1 -EXT_PIPELINE_CREATION_FEEDBACK_SPEC_VERSION :: 1 -EXT_PIPELINE_CREATION_FEEDBACK_EXTENSION_NAME :: "VK_EXT_pipeline_creation_feedback" -NV_shader_subgroup_partitioned :: 1 -NV_SHADER_SUBGROUP_PARTITIONED_SPEC_VERSION :: 1 -NV_SHADER_SUBGROUP_PARTITIONED_EXTENSION_NAME :: "VK_NV_shader_subgroup_partitioned" -NV_compute_shader_derivatives :: 1 -NV_COMPUTE_SHADER_DERIVATIVES_SPEC_VERSION :: 1 -NV_COMPUTE_SHADER_DERIVATIVES_EXTENSION_NAME :: "VK_NV_compute_shader_derivatives" -NV_mesh_shader :: 1 -NV_MESH_SHADER_SPEC_VERSION :: 1 -NV_MESH_SHADER_EXTENSION_NAME :: "VK_NV_mesh_shader" -NV_fragment_shader_barycentric :: 1 -NV_FRAGMENT_SHADER_BARYCENTRIC_SPEC_VERSION :: 1 -NV_FRAGMENT_SHADER_BARYCENTRIC_EXTENSION_NAME :: "VK_NV_fragment_shader_barycentric" -NV_shader_image_footprint :: 1 -NV_SHADER_IMAGE_FOOTPRINT_SPEC_VERSION :: 2 -NV_SHADER_IMAGE_FOOTPRINT_EXTENSION_NAME :: "VK_NV_shader_image_footprint" -NV_scissor_exclusive :: 1 -NV_SCISSOR_EXCLUSIVE_SPEC_VERSION :: 1 -NV_SCISSOR_EXCLUSIVE_EXTENSION_NAME :: "VK_NV_scissor_exclusive" -NV_device_diagnostic_checkpoints :: 1 -NV_DEVICE_DIAGNOSTIC_CHECKPOINTS_SPEC_VERSION :: 2 -NV_DEVICE_DIAGNOSTIC_CHECKPOINTS_EXTENSION_NAME :: "VK_NV_device_diagnostic_checkpoints" -EXT_pci_bus_info :: 1 -EXT_PCI_BUS_INFO_SPEC_VERSION :: 2 -EXT_PCI_BUS_INFO_EXTENSION_NAME :: "VK_EXT_pci_bus_info" -AMD_display_native_hdr :: 1 -AMD_DISPLAY_NATIVE_HDR_SPEC_VERSION :: 1 -AMD_DISPLAY_NATIVE_HDR_EXTENSION_NAME :: "VK_AMD_display_native_hdr" -EXT_fragment_density_map :: 1 -EXT_FRAGMENT_DENSITY_MAP_SPEC_VERSION :: 2 -EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME :: "VK_EXT_fragment_density_map" -EXT_scalar_block_layout :: 1 -EXT_SCALAR_BLOCK_LAYOUT_SPEC_VERSION :: 1 -EXT_SCALAR_BLOCK_LAYOUT_EXTENSION_NAME :: "VK_EXT_scalar_block_layout" -GOOGLE_hlsl_functionality1 :: 1 -GOOGLE_HLSL_FUNCTIONALITY_1_SPEC_VERSION :: 1 -GOOGLE_HLSL_FUNCTIONALITY_1_EXTENSION_NAME :: "VK_GOOGLE_hlsl_functionality1" -GOOGLE_HLSL_FUNCTIONALITY1_SPEC_VERSION :: GOOGLE_HLSL_FUNCTIONALITY_1_SPEC_VERSION -GOOGLE_HLSL_FUNCTIONALITY1_EXTENSION_NAME :: GOOGLE_HLSL_FUNCTIONALITY_1_EXTENSION_NAME -GOOGLE_decorate_string :: 1 -GOOGLE_DECORATE_STRING_SPEC_VERSION :: 1 -GOOGLE_DECORATE_STRING_EXTENSION_NAME :: "VK_GOOGLE_decorate_string" -EXT_subgroup_size_control :: 1 -EXT_SUBGROUP_SIZE_CONTROL_SPEC_VERSION :: 2 -EXT_SUBGROUP_SIZE_CONTROL_EXTENSION_NAME :: "VK_EXT_subgroup_size_control" -AMD_shader_core_properties2 :: 1 -AMD_SHADER_CORE_PROPERTIES_2_SPEC_VERSION :: 1 -AMD_SHADER_CORE_PROPERTIES_2_EXTENSION_NAME :: "VK_AMD_shader_core_properties2" -AMD_device_coherent_memory :: 1 -AMD_DEVICE_COHERENT_MEMORY_SPEC_VERSION :: 1 -AMD_DEVICE_COHERENT_MEMORY_EXTENSION_NAME :: "VK_AMD_device_coherent_memory" -EXT_shader_image_atomic_int64 :: 1 -EXT_SHADER_IMAGE_ATOMIC_INT64_SPEC_VERSION :: 1 -EXT_SHADER_IMAGE_ATOMIC_INT64_EXTENSION_NAME :: "VK_EXT_shader_image_atomic_int64" -EXT_memory_budget :: 1 -EXT_MEMORY_BUDGET_SPEC_VERSION :: 1 -EXT_MEMORY_BUDGET_EXTENSION_NAME :: "VK_EXT_memory_budget" -EXT_memory_priority :: 1 -EXT_MEMORY_PRIORITY_SPEC_VERSION :: 1 -EXT_MEMORY_PRIORITY_EXTENSION_NAME :: "VK_EXT_memory_priority" -NV_dedicated_allocation_image_aliasing :: 1 -NV_DEDICATED_ALLOCATION_IMAGE_ALIASING_SPEC_VERSION :: 1 -NV_DEDICATED_ALLOCATION_IMAGE_ALIASING_EXTENSION_NAME :: "VK_NV_dedicated_allocation_image_aliasing" -EXT_buffer_device_address :: 1 -EXT_BUFFER_DEVICE_ADDRESS_SPEC_VERSION :: 2 -EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME :: "VK_EXT_buffer_device_address" -EXT_tooling_info :: 1 -EXT_TOOLING_INFO_SPEC_VERSION :: 1 -EXT_TOOLING_INFO_EXTENSION_NAME :: "VK_EXT_tooling_info" -EXT_separate_stencil_usage :: 1 -EXT_SEPARATE_STENCIL_USAGE_SPEC_VERSION :: 1 -EXT_SEPARATE_STENCIL_USAGE_EXTENSION_NAME :: "VK_EXT_separate_stencil_usage" -EXT_validation_features :: 1 -EXT_VALIDATION_FEATURES_SPEC_VERSION :: 5 -EXT_VALIDATION_FEATURES_EXTENSION_NAME :: "VK_EXT_validation_features" -NV_cooperative_matrix :: 1 -NV_COOPERATIVE_MATRIX_SPEC_VERSION :: 1 -NV_COOPERATIVE_MATRIX_EXTENSION_NAME :: "VK_NV_cooperative_matrix" -NV_coverage_reduction_mode :: 1 -NV_COVERAGE_REDUCTION_MODE_SPEC_VERSION :: 1 -NV_COVERAGE_REDUCTION_MODE_EXTENSION_NAME :: "VK_NV_coverage_reduction_mode" -EXT_fragment_shader_interlock :: 1 -EXT_FRAGMENT_SHADER_INTERLOCK_SPEC_VERSION :: 1 -EXT_FRAGMENT_SHADER_INTERLOCK_EXTENSION_NAME :: "VK_EXT_fragment_shader_interlock" -EXT_ycbcr_image_arrays :: 1 -EXT_YCBCR_IMAGE_ARRAYS_SPEC_VERSION :: 1 -EXT_YCBCR_IMAGE_ARRAYS_EXTENSION_NAME :: "VK_EXT_ycbcr_image_arrays" -EXT_provoking_vertex :: 1 -EXT_PROVOKING_VERTEX_SPEC_VERSION :: 1 -EXT_PROVOKING_VERTEX_EXTENSION_NAME :: "VK_EXT_provoking_vertex" -EXT_headless_surface :: 1 -EXT_HEADLESS_SURFACE_SPEC_VERSION :: 1 -EXT_HEADLESS_SURFACE_EXTENSION_NAME :: "VK_EXT_headless_surface" -EXT_line_rasterization :: 1 -EXT_LINE_RASTERIZATION_SPEC_VERSION :: 1 -EXT_LINE_RASTERIZATION_EXTENSION_NAME :: "VK_EXT_line_rasterization" -EXT_shader_atomic_float :: 1 -EXT_SHADER_ATOMIC_FLOAT_SPEC_VERSION :: 1 -EXT_SHADER_ATOMIC_FLOAT_EXTENSION_NAME :: "VK_EXT_shader_atomic_float" -EXT_host_query_reset :: 1 -EXT_HOST_QUERY_RESET_SPEC_VERSION :: 1 -EXT_HOST_QUERY_RESET_EXTENSION_NAME :: "VK_EXT_host_query_reset" -EXT_index_type_uint8 :: 1 -EXT_INDEX_TYPE_UINT8_SPEC_VERSION :: 1 -EXT_INDEX_TYPE_UINT8_EXTENSION_NAME :: "VK_EXT_index_type_uint8" -EXT_extended_dynamic_state :: 1 -EXT_EXTENDED_DYNAMIC_STATE_SPEC_VERSION :: 1 -EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME :: "VK_EXT_extended_dynamic_state" -EXT_shader_atomic_float2 :: 1 -EXT_SHADER_ATOMIC_FLOAT_2_SPEC_VERSION :: 1 -EXT_SHADER_ATOMIC_FLOAT_2_EXTENSION_NAME :: "VK_EXT_shader_atomic_float2" -EXT_shader_demote_to_helper_invocation :: 1 -EXT_SHADER_DEMOTE_TO_HELPER_INVOCATION_SPEC_VERSION :: 1 -EXT_SHADER_DEMOTE_TO_HELPER_INVOCATION_EXTENSION_NAME :: "VK_EXT_shader_demote_to_helper_invocation" -NV_device_generated_commands :: 1 -NV_DEVICE_GENERATED_COMMANDS_SPEC_VERSION :: 3 -NV_DEVICE_GENERATED_COMMANDS_EXTENSION_NAME :: "VK_NV_device_generated_commands" -NV_inherited_viewport_scissor :: 1 -NV_INHERITED_VIEWPORT_SCISSOR_SPEC_VERSION :: 1 -NV_INHERITED_VIEWPORT_SCISSOR_EXTENSION_NAME :: "VK_NV_inherited_viewport_scissor" -EXT_texel_buffer_alignment :: 1 -EXT_TEXEL_BUFFER_ALIGNMENT_SPEC_VERSION :: 1 -EXT_TEXEL_BUFFER_ALIGNMENT_EXTENSION_NAME :: "VK_EXT_texel_buffer_alignment" -EXT_device_memory_report :: 1 -EXT_DEVICE_MEMORY_REPORT_SPEC_VERSION :: 2 -EXT_DEVICE_MEMORY_REPORT_EXTENSION_NAME :: "VK_EXT_device_memory_report" -EXT_acquire_drm_display :: 1 -EXT_ACQUIRE_DRM_DISPLAY_SPEC_VERSION :: 1 -EXT_ACQUIRE_DRM_DISPLAY_EXTENSION_NAME :: "VK_EXT_acquire_drm_display" -EXT_robustness2 :: 1 -EXT_ROBUSTNESS_2_SPEC_VERSION :: 1 -EXT_ROBUSTNESS_2_EXTENSION_NAME :: "VK_EXT_robustness2" -EXT_custom_border_color :: 1 -EXT_CUSTOM_BORDER_COLOR_SPEC_VERSION :: 12 -EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME :: "VK_EXT_custom_border_color" -GOOGLE_user_type :: 1 -GOOGLE_USER_TYPE_SPEC_VERSION :: 1 -GOOGLE_USER_TYPE_EXTENSION_NAME :: "VK_GOOGLE_user_type" -EXT_private_data :: 1 -EXT_PRIVATE_DATA_SPEC_VERSION :: 1 -EXT_PRIVATE_DATA_EXTENSION_NAME :: "VK_EXT_private_data" -EXT_pipeline_creation_cache_control :: 1 -EXT_PIPELINE_CREATION_CACHE_CONTROL_SPEC_VERSION :: 3 -EXT_PIPELINE_CREATION_CACHE_CONTROL_EXTENSION_NAME :: "VK_EXT_pipeline_creation_cache_control" -NV_device_diagnostics_config :: 1 -NV_DEVICE_DIAGNOSTICS_CONFIG_SPEC_VERSION :: 1 -NV_DEVICE_DIAGNOSTICS_CONFIG_EXTENSION_NAME :: "VK_NV_device_diagnostics_config" -EXT_graphics_pipeline_library :: 1 -EXT_GRAPHICS_PIPELINE_LIBRARY_SPEC_VERSION :: 1 -EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME :: "VK_EXT_graphics_pipeline_library" -NV_fragment_shading_rate_enums :: 1 -NV_FRAGMENT_SHADING_RATE_ENUMS_SPEC_VERSION :: 1 -NV_FRAGMENT_SHADING_RATE_ENUMS_EXTENSION_NAME :: "VK_NV_fragment_shading_rate_enums" -NV_ray_tracing_motion_blur :: 1 -NV_RAY_TRACING_MOTION_BLUR_SPEC_VERSION :: 1 -NV_RAY_TRACING_MOTION_BLUR_EXTENSION_NAME :: "VK_NV_ray_tracing_motion_blur" -EXT_ycbcr_2plane_444_formats :: 1 -EXT_YCBCR_2PLANE_444_FORMATS_SPEC_VERSION :: 1 -EXT_YCBCR_2PLANE_444_FORMATS_EXTENSION_NAME :: "VK_EXT_ycbcr_2plane_444_formats" -EXT_fragment_density_map2 :: 1 -EXT_FRAGMENT_DENSITY_MAP_2_SPEC_VERSION :: 1 -EXT_FRAGMENT_DENSITY_MAP_2_EXTENSION_NAME :: "VK_EXT_fragment_density_map2" -EXT_image_robustness :: 1 -EXT_IMAGE_ROBUSTNESS_SPEC_VERSION :: 1 -EXT_IMAGE_ROBUSTNESS_EXTENSION_NAME :: "VK_EXT_image_robustness" -EXT_4444_formats :: 1 -EXT_4444_FORMATS_SPEC_VERSION :: 1 -EXT_4444_FORMATS_EXTENSION_NAME :: "VK_EXT_4444_formats" -EXT_rgba10x6_formats :: 1 -EXT_RGBA10X6_FORMATS_SPEC_VERSION :: 1 -EXT_RGBA10X6_FORMATS_EXTENSION_NAME :: "VK_EXT_rgba10x6_formats" -NV_acquire_winrt_display :: 1 -NV_ACQUIRE_WINRT_DISPLAY_SPEC_VERSION :: 1 -NV_ACQUIRE_WINRT_DISPLAY_EXTENSION_NAME :: "VK_NV_acquire_winrt_display" -EXT_vertex_input_dynamic_state :: 1 -EXT_VERTEX_INPUT_DYNAMIC_STATE_SPEC_VERSION :: 2 -EXT_VERTEX_INPUT_DYNAMIC_STATE_EXTENSION_NAME :: "VK_EXT_vertex_input_dynamic_state" -EXT_physical_device_drm :: 1 -EXT_PHYSICAL_DEVICE_DRM_SPEC_VERSION :: 1 -EXT_PHYSICAL_DEVICE_DRM_EXTENSION_NAME :: "VK_EXT_physical_device_drm" -EXT_depth_clip_control :: 1 -EXT_DEPTH_CLIP_CONTROL_SPEC_VERSION :: 1 -EXT_DEPTH_CLIP_CONTROL_EXTENSION_NAME :: "VK_EXT_depth_clip_control" -EXT_primitive_topology_list_restart :: 1 -EXT_PRIMITIVE_TOPOLOGY_LIST_RESTART_SPEC_VERSION :: 1 -EXT_PRIMITIVE_TOPOLOGY_LIST_RESTART_EXTENSION_NAME :: "VK_EXT_primitive_topology_list_restart" -NV_external_memory_rdma :: 1 -NV_EXTERNAL_MEMORY_RDMA_SPEC_VERSION :: 1 -NV_EXTERNAL_MEMORY_RDMA_EXTENSION_NAME :: "VK_NV_external_memory_rdma" -EXT_extended_dynamic_state2 :: 1 -EXT_EXTENDED_DYNAMIC_STATE_2_SPEC_VERSION :: 1 -EXT_EXTENDED_DYNAMIC_STATE_2_EXTENSION_NAME :: "VK_EXT_extended_dynamic_state2" -EXT_color_write_enable :: 1 -EXT_COLOR_WRITE_ENABLE_SPEC_VERSION :: 1 -EXT_COLOR_WRITE_ENABLE_EXTENSION_NAME :: "VK_EXT_color_write_enable" -EXT_primitives_generated_query :: 1 -EXT_PRIMITIVES_GENERATED_QUERY_SPEC_VERSION :: 1 -EXT_PRIMITIVES_GENERATED_QUERY_EXTENSION_NAME :: "VK_EXT_primitives_generated_query" -EXT_global_priority_query :: 1 -EXT_GLOBAL_PRIORITY_QUERY_SPEC_VERSION :: 1 -EXT_GLOBAL_PRIORITY_QUERY_EXTENSION_NAME :: "VK_EXT_global_priority_query" -EXT_image_view_min_lod :: 1 -EXT_IMAGE_VIEW_MIN_LOD_SPEC_VERSION :: 1 -EXT_IMAGE_VIEW_MIN_LOD_EXTENSION_NAME :: "VK_EXT_image_view_min_lod" -EXT_multi_draw :: 1 -EXT_MULTI_DRAW_SPEC_VERSION :: 1 -EXT_MULTI_DRAW_EXTENSION_NAME :: "VK_EXT_multi_draw" -EXT_image_2d_view_of_3d :: 1 -EXT_IMAGE_2D_VIEW_OF_3D_SPEC_VERSION :: 1 -EXT_IMAGE_2D_VIEW_OF_3D_EXTENSION_NAME :: "VK_EXT_image_2d_view_of_3d" -EXT_load_store_op_none :: 1 -EXT_LOAD_STORE_OP_NONE_SPEC_VERSION :: 1 -EXT_LOAD_STORE_OP_NONE_EXTENSION_NAME :: "VK_EXT_load_store_op_none" -EXT_border_color_swizzle :: 1 -EXT_BORDER_COLOR_SWIZZLE_SPEC_VERSION :: 1 -EXT_BORDER_COLOR_SWIZZLE_EXTENSION_NAME :: "VK_EXT_border_color_swizzle" -EXT_pageable_device_local_memory :: 1 -EXT_PAGEABLE_DEVICE_LOCAL_MEMORY_SPEC_VERSION :: 1 -EXT_PAGEABLE_DEVICE_LOCAL_MEMORY_EXTENSION_NAME :: "VK_EXT_pageable_device_local_memory" -NV_linear_color_attachment :: 1 -NV_LINEAR_COLOR_ATTACHMENT_SPEC_VERSION :: 1 -NV_LINEAR_COLOR_ATTACHMENT_EXTENSION_NAME :: "VK_NV_linear_color_attachment" -GOOGLE_surfaceless_query :: 1 -GOOGLE_SURFACELESS_QUERY_SPEC_VERSION :: 1 -GOOGLE_SURFACELESS_QUERY_EXTENSION_NAME :: "VK_GOOGLE_surfaceless_query" -KHR_acceleration_structure :: 1 -KHR_ACCELERATION_STRUCTURE_SPEC_VERSION :: 13 -KHR_ACCELERATION_STRUCTURE_EXTENSION_NAME :: "VK_KHR_acceleration_structure" -KHR_ray_tracing_pipeline :: 1 -KHR_RAY_TRACING_PIPELINE_SPEC_VERSION :: 1 -KHR_RAY_TRACING_PIPELINE_EXTENSION_NAME :: "VK_KHR_ray_tracing_pipeline" -KHR_ray_query :: 1 -KHR_RAY_QUERY_SPEC_VERSION :: 1 -KHR_RAY_QUERY_EXTENSION_NAME :: "VK_KHR_ray_query" -KHR_win32_surface :: 1 -KHR_WIN32_SURFACE_SPEC_VERSION :: 6 -KHR_WIN32_SURFACE_EXTENSION_NAME :: "VK_KHR_win32_surface" -KHR_external_memory_win32 :: 1 -KHR_EXTERNAL_MEMORY_WIN32_SPEC_VERSION :: 1 -KHR_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME :: "VK_KHR_external_memory_win32" -KHR_win32_keyed_mutex :: 1 -KHR_WIN32_KEYED_MUTEX_SPEC_VERSION :: 1 -KHR_WIN32_KEYED_MUTEX_EXTENSION_NAME :: "VK_KHR_win32_keyed_mutex" -KHR_external_semaphore_win32 :: 1 -KHR_EXTERNAL_SEMAPHORE_WIN32_SPEC_VERSION :: 1 -KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME :: "VK_KHR_external_semaphore_win32" -KHR_external_fence_win32 :: 1 -KHR_EXTERNAL_FENCE_WIN32_SPEC_VERSION :: 1 -KHR_EXTERNAL_FENCE_WIN32_EXTENSION_NAME :: "VK_KHR_external_fence_win32" -NV_external_memory_win32 :: 1 -NV_EXTERNAL_MEMORY_WIN32_SPEC_VERSION :: 1 -NV_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME :: "VK_NV_external_memory_win32" -NV_win32_keyed_mutex :: 1 -NV_WIN32_KEYED_MUTEX_SPEC_VERSION :: 2 -NV_WIN32_KEYED_MUTEX_EXTENSION_NAME :: "VK_NV_win32_keyed_mutex" -EXT_full_screen_exclusive :: 1 -EXT_FULL_SCREEN_EXCLUSIVE_SPEC_VERSION :: 4 -EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME :: "VK_EXT_full_screen_exclusive" -EXT_metal_surface :: 1 -EXT_METAL_SURFACE_SPEC_VERSION :: 1 -EXT_METAL_SURFACE_EXTENSION_NAME :: "VK_EXT_metal_surface" - -// Handles types -Instance :: distinct Handle -PhysicalDevice :: distinct Handle -Device :: distinct Handle -Queue :: distinct Handle -CommandBuffer :: distinct Handle -Buffer :: distinct NonDispatchableHandle -Image :: distinct NonDispatchableHandle -Semaphore :: distinct NonDispatchableHandle -Fence :: distinct NonDispatchableHandle -DeviceMemory :: distinct NonDispatchableHandle -Event :: distinct NonDispatchableHandle -QueryPool :: distinct NonDispatchableHandle -BufferView :: distinct NonDispatchableHandle -ImageView :: distinct NonDispatchableHandle -ShaderModule :: distinct NonDispatchableHandle -PipelineCache :: distinct NonDispatchableHandle -PipelineLayout :: distinct NonDispatchableHandle -Pipeline :: distinct NonDispatchableHandle -RenderPass :: distinct NonDispatchableHandle -DescriptorSetLayout :: distinct NonDispatchableHandle -Sampler :: distinct NonDispatchableHandle -DescriptorSet :: distinct NonDispatchableHandle -DescriptorPool :: distinct NonDispatchableHandle -Framebuffer :: distinct NonDispatchableHandle -CommandPool :: distinct NonDispatchableHandle -SamplerYcbcrConversion :: distinct NonDispatchableHandle -DescriptorUpdateTemplate :: distinct NonDispatchableHandle -PrivateDataSlot :: distinct NonDispatchableHandle -SurfaceKHR :: distinct NonDispatchableHandle -SwapchainKHR :: distinct NonDispatchableHandle -DisplayKHR :: distinct NonDispatchableHandle -DisplayModeKHR :: distinct NonDispatchableHandle -DeferredOperationKHR :: distinct NonDispatchableHandle -DebugReportCallbackEXT :: distinct NonDispatchableHandle -CuModuleNVX :: distinct NonDispatchableHandle -CuFunctionNVX :: distinct NonDispatchableHandle -DebugUtilsMessengerEXT :: distinct NonDispatchableHandle -ValidationCacheEXT :: distinct NonDispatchableHandle -AccelerationStructureNV :: distinct NonDispatchableHandle -PerformanceConfigurationINTEL :: distinct NonDispatchableHandle -IndirectCommandsLayoutNV :: distinct NonDispatchableHandle -AccelerationStructureKHR :: distinct NonDispatchableHandle - - +// +// Vulkan wrapper generated from "https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/master/include/vulkan/vulkan_core.h" +// +package vulkan +API_VERSION_1_0 :: (1<<22) | (0<<12) | (0) +API_VERSION_1_1 :: (1<<22) | (1<<12) | (0) +API_VERSION_1_2 :: (1<<22) | (2<<12) | (0) +API_VERSION_1_3 :: (1<<22) | (3<<12) | (0) + +MAKE_VERSION :: proc(major, minor, patch: u32) -> u32 { + return (major<<22) | (minor<<12) | (patch) +} + +// Base types +Flags :: distinct u32 +Flags64 :: distinct u64 +DeviceSize :: distinct u64 +DeviceAddress :: distinct u64 +SampleMask :: distinct u32 + +Handle :: distinct rawptr +NonDispatchableHandle :: distinct u64 + +SetProcAddressType :: #type proc(p: rawptr, name: cstring) + + +RemoteAddressNV :: distinct rawptr // Declared inline before MemoryGetRemoteAddressInfoNV + +// Base constants +LOD_CLAMP_NONE :: 1000.0 +REMAINING_MIP_LEVELS :: ~u32(0) +REMAINING_ARRAY_LAYERS :: ~u32(0) +WHOLE_SIZE :: ~u64(0) +ATTACHMENT_UNUSED :: ~u32(0) +TRUE :: 1 +FALSE :: 0 +QUEUE_FAMILY_IGNORED :: ~u32(0) +SUBPASS_EXTERNAL :: ~u32(0) +MAX_PHYSICAL_DEVICE_NAME_SIZE :: 256 +MAX_SHADER_MODULE_IDENTIFIER_SIZE_EXT :: 32 +UUID_SIZE :: 16 +MAX_MEMORY_TYPES :: 32 +MAX_MEMORY_HEAPS :: 16 +MAX_EXTENSION_NAME_SIZE :: 256 +MAX_DESCRIPTION_SIZE :: 256 +MAX_DEVICE_GROUP_SIZE :: 32 +LUID_SIZE_KHX :: 8 +LUID_SIZE :: 8 +MAX_QUEUE_FAMILY_EXTERNAL :: ~u32(1) +MAX_GLOBAL_PRIORITY_SIZE_EXT :: 16 +QUEUE_FAMILY_EXTERNAL :: MAX_QUEUE_FAMILY_EXTERNAL + +// General Constants +HEADER_VERSION :: 250 +MAX_DRIVER_NAME_SIZE :: 256 +MAX_DRIVER_INFO_SIZE :: 256 + +// Vulkan Video Constants +VIDEO_H264_CPB_CNT_LIST_SIZE :: 32 +VIDEO_H264_SCALING_LIST_4X4_NUM_LISTS :: 6 +VIDEO_H264_SCALING_LIST_4X4_NUM_ELEMENTS :: 16 +VIDEO_H264_SCALING_LIST_8X8_NUM_LISTS :: 6 +VIDEO_H264_SCALING_LIST_8X8_NUM_ELEMENTS :: 64 +VIDEO_H264_MAX_NUM_LIST_REF :: 32 +VIDEO_H264_MAX_CHROMA_PLANES :: 2 +VIDEO_H265_SUBLAYERS_LIST_SIZE :: 7 +VIDEO_H265_CPB_CNT_LIST_SIZE :: 32 +VIDEO_H265_SCALING_LIST_4X4_NUM_LISTS :: 6 +VIDEO_H265_SCALING_LIST_4X4_NUM_ELEMENTS :: 16 +VIDEO_H265_SCALING_LIST_8X8_NUM_LISTS :: 6 +VIDEO_H265_SCALING_LIST_8X8_NUM_ELEMENTS :: 64 +VIDEO_H265_SCALING_LIST_16X16_NUM_LISTS :: 6 +VIDEO_H265_SCALING_LIST_16X16_NUM_ELEMENTS :: 64 +VIDEO_H265_SCALING_LIST_32X32_NUM_LISTS :: 2 +VIDEO_H265_SCALING_LIST_32X32_NUM_ELEMENTS :: 64 +VIDEO_H265_PREDICTOR_PALETTE_COMPONENTS_LIST_SIZE :: 3 +VIDEO_H265_PREDICTOR_PALETTE_COMP_ENTRIES_LIST_SIZE :: 128 +VIDEO_H265_MAX_DPB_SIZE :: 16 +VIDEO_H265_MAX_LONG_TERM_REF_PICS_SPS :: 32 +VIDEO_H265_CHROMA_QP_OFFSET_LIST_SIZE :: 6 +VIDEO_H265_CHROMA_QP_OFFSET_TILE_COLS_LIST_SIZE :: 19 +VIDEO_H265_CHROMA_QP_OFFSET_TILE_ROWS_LIST_SIZE :: 21 +VIDEO_H265_MAX_NUM_LIST_REF :: 15 +VIDEO_H265_MAX_CHROMA_PLANES :: 2 +VIDEO_H265_MAX_SHORT_TERM_REF_PIC_SETS :: 64 +VIDEO_H265_MAX_LONG_TERM_PICS :: 16 +VIDEO_H265_MAX_DELTA_POC :: 48 +VIDEO_DECODE_H264_FIELD_ORDER_COUNT_LIST_SIZE :: 2 +VIDEO_DECODE_H265_REF_PIC_SET_LIST_SIZE :: 8 + +// Vendor Constants +KHR_surface :: 1 +KHR_SURFACE_SPEC_VERSION :: 25 +KHR_SURFACE_EXTENSION_NAME :: "VK_KHR_surface" +KHR_swapchain :: 1 +KHR_SWAPCHAIN_SPEC_VERSION :: 70 +KHR_SWAPCHAIN_EXTENSION_NAME :: "VK_KHR_swapchain" +KHR_display :: 1 +KHR_DISPLAY_SPEC_VERSION :: 23 +KHR_DISPLAY_EXTENSION_NAME :: "VK_KHR_display" +KHR_display_swapchain :: 1 +KHR_DISPLAY_SWAPCHAIN_SPEC_VERSION :: 10 +KHR_DISPLAY_SWAPCHAIN_EXTENSION_NAME :: "VK_KHR_display_swapchain" +KHR_sampler_mirror_clamp_to_edge :: 1 +KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_SPEC_VERSION :: 3 +KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME :: "VK_KHR_sampler_mirror_clamp_to_edge" +KHR_video_queue :: 1 +KHR_VIDEO_QUEUE_SPEC_VERSION :: 8 +KHR_VIDEO_QUEUE_EXTENSION_NAME :: "VK_KHR_video_queue" +KHR_video_decode_queue :: 1 +KHR_VIDEO_DECODE_QUEUE_SPEC_VERSION :: 7 +KHR_VIDEO_DECODE_QUEUE_EXTENSION_NAME :: "VK_KHR_video_decode_queue" +KHR_video_decode_h264 :: 1 +KHR_VIDEO_DECODE_H264_SPEC_VERSION :: 8 +KHR_VIDEO_DECODE_H264_EXTENSION_NAME :: "VK_KHR_video_decode_h264" +KHR_dynamic_rendering :: 1 +KHR_DYNAMIC_RENDERING_SPEC_VERSION :: 1 +KHR_DYNAMIC_RENDERING_EXTENSION_NAME :: "VK_KHR_dynamic_rendering" +KHR_multiview :: 1 +KHR_MULTIVIEW_SPEC_VERSION :: 1 +KHR_MULTIVIEW_EXTENSION_NAME :: "VK_KHR_multiview" +KHR_get_physical_device_properties2 :: 1 +KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_SPEC_VERSION :: 2 +KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME :: "VK_KHR_get_physical_device_properties2" +KHR_device_group :: 1 +KHR_DEVICE_GROUP_SPEC_VERSION :: 4 +KHR_DEVICE_GROUP_EXTENSION_NAME :: "VK_KHR_device_group" +KHR_shader_draw_parameters :: 1 +KHR_SHADER_DRAW_PARAMETERS_SPEC_VERSION :: 1 +KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME :: "VK_KHR_shader_draw_parameters" +KHR_maintenance1 :: 1 +KHR_MAINTENANCE_1_SPEC_VERSION :: 2 +KHR_MAINTENANCE_1_EXTENSION_NAME :: "VK_KHR_maintenance1" +KHR_MAINTENANCE1_SPEC_VERSION :: KHR_MAINTENANCE_1_SPEC_VERSION +KHR_MAINTENANCE1_EXTENSION_NAME :: KHR_MAINTENANCE_1_EXTENSION_NAME +KHR_device_group_creation :: 1 +KHR_DEVICE_GROUP_CREATION_SPEC_VERSION :: 1 +KHR_DEVICE_GROUP_CREATION_EXTENSION_NAME :: "VK_KHR_device_group_creation" +MAX_DEVICE_GROUP_SIZE_KHR :: MAX_DEVICE_GROUP_SIZE +KHR_external_memory_capabilities :: 1 +KHR_EXTERNAL_MEMORY_CAPABILITIES_SPEC_VERSION :: 1 +KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME :: "VK_KHR_external_memory_capabilities" +LUID_SIZE_KHR :: LUID_SIZE +KHR_external_memory :: 1 +KHR_EXTERNAL_MEMORY_SPEC_VERSION :: 1 +KHR_EXTERNAL_MEMORY_EXTENSION_NAME :: "VK_KHR_external_memory" +QUEUE_FAMILY_EXTERNAL_KHR :: QUEUE_FAMILY_EXTERNAL +KHR_external_memory_fd :: 1 +KHR_EXTERNAL_MEMORY_FD_SPEC_VERSION :: 1 +KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME :: "VK_KHR_external_memory_fd" +KHR_external_semaphore_capabilities :: 1 +KHR_EXTERNAL_SEMAPHORE_CAPABILITIES_SPEC_VERSION :: 1 +KHR_EXTERNAL_SEMAPHORE_CAPABILITIES_EXTENSION_NAME :: "VK_KHR_external_semaphore_capabilities" +KHR_external_semaphore :: 1 +KHR_EXTERNAL_SEMAPHORE_SPEC_VERSION :: 1 +KHR_EXTERNAL_SEMAPHORE_EXTENSION_NAME :: "VK_KHR_external_semaphore" +KHR_external_semaphore_fd :: 1 +KHR_EXTERNAL_SEMAPHORE_FD_SPEC_VERSION :: 1 +KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME :: "VK_KHR_external_semaphore_fd" +KHR_push_descriptor :: 1 +KHR_PUSH_DESCRIPTOR_SPEC_VERSION :: 2 +KHR_PUSH_DESCRIPTOR_EXTENSION_NAME :: "VK_KHR_push_descriptor" +KHR_shader_float16_int8 :: 1 +KHR_SHADER_FLOAT16_INT8_SPEC_VERSION :: 1 +KHR_SHADER_FLOAT16_INT8_EXTENSION_NAME :: "VK_KHR_shader_float16_int8" +KHR_16bit_storage :: 1 +KHR_16BIT_STORAGE_SPEC_VERSION :: 1 +KHR_16BIT_STORAGE_EXTENSION_NAME :: "VK_KHR_16bit_storage" +KHR_incremental_present :: 1 +KHR_INCREMENTAL_PRESENT_SPEC_VERSION :: 2 +KHR_INCREMENTAL_PRESENT_EXTENSION_NAME :: "VK_KHR_incremental_present" +KHR_descriptor_update_template :: 1 +KHR_DESCRIPTOR_UPDATE_TEMPLATE_SPEC_VERSION :: 1 +KHR_DESCRIPTOR_UPDATE_TEMPLATE_EXTENSION_NAME :: "VK_KHR_descriptor_update_template" +KHR_imageless_framebuffer :: 1 +KHR_IMAGELESS_FRAMEBUFFER_SPEC_VERSION :: 1 +KHR_IMAGELESS_FRAMEBUFFER_EXTENSION_NAME :: "VK_KHR_imageless_framebuffer" +KHR_create_renderpass2 :: 1 +KHR_CREATE_RENDERPASS_2_SPEC_VERSION :: 1 +KHR_CREATE_RENDERPASS_2_EXTENSION_NAME :: "VK_KHR_create_renderpass2" +KHR_shared_presentable_image :: 1 +KHR_SHARED_PRESENTABLE_IMAGE_SPEC_VERSION :: 1 +KHR_SHARED_PRESENTABLE_IMAGE_EXTENSION_NAME :: "VK_KHR_shared_presentable_image" +KHR_external_fence_capabilities :: 1 +KHR_EXTERNAL_FENCE_CAPABILITIES_SPEC_VERSION :: 1 +KHR_EXTERNAL_FENCE_CAPABILITIES_EXTENSION_NAME :: "VK_KHR_external_fence_capabilities" +KHR_external_fence :: 1 +KHR_EXTERNAL_FENCE_SPEC_VERSION :: 1 +KHR_EXTERNAL_FENCE_EXTENSION_NAME :: "VK_KHR_external_fence" +KHR_external_fence_fd :: 1 +KHR_EXTERNAL_FENCE_FD_SPEC_VERSION :: 1 +KHR_EXTERNAL_FENCE_FD_EXTENSION_NAME :: "VK_KHR_external_fence_fd" +KHR_performance_query :: 1 +KHR_PERFORMANCE_QUERY_SPEC_VERSION :: 1 +KHR_PERFORMANCE_QUERY_EXTENSION_NAME :: "VK_KHR_performance_query" +KHR_maintenance2 :: 1 +KHR_MAINTENANCE_2_SPEC_VERSION :: 1 +KHR_MAINTENANCE_2_EXTENSION_NAME :: "VK_KHR_maintenance2" +KHR_MAINTENANCE2_SPEC_VERSION :: KHR_MAINTENANCE_2_SPEC_VERSION +KHR_MAINTENANCE2_EXTENSION_NAME :: KHR_MAINTENANCE_2_EXTENSION_NAME +KHR_get_surface_capabilities2 :: 1 +KHR_GET_SURFACE_CAPABILITIES_2_SPEC_VERSION :: 1 +KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME :: "VK_KHR_get_surface_capabilities2" +KHR_variable_pointers :: 1 +KHR_VARIABLE_POINTERS_SPEC_VERSION :: 1 +KHR_VARIABLE_POINTERS_EXTENSION_NAME :: "VK_KHR_variable_pointers" +KHR_get_display_properties2 :: 1 +KHR_GET_DISPLAY_PROPERTIES_2_SPEC_VERSION :: 1 +KHR_GET_DISPLAY_PROPERTIES_2_EXTENSION_NAME :: "VK_KHR_get_display_properties2" +KHR_dedicated_allocation :: 1 +KHR_DEDICATED_ALLOCATION_SPEC_VERSION :: 3 +KHR_DEDICATED_ALLOCATION_EXTENSION_NAME :: "VK_KHR_dedicated_allocation" +KHR_storage_buffer_storage_class :: 1 +KHR_STORAGE_BUFFER_STORAGE_CLASS_SPEC_VERSION :: 1 +KHR_STORAGE_BUFFER_STORAGE_CLASS_EXTENSION_NAME :: "VK_KHR_storage_buffer_storage_class" +KHR_relaxed_block_layout :: 1 +KHR_RELAXED_BLOCK_LAYOUT_SPEC_VERSION :: 1 +KHR_RELAXED_BLOCK_LAYOUT_EXTENSION_NAME :: "VK_KHR_relaxed_block_layout" +KHR_get_memory_requirements2 :: 1 +KHR_GET_MEMORY_REQUIREMENTS_2_SPEC_VERSION :: 1 +KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME :: "VK_KHR_get_memory_requirements2" +KHR_image_format_list :: 1 +KHR_IMAGE_FORMAT_LIST_SPEC_VERSION :: 1 +KHR_IMAGE_FORMAT_LIST_EXTENSION_NAME :: "VK_KHR_image_format_list" +KHR_sampler_ycbcr_conversion :: 1 +KHR_SAMPLER_YCBCR_CONVERSION_SPEC_VERSION :: 14 +KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME :: "VK_KHR_sampler_ycbcr_conversion" +KHR_bind_memory2 :: 1 +KHR_BIND_MEMORY_2_SPEC_VERSION :: 1 +KHR_BIND_MEMORY_2_EXTENSION_NAME :: "VK_KHR_bind_memory2" +KHR_maintenance3 :: 1 +KHR_MAINTENANCE_3_SPEC_VERSION :: 1 +KHR_MAINTENANCE_3_EXTENSION_NAME :: "VK_KHR_maintenance3" +KHR_MAINTENANCE3_SPEC_VERSION :: KHR_MAINTENANCE_3_SPEC_VERSION +KHR_MAINTENANCE3_EXTENSION_NAME :: KHR_MAINTENANCE_3_EXTENSION_NAME +KHR_draw_indirect_count :: 1 +KHR_DRAW_INDIRECT_COUNT_SPEC_VERSION :: 1 +KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME :: "VK_KHR_draw_indirect_count" +KHR_shader_subgroup_extended_types :: 1 +KHR_SHADER_SUBGROUP_EXTENDED_TYPES_SPEC_VERSION :: 1 +KHR_SHADER_SUBGROUP_EXTENDED_TYPES_EXTENSION_NAME :: "VK_KHR_shader_subgroup_extended_types" +KHR_8bit_storage :: 1 +KHR_8BIT_STORAGE_SPEC_VERSION :: 1 +KHR_8BIT_STORAGE_EXTENSION_NAME :: "VK_KHR_8bit_storage" +KHR_shader_atomic_int64 :: 1 +KHR_SHADER_ATOMIC_INT64_SPEC_VERSION :: 1 +KHR_SHADER_ATOMIC_INT64_EXTENSION_NAME :: "VK_KHR_shader_atomic_int64" +KHR_shader_clock :: 1 +KHR_SHADER_CLOCK_SPEC_VERSION :: 1 +KHR_SHADER_CLOCK_EXTENSION_NAME :: "VK_KHR_shader_clock" +KHR_video_decode_h265 :: 1 +KHR_VIDEO_DECODE_H265_SPEC_VERSION :: 7 +KHR_VIDEO_DECODE_H265_EXTENSION_NAME :: "VK_KHR_video_decode_h265" +KHR_global_priority :: 1 +MAX_GLOBAL_PRIORITY_SIZE_KHR :: 16 +KHR_GLOBAL_PRIORITY_SPEC_VERSION :: 1 +KHR_GLOBAL_PRIORITY_EXTENSION_NAME :: "VK_KHR_global_priority" +KHR_driver_properties :: 1 +KHR_DRIVER_PROPERTIES_SPEC_VERSION :: 1 +KHR_DRIVER_PROPERTIES_EXTENSION_NAME :: "VK_KHR_driver_properties" +MAX_DRIVER_NAME_SIZE_KHR :: MAX_DRIVER_NAME_SIZE +MAX_DRIVER_INFO_SIZE_KHR :: MAX_DRIVER_INFO_SIZE +KHR_shader_float_controls :: 1 +KHR_SHADER_FLOAT_CONTROLS_SPEC_VERSION :: 4 +KHR_SHADER_FLOAT_CONTROLS_EXTENSION_NAME :: "VK_KHR_shader_float_controls" +KHR_depth_stencil_resolve :: 1 +KHR_DEPTH_STENCIL_RESOLVE_SPEC_VERSION :: 1 +KHR_DEPTH_STENCIL_RESOLVE_EXTENSION_NAME :: "VK_KHR_depth_stencil_resolve" +KHR_swapchain_mutable_format :: 1 +KHR_SWAPCHAIN_MUTABLE_FORMAT_SPEC_VERSION :: 1 +KHR_SWAPCHAIN_MUTABLE_FORMAT_EXTENSION_NAME :: "VK_KHR_swapchain_mutable_format" +KHR_timeline_semaphore :: 1 +KHR_TIMELINE_SEMAPHORE_SPEC_VERSION :: 2 +KHR_TIMELINE_SEMAPHORE_EXTENSION_NAME :: "VK_KHR_timeline_semaphore" +KHR_vulkan_memory_model :: 1 +KHR_VULKAN_MEMORY_MODEL_SPEC_VERSION :: 3 +KHR_VULKAN_MEMORY_MODEL_EXTENSION_NAME :: "VK_KHR_vulkan_memory_model" +KHR_shader_terminate_invocation :: 1 +KHR_SHADER_TERMINATE_INVOCATION_SPEC_VERSION :: 1 +KHR_SHADER_TERMINATE_INVOCATION_EXTENSION_NAME :: "VK_KHR_shader_terminate_invocation" +KHR_fragment_shading_rate :: 1 +KHR_FRAGMENT_SHADING_RATE_SPEC_VERSION :: 2 +KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME :: "VK_KHR_fragment_shading_rate" +KHR_spirv_1_4 :: 1 +KHR_SPIRV_1_4_SPEC_VERSION :: 1 +KHR_SPIRV_1_4_EXTENSION_NAME :: "VK_KHR_spirv_1_4" +KHR_surface_protected_capabilities :: 1 +KHR_SURFACE_PROTECTED_CAPABILITIES_SPEC_VERSION :: 1 +KHR_SURFACE_PROTECTED_CAPABILITIES_EXTENSION_NAME :: "VK_KHR_surface_protected_capabilities" +KHR_separate_depth_stencil_layouts :: 1 +KHR_SEPARATE_DEPTH_STENCIL_LAYOUTS_SPEC_VERSION :: 1 +KHR_SEPARATE_DEPTH_STENCIL_LAYOUTS_EXTENSION_NAME :: "VK_KHR_separate_depth_stencil_layouts" +KHR_present_wait :: 1 +KHR_PRESENT_WAIT_SPEC_VERSION :: 1 +KHR_PRESENT_WAIT_EXTENSION_NAME :: "VK_KHR_present_wait" +KHR_uniform_buffer_standard_layout :: 1 +KHR_UNIFORM_BUFFER_STANDARD_LAYOUT_SPEC_VERSION :: 1 +KHR_UNIFORM_BUFFER_STANDARD_LAYOUT_EXTENSION_NAME :: "VK_KHR_uniform_buffer_standard_layout" +KHR_buffer_device_address :: 1 +KHR_BUFFER_DEVICE_ADDRESS_SPEC_VERSION :: 1 +KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME :: "VK_KHR_buffer_device_address" +KHR_deferred_host_operations :: 1 +KHR_DEFERRED_HOST_OPERATIONS_SPEC_VERSION :: 4 +KHR_DEFERRED_HOST_OPERATIONS_EXTENSION_NAME :: "VK_KHR_deferred_host_operations" +KHR_pipeline_executable_properties :: 1 +KHR_PIPELINE_EXECUTABLE_PROPERTIES_SPEC_VERSION :: 1 +KHR_PIPELINE_EXECUTABLE_PROPERTIES_EXTENSION_NAME :: "VK_KHR_pipeline_executable_properties" +KHR_map_memory2 :: 1 +KHR_MAP_MEMORY_2_SPEC_VERSION :: 1 +KHR_MAP_MEMORY_2_EXTENSION_NAME :: "VK_KHR_map_memory2" +KHR_shader_integer_dot_product :: 1 +KHR_SHADER_INTEGER_DOT_PRODUCT_SPEC_VERSION :: 1 +KHR_SHADER_INTEGER_DOT_PRODUCT_EXTENSION_NAME :: "VK_KHR_shader_integer_dot_product" +KHR_pipeline_library :: 1 +KHR_PIPELINE_LIBRARY_SPEC_VERSION :: 1 +KHR_PIPELINE_LIBRARY_EXTENSION_NAME :: "VK_KHR_pipeline_library" +KHR_shader_non_semantic_info :: 1 +KHR_SHADER_NON_SEMANTIC_INFO_SPEC_VERSION :: 1 +KHR_SHADER_NON_SEMANTIC_INFO_EXTENSION_NAME :: "VK_KHR_shader_non_semantic_info" +KHR_present_id :: 1 +KHR_PRESENT_ID_SPEC_VERSION :: 1 +KHR_PRESENT_ID_EXTENSION_NAME :: "VK_KHR_present_id" +KHR_synchronization2 :: 1 +KHR_SYNCHRONIZATION_2_SPEC_VERSION :: 1 +KHR_SYNCHRONIZATION_2_EXTENSION_NAME :: "VK_KHR_synchronization2" +KHR_fragment_shader_barycentric :: 1 +KHR_FRAGMENT_SHADER_BARYCENTRIC_SPEC_VERSION :: 1 +KHR_FRAGMENT_SHADER_BARYCENTRIC_EXTENSION_NAME :: "VK_KHR_fragment_shader_barycentric" +KHR_shader_subgroup_uniform_control_flow :: 1 +KHR_SHADER_SUBGROUP_UNIFORM_CONTROL_FLOW_SPEC_VERSION :: 1 +KHR_SHADER_SUBGROUP_UNIFORM_CONTROL_FLOW_EXTENSION_NAME :: "VK_KHR_shader_subgroup_uniform_control_flow" +KHR_zero_initialize_workgroup_memory :: 1 +KHR_ZERO_INITIALIZE_WORKGROUP_MEMORY_SPEC_VERSION :: 1 +KHR_ZERO_INITIALIZE_WORKGROUP_MEMORY_EXTENSION_NAME :: "VK_KHR_zero_initialize_workgroup_memory" +KHR_workgroup_memory_explicit_layout :: 1 +KHR_WORKGROUP_MEMORY_EXPLICIT_LAYOUT_SPEC_VERSION :: 1 +KHR_WORKGROUP_MEMORY_EXPLICIT_LAYOUT_EXTENSION_NAME :: "VK_KHR_workgroup_memory_explicit_layout" +KHR_copy_commands2 :: 1 +KHR_COPY_COMMANDS_2_SPEC_VERSION :: 1 +KHR_COPY_COMMANDS_2_EXTENSION_NAME :: "VK_KHR_copy_commands2" +KHR_format_feature_flags2 :: 1 +KHR_FORMAT_FEATURE_FLAGS_2_SPEC_VERSION :: 2 +KHR_FORMAT_FEATURE_FLAGS_2_EXTENSION_NAME :: "VK_KHR_format_feature_flags2" +KHR_ray_tracing_maintenance1 :: 1 +KHR_RAY_TRACING_MAINTENANCE_1_SPEC_VERSION :: 1 +KHR_RAY_TRACING_MAINTENANCE_1_EXTENSION_NAME :: "VK_KHR_ray_tracing_maintenance1" +KHR_portability_enumeration :: 1 +KHR_PORTABILITY_ENUMERATION_SPEC_VERSION :: 1 +KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME :: "VK_KHR_portability_enumeration" +KHR_maintenance4 :: 1 +KHR_MAINTENANCE_4_SPEC_VERSION :: 2 +KHR_MAINTENANCE_4_EXTENSION_NAME :: "VK_KHR_maintenance4" +KHR_ray_tracing_position_fetch :: 1 +KHR_RAY_TRACING_POSITION_FETCH_SPEC_VERSION :: 1 +KHR_RAY_TRACING_POSITION_FETCH_EXTENSION_NAME :: "VK_KHR_ray_tracing_position_fetch" +EXT_debug_report :: 1 +EXT_DEBUG_REPORT_SPEC_VERSION :: 10 +EXT_DEBUG_REPORT_EXTENSION_NAME :: "VK_EXT_debug_report" +NV_glsl_shader :: 1 +NV_GLSL_SHADER_SPEC_VERSION :: 1 +NV_GLSL_SHADER_EXTENSION_NAME :: "VK_NV_glsl_shader" +EXT_depth_range_unrestricted :: 1 +EXT_DEPTH_RANGE_UNRESTRICTED_SPEC_VERSION :: 1 +EXT_DEPTH_RANGE_UNRESTRICTED_EXTENSION_NAME :: "VK_EXT_depth_range_unrestricted" +AMD_rasterization_order :: 1 +AMD_RASTERIZATION_ORDER_SPEC_VERSION :: 1 +AMD_RASTERIZATION_ORDER_EXTENSION_NAME :: "VK_AMD_rasterization_order" +AMD_shader_trinary_minmax :: 1 +AMD_SHADER_TRINARY_MINMAX_SPEC_VERSION :: 1 +AMD_SHADER_TRINARY_MINMAX_EXTENSION_NAME :: "VK_AMD_shader_trinary_minmax" +AMD_shader_explicit_vertex_parameter :: 1 +AMD_SHADER_EXPLICIT_VERTEX_PARAMETER_SPEC_VERSION :: 1 +AMD_SHADER_EXPLICIT_VERTEX_PARAMETER_EXTENSION_NAME :: "VK_AMD_shader_explicit_vertex_parameter" +EXT_debug_marker :: 1 +EXT_DEBUG_MARKER_SPEC_VERSION :: 4 +EXT_DEBUG_MARKER_EXTENSION_NAME :: "VK_EXT_debug_marker" +AMD_gcn_shader :: 1 +AMD_GCN_SHADER_SPEC_VERSION :: 1 +AMD_GCN_SHADER_EXTENSION_NAME :: "VK_AMD_gcn_shader" +NV_dedicated_allocation :: 1 +NV_DEDICATED_ALLOCATION_SPEC_VERSION :: 1 +NV_DEDICATED_ALLOCATION_EXTENSION_NAME :: "VK_NV_dedicated_allocation" +EXT_transform_feedback :: 1 +EXT_TRANSFORM_FEEDBACK_SPEC_VERSION :: 1 +EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME :: "VK_EXT_transform_feedback" +NVX_binary_import :: 1 +NVX_BINARY_IMPORT_SPEC_VERSION :: 1 +NVX_BINARY_IMPORT_EXTENSION_NAME :: "VK_NVX_binary_import" +NVX_image_view_handle :: 1 +NVX_IMAGE_VIEW_HANDLE_SPEC_VERSION :: 2 +NVX_IMAGE_VIEW_HANDLE_EXTENSION_NAME :: "VK_NVX_image_view_handle" +AMD_draw_indirect_count :: 1 +AMD_DRAW_INDIRECT_COUNT_SPEC_VERSION :: 2 +AMD_DRAW_INDIRECT_COUNT_EXTENSION_NAME :: "VK_AMD_draw_indirect_count" +AMD_negative_viewport_height :: 1 +AMD_NEGATIVE_VIEWPORT_HEIGHT_SPEC_VERSION :: 1 +AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME :: "VK_AMD_negative_viewport_height" +AMD_gpu_shader_half_float :: 1 +AMD_GPU_SHADER_HALF_FLOAT_SPEC_VERSION :: 2 +AMD_GPU_SHADER_HALF_FLOAT_EXTENSION_NAME :: "VK_AMD_gpu_shader_half_float" +AMD_shader_ballot :: 1 +AMD_SHADER_BALLOT_SPEC_VERSION :: 1 +AMD_SHADER_BALLOT_EXTENSION_NAME :: "VK_AMD_shader_ballot" +AMD_texture_gather_bias_lod :: 1 +AMD_TEXTURE_GATHER_BIAS_LOD_SPEC_VERSION :: 1 +AMD_TEXTURE_GATHER_BIAS_LOD_EXTENSION_NAME :: "VK_AMD_texture_gather_bias_lod" +AMD_shader_info :: 1 +AMD_SHADER_INFO_SPEC_VERSION :: 1 +AMD_SHADER_INFO_EXTENSION_NAME :: "VK_AMD_shader_info" +AMD_shader_image_load_store_lod :: 1 +AMD_SHADER_IMAGE_LOAD_STORE_LOD_SPEC_VERSION :: 1 +AMD_SHADER_IMAGE_LOAD_STORE_LOD_EXTENSION_NAME :: "VK_AMD_shader_image_load_store_lod" +NV_corner_sampled_image :: 1 +NV_CORNER_SAMPLED_IMAGE_SPEC_VERSION :: 2 +NV_CORNER_SAMPLED_IMAGE_EXTENSION_NAME :: "VK_NV_corner_sampled_image" +NV_external_memory_capabilities :: 1 +NV_EXTERNAL_MEMORY_CAPABILITIES_SPEC_VERSION :: 1 +NV_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME :: "VK_NV_external_memory_capabilities" +NV_external_memory :: 1 +NV_EXTERNAL_MEMORY_SPEC_VERSION :: 1 +NV_EXTERNAL_MEMORY_EXTENSION_NAME :: "VK_NV_external_memory" +EXT_validation_flags :: 1 +EXT_VALIDATION_FLAGS_SPEC_VERSION :: 2 +EXT_VALIDATION_FLAGS_EXTENSION_NAME :: "VK_EXT_validation_flags" +EXT_shader_subgroup_ballot :: 1 +EXT_SHADER_SUBGROUP_BALLOT_SPEC_VERSION :: 1 +EXT_SHADER_SUBGROUP_BALLOT_EXTENSION_NAME :: "VK_EXT_shader_subgroup_ballot" +EXT_shader_subgroup_vote :: 1 +EXT_SHADER_SUBGROUP_VOTE_SPEC_VERSION :: 1 +EXT_SHADER_SUBGROUP_VOTE_EXTENSION_NAME :: "VK_EXT_shader_subgroup_vote" +EXT_texture_compression_astc_hdr :: 1 +EXT_TEXTURE_COMPRESSION_ASTC_HDR_SPEC_VERSION :: 1 +EXT_TEXTURE_COMPRESSION_ASTC_HDR_EXTENSION_NAME :: "VK_EXT_texture_compression_astc_hdr" +EXT_astc_decode_mode :: 1 +EXT_ASTC_DECODE_MODE_SPEC_VERSION :: 1 +EXT_ASTC_DECODE_MODE_EXTENSION_NAME :: "VK_EXT_astc_decode_mode" +EXT_pipeline_robustness :: 1 +EXT_PIPELINE_ROBUSTNESS_SPEC_VERSION :: 1 +EXT_PIPELINE_ROBUSTNESS_EXTENSION_NAME :: "VK_EXT_pipeline_robustness" +EXT_conditional_rendering :: 1 +EXT_CONDITIONAL_RENDERING_SPEC_VERSION :: 2 +EXT_CONDITIONAL_RENDERING_EXTENSION_NAME :: "VK_EXT_conditional_rendering" +NV_clip_space_w_scaling :: 1 +NV_CLIP_SPACE_W_SCALING_SPEC_VERSION :: 1 +NV_CLIP_SPACE_W_SCALING_EXTENSION_NAME :: "VK_NV_clip_space_w_scaling" +EXT_direct_mode_display :: 1 +EXT_DIRECT_MODE_DISPLAY_SPEC_VERSION :: 1 +EXT_DIRECT_MODE_DISPLAY_EXTENSION_NAME :: "VK_EXT_direct_mode_display" +EXT_display_surface_counter :: 1 +EXT_DISPLAY_SURFACE_COUNTER_SPEC_VERSION :: 1 +EXT_DISPLAY_SURFACE_COUNTER_EXTENSION_NAME :: "VK_EXT_display_surface_counter" +EXT_display_control :: 1 +EXT_DISPLAY_CONTROL_SPEC_VERSION :: 1 +EXT_DISPLAY_CONTROL_EXTENSION_NAME :: "VK_EXT_display_control" +GOOGLE_display_timing :: 1 +GOOGLE_DISPLAY_TIMING_SPEC_VERSION :: 1 +GOOGLE_DISPLAY_TIMING_EXTENSION_NAME :: "VK_GOOGLE_display_timing" +NV_sample_mask_override_coverage :: 1 +NV_SAMPLE_MASK_OVERRIDE_COVERAGE_SPEC_VERSION :: 1 +NV_SAMPLE_MASK_OVERRIDE_COVERAGE_EXTENSION_NAME :: "VK_NV_sample_mask_override_coverage" +NV_geometry_shader_passthrough :: 1 +NV_GEOMETRY_SHADER_PASSTHROUGH_SPEC_VERSION :: 1 +NV_GEOMETRY_SHADER_PASSTHROUGH_EXTENSION_NAME :: "VK_NV_geometry_shader_passthrough" +NV_viewport_array2 :: 1 +NV_VIEWPORT_ARRAY_2_SPEC_VERSION :: 1 +NV_VIEWPORT_ARRAY_2_EXTENSION_NAME :: "VK_NV_viewport_array2" +NV_VIEWPORT_ARRAY2_SPEC_VERSION :: NV_VIEWPORT_ARRAY_2_SPEC_VERSION +NV_VIEWPORT_ARRAY2_EXTENSION_NAME :: NV_VIEWPORT_ARRAY_2_EXTENSION_NAME +NVX_multiview_per_view_attributes :: 1 +NVX_MULTIVIEW_PER_VIEW_ATTRIBUTES_SPEC_VERSION :: 1 +NVX_MULTIVIEW_PER_VIEW_ATTRIBUTES_EXTENSION_NAME :: "VK_NVX_multiview_per_view_attributes" +NV_viewport_swizzle :: 1 +NV_VIEWPORT_SWIZZLE_SPEC_VERSION :: 1 +NV_VIEWPORT_SWIZZLE_EXTENSION_NAME :: "VK_NV_viewport_swizzle" +EXT_discard_rectangles :: 1 +EXT_DISCARD_RECTANGLES_SPEC_VERSION :: 2 +EXT_DISCARD_RECTANGLES_EXTENSION_NAME :: "VK_EXT_discard_rectangles" +EXT_conservative_rasterization :: 1 +EXT_CONSERVATIVE_RASTERIZATION_SPEC_VERSION :: 1 +EXT_CONSERVATIVE_RASTERIZATION_EXTENSION_NAME :: "VK_EXT_conservative_rasterization" +EXT_depth_clip_enable :: 1 +EXT_DEPTH_CLIP_ENABLE_SPEC_VERSION :: 1 +EXT_DEPTH_CLIP_ENABLE_EXTENSION_NAME :: "VK_EXT_depth_clip_enable" +EXT_swapchain_colorspace :: 1 +EXT_SWAPCHAIN_COLOR_SPACE_SPEC_VERSION :: 4 +EXT_SWAPCHAIN_COLOR_SPACE_EXTENSION_NAME :: "VK_EXT_swapchain_colorspace" +EXT_hdr_metadata :: 1 +EXT_HDR_METADATA_SPEC_VERSION :: 2 +EXT_HDR_METADATA_EXTENSION_NAME :: "VK_EXT_hdr_metadata" +EXT_external_memory_dma_buf :: 1 +EXT_EXTERNAL_MEMORY_DMA_BUF_SPEC_VERSION :: 1 +EXT_EXTERNAL_MEMORY_DMA_BUF_EXTENSION_NAME :: "VK_EXT_external_memory_dma_buf" +EXT_queue_family_foreign :: 1 +EXT_QUEUE_FAMILY_FOREIGN_SPEC_VERSION :: 1 +EXT_QUEUE_FAMILY_FOREIGN_EXTENSION_NAME :: "VK_EXT_queue_family_foreign" +EXT_debug_utils :: 1 +EXT_DEBUG_UTILS_SPEC_VERSION :: 2 +EXT_DEBUG_UTILS_EXTENSION_NAME :: "VK_EXT_debug_utils" +EXT_sampler_filter_minmax :: 1 +EXT_SAMPLER_FILTER_MINMAX_SPEC_VERSION :: 2 +EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME :: "VK_EXT_sampler_filter_minmax" +AMD_gpu_shader_int16 :: 1 +AMD_GPU_SHADER_INT16_SPEC_VERSION :: 2 +AMD_GPU_SHADER_INT16_EXTENSION_NAME :: "VK_AMD_gpu_shader_int16" +AMD_mixed_attachment_samples :: 1 +AMD_MIXED_ATTACHMENT_SAMPLES_SPEC_VERSION :: 1 +AMD_MIXED_ATTACHMENT_SAMPLES_EXTENSION_NAME :: "VK_AMD_mixed_attachment_samples" +AMD_shader_fragment_mask :: 1 +AMD_SHADER_FRAGMENT_MASK_SPEC_VERSION :: 1 +AMD_SHADER_FRAGMENT_MASK_EXTENSION_NAME :: "VK_AMD_shader_fragment_mask" +EXT_inline_uniform_block :: 1 +EXT_INLINE_UNIFORM_BLOCK_SPEC_VERSION :: 1 +EXT_INLINE_UNIFORM_BLOCK_EXTENSION_NAME :: "VK_EXT_inline_uniform_block" +EXT_shader_stencil_export :: 1 +EXT_SHADER_STENCIL_EXPORT_SPEC_VERSION :: 1 +EXT_SHADER_STENCIL_EXPORT_EXTENSION_NAME :: "VK_EXT_shader_stencil_export" +EXT_sample_locations :: 1 +EXT_SAMPLE_LOCATIONS_SPEC_VERSION :: 1 +EXT_SAMPLE_LOCATIONS_EXTENSION_NAME :: "VK_EXT_sample_locations" +EXT_blend_operation_advanced :: 1 +EXT_BLEND_OPERATION_ADVANCED_SPEC_VERSION :: 2 +EXT_BLEND_OPERATION_ADVANCED_EXTENSION_NAME :: "VK_EXT_blend_operation_advanced" +NV_fragment_coverage_to_color :: 1 +NV_FRAGMENT_COVERAGE_TO_COLOR_SPEC_VERSION :: 1 +NV_FRAGMENT_COVERAGE_TO_COLOR_EXTENSION_NAME :: "VK_NV_fragment_coverage_to_color" +NV_framebuffer_mixed_samples :: 1 +NV_FRAMEBUFFER_MIXED_SAMPLES_SPEC_VERSION :: 1 +NV_FRAMEBUFFER_MIXED_SAMPLES_EXTENSION_NAME :: "VK_NV_framebuffer_mixed_samples" +NV_fill_rectangle :: 1 +NV_FILL_RECTANGLE_SPEC_VERSION :: 1 +NV_FILL_RECTANGLE_EXTENSION_NAME :: "VK_NV_fill_rectangle" +NV_shader_sm_builtins :: 1 +NV_SHADER_SM_BUILTINS_SPEC_VERSION :: 1 +NV_SHADER_SM_BUILTINS_EXTENSION_NAME :: "VK_NV_shader_sm_builtins" +EXT_post_depth_coverage :: 1 +EXT_POST_DEPTH_COVERAGE_SPEC_VERSION :: 1 +EXT_POST_DEPTH_COVERAGE_EXTENSION_NAME :: "VK_EXT_post_depth_coverage" +EXT_image_drm_format_modifier :: 1 +EXT_IMAGE_DRM_FORMAT_MODIFIER_SPEC_VERSION :: 2 +EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME :: "VK_EXT_image_drm_format_modifier" +EXT_validation_cache :: 1 +EXT_VALIDATION_CACHE_SPEC_VERSION :: 1 +EXT_VALIDATION_CACHE_EXTENSION_NAME :: "VK_EXT_validation_cache" +EXT_descriptor_indexing :: 1 +EXT_DESCRIPTOR_INDEXING_SPEC_VERSION :: 2 +EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME :: "VK_EXT_descriptor_indexing" +EXT_shader_viewport_index_layer :: 1 +EXT_SHADER_VIEWPORT_INDEX_LAYER_SPEC_VERSION :: 1 +EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME :: "VK_EXT_shader_viewport_index_layer" +NV_shading_rate_image :: 1 +NV_SHADING_RATE_IMAGE_SPEC_VERSION :: 3 +NV_SHADING_RATE_IMAGE_EXTENSION_NAME :: "VK_NV_shading_rate_image" +NV_ray_tracing :: 1 +NV_RAY_TRACING_SPEC_VERSION :: 3 +NV_RAY_TRACING_EXTENSION_NAME :: "VK_NV_ray_tracing" +SHADER_UNUSED_KHR :: 0 +NV_representative_fragment_test :: 1 +NV_REPRESENTATIVE_FRAGMENT_TEST_SPEC_VERSION :: 2 +NV_REPRESENTATIVE_FRAGMENT_TEST_EXTENSION_NAME :: "VK_NV_representative_fragment_test" +EXT_filter_cubic :: 1 +EXT_FILTER_CUBIC_SPEC_VERSION :: 3 +EXT_FILTER_CUBIC_EXTENSION_NAME :: "VK_EXT_filter_cubic" +EXT_global_priority :: 1 +EXT_GLOBAL_PRIORITY_SPEC_VERSION :: 2 +EXT_GLOBAL_PRIORITY_EXTENSION_NAME :: "VK_EXT_global_priority" +EXT_external_memory_host :: 1 +EXT_EXTERNAL_MEMORY_HOST_SPEC_VERSION :: 1 +EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME :: "VK_EXT_external_memory_host" +AMD_buffer_marker :: 1 +AMD_BUFFER_MARKER_SPEC_VERSION :: 1 +AMD_BUFFER_MARKER_EXTENSION_NAME :: "VK_AMD_buffer_marker" +AMD_pipeline_compiler_control :: 1 +AMD_PIPELINE_COMPILER_CONTROL_SPEC_VERSION :: 1 +AMD_PIPELINE_COMPILER_CONTROL_EXTENSION_NAME :: "VK_AMD_pipeline_compiler_control" +EXT_calibrated_timestamps :: 1 +EXT_CALIBRATED_TIMESTAMPS_SPEC_VERSION :: 2 +EXT_CALIBRATED_TIMESTAMPS_EXTENSION_NAME :: "VK_EXT_calibrated_timestamps" +AMD_shader_core_properties :: 1 +AMD_SHADER_CORE_PROPERTIES_SPEC_VERSION :: 2 +AMD_SHADER_CORE_PROPERTIES_EXTENSION_NAME :: "VK_AMD_shader_core_properties" +AMD_memory_overallocation_behavior :: 1 +AMD_MEMORY_OVERALLOCATION_BEHAVIOR_SPEC_VERSION :: 1 +AMD_MEMORY_OVERALLOCATION_BEHAVIOR_EXTENSION_NAME :: "VK_AMD_memory_overallocation_behavior" +EXT_vertex_attribute_divisor :: 1 +EXT_VERTEX_ATTRIBUTE_DIVISOR_SPEC_VERSION :: 3 +EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME :: "VK_EXT_vertex_attribute_divisor" +EXT_pipeline_creation_feedback :: 1 +EXT_PIPELINE_CREATION_FEEDBACK_SPEC_VERSION :: 1 +EXT_PIPELINE_CREATION_FEEDBACK_EXTENSION_NAME :: "VK_EXT_pipeline_creation_feedback" +NV_shader_subgroup_partitioned :: 1 +NV_SHADER_SUBGROUP_PARTITIONED_SPEC_VERSION :: 1 +NV_SHADER_SUBGROUP_PARTITIONED_EXTENSION_NAME :: "VK_NV_shader_subgroup_partitioned" +NV_compute_shader_derivatives :: 1 +NV_COMPUTE_SHADER_DERIVATIVES_SPEC_VERSION :: 1 +NV_COMPUTE_SHADER_DERIVATIVES_EXTENSION_NAME :: "VK_NV_compute_shader_derivatives" +NV_mesh_shader :: 1 +NV_MESH_SHADER_SPEC_VERSION :: 1 +NV_MESH_SHADER_EXTENSION_NAME :: "VK_NV_mesh_shader" +NV_fragment_shader_barycentric :: 1 +NV_FRAGMENT_SHADER_BARYCENTRIC_SPEC_VERSION :: 1 +NV_FRAGMENT_SHADER_BARYCENTRIC_EXTENSION_NAME :: "VK_NV_fragment_shader_barycentric" +NV_shader_image_footprint :: 1 +NV_SHADER_IMAGE_FOOTPRINT_SPEC_VERSION :: 2 +NV_SHADER_IMAGE_FOOTPRINT_EXTENSION_NAME :: "VK_NV_shader_image_footprint" +NV_scissor_exclusive :: 1 +NV_SCISSOR_EXCLUSIVE_SPEC_VERSION :: 2 +NV_SCISSOR_EXCLUSIVE_EXTENSION_NAME :: "VK_NV_scissor_exclusive" +NV_device_diagnostic_checkpoints :: 1 +NV_DEVICE_DIAGNOSTIC_CHECKPOINTS_SPEC_VERSION :: 2 +NV_DEVICE_DIAGNOSTIC_CHECKPOINTS_EXTENSION_NAME :: "VK_NV_device_diagnostic_checkpoints" +EXT_pci_bus_info :: 1 +EXT_PCI_BUS_INFO_SPEC_VERSION :: 2 +EXT_PCI_BUS_INFO_EXTENSION_NAME :: "VK_EXT_pci_bus_info" +AMD_display_native_hdr :: 1 +AMD_DISPLAY_NATIVE_HDR_SPEC_VERSION :: 1 +AMD_DISPLAY_NATIVE_HDR_EXTENSION_NAME :: "VK_AMD_display_native_hdr" +EXT_fragment_density_map :: 1 +EXT_FRAGMENT_DENSITY_MAP_SPEC_VERSION :: 2 +EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME :: "VK_EXT_fragment_density_map" +EXT_scalar_block_layout :: 1 +EXT_SCALAR_BLOCK_LAYOUT_SPEC_VERSION :: 1 +EXT_SCALAR_BLOCK_LAYOUT_EXTENSION_NAME :: "VK_EXT_scalar_block_layout" +GOOGLE_hlsl_functionality1 :: 1 +GOOGLE_HLSL_FUNCTIONALITY_1_SPEC_VERSION :: 1 +GOOGLE_HLSL_FUNCTIONALITY_1_EXTENSION_NAME :: "VK_GOOGLE_hlsl_functionality1" +GOOGLE_HLSL_FUNCTIONALITY1_SPEC_VERSION :: GOOGLE_HLSL_FUNCTIONALITY_1_SPEC_VERSION +GOOGLE_HLSL_FUNCTIONALITY1_EXTENSION_NAME :: GOOGLE_HLSL_FUNCTIONALITY_1_EXTENSION_NAME +GOOGLE_decorate_string :: 1 +GOOGLE_DECORATE_STRING_SPEC_VERSION :: 1 +GOOGLE_DECORATE_STRING_EXTENSION_NAME :: "VK_GOOGLE_decorate_string" +EXT_subgroup_size_control :: 1 +EXT_SUBGROUP_SIZE_CONTROL_SPEC_VERSION :: 2 +EXT_SUBGROUP_SIZE_CONTROL_EXTENSION_NAME :: "VK_EXT_subgroup_size_control" +AMD_shader_core_properties2 :: 1 +AMD_SHADER_CORE_PROPERTIES_2_SPEC_VERSION :: 1 +AMD_SHADER_CORE_PROPERTIES_2_EXTENSION_NAME :: "VK_AMD_shader_core_properties2" +AMD_device_coherent_memory :: 1 +AMD_DEVICE_COHERENT_MEMORY_SPEC_VERSION :: 1 +AMD_DEVICE_COHERENT_MEMORY_EXTENSION_NAME :: "VK_AMD_device_coherent_memory" +EXT_shader_image_atomic_int64 :: 1 +EXT_SHADER_IMAGE_ATOMIC_INT64_SPEC_VERSION :: 1 +EXT_SHADER_IMAGE_ATOMIC_INT64_EXTENSION_NAME :: "VK_EXT_shader_image_atomic_int64" +EXT_memory_budget :: 1 +EXT_MEMORY_BUDGET_SPEC_VERSION :: 1 +EXT_MEMORY_BUDGET_EXTENSION_NAME :: "VK_EXT_memory_budget" +EXT_memory_priority :: 1 +EXT_MEMORY_PRIORITY_SPEC_VERSION :: 1 +EXT_MEMORY_PRIORITY_EXTENSION_NAME :: "VK_EXT_memory_priority" +NV_dedicated_allocation_image_aliasing :: 1 +NV_DEDICATED_ALLOCATION_IMAGE_ALIASING_SPEC_VERSION :: 1 +NV_DEDICATED_ALLOCATION_IMAGE_ALIASING_EXTENSION_NAME :: "VK_NV_dedicated_allocation_image_aliasing" +EXT_buffer_device_address :: 1 +EXT_BUFFER_DEVICE_ADDRESS_SPEC_VERSION :: 2 +EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME :: "VK_EXT_buffer_device_address" +EXT_tooling_info :: 1 +EXT_TOOLING_INFO_SPEC_VERSION :: 1 +EXT_TOOLING_INFO_EXTENSION_NAME :: "VK_EXT_tooling_info" +EXT_separate_stencil_usage :: 1 +EXT_SEPARATE_STENCIL_USAGE_SPEC_VERSION :: 1 +EXT_SEPARATE_STENCIL_USAGE_EXTENSION_NAME :: "VK_EXT_separate_stencil_usage" +EXT_validation_features :: 1 +EXT_VALIDATION_FEATURES_SPEC_VERSION :: 5 +EXT_VALIDATION_FEATURES_EXTENSION_NAME :: "VK_EXT_validation_features" +NV_cooperative_matrix :: 1 +NV_COOPERATIVE_MATRIX_SPEC_VERSION :: 1 +NV_COOPERATIVE_MATRIX_EXTENSION_NAME :: "VK_NV_cooperative_matrix" +NV_coverage_reduction_mode :: 1 +NV_COVERAGE_REDUCTION_MODE_SPEC_VERSION :: 1 +NV_COVERAGE_REDUCTION_MODE_EXTENSION_NAME :: "VK_NV_coverage_reduction_mode" +EXT_fragment_shader_interlock :: 1 +EXT_FRAGMENT_SHADER_INTERLOCK_SPEC_VERSION :: 1 +EXT_FRAGMENT_SHADER_INTERLOCK_EXTENSION_NAME :: "VK_EXT_fragment_shader_interlock" +EXT_ycbcr_image_arrays :: 1 +EXT_YCBCR_IMAGE_ARRAYS_SPEC_VERSION :: 1 +EXT_YCBCR_IMAGE_ARRAYS_EXTENSION_NAME :: "VK_EXT_ycbcr_image_arrays" +EXT_provoking_vertex :: 1 +EXT_PROVOKING_VERTEX_SPEC_VERSION :: 1 +EXT_PROVOKING_VERTEX_EXTENSION_NAME :: "VK_EXT_provoking_vertex" +EXT_headless_surface :: 1 +EXT_HEADLESS_SURFACE_SPEC_VERSION :: 1 +EXT_HEADLESS_SURFACE_EXTENSION_NAME :: "VK_EXT_headless_surface" +EXT_line_rasterization :: 1 +EXT_LINE_RASTERIZATION_SPEC_VERSION :: 1 +EXT_LINE_RASTERIZATION_EXTENSION_NAME :: "VK_EXT_line_rasterization" +EXT_shader_atomic_float :: 1 +EXT_SHADER_ATOMIC_FLOAT_SPEC_VERSION :: 1 +EXT_SHADER_ATOMIC_FLOAT_EXTENSION_NAME :: "VK_EXT_shader_atomic_float" +EXT_host_query_reset :: 1 +EXT_HOST_QUERY_RESET_SPEC_VERSION :: 1 +EXT_HOST_QUERY_RESET_EXTENSION_NAME :: "VK_EXT_host_query_reset" +EXT_index_type_uint8 :: 1 +EXT_INDEX_TYPE_UINT8_SPEC_VERSION :: 1 +EXT_INDEX_TYPE_UINT8_EXTENSION_NAME :: "VK_EXT_index_type_uint8" +EXT_extended_dynamic_state :: 1 +EXT_EXTENDED_DYNAMIC_STATE_SPEC_VERSION :: 1 +EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME :: "VK_EXT_extended_dynamic_state" +EXT_shader_atomic_float2 :: 1 +EXT_SHADER_ATOMIC_FLOAT_2_SPEC_VERSION :: 1 +EXT_SHADER_ATOMIC_FLOAT_2_EXTENSION_NAME :: "VK_EXT_shader_atomic_float2" +EXT_surface_maintenance1 :: 1 +EXT_SURFACE_MAINTENANCE_1_SPEC_VERSION :: 1 +EXT_SURFACE_MAINTENANCE_1_EXTENSION_NAME :: "VK_EXT_surface_maintenance1" +EXT_swapchain_maintenance1 :: 1 +EXT_SWAPCHAIN_MAINTENANCE_1_SPEC_VERSION :: 1 +EXT_SWAPCHAIN_MAINTENANCE_1_EXTENSION_NAME :: "VK_EXT_swapchain_maintenance1" +EXT_shader_demote_to_helper_invocation :: 1 +EXT_SHADER_DEMOTE_TO_HELPER_INVOCATION_SPEC_VERSION :: 1 +EXT_SHADER_DEMOTE_TO_HELPER_INVOCATION_EXTENSION_NAME :: "VK_EXT_shader_demote_to_helper_invocation" +NV_device_generated_commands :: 1 +NV_DEVICE_GENERATED_COMMANDS_SPEC_VERSION :: 3 +NV_DEVICE_GENERATED_COMMANDS_EXTENSION_NAME :: "VK_NV_device_generated_commands" +NV_inherited_viewport_scissor :: 1 +NV_INHERITED_VIEWPORT_SCISSOR_SPEC_VERSION :: 1 +NV_INHERITED_VIEWPORT_SCISSOR_EXTENSION_NAME :: "VK_NV_inherited_viewport_scissor" +EXT_texel_buffer_alignment :: 1 +EXT_TEXEL_BUFFER_ALIGNMENT_SPEC_VERSION :: 1 +EXT_TEXEL_BUFFER_ALIGNMENT_EXTENSION_NAME :: "VK_EXT_texel_buffer_alignment" +EXT_device_memory_report :: 1 +EXT_DEVICE_MEMORY_REPORT_SPEC_VERSION :: 2 +EXT_DEVICE_MEMORY_REPORT_EXTENSION_NAME :: "VK_EXT_device_memory_report" +EXT_acquire_drm_display :: 1 +EXT_ACQUIRE_DRM_DISPLAY_SPEC_VERSION :: 1 +EXT_ACQUIRE_DRM_DISPLAY_EXTENSION_NAME :: "VK_EXT_acquire_drm_display" +EXT_robustness2 :: 1 +EXT_ROBUSTNESS_2_SPEC_VERSION :: 1 +EXT_ROBUSTNESS_2_EXTENSION_NAME :: "VK_EXT_robustness2" +EXT_custom_border_color :: 1 +EXT_CUSTOM_BORDER_COLOR_SPEC_VERSION :: 12 +EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME :: "VK_EXT_custom_border_color" +GOOGLE_user_type :: 1 +GOOGLE_USER_TYPE_SPEC_VERSION :: 1 +GOOGLE_USER_TYPE_EXTENSION_NAME :: "VK_GOOGLE_user_type" +NV_present_barrier :: 1 +NV_PRESENT_BARRIER_SPEC_VERSION :: 1 +NV_PRESENT_BARRIER_EXTENSION_NAME :: "VK_NV_present_barrier" +EXT_private_data :: 1 +EXT_PRIVATE_DATA_SPEC_VERSION :: 1 +EXT_PRIVATE_DATA_EXTENSION_NAME :: "VK_EXT_private_data" +EXT_pipeline_creation_cache_control :: 1 +EXT_PIPELINE_CREATION_CACHE_CONTROL_SPEC_VERSION :: 3 +EXT_PIPELINE_CREATION_CACHE_CONTROL_EXTENSION_NAME :: "VK_EXT_pipeline_creation_cache_control" +NV_device_diagnostics_config :: 1 +NV_DEVICE_DIAGNOSTICS_CONFIG_SPEC_VERSION :: 2 +NV_DEVICE_DIAGNOSTICS_CONFIG_EXTENSION_NAME :: "VK_NV_device_diagnostics_config" +NV_low_latency :: 1 +NV_LOW_LATENCY_SPEC_VERSION :: 1 +NV_LOW_LATENCY_EXTENSION_NAME :: "VK_NV_low_latency" +EXT_descriptor_buffer :: 1 +EXT_DESCRIPTOR_BUFFER_SPEC_VERSION :: 1 +EXT_DESCRIPTOR_BUFFER_EXTENSION_NAME :: "VK_EXT_descriptor_buffer" +EXT_graphics_pipeline_library :: 1 +EXT_GRAPHICS_PIPELINE_LIBRARY_SPEC_VERSION :: 1 +EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME :: "VK_EXT_graphics_pipeline_library" +AMD_shader_early_and_late_fragment_tests :: 1 +AMD_SHADER_EARLY_AND_LATE_FRAGMENT_TESTS_SPEC_VERSION :: 1 +AMD_SHADER_EARLY_AND_LATE_FRAGMENT_TESTS_EXTENSION_NAME :: "VK_AMD_shader_early_and_late_fragment_tests" +NV_fragment_shading_rate_enums :: 1 +NV_FRAGMENT_SHADING_RATE_ENUMS_SPEC_VERSION :: 1 +NV_FRAGMENT_SHADING_RATE_ENUMS_EXTENSION_NAME :: "VK_NV_fragment_shading_rate_enums" +NV_ray_tracing_motion_blur :: 1 +NV_RAY_TRACING_MOTION_BLUR_SPEC_VERSION :: 1 +NV_RAY_TRACING_MOTION_BLUR_EXTENSION_NAME :: "VK_NV_ray_tracing_motion_blur" +EXT_ycbcr_2plane_444_formats :: 1 +EXT_YCBCR_2PLANE_444_FORMATS_SPEC_VERSION :: 1 +EXT_YCBCR_2PLANE_444_FORMATS_EXTENSION_NAME :: "VK_EXT_ycbcr_2plane_444_formats" +EXT_fragment_density_map2 :: 1 +EXT_FRAGMENT_DENSITY_MAP_2_SPEC_VERSION :: 1 +EXT_FRAGMENT_DENSITY_MAP_2_EXTENSION_NAME :: "VK_EXT_fragment_density_map2" +EXT_image_robustness :: 1 +EXT_IMAGE_ROBUSTNESS_SPEC_VERSION :: 1 +EXT_IMAGE_ROBUSTNESS_EXTENSION_NAME :: "VK_EXT_image_robustness" +EXT_image_compression_control :: 1 +EXT_IMAGE_COMPRESSION_CONTROL_SPEC_VERSION :: 1 +EXT_IMAGE_COMPRESSION_CONTROL_EXTENSION_NAME :: "VK_EXT_image_compression_control" +EXT_attachment_feedback_loop_layout :: 1 +EXT_ATTACHMENT_FEEDBACK_LOOP_LAYOUT_SPEC_VERSION :: 2 +EXT_ATTACHMENT_FEEDBACK_LOOP_LAYOUT_EXTENSION_NAME :: "VK_EXT_attachment_feedback_loop_layout" +EXT_4444_formats :: 1 +EXT_4444_FORMATS_SPEC_VERSION :: 1 +EXT_4444_FORMATS_EXTENSION_NAME :: "VK_EXT_4444_formats" +EXT_device_fault :: 1 +EXT_DEVICE_FAULT_SPEC_VERSION :: 2 +EXT_DEVICE_FAULT_EXTENSION_NAME :: "VK_EXT_device_fault" +EXT_rgba10x6_formats :: 1 +EXT_RGBA10X6_FORMATS_SPEC_VERSION :: 1 +EXT_RGBA10X6_FORMATS_EXTENSION_NAME :: "VK_EXT_rgba10x6_formats" +EXT_vertex_input_dynamic_state :: 1 +EXT_VERTEX_INPUT_DYNAMIC_STATE_SPEC_VERSION :: 2 +EXT_VERTEX_INPUT_DYNAMIC_STATE_EXTENSION_NAME :: "VK_EXT_vertex_input_dynamic_state" +EXT_physical_device_drm :: 1 +EXT_PHYSICAL_DEVICE_DRM_SPEC_VERSION :: 1 +EXT_PHYSICAL_DEVICE_DRM_EXTENSION_NAME :: "VK_EXT_physical_device_drm" +EXT_device_address_binding_report :: 1 +EXT_DEVICE_ADDRESS_BINDING_REPORT_SPEC_VERSION :: 1 +EXT_DEVICE_ADDRESS_BINDING_REPORT_EXTENSION_NAME :: "VK_EXT_device_address_binding_report" +EXT_depth_clip_control :: 1 +EXT_DEPTH_CLIP_CONTROL_SPEC_VERSION :: 1 +EXT_DEPTH_CLIP_CONTROL_EXTENSION_NAME :: "VK_EXT_depth_clip_control" +EXT_primitive_topology_list_restart :: 1 +EXT_PRIMITIVE_TOPOLOGY_LIST_RESTART_SPEC_VERSION :: 1 +EXT_PRIMITIVE_TOPOLOGY_LIST_RESTART_EXTENSION_NAME :: "VK_EXT_primitive_topology_list_restart" +NV_external_memory_rdma :: 1 +NV_EXTERNAL_MEMORY_RDMA_SPEC_VERSION :: 1 +NV_EXTERNAL_MEMORY_RDMA_EXTENSION_NAME :: "VK_NV_external_memory_rdma" +EXT_pipeline_properties :: 1 +EXT_PIPELINE_PROPERTIES_SPEC_VERSION :: 1 +EXT_PIPELINE_PROPERTIES_EXTENSION_NAME :: "VK_EXT_pipeline_properties" +EXT_multisampled_render_to_single_sampled :: 1 +EXT_MULTISAMPLED_RENDER_TO_SINGLE_SAMPLED_SPEC_VERSION :: 1 +EXT_MULTISAMPLED_RENDER_TO_SINGLE_SAMPLED_EXTENSION_NAME :: "VK_EXT_multisampled_render_to_single_sampled" +EXT_extended_dynamic_state2 :: 1 +EXT_EXTENDED_DYNAMIC_STATE_2_SPEC_VERSION :: 1 +EXT_EXTENDED_DYNAMIC_STATE_2_EXTENSION_NAME :: "VK_EXT_extended_dynamic_state2" +EXT_color_write_enable :: 1 +EXT_COLOR_WRITE_ENABLE_SPEC_VERSION :: 1 +EXT_COLOR_WRITE_ENABLE_EXTENSION_NAME :: "VK_EXT_color_write_enable" +EXT_primitives_generated_query :: 1 +EXT_PRIMITIVES_GENERATED_QUERY_SPEC_VERSION :: 1 +EXT_PRIMITIVES_GENERATED_QUERY_EXTENSION_NAME :: "VK_EXT_primitives_generated_query" +EXT_global_priority_query :: 1 +EXT_GLOBAL_PRIORITY_QUERY_SPEC_VERSION :: 1 +EXT_GLOBAL_PRIORITY_QUERY_EXTENSION_NAME :: "VK_EXT_global_priority_query" +EXT_image_view_min_lod :: 1 +EXT_IMAGE_VIEW_MIN_LOD_SPEC_VERSION :: 1 +EXT_IMAGE_VIEW_MIN_LOD_EXTENSION_NAME :: "VK_EXT_image_view_min_lod" +EXT_multi_draw :: 1 +EXT_MULTI_DRAW_SPEC_VERSION :: 1 +EXT_MULTI_DRAW_EXTENSION_NAME :: "VK_EXT_multi_draw" +EXT_image_2d_view_of_3d :: 1 +EXT_IMAGE_2D_VIEW_OF_3D_SPEC_VERSION :: 1 +EXT_IMAGE_2D_VIEW_OF_3D_EXTENSION_NAME :: "VK_EXT_image_2d_view_of_3d" +EXT_shader_tile_image :: 1 +EXT_SHADER_TILE_IMAGE_SPEC_VERSION :: 1 +EXT_SHADER_TILE_IMAGE_EXTENSION_NAME :: "VK_EXT_shader_tile_image" +EXT_opacity_micromap :: 1 +EXT_OPACITY_MICROMAP_SPEC_VERSION :: 2 +EXT_OPACITY_MICROMAP_EXTENSION_NAME :: "VK_EXT_opacity_micromap" +EXT_load_store_op_none :: 1 +EXT_LOAD_STORE_OP_NONE_SPEC_VERSION :: 1 +EXT_LOAD_STORE_OP_NONE_EXTENSION_NAME :: "VK_EXT_load_store_op_none" +EXT_border_color_swizzle :: 1 +EXT_BORDER_COLOR_SWIZZLE_SPEC_VERSION :: 1 +EXT_BORDER_COLOR_SWIZZLE_EXTENSION_NAME :: "VK_EXT_border_color_swizzle" +EXT_pageable_device_local_memory :: 1 +EXT_PAGEABLE_DEVICE_LOCAL_MEMORY_SPEC_VERSION :: 1 +EXT_PAGEABLE_DEVICE_LOCAL_MEMORY_EXTENSION_NAME :: "VK_EXT_pageable_device_local_memory" +EXT_image_sliced_view_of_3d :: 1 +EXT_IMAGE_SLICED_VIEW_OF_3D_SPEC_VERSION :: 1 +EXT_IMAGE_SLICED_VIEW_OF_3D_EXTENSION_NAME :: "VK_EXT_image_sliced_view_of_3d" +EXT_depth_clamp_zero_one :: 1 +EXT_DEPTH_CLAMP_ZERO_ONE_SPEC_VERSION :: 1 +EXT_DEPTH_CLAMP_ZERO_ONE_EXTENSION_NAME :: "VK_EXT_depth_clamp_zero_one" +EXT_non_seamless_cube_map :: 1 +EXT_NON_SEAMLESS_CUBE_MAP_SPEC_VERSION :: 1 +EXT_NON_SEAMLESS_CUBE_MAP_EXTENSION_NAME :: "VK_EXT_non_seamless_cube_map" +NV_copy_memory_indirect :: 1 +NV_COPY_MEMORY_INDIRECT_SPEC_VERSION :: 1 +NV_COPY_MEMORY_INDIRECT_EXTENSION_NAME :: "VK_NV_copy_memory_indirect" +NV_memory_decompression :: 1 +NV_MEMORY_DECOMPRESSION_SPEC_VERSION :: 1 +NV_MEMORY_DECOMPRESSION_EXTENSION_NAME :: "VK_NV_memory_decompression" +NV_linear_color_attachment :: 1 +NV_LINEAR_COLOR_ATTACHMENT_SPEC_VERSION :: 1 +NV_LINEAR_COLOR_ATTACHMENT_EXTENSION_NAME :: "VK_NV_linear_color_attachment" +GOOGLE_surfaceless_query :: 1 +GOOGLE_SURFACELESS_QUERY_SPEC_VERSION :: 2 +GOOGLE_SURFACELESS_QUERY_EXTENSION_NAME :: "VK_GOOGLE_surfaceless_query" +EXT_image_compression_control_swapchain :: 1 +EXT_IMAGE_COMPRESSION_CONTROL_SWAPCHAIN_SPEC_VERSION :: 1 +EXT_IMAGE_COMPRESSION_CONTROL_SWAPCHAIN_EXTENSION_NAME :: "VK_EXT_image_compression_control_swapchain" +EXT_extended_dynamic_state3 :: 1 +EXT_EXTENDED_DYNAMIC_STATE_3_SPEC_VERSION :: 2 +EXT_EXTENDED_DYNAMIC_STATE_3_EXTENSION_NAME :: "VK_EXT_extended_dynamic_state3" +EXT_subpass_merge_feedback :: 1 +EXT_SUBPASS_MERGE_FEEDBACK_SPEC_VERSION :: 2 +EXT_SUBPASS_MERGE_FEEDBACK_EXTENSION_NAME :: "VK_EXT_subpass_merge_feedback" +EXT_shader_module_identifier :: 1 +EXT_SHADER_MODULE_IDENTIFIER_SPEC_VERSION :: 1 +EXT_SHADER_MODULE_IDENTIFIER_EXTENSION_NAME :: "VK_EXT_shader_module_identifier" +EXT_rasterization_order_attachment_access :: 1 +EXT_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_SPEC_VERSION :: 1 +EXT_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_EXTENSION_NAME :: "VK_EXT_rasterization_order_attachment_access" +NV_optical_flow :: 1 +NV_OPTICAL_FLOW_SPEC_VERSION :: 1 +NV_OPTICAL_FLOW_EXTENSION_NAME :: "VK_NV_optical_flow" +EXT_legacy_dithering :: 1 +EXT_LEGACY_DITHERING_SPEC_VERSION :: 1 +EXT_LEGACY_DITHERING_EXTENSION_NAME :: "VK_EXT_legacy_dithering" +EXT_pipeline_protected_access :: 1 +EXT_PIPELINE_PROTECTED_ACCESS_SPEC_VERSION :: 1 +EXT_PIPELINE_PROTECTED_ACCESS_EXTENSION_NAME :: "VK_EXT_pipeline_protected_access" +EXT_shader_object :: 1 +EXT_SHADER_OBJECT_SPEC_VERSION :: 1 +EXT_SHADER_OBJECT_EXTENSION_NAME :: "VK_EXT_shader_object" +NV_ray_tracing_invocation_reorder :: 1 +NV_RAY_TRACING_INVOCATION_REORDER_SPEC_VERSION :: 1 +NV_RAY_TRACING_INVOCATION_REORDER_EXTENSION_NAME :: "VK_NV_ray_tracing_invocation_reorder" +EXT_mutable_descriptor_type :: 1 +EXT_MUTABLE_DESCRIPTOR_TYPE_SPEC_VERSION :: 1 +EXT_MUTABLE_DESCRIPTOR_TYPE_EXTENSION_NAME :: "VK_EXT_mutable_descriptor_type" +EXT_pipeline_library_group_handles :: 1 +EXT_PIPELINE_LIBRARY_GROUP_HANDLES_SPEC_VERSION :: 1 +EXT_PIPELINE_LIBRARY_GROUP_HANDLES_EXTENSION_NAME :: "VK_EXT_pipeline_library_group_handles" +EXT_attachment_feedback_loop_dynamic_state :: 1 +EXT_ATTACHMENT_FEEDBACK_LOOP_DYNAMIC_STATE_SPEC_VERSION :: 1 +EXT_ATTACHMENT_FEEDBACK_LOOP_DYNAMIC_STATE_EXTENSION_NAME :: "VK_EXT_attachment_feedback_loop_dynamic_state" +KHR_acceleration_structure :: 1 +KHR_ACCELERATION_STRUCTURE_SPEC_VERSION :: 13 +KHR_ACCELERATION_STRUCTURE_EXTENSION_NAME :: "VK_KHR_acceleration_structure" +KHR_ray_tracing_pipeline :: 1 +KHR_RAY_TRACING_PIPELINE_SPEC_VERSION :: 1 +KHR_RAY_TRACING_PIPELINE_EXTENSION_NAME :: "VK_KHR_ray_tracing_pipeline" +KHR_ray_query :: 1 +KHR_RAY_QUERY_SPEC_VERSION :: 1 +KHR_RAY_QUERY_EXTENSION_NAME :: "VK_KHR_ray_query" +EXT_mesh_shader :: 1 +EXT_MESH_SHADER_SPEC_VERSION :: 1 +EXT_MESH_SHADER_EXTENSION_NAME :: "VK_EXT_mesh_shader" +KHR_win32_surface :: 1 +KHR_WIN32_SURFACE_SPEC_VERSION :: 6 +KHR_WIN32_SURFACE_EXTENSION_NAME :: "VK_KHR_win32_surface" +KHR_external_memory_win32 :: 1 +KHR_EXTERNAL_MEMORY_WIN32_SPEC_VERSION :: 1 +KHR_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME :: "VK_KHR_external_memory_win32" +KHR_win32_keyed_mutex :: 1 +KHR_WIN32_KEYED_MUTEX_SPEC_VERSION :: 1 +KHR_WIN32_KEYED_MUTEX_EXTENSION_NAME :: "VK_KHR_win32_keyed_mutex" +KHR_external_semaphore_win32 :: 1 +KHR_EXTERNAL_SEMAPHORE_WIN32_SPEC_VERSION :: 1 +KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME :: "VK_KHR_external_semaphore_win32" +KHR_external_fence_win32 :: 1 +KHR_EXTERNAL_FENCE_WIN32_SPEC_VERSION :: 1 +KHR_EXTERNAL_FENCE_WIN32_EXTENSION_NAME :: "VK_KHR_external_fence_win32" +NV_external_memory_win32 :: 1 +NV_EXTERNAL_MEMORY_WIN32_SPEC_VERSION :: 1 +NV_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME :: "VK_NV_external_memory_win32" +NV_win32_keyed_mutex :: 1 +NV_WIN32_KEYED_MUTEX_SPEC_VERSION :: 2 +NV_WIN32_KEYED_MUTEX_EXTENSION_NAME :: "VK_NV_win32_keyed_mutex" +EXT_full_screen_exclusive :: 1 +EXT_FULL_SCREEN_EXCLUSIVE_SPEC_VERSION :: 4 +EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME :: "VK_EXT_full_screen_exclusive" +NV_acquire_winrt_display :: 1 +NV_ACQUIRE_WINRT_DISPLAY_SPEC_VERSION :: 1 +NV_ACQUIRE_WINRT_DISPLAY_EXTENSION_NAME :: "VK_NV_acquire_winrt_display" +EXT_metal_surface :: 1 +EXT_METAL_SURFACE_SPEC_VERSION :: 1 +EXT_METAL_SURFACE_EXTENSION_NAME :: "VK_EXT_metal_surface" +EXT_metal_objects :: 1 +EXT_METAL_OBJECTS_SPEC_VERSION :: 1 +EXT_METAL_OBJECTS_EXTENSION_NAME :: "VK_EXT_metal_objects" +KHR_wayland_surface :: 1 +KHR_WAYLAND_SURFACE_SPEC_VERSION :: 6 +KHR_WAYLAND_SURFACE_EXTENSION_NAME :: "VK_KHR_wayland_surface" + +// Handles types +Instance :: distinct Handle +PhysicalDevice :: distinct Handle +Device :: distinct Handle +Queue :: distinct Handle +CommandBuffer :: distinct Handle +Buffer :: distinct NonDispatchableHandle +Image :: distinct NonDispatchableHandle +Semaphore :: distinct NonDispatchableHandle +Fence :: distinct NonDispatchableHandle +DeviceMemory :: distinct NonDispatchableHandle +Event :: distinct NonDispatchableHandle +QueryPool :: distinct NonDispatchableHandle +BufferView :: distinct NonDispatchableHandle +ImageView :: distinct NonDispatchableHandle +ShaderModule :: distinct NonDispatchableHandle +PipelineCache :: distinct NonDispatchableHandle +PipelineLayout :: distinct NonDispatchableHandle +Pipeline :: distinct NonDispatchableHandle +RenderPass :: distinct NonDispatchableHandle +DescriptorSetLayout :: distinct NonDispatchableHandle +Sampler :: distinct NonDispatchableHandle +DescriptorSet :: distinct NonDispatchableHandle +DescriptorPool :: distinct NonDispatchableHandle +Framebuffer :: distinct NonDispatchableHandle +CommandPool :: distinct NonDispatchableHandle +SamplerYcbcrConversion :: distinct NonDispatchableHandle +DescriptorUpdateTemplate :: distinct NonDispatchableHandle +PrivateDataSlot :: distinct NonDispatchableHandle +SurfaceKHR :: distinct NonDispatchableHandle +SwapchainKHR :: distinct NonDispatchableHandle +DisplayKHR :: distinct NonDispatchableHandle +DisplayModeKHR :: distinct NonDispatchableHandle +VideoSessionKHR :: distinct NonDispatchableHandle +VideoSessionParametersKHR :: distinct NonDispatchableHandle +DeferredOperationKHR :: distinct NonDispatchableHandle +DebugReportCallbackEXT :: distinct NonDispatchableHandle +CuModuleNVX :: distinct NonDispatchableHandle +CuFunctionNVX :: distinct NonDispatchableHandle +DebugUtilsMessengerEXT :: distinct NonDispatchableHandle +ValidationCacheEXT :: distinct NonDispatchableHandle +AccelerationStructureNV :: distinct NonDispatchableHandle +PerformanceConfigurationINTEL :: distinct NonDispatchableHandle +IndirectCommandsLayoutNV :: distinct NonDispatchableHandle +AccelerationStructureKHR :: distinct NonDispatchableHandle +MicromapEXT :: distinct NonDispatchableHandle +OpticalFlowSessionNV :: distinct NonDispatchableHandle +ShaderEXT :: distinct NonDispatchableHandle + + diff --git a/vendor/vulkan/enums.odin b/vendor/vulkan/enums.odin index b2eec06ab..8efcf541c 100644 --- a/vendor/vulkan/enums.odin +++ b/vendor/vulkan/enums.odin @@ -1,3179 +1,3829 @@ -// -// Vulkan wrapper generated from "https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/master/include/vulkan/vulkan_core.h" -// -package vulkan - -import "core:c" - -// Enums -AccelerationStructureBuildTypeKHR :: enum c.int { - HOST = 0, - DEVICE = 1, - HOST_OR_DEVICE = 2, -} - -AccelerationStructureCompatibilityKHR :: enum c.int { - COMPATIBLE = 0, - INCOMPATIBLE = 1, -} - -AccelerationStructureCreateFlagsKHR :: distinct bit_set[AccelerationStructureCreateFlagKHR; Flags] -AccelerationStructureCreateFlagKHR :: enum Flags { - DEVICE_ADDRESS_CAPTURE_REPLAY = 0, - MOTION_NV = 2, -} - -AccelerationStructureMemoryRequirementsTypeNV :: enum c.int { - OBJECT = 0, - BUILD_SCRATCH = 1, - UPDATE_SCRATCH = 2, -} - -AccelerationStructureMotionInstanceTypeNV :: enum c.int { - STATIC = 0, - MATRIX_MOTION = 1, - SRT_MOTION = 2, -} - -AccelerationStructureTypeKHR :: enum c.int { - TOP_LEVEL = 0, - BOTTOM_LEVEL = 1, - GENERIC = 2, - TOP_LEVEL_NV = TOP_LEVEL, - BOTTOM_LEVEL_NV = BOTTOM_LEVEL, -} - -AccessFlags :: distinct bit_set[AccessFlag; Flags] -AccessFlag :: enum Flags { - INDIRECT_COMMAND_READ = 0, - INDEX_READ = 1, - VERTEX_ATTRIBUTE_READ = 2, - UNIFORM_READ = 3, - INPUT_ATTACHMENT_READ = 4, - SHADER_READ = 5, - SHADER_WRITE = 6, - COLOR_ATTACHMENT_READ = 7, - COLOR_ATTACHMENT_WRITE = 8, - DEPTH_STENCIL_ATTACHMENT_READ = 9, - DEPTH_STENCIL_ATTACHMENT_WRITE = 10, - TRANSFER_READ = 11, - TRANSFER_WRITE = 12, - HOST_READ = 13, - HOST_WRITE = 14, - MEMORY_READ = 15, - MEMORY_WRITE = 16, - TRANSFORM_FEEDBACK_WRITE_EXT = 25, - TRANSFORM_FEEDBACK_COUNTER_READ_EXT = 26, - TRANSFORM_FEEDBACK_COUNTER_WRITE_EXT = 27, - CONDITIONAL_RENDERING_READ_EXT = 20, - COLOR_ATTACHMENT_READ_NONCOHERENT_EXT = 19, - ACCELERATION_STRUCTURE_READ_KHR = 21, - ACCELERATION_STRUCTURE_WRITE_KHR = 22, - FRAGMENT_DENSITY_MAP_READ_EXT = 24, - FRAGMENT_SHADING_RATE_ATTACHMENT_READ_KHR = 23, - COMMAND_PREPROCESS_READ_NV = 17, - COMMAND_PREPROCESS_WRITE_NV = 18, - SHADING_RATE_IMAGE_READ_NV = FRAGMENT_SHADING_RATE_ATTACHMENT_READ_KHR, - ACCELERATION_STRUCTURE_READ_NV = ACCELERATION_STRUCTURE_READ_KHR, - ACCELERATION_STRUCTURE_WRITE_NV = ACCELERATION_STRUCTURE_WRITE_KHR, -} - -AccessFlags_NONE :: AccessFlags{} - - -AcquireProfilingLockFlagsKHR :: distinct bit_set[AcquireProfilingLockFlagKHR; Flags] -AcquireProfilingLockFlagKHR :: enum Flags { -} - -AttachmentDescriptionFlags :: distinct bit_set[AttachmentDescriptionFlag; Flags] -AttachmentDescriptionFlag :: enum Flags { - MAY_ALIAS = 0, -} - -AttachmentLoadOp :: enum c.int { - LOAD = 0, - CLEAR = 1, - DONT_CARE = 2, - NONE_EXT = 1000400000, -} - -AttachmentStoreOp :: enum c.int { - STORE = 0, - DONT_CARE = 1, - NONE = 1000301000, -} - -BlendFactor :: enum c.int { - ZERO = 0, - ONE = 1, - SRC_COLOR = 2, - ONE_MINUS_SRC_COLOR = 3, - DST_COLOR = 4, - ONE_MINUS_DST_COLOR = 5, - SRC_ALPHA = 6, - ONE_MINUS_SRC_ALPHA = 7, - DST_ALPHA = 8, - ONE_MINUS_DST_ALPHA = 9, - CONSTANT_COLOR = 10, - ONE_MINUS_CONSTANT_COLOR = 11, - CONSTANT_ALPHA = 12, - ONE_MINUS_CONSTANT_ALPHA = 13, - SRC_ALPHA_SATURATE = 14, - SRC1_COLOR = 15, - ONE_MINUS_SRC1_COLOR = 16, - SRC1_ALPHA = 17, - ONE_MINUS_SRC1_ALPHA = 18, -} - -BlendOp :: enum c.int { - ADD = 0, - SUBTRACT = 1, - REVERSE_SUBTRACT = 2, - MIN = 3, - MAX = 4, - ZERO_EXT = 1000148000, - SRC_EXT = 1000148001, - DST_EXT = 1000148002, - SRC_OVER_EXT = 1000148003, - DST_OVER_EXT = 1000148004, - SRC_IN_EXT = 1000148005, - DST_IN_EXT = 1000148006, - SRC_OUT_EXT = 1000148007, - DST_OUT_EXT = 1000148008, - SRC_ATOP_EXT = 1000148009, - DST_ATOP_EXT = 1000148010, - XOR_EXT = 1000148011, - MULTIPLY_EXT = 1000148012, - SCREEN_EXT = 1000148013, - OVERLAY_EXT = 1000148014, - DARKEN_EXT = 1000148015, - LIGHTEN_EXT = 1000148016, - COLORDODGE_EXT = 1000148017, - COLORBURN_EXT = 1000148018, - HARDLIGHT_EXT = 1000148019, - SOFTLIGHT_EXT = 1000148020, - DIFFERENCE_EXT = 1000148021, - EXCLUSION_EXT = 1000148022, - INVERT_EXT = 1000148023, - INVERT_RGB_EXT = 1000148024, - LINEARDODGE_EXT = 1000148025, - LINEARBURN_EXT = 1000148026, - VIVIDLIGHT_EXT = 1000148027, - LINEARLIGHT_EXT = 1000148028, - PINLIGHT_EXT = 1000148029, - HARDMIX_EXT = 1000148030, - HSL_HUE_EXT = 1000148031, - HSL_SATURATION_EXT = 1000148032, - HSL_COLOR_EXT = 1000148033, - HSL_LUMINOSITY_EXT = 1000148034, - PLUS_EXT = 1000148035, - PLUS_CLAMPED_EXT = 1000148036, - PLUS_CLAMPED_ALPHA_EXT = 1000148037, - PLUS_DARKER_EXT = 1000148038, - MINUS_EXT = 1000148039, - MINUS_CLAMPED_EXT = 1000148040, - CONTRAST_EXT = 1000148041, - INVERT_OVG_EXT = 1000148042, - RED_EXT = 1000148043, - GREEN_EXT = 1000148044, - BLUE_EXT = 1000148045, -} - -BlendOverlapEXT :: enum c.int { - UNCORRELATED = 0, - DISJOINT = 1, - CONJOINT = 2, -} - -BorderColor :: enum c.int { - FLOAT_TRANSPARENT_BLACK = 0, - INT_TRANSPARENT_BLACK = 1, - FLOAT_OPAQUE_BLACK = 2, - INT_OPAQUE_BLACK = 3, - FLOAT_OPAQUE_WHITE = 4, - INT_OPAQUE_WHITE = 5, - FLOAT_CUSTOM_EXT = 1000287003, - INT_CUSTOM_EXT = 1000287004, -} - -BufferCreateFlags :: distinct bit_set[BufferCreateFlag; Flags] -BufferCreateFlag :: enum Flags { - SPARSE_BINDING = 0, - SPARSE_RESIDENCY = 1, - SPARSE_ALIASED = 2, - PROTECTED = 3, - DEVICE_ADDRESS_CAPTURE_REPLAY = 4, - DEVICE_ADDRESS_CAPTURE_REPLAY_EXT = DEVICE_ADDRESS_CAPTURE_REPLAY, - DEVICE_ADDRESS_CAPTURE_REPLAY_KHR = DEVICE_ADDRESS_CAPTURE_REPLAY, -} - -BufferUsageFlags :: distinct bit_set[BufferUsageFlag; Flags] -BufferUsageFlag :: enum Flags { - TRANSFER_SRC = 0, - TRANSFER_DST = 1, - UNIFORM_TEXEL_BUFFER = 2, - STORAGE_TEXEL_BUFFER = 3, - UNIFORM_BUFFER = 4, - STORAGE_BUFFER = 5, - INDEX_BUFFER = 6, - VERTEX_BUFFER = 7, - INDIRECT_BUFFER = 8, - SHADER_DEVICE_ADDRESS = 17, - VIDEO_DECODE_SRC_KHR = 13, - VIDEO_DECODE_DST_KHR = 14, - TRANSFORM_FEEDBACK_BUFFER_EXT = 11, - TRANSFORM_FEEDBACK_COUNTER_BUFFER_EXT = 12, - CONDITIONAL_RENDERING_EXT = 9, - ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY_KHR = 19, - ACCELERATION_STRUCTURE_STORAGE_KHR = 20, - SHADER_BINDING_TABLE_KHR = 10, - VIDEO_ENCODE_DST_KHR = 15, - VIDEO_ENCODE_SRC_KHR = 16, - RAY_TRACING_NV = SHADER_BINDING_TABLE_KHR, - SHADER_DEVICE_ADDRESS_EXT = SHADER_DEVICE_ADDRESS, - SHADER_DEVICE_ADDRESS_KHR = SHADER_DEVICE_ADDRESS, -} - -BuildAccelerationStructureFlagsKHR :: distinct bit_set[BuildAccelerationStructureFlagKHR; Flags] -BuildAccelerationStructureFlagKHR :: enum Flags { - ALLOW_UPDATE = 0, - ALLOW_COMPACTION = 1, - PREFER_FAST_TRACE = 2, - PREFER_FAST_BUILD = 3, - LOW_MEMORY = 4, - MOTION_NV = 5, - ALLOW_UPDATE_NV = ALLOW_UPDATE, - ALLOW_COMPACTION_NV = ALLOW_COMPACTION, - PREFER_FAST_TRACE_NV = PREFER_FAST_TRACE, - PREFER_FAST_BUILD_NV = PREFER_FAST_BUILD, - LOW_MEMORY_NV = LOW_MEMORY, -} - -BuildAccelerationStructureModeKHR :: enum c.int { - BUILD = 0, - UPDATE = 1, -} - -ChromaLocation :: enum c.int { - COSITED_EVEN = 0, - MIDPOINT = 1, - COSITED_EVEN_KHR = COSITED_EVEN, - MIDPOINT_KHR = MIDPOINT, -} - -CoarseSampleOrderTypeNV :: enum c.int { - DEFAULT = 0, - CUSTOM = 1, - PIXEL_MAJOR = 2, - SAMPLE_MAJOR = 3, -} - -ColorComponentFlags :: distinct bit_set[ColorComponentFlag; Flags] -ColorComponentFlag :: enum Flags { - R = 0, - G = 1, - B = 2, - A = 3, -} - -ColorSpaceKHR :: enum c.int { - SRGB_NONLINEAR = 0, - DISPLAY_P3_NONLINEAR_EXT = 1000104001, - EXTENDED_SRGB_LINEAR_EXT = 1000104002, - DISPLAY_P3_LINEAR_EXT = 1000104003, - DCI_P3_NONLINEAR_EXT = 1000104004, - BT709_LINEAR_EXT = 1000104005, - BT709_NONLINEAR_EXT = 1000104006, - BT2020_LINEAR_EXT = 1000104007, - HDR10_ST2084_EXT = 1000104008, - DOLBYVISION_EXT = 1000104009, - HDR10_HLG_EXT = 1000104010, - ADOBERGB_LINEAR_EXT = 1000104011, - ADOBERGB_NONLINEAR_EXT = 1000104012, - PASS_THROUGH_EXT = 1000104013, - EXTENDED_SRGB_NONLINEAR_EXT = 1000104014, - DISPLAY_NATIVE_AMD = 1000213000, - COLORSPACE_SRGB_NONLINEAR = SRGB_NONLINEAR, - DCI_P3_LINEAR_EXT = DISPLAY_P3_LINEAR_EXT, -} - -CommandBufferLevel :: enum c.int { - PRIMARY = 0, - SECONDARY = 1, -} - -CommandBufferResetFlags :: distinct bit_set[CommandBufferResetFlag; Flags] -CommandBufferResetFlag :: enum Flags { - RELEASE_RESOURCES = 0, -} - -CommandBufferUsageFlags :: distinct bit_set[CommandBufferUsageFlag; Flags] -CommandBufferUsageFlag :: enum Flags { - ONE_TIME_SUBMIT = 0, - RENDER_PASS_CONTINUE = 1, - SIMULTANEOUS_USE = 2, -} - -CommandPoolCreateFlags :: distinct bit_set[CommandPoolCreateFlag; Flags] -CommandPoolCreateFlag :: enum Flags { - TRANSIENT = 0, - RESET_COMMAND_BUFFER = 1, - PROTECTED = 2, -} - -CommandPoolResetFlags :: distinct bit_set[CommandPoolResetFlag; Flags] -CommandPoolResetFlag :: enum Flags { - RELEASE_RESOURCES = 0, -} - -CompareOp :: enum c.int { - NEVER = 0, - LESS = 1, - EQUAL = 2, - LESS_OR_EQUAL = 3, - GREATER = 4, - NOT_EQUAL = 5, - GREATER_OR_EQUAL = 6, - ALWAYS = 7, -} - -ComponentSwizzle :: enum c.int { - IDENTITY = 0, - ZERO = 1, - ONE = 2, - R = 3, - G = 4, - B = 5, - A = 6, -} - -ComponentTypeNV :: enum c.int { - FLOAT16 = 0, - FLOAT32 = 1, - FLOAT64 = 2, - SINT8 = 3, - SINT16 = 4, - SINT32 = 5, - SINT64 = 6, - UINT8 = 7, - UINT16 = 8, - UINT32 = 9, - UINT64 = 10, -} - -CompositeAlphaFlagsKHR :: distinct bit_set[CompositeAlphaFlagKHR; Flags] -CompositeAlphaFlagKHR :: enum Flags { - OPAQUE = 0, - PRE_MULTIPLIED = 1, - POST_MULTIPLIED = 2, - INHERIT = 3, -} - -ConditionalRenderingFlagsEXT :: distinct bit_set[ConditionalRenderingFlagEXT; Flags] -ConditionalRenderingFlagEXT :: enum Flags { - INVERTED = 0, -} - -ConservativeRasterizationModeEXT :: enum c.int { - DISABLED = 0, - OVERESTIMATE = 1, - UNDERESTIMATE = 2, -} - -CopyAccelerationStructureModeKHR :: enum c.int { - CLONE = 0, - COMPACT = 1, - SERIALIZE = 2, - DESERIALIZE = 3, - CLONE_NV = CLONE, - COMPACT_NV = COMPACT, -} - -CoverageModulationModeNV :: enum c.int { - NONE = 0, - RGB = 1, - ALPHA = 2, - RGBA = 3, -} - -CoverageReductionModeNV :: enum c.int { - MERGE = 0, - TRUNCATE = 1, -} - -CullModeFlags :: distinct bit_set[CullModeFlag; Flags] -CullModeFlag :: enum Flags { - FRONT = 0, - BACK = 1, -} - -CullModeFlags_NONE :: CullModeFlags{} -CullModeFlags_FRONT_AND_BACK :: CullModeFlags{.FRONT, .BACK} - - -DebugReportFlagsEXT :: distinct bit_set[DebugReportFlagEXT; Flags] -DebugReportFlagEXT :: enum Flags { - INFORMATION = 0, - WARNING = 1, - PERFORMANCE_WARNING = 2, - ERROR = 3, - DEBUG = 4, -} - -DebugReportObjectTypeEXT :: enum c.int { - UNKNOWN = 0, - INSTANCE = 1, - PHYSICAL_DEVICE = 2, - DEVICE = 3, - QUEUE = 4, - SEMAPHORE = 5, - COMMAND_BUFFER = 6, - FENCE = 7, - DEVICE_MEMORY = 8, - BUFFER = 9, - IMAGE = 10, - EVENT = 11, - QUERY_POOL = 12, - BUFFER_VIEW = 13, - IMAGE_VIEW = 14, - SHADER_MODULE = 15, - PIPELINE_CACHE = 16, - PIPELINE_LAYOUT = 17, - RENDER_PASS = 18, - PIPELINE = 19, - DESCRIPTOR_SET_LAYOUT = 20, - SAMPLER = 21, - DESCRIPTOR_POOL = 22, - DESCRIPTOR_SET = 23, - FRAMEBUFFER = 24, - COMMAND_POOL = 25, - SURFACE_KHR = 26, - SWAPCHAIN_KHR = 27, - DEBUG_REPORT_CALLBACK_EXT = 28, - DISPLAY_KHR = 29, - DISPLAY_MODE_KHR = 30, - VALIDATION_CACHE_EXT = 33, - SAMPLER_YCBCR_CONVERSION = 1000156000, - DESCRIPTOR_UPDATE_TEMPLATE = 1000085000, - CU_MODULE_NVX = 1000029000, - CU_FUNCTION_NVX = 1000029001, - ACCELERATION_STRUCTURE_KHR = 1000150000, - ACCELERATION_STRUCTURE_NV = 1000165000, - BUFFER_COLLECTION_FUCHSIA = 1000366000, - DEBUG_REPORT = DEBUG_REPORT_CALLBACK_EXT, - VALIDATION_CACHE = VALIDATION_CACHE_EXT, - DESCRIPTOR_UPDATE_TEMPLATE_KHR = DESCRIPTOR_UPDATE_TEMPLATE, - SAMPLER_YCBCR_CONVERSION_KHR = SAMPLER_YCBCR_CONVERSION, -} - -DebugUtilsMessageSeverityFlagsEXT :: distinct bit_set[DebugUtilsMessageSeverityFlagEXT; Flags] -DebugUtilsMessageSeverityFlagEXT :: enum Flags { - VERBOSE = 0, - INFO = 4, - WARNING = 8, - ERROR = 12, -} - -DebugUtilsMessageTypeFlagsEXT :: distinct bit_set[DebugUtilsMessageTypeFlagEXT; Flags] -DebugUtilsMessageTypeFlagEXT :: enum Flags { - GENERAL = 0, - VALIDATION = 1, - PERFORMANCE = 2, -} - -DependencyFlags :: distinct bit_set[DependencyFlag; Flags] -DependencyFlag :: enum Flags { - BY_REGION = 0, - DEVICE_GROUP = 2, - VIEW_LOCAL = 1, - VIEW_LOCAL_KHR = VIEW_LOCAL, - DEVICE_GROUP_KHR = DEVICE_GROUP, -} - -DescriptorBindingFlags :: distinct bit_set[DescriptorBindingFlag; Flags] -DescriptorBindingFlag :: enum Flags { - UPDATE_AFTER_BIND = 0, - UPDATE_UNUSED_WHILE_PENDING = 1, - PARTIALLY_BOUND = 2, - VARIABLE_DESCRIPTOR_COUNT = 3, - UPDATE_AFTER_BIND_EXT = UPDATE_AFTER_BIND, - UPDATE_UNUSED_WHILE_PENDING_EXT = UPDATE_UNUSED_WHILE_PENDING, - PARTIALLY_BOUND_EXT = PARTIALLY_BOUND, - VARIABLE_DESCRIPTOR_COUNT_EXT = VARIABLE_DESCRIPTOR_COUNT, -} - -DescriptorPoolCreateFlags :: distinct bit_set[DescriptorPoolCreateFlag; Flags] -DescriptorPoolCreateFlag :: enum Flags { - FREE_DESCRIPTOR_SET = 0, - UPDATE_AFTER_BIND = 1, - HOST_ONLY_VALVE = 2, - UPDATE_AFTER_BIND_EXT = UPDATE_AFTER_BIND, -} - -DescriptorSetLayoutCreateFlags :: distinct bit_set[DescriptorSetLayoutCreateFlag; Flags] -DescriptorSetLayoutCreateFlag :: enum Flags { - UPDATE_AFTER_BIND_POOL = 1, - PUSH_DESCRIPTOR_KHR = 0, - HOST_ONLY_POOL_VALVE = 2, - UPDATE_AFTER_BIND_POOL_EXT = UPDATE_AFTER_BIND_POOL, -} - -DescriptorType :: enum c.int { - SAMPLER = 0, - COMBINED_IMAGE_SAMPLER = 1, - SAMPLED_IMAGE = 2, - STORAGE_IMAGE = 3, - UNIFORM_TEXEL_BUFFER = 4, - STORAGE_TEXEL_BUFFER = 5, - UNIFORM_BUFFER = 6, - STORAGE_BUFFER = 7, - UNIFORM_BUFFER_DYNAMIC = 8, - STORAGE_BUFFER_DYNAMIC = 9, - INPUT_ATTACHMENT = 10, - INLINE_UNIFORM_BLOCK = 1000138000, - ACCELERATION_STRUCTURE_KHR = 1000150000, - ACCELERATION_STRUCTURE_NV = 1000165000, - MUTABLE_VALVE = 1000351000, - INLINE_UNIFORM_BLOCK_EXT = INLINE_UNIFORM_BLOCK, -} - -DescriptorUpdateTemplateType :: enum c.int { - DESCRIPTOR_SET = 0, - PUSH_DESCRIPTORS_KHR = 1, - DESCRIPTOR_SET_KHR = DESCRIPTOR_SET, -} - -DeviceDiagnosticsConfigFlagsNV :: distinct bit_set[DeviceDiagnosticsConfigFlagNV; Flags] -DeviceDiagnosticsConfigFlagNV :: enum Flags { - ENABLE_SHADER_DEBUG_INFO = 0, - ENABLE_RESOURCE_TRACKING = 1, - ENABLE_AUTOMATIC_CHECKPOINTS = 2, -} - -DeviceEventTypeEXT :: enum c.int { - DISPLAY_HOTPLUG = 0, -} - -DeviceGroupPresentModeFlagsKHR :: distinct bit_set[DeviceGroupPresentModeFlagKHR; Flags] -DeviceGroupPresentModeFlagKHR :: enum Flags { - LOCAL = 0, - REMOTE = 1, - SUM = 2, - LOCAL_MULTI_DEVICE = 3, -} - -DeviceMemoryReportEventTypeEXT :: enum c.int { - ALLOCATE = 0, - FREE = 1, - IMPORT = 2, - UNIMPORT = 3, - ALLOCATION_FAILED = 4, -} - -DeviceQueueCreateFlags :: distinct bit_set[DeviceQueueCreateFlag; Flags] -DeviceQueueCreateFlag :: enum Flags { - PROTECTED = 0, -} - -DiscardRectangleModeEXT :: enum c.int { - INCLUSIVE = 0, - EXCLUSIVE = 1, -} - -DisplayEventTypeEXT :: enum c.int { - FIRST_PIXEL_OUT = 0, -} - -DisplayPlaneAlphaFlagsKHR :: distinct bit_set[DisplayPlaneAlphaFlagKHR; Flags] -DisplayPlaneAlphaFlagKHR :: enum Flags { - OPAQUE = 0, - GLOBAL = 1, - PER_PIXEL = 2, - PER_PIXEL_PREMULTIPLIED = 3, -} - -DisplayPowerStateEXT :: enum c.int { - OFF = 0, - SUSPEND = 1, - ON = 2, -} - -DriverId :: enum c.int { - AMD_PROPRIETARY = 1, - AMD_OPEN_SOURCE = 2, - MESA_RADV = 3, - NVIDIA_PROPRIETARY = 4, - INTEL_PROPRIETARY_WINDOWS = 5, - INTEL_OPEN_SOURCE_MESA = 6, - IMAGINATION_PROPRIETARY = 7, - QUALCOMM_PROPRIETARY = 8, - ARM_PROPRIETARY = 9, - GOOGLE_SWIFTSHADER = 10, - GGP_PROPRIETARY = 11, - BROADCOM_PROPRIETARY = 12, - MESA_LLVMPIPE = 13, - MOLTENVK = 14, - COREAVI_PROPRIETARY = 15, - JUICE_PROPRIETARY = 16, - VERISILICON_PROPRIETARY = 17, - MESA_TURNIP = 18, - MESA_V3DV = 19, - MESA_PANVK = 20, - SAMSUNG_PROPRIETARY = 21, - MESA_VENUS = 22, - AMD_PROPRIETARY_KHR = AMD_PROPRIETARY, - AMD_OPEN_SOURCE_KHR = AMD_OPEN_SOURCE, - MESA_RADV_KHR = MESA_RADV, - NVIDIA_PROPRIETARY_KHR = NVIDIA_PROPRIETARY, - INTEL_PROPRIETARY_WINDOWS_KHR = INTEL_PROPRIETARY_WINDOWS, - INTEL_OPEN_SOURCE_MESA_KHR = INTEL_OPEN_SOURCE_MESA, - IMAGINATION_PROPRIETARY_KHR = IMAGINATION_PROPRIETARY, - QUALCOMM_PROPRIETARY_KHR = QUALCOMM_PROPRIETARY, - ARM_PROPRIETARY_KHR = ARM_PROPRIETARY, - GOOGLE_SWIFTSHADER_KHR = GOOGLE_SWIFTSHADER, - GGP_PROPRIETARY_KHR = GGP_PROPRIETARY, - BROADCOM_PROPRIETARY_KHR = BROADCOM_PROPRIETARY, -} - -DynamicState :: enum c.int { - VIEWPORT = 0, - SCISSOR = 1, - LINE_WIDTH = 2, - DEPTH_BIAS = 3, - BLEND_CONSTANTS = 4, - DEPTH_BOUNDS = 5, - STENCIL_COMPARE_MASK = 6, - STENCIL_WRITE_MASK = 7, - STENCIL_REFERENCE = 8, - CULL_MODE = 1000267000, - FRONT_FACE = 1000267001, - PRIMITIVE_TOPOLOGY = 1000267002, - VIEWPORT_WITH_COUNT = 1000267003, - SCISSOR_WITH_COUNT = 1000267004, - VERTEX_INPUT_BINDING_STRIDE = 1000267005, - DEPTH_TEST_ENABLE = 1000267006, - DEPTH_WRITE_ENABLE = 1000267007, - DEPTH_COMPARE_OP = 1000267008, - DEPTH_BOUNDS_TEST_ENABLE = 1000267009, - STENCIL_TEST_ENABLE = 1000267010, - STENCIL_OP = 1000267011, - RASTERIZER_DISCARD_ENABLE = 1000377001, - DEPTH_BIAS_ENABLE = 1000377002, - PRIMITIVE_RESTART_ENABLE = 1000377004, - VIEWPORT_W_SCALING_NV = 1000087000, - DISCARD_RECTANGLE_EXT = 1000099000, - SAMPLE_LOCATIONS_EXT = 1000143000, - RAY_TRACING_PIPELINE_STACK_SIZE_KHR = 1000347000, - VIEWPORT_SHADING_RATE_PALETTE_NV = 1000164004, - VIEWPORT_COARSE_SAMPLE_ORDER_NV = 1000164006, - EXCLUSIVE_SCISSOR_NV = 1000205001, - FRAGMENT_SHADING_RATE_KHR = 1000226000, - LINE_STIPPLE_EXT = 1000259000, - VERTEX_INPUT_EXT = 1000352000, - PATCH_CONTROL_POINTS_EXT = 1000377000, - LOGIC_OP_EXT = 1000377003, - COLOR_WRITE_ENABLE_EXT = 1000381000, - CULL_MODE_EXT = CULL_MODE, - FRONT_FACE_EXT = FRONT_FACE, - PRIMITIVE_TOPOLOGY_EXT = PRIMITIVE_TOPOLOGY, - VIEWPORT_WITH_COUNT_EXT = VIEWPORT_WITH_COUNT, - SCISSOR_WITH_COUNT_EXT = SCISSOR_WITH_COUNT, - VERTEX_INPUT_BINDING_STRIDE_EXT = VERTEX_INPUT_BINDING_STRIDE, - DEPTH_TEST_ENABLE_EXT = DEPTH_TEST_ENABLE, - DEPTH_WRITE_ENABLE_EXT = DEPTH_WRITE_ENABLE, - DEPTH_COMPARE_OP_EXT = DEPTH_COMPARE_OP, - DEPTH_BOUNDS_TEST_ENABLE_EXT = DEPTH_BOUNDS_TEST_ENABLE, - STENCIL_TEST_ENABLE_EXT = STENCIL_TEST_ENABLE, - STENCIL_OP_EXT = STENCIL_OP, - RASTERIZER_DISCARD_ENABLE_EXT = RASTERIZER_DISCARD_ENABLE, - DEPTH_BIAS_ENABLE_EXT = DEPTH_BIAS_ENABLE, - PRIMITIVE_RESTART_ENABLE_EXT = PRIMITIVE_RESTART_ENABLE, -} - -EventCreateFlags :: distinct bit_set[EventCreateFlag; Flags] -EventCreateFlag :: enum Flags { - DEVICE_ONLY = 0, - DEVICE_ONLY_KHR = DEVICE_ONLY, -} - -ExternalFenceFeatureFlags :: distinct bit_set[ExternalFenceFeatureFlag; Flags] -ExternalFenceFeatureFlag :: enum Flags { - EXPORTABLE = 0, - IMPORTABLE = 1, - EXPORTABLE_KHR = EXPORTABLE, - IMPORTABLE_KHR = IMPORTABLE, -} - -ExternalFenceHandleTypeFlags :: distinct bit_set[ExternalFenceHandleTypeFlag; Flags] -ExternalFenceHandleTypeFlag :: enum Flags { - OPAQUE_FD = 0, - OPAQUE_WIN32 = 1, - OPAQUE_WIN32_KMT = 2, - SYNC_FD = 3, - OPAQUE_FD_KHR = OPAQUE_FD, - OPAQUE_WIN32_KHR = OPAQUE_WIN32, - OPAQUE_WIN32_KMT_KHR = OPAQUE_WIN32_KMT, - SYNC_FD_KHR = SYNC_FD, -} - -ExternalMemoryFeatureFlags :: distinct bit_set[ExternalMemoryFeatureFlag; Flags] -ExternalMemoryFeatureFlag :: enum Flags { - DEDICATED_ONLY = 0, - EXPORTABLE = 1, - IMPORTABLE = 2, - DEDICATED_ONLY_KHR = DEDICATED_ONLY, - EXPORTABLE_KHR = EXPORTABLE, - IMPORTABLE_KHR = IMPORTABLE, -} - -ExternalMemoryFeatureFlagsNV :: distinct bit_set[ExternalMemoryFeatureFlagNV; Flags] -ExternalMemoryFeatureFlagNV :: enum Flags { - DEDICATED_ONLY = 0, - EXPORTABLE = 1, - IMPORTABLE = 2, -} - -ExternalMemoryHandleTypeFlags :: distinct bit_set[ExternalMemoryHandleTypeFlag; Flags] -ExternalMemoryHandleTypeFlag :: enum Flags { - OPAQUE_FD = 0, - OPAQUE_WIN32 = 1, - OPAQUE_WIN32_KMT = 2, - D3D11_TEXTURE = 3, - D3D11_TEXTURE_KMT = 4, - D3D12_HEAP = 5, - D3D12_RESOURCE = 6, - DMA_BUF_EXT = 9, - ANDROID_HARDWARE_BUFFER_ANDROID = 10, - HOST_ALLOCATION_EXT = 7, - HOST_MAPPED_FOREIGN_MEMORY_EXT = 8, - ZIRCON_VMO_FUCHSIA = 11, - RDMA_ADDRESS_NV = 12, - OPAQUE_FD_KHR = OPAQUE_FD, - OPAQUE_WIN32_KHR = OPAQUE_WIN32, - OPAQUE_WIN32_KMT_KHR = OPAQUE_WIN32_KMT, - D3D11_TEXTURE_KHR = D3D11_TEXTURE, - D3D11_TEXTURE_KMT_KHR = D3D11_TEXTURE_KMT, - D3D12_HEAP_KHR = D3D12_HEAP, - D3D12_RESOURCE_KHR = D3D12_RESOURCE, -} - -ExternalMemoryHandleTypeFlagsNV :: distinct bit_set[ExternalMemoryHandleTypeFlagNV; Flags] -ExternalMemoryHandleTypeFlagNV :: enum Flags { - OPAQUE_WIN32 = 0, - OPAQUE_WIN32_KMT = 1, - D3D11_IMAGE = 2, - D3D11_IMAGE_KMT = 3, -} - -ExternalSemaphoreFeatureFlags :: distinct bit_set[ExternalSemaphoreFeatureFlag; Flags] -ExternalSemaphoreFeatureFlag :: enum Flags { - EXPORTABLE = 0, - IMPORTABLE = 1, - EXPORTABLE_KHR = EXPORTABLE, - IMPORTABLE_KHR = IMPORTABLE, -} - -ExternalSemaphoreHandleTypeFlags :: distinct bit_set[ExternalSemaphoreHandleTypeFlag; Flags] -ExternalSemaphoreHandleTypeFlag :: enum Flags { - OPAQUE_FD = 0, - OPAQUE_WIN32 = 1, - OPAQUE_WIN32_KMT = 2, - D3D12_FENCE = 3, - SYNC_FD = 4, - ZIRCON_EVENT_FUCHSIA = 7, - D3D11_FENCE = D3D12_FENCE, - OPAQUE_FD_KHR = OPAQUE_FD, - OPAQUE_WIN32_KHR = OPAQUE_WIN32, - OPAQUE_WIN32_KMT_KHR = OPAQUE_WIN32_KMT, - D3D12_FENCE_KHR = D3D12_FENCE, - SYNC_FD_KHR = SYNC_FD, -} - -FenceCreateFlags :: distinct bit_set[FenceCreateFlag; Flags] -FenceCreateFlag :: enum Flags { - SIGNALED = 0, -} - -FenceImportFlags :: distinct bit_set[FenceImportFlag; Flags] -FenceImportFlag :: enum Flags { - TEMPORARY = 0, - TEMPORARY_KHR = TEMPORARY, -} - -Filter :: enum c.int { - NEAREST = 0, - LINEAR = 1, - CUBIC_IMG = 1000015000, - CUBIC_EXT = CUBIC_IMG, -} - -Format :: enum c.int { - UNDEFINED = 0, - R4G4_UNORM_PACK8 = 1, - R4G4B4A4_UNORM_PACK16 = 2, - B4G4R4A4_UNORM_PACK16 = 3, - R5G6B5_UNORM_PACK16 = 4, - B5G6R5_UNORM_PACK16 = 5, - R5G5B5A1_UNORM_PACK16 = 6, - B5G5R5A1_UNORM_PACK16 = 7, - A1R5G5B5_UNORM_PACK16 = 8, - R8_UNORM = 9, - R8_SNORM = 10, - R8_USCALED = 11, - R8_SSCALED = 12, - R8_UINT = 13, - R8_SINT = 14, - R8_SRGB = 15, - R8G8_UNORM = 16, - R8G8_SNORM = 17, - R8G8_USCALED = 18, - R8G8_SSCALED = 19, - R8G8_UINT = 20, - R8G8_SINT = 21, - R8G8_SRGB = 22, - R8G8B8_UNORM = 23, - R8G8B8_SNORM = 24, - R8G8B8_USCALED = 25, - R8G8B8_SSCALED = 26, - R8G8B8_UINT = 27, - R8G8B8_SINT = 28, - R8G8B8_SRGB = 29, - B8G8R8_UNORM = 30, - B8G8R8_SNORM = 31, - B8G8R8_USCALED = 32, - B8G8R8_SSCALED = 33, - B8G8R8_UINT = 34, - B8G8R8_SINT = 35, - B8G8R8_SRGB = 36, - R8G8B8A8_UNORM = 37, - R8G8B8A8_SNORM = 38, - R8G8B8A8_USCALED = 39, - R8G8B8A8_SSCALED = 40, - R8G8B8A8_UINT = 41, - R8G8B8A8_SINT = 42, - R8G8B8A8_SRGB = 43, - B8G8R8A8_UNORM = 44, - B8G8R8A8_SNORM = 45, - B8G8R8A8_USCALED = 46, - B8G8R8A8_SSCALED = 47, - B8G8R8A8_UINT = 48, - B8G8R8A8_SINT = 49, - B8G8R8A8_SRGB = 50, - A8B8G8R8_UNORM_PACK32 = 51, - A8B8G8R8_SNORM_PACK32 = 52, - A8B8G8R8_USCALED_PACK32 = 53, - A8B8G8R8_SSCALED_PACK32 = 54, - A8B8G8R8_UINT_PACK32 = 55, - A8B8G8R8_SINT_PACK32 = 56, - A8B8G8R8_SRGB_PACK32 = 57, - A2R10G10B10_UNORM_PACK32 = 58, - A2R10G10B10_SNORM_PACK32 = 59, - A2R10G10B10_USCALED_PACK32 = 60, - A2R10G10B10_SSCALED_PACK32 = 61, - A2R10G10B10_UINT_PACK32 = 62, - A2R10G10B10_SINT_PACK32 = 63, - A2B10G10R10_UNORM_PACK32 = 64, - A2B10G10R10_SNORM_PACK32 = 65, - A2B10G10R10_USCALED_PACK32 = 66, - A2B10G10R10_SSCALED_PACK32 = 67, - A2B10G10R10_UINT_PACK32 = 68, - A2B10G10R10_SINT_PACK32 = 69, - R16_UNORM = 70, - R16_SNORM = 71, - R16_USCALED = 72, - R16_SSCALED = 73, - R16_UINT = 74, - R16_SINT = 75, - R16_SFLOAT = 76, - R16G16_UNORM = 77, - R16G16_SNORM = 78, - R16G16_USCALED = 79, - R16G16_SSCALED = 80, - R16G16_UINT = 81, - R16G16_SINT = 82, - R16G16_SFLOAT = 83, - R16G16B16_UNORM = 84, - R16G16B16_SNORM = 85, - R16G16B16_USCALED = 86, - R16G16B16_SSCALED = 87, - R16G16B16_UINT = 88, - R16G16B16_SINT = 89, - R16G16B16_SFLOAT = 90, - R16G16B16A16_UNORM = 91, - R16G16B16A16_SNORM = 92, - R16G16B16A16_USCALED = 93, - R16G16B16A16_SSCALED = 94, - R16G16B16A16_UINT = 95, - R16G16B16A16_SINT = 96, - R16G16B16A16_SFLOAT = 97, - R32_UINT = 98, - R32_SINT = 99, - R32_SFLOAT = 100, - R32G32_UINT = 101, - R32G32_SINT = 102, - R32G32_SFLOAT = 103, - R32G32B32_UINT = 104, - R32G32B32_SINT = 105, - R32G32B32_SFLOAT = 106, - R32G32B32A32_UINT = 107, - R32G32B32A32_SINT = 108, - R32G32B32A32_SFLOAT = 109, - R64_UINT = 110, - R64_SINT = 111, - R64_SFLOAT = 112, - R64G64_UINT = 113, - R64G64_SINT = 114, - R64G64_SFLOAT = 115, - R64G64B64_UINT = 116, - R64G64B64_SINT = 117, - R64G64B64_SFLOAT = 118, - R64G64B64A64_UINT = 119, - R64G64B64A64_SINT = 120, - R64G64B64A64_SFLOAT = 121, - B10G11R11_UFLOAT_PACK32 = 122, - E5B9G9R9_UFLOAT_PACK32 = 123, - D16_UNORM = 124, - X8_D24_UNORM_PACK32 = 125, - D32_SFLOAT = 126, - S8_UINT = 127, - D16_UNORM_S8_UINT = 128, - D24_UNORM_S8_UINT = 129, - D32_SFLOAT_S8_UINT = 130, - BC1_RGB_UNORM_BLOCK = 131, - BC1_RGB_SRGB_BLOCK = 132, - BC1_RGBA_UNORM_BLOCK = 133, - BC1_RGBA_SRGB_BLOCK = 134, - BC2_UNORM_BLOCK = 135, - BC2_SRGB_BLOCK = 136, - BC3_UNORM_BLOCK = 137, - BC3_SRGB_BLOCK = 138, - BC4_UNORM_BLOCK = 139, - BC4_SNORM_BLOCK = 140, - BC5_UNORM_BLOCK = 141, - BC5_SNORM_BLOCK = 142, - BC6H_UFLOAT_BLOCK = 143, - BC6H_SFLOAT_BLOCK = 144, - BC7_UNORM_BLOCK = 145, - BC7_SRGB_BLOCK = 146, - ETC2_R8G8B8_UNORM_BLOCK = 147, - ETC2_R8G8B8_SRGB_BLOCK = 148, - ETC2_R8G8B8A1_UNORM_BLOCK = 149, - ETC2_R8G8B8A1_SRGB_BLOCK = 150, - ETC2_R8G8B8A8_UNORM_BLOCK = 151, - ETC2_R8G8B8A8_SRGB_BLOCK = 152, - EAC_R11_UNORM_BLOCK = 153, - EAC_R11_SNORM_BLOCK = 154, - EAC_R11G11_UNORM_BLOCK = 155, - EAC_R11G11_SNORM_BLOCK = 156, - ASTC_4x4_UNORM_BLOCK = 157, - ASTC_4x4_SRGB_BLOCK = 158, - ASTC_5x4_UNORM_BLOCK = 159, - ASTC_5x4_SRGB_BLOCK = 160, - ASTC_5x5_UNORM_BLOCK = 161, - ASTC_5x5_SRGB_BLOCK = 162, - ASTC_6x5_UNORM_BLOCK = 163, - ASTC_6x5_SRGB_BLOCK = 164, - ASTC_6x6_UNORM_BLOCK = 165, - ASTC_6x6_SRGB_BLOCK = 166, - ASTC_8x5_UNORM_BLOCK = 167, - ASTC_8x5_SRGB_BLOCK = 168, - ASTC_8x6_UNORM_BLOCK = 169, - ASTC_8x6_SRGB_BLOCK = 170, - ASTC_8x8_UNORM_BLOCK = 171, - ASTC_8x8_SRGB_BLOCK = 172, - ASTC_10x5_UNORM_BLOCK = 173, - ASTC_10x5_SRGB_BLOCK = 174, - ASTC_10x6_UNORM_BLOCK = 175, - ASTC_10x6_SRGB_BLOCK = 176, - ASTC_10x8_UNORM_BLOCK = 177, - ASTC_10x8_SRGB_BLOCK = 178, - ASTC_10x10_UNORM_BLOCK = 179, - ASTC_10x10_SRGB_BLOCK = 180, - ASTC_12x10_UNORM_BLOCK = 181, - ASTC_12x10_SRGB_BLOCK = 182, - ASTC_12x12_UNORM_BLOCK = 183, - ASTC_12x12_SRGB_BLOCK = 184, - G8B8G8R8_422_UNORM = 1000156000, - B8G8R8G8_422_UNORM = 1000156001, - G8_B8_R8_3PLANE_420_UNORM = 1000156002, - G8_B8R8_2PLANE_420_UNORM = 1000156003, - G8_B8_R8_3PLANE_422_UNORM = 1000156004, - G8_B8R8_2PLANE_422_UNORM = 1000156005, - G8_B8_R8_3PLANE_444_UNORM = 1000156006, - R10X6_UNORM_PACK16 = 1000156007, - R10X6G10X6_UNORM_2PACK16 = 1000156008, - R10X6G10X6B10X6A10X6_UNORM_4PACK16 = 1000156009, - G10X6B10X6G10X6R10X6_422_UNORM_4PACK16 = 1000156010, - B10X6G10X6R10X6G10X6_422_UNORM_4PACK16 = 1000156011, - G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16 = 1000156012, - G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16 = 1000156013, - G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16 = 1000156014, - G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16 = 1000156015, - G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16 = 1000156016, - R12X4_UNORM_PACK16 = 1000156017, - R12X4G12X4_UNORM_2PACK16 = 1000156018, - R12X4G12X4B12X4A12X4_UNORM_4PACK16 = 1000156019, - G12X4B12X4G12X4R12X4_422_UNORM_4PACK16 = 1000156020, - B12X4G12X4R12X4G12X4_422_UNORM_4PACK16 = 1000156021, - G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16 = 1000156022, - G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16 = 1000156023, - G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16 = 1000156024, - G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16 = 1000156025, - G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16 = 1000156026, - G16B16G16R16_422_UNORM = 1000156027, - B16G16R16G16_422_UNORM = 1000156028, - G16_B16_R16_3PLANE_420_UNORM = 1000156029, - G16_B16R16_2PLANE_420_UNORM = 1000156030, - G16_B16_R16_3PLANE_422_UNORM = 1000156031, - G16_B16R16_2PLANE_422_UNORM = 1000156032, - G16_B16_R16_3PLANE_444_UNORM = 1000156033, - G8_B8R8_2PLANE_444_UNORM = 1000330000, - G10X6_B10X6R10X6_2PLANE_444_UNORM_3PACK16 = 1000330001, - G12X4_B12X4R12X4_2PLANE_444_UNORM_3PACK16 = 1000330002, - G16_B16R16_2PLANE_444_UNORM = 1000330003, - A4R4G4B4_UNORM_PACK16 = 1000340000, - A4B4G4R4_UNORM_PACK16 = 1000340001, - ASTC_4x4_SFLOAT_BLOCK = 1000066000, - ASTC_5x4_SFLOAT_BLOCK = 1000066001, - ASTC_5x5_SFLOAT_BLOCK = 1000066002, - ASTC_6x5_SFLOAT_BLOCK = 1000066003, - ASTC_6x6_SFLOAT_BLOCK = 1000066004, - ASTC_8x5_SFLOAT_BLOCK = 1000066005, - ASTC_8x6_SFLOAT_BLOCK = 1000066006, - ASTC_8x8_SFLOAT_BLOCK = 1000066007, - ASTC_10x5_SFLOAT_BLOCK = 1000066008, - ASTC_10x6_SFLOAT_BLOCK = 1000066009, - ASTC_10x8_SFLOAT_BLOCK = 1000066010, - ASTC_10x10_SFLOAT_BLOCK = 1000066011, - ASTC_12x10_SFLOAT_BLOCK = 1000066012, - ASTC_12x12_SFLOAT_BLOCK = 1000066013, - PVRTC1_2BPP_UNORM_BLOCK_IMG = 1000054000, - PVRTC1_4BPP_UNORM_BLOCK_IMG = 1000054001, - PVRTC2_2BPP_UNORM_BLOCK_IMG = 1000054002, - PVRTC2_4BPP_UNORM_BLOCK_IMG = 1000054003, - PVRTC1_2BPP_SRGB_BLOCK_IMG = 1000054004, - PVRTC1_4BPP_SRGB_BLOCK_IMG = 1000054005, - PVRTC2_2BPP_SRGB_BLOCK_IMG = 1000054006, - PVRTC2_4BPP_SRGB_BLOCK_IMG = 1000054007, - ASTC_4x4_SFLOAT_BLOCK_EXT = ASTC_4x4_SFLOAT_BLOCK, - ASTC_5x4_SFLOAT_BLOCK_EXT = ASTC_5x4_SFLOAT_BLOCK, - ASTC_5x5_SFLOAT_BLOCK_EXT = ASTC_5x5_SFLOAT_BLOCK, - ASTC_6x5_SFLOAT_BLOCK_EXT = ASTC_6x5_SFLOAT_BLOCK, - ASTC_6x6_SFLOAT_BLOCK_EXT = ASTC_6x6_SFLOAT_BLOCK, - ASTC_8x5_SFLOAT_BLOCK_EXT = ASTC_8x5_SFLOAT_BLOCK, - ASTC_8x6_SFLOAT_BLOCK_EXT = ASTC_8x6_SFLOAT_BLOCK, - ASTC_8x8_SFLOAT_BLOCK_EXT = ASTC_8x8_SFLOAT_BLOCK, - ASTC_10x5_SFLOAT_BLOCK_EXT = ASTC_10x5_SFLOAT_BLOCK, - ASTC_10x6_SFLOAT_BLOCK_EXT = ASTC_10x6_SFLOAT_BLOCK, - ASTC_10x8_SFLOAT_BLOCK_EXT = ASTC_10x8_SFLOAT_BLOCK, - ASTC_10x10_SFLOAT_BLOCK_EXT = ASTC_10x10_SFLOAT_BLOCK, - ASTC_12x10_SFLOAT_BLOCK_EXT = ASTC_12x10_SFLOAT_BLOCK, - ASTC_12x12_SFLOAT_BLOCK_EXT = ASTC_12x12_SFLOAT_BLOCK, - G8B8G8R8_422_UNORM_KHR = G8B8G8R8_422_UNORM, - B8G8R8G8_422_UNORM_KHR = B8G8R8G8_422_UNORM, - G8_B8_R8_3PLANE_420_UNORM_KHR = G8_B8_R8_3PLANE_420_UNORM, - G8_B8R8_2PLANE_420_UNORM_KHR = G8_B8R8_2PLANE_420_UNORM, - G8_B8_R8_3PLANE_422_UNORM_KHR = G8_B8_R8_3PLANE_422_UNORM, - G8_B8R8_2PLANE_422_UNORM_KHR = G8_B8R8_2PLANE_422_UNORM, - G8_B8_R8_3PLANE_444_UNORM_KHR = G8_B8_R8_3PLANE_444_UNORM, - R10X6_UNORM_PACK16_KHR = R10X6_UNORM_PACK16, - R10X6G10X6_UNORM_2PACK16_KHR = R10X6G10X6_UNORM_2PACK16, - R10X6G10X6B10X6A10X6_UNORM_4PACK16_KHR = R10X6G10X6B10X6A10X6_UNORM_4PACK16, - G10X6B10X6G10X6R10X6_422_UNORM_4PACK16_KHR = G10X6B10X6G10X6R10X6_422_UNORM_4PACK16, - B10X6G10X6R10X6G10X6_422_UNORM_4PACK16_KHR = B10X6G10X6R10X6G10X6_422_UNORM_4PACK16, - G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16_KHR = G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16, - G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16_KHR = G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16, - G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16_KHR = G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16, - G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16_KHR = G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16, - G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16_KHR = G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16, - R12X4_UNORM_PACK16_KHR = R12X4_UNORM_PACK16, - R12X4G12X4_UNORM_2PACK16_KHR = R12X4G12X4_UNORM_2PACK16, - R12X4G12X4B12X4A12X4_UNORM_4PACK16_KHR = R12X4G12X4B12X4A12X4_UNORM_4PACK16, - G12X4B12X4G12X4R12X4_422_UNORM_4PACK16_KHR = G12X4B12X4G12X4R12X4_422_UNORM_4PACK16, - B12X4G12X4R12X4G12X4_422_UNORM_4PACK16_KHR = B12X4G12X4R12X4G12X4_422_UNORM_4PACK16, - G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16_KHR = G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16, - G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16_KHR = G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16, - G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16_KHR = G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16, - G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16_KHR = G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16, - G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16_KHR = G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16, - G16B16G16R16_422_UNORM_KHR = G16B16G16R16_422_UNORM, - B16G16R16G16_422_UNORM_KHR = B16G16R16G16_422_UNORM, - G16_B16_R16_3PLANE_420_UNORM_KHR = G16_B16_R16_3PLANE_420_UNORM, - G16_B16R16_2PLANE_420_UNORM_KHR = G16_B16R16_2PLANE_420_UNORM, - G16_B16_R16_3PLANE_422_UNORM_KHR = G16_B16_R16_3PLANE_422_UNORM, - G16_B16R16_2PLANE_422_UNORM_KHR = G16_B16R16_2PLANE_422_UNORM, - G16_B16_R16_3PLANE_444_UNORM_KHR = G16_B16_R16_3PLANE_444_UNORM, - G8_B8R8_2PLANE_444_UNORM_EXT = G8_B8R8_2PLANE_444_UNORM, - G10X6_B10X6R10X6_2PLANE_444_UNORM_3PACK16_EXT = G10X6_B10X6R10X6_2PLANE_444_UNORM_3PACK16, - G12X4_B12X4R12X4_2PLANE_444_UNORM_3PACK16_EXT = G12X4_B12X4R12X4_2PLANE_444_UNORM_3PACK16, - G16_B16R16_2PLANE_444_UNORM_EXT = G16_B16R16_2PLANE_444_UNORM, - A4R4G4B4_UNORM_PACK16_EXT = A4R4G4B4_UNORM_PACK16, - A4B4G4R4_UNORM_PACK16_EXT = A4B4G4R4_UNORM_PACK16, -} - -FormatFeatureFlags :: distinct bit_set[FormatFeatureFlag; Flags] -FormatFeatureFlag :: enum Flags { - SAMPLED_IMAGE = 0, - STORAGE_IMAGE = 1, - STORAGE_IMAGE_ATOMIC = 2, - UNIFORM_TEXEL_BUFFER = 3, - STORAGE_TEXEL_BUFFER = 4, - STORAGE_TEXEL_BUFFER_ATOMIC = 5, - VERTEX_BUFFER = 6, - COLOR_ATTACHMENT = 7, - COLOR_ATTACHMENT_BLEND = 8, - DEPTH_STENCIL_ATTACHMENT = 9, - BLIT_SRC = 10, - BLIT_DST = 11, - SAMPLED_IMAGE_FILTER_LINEAR = 12, - TRANSFER_SRC = 14, - TRANSFER_DST = 15, - MIDPOINT_CHROMA_SAMPLES = 17, - SAMPLED_IMAGE_YCBCR_CONVERSION_LINEAR_FILTER = 18, - SAMPLED_IMAGE_YCBCR_CONVERSION_SEPARATE_RECONSTRUCTION_FILTER = 19, - SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT = 20, - SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_FORCEABLE = 21, - DISJOINT = 22, - COSITED_CHROMA_SAMPLES = 23, - SAMPLED_IMAGE_FILTER_MINMAX = 16, - SAMPLED_IMAGE_FILTER_CUBIC_IMG = 13, - VIDEO_DECODE_OUTPUT_KHR = 25, - VIDEO_DECODE_DPB_KHR = 26, - ACCELERATION_STRUCTURE_VERTEX_BUFFER_KHR = 29, - FRAGMENT_DENSITY_MAP_EXT = 24, - FRAGMENT_SHADING_RATE_ATTACHMENT_KHR = 30, - VIDEO_ENCODE_INPUT_KHR = 27, - VIDEO_ENCODE_DPB_KHR = 28, - TRANSFER_SRC_KHR = TRANSFER_SRC, - TRANSFER_DST_KHR = TRANSFER_DST, - SAMPLED_IMAGE_FILTER_MINMAX_EXT = SAMPLED_IMAGE_FILTER_MINMAX, - MIDPOINT_CHROMA_SAMPLES_KHR = MIDPOINT_CHROMA_SAMPLES, - SAMPLED_IMAGE_YCBCR_CONVERSION_LINEAR_FILTER_KHR = SAMPLED_IMAGE_YCBCR_CONVERSION_LINEAR_FILTER, - SAMPLED_IMAGE_YCBCR_CONVERSION_SEPARATE_RECONSTRUCTION_FILTER_KHR = SAMPLED_IMAGE_YCBCR_CONVERSION_SEPARATE_RECONSTRUCTION_FILTER, - SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_KHR = SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT, - SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_FORCEABLE_KHR = SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_FORCEABLE, - DISJOINT_KHR = DISJOINT, - COSITED_CHROMA_SAMPLES_KHR = COSITED_CHROMA_SAMPLES, - SAMPLED_IMAGE_FILTER_CUBIC_EXT = SAMPLED_IMAGE_FILTER_CUBIC_IMG, -} - -FragmentShadingRateCombinerOpKHR :: enum c.int { - KEEP = 0, - REPLACE = 1, - MIN = 2, - MAX = 3, - MUL = 4, -} - -FragmentShadingRateNV :: enum c.int { - _1_INVOCATION_PER_PIXEL = 0, - _1_INVOCATION_PER_1X2_PIXELS = 1, - _1_INVOCATION_PER_2X1_PIXELS = 4, - _1_INVOCATION_PER_2X2_PIXELS = 5, - _1_INVOCATION_PER_2X4_PIXELS = 6, - _1_INVOCATION_PER_4X2_PIXELS = 9, - _1_INVOCATION_PER_4X4_PIXELS = 10, - _2_INVOCATIONS_PER_PIXEL = 11, - _4_INVOCATIONS_PER_PIXEL = 12, - _8_INVOCATIONS_PER_PIXEL = 13, - _16_INVOCATIONS_PER_PIXEL = 14, - NO_INVOCATIONS = 15, -} - -FragmentShadingRateTypeNV :: enum c.int { - FRAGMENT_SIZE = 0, - ENUMS = 1, -} - -FramebufferCreateFlags :: distinct bit_set[FramebufferCreateFlag; Flags] -FramebufferCreateFlag :: enum Flags { - IMAGELESS = 0, - IMAGELESS_KHR = IMAGELESS, -} - -FrontFace :: enum c.int { - COUNTER_CLOCKWISE = 0, - CLOCKWISE = 1, -} - -FullScreenExclusiveEXT :: enum c.int { - DEFAULT = 0, - ALLOWED = 1, - DISALLOWED = 2, - APPLICATION_CONTROLLED = 3, -} - -GeometryFlagsKHR :: distinct bit_set[GeometryFlagKHR; Flags] -GeometryFlagKHR :: enum Flags { - OPAQUE = 0, - NO_DUPLICATE_ANY_HIT_INVOCATION = 1, - OPAQUE_NV = OPAQUE, - NO_DUPLICATE_ANY_HIT_INVOCATION_NV = NO_DUPLICATE_ANY_HIT_INVOCATION, -} - -GeometryInstanceFlagsKHR :: distinct bit_set[GeometryInstanceFlagKHR; Flags] -GeometryInstanceFlagKHR :: enum Flags { - TRIANGLE_FACING_CULL_DISABLE = 0, - TRIANGLE_FLIP_FACING = 1, - FORCE_OPAQUE = 2, - FORCE_NO_OPAQUE = 3, - TRIANGLE_FRONT_COUNTERCLOCKWISE = TRIANGLE_FLIP_FACING, - TRIANGLE_CULL_DISABLE_NV = TRIANGLE_FACING_CULL_DISABLE, - TRIANGLE_FRONT_COUNTERCLOCKWISE_NV = TRIANGLE_FRONT_COUNTERCLOCKWISE, - FORCE_OPAQUE_NV = FORCE_OPAQUE, - FORCE_NO_OPAQUE_NV = FORCE_NO_OPAQUE, -} - -GeometryTypeKHR :: enum c.int { - TRIANGLES = 0, - AABBS = 1, - INSTANCES = 2, - TRIANGLES_NV = TRIANGLES, - AABBS_NV = AABBS, -} - -GraphicsPipelineLibraryFlagsEXT :: distinct bit_set[GraphicsPipelineLibraryFlagEXT; Flags] -GraphicsPipelineLibraryFlagEXT :: enum Flags { - VERTEX_INPUT_INTERFACE = 0, - PRE_RASTERIZATION_SHADERS = 1, - FRAGMENT_SHADER = 2, - FRAGMENT_OUTPUT_INTERFACE = 3, -} - -ImageAspectFlags :: distinct bit_set[ImageAspectFlag; Flags] -ImageAspectFlag :: enum Flags { - COLOR = 0, - DEPTH = 1, - STENCIL = 2, - METADATA = 3, - PLANE_0 = 4, - PLANE_1 = 5, - PLANE_2 = 6, - MEMORY_PLANE_0_EXT = 7, - MEMORY_PLANE_1_EXT = 8, - MEMORY_PLANE_2_EXT = 9, - MEMORY_PLANE_3_EXT = 10, - PLANE_0_KHR = PLANE_0, - PLANE_1_KHR = PLANE_1, - PLANE_2_KHR = PLANE_2, -} - -ImageAspectFlags_NONE :: ImageAspectFlags{} - - -ImageCreateFlags :: distinct bit_set[ImageCreateFlag; Flags] -ImageCreateFlag :: enum Flags { - SPARSE_BINDING = 0, - SPARSE_RESIDENCY = 1, - SPARSE_ALIASED = 2, - MUTABLE_FORMAT = 3, - CUBE_COMPATIBLE = 4, - ALIAS = 10, - SPLIT_INSTANCE_BIND_REGIONS = 6, - D2_ARRAY_COMPATIBLE = 5, - BLOCK_TEXEL_VIEW_COMPATIBLE = 7, - EXTENDED_USAGE = 8, - PROTECTED = 11, - DISJOINT = 9, - CORNER_SAMPLED_NV = 13, - SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_EXT = 12, - SUBSAMPLED_EXT = 14, - D2_VIEW_COMPATIBLE_EXT = 17, - FRAGMENT_DENSITY_MAP_OFFSET_QCOM = 15, - SPLIT_INSTANCE_BIND_REGIONS_KHR = SPLIT_INSTANCE_BIND_REGIONS, - D2_ARRAY_COMPATIBLE_KHR = D2_ARRAY_COMPATIBLE, - BLOCK_TEXEL_VIEW_COMPATIBLE_KHR = BLOCK_TEXEL_VIEW_COMPATIBLE, - EXTENDED_USAGE_KHR = EXTENDED_USAGE, - DISJOINT_KHR = DISJOINT, - ALIAS_KHR = ALIAS, -} - -ImageLayout :: enum c.int { - UNDEFINED = 0, - GENERAL = 1, - COLOR_ATTACHMENT_OPTIMAL = 2, - DEPTH_STENCIL_ATTACHMENT_OPTIMAL = 3, - DEPTH_STENCIL_READ_ONLY_OPTIMAL = 4, - SHADER_READ_ONLY_OPTIMAL = 5, - TRANSFER_SRC_OPTIMAL = 6, - TRANSFER_DST_OPTIMAL = 7, - PREINITIALIZED = 8, - DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL = 1000117000, - DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL = 1000117001, - DEPTH_ATTACHMENT_OPTIMAL = 1000241000, - DEPTH_READ_ONLY_OPTIMAL = 1000241001, - STENCIL_ATTACHMENT_OPTIMAL = 1000241002, - STENCIL_READ_ONLY_OPTIMAL = 1000241003, - READ_ONLY_OPTIMAL = 1000314000, - ATTACHMENT_OPTIMAL = 1000314001, - PRESENT_SRC_KHR = 1000001002, - VIDEO_DECODE_DST_KHR = 1000024000, - VIDEO_DECODE_SRC_KHR = 1000024001, - VIDEO_DECODE_DPB_KHR = 1000024002, - SHARED_PRESENT_KHR = 1000111000, - FRAGMENT_DENSITY_MAP_OPTIMAL_EXT = 1000218000, - FRAGMENT_SHADING_RATE_ATTACHMENT_OPTIMAL_KHR = 1000164003, - VIDEO_ENCODE_DST_KHR = 1000299000, - VIDEO_ENCODE_SRC_KHR = 1000299001, - VIDEO_ENCODE_DPB_KHR = 1000299002, - DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR = DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL, - DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR = DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL, - SHADING_RATE_OPTIMAL_NV = FRAGMENT_SHADING_RATE_ATTACHMENT_OPTIMAL_KHR, - DEPTH_ATTACHMENT_OPTIMAL_KHR = DEPTH_ATTACHMENT_OPTIMAL, - DEPTH_READ_ONLY_OPTIMAL_KHR = DEPTH_READ_ONLY_OPTIMAL, - STENCIL_ATTACHMENT_OPTIMAL_KHR = STENCIL_ATTACHMENT_OPTIMAL, - STENCIL_READ_ONLY_OPTIMAL_KHR = STENCIL_READ_ONLY_OPTIMAL, - READ_ONLY_OPTIMAL_KHR = READ_ONLY_OPTIMAL, - ATTACHMENT_OPTIMAL_KHR = ATTACHMENT_OPTIMAL, -} - -ImageTiling :: enum c.int { - OPTIMAL = 0, - LINEAR = 1, - DRM_FORMAT_MODIFIER_EXT = 1000158000, -} - -ImageType :: enum c.int { - D1 = 0, - D2 = 1, - D3 = 2, -} - -ImageUsageFlags :: distinct bit_set[ImageUsageFlag; Flags] -ImageUsageFlag :: enum Flags { - TRANSFER_SRC = 0, - TRANSFER_DST = 1, - SAMPLED = 2, - STORAGE = 3, - COLOR_ATTACHMENT = 4, - DEPTH_STENCIL_ATTACHMENT = 5, - TRANSIENT_ATTACHMENT = 6, - INPUT_ATTACHMENT = 7, - VIDEO_DECODE_DST_KHR = 10, - VIDEO_DECODE_SRC_KHR = 11, - VIDEO_DECODE_DPB_KHR = 12, - FRAGMENT_DENSITY_MAP_EXT = 9, - FRAGMENT_SHADING_RATE_ATTACHMENT_KHR = 8, - VIDEO_ENCODE_DST_KHR = 13, - VIDEO_ENCODE_SRC_KHR = 14, - VIDEO_ENCODE_DPB_KHR = 15, - INVOCATION_MASK_HUAWEI = 18, - SHADING_RATE_IMAGE_NV = FRAGMENT_SHADING_RATE_ATTACHMENT_KHR, -} - -ImageViewCreateFlags :: distinct bit_set[ImageViewCreateFlag; Flags] -ImageViewCreateFlag :: enum Flags { - FRAGMENT_DENSITY_MAP_DYNAMIC_EXT = 0, - FRAGMENT_DENSITY_MAP_DEFERRED_EXT = 1, -} - -ImageViewType :: enum c.int { - D1 = 0, - D2 = 1, - D3 = 2, - CUBE = 3, - D1_ARRAY = 4, - D2_ARRAY = 5, - CUBE_ARRAY = 6, -} - -IndexType :: enum c.int { - UINT16 = 0, - UINT32 = 1, - NONE_KHR = 1000165000, - UINT8_EXT = 1000265000, - NONE_NV = NONE_KHR, -} - -IndirectCommandsLayoutUsageFlagsNV :: distinct bit_set[IndirectCommandsLayoutUsageFlagNV; Flags] -IndirectCommandsLayoutUsageFlagNV :: enum Flags { - EXPLICIT_PREPROCESS = 0, - INDEXED_SEQUENCES = 1, - UNORDERED_SEQUENCES = 2, -} - -IndirectCommandsTokenTypeNV :: enum c.int { - SHADER_GROUP = 0, - STATE_FLAGS = 1, - INDEX_BUFFER = 2, - VERTEX_BUFFER = 3, - PUSH_CONSTANT = 4, - DRAW_INDEXED = 5, - DRAW = 6, - DRAW_TASKS = 7, -} - -IndirectStateFlagsNV :: distinct bit_set[IndirectStateFlagNV; Flags] -IndirectStateFlagNV :: enum Flags { - FLAG_FRONTFACE = 0, -} - -InstanceCreateFlags :: distinct bit_set[InstanceCreateFlag; Flags] -InstanceCreateFlag :: enum Flags { - ENUMERATE_PORTABILITY_KHR = 0, -} - -InternalAllocationType :: enum c.int { - EXECUTABLE = 0, -} - -LineRasterizationModeEXT :: enum c.int { - DEFAULT = 0, - RECTANGULAR = 1, - BRESENHAM = 2, - RECTANGULAR_SMOOTH = 3, -} - -LogicOp :: enum c.int { - CLEAR = 0, - AND = 1, - AND_REVERSE = 2, - COPY = 3, - AND_INVERTED = 4, - NO_OP = 5, - XOR = 6, - OR = 7, - NOR = 8, - EQUIVALENT = 9, - INVERT = 10, - OR_REVERSE = 11, - COPY_INVERTED = 12, - OR_INVERTED = 13, - NAND = 14, - SET = 15, -} - -MemoryAllocateFlags :: distinct bit_set[MemoryAllocateFlag; Flags] -MemoryAllocateFlag :: enum Flags { - DEVICE_MASK = 0, - DEVICE_ADDRESS = 1, - DEVICE_ADDRESS_CAPTURE_REPLAY = 2, - DEVICE_MASK_KHR = DEVICE_MASK, - DEVICE_ADDRESS_KHR = DEVICE_ADDRESS, - DEVICE_ADDRESS_CAPTURE_REPLAY_KHR = DEVICE_ADDRESS_CAPTURE_REPLAY, -} - -MemoryHeapFlags :: distinct bit_set[MemoryHeapFlag; Flags] -MemoryHeapFlag :: enum Flags { - DEVICE_LOCAL = 0, - MULTI_INSTANCE = 1, - MULTI_INSTANCE_KHR = MULTI_INSTANCE, -} - -MemoryOverallocationBehaviorAMD :: enum c.int { - DEFAULT = 0, - ALLOWED = 1, - DISALLOWED = 2, -} - -MemoryPropertyFlags :: distinct bit_set[MemoryPropertyFlag; Flags] -MemoryPropertyFlag :: enum Flags { - DEVICE_LOCAL = 0, - HOST_VISIBLE = 1, - HOST_COHERENT = 2, - HOST_CACHED = 3, - LAZILY_ALLOCATED = 4, - PROTECTED = 5, - DEVICE_COHERENT_AMD = 6, - DEVICE_UNCACHED_AMD = 7, - RDMA_CAPABLE_NV = 8, -} - -ObjectType :: enum c.int { - UNKNOWN = 0, - INSTANCE = 1, - PHYSICAL_DEVICE = 2, - DEVICE = 3, - QUEUE = 4, - SEMAPHORE = 5, - COMMAND_BUFFER = 6, - FENCE = 7, - DEVICE_MEMORY = 8, - BUFFER = 9, - IMAGE = 10, - EVENT = 11, - QUERY_POOL = 12, - BUFFER_VIEW = 13, - IMAGE_VIEW = 14, - SHADER_MODULE = 15, - PIPELINE_CACHE = 16, - PIPELINE_LAYOUT = 17, - RENDER_PASS = 18, - PIPELINE = 19, - DESCRIPTOR_SET_LAYOUT = 20, - SAMPLER = 21, - DESCRIPTOR_POOL = 22, - DESCRIPTOR_SET = 23, - FRAMEBUFFER = 24, - COMMAND_POOL = 25, - SAMPLER_YCBCR_CONVERSION = 1000156000, - DESCRIPTOR_UPDATE_TEMPLATE = 1000085000, - PRIVATE_DATA_SLOT = 1000295000, - SURFACE_KHR = 1000000000, - SWAPCHAIN_KHR = 1000001000, - DISPLAY_KHR = 1000002000, - DISPLAY_MODE_KHR = 1000002001, - DEBUG_REPORT_CALLBACK_EXT = 1000011000, - VIDEO_SESSION_KHR = 1000023000, - VIDEO_SESSION_PARAMETERS_KHR = 1000023001, - CU_MODULE_NVX = 1000029000, - CU_FUNCTION_NVX = 1000029001, - DEBUG_UTILS_MESSENGER_EXT = 1000128000, - ACCELERATION_STRUCTURE_KHR = 1000150000, - VALIDATION_CACHE_EXT = 1000160000, - ACCELERATION_STRUCTURE_NV = 1000165000, - PERFORMANCE_CONFIGURATION_INTEL = 1000210000, - DEFERRED_OPERATION_KHR = 1000268000, - INDIRECT_COMMANDS_LAYOUT_NV = 1000277000, - BUFFER_COLLECTION_FUCHSIA = 1000366000, - DESCRIPTOR_UPDATE_TEMPLATE_KHR = DESCRIPTOR_UPDATE_TEMPLATE, - SAMPLER_YCBCR_CONVERSION_KHR = SAMPLER_YCBCR_CONVERSION, - PRIVATE_DATA_SLOT_EXT = PRIVATE_DATA_SLOT, -} - -PeerMemoryFeatureFlags :: distinct bit_set[PeerMemoryFeatureFlag; Flags] -PeerMemoryFeatureFlag :: enum Flags { - COPY_SRC = 0, - COPY_DST = 1, - GENERIC_SRC = 2, - GENERIC_DST = 3, - COPY_SRC_KHR = COPY_SRC, - COPY_DST_KHR = COPY_DST, - GENERIC_SRC_KHR = GENERIC_SRC, - GENERIC_DST_KHR = GENERIC_DST, -} - -PerformanceConfigurationTypeINTEL :: enum c.int { - PERFORMANCE_CONFIGURATION_TYPE_COMMAND_QUEUE_METRICS_DISCOVERY_ACTIVATED_INTEL = 0, -} - -PerformanceCounterDescriptionFlagsKHR :: distinct bit_set[PerformanceCounterDescriptionFlagKHR; Flags] -PerformanceCounterDescriptionFlagKHR :: enum Flags { - PERFORMANCE_IMPACTING = 0, - CONCURRENTLY_IMPACTED = 1, -} - -PerformanceCounterScopeKHR :: enum c.int { - COMMAND_BUFFER = 0, - RENDER_PASS = 1, - COMMAND = 2, - QUERY_SCOPE_COMMAND_BUFFER = COMMAND_BUFFER, - QUERY_SCOPE_RENDER_PASS = RENDER_PASS, - QUERY_SCOPE_COMMAND = COMMAND, -} - -PerformanceCounterStorageKHR :: enum c.int { - INT32 = 0, - INT64 = 1, - UINT32 = 2, - UINT64 = 3, - FLOAT32 = 4, - FLOAT64 = 5, -} - -PerformanceCounterUnitKHR :: enum c.int { - GENERIC = 0, - PERCENTAGE = 1, - NANOSECONDS = 2, - BYTES = 3, - BYTES_PER_SECOND = 4, - KELVIN = 5, - WATTS = 6, - VOLTS = 7, - AMPS = 8, - HERTZ = 9, - CYCLES = 10, -} - -PerformanceOverrideTypeINTEL :: enum c.int { - PERFORMANCE_OVERRIDE_TYPE_NULL_HARDWARE_INTEL = 0, - PERFORMANCE_OVERRIDE_TYPE_FLUSH_GPU_CACHES_INTEL = 1, -} - -PerformanceParameterTypeINTEL :: enum c.int { - PERFORMANCE_PARAMETER_TYPE_HW_COUNTERS_SUPPORTED_INTEL = 0, - PERFORMANCE_PARAMETER_TYPE_STREAM_MARKER_VALID_BITS_INTEL = 1, -} - -PerformanceValueTypeINTEL :: enum c.int { - PERFORMANCE_VALUE_TYPE_UINT32_INTEL = 0, - PERFORMANCE_VALUE_TYPE_UINT64_INTEL = 1, - PERFORMANCE_VALUE_TYPE_FLOAT_INTEL = 2, - PERFORMANCE_VALUE_TYPE_BOOL_INTEL = 3, - PERFORMANCE_VALUE_TYPE_STRING_INTEL = 4, -} - -PhysicalDeviceType :: enum c.int { - OTHER = 0, - INTEGRATED_GPU = 1, - DISCRETE_GPU = 2, - VIRTUAL_GPU = 3, - CPU = 4, -} - -PipelineBindPoint :: enum c.int { - GRAPHICS = 0, - COMPUTE = 1, - RAY_TRACING_KHR = 1000165000, - SUBPASS_SHADING_HUAWEI = 1000369003, - RAY_TRACING_NV = RAY_TRACING_KHR, -} - -PipelineCacheCreateFlags :: distinct bit_set[PipelineCacheCreateFlag; Flags] -PipelineCacheCreateFlag :: enum Flags { - EXTERNALLY_SYNCHRONIZED = 0, - EXTERNALLY_SYNCHRONIZED_EXT = EXTERNALLY_SYNCHRONIZED, -} - -PipelineCacheHeaderVersion :: enum c.int { - ONE = 1, -} - -PipelineColorBlendStateCreateFlags :: distinct bit_set[PipelineColorBlendStateCreateFlag; Flags] -PipelineColorBlendStateCreateFlag :: enum Flags { - RASTERIZATION_ORDER_ATTACHMENT_ACCESS_ARM = 0, -} - -PipelineCompilerControlFlagsAMD :: distinct bit_set[PipelineCompilerControlFlagAMD; Flags] -PipelineCompilerControlFlagAMD :: enum Flags { -} - -PipelineCreateFlags :: distinct bit_set[PipelineCreateFlag; Flags] -PipelineCreateFlag :: enum Flags { - DISABLE_OPTIMIZATION = 0, - ALLOW_DERIVATIVES = 1, - DERIVATIVE = 2, - VIEW_INDEX_FROM_DEVICE_INDEX = 3, - DISPATCH_BASE = 4, - FAIL_ON_PIPELINE_COMPILE_REQUIRED = 8, - EARLY_RETURN_ON_FAILURE = 9, - RENDERING_FRAGMENT_SHADING_RATE_ATTACHMENT_KHR = 21, - RENDERING_FRAGMENT_DENSITY_MAP_ATTACHMENT_EXT = 22, - RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_KHR = 14, - RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_KHR = 15, - RAY_TRACING_NO_NULL_MISS_SHADERS_KHR = 16, - RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_KHR = 17, - RAY_TRACING_SKIP_TRIANGLES_KHR = 12, - RAY_TRACING_SKIP_AABBS_KHR = 13, - RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_KHR = 19, - DEFER_COMPILE_NV = 5, - CAPTURE_STATISTICS_KHR = 6, - CAPTURE_INTERNAL_REPRESENTATIONS_KHR = 7, - INDIRECT_BINDABLE_NV = 18, - LIBRARY_KHR = 11, - RETAIN_LINK_TIME_OPTIMIZATION_INFO_EXT = 23, - LINK_TIME_OPTIMIZATION_EXT = 10, - RAY_TRACING_ALLOW_MOTION_NV = 20, - PIPELINE_RASTERIZATION_STATE_CREATE_FRAGMENT_SHADING_RATE_ATTACHMENT_KHR = RENDERING_FRAGMENT_SHADING_RATE_ATTACHMENT_KHR, - PIPELINE_RASTERIZATION_STATE_CREATE_FRAGMENT_DENSITY_MAP_ATTACHMENT_EXT = RENDERING_FRAGMENT_DENSITY_MAP_ATTACHMENT_EXT, - VIEW_INDEX_FROM_DEVICE_INDEX_KHR = VIEW_INDEX_FROM_DEVICE_INDEX, - DISPATCH_BASE_KHR = DISPATCH_BASE, - FAIL_ON_PIPELINE_COMPILE_REQUIRED_EXT = FAIL_ON_PIPELINE_COMPILE_REQUIRED, - EARLY_RETURN_ON_FAILURE_EXT = EARLY_RETURN_ON_FAILURE, -} - -PipelineCreationFeedbackFlags :: distinct bit_set[PipelineCreationFeedbackFlag; Flags] -PipelineCreationFeedbackFlag :: enum Flags { - VALID = 0, - APPLICATION_PIPELINE_CACHE_HIT = 1, - BASE_PIPELINE_ACCELERATION = 2, - VALID_EXT = VALID, - APPLICATION_PIPELINE_CACHE_HIT_EXT = APPLICATION_PIPELINE_CACHE_HIT, - BASE_PIPELINE_ACCELERATION_EXT = BASE_PIPELINE_ACCELERATION, -} - -PipelineDepthStencilStateCreateFlags :: distinct bit_set[PipelineDepthStencilStateCreateFlag; Flags] -PipelineDepthStencilStateCreateFlag :: enum Flags { - RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_ARM = 0, - RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_ARM = 1, -} - -PipelineExecutableStatisticFormatKHR :: enum c.int { - BOOL32 = 0, - INT64 = 1, - UINT64 = 2, - FLOAT64 = 3, -} - -PipelineLayoutCreateFlags :: distinct bit_set[PipelineLayoutCreateFlag; Flags] -PipelineLayoutCreateFlag :: enum Flags { - INDEPENDENT_SETS_EXT = 1, -} - -PipelineShaderStageCreateFlags :: distinct bit_set[PipelineShaderStageCreateFlag; Flags] -PipelineShaderStageCreateFlag :: enum Flags { - ALLOW_VARYING_SUBGROUP_SIZE = 0, - REQUIRE_FULL_SUBGROUPS = 1, - ALLOW_VARYING_SUBGROUP_SIZE_EXT = ALLOW_VARYING_SUBGROUP_SIZE, - REQUIRE_FULL_SUBGROUPS_EXT = REQUIRE_FULL_SUBGROUPS, -} - -PipelineStageFlags :: distinct bit_set[PipelineStageFlag; Flags] -PipelineStageFlag :: enum Flags { - TOP_OF_PIPE = 0, - DRAW_INDIRECT = 1, - VERTEX_INPUT = 2, - VERTEX_SHADER = 3, - TESSELLATION_CONTROL_SHADER = 4, - TESSELLATION_EVALUATION_SHADER = 5, - GEOMETRY_SHADER = 6, - FRAGMENT_SHADER = 7, - EARLY_FRAGMENT_TESTS = 8, - LATE_FRAGMENT_TESTS = 9, - COLOR_ATTACHMENT_OUTPUT = 10, - COMPUTE_SHADER = 11, - TRANSFER = 12, - BOTTOM_OF_PIPE = 13, - HOST = 14, - ALL_GRAPHICS = 15, - ALL_COMMANDS = 16, - TRANSFORM_FEEDBACK_EXT = 24, - CONDITIONAL_RENDERING_EXT = 18, - ACCELERATION_STRUCTURE_BUILD_KHR = 25, - RAY_TRACING_SHADER_KHR = 21, - TASK_SHADER_NV = 19, - MESH_SHADER_NV = 20, - FRAGMENT_DENSITY_PROCESS_EXT = 23, - FRAGMENT_SHADING_RATE_ATTACHMENT_KHR = 22, - COMMAND_PREPROCESS_NV = 17, - SHADING_RATE_IMAGE_NV = FRAGMENT_SHADING_RATE_ATTACHMENT_KHR, - RAY_TRACING_SHADER_NV = RAY_TRACING_SHADER_KHR, - ACCELERATION_STRUCTURE_BUILD_NV = ACCELERATION_STRUCTURE_BUILD_KHR, -} - -PipelineStageFlags_NONE :: PipelineStageFlags{} - - -PointClippingBehavior :: enum c.int { - ALL_CLIP_PLANES = 0, - USER_CLIP_PLANES_ONLY = 1, - ALL_CLIP_PLANES_KHR = ALL_CLIP_PLANES, - USER_CLIP_PLANES_ONLY_KHR = USER_CLIP_PLANES_ONLY, -} - -PolygonMode :: enum c.int { - FILL = 0, - LINE = 1, - POINT = 2, - FILL_RECTANGLE_NV = 1000153000, -} - -PresentModeKHR :: enum c.int { - IMMEDIATE = 0, - MAILBOX = 1, - FIFO = 2, - FIFO_RELAXED = 3, - SHARED_DEMAND_REFRESH = 1000111000, - SHARED_CONTINUOUS_REFRESH = 1000111001, -} - -PrimitiveTopology :: enum c.int { - POINT_LIST = 0, - LINE_LIST = 1, - LINE_STRIP = 2, - TRIANGLE_LIST = 3, - TRIANGLE_STRIP = 4, - TRIANGLE_FAN = 5, - LINE_LIST_WITH_ADJACENCY = 6, - LINE_STRIP_WITH_ADJACENCY = 7, - TRIANGLE_LIST_WITH_ADJACENCY = 8, - TRIANGLE_STRIP_WITH_ADJACENCY = 9, - PATCH_LIST = 10, -} - -ProvokingVertexModeEXT :: enum c.int { - FIRST_VERTEX = 0, - LAST_VERTEX = 1, -} - -QueryControlFlags :: distinct bit_set[QueryControlFlag; Flags] -QueryControlFlag :: enum Flags { - PRECISE = 0, -} - -QueryPipelineStatisticFlags :: distinct bit_set[QueryPipelineStatisticFlag; Flags] -QueryPipelineStatisticFlag :: enum Flags { - INPUT_ASSEMBLY_VERTICES = 0, - INPUT_ASSEMBLY_PRIMITIVES = 1, - VERTEX_SHADER_INVOCATIONS = 2, - GEOMETRY_SHADER_INVOCATIONS = 3, - GEOMETRY_SHADER_PRIMITIVES = 4, - CLIPPING_INVOCATIONS = 5, - CLIPPING_PRIMITIVES = 6, - FRAGMENT_SHADER_INVOCATIONS = 7, - TESSELLATION_CONTROL_SHADER_PATCHES = 8, - TESSELLATION_EVALUATION_SHADER_INVOCATIONS = 9, - COMPUTE_SHADER_INVOCATIONS = 10, -} - -QueryPoolSamplingModeINTEL :: enum c.int { - QUERY_POOL_SAMPLING_MODE_MANUAL_INTEL = 0, -} - -QueryResultFlags :: distinct bit_set[QueryResultFlag; Flags] -QueryResultFlag :: enum Flags { - _64 = 0, - WAIT = 1, - WITH_AVAILABILITY = 2, - PARTIAL = 3, - WITH_STATUS_KHR = 4, -} - -QueryType :: enum c.int { - OCCLUSION = 0, - PIPELINE_STATISTICS = 1, - TIMESTAMP = 2, - RESULT_STATUS_ONLY_KHR = 1000023000, - TRANSFORM_FEEDBACK_STREAM_EXT = 1000028004, - PERFORMANCE_QUERY_KHR = 1000116000, - ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR = 1000150000, - ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR = 1000150001, - ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV = 1000165000, - PERFORMANCE_QUERY_INTEL = 1000210000, - VIDEO_ENCODE_BITSTREAM_BUFFER_RANGE_KHR = 1000299000, - PRIMITIVES_GENERATED_EXT = 1000382000, -} - -QueueFlags :: distinct bit_set[QueueFlag; Flags] -QueueFlag :: enum Flags { - GRAPHICS = 0, - COMPUTE = 1, - TRANSFER = 2, - SPARSE_BINDING = 3, - PROTECTED = 4, - VIDEO_DECODE_KHR = 5, - VIDEO_ENCODE_KHR = 6, -} - -QueueGlobalPriorityKHR :: enum c.int { - LOW = 128, - MEDIUM = 256, - HIGH = 512, - REALTIME = 1024, - LOW_EXT = LOW, - MEDIUM_EXT = MEDIUM, - HIGH_EXT = HIGH, - REALTIME_EXT = REALTIME, -} - -RasterizationOrderAMD :: enum c.int { - STRICT = 0, - RELAXED = 1, -} - -RayTracingShaderGroupTypeKHR :: enum c.int { - GENERAL = 0, - TRIANGLES_HIT_GROUP = 1, - PROCEDURAL_HIT_GROUP = 2, - GENERAL_NV = GENERAL, - TRIANGLES_HIT_GROUP_NV = TRIANGLES_HIT_GROUP, - PROCEDURAL_HIT_GROUP_NV = PROCEDURAL_HIT_GROUP, -} - -RenderPassCreateFlags :: distinct bit_set[RenderPassCreateFlag; Flags] -RenderPassCreateFlag :: enum Flags { - TRANSFORM_QCOM = 1, -} - -RenderingFlags :: distinct bit_set[RenderingFlag; Flags] -RenderingFlag :: enum Flags { - CONTENTS_SECONDARY_COMMAND_BUFFERS = 0, - SUSPENDING = 1, - RESUMING = 2, - CONTENTS_SECONDARY_COMMAND_BUFFERS_KHR = CONTENTS_SECONDARY_COMMAND_BUFFERS, - SUSPENDING_KHR = SUSPENDING, - RESUMING_KHR = RESUMING, -} - -ResolveModeFlags :: distinct bit_set[ResolveModeFlag; Flags] -ResolveModeFlag :: enum Flags { - SAMPLE_ZERO = 0, - AVERAGE = 1, - MIN = 2, - MAX = 3, - SAMPLE_ZERO_KHR = SAMPLE_ZERO, - AVERAGE_KHR = AVERAGE, - MIN_KHR = MIN, - MAX_KHR = MAX, -} - -ResolveModeFlags_NONE :: ResolveModeFlags{} - - -Result :: enum c.int { - SUCCESS = 0, - NOT_READY = 1, - TIMEOUT = 2, - EVENT_SET = 3, - EVENT_RESET = 4, - INCOMPLETE = 5, - ERROR_OUT_OF_HOST_MEMORY = -1, - ERROR_OUT_OF_DEVICE_MEMORY = -2, - ERROR_INITIALIZATION_FAILED = -3, - ERROR_DEVICE_LOST = -4, - ERROR_MEMORY_MAP_FAILED = -5, - ERROR_LAYER_NOT_PRESENT = -6, - ERROR_EXTENSION_NOT_PRESENT = -7, - ERROR_FEATURE_NOT_PRESENT = -8, - ERROR_INCOMPATIBLE_DRIVER = -9, - ERROR_TOO_MANY_OBJECTS = -10, - ERROR_FORMAT_NOT_SUPPORTED = -11, - ERROR_FRAGMENTED_POOL = -12, - ERROR_UNKNOWN = -13, - ERROR_OUT_OF_POOL_MEMORY = -1000069000, - ERROR_INVALID_EXTERNAL_HANDLE = -1000072003, - ERROR_FRAGMENTATION = -1000161000, - ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS = -1000257000, - PIPELINE_COMPILE_REQUIRED = 1000297000, - ERROR_SURFACE_LOST_KHR = -1000000000, - ERROR_NATIVE_WINDOW_IN_USE_KHR = -1000000001, - SUBOPTIMAL_KHR = 1000001003, - ERROR_OUT_OF_DATE_KHR = -1000001004, - ERROR_INCOMPATIBLE_DISPLAY_KHR = -1000003001, - ERROR_VALIDATION_FAILED_EXT = -1000011001, - ERROR_INVALID_SHADER_NV = -1000012000, - ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT = -1000158000, - ERROR_NOT_PERMITTED_KHR = -1000174001, - ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT = -1000255000, - THREAD_IDLE_KHR = 1000268000, - THREAD_DONE_KHR = 1000268001, - OPERATION_DEFERRED_KHR = 1000268002, - OPERATION_NOT_DEFERRED_KHR = 1000268003, - ERROR_OUT_OF_POOL_MEMORY_KHR = ERROR_OUT_OF_POOL_MEMORY, - ERROR_INVALID_EXTERNAL_HANDLE_KHR = ERROR_INVALID_EXTERNAL_HANDLE, - ERROR_FRAGMENTATION_EXT = ERROR_FRAGMENTATION, - ERROR_NOT_PERMITTED_EXT = ERROR_NOT_PERMITTED_KHR, - ERROR_INVALID_DEVICE_ADDRESS_EXT = ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS, - ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS_KHR = ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS, - PIPELINE_COMPILE_REQUIRED_EXT = PIPELINE_COMPILE_REQUIRED, - ERROR_PIPELINE_COMPILE_REQUIRED_EXT = PIPELINE_COMPILE_REQUIRED, -} - -SampleCountFlags :: distinct bit_set[SampleCountFlag; Flags] -SampleCountFlag :: enum Flags { - _1 = 0, - _2 = 1, - _4 = 2, - _8 = 3, - _16 = 4, - _32 = 5, - _64 = 6, -} - -SamplerAddressMode :: enum c.int { - REPEAT = 0, - MIRRORED_REPEAT = 1, - CLAMP_TO_EDGE = 2, - CLAMP_TO_BORDER = 3, - MIRROR_CLAMP_TO_EDGE = 4, - MIRROR_CLAMP_TO_EDGE_KHR = MIRROR_CLAMP_TO_EDGE, -} - -SamplerCreateFlags :: distinct bit_set[SamplerCreateFlag; Flags] -SamplerCreateFlag :: enum Flags { - SUBSAMPLED_EXT = 0, - SUBSAMPLED_COARSE_RECONSTRUCTION_EXT = 1, -} - -SamplerMipmapMode :: enum c.int { - NEAREST = 0, - LINEAR = 1, -} - -SamplerReductionMode :: enum c.int { - WEIGHTED_AVERAGE = 0, - MIN = 1, - MAX = 2, - WEIGHTED_AVERAGE_EXT = WEIGHTED_AVERAGE, - MIN_EXT = MIN, - MAX_EXT = MAX, -} - -SamplerYcbcrModelConversion :: enum c.int { - RGB_IDENTITY = 0, - YCBCR_IDENTITY = 1, - YCBCR_709 = 2, - YCBCR_601 = 3, - YCBCR_2020 = 4, - RGB_IDENTITY_KHR = RGB_IDENTITY, - YCBCR_IDENTITY_KHR = YCBCR_IDENTITY, - YCBCR_709_KHR = YCBCR_709, - YCBCR_601_KHR = YCBCR_601, - YCBCR_2020_KHR = YCBCR_2020, -} - -SamplerYcbcrRange :: enum c.int { - ITU_FULL = 0, - ITU_NARROW = 1, - ITU_FULL_KHR = ITU_FULL, - ITU_NARROW_KHR = ITU_NARROW, -} - -ScopeNV :: enum c.int { - DEVICE = 1, - WORKGROUP = 2, - SUBGROUP = 3, - QUEUE_FAMILY = 5, -} - -SemaphoreImportFlags :: distinct bit_set[SemaphoreImportFlag; Flags] -SemaphoreImportFlag :: enum Flags { - TEMPORARY = 0, - TEMPORARY_KHR = TEMPORARY, -} - -SemaphoreType :: enum c.int { - BINARY = 0, - TIMELINE = 1, - BINARY_KHR = BINARY, - TIMELINE_KHR = TIMELINE, -} - -SemaphoreWaitFlags :: distinct bit_set[SemaphoreWaitFlag; Flags] -SemaphoreWaitFlag :: enum Flags { - ANY = 0, - ANY_KHR = ANY, -} - -ShaderCorePropertiesFlagsAMD :: distinct bit_set[ShaderCorePropertiesFlagAMD; Flags] -ShaderCorePropertiesFlagAMD :: enum Flags { -} - -ShaderFloatControlsIndependence :: enum c.int { - _32_BIT_ONLY = 0, - ALL = 1, - NONE = 2, - _32_BIT_ONLY_KHR = _32_BIT_ONLY, - ALL_KHR = ALL, -} - -ShaderGroupShaderKHR :: enum c.int { - GENERAL = 0, - CLOSEST_HIT = 1, - ANY_HIT = 2, - INTERSECTION = 3, -} - -ShaderInfoTypeAMD :: enum c.int { - STATISTICS = 0, - BINARY = 1, - DISASSEMBLY = 2, -} - -ShaderStageFlags :: distinct bit_set[ShaderStageFlag; Flags] -ShaderStageFlag :: enum Flags { - VERTEX = 0, - TESSELLATION_CONTROL = 1, - TESSELLATION_EVALUATION = 2, - GEOMETRY = 3, - FRAGMENT = 4, - COMPUTE = 5, - RAYGEN_KHR = 8, - ANY_HIT_KHR = 9, - CLOSEST_HIT_KHR = 10, - MISS_KHR = 11, - INTERSECTION_KHR = 12, - CALLABLE_KHR = 13, - TASK_NV = 6, - MESH_NV = 7, - SUBPASS_SHADING_HUAWEI = 14, - RAYGEN_NV = RAYGEN_KHR, - ANY_HIT_NV = ANY_HIT_KHR, - CLOSEST_HIT_NV = CLOSEST_HIT_KHR, - MISS_NV = MISS_KHR, - INTERSECTION_NV = INTERSECTION_KHR, - CALLABLE_NV = CALLABLE_KHR, - _MAX = 31, // Needed for the *_ALL bit set -} - -ShaderStageFlags_ALL_GRAPHICS :: ShaderStageFlags{.VERTEX, .TESSELLATION_CONTROL, .TESSELLATION_EVALUATION, .GEOMETRY, .FRAGMENT} -ShaderStageFlags_ALL :: ShaderStageFlags{.VERTEX, .TESSELLATION_CONTROL, .TESSELLATION_EVALUATION, .GEOMETRY, .FRAGMENT, .COMPUTE, .TASK_NV, .MESH_NV, .RAYGEN_KHR, .ANY_HIT_KHR, .CLOSEST_HIT_KHR, .MISS_KHR, .INTERSECTION_KHR, .CALLABLE_KHR, .SUBPASS_SHADING_HUAWEI, ShaderStageFlag(15), ShaderStageFlag(16), ShaderStageFlag(17), ShaderStageFlag(18), ShaderStageFlag(19), ShaderStageFlag(20), ShaderStageFlag(21), ShaderStageFlag(22), ShaderStageFlag(23), ShaderStageFlag(24), ShaderStageFlag(25), ShaderStageFlag(26), ShaderStageFlag(27), ShaderStageFlag(28), ShaderStageFlag(29), ShaderStageFlag(30)} - - -ShadingRatePaletteEntryNV :: enum c.int { - NO_INVOCATIONS = 0, - _16_INVOCATIONS_PER_PIXEL = 1, - _8_INVOCATIONS_PER_PIXEL = 2, - _4_INVOCATIONS_PER_PIXEL = 3, - _2_INVOCATIONS_PER_PIXEL = 4, - _1_INVOCATION_PER_PIXEL = 5, - _1_INVOCATION_PER_2X1_PIXELS = 6, - _1_INVOCATION_PER_1X2_PIXELS = 7, - _1_INVOCATION_PER_2X2_PIXELS = 8, - _1_INVOCATION_PER_4X2_PIXELS = 9, - _1_INVOCATION_PER_2X4_PIXELS = 10, - _1_INVOCATION_PER_4X4_PIXELS = 11, -} - -SharingMode :: enum c.int { - EXCLUSIVE = 0, - CONCURRENT = 1, -} - -SparseImageFormatFlags :: distinct bit_set[SparseImageFormatFlag; Flags] -SparseImageFormatFlag :: enum Flags { - SINGLE_MIPTAIL = 0, - ALIGNED_MIP_SIZE = 1, - NONSTANDARD_BLOCK_SIZE = 2, -} - -SparseMemoryBindFlags :: distinct bit_set[SparseMemoryBindFlag; Flags] -SparseMemoryBindFlag :: enum Flags { - METADATA = 0, -} - -StencilFaceFlags :: distinct bit_set[StencilFaceFlag; Flags] -StencilFaceFlag :: enum Flags { - FRONT = 0, - BACK = 1, -} - -StencilFaceFlags_FRONT_AND_BACK :: StencilFaceFlags{.FRONT, .BACK} - - -StencilOp :: enum c.int { - KEEP = 0, - ZERO = 1, - REPLACE = 2, - INCREMENT_AND_CLAMP = 3, - DECREMENT_AND_CLAMP = 4, - INVERT = 5, - INCREMENT_AND_WRAP = 6, - DECREMENT_AND_WRAP = 7, -} - -StructureType :: enum c.int { - APPLICATION_INFO = 0, - INSTANCE_CREATE_INFO = 1, - DEVICE_QUEUE_CREATE_INFO = 2, - DEVICE_CREATE_INFO = 3, - SUBMIT_INFO = 4, - MEMORY_ALLOCATE_INFO = 5, - MAPPED_MEMORY_RANGE = 6, - BIND_SPARSE_INFO = 7, - FENCE_CREATE_INFO = 8, - SEMAPHORE_CREATE_INFO = 9, - EVENT_CREATE_INFO = 10, - QUERY_POOL_CREATE_INFO = 11, - BUFFER_CREATE_INFO = 12, - BUFFER_VIEW_CREATE_INFO = 13, - IMAGE_CREATE_INFO = 14, - IMAGE_VIEW_CREATE_INFO = 15, - SHADER_MODULE_CREATE_INFO = 16, - PIPELINE_CACHE_CREATE_INFO = 17, - PIPELINE_SHADER_STAGE_CREATE_INFO = 18, - PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO = 19, - PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO = 20, - PIPELINE_TESSELLATION_STATE_CREATE_INFO = 21, - PIPELINE_VIEWPORT_STATE_CREATE_INFO = 22, - PIPELINE_RASTERIZATION_STATE_CREATE_INFO = 23, - PIPELINE_MULTISAMPLE_STATE_CREATE_INFO = 24, - PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO = 25, - PIPELINE_COLOR_BLEND_STATE_CREATE_INFO = 26, - PIPELINE_DYNAMIC_STATE_CREATE_INFO = 27, - GRAPHICS_PIPELINE_CREATE_INFO = 28, - COMPUTE_PIPELINE_CREATE_INFO = 29, - PIPELINE_LAYOUT_CREATE_INFO = 30, - SAMPLER_CREATE_INFO = 31, - DESCRIPTOR_SET_LAYOUT_CREATE_INFO = 32, - DESCRIPTOR_POOL_CREATE_INFO = 33, - DESCRIPTOR_SET_ALLOCATE_INFO = 34, - WRITE_DESCRIPTOR_SET = 35, - COPY_DESCRIPTOR_SET = 36, - FRAMEBUFFER_CREATE_INFO = 37, - RENDER_PASS_CREATE_INFO = 38, - COMMAND_POOL_CREATE_INFO = 39, - COMMAND_BUFFER_ALLOCATE_INFO = 40, - COMMAND_BUFFER_INHERITANCE_INFO = 41, - COMMAND_BUFFER_BEGIN_INFO = 42, - RENDER_PASS_BEGIN_INFO = 43, - BUFFER_MEMORY_BARRIER = 44, - IMAGE_MEMORY_BARRIER = 45, - MEMORY_BARRIER = 46, - LOADER_INSTANCE_CREATE_INFO = 47, - LOADER_DEVICE_CREATE_INFO = 48, - PHYSICAL_DEVICE_SUBGROUP_PROPERTIES = 1000094000, - BIND_BUFFER_MEMORY_INFO = 1000157000, - BIND_IMAGE_MEMORY_INFO = 1000157001, - PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES = 1000083000, - MEMORY_DEDICATED_REQUIREMENTS = 1000127000, - MEMORY_DEDICATED_ALLOCATE_INFO = 1000127001, - MEMORY_ALLOCATE_FLAGS_INFO = 1000060000, - DEVICE_GROUP_RENDER_PASS_BEGIN_INFO = 1000060003, - DEVICE_GROUP_COMMAND_BUFFER_BEGIN_INFO = 1000060004, - DEVICE_GROUP_SUBMIT_INFO = 1000060005, - DEVICE_GROUP_BIND_SPARSE_INFO = 1000060006, - BIND_BUFFER_MEMORY_DEVICE_GROUP_INFO = 1000060013, - BIND_IMAGE_MEMORY_DEVICE_GROUP_INFO = 1000060014, - PHYSICAL_DEVICE_GROUP_PROPERTIES = 1000070000, - DEVICE_GROUP_DEVICE_CREATE_INFO = 1000070001, - BUFFER_MEMORY_REQUIREMENTS_INFO_2 = 1000146000, - IMAGE_MEMORY_REQUIREMENTS_INFO_2 = 1000146001, - IMAGE_SPARSE_MEMORY_REQUIREMENTS_INFO_2 = 1000146002, - MEMORY_REQUIREMENTS_2 = 1000146003, - SPARSE_IMAGE_MEMORY_REQUIREMENTS_2 = 1000146004, - PHYSICAL_DEVICE_FEATURES_2 = 1000059000, - PHYSICAL_DEVICE_PROPERTIES_2 = 1000059001, - FORMAT_PROPERTIES_2 = 1000059002, - IMAGE_FORMAT_PROPERTIES_2 = 1000059003, - PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2 = 1000059004, - QUEUE_FAMILY_PROPERTIES_2 = 1000059005, - PHYSICAL_DEVICE_MEMORY_PROPERTIES_2 = 1000059006, - SPARSE_IMAGE_FORMAT_PROPERTIES_2 = 1000059007, - PHYSICAL_DEVICE_SPARSE_IMAGE_FORMAT_INFO_2 = 1000059008, - PHYSICAL_DEVICE_POINT_CLIPPING_PROPERTIES = 1000117000, - RENDER_PASS_INPUT_ATTACHMENT_ASPECT_CREATE_INFO = 1000117001, - IMAGE_VIEW_USAGE_CREATE_INFO = 1000117002, - PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO = 1000117003, - RENDER_PASS_MULTIVIEW_CREATE_INFO = 1000053000, - PHYSICAL_DEVICE_MULTIVIEW_FEATURES = 1000053001, - PHYSICAL_DEVICE_MULTIVIEW_PROPERTIES = 1000053002, - PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES = 1000120000, - PROTECTED_SUBMIT_INFO = 1000145000, - PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES = 1000145001, - PHYSICAL_DEVICE_PROTECTED_MEMORY_PROPERTIES = 1000145002, - DEVICE_QUEUE_INFO_2 = 1000145003, - SAMPLER_YCBCR_CONVERSION_CREATE_INFO = 1000156000, - SAMPLER_YCBCR_CONVERSION_INFO = 1000156001, - BIND_IMAGE_PLANE_MEMORY_INFO = 1000156002, - IMAGE_PLANE_MEMORY_REQUIREMENTS_INFO = 1000156003, - PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES = 1000156004, - SAMPLER_YCBCR_CONVERSION_IMAGE_FORMAT_PROPERTIES = 1000156005, - DESCRIPTOR_UPDATE_TEMPLATE_CREATE_INFO = 1000085000, - PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO = 1000071000, - EXTERNAL_IMAGE_FORMAT_PROPERTIES = 1000071001, - PHYSICAL_DEVICE_EXTERNAL_BUFFER_INFO = 1000071002, - EXTERNAL_BUFFER_PROPERTIES = 1000071003, - PHYSICAL_DEVICE_ID_PROPERTIES = 1000071004, - EXTERNAL_MEMORY_BUFFER_CREATE_INFO = 1000072000, - EXTERNAL_MEMORY_IMAGE_CREATE_INFO = 1000072001, - EXPORT_MEMORY_ALLOCATE_INFO = 1000072002, - PHYSICAL_DEVICE_EXTERNAL_FENCE_INFO = 1000112000, - EXTERNAL_FENCE_PROPERTIES = 1000112001, - EXPORT_FENCE_CREATE_INFO = 1000113000, - EXPORT_SEMAPHORE_CREATE_INFO = 1000077000, - PHYSICAL_DEVICE_EXTERNAL_SEMAPHORE_INFO = 1000076000, - EXTERNAL_SEMAPHORE_PROPERTIES = 1000076001, - PHYSICAL_DEVICE_MAINTENANCE_3_PROPERTIES = 1000168000, - DESCRIPTOR_SET_LAYOUT_SUPPORT = 1000168001, - PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES = 1000063000, - PHYSICAL_DEVICE_VULKAN_1_1_FEATURES = 49, - PHYSICAL_DEVICE_VULKAN_1_1_PROPERTIES = 50, - PHYSICAL_DEVICE_VULKAN_1_2_FEATURES = 51, - PHYSICAL_DEVICE_VULKAN_1_2_PROPERTIES = 52, - IMAGE_FORMAT_LIST_CREATE_INFO = 1000147000, - ATTACHMENT_DESCRIPTION_2 = 1000109000, - ATTACHMENT_REFERENCE_2 = 1000109001, - SUBPASS_DESCRIPTION_2 = 1000109002, - SUBPASS_DEPENDENCY_2 = 1000109003, - RENDER_PASS_CREATE_INFO_2 = 1000109004, - SUBPASS_BEGIN_INFO = 1000109005, - SUBPASS_END_INFO = 1000109006, - PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES = 1000177000, - PHYSICAL_DEVICE_DRIVER_PROPERTIES = 1000196000, - PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES = 1000180000, - PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES = 1000082000, - PHYSICAL_DEVICE_FLOAT_CONTROLS_PROPERTIES = 1000197000, - DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO = 1000161000, - PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES = 1000161001, - PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_PROPERTIES = 1000161002, - DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_ALLOCATE_INFO = 1000161003, - DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_LAYOUT_SUPPORT = 1000161004, - PHYSICAL_DEVICE_DEPTH_STENCIL_RESOLVE_PROPERTIES = 1000199000, - SUBPASS_DESCRIPTION_DEPTH_STENCIL_RESOLVE = 1000199001, - PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES = 1000221000, - IMAGE_STENCIL_USAGE_CREATE_INFO = 1000246000, - PHYSICAL_DEVICE_SAMPLER_FILTER_MINMAX_PROPERTIES = 1000130000, - SAMPLER_REDUCTION_MODE_CREATE_INFO = 1000130001, - PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES = 1000211000, - PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES = 1000108000, - FRAMEBUFFER_ATTACHMENTS_CREATE_INFO = 1000108001, - FRAMEBUFFER_ATTACHMENT_IMAGE_INFO = 1000108002, - RENDER_PASS_ATTACHMENT_BEGIN_INFO = 1000108003, - PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES = 1000253000, - PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES = 1000175000, - PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES = 1000241000, - ATTACHMENT_REFERENCE_STENCIL_LAYOUT = 1000241001, - ATTACHMENT_DESCRIPTION_STENCIL_LAYOUT = 1000241002, - PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES = 1000261000, - PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES = 1000207000, - PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_PROPERTIES = 1000207001, - SEMAPHORE_TYPE_CREATE_INFO = 1000207002, - TIMELINE_SEMAPHORE_SUBMIT_INFO = 1000207003, - SEMAPHORE_WAIT_INFO = 1000207004, - SEMAPHORE_SIGNAL_INFO = 1000207005, - PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES = 1000257000, - BUFFER_DEVICE_ADDRESS_INFO = 1000244001, - BUFFER_OPAQUE_CAPTURE_ADDRESS_CREATE_INFO = 1000257002, - MEMORY_OPAQUE_CAPTURE_ADDRESS_ALLOCATE_INFO = 1000257003, - DEVICE_MEMORY_OPAQUE_CAPTURE_ADDRESS_INFO = 1000257004, - PHYSICAL_DEVICE_VULKAN_1_3_FEATURES = 53, - PHYSICAL_DEVICE_VULKAN_1_3_PROPERTIES = 54, - PIPELINE_CREATION_FEEDBACK_CREATE_INFO = 1000192000, - PHYSICAL_DEVICE_SHADER_TERMINATE_INVOCATION_FEATURES = 1000215000, - PHYSICAL_DEVICE_TOOL_PROPERTIES = 1000245000, - PHYSICAL_DEVICE_SHADER_DEMOTE_TO_HELPER_INVOCATION_FEATURES = 1000276000, - PHYSICAL_DEVICE_PRIVATE_DATA_FEATURES = 1000295000, - DEVICE_PRIVATE_DATA_CREATE_INFO = 1000295001, - PRIVATE_DATA_SLOT_CREATE_INFO = 1000295002, - PHYSICAL_DEVICE_PIPELINE_CREATION_CACHE_CONTROL_FEATURES = 1000297000, - MEMORY_BARRIER_2 = 1000314000, - BUFFER_MEMORY_BARRIER_2 = 1000314001, - IMAGE_MEMORY_BARRIER_2 = 1000314002, - DEPENDENCY_INFO = 1000314003, - SUBMIT_INFO_2 = 1000314004, - SEMAPHORE_SUBMIT_INFO = 1000314005, - COMMAND_BUFFER_SUBMIT_INFO = 1000314006, - PHYSICAL_DEVICE_SYNCHRONIZATION_2_FEATURES = 1000314007, - PHYSICAL_DEVICE_ZERO_INITIALIZE_WORKGROUP_MEMORY_FEATURES = 1000325000, - PHYSICAL_DEVICE_IMAGE_ROBUSTNESS_FEATURES = 1000335000, - COPY_BUFFER_INFO_2 = 1000337000, - COPY_IMAGE_INFO_2 = 1000337001, - COPY_BUFFER_TO_IMAGE_INFO_2 = 1000337002, - COPY_IMAGE_TO_BUFFER_INFO_2 = 1000337003, - BLIT_IMAGE_INFO_2 = 1000337004, - RESOLVE_IMAGE_INFO_2 = 1000337005, - BUFFER_COPY_2 = 1000337006, - IMAGE_COPY_2 = 1000337007, - IMAGE_BLIT_2 = 1000337008, - BUFFER_IMAGE_COPY_2 = 1000337009, - IMAGE_RESOLVE_2 = 1000337010, - PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_PROPERTIES = 1000225000, - PIPELINE_SHADER_STAGE_REQUIRED_SUBGROUP_SIZE_CREATE_INFO = 1000225001, - PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_FEATURES = 1000225002, - PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_FEATURES = 1000138000, - PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_PROPERTIES = 1000138001, - WRITE_DESCRIPTOR_SET_INLINE_UNIFORM_BLOCK = 1000138002, - DESCRIPTOR_POOL_INLINE_UNIFORM_BLOCK_CREATE_INFO = 1000138003, - PHYSICAL_DEVICE_TEXTURE_COMPRESSION_ASTC_HDR_FEATURES = 1000066000, - RENDERING_INFO = 1000044000, - RENDERING_ATTACHMENT_INFO = 1000044001, - PIPELINE_RENDERING_CREATE_INFO = 1000044002, - PHYSICAL_DEVICE_DYNAMIC_RENDERING_FEATURES = 1000044003, - COMMAND_BUFFER_INHERITANCE_RENDERING_INFO = 1000044004, - PHYSICAL_DEVICE_SHADER_INTEGER_DOT_PRODUCT_FEATURES = 1000280000, - PHYSICAL_DEVICE_SHADER_INTEGER_DOT_PRODUCT_PROPERTIES = 1000280001, - PHYSICAL_DEVICE_TEXEL_BUFFER_ALIGNMENT_PROPERTIES = 1000281001, - FORMAT_PROPERTIES_3 = 1000360000, - PHYSICAL_DEVICE_MAINTENANCE_4_FEATURES = 1000413000, - PHYSICAL_DEVICE_MAINTENANCE_4_PROPERTIES = 1000413001, - DEVICE_BUFFER_MEMORY_REQUIREMENTS = 1000413002, - DEVICE_IMAGE_MEMORY_REQUIREMENTS = 1000413003, - SWAPCHAIN_CREATE_INFO_KHR = 1000001000, - PRESENT_INFO_KHR = 1000001001, - DEVICE_GROUP_PRESENT_CAPABILITIES_KHR = 1000060007, - IMAGE_SWAPCHAIN_CREATE_INFO_KHR = 1000060008, - BIND_IMAGE_MEMORY_SWAPCHAIN_INFO_KHR = 1000060009, - ACQUIRE_NEXT_IMAGE_INFO_KHR = 1000060010, - DEVICE_GROUP_PRESENT_INFO_KHR = 1000060011, - DEVICE_GROUP_SWAPCHAIN_CREATE_INFO_KHR = 1000060012, - DISPLAY_MODE_CREATE_INFO_KHR = 1000002000, - DISPLAY_SURFACE_CREATE_INFO_KHR = 1000002001, - DISPLAY_PRESENT_INFO_KHR = 1000003000, - XLIB_SURFACE_CREATE_INFO_KHR = 1000004000, - XCB_SURFACE_CREATE_INFO_KHR = 1000005000, - WAYLAND_SURFACE_CREATE_INFO_KHR = 1000006000, - ANDROID_SURFACE_CREATE_INFO_KHR = 1000008000, - WIN32_SURFACE_CREATE_INFO_KHR = 1000009000, - DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT = 1000011000, - PIPELINE_RASTERIZATION_STATE_RASTERIZATION_ORDER_AMD = 1000018000, - DEBUG_MARKER_OBJECT_NAME_INFO_EXT = 1000022000, - DEBUG_MARKER_OBJECT_TAG_INFO_EXT = 1000022001, - DEBUG_MARKER_MARKER_INFO_EXT = 1000022002, - VIDEO_PROFILE_KHR = 1000023000, - VIDEO_CAPABILITIES_KHR = 1000023001, - VIDEO_PICTURE_RESOURCE_KHR = 1000023002, - VIDEO_GET_MEMORY_PROPERTIES_KHR = 1000023003, - VIDEO_BIND_MEMORY_KHR = 1000023004, - VIDEO_SESSION_CREATE_INFO_KHR = 1000023005, - VIDEO_SESSION_PARAMETERS_CREATE_INFO_KHR = 1000023006, - VIDEO_SESSION_PARAMETERS_UPDATE_INFO_KHR = 1000023007, - VIDEO_BEGIN_CODING_INFO_KHR = 1000023008, - VIDEO_END_CODING_INFO_KHR = 1000023009, - VIDEO_CODING_CONTROL_INFO_KHR = 1000023010, - VIDEO_REFERENCE_SLOT_KHR = 1000023011, - VIDEO_QUEUE_FAMILY_PROPERTIES_2_KHR = 1000023012, - VIDEO_PROFILES_KHR = 1000023013, - PHYSICAL_DEVICE_VIDEO_FORMAT_INFO_KHR = 1000023014, - VIDEO_FORMAT_PROPERTIES_KHR = 1000023015, - QUEUE_FAMILY_QUERY_RESULT_STATUS_PROPERTIES_2_KHR = 1000023016, - VIDEO_DECODE_INFO_KHR = 1000024000, - VIDEO_DECODE_CAPABILITIES_KHR = 1000024001, - DEDICATED_ALLOCATION_IMAGE_CREATE_INFO_NV = 1000026000, - DEDICATED_ALLOCATION_BUFFER_CREATE_INFO_NV = 1000026001, - DEDICATED_ALLOCATION_MEMORY_ALLOCATE_INFO_NV = 1000026002, - PHYSICAL_DEVICE_TRANSFORM_FEEDBACK_FEATURES_EXT = 1000028000, - PHYSICAL_DEVICE_TRANSFORM_FEEDBACK_PROPERTIES_EXT = 1000028001, - PIPELINE_RASTERIZATION_STATE_STREAM_CREATE_INFO_EXT = 1000028002, - CU_MODULE_CREATE_INFO_NVX = 1000029000, - CU_FUNCTION_CREATE_INFO_NVX = 1000029001, - CU_LAUNCH_INFO_NVX = 1000029002, - IMAGE_VIEW_HANDLE_INFO_NVX = 1000030000, - IMAGE_VIEW_ADDRESS_PROPERTIES_NVX = 1000030001, - VIDEO_ENCODE_H264_CAPABILITIES_EXT = 1000038000, - VIDEO_ENCODE_H264_SESSION_PARAMETERS_CREATE_INFO_EXT = 1000038001, - VIDEO_ENCODE_H264_SESSION_PARAMETERS_ADD_INFO_EXT = 1000038002, - VIDEO_ENCODE_H264_VCL_FRAME_INFO_EXT = 1000038003, - VIDEO_ENCODE_H264_DPB_SLOT_INFO_EXT = 1000038004, - VIDEO_ENCODE_H264_NALU_SLICE_EXT = 1000038005, - VIDEO_ENCODE_H264_EMIT_PICTURE_PARAMETERS_EXT = 1000038006, - VIDEO_ENCODE_H264_PROFILE_EXT = 1000038007, - VIDEO_ENCODE_H264_RATE_CONTROL_INFO_EXT = 1000038008, - VIDEO_ENCODE_H264_RATE_CONTROL_LAYER_INFO_EXT = 1000038009, - VIDEO_ENCODE_H264_REFERENCE_LISTS_EXT = 1000038010, - VIDEO_ENCODE_H265_CAPABILITIES_EXT = 1000039000, - VIDEO_ENCODE_H265_SESSION_PARAMETERS_CREATE_INFO_EXT = 1000039001, - VIDEO_ENCODE_H265_SESSION_PARAMETERS_ADD_INFO_EXT = 1000039002, - VIDEO_ENCODE_H265_VCL_FRAME_INFO_EXT = 1000039003, - VIDEO_ENCODE_H265_DPB_SLOT_INFO_EXT = 1000039004, - VIDEO_ENCODE_H265_NALU_SLICE_SEGMENT_EXT = 1000039005, - VIDEO_ENCODE_H265_EMIT_PICTURE_PARAMETERS_EXT = 1000039006, - VIDEO_ENCODE_H265_PROFILE_EXT = 1000039007, - VIDEO_ENCODE_H265_REFERENCE_LISTS_EXT = 1000039008, - VIDEO_ENCODE_H265_RATE_CONTROL_INFO_EXT = 1000039009, - VIDEO_ENCODE_H265_RATE_CONTROL_LAYER_INFO_EXT = 1000039010, - VIDEO_DECODE_H264_CAPABILITIES_EXT = 1000040000, - VIDEO_DECODE_H264_PICTURE_INFO_EXT = 1000040001, - VIDEO_DECODE_H264_MVC_EXT = 1000040002, - VIDEO_DECODE_H264_PROFILE_EXT = 1000040003, - VIDEO_DECODE_H264_SESSION_PARAMETERS_CREATE_INFO_EXT = 1000040004, - VIDEO_DECODE_H264_SESSION_PARAMETERS_ADD_INFO_EXT = 1000040005, - VIDEO_DECODE_H264_DPB_SLOT_INFO_EXT = 1000040006, - TEXTURE_LOD_GATHER_FORMAT_PROPERTIES_AMD = 1000041000, - RENDERING_FRAGMENT_SHADING_RATE_ATTACHMENT_INFO_KHR = 1000044006, - RENDERING_FRAGMENT_DENSITY_MAP_ATTACHMENT_INFO_EXT = 1000044007, - ATTACHMENT_SAMPLE_COUNT_INFO_AMD = 1000044008, - MULTIVIEW_PER_VIEW_ATTRIBUTES_INFO_NVX = 1000044009, - STREAM_DESCRIPTOR_SURFACE_CREATE_INFO_GGP = 1000049000, - PHYSICAL_DEVICE_CORNER_SAMPLED_IMAGE_FEATURES_NV = 1000050000, - EXTERNAL_MEMORY_IMAGE_CREATE_INFO_NV = 1000056000, - EXPORT_MEMORY_ALLOCATE_INFO_NV = 1000056001, - IMPORT_MEMORY_WIN32_HANDLE_INFO_NV = 1000057000, - EXPORT_MEMORY_WIN32_HANDLE_INFO_NV = 1000057001, - WIN32_KEYED_MUTEX_ACQUIRE_RELEASE_INFO_NV = 1000058000, - VALIDATION_FLAGS_EXT = 1000061000, - VI_SURFACE_CREATE_INFO_NN = 1000062000, - IMAGE_VIEW_ASTC_DECODE_MODE_EXT = 1000067000, - PHYSICAL_DEVICE_ASTC_DECODE_FEATURES_EXT = 1000067001, - IMPORT_MEMORY_WIN32_HANDLE_INFO_KHR = 1000073000, - EXPORT_MEMORY_WIN32_HANDLE_INFO_KHR = 1000073001, - MEMORY_WIN32_HANDLE_PROPERTIES_KHR = 1000073002, - MEMORY_GET_WIN32_HANDLE_INFO_KHR = 1000073003, - IMPORT_MEMORY_FD_INFO_KHR = 1000074000, - MEMORY_FD_PROPERTIES_KHR = 1000074001, - MEMORY_GET_FD_INFO_KHR = 1000074002, - WIN32_KEYED_MUTEX_ACQUIRE_RELEASE_INFO_KHR = 1000075000, - IMPORT_SEMAPHORE_WIN32_HANDLE_INFO_KHR = 1000078000, - EXPORT_SEMAPHORE_WIN32_HANDLE_INFO_KHR = 1000078001, - D3D12_FENCE_SUBMIT_INFO_KHR = 1000078002, - SEMAPHORE_GET_WIN32_HANDLE_INFO_KHR = 1000078003, - IMPORT_SEMAPHORE_FD_INFO_KHR = 1000079000, - SEMAPHORE_GET_FD_INFO_KHR = 1000079001, - PHYSICAL_DEVICE_PUSH_DESCRIPTOR_PROPERTIES_KHR = 1000080000, - COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT = 1000081000, - PHYSICAL_DEVICE_CONDITIONAL_RENDERING_FEATURES_EXT = 1000081001, - CONDITIONAL_RENDERING_BEGIN_INFO_EXT = 1000081002, - PRESENT_REGIONS_KHR = 1000084000, - PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV = 1000087000, - SURFACE_CAPABILITIES_2_EXT = 1000090000, - DISPLAY_POWER_INFO_EXT = 1000091000, - DEVICE_EVENT_INFO_EXT = 1000091001, - DISPLAY_EVENT_INFO_EXT = 1000091002, - SWAPCHAIN_COUNTER_CREATE_INFO_EXT = 1000091003, - PRESENT_TIMES_INFO_GOOGLE = 1000092000, - PHYSICAL_DEVICE_MULTIVIEW_PER_VIEW_ATTRIBUTES_PROPERTIES_NVX = 1000097000, - PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV = 1000098000, - PHYSICAL_DEVICE_DISCARD_RECTANGLE_PROPERTIES_EXT = 1000099000, - PIPELINE_DISCARD_RECTANGLE_STATE_CREATE_INFO_EXT = 1000099001, - PHYSICAL_DEVICE_CONSERVATIVE_RASTERIZATION_PROPERTIES_EXT = 1000101000, - PIPELINE_RASTERIZATION_CONSERVATIVE_STATE_CREATE_INFO_EXT = 1000101001, - PHYSICAL_DEVICE_DEPTH_CLIP_ENABLE_FEATURES_EXT = 1000102000, - PIPELINE_RASTERIZATION_DEPTH_CLIP_STATE_CREATE_INFO_EXT = 1000102001, - HDR_METADATA_EXT = 1000105000, - SHARED_PRESENT_SURFACE_CAPABILITIES_KHR = 1000111000, - IMPORT_FENCE_WIN32_HANDLE_INFO_KHR = 1000114000, - EXPORT_FENCE_WIN32_HANDLE_INFO_KHR = 1000114001, - FENCE_GET_WIN32_HANDLE_INFO_KHR = 1000114002, - IMPORT_FENCE_FD_INFO_KHR = 1000115000, - FENCE_GET_FD_INFO_KHR = 1000115001, - PHYSICAL_DEVICE_PERFORMANCE_QUERY_FEATURES_KHR = 1000116000, - PHYSICAL_DEVICE_PERFORMANCE_QUERY_PROPERTIES_KHR = 1000116001, - QUERY_POOL_PERFORMANCE_CREATE_INFO_KHR = 1000116002, - PERFORMANCE_QUERY_SUBMIT_INFO_KHR = 1000116003, - ACQUIRE_PROFILING_LOCK_INFO_KHR = 1000116004, - PERFORMANCE_COUNTER_KHR = 1000116005, - PERFORMANCE_COUNTER_DESCRIPTION_KHR = 1000116006, - PHYSICAL_DEVICE_SURFACE_INFO_2_KHR = 1000119000, - SURFACE_CAPABILITIES_2_KHR = 1000119001, - SURFACE_FORMAT_2_KHR = 1000119002, - DISPLAY_PROPERTIES_2_KHR = 1000121000, - DISPLAY_PLANE_PROPERTIES_2_KHR = 1000121001, - DISPLAY_MODE_PROPERTIES_2_KHR = 1000121002, - DISPLAY_PLANE_INFO_2_KHR = 1000121003, - DISPLAY_PLANE_CAPABILITIES_2_KHR = 1000121004, - IOS_SURFACE_CREATE_INFO_MVK = 1000122000, - MACOS_SURFACE_CREATE_INFO_MVK = 1000123000, - DEBUG_UTILS_OBJECT_NAME_INFO_EXT = 1000128000, - DEBUG_UTILS_OBJECT_TAG_INFO_EXT = 1000128001, - DEBUG_UTILS_LABEL_EXT = 1000128002, - DEBUG_UTILS_MESSENGER_CALLBACK_DATA_EXT = 1000128003, - DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT = 1000128004, - ANDROID_HARDWARE_BUFFER_USAGE_ANDROID = 1000129000, - ANDROID_HARDWARE_BUFFER_PROPERTIES_ANDROID = 1000129001, - ANDROID_HARDWARE_BUFFER_FORMAT_PROPERTIES_ANDROID = 1000129002, - IMPORT_ANDROID_HARDWARE_BUFFER_INFO_ANDROID = 1000129003, - MEMORY_GET_ANDROID_HARDWARE_BUFFER_INFO_ANDROID = 1000129004, - EXTERNAL_FORMAT_ANDROID = 1000129005, - ANDROID_HARDWARE_BUFFER_FORMAT_PROPERTIES_2_ANDROID = 1000129006, - SAMPLE_LOCATIONS_INFO_EXT = 1000143000, - RENDER_PASS_SAMPLE_LOCATIONS_BEGIN_INFO_EXT = 1000143001, - PIPELINE_SAMPLE_LOCATIONS_STATE_CREATE_INFO_EXT = 1000143002, - PHYSICAL_DEVICE_SAMPLE_LOCATIONS_PROPERTIES_EXT = 1000143003, - MULTISAMPLE_PROPERTIES_EXT = 1000143004, - PHYSICAL_DEVICE_BLEND_OPERATION_ADVANCED_FEATURES_EXT = 1000148000, - PHYSICAL_DEVICE_BLEND_OPERATION_ADVANCED_PROPERTIES_EXT = 1000148001, - PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT = 1000148002, - PIPELINE_COVERAGE_TO_COLOR_STATE_CREATE_INFO_NV = 1000149000, - WRITE_DESCRIPTOR_SET_ACCELERATION_STRUCTURE_KHR = 1000150007, - ACCELERATION_STRUCTURE_BUILD_GEOMETRY_INFO_KHR = 1000150000, - ACCELERATION_STRUCTURE_DEVICE_ADDRESS_INFO_KHR = 1000150002, - ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR = 1000150003, - ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR = 1000150004, - ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR = 1000150005, - ACCELERATION_STRUCTURE_GEOMETRY_KHR = 1000150006, - ACCELERATION_STRUCTURE_VERSION_INFO_KHR = 1000150009, - COPY_ACCELERATION_STRUCTURE_INFO_KHR = 1000150010, - COPY_ACCELERATION_STRUCTURE_TO_MEMORY_INFO_KHR = 1000150011, - COPY_MEMORY_TO_ACCELERATION_STRUCTURE_INFO_KHR = 1000150012, - PHYSICAL_DEVICE_ACCELERATION_STRUCTURE_FEATURES_KHR = 1000150013, - PHYSICAL_DEVICE_ACCELERATION_STRUCTURE_PROPERTIES_KHR = 1000150014, - ACCELERATION_STRUCTURE_CREATE_INFO_KHR = 1000150017, - ACCELERATION_STRUCTURE_BUILD_SIZES_INFO_KHR = 1000150020, - PHYSICAL_DEVICE_RAY_TRACING_PIPELINE_FEATURES_KHR = 1000347000, - PHYSICAL_DEVICE_RAY_TRACING_PIPELINE_PROPERTIES_KHR = 1000347001, - RAY_TRACING_PIPELINE_CREATE_INFO_KHR = 1000150015, - RAY_TRACING_SHADER_GROUP_CREATE_INFO_KHR = 1000150016, - RAY_TRACING_PIPELINE_INTERFACE_CREATE_INFO_KHR = 1000150018, - PHYSICAL_DEVICE_RAY_QUERY_FEATURES_KHR = 1000348013, - PIPELINE_COVERAGE_MODULATION_STATE_CREATE_INFO_NV = 1000152000, - PHYSICAL_DEVICE_SHADER_SM_BUILTINS_FEATURES_NV = 1000154000, - PHYSICAL_DEVICE_SHADER_SM_BUILTINS_PROPERTIES_NV = 1000154001, - DRM_FORMAT_MODIFIER_PROPERTIES_LIST_EXT = 1000158000, - PHYSICAL_DEVICE_IMAGE_DRM_FORMAT_MODIFIER_INFO_EXT = 1000158002, - IMAGE_DRM_FORMAT_MODIFIER_LIST_CREATE_INFO_EXT = 1000158003, - IMAGE_DRM_FORMAT_MODIFIER_EXPLICIT_CREATE_INFO_EXT = 1000158004, - IMAGE_DRM_FORMAT_MODIFIER_PROPERTIES_EXT = 1000158005, - DRM_FORMAT_MODIFIER_PROPERTIES_LIST_2_EXT = 1000158006, - VALIDATION_CACHE_CREATE_INFO_EXT = 1000160000, - SHADER_MODULE_VALIDATION_CACHE_CREATE_INFO_EXT = 1000160001, - PHYSICAL_DEVICE_PORTABILITY_SUBSET_FEATURES_KHR = 1000163000, - PHYSICAL_DEVICE_PORTABILITY_SUBSET_PROPERTIES_KHR = 1000163001, - PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV = 1000164000, - PHYSICAL_DEVICE_SHADING_RATE_IMAGE_FEATURES_NV = 1000164001, - PHYSICAL_DEVICE_SHADING_RATE_IMAGE_PROPERTIES_NV = 1000164002, - PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV = 1000164005, - RAY_TRACING_PIPELINE_CREATE_INFO_NV = 1000165000, - ACCELERATION_STRUCTURE_CREATE_INFO_NV = 1000165001, - GEOMETRY_NV = 1000165003, - GEOMETRY_TRIANGLES_NV = 1000165004, - GEOMETRY_AABB_NV = 1000165005, - BIND_ACCELERATION_STRUCTURE_MEMORY_INFO_NV = 1000165006, - WRITE_DESCRIPTOR_SET_ACCELERATION_STRUCTURE_NV = 1000165007, - ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_INFO_NV = 1000165008, - PHYSICAL_DEVICE_RAY_TRACING_PROPERTIES_NV = 1000165009, - RAY_TRACING_SHADER_GROUP_CREATE_INFO_NV = 1000165011, - ACCELERATION_STRUCTURE_INFO_NV = 1000165012, - PHYSICAL_DEVICE_REPRESENTATIVE_FRAGMENT_TEST_FEATURES_NV = 1000166000, - PIPELINE_REPRESENTATIVE_FRAGMENT_TEST_STATE_CREATE_INFO_NV = 1000166001, - PHYSICAL_DEVICE_IMAGE_VIEW_IMAGE_FORMAT_INFO_EXT = 1000170000, - FILTER_CUBIC_IMAGE_VIEW_IMAGE_FORMAT_PROPERTIES_EXT = 1000170001, - IMPORT_MEMORY_HOST_POINTER_INFO_EXT = 1000178000, - MEMORY_HOST_POINTER_PROPERTIES_EXT = 1000178001, - PHYSICAL_DEVICE_EXTERNAL_MEMORY_HOST_PROPERTIES_EXT = 1000178002, - PHYSICAL_DEVICE_SHADER_CLOCK_FEATURES_KHR = 1000181000, - PIPELINE_COMPILER_CONTROL_CREATE_INFO_AMD = 1000183000, - CALIBRATED_TIMESTAMP_INFO_EXT = 1000184000, - PHYSICAL_DEVICE_SHADER_CORE_PROPERTIES_AMD = 1000185000, - VIDEO_DECODE_H265_CAPABILITIES_EXT = 1000187000, - VIDEO_DECODE_H265_SESSION_PARAMETERS_CREATE_INFO_EXT = 1000187001, - VIDEO_DECODE_H265_SESSION_PARAMETERS_ADD_INFO_EXT = 1000187002, - VIDEO_DECODE_H265_PROFILE_EXT = 1000187003, - VIDEO_DECODE_H265_PICTURE_INFO_EXT = 1000187004, - VIDEO_DECODE_H265_DPB_SLOT_INFO_EXT = 1000187005, - DEVICE_QUEUE_GLOBAL_PRIORITY_CREATE_INFO_KHR = 1000174000, - PHYSICAL_DEVICE_GLOBAL_PRIORITY_QUERY_FEATURES_KHR = 1000388000, - QUEUE_FAMILY_GLOBAL_PRIORITY_PROPERTIES_KHR = 1000388001, - DEVICE_MEMORY_OVERALLOCATION_CREATE_INFO_AMD = 1000189000, - PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_PROPERTIES_EXT = 1000190000, - PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT = 1000190001, - PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_FEATURES_EXT = 1000190002, - PRESENT_FRAME_TOKEN_GGP = 1000191000, - PHYSICAL_DEVICE_COMPUTE_SHADER_DERIVATIVES_FEATURES_NV = 1000201000, - PHYSICAL_DEVICE_MESH_SHADER_FEATURES_NV = 1000202000, - PHYSICAL_DEVICE_MESH_SHADER_PROPERTIES_NV = 1000202001, - PHYSICAL_DEVICE_FRAGMENT_SHADER_BARYCENTRIC_FEATURES_NV = 1000203000, - PHYSICAL_DEVICE_SHADER_IMAGE_FOOTPRINT_FEATURES_NV = 1000204000, - PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV = 1000205000, - PHYSICAL_DEVICE_EXCLUSIVE_SCISSOR_FEATURES_NV = 1000205002, - CHECKPOINT_DATA_NV = 1000206000, - QUEUE_FAMILY_CHECKPOINT_PROPERTIES_NV = 1000206001, - PHYSICAL_DEVICE_SHADER_INTEGER_FUNCTIONS_2_FEATURES_INTEL = 1000209000, - QUERY_POOL_PERFORMANCE_QUERY_CREATE_INFO_INTEL = 1000210000, - INITIALIZE_PERFORMANCE_API_INFO_INTEL = 1000210001, - PERFORMANCE_MARKER_INFO_INTEL = 1000210002, - PERFORMANCE_STREAM_MARKER_INFO_INTEL = 1000210003, - PERFORMANCE_OVERRIDE_INFO_INTEL = 1000210004, - PERFORMANCE_CONFIGURATION_ACQUIRE_INFO_INTEL = 1000210005, - PHYSICAL_DEVICE_PCI_BUS_INFO_PROPERTIES_EXT = 1000212000, - DISPLAY_NATIVE_HDR_SURFACE_CAPABILITIES_AMD = 1000213000, - SWAPCHAIN_DISPLAY_NATIVE_HDR_CREATE_INFO_AMD = 1000213001, - IMAGEPIPE_SURFACE_CREATE_INFO_FUCHSIA = 1000214000, - METAL_SURFACE_CREATE_INFO_EXT = 1000217000, - PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_FEATURES_EXT = 1000218000, - PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_PROPERTIES_EXT = 1000218001, - RENDER_PASS_FRAGMENT_DENSITY_MAP_CREATE_INFO_EXT = 1000218002, - FRAGMENT_SHADING_RATE_ATTACHMENT_INFO_KHR = 1000226000, - PIPELINE_FRAGMENT_SHADING_RATE_STATE_CREATE_INFO_KHR = 1000226001, - PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_PROPERTIES_KHR = 1000226002, - PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_FEATURES_KHR = 1000226003, - PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_KHR = 1000226004, - PHYSICAL_DEVICE_SHADER_CORE_PROPERTIES_2_AMD = 1000227000, - PHYSICAL_DEVICE_COHERENT_MEMORY_FEATURES_AMD = 1000229000, - PHYSICAL_DEVICE_SHADER_IMAGE_ATOMIC_INT64_FEATURES_EXT = 1000234000, - PHYSICAL_DEVICE_MEMORY_BUDGET_PROPERTIES_EXT = 1000237000, - PHYSICAL_DEVICE_MEMORY_PRIORITY_FEATURES_EXT = 1000238000, - MEMORY_PRIORITY_ALLOCATE_INFO_EXT = 1000238001, - SURFACE_PROTECTED_CAPABILITIES_KHR = 1000239000, - PHYSICAL_DEVICE_DEDICATED_ALLOCATION_IMAGE_ALIASING_FEATURES_NV = 1000240000, - PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES_EXT = 1000244000, - BUFFER_DEVICE_ADDRESS_CREATE_INFO_EXT = 1000244002, - VALIDATION_FEATURES_EXT = 1000247000, - PHYSICAL_DEVICE_PRESENT_WAIT_FEATURES_KHR = 1000248000, - PHYSICAL_DEVICE_COOPERATIVE_MATRIX_FEATURES_NV = 1000249000, - COOPERATIVE_MATRIX_PROPERTIES_NV = 1000249001, - PHYSICAL_DEVICE_COOPERATIVE_MATRIX_PROPERTIES_NV = 1000249002, - PHYSICAL_DEVICE_COVERAGE_REDUCTION_MODE_FEATURES_NV = 1000250000, - PIPELINE_COVERAGE_REDUCTION_STATE_CREATE_INFO_NV = 1000250001, - FRAMEBUFFER_MIXED_SAMPLES_COMBINATION_NV = 1000250002, - PHYSICAL_DEVICE_FRAGMENT_SHADER_INTERLOCK_FEATURES_EXT = 1000251000, - PHYSICAL_DEVICE_YCBCR_IMAGE_ARRAYS_FEATURES_EXT = 1000252000, - PHYSICAL_DEVICE_PROVOKING_VERTEX_FEATURES_EXT = 1000254000, - PIPELINE_RASTERIZATION_PROVOKING_VERTEX_STATE_CREATE_INFO_EXT = 1000254001, - PHYSICAL_DEVICE_PROVOKING_VERTEX_PROPERTIES_EXT = 1000254002, - SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT = 1000255000, - SURFACE_CAPABILITIES_FULL_SCREEN_EXCLUSIVE_EXT = 1000255002, - SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT = 1000255001, - HEADLESS_SURFACE_CREATE_INFO_EXT = 1000256000, - PHYSICAL_DEVICE_LINE_RASTERIZATION_FEATURES_EXT = 1000259000, - PIPELINE_RASTERIZATION_LINE_STATE_CREATE_INFO_EXT = 1000259001, - PHYSICAL_DEVICE_LINE_RASTERIZATION_PROPERTIES_EXT = 1000259002, - PHYSICAL_DEVICE_SHADER_ATOMIC_FLOAT_FEATURES_EXT = 1000260000, - PHYSICAL_DEVICE_INDEX_TYPE_UINT8_FEATURES_EXT = 1000265000, - PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_FEATURES_EXT = 1000267000, - PHYSICAL_DEVICE_PIPELINE_EXECUTABLE_PROPERTIES_FEATURES_KHR = 1000269000, - PIPELINE_INFO_KHR = 1000269001, - PIPELINE_EXECUTABLE_PROPERTIES_KHR = 1000269002, - PIPELINE_EXECUTABLE_INFO_KHR = 1000269003, - PIPELINE_EXECUTABLE_STATISTIC_KHR = 1000269004, - PIPELINE_EXECUTABLE_INTERNAL_REPRESENTATION_KHR = 1000269005, - PHYSICAL_DEVICE_SHADER_ATOMIC_FLOAT_2_FEATURES_EXT = 1000273000, - PHYSICAL_DEVICE_DEVICE_GENERATED_COMMANDS_PROPERTIES_NV = 1000277000, - GRAPHICS_SHADER_GROUP_CREATE_INFO_NV = 1000277001, - GRAPHICS_PIPELINE_SHADER_GROUPS_CREATE_INFO_NV = 1000277002, - INDIRECT_COMMANDS_LAYOUT_TOKEN_NV = 1000277003, - INDIRECT_COMMANDS_LAYOUT_CREATE_INFO_NV = 1000277004, - GENERATED_COMMANDS_INFO_NV = 1000277005, - GENERATED_COMMANDS_MEMORY_REQUIREMENTS_INFO_NV = 1000277006, - PHYSICAL_DEVICE_DEVICE_GENERATED_COMMANDS_FEATURES_NV = 1000277007, - PHYSICAL_DEVICE_INHERITED_VIEWPORT_SCISSOR_FEATURES_NV = 1000278000, - COMMAND_BUFFER_INHERITANCE_VIEWPORT_SCISSOR_INFO_NV = 1000278001, - PHYSICAL_DEVICE_TEXEL_BUFFER_ALIGNMENT_FEATURES_EXT = 1000281000, - COMMAND_BUFFER_INHERITANCE_RENDER_PASS_TRANSFORM_INFO_QCOM = 1000282000, - RENDER_PASS_TRANSFORM_BEGIN_INFO_QCOM = 1000282001, - PHYSICAL_DEVICE_DEVICE_MEMORY_REPORT_FEATURES_EXT = 1000284000, - DEVICE_DEVICE_MEMORY_REPORT_CREATE_INFO_EXT = 1000284001, - DEVICE_MEMORY_REPORT_CALLBACK_DATA_EXT = 1000284002, - PHYSICAL_DEVICE_ROBUSTNESS_2_FEATURES_EXT = 1000286000, - PHYSICAL_DEVICE_ROBUSTNESS_2_PROPERTIES_EXT = 1000286001, - SAMPLER_CUSTOM_BORDER_COLOR_CREATE_INFO_EXT = 1000287000, - PHYSICAL_DEVICE_CUSTOM_BORDER_COLOR_PROPERTIES_EXT = 1000287001, - PHYSICAL_DEVICE_CUSTOM_BORDER_COLOR_FEATURES_EXT = 1000287002, - PIPELINE_LIBRARY_CREATE_INFO_KHR = 1000290000, - PRESENT_ID_KHR = 1000294000, - PHYSICAL_DEVICE_PRESENT_ID_FEATURES_KHR = 1000294001, - VIDEO_ENCODE_INFO_KHR = 1000299000, - VIDEO_ENCODE_RATE_CONTROL_INFO_KHR = 1000299001, - VIDEO_ENCODE_RATE_CONTROL_LAYER_INFO_KHR = 1000299002, - VIDEO_ENCODE_CAPABILITIES_KHR = 1000299003, - PHYSICAL_DEVICE_DIAGNOSTICS_CONFIG_FEATURES_NV = 1000300000, - DEVICE_DIAGNOSTICS_CONFIG_CREATE_INFO_NV = 1000300001, - QUEUE_FAMILY_CHECKPOINT_PROPERTIES_2_NV = 1000314008, - CHECKPOINT_DATA_2_NV = 1000314009, - PHYSICAL_DEVICE_GRAPHICS_PIPELINE_LIBRARY_FEATURES_EXT = 1000320000, - PHYSICAL_DEVICE_GRAPHICS_PIPELINE_LIBRARY_PROPERTIES_EXT = 1000320001, - GRAPHICS_PIPELINE_LIBRARY_CREATE_INFO_EXT = 1000320002, - PHYSICAL_DEVICE_SHADER_SUBGROUP_UNIFORM_CONTROL_FLOW_FEATURES_KHR = 1000323000, - PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_ENUMS_PROPERTIES_NV = 1000326000, - PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_ENUMS_FEATURES_NV = 1000326001, - PIPELINE_FRAGMENT_SHADING_RATE_ENUM_STATE_CREATE_INFO_NV = 1000326002, - ACCELERATION_STRUCTURE_GEOMETRY_MOTION_TRIANGLES_DATA_NV = 1000327000, - PHYSICAL_DEVICE_RAY_TRACING_MOTION_BLUR_FEATURES_NV = 1000327001, - ACCELERATION_STRUCTURE_MOTION_INFO_NV = 1000327002, - PHYSICAL_DEVICE_YCBCR_2_PLANE_444_FORMATS_FEATURES_EXT = 1000330000, - PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_2_FEATURES_EXT = 1000332000, - PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_2_PROPERTIES_EXT = 1000332001, - COPY_COMMAND_TRANSFORM_INFO_QCOM = 1000333000, - PHYSICAL_DEVICE_WORKGROUP_MEMORY_EXPLICIT_LAYOUT_FEATURES_KHR = 1000336000, - PHYSICAL_DEVICE_4444_FORMATS_FEATURES_EXT = 1000340000, - PHYSICAL_DEVICE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_FEATURES_ARM = 1000342000, - PHYSICAL_DEVICE_RGBA10X6_FORMATS_FEATURES_EXT = 1000344000, - DIRECTFB_SURFACE_CREATE_INFO_EXT = 1000346000, - PHYSICAL_DEVICE_MUTABLE_DESCRIPTOR_TYPE_FEATURES_VALVE = 1000351000, - MUTABLE_DESCRIPTOR_TYPE_CREATE_INFO_VALVE = 1000351002, - PHYSICAL_DEVICE_VERTEX_INPUT_DYNAMIC_STATE_FEATURES_EXT = 1000352000, - VERTEX_INPUT_BINDING_DESCRIPTION_2_EXT = 1000352001, - VERTEX_INPUT_ATTRIBUTE_DESCRIPTION_2_EXT = 1000352002, - PHYSICAL_DEVICE_DRM_PROPERTIES_EXT = 1000353000, - PHYSICAL_DEVICE_DEPTH_CLIP_CONTROL_FEATURES_EXT = 1000355000, - PIPELINE_VIEWPORT_DEPTH_CLIP_CONTROL_CREATE_INFO_EXT = 1000355001, - PHYSICAL_DEVICE_PRIMITIVE_TOPOLOGY_LIST_RESTART_FEATURES_EXT = 1000356000, - IMPORT_MEMORY_ZIRCON_HANDLE_INFO_FUCHSIA = 1000364000, - MEMORY_ZIRCON_HANDLE_PROPERTIES_FUCHSIA = 1000364001, - MEMORY_GET_ZIRCON_HANDLE_INFO_FUCHSIA = 1000364002, - IMPORT_SEMAPHORE_ZIRCON_HANDLE_INFO_FUCHSIA = 1000365000, - SEMAPHORE_GET_ZIRCON_HANDLE_INFO_FUCHSIA = 1000365001, - BUFFER_COLLECTION_CREATE_INFO_FUCHSIA = 1000366000, - IMPORT_MEMORY_BUFFER_COLLECTION_FUCHSIA = 1000366001, - BUFFER_COLLECTION_IMAGE_CREATE_INFO_FUCHSIA = 1000366002, - BUFFER_COLLECTION_PROPERTIES_FUCHSIA = 1000366003, - BUFFER_CONSTRAINTS_INFO_FUCHSIA = 1000366004, - BUFFER_COLLECTION_BUFFER_CREATE_INFO_FUCHSIA = 1000366005, - IMAGE_CONSTRAINTS_INFO_FUCHSIA = 1000366006, - IMAGE_FORMAT_CONSTRAINTS_INFO_FUCHSIA = 1000366007, - SYSMEM_COLOR_SPACE_FUCHSIA = 1000366008, - BUFFER_COLLECTION_CONSTRAINTS_INFO_FUCHSIA = 1000366009, - SUBPASS_SHADING_PIPELINE_CREATE_INFO_HUAWEI = 1000369000, - PHYSICAL_DEVICE_SUBPASS_SHADING_FEATURES_HUAWEI = 1000369001, - PHYSICAL_DEVICE_SUBPASS_SHADING_PROPERTIES_HUAWEI = 1000369002, - PHYSICAL_DEVICE_INVOCATION_MASK_FEATURES_HUAWEI = 1000370000, - MEMORY_GET_REMOTE_ADDRESS_INFO_NV = 1000371000, - PHYSICAL_DEVICE_EXTERNAL_MEMORY_RDMA_FEATURES_NV = 1000371001, - PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_2_FEATURES_EXT = 1000377000, - SCREEN_SURFACE_CREATE_INFO_QNX = 1000378000, - PHYSICAL_DEVICE_COLOR_WRITE_ENABLE_FEATURES_EXT = 1000381000, - PIPELINE_COLOR_WRITE_CREATE_INFO_EXT = 1000381001, - PHYSICAL_DEVICE_PRIMITIVES_GENERATED_QUERY_FEATURES_EXT = 1000382000, - PHYSICAL_DEVICE_IMAGE_VIEW_MIN_LOD_FEATURES_EXT = 1000391000, - IMAGE_VIEW_MIN_LOD_CREATE_INFO_EXT = 1000391001, - PHYSICAL_DEVICE_MULTI_DRAW_FEATURES_EXT = 1000392000, - PHYSICAL_DEVICE_MULTI_DRAW_PROPERTIES_EXT = 1000392001, - PHYSICAL_DEVICE_IMAGE_2D_VIEW_OF_3D_FEATURES_EXT = 1000393000, - PHYSICAL_DEVICE_BORDER_COLOR_SWIZZLE_FEATURES_EXT = 1000411000, - SAMPLER_BORDER_COLOR_COMPONENT_MAPPING_CREATE_INFO_EXT = 1000411001, - PHYSICAL_DEVICE_PAGEABLE_DEVICE_LOCAL_MEMORY_FEATURES_EXT = 1000412000, - PHYSICAL_DEVICE_DESCRIPTOR_SET_HOST_MAPPING_FEATURES_VALVE = 1000420000, - DESCRIPTOR_SET_BINDING_REFERENCE_VALVE = 1000420001, - DESCRIPTOR_SET_LAYOUT_HOST_MAPPING_INFO_VALVE = 1000420002, - PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_OFFSET_FEATURES_QCOM = 1000425000, - PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_OFFSET_PROPERTIES_QCOM = 1000425001, - SUBPASS_FRAGMENT_DENSITY_MAP_OFFSET_END_INFO_QCOM = 1000425002, - PHYSICAL_DEVICE_LINEAR_COLOR_ATTACHMENT_FEATURES_NV = 1000430000, - PHYSICAL_DEVICE_VARIABLE_POINTER_FEATURES = PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES, - PHYSICAL_DEVICE_SHADER_DRAW_PARAMETER_FEATURES = PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES, - DEBUG_REPORT_CREATE_INFO_EXT = DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT, - RENDERING_INFO_KHR = RENDERING_INFO, - RENDERING_ATTACHMENT_INFO_KHR = RENDERING_ATTACHMENT_INFO, - PIPELINE_RENDERING_CREATE_INFO_KHR = PIPELINE_RENDERING_CREATE_INFO, - PHYSICAL_DEVICE_DYNAMIC_RENDERING_FEATURES_KHR = PHYSICAL_DEVICE_DYNAMIC_RENDERING_FEATURES, - COMMAND_BUFFER_INHERITANCE_RENDERING_INFO_KHR = COMMAND_BUFFER_INHERITANCE_RENDERING_INFO, - ATTACHMENT_SAMPLE_COUNT_INFO_NV = ATTACHMENT_SAMPLE_COUNT_INFO_AMD, - RENDER_PASS_MULTIVIEW_CREATE_INFO_KHR = RENDER_PASS_MULTIVIEW_CREATE_INFO, - PHYSICAL_DEVICE_MULTIVIEW_FEATURES_KHR = PHYSICAL_DEVICE_MULTIVIEW_FEATURES, - PHYSICAL_DEVICE_MULTIVIEW_PROPERTIES_KHR = PHYSICAL_DEVICE_MULTIVIEW_PROPERTIES, - PHYSICAL_DEVICE_FEATURES_2_KHR = PHYSICAL_DEVICE_FEATURES_2, - PHYSICAL_DEVICE_PROPERTIES_2_KHR = PHYSICAL_DEVICE_PROPERTIES_2, - FORMAT_PROPERTIES_2_KHR = FORMAT_PROPERTIES_2, - IMAGE_FORMAT_PROPERTIES_2_KHR = IMAGE_FORMAT_PROPERTIES_2, - PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2_KHR = PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2, - QUEUE_FAMILY_PROPERTIES_2_KHR = QUEUE_FAMILY_PROPERTIES_2, - PHYSICAL_DEVICE_MEMORY_PROPERTIES_2_KHR = PHYSICAL_DEVICE_MEMORY_PROPERTIES_2, - SPARSE_IMAGE_FORMAT_PROPERTIES_2_KHR = SPARSE_IMAGE_FORMAT_PROPERTIES_2, - PHYSICAL_DEVICE_SPARSE_IMAGE_FORMAT_INFO_2_KHR = PHYSICAL_DEVICE_SPARSE_IMAGE_FORMAT_INFO_2, - MEMORY_ALLOCATE_FLAGS_INFO_KHR = MEMORY_ALLOCATE_FLAGS_INFO, - DEVICE_GROUP_RENDER_PASS_BEGIN_INFO_KHR = DEVICE_GROUP_RENDER_PASS_BEGIN_INFO, - DEVICE_GROUP_COMMAND_BUFFER_BEGIN_INFO_KHR = DEVICE_GROUP_COMMAND_BUFFER_BEGIN_INFO, - DEVICE_GROUP_SUBMIT_INFO_KHR = DEVICE_GROUP_SUBMIT_INFO, - DEVICE_GROUP_BIND_SPARSE_INFO_KHR = DEVICE_GROUP_BIND_SPARSE_INFO, - BIND_BUFFER_MEMORY_DEVICE_GROUP_INFO_KHR = BIND_BUFFER_MEMORY_DEVICE_GROUP_INFO, - BIND_IMAGE_MEMORY_DEVICE_GROUP_INFO_KHR = BIND_IMAGE_MEMORY_DEVICE_GROUP_INFO, - PHYSICAL_DEVICE_TEXTURE_COMPRESSION_ASTC_HDR_FEATURES_EXT = PHYSICAL_DEVICE_TEXTURE_COMPRESSION_ASTC_HDR_FEATURES, - PHYSICAL_DEVICE_GROUP_PROPERTIES_KHR = PHYSICAL_DEVICE_GROUP_PROPERTIES, - DEVICE_GROUP_DEVICE_CREATE_INFO_KHR = DEVICE_GROUP_DEVICE_CREATE_INFO, - PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO_KHR = PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO, - EXTERNAL_IMAGE_FORMAT_PROPERTIES_KHR = EXTERNAL_IMAGE_FORMAT_PROPERTIES, - PHYSICAL_DEVICE_EXTERNAL_BUFFER_INFO_KHR = PHYSICAL_DEVICE_EXTERNAL_BUFFER_INFO, - EXTERNAL_BUFFER_PROPERTIES_KHR = EXTERNAL_BUFFER_PROPERTIES, - PHYSICAL_DEVICE_ID_PROPERTIES_KHR = PHYSICAL_DEVICE_ID_PROPERTIES, - EXTERNAL_MEMORY_BUFFER_CREATE_INFO_KHR = EXTERNAL_MEMORY_BUFFER_CREATE_INFO, - EXTERNAL_MEMORY_IMAGE_CREATE_INFO_KHR = EXTERNAL_MEMORY_IMAGE_CREATE_INFO, - EXPORT_MEMORY_ALLOCATE_INFO_KHR = EXPORT_MEMORY_ALLOCATE_INFO, - PHYSICAL_DEVICE_EXTERNAL_SEMAPHORE_INFO_KHR = PHYSICAL_DEVICE_EXTERNAL_SEMAPHORE_INFO, - EXTERNAL_SEMAPHORE_PROPERTIES_KHR = EXTERNAL_SEMAPHORE_PROPERTIES, - EXPORT_SEMAPHORE_CREATE_INFO_KHR = EXPORT_SEMAPHORE_CREATE_INFO, - PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES_KHR = PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES, - PHYSICAL_DEVICE_FLOAT16_INT8_FEATURES_KHR = PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES, - PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES_KHR = PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES, - DESCRIPTOR_UPDATE_TEMPLATE_CREATE_INFO_KHR = DESCRIPTOR_UPDATE_TEMPLATE_CREATE_INFO, - SURFACE_CAPABILITIES2_EXT = SURFACE_CAPABILITIES_2_EXT, - PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES_KHR = PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES, - FRAMEBUFFER_ATTACHMENTS_CREATE_INFO_KHR = FRAMEBUFFER_ATTACHMENTS_CREATE_INFO, - FRAMEBUFFER_ATTACHMENT_IMAGE_INFO_KHR = FRAMEBUFFER_ATTACHMENT_IMAGE_INFO, - RENDER_PASS_ATTACHMENT_BEGIN_INFO_KHR = RENDER_PASS_ATTACHMENT_BEGIN_INFO, - ATTACHMENT_DESCRIPTION_2_KHR = ATTACHMENT_DESCRIPTION_2, - ATTACHMENT_REFERENCE_2_KHR = ATTACHMENT_REFERENCE_2, - SUBPASS_DESCRIPTION_2_KHR = SUBPASS_DESCRIPTION_2, - SUBPASS_DEPENDENCY_2_KHR = SUBPASS_DEPENDENCY_2, - RENDER_PASS_CREATE_INFO_2_KHR = RENDER_PASS_CREATE_INFO_2, - SUBPASS_BEGIN_INFO_KHR = SUBPASS_BEGIN_INFO, - SUBPASS_END_INFO_KHR = SUBPASS_END_INFO, - PHYSICAL_DEVICE_EXTERNAL_FENCE_INFO_KHR = PHYSICAL_DEVICE_EXTERNAL_FENCE_INFO, - EXTERNAL_FENCE_PROPERTIES_KHR = EXTERNAL_FENCE_PROPERTIES, - EXPORT_FENCE_CREATE_INFO_KHR = EXPORT_FENCE_CREATE_INFO, - PHYSICAL_DEVICE_POINT_CLIPPING_PROPERTIES_KHR = PHYSICAL_DEVICE_POINT_CLIPPING_PROPERTIES, - RENDER_PASS_INPUT_ATTACHMENT_ASPECT_CREATE_INFO_KHR = RENDER_PASS_INPUT_ATTACHMENT_ASPECT_CREATE_INFO, - IMAGE_VIEW_USAGE_CREATE_INFO_KHR = IMAGE_VIEW_USAGE_CREATE_INFO, - PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO_KHR = PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO, - PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES_KHR = PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES, - PHYSICAL_DEVICE_VARIABLE_POINTER_FEATURES_KHR = PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES_KHR, - MEMORY_DEDICATED_REQUIREMENTS_KHR = MEMORY_DEDICATED_REQUIREMENTS, - MEMORY_DEDICATED_ALLOCATE_INFO_KHR = MEMORY_DEDICATED_ALLOCATE_INFO, - PHYSICAL_DEVICE_SAMPLER_FILTER_MINMAX_PROPERTIES_EXT = PHYSICAL_DEVICE_SAMPLER_FILTER_MINMAX_PROPERTIES, - SAMPLER_REDUCTION_MODE_CREATE_INFO_EXT = SAMPLER_REDUCTION_MODE_CREATE_INFO, - PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_FEATURES_EXT = PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_FEATURES, - PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_PROPERTIES_EXT = PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_PROPERTIES, - WRITE_DESCRIPTOR_SET_INLINE_UNIFORM_BLOCK_EXT = WRITE_DESCRIPTOR_SET_INLINE_UNIFORM_BLOCK, - DESCRIPTOR_POOL_INLINE_UNIFORM_BLOCK_CREATE_INFO_EXT = DESCRIPTOR_POOL_INLINE_UNIFORM_BLOCK_CREATE_INFO, - BUFFER_MEMORY_REQUIREMENTS_INFO_2_KHR = BUFFER_MEMORY_REQUIREMENTS_INFO_2, - IMAGE_MEMORY_REQUIREMENTS_INFO_2_KHR = IMAGE_MEMORY_REQUIREMENTS_INFO_2, - IMAGE_SPARSE_MEMORY_REQUIREMENTS_INFO_2_KHR = IMAGE_SPARSE_MEMORY_REQUIREMENTS_INFO_2, - MEMORY_REQUIREMENTS_2_KHR = MEMORY_REQUIREMENTS_2, - SPARSE_IMAGE_MEMORY_REQUIREMENTS_2_KHR = SPARSE_IMAGE_MEMORY_REQUIREMENTS_2, - IMAGE_FORMAT_LIST_CREATE_INFO_KHR = IMAGE_FORMAT_LIST_CREATE_INFO, - SAMPLER_YCBCR_CONVERSION_CREATE_INFO_KHR = SAMPLER_YCBCR_CONVERSION_CREATE_INFO, - SAMPLER_YCBCR_CONVERSION_INFO_KHR = SAMPLER_YCBCR_CONVERSION_INFO, - BIND_IMAGE_PLANE_MEMORY_INFO_KHR = BIND_IMAGE_PLANE_MEMORY_INFO, - IMAGE_PLANE_MEMORY_REQUIREMENTS_INFO_KHR = IMAGE_PLANE_MEMORY_REQUIREMENTS_INFO, - PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES_KHR = PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES, - SAMPLER_YCBCR_CONVERSION_IMAGE_FORMAT_PROPERTIES_KHR = SAMPLER_YCBCR_CONVERSION_IMAGE_FORMAT_PROPERTIES, - BIND_BUFFER_MEMORY_INFO_KHR = BIND_BUFFER_MEMORY_INFO, - BIND_IMAGE_MEMORY_INFO_KHR = BIND_IMAGE_MEMORY_INFO, - DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO_EXT = DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO, - PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES_EXT = PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES, - PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_PROPERTIES_EXT = PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_PROPERTIES, - DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_ALLOCATE_INFO_EXT = DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_ALLOCATE_INFO, - DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_LAYOUT_SUPPORT_EXT = DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_LAYOUT_SUPPORT, - PHYSICAL_DEVICE_MAINTENANCE_3_PROPERTIES_KHR = PHYSICAL_DEVICE_MAINTENANCE_3_PROPERTIES, - DESCRIPTOR_SET_LAYOUT_SUPPORT_KHR = DESCRIPTOR_SET_LAYOUT_SUPPORT, - DEVICE_QUEUE_GLOBAL_PRIORITY_CREATE_INFO_EXT = DEVICE_QUEUE_GLOBAL_PRIORITY_CREATE_INFO_KHR, - PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES_KHR = PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES, - PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES_KHR = PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES, - PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES_KHR = PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES, - PIPELINE_CREATION_FEEDBACK_CREATE_INFO_EXT = PIPELINE_CREATION_FEEDBACK_CREATE_INFO, - PHYSICAL_DEVICE_DRIVER_PROPERTIES_KHR = PHYSICAL_DEVICE_DRIVER_PROPERTIES, - PHYSICAL_DEVICE_FLOAT_CONTROLS_PROPERTIES_KHR = PHYSICAL_DEVICE_FLOAT_CONTROLS_PROPERTIES, - PHYSICAL_DEVICE_DEPTH_STENCIL_RESOLVE_PROPERTIES_KHR = PHYSICAL_DEVICE_DEPTH_STENCIL_RESOLVE_PROPERTIES, - SUBPASS_DESCRIPTION_DEPTH_STENCIL_RESOLVE_KHR = SUBPASS_DESCRIPTION_DEPTH_STENCIL_RESOLVE, - PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES_KHR = PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES, - PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_PROPERTIES_KHR = PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_PROPERTIES, - SEMAPHORE_TYPE_CREATE_INFO_KHR = SEMAPHORE_TYPE_CREATE_INFO, - TIMELINE_SEMAPHORE_SUBMIT_INFO_KHR = TIMELINE_SEMAPHORE_SUBMIT_INFO, - SEMAPHORE_WAIT_INFO_KHR = SEMAPHORE_WAIT_INFO, - SEMAPHORE_SIGNAL_INFO_KHR = SEMAPHORE_SIGNAL_INFO, - QUERY_POOL_CREATE_INFO_INTEL = QUERY_POOL_PERFORMANCE_QUERY_CREATE_INFO_INTEL, - PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES_KHR = PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES, - PHYSICAL_DEVICE_SHADER_TERMINATE_INVOCATION_FEATURES_KHR = PHYSICAL_DEVICE_SHADER_TERMINATE_INVOCATION_FEATURES, - PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES_EXT = PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES, - PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_PROPERTIES_EXT = PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_PROPERTIES, - PIPELINE_SHADER_STAGE_REQUIRED_SUBGROUP_SIZE_CREATE_INFO_EXT = PIPELINE_SHADER_STAGE_REQUIRED_SUBGROUP_SIZE_CREATE_INFO, - PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_FEATURES_EXT = PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_FEATURES, - PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES_KHR = PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES, - ATTACHMENT_REFERENCE_STENCIL_LAYOUT_KHR = ATTACHMENT_REFERENCE_STENCIL_LAYOUT, - ATTACHMENT_DESCRIPTION_STENCIL_LAYOUT_KHR = ATTACHMENT_DESCRIPTION_STENCIL_LAYOUT, - PHYSICAL_DEVICE_BUFFER_ADDRESS_FEATURES_EXT = PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES_EXT, - BUFFER_DEVICE_ADDRESS_INFO_EXT = BUFFER_DEVICE_ADDRESS_INFO, - PHYSICAL_DEVICE_TOOL_PROPERTIES_EXT = PHYSICAL_DEVICE_TOOL_PROPERTIES, - IMAGE_STENCIL_USAGE_CREATE_INFO_EXT = IMAGE_STENCIL_USAGE_CREATE_INFO, - PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES_KHR = PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES, - PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES_KHR = PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES, - BUFFER_DEVICE_ADDRESS_INFO_KHR = BUFFER_DEVICE_ADDRESS_INFO, - BUFFER_OPAQUE_CAPTURE_ADDRESS_CREATE_INFO_KHR = BUFFER_OPAQUE_CAPTURE_ADDRESS_CREATE_INFO, - MEMORY_OPAQUE_CAPTURE_ADDRESS_ALLOCATE_INFO_KHR = MEMORY_OPAQUE_CAPTURE_ADDRESS_ALLOCATE_INFO, - DEVICE_MEMORY_OPAQUE_CAPTURE_ADDRESS_INFO_KHR = DEVICE_MEMORY_OPAQUE_CAPTURE_ADDRESS_INFO, - PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES_EXT = PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES, - PHYSICAL_DEVICE_SHADER_DEMOTE_TO_HELPER_INVOCATION_FEATURES_EXT = PHYSICAL_DEVICE_SHADER_DEMOTE_TO_HELPER_INVOCATION_FEATURES, - PHYSICAL_DEVICE_SHADER_INTEGER_DOT_PRODUCT_FEATURES_KHR = PHYSICAL_DEVICE_SHADER_INTEGER_DOT_PRODUCT_FEATURES, - PHYSICAL_DEVICE_SHADER_INTEGER_DOT_PRODUCT_PROPERTIES_KHR = PHYSICAL_DEVICE_SHADER_INTEGER_DOT_PRODUCT_PROPERTIES, - PHYSICAL_DEVICE_TEXEL_BUFFER_ALIGNMENT_PROPERTIES_EXT = PHYSICAL_DEVICE_TEXEL_BUFFER_ALIGNMENT_PROPERTIES, - PHYSICAL_DEVICE_PRIVATE_DATA_FEATURES_EXT = PHYSICAL_DEVICE_PRIVATE_DATA_FEATURES, - DEVICE_PRIVATE_DATA_CREATE_INFO_EXT = DEVICE_PRIVATE_DATA_CREATE_INFO, - PRIVATE_DATA_SLOT_CREATE_INFO_EXT = PRIVATE_DATA_SLOT_CREATE_INFO, - PHYSICAL_DEVICE_PIPELINE_CREATION_CACHE_CONTROL_FEATURES_EXT = PHYSICAL_DEVICE_PIPELINE_CREATION_CACHE_CONTROL_FEATURES, - MEMORY_BARRIER_2_KHR = MEMORY_BARRIER_2, - BUFFER_MEMORY_BARRIER_2_KHR = BUFFER_MEMORY_BARRIER_2, - IMAGE_MEMORY_BARRIER_2_KHR = IMAGE_MEMORY_BARRIER_2, - DEPENDENCY_INFO_KHR = DEPENDENCY_INFO, - SUBMIT_INFO_2_KHR = SUBMIT_INFO_2, - SEMAPHORE_SUBMIT_INFO_KHR = SEMAPHORE_SUBMIT_INFO, - COMMAND_BUFFER_SUBMIT_INFO_KHR = COMMAND_BUFFER_SUBMIT_INFO, - PHYSICAL_DEVICE_SYNCHRONIZATION_2_FEATURES_KHR = PHYSICAL_DEVICE_SYNCHRONIZATION_2_FEATURES, - PHYSICAL_DEVICE_ZERO_INITIALIZE_WORKGROUP_MEMORY_FEATURES_KHR = PHYSICAL_DEVICE_ZERO_INITIALIZE_WORKGROUP_MEMORY_FEATURES, - PHYSICAL_DEVICE_IMAGE_ROBUSTNESS_FEATURES_EXT = PHYSICAL_DEVICE_IMAGE_ROBUSTNESS_FEATURES, - COPY_BUFFER_INFO_2_KHR = COPY_BUFFER_INFO_2, - COPY_IMAGE_INFO_2_KHR = COPY_IMAGE_INFO_2, - COPY_BUFFER_TO_IMAGE_INFO_2_KHR = COPY_BUFFER_TO_IMAGE_INFO_2, - COPY_IMAGE_TO_BUFFER_INFO_2_KHR = COPY_IMAGE_TO_BUFFER_INFO_2, - BLIT_IMAGE_INFO_2_KHR = BLIT_IMAGE_INFO_2, - RESOLVE_IMAGE_INFO_2_KHR = RESOLVE_IMAGE_INFO_2, - BUFFER_COPY_2_KHR = BUFFER_COPY_2, - IMAGE_COPY_2_KHR = IMAGE_COPY_2, - IMAGE_BLIT_2_KHR = IMAGE_BLIT_2, - BUFFER_IMAGE_COPY_2_KHR = BUFFER_IMAGE_COPY_2, - IMAGE_RESOLVE_2_KHR = IMAGE_RESOLVE_2, - FORMAT_PROPERTIES_3_KHR = FORMAT_PROPERTIES_3, - PHYSICAL_DEVICE_GLOBAL_PRIORITY_QUERY_FEATURES_EXT = PHYSICAL_DEVICE_GLOBAL_PRIORITY_QUERY_FEATURES_KHR, - QUEUE_FAMILY_GLOBAL_PRIORITY_PROPERTIES_EXT = QUEUE_FAMILY_GLOBAL_PRIORITY_PROPERTIES_KHR, - PHYSICAL_DEVICE_MAINTENANCE_4_FEATURES_KHR = PHYSICAL_DEVICE_MAINTENANCE_4_FEATURES, - PHYSICAL_DEVICE_MAINTENANCE_4_PROPERTIES_KHR = PHYSICAL_DEVICE_MAINTENANCE_4_PROPERTIES, - DEVICE_BUFFER_MEMORY_REQUIREMENTS_KHR = DEVICE_BUFFER_MEMORY_REQUIREMENTS, - DEVICE_IMAGE_MEMORY_REQUIREMENTS_KHR = DEVICE_IMAGE_MEMORY_REQUIREMENTS, -} - -SubgroupFeatureFlags :: distinct bit_set[SubgroupFeatureFlag; Flags] -SubgroupFeatureFlag :: enum Flags { - BASIC = 0, - VOTE = 1, - ARITHMETIC = 2, - BALLOT = 3, - SHUFFLE = 4, - SHUFFLE_RELATIVE = 5, - CLUSTERED = 6, - QUAD = 7, - PARTITIONED_NV = 8, -} - -SubmitFlags :: distinct bit_set[SubmitFlag; Flags] -SubmitFlag :: enum Flags { - PROTECTED = 0, - PROTECTED_KHR = PROTECTED, -} - -SubpassContents :: enum c.int { - INLINE = 0, - SECONDARY_COMMAND_BUFFERS = 1, -} - -SubpassDescriptionFlags :: distinct bit_set[SubpassDescriptionFlag; Flags] -SubpassDescriptionFlag :: enum Flags { - PER_VIEW_ATTRIBUTES_NVX = 0, - PER_VIEW_POSITION_X_ONLY_NVX = 1, - FRAGMENT_REGION_QCOM = 2, - SHADER_RESOLVE_QCOM = 3, - RASTERIZATION_ORDER_ATTACHMENT_COLOR_ACCESS_ARM = 4, - RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_ARM = 5, - RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_ARM = 6, -} - -SurfaceCounterFlagsEXT :: distinct bit_set[SurfaceCounterFlagEXT; Flags] -SurfaceCounterFlagEXT :: enum Flags { - VBLANK = 0, -} - -SurfaceTransformFlagsKHR :: distinct bit_set[SurfaceTransformFlagKHR; Flags] -SurfaceTransformFlagKHR :: enum Flags { - IDENTITY = 0, - ROTATE_90 = 1, - ROTATE_180 = 2, - ROTATE_270 = 3, - HORIZONTAL_MIRROR = 4, - HORIZONTAL_MIRROR_ROTATE_90 = 5, - HORIZONTAL_MIRROR_ROTATE_180 = 6, - HORIZONTAL_MIRROR_ROTATE_270 = 7, - INHERIT = 8, -} - -SwapchainCreateFlagsKHR :: distinct bit_set[SwapchainCreateFlagKHR; Flags] -SwapchainCreateFlagKHR :: enum Flags { - SPLIT_INSTANCE_BIND_REGIONS = 0, - PROTECTED = 1, - MUTABLE_FORMAT = 2, -} - -SystemAllocationScope :: enum c.int { - COMMAND = 0, - OBJECT = 1, - CACHE = 2, - DEVICE = 3, - INSTANCE = 4, -} - -TessellationDomainOrigin :: enum c.int { - UPPER_LEFT = 0, - LOWER_LEFT = 1, - UPPER_LEFT_KHR = UPPER_LEFT, - LOWER_LEFT_KHR = LOWER_LEFT, -} - -TimeDomainEXT :: enum c.int { - DEVICE = 0, - CLOCK_MONOTONIC = 1, - CLOCK_MONOTONIC_RAW = 2, - QUERY_PERFORMANCE_COUNTER = 3, -} - -ToolPurposeFlags :: distinct bit_set[ToolPurposeFlag; Flags] -ToolPurposeFlag :: enum Flags { - VALIDATION = 0, - PROFILING = 1, - TRACING = 2, - ADDITIONAL_FEATURES = 3, - MODIFYING_FEATURES = 4, - DEBUG_REPORTING_EXT = 5, - DEBUG_MARKERS_EXT = 6, - VALIDATION_EXT = VALIDATION, - PROFILING_EXT = PROFILING, - TRACING_EXT = TRACING, - ADDITIONAL_FEATURES_EXT = ADDITIONAL_FEATURES, - MODIFYING_FEATURES_EXT = MODIFYING_FEATURES, -} - -ValidationCacheHeaderVersionEXT :: enum c.int { - ONE = 1, -} - -ValidationCheckEXT :: enum c.int { - ALL = 0, - SHADERS = 1, -} - -ValidationFeatureDisableEXT :: enum c.int { - ALL = 0, - SHADERS = 1, - THREAD_SAFETY = 2, - API_PARAMETERS = 3, - OBJECT_LIFETIMES = 4, - CORE_CHECKS = 5, - UNIQUE_HANDLES = 6, - SHADER_VALIDATION_CACHE = 7, -} - -ValidationFeatureEnableEXT :: enum c.int { - GPU_ASSISTED = 0, - GPU_ASSISTED_RESERVE_BINDING_SLOT = 1, - BEST_PRACTICES = 2, - DEBUG_PRINTF = 3, - SYNCHRONIZATION_VALIDATION = 4, -} - -VendorId :: enum c.int { - VIV = 0x10001, - VSI = 0x10002, - KAZAN = 0x10003, - CODEPLAY = 0x10004, - MESA = 0x10005, - POCL = 0x10006, -} - -VertexInputRate :: enum c.int { - VERTEX = 0, - INSTANCE = 1, -} - -ViewportCoordinateSwizzleNV :: enum c.int { - POSITIVE_X = 0, - NEGATIVE_X = 1, - POSITIVE_Y = 2, - NEGATIVE_Y = 3, - POSITIVE_Z = 4, - NEGATIVE_Z = 5, - POSITIVE_W = 6, - NEGATIVE_W = 7, -} - -AccelerationStructureMotionInfoFlagsNV :: distinct bit_set[AccelerationStructureMotionInfoFlagNV; Flags] -AccelerationStructureMotionInfoFlagNV :: enum u32 {} -AccelerationStructureMotionInstanceFlagsNV :: distinct bit_set[AccelerationStructureMotionInstanceFlagNV; Flags] -AccelerationStructureMotionInstanceFlagNV :: enum u32 {} -BufferViewCreateFlags :: distinct bit_set[BufferViewCreateFlag; Flags] -BufferViewCreateFlag :: enum u32 {} -CommandPoolTrimFlags :: distinct bit_set[CommandPoolTrimFlag; Flags] -CommandPoolTrimFlag :: enum u32 {} -DebugUtilsMessengerCallbackDataFlagsEXT :: distinct bit_set[DebugUtilsMessengerCallbackDataFlagEXT; Flags] -DebugUtilsMessengerCallbackDataFlagEXT :: enum u32 {} -DebugUtilsMessengerCreateFlagsEXT :: distinct bit_set[DebugUtilsMessengerCreateFlagEXT; Flags] -DebugUtilsMessengerCreateFlagEXT :: enum u32 {} -DescriptorPoolResetFlags :: distinct bit_set[DescriptorPoolResetFlag; Flags] -DescriptorPoolResetFlag :: enum u32 {} -DescriptorUpdateTemplateCreateFlags :: distinct bit_set[DescriptorUpdateTemplateCreateFlag; Flags] -DescriptorUpdateTemplateCreateFlag :: enum u32 {} -DeviceCreateFlags :: distinct bit_set[DeviceCreateFlag; Flags] -DeviceCreateFlag :: enum u32 {} -DeviceMemoryReportFlagsEXT :: distinct bit_set[DeviceMemoryReportFlagEXT; Flags] -DeviceMemoryReportFlagEXT :: enum u32 {} -DisplayModeCreateFlagsKHR :: distinct bit_set[DisplayModeCreateFlagKHR; Flags] -DisplayModeCreateFlagKHR :: enum u32 {} -DisplaySurfaceCreateFlagsKHR :: distinct bit_set[DisplaySurfaceCreateFlagKHR; Flags] -DisplaySurfaceCreateFlagKHR :: enum u32 {} -HeadlessSurfaceCreateFlagsEXT :: distinct bit_set[HeadlessSurfaceCreateFlagEXT; Flags] -HeadlessSurfaceCreateFlagEXT :: enum u32 {} -IOSSurfaceCreateFlagsMVK :: distinct bit_set[IOSSurfaceCreateFlagMVK; Flags] -IOSSurfaceCreateFlagMVK :: enum u32 {} -MacOSSurfaceCreateFlagsMVK :: distinct bit_set[MacOSSurfaceCreateFlagMVK; Flags] -MacOSSurfaceCreateFlagMVK :: enum u32 {} -MemoryMapFlags :: distinct bit_set[MemoryMapFlag; Flags] -MemoryMapFlag :: enum u32 {} -MetalSurfaceCreateFlagsEXT :: distinct bit_set[MetalSurfaceCreateFlagEXT; Flags] -MetalSurfaceCreateFlagEXT :: enum u32 {} -PipelineCoverageModulationStateCreateFlagsNV :: distinct bit_set[PipelineCoverageModulationStateCreateFlagNV; Flags] -PipelineCoverageModulationStateCreateFlagNV :: enum u32 {} -PipelineCoverageReductionStateCreateFlagsNV :: distinct bit_set[PipelineCoverageReductionStateCreateFlagNV; Flags] -PipelineCoverageReductionStateCreateFlagNV :: enum u32 {} -PipelineCoverageToColorStateCreateFlagsNV :: distinct bit_set[PipelineCoverageToColorStateCreateFlagNV; Flags] -PipelineCoverageToColorStateCreateFlagNV :: enum u32 {} -PipelineDiscardRectangleStateCreateFlagsEXT :: distinct bit_set[PipelineDiscardRectangleStateCreateFlagEXT; Flags] -PipelineDiscardRectangleStateCreateFlagEXT :: enum u32 {} -PipelineDynamicStateCreateFlags :: distinct bit_set[PipelineDynamicStateCreateFlag; Flags] -PipelineDynamicStateCreateFlag :: enum u32 {} -PipelineInputAssemblyStateCreateFlags :: distinct bit_set[PipelineInputAssemblyStateCreateFlag; Flags] -PipelineInputAssemblyStateCreateFlag :: enum u32 {} -PipelineMultisampleStateCreateFlags :: distinct bit_set[PipelineMultisampleStateCreateFlag; Flags] -PipelineMultisampleStateCreateFlag :: enum u32 {} -PipelineRasterizationConservativeStateCreateFlagsEXT :: distinct bit_set[PipelineRasterizationConservativeStateCreateFlagEXT; Flags] -PipelineRasterizationConservativeStateCreateFlagEXT :: enum u32 {} -PipelineRasterizationDepthClipStateCreateFlagsEXT :: distinct bit_set[PipelineRasterizationDepthClipStateCreateFlagEXT; Flags] -PipelineRasterizationDepthClipStateCreateFlagEXT :: enum u32 {} -PipelineRasterizationStateCreateFlags :: distinct bit_set[PipelineRasterizationStateCreateFlag; Flags] -PipelineRasterizationStateCreateFlag :: enum u32 {} -PipelineRasterizationStateStreamCreateFlagsEXT :: distinct bit_set[PipelineRasterizationStateStreamCreateFlagEXT; Flags] -PipelineRasterizationStateStreamCreateFlagEXT :: enum u32 {} -PipelineTessellationStateCreateFlags :: distinct bit_set[PipelineTessellationStateCreateFlag; Flags] -PipelineTessellationStateCreateFlag :: enum u32 {} -PipelineVertexInputStateCreateFlags :: distinct bit_set[PipelineVertexInputStateCreateFlag; Flags] -PipelineVertexInputStateCreateFlag :: enum u32 {} -PipelineViewportStateCreateFlags :: distinct bit_set[PipelineViewportStateCreateFlag; Flags] -PipelineViewportStateCreateFlag :: enum u32 {} -PipelineViewportSwizzleStateCreateFlagsNV :: distinct bit_set[PipelineViewportSwizzleStateCreateFlagNV; Flags] -PipelineViewportSwizzleStateCreateFlagNV :: enum u32 {} -PrivateDataSlotCreateFlags :: distinct bit_set[PrivateDataSlotCreateFlag; Flags] -PrivateDataSlotCreateFlag :: enum u32 {} -QueryPoolCreateFlags :: distinct bit_set[QueryPoolCreateFlag; Flags] -QueryPoolCreateFlag :: enum u32 {} -SemaphoreCreateFlags :: distinct bit_set[SemaphoreCreateFlag; Flags] -SemaphoreCreateFlag :: enum u32 {} -ShaderModuleCreateFlags :: distinct bit_set[ShaderModuleCreateFlag; Flags] -ShaderModuleCreateFlag :: enum u32 {} -ValidationCacheCreateFlagsEXT :: distinct bit_set[ValidationCacheCreateFlagEXT; Flags] -ValidationCacheCreateFlagEXT :: enum u32 {} -Win32SurfaceCreateFlagsKHR :: distinct bit_set[Win32SurfaceCreateFlagKHR; Flags] -Win32SurfaceCreateFlagKHR :: enum u32 {} - - +// +// Vulkan wrapper generated from "https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/master/include/vulkan/vulkan_core.h" +// +package vulkan + +import "core:c" + +// Enums +AccelerationStructureBuildTypeKHR :: enum c.int { + HOST = 0, + DEVICE = 1, + HOST_OR_DEVICE = 2, +} + +AccelerationStructureCompatibilityKHR :: enum c.int { + COMPATIBLE = 0, + INCOMPATIBLE = 1, +} + +AccelerationStructureCreateFlagsKHR :: distinct bit_set[AccelerationStructureCreateFlagKHR; Flags] +AccelerationStructureCreateFlagKHR :: enum Flags { + DEVICE_ADDRESS_CAPTURE_REPLAY = 0, + DESCRIPTOR_BUFFER_CAPTURE_REPLAY_EXT = 3, + MOTION_NV = 2, +} + +AccelerationStructureMemoryRequirementsTypeNV :: enum c.int { + OBJECT = 0, + BUILD_SCRATCH = 1, + UPDATE_SCRATCH = 2, +} + +AccelerationStructureMotionInstanceTypeNV :: enum c.int { + STATIC = 0, + MATRIX_MOTION = 1, + SRT_MOTION = 2, +} + +AccelerationStructureTypeKHR :: enum c.int { + TOP_LEVEL = 0, + BOTTOM_LEVEL = 1, + GENERIC = 2, + TOP_LEVEL_NV = TOP_LEVEL, + BOTTOM_LEVEL_NV = BOTTOM_LEVEL, +} + +AccessFlags :: distinct bit_set[AccessFlag; Flags] +AccessFlag :: enum Flags { + INDIRECT_COMMAND_READ = 0, + INDEX_READ = 1, + VERTEX_ATTRIBUTE_READ = 2, + UNIFORM_READ = 3, + INPUT_ATTACHMENT_READ = 4, + SHADER_READ = 5, + SHADER_WRITE = 6, + COLOR_ATTACHMENT_READ = 7, + COLOR_ATTACHMENT_WRITE = 8, + DEPTH_STENCIL_ATTACHMENT_READ = 9, + DEPTH_STENCIL_ATTACHMENT_WRITE = 10, + TRANSFER_READ = 11, + TRANSFER_WRITE = 12, + HOST_READ = 13, + HOST_WRITE = 14, + MEMORY_READ = 15, + MEMORY_WRITE = 16, + TRANSFORM_FEEDBACK_WRITE_EXT = 25, + TRANSFORM_FEEDBACK_COUNTER_READ_EXT = 26, + TRANSFORM_FEEDBACK_COUNTER_WRITE_EXT = 27, + CONDITIONAL_RENDERING_READ_EXT = 20, + COLOR_ATTACHMENT_READ_NONCOHERENT_EXT = 19, + ACCELERATION_STRUCTURE_READ_KHR = 21, + ACCELERATION_STRUCTURE_WRITE_KHR = 22, + FRAGMENT_DENSITY_MAP_READ_EXT = 24, + FRAGMENT_SHADING_RATE_ATTACHMENT_READ_KHR = 23, + COMMAND_PREPROCESS_READ_NV = 17, + COMMAND_PREPROCESS_WRITE_NV = 18, + SHADING_RATE_IMAGE_READ_NV = FRAGMENT_SHADING_RATE_ATTACHMENT_READ_KHR, + ACCELERATION_STRUCTURE_READ_NV = ACCELERATION_STRUCTURE_READ_KHR, + ACCELERATION_STRUCTURE_WRITE_NV = ACCELERATION_STRUCTURE_WRITE_KHR, +} + +AccessFlags_NONE :: AccessFlags{} + + +AcquireProfilingLockFlagsKHR :: distinct bit_set[AcquireProfilingLockFlagKHR; Flags] +AcquireProfilingLockFlagKHR :: enum Flags { +} + +AttachmentDescriptionFlags :: distinct bit_set[AttachmentDescriptionFlag; Flags] +AttachmentDescriptionFlag :: enum Flags { + MAY_ALIAS = 0, +} + +AttachmentLoadOp :: enum c.int { + LOAD = 0, + CLEAR = 1, + DONT_CARE = 2, + NONE_EXT = 1000400000, +} + +AttachmentStoreOp :: enum c.int { + STORE = 0, + DONT_CARE = 1, + NONE = 1000301000, +} + +BlendFactor :: enum c.int { + ZERO = 0, + ONE = 1, + SRC_COLOR = 2, + ONE_MINUS_SRC_COLOR = 3, + DST_COLOR = 4, + ONE_MINUS_DST_COLOR = 5, + SRC_ALPHA = 6, + ONE_MINUS_SRC_ALPHA = 7, + DST_ALPHA = 8, + ONE_MINUS_DST_ALPHA = 9, + CONSTANT_COLOR = 10, + ONE_MINUS_CONSTANT_COLOR = 11, + CONSTANT_ALPHA = 12, + ONE_MINUS_CONSTANT_ALPHA = 13, + SRC_ALPHA_SATURATE = 14, + SRC1_COLOR = 15, + ONE_MINUS_SRC1_COLOR = 16, + SRC1_ALPHA = 17, + ONE_MINUS_SRC1_ALPHA = 18, +} + +BlendOp :: enum c.int { + ADD = 0, + SUBTRACT = 1, + REVERSE_SUBTRACT = 2, + MIN = 3, + MAX = 4, + ZERO_EXT = 1000148000, + SRC_EXT = 1000148001, + DST_EXT = 1000148002, + SRC_OVER_EXT = 1000148003, + DST_OVER_EXT = 1000148004, + SRC_IN_EXT = 1000148005, + DST_IN_EXT = 1000148006, + SRC_OUT_EXT = 1000148007, + DST_OUT_EXT = 1000148008, + SRC_ATOP_EXT = 1000148009, + DST_ATOP_EXT = 1000148010, + XOR_EXT = 1000148011, + MULTIPLY_EXT = 1000148012, + SCREEN_EXT = 1000148013, + OVERLAY_EXT = 1000148014, + DARKEN_EXT = 1000148015, + LIGHTEN_EXT = 1000148016, + COLORDODGE_EXT = 1000148017, + COLORBURN_EXT = 1000148018, + HARDLIGHT_EXT = 1000148019, + SOFTLIGHT_EXT = 1000148020, + DIFFERENCE_EXT = 1000148021, + EXCLUSION_EXT = 1000148022, + INVERT_EXT = 1000148023, + INVERT_RGB_EXT = 1000148024, + LINEARDODGE_EXT = 1000148025, + LINEARBURN_EXT = 1000148026, + VIVIDLIGHT_EXT = 1000148027, + LINEARLIGHT_EXT = 1000148028, + PINLIGHT_EXT = 1000148029, + HARDMIX_EXT = 1000148030, + HSL_HUE_EXT = 1000148031, + HSL_SATURATION_EXT = 1000148032, + HSL_COLOR_EXT = 1000148033, + HSL_LUMINOSITY_EXT = 1000148034, + PLUS_EXT = 1000148035, + PLUS_CLAMPED_EXT = 1000148036, + PLUS_CLAMPED_ALPHA_EXT = 1000148037, + PLUS_DARKER_EXT = 1000148038, + MINUS_EXT = 1000148039, + MINUS_CLAMPED_EXT = 1000148040, + CONTRAST_EXT = 1000148041, + INVERT_OVG_EXT = 1000148042, + RED_EXT = 1000148043, + GREEN_EXT = 1000148044, + BLUE_EXT = 1000148045, +} + +BlendOverlapEXT :: enum c.int { + UNCORRELATED = 0, + DISJOINT = 1, + CONJOINT = 2, +} + +BorderColor :: enum c.int { + FLOAT_TRANSPARENT_BLACK = 0, + INT_TRANSPARENT_BLACK = 1, + FLOAT_OPAQUE_BLACK = 2, + INT_OPAQUE_BLACK = 3, + FLOAT_OPAQUE_WHITE = 4, + INT_OPAQUE_WHITE = 5, + FLOAT_CUSTOM_EXT = 1000287003, + INT_CUSTOM_EXT = 1000287004, +} + +BufferCreateFlags :: distinct bit_set[BufferCreateFlag; Flags] +BufferCreateFlag :: enum Flags { + SPARSE_BINDING = 0, + SPARSE_RESIDENCY = 1, + SPARSE_ALIASED = 2, + PROTECTED = 3, + DEVICE_ADDRESS_CAPTURE_REPLAY = 4, + DESCRIPTOR_BUFFER_CAPTURE_REPLAY_EXT = 5, + DEVICE_ADDRESS_CAPTURE_REPLAY_EXT = DEVICE_ADDRESS_CAPTURE_REPLAY, + DEVICE_ADDRESS_CAPTURE_REPLAY_KHR = DEVICE_ADDRESS_CAPTURE_REPLAY, +} + +BufferUsageFlags :: distinct bit_set[BufferUsageFlag; Flags] +BufferUsageFlag :: enum Flags { + TRANSFER_SRC = 0, + TRANSFER_DST = 1, + UNIFORM_TEXEL_BUFFER = 2, + STORAGE_TEXEL_BUFFER = 3, + UNIFORM_BUFFER = 4, + STORAGE_BUFFER = 5, + INDEX_BUFFER = 6, + VERTEX_BUFFER = 7, + INDIRECT_BUFFER = 8, + SHADER_DEVICE_ADDRESS = 17, + VIDEO_DECODE_SRC_KHR = 13, + VIDEO_DECODE_DST_KHR = 14, + TRANSFORM_FEEDBACK_BUFFER_EXT = 11, + TRANSFORM_FEEDBACK_COUNTER_BUFFER_EXT = 12, + CONDITIONAL_RENDERING_EXT = 9, + ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY_KHR = 19, + ACCELERATION_STRUCTURE_STORAGE_KHR = 20, + SHADER_BINDING_TABLE_KHR = 10, + VIDEO_ENCODE_DST_KHR = 15, + VIDEO_ENCODE_SRC_KHR = 16, + SAMPLER_DESCRIPTOR_BUFFER_EXT = 21, + RESOURCE_DESCRIPTOR_BUFFER_EXT = 22, + PUSH_DESCRIPTORS_DESCRIPTOR_BUFFER_EXT = 26, + MICROMAP_BUILD_INPUT_READ_ONLY_EXT = 23, + MICROMAP_STORAGE_EXT = 24, + RAY_TRACING_NV = SHADER_BINDING_TABLE_KHR, + SHADER_DEVICE_ADDRESS_EXT = SHADER_DEVICE_ADDRESS, + SHADER_DEVICE_ADDRESS_KHR = SHADER_DEVICE_ADDRESS, +} + +BuildAccelerationStructureFlagsKHR :: distinct bit_set[BuildAccelerationStructureFlagKHR; Flags] +BuildAccelerationStructureFlagKHR :: enum Flags { + ALLOW_UPDATE = 0, + ALLOW_COMPACTION = 1, + PREFER_FAST_TRACE = 2, + PREFER_FAST_BUILD = 3, + LOW_MEMORY = 4, + MOTION_NV = 5, + ALLOW_OPACITY_MICROMAP_UPDATE_EXT = 6, + ALLOW_DISABLE_OPACITY_MICROMAPS_EXT = 7, + ALLOW_OPACITY_MICROMAP_DATA_UPDATE_EXT = 8, + ALLOW_DISPLACEMENT_MICROMAP_UPDATE_NV = 9, + ALLOW_DATA_ACCESS = 11, + ALLOW_UPDATE_NV = ALLOW_UPDATE, + ALLOW_COMPACTION_NV = ALLOW_COMPACTION, + PREFER_FAST_TRACE_NV = PREFER_FAST_TRACE, + PREFER_FAST_BUILD_NV = PREFER_FAST_BUILD, + LOW_MEMORY_NV = LOW_MEMORY, +} + +BuildAccelerationStructureModeKHR :: enum c.int { + BUILD = 0, + UPDATE = 1, +} + +BuildMicromapFlagsEXT :: distinct bit_set[BuildMicromapFlagEXT; Flags] +BuildMicromapFlagEXT :: enum Flags { + PREFER_FAST_TRACE = 0, + PREFER_FAST_BUILD = 1, + ALLOW_COMPACTION = 2, +} + +BuildMicromapModeEXT :: enum c.int { + BUILD = 0, +} + +ChromaLocation :: enum c.int { + COSITED_EVEN = 0, + MIDPOINT = 1, + COSITED_EVEN_KHR = COSITED_EVEN, + MIDPOINT_KHR = MIDPOINT, +} + +CoarseSampleOrderTypeNV :: enum c.int { + DEFAULT = 0, + CUSTOM = 1, + PIXEL_MAJOR = 2, + SAMPLE_MAJOR = 3, +} + +ColorComponentFlags :: distinct bit_set[ColorComponentFlag; Flags] +ColorComponentFlag :: enum Flags { + R = 0, + G = 1, + B = 2, + A = 3, +} + +ColorSpaceKHR :: enum c.int { + SRGB_NONLINEAR = 0, + DISPLAY_P3_NONLINEAR_EXT = 1000104001, + EXTENDED_SRGB_LINEAR_EXT = 1000104002, + DISPLAY_P3_LINEAR_EXT = 1000104003, + DCI_P3_NONLINEAR_EXT = 1000104004, + BT709_LINEAR_EXT = 1000104005, + BT709_NONLINEAR_EXT = 1000104006, + BT2020_LINEAR_EXT = 1000104007, + HDR10_ST2084_EXT = 1000104008, + DOLBYVISION_EXT = 1000104009, + HDR10_HLG_EXT = 1000104010, + ADOBERGB_LINEAR_EXT = 1000104011, + ADOBERGB_NONLINEAR_EXT = 1000104012, + PASS_THROUGH_EXT = 1000104013, + EXTENDED_SRGB_NONLINEAR_EXT = 1000104014, + DISPLAY_NATIVE_AMD = 1000213000, + COLORSPACE_SRGB_NONLINEAR = SRGB_NONLINEAR, + DCI_P3_LINEAR_EXT = DISPLAY_P3_LINEAR_EXT, +} + +CommandBufferLevel :: enum c.int { + PRIMARY = 0, + SECONDARY = 1, +} + +CommandBufferResetFlags :: distinct bit_set[CommandBufferResetFlag; Flags] +CommandBufferResetFlag :: enum Flags { + RELEASE_RESOURCES = 0, +} + +CommandBufferUsageFlags :: distinct bit_set[CommandBufferUsageFlag; Flags] +CommandBufferUsageFlag :: enum Flags { + ONE_TIME_SUBMIT = 0, + RENDER_PASS_CONTINUE = 1, + SIMULTANEOUS_USE = 2, +} + +CommandPoolCreateFlags :: distinct bit_set[CommandPoolCreateFlag; Flags] +CommandPoolCreateFlag :: enum Flags { + TRANSIENT = 0, + RESET_COMMAND_BUFFER = 1, + PROTECTED = 2, +} + +CommandPoolResetFlags :: distinct bit_set[CommandPoolResetFlag; Flags] +CommandPoolResetFlag :: enum Flags { + RELEASE_RESOURCES = 0, +} + +CompareOp :: enum c.int { + NEVER = 0, + LESS = 1, + EQUAL = 2, + LESS_OR_EQUAL = 3, + GREATER = 4, + NOT_EQUAL = 5, + GREATER_OR_EQUAL = 6, + ALWAYS = 7, +} + +ComponentSwizzle :: enum c.int { + IDENTITY = 0, + ZERO = 1, + ONE = 2, + R = 3, + G = 4, + B = 5, + A = 6, +} + +ComponentTypeNV :: enum c.int { + FLOAT16 = 0, + FLOAT32 = 1, + FLOAT64 = 2, + SINT8 = 3, + SINT16 = 4, + SINT32 = 5, + SINT64 = 6, + UINT8 = 7, + UINT16 = 8, + UINT32 = 9, + UINT64 = 10, +} + +CompositeAlphaFlagsKHR :: distinct bit_set[CompositeAlphaFlagKHR; Flags] +CompositeAlphaFlagKHR :: enum Flags { + OPAQUE = 0, + PRE_MULTIPLIED = 1, + POST_MULTIPLIED = 2, + INHERIT = 3, +} + +ConditionalRenderingFlagsEXT :: distinct bit_set[ConditionalRenderingFlagEXT; Flags] +ConditionalRenderingFlagEXT :: enum Flags { + INVERTED = 0, +} + +ConservativeRasterizationModeEXT :: enum c.int { + DISABLED = 0, + OVERESTIMATE = 1, + UNDERESTIMATE = 2, +} + +CopyAccelerationStructureModeKHR :: enum c.int { + CLONE = 0, + COMPACT = 1, + SERIALIZE = 2, + DESERIALIZE = 3, + CLONE_NV = CLONE, + COMPACT_NV = COMPACT, +} + +CopyMicromapModeEXT :: enum c.int { + CLONE = 0, + SERIALIZE = 1, + DESERIALIZE = 2, + COMPACT = 3, +} + +CoverageModulationModeNV :: enum c.int { + NONE = 0, + RGB = 1, + ALPHA = 2, + RGBA = 3, +} + +CoverageReductionModeNV :: enum c.int { + MERGE = 0, + TRUNCATE = 1, +} + +CullModeFlags :: distinct bit_set[CullModeFlag; Flags] +CullModeFlag :: enum Flags { + FRONT = 0, + BACK = 1, +} + +CullModeFlags_NONE :: CullModeFlags{} +CullModeFlags_FRONT_AND_BACK :: CullModeFlags{.FRONT, .BACK} + + +DebugReportFlagsEXT :: distinct bit_set[DebugReportFlagEXT; Flags] +DebugReportFlagEXT :: enum Flags { + INFORMATION = 0, + WARNING = 1, + PERFORMANCE_WARNING = 2, + ERROR = 3, + DEBUG = 4, +} + +DebugReportObjectTypeEXT :: enum c.int { + UNKNOWN = 0, + INSTANCE = 1, + PHYSICAL_DEVICE = 2, + DEVICE = 3, + QUEUE = 4, + SEMAPHORE = 5, + COMMAND_BUFFER = 6, + FENCE = 7, + DEVICE_MEMORY = 8, + BUFFER = 9, + IMAGE = 10, + EVENT = 11, + QUERY_POOL = 12, + BUFFER_VIEW = 13, + IMAGE_VIEW = 14, + SHADER_MODULE = 15, + PIPELINE_CACHE = 16, + PIPELINE_LAYOUT = 17, + RENDER_PASS = 18, + PIPELINE = 19, + DESCRIPTOR_SET_LAYOUT = 20, + SAMPLER = 21, + DESCRIPTOR_POOL = 22, + DESCRIPTOR_SET = 23, + FRAMEBUFFER = 24, + COMMAND_POOL = 25, + SURFACE_KHR = 26, + SWAPCHAIN_KHR = 27, + DEBUG_REPORT_CALLBACK_EXT = 28, + DISPLAY_KHR = 29, + DISPLAY_MODE_KHR = 30, + VALIDATION_CACHE_EXT = 33, + SAMPLER_YCBCR_CONVERSION = 1000156000, + DESCRIPTOR_UPDATE_TEMPLATE = 1000085000, + CU_MODULE_NVX = 1000029000, + CU_FUNCTION_NVX = 1000029001, + ACCELERATION_STRUCTURE_KHR = 1000150000, + ACCELERATION_STRUCTURE_NV = 1000165000, + BUFFER_COLLECTION_FUCHSIA = 1000366000, + DEBUG_REPORT = DEBUG_REPORT_CALLBACK_EXT, + VALIDATION_CACHE = VALIDATION_CACHE_EXT, + DESCRIPTOR_UPDATE_TEMPLATE_KHR = DESCRIPTOR_UPDATE_TEMPLATE, + SAMPLER_YCBCR_CONVERSION_KHR = SAMPLER_YCBCR_CONVERSION, +} + +DebugUtilsMessageSeverityFlagsEXT :: distinct bit_set[DebugUtilsMessageSeverityFlagEXT; Flags] +DebugUtilsMessageSeverityFlagEXT :: enum Flags { + VERBOSE = 0, + INFO = 4, + WARNING = 8, + ERROR = 12, +} + +DebugUtilsMessageTypeFlagsEXT :: distinct bit_set[DebugUtilsMessageTypeFlagEXT; Flags] +DebugUtilsMessageTypeFlagEXT :: enum Flags { + GENERAL = 0, + VALIDATION = 1, + PERFORMANCE = 2, + DEVICE_ADDRESS_BINDING = 3, +} + +DependencyFlags :: distinct bit_set[DependencyFlag; Flags] +DependencyFlag :: enum Flags { + BY_REGION = 0, + DEVICE_GROUP = 2, + VIEW_LOCAL = 1, + FEEDBACK_LOOP_EXT = 3, + VIEW_LOCAL_KHR = VIEW_LOCAL, + DEVICE_GROUP_KHR = DEVICE_GROUP, +} + +DescriptorBindingFlags :: distinct bit_set[DescriptorBindingFlag; Flags] +DescriptorBindingFlag :: enum Flags { + UPDATE_AFTER_BIND = 0, + UPDATE_UNUSED_WHILE_PENDING = 1, + PARTIALLY_BOUND = 2, + VARIABLE_DESCRIPTOR_COUNT = 3, + UPDATE_AFTER_BIND_EXT = UPDATE_AFTER_BIND, + UPDATE_UNUSED_WHILE_PENDING_EXT = UPDATE_UNUSED_WHILE_PENDING, + PARTIALLY_BOUND_EXT = PARTIALLY_BOUND, + VARIABLE_DESCRIPTOR_COUNT_EXT = VARIABLE_DESCRIPTOR_COUNT, +} + +DescriptorPoolCreateFlags :: distinct bit_set[DescriptorPoolCreateFlag; Flags] +DescriptorPoolCreateFlag :: enum Flags { + FREE_DESCRIPTOR_SET = 0, + UPDATE_AFTER_BIND = 1, + HOST_ONLY_EXT = 2, + UPDATE_AFTER_BIND_EXT = UPDATE_AFTER_BIND, + HOST_ONLY_VALVE = HOST_ONLY_EXT, +} + +DescriptorSetLayoutCreateFlags :: distinct bit_set[DescriptorSetLayoutCreateFlag; Flags] +DescriptorSetLayoutCreateFlag :: enum Flags { + UPDATE_AFTER_BIND_POOL = 1, + PUSH_DESCRIPTOR_KHR = 0, + DESCRIPTOR_BUFFER_EXT = 4, + EMBEDDED_IMMUTABLE_SAMPLERS_EXT = 5, + HOST_ONLY_POOL_EXT = 2, + UPDATE_AFTER_BIND_POOL_EXT = UPDATE_AFTER_BIND_POOL, + HOST_ONLY_POOL_VALVE = HOST_ONLY_POOL_EXT, +} + +DescriptorType :: enum c.int { + SAMPLER = 0, + COMBINED_IMAGE_SAMPLER = 1, + SAMPLED_IMAGE = 2, + STORAGE_IMAGE = 3, + UNIFORM_TEXEL_BUFFER = 4, + STORAGE_TEXEL_BUFFER = 5, + UNIFORM_BUFFER = 6, + STORAGE_BUFFER = 7, + UNIFORM_BUFFER_DYNAMIC = 8, + STORAGE_BUFFER_DYNAMIC = 9, + INPUT_ATTACHMENT = 10, + INLINE_UNIFORM_BLOCK = 1000138000, + ACCELERATION_STRUCTURE_KHR = 1000150000, + ACCELERATION_STRUCTURE_NV = 1000165000, + SAMPLE_WEIGHT_IMAGE_QCOM = 1000440000, + BLOCK_MATCH_IMAGE_QCOM = 1000440001, + MUTABLE_EXT = 1000351000, + INLINE_UNIFORM_BLOCK_EXT = INLINE_UNIFORM_BLOCK, + MUTABLE_VALVE = MUTABLE_EXT, +} + +DescriptorUpdateTemplateType :: enum c.int { + DESCRIPTOR_SET = 0, + PUSH_DESCRIPTORS_KHR = 1, + DESCRIPTOR_SET_KHR = DESCRIPTOR_SET, +} + +DeviceAddressBindingFlagsEXT :: distinct bit_set[DeviceAddressBindingFlagEXT; Flags] +DeviceAddressBindingFlagEXT :: enum Flags { + INTERNAL_OBJECT = 0, +} + +DeviceAddressBindingTypeEXT :: enum c.int { + BIND = 0, + UNBIND = 1, +} + +DeviceDiagnosticsConfigFlagsNV :: distinct bit_set[DeviceDiagnosticsConfigFlagNV; Flags] +DeviceDiagnosticsConfigFlagNV :: enum Flags { + ENABLE_SHADER_DEBUG_INFO = 0, + ENABLE_RESOURCE_TRACKING = 1, + ENABLE_AUTOMATIC_CHECKPOINTS = 2, + ENABLE_SHADER_ERROR_REPORTING = 3, +} + +DeviceEventTypeEXT :: enum c.int { + DISPLAY_HOTPLUG = 0, +} + +DeviceFaultAddressTypeEXT :: enum c.int { + NONE = 0, + READ_INVALID = 1, + WRITE_INVALID = 2, + EXECUTE_INVALID = 3, + INSTRUCTION_POINTER_UNKNOWN = 4, + INSTRUCTION_POINTER_INVALID = 5, + INSTRUCTION_POINTER_FAULT = 6, +} + +DeviceFaultVendorBinaryHeaderVersionEXT :: enum c.int { + ONE = 1, +} + +DeviceGroupPresentModeFlagsKHR :: distinct bit_set[DeviceGroupPresentModeFlagKHR; Flags] +DeviceGroupPresentModeFlagKHR :: enum Flags { + LOCAL = 0, + REMOTE = 1, + SUM = 2, + LOCAL_MULTI_DEVICE = 3, +} + +DeviceMemoryReportEventTypeEXT :: enum c.int { + ALLOCATE = 0, + FREE = 1, + IMPORT = 2, + UNIMPORT = 3, + ALLOCATION_FAILED = 4, +} + +DeviceQueueCreateFlags :: distinct bit_set[DeviceQueueCreateFlag; Flags] +DeviceQueueCreateFlag :: enum Flags { + PROTECTED = 0, +} + +DirectDriverLoadingModeLUNARG :: enum c.int { + DIRECT_DRIVER_LOADING_MODE_EXCLUSIVE_LUNARG = 0, + DIRECT_DRIVER_LOADING_MODE_INCLUSIVE_LUNARG = 1, +} + +DiscardRectangleModeEXT :: enum c.int { + INCLUSIVE = 0, + EXCLUSIVE = 1, +} + +DisplayEventTypeEXT :: enum c.int { + FIRST_PIXEL_OUT = 0, +} + +DisplayPlaneAlphaFlagsKHR :: distinct bit_set[DisplayPlaneAlphaFlagKHR; Flags] +DisplayPlaneAlphaFlagKHR :: enum Flags { + OPAQUE = 0, + GLOBAL = 1, + PER_PIXEL = 2, + PER_PIXEL_PREMULTIPLIED = 3, +} + +DisplayPowerStateEXT :: enum c.int { + OFF = 0, + SUSPEND = 1, + ON = 2, +} + +DriverId :: enum c.int { + AMD_PROPRIETARY = 1, + AMD_OPEN_SOURCE = 2, + MESA_RADV = 3, + NVIDIA_PROPRIETARY = 4, + INTEL_PROPRIETARY_WINDOWS = 5, + INTEL_OPEN_SOURCE_MESA = 6, + IMAGINATION_PROPRIETARY = 7, + QUALCOMM_PROPRIETARY = 8, + ARM_PROPRIETARY = 9, + GOOGLE_SWIFTSHADER = 10, + GGP_PROPRIETARY = 11, + BROADCOM_PROPRIETARY = 12, + MESA_LLVMPIPE = 13, + MOLTENVK = 14, + COREAVI_PROPRIETARY = 15, + JUICE_PROPRIETARY = 16, + VERISILICON_PROPRIETARY = 17, + MESA_TURNIP = 18, + MESA_V3DV = 19, + MESA_PANVK = 20, + SAMSUNG_PROPRIETARY = 21, + MESA_VENUS = 22, + MESA_DOZEN = 23, + MESA_NVK = 24, + IMAGINATION_OPEN_SOURCE_MESA = 25, + AMD_PROPRIETARY_KHR = AMD_PROPRIETARY, + AMD_OPEN_SOURCE_KHR = AMD_OPEN_SOURCE, + MESA_RADV_KHR = MESA_RADV, + NVIDIA_PROPRIETARY_KHR = NVIDIA_PROPRIETARY, + INTEL_PROPRIETARY_WINDOWS_KHR = INTEL_PROPRIETARY_WINDOWS, + INTEL_OPEN_SOURCE_MESA_KHR = INTEL_OPEN_SOURCE_MESA, + IMAGINATION_PROPRIETARY_KHR = IMAGINATION_PROPRIETARY, + QUALCOMM_PROPRIETARY_KHR = QUALCOMM_PROPRIETARY, + ARM_PROPRIETARY_KHR = ARM_PROPRIETARY, + GOOGLE_SWIFTSHADER_KHR = GOOGLE_SWIFTSHADER, + GGP_PROPRIETARY_KHR = GGP_PROPRIETARY, + BROADCOM_PROPRIETARY_KHR = BROADCOM_PROPRIETARY, +} + +DynamicState :: enum c.int { + VIEWPORT = 0, + SCISSOR = 1, + LINE_WIDTH = 2, + DEPTH_BIAS = 3, + BLEND_CONSTANTS = 4, + DEPTH_BOUNDS = 5, + STENCIL_COMPARE_MASK = 6, + STENCIL_WRITE_MASK = 7, + STENCIL_REFERENCE = 8, + CULL_MODE = 1000267000, + FRONT_FACE = 1000267001, + PRIMITIVE_TOPOLOGY = 1000267002, + VIEWPORT_WITH_COUNT = 1000267003, + SCISSOR_WITH_COUNT = 1000267004, + VERTEX_INPUT_BINDING_STRIDE = 1000267005, + DEPTH_TEST_ENABLE = 1000267006, + DEPTH_WRITE_ENABLE = 1000267007, + DEPTH_COMPARE_OP = 1000267008, + DEPTH_BOUNDS_TEST_ENABLE = 1000267009, + STENCIL_TEST_ENABLE = 1000267010, + STENCIL_OP = 1000267011, + RASTERIZER_DISCARD_ENABLE = 1000377001, + DEPTH_BIAS_ENABLE = 1000377002, + PRIMITIVE_RESTART_ENABLE = 1000377004, + VIEWPORT_W_SCALING_NV = 1000087000, + DISCARD_RECTANGLE_EXT = 1000099000, + DISCARD_RECTANGLE_ENABLE_EXT = 1000099001, + DISCARD_RECTANGLE_MODE_EXT = 1000099002, + SAMPLE_LOCATIONS_EXT = 1000143000, + RAY_TRACING_PIPELINE_STACK_SIZE_KHR = 1000347000, + VIEWPORT_SHADING_RATE_PALETTE_NV = 1000164004, + VIEWPORT_COARSE_SAMPLE_ORDER_NV = 1000164006, + EXCLUSIVE_SCISSOR_ENABLE_NV = 1000205000, + EXCLUSIVE_SCISSOR_NV = 1000205001, + FRAGMENT_SHADING_RATE_KHR = 1000226000, + LINE_STIPPLE_EXT = 1000259000, + VERTEX_INPUT_EXT = 1000352000, + PATCH_CONTROL_POINTS_EXT = 1000377000, + LOGIC_OP_EXT = 1000377003, + COLOR_WRITE_ENABLE_EXT = 1000381000, + TESSELLATION_DOMAIN_ORIGIN_EXT = 1000455002, + DEPTH_CLAMP_ENABLE_EXT = 1000455003, + POLYGON_MODE_EXT = 1000455004, + RASTERIZATION_SAMPLES_EXT = 1000455005, + SAMPLE_MASK_EXT = 1000455006, + ALPHA_TO_COVERAGE_ENABLE_EXT = 1000455007, + ALPHA_TO_ONE_ENABLE_EXT = 1000455008, + LOGIC_OP_ENABLE_EXT = 1000455009, + COLOR_BLEND_ENABLE_EXT = 1000455010, + COLOR_BLEND_EQUATION_EXT = 1000455011, + COLOR_WRITE_MASK_EXT = 1000455012, + RASTERIZATION_STREAM_EXT = 1000455013, + CONSERVATIVE_RASTERIZATION_MODE_EXT = 1000455014, + EXTRA_PRIMITIVE_OVERESTIMATION_SIZE_EXT = 1000455015, + DEPTH_CLIP_ENABLE_EXT = 1000455016, + SAMPLE_LOCATIONS_ENABLE_EXT = 1000455017, + COLOR_BLEND_ADVANCED_EXT = 1000455018, + PROVOKING_VERTEX_MODE_EXT = 1000455019, + LINE_RASTERIZATION_MODE_EXT = 1000455020, + LINE_STIPPLE_ENABLE_EXT = 1000455021, + DEPTH_CLIP_NEGATIVE_ONE_TO_ONE_EXT = 1000455022, + VIEWPORT_W_SCALING_ENABLE_NV = 1000455023, + VIEWPORT_SWIZZLE_NV = 1000455024, + COVERAGE_TO_COLOR_ENABLE_NV = 1000455025, + COVERAGE_TO_COLOR_LOCATION_NV = 1000455026, + COVERAGE_MODULATION_MODE_NV = 1000455027, + COVERAGE_MODULATION_TABLE_ENABLE_NV = 1000455028, + COVERAGE_MODULATION_TABLE_NV = 1000455029, + SHADING_RATE_IMAGE_ENABLE_NV = 1000455030, + REPRESENTATIVE_FRAGMENT_TEST_ENABLE_NV = 1000455031, + COVERAGE_REDUCTION_MODE_NV = 1000455032, + ATTACHMENT_FEEDBACK_LOOP_ENABLE_EXT = 1000524000, + CULL_MODE_EXT = CULL_MODE, + FRONT_FACE_EXT = FRONT_FACE, + PRIMITIVE_TOPOLOGY_EXT = PRIMITIVE_TOPOLOGY, + VIEWPORT_WITH_COUNT_EXT = VIEWPORT_WITH_COUNT, + SCISSOR_WITH_COUNT_EXT = SCISSOR_WITH_COUNT, + VERTEX_INPUT_BINDING_STRIDE_EXT = VERTEX_INPUT_BINDING_STRIDE, + DEPTH_TEST_ENABLE_EXT = DEPTH_TEST_ENABLE, + DEPTH_WRITE_ENABLE_EXT = DEPTH_WRITE_ENABLE, + DEPTH_COMPARE_OP_EXT = DEPTH_COMPARE_OP, + DEPTH_BOUNDS_TEST_ENABLE_EXT = DEPTH_BOUNDS_TEST_ENABLE, + STENCIL_TEST_ENABLE_EXT = STENCIL_TEST_ENABLE, + STENCIL_OP_EXT = STENCIL_OP, + RASTERIZER_DISCARD_ENABLE_EXT = RASTERIZER_DISCARD_ENABLE, + DEPTH_BIAS_ENABLE_EXT = DEPTH_BIAS_ENABLE, + PRIMITIVE_RESTART_ENABLE_EXT = PRIMITIVE_RESTART_ENABLE, +} + +EventCreateFlags :: distinct bit_set[EventCreateFlag; Flags] +EventCreateFlag :: enum Flags { + DEVICE_ONLY = 0, + DEVICE_ONLY_KHR = DEVICE_ONLY, +} + +ExportMetalObjectTypeFlagsEXT :: distinct bit_set[ExportMetalObjectTypeFlagEXT; Flags] +ExportMetalObjectTypeFlagEXT :: enum Flags { + METAL_DEVICE = 0, + METAL_COMMAND_QUEUE = 1, + METAL_BUFFER = 2, + METAL_TEXTURE = 3, + METAL_IOSURFACE = 4, + METAL_SHARED_EVENT = 5, +} + +ExternalFenceFeatureFlags :: distinct bit_set[ExternalFenceFeatureFlag; Flags] +ExternalFenceFeatureFlag :: enum Flags { + EXPORTABLE = 0, + IMPORTABLE = 1, + EXPORTABLE_KHR = EXPORTABLE, + IMPORTABLE_KHR = IMPORTABLE, +} + +ExternalFenceHandleTypeFlags :: distinct bit_set[ExternalFenceHandleTypeFlag; Flags] +ExternalFenceHandleTypeFlag :: enum Flags { + OPAQUE_FD = 0, + OPAQUE_WIN32 = 1, + OPAQUE_WIN32_KMT = 2, + SYNC_FD = 3, + OPAQUE_FD_KHR = OPAQUE_FD, + OPAQUE_WIN32_KHR = OPAQUE_WIN32, + OPAQUE_WIN32_KMT_KHR = OPAQUE_WIN32_KMT, + SYNC_FD_KHR = SYNC_FD, +} + +ExternalMemoryFeatureFlags :: distinct bit_set[ExternalMemoryFeatureFlag; Flags] +ExternalMemoryFeatureFlag :: enum Flags { + DEDICATED_ONLY = 0, + EXPORTABLE = 1, + IMPORTABLE = 2, + DEDICATED_ONLY_KHR = DEDICATED_ONLY, + EXPORTABLE_KHR = EXPORTABLE, + IMPORTABLE_KHR = IMPORTABLE, +} + +ExternalMemoryFeatureFlagsNV :: distinct bit_set[ExternalMemoryFeatureFlagNV; Flags] +ExternalMemoryFeatureFlagNV :: enum Flags { + DEDICATED_ONLY = 0, + EXPORTABLE = 1, + IMPORTABLE = 2, +} + +ExternalMemoryHandleTypeFlags :: distinct bit_set[ExternalMemoryHandleTypeFlag; Flags] +ExternalMemoryHandleTypeFlag :: enum Flags { + OPAQUE_FD = 0, + OPAQUE_WIN32 = 1, + OPAQUE_WIN32_KMT = 2, + D3D11_TEXTURE = 3, + D3D11_TEXTURE_KMT = 4, + D3D12_HEAP = 5, + D3D12_RESOURCE = 6, + DMA_BUF_EXT = 9, + ANDROID_HARDWARE_BUFFER_ANDROID = 10, + HOST_ALLOCATION_EXT = 7, + HOST_MAPPED_FOREIGN_MEMORY_EXT = 8, + ZIRCON_VMO_FUCHSIA = 11, + RDMA_ADDRESS_NV = 12, + OPAQUE_FD_KHR = OPAQUE_FD, + OPAQUE_WIN32_KHR = OPAQUE_WIN32, + OPAQUE_WIN32_KMT_KHR = OPAQUE_WIN32_KMT, + D3D11_TEXTURE_KHR = D3D11_TEXTURE, + D3D11_TEXTURE_KMT_KHR = D3D11_TEXTURE_KMT, + D3D12_HEAP_KHR = D3D12_HEAP, + D3D12_RESOURCE_KHR = D3D12_RESOURCE, +} + +ExternalMemoryHandleTypeFlagsNV :: distinct bit_set[ExternalMemoryHandleTypeFlagNV; Flags] +ExternalMemoryHandleTypeFlagNV :: enum Flags { + OPAQUE_WIN32 = 0, + OPAQUE_WIN32_KMT = 1, + D3D11_IMAGE = 2, + D3D11_IMAGE_KMT = 3, +} + +ExternalSemaphoreFeatureFlags :: distinct bit_set[ExternalSemaphoreFeatureFlag; Flags] +ExternalSemaphoreFeatureFlag :: enum Flags { + EXPORTABLE = 0, + IMPORTABLE = 1, + EXPORTABLE_KHR = EXPORTABLE, + IMPORTABLE_KHR = IMPORTABLE, +} + +ExternalSemaphoreHandleTypeFlags :: distinct bit_set[ExternalSemaphoreHandleTypeFlag; Flags] +ExternalSemaphoreHandleTypeFlag :: enum Flags { + OPAQUE_FD = 0, + OPAQUE_WIN32 = 1, + OPAQUE_WIN32_KMT = 2, + D3D12_FENCE = 3, + SYNC_FD = 4, + ZIRCON_EVENT_FUCHSIA = 7, + D3D11_FENCE = D3D12_FENCE, + OPAQUE_FD_KHR = OPAQUE_FD, + OPAQUE_WIN32_KHR = OPAQUE_WIN32, + OPAQUE_WIN32_KMT_KHR = OPAQUE_WIN32_KMT, + D3D12_FENCE_KHR = D3D12_FENCE, + SYNC_FD_KHR = SYNC_FD, +} + +FenceCreateFlags :: distinct bit_set[FenceCreateFlag; Flags] +FenceCreateFlag :: enum Flags { + SIGNALED = 0, +} + +FenceImportFlags :: distinct bit_set[FenceImportFlag; Flags] +FenceImportFlag :: enum Flags { + TEMPORARY = 0, + TEMPORARY_KHR = TEMPORARY, +} + +Filter :: enum c.int { + NEAREST = 0, + LINEAR = 1, + CUBIC_EXT = 1000015000, + CUBIC_IMG = CUBIC_EXT, +} + +Format :: enum c.int { + UNDEFINED = 0, + R4G4_UNORM_PACK8 = 1, + R4G4B4A4_UNORM_PACK16 = 2, + B4G4R4A4_UNORM_PACK16 = 3, + R5G6B5_UNORM_PACK16 = 4, + B5G6R5_UNORM_PACK16 = 5, + R5G5B5A1_UNORM_PACK16 = 6, + B5G5R5A1_UNORM_PACK16 = 7, + A1R5G5B5_UNORM_PACK16 = 8, + R8_UNORM = 9, + R8_SNORM = 10, + R8_USCALED = 11, + R8_SSCALED = 12, + R8_UINT = 13, + R8_SINT = 14, + R8_SRGB = 15, + R8G8_UNORM = 16, + R8G8_SNORM = 17, + R8G8_USCALED = 18, + R8G8_SSCALED = 19, + R8G8_UINT = 20, + R8G8_SINT = 21, + R8G8_SRGB = 22, + R8G8B8_UNORM = 23, + R8G8B8_SNORM = 24, + R8G8B8_USCALED = 25, + R8G8B8_SSCALED = 26, + R8G8B8_UINT = 27, + R8G8B8_SINT = 28, + R8G8B8_SRGB = 29, + B8G8R8_UNORM = 30, + B8G8R8_SNORM = 31, + B8G8R8_USCALED = 32, + B8G8R8_SSCALED = 33, + B8G8R8_UINT = 34, + B8G8R8_SINT = 35, + B8G8R8_SRGB = 36, + R8G8B8A8_UNORM = 37, + R8G8B8A8_SNORM = 38, + R8G8B8A8_USCALED = 39, + R8G8B8A8_SSCALED = 40, + R8G8B8A8_UINT = 41, + R8G8B8A8_SINT = 42, + R8G8B8A8_SRGB = 43, + B8G8R8A8_UNORM = 44, + B8G8R8A8_SNORM = 45, + B8G8R8A8_USCALED = 46, + B8G8R8A8_SSCALED = 47, + B8G8R8A8_UINT = 48, + B8G8R8A8_SINT = 49, + B8G8R8A8_SRGB = 50, + A8B8G8R8_UNORM_PACK32 = 51, + A8B8G8R8_SNORM_PACK32 = 52, + A8B8G8R8_USCALED_PACK32 = 53, + A8B8G8R8_SSCALED_PACK32 = 54, + A8B8G8R8_UINT_PACK32 = 55, + A8B8G8R8_SINT_PACK32 = 56, + A8B8G8R8_SRGB_PACK32 = 57, + A2R10G10B10_UNORM_PACK32 = 58, + A2R10G10B10_SNORM_PACK32 = 59, + A2R10G10B10_USCALED_PACK32 = 60, + A2R10G10B10_SSCALED_PACK32 = 61, + A2R10G10B10_UINT_PACK32 = 62, + A2R10G10B10_SINT_PACK32 = 63, + A2B10G10R10_UNORM_PACK32 = 64, + A2B10G10R10_SNORM_PACK32 = 65, + A2B10G10R10_USCALED_PACK32 = 66, + A2B10G10R10_SSCALED_PACK32 = 67, + A2B10G10R10_UINT_PACK32 = 68, + A2B10G10R10_SINT_PACK32 = 69, + R16_UNORM = 70, + R16_SNORM = 71, + R16_USCALED = 72, + R16_SSCALED = 73, + R16_UINT = 74, + R16_SINT = 75, + R16_SFLOAT = 76, + R16G16_UNORM = 77, + R16G16_SNORM = 78, + R16G16_USCALED = 79, + R16G16_SSCALED = 80, + R16G16_UINT = 81, + R16G16_SINT = 82, + R16G16_SFLOAT = 83, + R16G16B16_UNORM = 84, + R16G16B16_SNORM = 85, + R16G16B16_USCALED = 86, + R16G16B16_SSCALED = 87, + R16G16B16_UINT = 88, + R16G16B16_SINT = 89, + R16G16B16_SFLOAT = 90, + R16G16B16A16_UNORM = 91, + R16G16B16A16_SNORM = 92, + R16G16B16A16_USCALED = 93, + R16G16B16A16_SSCALED = 94, + R16G16B16A16_UINT = 95, + R16G16B16A16_SINT = 96, + R16G16B16A16_SFLOAT = 97, + R32_UINT = 98, + R32_SINT = 99, + R32_SFLOAT = 100, + R32G32_UINT = 101, + R32G32_SINT = 102, + R32G32_SFLOAT = 103, + R32G32B32_UINT = 104, + R32G32B32_SINT = 105, + R32G32B32_SFLOAT = 106, + R32G32B32A32_UINT = 107, + R32G32B32A32_SINT = 108, + R32G32B32A32_SFLOAT = 109, + R64_UINT = 110, + R64_SINT = 111, + R64_SFLOAT = 112, + R64G64_UINT = 113, + R64G64_SINT = 114, + R64G64_SFLOAT = 115, + R64G64B64_UINT = 116, + R64G64B64_SINT = 117, + R64G64B64_SFLOAT = 118, + R64G64B64A64_UINT = 119, + R64G64B64A64_SINT = 120, + R64G64B64A64_SFLOAT = 121, + B10G11R11_UFLOAT_PACK32 = 122, + E5B9G9R9_UFLOAT_PACK32 = 123, + D16_UNORM = 124, + X8_D24_UNORM_PACK32 = 125, + D32_SFLOAT = 126, + S8_UINT = 127, + D16_UNORM_S8_UINT = 128, + D24_UNORM_S8_UINT = 129, + D32_SFLOAT_S8_UINT = 130, + BC1_RGB_UNORM_BLOCK = 131, + BC1_RGB_SRGB_BLOCK = 132, + BC1_RGBA_UNORM_BLOCK = 133, + BC1_RGBA_SRGB_BLOCK = 134, + BC2_UNORM_BLOCK = 135, + BC2_SRGB_BLOCK = 136, + BC3_UNORM_BLOCK = 137, + BC3_SRGB_BLOCK = 138, + BC4_UNORM_BLOCK = 139, + BC4_SNORM_BLOCK = 140, + BC5_UNORM_BLOCK = 141, + BC5_SNORM_BLOCK = 142, + BC6H_UFLOAT_BLOCK = 143, + BC6H_SFLOAT_BLOCK = 144, + BC7_UNORM_BLOCK = 145, + BC7_SRGB_BLOCK = 146, + ETC2_R8G8B8_UNORM_BLOCK = 147, + ETC2_R8G8B8_SRGB_BLOCK = 148, + ETC2_R8G8B8A1_UNORM_BLOCK = 149, + ETC2_R8G8B8A1_SRGB_BLOCK = 150, + ETC2_R8G8B8A8_UNORM_BLOCK = 151, + ETC2_R8G8B8A8_SRGB_BLOCK = 152, + EAC_R11_UNORM_BLOCK = 153, + EAC_R11_SNORM_BLOCK = 154, + EAC_R11G11_UNORM_BLOCK = 155, + EAC_R11G11_SNORM_BLOCK = 156, + ASTC_4x4_UNORM_BLOCK = 157, + ASTC_4x4_SRGB_BLOCK = 158, + ASTC_5x4_UNORM_BLOCK = 159, + ASTC_5x4_SRGB_BLOCK = 160, + ASTC_5x5_UNORM_BLOCK = 161, + ASTC_5x5_SRGB_BLOCK = 162, + ASTC_6x5_UNORM_BLOCK = 163, + ASTC_6x5_SRGB_BLOCK = 164, + ASTC_6x6_UNORM_BLOCK = 165, + ASTC_6x6_SRGB_BLOCK = 166, + ASTC_8x5_UNORM_BLOCK = 167, + ASTC_8x5_SRGB_BLOCK = 168, + ASTC_8x6_UNORM_BLOCK = 169, + ASTC_8x6_SRGB_BLOCK = 170, + ASTC_8x8_UNORM_BLOCK = 171, + ASTC_8x8_SRGB_BLOCK = 172, + ASTC_10x5_UNORM_BLOCK = 173, + ASTC_10x5_SRGB_BLOCK = 174, + ASTC_10x6_UNORM_BLOCK = 175, + ASTC_10x6_SRGB_BLOCK = 176, + ASTC_10x8_UNORM_BLOCK = 177, + ASTC_10x8_SRGB_BLOCK = 178, + ASTC_10x10_UNORM_BLOCK = 179, + ASTC_10x10_SRGB_BLOCK = 180, + ASTC_12x10_UNORM_BLOCK = 181, + ASTC_12x10_SRGB_BLOCK = 182, + ASTC_12x12_UNORM_BLOCK = 183, + ASTC_12x12_SRGB_BLOCK = 184, + G8B8G8R8_422_UNORM = 1000156000, + B8G8R8G8_422_UNORM = 1000156001, + G8_B8_R8_3PLANE_420_UNORM = 1000156002, + G8_B8R8_2PLANE_420_UNORM = 1000156003, + G8_B8_R8_3PLANE_422_UNORM = 1000156004, + G8_B8R8_2PLANE_422_UNORM = 1000156005, + G8_B8_R8_3PLANE_444_UNORM = 1000156006, + R10X6_UNORM_PACK16 = 1000156007, + R10X6G10X6_UNORM_2PACK16 = 1000156008, + R10X6G10X6B10X6A10X6_UNORM_4PACK16 = 1000156009, + G10X6B10X6G10X6R10X6_422_UNORM_4PACK16 = 1000156010, + B10X6G10X6R10X6G10X6_422_UNORM_4PACK16 = 1000156011, + G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16 = 1000156012, + G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16 = 1000156013, + G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16 = 1000156014, + G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16 = 1000156015, + G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16 = 1000156016, + R12X4_UNORM_PACK16 = 1000156017, + R12X4G12X4_UNORM_2PACK16 = 1000156018, + R12X4G12X4B12X4A12X4_UNORM_4PACK16 = 1000156019, + G12X4B12X4G12X4R12X4_422_UNORM_4PACK16 = 1000156020, + B12X4G12X4R12X4G12X4_422_UNORM_4PACK16 = 1000156021, + G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16 = 1000156022, + G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16 = 1000156023, + G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16 = 1000156024, + G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16 = 1000156025, + G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16 = 1000156026, + G16B16G16R16_422_UNORM = 1000156027, + B16G16R16G16_422_UNORM = 1000156028, + G16_B16_R16_3PLANE_420_UNORM = 1000156029, + G16_B16R16_2PLANE_420_UNORM = 1000156030, + G16_B16_R16_3PLANE_422_UNORM = 1000156031, + G16_B16R16_2PLANE_422_UNORM = 1000156032, + G16_B16_R16_3PLANE_444_UNORM = 1000156033, + G8_B8R8_2PLANE_444_UNORM = 1000330000, + G10X6_B10X6R10X6_2PLANE_444_UNORM_3PACK16 = 1000330001, + G12X4_B12X4R12X4_2PLANE_444_UNORM_3PACK16 = 1000330002, + G16_B16R16_2PLANE_444_UNORM = 1000330003, + A4R4G4B4_UNORM_PACK16 = 1000340000, + A4B4G4R4_UNORM_PACK16 = 1000340001, + ASTC_4x4_SFLOAT_BLOCK = 1000066000, + ASTC_5x4_SFLOAT_BLOCK = 1000066001, + ASTC_5x5_SFLOAT_BLOCK = 1000066002, + ASTC_6x5_SFLOAT_BLOCK = 1000066003, + ASTC_6x6_SFLOAT_BLOCK = 1000066004, + ASTC_8x5_SFLOAT_BLOCK = 1000066005, + ASTC_8x6_SFLOAT_BLOCK = 1000066006, + ASTC_8x8_SFLOAT_BLOCK = 1000066007, + ASTC_10x5_SFLOAT_BLOCK = 1000066008, + ASTC_10x6_SFLOAT_BLOCK = 1000066009, + ASTC_10x8_SFLOAT_BLOCK = 1000066010, + ASTC_10x10_SFLOAT_BLOCK = 1000066011, + ASTC_12x10_SFLOAT_BLOCK = 1000066012, + ASTC_12x12_SFLOAT_BLOCK = 1000066013, + PVRTC1_2BPP_UNORM_BLOCK_IMG = 1000054000, + PVRTC1_4BPP_UNORM_BLOCK_IMG = 1000054001, + PVRTC2_2BPP_UNORM_BLOCK_IMG = 1000054002, + PVRTC2_4BPP_UNORM_BLOCK_IMG = 1000054003, + PVRTC1_2BPP_SRGB_BLOCK_IMG = 1000054004, + PVRTC1_4BPP_SRGB_BLOCK_IMG = 1000054005, + PVRTC2_2BPP_SRGB_BLOCK_IMG = 1000054006, + PVRTC2_4BPP_SRGB_BLOCK_IMG = 1000054007, + R16G16_S10_5_NV = 1000464000, + ASTC_4x4_SFLOAT_BLOCK_EXT = ASTC_4x4_SFLOAT_BLOCK, + ASTC_5x4_SFLOAT_BLOCK_EXT = ASTC_5x4_SFLOAT_BLOCK, + ASTC_5x5_SFLOAT_BLOCK_EXT = ASTC_5x5_SFLOAT_BLOCK, + ASTC_6x5_SFLOAT_BLOCK_EXT = ASTC_6x5_SFLOAT_BLOCK, + ASTC_6x6_SFLOAT_BLOCK_EXT = ASTC_6x6_SFLOAT_BLOCK, + ASTC_8x5_SFLOAT_BLOCK_EXT = ASTC_8x5_SFLOAT_BLOCK, + ASTC_8x6_SFLOAT_BLOCK_EXT = ASTC_8x6_SFLOAT_BLOCK, + ASTC_8x8_SFLOAT_BLOCK_EXT = ASTC_8x8_SFLOAT_BLOCK, + ASTC_10x5_SFLOAT_BLOCK_EXT = ASTC_10x5_SFLOAT_BLOCK, + ASTC_10x6_SFLOAT_BLOCK_EXT = ASTC_10x6_SFLOAT_BLOCK, + ASTC_10x8_SFLOAT_BLOCK_EXT = ASTC_10x8_SFLOAT_BLOCK, + ASTC_10x10_SFLOAT_BLOCK_EXT = ASTC_10x10_SFLOAT_BLOCK, + ASTC_12x10_SFLOAT_BLOCK_EXT = ASTC_12x10_SFLOAT_BLOCK, + ASTC_12x12_SFLOAT_BLOCK_EXT = ASTC_12x12_SFLOAT_BLOCK, + G8B8G8R8_422_UNORM_KHR = G8B8G8R8_422_UNORM, + B8G8R8G8_422_UNORM_KHR = B8G8R8G8_422_UNORM, + G8_B8_R8_3PLANE_420_UNORM_KHR = G8_B8_R8_3PLANE_420_UNORM, + G8_B8R8_2PLANE_420_UNORM_KHR = G8_B8R8_2PLANE_420_UNORM, + G8_B8_R8_3PLANE_422_UNORM_KHR = G8_B8_R8_3PLANE_422_UNORM, + G8_B8R8_2PLANE_422_UNORM_KHR = G8_B8R8_2PLANE_422_UNORM, + G8_B8_R8_3PLANE_444_UNORM_KHR = G8_B8_R8_3PLANE_444_UNORM, + R10X6_UNORM_PACK16_KHR = R10X6_UNORM_PACK16, + R10X6G10X6_UNORM_2PACK16_KHR = R10X6G10X6_UNORM_2PACK16, + R10X6G10X6B10X6A10X6_UNORM_4PACK16_KHR = R10X6G10X6B10X6A10X6_UNORM_4PACK16, + G10X6B10X6G10X6R10X6_422_UNORM_4PACK16_KHR = G10X6B10X6G10X6R10X6_422_UNORM_4PACK16, + B10X6G10X6R10X6G10X6_422_UNORM_4PACK16_KHR = B10X6G10X6R10X6G10X6_422_UNORM_4PACK16, + G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16_KHR = G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16, + G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16_KHR = G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16, + G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16_KHR = G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16, + G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16_KHR = G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16, + G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16_KHR = G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16, + R12X4_UNORM_PACK16_KHR = R12X4_UNORM_PACK16, + R12X4G12X4_UNORM_2PACK16_KHR = R12X4G12X4_UNORM_2PACK16, + R12X4G12X4B12X4A12X4_UNORM_4PACK16_KHR = R12X4G12X4B12X4A12X4_UNORM_4PACK16, + G12X4B12X4G12X4R12X4_422_UNORM_4PACK16_KHR = G12X4B12X4G12X4R12X4_422_UNORM_4PACK16, + B12X4G12X4R12X4G12X4_422_UNORM_4PACK16_KHR = B12X4G12X4R12X4G12X4_422_UNORM_4PACK16, + G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16_KHR = G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16, + G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16_KHR = G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16, + G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16_KHR = G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16, + G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16_KHR = G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16, + G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16_KHR = G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16, + G16B16G16R16_422_UNORM_KHR = G16B16G16R16_422_UNORM, + B16G16R16G16_422_UNORM_KHR = B16G16R16G16_422_UNORM, + G16_B16_R16_3PLANE_420_UNORM_KHR = G16_B16_R16_3PLANE_420_UNORM, + G16_B16R16_2PLANE_420_UNORM_KHR = G16_B16R16_2PLANE_420_UNORM, + G16_B16_R16_3PLANE_422_UNORM_KHR = G16_B16_R16_3PLANE_422_UNORM, + G16_B16R16_2PLANE_422_UNORM_KHR = G16_B16R16_2PLANE_422_UNORM, + G16_B16_R16_3PLANE_444_UNORM_KHR = G16_B16_R16_3PLANE_444_UNORM, + G8_B8R8_2PLANE_444_UNORM_EXT = G8_B8R8_2PLANE_444_UNORM, + G10X6_B10X6R10X6_2PLANE_444_UNORM_3PACK16_EXT = G10X6_B10X6R10X6_2PLANE_444_UNORM_3PACK16, + G12X4_B12X4R12X4_2PLANE_444_UNORM_3PACK16_EXT = G12X4_B12X4R12X4_2PLANE_444_UNORM_3PACK16, + G16_B16R16_2PLANE_444_UNORM_EXT = G16_B16R16_2PLANE_444_UNORM, + A4R4G4B4_UNORM_PACK16_EXT = A4R4G4B4_UNORM_PACK16, + A4B4G4R4_UNORM_PACK16_EXT = A4B4G4R4_UNORM_PACK16, +} + +FormatFeatureFlags :: distinct bit_set[FormatFeatureFlag; Flags] +FormatFeatureFlag :: enum Flags { + SAMPLED_IMAGE = 0, + STORAGE_IMAGE = 1, + STORAGE_IMAGE_ATOMIC = 2, + UNIFORM_TEXEL_BUFFER = 3, + STORAGE_TEXEL_BUFFER = 4, + STORAGE_TEXEL_BUFFER_ATOMIC = 5, + VERTEX_BUFFER = 6, + COLOR_ATTACHMENT = 7, + COLOR_ATTACHMENT_BLEND = 8, + DEPTH_STENCIL_ATTACHMENT = 9, + BLIT_SRC = 10, + BLIT_DST = 11, + SAMPLED_IMAGE_FILTER_LINEAR = 12, + TRANSFER_SRC = 14, + TRANSFER_DST = 15, + MIDPOINT_CHROMA_SAMPLES = 17, + SAMPLED_IMAGE_YCBCR_CONVERSION_LINEAR_FILTER = 18, + SAMPLED_IMAGE_YCBCR_CONVERSION_SEPARATE_RECONSTRUCTION_FILTER = 19, + SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT = 20, + SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_FORCEABLE = 21, + DISJOINT = 22, + COSITED_CHROMA_SAMPLES = 23, + SAMPLED_IMAGE_FILTER_MINMAX = 16, + VIDEO_DECODE_OUTPUT_KHR = 25, + VIDEO_DECODE_DPB_KHR = 26, + ACCELERATION_STRUCTURE_VERTEX_BUFFER_KHR = 29, + SAMPLED_IMAGE_FILTER_CUBIC_EXT = 13, + FRAGMENT_DENSITY_MAP_EXT = 24, + FRAGMENT_SHADING_RATE_ATTACHMENT_KHR = 30, + VIDEO_ENCODE_INPUT_KHR = 27, + VIDEO_ENCODE_DPB_KHR = 28, + SAMPLED_IMAGE_FILTER_CUBIC_IMG = SAMPLED_IMAGE_FILTER_CUBIC_EXT, + TRANSFER_SRC_KHR = TRANSFER_SRC, + TRANSFER_DST_KHR = TRANSFER_DST, + SAMPLED_IMAGE_FILTER_MINMAX_EXT = SAMPLED_IMAGE_FILTER_MINMAX, + MIDPOINT_CHROMA_SAMPLES_KHR = MIDPOINT_CHROMA_SAMPLES, + SAMPLED_IMAGE_YCBCR_CONVERSION_LINEAR_FILTER_KHR = SAMPLED_IMAGE_YCBCR_CONVERSION_LINEAR_FILTER, + SAMPLED_IMAGE_YCBCR_CONVERSION_SEPARATE_RECONSTRUCTION_FILTER_KHR = SAMPLED_IMAGE_YCBCR_CONVERSION_SEPARATE_RECONSTRUCTION_FILTER, + SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_KHR = SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT, + SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_FORCEABLE_KHR = SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_FORCEABLE, + DISJOINT_KHR = DISJOINT, + COSITED_CHROMA_SAMPLES_KHR = COSITED_CHROMA_SAMPLES, +} + +FragmentShadingRateCombinerOpKHR :: enum c.int { + KEEP = 0, + REPLACE = 1, + MIN = 2, + MAX = 3, + MUL = 4, +} + +FragmentShadingRateNV :: enum c.int { + _1_INVOCATION_PER_PIXEL = 0, + _1_INVOCATION_PER_1X2_PIXELS = 1, + _1_INVOCATION_PER_2X1_PIXELS = 4, + _1_INVOCATION_PER_2X2_PIXELS = 5, + _1_INVOCATION_PER_2X4_PIXELS = 6, + _1_INVOCATION_PER_4X2_PIXELS = 9, + _1_INVOCATION_PER_4X4_PIXELS = 10, + _2_INVOCATIONS_PER_PIXEL = 11, + _4_INVOCATIONS_PER_PIXEL = 12, + _8_INVOCATIONS_PER_PIXEL = 13, + _16_INVOCATIONS_PER_PIXEL = 14, + NO_INVOCATIONS = 15, +} + +FragmentShadingRateTypeNV :: enum c.int { + FRAGMENT_SIZE = 0, + ENUMS = 1, +} + +FramebufferCreateFlags :: distinct bit_set[FramebufferCreateFlag; Flags] +FramebufferCreateFlag :: enum Flags { + IMAGELESS = 0, + IMAGELESS_KHR = IMAGELESS, +} + +FrontFace :: enum c.int { + COUNTER_CLOCKWISE = 0, + CLOCKWISE = 1, +} + +FullScreenExclusiveEXT :: enum c.int { + DEFAULT = 0, + ALLOWED = 1, + DISALLOWED = 2, + APPLICATION_CONTROLLED = 3, +} + +GeometryFlagsKHR :: distinct bit_set[GeometryFlagKHR; Flags] +GeometryFlagKHR :: enum Flags { + OPAQUE = 0, + NO_DUPLICATE_ANY_HIT_INVOCATION = 1, + OPAQUE_NV = OPAQUE, + NO_DUPLICATE_ANY_HIT_INVOCATION_NV = NO_DUPLICATE_ANY_HIT_INVOCATION, +} + +GeometryInstanceFlagsKHR :: distinct bit_set[GeometryInstanceFlagKHR; Flags] +GeometryInstanceFlagKHR :: enum Flags { + TRIANGLE_FACING_CULL_DISABLE = 0, + TRIANGLE_FLIP_FACING = 1, + FORCE_OPAQUE = 2, + FORCE_NO_OPAQUE = 3, + FORCE_OPACITY_MICROMAP_2_STATE_EXT = 4, + DISABLE_OPACITY_MICROMAPS_EXT = 5, + TRIANGLE_FRONT_COUNTERCLOCKWISE = TRIANGLE_FLIP_FACING, + TRIANGLE_CULL_DISABLE_NV = TRIANGLE_FACING_CULL_DISABLE, + TRIANGLE_FRONT_COUNTERCLOCKWISE_NV = TRIANGLE_FRONT_COUNTERCLOCKWISE, + FORCE_OPAQUE_NV = FORCE_OPAQUE, + FORCE_NO_OPAQUE_NV = FORCE_NO_OPAQUE, +} + +GeometryTypeKHR :: enum c.int { + TRIANGLES = 0, + AABBS = 1, + INSTANCES = 2, + TRIANGLES_NV = TRIANGLES, + AABBS_NV = AABBS, +} + +GraphicsPipelineLibraryFlagsEXT :: distinct bit_set[GraphicsPipelineLibraryFlagEXT; Flags] +GraphicsPipelineLibraryFlagEXT :: enum Flags { + VERTEX_INPUT_INTERFACE = 0, + PRE_RASTERIZATION_SHADERS = 1, + FRAGMENT_SHADER = 2, + FRAGMENT_OUTPUT_INTERFACE = 3, +} + +ImageAspectFlags :: distinct bit_set[ImageAspectFlag; Flags] +ImageAspectFlag :: enum Flags { + COLOR = 0, + DEPTH = 1, + STENCIL = 2, + METADATA = 3, + PLANE_0 = 4, + PLANE_1 = 5, + PLANE_2 = 6, + MEMORY_PLANE_0_EXT = 7, + MEMORY_PLANE_1_EXT = 8, + MEMORY_PLANE_2_EXT = 9, + MEMORY_PLANE_3_EXT = 10, + PLANE_0_KHR = PLANE_0, + PLANE_1_KHR = PLANE_1, + PLANE_2_KHR = PLANE_2, +} + +ImageAspectFlags_NONE :: ImageAspectFlags{} + + +ImageCompressionFixedRateFlagsEXT :: distinct bit_set[ImageCompressionFixedRateFlagEXT; Flags] +ImageCompressionFixedRateFlagEXT :: enum Flags { + _1BPC = 0, + _2BPC = 1, + _3BPC = 2, + _4BPC = 3, + _5BPC = 4, + _6BPC = 5, + _7BPC = 6, + _8BPC = 7, + _9BPC = 8, + _10BPC = 9, + _11BPC = 10, + _12BPC = 11, + _13BPC = 12, + _14BPC = 13, + _15BPC = 14, + _16BPC = 15, + _17BPC = 16, + _18BPC = 17, + _19BPC = 18, + _20BPC = 19, + _21BPC = 20, + _22BPC = 21, + _23BPC = 22, + _24BPC = 23, +} + +ImageCompressionFixedRateFlagsEXT_NONE :: ImageCompressionFixedRateFlagsEXT{} + + +ImageCompressionFlagsEXT :: distinct bit_set[ImageCompressionFlagEXT; Flags] +ImageCompressionFlagEXT :: enum Flags { + FIXED_RATE_DEFAULT = 0, + FIXED_RATE_EXPLICIT = 1, + DISABLED = 2, +} + +ImageCompressionFlagsEXT_DEFAULT :: ImageCompressionFlagsEXT{} + + +ImageCreateFlags :: distinct bit_set[ImageCreateFlag; Flags] +ImageCreateFlag :: enum Flags { + SPARSE_BINDING = 0, + SPARSE_RESIDENCY = 1, + SPARSE_ALIASED = 2, + MUTABLE_FORMAT = 3, + CUBE_COMPATIBLE = 4, + ALIAS = 10, + SPLIT_INSTANCE_BIND_REGIONS = 6, + D2_ARRAY_COMPATIBLE = 5, + BLOCK_TEXEL_VIEW_COMPATIBLE = 7, + EXTENDED_USAGE = 8, + PROTECTED = 11, + DISJOINT = 9, + CORNER_SAMPLED_NV = 13, + SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_EXT = 12, + SUBSAMPLED_EXT = 14, + DESCRIPTOR_BUFFER_CAPTURE_REPLAY_EXT = 16, + MULTISAMPLED_RENDER_TO_SINGLE_SAMPLED_EXT = 18, + D2_VIEW_COMPATIBLE_EXT = 17, + FRAGMENT_DENSITY_MAP_OFFSET_QCOM = 15, + SPLIT_INSTANCE_BIND_REGIONS_KHR = SPLIT_INSTANCE_BIND_REGIONS, + D2_ARRAY_COMPATIBLE_KHR = D2_ARRAY_COMPATIBLE, + BLOCK_TEXEL_VIEW_COMPATIBLE_KHR = BLOCK_TEXEL_VIEW_COMPATIBLE, + EXTENDED_USAGE_KHR = EXTENDED_USAGE, + DISJOINT_KHR = DISJOINT, + ALIAS_KHR = ALIAS, +} + +ImageLayout :: enum c.int { + UNDEFINED = 0, + GENERAL = 1, + COLOR_ATTACHMENT_OPTIMAL = 2, + DEPTH_STENCIL_ATTACHMENT_OPTIMAL = 3, + DEPTH_STENCIL_READ_ONLY_OPTIMAL = 4, + SHADER_READ_ONLY_OPTIMAL = 5, + TRANSFER_SRC_OPTIMAL = 6, + TRANSFER_DST_OPTIMAL = 7, + PREINITIALIZED = 8, + DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL = 1000117000, + DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL = 1000117001, + DEPTH_ATTACHMENT_OPTIMAL = 1000241000, + DEPTH_READ_ONLY_OPTIMAL = 1000241001, + STENCIL_ATTACHMENT_OPTIMAL = 1000241002, + STENCIL_READ_ONLY_OPTIMAL = 1000241003, + READ_ONLY_OPTIMAL = 1000314000, + ATTACHMENT_OPTIMAL = 1000314001, + PRESENT_SRC_KHR = 1000001002, + VIDEO_DECODE_DST_KHR = 1000024000, + VIDEO_DECODE_SRC_KHR = 1000024001, + VIDEO_DECODE_DPB_KHR = 1000024002, + SHARED_PRESENT_KHR = 1000111000, + FRAGMENT_DENSITY_MAP_OPTIMAL_EXT = 1000218000, + FRAGMENT_SHADING_RATE_ATTACHMENT_OPTIMAL_KHR = 1000164003, + VIDEO_ENCODE_DST_KHR = 1000299000, + VIDEO_ENCODE_SRC_KHR = 1000299001, + VIDEO_ENCODE_DPB_KHR = 1000299002, + ATTACHMENT_FEEDBACK_LOOP_OPTIMAL_EXT = 1000339000, + DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR = DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL, + DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR = DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL, + SHADING_RATE_OPTIMAL_NV = FRAGMENT_SHADING_RATE_ATTACHMENT_OPTIMAL_KHR, + DEPTH_ATTACHMENT_OPTIMAL_KHR = DEPTH_ATTACHMENT_OPTIMAL, + DEPTH_READ_ONLY_OPTIMAL_KHR = DEPTH_READ_ONLY_OPTIMAL, + STENCIL_ATTACHMENT_OPTIMAL_KHR = STENCIL_ATTACHMENT_OPTIMAL, + STENCIL_READ_ONLY_OPTIMAL_KHR = STENCIL_READ_ONLY_OPTIMAL, + READ_ONLY_OPTIMAL_KHR = READ_ONLY_OPTIMAL, + ATTACHMENT_OPTIMAL_KHR = ATTACHMENT_OPTIMAL, +} + +ImageTiling :: enum c.int { + OPTIMAL = 0, + LINEAR = 1, + DRM_FORMAT_MODIFIER_EXT = 1000158000, +} + +ImageType :: enum c.int { + D1 = 0, + D2 = 1, + D3 = 2, +} + +ImageUsageFlags :: distinct bit_set[ImageUsageFlag; Flags] +ImageUsageFlag :: enum Flags { + TRANSFER_SRC = 0, + TRANSFER_DST = 1, + SAMPLED = 2, + STORAGE = 3, + COLOR_ATTACHMENT = 4, + DEPTH_STENCIL_ATTACHMENT = 5, + TRANSIENT_ATTACHMENT = 6, + INPUT_ATTACHMENT = 7, + VIDEO_DECODE_DST_KHR = 10, + VIDEO_DECODE_SRC_KHR = 11, + VIDEO_DECODE_DPB_KHR = 12, + FRAGMENT_DENSITY_MAP_EXT = 9, + FRAGMENT_SHADING_RATE_ATTACHMENT_KHR = 8, + VIDEO_ENCODE_DST_KHR = 13, + VIDEO_ENCODE_SRC_KHR = 14, + VIDEO_ENCODE_DPB_KHR = 15, + ATTACHMENT_FEEDBACK_LOOP_EXT = 19, + INVOCATION_MASK_HUAWEI = 18, + SAMPLE_WEIGHT_QCOM = 20, + SAMPLE_BLOCK_MATCH_QCOM = 21, + SHADING_RATE_IMAGE_NV = FRAGMENT_SHADING_RATE_ATTACHMENT_KHR, +} + +ImageViewCreateFlags :: distinct bit_set[ImageViewCreateFlag; Flags] +ImageViewCreateFlag :: enum Flags { + FRAGMENT_DENSITY_MAP_DYNAMIC_EXT = 0, + DESCRIPTOR_BUFFER_CAPTURE_REPLAY_EXT = 2, + FRAGMENT_DENSITY_MAP_DEFERRED_EXT = 1, +} + +ImageViewType :: enum c.int { + D1 = 0, + D2 = 1, + D3 = 2, + CUBE = 3, + D1_ARRAY = 4, + D2_ARRAY = 5, + CUBE_ARRAY = 6, +} + +IndexType :: enum c.int { + UINT16 = 0, + UINT32 = 1, + NONE_KHR = 1000165000, + UINT8_EXT = 1000265000, + NONE_NV = NONE_KHR, +} + +IndirectCommandsLayoutUsageFlagsNV :: distinct bit_set[IndirectCommandsLayoutUsageFlagNV; Flags] +IndirectCommandsLayoutUsageFlagNV :: enum Flags { + EXPLICIT_PREPROCESS = 0, + INDEXED_SEQUENCES = 1, + UNORDERED_SEQUENCES = 2, +} + +IndirectCommandsTokenTypeNV :: enum c.int { + SHADER_GROUP = 0, + STATE_FLAGS = 1, + INDEX_BUFFER = 2, + VERTEX_BUFFER = 3, + PUSH_CONSTANT = 4, + DRAW_INDEXED = 5, + DRAW = 6, + DRAW_TASKS = 7, + DRAW_MESH_TASKS = 1000328000, +} + +IndirectStateFlagsNV :: distinct bit_set[IndirectStateFlagNV; Flags] +IndirectStateFlagNV :: enum Flags { + FLAG_FRONTFACE = 0, +} + +InstanceCreateFlags :: distinct bit_set[InstanceCreateFlag; Flags] +InstanceCreateFlag :: enum Flags { + ENUMERATE_PORTABILITY_KHR = 0, +} + +InternalAllocationType :: enum c.int { + EXECUTABLE = 0, +} + +LineRasterizationModeEXT :: enum c.int { + DEFAULT = 0, + RECTANGULAR = 1, + BRESENHAM = 2, + RECTANGULAR_SMOOTH = 3, +} + +LogicOp :: enum c.int { + CLEAR = 0, + AND = 1, + AND_REVERSE = 2, + COPY = 3, + AND_INVERTED = 4, + NO_OP = 5, + XOR = 6, + OR = 7, + NOR = 8, + EQUIVALENT = 9, + INVERT = 10, + OR_REVERSE = 11, + COPY_INVERTED = 12, + OR_INVERTED = 13, + NAND = 14, + SET = 15, +} + +MemoryAllocateFlags :: distinct bit_set[MemoryAllocateFlag; Flags] +MemoryAllocateFlag :: enum Flags { + DEVICE_MASK = 0, + DEVICE_ADDRESS = 1, + DEVICE_ADDRESS_CAPTURE_REPLAY = 2, + DEVICE_MASK_KHR = DEVICE_MASK, + DEVICE_ADDRESS_KHR = DEVICE_ADDRESS, + DEVICE_ADDRESS_CAPTURE_REPLAY_KHR = DEVICE_ADDRESS_CAPTURE_REPLAY, +} + +MemoryHeapFlags :: distinct bit_set[MemoryHeapFlag; Flags] +MemoryHeapFlag :: enum Flags { + DEVICE_LOCAL = 0, + MULTI_INSTANCE = 1, + MULTI_INSTANCE_KHR = MULTI_INSTANCE, +} + +MemoryOverallocationBehaviorAMD :: enum c.int { + DEFAULT = 0, + ALLOWED = 1, + DISALLOWED = 2, +} + +MemoryPropertyFlags :: distinct bit_set[MemoryPropertyFlag; Flags] +MemoryPropertyFlag :: enum Flags { + DEVICE_LOCAL = 0, + HOST_VISIBLE = 1, + HOST_COHERENT = 2, + HOST_CACHED = 3, + LAZILY_ALLOCATED = 4, + PROTECTED = 5, + DEVICE_COHERENT_AMD = 6, + DEVICE_UNCACHED_AMD = 7, + RDMA_CAPABLE_NV = 8, +} + +MicromapCreateFlagsEXT :: distinct bit_set[MicromapCreateFlagEXT; Flags] +MicromapCreateFlagEXT :: enum Flags { + DEVICE_ADDRESS_CAPTURE_REPLAY = 0, +} + +MicromapTypeEXT :: enum c.int { + OPACITY_MICROMAP = 0, + DISPLACEMENT_MICROMAP_NV = 1000397000, +} + +ObjectType :: enum c.int { + UNKNOWN = 0, + INSTANCE = 1, + PHYSICAL_DEVICE = 2, + DEVICE = 3, + QUEUE = 4, + SEMAPHORE = 5, + COMMAND_BUFFER = 6, + FENCE = 7, + DEVICE_MEMORY = 8, + BUFFER = 9, + IMAGE = 10, + EVENT = 11, + QUERY_POOL = 12, + BUFFER_VIEW = 13, + IMAGE_VIEW = 14, + SHADER_MODULE = 15, + PIPELINE_CACHE = 16, + PIPELINE_LAYOUT = 17, + RENDER_PASS = 18, + PIPELINE = 19, + DESCRIPTOR_SET_LAYOUT = 20, + SAMPLER = 21, + DESCRIPTOR_POOL = 22, + DESCRIPTOR_SET = 23, + FRAMEBUFFER = 24, + COMMAND_POOL = 25, + SAMPLER_YCBCR_CONVERSION = 1000156000, + DESCRIPTOR_UPDATE_TEMPLATE = 1000085000, + PRIVATE_DATA_SLOT = 1000295000, + SURFACE_KHR = 1000000000, + SWAPCHAIN_KHR = 1000001000, + DISPLAY_KHR = 1000002000, + DISPLAY_MODE_KHR = 1000002001, + DEBUG_REPORT_CALLBACK_EXT = 1000011000, + VIDEO_SESSION_KHR = 1000023000, + VIDEO_SESSION_PARAMETERS_KHR = 1000023001, + CU_MODULE_NVX = 1000029000, + CU_FUNCTION_NVX = 1000029001, + DEBUG_UTILS_MESSENGER_EXT = 1000128000, + ACCELERATION_STRUCTURE_KHR = 1000150000, + VALIDATION_CACHE_EXT = 1000160000, + ACCELERATION_STRUCTURE_NV = 1000165000, + PERFORMANCE_CONFIGURATION_INTEL = 1000210000, + DEFERRED_OPERATION_KHR = 1000268000, + INDIRECT_COMMANDS_LAYOUT_NV = 1000277000, + BUFFER_COLLECTION_FUCHSIA = 1000366000, + MICROMAP_EXT = 1000396000, + OPTICAL_FLOW_SESSION_NV = 1000464000, + SHADER_EXT = 1000482000, + DESCRIPTOR_UPDATE_TEMPLATE_KHR = DESCRIPTOR_UPDATE_TEMPLATE, + SAMPLER_YCBCR_CONVERSION_KHR = SAMPLER_YCBCR_CONVERSION, + PRIVATE_DATA_SLOT_EXT = PRIVATE_DATA_SLOT, +} + +OpacityMicromapFormatEXT :: enum c.int { + _2_STATE = 1, + _4_STATE = 2, +} + +OpacityMicromapSpecialIndexEXT :: enum c.int { + FULLY_TRANSPARENT = -1, + FULLY_OPAQUE = -2, + FULLY_UNKNOWN_TRANSPARENT = -3, + FULLY_UNKNOWN_OPAQUE = -4, +} + +OpticalFlowExecuteFlagsNV :: distinct bit_set[OpticalFlowExecuteFlagNV; Flags] +OpticalFlowExecuteFlagNV :: enum Flags { + DISABLE_TEMPORAL_HINTS = 0, +} + +OpticalFlowGridSizeFlagsNV :: distinct bit_set[OpticalFlowGridSizeFlagNV; Flags] +OpticalFlowGridSizeFlagNV :: enum Flags { + _1X1 = 0, + _2X2 = 1, + _4X4 = 2, + _8X8 = 3, +} + +OpticalFlowGridSizeFlagsNV_UNKNOWN :: OpticalFlowGridSizeFlagsNV{} + + +OpticalFlowPerformanceLevelNV :: enum c.int { + UNKNOWN = 0, + SLOW = 1, + MEDIUM = 2, + FAST = 3, +} + +OpticalFlowSessionBindingPointNV :: enum c.int { + UNKNOWN = 0, + INPUT = 1, + REFERENCE = 2, + HINT = 3, + FLOW_VECTOR = 4, + BACKWARD_FLOW_VECTOR = 5, + COST = 6, + BACKWARD_COST = 7, + GLOBAL_FLOW = 8, +} + +OpticalFlowSessionCreateFlagsNV :: distinct bit_set[OpticalFlowSessionCreateFlagNV; Flags] +OpticalFlowSessionCreateFlagNV :: enum Flags { + ENABLE_HINT = 0, + ENABLE_COST = 1, + ENABLE_GLOBAL_FLOW = 2, + ALLOW_REGIONS = 3, + BOTH_DIRECTIONS = 4, +} + +OpticalFlowUsageFlagsNV :: distinct bit_set[OpticalFlowUsageFlagNV; Flags] +OpticalFlowUsageFlagNV :: enum Flags { + INPUT = 0, + OUTPUT = 1, + HINT = 2, + COST = 3, + GLOBAL_FLOW = 4, +} + +OpticalFlowUsageFlagsNV_UNKNOWN :: OpticalFlowUsageFlagsNV{} + + +PeerMemoryFeatureFlags :: distinct bit_set[PeerMemoryFeatureFlag; Flags] +PeerMemoryFeatureFlag :: enum Flags { + COPY_SRC = 0, + COPY_DST = 1, + GENERIC_SRC = 2, + GENERIC_DST = 3, + COPY_SRC_KHR = COPY_SRC, + COPY_DST_KHR = COPY_DST, + GENERIC_SRC_KHR = GENERIC_SRC, + GENERIC_DST_KHR = GENERIC_DST, +} + +PerformanceConfigurationTypeINTEL :: enum c.int { + PERFORMANCE_CONFIGURATION_TYPE_COMMAND_QUEUE_METRICS_DISCOVERY_ACTIVATED_INTEL = 0, +} + +PerformanceCounterDescriptionFlagsKHR :: distinct bit_set[PerformanceCounterDescriptionFlagKHR; Flags] +PerformanceCounterDescriptionFlagKHR :: enum Flags { + PERFORMANCE_IMPACTING = 0, + CONCURRENTLY_IMPACTED = 1, +} + +PerformanceCounterScopeKHR :: enum c.int { + COMMAND_BUFFER = 0, + RENDER_PASS = 1, + COMMAND = 2, + QUERY_SCOPE_COMMAND_BUFFER = COMMAND_BUFFER, + QUERY_SCOPE_RENDER_PASS = RENDER_PASS, + QUERY_SCOPE_COMMAND = COMMAND, +} + +PerformanceCounterStorageKHR :: enum c.int { + INT32 = 0, + INT64 = 1, + UINT32 = 2, + UINT64 = 3, + FLOAT32 = 4, + FLOAT64 = 5, +} + +PerformanceCounterUnitKHR :: enum c.int { + GENERIC = 0, + PERCENTAGE = 1, + NANOSECONDS = 2, + BYTES = 3, + BYTES_PER_SECOND = 4, + KELVIN = 5, + WATTS = 6, + VOLTS = 7, + AMPS = 8, + HERTZ = 9, + CYCLES = 10, +} + +PerformanceOverrideTypeINTEL :: enum c.int { + PERFORMANCE_OVERRIDE_TYPE_NULL_HARDWARE_INTEL = 0, + PERFORMANCE_OVERRIDE_TYPE_FLUSH_GPU_CACHES_INTEL = 1, +} + +PerformanceParameterTypeINTEL :: enum c.int { + PERFORMANCE_PARAMETER_TYPE_HW_COUNTERS_SUPPORTED_INTEL = 0, + PERFORMANCE_PARAMETER_TYPE_STREAM_MARKER_VALID_BITS_INTEL = 1, +} + +PerformanceValueTypeINTEL :: enum c.int { + PERFORMANCE_VALUE_TYPE_UINT32_INTEL = 0, + PERFORMANCE_VALUE_TYPE_UINT64_INTEL = 1, + PERFORMANCE_VALUE_TYPE_FLOAT_INTEL = 2, + PERFORMANCE_VALUE_TYPE_BOOL_INTEL = 3, + PERFORMANCE_VALUE_TYPE_STRING_INTEL = 4, +} + +PhysicalDeviceType :: enum c.int { + OTHER = 0, + INTEGRATED_GPU = 1, + DISCRETE_GPU = 2, + VIRTUAL_GPU = 3, + CPU = 4, +} + +PipelineBindPoint :: enum c.int { + GRAPHICS = 0, + COMPUTE = 1, + RAY_TRACING_KHR = 1000165000, + SUBPASS_SHADING_HUAWEI = 1000369003, + RAY_TRACING_NV = RAY_TRACING_KHR, +} + +PipelineCacheCreateFlags :: distinct bit_set[PipelineCacheCreateFlag; Flags] +PipelineCacheCreateFlag :: enum Flags { + EXTERNALLY_SYNCHRONIZED = 0, + EXTERNALLY_SYNCHRONIZED_EXT = EXTERNALLY_SYNCHRONIZED, +} + +PipelineCacheHeaderVersion :: enum c.int { + ONE = 1, +} + +PipelineColorBlendStateCreateFlags :: distinct bit_set[PipelineColorBlendStateCreateFlag; Flags] +PipelineColorBlendStateCreateFlag :: enum Flags { + RASTERIZATION_ORDER_ATTACHMENT_ACCESS_EXT = 0, + RASTERIZATION_ORDER_ATTACHMENT_ACCESS_ARM = RASTERIZATION_ORDER_ATTACHMENT_ACCESS_EXT, +} + +PipelineCompilerControlFlagsAMD :: distinct bit_set[PipelineCompilerControlFlagAMD; Flags] +PipelineCompilerControlFlagAMD :: enum Flags { +} + +PipelineCreateFlags :: distinct bit_set[PipelineCreateFlag; Flags] +PipelineCreateFlag :: enum Flags { + DISABLE_OPTIMIZATION = 0, + ALLOW_DERIVATIVES = 1, + DERIVATIVE = 2, + VIEW_INDEX_FROM_DEVICE_INDEX = 3, + DISPATCH_BASE = 4, + FAIL_ON_PIPELINE_COMPILE_REQUIRED = 8, + EARLY_RETURN_ON_FAILURE = 9, + RENDERING_FRAGMENT_SHADING_RATE_ATTACHMENT_KHR = 21, + RENDERING_FRAGMENT_DENSITY_MAP_ATTACHMENT_EXT = 22, + RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_KHR = 14, + RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_KHR = 15, + RAY_TRACING_NO_NULL_MISS_SHADERS_KHR = 16, + RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_KHR = 17, + RAY_TRACING_SKIP_TRIANGLES_KHR = 12, + RAY_TRACING_SKIP_AABBS_KHR = 13, + RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_KHR = 19, + DEFER_COMPILE_NV = 5, + CAPTURE_STATISTICS_KHR = 6, + CAPTURE_INTERNAL_REPRESENTATIONS_KHR = 7, + INDIRECT_BINDABLE_NV = 18, + LIBRARY_KHR = 11, + DESCRIPTOR_BUFFER_EXT = 29, + RETAIN_LINK_TIME_OPTIMIZATION_INFO_EXT = 23, + LINK_TIME_OPTIMIZATION_EXT = 10, + RAY_TRACING_ALLOW_MOTION_NV = 20, + COLOR_ATTACHMENT_FEEDBACK_LOOP_EXT = 25, + DEPTH_STENCIL_ATTACHMENT_FEEDBACK_LOOP_EXT = 26, + RAY_TRACING_OPACITY_MICROMAP_EXT = 24, + RAY_TRACING_DISPLACEMENT_MICROMAP_NV = 28, + NO_PROTECTED_ACCESS_EXT = 27, + PROTECTED_ACCESS_ONLY_EXT = 30, + PIPELINE_RASTERIZATION_STATE_CREATE_FRAGMENT_SHADING_RATE_ATTACHMENT_KHR = RENDERING_FRAGMENT_SHADING_RATE_ATTACHMENT_KHR, + PIPELINE_RASTERIZATION_STATE_CREATE_FRAGMENT_DENSITY_MAP_ATTACHMENT_EXT = RENDERING_FRAGMENT_DENSITY_MAP_ATTACHMENT_EXT, + VIEW_INDEX_FROM_DEVICE_INDEX_KHR = VIEW_INDEX_FROM_DEVICE_INDEX, + DISPATCH_BASE_KHR = DISPATCH_BASE, + FAIL_ON_PIPELINE_COMPILE_REQUIRED_EXT = FAIL_ON_PIPELINE_COMPILE_REQUIRED, + EARLY_RETURN_ON_FAILURE_EXT = EARLY_RETURN_ON_FAILURE, +} + +PipelineCreationFeedbackFlags :: distinct bit_set[PipelineCreationFeedbackFlag; Flags] +PipelineCreationFeedbackFlag :: enum Flags { + VALID = 0, + APPLICATION_PIPELINE_CACHE_HIT = 1, + BASE_PIPELINE_ACCELERATION = 2, + VALID_EXT = VALID, + APPLICATION_PIPELINE_CACHE_HIT_EXT = APPLICATION_PIPELINE_CACHE_HIT, + BASE_PIPELINE_ACCELERATION_EXT = BASE_PIPELINE_ACCELERATION, +} + +PipelineDepthStencilStateCreateFlags :: distinct bit_set[PipelineDepthStencilStateCreateFlag; Flags] +PipelineDepthStencilStateCreateFlag :: enum Flags { + RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_EXT = 0, + RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_EXT = 1, + RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_ARM = RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_EXT, + RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_ARM = RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_EXT, +} + +PipelineExecutableStatisticFormatKHR :: enum c.int { + BOOL32 = 0, + INT64 = 1, + UINT64 = 2, + FLOAT64 = 3, +} + +PipelineLayoutCreateFlags :: distinct bit_set[PipelineLayoutCreateFlag; Flags] +PipelineLayoutCreateFlag :: enum Flags { + INDEPENDENT_SETS_EXT = 1, +} + +PipelineRobustnessBufferBehaviorEXT :: enum c.int { + DEVICE_DEFAULT = 0, + DISABLED = 1, + ROBUST_BUFFER_ACCESS = 2, + ROBUST_BUFFER_ACCESS_2 = 3, +} + +PipelineRobustnessImageBehaviorEXT :: enum c.int { + DEVICE_DEFAULT = 0, + DISABLED = 1, + ROBUST_IMAGE_ACCESS = 2, + ROBUST_IMAGE_ACCESS_2 = 3, +} + +PipelineShaderStageCreateFlags :: distinct bit_set[PipelineShaderStageCreateFlag; Flags] +PipelineShaderStageCreateFlag :: enum Flags { + ALLOW_VARYING_SUBGROUP_SIZE = 0, + REQUIRE_FULL_SUBGROUPS = 1, + ALLOW_VARYING_SUBGROUP_SIZE_EXT = ALLOW_VARYING_SUBGROUP_SIZE, + REQUIRE_FULL_SUBGROUPS_EXT = REQUIRE_FULL_SUBGROUPS, +} + +PipelineStageFlags :: distinct bit_set[PipelineStageFlag; Flags] +PipelineStageFlag :: enum Flags { + TOP_OF_PIPE = 0, + DRAW_INDIRECT = 1, + VERTEX_INPUT = 2, + VERTEX_SHADER = 3, + TESSELLATION_CONTROL_SHADER = 4, + TESSELLATION_EVALUATION_SHADER = 5, + GEOMETRY_SHADER = 6, + FRAGMENT_SHADER = 7, + EARLY_FRAGMENT_TESTS = 8, + LATE_FRAGMENT_TESTS = 9, + COLOR_ATTACHMENT_OUTPUT = 10, + COMPUTE_SHADER = 11, + TRANSFER = 12, + BOTTOM_OF_PIPE = 13, + HOST = 14, + ALL_GRAPHICS = 15, + ALL_COMMANDS = 16, + TRANSFORM_FEEDBACK_EXT = 24, + CONDITIONAL_RENDERING_EXT = 18, + ACCELERATION_STRUCTURE_BUILD_KHR = 25, + RAY_TRACING_SHADER_KHR = 21, + FRAGMENT_DENSITY_PROCESS_EXT = 23, + FRAGMENT_SHADING_RATE_ATTACHMENT_KHR = 22, + COMMAND_PREPROCESS_NV = 17, + TASK_SHADER_EXT = 19, + MESH_SHADER_EXT = 20, + SHADING_RATE_IMAGE_NV = FRAGMENT_SHADING_RATE_ATTACHMENT_KHR, + RAY_TRACING_SHADER_NV = RAY_TRACING_SHADER_KHR, + ACCELERATION_STRUCTURE_BUILD_NV = ACCELERATION_STRUCTURE_BUILD_KHR, + TASK_SHADER_NV = TASK_SHADER_EXT, + MESH_SHADER_NV = MESH_SHADER_EXT, +} + +PipelineStageFlags_NONE :: PipelineStageFlags{} + + +PointClippingBehavior :: enum c.int { + ALL_CLIP_PLANES = 0, + USER_CLIP_PLANES_ONLY = 1, + ALL_CLIP_PLANES_KHR = ALL_CLIP_PLANES, + USER_CLIP_PLANES_ONLY_KHR = USER_CLIP_PLANES_ONLY, +} + +PolygonMode :: enum c.int { + FILL = 0, + LINE = 1, + POINT = 2, + FILL_RECTANGLE_NV = 1000153000, +} + +PresentGravityFlagsEXT :: distinct bit_set[PresentGravityFlagEXT; Flags] +PresentGravityFlagEXT :: enum Flags { + MIN = 0, + MAX = 1, + CENTERED = 2, +} + +PresentModeKHR :: enum c.int { + IMMEDIATE = 0, + MAILBOX = 1, + FIFO = 2, + FIFO_RELAXED = 3, + SHARED_DEMAND_REFRESH = 1000111000, + SHARED_CONTINUOUS_REFRESH = 1000111001, +} + +PresentScalingFlagsEXT :: distinct bit_set[PresentScalingFlagEXT; Flags] +PresentScalingFlagEXT :: enum Flags { + ONE_TO_ONE = 0, + ASPECT_RATIO_STRETCH = 1, + STRETCH = 2, +} + +PrimitiveTopology :: enum c.int { + POINT_LIST = 0, + LINE_LIST = 1, + LINE_STRIP = 2, + TRIANGLE_LIST = 3, + TRIANGLE_STRIP = 4, + TRIANGLE_FAN = 5, + LINE_LIST_WITH_ADJACENCY = 6, + LINE_STRIP_WITH_ADJACENCY = 7, + TRIANGLE_LIST_WITH_ADJACENCY = 8, + TRIANGLE_STRIP_WITH_ADJACENCY = 9, + PATCH_LIST = 10, +} + +ProvokingVertexModeEXT :: enum c.int { + FIRST_VERTEX = 0, + LAST_VERTEX = 1, +} + +QueryControlFlags :: distinct bit_set[QueryControlFlag; Flags] +QueryControlFlag :: enum Flags { + PRECISE = 0, +} + +QueryPipelineStatisticFlags :: distinct bit_set[QueryPipelineStatisticFlag; Flags] +QueryPipelineStatisticFlag :: enum Flags { + INPUT_ASSEMBLY_VERTICES = 0, + INPUT_ASSEMBLY_PRIMITIVES = 1, + VERTEX_SHADER_INVOCATIONS = 2, + GEOMETRY_SHADER_INVOCATIONS = 3, + GEOMETRY_SHADER_PRIMITIVES = 4, + CLIPPING_INVOCATIONS = 5, + CLIPPING_PRIMITIVES = 6, + FRAGMENT_SHADER_INVOCATIONS = 7, + TESSELLATION_CONTROL_SHADER_PATCHES = 8, + TESSELLATION_EVALUATION_SHADER_INVOCATIONS = 9, + COMPUTE_SHADER_INVOCATIONS = 10, + TASK_SHADER_INVOCATIONS_EXT = 11, + MESH_SHADER_INVOCATIONS_EXT = 12, + CLUSTER_CULLING_SHADER_INVOCATIONS_HUAWEI = 13, +} + +QueryPoolSamplingModeINTEL :: enum c.int { + QUERY_POOL_SAMPLING_MODE_MANUAL_INTEL = 0, +} + +QueryResultFlags :: distinct bit_set[QueryResultFlag; Flags] +QueryResultFlag :: enum Flags { + _64 = 0, + WAIT = 1, + WITH_AVAILABILITY = 2, + PARTIAL = 3, + WITH_STATUS_KHR = 4, +} + +QueryResultStatusKHR :: enum c.int { + ERROR = -1, + NOT_READY = 0, + COMPLETE = 1, +} + +QueryType :: enum c.int { + OCCLUSION = 0, + PIPELINE_STATISTICS = 1, + TIMESTAMP = 2, + RESULT_STATUS_ONLY_KHR = 1000023000, + TRANSFORM_FEEDBACK_STREAM_EXT = 1000028004, + PERFORMANCE_QUERY_KHR = 1000116000, + ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR = 1000150000, + ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR = 1000150001, + ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV = 1000165000, + PERFORMANCE_QUERY_INTEL = 1000210000, + VIDEO_ENCODE_FEEDBACK_KHR = 1000299000, + MESH_PRIMITIVES_GENERATED_EXT = 1000328000, + PRIMITIVES_GENERATED_EXT = 1000382000, + ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR = 1000386000, + ACCELERATION_STRUCTURE_SIZE_KHR = 1000386001, + MICROMAP_SERIALIZATION_SIZE_EXT = 1000396000, + MICROMAP_COMPACTED_SIZE_EXT = 1000396001, +} + +QueueFlags :: distinct bit_set[QueueFlag; Flags] +QueueFlag :: enum Flags { + GRAPHICS = 0, + COMPUTE = 1, + TRANSFER = 2, + SPARSE_BINDING = 3, + PROTECTED = 4, + VIDEO_DECODE_KHR = 5, + VIDEO_ENCODE_KHR = 6, + OPTICAL_FLOW_NV = 8, +} + +QueueGlobalPriorityKHR :: enum c.int { + LOW = 128, + MEDIUM = 256, + HIGH = 512, + REALTIME = 1024, + LOW_EXT = LOW, + MEDIUM_EXT = MEDIUM, + HIGH_EXT = HIGH, + REALTIME_EXT = REALTIME, +} + +RasterizationOrderAMD :: enum c.int { + STRICT = 0, + RELAXED = 1, +} + +RayTracingInvocationReorderModeNV :: enum c.int { + NONE = 0, + REORDER = 1, +} + +RayTracingShaderGroupTypeKHR :: enum c.int { + GENERAL = 0, + TRIANGLES_HIT_GROUP = 1, + PROCEDURAL_HIT_GROUP = 2, + GENERAL_NV = GENERAL, + TRIANGLES_HIT_GROUP_NV = TRIANGLES_HIT_GROUP, + PROCEDURAL_HIT_GROUP_NV = PROCEDURAL_HIT_GROUP, +} + +RenderPassCreateFlags :: distinct bit_set[RenderPassCreateFlag; Flags] +RenderPassCreateFlag :: enum Flags { + TRANSFORM_QCOM = 1, +} + +RenderingFlags :: distinct bit_set[RenderingFlag; Flags] +RenderingFlag :: enum Flags { + CONTENTS_SECONDARY_COMMAND_BUFFERS = 0, + SUSPENDING = 1, + RESUMING = 2, + ENABLE_LEGACY_DITHERING_EXT = 3, + CONTENTS_SECONDARY_COMMAND_BUFFERS_KHR = CONTENTS_SECONDARY_COMMAND_BUFFERS, + SUSPENDING_KHR = SUSPENDING, + RESUMING_KHR = RESUMING, +} + +ResolveModeFlags :: distinct bit_set[ResolveModeFlag; Flags] +ResolveModeFlag :: enum Flags { + SAMPLE_ZERO = 0, + AVERAGE = 1, + MIN = 2, + MAX = 3, + SAMPLE_ZERO_KHR = SAMPLE_ZERO, + AVERAGE_KHR = AVERAGE, + MIN_KHR = MIN, + MAX_KHR = MAX, +} + +ResolveModeFlags_NONE :: ResolveModeFlags{} + + +Result :: enum c.int { + SUCCESS = 0, + NOT_READY = 1, + TIMEOUT = 2, + EVENT_SET = 3, + EVENT_RESET = 4, + INCOMPLETE = 5, + ERROR_OUT_OF_HOST_MEMORY = -1, + ERROR_OUT_OF_DEVICE_MEMORY = -2, + ERROR_INITIALIZATION_FAILED = -3, + ERROR_DEVICE_LOST = -4, + ERROR_MEMORY_MAP_FAILED = -5, + ERROR_LAYER_NOT_PRESENT = -6, + ERROR_EXTENSION_NOT_PRESENT = -7, + ERROR_FEATURE_NOT_PRESENT = -8, + ERROR_INCOMPATIBLE_DRIVER = -9, + ERROR_TOO_MANY_OBJECTS = -10, + ERROR_FORMAT_NOT_SUPPORTED = -11, + ERROR_FRAGMENTED_POOL = -12, + ERROR_UNKNOWN = -13, + ERROR_OUT_OF_POOL_MEMORY = -1000069000, + ERROR_INVALID_EXTERNAL_HANDLE = -1000072003, + ERROR_FRAGMENTATION = -1000161000, + ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS = -1000257000, + PIPELINE_COMPILE_REQUIRED = 1000297000, + ERROR_SURFACE_LOST_KHR = -1000000000, + ERROR_NATIVE_WINDOW_IN_USE_KHR = -1000000001, + SUBOPTIMAL_KHR = 1000001003, + ERROR_OUT_OF_DATE_KHR = -1000001004, + ERROR_INCOMPATIBLE_DISPLAY_KHR = -1000003001, + ERROR_VALIDATION_FAILED_EXT = -1000011001, + ERROR_INVALID_SHADER_NV = -1000012000, + ERROR_IMAGE_USAGE_NOT_SUPPORTED_KHR = -1000023000, + ERROR_VIDEO_PICTURE_LAYOUT_NOT_SUPPORTED_KHR = -1000023001, + ERROR_VIDEO_PROFILE_OPERATION_NOT_SUPPORTED_KHR = -1000023002, + ERROR_VIDEO_PROFILE_FORMAT_NOT_SUPPORTED_KHR = -1000023003, + ERROR_VIDEO_PROFILE_CODEC_NOT_SUPPORTED_KHR = -1000023004, + ERROR_VIDEO_STD_VERSION_NOT_SUPPORTED_KHR = -1000023005, + ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT = -1000158000, + ERROR_NOT_PERMITTED_KHR = -1000174001, + ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT = -1000255000, + THREAD_IDLE_KHR = 1000268000, + THREAD_DONE_KHR = 1000268001, + OPERATION_DEFERRED_KHR = 1000268002, + OPERATION_NOT_DEFERRED_KHR = 1000268003, + ERROR_INVALID_VIDEO_STD_PARAMETERS_KHR = -1000299000, + ERROR_COMPRESSION_EXHAUSTED_EXT = -1000338000, + ERROR_INCOMPATIBLE_SHADER_BINARY_EXT = 1000482000, + ERROR_OUT_OF_POOL_MEMORY_KHR = ERROR_OUT_OF_POOL_MEMORY, + ERROR_INVALID_EXTERNAL_HANDLE_KHR = ERROR_INVALID_EXTERNAL_HANDLE, + ERROR_FRAGMENTATION_EXT = ERROR_FRAGMENTATION, + ERROR_NOT_PERMITTED_EXT = ERROR_NOT_PERMITTED_KHR, + ERROR_INVALID_DEVICE_ADDRESS_EXT = ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS, + ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS_KHR = ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS, + PIPELINE_COMPILE_REQUIRED_EXT = PIPELINE_COMPILE_REQUIRED, + ERROR_PIPELINE_COMPILE_REQUIRED_EXT = PIPELINE_COMPILE_REQUIRED, +} + +SampleCountFlags :: distinct bit_set[SampleCountFlag; Flags] +SampleCountFlag :: enum Flags { + _1 = 0, + _2 = 1, + _4 = 2, + _8 = 3, + _16 = 4, + _32 = 5, + _64 = 6, +} + +SamplerAddressMode :: enum c.int { + REPEAT = 0, + MIRRORED_REPEAT = 1, + CLAMP_TO_EDGE = 2, + CLAMP_TO_BORDER = 3, + MIRROR_CLAMP_TO_EDGE = 4, + MIRROR_CLAMP_TO_EDGE_KHR = MIRROR_CLAMP_TO_EDGE, +} + +SamplerCreateFlags :: distinct bit_set[SamplerCreateFlag; Flags] +SamplerCreateFlag :: enum Flags { + SUBSAMPLED_EXT = 0, + SUBSAMPLED_COARSE_RECONSTRUCTION_EXT = 1, + DESCRIPTOR_BUFFER_CAPTURE_REPLAY_EXT = 3, + NON_SEAMLESS_CUBE_MAP_EXT = 2, + IMAGE_PROCESSING_QCOM = 4, +} + +SamplerMipmapMode :: enum c.int { + NEAREST = 0, + LINEAR = 1, +} + +SamplerReductionMode :: enum c.int { + WEIGHTED_AVERAGE = 0, + MIN = 1, + MAX = 2, + WEIGHTED_AVERAGE_EXT = WEIGHTED_AVERAGE, + MIN_EXT = MIN, + MAX_EXT = MAX, +} + +SamplerYcbcrModelConversion :: enum c.int { + RGB_IDENTITY = 0, + YCBCR_IDENTITY = 1, + YCBCR_709 = 2, + YCBCR_601 = 3, + YCBCR_2020 = 4, + RGB_IDENTITY_KHR = RGB_IDENTITY, + YCBCR_IDENTITY_KHR = YCBCR_IDENTITY, + YCBCR_709_KHR = YCBCR_709, + YCBCR_601_KHR = YCBCR_601, + YCBCR_2020_KHR = YCBCR_2020, +} + +SamplerYcbcrRange :: enum c.int { + ITU_FULL = 0, + ITU_NARROW = 1, + ITU_FULL_KHR = ITU_FULL, + ITU_NARROW_KHR = ITU_NARROW, +} + +ScopeNV :: enum c.int { + DEVICE = 1, + WORKGROUP = 2, + SUBGROUP = 3, + QUEUE_FAMILY = 5, +} + +SemaphoreImportFlags :: distinct bit_set[SemaphoreImportFlag; Flags] +SemaphoreImportFlag :: enum Flags { + TEMPORARY = 0, + TEMPORARY_KHR = TEMPORARY, +} + +SemaphoreType :: enum c.int { + BINARY = 0, + TIMELINE = 1, + BINARY_KHR = BINARY, + TIMELINE_KHR = TIMELINE, +} + +SemaphoreWaitFlags :: distinct bit_set[SemaphoreWaitFlag; Flags] +SemaphoreWaitFlag :: enum Flags { + ANY = 0, + ANY_KHR = ANY, +} + +ShaderCodeTypeEXT :: enum c.int { + BINARY = 0, + SPIRV = 1, +} + +ShaderCorePropertiesFlagsAMD :: distinct bit_set[ShaderCorePropertiesFlagAMD; Flags] +ShaderCorePropertiesFlagAMD :: enum Flags { +} + +ShaderCreateFlagsEXT :: distinct bit_set[ShaderCreateFlagEXT; Flags] +ShaderCreateFlagEXT :: enum Flags { + LINK_STAGE = 0, + ALLOW_VARYING_SUBGROUP_SIZE = 1, + REQUIRE_FULL_SUBGROUPS = 2, + NO_TASK_SHADER = 3, + DISPATCH_BASE = 4, + FRAGMENT_SHADING_RATE_ATTACHMENT = 5, + FRAGMENT_DENSITY_MAP_ATTACHMENT = 6, +} + +ShaderFloatControlsIndependence :: enum c.int { + _32_BIT_ONLY = 0, + ALL = 1, + NONE = 2, + _32_BIT_ONLY_KHR = _32_BIT_ONLY, + ALL_KHR = ALL, +} + +ShaderGroupShaderKHR :: enum c.int { + GENERAL = 0, + CLOSEST_HIT = 1, + ANY_HIT = 2, + INTERSECTION = 3, +} + +ShaderInfoTypeAMD :: enum c.int { + STATISTICS = 0, + BINARY = 1, + DISASSEMBLY = 2, +} + +ShaderStageFlags :: distinct bit_set[ShaderStageFlag; Flags] +ShaderStageFlag :: enum Flags { + VERTEX = 0, + TESSELLATION_CONTROL = 1, + TESSELLATION_EVALUATION = 2, + GEOMETRY = 3, + FRAGMENT = 4, + COMPUTE = 5, + RAYGEN_KHR = 8, + ANY_HIT_KHR = 9, + CLOSEST_HIT_KHR = 10, + MISS_KHR = 11, + INTERSECTION_KHR = 12, + CALLABLE_KHR = 13, + TASK_EXT = 6, + MESH_EXT = 7, + SUBPASS_SHADING_HUAWEI = 14, + CLUSTER_CULLING_HUAWEI = 19, + RAYGEN_NV = RAYGEN_KHR, + ANY_HIT_NV = ANY_HIT_KHR, + CLOSEST_HIT_NV = CLOSEST_HIT_KHR, + MISS_NV = MISS_KHR, + INTERSECTION_NV = INTERSECTION_KHR, + CALLABLE_NV = CALLABLE_KHR, + TASK_NV = TASK_EXT, + MESH_NV = MESH_EXT, + _MAX = 31, // Needed for the *_ALL bit set +} + +ShaderStageFlags_ALL_GRAPHICS :: ShaderStageFlags{.VERTEX, .TESSELLATION_CONTROL, .TESSELLATION_EVALUATION, .GEOMETRY, .FRAGMENT} +ShaderStageFlags_ALL :: ShaderStageFlags{.VERTEX, .TESSELLATION_CONTROL, .TESSELLATION_EVALUATION, .GEOMETRY, .FRAGMENT, .COMPUTE, .TASK_EXT, .MESH_EXT, .RAYGEN_KHR, .ANY_HIT_KHR, .CLOSEST_HIT_KHR, .MISS_KHR, .INTERSECTION_KHR, .CALLABLE_KHR, .SUBPASS_SHADING_HUAWEI, ShaderStageFlag(15), ShaderStageFlag(16), ShaderStageFlag(17), ShaderStageFlag(18), .CLUSTER_CULLING_HUAWEI, ShaderStageFlag(20), ShaderStageFlag(21), ShaderStageFlag(22), ShaderStageFlag(23), ShaderStageFlag(24), ShaderStageFlag(25), ShaderStageFlag(26), ShaderStageFlag(27), ShaderStageFlag(28), ShaderStageFlag(29), ShaderStageFlag(30)} + + +ShadingRatePaletteEntryNV :: enum c.int { + NO_INVOCATIONS = 0, + _16_INVOCATIONS_PER_PIXEL = 1, + _8_INVOCATIONS_PER_PIXEL = 2, + _4_INVOCATIONS_PER_PIXEL = 3, + _2_INVOCATIONS_PER_PIXEL = 4, + _1_INVOCATION_PER_PIXEL = 5, + _1_INVOCATION_PER_2X1_PIXELS = 6, + _1_INVOCATION_PER_1X2_PIXELS = 7, + _1_INVOCATION_PER_2X2_PIXELS = 8, + _1_INVOCATION_PER_4X2_PIXELS = 9, + _1_INVOCATION_PER_2X4_PIXELS = 10, + _1_INVOCATION_PER_4X4_PIXELS = 11, +} + +SharingMode :: enum c.int { + EXCLUSIVE = 0, + CONCURRENT = 1, +} + +SparseImageFormatFlags :: distinct bit_set[SparseImageFormatFlag; Flags] +SparseImageFormatFlag :: enum Flags { + SINGLE_MIPTAIL = 0, + ALIGNED_MIP_SIZE = 1, + NONSTANDARD_BLOCK_SIZE = 2, +} + +SparseMemoryBindFlags :: distinct bit_set[SparseMemoryBindFlag; Flags] +SparseMemoryBindFlag :: enum Flags { + METADATA = 0, +} + +StencilFaceFlags :: distinct bit_set[StencilFaceFlag; Flags] +StencilFaceFlag :: enum Flags { + FRONT = 0, + BACK = 1, +} + +StencilFaceFlags_FRONT_AND_BACK :: StencilFaceFlags{.FRONT, .BACK} + + +StencilOp :: enum c.int { + KEEP = 0, + ZERO = 1, + REPLACE = 2, + INCREMENT_AND_CLAMP = 3, + DECREMENT_AND_CLAMP = 4, + INVERT = 5, + INCREMENT_AND_WRAP = 6, + DECREMENT_AND_WRAP = 7, +} + +StructureType :: enum c.int { + APPLICATION_INFO = 0, + INSTANCE_CREATE_INFO = 1, + DEVICE_QUEUE_CREATE_INFO = 2, + DEVICE_CREATE_INFO = 3, + SUBMIT_INFO = 4, + MEMORY_ALLOCATE_INFO = 5, + MAPPED_MEMORY_RANGE = 6, + BIND_SPARSE_INFO = 7, + FENCE_CREATE_INFO = 8, + SEMAPHORE_CREATE_INFO = 9, + EVENT_CREATE_INFO = 10, + QUERY_POOL_CREATE_INFO = 11, + BUFFER_CREATE_INFO = 12, + BUFFER_VIEW_CREATE_INFO = 13, + IMAGE_CREATE_INFO = 14, + IMAGE_VIEW_CREATE_INFO = 15, + SHADER_MODULE_CREATE_INFO = 16, + PIPELINE_CACHE_CREATE_INFO = 17, + PIPELINE_SHADER_STAGE_CREATE_INFO = 18, + PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO = 19, + PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO = 20, + PIPELINE_TESSELLATION_STATE_CREATE_INFO = 21, + PIPELINE_VIEWPORT_STATE_CREATE_INFO = 22, + PIPELINE_RASTERIZATION_STATE_CREATE_INFO = 23, + PIPELINE_MULTISAMPLE_STATE_CREATE_INFO = 24, + PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO = 25, + PIPELINE_COLOR_BLEND_STATE_CREATE_INFO = 26, + PIPELINE_DYNAMIC_STATE_CREATE_INFO = 27, + GRAPHICS_PIPELINE_CREATE_INFO = 28, + COMPUTE_PIPELINE_CREATE_INFO = 29, + PIPELINE_LAYOUT_CREATE_INFO = 30, + SAMPLER_CREATE_INFO = 31, + DESCRIPTOR_SET_LAYOUT_CREATE_INFO = 32, + DESCRIPTOR_POOL_CREATE_INFO = 33, + DESCRIPTOR_SET_ALLOCATE_INFO = 34, + WRITE_DESCRIPTOR_SET = 35, + COPY_DESCRIPTOR_SET = 36, + FRAMEBUFFER_CREATE_INFO = 37, + RENDER_PASS_CREATE_INFO = 38, + COMMAND_POOL_CREATE_INFO = 39, + COMMAND_BUFFER_ALLOCATE_INFO = 40, + COMMAND_BUFFER_INHERITANCE_INFO = 41, + COMMAND_BUFFER_BEGIN_INFO = 42, + RENDER_PASS_BEGIN_INFO = 43, + BUFFER_MEMORY_BARRIER = 44, + IMAGE_MEMORY_BARRIER = 45, + MEMORY_BARRIER = 46, + LOADER_INSTANCE_CREATE_INFO = 47, + LOADER_DEVICE_CREATE_INFO = 48, + PHYSICAL_DEVICE_SUBGROUP_PROPERTIES = 1000094000, + BIND_BUFFER_MEMORY_INFO = 1000157000, + BIND_IMAGE_MEMORY_INFO = 1000157001, + PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES = 1000083000, + MEMORY_DEDICATED_REQUIREMENTS = 1000127000, + MEMORY_DEDICATED_ALLOCATE_INFO = 1000127001, + MEMORY_ALLOCATE_FLAGS_INFO = 1000060000, + DEVICE_GROUP_RENDER_PASS_BEGIN_INFO = 1000060003, + DEVICE_GROUP_COMMAND_BUFFER_BEGIN_INFO = 1000060004, + DEVICE_GROUP_SUBMIT_INFO = 1000060005, + DEVICE_GROUP_BIND_SPARSE_INFO = 1000060006, + BIND_BUFFER_MEMORY_DEVICE_GROUP_INFO = 1000060013, + BIND_IMAGE_MEMORY_DEVICE_GROUP_INFO = 1000060014, + PHYSICAL_DEVICE_GROUP_PROPERTIES = 1000070000, + DEVICE_GROUP_DEVICE_CREATE_INFO = 1000070001, + BUFFER_MEMORY_REQUIREMENTS_INFO_2 = 1000146000, + IMAGE_MEMORY_REQUIREMENTS_INFO_2 = 1000146001, + IMAGE_SPARSE_MEMORY_REQUIREMENTS_INFO_2 = 1000146002, + MEMORY_REQUIREMENTS_2 = 1000146003, + SPARSE_IMAGE_MEMORY_REQUIREMENTS_2 = 1000146004, + PHYSICAL_DEVICE_FEATURES_2 = 1000059000, + PHYSICAL_DEVICE_PROPERTIES_2 = 1000059001, + FORMAT_PROPERTIES_2 = 1000059002, + IMAGE_FORMAT_PROPERTIES_2 = 1000059003, + PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2 = 1000059004, + QUEUE_FAMILY_PROPERTIES_2 = 1000059005, + PHYSICAL_DEVICE_MEMORY_PROPERTIES_2 = 1000059006, + SPARSE_IMAGE_FORMAT_PROPERTIES_2 = 1000059007, + PHYSICAL_DEVICE_SPARSE_IMAGE_FORMAT_INFO_2 = 1000059008, + PHYSICAL_DEVICE_POINT_CLIPPING_PROPERTIES = 1000117000, + RENDER_PASS_INPUT_ATTACHMENT_ASPECT_CREATE_INFO = 1000117001, + IMAGE_VIEW_USAGE_CREATE_INFO = 1000117002, + PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO = 1000117003, + RENDER_PASS_MULTIVIEW_CREATE_INFO = 1000053000, + PHYSICAL_DEVICE_MULTIVIEW_FEATURES = 1000053001, + PHYSICAL_DEVICE_MULTIVIEW_PROPERTIES = 1000053002, + PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES = 1000120000, + PROTECTED_SUBMIT_INFO = 1000145000, + PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES = 1000145001, + PHYSICAL_DEVICE_PROTECTED_MEMORY_PROPERTIES = 1000145002, + DEVICE_QUEUE_INFO_2 = 1000145003, + SAMPLER_YCBCR_CONVERSION_CREATE_INFO = 1000156000, + SAMPLER_YCBCR_CONVERSION_INFO = 1000156001, + BIND_IMAGE_PLANE_MEMORY_INFO = 1000156002, + IMAGE_PLANE_MEMORY_REQUIREMENTS_INFO = 1000156003, + PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES = 1000156004, + SAMPLER_YCBCR_CONVERSION_IMAGE_FORMAT_PROPERTIES = 1000156005, + DESCRIPTOR_UPDATE_TEMPLATE_CREATE_INFO = 1000085000, + PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO = 1000071000, + EXTERNAL_IMAGE_FORMAT_PROPERTIES = 1000071001, + PHYSICAL_DEVICE_EXTERNAL_BUFFER_INFO = 1000071002, + EXTERNAL_BUFFER_PROPERTIES = 1000071003, + PHYSICAL_DEVICE_ID_PROPERTIES = 1000071004, + EXTERNAL_MEMORY_BUFFER_CREATE_INFO = 1000072000, + EXTERNAL_MEMORY_IMAGE_CREATE_INFO = 1000072001, + EXPORT_MEMORY_ALLOCATE_INFO = 1000072002, + PHYSICAL_DEVICE_EXTERNAL_FENCE_INFO = 1000112000, + EXTERNAL_FENCE_PROPERTIES = 1000112001, + EXPORT_FENCE_CREATE_INFO = 1000113000, + EXPORT_SEMAPHORE_CREATE_INFO = 1000077000, + PHYSICAL_DEVICE_EXTERNAL_SEMAPHORE_INFO = 1000076000, + EXTERNAL_SEMAPHORE_PROPERTIES = 1000076001, + PHYSICAL_DEVICE_MAINTENANCE_3_PROPERTIES = 1000168000, + DESCRIPTOR_SET_LAYOUT_SUPPORT = 1000168001, + PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES = 1000063000, + PHYSICAL_DEVICE_VULKAN_1_1_FEATURES = 49, + PHYSICAL_DEVICE_VULKAN_1_1_PROPERTIES = 50, + PHYSICAL_DEVICE_VULKAN_1_2_FEATURES = 51, + PHYSICAL_DEVICE_VULKAN_1_2_PROPERTIES = 52, + IMAGE_FORMAT_LIST_CREATE_INFO = 1000147000, + ATTACHMENT_DESCRIPTION_2 = 1000109000, + ATTACHMENT_REFERENCE_2 = 1000109001, + SUBPASS_DESCRIPTION_2 = 1000109002, + SUBPASS_DEPENDENCY_2 = 1000109003, + RENDER_PASS_CREATE_INFO_2 = 1000109004, + SUBPASS_BEGIN_INFO = 1000109005, + SUBPASS_END_INFO = 1000109006, + PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES = 1000177000, + PHYSICAL_DEVICE_DRIVER_PROPERTIES = 1000196000, + PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES = 1000180000, + PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES = 1000082000, + PHYSICAL_DEVICE_FLOAT_CONTROLS_PROPERTIES = 1000197000, + DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO = 1000161000, + PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES = 1000161001, + PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_PROPERTIES = 1000161002, + DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_ALLOCATE_INFO = 1000161003, + DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_LAYOUT_SUPPORT = 1000161004, + PHYSICAL_DEVICE_DEPTH_STENCIL_RESOLVE_PROPERTIES = 1000199000, + SUBPASS_DESCRIPTION_DEPTH_STENCIL_RESOLVE = 1000199001, + PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES = 1000221000, + IMAGE_STENCIL_USAGE_CREATE_INFO = 1000246000, + PHYSICAL_DEVICE_SAMPLER_FILTER_MINMAX_PROPERTIES = 1000130000, + SAMPLER_REDUCTION_MODE_CREATE_INFO = 1000130001, + PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES = 1000211000, + PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES = 1000108000, + FRAMEBUFFER_ATTACHMENTS_CREATE_INFO = 1000108001, + FRAMEBUFFER_ATTACHMENT_IMAGE_INFO = 1000108002, + RENDER_PASS_ATTACHMENT_BEGIN_INFO = 1000108003, + PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES = 1000253000, + PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES = 1000175000, + PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES = 1000241000, + ATTACHMENT_REFERENCE_STENCIL_LAYOUT = 1000241001, + ATTACHMENT_DESCRIPTION_STENCIL_LAYOUT = 1000241002, + PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES = 1000261000, + PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES = 1000207000, + PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_PROPERTIES = 1000207001, + SEMAPHORE_TYPE_CREATE_INFO = 1000207002, + TIMELINE_SEMAPHORE_SUBMIT_INFO = 1000207003, + SEMAPHORE_WAIT_INFO = 1000207004, + SEMAPHORE_SIGNAL_INFO = 1000207005, + PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES = 1000257000, + BUFFER_DEVICE_ADDRESS_INFO = 1000244001, + BUFFER_OPAQUE_CAPTURE_ADDRESS_CREATE_INFO = 1000257002, + MEMORY_OPAQUE_CAPTURE_ADDRESS_ALLOCATE_INFO = 1000257003, + DEVICE_MEMORY_OPAQUE_CAPTURE_ADDRESS_INFO = 1000257004, + PHYSICAL_DEVICE_VULKAN_1_3_FEATURES = 53, + PHYSICAL_DEVICE_VULKAN_1_3_PROPERTIES = 54, + PIPELINE_CREATION_FEEDBACK_CREATE_INFO = 1000192000, + PHYSICAL_DEVICE_SHADER_TERMINATE_INVOCATION_FEATURES = 1000215000, + PHYSICAL_DEVICE_TOOL_PROPERTIES = 1000245000, + PHYSICAL_DEVICE_SHADER_DEMOTE_TO_HELPER_INVOCATION_FEATURES = 1000276000, + PHYSICAL_DEVICE_PRIVATE_DATA_FEATURES = 1000295000, + DEVICE_PRIVATE_DATA_CREATE_INFO = 1000295001, + PRIVATE_DATA_SLOT_CREATE_INFO = 1000295002, + PHYSICAL_DEVICE_PIPELINE_CREATION_CACHE_CONTROL_FEATURES = 1000297000, + MEMORY_BARRIER_2 = 1000314000, + BUFFER_MEMORY_BARRIER_2 = 1000314001, + IMAGE_MEMORY_BARRIER_2 = 1000314002, + DEPENDENCY_INFO = 1000314003, + SUBMIT_INFO_2 = 1000314004, + SEMAPHORE_SUBMIT_INFO = 1000314005, + COMMAND_BUFFER_SUBMIT_INFO = 1000314006, + PHYSICAL_DEVICE_SYNCHRONIZATION_2_FEATURES = 1000314007, + PHYSICAL_DEVICE_ZERO_INITIALIZE_WORKGROUP_MEMORY_FEATURES = 1000325000, + PHYSICAL_DEVICE_IMAGE_ROBUSTNESS_FEATURES = 1000335000, + COPY_BUFFER_INFO_2 = 1000337000, + COPY_IMAGE_INFO_2 = 1000337001, + COPY_BUFFER_TO_IMAGE_INFO_2 = 1000337002, + COPY_IMAGE_TO_BUFFER_INFO_2 = 1000337003, + BLIT_IMAGE_INFO_2 = 1000337004, + RESOLVE_IMAGE_INFO_2 = 1000337005, + BUFFER_COPY_2 = 1000337006, + IMAGE_COPY_2 = 1000337007, + IMAGE_BLIT_2 = 1000337008, + BUFFER_IMAGE_COPY_2 = 1000337009, + IMAGE_RESOLVE_2 = 1000337010, + PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_PROPERTIES = 1000225000, + PIPELINE_SHADER_STAGE_REQUIRED_SUBGROUP_SIZE_CREATE_INFO = 1000225001, + PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_FEATURES = 1000225002, + PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_FEATURES = 1000138000, + PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_PROPERTIES = 1000138001, + WRITE_DESCRIPTOR_SET_INLINE_UNIFORM_BLOCK = 1000138002, + DESCRIPTOR_POOL_INLINE_UNIFORM_BLOCK_CREATE_INFO = 1000138003, + PHYSICAL_DEVICE_TEXTURE_COMPRESSION_ASTC_HDR_FEATURES = 1000066000, + RENDERING_INFO = 1000044000, + RENDERING_ATTACHMENT_INFO = 1000044001, + PIPELINE_RENDERING_CREATE_INFO = 1000044002, + PHYSICAL_DEVICE_DYNAMIC_RENDERING_FEATURES = 1000044003, + COMMAND_BUFFER_INHERITANCE_RENDERING_INFO = 1000044004, + PHYSICAL_DEVICE_SHADER_INTEGER_DOT_PRODUCT_FEATURES = 1000280000, + PHYSICAL_DEVICE_SHADER_INTEGER_DOT_PRODUCT_PROPERTIES = 1000280001, + PHYSICAL_DEVICE_TEXEL_BUFFER_ALIGNMENT_PROPERTIES = 1000281001, + FORMAT_PROPERTIES_3 = 1000360000, + PHYSICAL_DEVICE_MAINTENANCE_4_FEATURES = 1000413000, + PHYSICAL_DEVICE_MAINTENANCE_4_PROPERTIES = 1000413001, + DEVICE_BUFFER_MEMORY_REQUIREMENTS = 1000413002, + DEVICE_IMAGE_MEMORY_REQUIREMENTS = 1000413003, + SWAPCHAIN_CREATE_INFO_KHR = 1000001000, + PRESENT_INFO_KHR = 1000001001, + DEVICE_GROUP_PRESENT_CAPABILITIES_KHR = 1000060007, + IMAGE_SWAPCHAIN_CREATE_INFO_KHR = 1000060008, + BIND_IMAGE_MEMORY_SWAPCHAIN_INFO_KHR = 1000060009, + ACQUIRE_NEXT_IMAGE_INFO_KHR = 1000060010, + DEVICE_GROUP_PRESENT_INFO_KHR = 1000060011, + DEVICE_GROUP_SWAPCHAIN_CREATE_INFO_KHR = 1000060012, + DISPLAY_MODE_CREATE_INFO_KHR = 1000002000, + DISPLAY_SURFACE_CREATE_INFO_KHR = 1000002001, + DISPLAY_PRESENT_INFO_KHR = 1000003000, + XLIB_SURFACE_CREATE_INFO_KHR = 1000004000, + XCB_SURFACE_CREATE_INFO_KHR = 1000005000, + WAYLAND_SURFACE_CREATE_INFO_KHR = 1000006000, + ANDROID_SURFACE_CREATE_INFO_KHR = 1000008000, + WIN32_SURFACE_CREATE_INFO_KHR = 1000009000, + DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT = 1000011000, + PIPELINE_RASTERIZATION_STATE_RASTERIZATION_ORDER_AMD = 1000018000, + DEBUG_MARKER_OBJECT_NAME_INFO_EXT = 1000022000, + DEBUG_MARKER_OBJECT_TAG_INFO_EXT = 1000022001, + DEBUG_MARKER_MARKER_INFO_EXT = 1000022002, + VIDEO_PROFILE_INFO_KHR = 1000023000, + VIDEO_CAPABILITIES_KHR = 1000023001, + VIDEO_PICTURE_RESOURCE_INFO_KHR = 1000023002, + VIDEO_SESSION_MEMORY_REQUIREMENTS_KHR = 1000023003, + BIND_VIDEO_SESSION_MEMORY_INFO_KHR = 1000023004, + VIDEO_SESSION_CREATE_INFO_KHR = 1000023005, + VIDEO_SESSION_PARAMETERS_CREATE_INFO_KHR = 1000023006, + VIDEO_SESSION_PARAMETERS_UPDATE_INFO_KHR = 1000023007, + VIDEO_BEGIN_CODING_INFO_KHR = 1000023008, + VIDEO_END_CODING_INFO_KHR = 1000023009, + VIDEO_CODING_CONTROL_INFO_KHR = 1000023010, + VIDEO_REFERENCE_SLOT_INFO_KHR = 1000023011, + QUEUE_FAMILY_VIDEO_PROPERTIES_KHR = 1000023012, + VIDEO_PROFILE_LIST_INFO_KHR = 1000023013, + PHYSICAL_DEVICE_VIDEO_FORMAT_INFO_KHR = 1000023014, + VIDEO_FORMAT_PROPERTIES_KHR = 1000023015, + QUEUE_FAMILY_QUERY_RESULT_STATUS_PROPERTIES_KHR = 1000023016, + VIDEO_DECODE_INFO_KHR = 1000024000, + VIDEO_DECODE_CAPABILITIES_KHR = 1000024001, + VIDEO_DECODE_USAGE_INFO_KHR = 1000024002, + DEDICATED_ALLOCATION_IMAGE_CREATE_INFO_NV = 1000026000, + DEDICATED_ALLOCATION_BUFFER_CREATE_INFO_NV = 1000026001, + DEDICATED_ALLOCATION_MEMORY_ALLOCATE_INFO_NV = 1000026002, + PHYSICAL_DEVICE_TRANSFORM_FEEDBACK_FEATURES_EXT = 1000028000, + PHYSICAL_DEVICE_TRANSFORM_FEEDBACK_PROPERTIES_EXT = 1000028001, + PIPELINE_RASTERIZATION_STATE_STREAM_CREATE_INFO_EXT = 1000028002, + CU_MODULE_CREATE_INFO_NVX = 1000029000, + CU_FUNCTION_CREATE_INFO_NVX = 1000029001, + CU_LAUNCH_INFO_NVX = 1000029002, + IMAGE_VIEW_HANDLE_INFO_NVX = 1000030000, + IMAGE_VIEW_ADDRESS_PROPERTIES_NVX = 1000030001, + VIDEO_ENCODE_H264_CAPABILITIES_EXT = 1000038000, + VIDEO_ENCODE_H264_SESSION_PARAMETERS_CREATE_INFO_EXT = 1000038001, + VIDEO_ENCODE_H264_SESSION_PARAMETERS_ADD_INFO_EXT = 1000038002, + VIDEO_ENCODE_H264_VCL_FRAME_INFO_EXT = 1000038003, + VIDEO_ENCODE_H264_DPB_SLOT_INFO_EXT = 1000038004, + VIDEO_ENCODE_H264_NALU_SLICE_INFO_EXT = 1000038005, + VIDEO_ENCODE_H264_PROFILE_INFO_EXT = 1000038007, + VIDEO_ENCODE_H264_RATE_CONTROL_INFO_EXT = 1000038008, + VIDEO_ENCODE_H264_RATE_CONTROL_LAYER_INFO_EXT = 1000038009, + VIDEO_ENCODE_H265_CAPABILITIES_EXT = 1000039000, + VIDEO_ENCODE_H265_SESSION_PARAMETERS_CREATE_INFO_EXT = 1000039001, + VIDEO_ENCODE_H265_SESSION_PARAMETERS_ADD_INFO_EXT = 1000039002, + VIDEO_ENCODE_H265_VCL_FRAME_INFO_EXT = 1000039003, + VIDEO_ENCODE_H265_DPB_SLOT_INFO_EXT = 1000039004, + VIDEO_ENCODE_H265_NALU_SLICE_SEGMENT_INFO_EXT = 1000039005, + VIDEO_ENCODE_H265_PROFILE_INFO_EXT = 1000039007, + VIDEO_ENCODE_H265_RATE_CONTROL_INFO_EXT = 1000039009, + VIDEO_ENCODE_H265_RATE_CONTROL_LAYER_INFO_EXT = 1000039010, + VIDEO_DECODE_H264_CAPABILITIES_KHR = 1000040000, + VIDEO_DECODE_H264_PICTURE_INFO_KHR = 1000040001, + VIDEO_DECODE_H264_PROFILE_INFO_KHR = 1000040003, + VIDEO_DECODE_H264_SESSION_PARAMETERS_CREATE_INFO_KHR = 1000040004, + VIDEO_DECODE_H264_SESSION_PARAMETERS_ADD_INFO_KHR = 1000040005, + VIDEO_DECODE_H264_DPB_SLOT_INFO_KHR = 1000040006, + TEXTURE_LOD_GATHER_FORMAT_PROPERTIES_AMD = 1000041000, + RENDERING_FRAGMENT_SHADING_RATE_ATTACHMENT_INFO_KHR = 1000044006, + RENDERING_FRAGMENT_DENSITY_MAP_ATTACHMENT_INFO_EXT = 1000044007, + ATTACHMENT_SAMPLE_COUNT_INFO_AMD = 1000044008, + MULTIVIEW_PER_VIEW_ATTRIBUTES_INFO_NVX = 1000044009, + STREAM_DESCRIPTOR_SURFACE_CREATE_INFO_GGP = 1000049000, + PHYSICAL_DEVICE_CORNER_SAMPLED_IMAGE_FEATURES_NV = 1000050000, + EXTERNAL_MEMORY_IMAGE_CREATE_INFO_NV = 1000056000, + EXPORT_MEMORY_ALLOCATE_INFO_NV = 1000056001, + IMPORT_MEMORY_WIN32_HANDLE_INFO_NV = 1000057000, + EXPORT_MEMORY_WIN32_HANDLE_INFO_NV = 1000057001, + WIN32_KEYED_MUTEX_ACQUIRE_RELEASE_INFO_NV = 1000058000, + VALIDATION_FLAGS_EXT = 1000061000, + VI_SURFACE_CREATE_INFO_NN = 1000062000, + IMAGE_VIEW_ASTC_DECODE_MODE_EXT = 1000067000, + PHYSICAL_DEVICE_ASTC_DECODE_FEATURES_EXT = 1000067001, + PIPELINE_ROBUSTNESS_CREATE_INFO_EXT = 1000068000, + PHYSICAL_DEVICE_PIPELINE_ROBUSTNESS_FEATURES_EXT = 1000068001, + PHYSICAL_DEVICE_PIPELINE_ROBUSTNESS_PROPERTIES_EXT = 1000068002, + IMPORT_MEMORY_WIN32_HANDLE_INFO_KHR = 1000073000, + EXPORT_MEMORY_WIN32_HANDLE_INFO_KHR = 1000073001, + MEMORY_WIN32_HANDLE_PROPERTIES_KHR = 1000073002, + MEMORY_GET_WIN32_HANDLE_INFO_KHR = 1000073003, + IMPORT_MEMORY_FD_INFO_KHR = 1000074000, + MEMORY_FD_PROPERTIES_KHR = 1000074001, + MEMORY_GET_FD_INFO_KHR = 1000074002, + WIN32_KEYED_MUTEX_ACQUIRE_RELEASE_INFO_KHR = 1000075000, + IMPORT_SEMAPHORE_WIN32_HANDLE_INFO_KHR = 1000078000, + EXPORT_SEMAPHORE_WIN32_HANDLE_INFO_KHR = 1000078001, + D3D12_FENCE_SUBMIT_INFO_KHR = 1000078002, + SEMAPHORE_GET_WIN32_HANDLE_INFO_KHR = 1000078003, + IMPORT_SEMAPHORE_FD_INFO_KHR = 1000079000, + SEMAPHORE_GET_FD_INFO_KHR = 1000079001, + PHYSICAL_DEVICE_PUSH_DESCRIPTOR_PROPERTIES_KHR = 1000080000, + COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT = 1000081000, + PHYSICAL_DEVICE_CONDITIONAL_RENDERING_FEATURES_EXT = 1000081001, + CONDITIONAL_RENDERING_BEGIN_INFO_EXT = 1000081002, + PRESENT_REGIONS_KHR = 1000084000, + PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV = 1000087000, + SURFACE_CAPABILITIES_2_EXT = 1000090000, + DISPLAY_POWER_INFO_EXT = 1000091000, + DEVICE_EVENT_INFO_EXT = 1000091001, + DISPLAY_EVENT_INFO_EXT = 1000091002, + SWAPCHAIN_COUNTER_CREATE_INFO_EXT = 1000091003, + PRESENT_TIMES_INFO_GOOGLE = 1000092000, + PHYSICAL_DEVICE_MULTIVIEW_PER_VIEW_ATTRIBUTES_PROPERTIES_NVX = 1000097000, + PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV = 1000098000, + PHYSICAL_DEVICE_DISCARD_RECTANGLE_PROPERTIES_EXT = 1000099000, + PIPELINE_DISCARD_RECTANGLE_STATE_CREATE_INFO_EXT = 1000099001, + PHYSICAL_DEVICE_CONSERVATIVE_RASTERIZATION_PROPERTIES_EXT = 1000101000, + PIPELINE_RASTERIZATION_CONSERVATIVE_STATE_CREATE_INFO_EXT = 1000101001, + PHYSICAL_DEVICE_DEPTH_CLIP_ENABLE_FEATURES_EXT = 1000102000, + PIPELINE_RASTERIZATION_DEPTH_CLIP_STATE_CREATE_INFO_EXT = 1000102001, + HDR_METADATA_EXT = 1000105000, + SHARED_PRESENT_SURFACE_CAPABILITIES_KHR = 1000111000, + IMPORT_FENCE_WIN32_HANDLE_INFO_KHR = 1000114000, + EXPORT_FENCE_WIN32_HANDLE_INFO_KHR = 1000114001, + FENCE_GET_WIN32_HANDLE_INFO_KHR = 1000114002, + IMPORT_FENCE_FD_INFO_KHR = 1000115000, + FENCE_GET_FD_INFO_KHR = 1000115001, + PHYSICAL_DEVICE_PERFORMANCE_QUERY_FEATURES_KHR = 1000116000, + PHYSICAL_DEVICE_PERFORMANCE_QUERY_PROPERTIES_KHR = 1000116001, + QUERY_POOL_PERFORMANCE_CREATE_INFO_KHR = 1000116002, + PERFORMANCE_QUERY_SUBMIT_INFO_KHR = 1000116003, + ACQUIRE_PROFILING_LOCK_INFO_KHR = 1000116004, + PERFORMANCE_COUNTER_KHR = 1000116005, + PERFORMANCE_COUNTER_DESCRIPTION_KHR = 1000116006, + PHYSICAL_DEVICE_SURFACE_INFO_2_KHR = 1000119000, + SURFACE_CAPABILITIES_2_KHR = 1000119001, + SURFACE_FORMAT_2_KHR = 1000119002, + DISPLAY_PROPERTIES_2_KHR = 1000121000, + DISPLAY_PLANE_PROPERTIES_2_KHR = 1000121001, + DISPLAY_MODE_PROPERTIES_2_KHR = 1000121002, + DISPLAY_PLANE_INFO_2_KHR = 1000121003, + DISPLAY_PLANE_CAPABILITIES_2_KHR = 1000121004, + IOS_SURFACE_CREATE_INFO_MVK = 1000122000, + MACOS_SURFACE_CREATE_INFO_MVK = 1000123000, + DEBUG_UTILS_OBJECT_NAME_INFO_EXT = 1000128000, + DEBUG_UTILS_OBJECT_TAG_INFO_EXT = 1000128001, + DEBUG_UTILS_LABEL_EXT = 1000128002, + DEBUG_UTILS_MESSENGER_CALLBACK_DATA_EXT = 1000128003, + DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT = 1000128004, + ANDROID_HARDWARE_BUFFER_USAGE_ANDROID = 1000129000, + ANDROID_HARDWARE_BUFFER_PROPERTIES_ANDROID = 1000129001, + ANDROID_HARDWARE_BUFFER_FORMAT_PROPERTIES_ANDROID = 1000129002, + IMPORT_ANDROID_HARDWARE_BUFFER_INFO_ANDROID = 1000129003, + MEMORY_GET_ANDROID_HARDWARE_BUFFER_INFO_ANDROID = 1000129004, + EXTERNAL_FORMAT_ANDROID = 1000129005, + ANDROID_HARDWARE_BUFFER_FORMAT_PROPERTIES_2_ANDROID = 1000129006, + SAMPLE_LOCATIONS_INFO_EXT = 1000143000, + RENDER_PASS_SAMPLE_LOCATIONS_BEGIN_INFO_EXT = 1000143001, + PIPELINE_SAMPLE_LOCATIONS_STATE_CREATE_INFO_EXT = 1000143002, + PHYSICAL_DEVICE_SAMPLE_LOCATIONS_PROPERTIES_EXT = 1000143003, + MULTISAMPLE_PROPERTIES_EXT = 1000143004, + PHYSICAL_DEVICE_BLEND_OPERATION_ADVANCED_FEATURES_EXT = 1000148000, + PHYSICAL_DEVICE_BLEND_OPERATION_ADVANCED_PROPERTIES_EXT = 1000148001, + PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT = 1000148002, + PIPELINE_COVERAGE_TO_COLOR_STATE_CREATE_INFO_NV = 1000149000, + WRITE_DESCRIPTOR_SET_ACCELERATION_STRUCTURE_KHR = 1000150007, + ACCELERATION_STRUCTURE_BUILD_GEOMETRY_INFO_KHR = 1000150000, + ACCELERATION_STRUCTURE_DEVICE_ADDRESS_INFO_KHR = 1000150002, + ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR = 1000150003, + ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR = 1000150004, + ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR = 1000150005, + ACCELERATION_STRUCTURE_GEOMETRY_KHR = 1000150006, + ACCELERATION_STRUCTURE_VERSION_INFO_KHR = 1000150009, + COPY_ACCELERATION_STRUCTURE_INFO_KHR = 1000150010, + COPY_ACCELERATION_STRUCTURE_TO_MEMORY_INFO_KHR = 1000150011, + COPY_MEMORY_TO_ACCELERATION_STRUCTURE_INFO_KHR = 1000150012, + PHYSICAL_DEVICE_ACCELERATION_STRUCTURE_FEATURES_KHR = 1000150013, + PHYSICAL_DEVICE_ACCELERATION_STRUCTURE_PROPERTIES_KHR = 1000150014, + ACCELERATION_STRUCTURE_CREATE_INFO_KHR = 1000150017, + ACCELERATION_STRUCTURE_BUILD_SIZES_INFO_KHR = 1000150020, + PHYSICAL_DEVICE_RAY_TRACING_PIPELINE_FEATURES_KHR = 1000347000, + PHYSICAL_DEVICE_RAY_TRACING_PIPELINE_PROPERTIES_KHR = 1000347001, + RAY_TRACING_PIPELINE_CREATE_INFO_KHR = 1000150015, + RAY_TRACING_SHADER_GROUP_CREATE_INFO_KHR = 1000150016, + RAY_TRACING_PIPELINE_INTERFACE_CREATE_INFO_KHR = 1000150018, + PHYSICAL_DEVICE_RAY_QUERY_FEATURES_KHR = 1000348013, + PIPELINE_COVERAGE_MODULATION_STATE_CREATE_INFO_NV = 1000152000, + PHYSICAL_DEVICE_SHADER_SM_BUILTINS_FEATURES_NV = 1000154000, + PHYSICAL_DEVICE_SHADER_SM_BUILTINS_PROPERTIES_NV = 1000154001, + DRM_FORMAT_MODIFIER_PROPERTIES_LIST_EXT = 1000158000, + PHYSICAL_DEVICE_IMAGE_DRM_FORMAT_MODIFIER_INFO_EXT = 1000158002, + IMAGE_DRM_FORMAT_MODIFIER_LIST_CREATE_INFO_EXT = 1000158003, + IMAGE_DRM_FORMAT_MODIFIER_EXPLICIT_CREATE_INFO_EXT = 1000158004, + IMAGE_DRM_FORMAT_MODIFIER_PROPERTIES_EXT = 1000158005, + DRM_FORMAT_MODIFIER_PROPERTIES_LIST_2_EXT = 1000158006, + VALIDATION_CACHE_CREATE_INFO_EXT = 1000160000, + SHADER_MODULE_VALIDATION_CACHE_CREATE_INFO_EXT = 1000160001, + PHYSICAL_DEVICE_PORTABILITY_SUBSET_FEATURES_KHR = 1000163000, + PHYSICAL_DEVICE_PORTABILITY_SUBSET_PROPERTIES_KHR = 1000163001, + PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV = 1000164000, + PHYSICAL_DEVICE_SHADING_RATE_IMAGE_FEATURES_NV = 1000164001, + PHYSICAL_DEVICE_SHADING_RATE_IMAGE_PROPERTIES_NV = 1000164002, + PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV = 1000164005, + RAY_TRACING_PIPELINE_CREATE_INFO_NV = 1000165000, + ACCELERATION_STRUCTURE_CREATE_INFO_NV = 1000165001, + GEOMETRY_NV = 1000165003, + GEOMETRY_TRIANGLES_NV = 1000165004, + GEOMETRY_AABB_NV = 1000165005, + BIND_ACCELERATION_STRUCTURE_MEMORY_INFO_NV = 1000165006, + WRITE_DESCRIPTOR_SET_ACCELERATION_STRUCTURE_NV = 1000165007, + ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_INFO_NV = 1000165008, + PHYSICAL_DEVICE_RAY_TRACING_PROPERTIES_NV = 1000165009, + RAY_TRACING_SHADER_GROUP_CREATE_INFO_NV = 1000165011, + ACCELERATION_STRUCTURE_INFO_NV = 1000165012, + PHYSICAL_DEVICE_REPRESENTATIVE_FRAGMENT_TEST_FEATURES_NV = 1000166000, + PIPELINE_REPRESENTATIVE_FRAGMENT_TEST_STATE_CREATE_INFO_NV = 1000166001, + PHYSICAL_DEVICE_IMAGE_VIEW_IMAGE_FORMAT_INFO_EXT = 1000170000, + FILTER_CUBIC_IMAGE_VIEW_IMAGE_FORMAT_PROPERTIES_EXT = 1000170001, + IMPORT_MEMORY_HOST_POINTER_INFO_EXT = 1000178000, + MEMORY_HOST_POINTER_PROPERTIES_EXT = 1000178001, + PHYSICAL_DEVICE_EXTERNAL_MEMORY_HOST_PROPERTIES_EXT = 1000178002, + PHYSICAL_DEVICE_SHADER_CLOCK_FEATURES_KHR = 1000181000, + PIPELINE_COMPILER_CONTROL_CREATE_INFO_AMD = 1000183000, + CALIBRATED_TIMESTAMP_INFO_EXT = 1000184000, + PHYSICAL_DEVICE_SHADER_CORE_PROPERTIES_AMD = 1000185000, + VIDEO_DECODE_H265_CAPABILITIES_KHR = 1000187000, + VIDEO_DECODE_H265_SESSION_PARAMETERS_CREATE_INFO_KHR = 1000187001, + VIDEO_DECODE_H265_SESSION_PARAMETERS_ADD_INFO_KHR = 1000187002, + VIDEO_DECODE_H265_PROFILE_INFO_KHR = 1000187003, + VIDEO_DECODE_H265_PICTURE_INFO_KHR = 1000187004, + VIDEO_DECODE_H265_DPB_SLOT_INFO_KHR = 1000187005, + DEVICE_QUEUE_GLOBAL_PRIORITY_CREATE_INFO_KHR = 1000174000, + PHYSICAL_DEVICE_GLOBAL_PRIORITY_QUERY_FEATURES_KHR = 1000388000, + QUEUE_FAMILY_GLOBAL_PRIORITY_PROPERTIES_KHR = 1000388001, + DEVICE_MEMORY_OVERALLOCATION_CREATE_INFO_AMD = 1000189000, + PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_PROPERTIES_EXT = 1000190000, + PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT = 1000190001, + PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_FEATURES_EXT = 1000190002, + PRESENT_FRAME_TOKEN_GGP = 1000191000, + PHYSICAL_DEVICE_COMPUTE_SHADER_DERIVATIVES_FEATURES_NV = 1000201000, + PHYSICAL_DEVICE_MESH_SHADER_FEATURES_NV = 1000202000, + PHYSICAL_DEVICE_MESH_SHADER_PROPERTIES_NV = 1000202001, + PHYSICAL_DEVICE_SHADER_IMAGE_FOOTPRINT_FEATURES_NV = 1000204000, + PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV = 1000205000, + PHYSICAL_DEVICE_EXCLUSIVE_SCISSOR_FEATURES_NV = 1000205002, + CHECKPOINT_DATA_NV = 1000206000, + QUEUE_FAMILY_CHECKPOINT_PROPERTIES_NV = 1000206001, + PHYSICAL_DEVICE_SHADER_INTEGER_FUNCTIONS_2_FEATURES_INTEL = 1000209000, + QUERY_POOL_PERFORMANCE_QUERY_CREATE_INFO_INTEL = 1000210000, + INITIALIZE_PERFORMANCE_API_INFO_INTEL = 1000210001, + PERFORMANCE_MARKER_INFO_INTEL = 1000210002, + PERFORMANCE_STREAM_MARKER_INFO_INTEL = 1000210003, + PERFORMANCE_OVERRIDE_INFO_INTEL = 1000210004, + PERFORMANCE_CONFIGURATION_ACQUIRE_INFO_INTEL = 1000210005, + PHYSICAL_DEVICE_PCI_BUS_INFO_PROPERTIES_EXT = 1000212000, + DISPLAY_NATIVE_HDR_SURFACE_CAPABILITIES_AMD = 1000213000, + SWAPCHAIN_DISPLAY_NATIVE_HDR_CREATE_INFO_AMD = 1000213001, + IMAGEPIPE_SURFACE_CREATE_INFO_FUCHSIA = 1000214000, + METAL_SURFACE_CREATE_INFO_EXT = 1000217000, + PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_FEATURES_EXT = 1000218000, + PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_PROPERTIES_EXT = 1000218001, + RENDER_PASS_FRAGMENT_DENSITY_MAP_CREATE_INFO_EXT = 1000218002, + FRAGMENT_SHADING_RATE_ATTACHMENT_INFO_KHR = 1000226000, + PIPELINE_FRAGMENT_SHADING_RATE_STATE_CREATE_INFO_KHR = 1000226001, + PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_PROPERTIES_KHR = 1000226002, + PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_FEATURES_KHR = 1000226003, + PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_KHR = 1000226004, + PHYSICAL_DEVICE_SHADER_CORE_PROPERTIES_2_AMD = 1000227000, + PHYSICAL_DEVICE_COHERENT_MEMORY_FEATURES_AMD = 1000229000, + PHYSICAL_DEVICE_SHADER_IMAGE_ATOMIC_INT64_FEATURES_EXT = 1000234000, + PHYSICAL_DEVICE_MEMORY_BUDGET_PROPERTIES_EXT = 1000237000, + PHYSICAL_DEVICE_MEMORY_PRIORITY_FEATURES_EXT = 1000238000, + MEMORY_PRIORITY_ALLOCATE_INFO_EXT = 1000238001, + SURFACE_PROTECTED_CAPABILITIES_KHR = 1000239000, + PHYSICAL_DEVICE_DEDICATED_ALLOCATION_IMAGE_ALIASING_FEATURES_NV = 1000240000, + PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES_EXT = 1000244000, + BUFFER_DEVICE_ADDRESS_CREATE_INFO_EXT = 1000244002, + VALIDATION_FEATURES_EXT = 1000247000, + PHYSICAL_DEVICE_PRESENT_WAIT_FEATURES_KHR = 1000248000, + PHYSICAL_DEVICE_COOPERATIVE_MATRIX_FEATURES_NV = 1000249000, + COOPERATIVE_MATRIX_PROPERTIES_NV = 1000249001, + PHYSICAL_DEVICE_COOPERATIVE_MATRIX_PROPERTIES_NV = 1000249002, + PHYSICAL_DEVICE_COVERAGE_REDUCTION_MODE_FEATURES_NV = 1000250000, + PIPELINE_COVERAGE_REDUCTION_STATE_CREATE_INFO_NV = 1000250001, + FRAMEBUFFER_MIXED_SAMPLES_COMBINATION_NV = 1000250002, + PHYSICAL_DEVICE_FRAGMENT_SHADER_INTERLOCK_FEATURES_EXT = 1000251000, + PHYSICAL_DEVICE_YCBCR_IMAGE_ARRAYS_FEATURES_EXT = 1000252000, + PHYSICAL_DEVICE_PROVOKING_VERTEX_FEATURES_EXT = 1000254000, + PIPELINE_RASTERIZATION_PROVOKING_VERTEX_STATE_CREATE_INFO_EXT = 1000254001, + PHYSICAL_DEVICE_PROVOKING_VERTEX_PROPERTIES_EXT = 1000254002, + SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT = 1000255000, + SURFACE_CAPABILITIES_FULL_SCREEN_EXCLUSIVE_EXT = 1000255002, + SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT = 1000255001, + HEADLESS_SURFACE_CREATE_INFO_EXT = 1000256000, + PHYSICAL_DEVICE_LINE_RASTERIZATION_FEATURES_EXT = 1000259000, + PIPELINE_RASTERIZATION_LINE_STATE_CREATE_INFO_EXT = 1000259001, + PHYSICAL_DEVICE_LINE_RASTERIZATION_PROPERTIES_EXT = 1000259002, + PHYSICAL_DEVICE_SHADER_ATOMIC_FLOAT_FEATURES_EXT = 1000260000, + PHYSICAL_DEVICE_INDEX_TYPE_UINT8_FEATURES_EXT = 1000265000, + PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_FEATURES_EXT = 1000267000, + PHYSICAL_DEVICE_PIPELINE_EXECUTABLE_PROPERTIES_FEATURES_KHR = 1000269000, + PIPELINE_INFO_KHR = 1000269001, + PIPELINE_EXECUTABLE_PROPERTIES_KHR = 1000269002, + PIPELINE_EXECUTABLE_INFO_KHR = 1000269003, + PIPELINE_EXECUTABLE_STATISTIC_KHR = 1000269004, + PIPELINE_EXECUTABLE_INTERNAL_REPRESENTATION_KHR = 1000269005, + MEMORY_MAP_INFO_KHR = 1000271000, + MEMORY_UNMAP_INFO_KHR = 1000271001, + PHYSICAL_DEVICE_SHADER_ATOMIC_FLOAT_2_FEATURES_EXT = 1000273000, + SURFACE_PRESENT_MODE_EXT = 1000274000, + SURFACE_PRESENT_SCALING_CAPABILITIES_EXT = 1000274001, + SURFACE_PRESENT_MODE_COMPATIBILITY_EXT = 1000274002, + PHYSICAL_DEVICE_SWAPCHAIN_MAINTENANCE_1_FEATURES_EXT = 1000275000, + SWAPCHAIN_PRESENT_FENCE_INFO_EXT = 1000275001, + SWAPCHAIN_PRESENT_MODES_CREATE_INFO_EXT = 1000275002, + SWAPCHAIN_PRESENT_MODE_INFO_EXT = 1000275003, + SWAPCHAIN_PRESENT_SCALING_CREATE_INFO_EXT = 1000275004, + RELEASE_SWAPCHAIN_IMAGES_INFO_EXT = 1000275005, + PHYSICAL_DEVICE_DEVICE_GENERATED_COMMANDS_PROPERTIES_NV = 1000277000, + GRAPHICS_SHADER_GROUP_CREATE_INFO_NV = 1000277001, + GRAPHICS_PIPELINE_SHADER_GROUPS_CREATE_INFO_NV = 1000277002, + INDIRECT_COMMANDS_LAYOUT_TOKEN_NV = 1000277003, + INDIRECT_COMMANDS_LAYOUT_CREATE_INFO_NV = 1000277004, + GENERATED_COMMANDS_INFO_NV = 1000277005, + GENERATED_COMMANDS_MEMORY_REQUIREMENTS_INFO_NV = 1000277006, + PHYSICAL_DEVICE_DEVICE_GENERATED_COMMANDS_FEATURES_NV = 1000277007, + PHYSICAL_DEVICE_INHERITED_VIEWPORT_SCISSOR_FEATURES_NV = 1000278000, + COMMAND_BUFFER_INHERITANCE_VIEWPORT_SCISSOR_INFO_NV = 1000278001, + PHYSICAL_DEVICE_TEXEL_BUFFER_ALIGNMENT_FEATURES_EXT = 1000281000, + COMMAND_BUFFER_INHERITANCE_RENDER_PASS_TRANSFORM_INFO_QCOM = 1000282000, + RENDER_PASS_TRANSFORM_BEGIN_INFO_QCOM = 1000282001, + PHYSICAL_DEVICE_DEVICE_MEMORY_REPORT_FEATURES_EXT = 1000284000, + DEVICE_DEVICE_MEMORY_REPORT_CREATE_INFO_EXT = 1000284001, + DEVICE_MEMORY_REPORT_CALLBACK_DATA_EXT = 1000284002, + PHYSICAL_DEVICE_ROBUSTNESS_2_FEATURES_EXT = 1000286000, + PHYSICAL_DEVICE_ROBUSTNESS_2_PROPERTIES_EXT = 1000286001, + SAMPLER_CUSTOM_BORDER_COLOR_CREATE_INFO_EXT = 1000287000, + PHYSICAL_DEVICE_CUSTOM_BORDER_COLOR_PROPERTIES_EXT = 1000287001, + PHYSICAL_DEVICE_CUSTOM_BORDER_COLOR_FEATURES_EXT = 1000287002, + PIPELINE_LIBRARY_CREATE_INFO_KHR = 1000290000, + PHYSICAL_DEVICE_PRESENT_BARRIER_FEATURES_NV = 1000292000, + SURFACE_CAPABILITIES_PRESENT_BARRIER_NV = 1000292001, + SWAPCHAIN_PRESENT_BARRIER_CREATE_INFO_NV = 1000292002, + PRESENT_ID_KHR = 1000294000, + PHYSICAL_DEVICE_PRESENT_ID_FEATURES_KHR = 1000294001, + VIDEO_ENCODE_INFO_KHR = 1000299000, + VIDEO_ENCODE_RATE_CONTROL_INFO_KHR = 1000299001, + VIDEO_ENCODE_RATE_CONTROL_LAYER_INFO_KHR = 1000299002, + VIDEO_ENCODE_CAPABILITIES_KHR = 1000299003, + VIDEO_ENCODE_USAGE_INFO_KHR = 1000299004, + QUERY_POOL_VIDEO_ENCODE_FEEDBACK_CREATE_INFO_KHR = 1000299005, + PHYSICAL_DEVICE_DIAGNOSTICS_CONFIG_FEATURES_NV = 1000300000, + DEVICE_DIAGNOSTICS_CONFIG_CREATE_INFO_NV = 1000300001, + QUERY_LOW_LATENCY_SUPPORT_NV = 1000310000, + EXPORT_METAL_OBJECT_CREATE_INFO_EXT = 1000311000, + EXPORT_METAL_OBJECTS_INFO_EXT = 1000311001, + EXPORT_METAL_DEVICE_INFO_EXT = 1000311002, + EXPORT_METAL_COMMAND_QUEUE_INFO_EXT = 1000311003, + EXPORT_METAL_BUFFER_INFO_EXT = 1000311004, + IMPORT_METAL_BUFFER_INFO_EXT = 1000311005, + EXPORT_METAL_TEXTURE_INFO_EXT = 1000311006, + IMPORT_METAL_TEXTURE_INFO_EXT = 1000311007, + EXPORT_METAL_IO_SURFACE_INFO_EXT = 1000311008, + IMPORT_METAL_IO_SURFACE_INFO_EXT = 1000311009, + EXPORT_METAL_SHARED_EVENT_INFO_EXT = 1000311010, + IMPORT_METAL_SHARED_EVENT_INFO_EXT = 1000311011, + QUEUE_FAMILY_CHECKPOINT_PROPERTIES_2_NV = 1000314008, + CHECKPOINT_DATA_2_NV = 1000314009, + PHYSICAL_DEVICE_DESCRIPTOR_BUFFER_PROPERTIES_EXT = 1000316000, + PHYSICAL_DEVICE_DESCRIPTOR_BUFFER_DENSITY_MAP_PROPERTIES_EXT = 1000316001, + PHYSICAL_DEVICE_DESCRIPTOR_BUFFER_FEATURES_EXT = 1000316002, + DESCRIPTOR_ADDRESS_INFO_EXT = 1000316003, + DESCRIPTOR_GET_INFO_EXT = 1000316004, + BUFFER_CAPTURE_DESCRIPTOR_DATA_INFO_EXT = 1000316005, + IMAGE_CAPTURE_DESCRIPTOR_DATA_INFO_EXT = 1000316006, + IMAGE_VIEW_CAPTURE_DESCRIPTOR_DATA_INFO_EXT = 1000316007, + SAMPLER_CAPTURE_DESCRIPTOR_DATA_INFO_EXT = 1000316008, + OPAQUE_CAPTURE_DESCRIPTOR_DATA_CREATE_INFO_EXT = 1000316010, + DESCRIPTOR_BUFFER_BINDING_INFO_EXT = 1000316011, + DESCRIPTOR_BUFFER_BINDING_PUSH_DESCRIPTOR_BUFFER_HANDLE_EXT = 1000316012, + ACCELERATION_STRUCTURE_CAPTURE_DESCRIPTOR_DATA_INFO_EXT = 1000316009, + PHYSICAL_DEVICE_GRAPHICS_PIPELINE_LIBRARY_FEATURES_EXT = 1000320000, + PHYSICAL_DEVICE_GRAPHICS_PIPELINE_LIBRARY_PROPERTIES_EXT = 1000320001, + GRAPHICS_PIPELINE_LIBRARY_CREATE_INFO_EXT = 1000320002, + PHYSICAL_DEVICE_SHADER_EARLY_AND_LATE_FRAGMENT_TESTS_FEATURES_AMD = 1000321000, + PHYSICAL_DEVICE_FRAGMENT_SHADER_BARYCENTRIC_FEATURES_KHR = 1000203000, + PHYSICAL_DEVICE_FRAGMENT_SHADER_BARYCENTRIC_PROPERTIES_KHR = 1000322000, + PHYSICAL_DEVICE_SHADER_SUBGROUP_UNIFORM_CONTROL_FLOW_FEATURES_KHR = 1000323000, + PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_ENUMS_PROPERTIES_NV = 1000326000, + PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_ENUMS_FEATURES_NV = 1000326001, + PIPELINE_FRAGMENT_SHADING_RATE_ENUM_STATE_CREATE_INFO_NV = 1000326002, + ACCELERATION_STRUCTURE_GEOMETRY_MOTION_TRIANGLES_DATA_NV = 1000327000, + PHYSICAL_DEVICE_RAY_TRACING_MOTION_BLUR_FEATURES_NV = 1000327001, + ACCELERATION_STRUCTURE_MOTION_INFO_NV = 1000327002, + PHYSICAL_DEVICE_MESH_SHADER_FEATURES_EXT = 1000328000, + PHYSICAL_DEVICE_MESH_SHADER_PROPERTIES_EXT = 1000328001, + PHYSICAL_DEVICE_YCBCR_2_PLANE_444_FORMATS_FEATURES_EXT = 1000330000, + PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_2_FEATURES_EXT = 1000332000, + PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_2_PROPERTIES_EXT = 1000332001, + COPY_COMMAND_TRANSFORM_INFO_QCOM = 1000333000, + PHYSICAL_DEVICE_WORKGROUP_MEMORY_EXPLICIT_LAYOUT_FEATURES_KHR = 1000336000, + PHYSICAL_DEVICE_IMAGE_COMPRESSION_CONTROL_FEATURES_EXT = 1000338000, + IMAGE_COMPRESSION_CONTROL_EXT = 1000338001, + SUBRESOURCE_LAYOUT_2_EXT = 1000338002, + IMAGE_SUBRESOURCE_2_EXT = 1000338003, + IMAGE_COMPRESSION_PROPERTIES_EXT = 1000338004, + PHYSICAL_DEVICE_ATTACHMENT_FEEDBACK_LOOP_LAYOUT_FEATURES_EXT = 1000339000, + PHYSICAL_DEVICE_4444_FORMATS_FEATURES_EXT = 1000340000, + PHYSICAL_DEVICE_FAULT_FEATURES_EXT = 1000341000, + DEVICE_FAULT_COUNTS_EXT = 1000341001, + DEVICE_FAULT_INFO_EXT = 1000341002, + PHYSICAL_DEVICE_RGBA10X6_FORMATS_FEATURES_EXT = 1000344000, + DIRECTFB_SURFACE_CREATE_INFO_EXT = 1000346000, + PHYSICAL_DEVICE_VERTEX_INPUT_DYNAMIC_STATE_FEATURES_EXT = 1000352000, + VERTEX_INPUT_BINDING_DESCRIPTION_2_EXT = 1000352001, + VERTEX_INPUT_ATTRIBUTE_DESCRIPTION_2_EXT = 1000352002, + PHYSICAL_DEVICE_DRM_PROPERTIES_EXT = 1000353000, + PHYSICAL_DEVICE_ADDRESS_BINDING_REPORT_FEATURES_EXT = 1000354000, + DEVICE_ADDRESS_BINDING_CALLBACK_DATA_EXT = 1000354001, + PHYSICAL_DEVICE_DEPTH_CLIP_CONTROL_FEATURES_EXT = 1000355000, + PIPELINE_VIEWPORT_DEPTH_CLIP_CONTROL_CREATE_INFO_EXT = 1000355001, + PHYSICAL_DEVICE_PRIMITIVE_TOPOLOGY_LIST_RESTART_FEATURES_EXT = 1000356000, + IMPORT_MEMORY_ZIRCON_HANDLE_INFO_FUCHSIA = 1000364000, + MEMORY_ZIRCON_HANDLE_PROPERTIES_FUCHSIA = 1000364001, + MEMORY_GET_ZIRCON_HANDLE_INFO_FUCHSIA = 1000364002, + IMPORT_SEMAPHORE_ZIRCON_HANDLE_INFO_FUCHSIA = 1000365000, + SEMAPHORE_GET_ZIRCON_HANDLE_INFO_FUCHSIA = 1000365001, + BUFFER_COLLECTION_CREATE_INFO_FUCHSIA = 1000366000, + IMPORT_MEMORY_BUFFER_COLLECTION_FUCHSIA = 1000366001, + BUFFER_COLLECTION_IMAGE_CREATE_INFO_FUCHSIA = 1000366002, + BUFFER_COLLECTION_PROPERTIES_FUCHSIA = 1000366003, + BUFFER_CONSTRAINTS_INFO_FUCHSIA = 1000366004, + BUFFER_COLLECTION_BUFFER_CREATE_INFO_FUCHSIA = 1000366005, + IMAGE_CONSTRAINTS_INFO_FUCHSIA = 1000366006, + IMAGE_FORMAT_CONSTRAINTS_INFO_FUCHSIA = 1000366007, + SYSMEM_COLOR_SPACE_FUCHSIA = 1000366008, + BUFFER_COLLECTION_CONSTRAINTS_INFO_FUCHSIA = 1000366009, + SUBPASS_SHADING_PIPELINE_CREATE_INFO_HUAWEI = 1000369000, + PHYSICAL_DEVICE_SUBPASS_SHADING_FEATURES_HUAWEI = 1000369001, + PHYSICAL_DEVICE_SUBPASS_SHADING_PROPERTIES_HUAWEI = 1000369002, + PHYSICAL_DEVICE_INVOCATION_MASK_FEATURES_HUAWEI = 1000370000, + MEMORY_GET_REMOTE_ADDRESS_INFO_NV = 1000371000, + PHYSICAL_DEVICE_EXTERNAL_MEMORY_RDMA_FEATURES_NV = 1000371001, + PIPELINE_PROPERTIES_IDENTIFIER_EXT = 1000372000, + PHYSICAL_DEVICE_PIPELINE_PROPERTIES_FEATURES_EXT = 1000372001, + PHYSICAL_DEVICE_MULTISAMPLED_RENDER_TO_SINGLE_SAMPLED_FEATURES_EXT = 1000376000, + SUBPASS_RESOLVE_PERFORMANCE_QUERY_EXT = 1000376001, + MULTISAMPLED_RENDER_TO_SINGLE_SAMPLED_INFO_EXT = 1000376002, + PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_2_FEATURES_EXT = 1000377000, + SCREEN_SURFACE_CREATE_INFO_QNX = 1000378000, + PHYSICAL_DEVICE_COLOR_WRITE_ENABLE_FEATURES_EXT = 1000381000, + PIPELINE_COLOR_WRITE_CREATE_INFO_EXT = 1000381001, + PHYSICAL_DEVICE_PRIMITIVES_GENERATED_QUERY_FEATURES_EXT = 1000382000, + PHYSICAL_DEVICE_RAY_TRACING_MAINTENANCE_1_FEATURES_KHR = 1000386000, + PHYSICAL_DEVICE_IMAGE_VIEW_MIN_LOD_FEATURES_EXT = 1000391000, + IMAGE_VIEW_MIN_LOD_CREATE_INFO_EXT = 1000391001, + PHYSICAL_DEVICE_MULTI_DRAW_FEATURES_EXT = 1000392000, + PHYSICAL_DEVICE_MULTI_DRAW_PROPERTIES_EXT = 1000392001, + PHYSICAL_DEVICE_IMAGE_2D_VIEW_OF_3D_FEATURES_EXT = 1000393000, + PHYSICAL_DEVICE_SHADER_TILE_IMAGE_FEATURES_EXT = 1000395000, + PHYSICAL_DEVICE_SHADER_TILE_IMAGE_PROPERTIES_EXT = 1000395001, + MICROMAP_BUILD_INFO_EXT = 1000396000, + MICROMAP_VERSION_INFO_EXT = 1000396001, + COPY_MICROMAP_INFO_EXT = 1000396002, + COPY_MICROMAP_TO_MEMORY_INFO_EXT = 1000396003, + COPY_MEMORY_TO_MICROMAP_INFO_EXT = 1000396004, + PHYSICAL_DEVICE_OPACITY_MICROMAP_FEATURES_EXT = 1000396005, + PHYSICAL_DEVICE_OPACITY_MICROMAP_PROPERTIES_EXT = 1000396006, + MICROMAP_CREATE_INFO_EXT = 1000396007, + MICROMAP_BUILD_SIZES_INFO_EXT = 1000396008, + ACCELERATION_STRUCTURE_TRIANGLES_OPACITY_MICROMAP_EXT = 1000396009, + PHYSICAL_DEVICE_DISPLACEMENT_MICROMAP_FEATURES_NV = 1000397000, + PHYSICAL_DEVICE_DISPLACEMENT_MICROMAP_PROPERTIES_NV = 1000397001, + ACCELERATION_STRUCTURE_TRIANGLES_DISPLACEMENT_MICROMAP_NV = 1000397002, + PHYSICAL_DEVICE_CLUSTER_CULLING_SHADER_FEATURES_HUAWEI = 1000404000, + PHYSICAL_DEVICE_CLUSTER_CULLING_SHADER_PROPERTIES_HUAWEI = 1000404001, + PHYSICAL_DEVICE_BORDER_COLOR_SWIZZLE_FEATURES_EXT = 1000411000, + SAMPLER_BORDER_COLOR_COMPONENT_MAPPING_CREATE_INFO_EXT = 1000411001, + PHYSICAL_DEVICE_PAGEABLE_DEVICE_LOCAL_MEMORY_FEATURES_EXT = 1000412000, + PHYSICAL_DEVICE_SHADER_CORE_PROPERTIES_ARM = 1000415000, + PHYSICAL_DEVICE_IMAGE_SLICED_VIEW_OF_3D_FEATURES_EXT = 1000418000, + IMAGE_VIEW_SLICED_CREATE_INFO_EXT = 1000418001, + PHYSICAL_DEVICE_DESCRIPTOR_SET_HOST_MAPPING_FEATURES_VALVE = 1000420000, + DESCRIPTOR_SET_BINDING_REFERENCE_VALVE = 1000420001, + DESCRIPTOR_SET_LAYOUT_HOST_MAPPING_INFO_VALVE = 1000420002, + PHYSICAL_DEVICE_DEPTH_CLAMP_ZERO_ONE_FEATURES_EXT = 1000421000, + PHYSICAL_DEVICE_NON_SEAMLESS_CUBE_MAP_FEATURES_EXT = 1000422000, + PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_OFFSET_FEATURES_QCOM = 1000425000, + PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_OFFSET_PROPERTIES_QCOM = 1000425001, + SUBPASS_FRAGMENT_DENSITY_MAP_OFFSET_END_INFO_QCOM = 1000425002, + PHYSICAL_DEVICE_COPY_MEMORY_INDIRECT_FEATURES_NV = 1000426000, + PHYSICAL_DEVICE_COPY_MEMORY_INDIRECT_PROPERTIES_NV = 1000426001, + PHYSICAL_DEVICE_MEMORY_DECOMPRESSION_FEATURES_NV = 1000427000, + PHYSICAL_DEVICE_MEMORY_DECOMPRESSION_PROPERTIES_NV = 1000427001, + PHYSICAL_DEVICE_LINEAR_COLOR_ATTACHMENT_FEATURES_NV = 1000430000, + PHYSICAL_DEVICE_IMAGE_COMPRESSION_CONTROL_SWAPCHAIN_FEATURES_EXT = 1000437000, + PHYSICAL_DEVICE_IMAGE_PROCESSING_FEATURES_QCOM = 1000440000, + PHYSICAL_DEVICE_IMAGE_PROCESSING_PROPERTIES_QCOM = 1000440001, + IMAGE_VIEW_SAMPLE_WEIGHT_CREATE_INFO_QCOM = 1000440002, + PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_3_FEATURES_EXT = 1000455000, + PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_3_PROPERTIES_EXT = 1000455001, + PHYSICAL_DEVICE_SUBPASS_MERGE_FEEDBACK_FEATURES_EXT = 1000458000, + RENDER_PASS_CREATION_CONTROL_EXT = 1000458001, + RENDER_PASS_CREATION_FEEDBACK_CREATE_INFO_EXT = 1000458002, + RENDER_PASS_SUBPASS_FEEDBACK_CREATE_INFO_EXT = 1000458003, + DIRECT_DRIVER_LOADING_INFO_LUNARG = 1000459000, + DIRECT_DRIVER_LOADING_LIST_LUNARG = 1000459001, + PHYSICAL_DEVICE_SHADER_MODULE_IDENTIFIER_FEATURES_EXT = 1000462000, + PHYSICAL_DEVICE_SHADER_MODULE_IDENTIFIER_PROPERTIES_EXT = 1000462001, + PIPELINE_SHADER_STAGE_MODULE_IDENTIFIER_CREATE_INFO_EXT = 1000462002, + SHADER_MODULE_IDENTIFIER_EXT = 1000462003, + PHYSICAL_DEVICE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_FEATURES_EXT = 1000342000, + PHYSICAL_DEVICE_OPTICAL_FLOW_FEATURES_NV = 1000464000, + PHYSICAL_DEVICE_OPTICAL_FLOW_PROPERTIES_NV = 1000464001, + OPTICAL_FLOW_IMAGE_FORMAT_INFO_NV = 1000464002, + OPTICAL_FLOW_IMAGE_FORMAT_PROPERTIES_NV = 1000464003, + OPTICAL_FLOW_SESSION_CREATE_INFO_NV = 1000464004, + OPTICAL_FLOW_EXECUTE_INFO_NV = 1000464005, + OPTICAL_FLOW_SESSION_CREATE_PRIVATE_DATA_INFO_NV = 1000464010, + PHYSICAL_DEVICE_LEGACY_DITHERING_FEATURES_EXT = 1000465000, + PHYSICAL_DEVICE_PIPELINE_PROTECTED_ACCESS_FEATURES_EXT = 1000466000, + PHYSICAL_DEVICE_RAY_TRACING_POSITION_FETCH_FEATURES_KHR = 1000481000, + PHYSICAL_DEVICE_SHADER_OBJECT_FEATURES_EXT = 1000482000, + PHYSICAL_DEVICE_SHADER_OBJECT_PROPERTIES_EXT = 1000482001, + SHADER_CREATE_INFO_EXT = 1000482002, + PHYSICAL_DEVICE_TILE_PROPERTIES_FEATURES_QCOM = 1000484000, + TILE_PROPERTIES_QCOM = 1000484001, + PHYSICAL_DEVICE_AMIGO_PROFILING_FEATURES_SEC = 1000485000, + AMIGO_PROFILING_SUBMIT_INFO_SEC = 1000485001, + PHYSICAL_DEVICE_MULTIVIEW_PER_VIEW_VIEWPORTS_FEATURES_QCOM = 1000488000, + PHYSICAL_DEVICE_RAY_TRACING_INVOCATION_REORDER_FEATURES_NV = 1000490000, + PHYSICAL_DEVICE_RAY_TRACING_INVOCATION_REORDER_PROPERTIES_NV = 1000490001, + PHYSICAL_DEVICE_MUTABLE_DESCRIPTOR_TYPE_FEATURES_EXT = 1000351000, + MUTABLE_DESCRIPTOR_TYPE_CREATE_INFO_EXT = 1000351002, + PHYSICAL_DEVICE_SHADER_CORE_BUILTINS_FEATURES_ARM = 1000497000, + PHYSICAL_DEVICE_SHADER_CORE_BUILTINS_PROPERTIES_ARM = 1000497001, + PHYSICAL_DEVICE_PIPELINE_LIBRARY_GROUP_HANDLES_FEATURES_EXT = 1000498000, + PHYSICAL_DEVICE_MULTIVIEW_PER_VIEW_RENDER_AREAS_FEATURES_QCOM = 1000510000, + MULTIVIEW_PER_VIEW_RENDER_AREAS_RENDER_PASS_BEGIN_INFO_QCOM = 1000510001, + PHYSICAL_DEVICE_ATTACHMENT_FEEDBACK_LOOP_DYNAMIC_STATE_FEATURES_EXT = 1000524000, + PHYSICAL_DEVICE_VARIABLE_POINTER_FEATURES = PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES, + PHYSICAL_DEVICE_SHADER_DRAW_PARAMETER_FEATURES = PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES, + DEBUG_REPORT_CREATE_INFO_EXT = DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT, + RENDERING_INFO_KHR = RENDERING_INFO, + RENDERING_ATTACHMENT_INFO_KHR = RENDERING_ATTACHMENT_INFO, + PIPELINE_RENDERING_CREATE_INFO_KHR = PIPELINE_RENDERING_CREATE_INFO, + PHYSICAL_DEVICE_DYNAMIC_RENDERING_FEATURES_KHR = PHYSICAL_DEVICE_DYNAMIC_RENDERING_FEATURES, + COMMAND_BUFFER_INHERITANCE_RENDERING_INFO_KHR = COMMAND_BUFFER_INHERITANCE_RENDERING_INFO, + ATTACHMENT_SAMPLE_COUNT_INFO_NV = ATTACHMENT_SAMPLE_COUNT_INFO_AMD, + RENDER_PASS_MULTIVIEW_CREATE_INFO_KHR = RENDER_PASS_MULTIVIEW_CREATE_INFO, + PHYSICAL_DEVICE_MULTIVIEW_FEATURES_KHR = PHYSICAL_DEVICE_MULTIVIEW_FEATURES, + PHYSICAL_DEVICE_MULTIVIEW_PROPERTIES_KHR = PHYSICAL_DEVICE_MULTIVIEW_PROPERTIES, + PHYSICAL_DEVICE_FEATURES_2_KHR = PHYSICAL_DEVICE_FEATURES_2, + PHYSICAL_DEVICE_PROPERTIES_2_KHR = PHYSICAL_DEVICE_PROPERTIES_2, + FORMAT_PROPERTIES_2_KHR = FORMAT_PROPERTIES_2, + IMAGE_FORMAT_PROPERTIES_2_KHR = IMAGE_FORMAT_PROPERTIES_2, + PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2_KHR = PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2, + QUEUE_FAMILY_PROPERTIES_2_KHR = QUEUE_FAMILY_PROPERTIES_2, + PHYSICAL_DEVICE_MEMORY_PROPERTIES_2_KHR = PHYSICAL_DEVICE_MEMORY_PROPERTIES_2, + SPARSE_IMAGE_FORMAT_PROPERTIES_2_KHR = SPARSE_IMAGE_FORMAT_PROPERTIES_2, + PHYSICAL_DEVICE_SPARSE_IMAGE_FORMAT_INFO_2_KHR = PHYSICAL_DEVICE_SPARSE_IMAGE_FORMAT_INFO_2, + MEMORY_ALLOCATE_FLAGS_INFO_KHR = MEMORY_ALLOCATE_FLAGS_INFO, + DEVICE_GROUP_RENDER_PASS_BEGIN_INFO_KHR = DEVICE_GROUP_RENDER_PASS_BEGIN_INFO, + DEVICE_GROUP_COMMAND_BUFFER_BEGIN_INFO_KHR = DEVICE_GROUP_COMMAND_BUFFER_BEGIN_INFO, + DEVICE_GROUP_SUBMIT_INFO_KHR = DEVICE_GROUP_SUBMIT_INFO, + DEVICE_GROUP_BIND_SPARSE_INFO_KHR = DEVICE_GROUP_BIND_SPARSE_INFO, + BIND_BUFFER_MEMORY_DEVICE_GROUP_INFO_KHR = BIND_BUFFER_MEMORY_DEVICE_GROUP_INFO, + BIND_IMAGE_MEMORY_DEVICE_GROUP_INFO_KHR = BIND_IMAGE_MEMORY_DEVICE_GROUP_INFO, + PHYSICAL_DEVICE_TEXTURE_COMPRESSION_ASTC_HDR_FEATURES_EXT = PHYSICAL_DEVICE_TEXTURE_COMPRESSION_ASTC_HDR_FEATURES, + PHYSICAL_DEVICE_GROUP_PROPERTIES_KHR = PHYSICAL_DEVICE_GROUP_PROPERTIES, + DEVICE_GROUP_DEVICE_CREATE_INFO_KHR = DEVICE_GROUP_DEVICE_CREATE_INFO, + PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO_KHR = PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO, + EXTERNAL_IMAGE_FORMAT_PROPERTIES_KHR = EXTERNAL_IMAGE_FORMAT_PROPERTIES, + PHYSICAL_DEVICE_EXTERNAL_BUFFER_INFO_KHR = PHYSICAL_DEVICE_EXTERNAL_BUFFER_INFO, + EXTERNAL_BUFFER_PROPERTIES_KHR = EXTERNAL_BUFFER_PROPERTIES, + PHYSICAL_DEVICE_ID_PROPERTIES_KHR = PHYSICAL_DEVICE_ID_PROPERTIES, + EXTERNAL_MEMORY_BUFFER_CREATE_INFO_KHR = EXTERNAL_MEMORY_BUFFER_CREATE_INFO, + EXTERNAL_MEMORY_IMAGE_CREATE_INFO_KHR = EXTERNAL_MEMORY_IMAGE_CREATE_INFO, + EXPORT_MEMORY_ALLOCATE_INFO_KHR = EXPORT_MEMORY_ALLOCATE_INFO, + PHYSICAL_DEVICE_EXTERNAL_SEMAPHORE_INFO_KHR = PHYSICAL_DEVICE_EXTERNAL_SEMAPHORE_INFO, + EXTERNAL_SEMAPHORE_PROPERTIES_KHR = EXTERNAL_SEMAPHORE_PROPERTIES, + EXPORT_SEMAPHORE_CREATE_INFO_KHR = EXPORT_SEMAPHORE_CREATE_INFO, + PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES_KHR = PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES, + PHYSICAL_DEVICE_FLOAT16_INT8_FEATURES_KHR = PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES, + PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES_KHR = PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES, + DESCRIPTOR_UPDATE_TEMPLATE_CREATE_INFO_KHR = DESCRIPTOR_UPDATE_TEMPLATE_CREATE_INFO, + SURFACE_CAPABILITIES2_EXT = SURFACE_CAPABILITIES_2_EXT, + PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES_KHR = PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES, + FRAMEBUFFER_ATTACHMENTS_CREATE_INFO_KHR = FRAMEBUFFER_ATTACHMENTS_CREATE_INFO, + FRAMEBUFFER_ATTACHMENT_IMAGE_INFO_KHR = FRAMEBUFFER_ATTACHMENT_IMAGE_INFO, + RENDER_PASS_ATTACHMENT_BEGIN_INFO_KHR = RENDER_PASS_ATTACHMENT_BEGIN_INFO, + ATTACHMENT_DESCRIPTION_2_KHR = ATTACHMENT_DESCRIPTION_2, + ATTACHMENT_REFERENCE_2_KHR = ATTACHMENT_REFERENCE_2, + SUBPASS_DESCRIPTION_2_KHR = SUBPASS_DESCRIPTION_2, + SUBPASS_DEPENDENCY_2_KHR = SUBPASS_DEPENDENCY_2, + RENDER_PASS_CREATE_INFO_2_KHR = RENDER_PASS_CREATE_INFO_2, + SUBPASS_BEGIN_INFO_KHR = SUBPASS_BEGIN_INFO, + SUBPASS_END_INFO_KHR = SUBPASS_END_INFO, + PHYSICAL_DEVICE_EXTERNAL_FENCE_INFO_KHR = PHYSICAL_DEVICE_EXTERNAL_FENCE_INFO, + EXTERNAL_FENCE_PROPERTIES_KHR = EXTERNAL_FENCE_PROPERTIES, + EXPORT_FENCE_CREATE_INFO_KHR = EXPORT_FENCE_CREATE_INFO, + PHYSICAL_DEVICE_POINT_CLIPPING_PROPERTIES_KHR = PHYSICAL_DEVICE_POINT_CLIPPING_PROPERTIES, + RENDER_PASS_INPUT_ATTACHMENT_ASPECT_CREATE_INFO_KHR = RENDER_PASS_INPUT_ATTACHMENT_ASPECT_CREATE_INFO, + IMAGE_VIEW_USAGE_CREATE_INFO_KHR = IMAGE_VIEW_USAGE_CREATE_INFO, + PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO_KHR = PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO, + PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES_KHR = PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES, + PHYSICAL_DEVICE_VARIABLE_POINTER_FEATURES_KHR = PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES_KHR, + MEMORY_DEDICATED_REQUIREMENTS_KHR = MEMORY_DEDICATED_REQUIREMENTS, + MEMORY_DEDICATED_ALLOCATE_INFO_KHR = MEMORY_DEDICATED_ALLOCATE_INFO, + PHYSICAL_DEVICE_SAMPLER_FILTER_MINMAX_PROPERTIES_EXT = PHYSICAL_DEVICE_SAMPLER_FILTER_MINMAX_PROPERTIES, + SAMPLER_REDUCTION_MODE_CREATE_INFO_EXT = SAMPLER_REDUCTION_MODE_CREATE_INFO, + PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_FEATURES_EXT = PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_FEATURES, + PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_PROPERTIES_EXT = PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_PROPERTIES, + WRITE_DESCRIPTOR_SET_INLINE_UNIFORM_BLOCK_EXT = WRITE_DESCRIPTOR_SET_INLINE_UNIFORM_BLOCK, + DESCRIPTOR_POOL_INLINE_UNIFORM_BLOCK_CREATE_INFO_EXT = DESCRIPTOR_POOL_INLINE_UNIFORM_BLOCK_CREATE_INFO, + BUFFER_MEMORY_REQUIREMENTS_INFO_2_KHR = BUFFER_MEMORY_REQUIREMENTS_INFO_2, + IMAGE_MEMORY_REQUIREMENTS_INFO_2_KHR = IMAGE_MEMORY_REQUIREMENTS_INFO_2, + IMAGE_SPARSE_MEMORY_REQUIREMENTS_INFO_2_KHR = IMAGE_SPARSE_MEMORY_REQUIREMENTS_INFO_2, + MEMORY_REQUIREMENTS_2_KHR = MEMORY_REQUIREMENTS_2, + SPARSE_IMAGE_MEMORY_REQUIREMENTS_2_KHR = SPARSE_IMAGE_MEMORY_REQUIREMENTS_2, + IMAGE_FORMAT_LIST_CREATE_INFO_KHR = IMAGE_FORMAT_LIST_CREATE_INFO, + SAMPLER_YCBCR_CONVERSION_CREATE_INFO_KHR = SAMPLER_YCBCR_CONVERSION_CREATE_INFO, + SAMPLER_YCBCR_CONVERSION_INFO_KHR = SAMPLER_YCBCR_CONVERSION_INFO, + BIND_IMAGE_PLANE_MEMORY_INFO_KHR = BIND_IMAGE_PLANE_MEMORY_INFO, + IMAGE_PLANE_MEMORY_REQUIREMENTS_INFO_KHR = IMAGE_PLANE_MEMORY_REQUIREMENTS_INFO, + PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES_KHR = PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES, + SAMPLER_YCBCR_CONVERSION_IMAGE_FORMAT_PROPERTIES_KHR = SAMPLER_YCBCR_CONVERSION_IMAGE_FORMAT_PROPERTIES, + BIND_BUFFER_MEMORY_INFO_KHR = BIND_BUFFER_MEMORY_INFO, + BIND_IMAGE_MEMORY_INFO_KHR = BIND_IMAGE_MEMORY_INFO, + DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO_EXT = DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO, + PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES_EXT = PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES, + PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_PROPERTIES_EXT = PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_PROPERTIES, + DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_ALLOCATE_INFO_EXT = DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_ALLOCATE_INFO, + DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_LAYOUT_SUPPORT_EXT = DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_LAYOUT_SUPPORT, + PHYSICAL_DEVICE_MAINTENANCE_3_PROPERTIES_KHR = PHYSICAL_DEVICE_MAINTENANCE_3_PROPERTIES, + DESCRIPTOR_SET_LAYOUT_SUPPORT_KHR = DESCRIPTOR_SET_LAYOUT_SUPPORT, + DEVICE_QUEUE_GLOBAL_PRIORITY_CREATE_INFO_EXT = DEVICE_QUEUE_GLOBAL_PRIORITY_CREATE_INFO_KHR, + PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES_KHR = PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES, + PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES_KHR = PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES, + PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES_KHR = PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES, + PIPELINE_CREATION_FEEDBACK_CREATE_INFO_EXT = PIPELINE_CREATION_FEEDBACK_CREATE_INFO, + PHYSICAL_DEVICE_DRIVER_PROPERTIES_KHR = PHYSICAL_DEVICE_DRIVER_PROPERTIES, + PHYSICAL_DEVICE_FLOAT_CONTROLS_PROPERTIES_KHR = PHYSICAL_DEVICE_FLOAT_CONTROLS_PROPERTIES, + PHYSICAL_DEVICE_DEPTH_STENCIL_RESOLVE_PROPERTIES_KHR = PHYSICAL_DEVICE_DEPTH_STENCIL_RESOLVE_PROPERTIES, + SUBPASS_DESCRIPTION_DEPTH_STENCIL_RESOLVE_KHR = SUBPASS_DESCRIPTION_DEPTH_STENCIL_RESOLVE, + PHYSICAL_DEVICE_FRAGMENT_SHADER_BARYCENTRIC_FEATURES_NV = PHYSICAL_DEVICE_FRAGMENT_SHADER_BARYCENTRIC_FEATURES_KHR, + PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES_KHR = PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES, + PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_PROPERTIES_KHR = PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_PROPERTIES, + SEMAPHORE_TYPE_CREATE_INFO_KHR = SEMAPHORE_TYPE_CREATE_INFO, + TIMELINE_SEMAPHORE_SUBMIT_INFO_KHR = TIMELINE_SEMAPHORE_SUBMIT_INFO, + SEMAPHORE_WAIT_INFO_KHR = SEMAPHORE_WAIT_INFO, + SEMAPHORE_SIGNAL_INFO_KHR = SEMAPHORE_SIGNAL_INFO, + QUERY_POOL_CREATE_INFO_INTEL = QUERY_POOL_PERFORMANCE_QUERY_CREATE_INFO_INTEL, + PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES_KHR = PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES, + PHYSICAL_DEVICE_SHADER_TERMINATE_INVOCATION_FEATURES_KHR = PHYSICAL_DEVICE_SHADER_TERMINATE_INVOCATION_FEATURES, + PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES_EXT = PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES, + PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_PROPERTIES_EXT = PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_PROPERTIES, + PIPELINE_SHADER_STAGE_REQUIRED_SUBGROUP_SIZE_CREATE_INFO_EXT = PIPELINE_SHADER_STAGE_REQUIRED_SUBGROUP_SIZE_CREATE_INFO, + PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_FEATURES_EXT = PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_FEATURES, + PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES_KHR = PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES, + ATTACHMENT_REFERENCE_STENCIL_LAYOUT_KHR = ATTACHMENT_REFERENCE_STENCIL_LAYOUT, + ATTACHMENT_DESCRIPTION_STENCIL_LAYOUT_KHR = ATTACHMENT_DESCRIPTION_STENCIL_LAYOUT, + PHYSICAL_DEVICE_BUFFER_ADDRESS_FEATURES_EXT = PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES_EXT, + BUFFER_DEVICE_ADDRESS_INFO_EXT = BUFFER_DEVICE_ADDRESS_INFO, + PHYSICAL_DEVICE_TOOL_PROPERTIES_EXT = PHYSICAL_DEVICE_TOOL_PROPERTIES, + IMAGE_STENCIL_USAGE_CREATE_INFO_EXT = IMAGE_STENCIL_USAGE_CREATE_INFO, + PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES_KHR = PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES, + PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES_KHR = PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES, + BUFFER_DEVICE_ADDRESS_INFO_KHR = BUFFER_DEVICE_ADDRESS_INFO, + BUFFER_OPAQUE_CAPTURE_ADDRESS_CREATE_INFO_KHR = BUFFER_OPAQUE_CAPTURE_ADDRESS_CREATE_INFO, + MEMORY_OPAQUE_CAPTURE_ADDRESS_ALLOCATE_INFO_KHR = MEMORY_OPAQUE_CAPTURE_ADDRESS_ALLOCATE_INFO, + DEVICE_MEMORY_OPAQUE_CAPTURE_ADDRESS_INFO_KHR = DEVICE_MEMORY_OPAQUE_CAPTURE_ADDRESS_INFO, + PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES_EXT = PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES, + PHYSICAL_DEVICE_SHADER_DEMOTE_TO_HELPER_INVOCATION_FEATURES_EXT = PHYSICAL_DEVICE_SHADER_DEMOTE_TO_HELPER_INVOCATION_FEATURES, + PHYSICAL_DEVICE_SHADER_INTEGER_DOT_PRODUCT_FEATURES_KHR = PHYSICAL_DEVICE_SHADER_INTEGER_DOT_PRODUCT_FEATURES, + PHYSICAL_DEVICE_SHADER_INTEGER_DOT_PRODUCT_PROPERTIES_KHR = PHYSICAL_DEVICE_SHADER_INTEGER_DOT_PRODUCT_PROPERTIES, + PHYSICAL_DEVICE_TEXEL_BUFFER_ALIGNMENT_PROPERTIES_EXT = PHYSICAL_DEVICE_TEXEL_BUFFER_ALIGNMENT_PROPERTIES, + PHYSICAL_DEVICE_PRIVATE_DATA_FEATURES_EXT = PHYSICAL_DEVICE_PRIVATE_DATA_FEATURES, + DEVICE_PRIVATE_DATA_CREATE_INFO_EXT = DEVICE_PRIVATE_DATA_CREATE_INFO, + PRIVATE_DATA_SLOT_CREATE_INFO_EXT = PRIVATE_DATA_SLOT_CREATE_INFO, + PHYSICAL_DEVICE_PIPELINE_CREATION_CACHE_CONTROL_FEATURES_EXT = PHYSICAL_DEVICE_PIPELINE_CREATION_CACHE_CONTROL_FEATURES, + MEMORY_BARRIER_2_KHR = MEMORY_BARRIER_2, + BUFFER_MEMORY_BARRIER_2_KHR = BUFFER_MEMORY_BARRIER_2, + IMAGE_MEMORY_BARRIER_2_KHR = IMAGE_MEMORY_BARRIER_2, + DEPENDENCY_INFO_KHR = DEPENDENCY_INFO, + SUBMIT_INFO_2_KHR = SUBMIT_INFO_2, + SEMAPHORE_SUBMIT_INFO_KHR = SEMAPHORE_SUBMIT_INFO, + COMMAND_BUFFER_SUBMIT_INFO_KHR = COMMAND_BUFFER_SUBMIT_INFO, + PHYSICAL_DEVICE_SYNCHRONIZATION_2_FEATURES_KHR = PHYSICAL_DEVICE_SYNCHRONIZATION_2_FEATURES, + PHYSICAL_DEVICE_ZERO_INITIALIZE_WORKGROUP_MEMORY_FEATURES_KHR = PHYSICAL_DEVICE_ZERO_INITIALIZE_WORKGROUP_MEMORY_FEATURES, + PHYSICAL_DEVICE_IMAGE_ROBUSTNESS_FEATURES_EXT = PHYSICAL_DEVICE_IMAGE_ROBUSTNESS_FEATURES, + COPY_BUFFER_INFO_2_KHR = COPY_BUFFER_INFO_2, + COPY_IMAGE_INFO_2_KHR = COPY_IMAGE_INFO_2, + COPY_BUFFER_TO_IMAGE_INFO_2_KHR = COPY_BUFFER_TO_IMAGE_INFO_2, + COPY_IMAGE_TO_BUFFER_INFO_2_KHR = COPY_IMAGE_TO_BUFFER_INFO_2, + BLIT_IMAGE_INFO_2_KHR = BLIT_IMAGE_INFO_2, + RESOLVE_IMAGE_INFO_2_KHR = RESOLVE_IMAGE_INFO_2, + BUFFER_COPY_2_KHR = BUFFER_COPY_2, + IMAGE_COPY_2_KHR = IMAGE_COPY_2, + IMAGE_BLIT_2_KHR = IMAGE_BLIT_2, + BUFFER_IMAGE_COPY_2_KHR = BUFFER_IMAGE_COPY_2, + IMAGE_RESOLVE_2_KHR = IMAGE_RESOLVE_2, + PHYSICAL_DEVICE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_FEATURES_ARM = PHYSICAL_DEVICE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_FEATURES_EXT, + PHYSICAL_DEVICE_MUTABLE_DESCRIPTOR_TYPE_FEATURES_VALVE = PHYSICAL_DEVICE_MUTABLE_DESCRIPTOR_TYPE_FEATURES_EXT, + MUTABLE_DESCRIPTOR_TYPE_CREATE_INFO_VALVE = MUTABLE_DESCRIPTOR_TYPE_CREATE_INFO_EXT, + FORMAT_PROPERTIES_3_KHR = FORMAT_PROPERTIES_3, + PIPELINE_INFO_EXT = PIPELINE_INFO_KHR, + PHYSICAL_DEVICE_GLOBAL_PRIORITY_QUERY_FEATURES_EXT = PHYSICAL_DEVICE_GLOBAL_PRIORITY_QUERY_FEATURES_KHR, + QUEUE_FAMILY_GLOBAL_PRIORITY_PROPERTIES_EXT = QUEUE_FAMILY_GLOBAL_PRIORITY_PROPERTIES_KHR, + PHYSICAL_DEVICE_MAINTENANCE_4_FEATURES_KHR = PHYSICAL_DEVICE_MAINTENANCE_4_FEATURES, + PHYSICAL_DEVICE_MAINTENANCE_4_PROPERTIES_KHR = PHYSICAL_DEVICE_MAINTENANCE_4_PROPERTIES, + DEVICE_BUFFER_MEMORY_REQUIREMENTS_KHR = DEVICE_BUFFER_MEMORY_REQUIREMENTS, + DEVICE_IMAGE_MEMORY_REQUIREMENTS_KHR = DEVICE_IMAGE_MEMORY_REQUIREMENTS, + SHADER_REQUIRED_SUBGROUP_SIZE_CREATE_INFO_EXT = PIPELINE_SHADER_STAGE_REQUIRED_SUBGROUP_SIZE_CREATE_INFO, +} + +SubgroupFeatureFlags :: distinct bit_set[SubgroupFeatureFlag; Flags] +SubgroupFeatureFlag :: enum Flags { + BASIC = 0, + VOTE = 1, + ARITHMETIC = 2, + BALLOT = 3, + SHUFFLE = 4, + SHUFFLE_RELATIVE = 5, + CLUSTERED = 6, + QUAD = 7, + PARTITIONED_NV = 8, +} + +SubmitFlags :: distinct bit_set[SubmitFlag; Flags] +SubmitFlag :: enum Flags { + PROTECTED = 0, + PROTECTED_KHR = PROTECTED, +} + +SubpassContents :: enum c.int { + INLINE = 0, + SECONDARY_COMMAND_BUFFERS = 1, +} + +SubpassDescriptionFlags :: distinct bit_set[SubpassDescriptionFlag; Flags] +SubpassDescriptionFlag :: enum Flags { + PER_VIEW_ATTRIBUTES_NVX = 0, + PER_VIEW_POSITION_X_ONLY_NVX = 1, + FRAGMENT_REGION_QCOM = 2, + SHADER_RESOLVE_QCOM = 3, + RASTERIZATION_ORDER_ATTACHMENT_COLOR_ACCESS_EXT = 4, + RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_EXT = 5, + RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_EXT = 6, + ENABLE_LEGACY_DITHERING_EXT = 7, + RASTERIZATION_ORDER_ATTACHMENT_COLOR_ACCESS_ARM = RASTERIZATION_ORDER_ATTACHMENT_COLOR_ACCESS_EXT, + RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_ARM = RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_EXT, + RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_ARM = RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_EXT, +} + +SubpassMergeStatusEXT :: enum c.int { + MERGED = 0, + DISALLOWED = 1, + NOT_MERGED_SIDE_EFFECTS = 2, + NOT_MERGED_SAMPLES_MISMATCH = 3, + NOT_MERGED_VIEWS_MISMATCH = 4, + NOT_MERGED_ALIASING = 5, + NOT_MERGED_DEPENDENCIES = 6, + NOT_MERGED_INCOMPATIBLE_INPUT_ATTACHMENT = 7, + NOT_MERGED_TOO_MANY_ATTACHMENTS = 8, + NOT_MERGED_INSUFFICIENT_STORAGE = 9, + NOT_MERGED_DEPTH_STENCIL_COUNT = 10, + NOT_MERGED_RESOLVE_ATTACHMENT_REUSE = 11, + NOT_MERGED_SINGLE_SUBPASS = 12, + NOT_MERGED_UNSPECIFIED = 13, +} + +SurfaceCounterFlagsEXT :: distinct bit_set[SurfaceCounterFlagEXT; Flags] +SurfaceCounterFlagEXT :: enum Flags { + VBLANK = 0, +} + +SurfaceTransformFlagsKHR :: distinct bit_set[SurfaceTransformFlagKHR; Flags] +SurfaceTransformFlagKHR :: enum Flags { + IDENTITY = 0, + ROTATE_90 = 1, + ROTATE_180 = 2, + ROTATE_270 = 3, + HORIZONTAL_MIRROR = 4, + HORIZONTAL_MIRROR_ROTATE_90 = 5, + HORIZONTAL_MIRROR_ROTATE_180 = 6, + HORIZONTAL_MIRROR_ROTATE_270 = 7, + INHERIT = 8, +} + +SwapchainCreateFlagsKHR :: distinct bit_set[SwapchainCreateFlagKHR; Flags] +SwapchainCreateFlagKHR :: enum Flags { + SPLIT_INSTANCE_BIND_REGIONS = 0, + PROTECTED = 1, + MUTABLE_FORMAT = 2, + DEFERRED_MEMORY_ALLOCATION_EXT = 3, +} + +SystemAllocationScope :: enum c.int { + COMMAND = 0, + OBJECT = 1, + CACHE = 2, + DEVICE = 3, + INSTANCE = 4, +} + +TessellationDomainOrigin :: enum c.int { + UPPER_LEFT = 0, + LOWER_LEFT = 1, + UPPER_LEFT_KHR = UPPER_LEFT, + LOWER_LEFT_KHR = LOWER_LEFT, +} + +TimeDomainEXT :: enum c.int { + DEVICE = 0, + CLOCK_MONOTONIC = 1, + CLOCK_MONOTONIC_RAW = 2, + QUERY_PERFORMANCE_COUNTER = 3, +} + +ToolPurposeFlags :: distinct bit_set[ToolPurposeFlag; Flags] +ToolPurposeFlag :: enum Flags { + VALIDATION = 0, + PROFILING = 1, + TRACING = 2, + ADDITIONAL_FEATURES = 3, + MODIFYING_FEATURES = 4, + DEBUG_REPORTING_EXT = 5, + DEBUG_MARKERS_EXT = 6, + VALIDATION_EXT = VALIDATION, + PROFILING_EXT = PROFILING, + TRACING_EXT = TRACING, + ADDITIONAL_FEATURES_EXT = ADDITIONAL_FEATURES, + MODIFYING_FEATURES_EXT = MODIFYING_FEATURES, +} + +ValidationCacheHeaderVersionEXT :: enum c.int { + ONE = 1, +} + +ValidationCheckEXT :: enum c.int { + ALL = 0, + SHADERS = 1, +} + +ValidationFeatureDisableEXT :: enum c.int { + ALL = 0, + SHADERS = 1, + THREAD_SAFETY = 2, + API_PARAMETERS = 3, + OBJECT_LIFETIMES = 4, + CORE_CHECKS = 5, + UNIQUE_HANDLES = 6, + SHADER_VALIDATION_CACHE = 7, +} + +ValidationFeatureEnableEXT :: enum c.int { + GPU_ASSISTED = 0, + GPU_ASSISTED_RESERVE_BINDING_SLOT = 1, + BEST_PRACTICES = 2, + DEBUG_PRINTF = 3, + SYNCHRONIZATION_VALIDATION = 4, +} + +VendorId :: enum c.int { + VIV = 0x10001, + VSI = 0x10002, + KAZAN = 0x10003, + CODEPLAY = 0x10004, + MESA = 0x10005, + POCL = 0x10006, + MOBILEYE = 0x10007, +} + +VertexInputRate :: enum c.int { + VERTEX = 0, + INSTANCE = 1, +} + +VideoCapabilityFlagsKHR :: distinct bit_set[VideoCapabilityFlagKHR; Flags] +VideoCapabilityFlagKHR :: enum Flags { + PROTECTED_CONTENT = 0, + SEPARATE_REFERENCE_IMAGES = 1, +} + +VideoChromaSubsamplingFlagsKHR :: distinct bit_set[VideoChromaSubsamplingFlagKHR; Flags] +VideoChromaSubsamplingFlagKHR :: enum Flags { + MONOCHROME = 0, + _420 = 1, + _422 = 2, + _444 = 3, +} + +VideoChromaSubsamplingFlagsKHR_INVALID :: VideoChromaSubsamplingFlagsKHR{} + + +VideoCodecOperationFlagsKHR :: distinct bit_set[VideoCodecOperationFlagKHR; Flags] +VideoCodecOperationFlagKHR :: enum Flags { + ENCODE_H264_EXT = 16, + ENCODE_H265_EXT = 17, + DECODE_H264 = 0, + DECODE_H265 = 1, +} + +VideoCodecOperationFlagsKHR_NONE :: VideoCodecOperationFlagsKHR{} + + +VideoCodingControlFlagsKHR :: distinct bit_set[VideoCodingControlFlagKHR; Flags] +VideoCodingControlFlagKHR :: enum Flags { + RESET = 0, + ENCODE_RATE_CONTROL = 1, + ENCODE_RATE_CONTROL_LAYER = 2, +} + +VideoComponentBitDepthFlagsKHR :: distinct bit_set[VideoComponentBitDepthFlagKHR; Flags] +VideoComponentBitDepthFlagKHR :: enum Flags { + _8 = 0, + _10 = 2, + _12 = 4, +} + +VideoComponentBitDepthFlagsKHR_INVALID :: VideoComponentBitDepthFlagsKHR{} + + +VideoDecodeCapabilityFlagsKHR :: distinct bit_set[VideoDecodeCapabilityFlagKHR; Flags] +VideoDecodeCapabilityFlagKHR :: enum Flags { + DPB_AND_OUTPUT_COINCIDE = 0, + DPB_AND_OUTPUT_DISTINCT = 1, +} + +VideoDecodeH264FieldOrderCount :: enum c.int { +} + +VideoDecodeH264PictureLayoutFlagsKHR :: distinct bit_set[VideoDecodeH264PictureLayoutFlagKHR; Flags] +VideoDecodeH264PictureLayoutFlagKHR :: enum Flags { + INTERLACED_INTERLEAVED_LINES = 0, + INTERLACED_SEPARATE_PLANES = 1, +} + +VideoDecodeH264PictureLayoutFlagsKHR_PROGRESSIVE :: VideoDecodeH264PictureLayoutFlagsKHR{} + + +VideoDecodeUsageFlagsKHR :: distinct bit_set[VideoDecodeUsageFlagKHR; Flags] +VideoDecodeUsageFlagKHR :: enum Flags { + TRANSCODING = 0, + OFFLINE = 1, + STREAMING = 2, +} + +VideoDecodeUsageFlagsKHR_DEFAULT :: VideoDecodeUsageFlagsKHR{} + + +VideoH264AspectRatioIdc :: enum c.int { +} + +VideoH264CabacInitIdc :: enum c.int { +} + +VideoH264ChromaFormatIdc :: enum c.int { +} + +VideoH264DisableDeblockingFilterIdc :: enum c.int { +} + +VideoH264LevelIdc :: enum c.int { +} + +VideoH264MemMgmtControlOp :: enum c.int { +} + +VideoH264ModificationOfPicNumsIdc :: enum c.int { +} + +VideoH264NonVclNaluType :: enum c.int { +} + +VideoH264PictureType :: enum c.int { +} + +VideoH264PocType :: enum c.int { +} + +VideoH264ProfileIdc :: enum c.int { +} + +VideoH264SliceType :: enum c.int { +} + +VideoH264WeightedBipredIdc :: enum c.int { +} + +VideoH265AspectRatioIdc :: enum c.int { +} + +VideoH265ChromaFormatIdc :: enum c.int { +} + +VideoH265LevelIdc :: enum c.int { +} + +VideoH265PictureType :: enum c.int { +} + +VideoH265ProfileIdc :: enum c.int { +} + +VideoH265SliceType :: enum c.int { +} + +VideoSessionCreateFlagsKHR :: distinct bit_set[VideoSessionCreateFlagKHR; Flags] +VideoSessionCreateFlagKHR :: enum Flags { + PROTECTED_CONTENT = 0, +} + +ViewportCoordinateSwizzleNV :: enum c.int { + POSITIVE_X = 0, + NEGATIVE_X = 1, + POSITIVE_Y = 2, + NEGATIVE_Y = 3, + POSITIVE_Z = 4, + NEGATIVE_Z = 5, + POSITIVE_W = 6, + NEGATIVE_W = 7, +} + +AccelerationStructureMotionInfoFlagsNV :: distinct bit_set[AccelerationStructureMotionInfoFlagNV; Flags] +AccelerationStructureMotionInfoFlagNV :: enum u32 {} +AccelerationStructureMotionInstanceFlagsNV :: distinct bit_set[AccelerationStructureMotionInstanceFlagNV; Flags] +AccelerationStructureMotionInstanceFlagNV :: enum u32 {} +BufferViewCreateFlags :: distinct bit_set[BufferViewCreateFlag; Flags] +BufferViewCreateFlag :: enum u32 {} +CommandPoolTrimFlags :: distinct bit_set[CommandPoolTrimFlag; Flags] +CommandPoolTrimFlag :: enum u32 {} +DebugUtilsMessengerCallbackDataFlagsEXT :: distinct bit_set[DebugUtilsMessengerCallbackDataFlagEXT; Flags] +DebugUtilsMessengerCallbackDataFlagEXT :: enum u32 {} +DebugUtilsMessengerCreateFlagsEXT :: distinct bit_set[DebugUtilsMessengerCreateFlagEXT; Flags] +DebugUtilsMessengerCreateFlagEXT :: enum u32 {} +DescriptorPoolResetFlags :: distinct bit_set[DescriptorPoolResetFlag; Flags] +DescriptorPoolResetFlag :: enum u32 {} +DescriptorUpdateTemplateCreateFlags :: distinct bit_set[DescriptorUpdateTemplateCreateFlag; Flags] +DescriptorUpdateTemplateCreateFlag :: enum u32 {} +DeviceCreateFlags :: distinct bit_set[DeviceCreateFlag; Flags] +DeviceCreateFlag :: enum u32 {} +DeviceMemoryReportFlagsEXT :: distinct bit_set[DeviceMemoryReportFlagEXT; Flags] +DeviceMemoryReportFlagEXT :: enum u32 {} +DirectDriverLoadingFlagsLUNARG :: distinct bit_set[DirectDriverLoadingFlagLUNARG; Flags] +DirectDriverLoadingFlagLUNARG :: enum u32 {} +DisplayModeCreateFlagsKHR :: distinct bit_set[DisplayModeCreateFlagKHR; Flags] +DisplayModeCreateFlagKHR :: enum u32 {} +DisplaySurfaceCreateFlagsKHR :: distinct bit_set[DisplaySurfaceCreateFlagKHR; Flags] +DisplaySurfaceCreateFlagKHR :: enum u32 {} +HeadlessSurfaceCreateFlagsEXT :: distinct bit_set[HeadlessSurfaceCreateFlagEXT; Flags] +HeadlessSurfaceCreateFlagEXT :: enum u32 {} +IOSSurfaceCreateFlagsMVK :: distinct bit_set[IOSSurfaceCreateFlagMVK; Flags] +IOSSurfaceCreateFlagMVK :: enum u32 {} +MacOSSurfaceCreateFlagsMVK :: distinct bit_set[MacOSSurfaceCreateFlagMVK; Flags] +MacOSSurfaceCreateFlagMVK :: enum u32 {} +MemoryMapFlags :: distinct bit_set[MemoryMapFlag; Flags] +MemoryMapFlag :: enum u32 {} +MemoryUnmapFlagsKHR :: distinct bit_set[MemoryUnmapFlagKHR; Flags] +MemoryUnmapFlagKHR :: enum u32 {} +MetalSurfaceCreateFlagsEXT :: distinct bit_set[MetalSurfaceCreateFlagEXT; Flags] +MetalSurfaceCreateFlagEXT :: enum u32 {} +PipelineCoverageModulationStateCreateFlagsNV :: distinct bit_set[PipelineCoverageModulationStateCreateFlagNV; Flags] +PipelineCoverageModulationStateCreateFlagNV :: enum u32 {} +PipelineCoverageReductionStateCreateFlagsNV :: distinct bit_set[PipelineCoverageReductionStateCreateFlagNV; Flags] +PipelineCoverageReductionStateCreateFlagNV :: enum u32 {} +PipelineCoverageToColorStateCreateFlagsNV :: distinct bit_set[PipelineCoverageToColorStateCreateFlagNV; Flags] +PipelineCoverageToColorStateCreateFlagNV :: enum u32 {} +PipelineDiscardRectangleStateCreateFlagsEXT :: distinct bit_set[PipelineDiscardRectangleStateCreateFlagEXT; Flags] +PipelineDiscardRectangleStateCreateFlagEXT :: enum u32 {} +PipelineDynamicStateCreateFlags :: distinct bit_set[PipelineDynamicStateCreateFlag; Flags] +PipelineDynamicStateCreateFlag :: enum u32 {} +PipelineInputAssemblyStateCreateFlags :: distinct bit_set[PipelineInputAssemblyStateCreateFlag; Flags] +PipelineInputAssemblyStateCreateFlag :: enum u32 {} +PipelineMultisampleStateCreateFlags :: distinct bit_set[PipelineMultisampleStateCreateFlag; Flags] +PipelineMultisampleStateCreateFlag :: enum u32 {} +PipelineRasterizationConservativeStateCreateFlagsEXT :: distinct bit_set[PipelineRasterizationConservativeStateCreateFlagEXT; Flags] +PipelineRasterizationConservativeStateCreateFlagEXT :: enum u32 {} +PipelineRasterizationDepthClipStateCreateFlagsEXT :: distinct bit_set[PipelineRasterizationDepthClipStateCreateFlagEXT; Flags] +PipelineRasterizationDepthClipStateCreateFlagEXT :: enum u32 {} +PipelineRasterizationStateCreateFlags :: distinct bit_set[PipelineRasterizationStateCreateFlag; Flags] +PipelineRasterizationStateCreateFlag :: enum u32 {} +PipelineRasterizationStateStreamCreateFlagsEXT :: distinct bit_set[PipelineRasterizationStateStreamCreateFlagEXT; Flags] +PipelineRasterizationStateStreamCreateFlagEXT :: enum u32 {} +PipelineTessellationStateCreateFlags :: distinct bit_set[PipelineTessellationStateCreateFlag; Flags] +PipelineTessellationStateCreateFlag :: enum u32 {} +PipelineVertexInputStateCreateFlags :: distinct bit_set[PipelineVertexInputStateCreateFlag; Flags] +PipelineVertexInputStateCreateFlag :: enum u32 {} +PipelineViewportStateCreateFlags :: distinct bit_set[PipelineViewportStateCreateFlag; Flags] +PipelineViewportStateCreateFlag :: enum u32 {} +PipelineViewportSwizzleStateCreateFlagsNV :: distinct bit_set[PipelineViewportSwizzleStateCreateFlagNV; Flags] +PipelineViewportSwizzleStateCreateFlagNV :: enum u32 {} +PrivateDataSlotCreateFlags :: distinct bit_set[PrivateDataSlotCreateFlag; Flags] +PrivateDataSlotCreateFlag :: enum u32 {} +QueryPoolCreateFlags :: distinct bit_set[QueryPoolCreateFlag; Flags] +QueryPoolCreateFlag :: enum u32 {} +SemaphoreCreateFlags :: distinct bit_set[SemaphoreCreateFlag; Flags] +SemaphoreCreateFlag :: enum u32 {} +ShaderModuleCreateFlags :: distinct bit_set[ShaderModuleCreateFlag; Flags] +ShaderModuleCreateFlag :: enum u32 {} +ValidationCacheCreateFlagsEXT :: distinct bit_set[ValidationCacheCreateFlagEXT; Flags] +ValidationCacheCreateFlagEXT :: enum u32 {} +VideoBeginCodingFlagsKHR :: distinct bit_set[VideoBeginCodingFlagKHR; Flags] +VideoBeginCodingFlagKHR :: enum u32 {} +VideoDecodeFlagsKHR :: distinct bit_set[VideoDecodeFlagKHR; Flags] +VideoDecodeFlagKHR :: enum u32 {} +VideoEndCodingFlagsKHR :: distinct bit_set[VideoEndCodingFlagKHR; Flags] +VideoEndCodingFlagKHR :: enum u32 {} +VideoSessionParametersCreateFlagsKHR :: distinct bit_set[VideoSessionParametersCreateFlagKHR; Flags] +VideoSessionParametersCreateFlagKHR :: enum u32 {} +WaylandSurfaceCreateFlagsKHR :: distinct bit_set[WaylandSurfaceCreateFlagKHR; Flags] +WaylandSurfaceCreateFlagKHR :: enum u32 {} +Win32SurfaceCreateFlagsKHR :: distinct bit_set[Win32SurfaceCreateFlagKHR; Flags] +Win32SurfaceCreateFlagKHR :: enum u32 {} + + diff --git a/vendor/vulkan/procedures.odin b/vendor/vulkan/procedures.odin index 02cfa9dbf..694945215 100644 --- a/vendor/vulkan/procedures.odin +++ b/vendor/vulkan/procedures.odin @@ -1,3334 +1,4058 @@ -// -// Vulkan wrapper generated from "https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/master/include/vulkan/vulkan_core.h" -// -package vulkan - -import "core:c" - -// Loader Procedure Types -ProcCreateInstance :: #type proc "system" (pCreateInfo: ^InstanceCreateInfo, pAllocator: ^AllocationCallbacks, pInstance: ^Instance) -> Result -ProcDebugUtilsMessengerCallbackEXT :: #type proc "system" (messageSeverity: DebugUtilsMessageSeverityFlagsEXT, messageTypes: DebugUtilsMessageTypeFlagsEXT, pCallbackData: ^DebugUtilsMessengerCallbackDataEXT, pUserData: rawptr) -> b32 -ProcDeviceMemoryReportCallbackEXT :: #type proc "system" (pCallbackData: ^DeviceMemoryReportCallbackDataEXT, pUserData: rawptr) -ProcEnumerateInstanceExtensionProperties :: #type proc "system" (pLayerName: cstring, pPropertyCount: ^u32, pProperties: [^]ExtensionProperties) -> Result -ProcEnumerateInstanceLayerProperties :: #type proc "system" (pPropertyCount: ^u32, pProperties: [^]LayerProperties) -> Result -ProcEnumerateInstanceVersion :: #type proc "system" (pApiVersion: ^u32) -> Result - -// Misc Procedure Types -ProcAllocationFunction :: #type proc "system" (pUserData: rawptr, size: int, alignment: int, allocationScope: SystemAllocationScope) -> rawptr -ProcDebugReportCallbackEXT :: #type proc "system" (flags: DebugReportFlagsEXT, objectType: DebugReportObjectTypeEXT, object: u64, location: int, messageCode: i32, pLayerPrefix: cstring, pMessage: cstring, pUserData: rawptr) -> b32 -ProcFreeFunction :: #type proc "system" (pUserData: rawptr, pMemory: rawptr) -ProcInternalAllocationNotification :: #type proc "system" (pUserData: rawptr, size: int, allocationType: InternalAllocationType, allocationScope: SystemAllocationScope) -ProcInternalFreeNotification :: #type proc "system" (pUserData: rawptr, size: int, allocationType: InternalAllocationType, allocationScope: SystemAllocationScope) -ProcReallocationFunction :: #type proc "system" (pUserData: rawptr, pOriginal: rawptr, size: int, alignment: int, allocationScope: SystemAllocationScope) -> rawptr -ProcVoidFunction :: #type proc "system" () - -// Instance Procedure Types -ProcAcquireDrmDisplayEXT :: #type proc "system" (physicalDevice: PhysicalDevice, drmFd: i32, display: DisplayKHR) -> Result -ProcAcquireWinrtDisplayNV :: #type proc "system" (physicalDevice: PhysicalDevice, display: DisplayKHR) -> Result -ProcCreateDebugReportCallbackEXT :: #type proc "system" (instance: Instance, pCreateInfo: ^DebugReportCallbackCreateInfoEXT, pAllocator: ^AllocationCallbacks, pCallback: ^DebugReportCallbackEXT) -> Result -ProcCreateDebugUtilsMessengerEXT :: #type proc "system" (instance: Instance, pCreateInfo: ^DebugUtilsMessengerCreateInfoEXT, pAllocator: ^AllocationCallbacks, pMessenger: ^DebugUtilsMessengerEXT) -> Result -ProcCreateDevice :: #type proc "system" (physicalDevice: PhysicalDevice, pCreateInfo: ^DeviceCreateInfo, pAllocator: ^AllocationCallbacks, pDevice: ^Device) -> Result -ProcCreateDisplayModeKHR :: #type proc "system" (physicalDevice: PhysicalDevice, display: DisplayKHR, pCreateInfo: ^DisplayModeCreateInfoKHR, pAllocator: ^AllocationCallbacks, pMode: ^DisplayModeKHR) -> Result -ProcCreateDisplayPlaneSurfaceKHR :: #type proc "system" (instance: Instance, pCreateInfo: ^DisplaySurfaceCreateInfoKHR, pAllocator: ^AllocationCallbacks, pSurface: ^SurfaceKHR) -> Result -ProcCreateHeadlessSurfaceEXT :: #type proc "system" (instance: Instance, pCreateInfo: ^HeadlessSurfaceCreateInfoEXT, pAllocator: ^AllocationCallbacks, pSurface: ^SurfaceKHR) -> Result -ProcCreateIOSSurfaceMVK :: #type proc "system" (instance: Instance, pCreateInfo: ^IOSSurfaceCreateInfoMVK, pAllocator: ^AllocationCallbacks, pSurface: ^SurfaceKHR) -> Result -ProcCreateMacOSSurfaceMVK :: #type proc "system" (instance: Instance, pCreateInfo: ^MacOSSurfaceCreateInfoMVK, pAllocator: ^AllocationCallbacks, pSurface: ^SurfaceKHR) -> Result -ProcCreateMetalSurfaceEXT :: #type proc "system" (instance: Instance, pCreateInfo: ^MetalSurfaceCreateInfoEXT, pAllocator: ^AllocationCallbacks, pSurface: ^SurfaceKHR) -> Result -ProcCreateWin32SurfaceKHR :: #type proc "system" (instance: Instance, pCreateInfo: ^Win32SurfaceCreateInfoKHR, pAllocator: ^AllocationCallbacks, pSurface: ^SurfaceKHR) -> Result -ProcDebugReportMessageEXT :: #type proc "system" (instance: Instance, flags: DebugReportFlagsEXT, objectType: DebugReportObjectTypeEXT, object: u64, location: int, messageCode: i32, pLayerPrefix: cstring, pMessage: cstring) -ProcDestroyDebugReportCallbackEXT :: #type proc "system" (instance: Instance, callback: DebugReportCallbackEXT, pAllocator: ^AllocationCallbacks) -ProcDestroyDebugUtilsMessengerEXT :: #type proc "system" (instance: Instance, messenger: DebugUtilsMessengerEXT, pAllocator: ^AllocationCallbacks) -ProcDestroyInstance :: #type proc "system" (instance: Instance, pAllocator: ^AllocationCallbacks) -ProcDestroySurfaceKHR :: #type proc "system" (instance: Instance, surface: SurfaceKHR, pAllocator: ^AllocationCallbacks) -ProcEnumerateDeviceExtensionProperties :: #type proc "system" (physicalDevice: PhysicalDevice, pLayerName: cstring, pPropertyCount: ^u32, pProperties: [^]ExtensionProperties) -> Result -ProcEnumerateDeviceLayerProperties :: #type proc "system" (physicalDevice: PhysicalDevice, pPropertyCount: ^u32, pProperties: [^]LayerProperties) -> Result -ProcEnumeratePhysicalDeviceGroups :: #type proc "system" (instance: Instance, pPhysicalDeviceGroupCount: ^u32, pPhysicalDeviceGroupProperties: [^]PhysicalDeviceGroupProperties) -> Result -ProcEnumeratePhysicalDeviceGroupsKHR :: #type proc "system" (instance: Instance, pPhysicalDeviceGroupCount: ^u32, pPhysicalDeviceGroupProperties: [^]PhysicalDeviceGroupProperties) -> Result -ProcEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR :: #type proc "system" (physicalDevice: PhysicalDevice, queueFamilyIndex: u32, pCounterCount: ^u32, pCounters: [^]PerformanceCounterKHR, pCounterDescriptions: [^]PerformanceCounterDescriptionKHR) -> Result -ProcEnumeratePhysicalDevices :: #type proc "system" (instance: Instance, pPhysicalDeviceCount: ^u32, pPhysicalDevices: [^]PhysicalDevice) -> Result -ProcGetDisplayModeProperties2KHR :: #type proc "system" (physicalDevice: PhysicalDevice, display: DisplayKHR, pPropertyCount: ^u32, pProperties: [^]DisplayModeProperties2KHR) -> Result -ProcGetDisplayModePropertiesKHR :: #type proc "system" (physicalDevice: PhysicalDevice, display: DisplayKHR, pPropertyCount: ^u32, pProperties: [^]DisplayModePropertiesKHR) -> Result -ProcGetDisplayPlaneCapabilities2KHR :: #type proc "system" (physicalDevice: PhysicalDevice, pDisplayPlaneInfo: ^DisplayPlaneInfo2KHR, pCapabilities: [^]DisplayPlaneCapabilities2KHR) -> Result -ProcGetDisplayPlaneCapabilitiesKHR :: #type proc "system" (physicalDevice: PhysicalDevice, mode: DisplayModeKHR, planeIndex: u32, pCapabilities: [^]DisplayPlaneCapabilitiesKHR) -> Result -ProcGetDisplayPlaneSupportedDisplaysKHR :: #type proc "system" (physicalDevice: PhysicalDevice, planeIndex: u32, pDisplayCount: ^u32, pDisplays: [^]DisplayKHR) -> Result -ProcGetDrmDisplayEXT :: #type proc "system" (physicalDevice: PhysicalDevice, drmFd: i32, connectorId: u32, display: ^DisplayKHR) -> Result -ProcGetInstanceProcAddr :: #type proc "system" (instance: Instance, pName: cstring) -> ProcVoidFunction -ProcGetPhysicalDeviceCalibrateableTimeDomainsEXT :: #type proc "system" (physicalDevice: PhysicalDevice, pTimeDomainCount: ^u32, pTimeDomains: [^]TimeDomainEXT) -> Result -ProcGetPhysicalDeviceCooperativeMatrixPropertiesNV :: #type proc "system" (physicalDevice: PhysicalDevice, pPropertyCount: ^u32, pProperties: [^]CooperativeMatrixPropertiesNV) -> Result -ProcGetPhysicalDeviceDisplayPlaneProperties2KHR :: #type proc "system" (physicalDevice: PhysicalDevice, pPropertyCount: ^u32, pProperties: [^]DisplayPlaneProperties2KHR) -> Result -ProcGetPhysicalDeviceDisplayPlanePropertiesKHR :: #type proc "system" (physicalDevice: PhysicalDevice, pPropertyCount: ^u32, pProperties: [^]DisplayPlanePropertiesKHR) -> Result -ProcGetPhysicalDeviceDisplayProperties2KHR :: #type proc "system" (physicalDevice: PhysicalDevice, pPropertyCount: ^u32, pProperties: [^]DisplayProperties2KHR) -> Result -ProcGetPhysicalDeviceDisplayPropertiesKHR :: #type proc "system" (physicalDevice: PhysicalDevice, pPropertyCount: ^u32, pProperties: [^]DisplayPropertiesKHR) -> Result -ProcGetPhysicalDeviceExternalBufferProperties :: #type proc "system" (physicalDevice: PhysicalDevice, pExternalBufferInfo: ^PhysicalDeviceExternalBufferInfo, pExternalBufferProperties: [^]ExternalBufferProperties) -ProcGetPhysicalDeviceExternalBufferPropertiesKHR :: #type proc "system" (physicalDevice: PhysicalDevice, pExternalBufferInfo: ^PhysicalDeviceExternalBufferInfo, pExternalBufferProperties: [^]ExternalBufferProperties) -ProcGetPhysicalDeviceExternalFenceProperties :: #type proc "system" (physicalDevice: PhysicalDevice, pExternalFenceInfo: ^PhysicalDeviceExternalFenceInfo, pExternalFenceProperties: [^]ExternalFenceProperties) -ProcGetPhysicalDeviceExternalFencePropertiesKHR :: #type proc "system" (physicalDevice: PhysicalDevice, pExternalFenceInfo: ^PhysicalDeviceExternalFenceInfo, pExternalFenceProperties: [^]ExternalFenceProperties) -ProcGetPhysicalDeviceExternalImageFormatPropertiesNV :: #type proc "system" (physicalDevice: PhysicalDevice, format: Format, type: ImageType, tiling: ImageTiling, usage: ImageUsageFlags, flags: ImageCreateFlags, externalHandleType: ExternalMemoryHandleTypeFlagsNV, pExternalImageFormatProperties: [^]ExternalImageFormatPropertiesNV) -> Result -ProcGetPhysicalDeviceExternalSemaphoreProperties :: #type proc "system" (physicalDevice: PhysicalDevice, pExternalSemaphoreInfo: ^PhysicalDeviceExternalSemaphoreInfo, pExternalSemaphoreProperties: [^]ExternalSemaphoreProperties) -ProcGetPhysicalDeviceExternalSemaphorePropertiesKHR :: #type proc "system" (physicalDevice: PhysicalDevice, pExternalSemaphoreInfo: ^PhysicalDeviceExternalSemaphoreInfo, pExternalSemaphoreProperties: [^]ExternalSemaphoreProperties) -ProcGetPhysicalDeviceFeatures :: #type proc "system" (physicalDevice: PhysicalDevice, pFeatures: [^]PhysicalDeviceFeatures) -ProcGetPhysicalDeviceFeatures2 :: #type proc "system" (physicalDevice: PhysicalDevice, pFeatures: [^]PhysicalDeviceFeatures2) -ProcGetPhysicalDeviceFeatures2KHR :: #type proc "system" (physicalDevice: PhysicalDevice, pFeatures: [^]PhysicalDeviceFeatures2) -ProcGetPhysicalDeviceFormatProperties :: #type proc "system" (physicalDevice: PhysicalDevice, format: Format, pFormatProperties: [^]FormatProperties) -ProcGetPhysicalDeviceFormatProperties2 :: #type proc "system" (physicalDevice: PhysicalDevice, format: Format, pFormatProperties: [^]FormatProperties2) -ProcGetPhysicalDeviceFormatProperties2KHR :: #type proc "system" (physicalDevice: PhysicalDevice, format: Format, pFormatProperties: [^]FormatProperties2) -ProcGetPhysicalDeviceFragmentShadingRatesKHR :: #type proc "system" (physicalDevice: PhysicalDevice, pFragmentShadingRateCount: ^u32, pFragmentShadingRates: [^]PhysicalDeviceFragmentShadingRateKHR) -> Result -ProcGetPhysicalDeviceImageFormatProperties :: #type proc "system" (physicalDevice: PhysicalDevice, format: Format, type: ImageType, tiling: ImageTiling, usage: ImageUsageFlags, flags: ImageCreateFlags, pImageFormatProperties: [^]ImageFormatProperties) -> Result -ProcGetPhysicalDeviceImageFormatProperties2 :: #type proc "system" (physicalDevice: PhysicalDevice, pImageFormatInfo: ^PhysicalDeviceImageFormatInfo2, pImageFormatProperties: [^]ImageFormatProperties2) -> Result -ProcGetPhysicalDeviceImageFormatProperties2KHR :: #type proc "system" (physicalDevice: PhysicalDevice, pImageFormatInfo: ^PhysicalDeviceImageFormatInfo2, pImageFormatProperties: [^]ImageFormatProperties2) -> Result -ProcGetPhysicalDeviceMemoryProperties :: #type proc "system" (physicalDevice: PhysicalDevice, pMemoryProperties: [^]PhysicalDeviceMemoryProperties) -ProcGetPhysicalDeviceMemoryProperties2 :: #type proc "system" (physicalDevice: PhysicalDevice, pMemoryProperties: [^]PhysicalDeviceMemoryProperties2) -ProcGetPhysicalDeviceMemoryProperties2KHR :: #type proc "system" (physicalDevice: PhysicalDevice, pMemoryProperties: [^]PhysicalDeviceMemoryProperties2) -ProcGetPhysicalDeviceMultisamplePropertiesEXT :: #type proc "system" (physicalDevice: PhysicalDevice, samples: SampleCountFlags, pMultisampleProperties: [^]MultisamplePropertiesEXT) -ProcGetPhysicalDevicePresentRectanglesKHR :: #type proc "system" (physicalDevice: PhysicalDevice, surface: SurfaceKHR, pRectCount: ^u32, pRects: [^]Rect2D) -> Result -ProcGetPhysicalDeviceProperties :: #type proc "system" (physicalDevice: PhysicalDevice, pProperties: [^]PhysicalDeviceProperties) -ProcGetPhysicalDeviceProperties2 :: #type proc "system" (physicalDevice: PhysicalDevice, pProperties: [^]PhysicalDeviceProperties2) -ProcGetPhysicalDeviceProperties2KHR :: #type proc "system" (physicalDevice: PhysicalDevice, pProperties: [^]PhysicalDeviceProperties2) -ProcGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR :: #type proc "system" (physicalDevice: PhysicalDevice, pPerformanceQueryCreateInfo: ^QueryPoolPerformanceCreateInfoKHR, pNumPasses: [^]u32) -ProcGetPhysicalDeviceQueueFamilyProperties :: #type proc "system" (physicalDevice: PhysicalDevice, pQueueFamilyPropertyCount: ^u32, pQueueFamilyProperties: [^]QueueFamilyProperties) -ProcGetPhysicalDeviceQueueFamilyProperties2 :: #type proc "system" (physicalDevice: PhysicalDevice, pQueueFamilyPropertyCount: ^u32, pQueueFamilyProperties: [^]QueueFamilyProperties2) -ProcGetPhysicalDeviceQueueFamilyProperties2KHR :: #type proc "system" (physicalDevice: PhysicalDevice, pQueueFamilyPropertyCount: ^u32, pQueueFamilyProperties: [^]QueueFamilyProperties2) -ProcGetPhysicalDeviceSparseImageFormatProperties :: #type proc "system" (physicalDevice: PhysicalDevice, format: Format, type: ImageType, samples: SampleCountFlags, usage: ImageUsageFlags, tiling: ImageTiling, pPropertyCount: ^u32, pProperties: [^]SparseImageFormatProperties) -ProcGetPhysicalDeviceSparseImageFormatProperties2 :: #type proc "system" (physicalDevice: PhysicalDevice, pFormatInfo: ^PhysicalDeviceSparseImageFormatInfo2, pPropertyCount: ^u32, pProperties: [^]SparseImageFormatProperties2) -ProcGetPhysicalDeviceSparseImageFormatProperties2KHR :: #type proc "system" (physicalDevice: PhysicalDevice, pFormatInfo: ^PhysicalDeviceSparseImageFormatInfo2, pPropertyCount: ^u32, pProperties: [^]SparseImageFormatProperties2) -ProcGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV :: #type proc "system" (physicalDevice: PhysicalDevice, pCombinationCount: ^u32, pCombinations: [^]FramebufferMixedSamplesCombinationNV) -> Result -ProcGetPhysicalDeviceSurfaceCapabilities2EXT :: #type proc "system" (physicalDevice: PhysicalDevice, surface: SurfaceKHR, pSurfaceCapabilities: [^]SurfaceCapabilities2EXT) -> Result -ProcGetPhysicalDeviceSurfaceCapabilities2KHR :: #type proc "system" (physicalDevice: PhysicalDevice, pSurfaceInfo: ^PhysicalDeviceSurfaceInfo2KHR, pSurfaceCapabilities: [^]SurfaceCapabilities2KHR) -> Result -ProcGetPhysicalDeviceSurfaceCapabilitiesKHR :: #type proc "system" (physicalDevice: PhysicalDevice, surface: SurfaceKHR, pSurfaceCapabilities: [^]SurfaceCapabilitiesKHR) -> Result -ProcGetPhysicalDeviceSurfaceFormats2KHR :: #type proc "system" (physicalDevice: PhysicalDevice, pSurfaceInfo: ^PhysicalDeviceSurfaceInfo2KHR, pSurfaceFormatCount: ^u32, pSurfaceFormats: [^]SurfaceFormat2KHR) -> Result -ProcGetPhysicalDeviceSurfaceFormatsKHR :: #type proc "system" (physicalDevice: PhysicalDevice, surface: SurfaceKHR, pSurfaceFormatCount: ^u32, pSurfaceFormats: [^]SurfaceFormatKHR) -> Result -ProcGetPhysicalDeviceSurfacePresentModes2EXT :: #type proc "system" (physicalDevice: PhysicalDevice, pSurfaceInfo: ^PhysicalDeviceSurfaceInfo2KHR, pPresentModeCount: ^u32, pPresentModes: [^]PresentModeKHR) -> Result -ProcGetPhysicalDeviceSurfacePresentModesKHR :: #type proc "system" (physicalDevice: PhysicalDevice, surface: SurfaceKHR, pPresentModeCount: ^u32, pPresentModes: [^]PresentModeKHR) -> Result -ProcGetPhysicalDeviceSurfaceSupportKHR :: #type proc "system" (physicalDevice: PhysicalDevice, queueFamilyIndex: u32, surface: SurfaceKHR, pSupported: ^b32) -> Result -ProcGetPhysicalDeviceToolProperties :: #type proc "system" (physicalDevice: PhysicalDevice, pToolCount: ^u32, pToolProperties: [^]PhysicalDeviceToolProperties) -> Result -ProcGetPhysicalDeviceToolPropertiesEXT :: #type proc "system" (physicalDevice: PhysicalDevice, pToolCount: ^u32, pToolProperties: [^]PhysicalDeviceToolProperties) -> Result -ProcGetPhysicalDeviceWin32PresentationSupportKHR :: #type proc "system" (physicalDevice: PhysicalDevice, queueFamilyIndex: u32) -> b32 -ProcGetWinrtDisplayNV :: #type proc "system" (physicalDevice: PhysicalDevice, deviceRelativeId: u32, pDisplay: ^DisplayKHR) -> Result -ProcReleaseDisplayEXT :: #type proc "system" (physicalDevice: PhysicalDevice, display: DisplayKHR) -> Result -ProcSubmitDebugUtilsMessageEXT :: #type proc "system" (instance: Instance, messageSeverity: DebugUtilsMessageSeverityFlagsEXT, messageTypes: DebugUtilsMessageTypeFlagsEXT, pCallbackData: ^DebugUtilsMessengerCallbackDataEXT) - -// Device Procedure Types -ProcAcquireFullScreenExclusiveModeEXT :: #type proc "system" (device: Device, swapchain: SwapchainKHR) -> Result -ProcAcquireNextImage2KHR :: #type proc "system" (device: Device, pAcquireInfo: ^AcquireNextImageInfoKHR, pImageIndex: ^u32) -> Result -ProcAcquireNextImageKHR :: #type proc "system" (device: Device, swapchain: SwapchainKHR, timeout: u64, semaphore: Semaphore, fence: Fence, pImageIndex: ^u32) -> Result -ProcAcquirePerformanceConfigurationINTEL :: #type proc "system" (device: Device, pAcquireInfo: ^PerformanceConfigurationAcquireInfoINTEL, pConfiguration: ^PerformanceConfigurationINTEL) -> Result -ProcAcquireProfilingLockKHR :: #type proc "system" (device: Device, pInfo: ^AcquireProfilingLockInfoKHR) -> Result -ProcAllocateCommandBuffers :: #type proc "system" (device: Device, pAllocateInfo: ^CommandBufferAllocateInfo, pCommandBuffers: [^]CommandBuffer) -> Result -ProcAllocateDescriptorSets :: #type proc "system" (device: Device, pAllocateInfo: ^DescriptorSetAllocateInfo, pDescriptorSets: [^]DescriptorSet) -> Result -ProcAllocateMemory :: #type proc "system" (device: Device, pAllocateInfo: ^MemoryAllocateInfo, pAllocator: ^AllocationCallbacks, pMemory: ^DeviceMemory) -> Result -ProcBeginCommandBuffer :: #type proc "system" (commandBuffer: CommandBuffer, pBeginInfo: ^CommandBufferBeginInfo) -> Result -ProcBindAccelerationStructureMemoryNV :: #type proc "system" (device: Device, bindInfoCount: u32, pBindInfos: [^]BindAccelerationStructureMemoryInfoNV) -> Result -ProcBindBufferMemory :: #type proc "system" (device: Device, buffer: Buffer, memory: DeviceMemory, memoryOffset: DeviceSize) -> Result -ProcBindBufferMemory2 :: #type proc "system" (device: Device, bindInfoCount: u32, pBindInfos: [^]BindBufferMemoryInfo) -> Result -ProcBindBufferMemory2KHR :: #type proc "system" (device: Device, bindInfoCount: u32, pBindInfos: [^]BindBufferMemoryInfo) -> Result -ProcBindImageMemory :: #type proc "system" (device: Device, image: Image, memory: DeviceMemory, memoryOffset: DeviceSize) -> Result -ProcBindImageMemory2 :: #type proc "system" (device: Device, bindInfoCount: u32, pBindInfos: [^]BindImageMemoryInfo) -> Result -ProcBindImageMemory2KHR :: #type proc "system" (device: Device, bindInfoCount: u32, pBindInfos: [^]BindImageMemoryInfo) -> Result -ProcBuildAccelerationStructuresKHR :: #type proc "system" (device: Device, deferredOperation: DeferredOperationKHR, infoCount: u32, pInfos: [^]AccelerationStructureBuildGeometryInfoKHR, ppBuildRangeInfos: ^[^]AccelerationStructureBuildRangeInfoKHR) -> Result -ProcCmdBeginConditionalRenderingEXT :: #type proc "system" (commandBuffer: CommandBuffer, pConditionalRenderingBegin: ^ConditionalRenderingBeginInfoEXT) -ProcCmdBeginDebugUtilsLabelEXT :: #type proc "system" (commandBuffer: CommandBuffer, pLabelInfo: ^DebugUtilsLabelEXT) -ProcCmdBeginQuery :: #type proc "system" (commandBuffer: CommandBuffer, queryPool: QueryPool, query: u32, flags: QueryControlFlags) -ProcCmdBeginQueryIndexedEXT :: #type proc "system" (commandBuffer: CommandBuffer, queryPool: QueryPool, query: u32, flags: QueryControlFlags, index: u32) -ProcCmdBeginRenderPass :: #type proc "system" (commandBuffer: CommandBuffer, pRenderPassBegin: ^RenderPassBeginInfo, contents: SubpassContents) -ProcCmdBeginRenderPass2 :: #type proc "system" (commandBuffer: CommandBuffer, pRenderPassBegin: ^RenderPassBeginInfo, pSubpassBeginInfo: ^SubpassBeginInfo) -ProcCmdBeginRenderPass2KHR :: #type proc "system" (commandBuffer: CommandBuffer, pRenderPassBegin: ^RenderPassBeginInfo, pSubpassBeginInfo: ^SubpassBeginInfo) -ProcCmdBeginRendering :: #type proc "system" (commandBuffer: CommandBuffer, pRenderingInfo: ^RenderingInfo) -ProcCmdBeginRenderingKHR :: #type proc "system" (commandBuffer: CommandBuffer, pRenderingInfo: ^RenderingInfo) -ProcCmdBeginTransformFeedbackEXT :: #type proc "system" (commandBuffer: CommandBuffer, firstCounterBuffer: u32, counterBufferCount: u32, pCounterBuffers: [^]Buffer, pCounterBufferOffsets: [^]DeviceSize) -ProcCmdBindDescriptorSets :: #type proc "system" (commandBuffer: CommandBuffer, pipelineBindPoint: PipelineBindPoint, layout: PipelineLayout, firstSet: u32, descriptorSetCount: u32, pDescriptorSets: [^]DescriptorSet, dynamicOffsetCount: u32, pDynamicOffsets: [^]u32) -ProcCmdBindIndexBuffer :: #type proc "system" (commandBuffer: CommandBuffer, buffer: Buffer, offset: DeviceSize, indexType: IndexType) -ProcCmdBindInvocationMaskHUAWEI :: #type proc "system" (commandBuffer: CommandBuffer, imageView: ImageView, imageLayout: ImageLayout) -ProcCmdBindPipeline :: #type proc "system" (commandBuffer: CommandBuffer, pipelineBindPoint: PipelineBindPoint, pipeline: Pipeline) -ProcCmdBindPipelineShaderGroupNV :: #type proc "system" (commandBuffer: CommandBuffer, pipelineBindPoint: PipelineBindPoint, pipeline: Pipeline, groupIndex: u32) -ProcCmdBindShadingRateImageNV :: #type proc "system" (commandBuffer: CommandBuffer, imageView: ImageView, imageLayout: ImageLayout) -ProcCmdBindTransformFeedbackBuffersEXT :: #type proc "system" (commandBuffer: CommandBuffer, firstBinding: u32, bindingCount: u32, pBuffers: [^]Buffer, pOffsets: [^]DeviceSize, pSizes: [^]DeviceSize) -ProcCmdBindVertexBuffers :: #type proc "system" (commandBuffer: CommandBuffer, firstBinding: u32, bindingCount: u32, pBuffers: [^]Buffer, pOffsets: [^]DeviceSize) -ProcCmdBindVertexBuffers2 :: #type proc "system" (commandBuffer: CommandBuffer, firstBinding: u32, bindingCount: u32, pBuffers: [^]Buffer, pOffsets: [^]DeviceSize, pSizes: [^]DeviceSize, pStrides: [^]DeviceSize) -ProcCmdBindVertexBuffers2EXT :: #type proc "system" (commandBuffer: CommandBuffer, firstBinding: u32, bindingCount: u32, pBuffers: [^]Buffer, pOffsets: [^]DeviceSize, pSizes: [^]DeviceSize, pStrides: [^]DeviceSize) -ProcCmdBlitImage :: #type proc "system" (commandBuffer: CommandBuffer, srcImage: Image, srcImageLayout: ImageLayout, dstImage: Image, dstImageLayout: ImageLayout, regionCount: u32, pRegions: [^]ImageBlit, filter: Filter) -ProcCmdBlitImage2 :: #type proc "system" (commandBuffer: CommandBuffer, pBlitImageInfo: ^BlitImageInfo2) -ProcCmdBlitImage2KHR :: #type proc "system" (commandBuffer: CommandBuffer, pBlitImageInfo: ^BlitImageInfo2) -ProcCmdBuildAccelerationStructureNV :: #type proc "system" (commandBuffer: CommandBuffer, pInfo: ^AccelerationStructureInfoNV, instanceData: Buffer, instanceOffset: DeviceSize, update: b32, dst: AccelerationStructureNV, src: AccelerationStructureNV, scratch: Buffer, scratchOffset: DeviceSize) -ProcCmdBuildAccelerationStructuresIndirectKHR :: #type proc "system" (commandBuffer: CommandBuffer, infoCount: u32, pInfos: [^]AccelerationStructureBuildGeometryInfoKHR, pIndirectDeviceAddresses: [^]DeviceAddress, pIndirectStrides: [^]u32, ppMaxPrimitiveCounts: ^[^]u32) -ProcCmdBuildAccelerationStructuresKHR :: #type proc "system" (commandBuffer: CommandBuffer, infoCount: u32, pInfos: [^]AccelerationStructureBuildGeometryInfoKHR, ppBuildRangeInfos: ^[^]AccelerationStructureBuildRangeInfoKHR) -ProcCmdClearAttachments :: #type proc "system" (commandBuffer: CommandBuffer, attachmentCount: u32, pAttachments: [^]ClearAttachment, rectCount: u32, pRects: [^]ClearRect) -ProcCmdClearColorImage :: #type proc "system" (commandBuffer: CommandBuffer, image: Image, imageLayout: ImageLayout, pColor: ^ClearColorValue, rangeCount: u32, pRanges: [^]ImageSubresourceRange) -ProcCmdClearDepthStencilImage :: #type proc "system" (commandBuffer: CommandBuffer, image: Image, imageLayout: ImageLayout, pDepthStencil: ^ClearDepthStencilValue, rangeCount: u32, pRanges: [^]ImageSubresourceRange) -ProcCmdCopyAccelerationStructureKHR :: #type proc "system" (commandBuffer: CommandBuffer, pInfo: ^CopyAccelerationStructureInfoKHR) -ProcCmdCopyAccelerationStructureNV :: #type proc "system" (commandBuffer: CommandBuffer, dst: AccelerationStructureNV, src: AccelerationStructureNV, mode: CopyAccelerationStructureModeKHR) -ProcCmdCopyAccelerationStructureToMemoryKHR :: #type proc "system" (commandBuffer: CommandBuffer, pInfo: ^CopyAccelerationStructureToMemoryInfoKHR) -ProcCmdCopyBuffer :: #type proc "system" (commandBuffer: CommandBuffer, srcBuffer: Buffer, dstBuffer: Buffer, regionCount: u32, pRegions: [^]BufferCopy) -ProcCmdCopyBuffer2 :: #type proc "system" (commandBuffer: CommandBuffer, pCopyBufferInfo: ^CopyBufferInfo2) -ProcCmdCopyBuffer2KHR :: #type proc "system" (commandBuffer: CommandBuffer, pCopyBufferInfo: ^CopyBufferInfo2) -ProcCmdCopyBufferToImage :: #type proc "system" (commandBuffer: CommandBuffer, srcBuffer: Buffer, dstImage: Image, dstImageLayout: ImageLayout, regionCount: u32, pRegions: [^]BufferImageCopy) -ProcCmdCopyBufferToImage2 :: #type proc "system" (commandBuffer: CommandBuffer, pCopyBufferToImageInfo: ^CopyBufferToImageInfo2) -ProcCmdCopyBufferToImage2KHR :: #type proc "system" (commandBuffer: CommandBuffer, pCopyBufferToImageInfo: ^CopyBufferToImageInfo2) -ProcCmdCopyImage :: #type proc "system" (commandBuffer: CommandBuffer, srcImage: Image, srcImageLayout: ImageLayout, dstImage: Image, dstImageLayout: ImageLayout, regionCount: u32, pRegions: [^]ImageCopy) -ProcCmdCopyImage2 :: #type proc "system" (commandBuffer: CommandBuffer, pCopyImageInfo: ^CopyImageInfo2) -ProcCmdCopyImage2KHR :: #type proc "system" (commandBuffer: CommandBuffer, pCopyImageInfo: ^CopyImageInfo2) -ProcCmdCopyImageToBuffer :: #type proc "system" (commandBuffer: CommandBuffer, srcImage: Image, srcImageLayout: ImageLayout, dstBuffer: Buffer, regionCount: u32, pRegions: [^]BufferImageCopy) -ProcCmdCopyImageToBuffer2 :: #type proc "system" (commandBuffer: CommandBuffer, pCopyImageToBufferInfo: ^CopyImageToBufferInfo2) -ProcCmdCopyImageToBuffer2KHR :: #type proc "system" (commandBuffer: CommandBuffer, pCopyImageToBufferInfo: ^CopyImageToBufferInfo2) -ProcCmdCopyMemoryToAccelerationStructureKHR :: #type proc "system" (commandBuffer: CommandBuffer, pInfo: ^CopyMemoryToAccelerationStructureInfoKHR) -ProcCmdCopyQueryPoolResults :: #type proc "system" (commandBuffer: CommandBuffer, queryPool: QueryPool, firstQuery: u32, queryCount: u32, dstBuffer: Buffer, dstOffset: DeviceSize, stride: DeviceSize, flags: QueryResultFlags) -ProcCmdCuLaunchKernelNVX :: #type proc "system" (commandBuffer: CommandBuffer, pLaunchInfo: ^CuLaunchInfoNVX) -ProcCmdDebugMarkerBeginEXT :: #type proc "system" (commandBuffer: CommandBuffer, pMarkerInfo: ^DebugMarkerMarkerInfoEXT) -ProcCmdDebugMarkerEndEXT :: #type proc "system" (commandBuffer: CommandBuffer) -ProcCmdDebugMarkerInsertEXT :: #type proc "system" (commandBuffer: CommandBuffer, pMarkerInfo: ^DebugMarkerMarkerInfoEXT) -ProcCmdDispatch :: #type proc "system" (commandBuffer: CommandBuffer, groupCountX: u32, groupCountY: u32, groupCountZ: u32) -ProcCmdDispatchBase :: #type proc "system" (commandBuffer: CommandBuffer, baseGroupX: u32, baseGroupY: u32, baseGroupZ: u32, groupCountX: u32, groupCountY: u32, groupCountZ: u32) -ProcCmdDispatchBaseKHR :: #type proc "system" (commandBuffer: CommandBuffer, baseGroupX: u32, baseGroupY: u32, baseGroupZ: u32, groupCountX: u32, groupCountY: u32, groupCountZ: u32) -ProcCmdDispatchIndirect :: #type proc "system" (commandBuffer: CommandBuffer, buffer: Buffer, offset: DeviceSize) -ProcCmdDraw :: #type proc "system" (commandBuffer: CommandBuffer, vertexCount: u32, instanceCount: u32, firstVertex: u32, firstInstance: u32) -ProcCmdDrawIndexed :: #type proc "system" (commandBuffer: CommandBuffer, indexCount: u32, instanceCount: u32, firstIndex: u32, vertexOffset: i32, firstInstance: u32) -ProcCmdDrawIndexedIndirect :: #type proc "system" (commandBuffer: CommandBuffer, buffer: Buffer, offset: DeviceSize, drawCount: u32, stride: u32) -ProcCmdDrawIndexedIndirectCount :: #type proc "system" (commandBuffer: CommandBuffer, buffer: Buffer, offset: DeviceSize, countBuffer: Buffer, countBufferOffset: DeviceSize, maxDrawCount: u32, stride: u32) -ProcCmdDrawIndexedIndirectCountAMD :: #type proc "system" (commandBuffer: CommandBuffer, buffer: Buffer, offset: DeviceSize, countBuffer: Buffer, countBufferOffset: DeviceSize, maxDrawCount: u32, stride: u32) -ProcCmdDrawIndexedIndirectCountKHR :: #type proc "system" (commandBuffer: CommandBuffer, buffer: Buffer, offset: DeviceSize, countBuffer: Buffer, countBufferOffset: DeviceSize, maxDrawCount: u32, stride: u32) -ProcCmdDrawIndirect :: #type proc "system" (commandBuffer: CommandBuffer, buffer: Buffer, offset: DeviceSize, drawCount: u32, stride: u32) -ProcCmdDrawIndirectByteCountEXT :: #type proc "system" (commandBuffer: CommandBuffer, instanceCount: u32, firstInstance: u32, counterBuffer: Buffer, counterBufferOffset: DeviceSize, counterOffset: u32, vertexStride: u32) -ProcCmdDrawIndirectCount :: #type proc "system" (commandBuffer: CommandBuffer, buffer: Buffer, offset: DeviceSize, countBuffer: Buffer, countBufferOffset: DeviceSize, maxDrawCount: u32, stride: u32) -ProcCmdDrawIndirectCountAMD :: #type proc "system" (commandBuffer: CommandBuffer, buffer: Buffer, offset: DeviceSize, countBuffer: Buffer, countBufferOffset: DeviceSize, maxDrawCount: u32, stride: u32) -ProcCmdDrawIndirectCountKHR :: #type proc "system" (commandBuffer: CommandBuffer, buffer: Buffer, offset: DeviceSize, countBuffer: Buffer, countBufferOffset: DeviceSize, maxDrawCount: u32, stride: u32) -ProcCmdDrawMeshTasksIndirectCountNV :: #type proc "system" (commandBuffer: CommandBuffer, buffer: Buffer, offset: DeviceSize, countBuffer: Buffer, countBufferOffset: DeviceSize, maxDrawCount: u32, stride: u32) -ProcCmdDrawMeshTasksIndirectNV :: #type proc "system" (commandBuffer: CommandBuffer, buffer: Buffer, offset: DeviceSize, drawCount: u32, stride: u32) -ProcCmdDrawMeshTasksNV :: #type proc "system" (commandBuffer: CommandBuffer, taskCount: u32, firstTask: u32) -ProcCmdDrawMultiEXT :: #type proc "system" (commandBuffer: CommandBuffer, drawCount: u32, pVertexInfo: ^MultiDrawInfoEXT, instanceCount: u32, firstInstance: u32, stride: u32) -ProcCmdDrawMultiIndexedEXT :: #type proc "system" (commandBuffer: CommandBuffer, drawCount: u32, pIndexInfo: ^MultiDrawIndexedInfoEXT, instanceCount: u32, firstInstance: u32, stride: u32, pVertexOffset: ^i32) -ProcCmdEndConditionalRenderingEXT :: #type proc "system" (commandBuffer: CommandBuffer) -ProcCmdEndDebugUtilsLabelEXT :: #type proc "system" (commandBuffer: CommandBuffer) -ProcCmdEndQuery :: #type proc "system" (commandBuffer: CommandBuffer, queryPool: QueryPool, query: u32) -ProcCmdEndQueryIndexedEXT :: #type proc "system" (commandBuffer: CommandBuffer, queryPool: QueryPool, query: u32, index: u32) -ProcCmdEndRenderPass :: #type proc "system" (commandBuffer: CommandBuffer) -ProcCmdEndRenderPass2 :: #type proc "system" (commandBuffer: CommandBuffer, pSubpassEndInfo: ^SubpassEndInfo) -ProcCmdEndRenderPass2KHR :: #type proc "system" (commandBuffer: CommandBuffer, pSubpassEndInfo: ^SubpassEndInfo) -ProcCmdEndRendering :: #type proc "system" (commandBuffer: CommandBuffer) -ProcCmdEndRenderingKHR :: #type proc "system" (commandBuffer: CommandBuffer) -ProcCmdEndTransformFeedbackEXT :: #type proc "system" (commandBuffer: CommandBuffer, firstCounterBuffer: u32, counterBufferCount: u32, pCounterBuffers: [^]Buffer, pCounterBufferOffsets: [^]DeviceSize) -ProcCmdExecuteCommands :: #type proc "system" (commandBuffer: CommandBuffer, commandBufferCount: u32, pCommandBuffers: [^]CommandBuffer) -ProcCmdExecuteGeneratedCommandsNV :: #type proc "system" (commandBuffer: CommandBuffer, isPreprocessed: b32, pGeneratedCommandsInfo: ^GeneratedCommandsInfoNV) -ProcCmdFillBuffer :: #type proc "system" (commandBuffer: CommandBuffer, dstBuffer: Buffer, dstOffset: DeviceSize, size: DeviceSize, data: u32) -ProcCmdInsertDebugUtilsLabelEXT :: #type proc "system" (commandBuffer: CommandBuffer, pLabelInfo: ^DebugUtilsLabelEXT) -ProcCmdNextSubpass :: #type proc "system" (commandBuffer: CommandBuffer, contents: SubpassContents) -ProcCmdNextSubpass2 :: #type proc "system" (commandBuffer: CommandBuffer, pSubpassBeginInfo: ^SubpassBeginInfo, pSubpassEndInfo: ^SubpassEndInfo) -ProcCmdNextSubpass2KHR :: #type proc "system" (commandBuffer: CommandBuffer, pSubpassBeginInfo: ^SubpassBeginInfo, pSubpassEndInfo: ^SubpassEndInfo) -ProcCmdPipelineBarrier :: #type proc "system" (commandBuffer: CommandBuffer, srcStageMask: PipelineStageFlags, dstStageMask: PipelineStageFlags, dependencyFlags: DependencyFlags, memoryBarrierCount: u32, pMemoryBarriers: [^]MemoryBarrier, bufferMemoryBarrierCount: u32, pBufferMemoryBarriers: [^]BufferMemoryBarrier, imageMemoryBarrierCount: u32, pImageMemoryBarriers: [^]ImageMemoryBarrier) -ProcCmdPipelineBarrier2 :: #type proc "system" (commandBuffer: CommandBuffer, pDependencyInfo: ^DependencyInfo) -ProcCmdPipelineBarrier2KHR :: #type proc "system" (commandBuffer: CommandBuffer, pDependencyInfo: ^DependencyInfo) -ProcCmdPreprocessGeneratedCommandsNV :: #type proc "system" (commandBuffer: CommandBuffer, pGeneratedCommandsInfo: ^GeneratedCommandsInfoNV) -ProcCmdPushConstants :: #type proc "system" (commandBuffer: CommandBuffer, layout: PipelineLayout, stageFlags: ShaderStageFlags, offset: u32, size: u32, pValues: rawptr) -ProcCmdPushDescriptorSetKHR :: #type proc "system" (commandBuffer: CommandBuffer, pipelineBindPoint: PipelineBindPoint, layout: PipelineLayout, set: u32, descriptorWriteCount: u32, pDescriptorWrites: [^]WriteDescriptorSet) -ProcCmdPushDescriptorSetWithTemplateKHR :: #type proc "system" (commandBuffer: CommandBuffer, descriptorUpdateTemplate: DescriptorUpdateTemplate, layout: PipelineLayout, set: u32, pData: rawptr) -ProcCmdResetEvent :: #type proc "system" (commandBuffer: CommandBuffer, event: Event, stageMask: PipelineStageFlags) -ProcCmdResetEvent2 :: #type proc "system" (commandBuffer: CommandBuffer, event: Event, stageMask: PipelineStageFlags2) -ProcCmdResetEvent2KHR :: #type proc "system" (commandBuffer: CommandBuffer, event: Event, stageMask: PipelineStageFlags2) -ProcCmdResetQueryPool :: #type proc "system" (commandBuffer: CommandBuffer, queryPool: QueryPool, firstQuery: u32, queryCount: u32) -ProcCmdResolveImage :: #type proc "system" (commandBuffer: CommandBuffer, srcImage: Image, srcImageLayout: ImageLayout, dstImage: Image, dstImageLayout: ImageLayout, regionCount: u32, pRegions: [^]ImageResolve) -ProcCmdResolveImage2 :: #type proc "system" (commandBuffer: CommandBuffer, pResolveImageInfo: ^ResolveImageInfo2) -ProcCmdResolveImage2KHR :: #type proc "system" (commandBuffer: CommandBuffer, pResolveImageInfo: ^ResolveImageInfo2) -ProcCmdSetBlendConstants :: #type proc "system" (commandBuffer: CommandBuffer) -ProcCmdSetCheckpointNV :: #type proc "system" (commandBuffer: CommandBuffer, pCheckpointMarker: rawptr) -ProcCmdSetCoarseSampleOrderNV :: #type proc "system" (commandBuffer: CommandBuffer, sampleOrderType: CoarseSampleOrderTypeNV, customSampleOrderCount: u32, pCustomSampleOrders: [^]CoarseSampleOrderCustomNV) -ProcCmdSetCullMode :: #type proc "system" (commandBuffer: CommandBuffer, cullMode: CullModeFlags) -ProcCmdSetCullModeEXT :: #type proc "system" (commandBuffer: CommandBuffer, cullMode: CullModeFlags) -ProcCmdSetDepthBias :: #type proc "system" (commandBuffer: CommandBuffer, depthBiasConstantFactor: f32, depthBiasClamp: f32, depthBiasSlopeFactor: f32) -ProcCmdSetDepthBiasEnable :: #type proc "system" (commandBuffer: CommandBuffer, depthBiasEnable: b32) -ProcCmdSetDepthBiasEnableEXT :: #type proc "system" (commandBuffer: CommandBuffer, depthBiasEnable: b32) -ProcCmdSetDepthBounds :: #type proc "system" (commandBuffer: CommandBuffer, minDepthBounds: f32, maxDepthBounds: f32) -ProcCmdSetDepthBoundsTestEnable :: #type proc "system" (commandBuffer: CommandBuffer, depthBoundsTestEnable: b32) -ProcCmdSetDepthBoundsTestEnableEXT :: #type proc "system" (commandBuffer: CommandBuffer, depthBoundsTestEnable: b32) -ProcCmdSetDepthCompareOp :: #type proc "system" (commandBuffer: CommandBuffer, depthCompareOp: CompareOp) -ProcCmdSetDepthCompareOpEXT :: #type proc "system" (commandBuffer: CommandBuffer, depthCompareOp: CompareOp) -ProcCmdSetDepthTestEnable :: #type proc "system" (commandBuffer: CommandBuffer, depthTestEnable: b32) -ProcCmdSetDepthTestEnableEXT :: #type proc "system" (commandBuffer: CommandBuffer, depthTestEnable: b32) -ProcCmdSetDepthWriteEnable :: #type proc "system" (commandBuffer: CommandBuffer, depthWriteEnable: b32) -ProcCmdSetDepthWriteEnableEXT :: #type proc "system" (commandBuffer: CommandBuffer, depthWriteEnable: b32) -ProcCmdSetDeviceMask :: #type proc "system" (commandBuffer: CommandBuffer, deviceMask: u32) -ProcCmdSetDeviceMaskKHR :: #type proc "system" (commandBuffer: CommandBuffer, deviceMask: u32) -ProcCmdSetDiscardRectangleEXT :: #type proc "system" (commandBuffer: CommandBuffer, firstDiscardRectangle: u32, discardRectangleCount: u32, pDiscardRectangles: [^]Rect2D) -ProcCmdSetEvent :: #type proc "system" (commandBuffer: CommandBuffer, event: Event, stageMask: PipelineStageFlags) -ProcCmdSetEvent2 :: #type proc "system" (commandBuffer: CommandBuffer, event: Event, pDependencyInfo: ^DependencyInfo) -ProcCmdSetEvent2KHR :: #type proc "system" (commandBuffer: CommandBuffer, event: Event, pDependencyInfo: ^DependencyInfo) -ProcCmdSetExclusiveScissorNV :: #type proc "system" (commandBuffer: CommandBuffer, firstExclusiveScissor: u32, exclusiveScissorCount: u32, pExclusiveScissors: [^]Rect2D) -ProcCmdSetFragmentShadingRateEnumNV :: #type proc "system" (commandBuffer: CommandBuffer, shadingRate: FragmentShadingRateNV) -ProcCmdSetFragmentShadingRateKHR :: #type proc "system" (commandBuffer: CommandBuffer, pFragmentSize: ^Extent2D) -ProcCmdSetFrontFace :: #type proc "system" (commandBuffer: CommandBuffer, frontFace: FrontFace) -ProcCmdSetFrontFaceEXT :: #type proc "system" (commandBuffer: CommandBuffer, frontFace: FrontFace) -ProcCmdSetLineStippleEXT :: #type proc "system" (commandBuffer: CommandBuffer, lineStippleFactor: u32, lineStipplePattern: u16) -ProcCmdSetLineWidth :: #type proc "system" (commandBuffer: CommandBuffer, lineWidth: f32) -ProcCmdSetLogicOpEXT :: #type proc "system" (commandBuffer: CommandBuffer, logicOp: LogicOp) -ProcCmdSetPatchControlPointsEXT :: #type proc "system" (commandBuffer: CommandBuffer, patchControlPoints: u32) -ProcCmdSetPerformanceMarkerINTEL :: #type proc "system" (commandBuffer: CommandBuffer, pMarkerInfo: ^PerformanceMarkerInfoINTEL) -> Result -ProcCmdSetPerformanceOverrideINTEL :: #type proc "system" (commandBuffer: CommandBuffer, pOverrideInfo: ^PerformanceOverrideInfoINTEL) -> Result -ProcCmdSetPerformanceStreamMarkerINTEL :: #type proc "system" (commandBuffer: CommandBuffer, pMarkerInfo: ^PerformanceStreamMarkerInfoINTEL) -> Result -ProcCmdSetPrimitiveRestartEnable :: #type proc "system" (commandBuffer: CommandBuffer, primitiveRestartEnable: b32) -ProcCmdSetPrimitiveRestartEnableEXT :: #type proc "system" (commandBuffer: CommandBuffer, primitiveRestartEnable: b32) -ProcCmdSetPrimitiveTopology :: #type proc "system" (commandBuffer: CommandBuffer, primitiveTopology: PrimitiveTopology) -ProcCmdSetPrimitiveTopologyEXT :: #type proc "system" (commandBuffer: CommandBuffer, primitiveTopology: PrimitiveTopology) -ProcCmdSetRasterizerDiscardEnable :: #type proc "system" (commandBuffer: CommandBuffer, rasterizerDiscardEnable: b32) -ProcCmdSetRasterizerDiscardEnableEXT :: #type proc "system" (commandBuffer: CommandBuffer, rasterizerDiscardEnable: b32) -ProcCmdSetRayTracingPipelineStackSizeKHR :: #type proc "system" (commandBuffer: CommandBuffer, pipelineStackSize: u32) -ProcCmdSetSampleLocationsEXT :: #type proc "system" (commandBuffer: CommandBuffer, pSampleLocationsInfo: ^SampleLocationsInfoEXT) -ProcCmdSetScissor :: #type proc "system" (commandBuffer: CommandBuffer, firstScissor: u32, scissorCount: u32, pScissors: [^]Rect2D) -ProcCmdSetScissorWithCount :: #type proc "system" (commandBuffer: CommandBuffer, scissorCount: u32, pScissors: [^]Rect2D) -ProcCmdSetScissorWithCountEXT :: #type proc "system" (commandBuffer: CommandBuffer, scissorCount: u32, pScissors: [^]Rect2D) -ProcCmdSetStencilCompareMask :: #type proc "system" (commandBuffer: CommandBuffer, faceMask: StencilFaceFlags, compareMask: u32) -ProcCmdSetStencilOp :: #type proc "system" (commandBuffer: CommandBuffer, faceMask: StencilFaceFlags, failOp: StencilOp, passOp: StencilOp, depthFailOp: StencilOp, compareOp: CompareOp) -ProcCmdSetStencilOpEXT :: #type proc "system" (commandBuffer: CommandBuffer, faceMask: StencilFaceFlags, failOp: StencilOp, passOp: StencilOp, depthFailOp: StencilOp, compareOp: CompareOp) -ProcCmdSetStencilReference :: #type proc "system" (commandBuffer: CommandBuffer, faceMask: StencilFaceFlags, reference: u32) -ProcCmdSetStencilTestEnable :: #type proc "system" (commandBuffer: CommandBuffer, stencilTestEnable: b32) -ProcCmdSetStencilTestEnableEXT :: #type proc "system" (commandBuffer: CommandBuffer, stencilTestEnable: b32) -ProcCmdSetStencilWriteMask :: #type proc "system" (commandBuffer: CommandBuffer, faceMask: StencilFaceFlags, writeMask: u32) -ProcCmdSetVertexInputEXT :: #type proc "system" (commandBuffer: CommandBuffer, vertexBindingDescriptionCount: u32, pVertexBindingDescriptions: [^]VertexInputBindingDescription2EXT, vertexAttributeDescriptionCount: u32, pVertexAttributeDescriptions: [^]VertexInputAttributeDescription2EXT) -ProcCmdSetViewport :: #type proc "system" (commandBuffer: CommandBuffer, firstViewport: u32, viewportCount: u32, pViewports: [^]Viewport) -ProcCmdSetViewportShadingRatePaletteNV :: #type proc "system" (commandBuffer: CommandBuffer, firstViewport: u32, viewportCount: u32, pShadingRatePalettes: [^]ShadingRatePaletteNV) -ProcCmdSetViewportWScalingNV :: #type proc "system" (commandBuffer: CommandBuffer, firstViewport: u32, viewportCount: u32, pViewportWScalings: [^]ViewportWScalingNV) -ProcCmdSetViewportWithCount :: #type proc "system" (commandBuffer: CommandBuffer, viewportCount: u32, pViewports: [^]Viewport) -ProcCmdSetViewportWithCountEXT :: #type proc "system" (commandBuffer: CommandBuffer, viewportCount: u32, pViewports: [^]Viewport) -ProcCmdSubpassShadingHUAWEI :: #type proc "system" (commandBuffer: CommandBuffer) -ProcCmdTraceRaysIndirectKHR :: #type proc "system" (commandBuffer: CommandBuffer, pRaygenShaderBindingTable: [^]StridedDeviceAddressRegionKHR, pMissShaderBindingTable: [^]StridedDeviceAddressRegionKHR, pHitShaderBindingTable: [^]StridedDeviceAddressRegionKHR, pCallableShaderBindingTable: [^]StridedDeviceAddressRegionKHR, indirectDeviceAddress: DeviceAddress) -ProcCmdTraceRaysKHR :: #type proc "system" (commandBuffer: CommandBuffer, pRaygenShaderBindingTable: [^]StridedDeviceAddressRegionKHR, pMissShaderBindingTable: [^]StridedDeviceAddressRegionKHR, pHitShaderBindingTable: [^]StridedDeviceAddressRegionKHR, pCallableShaderBindingTable: [^]StridedDeviceAddressRegionKHR, width: u32, height: u32, depth: u32) -ProcCmdTraceRaysNV :: #type proc "system" (commandBuffer: CommandBuffer, raygenShaderBindingTableBuffer: Buffer, raygenShaderBindingOffset: DeviceSize, missShaderBindingTableBuffer: Buffer, missShaderBindingOffset: DeviceSize, missShaderBindingStride: DeviceSize, hitShaderBindingTableBuffer: Buffer, hitShaderBindingOffset: DeviceSize, hitShaderBindingStride: DeviceSize, callableShaderBindingTableBuffer: Buffer, callableShaderBindingOffset: DeviceSize, callableShaderBindingStride: DeviceSize, width: u32, height: u32, depth: u32) -ProcCmdUpdateBuffer :: #type proc "system" (commandBuffer: CommandBuffer, dstBuffer: Buffer, dstOffset: DeviceSize, dataSize: DeviceSize, pData: rawptr) -ProcCmdWaitEvents :: #type proc "system" (commandBuffer: CommandBuffer, eventCount: u32, pEvents: [^]Event, srcStageMask: PipelineStageFlags, dstStageMask: PipelineStageFlags, memoryBarrierCount: u32, pMemoryBarriers: [^]MemoryBarrier, bufferMemoryBarrierCount: u32, pBufferMemoryBarriers: [^]BufferMemoryBarrier, imageMemoryBarrierCount: u32, pImageMemoryBarriers: [^]ImageMemoryBarrier) -ProcCmdWaitEvents2 :: #type proc "system" (commandBuffer: CommandBuffer, eventCount: u32, pEvents: [^]Event, pDependencyInfos: [^]DependencyInfo) -ProcCmdWaitEvents2KHR :: #type proc "system" (commandBuffer: CommandBuffer, eventCount: u32, pEvents: [^]Event, pDependencyInfos: [^]DependencyInfo) -ProcCmdWriteAccelerationStructuresPropertiesKHR :: #type proc "system" (commandBuffer: CommandBuffer, accelerationStructureCount: u32, pAccelerationStructures: [^]AccelerationStructureKHR, queryType: QueryType, queryPool: QueryPool, firstQuery: u32) -ProcCmdWriteAccelerationStructuresPropertiesNV :: #type proc "system" (commandBuffer: CommandBuffer, accelerationStructureCount: u32, pAccelerationStructures: [^]AccelerationStructureNV, queryType: QueryType, queryPool: QueryPool, firstQuery: u32) -ProcCmdWriteBufferMarker2AMD :: #type proc "system" (commandBuffer: CommandBuffer, stage: PipelineStageFlags2, dstBuffer: Buffer, dstOffset: DeviceSize, marker: u32) -ProcCmdWriteBufferMarkerAMD :: #type proc "system" (commandBuffer: CommandBuffer, pipelineStage: PipelineStageFlags, dstBuffer: Buffer, dstOffset: DeviceSize, marker: u32) -ProcCmdWriteTimestamp :: #type proc "system" (commandBuffer: CommandBuffer, pipelineStage: PipelineStageFlags, queryPool: QueryPool, query: u32) -ProcCmdWriteTimestamp2 :: #type proc "system" (commandBuffer: CommandBuffer, stage: PipelineStageFlags2, queryPool: QueryPool, query: u32) -ProcCmdWriteTimestamp2KHR :: #type proc "system" (commandBuffer: CommandBuffer, stage: PipelineStageFlags2, queryPool: QueryPool, query: u32) -ProcCompileDeferredNV :: #type proc "system" (device: Device, pipeline: Pipeline, shader: u32) -> Result -ProcCopyAccelerationStructureKHR :: #type proc "system" (device: Device, deferredOperation: DeferredOperationKHR, pInfo: ^CopyAccelerationStructureInfoKHR) -> Result -ProcCopyAccelerationStructureToMemoryKHR :: #type proc "system" (device: Device, deferredOperation: DeferredOperationKHR, pInfo: ^CopyAccelerationStructureToMemoryInfoKHR) -> Result -ProcCopyMemoryToAccelerationStructureKHR :: #type proc "system" (device: Device, deferredOperation: DeferredOperationKHR, pInfo: ^CopyMemoryToAccelerationStructureInfoKHR) -> Result -ProcCreateAccelerationStructureKHR :: #type proc "system" (device: Device, pCreateInfo: ^AccelerationStructureCreateInfoKHR, pAllocator: ^AllocationCallbacks, pAccelerationStructure: ^AccelerationStructureKHR) -> Result -ProcCreateAccelerationStructureNV :: #type proc "system" (device: Device, pCreateInfo: ^AccelerationStructureCreateInfoNV, pAllocator: ^AllocationCallbacks, pAccelerationStructure: ^AccelerationStructureNV) -> Result -ProcCreateBuffer :: #type proc "system" (device: Device, pCreateInfo: ^BufferCreateInfo, pAllocator: ^AllocationCallbacks, pBuffer: ^Buffer) -> Result -ProcCreateBufferView :: #type proc "system" (device: Device, pCreateInfo: ^BufferViewCreateInfo, pAllocator: ^AllocationCallbacks, pView: ^BufferView) -> Result -ProcCreateCommandPool :: #type proc "system" (device: Device, pCreateInfo: ^CommandPoolCreateInfo, pAllocator: ^AllocationCallbacks, pCommandPool: ^CommandPool) -> Result -ProcCreateComputePipelines :: #type proc "system" (device: Device, pipelineCache: PipelineCache, createInfoCount: u32, pCreateInfos: [^]ComputePipelineCreateInfo, pAllocator: ^AllocationCallbacks, pPipelines: [^]Pipeline) -> Result -ProcCreateCuFunctionNVX :: #type proc "system" (device: Device, pCreateInfo: ^CuFunctionCreateInfoNVX, pAllocator: ^AllocationCallbacks, pFunction: ^CuFunctionNVX) -> Result -ProcCreateCuModuleNVX :: #type proc "system" (device: Device, pCreateInfo: ^CuModuleCreateInfoNVX, pAllocator: ^AllocationCallbacks, pModule: ^CuModuleNVX) -> Result -ProcCreateDeferredOperationKHR :: #type proc "system" (device: Device, pAllocator: ^AllocationCallbacks, pDeferredOperation: ^DeferredOperationKHR) -> Result -ProcCreateDescriptorPool :: #type proc "system" (device: Device, pCreateInfo: ^DescriptorPoolCreateInfo, pAllocator: ^AllocationCallbacks, pDescriptorPool: ^DescriptorPool) -> Result -ProcCreateDescriptorSetLayout :: #type proc "system" (device: Device, pCreateInfo: ^DescriptorSetLayoutCreateInfo, pAllocator: ^AllocationCallbacks, pSetLayout: ^DescriptorSetLayout) -> Result -ProcCreateDescriptorUpdateTemplate :: #type proc "system" (device: Device, pCreateInfo: ^DescriptorUpdateTemplateCreateInfo, pAllocator: ^AllocationCallbacks, pDescriptorUpdateTemplate: ^DescriptorUpdateTemplate) -> Result -ProcCreateDescriptorUpdateTemplateKHR :: #type proc "system" (device: Device, pCreateInfo: ^DescriptorUpdateTemplateCreateInfo, pAllocator: ^AllocationCallbacks, pDescriptorUpdateTemplate: ^DescriptorUpdateTemplate) -> Result -ProcCreateEvent :: #type proc "system" (device: Device, pCreateInfo: ^EventCreateInfo, pAllocator: ^AllocationCallbacks, pEvent: ^Event) -> Result -ProcCreateFence :: #type proc "system" (device: Device, pCreateInfo: ^FenceCreateInfo, pAllocator: ^AllocationCallbacks, pFence: ^Fence) -> Result -ProcCreateFramebuffer :: #type proc "system" (device: Device, pCreateInfo: ^FramebufferCreateInfo, pAllocator: ^AllocationCallbacks, pFramebuffer: ^Framebuffer) -> Result -ProcCreateGraphicsPipelines :: #type proc "system" (device: Device, pipelineCache: PipelineCache, createInfoCount: u32, pCreateInfos: [^]GraphicsPipelineCreateInfo, pAllocator: ^AllocationCallbacks, pPipelines: [^]Pipeline) -> Result -ProcCreateImage :: #type proc "system" (device: Device, pCreateInfo: ^ImageCreateInfo, pAllocator: ^AllocationCallbacks, pImage: ^Image) -> Result -ProcCreateImageView :: #type proc "system" (device: Device, pCreateInfo: ^ImageViewCreateInfo, pAllocator: ^AllocationCallbacks, pView: ^ImageView) -> Result -ProcCreateIndirectCommandsLayoutNV :: #type proc "system" (device: Device, pCreateInfo: ^IndirectCommandsLayoutCreateInfoNV, pAllocator: ^AllocationCallbacks, pIndirectCommandsLayout: ^IndirectCommandsLayoutNV) -> Result -ProcCreatePipelineCache :: #type proc "system" (device: Device, pCreateInfo: ^PipelineCacheCreateInfo, pAllocator: ^AllocationCallbacks, pPipelineCache: ^PipelineCache) -> Result -ProcCreatePipelineLayout :: #type proc "system" (device: Device, pCreateInfo: ^PipelineLayoutCreateInfo, pAllocator: ^AllocationCallbacks, pPipelineLayout: ^PipelineLayout) -> Result -ProcCreatePrivateDataSlot :: #type proc "system" (device: Device, pCreateInfo: ^PrivateDataSlotCreateInfo, pAllocator: ^AllocationCallbacks, pPrivateDataSlot: ^PrivateDataSlot) -> Result -ProcCreatePrivateDataSlotEXT :: #type proc "system" (device: Device, pCreateInfo: ^PrivateDataSlotCreateInfo, pAllocator: ^AllocationCallbacks, pPrivateDataSlot: ^PrivateDataSlot) -> Result -ProcCreateQueryPool :: #type proc "system" (device: Device, pCreateInfo: ^QueryPoolCreateInfo, pAllocator: ^AllocationCallbacks, pQueryPool: ^QueryPool) -> Result -ProcCreateRayTracingPipelinesKHR :: #type proc "system" (device: Device, deferredOperation: DeferredOperationKHR, pipelineCache: PipelineCache, createInfoCount: u32, pCreateInfos: [^]RayTracingPipelineCreateInfoKHR, pAllocator: ^AllocationCallbacks, pPipelines: [^]Pipeline) -> Result -ProcCreateRayTracingPipelinesNV :: #type proc "system" (device: Device, pipelineCache: PipelineCache, createInfoCount: u32, pCreateInfos: [^]RayTracingPipelineCreateInfoNV, pAllocator: ^AllocationCallbacks, pPipelines: [^]Pipeline) -> Result -ProcCreateRenderPass :: #type proc "system" (device: Device, pCreateInfo: ^RenderPassCreateInfo, pAllocator: ^AllocationCallbacks, pRenderPass: [^]RenderPass) -> Result -ProcCreateRenderPass2 :: #type proc "system" (device: Device, pCreateInfo: ^RenderPassCreateInfo2, pAllocator: ^AllocationCallbacks, pRenderPass: [^]RenderPass) -> Result -ProcCreateRenderPass2KHR :: #type proc "system" (device: Device, pCreateInfo: ^RenderPassCreateInfo2, pAllocator: ^AllocationCallbacks, pRenderPass: [^]RenderPass) -> Result -ProcCreateSampler :: #type proc "system" (device: Device, pCreateInfo: ^SamplerCreateInfo, pAllocator: ^AllocationCallbacks, pSampler: ^Sampler) -> Result -ProcCreateSamplerYcbcrConversion :: #type proc "system" (device: Device, pCreateInfo: ^SamplerYcbcrConversionCreateInfo, pAllocator: ^AllocationCallbacks, pYcbcrConversion: ^SamplerYcbcrConversion) -> Result -ProcCreateSamplerYcbcrConversionKHR :: #type proc "system" (device: Device, pCreateInfo: ^SamplerYcbcrConversionCreateInfo, pAllocator: ^AllocationCallbacks, pYcbcrConversion: ^SamplerYcbcrConversion) -> Result -ProcCreateSemaphore :: #type proc "system" (device: Device, pCreateInfo: ^SemaphoreCreateInfo, pAllocator: ^AllocationCallbacks, pSemaphore: ^Semaphore) -> Result -ProcCreateShaderModule :: #type proc "system" (device: Device, pCreateInfo: ^ShaderModuleCreateInfo, pAllocator: ^AllocationCallbacks, pShaderModule: ^ShaderModule) -> Result -ProcCreateSharedSwapchainsKHR :: #type proc "system" (device: Device, swapchainCount: u32, pCreateInfos: [^]SwapchainCreateInfoKHR, pAllocator: ^AllocationCallbacks, pSwapchains: [^]SwapchainKHR) -> Result -ProcCreateSwapchainKHR :: #type proc "system" (device: Device, pCreateInfo: ^SwapchainCreateInfoKHR, pAllocator: ^AllocationCallbacks, pSwapchain: ^SwapchainKHR) -> Result -ProcCreateValidationCacheEXT :: #type proc "system" (device: Device, pCreateInfo: ^ValidationCacheCreateInfoEXT, pAllocator: ^AllocationCallbacks, pValidationCache: ^ValidationCacheEXT) -> Result -ProcDebugMarkerSetObjectNameEXT :: #type proc "system" (device: Device, pNameInfo: ^DebugMarkerObjectNameInfoEXT) -> Result -ProcDebugMarkerSetObjectTagEXT :: #type proc "system" (device: Device, pTagInfo: ^DebugMarkerObjectTagInfoEXT) -> Result -ProcDeferredOperationJoinKHR :: #type proc "system" (device: Device, operation: DeferredOperationKHR) -> Result -ProcDestroyAccelerationStructureKHR :: #type proc "system" (device: Device, accelerationStructure: AccelerationStructureKHR, pAllocator: ^AllocationCallbacks) -ProcDestroyAccelerationStructureNV :: #type proc "system" (device: Device, accelerationStructure: AccelerationStructureNV, pAllocator: ^AllocationCallbacks) -ProcDestroyBuffer :: #type proc "system" (device: Device, buffer: Buffer, pAllocator: ^AllocationCallbacks) -ProcDestroyBufferView :: #type proc "system" (device: Device, bufferView: BufferView, pAllocator: ^AllocationCallbacks) -ProcDestroyCommandPool :: #type proc "system" (device: Device, commandPool: CommandPool, pAllocator: ^AllocationCallbacks) -ProcDestroyCuFunctionNVX :: #type proc "system" (device: Device, function: CuFunctionNVX, pAllocator: ^AllocationCallbacks) -ProcDestroyCuModuleNVX :: #type proc "system" (device: Device, module: CuModuleNVX, pAllocator: ^AllocationCallbacks) -ProcDestroyDeferredOperationKHR :: #type proc "system" (device: Device, operation: DeferredOperationKHR, pAllocator: ^AllocationCallbacks) -ProcDestroyDescriptorPool :: #type proc "system" (device: Device, descriptorPool: DescriptorPool, pAllocator: ^AllocationCallbacks) -ProcDestroyDescriptorSetLayout :: #type proc "system" (device: Device, descriptorSetLayout: DescriptorSetLayout, pAllocator: ^AllocationCallbacks) -ProcDestroyDescriptorUpdateTemplate :: #type proc "system" (device: Device, descriptorUpdateTemplate: DescriptorUpdateTemplate, pAllocator: ^AllocationCallbacks) -ProcDestroyDescriptorUpdateTemplateKHR :: #type proc "system" (device: Device, descriptorUpdateTemplate: DescriptorUpdateTemplate, pAllocator: ^AllocationCallbacks) -ProcDestroyDevice :: #type proc "system" (device: Device, pAllocator: ^AllocationCallbacks) -ProcDestroyEvent :: #type proc "system" (device: Device, event: Event, pAllocator: ^AllocationCallbacks) -ProcDestroyFence :: #type proc "system" (device: Device, fence: Fence, pAllocator: ^AllocationCallbacks) -ProcDestroyFramebuffer :: #type proc "system" (device: Device, framebuffer: Framebuffer, pAllocator: ^AllocationCallbacks) -ProcDestroyImage :: #type proc "system" (device: Device, image: Image, pAllocator: ^AllocationCallbacks) -ProcDestroyImageView :: #type proc "system" (device: Device, imageView: ImageView, pAllocator: ^AllocationCallbacks) -ProcDestroyIndirectCommandsLayoutNV :: #type proc "system" (device: Device, indirectCommandsLayout: IndirectCommandsLayoutNV, pAllocator: ^AllocationCallbacks) -ProcDestroyPipeline :: #type proc "system" (device: Device, pipeline: Pipeline, pAllocator: ^AllocationCallbacks) -ProcDestroyPipelineCache :: #type proc "system" (device: Device, pipelineCache: PipelineCache, pAllocator: ^AllocationCallbacks) -ProcDestroyPipelineLayout :: #type proc "system" (device: Device, pipelineLayout: PipelineLayout, pAllocator: ^AllocationCallbacks) -ProcDestroyPrivateDataSlot :: #type proc "system" (device: Device, privateDataSlot: PrivateDataSlot, pAllocator: ^AllocationCallbacks) -ProcDestroyPrivateDataSlotEXT :: #type proc "system" (device: Device, privateDataSlot: PrivateDataSlot, pAllocator: ^AllocationCallbacks) -ProcDestroyQueryPool :: #type proc "system" (device: Device, queryPool: QueryPool, pAllocator: ^AllocationCallbacks) -ProcDestroyRenderPass :: #type proc "system" (device: Device, renderPass: RenderPass, pAllocator: ^AllocationCallbacks) -ProcDestroySampler :: #type proc "system" (device: Device, sampler: Sampler, pAllocator: ^AllocationCallbacks) -ProcDestroySamplerYcbcrConversion :: #type proc "system" (device: Device, ycbcrConversion: SamplerYcbcrConversion, pAllocator: ^AllocationCallbacks) -ProcDestroySamplerYcbcrConversionKHR :: #type proc "system" (device: Device, ycbcrConversion: SamplerYcbcrConversion, pAllocator: ^AllocationCallbacks) -ProcDestroySemaphore :: #type proc "system" (device: Device, semaphore: Semaphore, pAllocator: ^AllocationCallbacks) -ProcDestroyShaderModule :: #type proc "system" (device: Device, shaderModule: ShaderModule, pAllocator: ^AllocationCallbacks) -ProcDestroySwapchainKHR :: #type proc "system" (device: Device, swapchain: SwapchainKHR, pAllocator: ^AllocationCallbacks) -ProcDestroyValidationCacheEXT :: #type proc "system" (device: Device, validationCache: ValidationCacheEXT, pAllocator: ^AllocationCallbacks) -ProcDeviceWaitIdle :: #type proc "system" (device: Device) -> Result -ProcDisplayPowerControlEXT :: #type proc "system" (device: Device, display: DisplayKHR, pDisplayPowerInfo: ^DisplayPowerInfoEXT) -> Result -ProcEndCommandBuffer :: #type proc "system" (commandBuffer: CommandBuffer) -> Result -ProcFlushMappedMemoryRanges :: #type proc "system" (device: Device, memoryRangeCount: u32, pMemoryRanges: [^]MappedMemoryRange) -> Result -ProcFreeCommandBuffers :: #type proc "system" (device: Device, commandPool: CommandPool, commandBufferCount: u32, pCommandBuffers: [^]CommandBuffer) -ProcFreeDescriptorSets :: #type proc "system" (device: Device, descriptorPool: DescriptorPool, descriptorSetCount: u32, pDescriptorSets: [^]DescriptorSet) -> Result -ProcFreeMemory :: #type proc "system" (device: Device, memory: DeviceMemory, pAllocator: ^AllocationCallbacks) -ProcGetAccelerationStructureBuildSizesKHR :: #type proc "system" (device: Device, buildType: AccelerationStructureBuildTypeKHR, pBuildInfo: ^AccelerationStructureBuildGeometryInfoKHR, pMaxPrimitiveCounts: [^]u32, pSizeInfo: ^AccelerationStructureBuildSizesInfoKHR) -ProcGetAccelerationStructureDeviceAddressKHR :: #type proc "system" (device: Device, pInfo: ^AccelerationStructureDeviceAddressInfoKHR) -> DeviceAddress -ProcGetAccelerationStructureHandleNV :: #type proc "system" (device: Device, accelerationStructure: AccelerationStructureNV, dataSize: int, pData: rawptr) -> Result -ProcGetAccelerationStructureMemoryRequirementsNV :: #type proc "system" (device: Device, pInfo: ^AccelerationStructureMemoryRequirementsInfoNV, pMemoryRequirements: [^]MemoryRequirements2KHR) -ProcGetBufferDeviceAddress :: #type proc "system" (device: Device, pInfo: ^BufferDeviceAddressInfo) -> DeviceAddress -ProcGetBufferDeviceAddressEXT :: #type proc "system" (device: Device, pInfo: ^BufferDeviceAddressInfo) -> DeviceAddress -ProcGetBufferDeviceAddressKHR :: #type proc "system" (device: Device, pInfo: ^BufferDeviceAddressInfo) -> DeviceAddress -ProcGetBufferMemoryRequirements :: #type proc "system" (device: Device, buffer: Buffer, pMemoryRequirements: [^]MemoryRequirements) -ProcGetBufferMemoryRequirements2 :: #type proc "system" (device: Device, pInfo: ^BufferMemoryRequirementsInfo2, pMemoryRequirements: [^]MemoryRequirements2) -ProcGetBufferMemoryRequirements2KHR :: #type proc "system" (device: Device, pInfo: ^BufferMemoryRequirementsInfo2, pMemoryRequirements: [^]MemoryRequirements2) -ProcGetBufferOpaqueCaptureAddress :: #type proc "system" (device: Device, pInfo: ^BufferDeviceAddressInfo) -> u64 -ProcGetBufferOpaqueCaptureAddressKHR :: #type proc "system" (device: Device, pInfo: ^BufferDeviceAddressInfo) -> u64 -ProcGetCalibratedTimestampsEXT :: #type proc "system" (device: Device, timestampCount: u32, pTimestampInfos: [^]CalibratedTimestampInfoEXT, pTimestamps: [^]u64, pMaxDeviation: ^u64) -> Result -ProcGetDeferredOperationMaxConcurrencyKHR :: #type proc "system" (device: Device, operation: DeferredOperationKHR) -> u32 -ProcGetDeferredOperationResultKHR :: #type proc "system" (device: Device, operation: DeferredOperationKHR) -> Result -ProcGetDescriptorSetHostMappingVALVE :: #type proc "system" (device: Device, descriptorSet: DescriptorSet, ppData: ^rawptr) -ProcGetDescriptorSetLayoutHostMappingInfoVALVE :: #type proc "system" (device: Device, pBindingReference: ^DescriptorSetBindingReferenceVALVE, pHostMapping: ^DescriptorSetLayoutHostMappingInfoVALVE) -ProcGetDescriptorSetLayoutSupport :: #type proc "system" (device: Device, pCreateInfo: ^DescriptorSetLayoutCreateInfo, pSupport: ^DescriptorSetLayoutSupport) -ProcGetDescriptorSetLayoutSupportKHR :: #type proc "system" (device: Device, pCreateInfo: ^DescriptorSetLayoutCreateInfo, pSupport: ^DescriptorSetLayoutSupport) -ProcGetDeviceAccelerationStructureCompatibilityKHR :: #type proc "system" (device: Device, pVersionInfo: ^AccelerationStructureVersionInfoKHR, pCompatibility: ^AccelerationStructureCompatibilityKHR) -ProcGetDeviceBufferMemoryRequirements :: #type proc "system" (device: Device, pInfo: ^DeviceBufferMemoryRequirements, pMemoryRequirements: [^]MemoryRequirements2) -ProcGetDeviceBufferMemoryRequirementsKHR :: #type proc "system" (device: Device, pInfo: ^DeviceBufferMemoryRequirements, pMemoryRequirements: [^]MemoryRequirements2) -ProcGetDeviceGroupPeerMemoryFeatures :: #type proc "system" (device: Device, heapIndex: u32, localDeviceIndex: u32, remoteDeviceIndex: u32, pPeerMemoryFeatures: [^]PeerMemoryFeatureFlags) -ProcGetDeviceGroupPeerMemoryFeaturesKHR :: #type proc "system" (device: Device, heapIndex: u32, localDeviceIndex: u32, remoteDeviceIndex: u32, pPeerMemoryFeatures: [^]PeerMemoryFeatureFlags) -ProcGetDeviceGroupPresentCapabilitiesKHR :: #type proc "system" (device: Device, pDeviceGroupPresentCapabilities: [^]DeviceGroupPresentCapabilitiesKHR) -> Result -ProcGetDeviceGroupSurfacePresentModes2EXT :: #type proc "system" (device: Device, pSurfaceInfo: ^PhysicalDeviceSurfaceInfo2KHR, pModes: [^]DeviceGroupPresentModeFlagsKHR) -> Result -ProcGetDeviceGroupSurfacePresentModesKHR :: #type proc "system" (device: Device, surface: SurfaceKHR, pModes: [^]DeviceGroupPresentModeFlagsKHR) -> Result -ProcGetDeviceImageMemoryRequirements :: #type proc "system" (device: Device, pInfo: ^DeviceImageMemoryRequirements, pMemoryRequirements: [^]MemoryRequirements2) -ProcGetDeviceImageMemoryRequirementsKHR :: #type proc "system" (device: Device, pInfo: ^DeviceImageMemoryRequirements, pMemoryRequirements: [^]MemoryRequirements2) -ProcGetDeviceImageSparseMemoryRequirements :: #type proc "system" (device: Device, pInfo: ^DeviceImageMemoryRequirements, pSparseMemoryRequirementCount: ^u32, pSparseMemoryRequirements: [^]SparseImageMemoryRequirements2) -ProcGetDeviceImageSparseMemoryRequirementsKHR :: #type proc "system" (device: Device, pInfo: ^DeviceImageMemoryRequirements, pSparseMemoryRequirementCount: ^u32, pSparseMemoryRequirements: [^]SparseImageMemoryRequirements2) -ProcGetDeviceMemoryCommitment :: #type proc "system" (device: Device, memory: DeviceMemory, pCommittedMemoryInBytes: [^]DeviceSize) -ProcGetDeviceMemoryOpaqueCaptureAddress :: #type proc "system" (device: Device, pInfo: ^DeviceMemoryOpaqueCaptureAddressInfo) -> u64 -ProcGetDeviceMemoryOpaqueCaptureAddressKHR :: #type proc "system" (device: Device, pInfo: ^DeviceMemoryOpaqueCaptureAddressInfo) -> u64 -ProcGetDeviceProcAddr :: #type proc "system" (device: Device, pName: cstring) -> ProcVoidFunction -ProcGetDeviceQueue :: #type proc "system" (device: Device, queueFamilyIndex: u32, queueIndex: u32, pQueue: ^Queue) -ProcGetDeviceQueue2 :: #type proc "system" (device: Device, pQueueInfo: ^DeviceQueueInfo2, pQueue: ^Queue) -ProcGetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI :: #type proc "system" (device: Device, renderpass: RenderPass, pMaxWorkgroupSize: ^Extent2D) -> Result -ProcGetEventStatus :: #type proc "system" (device: Device, event: Event) -> Result -ProcGetFenceFdKHR :: #type proc "system" (device: Device, pGetFdInfo: ^FenceGetFdInfoKHR, pFd: ^c.int) -> Result -ProcGetFenceStatus :: #type proc "system" (device: Device, fence: Fence) -> Result -ProcGetFenceWin32HandleKHR :: #type proc "system" (device: Device, pGetWin32HandleInfo: ^FenceGetWin32HandleInfoKHR, pHandle: ^HANDLE) -> Result -ProcGetGeneratedCommandsMemoryRequirementsNV :: #type proc "system" (device: Device, pInfo: ^GeneratedCommandsMemoryRequirementsInfoNV, pMemoryRequirements: [^]MemoryRequirements2) -ProcGetImageDrmFormatModifierPropertiesEXT :: #type proc "system" (device: Device, image: Image, pProperties: [^]ImageDrmFormatModifierPropertiesEXT) -> Result -ProcGetImageMemoryRequirements :: #type proc "system" (device: Device, image: Image, pMemoryRequirements: [^]MemoryRequirements) -ProcGetImageMemoryRequirements2 :: #type proc "system" (device: Device, pInfo: ^ImageMemoryRequirementsInfo2, pMemoryRequirements: [^]MemoryRequirements2) -ProcGetImageMemoryRequirements2KHR :: #type proc "system" (device: Device, pInfo: ^ImageMemoryRequirementsInfo2, pMemoryRequirements: [^]MemoryRequirements2) -ProcGetImageSparseMemoryRequirements :: #type proc "system" (device: Device, image: Image, pSparseMemoryRequirementCount: ^u32, pSparseMemoryRequirements: [^]SparseImageMemoryRequirements) -ProcGetImageSparseMemoryRequirements2 :: #type proc "system" (device: Device, pInfo: ^ImageSparseMemoryRequirementsInfo2, pSparseMemoryRequirementCount: ^u32, pSparseMemoryRequirements: [^]SparseImageMemoryRequirements2) -ProcGetImageSparseMemoryRequirements2KHR :: #type proc "system" (device: Device, pInfo: ^ImageSparseMemoryRequirementsInfo2, pSparseMemoryRequirementCount: ^u32, pSparseMemoryRequirements: [^]SparseImageMemoryRequirements2) -ProcGetImageSubresourceLayout :: #type proc "system" (device: Device, image: Image, pSubresource: ^ImageSubresource, pLayout: ^SubresourceLayout) -ProcGetImageViewAddressNVX :: #type proc "system" (device: Device, imageView: ImageView, pProperties: [^]ImageViewAddressPropertiesNVX) -> Result -ProcGetImageViewHandleNVX :: #type proc "system" (device: Device, pInfo: ^ImageViewHandleInfoNVX) -> u32 -ProcGetMemoryFdKHR :: #type proc "system" (device: Device, pGetFdInfo: ^MemoryGetFdInfoKHR, pFd: ^c.int) -> Result -ProcGetMemoryFdPropertiesKHR :: #type proc "system" (device: Device, handleType: ExternalMemoryHandleTypeFlags, fd: c.int, pMemoryFdProperties: [^]MemoryFdPropertiesKHR) -> Result -ProcGetMemoryHostPointerPropertiesEXT :: #type proc "system" (device: Device, handleType: ExternalMemoryHandleTypeFlags, pHostPointer: rawptr, pMemoryHostPointerProperties: [^]MemoryHostPointerPropertiesEXT) -> Result -ProcGetMemoryRemoteAddressNV :: #type proc "system" (device: Device, pMemoryGetRemoteAddressInfo: ^MemoryGetRemoteAddressInfoNV, pAddress: [^]RemoteAddressNV) -> Result -ProcGetMemoryWin32HandleKHR :: #type proc "system" (device: Device, pGetWin32HandleInfo: ^MemoryGetWin32HandleInfoKHR, pHandle: ^HANDLE) -> Result -ProcGetMemoryWin32HandleNV :: #type proc "system" (device: Device, memory: DeviceMemory, handleType: ExternalMemoryHandleTypeFlagsNV, pHandle: ^HANDLE) -> Result -ProcGetMemoryWin32HandlePropertiesKHR :: #type proc "system" (device: Device, handleType: ExternalMemoryHandleTypeFlags, handle: HANDLE, pMemoryWin32HandleProperties: [^]MemoryWin32HandlePropertiesKHR) -> Result -ProcGetPastPresentationTimingGOOGLE :: #type proc "system" (device: Device, swapchain: SwapchainKHR, pPresentationTimingCount: ^u32, pPresentationTimings: [^]PastPresentationTimingGOOGLE) -> Result -ProcGetPerformanceParameterINTEL :: #type proc "system" (device: Device, parameter: PerformanceParameterTypeINTEL, pValue: ^PerformanceValueINTEL) -> Result -ProcGetPipelineCacheData :: #type proc "system" (device: Device, pipelineCache: PipelineCache, pDataSize: ^int, pData: rawptr) -> Result -ProcGetPipelineExecutableInternalRepresentationsKHR :: #type proc "system" (device: Device, pExecutableInfo: ^PipelineExecutableInfoKHR, pInternalRepresentationCount: ^u32, pInternalRepresentations: [^]PipelineExecutableInternalRepresentationKHR) -> Result -ProcGetPipelineExecutablePropertiesKHR :: #type proc "system" (device: Device, pPipelineInfo: ^PipelineInfoKHR, pExecutableCount: ^u32, pProperties: [^]PipelineExecutablePropertiesKHR) -> Result -ProcGetPipelineExecutableStatisticsKHR :: #type proc "system" (device: Device, pExecutableInfo: ^PipelineExecutableInfoKHR, pStatisticCount: ^u32, pStatistics: [^]PipelineExecutableStatisticKHR) -> Result -ProcGetPrivateData :: #type proc "system" (device: Device, objectType: ObjectType, objectHandle: u64, privateDataSlot: PrivateDataSlot, pData: ^u64) -ProcGetPrivateDataEXT :: #type proc "system" (device: Device, objectType: ObjectType, objectHandle: u64, privateDataSlot: PrivateDataSlot, pData: ^u64) -ProcGetQueryPoolResults :: #type proc "system" (device: Device, queryPool: QueryPool, firstQuery: u32, queryCount: u32, dataSize: int, pData: rawptr, stride: DeviceSize, flags: QueryResultFlags) -> Result -ProcGetQueueCheckpointData2NV :: #type proc "system" (queue: Queue, pCheckpointDataCount: ^u32, pCheckpointData: ^CheckpointData2NV) -ProcGetQueueCheckpointDataNV :: #type proc "system" (queue: Queue, pCheckpointDataCount: ^u32, pCheckpointData: ^CheckpointDataNV) -ProcGetRayTracingCaptureReplayShaderGroupHandlesKHR :: #type proc "system" (device: Device, pipeline: Pipeline, firstGroup: u32, groupCount: u32, dataSize: int, pData: rawptr) -> Result -ProcGetRayTracingShaderGroupHandlesKHR :: #type proc "system" (device: Device, pipeline: Pipeline, firstGroup: u32, groupCount: u32, dataSize: int, pData: rawptr) -> Result -ProcGetRayTracingShaderGroupHandlesNV :: #type proc "system" (device: Device, pipeline: Pipeline, firstGroup: u32, groupCount: u32, dataSize: int, pData: rawptr) -> Result -ProcGetRayTracingShaderGroupStackSizeKHR :: #type proc "system" (device: Device, pipeline: Pipeline, group: u32, groupShader: ShaderGroupShaderKHR) -> DeviceSize -ProcGetRefreshCycleDurationGOOGLE :: #type proc "system" (device: Device, swapchain: SwapchainKHR, pDisplayTimingProperties: [^]RefreshCycleDurationGOOGLE) -> Result -ProcGetRenderAreaGranularity :: #type proc "system" (device: Device, renderPass: RenderPass, pGranularity: ^Extent2D) -ProcGetSemaphoreCounterValue :: #type proc "system" (device: Device, semaphore: Semaphore, pValue: ^u64) -> Result -ProcGetSemaphoreCounterValueKHR :: #type proc "system" (device: Device, semaphore: Semaphore, pValue: ^u64) -> Result -ProcGetSemaphoreFdKHR :: #type proc "system" (device: Device, pGetFdInfo: ^SemaphoreGetFdInfoKHR, pFd: ^c.int) -> Result -ProcGetSemaphoreWin32HandleKHR :: #type proc "system" (device: Device, pGetWin32HandleInfo: ^SemaphoreGetWin32HandleInfoKHR, pHandle: ^HANDLE) -> Result -ProcGetShaderInfoAMD :: #type proc "system" (device: Device, pipeline: Pipeline, shaderStage: ShaderStageFlags, infoType: ShaderInfoTypeAMD, pInfoSize: ^int, pInfo: rawptr) -> Result -ProcGetSwapchainCounterEXT :: #type proc "system" (device: Device, swapchain: SwapchainKHR, counter: SurfaceCounterFlagsEXT, pCounterValue: ^u64) -> Result -ProcGetSwapchainImagesKHR :: #type proc "system" (device: Device, swapchain: SwapchainKHR, pSwapchainImageCount: ^u32, pSwapchainImages: [^]Image) -> Result -ProcGetSwapchainStatusKHR :: #type proc "system" (device: Device, swapchain: SwapchainKHR) -> Result -ProcGetValidationCacheDataEXT :: #type proc "system" (device: Device, validationCache: ValidationCacheEXT, pDataSize: ^int, pData: rawptr) -> Result -ProcImportFenceFdKHR :: #type proc "system" (device: Device, pImportFenceFdInfo: ^ImportFenceFdInfoKHR) -> Result -ProcImportFenceWin32HandleKHR :: #type proc "system" (device: Device, pImportFenceWin32HandleInfo: ^ImportFenceWin32HandleInfoKHR) -> Result -ProcImportSemaphoreFdKHR :: #type proc "system" (device: Device, pImportSemaphoreFdInfo: ^ImportSemaphoreFdInfoKHR) -> Result -ProcImportSemaphoreWin32HandleKHR :: #type proc "system" (device: Device, pImportSemaphoreWin32HandleInfo: ^ImportSemaphoreWin32HandleInfoKHR) -> Result -ProcInitializePerformanceApiINTEL :: #type proc "system" (device: Device, pInitializeInfo: ^InitializePerformanceApiInfoINTEL) -> Result -ProcInvalidateMappedMemoryRanges :: #type proc "system" (device: Device, memoryRangeCount: u32, pMemoryRanges: [^]MappedMemoryRange) -> Result -ProcMapMemory :: #type proc "system" (device: Device, memory: DeviceMemory, offset: DeviceSize, size: DeviceSize, flags: MemoryMapFlags, ppData: ^rawptr) -> Result -ProcMergePipelineCaches :: #type proc "system" (device: Device, dstCache: PipelineCache, srcCacheCount: u32, pSrcCaches: [^]PipelineCache) -> Result -ProcMergeValidationCachesEXT :: #type proc "system" (device: Device, dstCache: ValidationCacheEXT, srcCacheCount: u32, pSrcCaches: [^]ValidationCacheEXT) -> Result -ProcQueueBeginDebugUtilsLabelEXT :: #type proc "system" (queue: Queue, pLabelInfo: ^DebugUtilsLabelEXT) -ProcQueueBindSparse :: #type proc "system" (queue: Queue, bindInfoCount: u32, pBindInfo: ^BindSparseInfo, fence: Fence) -> Result -ProcQueueEndDebugUtilsLabelEXT :: #type proc "system" (queue: Queue) -ProcQueueInsertDebugUtilsLabelEXT :: #type proc "system" (queue: Queue, pLabelInfo: ^DebugUtilsLabelEXT) -ProcQueuePresentKHR :: #type proc "system" (queue: Queue, pPresentInfo: ^PresentInfoKHR) -> Result -ProcQueueSetPerformanceConfigurationINTEL :: #type proc "system" (queue: Queue, configuration: PerformanceConfigurationINTEL) -> Result -ProcQueueSubmit :: #type proc "system" (queue: Queue, submitCount: u32, pSubmits: [^]SubmitInfo, fence: Fence) -> Result -ProcQueueSubmit2 :: #type proc "system" (queue: Queue, submitCount: u32, pSubmits: [^]SubmitInfo2, fence: Fence) -> Result -ProcQueueSubmit2KHR :: #type proc "system" (queue: Queue, submitCount: u32, pSubmits: [^]SubmitInfo2, fence: Fence) -> Result -ProcQueueWaitIdle :: #type proc "system" (queue: Queue) -> Result -ProcRegisterDeviceEventEXT :: #type proc "system" (device: Device, pDeviceEventInfo: ^DeviceEventInfoEXT, pAllocator: ^AllocationCallbacks, pFence: ^Fence) -> Result -ProcRegisterDisplayEventEXT :: #type proc "system" (device: Device, display: DisplayKHR, pDisplayEventInfo: ^DisplayEventInfoEXT, pAllocator: ^AllocationCallbacks, pFence: ^Fence) -> Result -ProcReleaseFullScreenExclusiveModeEXT :: #type proc "system" (device: Device, swapchain: SwapchainKHR) -> Result -ProcReleasePerformanceConfigurationINTEL :: #type proc "system" (device: Device, configuration: PerformanceConfigurationINTEL) -> Result -ProcReleaseProfilingLockKHR :: #type proc "system" (device: Device) -ProcResetCommandBuffer :: #type proc "system" (commandBuffer: CommandBuffer, flags: CommandBufferResetFlags) -> Result -ProcResetCommandPool :: #type proc "system" (device: Device, commandPool: CommandPool, flags: CommandPoolResetFlags) -> Result -ProcResetDescriptorPool :: #type proc "system" (device: Device, descriptorPool: DescriptorPool, flags: DescriptorPoolResetFlags) -> Result -ProcResetEvent :: #type proc "system" (device: Device, event: Event) -> Result -ProcResetFences :: #type proc "system" (device: Device, fenceCount: u32, pFences: [^]Fence) -> Result -ProcResetQueryPool :: #type proc "system" (device: Device, queryPool: QueryPool, firstQuery: u32, queryCount: u32) -ProcResetQueryPoolEXT :: #type proc "system" (device: Device, queryPool: QueryPool, firstQuery: u32, queryCount: u32) -ProcSetDebugUtilsObjectNameEXT :: #type proc "system" (device: Device, pNameInfo: ^DebugUtilsObjectNameInfoEXT) -> Result -ProcSetDebugUtilsObjectTagEXT :: #type proc "system" (device: Device, pTagInfo: ^DebugUtilsObjectTagInfoEXT) -> Result -ProcSetDeviceMemoryPriorityEXT :: #type proc "system" (device: Device, memory: DeviceMemory, priority: f32) -ProcSetEvent :: #type proc "system" (device: Device, event: Event) -> Result -ProcSetHdrMetadataEXT :: #type proc "system" (device: Device, swapchainCount: u32, pSwapchains: [^]SwapchainKHR, pMetadata: ^HdrMetadataEXT) -ProcSetLocalDimmingAMD :: #type proc "system" (device: Device, swapChain: SwapchainKHR, localDimmingEnable: b32) -ProcSetPrivateData :: #type proc "system" (device: Device, objectType: ObjectType, objectHandle: u64, privateDataSlot: PrivateDataSlot, data: u64) -> Result -ProcSetPrivateDataEXT :: #type proc "system" (device: Device, objectType: ObjectType, objectHandle: u64, privateDataSlot: PrivateDataSlot, data: u64) -> Result -ProcSignalSemaphore :: #type proc "system" (device: Device, pSignalInfo: ^SemaphoreSignalInfo) -> Result -ProcSignalSemaphoreKHR :: #type proc "system" (device: Device, pSignalInfo: ^SemaphoreSignalInfo) -> Result -ProcTrimCommandPool :: #type proc "system" (device: Device, commandPool: CommandPool, flags: CommandPoolTrimFlags) -ProcTrimCommandPoolKHR :: #type proc "system" (device: Device, commandPool: CommandPool, flags: CommandPoolTrimFlags) -ProcUninitializePerformanceApiINTEL :: #type proc "system" (device: Device) -ProcUnmapMemory :: #type proc "system" (device: Device, memory: DeviceMemory) -ProcUpdateDescriptorSetWithTemplate :: #type proc "system" (device: Device, descriptorSet: DescriptorSet, descriptorUpdateTemplate: DescriptorUpdateTemplate, pData: rawptr) -ProcUpdateDescriptorSetWithTemplateKHR :: #type proc "system" (device: Device, descriptorSet: DescriptorSet, descriptorUpdateTemplate: DescriptorUpdateTemplate, pData: rawptr) -ProcUpdateDescriptorSets :: #type proc "system" (device: Device, descriptorWriteCount: u32, pDescriptorWrites: [^]WriteDescriptorSet, descriptorCopyCount: u32, pDescriptorCopies: [^]CopyDescriptorSet) -ProcWaitForFences :: #type proc "system" (device: Device, fenceCount: u32, pFences: [^]Fence, waitAll: b32, timeout: u64) -> Result -ProcWaitForPresentKHR :: #type proc "system" (device: Device, swapchain: SwapchainKHR, presentId: u64, timeout: u64) -> Result -ProcWaitSemaphores :: #type proc "system" (device: Device, pWaitInfo: ^SemaphoreWaitInfo, timeout: u64) -> Result -ProcWaitSemaphoresKHR :: #type proc "system" (device: Device, pWaitInfo: ^SemaphoreWaitInfo, timeout: u64) -> Result -ProcWriteAccelerationStructuresPropertiesKHR :: #type proc "system" (device: Device, accelerationStructureCount: u32, pAccelerationStructures: [^]AccelerationStructureKHR, queryType: QueryType, dataSize: int, pData: rawptr, stride: int) -> Result - - -// Loader Procedures -CreateInstance: ProcCreateInstance -DebugUtilsMessengerCallbackEXT: ProcDebugUtilsMessengerCallbackEXT -DeviceMemoryReportCallbackEXT: ProcDeviceMemoryReportCallbackEXT -EnumerateInstanceExtensionProperties: ProcEnumerateInstanceExtensionProperties -EnumerateInstanceLayerProperties: ProcEnumerateInstanceLayerProperties -EnumerateInstanceVersion: ProcEnumerateInstanceVersion -GetInstanceProcAddr: ProcGetInstanceProcAddr - -// Instance Procedures -AcquireDrmDisplayEXT: ProcAcquireDrmDisplayEXT -AcquireWinrtDisplayNV: ProcAcquireWinrtDisplayNV -CreateDebugReportCallbackEXT: ProcCreateDebugReportCallbackEXT -CreateDebugUtilsMessengerEXT: ProcCreateDebugUtilsMessengerEXT -CreateDevice: ProcCreateDevice -CreateDisplayModeKHR: ProcCreateDisplayModeKHR -CreateDisplayPlaneSurfaceKHR: ProcCreateDisplayPlaneSurfaceKHR -CreateHeadlessSurfaceEXT: ProcCreateHeadlessSurfaceEXT -CreateIOSSurfaceMVK: ProcCreateIOSSurfaceMVK -CreateMacOSSurfaceMVK: ProcCreateMacOSSurfaceMVK -CreateMetalSurfaceEXT: ProcCreateMetalSurfaceEXT -CreateWin32SurfaceKHR: ProcCreateWin32SurfaceKHR -DebugReportMessageEXT: ProcDebugReportMessageEXT -DestroyDebugReportCallbackEXT: ProcDestroyDebugReportCallbackEXT -DestroyDebugUtilsMessengerEXT: ProcDestroyDebugUtilsMessengerEXT -DestroyInstance: ProcDestroyInstance -DestroySurfaceKHR: ProcDestroySurfaceKHR -EnumerateDeviceExtensionProperties: ProcEnumerateDeviceExtensionProperties -EnumerateDeviceLayerProperties: ProcEnumerateDeviceLayerProperties -EnumeratePhysicalDeviceGroups: ProcEnumeratePhysicalDeviceGroups -EnumeratePhysicalDeviceGroupsKHR: ProcEnumeratePhysicalDeviceGroupsKHR -EnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR: ProcEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR -EnumeratePhysicalDevices: ProcEnumeratePhysicalDevices -GetDisplayModeProperties2KHR: ProcGetDisplayModeProperties2KHR -GetDisplayModePropertiesKHR: ProcGetDisplayModePropertiesKHR -GetDisplayPlaneCapabilities2KHR: ProcGetDisplayPlaneCapabilities2KHR -GetDisplayPlaneCapabilitiesKHR: ProcGetDisplayPlaneCapabilitiesKHR -GetDisplayPlaneSupportedDisplaysKHR: ProcGetDisplayPlaneSupportedDisplaysKHR -GetDrmDisplayEXT: ProcGetDrmDisplayEXT -GetPhysicalDeviceCalibrateableTimeDomainsEXT: ProcGetPhysicalDeviceCalibrateableTimeDomainsEXT -GetPhysicalDeviceCooperativeMatrixPropertiesNV: ProcGetPhysicalDeviceCooperativeMatrixPropertiesNV -GetPhysicalDeviceDisplayPlaneProperties2KHR: ProcGetPhysicalDeviceDisplayPlaneProperties2KHR -GetPhysicalDeviceDisplayPlanePropertiesKHR: ProcGetPhysicalDeviceDisplayPlanePropertiesKHR -GetPhysicalDeviceDisplayProperties2KHR: ProcGetPhysicalDeviceDisplayProperties2KHR -GetPhysicalDeviceDisplayPropertiesKHR: ProcGetPhysicalDeviceDisplayPropertiesKHR -GetPhysicalDeviceExternalBufferProperties: ProcGetPhysicalDeviceExternalBufferProperties -GetPhysicalDeviceExternalBufferPropertiesKHR: ProcGetPhysicalDeviceExternalBufferPropertiesKHR -GetPhysicalDeviceExternalFenceProperties: ProcGetPhysicalDeviceExternalFenceProperties -GetPhysicalDeviceExternalFencePropertiesKHR: ProcGetPhysicalDeviceExternalFencePropertiesKHR -GetPhysicalDeviceExternalImageFormatPropertiesNV: ProcGetPhysicalDeviceExternalImageFormatPropertiesNV -GetPhysicalDeviceExternalSemaphoreProperties: ProcGetPhysicalDeviceExternalSemaphoreProperties -GetPhysicalDeviceExternalSemaphorePropertiesKHR: ProcGetPhysicalDeviceExternalSemaphorePropertiesKHR -GetPhysicalDeviceFeatures: ProcGetPhysicalDeviceFeatures -GetPhysicalDeviceFeatures2: ProcGetPhysicalDeviceFeatures2 -GetPhysicalDeviceFeatures2KHR: ProcGetPhysicalDeviceFeatures2KHR -GetPhysicalDeviceFormatProperties: ProcGetPhysicalDeviceFormatProperties -GetPhysicalDeviceFormatProperties2: ProcGetPhysicalDeviceFormatProperties2 -GetPhysicalDeviceFormatProperties2KHR: ProcGetPhysicalDeviceFormatProperties2KHR -GetPhysicalDeviceFragmentShadingRatesKHR: ProcGetPhysicalDeviceFragmentShadingRatesKHR -GetPhysicalDeviceImageFormatProperties: ProcGetPhysicalDeviceImageFormatProperties -GetPhysicalDeviceImageFormatProperties2: ProcGetPhysicalDeviceImageFormatProperties2 -GetPhysicalDeviceImageFormatProperties2KHR: ProcGetPhysicalDeviceImageFormatProperties2KHR -GetPhysicalDeviceMemoryProperties: ProcGetPhysicalDeviceMemoryProperties -GetPhysicalDeviceMemoryProperties2: ProcGetPhysicalDeviceMemoryProperties2 -GetPhysicalDeviceMemoryProperties2KHR: ProcGetPhysicalDeviceMemoryProperties2KHR -GetPhysicalDeviceMultisamplePropertiesEXT: ProcGetPhysicalDeviceMultisamplePropertiesEXT -GetPhysicalDevicePresentRectanglesKHR: ProcGetPhysicalDevicePresentRectanglesKHR -GetPhysicalDeviceProperties: ProcGetPhysicalDeviceProperties -GetPhysicalDeviceProperties2: ProcGetPhysicalDeviceProperties2 -GetPhysicalDeviceProperties2KHR: ProcGetPhysicalDeviceProperties2KHR -GetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR: ProcGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR -GetPhysicalDeviceQueueFamilyProperties: ProcGetPhysicalDeviceQueueFamilyProperties -GetPhysicalDeviceQueueFamilyProperties2: ProcGetPhysicalDeviceQueueFamilyProperties2 -GetPhysicalDeviceQueueFamilyProperties2KHR: ProcGetPhysicalDeviceQueueFamilyProperties2KHR -GetPhysicalDeviceSparseImageFormatProperties: ProcGetPhysicalDeviceSparseImageFormatProperties -GetPhysicalDeviceSparseImageFormatProperties2: ProcGetPhysicalDeviceSparseImageFormatProperties2 -GetPhysicalDeviceSparseImageFormatProperties2KHR: ProcGetPhysicalDeviceSparseImageFormatProperties2KHR -GetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV: ProcGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV -GetPhysicalDeviceSurfaceCapabilities2EXT: ProcGetPhysicalDeviceSurfaceCapabilities2EXT -GetPhysicalDeviceSurfaceCapabilities2KHR: ProcGetPhysicalDeviceSurfaceCapabilities2KHR -GetPhysicalDeviceSurfaceCapabilitiesKHR: ProcGetPhysicalDeviceSurfaceCapabilitiesKHR -GetPhysicalDeviceSurfaceFormats2KHR: ProcGetPhysicalDeviceSurfaceFormats2KHR -GetPhysicalDeviceSurfaceFormatsKHR: ProcGetPhysicalDeviceSurfaceFormatsKHR -GetPhysicalDeviceSurfacePresentModes2EXT: ProcGetPhysicalDeviceSurfacePresentModes2EXT -GetPhysicalDeviceSurfacePresentModesKHR: ProcGetPhysicalDeviceSurfacePresentModesKHR -GetPhysicalDeviceSurfaceSupportKHR: ProcGetPhysicalDeviceSurfaceSupportKHR -GetPhysicalDeviceToolProperties: ProcGetPhysicalDeviceToolProperties -GetPhysicalDeviceToolPropertiesEXT: ProcGetPhysicalDeviceToolPropertiesEXT -GetPhysicalDeviceWin32PresentationSupportKHR: ProcGetPhysicalDeviceWin32PresentationSupportKHR -GetWinrtDisplayNV: ProcGetWinrtDisplayNV -ReleaseDisplayEXT: ProcReleaseDisplayEXT -SubmitDebugUtilsMessageEXT: ProcSubmitDebugUtilsMessageEXT - -// Device Procedures -AcquireFullScreenExclusiveModeEXT: ProcAcquireFullScreenExclusiveModeEXT -AcquireNextImage2KHR: ProcAcquireNextImage2KHR -AcquireNextImageKHR: ProcAcquireNextImageKHR -AcquirePerformanceConfigurationINTEL: ProcAcquirePerformanceConfigurationINTEL -AcquireProfilingLockKHR: ProcAcquireProfilingLockKHR -AllocateCommandBuffers: ProcAllocateCommandBuffers -AllocateDescriptorSets: ProcAllocateDescriptorSets -AllocateMemory: ProcAllocateMemory -BeginCommandBuffer: ProcBeginCommandBuffer -BindAccelerationStructureMemoryNV: ProcBindAccelerationStructureMemoryNV -BindBufferMemory: ProcBindBufferMemory -BindBufferMemory2: ProcBindBufferMemory2 -BindBufferMemory2KHR: ProcBindBufferMemory2KHR -BindImageMemory: ProcBindImageMemory -BindImageMemory2: ProcBindImageMemory2 -BindImageMemory2KHR: ProcBindImageMemory2KHR -BuildAccelerationStructuresKHR: ProcBuildAccelerationStructuresKHR -CmdBeginConditionalRenderingEXT: ProcCmdBeginConditionalRenderingEXT -CmdBeginDebugUtilsLabelEXT: ProcCmdBeginDebugUtilsLabelEXT -CmdBeginQuery: ProcCmdBeginQuery -CmdBeginQueryIndexedEXT: ProcCmdBeginQueryIndexedEXT -CmdBeginRenderPass: ProcCmdBeginRenderPass -CmdBeginRenderPass2: ProcCmdBeginRenderPass2 -CmdBeginRenderPass2KHR: ProcCmdBeginRenderPass2KHR -CmdBeginRendering: ProcCmdBeginRendering -CmdBeginRenderingKHR: ProcCmdBeginRenderingKHR -CmdBeginTransformFeedbackEXT: ProcCmdBeginTransformFeedbackEXT -CmdBindDescriptorSets: ProcCmdBindDescriptorSets -CmdBindIndexBuffer: ProcCmdBindIndexBuffer -CmdBindInvocationMaskHUAWEI: ProcCmdBindInvocationMaskHUAWEI -CmdBindPipeline: ProcCmdBindPipeline -CmdBindPipelineShaderGroupNV: ProcCmdBindPipelineShaderGroupNV -CmdBindShadingRateImageNV: ProcCmdBindShadingRateImageNV -CmdBindTransformFeedbackBuffersEXT: ProcCmdBindTransformFeedbackBuffersEXT -CmdBindVertexBuffers: ProcCmdBindVertexBuffers -CmdBindVertexBuffers2: ProcCmdBindVertexBuffers2 -CmdBindVertexBuffers2EXT: ProcCmdBindVertexBuffers2EXT -CmdBlitImage: ProcCmdBlitImage -CmdBlitImage2: ProcCmdBlitImage2 -CmdBlitImage2KHR: ProcCmdBlitImage2KHR -CmdBuildAccelerationStructureNV: ProcCmdBuildAccelerationStructureNV -CmdBuildAccelerationStructuresIndirectKHR: ProcCmdBuildAccelerationStructuresIndirectKHR -CmdBuildAccelerationStructuresKHR: ProcCmdBuildAccelerationStructuresKHR -CmdClearAttachments: ProcCmdClearAttachments -CmdClearColorImage: ProcCmdClearColorImage -CmdClearDepthStencilImage: ProcCmdClearDepthStencilImage -CmdCopyAccelerationStructureKHR: ProcCmdCopyAccelerationStructureKHR -CmdCopyAccelerationStructureNV: ProcCmdCopyAccelerationStructureNV -CmdCopyAccelerationStructureToMemoryKHR: ProcCmdCopyAccelerationStructureToMemoryKHR -CmdCopyBuffer: ProcCmdCopyBuffer -CmdCopyBuffer2: ProcCmdCopyBuffer2 -CmdCopyBuffer2KHR: ProcCmdCopyBuffer2KHR -CmdCopyBufferToImage: ProcCmdCopyBufferToImage -CmdCopyBufferToImage2: ProcCmdCopyBufferToImage2 -CmdCopyBufferToImage2KHR: ProcCmdCopyBufferToImage2KHR -CmdCopyImage: ProcCmdCopyImage -CmdCopyImage2: ProcCmdCopyImage2 -CmdCopyImage2KHR: ProcCmdCopyImage2KHR -CmdCopyImageToBuffer: ProcCmdCopyImageToBuffer -CmdCopyImageToBuffer2: ProcCmdCopyImageToBuffer2 -CmdCopyImageToBuffer2KHR: ProcCmdCopyImageToBuffer2KHR -CmdCopyMemoryToAccelerationStructureKHR: ProcCmdCopyMemoryToAccelerationStructureKHR -CmdCopyQueryPoolResults: ProcCmdCopyQueryPoolResults -CmdCuLaunchKernelNVX: ProcCmdCuLaunchKernelNVX -CmdDebugMarkerBeginEXT: ProcCmdDebugMarkerBeginEXT -CmdDebugMarkerEndEXT: ProcCmdDebugMarkerEndEXT -CmdDebugMarkerInsertEXT: ProcCmdDebugMarkerInsertEXT -CmdDispatch: ProcCmdDispatch -CmdDispatchBase: ProcCmdDispatchBase -CmdDispatchBaseKHR: ProcCmdDispatchBaseKHR -CmdDispatchIndirect: ProcCmdDispatchIndirect -CmdDraw: ProcCmdDraw -CmdDrawIndexed: ProcCmdDrawIndexed -CmdDrawIndexedIndirect: ProcCmdDrawIndexedIndirect -CmdDrawIndexedIndirectCount: ProcCmdDrawIndexedIndirectCount -CmdDrawIndexedIndirectCountAMD: ProcCmdDrawIndexedIndirectCountAMD -CmdDrawIndexedIndirectCountKHR: ProcCmdDrawIndexedIndirectCountKHR -CmdDrawIndirect: ProcCmdDrawIndirect -CmdDrawIndirectByteCountEXT: ProcCmdDrawIndirectByteCountEXT -CmdDrawIndirectCount: ProcCmdDrawIndirectCount -CmdDrawIndirectCountAMD: ProcCmdDrawIndirectCountAMD -CmdDrawIndirectCountKHR: ProcCmdDrawIndirectCountKHR -CmdDrawMeshTasksIndirectCountNV: ProcCmdDrawMeshTasksIndirectCountNV -CmdDrawMeshTasksIndirectNV: ProcCmdDrawMeshTasksIndirectNV -CmdDrawMeshTasksNV: ProcCmdDrawMeshTasksNV -CmdDrawMultiEXT: ProcCmdDrawMultiEXT -CmdDrawMultiIndexedEXT: ProcCmdDrawMultiIndexedEXT -CmdEndConditionalRenderingEXT: ProcCmdEndConditionalRenderingEXT -CmdEndDebugUtilsLabelEXT: ProcCmdEndDebugUtilsLabelEXT -CmdEndQuery: ProcCmdEndQuery -CmdEndQueryIndexedEXT: ProcCmdEndQueryIndexedEXT -CmdEndRenderPass: ProcCmdEndRenderPass -CmdEndRenderPass2: ProcCmdEndRenderPass2 -CmdEndRenderPass2KHR: ProcCmdEndRenderPass2KHR -CmdEndRendering: ProcCmdEndRendering -CmdEndRenderingKHR: ProcCmdEndRenderingKHR -CmdEndTransformFeedbackEXT: ProcCmdEndTransformFeedbackEXT -CmdExecuteCommands: ProcCmdExecuteCommands -CmdExecuteGeneratedCommandsNV: ProcCmdExecuteGeneratedCommandsNV -CmdFillBuffer: ProcCmdFillBuffer -CmdInsertDebugUtilsLabelEXT: ProcCmdInsertDebugUtilsLabelEXT -CmdNextSubpass: ProcCmdNextSubpass -CmdNextSubpass2: ProcCmdNextSubpass2 -CmdNextSubpass2KHR: ProcCmdNextSubpass2KHR -CmdPipelineBarrier: ProcCmdPipelineBarrier -CmdPipelineBarrier2: ProcCmdPipelineBarrier2 -CmdPipelineBarrier2KHR: ProcCmdPipelineBarrier2KHR -CmdPreprocessGeneratedCommandsNV: ProcCmdPreprocessGeneratedCommandsNV -CmdPushConstants: ProcCmdPushConstants -CmdPushDescriptorSetKHR: ProcCmdPushDescriptorSetKHR -CmdPushDescriptorSetWithTemplateKHR: ProcCmdPushDescriptorSetWithTemplateKHR -CmdResetEvent: ProcCmdResetEvent -CmdResetEvent2: ProcCmdResetEvent2 -CmdResetEvent2KHR: ProcCmdResetEvent2KHR -CmdResetQueryPool: ProcCmdResetQueryPool -CmdResolveImage: ProcCmdResolveImage -CmdResolveImage2: ProcCmdResolveImage2 -CmdResolveImage2KHR: ProcCmdResolveImage2KHR -CmdSetBlendConstants: ProcCmdSetBlendConstants -CmdSetCheckpointNV: ProcCmdSetCheckpointNV -CmdSetCoarseSampleOrderNV: ProcCmdSetCoarseSampleOrderNV -CmdSetCullMode: ProcCmdSetCullMode -CmdSetCullModeEXT: ProcCmdSetCullModeEXT -CmdSetDepthBias: ProcCmdSetDepthBias -CmdSetDepthBiasEnable: ProcCmdSetDepthBiasEnable -CmdSetDepthBiasEnableEXT: ProcCmdSetDepthBiasEnableEXT -CmdSetDepthBounds: ProcCmdSetDepthBounds -CmdSetDepthBoundsTestEnable: ProcCmdSetDepthBoundsTestEnable -CmdSetDepthBoundsTestEnableEXT: ProcCmdSetDepthBoundsTestEnableEXT -CmdSetDepthCompareOp: ProcCmdSetDepthCompareOp -CmdSetDepthCompareOpEXT: ProcCmdSetDepthCompareOpEXT -CmdSetDepthTestEnable: ProcCmdSetDepthTestEnable -CmdSetDepthTestEnableEXT: ProcCmdSetDepthTestEnableEXT -CmdSetDepthWriteEnable: ProcCmdSetDepthWriteEnable -CmdSetDepthWriteEnableEXT: ProcCmdSetDepthWriteEnableEXT -CmdSetDeviceMask: ProcCmdSetDeviceMask -CmdSetDeviceMaskKHR: ProcCmdSetDeviceMaskKHR -CmdSetDiscardRectangleEXT: ProcCmdSetDiscardRectangleEXT -CmdSetEvent: ProcCmdSetEvent -CmdSetEvent2: ProcCmdSetEvent2 -CmdSetEvent2KHR: ProcCmdSetEvent2KHR -CmdSetExclusiveScissorNV: ProcCmdSetExclusiveScissorNV -CmdSetFragmentShadingRateEnumNV: ProcCmdSetFragmentShadingRateEnumNV -CmdSetFragmentShadingRateKHR: ProcCmdSetFragmentShadingRateKHR -CmdSetFrontFace: ProcCmdSetFrontFace -CmdSetFrontFaceEXT: ProcCmdSetFrontFaceEXT -CmdSetLineStippleEXT: ProcCmdSetLineStippleEXT -CmdSetLineWidth: ProcCmdSetLineWidth -CmdSetLogicOpEXT: ProcCmdSetLogicOpEXT -CmdSetPatchControlPointsEXT: ProcCmdSetPatchControlPointsEXT -CmdSetPerformanceMarkerINTEL: ProcCmdSetPerformanceMarkerINTEL -CmdSetPerformanceOverrideINTEL: ProcCmdSetPerformanceOverrideINTEL -CmdSetPerformanceStreamMarkerINTEL: ProcCmdSetPerformanceStreamMarkerINTEL -CmdSetPrimitiveRestartEnable: ProcCmdSetPrimitiveRestartEnable -CmdSetPrimitiveRestartEnableEXT: ProcCmdSetPrimitiveRestartEnableEXT -CmdSetPrimitiveTopology: ProcCmdSetPrimitiveTopology -CmdSetPrimitiveTopologyEXT: ProcCmdSetPrimitiveTopologyEXT -CmdSetRasterizerDiscardEnable: ProcCmdSetRasterizerDiscardEnable -CmdSetRasterizerDiscardEnableEXT: ProcCmdSetRasterizerDiscardEnableEXT -CmdSetRayTracingPipelineStackSizeKHR: ProcCmdSetRayTracingPipelineStackSizeKHR -CmdSetSampleLocationsEXT: ProcCmdSetSampleLocationsEXT -CmdSetScissor: ProcCmdSetScissor -CmdSetScissorWithCount: ProcCmdSetScissorWithCount -CmdSetScissorWithCountEXT: ProcCmdSetScissorWithCountEXT -CmdSetStencilCompareMask: ProcCmdSetStencilCompareMask -CmdSetStencilOp: ProcCmdSetStencilOp -CmdSetStencilOpEXT: ProcCmdSetStencilOpEXT -CmdSetStencilReference: ProcCmdSetStencilReference -CmdSetStencilTestEnable: ProcCmdSetStencilTestEnable -CmdSetStencilTestEnableEXT: ProcCmdSetStencilTestEnableEXT -CmdSetStencilWriteMask: ProcCmdSetStencilWriteMask -CmdSetVertexInputEXT: ProcCmdSetVertexInputEXT -CmdSetViewport: ProcCmdSetViewport -CmdSetViewportShadingRatePaletteNV: ProcCmdSetViewportShadingRatePaletteNV -CmdSetViewportWScalingNV: ProcCmdSetViewportWScalingNV -CmdSetViewportWithCount: ProcCmdSetViewportWithCount -CmdSetViewportWithCountEXT: ProcCmdSetViewportWithCountEXT -CmdSubpassShadingHUAWEI: ProcCmdSubpassShadingHUAWEI -CmdTraceRaysIndirectKHR: ProcCmdTraceRaysIndirectKHR -CmdTraceRaysKHR: ProcCmdTraceRaysKHR -CmdTraceRaysNV: ProcCmdTraceRaysNV -CmdUpdateBuffer: ProcCmdUpdateBuffer -CmdWaitEvents: ProcCmdWaitEvents -CmdWaitEvents2: ProcCmdWaitEvents2 -CmdWaitEvents2KHR: ProcCmdWaitEvents2KHR -CmdWriteAccelerationStructuresPropertiesKHR: ProcCmdWriteAccelerationStructuresPropertiesKHR -CmdWriteAccelerationStructuresPropertiesNV: ProcCmdWriteAccelerationStructuresPropertiesNV -CmdWriteBufferMarker2AMD: ProcCmdWriteBufferMarker2AMD -CmdWriteBufferMarkerAMD: ProcCmdWriteBufferMarkerAMD -CmdWriteTimestamp: ProcCmdWriteTimestamp -CmdWriteTimestamp2: ProcCmdWriteTimestamp2 -CmdWriteTimestamp2KHR: ProcCmdWriteTimestamp2KHR -CompileDeferredNV: ProcCompileDeferredNV -CopyAccelerationStructureKHR: ProcCopyAccelerationStructureKHR -CopyAccelerationStructureToMemoryKHR: ProcCopyAccelerationStructureToMemoryKHR -CopyMemoryToAccelerationStructureKHR: ProcCopyMemoryToAccelerationStructureKHR -CreateAccelerationStructureKHR: ProcCreateAccelerationStructureKHR -CreateAccelerationStructureNV: ProcCreateAccelerationStructureNV -CreateBuffer: ProcCreateBuffer -CreateBufferView: ProcCreateBufferView -CreateCommandPool: ProcCreateCommandPool -CreateComputePipelines: ProcCreateComputePipelines -CreateCuFunctionNVX: ProcCreateCuFunctionNVX -CreateCuModuleNVX: ProcCreateCuModuleNVX -CreateDeferredOperationKHR: ProcCreateDeferredOperationKHR -CreateDescriptorPool: ProcCreateDescriptorPool -CreateDescriptorSetLayout: ProcCreateDescriptorSetLayout -CreateDescriptorUpdateTemplate: ProcCreateDescriptorUpdateTemplate -CreateDescriptorUpdateTemplateKHR: ProcCreateDescriptorUpdateTemplateKHR -CreateEvent: ProcCreateEvent -CreateFence: ProcCreateFence -CreateFramebuffer: ProcCreateFramebuffer -CreateGraphicsPipelines: ProcCreateGraphicsPipelines -CreateImage: ProcCreateImage -CreateImageView: ProcCreateImageView -CreateIndirectCommandsLayoutNV: ProcCreateIndirectCommandsLayoutNV -CreatePipelineCache: ProcCreatePipelineCache -CreatePipelineLayout: ProcCreatePipelineLayout -CreatePrivateDataSlot: ProcCreatePrivateDataSlot -CreatePrivateDataSlotEXT: ProcCreatePrivateDataSlotEXT -CreateQueryPool: ProcCreateQueryPool -CreateRayTracingPipelinesKHR: ProcCreateRayTracingPipelinesKHR -CreateRayTracingPipelinesNV: ProcCreateRayTracingPipelinesNV -CreateRenderPass: ProcCreateRenderPass -CreateRenderPass2: ProcCreateRenderPass2 -CreateRenderPass2KHR: ProcCreateRenderPass2KHR -CreateSampler: ProcCreateSampler -CreateSamplerYcbcrConversion: ProcCreateSamplerYcbcrConversion -CreateSamplerYcbcrConversionKHR: ProcCreateSamplerYcbcrConversionKHR -CreateSemaphore: ProcCreateSemaphore -CreateShaderModule: ProcCreateShaderModule -CreateSharedSwapchainsKHR: ProcCreateSharedSwapchainsKHR -CreateSwapchainKHR: ProcCreateSwapchainKHR -CreateValidationCacheEXT: ProcCreateValidationCacheEXT -DebugMarkerSetObjectNameEXT: ProcDebugMarkerSetObjectNameEXT -DebugMarkerSetObjectTagEXT: ProcDebugMarkerSetObjectTagEXT -DeferredOperationJoinKHR: ProcDeferredOperationJoinKHR -DestroyAccelerationStructureKHR: ProcDestroyAccelerationStructureKHR -DestroyAccelerationStructureNV: ProcDestroyAccelerationStructureNV -DestroyBuffer: ProcDestroyBuffer -DestroyBufferView: ProcDestroyBufferView -DestroyCommandPool: ProcDestroyCommandPool -DestroyCuFunctionNVX: ProcDestroyCuFunctionNVX -DestroyCuModuleNVX: ProcDestroyCuModuleNVX -DestroyDeferredOperationKHR: ProcDestroyDeferredOperationKHR -DestroyDescriptorPool: ProcDestroyDescriptorPool -DestroyDescriptorSetLayout: ProcDestroyDescriptorSetLayout -DestroyDescriptorUpdateTemplate: ProcDestroyDescriptorUpdateTemplate -DestroyDescriptorUpdateTemplateKHR: ProcDestroyDescriptorUpdateTemplateKHR -DestroyDevice: ProcDestroyDevice -DestroyEvent: ProcDestroyEvent -DestroyFence: ProcDestroyFence -DestroyFramebuffer: ProcDestroyFramebuffer -DestroyImage: ProcDestroyImage -DestroyImageView: ProcDestroyImageView -DestroyIndirectCommandsLayoutNV: ProcDestroyIndirectCommandsLayoutNV -DestroyPipeline: ProcDestroyPipeline -DestroyPipelineCache: ProcDestroyPipelineCache -DestroyPipelineLayout: ProcDestroyPipelineLayout -DestroyPrivateDataSlot: ProcDestroyPrivateDataSlot -DestroyPrivateDataSlotEXT: ProcDestroyPrivateDataSlotEXT -DestroyQueryPool: ProcDestroyQueryPool -DestroyRenderPass: ProcDestroyRenderPass -DestroySampler: ProcDestroySampler -DestroySamplerYcbcrConversion: ProcDestroySamplerYcbcrConversion -DestroySamplerYcbcrConversionKHR: ProcDestroySamplerYcbcrConversionKHR -DestroySemaphore: ProcDestroySemaphore -DestroyShaderModule: ProcDestroyShaderModule -DestroySwapchainKHR: ProcDestroySwapchainKHR -DestroyValidationCacheEXT: ProcDestroyValidationCacheEXT -DeviceWaitIdle: ProcDeviceWaitIdle -DisplayPowerControlEXT: ProcDisplayPowerControlEXT -EndCommandBuffer: ProcEndCommandBuffer -FlushMappedMemoryRanges: ProcFlushMappedMemoryRanges -FreeCommandBuffers: ProcFreeCommandBuffers -FreeDescriptorSets: ProcFreeDescriptorSets -FreeMemory: ProcFreeMemory -GetAccelerationStructureBuildSizesKHR: ProcGetAccelerationStructureBuildSizesKHR -GetAccelerationStructureDeviceAddressKHR: ProcGetAccelerationStructureDeviceAddressKHR -GetAccelerationStructureHandleNV: ProcGetAccelerationStructureHandleNV -GetAccelerationStructureMemoryRequirementsNV: ProcGetAccelerationStructureMemoryRequirementsNV -GetBufferDeviceAddress: ProcGetBufferDeviceAddress -GetBufferDeviceAddressEXT: ProcGetBufferDeviceAddressEXT -GetBufferDeviceAddressKHR: ProcGetBufferDeviceAddressKHR -GetBufferMemoryRequirements: ProcGetBufferMemoryRequirements -GetBufferMemoryRequirements2: ProcGetBufferMemoryRequirements2 -GetBufferMemoryRequirements2KHR: ProcGetBufferMemoryRequirements2KHR -GetBufferOpaqueCaptureAddress: ProcGetBufferOpaqueCaptureAddress -GetBufferOpaqueCaptureAddressKHR: ProcGetBufferOpaqueCaptureAddressKHR -GetCalibratedTimestampsEXT: ProcGetCalibratedTimestampsEXT -GetDeferredOperationMaxConcurrencyKHR: ProcGetDeferredOperationMaxConcurrencyKHR -GetDeferredOperationResultKHR: ProcGetDeferredOperationResultKHR -GetDescriptorSetHostMappingVALVE: ProcGetDescriptorSetHostMappingVALVE -GetDescriptorSetLayoutHostMappingInfoVALVE: ProcGetDescriptorSetLayoutHostMappingInfoVALVE -GetDescriptorSetLayoutSupport: ProcGetDescriptorSetLayoutSupport -GetDescriptorSetLayoutSupportKHR: ProcGetDescriptorSetLayoutSupportKHR -GetDeviceAccelerationStructureCompatibilityKHR: ProcGetDeviceAccelerationStructureCompatibilityKHR -GetDeviceBufferMemoryRequirements: ProcGetDeviceBufferMemoryRequirements -GetDeviceBufferMemoryRequirementsKHR: ProcGetDeviceBufferMemoryRequirementsKHR -GetDeviceGroupPeerMemoryFeatures: ProcGetDeviceGroupPeerMemoryFeatures -GetDeviceGroupPeerMemoryFeaturesKHR: ProcGetDeviceGroupPeerMemoryFeaturesKHR -GetDeviceGroupPresentCapabilitiesKHR: ProcGetDeviceGroupPresentCapabilitiesKHR -GetDeviceGroupSurfacePresentModes2EXT: ProcGetDeviceGroupSurfacePresentModes2EXT -GetDeviceGroupSurfacePresentModesKHR: ProcGetDeviceGroupSurfacePresentModesKHR -GetDeviceImageMemoryRequirements: ProcGetDeviceImageMemoryRequirements -GetDeviceImageMemoryRequirementsKHR: ProcGetDeviceImageMemoryRequirementsKHR -GetDeviceImageSparseMemoryRequirements: ProcGetDeviceImageSparseMemoryRequirements -GetDeviceImageSparseMemoryRequirementsKHR: ProcGetDeviceImageSparseMemoryRequirementsKHR -GetDeviceMemoryCommitment: ProcGetDeviceMemoryCommitment -GetDeviceMemoryOpaqueCaptureAddress: ProcGetDeviceMemoryOpaqueCaptureAddress -GetDeviceMemoryOpaqueCaptureAddressKHR: ProcGetDeviceMemoryOpaqueCaptureAddressKHR -GetDeviceProcAddr: ProcGetDeviceProcAddr -GetDeviceQueue: ProcGetDeviceQueue -GetDeviceQueue2: ProcGetDeviceQueue2 -GetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI: ProcGetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI -GetEventStatus: ProcGetEventStatus -GetFenceFdKHR: ProcGetFenceFdKHR -GetFenceStatus: ProcGetFenceStatus -GetFenceWin32HandleKHR: ProcGetFenceWin32HandleKHR -GetGeneratedCommandsMemoryRequirementsNV: ProcGetGeneratedCommandsMemoryRequirementsNV -GetImageDrmFormatModifierPropertiesEXT: ProcGetImageDrmFormatModifierPropertiesEXT -GetImageMemoryRequirements: ProcGetImageMemoryRequirements -GetImageMemoryRequirements2: ProcGetImageMemoryRequirements2 -GetImageMemoryRequirements2KHR: ProcGetImageMemoryRequirements2KHR -GetImageSparseMemoryRequirements: ProcGetImageSparseMemoryRequirements -GetImageSparseMemoryRequirements2: ProcGetImageSparseMemoryRequirements2 -GetImageSparseMemoryRequirements2KHR: ProcGetImageSparseMemoryRequirements2KHR -GetImageSubresourceLayout: ProcGetImageSubresourceLayout -GetImageViewAddressNVX: ProcGetImageViewAddressNVX -GetImageViewHandleNVX: ProcGetImageViewHandleNVX -GetMemoryFdKHR: ProcGetMemoryFdKHR -GetMemoryFdPropertiesKHR: ProcGetMemoryFdPropertiesKHR -GetMemoryHostPointerPropertiesEXT: ProcGetMemoryHostPointerPropertiesEXT -GetMemoryRemoteAddressNV: ProcGetMemoryRemoteAddressNV -GetMemoryWin32HandleKHR: ProcGetMemoryWin32HandleKHR -GetMemoryWin32HandleNV: ProcGetMemoryWin32HandleNV -GetMemoryWin32HandlePropertiesKHR: ProcGetMemoryWin32HandlePropertiesKHR -GetPastPresentationTimingGOOGLE: ProcGetPastPresentationTimingGOOGLE -GetPerformanceParameterINTEL: ProcGetPerformanceParameterINTEL -GetPipelineCacheData: ProcGetPipelineCacheData -GetPipelineExecutableInternalRepresentationsKHR: ProcGetPipelineExecutableInternalRepresentationsKHR -GetPipelineExecutablePropertiesKHR: ProcGetPipelineExecutablePropertiesKHR -GetPipelineExecutableStatisticsKHR: ProcGetPipelineExecutableStatisticsKHR -GetPrivateData: ProcGetPrivateData -GetPrivateDataEXT: ProcGetPrivateDataEXT -GetQueryPoolResults: ProcGetQueryPoolResults -GetQueueCheckpointData2NV: ProcGetQueueCheckpointData2NV -GetQueueCheckpointDataNV: ProcGetQueueCheckpointDataNV -GetRayTracingCaptureReplayShaderGroupHandlesKHR: ProcGetRayTracingCaptureReplayShaderGroupHandlesKHR -GetRayTracingShaderGroupHandlesKHR: ProcGetRayTracingShaderGroupHandlesKHR -GetRayTracingShaderGroupHandlesNV: ProcGetRayTracingShaderGroupHandlesNV -GetRayTracingShaderGroupStackSizeKHR: ProcGetRayTracingShaderGroupStackSizeKHR -GetRefreshCycleDurationGOOGLE: ProcGetRefreshCycleDurationGOOGLE -GetRenderAreaGranularity: ProcGetRenderAreaGranularity -GetSemaphoreCounterValue: ProcGetSemaphoreCounterValue -GetSemaphoreCounterValueKHR: ProcGetSemaphoreCounterValueKHR -GetSemaphoreFdKHR: ProcGetSemaphoreFdKHR -GetSemaphoreWin32HandleKHR: ProcGetSemaphoreWin32HandleKHR -GetShaderInfoAMD: ProcGetShaderInfoAMD -GetSwapchainCounterEXT: ProcGetSwapchainCounterEXT -GetSwapchainImagesKHR: ProcGetSwapchainImagesKHR -GetSwapchainStatusKHR: ProcGetSwapchainStatusKHR -GetValidationCacheDataEXT: ProcGetValidationCacheDataEXT -ImportFenceFdKHR: ProcImportFenceFdKHR -ImportFenceWin32HandleKHR: ProcImportFenceWin32HandleKHR -ImportSemaphoreFdKHR: ProcImportSemaphoreFdKHR -ImportSemaphoreWin32HandleKHR: ProcImportSemaphoreWin32HandleKHR -InitializePerformanceApiINTEL: ProcInitializePerformanceApiINTEL -InvalidateMappedMemoryRanges: ProcInvalidateMappedMemoryRanges -MapMemory: ProcMapMemory -MergePipelineCaches: ProcMergePipelineCaches -MergeValidationCachesEXT: ProcMergeValidationCachesEXT -QueueBeginDebugUtilsLabelEXT: ProcQueueBeginDebugUtilsLabelEXT -QueueBindSparse: ProcQueueBindSparse -QueueEndDebugUtilsLabelEXT: ProcQueueEndDebugUtilsLabelEXT -QueueInsertDebugUtilsLabelEXT: ProcQueueInsertDebugUtilsLabelEXT -QueuePresentKHR: ProcQueuePresentKHR -QueueSetPerformanceConfigurationINTEL: ProcQueueSetPerformanceConfigurationINTEL -QueueSubmit: ProcQueueSubmit -QueueSubmit2: ProcQueueSubmit2 -QueueSubmit2KHR: ProcQueueSubmit2KHR -QueueWaitIdle: ProcQueueWaitIdle -RegisterDeviceEventEXT: ProcRegisterDeviceEventEXT -RegisterDisplayEventEXT: ProcRegisterDisplayEventEXT -ReleaseFullScreenExclusiveModeEXT: ProcReleaseFullScreenExclusiveModeEXT -ReleasePerformanceConfigurationINTEL: ProcReleasePerformanceConfigurationINTEL -ReleaseProfilingLockKHR: ProcReleaseProfilingLockKHR -ResetCommandBuffer: ProcResetCommandBuffer -ResetCommandPool: ProcResetCommandPool -ResetDescriptorPool: ProcResetDescriptorPool -ResetEvent: ProcResetEvent -ResetFences: ProcResetFences -ResetQueryPool: ProcResetQueryPool -ResetQueryPoolEXT: ProcResetQueryPoolEXT -SetDebugUtilsObjectNameEXT: ProcSetDebugUtilsObjectNameEXT -SetDebugUtilsObjectTagEXT: ProcSetDebugUtilsObjectTagEXT -SetDeviceMemoryPriorityEXT: ProcSetDeviceMemoryPriorityEXT -SetEvent: ProcSetEvent -SetHdrMetadataEXT: ProcSetHdrMetadataEXT -SetLocalDimmingAMD: ProcSetLocalDimmingAMD -SetPrivateData: ProcSetPrivateData -SetPrivateDataEXT: ProcSetPrivateDataEXT -SignalSemaphore: ProcSignalSemaphore -SignalSemaphoreKHR: ProcSignalSemaphoreKHR -TrimCommandPool: ProcTrimCommandPool -TrimCommandPoolKHR: ProcTrimCommandPoolKHR -UninitializePerformanceApiINTEL: ProcUninitializePerformanceApiINTEL -UnmapMemory: ProcUnmapMemory -UpdateDescriptorSetWithTemplate: ProcUpdateDescriptorSetWithTemplate -UpdateDescriptorSetWithTemplateKHR: ProcUpdateDescriptorSetWithTemplateKHR -UpdateDescriptorSets: ProcUpdateDescriptorSets -WaitForFences: ProcWaitForFences -WaitForPresentKHR: ProcWaitForPresentKHR -WaitSemaphores: ProcWaitSemaphores -WaitSemaphoresKHR: ProcWaitSemaphoresKHR -WriteAccelerationStructuresPropertiesKHR: ProcWriteAccelerationStructuresPropertiesKHR - -load_proc_addresses_custom :: proc(set_proc_address: SetProcAddressType) { - // Loader Procedures - set_proc_address(&CreateInstance, "vkCreateInstance") - set_proc_address(&DebugUtilsMessengerCallbackEXT, "vkDebugUtilsMessengerCallbackEXT") - set_proc_address(&DeviceMemoryReportCallbackEXT, "vkDeviceMemoryReportCallbackEXT") - set_proc_address(&EnumerateInstanceExtensionProperties, "vkEnumerateInstanceExtensionProperties") - set_proc_address(&EnumerateInstanceLayerProperties, "vkEnumerateInstanceLayerProperties") - set_proc_address(&EnumerateInstanceVersion, "vkEnumerateInstanceVersion") - set_proc_address(&GetInstanceProcAddr, "vkGetInstanceProcAddr") - - // Instance Procedures - set_proc_address(&AcquireDrmDisplayEXT, "vkAcquireDrmDisplayEXT") - set_proc_address(&AcquireWinrtDisplayNV, "vkAcquireWinrtDisplayNV") - set_proc_address(&CreateDebugReportCallbackEXT, "vkCreateDebugReportCallbackEXT") - set_proc_address(&CreateDebugUtilsMessengerEXT, "vkCreateDebugUtilsMessengerEXT") - set_proc_address(&CreateDevice, "vkCreateDevice") - set_proc_address(&CreateDisplayModeKHR, "vkCreateDisplayModeKHR") - set_proc_address(&CreateDisplayPlaneSurfaceKHR, "vkCreateDisplayPlaneSurfaceKHR") - set_proc_address(&CreateHeadlessSurfaceEXT, "vkCreateHeadlessSurfaceEXT") - set_proc_address(&CreateIOSSurfaceMVK, "vkCreateIOSSurfaceMVK") - set_proc_address(&CreateMacOSSurfaceMVK, "vkCreateMacOSSurfaceMVK") - set_proc_address(&CreateMetalSurfaceEXT, "vkCreateMetalSurfaceEXT") - set_proc_address(&CreateWin32SurfaceKHR, "vkCreateWin32SurfaceKHR") - set_proc_address(&DebugReportMessageEXT, "vkDebugReportMessageEXT") - set_proc_address(&DestroyDebugReportCallbackEXT, "vkDestroyDebugReportCallbackEXT") - set_proc_address(&DestroyDebugUtilsMessengerEXT, "vkDestroyDebugUtilsMessengerEXT") - set_proc_address(&DestroyInstance, "vkDestroyInstance") - set_proc_address(&DestroySurfaceKHR, "vkDestroySurfaceKHR") - set_proc_address(&EnumerateDeviceExtensionProperties, "vkEnumerateDeviceExtensionProperties") - set_proc_address(&EnumerateDeviceLayerProperties, "vkEnumerateDeviceLayerProperties") - set_proc_address(&EnumeratePhysicalDeviceGroups, "vkEnumeratePhysicalDeviceGroups") - set_proc_address(&EnumeratePhysicalDeviceGroupsKHR, "vkEnumeratePhysicalDeviceGroupsKHR") - set_proc_address(&EnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR, "vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR") - set_proc_address(&EnumeratePhysicalDevices, "vkEnumeratePhysicalDevices") - set_proc_address(&GetDisplayModeProperties2KHR, "vkGetDisplayModeProperties2KHR") - set_proc_address(&GetDisplayModePropertiesKHR, "vkGetDisplayModePropertiesKHR") - set_proc_address(&GetDisplayPlaneCapabilities2KHR, "vkGetDisplayPlaneCapabilities2KHR") - set_proc_address(&GetDisplayPlaneCapabilitiesKHR, "vkGetDisplayPlaneCapabilitiesKHR") - set_proc_address(&GetDisplayPlaneSupportedDisplaysKHR, "vkGetDisplayPlaneSupportedDisplaysKHR") - set_proc_address(&GetDrmDisplayEXT, "vkGetDrmDisplayEXT") - set_proc_address(&GetPhysicalDeviceCalibrateableTimeDomainsEXT, "vkGetPhysicalDeviceCalibrateableTimeDomainsEXT") - set_proc_address(&GetPhysicalDeviceCooperativeMatrixPropertiesNV, "vkGetPhysicalDeviceCooperativeMatrixPropertiesNV") - set_proc_address(&GetPhysicalDeviceDisplayPlaneProperties2KHR, "vkGetPhysicalDeviceDisplayPlaneProperties2KHR") - set_proc_address(&GetPhysicalDeviceDisplayPlanePropertiesKHR, "vkGetPhysicalDeviceDisplayPlanePropertiesKHR") - set_proc_address(&GetPhysicalDeviceDisplayProperties2KHR, "vkGetPhysicalDeviceDisplayProperties2KHR") - set_proc_address(&GetPhysicalDeviceDisplayPropertiesKHR, "vkGetPhysicalDeviceDisplayPropertiesKHR") - set_proc_address(&GetPhysicalDeviceExternalBufferProperties, "vkGetPhysicalDeviceExternalBufferProperties") - set_proc_address(&GetPhysicalDeviceExternalBufferPropertiesKHR, "vkGetPhysicalDeviceExternalBufferPropertiesKHR") - set_proc_address(&GetPhysicalDeviceExternalFenceProperties, "vkGetPhysicalDeviceExternalFenceProperties") - set_proc_address(&GetPhysicalDeviceExternalFencePropertiesKHR, "vkGetPhysicalDeviceExternalFencePropertiesKHR") - set_proc_address(&GetPhysicalDeviceExternalImageFormatPropertiesNV, "vkGetPhysicalDeviceExternalImageFormatPropertiesNV") - set_proc_address(&GetPhysicalDeviceExternalSemaphoreProperties, "vkGetPhysicalDeviceExternalSemaphoreProperties") - set_proc_address(&GetPhysicalDeviceExternalSemaphorePropertiesKHR, "vkGetPhysicalDeviceExternalSemaphorePropertiesKHR") - set_proc_address(&GetPhysicalDeviceFeatures, "vkGetPhysicalDeviceFeatures") - set_proc_address(&GetPhysicalDeviceFeatures2, "vkGetPhysicalDeviceFeatures2") - set_proc_address(&GetPhysicalDeviceFeatures2KHR, "vkGetPhysicalDeviceFeatures2KHR") - set_proc_address(&GetPhysicalDeviceFormatProperties, "vkGetPhysicalDeviceFormatProperties") - set_proc_address(&GetPhysicalDeviceFormatProperties2, "vkGetPhysicalDeviceFormatProperties2") - set_proc_address(&GetPhysicalDeviceFormatProperties2KHR, "vkGetPhysicalDeviceFormatProperties2KHR") - set_proc_address(&GetPhysicalDeviceFragmentShadingRatesKHR, "vkGetPhysicalDeviceFragmentShadingRatesKHR") - set_proc_address(&GetPhysicalDeviceImageFormatProperties, "vkGetPhysicalDeviceImageFormatProperties") - set_proc_address(&GetPhysicalDeviceImageFormatProperties2, "vkGetPhysicalDeviceImageFormatProperties2") - set_proc_address(&GetPhysicalDeviceImageFormatProperties2KHR, "vkGetPhysicalDeviceImageFormatProperties2KHR") - set_proc_address(&GetPhysicalDeviceMemoryProperties, "vkGetPhysicalDeviceMemoryProperties") - set_proc_address(&GetPhysicalDeviceMemoryProperties2, "vkGetPhysicalDeviceMemoryProperties2") - set_proc_address(&GetPhysicalDeviceMemoryProperties2KHR, "vkGetPhysicalDeviceMemoryProperties2KHR") - set_proc_address(&GetPhysicalDeviceMultisamplePropertiesEXT, "vkGetPhysicalDeviceMultisamplePropertiesEXT") - set_proc_address(&GetPhysicalDevicePresentRectanglesKHR, "vkGetPhysicalDevicePresentRectanglesKHR") - set_proc_address(&GetPhysicalDeviceProperties, "vkGetPhysicalDeviceProperties") - set_proc_address(&GetPhysicalDeviceProperties2, "vkGetPhysicalDeviceProperties2") - set_proc_address(&GetPhysicalDeviceProperties2KHR, "vkGetPhysicalDeviceProperties2KHR") - set_proc_address(&GetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR, "vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR") - set_proc_address(&GetPhysicalDeviceQueueFamilyProperties, "vkGetPhysicalDeviceQueueFamilyProperties") - set_proc_address(&GetPhysicalDeviceQueueFamilyProperties2, "vkGetPhysicalDeviceQueueFamilyProperties2") - set_proc_address(&GetPhysicalDeviceQueueFamilyProperties2KHR, "vkGetPhysicalDeviceQueueFamilyProperties2KHR") - set_proc_address(&GetPhysicalDeviceSparseImageFormatProperties, "vkGetPhysicalDeviceSparseImageFormatProperties") - set_proc_address(&GetPhysicalDeviceSparseImageFormatProperties2, "vkGetPhysicalDeviceSparseImageFormatProperties2") - set_proc_address(&GetPhysicalDeviceSparseImageFormatProperties2KHR, "vkGetPhysicalDeviceSparseImageFormatProperties2KHR") - set_proc_address(&GetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV, "vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV") - set_proc_address(&GetPhysicalDeviceSurfaceCapabilities2EXT, "vkGetPhysicalDeviceSurfaceCapabilities2EXT") - set_proc_address(&GetPhysicalDeviceSurfaceCapabilities2KHR, "vkGetPhysicalDeviceSurfaceCapabilities2KHR") - set_proc_address(&GetPhysicalDeviceSurfaceCapabilitiesKHR, "vkGetPhysicalDeviceSurfaceCapabilitiesKHR") - set_proc_address(&GetPhysicalDeviceSurfaceFormats2KHR, "vkGetPhysicalDeviceSurfaceFormats2KHR") - set_proc_address(&GetPhysicalDeviceSurfaceFormatsKHR, "vkGetPhysicalDeviceSurfaceFormatsKHR") - set_proc_address(&GetPhysicalDeviceSurfacePresentModes2EXT, "vkGetPhysicalDeviceSurfacePresentModes2EXT") - set_proc_address(&GetPhysicalDeviceSurfacePresentModesKHR, "vkGetPhysicalDeviceSurfacePresentModesKHR") - set_proc_address(&GetPhysicalDeviceSurfaceSupportKHR, "vkGetPhysicalDeviceSurfaceSupportKHR") - set_proc_address(&GetPhysicalDeviceToolProperties, "vkGetPhysicalDeviceToolProperties") - set_proc_address(&GetPhysicalDeviceToolPropertiesEXT, "vkGetPhysicalDeviceToolPropertiesEXT") - set_proc_address(&GetPhysicalDeviceWin32PresentationSupportKHR, "vkGetPhysicalDeviceWin32PresentationSupportKHR") - set_proc_address(&GetWinrtDisplayNV, "vkGetWinrtDisplayNV") - set_proc_address(&ReleaseDisplayEXT, "vkReleaseDisplayEXT") - set_proc_address(&SubmitDebugUtilsMessageEXT, "vkSubmitDebugUtilsMessageEXT") - - // Device Procedures - set_proc_address(&AcquireFullScreenExclusiveModeEXT, "vkAcquireFullScreenExclusiveModeEXT") - set_proc_address(&AcquireNextImage2KHR, "vkAcquireNextImage2KHR") - set_proc_address(&AcquireNextImageKHR, "vkAcquireNextImageKHR") - set_proc_address(&AcquirePerformanceConfigurationINTEL, "vkAcquirePerformanceConfigurationINTEL") - set_proc_address(&AcquireProfilingLockKHR, "vkAcquireProfilingLockKHR") - set_proc_address(&AllocateCommandBuffers, "vkAllocateCommandBuffers") - set_proc_address(&AllocateDescriptorSets, "vkAllocateDescriptorSets") - set_proc_address(&AllocateMemory, "vkAllocateMemory") - set_proc_address(&BeginCommandBuffer, "vkBeginCommandBuffer") - set_proc_address(&BindAccelerationStructureMemoryNV, "vkBindAccelerationStructureMemoryNV") - set_proc_address(&BindBufferMemory, "vkBindBufferMemory") - set_proc_address(&BindBufferMemory2, "vkBindBufferMemory2") - set_proc_address(&BindBufferMemory2KHR, "vkBindBufferMemory2KHR") - set_proc_address(&BindImageMemory, "vkBindImageMemory") - set_proc_address(&BindImageMemory2, "vkBindImageMemory2") - set_proc_address(&BindImageMemory2KHR, "vkBindImageMemory2KHR") - set_proc_address(&BuildAccelerationStructuresKHR, "vkBuildAccelerationStructuresKHR") - set_proc_address(&CmdBeginConditionalRenderingEXT, "vkCmdBeginConditionalRenderingEXT") - set_proc_address(&CmdBeginDebugUtilsLabelEXT, "vkCmdBeginDebugUtilsLabelEXT") - set_proc_address(&CmdBeginQuery, "vkCmdBeginQuery") - set_proc_address(&CmdBeginQueryIndexedEXT, "vkCmdBeginQueryIndexedEXT") - set_proc_address(&CmdBeginRenderPass, "vkCmdBeginRenderPass") - set_proc_address(&CmdBeginRenderPass2, "vkCmdBeginRenderPass2") - set_proc_address(&CmdBeginRenderPass2KHR, "vkCmdBeginRenderPass2KHR") - set_proc_address(&CmdBeginRendering, "vkCmdBeginRendering") - set_proc_address(&CmdBeginRenderingKHR, "vkCmdBeginRenderingKHR") - set_proc_address(&CmdBeginTransformFeedbackEXT, "vkCmdBeginTransformFeedbackEXT") - set_proc_address(&CmdBindDescriptorSets, "vkCmdBindDescriptorSets") - set_proc_address(&CmdBindIndexBuffer, "vkCmdBindIndexBuffer") - set_proc_address(&CmdBindInvocationMaskHUAWEI, "vkCmdBindInvocationMaskHUAWEI") - set_proc_address(&CmdBindPipeline, "vkCmdBindPipeline") - set_proc_address(&CmdBindPipelineShaderGroupNV, "vkCmdBindPipelineShaderGroupNV") - set_proc_address(&CmdBindShadingRateImageNV, "vkCmdBindShadingRateImageNV") - set_proc_address(&CmdBindTransformFeedbackBuffersEXT, "vkCmdBindTransformFeedbackBuffersEXT") - set_proc_address(&CmdBindVertexBuffers, "vkCmdBindVertexBuffers") - set_proc_address(&CmdBindVertexBuffers2, "vkCmdBindVertexBuffers2") - set_proc_address(&CmdBindVertexBuffers2EXT, "vkCmdBindVertexBuffers2EXT") - set_proc_address(&CmdBlitImage, "vkCmdBlitImage") - set_proc_address(&CmdBlitImage2, "vkCmdBlitImage2") - set_proc_address(&CmdBlitImage2KHR, "vkCmdBlitImage2KHR") - set_proc_address(&CmdBuildAccelerationStructureNV, "vkCmdBuildAccelerationStructureNV") - set_proc_address(&CmdBuildAccelerationStructuresIndirectKHR, "vkCmdBuildAccelerationStructuresIndirectKHR") - set_proc_address(&CmdBuildAccelerationStructuresKHR, "vkCmdBuildAccelerationStructuresKHR") - set_proc_address(&CmdClearAttachments, "vkCmdClearAttachments") - set_proc_address(&CmdClearColorImage, "vkCmdClearColorImage") - set_proc_address(&CmdClearDepthStencilImage, "vkCmdClearDepthStencilImage") - set_proc_address(&CmdCopyAccelerationStructureKHR, "vkCmdCopyAccelerationStructureKHR") - set_proc_address(&CmdCopyAccelerationStructureNV, "vkCmdCopyAccelerationStructureNV") - set_proc_address(&CmdCopyAccelerationStructureToMemoryKHR, "vkCmdCopyAccelerationStructureToMemoryKHR") - set_proc_address(&CmdCopyBuffer, "vkCmdCopyBuffer") - set_proc_address(&CmdCopyBuffer2, "vkCmdCopyBuffer2") - set_proc_address(&CmdCopyBuffer2KHR, "vkCmdCopyBuffer2KHR") - set_proc_address(&CmdCopyBufferToImage, "vkCmdCopyBufferToImage") - set_proc_address(&CmdCopyBufferToImage2, "vkCmdCopyBufferToImage2") - set_proc_address(&CmdCopyBufferToImage2KHR, "vkCmdCopyBufferToImage2KHR") - set_proc_address(&CmdCopyImage, "vkCmdCopyImage") - set_proc_address(&CmdCopyImage2, "vkCmdCopyImage2") - set_proc_address(&CmdCopyImage2KHR, "vkCmdCopyImage2KHR") - set_proc_address(&CmdCopyImageToBuffer, "vkCmdCopyImageToBuffer") - set_proc_address(&CmdCopyImageToBuffer2, "vkCmdCopyImageToBuffer2") - set_proc_address(&CmdCopyImageToBuffer2KHR, "vkCmdCopyImageToBuffer2KHR") - set_proc_address(&CmdCopyMemoryToAccelerationStructureKHR, "vkCmdCopyMemoryToAccelerationStructureKHR") - set_proc_address(&CmdCopyQueryPoolResults, "vkCmdCopyQueryPoolResults") - set_proc_address(&CmdCuLaunchKernelNVX, "vkCmdCuLaunchKernelNVX") - set_proc_address(&CmdDebugMarkerBeginEXT, "vkCmdDebugMarkerBeginEXT") - set_proc_address(&CmdDebugMarkerEndEXT, "vkCmdDebugMarkerEndEXT") - set_proc_address(&CmdDebugMarkerInsertEXT, "vkCmdDebugMarkerInsertEXT") - set_proc_address(&CmdDispatch, "vkCmdDispatch") - set_proc_address(&CmdDispatchBase, "vkCmdDispatchBase") - set_proc_address(&CmdDispatchBaseKHR, "vkCmdDispatchBaseKHR") - set_proc_address(&CmdDispatchIndirect, "vkCmdDispatchIndirect") - set_proc_address(&CmdDraw, "vkCmdDraw") - set_proc_address(&CmdDrawIndexed, "vkCmdDrawIndexed") - set_proc_address(&CmdDrawIndexedIndirect, "vkCmdDrawIndexedIndirect") - set_proc_address(&CmdDrawIndexedIndirectCount, "vkCmdDrawIndexedIndirectCount") - set_proc_address(&CmdDrawIndexedIndirectCountAMD, "vkCmdDrawIndexedIndirectCountAMD") - set_proc_address(&CmdDrawIndexedIndirectCountKHR, "vkCmdDrawIndexedIndirectCountKHR") - set_proc_address(&CmdDrawIndirect, "vkCmdDrawIndirect") - set_proc_address(&CmdDrawIndirectByteCountEXT, "vkCmdDrawIndirectByteCountEXT") - set_proc_address(&CmdDrawIndirectCount, "vkCmdDrawIndirectCount") - set_proc_address(&CmdDrawIndirectCountAMD, "vkCmdDrawIndirectCountAMD") - set_proc_address(&CmdDrawIndirectCountKHR, "vkCmdDrawIndirectCountKHR") - set_proc_address(&CmdDrawMeshTasksIndirectCountNV, "vkCmdDrawMeshTasksIndirectCountNV") - set_proc_address(&CmdDrawMeshTasksIndirectNV, "vkCmdDrawMeshTasksIndirectNV") - set_proc_address(&CmdDrawMeshTasksNV, "vkCmdDrawMeshTasksNV") - set_proc_address(&CmdDrawMultiEXT, "vkCmdDrawMultiEXT") - set_proc_address(&CmdDrawMultiIndexedEXT, "vkCmdDrawMultiIndexedEXT") - set_proc_address(&CmdEndConditionalRenderingEXT, "vkCmdEndConditionalRenderingEXT") - set_proc_address(&CmdEndDebugUtilsLabelEXT, "vkCmdEndDebugUtilsLabelEXT") - set_proc_address(&CmdEndQuery, "vkCmdEndQuery") - set_proc_address(&CmdEndQueryIndexedEXT, "vkCmdEndQueryIndexedEXT") - set_proc_address(&CmdEndRenderPass, "vkCmdEndRenderPass") - set_proc_address(&CmdEndRenderPass2, "vkCmdEndRenderPass2") - set_proc_address(&CmdEndRenderPass2KHR, "vkCmdEndRenderPass2KHR") - set_proc_address(&CmdEndRendering, "vkCmdEndRendering") - set_proc_address(&CmdEndRenderingKHR, "vkCmdEndRenderingKHR") - set_proc_address(&CmdEndTransformFeedbackEXT, "vkCmdEndTransformFeedbackEXT") - set_proc_address(&CmdExecuteCommands, "vkCmdExecuteCommands") - set_proc_address(&CmdExecuteGeneratedCommandsNV, "vkCmdExecuteGeneratedCommandsNV") - set_proc_address(&CmdFillBuffer, "vkCmdFillBuffer") - set_proc_address(&CmdInsertDebugUtilsLabelEXT, "vkCmdInsertDebugUtilsLabelEXT") - set_proc_address(&CmdNextSubpass, "vkCmdNextSubpass") - set_proc_address(&CmdNextSubpass2, "vkCmdNextSubpass2") - set_proc_address(&CmdNextSubpass2KHR, "vkCmdNextSubpass2KHR") - set_proc_address(&CmdPipelineBarrier, "vkCmdPipelineBarrier") - set_proc_address(&CmdPipelineBarrier2, "vkCmdPipelineBarrier2") - set_proc_address(&CmdPipelineBarrier2KHR, "vkCmdPipelineBarrier2KHR") - set_proc_address(&CmdPreprocessGeneratedCommandsNV, "vkCmdPreprocessGeneratedCommandsNV") - set_proc_address(&CmdPushConstants, "vkCmdPushConstants") - set_proc_address(&CmdPushDescriptorSetKHR, "vkCmdPushDescriptorSetKHR") - set_proc_address(&CmdPushDescriptorSetWithTemplateKHR, "vkCmdPushDescriptorSetWithTemplateKHR") - set_proc_address(&CmdResetEvent, "vkCmdResetEvent") - set_proc_address(&CmdResetEvent2, "vkCmdResetEvent2") - set_proc_address(&CmdResetEvent2KHR, "vkCmdResetEvent2KHR") - set_proc_address(&CmdResetQueryPool, "vkCmdResetQueryPool") - set_proc_address(&CmdResolveImage, "vkCmdResolveImage") - set_proc_address(&CmdResolveImage2, "vkCmdResolveImage2") - set_proc_address(&CmdResolveImage2KHR, "vkCmdResolveImage2KHR") - set_proc_address(&CmdSetBlendConstants, "vkCmdSetBlendConstants") - set_proc_address(&CmdSetCheckpointNV, "vkCmdSetCheckpointNV") - set_proc_address(&CmdSetCoarseSampleOrderNV, "vkCmdSetCoarseSampleOrderNV") - set_proc_address(&CmdSetCullMode, "vkCmdSetCullMode") - set_proc_address(&CmdSetCullModeEXT, "vkCmdSetCullModeEXT") - set_proc_address(&CmdSetDepthBias, "vkCmdSetDepthBias") - set_proc_address(&CmdSetDepthBiasEnable, "vkCmdSetDepthBiasEnable") - set_proc_address(&CmdSetDepthBiasEnableEXT, "vkCmdSetDepthBiasEnableEXT") - set_proc_address(&CmdSetDepthBounds, "vkCmdSetDepthBounds") - set_proc_address(&CmdSetDepthBoundsTestEnable, "vkCmdSetDepthBoundsTestEnable") - set_proc_address(&CmdSetDepthBoundsTestEnableEXT, "vkCmdSetDepthBoundsTestEnableEXT") - set_proc_address(&CmdSetDepthCompareOp, "vkCmdSetDepthCompareOp") - set_proc_address(&CmdSetDepthCompareOpEXT, "vkCmdSetDepthCompareOpEXT") - set_proc_address(&CmdSetDepthTestEnable, "vkCmdSetDepthTestEnable") - set_proc_address(&CmdSetDepthTestEnableEXT, "vkCmdSetDepthTestEnableEXT") - set_proc_address(&CmdSetDepthWriteEnable, "vkCmdSetDepthWriteEnable") - set_proc_address(&CmdSetDepthWriteEnableEXT, "vkCmdSetDepthWriteEnableEXT") - set_proc_address(&CmdSetDeviceMask, "vkCmdSetDeviceMask") - set_proc_address(&CmdSetDeviceMaskKHR, "vkCmdSetDeviceMaskKHR") - set_proc_address(&CmdSetDiscardRectangleEXT, "vkCmdSetDiscardRectangleEXT") - set_proc_address(&CmdSetEvent, "vkCmdSetEvent") - set_proc_address(&CmdSetEvent2, "vkCmdSetEvent2") - set_proc_address(&CmdSetEvent2KHR, "vkCmdSetEvent2KHR") - set_proc_address(&CmdSetExclusiveScissorNV, "vkCmdSetExclusiveScissorNV") - set_proc_address(&CmdSetFragmentShadingRateEnumNV, "vkCmdSetFragmentShadingRateEnumNV") - set_proc_address(&CmdSetFragmentShadingRateKHR, "vkCmdSetFragmentShadingRateKHR") - set_proc_address(&CmdSetFrontFace, "vkCmdSetFrontFace") - set_proc_address(&CmdSetFrontFaceEXT, "vkCmdSetFrontFaceEXT") - set_proc_address(&CmdSetLineStippleEXT, "vkCmdSetLineStippleEXT") - set_proc_address(&CmdSetLineWidth, "vkCmdSetLineWidth") - set_proc_address(&CmdSetLogicOpEXT, "vkCmdSetLogicOpEXT") - set_proc_address(&CmdSetPatchControlPointsEXT, "vkCmdSetPatchControlPointsEXT") - set_proc_address(&CmdSetPerformanceMarkerINTEL, "vkCmdSetPerformanceMarkerINTEL") - set_proc_address(&CmdSetPerformanceOverrideINTEL, "vkCmdSetPerformanceOverrideINTEL") - set_proc_address(&CmdSetPerformanceStreamMarkerINTEL, "vkCmdSetPerformanceStreamMarkerINTEL") - set_proc_address(&CmdSetPrimitiveRestartEnable, "vkCmdSetPrimitiveRestartEnable") - set_proc_address(&CmdSetPrimitiveRestartEnableEXT, "vkCmdSetPrimitiveRestartEnableEXT") - set_proc_address(&CmdSetPrimitiveTopology, "vkCmdSetPrimitiveTopology") - set_proc_address(&CmdSetPrimitiveTopologyEXT, "vkCmdSetPrimitiveTopologyEXT") - set_proc_address(&CmdSetRasterizerDiscardEnable, "vkCmdSetRasterizerDiscardEnable") - set_proc_address(&CmdSetRasterizerDiscardEnableEXT, "vkCmdSetRasterizerDiscardEnableEXT") - set_proc_address(&CmdSetRayTracingPipelineStackSizeKHR, "vkCmdSetRayTracingPipelineStackSizeKHR") - set_proc_address(&CmdSetSampleLocationsEXT, "vkCmdSetSampleLocationsEXT") - set_proc_address(&CmdSetScissor, "vkCmdSetScissor") - set_proc_address(&CmdSetScissorWithCount, "vkCmdSetScissorWithCount") - set_proc_address(&CmdSetScissorWithCountEXT, "vkCmdSetScissorWithCountEXT") - set_proc_address(&CmdSetStencilCompareMask, "vkCmdSetStencilCompareMask") - set_proc_address(&CmdSetStencilOp, "vkCmdSetStencilOp") - set_proc_address(&CmdSetStencilOpEXT, "vkCmdSetStencilOpEXT") - set_proc_address(&CmdSetStencilReference, "vkCmdSetStencilReference") - set_proc_address(&CmdSetStencilTestEnable, "vkCmdSetStencilTestEnable") - set_proc_address(&CmdSetStencilTestEnableEXT, "vkCmdSetStencilTestEnableEXT") - set_proc_address(&CmdSetStencilWriteMask, "vkCmdSetStencilWriteMask") - set_proc_address(&CmdSetVertexInputEXT, "vkCmdSetVertexInputEXT") - set_proc_address(&CmdSetViewport, "vkCmdSetViewport") - set_proc_address(&CmdSetViewportShadingRatePaletteNV, "vkCmdSetViewportShadingRatePaletteNV") - set_proc_address(&CmdSetViewportWScalingNV, "vkCmdSetViewportWScalingNV") - set_proc_address(&CmdSetViewportWithCount, "vkCmdSetViewportWithCount") - set_proc_address(&CmdSetViewportWithCountEXT, "vkCmdSetViewportWithCountEXT") - set_proc_address(&CmdSubpassShadingHUAWEI, "vkCmdSubpassShadingHUAWEI") - set_proc_address(&CmdTraceRaysIndirectKHR, "vkCmdTraceRaysIndirectKHR") - set_proc_address(&CmdTraceRaysKHR, "vkCmdTraceRaysKHR") - set_proc_address(&CmdTraceRaysNV, "vkCmdTraceRaysNV") - set_proc_address(&CmdUpdateBuffer, "vkCmdUpdateBuffer") - set_proc_address(&CmdWaitEvents, "vkCmdWaitEvents") - set_proc_address(&CmdWaitEvents2, "vkCmdWaitEvents2") - set_proc_address(&CmdWaitEvents2KHR, "vkCmdWaitEvents2KHR") - set_proc_address(&CmdWriteAccelerationStructuresPropertiesKHR, "vkCmdWriteAccelerationStructuresPropertiesKHR") - set_proc_address(&CmdWriteAccelerationStructuresPropertiesNV, "vkCmdWriteAccelerationStructuresPropertiesNV") - set_proc_address(&CmdWriteBufferMarker2AMD, "vkCmdWriteBufferMarker2AMD") - set_proc_address(&CmdWriteBufferMarkerAMD, "vkCmdWriteBufferMarkerAMD") - set_proc_address(&CmdWriteTimestamp, "vkCmdWriteTimestamp") - set_proc_address(&CmdWriteTimestamp2, "vkCmdWriteTimestamp2") - set_proc_address(&CmdWriteTimestamp2KHR, "vkCmdWriteTimestamp2KHR") - set_proc_address(&CompileDeferredNV, "vkCompileDeferredNV") - set_proc_address(&CopyAccelerationStructureKHR, "vkCopyAccelerationStructureKHR") - set_proc_address(&CopyAccelerationStructureToMemoryKHR, "vkCopyAccelerationStructureToMemoryKHR") - set_proc_address(&CopyMemoryToAccelerationStructureKHR, "vkCopyMemoryToAccelerationStructureKHR") - set_proc_address(&CreateAccelerationStructureKHR, "vkCreateAccelerationStructureKHR") - set_proc_address(&CreateAccelerationStructureNV, "vkCreateAccelerationStructureNV") - set_proc_address(&CreateBuffer, "vkCreateBuffer") - set_proc_address(&CreateBufferView, "vkCreateBufferView") - set_proc_address(&CreateCommandPool, "vkCreateCommandPool") - set_proc_address(&CreateComputePipelines, "vkCreateComputePipelines") - set_proc_address(&CreateCuFunctionNVX, "vkCreateCuFunctionNVX") - set_proc_address(&CreateCuModuleNVX, "vkCreateCuModuleNVX") - set_proc_address(&CreateDeferredOperationKHR, "vkCreateDeferredOperationKHR") - set_proc_address(&CreateDescriptorPool, "vkCreateDescriptorPool") - set_proc_address(&CreateDescriptorSetLayout, "vkCreateDescriptorSetLayout") - set_proc_address(&CreateDescriptorUpdateTemplate, "vkCreateDescriptorUpdateTemplate") - set_proc_address(&CreateDescriptorUpdateTemplateKHR, "vkCreateDescriptorUpdateTemplateKHR") - set_proc_address(&CreateEvent, "vkCreateEvent") - set_proc_address(&CreateFence, "vkCreateFence") - set_proc_address(&CreateFramebuffer, "vkCreateFramebuffer") - set_proc_address(&CreateGraphicsPipelines, "vkCreateGraphicsPipelines") - set_proc_address(&CreateImage, "vkCreateImage") - set_proc_address(&CreateImageView, "vkCreateImageView") - set_proc_address(&CreateIndirectCommandsLayoutNV, "vkCreateIndirectCommandsLayoutNV") - set_proc_address(&CreatePipelineCache, "vkCreatePipelineCache") - set_proc_address(&CreatePipelineLayout, "vkCreatePipelineLayout") - set_proc_address(&CreatePrivateDataSlot, "vkCreatePrivateDataSlot") - set_proc_address(&CreatePrivateDataSlotEXT, "vkCreatePrivateDataSlotEXT") - set_proc_address(&CreateQueryPool, "vkCreateQueryPool") - set_proc_address(&CreateRayTracingPipelinesKHR, "vkCreateRayTracingPipelinesKHR") - set_proc_address(&CreateRayTracingPipelinesNV, "vkCreateRayTracingPipelinesNV") - set_proc_address(&CreateRenderPass, "vkCreateRenderPass") - set_proc_address(&CreateRenderPass2, "vkCreateRenderPass2") - set_proc_address(&CreateRenderPass2KHR, "vkCreateRenderPass2KHR") - set_proc_address(&CreateSampler, "vkCreateSampler") - set_proc_address(&CreateSamplerYcbcrConversion, "vkCreateSamplerYcbcrConversion") - set_proc_address(&CreateSamplerYcbcrConversionKHR, "vkCreateSamplerYcbcrConversionKHR") - set_proc_address(&CreateSemaphore, "vkCreateSemaphore") - set_proc_address(&CreateShaderModule, "vkCreateShaderModule") - set_proc_address(&CreateSharedSwapchainsKHR, "vkCreateSharedSwapchainsKHR") - set_proc_address(&CreateSwapchainKHR, "vkCreateSwapchainKHR") - set_proc_address(&CreateValidationCacheEXT, "vkCreateValidationCacheEXT") - set_proc_address(&DebugMarkerSetObjectNameEXT, "vkDebugMarkerSetObjectNameEXT") - set_proc_address(&DebugMarkerSetObjectTagEXT, "vkDebugMarkerSetObjectTagEXT") - set_proc_address(&DeferredOperationJoinKHR, "vkDeferredOperationJoinKHR") - set_proc_address(&DestroyAccelerationStructureKHR, "vkDestroyAccelerationStructureKHR") - set_proc_address(&DestroyAccelerationStructureNV, "vkDestroyAccelerationStructureNV") - set_proc_address(&DestroyBuffer, "vkDestroyBuffer") - set_proc_address(&DestroyBufferView, "vkDestroyBufferView") - set_proc_address(&DestroyCommandPool, "vkDestroyCommandPool") - set_proc_address(&DestroyCuFunctionNVX, "vkDestroyCuFunctionNVX") - set_proc_address(&DestroyCuModuleNVX, "vkDestroyCuModuleNVX") - set_proc_address(&DestroyDeferredOperationKHR, "vkDestroyDeferredOperationKHR") - set_proc_address(&DestroyDescriptorPool, "vkDestroyDescriptorPool") - set_proc_address(&DestroyDescriptorSetLayout, "vkDestroyDescriptorSetLayout") - set_proc_address(&DestroyDescriptorUpdateTemplate, "vkDestroyDescriptorUpdateTemplate") - set_proc_address(&DestroyDescriptorUpdateTemplateKHR, "vkDestroyDescriptorUpdateTemplateKHR") - set_proc_address(&DestroyDevice, "vkDestroyDevice") - set_proc_address(&DestroyEvent, "vkDestroyEvent") - set_proc_address(&DestroyFence, "vkDestroyFence") - set_proc_address(&DestroyFramebuffer, "vkDestroyFramebuffer") - set_proc_address(&DestroyImage, "vkDestroyImage") - set_proc_address(&DestroyImageView, "vkDestroyImageView") - set_proc_address(&DestroyIndirectCommandsLayoutNV, "vkDestroyIndirectCommandsLayoutNV") - set_proc_address(&DestroyPipeline, "vkDestroyPipeline") - set_proc_address(&DestroyPipelineCache, "vkDestroyPipelineCache") - set_proc_address(&DestroyPipelineLayout, "vkDestroyPipelineLayout") - set_proc_address(&DestroyPrivateDataSlot, "vkDestroyPrivateDataSlot") - set_proc_address(&DestroyPrivateDataSlotEXT, "vkDestroyPrivateDataSlotEXT") - set_proc_address(&DestroyQueryPool, "vkDestroyQueryPool") - set_proc_address(&DestroyRenderPass, "vkDestroyRenderPass") - set_proc_address(&DestroySampler, "vkDestroySampler") - set_proc_address(&DestroySamplerYcbcrConversion, "vkDestroySamplerYcbcrConversion") - set_proc_address(&DestroySamplerYcbcrConversionKHR, "vkDestroySamplerYcbcrConversionKHR") - set_proc_address(&DestroySemaphore, "vkDestroySemaphore") - set_proc_address(&DestroyShaderModule, "vkDestroyShaderModule") - set_proc_address(&DestroySwapchainKHR, "vkDestroySwapchainKHR") - set_proc_address(&DestroyValidationCacheEXT, "vkDestroyValidationCacheEXT") - set_proc_address(&DeviceWaitIdle, "vkDeviceWaitIdle") - set_proc_address(&DisplayPowerControlEXT, "vkDisplayPowerControlEXT") - set_proc_address(&EndCommandBuffer, "vkEndCommandBuffer") - set_proc_address(&FlushMappedMemoryRanges, "vkFlushMappedMemoryRanges") - set_proc_address(&FreeCommandBuffers, "vkFreeCommandBuffers") - set_proc_address(&FreeDescriptorSets, "vkFreeDescriptorSets") - set_proc_address(&FreeMemory, "vkFreeMemory") - set_proc_address(&GetAccelerationStructureBuildSizesKHR, "vkGetAccelerationStructureBuildSizesKHR") - set_proc_address(&GetAccelerationStructureDeviceAddressKHR, "vkGetAccelerationStructureDeviceAddressKHR") - set_proc_address(&GetAccelerationStructureHandleNV, "vkGetAccelerationStructureHandleNV") - set_proc_address(&GetAccelerationStructureMemoryRequirementsNV, "vkGetAccelerationStructureMemoryRequirementsNV") - set_proc_address(&GetBufferDeviceAddress, "vkGetBufferDeviceAddress") - set_proc_address(&GetBufferDeviceAddressEXT, "vkGetBufferDeviceAddressEXT") - set_proc_address(&GetBufferDeviceAddressKHR, "vkGetBufferDeviceAddressKHR") - set_proc_address(&GetBufferMemoryRequirements, "vkGetBufferMemoryRequirements") - set_proc_address(&GetBufferMemoryRequirements2, "vkGetBufferMemoryRequirements2") - set_proc_address(&GetBufferMemoryRequirements2KHR, "vkGetBufferMemoryRequirements2KHR") - set_proc_address(&GetBufferOpaqueCaptureAddress, "vkGetBufferOpaqueCaptureAddress") - set_proc_address(&GetBufferOpaqueCaptureAddressKHR, "vkGetBufferOpaqueCaptureAddressKHR") - set_proc_address(&GetCalibratedTimestampsEXT, "vkGetCalibratedTimestampsEXT") - set_proc_address(&GetDeferredOperationMaxConcurrencyKHR, "vkGetDeferredOperationMaxConcurrencyKHR") - set_proc_address(&GetDeferredOperationResultKHR, "vkGetDeferredOperationResultKHR") - set_proc_address(&GetDescriptorSetHostMappingVALVE, "vkGetDescriptorSetHostMappingVALVE") - set_proc_address(&GetDescriptorSetLayoutHostMappingInfoVALVE, "vkGetDescriptorSetLayoutHostMappingInfoVALVE") - set_proc_address(&GetDescriptorSetLayoutSupport, "vkGetDescriptorSetLayoutSupport") - set_proc_address(&GetDescriptorSetLayoutSupportKHR, "vkGetDescriptorSetLayoutSupportKHR") - set_proc_address(&GetDeviceAccelerationStructureCompatibilityKHR, "vkGetDeviceAccelerationStructureCompatibilityKHR") - set_proc_address(&GetDeviceBufferMemoryRequirements, "vkGetDeviceBufferMemoryRequirements") - set_proc_address(&GetDeviceBufferMemoryRequirementsKHR, "vkGetDeviceBufferMemoryRequirementsKHR") - set_proc_address(&GetDeviceGroupPeerMemoryFeatures, "vkGetDeviceGroupPeerMemoryFeatures") - set_proc_address(&GetDeviceGroupPeerMemoryFeaturesKHR, "vkGetDeviceGroupPeerMemoryFeaturesKHR") - set_proc_address(&GetDeviceGroupPresentCapabilitiesKHR, "vkGetDeviceGroupPresentCapabilitiesKHR") - set_proc_address(&GetDeviceGroupSurfacePresentModes2EXT, "vkGetDeviceGroupSurfacePresentModes2EXT") - set_proc_address(&GetDeviceGroupSurfacePresentModesKHR, "vkGetDeviceGroupSurfacePresentModesKHR") - set_proc_address(&GetDeviceImageMemoryRequirements, "vkGetDeviceImageMemoryRequirements") - set_proc_address(&GetDeviceImageMemoryRequirementsKHR, "vkGetDeviceImageMemoryRequirementsKHR") - set_proc_address(&GetDeviceImageSparseMemoryRequirements, "vkGetDeviceImageSparseMemoryRequirements") - set_proc_address(&GetDeviceImageSparseMemoryRequirementsKHR, "vkGetDeviceImageSparseMemoryRequirementsKHR") - set_proc_address(&GetDeviceMemoryCommitment, "vkGetDeviceMemoryCommitment") - set_proc_address(&GetDeviceMemoryOpaqueCaptureAddress, "vkGetDeviceMemoryOpaqueCaptureAddress") - set_proc_address(&GetDeviceMemoryOpaqueCaptureAddressKHR, "vkGetDeviceMemoryOpaqueCaptureAddressKHR") - set_proc_address(&GetDeviceProcAddr, "vkGetDeviceProcAddr") - set_proc_address(&GetDeviceQueue, "vkGetDeviceQueue") - set_proc_address(&GetDeviceQueue2, "vkGetDeviceQueue2") - set_proc_address(&GetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI, "vkGetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI") - set_proc_address(&GetEventStatus, "vkGetEventStatus") - set_proc_address(&GetFenceFdKHR, "vkGetFenceFdKHR") - set_proc_address(&GetFenceStatus, "vkGetFenceStatus") - set_proc_address(&GetFenceWin32HandleKHR, "vkGetFenceWin32HandleKHR") - set_proc_address(&GetGeneratedCommandsMemoryRequirementsNV, "vkGetGeneratedCommandsMemoryRequirementsNV") - set_proc_address(&GetImageDrmFormatModifierPropertiesEXT, "vkGetImageDrmFormatModifierPropertiesEXT") - set_proc_address(&GetImageMemoryRequirements, "vkGetImageMemoryRequirements") - set_proc_address(&GetImageMemoryRequirements2, "vkGetImageMemoryRequirements2") - set_proc_address(&GetImageMemoryRequirements2KHR, "vkGetImageMemoryRequirements2KHR") - set_proc_address(&GetImageSparseMemoryRequirements, "vkGetImageSparseMemoryRequirements") - set_proc_address(&GetImageSparseMemoryRequirements2, "vkGetImageSparseMemoryRequirements2") - set_proc_address(&GetImageSparseMemoryRequirements2KHR, "vkGetImageSparseMemoryRequirements2KHR") - set_proc_address(&GetImageSubresourceLayout, "vkGetImageSubresourceLayout") - set_proc_address(&GetImageViewAddressNVX, "vkGetImageViewAddressNVX") - set_proc_address(&GetImageViewHandleNVX, "vkGetImageViewHandleNVX") - set_proc_address(&GetMemoryFdKHR, "vkGetMemoryFdKHR") - set_proc_address(&GetMemoryFdPropertiesKHR, "vkGetMemoryFdPropertiesKHR") - set_proc_address(&GetMemoryHostPointerPropertiesEXT, "vkGetMemoryHostPointerPropertiesEXT") - set_proc_address(&GetMemoryRemoteAddressNV, "vkGetMemoryRemoteAddressNV") - set_proc_address(&GetMemoryWin32HandleKHR, "vkGetMemoryWin32HandleKHR") - set_proc_address(&GetMemoryWin32HandleNV, "vkGetMemoryWin32HandleNV") - set_proc_address(&GetMemoryWin32HandlePropertiesKHR, "vkGetMemoryWin32HandlePropertiesKHR") - set_proc_address(&GetPastPresentationTimingGOOGLE, "vkGetPastPresentationTimingGOOGLE") - set_proc_address(&GetPerformanceParameterINTEL, "vkGetPerformanceParameterINTEL") - set_proc_address(&GetPipelineCacheData, "vkGetPipelineCacheData") - set_proc_address(&GetPipelineExecutableInternalRepresentationsKHR, "vkGetPipelineExecutableInternalRepresentationsKHR") - set_proc_address(&GetPipelineExecutablePropertiesKHR, "vkGetPipelineExecutablePropertiesKHR") - set_proc_address(&GetPipelineExecutableStatisticsKHR, "vkGetPipelineExecutableStatisticsKHR") - set_proc_address(&GetPrivateData, "vkGetPrivateData") - set_proc_address(&GetPrivateDataEXT, "vkGetPrivateDataEXT") - set_proc_address(&GetQueryPoolResults, "vkGetQueryPoolResults") - set_proc_address(&GetQueueCheckpointData2NV, "vkGetQueueCheckpointData2NV") - set_proc_address(&GetQueueCheckpointDataNV, "vkGetQueueCheckpointDataNV") - set_proc_address(&GetRayTracingCaptureReplayShaderGroupHandlesKHR, "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR") - set_proc_address(&GetRayTracingShaderGroupHandlesKHR, "vkGetRayTracingShaderGroupHandlesKHR") - set_proc_address(&GetRayTracingShaderGroupHandlesNV, "vkGetRayTracingShaderGroupHandlesNV") - set_proc_address(&GetRayTracingShaderGroupStackSizeKHR, "vkGetRayTracingShaderGroupStackSizeKHR") - set_proc_address(&GetRefreshCycleDurationGOOGLE, "vkGetRefreshCycleDurationGOOGLE") - set_proc_address(&GetRenderAreaGranularity, "vkGetRenderAreaGranularity") - set_proc_address(&GetSemaphoreCounterValue, "vkGetSemaphoreCounterValue") - set_proc_address(&GetSemaphoreCounterValueKHR, "vkGetSemaphoreCounterValueKHR") - set_proc_address(&GetSemaphoreFdKHR, "vkGetSemaphoreFdKHR") - set_proc_address(&GetSemaphoreWin32HandleKHR, "vkGetSemaphoreWin32HandleKHR") - set_proc_address(&GetShaderInfoAMD, "vkGetShaderInfoAMD") - set_proc_address(&GetSwapchainCounterEXT, "vkGetSwapchainCounterEXT") - set_proc_address(&GetSwapchainImagesKHR, "vkGetSwapchainImagesKHR") - set_proc_address(&GetSwapchainStatusKHR, "vkGetSwapchainStatusKHR") - set_proc_address(&GetValidationCacheDataEXT, "vkGetValidationCacheDataEXT") - set_proc_address(&ImportFenceFdKHR, "vkImportFenceFdKHR") - set_proc_address(&ImportFenceWin32HandleKHR, "vkImportFenceWin32HandleKHR") - set_proc_address(&ImportSemaphoreFdKHR, "vkImportSemaphoreFdKHR") - set_proc_address(&ImportSemaphoreWin32HandleKHR, "vkImportSemaphoreWin32HandleKHR") - set_proc_address(&InitializePerformanceApiINTEL, "vkInitializePerformanceApiINTEL") - set_proc_address(&InvalidateMappedMemoryRanges, "vkInvalidateMappedMemoryRanges") - set_proc_address(&MapMemory, "vkMapMemory") - set_proc_address(&MergePipelineCaches, "vkMergePipelineCaches") - set_proc_address(&MergeValidationCachesEXT, "vkMergeValidationCachesEXT") - set_proc_address(&QueueBeginDebugUtilsLabelEXT, "vkQueueBeginDebugUtilsLabelEXT") - set_proc_address(&QueueBindSparse, "vkQueueBindSparse") - set_proc_address(&QueueEndDebugUtilsLabelEXT, "vkQueueEndDebugUtilsLabelEXT") - set_proc_address(&QueueInsertDebugUtilsLabelEXT, "vkQueueInsertDebugUtilsLabelEXT") - set_proc_address(&QueuePresentKHR, "vkQueuePresentKHR") - set_proc_address(&QueueSetPerformanceConfigurationINTEL, "vkQueueSetPerformanceConfigurationINTEL") - set_proc_address(&QueueSubmit, "vkQueueSubmit") - set_proc_address(&QueueSubmit2, "vkQueueSubmit2") - set_proc_address(&QueueSubmit2KHR, "vkQueueSubmit2KHR") - set_proc_address(&QueueWaitIdle, "vkQueueWaitIdle") - set_proc_address(&RegisterDeviceEventEXT, "vkRegisterDeviceEventEXT") - set_proc_address(&RegisterDisplayEventEXT, "vkRegisterDisplayEventEXT") - set_proc_address(&ReleaseFullScreenExclusiveModeEXT, "vkReleaseFullScreenExclusiveModeEXT") - set_proc_address(&ReleasePerformanceConfigurationINTEL, "vkReleasePerformanceConfigurationINTEL") - set_proc_address(&ReleaseProfilingLockKHR, "vkReleaseProfilingLockKHR") - set_proc_address(&ResetCommandBuffer, "vkResetCommandBuffer") - set_proc_address(&ResetCommandPool, "vkResetCommandPool") - set_proc_address(&ResetDescriptorPool, "vkResetDescriptorPool") - set_proc_address(&ResetEvent, "vkResetEvent") - set_proc_address(&ResetFences, "vkResetFences") - set_proc_address(&ResetQueryPool, "vkResetQueryPool") - set_proc_address(&ResetQueryPoolEXT, "vkResetQueryPoolEXT") - set_proc_address(&SetDebugUtilsObjectNameEXT, "vkSetDebugUtilsObjectNameEXT") - set_proc_address(&SetDebugUtilsObjectTagEXT, "vkSetDebugUtilsObjectTagEXT") - set_proc_address(&SetDeviceMemoryPriorityEXT, "vkSetDeviceMemoryPriorityEXT") - set_proc_address(&SetEvent, "vkSetEvent") - set_proc_address(&SetHdrMetadataEXT, "vkSetHdrMetadataEXT") - set_proc_address(&SetLocalDimmingAMD, "vkSetLocalDimmingAMD") - set_proc_address(&SetPrivateData, "vkSetPrivateData") - set_proc_address(&SetPrivateDataEXT, "vkSetPrivateDataEXT") - set_proc_address(&SignalSemaphore, "vkSignalSemaphore") - set_proc_address(&SignalSemaphoreKHR, "vkSignalSemaphoreKHR") - set_proc_address(&TrimCommandPool, "vkTrimCommandPool") - set_proc_address(&TrimCommandPoolKHR, "vkTrimCommandPoolKHR") - set_proc_address(&UninitializePerformanceApiINTEL, "vkUninitializePerformanceApiINTEL") - set_proc_address(&UnmapMemory, "vkUnmapMemory") - set_proc_address(&UpdateDescriptorSetWithTemplate, "vkUpdateDescriptorSetWithTemplate") - set_proc_address(&UpdateDescriptorSetWithTemplateKHR, "vkUpdateDescriptorSetWithTemplateKHR") - set_proc_address(&UpdateDescriptorSets, "vkUpdateDescriptorSets") - set_proc_address(&WaitForFences, "vkWaitForFences") - set_proc_address(&WaitForPresentKHR, "vkWaitForPresentKHR") - set_proc_address(&WaitSemaphores, "vkWaitSemaphores") - set_proc_address(&WaitSemaphoresKHR, "vkWaitSemaphoresKHR") - set_proc_address(&WriteAccelerationStructuresPropertiesKHR, "vkWriteAccelerationStructuresPropertiesKHR") - -} - -// Device Procedure VTable -Device_VTable :: struct { - AcquireFullScreenExclusiveModeEXT: ProcAcquireFullScreenExclusiveModeEXT, - AcquireNextImage2KHR: ProcAcquireNextImage2KHR, - AcquireNextImageKHR: ProcAcquireNextImageKHR, - AcquirePerformanceConfigurationINTEL: ProcAcquirePerformanceConfigurationINTEL, - AcquireProfilingLockKHR: ProcAcquireProfilingLockKHR, - AllocateCommandBuffers: ProcAllocateCommandBuffers, - AllocateDescriptorSets: ProcAllocateDescriptorSets, - AllocateMemory: ProcAllocateMemory, - BeginCommandBuffer: ProcBeginCommandBuffer, - BindAccelerationStructureMemoryNV: ProcBindAccelerationStructureMemoryNV, - BindBufferMemory: ProcBindBufferMemory, - BindBufferMemory2: ProcBindBufferMemory2, - BindBufferMemory2KHR: ProcBindBufferMemory2KHR, - BindImageMemory: ProcBindImageMemory, - BindImageMemory2: ProcBindImageMemory2, - BindImageMemory2KHR: ProcBindImageMemory2KHR, - BuildAccelerationStructuresKHR: ProcBuildAccelerationStructuresKHR, - CmdBeginConditionalRenderingEXT: ProcCmdBeginConditionalRenderingEXT, - CmdBeginDebugUtilsLabelEXT: ProcCmdBeginDebugUtilsLabelEXT, - CmdBeginQuery: ProcCmdBeginQuery, - CmdBeginQueryIndexedEXT: ProcCmdBeginQueryIndexedEXT, - CmdBeginRenderPass: ProcCmdBeginRenderPass, - CmdBeginRenderPass2: ProcCmdBeginRenderPass2, - CmdBeginRenderPass2KHR: ProcCmdBeginRenderPass2KHR, - CmdBeginRendering: ProcCmdBeginRendering, - CmdBeginRenderingKHR: ProcCmdBeginRenderingKHR, - CmdBeginTransformFeedbackEXT: ProcCmdBeginTransformFeedbackEXT, - CmdBindDescriptorSets: ProcCmdBindDescriptorSets, - CmdBindIndexBuffer: ProcCmdBindIndexBuffer, - CmdBindInvocationMaskHUAWEI: ProcCmdBindInvocationMaskHUAWEI, - CmdBindPipeline: ProcCmdBindPipeline, - CmdBindPipelineShaderGroupNV: ProcCmdBindPipelineShaderGroupNV, - CmdBindShadingRateImageNV: ProcCmdBindShadingRateImageNV, - CmdBindTransformFeedbackBuffersEXT: ProcCmdBindTransformFeedbackBuffersEXT, - CmdBindVertexBuffers: ProcCmdBindVertexBuffers, - CmdBindVertexBuffers2: ProcCmdBindVertexBuffers2, - CmdBindVertexBuffers2EXT: ProcCmdBindVertexBuffers2EXT, - CmdBlitImage: ProcCmdBlitImage, - CmdBlitImage2: ProcCmdBlitImage2, - CmdBlitImage2KHR: ProcCmdBlitImage2KHR, - CmdBuildAccelerationStructureNV: ProcCmdBuildAccelerationStructureNV, - CmdBuildAccelerationStructuresIndirectKHR: ProcCmdBuildAccelerationStructuresIndirectKHR, - CmdBuildAccelerationStructuresKHR: ProcCmdBuildAccelerationStructuresKHR, - CmdClearAttachments: ProcCmdClearAttachments, - CmdClearColorImage: ProcCmdClearColorImage, - CmdClearDepthStencilImage: ProcCmdClearDepthStencilImage, - CmdCopyAccelerationStructureKHR: ProcCmdCopyAccelerationStructureKHR, - CmdCopyAccelerationStructureNV: ProcCmdCopyAccelerationStructureNV, - CmdCopyAccelerationStructureToMemoryKHR: ProcCmdCopyAccelerationStructureToMemoryKHR, - CmdCopyBuffer: ProcCmdCopyBuffer, - CmdCopyBuffer2: ProcCmdCopyBuffer2, - CmdCopyBuffer2KHR: ProcCmdCopyBuffer2KHR, - CmdCopyBufferToImage: ProcCmdCopyBufferToImage, - CmdCopyBufferToImage2: ProcCmdCopyBufferToImage2, - CmdCopyBufferToImage2KHR: ProcCmdCopyBufferToImage2KHR, - CmdCopyImage: ProcCmdCopyImage, - CmdCopyImage2: ProcCmdCopyImage2, - CmdCopyImage2KHR: ProcCmdCopyImage2KHR, - CmdCopyImageToBuffer: ProcCmdCopyImageToBuffer, - CmdCopyImageToBuffer2: ProcCmdCopyImageToBuffer2, - CmdCopyImageToBuffer2KHR: ProcCmdCopyImageToBuffer2KHR, - CmdCopyMemoryToAccelerationStructureKHR: ProcCmdCopyMemoryToAccelerationStructureKHR, - CmdCopyQueryPoolResults: ProcCmdCopyQueryPoolResults, - CmdCuLaunchKernelNVX: ProcCmdCuLaunchKernelNVX, - CmdDebugMarkerBeginEXT: ProcCmdDebugMarkerBeginEXT, - CmdDebugMarkerEndEXT: ProcCmdDebugMarkerEndEXT, - CmdDebugMarkerInsertEXT: ProcCmdDebugMarkerInsertEXT, - CmdDispatch: ProcCmdDispatch, - CmdDispatchBase: ProcCmdDispatchBase, - CmdDispatchBaseKHR: ProcCmdDispatchBaseKHR, - CmdDispatchIndirect: ProcCmdDispatchIndirect, - CmdDraw: ProcCmdDraw, - CmdDrawIndexed: ProcCmdDrawIndexed, - CmdDrawIndexedIndirect: ProcCmdDrawIndexedIndirect, - CmdDrawIndexedIndirectCount: ProcCmdDrawIndexedIndirectCount, - CmdDrawIndexedIndirectCountAMD: ProcCmdDrawIndexedIndirectCountAMD, - CmdDrawIndexedIndirectCountKHR: ProcCmdDrawIndexedIndirectCountKHR, - CmdDrawIndirect: ProcCmdDrawIndirect, - CmdDrawIndirectByteCountEXT: ProcCmdDrawIndirectByteCountEXT, - CmdDrawIndirectCount: ProcCmdDrawIndirectCount, - CmdDrawIndirectCountAMD: ProcCmdDrawIndirectCountAMD, - CmdDrawIndirectCountKHR: ProcCmdDrawIndirectCountKHR, - CmdDrawMeshTasksIndirectCountNV: ProcCmdDrawMeshTasksIndirectCountNV, - CmdDrawMeshTasksIndirectNV: ProcCmdDrawMeshTasksIndirectNV, - CmdDrawMeshTasksNV: ProcCmdDrawMeshTasksNV, - CmdDrawMultiEXT: ProcCmdDrawMultiEXT, - CmdDrawMultiIndexedEXT: ProcCmdDrawMultiIndexedEXT, - CmdEndConditionalRenderingEXT: ProcCmdEndConditionalRenderingEXT, - CmdEndDebugUtilsLabelEXT: ProcCmdEndDebugUtilsLabelEXT, - CmdEndQuery: ProcCmdEndQuery, - CmdEndQueryIndexedEXT: ProcCmdEndQueryIndexedEXT, - CmdEndRenderPass: ProcCmdEndRenderPass, - CmdEndRenderPass2: ProcCmdEndRenderPass2, - CmdEndRenderPass2KHR: ProcCmdEndRenderPass2KHR, - CmdEndRendering: ProcCmdEndRendering, - CmdEndRenderingKHR: ProcCmdEndRenderingKHR, - CmdEndTransformFeedbackEXT: ProcCmdEndTransformFeedbackEXT, - CmdExecuteCommands: ProcCmdExecuteCommands, - CmdExecuteGeneratedCommandsNV: ProcCmdExecuteGeneratedCommandsNV, - CmdFillBuffer: ProcCmdFillBuffer, - CmdInsertDebugUtilsLabelEXT: ProcCmdInsertDebugUtilsLabelEXT, - CmdNextSubpass: ProcCmdNextSubpass, - CmdNextSubpass2: ProcCmdNextSubpass2, - CmdNextSubpass2KHR: ProcCmdNextSubpass2KHR, - CmdPipelineBarrier: ProcCmdPipelineBarrier, - CmdPipelineBarrier2: ProcCmdPipelineBarrier2, - CmdPipelineBarrier2KHR: ProcCmdPipelineBarrier2KHR, - CmdPreprocessGeneratedCommandsNV: ProcCmdPreprocessGeneratedCommandsNV, - CmdPushConstants: ProcCmdPushConstants, - CmdPushDescriptorSetKHR: ProcCmdPushDescriptorSetKHR, - CmdPushDescriptorSetWithTemplateKHR: ProcCmdPushDescriptorSetWithTemplateKHR, - CmdResetEvent: ProcCmdResetEvent, - CmdResetEvent2: ProcCmdResetEvent2, - CmdResetEvent2KHR: ProcCmdResetEvent2KHR, - CmdResetQueryPool: ProcCmdResetQueryPool, - CmdResolveImage: ProcCmdResolveImage, - CmdResolveImage2: ProcCmdResolveImage2, - CmdResolveImage2KHR: ProcCmdResolveImage2KHR, - CmdSetBlendConstants: ProcCmdSetBlendConstants, - CmdSetCheckpointNV: ProcCmdSetCheckpointNV, - CmdSetCoarseSampleOrderNV: ProcCmdSetCoarseSampleOrderNV, - CmdSetCullMode: ProcCmdSetCullMode, - CmdSetCullModeEXT: ProcCmdSetCullModeEXT, - CmdSetDepthBias: ProcCmdSetDepthBias, - CmdSetDepthBiasEnable: ProcCmdSetDepthBiasEnable, - CmdSetDepthBiasEnableEXT: ProcCmdSetDepthBiasEnableEXT, - CmdSetDepthBounds: ProcCmdSetDepthBounds, - CmdSetDepthBoundsTestEnable: ProcCmdSetDepthBoundsTestEnable, - CmdSetDepthBoundsTestEnableEXT: ProcCmdSetDepthBoundsTestEnableEXT, - CmdSetDepthCompareOp: ProcCmdSetDepthCompareOp, - CmdSetDepthCompareOpEXT: ProcCmdSetDepthCompareOpEXT, - CmdSetDepthTestEnable: ProcCmdSetDepthTestEnable, - CmdSetDepthTestEnableEXT: ProcCmdSetDepthTestEnableEXT, - CmdSetDepthWriteEnable: ProcCmdSetDepthWriteEnable, - CmdSetDepthWriteEnableEXT: ProcCmdSetDepthWriteEnableEXT, - CmdSetDeviceMask: ProcCmdSetDeviceMask, - CmdSetDeviceMaskKHR: ProcCmdSetDeviceMaskKHR, - CmdSetDiscardRectangleEXT: ProcCmdSetDiscardRectangleEXT, - CmdSetEvent: ProcCmdSetEvent, - CmdSetEvent2: ProcCmdSetEvent2, - CmdSetEvent2KHR: ProcCmdSetEvent2KHR, - CmdSetExclusiveScissorNV: ProcCmdSetExclusiveScissorNV, - CmdSetFragmentShadingRateEnumNV: ProcCmdSetFragmentShadingRateEnumNV, - CmdSetFragmentShadingRateKHR: ProcCmdSetFragmentShadingRateKHR, - CmdSetFrontFace: ProcCmdSetFrontFace, - CmdSetFrontFaceEXT: ProcCmdSetFrontFaceEXT, - CmdSetLineStippleEXT: ProcCmdSetLineStippleEXT, - CmdSetLineWidth: ProcCmdSetLineWidth, - CmdSetLogicOpEXT: ProcCmdSetLogicOpEXT, - CmdSetPatchControlPointsEXT: ProcCmdSetPatchControlPointsEXT, - CmdSetPerformanceMarkerINTEL: ProcCmdSetPerformanceMarkerINTEL, - CmdSetPerformanceOverrideINTEL: ProcCmdSetPerformanceOverrideINTEL, - CmdSetPerformanceStreamMarkerINTEL: ProcCmdSetPerformanceStreamMarkerINTEL, - CmdSetPrimitiveRestartEnable: ProcCmdSetPrimitiveRestartEnable, - CmdSetPrimitiveRestartEnableEXT: ProcCmdSetPrimitiveRestartEnableEXT, - CmdSetPrimitiveTopology: ProcCmdSetPrimitiveTopology, - CmdSetPrimitiveTopologyEXT: ProcCmdSetPrimitiveTopologyEXT, - CmdSetRasterizerDiscardEnable: ProcCmdSetRasterizerDiscardEnable, - CmdSetRasterizerDiscardEnableEXT: ProcCmdSetRasterizerDiscardEnableEXT, - CmdSetRayTracingPipelineStackSizeKHR: ProcCmdSetRayTracingPipelineStackSizeKHR, - CmdSetSampleLocationsEXT: ProcCmdSetSampleLocationsEXT, - CmdSetScissor: ProcCmdSetScissor, - CmdSetScissorWithCount: ProcCmdSetScissorWithCount, - CmdSetScissorWithCountEXT: ProcCmdSetScissorWithCountEXT, - CmdSetStencilCompareMask: ProcCmdSetStencilCompareMask, - CmdSetStencilOp: ProcCmdSetStencilOp, - CmdSetStencilOpEXT: ProcCmdSetStencilOpEXT, - CmdSetStencilReference: ProcCmdSetStencilReference, - CmdSetStencilTestEnable: ProcCmdSetStencilTestEnable, - CmdSetStencilTestEnableEXT: ProcCmdSetStencilTestEnableEXT, - CmdSetStencilWriteMask: ProcCmdSetStencilWriteMask, - CmdSetVertexInputEXT: ProcCmdSetVertexInputEXT, - CmdSetViewport: ProcCmdSetViewport, - CmdSetViewportShadingRatePaletteNV: ProcCmdSetViewportShadingRatePaletteNV, - CmdSetViewportWScalingNV: ProcCmdSetViewportWScalingNV, - CmdSetViewportWithCount: ProcCmdSetViewportWithCount, - CmdSetViewportWithCountEXT: ProcCmdSetViewportWithCountEXT, - CmdSubpassShadingHUAWEI: ProcCmdSubpassShadingHUAWEI, - CmdTraceRaysIndirectKHR: ProcCmdTraceRaysIndirectKHR, - CmdTraceRaysKHR: ProcCmdTraceRaysKHR, - CmdTraceRaysNV: ProcCmdTraceRaysNV, - CmdUpdateBuffer: ProcCmdUpdateBuffer, - CmdWaitEvents: ProcCmdWaitEvents, - CmdWaitEvents2: ProcCmdWaitEvents2, - CmdWaitEvents2KHR: ProcCmdWaitEvents2KHR, - CmdWriteAccelerationStructuresPropertiesKHR: ProcCmdWriteAccelerationStructuresPropertiesKHR, - CmdWriteAccelerationStructuresPropertiesNV: ProcCmdWriteAccelerationStructuresPropertiesNV, - CmdWriteBufferMarker2AMD: ProcCmdWriteBufferMarker2AMD, - CmdWriteBufferMarkerAMD: ProcCmdWriteBufferMarkerAMD, - CmdWriteTimestamp: ProcCmdWriteTimestamp, - CmdWriteTimestamp2: ProcCmdWriteTimestamp2, - CmdWriteTimestamp2KHR: ProcCmdWriteTimestamp2KHR, - CompileDeferredNV: ProcCompileDeferredNV, - CopyAccelerationStructureKHR: ProcCopyAccelerationStructureKHR, - CopyAccelerationStructureToMemoryKHR: ProcCopyAccelerationStructureToMemoryKHR, - CopyMemoryToAccelerationStructureKHR: ProcCopyMemoryToAccelerationStructureKHR, - CreateAccelerationStructureKHR: ProcCreateAccelerationStructureKHR, - CreateAccelerationStructureNV: ProcCreateAccelerationStructureNV, - CreateBuffer: ProcCreateBuffer, - CreateBufferView: ProcCreateBufferView, - CreateCommandPool: ProcCreateCommandPool, - CreateComputePipelines: ProcCreateComputePipelines, - CreateCuFunctionNVX: ProcCreateCuFunctionNVX, - CreateCuModuleNVX: ProcCreateCuModuleNVX, - CreateDeferredOperationKHR: ProcCreateDeferredOperationKHR, - CreateDescriptorPool: ProcCreateDescriptorPool, - CreateDescriptorSetLayout: ProcCreateDescriptorSetLayout, - CreateDescriptorUpdateTemplate: ProcCreateDescriptorUpdateTemplate, - CreateDescriptorUpdateTemplateKHR: ProcCreateDescriptorUpdateTemplateKHR, - CreateEvent: ProcCreateEvent, - CreateFence: ProcCreateFence, - CreateFramebuffer: ProcCreateFramebuffer, - CreateGraphicsPipelines: ProcCreateGraphicsPipelines, - CreateImage: ProcCreateImage, - CreateImageView: ProcCreateImageView, - CreateIndirectCommandsLayoutNV: ProcCreateIndirectCommandsLayoutNV, - CreatePipelineCache: ProcCreatePipelineCache, - CreatePipelineLayout: ProcCreatePipelineLayout, - CreatePrivateDataSlot: ProcCreatePrivateDataSlot, - CreatePrivateDataSlotEXT: ProcCreatePrivateDataSlotEXT, - CreateQueryPool: ProcCreateQueryPool, - CreateRayTracingPipelinesKHR: ProcCreateRayTracingPipelinesKHR, - CreateRayTracingPipelinesNV: ProcCreateRayTracingPipelinesNV, - CreateRenderPass: ProcCreateRenderPass, - CreateRenderPass2: ProcCreateRenderPass2, - CreateRenderPass2KHR: ProcCreateRenderPass2KHR, - CreateSampler: ProcCreateSampler, - CreateSamplerYcbcrConversion: ProcCreateSamplerYcbcrConversion, - CreateSamplerYcbcrConversionKHR: ProcCreateSamplerYcbcrConversionKHR, - CreateSemaphore: ProcCreateSemaphore, - CreateShaderModule: ProcCreateShaderModule, - CreateSharedSwapchainsKHR: ProcCreateSharedSwapchainsKHR, - CreateSwapchainKHR: ProcCreateSwapchainKHR, - CreateValidationCacheEXT: ProcCreateValidationCacheEXT, - DebugMarkerSetObjectNameEXT: ProcDebugMarkerSetObjectNameEXT, - DebugMarkerSetObjectTagEXT: ProcDebugMarkerSetObjectTagEXT, - DeferredOperationJoinKHR: ProcDeferredOperationJoinKHR, - DestroyAccelerationStructureKHR: ProcDestroyAccelerationStructureKHR, - DestroyAccelerationStructureNV: ProcDestroyAccelerationStructureNV, - DestroyBuffer: ProcDestroyBuffer, - DestroyBufferView: ProcDestroyBufferView, - DestroyCommandPool: ProcDestroyCommandPool, - DestroyCuFunctionNVX: ProcDestroyCuFunctionNVX, - DestroyCuModuleNVX: ProcDestroyCuModuleNVX, - DestroyDeferredOperationKHR: ProcDestroyDeferredOperationKHR, - DestroyDescriptorPool: ProcDestroyDescriptorPool, - DestroyDescriptorSetLayout: ProcDestroyDescriptorSetLayout, - DestroyDescriptorUpdateTemplate: ProcDestroyDescriptorUpdateTemplate, - DestroyDescriptorUpdateTemplateKHR: ProcDestroyDescriptorUpdateTemplateKHR, - DestroyDevice: ProcDestroyDevice, - DestroyEvent: ProcDestroyEvent, - DestroyFence: ProcDestroyFence, - DestroyFramebuffer: ProcDestroyFramebuffer, - DestroyImage: ProcDestroyImage, - DestroyImageView: ProcDestroyImageView, - DestroyIndirectCommandsLayoutNV: ProcDestroyIndirectCommandsLayoutNV, - DestroyPipeline: ProcDestroyPipeline, - DestroyPipelineCache: ProcDestroyPipelineCache, - DestroyPipelineLayout: ProcDestroyPipelineLayout, - DestroyPrivateDataSlot: ProcDestroyPrivateDataSlot, - DestroyPrivateDataSlotEXT: ProcDestroyPrivateDataSlotEXT, - DestroyQueryPool: ProcDestroyQueryPool, - DestroyRenderPass: ProcDestroyRenderPass, - DestroySampler: ProcDestroySampler, - DestroySamplerYcbcrConversion: ProcDestroySamplerYcbcrConversion, - DestroySamplerYcbcrConversionKHR: ProcDestroySamplerYcbcrConversionKHR, - DestroySemaphore: ProcDestroySemaphore, - DestroyShaderModule: ProcDestroyShaderModule, - DestroySwapchainKHR: ProcDestroySwapchainKHR, - DestroyValidationCacheEXT: ProcDestroyValidationCacheEXT, - DeviceWaitIdle: ProcDeviceWaitIdle, - DisplayPowerControlEXT: ProcDisplayPowerControlEXT, - EndCommandBuffer: ProcEndCommandBuffer, - FlushMappedMemoryRanges: ProcFlushMappedMemoryRanges, - FreeCommandBuffers: ProcFreeCommandBuffers, - FreeDescriptorSets: ProcFreeDescriptorSets, - FreeMemory: ProcFreeMemory, - GetAccelerationStructureBuildSizesKHR: ProcGetAccelerationStructureBuildSizesKHR, - GetAccelerationStructureDeviceAddressKHR: ProcGetAccelerationStructureDeviceAddressKHR, - GetAccelerationStructureHandleNV: ProcGetAccelerationStructureHandleNV, - GetAccelerationStructureMemoryRequirementsNV: ProcGetAccelerationStructureMemoryRequirementsNV, - GetBufferDeviceAddress: ProcGetBufferDeviceAddress, - GetBufferDeviceAddressEXT: ProcGetBufferDeviceAddressEXT, - GetBufferDeviceAddressKHR: ProcGetBufferDeviceAddressKHR, - GetBufferMemoryRequirements: ProcGetBufferMemoryRequirements, - GetBufferMemoryRequirements2: ProcGetBufferMemoryRequirements2, - GetBufferMemoryRequirements2KHR: ProcGetBufferMemoryRequirements2KHR, - GetBufferOpaqueCaptureAddress: ProcGetBufferOpaqueCaptureAddress, - GetBufferOpaqueCaptureAddressKHR: ProcGetBufferOpaqueCaptureAddressKHR, - GetCalibratedTimestampsEXT: ProcGetCalibratedTimestampsEXT, - GetDeferredOperationMaxConcurrencyKHR: ProcGetDeferredOperationMaxConcurrencyKHR, - GetDeferredOperationResultKHR: ProcGetDeferredOperationResultKHR, - GetDescriptorSetHostMappingVALVE: ProcGetDescriptorSetHostMappingVALVE, - GetDescriptorSetLayoutHostMappingInfoVALVE: ProcGetDescriptorSetLayoutHostMappingInfoVALVE, - GetDescriptorSetLayoutSupport: ProcGetDescriptorSetLayoutSupport, - GetDescriptorSetLayoutSupportKHR: ProcGetDescriptorSetLayoutSupportKHR, - GetDeviceAccelerationStructureCompatibilityKHR: ProcGetDeviceAccelerationStructureCompatibilityKHR, - GetDeviceBufferMemoryRequirements: ProcGetDeviceBufferMemoryRequirements, - GetDeviceBufferMemoryRequirementsKHR: ProcGetDeviceBufferMemoryRequirementsKHR, - GetDeviceGroupPeerMemoryFeatures: ProcGetDeviceGroupPeerMemoryFeatures, - GetDeviceGroupPeerMemoryFeaturesKHR: ProcGetDeviceGroupPeerMemoryFeaturesKHR, - GetDeviceGroupPresentCapabilitiesKHR: ProcGetDeviceGroupPresentCapabilitiesKHR, - GetDeviceGroupSurfacePresentModes2EXT: ProcGetDeviceGroupSurfacePresentModes2EXT, - GetDeviceGroupSurfacePresentModesKHR: ProcGetDeviceGroupSurfacePresentModesKHR, - GetDeviceImageMemoryRequirements: ProcGetDeviceImageMemoryRequirements, - GetDeviceImageMemoryRequirementsKHR: ProcGetDeviceImageMemoryRequirementsKHR, - GetDeviceImageSparseMemoryRequirements: ProcGetDeviceImageSparseMemoryRequirements, - GetDeviceImageSparseMemoryRequirementsKHR: ProcGetDeviceImageSparseMemoryRequirementsKHR, - GetDeviceMemoryCommitment: ProcGetDeviceMemoryCommitment, - GetDeviceMemoryOpaqueCaptureAddress: ProcGetDeviceMemoryOpaqueCaptureAddress, - GetDeviceMemoryOpaqueCaptureAddressKHR: ProcGetDeviceMemoryOpaqueCaptureAddressKHR, - GetDeviceProcAddr: ProcGetDeviceProcAddr, - GetDeviceQueue: ProcGetDeviceQueue, - GetDeviceQueue2: ProcGetDeviceQueue2, - GetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI: ProcGetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI, - GetEventStatus: ProcGetEventStatus, - GetFenceFdKHR: ProcGetFenceFdKHR, - GetFenceStatus: ProcGetFenceStatus, - GetFenceWin32HandleKHR: ProcGetFenceWin32HandleKHR, - GetGeneratedCommandsMemoryRequirementsNV: ProcGetGeneratedCommandsMemoryRequirementsNV, - GetImageDrmFormatModifierPropertiesEXT: ProcGetImageDrmFormatModifierPropertiesEXT, - GetImageMemoryRequirements: ProcGetImageMemoryRequirements, - GetImageMemoryRequirements2: ProcGetImageMemoryRequirements2, - GetImageMemoryRequirements2KHR: ProcGetImageMemoryRequirements2KHR, - GetImageSparseMemoryRequirements: ProcGetImageSparseMemoryRequirements, - GetImageSparseMemoryRequirements2: ProcGetImageSparseMemoryRequirements2, - GetImageSparseMemoryRequirements2KHR: ProcGetImageSparseMemoryRequirements2KHR, - GetImageSubresourceLayout: ProcGetImageSubresourceLayout, - GetImageViewAddressNVX: ProcGetImageViewAddressNVX, - GetImageViewHandleNVX: ProcGetImageViewHandleNVX, - GetMemoryFdKHR: ProcGetMemoryFdKHR, - GetMemoryFdPropertiesKHR: ProcGetMemoryFdPropertiesKHR, - GetMemoryHostPointerPropertiesEXT: ProcGetMemoryHostPointerPropertiesEXT, - GetMemoryRemoteAddressNV: ProcGetMemoryRemoteAddressNV, - GetMemoryWin32HandleKHR: ProcGetMemoryWin32HandleKHR, - GetMemoryWin32HandleNV: ProcGetMemoryWin32HandleNV, - GetMemoryWin32HandlePropertiesKHR: ProcGetMemoryWin32HandlePropertiesKHR, - GetPastPresentationTimingGOOGLE: ProcGetPastPresentationTimingGOOGLE, - GetPerformanceParameterINTEL: ProcGetPerformanceParameterINTEL, - GetPipelineCacheData: ProcGetPipelineCacheData, - GetPipelineExecutableInternalRepresentationsKHR: ProcGetPipelineExecutableInternalRepresentationsKHR, - GetPipelineExecutablePropertiesKHR: ProcGetPipelineExecutablePropertiesKHR, - GetPipelineExecutableStatisticsKHR: ProcGetPipelineExecutableStatisticsKHR, - GetPrivateData: ProcGetPrivateData, - GetPrivateDataEXT: ProcGetPrivateDataEXT, - GetQueryPoolResults: ProcGetQueryPoolResults, - GetQueueCheckpointData2NV: ProcGetQueueCheckpointData2NV, - GetQueueCheckpointDataNV: ProcGetQueueCheckpointDataNV, - GetRayTracingCaptureReplayShaderGroupHandlesKHR: ProcGetRayTracingCaptureReplayShaderGroupHandlesKHR, - GetRayTracingShaderGroupHandlesKHR: ProcGetRayTracingShaderGroupHandlesKHR, - GetRayTracingShaderGroupHandlesNV: ProcGetRayTracingShaderGroupHandlesNV, - GetRayTracingShaderGroupStackSizeKHR: ProcGetRayTracingShaderGroupStackSizeKHR, - GetRefreshCycleDurationGOOGLE: ProcGetRefreshCycleDurationGOOGLE, - GetRenderAreaGranularity: ProcGetRenderAreaGranularity, - GetSemaphoreCounterValue: ProcGetSemaphoreCounterValue, - GetSemaphoreCounterValueKHR: ProcGetSemaphoreCounterValueKHR, - GetSemaphoreFdKHR: ProcGetSemaphoreFdKHR, - GetSemaphoreWin32HandleKHR: ProcGetSemaphoreWin32HandleKHR, - GetShaderInfoAMD: ProcGetShaderInfoAMD, - GetSwapchainCounterEXT: ProcGetSwapchainCounterEXT, - GetSwapchainImagesKHR: ProcGetSwapchainImagesKHR, - GetSwapchainStatusKHR: ProcGetSwapchainStatusKHR, - GetValidationCacheDataEXT: ProcGetValidationCacheDataEXT, - ImportFenceFdKHR: ProcImportFenceFdKHR, - ImportFenceWin32HandleKHR: ProcImportFenceWin32HandleKHR, - ImportSemaphoreFdKHR: ProcImportSemaphoreFdKHR, - ImportSemaphoreWin32HandleKHR: ProcImportSemaphoreWin32HandleKHR, - InitializePerformanceApiINTEL: ProcInitializePerformanceApiINTEL, - InvalidateMappedMemoryRanges: ProcInvalidateMappedMemoryRanges, - MapMemory: ProcMapMemory, - MergePipelineCaches: ProcMergePipelineCaches, - MergeValidationCachesEXT: ProcMergeValidationCachesEXT, - QueueBeginDebugUtilsLabelEXT: ProcQueueBeginDebugUtilsLabelEXT, - QueueBindSparse: ProcQueueBindSparse, - QueueEndDebugUtilsLabelEXT: ProcQueueEndDebugUtilsLabelEXT, - QueueInsertDebugUtilsLabelEXT: ProcQueueInsertDebugUtilsLabelEXT, - QueuePresentKHR: ProcQueuePresentKHR, - QueueSetPerformanceConfigurationINTEL: ProcQueueSetPerformanceConfigurationINTEL, - QueueSubmit: ProcQueueSubmit, - QueueSubmit2: ProcQueueSubmit2, - QueueSubmit2KHR: ProcQueueSubmit2KHR, - QueueWaitIdle: ProcQueueWaitIdle, - RegisterDeviceEventEXT: ProcRegisterDeviceEventEXT, - RegisterDisplayEventEXT: ProcRegisterDisplayEventEXT, - ReleaseFullScreenExclusiveModeEXT: ProcReleaseFullScreenExclusiveModeEXT, - ReleasePerformanceConfigurationINTEL: ProcReleasePerformanceConfigurationINTEL, - ReleaseProfilingLockKHR: ProcReleaseProfilingLockKHR, - ResetCommandBuffer: ProcResetCommandBuffer, - ResetCommandPool: ProcResetCommandPool, - ResetDescriptorPool: ProcResetDescriptorPool, - ResetEvent: ProcResetEvent, - ResetFences: ProcResetFences, - ResetQueryPool: ProcResetQueryPool, - ResetQueryPoolEXT: ProcResetQueryPoolEXT, - SetDebugUtilsObjectNameEXT: ProcSetDebugUtilsObjectNameEXT, - SetDebugUtilsObjectTagEXT: ProcSetDebugUtilsObjectTagEXT, - SetDeviceMemoryPriorityEXT: ProcSetDeviceMemoryPriorityEXT, - SetEvent: ProcSetEvent, - SetHdrMetadataEXT: ProcSetHdrMetadataEXT, - SetLocalDimmingAMD: ProcSetLocalDimmingAMD, - SetPrivateData: ProcSetPrivateData, - SetPrivateDataEXT: ProcSetPrivateDataEXT, - SignalSemaphore: ProcSignalSemaphore, - SignalSemaphoreKHR: ProcSignalSemaphoreKHR, - TrimCommandPool: ProcTrimCommandPool, - TrimCommandPoolKHR: ProcTrimCommandPoolKHR, - UninitializePerformanceApiINTEL: ProcUninitializePerformanceApiINTEL, - UnmapMemory: ProcUnmapMemory, - UpdateDescriptorSetWithTemplate: ProcUpdateDescriptorSetWithTemplate, - UpdateDescriptorSetWithTemplateKHR: ProcUpdateDescriptorSetWithTemplateKHR, - UpdateDescriptorSets: ProcUpdateDescriptorSets, - WaitForFences: ProcWaitForFences, - WaitForPresentKHR: ProcWaitForPresentKHR, - WaitSemaphores: ProcWaitSemaphores, - WaitSemaphoresKHR: ProcWaitSemaphoresKHR, - WriteAccelerationStructuresPropertiesKHR: ProcWriteAccelerationStructuresPropertiesKHR, -} - -load_proc_addresses_device_vtable :: proc(device: Device, vtable: ^Device_VTable) { - vtable.AcquireFullScreenExclusiveModeEXT = auto_cast GetDeviceProcAddr(device, "vkAcquireFullScreenExclusiveModeEXT") - vtable.AcquireNextImage2KHR = auto_cast GetDeviceProcAddr(device, "vkAcquireNextImage2KHR") - vtable.AcquireNextImageKHR = auto_cast GetDeviceProcAddr(device, "vkAcquireNextImageKHR") - vtable.AcquirePerformanceConfigurationINTEL = auto_cast GetDeviceProcAddr(device, "vkAcquirePerformanceConfigurationINTEL") - vtable.AcquireProfilingLockKHR = auto_cast GetDeviceProcAddr(device, "vkAcquireProfilingLockKHR") - vtable.AllocateCommandBuffers = auto_cast GetDeviceProcAddr(device, "vkAllocateCommandBuffers") - vtable.AllocateDescriptorSets = auto_cast GetDeviceProcAddr(device, "vkAllocateDescriptorSets") - vtable.AllocateMemory = auto_cast GetDeviceProcAddr(device, "vkAllocateMemory") - vtable.BeginCommandBuffer = auto_cast GetDeviceProcAddr(device, "vkBeginCommandBuffer") - vtable.BindAccelerationStructureMemoryNV = auto_cast GetDeviceProcAddr(device, "vkBindAccelerationStructureMemoryNV") - vtable.BindBufferMemory = auto_cast GetDeviceProcAddr(device, "vkBindBufferMemory") - vtable.BindBufferMemory2 = auto_cast GetDeviceProcAddr(device, "vkBindBufferMemory2") - vtable.BindBufferMemory2KHR = auto_cast GetDeviceProcAddr(device, "vkBindBufferMemory2KHR") - vtable.BindImageMemory = auto_cast GetDeviceProcAddr(device, "vkBindImageMemory") - vtable.BindImageMemory2 = auto_cast GetDeviceProcAddr(device, "vkBindImageMemory2") - vtable.BindImageMemory2KHR = auto_cast GetDeviceProcAddr(device, "vkBindImageMemory2KHR") - vtable.BuildAccelerationStructuresKHR = auto_cast GetDeviceProcAddr(device, "vkBuildAccelerationStructuresKHR") - vtable.CmdBeginConditionalRenderingEXT = auto_cast GetDeviceProcAddr(device, "vkCmdBeginConditionalRenderingEXT") - vtable.CmdBeginDebugUtilsLabelEXT = auto_cast GetDeviceProcAddr(device, "vkCmdBeginDebugUtilsLabelEXT") - vtable.CmdBeginQuery = auto_cast GetDeviceProcAddr(device, "vkCmdBeginQuery") - vtable.CmdBeginQueryIndexedEXT = auto_cast GetDeviceProcAddr(device, "vkCmdBeginQueryIndexedEXT") - vtable.CmdBeginRenderPass = auto_cast GetDeviceProcAddr(device, "vkCmdBeginRenderPass") - vtable.CmdBeginRenderPass2 = auto_cast GetDeviceProcAddr(device, "vkCmdBeginRenderPass2") - vtable.CmdBeginRenderPass2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdBeginRenderPass2KHR") - vtable.CmdBeginRendering = auto_cast GetDeviceProcAddr(device, "vkCmdBeginRendering") - vtable.CmdBeginRenderingKHR = auto_cast GetDeviceProcAddr(device, "vkCmdBeginRenderingKHR") - vtable.CmdBeginTransformFeedbackEXT = auto_cast GetDeviceProcAddr(device, "vkCmdBeginTransformFeedbackEXT") - vtable.CmdBindDescriptorSets = auto_cast GetDeviceProcAddr(device, "vkCmdBindDescriptorSets") - vtable.CmdBindIndexBuffer = auto_cast GetDeviceProcAddr(device, "vkCmdBindIndexBuffer") - vtable.CmdBindInvocationMaskHUAWEI = auto_cast GetDeviceProcAddr(device, "vkCmdBindInvocationMaskHUAWEI") - vtable.CmdBindPipeline = auto_cast GetDeviceProcAddr(device, "vkCmdBindPipeline") - vtable.CmdBindPipelineShaderGroupNV = auto_cast GetDeviceProcAddr(device, "vkCmdBindPipelineShaderGroupNV") - vtable.CmdBindShadingRateImageNV = auto_cast GetDeviceProcAddr(device, "vkCmdBindShadingRateImageNV") - vtable.CmdBindTransformFeedbackBuffersEXT = auto_cast GetDeviceProcAddr(device, "vkCmdBindTransformFeedbackBuffersEXT") - vtable.CmdBindVertexBuffers = auto_cast GetDeviceProcAddr(device, "vkCmdBindVertexBuffers") - vtable.CmdBindVertexBuffers2 = auto_cast GetDeviceProcAddr(device, "vkCmdBindVertexBuffers2") - vtable.CmdBindVertexBuffers2EXT = auto_cast GetDeviceProcAddr(device, "vkCmdBindVertexBuffers2EXT") - vtable.CmdBlitImage = auto_cast GetDeviceProcAddr(device, "vkCmdBlitImage") - vtable.CmdBlitImage2 = auto_cast GetDeviceProcAddr(device, "vkCmdBlitImage2") - vtable.CmdBlitImage2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdBlitImage2KHR") - vtable.CmdBuildAccelerationStructureNV = auto_cast GetDeviceProcAddr(device, "vkCmdBuildAccelerationStructureNV") - vtable.CmdBuildAccelerationStructuresIndirectKHR = auto_cast GetDeviceProcAddr(device, "vkCmdBuildAccelerationStructuresIndirectKHR") - vtable.CmdBuildAccelerationStructuresKHR = auto_cast GetDeviceProcAddr(device, "vkCmdBuildAccelerationStructuresKHR") - vtable.CmdClearAttachments = auto_cast GetDeviceProcAddr(device, "vkCmdClearAttachments") - vtable.CmdClearColorImage = auto_cast GetDeviceProcAddr(device, "vkCmdClearColorImage") - vtable.CmdClearDepthStencilImage = auto_cast GetDeviceProcAddr(device, "vkCmdClearDepthStencilImage") - vtable.CmdCopyAccelerationStructureKHR = auto_cast GetDeviceProcAddr(device, "vkCmdCopyAccelerationStructureKHR") - vtable.CmdCopyAccelerationStructureNV = auto_cast GetDeviceProcAddr(device, "vkCmdCopyAccelerationStructureNV") - vtable.CmdCopyAccelerationStructureToMemoryKHR = auto_cast GetDeviceProcAddr(device, "vkCmdCopyAccelerationStructureToMemoryKHR") - vtable.CmdCopyBuffer = auto_cast GetDeviceProcAddr(device, "vkCmdCopyBuffer") - vtable.CmdCopyBuffer2 = auto_cast GetDeviceProcAddr(device, "vkCmdCopyBuffer2") - vtable.CmdCopyBuffer2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdCopyBuffer2KHR") - vtable.CmdCopyBufferToImage = auto_cast GetDeviceProcAddr(device, "vkCmdCopyBufferToImage") - vtable.CmdCopyBufferToImage2 = auto_cast GetDeviceProcAddr(device, "vkCmdCopyBufferToImage2") - vtable.CmdCopyBufferToImage2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdCopyBufferToImage2KHR") - vtable.CmdCopyImage = auto_cast GetDeviceProcAddr(device, "vkCmdCopyImage") - vtable.CmdCopyImage2 = auto_cast GetDeviceProcAddr(device, "vkCmdCopyImage2") - vtable.CmdCopyImage2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdCopyImage2KHR") - vtable.CmdCopyImageToBuffer = auto_cast GetDeviceProcAddr(device, "vkCmdCopyImageToBuffer") - vtable.CmdCopyImageToBuffer2 = auto_cast GetDeviceProcAddr(device, "vkCmdCopyImageToBuffer2") - vtable.CmdCopyImageToBuffer2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdCopyImageToBuffer2KHR") - vtable.CmdCopyMemoryToAccelerationStructureKHR = auto_cast GetDeviceProcAddr(device, "vkCmdCopyMemoryToAccelerationStructureKHR") - vtable.CmdCopyQueryPoolResults = auto_cast GetDeviceProcAddr(device, "vkCmdCopyQueryPoolResults") - vtable.CmdCuLaunchKernelNVX = auto_cast GetDeviceProcAddr(device, "vkCmdCuLaunchKernelNVX") - vtable.CmdDebugMarkerBeginEXT = auto_cast GetDeviceProcAddr(device, "vkCmdDebugMarkerBeginEXT") - vtable.CmdDebugMarkerEndEXT = auto_cast GetDeviceProcAddr(device, "vkCmdDebugMarkerEndEXT") - vtable.CmdDebugMarkerInsertEXT = auto_cast GetDeviceProcAddr(device, "vkCmdDebugMarkerInsertEXT") - vtable.CmdDispatch = auto_cast GetDeviceProcAddr(device, "vkCmdDispatch") - vtable.CmdDispatchBase = auto_cast GetDeviceProcAddr(device, "vkCmdDispatchBase") - vtable.CmdDispatchBaseKHR = auto_cast GetDeviceProcAddr(device, "vkCmdDispatchBaseKHR") - vtable.CmdDispatchIndirect = auto_cast GetDeviceProcAddr(device, "vkCmdDispatchIndirect") - vtable.CmdDraw = auto_cast GetDeviceProcAddr(device, "vkCmdDraw") - vtable.CmdDrawIndexed = auto_cast GetDeviceProcAddr(device, "vkCmdDrawIndexed") - vtable.CmdDrawIndexedIndirect = auto_cast GetDeviceProcAddr(device, "vkCmdDrawIndexedIndirect") - vtable.CmdDrawIndexedIndirectCount = auto_cast GetDeviceProcAddr(device, "vkCmdDrawIndexedIndirectCount") - vtable.CmdDrawIndexedIndirectCountAMD = auto_cast GetDeviceProcAddr(device, "vkCmdDrawIndexedIndirectCountAMD") - vtable.CmdDrawIndexedIndirectCountKHR = auto_cast GetDeviceProcAddr(device, "vkCmdDrawIndexedIndirectCountKHR") - vtable.CmdDrawIndirect = auto_cast GetDeviceProcAddr(device, "vkCmdDrawIndirect") - vtable.CmdDrawIndirectByteCountEXT = auto_cast GetDeviceProcAddr(device, "vkCmdDrawIndirectByteCountEXT") - vtable.CmdDrawIndirectCount = auto_cast GetDeviceProcAddr(device, "vkCmdDrawIndirectCount") - vtable.CmdDrawIndirectCountAMD = auto_cast GetDeviceProcAddr(device, "vkCmdDrawIndirectCountAMD") - vtable.CmdDrawIndirectCountKHR = auto_cast GetDeviceProcAddr(device, "vkCmdDrawIndirectCountKHR") - vtable.CmdDrawMeshTasksIndirectCountNV = auto_cast GetDeviceProcAddr(device, "vkCmdDrawMeshTasksIndirectCountNV") - vtable.CmdDrawMeshTasksIndirectNV = auto_cast GetDeviceProcAddr(device, "vkCmdDrawMeshTasksIndirectNV") - vtable.CmdDrawMeshTasksNV = auto_cast GetDeviceProcAddr(device, "vkCmdDrawMeshTasksNV") - vtable.CmdDrawMultiEXT = auto_cast GetDeviceProcAddr(device, "vkCmdDrawMultiEXT") - vtable.CmdDrawMultiIndexedEXT = auto_cast GetDeviceProcAddr(device, "vkCmdDrawMultiIndexedEXT") - vtable.CmdEndConditionalRenderingEXT = auto_cast GetDeviceProcAddr(device, "vkCmdEndConditionalRenderingEXT") - vtable.CmdEndDebugUtilsLabelEXT = auto_cast GetDeviceProcAddr(device, "vkCmdEndDebugUtilsLabelEXT") - vtable.CmdEndQuery = auto_cast GetDeviceProcAddr(device, "vkCmdEndQuery") - vtable.CmdEndQueryIndexedEXT = auto_cast GetDeviceProcAddr(device, "vkCmdEndQueryIndexedEXT") - vtable.CmdEndRenderPass = auto_cast GetDeviceProcAddr(device, "vkCmdEndRenderPass") - vtable.CmdEndRenderPass2 = auto_cast GetDeviceProcAddr(device, "vkCmdEndRenderPass2") - vtable.CmdEndRenderPass2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdEndRenderPass2KHR") - vtable.CmdEndRendering = auto_cast GetDeviceProcAddr(device, "vkCmdEndRendering") - vtable.CmdEndRenderingKHR = auto_cast GetDeviceProcAddr(device, "vkCmdEndRenderingKHR") - vtable.CmdEndTransformFeedbackEXT = auto_cast GetDeviceProcAddr(device, "vkCmdEndTransformFeedbackEXT") - vtable.CmdExecuteCommands = auto_cast GetDeviceProcAddr(device, "vkCmdExecuteCommands") - vtable.CmdExecuteGeneratedCommandsNV = auto_cast GetDeviceProcAddr(device, "vkCmdExecuteGeneratedCommandsNV") - vtable.CmdFillBuffer = auto_cast GetDeviceProcAddr(device, "vkCmdFillBuffer") - vtable.CmdInsertDebugUtilsLabelEXT = auto_cast GetDeviceProcAddr(device, "vkCmdInsertDebugUtilsLabelEXT") - vtable.CmdNextSubpass = auto_cast GetDeviceProcAddr(device, "vkCmdNextSubpass") - vtable.CmdNextSubpass2 = auto_cast GetDeviceProcAddr(device, "vkCmdNextSubpass2") - vtable.CmdNextSubpass2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdNextSubpass2KHR") - vtable.CmdPipelineBarrier = auto_cast GetDeviceProcAddr(device, "vkCmdPipelineBarrier") - vtable.CmdPipelineBarrier2 = auto_cast GetDeviceProcAddr(device, "vkCmdPipelineBarrier2") - vtable.CmdPipelineBarrier2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdPipelineBarrier2KHR") - vtable.CmdPreprocessGeneratedCommandsNV = auto_cast GetDeviceProcAddr(device, "vkCmdPreprocessGeneratedCommandsNV") - vtable.CmdPushConstants = auto_cast GetDeviceProcAddr(device, "vkCmdPushConstants") - vtable.CmdPushDescriptorSetKHR = auto_cast GetDeviceProcAddr(device, "vkCmdPushDescriptorSetKHR") - vtable.CmdPushDescriptorSetWithTemplateKHR = auto_cast GetDeviceProcAddr(device, "vkCmdPushDescriptorSetWithTemplateKHR") - vtable.CmdResetEvent = auto_cast GetDeviceProcAddr(device, "vkCmdResetEvent") - vtable.CmdResetEvent2 = auto_cast GetDeviceProcAddr(device, "vkCmdResetEvent2") - vtable.CmdResetEvent2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdResetEvent2KHR") - vtable.CmdResetQueryPool = auto_cast GetDeviceProcAddr(device, "vkCmdResetQueryPool") - vtable.CmdResolveImage = auto_cast GetDeviceProcAddr(device, "vkCmdResolveImage") - vtable.CmdResolveImage2 = auto_cast GetDeviceProcAddr(device, "vkCmdResolveImage2") - vtable.CmdResolveImage2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdResolveImage2KHR") - vtable.CmdSetBlendConstants = auto_cast GetDeviceProcAddr(device, "vkCmdSetBlendConstants") - vtable.CmdSetCheckpointNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetCheckpointNV") - vtable.CmdSetCoarseSampleOrderNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetCoarseSampleOrderNV") - vtable.CmdSetCullMode = auto_cast GetDeviceProcAddr(device, "vkCmdSetCullMode") - vtable.CmdSetCullModeEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetCullModeEXT") - vtable.CmdSetDepthBias = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthBias") - vtable.CmdSetDepthBiasEnable = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthBiasEnable") - vtable.CmdSetDepthBiasEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthBiasEnableEXT") - vtable.CmdSetDepthBounds = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthBounds") - vtable.CmdSetDepthBoundsTestEnable = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthBoundsTestEnable") - vtable.CmdSetDepthBoundsTestEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthBoundsTestEnableEXT") - vtable.CmdSetDepthCompareOp = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthCompareOp") - vtable.CmdSetDepthCompareOpEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthCompareOpEXT") - vtable.CmdSetDepthTestEnable = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthTestEnable") - vtable.CmdSetDepthTestEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthTestEnableEXT") - vtable.CmdSetDepthWriteEnable = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthWriteEnable") - vtable.CmdSetDepthWriteEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthWriteEnableEXT") - vtable.CmdSetDeviceMask = auto_cast GetDeviceProcAddr(device, "vkCmdSetDeviceMask") - vtable.CmdSetDeviceMaskKHR = auto_cast GetDeviceProcAddr(device, "vkCmdSetDeviceMaskKHR") - vtable.CmdSetDiscardRectangleEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetDiscardRectangleEXT") - vtable.CmdSetEvent = auto_cast GetDeviceProcAddr(device, "vkCmdSetEvent") - vtable.CmdSetEvent2 = auto_cast GetDeviceProcAddr(device, "vkCmdSetEvent2") - vtable.CmdSetEvent2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdSetEvent2KHR") - vtable.CmdSetExclusiveScissorNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetExclusiveScissorNV") - vtable.CmdSetFragmentShadingRateEnumNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetFragmentShadingRateEnumNV") - vtable.CmdSetFragmentShadingRateKHR = auto_cast GetDeviceProcAddr(device, "vkCmdSetFragmentShadingRateKHR") - vtable.CmdSetFrontFace = auto_cast GetDeviceProcAddr(device, "vkCmdSetFrontFace") - vtable.CmdSetFrontFaceEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetFrontFaceEXT") - vtable.CmdSetLineStippleEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetLineStippleEXT") - vtable.CmdSetLineWidth = auto_cast GetDeviceProcAddr(device, "vkCmdSetLineWidth") - vtable.CmdSetLogicOpEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetLogicOpEXT") - vtable.CmdSetPatchControlPointsEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetPatchControlPointsEXT") - vtable.CmdSetPerformanceMarkerINTEL = auto_cast GetDeviceProcAddr(device, "vkCmdSetPerformanceMarkerINTEL") - vtable.CmdSetPerformanceOverrideINTEL = auto_cast GetDeviceProcAddr(device, "vkCmdSetPerformanceOverrideINTEL") - vtable.CmdSetPerformanceStreamMarkerINTEL = auto_cast GetDeviceProcAddr(device, "vkCmdSetPerformanceStreamMarkerINTEL") - vtable.CmdSetPrimitiveRestartEnable = auto_cast GetDeviceProcAddr(device, "vkCmdSetPrimitiveRestartEnable") - vtable.CmdSetPrimitiveRestartEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetPrimitiveRestartEnableEXT") - vtable.CmdSetPrimitiveTopology = auto_cast GetDeviceProcAddr(device, "vkCmdSetPrimitiveTopology") - vtable.CmdSetPrimitiveTopologyEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetPrimitiveTopologyEXT") - vtable.CmdSetRasterizerDiscardEnable = auto_cast GetDeviceProcAddr(device, "vkCmdSetRasterizerDiscardEnable") - vtable.CmdSetRasterizerDiscardEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetRasterizerDiscardEnableEXT") - vtable.CmdSetRayTracingPipelineStackSizeKHR = auto_cast GetDeviceProcAddr(device, "vkCmdSetRayTracingPipelineStackSizeKHR") - vtable.CmdSetSampleLocationsEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetSampleLocationsEXT") - vtable.CmdSetScissor = auto_cast GetDeviceProcAddr(device, "vkCmdSetScissor") - vtable.CmdSetScissorWithCount = auto_cast GetDeviceProcAddr(device, "vkCmdSetScissorWithCount") - vtable.CmdSetScissorWithCountEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetScissorWithCountEXT") - vtable.CmdSetStencilCompareMask = auto_cast GetDeviceProcAddr(device, "vkCmdSetStencilCompareMask") - vtable.CmdSetStencilOp = auto_cast GetDeviceProcAddr(device, "vkCmdSetStencilOp") - vtable.CmdSetStencilOpEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetStencilOpEXT") - vtable.CmdSetStencilReference = auto_cast GetDeviceProcAddr(device, "vkCmdSetStencilReference") - vtable.CmdSetStencilTestEnable = auto_cast GetDeviceProcAddr(device, "vkCmdSetStencilTestEnable") - vtable.CmdSetStencilTestEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetStencilTestEnableEXT") - vtable.CmdSetStencilWriteMask = auto_cast GetDeviceProcAddr(device, "vkCmdSetStencilWriteMask") - vtable.CmdSetVertexInputEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetVertexInputEXT") - vtable.CmdSetViewport = auto_cast GetDeviceProcAddr(device, "vkCmdSetViewport") - vtable.CmdSetViewportShadingRatePaletteNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetViewportShadingRatePaletteNV") - vtable.CmdSetViewportWScalingNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetViewportWScalingNV") - vtable.CmdSetViewportWithCount = auto_cast GetDeviceProcAddr(device, "vkCmdSetViewportWithCount") - vtable.CmdSetViewportWithCountEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetViewportWithCountEXT") - vtable.CmdSubpassShadingHUAWEI = auto_cast GetDeviceProcAddr(device, "vkCmdSubpassShadingHUAWEI") - vtable.CmdTraceRaysIndirectKHR = auto_cast GetDeviceProcAddr(device, "vkCmdTraceRaysIndirectKHR") - vtable.CmdTraceRaysKHR = auto_cast GetDeviceProcAddr(device, "vkCmdTraceRaysKHR") - vtable.CmdTraceRaysNV = auto_cast GetDeviceProcAddr(device, "vkCmdTraceRaysNV") - vtable.CmdUpdateBuffer = auto_cast GetDeviceProcAddr(device, "vkCmdUpdateBuffer") - vtable.CmdWaitEvents = auto_cast GetDeviceProcAddr(device, "vkCmdWaitEvents") - vtable.CmdWaitEvents2 = auto_cast GetDeviceProcAddr(device, "vkCmdWaitEvents2") - vtable.CmdWaitEvents2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdWaitEvents2KHR") - vtable.CmdWriteAccelerationStructuresPropertiesKHR = auto_cast GetDeviceProcAddr(device, "vkCmdWriteAccelerationStructuresPropertiesKHR") - vtable.CmdWriteAccelerationStructuresPropertiesNV = auto_cast GetDeviceProcAddr(device, "vkCmdWriteAccelerationStructuresPropertiesNV") - vtable.CmdWriteBufferMarker2AMD = auto_cast GetDeviceProcAddr(device, "vkCmdWriteBufferMarker2AMD") - vtable.CmdWriteBufferMarkerAMD = auto_cast GetDeviceProcAddr(device, "vkCmdWriteBufferMarkerAMD") - vtable.CmdWriteTimestamp = auto_cast GetDeviceProcAddr(device, "vkCmdWriteTimestamp") - vtable.CmdWriteTimestamp2 = auto_cast GetDeviceProcAddr(device, "vkCmdWriteTimestamp2") - vtable.CmdWriteTimestamp2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdWriteTimestamp2KHR") - vtable.CompileDeferredNV = auto_cast GetDeviceProcAddr(device, "vkCompileDeferredNV") - vtable.CopyAccelerationStructureKHR = auto_cast GetDeviceProcAddr(device, "vkCopyAccelerationStructureKHR") - vtable.CopyAccelerationStructureToMemoryKHR = auto_cast GetDeviceProcAddr(device, "vkCopyAccelerationStructureToMemoryKHR") - vtable.CopyMemoryToAccelerationStructureKHR = auto_cast GetDeviceProcAddr(device, "vkCopyMemoryToAccelerationStructureKHR") - vtable.CreateAccelerationStructureKHR = auto_cast GetDeviceProcAddr(device, "vkCreateAccelerationStructureKHR") - vtable.CreateAccelerationStructureNV = auto_cast GetDeviceProcAddr(device, "vkCreateAccelerationStructureNV") - vtable.CreateBuffer = auto_cast GetDeviceProcAddr(device, "vkCreateBuffer") - vtable.CreateBufferView = auto_cast GetDeviceProcAddr(device, "vkCreateBufferView") - vtable.CreateCommandPool = auto_cast GetDeviceProcAddr(device, "vkCreateCommandPool") - vtable.CreateComputePipelines = auto_cast GetDeviceProcAddr(device, "vkCreateComputePipelines") - vtable.CreateCuFunctionNVX = auto_cast GetDeviceProcAddr(device, "vkCreateCuFunctionNVX") - vtable.CreateCuModuleNVX = auto_cast GetDeviceProcAddr(device, "vkCreateCuModuleNVX") - vtable.CreateDeferredOperationKHR = auto_cast GetDeviceProcAddr(device, "vkCreateDeferredOperationKHR") - vtable.CreateDescriptorPool = auto_cast GetDeviceProcAddr(device, "vkCreateDescriptorPool") - vtable.CreateDescriptorSetLayout = auto_cast GetDeviceProcAddr(device, "vkCreateDescriptorSetLayout") - vtable.CreateDescriptorUpdateTemplate = auto_cast GetDeviceProcAddr(device, "vkCreateDescriptorUpdateTemplate") - vtable.CreateDescriptorUpdateTemplateKHR = auto_cast GetDeviceProcAddr(device, "vkCreateDescriptorUpdateTemplateKHR") - vtable.CreateEvent = auto_cast GetDeviceProcAddr(device, "vkCreateEvent") - vtable.CreateFence = auto_cast GetDeviceProcAddr(device, "vkCreateFence") - vtable.CreateFramebuffer = auto_cast GetDeviceProcAddr(device, "vkCreateFramebuffer") - vtable.CreateGraphicsPipelines = auto_cast GetDeviceProcAddr(device, "vkCreateGraphicsPipelines") - vtable.CreateImage = auto_cast GetDeviceProcAddr(device, "vkCreateImage") - vtable.CreateImageView = auto_cast GetDeviceProcAddr(device, "vkCreateImageView") - vtable.CreateIndirectCommandsLayoutNV = auto_cast GetDeviceProcAddr(device, "vkCreateIndirectCommandsLayoutNV") - vtable.CreatePipelineCache = auto_cast GetDeviceProcAddr(device, "vkCreatePipelineCache") - vtable.CreatePipelineLayout = auto_cast GetDeviceProcAddr(device, "vkCreatePipelineLayout") - vtable.CreatePrivateDataSlot = auto_cast GetDeviceProcAddr(device, "vkCreatePrivateDataSlot") - vtable.CreatePrivateDataSlotEXT = auto_cast GetDeviceProcAddr(device, "vkCreatePrivateDataSlotEXT") - vtable.CreateQueryPool = auto_cast GetDeviceProcAddr(device, "vkCreateQueryPool") - vtable.CreateRayTracingPipelinesKHR = auto_cast GetDeviceProcAddr(device, "vkCreateRayTracingPipelinesKHR") - vtable.CreateRayTracingPipelinesNV = auto_cast GetDeviceProcAddr(device, "vkCreateRayTracingPipelinesNV") - vtable.CreateRenderPass = auto_cast GetDeviceProcAddr(device, "vkCreateRenderPass") - vtable.CreateRenderPass2 = auto_cast GetDeviceProcAddr(device, "vkCreateRenderPass2") - vtable.CreateRenderPass2KHR = auto_cast GetDeviceProcAddr(device, "vkCreateRenderPass2KHR") - vtable.CreateSampler = auto_cast GetDeviceProcAddr(device, "vkCreateSampler") - vtable.CreateSamplerYcbcrConversion = auto_cast GetDeviceProcAddr(device, "vkCreateSamplerYcbcrConversion") - vtable.CreateSamplerYcbcrConversionKHR = auto_cast GetDeviceProcAddr(device, "vkCreateSamplerYcbcrConversionKHR") - vtable.CreateSemaphore = auto_cast GetDeviceProcAddr(device, "vkCreateSemaphore") - vtable.CreateShaderModule = auto_cast GetDeviceProcAddr(device, "vkCreateShaderModule") - vtable.CreateSharedSwapchainsKHR = auto_cast GetDeviceProcAddr(device, "vkCreateSharedSwapchainsKHR") - vtable.CreateSwapchainKHR = auto_cast GetDeviceProcAddr(device, "vkCreateSwapchainKHR") - vtable.CreateValidationCacheEXT = auto_cast GetDeviceProcAddr(device, "vkCreateValidationCacheEXT") - vtable.DebugMarkerSetObjectNameEXT = auto_cast GetDeviceProcAddr(device, "vkDebugMarkerSetObjectNameEXT") - vtable.DebugMarkerSetObjectTagEXT = auto_cast GetDeviceProcAddr(device, "vkDebugMarkerSetObjectTagEXT") - vtable.DeferredOperationJoinKHR = auto_cast GetDeviceProcAddr(device, "vkDeferredOperationJoinKHR") - vtable.DestroyAccelerationStructureKHR = auto_cast GetDeviceProcAddr(device, "vkDestroyAccelerationStructureKHR") - vtable.DestroyAccelerationStructureNV = auto_cast GetDeviceProcAddr(device, "vkDestroyAccelerationStructureNV") - vtable.DestroyBuffer = auto_cast GetDeviceProcAddr(device, "vkDestroyBuffer") - vtable.DestroyBufferView = auto_cast GetDeviceProcAddr(device, "vkDestroyBufferView") - vtable.DestroyCommandPool = auto_cast GetDeviceProcAddr(device, "vkDestroyCommandPool") - vtable.DestroyCuFunctionNVX = auto_cast GetDeviceProcAddr(device, "vkDestroyCuFunctionNVX") - vtable.DestroyCuModuleNVX = auto_cast GetDeviceProcAddr(device, "vkDestroyCuModuleNVX") - vtable.DestroyDeferredOperationKHR = auto_cast GetDeviceProcAddr(device, "vkDestroyDeferredOperationKHR") - vtable.DestroyDescriptorPool = auto_cast GetDeviceProcAddr(device, "vkDestroyDescriptorPool") - vtable.DestroyDescriptorSetLayout = auto_cast GetDeviceProcAddr(device, "vkDestroyDescriptorSetLayout") - vtable.DestroyDescriptorUpdateTemplate = auto_cast GetDeviceProcAddr(device, "vkDestroyDescriptorUpdateTemplate") - vtable.DestroyDescriptorUpdateTemplateKHR = auto_cast GetDeviceProcAddr(device, "vkDestroyDescriptorUpdateTemplateKHR") - vtable.DestroyDevice = auto_cast GetDeviceProcAddr(device, "vkDestroyDevice") - vtable.DestroyEvent = auto_cast GetDeviceProcAddr(device, "vkDestroyEvent") - vtable.DestroyFence = auto_cast GetDeviceProcAddr(device, "vkDestroyFence") - vtable.DestroyFramebuffer = auto_cast GetDeviceProcAddr(device, "vkDestroyFramebuffer") - vtable.DestroyImage = auto_cast GetDeviceProcAddr(device, "vkDestroyImage") - vtable.DestroyImageView = auto_cast GetDeviceProcAddr(device, "vkDestroyImageView") - vtable.DestroyIndirectCommandsLayoutNV = auto_cast GetDeviceProcAddr(device, "vkDestroyIndirectCommandsLayoutNV") - vtable.DestroyPipeline = auto_cast GetDeviceProcAddr(device, "vkDestroyPipeline") - vtable.DestroyPipelineCache = auto_cast GetDeviceProcAddr(device, "vkDestroyPipelineCache") - vtable.DestroyPipelineLayout = auto_cast GetDeviceProcAddr(device, "vkDestroyPipelineLayout") - vtable.DestroyPrivateDataSlot = auto_cast GetDeviceProcAddr(device, "vkDestroyPrivateDataSlot") - vtable.DestroyPrivateDataSlotEXT = auto_cast GetDeviceProcAddr(device, "vkDestroyPrivateDataSlotEXT") - vtable.DestroyQueryPool = auto_cast GetDeviceProcAddr(device, "vkDestroyQueryPool") - vtable.DestroyRenderPass = auto_cast GetDeviceProcAddr(device, "vkDestroyRenderPass") - vtable.DestroySampler = auto_cast GetDeviceProcAddr(device, "vkDestroySampler") - vtable.DestroySamplerYcbcrConversion = auto_cast GetDeviceProcAddr(device, "vkDestroySamplerYcbcrConversion") - vtable.DestroySamplerYcbcrConversionKHR = auto_cast GetDeviceProcAddr(device, "vkDestroySamplerYcbcrConversionKHR") - vtable.DestroySemaphore = auto_cast GetDeviceProcAddr(device, "vkDestroySemaphore") - vtable.DestroyShaderModule = auto_cast GetDeviceProcAddr(device, "vkDestroyShaderModule") - vtable.DestroySwapchainKHR = auto_cast GetDeviceProcAddr(device, "vkDestroySwapchainKHR") - vtable.DestroyValidationCacheEXT = auto_cast GetDeviceProcAddr(device, "vkDestroyValidationCacheEXT") - vtable.DeviceWaitIdle = auto_cast GetDeviceProcAddr(device, "vkDeviceWaitIdle") - vtable.DisplayPowerControlEXT = auto_cast GetDeviceProcAddr(device, "vkDisplayPowerControlEXT") - vtable.EndCommandBuffer = auto_cast GetDeviceProcAddr(device, "vkEndCommandBuffer") - vtable.FlushMappedMemoryRanges = auto_cast GetDeviceProcAddr(device, "vkFlushMappedMemoryRanges") - vtable.FreeCommandBuffers = auto_cast GetDeviceProcAddr(device, "vkFreeCommandBuffers") - vtable.FreeDescriptorSets = auto_cast GetDeviceProcAddr(device, "vkFreeDescriptorSets") - vtable.FreeMemory = auto_cast GetDeviceProcAddr(device, "vkFreeMemory") - vtable.GetAccelerationStructureBuildSizesKHR = auto_cast GetDeviceProcAddr(device, "vkGetAccelerationStructureBuildSizesKHR") - vtable.GetAccelerationStructureDeviceAddressKHR = auto_cast GetDeviceProcAddr(device, "vkGetAccelerationStructureDeviceAddressKHR") - vtable.GetAccelerationStructureHandleNV = auto_cast GetDeviceProcAddr(device, "vkGetAccelerationStructureHandleNV") - vtable.GetAccelerationStructureMemoryRequirementsNV = auto_cast GetDeviceProcAddr(device, "vkGetAccelerationStructureMemoryRequirementsNV") - vtable.GetBufferDeviceAddress = auto_cast GetDeviceProcAddr(device, "vkGetBufferDeviceAddress") - vtable.GetBufferDeviceAddressEXT = auto_cast GetDeviceProcAddr(device, "vkGetBufferDeviceAddressEXT") - vtable.GetBufferDeviceAddressKHR = auto_cast GetDeviceProcAddr(device, "vkGetBufferDeviceAddressKHR") - vtable.GetBufferMemoryRequirements = auto_cast GetDeviceProcAddr(device, "vkGetBufferMemoryRequirements") - vtable.GetBufferMemoryRequirements2 = auto_cast GetDeviceProcAddr(device, "vkGetBufferMemoryRequirements2") - vtable.GetBufferMemoryRequirements2KHR = auto_cast GetDeviceProcAddr(device, "vkGetBufferMemoryRequirements2KHR") - vtable.GetBufferOpaqueCaptureAddress = auto_cast GetDeviceProcAddr(device, "vkGetBufferOpaqueCaptureAddress") - vtable.GetBufferOpaqueCaptureAddressKHR = auto_cast GetDeviceProcAddr(device, "vkGetBufferOpaqueCaptureAddressKHR") - vtable.GetCalibratedTimestampsEXT = auto_cast GetDeviceProcAddr(device, "vkGetCalibratedTimestampsEXT") - vtable.GetDeferredOperationMaxConcurrencyKHR = auto_cast GetDeviceProcAddr(device, "vkGetDeferredOperationMaxConcurrencyKHR") - vtable.GetDeferredOperationResultKHR = auto_cast GetDeviceProcAddr(device, "vkGetDeferredOperationResultKHR") - vtable.GetDescriptorSetHostMappingVALVE = auto_cast GetDeviceProcAddr(device, "vkGetDescriptorSetHostMappingVALVE") - vtable.GetDescriptorSetLayoutHostMappingInfoVALVE = auto_cast GetDeviceProcAddr(device, "vkGetDescriptorSetLayoutHostMappingInfoVALVE") - vtable.GetDescriptorSetLayoutSupport = auto_cast GetDeviceProcAddr(device, "vkGetDescriptorSetLayoutSupport") - vtable.GetDescriptorSetLayoutSupportKHR = auto_cast GetDeviceProcAddr(device, "vkGetDescriptorSetLayoutSupportKHR") - vtable.GetDeviceAccelerationStructureCompatibilityKHR = auto_cast GetDeviceProcAddr(device, "vkGetDeviceAccelerationStructureCompatibilityKHR") - vtable.GetDeviceBufferMemoryRequirements = auto_cast GetDeviceProcAddr(device, "vkGetDeviceBufferMemoryRequirements") - vtable.GetDeviceBufferMemoryRequirementsKHR = auto_cast GetDeviceProcAddr(device, "vkGetDeviceBufferMemoryRequirementsKHR") - vtable.GetDeviceGroupPeerMemoryFeatures = auto_cast GetDeviceProcAddr(device, "vkGetDeviceGroupPeerMemoryFeatures") - vtable.GetDeviceGroupPeerMemoryFeaturesKHR = auto_cast GetDeviceProcAddr(device, "vkGetDeviceGroupPeerMemoryFeaturesKHR") - vtable.GetDeviceGroupPresentCapabilitiesKHR = auto_cast GetDeviceProcAddr(device, "vkGetDeviceGroupPresentCapabilitiesKHR") - vtable.GetDeviceGroupSurfacePresentModes2EXT = auto_cast GetDeviceProcAddr(device, "vkGetDeviceGroupSurfacePresentModes2EXT") - vtable.GetDeviceGroupSurfacePresentModesKHR = auto_cast GetDeviceProcAddr(device, "vkGetDeviceGroupSurfacePresentModesKHR") - vtable.GetDeviceImageMemoryRequirements = auto_cast GetDeviceProcAddr(device, "vkGetDeviceImageMemoryRequirements") - vtable.GetDeviceImageMemoryRequirementsKHR = auto_cast GetDeviceProcAddr(device, "vkGetDeviceImageMemoryRequirementsKHR") - vtable.GetDeviceImageSparseMemoryRequirements = auto_cast GetDeviceProcAddr(device, "vkGetDeviceImageSparseMemoryRequirements") - vtable.GetDeviceImageSparseMemoryRequirementsKHR = auto_cast GetDeviceProcAddr(device, "vkGetDeviceImageSparseMemoryRequirementsKHR") - vtable.GetDeviceMemoryCommitment = auto_cast GetDeviceProcAddr(device, "vkGetDeviceMemoryCommitment") - vtable.GetDeviceMemoryOpaqueCaptureAddress = auto_cast GetDeviceProcAddr(device, "vkGetDeviceMemoryOpaqueCaptureAddress") - vtable.GetDeviceMemoryOpaqueCaptureAddressKHR = auto_cast GetDeviceProcAddr(device, "vkGetDeviceMemoryOpaqueCaptureAddressKHR") - vtable.GetDeviceProcAddr = auto_cast GetDeviceProcAddr(device, "vkGetDeviceProcAddr") - vtable.GetDeviceQueue = auto_cast GetDeviceProcAddr(device, "vkGetDeviceQueue") - vtable.GetDeviceQueue2 = auto_cast GetDeviceProcAddr(device, "vkGetDeviceQueue2") - vtable.GetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI = auto_cast GetDeviceProcAddr(device, "vkGetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI") - vtable.GetEventStatus = auto_cast GetDeviceProcAddr(device, "vkGetEventStatus") - vtable.GetFenceFdKHR = auto_cast GetDeviceProcAddr(device, "vkGetFenceFdKHR") - vtable.GetFenceStatus = auto_cast GetDeviceProcAddr(device, "vkGetFenceStatus") - vtable.GetFenceWin32HandleKHR = auto_cast GetDeviceProcAddr(device, "vkGetFenceWin32HandleKHR") - vtable.GetGeneratedCommandsMemoryRequirementsNV = auto_cast GetDeviceProcAddr(device, "vkGetGeneratedCommandsMemoryRequirementsNV") - vtable.GetImageDrmFormatModifierPropertiesEXT = auto_cast GetDeviceProcAddr(device, "vkGetImageDrmFormatModifierPropertiesEXT") - vtable.GetImageMemoryRequirements = auto_cast GetDeviceProcAddr(device, "vkGetImageMemoryRequirements") - vtable.GetImageMemoryRequirements2 = auto_cast GetDeviceProcAddr(device, "vkGetImageMemoryRequirements2") - vtable.GetImageMemoryRequirements2KHR = auto_cast GetDeviceProcAddr(device, "vkGetImageMemoryRequirements2KHR") - vtable.GetImageSparseMemoryRequirements = auto_cast GetDeviceProcAddr(device, "vkGetImageSparseMemoryRequirements") - vtable.GetImageSparseMemoryRequirements2 = auto_cast GetDeviceProcAddr(device, "vkGetImageSparseMemoryRequirements2") - vtable.GetImageSparseMemoryRequirements2KHR = auto_cast GetDeviceProcAddr(device, "vkGetImageSparseMemoryRequirements2KHR") - vtable.GetImageSubresourceLayout = auto_cast GetDeviceProcAddr(device, "vkGetImageSubresourceLayout") - vtable.GetImageViewAddressNVX = auto_cast GetDeviceProcAddr(device, "vkGetImageViewAddressNVX") - vtable.GetImageViewHandleNVX = auto_cast GetDeviceProcAddr(device, "vkGetImageViewHandleNVX") - vtable.GetMemoryFdKHR = auto_cast GetDeviceProcAddr(device, "vkGetMemoryFdKHR") - vtable.GetMemoryFdPropertiesKHR = auto_cast GetDeviceProcAddr(device, "vkGetMemoryFdPropertiesKHR") - vtable.GetMemoryHostPointerPropertiesEXT = auto_cast GetDeviceProcAddr(device, "vkGetMemoryHostPointerPropertiesEXT") - vtable.GetMemoryRemoteAddressNV = auto_cast GetDeviceProcAddr(device, "vkGetMemoryRemoteAddressNV") - vtable.GetMemoryWin32HandleKHR = auto_cast GetDeviceProcAddr(device, "vkGetMemoryWin32HandleKHR") - vtable.GetMemoryWin32HandleNV = auto_cast GetDeviceProcAddr(device, "vkGetMemoryWin32HandleNV") - vtable.GetMemoryWin32HandlePropertiesKHR = auto_cast GetDeviceProcAddr(device, "vkGetMemoryWin32HandlePropertiesKHR") - vtable.GetPastPresentationTimingGOOGLE = auto_cast GetDeviceProcAddr(device, "vkGetPastPresentationTimingGOOGLE") - vtable.GetPerformanceParameterINTEL = auto_cast GetDeviceProcAddr(device, "vkGetPerformanceParameterINTEL") - vtable.GetPipelineCacheData = auto_cast GetDeviceProcAddr(device, "vkGetPipelineCacheData") - vtable.GetPipelineExecutableInternalRepresentationsKHR = auto_cast GetDeviceProcAddr(device, "vkGetPipelineExecutableInternalRepresentationsKHR") - vtable.GetPipelineExecutablePropertiesKHR = auto_cast GetDeviceProcAddr(device, "vkGetPipelineExecutablePropertiesKHR") - vtable.GetPipelineExecutableStatisticsKHR = auto_cast GetDeviceProcAddr(device, "vkGetPipelineExecutableStatisticsKHR") - vtable.GetPrivateData = auto_cast GetDeviceProcAddr(device, "vkGetPrivateData") - vtable.GetPrivateDataEXT = auto_cast GetDeviceProcAddr(device, "vkGetPrivateDataEXT") - vtable.GetQueryPoolResults = auto_cast GetDeviceProcAddr(device, "vkGetQueryPoolResults") - vtable.GetQueueCheckpointData2NV = auto_cast GetDeviceProcAddr(device, "vkGetQueueCheckpointData2NV") - vtable.GetQueueCheckpointDataNV = auto_cast GetDeviceProcAddr(device, "vkGetQueueCheckpointDataNV") - vtable.GetRayTracingCaptureReplayShaderGroupHandlesKHR = auto_cast GetDeviceProcAddr(device, "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR") - vtable.GetRayTracingShaderGroupHandlesKHR = auto_cast GetDeviceProcAddr(device, "vkGetRayTracingShaderGroupHandlesKHR") - vtable.GetRayTracingShaderGroupHandlesNV = auto_cast GetDeviceProcAddr(device, "vkGetRayTracingShaderGroupHandlesNV") - vtable.GetRayTracingShaderGroupStackSizeKHR = auto_cast GetDeviceProcAddr(device, "vkGetRayTracingShaderGroupStackSizeKHR") - vtable.GetRefreshCycleDurationGOOGLE = auto_cast GetDeviceProcAddr(device, "vkGetRefreshCycleDurationGOOGLE") - vtable.GetRenderAreaGranularity = auto_cast GetDeviceProcAddr(device, "vkGetRenderAreaGranularity") - vtable.GetSemaphoreCounterValue = auto_cast GetDeviceProcAddr(device, "vkGetSemaphoreCounterValue") - vtable.GetSemaphoreCounterValueKHR = auto_cast GetDeviceProcAddr(device, "vkGetSemaphoreCounterValueKHR") - vtable.GetSemaphoreFdKHR = auto_cast GetDeviceProcAddr(device, "vkGetSemaphoreFdKHR") - vtable.GetSemaphoreWin32HandleKHR = auto_cast GetDeviceProcAddr(device, "vkGetSemaphoreWin32HandleKHR") - vtable.GetShaderInfoAMD = auto_cast GetDeviceProcAddr(device, "vkGetShaderInfoAMD") - vtable.GetSwapchainCounterEXT = auto_cast GetDeviceProcAddr(device, "vkGetSwapchainCounterEXT") - vtable.GetSwapchainImagesKHR = auto_cast GetDeviceProcAddr(device, "vkGetSwapchainImagesKHR") - vtable.GetSwapchainStatusKHR = auto_cast GetDeviceProcAddr(device, "vkGetSwapchainStatusKHR") - vtable.GetValidationCacheDataEXT = auto_cast GetDeviceProcAddr(device, "vkGetValidationCacheDataEXT") - vtable.ImportFenceFdKHR = auto_cast GetDeviceProcAddr(device, "vkImportFenceFdKHR") - vtable.ImportFenceWin32HandleKHR = auto_cast GetDeviceProcAddr(device, "vkImportFenceWin32HandleKHR") - vtable.ImportSemaphoreFdKHR = auto_cast GetDeviceProcAddr(device, "vkImportSemaphoreFdKHR") - vtable.ImportSemaphoreWin32HandleKHR = auto_cast GetDeviceProcAddr(device, "vkImportSemaphoreWin32HandleKHR") - vtable.InitializePerformanceApiINTEL = auto_cast GetDeviceProcAddr(device, "vkInitializePerformanceApiINTEL") - vtable.InvalidateMappedMemoryRanges = auto_cast GetDeviceProcAddr(device, "vkInvalidateMappedMemoryRanges") - vtable.MapMemory = auto_cast GetDeviceProcAddr(device, "vkMapMemory") - vtable.MergePipelineCaches = auto_cast GetDeviceProcAddr(device, "vkMergePipelineCaches") - vtable.MergeValidationCachesEXT = auto_cast GetDeviceProcAddr(device, "vkMergeValidationCachesEXT") - vtable.QueueBeginDebugUtilsLabelEXT = auto_cast GetDeviceProcAddr(device, "vkQueueBeginDebugUtilsLabelEXT") - vtable.QueueBindSparse = auto_cast GetDeviceProcAddr(device, "vkQueueBindSparse") - vtable.QueueEndDebugUtilsLabelEXT = auto_cast GetDeviceProcAddr(device, "vkQueueEndDebugUtilsLabelEXT") - vtable.QueueInsertDebugUtilsLabelEXT = auto_cast GetDeviceProcAddr(device, "vkQueueInsertDebugUtilsLabelEXT") - vtable.QueuePresentKHR = auto_cast GetDeviceProcAddr(device, "vkQueuePresentKHR") - vtable.QueueSetPerformanceConfigurationINTEL = auto_cast GetDeviceProcAddr(device, "vkQueueSetPerformanceConfigurationINTEL") - vtable.QueueSubmit = auto_cast GetDeviceProcAddr(device, "vkQueueSubmit") - vtable.QueueSubmit2 = auto_cast GetDeviceProcAddr(device, "vkQueueSubmit2") - vtable.QueueSubmit2KHR = auto_cast GetDeviceProcAddr(device, "vkQueueSubmit2KHR") - vtable.QueueWaitIdle = auto_cast GetDeviceProcAddr(device, "vkQueueWaitIdle") - vtable.RegisterDeviceEventEXT = auto_cast GetDeviceProcAddr(device, "vkRegisterDeviceEventEXT") - vtable.RegisterDisplayEventEXT = auto_cast GetDeviceProcAddr(device, "vkRegisterDisplayEventEXT") - vtable.ReleaseFullScreenExclusiveModeEXT = auto_cast GetDeviceProcAddr(device, "vkReleaseFullScreenExclusiveModeEXT") - vtable.ReleasePerformanceConfigurationINTEL = auto_cast GetDeviceProcAddr(device, "vkReleasePerformanceConfigurationINTEL") - vtable.ReleaseProfilingLockKHR = auto_cast GetDeviceProcAddr(device, "vkReleaseProfilingLockKHR") - vtable.ResetCommandBuffer = auto_cast GetDeviceProcAddr(device, "vkResetCommandBuffer") - vtable.ResetCommandPool = auto_cast GetDeviceProcAddr(device, "vkResetCommandPool") - vtable.ResetDescriptorPool = auto_cast GetDeviceProcAddr(device, "vkResetDescriptorPool") - vtable.ResetEvent = auto_cast GetDeviceProcAddr(device, "vkResetEvent") - vtable.ResetFences = auto_cast GetDeviceProcAddr(device, "vkResetFences") - vtable.ResetQueryPool = auto_cast GetDeviceProcAddr(device, "vkResetQueryPool") - vtable.ResetQueryPoolEXT = auto_cast GetDeviceProcAddr(device, "vkResetQueryPoolEXT") - vtable.SetDebugUtilsObjectNameEXT = auto_cast GetDeviceProcAddr(device, "vkSetDebugUtilsObjectNameEXT") - vtable.SetDebugUtilsObjectTagEXT = auto_cast GetDeviceProcAddr(device, "vkSetDebugUtilsObjectTagEXT") - vtable.SetDeviceMemoryPriorityEXT = auto_cast GetDeviceProcAddr(device, "vkSetDeviceMemoryPriorityEXT") - vtable.SetEvent = auto_cast GetDeviceProcAddr(device, "vkSetEvent") - vtable.SetHdrMetadataEXT = auto_cast GetDeviceProcAddr(device, "vkSetHdrMetadataEXT") - vtable.SetLocalDimmingAMD = auto_cast GetDeviceProcAddr(device, "vkSetLocalDimmingAMD") - vtable.SetPrivateData = auto_cast GetDeviceProcAddr(device, "vkSetPrivateData") - vtable.SetPrivateDataEXT = auto_cast GetDeviceProcAddr(device, "vkSetPrivateDataEXT") - vtable.SignalSemaphore = auto_cast GetDeviceProcAddr(device, "vkSignalSemaphore") - vtable.SignalSemaphoreKHR = auto_cast GetDeviceProcAddr(device, "vkSignalSemaphoreKHR") - vtable.TrimCommandPool = auto_cast GetDeviceProcAddr(device, "vkTrimCommandPool") - vtable.TrimCommandPoolKHR = auto_cast GetDeviceProcAddr(device, "vkTrimCommandPoolKHR") - vtable.UninitializePerformanceApiINTEL = auto_cast GetDeviceProcAddr(device, "vkUninitializePerformanceApiINTEL") - vtable.UnmapMemory = auto_cast GetDeviceProcAddr(device, "vkUnmapMemory") - vtable.UpdateDescriptorSetWithTemplate = auto_cast GetDeviceProcAddr(device, "vkUpdateDescriptorSetWithTemplate") - vtable.UpdateDescriptorSetWithTemplateKHR = auto_cast GetDeviceProcAddr(device, "vkUpdateDescriptorSetWithTemplateKHR") - vtable.UpdateDescriptorSets = auto_cast GetDeviceProcAddr(device, "vkUpdateDescriptorSets") - vtable.WaitForFences = auto_cast GetDeviceProcAddr(device, "vkWaitForFences") - vtable.WaitForPresentKHR = auto_cast GetDeviceProcAddr(device, "vkWaitForPresentKHR") - vtable.WaitSemaphores = auto_cast GetDeviceProcAddr(device, "vkWaitSemaphores") - vtable.WaitSemaphoresKHR = auto_cast GetDeviceProcAddr(device, "vkWaitSemaphoresKHR") - vtable.WriteAccelerationStructuresPropertiesKHR = auto_cast GetDeviceProcAddr(device, "vkWriteAccelerationStructuresPropertiesKHR") -} - -load_proc_addresses_device :: proc(device: Device) { - AcquireFullScreenExclusiveModeEXT = auto_cast GetDeviceProcAddr(device, "vkAcquireFullScreenExclusiveModeEXT") - AcquireNextImage2KHR = auto_cast GetDeviceProcAddr(device, "vkAcquireNextImage2KHR") - AcquireNextImageKHR = auto_cast GetDeviceProcAddr(device, "vkAcquireNextImageKHR") - AcquirePerformanceConfigurationINTEL = auto_cast GetDeviceProcAddr(device, "vkAcquirePerformanceConfigurationINTEL") - AcquireProfilingLockKHR = auto_cast GetDeviceProcAddr(device, "vkAcquireProfilingLockKHR") - AllocateCommandBuffers = auto_cast GetDeviceProcAddr(device, "vkAllocateCommandBuffers") - AllocateDescriptorSets = auto_cast GetDeviceProcAddr(device, "vkAllocateDescriptorSets") - AllocateMemory = auto_cast GetDeviceProcAddr(device, "vkAllocateMemory") - BeginCommandBuffer = auto_cast GetDeviceProcAddr(device, "vkBeginCommandBuffer") - BindAccelerationStructureMemoryNV = auto_cast GetDeviceProcAddr(device, "vkBindAccelerationStructureMemoryNV") - BindBufferMemory = auto_cast GetDeviceProcAddr(device, "vkBindBufferMemory") - BindBufferMemory2 = auto_cast GetDeviceProcAddr(device, "vkBindBufferMemory2") - BindBufferMemory2KHR = auto_cast GetDeviceProcAddr(device, "vkBindBufferMemory2KHR") - BindImageMemory = auto_cast GetDeviceProcAddr(device, "vkBindImageMemory") - BindImageMemory2 = auto_cast GetDeviceProcAddr(device, "vkBindImageMemory2") - BindImageMemory2KHR = auto_cast GetDeviceProcAddr(device, "vkBindImageMemory2KHR") - BuildAccelerationStructuresKHR = auto_cast GetDeviceProcAddr(device, "vkBuildAccelerationStructuresKHR") - CmdBeginConditionalRenderingEXT = auto_cast GetDeviceProcAddr(device, "vkCmdBeginConditionalRenderingEXT") - CmdBeginDebugUtilsLabelEXT = auto_cast GetDeviceProcAddr(device, "vkCmdBeginDebugUtilsLabelEXT") - CmdBeginQuery = auto_cast GetDeviceProcAddr(device, "vkCmdBeginQuery") - CmdBeginQueryIndexedEXT = auto_cast GetDeviceProcAddr(device, "vkCmdBeginQueryIndexedEXT") - CmdBeginRenderPass = auto_cast GetDeviceProcAddr(device, "vkCmdBeginRenderPass") - CmdBeginRenderPass2 = auto_cast GetDeviceProcAddr(device, "vkCmdBeginRenderPass2") - CmdBeginRenderPass2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdBeginRenderPass2KHR") - CmdBeginRendering = auto_cast GetDeviceProcAddr(device, "vkCmdBeginRendering") - CmdBeginRenderingKHR = auto_cast GetDeviceProcAddr(device, "vkCmdBeginRenderingKHR") - CmdBeginTransformFeedbackEXT = auto_cast GetDeviceProcAddr(device, "vkCmdBeginTransformFeedbackEXT") - CmdBindDescriptorSets = auto_cast GetDeviceProcAddr(device, "vkCmdBindDescriptorSets") - CmdBindIndexBuffer = auto_cast GetDeviceProcAddr(device, "vkCmdBindIndexBuffer") - CmdBindInvocationMaskHUAWEI = auto_cast GetDeviceProcAddr(device, "vkCmdBindInvocationMaskHUAWEI") - CmdBindPipeline = auto_cast GetDeviceProcAddr(device, "vkCmdBindPipeline") - CmdBindPipelineShaderGroupNV = auto_cast GetDeviceProcAddr(device, "vkCmdBindPipelineShaderGroupNV") - CmdBindShadingRateImageNV = auto_cast GetDeviceProcAddr(device, "vkCmdBindShadingRateImageNV") - CmdBindTransformFeedbackBuffersEXT = auto_cast GetDeviceProcAddr(device, "vkCmdBindTransformFeedbackBuffersEXT") - CmdBindVertexBuffers = auto_cast GetDeviceProcAddr(device, "vkCmdBindVertexBuffers") - CmdBindVertexBuffers2 = auto_cast GetDeviceProcAddr(device, "vkCmdBindVertexBuffers2") - CmdBindVertexBuffers2EXT = auto_cast GetDeviceProcAddr(device, "vkCmdBindVertexBuffers2EXT") - CmdBlitImage = auto_cast GetDeviceProcAddr(device, "vkCmdBlitImage") - CmdBlitImage2 = auto_cast GetDeviceProcAddr(device, "vkCmdBlitImage2") - CmdBlitImage2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdBlitImage2KHR") - CmdBuildAccelerationStructureNV = auto_cast GetDeviceProcAddr(device, "vkCmdBuildAccelerationStructureNV") - CmdBuildAccelerationStructuresIndirectKHR = auto_cast GetDeviceProcAddr(device, "vkCmdBuildAccelerationStructuresIndirectKHR") - CmdBuildAccelerationStructuresKHR = auto_cast GetDeviceProcAddr(device, "vkCmdBuildAccelerationStructuresKHR") - CmdClearAttachments = auto_cast GetDeviceProcAddr(device, "vkCmdClearAttachments") - CmdClearColorImage = auto_cast GetDeviceProcAddr(device, "vkCmdClearColorImage") - CmdClearDepthStencilImage = auto_cast GetDeviceProcAddr(device, "vkCmdClearDepthStencilImage") - CmdCopyAccelerationStructureKHR = auto_cast GetDeviceProcAddr(device, "vkCmdCopyAccelerationStructureKHR") - CmdCopyAccelerationStructureNV = auto_cast GetDeviceProcAddr(device, "vkCmdCopyAccelerationStructureNV") - CmdCopyAccelerationStructureToMemoryKHR = auto_cast GetDeviceProcAddr(device, "vkCmdCopyAccelerationStructureToMemoryKHR") - CmdCopyBuffer = auto_cast GetDeviceProcAddr(device, "vkCmdCopyBuffer") - CmdCopyBuffer2 = auto_cast GetDeviceProcAddr(device, "vkCmdCopyBuffer2") - CmdCopyBuffer2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdCopyBuffer2KHR") - CmdCopyBufferToImage = auto_cast GetDeviceProcAddr(device, "vkCmdCopyBufferToImage") - CmdCopyBufferToImage2 = auto_cast GetDeviceProcAddr(device, "vkCmdCopyBufferToImage2") - CmdCopyBufferToImage2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdCopyBufferToImage2KHR") - CmdCopyImage = auto_cast GetDeviceProcAddr(device, "vkCmdCopyImage") - CmdCopyImage2 = auto_cast GetDeviceProcAddr(device, "vkCmdCopyImage2") - CmdCopyImage2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdCopyImage2KHR") - CmdCopyImageToBuffer = auto_cast GetDeviceProcAddr(device, "vkCmdCopyImageToBuffer") - CmdCopyImageToBuffer2 = auto_cast GetDeviceProcAddr(device, "vkCmdCopyImageToBuffer2") - CmdCopyImageToBuffer2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdCopyImageToBuffer2KHR") - CmdCopyMemoryToAccelerationStructureKHR = auto_cast GetDeviceProcAddr(device, "vkCmdCopyMemoryToAccelerationStructureKHR") - CmdCopyQueryPoolResults = auto_cast GetDeviceProcAddr(device, "vkCmdCopyQueryPoolResults") - CmdCuLaunchKernelNVX = auto_cast GetDeviceProcAddr(device, "vkCmdCuLaunchKernelNVX") - CmdDebugMarkerBeginEXT = auto_cast GetDeviceProcAddr(device, "vkCmdDebugMarkerBeginEXT") - CmdDebugMarkerEndEXT = auto_cast GetDeviceProcAddr(device, "vkCmdDebugMarkerEndEXT") - CmdDebugMarkerInsertEXT = auto_cast GetDeviceProcAddr(device, "vkCmdDebugMarkerInsertEXT") - CmdDispatch = auto_cast GetDeviceProcAddr(device, "vkCmdDispatch") - CmdDispatchBase = auto_cast GetDeviceProcAddr(device, "vkCmdDispatchBase") - CmdDispatchBaseKHR = auto_cast GetDeviceProcAddr(device, "vkCmdDispatchBaseKHR") - CmdDispatchIndirect = auto_cast GetDeviceProcAddr(device, "vkCmdDispatchIndirect") - CmdDraw = auto_cast GetDeviceProcAddr(device, "vkCmdDraw") - CmdDrawIndexed = auto_cast GetDeviceProcAddr(device, "vkCmdDrawIndexed") - CmdDrawIndexedIndirect = auto_cast GetDeviceProcAddr(device, "vkCmdDrawIndexedIndirect") - CmdDrawIndexedIndirectCount = auto_cast GetDeviceProcAddr(device, "vkCmdDrawIndexedIndirectCount") - CmdDrawIndexedIndirectCountAMD = auto_cast GetDeviceProcAddr(device, "vkCmdDrawIndexedIndirectCountAMD") - CmdDrawIndexedIndirectCountKHR = auto_cast GetDeviceProcAddr(device, "vkCmdDrawIndexedIndirectCountKHR") - CmdDrawIndirect = auto_cast GetDeviceProcAddr(device, "vkCmdDrawIndirect") - CmdDrawIndirectByteCountEXT = auto_cast GetDeviceProcAddr(device, "vkCmdDrawIndirectByteCountEXT") - CmdDrawIndirectCount = auto_cast GetDeviceProcAddr(device, "vkCmdDrawIndirectCount") - CmdDrawIndirectCountAMD = auto_cast GetDeviceProcAddr(device, "vkCmdDrawIndirectCountAMD") - CmdDrawIndirectCountKHR = auto_cast GetDeviceProcAddr(device, "vkCmdDrawIndirectCountKHR") - CmdDrawMeshTasksIndirectCountNV = auto_cast GetDeviceProcAddr(device, "vkCmdDrawMeshTasksIndirectCountNV") - CmdDrawMeshTasksIndirectNV = auto_cast GetDeviceProcAddr(device, "vkCmdDrawMeshTasksIndirectNV") - CmdDrawMeshTasksNV = auto_cast GetDeviceProcAddr(device, "vkCmdDrawMeshTasksNV") - CmdDrawMultiEXT = auto_cast GetDeviceProcAddr(device, "vkCmdDrawMultiEXT") - CmdDrawMultiIndexedEXT = auto_cast GetDeviceProcAddr(device, "vkCmdDrawMultiIndexedEXT") - CmdEndConditionalRenderingEXT = auto_cast GetDeviceProcAddr(device, "vkCmdEndConditionalRenderingEXT") - CmdEndDebugUtilsLabelEXT = auto_cast GetDeviceProcAddr(device, "vkCmdEndDebugUtilsLabelEXT") - CmdEndQuery = auto_cast GetDeviceProcAddr(device, "vkCmdEndQuery") - CmdEndQueryIndexedEXT = auto_cast GetDeviceProcAddr(device, "vkCmdEndQueryIndexedEXT") - CmdEndRenderPass = auto_cast GetDeviceProcAddr(device, "vkCmdEndRenderPass") - CmdEndRenderPass2 = auto_cast GetDeviceProcAddr(device, "vkCmdEndRenderPass2") - CmdEndRenderPass2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdEndRenderPass2KHR") - CmdEndRendering = auto_cast GetDeviceProcAddr(device, "vkCmdEndRendering") - CmdEndRenderingKHR = auto_cast GetDeviceProcAddr(device, "vkCmdEndRenderingKHR") - CmdEndTransformFeedbackEXT = auto_cast GetDeviceProcAddr(device, "vkCmdEndTransformFeedbackEXT") - CmdExecuteCommands = auto_cast GetDeviceProcAddr(device, "vkCmdExecuteCommands") - CmdExecuteGeneratedCommandsNV = auto_cast GetDeviceProcAddr(device, "vkCmdExecuteGeneratedCommandsNV") - CmdFillBuffer = auto_cast GetDeviceProcAddr(device, "vkCmdFillBuffer") - CmdInsertDebugUtilsLabelEXT = auto_cast GetDeviceProcAddr(device, "vkCmdInsertDebugUtilsLabelEXT") - CmdNextSubpass = auto_cast GetDeviceProcAddr(device, "vkCmdNextSubpass") - CmdNextSubpass2 = auto_cast GetDeviceProcAddr(device, "vkCmdNextSubpass2") - CmdNextSubpass2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdNextSubpass2KHR") - CmdPipelineBarrier = auto_cast GetDeviceProcAddr(device, "vkCmdPipelineBarrier") - CmdPipelineBarrier2 = auto_cast GetDeviceProcAddr(device, "vkCmdPipelineBarrier2") - CmdPipelineBarrier2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdPipelineBarrier2KHR") - CmdPreprocessGeneratedCommandsNV = auto_cast GetDeviceProcAddr(device, "vkCmdPreprocessGeneratedCommandsNV") - CmdPushConstants = auto_cast GetDeviceProcAddr(device, "vkCmdPushConstants") - CmdPushDescriptorSetKHR = auto_cast GetDeviceProcAddr(device, "vkCmdPushDescriptorSetKHR") - CmdPushDescriptorSetWithTemplateKHR = auto_cast GetDeviceProcAddr(device, "vkCmdPushDescriptorSetWithTemplateKHR") - CmdResetEvent = auto_cast GetDeviceProcAddr(device, "vkCmdResetEvent") - CmdResetEvent2 = auto_cast GetDeviceProcAddr(device, "vkCmdResetEvent2") - CmdResetEvent2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdResetEvent2KHR") - CmdResetQueryPool = auto_cast GetDeviceProcAddr(device, "vkCmdResetQueryPool") - CmdResolveImage = auto_cast GetDeviceProcAddr(device, "vkCmdResolveImage") - CmdResolveImage2 = auto_cast GetDeviceProcAddr(device, "vkCmdResolveImage2") - CmdResolveImage2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdResolveImage2KHR") - CmdSetBlendConstants = auto_cast GetDeviceProcAddr(device, "vkCmdSetBlendConstants") - CmdSetCheckpointNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetCheckpointNV") - CmdSetCoarseSampleOrderNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetCoarseSampleOrderNV") - CmdSetCullMode = auto_cast GetDeviceProcAddr(device, "vkCmdSetCullMode") - CmdSetCullModeEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetCullModeEXT") - CmdSetDepthBias = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthBias") - CmdSetDepthBiasEnable = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthBiasEnable") - CmdSetDepthBiasEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthBiasEnableEXT") - CmdSetDepthBounds = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthBounds") - CmdSetDepthBoundsTestEnable = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthBoundsTestEnable") - CmdSetDepthBoundsTestEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthBoundsTestEnableEXT") - CmdSetDepthCompareOp = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthCompareOp") - CmdSetDepthCompareOpEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthCompareOpEXT") - CmdSetDepthTestEnable = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthTestEnable") - CmdSetDepthTestEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthTestEnableEXT") - CmdSetDepthWriteEnable = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthWriteEnable") - CmdSetDepthWriteEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthWriteEnableEXT") - CmdSetDeviceMask = auto_cast GetDeviceProcAddr(device, "vkCmdSetDeviceMask") - CmdSetDeviceMaskKHR = auto_cast GetDeviceProcAddr(device, "vkCmdSetDeviceMaskKHR") - CmdSetDiscardRectangleEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetDiscardRectangleEXT") - CmdSetEvent = auto_cast GetDeviceProcAddr(device, "vkCmdSetEvent") - CmdSetEvent2 = auto_cast GetDeviceProcAddr(device, "vkCmdSetEvent2") - CmdSetEvent2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdSetEvent2KHR") - CmdSetExclusiveScissorNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetExclusiveScissorNV") - CmdSetFragmentShadingRateEnumNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetFragmentShadingRateEnumNV") - CmdSetFragmentShadingRateKHR = auto_cast GetDeviceProcAddr(device, "vkCmdSetFragmentShadingRateKHR") - CmdSetFrontFace = auto_cast GetDeviceProcAddr(device, "vkCmdSetFrontFace") - CmdSetFrontFaceEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetFrontFaceEXT") - CmdSetLineStippleEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetLineStippleEXT") - CmdSetLineWidth = auto_cast GetDeviceProcAddr(device, "vkCmdSetLineWidth") - CmdSetLogicOpEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetLogicOpEXT") - CmdSetPatchControlPointsEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetPatchControlPointsEXT") - CmdSetPerformanceMarkerINTEL = auto_cast GetDeviceProcAddr(device, "vkCmdSetPerformanceMarkerINTEL") - CmdSetPerformanceOverrideINTEL = auto_cast GetDeviceProcAddr(device, "vkCmdSetPerformanceOverrideINTEL") - CmdSetPerformanceStreamMarkerINTEL = auto_cast GetDeviceProcAddr(device, "vkCmdSetPerformanceStreamMarkerINTEL") - CmdSetPrimitiveRestartEnable = auto_cast GetDeviceProcAddr(device, "vkCmdSetPrimitiveRestartEnable") - CmdSetPrimitiveRestartEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetPrimitiveRestartEnableEXT") - CmdSetPrimitiveTopology = auto_cast GetDeviceProcAddr(device, "vkCmdSetPrimitiveTopology") - CmdSetPrimitiveTopologyEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetPrimitiveTopologyEXT") - CmdSetRasterizerDiscardEnable = auto_cast GetDeviceProcAddr(device, "vkCmdSetRasterizerDiscardEnable") - CmdSetRasterizerDiscardEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetRasterizerDiscardEnableEXT") - CmdSetRayTracingPipelineStackSizeKHR = auto_cast GetDeviceProcAddr(device, "vkCmdSetRayTracingPipelineStackSizeKHR") - CmdSetSampleLocationsEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetSampleLocationsEXT") - CmdSetScissor = auto_cast GetDeviceProcAddr(device, "vkCmdSetScissor") - CmdSetScissorWithCount = auto_cast GetDeviceProcAddr(device, "vkCmdSetScissorWithCount") - CmdSetScissorWithCountEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetScissorWithCountEXT") - CmdSetStencilCompareMask = auto_cast GetDeviceProcAddr(device, "vkCmdSetStencilCompareMask") - CmdSetStencilOp = auto_cast GetDeviceProcAddr(device, "vkCmdSetStencilOp") - CmdSetStencilOpEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetStencilOpEXT") - CmdSetStencilReference = auto_cast GetDeviceProcAddr(device, "vkCmdSetStencilReference") - CmdSetStencilTestEnable = auto_cast GetDeviceProcAddr(device, "vkCmdSetStencilTestEnable") - CmdSetStencilTestEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetStencilTestEnableEXT") - CmdSetStencilWriteMask = auto_cast GetDeviceProcAddr(device, "vkCmdSetStencilWriteMask") - CmdSetVertexInputEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetVertexInputEXT") - CmdSetViewport = auto_cast GetDeviceProcAddr(device, "vkCmdSetViewport") - CmdSetViewportShadingRatePaletteNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetViewportShadingRatePaletteNV") - CmdSetViewportWScalingNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetViewportWScalingNV") - CmdSetViewportWithCount = auto_cast GetDeviceProcAddr(device, "vkCmdSetViewportWithCount") - CmdSetViewportWithCountEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetViewportWithCountEXT") - CmdSubpassShadingHUAWEI = auto_cast GetDeviceProcAddr(device, "vkCmdSubpassShadingHUAWEI") - CmdTraceRaysIndirectKHR = auto_cast GetDeviceProcAddr(device, "vkCmdTraceRaysIndirectKHR") - CmdTraceRaysKHR = auto_cast GetDeviceProcAddr(device, "vkCmdTraceRaysKHR") - CmdTraceRaysNV = auto_cast GetDeviceProcAddr(device, "vkCmdTraceRaysNV") - CmdUpdateBuffer = auto_cast GetDeviceProcAddr(device, "vkCmdUpdateBuffer") - CmdWaitEvents = auto_cast GetDeviceProcAddr(device, "vkCmdWaitEvents") - CmdWaitEvents2 = auto_cast GetDeviceProcAddr(device, "vkCmdWaitEvents2") - CmdWaitEvents2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdWaitEvents2KHR") - CmdWriteAccelerationStructuresPropertiesKHR = auto_cast GetDeviceProcAddr(device, "vkCmdWriteAccelerationStructuresPropertiesKHR") - CmdWriteAccelerationStructuresPropertiesNV = auto_cast GetDeviceProcAddr(device, "vkCmdWriteAccelerationStructuresPropertiesNV") - CmdWriteBufferMarker2AMD = auto_cast GetDeviceProcAddr(device, "vkCmdWriteBufferMarker2AMD") - CmdWriteBufferMarkerAMD = auto_cast GetDeviceProcAddr(device, "vkCmdWriteBufferMarkerAMD") - CmdWriteTimestamp = auto_cast GetDeviceProcAddr(device, "vkCmdWriteTimestamp") - CmdWriteTimestamp2 = auto_cast GetDeviceProcAddr(device, "vkCmdWriteTimestamp2") - CmdWriteTimestamp2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdWriteTimestamp2KHR") - CompileDeferredNV = auto_cast GetDeviceProcAddr(device, "vkCompileDeferredNV") - CopyAccelerationStructureKHR = auto_cast GetDeviceProcAddr(device, "vkCopyAccelerationStructureKHR") - CopyAccelerationStructureToMemoryKHR = auto_cast GetDeviceProcAddr(device, "vkCopyAccelerationStructureToMemoryKHR") - CopyMemoryToAccelerationStructureKHR = auto_cast GetDeviceProcAddr(device, "vkCopyMemoryToAccelerationStructureKHR") - CreateAccelerationStructureKHR = auto_cast GetDeviceProcAddr(device, "vkCreateAccelerationStructureKHR") - CreateAccelerationStructureNV = auto_cast GetDeviceProcAddr(device, "vkCreateAccelerationStructureNV") - CreateBuffer = auto_cast GetDeviceProcAddr(device, "vkCreateBuffer") - CreateBufferView = auto_cast GetDeviceProcAddr(device, "vkCreateBufferView") - CreateCommandPool = auto_cast GetDeviceProcAddr(device, "vkCreateCommandPool") - CreateComputePipelines = auto_cast GetDeviceProcAddr(device, "vkCreateComputePipelines") - CreateCuFunctionNVX = auto_cast GetDeviceProcAddr(device, "vkCreateCuFunctionNVX") - CreateCuModuleNVX = auto_cast GetDeviceProcAddr(device, "vkCreateCuModuleNVX") - CreateDeferredOperationKHR = auto_cast GetDeviceProcAddr(device, "vkCreateDeferredOperationKHR") - CreateDescriptorPool = auto_cast GetDeviceProcAddr(device, "vkCreateDescriptorPool") - CreateDescriptorSetLayout = auto_cast GetDeviceProcAddr(device, "vkCreateDescriptorSetLayout") - CreateDescriptorUpdateTemplate = auto_cast GetDeviceProcAddr(device, "vkCreateDescriptorUpdateTemplate") - CreateDescriptorUpdateTemplateKHR = auto_cast GetDeviceProcAddr(device, "vkCreateDescriptorUpdateTemplateKHR") - CreateEvent = auto_cast GetDeviceProcAddr(device, "vkCreateEvent") - CreateFence = auto_cast GetDeviceProcAddr(device, "vkCreateFence") - CreateFramebuffer = auto_cast GetDeviceProcAddr(device, "vkCreateFramebuffer") - CreateGraphicsPipelines = auto_cast GetDeviceProcAddr(device, "vkCreateGraphicsPipelines") - CreateImage = auto_cast GetDeviceProcAddr(device, "vkCreateImage") - CreateImageView = auto_cast GetDeviceProcAddr(device, "vkCreateImageView") - CreateIndirectCommandsLayoutNV = auto_cast GetDeviceProcAddr(device, "vkCreateIndirectCommandsLayoutNV") - CreatePipelineCache = auto_cast GetDeviceProcAddr(device, "vkCreatePipelineCache") - CreatePipelineLayout = auto_cast GetDeviceProcAddr(device, "vkCreatePipelineLayout") - CreatePrivateDataSlot = auto_cast GetDeviceProcAddr(device, "vkCreatePrivateDataSlot") - CreatePrivateDataSlotEXT = auto_cast GetDeviceProcAddr(device, "vkCreatePrivateDataSlotEXT") - CreateQueryPool = auto_cast GetDeviceProcAddr(device, "vkCreateQueryPool") - CreateRayTracingPipelinesKHR = auto_cast GetDeviceProcAddr(device, "vkCreateRayTracingPipelinesKHR") - CreateRayTracingPipelinesNV = auto_cast GetDeviceProcAddr(device, "vkCreateRayTracingPipelinesNV") - CreateRenderPass = auto_cast GetDeviceProcAddr(device, "vkCreateRenderPass") - CreateRenderPass2 = auto_cast GetDeviceProcAddr(device, "vkCreateRenderPass2") - CreateRenderPass2KHR = auto_cast GetDeviceProcAddr(device, "vkCreateRenderPass2KHR") - CreateSampler = auto_cast GetDeviceProcAddr(device, "vkCreateSampler") - CreateSamplerYcbcrConversion = auto_cast GetDeviceProcAddr(device, "vkCreateSamplerYcbcrConversion") - CreateSamplerYcbcrConversionKHR = auto_cast GetDeviceProcAddr(device, "vkCreateSamplerYcbcrConversionKHR") - CreateSemaphore = auto_cast GetDeviceProcAddr(device, "vkCreateSemaphore") - CreateShaderModule = auto_cast GetDeviceProcAddr(device, "vkCreateShaderModule") - CreateSharedSwapchainsKHR = auto_cast GetDeviceProcAddr(device, "vkCreateSharedSwapchainsKHR") - CreateSwapchainKHR = auto_cast GetDeviceProcAddr(device, "vkCreateSwapchainKHR") - CreateValidationCacheEXT = auto_cast GetDeviceProcAddr(device, "vkCreateValidationCacheEXT") - DebugMarkerSetObjectNameEXT = auto_cast GetDeviceProcAddr(device, "vkDebugMarkerSetObjectNameEXT") - DebugMarkerSetObjectTagEXT = auto_cast GetDeviceProcAddr(device, "vkDebugMarkerSetObjectTagEXT") - DeferredOperationJoinKHR = auto_cast GetDeviceProcAddr(device, "vkDeferredOperationJoinKHR") - DestroyAccelerationStructureKHR = auto_cast GetDeviceProcAddr(device, "vkDestroyAccelerationStructureKHR") - DestroyAccelerationStructureNV = auto_cast GetDeviceProcAddr(device, "vkDestroyAccelerationStructureNV") - DestroyBuffer = auto_cast GetDeviceProcAddr(device, "vkDestroyBuffer") - DestroyBufferView = auto_cast GetDeviceProcAddr(device, "vkDestroyBufferView") - DestroyCommandPool = auto_cast GetDeviceProcAddr(device, "vkDestroyCommandPool") - DestroyCuFunctionNVX = auto_cast GetDeviceProcAddr(device, "vkDestroyCuFunctionNVX") - DestroyCuModuleNVX = auto_cast GetDeviceProcAddr(device, "vkDestroyCuModuleNVX") - DestroyDeferredOperationKHR = auto_cast GetDeviceProcAddr(device, "vkDestroyDeferredOperationKHR") - DestroyDescriptorPool = auto_cast GetDeviceProcAddr(device, "vkDestroyDescriptorPool") - DestroyDescriptorSetLayout = auto_cast GetDeviceProcAddr(device, "vkDestroyDescriptorSetLayout") - DestroyDescriptorUpdateTemplate = auto_cast GetDeviceProcAddr(device, "vkDestroyDescriptorUpdateTemplate") - DestroyDescriptorUpdateTemplateKHR = auto_cast GetDeviceProcAddr(device, "vkDestroyDescriptorUpdateTemplateKHR") - DestroyDevice = auto_cast GetDeviceProcAddr(device, "vkDestroyDevice") - DestroyEvent = auto_cast GetDeviceProcAddr(device, "vkDestroyEvent") - DestroyFence = auto_cast GetDeviceProcAddr(device, "vkDestroyFence") - DestroyFramebuffer = auto_cast GetDeviceProcAddr(device, "vkDestroyFramebuffer") - DestroyImage = auto_cast GetDeviceProcAddr(device, "vkDestroyImage") - DestroyImageView = auto_cast GetDeviceProcAddr(device, "vkDestroyImageView") - DestroyIndirectCommandsLayoutNV = auto_cast GetDeviceProcAddr(device, "vkDestroyIndirectCommandsLayoutNV") - DestroyPipeline = auto_cast GetDeviceProcAddr(device, "vkDestroyPipeline") - DestroyPipelineCache = auto_cast GetDeviceProcAddr(device, "vkDestroyPipelineCache") - DestroyPipelineLayout = auto_cast GetDeviceProcAddr(device, "vkDestroyPipelineLayout") - DestroyPrivateDataSlot = auto_cast GetDeviceProcAddr(device, "vkDestroyPrivateDataSlot") - DestroyPrivateDataSlotEXT = auto_cast GetDeviceProcAddr(device, "vkDestroyPrivateDataSlotEXT") - DestroyQueryPool = auto_cast GetDeviceProcAddr(device, "vkDestroyQueryPool") - DestroyRenderPass = auto_cast GetDeviceProcAddr(device, "vkDestroyRenderPass") - DestroySampler = auto_cast GetDeviceProcAddr(device, "vkDestroySampler") - DestroySamplerYcbcrConversion = auto_cast GetDeviceProcAddr(device, "vkDestroySamplerYcbcrConversion") - DestroySamplerYcbcrConversionKHR = auto_cast GetDeviceProcAddr(device, "vkDestroySamplerYcbcrConversionKHR") - DestroySemaphore = auto_cast GetDeviceProcAddr(device, "vkDestroySemaphore") - DestroyShaderModule = auto_cast GetDeviceProcAddr(device, "vkDestroyShaderModule") - DestroySwapchainKHR = auto_cast GetDeviceProcAddr(device, "vkDestroySwapchainKHR") - DestroyValidationCacheEXT = auto_cast GetDeviceProcAddr(device, "vkDestroyValidationCacheEXT") - DeviceWaitIdle = auto_cast GetDeviceProcAddr(device, "vkDeviceWaitIdle") - DisplayPowerControlEXT = auto_cast GetDeviceProcAddr(device, "vkDisplayPowerControlEXT") - EndCommandBuffer = auto_cast GetDeviceProcAddr(device, "vkEndCommandBuffer") - FlushMappedMemoryRanges = auto_cast GetDeviceProcAddr(device, "vkFlushMappedMemoryRanges") - FreeCommandBuffers = auto_cast GetDeviceProcAddr(device, "vkFreeCommandBuffers") - FreeDescriptorSets = auto_cast GetDeviceProcAddr(device, "vkFreeDescriptorSets") - FreeMemory = auto_cast GetDeviceProcAddr(device, "vkFreeMemory") - GetAccelerationStructureBuildSizesKHR = auto_cast GetDeviceProcAddr(device, "vkGetAccelerationStructureBuildSizesKHR") - GetAccelerationStructureDeviceAddressKHR = auto_cast GetDeviceProcAddr(device, "vkGetAccelerationStructureDeviceAddressKHR") - GetAccelerationStructureHandleNV = auto_cast GetDeviceProcAddr(device, "vkGetAccelerationStructureHandleNV") - GetAccelerationStructureMemoryRequirementsNV = auto_cast GetDeviceProcAddr(device, "vkGetAccelerationStructureMemoryRequirementsNV") - GetBufferDeviceAddress = auto_cast GetDeviceProcAddr(device, "vkGetBufferDeviceAddress") - GetBufferDeviceAddressEXT = auto_cast GetDeviceProcAddr(device, "vkGetBufferDeviceAddressEXT") - GetBufferDeviceAddressKHR = auto_cast GetDeviceProcAddr(device, "vkGetBufferDeviceAddressKHR") - GetBufferMemoryRequirements = auto_cast GetDeviceProcAddr(device, "vkGetBufferMemoryRequirements") - GetBufferMemoryRequirements2 = auto_cast GetDeviceProcAddr(device, "vkGetBufferMemoryRequirements2") - GetBufferMemoryRequirements2KHR = auto_cast GetDeviceProcAddr(device, "vkGetBufferMemoryRequirements2KHR") - GetBufferOpaqueCaptureAddress = auto_cast GetDeviceProcAddr(device, "vkGetBufferOpaqueCaptureAddress") - GetBufferOpaqueCaptureAddressKHR = auto_cast GetDeviceProcAddr(device, "vkGetBufferOpaqueCaptureAddressKHR") - GetCalibratedTimestampsEXT = auto_cast GetDeviceProcAddr(device, "vkGetCalibratedTimestampsEXT") - GetDeferredOperationMaxConcurrencyKHR = auto_cast GetDeviceProcAddr(device, "vkGetDeferredOperationMaxConcurrencyKHR") - GetDeferredOperationResultKHR = auto_cast GetDeviceProcAddr(device, "vkGetDeferredOperationResultKHR") - GetDescriptorSetHostMappingVALVE = auto_cast GetDeviceProcAddr(device, "vkGetDescriptorSetHostMappingVALVE") - GetDescriptorSetLayoutHostMappingInfoVALVE = auto_cast GetDeviceProcAddr(device, "vkGetDescriptorSetLayoutHostMappingInfoVALVE") - GetDescriptorSetLayoutSupport = auto_cast GetDeviceProcAddr(device, "vkGetDescriptorSetLayoutSupport") - GetDescriptorSetLayoutSupportKHR = auto_cast GetDeviceProcAddr(device, "vkGetDescriptorSetLayoutSupportKHR") - GetDeviceAccelerationStructureCompatibilityKHR = auto_cast GetDeviceProcAddr(device, "vkGetDeviceAccelerationStructureCompatibilityKHR") - GetDeviceBufferMemoryRequirements = auto_cast GetDeviceProcAddr(device, "vkGetDeviceBufferMemoryRequirements") - GetDeviceBufferMemoryRequirementsKHR = auto_cast GetDeviceProcAddr(device, "vkGetDeviceBufferMemoryRequirementsKHR") - GetDeviceGroupPeerMemoryFeatures = auto_cast GetDeviceProcAddr(device, "vkGetDeviceGroupPeerMemoryFeatures") - GetDeviceGroupPeerMemoryFeaturesKHR = auto_cast GetDeviceProcAddr(device, "vkGetDeviceGroupPeerMemoryFeaturesKHR") - GetDeviceGroupPresentCapabilitiesKHR = auto_cast GetDeviceProcAddr(device, "vkGetDeviceGroupPresentCapabilitiesKHR") - GetDeviceGroupSurfacePresentModes2EXT = auto_cast GetDeviceProcAddr(device, "vkGetDeviceGroupSurfacePresentModes2EXT") - GetDeviceGroupSurfacePresentModesKHR = auto_cast GetDeviceProcAddr(device, "vkGetDeviceGroupSurfacePresentModesKHR") - GetDeviceImageMemoryRequirements = auto_cast GetDeviceProcAddr(device, "vkGetDeviceImageMemoryRequirements") - GetDeviceImageMemoryRequirementsKHR = auto_cast GetDeviceProcAddr(device, "vkGetDeviceImageMemoryRequirementsKHR") - GetDeviceImageSparseMemoryRequirements = auto_cast GetDeviceProcAddr(device, "vkGetDeviceImageSparseMemoryRequirements") - GetDeviceImageSparseMemoryRequirementsKHR = auto_cast GetDeviceProcAddr(device, "vkGetDeviceImageSparseMemoryRequirementsKHR") - GetDeviceMemoryCommitment = auto_cast GetDeviceProcAddr(device, "vkGetDeviceMemoryCommitment") - GetDeviceMemoryOpaqueCaptureAddress = auto_cast GetDeviceProcAddr(device, "vkGetDeviceMemoryOpaqueCaptureAddress") - GetDeviceMemoryOpaqueCaptureAddressKHR = auto_cast GetDeviceProcAddr(device, "vkGetDeviceMemoryOpaqueCaptureAddressKHR") - GetDeviceProcAddr = auto_cast GetDeviceProcAddr(device, "vkGetDeviceProcAddr") - GetDeviceQueue = auto_cast GetDeviceProcAddr(device, "vkGetDeviceQueue") - GetDeviceQueue2 = auto_cast GetDeviceProcAddr(device, "vkGetDeviceQueue2") - GetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI = auto_cast GetDeviceProcAddr(device, "vkGetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI") - GetEventStatus = auto_cast GetDeviceProcAddr(device, "vkGetEventStatus") - GetFenceFdKHR = auto_cast GetDeviceProcAddr(device, "vkGetFenceFdKHR") - GetFenceStatus = auto_cast GetDeviceProcAddr(device, "vkGetFenceStatus") - GetFenceWin32HandleKHR = auto_cast GetDeviceProcAddr(device, "vkGetFenceWin32HandleKHR") - GetGeneratedCommandsMemoryRequirementsNV = auto_cast GetDeviceProcAddr(device, "vkGetGeneratedCommandsMemoryRequirementsNV") - GetImageDrmFormatModifierPropertiesEXT = auto_cast GetDeviceProcAddr(device, "vkGetImageDrmFormatModifierPropertiesEXT") - GetImageMemoryRequirements = auto_cast GetDeviceProcAddr(device, "vkGetImageMemoryRequirements") - GetImageMemoryRequirements2 = auto_cast GetDeviceProcAddr(device, "vkGetImageMemoryRequirements2") - GetImageMemoryRequirements2KHR = auto_cast GetDeviceProcAddr(device, "vkGetImageMemoryRequirements2KHR") - GetImageSparseMemoryRequirements = auto_cast GetDeviceProcAddr(device, "vkGetImageSparseMemoryRequirements") - GetImageSparseMemoryRequirements2 = auto_cast GetDeviceProcAddr(device, "vkGetImageSparseMemoryRequirements2") - GetImageSparseMemoryRequirements2KHR = auto_cast GetDeviceProcAddr(device, "vkGetImageSparseMemoryRequirements2KHR") - GetImageSubresourceLayout = auto_cast GetDeviceProcAddr(device, "vkGetImageSubresourceLayout") - GetImageViewAddressNVX = auto_cast GetDeviceProcAddr(device, "vkGetImageViewAddressNVX") - GetImageViewHandleNVX = auto_cast GetDeviceProcAddr(device, "vkGetImageViewHandleNVX") - GetMemoryFdKHR = auto_cast GetDeviceProcAddr(device, "vkGetMemoryFdKHR") - GetMemoryFdPropertiesKHR = auto_cast GetDeviceProcAddr(device, "vkGetMemoryFdPropertiesKHR") - GetMemoryHostPointerPropertiesEXT = auto_cast GetDeviceProcAddr(device, "vkGetMemoryHostPointerPropertiesEXT") - GetMemoryRemoteAddressNV = auto_cast GetDeviceProcAddr(device, "vkGetMemoryRemoteAddressNV") - GetMemoryWin32HandleKHR = auto_cast GetDeviceProcAddr(device, "vkGetMemoryWin32HandleKHR") - GetMemoryWin32HandleNV = auto_cast GetDeviceProcAddr(device, "vkGetMemoryWin32HandleNV") - GetMemoryWin32HandlePropertiesKHR = auto_cast GetDeviceProcAddr(device, "vkGetMemoryWin32HandlePropertiesKHR") - GetPastPresentationTimingGOOGLE = auto_cast GetDeviceProcAddr(device, "vkGetPastPresentationTimingGOOGLE") - GetPerformanceParameterINTEL = auto_cast GetDeviceProcAddr(device, "vkGetPerformanceParameterINTEL") - GetPipelineCacheData = auto_cast GetDeviceProcAddr(device, "vkGetPipelineCacheData") - GetPipelineExecutableInternalRepresentationsKHR = auto_cast GetDeviceProcAddr(device, "vkGetPipelineExecutableInternalRepresentationsKHR") - GetPipelineExecutablePropertiesKHR = auto_cast GetDeviceProcAddr(device, "vkGetPipelineExecutablePropertiesKHR") - GetPipelineExecutableStatisticsKHR = auto_cast GetDeviceProcAddr(device, "vkGetPipelineExecutableStatisticsKHR") - GetPrivateData = auto_cast GetDeviceProcAddr(device, "vkGetPrivateData") - GetPrivateDataEXT = auto_cast GetDeviceProcAddr(device, "vkGetPrivateDataEXT") - GetQueryPoolResults = auto_cast GetDeviceProcAddr(device, "vkGetQueryPoolResults") - GetQueueCheckpointData2NV = auto_cast GetDeviceProcAddr(device, "vkGetQueueCheckpointData2NV") - GetQueueCheckpointDataNV = auto_cast GetDeviceProcAddr(device, "vkGetQueueCheckpointDataNV") - GetRayTracingCaptureReplayShaderGroupHandlesKHR = auto_cast GetDeviceProcAddr(device, "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR") - GetRayTracingShaderGroupHandlesKHR = auto_cast GetDeviceProcAddr(device, "vkGetRayTracingShaderGroupHandlesKHR") - GetRayTracingShaderGroupHandlesNV = auto_cast GetDeviceProcAddr(device, "vkGetRayTracingShaderGroupHandlesNV") - GetRayTracingShaderGroupStackSizeKHR = auto_cast GetDeviceProcAddr(device, "vkGetRayTracingShaderGroupStackSizeKHR") - GetRefreshCycleDurationGOOGLE = auto_cast GetDeviceProcAddr(device, "vkGetRefreshCycleDurationGOOGLE") - GetRenderAreaGranularity = auto_cast GetDeviceProcAddr(device, "vkGetRenderAreaGranularity") - GetSemaphoreCounterValue = auto_cast GetDeviceProcAddr(device, "vkGetSemaphoreCounterValue") - GetSemaphoreCounterValueKHR = auto_cast GetDeviceProcAddr(device, "vkGetSemaphoreCounterValueKHR") - GetSemaphoreFdKHR = auto_cast GetDeviceProcAddr(device, "vkGetSemaphoreFdKHR") - GetSemaphoreWin32HandleKHR = auto_cast GetDeviceProcAddr(device, "vkGetSemaphoreWin32HandleKHR") - GetShaderInfoAMD = auto_cast GetDeviceProcAddr(device, "vkGetShaderInfoAMD") - GetSwapchainCounterEXT = auto_cast GetDeviceProcAddr(device, "vkGetSwapchainCounterEXT") - GetSwapchainImagesKHR = auto_cast GetDeviceProcAddr(device, "vkGetSwapchainImagesKHR") - GetSwapchainStatusKHR = auto_cast GetDeviceProcAddr(device, "vkGetSwapchainStatusKHR") - GetValidationCacheDataEXT = auto_cast GetDeviceProcAddr(device, "vkGetValidationCacheDataEXT") - ImportFenceFdKHR = auto_cast GetDeviceProcAddr(device, "vkImportFenceFdKHR") - ImportFenceWin32HandleKHR = auto_cast GetDeviceProcAddr(device, "vkImportFenceWin32HandleKHR") - ImportSemaphoreFdKHR = auto_cast GetDeviceProcAddr(device, "vkImportSemaphoreFdKHR") - ImportSemaphoreWin32HandleKHR = auto_cast GetDeviceProcAddr(device, "vkImportSemaphoreWin32HandleKHR") - InitializePerformanceApiINTEL = auto_cast GetDeviceProcAddr(device, "vkInitializePerformanceApiINTEL") - InvalidateMappedMemoryRanges = auto_cast GetDeviceProcAddr(device, "vkInvalidateMappedMemoryRanges") - MapMemory = auto_cast GetDeviceProcAddr(device, "vkMapMemory") - MergePipelineCaches = auto_cast GetDeviceProcAddr(device, "vkMergePipelineCaches") - MergeValidationCachesEXT = auto_cast GetDeviceProcAddr(device, "vkMergeValidationCachesEXT") - QueueBeginDebugUtilsLabelEXT = auto_cast GetDeviceProcAddr(device, "vkQueueBeginDebugUtilsLabelEXT") - QueueBindSparse = auto_cast GetDeviceProcAddr(device, "vkQueueBindSparse") - QueueEndDebugUtilsLabelEXT = auto_cast GetDeviceProcAddr(device, "vkQueueEndDebugUtilsLabelEXT") - QueueInsertDebugUtilsLabelEXT = auto_cast GetDeviceProcAddr(device, "vkQueueInsertDebugUtilsLabelEXT") - QueuePresentKHR = auto_cast GetDeviceProcAddr(device, "vkQueuePresentKHR") - QueueSetPerformanceConfigurationINTEL = auto_cast GetDeviceProcAddr(device, "vkQueueSetPerformanceConfigurationINTEL") - QueueSubmit = auto_cast GetDeviceProcAddr(device, "vkQueueSubmit") - QueueSubmit2 = auto_cast GetDeviceProcAddr(device, "vkQueueSubmit2") - QueueSubmit2KHR = auto_cast GetDeviceProcAddr(device, "vkQueueSubmit2KHR") - QueueWaitIdle = auto_cast GetDeviceProcAddr(device, "vkQueueWaitIdle") - RegisterDeviceEventEXT = auto_cast GetDeviceProcAddr(device, "vkRegisterDeviceEventEXT") - RegisterDisplayEventEXT = auto_cast GetDeviceProcAddr(device, "vkRegisterDisplayEventEXT") - ReleaseFullScreenExclusiveModeEXT = auto_cast GetDeviceProcAddr(device, "vkReleaseFullScreenExclusiveModeEXT") - ReleasePerformanceConfigurationINTEL = auto_cast GetDeviceProcAddr(device, "vkReleasePerformanceConfigurationINTEL") - ReleaseProfilingLockKHR = auto_cast GetDeviceProcAddr(device, "vkReleaseProfilingLockKHR") - ResetCommandBuffer = auto_cast GetDeviceProcAddr(device, "vkResetCommandBuffer") - ResetCommandPool = auto_cast GetDeviceProcAddr(device, "vkResetCommandPool") - ResetDescriptorPool = auto_cast GetDeviceProcAddr(device, "vkResetDescriptorPool") - ResetEvent = auto_cast GetDeviceProcAddr(device, "vkResetEvent") - ResetFences = auto_cast GetDeviceProcAddr(device, "vkResetFences") - ResetQueryPool = auto_cast GetDeviceProcAddr(device, "vkResetQueryPool") - ResetQueryPoolEXT = auto_cast GetDeviceProcAddr(device, "vkResetQueryPoolEXT") - SetDebugUtilsObjectNameEXT = auto_cast GetDeviceProcAddr(device, "vkSetDebugUtilsObjectNameEXT") - SetDebugUtilsObjectTagEXT = auto_cast GetDeviceProcAddr(device, "vkSetDebugUtilsObjectTagEXT") - SetDeviceMemoryPriorityEXT = auto_cast GetDeviceProcAddr(device, "vkSetDeviceMemoryPriorityEXT") - SetEvent = auto_cast GetDeviceProcAddr(device, "vkSetEvent") - SetHdrMetadataEXT = auto_cast GetDeviceProcAddr(device, "vkSetHdrMetadataEXT") - SetLocalDimmingAMD = auto_cast GetDeviceProcAddr(device, "vkSetLocalDimmingAMD") - SetPrivateData = auto_cast GetDeviceProcAddr(device, "vkSetPrivateData") - SetPrivateDataEXT = auto_cast GetDeviceProcAddr(device, "vkSetPrivateDataEXT") - SignalSemaphore = auto_cast GetDeviceProcAddr(device, "vkSignalSemaphore") - SignalSemaphoreKHR = auto_cast GetDeviceProcAddr(device, "vkSignalSemaphoreKHR") - TrimCommandPool = auto_cast GetDeviceProcAddr(device, "vkTrimCommandPool") - TrimCommandPoolKHR = auto_cast GetDeviceProcAddr(device, "vkTrimCommandPoolKHR") - UninitializePerformanceApiINTEL = auto_cast GetDeviceProcAddr(device, "vkUninitializePerformanceApiINTEL") - UnmapMemory = auto_cast GetDeviceProcAddr(device, "vkUnmapMemory") - UpdateDescriptorSetWithTemplate = auto_cast GetDeviceProcAddr(device, "vkUpdateDescriptorSetWithTemplate") - UpdateDescriptorSetWithTemplateKHR = auto_cast GetDeviceProcAddr(device, "vkUpdateDescriptorSetWithTemplateKHR") - UpdateDescriptorSets = auto_cast GetDeviceProcAddr(device, "vkUpdateDescriptorSets") - WaitForFences = auto_cast GetDeviceProcAddr(device, "vkWaitForFences") - WaitForPresentKHR = auto_cast GetDeviceProcAddr(device, "vkWaitForPresentKHR") - WaitSemaphores = auto_cast GetDeviceProcAddr(device, "vkWaitSemaphores") - WaitSemaphoresKHR = auto_cast GetDeviceProcAddr(device, "vkWaitSemaphoresKHR") - WriteAccelerationStructuresPropertiesKHR = auto_cast GetDeviceProcAddr(device, "vkWriteAccelerationStructuresPropertiesKHR") -} - -load_proc_addresses_instance :: proc(instance: Instance) { - AcquireDrmDisplayEXT = auto_cast GetInstanceProcAddr(instance, "vkAcquireDrmDisplayEXT") - AcquireWinrtDisplayNV = auto_cast GetInstanceProcAddr(instance, "vkAcquireWinrtDisplayNV") - CreateDebugReportCallbackEXT = auto_cast GetInstanceProcAddr(instance, "vkCreateDebugReportCallbackEXT") - CreateDebugUtilsMessengerEXT = auto_cast GetInstanceProcAddr(instance, "vkCreateDebugUtilsMessengerEXT") - CreateDevice = auto_cast GetInstanceProcAddr(instance, "vkCreateDevice") - CreateDisplayModeKHR = auto_cast GetInstanceProcAddr(instance, "vkCreateDisplayModeKHR") - CreateDisplayPlaneSurfaceKHR = auto_cast GetInstanceProcAddr(instance, "vkCreateDisplayPlaneSurfaceKHR") - CreateHeadlessSurfaceEXT = auto_cast GetInstanceProcAddr(instance, "vkCreateHeadlessSurfaceEXT") - CreateIOSSurfaceMVK = auto_cast GetInstanceProcAddr(instance, "vkCreateIOSSurfaceMVK") - CreateMacOSSurfaceMVK = auto_cast GetInstanceProcAddr(instance, "vkCreateMacOSSurfaceMVK") - CreateMetalSurfaceEXT = auto_cast GetInstanceProcAddr(instance, "vkCreateMetalSurfaceEXT") - CreateWin32SurfaceKHR = auto_cast GetInstanceProcAddr(instance, "vkCreateWin32SurfaceKHR") - DebugReportMessageEXT = auto_cast GetInstanceProcAddr(instance, "vkDebugReportMessageEXT") - DestroyDebugReportCallbackEXT = auto_cast GetInstanceProcAddr(instance, "vkDestroyDebugReportCallbackEXT") - DestroyDebugUtilsMessengerEXT = auto_cast GetInstanceProcAddr(instance, "vkDestroyDebugUtilsMessengerEXT") - DestroyInstance = auto_cast GetInstanceProcAddr(instance, "vkDestroyInstance") - DestroySurfaceKHR = auto_cast GetInstanceProcAddr(instance, "vkDestroySurfaceKHR") - EnumerateDeviceExtensionProperties = auto_cast GetInstanceProcAddr(instance, "vkEnumerateDeviceExtensionProperties") - EnumerateDeviceLayerProperties = auto_cast GetInstanceProcAddr(instance, "vkEnumerateDeviceLayerProperties") - EnumeratePhysicalDeviceGroups = auto_cast GetInstanceProcAddr(instance, "vkEnumeratePhysicalDeviceGroups") - EnumeratePhysicalDeviceGroupsKHR = auto_cast GetInstanceProcAddr(instance, "vkEnumeratePhysicalDeviceGroupsKHR") - EnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR = auto_cast GetInstanceProcAddr(instance, "vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR") - EnumeratePhysicalDevices = auto_cast GetInstanceProcAddr(instance, "vkEnumeratePhysicalDevices") - GetDisplayModeProperties2KHR = auto_cast GetInstanceProcAddr(instance, "vkGetDisplayModeProperties2KHR") - GetDisplayModePropertiesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetDisplayModePropertiesKHR") - GetDisplayPlaneCapabilities2KHR = auto_cast GetInstanceProcAddr(instance, "vkGetDisplayPlaneCapabilities2KHR") - GetDisplayPlaneCapabilitiesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetDisplayPlaneCapabilitiesKHR") - GetDisplayPlaneSupportedDisplaysKHR = auto_cast GetInstanceProcAddr(instance, "vkGetDisplayPlaneSupportedDisplaysKHR") - GetDrmDisplayEXT = auto_cast GetInstanceProcAddr(instance, "vkGetDrmDisplayEXT") - GetPhysicalDeviceCalibrateableTimeDomainsEXT = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceCalibrateableTimeDomainsEXT") - GetPhysicalDeviceCooperativeMatrixPropertiesNV = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceCooperativeMatrixPropertiesNV") - GetPhysicalDeviceDisplayPlaneProperties2KHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceDisplayPlaneProperties2KHR") - GetPhysicalDeviceDisplayPlanePropertiesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceDisplayPlanePropertiesKHR") - GetPhysicalDeviceDisplayProperties2KHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceDisplayProperties2KHR") - GetPhysicalDeviceDisplayPropertiesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceDisplayPropertiesKHR") - GetPhysicalDeviceExternalBufferProperties = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceExternalBufferProperties") - GetPhysicalDeviceExternalBufferPropertiesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceExternalBufferPropertiesKHR") - GetPhysicalDeviceExternalFenceProperties = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceExternalFenceProperties") - GetPhysicalDeviceExternalFencePropertiesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceExternalFencePropertiesKHR") - GetPhysicalDeviceExternalImageFormatPropertiesNV = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceExternalImageFormatPropertiesNV") - GetPhysicalDeviceExternalSemaphoreProperties = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceExternalSemaphoreProperties") - GetPhysicalDeviceExternalSemaphorePropertiesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceExternalSemaphorePropertiesKHR") - GetPhysicalDeviceFeatures = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceFeatures") - GetPhysicalDeviceFeatures2 = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceFeatures2") - GetPhysicalDeviceFeatures2KHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceFeatures2KHR") - GetPhysicalDeviceFormatProperties = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceFormatProperties") - GetPhysicalDeviceFormatProperties2 = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceFormatProperties2") - GetPhysicalDeviceFormatProperties2KHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceFormatProperties2KHR") - GetPhysicalDeviceFragmentShadingRatesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceFragmentShadingRatesKHR") - GetPhysicalDeviceImageFormatProperties = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceImageFormatProperties") - GetPhysicalDeviceImageFormatProperties2 = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceImageFormatProperties2") - GetPhysicalDeviceImageFormatProperties2KHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceImageFormatProperties2KHR") - GetPhysicalDeviceMemoryProperties = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceMemoryProperties") - GetPhysicalDeviceMemoryProperties2 = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceMemoryProperties2") - GetPhysicalDeviceMemoryProperties2KHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceMemoryProperties2KHR") - GetPhysicalDeviceMultisamplePropertiesEXT = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceMultisamplePropertiesEXT") - GetPhysicalDevicePresentRectanglesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDevicePresentRectanglesKHR") - GetPhysicalDeviceProperties = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceProperties") - GetPhysicalDeviceProperties2 = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceProperties2") - GetPhysicalDeviceProperties2KHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceProperties2KHR") - GetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR") - GetPhysicalDeviceQueueFamilyProperties = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceQueueFamilyProperties") - GetPhysicalDeviceQueueFamilyProperties2 = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceQueueFamilyProperties2") - GetPhysicalDeviceQueueFamilyProperties2KHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceQueueFamilyProperties2KHR") - GetPhysicalDeviceSparseImageFormatProperties = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceSparseImageFormatProperties") - GetPhysicalDeviceSparseImageFormatProperties2 = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceSparseImageFormatProperties2") - GetPhysicalDeviceSparseImageFormatProperties2KHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceSparseImageFormatProperties2KHR") - GetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV") - GetPhysicalDeviceSurfaceCapabilities2EXT = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceSurfaceCapabilities2EXT") - GetPhysicalDeviceSurfaceCapabilities2KHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceSurfaceCapabilities2KHR") - GetPhysicalDeviceSurfaceCapabilitiesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceSurfaceCapabilitiesKHR") - GetPhysicalDeviceSurfaceFormats2KHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceSurfaceFormats2KHR") - GetPhysicalDeviceSurfaceFormatsKHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceSurfaceFormatsKHR") - GetPhysicalDeviceSurfacePresentModes2EXT = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceSurfacePresentModes2EXT") - GetPhysicalDeviceSurfacePresentModesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceSurfacePresentModesKHR") - GetPhysicalDeviceSurfaceSupportKHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceSurfaceSupportKHR") - GetPhysicalDeviceToolProperties = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceToolProperties") - GetPhysicalDeviceToolPropertiesEXT = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceToolPropertiesEXT") - GetPhysicalDeviceWin32PresentationSupportKHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceWin32PresentationSupportKHR") - GetWinrtDisplayNV = auto_cast GetInstanceProcAddr(instance, "vkGetWinrtDisplayNV") - ReleaseDisplayEXT = auto_cast GetInstanceProcAddr(instance, "vkReleaseDisplayEXT") - SubmitDebugUtilsMessageEXT = auto_cast GetInstanceProcAddr(instance, "vkSubmitDebugUtilsMessageEXT") - - // Device Procedures (may call into dispatch) - AcquireFullScreenExclusiveModeEXT = auto_cast GetInstanceProcAddr(instance, "vkAcquireFullScreenExclusiveModeEXT") - AcquireNextImage2KHR = auto_cast GetInstanceProcAddr(instance, "vkAcquireNextImage2KHR") - AcquireNextImageKHR = auto_cast GetInstanceProcAddr(instance, "vkAcquireNextImageKHR") - AcquirePerformanceConfigurationINTEL = auto_cast GetInstanceProcAddr(instance, "vkAcquirePerformanceConfigurationINTEL") - AcquireProfilingLockKHR = auto_cast GetInstanceProcAddr(instance, "vkAcquireProfilingLockKHR") - AllocateCommandBuffers = auto_cast GetInstanceProcAddr(instance, "vkAllocateCommandBuffers") - AllocateDescriptorSets = auto_cast GetInstanceProcAddr(instance, "vkAllocateDescriptorSets") - AllocateMemory = auto_cast GetInstanceProcAddr(instance, "vkAllocateMemory") - BeginCommandBuffer = auto_cast GetInstanceProcAddr(instance, "vkBeginCommandBuffer") - BindAccelerationStructureMemoryNV = auto_cast GetInstanceProcAddr(instance, "vkBindAccelerationStructureMemoryNV") - BindBufferMemory = auto_cast GetInstanceProcAddr(instance, "vkBindBufferMemory") - BindBufferMemory2 = auto_cast GetInstanceProcAddr(instance, "vkBindBufferMemory2") - BindBufferMemory2KHR = auto_cast GetInstanceProcAddr(instance, "vkBindBufferMemory2KHR") - BindImageMemory = auto_cast GetInstanceProcAddr(instance, "vkBindImageMemory") - BindImageMemory2 = auto_cast GetInstanceProcAddr(instance, "vkBindImageMemory2") - BindImageMemory2KHR = auto_cast GetInstanceProcAddr(instance, "vkBindImageMemory2KHR") - BuildAccelerationStructuresKHR = auto_cast GetInstanceProcAddr(instance, "vkBuildAccelerationStructuresKHR") - CmdBeginConditionalRenderingEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdBeginConditionalRenderingEXT") - CmdBeginDebugUtilsLabelEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdBeginDebugUtilsLabelEXT") - CmdBeginQuery = auto_cast GetInstanceProcAddr(instance, "vkCmdBeginQuery") - CmdBeginQueryIndexedEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdBeginQueryIndexedEXT") - CmdBeginRenderPass = auto_cast GetInstanceProcAddr(instance, "vkCmdBeginRenderPass") - CmdBeginRenderPass2 = auto_cast GetInstanceProcAddr(instance, "vkCmdBeginRenderPass2") - CmdBeginRenderPass2KHR = auto_cast GetInstanceProcAddr(instance, "vkCmdBeginRenderPass2KHR") - CmdBeginRendering = auto_cast GetInstanceProcAddr(instance, "vkCmdBeginRendering") - CmdBeginRenderingKHR = auto_cast GetInstanceProcAddr(instance, "vkCmdBeginRenderingKHR") - CmdBeginTransformFeedbackEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdBeginTransformFeedbackEXT") - CmdBindDescriptorSets = auto_cast GetInstanceProcAddr(instance, "vkCmdBindDescriptorSets") - CmdBindIndexBuffer = auto_cast GetInstanceProcAddr(instance, "vkCmdBindIndexBuffer") - CmdBindInvocationMaskHUAWEI = auto_cast GetInstanceProcAddr(instance, "vkCmdBindInvocationMaskHUAWEI") - CmdBindPipeline = auto_cast GetInstanceProcAddr(instance, "vkCmdBindPipeline") - CmdBindPipelineShaderGroupNV = auto_cast GetInstanceProcAddr(instance, "vkCmdBindPipelineShaderGroupNV") - CmdBindShadingRateImageNV = auto_cast GetInstanceProcAddr(instance, "vkCmdBindShadingRateImageNV") - CmdBindTransformFeedbackBuffersEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdBindTransformFeedbackBuffersEXT") - CmdBindVertexBuffers = auto_cast GetInstanceProcAddr(instance, "vkCmdBindVertexBuffers") - CmdBindVertexBuffers2 = auto_cast GetInstanceProcAddr(instance, "vkCmdBindVertexBuffers2") - CmdBindVertexBuffers2EXT = auto_cast GetInstanceProcAddr(instance, "vkCmdBindVertexBuffers2EXT") - CmdBlitImage = auto_cast GetInstanceProcAddr(instance, "vkCmdBlitImage") - CmdBlitImage2 = auto_cast GetInstanceProcAddr(instance, "vkCmdBlitImage2") - CmdBlitImage2KHR = auto_cast GetInstanceProcAddr(instance, "vkCmdBlitImage2KHR") - CmdBuildAccelerationStructureNV = auto_cast GetInstanceProcAddr(instance, "vkCmdBuildAccelerationStructureNV") - CmdBuildAccelerationStructuresIndirectKHR = auto_cast GetInstanceProcAddr(instance, "vkCmdBuildAccelerationStructuresIndirectKHR") - CmdBuildAccelerationStructuresKHR = auto_cast GetInstanceProcAddr(instance, "vkCmdBuildAccelerationStructuresKHR") - CmdClearAttachments = auto_cast GetInstanceProcAddr(instance, "vkCmdClearAttachments") - CmdClearColorImage = auto_cast GetInstanceProcAddr(instance, "vkCmdClearColorImage") - CmdClearDepthStencilImage = auto_cast GetInstanceProcAddr(instance, "vkCmdClearDepthStencilImage") - CmdCopyAccelerationStructureKHR = auto_cast GetInstanceProcAddr(instance, "vkCmdCopyAccelerationStructureKHR") - CmdCopyAccelerationStructureNV = auto_cast GetInstanceProcAddr(instance, "vkCmdCopyAccelerationStructureNV") - CmdCopyAccelerationStructureToMemoryKHR = auto_cast GetInstanceProcAddr(instance, "vkCmdCopyAccelerationStructureToMemoryKHR") - CmdCopyBuffer = auto_cast GetInstanceProcAddr(instance, "vkCmdCopyBuffer") - CmdCopyBuffer2 = auto_cast GetInstanceProcAddr(instance, "vkCmdCopyBuffer2") - CmdCopyBuffer2KHR = auto_cast GetInstanceProcAddr(instance, "vkCmdCopyBuffer2KHR") - CmdCopyBufferToImage = auto_cast GetInstanceProcAddr(instance, "vkCmdCopyBufferToImage") - CmdCopyBufferToImage2 = auto_cast GetInstanceProcAddr(instance, "vkCmdCopyBufferToImage2") - CmdCopyBufferToImage2KHR = auto_cast GetInstanceProcAddr(instance, "vkCmdCopyBufferToImage2KHR") - CmdCopyImage = auto_cast GetInstanceProcAddr(instance, "vkCmdCopyImage") - CmdCopyImage2 = auto_cast GetInstanceProcAddr(instance, "vkCmdCopyImage2") - CmdCopyImage2KHR = auto_cast GetInstanceProcAddr(instance, "vkCmdCopyImage2KHR") - CmdCopyImageToBuffer = auto_cast GetInstanceProcAddr(instance, "vkCmdCopyImageToBuffer") - CmdCopyImageToBuffer2 = auto_cast GetInstanceProcAddr(instance, "vkCmdCopyImageToBuffer2") - CmdCopyImageToBuffer2KHR = auto_cast GetInstanceProcAddr(instance, "vkCmdCopyImageToBuffer2KHR") - CmdCopyMemoryToAccelerationStructureKHR = auto_cast GetInstanceProcAddr(instance, "vkCmdCopyMemoryToAccelerationStructureKHR") - CmdCopyQueryPoolResults = auto_cast GetInstanceProcAddr(instance, "vkCmdCopyQueryPoolResults") - CmdCuLaunchKernelNVX = auto_cast GetInstanceProcAddr(instance, "vkCmdCuLaunchKernelNVX") - CmdDebugMarkerBeginEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdDebugMarkerBeginEXT") - CmdDebugMarkerEndEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdDebugMarkerEndEXT") - CmdDebugMarkerInsertEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdDebugMarkerInsertEXT") - CmdDispatch = auto_cast GetInstanceProcAddr(instance, "vkCmdDispatch") - CmdDispatchBase = auto_cast GetInstanceProcAddr(instance, "vkCmdDispatchBase") - CmdDispatchBaseKHR = auto_cast GetInstanceProcAddr(instance, "vkCmdDispatchBaseKHR") - CmdDispatchIndirect = auto_cast GetInstanceProcAddr(instance, "vkCmdDispatchIndirect") - CmdDraw = auto_cast GetInstanceProcAddr(instance, "vkCmdDraw") - CmdDrawIndexed = auto_cast GetInstanceProcAddr(instance, "vkCmdDrawIndexed") - CmdDrawIndexedIndirect = auto_cast GetInstanceProcAddr(instance, "vkCmdDrawIndexedIndirect") - CmdDrawIndexedIndirectCount = auto_cast GetInstanceProcAddr(instance, "vkCmdDrawIndexedIndirectCount") - CmdDrawIndexedIndirectCountAMD = auto_cast GetInstanceProcAddr(instance, "vkCmdDrawIndexedIndirectCountAMD") - CmdDrawIndexedIndirectCountKHR = auto_cast GetInstanceProcAddr(instance, "vkCmdDrawIndexedIndirectCountKHR") - CmdDrawIndirect = auto_cast GetInstanceProcAddr(instance, "vkCmdDrawIndirect") - CmdDrawIndirectByteCountEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdDrawIndirectByteCountEXT") - CmdDrawIndirectCount = auto_cast GetInstanceProcAddr(instance, "vkCmdDrawIndirectCount") - CmdDrawIndirectCountAMD = auto_cast GetInstanceProcAddr(instance, "vkCmdDrawIndirectCountAMD") - CmdDrawIndirectCountKHR = auto_cast GetInstanceProcAddr(instance, "vkCmdDrawIndirectCountKHR") - CmdDrawMeshTasksIndirectCountNV = auto_cast GetInstanceProcAddr(instance, "vkCmdDrawMeshTasksIndirectCountNV") - CmdDrawMeshTasksIndirectNV = auto_cast GetInstanceProcAddr(instance, "vkCmdDrawMeshTasksIndirectNV") - CmdDrawMeshTasksNV = auto_cast GetInstanceProcAddr(instance, "vkCmdDrawMeshTasksNV") - CmdDrawMultiEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdDrawMultiEXT") - CmdDrawMultiIndexedEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdDrawMultiIndexedEXT") - CmdEndConditionalRenderingEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdEndConditionalRenderingEXT") - CmdEndDebugUtilsLabelEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdEndDebugUtilsLabelEXT") - CmdEndQuery = auto_cast GetInstanceProcAddr(instance, "vkCmdEndQuery") - CmdEndQueryIndexedEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdEndQueryIndexedEXT") - CmdEndRenderPass = auto_cast GetInstanceProcAddr(instance, "vkCmdEndRenderPass") - CmdEndRenderPass2 = auto_cast GetInstanceProcAddr(instance, "vkCmdEndRenderPass2") - CmdEndRenderPass2KHR = auto_cast GetInstanceProcAddr(instance, "vkCmdEndRenderPass2KHR") - CmdEndRendering = auto_cast GetInstanceProcAddr(instance, "vkCmdEndRendering") - CmdEndRenderingKHR = auto_cast GetInstanceProcAddr(instance, "vkCmdEndRenderingKHR") - CmdEndTransformFeedbackEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdEndTransformFeedbackEXT") - CmdExecuteCommands = auto_cast GetInstanceProcAddr(instance, "vkCmdExecuteCommands") - CmdExecuteGeneratedCommandsNV = auto_cast GetInstanceProcAddr(instance, "vkCmdExecuteGeneratedCommandsNV") - CmdFillBuffer = auto_cast GetInstanceProcAddr(instance, "vkCmdFillBuffer") - CmdInsertDebugUtilsLabelEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdInsertDebugUtilsLabelEXT") - CmdNextSubpass = auto_cast GetInstanceProcAddr(instance, "vkCmdNextSubpass") - CmdNextSubpass2 = auto_cast GetInstanceProcAddr(instance, "vkCmdNextSubpass2") - CmdNextSubpass2KHR = auto_cast GetInstanceProcAddr(instance, "vkCmdNextSubpass2KHR") - CmdPipelineBarrier = auto_cast GetInstanceProcAddr(instance, "vkCmdPipelineBarrier") - CmdPipelineBarrier2 = auto_cast GetInstanceProcAddr(instance, "vkCmdPipelineBarrier2") - CmdPipelineBarrier2KHR = auto_cast GetInstanceProcAddr(instance, "vkCmdPipelineBarrier2KHR") - CmdPreprocessGeneratedCommandsNV = auto_cast GetInstanceProcAddr(instance, "vkCmdPreprocessGeneratedCommandsNV") - CmdPushConstants = auto_cast GetInstanceProcAddr(instance, "vkCmdPushConstants") - CmdPushDescriptorSetKHR = auto_cast GetInstanceProcAddr(instance, "vkCmdPushDescriptorSetKHR") - CmdPushDescriptorSetWithTemplateKHR = auto_cast GetInstanceProcAddr(instance, "vkCmdPushDescriptorSetWithTemplateKHR") - CmdResetEvent = auto_cast GetInstanceProcAddr(instance, "vkCmdResetEvent") - CmdResetEvent2 = auto_cast GetInstanceProcAddr(instance, "vkCmdResetEvent2") - CmdResetEvent2KHR = auto_cast GetInstanceProcAddr(instance, "vkCmdResetEvent2KHR") - CmdResetQueryPool = auto_cast GetInstanceProcAddr(instance, "vkCmdResetQueryPool") - CmdResolveImage = auto_cast GetInstanceProcAddr(instance, "vkCmdResolveImage") - CmdResolveImage2 = auto_cast GetInstanceProcAddr(instance, "vkCmdResolveImage2") - CmdResolveImage2KHR = auto_cast GetInstanceProcAddr(instance, "vkCmdResolveImage2KHR") - CmdSetBlendConstants = auto_cast GetInstanceProcAddr(instance, "vkCmdSetBlendConstants") - CmdSetCheckpointNV = auto_cast GetInstanceProcAddr(instance, "vkCmdSetCheckpointNV") - CmdSetCoarseSampleOrderNV = auto_cast GetInstanceProcAddr(instance, "vkCmdSetCoarseSampleOrderNV") - CmdSetCullMode = auto_cast GetInstanceProcAddr(instance, "vkCmdSetCullMode") - CmdSetCullModeEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetCullModeEXT") - CmdSetDepthBias = auto_cast GetInstanceProcAddr(instance, "vkCmdSetDepthBias") - CmdSetDepthBiasEnable = auto_cast GetInstanceProcAddr(instance, "vkCmdSetDepthBiasEnable") - CmdSetDepthBiasEnableEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetDepthBiasEnableEXT") - CmdSetDepthBounds = auto_cast GetInstanceProcAddr(instance, "vkCmdSetDepthBounds") - CmdSetDepthBoundsTestEnable = auto_cast GetInstanceProcAddr(instance, "vkCmdSetDepthBoundsTestEnable") - CmdSetDepthBoundsTestEnableEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetDepthBoundsTestEnableEXT") - CmdSetDepthCompareOp = auto_cast GetInstanceProcAddr(instance, "vkCmdSetDepthCompareOp") - CmdSetDepthCompareOpEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetDepthCompareOpEXT") - CmdSetDepthTestEnable = auto_cast GetInstanceProcAddr(instance, "vkCmdSetDepthTestEnable") - CmdSetDepthTestEnableEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetDepthTestEnableEXT") - CmdSetDepthWriteEnable = auto_cast GetInstanceProcAddr(instance, "vkCmdSetDepthWriteEnable") - CmdSetDepthWriteEnableEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetDepthWriteEnableEXT") - CmdSetDeviceMask = auto_cast GetInstanceProcAddr(instance, "vkCmdSetDeviceMask") - CmdSetDeviceMaskKHR = auto_cast GetInstanceProcAddr(instance, "vkCmdSetDeviceMaskKHR") - CmdSetDiscardRectangleEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetDiscardRectangleEXT") - CmdSetEvent = auto_cast GetInstanceProcAddr(instance, "vkCmdSetEvent") - CmdSetEvent2 = auto_cast GetInstanceProcAddr(instance, "vkCmdSetEvent2") - CmdSetEvent2KHR = auto_cast GetInstanceProcAddr(instance, "vkCmdSetEvent2KHR") - CmdSetExclusiveScissorNV = auto_cast GetInstanceProcAddr(instance, "vkCmdSetExclusiveScissorNV") - CmdSetFragmentShadingRateEnumNV = auto_cast GetInstanceProcAddr(instance, "vkCmdSetFragmentShadingRateEnumNV") - CmdSetFragmentShadingRateKHR = auto_cast GetInstanceProcAddr(instance, "vkCmdSetFragmentShadingRateKHR") - CmdSetFrontFace = auto_cast GetInstanceProcAddr(instance, "vkCmdSetFrontFace") - CmdSetFrontFaceEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetFrontFaceEXT") - CmdSetLineStippleEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetLineStippleEXT") - CmdSetLineWidth = auto_cast GetInstanceProcAddr(instance, "vkCmdSetLineWidth") - CmdSetLogicOpEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetLogicOpEXT") - CmdSetPatchControlPointsEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetPatchControlPointsEXT") - CmdSetPerformanceMarkerINTEL = auto_cast GetInstanceProcAddr(instance, "vkCmdSetPerformanceMarkerINTEL") - CmdSetPerformanceOverrideINTEL = auto_cast GetInstanceProcAddr(instance, "vkCmdSetPerformanceOverrideINTEL") - CmdSetPerformanceStreamMarkerINTEL = auto_cast GetInstanceProcAddr(instance, "vkCmdSetPerformanceStreamMarkerINTEL") - CmdSetPrimitiveRestartEnable = auto_cast GetInstanceProcAddr(instance, "vkCmdSetPrimitiveRestartEnable") - CmdSetPrimitiveRestartEnableEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetPrimitiveRestartEnableEXT") - CmdSetPrimitiveTopology = auto_cast GetInstanceProcAddr(instance, "vkCmdSetPrimitiveTopology") - CmdSetPrimitiveTopologyEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetPrimitiveTopologyEXT") - CmdSetRasterizerDiscardEnable = auto_cast GetInstanceProcAddr(instance, "vkCmdSetRasterizerDiscardEnable") - CmdSetRasterizerDiscardEnableEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetRasterizerDiscardEnableEXT") - CmdSetRayTracingPipelineStackSizeKHR = auto_cast GetInstanceProcAddr(instance, "vkCmdSetRayTracingPipelineStackSizeKHR") - CmdSetSampleLocationsEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetSampleLocationsEXT") - CmdSetScissor = auto_cast GetInstanceProcAddr(instance, "vkCmdSetScissor") - CmdSetScissorWithCount = auto_cast GetInstanceProcAddr(instance, "vkCmdSetScissorWithCount") - CmdSetScissorWithCountEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetScissorWithCountEXT") - CmdSetStencilCompareMask = auto_cast GetInstanceProcAddr(instance, "vkCmdSetStencilCompareMask") - CmdSetStencilOp = auto_cast GetInstanceProcAddr(instance, "vkCmdSetStencilOp") - CmdSetStencilOpEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetStencilOpEXT") - CmdSetStencilReference = auto_cast GetInstanceProcAddr(instance, "vkCmdSetStencilReference") - CmdSetStencilTestEnable = auto_cast GetInstanceProcAddr(instance, "vkCmdSetStencilTestEnable") - CmdSetStencilTestEnableEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetStencilTestEnableEXT") - CmdSetStencilWriteMask = auto_cast GetInstanceProcAddr(instance, "vkCmdSetStencilWriteMask") - CmdSetVertexInputEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetVertexInputEXT") - CmdSetViewport = auto_cast GetInstanceProcAddr(instance, "vkCmdSetViewport") - CmdSetViewportShadingRatePaletteNV = auto_cast GetInstanceProcAddr(instance, "vkCmdSetViewportShadingRatePaletteNV") - CmdSetViewportWScalingNV = auto_cast GetInstanceProcAddr(instance, "vkCmdSetViewportWScalingNV") - CmdSetViewportWithCount = auto_cast GetInstanceProcAddr(instance, "vkCmdSetViewportWithCount") - CmdSetViewportWithCountEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetViewportWithCountEXT") - CmdSubpassShadingHUAWEI = auto_cast GetInstanceProcAddr(instance, "vkCmdSubpassShadingHUAWEI") - CmdTraceRaysIndirectKHR = auto_cast GetInstanceProcAddr(instance, "vkCmdTraceRaysIndirectKHR") - CmdTraceRaysKHR = auto_cast GetInstanceProcAddr(instance, "vkCmdTraceRaysKHR") - CmdTraceRaysNV = auto_cast GetInstanceProcAddr(instance, "vkCmdTraceRaysNV") - CmdUpdateBuffer = auto_cast GetInstanceProcAddr(instance, "vkCmdUpdateBuffer") - CmdWaitEvents = auto_cast GetInstanceProcAddr(instance, "vkCmdWaitEvents") - CmdWaitEvents2 = auto_cast GetInstanceProcAddr(instance, "vkCmdWaitEvents2") - CmdWaitEvents2KHR = auto_cast GetInstanceProcAddr(instance, "vkCmdWaitEvents2KHR") - CmdWriteAccelerationStructuresPropertiesKHR = auto_cast GetInstanceProcAddr(instance, "vkCmdWriteAccelerationStructuresPropertiesKHR") - CmdWriteAccelerationStructuresPropertiesNV = auto_cast GetInstanceProcAddr(instance, "vkCmdWriteAccelerationStructuresPropertiesNV") - CmdWriteBufferMarker2AMD = auto_cast GetInstanceProcAddr(instance, "vkCmdWriteBufferMarker2AMD") - CmdWriteBufferMarkerAMD = auto_cast GetInstanceProcAddr(instance, "vkCmdWriteBufferMarkerAMD") - CmdWriteTimestamp = auto_cast GetInstanceProcAddr(instance, "vkCmdWriteTimestamp") - CmdWriteTimestamp2 = auto_cast GetInstanceProcAddr(instance, "vkCmdWriteTimestamp2") - CmdWriteTimestamp2KHR = auto_cast GetInstanceProcAddr(instance, "vkCmdWriteTimestamp2KHR") - CompileDeferredNV = auto_cast GetInstanceProcAddr(instance, "vkCompileDeferredNV") - CopyAccelerationStructureKHR = auto_cast GetInstanceProcAddr(instance, "vkCopyAccelerationStructureKHR") - CopyAccelerationStructureToMemoryKHR = auto_cast GetInstanceProcAddr(instance, "vkCopyAccelerationStructureToMemoryKHR") - CopyMemoryToAccelerationStructureKHR = auto_cast GetInstanceProcAddr(instance, "vkCopyMemoryToAccelerationStructureKHR") - CreateAccelerationStructureKHR = auto_cast GetInstanceProcAddr(instance, "vkCreateAccelerationStructureKHR") - CreateAccelerationStructureNV = auto_cast GetInstanceProcAddr(instance, "vkCreateAccelerationStructureNV") - CreateBuffer = auto_cast GetInstanceProcAddr(instance, "vkCreateBuffer") - CreateBufferView = auto_cast GetInstanceProcAddr(instance, "vkCreateBufferView") - CreateCommandPool = auto_cast GetInstanceProcAddr(instance, "vkCreateCommandPool") - CreateComputePipelines = auto_cast GetInstanceProcAddr(instance, "vkCreateComputePipelines") - CreateCuFunctionNVX = auto_cast GetInstanceProcAddr(instance, "vkCreateCuFunctionNVX") - CreateCuModuleNVX = auto_cast GetInstanceProcAddr(instance, "vkCreateCuModuleNVX") - CreateDeferredOperationKHR = auto_cast GetInstanceProcAddr(instance, "vkCreateDeferredOperationKHR") - CreateDescriptorPool = auto_cast GetInstanceProcAddr(instance, "vkCreateDescriptorPool") - CreateDescriptorSetLayout = auto_cast GetInstanceProcAddr(instance, "vkCreateDescriptorSetLayout") - CreateDescriptorUpdateTemplate = auto_cast GetInstanceProcAddr(instance, "vkCreateDescriptorUpdateTemplate") - CreateDescriptorUpdateTemplateKHR = auto_cast GetInstanceProcAddr(instance, "vkCreateDescriptorUpdateTemplateKHR") - CreateEvent = auto_cast GetInstanceProcAddr(instance, "vkCreateEvent") - CreateFence = auto_cast GetInstanceProcAddr(instance, "vkCreateFence") - CreateFramebuffer = auto_cast GetInstanceProcAddr(instance, "vkCreateFramebuffer") - CreateGraphicsPipelines = auto_cast GetInstanceProcAddr(instance, "vkCreateGraphicsPipelines") - CreateImage = auto_cast GetInstanceProcAddr(instance, "vkCreateImage") - CreateImageView = auto_cast GetInstanceProcAddr(instance, "vkCreateImageView") - CreateIndirectCommandsLayoutNV = auto_cast GetInstanceProcAddr(instance, "vkCreateIndirectCommandsLayoutNV") - CreatePipelineCache = auto_cast GetInstanceProcAddr(instance, "vkCreatePipelineCache") - CreatePipelineLayout = auto_cast GetInstanceProcAddr(instance, "vkCreatePipelineLayout") - CreatePrivateDataSlot = auto_cast GetInstanceProcAddr(instance, "vkCreatePrivateDataSlot") - CreatePrivateDataSlotEXT = auto_cast GetInstanceProcAddr(instance, "vkCreatePrivateDataSlotEXT") - CreateQueryPool = auto_cast GetInstanceProcAddr(instance, "vkCreateQueryPool") - CreateRayTracingPipelinesKHR = auto_cast GetInstanceProcAddr(instance, "vkCreateRayTracingPipelinesKHR") - CreateRayTracingPipelinesNV = auto_cast GetInstanceProcAddr(instance, "vkCreateRayTracingPipelinesNV") - CreateRenderPass = auto_cast GetInstanceProcAddr(instance, "vkCreateRenderPass") - CreateRenderPass2 = auto_cast GetInstanceProcAddr(instance, "vkCreateRenderPass2") - CreateRenderPass2KHR = auto_cast GetInstanceProcAddr(instance, "vkCreateRenderPass2KHR") - CreateSampler = auto_cast GetInstanceProcAddr(instance, "vkCreateSampler") - CreateSamplerYcbcrConversion = auto_cast GetInstanceProcAddr(instance, "vkCreateSamplerYcbcrConversion") - CreateSamplerYcbcrConversionKHR = auto_cast GetInstanceProcAddr(instance, "vkCreateSamplerYcbcrConversionKHR") - CreateSemaphore = auto_cast GetInstanceProcAddr(instance, "vkCreateSemaphore") - CreateShaderModule = auto_cast GetInstanceProcAddr(instance, "vkCreateShaderModule") - CreateSharedSwapchainsKHR = auto_cast GetInstanceProcAddr(instance, "vkCreateSharedSwapchainsKHR") - CreateSwapchainKHR = auto_cast GetInstanceProcAddr(instance, "vkCreateSwapchainKHR") - CreateValidationCacheEXT = auto_cast GetInstanceProcAddr(instance, "vkCreateValidationCacheEXT") - DebugMarkerSetObjectNameEXT = auto_cast GetInstanceProcAddr(instance, "vkDebugMarkerSetObjectNameEXT") - DebugMarkerSetObjectTagEXT = auto_cast GetInstanceProcAddr(instance, "vkDebugMarkerSetObjectTagEXT") - DeferredOperationJoinKHR = auto_cast GetInstanceProcAddr(instance, "vkDeferredOperationJoinKHR") - DestroyAccelerationStructureKHR = auto_cast GetInstanceProcAddr(instance, "vkDestroyAccelerationStructureKHR") - DestroyAccelerationStructureNV = auto_cast GetInstanceProcAddr(instance, "vkDestroyAccelerationStructureNV") - DestroyBuffer = auto_cast GetInstanceProcAddr(instance, "vkDestroyBuffer") - DestroyBufferView = auto_cast GetInstanceProcAddr(instance, "vkDestroyBufferView") - DestroyCommandPool = auto_cast GetInstanceProcAddr(instance, "vkDestroyCommandPool") - DestroyCuFunctionNVX = auto_cast GetInstanceProcAddr(instance, "vkDestroyCuFunctionNVX") - DestroyCuModuleNVX = auto_cast GetInstanceProcAddr(instance, "vkDestroyCuModuleNVX") - DestroyDeferredOperationKHR = auto_cast GetInstanceProcAddr(instance, "vkDestroyDeferredOperationKHR") - DestroyDescriptorPool = auto_cast GetInstanceProcAddr(instance, "vkDestroyDescriptorPool") - DestroyDescriptorSetLayout = auto_cast GetInstanceProcAddr(instance, "vkDestroyDescriptorSetLayout") - DestroyDescriptorUpdateTemplate = auto_cast GetInstanceProcAddr(instance, "vkDestroyDescriptorUpdateTemplate") - DestroyDescriptorUpdateTemplateKHR = auto_cast GetInstanceProcAddr(instance, "vkDestroyDescriptorUpdateTemplateKHR") - DestroyDevice = auto_cast GetInstanceProcAddr(instance, "vkDestroyDevice") - DestroyEvent = auto_cast GetInstanceProcAddr(instance, "vkDestroyEvent") - DestroyFence = auto_cast GetInstanceProcAddr(instance, "vkDestroyFence") - DestroyFramebuffer = auto_cast GetInstanceProcAddr(instance, "vkDestroyFramebuffer") - DestroyImage = auto_cast GetInstanceProcAddr(instance, "vkDestroyImage") - DestroyImageView = auto_cast GetInstanceProcAddr(instance, "vkDestroyImageView") - DestroyIndirectCommandsLayoutNV = auto_cast GetInstanceProcAddr(instance, "vkDestroyIndirectCommandsLayoutNV") - DestroyPipeline = auto_cast GetInstanceProcAddr(instance, "vkDestroyPipeline") - DestroyPipelineCache = auto_cast GetInstanceProcAddr(instance, "vkDestroyPipelineCache") - DestroyPipelineLayout = auto_cast GetInstanceProcAddr(instance, "vkDestroyPipelineLayout") - DestroyPrivateDataSlot = auto_cast GetInstanceProcAddr(instance, "vkDestroyPrivateDataSlot") - DestroyPrivateDataSlotEXT = auto_cast GetInstanceProcAddr(instance, "vkDestroyPrivateDataSlotEXT") - DestroyQueryPool = auto_cast GetInstanceProcAddr(instance, "vkDestroyQueryPool") - DestroyRenderPass = auto_cast GetInstanceProcAddr(instance, "vkDestroyRenderPass") - DestroySampler = auto_cast GetInstanceProcAddr(instance, "vkDestroySampler") - DestroySamplerYcbcrConversion = auto_cast GetInstanceProcAddr(instance, "vkDestroySamplerYcbcrConversion") - DestroySamplerYcbcrConversionKHR = auto_cast GetInstanceProcAddr(instance, "vkDestroySamplerYcbcrConversionKHR") - DestroySemaphore = auto_cast GetInstanceProcAddr(instance, "vkDestroySemaphore") - DestroyShaderModule = auto_cast GetInstanceProcAddr(instance, "vkDestroyShaderModule") - DestroySwapchainKHR = auto_cast GetInstanceProcAddr(instance, "vkDestroySwapchainKHR") - DestroyValidationCacheEXT = auto_cast GetInstanceProcAddr(instance, "vkDestroyValidationCacheEXT") - DeviceWaitIdle = auto_cast GetInstanceProcAddr(instance, "vkDeviceWaitIdle") - DisplayPowerControlEXT = auto_cast GetInstanceProcAddr(instance, "vkDisplayPowerControlEXT") - EndCommandBuffer = auto_cast GetInstanceProcAddr(instance, "vkEndCommandBuffer") - FlushMappedMemoryRanges = auto_cast GetInstanceProcAddr(instance, "vkFlushMappedMemoryRanges") - FreeCommandBuffers = auto_cast GetInstanceProcAddr(instance, "vkFreeCommandBuffers") - FreeDescriptorSets = auto_cast GetInstanceProcAddr(instance, "vkFreeDescriptorSets") - FreeMemory = auto_cast GetInstanceProcAddr(instance, "vkFreeMemory") - GetAccelerationStructureBuildSizesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetAccelerationStructureBuildSizesKHR") - GetAccelerationStructureDeviceAddressKHR = auto_cast GetInstanceProcAddr(instance, "vkGetAccelerationStructureDeviceAddressKHR") - GetAccelerationStructureHandleNV = auto_cast GetInstanceProcAddr(instance, "vkGetAccelerationStructureHandleNV") - GetAccelerationStructureMemoryRequirementsNV = auto_cast GetInstanceProcAddr(instance, "vkGetAccelerationStructureMemoryRequirementsNV") - GetBufferDeviceAddress = auto_cast GetInstanceProcAddr(instance, "vkGetBufferDeviceAddress") - GetBufferDeviceAddressEXT = auto_cast GetInstanceProcAddr(instance, "vkGetBufferDeviceAddressEXT") - GetBufferDeviceAddressKHR = auto_cast GetInstanceProcAddr(instance, "vkGetBufferDeviceAddressKHR") - GetBufferMemoryRequirements = auto_cast GetInstanceProcAddr(instance, "vkGetBufferMemoryRequirements") - GetBufferMemoryRequirements2 = auto_cast GetInstanceProcAddr(instance, "vkGetBufferMemoryRequirements2") - GetBufferMemoryRequirements2KHR = auto_cast GetInstanceProcAddr(instance, "vkGetBufferMemoryRequirements2KHR") - GetBufferOpaqueCaptureAddress = auto_cast GetInstanceProcAddr(instance, "vkGetBufferOpaqueCaptureAddress") - GetBufferOpaqueCaptureAddressKHR = auto_cast GetInstanceProcAddr(instance, "vkGetBufferOpaqueCaptureAddressKHR") - GetCalibratedTimestampsEXT = auto_cast GetInstanceProcAddr(instance, "vkGetCalibratedTimestampsEXT") - GetDeferredOperationMaxConcurrencyKHR = auto_cast GetInstanceProcAddr(instance, "vkGetDeferredOperationMaxConcurrencyKHR") - GetDeferredOperationResultKHR = auto_cast GetInstanceProcAddr(instance, "vkGetDeferredOperationResultKHR") - GetDescriptorSetHostMappingVALVE = auto_cast GetInstanceProcAddr(instance, "vkGetDescriptorSetHostMappingVALVE") - GetDescriptorSetLayoutHostMappingInfoVALVE = auto_cast GetInstanceProcAddr(instance, "vkGetDescriptorSetLayoutHostMappingInfoVALVE") - GetDescriptorSetLayoutSupport = auto_cast GetInstanceProcAddr(instance, "vkGetDescriptorSetLayoutSupport") - GetDescriptorSetLayoutSupportKHR = auto_cast GetInstanceProcAddr(instance, "vkGetDescriptorSetLayoutSupportKHR") - GetDeviceAccelerationStructureCompatibilityKHR = auto_cast GetInstanceProcAddr(instance, "vkGetDeviceAccelerationStructureCompatibilityKHR") - GetDeviceBufferMemoryRequirements = auto_cast GetInstanceProcAddr(instance, "vkGetDeviceBufferMemoryRequirements") - GetDeviceBufferMemoryRequirementsKHR = auto_cast GetInstanceProcAddr(instance, "vkGetDeviceBufferMemoryRequirementsKHR") - GetDeviceGroupPeerMemoryFeatures = auto_cast GetInstanceProcAddr(instance, "vkGetDeviceGroupPeerMemoryFeatures") - GetDeviceGroupPeerMemoryFeaturesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetDeviceGroupPeerMemoryFeaturesKHR") - GetDeviceGroupPresentCapabilitiesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetDeviceGroupPresentCapabilitiesKHR") - GetDeviceGroupSurfacePresentModes2EXT = auto_cast GetInstanceProcAddr(instance, "vkGetDeviceGroupSurfacePresentModes2EXT") - GetDeviceGroupSurfacePresentModesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetDeviceGroupSurfacePresentModesKHR") - GetDeviceImageMemoryRequirements = auto_cast GetInstanceProcAddr(instance, "vkGetDeviceImageMemoryRequirements") - GetDeviceImageMemoryRequirementsKHR = auto_cast GetInstanceProcAddr(instance, "vkGetDeviceImageMemoryRequirementsKHR") - GetDeviceImageSparseMemoryRequirements = auto_cast GetInstanceProcAddr(instance, "vkGetDeviceImageSparseMemoryRequirements") - GetDeviceImageSparseMemoryRequirementsKHR = auto_cast GetInstanceProcAddr(instance, "vkGetDeviceImageSparseMemoryRequirementsKHR") - GetDeviceMemoryCommitment = auto_cast GetInstanceProcAddr(instance, "vkGetDeviceMemoryCommitment") - GetDeviceMemoryOpaqueCaptureAddress = auto_cast GetInstanceProcAddr(instance, "vkGetDeviceMemoryOpaqueCaptureAddress") - GetDeviceMemoryOpaqueCaptureAddressKHR = auto_cast GetInstanceProcAddr(instance, "vkGetDeviceMemoryOpaqueCaptureAddressKHR") - GetDeviceProcAddr = auto_cast GetInstanceProcAddr(instance, "vkGetDeviceProcAddr") - GetDeviceQueue = auto_cast GetInstanceProcAddr(instance, "vkGetDeviceQueue") - GetDeviceQueue2 = auto_cast GetInstanceProcAddr(instance, "vkGetDeviceQueue2") - GetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI = auto_cast GetInstanceProcAddr(instance, "vkGetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI") - GetEventStatus = auto_cast GetInstanceProcAddr(instance, "vkGetEventStatus") - GetFenceFdKHR = auto_cast GetInstanceProcAddr(instance, "vkGetFenceFdKHR") - GetFenceStatus = auto_cast GetInstanceProcAddr(instance, "vkGetFenceStatus") - GetFenceWin32HandleKHR = auto_cast GetInstanceProcAddr(instance, "vkGetFenceWin32HandleKHR") - GetGeneratedCommandsMemoryRequirementsNV = auto_cast GetInstanceProcAddr(instance, "vkGetGeneratedCommandsMemoryRequirementsNV") - GetImageDrmFormatModifierPropertiesEXT = auto_cast GetInstanceProcAddr(instance, "vkGetImageDrmFormatModifierPropertiesEXT") - GetImageMemoryRequirements = auto_cast GetInstanceProcAddr(instance, "vkGetImageMemoryRequirements") - GetImageMemoryRequirements2 = auto_cast GetInstanceProcAddr(instance, "vkGetImageMemoryRequirements2") - GetImageMemoryRequirements2KHR = auto_cast GetInstanceProcAddr(instance, "vkGetImageMemoryRequirements2KHR") - GetImageSparseMemoryRequirements = auto_cast GetInstanceProcAddr(instance, "vkGetImageSparseMemoryRequirements") - GetImageSparseMemoryRequirements2 = auto_cast GetInstanceProcAddr(instance, "vkGetImageSparseMemoryRequirements2") - GetImageSparseMemoryRequirements2KHR = auto_cast GetInstanceProcAddr(instance, "vkGetImageSparseMemoryRequirements2KHR") - GetImageSubresourceLayout = auto_cast GetInstanceProcAddr(instance, "vkGetImageSubresourceLayout") - GetImageViewAddressNVX = auto_cast GetInstanceProcAddr(instance, "vkGetImageViewAddressNVX") - GetImageViewHandleNVX = auto_cast GetInstanceProcAddr(instance, "vkGetImageViewHandleNVX") - GetMemoryFdKHR = auto_cast GetInstanceProcAddr(instance, "vkGetMemoryFdKHR") - GetMemoryFdPropertiesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetMemoryFdPropertiesKHR") - GetMemoryHostPointerPropertiesEXT = auto_cast GetInstanceProcAddr(instance, "vkGetMemoryHostPointerPropertiesEXT") - GetMemoryRemoteAddressNV = auto_cast GetInstanceProcAddr(instance, "vkGetMemoryRemoteAddressNV") - GetMemoryWin32HandleKHR = auto_cast GetInstanceProcAddr(instance, "vkGetMemoryWin32HandleKHR") - GetMemoryWin32HandleNV = auto_cast GetInstanceProcAddr(instance, "vkGetMemoryWin32HandleNV") - GetMemoryWin32HandlePropertiesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetMemoryWin32HandlePropertiesKHR") - GetPastPresentationTimingGOOGLE = auto_cast GetInstanceProcAddr(instance, "vkGetPastPresentationTimingGOOGLE") - GetPerformanceParameterINTEL = auto_cast GetInstanceProcAddr(instance, "vkGetPerformanceParameterINTEL") - GetPipelineCacheData = auto_cast GetInstanceProcAddr(instance, "vkGetPipelineCacheData") - GetPipelineExecutableInternalRepresentationsKHR = auto_cast GetInstanceProcAddr(instance, "vkGetPipelineExecutableInternalRepresentationsKHR") - GetPipelineExecutablePropertiesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetPipelineExecutablePropertiesKHR") - GetPipelineExecutableStatisticsKHR = auto_cast GetInstanceProcAddr(instance, "vkGetPipelineExecutableStatisticsKHR") - GetPrivateData = auto_cast GetInstanceProcAddr(instance, "vkGetPrivateData") - GetPrivateDataEXT = auto_cast GetInstanceProcAddr(instance, "vkGetPrivateDataEXT") - GetQueryPoolResults = auto_cast GetInstanceProcAddr(instance, "vkGetQueryPoolResults") - GetQueueCheckpointData2NV = auto_cast GetInstanceProcAddr(instance, "vkGetQueueCheckpointData2NV") - GetQueueCheckpointDataNV = auto_cast GetInstanceProcAddr(instance, "vkGetQueueCheckpointDataNV") - GetRayTracingCaptureReplayShaderGroupHandlesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR") - GetRayTracingShaderGroupHandlesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetRayTracingShaderGroupHandlesKHR") - GetRayTracingShaderGroupHandlesNV = auto_cast GetInstanceProcAddr(instance, "vkGetRayTracingShaderGroupHandlesNV") - GetRayTracingShaderGroupStackSizeKHR = auto_cast GetInstanceProcAddr(instance, "vkGetRayTracingShaderGroupStackSizeKHR") - GetRefreshCycleDurationGOOGLE = auto_cast GetInstanceProcAddr(instance, "vkGetRefreshCycleDurationGOOGLE") - GetRenderAreaGranularity = auto_cast GetInstanceProcAddr(instance, "vkGetRenderAreaGranularity") - GetSemaphoreCounterValue = auto_cast GetInstanceProcAddr(instance, "vkGetSemaphoreCounterValue") - GetSemaphoreCounterValueKHR = auto_cast GetInstanceProcAddr(instance, "vkGetSemaphoreCounterValueKHR") - GetSemaphoreFdKHR = auto_cast GetInstanceProcAddr(instance, "vkGetSemaphoreFdKHR") - GetSemaphoreWin32HandleKHR = auto_cast GetInstanceProcAddr(instance, "vkGetSemaphoreWin32HandleKHR") - GetShaderInfoAMD = auto_cast GetInstanceProcAddr(instance, "vkGetShaderInfoAMD") - GetSwapchainCounterEXT = auto_cast GetInstanceProcAddr(instance, "vkGetSwapchainCounterEXT") - GetSwapchainImagesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetSwapchainImagesKHR") - GetSwapchainStatusKHR = auto_cast GetInstanceProcAddr(instance, "vkGetSwapchainStatusKHR") - GetValidationCacheDataEXT = auto_cast GetInstanceProcAddr(instance, "vkGetValidationCacheDataEXT") - ImportFenceFdKHR = auto_cast GetInstanceProcAddr(instance, "vkImportFenceFdKHR") - ImportFenceWin32HandleKHR = auto_cast GetInstanceProcAddr(instance, "vkImportFenceWin32HandleKHR") - ImportSemaphoreFdKHR = auto_cast GetInstanceProcAddr(instance, "vkImportSemaphoreFdKHR") - ImportSemaphoreWin32HandleKHR = auto_cast GetInstanceProcAddr(instance, "vkImportSemaphoreWin32HandleKHR") - InitializePerformanceApiINTEL = auto_cast GetInstanceProcAddr(instance, "vkInitializePerformanceApiINTEL") - InvalidateMappedMemoryRanges = auto_cast GetInstanceProcAddr(instance, "vkInvalidateMappedMemoryRanges") - MapMemory = auto_cast GetInstanceProcAddr(instance, "vkMapMemory") - MergePipelineCaches = auto_cast GetInstanceProcAddr(instance, "vkMergePipelineCaches") - MergeValidationCachesEXT = auto_cast GetInstanceProcAddr(instance, "vkMergeValidationCachesEXT") - QueueBeginDebugUtilsLabelEXT = auto_cast GetInstanceProcAddr(instance, "vkQueueBeginDebugUtilsLabelEXT") - QueueBindSparse = auto_cast GetInstanceProcAddr(instance, "vkQueueBindSparse") - QueueEndDebugUtilsLabelEXT = auto_cast GetInstanceProcAddr(instance, "vkQueueEndDebugUtilsLabelEXT") - QueueInsertDebugUtilsLabelEXT = auto_cast GetInstanceProcAddr(instance, "vkQueueInsertDebugUtilsLabelEXT") - QueuePresentKHR = auto_cast GetInstanceProcAddr(instance, "vkQueuePresentKHR") - QueueSetPerformanceConfigurationINTEL = auto_cast GetInstanceProcAddr(instance, "vkQueueSetPerformanceConfigurationINTEL") - QueueSubmit = auto_cast GetInstanceProcAddr(instance, "vkQueueSubmit") - QueueSubmit2 = auto_cast GetInstanceProcAddr(instance, "vkQueueSubmit2") - QueueSubmit2KHR = auto_cast GetInstanceProcAddr(instance, "vkQueueSubmit2KHR") - QueueWaitIdle = auto_cast GetInstanceProcAddr(instance, "vkQueueWaitIdle") - RegisterDeviceEventEXT = auto_cast GetInstanceProcAddr(instance, "vkRegisterDeviceEventEXT") - RegisterDisplayEventEXT = auto_cast GetInstanceProcAddr(instance, "vkRegisterDisplayEventEXT") - ReleaseFullScreenExclusiveModeEXT = auto_cast GetInstanceProcAddr(instance, "vkReleaseFullScreenExclusiveModeEXT") - ReleasePerformanceConfigurationINTEL = auto_cast GetInstanceProcAddr(instance, "vkReleasePerformanceConfigurationINTEL") - ReleaseProfilingLockKHR = auto_cast GetInstanceProcAddr(instance, "vkReleaseProfilingLockKHR") - ResetCommandBuffer = auto_cast GetInstanceProcAddr(instance, "vkResetCommandBuffer") - ResetCommandPool = auto_cast GetInstanceProcAddr(instance, "vkResetCommandPool") - ResetDescriptorPool = auto_cast GetInstanceProcAddr(instance, "vkResetDescriptorPool") - ResetEvent = auto_cast GetInstanceProcAddr(instance, "vkResetEvent") - ResetFences = auto_cast GetInstanceProcAddr(instance, "vkResetFences") - ResetQueryPool = auto_cast GetInstanceProcAddr(instance, "vkResetQueryPool") - ResetQueryPoolEXT = auto_cast GetInstanceProcAddr(instance, "vkResetQueryPoolEXT") - SetDebugUtilsObjectNameEXT = auto_cast GetInstanceProcAddr(instance, "vkSetDebugUtilsObjectNameEXT") - SetDebugUtilsObjectTagEXT = auto_cast GetInstanceProcAddr(instance, "vkSetDebugUtilsObjectTagEXT") - SetDeviceMemoryPriorityEXT = auto_cast GetInstanceProcAddr(instance, "vkSetDeviceMemoryPriorityEXT") - SetEvent = auto_cast GetInstanceProcAddr(instance, "vkSetEvent") - SetHdrMetadataEXT = auto_cast GetInstanceProcAddr(instance, "vkSetHdrMetadataEXT") - SetLocalDimmingAMD = auto_cast GetInstanceProcAddr(instance, "vkSetLocalDimmingAMD") - SetPrivateData = auto_cast GetInstanceProcAddr(instance, "vkSetPrivateData") - SetPrivateDataEXT = auto_cast GetInstanceProcAddr(instance, "vkSetPrivateDataEXT") - SignalSemaphore = auto_cast GetInstanceProcAddr(instance, "vkSignalSemaphore") - SignalSemaphoreKHR = auto_cast GetInstanceProcAddr(instance, "vkSignalSemaphoreKHR") - TrimCommandPool = auto_cast GetInstanceProcAddr(instance, "vkTrimCommandPool") - TrimCommandPoolKHR = auto_cast GetInstanceProcAddr(instance, "vkTrimCommandPoolKHR") - UninitializePerformanceApiINTEL = auto_cast GetInstanceProcAddr(instance, "vkUninitializePerformanceApiINTEL") - UnmapMemory = auto_cast GetInstanceProcAddr(instance, "vkUnmapMemory") - UpdateDescriptorSetWithTemplate = auto_cast GetInstanceProcAddr(instance, "vkUpdateDescriptorSetWithTemplate") - UpdateDescriptorSetWithTemplateKHR = auto_cast GetInstanceProcAddr(instance, "vkUpdateDescriptorSetWithTemplateKHR") - UpdateDescriptorSets = auto_cast GetInstanceProcAddr(instance, "vkUpdateDescriptorSets") - WaitForFences = auto_cast GetInstanceProcAddr(instance, "vkWaitForFences") - WaitForPresentKHR = auto_cast GetInstanceProcAddr(instance, "vkWaitForPresentKHR") - WaitSemaphores = auto_cast GetInstanceProcAddr(instance, "vkWaitSemaphores") - WaitSemaphoresKHR = auto_cast GetInstanceProcAddr(instance, "vkWaitSemaphoresKHR") - WriteAccelerationStructuresPropertiesKHR = auto_cast GetInstanceProcAddr(instance, "vkWriteAccelerationStructuresPropertiesKHR") -} - -load_proc_addresses_global :: proc(vk_get_instance_proc_addr: rawptr) { - GetInstanceProcAddr = auto_cast vk_get_instance_proc_addr - - CreateInstance = auto_cast GetInstanceProcAddr(nil, "vkCreateInstance") - DebugUtilsMessengerCallbackEXT = auto_cast GetInstanceProcAddr(nil, "vkDebugUtilsMessengerCallbackEXT") - DeviceMemoryReportCallbackEXT = auto_cast GetInstanceProcAddr(nil, "vkDeviceMemoryReportCallbackEXT") - EnumerateInstanceExtensionProperties = auto_cast GetInstanceProcAddr(nil, "vkEnumerateInstanceExtensionProperties") - EnumerateInstanceLayerProperties = auto_cast GetInstanceProcAddr(nil, "vkEnumerateInstanceLayerProperties") - EnumerateInstanceVersion = auto_cast GetInstanceProcAddr(nil, "vkEnumerateInstanceVersion") - GetInstanceProcAddr = auto_cast GetInstanceProcAddr(nil, "vkGetInstanceProcAddr") -} - -load_proc_addresses :: proc{ - load_proc_addresses_global, - load_proc_addresses_instance, - load_proc_addresses_device, - load_proc_addresses_device_vtable, - load_proc_addresses_custom, -} - +// +// Vulkan wrapper generated from "https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/master/include/vulkan/vulkan_core.h" +// +package vulkan + +import "core:c" + +// Loader Procedure Types +ProcCreateInstance :: #type proc "system" (pCreateInfo: ^InstanceCreateInfo, pAllocator: ^AllocationCallbacks, pInstance: ^Instance) -> Result +ProcDebugUtilsMessengerCallbackEXT :: #type proc "system" (messageSeverity: DebugUtilsMessageSeverityFlagsEXT, messageTypes: DebugUtilsMessageTypeFlagsEXT, pCallbackData: ^DebugUtilsMessengerCallbackDataEXT, pUserData: rawptr) -> b32 +ProcDeviceMemoryReportCallbackEXT :: #type proc "system" (pCallbackData: ^DeviceMemoryReportCallbackDataEXT, pUserData: rawptr) +ProcEnumerateInstanceExtensionProperties :: #type proc "system" (pLayerName: cstring, pPropertyCount: ^u32, pProperties: [^]ExtensionProperties) -> Result +ProcEnumerateInstanceLayerProperties :: #type proc "system" (pPropertyCount: ^u32, pProperties: [^]LayerProperties) -> Result +ProcEnumerateInstanceVersion :: #type proc "system" (pApiVersion: ^u32) -> Result + +// Misc Procedure Types +ProcAllocationFunction :: #type proc "system" (pUserData: rawptr, size: int, alignment: int, allocationScope: SystemAllocationScope) -> rawptr +ProcDebugReportCallbackEXT :: #type proc "system" (flags: DebugReportFlagsEXT, objectType: DebugReportObjectTypeEXT, object: u64, location: int, messageCode: i32, pLayerPrefix: cstring, pMessage: cstring, pUserData: rawptr) -> b32 +ProcFreeFunction :: #type proc "system" (pUserData: rawptr, pMemory: rawptr) +ProcInternalAllocationNotification :: #type proc "system" (pUserData: rawptr, size: int, allocationType: InternalAllocationType, allocationScope: SystemAllocationScope) +ProcInternalFreeNotification :: #type proc "system" (pUserData: rawptr, size: int, allocationType: InternalAllocationType, allocationScope: SystemAllocationScope) +ProcReallocationFunction :: #type proc "system" (pUserData: rawptr, pOriginal: rawptr, size: int, alignment: int, allocationScope: SystemAllocationScope) -> rawptr +ProcVoidFunction :: #type proc "system" () + +// Instance Procedure Types +ProcAcquireDrmDisplayEXT :: #type proc "system" (physicalDevice: PhysicalDevice, drmFd: i32, display: DisplayKHR) -> Result +ProcAcquireWinrtDisplayNV :: #type proc "system" (physicalDevice: PhysicalDevice, display: DisplayKHR) -> Result +ProcCreateDebugReportCallbackEXT :: #type proc "system" (instance: Instance, pCreateInfo: ^DebugReportCallbackCreateInfoEXT, pAllocator: ^AllocationCallbacks, pCallback: ^DebugReportCallbackEXT) -> Result +ProcCreateDebugUtilsMessengerEXT :: #type proc "system" (instance: Instance, pCreateInfo: ^DebugUtilsMessengerCreateInfoEXT, pAllocator: ^AllocationCallbacks, pMessenger: ^DebugUtilsMessengerEXT) -> Result +ProcCreateDevice :: #type proc "system" (physicalDevice: PhysicalDevice, pCreateInfo: ^DeviceCreateInfo, pAllocator: ^AllocationCallbacks, pDevice: ^Device) -> Result +ProcCreateDisplayModeKHR :: #type proc "system" (physicalDevice: PhysicalDevice, display: DisplayKHR, pCreateInfo: ^DisplayModeCreateInfoKHR, pAllocator: ^AllocationCallbacks, pMode: ^DisplayModeKHR) -> Result +ProcCreateDisplayPlaneSurfaceKHR :: #type proc "system" (instance: Instance, pCreateInfo: ^DisplaySurfaceCreateInfoKHR, pAllocator: ^AllocationCallbacks, pSurface: ^SurfaceKHR) -> Result +ProcCreateHeadlessSurfaceEXT :: #type proc "system" (instance: Instance, pCreateInfo: ^HeadlessSurfaceCreateInfoEXT, pAllocator: ^AllocationCallbacks, pSurface: ^SurfaceKHR) -> Result +ProcCreateIOSSurfaceMVK :: #type proc "system" (instance: Instance, pCreateInfo: ^IOSSurfaceCreateInfoMVK, pAllocator: ^AllocationCallbacks, pSurface: ^SurfaceKHR) -> Result +ProcCreateMacOSSurfaceMVK :: #type proc "system" (instance: Instance, pCreateInfo: ^MacOSSurfaceCreateInfoMVK, pAllocator: ^AllocationCallbacks, pSurface: ^SurfaceKHR) -> Result +ProcCreateMetalSurfaceEXT :: #type proc "system" (instance: Instance, pCreateInfo: ^MetalSurfaceCreateInfoEXT, pAllocator: ^AllocationCallbacks, pSurface: ^SurfaceKHR) -> Result +ProcCreateWaylandSurfaceKHR :: #type proc "system" (instance: Instance, pCreateInfo: ^WaylandSurfaceCreateInfoKHR, pAllocator: ^AllocationCallbacks, pSurface: ^SurfaceKHR) -> Result +ProcCreateWin32SurfaceKHR :: #type proc "system" (instance: Instance, pCreateInfo: ^Win32SurfaceCreateInfoKHR, pAllocator: ^AllocationCallbacks, pSurface: ^SurfaceKHR) -> Result +ProcDebugReportMessageEXT :: #type proc "system" (instance: Instance, flags: DebugReportFlagsEXT, objectType: DebugReportObjectTypeEXT, object: u64, location: int, messageCode: i32, pLayerPrefix: cstring, pMessage: cstring) +ProcDestroyDebugReportCallbackEXT :: #type proc "system" (instance: Instance, callback: DebugReportCallbackEXT, pAllocator: ^AllocationCallbacks) +ProcDestroyDebugUtilsMessengerEXT :: #type proc "system" (instance: Instance, messenger: DebugUtilsMessengerEXT, pAllocator: ^AllocationCallbacks) +ProcDestroyInstance :: #type proc "system" (instance: Instance, pAllocator: ^AllocationCallbacks) +ProcDestroySurfaceKHR :: #type proc "system" (instance: Instance, surface: SurfaceKHR, pAllocator: ^AllocationCallbacks) +ProcEnumerateDeviceExtensionProperties :: #type proc "system" (physicalDevice: PhysicalDevice, pLayerName: cstring, pPropertyCount: ^u32, pProperties: [^]ExtensionProperties) -> Result +ProcEnumerateDeviceLayerProperties :: #type proc "system" (physicalDevice: PhysicalDevice, pPropertyCount: ^u32, pProperties: [^]LayerProperties) -> Result +ProcEnumeratePhysicalDeviceGroups :: #type proc "system" (instance: Instance, pPhysicalDeviceGroupCount: ^u32, pPhysicalDeviceGroupProperties: [^]PhysicalDeviceGroupProperties) -> Result +ProcEnumeratePhysicalDeviceGroupsKHR :: #type proc "system" (instance: Instance, pPhysicalDeviceGroupCount: ^u32, pPhysicalDeviceGroupProperties: [^]PhysicalDeviceGroupProperties) -> Result +ProcEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR :: #type proc "system" (physicalDevice: PhysicalDevice, queueFamilyIndex: u32, pCounterCount: ^u32, pCounters: [^]PerformanceCounterKHR, pCounterDescriptions: [^]PerformanceCounterDescriptionKHR) -> Result +ProcEnumeratePhysicalDevices :: #type proc "system" (instance: Instance, pPhysicalDeviceCount: ^u32, pPhysicalDevices: [^]PhysicalDevice) -> Result +ProcGetDisplayModeProperties2KHR :: #type proc "system" (physicalDevice: PhysicalDevice, display: DisplayKHR, pPropertyCount: ^u32, pProperties: [^]DisplayModeProperties2KHR) -> Result +ProcGetDisplayModePropertiesKHR :: #type proc "system" (physicalDevice: PhysicalDevice, display: DisplayKHR, pPropertyCount: ^u32, pProperties: [^]DisplayModePropertiesKHR) -> Result +ProcGetDisplayPlaneCapabilities2KHR :: #type proc "system" (physicalDevice: PhysicalDevice, pDisplayPlaneInfo: ^DisplayPlaneInfo2KHR, pCapabilities: [^]DisplayPlaneCapabilities2KHR) -> Result +ProcGetDisplayPlaneCapabilitiesKHR :: #type proc "system" (physicalDevice: PhysicalDevice, mode: DisplayModeKHR, planeIndex: u32, pCapabilities: [^]DisplayPlaneCapabilitiesKHR) -> Result +ProcGetDisplayPlaneSupportedDisplaysKHR :: #type proc "system" (physicalDevice: PhysicalDevice, planeIndex: u32, pDisplayCount: ^u32, pDisplays: [^]DisplayKHR) -> Result +ProcGetDrmDisplayEXT :: #type proc "system" (physicalDevice: PhysicalDevice, drmFd: i32, connectorId: u32, display: ^DisplayKHR) -> Result +ProcGetInstanceProcAddr :: #type proc "system" (instance: Instance, pName: cstring) -> ProcVoidFunction +ProcGetInstanceProcAddrLUNARG :: #type proc "system" (instance: Instance, pName: cstring) -> ProcVoidFunction +ProcGetPhysicalDeviceCalibrateableTimeDomainsEXT :: #type proc "system" (physicalDevice: PhysicalDevice, pTimeDomainCount: ^u32, pTimeDomains: [^]TimeDomainEXT) -> Result +ProcGetPhysicalDeviceCooperativeMatrixPropertiesNV :: #type proc "system" (physicalDevice: PhysicalDevice, pPropertyCount: ^u32, pProperties: [^]CooperativeMatrixPropertiesNV) -> Result +ProcGetPhysicalDeviceDisplayPlaneProperties2KHR :: #type proc "system" (physicalDevice: PhysicalDevice, pPropertyCount: ^u32, pProperties: [^]DisplayPlaneProperties2KHR) -> Result +ProcGetPhysicalDeviceDisplayPlanePropertiesKHR :: #type proc "system" (physicalDevice: PhysicalDevice, pPropertyCount: ^u32, pProperties: [^]DisplayPlanePropertiesKHR) -> Result +ProcGetPhysicalDeviceDisplayProperties2KHR :: #type proc "system" (physicalDevice: PhysicalDevice, pPropertyCount: ^u32, pProperties: [^]DisplayProperties2KHR) -> Result +ProcGetPhysicalDeviceDisplayPropertiesKHR :: #type proc "system" (physicalDevice: PhysicalDevice, pPropertyCount: ^u32, pProperties: [^]DisplayPropertiesKHR) -> Result +ProcGetPhysicalDeviceExternalBufferProperties :: #type proc "system" (physicalDevice: PhysicalDevice, pExternalBufferInfo: ^PhysicalDeviceExternalBufferInfo, pExternalBufferProperties: [^]ExternalBufferProperties) +ProcGetPhysicalDeviceExternalBufferPropertiesKHR :: #type proc "system" (physicalDevice: PhysicalDevice, pExternalBufferInfo: ^PhysicalDeviceExternalBufferInfo, pExternalBufferProperties: [^]ExternalBufferProperties) +ProcGetPhysicalDeviceExternalFenceProperties :: #type proc "system" (physicalDevice: PhysicalDevice, pExternalFenceInfo: ^PhysicalDeviceExternalFenceInfo, pExternalFenceProperties: [^]ExternalFenceProperties) +ProcGetPhysicalDeviceExternalFencePropertiesKHR :: #type proc "system" (physicalDevice: PhysicalDevice, pExternalFenceInfo: ^PhysicalDeviceExternalFenceInfo, pExternalFenceProperties: [^]ExternalFenceProperties) +ProcGetPhysicalDeviceExternalImageFormatPropertiesNV :: #type proc "system" (physicalDevice: PhysicalDevice, format: Format, type: ImageType, tiling: ImageTiling, usage: ImageUsageFlags, flags: ImageCreateFlags, externalHandleType: ExternalMemoryHandleTypeFlagsNV, pExternalImageFormatProperties: [^]ExternalImageFormatPropertiesNV) -> Result +ProcGetPhysicalDeviceExternalSemaphoreProperties :: #type proc "system" (physicalDevice: PhysicalDevice, pExternalSemaphoreInfo: ^PhysicalDeviceExternalSemaphoreInfo, pExternalSemaphoreProperties: [^]ExternalSemaphoreProperties) +ProcGetPhysicalDeviceExternalSemaphorePropertiesKHR :: #type proc "system" (physicalDevice: PhysicalDevice, pExternalSemaphoreInfo: ^PhysicalDeviceExternalSemaphoreInfo, pExternalSemaphoreProperties: [^]ExternalSemaphoreProperties) +ProcGetPhysicalDeviceFeatures :: #type proc "system" (physicalDevice: PhysicalDevice, pFeatures: [^]PhysicalDeviceFeatures) +ProcGetPhysicalDeviceFeatures2 :: #type proc "system" (physicalDevice: PhysicalDevice, pFeatures: [^]PhysicalDeviceFeatures2) +ProcGetPhysicalDeviceFeatures2KHR :: #type proc "system" (physicalDevice: PhysicalDevice, pFeatures: [^]PhysicalDeviceFeatures2) +ProcGetPhysicalDeviceFormatProperties :: #type proc "system" (physicalDevice: PhysicalDevice, format: Format, pFormatProperties: [^]FormatProperties) +ProcGetPhysicalDeviceFormatProperties2 :: #type proc "system" (physicalDevice: PhysicalDevice, format: Format, pFormatProperties: [^]FormatProperties2) +ProcGetPhysicalDeviceFormatProperties2KHR :: #type proc "system" (physicalDevice: PhysicalDevice, format: Format, pFormatProperties: [^]FormatProperties2) +ProcGetPhysicalDeviceFragmentShadingRatesKHR :: #type proc "system" (physicalDevice: PhysicalDevice, pFragmentShadingRateCount: ^u32, pFragmentShadingRates: [^]PhysicalDeviceFragmentShadingRateKHR) -> Result +ProcGetPhysicalDeviceImageFormatProperties :: #type proc "system" (physicalDevice: PhysicalDevice, format: Format, type: ImageType, tiling: ImageTiling, usage: ImageUsageFlags, flags: ImageCreateFlags, pImageFormatProperties: [^]ImageFormatProperties) -> Result +ProcGetPhysicalDeviceImageFormatProperties2 :: #type proc "system" (physicalDevice: PhysicalDevice, pImageFormatInfo: ^PhysicalDeviceImageFormatInfo2, pImageFormatProperties: [^]ImageFormatProperties2) -> Result +ProcGetPhysicalDeviceImageFormatProperties2KHR :: #type proc "system" (physicalDevice: PhysicalDevice, pImageFormatInfo: ^PhysicalDeviceImageFormatInfo2, pImageFormatProperties: [^]ImageFormatProperties2) -> Result +ProcGetPhysicalDeviceMemoryProperties :: #type proc "system" (physicalDevice: PhysicalDevice, pMemoryProperties: [^]PhysicalDeviceMemoryProperties) +ProcGetPhysicalDeviceMemoryProperties2 :: #type proc "system" (physicalDevice: PhysicalDevice, pMemoryProperties: [^]PhysicalDeviceMemoryProperties2) +ProcGetPhysicalDeviceMemoryProperties2KHR :: #type proc "system" (physicalDevice: PhysicalDevice, pMemoryProperties: [^]PhysicalDeviceMemoryProperties2) +ProcGetPhysicalDeviceMultisamplePropertiesEXT :: #type proc "system" (physicalDevice: PhysicalDevice, samples: SampleCountFlags, pMultisampleProperties: [^]MultisamplePropertiesEXT) +ProcGetPhysicalDeviceOpticalFlowImageFormatsNV :: #type proc "system" (physicalDevice: PhysicalDevice, pOpticalFlowImageFormatInfo: ^OpticalFlowImageFormatInfoNV, pFormatCount: ^u32, pImageFormatProperties: [^]OpticalFlowImageFormatPropertiesNV) -> Result +ProcGetPhysicalDevicePresentRectanglesKHR :: #type proc "system" (physicalDevice: PhysicalDevice, surface: SurfaceKHR, pRectCount: ^u32, pRects: [^]Rect2D) -> Result +ProcGetPhysicalDeviceProperties :: #type proc "system" (physicalDevice: PhysicalDevice, pProperties: [^]PhysicalDeviceProperties) +ProcGetPhysicalDeviceProperties2 :: #type proc "system" (physicalDevice: PhysicalDevice, pProperties: [^]PhysicalDeviceProperties2) +ProcGetPhysicalDeviceProperties2KHR :: #type proc "system" (physicalDevice: PhysicalDevice, pProperties: [^]PhysicalDeviceProperties2) +ProcGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR :: #type proc "system" (physicalDevice: PhysicalDevice, pPerformanceQueryCreateInfo: ^QueryPoolPerformanceCreateInfoKHR, pNumPasses: [^]u32) +ProcGetPhysicalDeviceQueueFamilyProperties :: #type proc "system" (physicalDevice: PhysicalDevice, pQueueFamilyPropertyCount: ^u32, pQueueFamilyProperties: [^]QueueFamilyProperties) +ProcGetPhysicalDeviceQueueFamilyProperties2 :: #type proc "system" (physicalDevice: PhysicalDevice, pQueueFamilyPropertyCount: ^u32, pQueueFamilyProperties: [^]QueueFamilyProperties2) +ProcGetPhysicalDeviceQueueFamilyProperties2KHR :: #type proc "system" (physicalDevice: PhysicalDevice, pQueueFamilyPropertyCount: ^u32, pQueueFamilyProperties: [^]QueueFamilyProperties2) +ProcGetPhysicalDeviceSparseImageFormatProperties :: #type proc "system" (physicalDevice: PhysicalDevice, format: Format, type: ImageType, samples: SampleCountFlags, usage: ImageUsageFlags, tiling: ImageTiling, pPropertyCount: ^u32, pProperties: [^]SparseImageFormatProperties) +ProcGetPhysicalDeviceSparseImageFormatProperties2 :: #type proc "system" (physicalDevice: PhysicalDevice, pFormatInfo: ^PhysicalDeviceSparseImageFormatInfo2, pPropertyCount: ^u32, pProperties: [^]SparseImageFormatProperties2) +ProcGetPhysicalDeviceSparseImageFormatProperties2KHR :: #type proc "system" (physicalDevice: PhysicalDevice, pFormatInfo: ^PhysicalDeviceSparseImageFormatInfo2, pPropertyCount: ^u32, pProperties: [^]SparseImageFormatProperties2) +ProcGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV :: #type proc "system" (physicalDevice: PhysicalDevice, pCombinationCount: ^u32, pCombinations: [^]FramebufferMixedSamplesCombinationNV) -> Result +ProcGetPhysicalDeviceSurfaceCapabilities2EXT :: #type proc "system" (physicalDevice: PhysicalDevice, surface: SurfaceKHR, pSurfaceCapabilities: [^]SurfaceCapabilities2EXT) -> Result +ProcGetPhysicalDeviceSurfaceCapabilities2KHR :: #type proc "system" (physicalDevice: PhysicalDevice, pSurfaceInfo: ^PhysicalDeviceSurfaceInfo2KHR, pSurfaceCapabilities: [^]SurfaceCapabilities2KHR) -> Result +ProcGetPhysicalDeviceSurfaceCapabilitiesKHR :: #type proc "system" (physicalDevice: PhysicalDevice, surface: SurfaceKHR, pSurfaceCapabilities: [^]SurfaceCapabilitiesKHR) -> Result +ProcGetPhysicalDeviceSurfaceFormats2KHR :: #type proc "system" (physicalDevice: PhysicalDevice, pSurfaceInfo: ^PhysicalDeviceSurfaceInfo2KHR, pSurfaceFormatCount: ^u32, pSurfaceFormats: [^]SurfaceFormat2KHR) -> Result +ProcGetPhysicalDeviceSurfaceFormatsKHR :: #type proc "system" (physicalDevice: PhysicalDevice, surface: SurfaceKHR, pSurfaceFormatCount: ^u32, pSurfaceFormats: [^]SurfaceFormatKHR) -> Result +ProcGetPhysicalDeviceSurfacePresentModes2EXT :: #type proc "system" (physicalDevice: PhysicalDevice, pSurfaceInfo: ^PhysicalDeviceSurfaceInfo2KHR, pPresentModeCount: ^u32, pPresentModes: [^]PresentModeKHR) -> Result +ProcGetPhysicalDeviceSurfacePresentModesKHR :: #type proc "system" (physicalDevice: PhysicalDevice, surface: SurfaceKHR, pPresentModeCount: ^u32, pPresentModes: [^]PresentModeKHR) -> Result +ProcGetPhysicalDeviceSurfaceSupportKHR :: #type proc "system" (physicalDevice: PhysicalDevice, queueFamilyIndex: u32, surface: SurfaceKHR, pSupported: ^b32) -> Result +ProcGetPhysicalDeviceToolProperties :: #type proc "system" (physicalDevice: PhysicalDevice, pToolCount: ^u32, pToolProperties: [^]PhysicalDeviceToolProperties) -> Result +ProcGetPhysicalDeviceToolPropertiesEXT :: #type proc "system" (physicalDevice: PhysicalDevice, pToolCount: ^u32, pToolProperties: [^]PhysicalDeviceToolProperties) -> Result +ProcGetPhysicalDeviceVideoCapabilitiesKHR :: #type proc "system" (physicalDevice: PhysicalDevice, pVideoProfile: ^VideoProfileInfoKHR, pCapabilities: [^]VideoCapabilitiesKHR) -> Result +ProcGetPhysicalDeviceVideoFormatPropertiesKHR :: #type proc "system" (physicalDevice: PhysicalDevice, pVideoFormatInfo: ^PhysicalDeviceVideoFormatInfoKHR, pVideoFormatPropertyCount: ^u32, pVideoFormatProperties: [^]VideoFormatPropertiesKHR) -> Result +ProcGetPhysicalDeviceWaylandPresentationSupportKHR :: #type proc "system" (physicalDevice: PhysicalDevice, queueFamilyIndex: u32, display: ^wl_display) -> b32 +ProcGetPhysicalDeviceWin32PresentationSupportKHR :: #type proc "system" (physicalDevice: PhysicalDevice, queueFamilyIndex: u32) -> b32 +ProcGetWinrtDisplayNV :: #type proc "system" (physicalDevice: PhysicalDevice, deviceRelativeId: u32, pDisplay: ^DisplayKHR) -> Result +ProcReleaseDisplayEXT :: #type proc "system" (physicalDevice: PhysicalDevice, display: DisplayKHR) -> Result +ProcSubmitDebugUtilsMessageEXT :: #type proc "system" (instance: Instance, messageSeverity: DebugUtilsMessageSeverityFlagsEXT, messageTypes: DebugUtilsMessageTypeFlagsEXT, pCallbackData: ^DebugUtilsMessengerCallbackDataEXT) + +// Device Procedure Types +ProcAcquireFullScreenExclusiveModeEXT :: #type proc "system" (device: Device, swapchain: SwapchainKHR) -> Result +ProcAcquireNextImage2KHR :: #type proc "system" (device: Device, pAcquireInfo: ^AcquireNextImageInfoKHR, pImageIndex: ^u32) -> Result +ProcAcquireNextImageKHR :: #type proc "system" (device: Device, swapchain: SwapchainKHR, timeout: u64, semaphore: Semaphore, fence: Fence, pImageIndex: ^u32) -> Result +ProcAcquirePerformanceConfigurationINTEL :: #type proc "system" (device: Device, pAcquireInfo: ^PerformanceConfigurationAcquireInfoINTEL, pConfiguration: ^PerformanceConfigurationINTEL) -> Result +ProcAcquireProfilingLockKHR :: #type proc "system" (device: Device, pInfo: ^AcquireProfilingLockInfoKHR) -> Result +ProcAllocateCommandBuffers :: #type proc "system" (device: Device, pAllocateInfo: ^CommandBufferAllocateInfo, pCommandBuffers: [^]CommandBuffer) -> Result +ProcAllocateDescriptorSets :: #type proc "system" (device: Device, pAllocateInfo: ^DescriptorSetAllocateInfo, pDescriptorSets: [^]DescriptorSet) -> Result +ProcAllocateMemory :: #type proc "system" (device: Device, pAllocateInfo: ^MemoryAllocateInfo, pAllocator: ^AllocationCallbacks, pMemory: ^DeviceMemory) -> Result +ProcBeginCommandBuffer :: #type proc "system" (commandBuffer: CommandBuffer, pBeginInfo: ^CommandBufferBeginInfo) -> Result +ProcBindAccelerationStructureMemoryNV :: #type proc "system" (device: Device, bindInfoCount: u32, pBindInfos: [^]BindAccelerationStructureMemoryInfoNV) -> Result +ProcBindBufferMemory :: #type proc "system" (device: Device, buffer: Buffer, memory: DeviceMemory, memoryOffset: DeviceSize) -> Result +ProcBindBufferMemory2 :: #type proc "system" (device: Device, bindInfoCount: u32, pBindInfos: [^]BindBufferMemoryInfo) -> Result +ProcBindBufferMemory2KHR :: #type proc "system" (device: Device, bindInfoCount: u32, pBindInfos: [^]BindBufferMemoryInfo) -> Result +ProcBindImageMemory :: #type proc "system" (device: Device, image: Image, memory: DeviceMemory, memoryOffset: DeviceSize) -> Result +ProcBindImageMemory2 :: #type proc "system" (device: Device, bindInfoCount: u32, pBindInfos: [^]BindImageMemoryInfo) -> Result +ProcBindImageMemory2KHR :: #type proc "system" (device: Device, bindInfoCount: u32, pBindInfos: [^]BindImageMemoryInfo) -> Result +ProcBindOpticalFlowSessionImageNV :: #type proc "system" (device: Device, session: OpticalFlowSessionNV, bindingPoint: OpticalFlowSessionBindingPointNV, view: ImageView, layout: ImageLayout) -> Result +ProcBindVideoSessionMemoryKHR :: #type proc "system" (device: Device, videoSession: VideoSessionKHR, bindSessionMemoryInfoCount: u32, pBindSessionMemoryInfos: [^]BindVideoSessionMemoryInfoKHR) -> Result +ProcBuildAccelerationStructuresKHR :: #type proc "system" (device: Device, deferredOperation: DeferredOperationKHR, infoCount: u32, pInfos: [^]AccelerationStructureBuildGeometryInfoKHR, ppBuildRangeInfos: ^[^]AccelerationStructureBuildRangeInfoKHR) -> Result +ProcBuildMicromapsEXT :: #type proc "system" (device: Device, deferredOperation: DeferredOperationKHR, infoCount: u32, pInfos: [^]MicromapBuildInfoEXT) -> Result +ProcCmdBeginConditionalRenderingEXT :: #type proc "system" (commandBuffer: CommandBuffer, pConditionalRenderingBegin: ^ConditionalRenderingBeginInfoEXT) +ProcCmdBeginDebugUtilsLabelEXT :: #type proc "system" (commandBuffer: CommandBuffer, pLabelInfo: ^DebugUtilsLabelEXT) +ProcCmdBeginQuery :: #type proc "system" (commandBuffer: CommandBuffer, queryPool: QueryPool, query: u32, flags: QueryControlFlags) +ProcCmdBeginQueryIndexedEXT :: #type proc "system" (commandBuffer: CommandBuffer, queryPool: QueryPool, query: u32, flags: QueryControlFlags, index: u32) +ProcCmdBeginRenderPass :: #type proc "system" (commandBuffer: CommandBuffer, pRenderPassBegin: ^RenderPassBeginInfo, contents: SubpassContents) +ProcCmdBeginRenderPass2 :: #type proc "system" (commandBuffer: CommandBuffer, pRenderPassBegin: ^RenderPassBeginInfo, pSubpassBeginInfo: ^SubpassBeginInfo) +ProcCmdBeginRenderPass2KHR :: #type proc "system" (commandBuffer: CommandBuffer, pRenderPassBegin: ^RenderPassBeginInfo, pSubpassBeginInfo: ^SubpassBeginInfo) +ProcCmdBeginRendering :: #type proc "system" (commandBuffer: CommandBuffer, pRenderingInfo: ^RenderingInfo) +ProcCmdBeginRenderingKHR :: #type proc "system" (commandBuffer: CommandBuffer, pRenderingInfo: ^RenderingInfo) +ProcCmdBeginTransformFeedbackEXT :: #type proc "system" (commandBuffer: CommandBuffer, firstCounterBuffer: u32, counterBufferCount: u32, pCounterBuffers: [^]Buffer, pCounterBufferOffsets: [^]DeviceSize) +ProcCmdBeginVideoCodingKHR :: #type proc "system" (commandBuffer: CommandBuffer, pBeginInfo: ^VideoBeginCodingInfoKHR) +ProcCmdBindDescriptorBufferEmbeddedSamplersEXT :: #type proc "system" (commandBuffer: CommandBuffer, pipelineBindPoint: PipelineBindPoint, layout: PipelineLayout, set: u32) +ProcCmdBindDescriptorBuffersEXT :: #type proc "system" (commandBuffer: CommandBuffer, bufferCount: u32, pBindingInfos: [^]DescriptorBufferBindingInfoEXT) +ProcCmdBindDescriptorSets :: #type proc "system" (commandBuffer: CommandBuffer, pipelineBindPoint: PipelineBindPoint, layout: PipelineLayout, firstSet: u32, descriptorSetCount: u32, pDescriptorSets: [^]DescriptorSet, dynamicOffsetCount: u32, pDynamicOffsets: [^]u32) +ProcCmdBindIndexBuffer :: #type proc "system" (commandBuffer: CommandBuffer, buffer: Buffer, offset: DeviceSize, indexType: IndexType) +ProcCmdBindInvocationMaskHUAWEI :: #type proc "system" (commandBuffer: CommandBuffer, imageView: ImageView, imageLayout: ImageLayout) +ProcCmdBindPipeline :: #type proc "system" (commandBuffer: CommandBuffer, pipelineBindPoint: PipelineBindPoint, pipeline: Pipeline) +ProcCmdBindPipelineShaderGroupNV :: #type proc "system" (commandBuffer: CommandBuffer, pipelineBindPoint: PipelineBindPoint, pipeline: Pipeline, groupIndex: u32) +ProcCmdBindShadersEXT :: #type proc "system" (commandBuffer: CommandBuffer, stageCount: u32, pStages: [^]ShaderStageFlags, pShaders: [^]ShaderEXT) +ProcCmdBindShadingRateImageNV :: #type proc "system" (commandBuffer: CommandBuffer, imageView: ImageView, imageLayout: ImageLayout) +ProcCmdBindTransformFeedbackBuffersEXT :: #type proc "system" (commandBuffer: CommandBuffer, firstBinding: u32, bindingCount: u32, pBuffers: [^]Buffer, pOffsets: [^]DeviceSize, pSizes: [^]DeviceSize) +ProcCmdBindVertexBuffers :: #type proc "system" (commandBuffer: CommandBuffer, firstBinding: u32, bindingCount: u32, pBuffers: [^]Buffer, pOffsets: [^]DeviceSize) +ProcCmdBindVertexBuffers2 :: #type proc "system" (commandBuffer: CommandBuffer, firstBinding: u32, bindingCount: u32, pBuffers: [^]Buffer, pOffsets: [^]DeviceSize, pSizes: [^]DeviceSize, pStrides: [^]DeviceSize) +ProcCmdBindVertexBuffers2EXT :: #type proc "system" (commandBuffer: CommandBuffer, firstBinding: u32, bindingCount: u32, pBuffers: [^]Buffer, pOffsets: [^]DeviceSize, pSizes: [^]DeviceSize, pStrides: [^]DeviceSize) +ProcCmdBlitImage :: #type proc "system" (commandBuffer: CommandBuffer, srcImage: Image, srcImageLayout: ImageLayout, dstImage: Image, dstImageLayout: ImageLayout, regionCount: u32, pRegions: [^]ImageBlit, filter: Filter) +ProcCmdBlitImage2 :: #type proc "system" (commandBuffer: CommandBuffer, pBlitImageInfo: ^BlitImageInfo2) +ProcCmdBlitImage2KHR :: #type proc "system" (commandBuffer: CommandBuffer, pBlitImageInfo: ^BlitImageInfo2) +ProcCmdBuildAccelerationStructureNV :: #type proc "system" (commandBuffer: CommandBuffer, pInfo: ^AccelerationStructureInfoNV, instanceData: Buffer, instanceOffset: DeviceSize, update: b32, dst: AccelerationStructureNV, src: AccelerationStructureNV, scratch: Buffer, scratchOffset: DeviceSize) +ProcCmdBuildAccelerationStructuresIndirectKHR :: #type proc "system" (commandBuffer: CommandBuffer, infoCount: u32, pInfos: [^]AccelerationStructureBuildGeometryInfoKHR, pIndirectDeviceAddresses: [^]DeviceAddress, pIndirectStrides: [^]u32, ppMaxPrimitiveCounts: ^[^]u32) +ProcCmdBuildAccelerationStructuresKHR :: #type proc "system" (commandBuffer: CommandBuffer, infoCount: u32, pInfos: [^]AccelerationStructureBuildGeometryInfoKHR, ppBuildRangeInfos: ^[^]AccelerationStructureBuildRangeInfoKHR) +ProcCmdBuildMicromapsEXT :: #type proc "system" (commandBuffer: CommandBuffer, infoCount: u32, pInfos: [^]MicromapBuildInfoEXT) +ProcCmdClearAttachments :: #type proc "system" (commandBuffer: CommandBuffer, attachmentCount: u32, pAttachments: [^]ClearAttachment, rectCount: u32, pRects: [^]ClearRect) +ProcCmdClearColorImage :: #type proc "system" (commandBuffer: CommandBuffer, image: Image, imageLayout: ImageLayout, pColor: ^ClearColorValue, rangeCount: u32, pRanges: [^]ImageSubresourceRange) +ProcCmdClearDepthStencilImage :: #type proc "system" (commandBuffer: CommandBuffer, image: Image, imageLayout: ImageLayout, pDepthStencil: ^ClearDepthStencilValue, rangeCount: u32, pRanges: [^]ImageSubresourceRange) +ProcCmdControlVideoCodingKHR :: #type proc "system" (commandBuffer: CommandBuffer, pCodingControlInfo: ^VideoCodingControlInfoKHR) +ProcCmdCopyAccelerationStructureKHR :: #type proc "system" (commandBuffer: CommandBuffer, pInfo: ^CopyAccelerationStructureInfoKHR) +ProcCmdCopyAccelerationStructureNV :: #type proc "system" (commandBuffer: CommandBuffer, dst: AccelerationStructureNV, src: AccelerationStructureNV, mode: CopyAccelerationStructureModeKHR) +ProcCmdCopyAccelerationStructureToMemoryKHR :: #type proc "system" (commandBuffer: CommandBuffer, pInfo: ^CopyAccelerationStructureToMemoryInfoKHR) +ProcCmdCopyBuffer :: #type proc "system" (commandBuffer: CommandBuffer, srcBuffer: Buffer, dstBuffer: Buffer, regionCount: u32, pRegions: [^]BufferCopy) +ProcCmdCopyBuffer2 :: #type proc "system" (commandBuffer: CommandBuffer, pCopyBufferInfo: ^CopyBufferInfo2) +ProcCmdCopyBuffer2KHR :: #type proc "system" (commandBuffer: CommandBuffer, pCopyBufferInfo: ^CopyBufferInfo2) +ProcCmdCopyBufferToImage :: #type proc "system" (commandBuffer: CommandBuffer, srcBuffer: Buffer, dstImage: Image, dstImageLayout: ImageLayout, regionCount: u32, pRegions: [^]BufferImageCopy) +ProcCmdCopyBufferToImage2 :: #type proc "system" (commandBuffer: CommandBuffer, pCopyBufferToImageInfo: ^CopyBufferToImageInfo2) +ProcCmdCopyBufferToImage2KHR :: #type proc "system" (commandBuffer: CommandBuffer, pCopyBufferToImageInfo: ^CopyBufferToImageInfo2) +ProcCmdCopyImage :: #type proc "system" (commandBuffer: CommandBuffer, srcImage: Image, srcImageLayout: ImageLayout, dstImage: Image, dstImageLayout: ImageLayout, regionCount: u32, pRegions: [^]ImageCopy) +ProcCmdCopyImage2 :: #type proc "system" (commandBuffer: CommandBuffer, pCopyImageInfo: ^CopyImageInfo2) +ProcCmdCopyImage2KHR :: #type proc "system" (commandBuffer: CommandBuffer, pCopyImageInfo: ^CopyImageInfo2) +ProcCmdCopyImageToBuffer :: #type proc "system" (commandBuffer: CommandBuffer, srcImage: Image, srcImageLayout: ImageLayout, dstBuffer: Buffer, regionCount: u32, pRegions: [^]BufferImageCopy) +ProcCmdCopyImageToBuffer2 :: #type proc "system" (commandBuffer: CommandBuffer, pCopyImageToBufferInfo: ^CopyImageToBufferInfo2) +ProcCmdCopyImageToBuffer2KHR :: #type proc "system" (commandBuffer: CommandBuffer, pCopyImageToBufferInfo: ^CopyImageToBufferInfo2) +ProcCmdCopyMemoryIndirectNV :: #type proc "system" (commandBuffer: CommandBuffer, copyBufferAddress: DeviceAddress, copyCount: u32, stride: u32) +ProcCmdCopyMemoryToAccelerationStructureKHR :: #type proc "system" (commandBuffer: CommandBuffer, pInfo: ^CopyMemoryToAccelerationStructureInfoKHR) +ProcCmdCopyMemoryToImageIndirectNV :: #type proc "system" (commandBuffer: CommandBuffer, copyBufferAddress: DeviceAddress, copyCount: u32, stride: u32, dstImage: Image, dstImageLayout: ImageLayout, pImageSubresources: [^]ImageSubresourceLayers) +ProcCmdCopyMemoryToMicromapEXT :: #type proc "system" (commandBuffer: CommandBuffer, pInfo: ^CopyMemoryToMicromapInfoEXT) +ProcCmdCopyMicromapEXT :: #type proc "system" (commandBuffer: CommandBuffer, pInfo: ^CopyMicromapInfoEXT) +ProcCmdCopyMicromapToMemoryEXT :: #type proc "system" (commandBuffer: CommandBuffer, pInfo: ^CopyMicromapToMemoryInfoEXT) +ProcCmdCopyQueryPoolResults :: #type proc "system" (commandBuffer: CommandBuffer, queryPool: QueryPool, firstQuery: u32, queryCount: u32, dstBuffer: Buffer, dstOffset: DeviceSize, stride: DeviceSize, flags: QueryResultFlags) +ProcCmdCuLaunchKernelNVX :: #type proc "system" (commandBuffer: CommandBuffer, pLaunchInfo: ^CuLaunchInfoNVX) +ProcCmdDebugMarkerBeginEXT :: #type proc "system" (commandBuffer: CommandBuffer, pMarkerInfo: ^DebugMarkerMarkerInfoEXT) +ProcCmdDebugMarkerEndEXT :: #type proc "system" (commandBuffer: CommandBuffer) +ProcCmdDebugMarkerInsertEXT :: #type proc "system" (commandBuffer: CommandBuffer, pMarkerInfo: ^DebugMarkerMarkerInfoEXT) +ProcCmdDecodeVideoKHR :: #type proc "system" (commandBuffer: CommandBuffer, pDecodeInfo: ^VideoDecodeInfoKHR) +ProcCmdDecompressMemoryIndirectCountNV :: #type proc "system" (commandBuffer: CommandBuffer, indirectCommandsAddress: DeviceAddress, indirectCommandsCountAddress: DeviceAddress, stride: u32) +ProcCmdDecompressMemoryNV :: #type proc "system" (commandBuffer: CommandBuffer, decompressRegionCount: u32, pDecompressMemoryRegions: [^]DecompressMemoryRegionNV) +ProcCmdDispatch :: #type proc "system" (commandBuffer: CommandBuffer, groupCountX: u32, groupCountY: u32, groupCountZ: u32) +ProcCmdDispatchBase :: #type proc "system" (commandBuffer: CommandBuffer, baseGroupX: u32, baseGroupY: u32, baseGroupZ: u32, groupCountX: u32, groupCountY: u32, groupCountZ: u32) +ProcCmdDispatchBaseKHR :: #type proc "system" (commandBuffer: CommandBuffer, baseGroupX: u32, baseGroupY: u32, baseGroupZ: u32, groupCountX: u32, groupCountY: u32, groupCountZ: u32) +ProcCmdDispatchIndirect :: #type proc "system" (commandBuffer: CommandBuffer, buffer: Buffer, offset: DeviceSize) +ProcCmdDraw :: #type proc "system" (commandBuffer: CommandBuffer, vertexCount: u32, instanceCount: u32, firstVertex: u32, firstInstance: u32) +ProcCmdDrawClusterHUAWEI :: #type proc "system" (commandBuffer: CommandBuffer, groupCountX: u32, groupCountY: u32, groupCountZ: u32) +ProcCmdDrawClusterIndirectHUAWEI :: #type proc "system" (commandBuffer: CommandBuffer, buffer: Buffer, offset: DeviceSize) +ProcCmdDrawIndexed :: #type proc "system" (commandBuffer: CommandBuffer, indexCount: u32, instanceCount: u32, firstIndex: u32, vertexOffset: i32, firstInstance: u32) +ProcCmdDrawIndexedIndirect :: #type proc "system" (commandBuffer: CommandBuffer, buffer: Buffer, offset: DeviceSize, drawCount: u32, stride: u32) +ProcCmdDrawIndexedIndirectCount :: #type proc "system" (commandBuffer: CommandBuffer, buffer: Buffer, offset: DeviceSize, countBuffer: Buffer, countBufferOffset: DeviceSize, maxDrawCount: u32, stride: u32) +ProcCmdDrawIndexedIndirectCountAMD :: #type proc "system" (commandBuffer: CommandBuffer, buffer: Buffer, offset: DeviceSize, countBuffer: Buffer, countBufferOffset: DeviceSize, maxDrawCount: u32, stride: u32) +ProcCmdDrawIndexedIndirectCountKHR :: #type proc "system" (commandBuffer: CommandBuffer, buffer: Buffer, offset: DeviceSize, countBuffer: Buffer, countBufferOffset: DeviceSize, maxDrawCount: u32, stride: u32) +ProcCmdDrawIndirect :: #type proc "system" (commandBuffer: CommandBuffer, buffer: Buffer, offset: DeviceSize, drawCount: u32, stride: u32) +ProcCmdDrawIndirectByteCountEXT :: #type proc "system" (commandBuffer: CommandBuffer, instanceCount: u32, firstInstance: u32, counterBuffer: Buffer, counterBufferOffset: DeviceSize, counterOffset: u32, vertexStride: u32) +ProcCmdDrawIndirectCount :: #type proc "system" (commandBuffer: CommandBuffer, buffer: Buffer, offset: DeviceSize, countBuffer: Buffer, countBufferOffset: DeviceSize, maxDrawCount: u32, stride: u32) +ProcCmdDrawIndirectCountAMD :: #type proc "system" (commandBuffer: CommandBuffer, buffer: Buffer, offset: DeviceSize, countBuffer: Buffer, countBufferOffset: DeviceSize, maxDrawCount: u32, stride: u32) +ProcCmdDrawIndirectCountKHR :: #type proc "system" (commandBuffer: CommandBuffer, buffer: Buffer, offset: DeviceSize, countBuffer: Buffer, countBufferOffset: DeviceSize, maxDrawCount: u32, stride: u32) +ProcCmdDrawMeshTasksEXT :: #type proc "system" (commandBuffer: CommandBuffer, groupCountX: u32, groupCountY: u32, groupCountZ: u32) +ProcCmdDrawMeshTasksIndirectCountEXT :: #type proc "system" (commandBuffer: CommandBuffer, buffer: Buffer, offset: DeviceSize, countBuffer: Buffer, countBufferOffset: DeviceSize, maxDrawCount: u32, stride: u32) +ProcCmdDrawMeshTasksIndirectCountNV :: #type proc "system" (commandBuffer: CommandBuffer, buffer: Buffer, offset: DeviceSize, countBuffer: Buffer, countBufferOffset: DeviceSize, maxDrawCount: u32, stride: u32) +ProcCmdDrawMeshTasksIndirectEXT :: #type proc "system" (commandBuffer: CommandBuffer, buffer: Buffer, offset: DeviceSize, drawCount: u32, stride: u32) +ProcCmdDrawMeshTasksIndirectNV :: #type proc "system" (commandBuffer: CommandBuffer, buffer: Buffer, offset: DeviceSize, drawCount: u32, stride: u32) +ProcCmdDrawMeshTasksNV :: #type proc "system" (commandBuffer: CommandBuffer, taskCount: u32, firstTask: u32) +ProcCmdDrawMultiEXT :: #type proc "system" (commandBuffer: CommandBuffer, drawCount: u32, pVertexInfo: ^MultiDrawInfoEXT, instanceCount: u32, firstInstance: u32, stride: u32) +ProcCmdDrawMultiIndexedEXT :: #type proc "system" (commandBuffer: CommandBuffer, drawCount: u32, pIndexInfo: ^MultiDrawIndexedInfoEXT, instanceCount: u32, firstInstance: u32, stride: u32, pVertexOffset: ^i32) +ProcCmdEndConditionalRenderingEXT :: #type proc "system" (commandBuffer: CommandBuffer) +ProcCmdEndDebugUtilsLabelEXT :: #type proc "system" (commandBuffer: CommandBuffer) +ProcCmdEndQuery :: #type proc "system" (commandBuffer: CommandBuffer, queryPool: QueryPool, query: u32) +ProcCmdEndQueryIndexedEXT :: #type proc "system" (commandBuffer: CommandBuffer, queryPool: QueryPool, query: u32, index: u32) +ProcCmdEndRenderPass :: #type proc "system" (commandBuffer: CommandBuffer) +ProcCmdEndRenderPass2 :: #type proc "system" (commandBuffer: CommandBuffer, pSubpassEndInfo: ^SubpassEndInfo) +ProcCmdEndRenderPass2KHR :: #type proc "system" (commandBuffer: CommandBuffer, pSubpassEndInfo: ^SubpassEndInfo) +ProcCmdEndRendering :: #type proc "system" (commandBuffer: CommandBuffer) +ProcCmdEndRenderingKHR :: #type proc "system" (commandBuffer: CommandBuffer) +ProcCmdEndTransformFeedbackEXT :: #type proc "system" (commandBuffer: CommandBuffer, firstCounterBuffer: u32, counterBufferCount: u32, pCounterBuffers: [^]Buffer, pCounterBufferOffsets: [^]DeviceSize) +ProcCmdEndVideoCodingKHR :: #type proc "system" (commandBuffer: CommandBuffer, pEndCodingInfo: ^VideoEndCodingInfoKHR) +ProcCmdExecuteCommands :: #type proc "system" (commandBuffer: CommandBuffer, commandBufferCount: u32, pCommandBuffers: [^]CommandBuffer) +ProcCmdExecuteGeneratedCommandsNV :: #type proc "system" (commandBuffer: CommandBuffer, isPreprocessed: b32, pGeneratedCommandsInfo: ^GeneratedCommandsInfoNV) +ProcCmdFillBuffer :: #type proc "system" (commandBuffer: CommandBuffer, dstBuffer: Buffer, dstOffset: DeviceSize, size: DeviceSize, data: u32) +ProcCmdInsertDebugUtilsLabelEXT :: #type proc "system" (commandBuffer: CommandBuffer, pLabelInfo: ^DebugUtilsLabelEXT) +ProcCmdNextSubpass :: #type proc "system" (commandBuffer: CommandBuffer, contents: SubpassContents) +ProcCmdNextSubpass2 :: #type proc "system" (commandBuffer: CommandBuffer, pSubpassBeginInfo: ^SubpassBeginInfo, pSubpassEndInfo: ^SubpassEndInfo) +ProcCmdNextSubpass2KHR :: #type proc "system" (commandBuffer: CommandBuffer, pSubpassBeginInfo: ^SubpassBeginInfo, pSubpassEndInfo: ^SubpassEndInfo) +ProcCmdOpticalFlowExecuteNV :: #type proc "system" (commandBuffer: CommandBuffer, session: OpticalFlowSessionNV, pExecuteInfo: ^OpticalFlowExecuteInfoNV) +ProcCmdPipelineBarrier :: #type proc "system" (commandBuffer: CommandBuffer, srcStageMask: PipelineStageFlags, dstStageMask: PipelineStageFlags, dependencyFlags: DependencyFlags, memoryBarrierCount: u32, pMemoryBarriers: [^]MemoryBarrier, bufferMemoryBarrierCount: u32, pBufferMemoryBarriers: [^]BufferMemoryBarrier, imageMemoryBarrierCount: u32, pImageMemoryBarriers: [^]ImageMemoryBarrier) +ProcCmdPipelineBarrier2 :: #type proc "system" (commandBuffer: CommandBuffer, pDependencyInfo: ^DependencyInfo) +ProcCmdPipelineBarrier2KHR :: #type proc "system" (commandBuffer: CommandBuffer, pDependencyInfo: ^DependencyInfo) +ProcCmdPreprocessGeneratedCommandsNV :: #type proc "system" (commandBuffer: CommandBuffer, pGeneratedCommandsInfo: ^GeneratedCommandsInfoNV) +ProcCmdPushConstants :: #type proc "system" (commandBuffer: CommandBuffer, layout: PipelineLayout, stageFlags: ShaderStageFlags, offset: u32, size: u32, pValues: rawptr) +ProcCmdPushDescriptorSetKHR :: #type proc "system" (commandBuffer: CommandBuffer, pipelineBindPoint: PipelineBindPoint, layout: PipelineLayout, set: u32, descriptorWriteCount: u32, pDescriptorWrites: [^]WriteDescriptorSet) +ProcCmdPushDescriptorSetWithTemplateKHR :: #type proc "system" (commandBuffer: CommandBuffer, descriptorUpdateTemplate: DescriptorUpdateTemplate, layout: PipelineLayout, set: u32, pData: rawptr) +ProcCmdResetEvent :: #type proc "system" (commandBuffer: CommandBuffer, event: Event, stageMask: PipelineStageFlags) +ProcCmdResetEvent2 :: #type proc "system" (commandBuffer: CommandBuffer, event: Event, stageMask: PipelineStageFlags2) +ProcCmdResetEvent2KHR :: #type proc "system" (commandBuffer: CommandBuffer, event: Event, stageMask: PipelineStageFlags2) +ProcCmdResetQueryPool :: #type proc "system" (commandBuffer: CommandBuffer, queryPool: QueryPool, firstQuery: u32, queryCount: u32) +ProcCmdResolveImage :: #type proc "system" (commandBuffer: CommandBuffer, srcImage: Image, srcImageLayout: ImageLayout, dstImage: Image, dstImageLayout: ImageLayout, regionCount: u32, pRegions: [^]ImageResolve) +ProcCmdResolveImage2 :: #type proc "system" (commandBuffer: CommandBuffer, pResolveImageInfo: ^ResolveImageInfo2) +ProcCmdResolveImage2KHR :: #type proc "system" (commandBuffer: CommandBuffer, pResolveImageInfo: ^ResolveImageInfo2) +ProcCmdSetAlphaToCoverageEnableEXT :: #type proc "system" (commandBuffer: CommandBuffer, alphaToCoverageEnable: b32) +ProcCmdSetAlphaToOneEnableEXT :: #type proc "system" (commandBuffer: CommandBuffer, alphaToOneEnable: b32) +ProcCmdSetAttachmentFeedbackLoopEnableEXT :: #type proc "system" (commandBuffer: CommandBuffer, aspectMask: ImageAspectFlags) +ProcCmdSetBlendConstants :: #type proc "system" (commandBuffer: CommandBuffer) +ProcCmdSetCheckpointNV :: #type proc "system" (commandBuffer: CommandBuffer, pCheckpointMarker: rawptr) +ProcCmdSetCoarseSampleOrderNV :: #type proc "system" (commandBuffer: CommandBuffer, sampleOrderType: CoarseSampleOrderTypeNV, customSampleOrderCount: u32, pCustomSampleOrders: [^]CoarseSampleOrderCustomNV) +ProcCmdSetColorBlendAdvancedEXT :: #type proc "system" (commandBuffer: CommandBuffer, firstAttachment: u32, attachmentCount: u32, pColorBlendAdvanced: ^ColorBlendAdvancedEXT) +ProcCmdSetColorBlendEnableEXT :: #type proc "system" (commandBuffer: CommandBuffer, firstAttachment: u32, attachmentCount: u32, pColorBlendEnables: [^]b32) +ProcCmdSetColorBlendEquationEXT :: #type proc "system" (commandBuffer: CommandBuffer, firstAttachment: u32, attachmentCount: u32, pColorBlendEquations: [^]ColorBlendEquationEXT) +ProcCmdSetColorWriteMaskEXT :: #type proc "system" (commandBuffer: CommandBuffer, firstAttachment: u32, attachmentCount: u32, pColorWriteMasks: [^]ColorComponentFlags) +ProcCmdSetConservativeRasterizationModeEXT :: #type proc "system" (commandBuffer: CommandBuffer, conservativeRasterizationMode: ConservativeRasterizationModeEXT) +ProcCmdSetCoverageModulationModeNV :: #type proc "system" (commandBuffer: CommandBuffer, coverageModulationMode: CoverageModulationModeNV) +ProcCmdSetCoverageModulationTableEnableNV :: #type proc "system" (commandBuffer: CommandBuffer, coverageModulationTableEnable: b32) +ProcCmdSetCoverageModulationTableNV :: #type proc "system" (commandBuffer: CommandBuffer, coverageModulationTableCount: u32, pCoverageModulationTable: [^]f32) +ProcCmdSetCoverageReductionModeNV :: #type proc "system" (commandBuffer: CommandBuffer, coverageReductionMode: CoverageReductionModeNV) +ProcCmdSetCoverageToColorEnableNV :: #type proc "system" (commandBuffer: CommandBuffer, coverageToColorEnable: b32) +ProcCmdSetCoverageToColorLocationNV :: #type proc "system" (commandBuffer: CommandBuffer, coverageToColorLocation: u32) +ProcCmdSetCullMode :: #type proc "system" (commandBuffer: CommandBuffer, cullMode: CullModeFlags) +ProcCmdSetCullModeEXT :: #type proc "system" (commandBuffer: CommandBuffer, cullMode: CullModeFlags) +ProcCmdSetDepthBias :: #type proc "system" (commandBuffer: CommandBuffer, depthBiasConstantFactor: f32, depthBiasClamp: f32, depthBiasSlopeFactor: f32) +ProcCmdSetDepthBiasEnable :: #type proc "system" (commandBuffer: CommandBuffer, depthBiasEnable: b32) +ProcCmdSetDepthBiasEnableEXT :: #type proc "system" (commandBuffer: CommandBuffer, depthBiasEnable: b32) +ProcCmdSetDepthBounds :: #type proc "system" (commandBuffer: CommandBuffer, minDepthBounds: f32, maxDepthBounds: f32) +ProcCmdSetDepthBoundsTestEnable :: #type proc "system" (commandBuffer: CommandBuffer, depthBoundsTestEnable: b32) +ProcCmdSetDepthBoundsTestEnableEXT :: #type proc "system" (commandBuffer: CommandBuffer, depthBoundsTestEnable: b32) +ProcCmdSetDepthClampEnableEXT :: #type proc "system" (commandBuffer: CommandBuffer, depthClampEnable: b32) +ProcCmdSetDepthClipEnableEXT :: #type proc "system" (commandBuffer: CommandBuffer, depthClipEnable: b32) +ProcCmdSetDepthClipNegativeOneToOneEXT :: #type proc "system" (commandBuffer: CommandBuffer, negativeOneToOne: b32) +ProcCmdSetDepthCompareOp :: #type proc "system" (commandBuffer: CommandBuffer, depthCompareOp: CompareOp) +ProcCmdSetDepthCompareOpEXT :: #type proc "system" (commandBuffer: CommandBuffer, depthCompareOp: CompareOp) +ProcCmdSetDepthTestEnable :: #type proc "system" (commandBuffer: CommandBuffer, depthTestEnable: b32) +ProcCmdSetDepthTestEnableEXT :: #type proc "system" (commandBuffer: CommandBuffer, depthTestEnable: b32) +ProcCmdSetDepthWriteEnable :: #type proc "system" (commandBuffer: CommandBuffer, depthWriteEnable: b32) +ProcCmdSetDepthWriteEnableEXT :: #type proc "system" (commandBuffer: CommandBuffer, depthWriteEnable: b32) +ProcCmdSetDescriptorBufferOffsetsEXT :: #type proc "system" (commandBuffer: CommandBuffer, pipelineBindPoint: PipelineBindPoint, layout: PipelineLayout, firstSet: u32, setCount: u32, pBufferIndices: [^]u32, pOffsets: [^]DeviceSize) +ProcCmdSetDeviceMask :: #type proc "system" (commandBuffer: CommandBuffer, deviceMask: u32) +ProcCmdSetDeviceMaskKHR :: #type proc "system" (commandBuffer: CommandBuffer, deviceMask: u32) +ProcCmdSetDiscardRectangleEXT :: #type proc "system" (commandBuffer: CommandBuffer, firstDiscardRectangle: u32, discardRectangleCount: u32, pDiscardRectangles: [^]Rect2D) +ProcCmdSetDiscardRectangleEnableEXT :: #type proc "system" (commandBuffer: CommandBuffer, discardRectangleEnable: b32) +ProcCmdSetDiscardRectangleModeEXT :: #type proc "system" (commandBuffer: CommandBuffer, discardRectangleMode: DiscardRectangleModeEXT) +ProcCmdSetEvent :: #type proc "system" (commandBuffer: CommandBuffer, event: Event, stageMask: PipelineStageFlags) +ProcCmdSetEvent2 :: #type proc "system" (commandBuffer: CommandBuffer, event: Event, pDependencyInfo: ^DependencyInfo) +ProcCmdSetEvent2KHR :: #type proc "system" (commandBuffer: CommandBuffer, event: Event, pDependencyInfo: ^DependencyInfo) +ProcCmdSetExclusiveScissorEnableNV :: #type proc "system" (commandBuffer: CommandBuffer, firstExclusiveScissor: u32, exclusiveScissorCount: u32, pExclusiveScissorEnables: [^]b32) +ProcCmdSetExclusiveScissorNV :: #type proc "system" (commandBuffer: CommandBuffer, firstExclusiveScissor: u32, exclusiveScissorCount: u32, pExclusiveScissors: [^]Rect2D) +ProcCmdSetExtraPrimitiveOverestimationSizeEXT :: #type proc "system" (commandBuffer: CommandBuffer, extraPrimitiveOverestimationSize: f32) +ProcCmdSetFragmentShadingRateEnumNV :: #type proc "system" (commandBuffer: CommandBuffer, shadingRate: FragmentShadingRateNV) +ProcCmdSetFragmentShadingRateKHR :: #type proc "system" (commandBuffer: CommandBuffer, pFragmentSize: ^Extent2D) +ProcCmdSetFrontFace :: #type proc "system" (commandBuffer: CommandBuffer, frontFace: FrontFace) +ProcCmdSetFrontFaceEXT :: #type proc "system" (commandBuffer: CommandBuffer, frontFace: FrontFace) +ProcCmdSetLineRasterizationModeEXT :: #type proc "system" (commandBuffer: CommandBuffer, lineRasterizationMode: LineRasterizationModeEXT) +ProcCmdSetLineStippleEXT :: #type proc "system" (commandBuffer: CommandBuffer, lineStippleFactor: u32, lineStipplePattern: u16) +ProcCmdSetLineStippleEnableEXT :: #type proc "system" (commandBuffer: CommandBuffer, stippledLineEnable: b32) +ProcCmdSetLineWidth :: #type proc "system" (commandBuffer: CommandBuffer, lineWidth: f32) +ProcCmdSetLogicOpEXT :: #type proc "system" (commandBuffer: CommandBuffer, logicOp: LogicOp) +ProcCmdSetLogicOpEnableEXT :: #type proc "system" (commandBuffer: CommandBuffer, logicOpEnable: b32) +ProcCmdSetPatchControlPointsEXT :: #type proc "system" (commandBuffer: CommandBuffer, patchControlPoints: u32) +ProcCmdSetPerformanceMarkerINTEL :: #type proc "system" (commandBuffer: CommandBuffer, pMarkerInfo: ^PerformanceMarkerInfoINTEL) -> Result +ProcCmdSetPerformanceOverrideINTEL :: #type proc "system" (commandBuffer: CommandBuffer, pOverrideInfo: ^PerformanceOverrideInfoINTEL) -> Result +ProcCmdSetPerformanceStreamMarkerINTEL :: #type proc "system" (commandBuffer: CommandBuffer, pMarkerInfo: ^PerformanceStreamMarkerInfoINTEL) -> Result +ProcCmdSetPolygonModeEXT :: #type proc "system" (commandBuffer: CommandBuffer, polygonMode: PolygonMode) +ProcCmdSetPrimitiveRestartEnable :: #type proc "system" (commandBuffer: CommandBuffer, primitiveRestartEnable: b32) +ProcCmdSetPrimitiveRestartEnableEXT :: #type proc "system" (commandBuffer: CommandBuffer, primitiveRestartEnable: b32) +ProcCmdSetPrimitiveTopology :: #type proc "system" (commandBuffer: CommandBuffer, primitiveTopology: PrimitiveTopology) +ProcCmdSetPrimitiveTopologyEXT :: #type proc "system" (commandBuffer: CommandBuffer, primitiveTopology: PrimitiveTopology) +ProcCmdSetProvokingVertexModeEXT :: #type proc "system" (commandBuffer: CommandBuffer, provokingVertexMode: ProvokingVertexModeEXT) +ProcCmdSetRasterizationSamplesEXT :: #type proc "system" (commandBuffer: CommandBuffer, rasterizationSamples: SampleCountFlags) +ProcCmdSetRasterizationStreamEXT :: #type proc "system" (commandBuffer: CommandBuffer, rasterizationStream: u32) +ProcCmdSetRasterizerDiscardEnable :: #type proc "system" (commandBuffer: CommandBuffer, rasterizerDiscardEnable: b32) +ProcCmdSetRasterizerDiscardEnableEXT :: #type proc "system" (commandBuffer: CommandBuffer, rasterizerDiscardEnable: b32) +ProcCmdSetRayTracingPipelineStackSizeKHR :: #type proc "system" (commandBuffer: CommandBuffer, pipelineStackSize: u32) +ProcCmdSetRepresentativeFragmentTestEnableNV :: #type proc "system" (commandBuffer: CommandBuffer, representativeFragmentTestEnable: b32) +ProcCmdSetSampleLocationsEXT :: #type proc "system" (commandBuffer: CommandBuffer, pSampleLocationsInfo: ^SampleLocationsInfoEXT) +ProcCmdSetSampleLocationsEnableEXT :: #type proc "system" (commandBuffer: CommandBuffer, sampleLocationsEnable: b32) +ProcCmdSetSampleMaskEXT :: #type proc "system" (commandBuffer: CommandBuffer, samples: SampleCountFlags, pSampleMask: ^SampleMask) +ProcCmdSetScissor :: #type proc "system" (commandBuffer: CommandBuffer, firstScissor: u32, scissorCount: u32, pScissors: [^]Rect2D) +ProcCmdSetScissorWithCount :: #type proc "system" (commandBuffer: CommandBuffer, scissorCount: u32, pScissors: [^]Rect2D) +ProcCmdSetScissorWithCountEXT :: #type proc "system" (commandBuffer: CommandBuffer, scissorCount: u32, pScissors: [^]Rect2D) +ProcCmdSetShadingRateImageEnableNV :: #type proc "system" (commandBuffer: CommandBuffer, shadingRateImageEnable: b32) +ProcCmdSetStencilCompareMask :: #type proc "system" (commandBuffer: CommandBuffer, faceMask: StencilFaceFlags, compareMask: u32) +ProcCmdSetStencilOp :: #type proc "system" (commandBuffer: CommandBuffer, faceMask: StencilFaceFlags, failOp: StencilOp, passOp: StencilOp, depthFailOp: StencilOp, compareOp: CompareOp) +ProcCmdSetStencilOpEXT :: #type proc "system" (commandBuffer: CommandBuffer, faceMask: StencilFaceFlags, failOp: StencilOp, passOp: StencilOp, depthFailOp: StencilOp, compareOp: CompareOp) +ProcCmdSetStencilReference :: #type proc "system" (commandBuffer: CommandBuffer, faceMask: StencilFaceFlags, reference: u32) +ProcCmdSetStencilTestEnable :: #type proc "system" (commandBuffer: CommandBuffer, stencilTestEnable: b32) +ProcCmdSetStencilTestEnableEXT :: #type proc "system" (commandBuffer: CommandBuffer, stencilTestEnable: b32) +ProcCmdSetStencilWriteMask :: #type proc "system" (commandBuffer: CommandBuffer, faceMask: StencilFaceFlags, writeMask: u32) +ProcCmdSetTessellationDomainOriginEXT :: #type proc "system" (commandBuffer: CommandBuffer, domainOrigin: TessellationDomainOrigin) +ProcCmdSetVertexInputEXT :: #type proc "system" (commandBuffer: CommandBuffer, vertexBindingDescriptionCount: u32, pVertexBindingDescriptions: [^]VertexInputBindingDescription2EXT, vertexAttributeDescriptionCount: u32, pVertexAttributeDescriptions: [^]VertexInputAttributeDescription2EXT) +ProcCmdSetViewport :: #type proc "system" (commandBuffer: CommandBuffer, firstViewport: u32, viewportCount: u32, pViewports: [^]Viewport) +ProcCmdSetViewportShadingRatePaletteNV :: #type proc "system" (commandBuffer: CommandBuffer, firstViewport: u32, viewportCount: u32, pShadingRatePalettes: [^]ShadingRatePaletteNV) +ProcCmdSetViewportSwizzleNV :: #type proc "system" (commandBuffer: CommandBuffer, firstViewport: u32, viewportCount: u32, pViewportSwizzles: [^]ViewportSwizzleNV) +ProcCmdSetViewportWScalingEnableNV :: #type proc "system" (commandBuffer: CommandBuffer, viewportWScalingEnable: b32) +ProcCmdSetViewportWScalingNV :: #type proc "system" (commandBuffer: CommandBuffer, firstViewport: u32, viewportCount: u32, pViewportWScalings: [^]ViewportWScalingNV) +ProcCmdSetViewportWithCount :: #type proc "system" (commandBuffer: CommandBuffer, viewportCount: u32, pViewports: [^]Viewport) +ProcCmdSetViewportWithCountEXT :: #type proc "system" (commandBuffer: CommandBuffer, viewportCount: u32, pViewports: [^]Viewport) +ProcCmdSubpassShadingHUAWEI :: #type proc "system" (commandBuffer: CommandBuffer) +ProcCmdTraceRaysIndirect2KHR :: #type proc "system" (commandBuffer: CommandBuffer, indirectDeviceAddress: DeviceAddress) +ProcCmdTraceRaysIndirectKHR :: #type proc "system" (commandBuffer: CommandBuffer, pRaygenShaderBindingTable: [^]StridedDeviceAddressRegionKHR, pMissShaderBindingTable: [^]StridedDeviceAddressRegionKHR, pHitShaderBindingTable: [^]StridedDeviceAddressRegionKHR, pCallableShaderBindingTable: [^]StridedDeviceAddressRegionKHR, indirectDeviceAddress: DeviceAddress) +ProcCmdTraceRaysKHR :: #type proc "system" (commandBuffer: CommandBuffer, pRaygenShaderBindingTable: [^]StridedDeviceAddressRegionKHR, pMissShaderBindingTable: [^]StridedDeviceAddressRegionKHR, pHitShaderBindingTable: [^]StridedDeviceAddressRegionKHR, pCallableShaderBindingTable: [^]StridedDeviceAddressRegionKHR, width: u32, height: u32, depth: u32) +ProcCmdTraceRaysNV :: #type proc "system" (commandBuffer: CommandBuffer, raygenShaderBindingTableBuffer: Buffer, raygenShaderBindingOffset: DeviceSize, missShaderBindingTableBuffer: Buffer, missShaderBindingOffset: DeviceSize, missShaderBindingStride: DeviceSize, hitShaderBindingTableBuffer: Buffer, hitShaderBindingOffset: DeviceSize, hitShaderBindingStride: DeviceSize, callableShaderBindingTableBuffer: Buffer, callableShaderBindingOffset: DeviceSize, callableShaderBindingStride: DeviceSize, width: u32, height: u32, depth: u32) +ProcCmdUpdateBuffer :: #type proc "system" (commandBuffer: CommandBuffer, dstBuffer: Buffer, dstOffset: DeviceSize, dataSize: DeviceSize, pData: rawptr) +ProcCmdWaitEvents :: #type proc "system" (commandBuffer: CommandBuffer, eventCount: u32, pEvents: [^]Event, srcStageMask: PipelineStageFlags, dstStageMask: PipelineStageFlags, memoryBarrierCount: u32, pMemoryBarriers: [^]MemoryBarrier, bufferMemoryBarrierCount: u32, pBufferMemoryBarriers: [^]BufferMemoryBarrier, imageMemoryBarrierCount: u32, pImageMemoryBarriers: [^]ImageMemoryBarrier) +ProcCmdWaitEvents2 :: #type proc "system" (commandBuffer: CommandBuffer, eventCount: u32, pEvents: [^]Event, pDependencyInfos: [^]DependencyInfo) +ProcCmdWaitEvents2KHR :: #type proc "system" (commandBuffer: CommandBuffer, eventCount: u32, pEvents: [^]Event, pDependencyInfos: [^]DependencyInfo) +ProcCmdWriteAccelerationStructuresPropertiesKHR :: #type proc "system" (commandBuffer: CommandBuffer, accelerationStructureCount: u32, pAccelerationStructures: [^]AccelerationStructureKHR, queryType: QueryType, queryPool: QueryPool, firstQuery: u32) +ProcCmdWriteAccelerationStructuresPropertiesNV :: #type proc "system" (commandBuffer: CommandBuffer, accelerationStructureCount: u32, pAccelerationStructures: [^]AccelerationStructureNV, queryType: QueryType, queryPool: QueryPool, firstQuery: u32) +ProcCmdWriteBufferMarker2AMD :: #type proc "system" (commandBuffer: CommandBuffer, stage: PipelineStageFlags2, dstBuffer: Buffer, dstOffset: DeviceSize, marker: u32) +ProcCmdWriteBufferMarkerAMD :: #type proc "system" (commandBuffer: CommandBuffer, pipelineStage: PipelineStageFlags, dstBuffer: Buffer, dstOffset: DeviceSize, marker: u32) +ProcCmdWriteMicromapsPropertiesEXT :: #type proc "system" (commandBuffer: CommandBuffer, micromapCount: u32, pMicromaps: [^]MicromapEXT, queryType: QueryType, queryPool: QueryPool, firstQuery: u32) +ProcCmdWriteTimestamp :: #type proc "system" (commandBuffer: CommandBuffer, pipelineStage: PipelineStageFlags, queryPool: QueryPool, query: u32) +ProcCmdWriteTimestamp2 :: #type proc "system" (commandBuffer: CommandBuffer, stage: PipelineStageFlags2, queryPool: QueryPool, query: u32) +ProcCmdWriteTimestamp2KHR :: #type proc "system" (commandBuffer: CommandBuffer, stage: PipelineStageFlags2, queryPool: QueryPool, query: u32) +ProcCompileDeferredNV :: #type proc "system" (device: Device, pipeline: Pipeline, shader: u32) -> Result +ProcCopyAccelerationStructureKHR :: #type proc "system" (device: Device, deferredOperation: DeferredOperationKHR, pInfo: ^CopyAccelerationStructureInfoKHR) -> Result +ProcCopyAccelerationStructureToMemoryKHR :: #type proc "system" (device: Device, deferredOperation: DeferredOperationKHR, pInfo: ^CopyAccelerationStructureToMemoryInfoKHR) -> Result +ProcCopyMemoryToAccelerationStructureKHR :: #type proc "system" (device: Device, deferredOperation: DeferredOperationKHR, pInfo: ^CopyMemoryToAccelerationStructureInfoKHR) -> Result +ProcCopyMemoryToMicromapEXT :: #type proc "system" (device: Device, deferredOperation: DeferredOperationKHR, pInfo: ^CopyMemoryToMicromapInfoEXT) -> Result +ProcCopyMicromapEXT :: #type proc "system" (device: Device, deferredOperation: DeferredOperationKHR, pInfo: ^CopyMicromapInfoEXT) -> Result +ProcCopyMicromapToMemoryEXT :: #type proc "system" (device: Device, deferredOperation: DeferredOperationKHR, pInfo: ^CopyMicromapToMemoryInfoEXT) -> Result +ProcCreateAccelerationStructureKHR :: #type proc "system" (device: Device, pCreateInfo: ^AccelerationStructureCreateInfoKHR, pAllocator: ^AllocationCallbacks, pAccelerationStructure: ^AccelerationStructureKHR) -> Result +ProcCreateAccelerationStructureNV :: #type proc "system" (device: Device, pCreateInfo: ^AccelerationStructureCreateInfoNV, pAllocator: ^AllocationCallbacks, pAccelerationStructure: ^AccelerationStructureNV) -> Result +ProcCreateBuffer :: #type proc "system" (device: Device, pCreateInfo: ^BufferCreateInfo, pAllocator: ^AllocationCallbacks, pBuffer: ^Buffer) -> Result +ProcCreateBufferView :: #type proc "system" (device: Device, pCreateInfo: ^BufferViewCreateInfo, pAllocator: ^AllocationCallbacks, pView: ^BufferView) -> Result +ProcCreateCommandPool :: #type proc "system" (device: Device, pCreateInfo: ^CommandPoolCreateInfo, pAllocator: ^AllocationCallbacks, pCommandPool: ^CommandPool) -> Result +ProcCreateComputePipelines :: #type proc "system" (device: Device, pipelineCache: PipelineCache, createInfoCount: u32, pCreateInfos: [^]ComputePipelineCreateInfo, pAllocator: ^AllocationCallbacks, pPipelines: [^]Pipeline) -> Result +ProcCreateCuFunctionNVX :: #type proc "system" (device: Device, pCreateInfo: ^CuFunctionCreateInfoNVX, pAllocator: ^AllocationCallbacks, pFunction: ^CuFunctionNVX) -> Result +ProcCreateCuModuleNVX :: #type proc "system" (device: Device, pCreateInfo: ^CuModuleCreateInfoNVX, pAllocator: ^AllocationCallbacks, pModule: ^CuModuleNVX) -> Result +ProcCreateDeferredOperationKHR :: #type proc "system" (device: Device, pAllocator: ^AllocationCallbacks, pDeferredOperation: ^DeferredOperationKHR) -> Result +ProcCreateDescriptorPool :: #type proc "system" (device: Device, pCreateInfo: ^DescriptorPoolCreateInfo, pAllocator: ^AllocationCallbacks, pDescriptorPool: ^DescriptorPool) -> Result +ProcCreateDescriptorSetLayout :: #type proc "system" (device: Device, pCreateInfo: ^DescriptorSetLayoutCreateInfo, pAllocator: ^AllocationCallbacks, pSetLayout: ^DescriptorSetLayout) -> Result +ProcCreateDescriptorUpdateTemplate :: #type proc "system" (device: Device, pCreateInfo: ^DescriptorUpdateTemplateCreateInfo, pAllocator: ^AllocationCallbacks, pDescriptorUpdateTemplate: ^DescriptorUpdateTemplate) -> Result +ProcCreateDescriptorUpdateTemplateKHR :: #type proc "system" (device: Device, pCreateInfo: ^DescriptorUpdateTemplateCreateInfo, pAllocator: ^AllocationCallbacks, pDescriptorUpdateTemplate: ^DescriptorUpdateTemplate) -> Result +ProcCreateEvent :: #type proc "system" (device: Device, pCreateInfo: ^EventCreateInfo, pAllocator: ^AllocationCallbacks, pEvent: ^Event) -> Result +ProcCreateFence :: #type proc "system" (device: Device, pCreateInfo: ^FenceCreateInfo, pAllocator: ^AllocationCallbacks, pFence: ^Fence) -> Result +ProcCreateFramebuffer :: #type proc "system" (device: Device, pCreateInfo: ^FramebufferCreateInfo, pAllocator: ^AllocationCallbacks, pFramebuffer: ^Framebuffer) -> Result +ProcCreateGraphicsPipelines :: #type proc "system" (device: Device, pipelineCache: PipelineCache, createInfoCount: u32, pCreateInfos: [^]GraphicsPipelineCreateInfo, pAllocator: ^AllocationCallbacks, pPipelines: [^]Pipeline) -> Result +ProcCreateImage :: #type proc "system" (device: Device, pCreateInfo: ^ImageCreateInfo, pAllocator: ^AllocationCallbacks, pImage: ^Image) -> Result +ProcCreateImageView :: #type proc "system" (device: Device, pCreateInfo: ^ImageViewCreateInfo, pAllocator: ^AllocationCallbacks, pView: ^ImageView) -> Result +ProcCreateIndirectCommandsLayoutNV :: #type proc "system" (device: Device, pCreateInfo: ^IndirectCommandsLayoutCreateInfoNV, pAllocator: ^AllocationCallbacks, pIndirectCommandsLayout: ^IndirectCommandsLayoutNV) -> Result +ProcCreateMicromapEXT :: #type proc "system" (device: Device, pCreateInfo: ^MicromapCreateInfoEXT, pAllocator: ^AllocationCallbacks, pMicromap: ^MicromapEXT) -> Result +ProcCreateOpticalFlowSessionNV :: #type proc "system" (device: Device, pCreateInfo: ^OpticalFlowSessionCreateInfoNV, pAllocator: ^AllocationCallbacks, pSession: ^OpticalFlowSessionNV) -> Result +ProcCreatePipelineCache :: #type proc "system" (device: Device, pCreateInfo: ^PipelineCacheCreateInfo, pAllocator: ^AllocationCallbacks, pPipelineCache: ^PipelineCache) -> Result +ProcCreatePipelineLayout :: #type proc "system" (device: Device, pCreateInfo: ^PipelineLayoutCreateInfo, pAllocator: ^AllocationCallbacks, pPipelineLayout: ^PipelineLayout) -> Result +ProcCreatePrivateDataSlot :: #type proc "system" (device: Device, pCreateInfo: ^PrivateDataSlotCreateInfo, pAllocator: ^AllocationCallbacks, pPrivateDataSlot: ^PrivateDataSlot) -> Result +ProcCreatePrivateDataSlotEXT :: #type proc "system" (device: Device, pCreateInfo: ^PrivateDataSlotCreateInfo, pAllocator: ^AllocationCallbacks, pPrivateDataSlot: ^PrivateDataSlot) -> Result +ProcCreateQueryPool :: #type proc "system" (device: Device, pCreateInfo: ^QueryPoolCreateInfo, pAllocator: ^AllocationCallbacks, pQueryPool: ^QueryPool) -> Result +ProcCreateRayTracingPipelinesKHR :: #type proc "system" (device: Device, deferredOperation: DeferredOperationKHR, pipelineCache: PipelineCache, createInfoCount: u32, pCreateInfos: [^]RayTracingPipelineCreateInfoKHR, pAllocator: ^AllocationCallbacks, pPipelines: [^]Pipeline) -> Result +ProcCreateRayTracingPipelinesNV :: #type proc "system" (device: Device, pipelineCache: PipelineCache, createInfoCount: u32, pCreateInfos: [^]RayTracingPipelineCreateInfoNV, pAllocator: ^AllocationCallbacks, pPipelines: [^]Pipeline) -> Result +ProcCreateRenderPass :: #type proc "system" (device: Device, pCreateInfo: ^RenderPassCreateInfo, pAllocator: ^AllocationCallbacks, pRenderPass: [^]RenderPass) -> Result +ProcCreateRenderPass2 :: #type proc "system" (device: Device, pCreateInfo: ^RenderPassCreateInfo2, pAllocator: ^AllocationCallbacks, pRenderPass: [^]RenderPass) -> Result +ProcCreateRenderPass2KHR :: #type proc "system" (device: Device, pCreateInfo: ^RenderPassCreateInfo2, pAllocator: ^AllocationCallbacks, pRenderPass: [^]RenderPass) -> Result +ProcCreateSampler :: #type proc "system" (device: Device, pCreateInfo: ^SamplerCreateInfo, pAllocator: ^AllocationCallbacks, pSampler: ^Sampler) -> Result +ProcCreateSamplerYcbcrConversion :: #type proc "system" (device: Device, pCreateInfo: ^SamplerYcbcrConversionCreateInfo, pAllocator: ^AllocationCallbacks, pYcbcrConversion: ^SamplerYcbcrConversion) -> Result +ProcCreateSamplerYcbcrConversionKHR :: #type proc "system" (device: Device, pCreateInfo: ^SamplerYcbcrConversionCreateInfo, pAllocator: ^AllocationCallbacks, pYcbcrConversion: ^SamplerYcbcrConversion) -> Result +ProcCreateSemaphore :: #type proc "system" (device: Device, pCreateInfo: ^SemaphoreCreateInfo, pAllocator: ^AllocationCallbacks, pSemaphore: ^Semaphore) -> Result +ProcCreateShaderModule :: #type proc "system" (device: Device, pCreateInfo: ^ShaderModuleCreateInfo, pAllocator: ^AllocationCallbacks, pShaderModule: ^ShaderModule) -> Result +ProcCreateShadersEXT :: #type proc "system" (device: Device, createInfoCount: u32, pCreateInfos: [^]ShaderCreateInfoEXT, pAllocator: ^AllocationCallbacks, pShaders: [^]ShaderEXT) -> Result +ProcCreateSharedSwapchainsKHR :: #type proc "system" (device: Device, swapchainCount: u32, pCreateInfos: [^]SwapchainCreateInfoKHR, pAllocator: ^AllocationCallbacks, pSwapchains: [^]SwapchainKHR) -> Result +ProcCreateSwapchainKHR :: #type proc "system" (device: Device, pCreateInfo: ^SwapchainCreateInfoKHR, pAllocator: ^AllocationCallbacks, pSwapchain: ^SwapchainKHR) -> Result +ProcCreateValidationCacheEXT :: #type proc "system" (device: Device, pCreateInfo: ^ValidationCacheCreateInfoEXT, pAllocator: ^AllocationCallbacks, pValidationCache: ^ValidationCacheEXT) -> Result +ProcCreateVideoSessionKHR :: #type proc "system" (device: Device, pCreateInfo: ^VideoSessionCreateInfoKHR, pAllocator: ^AllocationCallbacks, pVideoSession: ^VideoSessionKHR) -> Result +ProcCreateVideoSessionParametersKHR :: #type proc "system" (device: Device, pCreateInfo: ^VideoSessionParametersCreateInfoKHR, pAllocator: ^AllocationCallbacks, pVideoSessionParameters: [^]VideoSessionParametersKHR) -> Result +ProcDebugMarkerSetObjectNameEXT :: #type proc "system" (device: Device, pNameInfo: ^DebugMarkerObjectNameInfoEXT) -> Result +ProcDebugMarkerSetObjectTagEXT :: #type proc "system" (device: Device, pTagInfo: ^DebugMarkerObjectTagInfoEXT) -> Result +ProcDeferredOperationJoinKHR :: #type proc "system" (device: Device, operation: DeferredOperationKHR) -> Result +ProcDestroyAccelerationStructureKHR :: #type proc "system" (device: Device, accelerationStructure: AccelerationStructureKHR, pAllocator: ^AllocationCallbacks) +ProcDestroyAccelerationStructureNV :: #type proc "system" (device: Device, accelerationStructure: AccelerationStructureNV, pAllocator: ^AllocationCallbacks) +ProcDestroyBuffer :: #type proc "system" (device: Device, buffer: Buffer, pAllocator: ^AllocationCallbacks) +ProcDestroyBufferView :: #type proc "system" (device: Device, bufferView: BufferView, pAllocator: ^AllocationCallbacks) +ProcDestroyCommandPool :: #type proc "system" (device: Device, commandPool: CommandPool, pAllocator: ^AllocationCallbacks) +ProcDestroyCuFunctionNVX :: #type proc "system" (device: Device, function: CuFunctionNVX, pAllocator: ^AllocationCallbacks) +ProcDestroyCuModuleNVX :: #type proc "system" (device: Device, module: CuModuleNVX, pAllocator: ^AllocationCallbacks) +ProcDestroyDeferredOperationKHR :: #type proc "system" (device: Device, operation: DeferredOperationKHR, pAllocator: ^AllocationCallbacks) +ProcDestroyDescriptorPool :: #type proc "system" (device: Device, descriptorPool: DescriptorPool, pAllocator: ^AllocationCallbacks) +ProcDestroyDescriptorSetLayout :: #type proc "system" (device: Device, descriptorSetLayout: DescriptorSetLayout, pAllocator: ^AllocationCallbacks) +ProcDestroyDescriptorUpdateTemplate :: #type proc "system" (device: Device, descriptorUpdateTemplate: DescriptorUpdateTemplate, pAllocator: ^AllocationCallbacks) +ProcDestroyDescriptorUpdateTemplateKHR :: #type proc "system" (device: Device, descriptorUpdateTemplate: DescriptorUpdateTemplate, pAllocator: ^AllocationCallbacks) +ProcDestroyDevice :: #type proc "system" (device: Device, pAllocator: ^AllocationCallbacks) +ProcDestroyEvent :: #type proc "system" (device: Device, event: Event, pAllocator: ^AllocationCallbacks) +ProcDestroyFence :: #type proc "system" (device: Device, fence: Fence, pAllocator: ^AllocationCallbacks) +ProcDestroyFramebuffer :: #type proc "system" (device: Device, framebuffer: Framebuffer, pAllocator: ^AllocationCallbacks) +ProcDestroyImage :: #type proc "system" (device: Device, image: Image, pAllocator: ^AllocationCallbacks) +ProcDestroyImageView :: #type proc "system" (device: Device, imageView: ImageView, pAllocator: ^AllocationCallbacks) +ProcDestroyIndirectCommandsLayoutNV :: #type proc "system" (device: Device, indirectCommandsLayout: IndirectCommandsLayoutNV, pAllocator: ^AllocationCallbacks) +ProcDestroyMicromapEXT :: #type proc "system" (device: Device, micromap: MicromapEXT, pAllocator: ^AllocationCallbacks) +ProcDestroyOpticalFlowSessionNV :: #type proc "system" (device: Device, session: OpticalFlowSessionNV, pAllocator: ^AllocationCallbacks) +ProcDestroyPipeline :: #type proc "system" (device: Device, pipeline: Pipeline, pAllocator: ^AllocationCallbacks) +ProcDestroyPipelineCache :: #type proc "system" (device: Device, pipelineCache: PipelineCache, pAllocator: ^AllocationCallbacks) +ProcDestroyPipelineLayout :: #type proc "system" (device: Device, pipelineLayout: PipelineLayout, pAllocator: ^AllocationCallbacks) +ProcDestroyPrivateDataSlot :: #type proc "system" (device: Device, privateDataSlot: PrivateDataSlot, pAllocator: ^AllocationCallbacks) +ProcDestroyPrivateDataSlotEXT :: #type proc "system" (device: Device, privateDataSlot: PrivateDataSlot, pAllocator: ^AllocationCallbacks) +ProcDestroyQueryPool :: #type proc "system" (device: Device, queryPool: QueryPool, pAllocator: ^AllocationCallbacks) +ProcDestroyRenderPass :: #type proc "system" (device: Device, renderPass: RenderPass, pAllocator: ^AllocationCallbacks) +ProcDestroySampler :: #type proc "system" (device: Device, sampler: Sampler, pAllocator: ^AllocationCallbacks) +ProcDestroySamplerYcbcrConversion :: #type proc "system" (device: Device, ycbcrConversion: SamplerYcbcrConversion, pAllocator: ^AllocationCallbacks) +ProcDestroySamplerYcbcrConversionKHR :: #type proc "system" (device: Device, ycbcrConversion: SamplerYcbcrConversion, pAllocator: ^AllocationCallbacks) +ProcDestroySemaphore :: #type proc "system" (device: Device, semaphore: Semaphore, pAllocator: ^AllocationCallbacks) +ProcDestroyShaderEXT :: #type proc "system" (device: Device, shader: ShaderEXT, pAllocator: ^AllocationCallbacks) +ProcDestroyShaderModule :: #type proc "system" (device: Device, shaderModule: ShaderModule, pAllocator: ^AllocationCallbacks) +ProcDestroySwapchainKHR :: #type proc "system" (device: Device, swapchain: SwapchainKHR, pAllocator: ^AllocationCallbacks) +ProcDestroyValidationCacheEXT :: #type proc "system" (device: Device, validationCache: ValidationCacheEXT, pAllocator: ^AllocationCallbacks) +ProcDestroyVideoSessionKHR :: #type proc "system" (device: Device, videoSession: VideoSessionKHR, pAllocator: ^AllocationCallbacks) +ProcDestroyVideoSessionParametersKHR :: #type proc "system" (device: Device, videoSessionParameters: VideoSessionParametersKHR, pAllocator: ^AllocationCallbacks) +ProcDeviceWaitIdle :: #type proc "system" (device: Device) -> Result +ProcDisplayPowerControlEXT :: #type proc "system" (device: Device, display: DisplayKHR, pDisplayPowerInfo: ^DisplayPowerInfoEXT) -> Result +ProcEndCommandBuffer :: #type proc "system" (commandBuffer: CommandBuffer) -> Result +ProcExportMetalObjectsEXT :: #type proc "system" (device: Device, pMetalObjectsInfo: ^ExportMetalObjectsInfoEXT) +ProcFlushMappedMemoryRanges :: #type proc "system" (device: Device, memoryRangeCount: u32, pMemoryRanges: [^]MappedMemoryRange) -> Result +ProcFreeCommandBuffers :: #type proc "system" (device: Device, commandPool: CommandPool, commandBufferCount: u32, pCommandBuffers: [^]CommandBuffer) +ProcFreeDescriptorSets :: #type proc "system" (device: Device, descriptorPool: DescriptorPool, descriptorSetCount: u32, pDescriptorSets: [^]DescriptorSet) -> Result +ProcFreeMemory :: #type proc "system" (device: Device, memory: DeviceMemory, pAllocator: ^AllocationCallbacks) +ProcGetAccelerationStructureBuildSizesKHR :: #type proc "system" (device: Device, buildType: AccelerationStructureBuildTypeKHR, pBuildInfo: ^AccelerationStructureBuildGeometryInfoKHR, pMaxPrimitiveCounts: [^]u32, pSizeInfo: ^AccelerationStructureBuildSizesInfoKHR) +ProcGetAccelerationStructureDeviceAddressKHR :: #type proc "system" (device: Device, pInfo: ^AccelerationStructureDeviceAddressInfoKHR) -> DeviceAddress +ProcGetAccelerationStructureHandleNV :: #type proc "system" (device: Device, accelerationStructure: AccelerationStructureNV, dataSize: int, pData: rawptr) -> Result +ProcGetAccelerationStructureMemoryRequirementsNV :: #type proc "system" (device: Device, pInfo: ^AccelerationStructureMemoryRequirementsInfoNV, pMemoryRequirements: [^]MemoryRequirements2KHR) +ProcGetAccelerationStructureOpaqueCaptureDescriptorDataEXT :: #type proc "system" (device: Device, pInfo: ^AccelerationStructureCaptureDescriptorDataInfoEXT, pData: rawptr) -> Result +ProcGetBufferDeviceAddress :: #type proc "system" (device: Device, pInfo: ^BufferDeviceAddressInfo) -> DeviceAddress +ProcGetBufferDeviceAddressEXT :: #type proc "system" (device: Device, pInfo: ^BufferDeviceAddressInfo) -> DeviceAddress +ProcGetBufferDeviceAddressKHR :: #type proc "system" (device: Device, pInfo: ^BufferDeviceAddressInfo) -> DeviceAddress +ProcGetBufferMemoryRequirements :: #type proc "system" (device: Device, buffer: Buffer, pMemoryRequirements: [^]MemoryRequirements) +ProcGetBufferMemoryRequirements2 :: #type proc "system" (device: Device, pInfo: ^BufferMemoryRequirementsInfo2, pMemoryRequirements: [^]MemoryRequirements2) +ProcGetBufferMemoryRequirements2KHR :: #type proc "system" (device: Device, pInfo: ^BufferMemoryRequirementsInfo2, pMemoryRequirements: [^]MemoryRequirements2) +ProcGetBufferOpaqueCaptureAddress :: #type proc "system" (device: Device, pInfo: ^BufferDeviceAddressInfo) -> u64 +ProcGetBufferOpaqueCaptureAddressKHR :: #type proc "system" (device: Device, pInfo: ^BufferDeviceAddressInfo) -> u64 +ProcGetBufferOpaqueCaptureDescriptorDataEXT :: #type proc "system" (device: Device, pInfo: ^BufferCaptureDescriptorDataInfoEXT, pData: rawptr) -> Result +ProcGetCalibratedTimestampsEXT :: #type proc "system" (device: Device, timestampCount: u32, pTimestampInfos: [^]CalibratedTimestampInfoEXT, pTimestamps: [^]u64, pMaxDeviation: ^u64) -> Result +ProcGetDeferredOperationMaxConcurrencyKHR :: #type proc "system" (device: Device, operation: DeferredOperationKHR) -> u32 +ProcGetDeferredOperationResultKHR :: #type proc "system" (device: Device, operation: DeferredOperationKHR) -> Result +ProcGetDescriptorEXT :: #type proc "system" (device: Device, pDescriptorInfo: ^DescriptorGetInfoEXT, dataSize: int, pDescriptor: rawptr) +ProcGetDescriptorSetHostMappingVALVE :: #type proc "system" (device: Device, descriptorSet: DescriptorSet, ppData: ^rawptr) +ProcGetDescriptorSetLayoutBindingOffsetEXT :: #type proc "system" (device: Device, layout: DescriptorSetLayout, binding: u32, pOffset: ^DeviceSize) +ProcGetDescriptorSetLayoutHostMappingInfoVALVE :: #type proc "system" (device: Device, pBindingReference: ^DescriptorSetBindingReferenceVALVE, pHostMapping: ^DescriptorSetLayoutHostMappingInfoVALVE) +ProcGetDescriptorSetLayoutSizeEXT :: #type proc "system" (device: Device, layout: DescriptorSetLayout, pLayoutSizeInBytes: [^]DeviceSize) +ProcGetDescriptorSetLayoutSupport :: #type proc "system" (device: Device, pCreateInfo: ^DescriptorSetLayoutCreateInfo, pSupport: ^DescriptorSetLayoutSupport) +ProcGetDescriptorSetLayoutSupportKHR :: #type proc "system" (device: Device, pCreateInfo: ^DescriptorSetLayoutCreateInfo, pSupport: ^DescriptorSetLayoutSupport) +ProcGetDeviceAccelerationStructureCompatibilityKHR :: #type proc "system" (device: Device, pVersionInfo: ^AccelerationStructureVersionInfoKHR, pCompatibility: ^AccelerationStructureCompatibilityKHR) +ProcGetDeviceBufferMemoryRequirements :: #type proc "system" (device: Device, pInfo: ^DeviceBufferMemoryRequirements, pMemoryRequirements: [^]MemoryRequirements2) +ProcGetDeviceBufferMemoryRequirementsKHR :: #type proc "system" (device: Device, pInfo: ^DeviceBufferMemoryRequirements, pMemoryRequirements: [^]MemoryRequirements2) +ProcGetDeviceFaultInfoEXT :: #type proc "system" (device: Device, pFaultCounts: [^]DeviceFaultCountsEXT, pFaultInfo: ^DeviceFaultInfoEXT) -> Result +ProcGetDeviceGroupPeerMemoryFeatures :: #type proc "system" (device: Device, heapIndex: u32, localDeviceIndex: u32, remoteDeviceIndex: u32, pPeerMemoryFeatures: [^]PeerMemoryFeatureFlags) +ProcGetDeviceGroupPeerMemoryFeaturesKHR :: #type proc "system" (device: Device, heapIndex: u32, localDeviceIndex: u32, remoteDeviceIndex: u32, pPeerMemoryFeatures: [^]PeerMemoryFeatureFlags) +ProcGetDeviceGroupPresentCapabilitiesKHR :: #type proc "system" (device: Device, pDeviceGroupPresentCapabilities: [^]DeviceGroupPresentCapabilitiesKHR) -> Result +ProcGetDeviceGroupSurfacePresentModes2EXT :: #type proc "system" (device: Device, pSurfaceInfo: ^PhysicalDeviceSurfaceInfo2KHR, pModes: [^]DeviceGroupPresentModeFlagsKHR) -> Result +ProcGetDeviceGroupSurfacePresentModesKHR :: #type proc "system" (device: Device, surface: SurfaceKHR, pModes: [^]DeviceGroupPresentModeFlagsKHR) -> Result +ProcGetDeviceImageMemoryRequirements :: #type proc "system" (device: Device, pInfo: ^DeviceImageMemoryRequirements, pMemoryRequirements: [^]MemoryRequirements2) +ProcGetDeviceImageMemoryRequirementsKHR :: #type proc "system" (device: Device, pInfo: ^DeviceImageMemoryRequirements, pMemoryRequirements: [^]MemoryRequirements2) +ProcGetDeviceImageSparseMemoryRequirements :: #type proc "system" (device: Device, pInfo: ^DeviceImageMemoryRequirements, pSparseMemoryRequirementCount: ^u32, pSparseMemoryRequirements: [^]SparseImageMemoryRequirements2) +ProcGetDeviceImageSparseMemoryRequirementsKHR :: #type proc "system" (device: Device, pInfo: ^DeviceImageMemoryRequirements, pSparseMemoryRequirementCount: ^u32, pSparseMemoryRequirements: [^]SparseImageMemoryRequirements2) +ProcGetDeviceMemoryCommitment :: #type proc "system" (device: Device, memory: DeviceMemory, pCommittedMemoryInBytes: [^]DeviceSize) +ProcGetDeviceMemoryOpaqueCaptureAddress :: #type proc "system" (device: Device, pInfo: ^DeviceMemoryOpaqueCaptureAddressInfo) -> u64 +ProcGetDeviceMemoryOpaqueCaptureAddressKHR :: #type proc "system" (device: Device, pInfo: ^DeviceMemoryOpaqueCaptureAddressInfo) -> u64 +ProcGetDeviceMicromapCompatibilityEXT :: #type proc "system" (device: Device, pVersionInfo: ^MicromapVersionInfoEXT, pCompatibility: ^AccelerationStructureCompatibilityKHR) +ProcGetDeviceProcAddr :: #type proc "system" (device: Device, pName: cstring) -> ProcVoidFunction +ProcGetDeviceQueue :: #type proc "system" (device: Device, queueFamilyIndex: u32, queueIndex: u32, pQueue: ^Queue) +ProcGetDeviceQueue2 :: #type proc "system" (device: Device, pQueueInfo: ^DeviceQueueInfo2, pQueue: ^Queue) +ProcGetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI :: #type proc "system" (device: Device, renderpass: RenderPass, pMaxWorkgroupSize: ^Extent2D) -> Result +ProcGetDynamicRenderingTilePropertiesQCOM :: #type proc "system" (device: Device, pRenderingInfo: ^RenderingInfo, pProperties: [^]TilePropertiesQCOM) -> Result +ProcGetEventStatus :: #type proc "system" (device: Device, event: Event) -> Result +ProcGetFenceFdKHR :: #type proc "system" (device: Device, pGetFdInfo: ^FenceGetFdInfoKHR, pFd: ^c.int) -> Result +ProcGetFenceStatus :: #type proc "system" (device: Device, fence: Fence) -> Result +ProcGetFenceWin32HandleKHR :: #type proc "system" (device: Device, pGetWin32HandleInfo: ^FenceGetWin32HandleInfoKHR, pHandle: ^HANDLE) -> Result +ProcGetFramebufferTilePropertiesQCOM :: #type proc "system" (device: Device, framebuffer: Framebuffer, pPropertiesCount: ^u32, pProperties: [^]TilePropertiesQCOM) -> Result +ProcGetGeneratedCommandsMemoryRequirementsNV :: #type proc "system" (device: Device, pInfo: ^GeneratedCommandsMemoryRequirementsInfoNV, pMemoryRequirements: [^]MemoryRequirements2) +ProcGetImageDrmFormatModifierPropertiesEXT :: #type proc "system" (device: Device, image: Image, pProperties: [^]ImageDrmFormatModifierPropertiesEXT) -> Result +ProcGetImageMemoryRequirements :: #type proc "system" (device: Device, image: Image, pMemoryRequirements: [^]MemoryRequirements) +ProcGetImageMemoryRequirements2 :: #type proc "system" (device: Device, pInfo: ^ImageMemoryRequirementsInfo2, pMemoryRequirements: [^]MemoryRequirements2) +ProcGetImageMemoryRequirements2KHR :: #type proc "system" (device: Device, pInfo: ^ImageMemoryRequirementsInfo2, pMemoryRequirements: [^]MemoryRequirements2) +ProcGetImageOpaqueCaptureDescriptorDataEXT :: #type proc "system" (device: Device, pInfo: ^ImageCaptureDescriptorDataInfoEXT, pData: rawptr) -> Result +ProcGetImageSparseMemoryRequirements :: #type proc "system" (device: Device, image: Image, pSparseMemoryRequirementCount: ^u32, pSparseMemoryRequirements: [^]SparseImageMemoryRequirements) +ProcGetImageSparseMemoryRequirements2 :: #type proc "system" (device: Device, pInfo: ^ImageSparseMemoryRequirementsInfo2, pSparseMemoryRequirementCount: ^u32, pSparseMemoryRequirements: [^]SparseImageMemoryRequirements2) +ProcGetImageSparseMemoryRequirements2KHR :: #type proc "system" (device: Device, pInfo: ^ImageSparseMemoryRequirementsInfo2, pSparseMemoryRequirementCount: ^u32, pSparseMemoryRequirements: [^]SparseImageMemoryRequirements2) +ProcGetImageSubresourceLayout :: #type proc "system" (device: Device, image: Image, pSubresource: ^ImageSubresource, pLayout: ^SubresourceLayout) +ProcGetImageSubresourceLayout2EXT :: #type proc "system" (device: Device, image: Image, pSubresource: ^ImageSubresource2EXT, pLayout: ^SubresourceLayout2EXT) +ProcGetImageViewAddressNVX :: #type proc "system" (device: Device, imageView: ImageView, pProperties: [^]ImageViewAddressPropertiesNVX) -> Result +ProcGetImageViewHandleNVX :: #type proc "system" (device: Device, pInfo: ^ImageViewHandleInfoNVX) -> u32 +ProcGetImageViewOpaqueCaptureDescriptorDataEXT :: #type proc "system" (device: Device, pInfo: ^ImageViewCaptureDescriptorDataInfoEXT, pData: rawptr) -> Result +ProcGetMemoryFdKHR :: #type proc "system" (device: Device, pGetFdInfo: ^MemoryGetFdInfoKHR, pFd: ^c.int) -> Result +ProcGetMemoryFdPropertiesKHR :: #type proc "system" (device: Device, handleType: ExternalMemoryHandleTypeFlags, fd: c.int, pMemoryFdProperties: [^]MemoryFdPropertiesKHR) -> Result +ProcGetMemoryHostPointerPropertiesEXT :: #type proc "system" (device: Device, handleType: ExternalMemoryHandleTypeFlags, pHostPointer: rawptr, pMemoryHostPointerProperties: [^]MemoryHostPointerPropertiesEXT) -> Result +ProcGetMemoryRemoteAddressNV :: #type proc "system" (device: Device, pMemoryGetRemoteAddressInfo: ^MemoryGetRemoteAddressInfoNV, pAddress: [^]RemoteAddressNV) -> Result +ProcGetMemoryWin32HandleKHR :: #type proc "system" (device: Device, pGetWin32HandleInfo: ^MemoryGetWin32HandleInfoKHR, pHandle: ^HANDLE) -> Result +ProcGetMemoryWin32HandleNV :: #type proc "system" (device: Device, memory: DeviceMemory, handleType: ExternalMemoryHandleTypeFlagsNV, pHandle: ^HANDLE) -> Result +ProcGetMemoryWin32HandlePropertiesKHR :: #type proc "system" (device: Device, handleType: ExternalMemoryHandleTypeFlags, handle: HANDLE, pMemoryWin32HandleProperties: [^]MemoryWin32HandlePropertiesKHR) -> Result +ProcGetMicromapBuildSizesEXT :: #type proc "system" (device: Device, buildType: AccelerationStructureBuildTypeKHR, pBuildInfo: ^MicromapBuildInfoEXT, pSizeInfo: ^MicromapBuildSizesInfoEXT) +ProcGetPastPresentationTimingGOOGLE :: #type proc "system" (device: Device, swapchain: SwapchainKHR, pPresentationTimingCount: ^u32, pPresentationTimings: [^]PastPresentationTimingGOOGLE) -> Result +ProcGetPerformanceParameterINTEL :: #type proc "system" (device: Device, parameter: PerformanceParameterTypeINTEL, pValue: ^PerformanceValueINTEL) -> Result +ProcGetPipelineCacheData :: #type proc "system" (device: Device, pipelineCache: PipelineCache, pDataSize: ^int, pData: rawptr) -> Result +ProcGetPipelineExecutableInternalRepresentationsKHR :: #type proc "system" (device: Device, pExecutableInfo: ^PipelineExecutableInfoKHR, pInternalRepresentationCount: ^u32, pInternalRepresentations: [^]PipelineExecutableInternalRepresentationKHR) -> Result +ProcGetPipelineExecutablePropertiesKHR :: #type proc "system" (device: Device, pPipelineInfo: ^PipelineInfoKHR, pExecutableCount: ^u32, pProperties: [^]PipelineExecutablePropertiesKHR) -> Result +ProcGetPipelineExecutableStatisticsKHR :: #type proc "system" (device: Device, pExecutableInfo: ^PipelineExecutableInfoKHR, pStatisticCount: ^u32, pStatistics: [^]PipelineExecutableStatisticKHR) -> Result +ProcGetPipelinePropertiesEXT :: #type proc "system" (device: Device, pPipelineInfo: ^PipelineInfoEXT, pPipelineProperties: [^]BaseOutStructure) -> Result +ProcGetPrivateData :: #type proc "system" (device: Device, objectType: ObjectType, objectHandle: u64, privateDataSlot: PrivateDataSlot, pData: ^u64) +ProcGetPrivateDataEXT :: #type proc "system" (device: Device, objectType: ObjectType, objectHandle: u64, privateDataSlot: PrivateDataSlot, pData: ^u64) +ProcGetQueryPoolResults :: #type proc "system" (device: Device, queryPool: QueryPool, firstQuery: u32, queryCount: u32, dataSize: int, pData: rawptr, stride: DeviceSize, flags: QueryResultFlags) -> Result +ProcGetQueueCheckpointData2NV :: #type proc "system" (queue: Queue, pCheckpointDataCount: ^u32, pCheckpointData: ^CheckpointData2NV) +ProcGetQueueCheckpointDataNV :: #type proc "system" (queue: Queue, pCheckpointDataCount: ^u32, pCheckpointData: ^CheckpointDataNV) +ProcGetRayTracingCaptureReplayShaderGroupHandlesKHR :: #type proc "system" (device: Device, pipeline: Pipeline, firstGroup: u32, groupCount: u32, dataSize: int, pData: rawptr) -> Result +ProcGetRayTracingShaderGroupHandlesKHR :: #type proc "system" (device: Device, pipeline: Pipeline, firstGroup: u32, groupCount: u32, dataSize: int, pData: rawptr) -> Result +ProcGetRayTracingShaderGroupHandlesNV :: #type proc "system" (device: Device, pipeline: Pipeline, firstGroup: u32, groupCount: u32, dataSize: int, pData: rawptr) -> Result +ProcGetRayTracingShaderGroupStackSizeKHR :: #type proc "system" (device: Device, pipeline: Pipeline, group: u32, groupShader: ShaderGroupShaderKHR) -> DeviceSize +ProcGetRefreshCycleDurationGOOGLE :: #type proc "system" (device: Device, swapchain: SwapchainKHR, pDisplayTimingProperties: [^]RefreshCycleDurationGOOGLE) -> Result +ProcGetRenderAreaGranularity :: #type proc "system" (device: Device, renderPass: RenderPass, pGranularity: ^Extent2D) +ProcGetSamplerOpaqueCaptureDescriptorDataEXT :: #type proc "system" (device: Device, pInfo: ^SamplerCaptureDescriptorDataInfoEXT, pData: rawptr) -> Result +ProcGetSemaphoreCounterValue :: #type proc "system" (device: Device, semaphore: Semaphore, pValue: ^u64) -> Result +ProcGetSemaphoreCounterValueKHR :: #type proc "system" (device: Device, semaphore: Semaphore, pValue: ^u64) -> Result +ProcGetSemaphoreFdKHR :: #type proc "system" (device: Device, pGetFdInfo: ^SemaphoreGetFdInfoKHR, pFd: ^c.int) -> Result +ProcGetSemaphoreWin32HandleKHR :: #type proc "system" (device: Device, pGetWin32HandleInfo: ^SemaphoreGetWin32HandleInfoKHR, pHandle: ^HANDLE) -> Result +ProcGetShaderBinaryDataEXT :: #type proc "system" (device: Device, shader: ShaderEXT, pDataSize: ^int, pData: rawptr) -> Result +ProcGetShaderInfoAMD :: #type proc "system" (device: Device, pipeline: Pipeline, shaderStage: ShaderStageFlags, infoType: ShaderInfoTypeAMD, pInfoSize: ^int, pInfo: rawptr) -> Result +ProcGetShaderModuleCreateInfoIdentifierEXT :: #type proc "system" (device: Device, pCreateInfo: ^ShaderModuleCreateInfo, pIdentifier: ^ShaderModuleIdentifierEXT) +ProcGetShaderModuleIdentifierEXT :: #type proc "system" (device: Device, shaderModule: ShaderModule, pIdentifier: ^ShaderModuleIdentifierEXT) +ProcGetSwapchainCounterEXT :: #type proc "system" (device: Device, swapchain: SwapchainKHR, counter: SurfaceCounterFlagsEXT, pCounterValue: ^u64) -> Result +ProcGetSwapchainImagesKHR :: #type proc "system" (device: Device, swapchain: SwapchainKHR, pSwapchainImageCount: ^u32, pSwapchainImages: [^]Image) -> Result +ProcGetSwapchainStatusKHR :: #type proc "system" (device: Device, swapchain: SwapchainKHR) -> Result +ProcGetValidationCacheDataEXT :: #type proc "system" (device: Device, validationCache: ValidationCacheEXT, pDataSize: ^int, pData: rawptr) -> Result +ProcGetVideoSessionMemoryRequirementsKHR :: #type proc "system" (device: Device, videoSession: VideoSessionKHR, pMemoryRequirementsCount: ^u32, pMemoryRequirements: [^]VideoSessionMemoryRequirementsKHR) -> Result +ProcImportFenceFdKHR :: #type proc "system" (device: Device, pImportFenceFdInfo: ^ImportFenceFdInfoKHR) -> Result +ProcImportFenceWin32HandleKHR :: #type proc "system" (device: Device, pImportFenceWin32HandleInfo: ^ImportFenceWin32HandleInfoKHR) -> Result +ProcImportSemaphoreFdKHR :: #type proc "system" (device: Device, pImportSemaphoreFdInfo: ^ImportSemaphoreFdInfoKHR) -> Result +ProcImportSemaphoreWin32HandleKHR :: #type proc "system" (device: Device, pImportSemaphoreWin32HandleInfo: ^ImportSemaphoreWin32HandleInfoKHR) -> Result +ProcInitializePerformanceApiINTEL :: #type proc "system" (device: Device, pInitializeInfo: ^InitializePerformanceApiInfoINTEL) -> Result +ProcInvalidateMappedMemoryRanges :: #type proc "system" (device: Device, memoryRangeCount: u32, pMemoryRanges: [^]MappedMemoryRange) -> Result +ProcMapMemory :: #type proc "system" (device: Device, memory: DeviceMemory, offset: DeviceSize, size: DeviceSize, flags: MemoryMapFlags, ppData: ^rawptr) -> Result +ProcMapMemory2KHR :: #type proc "system" (device: Device, pMemoryMapInfo: ^MemoryMapInfoKHR, ppData: ^rawptr) -> Result +ProcMergePipelineCaches :: #type proc "system" (device: Device, dstCache: PipelineCache, srcCacheCount: u32, pSrcCaches: [^]PipelineCache) -> Result +ProcMergeValidationCachesEXT :: #type proc "system" (device: Device, dstCache: ValidationCacheEXT, srcCacheCount: u32, pSrcCaches: [^]ValidationCacheEXT) -> Result +ProcQueueBeginDebugUtilsLabelEXT :: #type proc "system" (queue: Queue, pLabelInfo: ^DebugUtilsLabelEXT) +ProcQueueBindSparse :: #type proc "system" (queue: Queue, bindInfoCount: u32, pBindInfo: ^BindSparseInfo, fence: Fence) -> Result +ProcQueueEndDebugUtilsLabelEXT :: #type proc "system" (queue: Queue) +ProcQueueInsertDebugUtilsLabelEXT :: #type proc "system" (queue: Queue, pLabelInfo: ^DebugUtilsLabelEXT) +ProcQueuePresentKHR :: #type proc "system" (queue: Queue, pPresentInfo: ^PresentInfoKHR) -> Result +ProcQueueSetPerformanceConfigurationINTEL :: #type proc "system" (queue: Queue, configuration: PerformanceConfigurationINTEL) -> Result +ProcQueueSubmit :: #type proc "system" (queue: Queue, submitCount: u32, pSubmits: [^]SubmitInfo, fence: Fence) -> Result +ProcQueueSubmit2 :: #type proc "system" (queue: Queue, submitCount: u32, pSubmits: [^]SubmitInfo2, fence: Fence) -> Result +ProcQueueSubmit2KHR :: #type proc "system" (queue: Queue, submitCount: u32, pSubmits: [^]SubmitInfo2, fence: Fence) -> Result +ProcQueueWaitIdle :: #type proc "system" (queue: Queue) -> Result +ProcRegisterDeviceEventEXT :: #type proc "system" (device: Device, pDeviceEventInfo: ^DeviceEventInfoEXT, pAllocator: ^AllocationCallbacks, pFence: ^Fence) -> Result +ProcRegisterDisplayEventEXT :: #type proc "system" (device: Device, display: DisplayKHR, pDisplayEventInfo: ^DisplayEventInfoEXT, pAllocator: ^AllocationCallbacks, pFence: ^Fence) -> Result +ProcReleaseFullScreenExclusiveModeEXT :: #type proc "system" (device: Device, swapchain: SwapchainKHR) -> Result +ProcReleasePerformanceConfigurationINTEL :: #type proc "system" (device: Device, configuration: PerformanceConfigurationINTEL) -> Result +ProcReleaseProfilingLockKHR :: #type proc "system" (device: Device) +ProcReleaseSwapchainImagesEXT :: #type proc "system" (device: Device, pReleaseInfo: ^ReleaseSwapchainImagesInfoEXT) -> Result +ProcResetCommandBuffer :: #type proc "system" (commandBuffer: CommandBuffer, flags: CommandBufferResetFlags) -> Result +ProcResetCommandPool :: #type proc "system" (device: Device, commandPool: CommandPool, flags: CommandPoolResetFlags) -> Result +ProcResetDescriptorPool :: #type proc "system" (device: Device, descriptorPool: DescriptorPool, flags: DescriptorPoolResetFlags) -> Result +ProcResetEvent :: #type proc "system" (device: Device, event: Event) -> Result +ProcResetFences :: #type proc "system" (device: Device, fenceCount: u32, pFences: [^]Fence) -> Result +ProcResetQueryPool :: #type proc "system" (device: Device, queryPool: QueryPool, firstQuery: u32, queryCount: u32) +ProcResetQueryPoolEXT :: #type proc "system" (device: Device, queryPool: QueryPool, firstQuery: u32, queryCount: u32) +ProcSetDebugUtilsObjectNameEXT :: #type proc "system" (device: Device, pNameInfo: ^DebugUtilsObjectNameInfoEXT) -> Result +ProcSetDebugUtilsObjectTagEXT :: #type proc "system" (device: Device, pTagInfo: ^DebugUtilsObjectTagInfoEXT) -> Result +ProcSetDeviceMemoryPriorityEXT :: #type proc "system" (device: Device, memory: DeviceMemory, priority: f32) +ProcSetEvent :: #type proc "system" (device: Device, event: Event) -> Result +ProcSetHdrMetadataEXT :: #type proc "system" (device: Device, swapchainCount: u32, pSwapchains: [^]SwapchainKHR, pMetadata: ^HdrMetadataEXT) +ProcSetLocalDimmingAMD :: #type proc "system" (device: Device, swapChain: SwapchainKHR, localDimmingEnable: b32) +ProcSetPrivateData :: #type proc "system" (device: Device, objectType: ObjectType, objectHandle: u64, privateDataSlot: PrivateDataSlot, data: u64) -> Result +ProcSetPrivateDataEXT :: #type proc "system" (device: Device, objectType: ObjectType, objectHandle: u64, privateDataSlot: PrivateDataSlot, data: u64) -> Result +ProcSignalSemaphore :: #type proc "system" (device: Device, pSignalInfo: ^SemaphoreSignalInfo) -> Result +ProcSignalSemaphoreKHR :: #type proc "system" (device: Device, pSignalInfo: ^SemaphoreSignalInfo) -> Result +ProcTrimCommandPool :: #type proc "system" (device: Device, commandPool: CommandPool, flags: CommandPoolTrimFlags) +ProcTrimCommandPoolKHR :: #type proc "system" (device: Device, commandPool: CommandPool, flags: CommandPoolTrimFlags) +ProcUninitializePerformanceApiINTEL :: #type proc "system" (device: Device) +ProcUnmapMemory :: #type proc "system" (device: Device, memory: DeviceMemory) +ProcUnmapMemory2KHR :: #type proc "system" (device: Device, pMemoryUnmapInfo: ^MemoryUnmapInfoKHR) -> Result +ProcUpdateDescriptorSetWithTemplate :: #type proc "system" (device: Device, descriptorSet: DescriptorSet, descriptorUpdateTemplate: DescriptorUpdateTemplate, pData: rawptr) +ProcUpdateDescriptorSetWithTemplateKHR :: #type proc "system" (device: Device, descriptorSet: DescriptorSet, descriptorUpdateTemplate: DescriptorUpdateTemplate, pData: rawptr) +ProcUpdateDescriptorSets :: #type proc "system" (device: Device, descriptorWriteCount: u32, pDescriptorWrites: [^]WriteDescriptorSet, descriptorCopyCount: u32, pDescriptorCopies: [^]CopyDescriptorSet) +ProcUpdateVideoSessionParametersKHR :: #type proc "system" (device: Device, videoSessionParameters: VideoSessionParametersKHR, pUpdateInfo: ^VideoSessionParametersUpdateInfoKHR) -> Result +ProcWaitForFences :: #type proc "system" (device: Device, fenceCount: u32, pFences: [^]Fence, waitAll: b32, timeout: u64) -> Result +ProcWaitForPresentKHR :: #type proc "system" (device: Device, swapchain: SwapchainKHR, presentId: u64, timeout: u64) -> Result +ProcWaitSemaphores :: #type proc "system" (device: Device, pWaitInfo: ^SemaphoreWaitInfo, timeout: u64) -> Result +ProcWaitSemaphoresKHR :: #type proc "system" (device: Device, pWaitInfo: ^SemaphoreWaitInfo, timeout: u64) -> Result +ProcWriteAccelerationStructuresPropertiesKHR :: #type proc "system" (device: Device, accelerationStructureCount: u32, pAccelerationStructures: [^]AccelerationStructureKHR, queryType: QueryType, dataSize: int, pData: rawptr, stride: int) -> Result +ProcWriteMicromapsPropertiesEXT :: #type proc "system" (device: Device, micromapCount: u32, pMicromaps: [^]MicromapEXT, queryType: QueryType, dataSize: int, pData: rawptr, stride: int) -> Result + + +// Loader Procedures +CreateInstance: ProcCreateInstance +DebugUtilsMessengerCallbackEXT: ProcDebugUtilsMessengerCallbackEXT +DeviceMemoryReportCallbackEXT: ProcDeviceMemoryReportCallbackEXT +EnumerateInstanceExtensionProperties: ProcEnumerateInstanceExtensionProperties +EnumerateInstanceLayerProperties: ProcEnumerateInstanceLayerProperties +EnumerateInstanceVersion: ProcEnumerateInstanceVersion +GetInstanceProcAddr: ProcGetInstanceProcAddr + +// Instance Procedures +AcquireDrmDisplayEXT: ProcAcquireDrmDisplayEXT +AcquireWinrtDisplayNV: ProcAcquireWinrtDisplayNV +CreateDebugReportCallbackEXT: ProcCreateDebugReportCallbackEXT +CreateDebugUtilsMessengerEXT: ProcCreateDebugUtilsMessengerEXT +CreateDevice: ProcCreateDevice +CreateDisplayModeKHR: ProcCreateDisplayModeKHR +CreateDisplayPlaneSurfaceKHR: ProcCreateDisplayPlaneSurfaceKHR +CreateHeadlessSurfaceEXT: ProcCreateHeadlessSurfaceEXT +CreateIOSSurfaceMVK: ProcCreateIOSSurfaceMVK +CreateMacOSSurfaceMVK: ProcCreateMacOSSurfaceMVK +CreateMetalSurfaceEXT: ProcCreateMetalSurfaceEXT +CreateWaylandSurfaceKHR: ProcCreateWaylandSurfaceKHR +CreateWin32SurfaceKHR: ProcCreateWin32SurfaceKHR +DebugReportMessageEXT: ProcDebugReportMessageEXT +DestroyDebugReportCallbackEXT: ProcDestroyDebugReportCallbackEXT +DestroyDebugUtilsMessengerEXT: ProcDestroyDebugUtilsMessengerEXT +DestroyInstance: ProcDestroyInstance +DestroySurfaceKHR: ProcDestroySurfaceKHR +EnumerateDeviceExtensionProperties: ProcEnumerateDeviceExtensionProperties +EnumerateDeviceLayerProperties: ProcEnumerateDeviceLayerProperties +EnumeratePhysicalDeviceGroups: ProcEnumeratePhysicalDeviceGroups +EnumeratePhysicalDeviceGroupsKHR: ProcEnumeratePhysicalDeviceGroupsKHR +EnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR: ProcEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR +EnumeratePhysicalDevices: ProcEnumeratePhysicalDevices +GetDisplayModeProperties2KHR: ProcGetDisplayModeProperties2KHR +GetDisplayModePropertiesKHR: ProcGetDisplayModePropertiesKHR +GetDisplayPlaneCapabilities2KHR: ProcGetDisplayPlaneCapabilities2KHR +GetDisplayPlaneCapabilitiesKHR: ProcGetDisplayPlaneCapabilitiesKHR +GetDisplayPlaneSupportedDisplaysKHR: ProcGetDisplayPlaneSupportedDisplaysKHR +GetDrmDisplayEXT: ProcGetDrmDisplayEXT +GetInstanceProcAddrLUNARG: ProcGetInstanceProcAddrLUNARG +GetPhysicalDeviceCalibrateableTimeDomainsEXT: ProcGetPhysicalDeviceCalibrateableTimeDomainsEXT +GetPhysicalDeviceCooperativeMatrixPropertiesNV: ProcGetPhysicalDeviceCooperativeMatrixPropertiesNV +GetPhysicalDeviceDisplayPlaneProperties2KHR: ProcGetPhysicalDeviceDisplayPlaneProperties2KHR +GetPhysicalDeviceDisplayPlanePropertiesKHR: ProcGetPhysicalDeviceDisplayPlanePropertiesKHR +GetPhysicalDeviceDisplayProperties2KHR: ProcGetPhysicalDeviceDisplayProperties2KHR +GetPhysicalDeviceDisplayPropertiesKHR: ProcGetPhysicalDeviceDisplayPropertiesKHR +GetPhysicalDeviceExternalBufferProperties: ProcGetPhysicalDeviceExternalBufferProperties +GetPhysicalDeviceExternalBufferPropertiesKHR: ProcGetPhysicalDeviceExternalBufferPropertiesKHR +GetPhysicalDeviceExternalFenceProperties: ProcGetPhysicalDeviceExternalFenceProperties +GetPhysicalDeviceExternalFencePropertiesKHR: ProcGetPhysicalDeviceExternalFencePropertiesKHR +GetPhysicalDeviceExternalImageFormatPropertiesNV: ProcGetPhysicalDeviceExternalImageFormatPropertiesNV +GetPhysicalDeviceExternalSemaphoreProperties: ProcGetPhysicalDeviceExternalSemaphoreProperties +GetPhysicalDeviceExternalSemaphorePropertiesKHR: ProcGetPhysicalDeviceExternalSemaphorePropertiesKHR +GetPhysicalDeviceFeatures: ProcGetPhysicalDeviceFeatures +GetPhysicalDeviceFeatures2: ProcGetPhysicalDeviceFeatures2 +GetPhysicalDeviceFeatures2KHR: ProcGetPhysicalDeviceFeatures2KHR +GetPhysicalDeviceFormatProperties: ProcGetPhysicalDeviceFormatProperties +GetPhysicalDeviceFormatProperties2: ProcGetPhysicalDeviceFormatProperties2 +GetPhysicalDeviceFormatProperties2KHR: ProcGetPhysicalDeviceFormatProperties2KHR +GetPhysicalDeviceFragmentShadingRatesKHR: ProcGetPhysicalDeviceFragmentShadingRatesKHR +GetPhysicalDeviceImageFormatProperties: ProcGetPhysicalDeviceImageFormatProperties +GetPhysicalDeviceImageFormatProperties2: ProcGetPhysicalDeviceImageFormatProperties2 +GetPhysicalDeviceImageFormatProperties2KHR: ProcGetPhysicalDeviceImageFormatProperties2KHR +GetPhysicalDeviceMemoryProperties: ProcGetPhysicalDeviceMemoryProperties +GetPhysicalDeviceMemoryProperties2: ProcGetPhysicalDeviceMemoryProperties2 +GetPhysicalDeviceMemoryProperties2KHR: ProcGetPhysicalDeviceMemoryProperties2KHR +GetPhysicalDeviceMultisamplePropertiesEXT: ProcGetPhysicalDeviceMultisamplePropertiesEXT +GetPhysicalDeviceOpticalFlowImageFormatsNV: ProcGetPhysicalDeviceOpticalFlowImageFormatsNV +GetPhysicalDevicePresentRectanglesKHR: ProcGetPhysicalDevicePresentRectanglesKHR +GetPhysicalDeviceProperties: ProcGetPhysicalDeviceProperties +GetPhysicalDeviceProperties2: ProcGetPhysicalDeviceProperties2 +GetPhysicalDeviceProperties2KHR: ProcGetPhysicalDeviceProperties2KHR +GetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR: ProcGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR +GetPhysicalDeviceQueueFamilyProperties: ProcGetPhysicalDeviceQueueFamilyProperties +GetPhysicalDeviceQueueFamilyProperties2: ProcGetPhysicalDeviceQueueFamilyProperties2 +GetPhysicalDeviceQueueFamilyProperties2KHR: ProcGetPhysicalDeviceQueueFamilyProperties2KHR +GetPhysicalDeviceSparseImageFormatProperties: ProcGetPhysicalDeviceSparseImageFormatProperties +GetPhysicalDeviceSparseImageFormatProperties2: ProcGetPhysicalDeviceSparseImageFormatProperties2 +GetPhysicalDeviceSparseImageFormatProperties2KHR: ProcGetPhysicalDeviceSparseImageFormatProperties2KHR +GetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV: ProcGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV +GetPhysicalDeviceSurfaceCapabilities2EXT: ProcGetPhysicalDeviceSurfaceCapabilities2EXT +GetPhysicalDeviceSurfaceCapabilities2KHR: ProcGetPhysicalDeviceSurfaceCapabilities2KHR +GetPhysicalDeviceSurfaceCapabilitiesKHR: ProcGetPhysicalDeviceSurfaceCapabilitiesKHR +GetPhysicalDeviceSurfaceFormats2KHR: ProcGetPhysicalDeviceSurfaceFormats2KHR +GetPhysicalDeviceSurfaceFormatsKHR: ProcGetPhysicalDeviceSurfaceFormatsKHR +GetPhysicalDeviceSurfacePresentModes2EXT: ProcGetPhysicalDeviceSurfacePresentModes2EXT +GetPhysicalDeviceSurfacePresentModesKHR: ProcGetPhysicalDeviceSurfacePresentModesKHR +GetPhysicalDeviceSurfaceSupportKHR: ProcGetPhysicalDeviceSurfaceSupportKHR +GetPhysicalDeviceToolProperties: ProcGetPhysicalDeviceToolProperties +GetPhysicalDeviceToolPropertiesEXT: ProcGetPhysicalDeviceToolPropertiesEXT +GetPhysicalDeviceVideoCapabilitiesKHR: ProcGetPhysicalDeviceVideoCapabilitiesKHR +GetPhysicalDeviceVideoFormatPropertiesKHR: ProcGetPhysicalDeviceVideoFormatPropertiesKHR +GetPhysicalDeviceWaylandPresentationSupportKHR: ProcGetPhysicalDeviceWaylandPresentationSupportKHR +GetPhysicalDeviceWin32PresentationSupportKHR: ProcGetPhysicalDeviceWin32PresentationSupportKHR +GetWinrtDisplayNV: ProcGetWinrtDisplayNV +ReleaseDisplayEXT: ProcReleaseDisplayEXT +SubmitDebugUtilsMessageEXT: ProcSubmitDebugUtilsMessageEXT + +// Device Procedures +AcquireFullScreenExclusiveModeEXT: ProcAcquireFullScreenExclusiveModeEXT +AcquireNextImage2KHR: ProcAcquireNextImage2KHR +AcquireNextImageKHR: ProcAcquireNextImageKHR +AcquirePerformanceConfigurationINTEL: ProcAcquirePerformanceConfigurationINTEL +AcquireProfilingLockKHR: ProcAcquireProfilingLockKHR +AllocateCommandBuffers: ProcAllocateCommandBuffers +AllocateDescriptorSets: ProcAllocateDescriptorSets +AllocateMemory: ProcAllocateMemory +BeginCommandBuffer: ProcBeginCommandBuffer +BindAccelerationStructureMemoryNV: ProcBindAccelerationStructureMemoryNV +BindBufferMemory: ProcBindBufferMemory +BindBufferMemory2: ProcBindBufferMemory2 +BindBufferMemory2KHR: ProcBindBufferMemory2KHR +BindImageMemory: ProcBindImageMemory +BindImageMemory2: ProcBindImageMemory2 +BindImageMemory2KHR: ProcBindImageMemory2KHR +BindOpticalFlowSessionImageNV: ProcBindOpticalFlowSessionImageNV +BindVideoSessionMemoryKHR: ProcBindVideoSessionMemoryKHR +BuildAccelerationStructuresKHR: ProcBuildAccelerationStructuresKHR +BuildMicromapsEXT: ProcBuildMicromapsEXT +CmdBeginConditionalRenderingEXT: ProcCmdBeginConditionalRenderingEXT +CmdBeginDebugUtilsLabelEXT: ProcCmdBeginDebugUtilsLabelEXT +CmdBeginQuery: ProcCmdBeginQuery +CmdBeginQueryIndexedEXT: ProcCmdBeginQueryIndexedEXT +CmdBeginRenderPass: ProcCmdBeginRenderPass +CmdBeginRenderPass2: ProcCmdBeginRenderPass2 +CmdBeginRenderPass2KHR: ProcCmdBeginRenderPass2KHR +CmdBeginRendering: ProcCmdBeginRendering +CmdBeginRenderingKHR: ProcCmdBeginRenderingKHR +CmdBeginTransformFeedbackEXT: ProcCmdBeginTransformFeedbackEXT +CmdBeginVideoCodingKHR: ProcCmdBeginVideoCodingKHR +CmdBindDescriptorBufferEmbeddedSamplersEXT: ProcCmdBindDescriptorBufferEmbeddedSamplersEXT +CmdBindDescriptorBuffersEXT: ProcCmdBindDescriptorBuffersEXT +CmdBindDescriptorSets: ProcCmdBindDescriptorSets +CmdBindIndexBuffer: ProcCmdBindIndexBuffer +CmdBindInvocationMaskHUAWEI: ProcCmdBindInvocationMaskHUAWEI +CmdBindPipeline: ProcCmdBindPipeline +CmdBindPipelineShaderGroupNV: ProcCmdBindPipelineShaderGroupNV +CmdBindShadersEXT: ProcCmdBindShadersEXT +CmdBindShadingRateImageNV: ProcCmdBindShadingRateImageNV +CmdBindTransformFeedbackBuffersEXT: ProcCmdBindTransformFeedbackBuffersEXT +CmdBindVertexBuffers: ProcCmdBindVertexBuffers +CmdBindVertexBuffers2: ProcCmdBindVertexBuffers2 +CmdBindVertexBuffers2EXT: ProcCmdBindVertexBuffers2EXT +CmdBlitImage: ProcCmdBlitImage +CmdBlitImage2: ProcCmdBlitImage2 +CmdBlitImage2KHR: ProcCmdBlitImage2KHR +CmdBuildAccelerationStructureNV: ProcCmdBuildAccelerationStructureNV +CmdBuildAccelerationStructuresIndirectKHR: ProcCmdBuildAccelerationStructuresIndirectKHR +CmdBuildAccelerationStructuresKHR: ProcCmdBuildAccelerationStructuresKHR +CmdBuildMicromapsEXT: ProcCmdBuildMicromapsEXT +CmdClearAttachments: ProcCmdClearAttachments +CmdClearColorImage: ProcCmdClearColorImage +CmdClearDepthStencilImage: ProcCmdClearDepthStencilImage +CmdControlVideoCodingKHR: ProcCmdControlVideoCodingKHR +CmdCopyAccelerationStructureKHR: ProcCmdCopyAccelerationStructureKHR +CmdCopyAccelerationStructureNV: ProcCmdCopyAccelerationStructureNV +CmdCopyAccelerationStructureToMemoryKHR: ProcCmdCopyAccelerationStructureToMemoryKHR +CmdCopyBuffer: ProcCmdCopyBuffer +CmdCopyBuffer2: ProcCmdCopyBuffer2 +CmdCopyBuffer2KHR: ProcCmdCopyBuffer2KHR +CmdCopyBufferToImage: ProcCmdCopyBufferToImage +CmdCopyBufferToImage2: ProcCmdCopyBufferToImage2 +CmdCopyBufferToImage2KHR: ProcCmdCopyBufferToImage2KHR +CmdCopyImage: ProcCmdCopyImage +CmdCopyImage2: ProcCmdCopyImage2 +CmdCopyImage2KHR: ProcCmdCopyImage2KHR +CmdCopyImageToBuffer: ProcCmdCopyImageToBuffer +CmdCopyImageToBuffer2: ProcCmdCopyImageToBuffer2 +CmdCopyImageToBuffer2KHR: ProcCmdCopyImageToBuffer2KHR +CmdCopyMemoryIndirectNV: ProcCmdCopyMemoryIndirectNV +CmdCopyMemoryToAccelerationStructureKHR: ProcCmdCopyMemoryToAccelerationStructureKHR +CmdCopyMemoryToImageIndirectNV: ProcCmdCopyMemoryToImageIndirectNV +CmdCopyMemoryToMicromapEXT: ProcCmdCopyMemoryToMicromapEXT +CmdCopyMicromapEXT: ProcCmdCopyMicromapEXT +CmdCopyMicromapToMemoryEXT: ProcCmdCopyMicromapToMemoryEXT +CmdCopyQueryPoolResults: ProcCmdCopyQueryPoolResults +CmdCuLaunchKernelNVX: ProcCmdCuLaunchKernelNVX +CmdDebugMarkerBeginEXT: ProcCmdDebugMarkerBeginEXT +CmdDebugMarkerEndEXT: ProcCmdDebugMarkerEndEXT +CmdDebugMarkerInsertEXT: ProcCmdDebugMarkerInsertEXT +CmdDecodeVideoKHR: ProcCmdDecodeVideoKHR +CmdDecompressMemoryIndirectCountNV: ProcCmdDecompressMemoryIndirectCountNV +CmdDecompressMemoryNV: ProcCmdDecompressMemoryNV +CmdDispatch: ProcCmdDispatch +CmdDispatchBase: ProcCmdDispatchBase +CmdDispatchBaseKHR: ProcCmdDispatchBaseKHR +CmdDispatchIndirect: ProcCmdDispatchIndirect +CmdDraw: ProcCmdDraw +CmdDrawClusterHUAWEI: ProcCmdDrawClusterHUAWEI +CmdDrawClusterIndirectHUAWEI: ProcCmdDrawClusterIndirectHUAWEI +CmdDrawIndexed: ProcCmdDrawIndexed +CmdDrawIndexedIndirect: ProcCmdDrawIndexedIndirect +CmdDrawIndexedIndirectCount: ProcCmdDrawIndexedIndirectCount +CmdDrawIndexedIndirectCountAMD: ProcCmdDrawIndexedIndirectCountAMD +CmdDrawIndexedIndirectCountKHR: ProcCmdDrawIndexedIndirectCountKHR +CmdDrawIndirect: ProcCmdDrawIndirect +CmdDrawIndirectByteCountEXT: ProcCmdDrawIndirectByteCountEXT +CmdDrawIndirectCount: ProcCmdDrawIndirectCount +CmdDrawIndirectCountAMD: ProcCmdDrawIndirectCountAMD +CmdDrawIndirectCountKHR: ProcCmdDrawIndirectCountKHR +CmdDrawMeshTasksEXT: ProcCmdDrawMeshTasksEXT +CmdDrawMeshTasksIndirectCountEXT: ProcCmdDrawMeshTasksIndirectCountEXT +CmdDrawMeshTasksIndirectCountNV: ProcCmdDrawMeshTasksIndirectCountNV +CmdDrawMeshTasksIndirectEXT: ProcCmdDrawMeshTasksIndirectEXT +CmdDrawMeshTasksIndirectNV: ProcCmdDrawMeshTasksIndirectNV +CmdDrawMeshTasksNV: ProcCmdDrawMeshTasksNV +CmdDrawMultiEXT: ProcCmdDrawMultiEXT +CmdDrawMultiIndexedEXT: ProcCmdDrawMultiIndexedEXT +CmdEndConditionalRenderingEXT: ProcCmdEndConditionalRenderingEXT +CmdEndDebugUtilsLabelEXT: ProcCmdEndDebugUtilsLabelEXT +CmdEndQuery: ProcCmdEndQuery +CmdEndQueryIndexedEXT: ProcCmdEndQueryIndexedEXT +CmdEndRenderPass: ProcCmdEndRenderPass +CmdEndRenderPass2: ProcCmdEndRenderPass2 +CmdEndRenderPass2KHR: ProcCmdEndRenderPass2KHR +CmdEndRendering: ProcCmdEndRendering +CmdEndRenderingKHR: ProcCmdEndRenderingKHR +CmdEndTransformFeedbackEXT: ProcCmdEndTransformFeedbackEXT +CmdEndVideoCodingKHR: ProcCmdEndVideoCodingKHR +CmdExecuteCommands: ProcCmdExecuteCommands +CmdExecuteGeneratedCommandsNV: ProcCmdExecuteGeneratedCommandsNV +CmdFillBuffer: ProcCmdFillBuffer +CmdInsertDebugUtilsLabelEXT: ProcCmdInsertDebugUtilsLabelEXT +CmdNextSubpass: ProcCmdNextSubpass +CmdNextSubpass2: ProcCmdNextSubpass2 +CmdNextSubpass2KHR: ProcCmdNextSubpass2KHR +CmdOpticalFlowExecuteNV: ProcCmdOpticalFlowExecuteNV +CmdPipelineBarrier: ProcCmdPipelineBarrier +CmdPipelineBarrier2: ProcCmdPipelineBarrier2 +CmdPipelineBarrier2KHR: ProcCmdPipelineBarrier2KHR +CmdPreprocessGeneratedCommandsNV: ProcCmdPreprocessGeneratedCommandsNV +CmdPushConstants: ProcCmdPushConstants +CmdPushDescriptorSetKHR: ProcCmdPushDescriptorSetKHR +CmdPushDescriptorSetWithTemplateKHR: ProcCmdPushDescriptorSetWithTemplateKHR +CmdResetEvent: ProcCmdResetEvent +CmdResetEvent2: ProcCmdResetEvent2 +CmdResetEvent2KHR: ProcCmdResetEvent2KHR +CmdResetQueryPool: ProcCmdResetQueryPool +CmdResolveImage: ProcCmdResolveImage +CmdResolveImage2: ProcCmdResolveImage2 +CmdResolveImage2KHR: ProcCmdResolveImage2KHR +CmdSetAlphaToCoverageEnableEXT: ProcCmdSetAlphaToCoverageEnableEXT +CmdSetAlphaToOneEnableEXT: ProcCmdSetAlphaToOneEnableEXT +CmdSetAttachmentFeedbackLoopEnableEXT: ProcCmdSetAttachmentFeedbackLoopEnableEXT +CmdSetBlendConstants: ProcCmdSetBlendConstants +CmdSetCheckpointNV: ProcCmdSetCheckpointNV +CmdSetCoarseSampleOrderNV: ProcCmdSetCoarseSampleOrderNV +CmdSetColorBlendAdvancedEXT: ProcCmdSetColorBlendAdvancedEXT +CmdSetColorBlendEnableEXT: ProcCmdSetColorBlendEnableEXT +CmdSetColorBlendEquationEXT: ProcCmdSetColorBlendEquationEXT +CmdSetColorWriteMaskEXT: ProcCmdSetColorWriteMaskEXT +CmdSetConservativeRasterizationModeEXT: ProcCmdSetConservativeRasterizationModeEXT +CmdSetCoverageModulationModeNV: ProcCmdSetCoverageModulationModeNV +CmdSetCoverageModulationTableEnableNV: ProcCmdSetCoverageModulationTableEnableNV +CmdSetCoverageModulationTableNV: ProcCmdSetCoverageModulationTableNV +CmdSetCoverageReductionModeNV: ProcCmdSetCoverageReductionModeNV +CmdSetCoverageToColorEnableNV: ProcCmdSetCoverageToColorEnableNV +CmdSetCoverageToColorLocationNV: ProcCmdSetCoverageToColorLocationNV +CmdSetCullMode: ProcCmdSetCullMode +CmdSetCullModeEXT: ProcCmdSetCullModeEXT +CmdSetDepthBias: ProcCmdSetDepthBias +CmdSetDepthBiasEnable: ProcCmdSetDepthBiasEnable +CmdSetDepthBiasEnableEXT: ProcCmdSetDepthBiasEnableEXT +CmdSetDepthBounds: ProcCmdSetDepthBounds +CmdSetDepthBoundsTestEnable: ProcCmdSetDepthBoundsTestEnable +CmdSetDepthBoundsTestEnableEXT: ProcCmdSetDepthBoundsTestEnableEXT +CmdSetDepthClampEnableEXT: ProcCmdSetDepthClampEnableEXT +CmdSetDepthClipEnableEXT: ProcCmdSetDepthClipEnableEXT +CmdSetDepthClipNegativeOneToOneEXT: ProcCmdSetDepthClipNegativeOneToOneEXT +CmdSetDepthCompareOp: ProcCmdSetDepthCompareOp +CmdSetDepthCompareOpEXT: ProcCmdSetDepthCompareOpEXT +CmdSetDepthTestEnable: ProcCmdSetDepthTestEnable +CmdSetDepthTestEnableEXT: ProcCmdSetDepthTestEnableEXT +CmdSetDepthWriteEnable: ProcCmdSetDepthWriteEnable +CmdSetDepthWriteEnableEXT: ProcCmdSetDepthWriteEnableEXT +CmdSetDescriptorBufferOffsetsEXT: ProcCmdSetDescriptorBufferOffsetsEXT +CmdSetDeviceMask: ProcCmdSetDeviceMask +CmdSetDeviceMaskKHR: ProcCmdSetDeviceMaskKHR +CmdSetDiscardRectangleEXT: ProcCmdSetDiscardRectangleEXT +CmdSetDiscardRectangleEnableEXT: ProcCmdSetDiscardRectangleEnableEXT +CmdSetDiscardRectangleModeEXT: ProcCmdSetDiscardRectangleModeEXT +CmdSetEvent: ProcCmdSetEvent +CmdSetEvent2: ProcCmdSetEvent2 +CmdSetEvent2KHR: ProcCmdSetEvent2KHR +CmdSetExclusiveScissorEnableNV: ProcCmdSetExclusiveScissorEnableNV +CmdSetExclusiveScissorNV: ProcCmdSetExclusiveScissorNV +CmdSetExtraPrimitiveOverestimationSizeEXT: ProcCmdSetExtraPrimitiveOverestimationSizeEXT +CmdSetFragmentShadingRateEnumNV: ProcCmdSetFragmentShadingRateEnumNV +CmdSetFragmentShadingRateKHR: ProcCmdSetFragmentShadingRateKHR +CmdSetFrontFace: ProcCmdSetFrontFace +CmdSetFrontFaceEXT: ProcCmdSetFrontFaceEXT +CmdSetLineRasterizationModeEXT: ProcCmdSetLineRasterizationModeEXT +CmdSetLineStippleEXT: ProcCmdSetLineStippleEXT +CmdSetLineStippleEnableEXT: ProcCmdSetLineStippleEnableEXT +CmdSetLineWidth: ProcCmdSetLineWidth +CmdSetLogicOpEXT: ProcCmdSetLogicOpEXT +CmdSetLogicOpEnableEXT: ProcCmdSetLogicOpEnableEXT +CmdSetPatchControlPointsEXT: ProcCmdSetPatchControlPointsEXT +CmdSetPerformanceMarkerINTEL: ProcCmdSetPerformanceMarkerINTEL +CmdSetPerformanceOverrideINTEL: ProcCmdSetPerformanceOverrideINTEL +CmdSetPerformanceStreamMarkerINTEL: ProcCmdSetPerformanceStreamMarkerINTEL +CmdSetPolygonModeEXT: ProcCmdSetPolygonModeEXT +CmdSetPrimitiveRestartEnable: ProcCmdSetPrimitiveRestartEnable +CmdSetPrimitiveRestartEnableEXT: ProcCmdSetPrimitiveRestartEnableEXT +CmdSetPrimitiveTopology: ProcCmdSetPrimitiveTopology +CmdSetPrimitiveTopologyEXT: ProcCmdSetPrimitiveTopologyEXT +CmdSetProvokingVertexModeEXT: ProcCmdSetProvokingVertexModeEXT +CmdSetRasterizationSamplesEXT: ProcCmdSetRasterizationSamplesEXT +CmdSetRasterizationStreamEXT: ProcCmdSetRasterizationStreamEXT +CmdSetRasterizerDiscardEnable: ProcCmdSetRasterizerDiscardEnable +CmdSetRasterizerDiscardEnableEXT: ProcCmdSetRasterizerDiscardEnableEXT +CmdSetRayTracingPipelineStackSizeKHR: ProcCmdSetRayTracingPipelineStackSizeKHR +CmdSetRepresentativeFragmentTestEnableNV: ProcCmdSetRepresentativeFragmentTestEnableNV +CmdSetSampleLocationsEXT: ProcCmdSetSampleLocationsEXT +CmdSetSampleLocationsEnableEXT: ProcCmdSetSampleLocationsEnableEXT +CmdSetSampleMaskEXT: ProcCmdSetSampleMaskEXT +CmdSetScissor: ProcCmdSetScissor +CmdSetScissorWithCount: ProcCmdSetScissorWithCount +CmdSetScissorWithCountEXT: ProcCmdSetScissorWithCountEXT +CmdSetShadingRateImageEnableNV: ProcCmdSetShadingRateImageEnableNV +CmdSetStencilCompareMask: ProcCmdSetStencilCompareMask +CmdSetStencilOp: ProcCmdSetStencilOp +CmdSetStencilOpEXT: ProcCmdSetStencilOpEXT +CmdSetStencilReference: ProcCmdSetStencilReference +CmdSetStencilTestEnable: ProcCmdSetStencilTestEnable +CmdSetStencilTestEnableEXT: ProcCmdSetStencilTestEnableEXT +CmdSetStencilWriteMask: ProcCmdSetStencilWriteMask +CmdSetTessellationDomainOriginEXT: ProcCmdSetTessellationDomainOriginEXT +CmdSetVertexInputEXT: ProcCmdSetVertexInputEXT +CmdSetViewport: ProcCmdSetViewport +CmdSetViewportShadingRatePaletteNV: ProcCmdSetViewportShadingRatePaletteNV +CmdSetViewportSwizzleNV: ProcCmdSetViewportSwizzleNV +CmdSetViewportWScalingEnableNV: ProcCmdSetViewportWScalingEnableNV +CmdSetViewportWScalingNV: ProcCmdSetViewportWScalingNV +CmdSetViewportWithCount: ProcCmdSetViewportWithCount +CmdSetViewportWithCountEXT: ProcCmdSetViewportWithCountEXT +CmdSubpassShadingHUAWEI: ProcCmdSubpassShadingHUAWEI +CmdTraceRaysIndirect2KHR: ProcCmdTraceRaysIndirect2KHR +CmdTraceRaysIndirectKHR: ProcCmdTraceRaysIndirectKHR +CmdTraceRaysKHR: ProcCmdTraceRaysKHR +CmdTraceRaysNV: ProcCmdTraceRaysNV +CmdUpdateBuffer: ProcCmdUpdateBuffer +CmdWaitEvents: ProcCmdWaitEvents +CmdWaitEvents2: ProcCmdWaitEvents2 +CmdWaitEvents2KHR: ProcCmdWaitEvents2KHR +CmdWriteAccelerationStructuresPropertiesKHR: ProcCmdWriteAccelerationStructuresPropertiesKHR +CmdWriteAccelerationStructuresPropertiesNV: ProcCmdWriteAccelerationStructuresPropertiesNV +CmdWriteBufferMarker2AMD: ProcCmdWriteBufferMarker2AMD +CmdWriteBufferMarkerAMD: ProcCmdWriteBufferMarkerAMD +CmdWriteMicromapsPropertiesEXT: ProcCmdWriteMicromapsPropertiesEXT +CmdWriteTimestamp: ProcCmdWriteTimestamp +CmdWriteTimestamp2: ProcCmdWriteTimestamp2 +CmdWriteTimestamp2KHR: ProcCmdWriteTimestamp2KHR +CompileDeferredNV: ProcCompileDeferredNV +CopyAccelerationStructureKHR: ProcCopyAccelerationStructureKHR +CopyAccelerationStructureToMemoryKHR: ProcCopyAccelerationStructureToMemoryKHR +CopyMemoryToAccelerationStructureKHR: ProcCopyMemoryToAccelerationStructureKHR +CopyMemoryToMicromapEXT: ProcCopyMemoryToMicromapEXT +CopyMicromapEXT: ProcCopyMicromapEXT +CopyMicromapToMemoryEXT: ProcCopyMicromapToMemoryEXT +CreateAccelerationStructureKHR: ProcCreateAccelerationStructureKHR +CreateAccelerationStructureNV: ProcCreateAccelerationStructureNV +CreateBuffer: ProcCreateBuffer +CreateBufferView: ProcCreateBufferView +CreateCommandPool: ProcCreateCommandPool +CreateComputePipelines: ProcCreateComputePipelines +CreateCuFunctionNVX: ProcCreateCuFunctionNVX +CreateCuModuleNVX: ProcCreateCuModuleNVX +CreateDeferredOperationKHR: ProcCreateDeferredOperationKHR +CreateDescriptorPool: ProcCreateDescriptorPool +CreateDescriptorSetLayout: ProcCreateDescriptorSetLayout +CreateDescriptorUpdateTemplate: ProcCreateDescriptorUpdateTemplate +CreateDescriptorUpdateTemplateKHR: ProcCreateDescriptorUpdateTemplateKHR +CreateEvent: ProcCreateEvent +CreateFence: ProcCreateFence +CreateFramebuffer: ProcCreateFramebuffer +CreateGraphicsPipelines: ProcCreateGraphicsPipelines +CreateImage: ProcCreateImage +CreateImageView: ProcCreateImageView +CreateIndirectCommandsLayoutNV: ProcCreateIndirectCommandsLayoutNV +CreateMicromapEXT: ProcCreateMicromapEXT +CreateOpticalFlowSessionNV: ProcCreateOpticalFlowSessionNV +CreatePipelineCache: ProcCreatePipelineCache +CreatePipelineLayout: ProcCreatePipelineLayout +CreatePrivateDataSlot: ProcCreatePrivateDataSlot +CreatePrivateDataSlotEXT: ProcCreatePrivateDataSlotEXT +CreateQueryPool: ProcCreateQueryPool +CreateRayTracingPipelinesKHR: ProcCreateRayTracingPipelinesKHR +CreateRayTracingPipelinesNV: ProcCreateRayTracingPipelinesNV +CreateRenderPass: ProcCreateRenderPass +CreateRenderPass2: ProcCreateRenderPass2 +CreateRenderPass2KHR: ProcCreateRenderPass2KHR +CreateSampler: ProcCreateSampler +CreateSamplerYcbcrConversion: ProcCreateSamplerYcbcrConversion +CreateSamplerYcbcrConversionKHR: ProcCreateSamplerYcbcrConversionKHR +CreateSemaphore: ProcCreateSemaphore +CreateShaderModule: ProcCreateShaderModule +CreateShadersEXT: ProcCreateShadersEXT +CreateSharedSwapchainsKHR: ProcCreateSharedSwapchainsKHR +CreateSwapchainKHR: ProcCreateSwapchainKHR +CreateValidationCacheEXT: ProcCreateValidationCacheEXT +CreateVideoSessionKHR: ProcCreateVideoSessionKHR +CreateVideoSessionParametersKHR: ProcCreateVideoSessionParametersKHR +DebugMarkerSetObjectNameEXT: ProcDebugMarkerSetObjectNameEXT +DebugMarkerSetObjectTagEXT: ProcDebugMarkerSetObjectTagEXT +DeferredOperationJoinKHR: ProcDeferredOperationJoinKHR +DestroyAccelerationStructureKHR: ProcDestroyAccelerationStructureKHR +DestroyAccelerationStructureNV: ProcDestroyAccelerationStructureNV +DestroyBuffer: ProcDestroyBuffer +DestroyBufferView: ProcDestroyBufferView +DestroyCommandPool: ProcDestroyCommandPool +DestroyCuFunctionNVX: ProcDestroyCuFunctionNVX +DestroyCuModuleNVX: ProcDestroyCuModuleNVX +DestroyDeferredOperationKHR: ProcDestroyDeferredOperationKHR +DestroyDescriptorPool: ProcDestroyDescriptorPool +DestroyDescriptorSetLayout: ProcDestroyDescriptorSetLayout +DestroyDescriptorUpdateTemplate: ProcDestroyDescriptorUpdateTemplate +DestroyDescriptorUpdateTemplateKHR: ProcDestroyDescriptorUpdateTemplateKHR +DestroyDevice: ProcDestroyDevice +DestroyEvent: ProcDestroyEvent +DestroyFence: ProcDestroyFence +DestroyFramebuffer: ProcDestroyFramebuffer +DestroyImage: ProcDestroyImage +DestroyImageView: ProcDestroyImageView +DestroyIndirectCommandsLayoutNV: ProcDestroyIndirectCommandsLayoutNV +DestroyMicromapEXT: ProcDestroyMicromapEXT +DestroyOpticalFlowSessionNV: ProcDestroyOpticalFlowSessionNV +DestroyPipeline: ProcDestroyPipeline +DestroyPipelineCache: ProcDestroyPipelineCache +DestroyPipelineLayout: ProcDestroyPipelineLayout +DestroyPrivateDataSlot: ProcDestroyPrivateDataSlot +DestroyPrivateDataSlotEXT: ProcDestroyPrivateDataSlotEXT +DestroyQueryPool: ProcDestroyQueryPool +DestroyRenderPass: ProcDestroyRenderPass +DestroySampler: ProcDestroySampler +DestroySamplerYcbcrConversion: ProcDestroySamplerYcbcrConversion +DestroySamplerYcbcrConversionKHR: ProcDestroySamplerYcbcrConversionKHR +DestroySemaphore: ProcDestroySemaphore +DestroyShaderEXT: ProcDestroyShaderEXT +DestroyShaderModule: ProcDestroyShaderModule +DestroySwapchainKHR: ProcDestroySwapchainKHR +DestroyValidationCacheEXT: ProcDestroyValidationCacheEXT +DestroyVideoSessionKHR: ProcDestroyVideoSessionKHR +DestroyVideoSessionParametersKHR: ProcDestroyVideoSessionParametersKHR +DeviceWaitIdle: ProcDeviceWaitIdle +DisplayPowerControlEXT: ProcDisplayPowerControlEXT +EndCommandBuffer: ProcEndCommandBuffer +ExportMetalObjectsEXT: ProcExportMetalObjectsEXT +FlushMappedMemoryRanges: ProcFlushMappedMemoryRanges +FreeCommandBuffers: ProcFreeCommandBuffers +FreeDescriptorSets: ProcFreeDescriptorSets +FreeMemory: ProcFreeMemory +GetAccelerationStructureBuildSizesKHR: ProcGetAccelerationStructureBuildSizesKHR +GetAccelerationStructureDeviceAddressKHR: ProcGetAccelerationStructureDeviceAddressKHR +GetAccelerationStructureHandleNV: ProcGetAccelerationStructureHandleNV +GetAccelerationStructureMemoryRequirementsNV: ProcGetAccelerationStructureMemoryRequirementsNV +GetAccelerationStructureOpaqueCaptureDescriptorDataEXT: ProcGetAccelerationStructureOpaqueCaptureDescriptorDataEXT +GetBufferDeviceAddress: ProcGetBufferDeviceAddress +GetBufferDeviceAddressEXT: ProcGetBufferDeviceAddressEXT +GetBufferDeviceAddressKHR: ProcGetBufferDeviceAddressKHR +GetBufferMemoryRequirements: ProcGetBufferMemoryRequirements +GetBufferMemoryRequirements2: ProcGetBufferMemoryRequirements2 +GetBufferMemoryRequirements2KHR: ProcGetBufferMemoryRequirements2KHR +GetBufferOpaqueCaptureAddress: ProcGetBufferOpaqueCaptureAddress +GetBufferOpaqueCaptureAddressKHR: ProcGetBufferOpaqueCaptureAddressKHR +GetBufferOpaqueCaptureDescriptorDataEXT: ProcGetBufferOpaqueCaptureDescriptorDataEXT +GetCalibratedTimestampsEXT: ProcGetCalibratedTimestampsEXT +GetDeferredOperationMaxConcurrencyKHR: ProcGetDeferredOperationMaxConcurrencyKHR +GetDeferredOperationResultKHR: ProcGetDeferredOperationResultKHR +GetDescriptorEXT: ProcGetDescriptorEXT +GetDescriptorSetHostMappingVALVE: ProcGetDescriptorSetHostMappingVALVE +GetDescriptorSetLayoutBindingOffsetEXT: ProcGetDescriptorSetLayoutBindingOffsetEXT +GetDescriptorSetLayoutHostMappingInfoVALVE: ProcGetDescriptorSetLayoutHostMappingInfoVALVE +GetDescriptorSetLayoutSizeEXT: ProcGetDescriptorSetLayoutSizeEXT +GetDescriptorSetLayoutSupport: ProcGetDescriptorSetLayoutSupport +GetDescriptorSetLayoutSupportKHR: ProcGetDescriptorSetLayoutSupportKHR +GetDeviceAccelerationStructureCompatibilityKHR: ProcGetDeviceAccelerationStructureCompatibilityKHR +GetDeviceBufferMemoryRequirements: ProcGetDeviceBufferMemoryRequirements +GetDeviceBufferMemoryRequirementsKHR: ProcGetDeviceBufferMemoryRequirementsKHR +GetDeviceFaultInfoEXT: ProcGetDeviceFaultInfoEXT +GetDeviceGroupPeerMemoryFeatures: ProcGetDeviceGroupPeerMemoryFeatures +GetDeviceGroupPeerMemoryFeaturesKHR: ProcGetDeviceGroupPeerMemoryFeaturesKHR +GetDeviceGroupPresentCapabilitiesKHR: ProcGetDeviceGroupPresentCapabilitiesKHR +GetDeviceGroupSurfacePresentModes2EXT: ProcGetDeviceGroupSurfacePresentModes2EXT +GetDeviceGroupSurfacePresentModesKHR: ProcGetDeviceGroupSurfacePresentModesKHR +GetDeviceImageMemoryRequirements: ProcGetDeviceImageMemoryRequirements +GetDeviceImageMemoryRequirementsKHR: ProcGetDeviceImageMemoryRequirementsKHR +GetDeviceImageSparseMemoryRequirements: ProcGetDeviceImageSparseMemoryRequirements +GetDeviceImageSparseMemoryRequirementsKHR: ProcGetDeviceImageSparseMemoryRequirementsKHR +GetDeviceMemoryCommitment: ProcGetDeviceMemoryCommitment +GetDeviceMemoryOpaqueCaptureAddress: ProcGetDeviceMemoryOpaqueCaptureAddress +GetDeviceMemoryOpaqueCaptureAddressKHR: ProcGetDeviceMemoryOpaqueCaptureAddressKHR +GetDeviceMicromapCompatibilityEXT: ProcGetDeviceMicromapCompatibilityEXT +GetDeviceProcAddr: ProcGetDeviceProcAddr +GetDeviceQueue: ProcGetDeviceQueue +GetDeviceQueue2: ProcGetDeviceQueue2 +GetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI: ProcGetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI +GetDynamicRenderingTilePropertiesQCOM: ProcGetDynamicRenderingTilePropertiesQCOM +GetEventStatus: ProcGetEventStatus +GetFenceFdKHR: ProcGetFenceFdKHR +GetFenceStatus: ProcGetFenceStatus +GetFenceWin32HandleKHR: ProcGetFenceWin32HandleKHR +GetFramebufferTilePropertiesQCOM: ProcGetFramebufferTilePropertiesQCOM +GetGeneratedCommandsMemoryRequirementsNV: ProcGetGeneratedCommandsMemoryRequirementsNV +GetImageDrmFormatModifierPropertiesEXT: ProcGetImageDrmFormatModifierPropertiesEXT +GetImageMemoryRequirements: ProcGetImageMemoryRequirements +GetImageMemoryRequirements2: ProcGetImageMemoryRequirements2 +GetImageMemoryRequirements2KHR: ProcGetImageMemoryRequirements2KHR +GetImageOpaqueCaptureDescriptorDataEXT: ProcGetImageOpaqueCaptureDescriptorDataEXT +GetImageSparseMemoryRequirements: ProcGetImageSparseMemoryRequirements +GetImageSparseMemoryRequirements2: ProcGetImageSparseMemoryRequirements2 +GetImageSparseMemoryRequirements2KHR: ProcGetImageSparseMemoryRequirements2KHR +GetImageSubresourceLayout: ProcGetImageSubresourceLayout +GetImageSubresourceLayout2EXT: ProcGetImageSubresourceLayout2EXT +GetImageViewAddressNVX: ProcGetImageViewAddressNVX +GetImageViewHandleNVX: ProcGetImageViewHandleNVX +GetImageViewOpaqueCaptureDescriptorDataEXT: ProcGetImageViewOpaqueCaptureDescriptorDataEXT +GetMemoryFdKHR: ProcGetMemoryFdKHR +GetMemoryFdPropertiesKHR: ProcGetMemoryFdPropertiesKHR +GetMemoryHostPointerPropertiesEXT: ProcGetMemoryHostPointerPropertiesEXT +GetMemoryRemoteAddressNV: ProcGetMemoryRemoteAddressNV +GetMemoryWin32HandleKHR: ProcGetMemoryWin32HandleKHR +GetMemoryWin32HandleNV: ProcGetMemoryWin32HandleNV +GetMemoryWin32HandlePropertiesKHR: ProcGetMemoryWin32HandlePropertiesKHR +GetMicromapBuildSizesEXT: ProcGetMicromapBuildSizesEXT +GetPastPresentationTimingGOOGLE: ProcGetPastPresentationTimingGOOGLE +GetPerformanceParameterINTEL: ProcGetPerformanceParameterINTEL +GetPipelineCacheData: ProcGetPipelineCacheData +GetPipelineExecutableInternalRepresentationsKHR: ProcGetPipelineExecutableInternalRepresentationsKHR +GetPipelineExecutablePropertiesKHR: ProcGetPipelineExecutablePropertiesKHR +GetPipelineExecutableStatisticsKHR: ProcGetPipelineExecutableStatisticsKHR +GetPipelinePropertiesEXT: ProcGetPipelinePropertiesEXT +GetPrivateData: ProcGetPrivateData +GetPrivateDataEXT: ProcGetPrivateDataEXT +GetQueryPoolResults: ProcGetQueryPoolResults +GetQueueCheckpointData2NV: ProcGetQueueCheckpointData2NV +GetQueueCheckpointDataNV: ProcGetQueueCheckpointDataNV +GetRayTracingCaptureReplayShaderGroupHandlesKHR: ProcGetRayTracingCaptureReplayShaderGroupHandlesKHR +GetRayTracingShaderGroupHandlesKHR: ProcGetRayTracingShaderGroupHandlesKHR +GetRayTracingShaderGroupHandlesNV: ProcGetRayTracingShaderGroupHandlesNV +GetRayTracingShaderGroupStackSizeKHR: ProcGetRayTracingShaderGroupStackSizeKHR +GetRefreshCycleDurationGOOGLE: ProcGetRefreshCycleDurationGOOGLE +GetRenderAreaGranularity: ProcGetRenderAreaGranularity +GetSamplerOpaqueCaptureDescriptorDataEXT: ProcGetSamplerOpaqueCaptureDescriptorDataEXT +GetSemaphoreCounterValue: ProcGetSemaphoreCounterValue +GetSemaphoreCounterValueKHR: ProcGetSemaphoreCounterValueKHR +GetSemaphoreFdKHR: ProcGetSemaphoreFdKHR +GetSemaphoreWin32HandleKHR: ProcGetSemaphoreWin32HandleKHR +GetShaderBinaryDataEXT: ProcGetShaderBinaryDataEXT +GetShaderInfoAMD: ProcGetShaderInfoAMD +GetShaderModuleCreateInfoIdentifierEXT: ProcGetShaderModuleCreateInfoIdentifierEXT +GetShaderModuleIdentifierEXT: ProcGetShaderModuleIdentifierEXT +GetSwapchainCounterEXT: ProcGetSwapchainCounterEXT +GetSwapchainImagesKHR: ProcGetSwapchainImagesKHR +GetSwapchainStatusKHR: ProcGetSwapchainStatusKHR +GetValidationCacheDataEXT: ProcGetValidationCacheDataEXT +GetVideoSessionMemoryRequirementsKHR: ProcGetVideoSessionMemoryRequirementsKHR +ImportFenceFdKHR: ProcImportFenceFdKHR +ImportFenceWin32HandleKHR: ProcImportFenceWin32HandleKHR +ImportSemaphoreFdKHR: ProcImportSemaphoreFdKHR +ImportSemaphoreWin32HandleKHR: ProcImportSemaphoreWin32HandleKHR +InitializePerformanceApiINTEL: ProcInitializePerformanceApiINTEL +InvalidateMappedMemoryRanges: ProcInvalidateMappedMemoryRanges +MapMemory: ProcMapMemory +MapMemory2KHR: ProcMapMemory2KHR +MergePipelineCaches: ProcMergePipelineCaches +MergeValidationCachesEXT: ProcMergeValidationCachesEXT +QueueBeginDebugUtilsLabelEXT: ProcQueueBeginDebugUtilsLabelEXT +QueueBindSparse: ProcQueueBindSparse +QueueEndDebugUtilsLabelEXT: ProcQueueEndDebugUtilsLabelEXT +QueueInsertDebugUtilsLabelEXT: ProcQueueInsertDebugUtilsLabelEXT +QueuePresentKHR: ProcQueuePresentKHR +QueueSetPerformanceConfigurationINTEL: ProcQueueSetPerformanceConfigurationINTEL +QueueSubmit: ProcQueueSubmit +QueueSubmit2: ProcQueueSubmit2 +QueueSubmit2KHR: ProcQueueSubmit2KHR +QueueWaitIdle: ProcQueueWaitIdle +RegisterDeviceEventEXT: ProcRegisterDeviceEventEXT +RegisterDisplayEventEXT: ProcRegisterDisplayEventEXT +ReleaseFullScreenExclusiveModeEXT: ProcReleaseFullScreenExclusiveModeEXT +ReleasePerformanceConfigurationINTEL: ProcReleasePerformanceConfigurationINTEL +ReleaseProfilingLockKHR: ProcReleaseProfilingLockKHR +ReleaseSwapchainImagesEXT: ProcReleaseSwapchainImagesEXT +ResetCommandBuffer: ProcResetCommandBuffer +ResetCommandPool: ProcResetCommandPool +ResetDescriptorPool: ProcResetDescriptorPool +ResetEvent: ProcResetEvent +ResetFences: ProcResetFences +ResetQueryPool: ProcResetQueryPool +ResetQueryPoolEXT: ProcResetQueryPoolEXT +SetDebugUtilsObjectNameEXT: ProcSetDebugUtilsObjectNameEXT +SetDebugUtilsObjectTagEXT: ProcSetDebugUtilsObjectTagEXT +SetDeviceMemoryPriorityEXT: ProcSetDeviceMemoryPriorityEXT +SetEvent: ProcSetEvent +SetHdrMetadataEXT: ProcSetHdrMetadataEXT +SetLocalDimmingAMD: ProcSetLocalDimmingAMD +SetPrivateData: ProcSetPrivateData +SetPrivateDataEXT: ProcSetPrivateDataEXT +SignalSemaphore: ProcSignalSemaphore +SignalSemaphoreKHR: ProcSignalSemaphoreKHR +TrimCommandPool: ProcTrimCommandPool +TrimCommandPoolKHR: ProcTrimCommandPoolKHR +UninitializePerformanceApiINTEL: ProcUninitializePerformanceApiINTEL +UnmapMemory: ProcUnmapMemory +UnmapMemory2KHR: ProcUnmapMemory2KHR +UpdateDescriptorSetWithTemplate: ProcUpdateDescriptorSetWithTemplate +UpdateDescriptorSetWithTemplateKHR: ProcUpdateDescriptorSetWithTemplateKHR +UpdateDescriptorSets: ProcUpdateDescriptorSets +UpdateVideoSessionParametersKHR: ProcUpdateVideoSessionParametersKHR +WaitForFences: ProcWaitForFences +WaitForPresentKHR: ProcWaitForPresentKHR +WaitSemaphores: ProcWaitSemaphores +WaitSemaphoresKHR: ProcWaitSemaphoresKHR +WriteAccelerationStructuresPropertiesKHR: ProcWriteAccelerationStructuresPropertiesKHR +WriteMicromapsPropertiesEXT: ProcWriteMicromapsPropertiesEXT + +load_proc_addresses_custom :: proc(set_proc_address: SetProcAddressType) { + // Loader Procedures + set_proc_address(&CreateInstance, "vkCreateInstance") + set_proc_address(&DebugUtilsMessengerCallbackEXT, "vkDebugUtilsMessengerCallbackEXT") + set_proc_address(&DeviceMemoryReportCallbackEXT, "vkDeviceMemoryReportCallbackEXT") + set_proc_address(&EnumerateInstanceExtensionProperties, "vkEnumerateInstanceExtensionProperties") + set_proc_address(&EnumerateInstanceLayerProperties, "vkEnumerateInstanceLayerProperties") + set_proc_address(&EnumerateInstanceVersion, "vkEnumerateInstanceVersion") + set_proc_address(&GetInstanceProcAddr, "vkGetInstanceProcAddr") + + // Instance Procedures + set_proc_address(&AcquireDrmDisplayEXT, "vkAcquireDrmDisplayEXT") + set_proc_address(&AcquireWinrtDisplayNV, "vkAcquireWinrtDisplayNV") + set_proc_address(&CreateDebugReportCallbackEXT, "vkCreateDebugReportCallbackEXT") + set_proc_address(&CreateDebugUtilsMessengerEXT, "vkCreateDebugUtilsMessengerEXT") + set_proc_address(&CreateDevice, "vkCreateDevice") + set_proc_address(&CreateDisplayModeKHR, "vkCreateDisplayModeKHR") + set_proc_address(&CreateDisplayPlaneSurfaceKHR, "vkCreateDisplayPlaneSurfaceKHR") + set_proc_address(&CreateHeadlessSurfaceEXT, "vkCreateHeadlessSurfaceEXT") + set_proc_address(&CreateIOSSurfaceMVK, "vkCreateIOSSurfaceMVK") + set_proc_address(&CreateMacOSSurfaceMVK, "vkCreateMacOSSurfaceMVK") + set_proc_address(&CreateMetalSurfaceEXT, "vkCreateMetalSurfaceEXT") + set_proc_address(&CreateWaylandSurfaceKHR, "vkCreateWaylandSurfaceKHR") + set_proc_address(&CreateWin32SurfaceKHR, "vkCreateWin32SurfaceKHR") + set_proc_address(&DebugReportMessageEXT, "vkDebugReportMessageEXT") + set_proc_address(&DestroyDebugReportCallbackEXT, "vkDestroyDebugReportCallbackEXT") + set_proc_address(&DestroyDebugUtilsMessengerEXT, "vkDestroyDebugUtilsMessengerEXT") + set_proc_address(&DestroyInstance, "vkDestroyInstance") + set_proc_address(&DestroySurfaceKHR, "vkDestroySurfaceKHR") + set_proc_address(&EnumerateDeviceExtensionProperties, "vkEnumerateDeviceExtensionProperties") + set_proc_address(&EnumerateDeviceLayerProperties, "vkEnumerateDeviceLayerProperties") + set_proc_address(&EnumeratePhysicalDeviceGroups, "vkEnumeratePhysicalDeviceGroups") + set_proc_address(&EnumeratePhysicalDeviceGroupsKHR, "vkEnumeratePhysicalDeviceGroupsKHR") + set_proc_address(&EnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR, "vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR") + set_proc_address(&EnumeratePhysicalDevices, "vkEnumeratePhysicalDevices") + set_proc_address(&GetDisplayModeProperties2KHR, "vkGetDisplayModeProperties2KHR") + set_proc_address(&GetDisplayModePropertiesKHR, "vkGetDisplayModePropertiesKHR") + set_proc_address(&GetDisplayPlaneCapabilities2KHR, "vkGetDisplayPlaneCapabilities2KHR") + set_proc_address(&GetDisplayPlaneCapabilitiesKHR, "vkGetDisplayPlaneCapabilitiesKHR") + set_proc_address(&GetDisplayPlaneSupportedDisplaysKHR, "vkGetDisplayPlaneSupportedDisplaysKHR") + set_proc_address(&GetDrmDisplayEXT, "vkGetDrmDisplayEXT") + set_proc_address(&GetInstanceProcAddrLUNARG, "vkGetInstanceProcAddrLUNARG") + set_proc_address(&GetPhysicalDeviceCalibrateableTimeDomainsEXT, "vkGetPhysicalDeviceCalibrateableTimeDomainsEXT") + set_proc_address(&GetPhysicalDeviceCooperativeMatrixPropertiesNV, "vkGetPhysicalDeviceCooperativeMatrixPropertiesNV") + set_proc_address(&GetPhysicalDeviceDisplayPlaneProperties2KHR, "vkGetPhysicalDeviceDisplayPlaneProperties2KHR") + set_proc_address(&GetPhysicalDeviceDisplayPlanePropertiesKHR, "vkGetPhysicalDeviceDisplayPlanePropertiesKHR") + set_proc_address(&GetPhysicalDeviceDisplayProperties2KHR, "vkGetPhysicalDeviceDisplayProperties2KHR") + set_proc_address(&GetPhysicalDeviceDisplayPropertiesKHR, "vkGetPhysicalDeviceDisplayPropertiesKHR") + set_proc_address(&GetPhysicalDeviceExternalBufferProperties, "vkGetPhysicalDeviceExternalBufferProperties") + set_proc_address(&GetPhysicalDeviceExternalBufferPropertiesKHR, "vkGetPhysicalDeviceExternalBufferPropertiesKHR") + set_proc_address(&GetPhysicalDeviceExternalFenceProperties, "vkGetPhysicalDeviceExternalFenceProperties") + set_proc_address(&GetPhysicalDeviceExternalFencePropertiesKHR, "vkGetPhysicalDeviceExternalFencePropertiesKHR") + set_proc_address(&GetPhysicalDeviceExternalImageFormatPropertiesNV, "vkGetPhysicalDeviceExternalImageFormatPropertiesNV") + set_proc_address(&GetPhysicalDeviceExternalSemaphoreProperties, "vkGetPhysicalDeviceExternalSemaphoreProperties") + set_proc_address(&GetPhysicalDeviceExternalSemaphorePropertiesKHR, "vkGetPhysicalDeviceExternalSemaphorePropertiesKHR") + set_proc_address(&GetPhysicalDeviceFeatures, "vkGetPhysicalDeviceFeatures") + set_proc_address(&GetPhysicalDeviceFeatures2, "vkGetPhysicalDeviceFeatures2") + set_proc_address(&GetPhysicalDeviceFeatures2KHR, "vkGetPhysicalDeviceFeatures2KHR") + set_proc_address(&GetPhysicalDeviceFormatProperties, "vkGetPhysicalDeviceFormatProperties") + set_proc_address(&GetPhysicalDeviceFormatProperties2, "vkGetPhysicalDeviceFormatProperties2") + set_proc_address(&GetPhysicalDeviceFormatProperties2KHR, "vkGetPhysicalDeviceFormatProperties2KHR") + set_proc_address(&GetPhysicalDeviceFragmentShadingRatesKHR, "vkGetPhysicalDeviceFragmentShadingRatesKHR") + set_proc_address(&GetPhysicalDeviceImageFormatProperties, "vkGetPhysicalDeviceImageFormatProperties") + set_proc_address(&GetPhysicalDeviceImageFormatProperties2, "vkGetPhysicalDeviceImageFormatProperties2") + set_proc_address(&GetPhysicalDeviceImageFormatProperties2KHR, "vkGetPhysicalDeviceImageFormatProperties2KHR") + set_proc_address(&GetPhysicalDeviceMemoryProperties, "vkGetPhysicalDeviceMemoryProperties") + set_proc_address(&GetPhysicalDeviceMemoryProperties2, "vkGetPhysicalDeviceMemoryProperties2") + set_proc_address(&GetPhysicalDeviceMemoryProperties2KHR, "vkGetPhysicalDeviceMemoryProperties2KHR") + set_proc_address(&GetPhysicalDeviceMultisamplePropertiesEXT, "vkGetPhysicalDeviceMultisamplePropertiesEXT") + set_proc_address(&GetPhysicalDeviceOpticalFlowImageFormatsNV, "vkGetPhysicalDeviceOpticalFlowImageFormatsNV") + set_proc_address(&GetPhysicalDevicePresentRectanglesKHR, "vkGetPhysicalDevicePresentRectanglesKHR") + set_proc_address(&GetPhysicalDeviceProperties, "vkGetPhysicalDeviceProperties") + set_proc_address(&GetPhysicalDeviceProperties2, "vkGetPhysicalDeviceProperties2") + set_proc_address(&GetPhysicalDeviceProperties2KHR, "vkGetPhysicalDeviceProperties2KHR") + set_proc_address(&GetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR, "vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR") + set_proc_address(&GetPhysicalDeviceQueueFamilyProperties, "vkGetPhysicalDeviceQueueFamilyProperties") + set_proc_address(&GetPhysicalDeviceQueueFamilyProperties2, "vkGetPhysicalDeviceQueueFamilyProperties2") + set_proc_address(&GetPhysicalDeviceQueueFamilyProperties2KHR, "vkGetPhysicalDeviceQueueFamilyProperties2KHR") + set_proc_address(&GetPhysicalDeviceSparseImageFormatProperties, "vkGetPhysicalDeviceSparseImageFormatProperties") + set_proc_address(&GetPhysicalDeviceSparseImageFormatProperties2, "vkGetPhysicalDeviceSparseImageFormatProperties2") + set_proc_address(&GetPhysicalDeviceSparseImageFormatProperties2KHR, "vkGetPhysicalDeviceSparseImageFormatProperties2KHR") + set_proc_address(&GetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV, "vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV") + set_proc_address(&GetPhysicalDeviceSurfaceCapabilities2EXT, "vkGetPhysicalDeviceSurfaceCapabilities2EXT") + set_proc_address(&GetPhysicalDeviceSurfaceCapabilities2KHR, "vkGetPhysicalDeviceSurfaceCapabilities2KHR") + set_proc_address(&GetPhysicalDeviceSurfaceCapabilitiesKHR, "vkGetPhysicalDeviceSurfaceCapabilitiesKHR") + set_proc_address(&GetPhysicalDeviceSurfaceFormats2KHR, "vkGetPhysicalDeviceSurfaceFormats2KHR") + set_proc_address(&GetPhysicalDeviceSurfaceFormatsKHR, "vkGetPhysicalDeviceSurfaceFormatsKHR") + set_proc_address(&GetPhysicalDeviceSurfacePresentModes2EXT, "vkGetPhysicalDeviceSurfacePresentModes2EXT") + set_proc_address(&GetPhysicalDeviceSurfacePresentModesKHR, "vkGetPhysicalDeviceSurfacePresentModesKHR") + set_proc_address(&GetPhysicalDeviceSurfaceSupportKHR, "vkGetPhysicalDeviceSurfaceSupportKHR") + set_proc_address(&GetPhysicalDeviceToolProperties, "vkGetPhysicalDeviceToolProperties") + set_proc_address(&GetPhysicalDeviceToolPropertiesEXT, "vkGetPhysicalDeviceToolPropertiesEXT") + set_proc_address(&GetPhysicalDeviceVideoCapabilitiesKHR, "vkGetPhysicalDeviceVideoCapabilitiesKHR") + set_proc_address(&GetPhysicalDeviceVideoFormatPropertiesKHR, "vkGetPhysicalDeviceVideoFormatPropertiesKHR") + set_proc_address(&GetPhysicalDeviceWaylandPresentationSupportKHR, "vkGetPhysicalDeviceWaylandPresentationSupportKHR") + set_proc_address(&GetPhysicalDeviceWin32PresentationSupportKHR, "vkGetPhysicalDeviceWin32PresentationSupportKHR") + set_proc_address(&GetWinrtDisplayNV, "vkGetWinrtDisplayNV") + set_proc_address(&ReleaseDisplayEXT, "vkReleaseDisplayEXT") + set_proc_address(&SubmitDebugUtilsMessageEXT, "vkSubmitDebugUtilsMessageEXT") + + // Device Procedures + set_proc_address(&AcquireFullScreenExclusiveModeEXT, "vkAcquireFullScreenExclusiveModeEXT") + set_proc_address(&AcquireNextImage2KHR, "vkAcquireNextImage2KHR") + set_proc_address(&AcquireNextImageKHR, "vkAcquireNextImageKHR") + set_proc_address(&AcquirePerformanceConfigurationINTEL, "vkAcquirePerformanceConfigurationINTEL") + set_proc_address(&AcquireProfilingLockKHR, "vkAcquireProfilingLockKHR") + set_proc_address(&AllocateCommandBuffers, "vkAllocateCommandBuffers") + set_proc_address(&AllocateDescriptorSets, "vkAllocateDescriptorSets") + set_proc_address(&AllocateMemory, "vkAllocateMemory") + set_proc_address(&BeginCommandBuffer, "vkBeginCommandBuffer") + set_proc_address(&BindAccelerationStructureMemoryNV, "vkBindAccelerationStructureMemoryNV") + set_proc_address(&BindBufferMemory, "vkBindBufferMemory") + set_proc_address(&BindBufferMemory2, "vkBindBufferMemory2") + set_proc_address(&BindBufferMemory2KHR, "vkBindBufferMemory2KHR") + set_proc_address(&BindImageMemory, "vkBindImageMemory") + set_proc_address(&BindImageMemory2, "vkBindImageMemory2") + set_proc_address(&BindImageMemory2KHR, "vkBindImageMemory2KHR") + set_proc_address(&BindOpticalFlowSessionImageNV, "vkBindOpticalFlowSessionImageNV") + set_proc_address(&BindVideoSessionMemoryKHR, "vkBindVideoSessionMemoryKHR") + set_proc_address(&BuildAccelerationStructuresKHR, "vkBuildAccelerationStructuresKHR") + set_proc_address(&BuildMicromapsEXT, "vkBuildMicromapsEXT") + set_proc_address(&CmdBeginConditionalRenderingEXT, "vkCmdBeginConditionalRenderingEXT") + set_proc_address(&CmdBeginDebugUtilsLabelEXT, "vkCmdBeginDebugUtilsLabelEXT") + set_proc_address(&CmdBeginQuery, "vkCmdBeginQuery") + set_proc_address(&CmdBeginQueryIndexedEXT, "vkCmdBeginQueryIndexedEXT") + set_proc_address(&CmdBeginRenderPass, "vkCmdBeginRenderPass") + set_proc_address(&CmdBeginRenderPass2, "vkCmdBeginRenderPass2") + set_proc_address(&CmdBeginRenderPass2KHR, "vkCmdBeginRenderPass2KHR") + set_proc_address(&CmdBeginRendering, "vkCmdBeginRendering") + set_proc_address(&CmdBeginRenderingKHR, "vkCmdBeginRenderingKHR") + set_proc_address(&CmdBeginTransformFeedbackEXT, "vkCmdBeginTransformFeedbackEXT") + set_proc_address(&CmdBeginVideoCodingKHR, "vkCmdBeginVideoCodingKHR") + set_proc_address(&CmdBindDescriptorBufferEmbeddedSamplersEXT, "vkCmdBindDescriptorBufferEmbeddedSamplersEXT") + set_proc_address(&CmdBindDescriptorBuffersEXT, "vkCmdBindDescriptorBuffersEXT") + set_proc_address(&CmdBindDescriptorSets, "vkCmdBindDescriptorSets") + set_proc_address(&CmdBindIndexBuffer, "vkCmdBindIndexBuffer") + set_proc_address(&CmdBindInvocationMaskHUAWEI, "vkCmdBindInvocationMaskHUAWEI") + set_proc_address(&CmdBindPipeline, "vkCmdBindPipeline") + set_proc_address(&CmdBindPipelineShaderGroupNV, "vkCmdBindPipelineShaderGroupNV") + set_proc_address(&CmdBindShadersEXT, "vkCmdBindShadersEXT") + set_proc_address(&CmdBindShadingRateImageNV, "vkCmdBindShadingRateImageNV") + set_proc_address(&CmdBindTransformFeedbackBuffersEXT, "vkCmdBindTransformFeedbackBuffersEXT") + set_proc_address(&CmdBindVertexBuffers, "vkCmdBindVertexBuffers") + set_proc_address(&CmdBindVertexBuffers2, "vkCmdBindVertexBuffers2") + set_proc_address(&CmdBindVertexBuffers2EXT, "vkCmdBindVertexBuffers2EXT") + set_proc_address(&CmdBlitImage, "vkCmdBlitImage") + set_proc_address(&CmdBlitImage2, "vkCmdBlitImage2") + set_proc_address(&CmdBlitImage2KHR, "vkCmdBlitImage2KHR") + set_proc_address(&CmdBuildAccelerationStructureNV, "vkCmdBuildAccelerationStructureNV") + set_proc_address(&CmdBuildAccelerationStructuresIndirectKHR, "vkCmdBuildAccelerationStructuresIndirectKHR") + set_proc_address(&CmdBuildAccelerationStructuresKHR, "vkCmdBuildAccelerationStructuresKHR") + set_proc_address(&CmdBuildMicromapsEXT, "vkCmdBuildMicromapsEXT") + set_proc_address(&CmdClearAttachments, "vkCmdClearAttachments") + set_proc_address(&CmdClearColorImage, "vkCmdClearColorImage") + set_proc_address(&CmdClearDepthStencilImage, "vkCmdClearDepthStencilImage") + set_proc_address(&CmdControlVideoCodingKHR, "vkCmdControlVideoCodingKHR") + set_proc_address(&CmdCopyAccelerationStructureKHR, "vkCmdCopyAccelerationStructureKHR") + set_proc_address(&CmdCopyAccelerationStructureNV, "vkCmdCopyAccelerationStructureNV") + set_proc_address(&CmdCopyAccelerationStructureToMemoryKHR, "vkCmdCopyAccelerationStructureToMemoryKHR") + set_proc_address(&CmdCopyBuffer, "vkCmdCopyBuffer") + set_proc_address(&CmdCopyBuffer2, "vkCmdCopyBuffer2") + set_proc_address(&CmdCopyBuffer2KHR, "vkCmdCopyBuffer2KHR") + set_proc_address(&CmdCopyBufferToImage, "vkCmdCopyBufferToImage") + set_proc_address(&CmdCopyBufferToImage2, "vkCmdCopyBufferToImage2") + set_proc_address(&CmdCopyBufferToImage2KHR, "vkCmdCopyBufferToImage2KHR") + set_proc_address(&CmdCopyImage, "vkCmdCopyImage") + set_proc_address(&CmdCopyImage2, "vkCmdCopyImage2") + set_proc_address(&CmdCopyImage2KHR, "vkCmdCopyImage2KHR") + set_proc_address(&CmdCopyImageToBuffer, "vkCmdCopyImageToBuffer") + set_proc_address(&CmdCopyImageToBuffer2, "vkCmdCopyImageToBuffer2") + set_proc_address(&CmdCopyImageToBuffer2KHR, "vkCmdCopyImageToBuffer2KHR") + set_proc_address(&CmdCopyMemoryIndirectNV, "vkCmdCopyMemoryIndirectNV") + set_proc_address(&CmdCopyMemoryToAccelerationStructureKHR, "vkCmdCopyMemoryToAccelerationStructureKHR") + set_proc_address(&CmdCopyMemoryToImageIndirectNV, "vkCmdCopyMemoryToImageIndirectNV") + set_proc_address(&CmdCopyMemoryToMicromapEXT, "vkCmdCopyMemoryToMicromapEXT") + set_proc_address(&CmdCopyMicromapEXT, "vkCmdCopyMicromapEXT") + set_proc_address(&CmdCopyMicromapToMemoryEXT, "vkCmdCopyMicromapToMemoryEXT") + set_proc_address(&CmdCopyQueryPoolResults, "vkCmdCopyQueryPoolResults") + set_proc_address(&CmdCuLaunchKernelNVX, "vkCmdCuLaunchKernelNVX") + set_proc_address(&CmdDebugMarkerBeginEXT, "vkCmdDebugMarkerBeginEXT") + set_proc_address(&CmdDebugMarkerEndEXT, "vkCmdDebugMarkerEndEXT") + set_proc_address(&CmdDebugMarkerInsertEXT, "vkCmdDebugMarkerInsertEXT") + set_proc_address(&CmdDecodeVideoKHR, "vkCmdDecodeVideoKHR") + set_proc_address(&CmdDecompressMemoryIndirectCountNV, "vkCmdDecompressMemoryIndirectCountNV") + set_proc_address(&CmdDecompressMemoryNV, "vkCmdDecompressMemoryNV") + set_proc_address(&CmdDispatch, "vkCmdDispatch") + set_proc_address(&CmdDispatchBase, "vkCmdDispatchBase") + set_proc_address(&CmdDispatchBaseKHR, "vkCmdDispatchBaseKHR") + set_proc_address(&CmdDispatchIndirect, "vkCmdDispatchIndirect") + set_proc_address(&CmdDraw, "vkCmdDraw") + set_proc_address(&CmdDrawClusterHUAWEI, "vkCmdDrawClusterHUAWEI") + set_proc_address(&CmdDrawClusterIndirectHUAWEI, "vkCmdDrawClusterIndirectHUAWEI") + set_proc_address(&CmdDrawIndexed, "vkCmdDrawIndexed") + set_proc_address(&CmdDrawIndexedIndirect, "vkCmdDrawIndexedIndirect") + set_proc_address(&CmdDrawIndexedIndirectCount, "vkCmdDrawIndexedIndirectCount") + set_proc_address(&CmdDrawIndexedIndirectCountAMD, "vkCmdDrawIndexedIndirectCountAMD") + set_proc_address(&CmdDrawIndexedIndirectCountKHR, "vkCmdDrawIndexedIndirectCountKHR") + set_proc_address(&CmdDrawIndirect, "vkCmdDrawIndirect") + set_proc_address(&CmdDrawIndirectByteCountEXT, "vkCmdDrawIndirectByteCountEXT") + set_proc_address(&CmdDrawIndirectCount, "vkCmdDrawIndirectCount") + set_proc_address(&CmdDrawIndirectCountAMD, "vkCmdDrawIndirectCountAMD") + set_proc_address(&CmdDrawIndirectCountKHR, "vkCmdDrawIndirectCountKHR") + set_proc_address(&CmdDrawMeshTasksEXT, "vkCmdDrawMeshTasksEXT") + set_proc_address(&CmdDrawMeshTasksIndirectCountEXT, "vkCmdDrawMeshTasksIndirectCountEXT") + set_proc_address(&CmdDrawMeshTasksIndirectCountNV, "vkCmdDrawMeshTasksIndirectCountNV") + set_proc_address(&CmdDrawMeshTasksIndirectEXT, "vkCmdDrawMeshTasksIndirectEXT") + set_proc_address(&CmdDrawMeshTasksIndirectNV, "vkCmdDrawMeshTasksIndirectNV") + set_proc_address(&CmdDrawMeshTasksNV, "vkCmdDrawMeshTasksNV") + set_proc_address(&CmdDrawMultiEXT, "vkCmdDrawMultiEXT") + set_proc_address(&CmdDrawMultiIndexedEXT, "vkCmdDrawMultiIndexedEXT") + set_proc_address(&CmdEndConditionalRenderingEXT, "vkCmdEndConditionalRenderingEXT") + set_proc_address(&CmdEndDebugUtilsLabelEXT, "vkCmdEndDebugUtilsLabelEXT") + set_proc_address(&CmdEndQuery, "vkCmdEndQuery") + set_proc_address(&CmdEndQueryIndexedEXT, "vkCmdEndQueryIndexedEXT") + set_proc_address(&CmdEndRenderPass, "vkCmdEndRenderPass") + set_proc_address(&CmdEndRenderPass2, "vkCmdEndRenderPass2") + set_proc_address(&CmdEndRenderPass2KHR, "vkCmdEndRenderPass2KHR") + set_proc_address(&CmdEndRendering, "vkCmdEndRendering") + set_proc_address(&CmdEndRenderingKHR, "vkCmdEndRenderingKHR") + set_proc_address(&CmdEndTransformFeedbackEXT, "vkCmdEndTransformFeedbackEXT") + set_proc_address(&CmdEndVideoCodingKHR, "vkCmdEndVideoCodingKHR") + set_proc_address(&CmdExecuteCommands, "vkCmdExecuteCommands") + set_proc_address(&CmdExecuteGeneratedCommandsNV, "vkCmdExecuteGeneratedCommandsNV") + set_proc_address(&CmdFillBuffer, "vkCmdFillBuffer") + set_proc_address(&CmdInsertDebugUtilsLabelEXT, "vkCmdInsertDebugUtilsLabelEXT") + set_proc_address(&CmdNextSubpass, "vkCmdNextSubpass") + set_proc_address(&CmdNextSubpass2, "vkCmdNextSubpass2") + set_proc_address(&CmdNextSubpass2KHR, "vkCmdNextSubpass2KHR") + set_proc_address(&CmdOpticalFlowExecuteNV, "vkCmdOpticalFlowExecuteNV") + set_proc_address(&CmdPipelineBarrier, "vkCmdPipelineBarrier") + set_proc_address(&CmdPipelineBarrier2, "vkCmdPipelineBarrier2") + set_proc_address(&CmdPipelineBarrier2KHR, "vkCmdPipelineBarrier2KHR") + set_proc_address(&CmdPreprocessGeneratedCommandsNV, "vkCmdPreprocessGeneratedCommandsNV") + set_proc_address(&CmdPushConstants, "vkCmdPushConstants") + set_proc_address(&CmdPushDescriptorSetKHR, "vkCmdPushDescriptorSetKHR") + set_proc_address(&CmdPushDescriptorSetWithTemplateKHR, "vkCmdPushDescriptorSetWithTemplateKHR") + set_proc_address(&CmdResetEvent, "vkCmdResetEvent") + set_proc_address(&CmdResetEvent2, "vkCmdResetEvent2") + set_proc_address(&CmdResetEvent2KHR, "vkCmdResetEvent2KHR") + set_proc_address(&CmdResetQueryPool, "vkCmdResetQueryPool") + set_proc_address(&CmdResolveImage, "vkCmdResolveImage") + set_proc_address(&CmdResolveImage2, "vkCmdResolveImage2") + set_proc_address(&CmdResolveImage2KHR, "vkCmdResolveImage2KHR") + set_proc_address(&CmdSetAlphaToCoverageEnableEXT, "vkCmdSetAlphaToCoverageEnableEXT") + set_proc_address(&CmdSetAlphaToOneEnableEXT, "vkCmdSetAlphaToOneEnableEXT") + set_proc_address(&CmdSetAttachmentFeedbackLoopEnableEXT, "vkCmdSetAttachmentFeedbackLoopEnableEXT") + set_proc_address(&CmdSetBlendConstants, "vkCmdSetBlendConstants") + set_proc_address(&CmdSetCheckpointNV, "vkCmdSetCheckpointNV") + set_proc_address(&CmdSetCoarseSampleOrderNV, "vkCmdSetCoarseSampleOrderNV") + set_proc_address(&CmdSetColorBlendAdvancedEXT, "vkCmdSetColorBlendAdvancedEXT") + set_proc_address(&CmdSetColorBlendEnableEXT, "vkCmdSetColorBlendEnableEXT") + set_proc_address(&CmdSetColorBlendEquationEXT, "vkCmdSetColorBlendEquationEXT") + set_proc_address(&CmdSetColorWriteMaskEXT, "vkCmdSetColorWriteMaskEXT") + set_proc_address(&CmdSetConservativeRasterizationModeEXT, "vkCmdSetConservativeRasterizationModeEXT") + set_proc_address(&CmdSetCoverageModulationModeNV, "vkCmdSetCoverageModulationModeNV") + set_proc_address(&CmdSetCoverageModulationTableEnableNV, "vkCmdSetCoverageModulationTableEnableNV") + set_proc_address(&CmdSetCoverageModulationTableNV, "vkCmdSetCoverageModulationTableNV") + set_proc_address(&CmdSetCoverageReductionModeNV, "vkCmdSetCoverageReductionModeNV") + set_proc_address(&CmdSetCoverageToColorEnableNV, "vkCmdSetCoverageToColorEnableNV") + set_proc_address(&CmdSetCoverageToColorLocationNV, "vkCmdSetCoverageToColorLocationNV") + set_proc_address(&CmdSetCullMode, "vkCmdSetCullMode") + set_proc_address(&CmdSetCullModeEXT, "vkCmdSetCullModeEXT") + set_proc_address(&CmdSetDepthBias, "vkCmdSetDepthBias") + set_proc_address(&CmdSetDepthBiasEnable, "vkCmdSetDepthBiasEnable") + set_proc_address(&CmdSetDepthBiasEnableEXT, "vkCmdSetDepthBiasEnableEXT") + set_proc_address(&CmdSetDepthBounds, "vkCmdSetDepthBounds") + set_proc_address(&CmdSetDepthBoundsTestEnable, "vkCmdSetDepthBoundsTestEnable") + set_proc_address(&CmdSetDepthBoundsTestEnableEXT, "vkCmdSetDepthBoundsTestEnableEXT") + set_proc_address(&CmdSetDepthClampEnableEXT, "vkCmdSetDepthClampEnableEXT") + set_proc_address(&CmdSetDepthClipEnableEXT, "vkCmdSetDepthClipEnableEXT") + set_proc_address(&CmdSetDepthClipNegativeOneToOneEXT, "vkCmdSetDepthClipNegativeOneToOneEXT") + set_proc_address(&CmdSetDepthCompareOp, "vkCmdSetDepthCompareOp") + set_proc_address(&CmdSetDepthCompareOpEXT, "vkCmdSetDepthCompareOpEXT") + set_proc_address(&CmdSetDepthTestEnable, "vkCmdSetDepthTestEnable") + set_proc_address(&CmdSetDepthTestEnableEXT, "vkCmdSetDepthTestEnableEXT") + set_proc_address(&CmdSetDepthWriteEnable, "vkCmdSetDepthWriteEnable") + set_proc_address(&CmdSetDepthWriteEnableEXT, "vkCmdSetDepthWriteEnableEXT") + set_proc_address(&CmdSetDescriptorBufferOffsetsEXT, "vkCmdSetDescriptorBufferOffsetsEXT") + set_proc_address(&CmdSetDeviceMask, "vkCmdSetDeviceMask") + set_proc_address(&CmdSetDeviceMaskKHR, "vkCmdSetDeviceMaskKHR") + set_proc_address(&CmdSetDiscardRectangleEXT, "vkCmdSetDiscardRectangleEXT") + set_proc_address(&CmdSetDiscardRectangleEnableEXT, "vkCmdSetDiscardRectangleEnableEXT") + set_proc_address(&CmdSetDiscardRectangleModeEXT, "vkCmdSetDiscardRectangleModeEXT") + set_proc_address(&CmdSetEvent, "vkCmdSetEvent") + set_proc_address(&CmdSetEvent2, "vkCmdSetEvent2") + set_proc_address(&CmdSetEvent2KHR, "vkCmdSetEvent2KHR") + set_proc_address(&CmdSetExclusiveScissorEnableNV, "vkCmdSetExclusiveScissorEnableNV") + set_proc_address(&CmdSetExclusiveScissorNV, "vkCmdSetExclusiveScissorNV") + set_proc_address(&CmdSetExtraPrimitiveOverestimationSizeEXT, "vkCmdSetExtraPrimitiveOverestimationSizeEXT") + set_proc_address(&CmdSetFragmentShadingRateEnumNV, "vkCmdSetFragmentShadingRateEnumNV") + set_proc_address(&CmdSetFragmentShadingRateKHR, "vkCmdSetFragmentShadingRateKHR") + set_proc_address(&CmdSetFrontFace, "vkCmdSetFrontFace") + set_proc_address(&CmdSetFrontFaceEXT, "vkCmdSetFrontFaceEXT") + set_proc_address(&CmdSetLineRasterizationModeEXT, "vkCmdSetLineRasterizationModeEXT") + set_proc_address(&CmdSetLineStippleEXT, "vkCmdSetLineStippleEXT") + set_proc_address(&CmdSetLineStippleEnableEXT, "vkCmdSetLineStippleEnableEXT") + set_proc_address(&CmdSetLineWidth, "vkCmdSetLineWidth") + set_proc_address(&CmdSetLogicOpEXT, "vkCmdSetLogicOpEXT") + set_proc_address(&CmdSetLogicOpEnableEXT, "vkCmdSetLogicOpEnableEXT") + set_proc_address(&CmdSetPatchControlPointsEXT, "vkCmdSetPatchControlPointsEXT") + set_proc_address(&CmdSetPerformanceMarkerINTEL, "vkCmdSetPerformanceMarkerINTEL") + set_proc_address(&CmdSetPerformanceOverrideINTEL, "vkCmdSetPerformanceOverrideINTEL") + set_proc_address(&CmdSetPerformanceStreamMarkerINTEL, "vkCmdSetPerformanceStreamMarkerINTEL") + set_proc_address(&CmdSetPolygonModeEXT, "vkCmdSetPolygonModeEXT") + set_proc_address(&CmdSetPrimitiveRestartEnable, "vkCmdSetPrimitiveRestartEnable") + set_proc_address(&CmdSetPrimitiveRestartEnableEXT, "vkCmdSetPrimitiveRestartEnableEXT") + set_proc_address(&CmdSetPrimitiveTopology, "vkCmdSetPrimitiveTopology") + set_proc_address(&CmdSetPrimitiveTopologyEXT, "vkCmdSetPrimitiveTopologyEXT") + set_proc_address(&CmdSetProvokingVertexModeEXT, "vkCmdSetProvokingVertexModeEXT") + set_proc_address(&CmdSetRasterizationSamplesEXT, "vkCmdSetRasterizationSamplesEXT") + set_proc_address(&CmdSetRasterizationStreamEXT, "vkCmdSetRasterizationStreamEXT") + set_proc_address(&CmdSetRasterizerDiscardEnable, "vkCmdSetRasterizerDiscardEnable") + set_proc_address(&CmdSetRasterizerDiscardEnableEXT, "vkCmdSetRasterizerDiscardEnableEXT") + set_proc_address(&CmdSetRayTracingPipelineStackSizeKHR, "vkCmdSetRayTracingPipelineStackSizeKHR") + set_proc_address(&CmdSetRepresentativeFragmentTestEnableNV, "vkCmdSetRepresentativeFragmentTestEnableNV") + set_proc_address(&CmdSetSampleLocationsEXT, "vkCmdSetSampleLocationsEXT") + set_proc_address(&CmdSetSampleLocationsEnableEXT, "vkCmdSetSampleLocationsEnableEXT") + set_proc_address(&CmdSetSampleMaskEXT, "vkCmdSetSampleMaskEXT") + set_proc_address(&CmdSetScissor, "vkCmdSetScissor") + set_proc_address(&CmdSetScissorWithCount, "vkCmdSetScissorWithCount") + set_proc_address(&CmdSetScissorWithCountEXT, "vkCmdSetScissorWithCountEXT") + set_proc_address(&CmdSetShadingRateImageEnableNV, "vkCmdSetShadingRateImageEnableNV") + set_proc_address(&CmdSetStencilCompareMask, "vkCmdSetStencilCompareMask") + set_proc_address(&CmdSetStencilOp, "vkCmdSetStencilOp") + set_proc_address(&CmdSetStencilOpEXT, "vkCmdSetStencilOpEXT") + set_proc_address(&CmdSetStencilReference, "vkCmdSetStencilReference") + set_proc_address(&CmdSetStencilTestEnable, "vkCmdSetStencilTestEnable") + set_proc_address(&CmdSetStencilTestEnableEXT, "vkCmdSetStencilTestEnableEXT") + set_proc_address(&CmdSetStencilWriteMask, "vkCmdSetStencilWriteMask") + set_proc_address(&CmdSetTessellationDomainOriginEXT, "vkCmdSetTessellationDomainOriginEXT") + set_proc_address(&CmdSetVertexInputEXT, "vkCmdSetVertexInputEXT") + set_proc_address(&CmdSetViewport, "vkCmdSetViewport") + set_proc_address(&CmdSetViewportShadingRatePaletteNV, "vkCmdSetViewportShadingRatePaletteNV") + set_proc_address(&CmdSetViewportSwizzleNV, "vkCmdSetViewportSwizzleNV") + set_proc_address(&CmdSetViewportWScalingEnableNV, "vkCmdSetViewportWScalingEnableNV") + set_proc_address(&CmdSetViewportWScalingNV, "vkCmdSetViewportWScalingNV") + set_proc_address(&CmdSetViewportWithCount, "vkCmdSetViewportWithCount") + set_proc_address(&CmdSetViewportWithCountEXT, "vkCmdSetViewportWithCountEXT") + set_proc_address(&CmdSubpassShadingHUAWEI, "vkCmdSubpassShadingHUAWEI") + set_proc_address(&CmdTraceRaysIndirect2KHR, "vkCmdTraceRaysIndirect2KHR") + set_proc_address(&CmdTraceRaysIndirectKHR, "vkCmdTraceRaysIndirectKHR") + set_proc_address(&CmdTraceRaysKHR, "vkCmdTraceRaysKHR") + set_proc_address(&CmdTraceRaysNV, "vkCmdTraceRaysNV") + set_proc_address(&CmdUpdateBuffer, "vkCmdUpdateBuffer") + set_proc_address(&CmdWaitEvents, "vkCmdWaitEvents") + set_proc_address(&CmdWaitEvents2, "vkCmdWaitEvents2") + set_proc_address(&CmdWaitEvents2KHR, "vkCmdWaitEvents2KHR") + set_proc_address(&CmdWriteAccelerationStructuresPropertiesKHR, "vkCmdWriteAccelerationStructuresPropertiesKHR") + set_proc_address(&CmdWriteAccelerationStructuresPropertiesNV, "vkCmdWriteAccelerationStructuresPropertiesNV") + set_proc_address(&CmdWriteBufferMarker2AMD, "vkCmdWriteBufferMarker2AMD") + set_proc_address(&CmdWriteBufferMarkerAMD, "vkCmdWriteBufferMarkerAMD") + set_proc_address(&CmdWriteMicromapsPropertiesEXT, "vkCmdWriteMicromapsPropertiesEXT") + set_proc_address(&CmdWriteTimestamp, "vkCmdWriteTimestamp") + set_proc_address(&CmdWriteTimestamp2, "vkCmdWriteTimestamp2") + set_proc_address(&CmdWriteTimestamp2KHR, "vkCmdWriteTimestamp2KHR") + set_proc_address(&CompileDeferredNV, "vkCompileDeferredNV") + set_proc_address(&CopyAccelerationStructureKHR, "vkCopyAccelerationStructureKHR") + set_proc_address(&CopyAccelerationStructureToMemoryKHR, "vkCopyAccelerationStructureToMemoryKHR") + set_proc_address(&CopyMemoryToAccelerationStructureKHR, "vkCopyMemoryToAccelerationStructureKHR") + set_proc_address(&CopyMemoryToMicromapEXT, "vkCopyMemoryToMicromapEXT") + set_proc_address(&CopyMicromapEXT, "vkCopyMicromapEXT") + set_proc_address(&CopyMicromapToMemoryEXT, "vkCopyMicromapToMemoryEXT") + set_proc_address(&CreateAccelerationStructureKHR, "vkCreateAccelerationStructureKHR") + set_proc_address(&CreateAccelerationStructureNV, "vkCreateAccelerationStructureNV") + set_proc_address(&CreateBuffer, "vkCreateBuffer") + set_proc_address(&CreateBufferView, "vkCreateBufferView") + set_proc_address(&CreateCommandPool, "vkCreateCommandPool") + set_proc_address(&CreateComputePipelines, "vkCreateComputePipelines") + set_proc_address(&CreateCuFunctionNVX, "vkCreateCuFunctionNVX") + set_proc_address(&CreateCuModuleNVX, "vkCreateCuModuleNVX") + set_proc_address(&CreateDeferredOperationKHR, "vkCreateDeferredOperationKHR") + set_proc_address(&CreateDescriptorPool, "vkCreateDescriptorPool") + set_proc_address(&CreateDescriptorSetLayout, "vkCreateDescriptorSetLayout") + set_proc_address(&CreateDescriptorUpdateTemplate, "vkCreateDescriptorUpdateTemplate") + set_proc_address(&CreateDescriptorUpdateTemplateKHR, "vkCreateDescriptorUpdateTemplateKHR") + set_proc_address(&CreateEvent, "vkCreateEvent") + set_proc_address(&CreateFence, "vkCreateFence") + set_proc_address(&CreateFramebuffer, "vkCreateFramebuffer") + set_proc_address(&CreateGraphicsPipelines, "vkCreateGraphicsPipelines") + set_proc_address(&CreateImage, "vkCreateImage") + set_proc_address(&CreateImageView, "vkCreateImageView") + set_proc_address(&CreateIndirectCommandsLayoutNV, "vkCreateIndirectCommandsLayoutNV") + set_proc_address(&CreateMicromapEXT, "vkCreateMicromapEXT") + set_proc_address(&CreateOpticalFlowSessionNV, "vkCreateOpticalFlowSessionNV") + set_proc_address(&CreatePipelineCache, "vkCreatePipelineCache") + set_proc_address(&CreatePipelineLayout, "vkCreatePipelineLayout") + set_proc_address(&CreatePrivateDataSlot, "vkCreatePrivateDataSlot") + set_proc_address(&CreatePrivateDataSlotEXT, "vkCreatePrivateDataSlotEXT") + set_proc_address(&CreateQueryPool, "vkCreateQueryPool") + set_proc_address(&CreateRayTracingPipelinesKHR, "vkCreateRayTracingPipelinesKHR") + set_proc_address(&CreateRayTracingPipelinesNV, "vkCreateRayTracingPipelinesNV") + set_proc_address(&CreateRenderPass, "vkCreateRenderPass") + set_proc_address(&CreateRenderPass2, "vkCreateRenderPass2") + set_proc_address(&CreateRenderPass2KHR, "vkCreateRenderPass2KHR") + set_proc_address(&CreateSampler, "vkCreateSampler") + set_proc_address(&CreateSamplerYcbcrConversion, "vkCreateSamplerYcbcrConversion") + set_proc_address(&CreateSamplerYcbcrConversionKHR, "vkCreateSamplerYcbcrConversionKHR") + set_proc_address(&CreateSemaphore, "vkCreateSemaphore") + set_proc_address(&CreateShaderModule, "vkCreateShaderModule") + set_proc_address(&CreateShadersEXT, "vkCreateShadersEXT") + set_proc_address(&CreateSharedSwapchainsKHR, "vkCreateSharedSwapchainsKHR") + set_proc_address(&CreateSwapchainKHR, "vkCreateSwapchainKHR") + set_proc_address(&CreateValidationCacheEXT, "vkCreateValidationCacheEXT") + set_proc_address(&CreateVideoSessionKHR, "vkCreateVideoSessionKHR") + set_proc_address(&CreateVideoSessionParametersKHR, "vkCreateVideoSessionParametersKHR") + set_proc_address(&DebugMarkerSetObjectNameEXT, "vkDebugMarkerSetObjectNameEXT") + set_proc_address(&DebugMarkerSetObjectTagEXT, "vkDebugMarkerSetObjectTagEXT") + set_proc_address(&DeferredOperationJoinKHR, "vkDeferredOperationJoinKHR") + set_proc_address(&DestroyAccelerationStructureKHR, "vkDestroyAccelerationStructureKHR") + set_proc_address(&DestroyAccelerationStructureNV, "vkDestroyAccelerationStructureNV") + set_proc_address(&DestroyBuffer, "vkDestroyBuffer") + set_proc_address(&DestroyBufferView, "vkDestroyBufferView") + set_proc_address(&DestroyCommandPool, "vkDestroyCommandPool") + set_proc_address(&DestroyCuFunctionNVX, "vkDestroyCuFunctionNVX") + set_proc_address(&DestroyCuModuleNVX, "vkDestroyCuModuleNVX") + set_proc_address(&DestroyDeferredOperationKHR, "vkDestroyDeferredOperationKHR") + set_proc_address(&DestroyDescriptorPool, "vkDestroyDescriptorPool") + set_proc_address(&DestroyDescriptorSetLayout, "vkDestroyDescriptorSetLayout") + set_proc_address(&DestroyDescriptorUpdateTemplate, "vkDestroyDescriptorUpdateTemplate") + set_proc_address(&DestroyDescriptorUpdateTemplateKHR, "vkDestroyDescriptorUpdateTemplateKHR") + set_proc_address(&DestroyDevice, "vkDestroyDevice") + set_proc_address(&DestroyEvent, "vkDestroyEvent") + set_proc_address(&DestroyFence, "vkDestroyFence") + set_proc_address(&DestroyFramebuffer, "vkDestroyFramebuffer") + set_proc_address(&DestroyImage, "vkDestroyImage") + set_proc_address(&DestroyImageView, "vkDestroyImageView") + set_proc_address(&DestroyIndirectCommandsLayoutNV, "vkDestroyIndirectCommandsLayoutNV") + set_proc_address(&DestroyMicromapEXT, "vkDestroyMicromapEXT") + set_proc_address(&DestroyOpticalFlowSessionNV, "vkDestroyOpticalFlowSessionNV") + set_proc_address(&DestroyPipeline, "vkDestroyPipeline") + set_proc_address(&DestroyPipelineCache, "vkDestroyPipelineCache") + set_proc_address(&DestroyPipelineLayout, "vkDestroyPipelineLayout") + set_proc_address(&DestroyPrivateDataSlot, "vkDestroyPrivateDataSlot") + set_proc_address(&DestroyPrivateDataSlotEXT, "vkDestroyPrivateDataSlotEXT") + set_proc_address(&DestroyQueryPool, "vkDestroyQueryPool") + set_proc_address(&DestroyRenderPass, "vkDestroyRenderPass") + set_proc_address(&DestroySampler, "vkDestroySampler") + set_proc_address(&DestroySamplerYcbcrConversion, "vkDestroySamplerYcbcrConversion") + set_proc_address(&DestroySamplerYcbcrConversionKHR, "vkDestroySamplerYcbcrConversionKHR") + set_proc_address(&DestroySemaphore, "vkDestroySemaphore") + set_proc_address(&DestroyShaderEXT, "vkDestroyShaderEXT") + set_proc_address(&DestroyShaderModule, "vkDestroyShaderModule") + set_proc_address(&DestroySwapchainKHR, "vkDestroySwapchainKHR") + set_proc_address(&DestroyValidationCacheEXT, "vkDestroyValidationCacheEXT") + set_proc_address(&DestroyVideoSessionKHR, "vkDestroyVideoSessionKHR") + set_proc_address(&DestroyVideoSessionParametersKHR, "vkDestroyVideoSessionParametersKHR") + set_proc_address(&DeviceWaitIdle, "vkDeviceWaitIdle") + set_proc_address(&DisplayPowerControlEXT, "vkDisplayPowerControlEXT") + set_proc_address(&EndCommandBuffer, "vkEndCommandBuffer") + set_proc_address(&ExportMetalObjectsEXT, "vkExportMetalObjectsEXT") + set_proc_address(&FlushMappedMemoryRanges, "vkFlushMappedMemoryRanges") + set_proc_address(&FreeCommandBuffers, "vkFreeCommandBuffers") + set_proc_address(&FreeDescriptorSets, "vkFreeDescriptorSets") + set_proc_address(&FreeMemory, "vkFreeMemory") + set_proc_address(&GetAccelerationStructureBuildSizesKHR, "vkGetAccelerationStructureBuildSizesKHR") + set_proc_address(&GetAccelerationStructureDeviceAddressKHR, "vkGetAccelerationStructureDeviceAddressKHR") + set_proc_address(&GetAccelerationStructureHandleNV, "vkGetAccelerationStructureHandleNV") + set_proc_address(&GetAccelerationStructureMemoryRequirementsNV, "vkGetAccelerationStructureMemoryRequirementsNV") + set_proc_address(&GetAccelerationStructureOpaqueCaptureDescriptorDataEXT, "vkGetAccelerationStructureOpaqueCaptureDescriptorDataEXT") + set_proc_address(&GetBufferDeviceAddress, "vkGetBufferDeviceAddress") + set_proc_address(&GetBufferDeviceAddressEXT, "vkGetBufferDeviceAddressEXT") + set_proc_address(&GetBufferDeviceAddressKHR, "vkGetBufferDeviceAddressKHR") + set_proc_address(&GetBufferMemoryRequirements, "vkGetBufferMemoryRequirements") + set_proc_address(&GetBufferMemoryRequirements2, "vkGetBufferMemoryRequirements2") + set_proc_address(&GetBufferMemoryRequirements2KHR, "vkGetBufferMemoryRequirements2KHR") + set_proc_address(&GetBufferOpaqueCaptureAddress, "vkGetBufferOpaqueCaptureAddress") + set_proc_address(&GetBufferOpaqueCaptureAddressKHR, "vkGetBufferOpaqueCaptureAddressKHR") + set_proc_address(&GetBufferOpaqueCaptureDescriptorDataEXT, "vkGetBufferOpaqueCaptureDescriptorDataEXT") + set_proc_address(&GetCalibratedTimestampsEXT, "vkGetCalibratedTimestampsEXT") + set_proc_address(&GetDeferredOperationMaxConcurrencyKHR, "vkGetDeferredOperationMaxConcurrencyKHR") + set_proc_address(&GetDeferredOperationResultKHR, "vkGetDeferredOperationResultKHR") + set_proc_address(&GetDescriptorEXT, "vkGetDescriptorEXT") + set_proc_address(&GetDescriptorSetHostMappingVALVE, "vkGetDescriptorSetHostMappingVALVE") + set_proc_address(&GetDescriptorSetLayoutBindingOffsetEXT, "vkGetDescriptorSetLayoutBindingOffsetEXT") + set_proc_address(&GetDescriptorSetLayoutHostMappingInfoVALVE, "vkGetDescriptorSetLayoutHostMappingInfoVALVE") + set_proc_address(&GetDescriptorSetLayoutSizeEXT, "vkGetDescriptorSetLayoutSizeEXT") + set_proc_address(&GetDescriptorSetLayoutSupport, "vkGetDescriptorSetLayoutSupport") + set_proc_address(&GetDescriptorSetLayoutSupportKHR, "vkGetDescriptorSetLayoutSupportKHR") + set_proc_address(&GetDeviceAccelerationStructureCompatibilityKHR, "vkGetDeviceAccelerationStructureCompatibilityKHR") + set_proc_address(&GetDeviceBufferMemoryRequirements, "vkGetDeviceBufferMemoryRequirements") + set_proc_address(&GetDeviceBufferMemoryRequirementsKHR, "vkGetDeviceBufferMemoryRequirementsKHR") + set_proc_address(&GetDeviceFaultInfoEXT, "vkGetDeviceFaultInfoEXT") + set_proc_address(&GetDeviceGroupPeerMemoryFeatures, "vkGetDeviceGroupPeerMemoryFeatures") + set_proc_address(&GetDeviceGroupPeerMemoryFeaturesKHR, "vkGetDeviceGroupPeerMemoryFeaturesKHR") + set_proc_address(&GetDeviceGroupPresentCapabilitiesKHR, "vkGetDeviceGroupPresentCapabilitiesKHR") + set_proc_address(&GetDeviceGroupSurfacePresentModes2EXT, "vkGetDeviceGroupSurfacePresentModes2EXT") + set_proc_address(&GetDeviceGroupSurfacePresentModesKHR, "vkGetDeviceGroupSurfacePresentModesKHR") + set_proc_address(&GetDeviceImageMemoryRequirements, "vkGetDeviceImageMemoryRequirements") + set_proc_address(&GetDeviceImageMemoryRequirementsKHR, "vkGetDeviceImageMemoryRequirementsKHR") + set_proc_address(&GetDeviceImageSparseMemoryRequirements, "vkGetDeviceImageSparseMemoryRequirements") + set_proc_address(&GetDeviceImageSparseMemoryRequirementsKHR, "vkGetDeviceImageSparseMemoryRequirementsKHR") + set_proc_address(&GetDeviceMemoryCommitment, "vkGetDeviceMemoryCommitment") + set_proc_address(&GetDeviceMemoryOpaqueCaptureAddress, "vkGetDeviceMemoryOpaqueCaptureAddress") + set_proc_address(&GetDeviceMemoryOpaqueCaptureAddressKHR, "vkGetDeviceMemoryOpaqueCaptureAddressKHR") + set_proc_address(&GetDeviceMicromapCompatibilityEXT, "vkGetDeviceMicromapCompatibilityEXT") + set_proc_address(&GetDeviceProcAddr, "vkGetDeviceProcAddr") + set_proc_address(&GetDeviceQueue, "vkGetDeviceQueue") + set_proc_address(&GetDeviceQueue2, "vkGetDeviceQueue2") + set_proc_address(&GetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI, "vkGetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI") + set_proc_address(&GetDynamicRenderingTilePropertiesQCOM, "vkGetDynamicRenderingTilePropertiesQCOM") + set_proc_address(&GetEventStatus, "vkGetEventStatus") + set_proc_address(&GetFenceFdKHR, "vkGetFenceFdKHR") + set_proc_address(&GetFenceStatus, "vkGetFenceStatus") + set_proc_address(&GetFenceWin32HandleKHR, "vkGetFenceWin32HandleKHR") + set_proc_address(&GetFramebufferTilePropertiesQCOM, "vkGetFramebufferTilePropertiesQCOM") + set_proc_address(&GetGeneratedCommandsMemoryRequirementsNV, "vkGetGeneratedCommandsMemoryRequirementsNV") + set_proc_address(&GetImageDrmFormatModifierPropertiesEXT, "vkGetImageDrmFormatModifierPropertiesEXT") + set_proc_address(&GetImageMemoryRequirements, "vkGetImageMemoryRequirements") + set_proc_address(&GetImageMemoryRequirements2, "vkGetImageMemoryRequirements2") + set_proc_address(&GetImageMemoryRequirements2KHR, "vkGetImageMemoryRequirements2KHR") + set_proc_address(&GetImageOpaqueCaptureDescriptorDataEXT, "vkGetImageOpaqueCaptureDescriptorDataEXT") + set_proc_address(&GetImageSparseMemoryRequirements, "vkGetImageSparseMemoryRequirements") + set_proc_address(&GetImageSparseMemoryRequirements2, "vkGetImageSparseMemoryRequirements2") + set_proc_address(&GetImageSparseMemoryRequirements2KHR, "vkGetImageSparseMemoryRequirements2KHR") + set_proc_address(&GetImageSubresourceLayout, "vkGetImageSubresourceLayout") + set_proc_address(&GetImageSubresourceLayout2EXT, "vkGetImageSubresourceLayout2EXT") + set_proc_address(&GetImageViewAddressNVX, "vkGetImageViewAddressNVX") + set_proc_address(&GetImageViewHandleNVX, "vkGetImageViewHandleNVX") + set_proc_address(&GetImageViewOpaqueCaptureDescriptorDataEXT, "vkGetImageViewOpaqueCaptureDescriptorDataEXT") + set_proc_address(&GetMemoryFdKHR, "vkGetMemoryFdKHR") + set_proc_address(&GetMemoryFdPropertiesKHR, "vkGetMemoryFdPropertiesKHR") + set_proc_address(&GetMemoryHostPointerPropertiesEXT, "vkGetMemoryHostPointerPropertiesEXT") + set_proc_address(&GetMemoryRemoteAddressNV, "vkGetMemoryRemoteAddressNV") + set_proc_address(&GetMemoryWin32HandleKHR, "vkGetMemoryWin32HandleKHR") + set_proc_address(&GetMemoryWin32HandleNV, "vkGetMemoryWin32HandleNV") + set_proc_address(&GetMemoryWin32HandlePropertiesKHR, "vkGetMemoryWin32HandlePropertiesKHR") + set_proc_address(&GetMicromapBuildSizesEXT, "vkGetMicromapBuildSizesEXT") + set_proc_address(&GetPastPresentationTimingGOOGLE, "vkGetPastPresentationTimingGOOGLE") + set_proc_address(&GetPerformanceParameterINTEL, "vkGetPerformanceParameterINTEL") + set_proc_address(&GetPipelineCacheData, "vkGetPipelineCacheData") + set_proc_address(&GetPipelineExecutableInternalRepresentationsKHR, "vkGetPipelineExecutableInternalRepresentationsKHR") + set_proc_address(&GetPipelineExecutablePropertiesKHR, "vkGetPipelineExecutablePropertiesKHR") + set_proc_address(&GetPipelineExecutableStatisticsKHR, "vkGetPipelineExecutableStatisticsKHR") + set_proc_address(&GetPipelinePropertiesEXT, "vkGetPipelinePropertiesEXT") + set_proc_address(&GetPrivateData, "vkGetPrivateData") + set_proc_address(&GetPrivateDataEXT, "vkGetPrivateDataEXT") + set_proc_address(&GetQueryPoolResults, "vkGetQueryPoolResults") + set_proc_address(&GetQueueCheckpointData2NV, "vkGetQueueCheckpointData2NV") + set_proc_address(&GetQueueCheckpointDataNV, "vkGetQueueCheckpointDataNV") + set_proc_address(&GetRayTracingCaptureReplayShaderGroupHandlesKHR, "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR") + set_proc_address(&GetRayTracingShaderGroupHandlesKHR, "vkGetRayTracingShaderGroupHandlesKHR") + set_proc_address(&GetRayTracingShaderGroupHandlesNV, "vkGetRayTracingShaderGroupHandlesNV") + set_proc_address(&GetRayTracingShaderGroupStackSizeKHR, "vkGetRayTracingShaderGroupStackSizeKHR") + set_proc_address(&GetRefreshCycleDurationGOOGLE, "vkGetRefreshCycleDurationGOOGLE") + set_proc_address(&GetRenderAreaGranularity, "vkGetRenderAreaGranularity") + set_proc_address(&GetSamplerOpaqueCaptureDescriptorDataEXT, "vkGetSamplerOpaqueCaptureDescriptorDataEXT") + set_proc_address(&GetSemaphoreCounterValue, "vkGetSemaphoreCounterValue") + set_proc_address(&GetSemaphoreCounterValueKHR, "vkGetSemaphoreCounterValueKHR") + set_proc_address(&GetSemaphoreFdKHR, "vkGetSemaphoreFdKHR") + set_proc_address(&GetSemaphoreWin32HandleKHR, "vkGetSemaphoreWin32HandleKHR") + set_proc_address(&GetShaderBinaryDataEXT, "vkGetShaderBinaryDataEXT") + set_proc_address(&GetShaderInfoAMD, "vkGetShaderInfoAMD") + set_proc_address(&GetShaderModuleCreateInfoIdentifierEXT, "vkGetShaderModuleCreateInfoIdentifierEXT") + set_proc_address(&GetShaderModuleIdentifierEXT, "vkGetShaderModuleIdentifierEXT") + set_proc_address(&GetSwapchainCounterEXT, "vkGetSwapchainCounterEXT") + set_proc_address(&GetSwapchainImagesKHR, "vkGetSwapchainImagesKHR") + set_proc_address(&GetSwapchainStatusKHR, "vkGetSwapchainStatusKHR") + set_proc_address(&GetValidationCacheDataEXT, "vkGetValidationCacheDataEXT") + set_proc_address(&GetVideoSessionMemoryRequirementsKHR, "vkGetVideoSessionMemoryRequirementsKHR") + set_proc_address(&ImportFenceFdKHR, "vkImportFenceFdKHR") + set_proc_address(&ImportFenceWin32HandleKHR, "vkImportFenceWin32HandleKHR") + set_proc_address(&ImportSemaphoreFdKHR, "vkImportSemaphoreFdKHR") + set_proc_address(&ImportSemaphoreWin32HandleKHR, "vkImportSemaphoreWin32HandleKHR") + set_proc_address(&InitializePerformanceApiINTEL, "vkInitializePerformanceApiINTEL") + set_proc_address(&InvalidateMappedMemoryRanges, "vkInvalidateMappedMemoryRanges") + set_proc_address(&MapMemory, "vkMapMemory") + set_proc_address(&MapMemory2KHR, "vkMapMemory2KHR") + set_proc_address(&MergePipelineCaches, "vkMergePipelineCaches") + set_proc_address(&MergeValidationCachesEXT, "vkMergeValidationCachesEXT") + set_proc_address(&QueueBeginDebugUtilsLabelEXT, "vkQueueBeginDebugUtilsLabelEXT") + set_proc_address(&QueueBindSparse, "vkQueueBindSparse") + set_proc_address(&QueueEndDebugUtilsLabelEXT, "vkQueueEndDebugUtilsLabelEXT") + set_proc_address(&QueueInsertDebugUtilsLabelEXT, "vkQueueInsertDebugUtilsLabelEXT") + set_proc_address(&QueuePresentKHR, "vkQueuePresentKHR") + set_proc_address(&QueueSetPerformanceConfigurationINTEL, "vkQueueSetPerformanceConfigurationINTEL") + set_proc_address(&QueueSubmit, "vkQueueSubmit") + set_proc_address(&QueueSubmit2, "vkQueueSubmit2") + set_proc_address(&QueueSubmit2KHR, "vkQueueSubmit2KHR") + set_proc_address(&QueueWaitIdle, "vkQueueWaitIdle") + set_proc_address(&RegisterDeviceEventEXT, "vkRegisterDeviceEventEXT") + set_proc_address(&RegisterDisplayEventEXT, "vkRegisterDisplayEventEXT") + set_proc_address(&ReleaseFullScreenExclusiveModeEXT, "vkReleaseFullScreenExclusiveModeEXT") + set_proc_address(&ReleasePerformanceConfigurationINTEL, "vkReleasePerformanceConfigurationINTEL") + set_proc_address(&ReleaseProfilingLockKHR, "vkReleaseProfilingLockKHR") + set_proc_address(&ReleaseSwapchainImagesEXT, "vkReleaseSwapchainImagesEXT") + set_proc_address(&ResetCommandBuffer, "vkResetCommandBuffer") + set_proc_address(&ResetCommandPool, "vkResetCommandPool") + set_proc_address(&ResetDescriptorPool, "vkResetDescriptorPool") + set_proc_address(&ResetEvent, "vkResetEvent") + set_proc_address(&ResetFences, "vkResetFences") + set_proc_address(&ResetQueryPool, "vkResetQueryPool") + set_proc_address(&ResetQueryPoolEXT, "vkResetQueryPoolEXT") + set_proc_address(&SetDebugUtilsObjectNameEXT, "vkSetDebugUtilsObjectNameEXT") + set_proc_address(&SetDebugUtilsObjectTagEXT, "vkSetDebugUtilsObjectTagEXT") + set_proc_address(&SetDeviceMemoryPriorityEXT, "vkSetDeviceMemoryPriorityEXT") + set_proc_address(&SetEvent, "vkSetEvent") + set_proc_address(&SetHdrMetadataEXT, "vkSetHdrMetadataEXT") + set_proc_address(&SetLocalDimmingAMD, "vkSetLocalDimmingAMD") + set_proc_address(&SetPrivateData, "vkSetPrivateData") + set_proc_address(&SetPrivateDataEXT, "vkSetPrivateDataEXT") + set_proc_address(&SignalSemaphore, "vkSignalSemaphore") + set_proc_address(&SignalSemaphoreKHR, "vkSignalSemaphoreKHR") + set_proc_address(&TrimCommandPool, "vkTrimCommandPool") + set_proc_address(&TrimCommandPoolKHR, "vkTrimCommandPoolKHR") + set_proc_address(&UninitializePerformanceApiINTEL, "vkUninitializePerformanceApiINTEL") + set_proc_address(&UnmapMemory, "vkUnmapMemory") + set_proc_address(&UnmapMemory2KHR, "vkUnmapMemory2KHR") + set_proc_address(&UpdateDescriptorSetWithTemplate, "vkUpdateDescriptorSetWithTemplate") + set_proc_address(&UpdateDescriptorSetWithTemplateKHR, "vkUpdateDescriptorSetWithTemplateKHR") + set_proc_address(&UpdateDescriptorSets, "vkUpdateDescriptorSets") + set_proc_address(&UpdateVideoSessionParametersKHR, "vkUpdateVideoSessionParametersKHR") + set_proc_address(&WaitForFences, "vkWaitForFences") + set_proc_address(&WaitForPresentKHR, "vkWaitForPresentKHR") + set_proc_address(&WaitSemaphores, "vkWaitSemaphores") + set_proc_address(&WaitSemaphoresKHR, "vkWaitSemaphoresKHR") + set_proc_address(&WriteAccelerationStructuresPropertiesKHR, "vkWriteAccelerationStructuresPropertiesKHR") + set_proc_address(&WriteMicromapsPropertiesEXT, "vkWriteMicromapsPropertiesEXT") + +} + +// Device Procedure VTable +Device_VTable :: struct { + AcquireFullScreenExclusiveModeEXT: ProcAcquireFullScreenExclusiveModeEXT, + AcquireNextImage2KHR: ProcAcquireNextImage2KHR, + AcquireNextImageKHR: ProcAcquireNextImageKHR, + AcquirePerformanceConfigurationINTEL: ProcAcquirePerformanceConfigurationINTEL, + AcquireProfilingLockKHR: ProcAcquireProfilingLockKHR, + AllocateCommandBuffers: ProcAllocateCommandBuffers, + AllocateDescriptorSets: ProcAllocateDescriptorSets, + AllocateMemory: ProcAllocateMemory, + BeginCommandBuffer: ProcBeginCommandBuffer, + BindAccelerationStructureMemoryNV: ProcBindAccelerationStructureMemoryNV, + BindBufferMemory: ProcBindBufferMemory, + BindBufferMemory2: ProcBindBufferMemory2, + BindBufferMemory2KHR: ProcBindBufferMemory2KHR, + BindImageMemory: ProcBindImageMemory, + BindImageMemory2: ProcBindImageMemory2, + BindImageMemory2KHR: ProcBindImageMemory2KHR, + BindOpticalFlowSessionImageNV: ProcBindOpticalFlowSessionImageNV, + BindVideoSessionMemoryKHR: ProcBindVideoSessionMemoryKHR, + BuildAccelerationStructuresKHR: ProcBuildAccelerationStructuresKHR, + BuildMicromapsEXT: ProcBuildMicromapsEXT, + CmdBeginConditionalRenderingEXT: ProcCmdBeginConditionalRenderingEXT, + CmdBeginDebugUtilsLabelEXT: ProcCmdBeginDebugUtilsLabelEXT, + CmdBeginQuery: ProcCmdBeginQuery, + CmdBeginQueryIndexedEXT: ProcCmdBeginQueryIndexedEXT, + CmdBeginRenderPass: ProcCmdBeginRenderPass, + CmdBeginRenderPass2: ProcCmdBeginRenderPass2, + CmdBeginRenderPass2KHR: ProcCmdBeginRenderPass2KHR, + CmdBeginRendering: ProcCmdBeginRendering, + CmdBeginRenderingKHR: ProcCmdBeginRenderingKHR, + CmdBeginTransformFeedbackEXT: ProcCmdBeginTransformFeedbackEXT, + CmdBeginVideoCodingKHR: ProcCmdBeginVideoCodingKHR, + CmdBindDescriptorBufferEmbeddedSamplersEXT: ProcCmdBindDescriptorBufferEmbeddedSamplersEXT, + CmdBindDescriptorBuffersEXT: ProcCmdBindDescriptorBuffersEXT, + CmdBindDescriptorSets: ProcCmdBindDescriptorSets, + CmdBindIndexBuffer: ProcCmdBindIndexBuffer, + CmdBindInvocationMaskHUAWEI: ProcCmdBindInvocationMaskHUAWEI, + CmdBindPipeline: ProcCmdBindPipeline, + CmdBindPipelineShaderGroupNV: ProcCmdBindPipelineShaderGroupNV, + CmdBindShadersEXT: ProcCmdBindShadersEXT, + CmdBindShadingRateImageNV: ProcCmdBindShadingRateImageNV, + CmdBindTransformFeedbackBuffersEXT: ProcCmdBindTransformFeedbackBuffersEXT, + CmdBindVertexBuffers: ProcCmdBindVertexBuffers, + CmdBindVertexBuffers2: ProcCmdBindVertexBuffers2, + CmdBindVertexBuffers2EXT: ProcCmdBindVertexBuffers2EXT, + CmdBlitImage: ProcCmdBlitImage, + CmdBlitImage2: ProcCmdBlitImage2, + CmdBlitImage2KHR: ProcCmdBlitImage2KHR, + CmdBuildAccelerationStructureNV: ProcCmdBuildAccelerationStructureNV, + CmdBuildAccelerationStructuresIndirectKHR: ProcCmdBuildAccelerationStructuresIndirectKHR, + CmdBuildAccelerationStructuresKHR: ProcCmdBuildAccelerationStructuresKHR, + CmdBuildMicromapsEXT: ProcCmdBuildMicromapsEXT, + CmdClearAttachments: ProcCmdClearAttachments, + CmdClearColorImage: ProcCmdClearColorImage, + CmdClearDepthStencilImage: ProcCmdClearDepthStencilImage, + CmdControlVideoCodingKHR: ProcCmdControlVideoCodingKHR, + CmdCopyAccelerationStructureKHR: ProcCmdCopyAccelerationStructureKHR, + CmdCopyAccelerationStructureNV: ProcCmdCopyAccelerationStructureNV, + CmdCopyAccelerationStructureToMemoryKHR: ProcCmdCopyAccelerationStructureToMemoryKHR, + CmdCopyBuffer: ProcCmdCopyBuffer, + CmdCopyBuffer2: ProcCmdCopyBuffer2, + CmdCopyBuffer2KHR: ProcCmdCopyBuffer2KHR, + CmdCopyBufferToImage: ProcCmdCopyBufferToImage, + CmdCopyBufferToImage2: ProcCmdCopyBufferToImage2, + CmdCopyBufferToImage2KHR: ProcCmdCopyBufferToImage2KHR, + CmdCopyImage: ProcCmdCopyImage, + CmdCopyImage2: ProcCmdCopyImage2, + CmdCopyImage2KHR: ProcCmdCopyImage2KHR, + CmdCopyImageToBuffer: ProcCmdCopyImageToBuffer, + CmdCopyImageToBuffer2: ProcCmdCopyImageToBuffer2, + CmdCopyImageToBuffer2KHR: ProcCmdCopyImageToBuffer2KHR, + CmdCopyMemoryIndirectNV: ProcCmdCopyMemoryIndirectNV, + CmdCopyMemoryToAccelerationStructureKHR: ProcCmdCopyMemoryToAccelerationStructureKHR, + CmdCopyMemoryToImageIndirectNV: ProcCmdCopyMemoryToImageIndirectNV, + CmdCopyMemoryToMicromapEXT: ProcCmdCopyMemoryToMicromapEXT, + CmdCopyMicromapEXT: ProcCmdCopyMicromapEXT, + CmdCopyMicromapToMemoryEXT: ProcCmdCopyMicromapToMemoryEXT, + CmdCopyQueryPoolResults: ProcCmdCopyQueryPoolResults, + CmdCuLaunchKernelNVX: ProcCmdCuLaunchKernelNVX, + CmdDebugMarkerBeginEXT: ProcCmdDebugMarkerBeginEXT, + CmdDebugMarkerEndEXT: ProcCmdDebugMarkerEndEXT, + CmdDebugMarkerInsertEXT: ProcCmdDebugMarkerInsertEXT, + CmdDecodeVideoKHR: ProcCmdDecodeVideoKHR, + CmdDecompressMemoryIndirectCountNV: ProcCmdDecompressMemoryIndirectCountNV, + CmdDecompressMemoryNV: ProcCmdDecompressMemoryNV, + CmdDispatch: ProcCmdDispatch, + CmdDispatchBase: ProcCmdDispatchBase, + CmdDispatchBaseKHR: ProcCmdDispatchBaseKHR, + CmdDispatchIndirect: ProcCmdDispatchIndirect, + CmdDraw: ProcCmdDraw, + CmdDrawClusterHUAWEI: ProcCmdDrawClusterHUAWEI, + CmdDrawClusterIndirectHUAWEI: ProcCmdDrawClusterIndirectHUAWEI, + CmdDrawIndexed: ProcCmdDrawIndexed, + CmdDrawIndexedIndirect: ProcCmdDrawIndexedIndirect, + CmdDrawIndexedIndirectCount: ProcCmdDrawIndexedIndirectCount, + CmdDrawIndexedIndirectCountAMD: ProcCmdDrawIndexedIndirectCountAMD, + CmdDrawIndexedIndirectCountKHR: ProcCmdDrawIndexedIndirectCountKHR, + CmdDrawIndirect: ProcCmdDrawIndirect, + CmdDrawIndirectByteCountEXT: ProcCmdDrawIndirectByteCountEXT, + CmdDrawIndirectCount: ProcCmdDrawIndirectCount, + CmdDrawIndirectCountAMD: ProcCmdDrawIndirectCountAMD, + CmdDrawIndirectCountKHR: ProcCmdDrawIndirectCountKHR, + CmdDrawMeshTasksEXT: ProcCmdDrawMeshTasksEXT, + CmdDrawMeshTasksIndirectCountEXT: ProcCmdDrawMeshTasksIndirectCountEXT, + CmdDrawMeshTasksIndirectCountNV: ProcCmdDrawMeshTasksIndirectCountNV, + CmdDrawMeshTasksIndirectEXT: ProcCmdDrawMeshTasksIndirectEXT, + CmdDrawMeshTasksIndirectNV: ProcCmdDrawMeshTasksIndirectNV, + CmdDrawMeshTasksNV: ProcCmdDrawMeshTasksNV, + CmdDrawMultiEXT: ProcCmdDrawMultiEXT, + CmdDrawMultiIndexedEXT: ProcCmdDrawMultiIndexedEXT, + CmdEndConditionalRenderingEXT: ProcCmdEndConditionalRenderingEXT, + CmdEndDebugUtilsLabelEXT: ProcCmdEndDebugUtilsLabelEXT, + CmdEndQuery: ProcCmdEndQuery, + CmdEndQueryIndexedEXT: ProcCmdEndQueryIndexedEXT, + CmdEndRenderPass: ProcCmdEndRenderPass, + CmdEndRenderPass2: ProcCmdEndRenderPass2, + CmdEndRenderPass2KHR: ProcCmdEndRenderPass2KHR, + CmdEndRendering: ProcCmdEndRendering, + CmdEndRenderingKHR: ProcCmdEndRenderingKHR, + CmdEndTransformFeedbackEXT: ProcCmdEndTransformFeedbackEXT, + CmdEndVideoCodingKHR: ProcCmdEndVideoCodingKHR, + CmdExecuteCommands: ProcCmdExecuteCommands, + CmdExecuteGeneratedCommandsNV: ProcCmdExecuteGeneratedCommandsNV, + CmdFillBuffer: ProcCmdFillBuffer, + CmdInsertDebugUtilsLabelEXT: ProcCmdInsertDebugUtilsLabelEXT, + CmdNextSubpass: ProcCmdNextSubpass, + CmdNextSubpass2: ProcCmdNextSubpass2, + CmdNextSubpass2KHR: ProcCmdNextSubpass2KHR, + CmdOpticalFlowExecuteNV: ProcCmdOpticalFlowExecuteNV, + CmdPipelineBarrier: ProcCmdPipelineBarrier, + CmdPipelineBarrier2: ProcCmdPipelineBarrier2, + CmdPipelineBarrier2KHR: ProcCmdPipelineBarrier2KHR, + CmdPreprocessGeneratedCommandsNV: ProcCmdPreprocessGeneratedCommandsNV, + CmdPushConstants: ProcCmdPushConstants, + CmdPushDescriptorSetKHR: ProcCmdPushDescriptorSetKHR, + CmdPushDescriptorSetWithTemplateKHR: ProcCmdPushDescriptorSetWithTemplateKHR, + CmdResetEvent: ProcCmdResetEvent, + CmdResetEvent2: ProcCmdResetEvent2, + CmdResetEvent2KHR: ProcCmdResetEvent2KHR, + CmdResetQueryPool: ProcCmdResetQueryPool, + CmdResolveImage: ProcCmdResolveImage, + CmdResolveImage2: ProcCmdResolveImage2, + CmdResolveImage2KHR: ProcCmdResolveImage2KHR, + CmdSetAlphaToCoverageEnableEXT: ProcCmdSetAlphaToCoverageEnableEXT, + CmdSetAlphaToOneEnableEXT: ProcCmdSetAlphaToOneEnableEXT, + CmdSetAttachmentFeedbackLoopEnableEXT: ProcCmdSetAttachmentFeedbackLoopEnableEXT, + CmdSetBlendConstants: ProcCmdSetBlendConstants, + CmdSetCheckpointNV: ProcCmdSetCheckpointNV, + CmdSetCoarseSampleOrderNV: ProcCmdSetCoarseSampleOrderNV, + CmdSetColorBlendAdvancedEXT: ProcCmdSetColorBlendAdvancedEXT, + CmdSetColorBlendEnableEXT: ProcCmdSetColorBlendEnableEXT, + CmdSetColorBlendEquationEXT: ProcCmdSetColorBlendEquationEXT, + CmdSetColorWriteMaskEXT: ProcCmdSetColorWriteMaskEXT, + CmdSetConservativeRasterizationModeEXT: ProcCmdSetConservativeRasterizationModeEXT, + CmdSetCoverageModulationModeNV: ProcCmdSetCoverageModulationModeNV, + CmdSetCoverageModulationTableEnableNV: ProcCmdSetCoverageModulationTableEnableNV, + CmdSetCoverageModulationTableNV: ProcCmdSetCoverageModulationTableNV, + CmdSetCoverageReductionModeNV: ProcCmdSetCoverageReductionModeNV, + CmdSetCoverageToColorEnableNV: ProcCmdSetCoverageToColorEnableNV, + CmdSetCoverageToColorLocationNV: ProcCmdSetCoverageToColorLocationNV, + CmdSetCullMode: ProcCmdSetCullMode, + CmdSetCullModeEXT: ProcCmdSetCullModeEXT, + CmdSetDepthBias: ProcCmdSetDepthBias, + CmdSetDepthBiasEnable: ProcCmdSetDepthBiasEnable, + CmdSetDepthBiasEnableEXT: ProcCmdSetDepthBiasEnableEXT, + CmdSetDepthBounds: ProcCmdSetDepthBounds, + CmdSetDepthBoundsTestEnable: ProcCmdSetDepthBoundsTestEnable, + CmdSetDepthBoundsTestEnableEXT: ProcCmdSetDepthBoundsTestEnableEXT, + CmdSetDepthClampEnableEXT: ProcCmdSetDepthClampEnableEXT, + CmdSetDepthClipEnableEXT: ProcCmdSetDepthClipEnableEXT, + CmdSetDepthClipNegativeOneToOneEXT: ProcCmdSetDepthClipNegativeOneToOneEXT, + CmdSetDepthCompareOp: ProcCmdSetDepthCompareOp, + CmdSetDepthCompareOpEXT: ProcCmdSetDepthCompareOpEXT, + CmdSetDepthTestEnable: ProcCmdSetDepthTestEnable, + CmdSetDepthTestEnableEXT: ProcCmdSetDepthTestEnableEXT, + CmdSetDepthWriteEnable: ProcCmdSetDepthWriteEnable, + CmdSetDepthWriteEnableEXT: ProcCmdSetDepthWriteEnableEXT, + CmdSetDescriptorBufferOffsetsEXT: ProcCmdSetDescriptorBufferOffsetsEXT, + CmdSetDeviceMask: ProcCmdSetDeviceMask, + CmdSetDeviceMaskKHR: ProcCmdSetDeviceMaskKHR, + CmdSetDiscardRectangleEXT: ProcCmdSetDiscardRectangleEXT, + CmdSetDiscardRectangleEnableEXT: ProcCmdSetDiscardRectangleEnableEXT, + CmdSetDiscardRectangleModeEXT: ProcCmdSetDiscardRectangleModeEXT, + CmdSetEvent: ProcCmdSetEvent, + CmdSetEvent2: ProcCmdSetEvent2, + CmdSetEvent2KHR: ProcCmdSetEvent2KHR, + CmdSetExclusiveScissorEnableNV: ProcCmdSetExclusiveScissorEnableNV, + CmdSetExclusiveScissorNV: ProcCmdSetExclusiveScissorNV, + CmdSetExtraPrimitiveOverestimationSizeEXT: ProcCmdSetExtraPrimitiveOverestimationSizeEXT, + CmdSetFragmentShadingRateEnumNV: ProcCmdSetFragmentShadingRateEnumNV, + CmdSetFragmentShadingRateKHR: ProcCmdSetFragmentShadingRateKHR, + CmdSetFrontFace: ProcCmdSetFrontFace, + CmdSetFrontFaceEXT: ProcCmdSetFrontFaceEXT, + CmdSetLineRasterizationModeEXT: ProcCmdSetLineRasterizationModeEXT, + CmdSetLineStippleEXT: ProcCmdSetLineStippleEXT, + CmdSetLineStippleEnableEXT: ProcCmdSetLineStippleEnableEXT, + CmdSetLineWidth: ProcCmdSetLineWidth, + CmdSetLogicOpEXT: ProcCmdSetLogicOpEXT, + CmdSetLogicOpEnableEXT: ProcCmdSetLogicOpEnableEXT, + CmdSetPatchControlPointsEXT: ProcCmdSetPatchControlPointsEXT, + CmdSetPerformanceMarkerINTEL: ProcCmdSetPerformanceMarkerINTEL, + CmdSetPerformanceOverrideINTEL: ProcCmdSetPerformanceOverrideINTEL, + CmdSetPerformanceStreamMarkerINTEL: ProcCmdSetPerformanceStreamMarkerINTEL, + CmdSetPolygonModeEXT: ProcCmdSetPolygonModeEXT, + CmdSetPrimitiveRestartEnable: ProcCmdSetPrimitiveRestartEnable, + CmdSetPrimitiveRestartEnableEXT: ProcCmdSetPrimitiveRestartEnableEXT, + CmdSetPrimitiveTopology: ProcCmdSetPrimitiveTopology, + CmdSetPrimitiveTopologyEXT: ProcCmdSetPrimitiveTopologyEXT, + CmdSetProvokingVertexModeEXT: ProcCmdSetProvokingVertexModeEXT, + CmdSetRasterizationSamplesEXT: ProcCmdSetRasterizationSamplesEXT, + CmdSetRasterizationStreamEXT: ProcCmdSetRasterizationStreamEXT, + CmdSetRasterizerDiscardEnable: ProcCmdSetRasterizerDiscardEnable, + CmdSetRasterizerDiscardEnableEXT: ProcCmdSetRasterizerDiscardEnableEXT, + CmdSetRayTracingPipelineStackSizeKHR: ProcCmdSetRayTracingPipelineStackSizeKHR, + CmdSetRepresentativeFragmentTestEnableNV: ProcCmdSetRepresentativeFragmentTestEnableNV, + CmdSetSampleLocationsEXT: ProcCmdSetSampleLocationsEXT, + CmdSetSampleLocationsEnableEXT: ProcCmdSetSampleLocationsEnableEXT, + CmdSetSampleMaskEXT: ProcCmdSetSampleMaskEXT, + CmdSetScissor: ProcCmdSetScissor, + CmdSetScissorWithCount: ProcCmdSetScissorWithCount, + CmdSetScissorWithCountEXT: ProcCmdSetScissorWithCountEXT, + CmdSetShadingRateImageEnableNV: ProcCmdSetShadingRateImageEnableNV, + CmdSetStencilCompareMask: ProcCmdSetStencilCompareMask, + CmdSetStencilOp: ProcCmdSetStencilOp, + CmdSetStencilOpEXT: ProcCmdSetStencilOpEXT, + CmdSetStencilReference: ProcCmdSetStencilReference, + CmdSetStencilTestEnable: ProcCmdSetStencilTestEnable, + CmdSetStencilTestEnableEXT: ProcCmdSetStencilTestEnableEXT, + CmdSetStencilWriteMask: ProcCmdSetStencilWriteMask, + CmdSetTessellationDomainOriginEXT: ProcCmdSetTessellationDomainOriginEXT, + CmdSetVertexInputEXT: ProcCmdSetVertexInputEXT, + CmdSetViewport: ProcCmdSetViewport, + CmdSetViewportShadingRatePaletteNV: ProcCmdSetViewportShadingRatePaletteNV, + CmdSetViewportSwizzleNV: ProcCmdSetViewportSwizzleNV, + CmdSetViewportWScalingEnableNV: ProcCmdSetViewportWScalingEnableNV, + CmdSetViewportWScalingNV: ProcCmdSetViewportWScalingNV, + CmdSetViewportWithCount: ProcCmdSetViewportWithCount, + CmdSetViewportWithCountEXT: ProcCmdSetViewportWithCountEXT, + CmdSubpassShadingHUAWEI: ProcCmdSubpassShadingHUAWEI, + CmdTraceRaysIndirect2KHR: ProcCmdTraceRaysIndirect2KHR, + CmdTraceRaysIndirectKHR: ProcCmdTraceRaysIndirectKHR, + CmdTraceRaysKHR: ProcCmdTraceRaysKHR, + CmdTraceRaysNV: ProcCmdTraceRaysNV, + CmdUpdateBuffer: ProcCmdUpdateBuffer, + CmdWaitEvents: ProcCmdWaitEvents, + CmdWaitEvents2: ProcCmdWaitEvents2, + CmdWaitEvents2KHR: ProcCmdWaitEvents2KHR, + CmdWriteAccelerationStructuresPropertiesKHR: ProcCmdWriteAccelerationStructuresPropertiesKHR, + CmdWriteAccelerationStructuresPropertiesNV: ProcCmdWriteAccelerationStructuresPropertiesNV, + CmdWriteBufferMarker2AMD: ProcCmdWriteBufferMarker2AMD, + CmdWriteBufferMarkerAMD: ProcCmdWriteBufferMarkerAMD, + CmdWriteMicromapsPropertiesEXT: ProcCmdWriteMicromapsPropertiesEXT, + CmdWriteTimestamp: ProcCmdWriteTimestamp, + CmdWriteTimestamp2: ProcCmdWriteTimestamp2, + CmdWriteTimestamp2KHR: ProcCmdWriteTimestamp2KHR, + CompileDeferredNV: ProcCompileDeferredNV, + CopyAccelerationStructureKHR: ProcCopyAccelerationStructureKHR, + CopyAccelerationStructureToMemoryKHR: ProcCopyAccelerationStructureToMemoryKHR, + CopyMemoryToAccelerationStructureKHR: ProcCopyMemoryToAccelerationStructureKHR, + CopyMemoryToMicromapEXT: ProcCopyMemoryToMicromapEXT, + CopyMicromapEXT: ProcCopyMicromapEXT, + CopyMicromapToMemoryEXT: ProcCopyMicromapToMemoryEXT, + CreateAccelerationStructureKHR: ProcCreateAccelerationStructureKHR, + CreateAccelerationStructureNV: ProcCreateAccelerationStructureNV, + CreateBuffer: ProcCreateBuffer, + CreateBufferView: ProcCreateBufferView, + CreateCommandPool: ProcCreateCommandPool, + CreateComputePipelines: ProcCreateComputePipelines, + CreateCuFunctionNVX: ProcCreateCuFunctionNVX, + CreateCuModuleNVX: ProcCreateCuModuleNVX, + CreateDeferredOperationKHR: ProcCreateDeferredOperationKHR, + CreateDescriptorPool: ProcCreateDescriptorPool, + CreateDescriptorSetLayout: ProcCreateDescriptorSetLayout, + CreateDescriptorUpdateTemplate: ProcCreateDescriptorUpdateTemplate, + CreateDescriptorUpdateTemplateKHR: ProcCreateDescriptorUpdateTemplateKHR, + CreateEvent: ProcCreateEvent, + CreateFence: ProcCreateFence, + CreateFramebuffer: ProcCreateFramebuffer, + CreateGraphicsPipelines: ProcCreateGraphicsPipelines, + CreateImage: ProcCreateImage, + CreateImageView: ProcCreateImageView, + CreateIndirectCommandsLayoutNV: ProcCreateIndirectCommandsLayoutNV, + CreateMicromapEXT: ProcCreateMicromapEXT, + CreateOpticalFlowSessionNV: ProcCreateOpticalFlowSessionNV, + CreatePipelineCache: ProcCreatePipelineCache, + CreatePipelineLayout: ProcCreatePipelineLayout, + CreatePrivateDataSlot: ProcCreatePrivateDataSlot, + CreatePrivateDataSlotEXT: ProcCreatePrivateDataSlotEXT, + CreateQueryPool: ProcCreateQueryPool, + CreateRayTracingPipelinesKHR: ProcCreateRayTracingPipelinesKHR, + CreateRayTracingPipelinesNV: ProcCreateRayTracingPipelinesNV, + CreateRenderPass: ProcCreateRenderPass, + CreateRenderPass2: ProcCreateRenderPass2, + CreateRenderPass2KHR: ProcCreateRenderPass2KHR, + CreateSampler: ProcCreateSampler, + CreateSamplerYcbcrConversion: ProcCreateSamplerYcbcrConversion, + CreateSamplerYcbcrConversionKHR: ProcCreateSamplerYcbcrConversionKHR, + CreateSemaphore: ProcCreateSemaphore, + CreateShaderModule: ProcCreateShaderModule, + CreateShadersEXT: ProcCreateShadersEXT, + CreateSharedSwapchainsKHR: ProcCreateSharedSwapchainsKHR, + CreateSwapchainKHR: ProcCreateSwapchainKHR, + CreateValidationCacheEXT: ProcCreateValidationCacheEXT, + CreateVideoSessionKHR: ProcCreateVideoSessionKHR, + CreateVideoSessionParametersKHR: ProcCreateVideoSessionParametersKHR, + DebugMarkerSetObjectNameEXT: ProcDebugMarkerSetObjectNameEXT, + DebugMarkerSetObjectTagEXT: ProcDebugMarkerSetObjectTagEXT, + DeferredOperationJoinKHR: ProcDeferredOperationJoinKHR, + DestroyAccelerationStructureKHR: ProcDestroyAccelerationStructureKHR, + DestroyAccelerationStructureNV: ProcDestroyAccelerationStructureNV, + DestroyBuffer: ProcDestroyBuffer, + DestroyBufferView: ProcDestroyBufferView, + DestroyCommandPool: ProcDestroyCommandPool, + DestroyCuFunctionNVX: ProcDestroyCuFunctionNVX, + DestroyCuModuleNVX: ProcDestroyCuModuleNVX, + DestroyDeferredOperationKHR: ProcDestroyDeferredOperationKHR, + DestroyDescriptorPool: ProcDestroyDescriptorPool, + DestroyDescriptorSetLayout: ProcDestroyDescriptorSetLayout, + DestroyDescriptorUpdateTemplate: ProcDestroyDescriptorUpdateTemplate, + DestroyDescriptorUpdateTemplateKHR: ProcDestroyDescriptorUpdateTemplateKHR, + DestroyDevice: ProcDestroyDevice, + DestroyEvent: ProcDestroyEvent, + DestroyFence: ProcDestroyFence, + DestroyFramebuffer: ProcDestroyFramebuffer, + DestroyImage: ProcDestroyImage, + DestroyImageView: ProcDestroyImageView, + DestroyIndirectCommandsLayoutNV: ProcDestroyIndirectCommandsLayoutNV, + DestroyMicromapEXT: ProcDestroyMicromapEXT, + DestroyOpticalFlowSessionNV: ProcDestroyOpticalFlowSessionNV, + DestroyPipeline: ProcDestroyPipeline, + DestroyPipelineCache: ProcDestroyPipelineCache, + DestroyPipelineLayout: ProcDestroyPipelineLayout, + DestroyPrivateDataSlot: ProcDestroyPrivateDataSlot, + DestroyPrivateDataSlotEXT: ProcDestroyPrivateDataSlotEXT, + DestroyQueryPool: ProcDestroyQueryPool, + DestroyRenderPass: ProcDestroyRenderPass, + DestroySampler: ProcDestroySampler, + DestroySamplerYcbcrConversion: ProcDestroySamplerYcbcrConversion, + DestroySamplerYcbcrConversionKHR: ProcDestroySamplerYcbcrConversionKHR, + DestroySemaphore: ProcDestroySemaphore, + DestroyShaderEXT: ProcDestroyShaderEXT, + DestroyShaderModule: ProcDestroyShaderModule, + DestroySwapchainKHR: ProcDestroySwapchainKHR, + DestroyValidationCacheEXT: ProcDestroyValidationCacheEXT, + DestroyVideoSessionKHR: ProcDestroyVideoSessionKHR, + DestroyVideoSessionParametersKHR: ProcDestroyVideoSessionParametersKHR, + DeviceWaitIdle: ProcDeviceWaitIdle, + DisplayPowerControlEXT: ProcDisplayPowerControlEXT, + EndCommandBuffer: ProcEndCommandBuffer, + ExportMetalObjectsEXT: ProcExportMetalObjectsEXT, + FlushMappedMemoryRanges: ProcFlushMappedMemoryRanges, + FreeCommandBuffers: ProcFreeCommandBuffers, + FreeDescriptorSets: ProcFreeDescriptorSets, + FreeMemory: ProcFreeMemory, + GetAccelerationStructureBuildSizesKHR: ProcGetAccelerationStructureBuildSizesKHR, + GetAccelerationStructureDeviceAddressKHR: ProcGetAccelerationStructureDeviceAddressKHR, + GetAccelerationStructureHandleNV: ProcGetAccelerationStructureHandleNV, + GetAccelerationStructureMemoryRequirementsNV: ProcGetAccelerationStructureMemoryRequirementsNV, + GetAccelerationStructureOpaqueCaptureDescriptorDataEXT: ProcGetAccelerationStructureOpaqueCaptureDescriptorDataEXT, + GetBufferDeviceAddress: ProcGetBufferDeviceAddress, + GetBufferDeviceAddressEXT: ProcGetBufferDeviceAddressEXT, + GetBufferDeviceAddressKHR: ProcGetBufferDeviceAddressKHR, + GetBufferMemoryRequirements: ProcGetBufferMemoryRequirements, + GetBufferMemoryRequirements2: ProcGetBufferMemoryRequirements2, + GetBufferMemoryRequirements2KHR: ProcGetBufferMemoryRequirements2KHR, + GetBufferOpaqueCaptureAddress: ProcGetBufferOpaqueCaptureAddress, + GetBufferOpaqueCaptureAddressKHR: ProcGetBufferOpaqueCaptureAddressKHR, + GetBufferOpaqueCaptureDescriptorDataEXT: ProcGetBufferOpaqueCaptureDescriptorDataEXT, + GetCalibratedTimestampsEXT: ProcGetCalibratedTimestampsEXT, + GetDeferredOperationMaxConcurrencyKHR: ProcGetDeferredOperationMaxConcurrencyKHR, + GetDeferredOperationResultKHR: ProcGetDeferredOperationResultKHR, + GetDescriptorEXT: ProcGetDescriptorEXT, + GetDescriptorSetHostMappingVALVE: ProcGetDescriptorSetHostMappingVALVE, + GetDescriptorSetLayoutBindingOffsetEXT: ProcGetDescriptorSetLayoutBindingOffsetEXT, + GetDescriptorSetLayoutHostMappingInfoVALVE: ProcGetDescriptorSetLayoutHostMappingInfoVALVE, + GetDescriptorSetLayoutSizeEXT: ProcGetDescriptorSetLayoutSizeEXT, + GetDescriptorSetLayoutSupport: ProcGetDescriptorSetLayoutSupport, + GetDescriptorSetLayoutSupportKHR: ProcGetDescriptorSetLayoutSupportKHR, + GetDeviceAccelerationStructureCompatibilityKHR: ProcGetDeviceAccelerationStructureCompatibilityKHR, + GetDeviceBufferMemoryRequirements: ProcGetDeviceBufferMemoryRequirements, + GetDeviceBufferMemoryRequirementsKHR: ProcGetDeviceBufferMemoryRequirementsKHR, + GetDeviceFaultInfoEXT: ProcGetDeviceFaultInfoEXT, + GetDeviceGroupPeerMemoryFeatures: ProcGetDeviceGroupPeerMemoryFeatures, + GetDeviceGroupPeerMemoryFeaturesKHR: ProcGetDeviceGroupPeerMemoryFeaturesKHR, + GetDeviceGroupPresentCapabilitiesKHR: ProcGetDeviceGroupPresentCapabilitiesKHR, + GetDeviceGroupSurfacePresentModes2EXT: ProcGetDeviceGroupSurfacePresentModes2EXT, + GetDeviceGroupSurfacePresentModesKHR: ProcGetDeviceGroupSurfacePresentModesKHR, + GetDeviceImageMemoryRequirements: ProcGetDeviceImageMemoryRequirements, + GetDeviceImageMemoryRequirementsKHR: ProcGetDeviceImageMemoryRequirementsKHR, + GetDeviceImageSparseMemoryRequirements: ProcGetDeviceImageSparseMemoryRequirements, + GetDeviceImageSparseMemoryRequirementsKHR: ProcGetDeviceImageSparseMemoryRequirementsKHR, + GetDeviceMemoryCommitment: ProcGetDeviceMemoryCommitment, + GetDeviceMemoryOpaqueCaptureAddress: ProcGetDeviceMemoryOpaqueCaptureAddress, + GetDeviceMemoryOpaqueCaptureAddressKHR: ProcGetDeviceMemoryOpaqueCaptureAddressKHR, + GetDeviceMicromapCompatibilityEXT: ProcGetDeviceMicromapCompatibilityEXT, + GetDeviceProcAddr: ProcGetDeviceProcAddr, + GetDeviceQueue: ProcGetDeviceQueue, + GetDeviceQueue2: ProcGetDeviceQueue2, + GetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI: ProcGetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI, + GetDynamicRenderingTilePropertiesQCOM: ProcGetDynamicRenderingTilePropertiesQCOM, + GetEventStatus: ProcGetEventStatus, + GetFenceFdKHR: ProcGetFenceFdKHR, + GetFenceStatus: ProcGetFenceStatus, + GetFenceWin32HandleKHR: ProcGetFenceWin32HandleKHR, + GetFramebufferTilePropertiesQCOM: ProcGetFramebufferTilePropertiesQCOM, + GetGeneratedCommandsMemoryRequirementsNV: ProcGetGeneratedCommandsMemoryRequirementsNV, + GetImageDrmFormatModifierPropertiesEXT: ProcGetImageDrmFormatModifierPropertiesEXT, + GetImageMemoryRequirements: ProcGetImageMemoryRequirements, + GetImageMemoryRequirements2: ProcGetImageMemoryRequirements2, + GetImageMemoryRequirements2KHR: ProcGetImageMemoryRequirements2KHR, + GetImageOpaqueCaptureDescriptorDataEXT: ProcGetImageOpaqueCaptureDescriptorDataEXT, + GetImageSparseMemoryRequirements: ProcGetImageSparseMemoryRequirements, + GetImageSparseMemoryRequirements2: ProcGetImageSparseMemoryRequirements2, + GetImageSparseMemoryRequirements2KHR: ProcGetImageSparseMemoryRequirements2KHR, + GetImageSubresourceLayout: ProcGetImageSubresourceLayout, + GetImageSubresourceLayout2EXT: ProcGetImageSubresourceLayout2EXT, + GetImageViewAddressNVX: ProcGetImageViewAddressNVX, + GetImageViewHandleNVX: ProcGetImageViewHandleNVX, + GetImageViewOpaqueCaptureDescriptorDataEXT: ProcGetImageViewOpaqueCaptureDescriptorDataEXT, + GetMemoryFdKHR: ProcGetMemoryFdKHR, + GetMemoryFdPropertiesKHR: ProcGetMemoryFdPropertiesKHR, + GetMemoryHostPointerPropertiesEXT: ProcGetMemoryHostPointerPropertiesEXT, + GetMemoryRemoteAddressNV: ProcGetMemoryRemoteAddressNV, + GetMemoryWin32HandleKHR: ProcGetMemoryWin32HandleKHR, + GetMemoryWin32HandleNV: ProcGetMemoryWin32HandleNV, + GetMemoryWin32HandlePropertiesKHR: ProcGetMemoryWin32HandlePropertiesKHR, + GetMicromapBuildSizesEXT: ProcGetMicromapBuildSizesEXT, + GetPastPresentationTimingGOOGLE: ProcGetPastPresentationTimingGOOGLE, + GetPerformanceParameterINTEL: ProcGetPerformanceParameterINTEL, + GetPipelineCacheData: ProcGetPipelineCacheData, + GetPipelineExecutableInternalRepresentationsKHR: ProcGetPipelineExecutableInternalRepresentationsKHR, + GetPipelineExecutablePropertiesKHR: ProcGetPipelineExecutablePropertiesKHR, + GetPipelineExecutableStatisticsKHR: ProcGetPipelineExecutableStatisticsKHR, + GetPipelinePropertiesEXT: ProcGetPipelinePropertiesEXT, + GetPrivateData: ProcGetPrivateData, + GetPrivateDataEXT: ProcGetPrivateDataEXT, + GetQueryPoolResults: ProcGetQueryPoolResults, + GetQueueCheckpointData2NV: ProcGetQueueCheckpointData2NV, + GetQueueCheckpointDataNV: ProcGetQueueCheckpointDataNV, + GetRayTracingCaptureReplayShaderGroupHandlesKHR: ProcGetRayTracingCaptureReplayShaderGroupHandlesKHR, + GetRayTracingShaderGroupHandlesKHR: ProcGetRayTracingShaderGroupHandlesKHR, + GetRayTracingShaderGroupHandlesNV: ProcGetRayTracingShaderGroupHandlesNV, + GetRayTracingShaderGroupStackSizeKHR: ProcGetRayTracingShaderGroupStackSizeKHR, + GetRefreshCycleDurationGOOGLE: ProcGetRefreshCycleDurationGOOGLE, + GetRenderAreaGranularity: ProcGetRenderAreaGranularity, + GetSamplerOpaqueCaptureDescriptorDataEXT: ProcGetSamplerOpaqueCaptureDescriptorDataEXT, + GetSemaphoreCounterValue: ProcGetSemaphoreCounterValue, + GetSemaphoreCounterValueKHR: ProcGetSemaphoreCounterValueKHR, + GetSemaphoreFdKHR: ProcGetSemaphoreFdKHR, + GetSemaphoreWin32HandleKHR: ProcGetSemaphoreWin32HandleKHR, + GetShaderBinaryDataEXT: ProcGetShaderBinaryDataEXT, + GetShaderInfoAMD: ProcGetShaderInfoAMD, + GetShaderModuleCreateInfoIdentifierEXT: ProcGetShaderModuleCreateInfoIdentifierEXT, + GetShaderModuleIdentifierEXT: ProcGetShaderModuleIdentifierEXT, + GetSwapchainCounterEXT: ProcGetSwapchainCounterEXT, + GetSwapchainImagesKHR: ProcGetSwapchainImagesKHR, + GetSwapchainStatusKHR: ProcGetSwapchainStatusKHR, + GetValidationCacheDataEXT: ProcGetValidationCacheDataEXT, + GetVideoSessionMemoryRequirementsKHR: ProcGetVideoSessionMemoryRequirementsKHR, + ImportFenceFdKHR: ProcImportFenceFdKHR, + ImportFenceWin32HandleKHR: ProcImportFenceWin32HandleKHR, + ImportSemaphoreFdKHR: ProcImportSemaphoreFdKHR, + ImportSemaphoreWin32HandleKHR: ProcImportSemaphoreWin32HandleKHR, + InitializePerformanceApiINTEL: ProcInitializePerformanceApiINTEL, + InvalidateMappedMemoryRanges: ProcInvalidateMappedMemoryRanges, + MapMemory: ProcMapMemory, + MapMemory2KHR: ProcMapMemory2KHR, + MergePipelineCaches: ProcMergePipelineCaches, + MergeValidationCachesEXT: ProcMergeValidationCachesEXT, + QueueBeginDebugUtilsLabelEXT: ProcQueueBeginDebugUtilsLabelEXT, + QueueBindSparse: ProcQueueBindSparse, + QueueEndDebugUtilsLabelEXT: ProcQueueEndDebugUtilsLabelEXT, + QueueInsertDebugUtilsLabelEXT: ProcQueueInsertDebugUtilsLabelEXT, + QueuePresentKHR: ProcQueuePresentKHR, + QueueSetPerformanceConfigurationINTEL: ProcQueueSetPerformanceConfigurationINTEL, + QueueSubmit: ProcQueueSubmit, + QueueSubmit2: ProcQueueSubmit2, + QueueSubmit2KHR: ProcQueueSubmit2KHR, + QueueWaitIdle: ProcQueueWaitIdle, + RegisterDeviceEventEXT: ProcRegisterDeviceEventEXT, + RegisterDisplayEventEXT: ProcRegisterDisplayEventEXT, + ReleaseFullScreenExclusiveModeEXT: ProcReleaseFullScreenExclusiveModeEXT, + ReleasePerformanceConfigurationINTEL: ProcReleasePerformanceConfigurationINTEL, + ReleaseProfilingLockKHR: ProcReleaseProfilingLockKHR, + ReleaseSwapchainImagesEXT: ProcReleaseSwapchainImagesEXT, + ResetCommandBuffer: ProcResetCommandBuffer, + ResetCommandPool: ProcResetCommandPool, + ResetDescriptorPool: ProcResetDescriptorPool, + ResetEvent: ProcResetEvent, + ResetFences: ProcResetFences, + ResetQueryPool: ProcResetQueryPool, + ResetQueryPoolEXT: ProcResetQueryPoolEXT, + SetDebugUtilsObjectNameEXT: ProcSetDebugUtilsObjectNameEXT, + SetDebugUtilsObjectTagEXT: ProcSetDebugUtilsObjectTagEXT, + SetDeviceMemoryPriorityEXT: ProcSetDeviceMemoryPriorityEXT, + SetEvent: ProcSetEvent, + SetHdrMetadataEXT: ProcSetHdrMetadataEXT, + SetLocalDimmingAMD: ProcSetLocalDimmingAMD, + SetPrivateData: ProcSetPrivateData, + SetPrivateDataEXT: ProcSetPrivateDataEXT, + SignalSemaphore: ProcSignalSemaphore, + SignalSemaphoreKHR: ProcSignalSemaphoreKHR, + TrimCommandPool: ProcTrimCommandPool, + TrimCommandPoolKHR: ProcTrimCommandPoolKHR, + UninitializePerformanceApiINTEL: ProcUninitializePerformanceApiINTEL, + UnmapMemory: ProcUnmapMemory, + UnmapMemory2KHR: ProcUnmapMemory2KHR, + UpdateDescriptorSetWithTemplate: ProcUpdateDescriptorSetWithTemplate, + UpdateDescriptorSetWithTemplateKHR: ProcUpdateDescriptorSetWithTemplateKHR, + UpdateDescriptorSets: ProcUpdateDescriptorSets, + UpdateVideoSessionParametersKHR: ProcUpdateVideoSessionParametersKHR, + WaitForFences: ProcWaitForFences, + WaitForPresentKHR: ProcWaitForPresentKHR, + WaitSemaphores: ProcWaitSemaphores, + WaitSemaphoresKHR: ProcWaitSemaphoresKHR, + WriteAccelerationStructuresPropertiesKHR: ProcWriteAccelerationStructuresPropertiesKHR, + WriteMicromapsPropertiesEXT: ProcWriteMicromapsPropertiesEXT, +} + +load_proc_addresses_device_vtable :: proc(device: Device, vtable: ^Device_VTable) { + vtable.AcquireFullScreenExclusiveModeEXT = auto_cast GetDeviceProcAddr(device, "vkAcquireFullScreenExclusiveModeEXT") + vtable.AcquireNextImage2KHR = auto_cast GetDeviceProcAddr(device, "vkAcquireNextImage2KHR") + vtable.AcquireNextImageKHR = auto_cast GetDeviceProcAddr(device, "vkAcquireNextImageKHR") + vtable.AcquirePerformanceConfigurationINTEL = auto_cast GetDeviceProcAddr(device, "vkAcquirePerformanceConfigurationINTEL") + vtable.AcquireProfilingLockKHR = auto_cast GetDeviceProcAddr(device, "vkAcquireProfilingLockKHR") + vtable.AllocateCommandBuffers = auto_cast GetDeviceProcAddr(device, "vkAllocateCommandBuffers") + vtable.AllocateDescriptorSets = auto_cast GetDeviceProcAddr(device, "vkAllocateDescriptorSets") + vtable.AllocateMemory = auto_cast GetDeviceProcAddr(device, "vkAllocateMemory") + vtable.BeginCommandBuffer = auto_cast GetDeviceProcAddr(device, "vkBeginCommandBuffer") + vtable.BindAccelerationStructureMemoryNV = auto_cast GetDeviceProcAddr(device, "vkBindAccelerationStructureMemoryNV") + vtable.BindBufferMemory = auto_cast GetDeviceProcAddr(device, "vkBindBufferMemory") + vtable.BindBufferMemory2 = auto_cast GetDeviceProcAddr(device, "vkBindBufferMemory2") + vtable.BindBufferMemory2KHR = auto_cast GetDeviceProcAddr(device, "vkBindBufferMemory2KHR") + vtable.BindImageMemory = auto_cast GetDeviceProcAddr(device, "vkBindImageMemory") + vtable.BindImageMemory2 = auto_cast GetDeviceProcAddr(device, "vkBindImageMemory2") + vtable.BindImageMemory2KHR = auto_cast GetDeviceProcAddr(device, "vkBindImageMemory2KHR") + vtable.BindOpticalFlowSessionImageNV = auto_cast GetDeviceProcAddr(device, "vkBindOpticalFlowSessionImageNV") + vtable.BindVideoSessionMemoryKHR = auto_cast GetDeviceProcAddr(device, "vkBindVideoSessionMemoryKHR") + vtable.BuildAccelerationStructuresKHR = auto_cast GetDeviceProcAddr(device, "vkBuildAccelerationStructuresKHR") + vtable.BuildMicromapsEXT = auto_cast GetDeviceProcAddr(device, "vkBuildMicromapsEXT") + vtable.CmdBeginConditionalRenderingEXT = auto_cast GetDeviceProcAddr(device, "vkCmdBeginConditionalRenderingEXT") + vtable.CmdBeginDebugUtilsLabelEXT = auto_cast GetDeviceProcAddr(device, "vkCmdBeginDebugUtilsLabelEXT") + vtable.CmdBeginQuery = auto_cast GetDeviceProcAddr(device, "vkCmdBeginQuery") + vtable.CmdBeginQueryIndexedEXT = auto_cast GetDeviceProcAddr(device, "vkCmdBeginQueryIndexedEXT") + vtable.CmdBeginRenderPass = auto_cast GetDeviceProcAddr(device, "vkCmdBeginRenderPass") + vtable.CmdBeginRenderPass2 = auto_cast GetDeviceProcAddr(device, "vkCmdBeginRenderPass2") + vtable.CmdBeginRenderPass2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdBeginRenderPass2KHR") + vtable.CmdBeginRendering = auto_cast GetDeviceProcAddr(device, "vkCmdBeginRendering") + vtable.CmdBeginRenderingKHR = auto_cast GetDeviceProcAddr(device, "vkCmdBeginRenderingKHR") + vtable.CmdBeginTransformFeedbackEXT = auto_cast GetDeviceProcAddr(device, "vkCmdBeginTransformFeedbackEXT") + vtable.CmdBeginVideoCodingKHR = auto_cast GetDeviceProcAddr(device, "vkCmdBeginVideoCodingKHR") + vtable.CmdBindDescriptorBufferEmbeddedSamplersEXT = auto_cast GetDeviceProcAddr(device, "vkCmdBindDescriptorBufferEmbeddedSamplersEXT") + vtable.CmdBindDescriptorBuffersEXT = auto_cast GetDeviceProcAddr(device, "vkCmdBindDescriptorBuffersEXT") + vtable.CmdBindDescriptorSets = auto_cast GetDeviceProcAddr(device, "vkCmdBindDescriptorSets") + vtable.CmdBindIndexBuffer = auto_cast GetDeviceProcAddr(device, "vkCmdBindIndexBuffer") + vtable.CmdBindInvocationMaskHUAWEI = auto_cast GetDeviceProcAddr(device, "vkCmdBindInvocationMaskHUAWEI") + vtable.CmdBindPipeline = auto_cast GetDeviceProcAddr(device, "vkCmdBindPipeline") + vtable.CmdBindPipelineShaderGroupNV = auto_cast GetDeviceProcAddr(device, "vkCmdBindPipelineShaderGroupNV") + vtable.CmdBindShadersEXT = auto_cast GetDeviceProcAddr(device, "vkCmdBindShadersEXT") + vtable.CmdBindShadingRateImageNV = auto_cast GetDeviceProcAddr(device, "vkCmdBindShadingRateImageNV") + vtable.CmdBindTransformFeedbackBuffersEXT = auto_cast GetDeviceProcAddr(device, "vkCmdBindTransformFeedbackBuffersEXT") + vtable.CmdBindVertexBuffers = auto_cast GetDeviceProcAddr(device, "vkCmdBindVertexBuffers") + vtable.CmdBindVertexBuffers2 = auto_cast GetDeviceProcAddr(device, "vkCmdBindVertexBuffers2") + vtable.CmdBindVertexBuffers2EXT = auto_cast GetDeviceProcAddr(device, "vkCmdBindVertexBuffers2EXT") + vtable.CmdBlitImage = auto_cast GetDeviceProcAddr(device, "vkCmdBlitImage") + vtable.CmdBlitImage2 = auto_cast GetDeviceProcAddr(device, "vkCmdBlitImage2") + vtable.CmdBlitImage2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdBlitImage2KHR") + vtable.CmdBuildAccelerationStructureNV = auto_cast GetDeviceProcAddr(device, "vkCmdBuildAccelerationStructureNV") + vtable.CmdBuildAccelerationStructuresIndirectKHR = auto_cast GetDeviceProcAddr(device, "vkCmdBuildAccelerationStructuresIndirectKHR") + vtable.CmdBuildAccelerationStructuresKHR = auto_cast GetDeviceProcAddr(device, "vkCmdBuildAccelerationStructuresKHR") + vtable.CmdBuildMicromapsEXT = auto_cast GetDeviceProcAddr(device, "vkCmdBuildMicromapsEXT") + vtable.CmdClearAttachments = auto_cast GetDeviceProcAddr(device, "vkCmdClearAttachments") + vtable.CmdClearColorImage = auto_cast GetDeviceProcAddr(device, "vkCmdClearColorImage") + vtable.CmdClearDepthStencilImage = auto_cast GetDeviceProcAddr(device, "vkCmdClearDepthStencilImage") + vtable.CmdControlVideoCodingKHR = auto_cast GetDeviceProcAddr(device, "vkCmdControlVideoCodingKHR") + vtable.CmdCopyAccelerationStructureKHR = auto_cast GetDeviceProcAddr(device, "vkCmdCopyAccelerationStructureKHR") + vtable.CmdCopyAccelerationStructureNV = auto_cast GetDeviceProcAddr(device, "vkCmdCopyAccelerationStructureNV") + vtable.CmdCopyAccelerationStructureToMemoryKHR = auto_cast GetDeviceProcAddr(device, "vkCmdCopyAccelerationStructureToMemoryKHR") + vtable.CmdCopyBuffer = auto_cast GetDeviceProcAddr(device, "vkCmdCopyBuffer") + vtable.CmdCopyBuffer2 = auto_cast GetDeviceProcAddr(device, "vkCmdCopyBuffer2") + vtable.CmdCopyBuffer2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdCopyBuffer2KHR") + vtable.CmdCopyBufferToImage = auto_cast GetDeviceProcAddr(device, "vkCmdCopyBufferToImage") + vtable.CmdCopyBufferToImage2 = auto_cast GetDeviceProcAddr(device, "vkCmdCopyBufferToImage2") + vtable.CmdCopyBufferToImage2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdCopyBufferToImage2KHR") + vtable.CmdCopyImage = auto_cast GetDeviceProcAddr(device, "vkCmdCopyImage") + vtable.CmdCopyImage2 = auto_cast GetDeviceProcAddr(device, "vkCmdCopyImage2") + vtable.CmdCopyImage2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdCopyImage2KHR") + vtable.CmdCopyImageToBuffer = auto_cast GetDeviceProcAddr(device, "vkCmdCopyImageToBuffer") + vtable.CmdCopyImageToBuffer2 = auto_cast GetDeviceProcAddr(device, "vkCmdCopyImageToBuffer2") + vtable.CmdCopyImageToBuffer2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdCopyImageToBuffer2KHR") + vtable.CmdCopyMemoryIndirectNV = auto_cast GetDeviceProcAddr(device, "vkCmdCopyMemoryIndirectNV") + vtable.CmdCopyMemoryToAccelerationStructureKHR = auto_cast GetDeviceProcAddr(device, "vkCmdCopyMemoryToAccelerationStructureKHR") + vtable.CmdCopyMemoryToImageIndirectNV = auto_cast GetDeviceProcAddr(device, "vkCmdCopyMemoryToImageIndirectNV") + vtable.CmdCopyMemoryToMicromapEXT = auto_cast GetDeviceProcAddr(device, "vkCmdCopyMemoryToMicromapEXT") + vtable.CmdCopyMicromapEXT = auto_cast GetDeviceProcAddr(device, "vkCmdCopyMicromapEXT") + vtable.CmdCopyMicromapToMemoryEXT = auto_cast GetDeviceProcAddr(device, "vkCmdCopyMicromapToMemoryEXT") + vtable.CmdCopyQueryPoolResults = auto_cast GetDeviceProcAddr(device, "vkCmdCopyQueryPoolResults") + vtable.CmdCuLaunchKernelNVX = auto_cast GetDeviceProcAddr(device, "vkCmdCuLaunchKernelNVX") + vtable.CmdDebugMarkerBeginEXT = auto_cast GetDeviceProcAddr(device, "vkCmdDebugMarkerBeginEXT") + vtable.CmdDebugMarkerEndEXT = auto_cast GetDeviceProcAddr(device, "vkCmdDebugMarkerEndEXT") + vtable.CmdDebugMarkerInsertEXT = auto_cast GetDeviceProcAddr(device, "vkCmdDebugMarkerInsertEXT") + vtable.CmdDecodeVideoKHR = auto_cast GetDeviceProcAddr(device, "vkCmdDecodeVideoKHR") + vtable.CmdDecompressMemoryIndirectCountNV = auto_cast GetDeviceProcAddr(device, "vkCmdDecompressMemoryIndirectCountNV") + vtable.CmdDecompressMemoryNV = auto_cast GetDeviceProcAddr(device, "vkCmdDecompressMemoryNV") + vtable.CmdDispatch = auto_cast GetDeviceProcAddr(device, "vkCmdDispatch") + vtable.CmdDispatchBase = auto_cast GetDeviceProcAddr(device, "vkCmdDispatchBase") + vtable.CmdDispatchBaseKHR = auto_cast GetDeviceProcAddr(device, "vkCmdDispatchBaseKHR") + vtable.CmdDispatchIndirect = auto_cast GetDeviceProcAddr(device, "vkCmdDispatchIndirect") + vtable.CmdDraw = auto_cast GetDeviceProcAddr(device, "vkCmdDraw") + vtable.CmdDrawClusterHUAWEI = auto_cast GetDeviceProcAddr(device, "vkCmdDrawClusterHUAWEI") + vtable.CmdDrawClusterIndirectHUAWEI = auto_cast GetDeviceProcAddr(device, "vkCmdDrawClusterIndirectHUAWEI") + vtable.CmdDrawIndexed = auto_cast GetDeviceProcAddr(device, "vkCmdDrawIndexed") + vtable.CmdDrawIndexedIndirect = auto_cast GetDeviceProcAddr(device, "vkCmdDrawIndexedIndirect") + vtable.CmdDrawIndexedIndirectCount = auto_cast GetDeviceProcAddr(device, "vkCmdDrawIndexedIndirectCount") + vtable.CmdDrawIndexedIndirectCountAMD = auto_cast GetDeviceProcAddr(device, "vkCmdDrawIndexedIndirectCountAMD") + vtable.CmdDrawIndexedIndirectCountKHR = auto_cast GetDeviceProcAddr(device, "vkCmdDrawIndexedIndirectCountKHR") + vtable.CmdDrawIndirect = auto_cast GetDeviceProcAddr(device, "vkCmdDrawIndirect") + vtable.CmdDrawIndirectByteCountEXT = auto_cast GetDeviceProcAddr(device, "vkCmdDrawIndirectByteCountEXT") + vtable.CmdDrawIndirectCount = auto_cast GetDeviceProcAddr(device, "vkCmdDrawIndirectCount") + vtable.CmdDrawIndirectCountAMD = auto_cast GetDeviceProcAddr(device, "vkCmdDrawIndirectCountAMD") + vtable.CmdDrawIndirectCountKHR = auto_cast GetDeviceProcAddr(device, "vkCmdDrawIndirectCountKHR") + vtable.CmdDrawMeshTasksEXT = auto_cast GetDeviceProcAddr(device, "vkCmdDrawMeshTasksEXT") + vtable.CmdDrawMeshTasksIndirectCountEXT = auto_cast GetDeviceProcAddr(device, "vkCmdDrawMeshTasksIndirectCountEXT") + vtable.CmdDrawMeshTasksIndirectCountNV = auto_cast GetDeviceProcAddr(device, "vkCmdDrawMeshTasksIndirectCountNV") + vtable.CmdDrawMeshTasksIndirectEXT = auto_cast GetDeviceProcAddr(device, "vkCmdDrawMeshTasksIndirectEXT") + vtable.CmdDrawMeshTasksIndirectNV = auto_cast GetDeviceProcAddr(device, "vkCmdDrawMeshTasksIndirectNV") + vtable.CmdDrawMeshTasksNV = auto_cast GetDeviceProcAddr(device, "vkCmdDrawMeshTasksNV") + vtable.CmdDrawMultiEXT = auto_cast GetDeviceProcAddr(device, "vkCmdDrawMultiEXT") + vtable.CmdDrawMultiIndexedEXT = auto_cast GetDeviceProcAddr(device, "vkCmdDrawMultiIndexedEXT") + vtable.CmdEndConditionalRenderingEXT = auto_cast GetDeviceProcAddr(device, "vkCmdEndConditionalRenderingEXT") + vtable.CmdEndDebugUtilsLabelEXT = auto_cast GetDeviceProcAddr(device, "vkCmdEndDebugUtilsLabelEXT") + vtable.CmdEndQuery = auto_cast GetDeviceProcAddr(device, "vkCmdEndQuery") + vtable.CmdEndQueryIndexedEXT = auto_cast GetDeviceProcAddr(device, "vkCmdEndQueryIndexedEXT") + vtable.CmdEndRenderPass = auto_cast GetDeviceProcAddr(device, "vkCmdEndRenderPass") + vtable.CmdEndRenderPass2 = auto_cast GetDeviceProcAddr(device, "vkCmdEndRenderPass2") + vtable.CmdEndRenderPass2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdEndRenderPass2KHR") + vtable.CmdEndRendering = auto_cast GetDeviceProcAddr(device, "vkCmdEndRendering") + vtable.CmdEndRenderingKHR = auto_cast GetDeviceProcAddr(device, "vkCmdEndRenderingKHR") + vtable.CmdEndTransformFeedbackEXT = auto_cast GetDeviceProcAddr(device, "vkCmdEndTransformFeedbackEXT") + vtable.CmdEndVideoCodingKHR = auto_cast GetDeviceProcAddr(device, "vkCmdEndVideoCodingKHR") + vtable.CmdExecuteCommands = auto_cast GetDeviceProcAddr(device, "vkCmdExecuteCommands") + vtable.CmdExecuteGeneratedCommandsNV = auto_cast GetDeviceProcAddr(device, "vkCmdExecuteGeneratedCommandsNV") + vtable.CmdFillBuffer = auto_cast GetDeviceProcAddr(device, "vkCmdFillBuffer") + vtable.CmdInsertDebugUtilsLabelEXT = auto_cast GetDeviceProcAddr(device, "vkCmdInsertDebugUtilsLabelEXT") + vtable.CmdNextSubpass = auto_cast GetDeviceProcAddr(device, "vkCmdNextSubpass") + vtable.CmdNextSubpass2 = auto_cast GetDeviceProcAddr(device, "vkCmdNextSubpass2") + vtable.CmdNextSubpass2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdNextSubpass2KHR") + vtable.CmdOpticalFlowExecuteNV = auto_cast GetDeviceProcAddr(device, "vkCmdOpticalFlowExecuteNV") + vtable.CmdPipelineBarrier = auto_cast GetDeviceProcAddr(device, "vkCmdPipelineBarrier") + vtable.CmdPipelineBarrier2 = auto_cast GetDeviceProcAddr(device, "vkCmdPipelineBarrier2") + vtable.CmdPipelineBarrier2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdPipelineBarrier2KHR") + vtable.CmdPreprocessGeneratedCommandsNV = auto_cast GetDeviceProcAddr(device, "vkCmdPreprocessGeneratedCommandsNV") + vtable.CmdPushConstants = auto_cast GetDeviceProcAddr(device, "vkCmdPushConstants") + vtable.CmdPushDescriptorSetKHR = auto_cast GetDeviceProcAddr(device, "vkCmdPushDescriptorSetKHR") + vtable.CmdPushDescriptorSetWithTemplateKHR = auto_cast GetDeviceProcAddr(device, "vkCmdPushDescriptorSetWithTemplateKHR") + vtable.CmdResetEvent = auto_cast GetDeviceProcAddr(device, "vkCmdResetEvent") + vtable.CmdResetEvent2 = auto_cast GetDeviceProcAddr(device, "vkCmdResetEvent2") + vtable.CmdResetEvent2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdResetEvent2KHR") + vtable.CmdResetQueryPool = auto_cast GetDeviceProcAddr(device, "vkCmdResetQueryPool") + vtable.CmdResolveImage = auto_cast GetDeviceProcAddr(device, "vkCmdResolveImage") + vtable.CmdResolveImage2 = auto_cast GetDeviceProcAddr(device, "vkCmdResolveImage2") + vtable.CmdResolveImage2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdResolveImage2KHR") + vtable.CmdSetAlphaToCoverageEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetAlphaToCoverageEnableEXT") + vtable.CmdSetAlphaToOneEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetAlphaToOneEnableEXT") + vtable.CmdSetAttachmentFeedbackLoopEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetAttachmentFeedbackLoopEnableEXT") + vtable.CmdSetBlendConstants = auto_cast GetDeviceProcAddr(device, "vkCmdSetBlendConstants") + vtable.CmdSetCheckpointNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetCheckpointNV") + vtable.CmdSetCoarseSampleOrderNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetCoarseSampleOrderNV") + vtable.CmdSetColorBlendAdvancedEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetColorBlendAdvancedEXT") + vtable.CmdSetColorBlendEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetColorBlendEnableEXT") + vtable.CmdSetColorBlendEquationEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetColorBlendEquationEXT") + vtable.CmdSetColorWriteMaskEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetColorWriteMaskEXT") + vtable.CmdSetConservativeRasterizationModeEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetConservativeRasterizationModeEXT") + vtable.CmdSetCoverageModulationModeNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetCoverageModulationModeNV") + vtable.CmdSetCoverageModulationTableEnableNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetCoverageModulationTableEnableNV") + vtable.CmdSetCoverageModulationTableNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetCoverageModulationTableNV") + vtable.CmdSetCoverageReductionModeNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetCoverageReductionModeNV") + vtable.CmdSetCoverageToColorEnableNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetCoverageToColorEnableNV") + vtable.CmdSetCoverageToColorLocationNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetCoverageToColorLocationNV") + vtable.CmdSetCullMode = auto_cast GetDeviceProcAddr(device, "vkCmdSetCullMode") + vtable.CmdSetCullModeEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetCullModeEXT") + vtable.CmdSetDepthBias = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthBias") + vtable.CmdSetDepthBiasEnable = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthBiasEnable") + vtable.CmdSetDepthBiasEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthBiasEnableEXT") + vtable.CmdSetDepthBounds = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthBounds") + vtable.CmdSetDepthBoundsTestEnable = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthBoundsTestEnable") + vtable.CmdSetDepthBoundsTestEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthBoundsTestEnableEXT") + vtable.CmdSetDepthClampEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthClampEnableEXT") + vtable.CmdSetDepthClipEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthClipEnableEXT") + vtable.CmdSetDepthClipNegativeOneToOneEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthClipNegativeOneToOneEXT") + vtable.CmdSetDepthCompareOp = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthCompareOp") + vtable.CmdSetDepthCompareOpEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthCompareOpEXT") + vtable.CmdSetDepthTestEnable = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthTestEnable") + vtable.CmdSetDepthTestEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthTestEnableEXT") + vtable.CmdSetDepthWriteEnable = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthWriteEnable") + vtable.CmdSetDepthWriteEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthWriteEnableEXT") + vtable.CmdSetDescriptorBufferOffsetsEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetDescriptorBufferOffsetsEXT") + vtable.CmdSetDeviceMask = auto_cast GetDeviceProcAddr(device, "vkCmdSetDeviceMask") + vtable.CmdSetDeviceMaskKHR = auto_cast GetDeviceProcAddr(device, "vkCmdSetDeviceMaskKHR") + vtable.CmdSetDiscardRectangleEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetDiscardRectangleEXT") + vtable.CmdSetDiscardRectangleEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetDiscardRectangleEnableEXT") + vtable.CmdSetDiscardRectangleModeEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetDiscardRectangleModeEXT") + vtable.CmdSetEvent = auto_cast GetDeviceProcAddr(device, "vkCmdSetEvent") + vtable.CmdSetEvent2 = auto_cast GetDeviceProcAddr(device, "vkCmdSetEvent2") + vtable.CmdSetEvent2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdSetEvent2KHR") + vtable.CmdSetExclusiveScissorEnableNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetExclusiveScissorEnableNV") + vtable.CmdSetExclusiveScissorNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetExclusiveScissorNV") + vtable.CmdSetExtraPrimitiveOverestimationSizeEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetExtraPrimitiveOverestimationSizeEXT") + vtable.CmdSetFragmentShadingRateEnumNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetFragmentShadingRateEnumNV") + vtable.CmdSetFragmentShadingRateKHR = auto_cast GetDeviceProcAddr(device, "vkCmdSetFragmentShadingRateKHR") + vtable.CmdSetFrontFace = auto_cast GetDeviceProcAddr(device, "vkCmdSetFrontFace") + vtable.CmdSetFrontFaceEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetFrontFaceEXT") + vtable.CmdSetLineRasterizationModeEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetLineRasterizationModeEXT") + vtable.CmdSetLineStippleEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetLineStippleEXT") + vtable.CmdSetLineStippleEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetLineStippleEnableEXT") + vtable.CmdSetLineWidth = auto_cast GetDeviceProcAddr(device, "vkCmdSetLineWidth") + vtable.CmdSetLogicOpEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetLogicOpEXT") + vtable.CmdSetLogicOpEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetLogicOpEnableEXT") + vtable.CmdSetPatchControlPointsEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetPatchControlPointsEXT") + vtable.CmdSetPerformanceMarkerINTEL = auto_cast GetDeviceProcAddr(device, "vkCmdSetPerformanceMarkerINTEL") + vtable.CmdSetPerformanceOverrideINTEL = auto_cast GetDeviceProcAddr(device, "vkCmdSetPerformanceOverrideINTEL") + vtable.CmdSetPerformanceStreamMarkerINTEL = auto_cast GetDeviceProcAddr(device, "vkCmdSetPerformanceStreamMarkerINTEL") + vtable.CmdSetPolygonModeEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetPolygonModeEXT") + vtable.CmdSetPrimitiveRestartEnable = auto_cast GetDeviceProcAddr(device, "vkCmdSetPrimitiveRestartEnable") + vtable.CmdSetPrimitiveRestartEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetPrimitiveRestartEnableEXT") + vtable.CmdSetPrimitiveTopology = auto_cast GetDeviceProcAddr(device, "vkCmdSetPrimitiveTopology") + vtable.CmdSetPrimitiveTopologyEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetPrimitiveTopologyEXT") + vtable.CmdSetProvokingVertexModeEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetProvokingVertexModeEXT") + vtable.CmdSetRasterizationSamplesEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetRasterizationSamplesEXT") + vtable.CmdSetRasterizationStreamEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetRasterizationStreamEXT") + vtable.CmdSetRasterizerDiscardEnable = auto_cast GetDeviceProcAddr(device, "vkCmdSetRasterizerDiscardEnable") + vtable.CmdSetRasterizerDiscardEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetRasterizerDiscardEnableEXT") + vtable.CmdSetRayTracingPipelineStackSizeKHR = auto_cast GetDeviceProcAddr(device, "vkCmdSetRayTracingPipelineStackSizeKHR") + vtable.CmdSetRepresentativeFragmentTestEnableNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetRepresentativeFragmentTestEnableNV") + vtable.CmdSetSampleLocationsEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetSampleLocationsEXT") + vtable.CmdSetSampleLocationsEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetSampleLocationsEnableEXT") + vtable.CmdSetSampleMaskEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetSampleMaskEXT") + vtable.CmdSetScissor = auto_cast GetDeviceProcAddr(device, "vkCmdSetScissor") + vtable.CmdSetScissorWithCount = auto_cast GetDeviceProcAddr(device, "vkCmdSetScissorWithCount") + vtable.CmdSetScissorWithCountEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetScissorWithCountEXT") + vtable.CmdSetShadingRateImageEnableNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetShadingRateImageEnableNV") + vtable.CmdSetStencilCompareMask = auto_cast GetDeviceProcAddr(device, "vkCmdSetStencilCompareMask") + vtable.CmdSetStencilOp = auto_cast GetDeviceProcAddr(device, "vkCmdSetStencilOp") + vtable.CmdSetStencilOpEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetStencilOpEXT") + vtable.CmdSetStencilReference = auto_cast GetDeviceProcAddr(device, "vkCmdSetStencilReference") + vtable.CmdSetStencilTestEnable = auto_cast GetDeviceProcAddr(device, "vkCmdSetStencilTestEnable") + vtable.CmdSetStencilTestEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetStencilTestEnableEXT") + vtable.CmdSetStencilWriteMask = auto_cast GetDeviceProcAddr(device, "vkCmdSetStencilWriteMask") + vtable.CmdSetTessellationDomainOriginEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetTessellationDomainOriginEXT") + vtable.CmdSetVertexInputEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetVertexInputEXT") + vtable.CmdSetViewport = auto_cast GetDeviceProcAddr(device, "vkCmdSetViewport") + vtable.CmdSetViewportShadingRatePaletteNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetViewportShadingRatePaletteNV") + vtable.CmdSetViewportSwizzleNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetViewportSwizzleNV") + vtable.CmdSetViewportWScalingEnableNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetViewportWScalingEnableNV") + vtable.CmdSetViewportWScalingNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetViewportWScalingNV") + vtable.CmdSetViewportWithCount = auto_cast GetDeviceProcAddr(device, "vkCmdSetViewportWithCount") + vtable.CmdSetViewportWithCountEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetViewportWithCountEXT") + vtable.CmdSubpassShadingHUAWEI = auto_cast GetDeviceProcAddr(device, "vkCmdSubpassShadingHUAWEI") + vtable.CmdTraceRaysIndirect2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdTraceRaysIndirect2KHR") + vtable.CmdTraceRaysIndirectKHR = auto_cast GetDeviceProcAddr(device, "vkCmdTraceRaysIndirectKHR") + vtable.CmdTraceRaysKHR = auto_cast GetDeviceProcAddr(device, "vkCmdTraceRaysKHR") + vtable.CmdTraceRaysNV = auto_cast GetDeviceProcAddr(device, "vkCmdTraceRaysNV") + vtable.CmdUpdateBuffer = auto_cast GetDeviceProcAddr(device, "vkCmdUpdateBuffer") + vtable.CmdWaitEvents = auto_cast GetDeviceProcAddr(device, "vkCmdWaitEvents") + vtable.CmdWaitEvents2 = auto_cast GetDeviceProcAddr(device, "vkCmdWaitEvents2") + vtable.CmdWaitEvents2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdWaitEvents2KHR") + vtable.CmdWriteAccelerationStructuresPropertiesKHR = auto_cast GetDeviceProcAddr(device, "vkCmdWriteAccelerationStructuresPropertiesKHR") + vtable.CmdWriteAccelerationStructuresPropertiesNV = auto_cast GetDeviceProcAddr(device, "vkCmdWriteAccelerationStructuresPropertiesNV") + vtable.CmdWriteBufferMarker2AMD = auto_cast GetDeviceProcAddr(device, "vkCmdWriteBufferMarker2AMD") + vtable.CmdWriteBufferMarkerAMD = auto_cast GetDeviceProcAddr(device, "vkCmdWriteBufferMarkerAMD") + vtable.CmdWriteMicromapsPropertiesEXT = auto_cast GetDeviceProcAddr(device, "vkCmdWriteMicromapsPropertiesEXT") + vtable.CmdWriteTimestamp = auto_cast GetDeviceProcAddr(device, "vkCmdWriteTimestamp") + vtable.CmdWriteTimestamp2 = auto_cast GetDeviceProcAddr(device, "vkCmdWriteTimestamp2") + vtable.CmdWriteTimestamp2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdWriteTimestamp2KHR") + vtable.CompileDeferredNV = auto_cast GetDeviceProcAddr(device, "vkCompileDeferredNV") + vtable.CopyAccelerationStructureKHR = auto_cast GetDeviceProcAddr(device, "vkCopyAccelerationStructureKHR") + vtable.CopyAccelerationStructureToMemoryKHR = auto_cast GetDeviceProcAddr(device, "vkCopyAccelerationStructureToMemoryKHR") + vtable.CopyMemoryToAccelerationStructureKHR = auto_cast GetDeviceProcAddr(device, "vkCopyMemoryToAccelerationStructureKHR") + vtable.CopyMemoryToMicromapEXT = auto_cast GetDeviceProcAddr(device, "vkCopyMemoryToMicromapEXT") + vtable.CopyMicromapEXT = auto_cast GetDeviceProcAddr(device, "vkCopyMicromapEXT") + vtable.CopyMicromapToMemoryEXT = auto_cast GetDeviceProcAddr(device, "vkCopyMicromapToMemoryEXT") + vtable.CreateAccelerationStructureKHR = auto_cast GetDeviceProcAddr(device, "vkCreateAccelerationStructureKHR") + vtable.CreateAccelerationStructureNV = auto_cast GetDeviceProcAddr(device, "vkCreateAccelerationStructureNV") + vtable.CreateBuffer = auto_cast GetDeviceProcAddr(device, "vkCreateBuffer") + vtable.CreateBufferView = auto_cast GetDeviceProcAddr(device, "vkCreateBufferView") + vtable.CreateCommandPool = auto_cast GetDeviceProcAddr(device, "vkCreateCommandPool") + vtable.CreateComputePipelines = auto_cast GetDeviceProcAddr(device, "vkCreateComputePipelines") + vtable.CreateCuFunctionNVX = auto_cast GetDeviceProcAddr(device, "vkCreateCuFunctionNVX") + vtable.CreateCuModuleNVX = auto_cast GetDeviceProcAddr(device, "vkCreateCuModuleNVX") + vtable.CreateDeferredOperationKHR = auto_cast GetDeviceProcAddr(device, "vkCreateDeferredOperationKHR") + vtable.CreateDescriptorPool = auto_cast GetDeviceProcAddr(device, "vkCreateDescriptorPool") + vtable.CreateDescriptorSetLayout = auto_cast GetDeviceProcAddr(device, "vkCreateDescriptorSetLayout") + vtable.CreateDescriptorUpdateTemplate = auto_cast GetDeviceProcAddr(device, "vkCreateDescriptorUpdateTemplate") + vtable.CreateDescriptorUpdateTemplateKHR = auto_cast GetDeviceProcAddr(device, "vkCreateDescriptorUpdateTemplateKHR") + vtable.CreateEvent = auto_cast GetDeviceProcAddr(device, "vkCreateEvent") + vtable.CreateFence = auto_cast GetDeviceProcAddr(device, "vkCreateFence") + vtable.CreateFramebuffer = auto_cast GetDeviceProcAddr(device, "vkCreateFramebuffer") + vtable.CreateGraphicsPipelines = auto_cast GetDeviceProcAddr(device, "vkCreateGraphicsPipelines") + vtable.CreateImage = auto_cast GetDeviceProcAddr(device, "vkCreateImage") + vtable.CreateImageView = auto_cast GetDeviceProcAddr(device, "vkCreateImageView") + vtable.CreateIndirectCommandsLayoutNV = auto_cast GetDeviceProcAddr(device, "vkCreateIndirectCommandsLayoutNV") + vtable.CreateMicromapEXT = auto_cast GetDeviceProcAddr(device, "vkCreateMicromapEXT") + vtable.CreateOpticalFlowSessionNV = auto_cast GetDeviceProcAddr(device, "vkCreateOpticalFlowSessionNV") + vtable.CreatePipelineCache = auto_cast GetDeviceProcAddr(device, "vkCreatePipelineCache") + vtable.CreatePipelineLayout = auto_cast GetDeviceProcAddr(device, "vkCreatePipelineLayout") + vtable.CreatePrivateDataSlot = auto_cast GetDeviceProcAddr(device, "vkCreatePrivateDataSlot") + vtable.CreatePrivateDataSlotEXT = auto_cast GetDeviceProcAddr(device, "vkCreatePrivateDataSlotEXT") + vtable.CreateQueryPool = auto_cast GetDeviceProcAddr(device, "vkCreateQueryPool") + vtable.CreateRayTracingPipelinesKHR = auto_cast GetDeviceProcAddr(device, "vkCreateRayTracingPipelinesKHR") + vtable.CreateRayTracingPipelinesNV = auto_cast GetDeviceProcAddr(device, "vkCreateRayTracingPipelinesNV") + vtable.CreateRenderPass = auto_cast GetDeviceProcAddr(device, "vkCreateRenderPass") + vtable.CreateRenderPass2 = auto_cast GetDeviceProcAddr(device, "vkCreateRenderPass2") + vtable.CreateRenderPass2KHR = auto_cast GetDeviceProcAddr(device, "vkCreateRenderPass2KHR") + vtable.CreateSampler = auto_cast GetDeviceProcAddr(device, "vkCreateSampler") + vtable.CreateSamplerYcbcrConversion = auto_cast GetDeviceProcAddr(device, "vkCreateSamplerYcbcrConversion") + vtable.CreateSamplerYcbcrConversionKHR = auto_cast GetDeviceProcAddr(device, "vkCreateSamplerYcbcrConversionKHR") + vtable.CreateSemaphore = auto_cast GetDeviceProcAddr(device, "vkCreateSemaphore") + vtable.CreateShaderModule = auto_cast GetDeviceProcAddr(device, "vkCreateShaderModule") + vtable.CreateShadersEXT = auto_cast GetDeviceProcAddr(device, "vkCreateShadersEXT") + vtable.CreateSharedSwapchainsKHR = auto_cast GetDeviceProcAddr(device, "vkCreateSharedSwapchainsKHR") + vtable.CreateSwapchainKHR = auto_cast GetDeviceProcAddr(device, "vkCreateSwapchainKHR") + vtable.CreateValidationCacheEXT = auto_cast GetDeviceProcAddr(device, "vkCreateValidationCacheEXT") + vtable.CreateVideoSessionKHR = auto_cast GetDeviceProcAddr(device, "vkCreateVideoSessionKHR") + vtable.CreateVideoSessionParametersKHR = auto_cast GetDeviceProcAddr(device, "vkCreateVideoSessionParametersKHR") + vtable.DebugMarkerSetObjectNameEXT = auto_cast GetDeviceProcAddr(device, "vkDebugMarkerSetObjectNameEXT") + vtable.DebugMarkerSetObjectTagEXT = auto_cast GetDeviceProcAddr(device, "vkDebugMarkerSetObjectTagEXT") + vtable.DeferredOperationJoinKHR = auto_cast GetDeviceProcAddr(device, "vkDeferredOperationJoinKHR") + vtable.DestroyAccelerationStructureKHR = auto_cast GetDeviceProcAddr(device, "vkDestroyAccelerationStructureKHR") + vtable.DestroyAccelerationStructureNV = auto_cast GetDeviceProcAddr(device, "vkDestroyAccelerationStructureNV") + vtable.DestroyBuffer = auto_cast GetDeviceProcAddr(device, "vkDestroyBuffer") + vtable.DestroyBufferView = auto_cast GetDeviceProcAddr(device, "vkDestroyBufferView") + vtable.DestroyCommandPool = auto_cast GetDeviceProcAddr(device, "vkDestroyCommandPool") + vtable.DestroyCuFunctionNVX = auto_cast GetDeviceProcAddr(device, "vkDestroyCuFunctionNVX") + vtable.DestroyCuModuleNVX = auto_cast GetDeviceProcAddr(device, "vkDestroyCuModuleNVX") + vtable.DestroyDeferredOperationKHR = auto_cast GetDeviceProcAddr(device, "vkDestroyDeferredOperationKHR") + vtable.DestroyDescriptorPool = auto_cast GetDeviceProcAddr(device, "vkDestroyDescriptorPool") + vtable.DestroyDescriptorSetLayout = auto_cast GetDeviceProcAddr(device, "vkDestroyDescriptorSetLayout") + vtable.DestroyDescriptorUpdateTemplate = auto_cast GetDeviceProcAddr(device, "vkDestroyDescriptorUpdateTemplate") + vtable.DestroyDescriptorUpdateTemplateKHR = auto_cast GetDeviceProcAddr(device, "vkDestroyDescriptorUpdateTemplateKHR") + vtable.DestroyDevice = auto_cast GetDeviceProcAddr(device, "vkDestroyDevice") + vtable.DestroyEvent = auto_cast GetDeviceProcAddr(device, "vkDestroyEvent") + vtable.DestroyFence = auto_cast GetDeviceProcAddr(device, "vkDestroyFence") + vtable.DestroyFramebuffer = auto_cast GetDeviceProcAddr(device, "vkDestroyFramebuffer") + vtable.DestroyImage = auto_cast GetDeviceProcAddr(device, "vkDestroyImage") + vtable.DestroyImageView = auto_cast GetDeviceProcAddr(device, "vkDestroyImageView") + vtable.DestroyIndirectCommandsLayoutNV = auto_cast GetDeviceProcAddr(device, "vkDestroyIndirectCommandsLayoutNV") + vtable.DestroyMicromapEXT = auto_cast GetDeviceProcAddr(device, "vkDestroyMicromapEXT") + vtable.DestroyOpticalFlowSessionNV = auto_cast GetDeviceProcAddr(device, "vkDestroyOpticalFlowSessionNV") + vtable.DestroyPipeline = auto_cast GetDeviceProcAddr(device, "vkDestroyPipeline") + vtable.DestroyPipelineCache = auto_cast GetDeviceProcAddr(device, "vkDestroyPipelineCache") + vtable.DestroyPipelineLayout = auto_cast GetDeviceProcAddr(device, "vkDestroyPipelineLayout") + vtable.DestroyPrivateDataSlot = auto_cast GetDeviceProcAddr(device, "vkDestroyPrivateDataSlot") + vtable.DestroyPrivateDataSlotEXT = auto_cast GetDeviceProcAddr(device, "vkDestroyPrivateDataSlotEXT") + vtable.DestroyQueryPool = auto_cast GetDeviceProcAddr(device, "vkDestroyQueryPool") + vtable.DestroyRenderPass = auto_cast GetDeviceProcAddr(device, "vkDestroyRenderPass") + vtable.DestroySampler = auto_cast GetDeviceProcAddr(device, "vkDestroySampler") + vtable.DestroySamplerYcbcrConversion = auto_cast GetDeviceProcAddr(device, "vkDestroySamplerYcbcrConversion") + vtable.DestroySamplerYcbcrConversionKHR = auto_cast GetDeviceProcAddr(device, "vkDestroySamplerYcbcrConversionKHR") + vtable.DestroySemaphore = auto_cast GetDeviceProcAddr(device, "vkDestroySemaphore") + vtable.DestroyShaderEXT = auto_cast GetDeviceProcAddr(device, "vkDestroyShaderEXT") + vtable.DestroyShaderModule = auto_cast GetDeviceProcAddr(device, "vkDestroyShaderModule") + vtable.DestroySwapchainKHR = auto_cast GetDeviceProcAddr(device, "vkDestroySwapchainKHR") + vtable.DestroyValidationCacheEXT = auto_cast GetDeviceProcAddr(device, "vkDestroyValidationCacheEXT") + vtable.DestroyVideoSessionKHR = auto_cast GetDeviceProcAddr(device, "vkDestroyVideoSessionKHR") + vtable.DestroyVideoSessionParametersKHR = auto_cast GetDeviceProcAddr(device, "vkDestroyVideoSessionParametersKHR") + vtable.DeviceWaitIdle = auto_cast GetDeviceProcAddr(device, "vkDeviceWaitIdle") + vtable.DisplayPowerControlEXT = auto_cast GetDeviceProcAddr(device, "vkDisplayPowerControlEXT") + vtable.EndCommandBuffer = auto_cast GetDeviceProcAddr(device, "vkEndCommandBuffer") + vtable.ExportMetalObjectsEXT = auto_cast GetDeviceProcAddr(device, "vkExportMetalObjectsEXT") + vtable.FlushMappedMemoryRanges = auto_cast GetDeviceProcAddr(device, "vkFlushMappedMemoryRanges") + vtable.FreeCommandBuffers = auto_cast GetDeviceProcAddr(device, "vkFreeCommandBuffers") + vtable.FreeDescriptorSets = auto_cast GetDeviceProcAddr(device, "vkFreeDescriptorSets") + vtable.FreeMemory = auto_cast GetDeviceProcAddr(device, "vkFreeMemory") + vtable.GetAccelerationStructureBuildSizesKHR = auto_cast GetDeviceProcAddr(device, "vkGetAccelerationStructureBuildSizesKHR") + vtable.GetAccelerationStructureDeviceAddressKHR = auto_cast GetDeviceProcAddr(device, "vkGetAccelerationStructureDeviceAddressKHR") + vtable.GetAccelerationStructureHandleNV = auto_cast GetDeviceProcAddr(device, "vkGetAccelerationStructureHandleNV") + vtable.GetAccelerationStructureMemoryRequirementsNV = auto_cast GetDeviceProcAddr(device, "vkGetAccelerationStructureMemoryRequirementsNV") + vtable.GetAccelerationStructureOpaqueCaptureDescriptorDataEXT = auto_cast GetDeviceProcAddr(device, "vkGetAccelerationStructureOpaqueCaptureDescriptorDataEXT") + vtable.GetBufferDeviceAddress = auto_cast GetDeviceProcAddr(device, "vkGetBufferDeviceAddress") + vtable.GetBufferDeviceAddressEXT = auto_cast GetDeviceProcAddr(device, "vkGetBufferDeviceAddressEXT") + vtable.GetBufferDeviceAddressKHR = auto_cast GetDeviceProcAddr(device, "vkGetBufferDeviceAddressKHR") + vtable.GetBufferMemoryRequirements = auto_cast GetDeviceProcAddr(device, "vkGetBufferMemoryRequirements") + vtable.GetBufferMemoryRequirements2 = auto_cast GetDeviceProcAddr(device, "vkGetBufferMemoryRequirements2") + vtable.GetBufferMemoryRequirements2KHR = auto_cast GetDeviceProcAddr(device, "vkGetBufferMemoryRequirements2KHR") + vtable.GetBufferOpaqueCaptureAddress = auto_cast GetDeviceProcAddr(device, "vkGetBufferOpaqueCaptureAddress") + vtable.GetBufferOpaqueCaptureAddressKHR = auto_cast GetDeviceProcAddr(device, "vkGetBufferOpaqueCaptureAddressKHR") + vtable.GetBufferOpaqueCaptureDescriptorDataEXT = auto_cast GetDeviceProcAddr(device, "vkGetBufferOpaqueCaptureDescriptorDataEXT") + vtable.GetCalibratedTimestampsEXT = auto_cast GetDeviceProcAddr(device, "vkGetCalibratedTimestampsEXT") + vtable.GetDeferredOperationMaxConcurrencyKHR = auto_cast GetDeviceProcAddr(device, "vkGetDeferredOperationMaxConcurrencyKHR") + vtable.GetDeferredOperationResultKHR = auto_cast GetDeviceProcAddr(device, "vkGetDeferredOperationResultKHR") + vtable.GetDescriptorEXT = auto_cast GetDeviceProcAddr(device, "vkGetDescriptorEXT") + vtable.GetDescriptorSetHostMappingVALVE = auto_cast GetDeviceProcAddr(device, "vkGetDescriptorSetHostMappingVALVE") + vtable.GetDescriptorSetLayoutBindingOffsetEXT = auto_cast GetDeviceProcAddr(device, "vkGetDescriptorSetLayoutBindingOffsetEXT") + vtable.GetDescriptorSetLayoutHostMappingInfoVALVE = auto_cast GetDeviceProcAddr(device, "vkGetDescriptorSetLayoutHostMappingInfoVALVE") + vtable.GetDescriptorSetLayoutSizeEXT = auto_cast GetDeviceProcAddr(device, "vkGetDescriptorSetLayoutSizeEXT") + vtable.GetDescriptorSetLayoutSupport = auto_cast GetDeviceProcAddr(device, "vkGetDescriptorSetLayoutSupport") + vtable.GetDescriptorSetLayoutSupportKHR = auto_cast GetDeviceProcAddr(device, "vkGetDescriptorSetLayoutSupportKHR") + vtable.GetDeviceAccelerationStructureCompatibilityKHR = auto_cast GetDeviceProcAddr(device, "vkGetDeviceAccelerationStructureCompatibilityKHR") + vtable.GetDeviceBufferMemoryRequirements = auto_cast GetDeviceProcAddr(device, "vkGetDeviceBufferMemoryRequirements") + vtable.GetDeviceBufferMemoryRequirementsKHR = auto_cast GetDeviceProcAddr(device, "vkGetDeviceBufferMemoryRequirementsKHR") + vtable.GetDeviceFaultInfoEXT = auto_cast GetDeviceProcAddr(device, "vkGetDeviceFaultInfoEXT") + vtable.GetDeviceGroupPeerMemoryFeatures = auto_cast GetDeviceProcAddr(device, "vkGetDeviceGroupPeerMemoryFeatures") + vtable.GetDeviceGroupPeerMemoryFeaturesKHR = auto_cast GetDeviceProcAddr(device, "vkGetDeviceGroupPeerMemoryFeaturesKHR") + vtable.GetDeviceGroupPresentCapabilitiesKHR = auto_cast GetDeviceProcAddr(device, "vkGetDeviceGroupPresentCapabilitiesKHR") + vtable.GetDeviceGroupSurfacePresentModes2EXT = auto_cast GetDeviceProcAddr(device, "vkGetDeviceGroupSurfacePresentModes2EXT") + vtable.GetDeviceGroupSurfacePresentModesKHR = auto_cast GetDeviceProcAddr(device, "vkGetDeviceGroupSurfacePresentModesKHR") + vtable.GetDeviceImageMemoryRequirements = auto_cast GetDeviceProcAddr(device, "vkGetDeviceImageMemoryRequirements") + vtable.GetDeviceImageMemoryRequirementsKHR = auto_cast GetDeviceProcAddr(device, "vkGetDeviceImageMemoryRequirementsKHR") + vtable.GetDeviceImageSparseMemoryRequirements = auto_cast GetDeviceProcAddr(device, "vkGetDeviceImageSparseMemoryRequirements") + vtable.GetDeviceImageSparseMemoryRequirementsKHR = auto_cast GetDeviceProcAddr(device, "vkGetDeviceImageSparseMemoryRequirementsKHR") + vtable.GetDeviceMemoryCommitment = auto_cast GetDeviceProcAddr(device, "vkGetDeviceMemoryCommitment") + vtable.GetDeviceMemoryOpaqueCaptureAddress = auto_cast GetDeviceProcAddr(device, "vkGetDeviceMemoryOpaqueCaptureAddress") + vtable.GetDeviceMemoryOpaqueCaptureAddressKHR = auto_cast GetDeviceProcAddr(device, "vkGetDeviceMemoryOpaqueCaptureAddressKHR") + vtable.GetDeviceMicromapCompatibilityEXT = auto_cast GetDeviceProcAddr(device, "vkGetDeviceMicromapCompatibilityEXT") + vtable.GetDeviceProcAddr = auto_cast GetDeviceProcAddr(device, "vkGetDeviceProcAddr") + vtable.GetDeviceQueue = auto_cast GetDeviceProcAddr(device, "vkGetDeviceQueue") + vtable.GetDeviceQueue2 = auto_cast GetDeviceProcAddr(device, "vkGetDeviceQueue2") + vtable.GetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI = auto_cast GetDeviceProcAddr(device, "vkGetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI") + vtable.GetDynamicRenderingTilePropertiesQCOM = auto_cast GetDeviceProcAddr(device, "vkGetDynamicRenderingTilePropertiesQCOM") + vtable.GetEventStatus = auto_cast GetDeviceProcAddr(device, "vkGetEventStatus") + vtable.GetFenceFdKHR = auto_cast GetDeviceProcAddr(device, "vkGetFenceFdKHR") + vtable.GetFenceStatus = auto_cast GetDeviceProcAddr(device, "vkGetFenceStatus") + vtable.GetFenceWin32HandleKHR = auto_cast GetDeviceProcAddr(device, "vkGetFenceWin32HandleKHR") + vtable.GetFramebufferTilePropertiesQCOM = auto_cast GetDeviceProcAddr(device, "vkGetFramebufferTilePropertiesQCOM") + vtable.GetGeneratedCommandsMemoryRequirementsNV = auto_cast GetDeviceProcAddr(device, "vkGetGeneratedCommandsMemoryRequirementsNV") + vtable.GetImageDrmFormatModifierPropertiesEXT = auto_cast GetDeviceProcAddr(device, "vkGetImageDrmFormatModifierPropertiesEXT") + vtable.GetImageMemoryRequirements = auto_cast GetDeviceProcAddr(device, "vkGetImageMemoryRequirements") + vtable.GetImageMemoryRequirements2 = auto_cast GetDeviceProcAddr(device, "vkGetImageMemoryRequirements2") + vtable.GetImageMemoryRequirements2KHR = auto_cast GetDeviceProcAddr(device, "vkGetImageMemoryRequirements2KHR") + vtable.GetImageOpaqueCaptureDescriptorDataEXT = auto_cast GetDeviceProcAddr(device, "vkGetImageOpaqueCaptureDescriptorDataEXT") + vtable.GetImageSparseMemoryRequirements = auto_cast GetDeviceProcAddr(device, "vkGetImageSparseMemoryRequirements") + vtable.GetImageSparseMemoryRequirements2 = auto_cast GetDeviceProcAddr(device, "vkGetImageSparseMemoryRequirements2") + vtable.GetImageSparseMemoryRequirements2KHR = auto_cast GetDeviceProcAddr(device, "vkGetImageSparseMemoryRequirements2KHR") + vtable.GetImageSubresourceLayout = auto_cast GetDeviceProcAddr(device, "vkGetImageSubresourceLayout") + vtable.GetImageSubresourceLayout2EXT = auto_cast GetDeviceProcAddr(device, "vkGetImageSubresourceLayout2EXT") + vtable.GetImageViewAddressNVX = auto_cast GetDeviceProcAddr(device, "vkGetImageViewAddressNVX") + vtable.GetImageViewHandleNVX = auto_cast GetDeviceProcAddr(device, "vkGetImageViewHandleNVX") + vtable.GetImageViewOpaqueCaptureDescriptorDataEXT = auto_cast GetDeviceProcAddr(device, "vkGetImageViewOpaqueCaptureDescriptorDataEXT") + vtable.GetMemoryFdKHR = auto_cast GetDeviceProcAddr(device, "vkGetMemoryFdKHR") + vtable.GetMemoryFdPropertiesKHR = auto_cast GetDeviceProcAddr(device, "vkGetMemoryFdPropertiesKHR") + vtable.GetMemoryHostPointerPropertiesEXT = auto_cast GetDeviceProcAddr(device, "vkGetMemoryHostPointerPropertiesEXT") + vtable.GetMemoryRemoteAddressNV = auto_cast GetDeviceProcAddr(device, "vkGetMemoryRemoteAddressNV") + vtable.GetMemoryWin32HandleKHR = auto_cast GetDeviceProcAddr(device, "vkGetMemoryWin32HandleKHR") + vtable.GetMemoryWin32HandleNV = auto_cast GetDeviceProcAddr(device, "vkGetMemoryWin32HandleNV") + vtable.GetMemoryWin32HandlePropertiesKHR = auto_cast GetDeviceProcAddr(device, "vkGetMemoryWin32HandlePropertiesKHR") + vtable.GetMicromapBuildSizesEXT = auto_cast GetDeviceProcAddr(device, "vkGetMicromapBuildSizesEXT") + vtable.GetPastPresentationTimingGOOGLE = auto_cast GetDeviceProcAddr(device, "vkGetPastPresentationTimingGOOGLE") + vtable.GetPerformanceParameterINTEL = auto_cast GetDeviceProcAddr(device, "vkGetPerformanceParameterINTEL") + vtable.GetPipelineCacheData = auto_cast GetDeviceProcAddr(device, "vkGetPipelineCacheData") + vtable.GetPipelineExecutableInternalRepresentationsKHR = auto_cast GetDeviceProcAddr(device, "vkGetPipelineExecutableInternalRepresentationsKHR") + vtable.GetPipelineExecutablePropertiesKHR = auto_cast GetDeviceProcAddr(device, "vkGetPipelineExecutablePropertiesKHR") + vtable.GetPipelineExecutableStatisticsKHR = auto_cast GetDeviceProcAddr(device, "vkGetPipelineExecutableStatisticsKHR") + vtable.GetPipelinePropertiesEXT = auto_cast GetDeviceProcAddr(device, "vkGetPipelinePropertiesEXT") + vtable.GetPrivateData = auto_cast GetDeviceProcAddr(device, "vkGetPrivateData") + vtable.GetPrivateDataEXT = auto_cast GetDeviceProcAddr(device, "vkGetPrivateDataEXT") + vtable.GetQueryPoolResults = auto_cast GetDeviceProcAddr(device, "vkGetQueryPoolResults") + vtable.GetQueueCheckpointData2NV = auto_cast GetDeviceProcAddr(device, "vkGetQueueCheckpointData2NV") + vtable.GetQueueCheckpointDataNV = auto_cast GetDeviceProcAddr(device, "vkGetQueueCheckpointDataNV") + vtable.GetRayTracingCaptureReplayShaderGroupHandlesKHR = auto_cast GetDeviceProcAddr(device, "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR") + vtable.GetRayTracingShaderGroupHandlesKHR = auto_cast GetDeviceProcAddr(device, "vkGetRayTracingShaderGroupHandlesKHR") + vtable.GetRayTracingShaderGroupHandlesNV = auto_cast GetDeviceProcAddr(device, "vkGetRayTracingShaderGroupHandlesNV") + vtable.GetRayTracingShaderGroupStackSizeKHR = auto_cast GetDeviceProcAddr(device, "vkGetRayTracingShaderGroupStackSizeKHR") + vtable.GetRefreshCycleDurationGOOGLE = auto_cast GetDeviceProcAddr(device, "vkGetRefreshCycleDurationGOOGLE") + vtable.GetRenderAreaGranularity = auto_cast GetDeviceProcAddr(device, "vkGetRenderAreaGranularity") + vtable.GetSamplerOpaqueCaptureDescriptorDataEXT = auto_cast GetDeviceProcAddr(device, "vkGetSamplerOpaqueCaptureDescriptorDataEXT") + vtable.GetSemaphoreCounterValue = auto_cast GetDeviceProcAddr(device, "vkGetSemaphoreCounterValue") + vtable.GetSemaphoreCounterValueKHR = auto_cast GetDeviceProcAddr(device, "vkGetSemaphoreCounterValueKHR") + vtable.GetSemaphoreFdKHR = auto_cast GetDeviceProcAddr(device, "vkGetSemaphoreFdKHR") + vtable.GetSemaphoreWin32HandleKHR = auto_cast GetDeviceProcAddr(device, "vkGetSemaphoreWin32HandleKHR") + vtable.GetShaderBinaryDataEXT = auto_cast GetDeviceProcAddr(device, "vkGetShaderBinaryDataEXT") + vtable.GetShaderInfoAMD = auto_cast GetDeviceProcAddr(device, "vkGetShaderInfoAMD") + vtable.GetShaderModuleCreateInfoIdentifierEXT = auto_cast GetDeviceProcAddr(device, "vkGetShaderModuleCreateInfoIdentifierEXT") + vtable.GetShaderModuleIdentifierEXT = auto_cast GetDeviceProcAddr(device, "vkGetShaderModuleIdentifierEXT") + vtable.GetSwapchainCounterEXT = auto_cast GetDeviceProcAddr(device, "vkGetSwapchainCounterEXT") + vtable.GetSwapchainImagesKHR = auto_cast GetDeviceProcAddr(device, "vkGetSwapchainImagesKHR") + vtable.GetSwapchainStatusKHR = auto_cast GetDeviceProcAddr(device, "vkGetSwapchainStatusKHR") + vtable.GetValidationCacheDataEXT = auto_cast GetDeviceProcAddr(device, "vkGetValidationCacheDataEXT") + vtable.GetVideoSessionMemoryRequirementsKHR = auto_cast GetDeviceProcAddr(device, "vkGetVideoSessionMemoryRequirementsKHR") + vtable.ImportFenceFdKHR = auto_cast GetDeviceProcAddr(device, "vkImportFenceFdKHR") + vtable.ImportFenceWin32HandleKHR = auto_cast GetDeviceProcAddr(device, "vkImportFenceWin32HandleKHR") + vtable.ImportSemaphoreFdKHR = auto_cast GetDeviceProcAddr(device, "vkImportSemaphoreFdKHR") + vtable.ImportSemaphoreWin32HandleKHR = auto_cast GetDeviceProcAddr(device, "vkImportSemaphoreWin32HandleKHR") + vtable.InitializePerformanceApiINTEL = auto_cast GetDeviceProcAddr(device, "vkInitializePerformanceApiINTEL") + vtable.InvalidateMappedMemoryRanges = auto_cast GetDeviceProcAddr(device, "vkInvalidateMappedMemoryRanges") + vtable.MapMemory = auto_cast GetDeviceProcAddr(device, "vkMapMemory") + vtable.MapMemory2KHR = auto_cast GetDeviceProcAddr(device, "vkMapMemory2KHR") + vtable.MergePipelineCaches = auto_cast GetDeviceProcAddr(device, "vkMergePipelineCaches") + vtable.MergeValidationCachesEXT = auto_cast GetDeviceProcAddr(device, "vkMergeValidationCachesEXT") + vtable.QueueBeginDebugUtilsLabelEXT = auto_cast GetDeviceProcAddr(device, "vkQueueBeginDebugUtilsLabelEXT") + vtable.QueueBindSparse = auto_cast GetDeviceProcAddr(device, "vkQueueBindSparse") + vtable.QueueEndDebugUtilsLabelEXT = auto_cast GetDeviceProcAddr(device, "vkQueueEndDebugUtilsLabelEXT") + vtable.QueueInsertDebugUtilsLabelEXT = auto_cast GetDeviceProcAddr(device, "vkQueueInsertDebugUtilsLabelEXT") + vtable.QueuePresentKHR = auto_cast GetDeviceProcAddr(device, "vkQueuePresentKHR") + vtable.QueueSetPerformanceConfigurationINTEL = auto_cast GetDeviceProcAddr(device, "vkQueueSetPerformanceConfigurationINTEL") + vtable.QueueSubmit = auto_cast GetDeviceProcAddr(device, "vkQueueSubmit") + vtable.QueueSubmit2 = auto_cast GetDeviceProcAddr(device, "vkQueueSubmit2") + vtable.QueueSubmit2KHR = auto_cast GetDeviceProcAddr(device, "vkQueueSubmit2KHR") + vtable.QueueWaitIdle = auto_cast GetDeviceProcAddr(device, "vkQueueWaitIdle") + vtable.RegisterDeviceEventEXT = auto_cast GetDeviceProcAddr(device, "vkRegisterDeviceEventEXT") + vtable.RegisterDisplayEventEXT = auto_cast GetDeviceProcAddr(device, "vkRegisterDisplayEventEXT") + vtable.ReleaseFullScreenExclusiveModeEXT = auto_cast GetDeviceProcAddr(device, "vkReleaseFullScreenExclusiveModeEXT") + vtable.ReleasePerformanceConfigurationINTEL = auto_cast GetDeviceProcAddr(device, "vkReleasePerformanceConfigurationINTEL") + vtable.ReleaseProfilingLockKHR = auto_cast GetDeviceProcAddr(device, "vkReleaseProfilingLockKHR") + vtable.ReleaseSwapchainImagesEXT = auto_cast GetDeviceProcAddr(device, "vkReleaseSwapchainImagesEXT") + vtable.ResetCommandBuffer = auto_cast GetDeviceProcAddr(device, "vkResetCommandBuffer") + vtable.ResetCommandPool = auto_cast GetDeviceProcAddr(device, "vkResetCommandPool") + vtable.ResetDescriptorPool = auto_cast GetDeviceProcAddr(device, "vkResetDescriptorPool") + vtable.ResetEvent = auto_cast GetDeviceProcAddr(device, "vkResetEvent") + vtable.ResetFences = auto_cast GetDeviceProcAddr(device, "vkResetFences") + vtable.ResetQueryPool = auto_cast GetDeviceProcAddr(device, "vkResetQueryPool") + vtable.ResetQueryPoolEXT = auto_cast GetDeviceProcAddr(device, "vkResetQueryPoolEXT") + vtable.SetDebugUtilsObjectNameEXT = auto_cast GetDeviceProcAddr(device, "vkSetDebugUtilsObjectNameEXT") + vtable.SetDebugUtilsObjectTagEXT = auto_cast GetDeviceProcAddr(device, "vkSetDebugUtilsObjectTagEXT") + vtable.SetDeviceMemoryPriorityEXT = auto_cast GetDeviceProcAddr(device, "vkSetDeviceMemoryPriorityEXT") + vtable.SetEvent = auto_cast GetDeviceProcAddr(device, "vkSetEvent") + vtable.SetHdrMetadataEXT = auto_cast GetDeviceProcAddr(device, "vkSetHdrMetadataEXT") + vtable.SetLocalDimmingAMD = auto_cast GetDeviceProcAddr(device, "vkSetLocalDimmingAMD") + vtable.SetPrivateData = auto_cast GetDeviceProcAddr(device, "vkSetPrivateData") + vtable.SetPrivateDataEXT = auto_cast GetDeviceProcAddr(device, "vkSetPrivateDataEXT") + vtable.SignalSemaphore = auto_cast GetDeviceProcAddr(device, "vkSignalSemaphore") + vtable.SignalSemaphoreKHR = auto_cast GetDeviceProcAddr(device, "vkSignalSemaphoreKHR") + vtable.TrimCommandPool = auto_cast GetDeviceProcAddr(device, "vkTrimCommandPool") + vtable.TrimCommandPoolKHR = auto_cast GetDeviceProcAddr(device, "vkTrimCommandPoolKHR") + vtable.UninitializePerformanceApiINTEL = auto_cast GetDeviceProcAddr(device, "vkUninitializePerformanceApiINTEL") + vtable.UnmapMemory = auto_cast GetDeviceProcAddr(device, "vkUnmapMemory") + vtable.UnmapMemory2KHR = auto_cast GetDeviceProcAddr(device, "vkUnmapMemory2KHR") + vtable.UpdateDescriptorSetWithTemplate = auto_cast GetDeviceProcAddr(device, "vkUpdateDescriptorSetWithTemplate") + vtable.UpdateDescriptorSetWithTemplateKHR = auto_cast GetDeviceProcAddr(device, "vkUpdateDescriptorSetWithTemplateKHR") + vtable.UpdateDescriptorSets = auto_cast GetDeviceProcAddr(device, "vkUpdateDescriptorSets") + vtable.UpdateVideoSessionParametersKHR = auto_cast GetDeviceProcAddr(device, "vkUpdateVideoSessionParametersKHR") + vtable.WaitForFences = auto_cast GetDeviceProcAddr(device, "vkWaitForFences") + vtable.WaitForPresentKHR = auto_cast GetDeviceProcAddr(device, "vkWaitForPresentKHR") + vtable.WaitSemaphores = auto_cast GetDeviceProcAddr(device, "vkWaitSemaphores") + vtable.WaitSemaphoresKHR = auto_cast GetDeviceProcAddr(device, "vkWaitSemaphoresKHR") + vtable.WriteAccelerationStructuresPropertiesKHR = auto_cast GetDeviceProcAddr(device, "vkWriteAccelerationStructuresPropertiesKHR") + vtable.WriteMicromapsPropertiesEXT = auto_cast GetDeviceProcAddr(device, "vkWriteMicromapsPropertiesEXT") +} + +load_proc_addresses_device :: proc(device: Device) { + AcquireFullScreenExclusiveModeEXT = auto_cast GetDeviceProcAddr(device, "vkAcquireFullScreenExclusiveModeEXT") + AcquireNextImage2KHR = auto_cast GetDeviceProcAddr(device, "vkAcquireNextImage2KHR") + AcquireNextImageKHR = auto_cast GetDeviceProcAddr(device, "vkAcquireNextImageKHR") + AcquirePerformanceConfigurationINTEL = auto_cast GetDeviceProcAddr(device, "vkAcquirePerformanceConfigurationINTEL") + AcquireProfilingLockKHR = auto_cast GetDeviceProcAddr(device, "vkAcquireProfilingLockKHR") + AllocateCommandBuffers = auto_cast GetDeviceProcAddr(device, "vkAllocateCommandBuffers") + AllocateDescriptorSets = auto_cast GetDeviceProcAddr(device, "vkAllocateDescriptorSets") + AllocateMemory = auto_cast GetDeviceProcAddr(device, "vkAllocateMemory") + BeginCommandBuffer = auto_cast GetDeviceProcAddr(device, "vkBeginCommandBuffer") + BindAccelerationStructureMemoryNV = auto_cast GetDeviceProcAddr(device, "vkBindAccelerationStructureMemoryNV") + BindBufferMemory = auto_cast GetDeviceProcAddr(device, "vkBindBufferMemory") + BindBufferMemory2 = auto_cast GetDeviceProcAddr(device, "vkBindBufferMemory2") + BindBufferMemory2KHR = auto_cast GetDeviceProcAddr(device, "vkBindBufferMemory2KHR") + BindImageMemory = auto_cast GetDeviceProcAddr(device, "vkBindImageMemory") + BindImageMemory2 = auto_cast GetDeviceProcAddr(device, "vkBindImageMemory2") + BindImageMemory2KHR = auto_cast GetDeviceProcAddr(device, "vkBindImageMemory2KHR") + BindOpticalFlowSessionImageNV = auto_cast GetDeviceProcAddr(device, "vkBindOpticalFlowSessionImageNV") + BindVideoSessionMemoryKHR = auto_cast GetDeviceProcAddr(device, "vkBindVideoSessionMemoryKHR") + BuildAccelerationStructuresKHR = auto_cast GetDeviceProcAddr(device, "vkBuildAccelerationStructuresKHR") + BuildMicromapsEXT = auto_cast GetDeviceProcAddr(device, "vkBuildMicromapsEXT") + CmdBeginConditionalRenderingEXT = auto_cast GetDeviceProcAddr(device, "vkCmdBeginConditionalRenderingEXT") + CmdBeginDebugUtilsLabelEXT = auto_cast GetDeviceProcAddr(device, "vkCmdBeginDebugUtilsLabelEXT") + CmdBeginQuery = auto_cast GetDeviceProcAddr(device, "vkCmdBeginQuery") + CmdBeginQueryIndexedEXT = auto_cast GetDeviceProcAddr(device, "vkCmdBeginQueryIndexedEXT") + CmdBeginRenderPass = auto_cast GetDeviceProcAddr(device, "vkCmdBeginRenderPass") + CmdBeginRenderPass2 = auto_cast GetDeviceProcAddr(device, "vkCmdBeginRenderPass2") + CmdBeginRenderPass2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdBeginRenderPass2KHR") + CmdBeginRendering = auto_cast GetDeviceProcAddr(device, "vkCmdBeginRendering") + CmdBeginRenderingKHR = auto_cast GetDeviceProcAddr(device, "vkCmdBeginRenderingKHR") + CmdBeginTransformFeedbackEXT = auto_cast GetDeviceProcAddr(device, "vkCmdBeginTransformFeedbackEXT") + CmdBeginVideoCodingKHR = auto_cast GetDeviceProcAddr(device, "vkCmdBeginVideoCodingKHR") + CmdBindDescriptorBufferEmbeddedSamplersEXT = auto_cast GetDeviceProcAddr(device, "vkCmdBindDescriptorBufferEmbeddedSamplersEXT") + CmdBindDescriptorBuffersEXT = auto_cast GetDeviceProcAddr(device, "vkCmdBindDescriptorBuffersEXT") + CmdBindDescriptorSets = auto_cast GetDeviceProcAddr(device, "vkCmdBindDescriptorSets") + CmdBindIndexBuffer = auto_cast GetDeviceProcAddr(device, "vkCmdBindIndexBuffer") + CmdBindInvocationMaskHUAWEI = auto_cast GetDeviceProcAddr(device, "vkCmdBindInvocationMaskHUAWEI") + CmdBindPipeline = auto_cast GetDeviceProcAddr(device, "vkCmdBindPipeline") + CmdBindPipelineShaderGroupNV = auto_cast GetDeviceProcAddr(device, "vkCmdBindPipelineShaderGroupNV") + CmdBindShadersEXT = auto_cast GetDeviceProcAddr(device, "vkCmdBindShadersEXT") + CmdBindShadingRateImageNV = auto_cast GetDeviceProcAddr(device, "vkCmdBindShadingRateImageNV") + CmdBindTransformFeedbackBuffersEXT = auto_cast GetDeviceProcAddr(device, "vkCmdBindTransformFeedbackBuffersEXT") + CmdBindVertexBuffers = auto_cast GetDeviceProcAddr(device, "vkCmdBindVertexBuffers") + CmdBindVertexBuffers2 = auto_cast GetDeviceProcAddr(device, "vkCmdBindVertexBuffers2") + CmdBindVertexBuffers2EXT = auto_cast GetDeviceProcAddr(device, "vkCmdBindVertexBuffers2EXT") + CmdBlitImage = auto_cast GetDeviceProcAddr(device, "vkCmdBlitImage") + CmdBlitImage2 = auto_cast GetDeviceProcAddr(device, "vkCmdBlitImage2") + CmdBlitImage2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdBlitImage2KHR") + CmdBuildAccelerationStructureNV = auto_cast GetDeviceProcAddr(device, "vkCmdBuildAccelerationStructureNV") + CmdBuildAccelerationStructuresIndirectKHR = auto_cast GetDeviceProcAddr(device, "vkCmdBuildAccelerationStructuresIndirectKHR") + CmdBuildAccelerationStructuresKHR = auto_cast GetDeviceProcAddr(device, "vkCmdBuildAccelerationStructuresKHR") + CmdBuildMicromapsEXT = auto_cast GetDeviceProcAddr(device, "vkCmdBuildMicromapsEXT") + CmdClearAttachments = auto_cast GetDeviceProcAddr(device, "vkCmdClearAttachments") + CmdClearColorImage = auto_cast GetDeviceProcAddr(device, "vkCmdClearColorImage") + CmdClearDepthStencilImage = auto_cast GetDeviceProcAddr(device, "vkCmdClearDepthStencilImage") + CmdControlVideoCodingKHR = auto_cast GetDeviceProcAddr(device, "vkCmdControlVideoCodingKHR") + CmdCopyAccelerationStructureKHR = auto_cast GetDeviceProcAddr(device, "vkCmdCopyAccelerationStructureKHR") + CmdCopyAccelerationStructureNV = auto_cast GetDeviceProcAddr(device, "vkCmdCopyAccelerationStructureNV") + CmdCopyAccelerationStructureToMemoryKHR = auto_cast GetDeviceProcAddr(device, "vkCmdCopyAccelerationStructureToMemoryKHR") + CmdCopyBuffer = auto_cast GetDeviceProcAddr(device, "vkCmdCopyBuffer") + CmdCopyBuffer2 = auto_cast GetDeviceProcAddr(device, "vkCmdCopyBuffer2") + CmdCopyBuffer2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdCopyBuffer2KHR") + CmdCopyBufferToImage = auto_cast GetDeviceProcAddr(device, "vkCmdCopyBufferToImage") + CmdCopyBufferToImage2 = auto_cast GetDeviceProcAddr(device, "vkCmdCopyBufferToImage2") + CmdCopyBufferToImage2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdCopyBufferToImage2KHR") + CmdCopyImage = auto_cast GetDeviceProcAddr(device, "vkCmdCopyImage") + CmdCopyImage2 = auto_cast GetDeviceProcAddr(device, "vkCmdCopyImage2") + CmdCopyImage2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdCopyImage2KHR") + CmdCopyImageToBuffer = auto_cast GetDeviceProcAddr(device, "vkCmdCopyImageToBuffer") + CmdCopyImageToBuffer2 = auto_cast GetDeviceProcAddr(device, "vkCmdCopyImageToBuffer2") + CmdCopyImageToBuffer2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdCopyImageToBuffer2KHR") + CmdCopyMemoryIndirectNV = auto_cast GetDeviceProcAddr(device, "vkCmdCopyMemoryIndirectNV") + CmdCopyMemoryToAccelerationStructureKHR = auto_cast GetDeviceProcAddr(device, "vkCmdCopyMemoryToAccelerationStructureKHR") + CmdCopyMemoryToImageIndirectNV = auto_cast GetDeviceProcAddr(device, "vkCmdCopyMemoryToImageIndirectNV") + CmdCopyMemoryToMicromapEXT = auto_cast GetDeviceProcAddr(device, "vkCmdCopyMemoryToMicromapEXT") + CmdCopyMicromapEXT = auto_cast GetDeviceProcAddr(device, "vkCmdCopyMicromapEXT") + CmdCopyMicromapToMemoryEXT = auto_cast GetDeviceProcAddr(device, "vkCmdCopyMicromapToMemoryEXT") + CmdCopyQueryPoolResults = auto_cast GetDeviceProcAddr(device, "vkCmdCopyQueryPoolResults") + CmdCuLaunchKernelNVX = auto_cast GetDeviceProcAddr(device, "vkCmdCuLaunchKernelNVX") + CmdDebugMarkerBeginEXT = auto_cast GetDeviceProcAddr(device, "vkCmdDebugMarkerBeginEXT") + CmdDebugMarkerEndEXT = auto_cast GetDeviceProcAddr(device, "vkCmdDebugMarkerEndEXT") + CmdDebugMarkerInsertEXT = auto_cast GetDeviceProcAddr(device, "vkCmdDebugMarkerInsertEXT") + CmdDecodeVideoKHR = auto_cast GetDeviceProcAddr(device, "vkCmdDecodeVideoKHR") + CmdDecompressMemoryIndirectCountNV = auto_cast GetDeviceProcAddr(device, "vkCmdDecompressMemoryIndirectCountNV") + CmdDecompressMemoryNV = auto_cast GetDeviceProcAddr(device, "vkCmdDecompressMemoryNV") + CmdDispatch = auto_cast GetDeviceProcAddr(device, "vkCmdDispatch") + CmdDispatchBase = auto_cast GetDeviceProcAddr(device, "vkCmdDispatchBase") + CmdDispatchBaseKHR = auto_cast GetDeviceProcAddr(device, "vkCmdDispatchBaseKHR") + CmdDispatchIndirect = auto_cast GetDeviceProcAddr(device, "vkCmdDispatchIndirect") + CmdDraw = auto_cast GetDeviceProcAddr(device, "vkCmdDraw") + CmdDrawClusterHUAWEI = auto_cast GetDeviceProcAddr(device, "vkCmdDrawClusterHUAWEI") + CmdDrawClusterIndirectHUAWEI = auto_cast GetDeviceProcAddr(device, "vkCmdDrawClusterIndirectHUAWEI") + CmdDrawIndexed = auto_cast GetDeviceProcAddr(device, "vkCmdDrawIndexed") + CmdDrawIndexedIndirect = auto_cast GetDeviceProcAddr(device, "vkCmdDrawIndexedIndirect") + CmdDrawIndexedIndirectCount = auto_cast GetDeviceProcAddr(device, "vkCmdDrawIndexedIndirectCount") + CmdDrawIndexedIndirectCountAMD = auto_cast GetDeviceProcAddr(device, "vkCmdDrawIndexedIndirectCountAMD") + CmdDrawIndexedIndirectCountKHR = auto_cast GetDeviceProcAddr(device, "vkCmdDrawIndexedIndirectCountKHR") + CmdDrawIndirect = auto_cast GetDeviceProcAddr(device, "vkCmdDrawIndirect") + CmdDrawIndirectByteCountEXT = auto_cast GetDeviceProcAddr(device, "vkCmdDrawIndirectByteCountEXT") + CmdDrawIndirectCount = auto_cast GetDeviceProcAddr(device, "vkCmdDrawIndirectCount") + CmdDrawIndirectCountAMD = auto_cast GetDeviceProcAddr(device, "vkCmdDrawIndirectCountAMD") + CmdDrawIndirectCountKHR = auto_cast GetDeviceProcAddr(device, "vkCmdDrawIndirectCountKHR") + CmdDrawMeshTasksEXT = auto_cast GetDeviceProcAddr(device, "vkCmdDrawMeshTasksEXT") + CmdDrawMeshTasksIndirectCountEXT = auto_cast GetDeviceProcAddr(device, "vkCmdDrawMeshTasksIndirectCountEXT") + CmdDrawMeshTasksIndirectCountNV = auto_cast GetDeviceProcAddr(device, "vkCmdDrawMeshTasksIndirectCountNV") + CmdDrawMeshTasksIndirectEXT = auto_cast GetDeviceProcAddr(device, "vkCmdDrawMeshTasksIndirectEXT") + CmdDrawMeshTasksIndirectNV = auto_cast GetDeviceProcAddr(device, "vkCmdDrawMeshTasksIndirectNV") + CmdDrawMeshTasksNV = auto_cast GetDeviceProcAddr(device, "vkCmdDrawMeshTasksNV") + CmdDrawMultiEXT = auto_cast GetDeviceProcAddr(device, "vkCmdDrawMultiEXT") + CmdDrawMultiIndexedEXT = auto_cast GetDeviceProcAddr(device, "vkCmdDrawMultiIndexedEXT") + CmdEndConditionalRenderingEXT = auto_cast GetDeviceProcAddr(device, "vkCmdEndConditionalRenderingEXT") + CmdEndDebugUtilsLabelEXT = auto_cast GetDeviceProcAddr(device, "vkCmdEndDebugUtilsLabelEXT") + CmdEndQuery = auto_cast GetDeviceProcAddr(device, "vkCmdEndQuery") + CmdEndQueryIndexedEXT = auto_cast GetDeviceProcAddr(device, "vkCmdEndQueryIndexedEXT") + CmdEndRenderPass = auto_cast GetDeviceProcAddr(device, "vkCmdEndRenderPass") + CmdEndRenderPass2 = auto_cast GetDeviceProcAddr(device, "vkCmdEndRenderPass2") + CmdEndRenderPass2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdEndRenderPass2KHR") + CmdEndRendering = auto_cast GetDeviceProcAddr(device, "vkCmdEndRendering") + CmdEndRenderingKHR = auto_cast GetDeviceProcAddr(device, "vkCmdEndRenderingKHR") + CmdEndTransformFeedbackEXT = auto_cast GetDeviceProcAddr(device, "vkCmdEndTransformFeedbackEXT") + CmdEndVideoCodingKHR = auto_cast GetDeviceProcAddr(device, "vkCmdEndVideoCodingKHR") + CmdExecuteCommands = auto_cast GetDeviceProcAddr(device, "vkCmdExecuteCommands") + CmdExecuteGeneratedCommandsNV = auto_cast GetDeviceProcAddr(device, "vkCmdExecuteGeneratedCommandsNV") + CmdFillBuffer = auto_cast GetDeviceProcAddr(device, "vkCmdFillBuffer") + CmdInsertDebugUtilsLabelEXT = auto_cast GetDeviceProcAddr(device, "vkCmdInsertDebugUtilsLabelEXT") + CmdNextSubpass = auto_cast GetDeviceProcAddr(device, "vkCmdNextSubpass") + CmdNextSubpass2 = auto_cast GetDeviceProcAddr(device, "vkCmdNextSubpass2") + CmdNextSubpass2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdNextSubpass2KHR") + CmdOpticalFlowExecuteNV = auto_cast GetDeviceProcAddr(device, "vkCmdOpticalFlowExecuteNV") + CmdPipelineBarrier = auto_cast GetDeviceProcAddr(device, "vkCmdPipelineBarrier") + CmdPipelineBarrier2 = auto_cast GetDeviceProcAddr(device, "vkCmdPipelineBarrier2") + CmdPipelineBarrier2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdPipelineBarrier2KHR") + CmdPreprocessGeneratedCommandsNV = auto_cast GetDeviceProcAddr(device, "vkCmdPreprocessGeneratedCommandsNV") + CmdPushConstants = auto_cast GetDeviceProcAddr(device, "vkCmdPushConstants") + CmdPushDescriptorSetKHR = auto_cast GetDeviceProcAddr(device, "vkCmdPushDescriptorSetKHR") + CmdPushDescriptorSetWithTemplateKHR = auto_cast GetDeviceProcAddr(device, "vkCmdPushDescriptorSetWithTemplateKHR") + CmdResetEvent = auto_cast GetDeviceProcAddr(device, "vkCmdResetEvent") + CmdResetEvent2 = auto_cast GetDeviceProcAddr(device, "vkCmdResetEvent2") + CmdResetEvent2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdResetEvent2KHR") + CmdResetQueryPool = auto_cast GetDeviceProcAddr(device, "vkCmdResetQueryPool") + CmdResolveImage = auto_cast GetDeviceProcAddr(device, "vkCmdResolveImage") + CmdResolveImage2 = auto_cast GetDeviceProcAddr(device, "vkCmdResolveImage2") + CmdResolveImage2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdResolveImage2KHR") + CmdSetAlphaToCoverageEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetAlphaToCoverageEnableEXT") + CmdSetAlphaToOneEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetAlphaToOneEnableEXT") + CmdSetAttachmentFeedbackLoopEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetAttachmentFeedbackLoopEnableEXT") + CmdSetBlendConstants = auto_cast GetDeviceProcAddr(device, "vkCmdSetBlendConstants") + CmdSetCheckpointNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetCheckpointNV") + CmdSetCoarseSampleOrderNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetCoarseSampleOrderNV") + CmdSetColorBlendAdvancedEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetColorBlendAdvancedEXT") + CmdSetColorBlendEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetColorBlendEnableEXT") + CmdSetColorBlendEquationEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetColorBlendEquationEXT") + CmdSetColorWriteMaskEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetColorWriteMaskEXT") + CmdSetConservativeRasterizationModeEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetConservativeRasterizationModeEXT") + CmdSetCoverageModulationModeNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetCoverageModulationModeNV") + CmdSetCoverageModulationTableEnableNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetCoverageModulationTableEnableNV") + CmdSetCoverageModulationTableNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetCoverageModulationTableNV") + CmdSetCoverageReductionModeNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetCoverageReductionModeNV") + CmdSetCoverageToColorEnableNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetCoverageToColorEnableNV") + CmdSetCoverageToColorLocationNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetCoverageToColorLocationNV") + CmdSetCullMode = auto_cast GetDeviceProcAddr(device, "vkCmdSetCullMode") + CmdSetCullModeEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetCullModeEXT") + CmdSetDepthBias = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthBias") + CmdSetDepthBiasEnable = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthBiasEnable") + CmdSetDepthBiasEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthBiasEnableEXT") + CmdSetDepthBounds = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthBounds") + CmdSetDepthBoundsTestEnable = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthBoundsTestEnable") + CmdSetDepthBoundsTestEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthBoundsTestEnableEXT") + CmdSetDepthClampEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthClampEnableEXT") + CmdSetDepthClipEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthClipEnableEXT") + CmdSetDepthClipNegativeOneToOneEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthClipNegativeOneToOneEXT") + CmdSetDepthCompareOp = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthCompareOp") + CmdSetDepthCompareOpEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthCompareOpEXT") + CmdSetDepthTestEnable = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthTestEnable") + CmdSetDepthTestEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthTestEnableEXT") + CmdSetDepthWriteEnable = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthWriteEnable") + CmdSetDepthWriteEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetDepthWriteEnableEXT") + CmdSetDescriptorBufferOffsetsEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetDescriptorBufferOffsetsEXT") + CmdSetDeviceMask = auto_cast GetDeviceProcAddr(device, "vkCmdSetDeviceMask") + CmdSetDeviceMaskKHR = auto_cast GetDeviceProcAddr(device, "vkCmdSetDeviceMaskKHR") + CmdSetDiscardRectangleEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetDiscardRectangleEXT") + CmdSetDiscardRectangleEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetDiscardRectangleEnableEXT") + CmdSetDiscardRectangleModeEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetDiscardRectangleModeEXT") + CmdSetEvent = auto_cast GetDeviceProcAddr(device, "vkCmdSetEvent") + CmdSetEvent2 = auto_cast GetDeviceProcAddr(device, "vkCmdSetEvent2") + CmdSetEvent2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdSetEvent2KHR") + CmdSetExclusiveScissorEnableNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetExclusiveScissorEnableNV") + CmdSetExclusiveScissorNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetExclusiveScissorNV") + CmdSetExtraPrimitiveOverestimationSizeEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetExtraPrimitiveOverestimationSizeEXT") + CmdSetFragmentShadingRateEnumNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetFragmentShadingRateEnumNV") + CmdSetFragmentShadingRateKHR = auto_cast GetDeviceProcAddr(device, "vkCmdSetFragmentShadingRateKHR") + CmdSetFrontFace = auto_cast GetDeviceProcAddr(device, "vkCmdSetFrontFace") + CmdSetFrontFaceEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetFrontFaceEXT") + CmdSetLineRasterizationModeEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetLineRasterizationModeEXT") + CmdSetLineStippleEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetLineStippleEXT") + CmdSetLineStippleEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetLineStippleEnableEXT") + CmdSetLineWidth = auto_cast GetDeviceProcAddr(device, "vkCmdSetLineWidth") + CmdSetLogicOpEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetLogicOpEXT") + CmdSetLogicOpEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetLogicOpEnableEXT") + CmdSetPatchControlPointsEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetPatchControlPointsEXT") + CmdSetPerformanceMarkerINTEL = auto_cast GetDeviceProcAddr(device, "vkCmdSetPerformanceMarkerINTEL") + CmdSetPerformanceOverrideINTEL = auto_cast GetDeviceProcAddr(device, "vkCmdSetPerformanceOverrideINTEL") + CmdSetPerformanceStreamMarkerINTEL = auto_cast GetDeviceProcAddr(device, "vkCmdSetPerformanceStreamMarkerINTEL") + CmdSetPolygonModeEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetPolygonModeEXT") + CmdSetPrimitiveRestartEnable = auto_cast GetDeviceProcAddr(device, "vkCmdSetPrimitiveRestartEnable") + CmdSetPrimitiveRestartEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetPrimitiveRestartEnableEXT") + CmdSetPrimitiveTopology = auto_cast GetDeviceProcAddr(device, "vkCmdSetPrimitiveTopology") + CmdSetPrimitiveTopologyEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetPrimitiveTopologyEXT") + CmdSetProvokingVertexModeEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetProvokingVertexModeEXT") + CmdSetRasterizationSamplesEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetRasterizationSamplesEXT") + CmdSetRasterizationStreamEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetRasterizationStreamEXT") + CmdSetRasterizerDiscardEnable = auto_cast GetDeviceProcAddr(device, "vkCmdSetRasterizerDiscardEnable") + CmdSetRasterizerDiscardEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetRasterizerDiscardEnableEXT") + CmdSetRayTracingPipelineStackSizeKHR = auto_cast GetDeviceProcAddr(device, "vkCmdSetRayTracingPipelineStackSizeKHR") + CmdSetRepresentativeFragmentTestEnableNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetRepresentativeFragmentTestEnableNV") + CmdSetSampleLocationsEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetSampleLocationsEXT") + CmdSetSampleLocationsEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetSampleLocationsEnableEXT") + CmdSetSampleMaskEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetSampleMaskEXT") + CmdSetScissor = auto_cast GetDeviceProcAddr(device, "vkCmdSetScissor") + CmdSetScissorWithCount = auto_cast GetDeviceProcAddr(device, "vkCmdSetScissorWithCount") + CmdSetScissorWithCountEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetScissorWithCountEXT") + CmdSetShadingRateImageEnableNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetShadingRateImageEnableNV") + CmdSetStencilCompareMask = auto_cast GetDeviceProcAddr(device, "vkCmdSetStencilCompareMask") + CmdSetStencilOp = auto_cast GetDeviceProcAddr(device, "vkCmdSetStencilOp") + CmdSetStencilOpEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetStencilOpEXT") + CmdSetStencilReference = auto_cast GetDeviceProcAddr(device, "vkCmdSetStencilReference") + CmdSetStencilTestEnable = auto_cast GetDeviceProcAddr(device, "vkCmdSetStencilTestEnable") + CmdSetStencilTestEnableEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetStencilTestEnableEXT") + CmdSetStencilWriteMask = auto_cast GetDeviceProcAddr(device, "vkCmdSetStencilWriteMask") + CmdSetTessellationDomainOriginEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetTessellationDomainOriginEXT") + CmdSetVertexInputEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetVertexInputEXT") + CmdSetViewport = auto_cast GetDeviceProcAddr(device, "vkCmdSetViewport") + CmdSetViewportShadingRatePaletteNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetViewportShadingRatePaletteNV") + CmdSetViewportSwizzleNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetViewportSwizzleNV") + CmdSetViewportWScalingEnableNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetViewportWScalingEnableNV") + CmdSetViewportWScalingNV = auto_cast GetDeviceProcAddr(device, "vkCmdSetViewportWScalingNV") + CmdSetViewportWithCount = auto_cast GetDeviceProcAddr(device, "vkCmdSetViewportWithCount") + CmdSetViewportWithCountEXT = auto_cast GetDeviceProcAddr(device, "vkCmdSetViewportWithCountEXT") + CmdSubpassShadingHUAWEI = auto_cast GetDeviceProcAddr(device, "vkCmdSubpassShadingHUAWEI") + CmdTraceRaysIndirect2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdTraceRaysIndirect2KHR") + CmdTraceRaysIndirectKHR = auto_cast GetDeviceProcAddr(device, "vkCmdTraceRaysIndirectKHR") + CmdTraceRaysKHR = auto_cast GetDeviceProcAddr(device, "vkCmdTraceRaysKHR") + CmdTraceRaysNV = auto_cast GetDeviceProcAddr(device, "vkCmdTraceRaysNV") + CmdUpdateBuffer = auto_cast GetDeviceProcAddr(device, "vkCmdUpdateBuffer") + CmdWaitEvents = auto_cast GetDeviceProcAddr(device, "vkCmdWaitEvents") + CmdWaitEvents2 = auto_cast GetDeviceProcAddr(device, "vkCmdWaitEvents2") + CmdWaitEvents2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdWaitEvents2KHR") + CmdWriteAccelerationStructuresPropertiesKHR = auto_cast GetDeviceProcAddr(device, "vkCmdWriteAccelerationStructuresPropertiesKHR") + CmdWriteAccelerationStructuresPropertiesNV = auto_cast GetDeviceProcAddr(device, "vkCmdWriteAccelerationStructuresPropertiesNV") + CmdWriteBufferMarker2AMD = auto_cast GetDeviceProcAddr(device, "vkCmdWriteBufferMarker2AMD") + CmdWriteBufferMarkerAMD = auto_cast GetDeviceProcAddr(device, "vkCmdWriteBufferMarkerAMD") + CmdWriteMicromapsPropertiesEXT = auto_cast GetDeviceProcAddr(device, "vkCmdWriteMicromapsPropertiesEXT") + CmdWriteTimestamp = auto_cast GetDeviceProcAddr(device, "vkCmdWriteTimestamp") + CmdWriteTimestamp2 = auto_cast GetDeviceProcAddr(device, "vkCmdWriteTimestamp2") + CmdWriteTimestamp2KHR = auto_cast GetDeviceProcAddr(device, "vkCmdWriteTimestamp2KHR") + CompileDeferredNV = auto_cast GetDeviceProcAddr(device, "vkCompileDeferredNV") + CopyAccelerationStructureKHR = auto_cast GetDeviceProcAddr(device, "vkCopyAccelerationStructureKHR") + CopyAccelerationStructureToMemoryKHR = auto_cast GetDeviceProcAddr(device, "vkCopyAccelerationStructureToMemoryKHR") + CopyMemoryToAccelerationStructureKHR = auto_cast GetDeviceProcAddr(device, "vkCopyMemoryToAccelerationStructureKHR") + CopyMemoryToMicromapEXT = auto_cast GetDeviceProcAddr(device, "vkCopyMemoryToMicromapEXT") + CopyMicromapEXT = auto_cast GetDeviceProcAddr(device, "vkCopyMicromapEXT") + CopyMicromapToMemoryEXT = auto_cast GetDeviceProcAddr(device, "vkCopyMicromapToMemoryEXT") + CreateAccelerationStructureKHR = auto_cast GetDeviceProcAddr(device, "vkCreateAccelerationStructureKHR") + CreateAccelerationStructureNV = auto_cast GetDeviceProcAddr(device, "vkCreateAccelerationStructureNV") + CreateBuffer = auto_cast GetDeviceProcAddr(device, "vkCreateBuffer") + CreateBufferView = auto_cast GetDeviceProcAddr(device, "vkCreateBufferView") + CreateCommandPool = auto_cast GetDeviceProcAddr(device, "vkCreateCommandPool") + CreateComputePipelines = auto_cast GetDeviceProcAddr(device, "vkCreateComputePipelines") + CreateCuFunctionNVX = auto_cast GetDeviceProcAddr(device, "vkCreateCuFunctionNVX") + CreateCuModuleNVX = auto_cast GetDeviceProcAddr(device, "vkCreateCuModuleNVX") + CreateDeferredOperationKHR = auto_cast GetDeviceProcAddr(device, "vkCreateDeferredOperationKHR") + CreateDescriptorPool = auto_cast GetDeviceProcAddr(device, "vkCreateDescriptorPool") + CreateDescriptorSetLayout = auto_cast GetDeviceProcAddr(device, "vkCreateDescriptorSetLayout") + CreateDescriptorUpdateTemplate = auto_cast GetDeviceProcAddr(device, "vkCreateDescriptorUpdateTemplate") + CreateDescriptorUpdateTemplateKHR = auto_cast GetDeviceProcAddr(device, "vkCreateDescriptorUpdateTemplateKHR") + CreateEvent = auto_cast GetDeviceProcAddr(device, "vkCreateEvent") + CreateFence = auto_cast GetDeviceProcAddr(device, "vkCreateFence") + CreateFramebuffer = auto_cast GetDeviceProcAddr(device, "vkCreateFramebuffer") + CreateGraphicsPipelines = auto_cast GetDeviceProcAddr(device, "vkCreateGraphicsPipelines") + CreateImage = auto_cast GetDeviceProcAddr(device, "vkCreateImage") + CreateImageView = auto_cast GetDeviceProcAddr(device, "vkCreateImageView") + CreateIndirectCommandsLayoutNV = auto_cast GetDeviceProcAddr(device, "vkCreateIndirectCommandsLayoutNV") + CreateMicromapEXT = auto_cast GetDeviceProcAddr(device, "vkCreateMicromapEXT") + CreateOpticalFlowSessionNV = auto_cast GetDeviceProcAddr(device, "vkCreateOpticalFlowSessionNV") + CreatePipelineCache = auto_cast GetDeviceProcAddr(device, "vkCreatePipelineCache") + CreatePipelineLayout = auto_cast GetDeviceProcAddr(device, "vkCreatePipelineLayout") + CreatePrivateDataSlot = auto_cast GetDeviceProcAddr(device, "vkCreatePrivateDataSlot") + CreatePrivateDataSlotEXT = auto_cast GetDeviceProcAddr(device, "vkCreatePrivateDataSlotEXT") + CreateQueryPool = auto_cast GetDeviceProcAddr(device, "vkCreateQueryPool") + CreateRayTracingPipelinesKHR = auto_cast GetDeviceProcAddr(device, "vkCreateRayTracingPipelinesKHR") + CreateRayTracingPipelinesNV = auto_cast GetDeviceProcAddr(device, "vkCreateRayTracingPipelinesNV") + CreateRenderPass = auto_cast GetDeviceProcAddr(device, "vkCreateRenderPass") + CreateRenderPass2 = auto_cast GetDeviceProcAddr(device, "vkCreateRenderPass2") + CreateRenderPass2KHR = auto_cast GetDeviceProcAddr(device, "vkCreateRenderPass2KHR") + CreateSampler = auto_cast GetDeviceProcAddr(device, "vkCreateSampler") + CreateSamplerYcbcrConversion = auto_cast GetDeviceProcAddr(device, "vkCreateSamplerYcbcrConversion") + CreateSamplerYcbcrConversionKHR = auto_cast GetDeviceProcAddr(device, "vkCreateSamplerYcbcrConversionKHR") + CreateSemaphore = auto_cast GetDeviceProcAddr(device, "vkCreateSemaphore") + CreateShaderModule = auto_cast GetDeviceProcAddr(device, "vkCreateShaderModule") + CreateShadersEXT = auto_cast GetDeviceProcAddr(device, "vkCreateShadersEXT") + CreateSharedSwapchainsKHR = auto_cast GetDeviceProcAddr(device, "vkCreateSharedSwapchainsKHR") + CreateSwapchainKHR = auto_cast GetDeviceProcAddr(device, "vkCreateSwapchainKHR") + CreateValidationCacheEXT = auto_cast GetDeviceProcAddr(device, "vkCreateValidationCacheEXT") + CreateVideoSessionKHR = auto_cast GetDeviceProcAddr(device, "vkCreateVideoSessionKHR") + CreateVideoSessionParametersKHR = auto_cast GetDeviceProcAddr(device, "vkCreateVideoSessionParametersKHR") + DebugMarkerSetObjectNameEXT = auto_cast GetDeviceProcAddr(device, "vkDebugMarkerSetObjectNameEXT") + DebugMarkerSetObjectTagEXT = auto_cast GetDeviceProcAddr(device, "vkDebugMarkerSetObjectTagEXT") + DeferredOperationJoinKHR = auto_cast GetDeviceProcAddr(device, "vkDeferredOperationJoinKHR") + DestroyAccelerationStructureKHR = auto_cast GetDeviceProcAddr(device, "vkDestroyAccelerationStructureKHR") + DestroyAccelerationStructureNV = auto_cast GetDeviceProcAddr(device, "vkDestroyAccelerationStructureNV") + DestroyBuffer = auto_cast GetDeviceProcAddr(device, "vkDestroyBuffer") + DestroyBufferView = auto_cast GetDeviceProcAddr(device, "vkDestroyBufferView") + DestroyCommandPool = auto_cast GetDeviceProcAddr(device, "vkDestroyCommandPool") + DestroyCuFunctionNVX = auto_cast GetDeviceProcAddr(device, "vkDestroyCuFunctionNVX") + DestroyCuModuleNVX = auto_cast GetDeviceProcAddr(device, "vkDestroyCuModuleNVX") + DestroyDeferredOperationKHR = auto_cast GetDeviceProcAddr(device, "vkDestroyDeferredOperationKHR") + DestroyDescriptorPool = auto_cast GetDeviceProcAddr(device, "vkDestroyDescriptorPool") + DestroyDescriptorSetLayout = auto_cast GetDeviceProcAddr(device, "vkDestroyDescriptorSetLayout") + DestroyDescriptorUpdateTemplate = auto_cast GetDeviceProcAddr(device, "vkDestroyDescriptorUpdateTemplate") + DestroyDescriptorUpdateTemplateKHR = auto_cast GetDeviceProcAddr(device, "vkDestroyDescriptorUpdateTemplateKHR") + DestroyDevice = auto_cast GetDeviceProcAddr(device, "vkDestroyDevice") + DestroyEvent = auto_cast GetDeviceProcAddr(device, "vkDestroyEvent") + DestroyFence = auto_cast GetDeviceProcAddr(device, "vkDestroyFence") + DestroyFramebuffer = auto_cast GetDeviceProcAddr(device, "vkDestroyFramebuffer") + DestroyImage = auto_cast GetDeviceProcAddr(device, "vkDestroyImage") + DestroyImageView = auto_cast GetDeviceProcAddr(device, "vkDestroyImageView") + DestroyIndirectCommandsLayoutNV = auto_cast GetDeviceProcAddr(device, "vkDestroyIndirectCommandsLayoutNV") + DestroyMicromapEXT = auto_cast GetDeviceProcAddr(device, "vkDestroyMicromapEXT") + DestroyOpticalFlowSessionNV = auto_cast GetDeviceProcAddr(device, "vkDestroyOpticalFlowSessionNV") + DestroyPipeline = auto_cast GetDeviceProcAddr(device, "vkDestroyPipeline") + DestroyPipelineCache = auto_cast GetDeviceProcAddr(device, "vkDestroyPipelineCache") + DestroyPipelineLayout = auto_cast GetDeviceProcAddr(device, "vkDestroyPipelineLayout") + DestroyPrivateDataSlot = auto_cast GetDeviceProcAddr(device, "vkDestroyPrivateDataSlot") + DestroyPrivateDataSlotEXT = auto_cast GetDeviceProcAddr(device, "vkDestroyPrivateDataSlotEXT") + DestroyQueryPool = auto_cast GetDeviceProcAddr(device, "vkDestroyQueryPool") + DestroyRenderPass = auto_cast GetDeviceProcAddr(device, "vkDestroyRenderPass") + DestroySampler = auto_cast GetDeviceProcAddr(device, "vkDestroySampler") + DestroySamplerYcbcrConversion = auto_cast GetDeviceProcAddr(device, "vkDestroySamplerYcbcrConversion") + DestroySamplerYcbcrConversionKHR = auto_cast GetDeviceProcAddr(device, "vkDestroySamplerYcbcrConversionKHR") + DestroySemaphore = auto_cast GetDeviceProcAddr(device, "vkDestroySemaphore") + DestroyShaderEXT = auto_cast GetDeviceProcAddr(device, "vkDestroyShaderEXT") + DestroyShaderModule = auto_cast GetDeviceProcAddr(device, "vkDestroyShaderModule") + DestroySwapchainKHR = auto_cast GetDeviceProcAddr(device, "vkDestroySwapchainKHR") + DestroyValidationCacheEXT = auto_cast GetDeviceProcAddr(device, "vkDestroyValidationCacheEXT") + DestroyVideoSessionKHR = auto_cast GetDeviceProcAddr(device, "vkDestroyVideoSessionKHR") + DestroyVideoSessionParametersKHR = auto_cast GetDeviceProcAddr(device, "vkDestroyVideoSessionParametersKHR") + DeviceWaitIdle = auto_cast GetDeviceProcAddr(device, "vkDeviceWaitIdle") + DisplayPowerControlEXT = auto_cast GetDeviceProcAddr(device, "vkDisplayPowerControlEXT") + EndCommandBuffer = auto_cast GetDeviceProcAddr(device, "vkEndCommandBuffer") + ExportMetalObjectsEXT = auto_cast GetDeviceProcAddr(device, "vkExportMetalObjectsEXT") + FlushMappedMemoryRanges = auto_cast GetDeviceProcAddr(device, "vkFlushMappedMemoryRanges") + FreeCommandBuffers = auto_cast GetDeviceProcAddr(device, "vkFreeCommandBuffers") + FreeDescriptorSets = auto_cast GetDeviceProcAddr(device, "vkFreeDescriptorSets") + FreeMemory = auto_cast GetDeviceProcAddr(device, "vkFreeMemory") + GetAccelerationStructureBuildSizesKHR = auto_cast GetDeviceProcAddr(device, "vkGetAccelerationStructureBuildSizesKHR") + GetAccelerationStructureDeviceAddressKHR = auto_cast GetDeviceProcAddr(device, "vkGetAccelerationStructureDeviceAddressKHR") + GetAccelerationStructureHandleNV = auto_cast GetDeviceProcAddr(device, "vkGetAccelerationStructureHandleNV") + GetAccelerationStructureMemoryRequirementsNV = auto_cast GetDeviceProcAddr(device, "vkGetAccelerationStructureMemoryRequirementsNV") + GetAccelerationStructureOpaqueCaptureDescriptorDataEXT = auto_cast GetDeviceProcAddr(device, "vkGetAccelerationStructureOpaqueCaptureDescriptorDataEXT") + GetBufferDeviceAddress = auto_cast GetDeviceProcAddr(device, "vkGetBufferDeviceAddress") + GetBufferDeviceAddressEXT = auto_cast GetDeviceProcAddr(device, "vkGetBufferDeviceAddressEXT") + GetBufferDeviceAddressKHR = auto_cast GetDeviceProcAddr(device, "vkGetBufferDeviceAddressKHR") + GetBufferMemoryRequirements = auto_cast GetDeviceProcAddr(device, "vkGetBufferMemoryRequirements") + GetBufferMemoryRequirements2 = auto_cast GetDeviceProcAddr(device, "vkGetBufferMemoryRequirements2") + GetBufferMemoryRequirements2KHR = auto_cast GetDeviceProcAddr(device, "vkGetBufferMemoryRequirements2KHR") + GetBufferOpaqueCaptureAddress = auto_cast GetDeviceProcAddr(device, "vkGetBufferOpaqueCaptureAddress") + GetBufferOpaqueCaptureAddressKHR = auto_cast GetDeviceProcAddr(device, "vkGetBufferOpaqueCaptureAddressKHR") + GetBufferOpaqueCaptureDescriptorDataEXT = auto_cast GetDeviceProcAddr(device, "vkGetBufferOpaqueCaptureDescriptorDataEXT") + GetCalibratedTimestampsEXT = auto_cast GetDeviceProcAddr(device, "vkGetCalibratedTimestampsEXT") + GetDeferredOperationMaxConcurrencyKHR = auto_cast GetDeviceProcAddr(device, "vkGetDeferredOperationMaxConcurrencyKHR") + GetDeferredOperationResultKHR = auto_cast GetDeviceProcAddr(device, "vkGetDeferredOperationResultKHR") + GetDescriptorEXT = auto_cast GetDeviceProcAddr(device, "vkGetDescriptorEXT") + GetDescriptorSetHostMappingVALVE = auto_cast GetDeviceProcAddr(device, "vkGetDescriptorSetHostMappingVALVE") + GetDescriptorSetLayoutBindingOffsetEXT = auto_cast GetDeviceProcAddr(device, "vkGetDescriptorSetLayoutBindingOffsetEXT") + GetDescriptorSetLayoutHostMappingInfoVALVE = auto_cast GetDeviceProcAddr(device, "vkGetDescriptorSetLayoutHostMappingInfoVALVE") + GetDescriptorSetLayoutSizeEXT = auto_cast GetDeviceProcAddr(device, "vkGetDescriptorSetLayoutSizeEXT") + GetDescriptorSetLayoutSupport = auto_cast GetDeviceProcAddr(device, "vkGetDescriptorSetLayoutSupport") + GetDescriptorSetLayoutSupportKHR = auto_cast GetDeviceProcAddr(device, "vkGetDescriptorSetLayoutSupportKHR") + GetDeviceAccelerationStructureCompatibilityKHR = auto_cast GetDeviceProcAddr(device, "vkGetDeviceAccelerationStructureCompatibilityKHR") + GetDeviceBufferMemoryRequirements = auto_cast GetDeviceProcAddr(device, "vkGetDeviceBufferMemoryRequirements") + GetDeviceBufferMemoryRequirementsKHR = auto_cast GetDeviceProcAddr(device, "vkGetDeviceBufferMemoryRequirementsKHR") + GetDeviceFaultInfoEXT = auto_cast GetDeviceProcAddr(device, "vkGetDeviceFaultInfoEXT") + GetDeviceGroupPeerMemoryFeatures = auto_cast GetDeviceProcAddr(device, "vkGetDeviceGroupPeerMemoryFeatures") + GetDeviceGroupPeerMemoryFeaturesKHR = auto_cast GetDeviceProcAddr(device, "vkGetDeviceGroupPeerMemoryFeaturesKHR") + GetDeviceGroupPresentCapabilitiesKHR = auto_cast GetDeviceProcAddr(device, "vkGetDeviceGroupPresentCapabilitiesKHR") + GetDeviceGroupSurfacePresentModes2EXT = auto_cast GetDeviceProcAddr(device, "vkGetDeviceGroupSurfacePresentModes2EXT") + GetDeviceGroupSurfacePresentModesKHR = auto_cast GetDeviceProcAddr(device, "vkGetDeviceGroupSurfacePresentModesKHR") + GetDeviceImageMemoryRequirements = auto_cast GetDeviceProcAddr(device, "vkGetDeviceImageMemoryRequirements") + GetDeviceImageMemoryRequirementsKHR = auto_cast GetDeviceProcAddr(device, "vkGetDeviceImageMemoryRequirementsKHR") + GetDeviceImageSparseMemoryRequirements = auto_cast GetDeviceProcAddr(device, "vkGetDeviceImageSparseMemoryRequirements") + GetDeviceImageSparseMemoryRequirementsKHR = auto_cast GetDeviceProcAddr(device, "vkGetDeviceImageSparseMemoryRequirementsKHR") + GetDeviceMemoryCommitment = auto_cast GetDeviceProcAddr(device, "vkGetDeviceMemoryCommitment") + GetDeviceMemoryOpaqueCaptureAddress = auto_cast GetDeviceProcAddr(device, "vkGetDeviceMemoryOpaqueCaptureAddress") + GetDeviceMemoryOpaqueCaptureAddressKHR = auto_cast GetDeviceProcAddr(device, "vkGetDeviceMemoryOpaqueCaptureAddressKHR") + GetDeviceMicromapCompatibilityEXT = auto_cast GetDeviceProcAddr(device, "vkGetDeviceMicromapCompatibilityEXT") + GetDeviceProcAddr = auto_cast GetDeviceProcAddr(device, "vkGetDeviceProcAddr") + GetDeviceQueue = auto_cast GetDeviceProcAddr(device, "vkGetDeviceQueue") + GetDeviceQueue2 = auto_cast GetDeviceProcAddr(device, "vkGetDeviceQueue2") + GetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI = auto_cast GetDeviceProcAddr(device, "vkGetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI") + GetDynamicRenderingTilePropertiesQCOM = auto_cast GetDeviceProcAddr(device, "vkGetDynamicRenderingTilePropertiesQCOM") + GetEventStatus = auto_cast GetDeviceProcAddr(device, "vkGetEventStatus") + GetFenceFdKHR = auto_cast GetDeviceProcAddr(device, "vkGetFenceFdKHR") + GetFenceStatus = auto_cast GetDeviceProcAddr(device, "vkGetFenceStatus") + GetFenceWin32HandleKHR = auto_cast GetDeviceProcAddr(device, "vkGetFenceWin32HandleKHR") + GetFramebufferTilePropertiesQCOM = auto_cast GetDeviceProcAddr(device, "vkGetFramebufferTilePropertiesQCOM") + GetGeneratedCommandsMemoryRequirementsNV = auto_cast GetDeviceProcAddr(device, "vkGetGeneratedCommandsMemoryRequirementsNV") + GetImageDrmFormatModifierPropertiesEXT = auto_cast GetDeviceProcAddr(device, "vkGetImageDrmFormatModifierPropertiesEXT") + GetImageMemoryRequirements = auto_cast GetDeviceProcAddr(device, "vkGetImageMemoryRequirements") + GetImageMemoryRequirements2 = auto_cast GetDeviceProcAddr(device, "vkGetImageMemoryRequirements2") + GetImageMemoryRequirements2KHR = auto_cast GetDeviceProcAddr(device, "vkGetImageMemoryRequirements2KHR") + GetImageOpaqueCaptureDescriptorDataEXT = auto_cast GetDeviceProcAddr(device, "vkGetImageOpaqueCaptureDescriptorDataEXT") + GetImageSparseMemoryRequirements = auto_cast GetDeviceProcAddr(device, "vkGetImageSparseMemoryRequirements") + GetImageSparseMemoryRequirements2 = auto_cast GetDeviceProcAddr(device, "vkGetImageSparseMemoryRequirements2") + GetImageSparseMemoryRequirements2KHR = auto_cast GetDeviceProcAddr(device, "vkGetImageSparseMemoryRequirements2KHR") + GetImageSubresourceLayout = auto_cast GetDeviceProcAddr(device, "vkGetImageSubresourceLayout") + GetImageSubresourceLayout2EXT = auto_cast GetDeviceProcAddr(device, "vkGetImageSubresourceLayout2EXT") + GetImageViewAddressNVX = auto_cast GetDeviceProcAddr(device, "vkGetImageViewAddressNVX") + GetImageViewHandleNVX = auto_cast GetDeviceProcAddr(device, "vkGetImageViewHandleNVX") + GetImageViewOpaqueCaptureDescriptorDataEXT = auto_cast GetDeviceProcAddr(device, "vkGetImageViewOpaqueCaptureDescriptorDataEXT") + GetMemoryFdKHR = auto_cast GetDeviceProcAddr(device, "vkGetMemoryFdKHR") + GetMemoryFdPropertiesKHR = auto_cast GetDeviceProcAddr(device, "vkGetMemoryFdPropertiesKHR") + GetMemoryHostPointerPropertiesEXT = auto_cast GetDeviceProcAddr(device, "vkGetMemoryHostPointerPropertiesEXT") + GetMemoryRemoteAddressNV = auto_cast GetDeviceProcAddr(device, "vkGetMemoryRemoteAddressNV") + GetMemoryWin32HandleKHR = auto_cast GetDeviceProcAddr(device, "vkGetMemoryWin32HandleKHR") + GetMemoryWin32HandleNV = auto_cast GetDeviceProcAddr(device, "vkGetMemoryWin32HandleNV") + GetMemoryWin32HandlePropertiesKHR = auto_cast GetDeviceProcAddr(device, "vkGetMemoryWin32HandlePropertiesKHR") + GetMicromapBuildSizesEXT = auto_cast GetDeviceProcAddr(device, "vkGetMicromapBuildSizesEXT") + GetPastPresentationTimingGOOGLE = auto_cast GetDeviceProcAddr(device, "vkGetPastPresentationTimingGOOGLE") + GetPerformanceParameterINTEL = auto_cast GetDeviceProcAddr(device, "vkGetPerformanceParameterINTEL") + GetPipelineCacheData = auto_cast GetDeviceProcAddr(device, "vkGetPipelineCacheData") + GetPipelineExecutableInternalRepresentationsKHR = auto_cast GetDeviceProcAddr(device, "vkGetPipelineExecutableInternalRepresentationsKHR") + GetPipelineExecutablePropertiesKHR = auto_cast GetDeviceProcAddr(device, "vkGetPipelineExecutablePropertiesKHR") + GetPipelineExecutableStatisticsKHR = auto_cast GetDeviceProcAddr(device, "vkGetPipelineExecutableStatisticsKHR") + GetPipelinePropertiesEXT = auto_cast GetDeviceProcAddr(device, "vkGetPipelinePropertiesEXT") + GetPrivateData = auto_cast GetDeviceProcAddr(device, "vkGetPrivateData") + GetPrivateDataEXT = auto_cast GetDeviceProcAddr(device, "vkGetPrivateDataEXT") + GetQueryPoolResults = auto_cast GetDeviceProcAddr(device, "vkGetQueryPoolResults") + GetQueueCheckpointData2NV = auto_cast GetDeviceProcAddr(device, "vkGetQueueCheckpointData2NV") + GetQueueCheckpointDataNV = auto_cast GetDeviceProcAddr(device, "vkGetQueueCheckpointDataNV") + GetRayTracingCaptureReplayShaderGroupHandlesKHR = auto_cast GetDeviceProcAddr(device, "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR") + GetRayTracingShaderGroupHandlesKHR = auto_cast GetDeviceProcAddr(device, "vkGetRayTracingShaderGroupHandlesKHR") + GetRayTracingShaderGroupHandlesNV = auto_cast GetDeviceProcAddr(device, "vkGetRayTracingShaderGroupHandlesNV") + GetRayTracingShaderGroupStackSizeKHR = auto_cast GetDeviceProcAddr(device, "vkGetRayTracingShaderGroupStackSizeKHR") + GetRefreshCycleDurationGOOGLE = auto_cast GetDeviceProcAddr(device, "vkGetRefreshCycleDurationGOOGLE") + GetRenderAreaGranularity = auto_cast GetDeviceProcAddr(device, "vkGetRenderAreaGranularity") + GetSamplerOpaqueCaptureDescriptorDataEXT = auto_cast GetDeviceProcAddr(device, "vkGetSamplerOpaqueCaptureDescriptorDataEXT") + GetSemaphoreCounterValue = auto_cast GetDeviceProcAddr(device, "vkGetSemaphoreCounterValue") + GetSemaphoreCounterValueKHR = auto_cast GetDeviceProcAddr(device, "vkGetSemaphoreCounterValueKHR") + GetSemaphoreFdKHR = auto_cast GetDeviceProcAddr(device, "vkGetSemaphoreFdKHR") + GetSemaphoreWin32HandleKHR = auto_cast GetDeviceProcAddr(device, "vkGetSemaphoreWin32HandleKHR") + GetShaderBinaryDataEXT = auto_cast GetDeviceProcAddr(device, "vkGetShaderBinaryDataEXT") + GetShaderInfoAMD = auto_cast GetDeviceProcAddr(device, "vkGetShaderInfoAMD") + GetShaderModuleCreateInfoIdentifierEXT = auto_cast GetDeviceProcAddr(device, "vkGetShaderModuleCreateInfoIdentifierEXT") + GetShaderModuleIdentifierEXT = auto_cast GetDeviceProcAddr(device, "vkGetShaderModuleIdentifierEXT") + GetSwapchainCounterEXT = auto_cast GetDeviceProcAddr(device, "vkGetSwapchainCounterEXT") + GetSwapchainImagesKHR = auto_cast GetDeviceProcAddr(device, "vkGetSwapchainImagesKHR") + GetSwapchainStatusKHR = auto_cast GetDeviceProcAddr(device, "vkGetSwapchainStatusKHR") + GetValidationCacheDataEXT = auto_cast GetDeviceProcAddr(device, "vkGetValidationCacheDataEXT") + GetVideoSessionMemoryRequirementsKHR = auto_cast GetDeviceProcAddr(device, "vkGetVideoSessionMemoryRequirementsKHR") + ImportFenceFdKHR = auto_cast GetDeviceProcAddr(device, "vkImportFenceFdKHR") + ImportFenceWin32HandleKHR = auto_cast GetDeviceProcAddr(device, "vkImportFenceWin32HandleKHR") + ImportSemaphoreFdKHR = auto_cast GetDeviceProcAddr(device, "vkImportSemaphoreFdKHR") + ImportSemaphoreWin32HandleKHR = auto_cast GetDeviceProcAddr(device, "vkImportSemaphoreWin32HandleKHR") + InitializePerformanceApiINTEL = auto_cast GetDeviceProcAddr(device, "vkInitializePerformanceApiINTEL") + InvalidateMappedMemoryRanges = auto_cast GetDeviceProcAddr(device, "vkInvalidateMappedMemoryRanges") + MapMemory = auto_cast GetDeviceProcAddr(device, "vkMapMemory") + MapMemory2KHR = auto_cast GetDeviceProcAddr(device, "vkMapMemory2KHR") + MergePipelineCaches = auto_cast GetDeviceProcAddr(device, "vkMergePipelineCaches") + MergeValidationCachesEXT = auto_cast GetDeviceProcAddr(device, "vkMergeValidationCachesEXT") + QueueBeginDebugUtilsLabelEXT = auto_cast GetDeviceProcAddr(device, "vkQueueBeginDebugUtilsLabelEXT") + QueueBindSparse = auto_cast GetDeviceProcAddr(device, "vkQueueBindSparse") + QueueEndDebugUtilsLabelEXT = auto_cast GetDeviceProcAddr(device, "vkQueueEndDebugUtilsLabelEXT") + QueueInsertDebugUtilsLabelEXT = auto_cast GetDeviceProcAddr(device, "vkQueueInsertDebugUtilsLabelEXT") + QueuePresentKHR = auto_cast GetDeviceProcAddr(device, "vkQueuePresentKHR") + QueueSetPerformanceConfigurationINTEL = auto_cast GetDeviceProcAddr(device, "vkQueueSetPerformanceConfigurationINTEL") + QueueSubmit = auto_cast GetDeviceProcAddr(device, "vkQueueSubmit") + QueueSubmit2 = auto_cast GetDeviceProcAddr(device, "vkQueueSubmit2") + QueueSubmit2KHR = auto_cast GetDeviceProcAddr(device, "vkQueueSubmit2KHR") + QueueWaitIdle = auto_cast GetDeviceProcAddr(device, "vkQueueWaitIdle") + RegisterDeviceEventEXT = auto_cast GetDeviceProcAddr(device, "vkRegisterDeviceEventEXT") + RegisterDisplayEventEXT = auto_cast GetDeviceProcAddr(device, "vkRegisterDisplayEventEXT") + ReleaseFullScreenExclusiveModeEXT = auto_cast GetDeviceProcAddr(device, "vkReleaseFullScreenExclusiveModeEXT") + ReleasePerformanceConfigurationINTEL = auto_cast GetDeviceProcAddr(device, "vkReleasePerformanceConfigurationINTEL") + ReleaseProfilingLockKHR = auto_cast GetDeviceProcAddr(device, "vkReleaseProfilingLockKHR") + ReleaseSwapchainImagesEXT = auto_cast GetDeviceProcAddr(device, "vkReleaseSwapchainImagesEXT") + ResetCommandBuffer = auto_cast GetDeviceProcAddr(device, "vkResetCommandBuffer") + ResetCommandPool = auto_cast GetDeviceProcAddr(device, "vkResetCommandPool") + ResetDescriptorPool = auto_cast GetDeviceProcAddr(device, "vkResetDescriptorPool") + ResetEvent = auto_cast GetDeviceProcAddr(device, "vkResetEvent") + ResetFences = auto_cast GetDeviceProcAddr(device, "vkResetFences") + ResetQueryPool = auto_cast GetDeviceProcAddr(device, "vkResetQueryPool") + ResetQueryPoolEXT = auto_cast GetDeviceProcAddr(device, "vkResetQueryPoolEXT") + SetDebugUtilsObjectNameEXT = auto_cast GetDeviceProcAddr(device, "vkSetDebugUtilsObjectNameEXT") + SetDebugUtilsObjectTagEXT = auto_cast GetDeviceProcAddr(device, "vkSetDebugUtilsObjectTagEXT") + SetDeviceMemoryPriorityEXT = auto_cast GetDeviceProcAddr(device, "vkSetDeviceMemoryPriorityEXT") + SetEvent = auto_cast GetDeviceProcAddr(device, "vkSetEvent") + SetHdrMetadataEXT = auto_cast GetDeviceProcAddr(device, "vkSetHdrMetadataEXT") + SetLocalDimmingAMD = auto_cast GetDeviceProcAddr(device, "vkSetLocalDimmingAMD") + SetPrivateData = auto_cast GetDeviceProcAddr(device, "vkSetPrivateData") + SetPrivateDataEXT = auto_cast GetDeviceProcAddr(device, "vkSetPrivateDataEXT") + SignalSemaphore = auto_cast GetDeviceProcAddr(device, "vkSignalSemaphore") + SignalSemaphoreKHR = auto_cast GetDeviceProcAddr(device, "vkSignalSemaphoreKHR") + TrimCommandPool = auto_cast GetDeviceProcAddr(device, "vkTrimCommandPool") + TrimCommandPoolKHR = auto_cast GetDeviceProcAddr(device, "vkTrimCommandPoolKHR") + UninitializePerformanceApiINTEL = auto_cast GetDeviceProcAddr(device, "vkUninitializePerformanceApiINTEL") + UnmapMemory = auto_cast GetDeviceProcAddr(device, "vkUnmapMemory") + UnmapMemory2KHR = auto_cast GetDeviceProcAddr(device, "vkUnmapMemory2KHR") + UpdateDescriptorSetWithTemplate = auto_cast GetDeviceProcAddr(device, "vkUpdateDescriptorSetWithTemplate") + UpdateDescriptorSetWithTemplateKHR = auto_cast GetDeviceProcAddr(device, "vkUpdateDescriptorSetWithTemplateKHR") + UpdateDescriptorSets = auto_cast GetDeviceProcAddr(device, "vkUpdateDescriptorSets") + UpdateVideoSessionParametersKHR = auto_cast GetDeviceProcAddr(device, "vkUpdateVideoSessionParametersKHR") + WaitForFences = auto_cast GetDeviceProcAddr(device, "vkWaitForFences") + WaitForPresentKHR = auto_cast GetDeviceProcAddr(device, "vkWaitForPresentKHR") + WaitSemaphores = auto_cast GetDeviceProcAddr(device, "vkWaitSemaphores") + WaitSemaphoresKHR = auto_cast GetDeviceProcAddr(device, "vkWaitSemaphoresKHR") + WriteAccelerationStructuresPropertiesKHR = auto_cast GetDeviceProcAddr(device, "vkWriteAccelerationStructuresPropertiesKHR") + WriteMicromapsPropertiesEXT = auto_cast GetDeviceProcAddr(device, "vkWriteMicromapsPropertiesEXT") +} + +load_proc_addresses_instance :: proc(instance: Instance) { + AcquireDrmDisplayEXT = auto_cast GetInstanceProcAddr(instance, "vkAcquireDrmDisplayEXT") + AcquireWinrtDisplayNV = auto_cast GetInstanceProcAddr(instance, "vkAcquireWinrtDisplayNV") + CreateDebugReportCallbackEXT = auto_cast GetInstanceProcAddr(instance, "vkCreateDebugReportCallbackEXT") + CreateDebugUtilsMessengerEXT = auto_cast GetInstanceProcAddr(instance, "vkCreateDebugUtilsMessengerEXT") + CreateDevice = auto_cast GetInstanceProcAddr(instance, "vkCreateDevice") + CreateDisplayModeKHR = auto_cast GetInstanceProcAddr(instance, "vkCreateDisplayModeKHR") + CreateDisplayPlaneSurfaceKHR = auto_cast GetInstanceProcAddr(instance, "vkCreateDisplayPlaneSurfaceKHR") + CreateHeadlessSurfaceEXT = auto_cast GetInstanceProcAddr(instance, "vkCreateHeadlessSurfaceEXT") + CreateIOSSurfaceMVK = auto_cast GetInstanceProcAddr(instance, "vkCreateIOSSurfaceMVK") + CreateMacOSSurfaceMVK = auto_cast GetInstanceProcAddr(instance, "vkCreateMacOSSurfaceMVK") + CreateMetalSurfaceEXT = auto_cast GetInstanceProcAddr(instance, "vkCreateMetalSurfaceEXT") + CreateWaylandSurfaceKHR = auto_cast GetInstanceProcAddr(instance, "vkCreateWaylandSurfaceKHR") + CreateWin32SurfaceKHR = auto_cast GetInstanceProcAddr(instance, "vkCreateWin32SurfaceKHR") + DebugReportMessageEXT = auto_cast GetInstanceProcAddr(instance, "vkDebugReportMessageEXT") + DestroyDebugReportCallbackEXT = auto_cast GetInstanceProcAddr(instance, "vkDestroyDebugReportCallbackEXT") + DestroyDebugUtilsMessengerEXT = auto_cast GetInstanceProcAddr(instance, "vkDestroyDebugUtilsMessengerEXT") + DestroyInstance = auto_cast GetInstanceProcAddr(instance, "vkDestroyInstance") + DestroySurfaceKHR = auto_cast GetInstanceProcAddr(instance, "vkDestroySurfaceKHR") + EnumerateDeviceExtensionProperties = auto_cast GetInstanceProcAddr(instance, "vkEnumerateDeviceExtensionProperties") + EnumerateDeviceLayerProperties = auto_cast GetInstanceProcAddr(instance, "vkEnumerateDeviceLayerProperties") + EnumeratePhysicalDeviceGroups = auto_cast GetInstanceProcAddr(instance, "vkEnumeratePhysicalDeviceGroups") + EnumeratePhysicalDeviceGroupsKHR = auto_cast GetInstanceProcAddr(instance, "vkEnumeratePhysicalDeviceGroupsKHR") + EnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR = auto_cast GetInstanceProcAddr(instance, "vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR") + EnumeratePhysicalDevices = auto_cast GetInstanceProcAddr(instance, "vkEnumeratePhysicalDevices") + GetDisplayModeProperties2KHR = auto_cast GetInstanceProcAddr(instance, "vkGetDisplayModeProperties2KHR") + GetDisplayModePropertiesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetDisplayModePropertiesKHR") + GetDisplayPlaneCapabilities2KHR = auto_cast GetInstanceProcAddr(instance, "vkGetDisplayPlaneCapabilities2KHR") + GetDisplayPlaneCapabilitiesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetDisplayPlaneCapabilitiesKHR") + GetDisplayPlaneSupportedDisplaysKHR = auto_cast GetInstanceProcAddr(instance, "vkGetDisplayPlaneSupportedDisplaysKHR") + GetDrmDisplayEXT = auto_cast GetInstanceProcAddr(instance, "vkGetDrmDisplayEXT") + GetInstanceProcAddrLUNARG = auto_cast GetInstanceProcAddr(instance, "vkGetInstanceProcAddrLUNARG") + GetPhysicalDeviceCalibrateableTimeDomainsEXT = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceCalibrateableTimeDomainsEXT") + GetPhysicalDeviceCooperativeMatrixPropertiesNV = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceCooperativeMatrixPropertiesNV") + GetPhysicalDeviceDisplayPlaneProperties2KHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceDisplayPlaneProperties2KHR") + GetPhysicalDeviceDisplayPlanePropertiesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceDisplayPlanePropertiesKHR") + GetPhysicalDeviceDisplayProperties2KHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceDisplayProperties2KHR") + GetPhysicalDeviceDisplayPropertiesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceDisplayPropertiesKHR") + GetPhysicalDeviceExternalBufferProperties = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceExternalBufferProperties") + GetPhysicalDeviceExternalBufferPropertiesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceExternalBufferPropertiesKHR") + GetPhysicalDeviceExternalFenceProperties = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceExternalFenceProperties") + GetPhysicalDeviceExternalFencePropertiesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceExternalFencePropertiesKHR") + GetPhysicalDeviceExternalImageFormatPropertiesNV = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceExternalImageFormatPropertiesNV") + GetPhysicalDeviceExternalSemaphoreProperties = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceExternalSemaphoreProperties") + GetPhysicalDeviceExternalSemaphorePropertiesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceExternalSemaphorePropertiesKHR") + GetPhysicalDeviceFeatures = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceFeatures") + GetPhysicalDeviceFeatures2 = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceFeatures2") + GetPhysicalDeviceFeatures2KHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceFeatures2KHR") + GetPhysicalDeviceFormatProperties = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceFormatProperties") + GetPhysicalDeviceFormatProperties2 = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceFormatProperties2") + GetPhysicalDeviceFormatProperties2KHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceFormatProperties2KHR") + GetPhysicalDeviceFragmentShadingRatesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceFragmentShadingRatesKHR") + GetPhysicalDeviceImageFormatProperties = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceImageFormatProperties") + GetPhysicalDeviceImageFormatProperties2 = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceImageFormatProperties2") + GetPhysicalDeviceImageFormatProperties2KHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceImageFormatProperties2KHR") + GetPhysicalDeviceMemoryProperties = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceMemoryProperties") + GetPhysicalDeviceMemoryProperties2 = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceMemoryProperties2") + GetPhysicalDeviceMemoryProperties2KHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceMemoryProperties2KHR") + GetPhysicalDeviceMultisamplePropertiesEXT = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceMultisamplePropertiesEXT") + GetPhysicalDeviceOpticalFlowImageFormatsNV = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceOpticalFlowImageFormatsNV") + GetPhysicalDevicePresentRectanglesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDevicePresentRectanglesKHR") + GetPhysicalDeviceProperties = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceProperties") + GetPhysicalDeviceProperties2 = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceProperties2") + GetPhysicalDeviceProperties2KHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceProperties2KHR") + GetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR") + GetPhysicalDeviceQueueFamilyProperties = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceQueueFamilyProperties") + GetPhysicalDeviceQueueFamilyProperties2 = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceQueueFamilyProperties2") + GetPhysicalDeviceQueueFamilyProperties2KHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceQueueFamilyProperties2KHR") + GetPhysicalDeviceSparseImageFormatProperties = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceSparseImageFormatProperties") + GetPhysicalDeviceSparseImageFormatProperties2 = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceSparseImageFormatProperties2") + GetPhysicalDeviceSparseImageFormatProperties2KHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceSparseImageFormatProperties2KHR") + GetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV") + GetPhysicalDeviceSurfaceCapabilities2EXT = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceSurfaceCapabilities2EXT") + GetPhysicalDeviceSurfaceCapabilities2KHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceSurfaceCapabilities2KHR") + GetPhysicalDeviceSurfaceCapabilitiesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceSurfaceCapabilitiesKHR") + GetPhysicalDeviceSurfaceFormats2KHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceSurfaceFormats2KHR") + GetPhysicalDeviceSurfaceFormatsKHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceSurfaceFormatsKHR") + GetPhysicalDeviceSurfacePresentModes2EXT = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceSurfacePresentModes2EXT") + GetPhysicalDeviceSurfacePresentModesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceSurfacePresentModesKHR") + GetPhysicalDeviceSurfaceSupportKHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceSurfaceSupportKHR") + GetPhysicalDeviceToolProperties = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceToolProperties") + GetPhysicalDeviceToolPropertiesEXT = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceToolPropertiesEXT") + GetPhysicalDeviceVideoCapabilitiesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceVideoCapabilitiesKHR") + GetPhysicalDeviceVideoFormatPropertiesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceVideoFormatPropertiesKHR") + GetPhysicalDeviceWaylandPresentationSupportKHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceWaylandPresentationSupportKHR") + GetPhysicalDeviceWin32PresentationSupportKHR = auto_cast GetInstanceProcAddr(instance, "vkGetPhysicalDeviceWin32PresentationSupportKHR") + GetWinrtDisplayNV = auto_cast GetInstanceProcAddr(instance, "vkGetWinrtDisplayNV") + ReleaseDisplayEXT = auto_cast GetInstanceProcAddr(instance, "vkReleaseDisplayEXT") + SubmitDebugUtilsMessageEXT = auto_cast GetInstanceProcAddr(instance, "vkSubmitDebugUtilsMessageEXT") + + // Device Procedures (may call into dispatch) + AcquireFullScreenExclusiveModeEXT = auto_cast GetInstanceProcAddr(instance, "vkAcquireFullScreenExclusiveModeEXT") + AcquireNextImage2KHR = auto_cast GetInstanceProcAddr(instance, "vkAcquireNextImage2KHR") + AcquireNextImageKHR = auto_cast GetInstanceProcAddr(instance, "vkAcquireNextImageKHR") + AcquirePerformanceConfigurationINTEL = auto_cast GetInstanceProcAddr(instance, "vkAcquirePerformanceConfigurationINTEL") + AcquireProfilingLockKHR = auto_cast GetInstanceProcAddr(instance, "vkAcquireProfilingLockKHR") + AllocateCommandBuffers = auto_cast GetInstanceProcAddr(instance, "vkAllocateCommandBuffers") + AllocateDescriptorSets = auto_cast GetInstanceProcAddr(instance, "vkAllocateDescriptorSets") + AllocateMemory = auto_cast GetInstanceProcAddr(instance, "vkAllocateMemory") + BeginCommandBuffer = auto_cast GetInstanceProcAddr(instance, "vkBeginCommandBuffer") + BindAccelerationStructureMemoryNV = auto_cast GetInstanceProcAddr(instance, "vkBindAccelerationStructureMemoryNV") + BindBufferMemory = auto_cast GetInstanceProcAddr(instance, "vkBindBufferMemory") + BindBufferMemory2 = auto_cast GetInstanceProcAddr(instance, "vkBindBufferMemory2") + BindBufferMemory2KHR = auto_cast GetInstanceProcAddr(instance, "vkBindBufferMemory2KHR") + BindImageMemory = auto_cast GetInstanceProcAddr(instance, "vkBindImageMemory") + BindImageMemory2 = auto_cast GetInstanceProcAddr(instance, "vkBindImageMemory2") + BindImageMemory2KHR = auto_cast GetInstanceProcAddr(instance, "vkBindImageMemory2KHR") + BindOpticalFlowSessionImageNV = auto_cast GetInstanceProcAddr(instance, "vkBindOpticalFlowSessionImageNV") + BindVideoSessionMemoryKHR = auto_cast GetInstanceProcAddr(instance, "vkBindVideoSessionMemoryKHR") + BuildAccelerationStructuresKHR = auto_cast GetInstanceProcAddr(instance, "vkBuildAccelerationStructuresKHR") + BuildMicromapsEXT = auto_cast GetInstanceProcAddr(instance, "vkBuildMicromapsEXT") + CmdBeginConditionalRenderingEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdBeginConditionalRenderingEXT") + CmdBeginDebugUtilsLabelEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdBeginDebugUtilsLabelEXT") + CmdBeginQuery = auto_cast GetInstanceProcAddr(instance, "vkCmdBeginQuery") + CmdBeginQueryIndexedEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdBeginQueryIndexedEXT") + CmdBeginRenderPass = auto_cast GetInstanceProcAddr(instance, "vkCmdBeginRenderPass") + CmdBeginRenderPass2 = auto_cast GetInstanceProcAddr(instance, "vkCmdBeginRenderPass2") + CmdBeginRenderPass2KHR = auto_cast GetInstanceProcAddr(instance, "vkCmdBeginRenderPass2KHR") + CmdBeginRendering = auto_cast GetInstanceProcAddr(instance, "vkCmdBeginRendering") + CmdBeginRenderingKHR = auto_cast GetInstanceProcAddr(instance, "vkCmdBeginRenderingKHR") + CmdBeginTransformFeedbackEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdBeginTransformFeedbackEXT") + CmdBeginVideoCodingKHR = auto_cast GetInstanceProcAddr(instance, "vkCmdBeginVideoCodingKHR") + CmdBindDescriptorBufferEmbeddedSamplersEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdBindDescriptorBufferEmbeddedSamplersEXT") + CmdBindDescriptorBuffersEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdBindDescriptorBuffersEXT") + CmdBindDescriptorSets = auto_cast GetInstanceProcAddr(instance, "vkCmdBindDescriptorSets") + CmdBindIndexBuffer = auto_cast GetInstanceProcAddr(instance, "vkCmdBindIndexBuffer") + CmdBindInvocationMaskHUAWEI = auto_cast GetInstanceProcAddr(instance, "vkCmdBindInvocationMaskHUAWEI") + CmdBindPipeline = auto_cast GetInstanceProcAddr(instance, "vkCmdBindPipeline") + CmdBindPipelineShaderGroupNV = auto_cast GetInstanceProcAddr(instance, "vkCmdBindPipelineShaderGroupNV") + CmdBindShadersEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdBindShadersEXT") + CmdBindShadingRateImageNV = auto_cast GetInstanceProcAddr(instance, "vkCmdBindShadingRateImageNV") + CmdBindTransformFeedbackBuffersEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdBindTransformFeedbackBuffersEXT") + CmdBindVertexBuffers = auto_cast GetInstanceProcAddr(instance, "vkCmdBindVertexBuffers") + CmdBindVertexBuffers2 = auto_cast GetInstanceProcAddr(instance, "vkCmdBindVertexBuffers2") + CmdBindVertexBuffers2EXT = auto_cast GetInstanceProcAddr(instance, "vkCmdBindVertexBuffers2EXT") + CmdBlitImage = auto_cast GetInstanceProcAddr(instance, "vkCmdBlitImage") + CmdBlitImage2 = auto_cast GetInstanceProcAddr(instance, "vkCmdBlitImage2") + CmdBlitImage2KHR = auto_cast GetInstanceProcAddr(instance, "vkCmdBlitImage2KHR") + CmdBuildAccelerationStructureNV = auto_cast GetInstanceProcAddr(instance, "vkCmdBuildAccelerationStructureNV") + CmdBuildAccelerationStructuresIndirectKHR = auto_cast GetInstanceProcAddr(instance, "vkCmdBuildAccelerationStructuresIndirectKHR") + CmdBuildAccelerationStructuresKHR = auto_cast GetInstanceProcAddr(instance, "vkCmdBuildAccelerationStructuresKHR") + CmdBuildMicromapsEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdBuildMicromapsEXT") + CmdClearAttachments = auto_cast GetInstanceProcAddr(instance, "vkCmdClearAttachments") + CmdClearColorImage = auto_cast GetInstanceProcAddr(instance, "vkCmdClearColorImage") + CmdClearDepthStencilImage = auto_cast GetInstanceProcAddr(instance, "vkCmdClearDepthStencilImage") + CmdControlVideoCodingKHR = auto_cast GetInstanceProcAddr(instance, "vkCmdControlVideoCodingKHR") + CmdCopyAccelerationStructureKHR = auto_cast GetInstanceProcAddr(instance, "vkCmdCopyAccelerationStructureKHR") + CmdCopyAccelerationStructureNV = auto_cast GetInstanceProcAddr(instance, "vkCmdCopyAccelerationStructureNV") + CmdCopyAccelerationStructureToMemoryKHR = auto_cast GetInstanceProcAddr(instance, "vkCmdCopyAccelerationStructureToMemoryKHR") + CmdCopyBuffer = auto_cast GetInstanceProcAddr(instance, "vkCmdCopyBuffer") + CmdCopyBuffer2 = auto_cast GetInstanceProcAddr(instance, "vkCmdCopyBuffer2") + CmdCopyBuffer2KHR = auto_cast GetInstanceProcAddr(instance, "vkCmdCopyBuffer2KHR") + CmdCopyBufferToImage = auto_cast GetInstanceProcAddr(instance, "vkCmdCopyBufferToImage") + CmdCopyBufferToImage2 = auto_cast GetInstanceProcAddr(instance, "vkCmdCopyBufferToImage2") + CmdCopyBufferToImage2KHR = auto_cast GetInstanceProcAddr(instance, "vkCmdCopyBufferToImage2KHR") + CmdCopyImage = auto_cast GetInstanceProcAddr(instance, "vkCmdCopyImage") + CmdCopyImage2 = auto_cast GetInstanceProcAddr(instance, "vkCmdCopyImage2") + CmdCopyImage2KHR = auto_cast GetInstanceProcAddr(instance, "vkCmdCopyImage2KHR") + CmdCopyImageToBuffer = auto_cast GetInstanceProcAddr(instance, "vkCmdCopyImageToBuffer") + CmdCopyImageToBuffer2 = auto_cast GetInstanceProcAddr(instance, "vkCmdCopyImageToBuffer2") + CmdCopyImageToBuffer2KHR = auto_cast GetInstanceProcAddr(instance, "vkCmdCopyImageToBuffer2KHR") + CmdCopyMemoryIndirectNV = auto_cast GetInstanceProcAddr(instance, "vkCmdCopyMemoryIndirectNV") + CmdCopyMemoryToAccelerationStructureKHR = auto_cast GetInstanceProcAddr(instance, "vkCmdCopyMemoryToAccelerationStructureKHR") + CmdCopyMemoryToImageIndirectNV = auto_cast GetInstanceProcAddr(instance, "vkCmdCopyMemoryToImageIndirectNV") + CmdCopyMemoryToMicromapEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdCopyMemoryToMicromapEXT") + CmdCopyMicromapEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdCopyMicromapEXT") + CmdCopyMicromapToMemoryEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdCopyMicromapToMemoryEXT") + CmdCopyQueryPoolResults = auto_cast GetInstanceProcAddr(instance, "vkCmdCopyQueryPoolResults") + CmdCuLaunchKernelNVX = auto_cast GetInstanceProcAddr(instance, "vkCmdCuLaunchKernelNVX") + CmdDebugMarkerBeginEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdDebugMarkerBeginEXT") + CmdDebugMarkerEndEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdDebugMarkerEndEXT") + CmdDebugMarkerInsertEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdDebugMarkerInsertEXT") + CmdDecodeVideoKHR = auto_cast GetInstanceProcAddr(instance, "vkCmdDecodeVideoKHR") + CmdDecompressMemoryIndirectCountNV = auto_cast GetInstanceProcAddr(instance, "vkCmdDecompressMemoryIndirectCountNV") + CmdDecompressMemoryNV = auto_cast GetInstanceProcAddr(instance, "vkCmdDecompressMemoryNV") + CmdDispatch = auto_cast GetInstanceProcAddr(instance, "vkCmdDispatch") + CmdDispatchBase = auto_cast GetInstanceProcAddr(instance, "vkCmdDispatchBase") + CmdDispatchBaseKHR = auto_cast GetInstanceProcAddr(instance, "vkCmdDispatchBaseKHR") + CmdDispatchIndirect = auto_cast GetInstanceProcAddr(instance, "vkCmdDispatchIndirect") + CmdDraw = auto_cast GetInstanceProcAddr(instance, "vkCmdDraw") + CmdDrawClusterHUAWEI = auto_cast GetInstanceProcAddr(instance, "vkCmdDrawClusterHUAWEI") + CmdDrawClusterIndirectHUAWEI = auto_cast GetInstanceProcAddr(instance, "vkCmdDrawClusterIndirectHUAWEI") + CmdDrawIndexed = auto_cast GetInstanceProcAddr(instance, "vkCmdDrawIndexed") + CmdDrawIndexedIndirect = auto_cast GetInstanceProcAddr(instance, "vkCmdDrawIndexedIndirect") + CmdDrawIndexedIndirectCount = auto_cast GetInstanceProcAddr(instance, "vkCmdDrawIndexedIndirectCount") + CmdDrawIndexedIndirectCountAMD = auto_cast GetInstanceProcAddr(instance, "vkCmdDrawIndexedIndirectCountAMD") + CmdDrawIndexedIndirectCountKHR = auto_cast GetInstanceProcAddr(instance, "vkCmdDrawIndexedIndirectCountKHR") + CmdDrawIndirect = auto_cast GetInstanceProcAddr(instance, "vkCmdDrawIndirect") + CmdDrawIndirectByteCountEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdDrawIndirectByteCountEXT") + CmdDrawIndirectCount = auto_cast GetInstanceProcAddr(instance, "vkCmdDrawIndirectCount") + CmdDrawIndirectCountAMD = auto_cast GetInstanceProcAddr(instance, "vkCmdDrawIndirectCountAMD") + CmdDrawIndirectCountKHR = auto_cast GetInstanceProcAddr(instance, "vkCmdDrawIndirectCountKHR") + CmdDrawMeshTasksEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdDrawMeshTasksEXT") + CmdDrawMeshTasksIndirectCountEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdDrawMeshTasksIndirectCountEXT") + CmdDrawMeshTasksIndirectCountNV = auto_cast GetInstanceProcAddr(instance, "vkCmdDrawMeshTasksIndirectCountNV") + CmdDrawMeshTasksIndirectEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdDrawMeshTasksIndirectEXT") + CmdDrawMeshTasksIndirectNV = auto_cast GetInstanceProcAddr(instance, "vkCmdDrawMeshTasksIndirectNV") + CmdDrawMeshTasksNV = auto_cast GetInstanceProcAddr(instance, "vkCmdDrawMeshTasksNV") + CmdDrawMultiEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdDrawMultiEXT") + CmdDrawMultiIndexedEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdDrawMultiIndexedEXT") + CmdEndConditionalRenderingEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdEndConditionalRenderingEXT") + CmdEndDebugUtilsLabelEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdEndDebugUtilsLabelEXT") + CmdEndQuery = auto_cast GetInstanceProcAddr(instance, "vkCmdEndQuery") + CmdEndQueryIndexedEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdEndQueryIndexedEXT") + CmdEndRenderPass = auto_cast GetInstanceProcAddr(instance, "vkCmdEndRenderPass") + CmdEndRenderPass2 = auto_cast GetInstanceProcAddr(instance, "vkCmdEndRenderPass2") + CmdEndRenderPass2KHR = auto_cast GetInstanceProcAddr(instance, "vkCmdEndRenderPass2KHR") + CmdEndRendering = auto_cast GetInstanceProcAddr(instance, "vkCmdEndRendering") + CmdEndRenderingKHR = auto_cast GetInstanceProcAddr(instance, "vkCmdEndRenderingKHR") + CmdEndTransformFeedbackEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdEndTransformFeedbackEXT") + CmdEndVideoCodingKHR = auto_cast GetInstanceProcAddr(instance, "vkCmdEndVideoCodingKHR") + CmdExecuteCommands = auto_cast GetInstanceProcAddr(instance, "vkCmdExecuteCommands") + CmdExecuteGeneratedCommandsNV = auto_cast GetInstanceProcAddr(instance, "vkCmdExecuteGeneratedCommandsNV") + CmdFillBuffer = auto_cast GetInstanceProcAddr(instance, "vkCmdFillBuffer") + CmdInsertDebugUtilsLabelEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdInsertDebugUtilsLabelEXT") + CmdNextSubpass = auto_cast GetInstanceProcAddr(instance, "vkCmdNextSubpass") + CmdNextSubpass2 = auto_cast GetInstanceProcAddr(instance, "vkCmdNextSubpass2") + CmdNextSubpass2KHR = auto_cast GetInstanceProcAddr(instance, "vkCmdNextSubpass2KHR") + CmdOpticalFlowExecuteNV = auto_cast GetInstanceProcAddr(instance, "vkCmdOpticalFlowExecuteNV") + CmdPipelineBarrier = auto_cast GetInstanceProcAddr(instance, "vkCmdPipelineBarrier") + CmdPipelineBarrier2 = auto_cast GetInstanceProcAddr(instance, "vkCmdPipelineBarrier2") + CmdPipelineBarrier2KHR = auto_cast GetInstanceProcAddr(instance, "vkCmdPipelineBarrier2KHR") + CmdPreprocessGeneratedCommandsNV = auto_cast GetInstanceProcAddr(instance, "vkCmdPreprocessGeneratedCommandsNV") + CmdPushConstants = auto_cast GetInstanceProcAddr(instance, "vkCmdPushConstants") + CmdPushDescriptorSetKHR = auto_cast GetInstanceProcAddr(instance, "vkCmdPushDescriptorSetKHR") + CmdPushDescriptorSetWithTemplateKHR = auto_cast GetInstanceProcAddr(instance, "vkCmdPushDescriptorSetWithTemplateKHR") + CmdResetEvent = auto_cast GetInstanceProcAddr(instance, "vkCmdResetEvent") + CmdResetEvent2 = auto_cast GetInstanceProcAddr(instance, "vkCmdResetEvent2") + CmdResetEvent2KHR = auto_cast GetInstanceProcAddr(instance, "vkCmdResetEvent2KHR") + CmdResetQueryPool = auto_cast GetInstanceProcAddr(instance, "vkCmdResetQueryPool") + CmdResolveImage = auto_cast GetInstanceProcAddr(instance, "vkCmdResolveImage") + CmdResolveImage2 = auto_cast GetInstanceProcAddr(instance, "vkCmdResolveImage2") + CmdResolveImage2KHR = auto_cast GetInstanceProcAddr(instance, "vkCmdResolveImage2KHR") + CmdSetAlphaToCoverageEnableEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetAlphaToCoverageEnableEXT") + CmdSetAlphaToOneEnableEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetAlphaToOneEnableEXT") + CmdSetAttachmentFeedbackLoopEnableEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetAttachmentFeedbackLoopEnableEXT") + CmdSetBlendConstants = auto_cast GetInstanceProcAddr(instance, "vkCmdSetBlendConstants") + CmdSetCheckpointNV = auto_cast GetInstanceProcAddr(instance, "vkCmdSetCheckpointNV") + CmdSetCoarseSampleOrderNV = auto_cast GetInstanceProcAddr(instance, "vkCmdSetCoarseSampleOrderNV") + CmdSetColorBlendAdvancedEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetColorBlendAdvancedEXT") + CmdSetColorBlendEnableEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetColorBlendEnableEXT") + CmdSetColorBlendEquationEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetColorBlendEquationEXT") + CmdSetColorWriteMaskEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetColorWriteMaskEXT") + CmdSetConservativeRasterizationModeEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetConservativeRasterizationModeEXT") + CmdSetCoverageModulationModeNV = auto_cast GetInstanceProcAddr(instance, "vkCmdSetCoverageModulationModeNV") + CmdSetCoverageModulationTableEnableNV = auto_cast GetInstanceProcAddr(instance, "vkCmdSetCoverageModulationTableEnableNV") + CmdSetCoverageModulationTableNV = auto_cast GetInstanceProcAddr(instance, "vkCmdSetCoverageModulationTableNV") + CmdSetCoverageReductionModeNV = auto_cast GetInstanceProcAddr(instance, "vkCmdSetCoverageReductionModeNV") + CmdSetCoverageToColorEnableNV = auto_cast GetInstanceProcAddr(instance, "vkCmdSetCoverageToColorEnableNV") + CmdSetCoverageToColorLocationNV = auto_cast GetInstanceProcAddr(instance, "vkCmdSetCoverageToColorLocationNV") + CmdSetCullMode = auto_cast GetInstanceProcAddr(instance, "vkCmdSetCullMode") + CmdSetCullModeEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetCullModeEXT") + CmdSetDepthBias = auto_cast GetInstanceProcAddr(instance, "vkCmdSetDepthBias") + CmdSetDepthBiasEnable = auto_cast GetInstanceProcAddr(instance, "vkCmdSetDepthBiasEnable") + CmdSetDepthBiasEnableEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetDepthBiasEnableEXT") + CmdSetDepthBounds = auto_cast GetInstanceProcAddr(instance, "vkCmdSetDepthBounds") + CmdSetDepthBoundsTestEnable = auto_cast GetInstanceProcAddr(instance, "vkCmdSetDepthBoundsTestEnable") + CmdSetDepthBoundsTestEnableEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetDepthBoundsTestEnableEXT") + CmdSetDepthClampEnableEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetDepthClampEnableEXT") + CmdSetDepthClipEnableEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetDepthClipEnableEXT") + CmdSetDepthClipNegativeOneToOneEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetDepthClipNegativeOneToOneEXT") + CmdSetDepthCompareOp = auto_cast GetInstanceProcAddr(instance, "vkCmdSetDepthCompareOp") + CmdSetDepthCompareOpEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetDepthCompareOpEXT") + CmdSetDepthTestEnable = auto_cast GetInstanceProcAddr(instance, "vkCmdSetDepthTestEnable") + CmdSetDepthTestEnableEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetDepthTestEnableEXT") + CmdSetDepthWriteEnable = auto_cast GetInstanceProcAddr(instance, "vkCmdSetDepthWriteEnable") + CmdSetDepthWriteEnableEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetDepthWriteEnableEXT") + CmdSetDescriptorBufferOffsetsEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetDescriptorBufferOffsetsEXT") + CmdSetDeviceMask = auto_cast GetInstanceProcAddr(instance, "vkCmdSetDeviceMask") + CmdSetDeviceMaskKHR = auto_cast GetInstanceProcAddr(instance, "vkCmdSetDeviceMaskKHR") + CmdSetDiscardRectangleEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetDiscardRectangleEXT") + CmdSetDiscardRectangleEnableEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetDiscardRectangleEnableEXT") + CmdSetDiscardRectangleModeEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetDiscardRectangleModeEXT") + CmdSetEvent = auto_cast GetInstanceProcAddr(instance, "vkCmdSetEvent") + CmdSetEvent2 = auto_cast GetInstanceProcAddr(instance, "vkCmdSetEvent2") + CmdSetEvent2KHR = auto_cast GetInstanceProcAddr(instance, "vkCmdSetEvent2KHR") + CmdSetExclusiveScissorEnableNV = auto_cast GetInstanceProcAddr(instance, "vkCmdSetExclusiveScissorEnableNV") + CmdSetExclusiveScissorNV = auto_cast GetInstanceProcAddr(instance, "vkCmdSetExclusiveScissorNV") + CmdSetExtraPrimitiveOverestimationSizeEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetExtraPrimitiveOverestimationSizeEXT") + CmdSetFragmentShadingRateEnumNV = auto_cast GetInstanceProcAddr(instance, "vkCmdSetFragmentShadingRateEnumNV") + CmdSetFragmentShadingRateKHR = auto_cast GetInstanceProcAddr(instance, "vkCmdSetFragmentShadingRateKHR") + CmdSetFrontFace = auto_cast GetInstanceProcAddr(instance, "vkCmdSetFrontFace") + CmdSetFrontFaceEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetFrontFaceEXT") + CmdSetLineRasterizationModeEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetLineRasterizationModeEXT") + CmdSetLineStippleEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetLineStippleEXT") + CmdSetLineStippleEnableEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetLineStippleEnableEXT") + CmdSetLineWidth = auto_cast GetInstanceProcAddr(instance, "vkCmdSetLineWidth") + CmdSetLogicOpEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetLogicOpEXT") + CmdSetLogicOpEnableEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetLogicOpEnableEXT") + CmdSetPatchControlPointsEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetPatchControlPointsEXT") + CmdSetPerformanceMarkerINTEL = auto_cast GetInstanceProcAddr(instance, "vkCmdSetPerformanceMarkerINTEL") + CmdSetPerformanceOverrideINTEL = auto_cast GetInstanceProcAddr(instance, "vkCmdSetPerformanceOverrideINTEL") + CmdSetPerformanceStreamMarkerINTEL = auto_cast GetInstanceProcAddr(instance, "vkCmdSetPerformanceStreamMarkerINTEL") + CmdSetPolygonModeEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetPolygonModeEXT") + CmdSetPrimitiveRestartEnable = auto_cast GetInstanceProcAddr(instance, "vkCmdSetPrimitiveRestartEnable") + CmdSetPrimitiveRestartEnableEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetPrimitiveRestartEnableEXT") + CmdSetPrimitiveTopology = auto_cast GetInstanceProcAddr(instance, "vkCmdSetPrimitiveTopology") + CmdSetPrimitiveTopologyEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetPrimitiveTopologyEXT") + CmdSetProvokingVertexModeEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetProvokingVertexModeEXT") + CmdSetRasterizationSamplesEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetRasterizationSamplesEXT") + CmdSetRasterizationStreamEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetRasterizationStreamEXT") + CmdSetRasterizerDiscardEnable = auto_cast GetInstanceProcAddr(instance, "vkCmdSetRasterizerDiscardEnable") + CmdSetRasterizerDiscardEnableEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetRasterizerDiscardEnableEXT") + CmdSetRayTracingPipelineStackSizeKHR = auto_cast GetInstanceProcAddr(instance, "vkCmdSetRayTracingPipelineStackSizeKHR") + CmdSetRepresentativeFragmentTestEnableNV = auto_cast GetInstanceProcAddr(instance, "vkCmdSetRepresentativeFragmentTestEnableNV") + CmdSetSampleLocationsEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetSampleLocationsEXT") + CmdSetSampleLocationsEnableEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetSampleLocationsEnableEXT") + CmdSetSampleMaskEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetSampleMaskEXT") + CmdSetScissor = auto_cast GetInstanceProcAddr(instance, "vkCmdSetScissor") + CmdSetScissorWithCount = auto_cast GetInstanceProcAddr(instance, "vkCmdSetScissorWithCount") + CmdSetScissorWithCountEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetScissorWithCountEXT") + CmdSetShadingRateImageEnableNV = auto_cast GetInstanceProcAddr(instance, "vkCmdSetShadingRateImageEnableNV") + CmdSetStencilCompareMask = auto_cast GetInstanceProcAddr(instance, "vkCmdSetStencilCompareMask") + CmdSetStencilOp = auto_cast GetInstanceProcAddr(instance, "vkCmdSetStencilOp") + CmdSetStencilOpEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetStencilOpEXT") + CmdSetStencilReference = auto_cast GetInstanceProcAddr(instance, "vkCmdSetStencilReference") + CmdSetStencilTestEnable = auto_cast GetInstanceProcAddr(instance, "vkCmdSetStencilTestEnable") + CmdSetStencilTestEnableEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetStencilTestEnableEXT") + CmdSetStencilWriteMask = auto_cast GetInstanceProcAddr(instance, "vkCmdSetStencilWriteMask") + CmdSetTessellationDomainOriginEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetTessellationDomainOriginEXT") + CmdSetVertexInputEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetVertexInputEXT") + CmdSetViewport = auto_cast GetInstanceProcAddr(instance, "vkCmdSetViewport") + CmdSetViewportShadingRatePaletteNV = auto_cast GetInstanceProcAddr(instance, "vkCmdSetViewportShadingRatePaletteNV") + CmdSetViewportSwizzleNV = auto_cast GetInstanceProcAddr(instance, "vkCmdSetViewportSwizzleNV") + CmdSetViewportWScalingEnableNV = auto_cast GetInstanceProcAddr(instance, "vkCmdSetViewportWScalingEnableNV") + CmdSetViewportWScalingNV = auto_cast GetInstanceProcAddr(instance, "vkCmdSetViewportWScalingNV") + CmdSetViewportWithCount = auto_cast GetInstanceProcAddr(instance, "vkCmdSetViewportWithCount") + CmdSetViewportWithCountEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdSetViewportWithCountEXT") + CmdSubpassShadingHUAWEI = auto_cast GetInstanceProcAddr(instance, "vkCmdSubpassShadingHUAWEI") + CmdTraceRaysIndirect2KHR = auto_cast GetInstanceProcAddr(instance, "vkCmdTraceRaysIndirect2KHR") + CmdTraceRaysIndirectKHR = auto_cast GetInstanceProcAddr(instance, "vkCmdTraceRaysIndirectKHR") + CmdTraceRaysKHR = auto_cast GetInstanceProcAddr(instance, "vkCmdTraceRaysKHR") + CmdTraceRaysNV = auto_cast GetInstanceProcAddr(instance, "vkCmdTraceRaysNV") + CmdUpdateBuffer = auto_cast GetInstanceProcAddr(instance, "vkCmdUpdateBuffer") + CmdWaitEvents = auto_cast GetInstanceProcAddr(instance, "vkCmdWaitEvents") + CmdWaitEvents2 = auto_cast GetInstanceProcAddr(instance, "vkCmdWaitEvents2") + CmdWaitEvents2KHR = auto_cast GetInstanceProcAddr(instance, "vkCmdWaitEvents2KHR") + CmdWriteAccelerationStructuresPropertiesKHR = auto_cast GetInstanceProcAddr(instance, "vkCmdWriteAccelerationStructuresPropertiesKHR") + CmdWriteAccelerationStructuresPropertiesNV = auto_cast GetInstanceProcAddr(instance, "vkCmdWriteAccelerationStructuresPropertiesNV") + CmdWriteBufferMarker2AMD = auto_cast GetInstanceProcAddr(instance, "vkCmdWriteBufferMarker2AMD") + CmdWriteBufferMarkerAMD = auto_cast GetInstanceProcAddr(instance, "vkCmdWriteBufferMarkerAMD") + CmdWriteMicromapsPropertiesEXT = auto_cast GetInstanceProcAddr(instance, "vkCmdWriteMicromapsPropertiesEXT") + CmdWriteTimestamp = auto_cast GetInstanceProcAddr(instance, "vkCmdWriteTimestamp") + CmdWriteTimestamp2 = auto_cast GetInstanceProcAddr(instance, "vkCmdWriteTimestamp2") + CmdWriteTimestamp2KHR = auto_cast GetInstanceProcAddr(instance, "vkCmdWriteTimestamp2KHR") + CompileDeferredNV = auto_cast GetInstanceProcAddr(instance, "vkCompileDeferredNV") + CopyAccelerationStructureKHR = auto_cast GetInstanceProcAddr(instance, "vkCopyAccelerationStructureKHR") + CopyAccelerationStructureToMemoryKHR = auto_cast GetInstanceProcAddr(instance, "vkCopyAccelerationStructureToMemoryKHR") + CopyMemoryToAccelerationStructureKHR = auto_cast GetInstanceProcAddr(instance, "vkCopyMemoryToAccelerationStructureKHR") + CopyMemoryToMicromapEXT = auto_cast GetInstanceProcAddr(instance, "vkCopyMemoryToMicromapEXT") + CopyMicromapEXT = auto_cast GetInstanceProcAddr(instance, "vkCopyMicromapEXT") + CopyMicromapToMemoryEXT = auto_cast GetInstanceProcAddr(instance, "vkCopyMicromapToMemoryEXT") + CreateAccelerationStructureKHR = auto_cast GetInstanceProcAddr(instance, "vkCreateAccelerationStructureKHR") + CreateAccelerationStructureNV = auto_cast GetInstanceProcAddr(instance, "vkCreateAccelerationStructureNV") + CreateBuffer = auto_cast GetInstanceProcAddr(instance, "vkCreateBuffer") + CreateBufferView = auto_cast GetInstanceProcAddr(instance, "vkCreateBufferView") + CreateCommandPool = auto_cast GetInstanceProcAddr(instance, "vkCreateCommandPool") + CreateComputePipelines = auto_cast GetInstanceProcAddr(instance, "vkCreateComputePipelines") + CreateCuFunctionNVX = auto_cast GetInstanceProcAddr(instance, "vkCreateCuFunctionNVX") + CreateCuModuleNVX = auto_cast GetInstanceProcAddr(instance, "vkCreateCuModuleNVX") + CreateDeferredOperationKHR = auto_cast GetInstanceProcAddr(instance, "vkCreateDeferredOperationKHR") + CreateDescriptorPool = auto_cast GetInstanceProcAddr(instance, "vkCreateDescriptorPool") + CreateDescriptorSetLayout = auto_cast GetInstanceProcAddr(instance, "vkCreateDescriptorSetLayout") + CreateDescriptorUpdateTemplate = auto_cast GetInstanceProcAddr(instance, "vkCreateDescriptorUpdateTemplate") + CreateDescriptorUpdateTemplateKHR = auto_cast GetInstanceProcAddr(instance, "vkCreateDescriptorUpdateTemplateKHR") + CreateEvent = auto_cast GetInstanceProcAddr(instance, "vkCreateEvent") + CreateFence = auto_cast GetInstanceProcAddr(instance, "vkCreateFence") + CreateFramebuffer = auto_cast GetInstanceProcAddr(instance, "vkCreateFramebuffer") + CreateGraphicsPipelines = auto_cast GetInstanceProcAddr(instance, "vkCreateGraphicsPipelines") + CreateImage = auto_cast GetInstanceProcAddr(instance, "vkCreateImage") + CreateImageView = auto_cast GetInstanceProcAddr(instance, "vkCreateImageView") + CreateIndirectCommandsLayoutNV = auto_cast GetInstanceProcAddr(instance, "vkCreateIndirectCommandsLayoutNV") + CreateMicromapEXT = auto_cast GetInstanceProcAddr(instance, "vkCreateMicromapEXT") + CreateOpticalFlowSessionNV = auto_cast GetInstanceProcAddr(instance, "vkCreateOpticalFlowSessionNV") + CreatePipelineCache = auto_cast GetInstanceProcAddr(instance, "vkCreatePipelineCache") + CreatePipelineLayout = auto_cast GetInstanceProcAddr(instance, "vkCreatePipelineLayout") + CreatePrivateDataSlot = auto_cast GetInstanceProcAddr(instance, "vkCreatePrivateDataSlot") + CreatePrivateDataSlotEXT = auto_cast GetInstanceProcAddr(instance, "vkCreatePrivateDataSlotEXT") + CreateQueryPool = auto_cast GetInstanceProcAddr(instance, "vkCreateQueryPool") + CreateRayTracingPipelinesKHR = auto_cast GetInstanceProcAddr(instance, "vkCreateRayTracingPipelinesKHR") + CreateRayTracingPipelinesNV = auto_cast GetInstanceProcAddr(instance, "vkCreateRayTracingPipelinesNV") + CreateRenderPass = auto_cast GetInstanceProcAddr(instance, "vkCreateRenderPass") + CreateRenderPass2 = auto_cast GetInstanceProcAddr(instance, "vkCreateRenderPass2") + CreateRenderPass2KHR = auto_cast GetInstanceProcAddr(instance, "vkCreateRenderPass2KHR") + CreateSampler = auto_cast GetInstanceProcAddr(instance, "vkCreateSampler") + CreateSamplerYcbcrConversion = auto_cast GetInstanceProcAddr(instance, "vkCreateSamplerYcbcrConversion") + CreateSamplerYcbcrConversionKHR = auto_cast GetInstanceProcAddr(instance, "vkCreateSamplerYcbcrConversionKHR") + CreateSemaphore = auto_cast GetInstanceProcAddr(instance, "vkCreateSemaphore") + CreateShaderModule = auto_cast GetInstanceProcAddr(instance, "vkCreateShaderModule") + CreateShadersEXT = auto_cast GetInstanceProcAddr(instance, "vkCreateShadersEXT") + CreateSharedSwapchainsKHR = auto_cast GetInstanceProcAddr(instance, "vkCreateSharedSwapchainsKHR") + CreateSwapchainKHR = auto_cast GetInstanceProcAddr(instance, "vkCreateSwapchainKHR") + CreateValidationCacheEXT = auto_cast GetInstanceProcAddr(instance, "vkCreateValidationCacheEXT") + CreateVideoSessionKHR = auto_cast GetInstanceProcAddr(instance, "vkCreateVideoSessionKHR") + CreateVideoSessionParametersKHR = auto_cast GetInstanceProcAddr(instance, "vkCreateVideoSessionParametersKHR") + DebugMarkerSetObjectNameEXT = auto_cast GetInstanceProcAddr(instance, "vkDebugMarkerSetObjectNameEXT") + DebugMarkerSetObjectTagEXT = auto_cast GetInstanceProcAddr(instance, "vkDebugMarkerSetObjectTagEXT") + DeferredOperationJoinKHR = auto_cast GetInstanceProcAddr(instance, "vkDeferredOperationJoinKHR") + DestroyAccelerationStructureKHR = auto_cast GetInstanceProcAddr(instance, "vkDestroyAccelerationStructureKHR") + DestroyAccelerationStructureNV = auto_cast GetInstanceProcAddr(instance, "vkDestroyAccelerationStructureNV") + DestroyBuffer = auto_cast GetInstanceProcAddr(instance, "vkDestroyBuffer") + DestroyBufferView = auto_cast GetInstanceProcAddr(instance, "vkDestroyBufferView") + DestroyCommandPool = auto_cast GetInstanceProcAddr(instance, "vkDestroyCommandPool") + DestroyCuFunctionNVX = auto_cast GetInstanceProcAddr(instance, "vkDestroyCuFunctionNVX") + DestroyCuModuleNVX = auto_cast GetInstanceProcAddr(instance, "vkDestroyCuModuleNVX") + DestroyDeferredOperationKHR = auto_cast GetInstanceProcAddr(instance, "vkDestroyDeferredOperationKHR") + DestroyDescriptorPool = auto_cast GetInstanceProcAddr(instance, "vkDestroyDescriptorPool") + DestroyDescriptorSetLayout = auto_cast GetInstanceProcAddr(instance, "vkDestroyDescriptorSetLayout") + DestroyDescriptorUpdateTemplate = auto_cast GetInstanceProcAddr(instance, "vkDestroyDescriptorUpdateTemplate") + DestroyDescriptorUpdateTemplateKHR = auto_cast GetInstanceProcAddr(instance, "vkDestroyDescriptorUpdateTemplateKHR") + DestroyDevice = auto_cast GetInstanceProcAddr(instance, "vkDestroyDevice") + DestroyEvent = auto_cast GetInstanceProcAddr(instance, "vkDestroyEvent") + DestroyFence = auto_cast GetInstanceProcAddr(instance, "vkDestroyFence") + DestroyFramebuffer = auto_cast GetInstanceProcAddr(instance, "vkDestroyFramebuffer") + DestroyImage = auto_cast GetInstanceProcAddr(instance, "vkDestroyImage") + DestroyImageView = auto_cast GetInstanceProcAddr(instance, "vkDestroyImageView") + DestroyIndirectCommandsLayoutNV = auto_cast GetInstanceProcAddr(instance, "vkDestroyIndirectCommandsLayoutNV") + DestroyMicromapEXT = auto_cast GetInstanceProcAddr(instance, "vkDestroyMicromapEXT") + DestroyOpticalFlowSessionNV = auto_cast GetInstanceProcAddr(instance, "vkDestroyOpticalFlowSessionNV") + DestroyPipeline = auto_cast GetInstanceProcAddr(instance, "vkDestroyPipeline") + DestroyPipelineCache = auto_cast GetInstanceProcAddr(instance, "vkDestroyPipelineCache") + DestroyPipelineLayout = auto_cast GetInstanceProcAddr(instance, "vkDestroyPipelineLayout") + DestroyPrivateDataSlot = auto_cast GetInstanceProcAddr(instance, "vkDestroyPrivateDataSlot") + DestroyPrivateDataSlotEXT = auto_cast GetInstanceProcAddr(instance, "vkDestroyPrivateDataSlotEXT") + DestroyQueryPool = auto_cast GetInstanceProcAddr(instance, "vkDestroyQueryPool") + DestroyRenderPass = auto_cast GetInstanceProcAddr(instance, "vkDestroyRenderPass") + DestroySampler = auto_cast GetInstanceProcAddr(instance, "vkDestroySampler") + DestroySamplerYcbcrConversion = auto_cast GetInstanceProcAddr(instance, "vkDestroySamplerYcbcrConversion") + DestroySamplerYcbcrConversionKHR = auto_cast GetInstanceProcAddr(instance, "vkDestroySamplerYcbcrConversionKHR") + DestroySemaphore = auto_cast GetInstanceProcAddr(instance, "vkDestroySemaphore") + DestroyShaderEXT = auto_cast GetInstanceProcAddr(instance, "vkDestroyShaderEXT") + DestroyShaderModule = auto_cast GetInstanceProcAddr(instance, "vkDestroyShaderModule") + DestroySwapchainKHR = auto_cast GetInstanceProcAddr(instance, "vkDestroySwapchainKHR") + DestroyValidationCacheEXT = auto_cast GetInstanceProcAddr(instance, "vkDestroyValidationCacheEXT") + DestroyVideoSessionKHR = auto_cast GetInstanceProcAddr(instance, "vkDestroyVideoSessionKHR") + DestroyVideoSessionParametersKHR = auto_cast GetInstanceProcAddr(instance, "vkDestroyVideoSessionParametersKHR") + DeviceWaitIdle = auto_cast GetInstanceProcAddr(instance, "vkDeviceWaitIdle") + DisplayPowerControlEXT = auto_cast GetInstanceProcAddr(instance, "vkDisplayPowerControlEXT") + EndCommandBuffer = auto_cast GetInstanceProcAddr(instance, "vkEndCommandBuffer") + ExportMetalObjectsEXT = auto_cast GetInstanceProcAddr(instance, "vkExportMetalObjectsEXT") + FlushMappedMemoryRanges = auto_cast GetInstanceProcAddr(instance, "vkFlushMappedMemoryRanges") + FreeCommandBuffers = auto_cast GetInstanceProcAddr(instance, "vkFreeCommandBuffers") + FreeDescriptorSets = auto_cast GetInstanceProcAddr(instance, "vkFreeDescriptorSets") + FreeMemory = auto_cast GetInstanceProcAddr(instance, "vkFreeMemory") + GetAccelerationStructureBuildSizesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetAccelerationStructureBuildSizesKHR") + GetAccelerationStructureDeviceAddressKHR = auto_cast GetInstanceProcAddr(instance, "vkGetAccelerationStructureDeviceAddressKHR") + GetAccelerationStructureHandleNV = auto_cast GetInstanceProcAddr(instance, "vkGetAccelerationStructureHandleNV") + GetAccelerationStructureMemoryRequirementsNV = auto_cast GetInstanceProcAddr(instance, "vkGetAccelerationStructureMemoryRequirementsNV") + GetAccelerationStructureOpaqueCaptureDescriptorDataEXT = auto_cast GetInstanceProcAddr(instance, "vkGetAccelerationStructureOpaqueCaptureDescriptorDataEXT") + GetBufferDeviceAddress = auto_cast GetInstanceProcAddr(instance, "vkGetBufferDeviceAddress") + GetBufferDeviceAddressEXT = auto_cast GetInstanceProcAddr(instance, "vkGetBufferDeviceAddressEXT") + GetBufferDeviceAddressKHR = auto_cast GetInstanceProcAddr(instance, "vkGetBufferDeviceAddressKHR") + GetBufferMemoryRequirements = auto_cast GetInstanceProcAddr(instance, "vkGetBufferMemoryRequirements") + GetBufferMemoryRequirements2 = auto_cast GetInstanceProcAddr(instance, "vkGetBufferMemoryRequirements2") + GetBufferMemoryRequirements2KHR = auto_cast GetInstanceProcAddr(instance, "vkGetBufferMemoryRequirements2KHR") + GetBufferOpaqueCaptureAddress = auto_cast GetInstanceProcAddr(instance, "vkGetBufferOpaqueCaptureAddress") + GetBufferOpaqueCaptureAddressKHR = auto_cast GetInstanceProcAddr(instance, "vkGetBufferOpaqueCaptureAddressKHR") + GetBufferOpaqueCaptureDescriptorDataEXT = auto_cast GetInstanceProcAddr(instance, "vkGetBufferOpaqueCaptureDescriptorDataEXT") + GetCalibratedTimestampsEXT = auto_cast GetInstanceProcAddr(instance, "vkGetCalibratedTimestampsEXT") + GetDeferredOperationMaxConcurrencyKHR = auto_cast GetInstanceProcAddr(instance, "vkGetDeferredOperationMaxConcurrencyKHR") + GetDeferredOperationResultKHR = auto_cast GetInstanceProcAddr(instance, "vkGetDeferredOperationResultKHR") + GetDescriptorEXT = auto_cast GetInstanceProcAddr(instance, "vkGetDescriptorEXT") + GetDescriptorSetHostMappingVALVE = auto_cast GetInstanceProcAddr(instance, "vkGetDescriptorSetHostMappingVALVE") + GetDescriptorSetLayoutBindingOffsetEXT = auto_cast GetInstanceProcAddr(instance, "vkGetDescriptorSetLayoutBindingOffsetEXT") + GetDescriptorSetLayoutHostMappingInfoVALVE = auto_cast GetInstanceProcAddr(instance, "vkGetDescriptorSetLayoutHostMappingInfoVALVE") + GetDescriptorSetLayoutSizeEXT = auto_cast GetInstanceProcAddr(instance, "vkGetDescriptorSetLayoutSizeEXT") + GetDescriptorSetLayoutSupport = auto_cast GetInstanceProcAddr(instance, "vkGetDescriptorSetLayoutSupport") + GetDescriptorSetLayoutSupportKHR = auto_cast GetInstanceProcAddr(instance, "vkGetDescriptorSetLayoutSupportKHR") + GetDeviceAccelerationStructureCompatibilityKHR = auto_cast GetInstanceProcAddr(instance, "vkGetDeviceAccelerationStructureCompatibilityKHR") + GetDeviceBufferMemoryRequirements = auto_cast GetInstanceProcAddr(instance, "vkGetDeviceBufferMemoryRequirements") + GetDeviceBufferMemoryRequirementsKHR = auto_cast GetInstanceProcAddr(instance, "vkGetDeviceBufferMemoryRequirementsKHR") + GetDeviceFaultInfoEXT = auto_cast GetInstanceProcAddr(instance, "vkGetDeviceFaultInfoEXT") + GetDeviceGroupPeerMemoryFeatures = auto_cast GetInstanceProcAddr(instance, "vkGetDeviceGroupPeerMemoryFeatures") + GetDeviceGroupPeerMemoryFeaturesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetDeviceGroupPeerMemoryFeaturesKHR") + GetDeviceGroupPresentCapabilitiesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetDeviceGroupPresentCapabilitiesKHR") + GetDeviceGroupSurfacePresentModes2EXT = auto_cast GetInstanceProcAddr(instance, "vkGetDeviceGroupSurfacePresentModes2EXT") + GetDeviceGroupSurfacePresentModesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetDeviceGroupSurfacePresentModesKHR") + GetDeviceImageMemoryRequirements = auto_cast GetInstanceProcAddr(instance, "vkGetDeviceImageMemoryRequirements") + GetDeviceImageMemoryRequirementsKHR = auto_cast GetInstanceProcAddr(instance, "vkGetDeviceImageMemoryRequirementsKHR") + GetDeviceImageSparseMemoryRequirements = auto_cast GetInstanceProcAddr(instance, "vkGetDeviceImageSparseMemoryRequirements") + GetDeviceImageSparseMemoryRequirementsKHR = auto_cast GetInstanceProcAddr(instance, "vkGetDeviceImageSparseMemoryRequirementsKHR") + GetDeviceMemoryCommitment = auto_cast GetInstanceProcAddr(instance, "vkGetDeviceMemoryCommitment") + GetDeviceMemoryOpaqueCaptureAddress = auto_cast GetInstanceProcAddr(instance, "vkGetDeviceMemoryOpaqueCaptureAddress") + GetDeviceMemoryOpaqueCaptureAddressKHR = auto_cast GetInstanceProcAddr(instance, "vkGetDeviceMemoryOpaqueCaptureAddressKHR") + GetDeviceMicromapCompatibilityEXT = auto_cast GetInstanceProcAddr(instance, "vkGetDeviceMicromapCompatibilityEXT") + GetDeviceProcAddr = auto_cast GetInstanceProcAddr(instance, "vkGetDeviceProcAddr") + GetDeviceQueue = auto_cast GetInstanceProcAddr(instance, "vkGetDeviceQueue") + GetDeviceQueue2 = auto_cast GetInstanceProcAddr(instance, "vkGetDeviceQueue2") + GetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI = auto_cast GetInstanceProcAddr(instance, "vkGetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI") + GetDynamicRenderingTilePropertiesQCOM = auto_cast GetInstanceProcAddr(instance, "vkGetDynamicRenderingTilePropertiesQCOM") + GetEventStatus = auto_cast GetInstanceProcAddr(instance, "vkGetEventStatus") + GetFenceFdKHR = auto_cast GetInstanceProcAddr(instance, "vkGetFenceFdKHR") + GetFenceStatus = auto_cast GetInstanceProcAddr(instance, "vkGetFenceStatus") + GetFenceWin32HandleKHR = auto_cast GetInstanceProcAddr(instance, "vkGetFenceWin32HandleKHR") + GetFramebufferTilePropertiesQCOM = auto_cast GetInstanceProcAddr(instance, "vkGetFramebufferTilePropertiesQCOM") + GetGeneratedCommandsMemoryRequirementsNV = auto_cast GetInstanceProcAddr(instance, "vkGetGeneratedCommandsMemoryRequirementsNV") + GetImageDrmFormatModifierPropertiesEXT = auto_cast GetInstanceProcAddr(instance, "vkGetImageDrmFormatModifierPropertiesEXT") + GetImageMemoryRequirements = auto_cast GetInstanceProcAddr(instance, "vkGetImageMemoryRequirements") + GetImageMemoryRequirements2 = auto_cast GetInstanceProcAddr(instance, "vkGetImageMemoryRequirements2") + GetImageMemoryRequirements2KHR = auto_cast GetInstanceProcAddr(instance, "vkGetImageMemoryRequirements2KHR") + GetImageOpaqueCaptureDescriptorDataEXT = auto_cast GetInstanceProcAddr(instance, "vkGetImageOpaqueCaptureDescriptorDataEXT") + GetImageSparseMemoryRequirements = auto_cast GetInstanceProcAddr(instance, "vkGetImageSparseMemoryRequirements") + GetImageSparseMemoryRequirements2 = auto_cast GetInstanceProcAddr(instance, "vkGetImageSparseMemoryRequirements2") + GetImageSparseMemoryRequirements2KHR = auto_cast GetInstanceProcAddr(instance, "vkGetImageSparseMemoryRequirements2KHR") + GetImageSubresourceLayout = auto_cast GetInstanceProcAddr(instance, "vkGetImageSubresourceLayout") + GetImageSubresourceLayout2EXT = auto_cast GetInstanceProcAddr(instance, "vkGetImageSubresourceLayout2EXT") + GetImageViewAddressNVX = auto_cast GetInstanceProcAddr(instance, "vkGetImageViewAddressNVX") + GetImageViewHandleNVX = auto_cast GetInstanceProcAddr(instance, "vkGetImageViewHandleNVX") + GetImageViewOpaqueCaptureDescriptorDataEXT = auto_cast GetInstanceProcAddr(instance, "vkGetImageViewOpaqueCaptureDescriptorDataEXT") + GetMemoryFdKHR = auto_cast GetInstanceProcAddr(instance, "vkGetMemoryFdKHR") + GetMemoryFdPropertiesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetMemoryFdPropertiesKHR") + GetMemoryHostPointerPropertiesEXT = auto_cast GetInstanceProcAddr(instance, "vkGetMemoryHostPointerPropertiesEXT") + GetMemoryRemoteAddressNV = auto_cast GetInstanceProcAddr(instance, "vkGetMemoryRemoteAddressNV") + GetMemoryWin32HandleKHR = auto_cast GetInstanceProcAddr(instance, "vkGetMemoryWin32HandleKHR") + GetMemoryWin32HandleNV = auto_cast GetInstanceProcAddr(instance, "vkGetMemoryWin32HandleNV") + GetMemoryWin32HandlePropertiesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetMemoryWin32HandlePropertiesKHR") + GetMicromapBuildSizesEXT = auto_cast GetInstanceProcAddr(instance, "vkGetMicromapBuildSizesEXT") + GetPastPresentationTimingGOOGLE = auto_cast GetInstanceProcAddr(instance, "vkGetPastPresentationTimingGOOGLE") + GetPerformanceParameterINTEL = auto_cast GetInstanceProcAddr(instance, "vkGetPerformanceParameterINTEL") + GetPipelineCacheData = auto_cast GetInstanceProcAddr(instance, "vkGetPipelineCacheData") + GetPipelineExecutableInternalRepresentationsKHR = auto_cast GetInstanceProcAddr(instance, "vkGetPipelineExecutableInternalRepresentationsKHR") + GetPipelineExecutablePropertiesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetPipelineExecutablePropertiesKHR") + GetPipelineExecutableStatisticsKHR = auto_cast GetInstanceProcAddr(instance, "vkGetPipelineExecutableStatisticsKHR") + GetPipelinePropertiesEXT = auto_cast GetInstanceProcAddr(instance, "vkGetPipelinePropertiesEXT") + GetPrivateData = auto_cast GetInstanceProcAddr(instance, "vkGetPrivateData") + GetPrivateDataEXT = auto_cast GetInstanceProcAddr(instance, "vkGetPrivateDataEXT") + GetQueryPoolResults = auto_cast GetInstanceProcAddr(instance, "vkGetQueryPoolResults") + GetQueueCheckpointData2NV = auto_cast GetInstanceProcAddr(instance, "vkGetQueueCheckpointData2NV") + GetQueueCheckpointDataNV = auto_cast GetInstanceProcAddr(instance, "vkGetQueueCheckpointDataNV") + GetRayTracingCaptureReplayShaderGroupHandlesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR") + GetRayTracingShaderGroupHandlesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetRayTracingShaderGroupHandlesKHR") + GetRayTracingShaderGroupHandlesNV = auto_cast GetInstanceProcAddr(instance, "vkGetRayTracingShaderGroupHandlesNV") + GetRayTracingShaderGroupStackSizeKHR = auto_cast GetInstanceProcAddr(instance, "vkGetRayTracingShaderGroupStackSizeKHR") + GetRefreshCycleDurationGOOGLE = auto_cast GetInstanceProcAddr(instance, "vkGetRefreshCycleDurationGOOGLE") + GetRenderAreaGranularity = auto_cast GetInstanceProcAddr(instance, "vkGetRenderAreaGranularity") + GetSamplerOpaqueCaptureDescriptorDataEXT = auto_cast GetInstanceProcAddr(instance, "vkGetSamplerOpaqueCaptureDescriptorDataEXT") + GetSemaphoreCounterValue = auto_cast GetInstanceProcAddr(instance, "vkGetSemaphoreCounterValue") + GetSemaphoreCounterValueKHR = auto_cast GetInstanceProcAddr(instance, "vkGetSemaphoreCounterValueKHR") + GetSemaphoreFdKHR = auto_cast GetInstanceProcAddr(instance, "vkGetSemaphoreFdKHR") + GetSemaphoreWin32HandleKHR = auto_cast GetInstanceProcAddr(instance, "vkGetSemaphoreWin32HandleKHR") + GetShaderBinaryDataEXT = auto_cast GetInstanceProcAddr(instance, "vkGetShaderBinaryDataEXT") + GetShaderInfoAMD = auto_cast GetInstanceProcAddr(instance, "vkGetShaderInfoAMD") + GetShaderModuleCreateInfoIdentifierEXT = auto_cast GetInstanceProcAddr(instance, "vkGetShaderModuleCreateInfoIdentifierEXT") + GetShaderModuleIdentifierEXT = auto_cast GetInstanceProcAddr(instance, "vkGetShaderModuleIdentifierEXT") + GetSwapchainCounterEXT = auto_cast GetInstanceProcAddr(instance, "vkGetSwapchainCounterEXT") + GetSwapchainImagesKHR = auto_cast GetInstanceProcAddr(instance, "vkGetSwapchainImagesKHR") + GetSwapchainStatusKHR = auto_cast GetInstanceProcAddr(instance, "vkGetSwapchainStatusKHR") + GetValidationCacheDataEXT = auto_cast GetInstanceProcAddr(instance, "vkGetValidationCacheDataEXT") + GetVideoSessionMemoryRequirementsKHR = auto_cast GetInstanceProcAddr(instance, "vkGetVideoSessionMemoryRequirementsKHR") + ImportFenceFdKHR = auto_cast GetInstanceProcAddr(instance, "vkImportFenceFdKHR") + ImportFenceWin32HandleKHR = auto_cast GetInstanceProcAddr(instance, "vkImportFenceWin32HandleKHR") + ImportSemaphoreFdKHR = auto_cast GetInstanceProcAddr(instance, "vkImportSemaphoreFdKHR") + ImportSemaphoreWin32HandleKHR = auto_cast GetInstanceProcAddr(instance, "vkImportSemaphoreWin32HandleKHR") + InitializePerformanceApiINTEL = auto_cast GetInstanceProcAddr(instance, "vkInitializePerformanceApiINTEL") + InvalidateMappedMemoryRanges = auto_cast GetInstanceProcAddr(instance, "vkInvalidateMappedMemoryRanges") + MapMemory = auto_cast GetInstanceProcAddr(instance, "vkMapMemory") + MapMemory2KHR = auto_cast GetInstanceProcAddr(instance, "vkMapMemory2KHR") + MergePipelineCaches = auto_cast GetInstanceProcAddr(instance, "vkMergePipelineCaches") + MergeValidationCachesEXT = auto_cast GetInstanceProcAddr(instance, "vkMergeValidationCachesEXT") + QueueBeginDebugUtilsLabelEXT = auto_cast GetInstanceProcAddr(instance, "vkQueueBeginDebugUtilsLabelEXT") + QueueBindSparse = auto_cast GetInstanceProcAddr(instance, "vkQueueBindSparse") + QueueEndDebugUtilsLabelEXT = auto_cast GetInstanceProcAddr(instance, "vkQueueEndDebugUtilsLabelEXT") + QueueInsertDebugUtilsLabelEXT = auto_cast GetInstanceProcAddr(instance, "vkQueueInsertDebugUtilsLabelEXT") + QueuePresentKHR = auto_cast GetInstanceProcAddr(instance, "vkQueuePresentKHR") + QueueSetPerformanceConfigurationINTEL = auto_cast GetInstanceProcAddr(instance, "vkQueueSetPerformanceConfigurationINTEL") + QueueSubmit = auto_cast GetInstanceProcAddr(instance, "vkQueueSubmit") + QueueSubmit2 = auto_cast GetInstanceProcAddr(instance, "vkQueueSubmit2") + QueueSubmit2KHR = auto_cast GetInstanceProcAddr(instance, "vkQueueSubmit2KHR") + QueueWaitIdle = auto_cast GetInstanceProcAddr(instance, "vkQueueWaitIdle") + RegisterDeviceEventEXT = auto_cast GetInstanceProcAddr(instance, "vkRegisterDeviceEventEXT") + RegisterDisplayEventEXT = auto_cast GetInstanceProcAddr(instance, "vkRegisterDisplayEventEXT") + ReleaseFullScreenExclusiveModeEXT = auto_cast GetInstanceProcAddr(instance, "vkReleaseFullScreenExclusiveModeEXT") + ReleasePerformanceConfigurationINTEL = auto_cast GetInstanceProcAddr(instance, "vkReleasePerformanceConfigurationINTEL") + ReleaseProfilingLockKHR = auto_cast GetInstanceProcAddr(instance, "vkReleaseProfilingLockKHR") + ReleaseSwapchainImagesEXT = auto_cast GetInstanceProcAddr(instance, "vkReleaseSwapchainImagesEXT") + ResetCommandBuffer = auto_cast GetInstanceProcAddr(instance, "vkResetCommandBuffer") + ResetCommandPool = auto_cast GetInstanceProcAddr(instance, "vkResetCommandPool") + ResetDescriptorPool = auto_cast GetInstanceProcAddr(instance, "vkResetDescriptorPool") + ResetEvent = auto_cast GetInstanceProcAddr(instance, "vkResetEvent") + ResetFences = auto_cast GetInstanceProcAddr(instance, "vkResetFences") + ResetQueryPool = auto_cast GetInstanceProcAddr(instance, "vkResetQueryPool") + ResetQueryPoolEXT = auto_cast GetInstanceProcAddr(instance, "vkResetQueryPoolEXT") + SetDebugUtilsObjectNameEXT = auto_cast GetInstanceProcAddr(instance, "vkSetDebugUtilsObjectNameEXT") + SetDebugUtilsObjectTagEXT = auto_cast GetInstanceProcAddr(instance, "vkSetDebugUtilsObjectTagEXT") + SetDeviceMemoryPriorityEXT = auto_cast GetInstanceProcAddr(instance, "vkSetDeviceMemoryPriorityEXT") + SetEvent = auto_cast GetInstanceProcAddr(instance, "vkSetEvent") + SetHdrMetadataEXT = auto_cast GetInstanceProcAddr(instance, "vkSetHdrMetadataEXT") + SetLocalDimmingAMD = auto_cast GetInstanceProcAddr(instance, "vkSetLocalDimmingAMD") + SetPrivateData = auto_cast GetInstanceProcAddr(instance, "vkSetPrivateData") + SetPrivateDataEXT = auto_cast GetInstanceProcAddr(instance, "vkSetPrivateDataEXT") + SignalSemaphore = auto_cast GetInstanceProcAddr(instance, "vkSignalSemaphore") + SignalSemaphoreKHR = auto_cast GetInstanceProcAddr(instance, "vkSignalSemaphoreKHR") + TrimCommandPool = auto_cast GetInstanceProcAddr(instance, "vkTrimCommandPool") + TrimCommandPoolKHR = auto_cast GetInstanceProcAddr(instance, "vkTrimCommandPoolKHR") + UninitializePerformanceApiINTEL = auto_cast GetInstanceProcAddr(instance, "vkUninitializePerformanceApiINTEL") + UnmapMemory = auto_cast GetInstanceProcAddr(instance, "vkUnmapMemory") + UnmapMemory2KHR = auto_cast GetInstanceProcAddr(instance, "vkUnmapMemory2KHR") + UpdateDescriptorSetWithTemplate = auto_cast GetInstanceProcAddr(instance, "vkUpdateDescriptorSetWithTemplate") + UpdateDescriptorSetWithTemplateKHR = auto_cast GetInstanceProcAddr(instance, "vkUpdateDescriptorSetWithTemplateKHR") + UpdateDescriptorSets = auto_cast GetInstanceProcAddr(instance, "vkUpdateDescriptorSets") + UpdateVideoSessionParametersKHR = auto_cast GetInstanceProcAddr(instance, "vkUpdateVideoSessionParametersKHR") + WaitForFences = auto_cast GetInstanceProcAddr(instance, "vkWaitForFences") + WaitForPresentKHR = auto_cast GetInstanceProcAddr(instance, "vkWaitForPresentKHR") + WaitSemaphores = auto_cast GetInstanceProcAddr(instance, "vkWaitSemaphores") + WaitSemaphoresKHR = auto_cast GetInstanceProcAddr(instance, "vkWaitSemaphoresKHR") + WriteAccelerationStructuresPropertiesKHR = auto_cast GetInstanceProcAddr(instance, "vkWriteAccelerationStructuresPropertiesKHR") + WriteMicromapsPropertiesEXT = auto_cast GetInstanceProcAddr(instance, "vkWriteMicromapsPropertiesEXT") +} + +load_proc_addresses_global :: proc(vk_get_instance_proc_addr: rawptr) { + GetInstanceProcAddr = auto_cast vk_get_instance_proc_addr + + CreateInstance = auto_cast GetInstanceProcAddr(nil, "vkCreateInstance") + DebugUtilsMessengerCallbackEXT = auto_cast GetInstanceProcAddr(nil, "vkDebugUtilsMessengerCallbackEXT") + DeviceMemoryReportCallbackEXT = auto_cast GetInstanceProcAddr(nil, "vkDeviceMemoryReportCallbackEXT") + EnumerateInstanceExtensionProperties = auto_cast GetInstanceProcAddr(nil, "vkEnumerateInstanceExtensionProperties") + EnumerateInstanceLayerProperties = auto_cast GetInstanceProcAddr(nil, "vkEnumerateInstanceLayerProperties") + EnumerateInstanceVersion = auto_cast GetInstanceProcAddr(nil, "vkEnumerateInstanceVersion") + GetInstanceProcAddr = auto_cast GetInstanceProcAddr(nil, "vkGetInstanceProcAddr") +} + +load_proc_addresses :: proc{ + load_proc_addresses_global, + load_proc_addresses_instance, + load_proc_addresses_device, + load_proc_addresses_device_vtable, + load_proc_addresses_custom, +} + diff --git a/vendor/vulkan/structs.odin b/vendor/vulkan/structs.odin index 3bc3e1935..5d3231ccc 100644 --- a/vendor/vulkan/structs.odin +++ b/vendor/vulkan/structs.odin @@ -1,5865 +1,7664 @@ -// -// Vulkan wrapper generated from "https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/master/include/vulkan/vulkan_core.h" -// -package vulkan - -import "core:c" - -when ODIN_OS == .Windows { - import win32 "core:sys/windows" - - HINSTANCE :: win32.HINSTANCE - HWND :: win32.HWND - HMONITOR :: win32.HMONITOR - HANDLE :: win32.HANDLE - LPCWSTR :: win32.LPCWSTR - SECURITY_ATTRIBUTES :: win32.SECURITY_ATTRIBUTES - DWORD :: win32.DWORD - LONG :: win32.LONG - LUID :: win32.LUID -} else { - HINSTANCE :: distinct rawptr - HWND :: distinct rawptr - HMONITOR :: distinct rawptr - HANDLE :: distinct rawptr - LPCWSTR :: ^u16 - SECURITY_ATTRIBUTES :: struct {} - DWORD :: u32 - LONG :: c.long - LUID :: struct { - LowPart: DWORD, - HighPart: LONG, - } -} - -CAMetalLayer :: struct {} - -/********************************/ - -Extent2D :: struct { - width: u32, - height: u32, -} - -Extent3D :: struct { - width: u32, - height: u32, - depth: u32, -} - -Offset2D :: struct { - x: i32, - y: i32, -} - -Offset3D :: struct { - x: i32, - y: i32, - z: i32, -} - -Rect2D :: struct { - offset: Offset2D, - extent: Extent2D, -} - -BaseInStructure :: struct { - sType: StructureType, - pNext: ^BaseInStructure, -} - -BaseOutStructure :: struct { - sType: StructureType, - pNext: ^BaseOutStructure, -} - -BufferMemoryBarrier :: struct { - sType: StructureType, - pNext: rawptr, - srcAccessMask: AccessFlags, - dstAccessMask: AccessFlags, - srcQueueFamilyIndex: u32, - dstQueueFamilyIndex: u32, - buffer: Buffer, - offset: DeviceSize, - size: DeviceSize, -} - -DispatchIndirectCommand :: struct { - x: u32, - y: u32, - z: u32, -} - -DrawIndexedIndirectCommand :: struct { - indexCount: u32, - instanceCount: u32, - firstIndex: u32, - vertexOffset: i32, - firstInstance: u32, -} - -DrawIndirectCommand :: struct { - vertexCount: u32, - instanceCount: u32, - firstVertex: u32, - firstInstance: u32, -} - -ImageSubresourceRange :: struct { - aspectMask: ImageAspectFlags, - baseMipLevel: u32, - levelCount: u32, - baseArrayLayer: u32, - layerCount: u32, -} - -ImageMemoryBarrier :: struct { - sType: StructureType, - pNext: rawptr, - srcAccessMask: AccessFlags, - dstAccessMask: AccessFlags, - oldLayout: ImageLayout, - newLayout: ImageLayout, - srcQueueFamilyIndex: u32, - dstQueueFamilyIndex: u32, - image: Image, - subresourceRange: ImageSubresourceRange, -} - -MemoryBarrier :: struct { - sType: StructureType, - pNext: rawptr, - srcAccessMask: AccessFlags, - dstAccessMask: AccessFlags, -} - -PipelineCacheHeaderVersionOne :: struct { - headerSize: u32, - headerVersion: PipelineCacheHeaderVersion, - vendorID: u32, - deviceID: u32, - pipelineCacheUUID: [UUID_SIZE]u8, -} - -AllocationCallbacks :: struct { - pUserData: rawptr, - pfnAllocation: ProcAllocationFunction, - pfnReallocation: ProcReallocationFunction, - pfnFree: ProcFreeFunction, - pfnInternalAllocation: ProcInternalAllocationNotification, - pfnInternalFree: ProcInternalFreeNotification, -} - -ApplicationInfo :: struct { - sType: StructureType, - pNext: rawptr, - pApplicationName: cstring, - applicationVersion: u32, - pEngineName: cstring, - engineVersion: u32, - apiVersion: u32, -} - -FormatProperties :: struct { - linearTilingFeatures: FormatFeatureFlags, - optimalTilingFeatures: FormatFeatureFlags, - bufferFeatures: FormatFeatureFlags, -} - -ImageFormatProperties :: struct { - maxExtent: Extent3D, - maxMipLevels: u32, - maxArrayLayers: u32, - sampleCounts: SampleCountFlags, - maxResourceSize: DeviceSize, -} - -InstanceCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - flags: InstanceCreateFlags, - pApplicationInfo: ^ApplicationInfo, - enabledLayerCount: u32, - ppEnabledLayerNames: [^]cstring, - enabledExtensionCount: u32, - ppEnabledExtensionNames: [^]cstring, -} - -MemoryHeap :: struct { - size: DeviceSize, - flags: MemoryHeapFlags, -} - -MemoryType :: struct { - propertyFlags: MemoryPropertyFlags, - heapIndex: u32, -} - -PhysicalDeviceFeatures :: struct { - robustBufferAccess: b32, - fullDrawIndexUint32: b32, - imageCubeArray: b32, - independentBlend: b32, - geometryShader: b32, - tessellationShader: b32, - sampleRateShading: b32, - dualSrcBlend: b32, - logicOp: b32, - multiDrawIndirect: b32, - drawIndirectFirstInstance: b32, - depthClamp: b32, - depthBiasClamp: b32, - fillModeNonSolid: b32, - depthBounds: b32, - wideLines: b32, - largePoints: b32, - alphaToOne: b32, - multiViewport: b32, - samplerAnisotropy: b32, - textureCompressionETC2: b32, - textureCompressionASTC_LDR: b32, - textureCompressionBC: b32, - occlusionQueryPrecise: b32, - pipelineStatisticsQuery: b32, - vertexPipelineStoresAndAtomics: b32, - fragmentStoresAndAtomics: b32, - shaderTessellationAndGeometryPointSize: b32, - shaderImageGatherExtended: b32, - shaderStorageImageExtendedFormats: b32, - shaderStorageImageMultisample: b32, - shaderStorageImageReadWithoutFormat: b32, - shaderStorageImageWriteWithoutFormat: b32, - shaderUniformBufferArrayDynamicIndexing: b32, - shaderSampledImageArrayDynamicIndexing: b32, - shaderStorageBufferArrayDynamicIndexing: b32, - shaderStorageImageArrayDynamicIndexing: b32, - shaderClipDistance: b32, - shaderCullDistance: b32, - shaderFloat64: b32, - shaderInt64: b32, - shaderInt16: b32, - shaderResourceResidency: b32, - shaderResourceMinLod: b32, - sparseBinding: b32, - sparseResidencyBuffer: b32, - sparseResidencyImage2D: b32, - sparseResidencyImage3D: b32, - sparseResidency2Samples: b32, - sparseResidency4Samples: b32, - sparseResidency8Samples: b32, - sparseResidency16Samples: b32, - sparseResidencyAliased: b32, - variableMultisampleRate: b32, - inheritedQueries: b32, -} - -PhysicalDeviceLimits :: struct { - maxImageDimension1D: u32, - maxImageDimension2D: u32, - maxImageDimension3D: u32, - maxImageDimensionCube: u32, - maxImageArrayLayers: u32, - maxTexelBufferElements: u32, - maxUniformBufferRange: u32, - maxStorageBufferRange: u32, - maxPushConstantsSize: u32, - maxMemoryAllocationCount: u32, - maxSamplerAllocationCount: u32, - bufferImageGranularity: DeviceSize, - sparseAddressSpaceSize: DeviceSize, - maxBoundDescriptorSets: u32, - maxPerStageDescriptorSamplers: u32, - maxPerStageDescriptorUniformBuffers: u32, - maxPerStageDescriptorStorageBuffers: u32, - maxPerStageDescriptorSampledImages: u32, - maxPerStageDescriptorStorageImages: u32, - maxPerStageDescriptorInputAttachments: u32, - maxPerStageResources: u32, - maxDescriptorSetSamplers: u32, - maxDescriptorSetUniformBuffers: u32, - maxDescriptorSetUniformBuffersDynamic: u32, - maxDescriptorSetStorageBuffers: u32, - maxDescriptorSetStorageBuffersDynamic: u32, - maxDescriptorSetSampledImages: u32, - maxDescriptorSetStorageImages: u32, - maxDescriptorSetInputAttachments: u32, - maxVertexInputAttributes: u32, - maxVertexInputBindings: u32, - maxVertexInputAttributeOffset: u32, - maxVertexInputBindingStride: u32, - maxVertexOutputComponents: u32, - maxTessellationGenerationLevel: u32, - maxTessellationPatchSize: u32, - maxTessellationControlPerVertexInputComponents: u32, - maxTessellationControlPerVertexOutputComponents: u32, - maxTessellationControlPerPatchOutputComponents: u32, - maxTessellationControlTotalOutputComponents: u32, - maxTessellationEvaluationInputComponents: u32, - maxTessellationEvaluationOutputComponents: u32, - maxGeometryShaderInvocations: u32, - maxGeometryInputComponents: u32, - maxGeometryOutputComponents: u32, - maxGeometryOutputVertices: u32, - maxGeometryTotalOutputComponents: u32, - maxFragmentInputComponents: u32, - maxFragmentOutputAttachments: u32, - maxFragmentDualSrcAttachments: u32, - maxFragmentCombinedOutputResources: u32, - maxComputeSharedMemorySize: u32, - maxComputeWorkGroupCount: [3]u32, - maxComputeWorkGroupInvocations: u32, - maxComputeWorkGroupSize: [3]u32, - subPixelPrecisionBits: u32, - subTexelPrecisionBits: u32, - mipmapPrecisionBits: u32, - maxDrawIndexedIndexValue: u32, - maxDrawIndirectCount: u32, - maxSamplerLodBias: f32, - maxSamplerAnisotropy: f32, - maxViewports: u32, - maxViewportDimensions: [2]u32, - viewportBoundsRange: [2]f32, - viewportSubPixelBits: u32, - minMemoryMapAlignment: int, - minTexelBufferOffsetAlignment: DeviceSize, - minUniformBufferOffsetAlignment: DeviceSize, - minStorageBufferOffsetAlignment: DeviceSize, - minTexelOffset: i32, - maxTexelOffset: u32, - minTexelGatherOffset: i32, - maxTexelGatherOffset: u32, - minInterpolationOffset: f32, - maxInterpolationOffset: f32, - subPixelInterpolationOffsetBits: u32, - maxFramebufferWidth: u32, - maxFramebufferHeight: u32, - maxFramebufferLayers: u32, - framebufferColorSampleCounts: SampleCountFlags, - framebufferDepthSampleCounts: SampleCountFlags, - framebufferStencilSampleCounts: SampleCountFlags, - framebufferNoAttachmentsSampleCounts: SampleCountFlags, - maxColorAttachments: u32, - sampledImageColorSampleCounts: SampleCountFlags, - sampledImageIntegerSampleCounts: SampleCountFlags, - sampledImageDepthSampleCounts: SampleCountFlags, - sampledImageStencilSampleCounts: SampleCountFlags, - storageImageSampleCounts: SampleCountFlags, - maxSampleMaskWords: u32, - timestampComputeAndGraphics: b32, - timestampPeriod: f32, - maxClipDistances: u32, - maxCullDistances: u32, - maxCombinedClipAndCullDistances: u32, - discreteQueuePriorities: u32, - pointSizeRange: [2]f32, - lineWidthRange: [2]f32, - pointSizeGranularity: f32, - lineWidthGranularity: f32, - strictLines: b32, - standardSampleLocations: b32, - optimalBufferCopyOffsetAlignment: DeviceSize, - optimalBufferCopyRowPitchAlignment: DeviceSize, - nonCoherentAtomSize: DeviceSize, -} - -PhysicalDeviceMemoryProperties :: struct { - memoryTypeCount: u32, - memoryTypes: [MAX_MEMORY_TYPES]MemoryType, - memoryHeapCount: u32, - memoryHeaps: [MAX_MEMORY_HEAPS]MemoryHeap, -} - -PhysicalDeviceSparseProperties :: struct { - residencyStandard2DBlockShape: b32, - residencyStandard2DMultisampleBlockShape: b32, - residencyStandard3DBlockShape: b32, - residencyAlignedMipSize: b32, - residencyNonResidentStrict: b32, -} - -PhysicalDeviceProperties :: struct { - apiVersion: u32, - driverVersion: u32, - vendorID: u32, - deviceID: u32, - deviceType: PhysicalDeviceType, - deviceName: [MAX_PHYSICAL_DEVICE_NAME_SIZE]byte, - pipelineCacheUUID: [UUID_SIZE]u8, - limits: PhysicalDeviceLimits, - sparseProperties: PhysicalDeviceSparseProperties, -} - -QueueFamilyProperties :: struct { - queueFlags: QueueFlags, - queueCount: u32, - timestampValidBits: u32, - minImageTransferGranularity: Extent3D, -} - -DeviceQueueCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - flags: DeviceQueueCreateFlags, - queueFamilyIndex: u32, - queueCount: u32, - pQueuePriorities: [^]f32, -} - -DeviceCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - flags: DeviceCreateFlags, - queueCreateInfoCount: u32, - pQueueCreateInfos: [^]DeviceQueueCreateInfo, - enabledLayerCount: u32, - ppEnabledLayerNames: [^]cstring, - enabledExtensionCount: u32, - ppEnabledExtensionNames: [^]cstring, - pEnabledFeatures: [^]PhysicalDeviceFeatures, -} - -ExtensionProperties :: struct { - extensionName: [MAX_EXTENSION_NAME_SIZE]byte, - specVersion: u32, -} - -LayerProperties :: struct { - layerName: [MAX_EXTENSION_NAME_SIZE]byte, - specVersion: u32, - implementationVersion: u32, - description: [MAX_DESCRIPTION_SIZE]byte, -} - -SubmitInfo :: struct { - sType: StructureType, - pNext: rawptr, - waitSemaphoreCount: u32, - pWaitSemaphores: [^]Semaphore, - pWaitDstStageMask: [^]PipelineStageFlags, - commandBufferCount: u32, - pCommandBuffers: [^]CommandBuffer, - signalSemaphoreCount: u32, - pSignalSemaphores: [^]Semaphore, -} - -MappedMemoryRange :: struct { - sType: StructureType, - pNext: rawptr, - memory: DeviceMemory, - offset: DeviceSize, - size: DeviceSize, -} - -MemoryAllocateInfo :: struct { - sType: StructureType, - pNext: rawptr, - allocationSize: DeviceSize, - memoryTypeIndex: u32, -} - -MemoryRequirements :: struct { - size: DeviceSize, - alignment: DeviceSize, - memoryTypeBits: u32, -} - -SparseMemoryBind :: struct { - resourceOffset: DeviceSize, - size: DeviceSize, - memory: DeviceMemory, - memoryOffset: DeviceSize, - flags: SparseMemoryBindFlags, -} - -SparseBufferMemoryBindInfo :: struct { - buffer: Buffer, - bindCount: u32, - pBinds: [^]SparseMemoryBind, -} - -SparseImageOpaqueMemoryBindInfo :: struct { - image: Image, - bindCount: u32, - pBinds: [^]SparseMemoryBind, -} - -ImageSubresource :: struct { - aspectMask: ImageAspectFlags, - mipLevel: u32, - arrayLayer: u32, -} - -SparseImageMemoryBind :: struct { - subresource: ImageSubresource, - offset: Offset3D, - extent: Extent3D, - memory: DeviceMemory, - memoryOffset: DeviceSize, - flags: SparseMemoryBindFlags, -} - -SparseImageMemoryBindInfo :: struct { - image: Image, - bindCount: u32, - pBinds: [^]SparseImageMemoryBind, -} - -BindSparseInfo :: struct { - sType: StructureType, - pNext: rawptr, - waitSemaphoreCount: u32, - pWaitSemaphores: [^]Semaphore, - bufferBindCount: u32, - pBufferBinds: [^]SparseBufferMemoryBindInfo, - imageOpaqueBindCount: u32, - pImageOpaqueBinds: [^]SparseImageOpaqueMemoryBindInfo, - imageBindCount: u32, - pImageBinds: [^]SparseImageMemoryBindInfo, - signalSemaphoreCount: u32, - pSignalSemaphores: [^]Semaphore, -} - -SparseImageFormatProperties :: struct { - aspectMask: ImageAspectFlags, - imageGranularity: Extent3D, - flags: SparseImageFormatFlags, -} - -SparseImageMemoryRequirements :: struct { - formatProperties: SparseImageFormatProperties, - imageMipTailFirstLod: u32, - imageMipTailSize: DeviceSize, - imageMipTailOffset: DeviceSize, - imageMipTailStride: DeviceSize, -} - -FenceCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - flags: FenceCreateFlags, -} - -SemaphoreCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - flags: SemaphoreCreateFlags, -} - -EventCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - flags: EventCreateFlags, -} - -QueryPoolCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - flags: QueryPoolCreateFlags, - queryType: QueryType, - queryCount: u32, - pipelineStatistics: QueryPipelineStatisticFlags, -} - -BufferCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - flags: BufferCreateFlags, - size: DeviceSize, - usage: BufferUsageFlags, - sharingMode: SharingMode, - queueFamilyIndexCount: u32, - pQueueFamilyIndices: [^]u32, -} - -BufferViewCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - flags: BufferViewCreateFlags, - buffer: Buffer, - format: Format, - offset: DeviceSize, - range: DeviceSize, -} - -ImageCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - flags: ImageCreateFlags, - imageType: ImageType, - format: Format, - extent: Extent3D, - mipLevels: u32, - arrayLayers: u32, - samples: SampleCountFlags, - tiling: ImageTiling, - usage: ImageUsageFlags, - sharingMode: SharingMode, - queueFamilyIndexCount: u32, - pQueueFamilyIndices: [^]u32, - initialLayout: ImageLayout, -} - -SubresourceLayout :: struct { - offset: DeviceSize, - size: DeviceSize, - rowPitch: DeviceSize, - arrayPitch: DeviceSize, - depthPitch: DeviceSize, -} - -ComponentMapping :: struct { - r: ComponentSwizzle, - g: ComponentSwizzle, - b: ComponentSwizzle, - a: ComponentSwizzle, -} - -ImageViewCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - flags: ImageViewCreateFlags, - image: Image, - viewType: ImageViewType, - format: Format, - components: ComponentMapping, - subresourceRange: ImageSubresourceRange, -} - -ShaderModuleCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - flags: ShaderModuleCreateFlags, - codeSize: int, - pCode: ^u32, -} - -PipelineCacheCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - flags: PipelineCacheCreateFlags, - initialDataSize: int, - pInitialData: rawptr, -} - -SpecializationMapEntry :: struct { - constantID: u32, - offset: u32, - size: int, -} - -SpecializationInfo :: struct { - mapEntryCount: u32, - pMapEntries: [^]SpecializationMapEntry, - dataSize: int, - pData: rawptr, -} - -PipelineShaderStageCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - flags: PipelineShaderStageCreateFlags, - stage: ShaderStageFlags, - module: ShaderModule, - pName: cstring, - pSpecializationInfo: ^SpecializationInfo, -} - -ComputePipelineCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - flags: PipelineCreateFlags, - stage: PipelineShaderStageCreateInfo, - layout: PipelineLayout, - basePipelineHandle: Pipeline, - basePipelineIndex: i32, -} - -VertexInputBindingDescription :: struct { - binding: u32, - stride: u32, - inputRate: VertexInputRate, -} - -VertexInputAttributeDescription :: struct { - location: u32, - binding: u32, - format: Format, - offset: u32, -} - -PipelineVertexInputStateCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - flags: PipelineVertexInputStateCreateFlags, - vertexBindingDescriptionCount: u32, - pVertexBindingDescriptions: [^]VertexInputBindingDescription, - vertexAttributeDescriptionCount: u32, - pVertexAttributeDescriptions: [^]VertexInputAttributeDescription, -} - -PipelineInputAssemblyStateCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - flags: PipelineInputAssemblyStateCreateFlags, - topology: PrimitiveTopology, - primitiveRestartEnable: b32, -} - -PipelineTessellationStateCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - flags: PipelineTessellationStateCreateFlags, - patchControlPoints: u32, -} - -Viewport :: struct { - x: f32, - y: f32, - width: f32, - height: f32, - minDepth: f32, - maxDepth: f32, -} - -PipelineViewportStateCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - flags: PipelineViewportStateCreateFlags, - viewportCount: u32, - pViewports: [^]Viewport, - scissorCount: u32, - pScissors: [^]Rect2D, -} - -PipelineRasterizationStateCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - flags: PipelineRasterizationStateCreateFlags, - depthClampEnable: b32, - rasterizerDiscardEnable: b32, - polygonMode: PolygonMode, - cullMode: CullModeFlags, - frontFace: FrontFace, - depthBiasEnable: b32, - depthBiasConstantFactor: f32, - depthBiasClamp: f32, - depthBiasSlopeFactor: f32, - lineWidth: f32, -} - -PipelineMultisampleStateCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - flags: PipelineMultisampleStateCreateFlags, - rasterizationSamples: SampleCountFlags, - sampleShadingEnable: b32, - minSampleShading: f32, - pSampleMask: ^SampleMask, - alphaToCoverageEnable: b32, - alphaToOneEnable: b32, -} - -StencilOpState :: struct { - failOp: StencilOp, - passOp: StencilOp, - depthFailOp: StencilOp, - compareOp: CompareOp, - compareMask: u32, - writeMask: u32, - reference: u32, -} - -PipelineDepthStencilStateCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - flags: PipelineDepthStencilStateCreateFlags, - depthTestEnable: b32, - depthWriteEnable: b32, - depthCompareOp: CompareOp, - depthBoundsTestEnable: b32, - stencilTestEnable: b32, - front: StencilOpState, - back: StencilOpState, - minDepthBounds: f32, - maxDepthBounds: f32, -} - -PipelineColorBlendAttachmentState :: struct { - blendEnable: b32, - srcColorBlendFactor: BlendFactor, - dstColorBlendFactor: BlendFactor, - colorBlendOp: BlendOp, - srcAlphaBlendFactor: BlendFactor, - dstAlphaBlendFactor: BlendFactor, - alphaBlendOp: BlendOp, - colorWriteMask: ColorComponentFlags, -} - -PipelineColorBlendStateCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - flags: PipelineColorBlendStateCreateFlags, - logicOpEnable: b32, - logicOp: LogicOp, - attachmentCount: u32, - pAttachments: [^]PipelineColorBlendAttachmentState, - blendConstants: [4]f32, -} - -PipelineDynamicStateCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - flags: PipelineDynamicStateCreateFlags, - dynamicStateCount: u32, - pDynamicStates: [^]DynamicState, -} - -GraphicsPipelineCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - flags: PipelineCreateFlags, - stageCount: u32, - pStages: [^]PipelineShaderStageCreateInfo, - pVertexInputState: ^PipelineVertexInputStateCreateInfo, - pInputAssemblyState: ^PipelineInputAssemblyStateCreateInfo, - pTessellationState: ^PipelineTessellationStateCreateInfo, - pViewportState: ^PipelineViewportStateCreateInfo, - pRasterizationState: ^PipelineRasterizationStateCreateInfo, - pMultisampleState: ^PipelineMultisampleStateCreateInfo, - pDepthStencilState: ^PipelineDepthStencilStateCreateInfo, - pColorBlendState: ^PipelineColorBlendStateCreateInfo, - pDynamicState: ^PipelineDynamicStateCreateInfo, - layout: PipelineLayout, - renderPass: RenderPass, - subpass: u32, - basePipelineHandle: Pipeline, - basePipelineIndex: i32, -} - -PushConstantRange :: struct { - stageFlags: ShaderStageFlags, - offset: u32, - size: u32, -} - -PipelineLayoutCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - flags: PipelineLayoutCreateFlags, - setLayoutCount: u32, - pSetLayouts: [^]DescriptorSetLayout, - pushConstantRangeCount: u32, - pPushConstantRanges: [^]PushConstantRange, -} - -SamplerCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - flags: SamplerCreateFlags, - magFilter: Filter, - minFilter: Filter, - mipmapMode: SamplerMipmapMode, - addressModeU: SamplerAddressMode, - addressModeV: SamplerAddressMode, - addressModeW: SamplerAddressMode, - mipLodBias: f32, - anisotropyEnable: b32, - maxAnisotropy: f32, - compareEnable: b32, - compareOp: CompareOp, - minLod: f32, - maxLod: f32, - borderColor: BorderColor, - unnormalizedCoordinates: b32, -} - -CopyDescriptorSet :: struct { - sType: StructureType, - pNext: rawptr, - srcSet: DescriptorSet, - srcBinding: u32, - srcArrayElement: u32, - dstSet: DescriptorSet, - dstBinding: u32, - dstArrayElement: u32, - descriptorCount: u32, -} - -DescriptorBufferInfo :: struct { - buffer: Buffer, - offset: DeviceSize, - range: DeviceSize, -} - -DescriptorImageInfo :: struct { - sampler: Sampler, - imageView: ImageView, - imageLayout: ImageLayout, -} - -DescriptorPoolSize :: struct { - type: DescriptorType, - descriptorCount: u32, -} - -DescriptorPoolCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - flags: DescriptorPoolCreateFlags, - maxSets: u32, - poolSizeCount: u32, - pPoolSizes: [^]DescriptorPoolSize, -} - -DescriptorSetAllocateInfo :: struct { - sType: StructureType, - pNext: rawptr, - descriptorPool: DescriptorPool, - descriptorSetCount: u32, - pSetLayouts: [^]DescriptorSetLayout, -} - -DescriptorSetLayoutBinding :: struct { - binding: u32, - descriptorType: DescriptorType, - descriptorCount: u32, - stageFlags: ShaderStageFlags, - pImmutableSamplers: [^]Sampler, -} - -DescriptorSetLayoutCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - flags: DescriptorSetLayoutCreateFlags, - bindingCount: u32, - pBindings: [^]DescriptorSetLayoutBinding, -} - -WriteDescriptorSet :: struct { - sType: StructureType, - pNext: rawptr, - dstSet: DescriptorSet, - dstBinding: u32, - dstArrayElement: u32, - descriptorCount: u32, - descriptorType: DescriptorType, - pImageInfo: ^DescriptorImageInfo, - pBufferInfo: ^DescriptorBufferInfo, - pTexelBufferView: ^BufferView, -} - -AttachmentDescription :: struct { - flags: AttachmentDescriptionFlags, - format: Format, - samples: SampleCountFlags, - loadOp: AttachmentLoadOp, - storeOp: AttachmentStoreOp, - stencilLoadOp: AttachmentLoadOp, - stencilStoreOp: AttachmentStoreOp, - initialLayout: ImageLayout, - finalLayout: ImageLayout, -} - -AttachmentReference :: struct { - attachment: u32, - layout: ImageLayout, -} - -FramebufferCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - flags: FramebufferCreateFlags, - renderPass: RenderPass, - attachmentCount: u32, - pAttachments: [^]ImageView, - width: u32, - height: u32, - layers: u32, -} - -SubpassDescription :: struct { - flags: SubpassDescriptionFlags, - pipelineBindPoint: PipelineBindPoint, - inputAttachmentCount: u32, - pInputAttachments: [^]AttachmentReference, - colorAttachmentCount: u32, - pColorAttachments: [^]AttachmentReference, - pResolveAttachments: [^]AttachmentReference, - pDepthStencilAttachment: ^AttachmentReference, - preserveAttachmentCount: u32, - pPreserveAttachments: [^]u32, -} - -SubpassDependency :: struct { - srcSubpass: u32, - dstSubpass: u32, - srcStageMask: PipelineStageFlags, - dstStageMask: PipelineStageFlags, - srcAccessMask: AccessFlags, - dstAccessMask: AccessFlags, - dependencyFlags: DependencyFlags, -} - -RenderPassCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - flags: RenderPassCreateFlags, - attachmentCount: u32, - pAttachments: [^]AttachmentDescription, - subpassCount: u32, - pSubpasses: [^]SubpassDescription, - dependencyCount: u32, - pDependencies: [^]SubpassDependency, -} - -CommandPoolCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - flags: CommandPoolCreateFlags, - queueFamilyIndex: u32, -} - -CommandBufferAllocateInfo :: struct { - sType: StructureType, - pNext: rawptr, - commandPool: CommandPool, - level: CommandBufferLevel, - commandBufferCount: u32, -} - -CommandBufferInheritanceInfo :: struct { - sType: StructureType, - pNext: rawptr, - renderPass: RenderPass, - subpass: u32, - framebuffer: Framebuffer, - occlusionQueryEnable: b32, - queryFlags: QueryControlFlags, - pipelineStatistics: QueryPipelineStatisticFlags, -} - -CommandBufferBeginInfo :: struct { - sType: StructureType, - pNext: rawptr, - flags: CommandBufferUsageFlags, - pInheritanceInfo: ^CommandBufferInheritanceInfo, -} - -BufferCopy :: struct { - srcOffset: DeviceSize, - dstOffset: DeviceSize, - size: DeviceSize, -} - -ImageSubresourceLayers :: struct { - aspectMask: ImageAspectFlags, - mipLevel: u32, - baseArrayLayer: u32, - layerCount: u32, -} - -BufferImageCopy :: struct { - bufferOffset: DeviceSize, - bufferRowLength: u32, - bufferImageHeight: u32, - imageSubresource: ImageSubresourceLayers, - imageOffset: Offset3D, - imageExtent: Extent3D, -} - -ClearColorValue :: struct #raw_union { - float32: [4]f32, - int32: [4]i32, - uint32: [4]u32, -} - -ClearDepthStencilValue :: struct { - depth: f32, - stencil: u32, -} - -ClearValue :: struct #raw_union { - color: ClearColorValue, - depthStencil: ClearDepthStencilValue, -} - -ClearAttachment :: struct { - aspectMask: ImageAspectFlags, - colorAttachment: u32, - clearValue: ClearValue, -} - -ClearRect :: struct { - rect: Rect2D, - baseArrayLayer: u32, - layerCount: u32, -} - -ImageBlit :: struct { - srcSubresource: ImageSubresourceLayers, - srcOffsets: [2]Offset3D, - dstSubresource: ImageSubresourceLayers, - dstOffsets: [2]Offset3D, -} - -ImageCopy :: struct { - srcSubresource: ImageSubresourceLayers, - srcOffset: Offset3D, - dstSubresource: ImageSubresourceLayers, - dstOffset: Offset3D, - extent: Extent3D, -} - -ImageResolve :: struct { - srcSubresource: ImageSubresourceLayers, - srcOffset: Offset3D, - dstSubresource: ImageSubresourceLayers, - dstOffset: Offset3D, - extent: Extent3D, -} - -RenderPassBeginInfo :: struct { - sType: StructureType, - pNext: rawptr, - renderPass: RenderPass, - framebuffer: Framebuffer, - renderArea: Rect2D, - clearValueCount: u32, - pClearValues: [^]ClearValue, -} - -PhysicalDeviceSubgroupProperties :: struct { - sType: StructureType, - pNext: rawptr, - subgroupSize: u32, - supportedStages: ShaderStageFlags, - supportedOperations: SubgroupFeatureFlags, - quadOperationsInAllStages: b32, -} - -BindBufferMemoryInfo :: struct { - sType: StructureType, - pNext: rawptr, - buffer: Buffer, - memory: DeviceMemory, - memoryOffset: DeviceSize, -} - -BindImageMemoryInfo :: struct { - sType: StructureType, - pNext: rawptr, - image: Image, - memory: DeviceMemory, - memoryOffset: DeviceSize, -} - -PhysicalDevice16BitStorageFeatures :: struct { - sType: StructureType, - pNext: rawptr, - storageBuffer16BitAccess: b32, - uniformAndStorageBuffer16BitAccess: b32, - storagePushConstant16: b32, - storageInputOutput16: b32, -} - -MemoryDedicatedRequirements :: struct { - sType: StructureType, - pNext: rawptr, - prefersDedicatedAllocation: b32, - requiresDedicatedAllocation: b32, -} - -MemoryDedicatedAllocateInfo :: struct { - sType: StructureType, - pNext: rawptr, - image: Image, - buffer: Buffer, -} - -MemoryAllocateFlagsInfo :: struct { - sType: StructureType, - pNext: rawptr, - flags: MemoryAllocateFlags, - deviceMask: u32, -} - -DeviceGroupRenderPassBeginInfo :: struct { - sType: StructureType, - pNext: rawptr, - deviceMask: u32, - deviceRenderAreaCount: u32, - pDeviceRenderAreas: [^]Rect2D, -} - -DeviceGroupCommandBufferBeginInfo :: struct { - sType: StructureType, - pNext: rawptr, - deviceMask: u32, -} - -DeviceGroupSubmitInfo :: struct { - sType: StructureType, - pNext: rawptr, - waitSemaphoreCount: u32, - pWaitSemaphoreDeviceIndices: [^]u32, - commandBufferCount: u32, - pCommandBufferDeviceMasks: [^]u32, - signalSemaphoreCount: u32, - pSignalSemaphoreDeviceIndices: [^]u32, -} - -DeviceGroupBindSparseInfo :: struct { - sType: StructureType, - pNext: rawptr, - resourceDeviceIndex: u32, - memoryDeviceIndex: u32, -} - -BindBufferMemoryDeviceGroupInfo :: struct { - sType: StructureType, - pNext: rawptr, - deviceIndexCount: u32, - pDeviceIndices: [^]u32, -} - -BindImageMemoryDeviceGroupInfo :: struct { - sType: StructureType, - pNext: rawptr, - deviceIndexCount: u32, - pDeviceIndices: [^]u32, - splitInstanceBindRegionCount: u32, - pSplitInstanceBindRegions: [^]Rect2D, -} - -PhysicalDeviceGroupProperties :: struct { - sType: StructureType, - pNext: rawptr, - physicalDeviceCount: u32, - physicalDevices: [MAX_DEVICE_GROUP_SIZE]PhysicalDevice, - subsetAllocation: b32, -} - -DeviceGroupDeviceCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - physicalDeviceCount: u32, - pPhysicalDevices: [^]PhysicalDevice, -} - -BufferMemoryRequirementsInfo2 :: struct { - sType: StructureType, - pNext: rawptr, - buffer: Buffer, -} - -ImageMemoryRequirementsInfo2 :: struct { - sType: StructureType, - pNext: rawptr, - image: Image, -} - -ImageSparseMemoryRequirementsInfo2 :: struct { - sType: StructureType, - pNext: rawptr, - image: Image, -} - -MemoryRequirements2 :: struct { - sType: StructureType, - pNext: rawptr, - memoryRequirements: MemoryRequirements, -} - -SparseImageMemoryRequirements2 :: struct { - sType: StructureType, - pNext: rawptr, - memoryRequirements: SparseImageMemoryRequirements, -} - -PhysicalDeviceFeatures2 :: struct { - sType: StructureType, - pNext: rawptr, - features: PhysicalDeviceFeatures, -} - -PhysicalDeviceProperties2 :: struct { - sType: StructureType, - pNext: rawptr, - properties: PhysicalDeviceProperties, -} - -FormatProperties2 :: struct { - sType: StructureType, - pNext: rawptr, - formatProperties: FormatProperties, -} - -ImageFormatProperties2 :: struct { - sType: StructureType, - pNext: rawptr, - imageFormatProperties: ImageFormatProperties, -} - -PhysicalDeviceImageFormatInfo2 :: struct { - sType: StructureType, - pNext: rawptr, - format: Format, - type: ImageType, - tiling: ImageTiling, - usage: ImageUsageFlags, - flags: ImageCreateFlags, -} - -QueueFamilyProperties2 :: struct { - sType: StructureType, - pNext: rawptr, - queueFamilyProperties: QueueFamilyProperties, -} - -PhysicalDeviceMemoryProperties2 :: struct { - sType: StructureType, - pNext: rawptr, - memoryProperties: PhysicalDeviceMemoryProperties, -} - -SparseImageFormatProperties2 :: struct { - sType: StructureType, - pNext: rawptr, - properties: SparseImageFormatProperties, -} - -PhysicalDeviceSparseImageFormatInfo2 :: struct { - sType: StructureType, - pNext: rawptr, - format: Format, - type: ImageType, - samples: SampleCountFlags, - usage: ImageUsageFlags, - tiling: ImageTiling, -} - -PhysicalDevicePointClippingProperties :: struct { - sType: StructureType, - pNext: rawptr, - pointClippingBehavior: PointClippingBehavior, -} - -InputAttachmentAspectReference :: struct { - subpass: u32, - inputAttachmentIndex: u32, - aspectMask: ImageAspectFlags, -} - -RenderPassInputAttachmentAspectCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - aspectReferenceCount: u32, - pAspectReferences: [^]InputAttachmentAspectReference, -} - -ImageViewUsageCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - usage: ImageUsageFlags, -} - -PipelineTessellationDomainOriginStateCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - domainOrigin: TessellationDomainOrigin, -} - -RenderPassMultiviewCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - subpassCount: u32, - pViewMasks: [^]u32, - dependencyCount: u32, - pViewOffsets: [^]i32, - correlationMaskCount: u32, - pCorrelationMasks: [^]u32, -} - -PhysicalDeviceMultiviewFeatures :: struct { - sType: StructureType, - pNext: rawptr, - multiview: b32, - multiviewGeometryShader: b32, - multiviewTessellationShader: b32, -} - -PhysicalDeviceMultiviewProperties :: struct { - sType: StructureType, - pNext: rawptr, - maxMultiviewViewCount: u32, - maxMultiviewInstanceIndex: u32, -} - -PhysicalDeviceVariablePointersFeatures :: struct { - sType: StructureType, - pNext: rawptr, - variablePointersStorageBuffer: b32, - variablePointers: b32, -} - -PhysicalDeviceProtectedMemoryFeatures :: struct { - sType: StructureType, - pNext: rawptr, - protectedMemory: b32, -} - -PhysicalDeviceProtectedMemoryProperties :: struct { - sType: StructureType, - pNext: rawptr, - protectedNoFault: b32, -} - -DeviceQueueInfo2 :: struct { - sType: StructureType, - pNext: rawptr, - flags: DeviceQueueCreateFlags, - queueFamilyIndex: u32, - queueIndex: u32, -} - -ProtectedSubmitInfo :: struct { - sType: StructureType, - pNext: rawptr, - protectedSubmit: b32, -} - -SamplerYcbcrConversionCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - format: Format, - ycbcrModel: SamplerYcbcrModelConversion, - ycbcrRange: SamplerYcbcrRange, - components: ComponentMapping, - xChromaOffset: ChromaLocation, - yChromaOffset: ChromaLocation, - chromaFilter: Filter, - forceExplicitReconstruction: b32, -} - -SamplerYcbcrConversionInfo :: struct { - sType: StructureType, - pNext: rawptr, - conversion: SamplerYcbcrConversion, -} - -BindImagePlaneMemoryInfo :: struct { - sType: StructureType, - pNext: rawptr, - planeAspect: ImageAspectFlags, -} - -ImagePlaneMemoryRequirementsInfo :: struct { - sType: StructureType, - pNext: rawptr, - planeAspect: ImageAspectFlags, -} - -PhysicalDeviceSamplerYcbcrConversionFeatures :: struct { - sType: StructureType, - pNext: rawptr, - samplerYcbcrConversion: b32, -} - -SamplerYcbcrConversionImageFormatProperties :: struct { - sType: StructureType, - pNext: rawptr, - combinedImageSamplerDescriptorCount: u32, -} - -DescriptorUpdateTemplateEntry :: struct { - dstBinding: u32, - dstArrayElement: u32, - descriptorCount: u32, - descriptorType: DescriptorType, - offset: int, - stride: int, -} - -DescriptorUpdateTemplateCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - flags: DescriptorUpdateTemplateCreateFlags, - descriptorUpdateEntryCount: u32, - pDescriptorUpdateEntries: [^]DescriptorUpdateTemplateEntry, - templateType: DescriptorUpdateTemplateType, - descriptorSetLayout: DescriptorSetLayout, - pipelineBindPoint: PipelineBindPoint, - pipelineLayout: PipelineLayout, - set: u32, -} - -ExternalMemoryProperties :: struct { - externalMemoryFeatures: ExternalMemoryFeatureFlags, - exportFromImportedHandleTypes: ExternalMemoryHandleTypeFlags, - compatibleHandleTypes: ExternalMemoryHandleTypeFlags, -} - -PhysicalDeviceExternalImageFormatInfo :: struct { - sType: StructureType, - pNext: rawptr, - handleType: ExternalMemoryHandleTypeFlags, -} - -ExternalImageFormatProperties :: struct { - sType: StructureType, - pNext: rawptr, - externalMemoryProperties: ExternalMemoryProperties, -} - -PhysicalDeviceExternalBufferInfo :: struct { - sType: StructureType, - pNext: rawptr, - flags: BufferCreateFlags, - usage: BufferUsageFlags, - handleType: ExternalMemoryHandleTypeFlags, -} - -ExternalBufferProperties :: struct { - sType: StructureType, - pNext: rawptr, - externalMemoryProperties: ExternalMemoryProperties, -} - -PhysicalDeviceIDProperties :: struct { - sType: StructureType, - pNext: rawptr, - deviceUUID: [UUID_SIZE]u8, - driverUUID: [UUID_SIZE]u8, - deviceLUID: [LUID_SIZE]u8, - deviceNodeMask: u32, - deviceLUIDValid: b32, -} - -ExternalMemoryImageCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - handleTypes: ExternalMemoryHandleTypeFlags, -} - -ExternalMemoryBufferCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - handleTypes: ExternalMemoryHandleTypeFlags, -} - -ExportMemoryAllocateInfo :: struct { - sType: StructureType, - pNext: rawptr, - handleTypes: ExternalMemoryHandleTypeFlags, -} - -PhysicalDeviceExternalFenceInfo :: struct { - sType: StructureType, - pNext: rawptr, - handleType: ExternalFenceHandleTypeFlags, -} - -ExternalFenceProperties :: struct { - sType: StructureType, - pNext: rawptr, - exportFromImportedHandleTypes: ExternalFenceHandleTypeFlags, - compatibleHandleTypes: ExternalFenceHandleTypeFlags, - externalFenceFeatures: ExternalFenceFeatureFlags, -} - -ExportFenceCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - handleTypes: ExternalFenceHandleTypeFlags, -} - -ExportSemaphoreCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - handleTypes: ExternalSemaphoreHandleTypeFlags, -} - -PhysicalDeviceExternalSemaphoreInfo :: struct { - sType: StructureType, - pNext: rawptr, - handleType: ExternalSemaphoreHandleTypeFlags, -} - -ExternalSemaphoreProperties :: struct { - sType: StructureType, - pNext: rawptr, - exportFromImportedHandleTypes: ExternalSemaphoreHandleTypeFlags, - compatibleHandleTypes: ExternalSemaphoreHandleTypeFlags, - externalSemaphoreFeatures: ExternalSemaphoreFeatureFlags, -} - -PhysicalDeviceMaintenance3Properties :: struct { - sType: StructureType, - pNext: rawptr, - maxPerSetDescriptors: u32, - maxMemoryAllocationSize: DeviceSize, -} - -DescriptorSetLayoutSupport :: struct { - sType: StructureType, - pNext: rawptr, - supported: b32, -} - -PhysicalDeviceShaderDrawParametersFeatures :: struct { - sType: StructureType, - pNext: rawptr, - shaderDrawParameters: b32, -} - -PhysicalDeviceVulkan11Features :: struct { - sType: StructureType, - pNext: rawptr, - storageBuffer16BitAccess: b32, - uniformAndStorageBuffer16BitAccess: b32, - storagePushConstant16: b32, - storageInputOutput16: b32, - multiview: b32, - multiviewGeometryShader: b32, - multiviewTessellationShader: b32, - variablePointersStorageBuffer: b32, - variablePointers: b32, - protectedMemory: b32, - samplerYcbcrConversion: b32, - shaderDrawParameters: b32, -} - -PhysicalDeviceVulkan11Properties :: struct { - sType: StructureType, - pNext: rawptr, - deviceUUID: [UUID_SIZE]u8, - driverUUID: [UUID_SIZE]u8, - deviceLUID: [LUID_SIZE]u8, - deviceNodeMask: u32, - deviceLUIDValid: b32, - subgroupSize: u32, - subgroupSupportedStages: ShaderStageFlags, - subgroupSupportedOperations: SubgroupFeatureFlags, - subgroupQuadOperationsInAllStages: b32, - pointClippingBehavior: PointClippingBehavior, - maxMultiviewViewCount: u32, - maxMultiviewInstanceIndex: u32, - protectedNoFault: b32, - maxPerSetDescriptors: u32, - maxMemoryAllocationSize: DeviceSize, -} - -PhysicalDeviceVulkan12Features :: struct { - sType: StructureType, - pNext: rawptr, - samplerMirrorClampToEdge: b32, - drawIndirectCount: b32, - storageBuffer8BitAccess: b32, - uniformAndStorageBuffer8BitAccess: b32, - storagePushConstant8: b32, - shaderBufferInt64Atomics: b32, - shaderSharedInt64Atomics: b32, - shaderFloat16: b32, - shaderInt8: b32, - descriptorIndexing: b32, - shaderInputAttachmentArrayDynamicIndexing: b32, - shaderUniformTexelBufferArrayDynamicIndexing: b32, - shaderStorageTexelBufferArrayDynamicIndexing: b32, - shaderUniformBufferArrayNonUniformIndexing: b32, - shaderSampledImageArrayNonUniformIndexing: b32, - shaderStorageBufferArrayNonUniformIndexing: b32, - shaderStorageImageArrayNonUniformIndexing: b32, - shaderInputAttachmentArrayNonUniformIndexing: b32, - shaderUniformTexelBufferArrayNonUniformIndexing: b32, - shaderStorageTexelBufferArrayNonUniformIndexing: b32, - descriptorBindingUniformBufferUpdateAfterBind: b32, - descriptorBindingSampledImageUpdateAfterBind: b32, - descriptorBindingStorageImageUpdateAfterBind: b32, - descriptorBindingStorageBufferUpdateAfterBind: b32, - descriptorBindingUniformTexelBufferUpdateAfterBind: b32, - descriptorBindingStorageTexelBufferUpdateAfterBind: b32, - descriptorBindingUpdateUnusedWhilePending: b32, - descriptorBindingPartiallyBound: b32, - descriptorBindingVariableDescriptorCount: b32, - runtimeDescriptorArray: b32, - samplerFilterMinmax: b32, - scalarBlockLayout: b32, - imagelessFramebuffer: b32, - uniformBufferStandardLayout: b32, - shaderSubgroupExtendedTypes: b32, - separateDepthStencilLayouts: b32, - hostQueryReset: b32, - timelineSemaphore: b32, - bufferDeviceAddress: b32, - bufferDeviceAddressCaptureReplay: b32, - bufferDeviceAddressMultiDevice: b32, - vulkanMemoryModel: b32, - vulkanMemoryModelDeviceScope: b32, - vulkanMemoryModelAvailabilityVisibilityChains: b32, - shaderOutputViewportIndex: b32, - shaderOutputLayer: b32, - subgroupBroadcastDynamicId: b32, -} - -ConformanceVersion :: struct { - major: u8, - minor: u8, - subminor: u8, - patch: u8, -} - -PhysicalDeviceVulkan12Properties :: struct { - sType: StructureType, - pNext: rawptr, - driverID: DriverId, - driverName: [MAX_DRIVER_NAME_SIZE]byte, - driverInfo: [MAX_DRIVER_INFO_SIZE]byte, - conformanceVersion: ConformanceVersion, - denormBehaviorIndependence: ShaderFloatControlsIndependence, - roundingModeIndependence: ShaderFloatControlsIndependence, - shaderSignedZeroInfNanPreserveFloat16: b32, - shaderSignedZeroInfNanPreserveFloat32: b32, - shaderSignedZeroInfNanPreserveFloat64: b32, - shaderDenormPreserveFloat16: b32, - shaderDenormPreserveFloat32: b32, - shaderDenormPreserveFloat64: b32, - shaderDenormFlushToZeroFloat16: b32, - shaderDenormFlushToZeroFloat32: b32, - shaderDenormFlushToZeroFloat64: b32, - shaderRoundingModeRTEFloat16: b32, - shaderRoundingModeRTEFloat32: b32, - shaderRoundingModeRTEFloat64: b32, - shaderRoundingModeRTZFloat16: b32, - shaderRoundingModeRTZFloat32: b32, - shaderRoundingModeRTZFloat64: b32, - maxUpdateAfterBindDescriptorsInAllPools: u32, - shaderUniformBufferArrayNonUniformIndexingNative: b32, - shaderSampledImageArrayNonUniformIndexingNative: b32, - shaderStorageBufferArrayNonUniformIndexingNative: b32, - shaderStorageImageArrayNonUniformIndexingNative: b32, - shaderInputAttachmentArrayNonUniformIndexingNative: b32, - robustBufferAccessUpdateAfterBind: b32, - quadDivergentImplicitLod: b32, - maxPerStageDescriptorUpdateAfterBindSamplers: u32, - maxPerStageDescriptorUpdateAfterBindUniformBuffers: u32, - maxPerStageDescriptorUpdateAfterBindStorageBuffers: u32, - maxPerStageDescriptorUpdateAfterBindSampledImages: u32, - maxPerStageDescriptorUpdateAfterBindStorageImages: u32, - maxPerStageDescriptorUpdateAfterBindInputAttachments: u32, - maxPerStageUpdateAfterBindResources: u32, - maxDescriptorSetUpdateAfterBindSamplers: u32, - maxDescriptorSetUpdateAfterBindUniformBuffers: u32, - maxDescriptorSetUpdateAfterBindUniformBuffersDynamic: u32, - maxDescriptorSetUpdateAfterBindStorageBuffers: u32, - maxDescriptorSetUpdateAfterBindStorageBuffersDynamic: u32, - maxDescriptorSetUpdateAfterBindSampledImages: u32, - maxDescriptorSetUpdateAfterBindStorageImages: u32, - maxDescriptorSetUpdateAfterBindInputAttachments: u32, - supportedDepthResolveModes: ResolveModeFlags, - supportedStencilResolveModes: ResolveModeFlags, - independentResolveNone: b32, - independentResolve: b32, - filterMinmaxSingleComponentFormats: b32, - filterMinmaxImageComponentMapping: b32, - maxTimelineSemaphoreValueDifference: u64, - framebufferIntegerColorSampleCounts: SampleCountFlags, -} - -ImageFormatListCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - viewFormatCount: u32, - pViewFormats: [^]Format, -} - -AttachmentDescription2 :: struct { - sType: StructureType, - pNext: rawptr, - flags: AttachmentDescriptionFlags, - format: Format, - samples: SampleCountFlags, - loadOp: AttachmentLoadOp, - storeOp: AttachmentStoreOp, - stencilLoadOp: AttachmentLoadOp, - stencilStoreOp: AttachmentStoreOp, - initialLayout: ImageLayout, - finalLayout: ImageLayout, -} - -AttachmentReference2 :: struct { - sType: StructureType, - pNext: rawptr, - attachment: u32, - layout: ImageLayout, - aspectMask: ImageAspectFlags, -} - -SubpassDescription2 :: struct { - sType: StructureType, - pNext: rawptr, - flags: SubpassDescriptionFlags, - pipelineBindPoint: PipelineBindPoint, - viewMask: u32, - inputAttachmentCount: u32, - pInputAttachments: [^]AttachmentReference2, - colorAttachmentCount: u32, - pColorAttachments: [^]AttachmentReference2, - pResolveAttachments: [^]AttachmentReference2, - pDepthStencilAttachment: ^AttachmentReference2, - preserveAttachmentCount: u32, - pPreserveAttachments: [^]u32, -} - -SubpassDependency2 :: struct { - sType: StructureType, - pNext: rawptr, - srcSubpass: u32, - dstSubpass: u32, - srcStageMask: PipelineStageFlags, - dstStageMask: PipelineStageFlags, - srcAccessMask: AccessFlags, - dstAccessMask: AccessFlags, - dependencyFlags: DependencyFlags, - viewOffset: i32, -} - -RenderPassCreateInfo2 :: struct { - sType: StructureType, - pNext: rawptr, - flags: RenderPassCreateFlags, - attachmentCount: u32, - pAttachments: [^]AttachmentDescription2, - subpassCount: u32, - pSubpasses: [^]SubpassDescription2, - dependencyCount: u32, - pDependencies: [^]SubpassDependency2, - correlatedViewMaskCount: u32, - pCorrelatedViewMasks: [^]u32, -} - -SubpassBeginInfo :: struct { - sType: StructureType, - pNext: rawptr, - contents: SubpassContents, -} - -SubpassEndInfo :: struct { - sType: StructureType, - pNext: rawptr, -} - -PhysicalDevice8BitStorageFeatures :: struct { - sType: StructureType, - pNext: rawptr, - storageBuffer8BitAccess: b32, - uniformAndStorageBuffer8BitAccess: b32, - storagePushConstant8: b32, -} - -PhysicalDeviceDriverProperties :: struct { - sType: StructureType, - pNext: rawptr, - driverID: DriverId, - driverName: [MAX_DRIVER_NAME_SIZE]byte, - driverInfo: [MAX_DRIVER_INFO_SIZE]byte, - conformanceVersion: ConformanceVersion, -} - -PhysicalDeviceShaderAtomicInt64Features :: struct { - sType: StructureType, - pNext: rawptr, - shaderBufferInt64Atomics: b32, - shaderSharedInt64Atomics: b32, -} - -PhysicalDeviceShaderFloat16Int8Features :: struct { - sType: StructureType, - pNext: rawptr, - shaderFloat16: b32, - shaderInt8: b32, -} - -PhysicalDeviceFloatControlsProperties :: struct { - sType: StructureType, - pNext: rawptr, - denormBehaviorIndependence: ShaderFloatControlsIndependence, - roundingModeIndependence: ShaderFloatControlsIndependence, - shaderSignedZeroInfNanPreserveFloat16: b32, - shaderSignedZeroInfNanPreserveFloat32: b32, - shaderSignedZeroInfNanPreserveFloat64: b32, - shaderDenormPreserveFloat16: b32, - shaderDenormPreserveFloat32: b32, - shaderDenormPreserveFloat64: b32, - shaderDenormFlushToZeroFloat16: b32, - shaderDenormFlushToZeroFloat32: b32, - shaderDenormFlushToZeroFloat64: b32, - shaderRoundingModeRTEFloat16: b32, - shaderRoundingModeRTEFloat32: b32, - shaderRoundingModeRTEFloat64: b32, - shaderRoundingModeRTZFloat16: b32, - shaderRoundingModeRTZFloat32: b32, - shaderRoundingModeRTZFloat64: b32, -} - -DescriptorSetLayoutBindingFlagsCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - bindingCount: u32, - pBindingFlags: [^]DescriptorBindingFlags, -} - -PhysicalDeviceDescriptorIndexingFeatures :: struct { - sType: StructureType, - pNext: rawptr, - shaderInputAttachmentArrayDynamicIndexing: b32, - shaderUniformTexelBufferArrayDynamicIndexing: b32, - shaderStorageTexelBufferArrayDynamicIndexing: b32, - shaderUniformBufferArrayNonUniformIndexing: b32, - shaderSampledImageArrayNonUniformIndexing: b32, - shaderStorageBufferArrayNonUniformIndexing: b32, - shaderStorageImageArrayNonUniformIndexing: b32, - shaderInputAttachmentArrayNonUniformIndexing: b32, - shaderUniformTexelBufferArrayNonUniformIndexing: b32, - shaderStorageTexelBufferArrayNonUniformIndexing: b32, - descriptorBindingUniformBufferUpdateAfterBind: b32, - descriptorBindingSampledImageUpdateAfterBind: b32, - descriptorBindingStorageImageUpdateAfterBind: b32, - descriptorBindingStorageBufferUpdateAfterBind: b32, - descriptorBindingUniformTexelBufferUpdateAfterBind: b32, - descriptorBindingStorageTexelBufferUpdateAfterBind: b32, - descriptorBindingUpdateUnusedWhilePending: b32, - descriptorBindingPartiallyBound: b32, - descriptorBindingVariableDescriptorCount: b32, - runtimeDescriptorArray: b32, -} - -PhysicalDeviceDescriptorIndexingProperties :: struct { - sType: StructureType, - pNext: rawptr, - maxUpdateAfterBindDescriptorsInAllPools: u32, - shaderUniformBufferArrayNonUniformIndexingNative: b32, - shaderSampledImageArrayNonUniformIndexingNative: b32, - shaderStorageBufferArrayNonUniformIndexingNative: b32, - shaderStorageImageArrayNonUniformIndexingNative: b32, - shaderInputAttachmentArrayNonUniformIndexingNative: b32, - robustBufferAccessUpdateAfterBind: b32, - quadDivergentImplicitLod: b32, - maxPerStageDescriptorUpdateAfterBindSamplers: u32, - maxPerStageDescriptorUpdateAfterBindUniformBuffers: u32, - maxPerStageDescriptorUpdateAfterBindStorageBuffers: u32, - maxPerStageDescriptorUpdateAfterBindSampledImages: u32, - maxPerStageDescriptorUpdateAfterBindStorageImages: u32, - maxPerStageDescriptorUpdateAfterBindInputAttachments: u32, - maxPerStageUpdateAfterBindResources: u32, - maxDescriptorSetUpdateAfterBindSamplers: u32, - maxDescriptorSetUpdateAfterBindUniformBuffers: u32, - maxDescriptorSetUpdateAfterBindUniformBuffersDynamic: u32, - maxDescriptorSetUpdateAfterBindStorageBuffers: u32, - maxDescriptorSetUpdateAfterBindStorageBuffersDynamic: u32, - maxDescriptorSetUpdateAfterBindSampledImages: u32, - maxDescriptorSetUpdateAfterBindStorageImages: u32, - maxDescriptorSetUpdateAfterBindInputAttachments: u32, -} - -DescriptorSetVariableDescriptorCountAllocateInfo :: struct { - sType: StructureType, - pNext: rawptr, - descriptorSetCount: u32, - pDescriptorCounts: [^]u32, -} - -DescriptorSetVariableDescriptorCountLayoutSupport :: struct { - sType: StructureType, - pNext: rawptr, - maxVariableDescriptorCount: u32, -} - -SubpassDescriptionDepthStencilResolve :: struct { - sType: StructureType, - pNext: rawptr, - depthResolveMode: ResolveModeFlags, - stencilResolveMode: ResolveModeFlags, - pDepthStencilResolveAttachment: ^AttachmentReference2, -} - -PhysicalDeviceDepthStencilResolveProperties :: struct { - sType: StructureType, - pNext: rawptr, - supportedDepthResolveModes: ResolveModeFlags, - supportedStencilResolveModes: ResolveModeFlags, - independentResolveNone: b32, - independentResolve: b32, -} - -PhysicalDeviceScalarBlockLayoutFeatures :: struct { - sType: StructureType, - pNext: rawptr, - scalarBlockLayout: b32, -} - -ImageStencilUsageCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - stencilUsage: ImageUsageFlags, -} - -SamplerReductionModeCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - reductionMode: SamplerReductionMode, -} - -PhysicalDeviceSamplerFilterMinmaxProperties :: struct { - sType: StructureType, - pNext: rawptr, - filterMinmaxSingleComponentFormats: b32, - filterMinmaxImageComponentMapping: b32, -} - -PhysicalDeviceVulkanMemoryModelFeatures :: struct { - sType: StructureType, - pNext: rawptr, - vulkanMemoryModel: b32, - vulkanMemoryModelDeviceScope: b32, - vulkanMemoryModelAvailabilityVisibilityChains: b32, -} - -PhysicalDeviceImagelessFramebufferFeatures :: struct { - sType: StructureType, - pNext: rawptr, - imagelessFramebuffer: b32, -} - -FramebufferAttachmentImageInfo :: struct { - sType: StructureType, - pNext: rawptr, - flags: ImageCreateFlags, - usage: ImageUsageFlags, - width: u32, - height: u32, - layerCount: u32, - viewFormatCount: u32, - pViewFormats: [^]Format, -} - -FramebufferAttachmentsCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - attachmentImageInfoCount: u32, - pAttachmentImageInfos: [^]FramebufferAttachmentImageInfo, -} - -RenderPassAttachmentBeginInfo :: struct { - sType: StructureType, - pNext: rawptr, - attachmentCount: u32, - pAttachments: [^]ImageView, -} - -PhysicalDeviceUniformBufferStandardLayoutFeatures :: struct { - sType: StructureType, - pNext: rawptr, - uniformBufferStandardLayout: b32, -} - -PhysicalDeviceShaderSubgroupExtendedTypesFeatures :: struct { - sType: StructureType, - pNext: rawptr, - shaderSubgroupExtendedTypes: b32, -} - -PhysicalDeviceSeparateDepthStencilLayoutsFeatures :: struct { - sType: StructureType, - pNext: rawptr, - separateDepthStencilLayouts: b32, -} - -AttachmentReferenceStencilLayout :: struct { - sType: StructureType, - pNext: rawptr, - stencilLayout: ImageLayout, -} - -AttachmentDescriptionStencilLayout :: struct { - sType: StructureType, - pNext: rawptr, - stencilInitialLayout: ImageLayout, - stencilFinalLayout: ImageLayout, -} - -PhysicalDeviceHostQueryResetFeatures :: struct { - sType: StructureType, - pNext: rawptr, - hostQueryReset: b32, -} - -PhysicalDeviceTimelineSemaphoreFeatures :: struct { - sType: StructureType, - pNext: rawptr, - timelineSemaphore: b32, -} - -PhysicalDeviceTimelineSemaphoreProperties :: struct { - sType: StructureType, - pNext: rawptr, - maxTimelineSemaphoreValueDifference: u64, -} - -SemaphoreTypeCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - semaphoreType: SemaphoreType, - initialValue: u64, -} - -TimelineSemaphoreSubmitInfo :: struct { - sType: StructureType, - pNext: rawptr, - waitSemaphoreValueCount: u32, - pWaitSemaphoreValues: [^]u64, - signalSemaphoreValueCount: u32, - pSignalSemaphoreValues: [^]u64, -} - -SemaphoreWaitInfo :: struct { - sType: StructureType, - pNext: rawptr, - flags: SemaphoreWaitFlags, - semaphoreCount: u32, - pSemaphores: [^]Semaphore, - pValues: [^]u64, -} - -SemaphoreSignalInfo :: struct { - sType: StructureType, - pNext: rawptr, - semaphore: Semaphore, - value: u64, -} - -PhysicalDeviceBufferDeviceAddressFeatures :: struct { - sType: StructureType, - pNext: rawptr, - bufferDeviceAddress: b32, - bufferDeviceAddressCaptureReplay: b32, - bufferDeviceAddressMultiDevice: b32, -} - -BufferDeviceAddressInfo :: struct { - sType: StructureType, - pNext: rawptr, - buffer: Buffer, -} - -BufferOpaqueCaptureAddressCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - opaqueCaptureAddress: u64, -} - -MemoryOpaqueCaptureAddressAllocateInfo :: struct { - sType: StructureType, - pNext: rawptr, - opaqueCaptureAddress: u64, -} - -DeviceMemoryOpaqueCaptureAddressInfo :: struct { - sType: StructureType, - pNext: rawptr, - memory: DeviceMemory, -} - -PhysicalDeviceVulkan13Features :: struct { - sType: StructureType, - pNext: rawptr, - robustImageAccess: b32, - inlineUniformBlock: b32, - descriptorBindingInlineUniformBlockUpdateAfterBind: b32, - pipelineCreationCacheControl: b32, - privateData: b32, - shaderDemoteToHelperInvocation: b32, - shaderTerminateInvocation: b32, - subgroupSizeControl: b32, - computeFullSubgroups: b32, - synchronization2: b32, - textureCompressionASTC_HDR: b32, - shaderZeroInitializeWorkgroupMemory: b32, - dynamicRendering: b32, - shaderIntegerDotProduct: b32, - maintenance4: b32, -} - -PhysicalDeviceVulkan13Properties :: struct { - sType: StructureType, - pNext: rawptr, - minSubgroupSize: u32, - maxSubgroupSize: u32, - maxComputeWorkgroupSubgroups: u32, - requiredSubgroupSizeStages: ShaderStageFlags, - maxInlineUniformBlockSize: u32, - maxPerStageDescriptorInlineUniformBlocks: u32, - maxPerStageDescriptorUpdateAfterBindInlineUniformBlocks: u32, - maxDescriptorSetInlineUniformBlocks: u32, - maxDescriptorSetUpdateAfterBindInlineUniformBlocks: u32, - maxInlineUniformTotalSize: u32, - integerDotProduct8BitUnsignedAccelerated: b32, - integerDotProduct8BitSignedAccelerated: b32, - integerDotProduct8BitMixedSignednessAccelerated: b32, - integerDotProduct4x8BitPackedUnsignedAccelerated: b32, - integerDotProduct4x8BitPackedSignedAccelerated: b32, - integerDotProduct4x8BitPackedMixedSignednessAccelerated: b32, - integerDotProduct16BitUnsignedAccelerated: b32, - integerDotProduct16BitSignedAccelerated: b32, - integerDotProduct16BitMixedSignednessAccelerated: b32, - integerDotProduct32BitUnsignedAccelerated: b32, - integerDotProduct32BitSignedAccelerated: b32, - integerDotProduct32BitMixedSignednessAccelerated: b32, - integerDotProduct64BitUnsignedAccelerated: b32, - integerDotProduct64BitSignedAccelerated: b32, - integerDotProduct64BitMixedSignednessAccelerated: b32, - integerDotProductAccumulatingSaturating8BitUnsignedAccelerated: b32, - integerDotProductAccumulatingSaturating8BitSignedAccelerated: b32, - integerDotProductAccumulatingSaturating8BitMixedSignednessAccelerated: b32, - integerDotProductAccumulatingSaturating4x8BitPackedUnsignedAccelerated: b32, - integerDotProductAccumulatingSaturating4x8BitPackedSignedAccelerated: b32, - integerDotProductAccumulatingSaturating4x8BitPackedMixedSignednessAccelerated: b32, - integerDotProductAccumulatingSaturating16BitUnsignedAccelerated: b32, - integerDotProductAccumulatingSaturating16BitSignedAccelerated: b32, - integerDotProductAccumulatingSaturating16BitMixedSignednessAccelerated: b32, - integerDotProductAccumulatingSaturating32BitUnsignedAccelerated: b32, - integerDotProductAccumulatingSaturating32BitSignedAccelerated: b32, - integerDotProductAccumulatingSaturating32BitMixedSignednessAccelerated: b32, - integerDotProductAccumulatingSaturating64BitUnsignedAccelerated: b32, - integerDotProductAccumulatingSaturating64BitSignedAccelerated: b32, - integerDotProductAccumulatingSaturating64BitMixedSignednessAccelerated: b32, - storageTexelBufferOffsetAlignmentBytes: DeviceSize, - storageTexelBufferOffsetSingleTexelAlignment: b32, - uniformTexelBufferOffsetAlignmentBytes: DeviceSize, - uniformTexelBufferOffsetSingleTexelAlignment: b32, - maxBufferSize: DeviceSize, -} - -PipelineCreationFeedback :: struct { - flags: PipelineCreationFeedbackFlags, - duration: u64, -} - -PipelineCreationFeedbackCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - pPipelineCreationFeedback: ^PipelineCreationFeedback, - pipelineStageCreationFeedbackCount: u32, - pPipelineStageCreationFeedbacks: [^]PipelineCreationFeedback, -} - -PhysicalDeviceShaderTerminateInvocationFeatures :: struct { - sType: StructureType, - pNext: rawptr, - shaderTerminateInvocation: b32, -} - -PhysicalDeviceToolProperties :: struct { - sType: StructureType, - pNext: rawptr, - name: [MAX_EXTENSION_NAME_SIZE]byte, - version: [MAX_EXTENSION_NAME_SIZE]byte, - purposes: ToolPurposeFlags, - description: [MAX_DESCRIPTION_SIZE]byte, - layer: [MAX_EXTENSION_NAME_SIZE]byte, -} - -PhysicalDeviceShaderDemoteToHelperInvocationFeatures :: struct { - sType: StructureType, - pNext: rawptr, - shaderDemoteToHelperInvocation: b32, -} - -PhysicalDevicePrivateDataFeatures :: struct { - sType: StructureType, - pNext: rawptr, - privateData: b32, -} - -DevicePrivateDataCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - privateDataSlotRequestCount: u32, -} - -PrivateDataSlotCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - flags: PrivateDataSlotCreateFlags, -} - -PhysicalDevicePipelineCreationCacheControlFeatures :: struct { - sType: StructureType, - pNext: rawptr, - pipelineCreationCacheControl: b32, -} - -MemoryBarrier2 :: struct { - sType: StructureType, - pNext: rawptr, - srcStageMask: PipelineStageFlags2, - srcAccessMask: AccessFlags2, - dstStageMask: PipelineStageFlags2, - dstAccessMask: AccessFlags2, -} - -BufferMemoryBarrier2 :: struct { - sType: StructureType, - pNext: rawptr, - srcStageMask: PipelineStageFlags2, - srcAccessMask: AccessFlags2, - dstStageMask: PipelineStageFlags2, - dstAccessMask: AccessFlags2, - srcQueueFamilyIndex: u32, - dstQueueFamilyIndex: u32, - buffer: Buffer, - offset: DeviceSize, - size: DeviceSize, -} - -ImageMemoryBarrier2 :: struct { - sType: StructureType, - pNext: rawptr, - srcStageMask: PipelineStageFlags2, - srcAccessMask: AccessFlags2, - dstStageMask: PipelineStageFlags2, - dstAccessMask: AccessFlags2, - oldLayout: ImageLayout, - newLayout: ImageLayout, - srcQueueFamilyIndex: u32, - dstQueueFamilyIndex: u32, - image: Image, - subresourceRange: ImageSubresourceRange, -} - -DependencyInfo :: struct { - sType: StructureType, - pNext: rawptr, - dependencyFlags: DependencyFlags, - memoryBarrierCount: u32, - pMemoryBarriers: [^]MemoryBarrier2, - bufferMemoryBarrierCount: u32, - pBufferMemoryBarriers: [^]BufferMemoryBarrier2, - imageMemoryBarrierCount: u32, - pImageMemoryBarriers: [^]ImageMemoryBarrier2, -} - -SemaphoreSubmitInfo :: struct { - sType: StructureType, - pNext: rawptr, - semaphore: Semaphore, - value: u64, - stageMask: PipelineStageFlags2, - deviceIndex: u32, -} - -CommandBufferSubmitInfo :: struct { - sType: StructureType, - pNext: rawptr, - commandBuffer: CommandBuffer, - deviceMask: u32, -} - -SubmitInfo2 :: struct { - sType: StructureType, - pNext: rawptr, - flags: SubmitFlags, - waitSemaphoreInfoCount: u32, - pWaitSemaphoreInfos: [^]SemaphoreSubmitInfo, - commandBufferInfoCount: u32, - pCommandBufferInfos: [^]CommandBufferSubmitInfo, - signalSemaphoreInfoCount: u32, - pSignalSemaphoreInfos: [^]SemaphoreSubmitInfo, -} - -PhysicalDeviceSynchronization2Features :: struct { - sType: StructureType, - pNext: rawptr, - synchronization2: b32, -} - -PhysicalDeviceZeroInitializeWorkgroupMemoryFeatures :: struct { - sType: StructureType, - pNext: rawptr, - shaderZeroInitializeWorkgroupMemory: b32, -} - -PhysicalDeviceImageRobustnessFeatures :: struct { - sType: StructureType, - pNext: rawptr, - robustImageAccess: b32, -} - -BufferCopy2 :: struct { - sType: StructureType, - pNext: rawptr, - srcOffset: DeviceSize, - dstOffset: DeviceSize, - size: DeviceSize, -} - -CopyBufferInfo2 :: struct { - sType: StructureType, - pNext: rawptr, - srcBuffer: Buffer, - dstBuffer: Buffer, - regionCount: u32, - pRegions: [^]BufferCopy2, -} - -ImageCopy2 :: struct { - sType: StructureType, - pNext: rawptr, - srcSubresource: ImageSubresourceLayers, - srcOffset: Offset3D, - dstSubresource: ImageSubresourceLayers, - dstOffset: Offset3D, - extent: Extent3D, -} - -CopyImageInfo2 :: struct { - sType: StructureType, - pNext: rawptr, - srcImage: Image, - srcImageLayout: ImageLayout, - dstImage: Image, - dstImageLayout: ImageLayout, - regionCount: u32, - pRegions: [^]ImageCopy2, -} - -BufferImageCopy2 :: struct { - sType: StructureType, - pNext: rawptr, - bufferOffset: DeviceSize, - bufferRowLength: u32, - bufferImageHeight: u32, - imageSubresource: ImageSubresourceLayers, - imageOffset: Offset3D, - imageExtent: Extent3D, -} - -CopyBufferToImageInfo2 :: struct { - sType: StructureType, - pNext: rawptr, - srcBuffer: Buffer, - dstImage: Image, - dstImageLayout: ImageLayout, - regionCount: u32, - pRegions: [^]BufferImageCopy2, -} - -CopyImageToBufferInfo2 :: struct { - sType: StructureType, - pNext: rawptr, - srcImage: Image, - srcImageLayout: ImageLayout, - dstBuffer: Buffer, - regionCount: u32, - pRegions: [^]BufferImageCopy2, -} - -ImageBlit2 :: struct { - sType: StructureType, - pNext: rawptr, - srcSubresource: ImageSubresourceLayers, - srcOffsets: [2]Offset3D, - dstSubresource: ImageSubresourceLayers, - dstOffsets: [2]Offset3D, -} - -BlitImageInfo2 :: struct { - sType: StructureType, - pNext: rawptr, - srcImage: Image, - srcImageLayout: ImageLayout, - dstImage: Image, - dstImageLayout: ImageLayout, - regionCount: u32, - pRegions: [^]ImageBlit2, - filter: Filter, -} - -ImageResolve2 :: struct { - sType: StructureType, - pNext: rawptr, - srcSubresource: ImageSubresourceLayers, - srcOffset: Offset3D, - dstSubresource: ImageSubresourceLayers, - dstOffset: Offset3D, - extent: Extent3D, -} - -ResolveImageInfo2 :: struct { - sType: StructureType, - pNext: rawptr, - srcImage: Image, - srcImageLayout: ImageLayout, - dstImage: Image, - dstImageLayout: ImageLayout, - regionCount: u32, - pRegions: [^]ImageResolve2, -} - -PhysicalDeviceSubgroupSizeControlFeatures :: struct { - sType: StructureType, - pNext: rawptr, - subgroupSizeControl: b32, - computeFullSubgroups: b32, -} - -PhysicalDeviceSubgroupSizeControlProperties :: struct { - sType: StructureType, - pNext: rawptr, - minSubgroupSize: u32, - maxSubgroupSize: u32, - maxComputeWorkgroupSubgroups: u32, - requiredSubgroupSizeStages: ShaderStageFlags, -} - -PipelineShaderStageRequiredSubgroupSizeCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - requiredSubgroupSize: u32, -} - -PhysicalDeviceInlineUniformBlockFeatures :: struct { - sType: StructureType, - pNext: rawptr, - inlineUniformBlock: b32, - descriptorBindingInlineUniformBlockUpdateAfterBind: b32, -} - -PhysicalDeviceInlineUniformBlockProperties :: struct { - sType: StructureType, - pNext: rawptr, - maxInlineUniformBlockSize: u32, - maxPerStageDescriptorInlineUniformBlocks: u32, - maxPerStageDescriptorUpdateAfterBindInlineUniformBlocks: u32, - maxDescriptorSetInlineUniformBlocks: u32, - maxDescriptorSetUpdateAfterBindInlineUniformBlocks: u32, -} - -WriteDescriptorSetInlineUniformBlock :: struct { - sType: StructureType, - pNext: rawptr, - dataSize: u32, - pData: rawptr, -} - -DescriptorPoolInlineUniformBlockCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - maxInlineUniformBlockBindings: u32, -} - -PhysicalDeviceTextureCompressionASTCHDRFeatures :: struct { - sType: StructureType, - pNext: rawptr, - textureCompressionASTC_HDR: b32, -} - -RenderingAttachmentInfo :: struct { - sType: StructureType, - pNext: rawptr, - imageView: ImageView, - imageLayout: ImageLayout, - resolveMode: ResolveModeFlags, - resolveImageView: ImageView, - resolveImageLayout: ImageLayout, - loadOp: AttachmentLoadOp, - storeOp: AttachmentStoreOp, - clearValue: ClearValue, -} - -RenderingInfo :: struct { - sType: StructureType, - pNext: rawptr, - flags: RenderingFlags, - renderArea: Rect2D, - layerCount: u32, - viewMask: u32, - colorAttachmentCount: u32, - pColorAttachments: [^]RenderingAttachmentInfo, - pDepthAttachment: ^RenderingAttachmentInfo, - pStencilAttachment: ^RenderingAttachmentInfo, -} - -PipelineRenderingCreateInfo :: struct { - sType: StructureType, - pNext: rawptr, - viewMask: u32, - colorAttachmentCount: u32, - pColorAttachmentFormats: [^]Format, - depthAttachmentFormat: Format, - stencilAttachmentFormat: Format, -} - -PhysicalDeviceDynamicRenderingFeatures :: struct { - sType: StructureType, - pNext: rawptr, - dynamicRendering: b32, -} - -CommandBufferInheritanceRenderingInfo :: struct { - sType: StructureType, - pNext: rawptr, - flags: RenderingFlags, - viewMask: u32, - colorAttachmentCount: u32, - pColorAttachmentFormats: [^]Format, - depthAttachmentFormat: Format, - stencilAttachmentFormat: Format, - rasterizationSamples: SampleCountFlags, -} - -PhysicalDeviceShaderIntegerDotProductFeatures :: struct { - sType: StructureType, - pNext: rawptr, - shaderIntegerDotProduct: b32, -} - -PhysicalDeviceShaderIntegerDotProductProperties :: struct { - sType: StructureType, - pNext: rawptr, - integerDotProduct8BitUnsignedAccelerated: b32, - integerDotProduct8BitSignedAccelerated: b32, - integerDotProduct8BitMixedSignednessAccelerated: b32, - integerDotProduct4x8BitPackedUnsignedAccelerated: b32, - integerDotProduct4x8BitPackedSignedAccelerated: b32, - integerDotProduct4x8BitPackedMixedSignednessAccelerated: b32, - integerDotProduct16BitUnsignedAccelerated: b32, - integerDotProduct16BitSignedAccelerated: b32, - integerDotProduct16BitMixedSignednessAccelerated: b32, - integerDotProduct32BitUnsignedAccelerated: b32, - integerDotProduct32BitSignedAccelerated: b32, - integerDotProduct32BitMixedSignednessAccelerated: b32, - integerDotProduct64BitUnsignedAccelerated: b32, - integerDotProduct64BitSignedAccelerated: b32, - integerDotProduct64BitMixedSignednessAccelerated: b32, - integerDotProductAccumulatingSaturating8BitUnsignedAccelerated: b32, - integerDotProductAccumulatingSaturating8BitSignedAccelerated: b32, - integerDotProductAccumulatingSaturating8BitMixedSignednessAccelerated: b32, - integerDotProductAccumulatingSaturating4x8BitPackedUnsignedAccelerated: b32, - integerDotProductAccumulatingSaturating4x8BitPackedSignedAccelerated: b32, - integerDotProductAccumulatingSaturating4x8BitPackedMixedSignednessAccelerated: b32, - integerDotProductAccumulatingSaturating16BitUnsignedAccelerated: b32, - integerDotProductAccumulatingSaturating16BitSignedAccelerated: b32, - integerDotProductAccumulatingSaturating16BitMixedSignednessAccelerated: b32, - integerDotProductAccumulatingSaturating32BitUnsignedAccelerated: b32, - integerDotProductAccumulatingSaturating32BitSignedAccelerated: b32, - integerDotProductAccumulatingSaturating32BitMixedSignednessAccelerated: b32, - integerDotProductAccumulatingSaturating64BitUnsignedAccelerated: b32, - integerDotProductAccumulatingSaturating64BitSignedAccelerated: b32, - integerDotProductAccumulatingSaturating64BitMixedSignednessAccelerated: b32, -} - -PhysicalDeviceTexelBufferAlignmentProperties :: struct { - sType: StructureType, - pNext: rawptr, - storageTexelBufferOffsetAlignmentBytes: DeviceSize, - storageTexelBufferOffsetSingleTexelAlignment: b32, - uniformTexelBufferOffsetAlignmentBytes: DeviceSize, - uniformTexelBufferOffsetSingleTexelAlignment: b32, -} - -FormatProperties3 :: struct { - sType: StructureType, - pNext: rawptr, - linearTilingFeatures: FormatFeatureFlags2, - optimalTilingFeatures: FormatFeatureFlags2, - bufferFeatures: FormatFeatureFlags2, -} - -PhysicalDeviceMaintenance4Features :: struct { - sType: StructureType, - pNext: rawptr, - maintenance4: b32, -} - -PhysicalDeviceMaintenance4Properties :: struct { - sType: StructureType, - pNext: rawptr, - maxBufferSize: DeviceSize, -} - -DeviceBufferMemoryRequirements :: struct { - sType: StructureType, - pNext: rawptr, - pCreateInfo: ^BufferCreateInfo, -} - -DeviceImageMemoryRequirements :: struct { - sType: StructureType, - pNext: rawptr, - pCreateInfo: ^ImageCreateInfo, - planeAspect: ImageAspectFlags, -} - -SurfaceCapabilitiesKHR :: struct { - minImageCount: u32, - maxImageCount: u32, - currentExtent: Extent2D, - minImageExtent: Extent2D, - maxImageExtent: Extent2D, - maxImageArrayLayers: u32, - supportedTransforms: SurfaceTransformFlagsKHR, - currentTransform: SurfaceTransformFlagsKHR, - supportedCompositeAlpha: CompositeAlphaFlagsKHR, - supportedUsageFlags: ImageUsageFlags, -} - -SurfaceFormatKHR :: struct { - format: Format, - colorSpace: ColorSpaceKHR, -} - -SwapchainCreateInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - flags: SwapchainCreateFlagsKHR, - surface: SurfaceKHR, - minImageCount: u32, - imageFormat: Format, - imageColorSpace: ColorSpaceKHR, - imageExtent: Extent2D, - imageArrayLayers: u32, - imageUsage: ImageUsageFlags, - imageSharingMode: SharingMode, - queueFamilyIndexCount: u32, - pQueueFamilyIndices: [^]u32, - preTransform: SurfaceTransformFlagsKHR, - compositeAlpha: CompositeAlphaFlagsKHR, - presentMode: PresentModeKHR, - clipped: b32, - oldSwapchain: SwapchainKHR, -} - -PresentInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - waitSemaphoreCount: u32, - pWaitSemaphores: [^]Semaphore, - swapchainCount: u32, - pSwapchains: [^]SwapchainKHR, - pImageIndices: [^]u32, - pResults: [^]Result, -} - -ImageSwapchainCreateInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - swapchain: SwapchainKHR, -} - -BindImageMemorySwapchainInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - swapchain: SwapchainKHR, - imageIndex: u32, -} - -AcquireNextImageInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - swapchain: SwapchainKHR, - timeout: u64, - semaphore: Semaphore, - fence: Fence, - deviceMask: u32, -} - -DeviceGroupPresentCapabilitiesKHR :: struct { - sType: StructureType, - pNext: rawptr, - presentMask: [MAX_DEVICE_GROUP_SIZE]u32, - modes: DeviceGroupPresentModeFlagsKHR, -} - -DeviceGroupPresentInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - swapchainCount: u32, - pDeviceMasks: [^]u32, - mode: DeviceGroupPresentModeFlagsKHR, -} - -DeviceGroupSwapchainCreateInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - modes: DeviceGroupPresentModeFlagsKHR, -} - -DisplayModeParametersKHR :: struct { - visibleRegion: Extent2D, - refreshRate: u32, -} - -DisplayModeCreateInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - flags: DisplayModeCreateFlagsKHR, - parameters: DisplayModeParametersKHR, -} - -DisplayModePropertiesKHR :: struct { - displayMode: DisplayModeKHR, - parameters: DisplayModeParametersKHR, -} - -DisplayPlaneCapabilitiesKHR :: struct { - supportedAlpha: DisplayPlaneAlphaFlagsKHR, - minSrcPosition: Offset2D, - maxSrcPosition: Offset2D, - minSrcExtent: Extent2D, - maxSrcExtent: Extent2D, - minDstPosition: Offset2D, - maxDstPosition: Offset2D, - minDstExtent: Extent2D, - maxDstExtent: Extent2D, -} - -DisplayPlanePropertiesKHR :: struct { - currentDisplay: DisplayKHR, - currentStackIndex: u32, -} - -DisplayPropertiesKHR :: struct { - display: DisplayKHR, - displayName: cstring, - physicalDimensions: Extent2D, - physicalResolution: Extent2D, - supportedTransforms: SurfaceTransformFlagsKHR, - planeReorderPossible: b32, - persistentContent: b32, -} - -DisplaySurfaceCreateInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - flags: DisplaySurfaceCreateFlagsKHR, - displayMode: DisplayModeKHR, - planeIndex: u32, - planeStackIndex: u32, - transform: SurfaceTransformFlagsKHR, - globalAlpha: f32, - alphaMode: DisplayPlaneAlphaFlagsKHR, - imageExtent: Extent2D, -} - -DisplayPresentInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - srcRect: Rect2D, - dstRect: Rect2D, - persistent: b32, -} - -RenderingFragmentShadingRateAttachmentInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - imageView: ImageView, - imageLayout: ImageLayout, - shadingRateAttachmentTexelSize: Extent2D, -} - -RenderingFragmentDensityMapAttachmentInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - imageView: ImageView, - imageLayout: ImageLayout, -} - -AttachmentSampleCountInfoAMD :: struct { - sType: StructureType, - pNext: rawptr, - colorAttachmentCount: u32, - pColorAttachmentSamples: [^]SampleCountFlags, - depthStencilAttachmentSamples: SampleCountFlags, -} - -MultiviewPerViewAttributesInfoNVX :: struct { - sType: StructureType, - pNext: rawptr, - perViewAttributes: b32, - perViewAttributesPositionXOnly: b32, -} - -ImportMemoryFdInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - handleType: ExternalMemoryHandleTypeFlags, - fd: c.int, -} - -MemoryFdPropertiesKHR :: struct { - sType: StructureType, - pNext: rawptr, - memoryTypeBits: u32, -} - -MemoryGetFdInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - memory: DeviceMemory, - handleType: ExternalMemoryHandleTypeFlags, -} - -ImportSemaphoreFdInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - semaphore: Semaphore, - flags: SemaphoreImportFlags, - handleType: ExternalSemaphoreHandleTypeFlags, - fd: c.int, -} - -SemaphoreGetFdInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - semaphore: Semaphore, - handleType: ExternalSemaphoreHandleTypeFlags, -} - -PhysicalDevicePushDescriptorPropertiesKHR :: struct { - sType: StructureType, - pNext: rawptr, - maxPushDescriptors: u32, -} - -RectLayerKHR :: struct { - offset: Offset2D, - extent: Extent2D, - layer: u32, -} - -PresentRegionKHR :: struct { - rectangleCount: u32, - pRectangles: [^]RectLayerKHR, -} - -PresentRegionsKHR :: struct { - sType: StructureType, - pNext: rawptr, - swapchainCount: u32, - pRegions: [^]PresentRegionKHR, -} - -SharedPresentSurfaceCapabilitiesKHR :: struct { - sType: StructureType, - pNext: rawptr, - sharedPresentSupportedUsageFlags: ImageUsageFlags, -} - -ImportFenceFdInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - fence: Fence, - flags: FenceImportFlags, - handleType: ExternalFenceHandleTypeFlags, - fd: c.int, -} - -FenceGetFdInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - fence: Fence, - handleType: ExternalFenceHandleTypeFlags, -} - -PhysicalDevicePerformanceQueryFeaturesKHR :: struct { - sType: StructureType, - pNext: rawptr, - performanceCounterQueryPools: b32, - performanceCounterMultipleQueryPools: b32, -} - -PhysicalDevicePerformanceQueryPropertiesKHR :: struct { - sType: StructureType, - pNext: rawptr, - allowCommandBufferQueryCopies: b32, -} - -PerformanceCounterKHR :: struct { - sType: StructureType, - pNext: rawptr, - unit: PerformanceCounterUnitKHR, - scope: PerformanceCounterScopeKHR, - storage: PerformanceCounterStorageKHR, - uuid: [UUID_SIZE]u8, -} - -PerformanceCounterDescriptionKHR :: struct { - sType: StructureType, - pNext: rawptr, - flags: PerformanceCounterDescriptionFlagsKHR, - name: [MAX_DESCRIPTION_SIZE]byte, - category: [MAX_DESCRIPTION_SIZE]byte, - description: [MAX_DESCRIPTION_SIZE]byte, -} - -QueryPoolPerformanceCreateInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - queueFamilyIndex: u32, - counterIndexCount: u32, - pCounterIndices: [^]u32, -} - -PerformanceCounterResultKHR :: struct #raw_union { - int32: i32, - int64: i64, - uint32: u32, - uint64: u64, - float32: f32, - float64: f64, -} - -AcquireProfilingLockInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - flags: AcquireProfilingLockFlagsKHR, - timeout: u64, -} - -PerformanceQuerySubmitInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - counterPassIndex: u32, -} - -PhysicalDeviceSurfaceInfo2KHR :: struct { - sType: StructureType, - pNext: rawptr, - surface: SurfaceKHR, -} - -SurfaceCapabilities2KHR :: struct { - sType: StructureType, - pNext: rawptr, - surfaceCapabilities: SurfaceCapabilitiesKHR, -} - -SurfaceFormat2KHR :: struct { - sType: StructureType, - pNext: rawptr, - surfaceFormat: SurfaceFormatKHR, -} - -DisplayProperties2KHR :: struct { - sType: StructureType, - pNext: rawptr, - displayProperties: DisplayPropertiesKHR, -} - -DisplayPlaneProperties2KHR :: struct { - sType: StructureType, - pNext: rawptr, - displayPlaneProperties: DisplayPlanePropertiesKHR, -} - -DisplayModeProperties2KHR :: struct { - sType: StructureType, - pNext: rawptr, - displayModeProperties: DisplayModePropertiesKHR, -} - -DisplayPlaneInfo2KHR :: struct { - sType: StructureType, - pNext: rawptr, - mode: DisplayModeKHR, - planeIndex: u32, -} - -DisplayPlaneCapabilities2KHR :: struct { - sType: StructureType, - pNext: rawptr, - capabilities: DisplayPlaneCapabilitiesKHR, -} - -PhysicalDeviceShaderClockFeaturesKHR :: struct { - sType: StructureType, - pNext: rawptr, - shaderSubgroupClock: b32, - shaderDeviceClock: b32, -} - -DeviceQueueGlobalPriorityCreateInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - globalPriority: QueueGlobalPriorityKHR, -} - -PhysicalDeviceGlobalPriorityQueryFeaturesKHR :: struct { - sType: StructureType, - pNext: rawptr, - globalPriorityQuery: b32, -} - -QueueFamilyGlobalPriorityPropertiesKHR :: struct { - sType: StructureType, - pNext: rawptr, - priorityCount: u32, - priorities: [MAX_GLOBAL_PRIORITY_SIZE_KHR]QueueGlobalPriorityKHR, -} - -FragmentShadingRateAttachmentInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - pFragmentShadingRateAttachment: ^AttachmentReference2, - shadingRateAttachmentTexelSize: Extent2D, -} - -PipelineFragmentShadingRateStateCreateInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - fragmentSize: Extent2D, - combinerOps: [2]FragmentShadingRateCombinerOpKHR, -} - -PhysicalDeviceFragmentShadingRateFeaturesKHR :: struct { - sType: StructureType, - pNext: rawptr, - pipelineFragmentShadingRate: b32, - primitiveFragmentShadingRate: b32, - attachmentFragmentShadingRate: b32, -} - -PhysicalDeviceFragmentShadingRatePropertiesKHR :: struct { - sType: StructureType, - pNext: rawptr, - minFragmentShadingRateAttachmentTexelSize: Extent2D, - maxFragmentShadingRateAttachmentTexelSize: Extent2D, - maxFragmentShadingRateAttachmentTexelSizeAspectRatio: u32, - primitiveFragmentShadingRateWithMultipleViewports: b32, - layeredShadingRateAttachments: b32, - fragmentShadingRateNonTrivialCombinerOps: b32, - maxFragmentSize: Extent2D, - maxFragmentSizeAspectRatio: u32, - maxFragmentShadingRateCoverageSamples: u32, - maxFragmentShadingRateRasterizationSamples: SampleCountFlags, - fragmentShadingRateWithShaderDepthStencilWrites: b32, - fragmentShadingRateWithSampleMask: b32, - fragmentShadingRateWithShaderSampleMask: b32, - fragmentShadingRateWithConservativeRasterization: b32, - fragmentShadingRateWithFragmentShaderInterlock: b32, - fragmentShadingRateWithCustomSampleLocations: b32, - fragmentShadingRateStrictMultiplyCombiner: b32, -} - -PhysicalDeviceFragmentShadingRateKHR :: struct { - sType: StructureType, - pNext: rawptr, - sampleCounts: SampleCountFlags, - fragmentSize: Extent2D, -} - -SurfaceProtectedCapabilitiesKHR :: struct { - sType: StructureType, - pNext: rawptr, - supportsProtected: b32, -} - -PhysicalDevicePresentWaitFeaturesKHR :: struct { - sType: StructureType, - pNext: rawptr, - presentWait: b32, -} - -PhysicalDevicePipelineExecutablePropertiesFeaturesKHR :: struct { - sType: StructureType, - pNext: rawptr, - pipelineExecutableInfo: b32, -} - -PipelineInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - pipeline: Pipeline, -} - -PipelineExecutablePropertiesKHR :: struct { - sType: StructureType, - pNext: rawptr, - stages: ShaderStageFlags, - name: [MAX_DESCRIPTION_SIZE]byte, - description: [MAX_DESCRIPTION_SIZE]byte, - subgroupSize: u32, -} - -PipelineExecutableInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - pipeline: Pipeline, - executableIndex: u32, -} - -PipelineExecutableStatisticValueKHR :: struct #raw_union { - b32: b32, - i64: i64, - u64: u64, - f64: f64, -} - -PipelineExecutableStatisticKHR :: struct { - sType: StructureType, - pNext: rawptr, - name: [MAX_DESCRIPTION_SIZE]byte, - description: [MAX_DESCRIPTION_SIZE]byte, - format: PipelineExecutableStatisticFormatKHR, - value: PipelineExecutableStatisticValueKHR, -} - -PipelineExecutableInternalRepresentationKHR :: struct { - sType: StructureType, - pNext: rawptr, - name: [MAX_DESCRIPTION_SIZE]byte, - description: [MAX_DESCRIPTION_SIZE]byte, - isText: b32, - dataSize: int, - pData: rawptr, -} - -PipelineLibraryCreateInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - libraryCount: u32, - pLibraries: [^]Pipeline, -} - -PresentIdKHR :: struct { - sType: StructureType, - pNext: rawptr, - swapchainCount: u32, - pPresentIds: [^]u64, -} - -PhysicalDevicePresentIdFeaturesKHR :: struct { - sType: StructureType, - pNext: rawptr, - presentId: b32, -} - -QueueFamilyCheckpointProperties2NV :: struct { - sType: StructureType, - pNext: rawptr, - checkpointExecutionStageMask: PipelineStageFlags2, -} - -CheckpointData2NV :: struct { - sType: StructureType, - pNext: rawptr, - stage: PipelineStageFlags2, - pCheckpointMarker: rawptr, -} - -PhysicalDeviceShaderSubgroupUniformControlFlowFeaturesKHR :: struct { - sType: StructureType, - pNext: rawptr, - shaderSubgroupUniformControlFlow: b32, -} - -PhysicalDeviceWorkgroupMemoryExplicitLayoutFeaturesKHR :: struct { - sType: StructureType, - pNext: rawptr, - workgroupMemoryExplicitLayout: b32, - workgroupMemoryExplicitLayoutScalarBlockLayout: b32, - workgroupMemoryExplicitLayout8BitAccess: b32, - workgroupMemoryExplicitLayout16BitAccess: b32, -} - -DebugReportCallbackCreateInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - flags: DebugReportFlagsEXT, - pfnCallback: ProcDebugReportCallbackEXT, - pUserData: rawptr, -} - -PipelineRasterizationStateRasterizationOrderAMD :: struct { - sType: StructureType, - pNext: rawptr, - rasterizationOrder: RasterizationOrderAMD, -} - -DebugMarkerObjectNameInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - objectType: DebugReportObjectTypeEXT, - object: u64, - pObjectName: cstring, -} - -DebugMarkerObjectTagInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - objectType: DebugReportObjectTypeEXT, - object: u64, - tagName: u64, - tagSize: int, - pTag: rawptr, -} - -DebugMarkerMarkerInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - pMarkerName: cstring, - color: [4]f32, -} - -DedicatedAllocationImageCreateInfoNV :: struct { - sType: StructureType, - pNext: rawptr, - dedicatedAllocation: b32, -} - -DedicatedAllocationBufferCreateInfoNV :: struct { - sType: StructureType, - pNext: rawptr, - dedicatedAllocation: b32, -} - -DedicatedAllocationMemoryAllocateInfoNV :: struct { - sType: StructureType, - pNext: rawptr, - image: Image, - buffer: Buffer, -} - -PhysicalDeviceTransformFeedbackFeaturesEXT :: struct { - sType: StructureType, - pNext: rawptr, - transformFeedback: b32, - geometryStreams: b32, -} - -PhysicalDeviceTransformFeedbackPropertiesEXT :: struct { - sType: StructureType, - pNext: rawptr, - maxTransformFeedbackStreams: u32, - maxTransformFeedbackBuffers: u32, - maxTransformFeedbackBufferSize: DeviceSize, - maxTransformFeedbackStreamDataSize: u32, - maxTransformFeedbackBufferDataSize: u32, - maxTransformFeedbackBufferDataStride: u32, - transformFeedbackQueries: b32, - transformFeedbackStreamsLinesTriangles: b32, - transformFeedbackRasterizationStreamSelect: b32, - transformFeedbackDraw: b32, -} - -PipelineRasterizationStateStreamCreateInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - flags: PipelineRasterizationStateStreamCreateFlagsEXT, - rasterizationStream: u32, -} - -CuModuleCreateInfoNVX :: struct { - sType: StructureType, - pNext: rawptr, - dataSize: int, - pData: rawptr, -} - -CuFunctionCreateInfoNVX :: struct { - sType: StructureType, - pNext: rawptr, - module: CuModuleNVX, - pName: cstring, -} - -CuLaunchInfoNVX :: struct { - sType: StructureType, - pNext: rawptr, - function: CuFunctionNVX, - gridDimX: u32, - gridDimY: u32, - gridDimZ: u32, - blockDimX: u32, - blockDimY: u32, - blockDimZ: u32, - sharedMemBytes: u32, - paramCount: int, - pParams: [^]rawptr, - extraCount: int, - pExtras: [^]rawptr, -} - -ImageViewHandleInfoNVX :: struct { - sType: StructureType, - pNext: rawptr, - imageView: ImageView, - descriptorType: DescriptorType, - sampler: Sampler, -} - -ImageViewAddressPropertiesNVX :: struct { - sType: StructureType, - pNext: rawptr, - deviceAddress: DeviceAddress, - size: DeviceSize, -} - -TextureLODGatherFormatPropertiesAMD :: struct { - sType: StructureType, - pNext: rawptr, - supportsTextureGatherLODBiasAMD: b32, -} - -ShaderResourceUsageAMD :: struct { - numUsedVgprs: u32, - numUsedSgprs: u32, - ldsSizePerLocalWorkGroup: u32, - ldsUsageSizeInBytes: int, - scratchMemUsageInBytes: int, -} - -ShaderStatisticsInfoAMD :: struct { - shaderStageMask: ShaderStageFlags, - resourceUsage: ShaderResourceUsageAMD, - numPhysicalVgprs: u32, - numPhysicalSgprs: u32, - numAvailableVgprs: u32, - numAvailableSgprs: u32, - computeWorkGroupSize: [3]u32, -} - -PhysicalDeviceCornerSampledImageFeaturesNV :: struct { - sType: StructureType, - pNext: rawptr, - cornerSampledImage: b32, -} - -ExternalImageFormatPropertiesNV :: struct { - imageFormatProperties: ImageFormatProperties, - externalMemoryFeatures: ExternalMemoryFeatureFlagsNV, - exportFromImportedHandleTypes: ExternalMemoryHandleTypeFlagsNV, - compatibleHandleTypes: ExternalMemoryHandleTypeFlagsNV, -} - -ExternalMemoryImageCreateInfoNV :: struct { - sType: StructureType, - pNext: rawptr, - handleTypes: ExternalMemoryHandleTypeFlagsNV, -} - -ExportMemoryAllocateInfoNV :: struct { - sType: StructureType, - pNext: rawptr, - handleTypes: ExternalMemoryHandleTypeFlagsNV, -} - -ValidationFlagsEXT :: struct { - sType: StructureType, - pNext: rawptr, - disabledValidationCheckCount: u32, - pDisabledValidationChecks: [^]ValidationCheckEXT, -} - -ImageViewASTCDecodeModeEXT :: struct { - sType: StructureType, - pNext: rawptr, - decodeMode: Format, -} - -PhysicalDeviceASTCDecodeFeaturesEXT :: struct { - sType: StructureType, - pNext: rawptr, - decodeModeSharedExponent: b32, -} - -ConditionalRenderingBeginInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - buffer: Buffer, - offset: DeviceSize, - flags: ConditionalRenderingFlagsEXT, -} - -PhysicalDeviceConditionalRenderingFeaturesEXT :: struct { - sType: StructureType, - pNext: rawptr, - conditionalRendering: b32, - inheritedConditionalRendering: b32, -} - -CommandBufferInheritanceConditionalRenderingInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - conditionalRenderingEnable: b32, -} - -ViewportWScalingNV :: struct { - xcoeff: f32, - ycoeff: f32, -} - -PipelineViewportWScalingStateCreateInfoNV :: struct { - sType: StructureType, - pNext: rawptr, - viewportWScalingEnable: b32, - viewportCount: u32, - pViewportWScalings: [^]ViewportWScalingNV, -} - -SurfaceCapabilities2EXT :: struct { - sType: StructureType, - pNext: rawptr, - minImageCount: u32, - maxImageCount: u32, - currentExtent: Extent2D, - minImageExtent: Extent2D, - maxImageExtent: Extent2D, - maxImageArrayLayers: u32, - supportedTransforms: SurfaceTransformFlagsKHR, - currentTransform: SurfaceTransformFlagsKHR, - supportedCompositeAlpha: CompositeAlphaFlagsKHR, - supportedUsageFlags: ImageUsageFlags, - supportedSurfaceCounters: SurfaceCounterFlagsEXT, -} - -DisplayPowerInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - powerState: DisplayPowerStateEXT, -} - -DeviceEventInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - deviceEvent: DeviceEventTypeEXT, -} - -DisplayEventInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - displayEvent: DisplayEventTypeEXT, -} - -SwapchainCounterCreateInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - surfaceCounters: SurfaceCounterFlagsEXT, -} - -RefreshCycleDurationGOOGLE :: struct { - refreshDuration: u64, -} - -PastPresentationTimingGOOGLE :: struct { - presentID: u32, - desiredPresentTime: u64, - actualPresentTime: u64, - earliestPresentTime: u64, - presentMargin: u64, -} - -PresentTimeGOOGLE :: struct { - presentID: u32, - desiredPresentTime: u64, -} - -PresentTimesInfoGOOGLE :: struct { - sType: StructureType, - pNext: rawptr, - swapchainCount: u32, - pTimes: [^]PresentTimeGOOGLE, -} - -PhysicalDeviceMultiviewPerViewAttributesPropertiesNVX :: struct { - sType: StructureType, - pNext: rawptr, - perViewPositionAllComponents: b32, -} - -ViewportSwizzleNV :: struct { - x: ViewportCoordinateSwizzleNV, - y: ViewportCoordinateSwizzleNV, - z: ViewportCoordinateSwizzleNV, - w: ViewportCoordinateSwizzleNV, -} - -PipelineViewportSwizzleStateCreateInfoNV :: struct { - sType: StructureType, - pNext: rawptr, - flags: PipelineViewportSwizzleStateCreateFlagsNV, - viewportCount: u32, - pViewportSwizzles: [^]ViewportSwizzleNV, -} - -PhysicalDeviceDiscardRectanglePropertiesEXT :: struct { - sType: StructureType, - pNext: rawptr, - maxDiscardRectangles: u32, -} - -PipelineDiscardRectangleStateCreateInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - flags: PipelineDiscardRectangleStateCreateFlagsEXT, - discardRectangleMode: DiscardRectangleModeEXT, - discardRectangleCount: u32, - pDiscardRectangles: [^]Rect2D, -} - -PhysicalDeviceConservativeRasterizationPropertiesEXT :: struct { - sType: StructureType, - pNext: rawptr, - primitiveOverestimationSize: f32, - maxExtraPrimitiveOverestimationSize: f32, - extraPrimitiveOverestimationSizeGranularity: f32, - primitiveUnderestimation: b32, - conservativePointAndLineRasterization: b32, - degenerateTrianglesRasterized: b32, - degenerateLinesRasterized: b32, - fullyCoveredFragmentShaderInputVariable: b32, - conservativeRasterizationPostDepthCoverage: b32, -} - -PipelineRasterizationConservativeStateCreateInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - flags: PipelineRasterizationConservativeStateCreateFlagsEXT, - conservativeRasterizationMode: ConservativeRasterizationModeEXT, - extraPrimitiveOverestimationSize: f32, -} - -PhysicalDeviceDepthClipEnableFeaturesEXT :: struct { - sType: StructureType, - pNext: rawptr, - depthClipEnable: b32, -} - -PipelineRasterizationDepthClipStateCreateInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - flags: PipelineRasterizationDepthClipStateCreateFlagsEXT, - depthClipEnable: b32, -} - -XYColorEXT :: struct { - x: f32, - y: f32, -} - -HdrMetadataEXT :: struct { - sType: StructureType, - pNext: rawptr, - displayPrimaryRed: XYColorEXT, - displayPrimaryGreen: XYColorEXT, - displayPrimaryBlue: XYColorEXT, - whitePoint: XYColorEXT, - maxLuminance: f32, - minLuminance: f32, - maxContentLightLevel: f32, - maxFrameAverageLightLevel: f32, -} - -DebugUtilsLabelEXT :: struct { - sType: StructureType, - pNext: rawptr, - pLabelName: cstring, - color: [4]f32, -} - -DebugUtilsObjectNameInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - objectType: ObjectType, - objectHandle: u64, - pObjectName: cstring, -} - -DebugUtilsMessengerCallbackDataEXT :: struct { - sType: StructureType, - pNext: rawptr, - flags: DebugUtilsMessengerCallbackDataFlagsEXT, - pMessageIdName: cstring, - messageIdNumber: i32, - pMessage: cstring, - queueLabelCount: u32, - pQueueLabels: [^]DebugUtilsLabelEXT, - cmdBufLabelCount: u32, - pCmdBufLabels: [^]DebugUtilsLabelEXT, - objectCount: u32, - pObjects: [^]DebugUtilsObjectNameInfoEXT, -} - -DebugUtilsMessengerCreateInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - flags: DebugUtilsMessengerCreateFlagsEXT, - messageSeverity: DebugUtilsMessageSeverityFlagsEXT, - messageType: DebugUtilsMessageTypeFlagsEXT, - pfnUserCallback: ProcDebugUtilsMessengerCallbackEXT, - pUserData: rawptr, -} - -DebugUtilsObjectTagInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - objectType: ObjectType, - objectHandle: u64, - tagName: u64, - tagSize: int, - pTag: rawptr, -} - -SampleLocationEXT :: struct { - x: f32, - y: f32, -} - -SampleLocationsInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - sampleLocationsPerPixel: SampleCountFlags, - sampleLocationGridSize: Extent2D, - sampleLocationsCount: u32, - pSampleLocations: [^]SampleLocationEXT, -} - -AttachmentSampleLocationsEXT :: struct { - attachmentIndex: u32, - sampleLocationsInfo: SampleLocationsInfoEXT, -} - -SubpassSampleLocationsEXT :: struct { - subpassIndex: u32, - sampleLocationsInfo: SampleLocationsInfoEXT, -} - -RenderPassSampleLocationsBeginInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - attachmentInitialSampleLocationsCount: u32, - pAttachmentInitialSampleLocations: [^]AttachmentSampleLocationsEXT, - postSubpassSampleLocationsCount: u32, - pPostSubpassSampleLocations: [^]SubpassSampleLocationsEXT, -} - -PipelineSampleLocationsStateCreateInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - sampleLocationsEnable: b32, - sampleLocationsInfo: SampleLocationsInfoEXT, -} - -PhysicalDeviceSampleLocationsPropertiesEXT :: struct { - sType: StructureType, - pNext: rawptr, - sampleLocationSampleCounts: SampleCountFlags, - maxSampleLocationGridSize: Extent2D, - sampleLocationCoordinateRange: [2]f32, - sampleLocationSubPixelBits: u32, - variableSampleLocations: b32, -} - -MultisamplePropertiesEXT :: struct { - sType: StructureType, - pNext: rawptr, - maxSampleLocationGridSize: Extent2D, -} - -PhysicalDeviceBlendOperationAdvancedFeaturesEXT :: struct { - sType: StructureType, - pNext: rawptr, - advancedBlendCoherentOperations: b32, -} - -PhysicalDeviceBlendOperationAdvancedPropertiesEXT :: struct { - sType: StructureType, - pNext: rawptr, - advancedBlendMaxColorAttachments: u32, - advancedBlendIndependentBlend: b32, - advancedBlendNonPremultipliedSrcColor: b32, - advancedBlendNonPremultipliedDstColor: b32, - advancedBlendCorrelatedOverlap: b32, - advancedBlendAllOperations: b32, -} - -PipelineColorBlendAdvancedStateCreateInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - srcPremultiplied: b32, - dstPremultiplied: b32, - blendOverlap: BlendOverlapEXT, -} - -PipelineCoverageToColorStateCreateInfoNV :: struct { - sType: StructureType, - pNext: rawptr, - flags: PipelineCoverageToColorStateCreateFlagsNV, - coverageToColorEnable: b32, - coverageToColorLocation: u32, -} - -PipelineCoverageModulationStateCreateInfoNV :: struct { - sType: StructureType, - pNext: rawptr, - flags: PipelineCoverageModulationStateCreateFlagsNV, - coverageModulationMode: CoverageModulationModeNV, - coverageModulationTableEnable: b32, - coverageModulationTableCount: u32, - pCoverageModulationTable: [^]f32, -} - -PhysicalDeviceShaderSMBuiltinsPropertiesNV :: struct { - sType: StructureType, - pNext: rawptr, - shaderSMCount: u32, - shaderWarpsPerSM: u32, -} - -PhysicalDeviceShaderSMBuiltinsFeaturesNV :: struct { - sType: StructureType, - pNext: rawptr, - shaderSMBuiltins: b32, -} - -DrmFormatModifierPropertiesEXT :: struct { - drmFormatModifier: u64, - drmFormatModifierPlaneCount: u32, - drmFormatModifierTilingFeatures: FormatFeatureFlags, -} - -DrmFormatModifierPropertiesListEXT :: struct { - sType: StructureType, - pNext: rawptr, - drmFormatModifierCount: u32, - pDrmFormatModifierProperties: [^]DrmFormatModifierPropertiesEXT, -} - -PhysicalDeviceImageDrmFormatModifierInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - drmFormatModifier: u64, - sharingMode: SharingMode, - queueFamilyIndexCount: u32, - pQueueFamilyIndices: [^]u32, -} - -ImageDrmFormatModifierListCreateInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - drmFormatModifierCount: u32, - pDrmFormatModifiers: [^]u64, -} - -ImageDrmFormatModifierExplicitCreateInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - drmFormatModifier: u64, - drmFormatModifierPlaneCount: u32, - pPlaneLayouts: [^]SubresourceLayout, -} - -ImageDrmFormatModifierPropertiesEXT :: struct { - sType: StructureType, - pNext: rawptr, - drmFormatModifier: u64, -} - -DrmFormatModifierProperties2EXT :: struct { - drmFormatModifier: u64, - drmFormatModifierPlaneCount: u32, - drmFormatModifierTilingFeatures: FormatFeatureFlags2, -} - -DrmFormatModifierPropertiesList2EXT :: struct { - sType: StructureType, - pNext: rawptr, - drmFormatModifierCount: u32, - pDrmFormatModifierProperties: [^]DrmFormatModifierProperties2EXT, -} - -ValidationCacheCreateInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - flags: ValidationCacheCreateFlagsEXT, - initialDataSize: int, - pInitialData: rawptr, -} - -ShaderModuleValidationCacheCreateInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - validationCache: ValidationCacheEXT, -} - -ShadingRatePaletteNV :: struct { - shadingRatePaletteEntryCount: u32, - pShadingRatePaletteEntries: [^]ShadingRatePaletteEntryNV, -} - -PipelineViewportShadingRateImageStateCreateInfoNV :: struct { - sType: StructureType, - pNext: rawptr, - shadingRateImageEnable: b32, - viewportCount: u32, - pShadingRatePalettes: [^]ShadingRatePaletteNV, -} - -PhysicalDeviceShadingRateImageFeaturesNV :: struct { - sType: StructureType, - pNext: rawptr, - shadingRateImage: b32, - shadingRateCoarseSampleOrder: b32, -} - -PhysicalDeviceShadingRateImagePropertiesNV :: struct { - sType: StructureType, - pNext: rawptr, - shadingRateTexelSize: Extent2D, - shadingRatePaletteSize: u32, - shadingRateMaxCoarseSamples: u32, -} - -CoarseSampleLocationNV :: struct { - pixelX: u32, - pixelY: u32, - sample: u32, -} - -CoarseSampleOrderCustomNV :: struct { - shadingRate: ShadingRatePaletteEntryNV, - sampleCount: u32, - sampleLocationCount: u32, - pSampleLocations: [^]CoarseSampleLocationNV, -} - -PipelineViewportCoarseSampleOrderStateCreateInfoNV :: struct { - sType: StructureType, - pNext: rawptr, - sampleOrderType: CoarseSampleOrderTypeNV, - customSampleOrderCount: u32, - pCustomSampleOrders: [^]CoarseSampleOrderCustomNV, -} - -RayTracingShaderGroupCreateInfoNV :: struct { - sType: StructureType, - pNext: rawptr, - type: RayTracingShaderGroupTypeKHR, - generalShader: u32, - closestHitShader: u32, - anyHitShader: u32, - intersectionShader: u32, -} - -RayTracingPipelineCreateInfoNV :: struct { - sType: StructureType, - pNext: rawptr, - flags: PipelineCreateFlags, - stageCount: u32, - pStages: [^]PipelineShaderStageCreateInfo, - groupCount: u32, - pGroups: [^]RayTracingShaderGroupCreateInfoNV, - maxRecursionDepth: u32, - layout: PipelineLayout, - basePipelineHandle: Pipeline, - basePipelineIndex: i32, -} - -GeometryTrianglesNV :: struct { - sType: StructureType, - pNext: rawptr, - vertexData: Buffer, - vertexOffset: DeviceSize, - vertexCount: u32, - vertexStride: DeviceSize, - vertexFormat: Format, - indexData: Buffer, - indexOffset: DeviceSize, - indexCount: u32, - indexType: IndexType, - transformData: Buffer, - transformOffset: DeviceSize, -} - -GeometryAABBNV :: struct { - sType: StructureType, - pNext: rawptr, - aabbData: Buffer, - numAABBs: u32, - stride: u32, - offset: DeviceSize, -} - -GeometryDataNV :: struct { - triangles: GeometryTrianglesNV, - aabbs: GeometryAABBNV, -} - -GeometryNV :: struct { - sType: StructureType, - pNext: rawptr, - geometryType: GeometryTypeKHR, - geometry: GeometryDataNV, - flags: GeometryFlagsKHR, -} - -AccelerationStructureInfoNV :: struct { - sType: StructureType, - pNext: rawptr, - type: AccelerationStructureTypeNV, - flags: BuildAccelerationStructureFlagsNV, - instanceCount: u32, - geometryCount: u32, - pGeometries: [^]GeometryNV, -} - -AccelerationStructureCreateInfoNV :: struct { - sType: StructureType, - pNext: rawptr, - compactedSize: DeviceSize, - info: AccelerationStructureInfoNV, -} - -BindAccelerationStructureMemoryInfoNV :: struct { - sType: StructureType, - pNext: rawptr, - accelerationStructure: AccelerationStructureNV, - memory: DeviceMemory, - memoryOffset: DeviceSize, - deviceIndexCount: u32, - pDeviceIndices: [^]u32, -} - -WriteDescriptorSetAccelerationStructureNV :: struct { - sType: StructureType, - pNext: rawptr, - accelerationStructureCount: u32, - pAccelerationStructures: [^]AccelerationStructureNV, -} - -AccelerationStructureMemoryRequirementsInfoNV :: struct { - sType: StructureType, - pNext: rawptr, - type: AccelerationStructureMemoryRequirementsTypeNV, - accelerationStructure: AccelerationStructureNV, -} - -PhysicalDeviceRayTracingPropertiesNV :: struct { - sType: StructureType, - pNext: rawptr, - shaderGroupHandleSize: u32, - maxRecursionDepth: u32, - maxShaderGroupStride: u32, - shaderGroupBaseAlignment: u32, - maxGeometryCount: u64, - maxInstanceCount: u64, - maxTriangleCount: u64, - maxDescriptorSetAccelerationStructures: u32, -} - -TransformMatrixKHR :: struct { - mat: [3][4]f32, -} - -AabbPositionsKHR :: struct { - minX: f32, - minY: f32, - minZ: f32, - maxX: f32, - maxY: f32, - maxZ: f32, -} - -AccelerationStructureInstanceKHR :: struct { - transform: TransformMatrixKHR, - accelerationStructureReference: u64, -} - -PhysicalDeviceRepresentativeFragmentTestFeaturesNV :: struct { - sType: StructureType, - pNext: rawptr, - representativeFragmentTest: b32, -} - -PipelineRepresentativeFragmentTestStateCreateInfoNV :: struct { - sType: StructureType, - pNext: rawptr, - representativeFragmentTestEnable: b32, -} - -PhysicalDeviceImageViewImageFormatInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - imageViewType: ImageViewType, -} - -FilterCubicImageViewImageFormatPropertiesEXT :: struct { - sType: StructureType, - pNext: rawptr, - filterCubic: b32, - filterCubicMinmax: b32, -} - -ImportMemoryHostPointerInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - handleType: ExternalMemoryHandleTypeFlags, - pHostPointer: rawptr, -} - -MemoryHostPointerPropertiesEXT :: struct { - sType: StructureType, - pNext: rawptr, - memoryTypeBits: u32, -} - -PhysicalDeviceExternalMemoryHostPropertiesEXT :: struct { - sType: StructureType, - pNext: rawptr, - minImportedHostPointerAlignment: DeviceSize, -} - -PipelineCompilerControlCreateInfoAMD :: struct { - sType: StructureType, - pNext: rawptr, - compilerControlFlags: PipelineCompilerControlFlagsAMD, -} - -CalibratedTimestampInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - timeDomain: TimeDomainEXT, -} - -PhysicalDeviceShaderCorePropertiesAMD :: struct { - sType: StructureType, - pNext: rawptr, - shaderEngineCount: u32, - shaderArraysPerEngineCount: u32, - computeUnitsPerShaderArray: u32, - simdPerComputeUnit: u32, - wavefrontsPerSimd: u32, - wavefrontSize: u32, - sgprsPerSimd: u32, - minSgprAllocation: u32, - maxSgprAllocation: u32, - sgprAllocationGranularity: u32, - vgprsPerSimd: u32, - minVgprAllocation: u32, - maxVgprAllocation: u32, - vgprAllocationGranularity: u32, -} - -DeviceMemoryOverallocationCreateInfoAMD :: struct { - sType: StructureType, - pNext: rawptr, - overallocationBehavior: MemoryOverallocationBehaviorAMD, -} - -PhysicalDeviceVertexAttributeDivisorPropertiesEXT :: struct { - sType: StructureType, - pNext: rawptr, - maxVertexAttribDivisor: u32, -} - -VertexInputBindingDivisorDescriptionEXT :: struct { - binding: u32, - divisor: u32, -} - -PipelineVertexInputDivisorStateCreateInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - vertexBindingDivisorCount: u32, - pVertexBindingDivisors: [^]VertexInputBindingDivisorDescriptionEXT, -} - -PhysicalDeviceVertexAttributeDivisorFeaturesEXT :: struct { - sType: StructureType, - pNext: rawptr, - vertexAttributeInstanceRateDivisor: b32, - vertexAttributeInstanceRateZeroDivisor: b32, -} - -PhysicalDeviceComputeShaderDerivativesFeaturesNV :: struct { - sType: StructureType, - pNext: rawptr, - computeDerivativeGroupQuads: b32, - computeDerivativeGroupLinear: b32, -} - -PhysicalDeviceMeshShaderFeaturesNV :: struct { - sType: StructureType, - pNext: rawptr, - taskShader: b32, - meshShader: b32, -} - -PhysicalDeviceMeshShaderPropertiesNV :: struct { - sType: StructureType, - pNext: rawptr, - maxDrawMeshTasksCount: u32, - maxTaskWorkGroupInvocations: u32, - maxTaskWorkGroupSize: [3]u32, - maxTaskTotalMemorySize: u32, - maxTaskOutputCount: u32, - maxMeshWorkGroupInvocations: u32, - maxMeshWorkGroupSize: [3]u32, - maxMeshTotalMemorySize: u32, - maxMeshOutputVertices: u32, - maxMeshOutputPrimitives: u32, - maxMeshMultiviewViewCount: u32, - meshOutputPerVertexGranularity: u32, - meshOutputPerPrimitiveGranularity: u32, -} - -DrawMeshTasksIndirectCommandNV :: struct { - taskCount: u32, - firstTask: u32, -} - -PhysicalDeviceFragmentShaderBarycentricFeaturesNV :: struct { - sType: StructureType, - pNext: rawptr, - fragmentShaderBarycentric: b32, -} - -PhysicalDeviceShaderImageFootprintFeaturesNV :: struct { - sType: StructureType, - pNext: rawptr, - imageFootprint: b32, -} - -PipelineViewportExclusiveScissorStateCreateInfoNV :: struct { - sType: StructureType, - pNext: rawptr, - exclusiveScissorCount: u32, - pExclusiveScissors: [^]Rect2D, -} - -PhysicalDeviceExclusiveScissorFeaturesNV :: struct { - sType: StructureType, - pNext: rawptr, - exclusiveScissor: b32, -} - -QueueFamilyCheckpointPropertiesNV :: struct { - sType: StructureType, - pNext: rawptr, - checkpointExecutionStageMask: PipelineStageFlags, -} - -CheckpointDataNV :: struct { - sType: StructureType, - pNext: rawptr, - stage: PipelineStageFlags, - pCheckpointMarker: rawptr, -} - -PhysicalDeviceShaderIntegerFunctions2FeaturesINTEL :: struct { - sType: StructureType, - pNext: rawptr, - shaderIntegerFunctions2: b32, -} - -PerformanceValueDataINTEL :: struct #raw_union { - value32: u32, - value64: u64, - valueFloat: f32, - valueBool: b32, - valueString: cstring, -} - -PerformanceValueINTEL :: struct { - type: PerformanceValueTypeINTEL, - data: PerformanceValueDataINTEL, -} - -InitializePerformanceApiInfoINTEL :: struct { - sType: StructureType, - pNext: rawptr, - pUserData: rawptr, -} - -QueryPoolPerformanceQueryCreateInfoINTEL :: struct { - sType: StructureType, - pNext: rawptr, - performanceCountersSampling: QueryPoolSamplingModeINTEL, -} - -PerformanceMarkerInfoINTEL :: struct { - sType: StructureType, - pNext: rawptr, - marker: u64, -} - -PerformanceStreamMarkerInfoINTEL :: struct { - sType: StructureType, - pNext: rawptr, - marker: u32, -} - -PerformanceOverrideInfoINTEL :: struct { - sType: StructureType, - pNext: rawptr, - type: PerformanceOverrideTypeINTEL, - enable: b32, - parameter: u64, -} - -PerformanceConfigurationAcquireInfoINTEL :: struct { - sType: StructureType, - pNext: rawptr, - type: PerformanceConfigurationTypeINTEL, -} - -PhysicalDevicePCIBusInfoPropertiesEXT :: struct { - sType: StructureType, - pNext: rawptr, - pciDomain: u32, - pciBus: u32, - pciDevice: u32, - pciFunction: u32, -} - -DisplayNativeHdrSurfaceCapabilitiesAMD :: struct { - sType: StructureType, - pNext: rawptr, - localDimmingSupport: b32, -} - -SwapchainDisplayNativeHdrCreateInfoAMD :: struct { - sType: StructureType, - pNext: rawptr, - localDimmingEnable: b32, -} - -PhysicalDeviceFragmentDensityMapFeaturesEXT :: struct { - sType: StructureType, - pNext: rawptr, - fragmentDensityMap: b32, - fragmentDensityMapDynamic: b32, - fragmentDensityMapNonSubsampledImages: b32, -} - -PhysicalDeviceFragmentDensityMapPropertiesEXT :: struct { - sType: StructureType, - pNext: rawptr, - minFragmentDensityTexelSize: Extent2D, - maxFragmentDensityTexelSize: Extent2D, - fragmentDensityInvocations: b32, -} - -RenderPassFragmentDensityMapCreateInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - fragmentDensityMapAttachment: AttachmentReference, -} - -PhysicalDeviceShaderCoreProperties2AMD :: struct { - sType: StructureType, - pNext: rawptr, - shaderCoreFeatures: ShaderCorePropertiesFlagsAMD, - activeComputeUnitCount: u32, -} - -PhysicalDeviceCoherentMemoryFeaturesAMD :: struct { - sType: StructureType, - pNext: rawptr, - deviceCoherentMemory: b32, -} - -PhysicalDeviceShaderImageAtomicInt64FeaturesEXT :: struct { - sType: StructureType, - pNext: rawptr, - shaderImageInt64Atomics: b32, - sparseImageInt64Atomics: b32, -} - -PhysicalDeviceMemoryBudgetPropertiesEXT :: struct { - sType: StructureType, - pNext: rawptr, - heapBudget: [MAX_MEMORY_HEAPS]DeviceSize, - heapUsage: [MAX_MEMORY_HEAPS]DeviceSize, -} - -PhysicalDeviceMemoryPriorityFeaturesEXT :: struct { - sType: StructureType, - pNext: rawptr, - memoryPriority: b32, -} - -MemoryPriorityAllocateInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - priority: f32, -} - -PhysicalDeviceDedicatedAllocationImageAliasingFeaturesNV :: struct { - sType: StructureType, - pNext: rawptr, - dedicatedAllocationImageAliasing: b32, -} - -PhysicalDeviceBufferDeviceAddressFeaturesEXT :: struct { - sType: StructureType, - pNext: rawptr, - bufferDeviceAddress: b32, - bufferDeviceAddressCaptureReplay: b32, - bufferDeviceAddressMultiDevice: b32, -} - -BufferDeviceAddressCreateInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - deviceAddress: DeviceAddress, -} - -ValidationFeaturesEXT :: struct { - sType: StructureType, - pNext: rawptr, - enabledValidationFeatureCount: u32, - pEnabledValidationFeatures: [^]ValidationFeatureEnableEXT, - disabledValidationFeatureCount: u32, - pDisabledValidationFeatures: [^]ValidationFeatureDisableEXT, -} - -CooperativeMatrixPropertiesNV :: struct { - sType: StructureType, - pNext: rawptr, - MSize: u32, - NSize: u32, - KSize: u32, - AType: ComponentTypeNV, - BType: ComponentTypeNV, - CType: ComponentTypeNV, - DType: ComponentTypeNV, - scope: ScopeNV, -} - -PhysicalDeviceCooperativeMatrixFeaturesNV :: struct { - sType: StructureType, - pNext: rawptr, - cooperativeMatrix: b32, - cooperativeMatrixRobustBufferAccess: b32, -} - -PhysicalDeviceCooperativeMatrixPropertiesNV :: struct { - sType: StructureType, - pNext: rawptr, - cooperativeMatrixSupportedStages: ShaderStageFlags, -} - -PhysicalDeviceCoverageReductionModeFeaturesNV :: struct { - sType: StructureType, - pNext: rawptr, - coverageReductionMode: b32, -} - -PipelineCoverageReductionStateCreateInfoNV :: struct { - sType: StructureType, - pNext: rawptr, - flags: PipelineCoverageReductionStateCreateFlagsNV, - coverageReductionMode: CoverageReductionModeNV, -} - -FramebufferMixedSamplesCombinationNV :: struct { - sType: StructureType, - pNext: rawptr, - coverageReductionMode: CoverageReductionModeNV, - rasterizationSamples: SampleCountFlags, - depthStencilSamples: SampleCountFlags, - colorSamples: SampleCountFlags, -} - -PhysicalDeviceFragmentShaderInterlockFeaturesEXT :: struct { - sType: StructureType, - pNext: rawptr, - fragmentShaderSampleInterlock: b32, - fragmentShaderPixelInterlock: b32, - fragmentShaderShadingRateInterlock: b32, -} - -PhysicalDeviceYcbcrImageArraysFeaturesEXT :: struct { - sType: StructureType, - pNext: rawptr, - ycbcrImageArrays: b32, -} - -PhysicalDeviceProvokingVertexFeaturesEXT :: struct { - sType: StructureType, - pNext: rawptr, - provokingVertexLast: b32, - transformFeedbackPreservesProvokingVertex: b32, -} - -PhysicalDeviceProvokingVertexPropertiesEXT :: struct { - sType: StructureType, - pNext: rawptr, - provokingVertexModePerPipeline: b32, - transformFeedbackPreservesTriangleFanProvokingVertex: b32, -} - -PipelineRasterizationProvokingVertexStateCreateInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - provokingVertexMode: ProvokingVertexModeEXT, -} - -HeadlessSurfaceCreateInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - flags: HeadlessSurfaceCreateFlagsEXT, -} - -PhysicalDeviceLineRasterizationFeaturesEXT :: struct { - sType: StructureType, - pNext: rawptr, - rectangularLines: b32, - bresenhamLines: b32, - smoothLines: b32, - stippledRectangularLines: b32, - stippledBresenhamLines: b32, - stippledSmoothLines: b32, -} - -PhysicalDeviceLineRasterizationPropertiesEXT :: struct { - sType: StructureType, - pNext: rawptr, - lineSubPixelPrecisionBits: u32, -} - -PipelineRasterizationLineStateCreateInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - lineRasterizationMode: LineRasterizationModeEXT, - stippledLineEnable: b32, - lineStippleFactor: u32, - lineStipplePattern: u16, -} - -PhysicalDeviceShaderAtomicFloatFeaturesEXT :: struct { - sType: StructureType, - pNext: rawptr, - shaderBufferFloat32Atomics: b32, - shaderBufferFloat32AtomicAdd: b32, - shaderBufferFloat64Atomics: b32, - shaderBufferFloat64AtomicAdd: b32, - shaderSharedFloat32Atomics: b32, - shaderSharedFloat32AtomicAdd: b32, - shaderSharedFloat64Atomics: b32, - shaderSharedFloat64AtomicAdd: b32, - shaderImageFloat32Atomics: b32, - shaderImageFloat32AtomicAdd: b32, - sparseImageFloat32Atomics: b32, - sparseImageFloat32AtomicAdd: b32, -} - -PhysicalDeviceIndexTypeUint8FeaturesEXT :: struct { - sType: StructureType, - pNext: rawptr, - indexTypeUint8: b32, -} - -PhysicalDeviceExtendedDynamicStateFeaturesEXT :: struct { - sType: StructureType, - pNext: rawptr, - extendedDynamicState: b32, -} - -PhysicalDeviceShaderAtomicFloat2FeaturesEXT :: struct { - sType: StructureType, - pNext: rawptr, - shaderBufferFloat16Atomics: b32, - shaderBufferFloat16AtomicAdd: b32, - shaderBufferFloat16AtomicMinMax: b32, - shaderBufferFloat32AtomicMinMax: b32, - shaderBufferFloat64AtomicMinMax: b32, - shaderSharedFloat16Atomics: b32, - shaderSharedFloat16AtomicAdd: b32, - shaderSharedFloat16AtomicMinMax: b32, - shaderSharedFloat32AtomicMinMax: b32, - shaderSharedFloat64AtomicMinMax: b32, - shaderImageFloat32AtomicMinMax: b32, - sparseImageFloat32AtomicMinMax: b32, -} - -PhysicalDeviceDeviceGeneratedCommandsPropertiesNV :: struct { - sType: StructureType, - pNext: rawptr, - maxGraphicsShaderGroupCount: u32, - maxIndirectSequenceCount: u32, - maxIndirectCommandsTokenCount: u32, - maxIndirectCommandsStreamCount: u32, - maxIndirectCommandsTokenOffset: u32, - maxIndirectCommandsStreamStride: u32, - minSequencesCountBufferOffsetAlignment: u32, - minSequencesIndexBufferOffsetAlignment: u32, - minIndirectCommandsBufferOffsetAlignment: u32, -} - -PhysicalDeviceDeviceGeneratedCommandsFeaturesNV :: struct { - sType: StructureType, - pNext: rawptr, - deviceGeneratedCommands: b32, -} - -GraphicsShaderGroupCreateInfoNV :: struct { - sType: StructureType, - pNext: rawptr, - stageCount: u32, - pStages: [^]PipelineShaderStageCreateInfo, - pVertexInputState: ^PipelineVertexInputStateCreateInfo, - pTessellationState: ^PipelineTessellationStateCreateInfo, -} - -GraphicsPipelineShaderGroupsCreateInfoNV :: struct { - sType: StructureType, - pNext: rawptr, - groupCount: u32, - pGroups: [^]GraphicsShaderGroupCreateInfoNV, - pipelineCount: u32, - pPipelines: [^]Pipeline, -} - -BindShaderGroupIndirectCommandNV :: struct { - groupIndex: u32, -} - -BindIndexBufferIndirectCommandNV :: struct { - bufferAddress: DeviceAddress, - size: u32, - indexType: IndexType, -} - -BindVertexBufferIndirectCommandNV :: struct { - bufferAddress: DeviceAddress, - size: u32, - stride: u32, -} - -SetStateFlagsIndirectCommandNV :: struct { - data: u32, -} - -IndirectCommandsStreamNV :: struct { - buffer: Buffer, - offset: DeviceSize, -} - -IndirectCommandsLayoutTokenNV :: struct { - sType: StructureType, - pNext: rawptr, - tokenType: IndirectCommandsTokenTypeNV, - stream: u32, - offset: u32, - vertexBindingUnit: u32, - vertexDynamicStride: b32, - pushconstantPipelineLayout: PipelineLayout, - pushconstantShaderStageFlags: ShaderStageFlags, - pushconstantOffset: u32, - pushconstantSize: u32, - indirectStateFlags: IndirectStateFlagsNV, - indexTypeCount: u32, - pIndexTypes: [^]IndexType, - pIndexTypeValues: [^]u32, -} - -IndirectCommandsLayoutCreateInfoNV :: struct { - sType: StructureType, - pNext: rawptr, - flags: IndirectCommandsLayoutUsageFlagsNV, - pipelineBindPoint: PipelineBindPoint, - tokenCount: u32, - pTokens: [^]IndirectCommandsLayoutTokenNV, - streamCount: u32, - pStreamStrides: [^]u32, -} - -GeneratedCommandsInfoNV :: struct { - sType: StructureType, - pNext: rawptr, - pipelineBindPoint: PipelineBindPoint, - pipeline: Pipeline, - indirectCommandsLayout: IndirectCommandsLayoutNV, - streamCount: u32, - pStreams: [^]IndirectCommandsStreamNV, - sequencesCount: u32, - preprocessBuffer: Buffer, - preprocessOffset: DeviceSize, - preprocessSize: DeviceSize, - sequencesCountBuffer: Buffer, - sequencesCountOffset: DeviceSize, - sequencesIndexBuffer: Buffer, - sequencesIndexOffset: DeviceSize, -} - -GeneratedCommandsMemoryRequirementsInfoNV :: struct { - sType: StructureType, - pNext: rawptr, - pipelineBindPoint: PipelineBindPoint, - pipeline: Pipeline, - indirectCommandsLayout: IndirectCommandsLayoutNV, - maxSequencesCount: u32, -} - -PhysicalDeviceInheritedViewportScissorFeaturesNV :: struct { - sType: StructureType, - pNext: rawptr, - inheritedViewportScissor2D: b32, -} - -CommandBufferInheritanceViewportScissorInfoNV :: struct { - sType: StructureType, - pNext: rawptr, - viewportScissor2D: b32, - viewportDepthCount: u32, - pViewportDepths: [^]Viewport, -} - -PhysicalDeviceTexelBufferAlignmentFeaturesEXT :: struct { - sType: StructureType, - pNext: rawptr, - texelBufferAlignment: b32, -} - -RenderPassTransformBeginInfoQCOM :: struct { - sType: StructureType, - pNext: rawptr, - transform: SurfaceTransformFlagsKHR, -} - -CommandBufferInheritanceRenderPassTransformInfoQCOM :: struct { - sType: StructureType, - pNext: rawptr, - transform: SurfaceTransformFlagsKHR, - renderArea: Rect2D, -} - -PhysicalDeviceDeviceMemoryReportFeaturesEXT :: struct { - sType: StructureType, - pNext: rawptr, - deviceMemoryReport: b32, -} - -DeviceMemoryReportCallbackDataEXT :: struct { - sType: StructureType, - pNext: rawptr, - flags: DeviceMemoryReportFlagsEXT, - type: DeviceMemoryReportEventTypeEXT, - memoryObjectId: u64, - size: DeviceSize, - objectType: ObjectType, - objectHandle: u64, - heapIndex: u32, -} - -DeviceDeviceMemoryReportCreateInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - flags: DeviceMemoryReportFlagsEXT, - pfnUserCallback: ProcDeviceMemoryReportCallbackEXT, - pUserData: rawptr, -} - -PhysicalDeviceRobustness2FeaturesEXT :: struct { - sType: StructureType, - pNext: rawptr, - robustBufferAccess2: b32, - robustImageAccess2: b32, - nullDescriptor: b32, -} - -PhysicalDeviceRobustness2PropertiesEXT :: struct { - sType: StructureType, - pNext: rawptr, - robustStorageBufferAccessSizeAlignment: DeviceSize, - robustUniformBufferAccessSizeAlignment: DeviceSize, -} - -SamplerCustomBorderColorCreateInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - customBorderColor: ClearColorValue, - format: Format, -} - -PhysicalDeviceCustomBorderColorPropertiesEXT :: struct { - sType: StructureType, - pNext: rawptr, - maxCustomBorderColorSamplers: u32, -} - -PhysicalDeviceCustomBorderColorFeaturesEXT :: struct { - sType: StructureType, - pNext: rawptr, - customBorderColors: b32, - customBorderColorWithoutFormat: b32, -} - -PhysicalDeviceDiagnosticsConfigFeaturesNV :: struct { - sType: StructureType, - pNext: rawptr, - diagnosticsConfig: b32, -} - -DeviceDiagnosticsConfigCreateInfoNV :: struct { - sType: StructureType, - pNext: rawptr, - flags: DeviceDiagnosticsConfigFlagsNV, -} - -PhysicalDeviceGraphicsPipelineLibraryFeaturesEXT :: struct { - sType: StructureType, - pNext: rawptr, - graphicsPipelineLibrary: b32, -} - -PhysicalDeviceGraphicsPipelineLibraryPropertiesEXT :: struct { - sType: StructureType, - pNext: rawptr, - graphicsPipelineLibraryFastLinking: b32, - graphicsPipelineLibraryIndependentInterpolationDecoration: b32, -} - -GraphicsPipelineLibraryCreateInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - flags: GraphicsPipelineLibraryFlagsEXT, -} - -PhysicalDeviceFragmentShadingRateEnumsFeaturesNV :: struct { - sType: StructureType, - pNext: rawptr, - fragmentShadingRateEnums: b32, - supersampleFragmentShadingRates: b32, - noInvocationFragmentShadingRates: b32, -} - -PhysicalDeviceFragmentShadingRateEnumsPropertiesNV :: struct { - sType: StructureType, - pNext: rawptr, - maxFragmentShadingRateInvocationCount: SampleCountFlags, -} - -PipelineFragmentShadingRateEnumStateCreateInfoNV :: struct { - sType: StructureType, - pNext: rawptr, - shadingRateType: FragmentShadingRateTypeNV, - shadingRate: FragmentShadingRateNV, - combinerOps: [2]FragmentShadingRateCombinerOpKHR, -} - -DeviceOrHostAddressConstKHR :: struct #raw_union { - deviceAddress: DeviceAddress, - hostAddress: rawptr, -} - -AccelerationStructureGeometryMotionTrianglesDataNV :: struct { - sType: StructureType, - pNext: rawptr, - vertexData: DeviceOrHostAddressConstKHR, -} - -AccelerationStructureMotionInfoNV :: struct { - sType: StructureType, - pNext: rawptr, - maxInstances: u32, - flags: AccelerationStructureMotionInfoFlagsNV, -} - -AccelerationStructureMatrixMotionInstanceNV :: struct { - transformT0: TransformMatrixKHR, - transformT1: TransformMatrixKHR, - accelerationStructureReference: u64, -} - -SRTDataNV :: struct { - sx: f32, - a: f32, - b: f32, - pvx: f32, - sy: f32, - c: f32, - pvy: f32, - sz: f32, - pvz: f32, - qx: f32, - qy: f32, - qz: f32, - qw: f32, - tx: f32, - ty: f32, - tz: f32, -} - -AccelerationStructureSRTMotionInstanceNV :: struct { - transformT0: SRTDataNV, - transformT1: SRTDataNV, - accelerationStructureReference: u64, -} - -AccelerationStructureMotionInstanceDataNV :: struct #raw_union { - staticInstance: AccelerationStructureInstanceKHR, - matrixMotionInstance: AccelerationStructureMatrixMotionInstanceNV, - srtMotionInstance: AccelerationStructureSRTMotionInstanceNV, -} - -AccelerationStructureMotionInstanceNV :: struct { - type: AccelerationStructureMotionInstanceTypeNV, - flags: AccelerationStructureMotionInstanceFlagsNV, - data: AccelerationStructureMotionInstanceDataNV, -} - -PhysicalDeviceRayTracingMotionBlurFeaturesNV :: struct { - sType: StructureType, - pNext: rawptr, - rayTracingMotionBlur: b32, - rayTracingMotionBlurPipelineTraceRaysIndirect: b32, -} - -PhysicalDeviceYcbcr2Plane444FormatsFeaturesEXT :: struct { - sType: StructureType, - pNext: rawptr, - ycbcr2plane444Formats: b32, -} - -PhysicalDeviceFragmentDensityMap2FeaturesEXT :: struct { - sType: StructureType, - pNext: rawptr, - fragmentDensityMapDeferred: b32, -} - -PhysicalDeviceFragmentDensityMap2PropertiesEXT :: struct { - sType: StructureType, - pNext: rawptr, - subsampledLoads: b32, - subsampledCoarseReconstructionEarlyAccess: b32, - maxSubsampledArrayLayers: u32, - maxDescriptorSetSubsampledSamplers: u32, -} - -CopyCommandTransformInfoQCOM :: struct { - sType: StructureType, - pNext: rawptr, - transform: SurfaceTransformFlagsKHR, -} - -PhysicalDevice4444FormatsFeaturesEXT :: struct { - sType: StructureType, - pNext: rawptr, - formatA4R4G4B4: b32, - formatA4B4G4R4: b32, -} - -PhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM :: struct { - sType: StructureType, - pNext: rawptr, - rasterizationOrderColorAttachmentAccess: b32, - rasterizationOrderDepthAttachmentAccess: b32, - rasterizationOrderStencilAttachmentAccess: b32, -} - -PhysicalDeviceRGBA10X6FormatsFeaturesEXT :: struct { - sType: StructureType, - pNext: rawptr, - formatRgba10x6WithoutYCbCrSampler: b32, -} - -PhysicalDeviceMutableDescriptorTypeFeaturesVALVE :: struct { - sType: StructureType, - pNext: rawptr, - mutableDescriptorType: b32, -} - -MutableDescriptorTypeListVALVE :: struct { - descriptorTypeCount: u32, - pDescriptorTypes: [^]DescriptorType, -} - -MutableDescriptorTypeCreateInfoVALVE :: struct { - sType: StructureType, - pNext: rawptr, - mutableDescriptorTypeListCount: u32, - pMutableDescriptorTypeLists: [^]MutableDescriptorTypeListVALVE, -} - -PhysicalDeviceVertexInputDynamicStateFeaturesEXT :: struct { - sType: StructureType, - pNext: rawptr, - vertexInputDynamicState: b32, -} - -VertexInputBindingDescription2EXT :: struct { - sType: StructureType, - pNext: rawptr, - binding: u32, - stride: u32, - inputRate: VertexInputRate, - divisor: u32, -} - -VertexInputAttributeDescription2EXT :: struct { - sType: StructureType, - pNext: rawptr, - location: u32, - binding: u32, - format: Format, - offset: u32, -} - -PhysicalDeviceDrmPropertiesEXT :: struct { - sType: StructureType, - pNext: rawptr, - hasPrimary: b32, - hasRender: b32, - primaryMajor: i64, - primaryMinor: i64, - renderMajor: i64, - renderMinor: i64, -} - -PhysicalDeviceDepthClipControlFeaturesEXT :: struct { - sType: StructureType, - pNext: rawptr, - depthClipControl: b32, -} - -PipelineViewportDepthClipControlCreateInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - negativeOneToOne: b32, -} - -PhysicalDevicePrimitiveTopologyListRestartFeaturesEXT :: struct { - sType: StructureType, - pNext: rawptr, - primitiveTopologyListRestart: b32, - primitiveTopologyPatchListRestart: b32, -} - -SubpassShadingPipelineCreateInfoHUAWEI :: struct { - sType: StructureType, - pNext: rawptr, - renderPass: RenderPass, - subpass: u32, -} - -PhysicalDeviceSubpassShadingFeaturesHUAWEI :: struct { - sType: StructureType, - pNext: rawptr, - subpassShading: b32, -} - -PhysicalDeviceSubpassShadingPropertiesHUAWEI :: struct { - sType: StructureType, - pNext: rawptr, - maxSubpassShadingWorkgroupSizeAspectRatio: u32, -} - -PhysicalDeviceInvocationMaskFeaturesHUAWEI :: struct { - sType: StructureType, - pNext: rawptr, - invocationMask: b32, -} - -MemoryGetRemoteAddressInfoNV :: struct { - sType: StructureType, - pNext: rawptr, - memory: DeviceMemory, - handleType: ExternalMemoryHandleTypeFlags, -} - -PhysicalDeviceExternalMemoryRDMAFeaturesNV :: struct { - sType: StructureType, - pNext: rawptr, - externalMemoryRDMA: b32, -} - -PhysicalDeviceExtendedDynamicState2FeaturesEXT :: struct { - sType: StructureType, - pNext: rawptr, - extendedDynamicState2: b32, - extendedDynamicState2LogicOp: b32, - extendedDynamicState2PatchControlPoints: b32, -} - -PhysicalDeviceColorWriteEnableFeaturesEXT :: struct { - sType: StructureType, - pNext: rawptr, - colorWriteEnable: b32, -} - -PipelineColorWriteCreateInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - attachmentCount: u32, - pColorWriteEnables: [^]b32, -} - -PhysicalDevicePrimitivesGeneratedQueryFeaturesEXT :: struct { - sType: StructureType, - pNext: rawptr, - primitivesGeneratedQuery: b32, - primitivesGeneratedQueryWithRasterizerDiscard: b32, - primitivesGeneratedQueryWithNonZeroStreams: b32, -} - -PhysicalDeviceImageViewMinLodFeaturesEXT :: struct { - sType: StructureType, - pNext: rawptr, - minLod: b32, -} - -ImageViewMinLodCreateInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - minLod: f32, -} - -PhysicalDeviceMultiDrawFeaturesEXT :: struct { - sType: StructureType, - pNext: rawptr, - multiDraw: b32, -} - -PhysicalDeviceMultiDrawPropertiesEXT :: struct { - sType: StructureType, - pNext: rawptr, - maxMultiDrawCount: u32, -} - -MultiDrawInfoEXT :: struct { - firstVertex: u32, - vertexCount: u32, -} - -MultiDrawIndexedInfoEXT :: struct { - firstIndex: u32, - indexCount: u32, - vertexOffset: i32, -} - -PhysicalDeviceImage2DViewOf3DFeaturesEXT :: struct { - sType: StructureType, - pNext: rawptr, - image2DViewOf3D: b32, - sampler2DViewOf3D: b32, -} - -PhysicalDeviceBorderColorSwizzleFeaturesEXT :: struct { - sType: StructureType, - pNext: rawptr, - borderColorSwizzle: b32, - borderColorSwizzleFromImage: b32, -} - -SamplerBorderColorComponentMappingCreateInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - components: ComponentMapping, - srgb: b32, -} - -PhysicalDevicePageableDeviceLocalMemoryFeaturesEXT :: struct { - sType: StructureType, - pNext: rawptr, - pageableDeviceLocalMemory: b32, -} - -PhysicalDeviceDescriptorSetHostMappingFeaturesVALVE :: struct { - sType: StructureType, - pNext: rawptr, - descriptorSetHostMapping: b32, -} - -DescriptorSetBindingReferenceVALVE :: struct { - sType: StructureType, - pNext: rawptr, - descriptorSetLayout: DescriptorSetLayout, - binding: u32, -} - -DescriptorSetLayoutHostMappingInfoVALVE :: struct { - sType: StructureType, - pNext: rawptr, - descriptorOffset: int, - descriptorSize: u32, -} - -PhysicalDeviceFragmentDensityMapOffsetFeaturesQCOM :: struct { - sType: StructureType, - pNext: rawptr, - fragmentDensityMapOffset: b32, -} - -PhysicalDeviceFragmentDensityMapOffsetPropertiesQCOM :: struct { - sType: StructureType, - pNext: rawptr, - fragmentDensityOffsetGranularity: Extent2D, -} - -SubpassFragmentDensityMapOffsetEndInfoQCOM :: struct { - sType: StructureType, - pNext: rawptr, - fragmentDensityOffsetCount: u32, - pFragmentDensityOffsets: [^]Offset2D, -} - -PhysicalDeviceLinearColorAttachmentFeaturesNV :: struct { - sType: StructureType, - pNext: rawptr, - linearColorAttachment: b32, -} - -DeviceOrHostAddressKHR :: struct #raw_union { - deviceAddress: DeviceAddress, - hostAddress: rawptr, -} - -AccelerationStructureBuildRangeInfoKHR :: struct { - primitiveCount: u32, - primitiveOffset: u32, - firstVertex: u32, - transformOffset: u32, -} - -AccelerationStructureGeometryTrianglesDataKHR :: struct { - sType: StructureType, - pNext: rawptr, - vertexFormat: Format, - vertexData: DeviceOrHostAddressConstKHR, - vertexStride: DeviceSize, - maxVertex: u32, - indexType: IndexType, - indexData: DeviceOrHostAddressConstKHR, - transformData: DeviceOrHostAddressConstKHR, -} - -AccelerationStructureGeometryAabbsDataKHR :: struct { - sType: StructureType, - pNext: rawptr, - data: DeviceOrHostAddressConstKHR, - stride: DeviceSize, -} - -AccelerationStructureGeometryInstancesDataKHR :: struct { - sType: StructureType, - pNext: rawptr, - arrayOfPointers: b32, - data: DeviceOrHostAddressConstKHR, -} - -AccelerationStructureGeometryDataKHR :: struct #raw_union { - triangles: AccelerationStructureGeometryTrianglesDataKHR, - aabbs: AccelerationStructureGeometryAabbsDataKHR, - instances: AccelerationStructureGeometryInstancesDataKHR, -} - -AccelerationStructureGeometryKHR :: struct { - sType: StructureType, - pNext: rawptr, - geometryType: GeometryTypeKHR, - geometry: AccelerationStructureGeometryDataKHR, - flags: GeometryFlagsKHR, -} - -AccelerationStructureBuildGeometryInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - type: AccelerationStructureTypeKHR, - flags: BuildAccelerationStructureFlagsKHR, - mode: BuildAccelerationStructureModeKHR, - srcAccelerationStructure: AccelerationStructureKHR, - dstAccelerationStructure: AccelerationStructureKHR, - geometryCount: u32, - pGeometries: [^]AccelerationStructureGeometryKHR, - ppGeometries: ^[^]AccelerationStructureGeometryKHR, - scratchData: DeviceOrHostAddressKHR, -} - -AccelerationStructureCreateInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - createFlags: AccelerationStructureCreateFlagsKHR, - buffer: Buffer, - offset: DeviceSize, - size: DeviceSize, - type: AccelerationStructureTypeKHR, - deviceAddress: DeviceAddress, -} - -WriteDescriptorSetAccelerationStructureKHR :: struct { - sType: StructureType, - pNext: rawptr, - accelerationStructureCount: u32, - pAccelerationStructures: [^]AccelerationStructureKHR, -} - -PhysicalDeviceAccelerationStructureFeaturesKHR :: struct { - sType: StructureType, - pNext: rawptr, - accelerationStructure: b32, - accelerationStructureCaptureReplay: b32, - accelerationStructureIndirectBuild: b32, - accelerationStructureHostCommands: b32, - descriptorBindingAccelerationStructureUpdateAfterBind: b32, -} - -PhysicalDeviceAccelerationStructurePropertiesKHR :: struct { - sType: StructureType, - pNext: rawptr, - maxGeometryCount: u64, - maxInstanceCount: u64, - maxPrimitiveCount: u64, - maxPerStageDescriptorAccelerationStructures: u32, - maxPerStageDescriptorUpdateAfterBindAccelerationStructures: u32, - maxDescriptorSetAccelerationStructures: u32, - maxDescriptorSetUpdateAfterBindAccelerationStructures: u32, - minAccelerationStructureScratchOffsetAlignment: u32, -} - -AccelerationStructureDeviceAddressInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - accelerationStructure: AccelerationStructureKHR, -} - -AccelerationStructureVersionInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - pVersionData: ^u8, -} - -CopyAccelerationStructureToMemoryInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - src: AccelerationStructureKHR, - dst: DeviceOrHostAddressKHR, - mode: CopyAccelerationStructureModeKHR, -} - -CopyMemoryToAccelerationStructureInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - src: DeviceOrHostAddressConstKHR, - dst: AccelerationStructureKHR, - mode: CopyAccelerationStructureModeKHR, -} - -CopyAccelerationStructureInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - src: AccelerationStructureKHR, - dst: AccelerationStructureKHR, - mode: CopyAccelerationStructureModeKHR, -} - -AccelerationStructureBuildSizesInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - accelerationStructureSize: DeviceSize, - updateScratchSize: DeviceSize, - buildScratchSize: DeviceSize, -} - -RayTracingShaderGroupCreateInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - type: RayTracingShaderGroupTypeKHR, - generalShader: u32, - closestHitShader: u32, - anyHitShader: u32, - intersectionShader: u32, - pShaderGroupCaptureReplayHandle: rawptr, -} - -RayTracingPipelineInterfaceCreateInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - maxPipelineRayPayloadSize: u32, - maxPipelineRayHitAttributeSize: u32, -} - -RayTracingPipelineCreateInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - flags: PipelineCreateFlags, - stageCount: u32, - pStages: [^]PipelineShaderStageCreateInfo, - groupCount: u32, - pGroups: [^]RayTracingShaderGroupCreateInfoKHR, - maxPipelineRayRecursionDepth: u32, - pLibraryInfo: ^PipelineLibraryCreateInfoKHR, - pLibraryInterface: ^RayTracingPipelineInterfaceCreateInfoKHR, - pDynamicState: ^PipelineDynamicStateCreateInfo, - layout: PipelineLayout, - basePipelineHandle: Pipeline, - basePipelineIndex: i32, -} - -PhysicalDeviceRayTracingPipelineFeaturesKHR :: struct { - sType: StructureType, - pNext: rawptr, - rayTracingPipeline: b32, - rayTracingPipelineShaderGroupHandleCaptureReplay: b32, - rayTracingPipelineShaderGroupHandleCaptureReplayMixed: b32, - rayTracingPipelineTraceRaysIndirect: b32, - rayTraversalPrimitiveCulling: b32, -} - -PhysicalDeviceRayTracingPipelinePropertiesKHR :: struct { - sType: StructureType, - pNext: rawptr, - shaderGroupHandleSize: u32, - maxRayRecursionDepth: u32, - maxShaderGroupStride: u32, - shaderGroupBaseAlignment: u32, - shaderGroupHandleCaptureReplaySize: u32, - maxRayDispatchInvocationCount: u32, - shaderGroupHandleAlignment: u32, - maxRayHitAttributeSize: u32, -} - -StridedDeviceAddressRegionKHR :: struct { - deviceAddress: DeviceAddress, - stride: DeviceSize, - size: DeviceSize, -} - -TraceRaysIndirectCommandKHR :: struct { - width: u32, - height: u32, - depth: u32, -} - -PhysicalDeviceRayQueryFeaturesKHR :: struct { - sType: StructureType, - pNext: rawptr, - rayQuery: b32, -} - -Win32SurfaceCreateInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - flags: Win32SurfaceCreateFlagsKHR, - hinstance: HINSTANCE, - hwnd: HWND, -} - -ImportMemoryWin32HandleInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - handleType: ExternalMemoryHandleTypeFlags, - handle: HANDLE, - name: LPCWSTR, -} - -ExportMemoryWin32HandleInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - pAttributes: [^]SECURITY_ATTRIBUTES, - dwAccess: DWORD, - name: LPCWSTR, -} - -MemoryWin32HandlePropertiesKHR :: struct { - sType: StructureType, - pNext: rawptr, - memoryTypeBits: u32, -} - -MemoryGetWin32HandleInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - memory: DeviceMemory, - handleType: ExternalMemoryHandleTypeFlags, -} - -Win32KeyedMutexAcquireReleaseInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - acquireCount: u32, - pAcquireSyncs: [^]DeviceMemory, - pAcquireKeys: [^]u64, - pAcquireTimeouts: [^]u32, - releaseCount: u32, - pReleaseSyncs: [^]DeviceMemory, - pReleaseKeys: [^]u64, -} - -ImportSemaphoreWin32HandleInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - semaphore: Semaphore, - flags: SemaphoreImportFlags, - handleType: ExternalSemaphoreHandleTypeFlags, - handle: HANDLE, - name: LPCWSTR, -} - -ExportSemaphoreWin32HandleInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - pAttributes: [^]SECURITY_ATTRIBUTES, - dwAccess: DWORD, - name: LPCWSTR, -} - -D3D12FenceSubmitInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - waitSemaphoreValuesCount: u32, - pWaitSemaphoreValues: [^]u64, - signalSemaphoreValuesCount: u32, - pSignalSemaphoreValues: [^]u64, -} - -SemaphoreGetWin32HandleInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - semaphore: Semaphore, - handleType: ExternalSemaphoreHandleTypeFlags, -} - -ImportFenceWin32HandleInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - fence: Fence, - flags: FenceImportFlags, - handleType: ExternalFenceHandleTypeFlags, - handle: HANDLE, - name: LPCWSTR, -} - -ExportFenceWin32HandleInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - pAttributes: [^]SECURITY_ATTRIBUTES, - dwAccess: DWORD, - name: LPCWSTR, -} - -FenceGetWin32HandleInfoKHR :: struct { - sType: StructureType, - pNext: rawptr, - fence: Fence, - handleType: ExternalFenceHandleTypeFlags, -} - -ImportMemoryWin32HandleInfoNV :: struct { - sType: StructureType, - pNext: rawptr, - handleType: ExternalMemoryHandleTypeFlagsNV, - handle: HANDLE, -} - -ExportMemoryWin32HandleInfoNV :: struct { - sType: StructureType, - pNext: rawptr, - pAttributes: [^]SECURITY_ATTRIBUTES, - dwAccess: DWORD, -} - -Win32KeyedMutexAcquireReleaseInfoNV :: struct { - sType: StructureType, - pNext: rawptr, - acquireCount: u32, - pAcquireSyncs: [^]DeviceMemory, - pAcquireKeys: [^]u64, - pAcquireTimeoutMilliseconds: [^]u32, - releaseCount: u32, - pReleaseSyncs: [^]DeviceMemory, - pReleaseKeys: [^]u64, -} - -SurfaceFullScreenExclusiveInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - fullScreenExclusive: FullScreenExclusiveEXT, -} - -SurfaceCapabilitiesFullScreenExclusiveEXT :: struct { - sType: StructureType, - pNext: rawptr, - fullScreenExclusiveSupported: b32, -} - -SurfaceFullScreenExclusiveWin32InfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - hmonitor: HMONITOR, -} - -MetalSurfaceCreateInfoEXT :: struct { - sType: StructureType, - pNext: rawptr, - flags: MetalSurfaceCreateFlagsEXT, - pLayer: ^CAMetalLayer, -} - -MacOSSurfaceCreateInfoMVK :: struct { - sType: StructureType, - pNext: rawptr, - flags: MacOSSurfaceCreateFlagsMVK, - pView: rawptr, -} - -IOSSurfaceCreateInfoMVK :: struct { - sType: StructureType, - pNext: rawptr, - flags: IOSSurfaceCreateFlagsMVK, - pView: rawptr, -} - -// Aliases -PhysicalDeviceVariablePointerFeatures :: PhysicalDeviceVariablePointersFeatures -PhysicalDeviceShaderDrawParameterFeatures :: PhysicalDeviceShaderDrawParametersFeatures -PipelineStageFlags2 :: Flags64 -PipelineStageFlag2 :: Flags64 -AccessFlags2 :: Flags64 -AccessFlag2 :: Flags64 -FormatFeatureFlags2 :: Flags64 -FormatFeatureFlag2 :: Flags64 -RenderingFlagsKHR :: RenderingFlags -RenderingFlagKHR :: RenderingFlag -RenderingInfoKHR :: RenderingInfo -RenderingAttachmentInfoKHR :: RenderingAttachmentInfo -PipelineRenderingCreateInfoKHR :: PipelineRenderingCreateInfo -PhysicalDeviceDynamicRenderingFeaturesKHR :: PhysicalDeviceDynamicRenderingFeatures -CommandBufferInheritanceRenderingInfoKHR :: CommandBufferInheritanceRenderingInfo -AttachmentSampleCountInfoNV :: AttachmentSampleCountInfoAMD -RenderPassMultiviewCreateInfoKHR :: RenderPassMultiviewCreateInfo -PhysicalDeviceMultiviewFeaturesKHR :: PhysicalDeviceMultiviewFeatures -PhysicalDeviceMultiviewPropertiesKHR :: PhysicalDeviceMultiviewProperties -PhysicalDeviceFeatures2KHR :: PhysicalDeviceFeatures2 -PhysicalDeviceProperties2KHR :: PhysicalDeviceProperties2 -FormatProperties2KHR :: FormatProperties2 -ImageFormatProperties2KHR :: ImageFormatProperties2 -PhysicalDeviceImageFormatInfo2KHR :: PhysicalDeviceImageFormatInfo2 -QueueFamilyProperties2KHR :: QueueFamilyProperties2 -PhysicalDeviceMemoryProperties2KHR :: PhysicalDeviceMemoryProperties2 -SparseImageFormatProperties2KHR :: SparseImageFormatProperties2 -PhysicalDeviceSparseImageFormatInfo2KHR :: PhysicalDeviceSparseImageFormatInfo2 -PeerMemoryFeatureFlagsKHR :: PeerMemoryFeatureFlags -PeerMemoryFeatureFlagKHR :: PeerMemoryFeatureFlag -MemoryAllocateFlagsKHR :: MemoryAllocateFlags -MemoryAllocateFlagKHR :: MemoryAllocateFlag -MemoryAllocateFlagsInfoKHR :: MemoryAllocateFlagsInfo -DeviceGroupRenderPassBeginInfoKHR :: DeviceGroupRenderPassBeginInfo -DeviceGroupCommandBufferBeginInfoKHR :: DeviceGroupCommandBufferBeginInfo -DeviceGroupSubmitInfoKHR :: DeviceGroupSubmitInfo -DeviceGroupBindSparseInfoKHR :: DeviceGroupBindSparseInfo -BindBufferMemoryDeviceGroupInfoKHR :: BindBufferMemoryDeviceGroupInfo -BindImageMemoryDeviceGroupInfoKHR :: BindImageMemoryDeviceGroupInfo -CommandPoolTrimFlagsKHR :: CommandPoolTrimFlags -PhysicalDeviceGroupPropertiesKHR :: PhysicalDeviceGroupProperties -DeviceGroupDeviceCreateInfoKHR :: DeviceGroupDeviceCreateInfo -ExternalMemoryHandleTypeFlagsKHR :: ExternalMemoryHandleTypeFlags -ExternalMemoryHandleTypeFlagKHR :: ExternalMemoryHandleTypeFlag -ExternalMemoryFeatureFlagsKHR :: ExternalMemoryFeatureFlags -ExternalMemoryFeatureFlagKHR :: ExternalMemoryFeatureFlag -ExternalMemoryPropertiesKHR :: ExternalMemoryProperties -PhysicalDeviceExternalImageFormatInfoKHR :: PhysicalDeviceExternalImageFormatInfo -ExternalImageFormatPropertiesKHR :: ExternalImageFormatProperties -PhysicalDeviceExternalBufferInfoKHR :: PhysicalDeviceExternalBufferInfo -ExternalBufferPropertiesKHR :: ExternalBufferProperties -PhysicalDeviceIDPropertiesKHR :: PhysicalDeviceIDProperties -ExternalMemoryImageCreateInfoKHR :: ExternalMemoryImageCreateInfo -ExternalMemoryBufferCreateInfoKHR :: ExternalMemoryBufferCreateInfo -ExportMemoryAllocateInfoKHR :: ExportMemoryAllocateInfo -ExternalSemaphoreHandleTypeFlagsKHR :: ExternalSemaphoreHandleTypeFlags -ExternalSemaphoreHandleTypeFlagKHR :: ExternalSemaphoreHandleTypeFlag -ExternalSemaphoreFeatureFlagsKHR :: ExternalSemaphoreFeatureFlags -ExternalSemaphoreFeatureFlagKHR :: ExternalSemaphoreFeatureFlag -PhysicalDeviceExternalSemaphoreInfoKHR :: PhysicalDeviceExternalSemaphoreInfo -ExternalSemaphorePropertiesKHR :: ExternalSemaphoreProperties -SemaphoreImportFlagsKHR :: SemaphoreImportFlags -SemaphoreImportFlagKHR :: SemaphoreImportFlag -ExportSemaphoreCreateInfoKHR :: ExportSemaphoreCreateInfo -PhysicalDeviceShaderFloat16Int8FeaturesKHR :: PhysicalDeviceShaderFloat16Int8Features -PhysicalDeviceFloat16Int8FeaturesKHR :: PhysicalDeviceShaderFloat16Int8Features -PhysicalDevice16BitStorageFeaturesKHR :: PhysicalDevice16BitStorageFeatures -DescriptorUpdateTemplateKHR :: DescriptorUpdateTemplate -DescriptorUpdateTemplateTypeKHR :: DescriptorUpdateTemplateType -DescriptorUpdateTemplateCreateFlagsKHR :: DescriptorUpdateTemplateCreateFlags -DescriptorUpdateTemplateEntryKHR :: DescriptorUpdateTemplateEntry -DescriptorUpdateTemplateCreateInfoKHR :: DescriptorUpdateTemplateCreateInfo -PhysicalDeviceImagelessFramebufferFeaturesKHR :: PhysicalDeviceImagelessFramebufferFeatures -FramebufferAttachmentsCreateInfoKHR :: FramebufferAttachmentsCreateInfo -FramebufferAttachmentImageInfoKHR :: FramebufferAttachmentImageInfo -RenderPassAttachmentBeginInfoKHR :: RenderPassAttachmentBeginInfo -RenderPassCreateInfo2KHR :: RenderPassCreateInfo2 -AttachmentDescription2KHR :: AttachmentDescription2 -AttachmentReference2KHR :: AttachmentReference2 -SubpassDescription2KHR :: SubpassDescription2 -SubpassDependency2KHR :: SubpassDependency2 -SubpassBeginInfoKHR :: SubpassBeginInfo -SubpassEndInfoKHR :: SubpassEndInfo -ExternalFenceHandleTypeFlagsKHR :: ExternalFenceHandleTypeFlags -ExternalFenceHandleTypeFlagKHR :: ExternalFenceHandleTypeFlag -ExternalFenceFeatureFlagsKHR :: ExternalFenceFeatureFlags -ExternalFenceFeatureFlagKHR :: ExternalFenceFeatureFlag -PhysicalDeviceExternalFenceInfoKHR :: PhysicalDeviceExternalFenceInfo -ExternalFencePropertiesKHR :: ExternalFenceProperties -FenceImportFlagsKHR :: FenceImportFlags -FenceImportFlagKHR :: FenceImportFlag -ExportFenceCreateInfoKHR :: ExportFenceCreateInfo -PointClippingBehaviorKHR :: PointClippingBehavior -TessellationDomainOriginKHR :: TessellationDomainOrigin -PhysicalDevicePointClippingPropertiesKHR :: PhysicalDevicePointClippingProperties -RenderPassInputAttachmentAspectCreateInfoKHR :: RenderPassInputAttachmentAspectCreateInfo -InputAttachmentAspectReferenceKHR :: InputAttachmentAspectReference -ImageViewUsageCreateInfoKHR :: ImageViewUsageCreateInfo -PipelineTessellationDomainOriginStateCreateInfoKHR :: PipelineTessellationDomainOriginStateCreateInfo -PhysicalDeviceVariablePointerFeaturesKHR :: PhysicalDeviceVariablePointersFeatures -PhysicalDeviceVariablePointersFeaturesKHR :: PhysicalDeviceVariablePointersFeatures -MemoryDedicatedRequirementsKHR :: MemoryDedicatedRequirements -MemoryDedicatedAllocateInfoKHR :: MemoryDedicatedAllocateInfo -BufferMemoryRequirementsInfo2KHR :: BufferMemoryRequirementsInfo2 -ImageMemoryRequirementsInfo2KHR :: ImageMemoryRequirementsInfo2 -ImageSparseMemoryRequirementsInfo2KHR :: ImageSparseMemoryRequirementsInfo2 -MemoryRequirements2KHR :: MemoryRequirements2 -SparseImageMemoryRequirements2KHR :: SparseImageMemoryRequirements2 -ImageFormatListCreateInfoKHR :: ImageFormatListCreateInfo -SamplerYcbcrConversionKHR :: SamplerYcbcrConversion -SamplerYcbcrModelConversionKHR :: SamplerYcbcrModelConversion -SamplerYcbcrRangeKHR :: SamplerYcbcrRange -ChromaLocationKHR :: ChromaLocation -SamplerYcbcrConversionCreateInfoKHR :: SamplerYcbcrConversionCreateInfo -SamplerYcbcrConversionInfoKHR :: SamplerYcbcrConversionInfo -BindImagePlaneMemoryInfoKHR :: BindImagePlaneMemoryInfo -ImagePlaneMemoryRequirementsInfoKHR :: ImagePlaneMemoryRequirementsInfo -PhysicalDeviceSamplerYcbcrConversionFeaturesKHR :: PhysicalDeviceSamplerYcbcrConversionFeatures -SamplerYcbcrConversionImageFormatPropertiesKHR :: SamplerYcbcrConversionImageFormatProperties -BindBufferMemoryInfoKHR :: BindBufferMemoryInfo -BindImageMemoryInfoKHR :: BindImageMemoryInfo -PhysicalDeviceMaintenance3PropertiesKHR :: PhysicalDeviceMaintenance3Properties -DescriptorSetLayoutSupportKHR :: DescriptorSetLayoutSupport -PhysicalDeviceShaderSubgroupExtendedTypesFeaturesKHR :: PhysicalDeviceShaderSubgroupExtendedTypesFeatures -PhysicalDevice8BitStorageFeaturesKHR :: PhysicalDevice8BitStorageFeatures -PhysicalDeviceShaderAtomicInt64FeaturesKHR :: PhysicalDeviceShaderAtomicInt64Features -DriverIdKHR :: DriverId -ConformanceVersionKHR :: ConformanceVersion -PhysicalDeviceDriverPropertiesKHR :: PhysicalDeviceDriverProperties -ShaderFloatControlsIndependenceKHR :: ShaderFloatControlsIndependence -PhysicalDeviceFloatControlsPropertiesKHR :: PhysicalDeviceFloatControlsProperties -ResolveModeFlagKHR :: ResolveModeFlag -ResolveModeFlagsKHR :: ResolveModeFlags -SubpassDescriptionDepthStencilResolveKHR :: SubpassDescriptionDepthStencilResolve -PhysicalDeviceDepthStencilResolvePropertiesKHR :: PhysicalDeviceDepthStencilResolveProperties -SemaphoreTypeKHR :: SemaphoreType -SemaphoreWaitFlagKHR :: SemaphoreWaitFlag -SemaphoreWaitFlagsKHR :: SemaphoreWaitFlags -PhysicalDeviceTimelineSemaphoreFeaturesKHR :: PhysicalDeviceTimelineSemaphoreFeatures -PhysicalDeviceTimelineSemaphorePropertiesKHR :: PhysicalDeviceTimelineSemaphoreProperties -SemaphoreTypeCreateInfoKHR :: SemaphoreTypeCreateInfo -TimelineSemaphoreSubmitInfoKHR :: TimelineSemaphoreSubmitInfo -SemaphoreWaitInfoKHR :: SemaphoreWaitInfo -SemaphoreSignalInfoKHR :: SemaphoreSignalInfo -PhysicalDeviceVulkanMemoryModelFeaturesKHR :: PhysicalDeviceVulkanMemoryModelFeatures -PhysicalDeviceShaderTerminateInvocationFeaturesKHR :: PhysicalDeviceShaderTerminateInvocationFeatures -PhysicalDeviceSeparateDepthStencilLayoutsFeaturesKHR :: PhysicalDeviceSeparateDepthStencilLayoutsFeatures -AttachmentReferenceStencilLayoutKHR :: AttachmentReferenceStencilLayout -AttachmentDescriptionStencilLayoutKHR :: AttachmentDescriptionStencilLayout -PhysicalDeviceUniformBufferStandardLayoutFeaturesKHR :: PhysicalDeviceUniformBufferStandardLayoutFeatures -PhysicalDeviceBufferDeviceAddressFeaturesKHR :: PhysicalDeviceBufferDeviceAddressFeatures -BufferDeviceAddressInfoKHR :: BufferDeviceAddressInfo -BufferOpaqueCaptureAddressCreateInfoKHR :: BufferOpaqueCaptureAddressCreateInfo -MemoryOpaqueCaptureAddressAllocateInfoKHR :: MemoryOpaqueCaptureAddressAllocateInfo -DeviceMemoryOpaqueCaptureAddressInfoKHR :: DeviceMemoryOpaqueCaptureAddressInfo -PhysicalDeviceShaderIntegerDotProductFeaturesKHR :: PhysicalDeviceShaderIntegerDotProductFeatures -PhysicalDeviceShaderIntegerDotProductPropertiesKHR :: PhysicalDeviceShaderIntegerDotProductProperties -PipelineStageFlags2KHR :: PipelineStageFlags2 -PipelineStageFlag2KHR :: PipelineStageFlag2 -AccessFlags2KHR :: AccessFlags2 -AccessFlag2KHR :: AccessFlag2 -SubmitFlagKHR :: SubmitFlag -SubmitFlagsKHR :: SubmitFlags -MemoryBarrier2KHR :: MemoryBarrier2 -BufferMemoryBarrier2KHR :: BufferMemoryBarrier2 -ImageMemoryBarrier2KHR :: ImageMemoryBarrier2 -DependencyInfoKHR :: DependencyInfo -SubmitInfo2KHR :: SubmitInfo2 -SemaphoreSubmitInfoKHR :: SemaphoreSubmitInfo -CommandBufferSubmitInfoKHR :: CommandBufferSubmitInfo -PhysicalDeviceSynchronization2FeaturesKHR :: PhysicalDeviceSynchronization2Features -PhysicalDeviceZeroInitializeWorkgroupMemoryFeaturesKHR :: PhysicalDeviceZeroInitializeWorkgroupMemoryFeatures -CopyBufferInfo2KHR :: CopyBufferInfo2 -CopyImageInfo2KHR :: CopyImageInfo2 -CopyBufferToImageInfo2KHR :: CopyBufferToImageInfo2 -CopyImageToBufferInfo2KHR :: CopyImageToBufferInfo2 -BlitImageInfo2KHR :: BlitImageInfo2 -ResolveImageInfo2KHR :: ResolveImageInfo2 -BufferCopy2KHR :: BufferCopy2 -ImageCopy2KHR :: ImageCopy2 -ImageBlit2KHR :: ImageBlit2 -BufferImageCopy2KHR :: BufferImageCopy2 -ImageResolve2KHR :: ImageResolve2 -FormatFeatureFlags2KHR :: FormatFeatureFlags2 -FormatFeatureFlag2KHR :: FormatFeatureFlag2 -FormatProperties3KHR :: FormatProperties3 -PhysicalDeviceMaintenance4FeaturesKHR :: PhysicalDeviceMaintenance4Features -PhysicalDeviceMaintenance4PropertiesKHR :: PhysicalDeviceMaintenance4Properties -DeviceBufferMemoryRequirementsKHR :: DeviceBufferMemoryRequirements -DeviceImageMemoryRequirementsKHR :: DeviceImageMemoryRequirements -PhysicalDeviceTextureCompressionASTCHDRFeaturesEXT :: PhysicalDeviceTextureCompressionASTCHDRFeatures -SamplerReductionModeEXT :: SamplerReductionMode -SamplerReductionModeCreateInfoEXT :: SamplerReductionModeCreateInfo -PhysicalDeviceSamplerFilterMinmaxPropertiesEXT :: PhysicalDeviceSamplerFilterMinmaxProperties -PhysicalDeviceInlineUniformBlockFeaturesEXT :: PhysicalDeviceInlineUniformBlockFeatures -PhysicalDeviceInlineUniformBlockPropertiesEXT :: PhysicalDeviceInlineUniformBlockProperties -WriteDescriptorSetInlineUniformBlockEXT :: WriteDescriptorSetInlineUniformBlock -DescriptorPoolInlineUniformBlockCreateInfoEXT :: DescriptorPoolInlineUniformBlockCreateInfo -DescriptorBindingFlagEXT :: DescriptorBindingFlag -DescriptorBindingFlagsEXT :: DescriptorBindingFlags -DescriptorSetLayoutBindingFlagsCreateInfoEXT :: DescriptorSetLayoutBindingFlagsCreateInfo -PhysicalDeviceDescriptorIndexingFeaturesEXT :: PhysicalDeviceDescriptorIndexingFeatures -PhysicalDeviceDescriptorIndexingPropertiesEXT :: PhysicalDeviceDescriptorIndexingProperties -DescriptorSetVariableDescriptorCountAllocateInfoEXT :: DescriptorSetVariableDescriptorCountAllocateInfo -DescriptorSetVariableDescriptorCountLayoutSupportEXT :: DescriptorSetVariableDescriptorCountLayoutSupport -RayTracingShaderGroupTypeNV :: RayTracingShaderGroupTypeKHR -GeometryTypeNV :: GeometryTypeKHR -AccelerationStructureTypeNV :: AccelerationStructureTypeKHR -CopyAccelerationStructureModeNV :: CopyAccelerationStructureModeKHR -GeometryFlagsNV :: GeometryFlagsKHR -GeometryFlagNV :: GeometryFlagKHR -GeometryInstanceFlagsNV :: GeometryInstanceFlagsKHR -GeometryInstanceFlagNV :: GeometryInstanceFlagKHR -BuildAccelerationStructureFlagsNV :: BuildAccelerationStructureFlagsKHR -BuildAccelerationStructureFlagNV :: BuildAccelerationStructureFlagKHR -TransformMatrixNV :: TransformMatrixKHR -AabbPositionsNV :: AabbPositionsKHR -AccelerationStructureInstanceNV :: AccelerationStructureInstanceKHR -QueueGlobalPriorityEXT :: QueueGlobalPriorityKHR -DeviceQueueGlobalPriorityCreateInfoEXT :: DeviceQueueGlobalPriorityCreateInfoKHR -PipelineCreationFeedbackFlagEXT :: PipelineCreationFeedbackFlag -PipelineCreationFeedbackFlagsEXT :: PipelineCreationFeedbackFlags -PipelineCreationFeedbackCreateInfoEXT :: PipelineCreationFeedbackCreateInfo -PipelineCreationFeedbackEXT :: PipelineCreationFeedback -QueryPoolCreateInfoINTEL :: QueryPoolPerformanceQueryCreateInfoINTEL -PhysicalDeviceScalarBlockLayoutFeaturesEXT :: PhysicalDeviceScalarBlockLayoutFeatures -PhysicalDeviceSubgroupSizeControlFeaturesEXT :: PhysicalDeviceSubgroupSizeControlFeatures -PhysicalDeviceSubgroupSizeControlPropertiesEXT :: PhysicalDeviceSubgroupSizeControlProperties -PipelineShaderStageRequiredSubgroupSizeCreateInfoEXT :: PipelineShaderStageRequiredSubgroupSizeCreateInfo -PhysicalDeviceBufferAddressFeaturesEXT :: PhysicalDeviceBufferDeviceAddressFeaturesEXT -BufferDeviceAddressInfoEXT :: BufferDeviceAddressInfo -ToolPurposeFlagEXT :: ToolPurposeFlag -ToolPurposeFlagsEXT :: ToolPurposeFlags -PhysicalDeviceToolPropertiesEXT :: PhysicalDeviceToolProperties -ImageStencilUsageCreateInfoEXT :: ImageStencilUsageCreateInfo -PhysicalDeviceHostQueryResetFeaturesEXT :: PhysicalDeviceHostQueryResetFeatures -PhysicalDeviceShaderDemoteToHelperInvocationFeaturesEXT :: PhysicalDeviceShaderDemoteToHelperInvocationFeatures -PhysicalDeviceTexelBufferAlignmentPropertiesEXT :: PhysicalDeviceTexelBufferAlignmentProperties -PrivateDataSlotEXT :: PrivateDataSlot -PrivateDataSlotCreateFlagsEXT :: PrivateDataSlotCreateFlags -PhysicalDevicePrivateDataFeaturesEXT :: PhysicalDevicePrivateDataFeatures -DevicePrivateDataCreateInfoEXT :: DevicePrivateDataCreateInfo -PrivateDataSlotCreateInfoEXT :: PrivateDataSlotCreateInfo -PhysicalDevicePipelineCreationCacheControlFeaturesEXT :: PhysicalDevicePipelineCreationCacheControlFeatures -PhysicalDeviceImageRobustnessFeaturesEXT :: PhysicalDeviceImageRobustnessFeatures -PhysicalDeviceGlobalPriorityQueryFeaturesEXT :: PhysicalDeviceGlobalPriorityQueryFeaturesKHR -QueueFamilyGlobalPriorityPropertiesEXT :: QueueFamilyGlobalPriorityPropertiesKHR - - +// +// Vulkan wrapper generated from "https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/master/include/vulkan/vulkan_core.h" +// +package vulkan + +import "core:c" + +when ODIN_OS == .Windows { + import win32 "core:sys/windows" + + HINSTANCE :: win32.HINSTANCE + HWND :: win32.HWND + HMONITOR :: win32.HMONITOR + HANDLE :: win32.HANDLE + LPCWSTR :: win32.LPCWSTR + SECURITY_ATTRIBUTES :: win32.SECURITY_ATTRIBUTES + DWORD :: win32.DWORD + LONG :: win32.LONG + LUID :: win32.LUID +} else { + HINSTANCE :: distinct rawptr + HWND :: distinct rawptr + HMONITOR :: distinct rawptr + HANDLE :: distinct rawptr + LPCWSTR :: ^u16 + SECURITY_ATTRIBUTES :: struct {} + DWORD :: u32 + LONG :: c.long + LUID :: struct { + LowPart: DWORD, + HighPart: LONG, + } +} + +CAMetalLayer :: struct {} + +MTLBuffer_id :: rawptr +MTLTexture_id :: rawptr +MTLSharedEvent_id :: rawptr +MTLDevice_id :: rawptr +MTLCommandQueue_id :: rawptr + +/********************************/ + +Extent2D :: struct { + width: u32, + height: u32, +} + +Extent3D :: struct { + width: u32, + height: u32, + depth: u32, +} + +Offset2D :: struct { + x: i32, + y: i32, +} + +Offset3D :: struct { + x: i32, + y: i32, + z: i32, +} + +Rect2D :: struct { + offset: Offset2D, + extent: Extent2D, +} + +BaseInStructure :: struct { + sType: StructureType, + pNext: ^BaseInStructure, +} + +BaseOutStructure :: struct { + sType: StructureType, + pNext: ^BaseOutStructure, +} + +BufferMemoryBarrier :: struct { + sType: StructureType, + pNext: rawptr, + srcAccessMask: AccessFlags, + dstAccessMask: AccessFlags, + srcQueueFamilyIndex: u32, + dstQueueFamilyIndex: u32, + buffer: Buffer, + offset: DeviceSize, + size: DeviceSize, +} + +DispatchIndirectCommand :: struct { + x: u32, + y: u32, + z: u32, +} + +DrawIndexedIndirectCommand :: struct { + indexCount: u32, + instanceCount: u32, + firstIndex: u32, + vertexOffset: i32, + firstInstance: u32, +} + +DrawIndirectCommand :: struct { + vertexCount: u32, + instanceCount: u32, + firstVertex: u32, + firstInstance: u32, +} + +ImageSubresourceRange :: struct { + aspectMask: ImageAspectFlags, + baseMipLevel: u32, + levelCount: u32, + baseArrayLayer: u32, + layerCount: u32, +} + +ImageMemoryBarrier :: struct { + sType: StructureType, + pNext: rawptr, + srcAccessMask: AccessFlags, + dstAccessMask: AccessFlags, + oldLayout: ImageLayout, + newLayout: ImageLayout, + srcQueueFamilyIndex: u32, + dstQueueFamilyIndex: u32, + image: Image, + subresourceRange: ImageSubresourceRange, +} + +MemoryBarrier :: struct { + sType: StructureType, + pNext: rawptr, + srcAccessMask: AccessFlags, + dstAccessMask: AccessFlags, +} + +PipelineCacheHeaderVersionOne :: struct { + headerSize: u32, + headerVersion: PipelineCacheHeaderVersion, + vendorID: u32, + deviceID: u32, + pipelineCacheUUID: [UUID_SIZE]u8, +} + +AllocationCallbacks :: struct { + pUserData: rawptr, + pfnAllocation: ProcAllocationFunction, + pfnReallocation: ProcReallocationFunction, + pfnFree: ProcFreeFunction, + pfnInternalAllocation: ProcInternalAllocationNotification, + pfnInternalFree: ProcInternalFreeNotification, +} + +ApplicationInfo :: struct { + sType: StructureType, + pNext: rawptr, + pApplicationName: cstring, + applicationVersion: u32, + pEngineName: cstring, + engineVersion: u32, + apiVersion: u32, +} + +FormatProperties :: struct { + linearTilingFeatures: FormatFeatureFlags, + optimalTilingFeatures: FormatFeatureFlags, + bufferFeatures: FormatFeatureFlags, +} + +ImageFormatProperties :: struct { + maxExtent: Extent3D, + maxMipLevels: u32, + maxArrayLayers: u32, + sampleCounts: SampleCountFlags, + maxResourceSize: DeviceSize, +} + +InstanceCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + flags: InstanceCreateFlags, + pApplicationInfo: ^ApplicationInfo, + enabledLayerCount: u32, + ppEnabledLayerNames: [^]cstring, + enabledExtensionCount: u32, + ppEnabledExtensionNames: [^]cstring, +} + +MemoryHeap :: struct { + size: DeviceSize, + flags: MemoryHeapFlags, +} + +MemoryType :: struct { + propertyFlags: MemoryPropertyFlags, + heapIndex: u32, +} + +PhysicalDeviceFeatures :: struct { + robustBufferAccess: b32, + fullDrawIndexUint32: b32, + imageCubeArray: b32, + independentBlend: b32, + geometryShader: b32, + tessellationShader: b32, + sampleRateShading: b32, + dualSrcBlend: b32, + logicOp: b32, + multiDrawIndirect: b32, + drawIndirectFirstInstance: b32, + depthClamp: b32, + depthBiasClamp: b32, + fillModeNonSolid: b32, + depthBounds: b32, + wideLines: b32, + largePoints: b32, + alphaToOne: b32, + multiViewport: b32, + samplerAnisotropy: b32, + textureCompressionETC2: b32, + textureCompressionASTC_LDR: b32, + textureCompressionBC: b32, + occlusionQueryPrecise: b32, + pipelineStatisticsQuery: b32, + vertexPipelineStoresAndAtomics: b32, + fragmentStoresAndAtomics: b32, + shaderTessellationAndGeometryPointSize: b32, + shaderImageGatherExtended: b32, + shaderStorageImageExtendedFormats: b32, + shaderStorageImageMultisample: b32, + shaderStorageImageReadWithoutFormat: b32, + shaderStorageImageWriteWithoutFormat: b32, + shaderUniformBufferArrayDynamicIndexing: b32, + shaderSampledImageArrayDynamicIndexing: b32, + shaderStorageBufferArrayDynamicIndexing: b32, + shaderStorageImageArrayDynamicIndexing: b32, + shaderClipDistance: b32, + shaderCullDistance: b32, + shaderFloat64: b32, + shaderInt64: b32, + shaderInt16: b32, + shaderResourceResidency: b32, + shaderResourceMinLod: b32, + sparseBinding: b32, + sparseResidencyBuffer: b32, + sparseResidencyImage2D: b32, + sparseResidencyImage3D: b32, + sparseResidency2Samples: b32, + sparseResidency4Samples: b32, + sparseResidency8Samples: b32, + sparseResidency16Samples: b32, + sparseResidencyAliased: b32, + variableMultisampleRate: b32, + inheritedQueries: b32, +} + +PhysicalDeviceLimits :: struct { + maxImageDimension1D: u32, + maxImageDimension2D: u32, + maxImageDimension3D: u32, + maxImageDimensionCube: u32, + maxImageArrayLayers: u32, + maxTexelBufferElements: u32, + maxUniformBufferRange: u32, + maxStorageBufferRange: u32, + maxPushConstantsSize: u32, + maxMemoryAllocationCount: u32, + maxSamplerAllocationCount: u32, + bufferImageGranularity: DeviceSize, + sparseAddressSpaceSize: DeviceSize, + maxBoundDescriptorSets: u32, + maxPerStageDescriptorSamplers: u32, + maxPerStageDescriptorUniformBuffers: u32, + maxPerStageDescriptorStorageBuffers: u32, + maxPerStageDescriptorSampledImages: u32, + maxPerStageDescriptorStorageImages: u32, + maxPerStageDescriptorInputAttachments: u32, + maxPerStageResources: u32, + maxDescriptorSetSamplers: u32, + maxDescriptorSetUniformBuffers: u32, + maxDescriptorSetUniformBuffersDynamic: u32, + maxDescriptorSetStorageBuffers: u32, + maxDescriptorSetStorageBuffersDynamic: u32, + maxDescriptorSetSampledImages: u32, + maxDescriptorSetStorageImages: u32, + maxDescriptorSetInputAttachments: u32, + maxVertexInputAttributes: u32, + maxVertexInputBindings: u32, + maxVertexInputAttributeOffset: u32, + maxVertexInputBindingStride: u32, + maxVertexOutputComponents: u32, + maxTessellationGenerationLevel: u32, + maxTessellationPatchSize: u32, + maxTessellationControlPerVertexInputComponents: u32, + maxTessellationControlPerVertexOutputComponents: u32, + maxTessellationControlPerPatchOutputComponents: u32, + maxTessellationControlTotalOutputComponents: u32, + maxTessellationEvaluationInputComponents: u32, + maxTessellationEvaluationOutputComponents: u32, + maxGeometryShaderInvocations: u32, + maxGeometryInputComponents: u32, + maxGeometryOutputComponents: u32, + maxGeometryOutputVertices: u32, + maxGeometryTotalOutputComponents: u32, + maxFragmentInputComponents: u32, + maxFragmentOutputAttachments: u32, + maxFragmentDualSrcAttachments: u32, + maxFragmentCombinedOutputResources: u32, + maxComputeSharedMemorySize: u32, + maxComputeWorkGroupCount: [3]u32, + maxComputeWorkGroupInvocations: u32, + maxComputeWorkGroupSize: [3]u32, + subPixelPrecisionBits: u32, + subTexelPrecisionBits: u32, + mipmapPrecisionBits: u32, + maxDrawIndexedIndexValue: u32, + maxDrawIndirectCount: u32, + maxSamplerLodBias: f32, + maxSamplerAnisotropy: f32, + maxViewports: u32, + maxViewportDimensions: [2]u32, + viewportBoundsRange: [2]f32, + viewportSubPixelBits: u32, + minMemoryMapAlignment: int, + minTexelBufferOffsetAlignment: DeviceSize, + minUniformBufferOffsetAlignment: DeviceSize, + minStorageBufferOffsetAlignment: DeviceSize, + minTexelOffset: i32, + maxTexelOffset: u32, + minTexelGatherOffset: i32, + maxTexelGatherOffset: u32, + minInterpolationOffset: f32, + maxInterpolationOffset: f32, + subPixelInterpolationOffsetBits: u32, + maxFramebufferWidth: u32, + maxFramebufferHeight: u32, + maxFramebufferLayers: u32, + framebufferColorSampleCounts: SampleCountFlags, + framebufferDepthSampleCounts: SampleCountFlags, + framebufferStencilSampleCounts: SampleCountFlags, + framebufferNoAttachmentsSampleCounts: SampleCountFlags, + maxColorAttachments: u32, + sampledImageColorSampleCounts: SampleCountFlags, + sampledImageIntegerSampleCounts: SampleCountFlags, + sampledImageDepthSampleCounts: SampleCountFlags, + sampledImageStencilSampleCounts: SampleCountFlags, + storageImageSampleCounts: SampleCountFlags, + maxSampleMaskWords: u32, + timestampComputeAndGraphics: b32, + timestampPeriod: f32, + maxClipDistances: u32, + maxCullDistances: u32, + maxCombinedClipAndCullDistances: u32, + discreteQueuePriorities: u32, + pointSizeRange: [2]f32, + lineWidthRange: [2]f32, + pointSizeGranularity: f32, + lineWidthGranularity: f32, + strictLines: b32, + standardSampleLocations: b32, + optimalBufferCopyOffsetAlignment: DeviceSize, + optimalBufferCopyRowPitchAlignment: DeviceSize, + nonCoherentAtomSize: DeviceSize, +} + +PhysicalDeviceMemoryProperties :: struct { + memoryTypeCount: u32, + memoryTypes: [MAX_MEMORY_TYPES]MemoryType, + memoryHeapCount: u32, + memoryHeaps: [MAX_MEMORY_HEAPS]MemoryHeap, +} + +PhysicalDeviceSparseProperties :: struct { + residencyStandard2DBlockShape: b32, + residencyStandard2DMultisampleBlockShape: b32, + residencyStandard3DBlockShape: b32, + residencyAlignedMipSize: b32, + residencyNonResidentStrict: b32, +} + +PhysicalDeviceProperties :: struct { + apiVersion: u32, + driverVersion: u32, + vendorID: u32, + deviceID: u32, + deviceType: PhysicalDeviceType, + deviceName: [MAX_PHYSICAL_DEVICE_NAME_SIZE]byte, + pipelineCacheUUID: [UUID_SIZE]u8, + limits: PhysicalDeviceLimits, + sparseProperties: PhysicalDeviceSparseProperties, +} + +QueueFamilyProperties :: struct { + queueFlags: QueueFlags, + queueCount: u32, + timestampValidBits: u32, + minImageTransferGranularity: Extent3D, +} + +DeviceQueueCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + flags: DeviceQueueCreateFlags, + queueFamilyIndex: u32, + queueCount: u32, + pQueuePriorities: [^]f32, +} + +DeviceCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + flags: DeviceCreateFlags, + queueCreateInfoCount: u32, + pQueueCreateInfos: [^]DeviceQueueCreateInfo, + enabledLayerCount: u32, + ppEnabledLayerNames: [^]cstring, + enabledExtensionCount: u32, + ppEnabledExtensionNames: [^]cstring, + pEnabledFeatures: [^]PhysicalDeviceFeatures, +} + +ExtensionProperties :: struct { + extensionName: [MAX_EXTENSION_NAME_SIZE]byte, + specVersion: u32, +} + +LayerProperties :: struct { + layerName: [MAX_EXTENSION_NAME_SIZE]byte, + specVersion: u32, + implementationVersion: u32, + description: [MAX_DESCRIPTION_SIZE]byte, +} + +SubmitInfo :: struct { + sType: StructureType, + pNext: rawptr, + waitSemaphoreCount: u32, + pWaitSemaphores: [^]Semaphore, + pWaitDstStageMask: [^]PipelineStageFlags, + commandBufferCount: u32, + pCommandBuffers: [^]CommandBuffer, + signalSemaphoreCount: u32, + pSignalSemaphores: [^]Semaphore, +} + +MappedMemoryRange :: struct { + sType: StructureType, + pNext: rawptr, + memory: DeviceMemory, + offset: DeviceSize, + size: DeviceSize, +} + +MemoryAllocateInfo :: struct { + sType: StructureType, + pNext: rawptr, + allocationSize: DeviceSize, + memoryTypeIndex: u32, +} + +MemoryRequirements :: struct { + size: DeviceSize, + alignment: DeviceSize, + memoryTypeBits: u32, +} + +SparseMemoryBind :: struct { + resourceOffset: DeviceSize, + size: DeviceSize, + memory: DeviceMemory, + memoryOffset: DeviceSize, + flags: SparseMemoryBindFlags, +} + +SparseBufferMemoryBindInfo :: struct { + buffer: Buffer, + bindCount: u32, + pBinds: [^]SparseMemoryBind, +} + +SparseImageOpaqueMemoryBindInfo :: struct { + image: Image, + bindCount: u32, + pBinds: [^]SparseMemoryBind, +} + +ImageSubresource :: struct { + aspectMask: ImageAspectFlags, + mipLevel: u32, + arrayLayer: u32, +} + +SparseImageMemoryBind :: struct { + subresource: ImageSubresource, + offset: Offset3D, + extent: Extent3D, + memory: DeviceMemory, + memoryOffset: DeviceSize, + flags: SparseMemoryBindFlags, +} + +SparseImageMemoryBindInfo :: struct { + image: Image, + bindCount: u32, + pBinds: [^]SparseImageMemoryBind, +} + +BindSparseInfo :: struct { + sType: StructureType, + pNext: rawptr, + waitSemaphoreCount: u32, + pWaitSemaphores: [^]Semaphore, + bufferBindCount: u32, + pBufferBinds: [^]SparseBufferMemoryBindInfo, + imageOpaqueBindCount: u32, + pImageOpaqueBinds: [^]SparseImageOpaqueMemoryBindInfo, + imageBindCount: u32, + pImageBinds: [^]SparseImageMemoryBindInfo, + signalSemaphoreCount: u32, + pSignalSemaphores: [^]Semaphore, +} + +SparseImageFormatProperties :: struct { + aspectMask: ImageAspectFlags, + imageGranularity: Extent3D, + flags: SparseImageFormatFlags, +} + +SparseImageMemoryRequirements :: struct { + formatProperties: SparseImageFormatProperties, + imageMipTailFirstLod: u32, + imageMipTailSize: DeviceSize, + imageMipTailOffset: DeviceSize, + imageMipTailStride: DeviceSize, +} + +FenceCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + flags: FenceCreateFlags, +} + +SemaphoreCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + flags: SemaphoreCreateFlags, +} + +EventCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + flags: EventCreateFlags, +} + +QueryPoolCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + flags: QueryPoolCreateFlags, + queryType: QueryType, + queryCount: u32, + pipelineStatistics: QueryPipelineStatisticFlags, +} + +BufferCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + flags: BufferCreateFlags, + size: DeviceSize, + usage: BufferUsageFlags, + sharingMode: SharingMode, + queueFamilyIndexCount: u32, + pQueueFamilyIndices: [^]u32, +} + +BufferViewCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + flags: BufferViewCreateFlags, + buffer: Buffer, + format: Format, + offset: DeviceSize, + range: DeviceSize, +} + +ImageCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + flags: ImageCreateFlags, + imageType: ImageType, + format: Format, + extent: Extent3D, + mipLevels: u32, + arrayLayers: u32, + samples: SampleCountFlags, + tiling: ImageTiling, + usage: ImageUsageFlags, + sharingMode: SharingMode, + queueFamilyIndexCount: u32, + pQueueFamilyIndices: [^]u32, + initialLayout: ImageLayout, +} + +SubresourceLayout :: struct { + offset: DeviceSize, + size: DeviceSize, + rowPitch: DeviceSize, + arrayPitch: DeviceSize, + depthPitch: DeviceSize, +} + +ComponentMapping :: struct { + r: ComponentSwizzle, + g: ComponentSwizzle, + b: ComponentSwizzle, + a: ComponentSwizzle, +} + +ImageViewCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + flags: ImageViewCreateFlags, + image: Image, + viewType: ImageViewType, + format: Format, + components: ComponentMapping, + subresourceRange: ImageSubresourceRange, +} + +ShaderModuleCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + flags: ShaderModuleCreateFlags, + codeSize: int, + pCode: ^u32, +} + +PipelineCacheCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + flags: PipelineCacheCreateFlags, + initialDataSize: int, + pInitialData: rawptr, +} + +SpecializationMapEntry :: struct { + constantID: u32, + offset: u32, + size: int, +} + +SpecializationInfo :: struct { + mapEntryCount: u32, + pMapEntries: [^]SpecializationMapEntry, + dataSize: int, + pData: rawptr, +} + +PipelineShaderStageCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + flags: PipelineShaderStageCreateFlags, + stage: ShaderStageFlags, + module: ShaderModule, + pName: cstring, + pSpecializationInfo: ^SpecializationInfo, +} + +ComputePipelineCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + flags: PipelineCreateFlags, + stage: PipelineShaderStageCreateInfo, + layout: PipelineLayout, + basePipelineHandle: Pipeline, + basePipelineIndex: i32, +} + +VertexInputBindingDescription :: struct { + binding: u32, + stride: u32, + inputRate: VertexInputRate, +} + +VertexInputAttributeDescription :: struct { + location: u32, + binding: u32, + format: Format, + offset: u32, +} + +PipelineVertexInputStateCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + flags: PipelineVertexInputStateCreateFlags, + vertexBindingDescriptionCount: u32, + pVertexBindingDescriptions: [^]VertexInputBindingDescription, + vertexAttributeDescriptionCount: u32, + pVertexAttributeDescriptions: [^]VertexInputAttributeDescription, +} + +PipelineInputAssemblyStateCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + flags: PipelineInputAssemblyStateCreateFlags, + topology: PrimitiveTopology, + primitiveRestartEnable: b32, +} + +PipelineTessellationStateCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + flags: PipelineTessellationStateCreateFlags, + patchControlPoints: u32, +} + +Viewport :: struct { + x: f32, + y: f32, + width: f32, + height: f32, + minDepth: f32, + maxDepth: f32, +} + +PipelineViewportStateCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + flags: PipelineViewportStateCreateFlags, + viewportCount: u32, + pViewports: [^]Viewport, + scissorCount: u32, + pScissors: [^]Rect2D, +} + +PipelineRasterizationStateCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + flags: PipelineRasterizationStateCreateFlags, + depthClampEnable: b32, + rasterizerDiscardEnable: b32, + polygonMode: PolygonMode, + cullMode: CullModeFlags, + frontFace: FrontFace, + depthBiasEnable: b32, + depthBiasConstantFactor: f32, + depthBiasClamp: f32, + depthBiasSlopeFactor: f32, + lineWidth: f32, +} + +PipelineMultisampleStateCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + flags: PipelineMultisampleStateCreateFlags, + rasterizationSamples: SampleCountFlags, + sampleShadingEnable: b32, + minSampleShading: f32, + pSampleMask: ^SampleMask, + alphaToCoverageEnable: b32, + alphaToOneEnable: b32, +} + +StencilOpState :: struct { + failOp: StencilOp, + passOp: StencilOp, + depthFailOp: StencilOp, + compareOp: CompareOp, + compareMask: u32, + writeMask: u32, + reference: u32, +} + +PipelineDepthStencilStateCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + flags: PipelineDepthStencilStateCreateFlags, + depthTestEnable: b32, + depthWriteEnable: b32, + depthCompareOp: CompareOp, + depthBoundsTestEnable: b32, + stencilTestEnable: b32, + front: StencilOpState, + back: StencilOpState, + minDepthBounds: f32, + maxDepthBounds: f32, +} + +PipelineColorBlendAttachmentState :: struct { + blendEnable: b32, + srcColorBlendFactor: BlendFactor, + dstColorBlendFactor: BlendFactor, + colorBlendOp: BlendOp, + srcAlphaBlendFactor: BlendFactor, + dstAlphaBlendFactor: BlendFactor, + alphaBlendOp: BlendOp, + colorWriteMask: ColorComponentFlags, +} + +PipelineColorBlendStateCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + flags: PipelineColorBlendStateCreateFlags, + logicOpEnable: b32, + logicOp: LogicOp, + attachmentCount: u32, + pAttachments: [^]PipelineColorBlendAttachmentState, + blendConstants: [4]f32, +} + +PipelineDynamicStateCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + flags: PipelineDynamicStateCreateFlags, + dynamicStateCount: u32, + pDynamicStates: [^]DynamicState, +} + +GraphicsPipelineCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + flags: PipelineCreateFlags, + stageCount: u32, + pStages: [^]PipelineShaderStageCreateInfo, + pVertexInputState: ^PipelineVertexInputStateCreateInfo, + pInputAssemblyState: ^PipelineInputAssemblyStateCreateInfo, + pTessellationState: ^PipelineTessellationStateCreateInfo, + pViewportState: ^PipelineViewportStateCreateInfo, + pRasterizationState: ^PipelineRasterizationStateCreateInfo, + pMultisampleState: ^PipelineMultisampleStateCreateInfo, + pDepthStencilState: ^PipelineDepthStencilStateCreateInfo, + pColorBlendState: ^PipelineColorBlendStateCreateInfo, + pDynamicState: ^PipelineDynamicStateCreateInfo, + layout: PipelineLayout, + renderPass: RenderPass, + subpass: u32, + basePipelineHandle: Pipeline, + basePipelineIndex: i32, +} + +PushConstantRange :: struct { + stageFlags: ShaderStageFlags, + offset: u32, + size: u32, +} + +PipelineLayoutCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + flags: PipelineLayoutCreateFlags, + setLayoutCount: u32, + pSetLayouts: [^]DescriptorSetLayout, + pushConstantRangeCount: u32, + pPushConstantRanges: [^]PushConstantRange, +} + +SamplerCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + flags: SamplerCreateFlags, + magFilter: Filter, + minFilter: Filter, + mipmapMode: SamplerMipmapMode, + addressModeU: SamplerAddressMode, + addressModeV: SamplerAddressMode, + addressModeW: SamplerAddressMode, + mipLodBias: f32, + anisotropyEnable: b32, + maxAnisotropy: f32, + compareEnable: b32, + compareOp: CompareOp, + minLod: f32, + maxLod: f32, + borderColor: BorderColor, + unnormalizedCoordinates: b32, +} + +CopyDescriptorSet :: struct { + sType: StructureType, + pNext: rawptr, + srcSet: DescriptorSet, + srcBinding: u32, + srcArrayElement: u32, + dstSet: DescriptorSet, + dstBinding: u32, + dstArrayElement: u32, + descriptorCount: u32, +} + +DescriptorBufferInfo :: struct { + buffer: Buffer, + offset: DeviceSize, + range: DeviceSize, +} + +DescriptorImageInfo :: struct { + sampler: Sampler, + imageView: ImageView, + imageLayout: ImageLayout, +} + +DescriptorPoolSize :: struct { + type: DescriptorType, + descriptorCount: u32, +} + +DescriptorPoolCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + flags: DescriptorPoolCreateFlags, + maxSets: u32, + poolSizeCount: u32, + pPoolSizes: [^]DescriptorPoolSize, +} + +DescriptorSetAllocateInfo :: struct { + sType: StructureType, + pNext: rawptr, + descriptorPool: DescriptorPool, + descriptorSetCount: u32, + pSetLayouts: [^]DescriptorSetLayout, +} + +DescriptorSetLayoutBinding :: struct { + binding: u32, + descriptorType: DescriptorType, + descriptorCount: u32, + stageFlags: ShaderStageFlags, + pImmutableSamplers: [^]Sampler, +} + +DescriptorSetLayoutCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + flags: DescriptorSetLayoutCreateFlags, + bindingCount: u32, + pBindings: [^]DescriptorSetLayoutBinding, +} + +WriteDescriptorSet :: struct { + sType: StructureType, + pNext: rawptr, + dstSet: DescriptorSet, + dstBinding: u32, + dstArrayElement: u32, + descriptorCount: u32, + descriptorType: DescriptorType, + pImageInfo: ^DescriptorImageInfo, + pBufferInfo: ^DescriptorBufferInfo, + pTexelBufferView: ^BufferView, +} + +AttachmentDescription :: struct { + flags: AttachmentDescriptionFlags, + format: Format, + samples: SampleCountFlags, + loadOp: AttachmentLoadOp, + storeOp: AttachmentStoreOp, + stencilLoadOp: AttachmentLoadOp, + stencilStoreOp: AttachmentStoreOp, + initialLayout: ImageLayout, + finalLayout: ImageLayout, +} + +AttachmentReference :: struct { + attachment: u32, + layout: ImageLayout, +} + +FramebufferCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + flags: FramebufferCreateFlags, + renderPass: RenderPass, + attachmentCount: u32, + pAttachments: [^]ImageView, + width: u32, + height: u32, + layers: u32, +} + +SubpassDescription :: struct { + flags: SubpassDescriptionFlags, + pipelineBindPoint: PipelineBindPoint, + inputAttachmentCount: u32, + pInputAttachments: [^]AttachmentReference, + colorAttachmentCount: u32, + pColorAttachments: [^]AttachmentReference, + pResolveAttachments: [^]AttachmentReference, + pDepthStencilAttachment: ^AttachmentReference, + preserveAttachmentCount: u32, + pPreserveAttachments: [^]u32, +} + +SubpassDependency :: struct { + srcSubpass: u32, + dstSubpass: u32, + srcStageMask: PipelineStageFlags, + dstStageMask: PipelineStageFlags, + srcAccessMask: AccessFlags, + dstAccessMask: AccessFlags, + dependencyFlags: DependencyFlags, +} + +RenderPassCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + flags: RenderPassCreateFlags, + attachmentCount: u32, + pAttachments: [^]AttachmentDescription, + subpassCount: u32, + pSubpasses: [^]SubpassDescription, + dependencyCount: u32, + pDependencies: [^]SubpassDependency, +} + +CommandPoolCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + flags: CommandPoolCreateFlags, + queueFamilyIndex: u32, +} + +CommandBufferAllocateInfo :: struct { + sType: StructureType, + pNext: rawptr, + commandPool: CommandPool, + level: CommandBufferLevel, + commandBufferCount: u32, +} + +CommandBufferInheritanceInfo :: struct { + sType: StructureType, + pNext: rawptr, + renderPass: RenderPass, + subpass: u32, + framebuffer: Framebuffer, + occlusionQueryEnable: b32, + queryFlags: QueryControlFlags, + pipelineStatistics: QueryPipelineStatisticFlags, +} + +CommandBufferBeginInfo :: struct { + sType: StructureType, + pNext: rawptr, + flags: CommandBufferUsageFlags, + pInheritanceInfo: ^CommandBufferInheritanceInfo, +} + +BufferCopy :: struct { + srcOffset: DeviceSize, + dstOffset: DeviceSize, + size: DeviceSize, +} + +ImageSubresourceLayers :: struct { + aspectMask: ImageAspectFlags, + mipLevel: u32, + baseArrayLayer: u32, + layerCount: u32, +} + +BufferImageCopy :: struct { + bufferOffset: DeviceSize, + bufferRowLength: u32, + bufferImageHeight: u32, + imageSubresource: ImageSubresourceLayers, + imageOffset: Offset3D, + imageExtent: Extent3D, +} + +ClearColorValue :: struct #raw_union { + float32: [4]f32, + int32: [4]i32, + uint32: [4]u32, +} + +ClearDepthStencilValue :: struct { + depth: f32, + stencil: u32, +} + +ClearValue :: struct #raw_union { + color: ClearColorValue, + depthStencil: ClearDepthStencilValue, +} + +ClearAttachment :: struct { + aspectMask: ImageAspectFlags, + colorAttachment: u32, + clearValue: ClearValue, +} + +ClearRect :: struct { + rect: Rect2D, + baseArrayLayer: u32, + layerCount: u32, +} + +ImageBlit :: struct { + srcSubresource: ImageSubresourceLayers, + srcOffsets: [2]Offset3D, + dstSubresource: ImageSubresourceLayers, + dstOffsets: [2]Offset3D, +} + +ImageCopy :: struct { + srcSubresource: ImageSubresourceLayers, + srcOffset: Offset3D, + dstSubresource: ImageSubresourceLayers, + dstOffset: Offset3D, + extent: Extent3D, +} + +ImageResolve :: struct { + srcSubresource: ImageSubresourceLayers, + srcOffset: Offset3D, + dstSubresource: ImageSubresourceLayers, + dstOffset: Offset3D, + extent: Extent3D, +} + +RenderPassBeginInfo :: struct { + sType: StructureType, + pNext: rawptr, + renderPass: RenderPass, + framebuffer: Framebuffer, + renderArea: Rect2D, + clearValueCount: u32, + pClearValues: [^]ClearValue, +} + +PhysicalDeviceSubgroupProperties :: struct { + sType: StructureType, + pNext: rawptr, + subgroupSize: u32, + supportedStages: ShaderStageFlags, + supportedOperations: SubgroupFeatureFlags, + quadOperationsInAllStages: b32, +} + +BindBufferMemoryInfo :: struct { + sType: StructureType, + pNext: rawptr, + buffer: Buffer, + memory: DeviceMemory, + memoryOffset: DeviceSize, +} + +BindImageMemoryInfo :: struct { + sType: StructureType, + pNext: rawptr, + image: Image, + memory: DeviceMemory, + memoryOffset: DeviceSize, +} + +PhysicalDevice16BitStorageFeatures :: struct { + sType: StructureType, + pNext: rawptr, + storageBuffer16BitAccess: b32, + uniformAndStorageBuffer16BitAccess: b32, + storagePushConstant16: b32, + storageInputOutput16: b32, +} + +MemoryDedicatedRequirements :: struct { + sType: StructureType, + pNext: rawptr, + prefersDedicatedAllocation: b32, + requiresDedicatedAllocation: b32, +} + +MemoryDedicatedAllocateInfo :: struct { + sType: StructureType, + pNext: rawptr, + image: Image, + buffer: Buffer, +} + +MemoryAllocateFlagsInfo :: struct { + sType: StructureType, + pNext: rawptr, + flags: MemoryAllocateFlags, + deviceMask: u32, +} + +DeviceGroupRenderPassBeginInfo :: struct { + sType: StructureType, + pNext: rawptr, + deviceMask: u32, + deviceRenderAreaCount: u32, + pDeviceRenderAreas: [^]Rect2D, +} + +DeviceGroupCommandBufferBeginInfo :: struct { + sType: StructureType, + pNext: rawptr, + deviceMask: u32, +} + +DeviceGroupSubmitInfo :: struct { + sType: StructureType, + pNext: rawptr, + waitSemaphoreCount: u32, + pWaitSemaphoreDeviceIndices: [^]u32, + commandBufferCount: u32, + pCommandBufferDeviceMasks: [^]u32, + signalSemaphoreCount: u32, + pSignalSemaphoreDeviceIndices: [^]u32, +} + +DeviceGroupBindSparseInfo :: struct { + sType: StructureType, + pNext: rawptr, + resourceDeviceIndex: u32, + memoryDeviceIndex: u32, +} + +BindBufferMemoryDeviceGroupInfo :: struct { + sType: StructureType, + pNext: rawptr, + deviceIndexCount: u32, + pDeviceIndices: [^]u32, +} + +BindImageMemoryDeviceGroupInfo :: struct { + sType: StructureType, + pNext: rawptr, + deviceIndexCount: u32, + pDeviceIndices: [^]u32, + splitInstanceBindRegionCount: u32, + pSplitInstanceBindRegions: [^]Rect2D, +} + +PhysicalDeviceGroupProperties :: struct { + sType: StructureType, + pNext: rawptr, + physicalDeviceCount: u32, + physicalDevices: [MAX_DEVICE_GROUP_SIZE]PhysicalDevice, + subsetAllocation: b32, +} + +DeviceGroupDeviceCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + physicalDeviceCount: u32, + pPhysicalDevices: [^]PhysicalDevice, +} + +BufferMemoryRequirementsInfo2 :: struct { + sType: StructureType, + pNext: rawptr, + buffer: Buffer, +} + +ImageMemoryRequirementsInfo2 :: struct { + sType: StructureType, + pNext: rawptr, + image: Image, +} + +ImageSparseMemoryRequirementsInfo2 :: struct { + sType: StructureType, + pNext: rawptr, + image: Image, +} + +MemoryRequirements2 :: struct { + sType: StructureType, + pNext: rawptr, + memoryRequirements: MemoryRequirements, +} + +SparseImageMemoryRequirements2 :: struct { + sType: StructureType, + pNext: rawptr, + memoryRequirements: SparseImageMemoryRequirements, +} + +PhysicalDeviceFeatures2 :: struct { + sType: StructureType, + pNext: rawptr, + features: PhysicalDeviceFeatures, +} + +PhysicalDeviceProperties2 :: struct { + sType: StructureType, + pNext: rawptr, + properties: PhysicalDeviceProperties, +} + +FormatProperties2 :: struct { + sType: StructureType, + pNext: rawptr, + formatProperties: FormatProperties, +} + +ImageFormatProperties2 :: struct { + sType: StructureType, + pNext: rawptr, + imageFormatProperties: ImageFormatProperties, +} + +PhysicalDeviceImageFormatInfo2 :: struct { + sType: StructureType, + pNext: rawptr, + format: Format, + type: ImageType, + tiling: ImageTiling, + usage: ImageUsageFlags, + flags: ImageCreateFlags, +} + +QueueFamilyProperties2 :: struct { + sType: StructureType, + pNext: rawptr, + queueFamilyProperties: QueueFamilyProperties, +} + +PhysicalDeviceMemoryProperties2 :: struct { + sType: StructureType, + pNext: rawptr, + memoryProperties: PhysicalDeviceMemoryProperties, +} + +SparseImageFormatProperties2 :: struct { + sType: StructureType, + pNext: rawptr, + properties: SparseImageFormatProperties, +} + +PhysicalDeviceSparseImageFormatInfo2 :: struct { + sType: StructureType, + pNext: rawptr, + format: Format, + type: ImageType, + samples: SampleCountFlags, + usage: ImageUsageFlags, + tiling: ImageTiling, +} + +PhysicalDevicePointClippingProperties :: struct { + sType: StructureType, + pNext: rawptr, + pointClippingBehavior: PointClippingBehavior, +} + +InputAttachmentAspectReference :: struct { + subpass: u32, + inputAttachmentIndex: u32, + aspectMask: ImageAspectFlags, +} + +RenderPassInputAttachmentAspectCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + aspectReferenceCount: u32, + pAspectReferences: [^]InputAttachmentAspectReference, +} + +ImageViewUsageCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + usage: ImageUsageFlags, +} + +PipelineTessellationDomainOriginStateCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + domainOrigin: TessellationDomainOrigin, +} + +RenderPassMultiviewCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + subpassCount: u32, + pViewMasks: [^]u32, + dependencyCount: u32, + pViewOffsets: [^]i32, + correlationMaskCount: u32, + pCorrelationMasks: [^]u32, +} + +PhysicalDeviceMultiviewFeatures :: struct { + sType: StructureType, + pNext: rawptr, + multiview: b32, + multiviewGeometryShader: b32, + multiviewTessellationShader: b32, +} + +PhysicalDeviceMultiviewProperties :: struct { + sType: StructureType, + pNext: rawptr, + maxMultiviewViewCount: u32, + maxMultiviewInstanceIndex: u32, +} + +PhysicalDeviceVariablePointersFeatures :: struct { + sType: StructureType, + pNext: rawptr, + variablePointersStorageBuffer: b32, + variablePointers: b32, +} + +PhysicalDeviceProtectedMemoryFeatures :: struct { + sType: StructureType, + pNext: rawptr, + protectedMemory: b32, +} + +PhysicalDeviceProtectedMemoryProperties :: struct { + sType: StructureType, + pNext: rawptr, + protectedNoFault: b32, +} + +DeviceQueueInfo2 :: struct { + sType: StructureType, + pNext: rawptr, + flags: DeviceQueueCreateFlags, + queueFamilyIndex: u32, + queueIndex: u32, +} + +ProtectedSubmitInfo :: struct { + sType: StructureType, + pNext: rawptr, + protectedSubmit: b32, +} + +SamplerYcbcrConversionCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + format: Format, + ycbcrModel: SamplerYcbcrModelConversion, + ycbcrRange: SamplerYcbcrRange, + components: ComponentMapping, + xChromaOffset: ChromaLocation, + yChromaOffset: ChromaLocation, + chromaFilter: Filter, + forceExplicitReconstruction: b32, +} + +SamplerYcbcrConversionInfo :: struct { + sType: StructureType, + pNext: rawptr, + conversion: SamplerYcbcrConversion, +} + +BindImagePlaneMemoryInfo :: struct { + sType: StructureType, + pNext: rawptr, + planeAspect: ImageAspectFlags, +} + +ImagePlaneMemoryRequirementsInfo :: struct { + sType: StructureType, + pNext: rawptr, + planeAspect: ImageAspectFlags, +} + +PhysicalDeviceSamplerYcbcrConversionFeatures :: struct { + sType: StructureType, + pNext: rawptr, + samplerYcbcrConversion: b32, +} + +SamplerYcbcrConversionImageFormatProperties :: struct { + sType: StructureType, + pNext: rawptr, + combinedImageSamplerDescriptorCount: u32, +} + +DescriptorUpdateTemplateEntry :: struct { + dstBinding: u32, + dstArrayElement: u32, + descriptorCount: u32, + descriptorType: DescriptorType, + offset: int, + stride: int, +} + +DescriptorUpdateTemplateCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + flags: DescriptorUpdateTemplateCreateFlags, + descriptorUpdateEntryCount: u32, + pDescriptorUpdateEntries: [^]DescriptorUpdateTemplateEntry, + templateType: DescriptorUpdateTemplateType, + descriptorSetLayout: DescriptorSetLayout, + pipelineBindPoint: PipelineBindPoint, + pipelineLayout: PipelineLayout, + set: u32, +} + +ExternalMemoryProperties :: struct { + externalMemoryFeatures: ExternalMemoryFeatureFlags, + exportFromImportedHandleTypes: ExternalMemoryHandleTypeFlags, + compatibleHandleTypes: ExternalMemoryHandleTypeFlags, +} + +PhysicalDeviceExternalImageFormatInfo :: struct { + sType: StructureType, + pNext: rawptr, + handleType: ExternalMemoryHandleTypeFlags, +} + +ExternalImageFormatProperties :: struct { + sType: StructureType, + pNext: rawptr, + externalMemoryProperties: ExternalMemoryProperties, +} + +PhysicalDeviceExternalBufferInfo :: struct { + sType: StructureType, + pNext: rawptr, + flags: BufferCreateFlags, + usage: BufferUsageFlags, + handleType: ExternalMemoryHandleTypeFlags, +} + +ExternalBufferProperties :: struct { + sType: StructureType, + pNext: rawptr, + externalMemoryProperties: ExternalMemoryProperties, +} + +PhysicalDeviceIDProperties :: struct { + sType: StructureType, + pNext: rawptr, + deviceUUID: [UUID_SIZE]u8, + driverUUID: [UUID_SIZE]u8, + deviceLUID: [LUID_SIZE]u8, + deviceNodeMask: u32, + deviceLUIDValid: b32, +} + +ExternalMemoryImageCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + handleTypes: ExternalMemoryHandleTypeFlags, +} + +ExternalMemoryBufferCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + handleTypes: ExternalMemoryHandleTypeFlags, +} + +ExportMemoryAllocateInfo :: struct { + sType: StructureType, + pNext: rawptr, + handleTypes: ExternalMemoryHandleTypeFlags, +} + +PhysicalDeviceExternalFenceInfo :: struct { + sType: StructureType, + pNext: rawptr, + handleType: ExternalFenceHandleTypeFlags, +} + +ExternalFenceProperties :: struct { + sType: StructureType, + pNext: rawptr, + exportFromImportedHandleTypes: ExternalFenceHandleTypeFlags, + compatibleHandleTypes: ExternalFenceHandleTypeFlags, + externalFenceFeatures: ExternalFenceFeatureFlags, +} + +ExportFenceCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + handleTypes: ExternalFenceHandleTypeFlags, +} + +ExportSemaphoreCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + handleTypes: ExternalSemaphoreHandleTypeFlags, +} + +PhysicalDeviceExternalSemaphoreInfo :: struct { + sType: StructureType, + pNext: rawptr, + handleType: ExternalSemaphoreHandleTypeFlags, +} + +ExternalSemaphoreProperties :: struct { + sType: StructureType, + pNext: rawptr, + exportFromImportedHandleTypes: ExternalSemaphoreHandleTypeFlags, + compatibleHandleTypes: ExternalSemaphoreHandleTypeFlags, + externalSemaphoreFeatures: ExternalSemaphoreFeatureFlags, +} + +PhysicalDeviceMaintenance3Properties :: struct { + sType: StructureType, + pNext: rawptr, + maxPerSetDescriptors: u32, + maxMemoryAllocationSize: DeviceSize, +} + +DescriptorSetLayoutSupport :: struct { + sType: StructureType, + pNext: rawptr, + supported: b32, +} + +PhysicalDeviceShaderDrawParametersFeatures :: struct { + sType: StructureType, + pNext: rawptr, + shaderDrawParameters: b32, +} + +PhysicalDeviceVulkan11Features :: struct { + sType: StructureType, + pNext: rawptr, + storageBuffer16BitAccess: b32, + uniformAndStorageBuffer16BitAccess: b32, + storagePushConstant16: b32, + storageInputOutput16: b32, + multiview: b32, + multiviewGeometryShader: b32, + multiviewTessellationShader: b32, + variablePointersStorageBuffer: b32, + variablePointers: b32, + protectedMemory: b32, + samplerYcbcrConversion: b32, + shaderDrawParameters: b32, +} + +PhysicalDeviceVulkan11Properties :: struct { + sType: StructureType, + pNext: rawptr, + deviceUUID: [UUID_SIZE]u8, + driverUUID: [UUID_SIZE]u8, + deviceLUID: [LUID_SIZE]u8, + deviceNodeMask: u32, + deviceLUIDValid: b32, + subgroupSize: u32, + subgroupSupportedStages: ShaderStageFlags, + subgroupSupportedOperations: SubgroupFeatureFlags, + subgroupQuadOperationsInAllStages: b32, + pointClippingBehavior: PointClippingBehavior, + maxMultiviewViewCount: u32, + maxMultiviewInstanceIndex: u32, + protectedNoFault: b32, + maxPerSetDescriptors: u32, + maxMemoryAllocationSize: DeviceSize, +} + +PhysicalDeviceVulkan12Features :: struct { + sType: StructureType, + pNext: rawptr, + samplerMirrorClampToEdge: b32, + drawIndirectCount: b32, + storageBuffer8BitAccess: b32, + uniformAndStorageBuffer8BitAccess: b32, + storagePushConstant8: b32, + shaderBufferInt64Atomics: b32, + shaderSharedInt64Atomics: b32, + shaderFloat16: b32, + shaderInt8: b32, + descriptorIndexing: b32, + shaderInputAttachmentArrayDynamicIndexing: b32, + shaderUniformTexelBufferArrayDynamicIndexing: b32, + shaderStorageTexelBufferArrayDynamicIndexing: b32, + shaderUniformBufferArrayNonUniformIndexing: b32, + shaderSampledImageArrayNonUniformIndexing: b32, + shaderStorageBufferArrayNonUniformIndexing: b32, + shaderStorageImageArrayNonUniformIndexing: b32, + shaderInputAttachmentArrayNonUniformIndexing: b32, + shaderUniformTexelBufferArrayNonUniformIndexing: b32, + shaderStorageTexelBufferArrayNonUniformIndexing: b32, + descriptorBindingUniformBufferUpdateAfterBind: b32, + descriptorBindingSampledImageUpdateAfterBind: b32, + descriptorBindingStorageImageUpdateAfterBind: b32, + descriptorBindingStorageBufferUpdateAfterBind: b32, + descriptorBindingUniformTexelBufferUpdateAfterBind: b32, + descriptorBindingStorageTexelBufferUpdateAfterBind: b32, + descriptorBindingUpdateUnusedWhilePending: b32, + descriptorBindingPartiallyBound: b32, + descriptorBindingVariableDescriptorCount: b32, + runtimeDescriptorArray: b32, + samplerFilterMinmax: b32, + scalarBlockLayout: b32, + imagelessFramebuffer: b32, + uniformBufferStandardLayout: b32, + shaderSubgroupExtendedTypes: b32, + separateDepthStencilLayouts: b32, + hostQueryReset: b32, + timelineSemaphore: b32, + bufferDeviceAddress: b32, + bufferDeviceAddressCaptureReplay: b32, + bufferDeviceAddressMultiDevice: b32, + vulkanMemoryModel: b32, + vulkanMemoryModelDeviceScope: b32, + vulkanMemoryModelAvailabilityVisibilityChains: b32, + shaderOutputViewportIndex: b32, + shaderOutputLayer: b32, + subgroupBroadcastDynamicId: b32, +} + +ConformanceVersion :: struct { + major: u8, + minor: u8, + subminor: u8, + patch: u8, +} + +PhysicalDeviceVulkan12Properties :: struct { + sType: StructureType, + pNext: rawptr, + driverID: DriverId, + driverName: [MAX_DRIVER_NAME_SIZE]byte, + driverInfo: [MAX_DRIVER_INFO_SIZE]byte, + conformanceVersion: ConformanceVersion, + denormBehaviorIndependence: ShaderFloatControlsIndependence, + roundingModeIndependence: ShaderFloatControlsIndependence, + shaderSignedZeroInfNanPreserveFloat16: b32, + shaderSignedZeroInfNanPreserveFloat32: b32, + shaderSignedZeroInfNanPreserveFloat64: b32, + shaderDenormPreserveFloat16: b32, + shaderDenormPreserveFloat32: b32, + shaderDenormPreserveFloat64: b32, + shaderDenormFlushToZeroFloat16: b32, + shaderDenormFlushToZeroFloat32: b32, + shaderDenormFlushToZeroFloat64: b32, + shaderRoundingModeRTEFloat16: b32, + shaderRoundingModeRTEFloat32: b32, + shaderRoundingModeRTEFloat64: b32, + shaderRoundingModeRTZFloat16: b32, + shaderRoundingModeRTZFloat32: b32, + shaderRoundingModeRTZFloat64: b32, + maxUpdateAfterBindDescriptorsInAllPools: u32, + shaderUniformBufferArrayNonUniformIndexingNative: b32, + shaderSampledImageArrayNonUniformIndexingNative: b32, + shaderStorageBufferArrayNonUniformIndexingNative: b32, + shaderStorageImageArrayNonUniformIndexingNative: b32, + shaderInputAttachmentArrayNonUniformIndexingNative: b32, + robustBufferAccessUpdateAfterBind: b32, + quadDivergentImplicitLod: b32, + maxPerStageDescriptorUpdateAfterBindSamplers: u32, + maxPerStageDescriptorUpdateAfterBindUniformBuffers: u32, + maxPerStageDescriptorUpdateAfterBindStorageBuffers: u32, + maxPerStageDescriptorUpdateAfterBindSampledImages: u32, + maxPerStageDescriptorUpdateAfterBindStorageImages: u32, + maxPerStageDescriptorUpdateAfterBindInputAttachments: u32, + maxPerStageUpdateAfterBindResources: u32, + maxDescriptorSetUpdateAfterBindSamplers: u32, + maxDescriptorSetUpdateAfterBindUniformBuffers: u32, + maxDescriptorSetUpdateAfterBindUniformBuffersDynamic: u32, + maxDescriptorSetUpdateAfterBindStorageBuffers: u32, + maxDescriptorSetUpdateAfterBindStorageBuffersDynamic: u32, + maxDescriptorSetUpdateAfterBindSampledImages: u32, + maxDescriptorSetUpdateAfterBindStorageImages: u32, + maxDescriptorSetUpdateAfterBindInputAttachments: u32, + supportedDepthResolveModes: ResolveModeFlags, + supportedStencilResolveModes: ResolveModeFlags, + independentResolveNone: b32, + independentResolve: b32, + filterMinmaxSingleComponentFormats: b32, + filterMinmaxImageComponentMapping: b32, + maxTimelineSemaphoreValueDifference: u64, + framebufferIntegerColorSampleCounts: SampleCountFlags, +} + +ImageFormatListCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + viewFormatCount: u32, + pViewFormats: [^]Format, +} + +AttachmentDescription2 :: struct { + sType: StructureType, + pNext: rawptr, + flags: AttachmentDescriptionFlags, + format: Format, + samples: SampleCountFlags, + loadOp: AttachmentLoadOp, + storeOp: AttachmentStoreOp, + stencilLoadOp: AttachmentLoadOp, + stencilStoreOp: AttachmentStoreOp, + initialLayout: ImageLayout, + finalLayout: ImageLayout, +} + +AttachmentReference2 :: struct { + sType: StructureType, + pNext: rawptr, + attachment: u32, + layout: ImageLayout, + aspectMask: ImageAspectFlags, +} + +SubpassDescription2 :: struct { + sType: StructureType, + pNext: rawptr, + flags: SubpassDescriptionFlags, + pipelineBindPoint: PipelineBindPoint, + viewMask: u32, + inputAttachmentCount: u32, + pInputAttachments: [^]AttachmentReference2, + colorAttachmentCount: u32, + pColorAttachments: [^]AttachmentReference2, + pResolveAttachments: [^]AttachmentReference2, + pDepthStencilAttachment: ^AttachmentReference2, + preserveAttachmentCount: u32, + pPreserveAttachments: [^]u32, +} + +SubpassDependency2 :: struct { + sType: StructureType, + pNext: rawptr, + srcSubpass: u32, + dstSubpass: u32, + srcStageMask: PipelineStageFlags, + dstStageMask: PipelineStageFlags, + srcAccessMask: AccessFlags, + dstAccessMask: AccessFlags, + dependencyFlags: DependencyFlags, + viewOffset: i32, +} + +RenderPassCreateInfo2 :: struct { + sType: StructureType, + pNext: rawptr, + flags: RenderPassCreateFlags, + attachmentCount: u32, + pAttachments: [^]AttachmentDescription2, + subpassCount: u32, + pSubpasses: [^]SubpassDescription2, + dependencyCount: u32, + pDependencies: [^]SubpassDependency2, + correlatedViewMaskCount: u32, + pCorrelatedViewMasks: [^]u32, +} + +SubpassBeginInfo :: struct { + sType: StructureType, + pNext: rawptr, + contents: SubpassContents, +} + +SubpassEndInfo :: struct { + sType: StructureType, + pNext: rawptr, +} + +PhysicalDevice8BitStorageFeatures :: struct { + sType: StructureType, + pNext: rawptr, + storageBuffer8BitAccess: b32, + uniformAndStorageBuffer8BitAccess: b32, + storagePushConstant8: b32, +} + +PhysicalDeviceDriverProperties :: struct { + sType: StructureType, + pNext: rawptr, + driverID: DriverId, + driverName: [MAX_DRIVER_NAME_SIZE]byte, + driverInfo: [MAX_DRIVER_INFO_SIZE]byte, + conformanceVersion: ConformanceVersion, +} + +PhysicalDeviceShaderAtomicInt64Features :: struct { + sType: StructureType, + pNext: rawptr, + shaderBufferInt64Atomics: b32, + shaderSharedInt64Atomics: b32, +} + +PhysicalDeviceShaderFloat16Int8Features :: struct { + sType: StructureType, + pNext: rawptr, + shaderFloat16: b32, + shaderInt8: b32, +} + +PhysicalDeviceFloatControlsProperties :: struct { + sType: StructureType, + pNext: rawptr, + denormBehaviorIndependence: ShaderFloatControlsIndependence, + roundingModeIndependence: ShaderFloatControlsIndependence, + shaderSignedZeroInfNanPreserveFloat16: b32, + shaderSignedZeroInfNanPreserveFloat32: b32, + shaderSignedZeroInfNanPreserveFloat64: b32, + shaderDenormPreserveFloat16: b32, + shaderDenormPreserveFloat32: b32, + shaderDenormPreserveFloat64: b32, + shaderDenormFlushToZeroFloat16: b32, + shaderDenormFlushToZeroFloat32: b32, + shaderDenormFlushToZeroFloat64: b32, + shaderRoundingModeRTEFloat16: b32, + shaderRoundingModeRTEFloat32: b32, + shaderRoundingModeRTEFloat64: b32, + shaderRoundingModeRTZFloat16: b32, + shaderRoundingModeRTZFloat32: b32, + shaderRoundingModeRTZFloat64: b32, +} + +DescriptorSetLayoutBindingFlagsCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + bindingCount: u32, + pBindingFlags: [^]DescriptorBindingFlags, +} + +PhysicalDeviceDescriptorIndexingFeatures :: struct { + sType: StructureType, + pNext: rawptr, + shaderInputAttachmentArrayDynamicIndexing: b32, + shaderUniformTexelBufferArrayDynamicIndexing: b32, + shaderStorageTexelBufferArrayDynamicIndexing: b32, + shaderUniformBufferArrayNonUniformIndexing: b32, + shaderSampledImageArrayNonUniformIndexing: b32, + shaderStorageBufferArrayNonUniformIndexing: b32, + shaderStorageImageArrayNonUniformIndexing: b32, + shaderInputAttachmentArrayNonUniformIndexing: b32, + shaderUniformTexelBufferArrayNonUniformIndexing: b32, + shaderStorageTexelBufferArrayNonUniformIndexing: b32, + descriptorBindingUniformBufferUpdateAfterBind: b32, + descriptorBindingSampledImageUpdateAfterBind: b32, + descriptorBindingStorageImageUpdateAfterBind: b32, + descriptorBindingStorageBufferUpdateAfterBind: b32, + descriptorBindingUniformTexelBufferUpdateAfterBind: b32, + descriptorBindingStorageTexelBufferUpdateAfterBind: b32, + descriptorBindingUpdateUnusedWhilePending: b32, + descriptorBindingPartiallyBound: b32, + descriptorBindingVariableDescriptorCount: b32, + runtimeDescriptorArray: b32, +} + +PhysicalDeviceDescriptorIndexingProperties :: struct { + sType: StructureType, + pNext: rawptr, + maxUpdateAfterBindDescriptorsInAllPools: u32, + shaderUniformBufferArrayNonUniformIndexingNative: b32, + shaderSampledImageArrayNonUniformIndexingNative: b32, + shaderStorageBufferArrayNonUniformIndexingNative: b32, + shaderStorageImageArrayNonUniformIndexingNative: b32, + shaderInputAttachmentArrayNonUniformIndexingNative: b32, + robustBufferAccessUpdateAfterBind: b32, + quadDivergentImplicitLod: b32, + maxPerStageDescriptorUpdateAfterBindSamplers: u32, + maxPerStageDescriptorUpdateAfterBindUniformBuffers: u32, + maxPerStageDescriptorUpdateAfterBindStorageBuffers: u32, + maxPerStageDescriptorUpdateAfterBindSampledImages: u32, + maxPerStageDescriptorUpdateAfterBindStorageImages: u32, + maxPerStageDescriptorUpdateAfterBindInputAttachments: u32, + maxPerStageUpdateAfterBindResources: u32, + maxDescriptorSetUpdateAfterBindSamplers: u32, + maxDescriptorSetUpdateAfterBindUniformBuffers: u32, + maxDescriptorSetUpdateAfterBindUniformBuffersDynamic: u32, + maxDescriptorSetUpdateAfterBindStorageBuffers: u32, + maxDescriptorSetUpdateAfterBindStorageBuffersDynamic: u32, + maxDescriptorSetUpdateAfterBindSampledImages: u32, + maxDescriptorSetUpdateAfterBindStorageImages: u32, + maxDescriptorSetUpdateAfterBindInputAttachments: u32, +} + +DescriptorSetVariableDescriptorCountAllocateInfo :: struct { + sType: StructureType, + pNext: rawptr, + descriptorSetCount: u32, + pDescriptorCounts: [^]u32, +} + +DescriptorSetVariableDescriptorCountLayoutSupport :: struct { + sType: StructureType, + pNext: rawptr, + maxVariableDescriptorCount: u32, +} + +SubpassDescriptionDepthStencilResolve :: struct { + sType: StructureType, + pNext: rawptr, + depthResolveMode: ResolveModeFlags, + stencilResolveMode: ResolveModeFlags, + pDepthStencilResolveAttachment: ^AttachmentReference2, +} + +PhysicalDeviceDepthStencilResolveProperties :: struct { + sType: StructureType, + pNext: rawptr, + supportedDepthResolveModes: ResolveModeFlags, + supportedStencilResolveModes: ResolveModeFlags, + independentResolveNone: b32, + independentResolve: b32, +} + +PhysicalDeviceScalarBlockLayoutFeatures :: struct { + sType: StructureType, + pNext: rawptr, + scalarBlockLayout: b32, +} + +ImageStencilUsageCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + stencilUsage: ImageUsageFlags, +} + +SamplerReductionModeCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + reductionMode: SamplerReductionMode, +} + +PhysicalDeviceSamplerFilterMinmaxProperties :: struct { + sType: StructureType, + pNext: rawptr, + filterMinmaxSingleComponentFormats: b32, + filterMinmaxImageComponentMapping: b32, +} + +PhysicalDeviceVulkanMemoryModelFeatures :: struct { + sType: StructureType, + pNext: rawptr, + vulkanMemoryModel: b32, + vulkanMemoryModelDeviceScope: b32, + vulkanMemoryModelAvailabilityVisibilityChains: b32, +} + +PhysicalDeviceImagelessFramebufferFeatures :: struct { + sType: StructureType, + pNext: rawptr, + imagelessFramebuffer: b32, +} + +FramebufferAttachmentImageInfo :: struct { + sType: StructureType, + pNext: rawptr, + flags: ImageCreateFlags, + usage: ImageUsageFlags, + width: u32, + height: u32, + layerCount: u32, + viewFormatCount: u32, + pViewFormats: [^]Format, +} + +FramebufferAttachmentsCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + attachmentImageInfoCount: u32, + pAttachmentImageInfos: [^]FramebufferAttachmentImageInfo, +} + +RenderPassAttachmentBeginInfo :: struct { + sType: StructureType, + pNext: rawptr, + attachmentCount: u32, + pAttachments: [^]ImageView, +} + +PhysicalDeviceUniformBufferStandardLayoutFeatures :: struct { + sType: StructureType, + pNext: rawptr, + uniformBufferStandardLayout: b32, +} + +PhysicalDeviceShaderSubgroupExtendedTypesFeatures :: struct { + sType: StructureType, + pNext: rawptr, + shaderSubgroupExtendedTypes: b32, +} + +PhysicalDeviceSeparateDepthStencilLayoutsFeatures :: struct { + sType: StructureType, + pNext: rawptr, + separateDepthStencilLayouts: b32, +} + +AttachmentReferenceStencilLayout :: struct { + sType: StructureType, + pNext: rawptr, + stencilLayout: ImageLayout, +} + +AttachmentDescriptionStencilLayout :: struct { + sType: StructureType, + pNext: rawptr, + stencilInitialLayout: ImageLayout, + stencilFinalLayout: ImageLayout, +} + +PhysicalDeviceHostQueryResetFeatures :: struct { + sType: StructureType, + pNext: rawptr, + hostQueryReset: b32, +} + +PhysicalDeviceTimelineSemaphoreFeatures :: struct { + sType: StructureType, + pNext: rawptr, + timelineSemaphore: b32, +} + +PhysicalDeviceTimelineSemaphoreProperties :: struct { + sType: StructureType, + pNext: rawptr, + maxTimelineSemaphoreValueDifference: u64, +} + +SemaphoreTypeCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + semaphoreType: SemaphoreType, + initialValue: u64, +} + +TimelineSemaphoreSubmitInfo :: struct { + sType: StructureType, + pNext: rawptr, + waitSemaphoreValueCount: u32, + pWaitSemaphoreValues: [^]u64, + signalSemaphoreValueCount: u32, + pSignalSemaphoreValues: [^]u64, +} + +SemaphoreWaitInfo :: struct { + sType: StructureType, + pNext: rawptr, + flags: SemaphoreWaitFlags, + semaphoreCount: u32, + pSemaphores: [^]Semaphore, + pValues: [^]u64, +} + +SemaphoreSignalInfo :: struct { + sType: StructureType, + pNext: rawptr, + semaphore: Semaphore, + value: u64, +} + +PhysicalDeviceBufferDeviceAddressFeatures :: struct { + sType: StructureType, + pNext: rawptr, + bufferDeviceAddress: b32, + bufferDeviceAddressCaptureReplay: b32, + bufferDeviceAddressMultiDevice: b32, +} + +BufferDeviceAddressInfo :: struct { + sType: StructureType, + pNext: rawptr, + buffer: Buffer, +} + +BufferOpaqueCaptureAddressCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + opaqueCaptureAddress: u64, +} + +MemoryOpaqueCaptureAddressAllocateInfo :: struct { + sType: StructureType, + pNext: rawptr, + opaqueCaptureAddress: u64, +} + +DeviceMemoryOpaqueCaptureAddressInfo :: struct { + sType: StructureType, + pNext: rawptr, + memory: DeviceMemory, +} + +PhysicalDeviceVulkan13Features :: struct { + sType: StructureType, + pNext: rawptr, + robustImageAccess: b32, + inlineUniformBlock: b32, + descriptorBindingInlineUniformBlockUpdateAfterBind: b32, + pipelineCreationCacheControl: b32, + privateData: b32, + shaderDemoteToHelperInvocation: b32, + shaderTerminateInvocation: b32, + subgroupSizeControl: b32, + computeFullSubgroups: b32, + synchronization2: b32, + textureCompressionASTC_HDR: b32, + shaderZeroInitializeWorkgroupMemory: b32, + dynamicRendering: b32, + shaderIntegerDotProduct: b32, + maintenance4: b32, +} + +PhysicalDeviceVulkan13Properties :: struct { + sType: StructureType, + pNext: rawptr, + minSubgroupSize: u32, + maxSubgroupSize: u32, + maxComputeWorkgroupSubgroups: u32, + requiredSubgroupSizeStages: ShaderStageFlags, + maxInlineUniformBlockSize: u32, + maxPerStageDescriptorInlineUniformBlocks: u32, + maxPerStageDescriptorUpdateAfterBindInlineUniformBlocks: u32, + maxDescriptorSetInlineUniformBlocks: u32, + maxDescriptorSetUpdateAfterBindInlineUniformBlocks: u32, + maxInlineUniformTotalSize: u32, + integerDotProduct8BitUnsignedAccelerated: b32, + integerDotProduct8BitSignedAccelerated: b32, + integerDotProduct8BitMixedSignednessAccelerated: b32, + integerDotProduct4x8BitPackedUnsignedAccelerated: b32, + integerDotProduct4x8BitPackedSignedAccelerated: b32, + integerDotProduct4x8BitPackedMixedSignednessAccelerated: b32, + integerDotProduct16BitUnsignedAccelerated: b32, + integerDotProduct16BitSignedAccelerated: b32, + integerDotProduct16BitMixedSignednessAccelerated: b32, + integerDotProduct32BitUnsignedAccelerated: b32, + integerDotProduct32BitSignedAccelerated: b32, + integerDotProduct32BitMixedSignednessAccelerated: b32, + integerDotProduct64BitUnsignedAccelerated: b32, + integerDotProduct64BitSignedAccelerated: b32, + integerDotProduct64BitMixedSignednessAccelerated: b32, + integerDotProductAccumulatingSaturating8BitUnsignedAccelerated: b32, + integerDotProductAccumulatingSaturating8BitSignedAccelerated: b32, + integerDotProductAccumulatingSaturating8BitMixedSignednessAccelerated: b32, + integerDotProductAccumulatingSaturating4x8BitPackedUnsignedAccelerated: b32, + integerDotProductAccumulatingSaturating4x8BitPackedSignedAccelerated: b32, + integerDotProductAccumulatingSaturating4x8BitPackedMixedSignednessAccelerated: b32, + integerDotProductAccumulatingSaturating16BitUnsignedAccelerated: b32, + integerDotProductAccumulatingSaturating16BitSignedAccelerated: b32, + integerDotProductAccumulatingSaturating16BitMixedSignednessAccelerated: b32, + integerDotProductAccumulatingSaturating32BitUnsignedAccelerated: b32, + integerDotProductAccumulatingSaturating32BitSignedAccelerated: b32, + integerDotProductAccumulatingSaturating32BitMixedSignednessAccelerated: b32, + integerDotProductAccumulatingSaturating64BitUnsignedAccelerated: b32, + integerDotProductAccumulatingSaturating64BitSignedAccelerated: b32, + integerDotProductAccumulatingSaturating64BitMixedSignednessAccelerated: b32, + storageTexelBufferOffsetAlignmentBytes: DeviceSize, + storageTexelBufferOffsetSingleTexelAlignment: b32, + uniformTexelBufferOffsetAlignmentBytes: DeviceSize, + uniformTexelBufferOffsetSingleTexelAlignment: b32, + maxBufferSize: DeviceSize, +} + +PipelineCreationFeedback :: struct { + flags: PipelineCreationFeedbackFlags, + duration: u64, +} + +PipelineCreationFeedbackCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + pPipelineCreationFeedback: ^PipelineCreationFeedback, + pipelineStageCreationFeedbackCount: u32, + pPipelineStageCreationFeedbacks: [^]PipelineCreationFeedback, +} + +PhysicalDeviceShaderTerminateInvocationFeatures :: struct { + sType: StructureType, + pNext: rawptr, + shaderTerminateInvocation: b32, +} + +PhysicalDeviceToolProperties :: struct { + sType: StructureType, + pNext: rawptr, + name: [MAX_EXTENSION_NAME_SIZE]byte, + version: [MAX_EXTENSION_NAME_SIZE]byte, + purposes: ToolPurposeFlags, + description: [MAX_DESCRIPTION_SIZE]byte, + layer: [MAX_EXTENSION_NAME_SIZE]byte, +} + +PhysicalDeviceShaderDemoteToHelperInvocationFeatures :: struct { + sType: StructureType, + pNext: rawptr, + shaderDemoteToHelperInvocation: b32, +} + +PhysicalDevicePrivateDataFeatures :: struct { + sType: StructureType, + pNext: rawptr, + privateData: b32, +} + +DevicePrivateDataCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + privateDataSlotRequestCount: u32, +} + +PrivateDataSlotCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + flags: PrivateDataSlotCreateFlags, +} + +PhysicalDevicePipelineCreationCacheControlFeatures :: struct { + sType: StructureType, + pNext: rawptr, + pipelineCreationCacheControl: b32, +} + +MemoryBarrier2 :: struct { + sType: StructureType, + pNext: rawptr, + srcStageMask: PipelineStageFlags2, + srcAccessMask: AccessFlags2, + dstStageMask: PipelineStageFlags2, + dstAccessMask: AccessFlags2, +} + +BufferMemoryBarrier2 :: struct { + sType: StructureType, + pNext: rawptr, + srcStageMask: PipelineStageFlags2, + srcAccessMask: AccessFlags2, + dstStageMask: PipelineStageFlags2, + dstAccessMask: AccessFlags2, + srcQueueFamilyIndex: u32, + dstQueueFamilyIndex: u32, + buffer: Buffer, + offset: DeviceSize, + size: DeviceSize, +} + +ImageMemoryBarrier2 :: struct { + sType: StructureType, + pNext: rawptr, + srcStageMask: PipelineStageFlags2, + srcAccessMask: AccessFlags2, + dstStageMask: PipelineStageFlags2, + dstAccessMask: AccessFlags2, + oldLayout: ImageLayout, + newLayout: ImageLayout, + srcQueueFamilyIndex: u32, + dstQueueFamilyIndex: u32, + image: Image, + subresourceRange: ImageSubresourceRange, +} + +DependencyInfo :: struct { + sType: StructureType, + pNext: rawptr, + dependencyFlags: DependencyFlags, + memoryBarrierCount: u32, + pMemoryBarriers: [^]MemoryBarrier2, + bufferMemoryBarrierCount: u32, + pBufferMemoryBarriers: [^]BufferMemoryBarrier2, + imageMemoryBarrierCount: u32, + pImageMemoryBarriers: [^]ImageMemoryBarrier2, +} + +SemaphoreSubmitInfo :: struct { + sType: StructureType, + pNext: rawptr, + semaphore: Semaphore, + value: u64, + stageMask: PipelineStageFlags2, + deviceIndex: u32, +} + +CommandBufferSubmitInfo :: struct { + sType: StructureType, + pNext: rawptr, + commandBuffer: CommandBuffer, + deviceMask: u32, +} + +SubmitInfo2 :: struct { + sType: StructureType, + pNext: rawptr, + flags: SubmitFlags, + waitSemaphoreInfoCount: u32, + pWaitSemaphoreInfos: [^]SemaphoreSubmitInfo, + commandBufferInfoCount: u32, + pCommandBufferInfos: [^]CommandBufferSubmitInfo, + signalSemaphoreInfoCount: u32, + pSignalSemaphoreInfos: [^]SemaphoreSubmitInfo, +} + +PhysicalDeviceSynchronization2Features :: struct { + sType: StructureType, + pNext: rawptr, + synchronization2: b32, +} + +PhysicalDeviceZeroInitializeWorkgroupMemoryFeatures :: struct { + sType: StructureType, + pNext: rawptr, + shaderZeroInitializeWorkgroupMemory: b32, +} + +PhysicalDeviceImageRobustnessFeatures :: struct { + sType: StructureType, + pNext: rawptr, + robustImageAccess: b32, +} + +BufferCopy2 :: struct { + sType: StructureType, + pNext: rawptr, + srcOffset: DeviceSize, + dstOffset: DeviceSize, + size: DeviceSize, +} + +CopyBufferInfo2 :: struct { + sType: StructureType, + pNext: rawptr, + srcBuffer: Buffer, + dstBuffer: Buffer, + regionCount: u32, + pRegions: [^]BufferCopy2, +} + +ImageCopy2 :: struct { + sType: StructureType, + pNext: rawptr, + srcSubresource: ImageSubresourceLayers, + srcOffset: Offset3D, + dstSubresource: ImageSubresourceLayers, + dstOffset: Offset3D, + extent: Extent3D, +} + +CopyImageInfo2 :: struct { + sType: StructureType, + pNext: rawptr, + srcImage: Image, + srcImageLayout: ImageLayout, + dstImage: Image, + dstImageLayout: ImageLayout, + regionCount: u32, + pRegions: [^]ImageCopy2, +} + +BufferImageCopy2 :: struct { + sType: StructureType, + pNext: rawptr, + bufferOffset: DeviceSize, + bufferRowLength: u32, + bufferImageHeight: u32, + imageSubresource: ImageSubresourceLayers, + imageOffset: Offset3D, + imageExtent: Extent3D, +} + +CopyBufferToImageInfo2 :: struct { + sType: StructureType, + pNext: rawptr, + srcBuffer: Buffer, + dstImage: Image, + dstImageLayout: ImageLayout, + regionCount: u32, + pRegions: [^]BufferImageCopy2, +} + +CopyImageToBufferInfo2 :: struct { + sType: StructureType, + pNext: rawptr, + srcImage: Image, + srcImageLayout: ImageLayout, + dstBuffer: Buffer, + regionCount: u32, + pRegions: [^]BufferImageCopy2, +} + +ImageBlit2 :: struct { + sType: StructureType, + pNext: rawptr, + srcSubresource: ImageSubresourceLayers, + srcOffsets: [2]Offset3D, + dstSubresource: ImageSubresourceLayers, + dstOffsets: [2]Offset3D, +} + +BlitImageInfo2 :: struct { + sType: StructureType, + pNext: rawptr, + srcImage: Image, + srcImageLayout: ImageLayout, + dstImage: Image, + dstImageLayout: ImageLayout, + regionCount: u32, + pRegions: [^]ImageBlit2, + filter: Filter, +} + +ImageResolve2 :: struct { + sType: StructureType, + pNext: rawptr, + srcSubresource: ImageSubresourceLayers, + srcOffset: Offset3D, + dstSubresource: ImageSubresourceLayers, + dstOffset: Offset3D, + extent: Extent3D, +} + +ResolveImageInfo2 :: struct { + sType: StructureType, + pNext: rawptr, + srcImage: Image, + srcImageLayout: ImageLayout, + dstImage: Image, + dstImageLayout: ImageLayout, + regionCount: u32, + pRegions: [^]ImageResolve2, +} + +PhysicalDeviceSubgroupSizeControlFeatures :: struct { + sType: StructureType, + pNext: rawptr, + subgroupSizeControl: b32, + computeFullSubgroups: b32, +} + +PhysicalDeviceSubgroupSizeControlProperties :: struct { + sType: StructureType, + pNext: rawptr, + minSubgroupSize: u32, + maxSubgroupSize: u32, + maxComputeWorkgroupSubgroups: u32, + requiredSubgroupSizeStages: ShaderStageFlags, +} + +PipelineShaderStageRequiredSubgroupSizeCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + requiredSubgroupSize: u32, +} + +PhysicalDeviceInlineUniformBlockFeatures :: struct { + sType: StructureType, + pNext: rawptr, + inlineUniformBlock: b32, + descriptorBindingInlineUniformBlockUpdateAfterBind: b32, +} + +PhysicalDeviceInlineUniformBlockProperties :: struct { + sType: StructureType, + pNext: rawptr, + maxInlineUniformBlockSize: u32, + maxPerStageDescriptorInlineUniformBlocks: u32, + maxPerStageDescriptorUpdateAfterBindInlineUniformBlocks: u32, + maxDescriptorSetInlineUniformBlocks: u32, + maxDescriptorSetUpdateAfterBindInlineUniformBlocks: u32, +} + +WriteDescriptorSetInlineUniformBlock :: struct { + sType: StructureType, + pNext: rawptr, + dataSize: u32, + pData: rawptr, +} + +DescriptorPoolInlineUniformBlockCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + maxInlineUniformBlockBindings: u32, +} + +PhysicalDeviceTextureCompressionASTCHDRFeatures :: struct { + sType: StructureType, + pNext: rawptr, + textureCompressionASTC_HDR: b32, +} + +RenderingAttachmentInfo :: struct { + sType: StructureType, + pNext: rawptr, + imageView: ImageView, + imageLayout: ImageLayout, + resolveMode: ResolveModeFlags, + resolveImageView: ImageView, + resolveImageLayout: ImageLayout, + loadOp: AttachmentLoadOp, + storeOp: AttachmentStoreOp, + clearValue: ClearValue, +} + +RenderingInfo :: struct { + sType: StructureType, + pNext: rawptr, + flags: RenderingFlags, + renderArea: Rect2D, + layerCount: u32, + viewMask: u32, + colorAttachmentCount: u32, + pColorAttachments: [^]RenderingAttachmentInfo, + pDepthAttachment: ^RenderingAttachmentInfo, + pStencilAttachment: ^RenderingAttachmentInfo, +} + +PipelineRenderingCreateInfo :: struct { + sType: StructureType, + pNext: rawptr, + viewMask: u32, + colorAttachmentCount: u32, + pColorAttachmentFormats: [^]Format, + depthAttachmentFormat: Format, + stencilAttachmentFormat: Format, +} + +PhysicalDeviceDynamicRenderingFeatures :: struct { + sType: StructureType, + pNext: rawptr, + dynamicRendering: b32, +} + +CommandBufferInheritanceRenderingInfo :: struct { + sType: StructureType, + pNext: rawptr, + flags: RenderingFlags, + viewMask: u32, + colorAttachmentCount: u32, + pColorAttachmentFormats: [^]Format, + depthAttachmentFormat: Format, + stencilAttachmentFormat: Format, + rasterizationSamples: SampleCountFlags, +} + +PhysicalDeviceShaderIntegerDotProductFeatures :: struct { + sType: StructureType, + pNext: rawptr, + shaderIntegerDotProduct: b32, +} + +PhysicalDeviceShaderIntegerDotProductProperties :: struct { + sType: StructureType, + pNext: rawptr, + integerDotProduct8BitUnsignedAccelerated: b32, + integerDotProduct8BitSignedAccelerated: b32, + integerDotProduct8BitMixedSignednessAccelerated: b32, + integerDotProduct4x8BitPackedUnsignedAccelerated: b32, + integerDotProduct4x8BitPackedSignedAccelerated: b32, + integerDotProduct4x8BitPackedMixedSignednessAccelerated: b32, + integerDotProduct16BitUnsignedAccelerated: b32, + integerDotProduct16BitSignedAccelerated: b32, + integerDotProduct16BitMixedSignednessAccelerated: b32, + integerDotProduct32BitUnsignedAccelerated: b32, + integerDotProduct32BitSignedAccelerated: b32, + integerDotProduct32BitMixedSignednessAccelerated: b32, + integerDotProduct64BitUnsignedAccelerated: b32, + integerDotProduct64BitSignedAccelerated: b32, + integerDotProduct64BitMixedSignednessAccelerated: b32, + integerDotProductAccumulatingSaturating8BitUnsignedAccelerated: b32, + integerDotProductAccumulatingSaturating8BitSignedAccelerated: b32, + integerDotProductAccumulatingSaturating8BitMixedSignednessAccelerated: b32, + integerDotProductAccumulatingSaturating4x8BitPackedUnsignedAccelerated: b32, + integerDotProductAccumulatingSaturating4x8BitPackedSignedAccelerated: b32, + integerDotProductAccumulatingSaturating4x8BitPackedMixedSignednessAccelerated: b32, + integerDotProductAccumulatingSaturating16BitUnsignedAccelerated: b32, + integerDotProductAccumulatingSaturating16BitSignedAccelerated: b32, + integerDotProductAccumulatingSaturating16BitMixedSignednessAccelerated: b32, + integerDotProductAccumulatingSaturating32BitUnsignedAccelerated: b32, + integerDotProductAccumulatingSaturating32BitSignedAccelerated: b32, + integerDotProductAccumulatingSaturating32BitMixedSignednessAccelerated: b32, + integerDotProductAccumulatingSaturating64BitUnsignedAccelerated: b32, + integerDotProductAccumulatingSaturating64BitSignedAccelerated: b32, + integerDotProductAccumulatingSaturating64BitMixedSignednessAccelerated: b32, +} + +PhysicalDeviceTexelBufferAlignmentProperties :: struct { + sType: StructureType, + pNext: rawptr, + storageTexelBufferOffsetAlignmentBytes: DeviceSize, + storageTexelBufferOffsetSingleTexelAlignment: b32, + uniformTexelBufferOffsetAlignmentBytes: DeviceSize, + uniformTexelBufferOffsetSingleTexelAlignment: b32, +} + +FormatProperties3 :: struct { + sType: StructureType, + pNext: rawptr, + linearTilingFeatures: FormatFeatureFlags2, + optimalTilingFeatures: FormatFeatureFlags2, + bufferFeatures: FormatFeatureFlags2, +} + +PhysicalDeviceMaintenance4Features :: struct { + sType: StructureType, + pNext: rawptr, + maintenance4: b32, +} + +PhysicalDeviceMaintenance4Properties :: struct { + sType: StructureType, + pNext: rawptr, + maxBufferSize: DeviceSize, +} + +DeviceBufferMemoryRequirements :: struct { + sType: StructureType, + pNext: rawptr, + pCreateInfo: ^BufferCreateInfo, +} + +DeviceImageMemoryRequirements :: struct { + sType: StructureType, + pNext: rawptr, + pCreateInfo: ^ImageCreateInfo, + planeAspect: ImageAspectFlags, +} + +SurfaceCapabilitiesKHR :: struct { + minImageCount: u32, + maxImageCount: u32, + currentExtent: Extent2D, + minImageExtent: Extent2D, + maxImageExtent: Extent2D, + maxImageArrayLayers: u32, + supportedTransforms: SurfaceTransformFlagsKHR, + currentTransform: SurfaceTransformFlagsKHR, + supportedCompositeAlpha: CompositeAlphaFlagsKHR, + supportedUsageFlags: ImageUsageFlags, +} + +SurfaceFormatKHR :: struct { + format: Format, + colorSpace: ColorSpaceKHR, +} + +SwapchainCreateInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + flags: SwapchainCreateFlagsKHR, + surface: SurfaceKHR, + minImageCount: u32, + imageFormat: Format, + imageColorSpace: ColorSpaceKHR, + imageExtent: Extent2D, + imageArrayLayers: u32, + imageUsage: ImageUsageFlags, + imageSharingMode: SharingMode, + queueFamilyIndexCount: u32, + pQueueFamilyIndices: [^]u32, + preTransform: SurfaceTransformFlagsKHR, + compositeAlpha: CompositeAlphaFlagsKHR, + presentMode: PresentModeKHR, + clipped: b32, + oldSwapchain: SwapchainKHR, +} + +PresentInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + waitSemaphoreCount: u32, + pWaitSemaphores: [^]Semaphore, + swapchainCount: u32, + pSwapchains: [^]SwapchainKHR, + pImageIndices: [^]u32, + pResults: [^]Result, +} + +ImageSwapchainCreateInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + swapchain: SwapchainKHR, +} + +BindImageMemorySwapchainInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + swapchain: SwapchainKHR, + imageIndex: u32, +} + +AcquireNextImageInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + swapchain: SwapchainKHR, + timeout: u64, + semaphore: Semaphore, + fence: Fence, + deviceMask: u32, +} + +DeviceGroupPresentCapabilitiesKHR :: struct { + sType: StructureType, + pNext: rawptr, + presentMask: [MAX_DEVICE_GROUP_SIZE]u32, + modes: DeviceGroupPresentModeFlagsKHR, +} + +DeviceGroupPresentInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + swapchainCount: u32, + pDeviceMasks: [^]u32, + mode: DeviceGroupPresentModeFlagsKHR, +} + +DeviceGroupSwapchainCreateInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + modes: DeviceGroupPresentModeFlagsKHR, +} + +DisplayModeParametersKHR :: struct { + visibleRegion: Extent2D, + refreshRate: u32, +} + +DisplayModeCreateInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + flags: DisplayModeCreateFlagsKHR, + parameters: DisplayModeParametersKHR, +} + +DisplayModePropertiesKHR :: struct { + displayMode: DisplayModeKHR, + parameters: DisplayModeParametersKHR, +} + +DisplayPlaneCapabilitiesKHR :: struct { + supportedAlpha: DisplayPlaneAlphaFlagsKHR, + minSrcPosition: Offset2D, + maxSrcPosition: Offset2D, + minSrcExtent: Extent2D, + maxSrcExtent: Extent2D, + minDstPosition: Offset2D, + maxDstPosition: Offset2D, + minDstExtent: Extent2D, + maxDstExtent: Extent2D, +} + +DisplayPlanePropertiesKHR :: struct { + currentDisplay: DisplayKHR, + currentStackIndex: u32, +} + +DisplayPropertiesKHR :: struct { + display: DisplayKHR, + displayName: cstring, + physicalDimensions: Extent2D, + physicalResolution: Extent2D, + supportedTransforms: SurfaceTransformFlagsKHR, + planeReorderPossible: b32, + persistentContent: b32, +} + +DisplaySurfaceCreateInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + flags: DisplaySurfaceCreateFlagsKHR, + displayMode: DisplayModeKHR, + planeIndex: u32, + planeStackIndex: u32, + transform: SurfaceTransformFlagsKHR, + globalAlpha: f32, + alphaMode: DisplayPlaneAlphaFlagsKHR, + imageExtent: Extent2D, +} + +DisplayPresentInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + srcRect: Rect2D, + dstRect: Rect2D, + persistent: b32, +} + +QueueFamilyQueryResultStatusPropertiesKHR :: struct { + sType: StructureType, + pNext: rawptr, + queryResultStatusSupport: b32, +} + +QueueFamilyVideoPropertiesKHR :: struct { + sType: StructureType, + pNext: rawptr, + videoCodecOperations: VideoCodecOperationFlagsKHR, +} + +VideoProfileInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + videoCodecOperation: VideoCodecOperationFlagsKHR, + chromaSubsampling: VideoChromaSubsamplingFlagsKHR, + lumaBitDepth: VideoComponentBitDepthFlagsKHR, + chromaBitDepth: VideoComponentBitDepthFlagsKHR, +} + +VideoProfileListInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + profileCount: u32, + pProfiles: [^]VideoProfileInfoKHR, +} + +VideoCapabilitiesKHR :: struct { + sType: StructureType, + pNext: rawptr, + flags: VideoCapabilityFlagsKHR, + minBitstreamBufferOffsetAlignment: DeviceSize, + minBitstreamBufferSizeAlignment: DeviceSize, + pictureAccessGranularity: Extent2D, + minCodedExtent: Extent2D, + maxCodedExtent: Extent2D, + maxDpbSlots: u32, + maxActiveReferencePictures: u32, + stdHeaderVersion: ExtensionProperties, +} + +PhysicalDeviceVideoFormatInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + imageUsage: ImageUsageFlags, +} + +VideoFormatPropertiesKHR :: struct { + sType: StructureType, + pNext: rawptr, + format: Format, + componentMapping: ComponentMapping, + imageCreateFlags: ImageCreateFlags, + imageType: ImageType, + imageTiling: ImageTiling, + imageUsageFlags: ImageUsageFlags, +} + +VideoPictureResourceInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + codedOffset: Offset2D, + codedExtent: Extent2D, + baseArrayLayer: u32, + imageViewBinding: ImageView, +} + +VideoReferenceSlotInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + slotIndex: i32, + pPictureResource: ^VideoPictureResourceInfoKHR, +} + +VideoSessionMemoryRequirementsKHR :: struct { + sType: StructureType, + pNext: rawptr, + memoryBindIndex: u32, + memoryRequirements: MemoryRequirements, +} + +BindVideoSessionMemoryInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + memoryBindIndex: u32, + memory: DeviceMemory, + memoryOffset: DeviceSize, + memorySize: DeviceSize, +} + +VideoSessionCreateInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + queueFamilyIndex: u32, + flags: VideoSessionCreateFlagsKHR, + pVideoProfile: ^VideoProfileInfoKHR, + pictureFormat: Format, + maxCodedExtent: Extent2D, + referencePictureFormat: Format, + maxDpbSlots: u32, + maxActiveReferencePictures: u32, + pStdHeaderVersion: ^ExtensionProperties, +} + +VideoSessionParametersCreateInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + flags: VideoSessionParametersCreateFlagsKHR, + videoSessionParametersTemplate: VideoSessionParametersKHR, + videoSession: VideoSessionKHR, +} + +VideoSessionParametersUpdateInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + updateSequenceCount: u32, +} + +VideoBeginCodingInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + flags: VideoBeginCodingFlagsKHR, + videoSession: VideoSessionKHR, + videoSessionParameters: VideoSessionParametersKHR, + referenceSlotCount: u32, + pReferenceSlots: [^]VideoReferenceSlotInfoKHR, +} + +VideoEndCodingInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + flags: VideoEndCodingFlagsKHR, +} + +VideoCodingControlInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + flags: VideoCodingControlFlagsKHR, +} + +VideoDecodeCapabilitiesKHR :: struct { + sType: StructureType, + pNext: rawptr, + flags: VideoDecodeCapabilityFlagsKHR, +} + +VideoDecodeUsageInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + videoUsageHints: VideoDecodeUsageFlagsKHR, +} + +VideoDecodeInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + flags: VideoDecodeFlagsKHR, + srcBuffer: Buffer, + srcBufferOffset: DeviceSize, + srcBufferRange: DeviceSize, + dstPictureResource: VideoPictureResourceInfoKHR, + pSetupReferenceSlot: ^VideoReferenceSlotInfoKHR, + referenceSlotCount: u32, + pReferenceSlots: [^]VideoReferenceSlotInfoKHR, +} + +VideoDecodeH264ProfileInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + stdProfileIdc: VideoH264ProfileIdc, + pictureLayout: VideoDecodeH264PictureLayoutFlagsKHR, +} + +VideoDecodeH264CapabilitiesKHR :: struct { + sType: StructureType, + pNext: rawptr, + maxLevelIdc: VideoH264LevelIdc, + fieldOffsetGranularity: Offset2D, +} + +VideoDecodeH264SessionParametersAddInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + stdSPSCount: u32, + pStdSPSs: [^]VideoH264SequenceParameterSet, + stdPPSCount: u32, + pStdPPSs: [^]VideoH264PictureParameterSet, +} + +VideoDecodeH264SessionParametersCreateInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + maxStdSPSCount: u32, + maxStdPPSCount: u32, + pParametersAddInfo: ^VideoDecodeH264SessionParametersAddInfoKHR, +} + +VideoDecodeH264PictureInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + pStdPictureInfo: ^VideoDecodeH264PictureInfo, + sliceCount: u32, + pSliceOffsets: [^]u32, +} + +VideoDecodeH264DpbSlotInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + pStdReferenceInfo: ^VideoDecodeH264ReferenceInfo, +} + +RenderingFragmentShadingRateAttachmentInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + imageView: ImageView, + imageLayout: ImageLayout, + shadingRateAttachmentTexelSize: Extent2D, +} + +RenderingFragmentDensityMapAttachmentInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + imageView: ImageView, + imageLayout: ImageLayout, +} + +AttachmentSampleCountInfoAMD :: struct { + sType: StructureType, + pNext: rawptr, + colorAttachmentCount: u32, + pColorAttachmentSamples: [^]SampleCountFlags, + depthStencilAttachmentSamples: SampleCountFlags, +} + +MultiviewPerViewAttributesInfoNVX :: struct { + sType: StructureType, + pNext: rawptr, + perViewAttributes: b32, + perViewAttributesPositionXOnly: b32, +} + +ImportMemoryFdInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + handleType: ExternalMemoryHandleTypeFlags, + fd: c.int, +} + +MemoryFdPropertiesKHR :: struct { + sType: StructureType, + pNext: rawptr, + memoryTypeBits: u32, +} + +MemoryGetFdInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + memory: DeviceMemory, + handleType: ExternalMemoryHandleTypeFlags, +} + +ImportSemaphoreFdInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + semaphore: Semaphore, + flags: SemaphoreImportFlags, + handleType: ExternalSemaphoreHandleTypeFlags, + fd: c.int, +} + +SemaphoreGetFdInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + semaphore: Semaphore, + handleType: ExternalSemaphoreHandleTypeFlags, +} + +PhysicalDevicePushDescriptorPropertiesKHR :: struct { + sType: StructureType, + pNext: rawptr, + maxPushDescriptors: u32, +} + +RectLayerKHR :: struct { + offset: Offset2D, + extent: Extent2D, + layer: u32, +} + +PresentRegionKHR :: struct { + rectangleCount: u32, + pRectangles: [^]RectLayerKHR, +} + +PresentRegionsKHR :: struct { + sType: StructureType, + pNext: rawptr, + swapchainCount: u32, + pRegions: [^]PresentRegionKHR, +} + +SharedPresentSurfaceCapabilitiesKHR :: struct { + sType: StructureType, + pNext: rawptr, + sharedPresentSupportedUsageFlags: ImageUsageFlags, +} + +ImportFenceFdInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + fence: Fence, + flags: FenceImportFlags, + handleType: ExternalFenceHandleTypeFlags, + fd: c.int, +} + +FenceGetFdInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + fence: Fence, + handleType: ExternalFenceHandleTypeFlags, +} + +PhysicalDevicePerformanceQueryFeaturesKHR :: struct { + sType: StructureType, + pNext: rawptr, + performanceCounterQueryPools: b32, + performanceCounterMultipleQueryPools: b32, +} + +PhysicalDevicePerformanceQueryPropertiesKHR :: struct { + sType: StructureType, + pNext: rawptr, + allowCommandBufferQueryCopies: b32, +} + +PerformanceCounterKHR :: struct { + sType: StructureType, + pNext: rawptr, + unit: PerformanceCounterUnitKHR, + scope: PerformanceCounterScopeKHR, + storage: PerformanceCounterStorageKHR, + uuid: [UUID_SIZE]u8, +} + +PerformanceCounterDescriptionKHR :: struct { + sType: StructureType, + pNext: rawptr, + flags: PerformanceCounterDescriptionFlagsKHR, + name: [MAX_DESCRIPTION_SIZE]byte, + category: [MAX_DESCRIPTION_SIZE]byte, + description: [MAX_DESCRIPTION_SIZE]byte, +} + +QueryPoolPerformanceCreateInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + queueFamilyIndex: u32, + counterIndexCount: u32, + pCounterIndices: [^]u32, +} + +PerformanceCounterResultKHR :: struct #raw_union { + int32: i32, + int64: i64, + uint32: u32, + uint64: u64, + float32: f32, + float64: f64, +} + +AcquireProfilingLockInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + flags: AcquireProfilingLockFlagsKHR, + timeout: u64, +} + +PerformanceQuerySubmitInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + counterPassIndex: u32, +} + +PhysicalDeviceSurfaceInfo2KHR :: struct { + sType: StructureType, + pNext: rawptr, + surface: SurfaceKHR, +} + +SurfaceCapabilities2KHR :: struct { + sType: StructureType, + pNext: rawptr, + surfaceCapabilities: SurfaceCapabilitiesKHR, +} + +SurfaceFormat2KHR :: struct { + sType: StructureType, + pNext: rawptr, + surfaceFormat: SurfaceFormatKHR, +} + +DisplayProperties2KHR :: struct { + sType: StructureType, + pNext: rawptr, + displayProperties: DisplayPropertiesKHR, +} + +DisplayPlaneProperties2KHR :: struct { + sType: StructureType, + pNext: rawptr, + displayPlaneProperties: DisplayPlanePropertiesKHR, +} + +DisplayModeProperties2KHR :: struct { + sType: StructureType, + pNext: rawptr, + displayModeProperties: DisplayModePropertiesKHR, +} + +DisplayPlaneInfo2KHR :: struct { + sType: StructureType, + pNext: rawptr, + mode: DisplayModeKHR, + planeIndex: u32, +} + +DisplayPlaneCapabilities2KHR :: struct { + sType: StructureType, + pNext: rawptr, + capabilities: DisplayPlaneCapabilitiesKHR, +} + +PhysicalDeviceShaderClockFeaturesKHR :: struct { + sType: StructureType, + pNext: rawptr, + shaderSubgroupClock: b32, + shaderDeviceClock: b32, +} + +VideoDecodeH265ProfileInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + stdProfileIdc: VideoH265ProfileIdc, +} + +VideoDecodeH265CapabilitiesKHR :: struct { + sType: StructureType, + pNext: rawptr, + maxLevelIdc: VideoH265LevelIdc, +} + +VideoDecodeH265SessionParametersAddInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + stdVPSCount: u32, + pStdVPSs: [^]VideoH265VideoParameterSet, + stdSPSCount: u32, + pStdSPSs: [^]VideoH265SequenceParameterSet, + stdPPSCount: u32, + pStdPPSs: [^]VideoH265PictureParameterSet, +} + +VideoDecodeH265SessionParametersCreateInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + maxStdVPSCount: u32, + maxStdSPSCount: u32, + maxStdPPSCount: u32, + pParametersAddInfo: ^VideoDecodeH265SessionParametersAddInfoKHR, +} + +VideoDecodeH265PictureInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + pStdPictureInfo: ^VideoDecodeH265PictureInfo, + sliceSegmentCount: u32, + pSliceSegmentOffsets: [^]u32, +} + +VideoDecodeH265DpbSlotInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + pStdReferenceInfo: ^VideoDecodeH265ReferenceInfo, +} + +DeviceQueueGlobalPriorityCreateInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + globalPriority: QueueGlobalPriorityKHR, +} + +PhysicalDeviceGlobalPriorityQueryFeaturesKHR :: struct { + sType: StructureType, + pNext: rawptr, + globalPriorityQuery: b32, +} + +QueueFamilyGlobalPriorityPropertiesKHR :: struct { + sType: StructureType, + pNext: rawptr, + priorityCount: u32, + priorities: [MAX_GLOBAL_PRIORITY_SIZE_KHR]QueueGlobalPriorityKHR, +} + +FragmentShadingRateAttachmentInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + pFragmentShadingRateAttachment: ^AttachmentReference2, + shadingRateAttachmentTexelSize: Extent2D, +} + +PipelineFragmentShadingRateStateCreateInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + fragmentSize: Extent2D, + combinerOps: [2]FragmentShadingRateCombinerOpKHR, +} + +PhysicalDeviceFragmentShadingRateFeaturesKHR :: struct { + sType: StructureType, + pNext: rawptr, + pipelineFragmentShadingRate: b32, + primitiveFragmentShadingRate: b32, + attachmentFragmentShadingRate: b32, +} + +PhysicalDeviceFragmentShadingRatePropertiesKHR :: struct { + sType: StructureType, + pNext: rawptr, + minFragmentShadingRateAttachmentTexelSize: Extent2D, + maxFragmentShadingRateAttachmentTexelSize: Extent2D, + maxFragmentShadingRateAttachmentTexelSizeAspectRatio: u32, + primitiveFragmentShadingRateWithMultipleViewports: b32, + layeredShadingRateAttachments: b32, + fragmentShadingRateNonTrivialCombinerOps: b32, + maxFragmentSize: Extent2D, + maxFragmentSizeAspectRatio: u32, + maxFragmentShadingRateCoverageSamples: u32, + maxFragmentShadingRateRasterizationSamples: SampleCountFlags, + fragmentShadingRateWithShaderDepthStencilWrites: b32, + fragmentShadingRateWithSampleMask: b32, + fragmentShadingRateWithShaderSampleMask: b32, + fragmentShadingRateWithConservativeRasterization: b32, + fragmentShadingRateWithFragmentShaderInterlock: b32, + fragmentShadingRateWithCustomSampleLocations: b32, + fragmentShadingRateStrictMultiplyCombiner: b32, +} + +PhysicalDeviceFragmentShadingRateKHR :: struct { + sType: StructureType, + pNext: rawptr, + sampleCounts: SampleCountFlags, + fragmentSize: Extent2D, +} + +SurfaceProtectedCapabilitiesKHR :: struct { + sType: StructureType, + pNext: rawptr, + supportsProtected: b32, +} + +PhysicalDevicePresentWaitFeaturesKHR :: struct { + sType: StructureType, + pNext: rawptr, + presentWait: b32, +} + +PhysicalDevicePipelineExecutablePropertiesFeaturesKHR :: struct { + sType: StructureType, + pNext: rawptr, + pipelineExecutableInfo: b32, +} + +PipelineInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + pipeline: Pipeline, +} + +PipelineExecutablePropertiesKHR :: struct { + sType: StructureType, + pNext: rawptr, + stages: ShaderStageFlags, + name: [MAX_DESCRIPTION_SIZE]byte, + description: [MAX_DESCRIPTION_SIZE]byte, + subgroupSize: u32, +} + +PipelineExecutableInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + pipeline: Pipeline, + executableIndex: u32, +} + +PipelineExecutableStatisticValueKHR :: struct #raw_union { + b32: b32, + i64: i64, + u64: u64, + f64: f64, +} + +PipelineExecutableStatisticKHR :: struct { + sType: StructureType, + pNext: rawptr, + name: [MAX_DESCRIPTION_SIZE]byte, + description: [MAX_DESCRIPTION_SIZE]byte, + format: PipelineExecutableStatisticFormatKHR, + value: PipelineExecutableStatisticValueKHR, +} + +PipelineExecutableInternalRepresentationKHR :: struct { + sType: StructureType, + pNext: rawptr, + name: [MAX_DESCRIPTION_SIZE]byte, + description: [MAX_DESCRIPTION_SIZE]byte, + isText: b32, + dataSize: int, + pData: rawptr, +} + +MemoryMapInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + flags: MemoryMapFlags, + memory: DeviceMemory, + offset: DeviceSize, + size: DeviceSize, +} + +MemoryUnmapInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + flags: MemoryUnmapFlagsKHR, + memory: DeviceMemory, +} + +PipelineLibraryCreateInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + libraryCount: u32, + pLibraries: [^]Pipeline, +} + +PresentIdKHR :: struct { + sType: StructureType, + pNext: rawptr, + swapchainCount: u32, + pPresentIds: [^]u64, +} + +PhysicalDevicePresentIdFeaturesKHR :: struct { + sType: StructureType, + pNext: rawptr, + presentId: b32, +} + +QueueFamilyCheckpointProperties2NV :: struct { + sType: StructureType, + pNext: rawptr, + checkpointExecutionStageMask: PipelineStageFlags2, +} + +CheckpointData2NV :: struct { + sType: StructureType, + pNext: rawptr, + stage: PipelineStageFlags2, + pCheckpointMarker: rawptr, +} + +PhysicalDeviceFragmentShaderBarycentricFeaturesKHR :: struct { + sType: StructureType, + pNext: rawptr, + fragmentShaderBarycentric: b32, +} + +PhysicalDeviceFragmentShaderBarycentricPropertiesKHR :: struct { + sType: StructureType, + pNext: rawptr, + triStripVertexOrderIndependentOfProvokingVertex: b32, +} + +PhysicalDeviceShaderSubgroupUniformControlFlowFeaturesKHR :: struct { + sType: StructureType, + pNext: rawptr, + shaderSubgroupUniformControlFlow: b32, +} + +PhysicalDeviceWorkgroupMemoryExplicitLayoutFeaturesKHR :: struct { + sType: StructureType, + pNext: rawptr, + workgroupMemoryExplicitLayout: b32, + workgroupMemoryExplicitLayoutScalarBlockLayout: b32, + workgroupMemoryExplicitLayout8BitAccess: b32, + workgroupMemoryExplicitLayout16BitAccess: b32, +} + +PhysicalDeviceRayTracingMaintenance1FeaturesKHR :: struct { + sType: StructureType, + pNext: rawptr, + rayTracingMaintenance1: b32, + rayTracingPipelineTraceRaysIndirect2: b32, +} + +TraceRaysIndirectCommand2KHR :: struct { + raygenShaderRecordAddress: DeviceAddress, + raygenShaderRecordSize: DeviceSize, + missShaderBindingTableAddress: DeviceAddress, + missShaderBindingTableSize: DeviceSize, + missShaderBindingTableStride: DeviceSize, + hitShaderBindingTableAddress: DeviceAddress, + hitShaderBindingTableSize: DeviceSize, + hitShaderBindingTableStride: DeviceSize, + callableShaderBindingTableAddress: DeviceAddress, + callableShaderBindingTableSize: DeviceSize, + callableShaderBindingTableStride: DeviceSize, + width: u32, + height: u32, + depth: u32, +} + +PhysicalDeviceRayTracingPositionFetchFeaturesKHR :: struct { + sType: StructureType, + pNext: rawptr, + rayTracingPositionFetch: b32, +} + +DebugReportCallbackCreateInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + flags: DebugReportFlagsEXT, + pfnCallback: ProcDebugReportCallbackEXT, + pUserData: rawptr, +} + +PipelineRasterizationStateRasterizationOrderAMD :: struct { + sType: StructureType, + pNext: rawptr, + rasterizationOrder: RasterizationOrderAMD, +} + +DebugMarkerObjectNameInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + objectType: DebugReportObjectTypeEXT, + object: u64, + pObjectName: cstring, +} + +DebugMarkerObjectTagInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + objectType: DebugReportObjectTypeEXT, + object: u64, + tagName: u64, + tagSize: int, + pTag: rawptr, +} + +DebugMarkerMarkerInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + pMarkerName: cstring, + color: [4]f32, +} + +DedicatedAllocationImageCreateInfoNV :: struct { + sType: StructureType, + pNext: rawptr, + dedicatedAllocation: b32, +} + +DedicatedAllocationBufferCreateInfoNV :: struct { + sType: StructureType, + pNext: rawptr, + dedicatedAllocation: b32, +} + +DedicatedAllocationMemoryAllocateInfoNV :: struct { + sType: StructureType, + pNext: rawptr, + image: Image, + buffer: Buffer, +} + +PhysicalDeviceTransformFeedbackFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + transformFeedback: b32, + geometryStreams: b32, +} + +PhysicalDeviceTransformFeedbackPropertiesEXT :: struct { + sType: StructureType, + pNext: rawptr, + maxTransformFeedbackStreams: u32, + maxTransformFeedbackBuffers: u32, + maxTransformFeedbackBufferSize: DeviceSize, + maxTransformFeedbackStreamDataSize: u32, + maxTransformFeedbackBufferDataSize: u32, + maxTransformFeedbackBufferDataStride: u32, + transformFeedbackQueries: b32, + transformFeedbackStreamsLinesTriangles: b32, + transformFeedbackRasterizationStreamSelect: b32, + transformFeedbackDraw: b32, +} + +PipelineRasterizationStateStreamCreateInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + flags: PipelineRasterizationStateStreamCreateFlagsEXT, + rasterizationStream: u32, +} + +CuModuleCreateInfoNVX :: struct { + sType: StructureType, + pNext: rawptr, + dataSize: int, + pData: rawptr, +} + +CuFunctionCreateInfoNVX :: struct { + sType: StructureType, + pNext: rawptr, + module: CuModuleNVX, + pName: cstring, +} + +CuLaunchInfoNVX :: struct { + sType: StructureType, + pNext: rawptr, + function: CuFunctionNVX, + gridDimX: u32, + gridDimY: u32, + gridDimZ: u32, + blockDimX: u32, + blockDimY: u32, + blockDimZ: u32, + sharedMemBytes: u32, + paramCount: int, + pParams: [^]rawptr, + extraCount: int, + pExtras: [^]rawptr, +} + +ImageViewHandleInfoNVX :: struct { + sType: StructureType, + pNext: rawptr, + imageView: ImageView, + descriptorType: DescriptorType, + sampler: Sampler, +} + +ImageViewAddressPropertiesNVX :: struct { + sType: StructureType, + pNext: rawptr, + deviceAddress: DeviceAddress, + size: DeviceSize, +} + +TextureLODGatherFormatPropertiesAMD :: struct { + sType: StructureType, + pNext: rawptr, + supportsTextureGatherLODBiasAMD: b32, +} + +ShaderResourceUsageAMD :: struct { + numUsedVgprs: u32, + numUsedSgprs: u32, + ldsSizePerLocalWorkGroup: u32, + ldsUsageSizeInBytes: int, + scratchMemUsageInBytes: int, +} + +ShaderStatisticsInfoAMD :: struct { + shaderStageMask: ShaderStageFlags, + resourceUsage: ShaderResourceUsageAMD, + numPhysicalVgprs: u32, + numPhysicalSgprs: u32, + numAvailableVgprs: u32, + numAvailableSgprs: u32, + computeWorkGroupSize: [3]u32, +} + +PhysicalDeviceCornerSampledImageFeaturesNV :: struct { + sType: StructureType, + pNext: rawptr, + cornerSampledImage: b32, +} + +ExternalImageFormatPropertiesNV :: struct { + imageFormatProperties: ImageFormatProperties, + externalMemoryFeatures: ExternalMemoryFeatureFlagsNV, + exportFromImportedHandleTypes: ExternalMemoryHandleTypeFlagsNV, + compatibleHandleTypes: ExternalMemoryHandleTypeFlagsNV, +} + +ExternalMemoryImageCreateInfoNV :: struct { + sType: StructureType, + pNext: rawptr, + handleTypes: ExternalMemoryHandleTypeFlagsNV, +} + +ExportMemoryAllocateInfoNV :: struct { + sType: StructureType, + pNext: rawptr, + handleTypes: ExternalMemoryHandleTypeFlagsNV, +} + +ValidationFlagsEXT :: struct { + sType: StructureType, + pNext: rawptr, + disabledValidationCheckCount: u32, + pDisabledValidationChecks: [^]ValidationCheckEXT, +} + +ImageViewASTCDecodeModeEXT :: struct { + sType: StructureType, + pNext: rawptr, + decodeMode: Format, +} + +PhysicalDeviceASTCDecodeFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + decodeModeSharedExponent: b32, +} + +PhysicalDevicePipelineRobustnessFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + pipelineRobustness: b32, +} + +PhysicalDevicePipelineRobustnessPropertiesEXT :: struct { + sType: StructureType, + pNext: rawptr, + defaultRobustnessStorageBuffers: PipelineRobustnessBufferBehaviorEXT, + defaultRobustnessUniformBuffers: PipelineRobustnessBufferBehaviorEXT, + defaultRobustnessVertexInputs: PipelineRobustnessBufferBehaviorEXT, + defaultRobustnessImages: PipelineRobustnessImageBehaviorEXT, +} + +PipelineRobustnessCreateInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + storageBuffers: PipelineRobustnessBufferBehaviorEXT, + uniformBuffers: PipelineRobustnessBufferBehaviorEXT, + vertexInputs: PipelineRobustnessBufferBehaviorEXT, + images: PipelineRobustnessImageBehaviorEXT, +} + +ConditionalRenderingBeginInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + buffer: Buffer, + offset: DeviceSize, + flags: ConditionalRenderingFlagsEXT, +} + +PhysicalDeviceConditionalRenderingFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + conditionalRendering: b32, + inheritedConditionalRendering: b32, +} + +CommandBufferInheritanceConditionalRenderingInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + conditionalRenderingEnable: b32, +} + +ViewportWScalingNV :: struct { + xcoeff: f32, + ycoeff: f32, +} + +PipelineViewportWScalingStateCreateInfoNV :: struct { + sType: StructureType, + pNext: rawptr, + viewportWScalingEnable: b32, + viewportCount: u32, + pViewportWScalings: [^]ViewportWScalingNV, +} + +SurfaceCapabilities2EXT :: struct { + sType: StructureType, + pNext: rawptr, + minImageCount: u32, + maxImageCount: u32, + currentExtent: Extent2D, + minImageExtent: Extent2D, + maxImageExtent: Extent2D, + maxImageArrayLayers: u32, + supportedTransforms: SurfaceTransformFlagsKHR, + currentTransform: SurfaceTransformFlagsKHR, + supportedCompositeAlpha: CompositeAlphaFlagsKHR, + supportedUsageFlags: ImageUsageFlags, + supportedSurfaceCounters: SurfaceCounterFlagsEXT, +} + +DisplayPowerInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + powerState: DisplayPowerStateEXT, +} + +DeviceEventInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + deviceEvent: DeviceEventTypeEXT, +} + +DisplayEventInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + displayEvent: DisplayEventTypeEXT, +} + +SwapchainCounterCreateInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + surfaceCounters: SurfaceCounterFlagsEXT, +} + +RefreshCycleDurationGOOGLE :: struct { + refreshDuration: u64, +} + +PastPresentationTimingGOOGLE :: struct { + presentID: u32, + desiredPresentTime: u64, + actualPresentTime: u64, + earliestPresentTime: u64, + presentMargin: u64, +} + +PresentTimeGOOGLE :: struct { + presentID: u32, + desiredPresentTime: u64, +} + +PresentTimesInfoGOOGLE :: struct { + sType: StructureType, + pNext: rawptr, + swapchainCount: u32, + pTimes: [^]PresentTimeGOOGLE, +} + +PhysicalDeviceMultiviewPerViewAttributesPropertiesNVX :: struct { + sType: StructureType, + pNext: rawptr, + perViewPositionAllComponents: b32, +} + +ViewportSwizzleNV :: struct { + x: ViewportCoordinateSwizzleNV, + y: ViewportCoordinateSwizzleNV, + z: ViewportCoordinateSwizzleNV, + w: ViewportCoordinateSwizzleNV, +} + +PipelineViewportSwizzleStateCreateInfoNV :: struct { + sType: StructureType, + pNext: rawptr, + flags: PipelineViewportSwizzleStateCreateFlagsNV, + viewportCount: u32, + pViewportSwizzles: [^]ViewportSwizzleNV, +} + +PhysicalDeviceDiscardRectanglePropertiesEXT :: struct { + sType: StructureType, + pNext: rawptr, + maxDiscardRectangles: u32, +} + +PipelineDiscardRectangleStateCreateInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + flags: PipelineDiscardRectangleStateCreateFlagsEXT, + discardRectangleMode: DiscardRectangleModeEXT, + discardRectangleCount: u32, + pDiscardRectangles: [^]Rect2D, +} + +PhysicalDeviceConservativeRasterizationPropertiesEXT :: struct { + sType: StructureType, + pNext: rawptr, + primitiveOverestimationSize: f32, + maxExtraPrimitiveOverestimationSize: f32, + extraPrimitiveOverestimationSizeGranularity: f32, + primitiveUnderestimation: b32, + conservativePointAndLineRasterization: b32, + degenerateTrianglesRasterized: b32, + degenerateLinesRasterized: b32, + fullyCoveredFragmentShaderInputVariable: b32, + conservativeRasterizationPostDepthCoverage: b32, +} + +PipelineRasterizationConservativeStateCreateInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + flags: PipelineRasterizationConservativeStateCreateFlagsEXT, + conservativeRasterizationMode: ConservativeRasterizationModeEXT, + extraPrimitiveOverestimationSize: f32, +} + +PhysicalDeviceDepthClipEnableFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + depthClipEnable: b32, +} + +PipelineRasterizationDepthClipStateCreateInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + flags: PipelineRasterizationDepthClipStateCreateFlagsEXT, + depthClipEnable: b32, +} + +XYColorEXT :: struct { + x: f32, + y: f32, +} + +HdrMetadataEXT :: struct { + sType: StructureType, + pNext: rawptr, + displayPrimaryRed: XYColorEXT, + displayPrimaryGreen: XYColorEXT, + displayPrimaryBlue: XYColorEXT, + whitePoint: XYColorEXT, + maxLuminance: f32, + minLuminance: f32, + maxContentLightLevel: f32, + maxFrameAverageLightLevel: f32, +} + +DebugUtilsLabelEXT :: struct { + sType: StructureType, + pNext: rawptr, + pLabelName: cstring, + color: [4]f32, +} + +DebugUtilsObjectNameInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + objectType: ObjectType, + objectHandle: u64, + pObjectName: cstring, +} + +DebugUtilsMessengerCallbackDataEXT :: struct { + sType: StructureType, + pNext: rawptr, + flags: DebugUtilsMessengerCallbackDataFlagsEXT, + pMessageIdName: cstring, + messageIdNumber: i32, + pMessage: cstring, + queueLabelCount: u32, + pQueueLabels: [^]DebugUtilsLabelEXT, + cmdBufLabelCount: u32, + pCmdBufLabels: [^]DebugUtilsLabelEXT, + objectCount: u32, + pObjects: [^]DebugUtilsObjectNameInfoEXT, +} + +DebugUtilsMessengerCreateInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + flags: DebugUtilsMessengerCreateFlagsEXT, + messageSeverity: DebugUtilsMessageSeverityFlagsEXT, + messageType: DebugUtilsMessageTypeFlagsEXT, + pfnUserCallback: ProcDebugUtilsMessengerCallbackEXT, + pUserData: rawptr, +} + +DebugUtilsObjectTagInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + objectType: ObjectType, + objectHandle: u64, + tagName: u64, + tagSize: int, + pTag: rawptr, +} + +SampleLocationEXT :: struct { + x: f32, + y: f32, +} + +SampleLocationsInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + sampleLocationsPerPixel: SampleCountFlags, + sampleLocationGridSize: Extent2D, + sampleLocationsCount: u32, + pSampleLocations: [^]SampleLocationEXT, +} + +AttachmentSampleLocationsEXT :: struct { + attachmentIndex: u32, + sampleLocationsInfo: SampleLocationsInfoEXT, +} + +SubpassSampleLocationsEXT :: struct { + subpassIndex: u32, + sampleLocationsInfo: SampleLocationsInfoEXT, +} + +RenderPassSampleLocationsBeginInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + attachmentInitialSampleLocationsCount: u32, + pAttachmentInitialSampleLocations: [^]AttachmentSampleLocationsEXT, + postSubpassSampleLocationsCount: u32, + pPostSubpassSampleLocations: [^]SubpassSampleLocationsEXT, +} + +PipelineSampleLocationsStateCreateInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + sampleLocationsEnable: b32, + sampleLocationsInfo: SampleLocationsInfoEXT, +} + +PhysicalDeviceSampleLocationsPropertiesEXT :: struct { + sType: StructureType, + pNext: rawptr, + sampleLocationSampleCounts: SampleCountFlags, + maxSampleLocationGridSize: Extent2D, + sampleLocationCoordinateRange: [2]f32, + sampleLocationSubPixelBits: u32, + variableSampleLocations: b32, +} + +MultisamplePropertiesEXT :: struct { + sType: StructureType, + pNext: rawptr, + maxSampleLocationGridSize: Extent2D, +} + +PhysicalDeviceBlendOperationAdvancedFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + advancedBlendCoherentOperations: b32, +} + +PhysicalDeviceBlendOperationAdvancedPropertiesEXT :: struct { + sType: StructureType, + pNext: rawptr, + advancedBlendMaxColorAttachments: u32, + advancedBlendIndependentBlend: b32, + advancedBlendNonPremultipliedSrcColor: b32, + advancedBlendNonPremultipliedDstColor: b32, + advancedBlendCorrelatedOverlap: b32, + advancedBlendAllOperations: b32, +} + +PipelineColorBlendAdvancedStateCreateInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + srcPremultiplied: b32, + dstPremultiplied: b32, + blendOverlap: BlendOverlapEXT, +} + +PipelineCoverageToColorStateCreateInfoNV :: struct { + sType: StructureType, + pNext: rawptr, + flags: PipelineCoverageToColorStateCreateFlagsNV, + coverageToColorEnable: b32, + coverageToColorLocation: u32, +} + +PipelineCoverageModulationStateCreateInfoNV :: struct { + sType: StructureType, + pNext: rawptr, + flags: PipelineCoverageModulationStateCreateFlagsNV, + coverageModulationMode: CoverageModulationModeNV, + coverageModulationTableEnable: b32, + coverageModulationTableCount: u32, + pCoverageModulationTable: [^]f32, +} + +PhysicalDeviceShaderSMBuiltinsPropertiesNV :: struct { + sType: StructureType, + pNext: rawptr, + shaderSMCount: u32, + shaderWarpsPerSM: u32, +} + +PhysicalDeviceShaderSMBuiltinsFeaturesNV :: struct { + sType: StructureType, + pNext: rawptr, + shaderSMBuiltins: b32, +} + +DrmFormatModifierPropertiesEXT :: struct { + drmFormatModifier: u64, + drmFormatModifierPlaneCount: u32, + drmFormatModifierTilingFeatures: FormatFeatureFlags, +} + +DrmFormatModifierPropertiesListEXT :: struct { + sType: StructureType, + pNext: rawptr, + drmFormatModifierCount: u32, + pDrmFormatModifierProperties: [^]DrmFormatModifierPropertiesEXT, +} + +PhysicalDeviceImageDrmFormatModifierInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + drmFormatModifier: u64, + sharingMode: SharingMode, + queueFamilyIndexCount: u32, + pQueueFamilyIndices: [^]u32, +} + +ImageDrmFormatModifierListCreateInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + drmFormatModifierCount: u32, + pDrmFormatModifiers: [^]u64, +} + +ImageDrmFormatModifierExplicitCreateInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + drmFormatModifier: u64, + drmFormatModifierPlaneCount: u32, + pPlaneLayouts: [^]SubresourceLayout, +} + +ImageDrmFormatModifierPropertiesEXT :: struct { + sType: StructureType, + pNext: rawptr, + drmFormatModifier: u64, +} + +DrmFormatModifierProperties2EXT :: struct { + drmFormatModifier: u64, + drmFormatModifierPlaneCount: u32, + drmFormatModifierTilingFeatures: FormatFeatureFlags2, +} + +DrmFormatModifierPropertiesList2EXT :: struct { + sType: StructureType, + pNext: rawptr, + drmFormatModifierCount: u32, + pDrmFormatModifierProperties: [^]DrmFormatModifierProperties2EXT, +} + +ValidationCacheCreateInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + flags: ValidationCacheCreateFlagsEXT, + initialDataSize: int, + pInitialData: rawptr, +} + +ShaderModuleValidationCacheCreateInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + validationCache: ValidationCacheEXT, +} + +ShadingRatePaletteNV :: struct { + shadingRatePaletteEntryCount: u32, + pShadingRatePaletteEntries: [^]ShadingRatePaletteEntryNV, +} + +PipelineViewportShadingRateImageStateCreateInfoNV :: struct { + sType: StructureType, + pNext: rawptr, + shadingRateImageEnable: b32, + viewportCount: u32, + pShadingRatePalettes: [^]ShadingRatePaletteNV, +} + +PhysicalDeviceShadingRateImageFeaturesNV :: struct { + sType: StructureType, + pNext: rawptr, + shadingRateImage: b32, + shadingRateCoarseSampleOrder: b32, +} + +PhysicalDeviceShadingRateImagePropertiesNV :: struct { + sType: StructureType, + pNext: rawptr, + shadingRateTexelSize: Extent2D, + shadingRatePaletteSize: u32, + shadingRateMaxCoarseSamples: u32, +} + +CoarseSampleLocationNV :: struct { + pixelX: u32, + pixelY: u32, + sample: u32, +} + +CoarseSampleOrderCustomNV :: struct { + shadingRate: ShadingRatePaletteEntryNV, + sampleCount: u32, + sampleLocationCount: u32, + pSampleLocations: [^]CoarseSampleLocationNV, +} + +PipelineViewportCoarseSampleOrderStateCreateInfoNV :: struct { + sType: StructureType, + pNext: rawptr, + sampleOrderType: CoarseSampleOrderTypeNV, + customSampleOrderCount: u32, + pCustomSampleOrders: [^]CoarseSampleOrderCustomNV, +} + +RayTracingShaderGroupCreateInfoNV :: struct { + sType: StructureType, + pNext: rawptr, + type: RayTracingShaderGroupTypeKHR, + generalShader: u32, + closestHitShader: u32, + anyHitShader: u32, + intersectionShader: u32, +} + +RayTracingPipelineCreateInfoNV :: struct { + sType: StructureType, + pNext: rawptr, + flags: PipelineCreateFlags, + stageCount: u32, + pStages: [^]PipelineShaderStageCreateInfo, + groupCount: u32, + pGroups: [^]RayTracingShaderGroupCreateInfoNV, + maxRecursionDepth: u32, + layout: PipelineLayout, + basePipelineHandle: Pipeline, + basePipelineIndex: i32, +} + +GeometryTrianglesNV :: struct { + sType: StructureType, + pNext: rawptr, + vertexData: Buffer, + vertexOffset: DeviceSize, + vertexCount: u32, + vertexStride: DeviceSize, + vertexFormat: Format, + indexData: Buffer, + indexOffset: DeviceSize, + indexCount: u32, + indexType: IndexType, + transformData: Buffer, + transformOffset: DeviceSize, +} + +GeometryAABBNV :: struct { + sType: StructureType, + pNext: rawptr, + aabbData: Buffer, + numAABBs: u32, + stride: u32, + offset: DeviceSize, +} + +GeometryDataNV :: struct { + triangles: GeometryTrianglesNV, + aabbs: GeometryAABBNV, +} + +GeometryNV :: struct { + sType: StructureType, + pNext: rawptr, + geometryType: GeometryTypeKHR, + geometry: GeometryDataNV, + flags: GeometryFlagsKHR, +} + +AccelerationStructureInfoNV :: struct { + sType: StructureType, + pNext: rawptr, + type: AccelerationStructureTypeNV, + flags: BuildAccelerationStructureFlagsNV, + instanceCount: u32, + geometryCount: u32, + pGeometries: [^]GeometryNV, +} + +AccelerationStructureCreateInfoNV :: struct { + sType: StructureType, + pNext: rawptr, + compactedSize: DeviceSize, + info: AccelerationStructureInfoNV, +} + +BindAccelerationStructureMemoryInfoNV :: struct { + sType: StructureType, + pNext: rawptr, + accelerationStructure: AccelerationStructureNV, + memory: DeviceMemory, + memoryOffset: DeviceSize, + deviceIndexCount: u32, + pDeviceIndices: [^]u32, +} + +WriteDescriptorSetAccelerationStructureNV :: struct { + sType: StructureType, + pNext: rawptr, + accelerationStructureCount: u32, + pAccelerationStructures: [^]AccelerationStructureNV, +} + +AccelerationStructureMemoryRequirementsInfoNV :: struct { + sType: StructureType, + pNext: rawptr, + type: AccelerationStructureMemoryRequirementsTypeNV, + accelerationStructure: AccelerationStructureNV, +} + +PhysicalDeviceRayTracingPropertiesNV :: struct { + sType: StructureType, + pNext: rawptr, + shaderGroupHandleSize: u32, + maxRecursionDepth: u32, + maxShaderGroupStride: u32, + shaderGroupBaseAlignment: u32, + maxGeometryCount: u64, + maxInstanceCount: u64, + maxTriangleCount: u64, + maxDescriptorSetAccelerationStructures: u32, +} + +TransformMatrixKHR :: struct { + mat: [3][4]f32, +} + +AabbPositionsKHR :: struct { + minX: f32, + minY: f32, + minZ: f32, + maxX: f32, + maxY: f32, + maxZ: f32, +} + +AccelerationStructureInstanceKHR :: struct { + transform: TransformMatrixKHR, + accelerationStructureReference: u64, +} + +PhysicalDeviceRepresentativeFragmentTestFeaturesNV :: struct { + sType: StructureType, + pNext: rawptr, + representativeFragmentTest: b32, +} + +PipelineRepresentativeFragmentTestStateCreateInfoNV :: struct { + sType: StructureType, + pNext: rawptr, + representativeFragmentTestEnable: b32, +} + +PhysicalDeviceImageViewImageFormatInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + imageViewType: ImageViewType, +} + +FilterCubicImageViewImageFormatPropertiesEXT :: struct { + sType: StructureType, + pNext: rawptr, + filterCubic: b32, + filterCubicMinmax: b32, +} + +ImportMemoryHostPointerInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + handleType: ExternalMemoryHandleTypeFlags, + pHostPointer: rawptr, +} + +MemoryHostPointerPropertiesEXT :: struct { + sType: StructureType, + pNext: rawptr, + memoryTypeBits: u32, +} + +PhysicalDeviceExternalMemoryHostPropertiesEXT :: struct { + sType: StructureType, + pNext: rawptr, + minImportedHostPointerAlignment: DeviceSize, +} + +PipelineCompilerControlCreateInfoAMD :: struct { + sType: StructureType, + pNext: rawptr, + compilerControlFlags: PipelineCompilerControlFlagsAMD, +} + +CalibratedTimestampInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + timeDomain: TimeDomainEXT, +} + +PhysicalDeviceShaderCorePropertiesAMD :: struct { + sType: StructureType, + pNext: rawptr, + shaderEngineCount: u32, + shaderArraysPerEngineCount: u32, + computeUnitsPerShaderArray: u32, + simdPerComputeUnit: u32, + wavefrontsPerSimd: u32, + wavefrontSize: u32, + sgprsPerSimd: u32, + minSgprAllocation: u32, + maxSgprAllocation: u32, + sgprAllocationGranularity: u32, + vgprsPerSimd: u32, + minVgprAllocation: u32, + maxVgprAllocation: u32, + vgprAllocationGranularity: u32, +} + +DeviceMemoryOverallocationCreateInfoAMD :: struct { + sType: StructureType, + pNext: rawptr, + overallocationBehavior: MemoryOverallocationBehaviorAMD, +} + +PhysicalDeviceVertexAttributeDivisorPropertiesEXT :: struct { + sType: StructureType, + pNext: rawptr, + maxVertexAttribDivisor: u32, +} + +VertexInputBindingDivisorDescriptionEXT :: struct { + binding: u32, + divisor: u32, +} + +PipelineVertexInputDivisorStateCreateInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + vertexBindingDivisorCount: u32, + pVertexBindingDivisors: [^]VertexInputBindingDivisorDescriptionEXT, +} + +PhysicalDeviceVertexAttributeDivisorFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + vertexAttributeInstanceRateDivisor: b32, + vertexAttributeInstanceRateZeroDivisor: b32, +} + +PhysicalDeviceComputeShaderDerivativesFeaturesNV :: struct { + sType: StructureType, + pNext: rawptr, + computeDerivativeGroupQuads: b32, + computeDerivativeGroupLinear: b32, +} + +PhysicalDeviceMeshShaderFeaturesNV :: struct { + sType: StructureType, + pNext: rawptr, + taskShader: b32, + meshShader: b32, +} + +PhysicalDeviceMeshShaderPropertiesNV :: struct { + sType: StructureType, + pNext: rawptr, + maxDrawMeshTasksCount: u32, + maxTaskWorkGroupInvocations: u32, + maxTaskWorkGroupSize: [3]u32, + maxTaskTotalMemorySize: u32, + maxTaskOutputCount: u32, + maxMeshWorkGroupInvocations: u32, + maxMeshWorkGroupSize: [3]u32, + maxMeshTotalMemorySize: u32, + maxMeshOutputVertices: u32, + maxMeshOutputPrimitives: u32, + maxMeshMultiviewViewCount: u32, + meshOutputPerVertexGranularity: u32, + meshOutputPerPrimitiveGranularity: u32, +} + +DrawMeshTasksIndirectCommandNV :: struct { + taskCount: u32, + firstTask: u32, +} + +PhysicalDeviceShaderImageFootprintFeaturesNV :: struct { + sType: StructureType, + pNext: rawptr, + imageFootprint: b32, +} + +PipelineViewportExclusiveScissorStateCreateInfoNV :: struct { + sType: StructureType, + pNext: rawptr, + exclusiveScissorCount: u32, + pExclusiveScissors: [^]Rect2D, +} + +PhysicalDeviceExclusiveScissorFeaturesNV :: struct { + sType: StructureType, + pNext: rawptr, + exclusiveScissor: b32, +} + +QueueFamilyCheckpointPropertiesNV :: struct { + sType: StructureType, + pNext: rawptr, + checkpointExecutionStageMask: PipelineStageFlags, +} + +CheckpointDataNV :: struct { + sType: StructureType, + pNext: rawptr, + stage: PipelineStageFlags, + pCheckpointMarker: rawptr, +} + +PhysicalDeviceShaderIntegerFunctions2FeaturesINTEL :: struct { + sType: StructureType, + pNext: rawptr, + shaderIntegerFunctions2: b32, +} + +PerformanceValueDataINTEL :: struct #raw_union { + value32: u32, + value64: u64, + valueFloat: f32, + valueBool: b32, + valueString: cstring, +} + +PerformanceValueINTEL :: struct { + type: PerformanceValueTypeINTEL, + data: PerformanceValueDataINTEL, +} + +InitializePerformanceApiInfoINTEL :: struct { + sType: StructureType, + pNext: rawptr, + pUserData: rawptr, +} + +QueryPoolPerformanceQueryCreateInfoINTEL :: struct { + sType: StructureType, + pNext: rawptr, + performanceCountersSampling: QueryPoolSamplingModeINTEL, +} + +PerformanceMarkerInfoINTEL :: struct { + sType: StructureType, + pNext: rawptr, + marker: u64, +} + +PerformanceStreamMarkerInfoINTEL :: struct { + sType: StructureType, + pNext: rawptr, + marker: u32, +} + +PerformanceOverrideInfoINTEL :: struct { + sType: StructureType, + pNext: rawptr, + type: PerformanceOverrideTypeINTEL, + enable: b32, + parameter: u64, +} + +PerformanceConfigurationAcquireInfoINTEL :: struct { + sType: StructureType, + pNext: rawptr, + type: PerformanceConfigurationTypeINTEL, +} + +PhysicalDevicePCIBusInfoPropertiesEXT :: struct { + sType: StructureType, + pNext: rawptr, + pciDomain: u32, + pciBus: u32, + pciDevice: u32, + pciFunction: u32, +} + +DisplayNativeHdrSurfaceCapabilitiesAMD :: struct { + sType: StructureType, + pNext: rawptr, + localDimmingSupport: b32, +} + +SwapchainDisplayNativeHdrCreateInfoAMD :: struct { + sType: StructureType, + pNext: rawptr, + localDimmingEnable: b32, +} + +PhysicalDeviceFragmentDensityMapFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + fragmentDensityMap: b32, + fragmentDensityMapDynamic: b32, + fragmentDensityMapNonSubsampledImages: b32, +} + +PhysicalDeviceFragmentDensityMapPropertiesEXT :: struct { + sType: StructureType, + pNext: rawptr, + minFragmentDensityTexelSize: Extent2D, + maxFragmentDensityTexelSize: Extent2D, + fragmentDensityInvocations: b32, +} + +RenderPassFragmentDensityMapCreateInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + fragmentDensityMapAttachment: AttachmentReference, +} + +PhysicalDeviceShaderCoreProperties2AMD :: struct { + sType: StructureType, + pNext: rawptr, + shaderCoreFeatures: ShaderCorePropertiesFlagsAMD, + activeComputeUnitCount: u32, +} + +PhysicalDeviceCoherentMemoryFeaturesAMD :: struct { + sType: StructureType, + pNext: rawptr, + deviceCoherentMemory: b32, +} + +PhysicalDeviceShaderImageAtomicInt64FeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + shaderImageInt64Atomics: b32, + sparseImageInt64Atomics: b32, +} + +PhysicalDeviceMemoryBudgetPropertiesEXT :: struct { + sType: StructureType, + pNext: rawptr, + heapBudget: [MAX_MEMORY_HEAPS]DeviceSize, + heapUsage: [MAX_MEMORY_HEAPS]DeviceSize, +} + +PhysicalDeviceMemoryPriorityFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + memoryPriority: b32, +} + +MemoryPriorityAllocateInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + priority: f32, +} + +PhysicalDeviceDedicatedAllocationImageAliasingFeaturesNV :: struct { + sType: StructureType, + pNext: rawptr, + dedicatedAllocationImageAliasing: b32, +} + +PhysicalDeviceBufferDeviceAddressFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + bufferDeviceAddress: b32, + bufferDeviceAddressCaptureReplay: b32, + bufferDeviceAddressMultiDevice: b32, +} + +BufferDeviceAddressCreateInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + deviceAddress: DeviceAddress, +} + +ValidationFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + enabledValidationFeatureCount: u32, + pEnabledValidationFeatures: [^]ValidationFeatureEnableEXT, + disabledValidationFeatureCount: u32, + pDisabledValidationFeatures: [^]ValidationFeatureDisableEXT, +} + +CooperativeMatrixPropertiesNV :: struct { + sType: StructureType, + pNext: rawptr, + MSize: u32, + NSize: u32, + KSize: u32, + AType: ComponentTypeNV, + BType: ComponentTypeNV, + CType: ComponentTypeNV, + DType: ComponentTypeNV, + scope: ScopeNV, +} + +PhysicalDeviceCooperativeMatrixFeaturesNV :: struct { + sType: StructureType, + pNext: rawptr, + cooperativeMatrix: b32, + cooperativeMatrixRobustBufferAccess: b32, +} + +PhysicalDeviceCooperativeMatrixPropertiesNV :: struct { + sType: StructureType, + pNext: rawptr, + cooperativeMatrixSupportedStages: ShaderStageFlags, +} + +PhysicalDeviceCoverageReductionModeFeaturesNV :: struct { + sType: StructureType, + pNext: rawptr, + coverageReductionMode: b32, +} + +PipelineCoverageReductionStateCreateInfoNV :: struct { + sType: StructureType, + pNext: rawptr, + flags: PipelineCoverageReductionStateCreateFlagsNV, + coverageReductionMode: CoverageReductionModeNV, +} + +FramebufferMixedSamplesCombinationNV :: struct { + sType: StructureType, + pNext: rawptr, + coverageReductionMode: CoverageReductionModeNV, + rasterizationSamples: SampleCountFlags, + depthStencilSamples: SampleCountFlags, + colorSamples: SampleCountFlags, +} + +PhysicalDeviceFragmentShaderInterlockFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + fragmentShaderSampleInterlock: b32, + fragmentShaderPixelInterlock: b32, + fragmentShaderShadingRateInterlock: b32, +} + +PhysicalDeviceYcbcrImageArraysFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + ycbcrImageArrays: b32, +} + +PhysicalDeviceProvokingVertexFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + provokingVertexLast: b32, + transformFeedbackPreservesProvokingVertex: b32, +} + +PhysicalDeviceProvokingVertexPropertiesEXT :: struct { + sType: StructureType, + pNext: rawptr, + provokingVertexModePerPipeline: b32, + transformFeedbackPreservesTriangleFanProvokingVertex: b32, +} + +PipelineRasterizationProvokingVertexStateCreateInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + provokingVertexMode: ProvokingVertexModeEXT, +} + +HeadlessSurfaceCreateInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + flags: HeadlessSurfaceCreateFlagsEXT, +} + +PhysicalDeviceLineRasterizationFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + rectangularLines: b32, + bresenhamLines: b32, + smoothLines: b32, + stippledRectangularLines: b32, + stippledBresenhamLines: b32, + stippledSmoothLines: b32, +} + +PhysicalDeviceLineRasterizationPropertiesEXT :: struct { + sType: StructureType, + pNext: rawptr, + lineSubPixelPrecisionBits: u32, +} + +PipelineRasterizationLineStateCreateInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + lineRasterizationMode: LineRasterizationModeEXT, + stippledLineEnable: b32, + lineStippleFactor: u32, + lineStipplePattern: u16, +} + +PhysicalDeviceShaderAtomicFloatFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + shaderBufferFloat32Atomics: b32, + shaderBufferFloat32AtomicAdd: b32, + shaderBufferFloat64Atomics: b32, + shaderBufferFloat64AtomicAdd: b32, + shaderSharedFloat32Atomics: b32, + shaderSharedFloat32AtomicAdd: b32, + shaderSharedFloat64Atomics: b32, + shaderSharedFloat64AtomicAdd: b32, + shaderImageFloat32Atomics: b32, + shaderImageFloat32AtomicAdd: b32, + sparseImageFloat32Atomics: b32, + sparseImageFloat32AtomicAdd: b32, +} + +PhysicalDeviceIndexTypeUint8FeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + indexTypeUint8: b32, +} + +PhysicalDeviceExtendedDynamicStateFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + extendedDynamicState: b32, +} + +PhysicalDeviceShaderAtomicFloat2FeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + shaderBufferFloat16Atomics: b32, + shaderBufferFloat16AtomicAdd: b32, + shaderBufferFloat16AtomicMinMax: b32, + shaderBufferFloat32AtomicMinMax: b32, + shaderBufferFloat64AtomicMinMax: b32, + shaderSharedFloat16Atomics: b32, + shaderSharedFloat16AtomicAdd: b32, + shaderSharedFloat16AtomicMinMax: b32, + shaderSharedFloat32AtomicMinMax: b32, + shaderSharedFloat64AtomicMinMax: b32, + shaderImageFloat32AtomicMinMax: b32, + sparseImageFloat32AtomicMinMax: b32, +} + +SurfacePresentModeEXT :: struct { + sType: StructureType, + pNext: rawptr, + presentMode: PresentModeKHR, +} + +SurfacePresentScalingCapabilitiesEXT :: struct { + sType: StructureType, + pNext: rawptr, + supportedPresentScaling: PresentScalingFlagsEXT, + supportedPresentGravityX: PresentGravityFlagsEXT, + supportedPresentGravityY: PresentGravityFlagsEXT, + minScaledImageExtent: Extent2D, + maxScaledImageExtent: Extent2D, +} + +SurfacePresentModeCompatibilityEXT :: struct { + sType: StructureType, + pNext: rawptr, + presentModeCount: u32, + pPresentModes: [^]PresentModeKHR, +} + +PhysicalDeviceSwapchainMaintenance1FeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + swapchainMaintenance1: b32, +} + +SwapchainPresentFenceInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + swapchainCount: u32, + pFences: [^]Fence, +} + +SwapchainPresentModesCreateInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + presentModeCount: u32, + pPresentModes: [^]PresentModeKHR, +} + +SwapchainPresentModeInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + swapchainCount: u32, + pPresentModes: [^]PresentModeKHR, +} + +SwapchainPresentScalingCreateInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + scalingBehavior: PresentScalingFlagsEXT, + presentGravityX: PresentGravityFlagsEXT, + presentGravityY: PresentGravityFlagsEXT, +} + +ReleaseSwapchainImagesInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + swapchain: SwapchainKHR, + imageIndexCount: u32, + pImageIndices: [^]u32, +} + +PhysicalDeviceDeviceGeneratedCommandsPropertiesNV :: struct { + sType: StructureType, + pNext: rawptr, + maxGraphicsShaderGroupCount: u32, + maxIndirectSequenceCount: u32, + maxIndirectCommandsTokenCount: u32, + maxIndirectCommandsStreamCount: u32, + maxIndirectCommandsTokenOffset: u32, + maxIndirectCommandsStreamStride: u32, + minSequencesCountBufferOffsetAlignment: u32, + minSequencesIndexBufferOffsetAlignment: u32, + minIndirectCommandsBufferOffsetAlignment: u32, +} + +PhysicalDeviceDeviceGeneratedCommandsFeaturesNV :: struct { + sType: StructureType, + pNext: rawptr, + deviceGeneratedCommands: b32, +} + +GraphicsShaderGroupCreateInfoNV :: struct { + sType: StructureType, + pNext: rawptr, + stageCount: u32, + pStages: [^]PipelineShaderStageCreateInfo, + pVertexInputState: ^PipelineVertexInputStateCreateInfo, + pTessellationState: ^PipelineTessellationStateCreateInfo, +} + +GraphicsPipelineShaderGroupsCreateInfoNV :: struct { + sType: StructureType, + pNext: rawptr, + groupCount: u32, + pGroups: [^]GraphicsShaderGroupCreateInfoNV, + pipelineCount: u32, + pPipelines: [^]Pipeline, +} + +BindShaderGroupIndirectCommandNV :: struct { + groupIndex: u32, +} + +BindIndexBufferIndirectCommandNV :: struct { + bufferAddress: DeviceAddress, + size: u32, + indexType: IndexType, +} + +BindVertexBufferIndirectCommandNV :: struct { + bufferAddress: DeviceAddress, + size: u32, + stride: u32, +} + +SetStateFlagsIndirectCommandNV :: struct { + data: u32, +} + +IndirectCommandsStreamNV :: struct { + buffer: Buffer, + offset: DeviceSize, +} + +IndirectCommandsLayoutTokenNV :: struct { + sType: StructureType, + pNext: rawptr, + tokenType: IndirectCommandsTokenTypeNV, + stream: u32, + offset: u32, + vertexBindingUnit: u32, + vertexDynamicStride: b32, + pushconstantPipelineLayout: PipelineLayout, + pushconstantShaderStageFlags: ShaderStageFlags, + pushconstantOffset: u32, + pushconstantSize: u32, + indirectStateFlags: IndirectStateFlagsNV, + indexTypeCount: u32, + pIndexTypes: [^]IndexType, + pIndexTypeValues: [^]u32, +} + +IndirectCommandsLayoutCreateInfoNV :: struct { + sType: StructureType, + pNext: rawptr, + flags: IndirectCommandsLayoutUsageFlagsNV, + pipelineBindPoint: PipelineBindPoint, + tokenCount: u32, + pTokens: [^]IndirectCommandsLayoutTokenNV, + streamCount: u32, + pStreamStrides: [^]u32, +} + +GeneratedCommandsInfoNV :: struct { + sType: StructureType, + pNext: rawptr, + pipelineBindPoint: PipelineBindPoint, + pipeline: Pipeline, + indirectCommandsLayout: IndirectCommandsLayoutNV, + streamCount: u32, + pStreams: [^]IndirectCommandsStreamNV, + sequencesCount: u32, + preprocessBuffer: Buffer, + preprocessOffset: DeviceSize, + preprocessSize: DeviceSize, + sequencesCountBuffer: Buffer, + sequencesCountOffset: DeviceSize, + sequencesIndexBuffer: Buffer, + sequencesIndexOffset: DeviceSize, +} + +GeneratedCommandsMemoryRequirementsInfoNV :: struct { + sType: StructureType, + pNext: rawptr, + pipelineBindPoint: PipelineBindPoint, + pipeline: Pipeline, + indirectCommandsLayout: IndirectCommandsLayoutNV, + maxSequencesCount: u32, +} + +PhysicalDeviceInheritedViewportScissorFeaturesNV :: struct { + sType: StructureType, + pNext: rawptr, + inheritedViewportScissor2D: b32, +} + +CommandBufferInheritanceViewportScissorInfoNV :: struct { + sType: StructureType, + pNext: rawptr, + viewportScissor2D: b32, + viewportDepthCount: u32, + pViewportDepths: [^]Viewport, +} + +PhysicalDeviceTexelBufferAlignmentFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + texelBufferAlignment: b32, +} + +RenderPassTransformBeginInfoQCOM :: struct { + sType: StructureType, + pNext: rawptr, + transform: SurfaceTransformFlagsKHR, +} + +CommandBufferInheritanceRenderPassTransformInfoQCOM :: struct { + sType: StructureType, + pNext: rawptr, + transform: SurfaceTransformFlagsKHR, + renderArea: Rect2D, +} + +PhysicalDeviceDeviceMemoryReportFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + deviceMemoryReport: b32, +} + +DeviceMemoryReportCallbackDataEXT :: struct { + sType: StructureType, + pNext: rawptr, + flags: DeviceMemoryReportFlagsEXT, + type: DeviceMemoryReportEventTypeEXT, + memoryObjectId: u64, + size: DeviceSize, + objectType: ObjectType, + objectHandle: u64, + heapIndex: u32, +} + +DeviceDeviceMemoryReportCreateInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + flags: DeviceMemoryReportFlagsEXT, + pfnUserCallback: ProcDeviceMemoryReportCallbackEXT, + pUserData: rawptr, +} + +PhysicalDeviceRobustness2FeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + robustBufferAccess2: b32, + robustImageAccess2: b32, + nullDescriptor: b32, +} + +PhysicalDeviceRobustness2PropertiesEXT :: struct { + sType: StructureType, + pNext: rawptr, + robustStorageBufferAccessSizeAlignment: DeviceSize, + robustUniformBufferAccessSizeAlignment: DeviceSize, +} + +SamplerCustomBorderColorCreateInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + customBorderColor: ClearColorValue, + format: Format, +} + +PhysicalDeviceCustomBorderColorPropertiesEXT :: struct { + sType: StructureType, + pNext: rawptr, + maxCustomBorderColorSamplers: u32, +} + +PhysicalDeviceCustomBorderColorFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + customBorderColors: b32, + customBorderColorWithoutFormat: b32, +} + +PhysicalDevicePresentBarrierFeaturesNV :: struct { + sType: StructureType, + pNext: rawptr, + presentBarrier: b32, +} + +SurfaceCapabilitiesPresentBarrierNV :: struct { + sType: StructureType, + pNext: rawptr, + presentBarrierSupported: b32, +} + +SwapchainPresentBarrierCreateInfoNV :: struct { + sType: StructureType, + pNext: rawptr, + presentBarrierEnable: b32, +} + +PhysicalDeviceDiagnosticsConfigFeaturesNV :: struct { + sType: StructureType, + pNext: rawptr, + diagnosticsConfig: b32, +} + +DeviceDiagnosticsConfigCreateInfoNV :: struct { + sType: StructureType, + pNext: rawptr, + flags: DeviceDiagnosticsConfigFlagsNV, +} + +QueryLowLatencySupportNV :: struct { + sType: StructureType, + pNext: rawptr, + pQueriedLowLatencyData: rawptr, +} + +PhysicalDeviceDescriptorBufferPropertiesEXT :: struct { + sType: StructureType, + pNext: rawptr, + combinedImageSamplerDescriptorSingleArray: b32, + bufferlessPushDescriptors: b32, + allowSamplerImageViewPostSubmitCreation: b32, + descriptorBufferOffsetAlignment: DeviceSize, + maxDescriptorBufferBindings: u32, + maxResourceDescriptorBufferBindings: u32, + maxSamplerDescriptorBufferBindings: u32, + maxEmbeddedImmutableSamplerBindings: u32, + maxEmbeddedImmutableSamplers: u32, + bufferCaptureReplayDescriptorDataSize: int, + imageCaptureReplayDescriptorDataSize: int, + imageViewCaptureReplayDescriptorDataSize: int, + samplerCaptureReplayDescriptorDataSize: int, + accelerationStructureCaptureReplayDescriptorDataSize: int, + samplerDescriptorSize: int, + combinedImageSamplerDescriptorSize: int, + sampledImageDescriptorSize: int, + storageImageDescriptorSize: int, + uniformTexelBufferDescriptorSize: int, + robustUniformTexelBufferDescriptorSize: int, + storageTexelBufferDescriptorSize: int, + robustStorageTexelBufferDescriptorSize: int, + uniformBufferDescriptorSize: int, + robustUniformBufferDescriptorSize: int, + storageBufferDescriptorSize: int, + robustStorageBufferDescriptorSize: int, + inputAttachmentDescriptorSize: int, + accelerationStructureDescriptorSize: int, + maxSamplerDescriptorBufferRange: DeviceSize, + maxResourceDescriptorBufferRange: DeviceSize, + samplerDescriptorBufferAddressSpaceSize: DeviceSize, + resourceDescriptorBufferAddressSpaceSize: DeviceSize, + descriptorBufferAddressSpaceSize: DeviceSize, +} + +PhysicalDeviceDescriptorBufferDensityMapPropertiesEXT :: struct { + sType: StructureType, + pNext: rawptr, + combinedImageSamplerDensityMapDescriptorSize: int, +} + +PhysicalDeviceDescriptorBufferFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + descriptorBuffer: b32, + descriptorBufferCaptureReplay: b32, + descriptorBufferImageLayoutIgnored: b32, + descriptorBufferPushDescriptors: b32, +} + +DescriptorAddressInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + address: DeviceAddress, + range: DeviceSize, + format: Format, +} + +DescriptorBufferBindingInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + address: DeviceAddress, + usage: BufferUsageFlags, +} + +DescriptorBufferBindingPushDescriptorBufferHandleEXT :: struct { + sType: StructureType, + pNext: rawptr, + buffer: Buffer, +} + +DescriptorDataEXT :: struct #raw_union { + pSampler: ^Sampler, + pCombinedImageSampler: ^DescriptorImageInfo, + pInputAttachmentImage: ^DescriptorImageInfo, + pSampledImage: ^DescriptorImageInfo, + pStorageImage: ^DescriptorImageInfo, + pUniformTexelBuffer: ^DescriptorAddressInfoEXT, + pStorageTexelBuffer: ^DescriptorAddressInfoEXT, + pUniformBuffer: ^DescriptorAddressInfoEXT, + pStorageBuffer: ^DescriptorAddressInfoEXT, + accelerationStructure: DeviceAddress, +} + +DescriptorGetInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + type: DescriptorType, + data: DescriptorDataEXT, +} + +BufferCaptureDescriptorDataInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + buffer: Buffer, +} + +ImageCaptureDescriptorDataInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + image: Image, +} + +ImageViewCaptureDescriptorDataInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + imageView: ImageView, +} + +SamplerCaptureDescriptorDataInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + sampler: Sampler, +} + +OpaqueCaptureDescriptorDataCreateInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + opaqueCaptureDescriptorData: rawptr, +} + +AccelerationStructureCaptureDescriptorDataInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + accelerationStructure: AccelerationStructureKHR, + accelerationStructureNV: AccelerationStructureNV, +} + +PhysicalDeviceGraphicsPipelineLibraryFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + graphicsPipelineLibrary: b32, +} + +PhysicalDeviceGraphicsPipelineLibraryPropertiesEXT :: struct { + sType: StructureType, + pNext: rawptr, + graphicsPipelineLibraryFastLinking: b32, + graphicsPipelineLibraryIndependentInterpolationDecoration: b32, +} + +GraphicsPipelineLibraryCreateInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + flags: GraphicsPipelineLibraryFlagsEXT, +} + +PhysicalDeviceShaderEarlyAndLateFragmentTestsFeaturesAMD :: struct { + sType: StructureType, + pNext: rawptr, + shaderEarlyAndLateFragmentTests: b32, +} + +PhysicalDeviceFragmentShadingRateEnumsFeaturesNV :: struct { + sType: StructureType, + pNext: rawptr, + fragmentShadingRateEnums: b32, + supersampleFragmentShadingRates: b32, + noInvocationFragmentShadingRates: b32, +} + +PhysicalDeviceFragmentShadingRateEnumsPropertiesNV :: struct { + sType: StructureType, + pNext: rawptr, + maxFragmentShadingRateInvocationCount: SampleCountFlags, +} + +PipelineFragmentShadingRateEnumStateCreateInfoNV :: struct { + sType: StructureType, + pNext: rawptr, + shadingRateType: FragmentShadingRateTypeNV, + shadingRate: FragmentShadingRateNV, + combinerOps: [2]FragmentShadingRateCombinerOpKHR, +} + +DeviceOrHostAddressConstKHR :: struct #raw_union { + deviceAddress: DeviceAddress, + hostAddress: rawptr, +} + +AccelerationStructureGeometryMotionTrianglesDataNV :: struct { + sType: StructureType, + pNext: rawptr, + vertexData: DeviceOrHostAddressConstKHR, +} + +AccelerationStructureMotionInfoNV :: struct { + sType: StructureType, + pNext: rawptr, + maxInstances: u32, + flags: AccelerationStructureMotionInfoFlagsNV, +} + +AccelerationStructureMatrixMotionInstanceNV :: struct { + transformT0: TransformMatrixKHR, + transformT1: TransformMatrixKHR, + accelerationStructureReference: u64, +} + +SRTDataNV :: struct { + sx: f32, + a: f32, + b: f32, + pvx: f32, + sy: f32, + c: f32, + pvy: f32, + sz: f32, + pvz: f32, + qx: f32, + qy: f32, + qz: f32, + qw: f32, + tx: f32, + ty: f32, + tz: f32, +} + +AccelerationStructureSRTMotionInstanceNV :: struct { + transformT0: SRTDataNV, + transformT1: SRTDataNV, + accelerationStructureReference: u64, +} + +AccelerationStructureMotionInstanceDataNV :: struct #raw_union { + staticInstance: AccelerationStructureInstanceKHR, + matrixMotionInstance: AccelerationStructureMatrixMotionInstanceNV, + srtMotionInstance: AccelerationStructureSRTMotionInstanceNV, +} + +AccelerationStructureMotionInstanceNV :: struct { + type: AccelerationStructureMotionInstanceTypeNV, + flags: AccelerationStructureMotionInstanceFlagsNV, + data: AccelerationStructureMotionInstanceDataNV, +} + +PhysicalDeviceRayTracingMotionBlurFeaturesNV :: struct { + sType: StructureType, + pNext: rawptr, + rayTracingMotionBlur: b32, + rayTracingMotionBlurPipelineTraceRaysIndirect: b32, +} + +PhysicalDeviceYcbcr2Plane444FormatsFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + ycbcr2plane444Formats: b32, +} + +PhysicalDeviceFragmentDensityMap2FeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + fragmentDensityMapDeferred: b32, +} + +PhysicalDeviceFragmentDensityMap2PropertiesEXT :: struct { + sType: StructureType, + pNext: rawptr, + subsampledLoads: b32, + subsampledCoarseReconstructionEarlyAccess: b32, + maxSubsampledArrayLayers: u32, + maxDescriptorSetSubsampledSamplers: u32, +} + +CopyCommandTransformInfoQCOM :: struct { + sType: StructureType, + pNext: rawptr, + transform: SurfaceTransformFlagsKHR, +} + +PhysicalDeviceImageCompressionControlFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + imageCompressionControl: b32, +} + +ImageCompressionControlEXT :: struct { + sType: StructureType, + pNext: rawptr, + flags: ImageCompressionFlagsEXT, + compressionControlPlaneCount: u32, + pFixedRateFlags: [^]ImageCompressionFixedRateFlagsEXT, +} + +SubresourceLayout2EXT :: struct { + sType: StructureType, + pNext: rawptr, + subresourceLayout: SubresourceLayout, +} + +ImageSubresource2EXT :: struct { + sType: StructureType, + pNext: rawptr, + imageSubresource: ImageSubresource, +} + +ImageCompressionPropertiesEXT :: struct { + sType: StructureType, + pNext: rawptr, + imageCompressionFlags: ImageCompressionFlagsEXT, + imageCompressionFixedRateFlags: ImageCompressionFixedRateFlagsEXT, +} + +PhysicalDeviceAttachmentFeedbackLoopLayoutFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + attachmentFeedbackLoopLayout: b32, +} + +PhysicalDevice4444FormatsFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + formatA4R4G4B4: b32, + formatA4B4G4R4: b32, +} + +PhysicalDeviceFaultFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + deviceFault: b32, + deviceFaultVendorBinary: b32, +} + +DeviceFaultCountsEXT :: struct { + sType: StructureType, + pNext: rawptr, + addressInfoCount: u32, + vendorInfoCount: u32, + vendorBinarySize: DeviceSize, +} + +DeviceFaultAddressInfoEXT :: struct { + addressType: DeviceFaultAddressTypeEXT, + reportedAddress: DeviceAddress, + addressPrecision: DeviceSize, +} + +DeviceFaultVendorInfoEXT :: struct { + description: [MAX_DESCRIPTION_SIZE]byte, + vendorFaultCode: u64, + vendorFaultData: u64, +} + +DeviceFaultInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + description: [MAX_DESCRIPTION_SIZE]byte, + pAddressInfos: [^]DeviceFaultAddressInfoEXT, + pVendorInfos: [^]DeviceFaultVendorInfoEXT, + pVendorBinaryData: rawptr, +} + +DeviceFaultVendorBinaryHeaderVersionOneEXT :: struct { + headerSize: u32, + headerVersion: DeviceFaultVendorBinaryHeaderVersionEXT, + vendorID: u32, + deviceID: u32, + driverVersion: u32, + pipelineCacheUUID: [UUID_SIZE]u8, + applicationNameOffset: u32, + applicationVersion: u32, + engineNameOffset: u32, + engineVersion: u32, + apiVersion: u32, +} + +PhysicalDeviceRasterizationOrderAttachmentAccessFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + rasterizationOrderColorAttachmentAccess: b32, + rasterizationOrderDepthAttachmentAccess: b32, + rasterizationOrderStencilAttachmentAccess: b32, +} + +PhysicalDeviceRGBA10X6FormatsFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + formatRgba10x6WithoutYCbCrSampler: b32, +} + +PhysicalDeviceMutableDescriptorTypeFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + mutableDescriptorType: b32, +} + +MutableDescriptorTypeListEXT :: struct { + descriptorTypeCount: u32, + pDescriptorTypes: [^]DescriptorType, +} + +MutableDescriptorTypeCreateInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + mutableDescriptorTypeListCount: u32, + pMutableDescriptorTypeLists: [^]MutableDescriptorTypeListEXT, +} + +PhysicalDeviceVertexInputDynamicStateFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + vertexInputDynamicState: b32, +} + +VertexInputBindingDescription2EXT :: struct { + sType: StructureType, + pNext: rawptr, + binding: u32, + stride: u32, + inputRate: VertexInputRate, + divisor: u32, +} + +VertexInputAttributeDescription2EXT :: struct { + sType: StructureType, + pNext: rawptr, + location: u32, + binding: u32, + format: Format, + offset: u32, +} + +PhysicalDeviceDrmPropertiesEXT :: struct { + sType: StructureType, + pNext: rawptr, + hasPrimary: b32, + hasRender: b32, + primaryMajor: i64, + primaryMinor: i64, + renderMajor: i64, + renderMinor: i64, +} + +PhysicalDeviceAddressBindingReportFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + reportAddressBinding: b32, +} + +DeviceAddressBindingCallbackDataEXT :: struct { + sType: StructureType, + pNext: rawptr, + flags: DeviceAddressBindingFlagsEXT, + baseAddress: DeviceAddress, + size: DeviceSize, + bindingType: DeviceAddressBindingTypeEXT, +} + +PhysicalDeviceDepthClipControlFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + depthClipControl: b32, +} + +PipelineViewportDepthClipControlCreateInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + negativeOneToOne: b32, +} + +PhysicalDevicePrimitiveTopologyListRestartFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + primitiveTopologyListRestart: b32, + primitiveTopologyPatchListRestart: b32, +} + +SubpassShadingPipelineCreateInfoHUAWEI :: struct { + sType: StructureType, + pNext: rawptr, + renderPass: RenderPass, + subpass: u32, +} + +PhysicalDeviceSubpassShadingFeaturesHUAWEI :: struct { + sType: StructureType, + pNext: rawptr, + subpassShading: b32, +} + +PhysicalDeviceSubpassShadingPropertiesHUAWEI :: struct { + sType: StructureType, + pNext: rawptr, + maxSubpassShadingWorkgroupSizeAspectRatio: u32, +} + +PhysicalDeviceInvocationMaskFeaturesHUAWEI :: struct { + sType: StructureType, + pNext: rawptr, + invocationMask: b32, +} + +MemoryGetRemoteAddressInfoNV :: struct { + sType: StructureType, + pNext: rawptr, + memory: DeviceMemory, + handleType: ExternalMemoryHandleTypeFlags, +} + +PhysicalDeviceExternalMemoryRDMAFeaturesNV :: struct { + sType: StructureType, + pNext: rawptr, + externalMemoryRDMA: b32, +} + +PipelinePropertiesIdentifierEXT :: struct { + sType: StructureType, + pNext: rawptr, + pipelineIdentifier: [UUID_SIZE]u8, +} + +PhysicalDevicePipelinePropertiesFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + pipelinePropertiesIdentifier: b32, +} + +PhysicalDeviceMultisampledRenderToSingleSampledFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + multisampledRenderToSingleSampled: b32, +} + +SubpassResolvePerformanceQueryEXT :: struct { + sType: StructureType, + pNext: rawptr, + optimal: b32, +} + +MultisampledRenderToSingleSampledInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + multisampledRenderToSingleSampledEnable: b32, + rasterizationSamples: SampleCountFlags, +} + +PhysicalDeviceExtendedDynamicState2FeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + extendedDynamicState2: b32, + extendedDynamicState2LogicOp: b32, + extendedDynamicState2PatchControlPoints: b32, +} + +PhysicalDeviceColorWriteEnableFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + colorWriteEnable: b32, +} + +PipelineColorWriteCreateInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + attachmentCount: u32, + pColorWriteEnables: [^]b32, +} + +PhysicalDevicePrimitivesGeneratedQueryFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + primitivesGeneratedQuery: b32, + primitivesGeneratedQueryWithRasterizerDiscard: b32, + primitivesGeneratedQueryWithNonZeroStreams: b32, +} + +PhysicalDeviceImageViewMinLodFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + minLod: b32, +} + +ImageViewMinLodCreateInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + minLod: f32, +} + +PhysicalDeviceMultiDrawFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + multiDraw: b32, +} + +PhysicalDeviceMultiDrawPropertiesEXT :: struct { + sType: StructureType, + pNext: rawptr, + maxMultiDrawCount: u32, +} + +MultiDrawInfoEXT :: struct { + firstVertex: u32, + vertexCount: u32, +} + +MultiDrawIndexedInfoEXT :: struct { + firstIndex: u32, + indexCount: u32, + vertexOffset: i32, +} + +PhysicalDeviceImage2DViewOf3DFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + image2DViewOf3D: b32, + sampler2DViewOf3D: b32, +} + +PhysicalDeviceShaderTileImageFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + shaderTileImageColorReadAccess: b32, + shaderTileImageDepthReadAccess: b32, + shaderTileImageStencilReadAccess: b32, +} + +PhysicalDeviceShaderTileImagePropertiesEXT :: struct { + sType: StructureType, + pNext: rawptr, + shaderTileImageCoherentReadAccelerated: b32, + shaderTileImageReadSampleFromPixelRateInvocation: b32, + shaderTileImageReadFromHelperInvocation: b32, +} + +MicromapUsageEXT :: struct { + count: u32, + subdivisionLevel: u32, + format: u32, +} + +DeviceOrHostAddressKHR :: struct #raw_union { + deviceAddress: DeviceAddress, + hostAddress: rawptr, +} + +MicromapBuildInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + type: MicromapTypeEXT, + flags: BuildMicromapFlagsEXT, + mode: BuildMicromapModeEXT, + dstMicromap: MicromapEXT, + usageCountsCount: u32, + pUsageCounts: [^]MicromapUsageEXT, + ppUsageCounts: ^[^]MicromapUsageEXT, + data: DeviceOrHostAddressConstKHR, + scratchData: DeviceOrHostAddressKHR, + triangleArray: DeviceOrHostAddressConstKHR, + triangleArrayStride: DeviceSize, +} + +MicromapCreateInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + createFlags: MicromapCreateFlagsEXT, + buffer: Buffer, + offset: DeviceSize, + size: DeviceSize, + type: MicromapTypeEXT, + deviceAddress: DeviceAddress, +} + +PhysicalDeviceOpacityMicromapFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + micromap: b32, + micromapCaptureReplay: b32, + micromapHostCommands: b32, +} + +PhysicalDeviceOpacityMicromapPropertiesEXT :: struct { + sType: StructureType, + pNext: rawptr, + maxOpacity2StateSubdivisionLevel: u32, + maxOpacity4StateSubdivisionLevel: u32, +} + +MicromapVersionInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + pVersionData: ^u8, +} + +CopyMicromapToMemoryInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + src: MicromapEXT, + dst: DeviceOrHostAddressKHR, + mode: CopyMicromapModeEXT, +} + +CopyMemoryToMicromapInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + src: DeviceOrHostAddressConstKHR, + dst: MicromapEXT, + mode: CopyMicromapModeEXT, +} + +CopyMicromapInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + src: MicromapEXT, + dst: MicromapEXT, + mode: CopyMicromapModeEXT, +} + +MicromapBuildSizesInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + micromapSize: DeviceSize, + buildScratchSize: DeviceSize, + discardable: b32, +} + +AccelerationStructureTrianglesOpacityMicromapEXT :: struct { + sType: StructureType, + pNext: rawptr, + indexType: IndexType, + indexBuffer: DeviceOrHostAddressConstKHR, + indexStride: DeviceSize, + baseTriangle: u32, + usageCountsCount: u32, + pUsageCounts: [^]MicromapUsageEXT, + ppUsageCounts: ^[^]MicromapUsageEXT, + micromap: MicromapEXT, +} + +MicromapTriangleEXT :: struct { + dataOffset: u32, + subdivisionLevel: u16, + format: u16, +} + +PhysicalDeviceClusterCullingShaderFeaturesHUAWEI :: struct { + sType: StructureType, + pNext: rawptr, + clustercullingShader: b32, + multiviewClusterCullingShader: b32, +} + +PhysicalDeviceClusterCullingShaderPropertiesHUAWEI :: struct { + sType: StructureType, + pNext: rawptr, + maxWorkGroupCount: [3]u32, + maxWorkGroupSize: [3]u32, + maxOutputClusterCount: u32, + indirectBufferOffsetAlignment: DeviceSize, +} + +PhysicalDeviceBorderColorSwizzleFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + borderColorSwizzle: b32, + borderColorSwizzleFromImage: b32, +} + +SamplerBorderColorComponentMappingCreateInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + components: ComponentMapping, + srgb: b32, +} + +PhysicalDevicePageableDeviceLocalMemoryFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + pageableDeviceLocalMemory: b32, +} + +PhysicalDeviceShaderCorePropertiesARM :: struct { + sType: StructureType, + pNext: rawptr, + pixelRate: u32, + texelRate: u32, + fmaRate: u32, +} + +PhysicalDeviceImageSlicedViewOf3DFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + imageSlicedViewOf3D: b32, +} + +ImageViewSlicedCreateInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + sliceOffset: u32, + sliceCount: u32, +} + +PhysicalDeviceDescriptorSetHostMappingFeaturesVALVE :: struct { + sType: StructureType, + pNext: rawptr, + descriptorSetHostMapping: b32, +} + +DescriptorSetBindingReferenceVALVE :: struct { + sType: StructureType, + pNext: rawptr, + descriptorSetLayout: DescriptorSetLayout, + binding: u32, +} + +DescriptorSetLayoutHostMappingInfoVALVE :: struct { + sType: StructureType, + pNext: rawptr, + descriptorOffset: int, + descriptorSize: u32, +} + +PhysicalDeviceDepthClampZeroOneFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + depthClampZeroOne: b32, +} + +PhysicalDeviceNonSeamlessCubeMapFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + nonSeamlessCubeMap: b32, +} + +PhysicalDeviceFragmentDensityMapOffsetFeaturesQCOM :: struct { + sType: StructureType, + pNext: rawptr, + fragmentDensityMapOffset: b32, +} + +PhysicalDeviceFragmentDensityMapOffsetPropertiesQCOM :: struct { + sType: StructureType, + pNext: rawptr, + fragmentDensityOffsetGranularity: Extent2D, +} + +SubpassFragmentDensityMapOffsetEndInfoQCOM :: struct { + sType: StructureType, + pNext: rawptr, + fragmentDensityOffsetCount: u32, + pFragmentDensityOffsets: [^]Offset2D, +} + +CopyMemoryIndirectCommandNV :: struct { + srcAddress: DeviceAddress, + dstAddress: DeviceAddress, + size: DeviceSize, +} + +CopyMemoryToImageIndirectCommandNV :: struct { + srcAddress: DeviceAddress, + bufferRowLength: u32, + bufferImageHeight: u32, + imageSubresource: ImageSubresourceLayers, + imageOffset: Offset3D, + imageExtent: Extent3D, +} + +PhysicalDeviceCopyMemoryIndirectFeaturesNV :: struct { + sType: StructureType, + pNext: rawptr, + indirectCopy: b32, +} + +PhysicalDeviceCopyMemoryIndirectPropertiesNV :: struct { + sType: StructureType, + pNext: rawptr, + supportedQueues: QueueFlags, +} + +DecompressMemoryRegionNV :: struct { + srcAddress: DeviceAddress, + dstAddress: DeviceAddress, + compressedSize: DeviceSize, + decompressedSize: DeviceSize, + decompressionMethod: MemoryDecompressionMethodFlagsNV, +} + +PhysicalDeviceMemoryDecompressionFeaturesNV :: struct { + sType: StructureType, + pNext: rawptr, + memoryDecompression: b32, +} + +PhysicalDeviceMemoryDecompressionPropertiesNV :: struct { + sType: StructureType, + pNext: rawptr, + decompressionMethods: MemoryDecompressionMethodFlagsNV, + maxDecompressionIndirectCount: u64, +} + +PhysicalDeviceLinearColorAttachmentFeaturesNV :: struct { + sType: StructureType, + pNext: rawptr, + linearColorAttachment: b32, +} + +PhysicalDeviceImageCompressionControlSwapchainFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + imageCompressionControlSwapchain: b32, +} + +ImageViewSampleWeightCreateInfoQCOM :: struct { + sType: StructureType, + pNext: rawptr, + filterCenter: Offset2D, + filterSize: Extent2D, + numPhases: u32, +} + +PhysicalDeviceImageProcessingFeaturesQCOM :: struct { + sType: StructureType, + pNext: rawptr, + textureSampleWeighted: b32, + textureBoxFilter: b32, + textureBlockMatch: b32, +} + +PhysicalDeviceImageProcessingPropertiesQCOM :: struct { + sType: StructureType, + pNext: rawptr, + maxWeightFilterPhases: u32, + maxWeightFilterDimension: Extent2D, + maxBlockMatchRegion: Extent2D, + maxBoxFilterBlockSize: Extent2D, +} + +PhysicalDeviceExtendedDynamicState3FeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + extendedDynamicState3TessellationDomainOrigin: b32, + extendedDynamicState3DepthClampEnable: b32, + extendedDynamicState3PolygonMode: b32, + extendedDynamicState3RasterizationSamples: b32, + extendedDynamicState3SampleMask: b32, + extendedDynamicState3AlphaToCoverageEnable: b32, + extendedDynamicState3AlphaToOneEnable: b32, + extendedDynamicState3LogicOpEnable: b32, + extendedDynamicState3ColorBlendEnable: b32, + extendedDynamicState3ColorBlendEquation: b32, + extendedDynamicState3ColorWriteMask: b32, + extendedDynamicState3RasterizationStream: b32, + extendedDynamicState3ConservativeRasterizationMode: b32, + extendedDynamicState3ExtraPrimitiveOverestimationSize: b32, + extendedDynamicState3DepthClipEnable: b32, + extendedDynamicState3SampleLocationsEnable: b32, + extendedDynamicState3ColorBlendAdvanced: b32, + extendedDynamicState3ProvokingVertexMode: b32, + extendedDynamicState3LineRasterizationMode: b32, + extendedDynamicState3LineStippleEnable: b32, + extendedDynamicState3DepthClipNegativeOneToOne: b32, + extendedDynamicState3ViewportWScalingEnable: b32, + extendedDynamicState3ViewportSwizzle: b32, + extendedDynamicState3CoverageToColorEnable: b32, + extendedDynamicState3CoverageToColorLocation: b32, + extendedDynamicState3CoverageModulationMode: b32, + extendedDynamicState3CoverageModulationTableEnable: b32, + extendedDynamicState3CoverageModulationTable: b32, + extendedDynamicState3CoverageReductionMode: b32, + extendedDynamicState3RepresentativeFragmentTestEnable: b32, + extendedDynamicState3ShadingRateImageEnable: b32, +} + +PhysicalDeviceExtendedDynamicState3PropertiesEXT :: struct { + sType: StructureType, + pNext: rawptr, + dynamicPrimitiveTopologyUnrestricted: b32, +} + +ColorBlendEquationEXT :: struct { + srcColorBlendFactor: BlendFactor, + dstColorBlendFactor: BlendFactor, + colorBlendOp: BlendOp, + srcAlphaBlendFactor: BlendFactor, + dstAlphaBlendFactor: BlendFactor, + alphaBlendOp: BlendOp, +} + +ColorBlendAdvancedEXT :: struct { + advancedBlendOp: BlendOp, + srcPremultiplied: b32, + dstPremultiplied: b32, + blendOverlap: BlendOverlapEXT, + clampResults: b32, +} + +PhysicalDeviceSubpassMergeFeedbackFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + subpassMergeFeedback: b32, +} + +RenderPassCreationControlEXT :: struct { + sType: StructureType, + pNext: rawptr, + disallowMerging: b32, +} + +RenderPassCreationFeedbackInfoEXT :: struct { + postMergeSubpassCount: u32, +} + +RenderPassCreationFeedbackCreateInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + pRenderPassFeedback: ^RenderPassCreationFeedbackInfoEXT, +} + +RenderPassSubpassFeedbackInfoEXT :: struct { + subpassMergeStatus: SubpassMergeStatusEXT, + description: [MAX_DESCRIPTION_SIZE]byte, + postMergeIndex: u32, +} + +RenderPassSubpassFeedbackCreateInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + pSubpassFeedback: ^RenderPassSubpassFeedbackInfoEXT, +} + +DirectDriverLoadingInfoLUNARG :: struct { + sType: StructureType, + pNext: rawptr, + flags: DirectDriverLoadingFlagsLUNARG, + pfnGetInstanceProcAddr: ProcGetInstanceProcAddrLUNARG, +} + +DirectDriverLoadingListLUNARG :: struct { + sType: StructureType, + pNext: rawptr, + mode: DirectDriverLoadingModeLUNARG, + driverCount: u32, + pDrivers: [^]DirectDriverLoadingInfoLUNARG, +} + +PhysicalDeviceShaderModuleIdentifierFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + shaderModuleIdentifier: b32, +} + +PhysicalDeviceShaderModuleIdentifierPropertiesEXT :: struct { + sType: StructureType, + pNext: rawptr, + shaderModuleIdentifierAlgorithmUUID: [UUID_SIZE]u8, +} + +PipelineShaderStageModuleIdentifierCreateInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + identifierSize: u32, + pIdentifier: ^u8, +} + +ShaderModuleIdentifierEXT :: struct { + sType: StructureType, + pNext: rawptr, + identifierSize: u32, + identifier: [MAX_SHADER_MODULE_IDENTIFIER_SIZE_EXT]u8, +} + +PhysicalDeviceOpticalFlowFeaturesNV :: struct { + sType: StructureType, + pNext: rawptr, + opticalFlow: b32, +} + +PhysicalDeviceOpticalFlowPropertiesNV :: struct { + sType: StructureType, + pNext: rawptr, + supportedOutputGridSizes: OpticalFlowGridSizeFlagsNV, + supportedHintGridSizes: OpticalFlowGridSizeFlagsNV, + hintSupported: b32, + costSupported: b32, + bidirectionalFlowSupported: b32, + globalFlowSupported: b32, + minWidth: u32, + minHeight: u32, + maxWidth: u32, + maxHeight: u32, + maxNumRegionsOfInterest: u32, +} + +OpticalFlowImageFormatInfoNV :: struct { + sType: StructureType, + pNext: rawptr, + usage: OpticalFlowUsageFlagsNV, +} + +OpticalFlowImageFormatPropertiesNV :: struct { + sType: StructureType, + pNext: rawptr, + format: Format, +} + +OpticalFlowSessionCreateInfoNV :: struct { + sType: StructureType, + pNext: rawptr, + width: u32, + height: u32, + imageFormat: Format, + flowVectorFormat: Format, + costFormat: Format, + outputGridSize: OpticalFlowGridSizeFlagsNV, + hintGridSize: OpticalFlowGridSizeFlagsNV, + performanceLevel: OpticalFlowPerformanceLevelNV, + flags: OpticalFlowSessionCreateFlagsNV, +} + +OpticalFlowSessionCreatePrivateDataInfoNV :: struct { + sType: StructureType, + pNext: rawptr, + id: u32, + size: u32, + pPrivateData: rawptr, +} + +OpticalFlowExecuteInfoNV :: struct { + sType: StructureType, + pNext: rawptr, + flags: OpticalFlowExecuteFlagsNV, + regionCount: u32, + pRegions: [^]Rect2D, +} + +PhysicalDeviceLegacyDitheringFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + legacyDithering: b32, +} + +PhysicalDevicePipelineProtectedAccessFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + pipelineProtectedAccess: b32, +} + +PhysicalDeviceShaderObjectFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + shaderObject: b32, +} + +PhysicalDeviceShaderObjectPropertiesEXT :: struct { + sType: StructureType, + pNext: rawptr, + shaderBinaryUUID: [UUID_SIZE]u8, + shaderBinaryVersion: u32, +} + +ShaderCreateInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + flags: ShaderCreateFlagsEXT, + stage: ShaderStageFlags, + nextStage: ShaderStageFlags, + codeType: ShaderCodeTypeEXT, + codeSize: int, + pCode: rawptr, + pName: cstring, + setLayoutCount: u32, + pSetLayouts: [^]DescriptorSetLayout, + pushConstantRangeCount: u32, + pPushConstantRanges: [^]PushConstantRange, + pSpecializationInfo: ^SpecializationInfo, +} + +PhysicalDeviceTilePropertiesFeaturesQCOM :: struct { + sType: StructureType, + pNext: rawptr, + tileProperties: b32, +} + +TilePropertiesQCOM :: struct { + sType: StructureType, + pNext: rawptr, + tileSize: Extent3D, + apronSize: Extent2D, + origin: Offset2D, +} + +PhysicalDeviceAmigoProfilingFeaturesSEC :: struct { + sType: StructureType, + pNext: rawptr, + amigoProfiling: b32, +} + +AmigoProfilingSubmitInfoSEC :: struct { + sType: StructureType, + pNext: rawptr, + firstDrawTimestamp: u64, + swapBufferTimestamp: u64, +} + +PhysicalDeviceMultiviewPerViewViewportsFeaturesQCOM :: struct { + sType: StructureType, + pNext: rawptr, + multiviewPerViewViewports: b32, +} + +PhysicalDeviceRayTracingInvocationReorderPropertiesNV :: struct { + sType: StructureType, + pNext: rawptr, + rayTracingInvocationReorderReorderingHint: RayTracingInvocationReorderModeNV, +} + +PhysicalDeviceRayTracingInvocationReorderFeaturesNV :: struct { + sType: StructureType, + pNext: rawptr, + rayTracingInvocationReorder: b32, +} + +PhysicalDeviceShaderCoreBuiltinsFeaturesARM :: struct { + sType: StructureType, + pNext: rawptr, + shaderCoreBuiltins: b32, +} + +PhysicalDeviceShaderCoreBuiltinsPropertiesARM :: struct { + sType: StructureType, + pNext: rawptr, + shaderCoreMask: u64, + shaderCoreCount: u32, + shaderWarpsPerCore: u32, +} + +PhysicalDevicePipelineLibraryGroupHandlesFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + pipelineLibraryGroupHandles: b32, +} + +PhysicalDeviceMultiviewPerViewRenderAreasFeaturesQCOM :: struct { + sType: StructureType, + pNext: rawptr, + multiviewPerViewRenderAreas: b32, +} + +MultiviewPerViewRenderAreasRenderPassBeginInfoQCOM :: struct { + sType: StructureType, + pNext: rawptr, + perViewRenderAreaCount: u32, + pPerViewRenderAreas: [^]Rect2D, +} + +PhysicalDeviceAttachmentFeedbackLoopDynamicStateFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + attachmentFeedbackLoopDynamicState: b32, +} + +AccelerationStructureBuildRangeInfoKHR :: struct { + primitiveCount: u32, + primitiveOffset: u32, + firstVertex: u32, + transformOffset: u32, +} + +AccelerationStructureGeometryTrianglesDataKHR :: struct { + sType: StructureType, + pNext: rawptr, + vertexFormat: Format, + vertexData: DeviceOrHostAddressConstKHR, + vertexStride: DeviceSize, + maxVertex: u32, + indexType: IndexType, + indexData: DeviceOrHostAddressConstKHR, + transformData: DeviceOrHostAddressConstKHR, +} + +AccelerationStructureGeometryAabbsDataKHR :: struct { + sType: StructureType, + pNext: rawptr, + data: DeviceOrHostAddressConstKHR, + stride: DeviceSize, +} + +AccelerationStructureGeometryInstancesDataKHR :: struct { + sType: StructureType, + pNext: rawptr, + arrayOfPointers: b32, + data: DeviceOrHostAddressConstKHR, +} + +AccelerationStructureGeometryDataKHR :: struct #raw_union { + triangles: AccelerationStructureGeometryTrianglesDataKHR, + aabbs: AccelerationStructureGeometryAabbsDataKHR, + instances: AccelerationStructureGeometryInstancesDataKHR, +} + +AccelerationStructureGeometryKHR :: struct { + sType: StructureType, + pNext: rawptr, + geometryType: GeometryTypeKHR, + geometry: AccelerationStructureGeometryDataKHR, + flags: GeometryFlagsKHR, +} + +AccelerationStructureBuildGeometryInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + type: AccelerationStructureTypeKHR, + flags: BuildAccelerationStructureFlagsKHR, + mode: BuildAccelerationStructureModeKHR, + srcAccelerationStructure: AccelerationStructureKHR, + dstAccelerationStructure: AccelerationStructureKHR, + geometryCount: u32, + pGeometries: [^]AccelerationStructureGeometryKHR, + ppGeometries: ^[^]AccelerationStructureGeometryKHR, + scratchData: DeviceOrHostAddressKHR, +} + +AccelerationStructureCreateInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + createFlags: AccelerationStructureCreateFlagsKHR, + buffer: Buffer, + offset: DeviceSize, + size: DeviceSize, + type: AccelerationStructureTypeKHR, + deviceAddress: DeviceAddress, +} + +WriteDescriptorSetAccelerationStructureKHR :: struct { + sType: StructureType, + pNext: rawptr, + accelerationStructureCount: u32, + pAccelerationStructures: [^]AccelerationStructureKHR, +} + +PhysicalDeviceAccelerationStructureFeaturesKHR :: struct { + sType: StructureType, + pNext: rawptr, + accelerationStructure: b32, + accelerationStructureCaptureReplay: b32, + accelerationStructureIndirectBuild: b32, + accelerationStructureHostCommands: b32, + descriptorBindingAccelerationStructureUpdateAfterBind: b32, +} + +PhysicalDeviceAccelerationStructurePropertiesKHR :: struct { + sType: StructureType, + pNext: rawptr, + maxGeometryCount: u64, + maxInstanceCount: u64, + maxPrimitiveCount: u64, + maxPerStageDescriptorAccelerationStructures: u32, + maxPerStageDescriptorUpdateAfterBindAccelerationStructures: u32, + maxDescriptorSetAccelerationStructures: u32, + maxDescriptorSetUpdateAfterBindAccelerationStructures: u32, + minAccelerationStructureScratchOffsetAlignment: u32, +} + +AccelerationStructureDeviceAddressInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + accelerationStructure: AccelerationStructureKHR, +} + +AccelerationStructureVersionInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + pVersionData: ^u8, +} + +CopyAccelerationStructureToMemoryInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + src: AccelerationStructureKHR, + dst: DeviceOrHostAddressKHR, + mode: CopyAccelerationStructureModeKHR, +} + +CopyMemoryToAccelerationStructureInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + src: DeviceOrHostAddressConstKHR, + dst: AccelerationStructureKHR, + mode: CopyAccelerationStructureModeKHR, +} + +CopyAccelerationStructureInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + src: AccelerationStructureKHR, + dst: AccelerationStructureKHR, + mode: CopyAccelerationStructureModeKHR, +} + +AccelerationStructureBuildSizesInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + accelerationStructureSize: DeviceSize, + updateScratchSize: DeviceSize, + buildScratchSize: DeviceSize, +} + +RayTracingShaderGroupCreateInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + type: RayTracingShaderGroupTypeKHR, + generalShader: u32, + closestHitShader: u32, + anyHitShader: u32, + intersectionShader: u32, + pShaderGroupCaptureReplayHandle: rawptr, +} + +RayTracingPipelineInterfaceCreateInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + maxPipelineRayPayloadSize: u32, + maxPipelineRayHitAttributeSize: u32, +} + +RayTracingPipelineCreateInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + flags: PipelineCreateFlags, + stageCount: u32, + pStages: [^]PipelineShaderStageCreateInfo, + groupCount: u32, + pGroups: [^]RayTracingShaderGroupCreateInfoKHR, + maxPipelineRayRecursionDepth: u32, + pLibraryInfo: ^PipelineLibraryCreateInfoKHR, + pLibraryInterface: ^RayTracingPipelineInterfaceCreateInfoKHR, + pDynamicState: ^PipelineDynamicStateCreateInfo, + layout: PipelineLayout, + basePipelineHandle: Pipeline, + basePipelineIndex: i32, +} + +PhysicalDeviceRayTracingPipelineFeaturesKHR :: struct { + sType: StructureType, + pNext: rawptr, + rayTracingPipeline: b32, + rayTracingPipelineShaderGroupHandleCaptureReplay: b32, + rayTracingPipelineShaderGroupHandleCaptureReplayMixed: b32, + rayTracingPipelineTraceRaysIndirect: b32, + rayTraversalPrimitiveCulling: b32, +} + +PhysicalDeviceRayTracingPipelinePropertiesKHR :: struct { + sType: StructureType, + pNext: rawptr, + shaderGroupHandleSize: u32, + maxRayRecursionDepth: u32, + maxShaderGroupStride: u32, + shaderGroupBaseAlignment: u32, + shaderGroupHandleCaptureReplaySize: u32, + maxRayDispatchInvocationCount: u32, + shaderGroupHandleAlignment: u32, + maxRayHitAttributeSize: u32, +} + +StridedDeviceAddressRegionKHR :: struct { + deviceAddress: DeviceAddress, + stride: DeviceSize, + size: DeviceSize, +} + +TraceRaysIndirectCommandKHR :: struct { + width: u32, + height: u32, + depth: u32, +} + +PhysicalDeviceRayQueryFeaturesKHR :: struct { + sType: StructureType, + pNext: rawptr, + rayQuery: b32, +} + +PhysicalDeviceMeshShaderFeaturesEXT :: struct { + sType: StructureType, + pNext: rawptr, + taskShader: b32, + meshShader: b32, + multiviewMeshShader: b32, + primitiveFragmentShadingRateMeshShader: b32, + meshShaderQueries: b32, +} + +PhysicalDeviceMeshShaderPropertiesEXT :: struct { + sType: StructureType, + pNext: rawptr, + maxTaskWorkGroupTotalCount: u32, + maxTaskWorkGroupCount: [3]u32, + maxTaskWorkGroupInvocations: u32, + maxTaskWorkGroupSize: [3]u32, + maxTaskPayloadSize: u32, + maxTaskSharedMemorySize: u32, + maxTaskPayloadAndSharedMemorySize: u32, + maxMeshWorkGroupTotalCount: u32, + maxMeshWorkGroupCount: [3]u32, + maxMeshWorkGroupInvocations: u32, + maxMeshWorkGroupSize: [3]u32, + maxMeshSharedMemorySize: u32, + maxMeshPayloadAndSharedMemorySize: u32, + maxMeshOutputMemorySize: u32, + maxMeshPayloadAndOutputMemorySize: u32, + maxMeshOutputComponents: u32, + maxMeshOutputVertices: u32, + maxMeshOutputPrimitives: u32, + maxMeshOutputLayers: u32, + maxMeshMultiviewViewCount: u32, + meshOutputPerVertexGranularity: u32, + meshOutputPerPrimitiveGranularity: u32, + maxPreferredTaskWorkGroupInvocations: u32, + maxPreferredMeshWorkGroupInvocations: u32, + prefersLocalInvocationVertexOutput: b32, + prefersLocalInvocationPrimitiveOutput: b32, + prefersCompactVertexOutput: b32, + prefersCompactPrimitiveOutput: b32, +} + +DrawMeshTasksIndirectCommandEXT :: struct { + groupCountX: u32, + groupCountY: u32, + groupCountZ: u32, +} + +Win32SurfaceCreateInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + flags: Win32SurfaceCreateFlagsKHR, + hinstance: HINSTANCE, + hwnd: HWND, +} + +ImportMemoryWin32HandleInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + handleType: ExternalMemoryHandleTypeFlags, + handle: HANDLE, + name: LPCWSTR, +} + +ExportMemoryWin32HandleInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + pAttributes: [^]SECURITY_ATTRIBUTES, + dwAccess: DWORD, + name: LPCWSTR, +} + +MemoryWin32HandlePropertiesKHR :: struct { + sType: StructureType, + pNext: rawptr, + memoryTypeBits: u32, +} + +MemoryGetWin32HandleInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + memory: DeviceMemory, + handleType: ExternalMemoryHandleTypeFlags, +} + +Win32KeyedMutexAcquireReleaseInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + acquireCount: u32, + pAcquireSyncs: [^]DeviceMemory, + pAcquireKeys: [^]u64, + pAcquireTimeouts: [^]u32, + releaseCount: u32, + pReleaseSyncs: [^]DeviceMemory, + pReleaseKeys: [^]u64, +} + +ImportSemaphoreWin32HandleInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + semaphore: Semaphore, + flags: SemaphoreImportFlags, + handleType: ExternalSemaphoreHandleTypeFlags, + handle: HANDLE, + name: LPCWSTR, +} + +ExportSemaphoreWin32HandleInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + pAttributes: [^]SECURITY_ATTRIBUTES, + dwAccess: DWORD, + name: LPCWSTR, +} + +D3D12FenceSubmitInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + waitSemaphoreValuesCount: u32, + pWaitSemaphoreValues: [^]u64, + signalSemaphoreValuesCount: u32, + pSignalSemaphoreValues: [^]u64, +} + +SemaphoreGetWin32HandleInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + semaphore: Semaphore, + handleType: ExternalSemaphoreHandleTypeFlags, +} + +ImportFenceWin32HandleInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + fence: Fence, + flags: FenceImportFlags, + handleType: ExternalFenceHandleTypeFlags, + handle: HANDLE, + name: LPCWSTR, +} + +ExportFenceWin32HandleInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + pAttributes: [^]SECURITY_ATTRIBUTES, + dwAccess: DWORD, + name: LPCWSTR, +} + +FenceGetWin32HandleInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + fence: Fence, + handleType: ExternalFenceHandleTypeFlags, +} + +ImportMemoryWin32HandleInfoNV :: struct { + sType: StructureType, + pNext: rawptr, + handleType: ExternalMemoryHandleTypeFlagsNV, + handle: HANDLE, +} + +ExportMemoryWin32HandleInfoNV :: struct { + sType: StructureType, + pNext: rawptr, + pAttributes: [^]SECURITY_ATTRIBUTES, + dwAccess: DWORD, +} + +Win32KeyedMutexAcquireReleaseInfoNV :: struct { + sType: StructureType, + pNext: rawptr, + acquireCount: u32, + pAcquireSyncs: [^]DeviceMemory, + pAcquireKeys: [^]u64, + pAcquireTimeoutMilliseconds: [^]u32, + releaseCount: u32, + pReleaseSyncs: [^]DeviceMemory, + pReleaseKeys: [^]u64, +} + +SurfaceFullScreenExclusiveInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + fullScreenExclusive: FullScreenExclusiveEXT, +} + +SurfaceCapabilitiesFullScreenExclusiveEXT :: struct { + sType: StructureType, + pNext: rawptr, + fullScreenExclusiveSupported: b32, +} + +SurfaceFullScreenExclusiveWin32InfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + hmonitor: HMONITOR, +} + +MetalSurfaceCreateInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + flags: MetalSurfaceCreateFlagsEXT, + pLayer: ^CAMetalLayer, +} + +ExportMetalObjectCreateInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + exportObjectType: ExportMetalObjectTypeFlagsEXT, +} + +ExportMetalObjectsInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, +} + +ExportMetalDeviceInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + mtlDevice: MTLDevice_id, +} + +ExportMetalCommandQueueInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + queue: Queue, + mtlCommandQueue: MTLCommandQueue_id, +} + +ExportMetalBufferInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + memory: DeviceMemory, + mtlBuffer: MTLBuffer_id, +} + +ImportMetalBufferInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + mtlBuffer: MTLBuffer_id, +} + +ExportMetalTextureInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + image: Image, + imageView: ImageView, + bufferView: BufferView, + plane: ImageAspectFlags, + mtlTexture: MTLTexture_id, +} + +ImportMetalTextureInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + plane: ImageAspectFlags, + mtlTexture: MTLTexture_id, +} + +ExportMetalIOSurfaceInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + image: Image, + ioSurface: IOSurfaceRef, +} + +ImportMetalIOSurfaceInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + ioSurface: IOSurfaceRef, +} + +ExportMetalSharedEventInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + semaphore: Semaphore, + event: Event, + mtlSharedEvent: MTLSharedEvent_id, +} + +ImportMetalSharedEventInfoEXT :: struct { + sType: StructureType, + pNext: rawptr, + mtlSharedEvent: MTLSharedEvent_id, +} + +MacOSSurfaceCreateInfoMVK :: struct { + sType: StructureType, + pNext: rawptr, + flags: MacOSSurfaceCreateFlagsMVK, + pView: rawptr, +} + +IOSSurfaceCreateInfoMVK :: struct { + sType: StructureType, + pNext: rawptr, + flags: IOSSurfaceCreateFlagsMVK, + pView: rawptr, +} + +WaylandSurfaceCreateInfoKHR :: struct { + sType: StructureType, + pNext: rawptr, + flags: WaylandSurfaceCreateFlagsKHR, + display: ^wl_display, + surface: ^wl_surface, +} + +VideoH264SpsVuiFlags :: struct { + bit_field: u32, +} + +VideoH264HrdParameters :: struct { + cpb_cnt_minus1: u8, + bit_rate_scale: u8, + cpb_size_scale: u8, + reserved1: u8, + bit_rate_value_minus1: [VIDEO_H264_CPB_CNT_LIST_SIZE]u32, + cpb_size_value_minus1: [VIDEO_H264_CPB_CNT_LIST_SIZE]u32, + cbr_flag: [VIDEO_H264_CPB_CNT_LIST_SIZE]u8, + initial_cpb_removal_delay_length_minus1: u32, + cpb_removal_delay_length_minus1: u32, + dpb_output_delay_length_minus1: u32, + time_offset_length: u32, +} + +VideoH264SequenceParameterSetVui :: struct { + flags: VideoH264SpsVuiFlags, + aspect_ratio_idc: VideoH264AspectRatioIdc, + sar_width: u16, + sar_height: u16, + video_format: u8, + colour_primaries: u8, + transfer_characteristics: u8, + matrix_coefficients: u8, + num_units_in_tick: u32, + time_scale: u32, + max_num_reorder_frames: u8, + max_dec_frame_buffering: u8, + chroma_sample_loc_type_top_field: u8, + chroma_sample_loc_type_bottom_field: u8, + reserved1: u32, + pHrdParameters: [^]VideoH264HrdParameters, +} + +VideoH264SpsFlags :: struct { + bit_field: u32, +} + +VideoH264ScalingLists :: struct { + scaling_list_present_mask: u16, + use_default_scaling_matrix_mask: u16, + ScalingList4x4: [VIDEO_H264_SCALING_LIST_4X4_NUM_LISTS][VIDEO_H264_SCALING_LIST_4X4_NUM_ELEMENTS]u8, + ScalingList8x8: [VIDEO_H264_SCALING_LIST_8X8_NUM_LISTS][VIDEO_H264_SCALING_LIST_8X8_NUM_ELEMENTS]u8, +} + +VideoH264SequenceParameterSet :: struct { + flags: VideoH264SpsFlags, + profile_idc: VideoH264ProfileIdc, + level_idc: VideoH264LevelIdc, + chroma_format_idc: VideoH264ChromaFormatIdc, + seq_parameter_set_id: u8, + bit_depth_luma_minus8: u8, + bit_depth_chroma_minus8: u8, + log2_max_frame_num_minus4: u8, + pic_order_cnt_type: VideoH264PocType, + offset_for_non_ref_pic: i32, + offset_for_top_to_bottom_field: i32, + log2_max_pic_order_cnt_lsb_minus4: u8, + num_ref_frames_in_pic_order_cnt_cycle: u8, + max_num_ref_frames: u8, + reserved1: u8, + pic_width_in_mbs_minus1: u32, + pic_height_in_map_units_minus1: u32, + frame_crop_left_offset: u32, + frame_crop_right_offset: u32, + frame_crop_top_offset: u32, + frame_crop_bottom_offset: u32, + reserved2: u32, + pOffsetForRefFrame: ^i32, + pScalingLists: [^]VideoH264ScalingLists, + pSequenceParameterSetVui: ^VideoH264SequenceParameterSetVui, +} + +VideoH264PpsFlags :: struct { + bit_field: u32, +} + +VideoH264PictureParameterSet :: struct { + flags: VideoH264PpsFlags, + seq_parameter_set_id: u8, + pic_parameter_set_id: u8, + num_ref_idx_l0_default_active_minus1: u8, + num_ref_idx_l1_default_active_minus1: u8, + weighted_bipred_idc: VideoH264WeightedBipredIdc, + pic_init_qp_minus26: i8, + pic_init_qs_minus26: i8, + chroma_qp_index_offset: i8, + second_chroma_qp_index_offset: i8, + pScalingLists: [^]VideoH264ScalingLists, +} + +VideoH265DecPicBufMgr :: struct { + max_latency_increase_plus1: [VIDEO_H265_SUBLAYERS_LIST_SIZE]u32, + max_dec_pic_buffering_minus1: [VIDEO_H265_SUBLAYERS_LIST_SIZE]u8, + max_num_reorder_pics: [VIDEO_H265_SUBLAYERS_LIST_SIZE]u8, +} + +VideoH265SubLayerHrdParameters :: struct { + bit_rate_value_minus1: [VIDEO_H265_CPB_CNT_LIST_SIZE]u32, + cpb_size_value_minus1: [VIDEO_H265_CPB_CNT_LIST_SIZE]u32, + cpb_size_du_value_minus1: [VIDEO_H265_CPB_CNT_LIST_SIZE]u32, + bit_rate_du_value_minus1: [VIDEO_H265_CPB_CNT_LIST_SIZE]u32, + cbr_flag: u32, +} + +VideoH265HrdFlags :: struct { + bit_field: u32, +} + +VideoH265HrdParameters :: struct { + flags: VideoH265HrdFlags, + tick_divisor_minus2: u8, + du_cpb_removal_delay_increment_length_minus1: u8, + dpb_output_delay_du_length_minus1: u8, + bit_rate_scale: u8, + cpb_size_scale: u8, + cpb_size_du_scale: u8, + initial_cpb_removal_delay_length_minus1: u8, + au_cpb_removal_delay_length_minus1: u8, + dpb_output_delay_length_minus1: u8, + cpb_cnt_minus1: [VIDEO_H265_SUBLAYERS_LIST_SIZE]u8, + elemental_duration_in_tc_minus1: [VIDEO_H265_SUBLAYERS_LIST_SIZE]u16, + reserved: [3]u16, + pSubLayerHrdParametersNal: ^VideoH265SubLayerHrdParameters, + pSubLayerHrdParametersVcl: ^VideoH265SubLayerHrdParameters, +} + +VideoH265VpsFlags :: struct { + bit_field: u32, +} + +VideoH265ProfileTierLevelFlags :: struct { + bit_field: u32, +} + +VideoH265ProfileTierLevel :: struct { + flags: VideoH265ProfileTierLevelFlags, + general_profile_idc: VideoH265ProfileIdc, + general_level_idc: VideoH265LevelIdc, +} + +VideoH265VideoParameterSet :: struct { + flags: VideoH265VpsFlags, + vps_video_parameter_set_id: u8, + vps_max_sub_layers_minus1: u8, + reserved1: u8, + reserved2: u8, + vps_num_units_in_tick: u32, + vps_time_scale: u32, + vps_num_ticks_poc_diff_one_minus1: u32, + reserved3: u32, + pDecPicBufMgr: ^VideoH265DecPicBufMgr, + pHrdParameters: [^]VideoH265HrdParameters, + pProfileTierLevel: ^VideoH265ProfileTierLevel, +} + +VideoH265ScalingLists :: struct { + ScalingList4x4: [VIDEO_H265_SCALING_LIST_4X4_NUM_LISTS][VIDEO_H265_SCALING_LIST_4X4_NUM_ELEMENTS]u8, + ScalingList8x8: [VIDEO_H265_SCALING_LIST_8X8_NUM_LISTS][VIDEO_H265_SCALING_LIST_8X8_NUM_ELEMENTS]u8, + ScalingList16x16: [VIDEO_H265_SCALING_LIST_16X16_NUM_LISTS][VIDEO_H265_SCALING_LIST_16X16_NUM_ELEMENTS]u8, + ScalingList32x32: [VIDEO_H265_SCALING_LIST_32X32_NUM_LISTS][VIDEO_H265_SCALING_LIST_32X32_NUM_ELEMENTS]u8, + ScalingListDCCoef16x16: [VIDEO_H265_SCALING_LIST_16X16_NUM_LISTS]u8, + ScalingListDCCoef32x32: [VIDEO_H265_SCALING_LIST_32X32_NUM_LISTS]u8, +} + +VideoH265SpsVuiFlags :: struct { + bit_field: u32, +} + +VideoH265SequenceParameterSetVui :: struct { + flags: VideoH265SpsVuiFlags, + aspect_ratio_idc: VideoH265AspectRatioIdc, + sar_width: u16, + sar_height: u16, + video_format: u8, + colour_primaries: u8, + transfer_characteristics: u8, + matrix_coeffs: u8, + chroma_sample_loc_type_top_field: u8, + chroma_sample_loc_type_bottom_field: u8, + reserved1: u8, + reserved2: u8, + def_disp_win_left_offset: u16, + def_disp_win_right_offset: u16, + def_disp_win_top_offset: u16, + def_disp_win_bottom_offset: u16, + vui_num_units_in_tick: u32, + vui_time_scale: u32, + vui_num_ticks_poc_diff_one_minus1: u32, + min_spatial_segmentation_idc: u16, + reserved3: u16, + max_bytes_per_pic_denom: u8, + max_bits_per_min_cu_denom: u8, + log2_max_mv_length_horizontal: u8, + log2_max_mv_length_vertical: u8, + pHrdParameters: [^]VideoH265HrdParameters, +} + +VideoH265PredictorPaletteEntries :: struct { + PredictorPaletteEntries: [VIDEO_H265_PREDICTOR_PALETTE_COMPONENTS_LIST_SIZE][VIDEO_H265_PREDICTOR_PALETTE_COMP_ENTRIES_LIST_SIZE]u16, +} + +VideoH265SpsFlags :: struct { + bit_field: u32, +} + +VideoH265ShortTermRefPicSetFlags :: struct { + bit_field: u32, +} + +VideoH265ShortTermRefPicSet :: struct { + flags: VideoH265ShortTermRefPicSetFlags, + delta_idx_minus1: u32, + use_delta_flag: u16, + abs_delta_rps_minus1: u16, + used_by_curr_pic_flag: u16, + used_by_curr_pic_s0_flag: u16, + used_by_curr_pic_s1_flag: u16, + reserved1: u16, + reserved2: u8, + reserved3: u8, + num_negative_pics: u8, + num_positive_pics: u8, + delta_poc_s0_minus1: [VIDEO_H265_MAX_DPB_SIZE]u16, + delta_poc_s1_minus1: [VIDEO_H265_MAX_DPB_SIZE]u16, +} + +VideoH265LongTermRefPicsSps :: struct { + used_by_curr_pic_lt_sps_flag: u32, + lt_ref_pic_poc_lsb_sps: [VIDEO_H265_MAX_LONG_TERM_REF_PICS_SPS]u32, +} + +VideoH265SequenceParameterSet :: struct { + flags: VideoH265SpsFlags, + chroma_format_idc: VideoH265ChromaFormatIdc, + pic_width_in_luma_samples: u32, + pic_height_in_luma_samples: u32, + sps_video_parameter_set_id: u8, + sps_max_sub_layers_minus1: u8, + sps_seq_parameter_set_id: u8, + bit_depth_luma_minus8: u8, + bit_depth_chroma_minus8: u8, + log2_max_pic_order_cnt_lsb_minus4: u8, + log2_min_luma_coding_block_size_minus3: u8, + log2_diff_max_min_luma_coding_block_size: u8, + log2_min_luma_transform_block_size_minus2: u8, + log2_diff_max_min_luma_transform_block_size: u8, + max_transform_hierarchy_depth_inter: u8, + max_transform_hierarchy_depth_intra: u8, + num_short_term_ref_pic_sets: u8, + num_long_term_ref_pics_sps: u8, + pcm_sample_bit_depth_luma_minus1: u8, + pcm_sample_bit_depth_chroma_minus1: u8, + log2_min_pcm_luma_coding_block_size_minus3: u8, + log2_diff_max_min_pcm_luma_coding_block_size: u8, + reserved1: u8, + reserved2: u8, + palette_max_size: u8, + delta_palette_max_predictor_size: u8, + motion_vector_resolution_control_idc: u8, + sps_num_palette_predictor_initializers_minus1: u8, + conf_win_left_offset: u32, + conf_win_right_offset: u32, + conf_win_top_offset: u32, + conf_win_bottom_offset: u32, + pProfileTierLevel: ^VideoH265ProfileTierLevel, + pDecPicBufMgr: ^VideoH265DecPicBufMgr, + pScalingLists: [^]VideoH265ScalingLists, + pShortTermRefPicSet: ^VideoH265ShortTermRefPicSet, + pLongTermRefPicsSps: [^]VideoH265LongTermRefPicsSps, + pSequenceParameterSetVui: ^VideoH265SequenceParameterSetVui, + pPredictorPaletteEntries: [^]VideoH265PredictorPaletteEntries, +} + +VideoH265PpsFlags :: struct { + bit_field: u32, +} + +VideoH265PictureParameterSet :: struct { + flags: VideoH265PpsFlags, + pps_pic_parameter_set_id: u8, + pps_seq_parameter_set_id: u8, + sps_video_parameter_set_id: u8, + num_extra_slice_header_bits: u8, + num_ref_idx_l0_default_active_minus1: u8, + num_ref_idx_l1_default_active_minus1: u8, + init_qp_minus26: i8, + diff_cu_qp_delta_depth: u8, + pps_cb_qp_offset: i8, + pps_cr_qp_offset: i8, + pps_beta_offset_div2: i8, + pps_tc_offset_div2: i8, + log2_parallel_merge_level_minus2: u8, + log2_max_transform_skip_block_size_minus2: u8, + diff_cu_chroma_qp_offset_depth: u8, + chroma_qp_offset_list_len_minus1: u8, + cb_qp_offset_list: [VIDEO_H265_CHROMA_QP_OFFSET_LIST_SIZE]i8, + cr_qp_offset_list: [VIDEO_H265_CHROMA_QP_OFFSET_LIST_SIZE]i8, + log2_sao_offset_scale_luma: u8, + log2_sao_offset_scale_chroma: u8, + pps_act_y_qp_offset_plus5: i8, + pps_act_cb_qp_offset_plus5: i8, + pps_act_cr_qp_offset_plus3: i8, + pps_num_palette_predictor_initializers: u8, + luma_bit_depth_entry_minus8: u8, + chroma_bit_depth_entry_minus8: u8, + num_tile_columns_minus1: u8, + num_tile_rows_minus1: u8, + reserved1: u8, + reserved2: u8, + column_width_minus1: [VIDEO_H265_CHROMA_QP_OFFSET_TILE_COLS_LIST_SIZE]u16, + row_height_minus1: [VIDEO_H265_CHROMA_QP_OFFSET_TILE_ROWS_LIST_SIZE]u16, + reserved3: u32, + pScalingLists: [^]VideoH265ScalingLists, + pPredictorPaletteEntries: [^]VideoH265PredictorPaletteEntries, +} + +VideoDecodeH264PictureInfoFlags :: struct { + bit_field: u32, +} + +VideoDecodeH264PictureInfo :: struct { + flags: VideoDecodeH264PictureInfoFlags, + seq_parameter_set_id: u8, + pic_parameter_set_id: u8, + reserved1: u8, + reserved2: u8, + frame_num: u16, + idr_pic_id: u16, + PicOrderCnt: [VIDEO_DECODE_H264_FIELD_ORDER_COUNT_LIST_SIZE]i32, +} + +VideoDecodeH264ReferenceInfoFlags :: struct { + bit_field: u32, +} + +VideoDecodeH264ReferenceInfo :: struct { + flags: VideoDecodeH264ReferenceInfoFlags, + FrameNum: u16, + reserved: u16, + PicOrderCnt: [VIDEO_DECODE_H264_FIELD_ORDER_COUNT_LIST_SIZE]i32, +} + +VideoDecodeH265PictureInfoFlags :: struct { + bit_field: u32, +} + +VideoDecodeH265PictureInfo :: struct { + flags: VideoDecodeH265PictureInfoFlags, + sps_video_parameter_set_id: u8, + pps_seq_parameter_set_id: u8, + pps_pic_parameter_set_id: u8, + NumDeltaPocsOfRefRpsIdx: u8, + PicOrderCntVal: i32, + NumBitsForSTRefPicSetInSlice: u16, + reserved: u16, + RefPicSetStCurrBefore: [VIDEO_DECODE_H265_REF_PIC_SET_LIST_SIZE]u8, + RefPicSetStCurrAfter: [VIDEO_DECODE_H265_REF_PIC_SET_LIST_SIZE]u8, + RefPicSetLtCurr: [VIDEO_DECODE_H265_REF_PIC_SET_LIST_SIZE]u8, +} + +VideoDecodeH265ReferenceInfoFlags :: struct { + bit_field: u32, +} + +VideoDecodeH265ReferenceInfo :: struct { + flags: VideoDecodeH265ReferenceInfoFlags, + PicOrderCntVal: i32, +} + +// Opaque structs + +wl_surface :: struct {} // Opaque struct defined by Wayland +wl_display :: struct {} // Opaque struct defined by Wayland +IOSurfaceRef :: struct {} // Opaque struct defined by Apple’s CoreGraphics framework +// Aliases +PhysicalDeviceVariablePointerFeatures :: PhysicalDeviceVariablePointersFeatures +PhysicalDeviceShaderDrawParameterFeatures :: PhysicalDeviceShaderDrawParametersFeatures +PipelineStageFlags2 :: Flags64 +PipelineStageFlag2 :: Flags64 +AccessFlags2 :: Flags64 +AccessFlag2 :: Flags64 +FormatFeatureFlags2 :: Flags64 +FormatFeatureFlag2 :: Flags64 +RenderingFlagsKHR :: RenderingFlags +RenderingFlagKHR :: RenderingFlag +RenderingInfoKHR :: RenderingInfo +RenderingAttachmentInfoKHR :: RenderingAttachmentInfo +PipelineRenderingCreateInfoKHR :: PipelineRenderingCreateInfo +PhysicalDeviceDynamicRenderingFeaturesKHR :: PhysicalDeviceDynamicRenderingFeatures +CommandBufferInheritanceRenderingInfoKHR :: CommandBufferInheritanceRenderingInfo +AttachmentSampleCountInfoNV :: AttachmentSampleCountInfoAMD +RenderPassMultiviewCreateInfoKHR :: RenderPassMultiviewCreateInfo +PhysicalDeviceMultiviewFeaturesKHR :: PhysicalDeviceMultiviewFeatures +PhysicalDeviceMultiviewPropertiesKHR :: PhysicalDeviceMultiviewProperties +PhysicalDeviceFeatures2KHR :: PhysicalDeviceFeatures2 +PhysicalDeviceProperties2KHR :: PhysicalDeviceProperties2 +FormatProperties2KHR :: FormatProperties2 +ImageFormatProperties2KHR :: ImageFormatProperties2 +PhysicalDeviceImageFormatInfo2KHR :: PhysicalDeviceImageFormatInfo2 +QueueFamilyProperties2KHR :: QueueFamilyProperties2 +PhysicalDeviceMemoryProperties2KHR :: PhysicalDeviceMemoryProperties2 +SparseImageFormatProperties2KHR :: SparseImageFormatProperties2 +PhysicalDeviceSparseImageFormatInfo2KHR :: PhysicalDeviceSparseImageFormatInfo2 +PeerMemoryFeatureFlagsKHR :: PeerMemoryFeatureFlags +PeerMemoryFeatureFlagKHR :: PeerMemoryFeatureFlag +MemoryAllocateFlagsKHR :: MemoryAllocateFlags +MemoryAllocateFlagKHR :: MemoryAllocateFlag +MemoryAllocateFlagsInfoKHR :: MemoryAllocateFlagsInfo +DeviceGroupRenderPassBeginInfoKHR :: DeviceGroupRenderPassBeginInfo +DeviceGroupCommandBufferBeginInfoKHR :: DeviceGroupCommandBufferBeginInfo +DeviceGroupSubmitInfoKHR :: DeviceGroupSubmitInfo +DeviceGroupBindSparseInfoKHR :: DeviceGroupBindSparseInfo +BindBufferMemoryDeviceGroupInfoKHR :: BindBufferMemoryDeviceGroupInfo +BindImageMemoryDeviceGroupInfoKHR :: BindImageMemoryDeviceGroupInfo +CommandPoolTrimFlagsKHR :: CommandPoolTrimFlags +PhysicalDeviceGroupPropertiesKHR :: PhysicalDeviceGroupProperties +DeviceGroupDeviceCreateInfoKHR :: DeviceGroupDeviceCreateInfo +ExternalMemoryHandleTypeFlagsKHR :: ExternalMemoryHandleTypeFlags +ExternalMemoryHandleTypeFlagKHR :: ExternalMemoryHandleTypeFlag +ExternalMemoryFeatureFlagsKHR :: ExternalMemoryFeatureFlags +ExternalMemoryFeatureFlagKHR :: ExternalMemoryFeatureFlag +ExternalMemoryPropertiesKHR :: ExternalMemoryProperties +PhysicalDeviceExternalImageFormatInfoKHR :: PhysicalDeviceExternalImageFormatInfo +ExternalImageFormatPropertiesKHR :: ExternalImageFormatProperties +PhysicalDeviceExternalBufferInfoKHR :: PhysicalDeviceExternalBufferInfo +ExternalBufferPropertiesKHR :: ExternalBufferProperties +PhysicalDeviceIDPropertiesKHR :: PhysicalDeviceIDProperties +ExternalMemoryImageCreateInfoKHR :: ExternalMemoryImageCreateInfo +ExternalMemoryBufferCreateInfoKHR :: ExternalMemoryBufferCreateInfo +ExportMemoryAllocateInfoKHR :: ExportMemoryAllocateInfo +ExternalSemaphoreHandleTypeFlagsKHR :: ExternalSemaphoreHandleTypeFlags +ExternalSemaphoreHandleTypeFlagKHR :: ExternalSemaphoreHandleTypeFlag +ExternalSemaphoreFeatureFlagsKHR :: ExternalSemaphoreFeatureFlags +ExternalSemaphoreFeatureFlagKHR :: ExternalSemaphoreFeatureFlag +PhysicalDeviceExternalSemaphoreInfoKHR :: PhysicalDeviceExternalSemaphoreInfo +ExternalSemaphorePropertiesKHR :: ExternalSemaphoreProperties +SemaphoreImportFlagsKHR :: SemaphoreImportFlags +SemaphoreImportFlagKHR :: SemaphoreImportFlag +ExportSemaphoreCreateInfoKHR :: ExportSemaphoreCreateInfo +PhysicalDeviceShaderFloat16Int8FeaturesKHR :: PhysicalDeviceShaderFloat16Int8Features +PhysicalDeviceFloat16Int8FeaturesKHR :: PhysicalDeviceShaderFloat16Int8Features +PhysicalDevice16BitStorageFeaturesKHR :: PhysicalDevice16BitStorageFeatures +DescriptorUpdateTemplateKHR :: DescriptorUpdateTemplate +DescriptorUpdateTemplateTypeKHR :: DescriptorUpdateTemplateType +DescriptorUpdateTemplateCreateFlagsKHR :: DescriptorUpdateTemplateCreateFlags +DescriptorUpdateTemplateEntryKHR :: DescriptorUpdateTemplateEntry +DescriptorUpdateTemplateCreateInfoKHR :: DescriptorUpdateTemplateCreateInfo +PhysicalDeviceImagelessFramebufferFeaturesKHR :: PhysicalDeviceImagelessFramebufferFeatures +FramebufferAttachmentsCreateInfoKHR :: FramebufferAttachmentsCreateInfo +FramebufferAttachmentImageInfoKHR :: FramebufferAttachmentImageInfo +RenderPassAttachmentBeginInfoKHR :: RenderPassAttachmentBeginInfo +RenderPassCreateInfo2KHR :: RenderPassCreateInfo2 +AttachmentDescription2KHR :: AttachmentDescription2 +AttachmentReference2KHR :: AttachmentReference2 +SubpassDescription2KHR :: SubpassDescription2 +SubpassDependency2KHR :: SubpassDependency2 +SubpassBeginInfoKHR :: SubpassBeginInfo +SubpassEndInfoKHR :: SubpassEndInfo +ExternalFenceHandleTypeFlagsKHR :: ExternalFenceHandleTypeFlags +ExternalFenceHandleTypeFlagKHR :: ExternalFenceHandleTypeFlag +ExternalFenceFeatureFlagsKHR :: ExternalFenceFeatureFlags +ExternalFenceFeatureFlagKHR :: ExternalFenceFeatureFlag +PhysicalDeviceExternalFenceInfoKHR :: PhysicalDeviceExternalFenceInfo +ExternalFencePropertiesKHR :: ExternalFenceProperties +FenceImportFlagsKHR :: FenceImportFlags +FenceImportFlagKHR :: FenceImportFlag +ExportFenceCreateInfoKHR :: ExportFenceCreateInfo +PointClippingBehaviorKHR :: PointClippingBehavior +TessellationDomainOriginKHR :: TessellationDomainOrigin +PhysicalDevicePointClippingPropertiesKHR :: PhysicalDevicePointClippingProperties +RenderPassInputAttachmentAspectCreateInfoKHR :: RenderPassInputAttachmentAspectCreateInfo +InputAttachmentAspectReferenceKHR :: InputAttachmentAspectReference +ImageViewUsageCreateInfoKHR :: ImageViewUsageCreateInfo +PipelineTessellationDomainOriginStateCreateInfoKHR :: PipelineTessellationDomainOriginStateCreateInfo +PhysicalDeviceVariablePointerFeaturesKHR :: PhysicalDeviceVariablePointersFeatures +PhysicalDeviceVariablePointersFeaturesKHR :: PhysicalDeviceVariablePointersFeatures +MemoryDedicatedRequirementsKHR :: MemoryDedicatedRequirements +MemoryDedicatedAllocateInfoKHR :: MemoryDedicatedAllocateInfo +BufferMemoryRequirementsInfo2KHR :: BufferMemoryRequirementsInfo2 +ImageMemoryRequirementsInfo2KHR :: ImageMemoryRequirementsInfo2 +ImageSparseMemoryRequirementsInfo2KHR :: ImageSparseMemoryRequirementsInfo2 +MemoryRequirements2KHR :: MemoryRequirements2 +SparseImageMemoryRequirements2KHR :: SparseImageMemoryRequirements2 +ImageFormatListCreateInfoKHR :: ImageFormatListCreateInfo +SamplerYcbcrConversionKHR :: SamplerYcbcrConversion +SamplerYcbcrModelConversionKHR :: SamplerYcbcrModelConversion +SamplerYcbcrRangeKHR :: SamplerYcbcrRange +ChromaLocationKHR :: ChromaLocation +SamplerYcbcrConversionCreateInfoKHR :: SamplerYcbcrConversionCreateInfo +SamplerYcbcrConversionInfoKHR :: SamplerYcbcrConversionInfo +BindImagePlaneMemoryInfoKHR :: BindImagePlaneMemoryInfo +ImagePlaneMemoryRequirementsInfoKHR :: ImagePlaneMemoryRequirementsInfo +PhysicalDeviceSamplerYcbcrConversionFeaturesKHR :: PhysicalDeviceSamplerYcbcrConversionFeatures +SamplerYcbcrConversionImageFormatPropertiesKHR :: SamplerYcbcrConversionImageFormatProperties +BindBufferMemoryInfoKHR :: BindBufferMemoryInfo +BindImageMemoryInfoKHR :: BindImageMemoryInfo +PhysicalDeviceMaintenance3PropertiesKHR :: PhysicalDeviceMaintenance3Properties +DescriptorSetLayoutSupportKHR :: DescriptorSetLayoutSupport +PhysicalDeviceShaderSubgroupExtendedTypesFeaturesKHR :: PhysicalDeviceShaderSubgroupExtendedTypesFeatures +PhysicalDevice8BitStorageFeaturesKHR :: PhysicalDevice8BitStorageFeatures +PhysicalDeviceShaderAtomicInt64FeaturesKHR :: PhysicalDeviceShaderAtomicInt64Features +DriverIdKHR :: DriverId +ConformanceVersionKHR :: ConformanceVersion +PhysicalDeviceDriverPropertiesKHR :: PhysicalDeviceDriverProperties +ShaderFloatControlsIndependenceKHR :: ShaderFloatControlsIndependence +PhysicalDeviceFloatControlsPropertiesKHR :: PhysicalDeviceFloatControlsProperties +ResolveModeFlagKHR :: ResolveModeFlag +ResolveModeFlagsKHR :: ResolveModeFlags +SubpassDescriptionDepthStencilResolveKHR :: SubpassDescriptionDepthStencilResolve +PhysicalDeviceDepthStencilResolvePropertiesKHR :: PhysicalDeviceDepthStencilResolveProperties +SemaphoreTypeKHR :: SemaphoreType +SemaphoreWaitFlagKHR :: SemaphoreWaitFlag +SemaphoreWaitFlagsKHR :: SemaphoreWaitFlags +PhysicalDeviceTimelineSemaphoreFeaturesKHR :: PhysicalDeviceTimelineSemaphoreFeatures +PhysicalDeviceTimelineSemaphorePropertiesKHR :: PhysicalDeviceTimelineSemaphoreProperties +SemaphoreTypeCreateInfoKHR :: SemaphoreTypeCreateInfo +TimelineSemaphoreSubmitInfoKHR :: TimelineSemaphoreSubmitInfo +SemaphoreWaitInfoKHR :: SemaphoreWaitInfo +SemaphoreSignalInfoKHR :: SemaphoreSignalInfo +PhysicalDeviceVulkanMemoryModelFeaturesKHR :: PhysicalDeviceVulkanMemoryModelFeatures +PhysicalDeviceShaderTerminateInvocationFeaturesKHR :: PhysicalDeviceShaderTerminateInvocationFeatures +PhysicalDeviceSeparateDepthStencilLayoutsFeaturesKHR :: PhysicalDeviceSeparateDepthStencilLayoutsFeatures +AttachmentReferenceStencilLayoutKHR :: AttachmentReferenceStencilLayout +AttachmentDescriptionStencilLayoutKHR :: AttachmentDescriptionStencilLayout +PhysicalDeviceUniformBufferStandardLayoutFeaturesKHR :: PhysicalDeviceUniformBufferStandardLayoutFeatures +PhysicalDeviceBufferDeviceAddressFeaturesKHR :: PhysicalDeviceBufferDeviceAddressFeatures +BufferDeviceAddressInfoKHR :: BufferDeviceAddressInfo +BufferOpaqueCaptureAddressCreateInfoKHR :: BufferOpaqueCaptureAddressCreateInfo +MemoryOpaqueCaptureAddressAllocateInfoKHR :: MemoryOpaqueCaptureAddressAllocateInfo +DeviceMemoryOpaqueCaptureAddressInfoKHR :: DeviceMemoryOpaqueCaptureAddressInfo +PhysicalDeviceShaderIntegerDotProductFeaturesKHR :: PhysicalDeviceShaderIntegerDotProductFeatures +PhysicalDeviceShaderIntegerDotProductPropertiesKHR :: PhysicalDeviceShaderIntegerDotProductProperties +PipelineStageFlags2KHR :: PipelineStageFlags2 +PipelineStageFlag2KHR :: PipelineStageFlag2 +AccessFlags2KHR :: AccessFlags2 +AccessFlag2KHR :: AccessFlag2 +SubmitFlagKHR :: SubmitFlag +SubmitFlagsKHR :: SubmitFlags +MemoryBarrier2KHR :: MemoryBarrier2 +BufferMemoryBarrier2KHR :: BufferMemoryBarrier2 +ImageMemoryBarrier2KHR :: ImageMemoryBarrier2 +DependencyInfoKHR :: DependencyInfo +SubmitInfo2KHR :: SubmitInfo2 +SemaphoreSubmitInfoKHR :: SemaphoreSubmitInfo +CommandBufferSubmitInfoKHR :: CommandBufferSubmitInfo +PhysicalDeviceSynchronization2FeaturesKHR :: PhysicalDeviceSynchronization2Features +PhysicalDeviceZeroInitializeWorkgroupMemoryFeaturesKHR :: PhysicalDeviceZeroInitializeWorkgroupMemoryFeatures +CopyBufferInfo2KHR :: CopyBufferInfo2 +CopyImageInfo2KHR :: CopyImageInfo2 +CopyBufferToImageInfo2KHR :: CopyBufferToImageInfo2 +CopyImageToBufferInfo2KHR :: CopyImageToBufferInfo2 +BlitImageInfo2KHR :: BlitImageInfo2 +ResolveImageInfo2KHR :: ResolveImageInfo2 +BufferCopy2KHR :: BufferCopy2 +ImageCopy2KHR :: ImageCopy2 +ImageBlit2KHR :: ImageBlit2 +BufferImageCopy2KHR :: BufferImageCopy2 +ImageResolve2KHR :: ImageResolve2 +FormatFeatureFlags2KHR :: FormatFeatureFlags2 +FormatFeatureFlag2KHR :: FormatFeatureFlag2 +FormatProperties3KHR :: FormatProperties3 +PhysicalDeviceMaintenance4FeaturesKHR :: PhysicalDeviceMaintenance4Features +PhysicalDeviceMaintenance4PropertiesKHR :: PhysicalDeviceMaintenance4Properties +DeviceBufferMemoryRequirementsKHR :: DeviceBufferMemoryRequirements +DeviceImageMemoryRequirementsKHR :: DeviceImageMemoryRequirements +PhysicalDeviceTextureCompressionASTCHDRFeaturesEXT :: PhysicalDeviceTextureCompressionASTCHDRFeatures +SamplerReductionModeEXT :: SamplerReductionMode +SamplerReductionModeCreateInfoEXT :: SamplerReductionModeCreateInfo +PhysicalDeviceSamplerFilterMinmaxPropertiesEXT :: PhysicalDeviceSamplerFilterMinmaxProperties +PhysicalDeviceInlineUniformBlockFeaturesEXT :: PhysicalDeviceInlineUniformBlockFeatures +PhysicalDeviceInlineUniformBlockPropertiesEXT :: PhysicalDeviceInlineUniformBlockProperties +WriteDescriptorSetInlineUniformBlockEXT :: WriteDescriptorSetInlineUniformBlock +DescriptorPoolInlineUniformBlockCreateInfoEXT :: DescriptorPoolInlineUniformBlockCreateInfo +DescriptorBindingFlagEXT :: DescriptorBindingFlag +DescriptorBindingFlagsEXT :: DescriptorBindingFlags +DescriptorSetLayoutBindingFlagsCreateInfoEXT :: DescriptorSetLayoutBindingFlagsCreateInfo +PhysicalDeviceDescriptorIndexingFeaturesEXT :: PhysicalDeviceDescriptorIndexingFeatures +PhysicalDeviceDescriptorIndexingPropertiesEXT :: PhysicalDeviceDescriptorIndexingProperties +DescriptorSetVariableDescriptorCountAllocateInfoEXT :: DescriptorSetVariableDescriptorCountAllocateInfo +DescriptorSetVariableDescriptorCountLayoutSupportEXT :: DescriptorSetVariableDescriptorCountLayoutSupport +RayTracingShaderGroupTypeNV :: RayTracingShaderGroupTypeKHR +GeometryTypeNV :: GeometryTypeKHR +AccelerationStructureTypeNV :: AccelerationStructureTypeKHR +CopyAccelerationStructureModeNV :: CopyAccelerationStructureModeKHR +GeometryFlagsNV :: GeometryFlagsKHR +GeometryFlagNV :: GeometryFlagKHR +GeometryInstanceFlagsNV :: GeometryInstanceFlagsKHR +GeometryInstanceFlagNV :: GeometryInstanceFlagKHR +BuildAccelerationStructureFlagsNV :: BuildAccelerationStructureFlagsKHR +BuildAccelerationStructureFlagNV :: BuildAccelerationStructureFlagKHR +TransformMatrixNV :: TransformMatrixKHR +AabbPositionsNV :: AabbPositionsKHR +AccelerationStructureInstanceNV :: AccelerationStructureInstanceKHR +QueueGlobalPriorityEXT :: QueueGlobalPriorityKHR +DeviceQueueGlobalPriorityCreateInfoEXT :: DeviceQueueGlobalPriorityCreateInfoKHR +PipelineCreationFeedbackFlagEXT :: PipelineCreationFeedbackFlag +PipelineCreationFeedbackFlagsEXT :: PipelineCreationFeedbackFlags +PipelineCreationFeedbackCreateInfoEXT :: PipelineCreationFeedbackCreateInfo +PipelineCreationFeedbackEXT :: PipelineCreationFeedback +PhysicalDeviceFragmentShaderBarycentricFeaturesNV :: PhysicalDeviceFragmentShaderBarycentricFeaturesKHR +QueryPoolCreateInfoINTEL :: QueryPoolPerformanceQueryCreateInfoINTEL +PhysicalDeviceScalarBlockLayoutFeaturesEXT :: PhysicalDeviceScalarBlockLayoutFeatures +PhysicalDeviceSubgroupSizeControlFeaturesEXT :: PhysicalDeviceSubgroupSizeControlFeatures +PhysicalDeviceSubgroupSizeControlPropertiesEXT :: PhysicalDeviceSubgroupSizeControlProperties +PipelineShaderStageRequiredSubgroupSizeCreateInfoEXT :: PipelineShaderStageRequiredSubgroupSizeCreateInfo +PhysicalDeviceBufferAddressFeaturesEXT :: PhysicalDeviceBufferDeviceAddressFeaturesEXT +BufferDeviceAddressInfoEXT :: BufferDeviceAddressInfo +ToolPurposeFlagEXT :: ToolPurposeFlag +ToolPurposeFlagsEXT :: ToolPurposeFlags +PhysicalDeviceToolPropertiesEXT :: PhysicalDeviceToolProperties +ImageStencilUsageCreateInfoEXT :: ImageStencilUsageCreateInfo +PhysicalDeviceHostQueryResetFeaturesEXT :: PhysicalDeviceHostQueryResetFeatures +PhysicalDeviceShaderDemoteToHelperInvocationFeaturesEXT :: PhysicalDeviceShaderDemoteToHelperInvocationFeatures +PhysicalDeviceTexelBufferAlignmentPropertiesEXT :: PhysicalDeviceTexelBufferAlignmentProperties +PrivateDataSlotEXT :: PrivateDataSlot +PrivateDataSlotCreateFlagsEXT :: PrivateDataSlotCreateFlags +PhysicalDevicePrivateDataFeaturesEXT :: PhysicalDevicePrivateDataFeatures +DevicePrivateDataCreateInfoEXT :: DevicePrivateDataCreateInfo +PrivateDataSlotCreateInfoEXT :: PrivateDataSlotCreateInfo +PhysicalDevicePipelineCreationCacheControlFeaturesEXT :: PhysicalDevicePipelineCreationCacheControlFeatures +PhysicalDeviceImageRobustnessFeaturesEXT :: PhysicalDeviceImageRobustnessFeatures +PhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM :: PhysicalDeviceRasterizationOrderAttachmentAccessFeaturesEXT +PhysicalDeviceMutableDescriptorTypeFeaturesVALVE :: PhysicalDeviceMutableDescriptorTypeFeaturesEXT +MutableDescriptorTypeListVALVE :: MutableDescriptorTypeListEXT +MutableDescriptorTypeCreateInfoVALVE :: MutableDescriptorTypeCreateInfoEXT +PipelineInfoEXT :: PipelineInfoKHR +PhysicalDeviceGlobalPriorityQueryFeaturesEXT :: PhysicalDeviceGlobalPriorityQueryFeaturesKHR +QueueFamilyGlobalPriorityPropertiesEXT :: QueueFamilyGlobalPriorityPropertiesKHR +MemoryDecompressionMethodFlagNV :: Flags64 +MemoryDecompressionMethodFlagsNV :: Flags64 +ShaderRequiredSubgroupSizeCreateInfoEXT :: PipelineShaderStageRequiredSubgroupSizeCreateInfo + + diff --git a/vendor/wasm/WebGL/webgl.odin b/vendor/wasm/WebGL/webgl.odin index 04efc785b..7337e2a11 100644 --- a/vendor/wasm/WebGL/webgl.odin +++ b/vendor/wasm/WebGL/webgl.odin @@ -27,7 +27,7 @@ ContextAttributes :: distinct bit_set[ContextAttribute; u32] DEFAULT_CONTEXT_ATTRIBUTES :: ContextAttributes{} -@(default_calling_convention="c") +@(default_calling_convention="contextless") foreign webgl { // CreateCurrentContextById must be called before `GetCurrentContextAttributes` if the user wants to // set specific attributes, otherwise the default attributes will be set for the WebGL context @@ -50,7 +50,7 @@ foreign webgl { AttachShader :: proc(program: Program, shader: Shader) --- BindAttribLocation :: proc(program: Program, index: i32, name: string) --- BindBuffer :: proc(target: Enum, buffer: Buffer) --- - BindFramebuffer :: proc(target: Enum, buffer: Buffer) --- + BindFramebuffer :: proc(target: Enum, framebuffer: Framebuffer) --- BindTexture :: proc(target: Enum, texture: Texture) --- BlendColor :: proc(red, green, blue, alpha: f32) --- BlendEquation :: proc(mode: Enum) --- @@ -168,61 +168,59 @@ foreign webgl { Viewport :: proc(x, y, w, h: i32) --- } -Uniform1fv :: proc "c" (location: i32, v: f32) { Uniform1f(location, v) } -Uniform2fv :: proc "c" (location: i32, v: glm.vec2) { Uniform2f(location, v.x, v.y) } -Uniform3fv :: proc "c" (location: i32, v: glm.vec3) { Uniform3f(location, v.x, v.y, v.z) } -Uniform4fv :: proc "c" (location: i32, v: glm.vec4) { Uniform4f(location, v.x, v.y, v.z, v.w) } -Uniform1iv :: proc "c" (location: i32, v: i32) { Uniform1i(location, v) } -Uniform2iv :: proc "c" (location: i32, v: glm.ivec2) { Uniform2i(location, v.x, v.y) } -Uniform3iv :: proc "c" (location: i32, v: glm.ivec3) { Uniform3i(location, v.x, v.y, v.z) } -Uniform4iv :: proc "c" (location: i32, v: glm.ivec4) { Uniform4i(location, v.x, v.y, v.z, v.w) } +Uniform1fv :: proc "contextless" (location: i32, v: f32) { Uniform1f(location, v) } +Uniform2fv :: proc "contextless" (location: i32, v: glm.vec2) { Uniform2f(location, v.x, v.y) } +Uniform3fv :: proc "contextless" (location: i32, v: glm.vec3) { Uniform3f(location, v.x, v.y, v.z) } +Uniform4fv :: proc "contextless" (location: i32, v: glm.vec4) { Uniform4f(location, v.x, v.y, v.z, v.w) } +Uniform1iv :: proc "contextless" (location: i32, v: i32) { Uniform1i(location, v) } +Uniform2iv :: proc "contextless" (location: i32, v: glm.ivec2) { Uniform2i(location, v.x, v.y) } +Uniform3iv :: proc "contextless" (location: i32, v: glm.ivec3) { Uniform3i(location, v.x, v.y, v.z) } +Uniform4iv :: proc "contextless" (location: i32, v: glm.ivec4) { Uniform4i(location, v.x, v.y, v.z, v.w) } -VertexAttrib1fv :: proc "c" (index: i32, v: f32) { VertexAttrib1f(index, v) } -VertexAttrib2fv :: proc "c" (index: i32, v: glm.vec2){ VertexAttrib2f(index, v.x, v.y) } -VertexAttrib3fv :: proc "c" (index: i32, v: glm.vec3){ VertexAttrib3f(index, v.x, v.y, v.z) } -VertexAttrib4fv :: proc "c" (index: i32, v: glm.vec4){ VertexAttrib4f(index, v.x, v.y, v.z, v.w) } +VertexAttrib1fv :: proc "contextless" (index: i32, v: f32) { VertexAttrib1f(index, v) } +VertexAttrib2fv :: proc "contextless" (index: i32, v: glm.vec2){ VertexAttrib2f(index, v.x, v.y) } +VertexAttrib3fv :: proc "contextless" (index: i32, v: glm.vec3){ VertexAttrib3f(index, v.x, v.y, v.z) } +VertexAttrib4fv :: proc "contextless" (index: i32, v: glm.vec4){ VertexAttrib4f(index, v.x, v.y, v.z, v.w) } -UniformMatrix2fv :: proc "c" (location: i32, m: glm.mat2) { +UniformMatrix2fv :: proc "contextless" (location: i32, m: glm.mat2) { foreign webgl { @(link_name="UniformMatrix2fv") - _UniformMatrix2fv :: proc "c" (location: i32, value: [^]f32) --- + _UniformMatrix2fv :: proc "contextless" (location: i32, value: [^]f32) --- } value := transmute([2*2]f32)m _UniformMatrix2fv(location, &value[0]) } -UniformMatrix3fv :: proc "c" (location: i32, m: glm.mat3) { +UniformMatrix3fv :: proc "contextless" (location: i32, m: glm.mat3) { foreign webgl { @(link_name="UniformMatrix3fv") - _UniformMatrix3fv :: proc "c" (location: i32, value: [^]f32) --- + _UniformMatrix3fv :: proc "contextless" (location: i32, value: [^]f32) --- } value := transmute([3*3]f32)m _UniformMatrix3fv(location, &value[0]) } -UniformMatrix4fv :: proc "c" (location: i32, m: glm.mat4) { +UniformMatrix4fv :: proc "contextless" (location: i32, m: glm.mat4) { foreign webgl { @(link_name="UniformMatrix4fv") - _UniformMatrix4fv :: proc "c" (location: i32, value: [^]f32) --- + _UniformMatrix4fv :: proc "contextless" (location: i32, value: [^]f32) --- } value := transmute([4*4]f32)m _UniformMatrix4fv(location, &value[0]) } -GetShaderiv :: proc "c" (shader: Shader, pname: Enum) -> (p: i32) { - @(default_calling_convention="c") +GetShaderiv :: proc "contextless" (shader: Shader, pname: Enum) -> (p: i32) { foreign webgl { @(link_name="GetShaderiv") - _GetShaderiv :: proc "c" (shader: Shader, pname: Enum, p: ^i32) --- + _GetShaderiv :: proc "contextless" (shader: Shader, pname: Enum, p: ^i32) --- } _GetShaderiv(shader, pname, &p) return } -GetProgramInfoLog :: proc "c" (program: Program, buf: []byte) -> string { - @(default_calling_convention="c") +GetProgramInfoLog :: proc "contextless" (program: Program, buf: []byte) -> string { foreign webgl { @(link_name="GetProgramInfoLog") - _GetProgramInfoLog :: proc "c" (program: Program, buf: []byte, length: ^int) --- + _GetProgramInfoLog :: proc "contextless" (program: Program, buf: []byte, length: ^int) --- } length: int @@ -230,11 +228,10 @@ GetProgramInfoLog :: proc "c" (program: Program, buf: []byte) -> string { return string(buf[:length]) } -GetShaderInfoLog :: proc "c" (shader: Shader, buf: []byte) -> string { - @(default_calling_convention="c") +GetShaderInfoLog :: proc "contextless" (shader: Shader, buf: []byte) -> string { foreign webgl { @(link_name="GetShaderInfoLog") - _GetShaderInfoLog :: proc "c" (shader: Shader, buf: []byte, length: ^int) --- + _GetShaderInfoLog :: proc "contextless" (shader: Shader, buf: []byte, length: ^int) --- } length: int @@ -244,27 +241,27 @@ GetShaderInfoLog :: proc "c" (shader: Shader, buf: []byte) -> string { -BufferDataSlice :: proc "c" (target: Enum, slice: $S/[]$E, usage: Enum) { +BufferDataSlice :: proc "contextless" (target: Enum, slice: $S/[]$E, usage: Enum) { BufferData(target, len(slice)*size_of(E), raw_data(slice), usage) } -BufferSubDataSlice :: proc "c" (target: Enum, offset: uintptr, slice: $S/[]$E) { +BufferSubDataSlice :: proc "contextless" (target: Enum, offset: uintptr, slice: $S/[]$E) { BufferSubData(target, offset, len(slice)*size_of(E), raw_data(slice), usage) } -CompressedTexImage2DSlice :: proc "c" (target: Enum, level: i32, internalformat: Enum, width, height: i32, border: i32, slice: $S/[]$E) { +CompressedTexImage2DSlice :: proc "contextless" (target: Enum, level: i32, internalformat: Enum, width, height: i32, border: i32, slice: $S/[]$E) { CompressedTexImage2DSlice(target, level, internalformat, width, height, border, len(slice)*size_of(E), raw_data(slice)) } -CompressedTexSubImage2DSlice :: proc "c" (target: Enum, level: i32, xoffset, yoffset, width, height: i32, format: Enum, slice: $S/[]$E) { +CompressedTexSubImage2DSlice :: proc "contextless" (target: Enum, level: i32, xoffset, yoffset, width, height: i32, format: Enum, slice: $S/[]$E) { CompressedTexSubImage2DSlice(target, level, level, xoffset, yoffset, width, height, format, len(slice)*size_of(E), raw_data(slice)) } -ReadPixelsSlice :: proc "c" (x, y, width, height: i32, format: Enum, type: Enum, slice: $S/[]$E) { +ReadPixelsSlice :: proc "contextless" (x, y, width, height: i32, format: Enum, type: Enum, slice: $S/[]$E) { ReadnPixels(x, y, width, height, format, type, len(slice)*size_of(E), raw_data(slice)) } -TexImage2DSlice :: proc "c" (target: Enum, level: i32, internalformat: Enum, width, height: i32, border: i32, format, type: Enum, slice: $S/[]$E) { +TexImage2DSlice :: proc "contextless" (target: Enum, level: i32, internalformat: Enum, width, height: i32, border: i32, format, type: Enum, slice: $S/[]$E) { TexImage2D(target, level, internalformat, width, height, border, format, type, len(slice)*size_of(E), raw_data(slice)) } -TexSubImage2DSlice :: proc "c" (target: Enum, level: i32, xoffset, yoffset, width, height: i32, format, type: Enum, slice: $S/[]$E) { +TexSubImage2DSlice :: proc "contextless" (target: Enum, level: i32, xoffset, yoffset, width, height: i32, format, type: Enum, slice: $S/[]$E) { TexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, len(slice)*size_of(E), raw_data(slice)) } \ No newline at end of file diff --git a/vendor/wasm/WebGL/webgl2.odin b/vendor/wasm/WebGL/webgl2.odin index a1d55b703..d360bc396 100644 --- a/vendor/wasm/WebGL/webgl2.odin +++ b/vendor/wasm/WebGL/webgl2.odin @@ -10,13 +10,13 @@ Sync :: distinct u32 TransformFeedback :: distinct u32 VertexArrayObject :: distinct u32 -IsWebGL2Supported :: proc "c" () -> bool { +IsWebGL2Supported :: proc "contextless" () -> bool { major, minor: i32 GetWebGLVersion(&major, &minor) return major >= 2 } -@(default_calling_convention="c") +@(default_calling_convention="contextless") foreign webgl2 { /* Buffer objects */ CopyBufferSubData :: proc(readTarget, writeTarget: Enum, readOffset, writeOffset: int, size: int) --- @@ -110,7 +110,7 @@ foreign webgl2 { GetActiveUniformBlockName :: proc(program: Program, uniformBlockIndex: i32, buf: []byte) -> string { foreign webgl2 { - _GetActiveUniformBlockName :: proc(program: Program, uniformBlockIndex: i32, buf: []byte, length: ^int) --- + _GetActiveUniformBlockName :: proc "contextless" (program: Program, uniformBlockIndex: i32, buf: []byte, length: ^int) --- } n: int _GetActiveUniformBlockName(program, uniformBlockIndex, buf, &n) @@ -118,65 +118,65 @@ GetActiveUniformBlockName :: proc(program: Program, uniformBlockIndex: i32, buf: } -Uniform1uiv :: proc "c" (location: i32, v: u32) { +Uniform1uiv :: proc "contextless" (location: i32, v: u32) { Uniform1ui(location, v) } -Uniform2uiv :: proc "c" (location: i32, v: glm.uvec2) { +Uniform2uiv :: proc "contextless" (location: i32, v: glm.uvec2) { Uniform2ui(location, v.x, v.y) } -Uniform3uiv :: proc "c" (location: i32, v: glm.uvec3) { +Uniform3uiv :: proc "contextless" (location: i32, v: glm.uvec3) { Uniform3ui(location, v.x, v.y, v.z) } -Uniform4uiv :: proc "c" (location: i32, v: glm.uvec4) { +Uniform4uiv :: proc "contextless" (location: i32, v: glm.uvec4) { Uniform4ui(location, v.x, v.y, v.z, v.w) } -UniformMatrix3x2fv :: proc "c" (location: i32, m: glm.mat3x2) { +UniformMatrix3x2fv :: proc "contextless" (location: i32, m: glm.mat3x2) { foreign webgl2 { - _UniformMatrix3x2fv :: proc "c" (location: i32, addr: [^]f32) --- + _UniformMatrix3x2fv :: proc "contextless" (location: i32, addr: [^]f32) --- } array := matrix_flatten(m) _UniformMatrix3x2fv(location, &array[0]) } -UniformMatrix4x2fv :: proc "c" (location: i32, m: glm.mat4x2) { +UniformMatrix4x2fv :: proc "contextless" (location: i32, m: glm.mat4x2) { foreign webgl2 { - _UniformMatrix4x2fv :: proc "c" (location: i32, addr: [^]f32) --- + _UniformMatrix4x2fv :: proc "contextless" (location: i32, addr: [^]f32) --- } array := matrix_flatten(m) _UniformMatrix4x2fv(location, &array[0]) } -UniformMatrix2x3fv :: proc "c" (location: i32, m: glm.mat2x3) { +UniformMatrix2x3fv :: proc "contextless" (location: i32, m: glm.mat2x3) { foreign webgl2 { - _UniformMatrix2x3fv :: proc "c" (location: i32, addr: [^]f32) --- + _UniformMatrix2x3fv :: proc "contextless" (location: i32, addr: [^]f32) --- } array := matrix_flatten(m) _UniformMatrix2x3fv(location, &array[0]) } -UniformMatrix4x3fv :: proc "c" (location: i32, m: glm.mat4x3) { +UniformMatrix4x3fv :: proc "contextless" (location: i32, m: glm.mat4x3) { foreign webgl2 { - _UniformMatrix4x3fv :: proc "c" (location: i32, addr: [^]f32) --- + _UniformMatrix4x3fv :: proc "contextless" (location: i32, addr: [^]f32) --- } array := matrix_flatten(m) _UniformMatrix4x3fv(location, &array[0]) } -UniformMatrix2x4fv :: proc "c" (location: i32, m: glm.mat2x4) { +UniformMatrix2x4fv :: proc "contextless" (location: i32, m: glm.mat2x4) { foreign webgl2 { - _UniformMatrix2x4fv :: proc "c" (location: i32, addr: [^]f32) --- + _UniformMatrix2x4fv :: proc "contextless" (location: i32, addr: [^]f32) --- } array := matrix_flatten(m) _UniformMatrix2x4fv(location, &array[0]) } -UniformMatrix3x4fv :: proc "c" (location: i32, m: glm.mat3x4) { +UniformMatrix3x4fv :: proc "contextless" (location: i32, m: glm.mat3x4) { foreign webgl2 { - _UniformMatrix3x4fv :: proc "c" (location: i32, addr: [^]f32) --- + _UniformMatrix3x4fv :: proc "contextless" (location: i32, addr: [^]f32) --- } array := matrix_flatten(m) _UniformMatrix3x4fv(location, &array[0]) } -VertexAttribI4iv :: proc "c" (index: i32, v: glm.ivec4) { +VertexAttribI4iv :: proc "contextless" (index: i32, v: glm.ivec4) { VertexAttribI4i(index, v.x, v.y, v.z, v.w) } -VertexAttribI4uiv :: proc "c" (index: i32, v: glm.uvec4) { +VertexAttribI4uiv :: proc "contextless" (index: i32, v: glm.uvec4) { VertexAttribI4ui(index, v.x, v.y, v.z, v.w) } diff --git a/vendor/wasm/js/dom.odin b/vendor/wasm/js/dom.odin index d650dd70a..2662c4201 100644 --- a/vendor/wasm/js/dom.odin +++ b/vendor/wasm/js/dom.odin @@ -1,4 +1,4 @@ -//+build js wasm32, js wasm64 +//+build js wasm32, js wasm64p32 package wasm_js_interface foreign import dom_lib "odin_dom" diff --git a/vendor/wasm/js/dom_all_targets.odin b/vendor/wasm/js/dom_all_targets.odin new file mode 100644 index 000000000..7b3ad1a64 --- /dev/null +++ b/vendor/wasm/js/dom_all_targets.odin @@ -0,0 +1,36 @@ +//+build !js +package wasm_js_interface + +import "core:runtime" + + +get_element_value_string :: proc "contextless" (id: string, buf: []byte) -> string { + context = runtime.default_context() + panic("vendor:wasm/js not supported on non JS targets") +} + + +get_element_min_max :: proc "contextless" (id: string) -> (min, max: f64) { + context = runtime.default_context() + panic("vendor:wasm/js not supported on non JS targets") +} + + +Rect :: struct { + x, y, width, height: f64, +} + +get_bounding_client_rect :: proc "contextless" (id: string) -> (rect: Rect) { + context = runtime.default_context() + panic("vendor:wasm/js not supported on non JS targets") +} + +window_get_rect :: proc "contextless" () -> (rect: Rect) { + context = runtime.default_context() + panic("vendor:wasm/js not supported on non JS targets") +} + +window_get_scroll :: proc "contextless" () -> (x, y: f64) { + context = runtime.default_context() + panic("vendor:wasm/js not supported on non JS targets") +} diff --git a/vendor/wasm/js/events.odin b/vendor/wasm/js/events.odin index 136c0610d..f14d7054e 100644 --- a/vendor/wasm/js/events.odin +++ b/vendor/wasm/js/events.odin @@ -1,4 +1,4 @@ -//+build js wasm32, js wasm64 +//+build js wasm32, js wasm64p32 package wasm_js_interface foreign import dom_lib "odin_dom" diff --git a/vendor/wasm/js/events_all_targets.odin b/vendor/wasm/js/events_all_targets.odin new file mode 100644 index 000000000..2bc7e8ceb --- /dev/null +++ b/vendor/wasm/js/events_all_targets.odin @@ -0,0 +1,288 @@ +//+build !js +package wasm_js_interface + + +Event_Kind :: enum u32 { + Invalid, + + Load, + Unload, + Error, + Resize, + Visibility_Change, + Fullscreen_Change, + Fullscreen_Error, + + Click, + Double_Click, + Mouse_Move, + Mouse_Over, + Mouse_Out, + Mouse_Up, + Mouse_Down, + + Key_Up, + Key_Down, + Key_Press, + + Scroll, + Wheel, + + Focus, + Submit, + Blur, + Change, + Select, + + Animation_Start, + Animation_End, + Animation_Iteration, + Animation_Cancel, + + Copy, + Cut, + Paste, + + // Drag, + // Drag_Start, + // Drag_End, + // Drag_Enter, + // Drag_Leave, + // Drag_Over, + // Drop, + + Pointer_Cancel, + Pointer_Down, + Pointer_Enter, + Pointer_Leave, + Pointer_Move, + Pointer_Over, + Pointer_Up, + Got_Pointer_Capture, + Lost_Pointer_Capture, + Pointer_Lock_Change, + Pointer_Lock_Error, + + Selection_Change, + Selection_Start, + + Touch_Cancel, + Touch_End, + Touch_Move, + Touch_Start, + + Transition_Start, + Transition_End, + Transition_Run, + Transition_Cancel, + + Context_Menu, + + Custom, + +} +event_kind_string := [Event_Kind]string{ + .Invalid = "", + + .Load = "load", + .Unload = "unload", + .Error = "error", + .Resize = "resize", + .Visibility_Change = "visibilitychange", + .Fullscreen_Change = "fullscreenchange", + .Fullscreen_Error = "fullscreenerror", + + .Click = "click", + .Double_Click = "dblclick", + .Mouse_Move = "mousemove", + .Mouse_Over = "mouseover", + .Mouse_Out = "mouseout", + .Mouse_Up = "mouseup", + .Mouse_Down = "mousedown", + + .Key_Up = "keyup", + .Key_Down = "keydown", + .Key_Press = "keypress", + + .Scroll = "scroll", + .Wheel = "wheel", + + .Focus = "focus", + .Submit = "submit", + .Blur = "blur", + .Change = "change", + .Select = "select", + + .Animation_Start = "animationstart", + .Animation_End = "animationend", + .Animation_Iteration = "animationiteration", + .Animation_Cancel = "animationcancel", + + .Copy = "copy", + .Cut = "cut", + .Paste = "paste", + + // .Drag, = "drag", + // .Drag_Start, = "dragstart", + // .Drag_End, = "dragend", + // .Drag_Enter, = "dragenter", + // .Drag_Leave, = "dragleave", + // .Drag_Over, = "dragover", + // .Drop, = "drop", + + .Pointer_Cancel = "pointercancel", + .Pointer_Down = "pointerdown", + .Pointer_Enter = "pointerenter", + .Pointer_Leave = "pointerleave", + .Pointer_Move = "pointermove", + .Pointer_Over = "pointerover", + .Pointer_Up = "pointerup", + .Got_Pointer_Capture = "gotpointercapture", + .Lost_Pointer_Capture = "lostpointercapture", + .Pointer_Lock_Change = "pointerlockchange", + .Pointer_Lock_Error = "pointerlockerror", + + .Selection_Change = "selectionchange", + .Selection_Start = "selectionstart", + + .Transition_Start = "transitionstart", + .Transition_End = "transitionend", + .Transition_Run = "transitionrun", + .Transition_Cancel = "transitioncancel", + + .Touch_Cancel = "touchcancel", + .Touch_End = "touchend", + .Touch_Move = "touchmove", + .Touch_Start = "touchstart", + + .Context_Menu = "contextmenu", + + .Custom = "?custom?", +} + +Delta_Mode :: enum u32 { + Pixel = 0, + Line = 1, + Page = 2, +} + +Key_Location :: enum u8 { + Standard = 0, + Left = 1, + Right = 2, + Numpad = 3, +} + +KEYBOARD_MAX_KEY_SIZE :: 16 +KEYBOARD_MAX_CODE_SIZE :: 16 + +Event_Target_Kind :: enum u32 { + Element = 0, + Document = 1, + Window = 2, +} + +Event_Phase :: enum u8 { + None = 0, + Capturing_Phase = 1, + At_Target = 2, + Bubbling_Phase = 3, +} + +Event_Option :: enum u8 { + Bubbles = 0, + Cancelable = 1, + Composed = 2, +} +Event_Options :: distinct bit_set[Event_Option; u8] + +Event :: struct { + kind: Event_Kind, + target_kind: Event_Target_Kind, + current_target_kind: Event_Target_Kind, + id: string, + timestamp: f64, + + phase: Event_Phase, + options: Event_Options, + is_composing: bool, + is_trusted: bool, + + using data: struct #raw_union #align 8 { + scroll: struct { + delta: [2]f64, + }, + visibility_change: struct { + is_visible: bool, + }, + wheel: struct { + delta: [3]f64, + delta_mode: Delta_Mode, + }, + + key: struct { + key: string, + code: string, + location: Key_Location, + + ctrl: bool, + shift: bool, + alt: bool, + meta: bool, + + repeat: bool, + + _key_buf: [KEYBOARD_MAX_KEY_SIZE]byte, + _code_buf: [KEYBOARD_MAX_KEY_SIZE]byte, + }, + + mouse: struct { + screen: [2]i64, + client: [2]i64, + offset: [2]i64, + page: [2]i64, + movement: [2]i64, + + ctrl: bool, + shift: bool, + alt: bool, + meta: bool, + + button: i16, + buttons: bit_set[0..<16; u16], + }, + }, + + + user_data: rawptr, + callback: proc(e: Event), +} + + +add_event_listener :: proc(id: string, kind: Event_Kind, user_data: rawptr, callback: proc(e: Event), use_capture := false) -> bool { + panic("vendor:wasm/js not supported on non JS targets") +} + +remove_event_listener :: proc(id: string, kind: Event_Kind, user_data: rawptr, callback: proc(e: Event)) -> bool { + panic("vendor:wasm/js not supported on non JS targets") +} + +add_window_event_listener :: proc(kind: Event_Kind, user_data: rawptr, callback: proc(e: Event), use_capture := false) -> bool { + panic("vendor:wasm/js not supported on non JS targets") +} + +remove_window_event_listener :: proc(kind: Event_Kind, user_data: rawptr, callback: proc(e: Event)) -> bool { + panic("vendor:wasm/js not supported on non JS targets") +} + +remove_event_listener_from_event :: proc(e: Event) -> bool { + panic("vendor:wasm/js not supported on non JS targets") +} + +add_custom_event_listener :: proc(id: string, name: string, user_data: rawptr, callback: proc(e: Event), use_capture := false) -> bool { + panic("vendor:wasm/js not supported on non JS targets") +} +remove_custom_event_listener :: proc(id: string, name: string, user_data: rawptr, callback: proc(e: Event)) -> bool { + panic("vendor:wasm/js not supported on non JS targets") +} + diff --git a/vendor/wasm/js/general.odin b/vendor/wasm/js/general.odin index 0f6a9589c..513c60a6f 100644 --- a/vendor/wasm/js/general.odin +++ b/vendor/wasm/js/general.odin @@ -1,4 +1,4 @@ -//+build js wasm32, js wasm64 +//+build js wasm32, js wasm64p32 package wasm_js_interface foreign import "odin_env" diff --git a/vendor/wasm/js/memory_all_targets.odin b/vendor/wasm/js/memory_all_targets.odin new file mode 100644 index 000000000..e1de6a696 --- /dev/null +++ b/vendor/wasm/js/memory_all_targets.odin @@ -0,0 +1,14 @@ +//+build !js +package wasm_js_interface + +import "core:mem" + +PAGE_SIZE :: 64 * 1024 +page_alloc :: proc(page_count: int) -> (data: []byte, err: mem.Allocator_Error) { + panic("vendor:wasm/js not supported on non-js targets") +} + +page_allocator :: proc() -> mem.Allocator { + panic("vendor:wasm/js not supported on non-js targets") +} + diff --git a/vendor/wasm/js/memory.odin b/vendor/wasm/js/memory_js.odin similarity index 97% rename from vendor/wasm/js/memory.odin rename to vendor/wasm/js/memory_js.odin index efbf89445..cdeb58128 100644 --- a/vendor/wasm/js/memory.odin +++ b/vendor/wasm/js/memory_js.odin @@ -1,4 +1,4 @@ -//+build js wasm32, js wasm64 +//+build js wasm32, js wasm64p32 package wasm_js_interface import "core:mem" diff --git a/vendor/wasm/js/runtime.js b/vendor/wasm/js/runtime.js index 7f0ede146..bcc7e2051 100644 --- a/vendor/wasm/js/runtime.js +++ b/vendor/wasm/js/runtime.js @@ -313,8 +313,8 @@ class WebGLInterface { this.ctx.bindBuffer(target, bufferObj) } }, - BindFramebuffer: (target, buffer) => { - // TODO: BindFramebuffer + BindFramebuffer: (target, framebuffer) => { + this.ctx.bindFramebuffer(target, framebuffer ? this.framebuffers[framebuffer] : null) }, BindTexture: (target, texture) => { this.ctx.bindTexture(target, texture ? this.textures[texture] : null) diff --git a/vendor/zlib/zlib.odin b/vendor/zlib/zlib.odin index 8a046a401..021449813 100644 --- a/vendor/zlib/zlib.odin +++ b/vendor/zlib/zlib.odin @@ -2,8 +2,13 @@ package vendor_zlib import "core:c" -when ODIN_OS == .Windows { foreign import zlib "libz.lib" } -when ODIN_OS == .Linux { foreign import zlib "system:z" } +when ODIN_OS == .Windows { + foreign import zlib "libz.lib" +} else when ODIN_OS == .Linux { + foreign import zlib "system:z" +} else { + foreign import zlib "system:z" +} VERSION :: "1.2.12" VERNUM :: 0x12c0 @@ -41,39 +46,39 @@ gzFile_s :: struct { gzFile :: ^gzFile_s z_stream_s :: struct { - next_in: ^Bytef, - avail_in: uInt, - total_in: uLong, - next_out: ^Bytef, - avail_out: uInt, - total_out: uLong, - msg: [^]c.char, - state: rawptr, - zalloc: alloc_func, - zfree: free_func, - opaque: voidpf, - data_type: c.int, - adler: uLong, - reserved: uLong, + next_in: ^Bytef, + avail_in: uInt, + total_in: uLong, + next_out: ^Bytef, + avail_out: uInt, + total_out: uLong, + msg: [^]c.char, + state: rawptr, + zalloc: alloc_func, + zfree: free_func, + opaque: voidpf, + data_type: c.int, + adler: uLong, + reserved: uLong, } z_stream :: z_stream_s z_streamp :: ^z_stream gz_header_s :: struct { - text: c.int, - time: uLong, - xflags: c.int, - os: c.int, - extra: [^]Bytef, - extra_len: uInt, - extra_max: uInt, - name: [^]Bytef, - name_max: uInt, - comment: [^]Bytef, - comm_max: uInt, - hcrc: c.int, - done: c.int, + text: c.int, + time: uLong, + xflags: c.int, + os: c.int, + extra: [^]Bytef, + extra_len: uInt, + extra_max: uInt, + name: [^]Bytef, + name_max: uInt, + comment: [^]Bytef, + comm_max: uInt, + hcrc: c.int, + done: c.int, } gz_header :: gz_header_s