home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / demos / gpc / brf_trv.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-15  |  24.4 KB  |  727 lines

  1. /* $XConsortium: brf_trv.c,v 5.1 91/02/16 10:07:20 rws Exp $ */
  2. /***********************************************************
  3. Copyright(c) 1989,1990, 1991 by Sun Microsystems, Inc. and the X Consortium at M.I.T.
  4.  
  5.                         All Rights Reserved
  6.  
  7. Permission to use, copy, modify, and distribute this software and its
  8. documentation for any purpose and without fee is hereby granted,
  9. provided that the above copyright notice appear in all copies and that
  10. both that copyright notice and this permission notice appear in
  11. supporting documentation, and that the names of Sun Microsystems,
  12. the X Consortium, and MIT not be used in advertising or publicity
  13. pertaining to distribution of the software without specific, written
  14. prior permission.
  15.  
  16. SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  17. INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
  18. SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
  19. DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  20. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  21. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  22. SOFTWARE.
  23.  
  24. ******************************************************************/
  25.  
  26. /*--------------------------------------------------------------------*\
  27. |
  28. |  Copyright (C) 1989,1990, 1991, National Computer Graphics Association
  29. |
  30. |  Permission is granted to any individual or institution to use, copy, or
  31. |  redistribute this software so long as it is not sold for profit, provided
  32. |  this copyright notice is retained.
  33. |
  34. |                         Developed for the
  35. |                National Computer Graphics Association
  36. |                         2722 Merrilee Drive
  37. |                         Fairfax, VA  22031
  38. |                           (703) 698-9600
  39. |
  40. |                                by
  41. |                 SimGraphics Engineering Corporation
  42. |                    1137 Huntington Drive  Unit A
  43. |                      South Pasadena, CA  91030
  44. |                           (213) 255-0900
  45. |---------------------------------------------------------------------
  46. |
  47. | Author        :    SimGraphics Engineering Corportation
  48. |
  49. | File          :    brf_trv.c
  50. | Date          :    Fri Feb  9 10:46:55 PST 1990
  51. | Project       :    PLB
  52. | Description   :    Traverses the BRF structures, collecting usage
  53. |            information on each bif element, and generates
  54. |            the BRF report.
  55. | Status        :    Version 1.0
  56. |
  57. | Revisions     :    
  58. |
  59. |       5/90            MFC Tektronix, Inc.: PEX-SI API Binding change.
  60. |
  61. |      12/90            MFC Tektronix, Inc.: PEX-SI PEX5R1 Release.
  62. |
  63. \*--------------------------------------------------------------------*/
  64.  
  65. /*--------------------------------------------------------------------*\
  66. |    Table of Contents
  67. |
  68. |    void brf_traverser(    *BIF_Traverser_state, *BIF_All, *BRF_state)
  69. |        :    Walks throuth the BRF structures built for a 
  70. |                    givren test
  71. |    void brf_branch (    *BIF_Traverser_state, *BIF_All, *BRF_state)
  72. |        :    NOTE: An improvement to this code would be to add a
  73. |    void brf_report (    *BRF_state )
  74. |        :    Main routine involved in printing out a BRF report
  75. |    void brf_init (    )
  76. |        :    Initialized BRF tables
  77. |    void brf_start_stopwatch ()
  78. |        :    Starts the stop watch
  79. |    void brf_stop_stopwatch ( *BRF_state )
  80. |        :    Stops the stop watch
  81. |
  82. \*--------------------------------------------------------------------*/
  83.  
  84. #define STRLENGTH 80
  85. #include <stdio.h>
  86. #ifdef SYSV
  87. #include <sys/types.h>
  88. #include <sys/times.h>
  89. #include <time.h>
  90. #endif
  91. #include <sys/time.h>
  92. #include "brf_ents.h"
  93. #include "biftypes.h"
  94. #include "bifmacro.h"
  95. #include "bifparse.h"
  96. #include "brftypes.h"
  97. #include "brf_set.h"
  98. #include "globals.h"
  99. #include "ph_map.h"
  100. #include "brfexption.h"
  101. #include "stopwatch.h"
  102.  
  103. void brf_branch ();
  104. void brf_report ();
  105. void brf_init ();
  106. extern    char brf_filename[STRLENGTH];
  107. extern    FILE *brf_file;
  108. extern    int  brf_used_flag;
  109. extern  char input_filenm[128];
  110. extern BRF_exception brf_exception[MAX_EXCEPTION];
  111.  
  112. /*----------------------------------------------------------------------*\
  113. | Program: brf_trv.c
  114. |
  115. \*----------------------------------------------------------------------*/
  116.  
  117.  
  118. #define EXCEPTION_HANDLER 1
  119. #ifdef EXTERNALNOTE
  120.  
  121.  
  122.     ATTENTION END PORT PROGRAMMERS!!!!!!!!!!!!
  123.  
  124.         Part of the mechanism for the exceptions reporting is inside this
  125.     code, marked with "#ifdef EXCEPTION_HANDLER". These are the global
  126.     plb exception messages, as defined in bifmacro.h and set in bldgeneric.c
  127.     and bifbuild.c. Use this code as an example of how to add exception
  128.     reporters to customized ports. For a better example of exceptions reporting,
  129.     see the code in brf_ents.c
  130.  
  131. #endif
  132.  
  133. BRF_table brf_group1[] = 
  134. {
  135.     (BRF_table) &brf_label,
  136.     (BRF_table) &brf_marker,
  137.     (BRF_table) &brf_marker3,
  138.     (BRF_table) &brf_line,
  139.     (BRF_table) &brf_line3,
  140.     (BRF_table) &brf_text,
  141.     (BRF_table) &brf_text3,
  142.     (BRF_table) &brf_annotationtext3,
  143.     (BRF_table) &brf_pixelmap3,
  144.     (BRF_table) &brf_gensphere3,
  145.     (BRF_table) &brf_gencircle,
  146.     (BRF_table) &brf_gencircle3
  147. };
  148. int brf_group1_len = sizeof(brf_group1)/sizeof(BRF_table);
  149.  
  150. BRF_table brf_group2[] = 
  151. {
  152.     (BRF_table) &brf_linetype,
  153.     (BRF_table) &brf_interiorshading,
  154.     (BRF_table) &brf_interiorlighting,
  155.     (BRF_table) &brf_backfaceprocessing,
  156.     (BRF_table) &brf_edgeflag,
  157.     (BRF_table) &brf_textfont,
  158.     (BRF_table) &brf_textprec,
  159.     (BRF_table) &brf_lightstate,
  160.     (BRF_table) &brf_depthcueindex,
  161.     (BRF_table) &brf_hlhsremoval,
  162.     (BRF_table) &brf_readgeometryfile,
  163.     (BRF_table) &brf_cleargeometry,
  164.     (BRF_table) &brf_beginstructure,
  165.     (BRF_table) &brf_endstructure
  166. };
  167. int brf_group2_len = sizeof(brf_group2)/sizeof(BRF_table);
  168.  
  169. BRF_table brf_group3[] = 
  170. {
  171.     (BRF_table) &brf_executestructure,
  172.     (BRF_table) &brf_callstructure,
  173.     (BRF_table) &brf_invokeatframe
  174. };
  175. int brf_group3_len = sizeof(brf_group3)/sizeof(BRF_table);
  176.  
  177. BRF_table brf_group4[] = 
  178. {
  179.     (BRF_table) &brf_defineviewspecification,
  180.     (BRF_table) &brf_definelight,
  181.     (BRF_table) &brf_markertype,
  182.     (BRF_table) &brf_markersize,
  183.     (BRF_table) &brf_markercolor,
  184.     (BRF_table) &brf_markercolorindex,
  185.     (BRF_table) &brf_linewidth,
  186.     (BRF_table) &brf_linecolor,
  187.     (BRF_table) &brf_linecolorindex,
  188.     (BRF_table) &brf_lineshading,
  189.     (BRF_table) &brf_interiorstyle,
  190.     (BRF_table) &brf_interiorpatternindex,
  191.     (BRF_table) &brf_interiorcolor,
  192.     (BRF_table) &brf_interiorcolorindex,
  193.     (BRF_table) &brf_backfaceinteriorcolor,
  194.     (BRF_table) &brf_backfaceinteriorcolorindex,
  195.     (BRF_table) &brf_surfaceproperties,
  196.     (BRF_table) &brf_backfaceproperties,
  197.     (BRF_table) &brf_edgetype,
  198.     (BRF_table) &brf_edgewidth,
  199.     (BRF_table) &brf_edgecolor,
  200.     (BRF_table) &brf_edgecolorindex,
  201.     (BRF_table) &brf_textcolor,
  202.     (BRF_table) &brf_textcolorindex,
  203.     (BRF_table) &brf_textpath,
  204.     (BRF_table) &brf_textalign,
  205.     (BRF_table) &brf_charheight,
  206.     (BRF_table) &brf_charexp,
  207.     (BRF_table) &brf_charspace,
  208.     (BRF_table) &brf_charupvector,
  209.     (BRF_table) &brf_annotextcharheight,
  210.     (BRF_table) &brf_annotextcharupvector,
  211.     (BRF_table) &brf_annotextstyle
  212. };
  213. int brf_group4_len = sizeof(brf_group4)/sizeof(BRF_table);
  214.  
  215. BRF_table brf_group5[] = 
  216. {
  217.     (BRF_table) &brf_identity3,
  218.     (BRF_table) &brf_concatmatrix3,
  219.     (BRF_table) &brf_invertmatrix3,
  220.     (BRF_table) &brf_rotate3,
  221.     (BRF_table) &brf_rotatexyz3,
  222.     (BRF_table) &brf_translate3,
  223.     (BRF_table) &brf_scale3,
  224.     (BRF_table) &brf_matrix3,
  225.     (BRF_table) &brf_getmatrix3,
  226.     (BRF_table) &brf_pushmatrix3,
  227.     (BRF_table) &brf_popmatrix3,
  228.     (BRF_table) &brf_globaltransformation3,
  229.     (BRF_table) &brf_localtransformation3,
  230.     (BRF_table) &brf_applytoglobal3,
  231.     (BRF_table) &brf_applytolocal3,
  232.     (BRF_table) &brf_vieworientation3,
  233.     (BRF_table) &brf_viewmapping3,
  234.     (BRF_table) &brf_activeview
  235. };
  236. int brf_group5_len = sizeof(brf_group5)/sizeof(BRF_table);
  237.  
  238. BRF_table brf_group6[] = 
  239. {
  240.     (BRF_table) &brf_begintest,
  241.     (BRF_table) &brf_endtest,
  242.     (BRF_table) &brf_pause,
  243.     (BRF_table) &brf_sleep,
  244.     (BRF_table) &brf_definecolor,
  245.     (BRF_table) &brf_backgroundcolor,
  246.     (BRF_table) &brf_backgroundcolorindex,
  247.     (BRF_table) &brf_defaultviewspecification,
  248.     (BRF_table) &brf_definedepthcue,
  249.     (BRF_table) &brf_configuration
  250. };
  251. int brf_group6_len = sizeof(brf_group6)/sizeof(BRF_table);
  252.  
  253. BRF_table brf_group7[] = 
  254. {
  255.     (BRF_table) &brf_polygon,
  256.     (BRF_table) &brf_polygon3,
  257.     (BRF_table) &brf_fillareaset,
  258.     (BRF_table) &brf_fillareaset3,
  259.     (BRF_table) &brf_triangle3,
  260.     (BRF_table) &brf_quadmesh3,
  261.     (BRF_table) &brf_indexpolygons3
  262. };
  263. int brf_group7_len = sizeof(brf_group7)/sizeof(BRF_table);
  264.  
  265.  
  266. /*----------------------------------------------------------------------*\
  267. | Procedure   : void brf_traverser(    *BIF_Traverser_state, *BIF_All, 
  268. |                    *BRF_state)
  269. |------------------------------------------------------------------------
  270. | Description : Walks throuth the BRF structures built for a givren test
  271. |            loop.
  272. |------------------------------------------------------------------------
  273. | Return      : 
  274. \*----------------------------------------------------------------------*/
  275. brf_traverser( traverser_state, bif_entity, brf_state)
  276. BIF_Traverser_state *traverser_state;
  277. BIF_All *bif_entity;
  278. BRF_state *brf_state;
  279. {
  280.  
  281.     while ( bif_entity != NULL )
  282.     {
  283.  
  284. #ifdef EXCEPTION_HANDLER
  285.             BRF_do_exceptionsearch(bif_entity,brf_state);
  286. #endif
  287.         brf_branch(traverser_state, bif_entity, brf_state);
  288.         bif_entity = bif_entity->any.next;
  289.     }
  290. } /* End BIF_execute_traverser */
  291. /*----------------------------------------------------------------------*\
  292. | Procedure   : void brf_branch (    *BIF_Traverser_state, *BIF_All, 
  293. |                    *BRF_state)
  294. |------------------------------------------------------------------------
  295. | Description : NOTE: An improvement to this code would be to add a
  296. |        pointer to the BRF_data structures in the BIF_data
  297. |        structures, and to fill these pointers in the 
  298. |        new_(entities) calls.  This would eliminate the need for
  299. |        the search done by this procedure, and eliminate the 
  300. |        need for the brf_table
  301. |------------------------------------------------------------------------
  302. | Return      : 
  303. \*----------------------------------------------------------------------*/
  304. void brf_branch ( traverser_state, bif_entity , brf_state)
  305. BIF_Traverser_state *traverser_state;
  306. BIF_All *bif_entity;
  307. BRF_state *brf_state;
  308. {
  309. int i, entity_type;
  310. int (*brf_function)();
  311.     entity_type = bif_entity->entity_type;
  312.     brf_state->brf_flag = BRF_COLLECT;
  313.     for(i=0;i< brf_table_size;i++)
  314.     {
  315.         if(entity_type == brf_table[i]->any.entity_type)
  316.         {
  317.             brf_function = brf_table[i]->any.handler;
  318.             (*brf_function)
  319.                  (traverser_state,bif_entity,brf_table[i],brf_state);
  320.             break;
  321.         }
  322.     }
  323. }
  324.  
  325. /*----------------------------------------------------------------------*\
  326. | Procedure   : void brf_report (    *BRF_state )
  327. |------------------------------------------------------------------------
  328. | Description : Main routine involved in printing out a BRF report
  329. |------------------------------------------------------------------------
  330. | Return      : 
  331. \*----------------------------------------------------------------------*/
  332. void brf_report (brf_state )
  333. BRF_state *brf_state;
  334. {
  335. int i;
  336. int (*brf_function)();
  337. char    temp_str[80];
  338. int    num_exceptions;
  339. int    num_ents_used;
  340. static int loop_seq_no = 1;
  341. static char *sep1 =
  342. "------------------------------------------------------------------------\n";
  343. static char *sep2 =
  344. "|----------------------------------------------------------------------|\n";
  345. static char *sep3 =
  346. "| -------                       --------  --------  --------  -------- |\n";
  347.  
  348.     brf_state->brf_flag = BRF_REPORT;
  349. /*----------------------------------------------------------------------*/
  350.     /* Open the default report if one has not already been specified */
  351.     check_default_report("gpc_brf.out");
  352.  
  353. #ifdef EXTERNALNOTE
  354.     /* open a gap and print a marker to seperate the test
  355.     loop data from the header/system data. */
  356. #endif
  357.  
  358.     fprintf(brf_file,"\n\n\n");
  359.     fprintf(brf_file,sep1);
  360.     sprintf(temp_str,"|      Beginning Of Test Loop %d", loop_seq_no++);
  361.     BRF_appendEndBar(temp_str);
  362.     fprintf(brf_file,temp_str);
  363.     fprintf(brf_file,sep1);
  364.  
  365.  
  366.  
  367.     fprintf(brf_file,"\n\n%s%s%s%s%s%s%s%s",
  368. "------------------------------------------------------------------------\n",
  369. "|       Graphics Primitives: Polygon Summary Table                     |\n",
  370. "|                                                                      |\n",
  371. "|  Average                       Average   Average   Average   Average |\n",
  372. "|  Times                       Verticies    Facets     Edges  contours |\n",
  373. "|  Called                      Per Frame Per Frame Per Frame Per Frame |\n",
  374. "|  Per Frame                                                           |\n",
  375. "|----------------------------------------------------------------------|\n");
  376.  
  377.  
  378.  
  379.     num_ents_used = 0;
  380.     for(i=0;i< brf_group7_len   ;i++)
  381.     {
  382.         brf_function = brf_group7[i]->any.handler;
  383.         if ( (*brf_function)
  384.                  (NULL,NULL,brf_group7[i],brf_state) )
  385.             num_ents_used++ == 0;
  386.     }
  387.     fprintf(brf_file,sep3);
  388.         do_brftotalpoly(NULL,NULL,
  389.             &total_with_data, brf_state);
  390.     if ( num_ents_used == 0) fprintf( brf_file,
  391. "|       No Polygon Primitives used in this test loop.                  |\n");
  392.  
  393.     fprintf(brf_file,sep1);
  394.  
  395.  
  396.     fflush(brf_file);
  397.     
  398.  
  399.  
  400.     brf_state->brf_flag = BRF_REPORT2;
  401.     fprintf(brf_file,"\n\n%s%s%s%s%s%s%s%s",
  402. "------------------------------------------------------------------------\n",
  403. "|       Graphics Primitives: Polygon Optional Data Summary Table       |\n",
  404. "|                                                                      |\n",
  405. "|  Average                       Average   Average   Average   Average |\n",
  406. "|  Times                          Vertex    Vertex     Facet     Facet |\n",
  407. "|  Called                         Colors   Normals     Color   Normals |\n",
  408. "|  Per Frame                   Per Frame Per Frame Per Frame Per Frame |\n",
  409. "|----------------------------------------------------------------------|\n");
  410.  
  411.  
  412.     num_ents_used = 0;
  413.     for(i=0;i< brf_group7_len   ;i++)
  414.     {
  415.         brf_function = brf_group7[i]->any.handler;
  416.         if ( (*brf_function)
  417.                  (NULL,NULL,brf_group7[i],brf_state) )
  418.             num_ents_used++ == 0;
  419.     }
  420.     fprintf(brf_file,sep3);
  421.         do_brftotalpoly((BIF_Traverser_state *)NULL,NULL,
  422.             &total_with_data, brf_state);
  423.     if ( num_ents_used == 0) fprintf( brf_file,
  424. "|       No Polygon Optional Data in this test loop.                    |\n");
  425.  
  426.     fprintf(brf_file,sep1);
  427.  
  428.  
  429.     fprintf(brf_file,"\n\n%s%s%s%s%s%s%s%s",
  430. "------------------------------------------------------------------------\n",
  431. "|       Graphics Primitives: Polygon Edge Visibility Table             |\n",
  432. "|                                                                      |\n",
  433. "|  Average                       Average                               |\n",
  434. "|  Times                           Edges                               |\n",
  435. "|  Called                        Visible                               |\n",
  436. "|  Per Frame                   Per Frame                               |\n",
  437. "|----------------------------------------------------------------------|\n");
  438.     brf_state->brf_flag = BRF_REPORT3;
  439.     num_ents_used = 0;
  440.     for(i=0;i< brf_group7_len   ;i++)
  441.     {
  442.         brf_function = brf_group7[i]->any.handler;
  443.         if ( (*brf_function)
  444.                  (NULL,NULL,brf_group7[i],brf_state) )
  445.             num_ents_used++ == 0;
  446.     }
  447.     fprintf(brf_file,sep3);
  448.         do_brftotalpoly((BIF_Traverser_state *)NULL,NULL,
  449.             &total_with_data, brf_state);
  450.     if ( num_ents_used == 0) fprintf( brf_file,
  451. "|       No Polygon with visible edges in this loop.                    |\n");
  452.  
  453.     fprintf(brf_file,sep1);
  454.  
  455.     brf_state->brf_flag = BRF_REPORT;
  456.  
  457.  
  458.     fprintf(brf_file,"\n\n%s%s%s%s%s%s%s%s",
  459. "------------------------------------------------------------------------\n",
  460. "|       Graphics Primitives: Line and Text Summary Table               |\n",
  461. "|                                                                      |\n",
  462. "|  Average                                                             |\n",
  463. "|  Times                                                               |\n",
  464. "|  Called                                                              |\n",
  465. "|  Per Frame                                                           |\n",
  466. "|----------------------------------------------------------------------|\n");
  467.  
  468.     num_ents_used = 0;
  469.     for(i=0;i< brf_group1_len   ;i++)
  470.     {
  471.         brf_function = brf_group1[i]->any.handler;
  472.         if ( (*brf_function)
  473.                  (NULL,NULL,brf_group1[i],brf_state) )
  474.             num_ents_used++ == 0;
  475.     }
  476.     if ( num_ents_used == 0) fprintf( brf_file,
  477. "|       No Line or Text calls to report in this loop.                  |\n");
  478.  
  479.     fprintf(brf_file,sep1);
  480.  
  481.     fprintf(brf_file,"\n\n%s%s%s%s%s%s%s%s",
  482. "------------------------------------------------------------------------\n",
  483. "|       Graphics Attributes: Summary Table                             |\n",
  484. "|                                                                      |\n",
  485. "|  Average                                                             |\n",
  486. "|  Times                                                               |\n",
  487. "|  Called                                                              |\n",
  488. "|  Per Frame                                                           |\n",
  489. "|----------------------------------------------------------------------|\n");
  490.  
  491.     num_ents_used = 0;
  492.     for(i=0;i< brf_group4_len   ;i++)
  493.     {
  494.         brf_function = brf_group4[i]->any.handler;
  495.         if ( (*brf_function)
  496.                  (NULL,NULL,brf_group4[i],brf_state) )
  497.             num_ents_used++ == 0;
  498.     }
  499.  
  500.     for(i=0;i< brf_group2_len   ;i++)
  501.     {
  502.         brf_function = brf_group2[i]->any.handler;
  503.         if ( (*brf_function)
  504.                  (NULL,NULL,brf_group2[i],brf_state) )
  505.             num_ents_used++ == 0;
  506.     }
  507.     if ( num_ents_used == 0) fprintf( brf_file,
  508. "|       No Attribute calls to report in this loop.                     |\n");
  509.  
  510.     fprintf(brf_file,sep1);
  511.  
  512.     fprintf(brf_file,"\n\n%s%s%s%s%s%s%s%s",
  513. "------------------------------------------------------------------------\n",
  514. "|       Matrix Operations: Summary Table                               |\n",
  515. "|                                                                      |\n",
  516. "|  Average                                                             |\n",
  517. "|  Times                                                               |\n",
  518. "|  Called                                                              |\n",
  519. "|  Per Frame                                                           |\n",
  520. "|----------------------------------------------------------------------|\n");
  521.  
  522.     num_ents_used = 0;
  523.     for(i=0;i< brf_group5_len   ;i++)
  524.     {
  525.         brf_function = brf_group5[i]->any.handler;
  526.         if ( (*brf_function)
  527.                  (NULL,NULL,brf_group5[i],brf_state) )
  528.             num_ents_used++ == 0;
  529.     }
  530.     if ( num_ents_used == 0) fprintf( brf_file,
  531. "|       No Matrix calls to report in this loop.                        |\n");
  532.  
  533.     fprintf(brf_file,sep1);
  534.  
  535.     fprintf(brf_file,"\n\n%s%s%s%s%s%s%s%s",
  536. "------------------------------------------------------------------------\n",
  537. "|       Structure Calls: Summary Table                                 |\n",
  538. "|                                                                      |\n",
  539. "|  Average                                                             |\n",
  540. "|  Times                                                               |\n",
  541. "|  Called                                                              |\n",
  542. "|  Per Frame                                                           |\n",
  543. "|----------------------------------------------------------------------|\n");
  544.  
  545.     num_ents_used = 0;
  546.     for(i=0;i< brf_group3_len   ;i++)
  547.     {
  548.         brf_function = brf_group3[i]->any.handler;
  549.         if ( (*brf_function)
  550.                  (NULL,NULL,brf_group3[i],brf_state) )
  551.             num_ents_used++ == 0;
  552.     }
  553.     if ( num_ents_used == 0) fprintf( brf_file,
  554. "|       No Structure calls to report in this loop.                     |\n");
  555.  
  556.     fprintf(brf_file,sep1);
  557.     fprintf(brf_file,"\n\n");
  558. /*----------------------------------------------------------------------*/
  559.  
  560.     fprintf(brf_file,"%s%s%s%s%s",
  561. "------------------------------------------------------------------------\n",
  562. "|                                                                      |\n",
  563. "|       Global Exception: Summary Table                                |\n",
  564. "|                                                                      |\n",
  565. "|----------------------------------------------------------------------|\n");
  566.  
  567. #ifdef EXTERNALNOTE
  568.     /* this is the routine which prints out the global exceptions messages. 
  569.     The errors are defined in brfexception.h along with the number
  570.     of error messages and their exact text strings. This is the last
  571.     of an older system which has been superceded by brf_except.c.*/
  572. #endif
  573. #ifdef EXCEPTION_HANDLER
  574. /* add error message buffer printout right here. */
  575.     num_exceptions = 0;
  576.     /* global error messages */
  577.     {
  578.     int i;
  579.     for(i=0;i<NUM_GLOBAL_ERRORS;i++)
  580.         {
  581.                if((plb_exception & POW2(i)) != 0)
  582.            {
  583.             num_exceptions++;
  584.                        fprintf(brf_file,brf_exception_txt[i]);
  585.            }
  586.         }
  587.     }
  588.     for(i=0;i<brf_num_ex_tests;i++)
  589.     {
  590.         if(brf_exception[i].brf_ex_numhits > 0)
  591.         {
  592.             num_exceptions++;
  593.             sprintf(temp_str,"|%s",
  594.                  nice_float_8(
  595.                 (float)brf_exception[i].brf_ex_numhits
  596.                 /brf_state->brf_num_frames));
  597.             strcat(temp_str,brf_exception[i].brf_ex_message);
  598.             BRF_appendEndBar(temp_str);
  599.             fprintf(brf_file,temp_str);
  600.         }
  601.     }
  602.     if ( num_exceptions == 0) fprintf( brf_file,
  603. "|  No Exceptions to report in this loop.                               |\n");
  604.  
  605.  
  606.     fprintf(brf_file,sep1);
  607.     fprintf(brf_file,"\n\n");
  608.     fprintf(brf_file,"\n\n");
  609.  
  610. #endif
  611. }
  612.  
  613. /*----------------------------------------------------------------------*\
  614. | Procedure   : void brf_init (    )
  615. |------------------------------------------------------------------------
  616. | Description : Initialized BRF tables
  617. |------------------------------------------------------------------------
  618. | Return      : 
  619. \*----------------------------------------------------------------------*/
  620. void brf_init ( )
  621. {
  622. int i;
  623. int (*brf_function)();
  624. BRF_state brf_state;
  625.     brf_state.brf_flag = BRF_INITIALIZE;
  626.     for(i=0;i< brf_table_size;i++)
  627.     {
  628.         brf_function = brf_table[i]->any.handler;
  629.         (*brf_function)
  630.              (NULL,NULL,brf_table[i],&brf_state);
  631.     }
  632. }
  633.  
  634. /*----------------------------------------------------------------------*\
  635. | Procedure   : void brf_start_stopwatch ()
  636. |------------------------------------------------------------------------
  637. | Description : Starts the stop watch
  638. |------------------------------------------------------------------------
  639. | Return      : 
  640. \*----------------------------------------------------------------------*/
  641. brf_start_stopwatch()
  642. {
  643. float sttime;
  644.  
  645.  
  646.     sttime = stopwatch(WATCH_START);
  647.     sttime = stopwatch(WATCH_RESET);
  648.     if(sttime != 0)
  649.     {
  650.         fprintf(stderr,"Failure on timer init.\n");
  651.         fprintf(stderr,"Time should read 0.\n");
  652.         fprintf(stderr,"Timer init returns %f.\n\n\n",sttime);
  653.         exit(-1);
  654.     }
  655. #ifdef DEBUG
  656.     fprintf(stderr,"Stopwatch running. Time reads %f\n",sttime);
  657.     fflush(stderr);
  658. #endif
  659.  
  660.  
  661.     /* ST = start your timing here */
  662. }
  663.  
  664. /*----------------------------------------------------------------------*\
  665. | Procedure   : void brf_stop_stopwatch ( *BRF_state )
  666. |------------------------------------------------------------------------
  667. | Description : Stops the stop watch
  668. |------------------------------------------------------------------------
  669. | Return      : 
  670. \*----------------------------------------------------------------------*/
  671. brf_stop_stopwatch(brf_state)
  672. BRF_state *brf_state;
  673. {
  674.     float ettime;
  675.     float tttime;
  676.     int i = 1; /* flag value for pqcr */
  677.     int coli = 1; /* dummy value for pqcr */
  678.     int red; /* dummy value for pqcr */
  679.     int green; /* dummy value for pqcr */
  680.     int blue; /* dummy value for pqcr */
  681.     int errind; /* dummy value for pqcr */
  682.  
  683.     /* TT = stop take a split here (lap time?) */
  684.     ettime = stopwatch(WATCH_SPLIT);
  685. #ifdef EXTERNALNOTE
  686.     /* sync your graphics pipeline here */
  687. #endif
  688.  
  689. #ifdef USING_PHIGS
  690.     {
  691.     Pcolr_rep rep;
  692.     Pint errind;
  693.  
  694.     pinq_colr_rep((Pint)bench_setup.workid, (Pint)0,
  695.               PINQ_REALIZED, &errind, &rep);
  696.     
  697.     }
  698. #endif /* USING_PHIGS */
  699.  
  700.     /* ET = stop your timing here */
  701.     tttime = stopwatch(WATCH_SPLIT);
  702. #ifdef EXTERNALNOTE
  703.     /* 
  704.  
  705.       TIMING METHODOLOGY
  706.  
  707.       The overall time reported is from first graphics call issued to
  708.       graphics device to end of last pipe synchronization. Under some 
  709.       circumstances, it would be appropriate to run an empty loop
  710.       to obtain system overhead, then subtract that overhead to get
  711.       the real "Cost of Graphics" figure. However, this method
  712.       is less than accurate for systems with asynchronous graphics
  713.       device accelerators. In the interests of portability among
  714.       different systems, the overhead costs are left intact.  This is the
  715.       same methodology as used in the Level 1 GPC Benchmark.
  716.  
  717.       */
  718. #endif
  719.  
  720.     BRF_loopTiming( brf_state->brf_num_frames, 
  721.            tttime,       /* total elapsed time (+ Tdelay) in seconds */
  722.            (tttime - ettime),        /* ET - TT in seconds */
  723.            brf_state->brf_num_frames, /* num frames */ 
  724.            input_filenm,  /* Current input file name */
  725.            brf_file);     /* Current open report file pointer */
  726. }
  727.