diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index fda01b732..e419cb035 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -6,6 +6,7 @@ concurrency:
on:
push:
+ branches: [master]
pull_request:
env:
@@ -40,12 +41,31 @@ jobs:
path: bimg
- name: Prepare
uses: microsoft/setup-msbuild@v2
+ - name: Prepare ccache
+ shell: bash
+ run: |
+ curl -sSL https://github.com/ccache/ccache/releases/download/v4.14.1/ccache-4.14.1-windows-x86_64.zip -o ccache.zip
+ unzip -q -j ccache.zip '*/ccache.exe' -d ccache-cl
+ cp ccache-cl/ccache.exe ccache-cl/cl.exe
+ echo 'OldStyle' > Directory.Build.targets
+ - name: Cache key
+ id: cache-key
+ shell: bash
+ run: |
+ echo "key=$("/c/Program Files (x86)/Microsoft Visual Studio/Installer/vswhere.exe" -latest -property installationVersion)-$(git -C bgfx rev-parse HEAD:3rdparty)-$(git -C bimg rev-parse HEAD:3rdparty)" >> "$GITHUB_OUTPUT"
+ - name: Cache
+ uses: actions/cache@v6
+ with:
+ path: .ccache
+ key: ccache-msvc-${{ matrix.config }}-${{ matrix.platform }}-${{ steps.cache-key.outputs.key }}
+ restore-keys: ccache-msvc-${{ matrix.config }}-${{ matrix.platform }}-
- name: Build
shell: cmd
run: |
cd bgfx
..\bx\tools\bin\windows\genie.exe ${{ matrix.genie-args }} ${{ matrix.genie-action }}
- msbuild ".build/projects/${{ matrix.genie-action }}/bgfx.${{ matrix.solution-ext }}" /m /v:minimal /p:Configuration=${{ matrix.config }} /p:Platform=${{ matrix.platform }}
+ msbuild ".build/projects/${{ matrix.genie-action }}/bgfx.${{ matrix.solution-ext }}" /m /v:minimal /p:Configuration=${{ matrix.config }} /p:Platform=${{ matrix.platform }} /p:CLToolExe=cl.exe /p:CLToolPath=%GITHUB_WORKSPACE%\ccache-cl /p:UseMultiToolTask=true /p:EnforceProcessCountAcrossBuilds=true /p:TrackFileAccess=false || exit /b 1
+ ..\ccache-cl\ccache.exe -s
- name: Check
if: matrix.tools
shell: cmd
diff --git a/src/bgfx.cpp b/src/bgfx.cpp
index 0232ecc55..942013be5 100644
--- a/src/bgfx.cpp
+++ b/src/bgfx.cpp
@@ -9,6 +9,7 @@
#include
#include
#include
+#include
#include "topology.h"
@@ -68,99 +69,16 @@ namespace bgfx
}
}
- struct Superluminal
- {
- struct SuppressTailCallOptimization
- {
- int64_t SuppressTailCall[3];
- };
-
- typedef void (*SuperluminalBeginEventtFn)(const char* _inID, const char* _inData, uint32_t _inColor);
- typedef SuppressTailCallOptimization(*SuperluminalEndEventFn)();
-
- static void stubSuperluminalBeginEvent(const char* _inID, const char* _inData, uint32_t _inColor)
- {
- BX_UNUSED(_inID, _inData, _inColor);
- }
-
- static SuppressTailCallOptimization stubSuperluminalEndEvent()
- {
- return {};
- }
-
- bool init()
- {
- if (!BX_ENABLED(BGFX_CONFIG_PROFILER) )
- {
- return false;
- }
-
- const char* superluminalDllName = "PerformanceAPI.dll";
- superluminalDll = bx::dlopen(superluminalDllName);
-
- if (NULL != superluminalDll)
- {
- void* funcPtrs[11];
-
- typedef int (*PerformanceAPI_GetAPI)(int32_t _version, void** _funcPtrs);
-
- constexpr int32_t version = 0x30000;
-
- PerformanceAPI_GetAPI getApi = bx::dlsym(superluminalDll, "PerformanceAPI_GetAPI");
- if (NULL == getApi)
- {
- BX_TRACE("Failed to obtain Superluminal's %s GetAPI function!", superluminalDllName);
- bx::dlclose(superluminalDll);
- return false;
- }
-
- if (getApi(version, funcPtrs) )
- {
- BX_TRACE("Superluminal's PerformanceAPI.dll is loaded!");
- beginEvent = (SuperluminalBeginEventtFn)funcPtrs[2];
- endEvent = (SuperluminalEndEventFn )funcPtrs[6];
- return true;
- }
-
- BX_TRACE("Failed to obtain Superluminal's %s GetAPI function!", superluminalDllName);
- bx::dlclose(superluminalDll);
- }
- else
- {
- BX_TRACE("Failed to load Superluminal's %s!", superluminalDllName);
- }
-
- return false;
- }
-
- void shutdown()
- {
- if (NULL != superluminalDll)
- {
- bx::dlclose(superluminalDll);
- superluminalDll = NULL;
- beginEvent = stubSuperluminalBeginEvent;
- endEvent = stubSuperluminalEndEvent;
- }
- }
-
- void* superluminalDll = NULL;
- SuperluminalBeginEventtFn beginEvent = stubSuperluminalBeginEvent;
- SuperluminalEndEventFn endEvent = stubSuperluminalEndEvent;
- };
-
struct CallbackStub : public CallbackI
{
- Superluminal m_superluminal;
+ bx::Superluminal m_superluminal;
CallbackStub()
{
- m_superluminal.init();
- }
-
- virtual ~CallbackStub()
- {
- m_superluminal.shutdown();
+ if (BX_ENABLED(BGFX_CONFIG_PROFILER) )
+ {
+ m_superluminal.load();
+ }
}
virtual void fatal(const char* _filePath, uint16_t _line, Fatal::Enum _code, const char* _str) override