correctly destroy stuff
This commit is contained in:
@@ -58,7 +58,7 @@ namespace Game
|
|||||||
SetInstance(instance);
|
SetInstance(instance);
|
||||||
ResetScratch();
|
ResetScratch();
|
||||||
Puzzle::LoadStaticPuzzleData();
|
Puzzle::LoadStaticPuzzleData();
|
||||||
SetupInstance.Rendering.Setup({false});
|
SetupInstance.Rendering.Setup({});
|
||||||
instance.GameLevel.Setup(shared.Game);
|
instance.GameLevel.Setup(shared.Game);
|
||||||
instance.IsInitialized = true;
|
instance.IsInitialized = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,21 +84,7 @@ void DitherGen(DitherData& data, int32_t recursion)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Upload textures
|
// Upload textures
|
||||||
if (isValid(data.PreviewTex))
|
CleanupDitherData(data);
|
||||||
{
|
|
||||||
bgfx::destroy(data.PreviewTex);
|
|
||||||
data.PreviewTex = BGFX_INVALID_HANDLE;
|
|
||||||
}
|
|
||||||
if (isValid(data.FinalTex))
|
|
||||||
{
|
|
||||||
bgfx::destroy(data.FinalTex);
|
|
||||||
data.FinalTex = BGFX_INVALID_HANDLE;
|
|
||||||
}
|
|
||||||
if (isValid(data.RampTex))
|
|
||||||
{
|
|
||||||
bgfx::destroy(data.RampTex);
|
|
||||||
data.RampTex = BGFX_INVALID_HANDLE;
|
|
||||||
}
|
|
||||||
const bgfx::Memory* memPreview = bgfx::makeRef(data.DitherTex, texPixelCount * sizeof(Vec4));
|
const bgfx::Memory* memPreview = bgfx::makeRef(data.DitherTex, texPixelCount * sizeof(Vec4));
|
||||||
const bgfx::Memory* memFinal = bgfx::makeRef(data.DitherTex, texPixelCount * sizeof(Vec4));
|
const bgfx::Memory* memFinal = bgfx::makeRef(data.DitherTex, texPixelCount * sizeof(Vec4));
|
||||||
const bgfx::Memory* memRamp = bgfx::makeRef(data.BrightnessRamp, sizeof(data.BrightnessRamp));
|
const bgfx::Memory* memRamp = bgfx::makeRef(data.BrightnessRamp, sizeof(data.BrightnessRamp));
|
||||||
@@ -123,3 +109,22 @@ void DitherGen(DitherData& data, int32_t recursion)
|
|||||||
data.RampSampler = bgfx::createUniform("s_rampSampler", bgfx::UniformType::Sampler);
|
data.RampSampler = bgfx::createUniform("s_rampSampler", bgfx::UniformType::Sampler);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CleanupDitherData(DitherData& data)
|
||||||
|
{
|
||||||
|
if (isValid(data.PreviewTex))
|
||||||
|
{
|
||||||
|
bgfx::destroy(data.PreviewTex);
|
||||||
|
data.PreviewTex = BGFX_INVALID_HANDLE;
|
||||||
|
}
|
||||||
|
if (isValid(data.FinalTex))
|
||||||
|
{
|
||||||
|
bgfx::destroy(data.FinalTex);
|
||||||
|
data.FinalTex = BGFX_INVALID_HANDLE;
|
||||||
|
}
|
||||||
|
if (isValid(data.RampTex))
|
||||||
|
{
|
||||||
|
bgfx::destroy(data.RampTex);
|
||||||
|
data.RampTex = BGFX_INVALID_HANDLE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -24,3 +24,4 @@ struct DitherData
|
|||||||
};
|
};
|
||||||
|
|
||||||
void DitherGen(DitherData& data, int32_t recursion);
|
void DitherGen(DitherData& data, int32_t recursion);
|
||||||
|
void CleanupDitherData(DitherData& data);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "../Tools.h"
|
#include "../Tools.h"
|
||||||
#include "Rendering.h"
|
#include "Rendering.h"
|
||||||
|
|
||||||
|
#include "Dither.h"
|
||||||
#include "SDL3/SDL_events.h" // IWYU pragma: keep
|
#include "SDL3/SDL_events.h" // IWYU pragma: keep
|
||||||
#include "backends/imgui_impl_sdl3.h"
|
#include "backends/imgui_impl_sdl3.h"
|
||||||
#include "bgfx/defines.h"
|
#include "bgfx/defines.h"
|
||||||
@@ -326,9 +327,10 @@ namespace Game
|
|||||||
bgfx::Init init;
|
bgfx::Init init;
|
||||||
init.type = bgfx::RendererType::Direct3D12;
|
init.type = bgfx::RendererType::Direct3D12;
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
// init.debug = true;
|
init.debug = true;
|
||||||
#else
|
|
||||||
// init.debug = false;
|
// init.debug = false;
|
||||||
|
#else
|
||||||
|
init.debug = false;
|
||||||
#endif
|
#endif
|
||||||
init.platformData.nwh = shared.Window.Handle;
|
init.platformData.nwh = shared.Window.Handle;
|
||||||
init.platformData.ndt = nullptr;
|
init.platformData.ndt = nullptr;
|
||||||
@@ -558,6 +560,22 @@ namespace Game
|
|||||||
ZoneScopedN("Shutdown");
|
ZoneScopedN("Shutdown");
|
||||||
LOG("--- RENDERING_SHUTDOWN ---");
|
LOG("--- RENDERING_SHUTDOWN ---");
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < BX_COUNTOF(Textures); ++i)
|
||||||
|
{
|
||||||
|
if (isValid(Textures[i].RenderHandle))
|
||||||
|
{
|
||||||
|
bgfx::destroy(Textures[i].RenderHandle);
|
||||||
|
Textures[i].RenderHandle = {bgfx::kInvalidHandle};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int32_t i = 0; i < ModelCount; ++i)
|
||||||
|
{
|
||||||
|
bgfx::destroy(Models[i].VertexBuffer);
|
||||||
|
bgfx::destroy(Models[i].IndexBuffer);
|
||||||
|
}
|
||||||
|
ModelCount = 0;
|
||||||
|
|
||||||
|
CleanupDitherData(DitherTextures);
|
||||||
if (SetupData.UseImgui)
|
if (SetupData.UseImgui)
|
||||||
{
|
{
|
||||||
ImGui::SaveIniSettingsToDisk("imgui.ini");
|
ImGui::SaveIniSettingsToDisk("imgui.ini");
|
||||||
|
|||||||
Reference in New Issue
Block a user