Revision: 45779
          http://brlcad.svn.sourceforge.net/brlcad/?rev=45779&view=rev
Author:   kunigami
Date:     2011-08-04 01:15:44 +0000 (Thu, 04 Aug 2011)

Log Message:
-----------
added the random, unbuffered mode. it have a strange behaviour: the frame 
buffer is only painting pixels with x=0, even though I'm passing random values 
of x ranging from 0 to 511

Modified Paths:
--------------
    brlcad/trunk/src/rt/do.c
    brlcad/trunk/src/rt/ext.h
    brlcad/trunk/src/rt/opt.c
    brlcad/trunk/src/rt/view.c
    brlcad/trunk/src/rt/worker.c

Modified: brlcad/trunk/src/rt/do.c
===================================================================
--- brlcad/trunk/src/rt/do.c    2011-08-03 23:28:47 UTC (rev 45778)
+++ brlcad/trunk/src/rt/do.c    2011-08-04 01:15:44 UTC (rev 45779)
@@ -588,14 +588,6 @@
     quat_t quat;
     char *env_str;
     
-    /* TODO: Read from command line */
-    /* Read from ENV with we're going to use the experimental mode */
-    env_str = getenv("LIBRT_EXP_MODE");
-    if(env_str != NULL){
-       full_incr_mode = 1;
-       full_incr_nsamples = 10;
-    }
-
     if (rt_verbosity & VERBOSE_FRAMENUMBER)
        bu_log("\n...................Frame %5d...................\n",
               framenumber);

Modified: brlcad/trunk/src/rt/ext.h
===================================================================
--- brlcad/trunk/src/rt/ext.h   2011-08-03 23:28:47 UTC (rev 45778)
+++ brlcad/trunk/src/rt/ext.h   2011-08-04 01:15:44 UTC (rev 45779)
@@ -47,6 +47,7 @@
 extern int sub_ymin;
 extern int transpose_grid;             /* reverse the order of grid traversal 
*/
 extern int use_air;                    /* Handling of air in librt */
+extern int random_mode;                 /* Mode to shoot rays at random 
directions */
 
 /***** variables from main.c *****/
 extern FILE *outfp;                    /* optional output file */

Modified: brlcad/trunk/src/rt/opt.c
===================================================================
--- brlcad/trunk/src/rt/opt.c   2011-08-03 23:28:47 UTC (rev 45778)
+++ brlcad/trunk/src/rt/opt.c   2011-08-04 01:15:44 UTC (rev 45779)
@@ -95,6 +95,7 @@
 int            npsw = 1;               /* number of worker PSWs to run */
 struct resource        resource[MAX_PSW];      /* memory resources */
 int            transpose_grid = 0;     /* reverse the order of grid traversal 
*/
+int             random_mode = 0;        /* Mode to shoot rays at random 
directions */
 /***** end variables shared with worker() *****/
 
 /***** Photon Mapping Variables *****/
@@ -174,6 +175,7 @@
 {
     register int c;
     register int i;
+    char *env_str;              
 
     bu_optind = 1;             /* restart */
 
@@ -632,6 +634,21 @@
     if (R_DEBUG & RDEBUG_RTMEM_END)
        bu_debug |= BU_DEBUG_MEM_CHECK;
 
+    /* TODO: add options instead of reading from ENV */
+    env_str = getenv("LIBRT_RAND_MODE");
+    if(env_str != NULL && atoi(env_str) == 1){
+       random_mode = 1;
+       bu_log("random mode\n");
+    }
+    /* TODO: Read from command line */
+    /* Read from ENV with we're going to use the experimental mode */
+    env_str = getenv("LIBRT_EXP_MODE");
+    if(env_str != NULL && atoi(env_str) == 1){
+       full_incr_mode = 1;
+       full_incr_nsamples = 10;
+       bu_log("multi-sample mode\n");
+    }
+
     return 1;                  /* OK */
 }
 

Modified: brlcad/trunk/src/rt/view.c
===================================================================
--- brlcad/trunk/src/rt/view.c  2011-08-03 23:28:47 UTC (rev 45778)
+++ brlcad/trunk/src/rt/view.c  2011-08-04 01:15:44 UTC (rev 45779)
@@ -1507,9 +1507,8 @@
        buf_mode = BUFMODE_INCR;
     } else if (full_incr_mode){
        buf_mode = BUFMODE_ACC;
-       /* buf_mode = BUFMODE_SCANLINE; */
     }
-    else if (width <= 96) {
+    else if (width <= 96 || random_mode) {
        buf_mode = BUFMODE_UNBUF;
     } else if ((size_t)npsw <= (size_t)height/4) {
        /* Have each CPU do a whole scanline.  Saves lots of semaphore

Modified: brlcad/trunk/src/rt/worker.c
===================================================================
--- brlcad/trunk/src/rt/worker.c        2011-08-03 23:28:47 UTC (rev 45778)
+++ brlcad/trunk/src/rt/worker.c        2011-08-04 01:15:44 UTC (rev 45779)
@@ -516,6 +516,17 @@
                do_pixel(cpu, pat_num, pixelnum);
            }
        }
+    } else if (random_mode) {
+       
+       while (1) { 
+           /* Generate a random pixel id between 0 and last_pixel
+              inclusive - TODO: check if there is any issue related
+              with multi-threaded RNG */
+           pixelnum = rand()*1.0/RAND_MAX*(last_pixel + 1);
+           if (pixelnum >= last_pixel) pixelnum = last_pixel;
+           do_pixel(cpu, pat_num, pixelnum);
+       }
+
     } else {
        while (1) {
            if (stop_worker)


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts. 
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to