-
Notifications
You must be signed in to change notification settings - Fork 0
feature: export Runtime to Distribution #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,9 +3,31 @@ | |
|
|
||
| #include "Lux/Core/Application.h" | ||
| #include "Lux/Renderer/Renderer.h" | ||
| #include "Lux/Platform/Vulkan/VulkanSwapChain.h" | ||
|
|
||
| namespace Lux { | ||
|
|
||
| namespace | ||
| { | ||
| static void PopulateClearValues(const FramebufferSpecification& specification, std::vector<ClearValue>& clearValues) | ||
| { | ||
| clearValues.resize(specification.Attachments.Attachments.size()); | ||
|
|
||
| for (uint32_t attachmentIndex = 0; attachmentIndex < specification.Attachments.Attachments.size(); attachmentIndex++) | ||
| { | ||
| const auto& attachmentSpec = specification.Attachments.Attachments[attachmentIndex]; | ||
| if (Utils::IsDepthFormat(attachmentSpec.Format)) | ||
| { | ||
| clearValues[attachmentIndex].DepthStencil = { specification.DepthClearValue, 0 }; | ||
| continue; | ||
| } | ||
|
|
||
| const auto& clearColor = specification.ClearColor; | ||
| clearValues[attachmentIndex].Color = { { clearColor.r, clearColor.g, clearColor.b, clearColor.a } }; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #if WENEEDTODEALWITHTHIS | ||
| namespace Utils { | ||
|
|
||
|
|
@@ -39,6 +61,12 @@ namespace Lux { | |
| m_Height = (uint32_t)(specification.Height * m_Specification.Scale); | ||
| } | ||
|
|
||
| if (m_Specification.SwapChainTarget) | ||
| { | ||
| PopulateClearValues(m_Specification, m_ClearValues); | ||
| return; | ||
| } | ||
|
Comment on lines
+64
to
+68
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a swapchain-target attachment guard before the early return. Line 67 returns before the constructor reaches the general attachment validation, so a swapchain framebuffer with zero attachments can leave 🛠️ Suggested fix if (m_Specification.SwapChainTarget)
{
+ LUX_CORE_ASSERT(!m_Specification.Attachments.Attachments.empty(), "SwapChainTarget framebuffer requires at least one attachment");
PopulateClearValues(m_Specification, m_ClearValues);
return;
}🤖 Prompt for AI Agents |
||
|
|
||
| // Create all image objects immediately so we can start referencing them | ||
| // elsewhere | ||
| uint32_t attachmentIndex = 0; | ||
|
|
@@ -96,6 +124,30 @@ namespace Lux { | |
| Release(); | ||
| } | ||
|
|
||
| uint32_t Framebuffer::GetWidth() const | ||
| { | ||
| if (m_Specification.SwapChainTarget) | ||
| return Application::Get().GetWindow().GetSwapChain().GetWidth(); | ||
|
|
||
| return m_Width; | ||
| } | ||
|
|
||
| uint32_t Framebuffer::GetHeight() const | ||
| { | ||
| if (m_Specification.SwapChainTarget) | ||
| return Application::Get().GetWindow().GetSwapChain().GetHeight(); | ||
|
|
||
| return m_Height; | ||
| } | ||
|
|
||
| nvrhi::FramebufferHandle Framebuffer::GetHandle() const | ||
| { | ||
| if (m_Specification.SwapChainTarget) | ||
| return Application::Get().GetWindow().GetSwapChain().GetCurrentFramebuffer(); | ||
|
|
||
| return m_Handle; | ||
| } | ||
|
|
||
| void Framebuffer::Release() | ||
| { | ||
| #if DEAL | ||
|
|
@@ -166,14 +218,10 @@ namespace Lux { | |
|
|
||
| m_Width = (uint32_t)(width * m_Specification.Scale); | ||
| m_Height = (uint32_t)(height * m_Specification.Scale); | ||
| if (!m_Specification.SwapChainTarget) | ||
| { | ||
| RT_Invalidate(); | ||
| } | ||
| if (m_Specification.SwapChainTarget) | ||
| PopulateClearValues(m_Specification, m_ClearValues); | ||
| else | ||
| { | ||
| LUX_CORE_VERIFY(false); | ||
| } | ||
| RT_Invalidate(); | ||
|
|
||
| for (auto& callback : m_ResizeCallbacks) | ||
| callback(this); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -197,8 +197,12 @@ namespace Lux { | |
|
|
||
| void ScriptEngine::Shutdown() | ||
| { | ||
| if (!s_Data) | ||
| return; | ||
|
|
||
| ShutdownMono(); | ||
| delete s_Data; | ||
| s_Data = nullptr; | ||
| } | ||
|
|
||
| void ScriptEngine::InitMono() | ||
|
|
@@ -232,10 +236,16 @@ namespace Lux { | |
|
|
||
| void ScriptEngine::ShutdownMono() | ||
| { | ||
| if (!s_Data || !s_Data->RootDomain) | ||
| return; | ||
|
|
||
| mono_domain_set(mono_get_root_domain(), false); | ||
|
|
||
| mono_domain_unload(s_Data->AppDomain); | ||
| s_Data->AppDomain = nullptr; | ||
| if (s_Data->AppDomain) | ||
| { | ||
| mono_domain_unload(s_Data->AppDomain); | ||
| s_Data->AppDomain = nullptr; | ||
| } | ||
|
Comment on lines
+239
to
+248
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Stop file-watch callbacks before domain teardown to avoid shutdown races.
Proposed fixdiff --git a/Core/Source/Lux/Scripting/ScriptEngine.cpp b/Core/Source/Lux/Scripting/ScriptEngine.cpp
@@
static void OnAppAssemblyFileSystemEvent(const std::string& path, const filewatch::Event change_type)
{
+ if (!s_Data)
+ return;
+
if (!s_Data->AssemblyReloadPending && change_type == filewatch::Event::modified)
{
s_Data->AssemblyReloadPending = true;
Application::Get().QueueEvent([]()
{
+ if (!s_Data)
+ return;
s_Data->AppAssemblyFileWatcher.reset();
ScriptEngine::ReloadAssembly();
});
}
}
@@
void ScriptEngine::Shutdown()
{
if (!s_Data)
return;
+ s_Data->AppAssemblyFileWatcher.reset();
ShutdownMono();
delete s_Data;
s_Data = nullptr;
}🤖 Prompt for AI Agents |
||
|
|
||
| mono_jit_cleanup(s_Data->RootDomain); | ||
| s_Data->RootDomain = nullptr; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not skip audio shutdown when clearing the active runtime project.
Line 70 returns on
nullptrand bypasses the cleanup block at Line 80, soProject::SetActiveRuntime(nullptr, nullptr)can leave the audio engine initialized.🛠️ Suggested fix
📝 Committable suggestion
🤖 Prompt for AI Agents