├── .gitattributes
├── .github
├── dependabot.yml
└── workflows
│ ├── bindgen.yml
│ ├── build.yml
│ ├── commit.yml
│ ├── pull-request.yml
│ └── release.yml
├── .gitignore
├── .gitmodules
├── Header.png
├── LICENSE
├── README.md
├── bindgen
├── appsettings.json
├── config-build-c-library.json
├── config-extract-linux.json
├── config-extract-macos.json
├── config-extract-windows.json
├── config-generate-cs.json
├── extract.sh
├── generate.sh
└── merge.sh
├── library.sh
├── licenses.txt
└── src
├── c
└── production
│ └── Tracy
│ └── _Tracy.h
└── cs
├── Directory.Build.props
├── Directory.Build.targets
├── Tracy.sln
├── production
├── Directory.Build.props
├── Directory.Build.targets
└── Tracy
│ ├── Generated
│ ├── AssemblyAttributes.gen.cs
│ ├── PInvoke.gen.cs
│ └── Runtime.gen.cs
│ ├── Tracy.csproj
│ └── _README_PACKAGE.md
└── samples
├── Directory.Build.props
├── Directory.Build.targets
└── HelloWorld
├── HelloWorld.csproj
├── Profiler.cs
└── Program.cs
/.gitattributes:
--------------------------------------------------------------------------------
1 | #
2 | # Configure line ending normalisation for this repository.
3 | # See http://schacon.github.io/git/gitattributes.html for more information.
4 | #
5 | # Also each developer should configure the old style normalisation on her workstation
6 | # (see http://timclem.wordpress.com/2012/03/01/mind-the-end-of-your-line/):
7 | #
8 | # Windows user should use: git config --global core.autocrlf = true
9 | # Unix/Linux users should use: git config --global core.autocrlf = input
10 | #
11 |
12 | # Auto detect text files and perform LF normalization
13 | * text=auto
14 |
15 | *.md text
16 | *.cs text diff=cs
17 | *.sln text merge=union
18 | *.csproj text merge=union
19 | *.xml text diff=xml
20 | # Shell scripts require LF
21 | *.sh text eol=lf
22 | # Batch scripts require CRLF
23 | *.bat text eol=crlf
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: "gitsubmodule"
4 | directory: "/"
5 | schedule:
6 | interval: "daily"
7 | time: "00:15" # 8:15pm EDT
--------------------------------------------------------------------------------
/.github/workflows/bindgen.yml:
--------------------------------------------------------------------------------
1 | name: "Bindgen"
2 |
3 | on:
4 | workflow_call:
5 |
6 | jobs:
7 | bindgen-ast-job:
8 | name: "Bindgen AST"
9 | runs-on: ${{ matrix.platform.os }}
10 | strategy:
11 | fail-fast: false
12 | matrix:
13 | platform:
14 | - { name: Windows, os: windows-2022, rid: win }
15 | # - { name: macOS, os: macos-11, rid: osx }
16 | - { name: Linux, os: ubuntu-20.04, rid: linux }
17 |
18 | steps:
19 | - name: "Clone Git repository"
20 | uses: actions/checkout@v4
21 | with:
22 | submodules: "true"
23 |
24 | - name: "Install CAstFfi"
25 | shell: bash
26 | run: dotnet tool install --global bottlenoselabs.CAstFfi.Tool
27 |
28 | - name: "Read C code: Linux dependencies"
29 | if: runner.os == 'Linux'
30 | run: sudo apt-get install gcc-aarch64-linux-gnu
31 |
32 | - name: "Read C code: extract ${{ matrix.platform.rid }}"
33 | shell: bash
34 | run: cd ./bindgen && ./extract.sh
35 |
36 | - name: "Upload C code platform abstract syntax trees"
37 | uses: actions/upload-artifact@v4
38 | with:
39 | name: "ast-${{ matrix.platform.rid }}"
40 | path: "./bindgen/ast"
41 |
42 | bindgen-cross-platform-ast-job:
43 | name: "Bindgen AST cross-platform"
44 | needs: [bindgen-ast-job]
45 | runs-on: ubuntu-20.04
46 |
47 | steps:
48 | - name: "Clone Git repository"
49 | uses: actions/checkout@v4
50 | with:
51 | submodules: "false"
52 |
53 | - name: "Download C code platform abstract syntax trees (win)"
54 | uses: actions/download-artifact@v4
55 | with:
56 | name: "ast-win"
57 | path: "./bindgen/ast"
58 |
59 | # - name: "Download C code platform abstract syntax trees (osx)"
60 | # uses: actions/download-artifact@v4
61 | # with:
62 | # name: "ast-osx"
63 | # path: "./bindgen/ast"
64 |
65 | - name: "Download C code platform abstract syntax trees (linux)"
66 | uses: actions/download-artifact@v4
67 | with:
68 | name: "ast-linux"
69 | path: "./bindgen/ast"
70 |
71 | - name: "Install CAstFfi"
72 | shell: bash
73 | run: dotnet tool install --global bottlenoselabs.CAstFfi.Tool
74 |
75 | - name: "Generate cross-platform AST"
76 | shell: bash
77 | run: cd ./bindgen && ./merge.sh
78 |
79 | - name: "Upload cross-platform AST"
80 | uses: actions/upload-artifact@v4
81 | with:
82 | name: "ast-cross-platform"
83 | path: "./bindgen/x-ast/ast-cross-platform.json"
84 |
85 | bindgen-cs-job:
86 | name: "Bindgen C#"
87 | needs: [bindgen-cross-platform-ast-job]
88 | runs-on: ubuntu-20.04
89 |
90 | steps:
91 | - name: "Clone Git repository"
92 | uses: actions/checkout@v4
93 | with:
94 | submodules: "false"
95 |
96 | - name: "Download C code cross-platform abstract syntax tree"
97 | uses: actions/download-artifact@v4
98 | with:
99 | name: "ast-cross-platform"
100 | path: "./bindgen/x-ast"
101 |
102 | - name: "Install C2CS"
103 | shell: bash
104 | run: dotnet tool install --global bottlenoselabs.C2CS.Tool
105 |
106 | - name: "Generate C# code"
107 | shell: bash
108 | run: cd ./bindgen && ./generate.sh
109 |
110 | - name: "Upload generated C# code"
111 | uses: actions/upload-artifact@v4
112 | with:
113 | name: "bindgen-cs"
114 | path: "./src/cs/production/Tracy/Generated"
115 |
--------------------------------------------------------------------------------
/.github/workflows/build.yml:
--------------------------------------------------------------------------------
1 | name: "Build"
2 |
3 | on:
4 | workflow_dispatch:
5 | workflow_call:
6 | push:
7 | tags:
8 | - v*
9 | branches:
10 | - main
11 | paths-ignore:
12 | - "**.md"
13 |
14 | jobs:
15 | native-job:
16 | name: "Build native libraries: ${{ matrix.platform.rid }}"
17 | runs-on: ${{ matrix.platform.os }}
18 | strategy:
19 | fail-fast: false
20 | matrix:
21 | platform:
22 | - { name: Windows (x64), os: windows-2022, rid: win-x64 }
23 | # - { name: macOS (x64 + arm64), os: macos-11, rid: osx }
24 | - { name: Linux (x64), os: ubuntu-20.04, rid: linux-x64 }
25 | steps:
26 | - name: "Clone Git repository"
27 | uses: actions/checkout@v4
28 | with:
29 | submodules: "recursive"
30 |
31 | - name: "Install C2CS"
32 | shell: bash
33 | run: dotnet tool install --global bottlenoselabs.C2CS.Tool
34 |
35 | - name: "Get C2CS version"
36 | shell: bash
37 | run: echo "C2CS_VERSION=$(c2cs --version)" >> $GITHUB_ENV
38 |
39 | - name: "Cache native libraries"
40 | id: cache-libs
41 | uses: actions/cache@v3
42 | with:
43 | path: "./lib"
44 | key: "libs-${{ matrix.platform.rid }}-${{ hashFiles('ext/Tracy/**/*') }}-${{ hashFiles('src/c/**/*') }}-${{ hashFiles('bindgen/**/*') }}-${{ env.C2CS_VERSION }}"
45 |
46 | - name: "Build native libraries"
47 | if: steps.cache-libs.outputs.cache-hit != 'true'
48 | shell: bash
49 | run: ./library.sh "auto"
50 |
51 | - name: "Upload native libraries"
52 | uses: actions/upload-artifact@v4
53 | with:
54 | path: "./lib"
55 | name: "native-libraries-${{ matrix.platform.rid }}"
56 |
57 | dotnet-job:
58 | name: "Build .NET solution"
59 | needs: [native-job]
60 | runs-on: ubuntu-20.04
61 | steps:
62 | - name: "Clone Git repository"
63 | uses: actions/checkout@v4
64 | with:
65 | submodules: "true"
66 |
67 | - name: "Download native libraries (win-x64)"
68 | uses: actions/download-artifact@v4
69 | with:
70 | name: "native-libraries-win-x64"
71 | path: "./lib"
72 |
73 | # - name: "Download native libraries (osx)"
74 | # uses: actions/download-artifact@v4
75 | # with:
76 | # name: "native-libraries-osx"
77 | # path: "./lib"
78 |
79 | - name: "Download native libraries (linux-x64)"
80 | uses: actions/download-artifact@v4
81 | with:
82 | name: "native-libraries-linux-x64"
83 | path: "./lib"
84 |
85 | - name: "Download generated C# code"
86 | uses: actions/download-artifact@v4
87 | continue-on-error: true
88 | with:
89 | name: "bindgen-cs"
90 | path: "./src/cs/production/Tracy/Generated"
91 |
92 | - name: ".NET Build"
93 | run: dotnet build "./src/cs" --nologo --verbosity minimal --configuration Release -p:PackageVersion="$(date +'%Y.%m.%d')"
94 |
--------------------------------------------------------------------------------
/.github/workflows/commit.yml:
--------------------------------------------------------------------------------
1 | name: "Commit generated C# code"
2 |
3 | on:
4 | workflow_call:
5 |
6 | permissions: write-all
7 |
8 | jobs:
9 | commit-job:
10 | name: "Commit generated C# code"
11 | runs-on: ubuntu-20.04
12 | if: github.actor == 'dependabot[bot]'
13 |
14 | steps:
15 | - name: "Clone Git repository"
16 | uses: actions/checkout@v4
17 | with:
18 | submodules: "true"
19 |
20 | - name: "Download changes to commit"
21 | uses: actions/download-artifact@v4
22 | with:
23 | name: "bindgen-cs"
24 | path: "./src/cs/production/Tracy/Generated"
25 |
26 | - name: "Add + commit + push (if necessary)"
27 | uses: EndBug/add-and-commit@v7
28 | with:
29 | author_name: "Synthetic-Dev"
30 | author_email: "Synthetic-Dev@users.noreply.github.com"
31 | message: "Update C# bindings"
32 |
--------------------------------------------------------------------------------
/.github/workflows/pull-request.yml:
--------------------------------------------------------------------------------
1 | name: "Pull request"
2 |
3 | on:
4 | pull_request:
5 | types: [assigned, opened, synchronize, reopened]
6 | paths-ignore:
7 | - '**.md'
8 |
9 | jobs:
10 |
11 | bindgen-job:
12 | name: "Bindgen"
13 | uses: "./.github/workflows/bindgen.yml"
14 |
15 | build-job:
16 | name: "Build"
17 | needs: [bindgen-job]
18 | uses: "./.github/workflows/build.yml"
19 |
20 | commit-job:
21 | name: "Commit"
22 | needs: [bindgen-job, build-job]
23 | if: github.actor == 'dependabot[bot]'
24 | uses: "./.github/workflows/commit.yml"
25 |
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | name: "Release"
2 | on:
3 | workflow_dispatch:
4 | inputs:
5 | version:
6 | description: Version of the package
7 | required: true
8 | default: "0.0.0"
9 | # schedule:
10 | # - cron: "0 0 1 * *" # First day of every month
11 |
12 | jobs:
13 | build-job:
14 | name: "Build"
15 | uses: "./.github/workflows/build.yml"
16 |
17 | release-job:
18 | name: "Release"
19 | needs: [build-job]
20 | runs-on: ubuntu-20.04
21 | permissions:
22 | contents: write
23 | steps:
24 | - name: "Clone Git repository"
25 | uses: actions/checkout@v4
26 | with:
27 | submodules: "recursive"
28 |
29 | - name: "Download native libraries (win-x64)"
30 | uses: actions/download-artifact@v4
31 | with:
32 | name: "native-libraries-win-x64"
33 | path: "./lib"
34 |
35 | # - name: "Download native libraries (osx)"
36 | # uses: actions/download-artifact@v4
37 | # with:
38 | # name: "native-libraries-osx"
39 | # path: "./lib"
40 |
41 | - name: "Download native libraries (linux-x64)"
42 | uses: actions/download-artifact@v4
43 | with:
44 | name: "native-libraries-linux-x64"
45 | path: "./lib"
46 |
47 | - name: ".NET pack"
48 | run: dotnet pack "./src/cs" --nologo --verbosity minimal --configuration Release -p:PackageVersion="${{ github.event.inputs.version }}" -p:RepositoryBranch="${{ github.head_ref || github.ref_name }}" -p:RepositoryCommit="${{ github.sha }}"
49 |
50 | - name: "Upload packages to NuGet"
51 | env:
52 | NUGET_ACCESS_TOKEN: ${{ secrets.NUGET_ACCESS_TOKEN }}
53 | run: dotnet nuget push "./artifacts/package/release/**/*.nupkg" --source https://api.nuget.org/v3/index.json --skip-duplicate --api-key $NUGET_ACCESS_TOKEN
54 |
55 | - name: "Create tag and GitHub release"
56 | uses: softprops/action-gh-release@v1
57 | with:
58 | generate_release_notes: true
59 | prerelease: false
60 | tag_name: "v${{ github.event.inputs.version }}"
61 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # JetBrains
2 | .idea/
3 | .vscode/
4 |
5 | # C# build artifacts
6 | /artifacts/
7 | /bin/
8 | /obj/
9 |
10 | # C# packages
11 | /nupkg/
12 |
13 | # NuGet key
14 | nuget.key
15 |
16 | # Native libraries
17 | /lib/
18 |
19 | # Bindgen
20 | /bindgen/ast/
21 | /bindgen/x-ast/
22 |
23 | # macOS
24 | .DS_store
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "ext/Tracy"]
2 | path = ext/Tracy
3 | url = https://github.com/wolfpld/tracy
4 |
--------------------------------------------------------------------------------
/Header.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/l3dotdev/tracy-csharp-godot/914923eafb893edd418bfcf24f114569619b78a9/Header.png
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2024 SyntheticDev (https://github.com/Synthetic-Dev)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Tracy CSharp for Godot
2 |
3 | 
4 |
5 | > This is a fork of [Tracy-CSharp](https://github.com/clibequilibrium/Tracy-CSharp) made to work with .NET 6 and Godot
6 |
7 | C# bindings for https://github.com/wolfpld/tracy with native dynamic link libraries based on [`imgui-cs`](https://github.com/bottlenoselabs/imgui-cs).
8 |
9 | ## How to use
10 |
11 | ## Get it from [NuGet](https://www.nuget.org/packages/tracy-csharp-godot)
12 |
13 | ```bash
14 | dotnet add package tracy-csharp-godot --version 0.1.0
15 | ```
16 |
17 | ## From source
18 |
19 | ### Installing `C2CS`
20 |
21 | `C2CS` is distributed as a NuGet tool. To get started, the .NET 7 (or later) software development kit (SDK) is required.
22 |
23 | #### Latest release of `C2CS`
24 |
25 | ```bash
26 | dotnet tool install bottlenoselabs.c2cs.tool --global
27 | ```
28 |
29 | 1. Download and install [.NET 7 or later](https://dotnet.microsoft.com/download).
30 | 2. Fork the repository using GitHub or clone the repository manually with submodules: `git clone --recurse-submodules https://github.com/Synthetic-Dev/tracy-csharp-godot`.
31 | 3. Build the native library by running `library.sh`. To execute `.sh` scripts on Windows, use Git Bash which can be installed with Git itself: https://git-scm.com/download/win. The `library.sh` script requires that CMake is installed and in your path.
32 | 4. Locate the sample of the C# project: `./src/cs/samples/HelloWorld/HelloWorld.csproj`.
33 |
34 | ## Developers: Documentation
35 |
36 | For more information on how C# bindings work, see [`C2CS`](https://github.com/lithiumtoast/c2cs), the tool that generates the bindings for `Tracy` and other C libraries.
37 |
38 | To learn how to use `Tracy`, check out the [official readme](https://github.com/wolfpld/tracy).
39 |
40 | All of the C# bindings can be found in [the generated file `PInvoke.gen.cs`](https://github.com/Synthetic-Dev/tracy-csharp-godot/blob/main/src/cs/production/Tracy/Generated/PInvoke.gen.cs)
41 |
42 | ## License
43 |
44 | `Tracy-CSharp` is licensed under the MIT License (`MIT`) - see the [LICENSE file](LICENSE) for details.
45 |
46 | `Tracy` itself is licensed under BSD license (`BSD`) - see https://github.com/wolfpld/tracy/blob/master/LICENSE for more details.
47 |
--------------------------------------------------------------------------------
/bindgen/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "Console": {
4 | "LogLevel": {
5 | "Default": "Warning",
6 | "CAstFfi": "Debug",
7 | "C2CS": "Debug"
8 | },
9 | "FormatterOptions": {
10 | "ColorBehavior": "Enabled",
11 | "SingleLine": true,
12 | "IncludeScopes": true,
13 | "TimestampFormat": "yyyy-dd-MM HH:mm:ss ",
14 | "UseUtcTimestamp": true
15 | }
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/bindgen/config-build-c-library.json:
--------------------------------------------------------------------------------
1 | {
2 | "cMakeDirectoryPath": "../ext/Tracy/",
3 | "outputDirectoryPath": "../lib",
4 | "deleteBuildFiles": true,
5 | "cMakeArguments": [ "-DBUILD_SHARED_LIBS=ON" ]
6 | }
--------------------------------------------------------------------------------
/bindgen/config-extract-linux.json:
--------------------------------------------------------------------------------
1 | {
2 | "inputFilePath": "../src/c/production/Tracy/_Tracy.h",
3 | "userIncludeDirectories": [
4 | "../ext/Tracy"
5 | ],
6 | "platforms": {
7 | "x86_64-unknown-linux-gnu": {},
8 | "aarch64-unknown-linux-gnu": {}
9 | }
10 | }
--------------------------------------------------------------------------------
/bindgen/config-extract-macos.json:
--------------------------------------------------------------------------------
1 | {
2 | "inputFilePath": "../src/c/production/Tracy/_Tracy.h",
3 | "userIncludeDirectories": [
4 | "../ext/Tracy"
5 | ],
6 | "platforms": {
7 | "aarch64-apple-darwin": {},
8 | "x86_64-apple-darwin": {}
9 | }
10 | }
--------------------------------------------------------------------------------
/bindgen/config-extract-windows.json:
--------------------------------------------------------------------------------
1 | {
2 | "inputFilePath": "../src/c/production/Tracy/_Tracy.h",
3 | "userIncludeDirectories": [
4 | "../ext/Tracy"
5 | ],
6 | "platforms": {
7 | "x86_64-pc-windows-msvc": {},
8 | "aarch64-pc-windows-msvc": {}
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/bindgen/config-generate-cs.json:
--------------------------------------------------------------------------------
1 | {
2 | "inputFilePath": "./x-ast/ast-cross-platform.json",
3 | "outputFileDirectory": "./../src/cs/production/Tracy/Generated",
4 | "namespaceName": "Tracy",
5 | "className": "PInvoke",
6 | "libraryName": "TracyClient",
7 | "mappedNames": [],
8 | "ignoredNames": [],
9 | "isEnabledVerifyCSharpCodeCompiles": false,
10 | "mappedCNamespaces": [],
11 | "isEnabledAssemblyAttributes": true,
12 | "isEnabledLibraryImport": false,
13 | "isEnabledIdiomaticCSharp": true,
14 | "isEnabledEnumValueNamesUpperCase": false
15 | }
--------------------------------------------------------------------------------
/bindgen/extract.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
3 |
4 | function get_host_operating_system() {
5 | local UNAME_STRING="$(uname -a)"
6 | case "${UNAME_STRING}" in
7 | *Microsoft*) local HOST_OS="windows";;
8 | *microsoft*) local HOST_OS="windows";;
9 | Linux*) local HOST_OS="linux";;
10 | Darwin*) local HOST_OS="macos";;
11 | CYGWIN*) local HOST_OS="linux";;
12 | MINGW*) local HOST_OS="windows";;
13 | *Msys) local HOST_OS="windows";;
14 | *) local HOST_OS="UNKNOWN:${UNAME_STRING}"
15 | esac
16 | echo "$HOST_OS"
17 | return 0
18 | }
19 |
20 | OS="$(get_host_operating_system)"
21 |
22 | if [[ "$OS" == "windows" ]]; then
23 | CASTFFI_CONFIG_FILE_PATH="$DIRECTORY/config-extract-windows.json"
24 | elif [[ "$OS" == "macos" ]]; then
25 | CASTFFI_CONFIG_FILE_PATH="$DIRECTORY/config-extract-macos.json"
26 | elif [[ "$OS" == "linux" ]]; then
27 | CASTFFI_CONFIG_FILE_PATH="$DIRECTORY/config-extract-linux.json"
28 | else
29 | echo "Error: Unknown operating system '$OS'" >&2
30 | exit 1
31 | fi
32 |
33 | if ! [[ -x "$(command -v castffi)" ]]; then
34 | echo "Error: 'castffi' is not installed. Please visit https://github.com/bottlenoselabs/CAstFfi for instructions to install the CAstFfi tool." >&2
35 | exit 1
36 | fi
37 |
38 | castffi extract --config "$CASTFFI_CONFIG_FILE_PATH"
39 |
--------------------------------------------------------------------------------
/bindgen/generate.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
3 |
4 | if ! [[ -x "$(command -v c2cs)" ]]; then
5 | echo "Error: 'c2cs' is not installed. Please visit https://github.com/bottlenoselabs/C2CS for instructions to install the C2CS tool." >&2
6 | exit 1
7 | fi
8 |
9 | c2cs generate --config "$DIRECTORY/config-generate-cs.json"
--------------------------------------------------------------------------------
/bindgen/merge.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
3 |
4 | if ! [[ -x "$(command -v castffi)" ]]; then
5 | echo "Error: 'castffi' is not installed. Please visit https://github.com/bottlenoselabs/CAstFfi for instructions to install the CAstFfi tool." >&2
6 | exit 1
7 | fi
8 |
9 | castffi merge --inputDirectoryPath "$DIRECTORY/ast" --outputFilePath "$DIRECTORY/x-ast/ast-cross-platform.json"
--------------------------------------------------------------------------------
/library.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
3 |
4 | if ! [[ -x "$(command -v c2cs)" ]]; then
5 | echo "Error: 'c2cs' is not installed. The C2CS tool is used to generate a C shared library for the purposes of P/Invoke with C#. Please visit https://github.com/bottlenoselabs/C2CS for instructions to install the C2CS tool." >&2
6 | exit 1
7 | fi
8 |
9 | c2cs library --config "$DIRECTORY/bindgen/config-build-c-library.json"
10 |
11 | # Directory to search for libraries
12 | search_dir="./lib"
13 |
14 | # Check if the directory exists
15 | if [ ! -d "$search_dir" ]; then
16 | echo "Directory not found: $search_dir"
17 | exit 1
18 | fi
19 |
20 | # Find all libraries with prefix "lib"
21 | lib_files=$(find "$search_dir" -type f -name "lib*")
22 |
23 | # Iterate through the list of found libraries and strip the "lib" prefix
24 | for lib_file in $lib_files; do
25 | # Extract the filename without the path
26 | file_name=$(basename "$lib_file")
27 |
28 | # Strip the "lib" prefix
29 | new_name="${file_name#lib}"
30 |
31 | # Rename the file with the stripped prefix
32 | mv "$lib_file" "$(dirname "$lib_file")/$new_name"
33 |
34 | echo "Stripped and renamed: $file_name -> $new_name"
35 | done
36 |
37 |
38 | if [[ -z "$1" ]]; then
39 | read
40 | fi
--------------------------------------------------------------------------------
/licenses.txt:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 clibequilibrium (https://github.com/clibequilibrium)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
24 |
25 | MIT License
26 |
27 | Copyright (c) 2023 Bottlenose Labs Inc. (https://github.com/bottlenoselabs)
28 |
29 | Permission is hereby granted, free of charge, to any person obtaining a copy
30 | of this software and associated documentation files (the "Software"), to deal
31 | in the Software without restriction, including without limitation the rights
32 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
33 | copies of the Software, and to permit persons to whom the Software is
34 | furnished to do so, subject to the following conditions:
35 |
36 | The above copyright notice and this permission notice shall be included in all
37 | copies or substantial portions of the Software.
38 |
39 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
40 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
41 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
42 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
43 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
44 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
45 | SOFTWARE.
--------------------------------------------------------------------------------
/src/c/production/Tracy/_Tracy.h:
--------------------------------------------------------------------------------
1 | #define TRACY_ENABLE
2 | #include "public/tracy/TracyC.h"
--------------------------------------------------------------------------------
/src/cs/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | true
5 | $([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), .gitignore))/artifacts
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/cs/Directory.Build.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/src/cs/Tracy.sln:
--------------------------------------------------------------------------------
1 | Microsoft Visual Studio Solution File, Format Version 12.00
2 | #
3 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "production", "production", "{BC62B6F7-35F6-44DE-B5FA-17B398389F8F}"
4 | EndProject
5 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tracy", "production\Tracy\Tracy.csproj", "{E62D3998-855A-4500-862F-5A115A22B15F}"
6 | EndProject
7 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{CEBF55EF-ABE5-4878-8B02-310CB16C462F}"
8 | EndProject
9 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloWorld", "samples\HelloWorld\HelloWorld.csproj", "{19FC8B71-908D-46B8-854B-CECE81ADD22E}"
10 | EndProject
11 | Global
12 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
13 | Debug|Any CPU = Debug|Any CPU
14 | Release|Any CPU = Release|Any CPU
15 | EndGlobalSection
16 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
17 | {E62D3998-855A-4500-862F-5A115A22B15F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
18 | {E62D3998-855A-4500-862F-5A115A22B15F}.Debug|Any CPU.Build.0 = Debug|Any CPU
19 | {E62D3998-855A-4500-862F-5A115A22B15F}.Release|Any CPU.ActiveCfg = Release|Any CPU
20 | {E62D3998-855A-4500-862F-5A115A22B15F}.Release|Any CPU.Build.0 = Release|Any CPU
21 | {19FC8B71-908D-46B8-854B-CECE81ADD22E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
22 | {19FC8B71-908D-46B8-854B-CECE81ADD22E}.Debug|Any CPU.Build.0 = Debug|Any CPU
23 | EndGlobalSection
24 | GlobalSection(NestedProjects) = preSolution
25 | {E62D3998-855A-4500-862F-5A115A22B15F} = {BC62B6F7-35F6-44DE-B5FA-17B398389F8F}
26 | {19FC8B71-908D-46B8-854B-CECE81ADD22E} = {CEBF55EF-ABE5-4878-8B02-310CB16C462F}
27 | EndGlobalSection
28 | EndGlobal
29 |
--------------------------------------------------------------------------------
/src/cs/production/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/src/cs/production/Directory.Build.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/src/cs/production/Tracy/Generated/AssemblyAttributes.gen.cs:
--------------------------------------------------------------------------------
1 | // To disable generating this file set `isEnabledGenerateAssemblyAttributes` to `false` in the config file for generating C# code.
2 | //
3 | // This code was generated by the following tool on 2024-08-26 10:32:31 GMT+01:00:
4 | // https://github.com/bottlenoselabs/c2cs (v0.0.0.0)
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if the code is regenerated.
7 | //
8 | // ReSharper disable All
9 |
10 | #region Template
11 | #nullable enable
12 | #pragma warning disable CS1591
13 | #pragma warning disable CS8981
14 | using bottlenoselabs.C2CS.Runtime;
15 | using System;
16 | using System.Collections.Generic;
17 | using System.Globalization;
18 | using System.Runtime.InteropServices;
19 | using System.Runtime.CompilerServices;
20 | #endregion
21 |
22 | #if NET7_0_OR_GREATER
23 | [assembly: DisableRuntimeMarshalling]
24 | #endif
25 |
26 | [assembly: DefaultDllImportSearchPathsAttribute(DllImportSearchPath.SafeDirectories)]
27 |
--------------------------------------------------------------------------------
/src/cs/production/Tracy/Generated/PInvoke.gen.cs:
--------------------------------------------------------------------------------
1 |
2 | //
3 | // This code was generated by the following tool on 2024-08-26 10:32:31 GMT+01:00:
4 | // https://github.com/bottlenoselabs/c2cs (v0.0.0.0)
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if the code is regenerated.
7 | //
8 | // ReSharper disable All
9 |
10 | #region Template
11 | #nullable enable
12 | #pragma warning disable CS1591
13 | #pragma warning disable CS8981
14 | using bottlenoselabs.C2CS.Runtime;
15 | using System;
16 | using System.Collections.Generic;
17 | using System.Globalization;
18 | using System.Runtime.InteropServices;
19 | using System.Runtime.CompilerServices;
20 | #endregion
21 |
22 | namespace Tracy;
23 |
24 | public static unsafe partial class PInvoke
25 | {
26 | private const string LibraryName = "TracyClient";
27 |
28 | #region API
29 |
30 | [CNode(Kind = "Function")]
31 | [DllImport(LibraryName, EntryPoint = "___tracy_alloc_srcloc", CallingConvention = CallingConvention.Cdecl)]
32 | public static extern ulong TracyAllocSrcloc(uint line, CString source, int sourceSz, CString function, int functionSz);
33 |
34 | [CNode(Kind = "Function")]
35 | [DllImport(LibraryName, EntryPoint = "___tracy_alloc_srcloc_name", CallingConvention = CallingConvention.Cdecl)]
36 | public static extern ulong TracyAllocSrclocName(uint line, CString source, int sourceSz, CString function, int functionSz, CString name, int nameSz);
37 |
38 | [CNode(Kind = "Function")]
39 | [DllImport(LibraryName, EntryPoint = "___tracy_connected", CallingConvention = CallingConvention.Cdecl)]
40 | public static extern int TracyConnected();
41 |
42 | [CNode(Kind = "Function")]
43 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_frame_image", CallingConvention = CallingConvention.Cdecl)]
44 | public static extern void TracyEmitFrameImage(void* image, ushort w, ushort h, byte offset, int flip);
45 |
46 | [CNode(Kind = "Function")]
47 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_frame_mark", CallingConvention = CallingConvention.Cdecl)]
48 | public static extern void TracyEmitFrameMark(CString name);
49 |
50 | [CNode(Kind = "Function")]
51 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_frame_mark_end", CallingConvention = CallingConvention.Cdecl)]
52 | public static extern void TracyEmitFrameMarkEnd(CString name);
53 |
54 | [CNode(Kind = "Function")]
55 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_frame_mark_start", CallingConvention = CallingConvention.Cdecl)]
56 | public static extern void TracyEmitFrameMarkStart(CString name);
57 |
58 | [CNode(Kind = "Function")]
59 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_gpu_calibration", CallingConvention = CallingConvention.Cdecl)]
60 | public static extern void TracyEmitGpuCalibration(TracyGpuCalibrationData param);
61 |
62 | [CNode(Kind = "Function")]
63 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_gpu_calibration_serial", CallingConvention = CallingConvention.Cdecl)]
64 | public static extern void TracyEmitGpuCalibrationSerial(TracyGpuCalibrationData param);
65 |
66 | [CNode(Kind = "Function")]
67 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_gpu_context_name", CallingConvention = CallingConvention.Cdecl)]
68 | public static extern void TracyEmitGpuContextName(TracyGpuContextNameData param);
69 |
70 | [CNode(Kind = "Function")]
71 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_gpu_context_name_serial", CallingConvention = CallingConvention.Cdecl)]
72 | public static extern void TracyEmitGpuContextNameSerial(TracyGpuContextNameData param);
73 |
74 | [CNode(Kind = "Function")]
75 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_gpu_new_context", CallingConvention = CallingConvention.Cdecl)]
76 | public static extern void TracyEmitGpuNewContext(TracyGpuNewContextData param);
77 |
78 | [CNode(Kind = "Function")]
79 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_gpu_new_context_serial", CallingConvention = CallingConvention.Cdecl)]
80 | public static extern void TracyEmitGpuNewContextSerial(TracyGpuNewContextData param);
81 |
82 | [CNode(Kind = "Function")]
83 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_gpu_time", CallingConvention = CallingConvention.Cdecl)]
84 | public static extern void TracyEmitGpuTime(TracyGpuTimeData param);
85 |
86 | [CNode(Kind = "Function")]
87 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_gpu_time_serial", CallingConvention = CallingConvention.Cdecl)]
88 | public static extern void TracyEmitGpuTimeSerial(TracyGpuTimeData param);
89 |
90 | [CNode(Kind = "Function")]
91 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_gpu_zone_begin", CallingConvention = CallingConvention.Cdecl)]
92 | public static extern void TracyEmitGpuZoneBegin(TracyGpuZoneBeginData param);
93 |
94 | [CNode(Kind = "Function")]
95 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_gpu_zone_begin_alloc", CallingConvention = CallingConvention.Cdecl)]
96 | public static extern void TracyEmitGpuZoneBeginAlloc(TracyGpuZoneBeginData param);
97 |
98 | [CNode(Kind = "Function")]
99 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_gpu_zone_begin_alloc_callstack", CallingConvention = CallingConvention.Cdecl)]
100 | public static extern void TracyEmitGpuZoneBeginAllocCallstack(TracyGpuZoneBeginCallstackData param);
101 |
102 | [CNode(Kind = "Function")]
103 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_gpu_zone_begin_alloc_callstack_serial", CallingConvention = CallingConvention.Cdecl)]
104 | public static extern void TracyEmitGpuZoneBeginAllocCallstackSerial(TracyGpuZoneBeginCallstackData param);
105 |
106 | [CNode(Kind = "Function")]
107 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_gpu_zone_begin_alloc_serial", CallingConvention = CallingConvention.Cdecl)]
108 | public static extern void TracyEmitGpuZoneBeginAllocSerial(TracyGpuZoneBeginData param);
109 |
110 | [CNode(Kind = "Function")]
111 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_gpu_zone_begin_callstack", CallingConvention = CallingConvention.Cdecl)]
112 | public static extern void TracyEmitGpuZoneBeginCallstack(TracyGpuZoneBeginCallstackData param);
113 |
114 | [CNode(Kind = "Function")]
115 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_gpu_zone_begin_callstack_serial", CallingConvention = CallingConvention.Cdecl)]
116 | public static extern void TracyEmitGpuZoneBeginCallstackSerial(TracyGpuZoneBeginCallstackData param);
117 |
118 | [CNode(Kind = "Function")]
119 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_gpu_zone_begin_serial", CallingConvention = CallingConvention.Cdecl)]
120 | public static extern void TracyEmitGpuZoneBeginSerial(TracyGpuZoneBeginData param);
121 |
122 | [CNode(Kind = "Function")]
123 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_gpu_zone_end", CallingConvention = CallingConvention.Cdecl)]
124 | public static extern void TracyEmitGpuZoneEnd(TracyGpuZoneEndData data);
125 |
126 | [CNode(Kind = "Function")]
127 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_gpu_zone_end_serial", CallingConvention = CallingConvention.Cdecl)]
128 | public static extern void TracyEmitGpuZoneEndSerial(TracyGpuZoneEndData data);
129 |
130 | [CNode(Kind = "Function")]
131 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_memory_alloc", CallingConvention = CallingConvention.Cdecl)]
132 | public static extern void TracyEmitMemoryAlloc(void* ptr, int size, int secure);
133 |
134 | [CNode(Kind = "Function")]
135 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_memory_alloc_callstack", CallingConvention = CallingConvention.Cdecl)]
136 | public static extern void TracyEmitMemoryAllocCallstack(void* ptr, int size, int depth, int secure);
137 |
138 | [CNode(Kind = "Function")]
139 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_memory_alloc_callstack_named", CallingConvention = CallingConvention.Cdecl)]
140 | public static extern void TracyEmitMemoryAllocCallstackNamed(void* ptr, int size, int depth, int secure, CString name);
141 |
142 | [CNode(Kind = "Function")]
143 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_memory_alloc_named", CallingConvention = CallingConvention.Cdecl)]
144 | public static extern void TracyEmitMemoryAllocNamed(void* ptr, int size, int secure, CString name);
145 |
146 | [CNode(Kind = "Function")]
147 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_memory_free", CallingConvention = CallingConvention.Cdecl)]
148 | public static extern void TracyEmitMemoryFree(void* ptr, int secure);
149 |
150 | [CNode(Kind = "Function")]
151 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_memory_free_callstack", CallingConvention = CallingConvention.Cdecl)]
152 | public static extern void TracyEmitMemoryFreeCallstack(void* ptr, int depth, int secure);
153 |
154 | [CNode(Kind = "Function")]
155 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_memory_free_callstack_named", CallingConvention = CallingConvention.Cdecl)]
156 | public static extern void TracyEmitMemoryFreeCallstackNamed(void* ptr, int depth, int secure, CString name);
157 |
158 | [CNode(Kind = "Function")]
159 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_memory_free_named", CallingConvention = CallingConvention.Cdecl)]
160 | public static extern void TracyEmitMemoryFreeNamed(void* ptr, int secure, CString name);
161 |
162 | [CNode(Kind = "Function")]
163 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_message", CallingConvention = CallingConvention.Cdecl)]
164 | public static extern void TracyEmitMessage(CString txt, int size, int callstack);
165 |
166 | [CNode(Kind = "Function")]
167 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_message_appinfo", CallingConvention = CallingConvention.Cdecl)]
168 | public static extern void TracyEmitMessageAppinfo(CString txt, int size);
169 |
170 | [CNode(Kind = "Function")]
171 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_messageC", CallingConvention = CallingConvention.Cdecl)]
172 | public static extern void TracyEmitMessageC(CString txt, int size, uint color, int callstack);
173 |
174 | [CNode(Kind = "Function")]
175 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_messageL", CallingConvention = CallingConvention.Cdecl)]
176 | public static extern void TracyEmitMessageL(CString txt, int callstack);
177 |
178 | [CNode(Kind = "Function")]
179 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_messageLC", CallingConvention = CallingConvention.Cdecl)]
180 | public static extern void TracyEmitMessageLC(CString txt, uint color, int callstack);
181 |
182 | [CNode(Kind = "Function")]
183 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_plot", CallingConvention = CallingConvention.Cdecl)]
184 | public static extern void TracyEmitPlot(CString name, Double val);
185 |
186 | [CNode(Kind = "Function")]
187 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_plot_config", CallingConvention = CallingConvention.Cdecl)]
188 | public static extern void TracyEmitPlotConfig(CString name, int type, int step, int fill, uint color);
189 |
190 | [CNode(Kind = "Function")]
191 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_plot_float", CallingConvention = CallingConvention.Cdecl)]
192 | public static extern void TracyEmitPlotFloat(CString name, float val);
193 |
194 | [CNode(Kind = "Function")]
195 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_plot_int", CallingConvention = CallingConvention.Cdecl)]
196 | public static extern void TracyEmitPlotInt(CString name, long val);
197 |
198 | [CNode(Kind = "Function")]
199 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_zone_begin", CallingConvention = CallingConvention.Cdecl)]
200 | public static extern TracyCZoneCtx TracyEmitZoneBegin(TracySourceLocationData* srcloc, int active);
201 |
202 | [CNode(Kind = "Function")]
203 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_zone_begin_alloc", CallingConvention = CallingConvention.Cdecl)]
204 | public static extern TracyCZoneCtx TracyEmitZoneBeginAlloc(ulong srcloc, int active);
205 |
206 | [CNode(Kind = "Function")]
207 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_zone_begin_alloc_callstack", CallingConvention = CallingConvention.Cdecl)]
208 | public static extern TracyCZoneCtx TracyEmitZoneBeginAllocCallstack(ulong srcloc, int depth, int active);
209 |
210 | [CNode(Kind = "Function")]
211 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_zone_begin_callstack", CallingConvention = CallingConvention.Cdecl)]
212 | public static extern TracyCZoneCtx TracyEmitZoneBeginCallstack(TracySourceLocationData* srcloc, int depth, int active);
213 |
214 | [CNode(Kind = "Function")]
215 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_zone_color", CallingConvention = CallingConvention.Cdecl)]
216 | public static extern void TracyEmitZoneColor(TracyCZoneCtx ctx, uint color);
217 |
218 | [CNode(Kind = "Function")]
219 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_zone_end", CallingConvention = CallingConvention.Cdecl)]
220 | public static extern void TracyEmitZoneEnd(TracyCZoneCtx ctx);
221 |
222 | [CNode(Kind = "Function")]
223 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_zone_name", CallingConvention = CallingConvention.Cdecl)]
224 | public static extern void TracyEmitZoneName(TracyCZoneCtx ctx, CString txt, int size);
225 |
226 | [CNode(Kind = "Function")]
227 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_zone_text", CallingConvention = CallingConvention.Cdecl)]
228 | public static extern void TracyEmitZoneText(TracyCZoneCtx ctx, CString txt, int size);
229 |
230 | [CNode(Kind = "Function")]
231 | [DllImport(LibraryName, EntryPoint = "___tracy_emit_zone_value", CallingConvention = CallingConvention.Cdecl)]
232 | public static extern void TracyEmitZoneValue(TracyCZoneCtx ctx, ulong value);
233 |
234 | [CNode(Kind = "Function")]
235 | [DllImport(LibraryName, EntryPoint = "___tracy_set_thread_name", CallingConvention = CallingConvention.Cdecl)]
236 | public static extern void TracySetThreadName(CString name);
237 |
238 | #endregion
239 |
240 | #region Types
241 |
242 | [CNode(Kind = "Struct")]
243 | [StructLayout(LayoutKind.Explicit, Size = 8, Pack = 4)]
244 | public struct TracyCZoneContext
245 | {
246 | [FieldOffset(0)] // size = 4
247 | public uint Id;
248 |
249 | [FieldOffset(4)] // size = 4
250 | public int Active;
251 | }
252 |
253 | [CNode(Kind = "Struct")]
254 | [StructLayout(LayoutKind.Explicit, Size = 24, Pack = 8)]
255 | public struct TracyGpuCalibrationData
256 | {
257 | [FieldOffset(0)] // size = 8
258 | public long GpuTime;
259 |
260 | [FieldOffset(8)] // size = 8
261 | public long CpuDelta;
262 |
263 | [FieldOffset(16)] // size = 1
264 | public byte Context;
265 | }
266 |
267 | [CNode(Kind = "Struct")]
268 | [StructLayout(LayoutKind.Explicit, Size = 24, Pack = 8)]
269 | public struct TracyGpuContextNameData
270 | {
271 | [FieldOffset(0)] // size = 1
272 | public byte Context;
273 |
274 | [FieldOffset(8)] // size = 8
275 | public CString _Name;
276 |
277 | public string Name
278 | {
279 | get
280 | {
281 | return CString.ToString(_Name);
282 | }
283 | set
284 | {
285 | _Name = CString.FromString(value);
286 | }
287 | }
288 |
289 | [FieldOffset(16)] // size = 2
290 | public ushort Len;
291 | }
292 |
293 | [CNode(Kind = "Struct")]
294 | [StructLayout(LayoutKind.Explicit, Size = 16, Pack = 8)]
295 | public struct TracyGpuNewContextData
296 | {
297 | [FieldOffset(0)] // size = 8
298 | public long GpuTime;
299 |
300 | [FieldOffset(8)] // size = 4
301 | public float Period;
302 |
303 | [FieldOffset(12)] // size = 1
304 | public byte Context;
305 |
306 | [FieldOffset(13)] // size = 1
307 | public byte Flags;
308 |
309 | [FieldOffset(14)] // size = 1
310 | public byte Type;
311 | }
312 |
313 | [CNode(Kind = "Struct")]
314 | [StructLayout(LayoutKind.Explicit, Size = 16, Pack = 8)]
315 | public struct TracyGpuTimeData
316 | {
317 | [FieldOffset(0)] // size = 8
318 | public long GpuTime;
319 |
320 | [FieldOffset(8)] // size = 2
321 | public ushort QueryId;
322 |
323 | [FieldOffset(10)] // size = 1
324 | public byte Context;
325 | }
326 |
327 | [CNode(Kind = "Struct")]
328 | [StructLayout(LayoutKind.Explicit, Size = 16, Pack = 8)]
329 | public struct TracyGpuZoneBeginCallstackData
330 | {
331 | [FieldOffset(0)] // size = 8
332 | public ulong Srcloc;
333 |
334 | [FieldOffset(8)] // size = 4
335 | public int Depth;
336 |
337 | [FieldOffset(12)] // size = 2
338 | public ushort QueryId;
339 |
340 | [FieldOffset(14)] // size = 1
341 | public byte Context;
342 | }
343 |
344 | [CNode(Kind = "Struct")]
345 | [StructLayout(LayoutKind.Explicit, Size = 16, Pack = 8)]
346 | public struct TracyGpuZoneBeginData
347 | {
348 | [FieldOffset(0)] // size = 8
349 | public ulong Srcloc;
350 |
351 | [FieldOffset(8)] // size = 2
352 | public ushort QueryId;
353 |
354 | [FieldOffset(10)] // size = 1
355 | public byte Context;
356 | }
357 |
358 | [CNode(Kind = "Struct")]
359 | [StructLayout(LayoutKind.Explicit, Size = 4, Pack = 2)]
360 | public struct TracyGpuZoneEndData
361 | {
362 | [FieldOffset(0)] // size = 2
363 | public ushort QueryId;
364 |
365 | [FieldOffset(2)] // size = 1
366 | public byte Context;
367 | }
368 |
369 | [CNode(Kind = "Struct")]
370 | [StructLayout(LayoutKind.Explicit, Size = 32, Pack = 8)]
371 | public struct TracySourceLocationData
372 | {
373 | [FieldOffset(0)] // size = 8
374 | public CString _Name;
375 |
376 | public string Name
377 | {
378 | get
379 | {
380 | return CString.ToString(_Name);
381 | }
382 | set
383 | {
384 | _Name = CString.FromString(value);
385 | }
386 | }
387 |
388 | [FieldOffset(8)] // size = 8
389 | public CString _Function;
390 |
391 | public string Function
392 | {
393 | get
394 | {
395 | return CString.ToString(_Function);
396 | }
397 | set
398 | {
399 | _Function = CString.FromString(value);
400 | }
401 | }
402 |
403 | [FieldOffset(16)] // size = 8
404 | public CString _File;
405 |
406 | public string File
407 | {
408 | get
409 | {
410 | return CString.ToString(_File);
411 | }
412 | set
413 | {
414 | _File = CString.FromString(value);
415 | }
416 | }
417 |
418 | [FieldOffset(24)] // size = 4
419 | public uint Line;
420 |
421 | [FieldOffset(28)] // size = 4
422 | public uint Color;
423 | }
424 |
425 | [CNode(Kind = "Enum")]
426 | public enum TracyPlotFormatEnum : int
427 | {
428 | TracyPlotFormatNumber = 0,
429 | TracyPlotFormatMemory = 1,
430 | TracyPlotFormatPercentage = 2,
431 | TracyPlotFormatWatt = 3
432 | }
433 |
434 | [CNode(Kind = "TypeAlias")]
435 | [StructLayout(LayoutKind.Explicit, Size = 8, Pack = 4)]
436 | public struct TracyCZoneCtx
437 | {
438 | [FieldOffset(0)]
439 | public TracyCZoneContext Data;
440 |
441 | public static implicit operator TracyCZoneContext(TracyCZoneCtx data) => data.Data;
442 | public static implicit operator TracyCZoneCtx(TracyCZoneContext data) => new() { Data = data };
443 | }
444 |
445 | [CNode(Kind = "MacroObject")]
446 | public const int TracyHasCallstack = 1;
447 |
448 | #endregion
449 | }
450 |
--------------------------------------------------------------------------------
/src/cs/production/Tracy/Generated/Runtime.gen.cs:
--------------------------------------------------------------------------------
1 |
2 | // To disable generating this file set `isEnabledGeneratingRuntimeCode` to `false` in the config file for generating C# code.
3 |
4 | //
5 | // This code was generated by the following tool on 2024-08-26 10:32:31 GMT+01:00:
6 | // https://github.com/bottlenoselabs/c2cs (v0.0.0.0)
7 | //
8 | // Changes to this file may cause incorrect behavior and will be lost if the code is regenerated.
9 | //
10 | // ReSharper disable All
11 |
12 | #region Template
13 | #nullable enable
14 | #pragma warning disable CS1591
15 | #pragma warning disable CS8981
16 | using bottlenoselabs.C2CS.Runtime;
17 | using System;
18 | using System.Collections.Generic;
19 | using System.Globalization;
20 | using System.Runtime.InteropServices;
21 | using System.Runtime.CompilerServices;
22 | #endregion
23 |
24 | namespace bottlenoselabs.C2CS.Runtime;
25 |
26 | ///
27 | /// Specifies a C `const` for a parameter or return value.
28 | ///
29 | [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.ReturnValue)]
30 | public sealed class CConstAttribute : Attribute
31 | {
32 | // marker
33 | }
34 |
35 | ///
36 | /// Specifies a C node with a specific kind for a C# type.
37 | ///
38 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Enum | AttributeTargets.Field)]
39 | public sealed class CNodeAttribute : Attribute
40 | {
41 | ///
42 | /// Gets or sets the C node kind.
43 | ///
44 | public string Kind { get; set; } = string.Empty;
45 | }
46 |
47 | ///
48 | /// A boolean value type with the same memory layout as a in both managed and unmanaged contexts;
49 | /// equivalent to a standard bool found in C/C++/ObjC where 0 is false and any other value is
50 | /// true.
51 | ///
52 | [StructLayout(LayoutKind.Sequential)]
53 | public readonly struct CBool : IEquatable
54 | {
55 | public readonly byte Value;
56 |
57 | private CBool(bool value)
58 | {
59 | Value = Convert.ToByte(value);
60 | }
61 |
62 | ///
63 | /// Converts the specified to a .
64 | ///
65 | /// The value.
66 | /// A .
67 | public static implicit operator CBool(bool value)
68 | {
69 | return FromBoolean(value);
70 | }
71 |
72 | ///
73 | /// Converts the specified to a .
74 | ///
75 | /// The value.
76 | /// A .
77 | public static CBool FromBoolean(bool value)
78 | {
79 | return new CBool(value);
80 | }
81 |
82 | ///
83 | /// Converts the specified to a .
84 | ///
85 | /// The value.
86 | /// A .
87 | public static implicit operator bool(CBool value)
88 | {
89 | return ToBoolean(value);
90 | }
91 |
92 | ///
93 | /// Converts the specified to a .
94 | ///
95 | /// The value.
96 | /// A .
97 | public static bool ToBoolean(CBool value)
98 | {
99 | return Convert.ToBoolean(value.Value);
100 | }
101 |
102 | ///
103 | public override string ToString()
104 | {
105 | return ToBoolean(this).ToString();
106 | }
107 |
108 | ///
109 | public override bool Equals(object? obj)
110 | {
111 | return obj is CBool b && Equals(b);
112 | }
113 |
114 | ///
115 | public bool Equals(CBool other)
116 | {
117 | return Value == other.Value;
118 | }
119 |
120 | ///
121 | public override int GetHashCode()
122 | {
123 | return Value.GetHashCode();
124 | }
125 |
126 | ///
127 | /// Returns a value that indicates whether two specified structures are equal.
128 | ///
129 | /// The first to compare.
130 | /// The second to compare.
131 | /// true if and are equal; otherwise, false.
132 | public static bool operator ==(CBool left, CBool right)
133 | {
134 | return left.Value == right.Value;
135 | }
136 |
137 | ///
138 | /// Returns a value that indicates whether two specified structures are not equal.
139 | ///
140 | /// The first to compare.
141 | /// The second to compare.
142 | /// true if and are not equal; otherwise, false.
143 | public static bool operator !=(CBool left, CBool right)
144 | {
145 | return !(left == right);
146 | }
147 |
148 | ///
149 | /// Returns a value that indicates whether two specified structures are equal.
150 | ///
151 | /// The first to compare.
152 | /// The second to compare.
153 | /// true if and are equal; otherwise, false.
154 | public static bool Equals(CBool left, CBool right)
155 | {
156 | return left.Value == right.Value;
157 | }
158 | }
159 |
160 | ///
161 | /// A value type with the same memory layout as a in a managed context and char in
162 | /// an unmanaged context.
163 | ///
164 | [StructLayout(LayoutKind.Sequential)]
165 | public readonly struct CChar : IEquatable, IEquatable
166 | {
167 | public readonly byte Value;
168 |
169 | private CChar(byte value)
170 | {
171 | Value = Convert.ToByte(value);
172 | }
173 |
174 | ///
175 | /// Converts the specified to a .
176 | ///
177 | /// The value.
178 | /// A .
179 | public static implicit operator CChar(byte value)
180 | {
181 | return FromByte(value);
182 | }
183 |
184 | ///
185 | /// Converts the specified to a .
186 | ///
187 | /// The value.
188 | /// A .
189 | public static CChar FromByte(byte value)
190 | {
191 | return new CChar(value);
192 | }
193 |
194 | ///
195 | /// Converts the specified to a .
196 | ///
197 | /// The value.
198 | /// A .
199 | public static implicit operator byte(CChar value)
200 | {
201 | return ToByte(value);
202 | }
203 |
204 | ///
205 | /// Converts the specified to a .
206 | ///
207 | /// The value.
208 | /// A .
209 | public static byte ToByte(CChar value)
210 | {
211 | return value.Value;
212 | }
213 |
214 | ///
215 | public override string ToString()
216 | {
217 | return Value.ToString(CultureInfo.InvariantCulture);
218 | }
219 |
220 | ///
221 | public override bool Equals(object? obj)
222 | {
223 | return obj is CChar value && Equals(value);
224 | }
225 |
226 | ///
227 | public bool Equals(byte other)
228 | {
229 | return Value == other;
230 | }
231 |
232 | ///
233 | public bool Equals(CChar other)
234 | {
235 | return Value == other.Value;
236 | }
237 |
238 | ///
239 | public override int GetHashCode()
240 | {
241 | return Value.GetHashCode();
242 | }
243 |
244 | ///
245 | /// Returns a value that indicates whether two specified structures are equal.
246 | ///
247 | /// The first to compare.
248 | /// The second to compare.
249 | /// true if and are equal; otherwise, false.
250 | public static bool operator ==(CChar left, CChar right)
251 | {
252 | return left.Value == right.Value;
253 | }
254 |
255 | ///
256 | /// Returns a value that indicates whether two specified structures are not equal.
257 | ///
258 | /// The first to compare.
259 | /// The second to compare.
260 | /// true if and are not equal; otherwise, false.
261 | public static bool operator !=(CChar left, CChar right)
262 | {
263 | return !(left == right);
264 | }
265 |
266 | ///
267 | /// Returns a value that indicates whether two specified structures are equal.
268 | ///
269 | /// The first to compare.
270 | /// The second to compare.
271 | /// true if and are equal; otherwise, false.
272 | public static bool Equals(CChar left, CChar right)
273 | {
274 | return left.Value == right.Value;
275 | }
276 | }
277 |
278 | ///
279 | /// A pointer value type of bytes that represent a string; the C type `char*`.
280 | ///
281 | [StructLayout(LayoutKind.Sequential)]
282 | public readonly unsafe struct CString : IEquatable, IDisposable
283 | {
284 | public readonly nint Pointer;
285 |
286 | ///
287 | /// Gets a value indicating whether this is a null pointer.
288 | ///
289 | public bool IsNull => Pointer == 0;
290 |
291 | ///
292 | /// Initializes a new instance of the struct.
293 | ///
294 | /// The pointer value.
295 | public CString(byte* value)
296 | {
297 | Pointer = (nint)value;
298 | }
299 |
300 | ///
301 | /// Initializes a new instance of the struct.
302 | ///
303 | /// The pointer value.
304 | public CString(nint value)
305 | {
306 | Pointer = value;
307 | }
308 |
309 | ///
310 | /// Initializes a new instance of the struct.
311 | ///
312 | /// The string value.
313 | public CString(string s)
314 | {
315 | Pointer = FromString(s).Pointer;
316 | }
317 |
318 | ///
319 | /// Attempts to free the memory pointed by the .
320 | ///
321 | public void Dispose()
322 | {
323 | Marshal.FreeHGlobal(Pointer);
324 | }
325 |
326 | ///
327 | /// Performs an explicit conversion from an to a .
328 | ///
329 | /// The pointer value.
330 | ///
331 | /// The resulting .
332 | ///
333 | public static explicit operator CString(nint value)
334 | {
335 | return FromIntPtr(value);
336 | }
337 |
338 | ///
339 | /// Performs an explicit conversion from an to a .
340 | ///
341 | /// The pointer value.
342 | ///
343 | /// The resulting .
344 | ///
345 | public static CString FromIntPtr(nint value)
346 | {
347 | return new CString(value);
348 | }
349 |
350 | ///
351 | /// Performs an implicit conversion from a byte pointer to a .
352 | ///
353 | /// The pointer value.
354 | ///
355 | /// The resulting .
356 | ///
357 | public static implicit operator CString(byte* value)
358 | {
359 | return From(value);
360 | }
361 |
362 | ///
363 | /// Performs an implicit conversion from a byte pointer to a .
364 | ///
365 | /// The pointer value.
366 | ///
367 | /// The resulting .
368 | ///
369 | public static CString From(byte* value)
370 | {
371 | return new CString((nint)value);
372 | }
373 |
374 | ///
375 | /// Performs an implicit conversion from a to a .
376 | ///
377 | /// The pointer.
378 | ///
379 | /// The resulting .
380 | ///
381 | public static implicit operator nint(CString value)
382 | {
383 | return value.Pointer;
384 | }
385 |
386 | ///
387 | /// Performs an implicit conversion from a to a .
388 | ///
389 | /// The pointer.
390 | ///
391 | /// The resulting .
392 | ///
393 | public static nint ToIntPtr(CString value)
394 | {
395 | return value.Pointer;
396 | }
397 |
398 | ///
399 | /// Performs an explicit conversion from a to a .
400 | ///
401 | /// The .
402 | ///
403 | /// The resulting .
404 | ///
405 | public static explicit operator string(CString value)
406 | {
407 | return ToString(value);
408 | }
409 |
410 | ///
411 | /// Converts a C style string (ANSI or UTF-8) of type `char` (one dimensional byte array
412 | /// terminated by a 0x0) to a UTF-16 by allocating and copying.
413 | ///
414 | /// A pointer to the C string.
415 | /// A equivalent of .
416 | public static string ToString(CString value)
417 | {
418 | if (value.IsNull)
419 | {
420 | return string.Empty;
421 | }
422 |
423 | // calls ASM/C/C++ functions to calculate length and then "FastAllocate" the string with the GC
424 | // https://mattwarren.org/2016/05/31/Strings-and-the-CLR-a-Special-Relationship/
425 | var result = Marshal.PtrToStringAnsi(value.Pointer);
426 |
427 | if (string.IsNullOrEmpty(result))
428 | {
429 | return string.Empty;
430 | }
431 |
432 | return result;
433 | }
434 |
435 | ///
436 | /// Performs an explicit conversion from a to a .
437 | ///
438 | /// The .
439 | ///
440 | /// The resulting .
441 | ///
442 | public static explicit operator CString(string s)
443 | {
444 | return FromString(s);
445 | }
446 |
447 | ///
448 | /// Converts a UTF-16 to a C style string (one dimensional byte array terminated by a
449 | /// 0x0) by allocating and copying.
450 | ///
451 | /// The .
452 | /// A C string pointer.
453 | public static CString FromString(string str)
454 | {
455 | var pointer = Marshal.StringToHGlobalAnsi(str);
456 | return new CString(pointer);
457 | }
458 |
459 | ///
460 | public override string ToString()
461 | {
462 | return ToString(this);
463 | }
464 |
465 | ///
466 | public override bool Equals(object? obj)
467 | {
468 | return obj is CString value && Equals(value);
469 | }
470 |
471 | ///
472 | public bool Equals(CString other)
473 | {
474 | return Pointer == other.Pointer;
475 | }
476 |
477 | ///
478 | public override int GetHashCode()
479 | {
480 | return Pointer.GetHashCode();
481 | }
482 |
483 | ///
484 | /// Returns a value that indicates whether two specified structures are equal.
485 | ///
486 | /// The first to compare.
487 | /// The second to compare.
488 | /// true if and are equal; otherwise, false.
489 | public static bool operator ==(CString left, CString right)
490 | {
491 | return left.Pointer == right.Pointer;
492 | }
493 |
494 | ///
495 | /// Returns a value that indicates whether two specified structures are not equal.
496 | ///
497 | /// The first to compare.
498 | /// The second to compare.
499 | /// true if and are not equal; otherwise, false.
500 | public static bool operator !=(CString left, CString right)
501 | {
502 | return !(left == right);
503 | }
504 | }
505 |
506 | ///
507 | /// Utility methods for interoperability with C style strings in C#.
508 | ///
509 | public static unsafe class CStrings
510 | {
511 | ///
512 | /// Converts an array of strings to an array of C strings of type `char` (multi-dimensional array of one
513 | /// dimensional byte arrays each terminated by a 0x0) by allocating and copying if not already cached.
514 | ///
515 | ///
516 | /// Calls .
517 | ///
518 | /// The strings.
519 | /// An array pointer of C string pointers. You are responsible for freeing the returned pointer.
520 | public static CString* CStringArray(ReadOnlySpan values)
521 | {
522 | var pointerSize = IntPtr.Size;
523 | var result = (CString*)Marshal.AllocHGlobal(pointerSize * values.Length);
524 | for (var i = 0; i < values.Length; ++i)
525 | {
526 | var @string = values[i];
527 | var cString = CString.FromString(@string);
528 | result[i] = cString;
529 | }
530 |
531 | return result;
532 | }
533 |
534 | ///
535 | /// Converts an array of strings to an array of C strings of type `wchar_t` (multi-dimensional array of one
536 | /// dimensional ushort arrays each terminated by a 0x0) by allocating and copying if not already cached.
537 | ///
538 | ///
539 | /// Calls .
540 | ///
541 | /// The strings.
542 | /// An array pointer of C string pointers. You are responsible for freeing the returned pointer.
543 | public static CStringWide* CStringWideArray(ReadOnlySpan values)
544 | {
545 | var pointerSize = IntPtr.Size;
546 | var result = (CStringWide*)Marshal.AllocHGlobal(pointerSize * values.Length);
547 | for (var i = 0; i < values.Length; ++i)
548 | {
549 | var @string = values[i];
550 | var cString = CStringWide.FromString(@string);
551 | result[i] = cString;
552 | }
553 |
554 | return result;
555 | }
556 | }
557 |
558 | ///
559 | /// A pointer value type that represents a wide string; C type `wchar_t*`.
560 | ///
561 | [StructLayout(LayoutKind.Sequential)]
562 | public readonly unsafe struct CStringWide : IEquatable
563 | {
564 | public readonly nint Pointer;
565 |
566 | ///
567 | /// Gets a value indicating whether this is a null pointer.
568 | ///
569 | public bool IsNull => Pointer == 0;
570 |
571 | ///
572 | /// Initializes a new instance of the struct.
573 | ///
574 | /// The pointer value.
575 | public CStringWide(byte* value)
576 | {
577 | Pointer = (nint)value;
578 | }
579 |
580 | ///
581 | /// Initializes a new instance of the struct.
582 | ///
583 | /// The pointer value.
584 | public CStringWide(nint value)
585 | {
586 | Pointer = value;
587 | }
588 |
589 | ///
590 | /// Initializes a new instance of the struct.
591 | ///
592 | /// The string value.
593 | public CStringWide(string s)
594 | {
595 | Pointer = FromString(s).Pointer;
596 | }
597 |
598 | ///
599 | /// Performs an explicit conversion from a to a .
600 | ///
601 | /// The pointer value.
602 | ///
603 | /// The resulting .
604 | ///
605 | public static explicit operator CStringWide(nint value)
606 | {
607 | return FromIntPtr(value);
608 | }
609 |
610 | ///
611 | /// Performs an explicit conversion from a to a .
612 | ///
613 | /// The pointer value.
614 | ///
615 | /// The resulting .
616 | ///
617 | public static CStringWide FromIntPtr(nint value)
618 | {
619 | return new CStringWide(value);
620 | }
621 |
622 | ///
623 | /// Performs an implicit conversion from a byte pointer to a .
624 | ///
625 | /// The pointer value.
626 | ///
627 | /// The resulting .
628 | ///
629 | public static implicit operator CStringWide(byte* value)
630 | {
631 | return From(value);
632 | }
633 |
634 | ///
635 | /// Performs an implicit conversion from a byte pointer to a .
636 | ///
637 | /// The pointer value.
638 | ///
639 | /// The resulting .
640 | ///
641 | public static CStringWide From(byte* value)
642 | {
643 | return new CStringWide((nint)value);
644 | }
645 |
646 | ///
647 | /// Performs an implicit conversion from a to a .
648 | ///
649 | /// The pointer.
650 | ///
651 | /// The resulting .
652 | ///
653 | public static implicit operator nint(CStringWide value)
654 | {
655 | return value.Pointer;
656 | }
657 |
658 | ///
659 | /// Performs an implicit conversion from a to a .
660 | ///
661 | /// The pointer.
662 | ///
663 | /// The resulting .
664 | ///
665 | public static nint ToIntPtr(CStringWide value)
666 | {
667 | return value.Pointer;
668 | }
669 |
670 | ///
671 | /// Performs an explicit conversion from a to a .
672 | ///
673 | /// The .
674 | ///
675 | /// The resulting .
676 | ///
677 | public static explicit operator string(CStringWide value)
678 | {
679 | return ToString(value);
680 | }
681 |
682 | ///
683 | /// Converts a C style string (unicode) of type `wchar_t` (one dimensional ushort array
684 | /// terminated by a 0x0) to a UTF-16 by allocating and copying.
685 | ///
686 | /// A pointer to the C string.
687 | /// A equivalent of .
688 | public static string ToString(CStringWide value)
689 | {
690 | if (value.IsNull)
691 | {
692 | return string.Empty;
693 | }
694 |
695 | // calls ASM/C/C++ functions to calculate length and then "FastAllocate" the string with the GC
696 | // https://mattwarren.org/2016/05/31/Strings-and-the-CLR-a-Special-Relationship/
697 | var result = Marshal.PtrToStringUni(value.Pointer);
698 |
699 | if (string.IsNullOrEmpty(result))
700 | {
701 | return string.Empty;
702 | }
703 |
704 | return result;
705 | }
706 |
707 | ///
708 | /// Performs an explicit conversion from a to a .
709 | ///
710 | /// The .
711 | ///
712 | /// The resulting .
713 | ///
714 | public static explicit operator CStringWide(string s)
715 | {
716 | return FromString(s);
717 | }
718 |
719 | ///
720 | /// Converts a C string pointer (one dimensional byte array terminated by a
721 | /// 0x0) for a specified by allocating and copying if not already cached.
722 | ///
723 | /// The .
724 | /// A C string pointer.
725 | public static CStringWide FromString(string str)
726 | {
727 | var pointer = Marshal.StringToHGlobalUni(str);
728 | return new CStringWide(pointer);
729 | }
730 |
731 | ///
732 | public override string ToString()
733 | {
734 | return ToString(this);
735 | }
736 |
737 | ///
738 | public override bool Equals(object? obj)
739 | {
740 | return obj is CStringWide value && Equals(value);
741 | }
742 |
743 | ///
744 | public bool Equals(CStringWide other)
745 | {
746 | return Pointer == other.Pointer;
747 | }
748 |
749 | ///
750 | public override int GetHashCode()
751 | {
752 | return Pointer.GetHashCode();
753 | }
754 |
755 | ///
756 | /// Returns a value that indicates whether two specified structures are equal.
757 | ///
758 | /// The first to compare.
759 | /// The second to compare.
760 | /// true if and are equal; otherwise, false.
761 | public static bool operator ==(CStringWide left, CStringWide right)
762 | {
763 | return left.Pointer == right.Pointer;
764 | }
765 |
766 | ///
767 | /// Returns a value that indicates whether two specified structures are not equal.
768 | ///
769 | /// The first to compare.
770 | /// The second to compare.
771 | /// true if and are not equal; otherwise, false.
772 | public static bool operator !=(CStringWide left, CStringWide right)
773 | {
774 | return !(left == right);
775 | }
776 |
777 | ///
778 | /// Returns a value that indicates whether two specified structures are equal.
779 | ///
780 | /// The first to compare.
781 | /// The second to compare.
782 | /// true if and are equal; otherwise, false.
783 | public static bool Equals(CStringWide left, CStringWide right)
784 | {
785 | return left.Pointer == right.Pointer;
786 | }
787 | }
788 |
--------------------------------------------------------------------------------
/src/cs/production/Tracy/Tracy.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | net6.0
6 | enable
7 |
8 | true
9 |
10 |
11 |
12 |
13 | true
14 | tracy-csharp-godot
15 | C# interop bindings for https://github.com/wolfpld/tracy made to work with Godot.
16 | https://github.com/Synthetic-Dev/tracy-csharp-godot
17 | MIT
18 | _README_PACKAGE.md
19 |
20 |
21 |
22 |
23 | true
24 | /
25 | PreserveNewest
26 |
27 |
28 |
29 |
30 |
31 | %(Filename)%(Extension)
32 | runtimes/win-x64/native/%(Filename)%(Extension)
33 | true
34 | PreserveNewest
35 |
36 |
37 |
38 |
39 |
40 | %(Filename)%(Extension)
41 | runtimes/linux-x64/native/%(Filename)%(Extension)
42 | true
43 | PreserveNewest
44 |
45 |
46 |
47 |
48 | %(Filename)%(Extension)
49 | runtimes/osx/native/%(Filename)%(Extension)
50 | true
51 | PreserveNewest
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/src/cs/production/Tracy/_README_PACKAGE.md:
--------------------------------------------------------------------------------
1 | # Tracy CSharp for Godot
2 |
3 | > This is a fork of [Tracy-CSharp](https://github.com/clibequilibrium/Tracy-CSharp) made to work with .NET 6 and Godot
4 |
5 | C# bindings for https://github.com/wolfpld/tracy with native dynamic link libraries based on [`imgui-cs`](https://github.com/bottlenoselabs/imgui-cs).
6 |
7 | ## How to use
8 |
9 | See the [sample C# project](https://github.com/Synthetic-Dev/tracy-csharp-godot/tree/main/src/cs/samples/HelloWorld)
10 |
11 | ```cs
12 | using (Profiler.BeginEvent())
13 | {
14 | // Code to profile
15 | }
16 | Profiler.ProfileFrame("Main"); // Put this after you have completed rendering the frame.
17 | // Ideally that would be right after the swap buffers command.
18 | // Note that this step is optional, as some applications
19 | // (for example: a compression utility)
20 | // do not have the concept of a frame
21 | ```
22 |
23 | ## Developers: Documentation
24 |
25 | For more information on how C# bindings work, see [`C2CS`](https://github.com/lithiumtoast/c2cs), the tool that generates the bindings for `Tracy` and other C libraries.
26 |
27 | To learn how to use `Tracy`, check out the [official readme](https://github.com/wolfpld/tracy).
28 |
29 | All of the C# bindings can be found in [the generated file `PInvoke.gen.cs`](https://github.com/Synthetic-Dev/tracy-csharp-godot/blob/main/src/cs/production/Tracy/Generated/PInvoke.gen.cs)
30 |
31 | ## License
32 |
33 | `Tracy-CSharp` is licensed under the MIT License (`MIT`) - see the [LICENSE file](LICENSE) for details.
34 |
35 | `Tracy` itself is licensed under BSD license (`BSD`) - see https://github.com/wolfpld/tracy/blob/master/LICENSE for more details.
36 |
--------------------------------------------------------------------------------
/src/cs/samples/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/src/cs/samples/Directory.Build.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/src/cs/samples/HelloWorld/HelloWorld.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 | true
7 | false
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/cs/samples/HelloWorld/Profiler.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.Runtime.CompilerServices;
5 | using bottlenoselabs.C2CS.Runtime;
6 | using static Tracy.PInvoke;
7 |
8 | public static class Profiler
9 | {
10 | private static Dictionary> tracyAllocationsDictionary = new();
11 | private static CString frameName;
12 |
13 | public struct ProfilerScope : IDisposable
14 | {
15 | private TracyCZoneCtx ctx;
16 |
17 | public ProfilerScope(TracyCZoneCtx ctx)
18 | {
19 | this.ctx = ctx;
20 | }
21 |
22 | public readonly void Dispose()
23 | {
24 | TracyEmitZoneEnd(ctx);
25 | }
26 | }
27 |
28 | public static ProfilerScope BeginEvent([CallerMemberName] string functionName = "", ColorType colorType = default,
29 | [CallerFilePath] string scriptPath = "",
30 | [CallerLineNumber] int lineNumber = 0)
31 | {
32 | if (!tracyAllocationsDictionary.TryGetValue(functionName, out var tuple))
33 | {
34 | var source = (CString)scriptPath;
35 | var function = (CString)functionName;
36 |
37 | tuple = new Tuple(source, function);
38 | tracyAllocationsDictionary.Add(functionName, tuple);
39 | }
40 |
41 | var srcLoc = TracyAllocSrcloc((uint)lineNumber, tuple.Item1, (ulong)scriptPath.Length, tuple.Item2, (ulong)functionName.Length);
42 | var ctx = TracyEmitZoneBeginAlloc(srcLoc, 1);
43 |
44 | if (colorType != default)
45 | {
46 | TracyEmitZoneColor(ctx, (uint)colorType);
47 | }
48 |
49 | return new ProfilerScope(ctx);
50 | }
51 |
52 | public static void ProfileFrame(string name)
53 | {
54 | if (frameName == default)
55 | frameName = (CString)name;
56 |
57 | TracyEmitFrameMark(frameName);
58 | }
59 |
60 | public static void Dispose()
61 | {
62 | // Free CStrings
63 | foreach (var kvp in tracyAllocationsDictionary)
64 | {
65 | kvp.Value.Item1.Dispose();
66 | kvp.Value.Item2.Dispose();
67 | }
68 | }
69 |
70 | public enum ColorType : uint
71 | {
72 | Snow = 0xfffafa,
73 | GhostWhite = 0xf8f8ff,
74 | WhiteSmoke = 0xf5f5f5,
75 | Gainsboro = 0xdcdcdc,
76 | FloralWhite = 0xfffaf0,
77 | OldLace = 0xfdf5e6,
78 | Linen = 0xfaf0e6,
79 | AntiqueWhite = 0xfaebd7,
80 | PapayaWhip = 0xffefd5,
81 | BlanchedAlmond = 0xffebcd,
82 | Bisque = 0xffe4c4,
83 | PeachPuff = 0xffdab9,
84 | NavajoWhite = 0xffdead,
85 | Moccasin = 0xffe4b5,
86 | Cornsilk = 0xfff8dc,
87 | Ivory = 0xfffff0,
88 | LemonChiffon = 0xfffacd,
89 | Seashell = 0xfff5ee,
90 | Honeydew = 0xf0fff0,
91 | MintCream = 0xf5fffa,
92 | Azure = 0xf0ffff,
93 | AliceBlue = 0xf0f8ff,
94 | Lavender = 0xe6e6fa,
95 | LavenderBlush = 0xfff0f5,
96 | MistyRose = 0xffe4e1,
97 | White = 0xffffff,
98 | Black = 0x000000,
99 | DarkSlateGray = 0x2f4f4f,
100 | DarkSlateGrey = 0x2f4f4f,
101 | DimGray = 0x696969,
102 | DimGrey = 0x696969,
103 | SlateGray = 0x708090,
104 | SlateGrey = 0x708090,
105 | LightSlateGray = 0x778899,
106 | LightSlateGrey = 0x778899,
107 | Gray = 0xbebebe,
108 | Grey = 0xbebebe,
109 | X11Gray = 0xbebebe,
110 | X11Grey = 0xbebebe,
111 | WebGray = 0x808080,
112 | WebGrey = 0x808080,
113 | LightGrey = 0xd3d3d3,
114 | LightGray = 0xd3d3d3,
115 | MidnightBlue = 0x191970,
116 | Navy = 0x000080,
117 | NavyBlue = 0x000080,
118 | CornflowerBlue = 0x6495ed,
119 | DarkSlateBlue = 0x483d8b,
120 | SlateBlue = 0x6a5acd,
121 | MediumSlateBlue = 0x7b68ee,
122 | LightSlateBlue = 0x8470ff,
123 | MediumBlue = 0x0000cd,
124 | RoyalBlue = 0x4169e1,
125 | Blue = 0x0000ff,
126 | DodgerBlue = 0x1e90ff,
127 | DeepSkyBlue = 0x00bfff,
128 | SkyBlue = 0x87ceeb,
129 | LightSkyBlue = 0x87cefa,
130 | SteelBlue = 0x4682b4,
131 | LightSteelBlue = 0xb0c4de,
132 | LightBlue = 0xadd8e6,
133 | PowderBlue = 0xb0e0e6,
134 | PaleTurquoise = 0xafeeee,
135 | DarkTurquoise = 0x00ced1,
136 | MediumTurquoise = 0x48d1cc,
137 | Turquoise = 0x40e0d0,
138 | Cyan = 0x00ffff,
139 | Aqua = 0x00ffff,
140 | LightCyan = 0xe0ffff,
141 | CadetBlue = 0x5f9ea0,
142 | MediumAquamarine = 0x66cdaa,
143 | Aquamarine = 0x7fffd4,
144 | DarkGreen = 0x006400,
145 | DarkOliveGreen = 0x556b2f,
146 | DarkSeaGreen = 0x8fbc8f,
147 | SeaGreen = 0x2e8b57,
148 | MediumSeaGreen = 0x3cb371,
149 | LightSeaGreen = 0x20b2aa,
150 | PaleGreen = 0x98fb98,
151 | SpringGreen = 0x00ff7f,
152 | LawnGreen = 0x7cfc00,
153 | Green = 0x00ff00,
154 | Lime = 0x00ff00,
155 | X11Green = 0x00ff00,
156 | WebGreen = 0x008000,
157 | Chartreuse = 0x7fff00,
158 | MediumSpringGreen = 0x00fa9a,
159 | GreenYellow = 0xadff2f,
160 | LimeGreen = 0x32cd32,
161 | YellowGreen = 0x9acd32,
162 | ForestGreen = 0x228b22,
163 | OliveDrab = 0x6b8e23,
164 | DarkKhaki = 0xbdb76b,
165 | Khaki = 0xf0e68c,
166 | PaleGoldenrod = 0xeee8aa,
167 | LightGoldenrodYellow = 0xfafad2,
168 | LightYellow = 0xffffe0,
169 | Yellow = 0xffff00,
170 | Gold = 0xffd700,
171 | LightGoldenrod = 0xeedd82,
172 | Goldenrod = 0xdaa520,
173 | DarkGoldenrod = 0xb8860b,
174 | RosyBrown = 0xbc8f8f,
175 | IndianRed = 0xcd5c5c,
176 | SaddleBrown = 0x8b4513,
177 | Sienna = 0xa0522d,
178 | Peru = 0xcd853f,
179 | Burlywood = 0xdeb887,
180 | Beige = 0xf5f5dc,
181 | Wheat = 0xf5deb3,
182 | SandyBrown = 0xf4a460,
183 | Tan = 0xd2b48c,
184 | Chocolate = 0xd2691e,
185 | Firebrick = 0xb22222,
186 | Brown = 0xa52a2a,
187 | DarkSalmon = 0xe9967a,
188 | Salmon = 0xfa8072,
189 | LightSalmon = 0xffa07a,
190 | Orange = 0xffa500,
191 | DarkOrange = 0xff8c00,
192 | Coral = 0xff7f50,
193 | LightCoral = 0xf08080,
194 | Tomato = 0xff6347,
195 | OrangeRed = 0xff4500,
196 | Red = 0xff0000,
197 | HotPink = 0xff69b4,
198 | DeepPink = 0xff1493,
199 | Pink = 0xffc0cb,
200 | LightPink = 0xffb6c1,
201 | PaleVioletRed = 0xdb7093,
202 | Maroon = 0xb03060,
203 | X11Maroon = 0xb03060,
204 | WebMaroon = 0x800000,
205 | MediumVioletRed = 0xc71585,
206 | VioletRed = 0xd02090,
207 | Magenta = 0xff00ff,
208 | Fuchsia = 0xff00ff,
209 | Violet = 0xee82ee,
210 | Plum = 0xdda0dd,
211 | Orchid = 0xda70d6,
212 | MediumOrchid = 0xba55d3,
213 | DarkOrchid = 0x9932cc,
214 | DarkViolet = 0x9400d3,
215 | BlueViolet = 0x8a2be2,
216 | Purple = 0xa020f0,
217 | X11Purple = 0xa020f0,
218 | WebPurple = 0x800080,
219 | MediumPurple = 0x9370db,
220 | Thistle = 0xd8bfd8,
221 | Snow1 = 0xfffafa,
222 | Snow2 = 0xeee9e9,
223 | Snow3 = 0xcdc9c9,
224 | Snow4 = 0x8b8989,
225 | Seashell1 = 0xfff5ee,
226 | Seashell2 = 0xeee5de,
227 | Seashell3 = 0xcdc5bf,
228 | Seashell4 = 0x8b8682,
229 | AntiqueWhite1 = 0xffefdb,
230 | AntiqueWhite2 = 0xeedfcc,
231 | AntiqueWhite3 = 0xcdc0b0,
232 | AntiqueWhite4 = 0x8b8378,
233 | Bisque1 = 0xffe4c4,
234 | Bisque2 = 0xeed5b7,
235 | Bisque3 = 0xcdb79e,
236 | Bisque4 = 0x8b7d6b,
237 | PeachPuff1 = 0xffdab9,
238 | PeachPuff2 = 0xeecbad,
239 | PeachPuff3 = 0xcdaf95,
240 | PeachPuff4 = 0x8b7765,
241 | NavajoWhite1 = 0xffdead,
242 | NavajoWhite2 = 0xeecfa1,
243 | NavajoWhite3 = 0xcdb38b,
244 | NavajoWhite4 = 0x8b795e,
245 | LemonChiffon1 = 0xfffacd,
246 | LemonChiffon2 = 0xeee9bf,
247 | LemonChiffon3 = 0xcdc9a5,
248 | LemonChiffon4 = 0x8b8970,
249 | Cornsilk1 = 0xfff8dc,
250 | Cornsilk2 = 0xeee8cd,
251 | Cornsilk3 = 0xcdc8b1,
252 | Cornsilk4 = 0x8b8878,
253 | Ivory1 = 0xfffff0,
254 | Ivory2 = 0xeeeee0,
255 | Ivory3 = 0xcdcdc1,
256 | Ivory4 = 0x8b8b83,
257 | Honeydew1 = 0xf0fff0,
258 | Honeydew2 = 0xe0eee0,
259 | Honeydew3 = 0xc1cdc1,
260 | Honeydew4 = 0x838b83,
261 | LavenderBlush1 = 0xfff0f5,
262 | LavenderBlush2 = 0xeee0e5,
263 | LavenderBlush3 = 0xcdc1c5,
264 | LavenderBlush4 = 0x8b8386,
265 | MistyRose1 = 0xffe4e1,
266 | MistyRose2 = 0xeed5d2,
267 | MistyRose3 = 0xcdb7b5,
268 | MistyRose4 = 0x8b7d7b,
269 | Azure1 = 0xf0ffff,
270 | Azure2 = 0xe0eeee,
271 | Azure3 = 0xc1cdcd,
272 | Azure4 = 0x838b8b,
273 | SlateBlue1 = 0x836fff,
274 | SlateBlue2 = 0x7a67ee,
275 | SlateBlue3 = 0x6959cd,
276 | SlateBlue4 = 0x473c8b,
277 | RoyalBlue1 = 0x4876ff,
278 | RoyalBlue2 = 0x436eee,
279 | RoyalBlue3 = 0x3a5fcd,
280 | RoyalBlue4 = 0x27408b,
281 | Blue1 = 0x0000ff,
282 | Blue2 = 0x0000ee,
283 | Blue3 = 0x0000cd,
284 | Blue4 = 0x00008b,
285 | DodgerBlue1 = 0x1e90ff,
286 | DodgerBlue2 = 0x1c86ee,
287 | DodgerBlue3 = 0x1874cd,
288 | DodgerBlue4 = 0x104e8b,
289 | SteelBlue1 = 0x63b8ff,
290 | SteelBlue2 = 0x5cacee,
291 | SteelBlue3 = 0x4f94cd,
292 | SteelBlue4 = 0x36648b,
293 | DeepSkyBlue1 = 0x00bfff,
294 | DeepSkyBlue2 = 0x00b2ee,
295 | DeepSkyBlue3 = 0x009acd,
296 | DeepSkyBlue4 = 0x00688b,
297 | SkyBlue1 = 0x87ceff,
298 | SkyBlue2 = 0x7ec0ee,
299 | SkyBlue3 = 0x6ca6cd,
300 | SkyBlue4 = 0x4a708b,
301 | LightSkyBlue1 = 0xb0e2ff,
302 | LightSkyBlue2 = 0xa4d3ee,
303 | LightSkyBlue3 = 0x8db6cd,
304 | LightSkyBlue4 = 0x607b8b,
305 | SlateGray1 = 0xc6e2ff,
306 | SlateGray2 = 0xb9d3ee,
307 | SlateGray3 = 0x9fb6cd,
308 | SlateGray4 = 0x6c7b8b,
309 | LightSteelBlue1 = 0xcae1ff,
310 | LightSteelBlue2 = 0xbcd2ee,
311 | LightSteelBlue3 = 0xa2b5cd,
312 | LightSteelBlue4 = 0x6e7b8b,
313 | LightBlue1 = 0xbfefff,
314 | LightBlue2 = 0xb2dfee,
315 | LightBlue3 = 0x9ac0cd,
316 | LightBlue4 = 0x68838b,
317 | LightCyan1 = 0xe0ffff,
318 | LightCyan2 = 0xd1eeee,
319 | LightCyan3 = 0xb4cdcd,
320 | LightCyan4 = 0x7a8b8b,
321 | PaleTurquoise1 = 0xbbffff,
322 | PaleTurquoise2 = 0xaeeeee,
323 | PaleTurquoise3 = 0x96cdcd,
324 | PaleTurquoise4 = 0x668b8b,
325 | CadetBlue1 = 0x98f5ff,
326 | CadetBlue2 = 0x8ee5ee,
327 | CadetBlue3 = 0x7ac5cd,
328 | CadetBlue4 = 0x53868b,
329 | Turquoise1 = 0x00f5ff,
330 | Turquoise2 = 0x00e5ee,
331 | Turquoise3 = 0x00c5cd,
332 | Turquoise4 = 0x00868b,
333 | Cyan1 = 0x00ffff,
334 | Cyan2 = 0x00eeee,
335 | Cyan3 = 0x00cdcd,
336 | Cyan4 = 0x008b8b,
337 | DarkSlateGray1 = 0x97ffff,
338 | DarkSlateGray2 = 0x8deeee,
339 | DarkSlateGray3 = 0x79cdcd,
340 | DarkSlateGray4 = 0x528b8b,
341 | Aquamarine1 = 0x7fffd4,
342 | Aquamarine2 = 0x76eec6,
343 | Aquamarine3 = 0x66cdaa,
344 | Aquamarine4 = 0x458b74,
345 | DarkSeaGreen1 = 0xc1ffc1,
346 | DarkSeaGreen2 = 0xb4eeb4,
347 | DarkSeaGreen3 = 0x9bcd9b,
348 | DarkSeaGreen4 = 0x698b69,
349 | SeaGreen1 = 0x54ff9f,
350 | SeaGreen2 = 0x4eee94,
351 | SeaGreen3 = 0x43cd80,
352 | SeaGreen4 = 0x2e8b57,
353 | PaleGreen1 = 0x9aff9a,
354 | PaleGreen2 = 0x90ee90,
355 | PaleGreen3 = 0x7ccd7c,
356 | PaleGreen4 = 0x548b54,
357 | SpringGreen1 = 0x00ff7f,
358 | SpringGreen2 = 0x00ee76,
359 | SpringGreen3 = 0x00cd66,
360 | SpringGreen4 = 0x008b45,
361 | Green1 = 0x00ff00,
362 | Green2 = 0x00ee00,
363 | Green3 = 0x00cd00,
364 | Green4 = 0x008b00,
365 | Chartreuse1 = 0x7fff00,
366 | Chartreuse2 = 0x76ee00,
367 | Chartreuse3 = 0x66cd00,
368 | Chartreuse4 = 0x458b00,
369 | OliveDrab1 = 0xc0ff3e,
370 | OliveDrab2 = 0xb3ee3a,
371 | OliveDrab3 = 0x9acd32,
372 | OliveDrab4 = 0x698b22,
373 | DarkOliveGreen1 = 0xcaff70,
374 | DarkOliveGreen2 = 0xbcee68,
375 | DarkOliveGreen3 = 0xa2cd5a,
376 | DarkOliveGreen4 = 0x6e8b3d,
377 | Khaki1 = 0xfff68f,
378 | Khaki2 = 0xeee685,
379 | Khaki3 = 0xcdc673,
380 | Khaki4 = 0x8b864e,
381 | LightGoldenrod1 = 0xffec8b,
382 | LightGoldenrod2 = 0xeedc82,
383 | LightGoldenrod3 = 0xcdbe70,
384 | LightGoldenrod4 = 0x8b814c,
385 | LightYellow1 = 0xffffe0,
386 | LightYellow2 = 0xeeeed1,
387 | LightYellow3 = 0xcdcdb4,
388 | LightYellow4 = 0x8b8b7a,
389 | Yellow1 = 0xffff00,
390 | Yellow2 = 0xeeee00,
391 | Yellow3 = 0xcdcd00,
392 | Yellow4 = 0x8b8b00,
393 | Gold1 = 0xffd700,
394 | Gold2 = 0xeec900,
395 | Gold3 = 0xcdad00,
396 | Gold4 = 0x8b7500,
397 | Goldenrod1 = 0xffc125,
398 | Goldenrod2 = 0xeeb422,
399 | Goldenrod3 = 0xcd9b1d,
400 | Goldenrod4 = 0x8b6914,
401 | DarkGoldenrod1 = 0xffb90f,
402 | DarkGoldenrod2 = 0xeead0e,
403 | DarkGoldenrod3 = 0xcd950c,
404 | DarkGoldenrod4 = 0x8b6508,
405 | RosyBrown1 = 0xffc1c1,
406 | RosyBrown2 = 0xeeb4b4,
407 | RosyBrown3 = 0xcd9b9b,
408 | RosyBrown4 = 0x8b6969,
409 | IndianRed1 = 0xff6a6a,
410 | IndianRed2 = 0xee6363,
411 | IndianRed3 = 0xcd5555,
412 | IndianRed4 = 0x8b3a3a,
413 | Sienna1 = 0xff8247,
414 | Sienna2 = 0xee7942,
415 | Sienna3 = 0xcd6839,
416 | Sienna4 = 0x8b4726,
417 | Burlywood1 = 0xffd39b,
418 | Burlywood2 = 0xeec591,
419 | Burlywood3 = 0xcdaa7d,
420 | Burlywood4 = 0x8b7355,
421 | Wheat1 = 0xffe7ba,
422 | Wheat2 = 0xeed8ae,
423 | Wheat3 = 0xcdba96,
424 | Wheat4 = 0x8b7e66,
425 | Tan1 = 0xffa54f,
426 | Tan2 = 0xee9a49,
427 | Tan3 = 0xcd853f,
428 | Tan4 = 0x8b5a2b,
429 | Chocolate1 = 0xff7f24,
430 | Chocolate2 = 0xee7621,
431 | Chocolate3 = 0xcd661d,
432 | Chocolate4 = 0x8b4513,
433 | Firebrick1 = 0xff3030,
434 | Firebrick2 = 0xee2c2c,
435 | Firebrick3 = 0xcd2626,
436 | Firebrick4 = 0x8b1a1a,
437 | Brown1 = 0xff4040,
438 | Brown2 = 0xee3b3b,
439 | Brown3 = 0xcd3333,
440 | Brown4 = 0x8b2323,
441 | Salmon1 = 0xff8c69,
442 | Salmon2 = 0xee8262,
443 | Salmon3 = 0xcd7054,
444 | Salmon4 = 0x8b4c39,
445 | LightSalmon1 = 0xffa07a,
446 | LightSalmon2 = 0xee9572,
447 | LightSalmon3 = 0xcd8162,
448 | LightSalmon4 = 0x8b5742,
449 | Orange1 = 0xffa500,
450 | Orange2 = 0xee9a00,
451 | Orange3 = 0xcd8500,
452 | Orange4 = 0x8b5a00,
453 | DarkOrange1 = 0xff7f00,
454 | DarkOrange2 = 0xee7600,
455 | DarkOrange3 = 0xcd6600,
456 | DarkOrange4 = 0x8b4500,
457 | Coral1 = 0xff7256,
458 | Coral2 = 0xee6a50,
459 | Coral3 = 0xcd5b45,
460 | Coral4 = 0x8b3e2f,
461 | Tomato1 = 0xff6347,
462 | Tomato2 = 0xee5c42,
463 | Tomato3 = 0xcd4f39,
464 | Tomato4 = 0x8b3626,
465 | OrangeRed1 = 0xff4500,
466 | OrangeRed2 = 0xee4000,
467 | OrangeRed3 = 0xcd3700,
468 | OrangeRed4 = 0x8b2500,
469 | Red1 = 0xff0000,
470 | Red2 = 0xee0000,
471 | Red3 = 0xcd0000,
472 | Red4 = 0x8b0000,
473 | DeepPink1 = 0xff1493,
474 | DeepPink2 = 0xee1289,
475 | DeepPink3 = 0xcd1076,
476 | DeepPink4 = 0x8b0a50,
477 | HotPink1 = 0xff6eb4,
478 | HotPink2 = 0xee6aa7,
479 | HotPink3 = 0xcd6090,
480 | HotPink4 = 0x8b3a62,
481 | Pink1 = 0xffb5c5,
482 | Pink2 = 0xeea9b8,
483 | Pink3 = 0xcd919e,
484 | Pink4 = 0x8b636c,
485 | LightPink1 = 0xffaeb9,
486 | LightPink2 = 0xeea2ad,
487 | LightPink3 = 0xcd8c95,
488 | LightPink4 = 0x8b5f65,
489 | PaleVioletRed1 = 0xff82ab,
490 | PaleVioletRed2 = 0xee799f,
491 | PaleVioletRed3 = 0xcd6889,
492 | PaleVioletRed4 = 0x8b475d,
493 | Maroon1 = 0xff34b3,
494 | Maroon2 = 0xee30a7,
495 | Maroon3 = 0xcd2990,
496 | Maroon4 = 0x8b1c62,
497 | VioletRed1 = 0xff3e96,
498 | VioletRed2 = 0xee3a8c,
499 | VioletRed3 = 0xcd3278,
500 | VioletRed4 = 0x8b2252,
501 | Magenta1 = 0xff00ff,
502 | Magenta2 = 0xee00ee,
503 | Magenta3 = 0xcd00cd,
504 | Magenta4 = 0x8b008b,
505 | Orchid1 = 0xff83fa,
506 | Orchid2 = 0xee7ae9,
507 | Orchid3 = 0xcd69c9,
508 | Orchid4 = 0x8b4789,
509 | Plum1 = 0xffbbff,
510 | Plum2 = 0xeeaeee,
511 | Plum3 = 0xcd96cd,
512 | Plum4 = 0x8b668b,
513 | MediumOrchid1 = 0xe066ff,
514 | MediumOrchid2 = 0xd15fee,
515 | MediumOrchid3 = 0xb452cd,
516 | MediumOrchid4 = 0x7a378b,
517 | DarkOrchid1 = 0xbf3eff,
518 | DarkOrchid2 = 0xb23aee,
519 | DarkOrchid3 = 0x9a32cd,
520 | DarkOrchid4 = 0x68228b,
521 | Purple1 = 0x9b30ff,
522 | Purple2 = 0x912cee,
523 | Purple3 = 0x7d26cd,
524 | Purple4 = 0x551a8b,
525 | MediumPurple1 = 0xab82ff,
526 | MediumPurple2 = 0x9f79ee,
527 | MediumPurple3 = 0x8968cd,
528 | MediumPurple4 = 0x5d478b,
529 | Thistle1 = 0xffe1ff,
530 | Thistle2 = 0xeed2ee,
531 | Thistle3 = 0xcdb5cd,
532 | Thistle4 = 0x8b7b8b,
533 | Gray0 = 0x000000,
534 | Grey0 = 0x000000,
535 | Gray1 = 0x030303,
536 | Grey1 = 0x030303,
537 | Gray2 = 0x050505,
538 | Grey2 = 0x050505,
539 | Gray3 = 0x080808,
540 | Grey3 = 0x080808,
541 | Gray4 = 0x0a0a0a,
542 | Grey4 = 0x0a0a0a,
543 | Gray5 = 0x0d0d0d,
544 | Grey5 = 0x0d0d0d,
545 | Gray6 = 0x0f0f0f,
546 | Grey6 = 0x0f0f0f,
547 | Gray7 = 0x121212,
548 | Grey7 = 0x121212,
549 | Gray8 = 0x141414,
550 | Grey8 = 0x141414,
551 | Gray9 = 0x171717,
552 | Grey9 = 0x171717,
553 | Gray10 = 0x1a1a1a,
554 | Grey10 = 0x1a1a1a,
555 | Gray11 = 0x1c1c1c,
556 | Grey11 = 0x1c1c1c,
557 | Gray12 = 0x1f1f1f,
558 | Grey12 = 0x1f1f1f,
559 | Gray13 = 0x212121,
560 | Grey13 = 0x212121,
561 | Gray14 = 0x242424,
562 | Grey14 = 0x242424,
563 | Gray15 = 0x262626,
564 | Grey15 = 0x262626,
565 | Gray16 = 0x292929,
566 | Grey16 = 0x292929,
567 | Gray17 = 0x2b2b2b,
568 | Grey17 = 0x2b2b2b,
569 | Gray18 = 0x2e2e2e,
570 | Grey18 = 0x2e2e2e,
571 | Gray19 = 0x303030,
572 | Grey19 = 0x303030,
573 | Gray20 = 0x333333,
574 | Grey20 = 0x333333,
575 | Gray21 = 0x363636,
576 | Grey21 = 0x363636,
577 | Gray22 = 0x383838,
578 | Grey22 = 0x383838,
579 | Gray23 = 0x3b3b3b,
580 | Grey23 = 0x3b3b3b,
581 | Gray24 = 0x3d3d3d,
582 | Grey24 = 0x3d3d3d,
583 | Gray25 = 0x404040,
584 | Grey25 = 0x404040,
585 | Gray26 = 0x424242,
586 | Grey26 = 0x424242,
587 | Gray27 = 0x454545,
588 | Grey27 = 0x454545,
589 | Gray28 = 0x474747,
590 | Grey28 = 0x474747,
591 | Gray29 = 0x4a4a4a,
592 | Grey29 = 0x4a4a4a,
593 | Gray30 = 0x4d4d4d,
594 | Grey30 = 0x4d4d4d,
595 | Gray31 = 0x4f4f4f,
596 | Grey31 = 0x4f4f4f,
597 | Gray32 = 0x525252,
598 | Grey32 = 0x525252,
599 | Gray33 = 0x545454,
600 | Grey33 = 0x545454,
601 | Gray34 = 0x575757,
602 | Grey34 = 0x575757,
603 | Gray35 = 0x595959,
604 | Grey35 = 0x595959,
605 | Gray36 = 0x5c5c5c,
606 | Grey36 = 0x5c5c5c,
607 | Gray37 = 0x5e5e5e,
608 | Grey37 = 0x5e5e5e,
609 | Gray38 = 0x616161,
610 | Grey38 = 0x616161,
611 | Gray39 = 0x636363,
612 | Grey39 = 0x636363,
613 | Gray40 = 0x666666,
614 | Grey40 = 0x666666,
615 | Gray41 = 0x696969,
616 | Grey41 = 0x696969,
617 | Gray42 = 0x6b6b6b,
618 | Grey42 = 0x6b6b6b,
619 | Gray43 = 0x6e6e6e,
620 | Grey43 = 0x6e6e6e,
621 | Gray44 = 0x707070,
622 | Grey44 = 0x707070,
623 | Gray45 = 0x737373,
624 | Grey45 = 0x737373,
625 | Gray46 = 0x757575,
626 | Grey46 = 0x757575,
627 | Gray47 = 0x787878,
628 | Grey47 = 0x787878,
629 | Gray48 = 0x7a7a7a,
630 | Grey48 = 0x7a7a7a,
631 | Gray49 = 0x7d7d7d,
632 | Grey49 = 0x7d7d7d,
633 | Gray50 = 0x7f7f7f,
634 | Grey50 = 0x7f7f7f,
635 | Gray51 = 0x828282,
636 | Grey51 = 0x828282,
637 | Gray52 = 0x858585,
638 | Grey52 = 0x858585,
639 | Gray53 = 0x878787,
640 | Grey53 = 0x878787,
641 | Gray54 = 0x8a8a8a,
642 | Grey54 = 0x8a8a8a,
643 | Gray55 = 0x8c8c8c,
644 | Grey55 = 0x8c8c8c,
645 | Gray56 = 0x8f8f8f,
646 | Grey56 = 0x8f8f8f,
647 | Gray57 = 0x919191,
648 | Grey57 = 0x919191,
649 | Gray58 = 0x949494,
650 | Grey58 = 0x949494,
651 | Gray59 = 0x969696,
652 | Grey59 = 0x969696,
653 | Gray60 = 0x999999,
654 | Grey60 = 0x999999,
655 | Gray61 = 0x9c9c9c,
656 | Grey61 = 0x9c9c9c,
657 | Gray62 = 0x9e9e9e,
658 | Grey62 = 0x9e9e9e,
659 | Gray63 = 0xa1a1a1,
660 | Grey63 = 0xa1a1a1,
661 | Gray64 = 0xa3a3a3,
662 | Grey64 = 0xa3a3a3,
663 | Gray65 = 0xa6a6a6,
664 | Grey65 = 0xa6a6a6,
665 | Gray66 = 0xa8a8a8,
666 | Grey66 = 0xa8a8a8,
667 | Gray67 = 0xababab,
668 | Grey67 = 0xababab,
669 | Gray68 = 0xadadad,
670 | Grey68 = 0xadadad,
671 | Gray69 = 0xb0b0b0,
672 | Grey69 = 0xb0b0b0,
673 | Gray70 = 0xb3b3b3,
674 | Grey70 = 0xb3b3b3,
675 | Gray71 = 0xb5b5b5,
676 | Grey71 = 0xb5b5b5,
677 | Gray72 = 0xb8b8b8,
678 | Grey72 = 0xb8b8b8,
679 | Gray73 = 0xbababa,
680 | Grey73 = 0xbababa,
681 | Gray74 = 0xbdbdbd,
682 | Grey74 = 0xbdbdbd,
683 | Gray75 = 0xbfbfbf,
684 | Grey75 = 0xbfbfbf,
685 | Gray76 = 0xc2c2c2,
686 | Grey76 = 0xc2c2c2,
687 | Gray77 = 0xc4c4c4,
688 | Grey77 = 0xc4c4c4,
689 | Gray78 = 0xc7c7c7,
690 | Grey78 = 0xc7c7c7,
691 | Gray79 = 0xc9c9c9,
692 | Grey79 = 0xc9c9c9,
693 | Gray80 = 0xcccccc,
694 | Grey80 = 0xcccccc,
695 | Gray81 = 0xcfcfcf,
696 | Grey81 = 0xcfcfcf,
697 | Gray82 = 0xd1d1d1,
698 | Grey82 = 0xd1d1d1,
699 | Gray83 = 0xd4d4d4,
700 | Grey83 = 0xd4d4d4,
701 | Gray84 = 0xd6d6d6,
702 | Grey84 = 0xd6d6d6,
703 | Gray85 = 0xd9d9d9,
704 | Grey85 = 0xd9d9d9,
705 | Gray86 = 0xdbdbdb,
706 | Grey86 = 0xdbdbdb,
707 | Gray87 = 0xdedede,
708 | Grey87 = 0xdedede,
709 | Gray88 = 0xe0e0e0,
710 | Grey88 = 0xe0e0e0,
711 | Gray89 = 0xe3e3e3,
712 | Grey89 = 0xe3e3e3,
713 | Gray90 = 0xe5e5e5,
714 | Grey90 = 0xe5e5e5,
715 | Gray91 = 0xe8e8e8,
716 | Grey91 = 0xe8e8e8,
717 | Gray92 = 0xebebeb,
718 | Grey92 = 0xebebeb,
719 | Gray93 = 0xededed,
720 | Grey93 = 0xededed,
721 | Gray94 = 0xf0f0f0,
722 | Grey94 = 0xf0f0f0,
723 | Gray95 = 0xf2f2f2,
724 | Grey95 = 0xf2f2f2,
725 | Gray96 = 0xf5f5f5,
726 | Grey96 = 0xf5f5f5,
727 | Gray97 = 0xf7f7f7,
728 | Grey97 = 0xf7f7f7,
729 | Gray98 = 0xfafafa,
730 | Grey98 = 0xfafafa,
731 | Gray99 = 0xfcfcfc,
732 | Grey99 = 0xfcfcfc,
733 | Gray100 = 0xffffff,
734 | Grey100 = 0xffffff,
735 | DarkGrey = 0xa9a9a9,
736 | DarkGray = 0xa9a9a9,
737 | DarkBlue = 0x00008b,
738 | DarkCyan = 0x008b8b,
739 | DarkMagenta = 0x8b008b,
740 | DarkRed = 0x8b0000,
741 | LightGreen = 0x90ee90,
742 | Crimson = 0xdc143c,
743 | Indigo = 0x4b0082,
744 | Olive = 0x808000,
745 | RebeccaPurple = 0x663399,
746 | Silver = 0xc0c0c0,
747 | Teal = 0x008080,
748 | };
749 | }
--------------------------------------------------------------------------------
/src/cs/samples/HelloWorld/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading;
3 | using bottlenoselabs.C2CS.Runtime;
4 | using static Tracy.PInvoke;
5 |
6 | internal sealed class Program
7 | {
8 | static void Delay()
9 | {
10 | int i, end;
11 | double j = 0;
12 |
13 | using (Profiler.BeginEvent("My Custom Event Name"))
14 | {
15 |
16 | Random random = new Random();
17 |
18 | for (i = 0, end = (int)random.NextInt64() / 100; i < end; ++i)
19 | {
20 | j += Math.Sin(i);
21 | }
22 |
23 | }
24 | }
25 |
26 | static void ColoredEvent()
27 | {
28 | using (Profiler.BeginEvent(colorType: Profiler.ColorType.Aqua))
29 | {
30 |
31 | Thread.Sleep(16);
32 | }
33 | }
34 |
35 | internal static unsafe void Main(string[] args)
36 | {
37 | while (true)
38 | {
39 | Delay();
40 | ColoredEvent();
41 |
42 | Profiler.ProfileFrame("Main"); // Put this after you have completed rendering the frame.
43 | // Ideally that would be right after the swap buffers command.
44 | // Note that this step is optional, as some applications (for example: a compression utility) do not have the concept of a frame
45 | }
46 |
47 | // Call it at the end of your program to free allocated memory
48 | Profiler.Dispose();
49 | }
50 | }
--------------------------------------------------------------------------------