Skip to content

Commit d7b2bed

Browse files
authored
feat: merge pr #31 from ozooma10/creation-renderer
add CreationRendererPrivate (d3d12 renderer)
2 parents 6cc27ff + 3b3269a commit d7b2bed

3 files changed

Lines changed: 98 additions & 0 deletions

File tree

include/RE/C/CreationRenderer.h

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#pragma once
2+
3+
#include "REX/W32/D3D12.h"
4+
#include "REX/W32/DXGI.h"
5+
#include "REX/W32/DXGI_2.h"
6+
7+
namespace RE::CreationRendererPrivate
8+
{
9+
struct DeviceProperties;
10+
11+
namespace detail
12+
{
13+
struct QueueOwnerA;
14+
struct QueueOwnerB;
15+
}
16+
17+
// No RTTI - names from engine assert strings, not RTTI. accessor over g_RendererRoot;
18+
class Renderer
19+
{
20+
public:
21+
[[nodiscard]] static Renderer* GetSingleton()
22+
{
23+
static REL::Relocation<Renderer**> singleton{ ID::CreationRendererPrivate::Renderer::Singleton };
24+
return *singleton;
25+
}
26+
27+
[[nodiscard]] REX::W32::ID3D12Device* GetDevice() const;
28+
29+
[[nodiscard]] REX::W32::ID3D12CommandQueue* GetGraphicsQueue() const;
30+
31+
[[nodiscard]] REX::W32::IDXGIFactory2* GetDXGIFactory() const;
32+
[[nodiscard]] REX::W32::IDXGIAdapter* GetAdapter() const;
33+
34+
// members
35+
std::byte pad00[0x28]; // 00
36+
detail::QueueOwnerA* queueOwnerA; // 28
37+
DeviceProperties* deviceProperties; // 30 (arDeviceProperties)
38+
};
39+
static_assert(offsetof(Renderer, queueOwnerA) == 0x28);
40+
static_assert(offsetof(Renderer, deviceProperties) == 0x30);
41+
42+
struct DeviceProperties
43+
{
44+
std::byte pad000[0x408]; // 000
45+
REX::W32::IDXGIFactory2* dxgiFactory; // 408 (pDXGIFactory)
46+
REX::W32::IDXGIAdapter* dxActiveGPU; // 410 (pDxActiveGPU)
47+
REX::W32::ID3D12Device* dxDevice; // 418 (pDxDevice)
48+
};
49+
static_assert(offsetof(DeviceProperties, dxgiFactory) == 0x408);
50+
static_assert(offsetof(DeviceProperties, dxActiveGPU) == 0x410);
51+
static_assert(offsetof(DeviceProperties, dxDevice) == 0x418);
52+
53+
namespace detail
54+
{
55+
struct QueueOwnerA
56+
{
57+
std::byte pad00[0x08]; // 00
58+
QueueOwnerB* inner; // 08
59+
};
60+
static_assert(offsetof(QueueOwnerA, inner) == 0x08);
61+
62+
struct QueueOwnerB
63+
{
64+
std::byte pad00[0x60]; // 00
65+
REX::W32::ID3D12CommandQueue* graphicsQueue; // 60 (pgraphicsQueue)
66+
};
67+
static_assert(offsetof(QueueOwnerB, graphicsQueue) == 0x60);
68+
}
69+
70+
inline REX::W32::ID3D12Device* Renderer::GetDevice() const
71+
{
72+
return deviceProperties ? deviceProperties->dxDevice : nullptr;
73+
}
74+
75+
inline REX::W32::ID3D12CommandQueue* Renderer::GetGraphicsQueue() const
76+
{
77+
if (!queueOwnerA || !queueOwnerA->inner) {
78+
return nullptr;
79+
}
80+
return queueOwnerA->inner->graphicsQueue;
81+
}
82+
83+
inline REX::W32::IDXGIFactory2* Renderer::GetDXGIFactory() const
84+
{
85+
return deviceProperties ? deviceProperties->dxgiFactory : nullptr;
86+
}
87+
88+
inline REX::W32::IDXGIAdapter* Renderer::GetAdapter() const
89+
{
90+
return deviceProperties ? deviceProperties->dxActiveGPU : nullptr;
91+
}
92+
}

include/RE/IDs.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,11 @@ namespace RE::ID
798798
inline constexpr REL::ID GetEventSource{ 0 }; // 132107
799799
}
800800

801+
namespace CreationRendererPrivate::Renderer
802+
{
803+
inline constexpr REL::ID Singleton{ 944397 };
804+
}
805+
801806
namespace CriticalHitEvent::Event
802807
{
803808
inline constexpr REL::ID GetEventSource{ 0 }; // 153653

include/RE/Starfield.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@
242242
#include "RE/C/ConeProjectile.h"
243243
#include "RE/C/Console.h"
244244
#include "RE/C/ConsoleLog.h"
245+
#include "RE/C/CreationRenderer.h"
245246
#include "RE/D/DebuggerMessages.h"
246247
#include "RE/D/DecalData.h"
247248
#include "RE/D/DetectionState.h"

0 commit comments

Comments
 (0)