Skip to content

Instantly share code, notes, and snippets.

View fredemmott's full-sized avatar

Fred Emmott fredemmott

View GitHub Profile
wpr -snapshotconfig heap -name OpenKneeboardApp.exe enable
# your own wprp is optional, both are logged
wpr -start heapsnapshot -start .\OpenKneeboard.wprp -filemode
wpr -singlesnapshot heap $((get-process OpenKneeboardApp).id)
# Wait for leak, then the same again
wpr -singlesnapshot heap $((get-process OpenKneeboardApp).id)
wpr -stop c:\users\fred\trace.etl
wpr -snapshotconfig heap -name OpenKneeboardApp.exe disable
# in wpa, select both snapshots, right click, diff view. Then look at 'added'
struct D3D11Timer {
D3D11Timer() = default;
explicit D3D11Timer(ID3D11Device* device) {
device->GetImmediateContext(mContext.put());
D3D11_QUERY_DESC desc {D3D11_QUERY_TIMESTAMP_DISJOINT};
device->CreateQuery(&desc, mDisjointQuery.put());
desc = {D3D11_QUERY_TIMESTAMP};
device->CreateQuery(&desc, mBeginRenderTimestampQuery.put());
device->CreateQuery(&desc, mEndRenderTimestampQuery.put());
@fredemmott
fredemmott / Program.cs
Created December 13, 2024 14:45
wixsharp-as-script
using System.CommandLine;
using System.Runtime.CompilerServices;
using WixSharp;
using WixToolset.Dtf.WindowsInstaller;
using File = WixSharp.File;
[assembly: InternalsVisibleTo(assemblyName: "XRFrameTools_Installer.aot")] // assembly name + '.aot suffix
void CreateMSI(DirectoryInfo sourceRoot)
@fredemmott
fredemmott / compile-time-string-to-guid.hpp
Created December 11, 2024 03:21
Compile time string-to-GUID
// Copyright 2024 Fred Emmott <fred@fredemmott.com>
// SPDX-License-Identifier: MIT
#pragma once
// Usage:
//
// constexpr GUID TestGuid = "9add179d-b650-4eca-b471-88ab38c2bd46"_guid;
// constexpr GUID TestGuid2 = "{2f896df5-d701-42ea-ab02-cbd50af16516}"_guid;
namespace detail::compile_time_guid {
diff --git a/src/injectables/OpenXRKneeboard.cpp b/src/injectables/OpenXRKneeboard.cpp
index 0c3f6d51..5cdbb322 100644
--- a/src/injectables/OpenXRKneeboard.cpp
+++ b/src/injectables/OpenXRKneeboard.cpp
@@ -50,6 +50,9 @@
#include <openxr/openxr_platform.h>
#include <openxr/openxr_reflection.h>
+// From OpenXR v1.1 SDK for XrPosef_Multiply
+#include "xr_linear.h"
@fredemmott
fredemmott / HTCCSettingsApp.cpp
Last active November 23, 2024 15:44
HTCCSettingsApp skeleton - example ImGUI with Win32/D3D11
// Copyright 2024 Fred Emmott <fred@fredemmott.com>
// SPDX-License-Identifier: MIT
#include <Windows.h>
#include <d3d11.h>
#include <dxgi1_3.h>
#include <imgui.h>
#include <imgui_impl_dx11.h>
#include <imgui_impl_win32.h>
#include <wil/com.h>
// Copyright 2024 Fred Emmott <fred@fredemmott.com>
// SPDX-License-Identifier: ISC
#include <algorithm>
#include <concepts>
#include <functional>
#include <ranges>
#include <string>
#include <print>
diff --git a/.clang-format b/.clang-format
index 63d4edf..1cd1c88 100644
--- a/.clang-format
+++ b/.clang-format
@@ -23,7 +23,10 @@ IncludeCategories:
- Regex: '^<Windows\.h>$'
Priority: 30
- Regex: '^<Unknwn\.h>'
- Priority: 31
+ Priority: 30
template <size_t... I>
struct drop_last_impl_t {
drop_last_impl_t() = delete;
constexpr drop_last_impl_t(std::index_sequence<I...>) {
}
template <template <class...> class T, class... TArgs>
using next_t = T<std::tuple_element_t<I, std::tuple<TArgs...>>...>;
template <class TIn>