Text archives Help
- From: boulos@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r971 - in trunk: Core/Color Engine/Control Engine/PixelSamplers Model/Groups
- Date: Sat, 4 Mar 2006 22:29:53 -0700 (MST)
Author: boulos
Date: Sat Mar 4 22:29:51 2006
New Revision: 971
Added:
trunk/Engine/PixelSamplers/FastSampler.cc
trunk/Engine/PixelSamplers/FastSampler.h
Modified:
trunk/Core/Color/ColorSpace.h
trunk/Engine/Control/RTRT_register.cc
trunk/Engine/PixelSamplers/CMakeLists.txt
trunk/Model/Groups/CMakeLists.txt
Log:
Removing private from ColorSpace component data
so that loops may be hand inlined over color
components (see FastSampler).
Adding a new FastSampler for playing around with
making PixelSampling faster. Overall performance
for ray generation and copying of color values is
25% faster on my laptop.
Modified: trunk/Core/Color/ColorSpace.h
==============================================================================
--- trunk/Core/Color/ColorSpace.h (original)
+++ trunk/Core/Color/ColorSpace.h Sat Mar 4 22:29:51 2006
@@ -207,7 +207,7 @@
// (the implementation) in another header file called
// ColorSpace_fancy.h. If you want to use this function include
// that header file and it will get instantiated properly.
- std::string toString() const;
+ std::string toString() const;
template<typename Scalar>
ColorSpace<Traits> Pow(Scalar exponent) const
@@ -241,7 +241,7 @@
return Traits::luminance(data);
}
- protected:
+// protected:
// DO NOT MAKE THIS PUBLIC!
ComponentType data[NumComponents];
ColorSpace(ComponentType fillValue) {
Modified: trunk/Engine/Control/RTRT_register.cc
==============================================================================
--- trunk/Engine/Control/RTRT_register.cc (original)
+++ trunk/Engine/Control/RTRT_register.cc Sat Mar 4 22:29:51 2006
@@ -14,6 +14,7 @@
#include <Engine/LoadBalancers/CyclicLoadBalancer.h>
#include <Engine/LoadBalancers/SimpleLoadBalancer.h>
#include <Engine/LoadBalancers/WQLoadBalancer.h>
+#include <Engine/PixelSamplers/FastSampler.h>
#include <Engine/PixelSamplers/NullSampler.h>
#include <Engine/PixelSamplers/SingleSampler.h>
#include <Engine/PixelSamplers/JitterSampler.h>
@@ -72,6 +73,7 @@
engine->registerComponent("workqueue", &WQLoadBalancer::create);
// Register pixel samplers
+ engine->registerComponent("fast", &FastSampler::create);
engine->registerComponent("null", &NullSampler::create);
engine->registerComponent("singlesample", &SingleSampler::create);
engine->registerComponent("jittersample", &JitterSampler::create);
Modified: trunk/Engine/PixelSamplers/CMakeLists.txt
==============================================================================
--- trunk/Engine/PixelSamplers/CMakeLists.txt (original)
+++ trunk/Engine/PixelSamplers/CMakeLists.txt Sat Mar 4 22:29:51 2006
@@ -1,5 +1,7 @@
SET (Manta_PixelSamplers_SRCS
+ PixelSamplers/FastSampler.h
+ PixelSamplers/FastSampler.cc
PixelSamplers/JitterSampler.h
PixelSamplers/JitterSampler.cc
PixelSamplers/NullSampler.h
Added: trunk/Engine/PixelSamplers/FastSampler.cc
==============================================================================
--- (empty file)
+++ trunk/Engine/PixelSamplers/FastSampler.cc Sat Mar 4 22:29:51 2006
@@ -0,0 +1,113 @@
+
+#include <Engine/PixelSamplers/FastSampler.h>
+#include <Interface/Context.h>
+#include <Interface/Fragment.h>
+#include <Interface/RayPacket.h>
+#include <Interface/Renderer.h>
+using namespace Manta;
+
+PixelSampler* FastSampler::create(const vector<string>& args)
+{
+ return new FastSampler(args);
+}
+
+FastSampler::FastSampler(const vector<string>& /* args */)
+{
+}
+
+FastSampler::~FastSampler()
+{
+}
+
+void FastSampler::setupBegin(const SetupContext& context, int numChannels)
+{
+ channelInfo.resize(numChannels);
+ context.renderer->setupBegin(context, numChannels);
+}
+
+void FastSampler::setupDisplayChannel(SetupContext& context)
+{
+ ChannelInfo& ci = channelInfo[context.channelIndex];
+ bool stereo;
+ int xres, yres;
+ context.getResolution(stereo, xres, yres);
+
+ // Set up the scale from -1 to 1
+ ci.xscale = (Real)2/xres;
+ ci.yscale = ci.xscale;
+ ci.xoffset = (-xres/(Real)2+(Real)0.5)*ci.xscale; // Offset to pixel center
+ ci.yoffset = (-yres/(Real)2+(Real)0.5)*ci.yscale;
+ context.renderer->setupDisplayChannel(context);
+}
+
+void FastSampler::setupFrame(const RenderContext& context)
+{
+ context.renderer->setupFrame(context);
+}
+
+void FastSampler::renderFragment(const RenderContext& context,
+ Fragment& fragment)
+{
+ ChannelInfo& ci = channelInfo[context.channelIndex];
+ int flags = RayPacket::HaveImageCoordinates;
+ if(fragment.getFlags() & Fragment::ConstantEye)
+ flags |= RayPacket::ConstantEye;
+ for(int f=0;f<fragment.getSize();f+=RayPacket::MaxSize){
+ // We want to fill our RayPacket with as many as
+ // RayPacket::MaxSize rays.
+ int size = RayPacket::MaxSize;
+ if(size >= fragment.getSize()-f)
+ // We don't have enough fragments left to fill a ray packet, so
+ // set the size of the RayPacket to the number of fragments we
+ // have left.
+ size = fragment.getSize()-f;
+ // Create a ray packet
+ int depth = 0;
+ RayPacketData raydata;
+ RayPacket rays(raydata, 0, size, depth, flags);
+
+ // Check to see if the fragment is consecutive in x.
+ if(fragment.getFlags() & Fragment::ConsecutiveX){
+
+ // If so place each pixel in the ray packet relative to the first
+ // fragment.
+ Fragment::Element& fe0 = fragment.get(f);
+ Real px = fe0.x*ci.xscale+ci.xoffset;
+ Real py = fe0.y*ci.yscale+ci.yoffset;
+
+ for(int i=0;i<size;i++){
+ Fragment::Element& fe = fragment.get(f+i);
+ rays.setPixel(i, fe.which_eye, px, py);
+ px += ci.xscale;
+ }
+
+ }
+
+ // Otherwise, set each pixel individually.
+ else {
+ for(int i=0;i<size;i++){
+ 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);
+ }
+ }
+
+ // Trace the rays. The results will automatically go into the fragment
+ context.renderer->traceEyeRays(context, rays);
+
+#if 0 // old code
+ for(int i=0;i<size;i++){
+ Fragment::Element& fe = fragment.get(f+i);
+ fe.color = rays.getColor(i);
+ }
+#else
+ for(int i=0;i<size;i++)
+ {
+ Fragment::Element& fe = fragment.get(f+i);
+ for ( int c = 0; c < Color::NumComponents; c++ )
+ fe.color.data[c] = raydata.color[c][i];
+ }
+#endif
+ }
+}
Added: trunk/Engine/PixelSamplers/FastSampler.h
==============================================================================
--- (empty file)
+++ trunk/Engine/PixelSamplers/FastSampler.h Sat Mar 4 22:29:51 2006
@@ -0,0 +1,39 @@
+
+#ifndef Manta_Engine_FastSampler_h
+#define Manta_Engine_FastSampler_h
+
+#include <MantaTypes.h>
+#include <Interface/PixelSampler.h>
+#include <sgi_stl_warnings_off.h>
+#include <string>
+#include <vector>
+#include <sgi_stl_warnings_on.h>
+
+namespace Manta {
+ using namespace std;
+ class FastSampler : public PixelSampler {
+ public:
+ FastSampler(const vector<string>& args);
+ virtual ~FastSampler();
+ virtual void setupBegin(const SetupContext&, int numChannels);
+ virtual void setupDisplayChannel(SetupContext&);
+ virtual void setupFrame(const RenderContext& context);
+ virtual void renderFragment(const RenderContext& context,
+ Fragment& fragment);
+
+ static PixelSampler* create(const vector<string>& args);
+ private:
+ FastSampler(const FastSampler&);
+ FastSampler& operator=(const FastSampler&);
+
+ struct ChannelInfo {
+ Real xscale;
+ Real xoffset;
+ Real yscale;
+ Real yoffset;
+ };
+ vector<ChannelInfo> channelInfo;
+ };
+}
+
+#endif
Modified: trunk/Model/Groups/CMakeLists.txt
==============================================================================
--- trunk/Model/Groups/CMakeLists.txt (original)
+++ trunk/Model/Groups/CMakeLists.txt Sat Mar 4 22:29:51 2006
@@ -30,25 +30,3 @@
Groups/varray.h
)
-# Determine if VerticalKDTree can be included
-IF(${MANTA_REAL} MATCHES float)
- SET(Manta_Groups_SRCS
- ${Manta_Groups_SRCS}
- Groups/SSEKDTree.cc
- Groups/SSEKDTree.h
- Groups/VerticalKDTree.h
- Groups/VerticalKDTree.cc
- )
-
-# Otherwise include a stub implementation.
-ELSE(${MANTA_REAL} MATCHES float)
- SET(Manta_Groups_SRCS
- ${Manta_Groups_SRCS}
- Groups/SSEKDTree-stub.cc
- Groups/SSEKDTree.h
- Groups/VerticalKDTree.h
- Groups/VerticalKDTree-stub.cc
- )
-ENDIF(${MANTA_REAL} MATCHES float)
-
-
- [MANTA] r971 - in trunk: Core/Color Engine/Control Engine/PixelSamplers Model/Groups, boulos, 03/04/2006
Archive powered by MHonArc 2.6.16.