re-adding render to texture

This commit is contained in:
Kbz-8
2024-12-20 01:19:15 +01:00
parent b6660b99d6
commit b6edf442a2
7 changed files with 77 additions and 42 deletions

View File

@@ -67,7 +67,8 @@ namespace mlx
catch(...) { return nullptr; }
m_graphics.emplace_back(std::make_unique<GraphicsSupport>(info, m_graphics.size()));
m_in.RegisterWindow(m_graphics.back()->GetWindow());
if(m_graphics.back()->HasWindow())
m_in.RegisterWindow(m_graphics.back()->GetWindow());
m_graphics.back()->GetScene().BindFont(p_last_font_bound);
window->id = m_graphics.back()->GetID();
return window;

View File

@@ -1,9 +1,6 @@
#ifndef __MLX_HANDLES__
#define __MLX_HANDLES__
#include <Core/Application.h>
#include <Renderer/Image.h>
extern "C"
{
struct mlx_context_handler

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);
}