|
| 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 | +} |
0 commit comments