Skip to content

Fix XeLL initialization with ReShade-wrapped devices - #1325

Closed
williamstosh wants to merge 1 commit into
optiscaler:masterfrom
williamstosh:fix/xell-reshade-device
Closed

williamstosh wants to merge 1 commit into
optiscaler:masterfrom
williamstosh:fix/xell-reshade-device

Conversation

@williamstosh

Copy link
Copy Markdown
Contributor

Purpose / Background

Fix a save-load crash in The Witcher 3 Remastered's DX12 DLSSG via Streamline -> XeFG path with ReShade enabled.

On nightly baseline 4a8d55a9, XeLL initialized its context with a ReShade-wrapped device while XeFG supplied a native application queue. DbgEng unwinding, object vtables, and call-site disassembly showed XeLL submitting a ReShade-wrapped command list through the native queue's ExecuteCommandLists during RenderSubmitStart. D3D12Core interpreted the wrapper using its native object layout and faulted with 0xC0000005. This establishes the invalid submission boundary; Intel's internal queue-assignment sequence was not traced.

The observed setup used Streamline 2.14.1, ReShade 6.8.0.2155, XeFG 1.3.1.78, and XeLL 1.3.2.10 on an RTX 5090 D.

Changes / Impact

Change only OptiScaler/low_latency/low_latency_tech/ll_xell.cpp:

  • Obtain the native device with the existing Util::GetReShadeOriginal helper before querying ID3D12Device and creating the XeLL context.
  • Adopt the helper's acquired reference with ComPtr<IUnknown>::Attach; retain the existing independent member QI reference and cleanup paths.
  • Continue using the supplied device when no original device is returned, and log successful unwrapping at Debug level.

Both the normal XeLL output and the dedicated context created through acquire_xefg_xell use this initialization. Output selection, context reuse, SDK dependencies, and configuration remain unchanged.

Validation

Build and runtime validation used the patched 4a8d55a9 nightly baseline. The same patch applies to current master (ca7df362); its XeLL file and helper are unchanged. The current-master integration was checked for patch applicability, not separately rebuilt or run.

  • Upstream clang-format check, independent reference-lifetime review, and patch replay passed.
  • ReleaseDebug|x64 build completed with exit code 0.
  • Unpatched control with ReShade disabled: 5,110 successful XeFG Dispatches, normal shutdown.
  • Patched build with the original ReShade enabled, same save and FG settings: 14,673 successful Dispatches over approximately 6 minutes 17 seconds, zero recorded failed Dispatches or log errors.
  • Device logs confirmed XeLL's unwrapped device matched the device captured from the application queue.
  • Normal shutdown completed with Steam exit code 0, with no new crash dumps or application crash events. Temporary logging settings were restored; save-directory files and user settings were unchanged.

Runtime coverage is one save/configuration in a stationary scene. Extended gameplay, other versions, and other games were not tested.

Related: #1324 reports a separate descriptor-decoding failure in ReShade's ClearUAV path. This PR addresses the native-queue/wrapped-command-list boundary and does not claim to resolve that issue.

@cdozdil

cdozdil commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

Hi,

Maybe better check for reshade module, like these?

// Streamline's NGX has to use the device the game gives NGX. With ReShade above Opti the game gives the real
// one, with ReShade loaded by Opti (or Special K) the game and Opti both get ReShade's proxy.
static sl::Result SetD3D12Device(void* device, bool bind)
{
Microsoft::WRL::ComPtr<IUnknown> original;
if (reshadeModule == nullptr)
original.Attach(Util::GetReShadeOriginal((IUnknown*) device));
if (original != nullptr)
{
LOG_INFO("Using the real device behind ReShade's proxy");
device = original.Get();
}
return bind ? SetD3DDeviceAndBind(device) : _slSetD3DDevice(device);

// When ReShade hooks DXGI before Opti, FG libraries create their swapchain inside ReShade's hook,
// which then passes its proxy queue on to DXGI. ReShade loaded by Opti hooks after, it needs its proxy.
static Microsoft::WRL::ComPtr<ID3D12CommandQueue> ReShadeRealQueue(IUnknown* pDevice)
{
Microsoft::WRL::ComPtr<IUnknown> original;
Microsoft::WRL::ComPtr<ID3D12CommandQueue> queue;
// ReShade loaded by Special K sits above Opti too
if (reshadeModule != nullptr)
return queue;
original.Attach(Util::GetReShadeOriginal(pDevice));
if (original != nullptr && SUCCEEDED(original.As(&queue)))
LOG_INFO("Using the real queue behind ReShade's proxy");
return queue;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants