diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp index 52b44c3061..4dc573beee 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp +++ b/Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp @@ -89,6 +89,9 @@ const int DEFAULT_BIT_DEPTH = 32; const int DEFAULT_TEXTURE_BIT_DEPTH = 16; const D3DMULTISAMPLE_TYPE DEFAULT_MSAA = D3DMULTISAMPLE_NONE; +DX8FrameStatistics DX8Wrapper::FrameStatistics; +static DX8FrameStatistics LastFrameStatistics; + bool DX8Wrapper_IsWindowed = true; // FPU_PRESERVE @@ -146,15 +149,6 @@ IDirect3DSurface8 * DX8Wrapper::DefaultRenderTarget = nullptr; IDirect3DSurface8 * DX8Wrapper::DefaultDepthBuffer = nullptr; bool DX8Wrapper::IsRenderToTexture = false; -unsigned DX8Wrapper::matrix_changes = 0; -unsigned DX8Wrapper::material_changes = 0; -unsigned DX8Wrapper::vertex_buffer_changes = 0; -unsigned DX8Wrapper::index_buffer_changes = 0; -unsigned DX8Wrapper::light_changes = 0; -unsigned DX8Wrapper::texture_changes = 0; -unsigned DX8Wrapper::render_state_changes = 0; -unsigned DX8Wrapper::texture_stage_state_changes = 0; -unsigned DX8Wrapper::draw_calls = 0; unsigned DX8Wrapper::_MainThreadID = 0; bool DX8Wrapper::CurrentDX8LightEnables[4]; bool DX8Wrapper::IsDeviceLost; @@ -175,18 +169,6 @@ unsigned long DX8Wrapper::FrameCount = 0; bool _DX8SingleThreaded = false; -unsigned number_of_DX8_calls = 0; -static unsigned last_frame_matrix_changes = 0; -static unsigned last_frame_material_changes = 0; -static unsigned last_frame_vertex_buffer_changes = 0; -static unsigned last_frame_index_buffer_changes = 0; -static unsigned last_frame_light_changes = 0; -static unsigned last_frame_texture_changes = 0; -static unsigned last_frame_render_state_changes = 0; -static unsigned last_frame_texture_stage_state_changes = 0; -static unsigned last_frame_number_of_DX8_calls = 0; -static unsigned last_frame_draw_calls = 0; - static D3DPRESENT_PARAMETERS _PresentParameters; static DynamicVectorClass _RenderDeviceNameTable; static DynamicVectorClass _RenderDeviceShortNameTable; @@ -1527,67 +1509,25 @@ bool DX8Wrapper::Test_Z_Mode(D3DFORMAT colorbuffer,D3DFORMAT backbuffer, D3DFORM void DX8Wrapper::Reset_Statistics() { - matrix_changes = 0; - material_changes = 0; - vertex_buffer_changes = 0; - index_buffer_changes = 0; - light_changes = 0; - texture_changes = 0; - render_state_changes =0; - texture_stage_state_changes =0; - draw_calls =0; - - number_of_DX8_calls = 0; - last_frame_matrix_changes = 0; - last_frame_material_changes = 0; - last_frame_vertex_buffer_changes = 0; - last_frame_index_buffer_changes = 0; - last_frame_light_changes = 0; - last_frame_texture_changes = 0; - last_frame_render_state_changes = 0; - last_frame_texture_stage_state_changes = 0; - last_frame_number_of_DX8_calls = 0; - last_frame_draw_calls =0; + FrameStatistics = DX8FrameStatistics(); + LastFrameStatistics = DX8FrameStatistics(); } void DX8Wrapper::Begin_Statistics() { - matrix_changes=0; - material_changes=0; - vertex_buffer_changes=0; - index_buffer_changes=0; - light_changes=0; - texture_changes = 0; - render_state_changes =0; - texture_stage_state_changes =0; - number_of_DX8_calls=0; - draw_calls=0; + FrameStatistics = DX8FrameStatistics(); } void DX8Wrapper::End_Statistics() { - last_frame_matrix_changes=matrix_changes; - last_frame_material_changes=material_changes; - last_frame_vertex_buffer_changes=vertex_buffer_changes; - last_frame_index_buffer_changes=index_buffer_changes; - last_frame_light_changes=light_changes; - last_frame_texture_changes = texture_changes; - last_frame_render_state_changes = render_state_changes; - last_frame_texture_stage_state_changes = texture_stage_state_changes; - last_frame_number_of_DX8_calls=number_of_DX8_calls; - last_frame_draw_calls=draw_calls; + LastFrameStatistics = FrameStatistics; +} + +const DX8FrameStatistics& DX8Wrapper::Get_Last_Frame_Statistics() +{ + return LastFrameStatistics; } -unsigned DX8Wrapper::Get_Last_Frame_Matrix_Changes() { return last_frame_matrix_changes; } -unsigned DX8Wrapper::Get_Last_Frame_Material_Changes() { return last_frame_material_changes; } -unsigned DX8Wrapper::Get_Last_Frame_Vertex_Buffer_Changes() { return last_frame_vertex_buffer_changes; } -unsigned DX8Wrapper::Get_Last_Frame_Index_Buffer_Changes() { return last_frame_index_buffer_changes; } -unsigned DX8Wrapper::Get_Last_Frame_Light_Changes() { return last_frame_light_changes; } -unsigned DX8Wrapper::Get_Last_Frame_Texture_Changes() { return last_frame_texture_changes; } -unsigned DX8Wrapper::Get_Last_Frame_Render_State_Changes() { return last_frame_render_state_changes; } -unsigned DX8Wrapper::Get_Last_Frame_Texture_Stage_State_Changes() { return last_frame_texture_stage_state_changes; } -unsigned DX8Wrapper::Get_Last_Frame_DX8_Calls() { return last_frame_number_of_DX8_calls; } -unsigned DX8Wrapper::Get_Last_Frame_Draw_Calls() { return last_frame_draw_calls; } unsigned long DX8Wrapper::Get_FrameCount() {return FrameCount;} void DX8_Assert() @@ -1624,7 +1564,7 @@ void DX8Wrapper::End_Scene(bool flip_frames) hr=_Get_D3D_Device8()->Present(nullptr, nullptr, nullptr, nullptr); } - number_of_DX8_calls++; + DX8_RECORD_DX8_CALLS(); if (SUCCEEDED(hr)) { #ifdef EXTENDED_STATS @@ -2982,7 +2922,7 @@ DX8Wrapper::Create_Render_Target (int width, int height, WW3DFormat format) { DX8_THREAD_ASSERT(); DX8_Assert(); - number_of_DX8_calls++; + DX8_RECORD_DX8_CALLS(); // Use the current display format if format isn't specified if (format==WW3D_FORMAT_UNKNOWN) { @@ -3048,7 +2988,7 @@ void DX8Wrapper::Create_Render_Target { DX8_THREAD_ASSERT(); DX8_Assert(); - number_of_DX8_calls++; + DX8_RECORD_DX8_CALLS(); // Use the current display format if format isn't specified if (format==WW3D_FORMAT_UNKNOWN) @@ -3449,7 +3389,7 @@ void DX8Wrapper::Flush_DX8_Resource_Manager(unsigned int bytes) unsigned int DX8Wrapper::Get_Free_Texture_RAM() { DX8_Assert(); - number_of_DX8_calls++; + DX8_RECORD_DX8_CALLS(); return DX8Wrapper::_Get_D3D_Device8()->GetAvailableTextureMem(); } @@ -3465,7 +3405,7 @@ void DX8Wrapper::Set_Gamma(float gamma,float bright,float contrast,bool calibrat float oo_gamma=1.0f/gamma; DX8_Assert(); - number_of_DX8_calls++; + DX8_RECORD_DX8_CALLS(); DWORD flag=(calibrate?D3DSGR_CALIBRATE:D3DSGR_NO_CALIBRATION); diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h b/Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h index 32a86393c8..dbdbd5b9c8 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h +++ b/Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h @@ -91,17 +91,45 @@ class TextureClass; class LightClass; class SurfaceClass; -#define DX8_RECORD_MATRIX_CHANGE() matrix_changes++ -#define DX8_RECORD_MATERIAL_CHANGE() material_changes++ -#define DX8_RECORD_VERTEX_BUFFER_CHANGE() vertex_buffer_changes++ -#define DX8_RECORD_INDEX_BUFFER_CHANGE() index_buffer_changes++ -#define DX8_RECORD_LIGHT_CHANGE() light_changes++ -#define DX8_RECORD_TEXTURE_CHANGE() texture_changes++ -#define DX8_RECORD_RENDER_STATE_CHANGE() render_state_changes++ -#define DX8_RECORD_TEXTURE_STAGE_STATE_CHANGE() texture_stage_state_changes++ -#define DX8_RECORD_DRAW_CALLS() draw_calls++ - -extern unsigned number_of_DX8_calls; +struct DX8FrameStatistics +{ + DX8FrameStatistics() : + matrix_changes(0), + material_changes(0), + vertex_buffer_changes(0), + index_buffer_changes(0), + light_changes(0), + texture_changes(0), + render_state_changes(0), + texture_stage_state_changes(0), + dx8_calls(0), + draw_calls(0) + { + } + + unsigned matrix_changes; + unsigned material_changes; + unsigned vertex_buffer_changes; + unsigned index_buffer_changes; + unsigned light_changes; + unsigned texture_changes; + unsigned render_state_changes; + unsigned texture_stage_state_changes; + unsigned dx8_calls; + unsigned draw_calls; +}; + +#define DX8_RECORD_MATRIX_CHANGE() FrameStatistics.matrix_changes++ +#define DX8_RECORD_MATERIAL_CHANGE() FrameStatistics.material_changes++ +#define DX8_RECORD_VERTEX_BUFFER_CHANGE() FrameStatistics.vertex_buffer_changes++ +#define DX8_RECORD_INDEX_BUFFER_CHANGE() FrameStatistics.index_buffer_changes++ +#define DX8_RECORD_LIGHT_CHANGE() FrameStatistics.light_changes++ +#define DX8_RECORD_TEXTURE_CHANGE() FrameStatistics.texture_changes++ +#define DX8_RECORD_RENDER_STATE_CHANGE() FrameStatistics.render_state_changes++ +#define DX8_RECORD_TEXTURE_STAGE_STATE_CHANGE() FrameStatistics.texture_stage_state_changes++ +#define DX8_RECORD_DX8_CALLS() FrameStatistics.dx8_calls++ +#define DX8_RECORD_DRAW_CALLS() FrameStatistics.draw_calls++ + extern bool _DX8SingleThreaded; void DX8_Assert(); @@ -114,14 +142,14 @@ WWINLINE void DX8_ErrorCode(unsigned res) } #ifdef WWDEBUG -#define DX8CALL_HRES(x,res) DX8_Assert(); res = DX8Wrapper::_Get_D3D_Device8()->x; DX8_ErrorCode(res); number_of_DX8_calls++; -#define DX8CALL(x) DX8_Assert(); DX8_ErrorCode(DX8Wrapper::_Get_D3D_Device8()->x); number_of_DX8_calls++; -#define DX8CALL_D3D(x) DX8_Assert(); DX8_ErrorCode(DX8Wrapper::_Get_D3D8()->x); number_of_DX8_calls++; +#define DX8CALL_HRES(x,res) DX8_Assert(); res = DX8Wrapper::_Get_D3D_Device8()->x; DX8_ErrorCode(res); DX8Wrapper::Increment_DX8_CallCount(); +#define DX8CALL(x) DX8_Assert(); DX8_ErrorCode(DX8Wrapper::_Get_D3D_Device8()->x); DX8Wrapper::Increment_DX8_CallCount(); +#define DX8CALL_D3D(x) DX8_Assert(); DX8_ErrorCode(DX8Wrapper::_Get_D3D8()->x); DX8Wrapper::Increment_DX8_CallCount(); #define DX8_THREAD_ASSERT() if (_DX8SingleThreaded) { WWASSERT_PRINT(DX8Wrapper::_Get_Main_Thread_ID()==ThreadClass::_Get_Current_Thread_ID(),"DX8Wrapper::DX8 calls must be called from the main thread!"); } #else -#define DX8CALL_HRES(x,res) res = DX8Wrapper::_Get_D3D_Device8()->x; number_of_DX8_calls++; -#define DX8CALL(x) DX8Wrapper::_Get_D3D_Device8()->x; number_of_DX8_calls++; -#define DX8CALL_D3D(x) DX8Wrapper::_Get_D3D8()->x; number_of_DX8_calls++; +#define DX8CALL_HRES(x,res) res = DX8Wrapper::_Get_D3D_Device8()->x; DX8Wrapper::Increment_DX8_CallCount(); +#define DX8CALL(x) DX8Wrapper::_Get_D3D_Device8()->x; DX8Wrapper::Increment_DX8_CallCount(); +#define DX8CALL_D3D(x) DX8Wrapper::_Get_D3D8()->x; DX8Wrapper::Increment_DX8_CallCount(); #define DX8_THREAD_ASSERT() ; #endif @@ -407,18 +435,9 @@ class DX8Wrapper */ static void Begin_Statistics(); static void End_Statistics(); - static unsigned Get_Last_Frame_Matrix_Changes(); - static unsigned Get_Last_Frame_Material_Changes(); - static unsigned Get_Last_Frame_Vertex_Buffer_Changes(); - static unsigned Get_Last_Frame_Index_Buffer_Changes(); - static unsigned Get_Last_Frame_Light_Changes(); - static unsigned Get_Last_Frame_Texture_Changes(); - static unsigned Get_Last_Frame_Render_State_Changes(); - static unsigned Get_Last_Frame_Texture_Stage_State_Changes(); - static unsigned Get_Last_Frame_DX8_Calls(); - static unsigned Get_Last_Frame_Draw_Calls(); - + static const DX8FrameStatistics& Get_Last_Frame_Statistics(); static unsigned long Get_FrameCount(); + static void Increment_DX8_CallCount() { DX8_RECORD_DX8_CALLS(); } // Needed by shader class static bool Get_Fog_Enable() { return FogEnable; } @@ -651,15 +670,7 @@ class DX8Wrapper static bool FogEnable; static D3DCOLOR FogColor; - static unsigned matrix_changes; - static unsigned material_changes; - static unsigned vertex_buffer_changes; - static unsigned index_buffer_changes; - static unsigned light_changes; - static unsigned texture_changes; - static unsigned render_state_changes; - static unsigned texture_stage_state_changes; - static unsigned draw_calls; + static DX8FrameStatistics FrameStatistics; static bool CurrentDX8LightEnables[4]; static unsigned long FrameCount; diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp index f7c0982646..956540ddae 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp @@ -93,6 +93,9 @@ const int DEFAULT_BIT_DEPTH = 32; const int DEFAULT_TEXTURE_BIT_DEPTH = 16; const D3DMULTISAMPLE_TYPE DEFAULT_MSAA = D3DMULTISAMPLE_NONE; +DX8FrameStatistics DX8Wrapper::FrameStatistics; +static DX8FrameStatistics LastFrameStatistics; + bool DX8Wrapper_IsWindowed = true; // FPU_PRESERVE @@ -150,15 +153,6 @@ IDirect3DSurface8 * DX8Wrapper::DefaultRenderTarget = nullptr; IDirect3DSurface8 * DX8Wrapper::DefaultDepthBuffer = nullptr; bool DX8Wrapper::IsRenderToTexture = false; -unsigned DX8Wrapper::matrix_changes = 0; -unsigned DX8Wrapper::material_changes = 0; -unsigned DX8Wrapper::vertex_buffer_changes = 0; -unsigned DX8Wrapper::index_buffer_changes = 0; -unsigned DX8Wrapper::light_changes = 0; -unsigned DX8Wrapper::texture_changes = 0; -unsigned DX8Wrapper::render_state_changes = 0; -unsigned DX8Wrapper::texture_stage_state_changes = 0; -unsigned DX8Wrapper::draw_calls = 0; unsigned DX8Wrapper::_MainThreadID = 0; bool DX8Wrapper::CurrentDX8LightEnables[4]; bool DX8Wrapper::IsDeviceLost; @@ -179,18 +173,6 @@ unsigned long DX8Wrapper::FrameCount = 0; bool _DX8SingleThreaded = false; -unsigned number_of_DX8_calls = 0; -static unsigned last_frame_matrix_changes = 0; -static unsigned last_frame_material_changes = 0; -static unsigned last_frame_vertex_buffer_changes = 0; -static unsigned last_frame_index_buffer_changes = 0; -static unsigned last_frame_light_changes = 0; -static unsigned last_frame_texture_changes = 0; -static unsigned last_frame_render_state_changes = 0; -static unsigned last_frame_texture_stage_state_changes = 0; -static unsigned last_frame_number_of_DX8_calls = 0; -static unsigned last_frame_draw_calls = 0; - static D3DPRESENT_PARAMETERS _PresentParameters; static DynamicVectorClass _RenderDeviceNameTable; static DynamicVectorClass _RenderDeviceShortNameTable; @@ -1649,67 +1631,25 @@ bool DX8Wrapper::Test_Z_Mode(D3DFORMAT colorbuffer,D3DFORMAT backbuffer, D3DFORM void DX8Wrapper::Reset_Statistics() { - matrix_changes = 0; - material_changes = 0; - vertex_buffer_changes = 0; - index_buffer_changes = 0; - light_changes = 0; - texture_changes = 0; - render_state_changes =0; - texture_stage_state_changes =0; - draw_calls =0; - - number_of_DX8_calls = 0; - last_frame_matrix_changes = 0; - last_frame_material_changes = 0; - last_frame_vertex_buffer_changes = 0; - last_frame_index_buffer_changes = 0; - last_frame_light_changes = 0; - last_frame_texture_changes = 0; - last_frame_render_state_changes = 0; - last_frame_texture_stage_state_changes = 0; - last_frame_number_of_DX8_calls = 0; - last_frame_draw_calls =0; + FrameStatistics = DX8FrameStatistics(); + LastFrameStatistics = DX8FrameStatistics(); } void DX8Wrapper::Begin_Statistics() { - matrix_changes=0; - material_changes=0; - vertex_buffer_changes=0; - index_buffer_changes=0; - light_changes=0; - texture_changes = 0; - render_state_changes =0; - texture_stage_state_changes =0; - number_of_DX8_calls=0; - draw_calls=0; + FrameStatistics = DX8FrameStatistics(); } void DX8Wrapper::End_Statistics() { - last_frame_matrix_changes=matrix_changes; - last_frame_material_changes=material_changes; - last_frame_vertex_buffer_changes=vertex_buffer_changes; - last_frame_index_buffer_changes=index_buffer_changes; - last_frame_light_changes=light_changes; - last_frame_texture_changes = texture_changes; - last_frame_render_state_changes = render_state_changes; - last_frame_texture_stage_state_changes = texture_stage_state_changes; - last_frame_number_of_DX8_calls=number_of_DX8_calls; - last_frame_draw_calls=draw_calls; + LastFrameStatistics = FrameStatistics; +} + +const DX8FrameStatistics& DX8Wrapper::Get_Last_Frame_Statistics() +{ + return LastFrameStatistics; } -unsigned DX8Wrapper::Get_Last_Frame_Matrix_Changes() { return last_frame_matrix_changes; } -unsigned DX8Wrapper::Get_Last_Frame_Material_Changes() { return last_frame_material_changes; } -unsigned DX8Wrapper::Get_Last_Frame_Vertex_Buffer_Changes() { return last_frame_vertex_buffer_changes; } -unsigned DX8Wrapper::Get_Last_Frame_Index_Buffer_Changes() { return last_frame_index_buffer_changes; } -unsigned DX8Wrapper::Get_Last_Frame_Light_Changes() { return last_frame_light_changes; } -unsigned DX8Wrapper::Get_Last_Frame_Texture_Changes() { return last_frame_texture_changes; } -unsigned DX8Wrapper::Get_Last_Frame_Render_State_Changes() { return last_frame_render_state_changes; } -unsigned DX8Wrapper::Get_Last_Frame_Texture_Stage_State_Changes() { return last_frame_texture_stage_state_changes; } -unsigned DX8Wrapper::Get_Last_Frame_DX8_Calls() { return last_frame_number_of_DX8_calls; } -unsigned DX8Wrapper::Get_Last_Frame_Draw_Calls() { return last_frame_draw_calls; } unsigned long DX8Wrapper::Get_FrameCount() {return FrameCount;} void DX8_Assert() @@ -1746,7 +1686,7 @@ void DX8Wrapper::End_Scene(bool flip_frames) hr=_Get_D3D_Device8()->Present(nullptr, nullptr, nullptr, nullptr); } - number_of_DX8_calls++; + DX8_RECORD_DX8_CALLS(); if (SUCCEEDED(hr)) { #ifdef EXTENDED_STATS @@ -1855,7 +1795,7 @@ void DX8Wrapper::Clear(bool clear_color, bool clear_z_stencil, const Vector3 &co IDirect3DSurface8* depthbuffer; _Get_D3D_Device8()->GetDepthStencilSurface(&depthbuffer); - number_of_DX8_calls++; + DX8_RECORD_DX8_CALLS(); if (depthbuffer) { @@ -3217,7 +3157,7 @@ DX8Wrapper::Create_Render_Target (int width, int height, WW3DFormat format) { DX8_THREAD_ASSERT(); DX8_Assert(); - number_of_DX8_calls++; + DX8_RECORD_DX8_CALLS(); // Use the current display format if format isn't specified if (format==WW3D_FORMAT_UNKNOWN) { @@ -3283,7 +3223,7 @@ void DX8Wrapper::Create_Render_Target { DX8_THREAD_ASSERT(); DX8_Assert(); - number_of_DX8_calls++; + DX8_RECORD_DX8_CALLS(); // Use the current display format if format isn't specified if (format==WW3D_FORMAT_UNKNOWN) @@ -3684,7 +3624,7 @@ void DX8Wrapper::Flush_DX8_Resource_Manager(unsigned int bytes) unsigned int DX8Wrapper::Get_Free_Texture_RAM() { DX8_Assert(); - number_of_DX8_calls++; + DX8_RECORD_DX8_CALLS(); return DX8Wrapper::_Get_D3D_Device8()->GetAvailableTextureMem(); } @@ -3700,7 +3640,7 @@ void DX8Wrapper::Set_Gamma(float gamma,float bright,float contrast,bool calibrat float oo_gamma=1.0f/gamma; DX8_Assert(); - number_of_DX8_calls++; + DX8_RECORD_DX8_CALLS(); DWORD flag=(calibrate?D3DSGR_CALIBRATE:D3DSGR_NO_CALIBRATION); diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h index adcbe2cd8e..937aa6ea6a 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h @@ -94,17 +94,45 @@ class TextureClass; class LightClass; class SurfaceClass; -#define DX8_RECORD_MATRIX_CHANGE() matrix_changes++ -#define DX8_RECORD_MATERIAL_CHANGE() material_changes++ -#define DX8_RECORD_VERTEX_BUFFER_CHANGE() vertex_buffer_changes++ -#define DX8_RECORD_INDEX_BUFFER_CHANGE() index_buffer_changes++ -#define DX8_RECORD_LIGHT_CHANGE() light_changes++ -#define DX8_RECORD_TEXTURE_CHANGE() texture_changes++ -#define DX8_RECORD_RENDER_STATE_CHANGE() render_state_changes++ -#define DX8_RECORD_TEXTURE_STAGE_STATE_CHANGE() texture_stage_state_changes++ -#define DX8_RECORD_DRAW_CALLS() draw_calls++ - -extern unsigned number_of_DX8_calls; +struct DX8FrameStatistics +{ + DX8FrameStatistics() : + matrix_changes(0), + material_changes(0), + vertex_buffer_changes(0), + index_buffer_changes(0), + light_changes(0), + texture_changes(0), + render_state_changes(0), + texture_stage_state_changes(0), + dx8_calls(0), + draw_calls(0) + { + } + + unsigned matrix_changes; + unsigned material_changes; + unsigned vertex_buffer_changes; + unsigned index_buffer_changes; + unsigned light_changes; + unsigned texture_changes; + unsigned render_state_changes; + unsigned texture_stage_state_changes; + unsigned dx8_calls; + unsigned draw_calls; +}; + +#define DX8_RECORD_MATRIX_CHANGE() FrameStatistics.matrix_changes++ +#define DX8_RECORD_MATERIAL_CHANGE() FrameStatistics.material_changes++ +#define DX8_RECORD_VERTEX_BUFFER_CHANGE() FrameStatistics.vertex_buffer_changes++ +#define DX8_RECORD_INDEX_BUFFER_CHANGE() FrameStatistics.index_buffer_changes++ +#define DX8_RECORD_LIGHT_CHANGE() FrameStatistics.light_changes++ +#define DX8_RECORD_TEXTURE_CHANGE() FrameStatistics.texture_changes++ +#define DX8_RECORD_RENDER_STATE_CHANGE() FrameStatistics.render_state_changes++ +#define DX8_RECORD_TEXTURE_STAGE_STATE_CHANGE() FrameStatistics.texture_stage_state_changes++ +#define DX8_RECORD_DX8_CALLS() FrameStatistics.dx8_calls++ +#define DX8_RECORD_DRAW_CALLS() FrameStatistics.draw_calls++ + extern bool _DX8SingleThreaded; void DX8_Assert(); @@ -117,14 +145,14 @@ WWINLINE void DX8_ErrorCode(unsigned res) } #ifdef WWDEBUG -#define DX8CALL_HRES(x,res) DX8_Assert(); res = DX8Wrapper::_Get_D3D_Device8()->x; DX8_ErrorCode(res); number_of_DX8_calls++; -#define DX8CALL(x) DX8_Assert(); DX8_ErrorCode(DX8Wrapper::_Get_D3D_Device8()->x); number_of_DX8_calls++; -#define DX8CALL_D3D(x) DX8_Assert(); DX8_ErrorCode(DX8Wrapper::_Get_D3D8()->x); number_of_DX8_calls++; +#define DX8CALL_HRES(x,res) DX8_Assert(); res = DX8Wrapper::_Get_D3D_Device8()->x; DX8_ErrorCode(res); DX8Wrapper::Increment_DX8_CallCount(); +#define DX8CALL(x) DX8_Assert(); DX8_ErrorCode(DX8Wrapper::_Get_D3D_Device8()->x); DX8Wrapper::Increment_DX8_CallCount(); +#define DX8CALL_D3D(x) DX8_Assert(); DX8_ErrorCode(DX8Wrapper::_Get_D3D8()->x); DX8Wrapper::Increment_DX8_CallCount(); #define DX8_THREAD_ASSERT() if (_DX8SingleThreaded) { WWASSERT_PRINT(DX8Wrapper::_Get_Main_Thread_ID()==ThreadClass::_Get_Current_Thread_ID(),"DX8Wrapper::DX8 calls must be called from the main thread!"); } #else -#define DX8CALL_HRES(x,res) res = DX8Wrapper::_Get_D3D_Device8()->x; number_of_DX8_calls++; -#define DX8CALL(x) DX8Wrapper::_Get_D3D_Device8()->x; number_of_DX8_calls++; -#define DX8CALL_D3D(x) DX8Wrapper::_Get_D3D8()->x; number_of_DX8_calls++; +#define DX8CALL_HRES(x,res) res = DX8Wrapper::_Get_D3D_Device8()->x; DX8Wrapper::Increment_DX8_CallCount(); +#define DX8CALL(x) DX8Wrapper::_Get_D3D_Device8()->x; DX8Wrapper::Increment_DX8_CallCount(); +#define DX8CALL_D3D(x) DX8Wrapper::_Get_D3D8()->x; DX8Wrapper::Increment_DX8_CallCount(); #define DX8_THREAD_ASSERT() ; #endif @@ -413,18 +441,9 @@ class DX8Wrapper */ static void Begin_Statistics(); static void End_Statistics(); - static unsigned Get_Last_Frame_Matrix_Changes(); - static unsigned Get_Last_Frame_Material_Changes(); - static unsigned Get_Last_Frame_Vertex_Buffer_Changes(); - static unsigned Get_Last_Frame_Index_Buffer_Changes(); - static unsigned Get_Last_Frame_Light_Changes(); - static unsigned Get_Last_Frame_Texture_Changes(); - static unsigned Get_Last_Frame_Render_State_Changes(); - static unsigned Get_Last_Frame_Texture_Stage_State_Changes(); - static unsigned Get_Last_Frame_DX8_Calls(); - static unsigned Get_Last_Frame_Draw_Calls(); - + static const DX8FrameStatistics& Get_Last_Frame_Statistics(); static unsigned long Get_FrameCount(); + static void Increment_DX8_CallCount() { DX8_RECORD_DX8_CALLS(); } // Needed by shader class static bool Get_Fog_Enable() { return FogEnable; } @@ -657,15 +676,7 @@ class DX8Wrapper static bool FogEnable; static D3DCOLOR FogColor; - static unsigned matrix_changes; - static unsigned material_changes; - static unsigned vertex_buffer_changes; - static unsigned index_buffer_changes; - static unsigned light_changes; - static unsigned texture_changes; - static unsigned render_state_changes; - static unsigned texture_stage_state_changes; - static unsigned draw_calls; + static DX8FrameStatistics FrameStatistics; static bool CurrentDX8LightEnables[4]; static unsigned long FrameCount;