re-adding render to texture

This commit is contained in:
2024-12-20 01:19:15 +01:00
parent 952e48a05c
commit 4e326db10d
7 changed files with 77 additions and 42 deletions

View File

@@ -1,5 +1,7 @@
#include <PreCompiled.h>
#include <Core/Graphics.h>
#include <Core/Application.h>
#include <Core/Handles.h>
namespace mlx
{
@@ -9,11 +11,24 @@ namespace mlx
{
MLX_PROFILE_FUNCTION();
p_window = std::make_shared<Window>(info);
m_has_window = true;
if(info->render_target == nullptr)
{
p_window = std::make_shared<Window>(info);
m_has_window = true;
}
else
m_has_window = false;
m_renderer.Init(p_window.get());
m_scene_renderer.Init(nullptr);
if(info->render_target != nullptr)
{
m_renderer.Init(info->render_target->texture);
m_scene_renderer.Init(info->render_target->texture);
}
else
{
m_renderer.Init(p_window.get());
m_scene_renderer.Init(nullptr);
}
p_scene = std::make_unique<Scene>();
}
@@ -25,7 +40,7 @@ namespace mlx
m_scene_renderer.Render(*p_scene, m_renderer);
m_renderer.EndFrame();
#ifdef GRAPHICS_MEMORY_DUMP
// dump memory to file every two seconds
// Dump memory usage to file every two seconds
using namespace std::chrono_literals;
static std::int64_t timer = static_cast<std::uint64_t>(std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count());
if(std::chrono::duration<std::uint64_t>{ static_cast<std::uint64_t>(std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count()) - timer } >= 1s)

View File

@@ -29,9 +29,9 @@ namespace mlx
else
extent = kvfGetSwapchainImagesSize(renderer.GetSwapchain().Get());
#ifdef DEBUG
m_main_render_texture.Init({}, extent.width, extent.height, VK_FORMAT_R8G8B8A8_SRGB, false, "mlx_renderpasses_target");
m_main_render_texture.Init({}, extent.width, extent.height, VK_FORMAT_R8G8B8A8_UNORM, false, "mlx_renderpasses_target");
#else
m_main_render_texture.Init({}, extent.width, extent.height, VK_FORMAT_R8G8B8A8_SRGB, false, {});
m_main_render_texture.Init({}, extent.width, extent.height, VK_FORMAT_R8G8B8A8_UNORM, false, {});
#endif
m_main_render_texture.TransitionLayout(VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
}