pstats pixel count for tinydisplay

This commit is contained in:
David Rose 2008-08-05 00:57:35 +00:00
parent 34538489ba
commit 85d94ff0c5
7 changed files with 123 additions and 5 deletions

View File

@ -185,6 +185,7 @@ static LevelCollectorProperties level_properties[] = {
{ 1, "Vertices:Indexed triangle strips", { 0.5, 0.2, 0.8 } },
{ 1, "Vertices:Display lists", { 0.8, 0.5, 1.0 } },
{ 1, "Vertices:Immediate mode", { 1.0, 0.5, 0.0 } },
{ 1, "Pixels", { 0.8, 0.3, 0.7 }, "M", 5, 1000000 },
{ 1, "Nodes", { 0.4, 0.2, 0.8 }, "", 500.0 },
{ 1, "Nodes:GeomNodes", { 0.8, 0.2, 0.0 } },
{ 1, "Geoms", { 0.4, 0.8, 0.3 }, "", 500.0 },

View File

@ -32,6 +32,15 @@ TypeHandle TinyGraphicsStateGuardian::_type_handle;
PStatCollector TinyGraphicsStateGuardian::_vertices_immediate_pcollector("Vertices:Immediate mode");
PStatCollector TinyGraphicsStateGuardian::_draw_transform_pcollector("Draw:Transform");
PStatCollector TinyGraphicsStateGuardian::_pixel_count_white_untextured_pcollector("Pixels:White untextured");
PStatCollector TinyGraphicsStateGuardian::_pixel_count_flat_untextured_pcollector("Pixels:Flat untextured");
PStatCollector TinyGraphicsStateGuardian::_pixel_count_smooth_untextured_pcollector("Pixels:Smooth untextured");
PStatCollector TinyGraphicsStateGuardian::_pixel_count_white_textured_pcollector("Pixels:White textured");
PStatCollector TinyGraphicsStateGuardian::_pixel_count_flat_textured_pcollector("Pixels:Flat textured");
PStatCollector TinyGraphicsStateGuardian::_pixel_count_smooth_textured_pcollector("Pixels:Smooth textured");
PStatCollector TinyGraphicsStateGuardian::_pixel_count_white_perspective_pcollector("Pixels:White perspective");
PStatCollector TinyGraphicsStateGuardian::_pixel_count_flat_perspective_pcollector("Pixels:Flat perspective");
PStatCollector TinyGraphicsStateGuardian::_pixel_count_smooth_perspective_pcollector("Pixels:Smooth perspective");
////////////////////////////////////////////////////////////////////
// Function: TinyGraphicsStateGuardian::Constructor
@ -341,6 +350,16 @@ begin_frame(Thread *current_thread) {
#ifdef DO_PSTATS
_vertices_immediate_pcollector.clear_level();
_pixel_count_white_untextured_pcollector.clear_level();
_pixel_count_flat_untextured_pcollector.clear_level();
_pixel_count_smooth_untextured_pcollector.clear_level();
_pixel_count_white_textured_pcollector.clear_level();
_pixel_count_flat_textured_pcollector.clear_level();
_pixel_count_smooth_textured_pcollector.clear_level();
_pixel_count_white_perspective_pcollector.clear_level();
_pixel_count_flat_perspective_pcollector.clear_level();
_pixel_count_smooth_perspective_pcollector.clear_level();
#endif
return true;
@ -424,9 +443,21 @@ void TinyGraphicsStateGuardian::
end_frame(Thread *current_thread) {
GraphicsStateGuardian::end_frame(current_thread);
#ifdef DO_PSTATS
// Flush any PCollectors specific to this kind of GSG.
_vertices_immediate_pcollector.flush_level();
_pixel_count_white_untextured_pcollector.flush_level();
_pixel_count_flat_untextured_pcollector.flush_level();
_pixel_count_smooth_untextured_pcollector.flush_level();
_pixel_count_white_textured_pcollector.flush_level();
_pixel_count_flat_textured_pcollector.flush_level();
_pixel_count_smooth_textured_pcollector.flush_level();
_pixel_count_white_perspective_pcollector.flush_level();
_pixel_count_flat_perspective_pcollector.flush_level();
_pixel_count_smooth_perspective_pcollector.flush_level();
#endif // DO_PSTATS
// Evict any textures that exceed our texture memory.
_textures_lru.begin_epoch();
}
@ -783,6 +814,18 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader,
}
_c->zb_fill_tri = fill_tri_funcs[depth_write_state][color_write_state][alpha_test_state][depth_test_state][texfilter_state][shade_model_state][texturing_state];
#ifdef DO_PSTATS
pixel_count_white_untextured = 0;
pixel_count_flat_untextured = 0;
pixel_count_smooth_untextured = 0;
pixel_count_white_textured = 0;
pixel_count_flat_textured = 0;
pixel_count_smooth_textured = 0;
pixel_count_white_perspective = 0;
pixel_count_flat_perspective = 0;
pixel_count_smooth_perspective = 0;
#endif // DO_PSTATS
return true;
}
@ -1028,6 +1071,19 @@ draw_points(const GeomPrimitivePipelineReader *reader, bool force) {
////////////////////////////////////////////////////////////////////
void TinyGraphicsStateGuardian::
end_draw_primitives() {
#ifdef DO_PSTATS
_pixel_count_white_untextured_pcollector.add_level(pixel_count_white_untextured);
_pixel_count_flat_untextured_pcollector.add_level(pixel_count_flat_untextured);
_pixel_count_smooth_untextured_pcollector.add_level(pixel_count_smooth_untextured);
_pixel_count_white_textured_pcollector.add_level(pixel_count_white_textured);
_pixel_count_flat_textured_pcollector.add_level(pixel_count_flat_textured);
_pixel_count_smooth_textured_pcollector.add_level(pixel_count_smooth_textured);
_pixel_count_white_perspective_pcollector.add_level(pixel_count_white_perspective);
_pixel_count_flat_perspective_pcollector.add_level(pixel_count_flat_perspective);
_pixel_count_smooth_perspective_pcollector.add_level(pixel_count_smooth_perspective);
#endif // DO_PSTATS
GraphicsStateGuardian::end_draw_primitives();
}

View File

@ -152,6 +152,15 @@ private:
static PStatCollector _vertices_immediate_pcollector;
static PStatCollector _draw_transform_pcollector;
static PStatCollector _pixel_count_white_untextured_pcollector;
static PStatCollector _pixel_count_flat_untextured_pcollector;
static PStatCollector _pixel_count_smooth_untextured_pcollector;
static PStatCollector _pixel_count_white_textured_pcollector;
static PStatCollector _pixel_count_flat_textured_pcollector;
static PStatCollector _pixel_count_smooth_textured_pcollector;
static PStatCollector _pixel_count_white_perspective_pcollector;
static PStatCollector _pixel_count_flat_perspective_pcollector;
static PStatCollector _pixel_count_smooth_perspective_pcollector;
public:
static TypeHandle get_class_type() {

View File

@ -10,6 +10,18 @@
#include "zbuffer.h"
#include "pnotify.h"
#ifdef DO_PSTATS
int pixel_count_white_untextured;
int pixel_count_flat_untextured;
int pixel_count_smooth_untextured;
int pixel_count_white_textured;
int pixel_count_flat_textured;
int pixel_count_smooth_textured;
int pixel_count_white_perspective;
int pixel_count_flat_perspective;
int pixel_count_smooth_perspective;
#endif // DO_PSTATS
ZBuffer *ZB_open(int xsize, int ysize, int mode,
int nb_colors,
unsigned char *color_indexes,

View File

@ -136,6 +136,26 @@ struct ZBufferPoint {
/* zbuffer.c */
#ifdef DO_PSTATS
extern int pixel_count_white_untextured;
extern int pixel_count_flat_untextured;
extern int pixel_count_smooth_untextured;
extern int pixel_count_white_textured;
extern int pixel_count_flat_textured;
extern int pixel_count_smooth_textured;
extern int pixel_count_white_perspective;
extern int pixel_count_flat_perspective;
extern int pixel_count_smooth_perspective;
#define COUNT_PIXELS(pixel_count, p0, p1, p2) \
(pixel_count) += abs((p0)->x * ((p1)->y - (p2)->y) + (p1)->x * ((p2)->y - (p0)->y) + (p2)->x * ((p0)->y - (p1)->y)) / 2
#else
#define COUNT_PIXELS(pixel_count, p0, p1, p2)
#endif // DO_PSTATS
ZBuffer *ZB_open(int xsize,int ysize,int mode,
int nb_colors,
unsigned char *color_indexes,

View File

@ -39,6 +39,8 @@
EARLY_OUT();
COUNT_PIXELS(PIXEL_COUNT, p0, p1, p2);
/* we sort the vertex with increasing y */
if (p1->y < p0->y) {
t = p0;
@ -382,3 +384,4 @@
#undef DRAW_INIT
#undef DRAW_LINE
#undef PUT_PIXEL
#undef PIXEL_COUNT

View File

@ -21,6 +21,8 @@ static void FNAME(white_untextured) (ZBuffer *zb,
z+=dzdx; \
}
#define PIXEL_COUNT pixel_count_white_untextured
#include "ztriangle.h"
}
@ -58,6 +60,8 @@ static void FNAME(flat_untextured) (ZBuffer *zb,
z+=dzdx; \
}
#define PIXEL_COUNT pixel_count_flat_untextured
#include "ztriangle.h"
}
@ -105,6 +109,8 @@ static void FNAME(smooth_untextured) (ZBuffer *zb,
oa1+=dadx; \
}
#define PIXEL_COUNT pixel_count_smooth_untextured
#include "ztriangle.h"
}
@ -140,6 +146,8 @@ static void FNAME(white_textured) (ZBuffer *zb,
t+=dtdx; \
}
#define PIXEL_COUNT pixel_count_white_textured
#include "ztriangle.h"
}
@ -193,6 +201,8 @@ static void FNAME(flat_textured) (ZBuffer *zb,
t+=dtdx; \
}
#define PIXEL_COUNT pixel_count_flat_textured
#include "ztriangle.h"
}
@ -256,6 +266,8 @@ static void FNAME(smooth_textured) (ZBuffer *zb,
t+=dtdx; \
}
#define PIXEL_COUNT pixel_count_smooth_textured
#include "ztriangle.h"
}
@ -275,8 +287,8 @@ static void FNAME(white_perspective) (ZBuffer *zb,
#define NB_INTERP 8
#define EARLY_OUT() \
{ \
#define EARLY_OUT() \
{ \
}
#define DRAW_INIT() \
@ -364,6 +376,8 @@ static void FNAME(white_perspective) (ZBuffer *zb,
} \
}
#define PIXEL_COUNT pixel_count_white_perspective
#include "ztriangle.h"
}
@ -382,9 +396,8 @@ static void FNAME(flat_perspective) (ZBuffer *zb,
#define INTERP_STZ
#define INTERP_RGB
#define EARLY_OUT() \
{ \
#define EARLY_OUT() \
{ \
}
#define DRAW_INIT() \
@ -493,6 +506,8 @@ static void FNAME(flat_perspective) (ZBuffer *zb,
} \
}
#define PIXEL_COUNT pixel_count_flat_perspective
#include "ztriangle.h"
}
@ -630,6 +645,8 @@ static void FNAME(smooth_perspective) (ZBuffer *zb,
} \
}
#define PIXEL_COUNT pixel_count_smooth_perspective
#include "ztriangle.h"
}