Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 14 additions & 70 deletions GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 = { 0 };
static DX8FrameStatistics LastFrameStatistics = { 0 };

bool DX8Wrapper_IsWindowed = true;

// FPU_PRESERVE
Expand Down Expand Up @@ -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;
Expand All @@ -178,18 +172,7 @@ D3DADAPTER_IDENTIFIER8 DX8Wrapper::CurrentAdapterIdentifier;
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<StringClass> _RenderDeviceNameTable;
Expand Down Expand Up @@ -1649,67 +1632,28 @@ 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;
memset(&FrameStatistics, 0, sizeof(DX8FrameStatistics));
memset(&LastFrameStatistics, 0, sizeof(DX8FrameStatistics));
Comment thread
xezon marked this conversation as resolved.
Outdated
number_of_DX8_calls=0;
}

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;
memset(&FrameStatistics, 0, sizeof(DX8FrameStatistics));
number_of_DX8_calls=0;
draw_calls=0;
}

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;
LastFrameStatistics.dx8_calls = number_of_DX8_calls;
}

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()
Expand Down
54 changes: 25 additions & 29 deletions GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,29 @@ 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++
struct DX8FrameStatistics
{
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_DRAW_CALLS() FrameStatistics.draw_calls++

extern unsigned number_of_DX8_calls;
extern bool _DX8SingleThreaded;
Expand Down Expand Up @@ -413,17 +427,7 @@ 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();

// Needed by shader class
Expand Down Expand Up @@ -657,15 +661,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;
Expand Down
Loading