mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 14:43:34 +00:00
yes
This commit is contained in:
@@ -21,10 +21,8 @@ namespace mlx
|
|||||||
{
|
{
|
||||||
using namespace std::literals;
|
using namespace std::literals;
|
||||||
|
|
||||||
#ifndef DEBUG
|
if(type == LogType::Debug && std::getenv("MLX_DEBUG_LOGS") == nullptr)
|
||||||
if(type == LogType::Debug)
|
return;
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
std::string code_infos;
|
std::string code_infos;
|
||||||
if((type == LogType::Error || type == LogType::FatalError) && !file.empty() && !function.empty())
|
if((type == LogType::Error || type == LogType::FatalError) && !file.empty() && !function.empty())
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ namespace mlx
|
|||||||
SDL_SetHint(SDL_HINT_VIDEODRIVER, "wayland,x11");
|
SDL_SetHint(SDL_HINT_VIDEODRIVER, "wayland,x11");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//SDL_SetHintWithPriority(SDL_HINT_SHUTDOWN_DBUS_ON_QUIT, "1", SDL_HINT_OVERRIDE);
|
||||||
|
|
||||||
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS | SDL_INIT_TIMER) != 0)
|
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS | SDL_INIT_TIMER) != 0)
|
||||||
FatalError("SDL: unable to init all subsystems; %", SDL_GetError());
|
FatalError("SDL: unable to init all subsystems; %", SDL_GetError());
|
||||||
DebugLog("SDL Manager initialized");
|
DebugLog("SDL Manager initialized");
|
||||||
@@ -252,6 +254,7 @@ namespace mlx
|
|||||||
case SDL_WINDOWEVENT_FOCUS_GAINED: functor(MLX_WINDOW_EVENT, id, 5); break;
|
case SDL_WINDOWEVENT_FOCUS_GAINED: functor(MLX_WINDOW_EVENT, id, 5); break;
|
||||||
case SDL_WINDOWEVENT_LEAVE: functor(MLX_WINDOW_EVENT, id, 6); break;
|
case SDL_WINDOWEVENT_LEAVE: functor(MLX_WINDOW_EVENT, id, 6); break;
|
||||||
case SDL_WINDOWEVENT_FOCUS_LOST: functor(MLX_WINDOW_EVENT, id, 7); break;
|
case SDL_WINDOWEVENT_FOCUS_LOST: functor(MLX_WINDOW_EVENT, id, 7); break;
|
||||||
|
case SDL_WINDOWEVENT_SIZE_CHANGED: functor(MLX_WINDOW_EVENT, id, 8); break;
|
||||||
|
|
||||||
default : break;
|
default : break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,19 @@
|
|||||||
#include <PreCompiled.h>
|
#include <PreCompiled.h>
|
||||||
|
|
||||||
#include <mlx.h>
|
|
||||||
#include <Platform/Inputs.h>
|
#include <Platform/Inputs.h>
|
||||||
#include <Core/SDLManager.h>
|
#include <Core/SDLManager.h>
|
||||||
|
#include <Core/EventBus.h>
|
||||||
|
|
||||||
namespace mlx
|
namespace mlx
|
||||||
{
|
{
|
||||||
|
namespace Internal
|
||||||
|
{
|
||||||
|
struct ResizeEventBroadcast : public EventBase
|
||||||
|
{
|
||||||
|
Event What() const override { return Event::ResizeEventCode; }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
void Inputs::FetchInputs()
|
void Inputs::FetchInputs()
|
||||||
{
|
{
|
||||||
SDLManager::Get().InputsFetcher([this](mlx_event_type event, int window_id, int code)
|
SDLManager::Get().InputsFetcher([this](mlx_event_type event, int window_id, int code)
|
||||||
@@ -14,6 +22,8 @@ namespace mlx
|
|||||||
return;
|
return;
|
||||||
if(!m_events_hooks.contains(window_id) || m_events_hooks[window_id][event].empty())
|
if(!m_events_hooks.contains(window_id) || m_events_hooks[window_id][event].empty())
|
||||||
return;
|
return;
|
||||||
|
if(event == MLX_WINDOW_EVENT && code == 8)
|
||||||
|
EventBus::SendBroadcast(Internal::ResizeEventBroadcast{});
|
||||||
for(const auto& hook : m_events_hooks[window_id][event])
|
for(const auto& hook : m_events_hooks[window_id][event])
|
||||||
{
|
{
|
||||||
if(hook.fn)
|
if(hook.fn)
|
||||||
|
|||||||
@@ -112,10 +112,13 @@ namespace mlx
|
|||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DescriptorPool::ReturnDescriptorSet(std::shared_ptr<class DescriptorSet> set)
|
void DescriptorPool::ReturnDescriptorSet(std::shared_ptr<DescriptorSet> set)
|
||||||
{
|
{
|
||||||
auto it = std::find_if(m_used_sets.begin(), m_used_sets.end(), [&](std::shared_ptr<DescriptorSet> rhs_set)
|
std::size_t i = 0;
|
||||||
|
auto it = std::find_if(m_used_sets.begin(), m_used_sets.end(), [&](const std::shared_ptr<DescriptorSet>& rhs_set)
|
||||||
{
|
{
|
||||||
|
i++;
|
||||||
|
std::cout << m_used_sets.size() << " " << i << std::endl;
|
||||||
return set == rhs_set;
|
return set == rhs_set;
|
||||||
});
|
});
|
||||||
if(it == m_used_sets.end())
|
if(it == m_used_sets.end())
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ namespace mlx
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string VulkanFormatName(VkFormat format)
|
std::string VulkanFormatName(VkFormat format)
|
||||||
{
|
{
|
||||||
#define STRINGIFY(x) case x: return #x
|
#define STRINGIFY(x) case x: return #x
|
||||||
@@ -159,7 +158,16 @@ namespace mlx
|
|||||||
void Swapchain::Init(NonOwningPtr<Window> window)
|
void Swapchain::Init(NonOwningPtr<Window> window)
|
||||||
{
|
{
|
||||||
p_window = window;
|
p_window = window;
|
||||||
|
|
||||||
|
std::function<void(const EventBase&)> functor = [this](const EventBase& event)
|
||||||
|
{
|
||||||
|
if(event.What() == Event::ResizeEventCode && !m_resize)
|
||||||
|
m_resize = true;
|
||||||
|
};
|
||||||
|
EventBus::RegisterListener({ functor, "mlx_swapchain_" + std::to_string(reinterpret_cast<std::uintptr_t>(this)) });
|
||||||
|
|
||||||
CreateSwapchain();
|
CreateSwapchain();
|
||||||
|
m_resize = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Swapchain::AquireFrame(VkSemaphore signal)
|
void Swapchain::AquireFrame(VkSemaphore signal)
|
||||||
@@ -170,6 +178,7 @@ namespace mlx
|
|||||||
Destroy();
|
Destroy();
|
||||||
CreateSwapchain();
|
CreateSwapchain();
|
||||||
EventBus::SendBroadcast(Internal::ResizeEventBroadcast{});
|
EventBus::SendBroadcast(Internal::ResizeEventBroadcast{});
|
||||||
|
m_resize = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkResult result = RenderCore::Get().vkAcquireNextImageKHR(RenderCore::Get().GetDevice(), m_swapchain, UINT64_MAX, signal, VK_NULL_HANDLE, &m_current_image_index);
|
VkResult result = RenderCore::Get().vkAcquireNextImageKHR(RenderCore::Get().GetDevice(), m_swapchain, UINT64_MAX, signal, VK_NULL_HANDLE, &m_current_image_index);
|
||||||
@@ -245,7 +254,6 @@ namespace mlx
|
|||||||
kvfSubmitSingleTimeCommandBuffer(RenderCore::Get().GetDevice(), cmd, KVF_GRAPHICS_QUEUE, fence);
|
kvfSubmitSingleTimeCommandBuffer(RenderCore::Get().GetDevice(), cmd, KVF_GRAPHICS_QUEUE, fence);
|
||||||
kvfDestroyFence(RenderCore::Get().GetDevice(), fence);
|
kvfDestroyFence(RenderCore::Get().GetDevice(), fence);
|
||||||
kvfDestroyCommandBuffer(RenderCore::Get().GetDevice(), cmd);
|
kvfDestroyCommandBuffer(RenderCore::Get().GetDevice(), cmd);
|
||||||
m_resize = false;
|
|
||||||
DebugLog("Vulkan: swapchain created with format %", VulkanFormatName(format));
|
DebugLog("Vulkan: swapchain created with format %", VulkanFormatName(format));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user