trunk/src/emu/video/poly.c
| r28719 | r28720 | |
| 123 | 123 | /* polygon_info describes a single polygon, which includes the poly_params */ |
| 124 | 124 | struct polygon_info |
| 125 | 125 | { |
| 126 | | poly_manager * poly; /* pointer back to the poly manager */ |
| 126 | legacy_poly_manager * poly; /* pointer back to the poly manager */ |
| 127 | 127 | void * dest; /* pointer to the destination we are rendering to */ |
| 128 | 128 | void * extra; /* extra data pointer */ |
| 129 | 129 | UINT8 numparams; /* number of parameters for this polygon */ |
| r28719 | r28720 | |
| 136 | 136 | |
| 137 | 137 | |
| 138 | 138 | /* full poly manager description */ |
| 139 | | struct poly_manager |
| 139 | struct legacy_poly_manager |
| 140 | 140 | { |
| 141 | 141 | /* queue management */ |
| 142 | 142 | osd_work_queue * queue; /* work queue */ |
| r28719 | r28720 | |
| 194 | 194 | |
| 195 | 195 | static void **allocate_array(running_machine &machine, size_t *itemsize, UINT32 itemcount); |
| 196 | 196 | static void *poly_item_callback(void *param, int threadid); |
| 197 | | static void poly_state_presave(poly_manager *poly); |
| 197 | static void poly_state_presave(legacy_poly_manager *poly); |
| 198 | 198 | |
| 199 | 199 | |
| 200 | 200 | |
| r28719 | r28720 | |
| 274 | 274 | object, blocking if we run out |
| 275 | 275 | -------------------------------------------------*/ |
| 276 | 276 | |
| 277 | | INLINE polygon_info *allocate_polygon(poly_manager *poly, int miny, int maxy) |
| 277 | INLINE polygon_info *allocate_polygon(legacy_poly_manager *poly, int miny, int maxy) |
| 278 | 278 | { |
| 279 | 279 | /* wait for a work item if we have to */ |
| 280 | 280 | if (poly->polygon_next + 1 > poly->polygon_count) |
| r28719 | r28720 | |
| 308 | 308 | manager |
| 309 | 309 | -------------------------------------------------*/ |
| 310 | 310 | |
| 311 | | poly_manager *poly_alloc(running_machine &machine, int max_polys, size_t extra_data_size, UINT8 flags) |
| 311 | legacy_poly_manager *poly_alloc(running_machine &machine, int max_polys, size_t extra_data_size, UINT8 flags) |
| 312 | 312 | { |
| 313 | | poly_manager *poly; |
| 313 | legacy_poly_manager *poly; |
| 314 | 314 | |
| 315 | 315 | /* allocate the manager itself */ |
| 316 | | poly = auto_alloc_clear(machine, poly_manager); |
| 316 | poly = auto_alloc_clear(machine, legacy_poly_manager); |
| 317 | 317 | poly->flags = flags; |
| 318 | 318 | |
| 319 | 319 | /* allocate polygons */ |
| r28719 | r28720 | |
| 348 | 348 | poly_free - free a polygon manager |
| 349 | 349 | -------------------------------------------------*/ |
| 350 | 350 | |
| 351 | | void poly_free(poly_manager *poly) |
| 351 | void poly_free(legacy_poly_manager *poly) |
| 352 | 352 | { |
| 353 | 353 | #if KEEP_STATISTICS |
| 354 | 354 | { |
| r28719 | r28720 | |
| 387 | 387 | to complete |
| 388 | 388 | -------------------------------------------------*/ |
| 389 | 389 | |
| 390 | | void poly_wait(poly_manager *poly, const char *debug_reason) |
| 390 | void poly_wait(legacy_poly_manager *poly, const char *debug_reason) |
| 391 | 391 | { |
| 392 | 392 | osd_ticks_t time; |
| 393 | 393 | |
| r28719 | r28720 | |
| 431 | 431 | extra data for the next polygon |
| 432 | 432 | -------------------------------------------------*/ |
| 433 | 433 | |
| 434 | | void *poly_get_extra_data(poly_manager *poly) |
| 434 | void *poly_get_extra_data(legacy_poly_manager *poly) |
| 435 | 435 | { |
| 436 | 436 | /* wait for a work item if we have to */ |
| 437 | 437 | if (poly->extra_next + 1 > poly->extra_count) |
| r28719 | r28720 | |
| 460 | 460 | triangle given 3 vertexes |
| 461 | 461 | -------------------------------------------------*/ |
| 462 | 462 | |
| 463 | | UINT32 poly_render_triangle(poly_manager *poly, void *dest, const rectangle &cliprect, poly_draw_scanline_func callback, int paramcount, const poly_vertex *v1, const poly_vertex *v2, const poly_vertex *v3) |
| 463 | UINT32 poly_render_triangle(legacy_poly_manager *poly, void *dest, const rectangle &cliprect, poly_draw_scanline_func callback, int paramcount, const poly_vertex *v1, const poly_vertex *v2, const poly_vertex *v3) |
| 464 | 464 | { |
| 465 | 465 | float dxdy_v1v2, dxdy_v1v3, dxdy_v2v3; |
| 466 | 466 | const poly_vertex *tv; |
| r28719 | r28720 | |
| 643 | 643 | triangles in a fan |
| 644 | 644 | -------------------------------------------------*/ |
| 645 | 645 | |
| 646 | | UINT32 poly_render_triangle_fan(poly_manager *poly, void *dest, const rectangle &cliprect, poly_draw_scanline_func callback, int paramcount, int numverts, const poly_vertex *v) |
| 646 | UINT32 poly_render_triangle_fan(legacy_poly_manager *poly, void *dest, const rectangle &cliprect, poly_draw_scanline_func callback, int paramcount, int numverts, const poly_vertex *v) |
| 647 | 647 | { |
| 648 | 648 | UINT32 pixels = 0; |
| 649 | 649 | int vertnum; |
| r28719 | r28720 | |
| 660 | 660 | render of an object, given specific extents |
| 661 | 661 | -------------------------------------------------*/ |
| 662 | 662 | |
| 663 | | UINT32 poly_render_triangle_custom(poly_manager *poly, void *dest, const rectangle &cliprect, poly_draw_scanline_func callback, int startscanline, int numscanlines, const poly_extent *extents) |
| 663 | UINT32 poly_render_triangle_custom(legacy_poly_manager *poly, void *dest, const rectangle &cliprect, poly_draw_scanline_func callback, int startscanline, int numscanlines, const poly_extent *extents) |
| 664 | 664 | { |
| 665 | 665 | INT32 curscan, scaninc; |
| 666 | 666 | polygon_info *polygon; |
| r28719 | r28720 | |
| 756 | 756 | given 4 vertexes |
| 757 | 757 | -------------------------------------------------*/ |
| 758 | 758 | |
| 759 | | UINT32 poly_render_quad(poly_manager *poly, void *dest, const rectangle &cliprect, poly_draw_scanline_func callback, int paramcount, const poly_vertex *v1, const poly_vertex *v2, const poly_vertex *v3, const poly_vertex *v4) |
| 759 | UINT32 poly_render_quad(legacy_poly_manager *poly, void *dest, const rectangle &cliprect, poly_draw_scanline_func callback, int paramcount, const poly_vertex *v1, const poly_vertex *v2, const poly_vertex *v3, const poly_vertex *v4) |
| 760 | 760 | { |
| 761 | 761 | poly_edge fedgelist[3], bedgelist[3]; |
| 762 | 762 | const poly_edge *ledge, *redge; |
| r28719 | r28720 | |
| 976 | 976 | quads in a fan |
| 977 | 977 | -------------------------------------------------*/ |
| 978 | 978 | |
| 979 | | UINT32 poly_render_quad_fan(poly_manager *poly, void *dest, const rectangle &cliprect, poly_draw_scanline_func callback, int paramcount, int numverts, const poly_vertex *v) |
| 979 | UINT32 poly_render_quad_fan(legacy_poly_manager *poly, void *dest, const rectangle &cliprect, poly_draw_scanline_func callback, int paramcount, int numverts, const poly_vertex *v) |
| 980 | 980 | { |
| 981 | 981 | UINT32 pixels = 0; |
| 982 | 982 | int vertnum; |
| r28719 | r28720 | |
| 998 | 998 | to 32 vertices |
| 999 | 999 | -------------------------------------------------*/ |
| 1000 | 1000 | |
| 1001 | | UINT32 poly_render_polygon(poly_manager *poly, void *dest, const rectangle &cliprect, poly_draw_scanline_func callback, int paramcount, int numverts, const poly_vertex *v) |
| 1001 | UINT32 poly_render_polygon(legacy_poly_manager *poly, void *dest, const rectangle &cliprect, poly_draw_scanline_func callback, int paramcount, int numverts, const poly_vertex *v) |
| 1002 | 1002 | { |
| 1003 | 1003 | poly_edge fedgelist[MAX_POLYGON_VERTS - 1], bedgelist[MAX_POLYGON_VERTS - 1]; |
| 1004 | 1004 | const poly_edge *ledge, *redge; |
| r28719 | r28720 | |
| 1351 | 1351 | ensure everything is synced before saving |
| 1352 | 1352 | -------------------------------------------------*/ |
| 1353 | 1353 | |
| 1354 | | static void poly_state_presave(poly_manager *poly) |
| 1354 | static void poly_state_presave(legacy_poly_manager *poly) |
| 1355 | 1355 | { |
| 1356 | 1356 | poly_wait(poly, "pre-save"); |
| 1357 | 1357 | } |
trunk/src/emu/video/poly.h
| r28719 | r28720 | |
| 55 | 55 | ***************************************************************************/ |
| 56 | 56 | |
| 57 | 57 | /* opaque reference to the poly manager */ |
| 58 | | struct poly_manager; |
| 58 | struct legacy_poly_manager; |
| 59 | 59 | |
| 60 | 60 | |
| 61 | 61 | /* input vertex data */ |
| r28719 | r28720 | |
| 97 | 97 | /* ----- initialization/teardown ----- */ |
| 98 | 98 | |
| 99 | 99 | /* allocate a new poly manager that can render triangles */ |
| 100 | | poly_manager *poly_alloc(running_machine &machine, int max_polys, size_t extra_data_size, UINT8 flags); |
| 100 | legacy_poly_manager *poly_alloc(running_machine &machine, int max_polys, size_t extra_data_size, UINT8 flags); |
| 101 | 101 | |
| 102 | 102 | /* free a poly manager */ |
| 103 | | void poly_free(poly_manager *poly); |
| 103 | void poly_free(legacy_poly_manager *poly); |
| 104 | 104 | |
| 105 | 105 | |
| 106 | 106 | |
| 107 | 107 | /* ----- common functions ----- */ |
| 108 | 108 | |
| 109 | 109 | /* wait until all polygons in the queue have been rendered */ |
| 110 | | void poly_wait(poly_manager *poly, const char *debug_reason); |
| 110 | void poly_wait(legacy_poly_manager *poly, const char *debug_reason); |
| 111 | 111 | |
| 112 | 112 | /* get a pointer to the extra data for the next polygon */ |
| 113 | | void *poly_get_extra_data(poly_manager *poly); |
| 113 | void *poly_get_extra_data(legacy_poly_manager *poly); |
| 114 | 114 | |
| 115 | 115 | |
| 116 | 116 | |
| 117 | 117 | /* ----- core triangle rendering ----- */ |
| 118 | 118 | |
| 119 | 119 | /* render a single triangle given 3 vertexes */ |
| 120 | | UINT32 poly_render_triangle(poly_manager *poly, void *dest, const rectangle &cliprect, poly_draw_scanline_func callback, int paramcount, const poly_vertex *v1, const poly_vertex *v2, const poly_vertex *v3); |
| 120 | UINT32 poly_render_triangle(legacy_poly_manager *poly, void *dest, const rectangle &cliprect, poly_draw_scanline_func callback, int paramcount, const poly_vertex *v1, const poly_vertex *v2, const poly_vertex *v3); |
| 121 | 121 | |
| 122 | 122 | /* render a set of triangles in a fan */ |
| 123 | | UINT32 poly_render_triangle_fan(poly_manager *poly, void *dest, const rectangle &cliprect, poly_draw_scanline_func callback, int paramcount, int numverts, const poly_vertex *v); |
| 123 | UINT32 poly_render_triangle_fan(legacy_poly_manager *poly, void *dest, const rectangle &cliprect, poly_draw_scanline_func callback, int paramcount, int numverts, const poly_vertex *v); |
| 124 | 124 | |
| 125 | 125 | /* perform a custom render of an object, given specific extents */ |
| 126 | | UINT32 poly_render_triangle_custom(poly_manager *poly, void *dest, const rectangle &cliprect, poly_draw_scanline_func callback, int startscanline, int numscanlines, const poly_extent *extents); |
| 126 | UINT32 poly_render_triangle_custom(legacy_poly_manager *poly, void *dest, const rectangle &cliprect, poly_draw_scanline_func callback, int startscanline, int numscanlines, const poly_extent *extents); |
| 127 | 127 | |
| 128 | 128 | |
| 129 | 129 | |
| 130 | 130 | /* ----- core quad rendering ----- */ |
| 131 | 131 | |
| 132 | 132 | /* render a single quad given 4 vertexes */ |
| 133 | | UINT32 poly_render_quad(poly_manager *poly, void *dest, const rectangle &cliprect, poly_draw_scanline_func callback, int paramcount, const poly_vertex *v1, const poly_vertex *v2, const poly_vertex *v3, const poly_vertex *v4); |
| 133 | UINT32 poly_render_quad(legacy_poly_manager *poly, void *dest, const rectangle &cliprect, poly_draw_scanline_func callback, int paramcount, const poly_vertex *v1, const poly_vertex *v2, const poly_vertex *v3, const poly_vertex *v4); |
| 134 | 134 | |
| 135 | 135 | /* render a set of quads in a fan */ |
| 136 | | UINT32 poly_render_quad_fan(poly_manager *poly, void *dest, const rectangle &cliprect, poly_draw_scanline_func callback, int paramcount, int numverts, const poly_vertex *v); |
| 136 | UINT32 poly_render_quad_fan(legacy_poly_manager *poly, void *dest, const rectangle &cliprect, poly_draw_scanline_func callback, int paramcount, int numverts, const poly_vertex *v); |
| 137 | 137 | |
| 138 | 138 | |
| 139 | 139 | |
| 140 | 140 | /* ----- core polygon rendering ----- */ |
| 141 | 141 | |
| 142 | 142 | /* render a single polygon up to 32 vertices */ |
| 143 | | UINT32 poly_render_polygon(poly_manager *poly, void *dest, const rectangle &cliprect, poly_draw_scanline_func callback, int paramcount, int numverts, const poly_vertex *v); |
| 143 | UINT32 poly_render_polygon(legacy_poly_manager *poly, void *dest, const rectangle &cliprect, poly_draw_scanline_func callback, int paramcount, int numverts, const poly_vertex *v); |
| 144 | 144 | |
| 145 | 145 | |
| 146 | 146 | |