This commit is contained in:
Jorijn van der Graaf 2026-05-05 23:49:29 +02:00
commit b3db40ebec
6 changed files with 212 additions and 64 deletions

View file

@ -732,16 +732,12 @@ void Window::Render() {
// widget's OnTextInput / OnKeyDown sees them in the same frame.
Device::TickKeyRepeats();
onUpdate.Invoke({startTime, startTime-lastFrameBegin});
#ifdef CRAFTER_TIMING
totalUpdate = std::chrono::nanoseconds(0);
updateTimings.clear();
for (const std::pair<const EventListener<FrameTime>*, std::chrono::nanoseconds>& entry : onUpdate.listenerTimes) {
updateTimings.push_back(entry);
totalUpdate += entry.second;
}
#endif
// Bind the descriptor heaps BEFORE the user's update event fires.
// Any compute work the update lambda records (e.g. physics dispatches)
// needs the heaps bound at execution time; recording order in the cmd
// buffer dictates GPU execution order, so the bind must come first.
// Pass-side dispatches still run with the same heaps bound — moving
// the bind earlier doesn't change anything for them.
if (descriptorHeap) {
VkBindHeapInfoEXT resourceHeapInfo = {
.sType = VK_STRUCTURE_TYPE_BIND_HEAP_INFO_EXT,
@ -766,6 +762,16 @@ void Window::Render() {
Device::vkCmdBindSamplerHeapEXT(drawCmdBuffers[currentBuffer], &samplerHeapInfo);
}
onUpdate.Invoke({startTime, startTime-lastFrameBegin});
#ifdef CRAFTER_TIMING
totalUpdate = std::chrono::nanoseconds(0);
updateTimings.clear();
for (const std::pair<const EventListener<FrameTime>*, std::chrono::nanoseconds>& entry : onUpdate.listenerTimes) {
updateTimings.push_back(entry);
totalUpdate += entry.second;
}
#endif
// Note: vkCmdClearColorImage is unavailable here — the swapchain is
// created with VK_IMAGE_USAGE_STORAGE_BIT only (no TRANSFER_DST_BIT).
// Passes that need a background should write one explicitly (UIScene