Compare commits
	
		
			1 Commits
		
	
	
		
			dev-8cf1f9
			...
			tracypatch
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| f784f91798 | 
							
								
								
									
										2
									
								
								external/CMakeLists.txt
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								external/CMakeLists.txt
									
									
									
									
										vendored
									
									
								
							@@ -1,5 +1,7 @@
 | 
			
		||||
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
 | 
			
		||||
 | 
			
		||||
add_subdirectory(./tracy)
 | 
			
		||||
 | 
			
		||||
add_subdirectory(./entt)
 | 
			
		||||
 | 
			
		||||
add_subdirectory(./solanaceae_util)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								external/solanaceae_message3
									
									
									
									
										vendored
									
									
								
							
							
								
								
								
								
								
							
						
						
									
										2
									
								
								external/solanaceae_message3
									
									
									
									
										vendored
									
									
								
							 Submodule external/solanaceae_message3 updated: e6f4f18f00...7c28b232a4
									
								
							
							
								
								
									
										5
									
								
								external/toxcore/CMakeLists.txt
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								external/toxcore/CMakeLists.txt
									
									
									
									
										vendored
									
									
								
							@@ -171,9 +171,10 @@ configure_file(
 | 
			
		||||
target_include_directories(toxcore PRIVATE "${TOX_DIR}toxcore")
 | 
			
		||||
target_include_directories(toxcore PUBLIC "${TOX_DIR}")
 | 
			
		||||
 | 
			
		||||
target_compile_definitions(toxcore PUBLIC USE_IPV6=1)
 | 
			
		||||
#target_compile_definitions(toxcore PUBLIC USE_IPV6=1)
 | 
			
		||||
#target_compile_definitions(toxcore PUBLIC MIN_LOGGER_LEVEL=LOGGER_LEVEL_DEBUG)
 | 
			
		||||
target_compile_definitions(toxcore PUBLIC MIN_LOGGER_LEVEL=LOGGER_LEVEL_INFO)
 | 
			
		||||
#target_compile_definitions(toxcore PUBLIC MIN_LOGGER_LEVEL=LOGGER_LEVEL_INFO)
 | 
			
		||||
target_compile_definitions(toxcore PUBLIC MIN_LOGGER_LEVEL=LOGGER_LEVEL_TRACE)
 | 
			
		||||
 | 
			
		||||
find_package(unofficial-sodium CONFIG QUIET)
 | 
			
		||||
find_package(sodium QUIET)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										12
									
								
								external/tracy/CMakeLists.txt
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								external/tracy/CMakeLists.txt
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,12 @@
 | 
			
		||||
cmake_minimum_required(VERSION 3.24 FATAL_ERROR)
 | 
			
		||||
 | 
			
		||||
include(FetchContent)
 | 
			
		||||
 | 
			
		||||
if (NOT TARGET TracyClient)
 | 
			
		||||
	FetchContent_Declare(tracy
 | 
			
		||||
		GIT_REPOSITORY https://github.com/wolfpld/tracy.git
 | 
			
		||||
		GIT_TAG v0.10
 | 
			
		||||
	)
 | 
			
		||||
	FetchContent_MakeAvailable(tracy)
 | 
			
		||||
endif()
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										15
									
								
								flake.nix
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								flake.nix
									
									
									
									
									
								
							@@ -12,6 +12,14 @@
 | 
			
		||||
    flake-utils.lib.eachDefaultSystem (system:
 | 
			
		||||
    let
 | 
			
		||||
      pkgs = import nixpkgs { inherit system; };
 | 
			
		||||
 | 
			
		||||
      # get deps (move to lockfile or something)
 | 
			
		||||
      # TODO: use system provided instead
 | 
			
		||||
      tracy-src = pkgs.fetchFromGitHub {
 | 
			
		||||
        owner = "wolfpld"; repo = "tracy";
 | 
			
		||||
        rev = "v0.10";
 | 
			
		||||
        hash = "sha256-DN1ExvQ5wcIUyhMAfiakFbZkDsx+5l8VMtYGvSdboPA=";
 | 
			
		||||
      };
 | 
			
		||||
    in {
 | 
			
		||||
      packages.default = pkgs.stdenv.mkDerivation {
 | 
			
		||||
        pname = "tomato";
 | 
			
		||||
@@ -56,8 +64,11 @@
 | 
			
		||||
        ] ++ self.packages.${system}.default.dlopenBuildInputs;
 | 
			
		||||
 | 
			
		||||
        cmakeFlags = [
 | 
			
		||||
          "TOMATO_ASAN=1"
 | 
			
		||||
          "CMAKE_BUILD_TYPE=RelWithDebInfo"
 | 
			
		||||
          "-DTOMATO_ASAN=OFF"
 | 
			
		||||
          "-DCMAKE_BUILD_TYPE=RelWithDebInfo"
 | 
			
		||||
 | 
			
		||||
          "-DTRACY_ENABLE=ON"
 | 
			
		||||
          "-DFETCHCONTENT_SOURCE_DIR_TRACY=${tracy-src}"
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        # TODO: replace with install command
 | 
			
		||||
 
 | 
			
		||||
@@ -82,6 +82,8 @@ target_link_libraries(tomato PUBLIC
 | 
			
		||||
	solanaceae_tox_contacts
 | 
			
		||||
	solanaceae_tox_messages
 | 
			
		||||
 | 
			
		||||
	TracyClient
 | 
			
		||||
 | 
			
		||||
	SDL3::SDL3
 | 
			
		||||
 | 
			
		||||
	imgui
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +2,8 @@
 | 
			
		||||
 | 
			
		||||
#include "./file_selector.hpp"
 | 
			
		||||
 | 
			
		||||
#include <tracy/Tracy.hpp>
 | 
			
		||||
 | 
			
		||||
#include <solanaceae/message3/components.hpp>
 | 
			
		||||
#include <solanaceae/tox_messages/components.hpp>
 | 
			
		||||
#include <solanaceae/contact/components.hpp>
 | 
			
		||||
@@ -149,6 +151,7 @@ ChatGui4::~ChatGui4(void) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
float ChatGui4::render(float time_delta) {
 | 
			
		||||
	ZoneScoped;
 | 
			
		||||
	_fss.render();
 | 
			
		||||
	_sip.render(time_delta);
 | 
			
		||||
 | 
			
		||||
@@ -338,6 +341,7 @@ float ChatGui4::render(float time_delta) {
 | 
			
		||||
						Components::ConvertedTimeCache prev_time {};
 | 
			
		||||
						auto tmp_view = msg_reg.view<Message::Components::Timestamp>();
 | 
			
		||||
						for (auto view_it = tmp_view.rbegin(), view_last = tmp_view.rend(); view_it != view_last; view_it++) {
 | 
			
		||||
							ZoneScoped;
 | 
			
		||||
							const Message3 e = *view_it;
 | 
			
		||||
 | 
			
		||||
							// manually filter ("reverse" iteration <.<)
 | 
			
		||||
@@ -677,6 +681,7 @@ void ChatGui4::sendFilePath(const char* file_path) {
 | 
			
		||||
 | 
			
		||||
// has MessageText
 | 
			
		||||
void ChatGui4::renderMessageBodyText(Message3Registry& reg, const Message3 e) {
 | 
			
		||||
	ZoneScoped;
 | 
			
		||||
	const auto& msgtext = reg.get<Message::Components::MessageText>(e).text;
 | 
			
		||||
 | 
			
		||||
	// TODO: set word wrap
 | 
			
		||||
@@ -719,6 +724,7 @@ void ChatGui4::renderMessageBodyText(Message3Registry& reg, const Message3 e) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ChatGui4::renderMessageBodyFile(Message3Registry& reg, const Message3 e) {
 | 
			
		||||
	ZoneScoped;
 | 
			
		||||
	if (
 | 
			
		||||
		!_show_chat_avatar_tf
 | 
			
		||||
		&& (
 | 
			
		||||
@@ -978,6 +984,7 @@ void ChatGui4::renderMessageExtra(Message3Registry& reg, const Message3 e) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ChatGui4::renderContactList(void) {
 | 
			
		||||
	ZoneScoped;
 | 
			
		||||
	if (ImGui::BeginChild("contacts", {TEXT_BASE_WIDTH*35, 0})) {
 | 
			
		||||
		//for (const auto& c : _cm.getBigContacts()) {
 | 
			
		||||
		for (const auto& c : _cr.view<Contact::Components::TagBig>()) {
 | 
			
		||||
@@ -1138,6 +1145,7 @@ bool ChatGui4::renderSubContactListContact(const Contact3 c, const bool selected
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ChatGui4::pasteFile(const char* mime_type) {
 | 
			
		||||
	ZoneScoped;
 | 
			
		||||
	size_t data_size = 0;
 | 
			
		||||
	void* data = SDL_GetClipboardData(mime_type, &data_size);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										10
									
								
								src/main.cpp
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								src/main.cpp
									
									
									
									
									
								
							@@ -1,6 +1,8 @@
 | 
			
		||||
#include <SDL3/SDL.h>
 | 
			
		||||
#include <SDL3/SDL_main.h>
 | 
			
		||||
 | 
			
		||||
#include <tracy/Tracy.hpp>
 | 
			
		||||
 | 
			
		||||
#include <imgui/imgui.h>
 | 
			
		||||
#include <imgui/backends/imgui_impl_sdl3.h>
 | 
			
		||||
#include <imgui/backends/imgui_impl_sdlrenderer3.h>
 | 
			
		||||
@@ -90,6 +92,7 @@ int main(int argc, char** argv) {
 | 
			
		||||
 | 
			
		||||
	bool quit = false;
 | 
			
		||||
	while (!quit) {
 | 
			
		||||
		ZoneScopedN("tomato::mainloop");
 | 
			
		||||
		auto new_time = std::chrono::steady_clock::now();
 | 
			
		||||
 | 
			
		||||
		const float time_delta_tick = std::chrono::duration<float, std::chrono::seconds::period>(new_time - last_time_tick).count();
 | 
			
		||||
@@ -99,7 +102,10 @@ int main(int argc, char** argv) {
 | 
			
		||||
		bool render = time_delta_render >= screen->nextRender();
 | 
			
		||||
 | 
			
		||||
		if (tick) {
 | 
			
		||||
			ZoneScopedN("tomato::tick");
 | 
			
		||||
			FrameMarkStart("tomato::tick");
 | 
			
		||||
			Screen* ret_screen = screen->tick(time_delta_tick, quit);
 | 
			
		||||
			FrameMarkEnd("tomato::tick");
 | 
			
		||||
			if (ret_screen != nullptr) {
 | 
			
		||||
				screen.reset(ret_screen);
 | 
			
		||||
			}
 | 
			
		||||
@@ -126,6 +132,8 @@ int main(int argc, char** argv) {
 | 
			
		||||
 | 
			
		||||
		// can do both in the same loop
 | 
			
		||||
		if (render) {
 | 
			
		||||
			ZoneScopedN("tomato::render");
 | 
			
		||||
			FrameMarkStart("tomato::render");
 | 
			
		||||
			ImGui_ImplSDLRenderer3_NewFrame();
 | 
			
		||||
			ImGui_ImplSDL3_NewFrame();
 | 
			
		||||
			ImGui::NewFrame();
 | 
			
		||||
@@ -141,9 +149,11 @@ int main(int argc, char** argv) {
 | 
			
		||||
			ImGui_ImplSDLRenderer3_RenderDrawData(ImGui::GetDrawData());
 | 
			
		||||
 | 
			
		||||
			SDL_RenderPresent(renderer.get());
 | 
			
		||||
			FrameMark;
 | 
			
		||||
			// clearing after present is (should) more performant, but first frame is a mess
 | 
			
		||||
			SDL_SetRenderDrawColor(renderer.get(), 0x10, 0x10, 0x10, SDL_ALPHA_OPAQUE);
 | 
			
		||||
			SDL_RenderClear(renderer.get());
 | 
			
		||||
			FrameMarkEnd("tomato::render");
 | 
			
		||||
 | 
			
		||||
			last_time_render = new_time;
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,7 @@
 | 
			
		||||
#include "./main_screen.hpp"
 | 
			
		||||
 | 
			
		||||
#include <tracy/Tracy.hpp>
 | 
			
		||||
 | 
			
		||||
#include <solanaceae/contact/components.hpp>
 | 
			
		||||
 | 
			
		||||
#include <imgui/imgui.h>
 | 
			
		||||
@@ -155,6 +157,7 @@ bool MainScreen::handleEvent(SDL_Event& e) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Screen* MainScreen::render(float time_delta, bool&) {
 | 
			
		||||
	ZoneScoped;
 | 
			
		||||
	// HACK: render the tomato main window first, with proper flags set.
 | 
			
		||||
	// flags need to be set the first time begin() is called.
 | 
			
		||||
	// and plugins are run before the main cg is run.
 | 
			
		||||
@@ -403,6 +406,7 @@ Screen* MainScreen::render(float time_delta, bool&) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Screen* MainScreen::tick(float time_delta, bool& quit) {
 | 
			
		||||
	ZoneScoped;
 | 
			
		||||
	quit = !tc.iterate(time_delta); // compute
 | 
			
		||||
 | 
			
		||||
	tcm.iterate(time_delta); // compute
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,12 @@
 | 
			
		||||
#include "./tox_client.hpp"
 | 
			
		||||
#include "toxcore/tox.h"
 | 
			
		||||
 | 
			
		||||
// experimental
 | 
			
		||||
#include <cstdint>
 | 
			
		||||
#include <toxcore/tox_private.h>
 | 
			
		||||
#include <toxcore/mem.h>
 | 
			
		||||
 | 
			
		||||
#include <tracy/Tracy.hpp>
 | 
			
		||||
 | 
			
		||||
// meh, change this
 | 
			
		||||
#include <exception>
 | 
			
		||||
@@ -67,6 +75,52 @@ ToxClient::ToxClient(std::string_view save_path, std::string_view save_password)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
#if 1
 | 
			
		||||
	// experimental tracy alloc tracking
 | 
			
		||||
	static Tox_System g_mysystem = tox_default_system();
 | 
			
		||||
	static const Memory* g_systemmemory = os_memory();
 | 
			
		||||
	static Memory_Funcs g_mymemoryfuncs {
 | 
			
		||||
		+[](void* obj, uint32_t size) {
 | 
			
		||||
			auto ret = g_systemmemory->funcs->malloc(g_systemmemory->obj, size);
 | 
			
		||||
			TracyAllocNS(ret, size, 32, "tox");
 | 
			
		||||
			return ret;
 | 
			
		||||
		},
 | 
			
		||||
		+[](void* obj, uint32_t nmemb, uint32_t size) {
 | 
			
		||||
			auto ret = g_systemmemory->funcs->calloc(g_systemmemory->obj, nmemb, size);
 | 
			
		||||
			TracyAllocNS(ret, nmemb*size, 32, "tox");
 | 
			
		||||
			return ret;
 | 
			
		||||
		},
 | 
			
		||||
		+[](void* obj, void* ptr, uint32_t size) {
 | 
			
		||||
			TracyFreeNS(ptr, 32, "tox");
 | 
			
		||||
			auto ret = g_systemmemory->funcs->realloc(g_systemmemory->obj, ptr, size);
 | 
			
		||||
			TracyAllocNS(ret, size, 32, "tox");
 | 
			
		||||
			return ret;
 | 
			
		||||
		},
 | 
			
		||||
		+[](void* obj, void* ptr) {
 | 
			
		||||
			TracyFreeNS(ptr, 32, "tox");
 | 
			
		||||
			g_systemmemory->funcs->free(g_systemmemory->obj, ptr);
 | 
			
		||||
		}
 | 
			
		||||
	};
 | 
			
		||||
	static Memory g_mymemory {
 | 
			
		||||
		&g_mymemoryfuncs,
 | 
			
		||||
		nullptr
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	g_mysystem.mem = &g_mymemory;
 | 
			
		||||
 | 
			
		||||
	tox_options_set_operating_system(options, &g_mysystem);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	tox_options_set_log_callback(options, +[](Tox*, Tox_Log_Level level, const char*, uint32_t, const char*, const char* message, void*) {
 | 
			
		||||
		std::string tmp_str;
 | 
			
		||||
		tmp_str += "[";
 | 
			
		||||
		tmp_str += tox_log_level_to_string(level);
 | 
			
		||||
		tmp_str += "] ";
 | 
			
		||||
		tmp_str += message;
 | 
			
		||||
		TracyMessageS(tmp_str.c_str(), tmp_str.size(), 32);
 | 
			
		||||
	});
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	tox_options_set_experimental_groups_persistence(options, true);
 | 
			
		||||
 | 
			
		||||
	TOX_ERR_NEW err_new;
 | 
			
		||||
@@ -127,6 +181,7 @@ ToxClient::~ToxClient(void) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool ToxClient::iterate(float time_delta) {
 | 
			
		||||
	ZoneScoped;
 | 
			
		||||
	Tox_Err_Events_Iterate err_e_it = TOX_ERR_EVENTS_ITERATE_OK;
 | 
			
		||||
	auto* events = tox_events_iterate(_tox, false, &err_e_it);
 | 
			
		||||
	if (err_e_it == TOX_ERR_EVENTS_ITERATE_OK && events != nullptr) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user