From b73c188edb2ee9ba44ea77845a4bf0cbd7b07530 Mon Sep 17 00:00:00 2001 From: Harrand Date: Sat, 16 Nov 2024 00:44:00 +0000 Subject: [PATCH] [imgui] render wip, actually do some work on render --- src/tz/imgui.cpp | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/tz/imgui.cpp b/src/tz/imgui.cpp index 5c7715c6df..24ae97c03c 100644 --- a/src/tz/imgui.cpp +++ b/src/tz/imgui.cpp @@ -30,7 +30,8 @@ namespace tz } render; void impl_write_vertices_and_indices(ImDrawData* draw); - void impl_add_new_pass(); + void impl_push_pass(); + void impl_pop_pass(); void impl_on_render(tz::gpu::graph_handle graph); void imgui_initialise() @@ -112,6 +113,14 @@ namespace tz } impl_write_vertices_and_indices(draws); + while(std::cmp_greater(draws->CmdListsCount, render.passes.size())) + { + impl_push_pass(); + } + while(std::cmp_less(draws->CmdListsCount, render.passes.size())) + { + impl_pop_pass(); + } } void impl_write_vertices_and_indices(ImDrawData* draw) @@ -146,7 +155,7 @@ namespace tz tz::gpu::resource_write(render.index_buffer, tz::view_bytes(new_indices)); } - void impl_add_new_pass() + void impl_push_pass() { tz::gpu::resource_handle resources[] = { @@ -172,6 +181,22 @@ namespace tz .resources = resources, .name = pass_name.c_str() }))); + + auto sz = render.passes.size(); + std::vector deps; + deps.reserve(1); + if(sz >= 2) + { + deps.push_back(render.passes[sz - 2]); + } + tz::gpu::graph_add_pass(render.graph, render.passes[sz - 1], deps); + } + + void impl_pop_pass() + { + tz::gpu::destroy_pass(render.passes.back()); + render.passes.pop_back(); + tz_error("todo: implement graph remove pass"); } }