![]() |
Shadowrun: Awakened 29 September 2011 - Build 871
|
#include "machine.h"#include "types.h"#include "macros.h"#include "vector.h"#include "tgafile.h"#include "trace.h"#include "light.h"#include "shade.h"#include "camera.h"#include "util.h"#include "intersect.h"#include "global.h"#include "ui.h"#include "video.h"#include "tbb/task_scheduler_init.h"#include "tbb/parallel_for.h"#include "tbb/spin_mutex.h"#include "tbb/blocked_range2d.h"
Include dependency graph for trace.tbb.cpp:Go to the source code of this file.
Classes | |
| class | parallel_task |
Functions | |
| static color_t | render_one_pixel (int x, int y, unsigned int *local_mbox, unsigned int &serial, int startx, int stopx, int starty, int stopy) |
| void * | thread_trace (thr_parms *parms) |
Variables | |
| static thr_parms * | all_parms |
| static flt | jitterscale |
| static tbb::spin_mutex | MyMutex |
| static tbb::spin_mutex | MyMutex2 |
| static scenedef | scene |
| static int | startx |
| static int | starty |
| static int | stopx |
| static int | stopy |
| static int | totaly |
| static color_t render_one_pixel | ( | int | x, |
| int | y, | ||
| unsigned int * | local_mbox, | ||
| unsigned int & | serial, | ||
| int | startx, | ||
| int | stopx, | ||
| int | starty, | ||
| int | stopy | ||
| ) | [static] |
Definition at line 90 of file trace.tbb.cpp.
References scenedef::antialiasing, color::b, camray(), ray::d, FHUGE, ray::flags, color::g, video::get_color(), ray::intstruct, jitterscale, ray::maxdist, ray::mbox, color::r, RT_RAY_REGULAR, scene, ray::scene, ray::serial, trace(), vector::x, vector::y, and vector::z.
{
/* private vars moved inside loop */
ray primary, sample;
color col, avcol;
int R,G,B;
intersectstruct local_intersections;
int alias;
/* end private */
primary=camray(&scene, x, y);
primary.intstruct = &local_intersections;
primary.flags = RT_RAY_REGULAR;
serial++;
primary.serial = serial;
primary.mbox = local_mbox;
primary.maxdist = FHUGE;
primary.scene = &scene;
col=trace(&primary);
serial = primary.serial;
/* perform antialiasing if enabled.. */
if (scene.antialiasing > 0) {
for (alias=0; alias < scene.antialiasing; alias++) {
serial++; /* increment serial number */
sample=primary; /* copy the regular primary ray to start with */
sample.serial = serial;
{
tbb::spin_mutex::scoped_lock lock (MyMutex);
sample.d.x+=((rand() % 100) - 50) / jitterscale;
sample.d.y+=((rand() % 100) - 50) / jitterscale;
sample.d.z+=((rand() % 100) - 50) / jitterscale;
}
avcol=trace(&sample);
serial = sample.serial; /* update our overall serial # */
col.r += avcol.r;
col.g += avcol.g;
col.b += avcol.b;
}
col.r /= (scene.antialiasing + 1.0);
col.g /= (scene.antialiasing + 1.0);
col.b /= (scene.antialiasing + 1.0);
}
/* Handle overexposure and underexposure here... */
R=(int) (col.r*255);
if (R > 255) R = 255;
else if (R < 0) R = 0;
G=(int) (col.g*255);
if (G > 255) G = 255;
else if (G < 0) G = 0;
B=(int) (col.b*255);
if (B > 255) B = 255;
else if (B < 0) B = 0;
return video->get_color(R, G, B);
}
| void* thread_trace | ( | thr_parms * | parms | ) |
Definition at line 184 of file trace.tbb.cpp.
References tbb::task_scheduler_init::automatic, g, scenedef::hres, jitterscale, tbb::parallel_for(), thr_parms::scene, thr_parms::startx, startx, thr_parms::starty, starty, thr_parms::stopx, stopx, thr_parms::stopy, stopy, totaly, and scenedef::vres.
{
int n, nthreads = tbb::task_scheduler_init::automatic;
char *nthreads_str = getenv ("TBB_NUM_THREADS");
if (nthreads_str && (sscanf (nthreads_str, "%d", &n) > 0) && (n > 0)) nthreads = n;
tbb::task_scheduler_init init (nthreads);
// shared but read-only so could be private too
all_parms = parms;
scene = parms->scene;
startx = parms->startx;
stopx = parms->stopx;
starty = parms->starty;
stopy = parms->stopy;
jitterscale = 40.0*(scene.hres + scene.vres);
totaly = parms->scene.vres;
int g, grain_size = 50;
char *grain_str = getenv ("TBB_GRAINSIZE");
if (grain_str && (sscanf (grain_str, "%d", &g) > 0) && (g > 0)) grain_size = g;
tbb::parallel_for (tbb::blocked_range2d<int> (starty, stopy, grain_size, startx, stopx, grain_size), parallel_task (), tbb::simple_partitioner());
return(NULL);
}
Definition at line 74 of file trace.tbb.cpp.
flt jitterscale [static] |
Definition at line 80 of file trace.tbb.cpp.
Referenced by render_one_pixel(), and thread_trace().
tbb::spin_mutex MyMutex [static] |
Definition at line 88 of file trace.tbb.cpp.
Definition at line 88 of file trace.tbb.cpp.
Definition at line 75 of file trace.tbb.cpp.
Referenced by render_one_pixel().
int startx [static] |
Definition at line 76 of file trace.tbb.cpp.
Referenced by thread_trace().
int starty [static] |
Definition at line 78 of file trace.tbb.cpp.
Referenced by thread_trace().
int stopx [static] |
Definition at line 77 of file trace.tbb.cpp.
Referenced by thread_trace().
int stopy [static] |
Definition at line 79 of file trace.tbb.cpp.
Referenced by thread_trace().
int totaly [static] |
Definition at line 81 of file trace.tbb.cpp.
Referenced by thread_trace().
Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.