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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ api-projects/**/build*/
# Local state
.wraplock
.cache/
__pycache__/
*.pyc
.superpowers/
Diagnostics/
CrashDumps/
9 changes: 9 additions & 0 deletions THIRD_PARTY_NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ The exact notices from the build toolchain are preserved under
The MinGW-w64 DirectX header notice is preserved at
`backend/dxvk/include/native/directx/COPYING.MinGW-w64.txt`.

## Test-only Improved Streaming INI reader

The offline streaming regression vendors the unmodified INI reader/parser from
JuniorDjjr/LoadWholeMap under `tests/vendor/loadwholemap-ini/`. Its pinned commit,
file hashes and coverage limits are recorded in that directory's `README.md`;
the original license is retained in `LICENSE.txt` and in the parser header.
These files are used by test executables only and are not linked into the
RenderStack runtime DLLs.

## Distribution Rules

- Keep this file with source and binary distributions.
Expand Down
17 changes: 17 additions & 0 deletions backend/dxvk/src/d3d9/d3d9_binding_fast_path.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once

#include "../util/util_bit.h"

namespace dxvk {

// Return true only when a non-empty batch has been consumed by bindOne.
template<typename BindOne>
bool TryD3D9SingleBinding(uint32_t mask, const BindOne& bindOne) {
if (!mask || (mask & (mask - 1u)))
return false;

bindOne(bit::tzcnt(mask));
return true;
}

}
66 changes: 66 additions & 0 deletions backend/dxvk/src/d3d9/d3d9_bridge_diagnostics.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#pragma once

#include <d3d9.h>

// Private, copied-data diagnostics. Public API1-7 and lifecycle vtables do not
// change. Start/Stop/GetAudit run on the device's calling thread; Publish/GetHud
// additionally support concurrent copying from the HUD thread. No pointer in a
// snapshot refers to caller memory. Initialize StructSize and Version on reads.
inline constexpr GUID IID_D3D9BridgeDiagnostics =
{0x36f6d3a1,0xc28c,0x4dd0,{0x91,0xaf,0x23,0x1e,0x8b,0xa0,0xb2,0x03}};
inline constexpr UINT D3D9_BRIDGE_DIAGNOSTICS_VERSION = 1;
inline constexpr UINT D3D9_BRIDGE_AUDIT_COUNTER_COUNT = 17;
inline constexpr UINT D3D9_BRIDGE_PREPARE_COUNTER_COUNT = 28;
inline constexpr UINT D3D9_BRIDGE_HUD_LINE_COUNT = 8;
inline constexpr UINT D3D9_BRIDGE_HUD_LINE_CAPACITY = 128;

enum D3D9BridgeAuditStatus : UINT {
D3D9_BRIDGE_AUDIT_IDLE, D3D9_BRIDGE_AUDIT_ACTIVE,
D3D9_BRIDGE_AUDIT_COMPLETE, D3D9_BRIDGE_AUDIT_INTERRUPTED,
D3D9_BRIDGE_AUDIT_UNAVAILABLE,
};

struct D3D9BridgeAuditCounter {
UINT64 Calls, RedundantCalls, Units, RedundantUnits, QpcTicks, MaxQpcTicks;
// TimedCalls == 0 means no elapsed measurement was taken. A timed zero
// remains distinguishable from an unsupported/untimed category. Spans are
// device-locked API-body elapsed: lock acquisition wait is excluded. They
// include waits inside that body and may nest (e.g. state-block restore).
UINT64 TimedCalls;
};
struct D3D9BridgePrepareCounter { UINT64 Draws, Units; };

struct D3D9BridgeAuditSnapshot {
UINT StructSize, Version;
UINT64 CaptureId;
UINT Status, Available, Active, DurationMs;
UINT64 ElapsedMs, ObservedPresentBoundaries, QpcFrequency;
D3D9BridgeAuditCounter Total;
// Order matches D3D9GtaSaStateAuditKind; timings are inclusive measured
// API spans, not additive frame costs. Present boundaries are attempts,
// never a successful-Present or FPS numerator.
D3D9BridgeAuditCounter Counters[D3D9_BRIDGE_AUDIT_COUNTER_COUNT];
UINT64 SamplerBindingCacheHits, TextureBindingCacheHits;
UINT64 ResourceBindingCacheInvalidations, StateBlockFastSkips;
UINT64 PrepareDraws, PrepareCleanDraws, PrepareCategoryEvents;
UINT64 PrepareMaxCategoriesPerDraw;
D3D9BridgePrepareCounter Prepare[D3D9_BRIDGE_PREPARE_COUNTER_COUNT];
};

struct D3D9BridgeHudSnapshot {
UINT StructSize, Version;
UINT64 CaptureId;
UINT Phase, Status, Visible, ProgressPermille;
UINT64 ElapsedMs, DurationMs;
UINT LineCount;
char Lines[D3D9_BRIDGE_HUD_LINE_COUNT][D3D9_BRIDGE_HUD_LINE_CAPACITY];
};

struct ID3D9BridgeDiagnostics : IUnknown {
virtual HRESULT STDMETHODCALLTYPE SetCaptureOwner(BOOL) = 0;
virtual HRESULT STDMETHODCALLTYPE StartAudit(UINT64 captureId, UINT durationMs) = 0;
virtual HRESULT STDMETHODCALLTYPE StopAudit(UINT64 captureId) = 0;
virtual HRESULT STDMETHODCALLTYPE GetAudit(D3D9BridgeAuditSnapshot*) = 0;
virtual HRESULT STDMETHODCALLTYPE PublishHud(const D3D9BridgeHudSnapshot*) = 0;
virtual HRESULT STDMETHODCALLTYPE GetHud(D3D9BridgeHudSnapshot*) = 0;
};
44 changes: 44 additions & 0 deletions backend/dxvk/src/d3d9/d3d9_bridge_lifecycle.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#pragma once

#include <d3d9.h>

// Private Bridge/backend integration. This is independent of public API1-7.
// Callbacks run synchronously on the calling device thread. The observer must
// outlive registration, must not retain the device, and may not throw. Clear
// registration serializes with callbacks. FinalRelease runs while the device
// is still usable, before its final public reference is retired.
inline constexpr GUID IID_D3D9BridgeLifecycle =
{0x36f6d3a1,0xc28c,0x4dd0,{0x91,0xaf,0x23,0x1e,0x8b,0xa0,0xb2,0x01}};
inline constexpr GUID IID_D3D9BridgeRuntime =
{0x36f6d3a1,0xc28c,0x4dd0,{0x91,0xaf,0x23,0x1e,0x8b,0xa0,0xb2,0x02}};

enum class D3D9BridgeEvent : UINT {
PresentBefore, PresentAfter, ResetBefore, ResetAfter, FinalRelease
};

struct D3D9BridgePresentArgs {
const RECT* Source;
const RECT* Destination;
HWND Window;
const RGNDATA* DirtyRegion;
};

struct D3D9BridgeObserver {
UINT StructSize;
void* Context;
void (STDMETHODCALLTYPE* Notify)(void*, IDirect3DDevice9*, D3D9BridgeEvent,
HRESULT, D3DPRESENT_PARAMETERS*, const D3D9BridgePresentArgs*);
};

struct ID3D9BridgeLifecycle : IUnknown {
virtual HRESULT STDMETHODCALLTYPE SetObserver(const D3D9BridgeObserver*) = 0;
};

// Query on the Bridge IDirect3D9 factory. Shutdown is explicit and must be
// called outside callbacks/loader lock, after releasing all created devices.
// It returns D3DERR_INVALIDCALL while a device is live and E_FAIL when rollback
// needs a retry, E_PENDING for a concurrent shutdown, and S_FALSE after completed
// shutdown. An initialized Bridge stays module-pinned for stale hooks.
struct ID3D9BridgeRuntime : IUnknown {
virtual HRESULT STDMETHODCALLTYPE Shutdown() = 0;
};
22 changes: 22 additions & 0 deletions backend/dxvk/src/d3d9/d3d9_bridge_thread_stats.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#pragma once
#include <d3d9.h>

// Private optional boundary query. Does not flush, synchronize, enable an
// audit, require GTA compatibility, or alter any public D3D9/API1-7 vtable.
inline constexpr GUID IID_D3D9BridgeThreadStats =
{0xd0967703,0x3642,0x49d2,{0x93,0xa8,0x91,0xa2,0xd1,0xe0,0x31,0x50}};
struct D3D9BridgeThreadSnapshot {
UINT StructSize,Version,MainThreadId,CsThreadId,AvailableMask,Reserved;
// CPU is scheduled kernel+user execution, in 100ns units. Queue idle is
// wall time spent inside the CS condition wait, including an open wait.
// OrderedDispatched-OrderedCompleted includes in-flight work and excludes
// the high-priority/injected stream. Counters are lifetime totals.
UINT64 WallUs,MainCpu100ns,CsCpu100ns,CsQueueIdleUs,OrderedDispatched,OrderedCompleted;
// Existing CS/GPU wait counters count COMPLETED spans (possibly crossing
// a sampling boundary). Device-wide GPU waits are not necessarily main-
// thread waits. GPU idle is an estimate, not a timestamp-query GPU time.
UINT64 CsSyncCount,CsSyncUs,GpuSyncCount,GpuSyncUs,GpuIdleUs,Chunks,Submits;
};
struct ID3D9BridgeThreadStats : IUnknown {
virtual HRESULT STDMETHODCALLTYPE GetThreadStats(D3D9BridgeThreadSnapshot*) = 0;
};
Loading
Loading