Text archives Help
- From: sparker@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r784 - in trunk: Engine/Control Engine/PixelSamplers Engine/Renderers Interface Model/Materials tests/perftest
- Date: Tue, 13 Dec 2005 14:06:36 -0700 (MST)
Author: sparker
Date: Tue Dec 13 14:06:35 2005
New Revision: 784
Modified:
trunk/Engine/Control/RTRT.cc
trunk/Engine/PixelSamplers/JitterSampler.cc
trunk/Engine/PixelSamplers/JitterSampler.h
trunk/Engine/PixelSamplers/SingleSampler.cc
trunk/Engine/Renderers/Moire.cc
trunk/Engine/Renderers/NullRenderer.cc
trunk/Interface/RayPacket.h
trunk/Model/Materials/Dielectric.cc
trunk/Model/Materials/MetalMaterial.cc
trunk/Model/Materials/Phong.cc
trunk/tests/perftest/perftest1.cc
Log:
Got rid of "localColor" and color pointer in ray packet. Now just use a
single result color.
Consequently, singlesampler cannot use this to directly deposit the result
into the image,
but everything else gets simpler and less error prone. It made a very slight
performance
difference for a micro-benchmark but for real scenes it made no difference at
all, and the
new streamlined version might be slightly faster for raypacket-heavy
computations (although
I couldn't detect a difference on primtest with dielectrics.
For some reason, this made a pretty big (20%) performance drop on the G5 even
though it
should not have. However, when compiling with -malign-natural, there was no
performance difference.
I suspect that there is an alignment problem somewhere and that you shouldn't
see
similar problems elsewhere. However, please let me know about your
performance experience
with this change.
Modified: trunk/Engine/Control/RTRT.cc
==============================================================================
--- trunk/Engine/Control/RTRT.cc (original)
+++ trunk/Engine/Control/RTRT.cc Tue Dec 13 14:06:35 2005
@@ -1266,7 +1266,7 @@
result_rays.resize( 1 );
// Set the image space coordinates of the pixel.
- result_rays.setPixel(0, 0, image_x, image_y, &result_color );
+ result_rays.setPixel(0, 0, image_x, image_y);
result_rays.setFlag ( RayPacket::HaveImageCoordinates );
// Get a pointer to the channel.
@@ -1293,6 +1293,7 @@
// Shade.
result_rays.hitInfo(0).hitMaterial()->shade( render_context, result_rays
);
}
+ result_color = result_rays.getResult(0);
}
Modified: trunk/Engine/PixelSamplers/JitterSampler.cc
==============================================================================
--- trunk/Engine/PixelSamplers/JitterSampler.cc (original)
+++ trunk/Engine/PixelSamplers/JitterSampler.cc Tue Dec 13 14:06:35 2005
@@ -90,8 +90,7 @@
//
// current_fragment_return keeps track of which fragment elements have
// had their color computed.
-void JitterSampler::computeAverages(Fragment& fragment, Color* sample_color,
- int sample_color_size,
+void JitterSampler::computeAverages(Fragment& fragment, const RayPacket&
rays,
int& samples_collected_return,
int& current_fragment_return) {
// Copy the values, so the we can hopefully use the cache when
@@ -99,8 +98,8 @@
int samples_collected = samples_collected_return;
int current_fragment = current_fragment_return;
Color fragment_color = Color::black();
- for(int sample_index = 0; sample_index < sample_color_size;
sample_index++) {
- fragment_color += sample_color[sample_index];
+ for(int sample_index = 0; sample_index < rays.getSize(); sample_index++) {
+ fragment_color += rays.getResult(sample_index);
samples_collected++;
// We've collected enough samples, so compute the average and
// assign it to the fragment.
@@ -153,7 +152,6 @@
Real px, py;
int sample_count = 0;
- Color sample_color[RayPacket::MaxSize];
// No samples accumulated yet.
int samples_collected = 0;
// Index to the first fragment's element.
@@ -189,7 +187,7 @@
}
px = (fe0.x+(x_sample))*ci.xscale+ci.xoffset;
py = (fe0.y+(y_sample))*ci.yscale+ci.yoffset;
- rays.setPixel(sample_count, 0, px, py,
&sample_color[sample_count]);
+ rays.setPixel(sample_count, 0, px, py);
sample_count++;
if (sample_count == RayPacket::MaxSize) {
@@ -197,7 +195,7 @@
rays.resize(sample_count);
context.renderer->traceEyeRays(context, rays);
- computeAverages(fragment, sample_color, rays.getSize(),
+ computeAverages(fragment, rays,
samples_collected, current_fragment);
// Now reset the index, so that we can start filling up
@@ -215,37 +213,7 @@
rays.resize(sample_count);
context.renderer->traceEyeRays(context, rays);
- computeAverages(fragment, sample_color, rays.getSize(),
+ computeAverages(fragment, rays,
samples_collected, current_fragment);
}
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Modified: trunk/Engine/PixelSamplers/JitterSampler.h
==============================================================================
--- trunk/Engine/PixelSamplers/JitterSampler.h (original)
+++ trunk/Engine/PixelSamplers/JitterSampler.h Tue Dec 13 14:06:35 2005
@@ -31,8 +31,7 @@
JitterSampler(const JitterSampler&);
JitterSampler& operator=(const JitterSampler&);
- void computeAverages(Fragment& fragment, Color* sample_color,
- int sample_color_size,
+ void computeAverages(Fragment& fragment, const RayPacket& rays,
int& samples_collected, int& current_fragment);
int num_samples;
Modified: trunk/Engine/PixelSamplers/SingleSampler.cc
==============================================================================
--- trunk/Engine/PixelSamplers/SingleSampler.cc (original)
+++ trunk/Engine/PixelSamplers/SingleSampler.cc Tue Dec 13 14:06:35 2005
@@ -78,7 +78,7 @@
for(int i=0;i<size;i++){
Fragment::Element& fe = fragment.get(f+i);
- rays.setPixel(i, fe.which_eye, px, py, &fe.color);
+ rays.setPixel(i, fe.which_eye, px, py);
px += ci.xscale;
}
@@ -90,11 +90,16 @@
Fragment::Element& fe = fragment.get(f+i);
Real px = fe.x*ci.xscale+ci.xoffset;
Real py = fe.y*ci.yscale+ci.yoffset;
- rays.setPixel(i, fe.which_eye, px, py, &fe.color);
+ rays.setPixel(i, fe.which_eye, px, py);
}
}
// Trace the rays. The results will automatically go into the fragment
context.renderer->traceEyeRays(context, rays);
+
+ for(int i=0;i<size;i++){
+ Fragment::Element& fe = fragment.get(f+i);
+ fe.color = rays.getResult(i);
+ }
}
}
Modified: trunk/Engine/Renderers/Moire.cc
==============================================================================
--- trunk/Engine/Renderers/Moire.cc (original)
+++ trunk/Engine/Renderers/Moire.cc Tue Dec 13 14:06:35 2005
@@ -56,10 +56,10 @@
double phase = context.frameState->frameTime * M_PI;
double cycles = 100;
for(int i=0;i<rays.getSize();i++){
- const RayPacket::Element& p = rays.get(i);
+ RayPacket::Element& p = rays.get(i);
double dist2 = p.imageX*p.imageX + p.imageY*p.imageY;
double val = cos(dist2*2*M_PI*cycles+phase)/2+0.5;
- *p.color = Color(GrayColor(val));
+ p.color = Color(GrayColor(val));
}
}
Modified: trunk/Engine/Renderers/NullRenderer.cc
==============================================================================
--- trunk/Engine/Renderers/NullRenderer.cc (original)
+++ trunk/Engine/Renderers/NullRenderer.cc Tue Dec 13 14:06:35 2005
@@ -40,7 +40,7 @@
ASSERT(rays.getFlag(RayPacket::HaveImageCoordinates));
for(int i=0;i<rays.getSize();i++){
RayPacket::Element& p = rays.get(i);
- *p.color = Color(RGBColor(0.9, 0.6, 0.3));
+ p.color = color;
}
}
@@ -48,6 +48,6 @@
{
for(int i=0;i<rays.getSize();i++){
RayPacket::Element& p = rays.get(i);
- *p.color = color;
+ p.color = color;
}
}
Modified: trunk/Interface/RayPacket.h
==============================================================================
--- trunk/Interface/RayPacket.h (original)
+++ trunk/Interface/RayPacket.h Tue Dec 13 14:06:35 2005
@@ -84,8 +84,7 @@
#ifndef SWIG // SWIG doesn't support nested structs/classes.
struct Element {
- Color localColor;
- Color* color;
+ Color color;
Real imageX;
Real imageY;
Ray ray;
@@ -110,25 +109,24 @@
return data[which];
}
#endif // SWIG
- void setPixel(int which, int whichEye, Real imageX, Real imageY,
- Color* color) {
- data[which].color = color;
+ void setPixel(int which, int whichEye, Real imageX, Real imageY)
+ {
data[which].imageX = imageX;
data[which].imageY = imageY;
data[which].whichEye = whichEye;
}
- void useLocalColors() {
- for(int i=0;i<size;i++)
- data[i].color = &data[i].localColor;
- }
HitInfo& hitInfo(int which) {
return data[which].hitInfo;
}
void setResult(int which, const Color& color)
{
- *data[which].color = color;
+ data[which].color = color;
+ }
+ const Color& getResult(int which) const
+ {
+ return data[which].color;
}
void normalizeDirections()
Modified: trunk/Model/Materials/Dielectric.cc
==============================================================================
--- trunk/Model/Materials/Dielectric.cc (original)
+++ trunk/Model/Materials/Dielectric.cc Tue Dec 13 14:06:35 2005
@@ -97,7 +97,7 @@
for(int i=0;i<rays.getSize();i++)
{
RayPacket::Element& e = rays.get(i);
- *e.color = Color::black();
+ e.color = Color::black();
Real n_dot_v = Dot(e.normal, e.ray.direction());
Real eta_tmp_inv;
@@ -168,10 +168,6 @@
// Resize the packets.
reflected_rays.resize(num_refl);
refracted_rays.resize(num_refr);
- // Use the local storage of the colors. We need to call this after
- // we figure out the size of our ray packet.
- reflected_rays.useLocalColors();
- refracted_rays.useLocalColors();
// Trace the rays.
if(num_refl)
@@ -184,12 +180,12 @@
{
RayPacket::Element& r = reflected_rays.get(i);
RayPacket::Element& e = rays.get(refl_source[i]);
- *e.color += refl_attenuation[i] * r.localColor;
+ e.color += refl_attenuation[i] * r.color;
}
for (int i = 0; i < num_refr; i++)
{
RayPacket::Element& r = refracted_rays.get(i);
RayPacket::Element& e = rays.get(refr_source[i]);
- *e.color += refr_attenuation[i] * r.localColor;
+ e.color += refr_attenuation[i] * r.color;
}
}
Modified: trunk/Model/Materials/MetalMaterial.cc
==============================================================================
--- trunk/Model/Materials/MetalMaterial.cc (original)
+++ trunk/Model/Materials/MetalMaterial.cc Tue Dec 13 14:06:35 2005
@@ -42,7 +42,6 @@
RayPacketData rdata;
RayPacket refl_rays(rdata, rays.getSize(), rays.getDepth()+1,
RayPacket::NormalizedDirections);
- refl_rays.useLocalColors();
for(int i=0;i<rays.getSize();i++)
{
RayPacket::Element& e = rays.get(i);
@@ -70,7 +69,7 @@
ColorComponent kc = (ColorComponent)k;
Color R = specular[i] * (1-kc) + Color::white()*kc;
- *e.color = R * (*r.color);
+ e.color = R * r.color;
}
} else {
// Stuff black in it.
Modified: trunk/Model/Materials/Phong.cc
==============================================================================
--- trunk/Model/Materials/Phong.cc (original)
+++ trunk/Model/Materials/Phong.cc Tue Dec 13 14:06:35 2005
@@ -111,7 +111,6 @@
RayPacketData rdata;
RayPacket refl_rays(rdata, rays.getSize(), rays.getDepth()+1,
RayPacket::NormalizedDirections);
- refl_rays.useLocalColors();
for(int i=0;i<rays.getSize();i++){
RayPacket::Element& e = rays.get(i);
Vector refl_dir = (e.ray.direction() -
@@ -125,7 +124,7 @@
for(int i=0;i<rays.getSize();i++){
RayPacket::Element& e = rays.get(i);
RayPacket::Element& r = refl_rays.get(i);
- *e.color += *r.color * refl[i];
+ e.color += r.color * refl[i];
}
}
}
Modified: trunk/tests/perftest/perftest1.cc
==============================================================================
--- trunk/tests/perftest/perftest1.cc (original)
+++ trunk/tests/perftest/perftest1.cc Tue Dec 13 14:06:35 2005
@@ -47,7 +47,6 @@
RayPacket rays(data, RayPacket::MaxSize, 0,
RayPacket::NormalizedDirections);
//RayPacket rays(data, RayPacket::MaxSize, 0, 0);
rays.resetHit();
- rays.useLocalColors();
for(int i=0;i<rays.getSize();i++){
RayPacket::Element& e = rays.get(i);
e.ray = Ray(Point(0, 0, 10), Vector(0, 0, 1));
- [MANTA] r784 - in trunk: Engine/Control Engine/PixelSamplers Engine/Renderers Interface Model/Materials tests/perftest, sparker, 12/13/2005
Archive powered by MHonArc 2.6.16.