Minor - Optimisation stats - V11.5.0

This commit is contained in:
CatChow0 2025-06-23 22:39:58 +02:00
parent de16b97f8e
commit 688fe7ff1c
8 changed files with 124 additions and 127 deletions

View File

@ -7,13 +7,11 @@
<list default="true" id="e81d6e08-efc7-40a0-909d-ec4943d948e9" name="Changes" comment=""> <list default="true" id="e81d6e08-efc7-40a0-909d-ec4943d948e9" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/enginecustom/imgui.ini" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/imgui.ini" afterDir="false" /> <change beforePath="$PROJECT_DIR$/enginecustom/imgui.ini" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/imgui.ini" afterDir="false" />
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/Skybox.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/Skybox.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/application_class.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/application_class.h" afterDir="false" /> <change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/application_class.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/application_class.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/object.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/object.h" afterDir="false" /> <change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/imguiManager.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/imguiManager.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/stats.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/stats.h" afterDir="false" /> <change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/stats.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/stats.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/Skybox.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/Skybox.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/application_class.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/application_class.cpp" afterDir="false" /> <change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/application_class.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/application_class.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/object.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/object.cpp" afterDir="false" /> <change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/imguiManager.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/imguiManager.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/stats.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/stats.cpp" afterDir="false" /> <change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/stats.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/stats.cpp" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
@ -68,46 +66,7 @@
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" /> <setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" /> <setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" /> <setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" /> <setting file="cidr-memory-view://10" root0="FORCE_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="file://C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/um/d3d11.h" root0="SKIP_HIGHLIGHTING" /> <setting file="file://C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/um/d3d11.h" root0="SKIP_HIGHLIGHTING" />
<setting file="file://C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/um/dinput.h" root0="SKIP_HIGHLIGHTING" /> <setting file="file://C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/um/dinput.h" root0="SKIP_HIGHLIGHTING" />
<setting file="file://C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.44.35207/include/memory" root0="SKIP_HIGHLIGHTING" /> <setting file="file://C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.44.35207/include/memory" root0="SKIP_HIGHLIGHTING" />
@ -139,7 +98,7 @@
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true", "ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
"C++ Project.enginecustom.executor": "Run", "C++ Project.enginecustom.executor": "Run",
"C/C++ Project.KhaoticDemo.executor": "Run", "C/C++ Project.KhaoticDemo.executor": "Run",
"C/C++ Project.enginecustom.executor": "Debug", "C/C++ Project.enginecustom.executor": "Run",
"RunOnceActivity.ShowReadmeOnStart": "true", "RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.git.unshallow": "true", "RunOnceActivity.git.unshallow": "true",
"SHARE_PROJECT_CONFIGURATION_FILES": "true", "SHARE_PROJECT_CONFIGURATION_FILES": "true",
@ -150,7 +109,7 @@
"node.js.selected.package.eslint": "(autodetect)", "node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)", "node.js.selected.package.tslint": "(autodetect)",
"nodejs_package_manager_path": "npm", "nodejs_package_manager_path": "npm",
"settings.editor.selected.configurable": "preferences.pluginManager", "settings.editor.selected.configurable": "preferences.environmentSetup",
"vue.rearranger.settings.migration": "true" "vue.rearranger.settings.migration": "true"
} }
}]]></component> }]]></component>
@ -300,6 +259,10 @@
<workItem from="1750335650897" duration="2051000" /> <workItem from="1750335650897" duration="2051000" />
<workItem from="1750344288223" duration="1751000" /> <workItem from="1750344288223" duration="1751000" />
<workItem from="1750351735497" duration="9648000" /> <workItem from="1750351735497" duration="9648000" />
<workItem from="1750417484899" duration="2384000" />
<workItem from="1750420267631" duration="148000" />
<workItem from="1750592598277" duration="332000" />
<workItem from="1750699146323" duration="10385000" />
</task> </task>
<task id="LOCAL-00001" summary="Minor update - viewport window tweak"> <task id="LOCAL-00001" summary="Minor update - viewport window tweak">
<option name="closed" value="true" /> <option name="closed" value="true" />

View File

@ -10,9 +10,9 @@ Collapsed=0
[Window][Khaotic Engine] [Window][Khaotic Engine]
Pos=1267,19 Pos=1267,19
Size=317,609 Size=317,441
Collapsed=0 Collapsed=0
DockId=0x00000002,0 DockId=0x00000005,0
[Window][render Stats] [Window][render Stats]
Pos=0,630 Pos=0,630
@ -22,7 +22,7 @@ DockId=0x00000009,0
[Window][Objects] [Window][Objects]
Pos=0,19 Pos=0,19
Size=238,609 Size=234,842
Collapsed=0 Collapsed=0
DockId=0x0000000B,0 DockId=0x0000000B,0
@ -33,27 +33,35 @@ Collapsed=0
DockId=0x00000007,0 DockId=0x00000007,0
[Window][Log Window] [Window][Log Window]
Pos=794,630 Pos=0,630
Size=790,231 Size=1584,231
Collapsed=0 Collapsed=0
DockId=0x0000000A,0 DockId=0x0000000A,0
[Window][Light] [Window][Light]
Pos=0,19 Pos=0,19
Size=238,609 Size=234,609
Collapsed=0 Collapsed=0
DockId=0x0000000B,1 DockId=0x0000000B,0
[Window][Engine Settings]
Pos=1267,462
Size=317,166
Collapsed=0
DockId=0x00000006,0
[Docking][Data] [Docking][Data]
DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=0,19 Size=1584,842 Split=Y DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=0,19 Size=1584,842 Split=Y
DockNode ID=0x00000003 Parent=0xCCBD8CF7 SizeRef=1584,609 Split=X DockNode ID=0x00000003 Parent=0xCCBD8CF7 SizeRef=1584,609 Split=X
DockNode ID=0x0000000B Parent=0x00000003 SizeRef=238,842 Selected=0x031DC75C DockNode ID=0x0000000B Parent=0x00000003 SizeRef=234,842 Selected=0x321620B2
DockNode ID=0x0000000C Parent=0x00000003 SizeRef=1344,842 Split=X DockNode ID=0x0000000C Parent=0x00000003 SizeRef=1348,842 Split=X
DockNode ID=0x00000007 Parent=0x0000000C SizeRef=266,842 Selected=0x393905AB DockNode ID=0x00000007 Parent=0x0000000C SizeRef=266,842 Selected=0x393905AB
DockNode ID=0x00000008 Parent=0x0000000C SizeRef=1316,842 Split=X DockNode ID=0x00000008 Parent=0x0000000C SizeRef=1316,842 Split=X
DockNode ID=0x00000001 Parent=0x00000008 SizeRef=1025,842 CentralNode=1 DockNode ID=0x00000001 Parent=0x00000008 SizeRef=1265,842 CentralNode=1
DockNode ID=0x00000002 Parent=0x00000008 SizeRef=317,842 Selected=0x9F035453 DockNode ID=0x00000002 Parent=0x00000008 SizeRef=317,842 Split=Y Selected=0x9F035453
DockNode ID=0x00000004 Parent=0xCCBD8CF7 SizeRef=1584,231 Split=X Selected=0xF5D1BB37 DockNode ID=0x00000005 Parent=0x00000002 SizeRef=317,441 Selected=0x9F035453
DockNode ID=0x00000009 Parent=0x00000004 SizeRef=792,231 Selected=0xF5D1BB37 DockNode ID=0x00000006 Parent=0x00000002 SizeRef=317,166 Selected=0x0B098C4B
DockNode ID=0x0000000A Parent=0x00000004 SizeRef=790,231 Selected=0xAB74BEE9 DockNode ID=0x00000004 Parent=0xCCBD8CF7 SizeRef=1584,231 Split=X Selected=0xF5D1BB37
DockNode ID=0x00000009 Parent=0x00000004 SizeRef=792,231 Selected=0xF5D1BB37
DockNode ID=0x0000000A Parent=0x00000004 SizeRef=790,231 Selected=0xAB74BEE9

View File

@ -9,8 +9,6 @@
#include "camera_class.h" #include "camera_class.h"
#include "object.h" #include "object.h"
#include "light_class.h" #include "light_class.h"
#include <vector>
#include <filesystem>
#include "bitmap_class.h" #include "bitmap_class.h"
#include "sprite_class.h" #include "sprite_class.h"
@ -31,6 +29,8 @@
#include "physics.h" #include "physics.h"
#include "frustum.h" #include "frustum.h"
#include "skybox.h" #include "skybox.h"
#include "shadow_map.h"
#include "stats.h"
#include <fstream> #include <fstream>
@ -43,9 +43,8 @@
#include <DirectXMath.h> #include <DirectXMath.h>
#include <mutex> #include <mutex>
#include <memory> #include <memory>
#include <vector>
#include "shadow_map.h" #include <filesystem>
#include "stats.h"
///////////// /////////////
@ -128,14 +127,20 @@ public:
void set_cel_shading(const bool enable) { enable_cel_shading_ = enable; }; void set_cel_shading(const bool enable) { enable_cel_shading_ = enable; };
void set_vsync(bool vsync); void set_vsync(bool vsync) {
vsync_enabled_ = vsync;
if (direct_3d_) {
direct_3d_->set_vsync(vsync);
Logger::Get().Log("Setting Vsync to " + std::to_string(vsync), __FILE__, __LINE__);
}
};
bool get_vsync() const { return vsync_enabled_; }; bool get_vsync() const { return vsync_enabled_; };
HWND get_hwnd() const; HWND get_hwnd() const { return hwnd_; };
void set_hwnd(HWND hwnd); void set_hwnd(HWND hwnd) { hwnd_ = hwnd; };
bool is_windowed() const; bool is_windowed() const { return windowed_; };
void set_windowed(bool windowed); void set_windowed(bool windowed) { windowed_ = windowed; };
void set_window_size(const ImVec2 size) { window_size_ = size; }; void set_window_size(const ImVec2 size) { window_size_ = size; };
ImVec2 get_window_size() const { return window_size_; }; ImVec2 get_window_size() const { return window_size_; };
@ -151,6 +156,7 @@ public:
void set_frustum(const frustum& frustum) { frustum_culling_ = frustum; }; void set_frustum(const frustum& frustum) { frustum_culling_ = frustum; };
void construct_frustum(); void construct_frustum();
int get_render_count() const { return render_count_; }; int get_render_count() const { return render_count_; };
void set_render_count(const int render_count) { render_count_ = render_count; }; void set_render_count(const int render_count) { render_count_ = render_count; };
float get_frustum_tolerance() const { return frustum_culling_tolerance_; }; float get_frustum_tolerance() const { return frustum_culling_tolerance_; };
@ -176,6 +182,8 @@ private:
bool render_pass(const std::vector<std::reference_wrapper<std::vector<object*>>>& RenderQueues, XMFLOAT4* diffuse, XMFLOAT4* position, XMFLOAT4* ambient, XMMATRIX view, XMMATRIX projection); bool render_pass(const std::vector<std::reference_wrapper<std::vector<object*>>>& RenderQueues, XMFLOAT4* diffuse, XMFLOAT4* position, XMFLOAT4* ambient, XMMATRIX view, XMMATRIX projection);
void update_skybox_position(); void update_skybox_position();
void culling_thread_function();
void update_stats_after_modification();
public : public :
std::vector<ID3D11ShaderResourceView*> textures; std::vector<ID3D11ShaderResourceView*> textures;
@ -186,9 +194,7 @@ private :
std::thread culling_thread_; std::thread culling_thread_;
std::atomic<bool> culling_active_; std::atomic<bool> culling_active_;
std::mutex objects_mutex_; std::mutex objects_mutex_;
void culling_thread_function();
std::mutex terrain_mutex_; std::mutex terrain_mutex_;
std::vector<std::tuple<float, float, float, std::string, int>> terrain_generation_data_; std::vector<std::tuple<float, float, float, std::string, int>> terrain_generation_data_;
bool terrain_generation_ready_; bool terrain_generation_ready_;
@ -231,8 +237,9 @@ private :
object* selected_object_; object* selected_object_;
std::vector<object*> cubes_; std::vector<object*> cubes_;
std::vector<object*> terrain_chunk_; std::vector<object*> terrain_chunk_;
float speed_ = 0.1f; // speed for the demo spinning object
std::vector<object*> object_; std::vector<object*> object_;
float speed_ = 0.1f; // speed for the demo spinning object
std::vector<object*> imported_object_; std::vector<object*> imported_object_;
int object_id_ = 0; int object_id_ = 0;
std::vector<std::reference_wrapper<std::vector<object*>>> render_queues_; std::vector<std::reference_wrapper<std::vector<object*>>> render_queues_;

View File

@ -106,9 +106,12 @@ private:
const std::deque<Logger::LogEntry>& logBuffer = Logger::Get().GetLogBuffer(); const std::deque<Logger::LogEntry>& logBuffer = Logger::Get().GetLogBuffer();
int current_fps_, min_fps_, max_fps_, draw_calls_, total_vertex_count_, total_triangle_count_, visible_triangle_count_; int current_fps_, min_fps_, max_fps_, draw_calls_, visible_triangle_count_;
float current_frame_time_, min_frame_time_, max_frame_time_ ; float current_frame_time_, min_frame_time_, max_frame_time_ ;
std::shared_ptr<int> total_vertex_count_;
std::shared_ptr<int> total_triangle_count_;
// gpu information // gpu information
char card_name_[128]; char card_name_[128];
int video_memory_ = 0; int video_memory_ = 0;

View File

@ -18,6 +18,7 @@ public:
bool initialize(application_class* app); bool initialize(application_class* app);
void update_geometric_stats(); void update_geometric_stats();
void update_visible_count();
void update_display_stats(); void update_display_stats();
int get_total_vertex_count() const; int get_total_vertex_count() const;
@ -36,6 +37,10 @@ public:
std::string get_cpu_name(); std::string get_cpu_name();
std::string get_gpu_driver_version(ID3D11Device* device); std::string get_gpu_driver_version(ID3D11Device* device);
std::shared_ptr<int>& get_vertex_count_ptr() { return total_vertex_count_; }
std::shared_ptr<int>& get_triangle_count_ptr() { return total_triangle_count_; }
private: private:
std::thread update_display_thread_; std::thread update_display_thread_;
@ -47,8 +52,9 @@ private:
std::vector<object*> cubes_vec_; std::vector<object*> cubes_vec_;
std::vector<object*> terrain_chunk_vec_; std::vector<object*> terrain_chunk_vec_;
int total_vertex_count_; std::shared_ptr<int> total_vertex_count_;
int total_triangle_count_; std::shared_ptr<int> total_triangle_count_;
int visible_triangle_count_ = 0; int visible_triangle_count_ = 0;
int current_fps_ = 0; int current_fps_ = 0;
int min_fps_ = 0; int min_fps_ = 0;

View File

@ -1155,7 +1155,7 @@ bool application_class::render(float rotation, float x, float y, float z, float
// return false; // return false;
// } // }
stats_->update_geometric_stats(); // stats_->update_geometric_stats();
// Update the render count text. // Update the render count text.
result = update_render_count_string(get_render_count()); result = update_render_count_string(get_render_count());
@ -1353,6 +1353,8 @@ void application_class::generate_terrain()
// Ajouter à la liste des chunks de terrain // Ajouter à la liste des chunks de terrain
terrain_chunk_.push_back(terrain); terrain_chunk_.push_back(terrain);
update_stats_after_modification();
} }
} }
@ -1395,6 +1397,8 @@ void application_class::add_kobject(std::wstring& filepath)
object_.push_back(newObject); object_.push_back(newObject);
update_stats_after_modification();
// Vérifiez que l'objet a bien reçu les textures_ // Vérifiez que l'objet a bien reçu les textures_
if (newObject->get_model()->GetTexture(TextureType::Diffuse,0) == nullptr) if (newObject->get_model()->GetTexture(TextureType::Diffuse,0) == nullptr)
{ {
@ -1426,6 +1430,8 @@ void application_class::add_cube()
cubes_.push_back(newCube); cubes_.push_back(newCube);
update_stats_after_modification();
} }
void application_class::delete_kobject(int index) void application_class::delete_kobject(int index)
@ -1437,6 +1443,8 @@ void application_class::delete_kobject(int index)
{ {
object_.erase(object_.begin() + index); object_.erase(object_.begin() + index);
} }
update_stats_after_modification();
} }
void application_class::delete_terrain() void application_class::delete_terrain()
@ -1444,6 +1452,7 @@ void application_class::delete_terrain()
std::lock_guard<std::mutex> lock(objects_mutex_); std::lock_guard<std::mutex> lock(objects_mutex_);
Logger::Get().Log("Deleting terrain", __FILE__, __LINE__); Logger::Get().Log("Deleting terrain", __FILE__, __LINE__);
terrain_chunk_.clear(); terrain_chunk_.clear();
update_stats_after_modification();
} }
bool application_class::update_mouse_strings(int mouseX, int mouseY, bool mouseDown) bool application_class::update_mouse_strings(int mouseX, int mouseY, bool mouseDown)
@ -1637,39 +1646,6 @@ void application_class::set_light_position(int index, XMVECTOR position)
lights_[index]->SetPosition(lightPosition.x, lightPosition.y, lightPosition.z); lights_[index]->SetPosition(lightPosition.x, lightPosition.y, lightPosition.z);
} }
void application_class::set_vsync(bool vsync)
{
vsync_enabled_ = vsync;
if (direct_3d_)
{
Logger::Get().Log("Setting Vsync to " + std::to_string(vsync) + " with a screen width : " + std::to_string(get_screen_width()) + "and a screen height : " + std::to_string(get_screen_height()), __FILE__, __LINE__);
direct_3d_->set_vsync(vsync);
}
}
HWND application_class::get_hwnd() const
{
return hwnd_;
}
void application_class::set_hwnd(HWND hwnd)
{
hwnd_ = hwnd;
}
bool application_class::is_windowed() const
{
return windowed_;
}
void application_class::set_windowed(bool windowed)
{
// log the new windowed mode
Logger::Get().Log("Setting windowed mode to " + std::to_string(windowed), __FILE__, __LINE__);
windowed_ = windowed;
}
void application_class::set_screen_height(int height) void application_class::set_screen_height(int height)
{ {
// log the new screen height // log the new screen height
@ -1736,7 +1712,7 @@ void application_class::culling_thread_function()
} }
} }
// Pause pour éviter de surcharger le CPU // Pause pour éviter de surcharger le CPU
std::this_thread::sleep_for(std::chrono::milliseconds(16)); // ~60 Hz std::this_thread::sleep_for(std::chrono::milliseconds(16)); // ~60 Hz
} }
@ -1753,6 +1729,7 @@ bool application_class::render_pass(const std::vector<std::reference_wrapper<std
bool result; bool result;
int renderCount = 0; int renderCount = 0;
int i;
if (RenderQueues.empty()) if (RenderQueues.empty())
{ {
@ -2204,6 +2181,16 @@ bool application_class::create_big_cube(int side_count)
} }
// Transférer les cubes du vecteur temporaire au vecteur membre // Transférer les cubes du vecteur temporaire au vecteur membre
cubes_ = std::move(tempCubes); cubes_ = std::move(tempCubes);
update_stats_after_modification();
return true; return true;
} }
void application_class::update_stats_after_modification()
{
if (stats_)
{
stats_ -> update_geometric_stats();
}
}

View File

@ -17,6 +17,14 @@ imguiManager::imguiManager()
total_triangle_count_ = 0; total_triangle_count_ = 0;
visible_triangle_count_ = 0; visible_triangle_count_ = 0;
current_frame_time_ = 0; current_frame_time_ = 0;
showObjectWindow = false;
showTerrainWindow = false;
showLightWindow = false;
showOldSceneWindow = false;
showEngineSettingsWindow = false;
showLogWindow = false;
showStatsWindow = false;
// Initialiser l'historique des frametimes à zéro // Initialiser l'historique des frametimes à zéro
for (int i = 0; i < FRAME_HISTORY_COUNT; i++) for (int i = 0; i < FRAME_HISTORY_COUNT; i++)
@ -171,6 +179,9 @@ bool imguiManager::Initialize(HWND hwnd, ID3D11Device* device, ID3D11DeviceConte
} }
stats_ = app_->get_stats(); stats_ = app_->get_stats();
total_triangle_count_ = stats_->get_triangle_count_ptr();
total_vertex_count_ = stats_->get_vertex_count_ptr();
Logger::Get().Log("imgui initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize); Logger::Get().Log("imgui initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@ -989,8 +1000,11 @@ void imguiManager::WidgetRenderStats()
min_fps_ = stats_->get_min_fps(); min_fps_ = stats_->get_min_fps();
max_fps_ = stats_->get_max_fps(); max_fps_ = stats_->get_max_fps();
draw_calls_ = stats_->get_draw_calls(); draw_calls_ = stats_->get_draw_calls();
total_vertex_count_ = stats_->get_total_vertex_count();
total_triangle_count_ = stats_->get_total_triangle_count();
// total_vertex_count_ = stats_->get_total_vertex_count();
// total_triangle_count_ = stats_->get_total_triangle_count();
visible_triangle_count_ = stats_->get_visible_triangle_count(); visible_triangle_count_ = stats_->get_visible_triangle_count();
current_frame_time_ = stats_->get_frame_time(); current_frame_time_ = stats_->get_frame_time();
@ -1039,9 +1053,9 @@ void imguiManager::WidgetRenderStats()
ImGui::Separator(); ImGui::Separator();
ImGui::Text("Statistiques de rendu:"); ImGui::Text("Statistiques de rendu:");
ImGui::Text("Vertices total: %d", total_vertex_count_); ImGui::Text("Vertices total: %d", *total_vertex_count_);
ImGui::Text("Triangles total: %d", total_triangle_count_); ImGui::Text("Triangles total: %d", *total_triangle_count_);
ImGui::SameLine(); ImGui::SameLine();
ImGui::Text("Triangles visibles: %d", visible_triangle_count_); ImGui::Text("Triangles visibles: %d", visible_triangle_count_);

View File

@ -3,6 +3,8 @@
stats::stats() : fps_(nullptr), drawcalls_(0) stats::stats() : fps_(nullptr), drawcalls_(0)
{ {
total_triangle_count_ = std::make_shared<int>(0);
total_vertex_count_ = std::make_shared<int>(0);
} }
stats::~stats() stats::~stats()
@ -35,13 +37,20 @@ bool stats::initialize(application_class* app)
void stats::update_geometric_stats() void stats::update_geometric_stats()
{ {
object_vec_ = app_->get_kobjects(); object_vec_ = app_->get_kobjects();
cubes_vec_ = app_->get_cubes(); cubes_vec_ = app_->get_cubes();
terrain_chunk_vec_ = app_->get_terrain_cubes(); terrain_chunk_vec_ = app_->get_terrain_cubes();
*total_vertex_count_ = get_total_vertex_count();
*total_triangle_count_ = get_total_triangle_count();
update_visible_count();
}
total_vertex_count_ = get_total_vertex_count(); void stats::update_visible_count()
total_triangle_count_ = get_total_triangle_count(); {
visible_triangle_count_ = get_visible_triangle_count(); visible_triangle_count_ = get_visible_triangle_count();
} }
void stats::update_display_stats() void stats::update_display_stats()