fixed lua allocator; fixed saved window size when not maximized; refactor; minor ux improvements; composite texture - translate node

This commit is contained in:
Mikulas Florek 2023-07-26 20:42:13 +02:00
parent 54f2c24d83
commit 18b38a2030
32 changed files with 319 additions and 283 deletions

View file

@ -3,7 +3,6 @@
#include "animation/animation.h"
#include "animation/property_animation.h"
#include "animation/controller.h"
#include "engine/debug.h"
#include "engine/engine.h"
#include "engine/resource_manager.h"
#include "engine/world.h"
@ -56,7 +55,7 @@ struct AnimationSystemImpl final : ISystem
void serialize(OutputMemoryStream& stream) const override {}
bool deserialize(i32 version, InputMemoryStream& stream) override { return version == 0; }
debug::TagAllocator m_allocator;
TagAllocator m_allocator;
Engine& m_engine;
AnimResourceManager<Animation> m_animation_manager;
AnimResourceManager<PropertyAnimation> m_property_animation_manager;

View file

@ -70,7 +70,7 @@ struct AudioSystemImpl final : AudioSystem {
Engine& m_engine;
debug::TagAllocator m_allocator;
TagAllocator m_allocator;
ClipManager m_manager;
UniquePtr<AudioDevice> m_device;
};

View file

@ -7,7 +7,6 @@
#include "editor/utils.h"
#include "editor/world_editor.h"
#include "engine/atomic.h"
#include "engine/debug.h"
#include "engine/engine.h"
#include "engine/hash.h"
#include "engine/job_system.h"
@ -838,7 +837,7 @@ struct AssetCompilerImpl : AssetCompiler {
return m_resources;
}
debug::TagAllocator m_allocator;
TagAllocator m_allocator;
Semaphore m_semaphore;
Mutex m_to_compile_mutex;
Mutex m_compiled_mutex;

View file

@ -23,8 +23,7 @@
#include "engine/string.h"
namespace Lumix
{
namespace Lumix {
namespace {
@ -199,15 +198,17 @@ struct Block {
profiler::JobRecord job_info;
};
struct ProfilerUIImpl final : ProfilerUI {
struct ProfilerUIImpl final : StudioApp::GUIPlugin {
ProfilerUIImpl(StudioApp& app, debug::Allocator* allocator, Engine& engine)
: m_debug_allocator(allocator)
: m_allocator(engine.getAllocator())
, m_debug_allocator(allocator)
, m_app(app)
, m_threads(m_allocator)
, m_data(m_allocator)
, m_blocks(m_allocator)
, m_counters(m_allocator)
, m_allocation_tags(m_allocator)
// we can't use m_allocator for tags, because it would create circular dependency and deadlock
, m_allocation_tags(getGlobalAllocator())
, m_engine(engine)
{
m_current_frame = -1;
@ -700,22 +701,15 @@ struct ProfilerUIImpl final : ProfilerUI {
}
void onGUIMemoryProfiler() {
if (m_debug_allocator) {
if (ImGui::Button("Refresh"))
{
refreshAllocations();
}
ImGui::SameLine();
if (ImGui::Button("Check memory"))
{
m_debug_allocator->checkGuards();
}
}
else {
if (!m_debug_allocator) {
ImGui::TextUnformatted("Debug allocator not used, can't print memory stats.");
return;
}
if (ImGui::Button("Capture")) captureAllocations();
ImGui::SameLine();
if (ImGui::Button("Check memory")) m_debug_allocator->checkGuards();
size_t total = 0;
for (AllocationTag& tag : m_allocation_tags) {
total += tag.m_size;
@ -735,7 +729,7 @@ struct ProfilerUIImpl final : ProfilerUI {
break;
}
n = debug::StackTree::getParent(n);
} while (n && strstr(fn_name, "TagAllocator::allocate") != 0);
} while (n && strstr(fn_name, "Allocator::") != 0);
ImGui::Text("%s: L%d:", fn_name, line);
if (ImGui::IsItemHovered()) callstackTooltip(a.stack_node);
ImGui::NextColumn();
@ -753,8 +747,7 @@ struct ProfilerUIImpl final : ProfilerUI {
ImGui::Text("Total: %d MB", u32(total / 1024 / 1024));
const u32 reserved_pages = m_app.getEngine().getPageAllocator().getReservedCount() * PageAllocator::PAGE_SIZE;
ImGui::Text("Page allocator: %.1f MB", reserved_pages / 1024.f / 1024.f);
ImGui::Text("Lua: %.1f MB", m_app.getEngine().getLuaAllocated() / 1024.f / 1024.f);
// TODO os::memcommit sources, e.g. linear allocators
ImGui::Text("Linear allocators: %.1f MB", LinearAllocator::getTotalCommitedBytes() / 1024.f / 1024.f);
// TODO gpu mem
}
@ -1314,10 +1307,10 @@ struct ProfilerUIImpl final : ProfilerUI {
for (AllocationTag& tag : m_allocation_tags) {
if (tag.m_tag == name) return tag;
}
return m_allocation_tags.emplace(name, m_allocator);
return m_allocation_tags.emplace(name, getGlobalAllocator());
}
void refreshAllocations() {
void captureAllocations() {
if (!m_debug_allocator) return;
m_allocation_tags.clear();
@ -1367,7 +1360,7 @@ struct ProfilerUIImpl final : ProfilerUI {
}
StudioApp& m_app;
DefaultAllocator m_allocator;
IAllocator& m_allocator;
debug::Allocator* m_debug_allocator;
Array<AllocationTag> m_allocation_tags;
int m_current_frame;
@ -1425,8 +1418,7 @@ struct ProfilerUIImpl final : ProfilerUI {
} // anonymous namespace
UniquePtr<ProfilerUI> ProfilerUI::create(StudioApp& app)
{
UniquePtr<StudioApp::GUIPlugin> createProfilerUI(StudioApp& app) {
Engine& engine = app.getEngine();
debug::Allocator* debug_allocator = nullptr;
IAllocator* allocator = &engine.getAllocator();

View file

@ -1,21 +1,11 @@
#pragma once
#include "editor/studio_app.h"
#include "engine/lumix.h"
namespace Lumix {
namespace Lumix
{
struct Engine;
template <typename T> struct UniquePtr;
struct ProfilerUI : StudioApp::GUIPlugin
{
static UniquePtr<ProfilerUI> create(struct StudioApp& app);
};
UniquePtr<StudioApp::GUIPlugin> createProfilerUI(StudioApp& app);
} // namespace Lumix
}

View file

@ -87,7 +87,7 @@ struct StudioAppImpl final : StudioApp
, m_settings(*this)
, m_gui_plugins(m_allocator)
, m_mouse_plugins(m_allocator)
, m_systems(m_allocator)
, m_plugins(m_allocator)
, m_add_cmp_plugins(m_allocator)
, m_component_labels(m_allocator)
, m_component_icons(m_allocator)
@ -144,19 +144,7 @@ struct StudioAppImpl final : StudioApp
const bool handle_input = isFocused();
m_events.push(event);
switch (event.type) {
case os::Event::Type::MOUSE_MOVE:
if (!m_cursor_captured) {
ImGuiIO& io = ImGui::GetIO();
const os::Point cp = os::getMouseScreenPos();
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) {
io.AddMousePosEvent((float)cp.x, (float)cp.y);
}
else {
const os::Rect screen_rect = os::getWindowScreenRect(m_main_window);
io.AddMousePosEvent((float)cp.x - screen_rect.left, (float)cp.y - screen_rect.top);
}
}
break;
case os::Event::Type::MOUSE_MOVE: break;
case os::Event::Type::FOCUS: {
ImGuiIO& io = ImGui::GetIO();
io.AddFocusEvent(isFocused());
@ -180,22 +168,12 @@ struct StudioAppImpl final : StudioApp
ImGuiViewport* vp = ImGui::FindViewportByPlatformHandle(event.window);
if (vp) vp->PlatformRequestResize = true;
}
if (event.window == m_main_window && event.win_size.h > 0 && event.win_size.w > 0) {
m_settings.m_window.w = event.win_size.w;
m_settings.m_window.h = event.win_size.h;
m_settings.m_is_maximized = os::isMaximized(m_main_window);
}
break;
case os::Event::Type::WINDOW_MOVE:
if (ImGui::GetCurrentContext()) {
ImGuiViewport* vp = ImGui::FindViewportByPlatformHandle(event.window);
if (vp) vp->PlatformRequestMove = true;
}
if (event.window == m_main_window && !os::isMinimized(event.window)) {
m_settings.m_window.x = event.win_move.x;
m_settings.m_window.y = event.win_move.y;
m_settings.m_is_maximized = os::isMaximized(m_main_window);
}
break;
case os::Event::Type::WINDOW_CLOSE: {
ImGuiViewport* vp = ImGui::FindViewportByPlatformHandle(event.window);
@ -250,8 +228,7 @@ struct StudioAppImpl final : StudioApp
}
}
void onIdle()
{
void onIdle() {
update();
if (m_settings.m_sleep_when_inactive && !isFocused()) {
@ -350,7 +327,7 @@ struct StudioAppImpl final : StudioApp
m_windows.push(m_main_window);
logInfo("Current directory: ", current_dir);
createLua();
registerLuaAPI();
extractBundled();
m_asset_compiler = AssetCompiler::create(*this);
@ -362,16 +339,17 @@ struct StudioAppImpl final : StudioApp
m_asset_browser = AssetBrowser::create(*this);
m_property_grid.create(*this);
m_profiler_ui = ProfilerUI::create(*this);
m_profiler_ui = createProfilerUI(*this);
m_log_ui.create(*this, m_allocator);
// TODO refactor so we don't need to call loadSettings twice
ImGui::SetAllocatorFunctions(imguiAlloc, imguiFree, this);
ImGui::CreateContext();
loadSettings();
initIMGUI();
loadSettings(); // needs imgui context
initIMGUI(); // needs settings
initPlugins(); // needs initialized imgui
loadSettings(); // needs plugins
setStudioApp();
loadSettings();
loadWorldFromCommandLine();
m_asset_compiler->onInitFinished();
@ -403,10 +381,10 @@ struct StudioAppImpl final : StudioApp
destroyAddCmpTreeNode(m_add_cmp_root.child);
for (auto* i : m_systems) {
for (auto* i : m_plugins) {
LUMIX_DELETE(m_allocator, i);
}
m_systems.clear();
m_plugins.clear();
for (auto* i : m_gui_plugins) {
LUMIX_DELETE(m_allocator, i);
@ -668,6 +646,17 @@ struct StudioAppImpl final : StudioApp
}
io.DeltaTime = m_engine->getLastTimeDelta();
if (!m_cursor_captured) {
const os::Point cp = os::getMouseScreenPos();
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) {
io.AddMousePosEvent((float)cp.x, (float)cp.y);
}
else {
const os::Rect screen_rect = os::getWindowScreenRect(m_main_window);
io.AddMousePosEvent((float)cp.x - screen_rect.left, (float)cp.y - screen_rect.top);
}
}
const ImGuiMouseCursor imgui_cursor = ImGui::GetMouseCursor();
ImGui::NewFrame();
if (!m_cursor_captured) {
@ -767,7 +756,7 @@ struct StudioAppImpl final : StudioApp
}
for (ComponentUID cmp = world->getFirstComponent(ents[0]); cmp.isValid(); cmp = world->getNextComponent(cmp)) {
for (auto* plugin : m_systems) {
for (auto* plugin : m_plugins) {
if (plugin->showGizmo(view, cmp)) break;
}
}
@ -1997,6 +1986,14 @@ struct StudioAppImpl final : StudioApp
m_settings.m_is_entity_list_open = m_is_entity_list_open;
m_settings.setValue(Settings::LOCAL, "fileselector_dir", m_file_selector.m_current_dir.c_str());
if (!os::isMinimized(m_main_window)) {
os::Rect win_rect = os::getWindowScreenRect(m_main_window);
m_settings.m_window.x = win_rect.left;
m_settings.m_window.y = win_rect.top;
m_settings.m_window.w = win_rect.width;
m_settings.m_window.h = win_rect.height;
}
for (auto* i : m_gui_plugins) {
i->onBeforeSettingsSaved();
}
@ -2517,7 +2514,7 @@ struct StudioAppImpl final : StudioApp
}
IPlugin* getIPlugin(const char* name) override {
for (auto* i : m_systems) {
for (auto* i : m_plugins) {
if (equalStrings(i->getName(), name)) return i;
}
return nullptr;
@ -2531,20 +2528,45 @@ struct StudioAppImpl final : StudioApp
}
void initPlugins()
{
for (int i = 1, c = m_systems.size(); i < c; ++i) {
void initPlugins() {
#ifdef STATIC_PLUGINS
#define LUMIX_EDITOR_PLUGINS
#include "engine/plugins.inl"
#undef LUMIX_EDITOR_PLUGINS
#else
auto& plugin_manager = m_engine->getSystemManager();
for (auto* lib : plugin_manager.getLibraries())
{
auto* f = (StudioApp::IPlugin * (*)(StudioApp&)) os::getLibrarySymbol(lib, "setStudioApp");
if (f)
{
StudioApp::IPlugin* plugin = f(*this);
if (plugin) addPlugin(*plugin);
}
}
#endif
addPlugin(*createSplineEditor(*this));
addPlugin(*m_property_grid.get());
addPlugin(*m_log_ui.get());
addPlugin(*m_asset_browser.get());
addPlugin(*m_profiler_ui.get());
for (IPlugin* plugin : m_plugins) {
logInfo("Studio plugin ", plugin->getName(), " loaded");
}
for (int i = 1, c = m_plugins.size(); i < c; ++i) {
for (int j = 0; j < i; ++j) {
IPlugin* p = m_systems[i];
if (m_systems[j]->dependsOn(*p)) {
m_systems.erase(i);
IPlugin* p = m_plugins[i];
if (m_plugins[j]->dependsOn(*p)) {
m_plugins.erase(i);
--i;
m_systems.insert(j, p);
m_plugins.insert(j, p);
}
}
}
for (IPlugin* plugin : m_systems) {
for (IPlugin* plugin : m_plugins) {
plugin->init();
}
@ -2578,10 +2600,11 @@ struct StudioAppImpl final : StudioApp
registerComponent(r->icon, r->component_type, r->label);
}
}
PrefabSystem::createEditorPlugins(*this, m_editor->getPrefabSystem());
}
void addPlugin(IPlugin& plugin) override { m_systems.push(&plugin); }
void addPlugin(IPlugin& plugin) override { m_plugins.push(&plugin); }
void addPlugin(GUIPlugin& plugin) override
@ -2598,38 +2621,6 @@ struct StudioAppImpl final : StudioApp
void removePlugin(GUIPlugin& plugin) override { m_gui_plugins.swapAndPopItem(&plugin); }
void removePlugin(MousePlugin& plugin) override { m_mouse_plugins.swapAndPopItem(&plugin); }
void setStudioApp()
{
#ifdef STATIC_PLUGINS
#define LUMIX_EDITOR_PLUGINS
#include "engine/plugins.inl"
#undef LUMIX_EDITOR_PLUGINS
#else
auto& plugin_manager = m_engine->getSystemManager();
for (auto* lib : plugin_manager.getLibraries())
{
auto* f = (StudioApp::IPlugin * (*)(StudioApp&)) os::getLibrarySymbol(lib, "setStudioApp");
if (f)
{
StudioApp::IPlugin* plugin = f(*this);
if (plugin) addPlugin(*plugin);
}
}
#endif
addPlugin(*createSplineEditor(*this));
addPlugin(*m_property_grid.get());
addPlugin(*m_log_ui.get());
addPlugin(*m_asset_browser.get());
addPlugin(*m_profiler_ui.get());
for (IPlugin* plugin : m_systems) {
logInfo("Studio plugin ", plugin->getName(), " loaded");
}
initPlugins();
PrefabSystem::createEditorPlugins(*this, m_editor->getPrefabSystem());
}
void runScript(const char* src, const char* script_name) override
{
@ -2889,7 +2880,7 @@ struct StudioAppImpl final : StudioApp
}
void createLua()
void registerLuaAPI()
{
lua_State* L = m_engine->getState();
@ -3329,8 +3320,8 @@ struct StudioAppImpl final : StudioApp
DefaultAllocator m_main_allocator;
debug::Allocator m_debug_allocator;
debug::TagAllocator m_allocator;
debug::TagAllocator m_imgui_allocator;
TagAllocator m_allocator;
TagAllocator m_imgui_allocator;
UniquePtr<Engine> m_engine;
UniquePtr<WorldEditor> m_editor;
@ -3352,7 +3343,7 @@ struct StudioAppImpl final : StudioApp
Array<GUIPlugin*> m_gui_plugins;
Array<MousePlugin*> m_mouse_plugins;
Array<IPlugin*> m_systems;
Array<IPlugin*> m_plugins;
Array<IAddComponentPlugin*> m_add_cmp_plugins;
Array<StaticString<LUMIX_MAX_PATH>> m_worlds;
@ -3374,7 +3365,7 @@ struct StudioAppImpl final : StudioApp
UniquePtr<AssetBrowser> m_asset_browser;
UniquePtr<AssetCompiler> m_asset_compiler;
Local<PropertyGrid> m_property_grid;
UniquePtr<ProfilerUI> m_profiler_ui;
UniquePtr<GUIPlugin> m_profiler_ui;
Local<LogUI> m_log_ui;
Settings m_settings;

View file

@ -15,6 +15,7 @@ namespace Lumix {
struct LUMIX_ENGINE_API IAllocator {
virtual ~IAllocator() {}
virtual bool isDebug() const { return false; }
virtual bool isTagAllocator() const { return false; }
virtual IAllocator* getParent() { return nullptr; }
virtual void* allocate(size_t size) = 0;

View file

@ -311,7 +311,7 @@ void* BaseProxyAllocator::reallocate(void* ptr, size_t new_size, size_t old_size
LinearAllocator::LinearAllocator(u32 reserved) {
m_end = 0;
m_commited = 0;
m_commited_bytes = 0;
m_reserved = reserved;
m_mem = (u8*)os::memReserve(reserved);
}
@ -319,6 +319,7 @@ LinearAllocator::LinearAllocator(u32 reserved) {
LinearAllocator::~LinearAllocator() {
ASSERT(m_end == 0);
os::memRelease(m_mem, m_reserved);
atomicSubtract(&g_total_commited_bytes, m_commited_bytes);
}
void LinearAllocator::reset() {
@ -339,19 +340,22 @@ void* LinearAllocator::allocate_aligned(size_t size, size_t align) {
if (compareAndExchange(&m_end, u32(start + size), end)) break;
}
if (start + size <= m_commited) return m_mem + start;
if (start + size <= m_commited_bytes) return m_mem + start;
MutexGuard guard(m_mutex);
if (start + size <= m_commited) return m_mem + start;
if (start + size <= m_commited_bytes) return m_mem + start;
const u32 commited = roundUp(start + (u32)size, 4096);
ASSERT(commited < m_reserved);
os::memCommit(m_mem + m_commited, commited - m_commited);
m_commited = commited;
os::memCommit(m_mem + m_commited_bytes, commited - m_commited_bytes);
atomicAdd(&g_total_commited_bytes, commited - m_commited_bytes);
m_commited_bytes = commited;
return m_mem + start;
}
volatile i64 LinearAllocator::g_total_commited_bytes = 0;
void LinearAllocator::deallocate_aligned(void* ptr) { /*everything should be "deallocated" with reset()*/ }
void* LinearAllocator::reallocate_aligned(void* ptr, size_t new_size, size_t old_size, size_t align) {
if (!ptr) return allocate_aligned(new_size, align);
@ -364,15 +368,15 @@ void* LinearAllocator::allocate(size_t size) {
ASSERT(size < 0xffFFffFF);
const u32 start = atomicAdd(&m_end, (u32)size);
if (start + size <= m_commited) return m_mem + start;
if (start + size <= m_commited_bytes) return m_mem + start;
MutexGuard guard(m_mutex);
if (start + size <= m_commited) return m_mem + start;
if (start + size <= m_commited_bytes) return m_mem + start;
const u32 commited = roundUp(start + (u32)size, 4096);
ASSERT(commited < m_reserved);
os::memCommit(m_mem + m_commited, commited - m_commited);
m_commited = commited;
os::memCommit(m_mem + m_commited_bytes, commited - m_commited_bytes);
m_commited_bytes = commited;
return m_mem + start;
}
@ -385,4 +389,48 @@ void* LinearAllocator::reallocate(void* ptr, size_t new_size, size_t old_size) {
return nullptr;
}
TagAllocator::TagAllocator(IAllocator& allocator, const char* tag_name)
: m_tag(tag_name)
{
m_allocator = &allocator;
while (m_allocator->getParent() && m_allocator->isTagAllocator()) {
m_allocator = m_allocator->getParent();
}
}
thread_local const char* TagAllocator::active_tag = nullptr;
void* TagAllocator::allocate(size_t size) {
active_tag = m_tag;
return m_allocator->allocate(size);
}
void TagAllocator::deallocate(void* ptr) {
m_allocator->deallocate(ptr);
}
void* TagAllocator::reallocate(void* ptr, size_t new_size, size_t old_size) {
active_tag = m_tag;
return m_allocator->reallocate(ptr, new_size, old_size);
}
void* TagAllocator::allocate_aligned(size_t size, size_t align) {
active_tag = m_tag;
return m_allocator->allocate_aligned(size, align);
}
void TagAllocator::deallocate_aligned(void* ptr) {
m_allocator->deallocate_aligned(ptr);
}
void* TagAllocator::reallocate_aligned(void* ptr, size_t new_size, size_t old_size, size_t align) {
active_tag = m_tag;
return m_allocator->reallocate_aligned(ptr, new_size, old_size, align);
}
IAllocator& getGlobalAllocator() {
static DefaultAllocator alloc;
return alloc;
}
} // namespace Lumix

View file

@ -27,6 +27,27 @@ struct LUMIX_ENGINE_API DefaultAllocator final : IAllocator {
Mutex m_mutex;
};
// set active_tag before calling its parent allocator, parent allocator can use the tag to e.g. group allocations
struct LUMIX_ENGINE_API TagAllocator final : IAllocator {
TagAllocator(IAllocator& allocator, const char* tag_name);
void* allocate(size_t size) override;
void deallocate(void* ptr) override;
void* reallocate(void* ptr, size_t new_size, size_t old_size) override;
void* allocate_aligned(size_t size, size_t align) override;
void deallocate_aligned(void* ptr) override;
void* reallocate_aligned(void* ptr, size_t new_size, size_t old_size, size_t align) override;
IAllocator* getParent() override { return m_allocator; }
bool isTagAllocator() const override { return true; }
IAllocator* m_allocator;
const char* m_tag;
static thread_local const char* active_tag;
};
// detects memory leaks, just by counting number of allocations - very fast
struct LUMIX_ENGINE_API BaseProxyAllocator final : IAllocator {
explicit BaseProxyAllocator(IAllocator& source);
@ -61,14 +82,17 @@ struct LUMIX_ENGINE_API LinearAllocator : IAllocator {
void deallocate(void* ptr) override;
void* reallocate(void* ptr, size_t new_size, size_t old_size) override;
u32 getCommited() const { return m_commited; }
u32 getCommitedBytes() const { return m_commited_bytes; }
static size_t getTotalCommitedBytes() { return g_total_commited_bytes; }
private:
u32 m_commited;
u32 m_commited_bytes;
u32 m_reserved;
volatile i32 m_end;
u8* m_mem;
Mutex m_mutex;
static volatile i64 g_total_commited_bytes;
};
// one allocation from local memory backing (m_mem), use fallback allocator otherwise
@ -128,4 +152,7 @@ private:
IAllocator& m_fallback;
};
// used for stuff that can't access engine's allocator, e.g. global objects constructed before engine such as logger
LUMIX_ENGINE_API IAllocator& getGlobalAllocator();
} // namespace Lumix

View file

@ -11,7 +11,9 @@ LUMIX_ENGINE_API i32 atomicIncrement(i32 volatile* value);
LUMIX_ENGINE_API i32 atomicDecrement(i32 volatile* value);
// returns the initial value
LUMIX_ENGINE_API i32 atomicAdd(i32 volatile* addend, i32 value);
LUMIX_ENGINE_API i64 atomicAdd(i64 volatile* addend, i64 value);
LUMIX_ENGINE_API i32 atomicSubtract(i32 volatile* addend, i32 value);
LUMIX_ENGINE_API i64 atomicSubtract(i64 volatile* addend, i64 value);
LUMIX_ENGINE_API bool compareAndExchange(i32 volatile* dest, i32 exchange, i32 comperand);
LUMIX_ENGINE_API bool compareAndExchange64(i64 volatile* dest, i64 exchange, i64 comperand);
LUMIX_ENGINE_API void memoryBarrier();

View file

@ -109,23 +109,6 @@ private:
bool m_are_guards_enabled;
};
struct LUMIX_ENGINE_API TagAllocator final : IAllocator {
TagAllocator(IAllocator& allocator, const char* tag_name);
void* allocate(size_t size) override;
void deallocate(void* ptr) override;
void* reallocate(void* ptr, size_t new_size, size_t old_size) override;
void* allocate_aligned(size_t size, size_t align) override;
void deallocate_aligned(void* ptr) override;
void* reallocate_aligned(void* ptr, size_t new_size, size_t old_size, size_t align) override;
IAllocator* getParent() override { return &m_allocator; }
IAllocator& m_allocator;
const char* m_tag;
};
} // namespace Debug

View file

@ -23,24 +23,21 @@
namespace Lumix
{
static const u32 SERIALIZED_PROJECT_MAGIC = 0x5f50524c; // == '_PRL'
static const u32 SERIALIZED_PROJECT_MAGIC = 0x5f50524c;
void registerEngineAPI(lua_State* L, Engine* engine);
struct PrefabResourceManager final : ResourceManager
{
struct PrefabResourceManager final : ResourceManager {
explicit PrefabResourceManager(IAllocator& allocator)
: m_allocator(allocator)
, ResourceManager(allocator)
{}
Resource* createResource(const Path& path) override
{
Resource* createResource(const Path& path) override {
return LUMIX_NEW(m_allocator, PrefabResource)(path, *this, m_allocator);
}
void destroyResource(Resource& resource) override
{
void destroyResource(Resource& resource) override {
return LUMIX_DELETE(m_allocator, &static_cast<PrefabResource&>(resource));
}
@ -48,9 +45,7 @@ struct PrefabResourceManager final : ResourceManager
};
struct EngineImpl final : Engine
{
public:
struct EngineImpl final : Engine {
void operator=(const EngineImpl&) = delete;
EngineImpl(const EngineImpl&) = delete;
@ -65,8 +60,8 @@ public:
, m_smooth_time_delta(1/60.f)
, m_time_multiplier(1.0f)
, m_paused(false)
, m_next_frame(false)\
//, m_lua_allocator(allocator, "lua")
, m_next_frame(false)
, m_lua_allocator(allocator, "lua")
{
for (float& f : m_last_time_deltas) f = 1/60.f;
os::init();
@ -83,7 +78,6 @@ public:
m_is_log_file_open = m_log_file.open("lumix.log");
profiler::setThreadName("Worker");
installUnhandledExceptionHandler();
logInfo("Creating engine...");
@ -94,12 +88,8 @@ public:
os::logInfo();
m_state = luaL_newstate();
#ifdef _WIN32
lua_setallocf(m_state, luaAlloc, this);
#endif
m_state = lua_newstate(luaAlloc, this);
luaL_openlibs(m_state);
registerEngineAPI(m_state, this);
if (init_data.file_system.get()) {
@ -171,9 +161,11 @@ public:
return nullptr;
}
if (!ptr) {
ASSERT(osize == 0);
return engine->m_lua_allocator.allocate(nsize);
}
ASSERT(osize > 0);
return engine->m_lua_allocator.reallocate(ptr, nsize, osize);
}
@ -456,12 +448,10 @@ public:
ResourceManagerHub& getResourceManager() override { return m_resource_manager; }
lua_State* getState() override { return m_state; }
float getLastTimeDelta() const override { return m_smooth_time_delta / m_time_multiplier; }
u64 getLuaAllocated() const override { return m_lua_allocated; }
private:
debug::TagAllocator m_allocator;
// TODO replace with tag allocator
DefaultAllocator m_lua_allocator;
TagAllocator m_allocator;
TagAllocator m_lua_allocator;
size_t m_lua_allocated = 0;
PageAllocator m_page_allocator;
UniquePtr<FileSystem> m_file_system;

View file

@ -43,7 +43,6 @@ struct LUMIX_ENGINE_API Engine {
virtual struct ResourceManagerHub& getResourceManager() = 0;
virtual struct PageAllocator& getPageAllocator() = 0;
virtual IAllocator& getAllocator() = 0;
virtual u64 getLuaAllocated() const = 0;
virtual bool instantiatePrefab(World& world,
const struct PrefabResource& prefab,
const struct DVec3& pos,

View file

@ -29,6 +29,16 @@ i32 atomicSubtract(i32 volatile* addend, i32 value)
return __sync_fetch_and_sub(addend, value);
}
i64 atomicAdd(i64 volatile* addend, i64 value)
{
return __sync_fetch_and_add(addend, value);
}
i64 atomicSubtract(i64 volatile* addend, i64 value)
{
return __sync_fetch_and_sub(addend, value);
}
bool compareAndExchange(i32 volatile* dest, i32 exchange, i32 comperand)
{
return __sync_bool_compare_and_swap(dest, comperand, exchange);

View file

@ -14,16 +14,14 @@ namespace Lumix
namespace detail {
struct Logger {
Logger() : callback(allocator) {}
Logger() : callback(getGlobalAllocator()) {}
Mutex mutex;
DefaultAllocator allocator;
LogCallback callback;
};
struct Log {
Log() : message(allocator) { message.reserve(4096); }
DefaultAllocator allocator;
Log() : message(getGlobalAllocator()) { message.reserve(4096); }
OutputMemoryStream message;
};

View file

@ -237,4 +237,4 @@ void argError(lua_State* L, int index, const char* expected_type) {
}
} // namespace Lumix::LuaWrapper
} // namespace Lumix::LuaWrapper

View file

@ -105,10 +105,10 @@ struct ThreadContext
static struct Instance
{
Instance()
: contexts(allocator)
, trace_task(allocator)
, counters(allocator)
, global_context(default_global_context_size, allocator)
: contexts(getGlobalAllocator())
, trace_task(getGlobalAllocator())
, counters(getGlobalAllocator())
, global_context(default_global_context_size, getGlobalAllocator())
{
startTrace();
}
@ -163,7 +163,7 @@ static struct Instance
ThreadContext* getThreadContext()
{
thread_local ThreadContext* ctx = [&](){
ThreadContext* new_ctx = LUMIX_NEW(allocator, ThreadContext)(default_context_size, allocator);
ThreadContext* new_ctx = LUMIX_NEW(getGlobalAllocator(), ThreadContext)(default_context_size, getGlobalAllocator());
new_ctx->thread_id = os::getCurrentThreadID();
MutexGuard lock(mutex);
contexts.push(new_ctx);
@ -173,7 +173,6 @@ static struct Instance
return ctx;
}
DefaultAllocator allocator;
Array<Counter> counters;
Array<ThreadContext*> contexts;
Mutex mutex;
@ -551,7 +550,7 @@ static void read(const ThreadContext& ctx, u32 p, T& value)
}
static void saveStrings(OutputMemoryStream& blob) {
HashMap<const char*, const char*> map(g_instance.allocator);
HashMap<const char*, const char*> map(getGlobalAllocator());
map.reserve(512);
auto gather = [&](const ThreadContext& ctx){
u32 p = ctx.begin;

View file

@ -25,13 +25,8 @@ static Context& getContext() {
return ctx;
}
static IAllocator& getAllocator() {
static DefaultAllocator alloc;
return alloc;
}
Array<FunctionBase*>& allFunctions() {
static Array<FunctionBase*> fncs(getAllocator());
static Array<FunctionBase*> fncs(getGlobalAllocator());
return fncs;
}
@ -162,7 +157,7 @@ struct NoUIAttribute : IAttribute {
};
builder build_module(const char* name) {
builder res(getAllocator());
builder res(getGlobalAllocator());
Context& ctx = getContext();
res.module->next = ctx.first_module;
ctx.first_module = res.module;

View file

@ -29,6 +29,16 @@ i32 atomicSubtract(i32 volatile* addend, i32 value)
return _InterlockedExchangeAdd((volatile long*)addend, -value);
}
i64 atomicAdd(i64 volatile* addend, i64 value)
{
return _InterlockedExchangeAdd64((volatile long long*)addend, value);
}
i64 atomicSubtract(i64 volatile* addend, i64 value)
{
return _InterlockedExchangeAdd64((volatile long long*)addend, -value);
}
bool compareAndExchange(i32 volatile* dest, i32 exchange, i32 comperand)
{
return _InterlockedCompareExchange((volatile long*)dest, exchange, comperand) == comperand;

View file

@ -21,7 +21,6 @@
static bool g_is_crash_reporting_enabled = false;
static Lumix::DefaultAllocator stack_node_allocator;
namespace Lumix
@ -66,8 +65,8 @@ struct StackNode
{
~StackNode()
{
LUMIX_DELETE(stack_node_allocator, m_next);
LUMIX_DELETE(stack_node_allocator, m_first_child);
LUMIX_DELETE(getGlobalAllocator(), m_next);
LUMIX_DELETE(getGlobalAllocator(), m_first_child);
}
void* m_instruction;
@ -90,7 +89,7 @@ StackTree::StackTree()
StackTree::~StackTree()
{
LUMIX_DELETE(stack_node_allocator, m_root);
LUMIX_DELETE(getGlobalAllocator(), m_root);
if (atomicDecrement(&s_instances) == 0)
{
HANDLE process = GetCurrentProcess();
@ -192,7 +191,7 @@ StackNode* StackTree::insertChildren(StackNode* root_node, void** instruction, v
StackNode* node = root_node;
while (instruction >= stack)
{
StackNode* new_node = LUMIX_NEW(stack_node_allocator, StackNode)();
StackNode* new_node = LUMIX_NEW(getGlobalAllocator(), StackNode)();
node->m_first_child = new_node;
new_node->m_parent = node;
new_node->m_next = nullptr;
@ -212,7 +211,7 @@ StackNode* StackTree::record()
void** ptr = stack + captured_frames_count - 1;
if (!m_root) {
m_root = LUMIX_NEW(stack_node_allocator, StackNode)();
m_root = LUMIX_NEW(getGlobalAllocator(), StackNode)();
m_root->m_instruction = *ptr;
m_root->m_first_child = nullptr;
m_root->m_next = nullptr;
@ -230,7 +229,7 @@ StackNode* StackTree::record()
}
if (node->m_instruction != *ptr)
{
node->m_next = LUMIX_NEW(stack_node_allocator, StackNode);
node->m_next = LUMIX_NEW(getGlobalAllocator(), StackNode);
node->m_next->m_parent = node->m_parent;
node->m_next->m_instruction = *ptr;
node->m_next->m_next = nullptr;
@ -428,8 +427,6 @@ void* Allocator::reallocate(void* user_ptr, size_t new_size, size_t old_size)
}
thread_local const char* active_tag = nullptr;
void* Allocator::allocate_aligned(size_t size, size_t align)
{
void* system_ptr;
@ -454,7 +451,7 @@ void* Allocator::allocate_aligned(size_t size, size_t align)
m_total_size += size;
m_mutex.exit();
info->tag = active_tag;
info->tag = TagAllocator::active_tag;
info->align = u16(align);
info->stack_leaf = m_stack_tree.record();
info->size = size;
@ -552,7 +549,7 @@ void* Allocator::allocate(size_t size)
info->stack_leaf = m_stack_tree.record();
info->size = size;
info->align = 0;
info->tag = active_tag;
info->tag = TagAllocator::active_tag;
if (m_is_fill_enabled)
{
memset(user_ptr, UNINITIALIZED_MEMORY_PATTERN, size);
@ -603,49 +600,6 @@ void Allocator::deallocate(void* user_ptr)
}
}
TagAllocator::TagAllocator(IAllocator& allocator, const char* tag_name)
: m_allocator(allocator)
, m_tag(tag_name)
{
}
void* TagAllocator::allocate(size_t size) {
if (!active_tag) active_tag = m_tag;
void* mem = m_allocator.allocate(size);
active_tag = nullptr;
return mem;
}
void TagAllocator::deallocate(void* ptr) {
m_allocator.deallocate(ptr);
}
void* TagAllocator::reallocate(void* ptr, size_t new_size, size_t old_size) {
if (!active_tag) active_tag = m_tag;
void* mem = m_allocator.reallocate(ptr, new_size, old_size);
active_tag = nullptr;
return mem;
}
void* TagAllocator::allocate_aligned(size_t size, size_t align) {
if (!active_tag) active_tag = m_tag;
void* mem = m_allocator.allocate_aligned(size, align);
active_tag = nullptr;
return mem;
}
void TagAllocator::deallocate_aligned(void* ptr) {
m_allocator.deallocate_aligned(ptr);
}
void* TagAllocator::reallocate_aligned(void* ptr, size_t new_size, size_t old_size, size_t align) {
if (!active_tag) active_tag = m_tag;
void* mem = m_allocator.reallocate_aligned(ptr, new_size, old_size, align);
active_tag = nullptr;
return mem;
}
} // namespace Debug

View file

@ -34,7 +34,7 @@ struct EventQueue {
};
void pushBack(const Event& e) {
Rec* n = LUMIX_NEW(allocator, Rec);
Rec* n = LUMIX_NEW(getGlobalAllocator(), Rec);
n->prev = back;
if (back) back->next = n;
back = n;
@ -48,7 +48,7 @@ struct EventQueue {
Rec* tmp = front;
front = tmp->next;
if (!front) back = nullptr;
LUMIX_DELETE(allocator, tmp);
LUMIX_DELETE(getGlobalAllocator(), tmp);
return e;
}
@ -58,7 +58,6 @@ struct EventQueue {
Rec* front = nullptr;
Rec* back = nullptr;
DefaultAllocator allocator;
};
static struct

View file

@ -1,8 +1,8 @@
#pragma once
#include "engine/allocators.h"
#include "engine/array.h"
#include "engine/debug.h"
#include "engine/delegate_list.h"
#include "engine/lumix.h"
#include "engine/math.h"
@ -174,7 +174,7 @@ private:
void (*destroy)(IModule*, EntityRef);
};
debug::TagAllocator m_allocator;
TagAllocator m_allocator;
Engine& m_engine;
// TODO get rid of MAX_TYPES_COUNT limit (index archetypes maybe)
ComponentTypeEntry m_component_type_map[ComponentType::MAX_TYPES_COUNT];

View file

@ -125,7 +125,7 @@ struct GUISystemImpl final : GUISystem
void serialize(OutputMemoryStream& stream) const override {}
bool deserialize(i32 version, InputMemoryStream& stream) override { return version == 0; }
debug::TagAllocator m_allocator;
TagAllocator m_allocator;
Engine& m_engine;
SpriteManager m_sprite_manager;
Interface* m_interface;

View file

@ -3,7 +3,6 @@
#include "engine/array.h"
#include "engine/associative_array.h"
#include "engine/hash.h"
#include "engine/debug.h"
#include "engine/engine.h"
#include "engine/flag_set.h"
#include "engine/allocator.h"
@ -289,7 +288,7 @@ namespace Lumix
void serialize(OutputMemoryStream& stream) const override {}
bool deserialize(i32 version, InputMemoryStream& stream) override { return version == 0; }
debug::TagAllocator m_allocator;
TagAllocator m_allocator;
Engine& m_engine;
LuaScriptManager m_script_manager;
};

View file

@ -1,6 +1,5 @@
#include "navigation_module.h"
#include "animation/animation_module.h"
#include "engine/debug.h"
#include "engine/engine.h"
#include "engine/lumix.h"
#include "engine/math.h"
@ -47,7 +46,7 @@ struct NavigationSystem final : ISystem {
static NavigationSystem* s_instance;
debug::TagAllocator m_allocator;
TagAllocator m_allocator;
Engine& m_engine;
};

View file

@ -12,7 +12,6 @@
#include <vehicle/PxVehicleSDK.h>
#include "cooking/PxCooking.h"
#include "engine/debug.h"
#include "engine/engine.h"
#include "engine/log.h"
#include "engine/lua_wrapper.h"
@ -247,7 +246,7 @@ namespace Lumix
}
debug::TagAllocator m_allocator;
TagAllocator m_allocator;
physx::PxPhysics* m_physics;
physx::PxFoundation* m_foundation;
physx::PxControllerManager* m_controller_manager;

View file

@ -42,12 +42,13 @@ enum class CompositeTexture::NodeType : u32 {
WAVE_NOISE,
CURVE,
SET_ALPHA,
CUT,
CROP,
SHARPEN,
STATIC_SWITCH,
STEP,
SPLATTER,
GRADIENT_MAP
GRADIENT_MAP,
TRANSLATE
};
enum { OUTPUT_FLAG = 1 << 31 };
@ -929,10 +930,62 @@ struct SetAlphaNode final : CompositeTexture::Node {
}
};
struct CutNode final : CompositeTexture::Node {
CutNode(IAllocator& allocator) : Node(allocator) {}
struct TranslateNode final : CompositeTexture::Node {
TranslateNode(IAllocator& allocator) : Node(allocator) {}
CompositeTexture::NodeType getType() const override { return CompositeTexture::NodeType::CUT; }
CompositeTexture::NodeType getType() const override { return CompositeTexture::NodeType::TRANSLATE; }
bool hasInputPins() const override { return true; }
bool hasOutputPins() const override { return true; }
void serialize(OutputMemoryStream& blob) const override {
blob.write(x);
blob.write(y);
}
void deserialize(InputMemoryStream& blob) override {
blob.read(x);
blob.read(y);
}
bool getPixelData(CompositeTexture::PixelData* data, u32 output_idx) override {
CompositeTexture::PixelData tmp(m_resource->m_app.getAllocator());
if (!getInputPixelData(0, &tmp)) return false;
data->w = tmp.w;
data->h = tmp.h;
data->channels = tmp.channels;
data->pixels.resize(data->w * data->h * data->channels);
for (u32 j = 0; j < data->h; ++j) {
for (u32 i = 0; i < data->w; ++i) {
memcpy(&data->pixels[(((x + i) % data->w) + ((y + j) % data->h) * data->w) * data->channels]
, &tmp.pixels[(i + j * tmp.w) * tmp.channels]
, data->channels);
}
}
return true;
}
bool gui() override {
ImGuiEx::NodeTitle("Translate");
inputSlot();
ImGui::BeginGroup();
bool res = ImGui::DragInt("X", (i32*)&x, 1, 0, 999999);
res = ImGui::DragInt("Y", (i32*)&y, 1, 0, 999999) || res;
ImGui::EndGroup();
ImGui::SameLine();
outputSlot();
return res;
}
u32 x = 0, y = 0;
};
struct CropNode final : CompositeTexture::Node {
CropNode(IAllocator& allocator) : Node(allocator) {}
CompositeTexture::NodeType getType() const override { return CompositeTexture::NodeType::CROP; }
bool hasInputPins() const override { return true; }
bool hasOutputPins() const override { return true; }
@ -971,7 +1024,7 @@ struct CutNode final : CompositeTexture::Node {
}
bool gui() override {
ImGuiEx::NodeTitle("Cut");
ImGuiEx::NodeTitle("Crop");
inputSlot();
ImGui::BeginGroup();
bool res = ImGui::DragInt("X", (i32*)&x, 1, 0, 999999);
@ -1855,7 +1908,7 @@ CompositeTexture::Node* createNode(CompositeTexture::NodeType type, CompositeTex
case CompositeTexture::NodeType::SPLIT: node = LUMIX_NEW(allocator, SplitNode)(allocator); break;
case CompositeTexture::NodeType::MERGE: node = LUMIX_NEW(allocator, MergeNode)(allocator); break;
case CompositeTexture::NodeType::GAMMA: node = LUMIX_NEW(allocator, GammaNode)(allocator); break;
case CompositeTexture::NodeType::CUT: node = LUMIX_NEW(allocator, CutNode)(allocator); break;
case CompositeTexture::NodeType::CROP: node = LUMIX_NEW(allocator, CropNode)(allocator); break;
case CompositeTexture::NodeType::CONTRAST: node = LUMIX_NEW(allocator, ContrastNode)(allocator); break;
case CompositeTexture::NodeType::BRIGHTNESS: node = LUMIX_NEW(allocator, BrightnessNode)(allocator); break;
case CompositeTexture::NodeType::RESIZE: node = LUMIX_NEW(allocator, ResizeNode)(allocator); break;
@ -1875,6 +1928,7 @@ CompositeTexture::Node* createNode(CompositeTexture::NodeType type, CompositeTex
case CompositeTexture::NodeType::SHARPEN: node = LUMIX_NEW(allocator, SharpenNode)(allocator); break;
case CompositeTexture::NodeType::GRADIENT_MAP: node = LUMIX_NEW(allocator, GradientMapNode)(allocator); break;
case CompositeTexture::NodeType::SPLATTER: node = LUMIX_NEW(allocator, SplatterNode)(allocator); break;
case CompositeTexture::NodeType::TRANSLATE: node = LUMIX_NEW(allocator, TranslateNode)(allocator); break;
case CompositeTexture::NodeType::STATIC_SWITCH: node = LUMIX_NEW(allocator, StaticSwitchNode)(allocator); break;
case CompositeTexture::NodeType::STEP: node = LUMIX_NEW(allocator, StepNode)(allocator); break;
}
@ -2141,8 +2195,8 @@ static const struct {
{ 'C', "Color", CompositeTexture::NodeType::COLOR },
{ '1', "Constant", CompositeTexture::NodeType::CONSTANT },
{ 0, "Contrast", CompositeTexture::NodeType::CONTRAST },
{ 0, "Crop", CompositeTexture::NodeType::CROP },
{ 'U', "Curve", CompositeTexture::NodeType::CURVE },
{ 0, "Cut", CompositeTexture::NodeType::CUT },
{ 'F', "Flip", CompositeTexture::NodeType::FLIP },
{ 0, "Gamma", CompositeTexture::NodeType::GAMMA },
{ 0, "Gradient", CompositeTexture::NodeType::GRADIENT },
@ -2163,6 +2217,7 @@ static const struct {
{ 'S', "Split", CompositeTexture::NodeType::SPLIT },
{ 0, "Static switch", CompositeTexture::NodeType::STATIC_SWITCH },
{ 0, "Step", CompositeTexture::NodeType::STEP },
{ 0, "Translate", CompositeTexture::NodeType::TRANSLATE },
{ 'W', "Wave noise", CompositeTexture::NodeType::WAVE_NOISE }
};
@ -2208,14 +2263,13 @@ struct CompositeTextureEditorWindow : StudioApp::GUIPlugin, NodeEditor {
void onContextMenu(ImVec2 pos) override {
CompositeTexture::Node* node = nullptr;
static char filter[64] = "";
if (ImGui::IsWindowAppearing()) ImGui::SetKeyboardFocusHere();
ImGui::SetNextItemWidth(150);
ImGui::InputTextWithHint("##filter", "Filter", filter, sizeof(filter), ImGuiInputTextFlags_AutoSelectAll);
ImGuiEx::filter("Filter", m_filter, sizeof(m_filter), 150, ImGui::IsWindowAppearing());
for (const auto& t : TYPES) {
if ((!filter[0] || stristr(t.label, filter)) && (ImGui::IsKeyPressed(ImGuiKey_Enter) || ImGui::MenuItem(t.label))) {
StaticString<64> label(t.label);
if (t.key) label.append(" (LMB + ", t.key, ")");
if ((!m_filter[0] || stristr(t.label, m_filter)) && (ImGui::IsKeyPressed(ImGuiKey_Enter) || ImGui::MenuItem(label))) {
node = m_resource.addNode(t.type);
filter[0] = '\0';
m_filter[0] = '\0';
ImGui::CloseCurrentPopup();
break;
}
@ -2406,6 +2460,7 @@ struct CompositeTextureEditorWindow : StudioApp::GUIPlugin, NodeEditor {
bool m_dirty = false;
bool m_show_confirm = false;
ImGuiID m_dock_id = 0;
char m_filter[64] = "";
};
CompositeTextureEditor::CompositeTextureEditor(StudioApp& app)

View file

@ -2264,7 +2264,7 @@ void FBXImporter::bakeVertexAO(const ImportConfig& cfg) {
void FBXImporter::writeModelHeader()
{
Model::FileHeader header;
header.magic = 0x5f4c4d4f; // == '_LMO';
header.magic = 0x5f4c4d4f;
header.version = (u32)Model::FileVersion::LATEST;
write(header);
}

View file

@ -20,6 +20,7 @@
namespace Lumix
{
static constexpr u32 FILE_MAGIC = 0x5f4c4d4f;
static LocalRigidTransform invert(const LocalRigidTransform& tr)
{

View file

@ -194,8 +194,7 @@ public:
Vec3 evalVertexPose(const Pose& pose, u32 mesh, u32 index) const;
public:
static const u32 FILE_MAGIC = 0x5f4c4d4f; // == '_LM2'
static const u32 MAX_LOD_COUNT = 4;
static constexpr u32 MAX_LOD_COUNT = 4;
private:
Model(const Model&);

View file

@ -2,7 +2,6 @@
#include "engine/crt.h"
#include "engine/atomic.h"
#include "engine/core.h"
#include "engine/debug.h"
#include "engine/job_system.h"
#include "engine/log.h"
#include "engine/math.h"

View file

@ -4,7 +4,6 @@
#include "engine/array.h"
#include "engine/atomic.h"
#include "engine/command_line_parser.h"
#include "engine/debug.h"
#include "engine/engine.h"
#include "engine/hash.h"
#include "engine/log.h"
@ -920,7 +919,7 @@ struct RendererImpl final : Renderer
u32 frame_data_mem = 0;
for (const Local<FrameData>& fd : m_frames) {
frame_data_mem += fd->linear_allocator.getCommited();
frame_data_mem += fd->linear_allocator.getCommitedBytes();
}
static u32 frame_data_counter = profiler::createCounter("Render frame data (kB)", 0);
profiler::pushCounter(frame_data_counter, float(double(frame_data_mem) / 1024.0));
@ -937,7 +936,7 @@ struct RendererImpl final : Renderer
}
Engine& m_engine;
debug::TagAllocator m_allocator;
TagAllocator m_allocator;
Array<StaticString<32>> m_shader_defines;
jobs::Mutex m_render_mutex;
jobs::Mutex m_shader_defines_mutex;