|
KallistiOS git master
Independent SDK for the Sega Dreamcast
|
Example of pushing polygons with SH4ZAM. More...
Functions | |
| static void | cache_polygon_header (pvr_poly_hdr_t *poly_header) |
| static void | submit_polygon_header (const pvr_poly_hdr_t *poly_header) |
| Submits the polygon header for the ball vertex strip to the PowerVR GPU. | |
| static void | setup_projection_view (shz_mat4x4_t *mat) |
| Sets up and caches our projection view matrix for use later. | |
| static void | apply_model_matrix (shz_vec3_t pos, shz_vec2_t rot, const shz_mat4x4_t *proj_view) |
| static void | render_sphere (float radius, uint32_t base_color) |
| Renders a single one of Bruce's balls. | |
| static void | init_balls (Ball *balls) |
| static bool | check_exit (void) |
| Polls to see whether the start button of the fist controller was pressed. | |
| static void | update_frame_stats (void) |
| Calculates and intermittently reports frame statistics. | |
| int | main (int argc, const char *argv[]) |
| Program entry point. | |
Variables | |
| constexpr unsigned | BALL_COUNT = 93 |
| Number of balls to render (play with me!) | |
| constexpr unsigned | SPHERE_STACKS = 20 |
| Number of Z stacks which comprise the ball's geometry. | |
| constexpr unsigned | SPHERE_SLICES = 20 |
| Number of X/Y slices which comprise each stack of the ball's geometry. | |
| constexpr unsigned | TRIANGLES_PER_BALL = SPHERE_STACKS * SPHERE_SLICES * 2 |
| Total number of triangles which get rendered per ball. | |
| constexpr unsigned | TRIANGLES_TOTAL = TRIANGLES_PER_BALL * BALL_COUNT |
| Total number of triangles rendered per scene, including all balls. | |
Example of pushing polygons with SH4ZAM.
Welcome to Bruce's Balls!
The following example illustrates the use of SH4ZAM to accelerate rendering and vertex processing. It also serves as a performance benchmark at the high-end, capable of pushing 4.5 million polygons per second with the proper build flags.
The program simply renders a series of high-polygon balls and reports back the rendering performance in terms of polygons per second. It does so by using KOS's "Direct Rendering" PVR API, which submits geometry to the PowerVR GPU via filling and flushing the two store queues to the TA in alternation. Ths is the fastest rendering path.
|
static |
|
static |
Precomputes and caches the polygon header used for drawing balls.
For maximum performance, do not waste time dynamically compiling polygon contexts into headers each frame. Do it once and cache the result!
Compile the polygon context into a polygon header for use later.
References cxt, PVR_LIST_OP_POLY, pvr_poly_compile(), and pvr_poly_cxt_col().
Referenced by main().
|
static |
Polls to see whether the start button of the fist controller was pressed.
References maple_dev_status(), maple_enum_type(), MAPLE_FUNC_CONTROLLER, and cont_state_t::start.
Referenced by main().
|
static |
Initializes Bruce's balls.
Precalculates the balls' attributes, aligning them to a grid and givign them intial orientation and velocity values.
References BALL_COUNT, and y.
Referenced by main().
| int main | ( | int | argc, |
| const char * | argv[] ) |
Program entry point.
Render Bruce's current ball.
References apply_model_matrix(), BALL_COUNT, cache_polygon_header(), check_exit(), color, init_balls(), pos, printf, PVR_BINSIZE_0, PVR_BINSIZE_32, pvr_init(), pvr_list_begin(), pvr_list_finish(), PVR_LIST_OP_POLY, pvr_scene_begin(), pvr_scene_finish(), pvr_shutdown(), render_sphere(), setup_projection_view(), submit_polygon_header(), TRIANGLES_TOTAL, and update_frame_stats().
|
static |
Renders a single one of Bruce's balls.
References pvr_vertex_t::flags, PVR_CMD_VERTEX, PVR_CMD_VERTEX_EOL, pvr_dr_commit, pvr_dr_target, SPHERE_SLICES, SPHERE_STACKS, pvr_vertex_t::x, pvr_vertex_t::y, and pvr_vertex_t::z.
Referenced by main().
|
static |
Sets up and caches our projection view matrix for use later.
Referenced by main().
|
static |
Submits the polygon header for the ball vertex strip to the PowerVR GPU.
References pvr_dr_target.
Referenced by main().
|
static |
Calculates and intermittently reports frame statistics.
Structure containing statistics we're measuring.
< Timestamp from the last time this routine was called.
< The number of rames that have run within the last second.
< The last calculated framerate.
< Static instance of statistics, which persists between frames.
References printf, stats(), timer_ns_gettime64(), and TRIANGLES_TOTAL.
Referenced by main().
|
constexpr |
Number of balls to render (play with me!)
Referenced by init_balls(), and main().
|
constexpr |
Number of X/Y slices which comprise each stack of the ball's geometry.
Referenced by render_sphere().
|
constexpr |
Number of Z stacks which comprise the ball's geometry.
Referenced by render_sphere().
|
constexpr |
Total number of triangles which get rendered per ball.
|
constexpr |
Total number of triangles rendered per scene, including all balls.
Referenced by main(), and update_frame_stats().