Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion .github/workflows/windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
jobs:
build:
runs-on: ${{ matrix.os }}
env:
CCACHE_DISABLE: "1"
SCCACHE_DISABLE: "1"

strategy:
matrix:
Expand Down Expand Up @@ -36,9 +39,32 @@ jobs:
xmake-version: latest
actions-cache-folder: ".xmake-cache"

- name: Disable compiler cache
run: |
$filteredPathEntries = foreach ($entry in ($env:Path -split ';')) {
if ([string]::IsNullOrWhiteSpace($entry)) {
continue
}

$pathEntry = $entry.Trim('"')
$hasCompilerCache = (Test-Path (Join-Path $pathEntry 'ccache.exe')) -or (Test-Path (Join-Path $pathEntry 'sccache.exe'))
if (-not $hasCompilerCache) {
$entry
}
}
$env:Path = $filteredPathEntries -join ';'
"Path=$env:Path" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
if (Get-Command ccache -ErrorAction SilentlyContinue) {
throw "ccache is still on PATH"
}
if (Get-Command sccache -ErrorAction SilentlyContinue) {
throw "sccache is still on PATH"
}
xmake g --ccache=n

- name: Config
run: |
xmake f -y -a x64 -m release ${{ matrix.compiler }}
xmake f -y -a x64 -m release ${{ matrix.compiler }} --ccache=n --policies=package.build.ccache:n,build.ccache:n

- name: Build
run: |
Expand Down
30 changes: 22 additions & 8 deletions examples/playground/main.cpp
Original file line number Diff line number Diff line change
@@ -1,39 +1,53 @@
#include <spdlog/spdlog.h>
#include <imgui.h>
#include <combaseapi.h>
#include <filesystem>
#include <shlobj.h>

import engine;
import asset;

using namespace hitagi;

static auto GetLatestWinPixGpuCapturerPath_Cpp17() {
static auto GetLatestWinPixGpuCapturerPath_Cpp17() -> std::filesystem::path {
LPWSTR programFilesPath = nullptr;
SHGetKnownFolderPath(FOLDERID_ProgramFiles, KF_FLAG_DEFAULT, nullptr, &programFilesPath);
if (FAILED(SHGetKnownFolderPath(FOLDERID_ProgramFiles, KF_FLAG_DEFAULT, nullptr, &programFilesPath)) ||
programFilesPath == nullptr) {
return {};
}

std::filesystem::path pixInstallationPath = programFilesPath;
CoTaskMemFree(programFilesPath);

pixInstallationPath /= "Microsoft PIX";
if (!std::filesystem::exists(pixInstallationPath)) {
return {};
}

std::string newestVersionFound;
std::wstring newestVersionFound;

for (auto const& directory_entry : std::filesystem::directory_iterator(pixInstallationPath)) {
if (directory_entry.is_directory()) {
if (newestVersionFound.empty() || newestVersionFound < directory_entry.path().filename().string()) {
newestVersionFound = directory_entry.path().filename().string();
const auto version = directory_entry.path().filename().wstring();
if (newestVersionFound.empty() || newestVersionFound < version) {
newestVersionFound = version;
}
}
}

if (newestVersionFound.empty()) {
// TODO: Error, no PIX installation found
return {};
}

return pixInstallationPath / newestVersionFound / L"WinPixGpuCapturer.dll";
}

auto main(int argc, char** argv) -> int {
if (GetModuleHandle("WinPixGpuCapturer.dll") == nullptr) {
LoadLibrary(GetLatestWinPixGpuCapturerPath_Cpp17().string().c_str());
if (GetModuleHandleW(L"WinPixGpuCapturer.dll") == nullptr) {
const auto pixCapturerPath = GetLatestWinPixGpuCapturerPath_Cpp17();
if (!pixCapturerPath.empty()) {
LoadLibraryW(pixCapturerPath.c_str());
}
}

spdlog::set_level(spdlog::level::trace);
Expand Down
Loading