Prepare shader reload.

- Expose wait until gpus is idle to api
- Alt+R to reload
This commit is contained in:
2025-03-15 19:55:41 -04:00
parent f01c8c3ccb
commit c9cd01bb31
8 changed files with 44 additions and 9 deletions

View File

@@ -1,6 +1,7 @@
#include <main.h>
#include <Core/Application/ApplicationManager.h>
#include <Core/Common/EnumUtils.h>
#include <Core/HAL/Display/Display.h>
#include <Core/HAL/Event/SystemEvent.h>
#include <Core/HAL/Filesystem/Filesystem.h>
@@ -158,6 +159,9 @@ void JulietApplication::Shutdown()
void JulietApplication::Update()
{
bool reloadShaders = false;
static bool reloadShadersDebounce = false;
SystemEvent evt;
while (GetEvent(evt))
{
@@ -168,6 +172,23 @@ void JulietApplication::Update()
Running = false;
}
}
if (evt.Type == EventType::Key_Down)
{
}
// Shader hot reload using keyboard.
// TODO: Add Input debounce in the library. (Just pressed vs pressed)
if (!reloadShadersDebounce && ((GetKeyModState() & KeyMod::Alt) != KeyMod::None) && IsKeyDown(ScanCode::R))
{
reloadShaders = true;
reloadShadersDebounce = true;
}
if (reloadShadersDebounce && !IsKeyDown(ScanCode::R))
{
reloadShadersDebounce = false;
}
}
Game.Update(0.0f);
@@ -177,6 +198,12 @@ void JulietApplication::Update()
ReloadCode(GameCode);
}
if (reloadShaders)
{
// We need to wait for the gpu to be idle to recreate our graphics pipelines
WaitUntilGPUIsIdle(GraphicsDevice);
}
// Draw here for now
// 1) Acquire a Command Buffer
CommandList* cmdList = AcquireCommandList(GraphicsDevice, QueueType::Graphics);