Skip to content

Commit 0328a5b

Browse files
janbladeclaude
andcommitted
docs: clean up comments for upstream (drop session-log framing)
The comments this fix added referenced a dated internal investigation and a memory/plans/*.md file that only exists in the fork's own AI-OS working notes, not in this repo. Rewrote them as plain engineering comments describing what the code does and why, with no session-log framing (dates, "diagnosed"/ "investigated" narration) or references to files outside this project. No behavior change. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 25350a2 commit 0328a5b

2 files changed

Lines changed: 14 additions & 19 deletions

File tree

‎OptiScaler/hooks/DxgiFactory_Hooks.cpp‎

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,9 @@ static bool PrepareDx12InteropDesc1(DXGI_SWAP_CHAIN_DESC1& desc)
6969

7070
void DxgiFactoryHooks::HookToFactory(IDXGIFactory* pFactory)
7171
{
72-
// Investigated 2026-09-06 (NBA 2K26 menu/overlay never initializing -- see
73-
// memory/plans/2026-09-06-optiscaler-reshade-addon64.md's task-file entry): confirmed live that
74-
// every IDXGIFactory instance this process saw shared one vtable (Detours patches the target
75-
// function's machine code in place, not the vtable slot's stored pointer, so this guard's
76-
// "hook the first factory, every later one is covered too" assumption held here). The actual gap
77-
// was CreateSwapChainForComposition never being hooked at all -- see below.
72+
// Every IDXGIFactory instance the process obtains shares one vtable, so hooking the first one
73+
// covers every later instance too -- Detours patches the target function's machine code in
74+
// place, not the vtable slot's stored pointer.
7875
if (pFactory == nullptr || o_EnumAdapters != nullptr)
7976
return;
8077

@@ -279,12 +276,11 @@ HRESULT DxgiFactoryHooks::CreateSwapChain(IDXGIFactory* realFactory, IUnknown* p
279276
return res;
280277
}
281278

282-
// Diagnosed 2026-09-06 (NBA 2K26 menu never initializing): Width==0 && Height==0 with a real
283-
// OutputWindow is DXGI's documented "size to the window's client area" idiom, not an overlay --
284-
// confirmed live, NBA 2K26's actual swapchain (BufferCount 3, real HWND, Windowed) is created
285-
// exactly this way and was previously being misclassified as "Overlay call!" and passed through
286-
// unwrapped, which is why the menu/toast overlay never appeared. Only a genuinely tiny, non-zero
287-
// descriptor (Steam/Discord-style overlay helper swapchains) should still take that path.
279+
// Width==0 && Height==0 with a real OutputWindow is DXGI's documented "size to the window's
280+
// client area" idiom, not an overlay -- treating it as tiny and leaving it unwrapped misses the
281+
// game's real swapchain whenever it's created this way, which silently breaks anything driven off
282+
// the wrapped swapchain's Present (the menu overlay). Only a genuinely tiny, non-zero descriptor
283+
// (Steam/Discord-style overlay helper swapchains) should take that path.
288284
//
289285
// A non-null OutputWindow alone isn't enough to trust, though: a helper/overlay swapchain could
290286
// use this exact same 0x0 idiom against its OWN tiny/hidden window. Check the window's real

‎OptiScaler/hooks/DxgiFactory_Hooks.h‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,12 @@ class DxgiFactoryHooks
4949
const DXGI_SWAP_CHAIN_DESC1* pDesc, IDXGIOutput* pRestrictToOutput,
5050
IDXGISwapChain1** ppSwapChain);
5151

52-
// Diagnosed 2026-09-06 (NBA 2K26 menu/overlay investigation, see
53-
// memory/plans/2026-09-06-optiscaler-reshade-addon64.md): HookToFactory hooked CreateSwapChain,
54-
// CreateSwapChainForHwnd and CreateSwapChainForCoreWindow but never IDXGIFactory2::
55-
// CreateSwapChainForComposition -- a game creating its real swapchain that way (DirectComposition,
56-
// common for HDR/compositor-hosted presentation) would never get wrapped at all: no crash, no
57-
// error, just total silence, exactly matching the live symptom (DLSS works fine since it never
58-
// touches the swapchain; the menu, driven off the wrapped swapchain's Present, never initializes).
52+
// The one DXGI swapchain-creation entry point HookToFactory previously left unhooked
53+
// (CreateSwapChain, CreateSwapChainForHwnd and CreateSwapChainForCoreWindow all were). A game
54+
// creating its real swapchain via DirectComposition (common for HDR/compositor-hosted
55+
// presentation) would never get wrapped at all: no crash, no error, just silence -- DLSS keeps
56+
// working since it never touches the swapchain, but the menu, driven off the wrapped
57+
// swapchain's Present, never initializes.
5958
static HRESULT CreateSwapChainForComposition(IDXGIFactory2* realFactory, IUnknown* pDevice,
6059
const DXGI_SWAP_CHAIN_DESC1* pDesc, IDXGIOutput* pRestrictToOutput,
6160
IDXGISwapChain1** ppSwapChain);

0 commit comments

Comments
 (0)