|
1 | 1 | #include "Core/Renderer/D3D12.h" |
2 | 2 | #include "Core/Renderer/ScreenQuad.h" |
3 | 3 | #include "Core/Scene/SceneManager.h" |
| 4 | +#include <chrono> |
| 5 | + |
| 6 | +using Clock = std::chrono::high_resolution_clock; |
| 7 | +using TimePoint = std::chrono::time_point<Clock>; |
| 8 | + |
| 9 | +// Variables globales o del renderer |
| 10 | +TimePoint lastFrameTime = Clock::now(); |
4 | 11 |
|
5 | 12 | D3D12::D3D12() : Renderer::Renderer() { |
6 | 13 | this->m_nBackBuffers = 2; |
7 | 14 | this->m_nCurrentFence = 0; |
8 | 15 | this->m_hFence = NULL; |
9 | | - this->m_vsyncState = VSYNC::ENABLED; |
| 16 | + this->m_vsyncState = VSYNC::DISABLED; |
10 | 17 |
|
11 | 18 | this->m_nAlbedoIndex = 0; |
12 | 19 | this->m_nUVIndex = 0; |
@@ -153,6 +160,7 @@ void D3D12::Init(HWND hwnd) { |
153 | 160 | ID3D12CommandList* lists[] = { |
154 | 161 | this->m_list.Get() |
155 | 162 | }; |
| 163 | + |
156 | 164 | this->m_queue->ExecuteCommandLists(1, lists); |
157 | 165 | this->WaitFrame(); |
158 | 166 | } |
@@ -278,6 +286,10 @@ void D3D12::Update() { |
278 | 286 | this->m_sc->Present(this->m_vsyncState, 0); |
279 | 287 | this->m_nActualBackBuffer = this->m_sc->GetCurrentBackBufferIndex(); |
280 | 288 | this->WaitFrame(); |
| 289 | + TimePoint now = Clock::now(); |
| 290 | + std::chrono::duration<float> delta = now - lastFrameTime; |
| 291 | + lastFrameTime = now; |
| 292 | + std::cout << delta.count() << std::endl; |
281 | 293 | } |
282 | 294 |
|
283 | 295 | void D3D12::WaitFrame() { |
@@ -413,6 +425,7 @@ void D3D12::GetMostCapableAdapter() { |
413 | 425 | IID_PPV_ARGS(tempDevice.GetAddressOf() |
414 | 426 | )))) { |
415 | 427 | this->m_adapter = adapter; |
| 428 | + break; |
416 | 429 | } |
417 | 430 | } |
418 | 431 |
|
|
0 commit comments