-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add SSwapChainData and fix mistakes in former PR
- Loading branch information
Showing
8 changed files
with
201 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
#pragma once | ||
|
||
#include <D3D12MemAlloc.h> | ||
|
||
#ifdef RED4EXT_HEADER_ONLY | ||
#include <RED4ext/GpuApi/D3D12MemAlloc-inl.hpp> | ||
#endif | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#pragma once | ||
|
||
#ifdef RED4EXT_STATIC_LIB | ||
#include <RED4ext/GpuApi/DeviceData.hpp> | ||
#endif | ||
|
||
template<typename T, size_t MAX_SIZE> | ||
bool RED4ext::GpuApi::ResourceContainer<T, MAX_SIZE>::Resource::IsUsed() const | ||
{ | ||
return refCount >= 0; | ||
} | ||
|
||
template<typename T, size_t MAX_SIZE> | ||
bool RED4ext::GpuApi::ResourceContainer<T, MAX_SIZE>::IsUsedID(const uint32_t id) const | ||
{ | ||
return IsValidID(id) && resources[IDToIndex(id)].IsUsed(); | ||
} | ||
|
||
template<typename T, size_t MAX_SIZE> | ||
bool RED4ext::GpuApi::ResourceContainer<T, MAX_SIZE>::IsUnusedID(const uint32_t id) const | ||
{ | ||
return IsValidID(id) && !resources[IDToIndex(id)].IsUsed(); | ||
} | ||
|
||
template<typename T, size_t MAX_SIZE> | ||
bool RED4ext::GpuApi::ResourceContainer<T, MAX_SIZE>::IsEmpty() const | ||
{ | ||
assert(numUnused <= MAX_SIZE); | ||
return numUnused == MAX_SIZE; | ||
} | ||
|
||
template<typename T, size_t MAX_SIZE> | ||
bool RED4ext::GpuApi::ResourceContainer<T, MAX_SIZE>::IsFull() const | ||
{ | ||
assert(numUnused <= MAX_SIZE); | ||
return numUnused == 0; | ||
} | ||
|
||
template<typename T, size_t MAX_SIZE> | ||
T& RED4ext::GpuApi::ResourceContainer<T, MAX_SIZE>::GetData(uint32_t id) | ||
{ | ||
assert(IsUsedID(id)); | ||
return resources[IDToIndex(id)].instance; | ||
} | ||
|
||
template<typename T, size_t MAX_SIZE> | ||
const T& RED4ext::GpuApi::ResourceContainer<T, MAX_SIZE>::GetData(uint32_t id) const | ||
{ | ||
assert(IsUsedID(id)); | ||
return resources[IDToIndex(id)].instance; | ||
} | ||
|
||
RED4EXT_INLINE RED4ext::GpuApi::SDeviceData& RED4ext::GpuApi::GetDeviceData() | ||
{ | ||
static UniversalRelocPtr<SDeviceData*> dd(Detail::AddressHashes::g_DeviceData); | ||
return *dd; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#pragma once | ||
|
||
#include <d3d12.h> | ||
#include <dxgi1_6.h> | ||
#include <wrl/client.h> | ||
#include <wrl/wrappers/corewrappers.h> | ||
|
||
namespace RED4ext | ||
{ | ||
namespace GpuApi | ||
{ | ||
struct SSwapChainData | ||
{ | ||
static constexpr uint32_t MaxBackBuffers = 3u; | ||
|
||
Microsoft::WRL::ComPtr<IDXGISwapChain4> swapChain; // 00 | ||
uint8_t unk8[0x28 - 0x08]; // 08 - Always seems to be filled with zeros. | ||
uint32_t backBufferTextureId; // 28 - Reference to back buffer texture data. | ||
uint32_t backBufferIndex; // 2C | ||
uint8_t unk30; // 30 - Always seems to be zero. | ||
bool fullScreen; // 31 - True when in fullscreen. | ||
HWND windowHandle; // 38 | ||
Microsoft::WRL::ComPtr<ID3D12Fence1> presentFence; // 40 | ||
uint64_t presentFenceCompletionFrames[MaxBackBuffers]; // 48 - Compared against completion value in presentFence | ||
// before swapping back buffer. | ||
uint64_t presentFenceNextCompletionFrame; // 60 - Gets assigned to presentFenceCompletionFrames[backBufferIndex] | ||
// each GpuApi::DoPresent call after the presentFence is Signaled with the | ||
// same value, auto-incremented on each call. | ||
D3D12_CPU_DESCRIPTOR_HANDLE backBufferRtvs[MaxBackBuffers]; // 68 | ||
D3D12_CPU_DESCRIPTOR_HANDLE backBufferUavs[MaxBackBuffers]; // 80 | ||
Microsoft::WRL::Wrappers::Event presentFenceEvent; // 98 - Event signaled on presentFence completion. | ||
}; | ||
RED4EXT_ASSERT_SIZE(SSwapChainData, 0xa8); | ||
RED4EXT_ASSERT_OFFSET(SSwapChainData, swapChain, 0x00); | ||
RED4EXT_ASSERT_OFFSET(SSwapChainData, backBufferTextureId, 0x28); | ||
RED4EXT_ASSERT_OFFSET(SSwapChainData, backBufferIndex, 0x2c); | ||
RED4EXT_ASSERT_OFFSET(SSwapChainData, fullScreen, 0x31); | ||
RED4EXT_ASSERT_OFFSET(SSwapChainData, windowHandle, 0x38); | ||
RED4EXT_ASSERT_OFFSET(SSwapChainData, presentFence, 0x40); | ||
RED4EXT_ASSERT_OFFSET(SSwapChainData, presentFenceCompletionFrames, 0x48); | ||
RED4EXT_ASSERT_OFFSET(SSwapChainData, presentFenceNextCompletionFrame, 0x60); | ||
RED4EXT_ASSERT_OFFSET(SSwapChainData, backBufferRtvs, 0x68); | ||
RED4EXT_ASSERT_OFFSET(SSwapChainData, backBufferUavs, 0x80); | ||
RED4EXT_ASSERT_OFFSET(SSwapChainData, presentFenceEvent, 0x98); | ||
} // namespace GpuApi | ||
} // namespace RED4ext |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#ifndef RED4EXT_STATIC_LIB | ||
#error Please define 'RED4EXT_STATIC_LIB' to compile this file. | ||
#endif | ||
|
||
#include <RED4ext/GpuApi/DeviceData-inl.hpp> |